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