@ni/nimble-components 32.7.0 → 32.7.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.
@@ -31748,8 +31748,24 @@ so this becomes the fallback color for the slot */ ''}
31748
31748
  return joinable($pos.nodeBefore, $pos.nodeAfter) &&
31749
31749
  $pos.parent.canReplace(index, index + 1);
31750
31750
  }
31751
+ function canAppendWithSubstitutedLinebreaks(a, b) {
31752
+ if (!b.content.size)
31753
+ a.type.compatibleContent(b.type);
31754
+ let match = a.contentMatchAt(a.childCount);
31755
+ let { linebreakReplacement } = a.type.schema;
31756
+ for (let i = 0; i < b.childCount; i++) {
31757
+ let child = b.child(i);
31758
+ let type = child.type == linebreakReplacement ? a.type.schema.nodes.text : child.type;
31759
+ match = match.matchType(type);
31760
+ if (!match)
31761
+ return false;
31762
+ if (!a.type.allowsMarks(child.marks))
31763
+ return false;
31764
+ }
31765
+ return match.validEnd;
31766
+ }
31751
31767
  function joinable(a, b) {
31752
- return !!(a && b && !a.isLeaf && a.canAppend(b));
31768
+ return !!(a && b && !a.isLeaf && canAppendWithSubstitutedLinebreaks(a, b));
31753
31769
  }
31754
31770
  /**
31755
31771
  Find an ancestor of the given position that can be joined to the
@@ -31782,8 +31798,31 @@ so this becomes the fallback color for the slot */ ''}
31782
31798
  }
31783
31799
  }
31784
31800
  function join(tr, pos, depth) {
31785
- let step = new ReplaceStep(pos - depth, pos + depth, Slice.empty, true);
31786
- tr.step(step);
31801
+ let convertNewlines = null;
31802
+ let { linebreakReplacement } = tr.doc.type.schema;
31803
+ let $before = tr.doc.resolve(pos - depth), beforeType = $before.node().type;
31804
+ if (linebreakReplacement && beforeType.inlineContent) {
31805
+ let pre = beforeType.whitespace == "pre";
31806
+ let supportLinebreak = !!beforeType.contentMatch.matchType(linebreakReplacement);
31807
+ if (pre && !supportLinebreak)
31808
+ convertNewlines = false;
31809
+ else if (!pre && supportLinebreak)
31810
+ convertNewlines = true;
31811
+ }
31812
+ let mapFrom = tr.steps.length;
31813
+ if (convertNewlines === false) {
31814
+ let $after = tr.doc.resolve(pos + depth);
31815
+ replaceLinebreaks(tr, $after.node(), $after.before(), mapFrom);
31816
+ }
31817
+ if (beforeType.inlineContent)
31818
+ clearIncompatible(tr, pos + depth - 1, beforeType, $before.node().contentMatchAt($before.index()), convertNewlines == null);
31819
+ let mapping = tr.mapping.slice(mapFrom), start = mapping.map(pos - depth);
31820
+ tr.step(new ReplaceStep(start, mapping.map(pos + depth, -1), Slice.empty, true));
31821
+ if (convertNewlines === true) {
31822
+ let $full = tr.doc.resolve(start);
31823
+ replaceNewlines(tr, $full.node(), $full.before(), tr.steps.length);
31824
+ }
31825
+ return tr;
31787
31826
  }
31788
31827
  /**
31789
31828
  Try to find a point where a node of the given type can be inserted
@@ -32267,7 +32306,8 @@ so this becomes the fallback color for the slot */ ''}
32267
32306
  return tr.delete($from.before(depth), $to.after(depth));
32268
32307
  }
32269
32308
  for (let d = 1; d <= $from.depth && d <= $to.depth; d++) {
32270
- if (from - $from.start(d) == $from.depth - d && to > $from.end(d) && $to.end(d) - to != $to.depth - d)
32309
+ if (from - $from.start(d) == $from.depth - d && to > $from.end(d) && $to.end(d) - to != $to.depth - d &&
32310
+ $from.start(d - 1) == $to.start(d - 1) && $from.node(d - 1).canReplace($from.index(d - 1), $to.index(d - 1)))
32271
32311
  return tr.delete($from.before(d), to);
32272
32312
  }
32273
32313
  tr.delete(from, to);
@@ -34860,16 +34900,17 @@ so this becomes the fallback color for the slot */ ''}
34860
34900
  // some cases they will be split more often than would appear
34861
34901
  // necessary.
34862
34902
  class MarkViewDesc extends ViewDesc {
34863
- constructor(parent, mark, dom, contentDOM) {
34903
+ constructor(parent, mark, dom, contentDOM, spec) {
34864
34904
  super(parent, [], dom, contentDOM);
34865
34905
  this.mark = mark;
34906
+ this.spec = spec;
34866
34907
  }
34867
34908
  static create(parent, mark, inline, view) {
34868
34909
  let custom = view.nodeViews[mark.type.name];
34869
34910
  let spec = custom && custom(mark, view, inline);
34870
34911
  if (!spec || !spec.dom)
34871
34912
  spec = DOMSerializer.renderSpec(document, mark.type.spec.toDOM(mark, inline), null, mark.attrs);
34872
- return new MarkViewDesc(parent, mark, spec.dom, spec.contentDOM || spec.dom);
34913
+ return new MarkViewDesc(parent, mark, spec.dom, spec.contentDOM || spec.dom, spec);
34873
34914
  }
34874
34915
  parseRule() {
34875
34916
  if ((this.dirty & NODE_DIRTY) || this.mark.type.spec.reparseInView)
@@ -34901,6 +34942,11 @@ so this becomes the fallback color for the slot */ ''}
34901
34942
  copy.children = nodes;
34902
34943
  return copy;
34903
34944
  }
34945
+ destroy() {
34946
+ if (this.spec.destroy)
34947
+ this.spec.destroy();
34948
+ super.destroy();
34949
+ }
34904
34950
  }
34905
34951
  // Node view descs are the main, most common type of view desc, and
34906
34952
  // correspond to an actual node in the document. Unlike mark descs,
@@ -35220,7 +35266,7 @@ so this becomes the fallback color for the slot */ ''}
35220
35266
  update(node, outerDeco, innerDeco, view) {
35221
35267
  if (this.dirty == NODE_DIRTY)
35222
35268
  return false;
35223
- if (this.spec.update) {
35269
+ if (this.spec.update && (this.node.type == node.type || this.spec.multiType)) {
35224
35270
  let result = this.spec.update(node, outerDeco, innerDeco);
35225
35271
  if (result)
35226
35272
  this.updateInner(node, outerDeco, innerDeco, view);
@@ -36621,6 +36667,7 @@ so this becomes the fallback color for the slot */ ''}
36621
36667
  function detachedDoc() {
36622
36668
  return _detachedDoc || (_detachedDoc = document.implementation.createHTMLDocument("title"));
36623
36669
  }
36670
+ let _policy = null;
36624
36671
  function maybeWrapTrusted(html) {
36625
36672
  let trustedTypes = window.trustedTypes;
36626
36673
  if (!trustedTypes)
@@ -36628,7 +36675,9 @@ so this becomes the fallback color for the slot */ ''}
36628
36675
  // With the require-trusted-types-for CSP, Chrome will block
36629
36676
  // innerHTML, even on a detached document. This wraps the string in
36630
36677
  // a way that makes the browser allow us to use its parser again.
36631
- return trustedTypes.createPolicy("detachedDocument", { createHTML: (s) => s }).createHTML(html);
36678
+ if (!_policy)
36679
+ _policy = trustedTypes.createPolicy("ProseMirrorClipboard", { createHTML: (s) => s });
36680
+ return _policy.createHTML(html);
36632
36681
  }
36633
36682
  function readHTML(html) {
36634
36683
  let metas = /^(\s*<meta [^>]*>)*/.exec(html);
@@ -36779,9 +36828,7 @@ so this becomes the fallback color for the slot */ ''}
36779
36828
  // and handling them eagerly tends to corrupt the input.
36780
36829
  if (android && chrome && event.keyCode == 13)
36781
36830
  return;
36782
- if (view.domObserver.selectionChanged(view.domSelectionRange()))
36783
- view.domObserver.flush();
36784
- else if (event.keyCode != 229)
36831
+ if (event.keyCode != 229)
36785
36832
  view.domObserver.forceFlush();
36786
36833
  // On iOS, if we preventDefault enter key presses, the virtual
36787
36834
  // keyboard gets confused. So the hack here is to set a flag that
@@ -38303,9 +38350,6 @@ so this becomes the fallback color for the slot */ ''}
38303
38350
  this.queue.push(mut);
