prosemirror-view 1.20.3 → 1.23.1
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 +36 -0
- package/dist/index.es.js +43 -9
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +43 -9
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/browser.js +1 -1
- package/src/clipboard.js +7 -1
- package/src/decoration.js +8 -0
- package/src/index.js +12 -1
- package/src/viewdesc.js +13 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,39 @@
|
|
|
1
|
+
## 1.23.1 (2021-11-15)
|
|
2
|
+
|
|
3
|
+
### Bug fixes
|
|
4
|
+
|
|
5
|
+
Restore accidentally reduced lookahead distance in view updating algorithm.
|
|
6
|
+
|
|
7
|
+
## 1.23.0 (2021-11-11)
|
|
8
|
+
|
|
9
|
+
### Bug fixes
|
|
10
|
+
|
|
11
|
+
When parsing clipboard content, ignore trailing BR nodes that look like they might be there as a contenteditable kludge.
|
|
12
|
+
|
|
13
|
+
### New features
|
|
14
|
+
|
|
15
|
+
`EditorView` now exposes an `isDestroyed` property that can be used to test if the view has been destroyed.
|
|
16
|
+
|
|
17
|
+
## 1.22.0 (2021-11-08)
|
|
18
|
+
|
|
19
|
+
### Bug fixes
|
|
20
|
+
|
|
21
|
+
Fix an issue where some types of node decoration changes could cause an unnecessary cascade of node redraws.
|
|
22
|
+
|
|
23
|
+
### New features
|
|
24
|
+
|
|
25
|
+
Widget decorations now accept a `destroy` option, which will be called when the widget is removed from the view.
|
|
26
|
+
|
|
27
|
+
## 1.21.0 (2021-10-29)
|
|
28
|
+
|
|
29
|
+
### Bug fixes
|
|
30
|
+
|
|
31
|
+
Fix issue where recent Mobile Safari versions weren't treated as Mac platforms.
|
|
32
|
+
|
|
33
|
+
### New features
|
|
34
|
+
|
|
35
|
+
Multiple `style` properties provided through the `attributes` prop are now merged. Adjust mac detection for recent changes to navigator.platform on iOS
|
|
36
|
+
|
|
1
37
|
## 1.20.3 (2021-10-13)
|
|
2
38
|
|
|
3
39
|
### 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,12 +1810,14 @@ 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
|
-
for (var i$1 = this.index, e = Math.min(children.length, i$1 +
|
|
1820
|
+
for (var i$1 = this.index, e = Math.min(children.length, i$1 + 5); i$1 < e; i$1++) {
|
|
1812
1821
|
var child = children[i$1];
|
|
1813
1822
|
if (child.matchesNode(node, outerDeco, innerDeco) && !this.preMatch.matched.has(child)) {
|
|
1814
1823
|
found = i$1;
|
|
@@ -2966,7 +2975,13 @@ 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
|
+
});
|
|
2970
2985
|
}
|
|
2971
2986
|
if (sliceData) {
|
|
2972
2987
|
slice = addContext(closeSlice(slice, +sliceData[1], +sliceData[2]), sliceData[3]);
|
|
@@ -4121,6 +4136,10 @@ WidgetType.prototype.eq = function eq (other) {
|
|
|
4121
4136
|
this.toDOM == other.toDOM && compareObjs(this.spec, other.spec)))
|
|
4122
4137
|
};
|
|
4123
4138
|
|
|
4139
|
+
WidgetType.prototype.destroy = function destroy (node) {
|
|
4140
|
+
if (this.spec.destroy) { this.spec.destroy(node); }
|
|
4141
|
+
};
|
|
4142
|
+
|
|
4124
4143
|
var InlineType = function InlineType(attrs, spec) {
|
|
4125
4144
|
this.spec = spec || noSpec;
|
|
4126
4145
|
this.attrs = attrs;
|
|
@@ -4248,6 +4267,10 @@ Decoration.prototype.map = function map (mapping, offset, oldOffset) {
|
|
|
4248
4267
|
// key are interchangeable—if widgets differ in, for example,
|
|
4249
4268
|
// the behavior of some event handler, they should get
|
|
4250
4269
|
// different keys.
|
|
4270
|
+
//
|
|
4271
|
+
// destroy:: ?(node: dom.Node)
|
|
4272
|
+
// Called when the widget decoration is removed as a result of
|
|
4273
|
+
// mapping
|
|
4251
4274
|
Decoration.widget = function widget (pos, toDOM, spec) {
|
|
4252
4275
|
return new Decoration(pos, pos, new WidgetType(toDOM, spec))
|
|
4253
4276
|
};
|
|
@@ -4843,7 +4866,7 @@ var EditorView = function EditorView(place, props) {
|
|
|
4843
4866
|
this.updatePluginViews();
|
|
4844
4867
|
};
|
|
4845
4868
|
|
|
4846
|
-
var prototypeAccessors$2 = { props: { configurable: true },root: { configurable: true } };
|
|
4869
|
+
var prototypeAccessors$2 = { props: { configurable: true },root: { configurable: true },isDestroyed: { configurable: true } };
|
|
4847
4870
|
|
|
4848
4871
|
// composing:: boolean
|
|
4849
4872
|
// Holds `true` when a
|
|
@@ -5153,6 +5176,14 @@ EditorView.prototype.destroy = function destroy () {
|
|
|
5153
5176
|
this.docView = null;
|
|
5154
5177
|
};
|
|
5155
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
|
+
|
|
5156
5187
|
// Used for testing.
|
|
5157
5188
|
EditorView.prototype.dispatchEvent = function dispatchEvent$1 (event) {
|
|
5158
5189
|
return dispatchEvent(this, event)
|
|
@@ -5185,6 +5216,9 @@ function computeDocDeco(view) {
|
|
|
5185
5216
|
if (value) { for (var attr in value) {
|
|
5186
5217
|
if (attr == "class")
|
|
5187
5218
|
{ attrs.class += " " + value[attr]; }
|
|
5219
|
+
if (attr == "style") {
|
|
5220
|
+
attrs.style = (attrs.style ? attrs.style + ";" : "") + value[attr];
|
|
5221
|
+
}
|
|
5188
5222
|
else if (!attrs[attr] && attr != "contenteditable" && attr != "nodeName")
|
|
5189
5223
|
{ attrs[attr] = String(value[attr]); }
|
|
5190
5224
|
} }
|
|
@@ -5420,7 +5454,7 @@ function checkStateComponent(plugin) {
|
|
|
5420
5454
|
// view](#state.PluginSpec.view) and
|
|
5421
5455
|
// [props](#state.PluginSpec.props). Passing plugins with a state
|
|
5422
5456
|
// component (a [state field](#state.PluginSpec.state) field or a
|
|
5423
|
-
// [transaction
|
|
5457
|
+
// [transaction](#state.PluginSpec.filterTransaction) filter or
|
|
5424
5458
|
// appender) will result in an error, since such plugins must be
|
|
5425
5459
|
// present in the state to work.
|
|
5426
5460
|
//
|