@kerebron/extension-codemirror 0.2.1 → 0.3.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 +4 -3
- package/esm/editor/src/CoreEditor.d.ts +11 -5
- package/esm/editor/src/CoreEditor.d.ts.map +1 -1
- package/esm/editor/src/CoreEditor.js +62 -61
- package/esm/editor/src/DummyEditorView.d.ts +60 -0
- package/esm/editor/src/DummyEditorView.d.ts.map +1 -0
- package/esm/editor/src/DummyEditorView.js +277 -0
- package/esm/editor/src/Extension.d.ts +9 -9
- package/esm/editor/src/Extension.d.ts.map +1 -1
- package/esm/editor/src/Extension.js +2 -2
- package/esm/editor/src/ExtensionManager.d.ts +8 -7
- package/esm/editor/src/ExtensionManager.d.ts.map +1 -1
- package/esm/editor/src/ExtensionManager.js +58 -39
- package/esm/editor/src/Mark.d.ts +8 -6
- package/esm/editor/src/Mark.d.ts.map +1 -1
- package/esm/editor/src/Mark.js +8 -2
- package/esm/editor/src/Node.d.ts +14 -12
- package/esm/editor/src/Node.d.ts.map +1 -1
- package/esm/editor/src/Node.js +10 -4
- package/esm/editor/src/commands/CommandManager.d.ts +5 -9
- package/esm/editor/src/commands/CommandManager.d.ts.map +1 -1
- package/esm/editor/src/commands/CommandManager.js +7 -6
- package/esm/editor/src/commands/mod.d.ts +12 -6
- package/esm/editor/src/commands/mod.d.ts.map +1 -1
- package/esm/editor/src/commands/mod.js +0 -45
- package/esm/editor/src/mod.d.ts +1 -0
- package/esm/editor/src/mod.d.ts.map +1 -1
- package/esm/editor/src/mod.js +1 -0
- package/esm/editor/src/nodeToTreeString.d.ts.map +1 -1
- package/esm/editor/src/nodeToTreeString.js +23 -21
- package/esm/editor/src/plugins/input-rules/InputRulesPlugin.js +2 -2
- package/esm/editor/src/plugins/keymap/keymap.d.ts +11 -0
- package/esm/editor/src/plugins/keymap/keymap.d.ts.map +1 -0
- package/esm/editor/src/plugins/keymap/keymap.js +125 -0
- package/esm/editor/src/plugins/keymap/w3c-keyname.d.ts +4 -0
- package/esm/editor/src/plugins/keymap/w3c-keyname.d.ts.map +1 -0
- package/esm/editor/src/plugins/keymap/w3c-keyname.js +124 -0
- package/esm/editor/src/types.d.ts +10 -5
- package/esm/editor/src/types.d.ts.map +1 -1
- package/esm/editor/src/utilities/createNodeFromContent.d.ts +4 -3
- package/esm/editor/src/utilities/createNodeFromContent.d.ts.map +1 -1
- package/esm/editor/src/utilities/createNodeFromContent.js +4 -5
- package/esm/editor/src/utilities/getHtmlAttributes.d.ts +8 -3
- package/esm/editor/src/utilities/getHtmlAttributes.d.ts.map +1 -1
- package/esm/extension-codemirror/src/NodeCodeMirror.d.ts +2 -13
- package/esm/extension-codemirror/src/NodeCodeMirror.d.ts.map +1 -1
- package/esm/extension-codemirror/src/NodeCodeMirror.js +4 -16
- package/esm/extension-codemirror/src/defaults.d.ts.map +1 -1
- package/esm/extension-codemirror/src/utils.d.ts.map +1 -1
- package/package.json +2 -3
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { Schema } from 'prosemirror-model';
|
|
2
2
|
import { Plugin } from 'prosemirror-state';
|
|
3
3
|
import { NodeViewConstructor } from 'prosemirror-view';
|
|
4
|
-
import { Extension } from './Extension.js';
|
|
5
|
-
import { AnyExtension } from './types.js';
|
|
4
|
+
import { Converter, Extension } from './Extension.js';
|
|
5
|
+
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 { CommandFactory } from './commands/mod.js';
|
|
10
10
|
export declare function findDuplicates(items: any[]): any[];
|
|
11
11
|
export declare function splitExtensions(extensions: Iterable<AnyExtension>): {
|
|
12
12
|
baseExtensions: Extension[];
|
|
@@ -19,12 +19,13 @@ export declare class ExtensionManager {
|
|
|
19
19
|
private extensions;
|
|
20
20
|
readonly plugins: Plugin[];
|
|
21
21
|
readonly nodeViews: Record<string, NodeViewConstructor>;
|
|
22
|
-
readonly
|
|
23
|
-
[key: string]:
|
|
22
|
+
readonly commandFactories: {
|
|
23
|
+
[key: string]: CommandFactory;
|
|
24
24
|
};
|
|
25
|
-
|
|
25
|
+
converters: Record<string, Converter>;
|
|
26
26
|
private debug;
|
|
27
|
-
constructor(extensions:
|
|
27
|
+
constructor(extensions: AnyExtensionOrReq[], editor: CoreEditor);
|
|
28
|
+
getExtension(name: string): Extension | undefined;
|
|
28
29
|
private getPlugins;
|
|
29
30
|
private setupExtensions;
|
|
30
31
|
getSchemaByResolvedExtensions(editor: CoreEditor): Schema;
|
|
@@ -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;
|
|
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;AAMjC,OAAO,EAGL,cAAc,EAEf,MAAM,mBAAmB,CAAC;AAK3B,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;IAYkB,OAAO,CAAC,MAAM;IAX3D,SAAgB,MAAM,EAAE,MAAM,CAAC;IAE/B,OAAO,CAAC,UAAU,CAAgC;IAClD,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,CAAC;IAC3B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAM;IAE7D,QAAQ,CAAC,gBAAgB,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,cAAc,CAAA;KAAE,CAAM;IAC3D,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAM;IAElD,OAAO,CAAC,KAAK,CAAQ;gBAET,UAAU,EAAE,iBAAiB,EAAE,EAAU,MAAM,EAAE,UAAU;IAcvE,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS;IAYjD,OAAO,CAAC,UAAU;IAoJlB,OAAO,CAAC,eAAe;IAoEvB,6BAA6B,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM;CAuC1D"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Schema } from 'prosemirror-model';
|
|
2
|
-
import { keymap } from 'prosemirror-keymap';
|
|
3
2
|
import { InputRulesPlugin, } from './plugins/input-rules/InputRulesPlugin.js';
|
|
4
|
-
import {
|
|
3
|
+
import { KeymapPlugin } from './plugins/keymap/keymap.js';
|
|
4
|
+
import { chainCommands, } from './commands/mod.js';
|
|
5
5
|
import { addAttributesToSchema } from './utilities/getHtmlAttributes.js';
|
|
6
6
|
export function findDuplicates(items) {
|
|
7
7
|
const filtered = items.filter((el, index) => items.indexOf(el) !== index);
|
|
@@ -49,7 +49,7 @@ export class ExtensionManager {
|
|
|
49
49
|
writable: true,
|
|
50
50
|
value: {}
|
|
51
51
|
});
|
|
52
|
-
Object.defineProperty(this, "
|
|
52
|
+
Object.defineProperty(this, "commandFactories", {
|
|
53
53
|
enumerable: true,
|
|
54
54
|
configurable: true,
|
|
55
55
|
writable: true,
|
|
@@ -67,7 +67,7 @@ export class ExtensionManager {
|
|
|
67
67
|
writable: true,
|
|
68
68
|
value: true
|
|
69
69
|
});
|
|
70
|
-
this.setupExtensions(extensions);
|
|
70
|
+
this.setupExtensions(new Set(extensions));
|
|
71
71
|
this.schema = this.getSchemaByResolvedExtensions(editor);
|
|
72
72
|
const event = new CustomEvent('schema:ready', {
|
|
73
73
|
detail: {
|
|
@@ -78,6 +78,14 @@ export class ExtensionManager {
|
|
|
78
78
|
editor.dispatchEvent(event);
|
|
79
79
|
this.plugins = this.getPlugins();
|
|
80
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
|
+
}
|
|
81
89
|
getPlugins() {
|
|
82
90
|
const plugins = [];
|
|
83
91
|
const inputRules = [];
|
|
@@ -85,10 +93,13 @@ export class ExtensionManager {
|
|
|
85
93
|
const keyBindings = new Map();
|
|
86
94
|
const mergeCommands = (toInsert, extName) => {
|
|
87
95
|
for (const key in toInsert) {
|
|
88
|
-
const
|
|
96
|
+
const commandFactory = toInsert[key];
|
|
97
|
+
if (!commandFactory) {
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
89
100
|
if (this.debug) {
|
|
90
|
-
const
|
|
91
|
-
const realCommand =
|
|
101
|
+
const wrappedFactory = (...args) => {
|
|
102
|
+
const realCommand = commandFactory(...args);
|
|
92
103
|
const command = (state, dispatch, view) => {
|
|
93
104
|
if (dispatch) {
|
|
94
105
|
console.debug(`Command: ${extName}.${key}`);
|
|
@@ -97,23 +108,26 @@ export class ExtensionManager {
|
|
|
97
108
|
};
|
|
98
109
|
return command;
|
|
99
110
|
};
|
|
100
|
-
commands.set(key,
|
|
101
|
-
this.
|
|
111
|
+
commands.set(key, wrappedFactory);
|
|
112
|
+
this.commandFactories[key] = wrappedFactory;
|
|
102
113
|
}
|
|
103
114
|
else {
|
|
104
|
-
commands.set(key,
|
|
105
|
-
this.
|
|
115
|
+
commands.set(key, commandFactory);
|
|
116
|
+
this.commandFactories[key] = commandFactory;
|
|
106
117
|
}
|
|
107
118
|
}
|
|
108
119
|
};
|
|
109
120
|
function mergeShortcuts(toInsert, extName) {
|
|
110
121
|
for (const key in toInsert) {
|
|
111
|
-
|
|
112
|
-
|
|
122
|
+
if (!toInsert[key]) {
|
|
123
|
+
continue;
|
|
124
|
+
}
|
|
125
|
+
const commandFactory = commands.get(toInsert[key]);
|
|
126
|
+
if (!commandFactory) {
|
|
113
127
|
console.warn(`No command constructor: ${toInsert[key]}`);
|
|
114
128
|
continue;
|
|
115
129
|
}
|
|
116
|
-
const command =
|
|
130
|
+
const command = commandFactory();
|
|
117
131
|
const keyBinding = keyBindings.get(key);
|
|
118
132
|
if (keyBinding) {
|
|
119
133
|
keyBindings.set(key, chainCommands(keyBinding, command));
|
|
@@ -129,7 +143,7 @@ export class ExtensionManager {
|
|
|
129
143
|
const nodeType = this.schema.nodes[extension.name];
|
|
130
144
|
inputRules.push(...extension.getInputRules(nodeType));
|
|
131
145
|
plugins.push(...extension.getProseMirrorPlugins(this.editor, this.schema));
|
|
132
|
-
mergeCommands(extension.
|
|
146
|
+
mergeCommands(extension.getCommandFactories(this.editor, nodeType), extension.name);
|
|
133
147
|
mergeShortcuts(extension.getKeyboardShortcuts(this.editor), extension.name);
|
|
134
148
|
converters = {
|
|
135
149
|
...converters,
|
|
@@ -143,12 +157,12 @@ export class ExtensionManager {
|
|
|
143
157
|
if (extension.type === 'mark') {
|
|
144
158
|
const markType = this.schema.marks[extension.name];
|
|
145
159
|
inputRules.push(...extension.getInputRules(markType));
|
|
146
|
-
mergeCommands(extension.
|
|
160
|
+
mergeCommands(extension.getCommandFactories(this.editor, markType), extension.name);
|
|
147
161
|
mergeShortcuts(extension.getKeyboardShortcuts(this.editor), extension.name);
|
|
148
162
|
}
|
|
149
163
|
if (extension.type === 'extension') {
|
|
150
164
|
plugins.push(...extension.getProseMirrorPlugins(this.editor, this.schema));
|
|
151
|
-
mergeCommands(extension.
|
|
165
|
+
mergeCommands(extension.getCommandFactories(this.editor), extension.name);
|
|
152
166
|
mergeShortcuts(extension.getKeyboardShortcuts(this.editor), extension.name);
|
|
153
167
|
converters = {
|
|
154
168
|
...converters,
|
|
@@ -158,24 +172,30 @@ export class ExtensionManager {
|
|
|
158
172
|
}
|
|
159
173
|
if (this.debug) {
|
|
160
174
|
for (const key in keyBindings) {
|
|
175
|
+
const keyBinding = keyBindings.get(key);
|
|
176
|
+
if (!keyBinding) {
|
|
177
|
+
continue;
|
|
178
|
+
}
|
|
161
179
|
const wrapperCommand = (state, dispatch, view) => {
|
|
162
180
|
console.debug(`Key: ${key}`);
|
|
163
181
|
return true;
|
|
164
182
|
};
|
|
165
|
-
keyBindings.set(key, chainCommands(wrapperCommand,
|
|
183
|
+
keyBindings.set(key, chainCommands(wrapperCommand, keyBinding));
|
|
166
184
|
}
|
|
167
185
|
}
|
|
168
186
|
this.converters = converters;
|
|
169
187
|
plugins.push(new InputRulesPlugin(inputRules));
|
|
170
|
-
plugins.push(
|
|
188
|
+
plugins.push(new KeymapPlugin(Object.fromEntries(keyBindings)));
|
|
171
189
|
return plugins;
|
|
172
190
|
}
|
|
173
191
|
setupExtensions(extensions) {
|
|
174
192
|
const allExtensions = new Map();
|
|
175
193
|
const createMap = (extensions) => {
|
|
176
194
|
for (const extension of extensions) {
|
|
177
|
-
|
|
178
|
-
|
|
195
|
+
if ('name' in extension) {
|
|
196
|
+
allExtensions.set(extension.name, extension);
|
|
197
|
+
}
|
|
198
|
+
if ('requires' in extension) {
|
|
179
199
|
const childExtensions = Array.from(extension.requires).filter((e) => typeof e !== 'string');
|
|
180
200
|
createMap(new Set(childExtensions));
|
|
181
201
|
}
|
|
@@ -188,22 +208,27 @@ export class ExtensionManager {
|
|
|
188
208
|
this.extensions.add(extension);
|
|
189
209
|
};
|
|
190
210
|
function recursiveInitializeExtension(extension) {
|
|
191
|
-
if (initialized.has(extension.name)) {
|
|
211
|
+
if ('name' in extension && initialized.has(extension.name)) {
|
|
192
212
|
return;
|
|
193
213
|
}
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
if (!
|
|
199
|
-
|
|
214
|
+
if ('requires' in extension) {
|
|
215
|
+
const requires = extension.requires || [];
|
|
216
|
+
const requireNames = requires.map((e) => typeof e === 'string' ? e : ('name' in e ? e.name : ''));
|
|
217
|
+
for (const require of requireNames) {
|
|
218
|
+
if (!initialized.has(require)) {
|
|
219
|
+
const requiredExtension = allExtensions.get(require);
|
|
220
|
+
if (!requiredExtension) {
|
|
221
|
+
throw new Error('Required extension not found: ' + require);
|
|
222
|
+
}
|
|
223
|
+
recursiveInitializeExtension(requiredExtension);
|
|
200
224
|
}
|
|
201
|
-
recursiveInitializeExtension(requiredExtension);
|
|
202
225
|
}
|
|
203
226
|
}
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
227
|
+
if ('name' in extension) {
|
|
228
|
+
initializeExtension(extension);
|
|
229
|
+
initialized.add(extension.name);
|
|
230
|
+
allExtensions.delete(extension.name);
|
|
231
|
+
}
|
|
207
232
|
}
|
|
208
233
|
for (const extension of allExtensions.values()) {
|
|
209
234
|
recursiveInitializeExtension(extension);
|
|
@@ -219,17 +244,11 @@ export class ExtensionManager {
|
|
|
219
244
|
for (const extension of nodeExtensions) {
|
|
220
245
|
nodes[extension.name] = extension.getNodeSpec();
|
|
221
246
|
addAttributesToSchema(nodes[extension.name], extension);
|
|
222
|
-
if ('automerge' in extension) {
|
|
223
|
-
nodes[extension.name].automerge = extension.automerge;
|
|
224
|
-
}
|
|
225
247
|
}
|
|
226
248
|
const marks = {};
|
|
227
249
|
for (const extension of markExtensions) {
|
|
228
250
|
marks[extension.name] = extension.getMarkSpec();
|
|
229
251
|
addAttributesToSchema(marks[extension.name], extension);
|
|
230
|
-
if ('automerge' in extension) {
|
|
231
|
-
marks[extension.name].automerge = extension.automerge;
|
|
232
|
-
}
|
|
233
252
|
}
|
|
234
253
|
const spec = {
|
|
235
254
|
topNode: this.editor.options.topNode || 'doc',
|
|
@@ -238,7 +257,7 @@ export class ExtensionManager {
|
|
|
238
257
|
};
|
|
239
258
|
for (const extension of baseExtensions) {
|
|
240
259
|
if ('setupSpec' in baseExtensions) {
|
|
241
|
-
|
|
260
|
+
extension.setupSpec(spec);
|
|
242
261
|
}
|
|
243
262
|
}
|
|
244
263
|
const event = new CustomEvent('schema:spec', {
|
package/esm/editor/src/Mark.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { MarkSpec, MarkType } from 'prosemirror-model';
|
|
2
|
-
import { InputRule } from './plugins/input-rules/InputRulesPlugin.js';
|
|
3
|
-
import { CoreEditor } from './CoreEditor.js';
|
|
4
|
-
import {
|
|
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';
|
|
5
6
|
export interface MarkConfig {
|
|
6
7
|
[key: string]: any;
|
|
7
8
|
}
|
|
@@ -9,10 +10,11 @@ export declare abstract class Mark {
|
|
|
9
10
|
protected config: Partial<MarkConfig>;
|
|
10
11
|
readonly type = "mark";
|
|
11
12
|
name: string;
|
|
13
|
+
readonly attributes: Record<string, Attribute<any>>;
|
|
12
14
|
constructor(config?: Partial<MarkConfig>);
|
|
13
15
|
getMarkSpec(): MarkSpec;
|
|
14
16
|
getInputRules(type: MarkType): InputRule[];
|
|
15
|
-
|
|
16
|
-
getKeyboardShortcuts(): Partial<CommandShortcuts>;
|
|
17
|
+
getCommandFactories(editor: CoreEditor, type: MarkType): Partial<CommandFactories>;
|
|
18
|
+
getKeyboardShortcuts(editor: CoreEditor): Partial<CommandShortcuts>;
|
|
17
19
|
}
|
|
18
20
|
//# sourceMappingURL=Mark.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Mark.d.ts","sourceRoot":"","sources":["../../../src/editor/src/Mark.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;
|
|
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;IAML,SAAS,CAAC,MAAM,EAAE,OAAO,CAAC,UAAU,CAAC;IALxD,QAAQ,CAAC,IAAI,UAAU;IACvB,IAAI,EAAE,MAAM,CAAU;IAEtB,SAAgB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,CAAC,CAAC,CAAM;gBAEnC,MAAM,GAAE,OAAO,CAAC,UAAU,CAAM;IAE7D,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, "attributes", {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
configurable: true,
|
|
24
|
+
writable: true,
|
|
25
|
+
value: {}
|
|
26
|
+
});
|
|
21
27
|
}
|
|
22
28
|
getMarkSpec() {
|
|
23
29
|
throw new Error('MarkSpec not defined: ' + this.name);
|
|
@@ -25,10 +31,10 @@ export class Mark {
|
|
|
25
31
|
getInputRules(type) {
|
|
26
32
|
return [];
|
|
27
33
|
}
|
|
28
|
-
|
|
34
|
+
getCommandFactories(editor, type) {
|
|
29
35
|
return {};
|
|
30
36
|
}
|
|
31
|
-
getKeyboardShortcuts() {
|
|
37
|
+
getKeyboardShortcuts(editor) {
|
|
32
38
|
return {};
|
|
33
39
|
}
|
|
34
40
|
}
|
package/esm/editor/src/Node.d.ts
CHANGED
|
@@ -1,27 +1,29 @@
|
|
|
1
|
-
import { NodeSpec, NodeType } from 'prosemirror-model';
|
|
2
|
-
import { NodeViewConstructor } from 'prosemirror-view';
|
|
3
|
-
import { Plugin } from 'prosemirror-state';
|
|
4
|
-
import { InputRule } from './plugins/input-rules/InputRulesPlugin.js';
|
|
5
|
-
import { CoreEditor } from './CoreEditor.js';
|
|
6
|
-
import { Command, CommandShortcuts } from './commands/mod.js';
|
|
7
|
-
import { Converter } from './Extension.js';
|
|
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';
|
|
8
9
|
export interface NodeConfig {
|
|
9
10
|
[key: string]: any;
|
|
10
11
|
}
|
|
11
|
-
export interface
|
|
12
|
+
export interface CommandFactories {
|
|
12
13
|
[key: string]: () => Command;
|
|
13
14
|
}
|
|
14
15
|
export declare abstract class Node {
|
|
15
16
|
protected config: Partial<NodeConfig>;
|
|
16
17
|
readonly type = "node";
|
|
17
18
|
name: string;
|
|
19
|
+
readonly attributes: Record<string, Attribute<any>>;
|
|
18
20
|
constructor(config?: Partial<NodeConfig>);
|
|
19
21
|
getNodeSpec(): NodeSpec;
|
|
20
22
|
getInputRules(type: NodeType): InputRule[];
|
|
21
|
-
getProseMirrorPlugins(editor: CoreEditor): Plugin[];
|
|
22
|
-
|
|
23
|
-
getKeyboardShortcuts(): Partial<CommandShortcuts>;
|
|
23
|
+
getProseMirrorPlugins(editor: CoreEditor, schema: Schema): Plugin[];
|
|
24
|
+
getCommandFactories(editor: CoreEditor, type: NodeType): Partial<CommandFactories>;
|
|
25
|
+
getKeyboardShortcuts(editor: CoreEditor): Partial<CommandShortcuts>;
|
|
24
26
|
getNodeView(): NodeViewConstructor | undefined;
|
|
25
|
-
getConverters(): Record<string, Converter>;
|
|
27
|
+
getConverters(editor: CoreEditor, schema: Schema): Record<string, Converter>;
|
|
26
28
|
}
|
|
27
29
|
//# 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,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":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AC,gBAAgB,CAAC;IAI5B,oBAAoB,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAInE,WAAW,IAAI,mBAAmB,GAAG,SAAS;IAI9C,aAAa,CAAC,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC;CAG7E"}
|
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, "attributes", {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
configurable: true,
|
|
24
|
+
writable: true,
|
|
25
|
+
value: {}
|
|
26
|
+
});
|
|
21
27
|
}
|
|
22
28
|
getNodeSpec() {
|
|
23
29
|
throw new Error('NodeSpec not defined: ' + this.name);
|
|
@@ -25,19 +31,19 @@ export class Node {
|
|
|
25
31
|
getInputRules(type) {
|
|
26
32
|
return [];
|
|
27
33
|
}
|
|
28
|
-
getProseMirrorPlugins(editor) {
|
|
34
|
+
getProseMirrorPlugins(editor, schema) {
|
|
29
35
|
return [];
|
|
30
36
|
}
|
|
31
|
-
|
|
37
|
+
getCommandFactories(editor, type) {
|
|
32
38
|
return {};
|
|
33
39
|
}
|
|
34
|
-
getKeyboardShortcuts() {
|
|
40
|
+
getKeyboardShortcuts(editor) {
|
|
35
41
|
return {};
|
|
36
42
|
}
|
|
37
43
|
getNodeView() {
|
|
38
44
|
return undefined;
|
|
39
45
|
}
|
|
40
|
-
getConverters() {
|
|
46
|
+
getConverters(editor, schema) {
|
|
41
47
|
return {};
|
|
42
48
|
}
|
|
43
49
|
}
|
|
@@ -1,15 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { EditorState, Transaction } from 'prosemirror-state';
|
|
2
2
|
import { CoreEditor } from '../CoreEditor.js';
|
|
3
|
-
|
|
4
|
-
[key: string]: ChainedCommands;
|
|
5
|
-
} & {
|
|
6
|
-
run: () => boolean;
|
|
7
|
-
};
|
|
3
|
+
import { ChainedCommands, CommandFactory } from './mod.js';
|
|
8
4
|
export declare class CommandManager {
|
|
9
5
|
private editor;
|
|
10
|
-
private
|
|
11
|
-
constructor(editor: CoreEditor,
|
|
12
|
-
[key: string]:
|
|
6
|
+
private commandFactories;
|
|
7
|
+
constructor(editor: CoreEditor, commandFactories?: {
|
|
8
|
+
[key: string]: CommandFactory;
|
|
13
9
|
});
|
|
14
10
|
get state(): EditorState;
|
|
15
11
|
get chain(): () => ChainedCommands;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CommandManager.d.ts","sourceRoot":"","sources":["../../../../src/editor/src/commands/CommandManager.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"CommandManager.d.ts","sourceRoot":"","sources":["../../../../src/editor/src/commands/CommandManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,WAAW,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAC3E,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE3D,qBAAa,cAAc;IAEvB,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,gBAAgB;gBADhB,MAAM,EAAE,UAAU,EAClB,gBAAgB,GAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,cAAc,CAAA;KAAO;IAIlE,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,17 +1,17 @@
|
|
|
1
1
|
import { createChainableState } from './createChainableState.js';
|
|
2
2
|
export class CommandManager {
|
|
3
|
-
constructor(editor,
|
|
3
|
+
constructor(editor, commandFactories = {}) {
|
|
4
4
|
Object.defineProperty(this, "editor", {
|
|
5
5
|
enumerable: true,
|
|
6
6
|
configurable: true,
|
|
7
7
|
writable: true,
|
|
8
8
|
value: editor
|
|
9
9
|
});
|
|
10
|
-
Object.defineProperty(this, "
|
|
10
|
+
Object.defineProperty(this, "commandFactories", {
|
|
11
11
|
enumerable: true,
|
|
12
12
|
configurable: true,
|
|
13
13
|
writable: true,
|
|
14
|
-
value:
|
|
14
|
+
value: commandFactories
|
|
15
15
|
});
|
|
16
16
|
}
|
|
17
17
|
get state() {
|
|
@@ -24,7 +24,7 @@ export class CommandManager {
|
|
|
24
24
|
return () => this.createCan();
|
|
25
25
|
}
|
|
26
26
|
createChain(startTr, shouldDispatch = true) {
|
|
27
|
-
const {
|
|
27
|
+
const { commandFactories, editor, state } = this;
|
|
28
28
|
const { view } = editor;
|
|
29
29
|
const callbacks = [];
|
|
30
30
|
const hasStartTransaction = !!startTr;
|
|
@@ -32,9 +32,10 @@ export class CommandManager {
|
|
|
32
32
|
const chainedState = createChainableState(tr, state);
|
|
33
33
|
const fakeDispatch = () => undefined;
|
|
34
34
|
const chain = {
|
|
35
|
-
...Object.fromEntries(Object.entries(
|
|
35
|
+
...Object.fromEntries(Object.entries(commandFactories).map(([name, commandFactory]) => {
|
|
36
36
|
const chainedCommand = (...args) => {
|
|
37
|
-
const
|
|
37
|
+
const command = commandFactory(...args);
|
|
38
|
+
const callback = command(chainedState, shouldDispatch ? fakeDispatch : undefined);
|
|
38
39
|
callbacks.push(callback);
|
|
39
40
|
return chain;
|
|
40
41
|
};
|
|
@@ -37,13 +37,19 @@ export declare function toggleMark(markType: MarkType, attrs?: Attrs | null, opt
|
|
|
37
37
|
export declare function autoJoin(command: Command, isJoinable: ((before: Node, after: Node) => boolean) | readonly string[]): Command;
|
|
38
38
|
export declare function chainCommands(...commands: readonly Command[]): Command;
|
|
39
39
|
export declare function alternativeCommands(...commands: readonly Command[]): Command;
|
|
40
|
-
export
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
40
|
+
export type CommandFactory = (...args: any[]) => Command;
|
|
41
|
+
export interface Commands {
|
|
42
|
+
[name: string]: Command;
|
|
43
|
+
}
|
|
44
|
+
export interface CommandFactories {
|
|
45
|
+
[name: string]: CommandFactory;
|
|
46
|
+
}
|
|
46
47
|
export type CommandShortcuts = {
|
|
47
48
|
[name: string]: string;
|
|
48
49
|
};
|
|
50
|
+
export type ChainedCommands = {
|
|
51
|
+
[Item in keyof Commands]: (...args: unknown[]) => ChainedCommands;
|
|
52
|
+
} & {
|
|
53
|
+
run: () => boolean;
|
|
54
|
+
};
|
|
49
55
|
//# sourceMappingURL=mod.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../../../src/editor/src/commands/mod.ts"],"names":[],"mappings":"AAUA,OAAO,EACL,KAAK,EAGL,QAAQ,EACR,IAAI,EACJ,SAAS,EAET,QAAQ,EACR,WAAW,EAEZ,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAEL,OAAO,EAMP,WAAW,EACZ,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAMjD,wBAAgB,UAAU,CACxB,QAAQ,EAAE,QAAQ,EAClB,KAAK,GAAE,KAAK,GAAG,IAAW,GACzB,OAAO,CAUT;AAOD,wBAAgB,eAAe,CAC7B,EAAE,EAAE,WAAW,GAAG,IAAI,EACtB,KAAK,EAAE,SAAS,EAChB,QAAQ,EAAE,QAAQ,EAClB,KAAK,GAAE,KAAK,GAAG,IAAW,WA0B3B;AAmDD,eAAO,MAAM,eAAe,EAAE,OAI7B,CAAC;AAuBF,eAAO,MAAM,YAAY,EAAE,OAiE1B,CAAC;AAKF,e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= chainCommands(deleteSelection, joinBackward, selectNodeBackward);
|
|
885
|
-
let del = chainCommands(deleteSelection, joinForward, selectNodeForward);
|
|
886
|
-
/// A basic keymap containing bindings not specific to any schema.
|
|
887
|
-
/// Binds the following keys (when multiple commands are listed, they
|
|
888
|
-
/// are chained with [`chainCommands`](#commands.chainCommands)):
|
|
889
|
-
///
|
|
890
|
-
/// * **Enter** to `newlineInCode`, `createParagraphNear`, `liftEmptyBlock`, `splitBlock`
|
|
891
|
-
/// * **Mod-Enter** to `exitCode`
|
|
892
|
-
/// * **Backspace** and **Mod-Backspace** to `deleteSelection`, `joinBackward`, `selectNodeBackward`
|
|
893
|
-
/// * **Delete** and **Mod-Delete** to `deleteSelection`, `joinForward`, `selectNodeForward`
|
|
894
|
-
/// * **Mod-Delete** to `deleteSelection`, `joinForward`, `selectNodeForward`
|
|
895
|
-
/// * **Mod-a** to `selectAll`
|
|
896
|
-
const pcBaseKeymap = {
|
|
897
|
-
'Enter': chainCommands(newlineInCode, createParagraphNear, liftEmptyBlock, splitBlock),
|
|
898
|
-
'Mod-Enter': exitCode,
|
|
899
|
-
'Backspace': backspace,
|
|
900
|
-
'Mod-Backspace': backspace,
|
|
901
|
-
'Shift-Backspace': backspace,
|
|
902
|
-
'Delete': del,
|
|
903
|
-
'Mod-Delete': del,
|
|
904
|
-
'Mod-a': selectAll,
|
|
905
|
-
};
|
|
906
|
-
/// A copy of `pcBaseKeymap` that also binds **Ctrl-h** like Backspace,
|
|
907
|
-
/// **Ctrl-d** like Delete, **Alt-Backspace** like Ctrl-Backspace, and
|
|
908
|
-
/// **Ctrl-Alt-Backspace**, **Alt-Delete**, and **Alt-d** like
|
|
909
|
-
/// Ctrl-Delete.
|
|
910
|
-
const macBaseKeymap = {
|
|
911
|
-
'Ctrl-h': pcBaseKeymap['Backspace'],
|
|
912
|
-
'Alt-Backspace': pcBaseKeymap['Mod-Backspace'],
|
|
913
|
-
'Ctrl-d': pcBaseKeymap['Delete'],
|
|
914
|
-
'Ctrl-Alt-Backspace': pcBaseKeymap['Mod-Delete'],
|
|
915
|
-
'Alt-Delete': pcBaseKeymap['Mod-Delete'],
|
|
916
|
-
'Alt-d': pcBaseKeymap['Mod-Delete'],
|
|
917
|
-
'Ctrl-a': selectTextblockStart,
|
|
918
|
-
'Ctrl-e': selectTextblockEnd,
|
|
919
|
-
};
|
|
920
|
-
for (let key in pcBaseKeymap)
|
|
921
|
-
macBaseKeymap[key] = pcBaseKeymap[key];
|
|
922
|
-
const mac = /(Mac|iPhone|iPod|iPad)/i.test(navigator.platform);
|
|
923
|
-
/// Depending on the detected platform, this will hold
|
|
924
|
-
/// [`pcBasekeymap`](#commands.pcBaseKeymap) or
|
|
925
|
-
/// [`macBaseKeymap`](#commands.macBaseKeymap).
|
|
926
|
-
export const baseKeymap = mac
|
|
927
|
-
? macBaseKeymap
|
|
928
|
-
: pcBaseKeymap;
|
package/esm/editor/src/mod.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../../src/editor/src/mod.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,uBAAuB,CAAC"}
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../../src/editor/src/mod.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,uBAAuB,CAAC;AACtC,cAAc,YAAY,CAAC"}
|
package/esm/editor/src/mod.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nodeToTreeString.d.ts","sourceRoot":"","sources":["../../../src/editor/src/nodeToTreeString.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAYzC,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,IAAI,GAAG,IAAI,EAAE,GAAG,SAAS,IAAI,EAAE,EACrC,KAAK,SAAI,EACT,UAAU,SAAI,
|
|
1
|
+
{"version":3,"file":"nodeToTreeString.d.ts","sourceRoot":"","sources":["../../../src/editor/src/nodeToTreeString.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAYzC,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,IAAI,GAAG,IAAI,EAAE,GAAG,SAAS,IAAI,EAAE,EACrC,KAAK,SAAI,EACT,UAAU,SAAI,UA4Df;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,EAAE,QAE5C"}
|