Created
June 27, 2018 19:46
-
-
Save twavv/b2b144b4d6b6cff1eaac3023f3106e98 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as Slate from "slate"; | |
const enum SchemaViolation { | |
CHILD_OBJECT_INVALID = "child_object_invalid", | |
CHILD_REQUIRED = "child_required", | |
CHILD_TYPE_INVALID = "child_type_invalid", | |
CHILD_UNKNOWN = "child_unknown", | |
FIRST_CHILD_OBJECT_INVALID = "first_child_object_invalid", | |
FIRST_CHILD_TYPE_INVALID = "first_child_type_invalid", | |
LAST_CHILD_OBJECT_INVALID = "last_child_object_invalid", | |
LAST_CHILD_TYPE_INVALID = "last_child_type_invalid", | |
NODE_DATA_INVALID = "node_data_invalid", | |
NODE_IS_VOID_INVALID = "node_is_void_invalid", | |
NODE_MARK_INVALID = "node_mark_invalid", | |
NODE_TEXT_INVALID = "node_text_invalid", | |
PARENT_OBJECT_INVALID = "parent_object_invalid", | |
PARENT_TYPE_INVALID = "parent_type_invalid", | |
} | |
export default SchemaViolation; | |
export interface CommonViolationContext { | |
node: Slate.Node; | |
rule: Slate.Rules; | |
} | |
export interface ChildObjectInvalidContext extends CommonViolationContext { | |
child: Slate.Node; | |
index: number; | |
} | |
export interface ChildRequiredContext extends CommonViolationContext { | |
index: number; | |
} | |
export interface ChildTypeInvalidContext extends CommonViolationContext { | |
child: Slate.Node; | |
index: number; | |
} | |
export interface ChildUnknownContext extends CommonViolationContext { | |
child: Slate.Node; | |
index: number; | |
} | |
export interface FirstChildObjectInvalidContext extends CommonViolationContext { | |
child: Slate.Node; | |
} | |
export interface FirstChildTypeInvalidContext extends CommonViolationContext { | |
child: Slate.Node; | |
} | |
export interface LastChildObjectInvalidContext extends CommonViolationContext { | |
child: Slate.Node; | |
} | |
export interface LastChildTypeInvalidContext extends CommonViolationContext { | |
child: Slate.Node; | |
} | |
export interface NodeDataInvalidContext extends CommonViolationContext { | |
key: string; | |
value: any; | |
} | |
export interface NodeIsVoidInvalidContext extends CommonViolationContext {} | |
export interface NodeMarkInvalidContext extends CommonViolationContext { | |
mark: Slate.Mark; | |
} | |
export interface NodeTextInvalidContext extends CommonViolationContext { | |
text: string; | |
} | |
export interface ParentObjectInvalidContext extends CommonViolationContext { | |
parent: Slate.Node; | |
} | |
export interface ParentTypeInvalidContext extends CommonViolationContext { | |
parent: Slate.Node; | |
} | |
export type ViolationContext | |
= ChildObjectInvalidContext | ChildRequiredContext | |
| ChildTypeInvalidContext | ChildUnknownContext | |
| FirstChildObjectInvalidContext | FirstChildTypeInvalidContext | |
| LastChildObjectInvalidContext | LastChildTypeInvalidContext | |
| NodeDataInvalidContext | NodeIsVoidInvalidContext | |
| NodeMarkInvalidContext | NodeTextInvalidContext | |
| ParentObjectInvalidContext | ParentTypeInvalidContext; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment