@ni/nimble-components 32.1.0 → 32.1.2

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.
@@ -15,7 +15,7 @@
15
15
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16
16
  PERFORMANCE OF THIS SOFTWARE.
17
17
  ***************************************************************************** */
18
- /* global Reflect, Promise, SuppressedError, Symbol */
18
+ /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
19
19
 
20
20
 
21
21
  function __decorate$1(decorators, target, key, desc) {
@@ -54,7 +54,7 @@
54
54
  function __asyncGenerator(thisArg, _arguments, generator) {
55
55
  if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
56
56
  var g = generator.apply(thisArg, _arguments || []), i, q = [];
57
- return i = {}, verb("next"), verb("throw"), verb("return", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;
57
+ return i = Object.create((typeof AsyncIterator === "function" ? AsyncIterator : Object).prototype), verb("next"), verb("throw"), verb("return", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;
58
58
  function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }
59
59
  function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } }
60
60
  function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
@@ -29373,7 +29373,7 @@ so this becomes the fallback color for the slot */ ''}
29373
29373
  */
29374
29374
  parse(dom, options = {}) {
29375
29375
  let context = new ParseContext(this, options, false);
29376
- context.addAll(dom, options.from, options.to);
29376
+ context.addAll(dom, Mark$1.none, options.from, options.to);
29377
29377
  return context.finish();
29378
29378
  }
29379
29379
  /**
@@ -29386,7 +29386,7 @@ so this becomes the fallback color for the slot */ ''}
29386
29386
  */
29387
29387
  parseSlice(dom, options = {}) {
29388
29388
  let context = new ParseContext(this, options, true);
29389
- context.addAll(dom, options.from, options.to);
29389
+ context.addAll(dom, Mark$1.none, options.from, options.to);
29390
29390
  return Slice.maxOpen(context.finish());
29391
29391
  }
29392
29392
  /**
@@ -29495,22 +29495,15 @@ so this becomes the fallback color for the slot */ ''}
29495
29495
  return type && type.whitespace == "pre" ? OPT_PRESERVE_WS | OPT_PRESERVE_WS_FULL : base & ~OPT_OPEN_LEFT;
29496
29496
  }
29497
29497
  class NodeContext {
29498
- constructor(type, attrs,
29499
- // Marks applied to this node itself
29500
- marks,
29501
- // Marks that can't apply here, but will be used in children if possible
29502
- pendingMarks, solid, match, options) {
29498
+ constructor(type, attrs, marks, solid, match, options) {
29503
29499
  this.type = type;
29504
29500
  this.attrs = attrs;
29505
29501
  this.marks = marks;
29506
- this.pendingMarks = pendingMarks;
29507
29502
  this.solid = solid;
29508
29503
  this.options = options;
29509
29504
  this.content = [];
29510
29505
  // Marks applied to the node's children
29511
29506
  this.activeMarks = Mark$1.none;
29512
- // Nested Marks with same type
29513
- this.stashMarks = [];
29514
29507
  this.match = match || (options & OPT_OPEN_LEFT ? null : type.contentMatch);
29515
29508
  }
29516
29509
  findWrapping(node) {
@@ -29550,21 +29543,6 @@ so this becomes the fallback color for the slot */ ''}
29550
29543
  content = content.append(this.match.fillBefore(Fragment.empty, true));
29551
29544
  return this.type ? this.type.create(this.attrs, content, this.marks) : content;
29552
29545
  }
29553
- popFromStashMark(mark) {
29554
- for (let i = this.stashMarks.length - 1; i >= 0; i--)
29555
- if (mark.eq(this.stashMarks[i]))
29556
- return this.stashMarks.splice(i, 1)[0];
29557
- }
29558
- applyPending(nextType) {
29559
- for (let i = 0, pending = this.pendingMarks; i < pending.length; i++) {
29560
- let mark = pending[i];
29561
- if ((this.type ? this.type.allowsMarkType(mark.type) : markMayApply(mark.type, nextType)) &&
29562
- !mark.isInSet(this.activeMarks)) {
29563
- this.activeMarks = mark.addToSet(this.activeMarks);
29564
- this.pendingMarks = mark.removeFromSet(this.pendingMarks);
29565
- }
29566
- }
29567
- }
29568
29546
  inlineContext(node) {
29569
29547
  if (this.type)
29570
29548
  return this.type.inlineContent;
@@ -29586,11 +29564,11 @@ so this becomes the fallback color for the slot */ ''}
29586
29564
  let topNode = options.topNode, topContext;
29587
29565
  let topOptions = wsOptionsFor(null, options.preserveWhitespace, 0) | (isOpen ? OPT_OPEN_LEFT : 0);
29588
29566
  if (topNode)
29589
- topContext = new NodeContext(topNode.type, topNode.attrs, Mark$1.none, Mark$1.none, true, options.topMatch || topNode.type.contentMatch, topOptions);
29567
+ topContext = new NodeContext(topNode.type, topNode.attrs, Mark$1.none, true, options.topMatch || topNode.type.contentMatch, topOptions);
29590
29568
  else if (isOpen)
29591
- topContext = new NodeContext(null, null, Mark$1.none, Mark$1.none, true, null, topOptions);
29569
+ topContext = new NodeContext(null, null, Mark$1.none, true, null, topOptions);
29592
29570
  else
29593
- topContext = new NodeContext(parser.schema.topNodeType, null, Mark$1.none, Mark$1.none, true, null, topOptions);
29571
+ topContext = new NodeContext(parser.schema.topNodeType, null, Mark$1.none, true, null, topOptions);
29594
29572
  this.nodes = [topContext];
29595
29573
  this.find = options.findPositions;
29596
29574
  this.needsBlock = false;
@@ -29601,31 +29579,13 @@ so this becomes the fallback color for the slot */ ''}
29601
29579
  // Add a DOM node to the content. Text is inserted as text node,
29602
29580
  // otherwise, the node is passed to `addElement` or, if it has a
29603
29581
  // `style` attribute, `addElementWithStyles`.
29604
- addDOM(dom) {
29582
+ addDOM(dom, marks) {
29605
29583
  if (dom.nodeType == 3)
29606
- this.addTextNode(dom);
29584
+ this.addTextNode(dom, marks);
29607
29585
  else if (dom.nodeType == 1)
29608
- this.addElement(dom);
29609
- }
29610
- withStyleRules(dom, f) {
29611
- let style = dom.style;
29612
- if (!style || !style.length)
29613
- return f();
29614
- let marks = this.readStyles(dom.style);
29615
- if (!marks)
29616
- return; // A style with ignore: true
29617
- let [addMarks, removeMarks] = marks, top = this.top;
29618
- for (let i = 0; i < removeMarks.length; i++)
29619
- this.removePendingMark(removeMarks[i], top);
29620
- for (let i = 0; i < addMarks.length; i++)
29621
- this.addPendingMark(addMarks[i]);
29622
- f();
29623
- for (let i = 0; i < addMarks.length; i++)
29624
- this.removePendingMark(addMarks[i], top);
29625
- for (let i = 0; i < removeMarks.length; i++)
29626
- this.addPendingMark(removeMarks[i]);
29586
+ this.addElement(dom, marks);
29627
29587
  }
29628
- addTextNode(dom) {
29588
+ addTextNode(dom, marks) {
29629
29589
  let value = dom.nodeValue;
29630
29590
  let top = this.top;
29631
29591
  if (top.options & OPT_PRESERVE_WS_FULL ||
@@ -29652,7 +29612,7 @@ so this becomes the fallback color for the slot */ ''}
29652
29612
  value = value.replace(/\r\n?/g, "\n");
29653
29613
  }
29654
29614
  if (value)
29655
- this.insertNode(this.parser.schema.text(value));
29615
+ this.insertNode(this.parser.schema.text(value), marks);
29656
29616
  this.findInText(dom);
29657
29617
  }
29658
29618
  else {
@@ -29661,7 +29621,7 @@ so this becomes the fallback color for the slot */ ''}
29661
29621
  }
29662
29622
  // Try to find a handler for the given tag and use that to parse. If
29663
29623
  // none is found, the element's content nodes are added directly.
29664
- addElement(dom, matchAfter) {
29624
+ addElement(dom, marks, matchAfter) {
29665
29625
  let name = dom.nodeName.toLowerCase(), ruleID;
29666
29626
  if (listTags.hasOwnProperty(name) && this.parser.normalizeLists)
29667
29627
  normalizeList(dom);
@@ -29669,7 +29629,7 @@ so this becomes the fallback color for the slot */ ''}
29669
29629
  (ruleID = this.parser.matchTag(dom, this, matchAfter));
29670
29630
  if (rule ? rule.ignore : ignoreTags.hasOwnProperty(name)) {
29671
29631
  this.findInside(dom);
29672
- this.ignoreFallback(dom);
29632
+ this.ignoreFallback(dom, marks);
29673
29633
  }
29674
29634
  else if (!rule || rule.skip || rule.closeParent) {
29675
29635
  if (rule && rule.closeParent)
@@ -29687,45 +29647,44 @@ so this becomes the fallback color for the slot */ ''}
29687
29647
  this.needsBlock = true;
29688
29648
  }
