@kerebron/extension-basic-editor 0.2.1 → 0.4.2
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 -2
- package/esm/editor/src/CoreEditor.d.ts +24 -9
- package/esm/editor/src/CoreEditor.d.ts.map +1 -1
- package/esm/editor/src/CoreEditor.js +125 -70
- 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 +15 -10
- package/esm/editor/src/Extension.d.ts.map +1 -1
- package/esm/editor/src/Extension.js +23 -3
- package/esm/editor/src/ExtensionManager.d.ts +9 -9
- package/esm/editor/src/ExtensionManager.d.ts.map +1 -1
- package/esm/editor/src/ExtensionManager.js +81 -74
- package/esm/editor/src/Mark.d.ts +11 -6
- package/esm/editor/src/Mark.d.ts.map +1 -1
- package/esm/editor/src/Mark.js +19 -2
- package/esm/editor/src/Node.d.ts +18 -13
- package/esm/editor/src/Node.d.ts.map +1 -1
- package/esm/editor/src/Node.js +22 -5
- package/esm/editor/src/commands/CommandManager.d.ts +14 -11
- package/esm/editor/src/commands/CommandManager.d.ts.map +1 -1
- package/esm/editor/src/commands/CommandManager.js +64 -6
- 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 -47
- package/esm/editor/src/commands/mod.d.ts.map +1 -1
- package/esm/editor/src/commands/mod.js +14 -866
- 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 +3 -0
- package/esm/editor/src/mod.d.ts.map +1 -1
- package/esm/editor/src/mod.js +3 -0
- package/esm/editor/src/nodeToTreeString.d.ts +8 -2
- package/esm/editor/src/nodeToTreeString.d.ts.map +1 -1
- package/esm/editor/src/nodeToTreeString.js +47 -29
- 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/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/mod.d.ts +2 -0
- package/esm/editor/src/plugins/keymap/mod.d.ts.map +1 -0
- package/esm/editor/src/plugins/keymap/mod.js +1 -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 +30 -7
- 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 +41 -0
- package/esm/editor/src/utilities/SmartOutput.d.ts.map +1 -0
- package/esm/editor/src/utilities/SmartOutput.js +228 -0
- 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/editor/src/utilities/getShadowRoot.d.ts +2 -0
- package/esm/editor/src/utilities/getShadowRoot.d.ts.map +1 -0
- package/esm/editor/src/utilities/getShadowRoot.js +16 -0
- package/esm/editor/src/utilities/mod.d.ts +3 -0
- package/esm/editor/src/utilities/mod.d.ts.map +1 -1
- package/esm/editor/src/utilities/mod.js +3 -0
- package/esm/editor/src/utilities/toRawTextResult.d.ts +3 -0
- package/esm/editor/src/utilities/toRawTextResult.d.ts.map +1 -0
- package/esm/editor/src/utilities/toRawTextResult.js +21 -0
- package/esm/extension-basic-editor/src/ExtensionBaseKeymap.d.ts +1 -2
- package/esm/extension-basic-editor/src/ExtensionBaseKeymap.d.ts.map +1 -1
- package/esm/extension-basic-editor/src/ExtensionBaseKeymap.js +40 -14
- package/esm/extension-basic-editor/src/ExtensionBasicCodeEditor.d.ts +11 -0
- package/esm/extension-basic-editor/src/ExtensionBasicCodeEditor.d.ts.map +1 -0
- package/esm/extension-basic-editor/src/ExtensionBasicCodeEditor.js +71 -0
- package/esm/extension-basic-editor/src/ExtensionBasicEditor.d.ts +23 -9
- package/esm/extension-basic-editor/src/ExtensionBasicEditor.d.ts.map +1 -1
- package/esm/extension-basic-editor/src/ExtensionBasicEditor.js +38 -8
- package/esm/extension-basic-editor/src/ExtensionDropcursor.d.ts +7 -0
- package/esm/extension-basic-editor/src/ExtensionDropcursor.d.ts.map +1 -1
- package/esm/extension-basic-editor/src/ExtensionDropcursor.js +211 -1
- package/esm/extension-basic-editor/src/ExtensionGapcursor.d.ts +21 -1
- package/esm/extension-basic-editor/src/ExtensionGapcursor.d.ts.map +1 -1
- package/esm/extension-basic-editor/src/ExtensionGapcursor.js +239 -1
- package/esm/extension-basic-editor/src/ExtensionHistory.d.ts +4 -3
- package/esm/extension-basic-editor/src/ExtensionHistory.d.ts.map +1 -1
- package/esm/extension-basic-editor/src/ExtensionHistory.js +29 -3
- package/esm/extension-basic-editor/src/ExtensionHtml.d.ts.map +1 -1
- package/esm/extension-basic-editor/src/ExtensionHtml.js +7 -4
- package/esm/extension-basic-editor/src/ExtensionMediaUpload.d.ts +24 -0
- package/esm/extension-basic-editor/src/ExtensionMediaUpload.d.ts.map +1 -0
- package/esm/extension-basic-editor/src/ExtensionMediaUpload.js +176 -0
- package/esm/extension-basic-editor/src/ExtensionSelection.d.ts +11 -0
- package/esm/extension-basic-editor/src/ExtensionSelection.d.ts.map +1 -0
- package/esm/extension-basic-editor/src/ExtensionSelection.js +237 -0
- package/esm/extension-basic-editor/src/MarkBookmark.d.ts.map +1 -1
- package/esm/extension-basic-editor/src/MarkChange.d.ts.map +1 -1
- package/esm/extension-basic-editor/src/MarkCode.d.ts +4 -7
- package/esm/extension-basic-editor/src/MarkCode.d.ts.map +1 -1
- package/esm/extension-basic-editor/src/MarkCode.js +2 -11
- package/esm/extension-basic-editor/src/MarkHighlight.d.ts +8 -0
- package/esm/extension-basic-editor/src/MarkHighlight.d.ts.map +1 -0
- package/esm/extension-basic-editor/src/MarkHighlight.js +43 -0
- package/esm/extension-basic-editor/src/MarkItalic.d.ts +4 -6
- package/esm/extension-basic-editor/src/MarkItalic.d.ts.map +1 -1
- package/esm/extension-basic-editor/src/MarkItalic.js +2 -11
- package/esm/extension-basic-editor/src/MarkLink.d.ts +1 -11
- package/esm/extension-basic-editor/src/MarkLink.d.ts.map +1 -1
- package/esm/extension-basic-editor/src/MarkLink.js +0 -32
- package/esm/extension-basic-editor/src/MarkStrike.d.ts +11 -0
- package/esm/extension-basic-editor/src/MarkStrike.d.ts.map +1 -0
- package/esm/extension-basic-editor/src/MarkStrike.js +39 -0
- package/esm/extension-basic-editor/src/MarkStrong.d.ts +4 -7
- package/esm/extension-basic-editor/src/MarkStrong.d.ts.map +1 -1
- package/esm/extension-basic-editor/src/MarkStrong.js +2 -11
- package/esm/extension-basic-editor/src/MarkTextColor.d.ts +8 -0
- package/esm/extension-basic-editor/src/MarkTextColor.d.ts.map +1 -0
- package/esm/extension-basic-editor/src/MarkTextColor.js +35 -0
- package/esm/extension-basic-editor/src/MarkUnderline.d.ts +3 -5
- package/esm/extension-basic-editor/src/MarkUnderline.d.ts.map +1 -1
- package/esm/extension-basic-editor/src/MarkUnderline.js +2 -11
- package/esm/extension-basic-editor/src/NodeAside.d.ts +0 -3
- package/esm/extension-basic-editor/src/NodeAside.d.ts.map +1 -1
- package/esm/extension-basic-editor/src/NodeAside.js +0 -8
- package/esm/extension-basic-editor/src/NodeBlockquote.d.ts +3 -6
- package/esm/extension-basic-editor/src/NodeBlockquote.d.ts.map +1 -1
- package/esm/extension-basic-editor/src/NodeBlockquote.js +2 -11
- package/esm/extension-basic-editor/src/NodeBulletList.d.ts +4 -7
- package/esm/extension-basic-editor/src/NodeBulletList.d.ts.map +1 -1
- package/esm/extension-basic-editor/src/NodeBulletList.js +2 -11
- package/esm/extension-basic-editor/src/NodeCodeBlock.d.ts +9 -0
- package/esm/extension-basic-editor/src/NodeCodeBlock.d.ts.map +1 -0
- package/esm/extension-basic-editor/src/NodeCodeBlock.js +58 -0
- package/esm/extension-basic-editor/src/NodeDefinitionDesc.d.ts +8 -0
- package/esm/extension-basic-editor/src/NodeDefinitionDesc.d.ts.map +1 -0
- package/esm/extension-basic-editor/src/NodeDefinitionDesc.js +29 -0
- package/esm/extension-basic-editor/src/NodeDefinitionList.d.ts +13 -0
- package/esm/extension-basic-editor/src/NodeDefinitionList.d.ts.map +1 -0
- package/esm/extension-basic-editor/src/NodeDefinitionList.js +41 -0
- package/esm/extension-basic-editor/src/NodeDefinitionTerm.d.ts +8 -0
- package/esm/extension-basic-editor/src/NodeDefinitionTerm.d.ts.map +1 -0
- package/esm/extension-basic-editor/src/NodeDefinitionTerm.js +29 -0
- package/esm/extension-basic-editor/src/NodeDocumentCode.d.ts +7 -0
- package/esm/extension-basic-editor/src/NodeDocumentCode.d.ts.map +1 -0
- package/esm/extension-basic-editor/src/NodeDocumentCode.js +37 -0
- package/esm/extension-basic-editor/src/NodeFrontmatter.d.ts +8 -0
- package/esm/extension-basic-editor/src/NodeFrontmatter.d.ts.map +1 -0
- package/esm/extension-basic-editor/src/NodeFrontmatter.js +29 -0
- package/esm/extension-basic-editor/src/NodeHardBreak.d.ts +5 -2
- package/esm/extension-basic-editor/src/NodeHardBreak.d.ts.map +1 -1
- package/esm/extension-basic-editor/src/NodeHardBreak.js +40 -53
- package/esm/extension-basic-editor/src/NodeHeading.d.ts +3 -14
- package/esm/extension-basic-editor/src/NodeHeading.d.ts.map +1 -1
- package/esm/extension-basic-editor/src/NodeHeading.js +2 -15
- package/esm/extension-basic-editor/src/NodeHorizontalRule.d.ts +4 -4
- package/esm/extension-basic-editor/src/NodeHorizontalRule.d.ts.map +1 -1
- package/esm/extension-basic-editor/src/NodeHorizontalRule.js +1 -2
- package/esm/extension-basic-editor/src/NodeListItem.d.ts +7 -5
- package/esm/extension-basic-editor/src/NodeListItem.d.ts.map +1 -1
- package/esm/extension-basic-editor/src/NodeListItem.js +10 -15
- package/esm/extension-basic-editor/src/NodeMath.d.ts +8 -0
- package/esm/extension-basic-editor/src/NodeMath.d.ts.map +1 -0
- package/esm/extension-basic-editor/src/NodeMath.js +112 -0
- package/esm/extension-basic-editor/src/NodeOrderedList.d.ts +3 -6
- package/esm/extension-basic-editor/src/NodeOrderedList.d.ts.map +1 -1
- package/esm/extension-basic-editor/src/NodeOrderedList.js +4 -14
- package/esm/extension-basic-editor/src/NodeParagraph.d.ts +2 -5
- package/esm/extension-basic-editor/src/NodeParagraph.d.ts.map +1 -1
- package/esm/extension-basic-editor/src/NodeParagraph.js +2 -11
- package/esm/extension-basic-editor/src/NodeTaskItem.d.ts +24 -0
- package/esm/extension-basic-editor/src/NodeTaskItem.d.ts.map +1 -0
- package/esm/extension-basic-editor/src/NodeTaskItem.js +153 -0
- package/esm/extension-basic-editor/src/NodeTaskList.d.ts +11 -0
- package/esm/extension-basic-editor/src/NodeTaskList.d.ts.map +1 -0
- package/esm/extension-basic-editor/src/NodeTaskList.js +38 -0
- package/esm/extension-basic-editor/src/NodeText.d.ts +0 -1
- package/esm/extension-basic-editor/src/NodeText.d.ts.map +1 -1
- package/esm/extension-basic-editor/src/NodeText.js +0 -6
- package/esm/extension-basic-editor/src/NodeVideo.d.ts +8 -0
- package/esm/extension-basic-editor/src/NodeVideo.d.ts.map +1 -0
- package/esm/extension-basic-editor/src/NodeVideo.js +58 -0
- package/esm/extension-basic-editor/src/remote-selection/ExtensionRemoteSelection.d.ts +24 -0
- package/esm/extension-basic-editor/src/remote-selection/ExtensionRemoteSelection.d.ts.map +1 -0
- package/esm/extension-basic-editor/src/remote-selection/ExtensionRemoteSelection.js +35 -0
- package/esm/extension-basic-editor/src/remote-selection/remoteSelectionPlugin.d.ts +25 -0
- package/esm/extension-basic-editor/src/remote-selection/remoteSelectionPlugin.d.ts.map +1 -0
- package/esm/extension-basic-editor/src/remote-selection/remoteSelectionPlugin.js +96 -0
- package/package.json +29 -6
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
// Headless View to be used on Server-side
|
|
2
|
+
// TODO: remove all unnecessary props and methods
|
|
3
|
+
/// An editor view manages the DOM structure that represents an
|
|
4
|
+
/// editable document. Its state and behavior are determined by its
|
|
5
|
+
/// [props](#view.DirectEditorProps).
|
|
6
|
+
export class DummyEditorView {
|
|
7
|
+
/// Create a view. `place` may be a DOM node that the editor should
|
|
8
|
+
/// be appended to, a function that will place it into the document,
|
|
9
|
+
/// or an object whose `mount` property holds the node to use as the
|
|
10
|
+
/// document container. If it is `null`, the editor will not be
|
|
11
|
+
/// added to the document.
|
|
12
|
+
constructor(props) {
|
|
13
|
+
/// @internal
|
|
14
|
+
Object.defineProperty(this, "_props", {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
configurable: true,
|
|
17
|
+
writable: true,
|
|
18
|
+
value: void 0
|
|
19
|
+
});
|
|
20
|
+
Object.defineProperty(this, "directPlugins", {
|
|
21
|
+
enumerable: true,
|
|
22
|
+
configurable: true,
|
|
23
|
+
writable: true,
|
|
24
|
+
value: void 0
|
|
25
|
+
});
|
|
26
|
+
/// @internal
|
|
27
|
+
Object.defineProperty(this, "nodeViews", {
|
|
28
|
+
enumerable: true,
|
|
29
|
+
configurable: true,
|
|
30
|
+
writable: true,
|
|
31
|
+
value: void 0
|
|
32
|
+
});
|
|
33
|
+
Object.defineProperty(this, "prevDirectPlugins", {
|
|
34
|
+
enumerable: true,
|
|
35
|
+
configurable: true,
|
|
36
|
+
writable: true,
|
|
37
|
+
value: []
|
|
38
|
+
});
|
|
39
|
+
Object.defineProperty(this, "pluginViews", {
|
|
40
|
+
enumerable: true,
|
|
41
|
+
configurable: true,
|
|
42
|
+
writable: true,
|
|
43
|
+
value: []
|
|
44
|
+
});
|
|
45
|
+
/// The view's current [state](#state.EditorState).
|
|
46
|
+
Object.defineProperty(this, "state", {
|
|
47
|
+
enumerable: true,
|
|
48
|
+
configurable: true,
|
|
49
|
+
writable: true,
|
|
50
|
+
value: void 0
|
|
51
|
+
});
|
|
52
|
+
/// Indicates whether the editor is currently [editable](#view.EditorProps.editable).
|
|
53
|
+
Object.defineProperty(this, "editable", {
|
|
54
|
+
enumerable: true,
|
|
55
|
+
configurable: true,
|
|
56
|
+
writable: true,
|
|
57
|
+
value: void 0
|
|
58
|
+
});
|
|
59
|
+
this._props = props;
|
|
60
|
+
this.state = props.state;
|
|
61
|
+
this.directPlugins = props.plugins || [];
|
|
62
|
+
this.directPlugins.forEach(checkStateComponent);
|
|
63
|
+
this.dispatch = this.dispatch.bind(this);
|
|
64
|
+
this.editable = getEditable(this);
|
|
65
|
+
this.nodeViews = buildNodeViews(this);
|
|
66
|
+
// TODO initInput(this)
|
|
67
|
+
this.updatePluginViews();
|
|
68
|
+
}
|
|
69
|
+
/// Holds `true` when a
|
|
70
|
+
/// [composition](https://w3c.github.io/uievents/#events-compositionevents)
|
|
71
|
+
/// is active.
|
|
72
|
+
get composing() {
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
get dom() {
|
|
76
|
+
return {
|
|
77
|
+
addEventListener() { },
|
|
78
|
+
removeEventListener() { },
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
/// The view's current [props](#view.EditorProps).
|
|
82
|
+
get props() {
|
|
83
|
+
if (this._props.state != this.state) {
|
|
84
|
+
let prev = this._props;
|
|
85
|
+
this._props = {};
|
|
86
|
+
for (let name in prev)
|
|
87
|
+
this._props[name] = prev[name];
|
|
88
|
+
this._props.state = this.state;
|
|
89
|
+
}
|
|
90
|
+
return this._props;
|
|
91
|
+
}
|
|
92
|
+
/// Update the view's props. Will immediately cause an update to
|
|
93
|
+
/// the DOM.
|
|
94
|
+
update(props) {
|
|
95
|
+
let prevProps = this._props;
|
|
96
|
+
this._props = props;
|
|
97
|
+
if (props.plugins) {
|
|
98
|
+
props.plugins.forEach(checkStateComponent);
|
|
99
|
+
this.directPlugins = props.plugins;
|
|
100
|
+
}
|
|
101
|
+
this.updateStateInner(props.state, prevProps);
|
|
102
|
+
}
|
|
103
|
+
/// Update the view by updating existing props object with the object
|
|
104
|
+
/// given as argument. Equivalent to `view.update(Object.assign({},
|
|
105
|
+
/// view.props, props))`.
|
|
106
|
+
setProps(props) {
|
|
107
|
+
let updated = {};
|
|
108
|
+
for (let name in this._props) {
|
|
109
|
+
updated[name] = this._props[name];
|
|
110
|
+
}
|
|
111
|
+
updated.state = this.state;
|
|
112
|
+
for (let name in props)
|
|
113
|
+
updated[name] = props[name];
|
|
114
|
+
this.update(updated);
|
|
115
|
+
}
|
|
116
|
+
/// Update the editor's `state` prop, without touching any of the
|
|
117
|
+
/// other props.
|
|
118
|
+
updateState(state) {
|
|
119
|
+
this.updateStateInner(state, this._props);
|
|
120
|
+
}
|
|
121
|
+
updateStateInner(state, prevProps) {
|
|
122
|
+
let prev = this.state, redraw = false, updateSel = false;
|
|
123
|
+
// When stored marks are added, stop composition, so that they can
|
|
124
|
+
// be displayed.
|
|
125
|
+
if (state.storedMarks && this.composing) {
|
|
126
|
+
// TODO clearComposition(this)
|
|
127
|
+
updateSel = true;
|
|
128
|
+
}
|
|
129
|
+
this.state = state;
|
|
130
|
+
let pluginsChanged = prev.plugins != state.plugins ||
|
|
131
|
+
this._props.plugins != prevProps.plugins;
|
|
132
|
+
if (pluginsChanged || this._props.plugins != prevProps.plugins ||
|
|
133
|
+
this._props.nodeViews != prevProps.nodeViews) {
|
|
134
|
+
let nodeViews = buildNodeViews(this);
|
|
135
|
+
if (changedNodeViews(nodeViews, this.nodeViews)) {
|
|
136
|
+
this.nodeViews = nodeViews;
|
|
137
|
+
redraw = true;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
this.editable = getEditable(this);
|
|
141
|
+
let updateDoc = redraw;
|
|
142
|
+
if (updateDoc || !state.selection.eq(prev.selection))
|
|
143
|
+
updateSel = true;
|
|
144
|
+
if (updateSel) {
|
|
145
|
+
// Work around an issue in Chrome, IE, and Edge where changing
|
|
146
|
+
// the DOM around an active selection puts it into a broken
|
|
147
|
+
// state where the thing the user sees differs from the
|
|
148
|
+
// selection reported by the Selection object (#710, #973,
|
|
149
|
+
// #1011, #1013, #1035).
|
|
150
|
+
let forceSelUpdate = false;
|
|
151
|
+
if (updateDoc) {
|
|
152
|
+
// If the node that the selection points into is written to,
|
|
153
|
+
// Chrome sometimes starts misreporting the selection, so this
|
|
154
|
+
// tracks that and forces a selection reset when our update
|
|
155
|
+
// did write to the node.
|
|
156
|
+
// TODO if (this.composing) this.input.compositionNode = findCompositionNode(this)
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
this.updatePluginViews(prev);
|
|
160
|
+
}
|
|
161
|
+
/// @internal
|
|
162
|
+
scrollToSelection() {
|
|
163
|
+
}
|
|
164
|
+
destroyPluginViews() {
|
|
165
|
+
let view;
|
|
166
|
+
while (view = this.pluginViews.pop())
|
|
167
|
+
if (view.destroy)
|
|
168
|
+
view.destroy();
|
|
169
|
+
}
|
|
170
|
+
updatePluginViews(prevState) {
|
|
171
|
+
if (!prevState || prevState.plugins != this.state.plugins ||
|
|
172
|
+
this.directPlugins != this.prevDirectPlugins) {
|
|
173
|
+
this.prevDirectPlugins = this.directPlugins;
|
|
174
|
+
this.destroyPluginViews();
|
|
175
|
+
for (let i = 0; i < this.directPlugins.length; i++) {
|
|
176
|
+
let plugin = this.directPlugins[i];
|
|
177
|
+
if (plugin.spec.view) {
|
|
178
|
+
this.pluginViews.push(plugin.spec.view(this));
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
for (let i = 0; i < this.state.plugins.length; i++) {
|
|
182
|
+
let plugin = this.state.plugins[i];
|
|
183
|
+
if (plugin.spec.view) {
|
|
184
|
+
this.pluginViews.push(plugin.spec.view(this));
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
else {
|
|
189
|
+
for (let i = 0; i < this.pluginViews.length; i++) {
|
|
190
|
+
let pluginView = this.pluginViews[i];
|
|
191
|
+
if (pluginView.update)
|
|
192
|
+
pluginView.update(this, prevState);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
someProp(propName, f) {
|
|
197
|
+
let prop = this._props && this._props[propName], value;
|
|
198
|
+
if (prop != null && (value = f ? f(prop) : prop)) {
|
|
199
|
+
return value;
|
|
200
|
+
}
|
|
201
|
+
for (let i = 0; i < this.directPlugins.length; i++) {
|
|
202
|
+
let prop = this.directPlugins[i].props[propName];
|
|
203
|
+
if (prop != null && (value = f ? f(prop) : prop)) {
|
|
204
|
+
return value;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
let plugins = this.state.plugins;
|
|
208
|
+
if (plugins) {
|
|
209
|
+
for (let i = 0; i < plugins.length; i++) {
|
|
210
|
+
let prop = plugins[i].props[propName];
|
|
211
|
+
if (prop != null && (value = f ? f(prop) : prop))
|
|
212
|
+
return value;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
/// Query whether the view has focus.
|
|
217
|
+
hasFocus() {
|
|
218
|
+
return false;
|
|
219
|
+
}
|
|
220
|
+
/// Focus the editor.
|
|
221
|
+
focus() {
|
|
222
|
+
}
|
|
223
|
+
/// Removes the editor from the DOM and destroys all [node
|
|
224
|
+
/// views](#view.NodeView).
|
|
225
|
+
destroy() {
|
|
226
|
+
this.destroyPluginViews();
|
|
227
|
+
}
|
|
228
|
+
/// This is true when the view has been
|
|
229
|
+
/// [destroyed](#view.DummyEditorView.destroy) (and thus should not be
|
|
230
|
+
/// used anymore).
|
|
231
|
+
get isDestroyed() {
|
|
232
|
+
return false;
|
|
233
|
+
}
|
|
234
|
+
/// Used for testing.
|
|
235
|
+
dispatchEvent(event) {
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
DummyEditorView.prototype.dispatch = function (tr) {
|
|
239
|
+
let dispatchTransaction = this.props.dispatchTransaction;
|
|
240
|
+
if (dispatchTransaction)
|
|
241
|
+
dispatchTransaction.call(this, tr);
|
|
242
|
+
else
|
|
243
|
+
this.updateState(this.state.apply(tr));
|
|
244
|
+
};
|
|
245
|
+
function getEditable(view) {
|
|
246
|
+
return !view.someProp('editable', (value) => value(view.state) === false);
|
|
247
|
+
}
|
|
248
|
+
function buildNodeViews(view) {
|
|
249
|
+
let result = Object.create(null);
|
|
250
|
+
function add(obj) {
|
|
251
|
+
for (let prop in obj) {
|
|
252
|
+
if (!Object.prototype.hasOwnProperty.call(result, prop)) {
|
|
253
|
+
result[prop] = obj[prop];
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
view.someProp('nodeViews', add);
|
|
258
|
+
view.someProp('markViews', add);
|
|
259
|
+
return result;
|
|
260
|
+
}
|
|
261
|
+
function changedNodeViews(a, b) {
|
|
262
|
+
let nA = 0, nB = 0;
|
|
263
|
+
for (let prop in a) {
|
|
264
|
+
if (a[prop] != b[prop])
|
|
265
|
+
return true;
|
|
266
|
+
nA++;
|
|
267
|
+
}
|
|
268
|
+
for (let _ in b)
|
|
269
|
+
nB++;
|
|
270
|
+
return nA != nB;
|
|
271
|
+
}
|
|
272
|
+
function checkStateComponent(plugin) {
|
|
273
|
+
if (plugin.spec.state || plugin.spec.filterTransaction ||
|
|
274
|
+
plugin.spec.appendTransaction) {
|
|
275
|
+
throw new RangeError('Plugins passed directly to the view must not have a state component');
|
|
276
|
+
}
|
|
277
|
+
}
|
|
@@ -1,25 +1,30 @@
|
|
|
1
|
-
import { Plugin } from 'prosemirror-state';
|
|
1
|
+
import type { Plugin } from 'prosemirror-state';
|
|
2
|
+
import type { Node, Schema, SchemaSpec } from 'prosemirror-model';
|
|
2
3
|
import { type CoreEditor } from './CoreEditor.js';
|
|
3
|
-
import { InputRule } from './plugins/input-rules/InputRulesPlugin.js';
|
|
4
|
-
import {
|
|
5
|
-
import { Schema, type SchemaSpec } from 'prosemirror-model';
|
|
4
|
+
import type { InputRule } from './plugins/input-rules/InputRulesPlugin.js';
|
|
5
|
+
import { CommandFactories, CommandShortcuts } from './commands/mod.js';
|
|
6
6
|
export interface ExtensionConfig {
|
|
7
7
|
[key: string]: any;
|
|
8
8
|
requires: Array<Extension | string>;
|
|
9
9
|
}
|
|
10
10
|
export interface Converter {
|
|
11
|
-
fromDoc(document:
|
|
12
|
-
toDoc(content:
|
|
11
|
+
fromDoc(document: Node): Promise<Uint8Array>;
|
|
12
|
+
toDoc(content: Uint8Array): Promise<Node>;
|
|
13
13
|
}
|
|
14
14
|
export declare abstract class Extension {
|
|
15
15
|
protected config: Partial<ExtensionConfig>;
|
|
16
16
|
readonly type = "extension";
|
|
17
17
|
abstract name: string;
|
|
18
|
-
protected
|
|
18
|
+
protected editor: CoreEditor;
|
|
19
|
+
readonly conflicts?: Array<string>;
|
|
20
|
+
constructor(config?: Partial<ExtensionConfig>);
|
|
21
|
+
setEditor(editor: CoreEditor): void;
|
|
22
|
+
getEditor(): CoreEditor;
|
|
23
|
+
created(): void;
|
|
19
24
|
getInputRules(): InputRule[];
|
|
20
|
-
getProseMirrorPlugins(
|
|
21
|
-
|
|
22
|
-
getKeyboardShortcuts(): Partial<CommandShortcuts>;
|
|
25
|
+
getProseMirrorPlugins(): Plugin[];
|
|
26
|
+
getCommandFactories(editor: CoreEditor): Partial<CommandFactories>;
|
|
27
|
+
getKeyboardShortcuts(editor: CoreEditor): Partial<CommandShortcuts>;
|
|
23
28
|
getConverters(editor: CoreEditor, schema: Schema): Record<string, Converter>;
|
|
24
29
|
setupSpec(spec: SchemaSpec): void;
|
|
25
30
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Extension.d.ts","sourceRoot":"","sources":["../../../src/editor/src/Extension.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"Extension.d.ts","sourceRoot":"","sources":["../../../src/editor/src/Extension.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAElE,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2CAA2C,CAAC;AAC3E,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAEvE,MAAM,WAAW,eAAe;IAE9B,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;IAEnB,QAAQ,EAAE,KAAK,CAAC,SAAS,GAAG,MAAM,CAAC,CAAC;CACrC;AAED,MAAM,WAAW,SAAS;IACxB,OAAO,CAAC,QAAQ,EAAE,IAAI,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;IAC7C,KAAK,CAAC,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC3C;AAED,8BAAsB,SAAS;IAOV,SAAS,CAAC,MAAM,EAAE,OAAO,CAAC,eAAe,CAAC;IAN7D,QAAQ,CAAC,IAAI,eAAe;IAC5B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,MAAM,EAAG,UAAU,CAAC;IAE9B,QAAQ,CAAC,SAAS,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;gBAEN,MAAM,GAAE,OAAO,CAAC,eAAe,CAAM;IAGlE,SAAS,CAAC,MAAM,EAAE,UAAU;IAI5B,SAAS;IAIT,OAAO;IAGP,aAAa,IAAI,SAAS,EAAE;IAI5B,qBAAqB,IAAI,MAAM,EAAE;IAIjC,mBAAmB,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAIlE,oBAAoB,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAInE,aAAa,CAAC,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC;IAI5E,SAAS,CAAC,IAAI,EAAE,UAAU;CAE3B"}
|
|
@@ -12,17 +12,37 @@ 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) {
|
|
23
43
|
return {};
|
|
24
44
|
}
|
|
25
|
-
getKeyboardShortcuts() {
|
|
45
|
+
getKeyboardShortcuts(editor) {
|
|
26
46
|
return {};
|
|
27
47
|
}
|
|
28
48
|
getConverters(editor, schema) {
|
|
@@ -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 { type
|
|
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,18 +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
|
-
|
|
23
|
-
[key: string]: () => Command;
|
|
24
|
-
};
|
|
25
|
-
private converters;
|
|
23
|
+
converters: Record<string, Converter>;
|
|
26
24
|
private debug;
|
|
27
|
-
constructor(extensions:
|
|
28
|
-
|
|
25
|
+
constructor(extensions: AnyExtensionOrReq[], editor: CoreEditor, commandManager: CommandManager);
|
|
26
|
+
getExtension<T extends Extension>(name: string): T | undefined;
|
|
27
|
+
private initPlugins;
|
|
29
28
|
private setupExtensions;
|
|
30
29
|
getSchemaByResolvedExtensions(editor: CoreEditor): Schema;
|
|
30
|
+
created(): void;
|
|
31
31
|
}
|
|
32
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;
|
|
1
|
+
{"version":3,"file":"ExtensionManager.d.ts","sourceRoot":"","sources":["../../../src/editor/src/ExtensionManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAEvD,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AASjC,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAGnE,wBAAgB,cAAc,CAAC,KAAK,EAAE,GAAG,EAAE,GAAG,GAAG,EAAE,CAIlD;AAED,wBAAgB,eAAe,CAAC,UAAU,EAAE,QAAQ,CAAC,YAAY,CAAC;;;;EAgBjE;AAED,qBAAa,gBAAgB;IAazB,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,cAAc;IAbxB,SAAgB,MAAM,EAAE,MAAM,CAAC;IAE/B,OAAO,CAAC,UAAU,CAAgC;IAClD,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,CAAM;IAChC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAM;IAEtD,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAM;IAElD,OAAO,CAAC,KAAK,CAAQ;gBAGnB,UAAU,EAAE,iBAAiB,EAAE,EACvB,MAAM,EAAE,UAAU,EAClB,cAAc,EAAE,cAAc;IAcxC,YAAY,CAAC,CAAC,SAAS,SAAS,EAAE,IAAI,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS;IAY9D,OAAO,CAAC,WAAW;IAkHnB,OAAO,CAAC,eAAe;IAwEvB,6BAA6B,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM;IAkDzD,OAAO;CAOR"}
|