@kerebron/extension-dev-toolkit 0.3.2 → 0.4.1
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/README.md +26 -11
- package/esm/editor/src/CoreEditor.d.ts +13 -4
- package/esm/editor/src/CoreEditor.d.ts.map +1 -1
- package/esm/editor/src/CoreEditor.js +64 -12
- package/esm/editor/src/Extension.d.ts +6 -1
- package/esm/editor/src/Extension.d.ts.map +1 -1
- package/esm/editor/src/Extension.js +21 -1
- package/esm/editor/src/ExtensionManager.d.ts +5 -6
- package/esm/editor/src/ExtensionManager.d.ts.map +1 -1
- package/esm/editor/src/ExtensionManager.js +43 -55
- package/esm/editor/src/Mark.d.ts +3 -0
- package/esm/editor/src/Mark.d.ts.map +1 -1
- package/esm/editor/src/Mark.js +11 -0
- package/esm/editor/src/Node.d.ts +5 -2
- package/esm/editor/src/Node.d.ts.map +1 -1
- package/esm/editor/src/Node.js +13 -2
- package/esm/editor/src/commands/CommandManager.d.ts +13 -6
- package/esm/editor/src/commands/CommandManager.d.ts.map +1 -1
- package/esm/editor/src/commands/CommandManager.js +59 -2
- package/esm/editor/src/commands/baseCommandFactories.d.ts +3 -0
- package/esm/editor/src/commands/baseCommandFactories.d.ts.map +1 -0
- package/esm/editor/src/commands/baseCommandFactories.js +836 -0
- package/esm/editor/src/commands/keyCommandFactories.d.ts +3 -0
- package/esm/editor/src/commands/keyCommandFactories.d.ts.map +1 -0
- package/esm/editor/src/commands/keyCommandFactories.js +10 -0
- package/esm/editor/src/commands/mod.d.ts +5 -53
- package/esm/editor/src/commands/mod.d.ts.map +1 -1
- package/esm/editor/src/commands/mod.js +14 -821
- package/esm/editor/src/commands/replaceCommandFactories.d.ts +3 -0
- package/esm/editor/src/commands/replaceCommandFactories.d.ts.map +1 -0
- package/esm/editor/src/commands/replaceCommandFactories.js +94 -0
- package/esm/editor/src/commands/types.d.ts +18 -0
- package/esm/editor/src/commands/types.d.ts.map +1 -0
- package/esm/editor/src/commands/types.js +1 -0
- package/esm/editor/src/mod.d.ts +2 -0
- package/esm/editor/src/mod.d.ts.map +1 -1
- package/esm/editor/src/mod.js +2 -0
- package/esm/editor/src/plugins/TrackSelecionPlugin.d.ts +6 -0
- package/esm/editor/src/plugins/TrackSelecionPlugin.d.ts.map +1 -0
- package/esm/editor/src/plugins/TrackSelecionPlugin.js +24 -0
- package/esm/editor/src/types.d.ts +19 -1
- package/esm/editor/src/types.d.ts.map +1 -1
- package/esm/editor/src/ui.d.ts +15 -0
- package/esm/editor/src/ui.d.ts.map +1 -0
- package/esm/editor/src/ui.js +16 -0
- package/esm/editor/src/utilities/SmartOutput.d.ts +9 -7
- package/esm/editor/src/utilities/SmartOutput.d.ts.map +1 -1
- package/esm/editor/src/utilities/SmartOutput.js +35 -20
- package/package.json +1 -1
package/esm/editor/src/Node.js
CHANGED
|
@@ -18,6 +18,12 @@ export class Node {
|
|
|
18
18
|
writable: true,
|
|
19
19
|
value: 'node'
|
|
20
20
|
});
|
|
21
|
+
Object.defineProperty(this, "editor", {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
configurable: true,
|
|
24
|
+
writable: true,
|
|
25
|
+
value: void 0
|
|
26
|
+
});
|
|
21
27
|
Object.defineProperty(this, "attributes", {
|
|
22
28
|
enumerable: true,
|
|
23
29
|
configurable: true,
|
|
@@ -25,13 +31,18 @@ export class Node {
|
|
|
25
31
|
value: {}
|
|
26
32
|
});
|
|
27
33
|
}
|
|
34
|
+
setEditor(editor) {
|
|
35
|
+
this.editor = editor;
|
|
36
|
+
}
|
|
37
|
+
created() {
|
|
38
|
+
}
|
|
28
39
|
getNodeSpec() {
|
|
29
40
|
throw new Error('NodeSpec not defined: ' + this.name);
|
|
30
41
|
}
|
|
31
42
|
getInputRules(type) {
|
|
32
43
|
return [];
|
|
33
44
|
}
|
|
34
|
-
getProseMirrorPlugins(
|
|
45
|
+
getProseMirrorPlugins() {
|
|
35
46
|
return [];
|
|
36
47
|
}
|
|
37
48
|
getCommandFactories(editor, type) {
|
|
@@ -40,7 +51,7 @@ export class Node {
|
|
|
40
51
|
getKeyboardShortcuts(editor) {
|
|
41
52
|
return {};
|
|
42
53
|
}
|
|
43
|
-
getNodeView() {
|
|
54
|
+
getNodeView(editor) {
|
|
44
55
|
return undefined;
|
|
45
56
|
}
|
|
46
57
|
getConverters(editor, schema) {
|
|
@@ -1,16 +1,23 @@
|
|
|
1
|
-
import { EditorState, Transaction } from 'prosemirror-state';
|
|
2
|
-
import { CoreEditor } from '../CoreEditor.js';
|
|
3
|
-
import { ChainedCommands, CommandFactory } from './
|
|
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;
|
|
4
5
|
export declare class CommandManager {
|
|
5
6
|
private editor;
|
|
6
|
-
|
|
7
|
-
constructor(editor: CoreEditor, commandFactories?: {
|
|
7
|
+
readonly commandFactories: {
|
|
8
8
|
[key: string]: CommandFactory;
|
|
9
|
-
}
|
|
9
|
+
};
|
|
10
|
+
readonly run: {
|
|
11
|
+
[key: string]: CommandRunner;
|
|
12
|
+
};
|
|
13
|
+
private debug;
|
|
14
|
+
constructor(editor: CoreEditor);
|
|
15
|
+
mergeCommandFactories(toInsert: Partial<CommandFactories>, extName: string): void;
|
|
10
16
|
get state(): EditorState;
|
|
11
17
|
get chain(): () => ChainedCommands;
|
|
12
18
|
get can(): () => ChainedCommands;
|
|
13
19
|
createChain(startTr?: Transaction, shouldDispatch?: boolean): ChainedCommands;
|
|
14
20
|
createCan(startTr?: Transaction): ChainedCommands;
|
|
15
21
|
}
|
|
22
|
+
export {};
|
|
16
23
|
//# sourceMappingURL=CommandManager.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CommandManager.d.ts","sourceRoot":"","sources":["../../../../src/editor/src/commands/CommandManager.ts"],"names":[],"mappings":"
|
|
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,6 +1,10 @@
|
|
|
1
|
+
import { EditorView } from 'prosemirror-view';
|
|
1
2
|
import { createChainableState } from './createChainableState.js';
|
|
3
|
+
import { baseCommandFactories } from './baseCommandFactories.js';
|
|
4
|
+
import { keyCommandFactories } from './keyCommandFactories.js';
|
|
5
|
+
import { replaceCommandFactories } from './replaceCommandFactories.js';
|
|
2
6
|
export class CommandManager {
|
|
3
|
-
constructor(editor
|
|
7
|
+
constructor(editor) {
|
|
4
8
|
Object.defineProperty(this, "editor", {
|
|
5
9
|
enumerable: true,
|
|
6
10
|
configurable: true,
|
|
@@ -11,8 +15,61 @@ export class CommandManager {
|
|
|
11
15
|
enumerable: true,
|
|
12
16
|
configurable: true,
|
|
13
17
|
writable: true,
|
|
14
|
-
value:
|
|
18
|
+
value: {}
|
|
15
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
|
+
}
|
|
16
73
|
}
|
|
17
74
|
get state() {
|
|
18
75
|
return this.editor.state;
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|