@ni/spright-components 6.19.0 → 6.19.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.
@@ -14893,6 +14893,7 @@
14893
14893
  calendarEventBackgroundTransportOrderColor: 'calendar-event-background-transport-order-color',
14894
14894
  calendarEventBackgroundHoverTransportOrderColor: 'calendar-event-background-hover-transport-order-color',
14895
14895
  calendarEventBorderTransportOrderColor: 'calendar-event-border-transport-order-color',
14896
+ calendarEventBorderWorkOrderColor: 'calendar-event-border-work-order-color',
14896
14897
  calendarEventBackgroundAggregateAvailabilityColor: 'calendar-event-background-aggregate-availability-color',
14897
14898
  calendarEventBorderAggregateAvailabilityColor: 'calendar-event-border-aggregate-availability-color'
14898
14899
  };
@@ -16387,6 +16388,7 @@
16387
16388
  calendarEventBackgroundTransportOrderColor: createThemeColor(BrownLight10, BrownDark10, BrownDark10),
16388
16389
  calendarEventBackgroundHoverTransportOrderColor: createThemeColor(BrownLight20, BrownDark20, BrownDark20),
16389
16390
  calendarEventBorderTransportOrderColor: createThemeColor(BrownLight, BrownDark, BrownDark),
16391
+ calendarEventBorderWorkOrderColor: createThemeColor(NiIndigo, NiIndigo, NiIndigo),
16390
16392
  calendarEventBackgroundAggregateAvailabilityColor: createThemeColor(Black91V10, Black82, Black82),
16391
16393
  calendarEventBorderAggregateAvailabilityColor: hexToRgbaCssThemeColor(createThemeColor(Black91, Black82V100, Black82V100), 0.5, 1, 1),
16392
16394
  controlHeight: '32px',
@@ -16563,6 +16565,7 @@
16563
16565
  createThemeColorToken(tokenNames.calendarEventBackgroundTransportOrderColor, tokenValues.calendarEventBackgroundTransportOrderColor);
16564
16566
  createThemeColorToken(tokenNames.calendarEventBackgroundHoverTransportOrderColor, tokenValues.calendarEventBackgroundHoverTransportOrderColor);
16565
16567
  const calendarEventBorderTransportOrderColor = createThemeColorToken(tokenNames.calendarEventBorderTransportOrderColor, tokenValues.calendarEventBorderTransportOrderColor);
16568
+ createThemeColorToken(tokenNames.calendarEventBorderWorkOrderColor, tokenValues.calendarEventBorderWorkOrderColor);
16566
16569
  createThemeColorToken(tokenNames.calendarEventBackgroundAggregateAvailabilityColor, tokenValues.calendarEventBackgroundAggregateAvailabilityColor);
16567
16570
  createThemeColorToken(tokenNames.calendarEventBorderAggregateAvailabilityColor, tokenValues.calendarEventBorderAggregateAvailabilityColor);
16568
16571
  // #endregion
@@ -29158,7 +29161,7 @@ so this becomes the fallback color for the slot */ ''}
29158
29161
  return Fragment.empty;
29159
29162
  if (!Array.isArray(value))
29160
29163
  throw new RangeError("Invalid input for Fragment.fromJSON");
29161
- return new Fragment(value.map(schema.nodeFromJSON));
29164
+ return Fragment.fromArray(value.map(schema.nodeFromJSON));
29162
29165
  }
29163
29166
  /**
29164
29167
  Build a fragment from an array of nodes. Ensures that adjacent
@@ -29392,17 +29395,6 @@ so this becomes the fallback color for the slot */ ''}
29392
29395
  */
29393
29396
  class ReplaceError extends Error {
29394
29397
  }
29395
- /*
29396
- ReplaceError = function(this: any, message: string) {
29397
- let err = Error.call(this, message)
29398
- ;(err as any).__proto__ = ReplaceError.prototype
29399
- return err
29400
- } as any
29401
-
29402
- ReplaceError.prototype = Object.create(Error.prototype)
29403
- ReplaceError.prototype.constructor = ReplaceError
29404
- ReplaceError.prototype.name = "ReplaceError"
29405
- */
29406
29398
  /**
29407
29399
  A slice represents a piece cut out of a larger document. It
29408
29400
  stores not only a fragment, but also the depth up to which nodes on
@@ -29448,7 +29440,7 @@ so this becomes the fallback color for the slot */ ''}
29448
29440
  @internal
29449
29441
  */
29450
29442
  insertAt(pos, fragment) {
29451
- let content = insertInto(this.content, pos + this.openStart, fragment);
29443
+ let content = insertInto(this.content, pos + this.openStart, fragment, this.openStart + 1, this.openEnd + 1);
29452
29444
  return content && new Slice(content, this.openStart, this.openEnd);
29453
29445
  }
29454
29446
  /**
@@ -29522,14 +29514,14 @@ so this becomes the fallback color for the slot */ ''}
29522
29514
  throw new RangeError("Removing non-flat range");
29523
29515
  return content.replaceChild(index, child.copy(removeRange(child.content, from - offset - 1, to - offset - 1)));
29524
29516
  }
29525
- function insertInto(content, dist, insert, parent) {
29517
+ function insertInto(content, dist, insert, openStart, openEnd, parent) {
29526
29518
  let { index, offset } = content.findIndex(dist), child = content.maybeChild(index);
29527
29519
  if (offset == dist || child.isText) {
29528
- if (parent && !parent.canReplace(index, index, insert))
29520
+ if (parent && openStart <= 0 && openEnd <= 0 && !parent.canReplace(index, index, insert))
29529
29521
  return null;
29530
29522
  return content.cut(0, dist).append(insert).append(content.cut(dist));
29531
29523
  }
29532
- let inner = insertInto(child.content, dist - offset - 1, insert, child);
29524
+ let inner = insertInto(child.content, dist - offset - 1, insert, index == 0 ? openStart - 1 : 0, index == content.childCount - 1 ? openEnd - 1 : 0, child);
29533
29525
  return inner && content.replaceChild(index, child.copy(inner));
29534
29526
  }
29535
29527
  function replace$1($from, $to, slice) {
@@ -30059,10 +30051,11 @@ so this becomes the fallback color for the slot */ ''}
30059
30051
  */
30060
30052
  forEach(f) { this.content.forEach(f); }
30061
30053
  /**
30062
- Invoke a callback for all descendant nodes recursively between
30054
+ Invoke a callback for all descendant nodes recursively overlapping
30063
30055
  the given two positions that are relative to start of this
30064
- node's content. The callback is invoked with the node, its
30065
- position relative to the original node (method receiver),
30056
+ node's content. This includes all ancestors of the nodes
30057
+ containing the two positions. The callback is invoked with the
30058
+ node, its position relative to the original node (method receiver),
30066
30059
  its parent node, and its child index. When the callback returns
30067
30060
  false for a given node, that node's children will not be
30068
30061
  recursed over. The last parameter can be used to specify a
@@ -32150,6 +32143,8 @@ so this becomes the fallback color for the slot */ ''}
32150
32143
  @internal
32151
32144
  */
32152
32145
  serializeNodeInner(node, options) {
32146
+ if (node.isText)
32147
+ return doc$1(options).createTextNode(node.text);
32153
32148
  let { dom, contentDOM } = renderSpec(doc$1(options), this.nodes[node.type.name](node), null, node.attrs);
32154
32149
  if (contentDOM) {
32155
32150
  if (node.isLeaf)
@@ -32184,6 +32179,9 @@ so this becomes the fallback color for the slot */ ''}
32184
32179
  return toDOM && renderSpec(doc$1(options), toDOM(mark, inline), null, mark.attrs);
32185
32180
  }
32186
32181
  static renderSpec(doc, structure, xmlNS = null, blockArraysIn) {
32182
+ // Kludge for backwards-compatibility with accidental original behavious
32183
+ if (typeof structure == "string")
32184
+ return { dom: doc.createTextNode(structure) };
32187
32185
  return renderSpec(doc, structure, xmlNS, blockArraysIn);
32188
32186
  }
32189
32187
  /**
@@ -32255,11 +32253,9 @@ so this becomes the fallback color for the slot */ ''}
32255
32253
  return result;
32256
32254
  }
32257
32255
  function renderSpec(doc, structure, xmlNS, blockArraysIn) {
32258
- if (typeof structure == "string")
32259
- return { dom: doc.createTextNode(structure) };
32260
- if (structure.nodeType != null)
32256
+ if (structure.nodeType == 1)
32261
32257
  return { dom: structure };
32262
- if (structure.dom && structure.dom.nodeType != null)
32258
+ if (structure.dom && structure.dom.nodeType == 1)
32263
32259
  return structure;
32264
32260
  let tagName = structure[0], suspicious;
32265
32261
  if (typeof tagName != "string")
@@ -32295,6 +32291,9 @@ so this becomes the fallback color for the slot */ ''}
32295
32291
  throw new RangeError("Content hole must be the only child of its parent node");
32296
32292
  return { dom, contentDOM: dom };
32297
32293
  }
32294
+ else if (typeof child == "string") {
32295
+ dom.appendChild(doc.createTextNode(child));
32296
+ }
32298
32297
  else {
32299
32298
  let { dom: inner, contentDOM: innerContent } = renderSpec(doc, child, xmlNS, blockArraysIn);
32300
32299
  dom.appendChild(inner);
@@ -42775,8 +42774,44 @@ so this becomes the fallback color for the slot */ ''}
42775
42774
  }
42776
42775
  return true;
42777
42776
  };
42777
+
42778
+ // src/commands/deleteSelection.ts
42779
+ var hasTextContent = (nodeSpec) => {
42780
+ if (!nodeSpec.content) {
42781
+ return false;
42782
+ }
42783
+ const textRegex = /^text(\*|\+)/;
42784
+ return textRegex.test(nodeSpec.content);
42785
+ };
42786
+ var expandSelectionForSide = ($pos, schema, side) => {
42787
+ if (!$pos.parent.isInline) {
42788
+ return $pos.pos;
42789
+ }
42790
+ if (side === "left" && $pos.pos > $pos.start() || side === "right" && $pos.pos < $pos.end()) {
42791
+ return $pos.pos;
42792
+ }
42793
+ const parentContent = schema.nodes[$pos.parent.type.name].spec;
42794
+ if (!hasTextContent(parentContent)) {
42795
+ return $pos.pos;
42796
+ }
42797
+ return side === "left" ? $pos.start() - 1 : $pos.end() + 1;
42798
+ };
42799
+ var expandSelectionForInlineText = ($from, $to, schema) => {
42800
+ const from = expandSelectionForSide($from, schema, "left");
42801
+ const to = expandSelectionForSide($to, schema, "right");
42802
+ return { from, to };
42803
+ };
42778
42804
  var deleteSelection = () => ({ state, dispatch }) => {
42779
- return deleteSelection$1(state, dispatch);
42805
+ const { $from, $to } = state.selection;
42806
+ if (state.selection.empty) {
42807
+ return false;
42808
+ }
42809
+ const { from, to } = expandSelectionForInlineText($from, $to, state.schema);
42810
+ if (dispatch) {
42811
+ state.tr.deleteRange(from, to).scrollIntoView();
42812
+ dispatch(state.tr);
42813
+ }
42814
+ return true;
42780
42815
  };
42781
42816
 
42782
42817
  // src/commands/enter.ts
@@ -45436,6 +45471,7 @@ so this becomes the fallback color for the slot */ ''}
45436
45471
  });
45437
45472
  extension.name = this.name;
45438
45473
  extension.parent = this.parent;
45474
+ this.child = null;
45439
45475
  return extension;
45440
45476
  }
45441
45477
  extend(extendedConfig = {}) {
@@ -45971,6 +46007,36 @@ so this becomes the fallback color for the slot */ ''}
45971
46007
  })
45972
46008
  );
45973
46009
  }
46010
+ /**
46011
+ * Destroy the extension manager and clean up all extension references
46012
+ * to prevent memory leaks through parent/child extension chains.
46013
+ *
46014
+ * Walks each extension's full parent chain and nulls every forward
46015
+ * `parent.child → current` link where the parent still points to the
46016
+ * current node. This breaks the retention path from module-scope
46017
+ * singleton roots through deep extend() chains.
46018
+ *
46019
+ * Only ancestor `.child` links matching the current chain are cleared.
46020
+ * The `.parent` pointer on ancestors is never touched — extensions
46021
+ * may be shared across live editors, so their own backward references
46022
+ * and non-matching forward links must remain intact.
46023
+ */
46024
+ destroy() {
46025
+ this.extensions.forEach((extension) => {
46026
+ let current = extension;
46027
+ while (current.parent) {
46028
+ const parent = current.parent;
46029
+ if (parent.child === current) {
46030
+ parent.child = null;
46031
+ }
46032
+ current = parent;
46033
+ }
46034
+ });
46035
+ this.extensions = [];
46036
+ this.baseExtensions = [];
46037
+ this.schema = null;
46038
+ this.editor = null;
46039
+ }
45974
46040
  /**
45975
46041
  * Go through all extensions, create extension storages & setup marks
45976
46042
  * & bind editor event listener.
@@ -46384,12 +46450,23 @@ so this becomes the fallback color for the slot */ ''}
46384
46450
  });
