@lexical/react 0.8.0 → 0.9.0

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.
Files changed (94) hide show
  1. package/LexicalAutoEmbedPlugin.d.ts +1 -0
  2. package/LexicalAutoEmbedPlugin.dev.js +11 -0
  3. package/LexicalAutoFocusPlugin.dev.js +1 -0
  4. package/LexicalAutoLinkPlugin.d.ts +1 -0
  5. package/LexicalAutoLinkPlugin.dev.js +57 -11
  6. package/LexicalAutoLinkPlugin.prod.js +7 -6
  7. package/LexicalBlockWithAlignableContents.dev.js +13 -2
  8. package/LexicalBlockWithAlignableContents.prod.js +4 -4
  9. package/LexicalCharacterLimitPlugin.d.ts +1 -0
  10. package/LexicalCharacterLimitPlugin.dev.js +46 -7
  11. package/LexicalCheckListPlugin.dev.js +50 -12
  12. package/LexicalCheckListPlugin.prod.js +1 -1
  13. package/LexicalClearEditorPlugin.d.ts +1 -0
  14. package/LexicalClearEditorPlugin.dev.js +1 -1
  15. package/LexicalCollaborationContext.dev.js +3 -0
  16. package/LexicalCollaborationPlugin.d.ts +3 -2
  17. package/LexicalCollaborationPlugin.dev.js +35 -6
  18. package/LexicalComposer.d.ts +1 -0
  19. package/LexicalComposer.dev.js +10 -6
  20. package/LexicalComposerContext.dev.js +6 -0
  21. package/LexicalContentEditable.dev.js +0 -1
  22. package/LexicalContentEditable.js.flow +1 -0
  23. package/LexicalDecoratorBlockNode.d.ts +1 -0
  24. package/LexicalDecoratorBlockNode.dev.js +5 -0
  25. package/LexicalErrorBoundary.d.ts +1 -0
  26. package/LexicalHashtagPlugin.d.ts +1 -0
  27. package/LexicalHashtagPlugin.dev.js +43 -73
  28. package/LexicalHorizontalRuleNode.d.ts +1 -0
  29. package/LexicalHorizontalRuleNode.dev.js +22 -0
  30. package/LexicalHorizontalRulePlugin.dev.js +4 -0
  31. package/LexicalLinkPlugin.dev.js +10 -4
  32. package/LexicalListPlugin.dev.js +2 -0
  33. package/LexicalMarkdownShortcutPlugin.dev.js +2 -2
  34. package/LexicalNestedComposer.dev.js +12 -6
  35. package/LexicalNestedComposer.prod.js +2 -2
  36. package/LexicalNodeEventPlugin.dev.js +3 -5
  37. package/LexicalOnChangePlugin.dev.js +1 -1
  38. package/LexicalPlainTextPlugin.d.ts +1 -0
  39. package/LexicalPlainTextPlugin.dev.js +12 -8
  40. package/LexicalRichTextPlugin.d.ts +1 -0
  41. package/LexicalRichTextPlugin.dev.js +12 -8
  42. package/LexicalTabIndentationPlugin.dev.js +3 -1
  43. package/{LexicalTableOfContents__EXPERIMENTAL.d.ts → LexicalTableOfContents.d.ts} +1 -0
  44. package/{LexicalTableOfContents__EXPERIMENTAL.dev.js → LexicalTableOfContents.dev.js} +33 -5
  45. package/{DEPRECATED_useLexical.js → LexicalTableOfContents.js} +2 -2
  46. package/LexicalTablePlugin.d.ts +1 -0
  47. package/LexicalTablePlugin.dev.js +19 -5
  48. package/LexicalTreeView.d.ts +1 -0
  49. package/LexicalTreeView.dev.js +113 -21
  50. package/LexicalTreeView.prod.js +16 -15
  51. package/LexicalTypeaheadMenuPlugin.dev.js +123 -17
  52. package/LexicalTypeaheadMenuPlugin.prod.js +18 -18
  53. package/package.json +19 -19
  54. package/shared/useYjsCollaboration.d.ts +3 -4
  55. package/useLexicalEditable.dev.js +5 -1
  56. package/useLexicalIsTextContentEmpty.dev.js +0 -1
  57. package/useLexicalNodeSelection.dev.js +7 -0
  58. package/useLexicalSubscription.dev.js +3 -1
  59. package/DEPRECATED_useLexical.d.ts +0 -18
  60. package/DEPRECATED_useLexical.dev.js +0 -104
  61. package/DEPRECATED_useLexical.js.flow +0 -25
  62. package/DEPRECATED_useLexical.prod.js +0 -8
  63. package/DEPRECATED_useLexicalCanShowPlaceholder.d.ts +0 -9
  64. package/DEPRECATED_useLexicalCanShowPlaceholder.dev.js +0 -72
  65. package/DEPRECATED_useLexicalCanShowPlaceholder.js +0 -9
  66. package/DEPRECATED_useLexicalCanShowPlaceholder.js.flow +0 -15
  67. package/DEPRECATED_useLexicalCanShowPlaceholder.prod.js +0 -8
  68. package/DEPRECATED_useLexicalCharacterLimit.d.ts +0 -8
  69. package/DEPRECATED_useLexicalCharacterLimit.dev.js +0 -213
  70. package/DEPRECATED_useLexicalCharacterLimit.js +0 -9
  71. package/DEPRECATED_useLexicalCharacterLimit.js.flow +0 -31
  72. package/DEPRECATED_useLexicalCharacterLimit.prod.js +0 -13
  73. package/DEPRECATED_useLexicalEditor.d.ts +0 -9
  74. package/DEPRECATED_useLexicalEditor.dev.js +0 -87
  75. package/DEPRECATED_useLexicalEditor.js +0 -9
  76. package/DEPRECATED_useLexicalEditor.prod.js +0 -8
  77. package/DEPRECATED_useLexicalHistory.d.ts +0 -12
  78. package/DEPRECATED_useLexicalHistory.dev.js +0 -38
  79. package/DEPRECATED_useLexicalHistory.js +0 -9
  80. package/DEPRECATED_useLexicalHistory.js.flow +0 -34
  81. package/DEPRECATED_useLexicalHistory.prod.js +0 -7
  82. package/DEPRECATED_useLexicalPlainText.d.ts +0 -10
  83. package/DEPRECATED_useLexicalPlainText.dev.js +0 -88
  84. package/DEPRECATED_useLexicalPlainText.js +0 -9
  85. package/DEPRECATED_useLexicalPlainText.js.flow +0 -17
  86. package/DEPRECATED_useLexicalPlainText.prod.js +0 -8
  87. package/DEPRECATED_useLexicalRichText.d.ts +0 -10
  88. package/DEPRECATED_useLexicalRichText.dev.js +0 -88
  89. package/DEPRECATED_useLexicalRichText.js +0 -9
  90. package/DEPRECATED_useLexicalRichText.js.flow +0 -17
  91. package/DEPRECATED_useLexicalRichText.prod.js +0 -8
  92. package/LexicalTableOfContents__EXPERIMENTAL.js +0 -9
  93. /package/{LexicalTableOfContents__EXPERIMENTAL.js.flow → LexicalTableOfContents.js.flow} +0 -0
  94. /package/{LexicalTableOfContents__EXPERIMENTAL.prod.js → LexicalTableOfContents.prod.js} +0 -0
