@kerebron/extension-dev-toolkit 0.4.4 → 0.4.6
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/{extension-dev-toolkit/src/mod.d.ts → mod.d.ts} +2 -2
- package/esm/mod.d.ts.map +1 -0
- package/esm/{extension-dev-toolkit/src/mod.js → mod.js} +1 -1
- package/package.json +4 -6
- 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/extension-dev-toolkit/src/mod.d.ts.map +0 -1
|
@@ -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"}
|