29689
29649
  else if (!dom.firstChild) {
29690
- this.leafFallback(dom);
29650
+ this.leafFallback(dom, marks);
29691
29651
  return;
29692
29652
  }
29693
- if (rule && rule.skip)
29694
- this.addAll(dom);
29695
- else
29696
- this.withStyleRules(dom, () => this.addAll(dom));
29653
+ let innerMarks = rule && rule.skip ? marks : this.readStyles(dom, marks);
29654
+ if (innerMarks)
29655
+ this.addAll(dom, innerMarks);
29697
29656
  if (sync)
29698
29657
  this.sync(top);
29699
29658
  this.needsBlock = oldNeedsBlock;
29700
29659
  }
29701
29660
  else {
29702
- this.withStyleRules(dom, () => {
29703
- this.addElementByRule(dom, rule, rule.consuming === false ? ruleID : undefined);
29704
- });
29661
+ let innerMarks = this.readStyles(dom, marks);
29662
+ if (innerMarks)
29663
+ this.addElementByRule(dom, rule, innerMarks, rule.consuming === false ? ruleID : undefined);
29705
29664
  }
29706
29665
  }
29707
29666
  // Called for leaf DOM nodes that would otherwise be ignored
29708
- leafFallback(dom) {
29667
+ leafFallback(dom, marks) {
29709
29668
  if (dom.nodeName == "BR" && this.top.type && this.top.type.inlineContent)
29710
- this.addTextNode(dom.ownerDocument.createTextNode("\n"));
29669
+ this.addTextNode(dom.ownerDocument.createTextNode("\n"), marks);
29711
29670
  }
29712
29671
  // Called for ignored nodes
29713
- ignoreFallback(dom) {
29672
+ ignoreFallback(dom, marks) {
29714
29673
  // Ignored BR nodes should at least create an inline context
29715
29674
  if (dom.nodeName == "BR" && (!this.top.type || !this.top.type.inlineContent))
29716
- this.findPlace(this.parser.schema.text("-"));
29675
+ this.findPlace(this.parser.schema.text("-"), marks);
29717
29676
  }
29718
29677
  // Run any style parser associated with the node's styles. Either
29719
- // return an array of marks, or null to indicate some of the styles
29720
- // had a rule with `ignore` set.
29721
- readStyles(styles) {
29722
- let add = Mark$1.none, remove = Mark$1.none;
29678
+ // return an updated array of marks, or null to indicate some of the
29679
+ // styles had a rule with `ignore` set.
29680
+ readStyles(dom, marks) {
29681
+ let styles = dom.style;
29723
29682
  // Because many properties will only show up in 'normalized' form
29724
29683
  // in `style.item` (i.e. text-decoration becomes
29725
29684
  // text-decoration-line, text-decoration-color, etc), we directly
29726
29685
  // query the styles mentioned in our rules instead of iterating
29727
29686
  // over the items.
29728
- if (styles.length)
29687
+ if (styles && styles.length)
29729
29688
  for (let i = 0; i < this.parser.matchedStyles.length; i++) {
29730
29689
  let name = this.parser.matchedStyles[i], value = styles.getPropertyValue(name);
29731
29690
  if (value)
@@ -29735,52 +29694,50 @@ so this becomes the fallback color for the slot */ ''}
29735
29694
  break;
29736
29695
  if (rule.ignore)
29737
29696
  return null;
29738
- if (rule.clearMark) {
29739
- this.top.pendingMarks.concat(this.top.activeMarks).forEach(m => {
29740
- if (rule.clearMark(m))
29741
- remove = m.addToSet(remove);
29742
- });
29743
- }
29744
- else {
29745
- add = this.parser.schema.marks[rule.mark].create(rule.attrs).addToSet(add);
29746
- }
29697
+ if (rule.clearMark)
29698
+ marks = marks.filter(m => !rule.clearMark(m));
29699
+ else
29700
+ marks = marks.concat(this.parser.schema.marks[rule.mark].create(rule.attrs));
29747
29701
  if (rule.consuming === false)
29748
29702
  after = rule;
29749
29703
  else
29750
29704
  break;
29751
29705
  }
29752
29706
  }
29753
- return [add, remove];
29707
+ return marks;
29754
29708
  }
29755
29709
  // Look up a handler for the given node. If none are found, return
29756
29710
  // false. Otherwise, apply it, use its return value to drive the way
29757
29711
  // the node's content is wrapped, and return true.
29758
- addElementByRule(dom, rule, continueAfter) {
29759
- let sync, nodeType, mark;
29712
+ addElementByRule(dom, rule, marks, continueAfter) {
29713
+ let sync, nodeType;
29760
29714
  if (rule.node) {
29761
29715
  nodeType = this.parser.schema.nodes[rule.node];
29762
29716
  if (!nodeType.isLeaf) {
29763
- sync = this.enter(nodeType, rule.attrs || null, rule.preserveWhitespace);
29717
+ let inner = this.enter(nodeType, rule.attrs || null, marks, rule.preserveWhitespace);
29718
+ if (inner) {
29719
+ sync = true;
29720
+ marks = inner;
29721
+ }
29764
29722
  }
29765
- else if (!this.insertNode(nodeType.create(rule.attrs))) {
29766
- this.leafFallback(dom);
29723
+ else if (!this.insertNode(nodeType.create(rule.attrs), marks)) {
29724
+ this.leafFallback(dom, marks);
29767
29725
  }
29768
29726
  }
29769
29727
  else {
29770
29728
  let markType = this.parser.schema.marks[rule.mark];
29771
- mark = markType.create(rule.attrs);
29772
- this.addPendingMark(mark);
29729
+ marks = marks.concat(markType.create(rule.attrs));
29773
29730
  }
29774
29731
  let startIn = this.top;
29775
29732
  if (nodeType && nodeType.isLeaf) {
29776
29733
  this.findInside(dom);
29777
29734
  }
29778
29735
  else if (continueAfter) {
29779
- this.addElement(dom, continueAfter);
29736
+ this.addElement(dom, marks, continueAfter);
29780
29737
  }
29781
29738
  else if (rule.getContent) {
29782
29739
  this.findInside(dom);
29783
- rule.getContent(dom, this.parser.schema).forEach(node => this.insertNode(node));
29740
+ rule.getContent(dom, this.parser.schema).forEach(node => this.insertNode(node, marks));
29784
29741
  }
29785
29742
  else {
29786
29743
  let contentDOM = dom;
@@ -29791,28 +29748,26 @@ so this becomes the fallback color for the slot */ ''}
29791
29748
  else if (rule.contentElement)
29792
29749
  contentDOM = rule.contentElement;
29793
29750
  this.findAround(dom, contentDOM, true);
29794
- this.addAll(contentDOM);
29751
+ this.addAll(contentDOM, marks);
29795
29752
  }
29796
29753
  if (sync && this.sync(startIn))
29797
29754
  this.open--;
29798
- if (mark)
29799
- this.removePendingMark(mark, startIn);
29800
29755
  }
29801
29756
  // Add all child nodes between `startIndex` and `endIndex` (or the
29802
29757
  // whole node, if not given). If `sync` is passed, use it to
29803
29758
  // synchronize after every block element.
29804
- addAll(parent, startIndex, endIndex) {
29759
+ addAll(parent, marks, startIndex, endIndex) {
29805
29760
  let index = startIndex || 0;
29806
29761
  for (let dom = startIndex ? parent.childNodes[startIndex] : parent.firstChild, end = endIndex == null ? null : parent.childNodes[endIndex]; dom != end; dom = dom.nextSibling, ++index) {
29807
29762
  this.findAtPoint(parent, index);
29808
- this.addDOM(dom);
29763
+ this.addDOM(dom, marks);
29809
29764
  }
29810
29765
  this.findAtPoint(parent, index);
29811
29766
  }
29812
29767
  // Try to find a way to fit the given node type into the current
29813
29768
  // context. May add intermediate wrappers and/or leave non-solid
29814
29769
  // nodes that we're in.
29815
- findPlace(node) {
29770
+ findPlace(node, marks) {
29816
29771
  let route, sync;
29817
29772
  for (let depth = this.open; depth >= 0; depth--) {
29818
29773
  let cx = this.nodes[depth];
@@ -29827,53 +29782,61 @@ so this becomes the fallback color for the slot */ ''}
29827
29782
  break;
29828
29783
  }
29829
29784
  if (!route)
29830
- return false;
29785
+ return null;
29831
29786
  this.sync(sync);
29832
29787
  for (let i = 0; i < route.length; i++)
29833
- this.enterInner(route[i], null, false);
29834
- return true;
29788
+ marks = this.enterInner(route[i], null, marks, false);
29789
+ return marks;
29835
29790
  }
29836
29791
  // Try to insert the given node, adjusting the context when needed.
29837
- insertNode(node) {
29792
+ insertNode(node, marks) {
29838
29793
  if (node.isInline && this.needsBlock && !this.top.type) {
29839
29794
  let block = this.textblockFromContext();
29840
29795
  if (block)
29841
- this.enterInner(block);
29796
+ marks = this.enterInner(block, null, marks);
29842
29797
  }
29843
- if (this.findPlace(node)) {
29798
+ let innerMarks = this.findPlace(node, marks);
29799
+ if (innerMarks) {
29844
29800
  this.closeExtra();
29845
29801
  let top = this.top;
29846
- top.applyPending(node.type);
29847
29802
  if (top.match)
29848
29803
  top.match = top.match.matchType(node.type);
29849
- let marks = top.activeMarks;
29850
- for (let i = 0; i < node.marks.length; i++)
29851
- if (!top.type || top.type.allowsMarkType(node.marks[i].type))
29852
- marks = node.marks[i].addToSet(marks);
29853
- top.content.push(node.mark(marks));
29804
+ let nodeMarks = Mark$1.none;
29805
+ for (let m of innerMarks.concat(node.marks))
29806
+ if (top.type ? top.type.allowsMarkType(m.type) : markMayApply(m.type, node.type))
29807
+ nodeMarks = m.addToSet(nodeMarks);
29808
+ top.content.push(node.mark(nodeMarks));
29854
29809
  return true;
29855
29810
  }
29856
29811
  return false;
29857
29812
  }
29858
29813
  // Try to start a node of the given type, adjusting the context when
29859
29814
  // necessary.
29860
- enter(type, attrs, preserveWS) {
29861
- let ok = this.findPlace(type.create(attrs));
29862
- if (ok)
29863
- this.enterInner(type, attrs, true, preserveWS);
29864
- return ok;
29815
+ enter(type, attrs, marks, preserveWS) {
29816
+ let innerMarks = this.findPlace(type.create(attrs), marks);
29817
+ if (innerMarks)
29818
+ innerMarks = this.enterInner(type, attrs, marks, true, preserveWS);
29819
+ return innerMarks;
29865
29820
  }
29866
29821
  // Open a node of the given type
29867
- enterInner(type, attrs = null, solid = false, preserveWS) {
29822
+ enterInner(type, attrs, marks, solid = false, preserveWS) {
29868
29823
  this.closeExtra();
29869
29824
  let top = this.top;
29870
- top.applyPending(type);
29871
29825
  top.match = top.match && top.match.matchType(type);
29872
29826
  let options = wsOptionsFor(type, preserveWS, top.options);
29873
29827
  if ((top.options & OPT_OPEN_LEFT) && top.content.length == 0)
29874
29828
  options |= OPT_OPEN_LEFT;
29875
- this.nodes.push(new NodeContext(type, attrs, top.activeMarks, top.pendingMarks, solid, null, options));
29829
+ let applyMarks = Mark$1.none;
29830
+ marks = marks.filter(m => {
29831
+ if (top.type ? top.type.allowsMarkType(m.type) : markMayApply(m.type, type)) {
29832
+ applyMarks = m.addToSet(applyMarks);
29833
+ return false;
29834
+ }
29835
+ return true;
29836
+ });
29837
+ this.nodes.push(new NodeContext(type, attrs, applyMarks, solid, null, options));
29876
29838
  this.open++;
29839
+ return marks;
29877
29840
  }
29878
29841
  // Make sure all nodes above this.open are finished and added to
29879
29842
  // their parents
@@ -29987,29 +29950,6 @@ so this becomes the fallback color for the slot */ ''}
29987
29950
  return type;
29988
29951
  }
29989
29952
  }
29990
- addPendingMark(mark) {
29991
- let found = findSameMarkInSet(mark, this.top.pendingMarks);
29992
- if (found)
29993
- this.top.stashMarks.push(found);
29994
- this.top.pendingMarks = mark.addToSet(this.top.pendingMarks);
29995
- }
29996
- removePendingMark(mark, upto) {
29997
- for (let depth = this.open; depth >= 0; depth--) {
29998
- let level = this.nodes[depth];
29999
- let found = level.pendingMarks.lastIndexOf(mark);
30000
- if (found > -1) {
30001
- level.pendingMarks = mark.removeFromSet(level.pendingMarks);
30002
- }
30003
- else {
30004
- level.activeMarks = mark.removeFromSet(level.activeMarks);
30005
- let stashMark = level.popFromStashMark(mark);
30006
- if (stashMark && level.type && level.type.allowsMarkType(stashMark.type))
30007
- level.activeMarks = stashMark.addToSet(level.activeMarks);
30008
- }
30009
- if (level == upto)
30010
- break;
30011
- }
30012
- }
30013
29953
  }
30014
29954
  // Kludge to work around directly nested list nodes produced by some
30015
29955
  // tools and allowed by browsers to mean that the nested list is
@@ -30062,12 +30002,6 @@ so this becomes the fallback color for the slot */ ''}
30062
30002
  return true;
30063
30003
  }
30064
30004
  }