38304
38351
  return this.queue;
38305
38352
  }
38306
- selectionChanged(sel) {
38307
- return !this.suppressingSelectionUpdates && !this.currentSelection.eq(sel) && hasFocusAndSelection(this.view) && !this.ignoreSelectionChange(sel);
38308
- }
38309
38353
  flush() {
38310
38354
  let { view } = this;
38311
38355
  if (!view.docView || this.flushingSoon > -1)
@@ -38313,7 +38357,8 @@ so this becomes the fallback color for the slot */ ''}
38313
38357
  let mutations = this.pendingRecords();
38314
38358
  if (mutations.length)
38315
38359
  this.queue = [];
38316
- let sel = view.domSelectionRange(), newSel = this.selectionChanged(sel);
38360
+ let sel = view.domSelectionRange();
38361
+ let newSel = !this.suppressingSelectionUpdates && !this.currentSelection.eq(sel) && hasFocusAndSelection(view) && !this.ignoreSelectionChange(sel);
38317
38362
  let from = -1, to = -1, typeOver = false, added = [];
38318
38363
  if (view.editable) {
38319
38364
  for (let i = 0; i < mutations.length; i++) {
@@ -40089,10 +40134,7 @@ so this becomes the fallback color for the slot */ ''}
40089
40134
  if (!$pos.parent.canReplace(index, index + 1) || !(after.isTextblock || canJoin(state.doc, $pos.pos)))
40090
40135
  return false;
40091
40136
  if (dispatch)
40092
- dispatch(state.tr
40093
- .clearIncompatible($pos.pos, before.type, before.contentMatchAt(before.childCount))
40094
- .join($pos.pos)
40095
- .scrollIntoView());
40137
+ dispatch(state.tr.join($pos.pos).scrollIntoView());
40096
40138
  return true;
40097
40139
  }
40098
40140
  function deleteBarrier(state, $cut, dispatch, dir) {
@@ -40110,9 +40152,10 @@ so this becomes the fallback color for the slot */ ''}
40110
40152
  wrap = Fragment.from(conn[i].create(null, wrap));
40111
40153
  wrap = Fragment.from(before.copy(wrap));
40112
40154
  let tr = state.tr.step(new ReplaceAroundStep($cut.pos - 1, end, $cut.pos, end, new Slice(wrap, 1, 0), conn.length, true));
40113
- let joinAt = end + 2 * conn.length;
40114
- if (canJoin(tr.doc, joinAt))
40115
- tr.join(joinAt);
40155
+ let $joinAt = tr.doc.resolve(end + 2 * conn.length);
40156
+ if ($joinAt.nodeAfter && $joinAt.nodeAfter.type == before.type &&
40157
+ canJoin(tr.doc, $joinAt.pos))
40158
+ tr.join($joinAt.pos);
40116
40159
  dispatch(tr.scrollIntoView());
40117
40160
  }
40118
40161
  return true;
@@ -55758,84 +55801,8 @@ img.ProseMirror-separator {
55758
55801
  },
55759
55802
  });
55760
55803
 
