prosemirror-view 1.21.0 → 1.22.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/dist/index.js CHANGED
@@ -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++) { 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
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];
@@ -4125,6 +4134,10 @@ WidgetType.prototype.eq = function eq (other) {
4125
4134
  this.toDOM == other.toDOM && compareObjs(this.spec, other.spec)))
4126
4135
  };
4127
4136
 
4137
+ WidgetType.prototype.destroy = function destroy (node) {
4138
+ if (this.spec.destroy) { this.spec.destroy(node); }
4139
+ };
4140
+
4128
4141
  var InlineType = function InlineType(attrs, spec) {
4129
4142
  this.spec = spec || noSpec;
4130
4143
  this.attrs = attrs;
@@ -4252,6 +4265,10 @@ Decoration.prototype.map = function map (mapping, offset, oldOffset) {
4252
4265
  // key are interchangeable—if widgets differ in, for example,
4253
4266
  // the behavior of some event handler, they should get
4254
4267
  // different keys.
4268
+ //
4269
+ // destroy:: ?(node: dom.Node)
4270
+ // Called when the widget decoration is removed as a result of
4271
+ // mapping
4255
4272
  Decoration.widget = function widget (pos, toDOM, spec) {
4256
4273
  return new Decoration(pos, pos, new WidgetType(toDOM, spec))
4257
4274
  };
@@ -5427,7 +5444,7 @@ function checkStateComponent(plugin) {
5427
5444
  // view](#state.PluginSpec.view) and
5428
5445
  // [props](#state.PluginSpec.props). Passing plugins with a state
5429
5446
  // component (a [state field](#state.PluginSpec.state) field or a
5430
- // [transaction)[#state.PluginSpec.filterTransaction] filter or
5447
+ // [transaction](#state.PluginSpec.filterTransaction) filter or
5431
5448
  // appender) will result in an error, since such plugins must be
5432
5449
  // present in the state to work.
5433
5450
  //