30065
- function findSameMarkInSet(mark, set) {
30066
- for (let i = 0; i < set.length; i++) {
30067
- if (mark.eq(set[i]))
30068
- return set[i];
30069
- }
30070
- }
30071
30005
 
30072
30006
  /**
30073
30007
  A DOM serializer knows how to convert ProseMirror nodes and
@@ -31370,7 +31304,9 @@ so this becomes the fallback color for the slot */ ''}
31370
31304
  throw new RangeError("Type given to setBlockType should be a textblock");
31371
31305
  let mapFrom = tr.steps.length;
31372
31306
  tr.doc.nodesBetween(from, to, (node, pos) => {
31373
- if (node.isTextblock && !node.hasMarkup(type, attrs) && canChangeType(tr.doc, tr.mapping.slice(mapFrom).map(pos), type)) {
31307
+ let attrsHere = typeof attrs == "function" ? attrs(node) : attrs;
31308
+ if (node.isTextblock && !node.hasMarkup(type, attrsHere) &&
31309
+ canChangeType(tr.doc, tr.mapping.slice(mapFrom).map(pos), type)) {
31374
31310
  let convertNewlines = null;
31375
31311
  if (type.schema.linebreakReplacement) {
31376
31312
  let pre = type.whitespace == "pre", supportLinebreak = !!type.contentMatch.matchType(type.schema.linebreakReplacement);
@@ -31385,7 +31321,7 @@ so this becomes the fallback color for the slot */ ''}
31385
31321
  clearIncompatible(tr, tr.mapping.slice(mapFrom).map(pos, 1), type, undefined, convertNewlines === null);
31386
31322
  let mapping = tr.mapping.slice(mapFrom);
31387
31323
  let startM = mapping.map(pos, 1), endM = mapping.map(pos + node.nodeSize, 1);
31388
- tr.step(new ReplaceAroundStep(startM, endM, startM + 1, endM - 1, new Slice(Fragment.from(type.create(attrs, null, node.marks)), 0, 0), 1, true));
31324
+ tr.step(new ReplaceAroundStep(startM, endM, startM + 1, endM - 1, new Slice(Fragment.from(type.create(attrsHere, null, node.marks)), 0, 0), 1, true));
31389
31325
  if (convertNewlines === true)
31390
31326
  replaceNewlines(tr, node, pos, mapFrom);
31391
31327
  return false;
@@ -33535,15 +33471,18 @@ so this becomes the fallback color for the slot */ ''}
33535
33471
  if (doc.caretPositionFromPoint) {
33536
33472
  try { // Firefox throws for this call in hard-to-predict circumstances (#994)
33537
33473
  let pos = doc.caretPositionFromPoint(x, y);
33474
+ // Clip the offset, because Chrome will return a text offset
33475
+ // into <input> nodes, which can't be treated as a regular DOM
33476
+ // offset
33538
33477
  if (pos)
33539
- return { node: pos.offsetNode, offset: pos.offset };
33478
+ return { node: pos.offsetNode, offset: Math.min(nodeSize(pos.offsetNode), pos.offset) };
33540
33479
  }
33541
33480
  catch (_) { }
33542
33481
  }
33543
33482
  if (doc.caretRangeFromPoint) {
33544
33483
  let range = doc.caretRangeFromPoint(x, y);
33545
33484
  if (range)
33546
- return { node: range.startContainer, offset: range.startOffset };
33485
+ return { node: range.startContainer, offset: Math.min(nodeSize(range.startContainer), range.startOffset) };
33547
33486
  }
33548
33487
  }
33549
33488
 
@@ -34055,6 +33994,8 @@ so this becomes the fallback color for the slot */ ''}
34055
33994
  return false;
34056
33995
  let offset = $head.parentOffset, atStart = !offset, atEnd = offset == $head.parent.content.size;
34057
33996
  let sel = view.domSelection();
33997
+ if (!sel)
33998
+ return $head.pos == $head.start() || $head.pos == $head.end();
34058
33999
  // If the textblock is all LTR, or the browser doesn't support
34059
34000
  // Selection.modify (Edge), fall back to a primitive approach
34060
34001
  if (!maybeRTL.test($head.parent.textContent) || !sel.modify)
@@ -35677,12 +35618,14 @@ so this becomes the fallback color for the slot */ ''}
35677
35618
  }
