prosemirror-view 1.22.0 → 1.23.3
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 +28 -0
- package/dist/index.es.js +57 -21
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +57 -21
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/clipboard.js +10 -1
- package/src/decoration.js +1 -1
- package/src/index.js +8 -0
- package/src/viewdesc.js +36 -17
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,31 @@
|
|
|
1
|
+
## 1.23.3 (2021-11-26)
|
|
2
|
+
|
|
3
|
+
### Bug fixes
|
|
4
|
+
|
|
5
|
+
The clipboard parser will no longer drop trailing `<br>` nodes that appear in an inline parent element.
|
|
6
|
+
|
|
7
|
+
## 1.23.2 (2021-11-19)
|
|
8
|
+
|
|
9
|
+
### Bug fixes
|
|
10
|
+
|
|
11
|
+
Avoid some unnecessary node redraws when marks are present in sibling nodes.
|
|
12
|
+
|
|
13
|
+
## 1.23.1 (2021-11-15)
|
|
14
|
+
|
|
15
|
+
### Bug fixes
|
|
16
|
+
|
|
17
|
+
Restore accidentally reduced lookahead distance in view updating algorithm.
|
|
18
|
+
|
|
19
|
+
## 1.23.0 (2021-11-11)
|
|
20
|
+
|
|
21
|
+
### Bug fixes
|
|
22
|
+
|
|
23
|
+
When parsing clipboard content, ignore trailing BR nodes that look like they might be there as a contenteditable kludge.
|
|
24
|
+
|
|
25
|
+
### New features
|
|
26
|
+
|
|
27
|
+
`EditorView` now exposes an `isDestroyed` property that can be used to test if the view has been destroyed.
|
|
28
|
+
|
|
1
29
|
## 1.22.0 (2021-11-08)
|
|
2
30
|
|
|
3
31
|
### Bug fixes
|
package/dist/index.es.js
CHANGED
|
@@ -1747,7 +1747,7 @@ var ViewTreeUpdater = function ViewTreeUpdater(top, lockedNode) {
|
|
|
1747
1747
|
// Tracks whether anything was changed
|
|
1748
1748
|
this.changed = false;
|
|
1749
1749
|
|
|
1750
|
-
this.preMatch = preMatch(top.node.content, top
|
|
1750
|
+
this.preMatch = preMatch(top.node.content, top);
|
|
1751
1751
|
};
|
|
1752
1752
|
|
|
1753
1753
|
// Destroy and remove the children between the given indices in
|
|
@@ -1808,19 +1808,16 @@ ViewTreeUpdater.prototype.syncToMarks = function syncToMarks (marks, inline, vie
|
|
|
1808
1808
|
// Try to find a node desc matching the given data. Skip over it and
|
|
1809
1809
|
// return true when successful.
|
|
1810
1810
|
ViewTreeUpdater.prototype.findNodeMatch = function findNodeMatch (node, outerDeco, innerDeco, index) {
|
|
1811
|
-
var
|
|
1812
|
-
if (index >= this.preMatch.index
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
break
|
|
1817
|
-
}
|
|
1818
|
-
}
|
|
1811
|
+
var found = -1, targetDesc;
|
|
1812
|
+
if (index >= this.preMatch.index &&
|
|
1813
|
+
(targetDesc = this.preMatch.matches[index - this.preMatch.index]).parent == this.top &&
|
|
1814
|
+
targetDesc.matchesNode(node, outerDeco, innerDeco)) {
|
|
1815
|
+
found = this.top.children.indexOf(targetDesc, this.index);
|
|
1819
1816
|
} else {
|
|
1820
|
-
for (var i
|
|
1821
|
-
var child = children[i
|
|
1817
|
+
for (var i = this.index, e = Math.min(this.top.children.length, i + 5); i < e; i++) {
|
|
1818
|
+
var child = this.top.children[i];
|
|
1822
1819
|
if (child.matchesNode(node, outerDeco, innerDeco) && !this.preMatch.matched.has(child)) {
|
|
1823
|
-
found = i
|
|
1820
|
+
found = i;
|
|
1824
1821
|
break
|
|
1825
1822
|
}
|
|
1826
1823
|
}
|
|
@@ -1929,22 +1926,44 @@ ViewTreeUpdater.prototype.addHackNode = function addHackNode (nodeName) {
|
|
|
1929
1926
|
}
|
|
1930
1927
|
};
|
|
1931
1928
|
|
|
1932
|
-
// : (Fragment, [ViewDesc]) → {index: number, matched: Map<ViewDesc, number
|
|
1929
|
+
// : (Fragment, [ViewDesc]) → {index: number, matched: Map<ViewDesc, number>, matches: ViewDesc[]}
|
|
1933
1930
|
// Iterate from the end of the fragment and array of descs to find
|
|
1934
1931
|
// directly matching ones, in order to avoid overeagerly reusing those
|
|
1935
1932
|
// for other nodes. Returns the fragment index of the first node that
|
|
1936
1933
|
// is part of the sequence of matched nodes at the end of the
|
|
1937
1934
|
// fragment.
|
|
1938
|
-
function preMatch(frag,
|
|
1939
|
-
var
|
|
1940
|
-
|
|
1941
|
-
|
|
1935
|
+
function preMatch(frag, parentDesc) {
|
|
1936
|
+
var curDesc = parentDesc, descI = curDesc.children.length;
|
|
1937
|
+
var fI = frag.childCount, matched = new Map, matches = [];
|
|
1938
|
+
outer: while (fI > 0) {
|
|
1939
|
+
var desc = (void 0);
|
|
1940
|
+
for (;;) {
|
|
1941
|
+
if (descI) {
|
|
1942
|
+
var next = curDesc.children[descI - 1];
|
|
1943
|
+
if (next instanceof MarkViewDesc) {
|
|
1944
|
+
curDesc = next;
|
|
1945
|
+
descI = next.children.length;
|
|
1946
|
+
} else {
|
|
1947
|
+
desc = next;
|
|
1948
|
+
descI--;
|
|
1949
|
+
break
|
|
1950
|
+
}
|
|
1951
|
+
} else if (curDesc == parentDesc) {
|
|
1952
|
+
break outer
|
|
1953
|
+
} else {
|
|
1954
|
+
// FIXME
|
|
1955
|
+
descI = curDesc.parent.children.indexOf(curDesc);
|
|
1956
|
+
curDesc = curDesc.parent;
|
|
1957
|
+
}
|
|
1958
|
+
}
|
|
1959
|
+
var node = desc.node;
|
|
1942
1960
|
if (!node) { continue }
|
|
1943
1961
|
if (node != frag.child(fI - 1)) { break }
|
|
1944
1962
|
--fI;
|
|
1945
1963
|
matched.set(desc, fI);
|
|
1964
|
+
matches.push(desc);
|
|
1946
1965
|
}
|
|
1947
|
-
return {index: fI, matched: matched}
|
|
1966
|
+
return {index: fI, matched: matched, matches: matches.reverse()}
|
|
1948
1967
|
}
|
|
1949
1968
|
|
|
1950
1969
|
function compareSide(a, b) { return a.type.side - b.type.side }
|
|
@@ -2975,7 +2994,14 @@ function parseFromClipboard(view, text, html, plainText, $context) {
|
|
|
2975
2994
|
var sliceData = contextNode && /^(\d+) (\d+) (.*)/.exec(contextNode.getAttribute("data-pm-slice"));
|
|
2976
2995
|
if (!slice) {
|
|
2977
2996
|
var parser = view.someProp("clipboardParser") || view.someProp("domParser") || DOMParser.fromSchema(view.state.schema);
|
|
2978
|
-
slice = parser.parseSlice(dom, {
|
|
2997
|
+
slice = parser.parseSlice(dom, {
|
|
2998
|
+
preserveWhitespace: !!(asText || sliceData),
|
|
2999
|
+
context: $context,
|
|
3000
|
+
ruleFromNode: function ruleFromNode(dom) {
|
|
3001
|
+
if (dom.nodeName == "BR" && !dom.nextSibling &&
|
|
3002
|
+
dom.parentNode && !inlineParents.test(dom.parentNode.nodeName)) { return {ignore: true} }
|
|
3003
|
+
}
|
|
3004
|
+
});
|
|
2979
3005
|
}
|
|
2980
3006
|
if (sliceData) {
|
|
2981
3007
|
slice = addContext(closeSlice(slice, +sliceData[1], +sliceData[2]), sliceData[3]);
|
|
@@ -2995,6 +3021,8 @@ function parseFromClipboard(view, text, html, plainText, $context) {
|
|
|
2995
3021
|
return slice
|
|
2996
3022
|
}
|
|
2997
3023
|
|
|
3024
|
+
var inlineParents = /^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;
|
|
3025
|
+
|
|
2998
3026
|
// Takes a slice parsed with parseSlice, which means there hasn't been
|
|
2999
3027
|
// any content-expression checking done on the top nodes, tries to
|
|
3000
3028
|
// find a parent node in the current context that might fit the nodes,
|
|
@@ -4261,7 +4289,7 @@ Decoration.prototype.map = function map (mapping, offset, oldOffset) {
|
|
|
4261
4289
|
// key are interchangeable—if widgets differ in, for example,
|
|
4262
4290
|
// the behavior of some event handler, they should get
|
|
4263
4291
|
// different keys.
|
|
4264
|
-
//
|
|
4292
|
+
//
|
|
4265
4293
|
// destroy:: ?(node: dom.Node)
|
|
4266
4294
|
// Called when the widget decoration is removed as a result of
|
|
4267
4295
|
// mapping
|
|
@@ -4860,7 +4888,7 @@ var EditorView = function EditorView(place, props) {
|
|
|
4860
4888
|
this.updatePluginViews();
|
|
4861
4889
|
};
|
|
4862
4890
|
|
|
4863
|
-
var prototypeAccessors$2 = { props: { configurable: true },root: { configurable: true } };
|
|
4891
|
+
var prototypeAccessors$2 = { props: { configurable: true },root: { configurable: true },isDestroyed: { configurable: true } };
|
|
4864
4892
|
|
|
4865
4893
|
// composing:: boolean
|
|
4866
4894
|
// Holds `true` when a
|
|
@@ -5170,6 +5198,14 @@ EditorView.prototype.destroy = function destroy () {
|
|
|
5170
5198
|
this.docView = null;
|
|
5171
5199
|
};
|
|
5172
5200
|
|
|
5201
|
+
// :: boolean
|
|
5202
|
+
// This is true when the view has been
|
|
5203
|
+
// [destroyed](#view.EditorView.destroy) (and thus should not be
|
|
5204
|
+
// used anymore).
|
|
5205
|
+
prototypeAccessors$2.isDestroyed.get = function () {
|
|
5206
|
+
return this.docView == null
|
|
5207
|
+
};
|
|
5208
|
+
|
|
5173
5209
|
// Used for testing.
|
|
5174
5210
|
EditorView.prototype.dispatchEvent = function dispatchEvent$1 (event) {
|
|
5175
5211
|
return dispatchEvent(this, event)
|