55761
- /**
55762
- * This extension allows you to create list items.
55763
- * @see https://www.tiptap.dev/api/nodes/list-item
55764
- */
55765
- const ListItem = Node$1.create({
55766
- name: 'listItem',
55767
- addOptions() {
55768
- return {
55769
- HTMLAttributes: {},
55770
- bulletListTypeName: 'bulletList',
55771
- orderedListTypeName: 'orderedList',
55772
- };
55773
- },
55774
- content: 'paragraph block*',
55775
- defining: true,
55776
- parseHTML() {
55777
- return [
55778
- {
55779
- tag: 'li',
55780
- },
55781
- ];
55782
- },
55783
- renderHTML({ HTMLAttributes }) {
55784
- return ['li', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
55785
- },
55786
- addKeyboardShortcuts() {
55787
- return {
55788
- Enter: () => this.editor.commands.splitListItem(this.name),
55789
- Tab: () => this.editor.commands.sinkListItem(this.name),
55790
- 'Shift-Tab': () => this.editor.commands.liftListItem(this.name),
55791
- };
55792
- },
55793
- });
55794
-
55795
- /**
55796
- * This extension allows you to create text styles. It is required by default
55797
- * for the `textColor` and `backgroundColor` extensions.
55798
- * @see https://www.tiptap.dev/api/marks/text-style
55799
- */
55800
- const TextStyle = Mark.create({
55801
- name: 'textStyle',
55802
- priority: 101,
55803
- addOptions() {
55804
- return {
55805
- HTMLAttributes: {},
55806
- };
55807
- },
55808
- parseHTML() {
55809
- return [
55810
- {
55811
- tag: 'span',
55812
- getAttrs: element => {
55813
- const hasStyles = element.hasAttribute('style');
55814
- if (!hasStyles) {
55815
- return false;
55816
- }
55817
- return {};
55818
- },
55819
- },
55820
- ];
55821
- },
55822
- renderHTML({ HTMLAttributes }) {
55823
- return ['span', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
55824
- },
55825
- addCommands() {
55826
- return {
55827
- removeEmptyTextStyle: () => ({ state, commands }) => {
55828
- const attributes = getMarkAttributes(state, this.type);
55829
- const hasStyles = Object.entries(attributes).some(([, value]) => !!value);
55830
- if (hasStyles) {
55831
- return true;
55832
- }
55833
- return commands.unsetMark(this.name);
55834
- },
55835
- };
55836
- },
55837
- });
55838
-
55804
+ const ListItemName$1 = 'listItem';
55805
+ const TextStyleName$1 = 'textStyle';
55839
55806
  /**
55840
55807
  * Matches a bullet list to a dash or asterisk.
55841
55808
  */
@@ -55872,7 +55839,7 @@ img.ProseMirror-separator {
55872
55839
  return {
55873
55840
  toggleBulletList: () => ({ commands, chain }) => {
55874
55841
  if (this.options.keepAttributes) {
55875
- return chain().toggleList(this.name, this.options.itemTypeName, this.options.keepMarks).updateAttributes(ListItem.name, this.editor.getAttributes(TextStyle.name)).run();
55842
+ return chain().toggleList(this.name, this.options.itemTypeName, this.options.keepMarks).updateAttributes(ListItemName$1, this.editor.getAttributes(TextStyleName$1)).run();
55876
55843
  }
55877
55844
  return commands.toggleList(this.name, this.options.itemTypeName, this.options.keepMarks);
55878
55845
  },
@@ -55894,7 +55861,7 @@ img.ProseMirror-separator {
55894
55861
  type: this.type,
55895
55862
  keepMarks: this.options.keepMarks,
55896
55863
  keepAttributes: this.options.keepAttributes,
55897
- getAttributes: () => { return this.editor.getAttributes(TextStyle.name); },
55864
+ getAttributes: () => { return this.editor.getAttributes(TextStyleName$1); },
55898
55865
  editor: this.editor,
55899
55866
  });
55900
55867
  }
@@ -58756,6 +58723,40 @@ img.ProseMirror-separator {
58756
58723
  },
58757
58724
  });