35678
35619
  function selectCursorWrapper(view) {
35679
35620
  let domSel = view.domSelection(), range = document.createRange();
35621
+ if (!domSel)
35622
+ return;
35680
35623
  let node = view.cursorWrapper.dom, img = node.nodeName == "IMG";
35681
35624
  if (img)
35682
- range.setEnd(node.parentNode, domIndex(node) + 1);
35625
+ range.setStart(node.parentNode, domIndex(node) + 1);
35683
35626
  else
35684
- range.setEnd(node, 0);
35685
- range.collapse(false);
35627
+ range.setStart(node, 0);
35628
+ range.collapse(true);
35686
35629
  domSel.removeAllRanges();
35687
35630
  domSel.addRange(range);
35688
35631
  // Kludge to kill 'control selection' in IE11 when selecting an
@@ -35970,6 +35913,8 @@ so this becomes the fallback color for the slot */ ''}
35970
35913
  }
35971
35914
  }
35972
35915
  let sel = view.domSelection();
35916
+ if (!sel)
35917
+ return;
35973
35918
  if (selectionCollapsed(sel)) {
35974
35919
  let range = document.createRange();
35975
35920
  range.setEnd(node, offset);
@@ -36324,6 +36269,15 @@ so this becomes the fallback color for the slot */ ''}
36324
36269
  function detachedDoc() {
36325
36270
  return _detachedDoc || (_detachedDoc = document.implementation.createHTMLDocument("title"));
36326
36271
  }
36272
+ function maybeWrapTrusted(html) {
36273
+ let trustedTypes = window.trustedTypes;
36274
+ if (!trustedTypes)
36275
+ return html;
36276
+ // With the require-trusted-types-for CSP, Chrome will block
36277
+ // innerHTML, even on a detached document. This wraps the string in
36278
+ // a way that makes the browser allow us to use its parser again.
36279
+ return trustedTypes.createPolicy("detachedDocument", { createHTML: (s) => s }).createHTML(html);
36280
+ }
36327
36281
  function readHTML(html) {
36328
36282
  let metas = /^(\s*<meta [^>]*>)*/.exec(html);
36329
36283
  if (metas)
@@ -36332,7 +36286,7 @@ so this becomes the fallback color for the slot */ ''}
36332
36286
  let firstTag = /<([a-z][^>\s]+)/i.exec(html), wrap;
36333
36287
  if (wrap = firstTag && wrapMap[firstTag[1].toLowerCase()])
36334
36288
  html = wrap.map(n => "<" + n + ">").join("") + html + wrap.map(n => "</" + n + ">").reverse().join("");
36335
- elt.innerHTML = html;
36289
+ elt.innerHTML = maybeWrapTrusted(html);
36336
36290
  if (wrap)
36337
36291
  for (let i = 0; i < wrap.length; i++)
36338
36292
  elt = elt.querySelector(wrap[i]) || elt;
@@ -36473,7 +36427,9 @@ so this becomes the fallback color for the slot */ ''}
36473
36427
  // and handling them eagerly tends to corrupt the input.
36474
36428
  if (android && chrome && event.keyCode == 13)
36475
36429
  return;
36476
- if (event.keyCode != 229)
36430
+ if (view.domObserver.selectionChanged(view.domSelectionRange()))
36431
+ view.domObserver.flush();
36432
+ else if (event.keyCode != 229)
36477
36433
  view.domObserver.forceFlush();
36478
36434
  // On iOS, if we preventDefault enter key presses, the virtual
36479
36435
  // keyboard gets confused. So the hack here is to set a flag that
@@ -36536,6 +36492,8 @@ so this becomes the fallback color for the slot */ ''}
36536
36492
  function updateSelection(view, selection, origin) {
36537
36493
  if (!view.focused)
36538
36494
  view.focus();
36495
+ if (view.state.selection.eq(selection))
36496
+ return;
36539
36497
  let tr = view.state.tr.setSelection(selection);
36540
36498
  tr.setMeta("pointer", true);
36541
36499
  view.dispatch(tr);
@@ -36789,8 +36747,8 @@ so this becomes the fallback color for the slot */ ''}
36789
36747
  editHandlers.compositionstart = editHandlers.compositionupdate = view => {
36790
36748
  if (!view.composing) {
36791
36749
  view.domObserver.flush();
36792
- let { state } = view, $pos = state.selection.$from;
36793
- if (state.selection.empty &&
36750
+ let { state } = view, $pos = state.selection.$to;
36751
+ if (state.selection instanceof TextSelection &&
36794
36752
  (state.storedMarks ||
36795
36753
  (!$pos.textOffset && $pos.parentOffset && $pos.nodeBefore.marks.some(m => m.type.spec.inclusive === false)))) {
36796
36754
  // Need to wrap the cursor in mark nodes different from the ones in the DOM context
@@ -36799,7 +36757,7 @@ so this becomes the fallback color for the slot */ ''}
36799
36757
  view.markCursor = null;
36800
36758
  }
36801
36759
  else {
36802
- endComposition(view);
36760
+ endComposition(view, !state.selection.empty);
36803
36761
  // In firefox, if the cursor is after but outside a marked node,
36804
36762
  // the inserted text won't inherit the marks. So this moves it
36805
36763
  // inside if necessary.
@@ -36810,7 +36768,9 @@ so this becomes the fallback color for the slot */ ''}
36810
36768
  if (!before)
36811
36769
  break;
36812
36770
  if (before.nodeType == 3) {
36813
- view.domSelection().collapse(before, before.nodeValue.length);
36771
+ let sel = view.domSelection();
36772
+ if (sel)
36773
+ sel.collapse(before, before.nodeValue.length);
36814
36774
  break;
36815
36775
  }
36816
36776
  else {
@@ -36878,15 +36838,17 @@ so this becomes the fallback color for the slot */ ''}
36878
36838
  /**
36879
36839
  @internal
36880
36840
  */
36881
- function endComposition(view, forceUpdate = false) {
36841
+ function endComposition(view, restarting = false) {
36882
36842
  if (android && view.domObserver.flushingSoon >= 0)
36883
36843
  return;
36884
36844
  view.domObserver.forceFlush();
36885
36845
  clearComposition(view);
36886
- if (forceUpdate || view.docView && view.docView.dirty) {
36846
+ if (restarting || view.docView && view.docView.dirty) {
36887
36847
  let sel = selectionFromDOM(view);
36888
36848
  if (sel && !sel.eq(view.state.selection))
36889
36849
  view.dispatch(view.state.tr.setSelection(sel));
36850
+ else if ((view.markCursor || restarting) && !view.state.selection.empty)
36851
+ view.dispatch(view.state.tr.deleteSelection());
36890
36852
  else
36891
36853
  view.updateState(view.state);
36892
36854
  return true;
@@ -37543,6 +37505,7 @@ so this becomes the fallback color for the slot */ ''}
37543
37505
  }
37544
37506
  return result;
37545
37507
  }
37508
+ forEachSet(f) { f(this); }
37546
37509
  }
37547
37510
  /**
37548
37511
  The empty set of decorations.
@@ -37618,6 +37581,10 @@ so this becomes the fallback color for the slot */ ''}
37618
37581
  members.reduce((r, m) => r.concat(m instanceof DecorationSet ? m : m.members), []));
37619
37582
  }
37620
37583
  }
37584
+ forEachSet(f) {
37585
+ for (let i = 0; i < this.members.length; i++)
37586
+ this.members[i].forEachSet(f);
37587
+ }
37621
37588
  }
37622
37589
  function mapChildren(oldChildren, newLocal, mapping, node, offset, oldOffset, options) {
37623
37590
  let children = oldChildren.slice();
@@ -37984,6 +37951,9 @@ so this becomes the fallback color for the slot */ ''}
37984
37951
  this.queue.push(mut);
37985
37952
  return this.queue;
37986
37953
  }
37954
+ selectionChanged(sel) {
37955
+ return !this.suppressingSelectionUpdates && !this.currentSelection.eq(sel) && hasFocusAndSelection(this.view) && !this.ignoreSelectionChange(sel);
37956
+ }
37987
37957
  flush() {
37988
37958
  let { view } = this;
37989
37959
  if (!view.docView || this.flushingSoon > -1)
@@ -37991,8 +37961,7 @@ so this becomes the fallback color for the slot */ ''}
37991
37961
  let mutations = this.pendingRecords();
37992
37962
  if (mutations.length)
37993
37963
  this.queue = [];
37994
- let sel = view.domSelectionRange();
37995
- let newSel = !this.suppressingSelectionUpdates && !this.currentSelection.eq(sel) && hasFocusAndSelection(view) && !this.ignoreSelectionChange(sel);
37964
+ let sel = view.domSelectionRange(), newSel = this.selectionChanged(sel);
37996
37965
  let from = -1, to = -1, typeOver = false, added = [];
