@ni/spright-components 4.1.14 → 4.1.15

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.
@@ -28724,7 +28724,7 @@ so this becomes the fallback color for the slot */ ''}
28724
28724
  let result = [];
28725
28725
  for (let typeName in types) {
28726
28726
  let type = types[typeName];
28727
- if (type.groups.indexOf(name) > -1)
28727
+ if (type.isInGroup(name))
28728
28728
  result.push(type);
28729
28729
  }
28730
28730
  if (result.length == 0)
@@ -29003,6 +29003,13 @@ so this becomes the fallback color for the slot */ ''}
29003
29003
  */
29004
29004
  get isAtom() { return this.isLeaf || !!this.spec.atom; }
29005
29005
  /**
29006
+ Return true when this node type is part of the given
29007
+ [group](https://prosemirror.net/docs/ref/#model.NodeSpec.group).
29008
+ */
29009
+ isInGroup(group) {
29010
+ return this.groups.indexOf(group) > -1;
29011
+ }
29012
+ /**
29006
29013
  The node type's [whitespace](https://prosemirror.net/docs/ref/#model.NodeSpec.whitespace) option.
29007
29014
  */
29008
29015
  get whitespace() {
@@ -29835,6 +29842,7 @@ so this becomes the fallback color for the slot */ ''}
29835
29842
  contentDOM = rule.contentElement;
29836
29843
  this.findAround(dom, contentDOM, true);
29837
29844
  this.addAll(contentDOM, marks);
29845
+ this.findAround(dom, contentDOM, false);
29838
29846
  }
29839
29847
  if (sync && this.sync(startIn))
29840
29848
  this.open--;
@@ -30013,7 +30021,7 @@ so this becomes the fallback color for the slot */ ''}
30013
30021
  let next = depth > 0 || (depth == 0 && useRoot) ? this.nodes[depth].type
30014
30022
  : option && depth >= minDepth ? option.node(depth - minDepth).type
30015
30023
  : null;
30016
- if (!next || (next.name != part && next.groups.indexOf(part) == -1))
30024
+ if (!next || (next.name != part && !next.isInGroup(part)))
30017
30025
  return false;
30018
30026
  depth--;
30019
30027
  }
@@ -41778,12 +41786,16 @@ so this becomes the fallback color for the slot */ ''}
41778
41786
  return;
41779
41787
  }
41780
41788
  let start = $pos.parent.childAfter($pos.parentOffset);
41781
- if ($pos.parentOffset === start.offset && start.offset !== 0) {
41789
+ // If the cursor is at the start of a text node that does not have the mark, look backward
41790
+ if (!start.node || !start.node.marks.some(mark => mark.type === type)) {
41782
41791
  start = $pos.parent.childBefore($pos.parentOffset);
41783
41792
  }
41784
- if (!start.node) {
41793
+ // If there is no text node with the mark even backward, return undefined
41794
+ if (!start.node || !start.node.marks.some(mark => mark.type === type)) {
41785
41795
  return;
41786
41796
  }
41797
+ // We now know that the cursor is either at the start, middle or end of a text node with the specified mark
41798
+ // so we can look it up on the targeted mark
41787
41799
  const mark = findMarkInSet([...start.node.marks], type, attributes);
41788
41800
  if (!mark) {
41789
41801
  return;
@@ -42073,7 +42085,7 @@ so this becomes the fallback color for the slot */ ''}
42073
42085
  var _a;
42074
42086
  if (dispatch) {
42075
42087
  options = {
42076
- parseOptions: {},
42088
+ parseOptions: editor.options.parseOptions,
42077
42089
  updateSelection: true,
42078
42090
  applyInputRules: false,
42079
42091
  applyPasteRules: false,
@@ -42094,7 +42106,9 @@ so this becomes the fallback color for the slot */ ''}
42094
42106
  editor,
42095
42107
  error: e,
42096
42108
  disableCollaboration: () => {
42097
- console.error('[tiptap error]: Unable to disable collaboration at this point in time');
42109
+ if (editor.storage.collaboration) {
42110
+ editor.storage.collaboration.isDisabled = true;
42111
+ }
42098
42112
  },
42099
42113
  });
42100
42114
  return false;
@@ -43868,7 +43882,8 @@ so this becomes the fallback color for the slot */ ''}
43868
43882
  const children = [];
43869
43883
  this.node.content.forEach((node, offset) => {
43870
43884
  const isBlock = node.isBlock && !node.isTextblock;
43871
- const targetPos = this.pos + offset + 1;
43885
+ const isNonTextAtom = node.isAtom && !node.isText;
43886
+ const targetPos = this.pos + offset + (isNonTextAtom ? 0 : 1);
43872
43887
  const $pos = this.resolvedPos.doc.resolve(targetPos);
43873
43888
  if (!isBlock && $pos.depth <= this.depth) {
43874
43889
  return;
@@ -43944,9 +43959,12 @@ so this becomes the fallback color for the slot */ ''}
43944
43959
  return nodes;
43945
43960
  }
43946
43961
  setAttribute(attributes) {
43947
- const oldSelection = this.editor.state.selection;
43948
- this.editor.chain().setTextSelection(this.from).updateAttributes(this.node.type.name, attributes).setTextSelection(oldSelection.from)
43949
- .run();
43962
+ const { tr } = this.editor.state;
43963
+ tr.setNodeMarkup(this.from, undefined, {
43964
+ ...this.node.attrs,
43965
+ ...attributes,
43966
+ });
43967
+ this.editor.view.dispatch(tr);
43950
43968
  }
43951
43969
  }