58758
58725
 
58726
+ /**
58727
+ * This extension allows you to create list items.
58728
+ * @see https://www.tiptap.dev/api/nodes/list-item
58729
+ */
58730
+ const ListItem = Node$1.create({
58731
+ name: 'listItem',
58732
+ addOptions() {
58733
+ return {
58734
+ HTMLAttributes: {},
58735
+ bulletListTypeName: 'bulletList',
58736
+ orderedListTypeName: 'orderedList',
58737
+ };
58738
+ },
58739
+ content: 'paragraph block*',
58740
+ defining: true,
58741
+ parseHTML() {
58742
+ return [
58743
+ {
58744
+ tag: 'li',
58745
+ },
58746
+ ];
58747
+ },
58748
+ renderHTML({ HTMLAttributes }) {
58749
+ return ['li', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
58750
+ },
58751
+ addKeyboardShortcuts() {
58752
+ return {
58753
+ Enter: () => this.editor.commands.splitListItem(this.name),
58754
+ Tab: () => this.editor.commands.sinkListItem(this.name),
58755
+ 'Shift-Tab': () => this.editor.commands.liftListItem(this.name),
58756
+ };
58757
+ },
58758
+ });
58759
+
58759
58760
  function findSuggestionMatch(config) {
58760
58761
  var _a;
58761
58762
  const { char, allowSpaces, allowedPrefixes, startOfLine, $position, } = config;
@@ -59162,6 +59163,8 @@ img.ProseMirror-separator {
59162
59163
  },
59163
59164
  });
59164
59165
 
59166
+ const ListItemName = 'listItem';
59167
+ const TextStyleName = 'textStyle';
59165
59168
  /**
59166
59169
  * Matches an ordered list to a 1. on input (or any number followed by a dot).
59167
59170
  */
@@ -59219,7 +59222,7 @@ img.ProseMirror-separator {
59219
59222
  return {
59220
59223
  toggleOrderedList: () => ({ commands, chain }) => {
59221
59224
  if (this.options.keepAttributes) {
59222
- return chain().toggleList(this.name, this.options.itemTypeName, this.options.keepMarks).updateAttributes(ListItem.name, this.editor.getAttributes(TextStyle.name)).run();
59225
+ return chain().toggleList(this.name, this.options.itemTypeName, this.options.keepMarks).updateAttributes(ListItemName, this.editor.getAttributes(TextStyleName)).run();
59223
59226
  }
59224
59227
  return commands.toggleList(this.name, this.options.itemTypeName, this.options.keepMarks);
59225
59228
  },
@@ -59243,7 +59246,7 @@ img.ProseMirror-separator {
59243
59246
  type: this.type,
59244
59247
  keepMarks: this.options.keepMarks,
59245
59248
  keepAttributes: this.options.keepAttributes,
59246
- getAttributes: match => ({ start: +match[1], ...this.editor.getAttributes(TextStyle.name) }),
59249
+ getAttributes: match => ({ start: +match[1], ...this.editor.getAttributes(TextStyleName) }),
59247
59250
  joinPredicate: (match, node) => node.childCount + node.attrs.start === +match[1],
59248
59251
  editor: this.editor,
59249
59252
  });
@@ -67658,7 +67661,7 @@ focus outline in that case.
67658
67661
  return;
67659
67662
  }
67660
67663
  let offset = 0;
67661
- const fallback = supportsScrollend ? () => void 0 : debounce(
67664
+ const fallback = instance.options.useScrollendEvent && supportsScrollend ? () => void 0 : debounce(
67662
67665
  targetWindow,
67663
67666
  () => {
67664
67667
  cb(offset, false);
@@ -67780,6 +67783,7 @@ focus outline in that case.
67780
67783
  isScrollingResetDelay: 150,
67781
67784
  enabled: true,
67782
67785
  isRtl: false,
67786
+ useScrollendEvent: true,
67783
67787
  ...opts2
67784
67788
  };
67785
67789
  };