@ni/nimble-components 21.3.1 → 21.3.3

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.
@@ -16301,7 +16301,7 @@
16301
16301
 
16302
16302
  /**
16303
16303
  * Do not edit directly
16304
- * Generated on Fri, 09 Feb 2024 01:47:11 GMT
16304
+ * Generated on Tue, 13 Feb 2024 21:07:13 GMT
16305
16305
  */
16306
16306
 
16307
16307
  const Information100DarkUi = "#a46eff";
@@ -27804,7 +27804,7 @@
27804
27804
  ProseMirror document conforming to a given schema. Its behavior is
27805
27805
  defined by an array of [rules](https://prosemirror.net/docs/ref/#model.ParseRule).
27806
27806
  */
27807
- class DOMParser {
27807
+ let DOMParser$1 = class DOMParser {
27808
27808
  /**
27809
27809
  Create a parser that targets the given schema, using the given
27810
27810
  parsing rules.
@@ -27949,7 +27949,7 @@
27949
27949
  return schema.cached.domParser ||
27950
27950
  (schema.cached.domParser = new DOMParser(schema, DOMParser.schemaRules(schema)));
27951
27951
  }
27952
- }
27952
+ };
27953
27953
  const blockTags = {
27954
27954
  address: true, article: true, aside: true, blockquote: true, canvas: true,
27955
27955
  dd: true, div: true, dl: true, fieldset: true, figcaption: true, figure: true,
@@ -34488,7 +34488,7 @@
34488
34488
  dom = child;
34489
34489
  }
34490
34490
  if (!slice) {
34491
- let parser = view.someProp("clipboardParser") || view.someProp("domParser") || DOMParser.fromSchema(view.state.schema);
34491
+ let parser = view.someProp("clipboardParser") || view.someProp("domParser") || DOMParser$1.fromSchema(view.state.schema);
34492
34492
  slice = parser.parseSlice(dom, {
34493
34493
  preserveWhitespace: !!(asText || sliceData),
34494
34494
  context: $context,
@@ -36412,7 +36412,7 @@
36412
36412
  }
36413
36413
  }
36414
36414
  let startDoc = view.state.doc;
36415
- let parser = view.someProp("domParser") || DOMParser.fromSchema(view.state.schema);
36415
+ let parser = view.someProp("domParser") || DOMParser$1.fromSchema(view.state.schema);
36416
36416
  let $from = startDoc.resolve(from);
36417
36417
  let sel = null, doc = parser.parse(parent, {
36418
36418
  topNode: $from.parent,
@@ -37597,6 +37597,60 @@
37597
37597
  }
37598
37598
  return false;
37599
37599
  };
37600
+ /**
37601
+ A more limited form of [`joinBackward`]($commands.joinBackward)
37602
+ that only tries to join the current textblock to the one before
37603
+ it, if the cursor is at the start of a textblock.
37604
+ */
37605
+ const joinTextblockBackward$1 = (state, dispatch, view) => {
37606
+ let $cursor = atBlockStart(state, view);
37607
+ if (!$cursor)
37608
+ return false;
37609
+ let $cut = findCutBefore($cursor);
37610
+ return $cut ? joinTextblocksAround(state, $cut, dispatch) : false;
37611
+ };
37612
+ /**
37613
+ A more limited form of [`joinForward`]($commands.joinForward)
37614
+ that only tries to join the current textblock to the one after
37615
+ it, if the cursor is at the end of a textblock.
37616
+ */
37617
+ const joinTextblockForward$1 = (state, dispatch, view) => {
37618
+ let $cursor = atBlockEnd(state, view);
37619
+ if (!$cursor)
37620
+ return false;
37621
+ let $cut = findCutAfter($cursor);
37622
+ return $cut ? joinTextblocksAround(state, $cut, dispatch) : false;
37623
+ };
37624
+ function joinTextblocksAround(state, $cut, dispatch) {
37625
+ let before = $cut.nodeBefore, beforeText = before, beforePos = $cut.pos - 1;
37626
+ for (; !beforeText.isTextblock; beforePos--) {
37627
+ if (beforeText.type.spec.isolating)
37628
+ return false;
37629
+ let child = beforeText.lastChild;
37630
+ if (!child)
37631
+ return false;
37632
+ beforeText = child;
37633
+ }
37634
+ let after = $cut.nodeAfter, afterText = after, afterPos = $cut.pos + 1;
37635
+ for (; !afterText.isTextblock; afterPos++) {
37636
+ if (afterText.type.spec.isolating)
37637
+ return false;
37638
+ let child = afterText.firstChild;
37639
+ if (!child)
37640
+ return false;
37641
+ afterText = child;
37642
+ }
37643
+ let step = replaceStep(state.doc, beforePos, afterPos, Slice.empty);
37644
+ if (!step || step.from != beforePos ||
37645
+ step instanceof ReplaceStep && step.slice.size >= afterPos - beforePos)
37646
+ return false;
37647
+ if (dispatch) {
37648
+ let tr = state.tr.step(step);
37649
+ tr.setSelection(TextSelection.create(tr.doc, beforePos));
37650
+ dispatch(tr.scrollIntoView());
37651
+ }
37652
+ return true;
37653
+ }
37600
37654
  function textblockAt(node, side, only = false) {
37601
37655
  for (let scan = node; scan; scan = (side == "start" ? scan.firstChild : scan.lastChild)) {
37602
37656
  if (scan.isTextblock)
@@ -38177,7 +38231,6 @@
38177
38231
  ...state,
38178
38232
  apply: state.apply.bind(state),
38179
38233
  applyTransaction: state.applyTransaction.bind(state),
38180
- filterTransaction: state.filterTransaction,
38181
38234
  plugins: state.plugins,
38182
38235
  schema: state.schema,
38183
38236
  reconfigure: state.reconfigure.bind(state),
@@ -38892,11 +38945,11 @@
38892
38945
  this.handler = config.handler;
38893
38946
  }
38894
38947
  }
38895
- const pasteRuleMatcherHandler = (text, find) => {
38948
+ const pasteRuleMatcherHandler = (text, find, event) => {
38896
38949
  if (isRegExp$1(find)) {
38897
38950
  return [...text.matchAll(find)];
38898
38951
  }
38899
- const matches = find(text);
38952
+ const matches = find(text, event);
38900
38953
  if (!matches) {
38901
38954
  return [];
38902
38955
  }
@@ -38928,7 +38981,7 @@
38928
38981
  const resolvedFrom = Math.max(from, pos);
38929
38982
  const resolvedTo = Math.min(to, pos + node.content.size);
38930
38983
  const textToMatch = node.textBetween(resolvedFrom - pos, resolvedTo - pos, undefined, '\ufffc');
38931
- const matches = pasteRuleMatcherHandler(textToMatch, rule.find);
38984
+ const matches = pasteRuleMatcherHandler(textToMatch, rule.find, pasteEvent);
38932
38985
  matches.forEach(match => {
38933
38986
  if (match.index === undefined) {
38934
38987
  return;
@@ -39309,7 +39362,7 @@
39309
39362
  ...config,
39310
39363
  };
39311
39364
  this.name = this.config.name;
39312
- if (config.defaultOptions) {
39365
+ if (config.defaultOptions && Object.keys(config.defaultOptions).length > 0) {
39313
39366
  console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`);
39314
39367
  }
39315
39368
  // TODO: remove `addOptions` fallback
@@ -39339,7 +39392,7 @@
39339
39392
  return extension;
39340
39393
  }
39341
39394
  extend(extendedConfig = {}) {
39342
- const extension = new Extension(extendedConfig);
39395
+ const extension = new Extension({ ...this.config, ...extendedConfig });
39343
39396
  extension.parent = this;
39344
39397
  this.child = extension;
39345
39398
  extension.name = extendedConfig.name ? extendedConfig.name : extension.parent.name;
@@ -39746,10 +39799,24 @@
39746
39799
  return commands.insertContentAt({ from: tr.selection.from, to: tr.selection.to }, value, options);
39747
39800
  };
39748
39801
 
39802
+ const removeWhitespaces = (node) => {
39803
+ const children = node.childNodes;
39804
+ for (let i = children.length - 1; i >= 0; i -= 1) {
39805
+ const child = children[i];
39806
+ if (child.nodeType === 3 && child.nodeValue && /^(\n\s\s|\n)$/.test(child.nodeValue)) {
39807
+ node.removeChild(child);
39808
+ }
39809
+ else if (child.nodeType === 1) {
39810
+ removeWhitespaces(child);
39811
+ }
39812
+ }
39813
+ return node;
39814
+ };
39749
39815
  function elementFromString(value) {
39750
39816
  // add a wrapper to preserve leading and trailing whitespace
39751
39817
  const wrappedValue = `<body>${value}</body>`;
39752
- return new window.DOMParser().parseFromString(wrappedValue, 'text/html').body;
39818
+ const html = new window.DOMParser().parseFromString(wrappedValue, 'text/html').body;
39819
+ return removeWhitespaces(html);
39753
39820
  }
39754
39821
 
39755
39822
  function createNodeFromContent(content, schema, options) {
@@ -39771,7 +39838,7 @@
39771
39838
  }
39772
39839
  }
39773
39840
  if (typeof content === 'string') {
39774
- const parser = DOMParser.fromSchema(schema);
39841
+ const parser = DOMParser$1.fromSchema(schema);
39775
39842
  return options.slice
39776
39843
  ? parser.parseSlice(elementFromString(content), options.parseOptions).content
39777
39844
  : parser.parse(elementFromString(content), options.parseOptions);
@@ -39915,6 +39982,14 @@
39915
39982
  }
39916
39983
  };
39917
39984
 
39985
+ const joinTextblockBackward = () => ({ state, dispatch }) => {
39986
+ return joinTextblockBackward$1(state, dispatch);
39987
+ };
39988
+
39989
+ const joinTextblockForward = () => ({ state, dispatch }) => {
39990
+ return joinTextblockForward$1(state, dispatch);
39991
+ };
39992
+
39918
39993
  function isMacOS() {
39919
39994
  return typeof navigator !== 'undefined'
39920
39995
  ? /Mac/.test(navigator.platform)
@@ -40387,6 +40462,9 @@
40387
40462
  }
40388
40463
  else {
40389
40464
  doc.nodesBetween(from, to, (node, pos) => {
40465
+ if (!node || (node === null || node === void 0 ? void 0 : node.nodeSize) === undefined) {
40466
+ return;
40467
+ }
40390
40468
  marks.push(...node.marks.map(mark => ({
40391
40469
  from: pos,
40392
40470
  to: pos + node.nodeSize,
@@ -41078,6 +41156,8 @@
41078
41156
  joinForward: joinForward,
41079
41157
  joinItemBackward: joinItemBackward,
41080
41158
  joinItemForward: joinItemForward,
41159
+ joinTextblockBackward: joinTextblockBackward,
41160
+ joinTextblockForward: joinTextblockForward,
41081
41161
  keyboardShortcut: keyboardShortcut,
41082
41162
  lift: lift,
41083
41163
  liftEmptyBlock: liftEmptyBlock,
@@ -41303,6 +41383,180 @@
41303
41383
  Tabindex: Tabindex
41304
41384
  });
41305
41385
 
41386
+ class NodePos {
41387
+ constructor(pos, editor, isBlock = false, node = null) {
41388
+ this.currentNode = null;
41389
+ this.actualDepth = null;
41390
+ this.isBlock = isBlock;
41391
+ this.resolvedPos = pos;
41392
+ this.editor = editor;
41393
+ this.currentNode = node;
41394
+ }
41395
+ get name() {
41396
+ return this.node.type.name;
41397
+ }
41398
+ get node() {
41399
+ return this.currentNode || this.resolvedPos.node();
41400
+ }
41401
+ get element() {
41402
+ return this.editor.view.domAtPos(this.pos).node;
41403
+ }
41404
+ get depth() {
41405
+ var _a;
41406
+ return (_a = this.actualDepth) !== null && _a !== void 0 ? _a : this.resolvedPos.depth;
41407
+ }
41408
+ get pos() {
41409
+ return this.resolvedPos.pos;
41410
+ }
41411
+ get content() {
41412
+ return this.node.content;
41413
+ }
41414
+ set content(content) {
41415
+ let from = this.from;
41416
+ let to = this.to;
41417
+ if (this.isBlock) {
41418
+ if (this.content.size === 0) {
41419
+ console.error(`You can’t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);
41420
+ return;
41421
+ }
41422
+ from = this.from + 1;
41423
+ to = this.to - 1;
41424
+ }
41425
+ this.editor.commands.insertContentAt({ from, to }, content);
41426
+ }
41427
+ get attributes() {
41428
+ return this.node.attrs;
41429
+ }
41430
+ get textContent() {
41431
+ return this.node.textContent;
41432
+ }
41433
+ get size() {
41434
+ return this.node.nodeSize;
41435
+ }
41436
+ get from() {
41437
+ if (this.isBlock) {
41438
+ return this.pos;
41439
+ }
41440
+ return this.resolvedPos.start(this.resolvedPos.depth);
41441
+ }
41442
+ get range() {
41443
+ return {
41444
+ from: this.from,
41445
+ to: this.to,
41446
+ };
41447
+ }
41448
+ get to() {
41449
+ if (this.isBlock) {
41450
+ return this.pos + this.size;
41451
+ }
41452
+ return this.resolvedPos.end(this.resolvedPos.depth) + (this.node.isText ? 0 : 1);
41453
+ }
41454
+ get parent() {
41455
+ if (this.depth === 0) {
41456
+ return null;
41457
+ }
41458
+ const parentPos = this.resolvedPos.start(this.resolvedPos.depth - 1);
41459
+ const $pos = this.resolvedPos.doc.resolve(parentPos);
41460
+ return new NodePos($pos, this.editor);
41461
+ }
41462
+ get before() {
41463
+ let $pos = this.resolvedPos.doc.resolve(this.from - (this.isBlock ? 1 : 2));
41464
+ if ($pos.depth !== this.depth) {
41465
+ $pos = this.resolvedPos.doc.resolve(this.from - 3);
41466
+ }
41467
+ return new NodePos($pos, this.editor);
41468
+ }
41469
+ get after() {
41470
+ let $pos = this.resolvedPos.doc.resolve(this.to + (this.isBlock ? 2 : 1));
41471
+ if ($pos.depth !== this.depth) {
41472
+ $pos = this.resolvedPos.doc.resolve(this.to + 3);
41473
+ }
41474
+ return new NodePos($pos, this.editor);
41475
+ }
41476
+ get children() {
41477
+ const children = [];
41478
+ this.node.content.forEach((node, offset) => {
41479
+ const isBlock = node.isBlock && !node.isTextblock;
41480
+ const targetPos = this.pos + offset + (isBlock ? 0 : 1);
41481
+ const $pos = this.resolvedPos.doc.resolve(targetPos);
41482
+ if (!isBlock && $pos.depth <= this.depth) {
41483
+ return;
41484
+ }
41485
+ const childNodePos = new NodePos($pos, this.editor, isBlock, isBlock ? node : null);
41486
+ if (isBlock) {
41487
+ childNodePos.actualDepth = this.depth + 1;
41488
+ }
41489
+ children.push(new NodePos($pos, this.editor, isBlock, isBlock ? node : null));
41490
+ });
41491
+ return children;
41492
+ }
41493
+ get firstChild() {
41494
+ return this.children[0] || null;
41495
+ }
41496
+ get lastChild() {
41497
+ const children = this.children;
41498
+ return children[children.length - 1] || null;
41499
+ }
41500
+ closest(selector, attributes = {}) {
41501
+ let node = null;
41502
+ let currentNode = this.parent;
41503
+ while (currentNode && !node) {
41504
+ if (currentNode.node.type.name === selector) {
41505
+ if (Object.keys(attributes).length > 0) {
41506
+ const nodeAttributes = currentNode.node.attrs;
41507
+ const attrKeys = Object.keys(attributes);
41508
+ for (let index = 0; index < attrKeys.length; index += 1) {
41509
+ const key = attrKeys[index];
41510
+ if (nodeAttributes[key] !== attributes[key]) {
41511
+ break;
41512
+ }
41513
+ }
41514
+ }
41515
+ else {
41516
+ node = currentNode;
41517
+ }
41518
+ }
41519
+ currentNode = currentNode.parent;
41520
+ }
41521
+ return node;
41522
+ }
41523
+ querySelector(selector, attributes = {}) {
41524
+ return this.querySelectorAll(selector, attributes, true)[0] || null;
41525
+ }
41526
+ querySelectorAll(selector, attributes = {}, firstItemOnly = false) {
41527
+ let nodes = [];
41528
+ // iterate through children recursively finding all nodes which match the selector with the node name
41529
+ if (this.isBlock || !this.children || this.children.length === 0) {
41530
+ return nodes;
41531
+ }
41532
+ this.children.forEach(childPos => {
41533
+ if (childPos.node.type.name === selector) {
41534
+ if (Object.keys(attributes).length > 0) {
41535
+ const nodeAttributes = childPos.node.attrs;
41536
+ const attrKeys = Object.keys(attributes);
41537
+ for (let index = 0; index < attrKeys.length; index += 1) {
41538
+ const key = attrKeys[index];
41539
+ if (nodeAttributes[key] !== attributes[key]) {
41540
+ return;
41541
+ }
41542
+ }
41543
+ }
41544
+ nodes.push(childPos);
41545
+ if (firstItemOnly) {
41546
+ return;
41547
+ }
41548
+ }
41549
+ nodes = nodes.concat(childPos.querySelectorAll(selector));
41550
+ });
41551
+ return nodes;
41552
+ }
41553
+ setAttribute(attributes) {
41554
+ const oldSelection = this.editor.state.selection;
41555
+ this.editor.chain().setTextSelection(this.from).updateAttributes(this.node.type.name, attributes).setTextSelection(oldSelection.from)
41556
+ .run();
41557
+ }
41558
+ }
41559
+
41306
41560
  const style = `.ProseMirror {
41307
41561
  position: relative;
41308
41562
  }
@@ -41748,6 +42002,21 @@ img.ProseMirror-separator {
41748
42002
  // @ts-ignore
41749
42003
  return !((_a = this.view) === null || _a === void 0 ? void 0 : _a.docView);
41750
42004
  }
42005
+ $node(selector, attributes) {
42006
+ var _a;
42007
+ return ((_a = this.$doc) === null || _a === void 0 ? void 0 : _a.querySelector(selector, attributes)) || null;
42008
+ }
42009
+ $nodes(selector, attributes) {
42010
+ var _a;
42011
+ return ((_a = this.$doc) === null || _a === void 0 ? void 0 : _a.querySelectorAll(selector, attributes)) || null;
42012
+ }
42013
+ $pos(pos) {
42014
+ const $pos = this.state.doc.resolve(pos);
42015
+ return new NodePos($pos, this);
42016
+ }
42017
+ get $doc() {
42018
+ return this.$pos(0);
42019
+ }
41751
42020
  }
41752
42021
 
41753
42022
  /**
@@ -41860,7 +42129,7 @@ img.ProseMirror-separator {
41860
42129
  ...config,
41861
42130
  };
41862
42131
  this.name = this.config.name;
41863
- if (config.defaultOptions) {
42132
+ if (config.defaultOptions && Object.keys(config.defaultOptions).length > 0) {
41864
42133
  console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`);
41865
42134
  }
41866
42135
  // TODO: remove `addOptions` fallback
@@ -41890,7 +42159,7 @@ img.ProseMirror-separator {
41890
42159
  return extension;
41891
42160
  }
41892
42161
  extend(extendedConfig = {}) {
41893
- const extension = new Mark(extendedConfig);
42162
+ const extension = new Mark({ ...this.config, ...extendedConfig });
41894
42163
  extension.parent = this;
41895
42164
  this.child = extension;
41896
42165
  extension.name = extendedConfig.name ? extendedConfig.name : extension.parent.name;
@@ -41943,7 +42212,7 @@ img.ProseMirror-separator {
41943
42212
  ...config,
41944
42213
  };
41945
42214
  this.name = this.config.name;
41946
- if (config.defaultOptions) {
42215
+ if (config.defaultOptions && Object.keys(config.defaultOptions).length > 0) {
41947
42216
  console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`);
41948
42217
  }
41949
42218
  // TODO: remove `addOptions` fallback
@@ -41973,7 +42242,7 @@ img.ProseMirror-separator {
41973
42242
  return extension;
41974
42243
  }
41975
42244
  extend(extendedConfig = {}) {
41976
- const extension = new Node(extendedConfig);
42245
+ const extension = new Node({ ...this.config, ...extendedConfig });
41977
42246
  extension.parent = this;
41978
42247
  this.child = extension;
41979
42248
  extension.name = extendedConfig.name ? extendedConfig.name : extension.parent.name;
@@ -53527,11 +53796,8 @@ img.ProseMirror-separator {
53527
53796
  addKeyboardShortcuts() {
53528
53797
  return {
53529
53798
  'Mod-z': () => this.editor.commands.undo(),
53530
- 'Mod-Z': () => this.editor.commands.undo(),
53531
- 'Mod-y': () => this.editor.commands.redo(),
53532
- 'Mod-Y': () => this.editor.commands.redo(),
53533
53799
  'Shift-Mod-z': () => this.editor.commands.redo(),
53534
- 'Shift-Mod-Z': () => this.editor.commands.redo(),
53800
+ 'Mod-y': () => this.editor.commands.redo(),
53535
53801
  // Russian keyboard layouts
53536
53802
  'Mod-я': () => this.editor.commands.undo(),
53537
53803
  'Shift-Mod-я': () => this.editor.commands.redo(),
@@ -55438,8 +55704,13 @@ img.ProseMirror-separator {
55438
55704
  if (event.button !== 0) {
55439
55705
  return false;
55440
55706
  }
55441
- const eventTarget = event.target;
55442
- if (eventTarget.nodeName !== 'A') {
55707
+ let a = event.target;
55708
+ const els = [];
55709
+ while (a.nodeName !== 'DIV') {
55710
+ els.push(a);
55711
+ a = a.parentNode;
55712
+ }
55713
+ if (!els.find(value => value.nodeName === 'A')) {
55443
55714
  return false;
55444
55715
  }
55445
55716
  const attrs = getAttributes(view.state, options.type.name);
@@ -55447,9 +55718,7 @@ img.ProseMirror-separator {
55447
55718
  const href = (_a = link === null || link === void 0 ? void 0 : link.href) !== null && _a !== void 0 ? _a : attrs.href;
55448
55719
  const target = (_b = link === null || link === void 0 ? void 0 : link.target) !== null && _b !== void 0 ? _b : attrs.target;
55449
55720
  if (link && href) {
55450
- if (view.editable) {
55451
- window.open(href, target);
55452
- }
55721
+ window.open(href, target);
55453
55722
  return true;
55454
55723
  }
55455
55724
  return false;
@@ -55463,7 +55732,6 @@ img.ProseMirror-separator {
55463
55732
  key: new PluginKey('handlePasteLink'),
55464
55733
  props: {
55465
55734
  handlePaste: (view, event, slice) => {
55466
- var _a;
55467
55735
  const { state } = view;
55468
55736
  const { selection } = state;
55469
55737
  const { empty } = selection;
@@ -55478,19 +55746,14 @@ img.ProseMirror-separator {
55478
55746
  if (!textContent || !link) {
55479
55747
  return false;
55480
55748
  }
55481
- const html = (_a = event.clipboardData) === null || _a === void 0 ? void 0 : _a.getData('text/html');
55482
- const hrefRegex = /href="([^"]*)"/;
55483
- const existingLink = html === null || html === void 0 ? void 0 : html.match(hrefRegex);
55484
- const url = existingLink ? existingLink[1] : link.href;
55485
55749
  options.editor.commands.setMark(options.type, {
55486
- href: url,
55750
+ href: link.href,
55487
55751
  });
55488
55752
  return true;
55489
55753
  },
55490
55754
  },
55491
55755
  });
55492
55756
  }
55493
-
55494
55757
  const Link = Mark.create({
55495
55758
  name: 'link',
55496
55759
  priority: 1000,
@@ -55575,32 +55838,44 @@ img.ProseMirror-separator {
55575
55838
  addPasteRules() {
55576
55839
  return [
55577
55840
  markPasteRule({
55578
- find: text => find$1(text)
55579
- .filter(link => {
55580
- if (this.options.validate) {
55581
- return this.options.validate(link.value);
55841
+ find: (text, event) => {
55842
+ var _a;
55843
+ const html = (_a = event === null || event === void 0 ? void 0 : event.clipboardData) === null || _a === void 0 ? void 0 : _a.getData('text/html');
55844
+ const foundLinks = [];
55845
+ if (html) {
55846
+ const dom = new DOMParser().parseFromString(html, 'text/html');
55847
+ const anchors = dom.querySelectorAll('a');
55848
+ if (anchors.length) {
55849
+ [...anchors].forEach(anchor => (foundLinks.push({
55850
+ text: anchor.innerText,
55851
+ data: {
55852
+ href: anchor.getAttribute('href'),
55853
+ },
55854
+ // get the index of the anchor inside the text
55855
+ // and add the length of the anchor text
55856
+ index: dom.body.innerText.indexOf(anchor.innerText) + anchor.innerText.length,
55857
+ })));
55858
+ }
55582
55859
  }
55583
- return true;
55584
- })
55585
- .filter(link => link.isLink)
55586
- .map(link => ({
55587
- text: link.value,
55588
- index: link.start,
55589
- data: link,
55590
- })),
55591
- type: this.type,
55592
- getAttributes: (match, pasteEvent) => {
55593
- var _a, _b;
55594
- const html = (_a = pasteEvent === null || pasteEvent === void 0 ? void 0 : pasteEvent.clipboardData) === null || _a === void 0 ? void 0 : _a.getData('text/html');
55595
- const hrefRegex = /href="([^"]*)"/;
55596
- const existingLink = html === null || html === void 0 ? void 0 : html.match(hrefRegex);
55597
- if (existingLink) {
55598
- return {
55599
- href: existingLink[1],
55600
- };
55860
+ if (text) {
55861
+ const links = find$1(text).filter(item => item.isLink);
55862
+ if (links.length) {
55863
+ links.forEach(link => (foundLinks.push({
55864
+ text: link.value,
55865
+ data: {
55866
+ href: link.href,
55867
+ },
55868
+ index: link.start,
55869
+ })));
55870
+ }
55601
55871
  }
55872
+ return foundLinks;
55873
+ },
55874
+ type: this.type,
55875
+ getAttributes: match => {
55876
+ var _a;
55602
55877
  return {
55603
- href: (_b = match.data) === null || _b === void 0 ? void 0 : _b.href,
55878
+ href: (_a = match.data) === null || _a === void 0 ? void 0 : _a.href,
55604
55879
  };
55605
55880
  },
55606
55881
  }),
@@ -55846,6 +56121,7 @@ img.ProseMirror-separator {
55846
56121
  emptyNodeClass: 'is-empty',
55847
56122
  placeholder: 'Write something …',
55848
56123
  showOnlyWhenEditable: true,
56124
+ considerAnyAsEmpty: false,
55849
56125
  showOnlyCurrent: true,
55850
56126
  includeChildren: false,
55851
56127
  };
@@ -55856,6 +56132,7 @@ img.ProseMirror-separator {
55856
56132
  key: new PluginKey('placeholder'),
55857
56133
  props: {
55858
56134
  decorations: ({ doc, selection }) => {
56135
+ var _a;
55859
56136
  const active = this.editor.isEditable || !this.options.showOnlyWhenEditable;
55860
56137
  const { anchor } = selection;
55861
56138
  const decorations = [];
@@ -55863,15 +56140,22 @@ img.ProseMirror-separator {
55863
56140
  return null;
55864
56141
  }
55865
56142
  // only calculate isEmpty once due to its performance impacts (see issue #3360)
55866
- const emptyDocInstance = doc.type.createAndFill();
55867
- const isEditorEmpty = (emptyDocInstance === null || emptyDocInstance === void 0 ? void 0 : emptyDocInstance.sameMarkup(doc))
55868
- && emptyDocInstance.content.findDiffStart(doc.content) === null;
56143
+ const { firstChild } = doc.content;
56144
+ const isLeaf = firstChild && firstChild.type.isLeaf;
56145
+ const isAtom = firstChild && firstChild.isAtom;
56146
+ const isValidNode = this.options.considerAnyAsEmpty
56147
+ ? true
56148
+ : firstChild && firstChild.type.name === ((_a = doc.type.contentMatch.defaultType) === null || _a === void 0 ? void 0 : _a.name);
56149
+ const isEmptyDoc = doc.content.childCount <= 1
56150
+ && firstChild
56151
+ && isValidNode
56152
+ && (firstChild.nodeSize <= 2 && (!isLeaf || !isAtom));
55869
56153
  doc.descendants((node, pos) => {
55870
56154
  const hasAnchor = anchor >= pos && anchor <= pos + node.nodeSize;
55871
56155
  const isEmpty = !node.isLeaf && !node.childCount;
55872
56156
  if ((hasAnchor || !this.options.showOnlyCurrent) && isEmpty) {
55873
56157
  const classes = [this.options.emptyNodeClass];
55874
- if (isEditorEmpty) {
56158
+ if (isEmptyDoc) {
55875
56159
  classes.push(this.options.emptyEditorClass);
55876
56160
  }
55877
56161
  const decoration = Decoration.node(pos, pos + node.nodeSize, {
@@ -56133,10 +56417,18 @@ img.ProseMirror-separator {
56133
56417
  addOptions() {
56134
56418
  return {
56135
56419
  HTMLAttributes: {},
56136
- renderLabel({ options, node }) {
56420
+ renderText({ options, node }) {
56137
56421
  var _a;
56138
56422
  return `${options.suggestion.char}${(_a = node.attrs.label) !== null && _a !== void 0 ? _a : node.attrs.id}`;
56139
56423
  },
56424
+ renderHTML({ options, node }) {
56425
+ var _a;
56426
+ return [
56427
+ 'span',
56428
+ this.HTMLAttributes,
56429
+ `${options.suggestion.char}${(_a = node.attrs.label) !== null && _a !== void 0 ? _a : node.attrs.id}`,
56430
+ ];
56431
+ },
56140
56432
  suggestion: {
56141
56433
  char: '@',
56142
56434
  pluginKey: MentionPluginKey,
@@ -56214,17 +56506,39 @@ img.ProseMirror-separator {
56214
56506
  ];
56215
56507
  },
56216
56508
  renderHTML({ node, HTMLAttributes }) {
56217
- return [
56218
- 'span',
56219
- mergeAttributes({ 'data-type': this.name }, this.options.HTMLAttributes, HTMLAttributes),
56220
- this.options.renderLabel({
56221
- options: this.options,
56222
- node,
56223
- }),
56224
- ];
56509
+ if (this.options.renderLabel !== undefined) {
56510
+ console.warn('renderLabel is deprecated use renderText and renderHTML instead');
56511
+ return [
56512
+ 'span',
56513
+ mergeAttributes({ 'data-type': this.name }, this.options.HTMLAttributes, HTMLAttributes),
56514
+ this.options.renderLabel({
56515
+ options: this.options,
56516
+ node,
56517
+ }),
56518
+ ];
56519
+ }
56520
+ const html = this.options.renderHTML({
56521
+ options: this.options,
56522
+ node,
56523
+ });
56524
+ if (typeof html === 'string') {
56525
+ return [
56526
+ 'span',
56527
+ mergeAttributes({ 'data-type': this.name }, this.options.HTMLAttributes, HTMLAttributes),
56528
+ html,
56529
+ ];
56530
+ }
56531
+ return html;
56225
56532
  },
56226
56533
  renderText({ node }) {
56227
- return this.options.renderLabel({
56534
+ if (this.options.renderLabel !== undefined) {
56535
+ console.warn('renderLabel is deprecated use renderText and renderHTML instead');
56536
+ return this.options.renderLabel({
56537
+ options: this.options,
56538
+ node,
56539
+ });
56540
+ }
56541
+ return this.options.renderText({
56228
56542
  options: this.options,
56229
56543
  node,
56230
56544
  });
@@ -56416,7 +56730,7 @@ img.ProseMirror-separator {
56416
56730
  return [
56417
56731
  config.viewElement,
56418
56732
  mergeAttributes(this.options.HTMLAttributes, HTMLAttributes),
56419
- this.options.renderLabel({
56733
+ this.options.renderText({
56420
56734
  options: this.options,
56421
56735
  node
56422
56736
  })
@@ -65379,24 +65693,11 @@ img.ProseMirror-separator {
65379
65693
  : TableRowSelectionState.notSelected;
65380
65694
  }
65381
65695
  getGroupedRowSelectionState(groupedRow) {
65382
- const leafRows = groupedRow.getLeafRows() ?? [];
65696
+ const leafRows = groupedRow.getLeafRows().filter(x => !x.getIsGrouped()) ?? [];
65383
65697
  let foundSelectedRow = false;
65384
65698
  let foundNotSelectedRow = false;
65385
65699
  for (const row of leafRows) {
65386
- if (row.getIsGrouped()) {
65387
- const subGroupRowSelectionState = this.getGroupedRowSelectionState(row);
65388
- switch (subGroupRowSelectionState) {
65389
- case TableRowSelectionState.notSelected:
65390
- foundNotSelectedRow = true;
65391
- break;
65392
- case TableRowSelectionState.selected:
65393
- foundSelectedRow = true;
65394
- break;
65395
- default:
65396
- return TableRowSelectionState.partiallySelected;
65397
- }
65398
- }
65399
- else if (row.getIsSelected()) {
65700
+ if (row.getIsSelected()) {
65400
65701
  foundSelectedRow = true;
65401
65702
  }
65402
65703
  else {