43952
43970
 
@@ -44198,18 +44216,27 @@ img.ProseMirror-separator {
44198
44216
  /**
44199
44217
  * Unregister a ProseMirror plugin.
44200
44218
  *
44201
- * @param nameOrPluginKey The plugins name
44219
+ * @param nameOrPluginKeyToRemove The plugins name
44202
44220
  * @returns The new editor state or undefined if the editor is destroyed
44203
44221
  */
44204
- unregisterPlugin(nameOrPluginKey) {
44222
+ unregisterPlugin(nameOrPluginKeyToRemove) {
44205
44223
  if (this.isDestroyed) {
44206
44224
  return undefined;
44207
44225
  }
44208
- // @ts-ignore
44209
- const name = typeof nameOrPluginKey === 'string' ? `${nameOrPluginKey}$` : nameOrPluginKey.key;
44210
- const state = this.state.reconfigure({
44226
+ const prevPlugins = this.state.plugins;
44227
+ let plugins = prevPlugins;
44228
+ [].concat(nameOrPluginKeyToRemove).forEach(nameOrPluginKey => {
44211
44229
  // @ts-ignore
44212
- plugins: this.state.plugins.filter(plugin => !plugin.key.startsWith(name)),
44230
+ const name = typeof nameOrPluginKey === 'string' ? `${nameOrPluginKey}$` : nameOrPluginKey.key;
44231
+ // @ts-ignore
44232
+ plugins = prevPlugins.filter(plugin => !plugin.key.startsWith(name));
44233
+ });
44234
+ if (prevPlugins.length === plugins.length) {
44235
+ // No plugin was removed, so we don’t need to update the state
44236
+ return undefined;
44237
+ }
44238
+ const state = this.state.reconfigure({
44239
+ plugins,
44213
44240
  });
44214
44241
  this.view.updateState(state);
44215
44242
  return state;
@@ -44272,6 +44299,9 @@ img.ProseMirror-separator {
44272
44299
  editor: this,
44273
44300
  error: e,
44274
44301
  disableCollaboration: () => {
44302
+ if (this.storage.collaboration) {
44303
+ this.storage.collaboration.isDisabled = true;
44304
+ }
44275
44305
  // To avoid syncing back invalid content, reinitialize the extensions without the collaboration extension
44276
44306
  this.options.extensions = this.options.extensions.filter(extension => extension.name !== 'collaboration');
44277
44307
  // Restart the initialization process by recreating the extension manager with the new set of extensions
@@ -44290,6 +44320,12 @@ img.ProseMirror-separator {
44290
44320
  selection: selection || undefined,
44291
44321
  }),
44292
44322
  });
44323
+ // add `role="textbox"` to the editor element
44324
+ this.view.dom.setAttribute('role', 'textbox');
44325
+ // add aria-label to the editor element
44326
+ if (!this.view.dom.getAttribute('aria-label')) {
44327
+ this.view.dom.setAttribute('aria-label', 'Rich-Text Editor');
44328
+ }
44293
44329
  // `editor.view` is not yet available at this time.
44294
44330
  // Therefore we will add all plugins and node views directly afterwards.
44295
44331
  const newState = this.state.reconfigure({
@@ -55422,6 +55458,10 @@ img.ProseMirror-separator {
55422
55458
  tag: 'b',
55423
55459
  getAttrs: node => node.style.fontWeight !== 'normal' && null,
55424
55460
  },
55461
+ {
55462
+ style: 'font-weight=400',
55463
+ clearMark: mark => mark.type.name === this.name,
55464
+ },
55425
55465
  {
55426
55466
  style: 'font-weight',
55427
55467
  getAttrs: value => /^(bold(er)?|[5-9]\d{2,})$/.test(value) && null,
@@ -56327,6 +56367,10 @@ img.ProseMirror-separator {
56327
56367
  tag: 'i',
56328
56368
  getAttrs: node => node.style.fontStyle !== 'normal' && null,
56329
56369
  },
56370
+ {
56371
+ style: 'font-style=normal',
56372
+ clearMark: mark => mark.type.name === this.name,
56373
+ },
56330
56374
  {
56331
56375
  style: 'font-style=italic',
56332
56376
  },
@@ -58712,6 +58756,7 @@ img.ProseMirror-separator {
58712
58756
  */
58713
58757
  const Mention = Node$1.create({
58714
58758
  name: 'mention',
58759
+ priority: 101,
58715
58760
  addOptions() {
58716
58761
  return {
58717
58762
  HTMLAttributes: {},