@@ -18,7 +18,6 @@ var React = require('react');
18
18
  * LICENSE file in the root directory of this source tree.
19
19
  *
20
20
  */
21
-
22
21
  const CAN_USE_DOM = typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined';
23
22
 
24
23
  /**
@@ -47,171 +46,216 @@ class TypeaheadOption {
47
46
  };
48
47
  this.setRefElement = this.setRefElement.bind(this);
49
48
  }
49
+
50
50
  setRefElement(element) {
51
51
  this.ref = {
52
52
  current: element
53
53
  };
54
54
  }
55
+
55
56
  }
57
+
56
58
  const scrollIntoViewIfNeeded = target => {
57
59
  const container = document.getElementById('typeahead-menu');
58
60
  if (!container) return;
59
61
  const typeaheadContainerNode = container.querySelector('.typeahead-popover');
60
62
  if (!typeaheadContainerNode) return;
61
63
  const typeaheadRect = typeaheadContainerNode.getBoundingClientRect();
64
+
62
65
  if (typeaheadRect.top + typeaheadRect.height > window.innerHeight) {
63
66
  typeaheadContainerNode.scrollIntoView({
64
67
  block: 'center'
65
68
  });
66
69
  }
70
+
67
71
  if (typeaheadRect.top < 0) {
68
72
  typeaheadContainerNode.scrollIntoView({
69
73
  block: 'center'
70
74
  });
71
75
  }
76
+
72
77
  target.scrollIntoView({
73
78
  block: 'nearest'
74
79
  });
75
80
  };
81
+
76
82
  function getTextUpToAnchor(selection) {
77
83
  const anchor = selection.anchor;
84
+
78
85
  if (anchor.type !== 'text') {
79
86
  return null;
80
87
  }
88
+
81
89
  const anchorNode = anchor.getNode();
90
+
82
91
  if (!anchorNode.isSimpleText()) {
83
92
  return null;
84
93
  }
94
+
85
95
  const anchorOffset = anchor.offset;
86
96
  return anchorNode.getTextContent().slice(0, anchorOffset);
87
97
  }
98
+
88
99
  function tryToPositionRange(leadOffset, range) {
89
100
  const domSelection = window.getSelection();
101
+
90
102
  if (domSelection === null || !domSelection.isCollapsed) {
91
103
  return false;
92
104
  }
105
+
93
106
  const anchorNode = domSelection.anchorNode;
94
107
  const startOffset = leadOffset;
95
108
  const endOffset = domSelection.anchorOffset;
109
+
96
110
  if (anchorNode == null || endOffset == null) {
97
111
  return false;
98
112
  }
113
+
99
114
  try {
100
115
  range.setStart(anchorNode, startOffset);
101
116
  range.setEnd(anchorNode, endOffset);
102
117
  } catch (error) {
103
118
  return false;
104
119
  }
120
+
105
121
  return true;
106
122
  }
123
+
107
124
  function getQueryTextForSearch(editor) {
108
125
  let text = null;
109
126
  editor.getEditorState().read(() => {
110
127
  const selection = lexical.$getSelection();
128
+
111
129
  if (!lexical.$isRangeSelection(selection)) {
112
130
  return;
113
131
  }
132
+
114
133
  text = getTextUpToAnchor(selection);
115
134
  });
116
135
  return text;
117
136
  }
118
-
119
137
  /**
120
138
  * Walk backwards along user input and forward through entity title to try
121
139
  * and replace more of the user's text with entity.
122
140
  */
141
+
142
+
123
143
  function getFullMatchOffset(documentText, entryText, offset) {
124
144
  let triggerOffset = offset;
145
+
125
146
  for (let i = triggerOffset; i <= entryText.length; i++) {
126
147
  if (documentText.substr(-i) === entryText.substr(0, i)) {
127
148
  triggerOffset = i;
128
149
  }
129
150
  }
151
+
130
152
  return triggerOffset;
131
153
  }
132
-
133
154
  /**
134
155
  * Split Lexical TextNode and return a new TextNode only containing matched text.
135
156
  * Common use cases include: removing the node, replacing with a new node.
136
157
  */
158
+
159
+
137
160
  function splitNodeContainingQuery(editor, match) {
138
161
  const selection = lexical.$getSelection();
162
+
139
163
  if (!lexical.$isRangeSelection(selection) || !selection.isCollapsed()) {
140
164
  return null;
141
165
  }
166
+
142
167
  const anchor = selection.anchor;
168
+
143
169
  if (anchor.type !== 'text') {
144
170
  return null;
145
171
  }
172
+
146
173
  const anchorNode = anchor.getNode();
174
+
147
175
  if (!anchorNode.isSimpleText()) {
148
176
  return null;
149
177
  }
178
+
150
179
  const selectionOffset = anchor.offset;
151
180
  const textContent = anchorNode.getTextContent().slice(0, selectionOffset);
152
181
  const characterOffset = match.replaceableString.length;
153
182
  const queryOffset = getFullMatchOffset(textContent, match.matchingString, characterOffset);
154
183
  const startOffset = selectionOffset - queryOffset;
184
+
155
185
  if (startOffset < 0) {
156
186
  return null;
157
187
  }
188
+
158
189
  let newNode;
190
+
159
191
  if (startOffset === 0) {
160
192
  [newNode] = anchorNode.splitText(selectionOffset);
161
193
  } else {
162
194
  [, newNode] = anchorNode.splitText(startOffset, selectionOffset);
163
195
  }
196
+
164
197
  return newNode;
165
198
  }
199
+
166
200
  function isSelectionOnEntityBoundary(editor, offset) {
167
201
  if (offset !== 0) {
168
202
  return false;
169
203
  }
204
+
170
205
  return editor.getEditorState().read(() => {
171
206
  const selection = lexical.$getSelection();
207
+
172
208
  if (lexical.$isRangeSelection(selection)) {
173
209
  const anchor = selection.anchor;
174
210
  const anchorNode = anchor.getNode();
175
211
  const prevSibling = anchorNode.getPreviousSibling();
176
212
  return lexical.$isTextNode(prevSibling) && prevSibling.isTextEntity();
177
213
  }
214
+
178
215
  return false;
179
216
  });
180
217
  }