37997
37966
  if (view.editable) {
37998
37967
  for (let i = 0; i < mutations.length; i++) {
@@ -38280,6 +38249,8 @@ so this becomes the fallback color for the slot */ ''}
38280
38249
  }
38281
38250
  view.input.lastKeyCode = null;
38282
38251
  let change = findDiff(compare.content, parse.doc.content, parse.from, preferredPos, preferredSide);
38252
+ if (change)
38253
+ view.input.domChangeCount++;
38283
38254
  if ((ios && view.input.lastIOSEnter > Date.now() - 225 || android) &&
38284
38255
  addedNodes.some(n => n.nodeType == 1 && !isInline.test(n.nodeName)) &&
38285
38256
  (!change || change.endA >= change.endB) &&
@@ -38305,7 +38276,6 @@ so this becomes the fallback color for the slot */ ''}
38305
38276
  return;
38306
38277
  }
38307
38278
  }
38308
- view.input.domChangeCount++;
38309
38279
  // Handle the case where overwriting a selection by typing matches
38310
38280
  // the start or end of the selected content, creating a change
38311
38281
  // that's smaller than what was actually overwritten.
@@ -39028,6 +38998,8 @@ so this becomes the fallback color for the slot */ ''}
39028
38998
  */
39029
38999
  domSelectionRange() {
39030
39000
  let sel = this.domSelection();
39001
+ if (!sel)
39002
+ return { focusNode: null, focusOffset: 0, anchorNode: null, anchorOffset: 0 };
39031
39003
  return safari && this.root.nodeType === 11 &&
39032
39004
  deepActiveElement(this.dom.ownerDocument) == this.dom && safariShadowSelectionRange(this, sel) || sel;
39033
39005
  }
@@ -39065,7 +39037,7 @@ so this becomes the fallback color for the slot */ ''}
39065
39037
  dom.className = "ProseMirror-separator";
39066
39038
  dom.setAttribute("mark-placeholder", "true");
39067
39039
  dom.setAttribute("alt", "");
39068
- view.cursorWrapper = { dom, deco: Decoration.widget(view.state.selection.head, dom, { raw: true, marks: view.markCursor }) };
39040
+ view.cursorWrapper = { dom, deco: Decoration.widget(view.state.selection.from, dom, { raw: true, marks: view.markCursor }) };
39069
39041
  }
39070
39042
  else {
39071
39043
  view.cursorWrapper = null;
@@ -41000,7 +40972,7 @@ so this becomes the fallback color for the slot */ ''}
41000
40972
 
41001
40973
  function findDuplicates(items) {
41002
40974
  const filtered = items.filter((el, index) => items.indexOf(el) !== index);
41003
- return [...new Set(filtered)];
40975
+ return Array.from(new Set(filtered));
41004
40976
  }
41005
40977
 
41006
40978
  class ExtensionManager {
@@ -41802,7 +41774,11 @@ so this becomes the fallback color for the slot */ ''}
41802
41774
  if (isArrayContent) {
41803
41775
  return Fragment.fromArray(content.map(item => schema.nodeFromJSON(item)));
41804
41776
  }
41805
- return schema.nodeFromJSON(content);
41777
+ const node = schema.nodeFromJSON(content);
41778
+ if (options.errorOnInvalidContent) {
41779
+ node.check();
41780
+ }
41781
+ return node;
41806
41782
  }
