@kerebron/editor-react 0.4.5 → 0.4.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/{editor-react/src/EditorContent.d.ts → EditorContent.d.ts} +1 -1
- package/esm/EditorContent.d.ts.map +1 -0
- package/esm/{editor-react/src/mod.d.ts → mod.d.ts} +1 -1
- package/esm/mod.d.ts.map +1 -0
- package/esm/{editor-react/src/mod.js → mod.js} +1 -1
- package/esm/{editor-react/src/useEditor.d.ts → useEditor.d.ts} +2 -2
- package/esm/useEditor.d.ts.map +1 -0
- package/esm/{editor-react/src/useEditor.js → useEditor.js} +2 -2
- package/package.json +5 -11
- package/esm/editor/src/CoreEditor.d.ts +0 -40
- package/esm/editor/src/CoreEditor.d.ts.map +0 -1
- package/esm/editor/src/CoreEditor.js +0 -252
- package/esm/editor/src/DummyEditorView.d.ts +0 -60
- package/esm/editor/src/DummyEditorView.d.ts.map +0 -1
- package/esm/editor/src/DummyEditorView.js +0 -277
- package/esm/editor/src/Extension.d.ts +0 -31
- package/esm/editor/src/Extension.d.ts.map +0 -1
- package/esm/editor/src/Extension.js +0 -53
- package/esm/editor/src/ExtensionManager.d.ts +0 -32
- package/esm/editor/src/ExtensionManager.d.ts.map +0 -1
- package/esm/editor/src/ExtensionManager.js +0 -260
- package/esm/editor/src/Mark.d.ts +0 -23
- package/esm/editor/src/Mark.d.ts.map +0 -1
- package/esm/editor/src/Mark.js +0 -51
- package/esm/editor/src/Node.d.ts +0 -32
- package/esm/editor/src/Node.d.ts.map +0 -1
- package/esm/editor/src/Node.js +0 -60
- package/esm/editor/src/commands/CommandManager.d.ts +0 -23
- package/esm/editor/src/commands/CommandManager.d.ts.map +0 -1
- package/esm/editor/src/commands/CommandManager.js +0 -118
- package/esm/editor/src/commands/baseCommandFactories.d.ts +0 -3
- package/esm/editor/src/commands/baseCommandFactories.d.ts.map +0 -1
- package/esm/editor/src/commands/baseCommandFactories.js +0 -836
- package/esm/editor/src/commands/createChainableState.d.ts +0 -3
- package/esm/editor/src/commands/createChainableState.d.ts.map +0 -1
- package/esm/editor/src/commands/createChainableState.js +0 -29
- package/esm/editor/src/commands/keyCommandFactories.d.ts +0 -3
- package/esm/editor/src/commands/keyCommandFactories.d.ts.map +0 -1
- package/esm/editor/src/commands/keyCommandFactories.js +0 -10
- package/esm/editor/src/commands/mod.d.ts +0 -7
- package/esm/editor/src/commands/mod.d.ts.map +0 -1
- package/esm/editor/src/commands/mod.js +0 -76
- package/esm/editor/src/commands/replaceCommandFactories.d.ts +0 -3
- package/esm/editor/src/commands/replaceCommandFactories.d.ts.map +0 -1
- package/esm/editor/src/commands/replaceCommandFactories.js +0 -94
- package/esm/editor/src/commands/types.d.ts +0 -18
- package/esm/editor/src/commands/types.d.ts.map +0 -1
- package/esm/editor/src/commands/types.js +0 -1
- package/esm/editor/src/mod.d.ts +0 -9
- package/esm/editor/src/mod.d.ts.map +0 -1
- package/esm/editor/src/mod.js +0 -8
- package/esm/editor/src/nodeToTreeString.d.ts +0 -10
- package/esm/editor/src/nodeToTreeString.d.ts.map +0 -1
- package/esm/editor/src/nodeToTreeString.js +0 -74
- package/esm/editor/src/plugins/TrackSelecionPlugin.d.ts +0 -6
- package/esm/editor/src/plugins/TrackSelecionPlugin.d.ts.map +0 -1
- package/esm/editor/src/plugins/TrackSelecionPlugin.js +0 -24
- package/esm/editor/src/plugins/input-rules/InputRulesPlugin.d.ts +0 -23
- package/esm/editor/src/plugins/input-rules/InputRulesPlugin.d.ts.map +0 -1
- package/esm/editor/src/plugins/input-rules/InputRulesPlugin.js +0 -163
- package/esm/editor/src/plugins/keymap/keymap.d.ts +0 -11
- package/esm/editor/src/plugins/keymap/keymap.d.ts.map +0 -1
- package/esm/editor/src/plugins/keymap/keymap.js +0 -125
- package/esm/editor/src/plugins/keymap/w3c-keyname.d.ts +0 -4
- package/esm/editor/src/plugins/keymap/w3c-keyname.d.ts.map +0 -1
- package/esm/editor/src/plugins/keymap/w3c-keyname.js +0 -124
- package/esm/editor/src/types.d.ts +0 -52
- package/esm/editor/src/types.d.ts.map +0 -1
- package/esm/editor/src/types.js +0 -1
- package/esm/editor/src/ui.d.ts +0 -15
- package/esm/editor/src/ui.d.ts.map +0 -1
- package/esm/editor/src/ui.js +0 -16
- package/esm/editor/src/utilities/SmartOutput.d.ts +0 -41
- package/esm/editor/src/utilities/SmartOutput.d.ts.map +0 -1
- package/esm/editor/src/utilities/SmartOutput.js +0 -228
- package/esm/editor/src/utilities/createNodeFromContent.d.ts +0 -9
- package/esm/editor/src/utilities/createNodeFromContent.d.ts.map +0 -1
- package/esm/editor/src/utilities/createNodeFromContent.js +0 -32
- package/esm/editor/src/utilities/getHtmlAttributes.d.ts +0 -9
- package/esm/editor/src/utilities/getHtmlAttributes.d.ts.map +0 -1
- package/esm/editor/src/utilities/getHtmlAttributes.js +0 -47
- package/esm/editor-react/src/EditorContent.d.ts.map +0 -1
- package/esm/editor-react/src/mod.d.ts.map +0 -1
- package/esm/editor-react/src/useEditor.d.ts.map +0 -1
- /package/esm/{editor-react/src/EditorContent.js → EditorContent.js} +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Mark.d.ts","sourceRoot":"","sources":["../../../src/editor/src/Mark.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE5D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2CAA2C,CAAC;AAC3E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,KAAK,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC5E,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC,MAAM,WAAW,UAAU;IAEzB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED,8BAAsB,IAAI;IAOL,SAAS,CAAC,MAAM,EAAE,OAAO,CAAC,UAAU,CAAC;IANxD,QAAQ,CAAC,IAAI,UAAU;IACvB,IAAI,EAAE,MAAM,CAAU;IACtB,SAAS,CAAC,MAAM,EAAG,UAAU,CAAC;IAE9B,SAAgB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,CAAC,CAAC,CAAM;gBAEnC,MAAM,GAAE,OAAO,CAAC,UAAU,CAAM;IAE7D,SAAS,CAAC,MAAM,EAAE,UAAU;IAI5B,OAAO;IAGP,WAAW,IAAI,QAAQ;IAIvB,aAAa,CAAC,IAAI,EAAE,QAAQ,GAAG,SAAS,EAAE;IAI1C,mBAAmB,CACjB,MAAM,EAAE,UAAU,EAClB,IAAI,EAAE,QAAQ,GACb,OAAO,CAAC,gBAAgB,CAAC;IAI5B,oBAAoB,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,gBAAgB,CAAC;CAGpE"}
|
package/esm/editor/src/Mark.js
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
export class Mark {
|
|
2
|
-
constructor(config = {}) {
|
|
3
|
-
Object.defineProperty(this, "config", {
|
|
4
|
-
enumerable: true,
|
|
5
|
-
configurable: true,
|
|
6
|
-
writable: true,
|
|
7
|
-
value: config
|
|
8
|
-
});
|
|
9
|
-
Object.defineProperty(this, "type", {
|
|
10
|
-
enumerable: true,
|
|
11
|
-
configurable: true,
|
|
12
|
-
writable: true,
|
|
13
|
-
value: 'mark'
|
|
14
|
-
});
|
|
15
|
-
Object.defineProperty(this, "name", {
|
|
16
|
-
enumerable: true,
|
|
17
|
-
configurable: true,
|
|
18
|
-
writable: true,
|
|
19
|
-
value: 'node'
|
|
20
|
-
});
|
|
21
|
-
Object.defineProperty(this, "editor", {
|
|
22
|
-
enumerable: true,
|
|
23
|
-
configurable: true,
|
|
24
|
-
writable: true,
|
|
25
|
-
value: void 0
|
|
26
|
-
});
|
|
27
|
-
Object.defineProperty(this, "attributes", {
|
|
28
|
-
enumerable: true,
|
|
29
|
-
configurable: true,
|
|
30
|
-
writable: true,
|
|
31
|
-
value: {}
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
setEditor(editor) {
|
|
35
|
-
this.editor = editor;
|
|
36
|
-
}
|
|
37
|
-
created() {
|
|
38
|
-
}
|
|
39
|
-
getMarkSpec() {
|
|
40
|
-
throw new Error('MarkSpec not defined: ' + this.name);
|
|
41
|
-
}
|
|
42
|
-
getInputRules(type) {
|
|
43
|
-
return [];
|
|
44
|
-
}
|
|
45
|
-
getCommandFactories(editor, type) {
|
|
46
|
-
return {};
|
|
47
|
-
}
|
|
48
|
-
getKeyboardShortcuts(editor) {
|
|
49
|
-
return {};
|
|
50
|
-
}
|
|
51
|
-
}
|
package/esm/editor/src/Node.d.ts
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import type { NodeSpec, NodeType, Schema } from 'prosemirror-model';
|
|
2
|
-
import type { NodeViewConstructor } from 'prosemirror-view';
|
|
3
|
-
import type { Plugin } from 'prosemirror-state';
|
|
4
|
-
import type { InputRule } from './plugins/input-rules/InputRulesPlugin.js';
|
|
5
|
-
import type { CoreEditor } from './CoreEditor.js';
|
|
6
|
-
import type { Command, CommandShortcuts } from './commands/mod.js';
|
|
7
|
-
import type { Converter } from './Extension.js';
|
|
8
|
-
import { Attribute } from './types.js';
|
|
9
|
-
export interface NodeConfig {
|
|
10
|
-
[key: string]: any;
|
|
11
|
-
}
|
|
12
|
-
export interface CommandFactories {
|
|
13
|
-
[key: string]: () => Command;
|
|
14
|
-
}
|
|
15
|
-
export declare abstract class Node {
|
|
16
|
-
protected config: Partial<NodeConfig>;
|
|
17
|
-
readonly type = "node";
|
|
18
|
-
name: string;
|
|
19
|
-
protected editor: CoreEditor;
|
|
20
|
-
readonly attributes: Record<string, Attribute<any>>;
|
|
21
|
-
constructor(config?: Partial<NodeConfig>);
|
|
22
|
-
setEditor(editor: CoreEditor): void;
|
|
23
|
-
created(): void;
|
|
24
|
-
getNodeSpec(): NodeSpec;
|
|
25
|
-
getInputRules(type: NodeType): InputRule[];
|
|
26
|
-
getProseMirrorPlugins(): Plugin[];
|
|
27
|
-
getCommandFactories(editor: CoreEditor, type: NodeType): Partial<CommandFactories>;
|
|
28
|
-
getKeyboardShortcuts(editor: CoreEditor): Partial<CommandShortcuts>;
|
|
29
|
-
getNodeView(editor: CoreEditor): NodeViewConstructor | undefined;
|
|
30
|
-
getConverters(editor: CoreEditor, schema: Schema): Record<string, Converter>;
|
|
31
|
-
}
|
|
32
|
-
//# sourceMappingURL=Node.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Node.d.ts","sourceRoot":"","sources":["../../../src/editor/src/Node.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AACpE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2CAA2C,CAAC;AAC3E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,KAAK,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC,MAAM,WAAW,UAAU;IAEzB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED,MAAM,WAAW,gBAAgB;IAC/B,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,OAAO,CAAC;CAC9B;AAED,8BAAsB,IAAI;IAOL,SAAS,CAAC,MAAM,EAAE,OAAO,CAAC,UAAU,CAAC;IANxD,QAAQ,CAAC,IAAI,UAAU;IACvB,IAAI,EAAE,MAAM,CAAU;IACtB,SAAS,CAAC,MAAM,EAAG,UAAU,CAAC;IAE9B,SAAgB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,CAAC,CAAC,CAAM;gBAEnC,MAAM,GAAE,OAAO,CAAC,UAAU,CAAM;IAE7D,SAAS,CAAC,MAAM,EAAE,UAAU;IAI5B,OAAO;IAGP,WAAW,IAAI,QAAQ;IAIvB,aAAa,CAAC,IAAI,EAAE,QAAQ,GAAG,SAAS,EAAE;IAI1C,qBAAqB,IAAI,MAAM,EAAE;IAIjC,mBAAmB,CACjB,MAAM,EAAE,UAAU,EAClB,IAAI,EAAE,QAAQ,GACb,OAAO,CAAC,gBAAgB,CAAC;IAI5B,oBAAoB,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAInE,WAAW,CAAC,MAAM,EAAE,UAAU,GAAG,mBAAmB,GAAG,SAAS;IAIhE,aAAa,CAAC,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC;CAG7E"}
|
package/esm/editor/src/Node.js
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
export class Node {
|
|
2
|
-
constructor(config = {}) {
|
|
3
|
-
Object.defineProperty(this, "config", {
|
|
4
|
-
enumerable: true,
|
|
5
|
-
configurable: true,
|
|
6
|
-
writable: true,
|
|
7
|
-
value: config
|
|
8
|
-
});
|
|
9
|
-
Object.defineProperty(this, "type", {
|
|
10
|
-
enumerable: true,
|
|
11
|
-
configurable: true,
|
|
12
|
-
writable: true,
|
|
13
|
-
value: 'node'
|
|
14
|
-
});
|
|
15
|
-
Object.defineProperty(this, "name", {
|
|
16
|
-
enumerable: true,
|
|
17
|
-
configurable: true,
|
|
18
|
-
writable: true,
|
|
19
|
-
value: 'node'
|
|
20
|
-
});
|
|
21
|
-
Object.defineProperty(this, "editor", {
|
|
22
|
-
enumerable: true,
|
|
23
|
-
configurable: true,
|
|
24
|
-
writable: true,
|
|
25
|
-
value: void 0
|
|
26
|
-
});
|
|
27
|
-
Object.defineProperty(this, "attributes", {
|
|
28
|
-
enumerable: true,
|
|
29
|
-
configurable: true,
|
|
30
|
-
writable: true,
|
|
31
|
-
value: {}
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
setEditor(editor) {
|
|
35
|
-
this.editor = editor;
|
|
36
|
-
}
|
|
37
|
-
created() {
|
|
38
|
-
}
|
|
39
|
-
getNodeSpec() {
|
|
40
|
-
throw new Error('NodeSpec not defined: ' + this.name);
|
|
41
|
-
}
|
|
42
|
-
getInputRules(type) {
|
|
43
|
-
return [];
|
|
44
|
-
}
|
|
45
|
-
getProseMirrorPlugins() {
|
|
46
|
-
return [];
|
|
47
|
-
}
|
|
48
|
-
getCommandFactories(editor, type) {
|
|
49
|
-
return {};
|
|
50
|
-
}
|
|
51
|
-
getKeyboardShortcuts(editor) {
|
|
52
|
-
return {};
|
|
53
|
-
}
|
|
54
|
-
getNodeView(editor) {
|
|
55
|
-
return undefined;
|
|
56
|
-
}
|
|
57
|
-
getConverters(editor, schema) {
|
|
58
|
-
return {};
|
|
59
|
-
}
|
|
60
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import type { EditorState, Transaction } from 'prosemirror-state';
|
|
2
|
-
import type { CoreEditor } from '../CoreEditor.js';
|
|
3
|
-
import type { ChainedCommands, CommandFactories, CommandFactory } from './types.js';
|
|
4
|
-
type CommandRunner = (...args: any[]) => boolean;
|
|
5
|
-
export declare class CommandManager {
|
|
6
|
-
private editor;
|
|
7
|
-
readonly commandFactories: {
|
|
8
|
-
[key: string]: CommandFactory;
|
|
9
|
-
};
|
|
10
|
-
readonly run: {
|
|
11
|
-
[key: string]: CommandRunner;
|
|
12
|
-
};
|
|
13
|
-
private debug;
|
|
14
|
-
constructor(editor: CoreEditor);
|
|
15
|
-
mergeCommandFactories(toInsert: Partial<CommandFactories>, extName: string): void;
|
|
16
|
-
get state(): EditorState;
|
|
17
|
-
get chain(): () => ChainedCommands;
|
|
18
|
-
get can(): () => ChainedCommands;
|
|
19
|
-
createChain(startTr?: Transaction, shouldDispatch?: boolean): ChainedCommands;
|
|
20
|
-
createCan(startTr?: Transaction): ChainedCommands;
|
|
21
|
-
}
|
|
22
|
-
export {};
|
|
23
|
-
//# sourceMappingURL=CommandManager.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CommandManager.d.ts","sourceRoot":"","sources":["../../../../src/editor/src/commands/CommandManager.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAElE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD,OAAO,KAAK,EACV,eAAe,EAEf,gBAAgB,EAChB,cAAc,EACf,MAAM,YAAY,CAAC;AAMpB,KAAK,aAAa,GAAG,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,OAAO,CAAC;AAEjD,qBAAa,cAAc;IAOvB,OAAO,CAAC,MAAM;IANhB,SAAgB,gBAAgB,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,cAAc,CAAA;KAAE,CAAM;IACzE,SAAgB,GAAG,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,aAAa,CAAA;KAAE,CAAM;IAE3D,OAAO,CAAC,KAAK,CAAQ;gBAGX,MAAM,EAAE,UAAU;IAOrB,qBAAqB,CAC1B,QAAQ,EAAE,OAAO,CAAC,gBAAgB,CAAC,EACnC,OAAO,EAAE,MAAM;IA4CjB,IAAI,KAAK,IAAI,WAAW,CAEvB;IAED,IAAI,KAAK,IAAI,MAAM,eAAe,CAEjC;IAED,IAAI,GAAG,IAAI,MAAM,eAAe,CAE/B;IAEM,WAAW,CAChB,OAAO,CAAC,EAAE,WAAW,EACrB,cAAc,UAAO,GACpB,eAAe;IA4CX,SAAS,CAAC,OAAO,CAAC,EAAE,WAAW,GAAG,eAAe;CAGzD"}
|
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
import { EditorView } from 'prosemirror-view';
|
|
2
|
-
import { createChainableState } from './createChainableState.js';
|
|
3
|
-
import { baseCommandFactories } from './baseCommandFactories.js';
|
|
4
|
-
import { keyCommandFactories } from './keyCommandFactories.js';
|
|
5
|
-
import { replaceCommandFactories } from './replaceCommandFactories.js';
|
|
6
|
-
export class CommandManager {
|
|
7
|
-
constructor(editor) {
|
|
8
|
-
Object.defineProperty(this, "editor", {
|
|
9
|
-
enumerable: true,
|
|
10
|
-
configurable: true,
|
|
11
|
-
writable: true,
|
|
12
|
-
value: editor
|
|
13
|
-
});
|
|
14
|
-
Object.defineProperty(this, "commandFactories", {
|
|
15
|
-
enumerable: true,
|
|
16
|
-
configurable: true,
|
|
17
|
-
writable: true,
|
|
18
|
-
value: {}
|
|
19
|
-
});
|
|
20
|
-
Object.defineProperty(this, "run", {
|
|
21
|
-
enumerable: true,
|
|
22
|
-
configurable: true,
|
|
23
|
-
writable: true,
|
|
24
|
-
value: {}
|
|
25
|
-
});
|
|
26
|
-
Object.defineProperty(this, "debug", {
|
|
27
|
-
enumerable: true,
|
|
28
|
-
configurable: true,
|
|
29
|
-
writable: true,
|
|
30
|
-
value: true
|
|
31
|
-
});
|
|
32
|
-
this.mergeCommandFactories(baseCommandFactories, 'baseCommand');
|
|
33
|
-
this.mergeCommandFactories(keyCommandFactories, 'key');
|
|
34
|
-
this.mergeCommandFactories(replaceCommandFactories, 'replace');
|
|
35
|
-
}
|
|
36
|
-
mergeCommandFactories(toInsert, extName) {
|
|
37
|
-
for (const key in toInsert) {
|
|
38
|
-
const commandFactory = toInsert[key];
|
|
39
|
-
if (!commandFactory) {
|
|
40
|
-
continue;
|
|
41
|
-
}
|
|
42
|
-
if (this.debug) {
|
|
43
|
-
const wrappedFactory = (...args) => {
|
|
44
|
-
const realCommand = commandFactory(...args);
|
|
45
|
-
const command = (state, dispatch, view) => {
|
|
46
|
-
if (dispatch) {
|
|
47
|
-
console.debug(`Command: ${extName}.${key}`);
|
|
48
|
-
}
|
|
49
|
-
return realCommand(state, dispatch, view);
|
|
50
|
-
};
|
|
51
|
-
return command;
|
|
52
|
-
};
|
|
53
|
-
this.commandFactories[key] = wrappedFactory;
|
|
54
|
-
}
|
|
55
|
-
else {
|
|
56
|
-
this.commandFactories[key] = commandFactory;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
for (const key in this.commandFactories) {
|
|
60
|
-
const factory = this.commandFactories[key];
|
|
61
|
-
this.run[key] = (...args) => {
|
|
62
|
-
const command = factory(...args);
|
|
63
|
-
const state = this.editor.state;
|
|
64
|
-
const view = this.editor.view;
|
|
65
|
-
if (view instanceof EditorView) {
|
|
66
|
-
return command(state, view.dispatch, view);
|
|
67
|
-
}
|
|
68
|
-
else {
|
|
69
|
-
return command(state, view.dispatch);
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
get state() {
|
|
75
|
-
return this.editor.state;
|
|
76
|
-
}
|
|
77
|
-
get chain() {
|
|
78
|
-
return () => this.createChain();
|
|
79
|
-
}
|
|
80
|
-
get can() {
|
|
81
|
-
return () => this.createCan();
|
|
82
|
-
}
|
|
83
|
-
createChain(startTr, shouldDispatch = true) {
|
|
84
|
-
const { commandFactories, editor, state } = this;
|
|
85
|
-
const { view } = editor;
|
|
86
|
-
const callbacks = [];
|
|
87
|
-
const hasStartTransaction = !!startTr;
|
|
88
|
-
const tr = startTr || state.tr;
|
|
89
|
-
const chainedState = createChainableState(tr, state);
|
|
90
|
-
const fakeDispatch = () => undefined;
|
|
91
|
-
const chain = {
|
|
92
|
-
...Object.fromEntries(Object.entries(commandFactories).map(([name, commandFactory]) => {
|
|
93
|
-
const chainedCommand = (...args) => {
|
|
94
|
-
const command = commandFactory(...args);
|
|
95
|
-
const callback = command(chainedState, shouldDispatch ? fakeDispatch : undefined);
|
|
96
|
-
callbacks.push(callback);
|
|
97
|
-
return chain;
|
|
98
|
-
};
|
|
99
|
-
return [name, chainedCommand];
|
|
100
|
-
})),
|
|
101
|
-
run: () => {
|
|
102
|
-
if (!hasStartTransaction &&
|
|
103
|
-
shouldDispatch &&
|
|
104
|
-
!tr.getMeta('preventDispatch')) {
|
|
105
|
-
view.dispatch(tr);
|
|
106
|
-
}
|
|
107
|
-
return callbacks.every((callback) => callback === true);
|
|
108
|
-
},
|
|
109
|
-
chain: () => {
|
|
110
|
-
return this.createChain(tr, shouldDispatch);
|
|
111
|
-
},
|
|
112
|
-
};
|
|
113
|
-
return chain;
|
|
114
|
-
}
|
|
115
|
-
createCan(startTr) {
|
|
116
|
-
return this.createChain(startTr, false);
|
|
117
|
-
}
|
|
118
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"baseCommandFactories.d.ts","sourceRoot":"","sources":["../../../../src/editor/src/commands/baseCommandFactories.ts"],"names":[],"mappings":"AAgCA,OAAO,EAAgB,cAAc,EAAE,MAAM,YAAY,CAAC;AAo/B1D,eAAO,MAAM,oBAAoB,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CA2B/D,CAAC"}
|