@ni/nimble-components 35.7.0 → 35.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.
@@ -39623,8 +39623,8 @@ so this becomes the fallback color for the slot */ ''}
39623
39623
  this.target = targetDesc && targetDesc.nodeDOM.nodeType == 1 ? targetDesc.nodeDOM : null;
39624
39624
  let { selection } = view.state;
39625
39625
  if (event.button == 0 &&
39626
- targetNode.type.spec.draggable && targetNode.type.spec.selectable !== false ||
39627
- selection instanceof NodeSelection && selection.from <= targetPos && selection.to > targetPos)
39626
+ (targetNode.type.spec.draggable && targetNode.type.spec.selectable !== false ||
39627
+ selection instanceof NodeSelection && selection.from <= targetPos && selection.to > targetPos))
39628
39628
  this.mightDrag = {
39629
39629
  node: targetNode,
39630
39630
  pos: targetPos,
@@ -39973,8 +39973,9 @@ so this becomes the fallback color for the slot */ ''}
39973
39973
  }
39974
39974
  const dragCopyModifier = mac$2 ? "altKey" : "ctrlKey";
39975
39975
  function dragMoves(view, event) {
39976
- let moves = view.someProp("dragCopies", test => !test(event));
39977
- return moves != null ? moves : !event[dragCopyModifier];
39976
+ let copy;
39977
+ view.someProp("dragCopies", test => { copy = copy || test(event); });
39978
+ return copy != null ? !copy : !event[dragCopyModifier];
39978
39979
  }
39979
39980
  handlers.dragstart = (view, _event) => {
39980
39981
  let event = _event;
@@ -40001,7 +40002,7 @@ so this becomes the fallback color for the slot */ ''}
40001
40002
  if (!event.dataTransfer.files.length || !chrome || chrome_version > 120)
40002
40003
  event.dataTransfer.clearData();
40003
40004
  event.dataTransfer.setData(brokenClipboardAPI ? "Text" : "text/html", dom.innerHTML);
40004
- // See https://github.com/ProseMirror/prosemirror/issues/1156
40005
+ // See https://code.haverbeke.berlin/prosemirror/prosemirror/issues/1156
40005
40006
  event.dataTransfer.effectAllowed = "copyMove";
40006
40007
  if (!brokenClipboardAPI)
40007
40008
  event.dataTransfer.setData("text/plain", text);
@@ -41626,7 +41627,7 @@ so this becomes the fallback color for the slot */ ''}
41626
41627
  this.pluginViews = [];
41627
41628
  /**
41628
41629
  Holds `true` when a hack node is needed in Firefox to prevent the
41629
- [space is eaten issue](https://github.com/ProseMirror/prosemirror/issues/651)
41630
+ [space is eaten issue](https://code.haverbeke.berlin/prosemirror/prosemirror/issues/651)
41630
41631
  @internal
41631
41632
  */
41632
41633
  this.requiresGeckoHackNode = false;
@@ -43167,7 +43168,7 @@ so this becomes the fallback color for the slot */ ''}
43167
43168
  const fromSelectionAtStart = $from.parentOffset === 0;
43168
43169
  const isTextSelection2 = $fromNode.isText || $fromNode.isTextblock;
43169
43170
  const hasContent = $fromNode.content.size > 0;
43170
- if (fromSelectionAtStart && isTextSelection2 && hasContent) {
43171
+ if (fromSelectionAtStart && isTextSelection2 && hasContent && isOnlyBlockContent) {
43171
43172
  from = Math.max(0, from - 1);
43172
43173
  }
43173
43174
  tr.replaceWith(from, to, newContent);
@@ -44784,6 +44785,16 @@ so this becomes the fallback color for the slot */ ''}
44784
44785
  tr.join(after);
44785
44786
  return true;
44786
44787
  };
