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/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,41 @@
|
|
|
1
|
+
## 1.23.0 (2021-11-11)
|
|
2
|
+
|
|
3
|
+
### Bug fixes
|
|
4
|
+
|
|
5
|
+
When parsing clipboard content, ignore trailing BR nodes that look like they might be there as a contenteditable kludge.
|
|
6
|
+
|
|
7
|
+
### New features
|
|
8
|
+
|
|
9
|
+
`EditorView` now exposes an `isDestroyed` property that can be used to test if the view has been destroyed.
|
|
10
|
+
|
|
11
|
+
## 1.22.0 (2021-11-08)
|
|
12
|
+
|
|
13
|
+
### Bug fixes
|
|
14
|
+
|
|
15
|
+
Fix an issue where some types of node decoration changes could cause an unnecessary cascade of node redraws.
|
|
16
|
+
|
|
17
|
+
### New features
|
|
18
|
+
|
|
19
|
+
Widget decorations now accept a `destroy` option, which will be called when the widget is removed from the view.
|
|
20
|
+
|
|
21
|
+
## 1.21.0 (2021-10-29)
|
|
22
|
+
|
|
23
|
+
### Bug fixes
|
|
24
|
+
|
|
25
|
+
Fix issue where recent Mobile Safari versions weren't treated as Mac platforms.
|
|
26
|
+
|
|
27
|
+
### New features
|
|
28
|
+
|
|
29
|
+
Multiple `style` properties provided through the `attributes` prop are now merged. Adjust mac detection for recent changes to navigator.platform on iOS
|
|
30
|
+
|
|
31
|
+
## 1.20.3 (2021-10-13)
|
|
32
|
+
|
|
33
|
+
### Bug fixes
|
|
34
|
+
|
|
35
|
+
Stop removing leading/trailing whitespace from pasted plain text.
|
|
36
|
+
|
|
37
|
+
Fix an issue that could cause invalid content to be produced when pasting HTML with isolating nodes in it.
|
|
38
|
+
|
|
1
39
|
## 1.20.2 (2021-10-07)
|
|
2
40
|
|
|
3
41
|
### Bug fixes
|
package/dist/index.es.js
CHANGED
|
@@ -9,7 +9,6 @@ if (typeof navigator != "undefined" && typeof document != "undefined") {
|
|
|
9
9
|
var ie_upto10 = /MSIE \d/.test(navigator.userAgent);
|
|
10
10
|
var ie_11up = /Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);
|
|
11
11
|
|
|
12
|
-
result.mac = /Mac/.test(navigator.platform);
|
|
13
12
|
var ie = result.ie = !!(ie_upto10 || ie_11up || ie_edge);
|
|
14
13
|
result.ie_version = ie_upto10 ? document.documentMode || 6 : ie_11up ? +ie_11up[1] : ie_edge ? +ie_edge[1] : null;
|
|
15
14
|
result.gecko = !ie && /gecko\/(\d+)/i.test(navigator.userAgent);
|
|
@@ -20,6 +19,7 @@ if (typeof navigator != "undefined" && typeof document != "undefined") {
|
|
|
20
19
|
// Is true for both iOS and iPadOS for convenience
|
|
21
20
|
result.safari = !ie && /Apple Computer/.test(navigator.vendor);
|
|
22
21
|
result.ios = result.safari && (/Mobile\/\w+/.test(navigator.userAgent) || navigator.maxTouchPoints > 2);
|
|
22
|
+
result.mac = result.ios || /Mac/.test(navigator.platform);
|
|
23
23
|
result.android = /Android \d/.test(navigator.userAgent);
|
|
24
24
|
result.webkit = "webkitFontSmoothing" in document.documentElement.style;
|
|
25
25
|
result.webkit_version = result.webkit && +(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent) || [0, 0])[1];
|
|
@@ -1121,6 +1121,11 @@ var WidgetViewDesc = /*@__PURE__*/(function (ViewDesc) {
|
|
|
1121
1121
|
return mutation.type != "selection" || this.widget.spec.ignoreSelection
|
|
1122
1122
|
};
|
|
1123
1123
|
|
|
1124
|
+
WidgetViewDesc.prototype.destroy = function destroy () {
|
|
1125
|
+
this.widget.type.destroy(this.dom);
|
|
1126
|
+
ViewDesc.prototype.destroy.call(this);
|
|
1127
|
+
};
|
|
1128
|
+
|
|
1124
1129
|
prototypeAccessors$1.domAtom.get = function () { return true };
|
|
1125
1130
|
|
|
1126
1131
|
Object.defineProperties( WidgetViewDesc.prototype, prototypeAccessors$1 );
|
|
@@ -1696,6 +1701,8 @@ function patchAttributes(dom, prev, cur) {
|
|
|
1696
1701
|
{ dom.classList.remove(prevList[i]); } }
|
|
1697
1702
|
for (var i$1 = 0; i$1 < curList.length; i$1++) { if (prevList.indexOf(curList[i$1]) == -1)
|
|
1698
1703
|
{ dom.classList.add(curList[i$1]); } }
|
|
1704
|
+
if (dom.classList.length == 0)
|
|
1705
|
+
{ dom.removeAttribute("class"); }
|
|
1699
1706
|
}
|
|
1700
1707
|
if (prev.style != cur.style) {
|
|
1701
1708
|
if (prev.style) {
|
|
@@ -1803,10 +1810,12 @@ ViewTreeUpdater.prototype.syncToMarks = function syncToMarks (marks, inline, vie
|
|
|
1803
1810
|
ViewTreeUpdater.prototype.findNodeMatch = function findNodeMatch (node, outerDeco, innerDeco, index) {
|
|
1804
1811
|
var children = this.top.children, found = -1;
|
|
1805
1812
|
if (index >= this.preMatch.index) {
|
|
1806
|
-
for (var i = this.index; i < children.length; i++) {
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1813
|
+
for (var i = this.index; i < children.length; i++) {
|
|
1814
|
+
if (this.preMatch.matched.get(children[i]) == index) {
|
|
1815
|
+
if (children[i].matchesNode(node, outerDeco, innerDeco)) { found = i; }
|
|
1816
|
+
break
|
|
1817
|
+
}
|
|
1818
|
+
}
|
|
1810
1819
|
} else {
|
|
1811
1820
|
for (var i$1 = this.index, e = Math.min(children.length, i$1 + 1); i$1 < e; i$1++) {
|
|
1812
1821
|
var child = children[i$1];
|
|
@@ -2951,7 +2960,7 @@ function parseFromClipboard(view, text, html, plainText, $context) {
|
|
|
2951
2960
|
var schema = ref.schema;
|
|
2952
2961
|
var serializer = DOMSerializer.fromSchema(schema);
|
|
2953
2962
|
dom = document.createElement("div");
|
|
2954
|
-
text.
|
|
2963
|
+
text.split(/(?:\r\n?|\n)+/).forEach(function (block) {
|
|
2955
2964
|
var p = dom.appendChild(document.createElement("p"));
|
|
2956
2965
|
if (block) { p.appendChild(serializer.serializeNode(schema.text(block, marks))); }
|
|
2957
2966
|
});
|
|
@@ -2966,12 +2975,27 @@ function parseFromClipboard(view, text, html, plainText, $context) {
|
|
|
2966
2975
|
var sliceData = contextNode && /^(\d+) (\d+) (.*)/.exec(contextNode.getAttribute("data-pm-slice"));
|
|
2967
2976
|
if (!slice) {
|
|
2968
2977
|
var parser = view.someProp("clipboardParser") || view.someProp("domParser") || DOMParser.fromSchema(view.state.schema);
|
|
2969
|
-
slice = parser.parseSlice(dom, {
|
|
2978
|
+
slice = parser.parseSlice(dom, {
|
|
2979
|
+
preserveWhitespace: !!(asText || sliceData),
|
|
2980
|
+
context: $context,
|
|
2981
|
+
ruleFromNode: function ruleFromNode(dom) {
|
|
2982
|
+
if (dom.nodeName == "BR" && !dom.nextSibling) { return {ignore: true} }
|
|
2983
|
+
}
|
|
2984
|
+
});
|
|
2985
|
+
}
|
|
2986
|
+
if (sliceData) {
|
|
2987
|
+
slice = addContext(closeSlice(slice, +sliceData[1], +sliceData[2]), sliceData[3]);
|
|
2988
|
+
} else { // HTML wasn't created by ProseMirror. Make sure top-level siblings are coherent
|
|
2989
|
+
slice = Slice.maxOpen(normalizeSiblings(slice.content, $context), true);
|
|
2990
|
+
if (slice.openStart || slice.openEnd) {
|
|
2991
|
+
var openStart = 0, openEnd = 0;
|
|
2992
|
+
for (var node = slice.content.firstChild; openStart < slice.openStart && !node.type.spec.isolating;
|
|
2993
|
+
openStart++, node = node.firstChild) {}
|
|
2994
|
+
for (var node$1 = slice.content.lastChild; openEnd < slice.openEnd && !node$1.type.spec.isolating;
|
|
2995
|
+
openEnd++, node$1 = node$1.lastChild) {}
|
|
2996
|
+
slice = closeSlice(slice, openStart, openEnd);
|
|
2997
|
+
}
|
|
2970
2998
|
}
|
|
2971
|
-
if (sliceData)
|
|
2972
|
-
{ slice = addContext(closeSlice(slice, +sliceData[1], +sliceData[2]), sliceData[3]); }
|
|
2973
|
-
else // HTML wasn't created by ProseMirror. Make sure top-level siblings are coherent
|
|
2974
|
-
{ slice = Slice.maxOpen(normalizeSiblings(slice.content, $context), false); }
|
|
2975
2999
|
|
|
2976
3000
|
view.someProp("transformPasted", function (f) { slice = f(slice); });
|
|
2977
3001
|
return slice
|
|
@@ -4112,6 +4136,10 @@ WidgetType.prototype.eq = function eq (other) {
|
|
|
4112
4136
|
this.toDOM == other.toDOM && compareObjs(this.spec, other.spec)))
|
|
4113
4137
|
};
|
|
4114
4138
|
|
|
4139
|
+
WidgetType.prototype.destroy = function destroy (node) {
|
|
4140
|
+
if (this.spec.destroy) { this.spec.destroy(node); }
|
|
4141
|
+
};
|
|
4142
|
+
|
|
4115
4143
|
var InlineType = function InlineType(attrs, spec) {
|
|
4116
4144
|
this.spec = spec || noSpec;
|
|
4117
4145
|
this.attrs = attrs;
|
|
@@ -4239,6 +4267,10 @@ Decoration.prototype.map = function map (mapping, offset, oldOffset) {
|
|
|
4239
4267
|
// key are interchangeable—if widgets differ in, for example,
|
|
4240
4268
|
// the behavior of some event handler, they should get
|
|
4241
4269
|
// different keys.
|
|
4270
|
+
//
|
|
4271
|
+
// destroy:: ?(node: dom.Node)
|
|
4272
|
+
// Called when the widget decoration is removed as a result of
|
|
4273
|
+
// mapping
|
|
4242
4274
|
Decoration.widget = function widget (pos, toDOM, spec) {
|
|
4243
4275
|
return new Decoration(pos, pos, new WidgetType(toDOM, spec))
|
|
4244
4276
|
};
|
|
@@ -4834,7 +4866,7 @@ var EditorView = function EditorView(place, props) {
|
|
|
4834
4866
|
this.updatePluginViews();
|
|
4835
4867
|
};
|
|
4836
4868
|
|
|
4837
|
-
var prototypeAccessors$2 = { props: { configurable: true },root: { configurable: true } };
|
|
4869
|
+
var prototypeAccessors$2 = { props: { configurable: true },root: { configurable: true },isDestroyed: { configurable: true } };
|
|
4838
4870
|
|
|
4839
4871
|
// composing:: boolean
|
|
4840
4872
|
// Holds `true` when a
|
|
@@ -5144,6 +5176,14 @@ EditorView.prototype.destroy = function destroy () {
|
|
|
5144
5176
|
this.docView = null;
|
|
5145
5177
|
};
|
|
5146
5178
|
|
|
5179
|
+
// :: boolean
|
|
5180
|
+
// This is true when the view has been
|
|
5181
|
+
// [destroyed](#view.EditorView.destroy) (and thus should not be
|
|
5182
|
+
// used anymore).
|
|
5183
|
+
prototypeAccessors$2.isDestroyed.get = function () {
|
|
5184
|
+
return this.docView == null
|
|
5185
|
+
};
|
|
5186
|
+
|
|
5147
5187
|
// Used for testing.
|
|
5148
5188
|
EditorView.prototype.dispatchEvent = function dispatchEvent$1 (event) {
|
|
5149
5189
|
return dispatchEvent(this, event)
|
|
@@ -5176,6 +5216,9 @@ function computeDocDeco(view) {
|
|
|
5176
5216
|
if (value) { for (var attr in value) {
|
|
5177
5217
|
if (attr == "class")
|
|
5178
5218
|
{ attrs.class += " " + value[attr]; }
|
|
5219
|
+
if (attr == "style") {
|
|
5220
|
+
attrs.style = (attrs.style ? attrs.style + ";" : "") + value[attr];
|
|
5221
|
+
}
|
|
5179
5222
|
else if (!attrs[attr] && attr != "contenteditable" && attr != "nodeName")
|
|
5180
5223
|
{ attrs[attr] = String(value[attr]); }
|
|
5181
5224
|
} }
|
|
@@ -5411,7 +5454,7 @@ function checkStateComponent(plugin) {
|
|
|
5411
5454
|
// view](#state.PluginSpec.view) and
|
|
5412
5455
|
// [props](#state.PluginSpec.props). Passing plugins with a state
|
|
5413
5456
|
// component (a [state field](#state.PluginSpec.state) field or a
|
|
5414
|
-
// [transaction
|
|
5457
|
+
// [transaction](#state.PluginSpec.filterTransaction) filter or
|
|
5415
5458
|
// appender) will result in an error, since such plugins must be
|
|
5416
5459
|
// present in the state to work.
|
|
5417
5460
|
//
|