prosemirror-view 1.20.2 → 1.23.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/CHANGELOG.md +38 -0
- package/dist/index.es.js +56 -13
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +56 -13
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/browser.js +1 -1
- package/src/clipboard.js +20 -5
- package/src/decoration.js +8 -0
- package/src/index.js +12 -1
- package/src/viewdesc.js +12 -3
package/dist/index.js
CHANGED
|
@@ -13,7 +13,6 @@ if (typeof navigator != "undefined" && typeof document != "undefined") {
|
|
|
13
13
|
var ie_upto10 = /MSIE \d/.test(navigator.userAgent);
|
|
14
14
|
var ie_11up = /Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);
|
|
15
15
|
|
|
16
|
-
result.mac = /Mac/.test(navigator.platform);
|
|
17
16
|
var ie = result.ie = !!(ie_upto10 || ie_11up || ie_edge);
|
|
18
17
|
result.ie_version = ie_upto10 ? document.documentMode || 6 : ie_11up ? +ie_11up[1] : ie_edge ? +ie_edge[1] : null;
|
|
19
18
|
result.gecko = !ie && /gecko\/(\d+)/i.test(navigator.userAgent);
|
|
@@ -24,6 +23,7 @@ if (typeof navigator != "undefined" && typeof document != "undefined") {
|
|
|
24
23
|
// Is true for both iOS and iPadOS for convenience
|
|
25
24
|
result.safari = !ie && /Apple Computer/.test(navigator.vendor);
|
|
26
25
|
result.ios = result.safari && (/Mobile\/\w+/.test(navigator.userAgent) || navigator.maxTouchPoints > 2);
|
|
26
|
+
result.mac = result.ios || /Mac/.test(navigator.platform);
|
|
27
27
|
result.android = /Android \d/.test(navigator.userAgent);
|
|
28
28
|
result.webkit = "webkitFontSmoothing" in document.documentElement.style;
|
|
29
29
|
result.webkit_version = result.webkit && +(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent) || [0, 0])[1];
|
|
@@ -1125,6 +1125,11 @@ var WidgetViewDesc = /*@__PURE__*/(function (ViewDesc) {
|
|
|
1125
1125
|
return mutation.type != "selection" || this.widget.spec.ignoreSelection
|
|
1126
1126
|
};
|
|
1127
1127
|
|
|
1128
|
+
WidgetViewDesc.prototype.destroy = function destroy () {
|
|
1129
|
+
this.widget.type.destroy(this.dom);
|
|
1130
|
+
ViewDesc.prototype.destroy.call(this);
|
|
1131
|
+
};
|
|
1132
|
+
|
|
1128
1133
|
prototypeAccessors$1.domAtom.get = function () { return true };
|
|
1129
1134
|
|
|
1130
1135
|
Object.defineProperties( WidgetViewDesc.prototype, prototypeAccessors$1 );
|
|
@@ -1700,6 +1705,8 @@ function patchAttributes(dom, prev, cur) {
|
|
|
1700
1705
|
{ dom.classList.remove(prevList[i]); } }
|
|
1701
1706
|
for (var i$1 = 0; i$1 < curList.length; i$1++) { if (prevList.indexOf(curList[i$1]) == -1)
|
|
1702
1707
|
{ dom.classList.add(curList[i$1]); } }
|
|
1708
|
+
if (dom.classList.length == 0)
|
|
1709
|
+
{ dom.removeAttribute("class"); }
|
|
1703
1710
|
}
|
|
1704
1711
|
if (prev.style != cur.style) {
|
|
1705
1712
|
if (prev.style) {
|
|
@@ -1807,10 +1814,12 @@ ViewTreeUpdater.prototype.syncToMarks = function syncToMarks (marks, inline, vie
|
|
|
1807
1814
|
ViewTreeUpdater.prototype.findNodeMatch = function findNodeMatch (node, outerDeco, innerDeco, index) {
|
|
1808
1815
|
var children = this.top.children, found = -1;
|
|
1809
1816
|
if (index >= this.preMatch.index) {
|
|
1810
|
-
for (var i = this.index; i < children.length; i++) {
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1817
|
+
for (var i = this.index; i < children.length; i++) {
|
|
1818
|
+
if (this.preMatch.matched.get(children[i]) == index) {
|
|
1819
|
+
if (children[i].matchesNode(node, outerDeco, innerDeco)) { found = i; }
|
|
1820
|
+
break
|
|
1821
|
+
}
|
|
1822
|
+
}
|
|
1814
1823
|
} else {
|
|
1815
1824
|
for (var i$1 = this.index, e = Math.min(children.length, i$1 + 1); i$1 < e; i$1++) {
|
|
1816
1825
|
var child = children[i$1];
|
|
@@ -2955,7 +2964,7 @@ function parseFromClipboard(view, text, html, plainText, $context) {
|
|
|
2955
2964
|
var schema = ref.schema;
|
|
2956
2965
|
var serializer = prosemirrorModel.DOMSerializer.fromSchema(schema);
|
|
2957
2966
|
dom = document.createElement("div");
|
|
2958
|
-
text.
|
|
2967
|
+
text.split(/(?:\r\n?|\n)+/).forEach(function (block) {
|
|
2959
2968
|
var p = dom.appendChild(document.createElement("p"));
|
|
2960
2969
|
if (block) { p.appendChild(serializer.serializeNode(schema.text(block, marks))); }
|
|
2961
2970
|
});
|
|
@@ -2970,12 +2979,27 @@ function parseFromClipboard(view, text, html, plainText, $context) {
|
|
|
2970
2979
|
var sliceData = contextNode && /^(\d+) (\d+) (.*)/.exec(contextNode.getAttribute("data-pm-slice"));
|
|
2971
2980
|
if (!slice) {
|
|
2972
2981
|
var parser = view.someProp("clipboardParser") || view.someProp("domParser") || prosemirrorModel.DOMParser.fromSchema(view.state.schema);
|
|
2973
|
-
slice = parser.parseSlice(dom, {
|
|
2982
|
+
slice = parser.parseSlice(dom, {
|
|
2983
|
+
preserveWhitespace: !!(asText || sliceData),
|
|
2984
|
+
context: $context,
|
|
2985
|
+
ruleFromNode: function ruleFromNode(dom) {
|
|
2986
|
+
if (dom.nodeName == "BR" && !dom.nextSibling) { return {ignore: true} }
|
|
2987
|
+
}
|
|
2988
|
+
});
|
|
2989
|
+
}
|
|
2990
|
+
if (sliceData) {
|
|
2991
|
+
slice = addContext(closeSlice(slice, +sliceData[1], +sliceData[2]), sliceData[3]);
|
|
2992
|
+
} else { // HTML wasn't created by ProseMirror. Make sure top-level siblings are coherent
|
|
2993
|
+
slice = prosemirrorModel.Slice.maxOpen(normalizeSiblings(slice.content, $context), true);
|
|
2994
|
+
if (slice.openStart || slice.openEnd) {
|
|
2995
|
+
var openStart = 0, openEnd = 0;
|
|
2996
|
+
for (var node = slice.content.firstChild; openStart < slice.openStart && !node.type.spec.isolating;
|
|
2997
|
+
openStart++, node = node.firstChild) {}
|
|
2998
|
+
for (var node$1 = slice.content.lastChild; openEnd < slice.openEnd && !node$1.type.spec.isolating;
|
|
2999
|
+
openEnd++, node$1 = node$1.lastChild) {}
|
|
3000
|
+
slice = closeSlice(slice, openStart, openEnd);
|
|
3001
|
+
}
|
|
2974
3002
|
}
|
|
2975
|
-
if (sliceData)
|
|
2976
|
-
{ slice = addContext(closeSlice(slice, +sliceData[1], +sliceData[2]), sliceData[3]); }
|
|
2977
|
-
else // HTML wasn't created by ProseMirror. Make sure top-level siblings are coherent
|
|
2978
|
-
{ slice = prosemirrorModel.Slice.maxOpen(normalizeSiblings(slice.content, $context), false); }
|
|
2979
3003
|
|
|
2980
3004
|
view.someProp("transformPasted", function (f) { slice = f(slice); });
|
|
2981
3005
|
return slice
|
|
@@ -4116,6 +4140,10 @@ WidgetType.prototype.eq = function eq (other) {
|
|
|
4116
4140
|
this.toDOM == other.toDOM && compareObjs(this.spec, other.spec)))
|
|
4117
4141
|
};
|
|
4118
4142
|
|
|
4143
|
+
WidgetType.prototype.destroy = function destroy (node) {
|
|
4144
|
+
if (this.spec.destroy) { this.spec.destroy(node); }
|
|
4145
|
+
};
|
|
4146
|
+
|
|
4119
4147
|
var InlineType = function InlineType(attrs, spec) {
|
|
4120
4148
|
this.spec = spec || noSpec;
|
|
4121
4149
|
this.attrs = attrs;
|
|
@@ -4243,6 +4271,10 @@ Decoration.prototype.map = function map (mapping, offset, oldOffset) {
|
|
|
4243
4271
|
// key are interchangeable—if widgets differ in, for example,
|
|
4244
4272
|
// the behavior of some event handler, they should get
|
|
4245
4273
|
// different keys.
|
|
4274
|
+
//
|
|
4275
|
+
// destroy:: ?(node: dom.Node)
|
|
4276
|
+
// Called when the widget decoration is removed as a result of
|
|
4277
|
+
// mapping
|
|
4246
4278
|
Decoration.widget = function widget (pos, toDOM, spec) {
|
|
4247
4279
|
return new Decoration(pos, pos, new WidgetType(toDOM, spec))
|
|
4248
4280
|
};
|
|
@@ -4838,7 +4870,7 @@ var EditorView = function EditorView(place, props) {
|
|
|
4838
4870
|
this.updatePluginViews();
|
|
4839
4871
|
};
|
|
4840
4872
|
|
|
4841
|
-
var prototypeAccessors$2 = { props: { configurable: true },root: { configurable: true } };
|
|
4873
|
+
var prototypeAccessors$2 = { props: { configurable: true },root: { configurable: true },isDestroyed: { configurable: true } };
|
|
4842
4874
|
|
|
4843
4875
|
// composing:: boolean
|
|
4844
4876
|
// Holds `true` when a
|
|
@@ -5148,6 +5180,14 @@ EditorView.prototype.destroy = function destroy () {
|
|
|
5148
5180
|
this.docView = null;
|
|
5149
5181
|
};
|
|
5150
5182
|
|
|
5183
|
+
// :: boolean
|
|
5184
|
+
// This is true when the view has been
|
|
5185
|
+
// [destroyed](#view.EditorView.destroy) (and thus should not be
|
|
5186
|
+
// used anymore).
|
|
5187
|
+
prototypeAccessors$2.isDestroyed.get = function () {
|
|
5188
|
+
return this.docView == null
|
|
5189
|
+
};
|
|
5190
|
+
|
|
5151
5191
|
// Used for testing.
|
|
5152
5192
|
EditorView.prototype.dispatchEvent = function dispatchEvent$1 (event) {
|
|
5153
5193
|
return dispatchEvent(this, event)
|
|
@@ -5180,6 +5220,9 @@ function computeDocDeco(view) {
|
|
|
5180
5220
|
if (value) { for (var attr in value) {
|
|
5181
5221
|
if (attr == "class")
|
|
5182
5222
|
{ attrs.class += " " + value[attr]; }
|
|
5223
|
+
if (attr == "style") {
|
|
5224
|
+
attrs.style = (attrs.style ? attrs.style + ";" : "") + value[attr];
|
|
5225
|
+
}
|
|
5183
5226
|
else if (!attrs[attr] && attr != "contenteditable" && attr != "nodeName")
|
|
5184
5227
|
{ attrs[attr] = String(value[attr]); }
|
|
5185
5228
|
} }
|
|
@@ -5415,7 +5458,7 @@ function checkStateComponent(plugin) {
|
|
|
5415
5458
|
// view](#state.PluginSpec.view) and
|
|
5416
5459
|
// [props](#state.PluginSpec.props). Passing plugins with a state
|
|
5417
5460
|
// component (a [state field](#state.PluginSpec.state) field or a
|
|
5418
|
-
// [transaction
|
|
5461
|
+
// [transaction](#state.PluginSpec.filterTransaction) filter or
|
|
5419
5462
|
// appender) will result in an error, since such plugins must be
|
|
5420
5463
|
// present in the state to work.
|
|
5421
5464
|
//
|