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/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,12 +1814,14 @@ 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++) { if (children[i].matchesNode(node, outerDeco, innerDeco)) {
1811
- found = i;
1812
- break
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
- for (var i$1 = this.index, e = Math.min(children.length, i$1 + 1); i$1 < e; i$1++) {
1824
+ for (var i$1 = this.index, e = Math.min(children.length, i$1 + 5); i$1 < e; i$1++) {
1816
1825
  var child = children[i$1];
1817
1826
  if (child.matchesNode(node, outerDeco, innerDeco) && !this.preMatch.matched.has(child)) {
1818
1827
  found = i$1;
@@ -2970,7 +2979,13 @@ 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, {preserveWhitespace: !!(asText || sliceData), context: $context});
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
+ });
2974
2989
  }
2975
2990
  if (sliceData) {
2976
2991
  slice = addContext(closeSlice(slice, +sliceData[1], +sliceData[2]), sliceData[3]);
@@ -4125,6 +4140,10 @@ WidgetType.prototype.eq = function eq (other) {
4125
4140
  this.toDOM == other.toDOM && compareObjs(this.spec, other.spec)))
4126
4141
  };
4127
4142
 
4143
+ WidgetType.prototype.destroy = function destroy (node) {
4144
+ if (this.spec.destroy) { this.spec.destroy(node); }
4145
+ };
4146
+
4128
4147
  var InlineType = function InlineType(attrs, spec) {
4129
4148
  this.spec = spec || noSpec;
4130
4149
  this.attrs = attrs;
@@ -4252,6 +4271,10 @@ Decoration.prototype.map = function map (mapping, offset, oldOffset) {
4252
4271
  // key are interchangeable—if widgets differ in, for example,
4253
4272
  // the behavior of some event handler, they should get
4254
4273
  // different keys.
4274
+ //
4275
+ // destroy:: ?(node: dom.Node)
4276
+ // Called when the widget decoration is removed as a result of
4277
+ // mapping
4255
4278
  Decoration.widget = function widget (pos, toDOM, spec) {
4256
4279
  return new Decoration(pos, pos, new WidgetType(toDOM, spec))
4257
4280
  };
@@ -4847,7 +4870,7 @@ var EditorView = function EditorView(place, props) {
4847
4870
  this.updatePluginViews();
4848
4871
  };
4849
4872
 
4850
- var prototypeAccessors$2 = { props: { configurable: true },root: { configurable: true } };
4873
+ var prototypeAccessors$2 = { props: { configurable: true },root: { configurable: true },isDestroyed: { configurable: true } };
4851
4874
 
4852
4875
  // composing:: boolean
4853
4876
  // Holds `true` when a
@@ -5157,6 +5180,14 @@ EditorView.prototype.destroy = function destroy () {
5157
5180
  this.docView = null;
5158
5181
  };
5159
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
+
5160
5191
  // Used for testing.
5161
5192
  EditorView.prototype.dispatchEvent = function dispatchEvent$1 (event) {
5162
5193
  return dispatchEvent(this, event)
@@ -5189,6 +5220,9 @@ function computeDocDeco(view) {
5189
5220
  if (value) { for (var attr in value) {
5190
5221
  if (attr == "class")
5191
5222
  { attrs.class += " " + value[attr]; }
5223
+ if (attr == "style") {
5224
+ attrs.style = (attrs.style ? attrs.style + ";" : "") + value[attr];
5225
+ }
5192
5226
  else if (!attrs[attr] && attr != "contenteditable" && attr != "nodeName")
5193
5227
  { attrs[attr] = String(value[attr]); }
5194
5228
  } }
@@ -5424,7 +5458,7 @@ function checkStateComponent(plugin) {
5424
5458
  // view](#state.PluginSpec.view) and
5425
5459
  // [props](#state.PluginSpec.props). Passing plugins with a state
5426
5460
  // component (a [state field](#state.PluginSpec.state) field or a
5427
- // [transaction)[#state.PluginSpec.filterTransaction] filter or
5461
+ // [transaction](#state.PluginSpec.filterTransaction) filter or
5428
5462
  // appender) will result in an error, since such plugins must be
5429
5463
  // present in the state to work.
5430
5464
  //