218
+
181
219
  function startTransition(callback) {
182
220
  if (React.startTransition) {
183
221
  React.startTransition(callback);
184
222
  } else {
185
223
  callback();
186
224
  }
187
- }
225
+ } // Got from https://stackoverflow.com/a/42543908/2013580
226
+
188
227
 
189
- // Got from https://stackoverflow.com/a/42543908/2013580
190
228
  function getScrollParent(element, includeHidden) {
191
229
  let style = getComputedStyle(element);
192
230
  const excludeStaticParent = style.position === 'absolute';
193
231
  const overflowRegex = includeHidden ? /(auto|scroll|hidden)/ : /(auto|scroll)/;
232
+
194
233
  if (style.position === 'fixed') {
195
234
  return document.body;
196
235
  }
236
+
197
237
  for (let parent = element; parent = parent.parentElement;) {
198
238
  style = getComputedStyle(parent);
239
+
199
240
  if (excludeStaticParent && style.position === 'static') {
200
241
  continue;
201
242
  }
243
+
202
244
  if (overflowRegex.test(style.overflow + style.overflowY + style.overflowX)) {
203
245
  return parent;
204
246
  }
205
247
  }
248
+
206
249
  return document.body;
207
250
  }
251
+
208
252
  function isTriggerVisibleInNearestScrollContainer(targetElement, containerElement) {
209
253
  const tRect = targetElement.getBoundingClientRect();
210
254
  const cRect = containerElement.getBoundingClientRect();
211
255
  return tRect.top > cRect.top && tRect.top < cRect.bottom;
212
- }
256
+ } // Reposition the menu on scroll, window resize, and element resize.
257
+
213
258
 