46385
46451
  var Tabindex = Extension.create({
46386
46452
  name: "tabindex",
46453
+ addOptions() {
46454
+ return {
46455
+ value: void 0
46456
+ };
46457
+ },
46387
46458
  addProseMirrorPlugins() {
46388
46459
  return [
46389
46460
  new Plugin({
46390
46461
  key: new PluginKey("tabindex"),
46391
46462
  props: {
46392
- attributes: () => this.editor.isEditable ? { tabindex: "0" } : {}
46463
+ attributes: () => {
46464
+ var _a;
46465
+ if (!this.editor.isEditable && this.options.value === void 0) {
46466
+ return {};
46467
+ }
46468
+ return { tabindex: (_a = this.options.value) != null ? _a : "0" };
46469
+ }
46393
46470
  }
46394
46471
  })
46395
46472
  ];
@@ -46728,6 +46805,7 @@ img.ProseMirror-separator {
46728
46805
  this.className = "tiptap";
46729
46806
  this.editorView = null;
46730
46807
  this.isFocused = false;
46808
+ this.destroyed = false;
46731
46809
  /**
46732
46810
  * The editor is considered initialized after the `create` event has been emitted.
46733
46811
  */
@@ -47019,7 +47097,7 @@ img.ProseMirror-separator {
47019
47097
  * Creates an extension manager.
47020
47098
  */
47021
47099
  createExtensionManager() {
47022
- var _a, _b;
47100
+ var _a, _b, _c, _d;
47023
47101
  const coreExtensions = this.options.enableCoreExtensions ? [
47024
47102
  Editable,
47025
47103
  ClipboardTextSerializer.configure({
@@ -47028,7 +47106,9 @@ img.ProseMirror-separator {
47028
47106
  Commands,
47029
47107
  FocusEvents,
47030
47108
  Keymap,
47031
- Tabindex,
47109
+ Tabindex.configure({
47110
+ value: (_d = (_c = this.options.coreExtensionOptions) == null ? void 0 : _c.tabindex) == null ? void 0 : _d.value
47111
+ }),
47032
47112
  Drop,
47033
47113
  Paste,
47034
47114
  Delete,
@@ -47265,9 +47345,18 @@ img.ProseMirror-separator {
47265
47345
  * Destroy the editor.
47266
47346
  */
47267
47347
  destroy() {
47348
+ if (this.destroyed) {
47349
+ return;
47350
+ }
47351
+ this.destroyed = true;
47268
47352
  this.emit("destroy");
47269
47353
  this.unmount();
47270
47354
  this.removeAllListeners();
47355
+ this.extensionManager.destroy();
47356
+ this.extensionManager = null;
47357
+ this.schema = null;
47358
+ this.commandManager = null;
47359
+ this.extensionStorage = {};
47271
47360
  }
47272
47361
  /**
47273
47362
  * Check if the editor is already destroyed.
@@ -47286,7 +47375,8 @@ img.ProseMirror-separator {
47286
47375
  }
47287
47376
  $pos(pos) {
47288
47377
  const $pos = this.state.doc.resolve(pos);
47289
- return new NodePos($pos, this);
47378
+ const node = pos > 0 && $pos.nodeAfter && !$pos.nodeAfter.isText ? $pos.nodeAfter : null;
47379
+ return new NodePos($pos, this, false, node);
47290
47380
  }
47291
47381
  get $doc() {
47292
47382
  return this.$pos(0);
@@ -49884,6 +49974,15 @@ ${indentedChild}`;
49884
49974
  function decodeHTML(str, mode = DecodingMode.Legacy) {
49885
49975
  return htmlDecoder(str, mode);
49886
49976
  }
49977
+ /**
49978
+ * Decodes an HTML string, requiring all entities to be terminated by a semicolon.
49979
+ *
49980
+ * @param str The string to decode.
49981
+ * @returns The decoded string.
49982
+ */
49983
+ function decodeHTMLStrict(str) {
49984
+ return htmlDecoder(str, DecodingMode.Strict);
49985
+ }
49887
49986
 
49888
49987
  // Utilities
49889
49988
  //
@@ -50063,6 +50162,10 @@ ${indentedChild}`;
50063
50162
  return P.test(ch) || regex.test(ch)
50064
50163
  }
50065
50164
 
50165
+ function isPunctCharCode (code) {
50166
+ return isPunctChar(fromCodePoint(code))
50167
+ }
50168
+
50066
50169
  // Markdown ASCII punctuation characters.
50067
50170
  //
50068
50171
  // !, ", #, $, %, &, ', (, ), *, +, ,, -, ., /, :, ;, <, =, >, ?, @, [, \, ], ^, _, `, {, |, }, or ~
@@ -50124,6 +50227,7 @@ ${indentedChild}`;
50124
50227
  // (remove this when node v10 is no longer supported).
50125
50228
  //
50126
50229
  if ('ẞ'.toLowerCase() === 'Ṿ') {
50230
+ /* c8 ignore next 2 */
50127
50231
  str = str.replace(/ẞ/g, 'ß');
50128
50232
  }
50129
50233
 
@@ -50162,6 +50266,28 @@ ${indentedChild}`;
50162
50266
  return str.toLowerCase().toUpperCase()
50163
50267
  }
50164
50268
 
50269
+ function isAsciiTrimmable (c) {
50270
+ return c === 0x20 || c === 0x09 || c === 0x0a || c === 0x0d
50271
+ }
50272
+
50273
+ // "Light" .trim() for blocks (headers, paragraphs), where unicode spaces
50274
+ // should be preserved.
50275
+ function asciiTrim (str) {
50276
+ let start = 0;
50277
+ for (; start < str.length; start++) {
50278
+ if (!isAsciiTrimmable(str.charCodeAt(start))) {
50279
+ break
50280
+ }
50281
+ }
50282
+ let end = str.length - 1;
50283
+ for (; end >= start; end--) {
50284
+ if (!isAsciiTrimmable(str.charCodeAt(end))) {
50285
+ break
50286
+ }
50287
+ }
50288
+ return str.slice(start, end + 1)
50289
+ }
50290
+
50165
50291
  // Re-export libraries commonly used in both markdown-it and its plugins,
50166
50292
  // so plugins won't have to depend on them explicitly, which reduces their
50167
50293
  // bundled size (e.g. a browser build).
@@ -50171,6 +50297,7 @@ ${indentedChild}`;
50171
50297
  var utils = /*#__PURE__*/Object.freeze({
50172
50298
  __proto__: null,
50173
50299
  arrayReplaceAt: arrayReplaceAt,
50300
+ asciiTrim: asciiTrim,
50174
50301
  assign: assign$1,
50175
50302
  escapeHtml: escapeHtml,
50176
50303
  escapeRE: escapeRE$1,
@@ -50178,6 +50305,7 @@ ${indentedChild}`;
50178
50305
  has: has,
50179
50306
  isMdAsciiPunct: isMdAsciiPunct,
50180
50307
  isPunctChar: isPunctChar,
50308
+ isPunctCharCode: isPunctCharCode,
50181
50309
  isSpace: isSpace,
50182
50310
  isString: isString$1,
50183
50311
  isValidEntityCode: isValidEntityCode,
@@ -51541,14 +51669,36 @@ ${indentedChild}`;
51541
51669
  const QUOTE_RE = /['"]/g;
51542
51670
  const APOSTROPHE$1 = '\u2019'; /* ’ */
51543
51671
 
51544
- function replaceAt (str, index, ch) {
51545
- return str.slice(0, index) + ch + str.slice(index + 1)
51672
+ function addReplacement (replacements, tokenIdx, pos, ch) {
51673
+ if (!replacements[tokenIdx]) {
51674
+ replacements[tokenIdx] = [];
51675
+ }
51676
+
51677
+ replacements[tokenIdx].push({ pos, ch });
51678
+ }
51679
+
51680
+ function applyReplacements (str, replacements) {
51681
+ let result = '';
51682
+ let lastPos = 0;
51683
+
51684
+ replacements.sort((a, b) => a.pos - b.pos);
51685
+
51686
+ for (let i = 0; i < replacements.length; i++) {
51687
+ const replacement = replacements[i];
51688
+
51689
+ result += str.slice(lastPos, replacement.pos) + replacement.ch;
51690
+ lastPos = replacement.pos + 1;
51691
+ }
51692
+
51693
+ return result + str.slice(lastPos)
51546
51694
  }
51547
51695
 
51548
51696
  function process_inlines (tokens, state) {
51549
51697
  let j;
51550
51698
 
51551
51699
  const stack = [];
51700
+ // token index -> list of replacements in the original token content
51701
+ const replacements = {};
51552
51702
 
51553
51703
  for (let i = 0; i < tokens.length; i++) {
51554
51704
  const token = tokens[i];
@@ -51562,9 +51712,9 @@ ${indentedChild}`;
51562
51712
 
51563
51713
  if (token.type !== 'text') { continue }
51564
51714
 
51565
- let text = token.content;
51715
+ const text = token.content;
51566
51716
  let pos = 0;
51567
- let max = text.length;
51717
+ const max = text.length;
51568
51718
 
51569
51719
  /* eslint no-labels:0,block-scoped-var:0 */
51570
51720
  OUTER:
@@ -51612,8 +51762,8 @@ ${indentedChild}`;
51612
51762
  }
51613
51763
  }
51614
51764
 
51615
- const isLastPunctChar = isMdAsciiPunct(lastChar) || isPunctChar(String.fromCharCode(lastChar));
51616
- const isNextPunctChar = isMdAsciiPunct(nextChar) || isPunctChar(String.fromCharCode(nextChar));
51765
+ const isLastPunctChar = isMdAsciiPunct(lastChar) || isPunctCharCode(lastChar);
51766
+ const isNextPunctChar = isMdAsciiPunct(nextChar) || isPunctCharCode(nextChar);
51617
51767
 
51618
51768
  const isLastWhiteSpace = isWhiteSpace(lastChar);
51619
51769
  const isNextWhiteSpace = isWhiteSpace(nextChar);
@@ -51656,7 +51806,7 @@ ${indentedChild}`;
51656
51806
  if (!canOpen && !canClose) {
51657
51807
  // middle of word
51658
51808
  if (isSingle) {
51659
- token.content = replaceAt(token.content, t.index, APOSTROPHE$1);
51809
+ addReplacement(replacements, i, t.index, APOSTROPHE$1);
51660
51810
  }
51661
51811
  continue
51662
51812
  }
@@ -51679,18 +51829,8 @@ ${indentedChild}`;
51679
51829
  closeQuote = state.md.options.quotes[1];
51680
51830
  }
51681
51831
 
51682
- // replace token.content *before* tokens[item.token].content,
51683
- // because, if they are pointing at the same token, replaceAt
51684
- // could mess up indices when quote length != 1
51685
- token.content = replaceAt(token.content, t.index, closeQuote);
51686
- tokens[item.token].content = replaceAt(
51687
- tokens[item.token].content, item.pos, openQuote);
51688
-
51689
- pos += closeQuote.length - 1;
51690
- if (item.token === i) { pos += openQuote.length - 1; }
51691
-
51692
- text = token.content;
51693
- max = text.length;
51832
+ addReplacement(replacements, i, t.index, closeQuote);
51833
+ addReplacement(replacements, item.token, item.pos, openQuote);
51694
51834
 
51695
51835
  stack.length = j;
51696
51836
  continue OUTER
@@ -51706,10 +51846,14 @@ ${indentedChild}`;
51706
51846
  level: thisLevel
51707
51847
  });
51708
51848
  } else if (canClose && isSingle) {
51709
- token.content = replaceAt(token.content, t.index, APOSTROPHE$1);
51849
+ addReplacement(replacements, i, t.index, APOSTROPHE$1);
51710
51850
  }
51711
51851
  }
51712
51852
  }
51853
+
51854
+ Object.keys(replacements).forEach(function (tokenIdx) {
51855
+ tokens[tokenIdx].content = applyReplacements(tokens[tokenIdx].content, replacements[tokenIdx]);
51856
+ });
51713
51857
  }
51714
51858
 
51715
51859
  function smartquotes (state) {
@@ -53313,11 +53457,22 @@ ${indentedChild}`;
53313
53457
 
53314
53458
  let nextLine = startLine + 1;
53315
53459
 
53460
+ // Block types 6 and 7 (the only ones whose end condition is a blank line)
53461
+ // have `/^$/` as their closing regexp. For all other types (1-5, e.g.
53462
+ // `<!--` comments), a blank line is regular content and must not terminate
53463
+ // the block - it ends only when its closing sequence is found.
53464
+ const endsOnBlankLine = HTML_SEQUENCES[i][1].test('');
53465
+
53316
53466
  // If we are here - we detected HTML block.
53317
53467
  // Let's roll down till block end.
53318
53468
  if (!HTML_SEQUENCES[i][1].test(lineText)) {
53319
53469
  for (; nextLine < endLine; nextLine++) {
53320
- if (state.sCount[nextLine] < state.blkIndent) { break }
53470
+ if (state.sCount[nextLine] < state.blkIndent) {
53471
+ // An outdented blank line shouldn't end a block that doesn't end on a
53472
+ // blank line (e.g. a `<!--` comment inside a list item). Such blocks
53473
+ // must continue until their closing sequence regardless of indent.
53474
+ if (endsOnBlankLine || !state.isEmpty(nextLine)) { break }
53475
+ }
53321
53476
 
53322
53477
  pos = state.bMarks[nextLine] + state.tShift[nextLine];
53323
53478
  max = state.eMarks[nextLine];
@@ -53380,7 +53535,7 @@ ${indentedChild}`;
53380
53535
  token_o.map = [startLine, state.line];
53381
53536
 
53382
53537
  const token_i = state.push('inline', '', 0);
53383
- token_i.content = state.src.slice(pos, max).trim();
53538
+ token_i.content = asciiTrim(state.src.slice(pos, max));
53384
53539
  token_i.map = [startLine, state.line];
53385
53540
  token_i.children = [];
53386
53541
 
@@ -53392,6 +53547,7 @@ ${indentedChild}`;
53392
53547
 
53393
53548
  // lheading (---, ===)
53394
53549
 
53550
+
53395
53551
  function lheading (state, startLine, endLine/*, silent */) {
53396
53552
  const terminatorRules = state.md.block.ruler.getRules('paragraph');
53397
53553
 
@@ -53449,10 +53605,11 @@ ${indentedChild}`;
53449
53605
 
53450
53606
  if (!level) {
53451
53607
  // Didn't find valid underline
53608
+ state.parentType = oldParentType;
53452
53609
  return false
53453
53610
  }
53454
53611
 
53455
- const content = state.getLines(startLine, nextLine, state.blkIndent, false).trim();
53612
+ const content = asciiTrim(state.getLines(startLine, nextLine, state.blkIndent, false));
53456
53613
 
53457
53614
  state.line = nextLine + 1;
53458
53615
 
@@ -53475,6 +53632,7 @@ ${indentedChild}`;
53475
53632
 
53476
53633
  // Paragraph
53477
53634
 
53635
+
53478
53636
  function paragraph (state, startLine, endLine) {
53479
53637
  const terminatorRules = state.md.block.ruler.getRules('paragraph');
53480
53638
  const oldParentType = state.parentType;
@@ -53501,7 +53659,7 @@ ${indentedChild}`;
53501
53659
  if (terminate) { break }
53502
53660
  }
53503
53661
 
53504
- const content = state.getLines(startLine, nextLine, state.blkIndent, false).trim();
53662
+ const content = asciiTrim(state.getLines(startLine, nextLine, state.blkIndent, false));
53505
53663
 
53506
53664
  state.line = nextLine;
53507
53665
 
@@ -53728,8 +53886,30 @@ ${indentedChild}`;
53728
53886
  const max = this.posMax;
53729
53887
  const marker = this.src.charCodeAt(start);
53730
53888
 
53731
- // treat beginning of the line as a whitespace
53732
- const lastChar = start > 0 ? this.src.charCodeAt(start - 1) : 0x20;
53889
+ // Astral characters below are combined manually, because .codePointAt()
53890
+ // does not guarantee numeric type output. And we don't wish JIT cache issues.
53891
+ // The broken surrogate pairs are evaluated as U+FFFD to prevent possible
53892
+ // crashes.
53893
+
53894
+ let lastChar;
53895
+ if (start === 0) {
53896
+ // treat beginning of the line as a whitespace
53897
+ lastChar = 0x20;
53898
+ } else if (start === 1) {
53899
+ lastChar = this.src.charCodeAt(0);
53900
+ if ((lastChar & 0xF800) === 0xD800) { lastChar = 0xFFFD; }
53901
+ } else {
53902
+ lastChar = this.src.charCodeAt(start - 1);
53903
+ if ((lastChar & 0xFC00) === 0xDC00) {
53904
+ // low surrogate => add high one, replace broken pair with U+FFFD
53905
+ const highSurr = this.src.charCodeAt(start - 2);
53906
+ lastChar = (highSurr & 0xFC00) === 0xD800
53907
+ ? 0x10000 + ((highSurr - 0xD800) << 10) + (lastChar - 0xDC00)
53908
+ : 0xFFFD;
53909
+ } else if ((lastChar & 0xFC00) === 0xD800) {
53910
+ lastChar = 0xFFFD;
53911
+ }
53912
+ }
53733
53913
 
53734
53914
  let pos = start;
53735
53915
  while (pos < max && this.src.charCodeAt(pos) === marker) { pos++; }
@@ -53737,10 +53917,19 @@ ${indentedChild}`;
53737
53917
  const count = pos - start;
53738
53918
 
53739
53919
  // treat end of the line as a whitespace
53740
- const nextChar = pos < max ? this.src.charCodeAt(pos) : 0x20;
53920
+ let nextChar = pos < max ? this.src.charCodeAt(pos) : 0x20;
53921
+ if ((nextChar & 0xFC00) === 0xD800) {
53922
+ // high surrogate => add low one, replace broken pair with U+FFFD
53923
+ const lowSurr = this.src.charCodeAt(pos + 1);
53924
+ nextChar = (lowSurr & 0xFC00) === 0xDC00
53925
+ ? 0x10000 + ((nextChar - 0xD800) << 10) + (lowSurr - 0xDC00)
53926
+ : 0xFFFD;
53927
+ } else if ((nextChar & 0xFC00) === 0xDC00) {
53928
+ nextChar = 0xFFFD;
53929
+ }
53741
53930
 
53742
- const isLastPunctChar = isMdAsciiPunct(lastChar) || isPunctChar(String.fromCharCode(lastChar));
53743
- const isNextPunctChar = isMdAsciiPunct(nextChar) || isPunctChar(String.fromCharCode(nextChar));
53931
+ const isLastPunctChar = isMdAsciiPunct(lastChar) || isPunctCharCode(lastChar);
53932
+ const isNextPunctChar = isMdAsciiPunct(nextChar) || isPunctCharCode(nextChar);
53744
53933
 
53745
53934
  const isLastWhiteSpace = isWhiteSpace(lastChar);
53746
53935
  const isNextWhiteSpace = isWhiteSpace(nextChar);
@@ -54767,7 +54956,7 @@ ${indentedChild}`;
54767
54956
  } else {
54768
54957
  const match = state.src.slice(pos).match(NAMED_RE);
54769
54958
  if (match) {
54770
- const decoded = decodeHTML(match[0]);
54959
+ const decoded = decodeHTMLStrict(match[0]);
54771
54960
  if (decoded !== match[0]) {
54772
54961
  if (!silent) {
54773
54962
  const token = state.push('text_special', '', 0);
@@ -55429,11 +55618,6 @@ ${indentedChild}`;
55429
55618
  // DON'T try to make PRs with changes. Extend TLDs with LinkifyIt.tlds() instead
55430
55619
  const tlds_default = 'biz|com|edu|gov|net|org|pro|web|xxx|aero|asia|coop|info|museum|name|shop|рф'.split('|');
55431
55620
 
55432
- function resetScanCache (self) {
55433
- self.__index__ = -1;
55434
- self.__text_cache__ = '';
55435
- }
55436
-
55437
55621
  function createValidator (re) {
55438
55622
  return function (text, pos) {
55439
55623
  const tail = text.slice(pos);
@@ -55472,8 +55656,11 @@ ${indentedChild}`;
55472
55656
  function untpl (tpl) { return tpl.replace('%TLDS%', re.src_tlds) }
55473
55657
 
55474
55658
  re.email_fuzzy = RegExp(untpl(re.tpl_email_fuzzy), 'i');
55659
+ re.email_fuzzy_global = RegExp(untpl(re.tpl_email_fuzzy), 'ig');
55475
55660
  re.link_fuzzy = RegExp(untpl(re.tpl_link_fuzzy), 'i');
55661
+ re.link_fuzzy_global = RegExp(untpl(re.tpl_link_fuzzy), 'ig');
55476
55662
  re.link_no_ip_fuzzy = RegExp(untpl(re.tpl_link_no_ip_fuzzy), 'i');
55663
+ re.link_no_ip_fuzzy_global = RegExp(untpl(re.tpl_link_no_ip_fuzzy), 'ig');
55477
55664
  re.host_fuzzy_test = RegExp(untpl(re.tpl_host_fuzzy_test), 'i');
55478
55665
 
55479
55666
  //
@@ -55567,12 +55754,6 @@ ${indentedChild}`;
55567
55754
  '(' + self.re.schema_test.source + ')|(' + self.re.host_fuzzy_test.source + ')|@',
55568
55755
  'i'
55569
55756
  );
55570
-
55571
- //
55572
- // Cleanup
55573
- //
55574
-
55575
- resetScanCache(self);
55576
55757
  }
55577
55758
 
55578
55759
  /**
@@ -55580,55 +55761,45 @@ ${indentedChild}`;
55580
55761
  *
55581
55762
  * Match result. Single element of array, returned by [[LinkifyIt#match]]
55582
55763
  **/
55583
- function Match (self, shift) {
55584
- const start = self.__index__;
55585
- const end = self.__last_index__;
55586
- const text = self.__text_cache__.slice(start, end);
55764
+ function Match (text, schema, index, lastIndex) {
55765
+ const raw = text.slice(index, lastIndex);
55587
55766
 
55588
55767
  /**
55589
55768
  * Match#schema -> String
55590
55769
  *
55591
55770
  * Prefix (protocol) for matched string.
55592
55771
  **/
55593
- this.schema = self.__schema__.toLowerCase();
55772
+ this.schema = schema.toLowerCase();
55594
55773
  /**
55595
55774
  * Match#index -> Number
55596
55775
  *
55597
55776
  * First position of matched string.
55598
55777
  **/
55599
- this.index = start + shift;
55778
+ this.index = index;
55600
55779
  /**
55601
55780
  * Match#lastIndex -> Number
55602
55781
  *
55603
55782
  * Next position after matched string.
55604
55783
  **/
55605
- this.lastIndex = end + shift;
55784
+ this.lastIndex = lastIndex;
55606
55785
  /**
55607
55786
  * Match#raw -> String
55608
55787
  *
55609
55788
  * Matched string.
55610
55789
  **/
55611
- this.raw = text;
55790
+ this.raw = raw;
55612
55791
  /**
55613
55792
  * Match#text -> String
55614
55793
  *
55615
55794
  * Notmalized text of matched string.
55616
55795
  **/
55617
- this.text = text;
55796
+ this.text = raw;
55618
55797
  /**
55619
55798
  * Match#url -> String
55620
55799
  *
55621
55800
  * Normalized url of matched string.
55622
55801
  **/
55623
- this.url = text;
55624
- }
55625
-
55626
- function createMatch (self, shift) {
55627
- const match = new Match(self, shift);
55628
-
55629
- self.__compiled__[match.schema].normalize(match, self);
55630
-
55631
- return match
55802
+ this.url = raw;
55632
55803
  }
55633
55804
 
55634
55805
  /**
@@ -55683,12 +55854,6 @@ ${indentedChild}`;
55683
55854
 
55684
55855
  this.__opts__ = assign({}, defaultOptions, options);
55685
55856
 
55686
- // Cache last tested result. Used to skip repeating steps on next `match` call.
55687
- this.__index__ = -1;
55688
- this.__last_index__ = -1; // Next scan position
55689
- this.__schema__ = '';
55690
- this.__text_cache__ = '';
55691
-
55692
55857
  this.__schemas__ = assign({}, defaultSchemas, schemas);
55693
55858
  this.__compiled__ = {};
55694
55859
 
@@ -55730,69 +55895,38 @@ ${indentedChild}`;
55730
55895
  * Searches linkifiable pattern and returns `true` on success or `false` on fail.
55731
55896
  **/
55732
55897
  LinkifyIt.prototype.test = function test (text) {
55733
- // Reset scan cache
55734
- this.__text_cache__ = text;
55735
- this.__index__ = -1;
55736
-
55737
55898
  if (!text.length) { return false }
55738
55899
 
55739
- let m, ml, me, len, shift, next, re, tld_pos, at_pos;
55900
+ let m, re;
55740
55901
 
55741
55902
  // try to scan for link with schema - that's the most simple rule
55742
55903
  if (this.re.schema_test.test(text)) {
55743
55904
  re = this.re.schema_search;
55744
55905
  re.lastIndex = 0;
55745
55906
  while ((m = re.exec(text)) !== null) {
55746
- len = this.testSchemaAt(text, m[2], re.lastIndex);
55747
- if (len) {
55748
- this.__schema__ = m[2];
55749
- this.__index__ = m.index + m[1].length;
55750
- this.__last_index__ = m.index + m[0].length + len;
55751
- break
55752
- }
55907
+ if (this.testSchemaAt(text, m[2], re.lastIndex)) { return true }
55753
55908
  }
55754
55909
  }
55755
55910
 
55756
55911
  if (this.__opts__.fuzzyLink && this.__compiled__['http:']) {
55757
55912
  // guess schemaless links
55758
- tld_pos = text.search(this.re.host_fuzzy_test);
55759
- if (tld_pos >= 0) {
55760
- // if tld is located after found link - no need to check fuzzy pattern
55761
- if (this.__index__ < 0 || tld_pos < this.__index__) {
55762
- if ((ml = text.match(this.__opts__.fuzzyIP ? this.re.link_fuzzy : this.re.link_no_ip_fuzzy)) !== null) {
55763
- shift = ml.index + ml[1].length;
55764
-
55765
- if (this.__index__ < 0 || shift < this.__index__) {
55766
- this.__schema__ = '';
55767
- this.__index__ = shift;
55768
- this.__last_index__ = ml.index + ml[0].length;
55769
- }
55770
- }
55913
+ if (text.search(this.re.host_fuzzy_test) >= 0) {
55914
+ if (text.match(this.__opts__.fuzzyIP ? this.re.link_fuzzy : this.re.link_no_ip_fuzzy) !== null) {
55915
+ return true
55771
55916
  }
55772
55917
  }
55773
55918
  }
55774
55919
 
55775
55920
  if (this.__opts__.fuzzyEmail && this.__compiled__['mailto:']) {
55776
55921
  // guess schemaless emails
55777
- at_pos = text.indexOf('@');
55778
- if (at_pos >= 0) {
55922
+ if (text.indexOf('@') >= 0) {
55779
55923
  // We can't skip this check, because this cases are possible:
55780
55924
  // 192.168.1.1@gmail.com, my.in@example.com
55781
- if ((me = text.match(this.re.email_fuzzy)) !== null) {
55782
- shift = me.index + me[1].length;
55783
- next = me.index + me[0].length;
55784
-
55785
- if (this.__index__ < 0 || shift < this.__index__ ||
55786
- (shift === this.__index__ && next > this.__last_index__)) {
55787
- this.__schema__ = 'mailto:';
55788
- this.__index__ = shift;
55789
- this.__last_index__ = next;
55790
- }
55791
- }
55925
+ if (text.match(this.re.email_fuzzy) !== null) { return true }
55792
55926
  }
55793
55927
  }
55794
55928
 
55795
- return this.__index__ >= 0
55929
+ return false
55796
55930
  };
55797
55931
 
55798
55932
  /**
@@ -55841,23 +55975,88 @@ ${indentedChild}`;
55841
55975
  **/
55842
55976
  LinkifyIt.prototype.match = function match (text) {
55843
55977
  const result = [];
55844
- let shift = 0;
55978
+ const type_schemed = [];
55979
+ const type_fuzzy_link = [];
55980
+ const type_fuzzy_email = [];
55981
+ let m, len, re;
55845
55982
 
55846
- // Try to take previous element from cache, if .test() called before
55847
- if (this.__index__ >= 0 && this.__text_cache__ === text) {
55848
- result.push(createMatch(this, shift));
55849
- shift = this.__last_index__;
55983
+ function choose (a, b) {
55984
+ if (!a) { return b }
55985
+ if (!b) { return a }
55986
+ if (a.index !== b.index) { return a.index < b.index ? a : b }
55987
+ return a.lastIndex >= b.lastIndex ? a : b
55850
55988
  }
55851
55989
 
55852
- // Cut head if cache was used
55853
- let tail = shift ? text.slice(shift) : text;
55990
+ if (!text.length) { return null }
55854
55991
 
55855
- // Scan string until end reached
55856
- while (this.test(tail)) {
55857
- result.push(createMatch(this, shift));
55992
+ // scan for links with schema
55993
+ if (this.re.schema_test.test(text)) {
55994
+ re = this.re.schema_search;
55995
+ re.lastIndex = 0;
55996
+ while ((m = re.exec(text)) !== null) {
55997
+ len = this.testSchemaAt(text, m[2], re.lastIndex);
55998
+ if (len) {
55999
+ type_schemed.push({
56000
+ schema: m[2],
56001
+ index: m.index + m[1].length,
56002
+ lastIndex: m.index + m[0].length + len
56003
+ });
56004
+ }
56005
+ }
56006
+ }
55858
56007
 
55859
- tail = tail.slice(this.__last_index__);
55860
- shift += this.__last_index__;
56008
+ if (this.__opts__.fuzzyLink && this.__compiled__['http:']) {
56009
+ re = this.__opts__.fuzzyIP ? this.re.link_fuzzy_global : this.re.link_no_ip_fuzzy_global;
56010
+ re.lastIndex = 0;
56011
+ while ((m = re.exec(text)) !== null) {
56012
+ type_fuzzy_link.push({
56013
+ schema: '',
56014
+ index: m.index + m[1].length,
56015
+ lastIndex: m.index + m[0].length
56016
+ });
56017
+ }
56018
+ }
56019
+
56020
+ if (this.__opts__.fuzzyEmail && this.__compiled__['mailto:']) {
56021
+ re = this.re.email_fuzzy_global;
56022
+ re.lastIndex = 0;
56023
+ while ((m = re.exec(text)) !== null) {
56024
+ type_fuzzy_email.push({
56025
+ schema: 'mailto:',
56026
+ index: m.index + m[1].length,
56027
+ lastIndex: m.index + m[0].length
56028
+ });
56029
+ }
56030
+ }
56031
+
56032
+ const indexes = [0, 0, 0];
56033
+ let lastIndex = 0;
56034
+
56035
+ for (;;) {
56036
+ const candidates = [
56037
+ type_schemed[indexes[0]],
56038
+ type_fuzzy_email[indexes[1]],
56039
+ type_fuzzy_link[indexes[2]]
56040
+ ];
56041
+
56042
+ const candidate = choose(choose(candidates[0], candidates[1]), candidates[2]);
56043
+
56044
+ if (!candidate) { break }
56045
+
56046
+ if (candidate === candidates[0]) {
56047
+ indexes[0]++;
56048
+ } else if (candidate === candidates[1]) {
56049
+ indexes[1]++;
56050
+ } else {
56051
+ indexes[2]++;
56052
+ }
56053
+
56054
+ if (candidate.index < lastIndex) { continue }
56055
+
56056
+ const match = new Match(text, candidate.schema, candidate.index, candidate.lastIndex);
56057
+ this.__compiled__[match.schema].normalize(match, this);
56058
+ result.push(match);
56059
+ lastIndex = candidate.lastIndex;
55861
56060
  }
55862
56061
 
55863
56062
  if (result.length) {
@@ -55874,10 +56073,6 @@ ${indentedChild}`;
55874
56073
  * of the string, and null otherwise.
55875
56074
  **/
55876
56075
  LinkifyIt.prototype.matchAtStart = function matchAtStart (text) {
55877
- // Reset scan cache
55878
- this.__text_cache__ = text;
55879
- this.__index__ = -1;
55880
-
55881
56076
  if (!text.length) return null
55882
56077
 
55883
56078
  const m = this.re.schema_at_start.exec(text);
@@ -55886,11 +56081,10 @@ ${indentedChild}`;
55886
56081
  const len = this.testSchemaAt(text, m[2], m[0].length);
55887
56082
  if (!len) return null
55888
56083
 
55889
- this.__schema__ = m[2];
55890
- this.__index__ = m.index + m[1].length;
55891
- this.__last_index__ = m.index + m[0].length + len;
56084
+ const match = new Match(text, m[2], m.index + m[1].length, m.index + m[0].length + len);
55892
56085
 
55893
- return createMatch(this, 0)
56086
+ this.__compiled__[match.schema].normalize(match, this);
56087
+ return match
55894
56088
  };
55895
56089
 
55896
56090
  /** chainable
@@ -56942,7 +57136,7 @@ ${indentedChild}`;
56942
57136
  * ```javascript
56943
57137
  * var md = require('markdown-it')()
56944
57138
  * .set({ html: true, breaks: true })
56945
- * .set({ typographer, true });
57139
+ * .set({ typographer: true });
56946
57140
  * ```
56947
57141
  *
56948
57142
  * __Note:__ To achieve the best possible performance, don't modify a
@@ -58890,7 +59084,7 @@ ${indentedChild}`;
58890
59084
  // THIS FILE IS AUTOMATICALLY GENERATED DO NOT EDIT DIRECTLY
58891
59085
  // See update-tlds.js for encoding/decoding format
58892
59086
  // https://data.iana.org/TLD/tlds-alpha-by-domain.txt
58893
- const encodedTlds = 'aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2';
59087
+ const encodedTlds = 'aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2odyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rck0msd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2oodside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2';
58894
59088
  // Internationalized domain names containing non-ASCII
58895
59089
  const encodedUtlds = 'ελ1υ2бг1ел3дети4ею2католик6ом3мкд2он1сква6онлайн5рг3рус2ф2сайт3рб3укр3қаз3հայ3ישראל5קום3ابوظبي5رامكو5لاردن4بحرين5جزائر5سعودية6عليان5مغرب5مارات5یران5بارت2زار4يتك3ھارت5تونس4سودان3رية5شبكة4عراق2ب2مان4فلسطين6قطر3كاثوليك6وم3مصر2ليسيا5وريتانيا7قع4همراه5پاکستان7ڀارت4कॉम3नेट3भारत0म्3ोत5संगठन5বাংলা5ভারত2ৰত4ਭਾਰਤ4ભારત4ଭାରତ4இந்தியா6லங்கை6சிங்கப்பூர்11భారత్5ಭಾರತ4ഭാരതം5ලංකා4คอม3ไทย3ລາວ3გე2みんな3アマゾン4クラウド4グーグル4コム2ストア3セール3ファッション6ポイント4世界2中信1国1國1文网3亚马逊3企业2佛山2信息2健康2八卦2公司1益2台湾1灣2商城1店1标2嘉里0大酒店5在线2大拿2天主教3娱乐2家電2广东2微博2慈善2我爱你3手机2招聘2政务1府2新加坡2闻2时尚2書籍2机构2淡马锡3游戏2澳門2点看2移动2组织机构4网址1店1站1络2联通2谷歌2购物2通販2集团2電訊盈科4飞利浦3食品2餐厅2香格里拉3港2닷넷1컴2삼성2한국2';
58896
59090
 
@@ -60282,11 +60476,6 @@ ${indentedChild}`;
60282
60476
  tt(Email$1, DOT, EmailDomainDot);
60283
60477
  tt(Email$1, HYPHEN, EmailDomainHyphen);
60284
60478
 
60285
- // Final possible email states
60286
- const EmailColon = tt(Email$1, COLON); // URL followed by colon (potential port number here)
60287
- /*const EmailColonPort = */
60288
- ta(EmailColon, groups.numeric, Email); // URL followed by colon and port number
60289
-
60290
60479
  // Account for dots and hyphens. Hyphens are usually parts of domain names
60291
60480
  // (but not TLDs)
60292
60481
  const DomainHyphen = tt(Domain, HYPHEN); // domain followed by hyphen
@@ -60369,16 +60558,18 @@ ${indentedChild}`;
60369
60558
  // Continue not accepting for open brackets
60370
60559
  tt(UrlNonaccept, OPEN, UrlOpen);
60371
60560
 
60372
- // Closing bracket component. This character WILL be included in the URL
60373
- tt(UrlOpen, CLOSE, Url$1);
60374
-
60375
- // URL that beings with an opening bracket, followed by a symbols.
60561
+ // URL that begins with an opening bracket, followed by a symbols.
60376
60562
  // Note that the final state can still be `UrlOpen` (if the URL has a
60377
60563
  // single opening bracket for some reason).
60378
60564
  const UrlOpenQ = makeState(Url);
60379
60565
  ta(UrlOpen, qsAccepting, UrlOpenQ);
60380
60566
  const UrlOpenSyms = makeState(); // UrlOpen followed by some symbols it cannot end it
60381
- ta(UrlOpen, qsNonAccepting);
60567
+ ta(UrlOpen, qsNonAccepting, UrlOpenSyms);
60568
+
60569
+ // Closing bracket component. This character WILL be included in the URL.
60570
+ // Must come after qsNonAccepting (which includes all close-bracket tokens)
60571
+ // so that CLOSE -> Url wins over CLOSE -> UrlOpenSyms.
60572
+ tt(UrlOpen, CLOSE, Url$1);
60382
60573
 
60383
60574
  // URL that begins with an opening bracket, followed by some symbols
60384
60575
  ta(UrlOpenQ, qsAccepting, UrlOpenQ);
@@ -61132,6 +61323,25 @@ ${indentedChild}`;
61132
61323
  return [inputRule];
61133
61324
  }
61134
61325
  });
61326
+ function isSameLineOrderedListToken(token) {
61327
+ var _a, _b;
61328
+ const nestedToken = (_a = token.tokens) == null ? void 0 : _a[0];
61329
+ return Boolean(
61330
+ token.text && ((_b = token.tokens) == null ? void 0 : _b.length) === 1 && (nestedToken == null ? void 0 : nestedToken.type) === "list" && nestedToken.ordered && nestedToken.raw === token.text
61331
+ );
61332
+ }
61333
+ function parseSameLineOrderedListText(text, helpers) {
61334
+ if (helpers.tokenizeInline) {
61335
+ return helpers.parseInline(helpers.tokenizeInline(text));
61336
+ }
61337
+ return helpers.parseInline([
61338
+ {
61339
+ type: "text",
61340
+ raw: text,
61341
+ text
61342
+ }
61343
+ ]);
61344
+ }
61135
61345
  var ListItem = Node3.create({
61136
61346
  name: "listItem",
61137
61347
  addOptions() {
@@ -61162,6 +61372,17 @@ ${indentedChild}`;
61162
61372
  const parseBlockChildren = (_a = helpers.parseBlockChildren) != null ? _a : helpers.parseChildren;
61163
61373
  let content = [];
61164
61374
  if (token.tokens && token.tokens.length > 0) {
61375
+ if (isSameLineOrderedListToken(token)) {
61376
+ return {
61377
+ type: "listItem",
61378
+ content: [
61379
+ {
61380
+ type: "paragraph",
61381
+ content: parseSameLineOrderedListText(token.text || "", helpers)
61382
+ }
61383
+ ]
61384
+ };
61385
+ }
61165
61386
  const hasParagraphTokens = token.tokens.some((t) => t.type === "paragraph");
61166
61387
  if (hasParagraphTokens) {
61167
61388
  content = parseBlockChildren(token.tokens);
@@ -63805,6 +64026,7 @@ ${indentedChild}`;
63805
64026
  addOptions() {
63806
64027
  return {
63807
64028
  limit: null,
64029
+ autoTrim: true,
63808
64030
  mode: "textSize",
63809
64031
  textCounter: (text) => text.length,
63810
64032
  wordCounter: (text) => text.split(" ").filter((word) => word !== "").length
@@ -63842,7 +64064,8 @@ ${indentedChild}`;
63842
64064
  return;
63843
64065
  }
63844
64066
  const limit = this.options.limit;
63845
- if (limit === null || limit === void 0 || limit === 0) {
64067
+ const autoTrim = this.options.autoTrim;
64068
+ if (limit === null || limit === void 0 || limit === 0 || autoTrim === false) {
63846
64069
  initialEvaluationDone = true;
63847
64070
  return;
63848
64071
  }
@@ -63985,10 +64208,114 @@ ${indentedChild}`;
63985
64208
  };
63986
64209
  }
63987
64210
  });
64211
+ function createPlaceholderDecoration(options) {
64212
+ const {
64213
+ editor,
64214
+ placeholder,
64215
+ dataAttribute,
64216
+ pos,
64217
+ node,
64218
+ isEmptyDoc,
64219
+ hasAnchor,
64220
+ classes: { emptyNode, emptyEditor }
64221
+ } = options;
64222
+ const classes = [emptyNode];
64223
+ if (isEmptyDoc) {
64224
+ classes.push(emptyEditor);
64225
+ }
64226
+ return Decoration.node(pos, pos + node.nodeSize, {
64227
+ class: classes.join(" "),
64228
+ [dataAttribute]: typeof placeholder === "function" ? placeholder({
64229
+ editor,
64230
+ node,
64231
+ pos,
64232
+ hasAnchor
64233
+ }) : placeholder
64234
+ });
64235
+ }
64236
+
64237
+ // src/placeholder/utils/findScrollParent.ts
64238
+ function isScrollable(el) {
64239
+ const style = getComputedStyle(el);
64240
+ const overflow = `${style.overflow} ${style.overflowY} ${style.overflowX}`;
64241
+ return /auto|scroll|overlay/.test(overflow);
64242
+ }
64243
+ function findScrollParent(element) {
64244
+ let el = element;
64245
+ while (el) {
64246
+ if (isScrollable(el)) {
64247
+ return el;
64248
+ }
64249
+ const parent = el.parentElement;
64250
+ if (!parent) {
64251
+ const root = el.getRootNode();
64252
+ if (root instanceof ShadowRoot) {
64253
+ el = root.host;
64254
+ continue;
64255
+ }
64256
+ return window;
64257
+ }
64258
+ el = parent;
64259
+ }
64260
+ return window;
64261
+ }
64262
+
64263
+ // src/placeholder/utils/getViewportBoundaryPositions.ts
64264
+ function getContainerRect(container) {
64265
+ if (container === window) {
64266
+ return { top: 0, bottom: window.innerHeight };
64267
+ }
64268
+ return container.getBoundingClientRect();
64269
+ }
64270
+ function getViewportBoundaryPositions({
64271
+ doc,
64272
+ view,
64273
+ scrollContainer
64274
+ }) {
64275
+ const editorRect = view.dom.getBoundingClientRect();
64276
+ const containerRect = scrollContainer ? getContainerRect(scrollContainer) : { top: 0, bottom: window.innerHeight };
64277
+ const visibleTop = Math.max(editorRect.top, containerRect.top);
64278
+ const visibleBottom = Math.min(editorRect.bottom, containerRect.bottom);
64279
+ if (visibleTop >= visibleBottom) {
64280
+ return { top: 0, bottom: doc.content.size };
64281
+ }
64282
+ const isRTL = getComputedStyle(view.dom).direction === "rtl";
64283
+ const x = isRTL ? Math.max(editorRect.right - 2, editorRect.left + 2) : editorRect.left + 2;
64284
+ const topPos = view.posAtCoords({ left: x, top: visibleTop + 2 });
64285
+ const bottomPos = view.posAtCoords({ left: x, top: visibleBottom - 2 });
64286
+ return {
64287
+ top: topPos ? topPos.pos : 0,
64288
+ bottom: bottomPos ? bottomPos.pos : doc.content.size
64289
+ };
64290
+ }
64291
+
64292
+ // src/placeholder/utils/throttle.ts
64293
+ function throttle(fn, delay) {
64294
+ let timer = null;
64295
+ const call = ((...args) => {
64296
+ if (timer) {
64297
+ return;
64298
+ }
64299
+ fn(...args);
64300
+ timer = setTimeout(() => {
64301
+ timer = null;
64302
+ }, delay);
64303
+ });
64304
+ const cancel = () => {
64305
+ if (timer) {
64306
+ clearTimeout(timer);
64307
+ timer = null;
64308
+ }
64309
+ };
64310
+ return { call, cancel };
64311
+ }
64312
+
64313
+ // src/placeholder/placeholder.ts
63988
64314
  var DEFAULT_DATA_ATTRIBUTE = "placeholder";
63989
64315
  function preparePlaceholderAttribute(attr) {
63990
64316
  return attr.replace(/\s+/g, "-").replace(/[^a-zA-Z0-9-]/g, "").replace(/^[0-9-]+/, "").replace(/^-+/, "").toLowerCase();
63991
64317
  }
64318
+ var PLUGIN_KEY = new PluginKey("tiptap__placeholder");
63992
64319
  var Placeholder = Extension.create({
63993
64320
  name: "placeholder",
63994
64321
  addOptions() {
@@ -64006,40 +64333,124 @@ ${indentedChild}`;
64006
64333
  const dataAttribute = this.options.dataAttribute ? `data-${preparePlaceholderAttribute(this.options.dataAttribute)}` : `data-${DEFAULT_DATA_ATTRIBUTE}`;
64007
64334
  return [
64008
64335
  new Plugin({
64009
- key: new PluginKey("placeholder"),
64336
+ state: {
64337
+ init() {
64338
+ return {
64339
+ // null means "no viewport info yet" — decoration callback falls
64340
+ // back to full document scan until the scroll handler fires.
64341
+ topPos: null,
64342
+ bottomPos: null
64343
+ };
64344
+ },
64345
+ apply(tr, prev) {
64346
+ const meta = tr.getMeta(PLUGIN_KEY);
64347
+ if (meta == null ? void 0 : meta.positions) {
64348
+ return {
64349
+ topPos: meta.positions.top,
64350
+ bottomPos: meta.positions.bottom
64351
+ };
64352
+ }
64353
+ if (!tr.docChanged) {
64354
+ return prev;
64355
+ }
64356
+ return {
64357
+ topPos: prev.topPos !== null ? tr.mapping.map(prev.topPos) : null,
64358
+ bottomPos: prev.bottomPos !== null ? tr.mapping.map(prev.bottomPos) : null
64359
+ };
64360
+ }
64361
+ },
64362
+ key: PLUGIN_KEY,
64363
+ view(view) {
64364
+ const scrollContainer = findScrollParent(view.dom);
64365
+ const computeAndDispatch = () => {
64366
+ const positions = getViewportBoundaryPositions({
64367
+ view,
64368
+ doc: view.state.doc,
64369
+ scrollContainer
64370
+ });
64371
+ const prev = PLUGIN_KEY.getState(view.state);
64372
+ if (prev.topPos === positions.top && prev.bottomPos === positions.bottom) {
64373
+ return;
64374
+ }
64375
+ const tr = view.state.tr.setMeta(PLUGIN_KEY, { positions }).setMeta("tiptap__viewportUpdate", true);
64376
+ view.dispatch(tr);
64377
+ };
64378
+ const { call: throttledUpdate, cancel: cancelThrottle } = throttle(computeAndDispatch, 250);
64379
+ const scrollParent = scrollContainer;
64380
+ scrollParent.addEventListener("scroll", throttledUpdate, { passive: true });
64381
+ computeAndDispatch();
64382
+ return {
64383
+ update(_, prevState) {
64384
+ if (view.state.doc.content.size !== prevState.doc.content.size) {
64385
+ computeAndDispatch();
64386
+ }
64387
+ },
64388
+ destroy: () => {
64389
+ cancelThrottle();
64390
+ scrollParent.removeEventListener("scroll", throttledUpdate);
64391
+ }
64392
+ };
64393
+ },
64010
64394
  props: {
64011
64395
  decorations: ({ doc, selection }) => {
64396
+ var _a, _b;
64012
64397
  const active = this.editor.isEditable || !this.options.showOnlyWhenEditable;
64013
- const { anchor } = selection;
64014
- const decorations = [];
64015
64398
  if (!active) {
64016
64399
  return null;
64017
64400
  }
64401
+ const { anchor } = selection;
64402
+ const decorations = [];
64018
64403
  const isEmptyDoc = this.editor.isEmpty;
64019
- doc.descendants((node, pos) => {
64020
- const hasAnchor = anchor >= pos && anchor <= pos + node.nodeSize;
64021
- const isEmpty = !node.isLeaf && isNodeEmpty(node);
64022
- if (!node.type.isTextblock) {
64023
- return this.options.includeChildren;
64404
+ const useResolvedPath = this.options.showOnlyCurrent && !this.options.includeChildren;
64405
+ if (useResolvedPath) {
64406
+ const resolved = doc.resolve(anchor);
64407
+ if (resolved.depth > 0) {
64408
+ const node = resolved.node(1);
64409
+ const nodeStart = resolved.before(1);
64410
+ if (node.type.isTextblock && isNodeEmpty(node)) {
64411
+ const hasAnchor = anchor >= nodeStart && anchor <= nodeStart + node.nodeSize;
64412
+ const decoration = createPlaceholderDecoration({
64413
+ node,
64414
+ dataAttribute,
64415
+ hasAnchor,
64416
+ placeholder: this.options.placeholder,
64417
+ classes: {
64418
+ emptyEditor: this.options.emptyEditorClass,
64419
+ emptyNode: this.options.emptyNodeClass
64420
+ },
64421
+ editor: this.editor,
64422
+ isEmptyDoc,
64423
+ pos: resolved.before(1)
64424
+ });
64425
+ decorations.push(decoration);
64426
+ }
64024
64427
  }
64025
- if ((hasAnchor || !this.options.showOnlyCurrent) && isEmpty) {
64026
- const classes = [this.options.emptyNodeClass];
64027
- if (isEmptyDoc) {
64028
- classes.push(this.options.emptyEditorClass);
64428
+ } else {
64429
+ const pluginState = PLUGIN_KEY.getState(this.editor.state);
64430
+ const from = (_a = pluginState.topPos) != null ? _a : 0;
64431
+ const to = (_b = pluginState.bottomPos) != null ? _b : doc.content.size;
64432
+ doc.nodesBetween(from, to, (node, pos) => {
64433
+ const hasAnchor = anchor >= pos && anchor <= pos + node.nodeSize;
64434
+ const isEmpty = !node.isLeaf && isNodeEmpty(node);
64435
+ if (!node.type.isTextblock) {
64436
+ return this.options.includeChildren;
64029
64437
  }
64030
- const decoration = Decoration.node(pos, pos + node.nodeSize, {
64031
- class: classes.join(" "),
64032
- [dataAttribute]: typeof this.options.placeholder === "function" ? this.options.placeholder({
64438
+ if ((hasAnchor || !this.options.showOnlyCurrent) && isEmpty) {
64439
+ const decoration = createPlaceholderDecoration({
64440
+ classes: { emptyEditor: this.options.emptyEditorClass, emptyNode: this.options.emptyNodeClass },
64033
64441
  editor: this.editor,
64442
+ isEmptyDoc,
64443
+ dataAttribute,
64444
+ hasAnchor,
64445
+ placeholder: this.options.placeholder,
64034
64446
  node,
64035
- pos,
64036
- hasAnchor
64037
- }) : this.options.placeholder
64038
- });
64039
- decorations.push(decoration);
64040
- }
64041
- return this.options.includeChildren;
64042
- });
64447
+ pos
64448
+ });
64449
+ decorations.push(decoration);
64450
+ }
64451
+ return this.options.includeChildren;
64452
+ });
64453
+ }
64043
64454
  return DecorationSet.create(doc, decorations);
64044
64455
  }
64045
64456
  }
@@ -72776,24 +73187,56 @@ focus outline in that case.
72776
73187
  </template>
72777
73188
  `;
72778
73189
 
73190
+ function createLazyMeasurementsView(count, flat, getItemKey) {
73191
+ const cache = new Array(count);
73192
+ return new Proxy(cache, {
73193
+ get(target, prop, receiver) {
73194
+ if (typeof prop === "string") {
73195
+ const c = prop.charCodeAt(0);
73196
+ if (c >= 48 && c <= 57) {
73197
+ const i = +prop;
73198
+ if (Number.isInteger(i) && i >= 0 && i < count) {
73199
+ let v = target[i];
73200
+ if (!v) {
73201
+ const s = flat[i * 2];
73202
+ v = target[i] = {
73203
+ index: i,
73204
+ key: getItemKey(i),
73205
+ start: s,
73206
+ size: flat[i * 2 + 1],
73207
+ end: s + flat[i * 2 + 1],
73208
+ lane: 0
73209
+ };
73210
+ }
73211
+ return v;
73212
+ }
73213
+ }
73214
+ if (prop === "length") return count;
73215
+ }
73216
+ return Reflect.get(target, prop, receiver);
73217
+ }
73218
+ });
73219
+ }
73220
+
72779
73221
  function memo(getDeps, fn, opts) {
72780
73222
  let deps = opts.initialDeps ?? [];
72781
73223
  let result;
72782
73224
  let isInitial = true;
72783
73225
  function memoizedFunction() {
72784
- var _a, _b, _c;
72785
- let depTime;
72786
- if (opts.key && ((_a = opts.debug) == null ? void 0 : _a.call(opts))) depTime = Date.now();
73226
+ var _a;
73227
+ const debugEnabled = !!opts.key && !!((_a = opts.debug) == null ? void 0 : _a.call(opts));
73228
+ let depTime = 0;
73229
+ if (debugEnabled) depTime = Date.now();
72787
73230
  const newDeps = getDeps();
72788
73231
  const depsChanged = newDeps.length !== deps.length || newDeps.some((dep, index) => deps[index] !== dep);
72789
73232
  if (!depsChanged) {
72790
73233
  return result;
72791
73234
  }
72792
73235
  deps = newDeps;
72793
- let resultTime;
72794
- if (opts.key && ((_b = opts.debug) == null ? void 0 : _b.call(opts))) resultTime = Date.now();
73236
+ let resultTime = 0;
73237
+ if (debugEnabled) resultTime = Date.now();
72795
73238
  result = fn(...newDeps);
72796
- if (opts.key && ((_c = opts.debug) == null ? void 0 : _c.call(opts))) {
73239
+ if (debugEnabled) {
72797
73240
  const depEndTime = Math.round((Date.now() - depTime) * 100) / 100;
72798
73241
  const resultEndTime = Math.round((Date.now() - resultTime) * 100) / 100;
72799
73242
  const resultFpsPercentage = resultEndTime / 16;
@@ -72843,6 +73286,14 @@ focus outline in that case.
72843
73286
  };
72844
73287
  };
72845
73288
 
73289
+ let _isIOSResult;
73290
+ const isIOSWebKit = () => {
73291
+ if (_isIOSResult !== void 0) return _isIOSResult;
73292
+ if (typeof navigator === "undefined") return _isIOSResult = false;
73293
+ if (/iP(hone|od|ad)/.test(navigator.userAgent)) return _isIOSResult = true;
73294
+ const mtp = navigator.maxTouchPoints;
73295
+ return _isIOSResult = navigator.platform === "MacIntel" && mtp !== void 0 && mtp > 0;
73296
+ };
72846
73297
  const getRect = (element) => {
72847
73298
  const { offsetWidth, offsetHeight } = element;
72848
73299
  return { width: offsetWidth, height: offsetHeight };
@@ -72851,9 +73302,10 @@ focus outline in that case.
72851
73302
  const defaultRangeExtractor = (range) => {
72852
73303
  const start = Math.max(range.startIndex - range.overscan, 0);
72853
73304
  const end = Math.min(range.endIndex + range.overscan, range.count - 1);
72854
- const arr = [];
72855
- for (let i = start; i <= end; i++) {
72856
- arr.push(i);
73305
+ const len = end - start + 1;
73306
+ const arr = new Array(len);
73307
+ for (let i = 0; i < len; i++) {
73308
+ arr[i] = start + i;
72857
73309
  }
72858
73310
  return arr;
72859
73311
  };
@@ -72898,7 +73350,7 @@ focus outline in that case.
72898
73350
  passive: true
72899
73351
  };
72900
73352
  const supportsScrollend = typeof window == "undefined" ? true : "onscrollend" in window;
72901
- const observeElementOffset = (instance, cb) => {
73353
+ const observeOffset = (instance, cb, readOffset) => {
72902
73354
  const element = instance.scrollElement;
72903
73355
  if (!element) {
72904
73356
  return;
@@ -72907,24 +73359,21 @@ focus outline in that case.
72907
73359
  if (!targetWindow) {
72908
73360
  return;
72909
73361
  }
73362
+ const registerScrollendEvent = instance.options.useScrollendEvent && supportsScrollend;
72910
73363
  let offset = 0;
72911
- const fallback = instance.options.useScrollendEvent && supportsScrollend ? () => void 0 : debounce(
73364
+ const fallback = registerScrollendEvent ? null : debounce(
72912
73365
  targetWindow,
72913
- () => {
72914
- cb(offset, false);
72915
- },
73366
+ () => cb(offset, false),
72916
73367
  instance.options.isScrollingResetDelay
72917
73368
  );
72918
73369
  const createHandler = (isScrolling) => () => {
72919
- const { horizontal, isRtl } = instance.options;
72920
- offset = horizontal ? element["scrollLeft"] * (isRtl && -1 || 1) : element["scrollTop"];
72921
- fallback();
73370
+ offset = readOffset(element);
73371
+ fallback == null ? void 0 : fallback();
72922
73372
  cb(offset, isScrolling);
72923
73373
  };
72924
73374
  const handler = createHandler(true);
72925
73375
  const endHandler = createHandler(false);
72926
73376
  element.addEventListener("scroll", handler, addEventListenerOptions);
72927
- const registerScrollendEvent = instance.options.useScrollendEvent && supportsScrollend;
72928
73377
  if (registerScrollendEvent) {
72929
73378
  element.addEventListener("scrollend", endHandler, addEventListenerOptions);
72930
73379
  }
@@ -72935,6 +73384,10 @@ focus outline in that case.
72935
73384
  }
72936
73385
  };
72937
73386
  };
73387
+ const observeElementOffset = (instance, cb) => observeOffset(instance, cb, (el) => {
73388
+ const { horizontal, isRtl } = instance.options;
73389
+ return horizontal ? el.scrollLeft * (isRtl && -1 || 1) : el.scrollTop;
73390
+ });
72938
73391
  const measureElement = (element, entry, instance) => {
72939
73392
  if (entry == null ? void 0 : entry.borderBoxSize) {
72940
73393
  const box = entry.borderBoxSize[0];
@@ -72947,17 +73400,17 @@ focus outline in that case.
72947
73400
  }
72948
73401
  return element[instance.options.horizontal ? "offsetWidth" : "offsetHeight"];
72949
73402
  };
72950
- const elementScroll = (offset, {
73403
+ const scrollWithAdjustments = (offset, {
72951
73404
  adjustments = 0,
72952
73405
  behavior
72953
73406
  }, instance) => {
72954
73407
  var _a, _b;
72955
- const toOffset = offset + adjustments;
72956
73408
  (_b = (_a = instance.scrollElement) == null ? void 0 : _a.scrollTo) == null ? void 0 : _b.call(_a, {
72957
- [instance.options.horizontal ? "left" : "top"]: toOffset,
73409
+ [instance.options.horizontal ? "left" : "top"]: offset + adjustments,
72958
73410
  behavior
72959
73411
  });
72960
73412
  };
73413
+ const elementScroll = scrollWithAdjustments;
72961
73414
  let Virtualizer$1 = class Virtualizer {
72962
73415
  constructor(opts) {
72963
73416
  this.unsubs = [];
@@ -72966,16 +73419,24 @@ focus outline in that case.
72966
73419
  this.isScrolling = false;
72967
73420
  this.scrollState = null;
72968
73421
  this.measurementsCache = [];
73422
+ this._flatMeasurements = null;
72969
73423
  this.itemSizeCache = /* @__PURE__ */ new Map();
73424
+ this.itemSizeCacheVersion = 0;
72970
73425
  this.laneAssignments = /* @__PURE__ */ new Map();
72971
- this.pendingMeasuredCacheIndexes = [];
73426
+ this.pendingMin = null;
72972
73427
  this.prevLanes = void 0;
72973
73428
  this.lanesChangedFlag = false;
72974
73429
  this.lanesSettling = false;
73430
+ this.pendingScrollAnchor = null;
72975
73431
  this.scrollRect = null;
72976
73432
  this.scrollOffset = null;
72977
73433
  this.scrollDirection = null;
72978
73434
  this.scrollAdjustments = 0;
73435
+ this._iosDeferredAdjustment = 0;
73436
+ this._iosTouching = false;
73437
+ this._iosJustTouchEnded = false;
73438
+ this._iosTouchEndTimerId = null;
73439
+ this._intendedScrollOffset = null;
72979
73440
  this.elementsCache = /* @__PURE__ */ new Map();
72980
73441
  this.now = () => {
72981
73442
  var _a, _b, _c;
@@ -72997,6 +73458,12 @@ focus outline in that case.
72997
73458
  const index = this.indexFromElement(node);
72998
73459
  if (!node.isConnected) {
72999
73460
  this.observer.unobserve(node);
73461
+ for (const [cacheKey, cachedNode] of this.elementsCache) {
73462
+ if (cachedNode === node) {
73463
+ this.elementsCache.delete(cacheKey);
73464
+ break;
73465
+ }
73466
+ }
73000
73467
  return;
73001
73468
  }
73002
73469
  if (this.shouldMeasureDuringScroll(index)) {
@@ -73028,10 +73495,8 @@ focus outline in that case.
73028
73495
  })();
73029
73496
  this.range = null;
73030
73497
  this.setOptions = (opts2) => {
73031
- Object.entries(opts2).forEach(([key, value]) => {
73032
- if (typeof value === "undefined") delete opts2[key];
73033
- });
73034
- this.options = {
73498
+ var _a, _b;
73499
+ const merged = {
73035
73500
  debug: false,
73036
73501
  initialOffset: 0,
73037
73502
  overscan: 1,
@@ -73051,14 +73516,50 @@ focus outline in that case.
73051
73516
  indexAttribute: "data-index",
73052
73517
  initialMeasurementsCache: [],
73053
73518
  lanes: 1,
73519
+ anchorTo: "start",
73520
+ followOnAppend: false,
73521
+ scrollEndThreshold: 1,
73054
73522
  isScrollingResetDelay: 150,
73055
73523
  enabled: true,
73056
73524
  isRtl: false,
73057
73525
  useScrollendEvent: false,
73058
73526
  useAnimationFrameWithResizeObserver: false,
73059
- laneAssignmentMode: "estimate",
73060
- ...opts2
73527
+ laneAssignmentMode: "estimate"
73061
73528
  };
73529
+ for (const key in opts2) {
73530
+ const v = opts2[key];
73531
+ if (v !== void 0) merged[key] = v;
73532
+ }
73533
+ const prevOptions = this.options;
73534
+ let anchor = null;
73535
+ let followOnAppend = null;
73536
+ if (prevOptions !== void 0 && prevOptions.enabled && merged.enabled && merged.anchorTo === "end" && this.scrollElement !== null) {
73537
+ const prevCount = prevOptions.count;
73538
+ const nextCount = merged.count;
73539
+ const measurements = this.getMeasurements();
73540
+ const prevFirstKey = prevCount > 0 ? ((_a = measurements[0]) == null ? void 0 : _a.key) ?? prevOptions.getItemKey(0) : null;
73541
+ const prevLastKey = prevCount > 0 ? ((_b = measurements[prevCount - 1]) == null ? void 0 : _b.key) ?? prevOptions.getItemKey(prevCount - 1) : null;
73542
+ const didCountChange = nextCount !== prevCount;
73543
+ const didEdgeKeysChange = didCountChange || prevCount > 0 && nextCount > 0 && (merged.getItemKey(0) !== prevFirstKey || merged.getItemKey(nextCount - 1) !== prevLastKey);
73544
+ if (didEdgeKeysChange) {
73545
+ const item = prevCount > 0 ? this.getVirtualItemForOffset(this.getScrollOffset()) ?? measurements[0] : null;
73546
+ if (item) {
73547
+ anchor = [item.key, this.getScrollOffset() - item.start];
73548
+ }
73549
+ const behavior = merged.followOnAppend === true ? "auto" : merged.followOnAppend || null;
73550
+ if (behavior && nextCount > prevCount && this.isAtEnd(prevOptions.scrollEndThreshold) && (prevCount === 0 || merged.getItemKey(nextCount - 1) !== prevLastKey)) {
73551
+ followOnAppend = behavior;
73552
+ }
73553
+ }
73554
+ }
73555
+ this.options = merged;
73556
+ if (anchor || followOnAppend) {
73557
+ this.pendingScrollAnchor = [
73558
+ (anchor == null ? void 0 : anchor[0]) ?? null,
73559
+ (anchor == null ? void 0 : anchor[1]) ?? 0,
73560
+ followOnAppend
73561
+ ];
73562
+ }
73062
73563
  };
73063
73564
  this.notify = (sync) => {
73064
73565
  var _a, _b;
@@ -73129,21 +73630,104 @@ focus outline in that case.
73129
73630
  );
73130
73631
  this.unsubs.push(
73131
73632
  this.options.observeElementOffset(this, (offset, isScrolling) => {
73633
+ if (this._intendedScrollOffset !== null && Math.abs(offset - this._intendedScrollOffset) < 1.5) {
73634
+ offset = this._intendedScrollOffset;
73635
+ }
73636
+ this._intendedScrollOffset = null;
73132
73637
  this.scrollAdjustments = 0;
73133
73638
  this.scrollDirection = isScrolling ? this.getScrollOffset() < offset ? "forward" : "backward" : null;
73134
73639
  this.scrollOffset = offset;
73135
73640
  this.isScrolling = isScrolling;
73641
+ this._flushIosDeferredIfReady();
73136
73642
  if (this.scrollState) {
73137
73643
  this.scheduleScrollReconcile();
73138
73644
  }
73139
73645
  this.maybeNotify();
73140
73646
  })
73141
73647
  );
73648
+ if ("addEventListener" in this.scrollElement) {
73649
+ const scrollEl = this.scrollElement;
73650
+ const onTouchStart = () => {
73651
+ this._iosTouching = true;
73652
+ this._iosJustTouchEnded = false;
73653
+ if (this._iosTouchEndTimerId !== null && this.targetWindow != null) {
73654
+ this.targetWindow.clearTimeout(this._iosTouchEndTimerId);
73655
+ this._iosTouchEndTimerId = null;
73656
+ }
73657
+ };
73658
+ const onTouchEnd = () => {
73659
+ this._iosTouching = false;
73660
+ if (!isIOSWebKit() || this.targetWindow == null) {
73661
+ return;
73662
+ }
73663
+ this._iosJustTouchEnded = true;
73664
+ this._iosTouchEndTimerId = this.targetWindow.setTimeout(() => {
73665
+ this._iosJustTouchEnded = false;
73666
+ this._iosTouchEndTimerId = null;
73667
+ this._flushIosDeferredIfReady();
73668
+ }, 150);
73669
+ };
73670
+ scrollEl.addEventListener(
73671
+ "touchstart",
73672
+ onTouchStart,
73673
+ addEventListenerOptions
73674
+ );
73675
+ scrollEl.addEventListener(
73676
+ "touchend",
73677
+ onTouchEnd,
73678
+ addEventListenerOptions
73679
+ );
73680
+ this.unsubs.push(() => {
73681
+ scrollEl.removeEventListener("touchstart", onTouchStart);
73682
+ scrollEl.removeEventListener("touchend", onTouchEnd);
73683
+ if (this._iosTouchEndTimerId !== null && this.targetWindow != null) {
73684
+ this.targetWindow.clearTimeout(this._iosTouchEndTimerId);
73685
+ this._iosTouchEndTimerId = null;
73686
+ }
73687
+ });
73688
+ }
73142
73689
  this._scrollToOffset(this.getScrollOffset(), {
73143
73690
  adjustments: void 0,
73144
73691
  behavior: void 0
73145
73692
  });
73146
73693
  }
73694
+ const anchor = this.pendingScrollAnchor;
73695
+ this.pendingScrollAnchor = null;
73696
+ if (anchor && this.scrollElement && this.options.enabled) {
73697
+ const [key, offset, followOnAppend] = anchor;
73698
+ if (key !== null) {
73699
+ const { count, getItemKey } = this.options;
73700
+ let index = 0;
73701
+ while (index < count && getItemKey(index) !== key) {
73702
+ index++;
73703
+ }
73704
+ const item = index < count ? this.getMeasurements()[index] : void 0;
73705
+ if (item) {
73706
+ const delta = item.start + offset - this.getScrollOffset();
73707
+ if (!approxEqual(delta, 0)) {
73708
+ this.applyScrollAdjustment(delta);
73709
+ }
73710
+ }
73711
+ }
73712
+ if (followOnAppend) {
73713
+ this.scrollToEnd({ behavior: followOnAppend });
73714
+ }
73715
+ }
73716
+ };
73717
+ this._flushIosDeferredIfReady = () => {
73718
+ if (this._iosDeferredAdjustment === 0) return;
73719
+ if (this.isScrolling) return;
73720
+ if (this._iosTouching) return;
73721
+ if (this._iosJustTouchEnded) return;
73722
+ const cur = this.getScrollOffset();
73723
+ const max = this.getMaxScrollOffset();
73724
+ if (cur < 0 || cur > max) return;
73725
+ const delta = this._iosDeferredAdjustment;
73726
+ this._iosDeferredAdjustment = 0;
73727
+ this._scrollToOffset(cur, {
73728
+ adjustments: this.scrollAdjustments += delta,
73729
+ behavior: void 0
73730
+ });
73147
73731
  };
73148
73732
  this.rafId = null;
73149
73733
  this.getSize = () => {
@@ -73205,7 +73789,7 @@ focus outline in that case.
73205
73789
  this.lanesChangedFlag = true;
73206
73790
  }
73207
73791
  this.prevLanes = lanes;
73208
- this.pendingMeasuredCacheIndexes = [];
73792
+ this.pendingMin = null;
73209
73793
  return {
73210
73794
  count,
73211
73795
  paddingStart,
@@ -73221,7 +73805,7 @@ focus outline in that case.
73221
73805
  }
73222
73806
  );
73223
73807
  this.getMeasurements = memo(
73224
- () => [this.getMeasurementOptions(), this.itemSizeCache],
73808
+ () => [this.getMeasurementOptions(), this.itemSizeCacheVersion],
73225
73809
  ({
73226
73810
  count,
73227
73811
  paddingStart,
@@ -73230,7 +73814,8 @@ focus outline in that case.
73230
73814
  enabled,
73231
73815
  lanes,
73232
73816
  laneAssignmentMode
73233
- }, itemSizeCache) => {
73817
+ }, _itemSizeCacheVersion) => {
73818
+ const itemSizeCache = this.itemSizeCache;
73234
73819
  if (!enabled) {
73235
73820
  this.measurementsCache = [];
73236
73821
  this.itemSizeCache.clear();
@@ -73250,7 +73835,7 @@ focus outline in that case.
73250
73835
  this.measurementsCache = [];
73251
73836
  this.itemSizeCache.clear();
73252
73837
  this.laneAssignments.clear();
73253
- this.pendingMeasuredCacheIndexes = [];
73838
+ this.pendingMin = null;
73254
73839
  }
73255
73840
  if (this.measurementsCache.length === 0 && !this.lanesSettling) {
73256
73841
  this.measurementsCache = this.options.initialMeasurementsCache;
@@ -73258,11 +73843,40 @@ focus outline in that case.
73258
73843
  this.itemSizeCache.set(item.key, item.size);
73259
73844
  });
73260
73845
  }
73261
- const min = this.lanesSettling ? 0 : this.pendingMeasuredCacheIndexes.length > 0 ? Math.min(...this.pendingMeasuredCacheIndexes) : 0;
73262
- this.pendingMeasuredCacheIndexes = [];
73846
+ const min = this.lanesSettling ? 0 : this.pendingMin ?? 0;
73847
+ this.pendingMin = null;
73263
73848
  if (this.lanesSettling && this.measurementsCache.length === count) {
73264
73849
  this.lanesSettling = false;
73265
73850
  }
73851
+ if (lanes === 1) {
73852
+ const gap = this.options.gap;
73853
+ const need = count * 2;
73854
+ let flat = this._flatMeasurements;
73855
+ if (!flat || flat.length < need) {
73856
+ const next = new Float64Array(need);
73857
+ if (flat && min > 0) next.set(flat.subarray(0, min * 2));
73858
+ flat = next;
73859
+ this._flatMeasurements = flat;
73860
+ }
73861
+ let runningStart;
73862
+ if (min === 0) {
73863
+ runningStart = paddingStart + scrollMargin;
73864
+ } else {
73865
+ const prevIdx = min - 1;
73866
+ runningStart = flat[prevIdx * 2] + flat[prevIdx * 2 + 1] + gap;
73867
+ }
73868
+ for (let i = min; i < count; i++) {
73869
+ const key = getItemKey(i);
73870
+ const measuredSize = itemSizeCache.get(key);
73871
+ const size = typeof measuredSize === "number" ? measuredSize : this.options.estimateSize(i);
73872
+ flat[i * 2] = runningStart;
73873
+ flat[i * 2 + 1] = size;
73874
+ runningStart += size + gap;
73875
+ }
73876
+ const view = createLazyMeasurementsView(count, flat, getItemKey);
73877
+ this.measurementsCache = view;
73878
+ return view;
73879
+ }
73266
73880
  const measurements = this.measurementsCache.slice(0, min);
73267
73881
  const laneLastIndex = new Array(lanes).fill(
73268
73882
  void 0
@@ -73325,7 +73939,11 @@ focus outline in that case.
73325
73939
  measurements,
73326
73940
  outerSize,
73327
73941
  scrollOffset,
73328
- lanes
73942
+ lanes,
73943
+ // Pass the typed array so binary search + forward-walk can
73944
+ // read start/end directly from Float64Array, skipping the
73945
+ // Proxy traps that materialize a full VirtualItem per probe.
73946
+ flat: lanes === 1 && this._flatMeasurements != null ? this._flatMeasurements : null
73329
73947
  }) : null;
73330
73948
  },
73331
73949
  {
@@ -73420,23 +74038,60 @@ focus outline in that case.
73420
74038
  }
73421
74039
  };
73422
74040
  this.resizeItem = (index, size) => {
73423
- var _a;
73424
- const item = this.measurementsCache[index];
73425
- if (!item) return;
73426
- const itemSize = this.itemSizeCache.get(item.key) ?? item.size;
74041
+ var _a, _b;
74042
+ if (index < 0 || index >= this.options.count) return;
74043
+ let cachedSize;
74044
+ let itemStart;
74045
+ let key;
74046
+ const flat = this._flatMeasurements;
74047
+ if (this.options.lanes === 1 && flat !== null) {
74048
+ key = this.options.getItemKey(index);
74049
+ itemStart = flat[index * 2];
74050
+ cachedSize = flat[index * 2 + 1];
74051
+ } else {
74052
+ const item = this.measurementsCache[index];
74053
+ if (!item) return;
74054
+ key = item.key;
74055
+ itemStart = item.start;
74056
+ cachedSize = item.size;
74057
+ }
74058
+ const itemSize = this.itemSizeCache.get(key) ?? cachedSize;
73427
74059
  const delta = size - itemSize;
73428
74060
  if (delta !== 0) {
73429
- if (((_a = this.scrollState) == null ? void 0 : _a.behavior) !== "smooth" && (this.shouldAdjustScrollPositionOnItemSizeChange !== void 0 ? this.shouldAdjustScrollPositionOnItemSizeChange(item, delta, this) : item.start < this.getScrollOffset() + this.scrollAdjustments)) {
73430
- if (this.options.debug) {
73431
- console.info("correction", delta);
73432
- }
73433
- this._scrollToOffset(this.getScrollOffset(), {
73434
- adjustments: this.scrollAdjustments += delta,
73435
- behavior: void 0
73436
- });
74061
+ const wasAtEnd = this.options.anchorTo === "end" && ((_a = this.scrollState) == null ? void 0 : _a.behavior) !== "smooth" && this.getVirtualDistanceFromEnd() <= this.options.scrollEndThreshold;
74062
+ const prevTotalSize = wasAtEnd ? this.getTotalSize() : 0;
74063
+ const shouldAdjustScroll = ((_b = this.scrollState) == null ? void 0 : _b.behavior) !== "smooth" && (this.shouldAdjustScrollPositionOnItemSizeChange !== void 0 ? this.shouldAdjustScrollPositionOnItemSizeChange(
74064
+ // The callback expects a VirtualItem; build one lazily only
74065
+ // when the consumer actually supplied a custom predicate.
74066
+ this.measurementsCache[index] ?? {
74067
+ index,
74068
+ key,
74069
+ start: itemStart,
74070
+ size: cachedSize,
74071
+ end: itemStart + cachedSize,
74072
+ lane: 0
74073
+ },
74074
+ delta,
74075
+ this
74076
+ ) : (
74077
+ // Default: adjust scrollTop only when the resize is an above-
74078
+ // viewport item AND we're not actively scrolling backward.
74079
+ // Adjusting during backward scroll fights the user's scroll
74080
+ // direction and produces the "items jump while scrolling up"
74081
+ // jank reported across many issues. Users who want the old
74082
+ // behavior can pass shouldAdjustScrollPositionOnItemSizeChange.
74083
+ itemStart < this.getScrollOffset() + this.scrollAdjustments && this.scrollDirection !== "backward"
74084
+ ));
74085
+ if (this.pendingMin === null || index < this.pendingMin) {
74086
+ this.pendingMin = index;
74087
+ }
74088
+ this.itemSizeCache.set(key, size);
74089
+ this.itemSizeCacheVersion++;
74090
+ if (wasAtEnd) {
74091
+ this.applyScrollAdjustment(this.getTotalSize() - prevTotalSize);
74092
+ } else if (shouldAdjustScroll) {
74093
+ this.applyScrollAdjustment(delta);
73437
74094
  }
73438
- this.pendingMeasuredCacheIndexes.push(item.index);
73439
- this.itemSizeCache = new Map(this.itemSizeCache.set(item.key, size));
73440
74095
  this.notify(false);
73441
74096
  }
73442
74097
  };
@@ -73461,14 +74116,15 @@ focus outline in that case.
73461
74116
  if (measurements.length === 0) {
73462
74117
  return void 0;
73463
74118
  }
73464
- return notUndefined(
73465
- measurements[findNearestBinarySearch(
73466
- 0,
73467
- measurements.length - 1,
73468
- (index) => notUndefined(measurements[index]).start,
73469
- offset
73470
- )]
74119
+ const flat = this._flatMeasurements;
74120
+ const useFlat = this.options.lanes === 1 && flat != null;
74121
+ const idx = findNearestBinarySearch(
74122
+ 0,
74123
+ measurements.length - 1,
74124
+ useFlat ? (i) => flat[i * 2] : (i) => notUndefined(measurements[i]).start,
74125
+ offset
73471
74126
  );
74127
+ return notUndefined(measurements[idx]);
73472
74128
  };
73473
74129
  this.getMaxScrollOffset = () => {
73474
74130
  if (!this.scrollElement) return 0;
@@ -73479,6 +74135,18 @@ focus outline in that case.
73479
74135
  return this.options.horizontal ? doc.scrollWidth - this.scrollElement.innerWidth : doc.scrollHeight - this.scrollElement.innerHeight;
73480
74136
  }
73481
74137
  };
74138
+ this.getVirtualDistanceFromEnd = () => {
74139
+ return Math.max(
74140
+ this.getTotalSize() - this.getSize() - this.getScrollOffset(),
74141
+ 0
74142
+ );
74143
+ };
74144
+ this.getDistanceFromEnd = () => {
74145
+ return Math.max(this.getMaxScrollOffset() - this.getScrollOffset(), 0);
74146
+ };
74147
+ this.isAtEnd = (threshold = this.options.scrollEndThreshold) => {
74148
+ return this.getDistanceFromEnd() <= threshold;
74149
+ };
73482
74150
  this.getOffsetForAlignment = (toOffset, align, itemSize = 0) => {
73483
74151
  if (!this.scrollElement) return 0;
73484
74152
  const size = this.getSize();
@@ -73568,6 +74236,18 @@ focus outline in that case.
73568
74236
  this._scrollToOffset(offset, { adjustments: void 0, behavior });
73569
74237
  this.scheduleScrollReconcile();
73570
74238
  };
74239
+ this.scrollToEnd = ({ behavior = "auto" } = {}) => {
74240
+ if (this.options.count > 0) {
74241
+ this.scrollToIndex(this.options.count - 1, {
74242
+ align: "end",
74243
+ behavior
74244
+ });
74245
+ return;
74246
+ }
74247
+ this.scrollToOffset(Math.max(this.getTotalSize() - this.getSize(), 0), {
74248
+ behavior
74249
+ });
74250
+ };
73571
74251
  this.getTotalSize = () => {
73572
74252
  var _a;
73573
74253
  const measurements = this.getMeasurements();
@@ -73575,7 +74255,13 @@ focus outline in that case.
73575
74255
  if (measurements.length === 0) {
73576
74256
  end = this.options.paddingStart;
73577
74257
  } else if (this.options.lanes === 1) {
73578
- end = ((_a = measurements[measurements.length - 1]) == null ? void 0 : _a.end) ?? 0;
74258
+ const lastIdx = measurements.length - 1;
74259
+ const flat = this._flatMeasurements;
74260
+ if (flat != null) {
74261
+ end = flat[lastIdx * 2] + flat[lastIdx * 2 + 1];
74262
+ } else {
74263
+ end = ((_a = measurements[lastIdx]) == null ? void 0 : _a.end) ?? 0;
74264
+ }
73579
74265
  } else {
73580
74266
  const endByLane = Array(this.options.lanes).fill(null);
73581
74267
  let endIndex = measurements.length - 1;
@@ -73593,19 +74279,54 @@ focus outline in that case.
73593
74279
  0
73594
74280
  );
73595
74281
  };
74282
+ this.takeSnapshot = () => {
74283
+ const snapshot = [];
74284
+ if (this.itemSizeCache.size === 0) return snapshot;
74285
+ const m = this.getMeasurements();
74286
+ for (const item of m) {
74287
+ if (item && this.itemSizeCache.has(item.key)) {
74288
+ snapshot.push({
74289
+ index: item.index,
74290
+ key: item.key,
74291
+ start: item.start,
74292
+ size: item.size,
74293
+ end: item.end,
74294
+ lane: item.lane
74295
+ });
74296
+ }
74297
+ }
74298
+ return snapshot;
74299
+ };
73596
74300
  this._scrollToOffset = (offset, {
73597
74301
  adjustments,
73598
74302
  behavior
73599
74303
  }) => {
74304
+ this._intendedScrollOffset = offset + (adjustments ?? 0);
73600
74305
  this.options.scrollToFn(offset, { behavior, adjustments }, this);
73601
74306
  };
73602
74307
  this.measure = () => {
73603
- this.itemSizeCache = /* @__PURE__ */ new Map();
73604
- this.laneAssignments = /* @__PURE__ */ new Map();
74308
+ this.pendingMin = null;
74309
+ this.itemSizeCache.clear();
74310
+ this.laneAssignments.clear();
74311
+ this.itemSizeCacheVersion++;
73605
74312
  this.notify(false);
73606
74313
  };
73607
74314
  this.setOptions(opts);
73608
74315
  }
74316
+ applyScrollAdjustment(delta, behavior) {
74317
+ if (delta === 0) return;
74318
+ if (this.options.debug) {
74319
+ console.info("correction", delta);
74320
+ }
74321
+ if (isIOSWebKit() && (this.isScrolling || this._iosTouching || this._iosJustTouchEnded)) {
74322
+ this._iosDeferredAdjustment += delta;
74323
+ } else {
74324
+ this._scrollToOffset(this.getScrollOffset(), {
74325
+ adjustments: this.scrollAdjustments += delta,
74326
+ behavior
74327
+ });
74328
+ }
74329
+ }
73609
74330
  scheduleScrollReconcile() {
73610
74331
  if (!this.targetWindow) {
73611
74332
  this.scrollState = null;
@@ -73633,17 +74354,28 @@ focus outline in that case.
73633
74354
  if (!targetChanged && approxEqual(targetOffset, this.getScrollOffset())) {
73634
74355
  this.scrollState.stableFrames++;
73635
74356
  if (this.scrollState.stableFrames >= STABLE_FRAMES) {
74357
+ if (this.getScrollOffset() !== targetOffset) {
74358
+ this._scrollToOffset(targetOffset, {
74359
+ adjustments: void 0,
74360
+ behavior: "auto"
74361
+ });
74362
+ }
73636
74363
  this.scrollState = null;
73637
74364
  return;
73638
74365
  }
73639
74366
  } else {
73640
74367
  this.scrollState.stableFrames = 0;
73641
74368
  if (targetChanged) {
74369
+ const viewport = this.getSize() || 600;
74370
+ const distance = Math.abs(targetOffset - this.getScrollOffset());
74371
+ const keepSmooth = this.scrollState.behavior === "smooth" && distance > viewport;
73642
74372
  this.scrollState.lastTargetOffset = targetOffset;
73643
- this.scrollState.behavior = "auto";
74373
+ if (!keepSmooth) {
74374
+ this.scrollState.behavior = "auto";
74375
+ }
73644
74376
  this._scrollToOffset(targetOffset, {
73645
74377
  adjustments: void 0,
73646
- behavior: "auto"
74378
+ behavior: keepSmooth ? "smooth" : "auto"
73647
74379
  });
73648
74380
  }
73649
74381
  }
@@ -73672,25 +74404,22 @@ focus outline in that case.
73672
74404
  measurements,
73673
74405
  outerSize,
73674
74406
  scrollOffset,
73675
- lanes
74407
+ lanes,
74408
+ flat
73676
74409
  }) {
73677
74410
  const lastIndex = measurements.length - 1;
73678
- const getOffset = (index) => measurements[index].start;
74411
+ const getStart = flat ? (index) => flat[index * 2] : (index) => measurements[index].start;
74412
+ const getEnd = flat ? (index) => flat[index * 2] + flat[index * 2 + 1] : (index) => measurements[index].end;
73679
74413
  if (measurements.length <= lanes) {
73680
74414
  return {
73681
74415
  startIndex: 0,
73682
74416
  endIndex: lastIndex
73683
74417
  };
73684
74418
  }
73685
- let startIndex = findNearestBinarySearch(
73686
- 0,
73687
- lastIndex,
73688
- getOffset,
73689
- scrollOffset
73690
- );
74419
+ let startIndex = findNearestBinarySearch(0, lastIndex, getStart, scrollOffset);
73691
74420
  let endIndex = startIndex;
73692
74421
  if (lanes === 1) {
73693
- while (endIndex < lastIndex && measurements[endIndex].end < scrollOffset + outerSize) {
74422
+ while (endIndex < lastIndex && getEnd(endIndex) < scrollOffset + outerSize) {
73694
74423
  endIndex++;
73695
74424
  }
73696
74425
  } else if (lanes > 1) {