@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,31 +0,0 @@
|
|
|
1
|
-
import type { Plugin } from 'prosemirror-state';
|
|
2
|
-
import type { Node, Schema, SchemaSpec } from 'prosemirror-model';
|
|
3
|
-
import { type CoreEditor } from './CoreEditor.js';
|
|
4
|
-
import type { InputRule } from './plugins/input-rules/InputRulesPlugin.js';
|
|
5
|
-
import { CommandFactories, CommandShortcuts } from './commands/mod.js';
|
|
6
|
-
export interface ExtensionConfig {
|
|
7
|
-
[key: string]: any;
|
|
8
|
-
requires: Array<Extension | string>;
|
|
9
|
-
}
|
|
10
|
-
export interface Converter {
|
|
11
|
-
fromDoc(document: Node): Promise<Uint8Array>;
|
|
12
|
-
toDoc(content: Uint8Array): Promise<Node>;
|
|
13
|
-
}
|
|
14
|
-
export declare abstract class Extension {
|
|
15
|
-
protected config: Partial<ExtensionConfig>;
|
|
16
|
-
readonly type = "extension";
|
|
17
|
-
abstract name: string;
|
|
18
|
-
protected editor: CoreEditor;
|
|
19
|
-
readonly conflicts?: Array<string>;
|
|
20
|
-
constructor(config?: Partial<ExtensionConfig>);
|
|
21
|
-
setEditor(editor: CoreEditor): void;
|
|
22
|
-
getEditor(): CoreEditor;
|
|
23
|
-
created(): void;
|
|
24
|
-
getInputRules(): InputRule[];
|
|
25
|
-
getProseMirrorPlugins(): Plugin[];
|
|
26
|
-
getCommandFactories(editor: CoreEditor): Partial<CommandFactories>;
|
|
27
|
-
getKeyboardShortcuts(editor: CoreEditor): Partial<CommandShortcuts>;
|
|
28
|
-
getConverters(editor: CoreEditor, schema: Schema): Record<string, Converter>;
|
|
29
|
-
setupSpec(spec: SchemaSpec): void;
|
|
30
|
-
}
|
|
31
|
-
//# sourceMappingURL=Extension.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Extension.d.ts","sourceRoot":"","sources":["../../../src/editor/src/Extension.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAElE,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2CAA2C,CAAC;AAC3E,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAEvE,MAAM,WAAW,eAAe;IAE9B,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;IAEnB,QAAQ,EAAE,KAAK,CAAC,SAAS,GAAG,MAAM,CAAC,CAAC;CACrC;AAED,MAAM,WAAW,SAAS;IACxB,OAAO,CAAC,QAAQ,EAAE,IAAI,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;IAC7C,KAAK,CAAC,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC3C;AAED,8BAAsB,SAAS;IAOV,SAAS,CAAC,MAAM,EAAE,OAAO,CAAC,eAAe,CAAC;IAN7D,QAAQ,CAAC,IAAI,eAAe;IAC5B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,MAAM,EAAG,UAAU,CAAC;IAE9B,QAAQ,CAAC,SAAS,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;gBAEN,MAAM,GAAE,OAAO,CAAC,eAAe,CAAM;IAGlE,SAAS,CAAC,MAAM,EAAE,UAAU;IAI5B,SAAS;IAIT,OAAO;IAGP,aAAa,IAAI,SAAS,EAAE;IAI5B,qBAAqB,IAAI,MAAM,EAAE;IAIjC,mBAAmB,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAIlE,oBAAoB,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAInE,aAAa,CAAC,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC;IAI5E,SAAS,CAAC,IAAI,EAAE,UAAU;CAE3B"}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
export class Extension {
|
|
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: 'extension'
|
|
14
|
-
});
|
|
15
|
-
Object.defineProperty(this, "editor", {
|
|
16
|
-
enumerable: true,
|
|
17
|
-
configurable: true,
|
|
18
|
-
writable: true,
|
|
19
|
-
value: void 0
|
|
20
|
-
});
|
|
21
|
-
Object.defineProperty(this, "conflicts", {
|
|
22
|
-
enumerable: true,
|
|
23
|
-
configurable: true,
|
|
24
|
-
writable: true,
|
|
25
|
-
value: void 0
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
setEditor(editor) {
|
|
29
|
-
this.editor = editor;
|
|
30
|
-
}
|
|
31
|
-
getEditor() {
|
|
32
|
-
return this.editor;
|
|
33
|
-
}
|
|
34
|
-
created() {
|
|
35
|
-
}
|
|
36
|
-
getInputRules() {
|
|
37
|
-
return [];
|
|
38
|
-
}
|
|
39
|
-
getProseMirrorPlugins() {
|
|
40
|
-
return [];
|
|
41
|
-
}
|
|
42
|
-
getCommandFactories(editor) {
|
|
43
|
-
return {};
|
|
44
|
-
}
|
|
45
|
-
getKeyboardShortcuts(editor) {
|
|
46
|
-
return {};
|
|
47
|
-
}
|
|
48
|
-
getConverters(editor, schema) {
|
|
49
|
-
return {};
|
|
50
|
-
}
|
|
51
|
-
setupSpec(spec) {
|
|
52
|
-
}
|
|
53
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { Schema } from 'prosemirror-model';
|
|
2
|
-
import { Plugin } from 'prosemirror-state';
|
|
3
|
-
import { NodeViewConstructor } from 'prosemirror-view';
|
|
4
|
-
import { Converter, Extension } from './Extension.js';
|
|
5
|
-
import { AnyExtension, AnyExtensionOrReq } from './types.js';
|
|
6
|
-
import { CoreEditor } from './CoreEditor.js';
|
|
7
|
-
import { Mark } from './Mark.js';
|
|
8
|
-
import { Node } from './Node.js';
|
|
9
|
-
import { type CommandManager } from './commands/CommandManager.js';
|
|
10
|
-
export declare function findDuplicates(items: any[]): any[];
|
|
11
|
-
export declare function splitExtensions(extensions: Iterable<AnyExtension>): {
|
|
12
|
-
baseExtensions: Extension[];
|
|
13
|
-
nodeExtensions: Node[];
|
|
14
|
-
markExtensions: Mark[];
|
|
15
|
-
};
|
|
16
|
-
export declare class ExtensionManager {
|
|
17
|
-
private editor;
|
|
18
|
-
private commandManager;
|
|
19
|
-
readonly schema: Schema;
|
|
20
|
-
private extensions;
|
|
21
|
-
readonly plugins: Plugin[];
|
|
22
|
-
readonly nodeViews: Record<string, NodeViewConstructor>;
|
|
23
|
-
converters: Record<string, Converter>;
|
|
24
|
-
private debug;
|
|
25
|
-
constructor(extensions: AnyExtensionOrReq[], editor: CoreEditor, commandManager: CommandManager);
|
|
26
|
-
getExtension<T extends Extension>(name: string): T | undefined;
|
|
27
|
-
private initPlugins;
|
|
28
|
-
private setupExtensions;
|
|
29
|
-
getSchemaByResolvedExtensions(editor: CoreEditor): Schema;
|
|
30
|
-
created(): void;
|
|
31
|
-
}
|
|
32
|
-
//# sourceMappingURL=ExtensionManager.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ExtensionManager.d.ts","sourceRoot":"","sources":["../../../src/editor/src/ExtensionManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAEvD,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AASjC,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAGnE,wBAAgB,cAAc,CAAC,KAAK,EAAE,GAAG,EAAE,GAAG,GAAG,EAAE,CAIlD;AAED,wBAAgB,eAAe,CAAC,UAAU,EAAE,QAAQ,CAAC,YAAY,CAAC;;;;EAgBjE;AAED,qBAAa,gBAAgB;IAazB,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,cAAc;IAbxB,SAAgB,MAAM,EAAE,MAAM,CAAC;IAE/B,OAAO,CAAC,UAAU,CAAgC;IAClD,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,CAAM;IAChC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAM;IAEtD,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAM;IAElD,OAAO,CAAC,KAAK,CAAQ;gBAGnB,UAAU,EAAE,iBAAiB,EAAE,EACvB,MAAM,EAAE,UAAU,EAClB,cAAc,EAAE,cAAc;IAcxC,YAAY,CAAC,CAAC,SAAS,SAAS,EAAE,IAAI,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS;IAY9D,OAAO,CAAC,WAAW;IAkHnB,OAAO,CAAC,eAAe;IAwEvB,6BAA6B,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM;IAkDzD,OAAO;CAOR"}
|
|
@@ -1,260 +0,0 @@
|
|
|
1
|
-
import { Schema } from 'prosemirror-model';
|
|
2
|
-
import { InputRulesPlugin, } from './plugins/input-rules/InputRulesPlugin.js';
|
|
3
|
-
import { KeymapPlugin } from './plugins/keymap/keymap.js';
|
|
4
|
-
import { firstCommand } from './commands/mod.js';
|
|
5
|
-
import { addAttributesToSchema } from './utilities/getHtmlAttributes.js';
|
|
6
|
-
import { TrackSelecionPlugin } from './plugins/TrackSelecionPlugin.js';
|
|
7
|
-
export function findDuplicates(items) {
|
|
8
|
-
const filtered = items.filter((el, index) => items.indexOf(el) !== index);
|
|
9
|
-
return Array.from(new Set(filtered));
|
|
10
|
-
}
|
|
11
|
-
export function splitExtensions(extensions) {
|
|
12
|
-
const baseExtensions = Array.from(extensions).filter((extension) => extension.type === 'extension');
|
|
13
|
-
const nodeExtensions = Array.from(extensions).filter((extension) => extension.type === 'node');
|
|
14
|
-
const markExtensions = Array.from(extensions).filter((extension) => extension.type === 'mark');
|
|
15
|
-
return {
|
|
16
|
-
baseExtensions,
|
|
17
|
-
nodeExtensions,
|
|
18
|
-
markExtensions,
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
export class ExtensionManager {
|
|
22
|
-
constructor(extensions, editor, commandManager) {
|
|
23
|
-
Object.defineProperty(this, "editor", {
|
|
24
|
-
enumerable: true,
|
|
25
|
-
configurable: true,
|
|
26
|
-
writable: true,
|
|
27
|
-
value: editor
|
|
28
|
-
});
|
|
29
|
-
Object.defineProperty(this, "commandManager", {
|
|
30
|
-
enumerable: true,
|
|
31
|
-
configurable: true,
|
|
32
|
-
writable: true,
|
|
33
|
-
value: commandManager
|
|
34
|
-
});
|
|
35
|
-
Object.defineProperty(this, "schema", {
|
|
36
|
-
enumerable: true,
|
|
37
|
-
configurable: true,
|
|
38
|
-
writable: true,
|
|
39
|
-
value: void 0
|
|
40
|
-
});
|
|
41
|
-
Object.defineProperty(this, "extensions", {
|
|
42
|
-
enumerable: true,
|
|
43
|
-
configurable: true,
|
|
44
|
-
writable: true,
|
|
45
|
-
value: new Set()
|
|
46
|
-
});
|
|
47
|
-
Object.defineProperty(this, "plugins", {
|
|
48
|
-
enumerable: true,
|
|
49
|
-
configurable: true,
|
|
50
|
-
writable: true,
|
|
51
|
-
value: []
|
|
52
|
-
});
|
|
53
|
-
Object.defineProperty(this, "nodeViews", {
|
|
54
|
-
enumerable: true,
|
|
55
|
-
configurable: true,
|
|
56
|
-
writable: true,
|
|
57
|
-
value: {}
|
|
58
|
-
});
|
|
59
|
-
Object.defineProperty(this, "converters", {
|
|
60
|
-
enumerable: true,
|
|
61
|
-
configurable: true,
|
|
62
|
-
writable: true,
|
|
63
|
-
value: {}
|
|
64
|
-
});
|
|
65
|
-
Object.defineProperty(this, "debug", {
|
|
66
|
-
enumerable: true,
|
|
67
|
-
configurable: true,
|
|
68
|
-
writable: true,
|
|
69
|
-
value: true
|
|
70
|
-
});
|
|
71
|
-
this.setupExtensions(new Set(extensions));
|
|
72
|
-
this.schema = this.getSchemaByResolvedExtensions(editor);
|
|
73
|
-
const event = new CustomEvent('schema:ready', {
|
|
74
|
-
detail: {
|
|
75
|
-
editor,
|
|
76
|
-
schema: this.schema,
|
|
77
|
-
},
|
|
78
|
-
});
|
|
79
|
-
editor.dispatchEvent(event);
|
|
80
|
-
}
|
|
81
|
-
getExtension(name) {
|
|
82
|
-
const { nodeExtensions, markExtensions, baseExtensions } = splitExtensions(this.extensions);
|
|
83
|
-
for (const extension of baseExtensions) {
|
|
84
|
-
if (extension.name === name) {
|
|
85
|
-
return extension;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
initPlugins() {
|
|
90
|
-
const inputRules = [];
|
|
91
|
-
const keyBindings = new Map();
|
|
92
|
-
const mergeShortcuts = (toInsert, extName) => {
|
|
93
|
-
for (const key in toInsert) {
|
|
94
|
-
if (!toInsert[key]) {
|
|
95
|
-
continue;
|
|
96
|
-
}
|
|
97
|
-
const commandFactory = this.commandManager.commandFactories[toInsert[key]];
|
|
98
|
-
if (!commandFactory) {
|
|
99
|
-
console.warn(`No command constructor: ${toInsert[key]}`);
|
|
100
|
-
continue;
|
|
101
|
-
}
|
|
102
|
-
const command = commandFactory();
|
|
103
|
-
const keyBinding = keyBindings.get(key);
|
|
104
|
-
if (keyBinding) {
|
|
105
|
-
keyBindings.set(key, firstCommand(command, keyBinding));
|
|
106
|
-
}
|
|
107
|
-
else {
|
|
108
|
-
keyBindings.set(key, command);
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
};
|
|
112
|
-
let converters = {};
|
|
113
|
-
for (const extension of this.extensions) {
|
|
114
|
-
extension.setEditor(this.editor);
|
|
115
|
-
if (extension.type === 'node') {
|
|
116
|
-
const nodeType = this.schema.nodes[extension.name];
|
|
117
|
-
inputRules.push(...extension.getInputRules(nodeType));
|
|
118
|
-
this.plugins.push(...extension.getProseMirrorPlugins());
|
|
119
|
-
this.commandManager.mergeCommandFactories(extension.getCommandFactories(this.editor, nodeType), extension.name);
|
|
120
|
-
mergeShortcuts(extension.getKeyboardShortcuts(this.editor), extension.name);
|
|
121
|
-
converters = {
|
|
122
|
-
...converters,
|
|
123
|
-
...extension.getConverters(this.editor, this.schema),
|
|
124
|
-
};
|
|
125
|
-
const nodeView = extension.getNodeView(this.editor);
|
|
126
|
-
if (nodeView) {
|
|
127
|
-
this.nodeViews[extension.name] = nodeView;
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
if (extension.type === 'mark') {
|
|
131
|
-
const markType = this.schema.marks[extension.name];
|
|
132
|
-
inputRules.push(...extension.getInputRules(markType));
|
|
133
|
-
this.commandManager.mergeCommandFactories(extension.getCommandFactories(this.editor, markType), extension.name);
|
|
134
|
-
mergeShortcuts(extension.getKeyboardShortcuts(this.editor), extension.name);
|
|
135
|
-
}
|
|
136
|
-
if (extension.type === 'extension') {
|
|
137
|
-
this.plugins.push(...extension.getProseMirrorPlugins());
|
|
138
|
-
this.commandManager.mergeCommandFactories(extension.getCommandFactories(this.editor), extension.name);
|
|
139
|
-
mergeShortcuts(extension.getKeyboardShortcuts(this.editor), extension.name);
|
|
140
|
-
converters = {
|
|
141
|
-
...converters,
|
|
142
|
-
...extension.getConverters(this.editor, this.schema),
|
|
143
|
-
};
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
if (this.debug) {
|
|
147
|
-
for (const key in keyBindings) {
|
|
148
|
-
const keyBinding = keyBindings.get(key);
|
|
149
|
-
if (!keyBinding) {
|
|
150
|
-
continue;
|
|
151
|
-
}
|
|
152
|
-
const wrapperCommand = (state, dispatch, view) => {
|
|
153
|
-
console.debug(`Key: ${key}`);
|
|
154
|
-
return true;
|
|
155
|
-
};
|
|
156
|
-
keyBindings.set(key, firstCommand(wrapperCommand, keyBinding));
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
this.converters = converters;
|
|
160
|
-
this.plugins.push(new InputRulesPlugin(inputRules));
|
|
161
|
-
this.plugins.push(new KeymapPlugin(Object.fromEntries(keyBindings)));
|
|
162
|
-
this.plugins.push(new TrackSelecionPlugin(this.editor));
|
|
163
|
-
}
|
|
164
|
-
setupExtensions(extensions) {
|
|
165
|
-
const allExtensions = new Map();
|
|
166
|
-
const createMap = (extensions) => {
|
|
167
|
-
for (const extension of extensions) {
|
|
168
|
-
if ('name' in extension) {
|
|
169
|
-
allExtensions.set(extension.name, extension);
|
|
170
|
-
}
|
|
171
|
-
if ('requires' in extension) {
|
|
172
|
-
const childExtensions = Array.from(extension.requires).filter((e) => typeof e !== 'string');
|
|
173
|
-
createMap(new Set(childExtensions));
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
};
|
|
177
|
-
createMap(extensions);
|
|
178
|
-
const initialized = new Set();
|
|
179
|
-
const initializeExtension = (extension) => {
|
|
180
|
-
console.info(`Initialize ${extension.type} ${extension.name}`);
|
|
181
|
-
this.extensions.add(extension);
|
|
182
|
-
};
|
|
183
|
-
function recursiveInitializeExtension(extension) {
|
|
184
|
-
if ('name' in extension && initialized.has(extension.name)) {
|
|
185
|
-
return;
|
|
186
|
-
}
|
|
187
|
-
if ('requires' in extension) {
|
|
188
|
-
const requires = extension.requires || [];
|
|
189
|
-
const requireNames = requires.map((e) => typeof e === 'string' ? e : ('name' in e ? e.name : ''));
|
|
190
|
-
for (const require of requireNames) {
|
|
191
|
-
if (!initialized.has(require)) {
|
|
192
|
-
const requiredExtension = allExtensions.get(require);
|
|
193
|
-
if (!requiredExtension) {
|
|
194
|
-
throw new Error(`Required extension for (${'name' in extension ? extension.name : extension}) not found: ${require}`);
|
|
195
|
-
}
|
|
196
|
-
recursiveInitializeExtension(requiredExtension);
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
if ('name' in extension) {
|
|
201
|
-
initializeExtension(extension);
|
|
202
|
-
initialized.add(extension.name);
|
|
203
|
-
allExtensions.delete(extension.name);
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
for (const extension of allExtensions.values()) {
|
|
207
|
-
recursiveInitializeExtension(extension);
|
|
208
|
-
}
|
|
209
|
-
if (allExtensions.size > 0) {
|
|
210
|
-
throw new Error('Not all extensions initialized: ' +
|
|
211
|
-
Array.from(allExtensions.keys()).join(', '));
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
getSchemaByResolvedExtensions(editor) {
|
|
215
|
-
const { nodeExtensions, markExtensions, baseExtensions } = splitExtensions(this.extensions);
|
|
216
|
-
for (const extension of baseExtensions) {
|
|
217
|
-
if (Array.isArray(extension.conflicts)) {
|
|
218
|
-
for (const name of extension.conflicts) {
|
|
219
|
-
if (this.getExtension(name)) {
|
|
220
|
-
throw new Error(`Extension conflict: ${extension.name} vs ${name}`);
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
const nodes = {};
|
|
226
|
-
for (const extension of nodeExtensions) {
|
|
227
|
-
nodes[extension.name] = extension.getNodeSpec();
|
|
228
|
-
addAttributesToSchema(nodes[extension.name], extension);
|
|
229
|
-
}
|
|
230
|
-
const marks = {};
|
|
231
|
-
for (const extension of markExtensions) {
|
|
232
|
-
marks[extension.name] = extension.getMarkSpec();
|
|
233
|
-
addAttributesToSchema(marks[extension.name], extension);
|
|
234
|
-
}
|
|
235
|
-
const spec = {
|
|
236
|
-
topNode: this.editor.config.topNode || 'doc',
|
|
237
|
-
nodes,
|
|
238
|
-
marks,
|
|
239
|
-
};
|
|
240
|
-
for (const extension of baseExtensions) {
|
|
241
|
-
if ('setupSpec' in baseExtensions) {
|
|
242
|
-
extension.setupSpec(spec);
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
const event = new CustomEvent('schema:spec', {
|
|
246
|
-
detail: {
|
|
247
|
-
editor,
|
|
248
|
-
spec,
|
|
249
|
-
},
|
|
250
|
-
});
|
|
251
|
-
editor.dispatchEvent(event);
|
|
252
|
-
return new Schema(spec);
|
|
253
|
-
}
|
|
254
|
-
created() {
|
|
255
|
-
this.initPlugins();
|
|
256
|
-
for (const extension of this.extensions) {
|
|
257
|
-
extension.created();
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
}
|
package/esm/editor/src/Mark.d.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import type { MarkSpec, MarkType } from 'prosemirror-model';
|
|
2
|
-
import type { InputRule } from './plugins/input-rules/InputRulesPlugin.js';
|
|
3
|
-
import type { CoreEditor } from './CoreEditor.js';
|
|
4
|
-
import type { CommandFactories, CommandShortcuts } from './commands/mod.js';
|
|
5
|
-
import { Attribute } from './types.js';
|
|
6
|
-
export interface MarkConfig {
|
|
7
|
-
[key: string]: any;
|
|
8
|
-
}
|
|
9
|
-
export declare abstract class Mark {
|
|
10
|
-
protected config: Partial<MarkConfig>;
|
|
11
|
-
readonly type = "mark";
|
|
12
|
-
name: string;
|
|
13
|
-
protected editor: CoreEditor;
|
|
14
|
-
readonly attributes: Record<string, Attribute<any>>;
|
|
15
|
-
constructor(config?: Partial<MarkConfig>);
|
|
16
|
-
setEditor(editor: CoreEditor): void;
|
|
17
|
-
created(): void;
|
|
18
|
-
getMarkSpec(): MarkSpec;
|
|
19
|
-
getInputRules(type: MarkType): InputRule[];
|
|
20
|
-
getCommandFactories(editor: CoreEditor, type: MarkType): Partial<CommandFactories>;
|
|
21
|
-
getKeyboardShortcuts(editor: CoreEditor): Partial<CommandShortcuts>;
|
|
22
|
-
}
|
|
23
|
-
//# sourceMappingURL=Mark.d.ts.map
|
|
@@ -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"}
|