41807
41783
  catch (error) {
41808
41784
  if (options.errorOnInvalidContent) {
@@ -42563,7 +42539,7 @@ so this becomes the fallback color for the slot */ ''}
42563
42539
  .resolve(from)
42564
42540
  .marks()
42565
42541
  .forEach(mark => {
42566
- const $pos = doc.resolve(from - 1);
42542
+ const $pos = doc.resolve(from);
42567
42543
  const range = getMarkRange($pos, mark.type);
42568
42544
  if (!range) {
42569
42545
  return;
@@ -42705,31 +42681,40 @@ so this becomes the fallback color for the slot */ ''}
42705
42681
  }
42706
42682
 
42707
42683
  /**
42708
- * Returns true if the given node is empty.
42709
- * When `checkChildren` is true (default), it will also check if all children are empty.
42684
+ * Returns true if the given prosemirror node is empty.
42710
42685
  */
42711
- function isNodeEmpty(node, { checkChildren } = { checkChildren: true }) {
42686
+ function isNodeEmpty(node, { checkChildren = true, ignoreWhitespace = false, } = {}) {
42687
+ var _a;
42688
+ if (ignoreWhitespace) {
42689
+ if (node.type.name === 'hardBreak') {
42690
+ // Hard breaks are considered empty
42691
+ return true;
42692
+ }
42693
+ if (node.isText) {
42694
+ return /^\s*$/m.test((_a = node.text) !== null && _a !== void 0 ? _a : '');
42695
+ }
42696
+ }
42712
42697
  if (node.isText) {
42713
42698
  return !node.text;
42714
42699
  }
42700
+ if (node.isAtom || node.isLeaf) {
42701
+ return false;
42702
+ }
42715
42703
  if (node.content.childCount === 0) {
42716
42704
  return true;
42717
42705
  }
42718
- if (node.isLeaf) {
42719
- return false;
42720
- }
42721
42706
  if (checkChildren) {
42722
- let hasSameContent = true;
42707
+ let isContentEmpty = true;
42723
42708
  node.content.forEach(childNode => {
42724
- if (hasSameContent === false) {
42709
+ if (isContentEmpty === false) {
42725
42710
  // Exit early for perf
42726
42711
  return;
42727
42712
  }
42728
- if (!isNodeEmpty(childNode)) {
42729
- hasSameContent = false;
42713
+ if (!isNodeEmpty(childNode, { ignoreWhitespace, checkChildren })) {
42714
+ isContentEmpty = false;
42730
42715
  }
42731
42716
  });
42732
- return hasSameContent;
42717
+ return isContentEmpty;
42733
42718
  }
42734
42719
  return false;
42735
42720
  }
@@ -42942,7 +42927,7 @@ so this becomes the fallback color for the slot */ ''}
42942
42927
  return can;
42943
42928
  };
42944
42929
 
42945
- const splitListItem = typeOrName => ({ tr, state, dispatch, editor, }) => {
42930
+ const splitListItem = (typeOrName, overrideAttrs = {}) => ({ tr, state, dispatch, editor, }) => {
42946
42931
  var _a;
42947
42932
  const type = getNodeType(typeOrName, state.schema);
42948
42933
  const { $from, $to } = state.selection;
@@ -42978,7 +42963,10 @@ so this becomes the fallback color for the slot */ ''}
42978
42963
  // eslint-disable-next-line
42979
42964
  const depthAfter = $from.indexAfter(-1) < $from.node(-2).childCount ? 1 : $from.indexAfter(-2) < $from.node(-3).childCount ? 2 : 3;
42980
42965
  // Add a second list item with an empty default start node
42981
- const newNextTypeAttributes = getSplittedAttributes(extensionAttributes, $from.node().type.name, $from.node().attrs);
42966
+ const newNextTypeAttributes = {
42967
+ ...getSplittedAttributes(extensionAttributes, $from.node().type.name, $from.node().attrs),
42968
+ ...overrideAttrs,
42969
+ };
42982
42970
  const nextType = ((_a = type.contentMatch.defaultType) === null || _a === void 0 ? void 0 : _a.createAndFill(newNextTypeAttributes)) || undefined;
42983
42971
  wrap = wrap.append(Fragment.from(type.createAndFill(null, nextType) || undefined));
42984
42972
  const start = $from.before($from.depth - (depthBefore - 1));
@@ -43000,8 +42988,14 @@ so this becomes the fallback color for the slot */ ''}
43000
42988
  return true;
43001
42989
  }
43002
42990
  const nextType = $to.pos === $from.end() ? grandParent.contentMatchAt(0).defaultType : null;
43003
- const newTypeAttributes = getSplittedAttributes(extensionAttributes, grandParent.type.name, grandParent.attrs);
43004
- const newNextTypeAttributes = getSplittedAttributes(extensionAttributes, $from.node().type.name, $from.node().attrs);
42991
+ const newTypeAttributes = {
42992
+ ...getSplittedAttributes(extensionAttributes, grandParent.type.name, grandParent.attrs),
42993
+ ...overrideAttrs,
42994
+ };
42995
+ const newNextTypeAttributes = {
42996
+ ...getSplittedAttributes(extensionAttributes, $from.node().type.name, $from.node().attrs),
42997
+ ...overrideAttrs,
42998
+ };
43005
42999
  tr.delete($from.pos, $to.pos);
43006
43000
  const types = nextType
43007
43001
  ? [
@@ -43727,8 +43721,8 @@ img.ProseMirror-separator {
43727
43721
  display: inline !important;
43728
43722
  border: none !important;
43729
43723
  margin: 0 !important;
43730
- width: 1px !important;
43731
- height: 1px !important;
43724
+ width: 0 !important;
43725
+ height: 0 !important;
43732
43726
  }
43733
43727
 
43734
43728
  .ProseMirror-gapcursor {
@@ -43793,6 +43787,10 @@ img.ProseMirror-separator {
43793
43787
  constructor(options = {}) {
43794
43788
  super();
43795
43789
  this.isFocused = false;
43790
+ /**
43791
+ * The editor is considered initialized after the `create` event has been emitted.
43792
+ */
43793
+ this.isInitialized = false;
43796
43794
  this.extensionStorage = {};
43797
43795
  this.options = {
43798
43796
  element: document.createElement('div'),
@@ -43843,6 +43841,7 @@ img.ProseMirror-separator {
43843
43841
  }
43844
43842
  this.commands.focus(this.options.autofocus);
43845
43843
  this.emit('create', { editor: this });
43844
+ this.isInitialized = true;
43846
43845
  }, 0);
43847
43846
  }
43848
43847
  /**
@@ -55328,6 +55327,7 @@ img.ProseMirror-separator {
55328
55327
  */
55329
55328
  const TextStyle$1 = Mark.create({
55330
55329
  name: 'textStyle',
55330
+ priority: 101,
55331
55331
  addOptions() {
55332
55332
  return {
55333
55333
  HTMLAttributes: {},
@@ -58112,10 +58112,20 @@ img.ProseMirror-separator {
58112
58112
  }
58113
58113
  // From DOMPurify
58114
58114
  // https://github.com/cure53/DOMPurify/blob/main/src/regexp.js
58115
- const ATTR_WHITESPACE = /[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g; // eslint-disable-line no-control-regex
58116
- const IS_ALLOWED_URI = /^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i; // eslint-disable-line no-useless-escape
58117
- function isAllowedUri(uri) {
58118
- return !uri || uri.replace(ATTR_WHITESPACE, '').match(IS_ALLOWED_URI);
58115
+ // eslint-disable-next-line no-control-regex
58116
+ const ATTR_WHITESPACE = /[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g;
58117
+ function isAllowedUri(uri, protocols) {
58118
+ const allowedProtocols = ['http', 'https', 'ftp', 'ftps', 'mailto', 'tel', 'callto', 'sms', 'cid', 'xmpp'];
58119
+ if (protocols) {
58120
+ protocols.forEach(protocol => {
58121
+ const nextProtocol = (typeof protocol === 'string' ? protocol : protocol.scheme);
58122
+ if (nextProtocol) {
58123
+ allowedProtocols.push(nextProtocol);
58124
+ }
58125
+ });
58126
+ }
58127
+ // eslint-disable-next-line no-useless-escape
58128
+ return !uri || uri.replace(ATTR_WHITESPACE, '').match(new RegExp(`^(?:(?:${allowedProtocols.join('|')}):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))`, 'i'));
58119
58129
  }
58120
58130
  /**
58121
58131
  * This extension allows you to create links.
@@ -58160,6 +58170,9 @@ img.ProseMirror-separator {
58160
58170
  return {
58161
58171
  href: {
58162
58172
  default: null,
58173
+ parseHTML(element) {
58174
+ return element.getAttribute('href');
58175
+ },
58163
58176
  },
58164
58177
  target: {
58165
58178
  default: this.options.HTMLAttributes.target,
@@ -58178,16 +58191,16 @@ img.ProseMirror-separator {
58178
58191
  getAttrs: dom => {
58179
58192
  const href = dom.getAttribute('href');
58180
58193
  // prevent XSS attacks
58181
- if (!href || !isAllowedUri(href)) {
58194
+ if (!href || !isAllowedUri(href, this.options.protocols)) {
58182
58195
  return false;
58183
58196
  }
58184
- return { href };
58197
+ return null;
58185
58198
  },
58186
58199
  }];
58187
58200
  },
58188
58201
  renderHTML({ HTMLAttributes }) {
58189
58202
  // prevent XSS attacks
58190
- if (!isAllowedUri(HTMLAttributes.href)) {
58203
+ if (!isAllowedUri(HTMLAttributes.href, this.options.protocols)) {
58191
58204
  // strip out the href
58192
58205
  return ['a', mergeAttributes(this.options.HTMLAttributes, { ...HTMLAttributes, href: '' }), 0];
58193
58206
  }
@@ -58370,9 +58383,9 @@ img.ProseMirror-separator {
58370
58383
  const started = !prev.active && next.active;
58371
58384
  const stopped = prev.active && !next.active;
58372
58385
  const changed = !started && !stopped && prev.query !== next.query;
58373
- const handleStart = started;
58386
+ const handleStart = started || (moved && changed);
58374
58387
  const handleChange = changed || moved;
58375
- const handleExit = stopped;
58388
+ const handleExit = stopped || (moved && changed);
58376
58389
  // Cancel when suggestion isn't active
58377
58390
  if (!handleStart && !handleChange && !handleExit) {
58378
58391
  return;
@@ -58746,6 +58759,7 @@ img.ProseMirror-separator {
58746
58759
  */
58747
58760
  const TextStyle = Mark.create({
58748
58761
  name: 'textStyle',
58762
+ priority: 101,
58749
58763
  addOptions() {
58750
58764
  return {
58751
58765
  HTMLAttributes: {},
@@ -58816,6 +58830,10 @@ img.ProseMirror-separator {
58816
58830
  : 1;
58817
58831
  },
58818
58832
  },
58833
+ type: {
58834
+ default: undefined,
58835
+ parseHTML: element => element.getAttribute('type'),
58836
+ },
58819
58837
  };
58820
58838
  },
58821
58839
  parseHTML() {
@@ -62053,7 +62071,7 @@ img.ProseMirror-separator {
62053
62071
  ...columnDef
62054
62072
  };
62055
62073
  const accessorKey = resolvedColumnDef.accessorKey;
62056
- let id = (_ref = (_resolvedColumnDef$id = resolvedColumnDef.id) != null ? _resolvedColumnDef$id : accessorKey ? accessorKey.replace('.', '_') : undefined) != null ? _ref : typeof resolvedColumnDef.header === 'string' ? resolvedColumnDef.header : undefined;
62074
+ let id = (_ref = (_resolvedColumnDef$id = resolvedColumnDef.id) != null ? _resolvedColumnDef$id : accessorKey ? typeof String.prototype.replaceAll === 'function' ? accessorKey.replaceAll('.', '_') : accessorKey.replace(/\./g, '_') : undefined) != null ? _ref : typeof resolvedColumnDef.header === 'string' ? resolvedColumnDef.header : undefined;
62057
62075
  let accessorFn;
62058
62076
  if (resolvedColumnDef.accessorFn) {
62059
62077
  accessorFn = resolvedColumnDef.accessorFn;
@@ -62462,8 +62480,8 @@ img.ProseMirror-separator {
62462
62480
  };
62463
62481
 
62464
62482
  const includesString = (row, columnId, filterValue) => {
62465
- var _row$getValue;
62466
- const search = filterValue.toLowerCase();
62483
+ var _filterValue$toString, _row$getValue;
62484
+ const search = filterValue == null || (_filterValue$toString = filterValue.toString()) == null ? void 0 : _filterValue$toString.toLowerCase();
62467
62485
  return Boolean((_row$getValue = row.getValue(columnId)) == null || (_row$getValue = _row$getValue.toString()) == null || (_row$getValue = _row$getValue.toLowerCase()) == null ? void 0 : _row$getValue.includes(search));
62468
62486
  };
62469
62487
  includesString.autoRemove = val => testFalsey(val);
@@ -66011,7 +66029,7 @@ focus outline in that case.
66011
66029
  position: absolute;
66012
66030
  }
66013
66031
 
66014
- :host([selectable]:not([selected]):hover)::before {
66032
+ :host([selectable]:not([selected])[allow-hover]:hover)::before {
66015
66033
  background-color: ${fillHoverColor};
66016
66034
  }
66017
66035
 
@@ -66019,7 +66037,7 @@ focus outline in that case.
66019
66037
  background-color: ${fillSelectedColor};
66020
66038
  }
66021
66039
 
66022
- :host([selected]:hover)::before {
66040
+ :host([selected][allow-hover]:hover)::before {
66023
66041
  background-color: ${fillHoverSelectedColor};
66024
66042
  }
66025
66043
 
@@ -66134,7 +66152,7 @@ focus outline in that case.
66134
66152
  height: ${controlHeight};
66135
66153
  }
66136
66154
 
66137
- :host(:hover) nimble-table-cell {
66155
+ :host([allow-hover]:hover) nimble-table-cell {
66138
66156
  --ni-private-table-cell-action-menu-display: block;
66139
66157
  }
66140
66158
 
@@ -66146,7 +66164,7 @@ focus outline in that case.
66146
66164
  --ni-private-table-cell-action-menu-display: block;
66147
66165
  }
66148
66166
  `.withBehaviors(themeBehavior(Theme.color, css `
66149
- :host([selectable]:not([selected]):hover)::before {
66167
+ :host([selectable]:not([selected])[allow-hover]:hover)::before {
66150
66168
  background-color: ${hexToRgbaCssColor(White, 0.05)};
66151
66169
  }
66152
66170
 
@@ -66154,7 +66172,7 @@ focus outline in that case.
66154
66172
  background-color: ${hexToRgbaCssColor(White, 0.25)};
66155
66173
  }
66156
66174
 
66157
- :host([selected]:hover)::before {
66175
+ :host([selected][allow-hover]:hover)::before {
66158
66176
  background-color: ${hexToRgbaCssColor(White, 0.2)};
66159
66177
  }
66160
66178
  `));
@@ -66438,6 +66456,10 @@ focus outline in that case.
66438
66456
  * @internal
66439
66457
  */
66440
66458
  this.animationClass = '';
66459
+ /**
66460
+ * @internal
66461
+ */
66462
+ this.allowHover = false;
66441
66463
  // Programmatically updating the selection state of a checkbox fires the 'change' event.
66442
66464
  // Therefore, selection change events that occur due to programmatically updating
66443
66465
  // the selection checkbox 'checked' value should be ingored.
@@ -66678,6 +66700,9 @@ focus outline in that case.
66678
66700
  __decorate$1([
66679
66701
  observable
66680
66702
  ], TableRow.prototype, "animationClass", void 0);
66703
+ __decorate$1([
66704
+ attr({ attribute: 'allow-hover', mode: 'boolean' })
66705
+ ], TableRow.prototype, "allowHover", void 0);
66681
66706
  __decorate$1([
66682
66707
  volatile
66683
66708
  ], TableRow.prototype, "isTopLevelParentRow", null);
@@ -66733,7 +66758,7 @@ focus outline in that case.
66733
66758
  position: absolute;
66734
66759
  }
66735
66760
 
66736
- :host(:hover)::before {
66761
+ :host([allow-hover]:hover)::before {
66737
66762
  background-color: ${fillHoverColor};
66738
66763
  }
66739
66764
 
@@ -66779,11 +66804,11 @@ focus outline in that case.
66779
66804
  padding-left: 0px;
66780
66805
  }
66781
66806
  `.withBehaviors(themeBehavior(Theme.color, css `
66782
- :host(:hover)::before {
66807
+ :host([allow-hover]:hover)::before {
66783
66808
  background-color: ${hexToRgbaCssColor(White, 0.05)};
66784
66809
  }
66785
66810
  `), themeBehavior(Theme.dark, css `
66786
- :host(:hover)::before {
66811
+ :host([allow-hover]:hover)::before {
66787
66812
  background-color: ${hexToRgbaCssColor(White, 0.1)};
66788
66813
  }
66789
66814
  `));
@@ -66847,6 +66872,10 @@ focus outline in that case.
66847
66872
  * @internal
66848
66873
  */
66849
66874
  this.animationClass = '';
66875
+ /**
66876
+ * @internal
66877
+ */
66878
+ this.allowHover = false;
66850
66879
  // Programmatically updating the selection state of a checkbox fires the 'change' event.
66851
66880
  // Therefore, selection change events that occur due to programmatically updating
66852
66881
  // the selection checkbox 'checked' value should be ingored.
@@ -66939,6 +66968,9 @@ focus outline in that case.
66939
66968
  __decorate$1([
66940
66969
  observable
66941
66970
  ], TableGroupRow.prototype, "animationClass", void 0);
66971
+ __decorate$1([
66972
+ attr({ attribute: 'allow-hover', mode: 'boolean' })
66973
+ ], TableGroupRow.prototype, "allowHover", void 0);
66942
66974
  const nimbleTableGroupRow = TableGroupRow.compose({
66943
66975
  baseName: 'table-group-row',
66944
66976
  template: template$h,
@@ -67071,6 +67103,7 @@ focus outline in that case.
67071
67103
  ?selectable="${(_, c) => c.parent.selectionMode === TableRowSelectionMode.multiple}"
67072
67104
  selection-state="${(x, c) => c.parent.tableData[x.index]?.selectionState}"
67073
67105
  :resolvedRowIndex="${x => x.index}"
67106
+ ?allow-hover="${(_, c) => !c.parent.virtualizer.isScrolling}"
67074
67107
  @focusin="${(_, c) => c.parent.onRowFocusIn(c.event)}"
67075
67108
  @blur="${(_, c) => c.parent.onRowBlur(c.event)}"
67076
67109
  @group-selection-toggle="${(x, c) => c.parent.onRowSelectionToggle(x.index, c.event)}"
@@ -67096,6 +67129,7 @@ focus outline in that case.
67096
67129
  ?row-operation-grid-cell-hidden="${(_, c) => !c.parent.showRowOperationColumn}"
67097
67130
  ?loading="${(x, c) => c.parent.tableData[x.index]?.isLoadingChildren}"
67098
67131
  :resolvedRowIndex="${x => x.index}"
67132
+ ?allow-hover="${(_, c) => !c.parent.virtualizer.isScrolling}"
67099
67133
  @click="${(x, c) => c.parent.onRowClick(x.index, c.event)}"
67100
67134
  @focusin="${(_, c) => c.parent.onRowFocusIn(c.event)}"
67101
67135
  @blur="${(_, c) => c.parent.onRowBlur(c.event)}"
@@ -67247,7 +67281,8 @@ focus outline in that case.
67247
67281
  instance.options.isScrollingResetDelay
67248
67282
  );
67249
67283
  const createHandler = (isScrolling) => () => {
67250
- offset = element[instance.options.horizontal ? "scrollLeft" : "scrollTop"];
67284
+ const { horizontal, isRtl } = instance.options;
67285
+ offset = horizontal ? element["scrollLeft"] * (isRtl && -1 || 1) : element["scrollTop"];
67251
67286
  fallback();
67252
67287
  cb(offset, isScrolling);
67253
67288
  };
@@ -67358,20 +67393,36 @@ focus outline in that case.
67358
67393
  lanes: 1,
67359
67394
  isScrollingResetDelay: 150,
67360
67395
  enabled: true,
67396
+ isRtl: false,
67361
67397
  ...opts2
67362
67398
  };
67363
67399
  };
67364
- this.notify = (force, sync) => {
67400
+ this.notify = (sync) => {
67365
67401
  var _a, _b;
67366
- const { startIndex, endIndex } = this.range ?? {
67367
- startIndex: void 0,
67368
- endIndex: void 0
67369
- };
67370
- const range = this.calculateRange();
67371
- if (force || startIndex !== (range == null ? void 0 : range.startIndex) || endIndex !== (range == null ? void 0 : range.endIndex)) {
67372
- (_b = (_a = this.options).onChange) == null ? void 0 : _b.call(_a, this, sync);
67373
- }
67402
+ (_b = (_a = this.options).onChange) == null ? void 0 : _b.call(_a, this, sync);
67374
67403
  };
67404
+ this.maybeNotify = memo(
67405
+ () => {
67406
+ this.calculateRange();
67407
+ return [
67408
+ this.isScrolling,
67409
+ this.range ? this.range.startIndex : null,
67410
+ this.range ? this.range.endIndex : null
67411
+ ];
67412
+ },
67413
+ (isScrolling) => {
67414
+ this.notify(isScrolling);
67415
+ },
67416
+ {
67417
+ key: "maybeNotify",
67418
+ debug: () => this.options.debug,
67419
+ initialDeps: [
67420
+ this.isScrolling,
67421
+ this.range ? this.range.startIndex : null,
67422
+ this.range ? this.range.endIndex : null
67423
+ ]
67424
+ }
67425
+ );
67375
67426
  this.cleanup = () => {
67376
67427
  this.unsubs.filter(Boolean).forEach((d) => d());
67377
67428
  this.unsubs = [];
@@ -67391,7 +67442,7 @@ focus outline in that case.
67391
67442
  if (this.scrollElement !== scrollElement) {
67392
67443
  this.cleanup();
67393
67444
  if (!scrollElement) {
67394
- this.notify(false, false);
67445
+ this.maybeNotify();
67395
67446
  return;
67396
67447
  }
67397
67448
  this.scrollElement = scrollElement;
@@ -67407,7 +67458,7 @@ focus outline in that case.
67407
67458
  this.unsubs.push(
67408
67459
  this.options.observeElementRect(this, (rect) => {
67409
67460
  this.scrollRect = rect;
67410
- this.notify(false, false);
67461
+ this.maybeNotify();
67411
67462
  })
67412
67463
  );
67413
67464
  this.unsubs.push(
@@ -67415,9 +67466,8 @@ focus outline in that case.
67415
67466
  this.scrollAdjustments = 0;
67416
67467
  this.scrollDirection = isScrolling ? this.getScrollOffset() < offset ? "forward" : "backward" : null;
67417
67468
  this.scrollOffset = offset;
67418
- const prevIsScrolling = this.isScrolling;
67419
67469
  this.isScrolling = isScrolling;
67420
- this.notify(prevIsScrolling !== isScrolling, isScrolling);
67470
+ this.maybeNotify();
67421
67471
  })
67422
67472
  );
67423
67473
  }
@@ -67490,7 +67540,6 @@ focus outline in that case.
67490
67540
  this.getMeasurements = memo(
67491
67541
  () => [this.getMeasurementOptions(), this.itemSizeCache],
67492
67542
  ({ count, paddingStart, scrollMargin, getItemKey, enabled }, itemSizeCache) => {
67493
- var _a;
67494
67543
  if (!enabled) {
67495
67544
  this.measurementsCache = [];
67496
67545
  this.itemSizeCache.clear();
@@ -67506,33 +67555,6 @@ focus outline in that case.
67506
67555
  this.pendingMeasuredCacheIndexes = [];
67507
67556
  const measurements = this.measurementsCache.slice(0, min);
67508
67557
  for (let i = min; i < count; i++) {
67509
- let measureElement2 = (_a = this.measurementsCache[i]) == null ? void 0 : _a.measureElement;
67510
- if (!measureElement2) {
67511
- measureElement2 = (node) => {
67512
- const key2 = getItemKey(i);
67513
- const prevNode = this.elementsCache.get(key2);
67514
- if (!node) {
67515
- if (prevNode) {
67516
- this.observer.unobserve(prevNode);
67517
- this.elementsCache.delete(key2);
67518
- }
67519
- return;
67520
- }
67521
- if (prevNode !== node) {
67522
- if (prevNode) {
67523
- this.observer.unobserve(prevNode);
67524
- }
67525
- this.observer.observe(node);
67526
- this.elementsCache.set(key2, node);
67527
- }
67528
- if (node.isConnected) {
67529
- this.resizeItem(
67530
- i,
67531
- this.options.measureElement(node, void 0, this)
67532
- );
67533
- }
67534
- };
67535
- }
67536
67558
  const key = getItemKey(i);
67537
67559
  const furthestMeasurement = this.options.lanes === 1 ? measurements[i - 1] : this.getFurthestMeasurement(measurements, i);
67538
67560
  const start = furthestMeasurement ? furthestMeasurement.end + this.options.gap : paddingStart + scrollMargin;
@@ -67546,8 +67568,7 @@ focus outline in that case.
67546
67568
  size,
67547
67569
  end,
67548
67570
  key,
67549
- lane,
67550
- measureElement: measureElement2
67571
+ lane
67551
67572
  };
67552
67573
  }
67553
67574
  this.measurementsCache = measurements;
@@ -67604,29 +67625,26 @@ focus outline in that case.
67604
67625
  return parseInt(indexStr, 10);
67605
67626
  };
67606
67627
  this._measureElement = (node, entry) => {
67607
- const i = this.indexFromElement(node);
67608
- const item = this.getMeasurements()[i];
67609
- if (!item || !node.isConnected) {
67610
- this.elementsCache.forEach((cached, key) => {
67611
- if (cached === node) {
67612
- this.observer.unobserve(node);
67613
- this.elementsCache.delete(key);
67614
- }
67615
- });
67628
+ const index = this.indexFromElement(node);
67629
+ const item = this.measurementsCache[index];
67630
+ if (!item) {
67616
67631
  return;
67617
67632
  }
67618
- const prevNode = this.elementsCache.get(item.key);
67633
+ const key = item.key;
67634
+ const prevNode = this.elementsCache.get(key);
67619
67635
  if (prevNode !== node) {
67620
67636
  if (prevNode) {
67621
67637
  this.observer.unobserve(prevNode);
67622
67638
  }
67623
67639
  this.observer.observe(node);
67624
- this.elementsCache.set(item.key, node);
67640
+ this.elementsCache.set(key, node);
67641
+ }
67642
+ if (node.isConnected) {
67643
+ this.resizeItem(index, this.options.measureElement(node, entry, this));
67625
67644
  }
67626
- this.resizeItem(i, this.options.measureElement(node, entry, this));
67627
67645
  };
67628
67646
  this.resizeItem = (index, size) => {
67629
- const item = this.getMeasurements()[index];
67647
+ const item = this.measurementsCache[index];
67630
67648
  if (!item) {
67631
67649
  return;
67632
67650
  }
@@ -67644,11 +67662,17 @@ focus outline in that case.
67644
67662
  }
67645
67663
  this.pendingMeasuredCacheIndexes.push(item.index);
67646
67664
  this.itemSizeCache = new Map(this.itemSizeCache.set(item.key, size));
67647
- this.notify(true, false);
67665
+ this.notify(false);
67648
67666
  }
67649
67667
  };
67650
67668
  this.measureElement = (node) => {
67651
67669
  if (!node) {
67670
+ this.elementsCache.forEach((cached, key) => {
67671
+ if (!cached.isConnected) {
67672
+ this.observer.unobserve(cached);
67673
+ this.elementsCache.delete(key);
67674
+ }
67675
+ });
67652
67676
  return;
67653
67677
  }
67654
67678
  this._measureElement(node, void 0);
@@ -67665,7 +67689,7 @@ focus outline in that case.
67665
67689
  return virtualItems;
67666
67690
  },
67667
67691
  {
67668
- key: "getIndexes",
67692
+ key: "getVirtualItems",
67669
67693
  debug: () => this.options.debug
67670
67694
  }
67671
67695
  );
@@ -67709,7 +67733,7 @@ focus outline in that case.
67709
67733
  };
67710
67734
  this.getOffsetForIndex = (index, align = "auto") => {
67711
67735
  index = Math.max(0, Math.min(index, this.options.count - 1));
67712
- const item = this.getMeasurements()[index];
67736
+ const item = this.measurementsCache[index];
67713
67737
  if (!item) {
67714
67738
  return void 0;
67715
67739
  }
@@ -67809,9 +67833,8 @@ focus outline in that case.
67809
67833
  this.options.scrollToFn(offset, { behavior, adjustments }, this);
67810
67834
  };
67811
67835
  this.measure = () => {
67812
- var _a, _b;
67813
67836
  this.itemSizeCache = /* @__PURE__ */ new Map();
67814
- (_b = (_a = this.options).onChange) == null ? void 0 : _b.call(_a, this, false);
67837
+ this.notify(false);
67815
67838
  };
67816
67839
  this.setOptions(opts);
67817
67840
  }
@@ -67865,9 +67888,11 @@ focus outline in that case.
67865
67888
  constructor(table, tanStackTable) {
67866
67889
  this.visibleItems = [];
67867
67890
  this.scrollHeight = 0;
67891
+ this.isScrolling = false;
67868
67892
  this.headerContainerMarginRight = 0;
67869
67893
  this.rowContainerYOffset = 0;
67870
67894
  this._pageSize = 0;
67895
+ this.isScrollingTimer = 0;
67871
67896
  this.table = table;
67872
67897
  this.tanStackTable = tanStackTable;
67873
67898
  this.viewportResizeObserver = new ResizeObserver(entries => {
@@ -67921,7 +67946,7 @@ focus outline in that case.
67921
67946
  estimateSize: (_) => rowHeight,
67922
67947
  enableSmoothScroll: true,
67923
67948
  overscan: 3,
67924
- scrollingDelay: 5,
67949
+ isScrollingResetDelay: 250,
67925
67950
  scrollToFn: elementScroll,
67926
67951
  observeElementOffset,
67927
67952
  observeElementRect,
@@ -67932,6 +67957,16 @@ focus outline in that case.
67932
67957
  const virtualizer = this.virtualizer;
67933
67958
  this.visibleItems = virtualizer.getVirtualItems();
67934
67959
  this.scrollHeight = virtualizer.getTotalSize();
67960
+ this.isScrolling = virtualizer.isScrolling;
67961
+ // There are multiple browser bugs that can result in us getting stuck thinking that we're scrolling.
67962
+ // As a workaround, we assume scrolling stopped if we haven't received an update in 300ms.
67963
+ // Tech debt item to remove this workaround: https://github.com/ni/nimble/issues/2382
67964
+ window.clearTimeout(this.isScrollingTimer);
67965
+ if (this.isScrolling) {
67966
+ this.isScrollingTimer = window.setTimeout(() => {
67967
+ this.isScrolling = false;
67968
+ }, 300);
67969
+ }
67935
67970
  // We're using a separate div ('table-scroll') to represent the full height of all rows, and
67936
67971
  // the row container's height is only big enough to hold the virtualized rows. So we don't
67937
67972
  // use the TanStackVirtual-provided 'start' offset (which is in terms of the full height)
@@ -67953,6 +67988,9 @@ focus outline in that case.
67953
67988
  __decorate$1([
67954
67989
  observable
67955
67990
  ], Virtualizer.prototype, "scrollHeight", void 0);
67991
+ __decorate$1([
67992
+ observable
67993
+ ], Virtualizer.prototype, "isScrolling", void 0);
67956
67994
  __decorate$1([
67957
67995
  observable
67958
67996
  ], Virtualizer.prototype, "headerContainerMarginRight", void 0);