44788
+ function createInnerSelectionForWholeDocList(tr) {
44789
+ const doc = tr.doc;
44790
+ const list = doc.firstChild;
44791
+ if (!list) {
44792
+ return null;
44793
+ }
44794
+ const $start = doc.resolve(1);
44795
+ const $end = doc.resolve(list.nodeSize - 1);
44796
+ return TextSelection.between($start, $end);
44797
+ }
44787
44798
  var toggleList = (listTypeOrName, itemTypeOrName, keepMarks, attributes = {}) => ({ editor, tr, state, dispatch, chain, commands, can }) => {
44788
44799
  const { extensions, splittableMarks } = editor.extensionManager;
44789
44800
  const listType = getNodeType(listTypeOrName, state.schema);
@@ -44796,13 +44807,35 @@ so this becomes the fallback color for the slot */ ''}
44796
44807
  return false;
44797
44808
  }
44798
44809
  const parentList = findParentNode((node) => isList(node.type.name, extensions))(selection);
44799
- if (range.depth >= 1 && parentList && range.depth - parentList.depth <= 1) {
44800
- if (parentList.node.type === listType) {
44810
+ const isAllSelection = selection.from === 0 && selection.to === state.doc.content.size;
44811
+ const topLevelNodes = state.doc.content.content;
44812
+ const soleTopLevelNode = topLevelNodes.length === 1 ? topLevelNodes[0] : null;
44813
+ const allSelectionList = isAllSelection && soleTopLevelNode && isList(soleTopLevelNode.type.name, extensions) ? {
44814
+ node: soleTopLevelNode,
44815
+ pos: 0} : null;
44816
+ const currentList = parentList != null ? parentList : allSelectionList;
44817
+ const isInsideExistingList = !!parentList && range.depth >= 1 && range.depth - parentList.depth <= 1;
44818
+ const hasWholeDocSelectedList = !!allSelectionList;
44819
+ if ((isInsideExistingList || hasWholeDocSelectedList) && currentList) {
44820
+ if (currentList.node.type === listType) {
44821
+ if (isAllSelection && hasWholeDocSelectedList) {
44822
+ return chain().command(({ tr: trx, dispatch: disp }) => {
44823
+ const nextSelection = createInnerSelectionForWholeDocList(trx);
44824
+ if (!nextSelection) {
44825
+ return false;
44826
+ }
44827
+ trx.setSelection(nextSelection);
44828
+ if (disp) {
44829
+ disp(trx);
44830
+ }
44831
+ return true;
44832
+ }).liftListItem(itemType).run();
44833
+ }
44801
44834
  return commands.liftListItem(itemType);
44802
44835
  }
44803
- if (isList(parentList.node.type.name, extensions) && listType.validContent(parentList.node.content) && dispatch) {
44836
+ if (isList(currentList.node.type.name, extensions) && listType.validContent(currentList.node.content)) {
44804
44837
  return chain().command(() => {
44805
- tr.setNodeMarkup(parentList.pos, listType);
44838
+ tr.setNodeMarkup(currentList.pos, listType);
44806
44839
  return true;
44807
44840
  }).command(() => joinListBackwards(tr, listType)).command(() => joinListForwards(tr, listType)).run();
44808
44841
  }
@@ -47883,7 +47916,10 @@ ${indentedChild}`;
47883
47916
  }
47884
47917
  markEnd = range.from + startSpaces + captureGroup.length;
47885
47918
  tr.addMark(range.from + startSpaces, markEnd, config.type.create(attributes || {}));
47886
- tr.removeStoredMark(config.type);
47919
+ const isMatchAtEndOfText = match.index !== void 0 && match.input !== void 0 && match.index + match[0].length >= match.input.length;
47920
+ if (!isMatchAtEndOfText) {
47921
+ tr.removeStoredMark(config.type);
47922
+ }
47887
47923
  }
47888
47924
  }
47889
47925
  });
@@ -61410,6 +61446,36 @@ ${indentedChild}`;
61410
61446
  // src/ordered-list/utils.ts
61411
61447
  var ORDERED_LIST_ITEM_REGEX = /^(\s*)(\d+)\.\s+(.*)$/;
61412
61448
  var INDENTED_LINE_REGEX = /^\s/;
61449
+ function isBlockContentLine(line) {
61450
+ const trimmedLine = line.trimStart();
61451
+ return /^[-+*]\s+/.test(trimmedLine) || /^\d+\.\s+/.test(trimmedLine) || /^>\s?/.test(trimmedLine) || /^```/.test(trimmedLine) || /^~~~/.test(trimmedLine);
61452
+ }
61453
+ function splitItemContent(contentLines) {
61454
+ const paragraphLines = [];
61455
+ const blockLines = [];
61456
+ let reachedBlockBoundary = false;
61457
+ contentLines.forEach((line) => {
61458
+ if (reachedBlockBoundary) {
61459
+ blockLines.push(line);
61460
+ return;
61461
+ }
61462
+ if (line.trim() === "") {
61463
+ reachedBlockBoundary = true;
61464
+ blockLines.push(line);
61465
+ return;
61466
+ }
61467
+ if (paragraphLines.length > 0 && isBlockContentLine(line)) {
61468
+ reachedBlockBoundary = true;
61469
+ blockLines.push(line);
61470
+ return;
61471
+ }
61472
+ paragraphLines.push(line);
61473
+ });
61474
+ return {
61475
+ paragraphLines,
61476
+ blockLines
61477
+ };
61478
+ }
61413
61479
  function collectOrderedListItems(lines) {
61414
61480
  const listItems = [];
61415
61481
  let currentLineIndex = 0;
@@ -61422,9 +61488,10 @@ ${indentedChild}`;
61422
61488
  }
61423
61489
  const [, indent, number, content] = match;
61424
61490
  const indentLevel = indent.length;
61425
- let itemContent = content;
61491
+ const itemContentLines = [content];
61426
61492
  let nextLineIndex = currentLineIndex + 1;
61427
61493
  const itemLines = [line];
61494
+ let sawBlankLine = false;
61428
61495
  while (nextLineIndex < lines.length) {
61429
61496
  const nextLine = lines[nextLineIndex];
61430
61497
  const nextMatch = nextLine.match(ORDERED_LIST_ITEM_REGEX);
@@ -61433,21 +61500,27 @@ ${indentedChild}`;
61433
61500
  }
61434
61501
  if (nextLine.trim() === "") {
61435
61502
  itemLines.push(nextLine);
61436
- itemContent += "\n";
61503
+ itemContentLines.push("");
61504
+ sawBlankLine = true;
61437
61505
  nextLineIndex += 1;
61438
61506
  } else if (nextLine.match(INDENTED_LINE_REGEX)) {
61439
61507
  itemLines.push(nextLine);
61440
- itemContent += `
61441
- ${nextLine.slice(indentLevel + 2)}`;
61508
+ itemContentLines.push(nextLine.slice(indentLevel + 2));
61442
61509
  nextLineIndex += 1;
61443
61510
  } else {
61444
- break;
61511
+ if (sawBlankLine) {
61512
+ break;
61513
+ }
61514
+ itemLines.push(nextLine);
61515
+ itemContentLines.push(nextLine);
61516
+ nextLineIndex += 1;
61445
61517
  }
61446
61518
  }
61447
61519
  listItems.push({
61448
61520
  indent: indentLevel,
61449
61521
  number: parseInt(number, 10),
61450
- content: itemContent.trim(),
61522
+ content: itemContentLines.join("\n").trim(),
61523
+ contentLines: itemContentLines,
61451
61524
  raw: itemLines.join("\n")
61452
61525
  });
61453
61526
  consumed = nextLineIndex;
@@ -61456,14 +61529,13 @@ ${nextLine.slice(indentLevel + 2)}`;
61456
61529
  return [listItems, consumed];
61457
61530
  }
61458
61531
  function buildNestedStructure(items, baseIndent, lexer) {
61459
- var _a;
61460
61532
  const result = [];
61461
61533
  let currentIndex = 0;
61462
61534
  while (currentIndex < items.length) {
61463
61535
  const item = items[currentIndex];
61464
61536
  if (item.indent === baseIndent) {
61465
- const contentLines = item.content.split("\n");
61466
- const mainText = ((_a = contentLines[0]) == null ? void 0 : _a.trim()) || "";
61537
+ const { paragraphLines, blockLines } = splitItemContent(item.contentLines);
61538
+ const mainText = paragraphLines.join("\n").trim();
61467
61539
  const tokens = [];
61468
61540
  if (mainText) {
61469
61541
  tokens.push({
@@ -61472,7 +61544,7 @@ ${nextLine.slice(indentLevel + 2)}`;
61472
61544
  tokens: lexer.inlineTokens(mainText)
61473
61545
  });
61474
61546
  }
61475
- const additionalContent = contentLines.slice(1).join("\n").trim();
61547
+ const additionalContent = blockLines.join("\n").trim();
61476
61548
  if (additionalContent) {
61477
61549
  const blockTokens = lexer.blockTokens(additionalContent);
61478
61550
  tokens.push(...blockTokens);
@@ -72944,6 +73016,7 @@ focus outline in that case.
72944
73016
  isRtl: false,
72945
73017
  useScrollendEvent: false,
72946
73018
  useAnimationFrameWithResizeObserver: false,
73019
+ laneAssignmentMode: "estimate",
72947
73020
  ...opts2
72948
73021
  };
72949
73022
  };
@@ -73083,9 +73156,10 @@ focus outline in that case.
73083
73156
  this.options.scrollMargin,
73084
73157
  this.options.getItemKey,
73085
73158
  this.options.enabled,
73086
- this.options.lanes
73159
+ this.options.lanes,
73160
+ this.options.laneAssignmentMode
73087
73161
  ],
73088
- (count, paddingStart, scrollMargin, getItemKey, enabled, lanes) => {
73162
+ (count, paddingStart, scrollMargin, getItemKey, enabled, lanes, laneAssignmentMode) => {
73089
73163
  const lanesChanged = this.prevLanes !== void 0 && this.prevLanes !== lanes;
73090
73164
  if (lanesChanged) {
73091
73165
  this.lanesChangedFlag = true;
@@ -73098,7 +73172,8 @@ focus outline in that case.
73098
73172
  scrollMargin,
73099
73173
  getItemKey,
73100
73174
  enabled,
73101
- lanes
73175
+ lanes,
73176
+ laneAssignmentMode
73102
73177
  };
73103
73178
  },
73104
73179
  {
@@ -73107,7 +73182,15 @@ focus outline in that case.
73107
73182
  );
73108
73183
  this.getMeasurements = memo(
73109
73184
  () => [this.getMeasurementOptions(), this.itemSizeCache],
73110
- ({ count, paddingStart, scrollMargin, getItemKey, enabled, lanes }, itemSizeCache) => {
73185
+ ({
73186
+ count,
73187
+ paddingStart,
73188
+ scrollMargin,
73189
+ getItemKey,
73190
+ enabled,
73191
+ lanes,
73192
+ laneAssignmentMode
73193
+ }, itemSizeCache) => {
73111
73194
  if (!enabled) {
73112
73195
  this.measurementsCache = [];
73113
73196
  this.itemSizeCache.clear();
@@ -73155,6 +73238,7 @@ focus outline in that case.
73155
73238
  const cachedLane = this.laneAssignments.get(i);
73156
73239
  let lane;
73157
73240
  let start;
73241
+ const shouldCacheLane = laneAssignmentMode === "estimate" || itemSizeCache.has(key);
73158
73242
  if (cachedLane !== void 0 && this.options.lanes > 1) {
73159
73243
  lane = cachedLane;
73160
73244
  const prevIndex = laneLastIndex[lane];
@@ -73164,7 +73248,7 @@ focus outline in that case.
73164
73248
  const furthestMeasurement = this.options.lanes === 1 ? measurements[i - 1] : this.getFurthestMeasurement(measurements, i);
73165
73249
  start = furthestMeasurement ? furthestMeasurement.end + this.options.gap : paddingStart + scrollMargin;
73166
73250
  lane = furthestMeasurement ? furthestMeasurement.lane : i % this.options.lanes;
73167
- if (this.options.lanes > 1) {
73251
+ if (this.options.lanes > 1 && shouldCacheLane) {
73168
73252
  this.laneAssignments.set(i, lane);
73169
73253
  }
73170
73254
  }