214
- // Reposition the menu on scroll, window resize, and element resize.
215
259
  function useDynamicPositioning(resolution, targetElement, onReposition, onVisibilityChange) {
216
260
  const [editor] = LexicalComposerContext.useLexicalComposerContext();
217
261
  React.useEffect(() => {
@@ -220,6 +264,7 @@ function useDynamicPositioning(resolution, targetElement, onReposition, onVisibi
220
264
  const rootScrollParent = rootElement != null ? getScrollParent(rootElement, false) : document.body;
221
265
  let ticking = false;
222
266
  let previousIsInView = isTriggerVisibleInNearestScrollContainer(targetElement, rootScrollParent);
267
+
223
268
  const handleScroll = function () {
224
269
  if (!ticking) {
225
270
  window.requestAnimationFrame(function () {
@@ -228,14 +273,18 @@ function useDynamicPositioning(resolution, targetElement, onReposition, onVisibi
228
273
  });
229
274
  ticking = true;
230
275
  }
276
+
231
277
  const isInView = isTriggerVisibleInNearestScrollContainer(targetElement, rootScrollParent);
278
+
232
279
  if (isInView !== previousIsInView) {
233
280
  previousIsInView = isInView;
281
+
234
282
  if (onVisibilityChange != null) {
235
283
  onVisibilityChange(isInView);
236
284
  }
237
285
  }
238
286
  };
287
+
239
288
  const resizeObserver = new ResizeObserver(onReposition);
240
289
  window.addEventListener('resize', onReposition);
241
290
  document.addEventListener('scroll', handleScroll, {
@@ -252,6 +301,7 @@ function useDynamicPositioning(resolution, targetElement, onReposition, onVisibi
252
301
  }, [targetElement, editor, onVisibilityChange, onReposition, resolution]);
253
302
  }
254
303
  const SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND = lexical.createCommand('SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND');
304
+
255
305
  function LexicalPopoverMenu({
256
306
  close,
257
307
  editor,
@@ -273,6 +323,7 @@ function LexicalPopoverMenu({
273
323
  }, [close, editor, resolution.match, onSelectOption]);
274
324
  const updateSelectedIndex = React.useCallback(index => {
275
325
  const rootElem = editor.getRootElement();
326
+
276
327
  if (rootElem !== null) {
277
328
  rootElem.setAttribute('aria-activedescendant', 'typeahead-item-' + index);
278
329
  setHighlightedIndex(index);
@@ -281,6 +332,7 @@ function LexicalPopoverMenu({
281
332
  React.useEffect(() => {
282
333
  return () => {
283
334
  const rootElem = editor.getRootElement();
335
+
284
336
  if (rootElem !== null) {
285
337
  rootElem.removeAttribute('aria-activedescendant');
286
338
  }
@@ -301,38 +353,47 @@ function LexicalPopoverMenu({
301
353
  scrollIntoViewIfNeeded(option.ref.current);
302
354
  return true;
303
355
  }
356
+
304
357
  return false;
305
358
  }, lexical.COMMAND_PRIORITY_LOW));
306
359
  }, [editor, updateSelectedIndex]);
307
360
  React.useEffect(() => {
308
361
  return utils.mergeRegister(editor.registerCommand(lexical.KEY_ARROW_DOWN_COMMAND, payload => {
309
362
  const event = payload;
363
+
310
364
  if (options !== null && options.length && selectedIndex !== null) {
311
365
  const newSelectedIndex = selectedIndex !== options.length - 1 ? selectedIndex + 1 : 0;
312
366
  updateSelectedIndex(newSelectedIndex);
313
367
  const option = options[newSelectedIndex];
368
+
314
369
  if (option.ref != null && option.ref.current) {
315
370
  editor.dispatchCommand(SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND, {
316
371
  index: newSelectedIndex,
317
372
  option
318
373
  });
319
374
  }
375
+
320
376
  event.preventDefault();
321
377
  event.stopImmediatePropagation();
322
378
  }
379
+
323
380
  return true;
324
381
  }, lexical.COMMAND_PRIORITY_LOW), editor.registerCommand(lexical.KEY_ARROW_UP_COMMAND, payload => {
325
382
  const event = payload;
383
+
326
384
  if (options !== null && options.length && selectedIndex !== null) {
327
385
  const newSelectedIndex = selectedIndex !== 0 ? selectedIndex - 1 : options.length - 1;
328
386
  updateSelectedIndex(newSelectedIndex);
329
387
  const option = options[newSelectedIndex];
388
+
330
389
  if (option.ref != null && option.ref.current) {
331
390
  scrollIntoViewIfNeeded(option.ref.current);
332
391
  }
392
+
333
393
  event.preventDefault();
334
394
  event.stopImmediatePropagation();
335
395
  }
396
+
336
397
  return true;
337
398
  }, lexical.COMMAND_PRIORITY_LOW), editor.registerCommand(lexical.KEY_ESCAPE_COMMAND, payload => {
338
399
  const event = payload;
@@ -342,9 +403,11 @@ function LexicalPopoverMenu({
342
403
  return true;
343
404
  }, lexical.COMMAND_PRIORITY_LOW), editor.registerCommand(lexical.KEY_TAB_COMMAND, payload => {
344
405
  const event = payload;
406
+
345
407
  if (options === null || selectedIndex === null || options[selectedIndex] == null) {
346
408
  return false;
347
409
  }
410
+
348
411
  event.preventDefault();
349
412
  event.stopImmediatePropagation();
350
413
  selectOptionAndCleanUp(options[selectedIndex]);
@@ -353,10 +416,12 @@ function LexicalPopoverMenu({
353
416
  if (options === null || selectedIndex === null || options[selectedIndex] == null) {
354
417
  return false;
355
418
  }
419
+
356
420
  if (event !== null) {
357
421
  event.preventDefault();
358
422
  event.stopImmediatePropagation();
359
423
  }
424
+
360
425
  selectOptionAndCleanUp(options[selectedIndex]);
361
426
  return true;
362
427
  }, lexical.COMMAND_PRIORITY_LOW));
@@ -369,6 +434,7 @@ function LexicalPopoverMenu({
369
434
  }), [selectOptionAndCleanUp, selectedIndex, options]);
370
435
  return menuRenderFn(anchorElementRef, listItemProps, resolution.match.matchingString);
371
436
  }
437
+
372
438
  function useBasicTypeaheadTriggerMatch(trigger, {
373
439
  minLength = 1,
374
440
  maxLength = 75
@@ -377,9 +443,11 @@ function useBasicTypeaheadTriggerMatch(trigger, {
377
443
  const validChars = '[^' + trigger + PUNCTUATION + '\\s]';
378
444
  const TypeaheadTriggerRegex = new RegExp('(^|\\s|\\()(' + '[' + trigger + ']' + '((?:' + validChars + '){0,' + maxLength + '})' + ')$');
379
445
  const match = TypeaheadTriggerRegex.exec(text);
446
+
380
447
  if (match !== null) {
381
448
  const maybeLeadingWhitespace = match[1];
382
449
  const matchingString = match[3];
450
+
383
451
  if (matchingString.length >= minLength) {
384
452
  return {
385
453
  leadOffset: match.index + maybeLeadingWhitespace.length,
@@ -388,15 +456,18 @@ function useBasicTypeaheadTriggerMatch(trigger, {
388
456
  };
389
457
  }
390
458
  }
459
+
391
460
  return null;
392
461
  }, [maxLength, minLength, trigger]);
393
462
  }
463
+
394
464
  function useMenuAnchorRef(resolution, setResolution, className) {
395
465
  const [editor] = LexicalComposerContext.useLexicalComposerContext();
396
466
  const anchorElementRef = React.useRef(document.createElement('div'));
397
467
  const positionMenu = React.useCallback(() => {
398
468
  const rootElement = editor.getRootElement();
399
469
  const containerDiv = anchorElementRef.current;
470
+
400
471
  if (rootElement !== null && resolution !== null) {
401
472
  const {
402
473
  left,
@@ -408,10 +479,12 @@ function useMenuAnchorRef(resolution, setResolution, className) {
408
479
  containerDiv.style.left = `${left + window.pageXOffset}px`;
409
480
  containerDiv.style.height = `${height}px`;
410
481
  containerDiv.style.width = `${width}px`;
482
+
411
483
  if (!containerDiv.isConnected) {
412
484
  if (className != null) {
413
485
  containerDiv.className = className;
414
486
  }
487
+
415
488
  containerDiv.setAttribute('aria-label', 'Typeahead menu');
416
489
  containerDiv.setAttribute('id', 'typeahead-menu');
417
490
  containerDiv.setAttribute('role', 'listbox');
@@ -419,19 +492,23 @@ function useMenuAnchorRef(resolution, setResolution, className) {
419
492
  containerDiv.style.position = 'absolute';
420
493
  document.body.append(containerDiv);
421
494
  }
495
+
422
496
  anchorElementRef.current = containerDiv;
423
497
  rootElement.setAttribute('aria-controls', 'typeahead-menu');
424
498
  }
425
499
  }, [editor, resolution, className]);
426
500
  React.useEffect(() => {
427
501
  const rootElement = editor.getRootElement();
502
+
428
503
  if (resolution !== null) {
429
504
  positionMenu();
430
505
  return () => {
431
506
  if (rootElement !== null) {
432
507
  rootElement.removeAttribute('aria-controls');
433
508
  }
509
+
434
510
  const containerDiv = anchorElementRef.current;
511
+
435
512
  if (containerDiv !== null && containerDiv.isConnected) {
436
513
  containerDiv.remove();
437
514
  }
@@ -448,6 +525,7 @@ function useMenuAnchorRef(resolution, setResolution, className) {
448
525
  useDynamicPositioning(resolution, anchorElementRef.current, positionMenu, onVisibilityChange);
449
526
  return anchorElementRef;
450
527
  }
528
+
451
529
  function LexicalTypeaheadMenuPlugin({
452
530
  options,
453
531
  onQueryChange,
@@ -463,12 +541,14 @@ function LexicalTypeaheadMenuPlugin({
463
541
  const anchorElementRef = useMenuAnchorRef(resolution, setResolution, anchorClassName);
464
542
  const closeTypeahead = React.useCallback(() => {
465
543
  setResolution(null);
544
+
466
545
  if (onClose != null && resolution !== null) {
467
546
  onClose();
468
547
  }
469
548
  }, [onClose, resolution]);
470
549
  const openTypeahead = React.useCallback(res => {
471
550
  setResolution(res);
551
+
472
552
  if (onOpen != null && resolution === null) {
473
553
  onOpen(res);
474
554
  }
@@ -479,14 +559,18 @@ function LexicalTypeaheadMenuPlugin({
479
559
  const range = document.createRange();
480
560
  const selection = lexical.$getSelection();
481
561
  const text = getQueryTextForSearch(editor);
562
+
482
563
  if (!lexical.$isRangeSelection(selection) || !selection.isCollapsed() || text === null || range === null) {
483
564
  closeTypeahead();
484
565
  return;
485
566
  }
567
+
486
568
  const match = triggerFn(text, editor);
487
569
  onQueryChange(match ? match.matchingString : null);
570
+
488
571
  if (match !== null && !isSelectionOnEntityBoundary(editor, match.leadOffset)) {
489
572
  const isRangePositioned = tryToPositionRange(match.leadOffset, range);
573
+
490
574
  if (isRangePositioned !== null) {
491
575
  startTransition(() => openTypeahead({
492
576
  getRect: () => range.getBoundingClientRect(),
@@ -495,9 +579,11 @@ function LexicalTypeaheadMenuPlugin({
495
579
  return;
496
580
  }
497
581
  }
582
+
498
583
  closeTypeahead();
499
584
  });
500
585
  };
586
+
501
587
  const removeUpdateListener = editor.registerUpdateListener(updateListener);
502
588
  return () => {
503
589
  removeUpdateListener();
@@ -527,37 +613,57 @@ function LexicalNodeMenuPlugin({
527
613
  const anchorElementRef = useMenuAnchorRef(resolution, setResolution, anchorClassName);
528
614
  const closeNodeMenu = React.useCallback(() => {
529
615
  setResolution(null);
616
+
530
617
  if (onClose != null && resolution !== null) {
531
618
  onClose();
532
619
  }
533
620
  }, [onClose, resolution]);
534
621
  const openNodeMenu = React.useCallback(res => {
535
622
  setResolution(res);
623
+
536
624
  if (onOpen != null && resolution === null) {
537
625
  onOpen(res);
538
626
  }
539
627
  }, [onOpen, resolution]);
540
- React.useEffect(() => {
541
- if (nodeKey && resolution == null) {
628
+ const positionOrCloseMenu = React.useCallback(() => {
629
+ if (nodeKey) {
542
630
  editor.update(() => {
543
631
  const node = lexical.$getNodeByKey(nodeKey);
544
632
  const domElement = editor.getElementByKey(nodeKey);
633
+
545
634
  if (node != null && domElement != null) {
546
635
  const text = node.getTextContent();
547
- startTransition(() => openNodeMenu({
548
- getRect: () => domElement.getBoundingClientRect(),
549
- match: {
550
- leadOffset: text.length,
551
- matchingString: text,
552
- replaceableString: text
553
- }
554
- }));
636
+
637
+ if (resolution == null || resolution.match.matchingString !== text) {
638
+ startTransition(() => openNodeMenu({
639
+ getRect: () => domElement.getBoundingClientRect(),
640
+ match: {
641
+ leadOffset: text.length,
642
+ matchingString: text,
643
+ replaceableString: text
644
+ }
645
+ }));
646
+ }
555
647
  }
556
648
  });
557
649
  } else if (nodeKey == null && resolution != null) {
558
650
  closeNodeMenu();
559
651
  }
560
652
  }, [closeNodeMenu, editor, nodeKey, openNodeMenu, resolution]);
653
+ React.useEffect(() => {
654
+ positionOrCloseMenu();
655
+ }, [positionOrCloseMenu, nodeKey]);
656
+ React.useEffect(() => {
657
+ if (nodeKey != null) {
658
+ return editor.registerUpdateListener(({
659
+ dirtyElements
660
+ }) => {
661
+ if (dirtyElements.get(nodeKey)) {
662
+ positionOrCloseMenu();
663
+ }
664
+ });
665
+ }
666
+ }, [editor, positionOrCloseMenu, nodeKey]);
561
667
  return resolution === null || editor === null ? null : /*#__PURE__*/React.createElement(LexicalPopoverMenu, {
562
668
  close: closeNodeMenu,
563
669
  resolution: resolution,
@@ -4,23 +4,23 @@
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
- 'use strict';var k=require("@lexical/react/LexicalComposerContext"),n=require("@lexical/utils"),w=require("lexical"),x=require("react"),y="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?x.useLayoutEffect:x.useEffect;class z{constructor(c){this.key=c;this.ref={current:null};this.setRefElement=this.setRefElement.bind(this)}setRefElement(c){this.ref={current:c}}}
8
- let A=c=>{var a=document.getElementById("typeahead-menu");if(a&&(a=a.querySelector(".typeahead-popover"))){var b=a.getBoundingClientRect();b.top+b.height>window.innerHeight&&a.scrollIntoView({block:"center"});0>b.top&&a.scrollIntoView({block:"center"});c.scrollIntoView({block:"nearest"})}};function B(c,a){var b=window.getSelection();if(null===b||!b.isCollapsed)return!1;let e=b.anchorNode;b=b.anchorOffset;if(null==e||null==b)return!1;try{a.setStart(e,c),a.setEnd(e,b)}catch(f){return!1}return!0}
9
- function C(c){let a=null;c.getEditorState().read(()=>{var b=w.$getSelection();if(w.$isRangeSelection(b)){var e=b.anchor;"text"!==e.type?a=null:(b=e.getNode(),b.isSimpleText()?(e=e.offset,a=b.getTextContent().slice(0,e)):a=null)}});return a}
10
- function D(c,a){c=w.$getSelection();if(!w.$isRangeSelection(c)||!c.isCollapsed())return null;var b=c.anchor;if("text"!==b.type)return null;c=b.getNode();if(!c.isSimpleText())return null;b=b.offset;let e=c.getTextContent().slice(0,b);var f=a.matchingString;a=a.replaceableString.length;for(let p=a;p<=f.length;p++)e.substr(-p)===f.substr(0,p)&&(a=p);a=b-a;if(0>a)return null;let q;0===a?[q]=c.splitText(b):[,q]=c.splitText(a,b);return q}
11
- function E(c,a){return 0!==a?!1:c.getEditorState().read(()=>{var b=w.$getSelection();return w.$isRangeSelection(b)?(b=b.anchor.getNode().getPreviousSibling(),w.$isTextNode(b)&&b.isTextEntity()):!1})}function F(c){x.startTransition?x.startTransition(c):c()}
7
+ 'use strict';var k=require("@lexical/react/LexicalComposerContext"),n=require("@lexical/utils"),x=require("lexical"),y=require("react"),z="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?y.useLayoutEffect:y.useEffect;class A{constructor(c){this.key=c;this.ref={current:null};this.setRefElement=this.setRefElement.bind(this)}setRefElement(c){this.ref={current:c}}}
8
+ let B=c=>{var a=document.getElementById("typeahead-menu");if(a&&(a=a.querySelector(".typeahead-popover"))){var b=a.getBoundingClientRect();b.top+b.height>window.innerHeight&&a.scrollIntoView({block:"center"});0>b.top&&a.scrollIntoView({block:"center"});c.scrollIntoView({block:"nearest"})}};function C(c,a){var b=window.getSelection();if(null===b||!b.isCollapsed)return!1;let e=b.anchorNode;b=b.anchorOffset;if(null==e||null==b)return!1;try{a.setStart(e,c),a.setEnd(e,b)}catch(g){return!1}return!0}
9
+ function D(c){let a=null;c.getEditorState().read(()=>{var b=x.$getSelection();if(x.$isRangeSelection(b)){var e=b.anchor;"text"!==e.type?a=null:(b=e.getNode(),b.isSimpleText()?(e=e.offset,a=b.getTextContent().slice(0,e)):a=null)}});return a}
10
+ function E(c,a){c=x.$getSelection();if(!x.$isRangeSelection(c)||!c.isCollapsed())return null;var b=c.anchor;if("text"!==b.type)return null;c=b.getNode();if(!c.isSimpleText())return null;b=b.offset;let e=c.getTextContent().slice(0,b);var g=a.matchingString;a=a.replaceableString.length;for(let p=a;p<=g.length;p++)e.substr(-p)===g.substr(0,p)&&(a=p);a=b-a;if(0>a)return null;let q;0===a?[q]=c.splitText(b):[,q]=c.splitText(a,b);return q}
11
+ function F(c,a){return 0!==a?!1:c.getEditorState().read(()=>{var b=x.$getSelection();return x.$isRangeSelection(b)?(b=b.anchor.getNode().getPreviousSibling(),x.$isTextNode(b)&&b.isTextEntity()):!1})}function G(c){y.startTransition?y.startTransition(c):c()}
12
12
  function I(c,a){let b=getComputedStyle(c),e="absolute"===b.position;a=a?/(auto|scroll|hidden)/:/(auto|scroll)/;if("fixed"===b.position)return document.body;for(;c=c.parentElement;)if(b=getComputedStyle(c),(!e||"static"!==b.position)&&a.test(b.overflow+b.overflowY+b.overflowX))return c;return document.body}function J(c,a){c=c.getBoundingClientRect();a=a.getBoundingClientRect();return c.top>a.top&&c.top<a.bottom}
13
- function K(c,a,b,e){let [f]=k.useLexicalComposerContext();x.useEffect(()=>{if(null!=a&&null!=c){let q=f.getRootElement(),p=null!=q?I(q,!1):document.body,g=!1,d=J(a,p),l=function(){g||(window.requestAnimationFrame(function(){b();g=!1}),g=!0);const t=J(a,p);t!==d&&(d=t,null!=e&&e(t))},r=new ResizeObserver(b);window.addEventListener("resize",b);document.addEventListener("scroll",l,{capture:!0,passive:!0});r.observe(a);return()=>{r.unobserve(a);window.removeEventListener("resize",b);document.removeEventListener("scroll",
14
- l)}}},[a,f,e,b,c])}let L=w.createCommand("SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND");
15
- function M({close:c,editor:a,anchorElementRef:b,resolution:e,options:f,menuRenderFn:q,onSelectOption:p}){let [g,d]=x.useState(null);x.useEffect(()=>{d(0)},[e.match.matchingString]);let l=x.useCallback(h=>{a.update(()=>{const m=D(a,e.match);p(h,m,c,e.match.matchingString)})},[c,a,e.match,p]),r=x.useCallback(h=>{const m=a.getRootElement();null!==m&&(m.setAttribute("aria-activedescendant","typeahead-item-"+h),d(h))},[a]);x.useEffect(()=>()=>{let h=a.getRootElement();null!==h&&h.removeAttribute("aria-activedescendant")},
16
- [a]);y(()=>{null===f?d(null):null===g&&r(0)},[f,g,r]);x.useEffect(()=>n.mergeRegister(a.registerCommand(L,({option:h})=>h.ref&&null!=h.ref.current?(A(h.ref.current),!0):!1,w.COMMAND_PRIORITY_LOW)),[a,r]);x.useEffect(()=>n.mergeRegister(a.registerCommand(w.KEY_ARROW_DOWN_COMMAND,h=>{if(null!==f&&f.length&&null!==g){let m=g!==f.length-1?g+1:0;r(m);let u=f[m];null!=u.ref&&u.ref.current&&a.dispatchCommand(L,{index:m,option:u});h.preventDefault();h.stopImmediatePropagation()}return!0},w.COMMAND_PRIORITY_LOW),
17
- a.registerCommand(w.KEY_ARROW_UP_COMMAND,h=>{if(null!==f&&f.length&&null!==g){var m=0!==g?g-1:f.length-1;r(m);m=f[m];null!=m.ref&&m.ref.current&&A(m.ref.current);h.preventDefault();h.stopImmediatePropagation()}return!0},w.COMMAND_PRIORITY_LOW),a.registerCommand(w.KEY_ESCAPE_COMMAND,h=>{h.preventDefault();h.stopImmediatePropagation();c();return!0},w.COMMAND_PRIORITY_LOW),a.registerCommand(w.KEY_TAB_COMMAND,h=>{if(null===f||null===g||null==f[g])return!1;h.preventDefault();h.stopImmediatePropagation();
18
- l(f[g]);return!0},w.COMMAND_PRIORITY_LOW),a.registerCommand(w.KEY_ENTER_COMMAND,h=>{if(null===f||null===g||null==f[g])return!1;null!==h&&(h.preventDefault(),h.stopImmediatePropagation());l(f[g]);return!0},w.COMMAND_PRIORITY_LOW)),[l,c,a,f,g,r]);let t=x.useMemo(()=>({options:f,selectOptionAndCleanUp:l,selectedIndex:g,setHighlightedIndex:d}),[l,g,f]);return q(b,t,e.match.matchingString)}
19
- function N(c,a,b){let [e]=k.useLexicalComposerContext(),f=x.useRef(document.createElement("div")),q=x.useCallback(()=>{const g=e.getRootElement(),d=f.current;if(null!==g&&null!==c){const {left:l,top:r,width:t,height:h}=c.getRect();d.style.top=`${r+window.pageYOffset}px`;d.style.left=`${l+window.pageXOffset}px`;d.style.height=`${h}px`;d.style.width=`${t}px`;d.isConnected||(null!=b&&(d.className=b),d.setAttribute("aria-label","Typeahead menu"),d.setAttribute("id","typeahead-menu"),d.setAttribute("role",
20
- "listbox"),d.style.display="block",d.style.position="absolute",document.body.append(d));f.current=d;g.setAttribute("aria-controls","typeahead-menu")}},[e,c,b]);x.useEffect(()=>{let g=e.getRootElement();if(null!==c)return q(),()=>{null!==g&&g.removeAttribute("aria-controls");let d=f.current;null!==d&&d.isConnected&&d.remove()}},[e,q,c]);let p=x.useCallback(g=>{null!==c&&(g||a(null))},[c,a]);K(c,f.current,q,p);return f}
21
- exports.LexicalNodeMenuPlugin=function({options:c,nodeKey:a,onClose:b,onOpen:e,onSelectOption:f,menuRenderFn:q,anchorClassName:p}){let [g]=k.useLexicalComposerContext(),[d,l]=x.useState(null);p=N(d,l,p);let r=x.useCallback(()=>{l(null);null!=b&&null!==d&&b()},[b,d]),t=x.useCallback(h=>{l(h);null!=e&&null===d&&e(h)},[e,d]);x.useEffect(()=>{a&&null==d?g.update(()=>{let h=w.$getNodeByKey(a),m=g.getElementByKey(a);if(null!=h&&null!=m){let u=h.getTextContent();F(()=>t({getRect:()=>m.getBoundingClientRect(),
22
- match:{leadOffset:u.length,matchingString:u,replaceableString:u}}))}}):null==a&&null!=d&&r()},[r,g,a,t,d]);return null===d||null===g?null:x.createElement(M,{close:r,resolution:d,editor:g,anchorElementRef:p,options:c,menuRenderFn:q,onSelectOption:f})};
23
- exports.LexicalTypeaheadMenuPlugin=function({options:c,onQueryChange:a,onSelectOption:b,onOpen:e,onClose:f,menuRenderFn:q,triggerFn:p,anchorClassName:g}){let [d]=k.useLexicalComposerContext(),[l,r]=x.useState(null);g=N(l,r,g);let t=x.useCallback(()=>{r(null);null!=f&&null!==l&&f()},[f,l]),h=x.useCallback(m=>{r(m);null!=e&&null===l&&e(m)},[e,l]);x.useEffect(()=>{let m=d.registerUpdateListener(()=>{d.getEditorState().read(()=>{const u=document.createRange(),G=w.$getSelection(),H=C(d);if(w.$isRangeSelection(G)&&
24
- G.isCollapsed()&&null!==H&&null!==u){var v=p(H,d);a(v?v.matchingString:null);null===v||E(d,v.leadOffset)||null===B(v.leadOffset,u)?t():F(()=>h({getRect:()=>u.getBoundingClientRect(),match:v}))}else t()})});return()=>{m()}},[d,p,a,l,t,h]);return null===l||null===d?null:x.createElement(M,{close:t,resolution:l,editor:d,anchorElementRef:g,options:c,menuRenderFn:q,onSelectOption:b})};exports.PUNCTUATION="\\.,\\+\\*\\?\\$\\@\\|#{}\\(\\)\\^\\-\\[\\]\\\\/!%'\"~=<>_:;";
25
- exports.SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND=L;exports.TypeaheadOption=z;exports.getScrollParent=I;exports.useBasicTypeaheadTriggerMatch=function(c,{minLength:a=1,maxLength:b=75}){return x.useCallback(e=>{e=(new RegExp("(^|\\s|\\()(["+c+"]((?:[^"+(c+"\\.,\\+\\*\\?\\$\\@\\|#{}\\(\\)\\^\\-\\[\\]\\\\/!%'\"~=<>_:;\\s]){0,")+b+"}))$")).exec(e);if(null!==e){let f=e[1],q=e[3];if(q.length>=a)return{leadOffset:e.index+f.length,matchingString:q,replaceableString:e[2]}}return null},[b,a,c])};
13
+ function K(c,a,b,e){let [g]=k.useLexicalComposerContext();y.useEffect(()=>{if(null!=a&&null!=c){let q=g.getRootElement(),p=null!=q?I(q,!1):document.body,f=!1,d=J(a,p),m=function(){f||(window.requestAnimationFrame(function(){b();f=!1}),f=!0);const t=J(a,p);t!==d&&(d=t,null!=e&&e(t))},r=new ResizeObserver(b);window.addEventListener("resize",b);document.addEventListener("scroll",m,{capture:!0,passive:!0});r.observe(a);return()=>{r.unobserve(a);window.removeEventListener("resize",b);document.removeEventListener("scroll",
14
+ m)}}},[a,g,e,b,c])}let L=x.createCommand("SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND");
15
+ function M({close:c,editor:a,anchorElementRef:b,resolution:e,options:g,menuRenderFn:q,onSelectOption:p}){let [f,d]=y.useState(null);y.useEffect(()=>{d(0)},[e.match.matchingString]);let m=y.useCallback(h=>{a.update(()=>{const l=E(a,e.match);p(h,l,c,e.match.matchingString)})},[c,a,e.match,p]),r=y.useCallback(h=>{const l=a.getRootElement();null!==l&&(l.setAttribute("aria-activedescendant","typeahead-item-"+h),d(h))},[a]);y.useEffect(()=>()=>{let h=a.getRootElement();null!==h&&h.removeAttribute("aria-activedescendant")},
16
+ [a]);z(()=>{null===g?d(null):null===f&&r(0)},[g,f,r]);y.useEffect(()=>n.mergeRegister(a.registerCommand(L,({option:h})=>h.ref&&null!=h.ref.current?(B(h.ref.current),!0):!1,x.COMMAND_PRIORITY_LOW)),[a,r]);y.useEffect(()=>n.mergeRegister(a.registerCommand(x.KEY_ARROW_DOWN_COMMAND,h=>{if(null!==g&&g.length&&null!==f){let l=f!==g.length-1?f+1:0;r(l);let u=g[l];null!=u.ref&&u.ref.current&&a.dispatchCommand(L,{index:l,option:u});h.preventDefault();h.stopImmediatePropagation()}return!0},x.COMMAND_PRIORITY_LOW),
17
+ a.registerCommand(x.KEY_ARROW_UP_COMMAND,h=>{if(null!==g&&g.length&&null!==f){var l=0!==f?f-1:g.length-1;r(l);l=g[l];null!=l.ref&&l.ref.current&&B(l.ref.current);h.preventDefault();h.stopImmediatePropagation()}return!0},x.COMMAND_PRIORITY_LOW),a.registerCommand(x.KEY_ESCAPE_COMMAND,h=>{h.preventDefault();h.stopImmediatePropagation();c();return!0},x.COMMAND_PRIORITY_LOW),a.registerCommand(x.KEY_TAB_COMMAND,h=>{if(null===g||null===f||null==g[f])return!1;h.preventDefault();h.stopImmediatePropagation();
18
+ m(g[f]);return!0},x.COMMAND_PRIORITY_LOW),a.registerCommand(x.KEY_ENTER_COMMAND,h=>{if(null===g||null===f||null==g[f])return!1;null!==h&&(h.preventDefault(),h.stopImmediatePropagation());m(g[f]);return!0},x.COMMAND_PRIORITY_LOW)),[m,c,a,g,f,r]);let t=y.useMemo(()=>({options:g,selectOptionAndCleanUp:m,selectedIndex:f,setHighlightedIndex:d}),[m,f,g]);return q(b,t,e.match.matchingString)}
19
+ function N(c,a,b){let [e]=k.useLexicalComposerContext(),g=y.useRef(document.createElement("div")),q=y.useCallback(()=>{const f=e.getRootElement(),d=g.current;if(null!==f&&null!==c){const {left:m,top:r,width:t,height:h}=c.getRect();d.style.top=`${r+window.pageYOffset}px`;d.style.left=`${m+window.pageXOffset}px`;d.style.height=`${h}px`;d.style.width=`${t}px`;d.isConnected||(null!=b&&(d.className=b),d.setAttribute("aria-label","Typeahead menu"),d.setAttribute("id","typeahead-menu"),d.setAttribute("role",
20
+ "listbox"),d.style.display="block",d.style.position="absolute",document.body.append(d));g.current=d;f.setAttribute("aria-controls","typeahead-menu")}},[e,c,b]);y.useEffect(()=>{let f=e.getRootElement();if(null!==c)return q(),()=>{null!==f&&f.removeAttribute("aria-controls");let d=g.current;null!==d&&d.isConnected&&d.remove()}},[e,q,c]);let p=y.useCallback(f=>{null!==c&&(f||a(null))},[c,a]);K(c,g.current,q,p);return g}
21
+ exports.LexicalNodeMenuPlugin=function({options:c,nodeKey:a,onClose:b,onOpen:e,onSelectOption:g,menuRenderFn:q,anchorClassName:p}){let [f]=k.useLexicalComposerContext(),[d,m]=y.useState(null);p=N(d,m,p);let r=y.useCallback(()=>{m(null);null!=b&&null!==d&&b()},[b,d]),t=y.useCallback(l=>{m(l);null!=e&&null===d&&e(l)},[e,d]),h=y.useCallback(()=>{a?f.update(()=>{const l=x.$getNodeByKey(a),u=f.getElementByKey(a);if(null!=l&&null!=u){const v=l.getTextContent();null!=d&&d.match.matchingString===v||G(()=>
22
+ t({getRect:()=>u.getBoundingClientRect(),match:{leadOffset:v.length,matchingString:v,replaceableString:v}}))}}):null==a&&null!=d&&r()},[r,f,a,t,d]);y.useEffect(()=>{h()},[h,a]);y.useEffect(()=>{if(null!=a)return f.registerUpdateListener(({dirtyElements:l})=>{l.get(a)&&h()})},[f,h,a]);return null===d||null===f?null:y.createElement(M,{close:r,resolution:d,editor:f,anchorElementRef:p,options:c,menuRenderFn:q,onSelectOption:g})};
23
+ exports.LexicalTypeaheadMenuPlugin=function({options:c,onQueryChange:a,onSelectOption:b,onOpen:e,onClose:g,menuRenderFn:q,triggerFn:p,anchorClassName:f}){let [d]=k.useLexicalComposerContext(),[m,r]=y.useState(null);f=N(m,r,f);let t=y.useCallback(()=>{r(null);null!=g&&null!==m&&g()},[g,m]),h=y.useCallback(l=>{r(l);null!=e&&null===m&&e(l)},[e,m]);y.useEffect(()=>{let l=d.registerUpdateListener(()=>{d.getEditorState().read(()=>{const u=document.createRange(),v=x.$getSelection(),H=D(d);if(x.$isRangeSelection(v)&&
24
+ v.isCollapsed()&&null!==H&&null!==u){var w=p(H,d);a(w?w.matchingString:null);null===w||F(d,w.leadOffset)||null===C(w.leadOffset,u)?t():G(()=>h({getRect:()=>u.getBoundingClientRect(),match:w}))}else t()})});return()=>{l()}},[d,p,a,m,t,h]);return null===m||null===d?null:y.createElement(M,{close:t,resolution:m,editor:d,anchorElementRef:f,options:c,menuRenderFn:q,onSelectOption:b})};exports.PUNCTUATION="\\.,\\+\\*\\?\\$\\@\\|#{}\\(\\)\\^\\-\\[\\]\\\\/!%'\"~=<>_:;";
25
+ exports.SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND=L;exports.TypeaheadOption=A;exports.getScrollParent=I;exports.useBasicTypeaheadTriggerMatch=function(c,{minLength:a=1,maxLength:b=75}){return y.useCallback(e=>{e=(new RegExp("(^|\\s|\\()(["+c+"]((?:[^"+(c+"\\.,\\+\\*\\?\\$\\@\\|#{}\\(\\)\\^\\-\\[\\]\\\\/!%'\"~=<>_:;\\s]){0,")+b+"}))$")).exec(e);if(null!==e){let g=e[1],q=e[3];if(q.length>=a)return{leadOffset:e.index+g.length,matchingString:q,replaceableString:e[2]}}return null},[b,a,c])};
26
26
  exports.useDynamicPositioning=K
package/package.json CHANGED
@@ -8,29 +8,29 @@
8
8
  "rich-text"
9
9
  ],
10
10
  "license": "MIT",
11
- "version": "0.8.0",
11
+ "version": "0.9.0",
12
12
  "dependencies": {
13
- "@lexical/clipboard": "0.8.0",
14
- "@lexical/code": "0.8.0",
15
- "@lexical/dragon": "0.8.0",
16
- "@lexical/hashtag": "0.8.0",
17
- "@lexical/history": "0.8.0",
18
- "@lexical/link": "0.8.0",
19
- "@lexical/list": "0.8.0",
20
- "@lexical/mark": "0.8.0",
21
- "@lexical/markdown": "0.8.0",
22
- "@lexical/overflow": "0.8.0",
23
- "@lexical/plain-text": "0.8.0",
24
- "@lexical/rich-text": "0.8.0",
25
- "@lexical/selection": "0.8.0",
26
- "@lexical/table": "0.8.0",
27
- "@lexical/text": "0.8.0",
28
- "@lexical/utils": "0.8.0",
29
- "@lexical/yjs": "0.8.0",
13
+ "@lexical/clipboard": "0.9.0",
14
+ "@lexical/code": "0.9.0",
15
+ "@lexical/dragon": "0.9.0",
16
+ "@lexical/hashtag": "0.9.0",
17
+ "@lexical/history": "0.9.0",
18
+ "@lexical/link": "0.9.0",
19
+ "@lexical/list": "0.9.0",
20
+ "@lexical/mark": "0.9.0",
21
+ "@lexical/markdown": "0.9.0",
22
+ "@lexical/overflow": "0.9.0",
23
+ "@lexical/plain-text": "0.9.0",
24
+ "@lexical/rich-text": "0.9.0",
25
+ "@lexical/selection": "0.9.0",
26
+ "@lexical/table": "0.9.0",
27
+ "@lexical/text": "0.9.0",
28
+ "@lexical/utils": "0.9.0",
29
+ "@lexical/yjs": "0.9.0",
30
30
  "react-error-boundary": "^3.1.4"
31
31
  },
32
32
  "peerDependencies": {
33
- "lexical": "0.8.0",
33
+ "lexical": "0.9.0",
34
34
  "react": ">=17.x",
35
35
  "react-dom": ">=17.x"
36
36
  },