@kerebron/extension-tables 0.1.3 → 0.2.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/assets/tables.css +46 -9
- package/package.json +4 -1
- package/esm/editor/src/CoreEditor.d.ts +0 -25
- package/esm/editor/src/CoreEditor.d.ts.map +0 -1
- package/esm/editor/src/CoreEditor.js +0 -194
- package/esm/editor/src/Extension.d.ts +0 -26
- package/esm/editor/src/Extension.d.ts.map +0 -1
- package/esm/editor/src/Extension.js +0 -33
- 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 -253
- package/esm/editor/src/Mark.d.ts +0 -18
- package/esm/editor/src/Mark.d.ts.map +0 -1
- package/esm/editor/src/Mark.js +0 -34
- package/esm/editor/src/Node.d.ts +0 -27
- package/esm/editor/src/Node.d.ts.map +0 -1
- package/esm/editor/src/Node.js +0 -43
- package/esm/editor/src/commands/CommandManager.d.ts +0 -20
- package/esm/editor/src/commands/CommandManager.d.ts.map +0 -1
- package/esm/editor/src/commands/CommandManager.js +0 -60
- 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/mod.d.ts +0 -49
- package/esm/editor/src/commands/mod.d.ts.map +0 -1
- package/esm/editor/src/commands/mod.js +0 -928
- package/esm/editor/src/mod.d.ts +0 -6
- package/esm/editor/src/mod.d.ts.map +0 -1
- package/esm/editor/src/mod.js +0 -5
- package/esm/editor/src/nodeToTreeString.d.ts +0 -4
- package/esm/editor/src/nodeToTreeString.d.ts.map +0 -1
- package/esm/editor/src/nodeToTreeString.js +0 -56
- 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/input-rules/mod.d.ts +0 -3
- package/esm/editor/src/plugins/input-rules/mod.d.ts.map +0 -1
- package/esm/editor/src/plugins/input-rules/mod.js +0 -2
- package/esm/editor/src/plugins/input-rules/rulebuilders.d.ts +0 -5
- package/esm/editor/src/plugins/input-rules/rulebuilders.d.ts.map +0 -1
- package/esm/editor/src/plugins/input-rules/rulebuilders.js +0 -50
- package/esm/editor/src/types.d.ts +0 -29
- package/esm/editor/src/types.d.ts.map +0 -1
- package/esm/editor/src/types.js +0 -1
- package/esm/editor/src/utilities/createNodeFromContent.d.ts +0 -8
- package/esm/editor/src/utilities/createNodeFromContent.d.ts.map +0 -1
- package/esm/editor/src/utilities/createNodeFromContent.js +0 -33
- package/esm/editor/src/utilities/getHtmlAttributes.d.ts +0 -4
- package/esm/editor/src/utilities/getHtmlAttributes.d.ts.map +0 -1
- package/esm/editor/src/utilities/getHtmlAttributes.js +0 -47
- package/esm/editor/src/utilities/mod.d.ts +0 -3
- package/esm/editor/src/utilities/mod.d.ts.map +0 -1
- package/esm/editor/src/utilities/mod.js +0 -2
- package/esm/extension-tables/src/ExtensionTables.d.ts +0 -10
- package/esm/extension-tables/src/ExtensionTables.d.ts.map +0 -1
- package/esm/extension-tables/src/ExtensionTables.js +0 -27
- package/esm/extension-tables/src/NodeTable.d.ts +0 -24
- package/esm/extension-tables/src/NodeTable.d.ts.map +0 -1
- package/esm/extension-tables/src/NodeTable.js +0 -115
- package/esm/extension-tables/src/NodeTableCell.d.ts +0 -16
- package/esm/extension-tables/src/NodeTableCell.d.ts.map +0 -1
- package/esm/extension-tables/src/NodeTableCell.js +0 -77
- package/esm/extension-tables/src/NodeTableHeader.d.ts +0 -16
- package/esm/extension-tables/src/NodeTableHeader.d.ts.map +0 -1
- package/esm/extension-tables/src/NodeTableHeader.js +0 -75
- package/esm/extension-tables/src/NodeTableRow.d.ts +0 -16
- package/esm/extension-tables/src/NodeTableRow.d.ts.map +0 -1
- package/esm/extension-tables/src/NodeTableRow.js +0 -47
- package/esm/extension-tables/src/utilities/CellSelection.d.ts +0 -53
- package/esm/extension-tables/src/utilities/CellSelection.d.ts.map +0 -1
- package/esm/extension-tables/src/utilities/CellSelection.js +0 -382
- package/esm/extension-tables/src/utilities/TableMap.d.ts +0 -92
- package/esm/extension-tables/src/utilities/TableMap.d.ts.map +0 -1
- package/esm/extension-tables/src/utilities/TableMap.js +0 -335
- package/esm/extension-tables/src/utilities/TableView.d.ts +0 -21
- package/esm/extension-tables/src/utilities/TableView.d.ts.map +0 -1
- package/esm/extension-tables/src/utilities/TableView.js +0 -108
- package/esm/extension-tables/src/utilities/columnResizing.d.ts +0 -50
- package/esm/extension-tables/src/utilities/columnResizing.d.ts.map +0 -1
- package/esm/extension-tables/src/utilities/columnResizing.js +0 -306
- package/esm/extension-tables/src/utilities/commands.d.ts +0 -166
- package/esm/extension-tables/src/utilities/commands.d.ts.map +0 -1
- package/esm/extension-tables/src/utilities/commands.js +0 -702
- package/esm/extension-tables/src/utilities/copypaste.d.ts +0 -35
- package/esm/extension-tables/src/utilities/copypaste.d.ts.map +0 -1
- package/esm/extension-tables/src/utilities/copypaste.js +0 -283
- package/esm/extension-tables/src/utilities/createCell.d.ts +0 -3
- package/esm/extension-tables/src/utilities/createCell.d.ts.map +0 -1
- package/esm/extension-tables/src/utilities/createCell.js +0 -6
- package/esm/extension-tables/src/utilities/createTable.d.ts +0 -3
- package/esm/extension-tables/src/utilities/createTable.d.ts.map +0 -1
- package/esm/extension-tables/src/utilities/createTable.js +0 -30
- package/esm/extension-tables/src/utilities/fixTables.d.ts +0 -20
- package/esm/extension-tables/src/utilities/fixTables.d.ts.map +0 -1
- package/esm/extension-tables/src/utilities/fixTables.js +0 -146
- package/esm/extension-tables/src/utilities/getTableNodeTypes.d.ts +0 -5
- package/esm/extension-tables/src/utilities/getTableNodeTypes.d.ts.map +0 -1
- package/esm/extension-tables/src/utilities/getTableNodeTypes.js +0 -14
- package/esm/extension-tables/src/utilities/input.d.ts +0 -21
- package/esm/extension-tables/src/utilities/input.d.ts.map +0 -1
- package/esm/extension-tables/src/utilities/input.js +0 -241
- package/esm/extension-tables/src/utilities/tableEditing.d.ts +0 -23
- package/esm/extension-tables/src/utilities/tableEditing.d.ts.map +0 -1
- package/esm/extension-tables/src/utilities/tableEditing.js +0 -63
- package/esm/extension-tables/src/utilities/tableNodeTypes.d.ts +0 -14
- package/esm/extension-tables/src/utilities/tableNodeTypes.d.ts.map +0 -1
- package/esm/extension-tables/src/utilities/tableNodeTypes.js +0 -16
- package/esm/extension-tables/src/utilities/util.d.ts +0 -73
- package/esm/extension-tables/src/utilities/util.d.ts.map +0 -1
- package/esm/extension-tables/src/utilities/util.js +0 -155
- package/esm/package.json +0 -3
package/assets/tables.css
CHANGED
|
@@ -1,26 +1,27 @@
|
|
|
1
|
-
.
|
|
1
|
+
.kb-editor .tableWrapper {
|
|
2
2
|
overflow-x: auto;
|
|
3
3
|
}
|
|
4
|
-
.
|
|
4
|
+
.kb-editor table {
|
|
5
5
|
border-collapse: collapse;
|
|
6
6
|
table-layout: fixed;
|
|
7
7
|
width: 100%;
|
|
8
8
|
overflow: hidden;
|
|
9
9
|
}
|
|
10
|
-
.
|
|
11
|
-
.
|
|
10
|
+
.kb-editor td,
|
|
11
|
+
.kb-editor th {
|
|
12
12
|
vertical-align: top;
|
|
13
13
|
box-sizing: border-box;
|
|
14
14
|
position: relative;
|
|
15
|
+
border: 1px solid var(--kb-color-border);
|
|
15
16
|
}
|
|
16
17
|
|
|
17
|
-
.
|
|
18
|
-
.
|
|
18
|
+
.kb-editor td:not([data-colwidth]):not(.column-resize-dragging),
|
|
19
|
+
.kb-editor th:not([data-colwidth]):not(.column-resize-dragging) {
|
|
19
20
|
/* if there's no explicit width set and the column is not being resized, set a default width */
|
|
20
21
|
min-width: var(--default-cell-min-width);
|
|
21
22
|
}
|
|
22
23
|
|
|
23
|
-
.
|
|
24
|
+
.kb-editor .column-resize-handle {
|
|
24
25
|
position: absolute;
|
|
25
26
|
right: -2px;
|
|
26
27
|
top: 0;
|
|
@@ -30,12 +31,12 @@
|
|
|
30
31
|
background-color: #adf;
|
|
31
32
|
pointer-events: none;
|
|
32
33
|
}
|
|
33
|
-
.
|
|
34
|
+
.kb-editor.resize-cursor {
|
|
34
35
|
cursor: ew-resize;
|
|
35
36
|
cursor: col-resize;
|
|
36
37
|
}
|
|
37
38
|
/* Give selected cells a blue overlay */
|
|
38
|
-
.
|
|
39
|
+
.kb-editor .selectedCell:after {
|
|
39
40
|
z-index: 2;
|
|
40
41
|
position: absolute;
|
|
41
42
|
content: '';
|
|
@@ -46,3 +47,39 @@
|
|
|
46
47
|
background: rgba(200, 200, 255, 0.4);
|
|
47
48
|
pointer-events: none;
|
|
48
49
|
}
|
|
50
|
+
|
|
51
|
+
/* Touch-optimized table editing */
|
|
52
|
+
@media (max-width: 767px) {
|
|
53
|
+
.kb-editor table {
|
|
54
|
+
font-size: var(--kb-text-sm);
|
|
55
|
+
border-collapse: collapse;
|
|
56
|
+
width: 100%;
|
|
57
|
+
overflow-x: auto;
|
|
58
|
+
display: block;
|
|
59
|
+
white-space: nowrap;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.kb-editor th,
|
|
63
|
+
.kb-editor td {
|
|
64
|
+
min-width: 120px;
|
|
65
|
+
padding: var(--kb-space-md);
|
|
66
|
+
border: 1px solid var(--kb-color-border);
|
|
67
|
+
vertical-align: top;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/* Hide complex table controls on mobile */
|
|
71
|
+
.tableWrapper .column-resize-handle {
|
|
72
|
+
display: none !important;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.kb-editor .tableWrapper {
|
|
76
|
+
overflow-x: auto;
|
|
77
|
+
-webkit-overflow-scrolling: touch;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/* Table selection visual feedback */
|
|
81
|
+
.kb-editor .selectedCell {
|
|
82
|
+
background: rgba(var(--kb-color-primary-rgb), 0.1);
|
|
83
|
+
border: 2px solid var(--kb-color-primary);
|
|
84
|
+
}
|
|
85
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kerebron/extension-tables",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"module": "./esm/extension-tables/src/ExtensionTables.js",
|
|
6
6
|
"exports": {
|
|
@@ -21,6 +21,9 @@
|
|
|
21
21
|
}
|
|
22
22
|
},
|
|
23
23
|
"scripts": {},
|
|
24
|
+
"files": [
|
|
25
|
+
"assets/*.css"
|
|
26
|
+
],
|
|
24
27
|
"dependencies": {
|
|
25
28
|
"prosemirror-keymap": "1.2.2",
|
|
26
29
|
"prosemirror-model": "1.25.1",
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { EditorView } from 'prosemirror-view';
|
|
2
|
-
import { Node as ProseMirrorNode, type Schema } from 'prosemirror-model';
|
|
3
|
-
import type { EditorOptions, JSONContent } from './types.js';
|
|
4
|
-
import { EditorState, Transaction } from 'prosemirror-state';
|
|
5
|
-
import { ChainedCommands } from './commands/CommandManager.js';
|
|
6
|
-
export declare class CoreEditor extends EventTarget {
|
|
7
|
-
readonly options: Partial<EditorOptions>;
|
|
8
|
-
private extensionManager;
|
|
9
|
-
private commandManager;
|
|
10
|
-
view: EditorView;
|
|
11
|
-
state: EditorState;
|
|
12
|
-
constructor(options?: Partial<EditorOptions>);
|
|
13
|
-
get schema(): Schema<any, any>;
|
|
14
|
-
chain(): ChainedCommands;
|
|
15
|
-
can(): ChainedCommands;
|
|
16
|
-
private createView;
|
|
17
|
-
dispatchTransaction(transaction: Transaction): void;
|
|
18
|
-
private setupPlugins;
|
|
19
|
-
setDocument(content?: any, mediaType?: string): void;
|
|
20
|
-
getDocument(mediaType?: string): void | ProseMirrorNode | JSONContent;
|
|
21
|
-
getJSON(): JSONContent;
|
|
22
|
-
clone(options?: Partial<EditorOptions>): CoreEditor;
|
|
23
|
-
debug(doc?: ProseMirrorNode): void;
|
|
24
|
-
}
|
|
25
|
-
//# sourceMappingURL=CoreEditor.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
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,KAAK,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAGzE,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAE7D,OAAO,EAAE,eAAe,EAAkB,MAAM,8BAA8B,CAAC;AAgC/E,qBAAa,UAAW,SAAQ,WAAW;IACzC,SAAgB,OAAO,EAAE,OAAO,CAAC,aAAa,CAAC,CAG7C;IACF,OAAO,CAAC,gBAAgB,CAAmB;IAC3C,OAAO,CAAC,cAAc,CAAiB;IAChC,IAAI,EAAG,UAAU,CAAC;IAClB,KAAK,EAAG,WAAW,CAAC;gBAEf,OAAO,GAAE,OAAO,CAAC,aAAa,CAAM;IAyBhD,IAAW,MAAM,qBAEhB;IAEM,KAAK,IAAI,eAAe;IAIxB,GAAG,IAAI,eAAe;IAI7B,OAAO,CAAC,UAAU;IAaX,mBAAmB,CAAC,WAAW,EAAE,WAAW;IAcnD,OAAO,CAAC,YAAY;IAcb,WAAW,CAAC,OAAO,CAAC,EAAE,GAAG,EAAE,SAAS,CAAC,EAAE,MAAM;IAwC7C,WAAW,CAAC,SAAS,CAAC,EAAE,MAAM;IAkB9B,OAAO,IAAI,WAAW;IAItB,KAAK,CAAC,OAAO,GAAE,OAAO,CAAC,aAAa,CAAM,GAAG,UAAU;IAOvD,KAAK,CAAC,GAAG,CAAC,EAAE,eAAe;CAMnC"}
|
|
@@ -1,194 +0,0 @@
|
|
|
1
|
-
import { EditorView } from 'prosemirror-view';
|
|
2
|
-
import { Node as ProseMirrorNode } from 'prosemirror-model';
|
|
3
|
-
import { ExtensionManager } from './ExtensionManager.js';
|
|
4
|
-
import { EditorState } from 'prosemirror-state';
|
|
5
|
-
import { createNodeFromContent } from './utilities/createNodeFromContent.js';
|
|
6
|
-
import { CommandManager } from './commands/CommandManager.js';
|
|
7
|
-
import { nodeToTreeString } from './nodeToTreeString.js';
|
|
8
|
-
function ensureDocSchema(doc, schema) {
|
|
9
|
-
if (doc.type.schema != schema) {
|
|
10
|
-
const findNode = (nodeName) => {
|
|
11
|
-
if (!schema.nodes[nodeName]) {
|
|
12
|
-
throw new Error(`Not able to rewrite schema for node '${nodeName}'`);
|
|
13
|
-
}
|
|
14
|
-
return schema.nodes[nodeName];
|
|
15
|
-
};
|
|
16
|
-
const findMark = (markName) => {
|
|
17
|
-
if (!schema.marks[markName]) {
|
|
18
|
-
throw new Error(`Not able to rewrite schema for mark '${markName}'`);
|
|
19
|
-
}
|
|
20
|
-
return schema.marks[markName];
|
|
21
|
-
};
|
|
22
|
-
// TODO fix readonly warnings
|
|
23
|
-
doc.type = findNode(doc.type.name);
|
|
24
|
-
doc.marks.forEach((mark) => {
|
|
25
|
-
mark.type = findMark(mark.type.name);
|
|
26
|
-
});
|
|
27
|
-
doc.descendants((node) => {
|
|
28
|
-
node.type = findNode(node.type.name);
|
|
29
|
-
node.marks.forEach((mark) => {
|
|
30
|
-
mark.type = findMark(mark.type.name);
|
|
31
|
-
});
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
export class CoreEditor extends EventTarget {
|
|
36
|
-
constructor(options = {}) {
|
|
37
|
-
super();
|
|
38
|
-
Object.defineProperty(this, "options", {
|
|
39
|
-
enumerable: true,
|
|
40
|
-
configurable: true,
|
|
41
|
-
writable: true,
|
|
42
|
-
value: {
|
|
43
|
-
element: null, // document.createElement('div'),
|
|
44
|
-
extensions: [],
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
Object.defineProperty(this, "extensionManager", {
|
|
48
|
-
enumerable: true,
|
|
49
|
-
configurable: true,
|
|
50
|
-
writable: true,
|
|
51
|
-
value: void 0
|
|
52
|
-
});
|
|
53
|
-
Object.defineProperty(this, "commandManager", {
|
|
54
|
-
enumerable: true,
|
|
55
|
-
configurable: true,
|
|
56
|
-
writable: true,
|
|
57
|
-
value: void 0
|
|
58
|
-
});
|
|
59
|
-
Object.defineProperty(this, "view", {
|
|
60
|
-
enumerable: true,
|
|
61
|
-
configurable: true,
|
|
62
|
-
writable: true,
|
|
63
|
-
value: void 0
|
|
64
|
-
});
|
|
65
|
-
Object.defineProperty(this, "state", {
|
|
66
|
-
enumerable: true,
|
|
67
|
-
configurable: true,
|
|
68
|
-
writable: true,
|
|
69
|
-
value: void 0
|
|
70
|
-
});
|
|
71
|
-
this.options = {
|
|
72
|
-
...this.options,
|
|
73
|
-
...options,
|
|
74
|
-
};
|
|
75
|
-
this.extensionManager = new ExtensionManager(this.options.extensions, this);
|
|
76
|
-
// const content = this.options.content ? this.options.content : {
|
|
77
|
-
// type: this.extensionManager.schema.topNodeType.name,
|
|
78
|
-
// content: this.extensionManager.schema.topNodeType.spec.EMPTY_DOC,
|
|
79
|
-
// };
|
|
80
|
-
const content = this.options.content
|
|
81
|
-
? this.options.content
|
|
82
|
-
: this.extensionManager.schema.topNodeType.spec.EMPTY_DOC;
|
|
83
|
-
this.createView(content);
|
|
84
|
-
this.commandManager = new CommandManager(this, this.extensionManager.commandConstructors);
|
|
85
|
-
this.setupPlugins();
|
|
86
|
-
}
|
|
87
|
-
get schema() {
|
|
88
|
-
return this.extensionManager.schema;
|
|
89
|
-
}
|
|
90
|
-
chain() {
|
|
91
|
-
return this.commandManager.chain();
|
|
92
|
-
}
|
|
93
|
-
can() {
|
|
94
|
-
return this.commandManager.can();
|
|
95
|
-
}
|
|
96
|
-
createView(content) {
|
|
97
|
-
const doc = createNodeFromContent(content, this.schema);
|
|
98
|
-
this.state = EditorState.create({ doc });
|
|
99
|
-
if (this.options.element) {
|
|
100
|
-
this.view = new EditorView(this.options.element, {
|
|
101
|
-
state: this.state,
|
|
102
|
-
dispatchTransaction: (tx) => this.dispatchTransaction(tx),
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
dispatchTransaction(transaction) {
|
|
107
|
-
this.state = this.state.apply(transaction);
|
|
108
|
-
if (this.view) {
|
|
109
|
-
this.view.updateState(this.state);
|
|
110
|
-
const event = new CustomEvent('transaction', {
|
|
111
|
-
detail: {
|
|
112
|
-
editor: this,
|
|
113
|
-
transaction,
|
|
114
|
-
},
|
|
115
|
-
});
|
|
116
|
-
this.dispatchEvent(event);
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
setupPlugins() {
|
|
120
|
-
this.state = this.state.reconfigure({
|
|
121
|
-
plugins: this.extensionManager.plugins,
|
|
122
|
-
});
|
|
123
|
-
if (this.view) {
|
|
124
|
-
this.view.updateState(this.state);
|
|
125
|
-
this.view.setProps({
|
|
126
|
-
nodeViews: this.extensionManager.nodeViews,
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
setDocument(content, mediaType) {
|
|
131
|
-
if (!content) {
|
|
132
|
-
content = {
|
|
133
|
-
type: this.extensionManager.schema.topNodeType.name,
|
|
134
|
-
content: this.extensionManager.schema.topNodeType.spec.EMPTY_DOC.content,
|
|
135
|
-
};
|
|
136
|
-
mediaType = undefined;
|
|
137
|
-
}
|
|
138
|
-
let doc;
|
|
139
|
-
if (mediaType) {
|
|
140
|
-
const converter = this.extensionManager.converters[mediaType];
|
|
141
|
-
if (converter) {
|
|
142
|
-
doc = converter.toDoc(content);
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
else {
|
|
146
|
-
doc = createNodeFromContent(content, this.schema);
|
|
147
|
-
}
|
|
148
|
-
ensureDocSchema(doc, this.schema);
|
|
149
|
-
this.state = EditorState.create({
|
|
150
|
-
doc,
|
|
151
|
-
plugins: this.state.plugins,
|
|
152
|
-
storedMarks: this.state.storedMarks,
|
|
153
|
-
});
|
|
154
|
-
if (this.view) {
|
|
155
|
-
this.view.updateState(this.state);
|
|
156
|
-
}
|
|
157
|
-
const event = new CustomEvent('doc:loaded', {
|
|
158
|
-
detail: {
|
|
159
|
-
editor: this,
|
|
160
|
-
doc,
|
|
161
|
-
},
|
|
162
|
-
});
|
|
163
|
-
this.dispatchEvent(event);
|
|
164
|
-
}
|
|
165
|
-
getDocument(mediaType) {
|
|
166
|
-
if (mediaType) {
|
|
167
|
-
const converter = this.extensionManager.converters[mediaType];
|
|
168
|
-
if (converter) {
|
|
169
|
-
const json = this.state.doc.toJSON();
|
|
170
|
-
const clonedDoc = ProseMirrorNode.fromJSON(this.state.schema, json);
|
|
171
|
-
return converter.fromDoc(clonedDoc);
|
|
172
|
-
}
|
|
173
|
-
if (mediaType === 'text/json') {
|
|
174
|
-
return this.getJSON();
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
return this.state.doc;
|
|
178
|
-
}
|
|
179
|
-
getJSON() {
|
|
180
|
-
return this.state.doc.toJSON();
|
|
181
|
-
}
|
|
182
|
-
clone(options = {}) {
|
|
183
|
-
return new CoreEditor({
|
|
184
|
-
...options,
|
|
185
|
-
extensions: [...this.options.extensions],
|
|
186
|
-
});
|
|
187
|
-
}
|
|
188
|
-
debug(doc) {
|
|
189
|
-
if (!doc) {
|
|
190
|
-
doc = this.state.doc;
|
|
191
|
-
}
|
|
192
|
-
console.debug(nodeToTreeString(doc));
|
|
193
|
-
}
|
|
194
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { Plugin } from 'prosemirror-state';
|
|
2
|
-
import { type CoreEditor } from './CoreEditor.js';
|
|
3
|
-
import { InputRule } from './plugins/input-rules/InputRulesPlugin.js';
|
|
4
|
-
import { Commands, CommandShortcuts } from './commands/mod.js';
|
|
5
|
-
import { Schema, type SchemaSpec } from 'prosemirror-model';
|
|
6
|
-
export interface ExtensionConfig {
|
|
7
|
-
[key: string]: any;
|
|
8
|
-
requires: Array<Extension | string>;
|
|
9
|
-
}
|
|
10
|
-
export interface Converter {
|
|
11
|
-
fromDoc(document: unknown): void;
|
|
12
|
-
toDoc(content: unknown): any;
|
|
13
|
-
}
|
|
14
|
-
export declare abstract class Extension {
|
|
15
|
-
protected config: Partial<ExtensionConfig>;
|
|
16
|
-
readonly type = "extension";
|
|
17
|
-
abstract name: string;
|
|
18
|
-
protected constructor(config?: Partial<ExtensionConfig>);
|
|
19
|
-
getInputRules(): InputRule[];
|
|
20
|
-
getProseMirrorPlugins(editor: CoreEditor, schema: Schema): Plugin[];
|
|
21
|
-
getCommands(editor: CoreEditor): Partial<Commands>;
|
|
22
|
-
getKeyboardShortcuts(): Partial<CommandShortcuts>;
|
|
23
|
-
getConverters(editor: CoreEditor, schema: Schema): Record<string, Converter>;
|
|
24
|
-
setupSpec(spec: SchemaSpec): void;
|
|
25
|
-
}
|
|
26
|
-
//# 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,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE3C,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,2CAA2C,CAAC;AACtE,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAE,MAAM,EAAE,KAAK,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE5D,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,OAAO,GAAG,IAAI,CAAC;IACjC,KAAK,CAAC,OAAO,EAAE,OAAO,GAAG,GAAG,CAAC;CAC9B;AAED,8BAAsB,SAAS;IAIP,SAAS,CAAC,MAAM,EAAE,OAAO,CAAC,eAAe,CAAC;IAHhE,QAAQ,CAAC,IAAI,eAAe;IAC5B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB,SAAS,aAAuB,MAAM,GAAE,OAAO,CAAC,eAAe,CAAM;IAGrE,aAAa,IAAI,SAAS,EAAE;IAI5B,qBAAqB,CAAC,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE;IAInE,WAAW,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,QAAQ,CAAC;IAIlD,oBAAoB,IAAI,OAAO,CAAC,gBAAgB,CAAC;IAIjD,aAAa,CAAC,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC;IAI5E,SAAS,CAAC,IAAI,EAAE,UAAU;CAE3B"}
|
|
@@ -1,33 +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
|
-
}
|
|
16
|
-
getInputRules() {
|
|
17
|
-
return [];
|
|
18
|
-
}
|
|
19
|
-
getProseMirrorPlugins(editor, schema) {
|
|
20
|
-
return [];
|
|
21
|
-
}
|
|
22
|
-
getCommands(editor) {
|
|
23
|
-
return {};
|
|
24
|
-
}
|
|
25
|
-
getKeyboardShortcuts() {
|
|
26
|
-
return {};
|
|
27
|
-
}
|
|
28
|
-
getConverters(editor, schema) {
|
|
29
|
-
return {};
|
|
30
|
-
}
|
|
31
|
-
setupSpec(spec) {
|
|
32
|
-
}
|
|
33
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { Schema } from 'prosemirror-model';
|
|
2
|
-
import { Plugin } from 'prosemirror-state';
|
|
3
|
-
import { NodeViewConstructor } from 'prosemirror-view';
|
|
4
|
-
import { Extension } from './Extension.js';
|
|
5
|
-
import { AnyExtension } from './types.js';
|
|
6
|
-
import { CoreEditor } from './CoreEditor.js';
|
|
7
|
-
import { Mark } from './Mark.js';
|
|
8
|
-
import { Node } from './Node.js';
|
|
9
|
-
import { type Command } from 'prosemirror-state';
|
|
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
|
-
readonly schema: Schema;
|
|
19
|
-
private extensions;
|
|
20
|
-
readonly plugins: Plugin[];
|
|
21
|
-
readonly nodeViews: Record<string, NodeViewConstructor>;
|
|
22
|
-
readonly commandConstructors: {
|
|
23
|
-
[key: string]: () => Command;
|
|
24
|
-
};
|
|
25
|
-
private converters;
|
|
26
|
-
private debug;
|
|
27
|
-
constructor(extensions: Set<AnyExtension>, editor: CoreEditor);
|
|
28
|
-
private getPlugins;
|
|
29
|
-
private setupExtensions;
|
|
30
|
-
getSchemaByResolvedExtensions(editor: CoreEditor): Schema;
|
|
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;AAE3C,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAEvD,OAAO,EAAa,SAAS,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,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,EAAE,KAAK,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAGjD,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;IAYgB,OAAO,CAAC,MAAM;IAXzD,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,mBAAmB,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,OAAO,CAAA;KAAE,CAAM;IACpE,OAAO,CAAC,UAAU,CAAiC;IAEnD,OAAO,CAAC,KAAK,CAAQ;gBAET,UAAU,EAAE,GAAG,CAAC,YAAY,CAAC,EAAU,MAAM,EAAE,UAAU;IAcrE,OAAO,CAAC,UAAU;IAkIlB,OAAO,CAAC,eAAe;IA6DvB,6BAA6B,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM;CA6C1D"}
|
|
@@ -1,253 +0,0 @@
|
|
|
1
|
-
import { Schema } from 'prosemirror-model';
|
|
2
|
-
import { keymap } from 'prosemirror-keymap';
|
|
3
|
-
import { InputRulesPlugin, } from './plugins/input-rules/InputRulesPlugin.js';
|
|
4
|
-
import { chainCommands } from './commands/mod.js';
|
|
5
|
-
import { addAttributesToSchema } from './utilities/getHtmlAttributes.js';
|
|
6
|
-
export function findDuplicates(items) {
|
|
7
|
-
const filtered = items.filter((el, index) => items.indexOf(el) !== index);
|
|
8
|
-
return Array.from(new Set(filtered));
|
|
9
|
-
}
|
|
10
|
-
export function splitExtensions(extensions) {
|
|
11
|
-
const baseExtensions = Array.from(extensions).filter((extension) => extension.type === 'extension');
|
|
12
|
-
const nodeExtensions = Array.from(extensions).filter((extension) => extension.type === 'node');
|
|
13
|
-
const markExtensions = Array.from(extensions).filter((extension) => extension.type === 'mark');
|
|
14
|
-
return {
|
|
15
|
-
baseExtensions,
|
|
16
|
-
nodeExtensions,
|
|
17
|
-
markExtensions,
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
export class ExtensionManager {
|
|
21
|
-
constructor(extensions, editor) {
|
|
22
|
-
Object.defineProperty(this, "editor", {
|
|
23
|
-
enumerable: true,
|
|
24
|
-
configurable: true,
|
|
25
|
-
writable: true,
|
|
26
|
-
value: editor
|
|
27
|
-
});
|
|
28
|
-
Object.defineProperty(this, "schema", {
|
|
29
|
-
enumerable: true,
|
|
30
|
-
configurable: true,
|
|
31
|
-
writable: true,
|
|
32
|
-
value: void 0
|
|
33
|
-
});
|
|
34
|
-
Object.defineProperty(this, "extensions", {
|
|
35
|
-
enumerable: true,
|
|
36
|
-
configurable: true,
|
|
37
|
-
writable: true,
|
|
38
|
-
value: new Set()
|
|
39
|
-
});
|
|
40
|
-
Object.defineProperty(this, "plugins", {
|
|
41
|
-
enumerable: true,
|
|
42
|
-
configurable: true,
|
|
43
|
-
writable: true,
|
|
44
|
-
value: void 0
|
|
45
|
-
});
|
|
46
|
-
Object.defineProperty(this, "nodeViews", {
|
|
47
|
-
enumerable: true,
|
|
48
|
-
configurable: true,
|
|
49
|
-
writable: true,
|
|
50
|
-
value: {}
|
|
51
|
-
});
|
|
52
|
-
Object.defineProperty(this, "commandConstructors", {
|
|
53
|
-
enumerable: true,
|
|
54
|
-
configurable: true,
|
|
55
|
-
writable: true,
|
|
56
|
-
value: {}
|
|
57
|
-
});
|
|
58
|
-
Object.defineProperty(this, "converters", {
|
|
59
|
-
enumerable: true,
|
|
60
|
-
configurable: true,
|
|
61
|
-
writable: true,
|
|
62
|
-
value: {}
|
|
63
|
-
});
|
|
64
|
-
Object.defineProperty(this, "debug", {
|
|
65
|
-
enumerable: true,
|
|
66
|
-
configurable: true,
|
|
67
|
-
writable: true,
|
|
68
|
-
value: true
|
|
69
|
-
});
|
|
70
|
-
this.setupExtensions(extensions);
|
|
71
|
-
this.schema = this.getSchemaByResolvedExtensions(editor);
|
|
72
|
-
const event = new CustomEvent('schema:ready', {
|
|
73
|
-
detail: {
|
|
74
|
-
editor,
|
|
75
|
-
schema: this.schema,
|
|
76
|
-
},
|
|
77
|
-
});
|
|
78
|
-
editor.dispatchEvent(event);
|
|
79
|
-
this.plugins = this.getPlugins();
|
|
80
|
-
}
|
|
81
|
-
getPlugins() {
|
|
82
|
-
const plugins = [];
|
|
83
|
-
const inputRules = [];
|
|
84
|
-
const commands = new Map();
|
|
85
|
-
const keyBindings = new Map();
|
|
86
|
-
const mergeCommands = (toInsert, extName) => {
|
|
87
|
-
for (const key in toInsert) {
|
|
88
|
-
const commandConstructor = toInsert[key];
|
|
89
|
-
if (this.debug) {
|
|
90
|
-
const wrappedConstructor = () => {
|
|
91
|
-
const realCommand = commandConstructor();
|
|
92
|
-
const command = (state, dispatch, view) => {
|
|
93
|
-
if (dispatch) {
|
|
94
|
-
console.debug(`Command: ${extName}.${key}`);
|
|
95
|
-
}
|
|
96
|
-
return realCommand(state, dispatch, view);
|
|
97
|
-
};
|
|
98
|
-
return command;
|
|
99
|
-
};
|
|
100
|
-
commands.set(key, wrappedConstructor);
|
|
101
|
-
this.commandConstructors[key] = wrappedConstructor;
|
|
102
|
-
}
|
|
103
|
-
else {
|
|
104
|
-
commands.set(key, commandConstructor);
|
|
105
|
-
this.commandConstructors[key] = commandConstructor;
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
};
|
|
109
|
-
function mergeShortcuts(toInsert, extName) {
|
|
110
|
-
for (const key in toInsert) {
|
|
111
|
-
const commandConstructor = commands.get(toInsert[key]);
|
|
112
|
-
if (!commandConstructor) {
|
|
113
|
-
console.warn(`No command constructor: ${toInsert[key]}`);
|
|
114
|
-
continue;
|
|
115
|
-
}
|
|
116
|
-
const command = commandConstructor();
|
|
117
|
-
const keyBinding = keyBindings.get(key);
|
|
118
|
-
if (keyBinding) {
|
|
119
|
-
keyBindings.set(key, chainCommands(keyBinding, command));
|
|
120
|
-
}
|
|
121
|
-
else {
|
|
122
|
-
keyBindings.set(key, command);
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
let converters = {};
|
|
127
|
-
for (const extension of this.extensions) {
|
|
128
|
-
if (extension.type === 'node') {
|
|
129
|
-
const nodeType = this.schema.nodes[extension.name];
|
|
130
|
-
inputRules.push(...extension.getInputRules(nodeType));
|
|
131
|
-
plugins.push(...extension.getProseMirrorPlugins(this.editor, this.schema));
|
|
132
|
-
mergeCommands(extension.getCommands(this.editor, nodeType), extension.name);
|
|
133
|
-
mergeShortcuts(extension.getKeyboardShortcuts(this.editor), extension.name);
|
|
134
|
-
converters = {
|
|
135
|
-
...converters,
|
|
136
|
-
...extension.getConverters(this.editor, this.schema),
|
|
137
|
-
};
|
|
138
|
-
const nodeView = extension.getNodeView();
|
|
139
|
-
if (nodeView) {
|
|
140
|
-
this.nodeViews[extension.name] = nodeView;
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
if (extension.type === 'mark') {
|
|
144
|
-
const markType = this.schema.marks[extension.name];
|
|
145
|
-
inputRules.push(...extension.getInputRules(markType));
|
|
146
|
-
mergeCommands(extension.getCommands(this.editor, markType), extension.name);
|
|
147
|
-
mergeShortcuts(extension.getKeyboardShortcuts(this.editor), extension.name);
|
|
148
|
-
}
|
|
149
|
-
if (extension.type === 'extension') {
|
|
150
|
-
plugins.push(...extension.getProseMirrorPlugins(this.editor, this.schema));
|
|
151
|
-
mergeCommands(extension.getCommands(this.editor), extension.name);
|
|
152
|
-
mergeShortcuts(extension.getKeyboardShortcuts(this.editor), extension.name);
|
|
153
|
-
converters = {
|
|
154
|
-
...converters,
|
|
155
|
-
...extension.getConverters(this.editor, this.schema),
|
|
156
|
-
};
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
if (this.debug) {
|
|
160
|
-
for (const key in keyBindings) {
|
|
161
|
-
const wrapperCommand = (state, dispatch, view) => {
|
|
162
|
-
console.debug(`Key: ${key}`);
|
|
163
|
-
return true;
|
|
164
|
-
};
|
|
165
|
-
keyBindings.set(key, chainCommands(wrapperCommand, keyBindings.get(key)));
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
this.converters = converters;
|
|
169
|
-
plugins.push(new InputRulesPlugin(inputRules));
|
|
170
|
-
plugins.push(keymap(Object.fromEntries(keyBindings)));
|
|
171
|
-
return plugins;
|
|
172
|
-
}
|
|
173
|
-
setupExtensions(extensions) {
|
|
174
|
-
const allExtensions = new Map();
|
|
175
|
-
const createMap = (extensions) => {
|
|
176
|
-
for (const extension of extensions) {
|
|
177
|
-
allExtensions.set(extension.name, extension);
|
|
178
|
-
if (extension.requires) {
|
|
179
|
-
const childExtensions = Array.from(extension.requires).filter((e) => typeof e !== 'string');
|
|
180
|
-
createMap(new Set(childExtensions));
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
};
|
|
184
|
-
createMap(extensions);
|
|
185
|
-
const initialized = new Set();
|
|
186
|
-
const initializeExtension = (extension) => {
|
|
187
|
-
console.info(`Initialize ${extension.type} ${extension.name}`);
|
|
188
|
-
this.extensions.add(extension);
|
|
189
|
-
};
|
|
190
|
-
function recursiveInitializeExtension(extension) {
|
|
191
|
-
if (initialized.has(extension.name)) {
|
|
192
|
-
return;
|
|
193
|
-
}
|
|
194
|
-
const requires = (extension.requires || []).map((e) => typeof e === 'string' ? e : e.name);
|
|
195
|
-
for (const require of requires) {
|
|
196
|
-
if (!initialized.has(require)) {
|
|
197
|
-
const requiredExtension = allExtensions.get(require);
|
|
198
|
-
if (!requiredExtension) {
|
|
199
|
-
throw new Error('Required extension not found: ' + require);
|
|
200
|
-
}
|
|
201
|
-
recursiveInitializeExtension(requiredExtension);
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
initializeExtension(extension);
|
|
205
|
-
initialized.add(extension.name);
|
|
206
|
-
allExtensions.delete(extension.name);
|
|
207
|
-
}
|
|
208
|
-
for (const extension of allExtensions.values()) {
|
|
209
|
-
recursiveInitializeExtension(extension);
|
|
210
|
-
}
|
|
211
|
-
if (allExtensions.size > 0) {
|
|
212
|
-
throw new Error('Not all extensions initialized: ' +
|
|
213
|
-
Array.from(allExtensions.keys()).join(', '));
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
getSchemaByResolvedExtensions(editor) {
|
|
217
|
-
const { nodeExtensions, markExtensions, baseExtensions } = splitExtensions(this.extensions);
|
|
218
|
-
const nodes = {};
|
|
219
|
-
for (const extension of nodeExtensions) {
|
|
220
|
-
nodes[extension.name] = extension.getNodeSpec();
|
|
221
|
-
addAttributesToSchema(nodes[extension.name], extension);
|
|
222
|
-
if ('automerge' in extension) {
|
|
223
|
-
nodes[extension.name].automerge = extension.automerge;
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
const marks = {};
|
|
227
|
-
for (const extension of markExtensions) {
|
|
228
|
-
marks[extension.name] = extension.getMarkSpec();
|
|
229
|
-
addAttributesToSchema(marks[extension.name], extension);
|
|
230
|
-
if ('automerge' in extension) {
|
|
231
|
-
marks[extension.name].automerge = extension.automerge;
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
const spec = {
|
|
235
|
-
topNode: this.editor.options.topNode || 'doc',
|
|
236
|
-
nodes,
|
|
237
|
-
marks,
|
|
238
|
-
};
|
|
239
|
-
for (const extension of baseExtensions) {
|
|
240
|
-
if ('setupSpec' in baseExtensions) {
|
|
241
|
-
baseExtensions.setupSpec(spec);
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
const event = new CustomEvent('schema:spec', {
|
|
245
|
-
detail: {
|
|
246
|
-
editor,
|
|
247
|
-
spec,
|
|
248
|
-
},
|
|
249
|
-
});
|
|
250
|
-
editor.dispatchEvent(event);
|
|
251
|
-
return new Schema(spec);
|
|
252
|
-
}
|
|
253
|
-
}
|