@kerebron/extension-odt 0.3.2 → 0.4.0
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/esm/extension-odt/src/ExtensionOdt.d.ts.map +1 -1
- package/esm/extension-odt/src/ExtensionOdt.js +5 -1
- package/esm/extension-odt/src/OdtParser.d.ts.map +1 -1
- package/esm/extension-odt/src/OdtParser.js +12 -16
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -26,11 +26,20 @@ number of output npm modules.
|
|
|
26
26
|
|
|
27
27
|
**Work in progress**
|
|
28
28
|
|
|
29
|
+
|
|
30
|
+
## Build
|
|
31
|
+
|
|
32
|
+
### Build static examples and `.wasm` files
|
|
33
|
+
|
|
34
|
+
```sh
|
|
35
|
+
deno task build
|
|
36
|
+
```
|
|
37
|
+
|
|
29
38
|
## Development
|
|
30
39
|
|
|
31
40
|
To start example server:
|
|
32
41
|
|
|
33
|
-
```
|
|
42
|
+
```sh
|
|
34
43
|
deno task -f server-deno-hono start
|
|
35
44
|
```
|
|
36
45
|
|
|
@@ -38,14 +47,6 @@ deno task -f server-deno-hono start
|
|
|
38
47
|
|
|
39
48
|
TODO
|
|
40
49
|
|
|
41
|
-
## Build
|
|
42
|
-
|
|
43
|
-
### Build static examples
|
|
44
|
-
|
|
45
|
-
```shell
|
|
46
|
-
deno task -r build
|
|
47
|
-
```
|
|
48
|
-
|
|
49
50
|
### NPM packages are generated using DNT
|
|
50
51
|
|
|
51
52
|
- https://deno.com/blog/publish-esm-cjs-module-dnt - the easiest way to publish
|
|
@@ -55,13 +56,27 @@ deno task -r build
|
|
|
55
56
|
|
|
56
57
|
To generate npm packages
|
|
57
58
|
|
|
58
|
-
```
|
|
59
|
+
```sh
|
|
59
60
|
deno -A ./build/build_npm.ts
|
|
60
61
|
```
|
|
61
62
|
|
|
62
63
|
## Run through docker
|
|
63
64
|
|
|
64
|
-
```
|
|
65
|
+
```sh
|
|
65
66
|
docker build . -t editor-test
|
|
66
67
|
docker run -it -p 8000:8000 -v $PWD:/usr/src/app editor-test
|
|
67
68
|
```
|
|
69
|
+
|
|
70
|
+
## Prerequisites
|
|
71
|
+
|
|
72
|
+
Install deno
|
|
73
|
+
|
|
74
|
+
```
|
|
75
|
+
npm install -g deno
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Install rust
|
|
79
|
+
|
|
80
|
+
```
|
|
81
|
+
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
|
|
82
|
+
```
|
|
@@ -1,19 +1,27 @@
|
|
|
1
1
|
import { EditorView } from 'prosemirror-view';
|
|
2
2
|
import { Node as ProseMirrorNode, Schema } from 'prosemirror-model';
|
|
3
|
-
import type {
|
|
3
|
+
import type { EditorConfig, JSONContent } from './types.js';
|
|
4
4
|
import { EditorState, Transaction } from 'prosemirror-state';
|
|
5
5
|
import { DummyEditorView } from './DummyEditorView.js';
|
|
6
6
|
import { ChainedCommands } from './commands/mod.js';
|
|
7
7
|
import { Extension } from './Extension.js';
|
|
8
|
+
import { EditorUi } from './ui.js';
|
|
8
9
|
export declare class CoreEditor extends EventTarget {
|
|
9
|
-
readonly
|
|
10
|
+
readonly config: Partial<EditorConfig>;
|
|
10
11
|
private extensionManager;
|
|
11
12
|
private commandManager;
|
|
12
13
|
view: EditorView | DummyEditorView;
|
|
13
14
|
state: EditorState;
|
|
14
|
-
|
|
15
|
+
ui: EditorUi;
|
|
16
|
+
constructor(config?: Partial<EditorConfig>);
|
|
15
17
|
getExtension<T extends Extension>(name: string): T | undefined;
|
|
16
18
|
get schema(): Schema<any, any>;
|
|
19
|
+
get run(): {
|
|
20
|
+
[key: string]: (...args: any[]) => boolean;
|
|
21
|
+
};
|
|
22
|
+
get commandFactories(): {
|
|
23
|
+
[key: string]: import("./commands/types.js").CommandFactory;
|
|
24
|
+
};
|
|
17
25
|
chain(): ChainedCommands;
|
|
18
26
|
can(): ChainedCommands;
|
|
19
27
|
private createView;
|
|
@@ -25,7 +33,8 @@ export declare class CoreEditor extends EventTarget {
|
|
|
25
33
|
loadDocument(mediaType: string, content: Uint8Array): Promise<void>;
|
|
26
34
|
saveDocument(mediaType: string): Promise<Uint8Array>;
|
|
27
35
|
getJSON(): JSONContent;
|
|
28
|
-
clone(options?: Partial<
|
|
36
|
+
clone(options?: Partial<EditorConfig>): CoreEditor;
|
|
29
37
|
debug(doc?: ProseMirrorNode): void;
|
|
38
|
+
destroy(): void;
|
|
30
39
|
}
|
|
31
40
|
//# sourceMappingURL=CoreEditor.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CoreEditor.d.ts","sourceRoot":"","sources":["../../../src/editor/src/CoreEditor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,IAAI,IAAI,eAAe,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAGpE,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"CoreEditor.d.ts","sourceRoot":"","sources":["../../../src/editor/src/CoreEditor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,IAAI,IAAI,eAAe,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAGpE,OAAO,KAAK,EAAE,YAAY,EAAE,WAA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AO3B,OAAO;CAOf"}
|
|
@@ -6,6 +6,7 @@ import { CommandManager } from './commands/CommandManager.js';
|
|
|
6
6
|
import { nodeToTreeString } from './nodeToTreeString.js';
|
|
7
7
|
import { DummyEditorView } from './DummyEditorView.js';
|
|
8
8
|
import { createNodeFromObject } from './utilities/createNodeFromContent.js';
|
|
9
|
+
import { defaultUi } from './ui.js';
|
|
9
10
|
function ensureDocSchema(doc, schema) {
|
|
10
11
|
if (doc.type.schema === schema) {
|
|
11
12
|
return doc;
|
|
@@ -14,9 +15,9 @@ function ensureDocSchema(doc, schema) {
|
|
|
14
15
|
return ProseMirrorNode.fromJSON(schema, json);
|
|
15
16
|
}
|
|
16
17
|
export class CoreEditor extends EventTarget {
|
|
17
|
-
constructor(
|
|
18
|
+
constructor(config = {}) {
|
|
18
19
|
super();
|
|
19
|
-
Object.defineProperty(this, "
|
|
20
|
+
Object.defineProperty(this, "config", {
|
|
20
21
|
enumerable: true,
|
|
21
22
|
configurable: true,
|
|
22
23
|
writable: true,
|
|
@@ -49,20 +50,27 @@ export class CoreEditor extends EventTarget {
|
|
|
49
50
|
writable: true,
|
|
50
51
|
value: void 0
|
|
51
52
|
});
|
|
52
|
-
this
|
|
53
|
-
|
|
54
|
-
|
|
53
|
+
Object.defineProperty(this, "ui", {
|
|
54
|
+
enumerable: true,
|
|
55
|
+
configurable: true,
|
|
56
|
+
writable: true,
|
|
57
|
+
value: defaultUi(this)
|
|
58
|
+
});
|
|
59
|
+
this.config = {
|
|
60
|
+
...this.config,
|
|
61
|
+
...config,
|
|
55
62
|
};
|
|
56
|
-
this.
|
|
63
|
+
this.commandManager = new CommandManager(this);
|
|
64
|
+
this.extensionManager = new ExtensionManager(this.config.extensions || [], this, this.commandManager);
|
|
65
|
+
this.extensionManager.created();
|
|
57
66
|
// const content = this.options.content ? this.options.content : {
|
|
58
67
|
// type: this.extensionManager.schema.topNodeType.name,
|
|
59
68
|
// content: this.extensionManager.schema.topNodeType.spec.EMPTY_DOC,
|
|
60
69
|
// };
|
|
61
|
-
const content = this.
|
|
62
|
-
? this.
|
|
70
|
+
const content = this.config.content
|
|
71
|
+
? this.config.content
|
|
63
72
|
: this.extensionManager.schema.topNodeType.spec.EMPTY_DOC;
|
|
64
73
|
this.createView(content);
|
|
65
|
-
this.commandManager = new CommandManager(this, this.extensionManager.commandFactories);
|
|
66
74
|
this.setupPlugins();
|
|
67
75
|
}
|
|
68
76
|
getExtension(name) {
|
|
@@ -71,6 +79,12 @@ export class CoreEditor extends EventTarget {
|
|
|
71
79
|
get schema() {
|
|
72
80
|
return this.extensionManager.schema;
|
|
73
81
|
}
|
|
82
|
+
get run() {
|
|
83
|
+
return this.commandManager.run;
|
|
84
|
+
}
|
|
85
|
+
get commandFactories() {
|
|
86
|
+
return this.commandManager.commandFactories;
|
|
87
|
+
}
|
|
74
88
|
chain() {
|
|
75
89
|
return this.commandManager.createChain();
|
|
76
90
|
}
|
|
@@ -80,14 +94,30 @@ export class CoreEditor extends EventTarget {
|
|
|
80
94
|
createView(content) {
|
|
81
95
|
const doc = createNodeFromObject(content, this.schema);
|
|
82
96
|
this.state = EditorState.create({ doc });
|
|
83
|
-
if (this.
|
|
84
|
-
|
|
97
|
+
if (this.config.element) {
|
|
98
|
+
const view = new EditorView(this.config.element, {
|
|
85
99
|
state: this.state,
|
|
86
100
|
attributes: {
|
|
87
101
|
class: 'kb-editor',
|
|
88
102
|
},
|
|
89
103
|
dispatchTransaction: (tx) => this.dispatchTransaction(tx),
|
|
90
104
|
});
|
|
105
|
+
this.view = view;
|
|
106
|
+
const parent = this.config.element.parentNode;
|
|
107
|
+
if (parent) {
|
|
108
|
+
const observer = new MutationObserver((mutations) => {
|
|
109
|
+
for (const mutation of mutations) {
|
|
110
|
+
for (const removedNode of mutation.removedNodes) {
|
|
111
|
+
if (removedNode.contains(view.dom)) {
|
|
112
|
+
// Editor DOM was removed
|
|
113
|
+
observer.disconnect(); // Prevent multiple calls
|
|
114
|
+
view.destroy();
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
}
|
|
91
121
|
}
|
|
92
122
|
else {
|
|
93
123
|
this.view = new DummyEditorView({
|
|
@@ -95,6 +125,13 @@ export class CoreEditor extends EventTarget {
|
|
|
95
125
|
dispatchTransaction: (tx) => this.dispatchTransaction(tx),
|
|
96
126
|
});
|
|
97
127
|
}
|
|
128
|
+
const event = new CustomEvent('doc:loaded', {
|
|
129
|
+
detail: {
|
|
130
|
+
editor: this,
|
|
131
|
+
doc,
|
|
132
|
+
},
|
|
133
|
+
});
|
|
134
|
+
this.dispatchEvent(event);
|
|
98
135
|
}
|
|
99
136
|
dispatchTransaction(transaction) {
|
|
100
137
|
this.state = this.state.apply(transaction);
|
|
@@ -108,6 +145,14 @@ export class CoreEditor extends EventTarget {
|
|
|
108
145
|
});
|
|
109
146
|
this.dispatchEvent(event);
|
|
110
147
|
}
|
|
148
|
+
if (transaction.docChanged) {
|
|
149
|
+
const event = new CustomEvent('changed', {
|
|
150
|
+
detail: {
|
|
151
|
+
editor: this,
|
|
152
|
+
},
|
|
153
|
+
});
|
|
154
|
+
this.dispatchEvent(event);
|
|
155
|
+
}
|
|
111
156
|
}
|
|
112
157
|
setupPlugins() {
|
|
113
158
|
this.state = this.state.reconfigure({
|
|
@@ -188,7 +233,7 @@ export class CoreEditor extends EventTarget {
|
|
|
188
233
|
clone(options = {}) {
|
|
189
234
|
return new CoreEditor({
|
|
190
235
|
...options,
|
|
191
|
-
extensions: [...(this.
|
|
236
|
+
extensions: [...(this.config.extensions || [])],
|
|
192
237
|
});
|
|
193
238
|
}
|
|
194
239
|
debug(doc) {
|
|
@@ -197,4 +242,11 @@ export class CoreEditor extends EventTarget {
|
|
|
197
242
|
}
|
|
198
243
|
console.debug(nodeToTreeString(doc));
|
|
199
244
|
}
|
|
245
|
+
destroy() {
|
|
246
|
+
const event = new CustomEvent('beforeDestroy', {
|
|
247
|
+
detail: {},
|
|
248
|
+
});
|
|
249
|
+
this.dispatchEvent(event);
|
|
250
|
+
this.view.destroy();
|
|
251
|
+
}
|
|
200
252
|
}
|
|
@@ -15,9 +15,14 @@ export declare abstract class Extension {
|
|
|
15
15
|
protected config: Partial<ExtensionConfig>;
|
|
16
16
|
readonly type = "extension";
|
|
17
17
|
abstract name: string;
|
|
18
|
+
protected editor: CoreEditor;
|
|
19
|
+
readonly conflicts?: Array<string>;
|
|
18
20
|
constructor(config?: Partial<ExtensionConfig>);
|
|
21
|
+
setEditor(editor: CoreEditor): void;
|
|
22
|
+
getEditor(): CoreEditor;
|
|
23
|
+
created(): void;
|
|
19
24
|
getInputRules(): InputRule[];
|
|
20
|
-
getProseMirrorPlugins(
|
|
25
|
+
getProseMirrorPlugins(): Plugin[];
|
|
21
26
|
getCommandFactories(editor: CoreEditor): Partial<CommandFactories>;
|
|
22
27
|
getKeyboardShortcuts(editor: CoreEditor): Partial<CommandShortcuts>;
|
|
23
28
|
getConverters(editor: CoreEditor, schema: Schema): Record<string, Converter>;
|
|
@@ -1 +1 @@
|
|
|
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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AU;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"}
|
|
@@ -12,11 +12,31 @@ export class Extension {
|
|
|
12
12
|
writable: true,
|
|
13
13
|
value: 'extension'
|
|
14
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() {
|
|
15
35
|
}
|
|
16
36
|
getInputRules() {
|
|
17
37
|
return [];
|
|
18
38
|
}
|
|
19
|
-
getProseMirrorPlugins(
|
|
39
|
+
getProseMirrorPlugins() {
|
|
20
40
|
return [];
|
|
21
41
|
}
|
|
22
42
|
getCommandFactories(editor) {
|
|
@@ -6,7 +6,7 @@ import { AnyExtension, AnyExtensionOrReq } from './types.js';
|
|
|
6
6
|
import { CoreEditor } from './CoreEditor.js';
|
|
7
7
|
import { Mark } from './Mark.js';
|
|
8
8
|
import { Node } from './Node.js';
|
|
9
|
-
import {
|
|
9
|
+
import { type CommandManager } from './commands/CommandManager.js';
|
|
10
10
|
export declare function findDuplicates(items: any[]): any[];
|
|
11
11
|
export declare function splitExtensions(extensions: Iterable<AnyExtension>): {
|
|
12
12
|
baseExtensions: Extension[];
|
|
@@ -15,19 +15,18 @@ export declare function splitExtensions(extensions: Iterable<AnyExtension>): {
|
|
|
15
15
|
};
|
|
16
16
|
export declare class ExtensionManager {
|
|
17
17
|
private editor;
|
|
18
|
+
private commandManager;
|
|
18
19
|
readonly schema: Schema;
|
|
19
20
|
private extensions;
|
|
20
21
|
readonly plugins: Plugin[];
|
|
21
22
|
readonly nodeViews: Record<string, NodeViewConstructor>;
|
|
22
|
-
readonly commandFactories: {
|
|
23
|
-
[key: string]: CommandFactory;
|
|
24
|
-
};
|
|
25
23
|
converters: Record<string, Converter>;
|
|
26
24
|
private debug;
|
|
27
|
-
constructor(extensions: AnyExtensionOrReq[], editor: CoreEditor);
|
|
25
|
+
constructor(extensions: AnyExtensionOrReq[], editor: CoreEditor, commandManager: CommandManager);
|
|
28
26
|
getExtension<T extends Extension>(name: string): T | undefined;
|
|
29
|
-
private
|
|
27
|
+
private initPlugins;
|
|
30
28
|
private setupExtensions;
|
|
31
29
|
getSchemaByResolvedExtensions(editor: CoreEditor): Schema;
|
|
30
|
+
created(): void;
|
|
32
31
|
}
|
|
33
32
|
//# sourceMappingURL=ExtensionManager.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
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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,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,8 +1,9 @@
|
|
|
1
1
|
import { Schema } from 'prosemirror-model';
|
|
2
2
|
import { InputRulesPlugin, } from './plugins/input-rules/InputRulesPlugin.js';
|
|
3
3
|
import { KeymapPlugin } from './plugins/keymap/keymap.js';
|
|
4
|
-
import {
|
|
4
|
+
import { firstCommand } from './commands/mod.js';
|
|
5
5
|
import { addAttributesToSchema } from './utilities/getHtmlAttributes.js';
|
|
6
|
+
import { TrackSelecionPlugin } from './plugins/TrackSelecionPlugin.js';
|
|
6
7
|
export function findDuplicates(items) {
|
|
7
8
|
const filtered = items.filter((el, index) => items.indexOf(el) !== index);
|
|
8
9
|
return Array.from(new Set(filtered));
|
|
@@ -18,13 +19,19 @@ export function splitExtensions(extensions) {
|
|
|
18
19
|
};
|
|
19
20
|
}
|
|
20
21
|
export class ExtensionManager {
|
|
21
|
-
constructor(extensions, editor) {
|
|
22
|
+
constructor(extensions, editor, commandManager) {
|
|
22
23
|
Object.defineProperty(this, "editor", {
|
|
23
24
|
enumerable: true,
|
|
24
25
|
configurable: true,
|
|
25
26
|
writable: true,
|
|
26
27
|
value: editor
|
|
27
28
|
});
|
|
29
|
+
Object.defineProperty(this, "commandManager", {
|
|
30
|
+
enumerable: true,
|
|
31
|
+
configurable: true,
|
|
32
|
+
writable: true,
|
|
33
|
+
value: commandManager
|
|
34
|
+
});
|
|
28
35
|
Object.defineProperty(this, "schema", {
|
|
29
36
|
enumerable: true,
|
|
30
37
|
configurable: true,
|
|
@@ -41,7 +48,7 @@ export class ExtensionManager {
|
|
|
41
48
|
enumerable: true,
|
|
42
49
|
configurable: true,
|
|
43
50
|
writable: true,
|
|
44
|
-
value:
|
|
51
|
+
value: []
|
|
45
52
|
});
|
|
46
53
|
Object.defineProperty(this, "nodeViews", {
|
|
47
54
|
enumerable: true,
|
|
@@ -49,12 +56,6 @@ export class ExtensionManager {
|
|
|
49
56
|
writable: true,
|
|
50
57
|
value: {}
|
|
51
58
|
});
|
|
52
|
-
Object.defineProperty(this, "commandFactories", {
|
|
53
|
-
enumerable: true,
|
|
54
|
-
configurable: true,
|
|
55
|
-
writable: true,
|
|
56
|
-
value: {}
|
|
57
|
-
});
|
|
58
59
|
Object.defineProperty(this, "converters", {
|
|
59
60
|
enumerable: true,
|
|
60
61
|
configurable: true,
|
|
@@ -76,7 +77,6 @@ export class ExtensionManager {
|
|
|
76
77
|
},
|
|
77
78
|
});
|
|
78
79
|
editor.dispatchEvent(event);
|
|
79
|
-
this.plugins = this.getPlugins();
|
|
80
80
|
}
|
|
81
81
|
getExtension(name) {
|
|
82
82
|
const { nodeExtensions, markExtensions, baseExtensions } = splitExtensions(this.extensions);
|
|
@@ -86,43 +86,15 @@ export class ExtensionManager {
|
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
|
-
|
|
90
|
-
const plugins = [];
|
|
89
|
+
initPlugins() {
|
|
91
90
|
const inputRules = [];
|
|
92
|
-
const commands = new Map();
|
|
93
91
|
const keyBindings = new Map();
|
|
94
|
-
const
|
|
95
|
-
for (const key in toInsert) {
|
|
96
|
-
const commandFactory = toInsert[key];
|
|
97
|
-
if (!commandFactory) {
|
|
98
|
-
continue;
|
|
99
|
-
}
|
|
100
|
-
if (this.debug) {
|
|
101
|
-
const wrappedFactory = (...args) => {
|
|
102
|
-
const realCommand = commandFactory(...args);
|
|
103
|
-
const command = (state, dispatch, view) => {
|
|
104
|
-
if (dispatch) {
|
|
105
|
-
console.debug(`Command: ${extName}.${key}`);
|
|
106
|
-
}
|
|
107
|
-
return realCommand(state, dispatch, view);
|
|
108
|
-
};
|
|
109
|
-
return command;
|
|
110
|
-
};
|
|
111
|
-
commands.set(key, wrappedFactory);
|
|
112
|
-
this.commandFactories[key] = wrappedFactory;
|
|
113
|
-
}
|
|
114
|
-
else {
|
|
115
|
-
commands.set(key, commandFactory);
|
|
116
|
-
this.commandFactories[key] = commandFactory;
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
};
|
|
120
|
-
function mergeShortcuts(toInsert, extName) {
|
|
92
|
+
const mergeShortcuts = (toInsert, extName) => {
|
|
121
93
|
for (const key in toInsert) {
|
|
122
94
|
if (!toInsert[key]) {
|
|
123
95
|
continue;
|
|
124
96
|
}
|
|
125
|
-
const commandFactory =
|
|
97
|
+
const commandFactory = this.commandManager.commandFactories[toInsert[key]];
|
|
126
98
|
if (!commandFactory) {
|
|
127
99
|
console.warn(`No command constructor: ${toInsert[key]}`);
|
|
128
100
|
continue;
|
|
@@ -130,26 +102,27 @@ export class ExtensionManager {
|
|
|
130
102
|
const command = commandFactory();
|
|
131
103
|
const keyBinding = keyBindings.get(key);
|
|
132
104
|
if (keyBinding) {
|
|
133
|
-
keyBindings.set(key,
|
|
105
|
+
keyBindings.set(key, firstCommand(command, keyBinding));
|
|
134
106
|
}
|
|
135
107
|
else {
|
|
136
108
|
keyBindings.set(key, command);
|
|
137
109
|
}
|
|
138
110
|
}
|
|
139
|
-
}
|
|
111
|
+
};
|
|
140
112
|
let converters = {};
|
|
141
113
|
for (const extension of this.extensions) {
|
|
114
|
+
extension.setEditor(this.editor);
|
|
142
115
|
if (extension.type === 'node') {
|
|
143
116
|
const nodeType = this.schema.nodes[extension.name];
|
|
144
117
|
inputRules.push(...extension.getInputRules(nodeType));
|
|
145
|
-
plugins.push(...extension.getProseMirrorPlugins(
|
|
146
|
-
|
|
118
|
+
this.plugins.push(...extension.getProseMirrorPlugins());
|
|
119
|
+
this.commandManager.mergeCommandFactories(extension.getCommandFactories(this.editor, nodeType), extension.name);
|
|
147
120
|
mergeShortcuts(extension.getKeyboardShortcuts(this.editor), extension.name);
|
|
148
121
|
converters = {
|
|
149
122
|
...converters,
|
|
150
123
|
...extension.getConverters(this.editor, this.schema),
|
|
151
124
|
};
|
|
152
|
-
const nodeView = extension.getNodeView();
|
|
125
|
+
const nodeView = extension.getNodeView(this.editor);
|
|
153
126
|
if (nodeView) {
|
|
154
127
|
this.nodeViews[extension.name] = nodeView;
|
|
155
128
|
}
|
|
@@ -157,12 +130,12 @@ export class ExtensionManager {
|
|
|
157
130
|
if (extension.type === 'mark') {
|
|
158
131
|
const markType = this.schema.marks[extension.name];
|
|
159
132
|
inputRules.push(...extension.getInputRules(markType));
|
|
160
|
-
|
|
133
|
+
this.commandManager.mergeCommandFactories(extension.getCommandFactories(this.editor, markType), extension.name);
|
|
161
134
|
mergeShortcuts(extension.getKeyboardShortcuts(this.editor), extension.name);
|
|
162
135
|
}
|
|
163
136
|
if (extension.type === 'extension') {
|
|
164
|
-
plugins.push(...extension.getProseMirrorPlugins(
|
|
165
|
-
|
|
137
|
+
this.plugins.push(...extension.getProseMirrorPlugins());
|
|
138
|
+
this.commandManager.mergeCommandFactories(extension.getCommandFactories(this.editor), extension.name);
|
|
166
139
|
mergeShortcuts(extension.getKeyboardShortcuts(this.editor), extension.name);
|
|
167
140
|
converters = {
|
|
168
141
|
...converters,
|
|
@@ -180,13 +153,13 @@ export class ExtensionManager {
|
|
|
180
153
|
console.debug(`Key: ${key}`);
|
|
181
154
|
return true;
|
|
182
155
|
};
|
|
183
|
-
keyBindings.set(key,
|
|
156
|
+
keyBindings.set(key, firstCommand(wrapperCommand, keyBinding));
|
|
184
157
|
}
|
|
185
158
|
}
|
|
186
159
|
this.converters = converters;
|
|
187
|
-
plugins.push(new InputRulesPlugin(inputRules));
|
|
188
|
-
plugins.push(new KeymapPlugin(Object.fromEntries(keyBindings)));
|
|
189
|
-
|
|
160
|
+
this.plugins.push(new InputRulesPlugin(inputRules));
|
|
161
|
+
this.plugins.push(new KeymapPlugin(Object.fromEntries(keyBindings)));
|
|
162
|
+
this.plugins.push(new TrackSelecionPlugin(this.editor));
|
|
190
163
|
}
|
|
191
164
|
setupExtensions(extensions) {
|
|
192
165
|
const allExtensions = new Map();
|
|
@@ -218,7 +191,7 @@ export class ExtensionManager {
|
|
|
218
191
|
if (!initialized.has(require)) {
|
|
219
192
|
const requiredExtension = allExtensions.get(require);
|
|
220
193
|
if (!requiredExtension) {
|
|
221
|
-
throw new Error(
|
|
194
|
+
throw new Error(`Required extension for (${'name' in extension ? extension.name : extension}) not found: ${require}`);
|
|
222
195
|
}
|
|
223
196
|
recursiveInitializeExtension(requiredExtension);
|
|
224
197
|
}
|
|
@@ -240,6 +213,15 @@ export class ExtensionManager {
|
|
|
240
213
|
}
|
|
241
214
|
getSchemaByResolvedExtensions(editor) {
|
|
242
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
|
+
}
|
|
243
225
|
const nodes = {};
|
|
244
226
|
for (const extension of nodeExtensions) {
|
|
245
227
|
nodes[extension.name] = extension.getNodeSpec();
|
|
@@ -251,7 +233,7 @@ export class ExtensionManager {
|
|
|
251
233
|
addAttributesToSchema(marks[extension.name], extension);
|
|
252
234
|
}
|
|
253
235
|
const spec = {
|
|
254
|
-
topNode: this.editor.
|
|
236
|
+
topNode: this.editor.config.topNode || 'doc',
|
|
255
237
|
nodes,
|
|
256
238
|
marks,
|
|
257
239
|
};
|
|
@@ -269,4 +251,10 @@ export class ExtensionManager {
|
|
|
269
251
|
editor.dispatchEvent(event);
|
|
270
252
|
return new Schema(spec);
|
|
271
253
|
}
|
|
254
|
+
created() {
|
|
255
|
+
this.initPlugins();
|
|
256
|
+
for (const extension of this.extensions) {
|
|
257
|
+
extension.created();
|
|
258
|
+
}
|
|
259
|
+
}
|
|
272
260
|
}
|
package/esm/editor/src/Mark.d.ts
CHANGED
|
@@ -10,8 +10,11 @@ export declare abstract class Mark {
|
|
|
10
10
|
protected config: Partial<MarkConfig>;
|
|
11
11
|
readonly type = "mark";
|
|
12
12
|
name: string;
|
|
13
|
+
protected editor: CoreEditor;
|
|
13
14
|
readonly attributes: Record<string, Attribute<any>>;
|
|
14
15
|
constructor(config?: Partial<MarkConfig>);
|
|
16
|
+
setEditor(editor: CoreEditor): void;
|
|
17
|
+
created(): void;
|
|
15
18
|
getMarkSpec(): MarkSpec;
|
|
16
19
|
getInputRules(type: MarkType): InputRule[];
|
|
17
20
|
getCommandFactories(editor: CoreEditor, type: MarkType): Partial<CommandFactories>;
|
|
@@ -1 +1 @@
|
|
|
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;
|
|
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
CHANGED
|
@@ -18,6 +18,12 @@ export class Mark {
|
|
|
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,6 +31,11 @@ export class Mark {
|
|
|
25
31
|
value: {}
|
|
26
32
|
});
|
|
27
33
|
}
|
|
34
|
+
setEditor(editor) {
|
|
35
|
+
this.editor = editor;
|
|
36
|
+
}
|
|
37
|
+
created() {
|
|
38
|
+
}
|
|
28
39
|
getMarkSpec() {
|
|
29
40
|
throw new Error('MarkSpec not defined: ' + this.name);
|
|
30
41
|
}
|
package/esm/editor/src/Node.d.ts
CHANGED
|
@@ -16,14 +16,17 @@ export declare abstract class Node {
|
|
|
16
16
|
protected config: Partial<NodeConfig>;
|
|
17
17
|
readonly type = "node";
|
|
18
18
|
name: string;
|
|
19
|
+
protected editor: CoreEditor;
|
|
19
20
|
readonly attributes: Record<string, Attribute<any>>;
|
|
20
21
|
constructor(config?: Partial<NodeConfig>);
|
|
22
|
+
setEditor(editor: CoreEditor): void;
|
|
23
|
+
created(): void;
|
|
21
24
|
getNodeSpec(): NodeSpec;
|
|
22
25
|
getInputRules(type: NodeType): InputRule[];
|
|
23
|
-
getProseMirrorPlugins(
|
|
26
|
+
getProseMirrorPlugins(): Plugin[];
|
|
24
27
|
getCommandFactories(editor: CoreEditor, type: NodeType): Partial<CommandFactories>;
|
|
25
28
|
getKeyboardShortcuts(editor: CoreEditor): Partial<CommandShortcuts>;
|
|
26
|
-
getNodeView(): NodeViewConstructor | undefined;
|
|
29
|
+
getNodeView(editor: CoreEditor): NodeViewConstructor | undefined;
|
|
27
30
|
getConverters(editor: CoreEditor, schema: Schema): Record<string, Converter>;
|
|
28
31
|
}
|
|
29
32
|
//# sourceMappingURL=Node.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
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,MAA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