From 58ef6155a84a1bba50fc5ff9e68e7d363c05c8ef Mon Sep 17 00:00:00 2001 From: Sebastian Greaves Date: Wed, 12 Dec 2018 12:03:51 +0000 Subject: [PATCH] Update changes missed with the 0.42.0 fix --- types/slate-react/index.d.ts | 13 ++--- types/slate/index.d.ts | 101 +++-------------------------------- 2 files changed, 10 insertions(+), 104 deletions(-) diff --git a/types/slate-react/index.d.ts b/types/slate-react/index.d.ts index 540316befc..30e54f2a02 100644 --- a/types/slate-react/index.d.ts +++ b/types/slate-react/index.d.ts @@ -6,7 +6,7 @@ // Patrick Sachs // Brandon Shelton // Irwan Fario Subastian -// Sebastian Greaves +// Hanna Greaves // Francesco Agnoletto // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.8 @@ -18,8 +18,7 @@ import { Block, Inline, Operations, - Schema, - Stack, + SchemaProperties, Value, Operation, MarkProperties, @@ -112,7 +111,7 @@ export interface BasicEditorProps { plugins?: Plugin[]; readOnly?: boolean; role?: string; - schema?: Schema; + schema?: SchemaProperties; spellCheck?: boolean; style?: React.CSSProperties; tabIndex?: number; @@ -121,15 +120,11 @@ export interface BasicEditorProps { export type EditorProps = BasicEditorProps & Plugin; export interface EditorState { - schema: Schema; value: Value; - stack: Stack; } export class Editor extends React.Component implements Controller { controller: CoreEditor; - schema: Schema; - stack: Stack; readonly plugins: Plugin[]; readonly operations: Immutable.List; @@ -137,7 +132,7 @@ export class Editor extends React.Component implements readonly value: Value; // Instance methods - resolveController(plugins: Plugin[], schema: Schema, commands: any[], queries: any[]): void; + resolveController(plugins: Plugin[], schema: SchemaProperties, commands: any[], queries: any[]): void; // Controller addMark: CoreEditor['addMark']; diff --git a/types/slate/index.d.ts b/types/slate/index.d.ts index 9ee697cb43..6eb42ec623 100644 --- a/types/slate/index.d.ts +++ b/types/slate/index.d.ts @@ -53,39 +53,10 @@ export interface SchemaProperties { inlines?: RulesByNodeType; } -export class Schema extends Immutable.Record({}) { - stack: Stack; - rules: Rules[]; - - static create(properties: SchemaProperties | Schema): Schema; - static fromJSON(object: SchemaProperties): Schema; - static fromJS(object: SchemaProperties): Schema; - static isSchema(maybeSchema: any): maybeSchema is Schema; - - validateNode(node: Node): Error | void; - testNode(node: Node): boolean; - assertNode(node: Node): boolean; - getNodeRules(node: Node): any[]; - isVoid(node: Node): boolean; - isAtomic(mark: Mark): boolean; - normalizeNode(node: Node): () => void; - testRules(object: any, rules: object | any[]): boolean; - validateRules( - object: any, - rule: object | any[], - rules: any[] | null, - options?: object - ): Error | void; - - toJSON(): SchemaProperties; - toJS(): SchemaProperties; -} - export interface ValueProperties { document?: Document; selection?: Selection; history?: History; - schema?: Schema; data?: Data; decorations?: Immutable.List | null; } @@ -94,7 +65,6 @@ export interface ValueJSON { document?: DocumentJSON; selection?: Selection; history?: History; - schema?: Schema; data?: Data; decorations?: Immutable.List | null; object?: "value"; @@ -106,7 +76,6 @@ export class Value extends Immutable.Record({}) { document: Document; selection: Selection; history: History; - schema: Schema; data: Data; object: "value"; decorations: Immutable.List; @@ -350,9 +319,6 @@ export class Text extends Immutable.Record({}) { ): Text; splitText(offset: number): Text[]; mergeText(text: Text): Text; - normalize(schema: Schema): () => void | null; - validate(schema: Schema): Error | null; - getFirstInvalidNode(schema: Schema): Text | null; setLeaves(leaves: Immutable.List): Text; } @@ -446,13 +412,13 @@ declare class BaseNode< getChild(path: Path): Node | null; getClosestBlock(path: Path): Block | null; getClosestInline(path: Path): Inline | null; - getClosestVoid(path: Path, schema: Schema): Node | null; + getClosestVoid(path: Path): Node | null; + getClosestVoid(key: string): Node | null; getClosest(path: Path, iterator: (node: Node) => boolean): Node | null; getCommonAncestor(a: Path, b: Path): Node; - getDecorations(stack: Stack): Immutable.List; + getDecorations(editor: Editor): Immutable.List; getDepth(path: Path, startAt?: number): number; getDescendant(path: Path): Node | null; - getFirstInvalidNode(schema: Schema): Node | null; getFirstText(): Text | null; getFragmentAtRange(range: Range): Document; getFurthest(path: Path, iterator: (node: Node) => boolean): Node | null; @@ -514,7 +480,7 @@ declare class BaseNode< hasInlineChildren(): boolean; hasDescendant(path: Path): boolean; hasNode(path: Path): boolean; - hasVoidParent(path: Path, schema: Schema): boolean; + hasVoidParent(path: Path, editor: Editor): boolean; insertNode(path: Path, node: Node): Node; insertText( path: Path, @@ -528,7 +494,7 @@ declare class BaseNode< mapDescendants(iterator: () => void): Node; mergeNode(path: Path): Node; moveNode(path: Path, newPath: Path, newIndex?: number): Node; - normalize(schema: Schema): () => void | void; + normalize(editor: Editor): () => void | void; refinedNOde(path: Path, key: string): Node | null; refindPath(path: Path, key: string): Immutable.List | null; regenerateKey(): Node; @@ -548,7 +514,7 @@ declare class BaseNode< properties: MarkProperties ): Node; splitNode(path: Path, position: number, properties: NodeProperties): Node; - validate(schema: Schema): Error | void; + validate(editor: Editor): Error | void; } export interface MarkProperties { @@ -914,61 +880,6 @@ export interface Operations { invert: (operation: Operation) => Operation; } -export interface StackProperties { - plugins?: any[]; -} - -export interface StackJSON { - object: "stack"; - plugins: any[]; -} - -export class Stack extends Immutable.Record({}) { - object: "stack"; - plugins: any[]; - - static create(attrs: StackProperties): Stack; - static isStack(maybeStack: any): maybeStack is Stack; - - static fromJSON(properties: StackJSON): Stack; - static fromJS(properties: StackJSON): Stack; - toJSON(options: any): object; -} - -export interface HistoryProperties { - undos?: Operation[]; - redos?: Operation[]; -} - -export interface HistoryJSON { - object: "history"; - undos: any[]; - redos: any[]; -} - -export interface HistoryOptions { - merge?: boolean; - skip?: boolean; -} - -export class History extends Immutable.Record({}) { - redos: Stack; - undos: Stack; - object: "history"; - - static create(attrs: History | HistoryProperties): History; - static createOperationsList( - oeprations?: Immutable.List | Operation[] - ): Immutable.List; - static fromJSON(object: HistoryJSON): History; - static fromJS(object: HistoryJSON): History; - static isHistory(maybeHistory: any): maybeHistory is History; - - save(operation: Operation, options?: HistoryOptions): History; - toJSON(): HistoryJSON; - toJS(): HistoryJSON; -} - export type ErrorCode = | "child_object_invalid" | "child_required"