diff --git a/types/slate/index.d.ts b/types/slate/index.d.ts index 3d971fa3fa..eac4822d6d 100644 --- a/types/slate/index.d.ts +++ b/types/slate/index.d.ts @@ -790,91 +790,107 @@ export type Operation = export interface InsertTextOperation { type: "insert_text"; - path: number[]; + path: Path; offset: number; text: string; marks: Mark[]; + data: Data; } export interface RemoveTextOperation { type: "remove_text"; - path: number[]; + path: Path; offset: number; text: string; + data: Data; } export interface AddMarkOperation { type: "add_mark"; - path: number[]; + path: Path; offset: number; length: number; mark: Mark; + data: Data; } export interface RemoveMarkOperation { type: "remove_mark"; - path: number[]; + path: Path; offset: number; length: number; mark: Mark; + data: Data; } export interface SetMarkOperation { type: "set_mark"; - path: number[]; + path: Path; offset: number; length: number; - mark: Mark; properties: MarkProperties; + newProperties: MarkProperties; + data: Data; } export interface InsertNodeOperation { type: "insert_node"; - path: number[]; + path: Path; node: Node; + data: Data; } export interface MergeNodeOperation { type: "merge_node"; - path: number[]; + path: Path; position: number; + properties: NodeProperties; + data: Data; } export interface MoveNodeOperation { type: "move_node"; - path: number[]; - newPath: number[]; + path: Path; + newPath: Path | number[]; + data: Data; } export interface RemoveNodeOperation { type: "remove_node"; - path: number[]; + path: Path; node: Node; + data: Data; } export interface SetNodeOperation { type: "set_node"; - path: number[]; - properties: BlockProperties | InlineProperties | TextProperties; + path: Path; + properties: NodeProperties; + newProperties: NodeProperties; + data: Data; } export interface SplitNodeOperation { type: "split_node"; - path: number[]; + path: Path; position: number; target: number; + properties: NodeProperties; + data: Data; } export interface SetSelectionOperation { type: "set_selection"; - properties: RangeProperties; - selection: Range; + properties: SelectionProperties; + newProperties: SelectionProperties; + data: Data; } export interface SetValueOperation { type: "set_value"; properties: ValueProperties; - value: Value; + newProperties: ValueProperties; + data: Data; } export interface Operations { @@ -998,6 +1014,7 @@ export interface EditorProperties { export class Editor implements Controller { object: "editor"; onChange: (change: { operations: Immutable.List, value: Value }) => void; + operations: Immutable.List; plugins: Plugin[]; readOnly: boolean; value: Value; diff --git a/types/slate/slate-tests.ts b/types/slate/slate-tests.ts index 07a93ca894..98f717b484 100644 --- a/types/slate/slate-tests.ts +++ b/types/slate/slate-tests.ts @@ -15,7 +15,7 @@ import { Node, Command, Query, - Decoration + Decoration, } from "slate"; const data = Data.create({ foo: "bar " }); @@ -356,7 +356,99 @@ editor .wrapNodeByKey("a", inline) .wrapNodeByPath("a", inline) .wrapText("a", "b") -.wrapTextAtRange(range, "a"); +.wrapTextAtRange(range, "a") +.applyOperation({ + type: "insert_text", + path: 'a', + offset: 0, + text: 'text', + marks: [Mark.create({type: 'test_mark'})], + data: Data.create({}) +}) +.applyOperation({ + type: "remove_text", + path: 'a', + offset: 0, + text: 'text', + data: Data.create({}) +}) +.applyOperation({ + type: "add_mark", + path: 'a', + offset: 0, + length: 1, + mark: Mark.create({type: 'test_mark'}), + data: Data.create({}) +}) +.applyOperation({ + type: "remove_mark", + path: 'a', + offset: 0, + length: 1, + mark: Mark.create({type: 'test_mark'}), + data: Data.create({}) +}) +.applyOperation({ + type: "set_mark", + path: 'a', + offset: 0, + length: 1, + properties: {type: 'test_mark'}, + newProperties: {type: 'new_test_mark'}, + data: Data.create({}) +}) +.applyOperation({ + type: "insert_node", + path: 'a', + node: Block.create({type: 'block'}), + data: Data.create({}) +}) +.applyOperation({ + type: "merge_node", + path: 'a', + position: 0, + properties: {type: 'node'}, + data: Data.create({}) +}) +.applyOperation({ + type: "move_node", + path: 'a', + newPath: 'a', + data: Data.create({}) +}) +.applyOperation({ + type: "remove_node", + path: 'a', + node: Block.create({type: 'block'}), + data: Data.create({}) +}) +.applyOperation({ + type: "set_node", + path: 'a', + properties: {type: 'node'}, + newProperties: {type: 'new_node'}, + data: Data.create({}) +}) +.applyOperation({ + type: "split_node", + path: 'a', + position: 0, + target: 1, + properties: {type: 'block'}, + data: Data.create({}) +}) +.applyOperation({ + type: "set_selection", + properties: {}, + newProperties: {}, + data: Data.create({}) +}) +.applyOperation({ + type: "set_value", + properties: {}, + newProperties: {}, + data: Data.create({}) +}); KeyUtils.setGenerator(() => "Test"); KeyUtils.create();