@lexical/react 0.3.8 → 0.3.11
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.
- package/LexicalAutoEmbedPlugin.d.ts +46 -0
- package/LexicalAutoEmbedPlugin.dev.js +490 -0
- package/LexicalAutoEmbedPlugin.js +9 -0
- package/LexicalAutoEmbedPlugin.prod.js +21 -0
- package/LexicalAutoLinkPlugin.dev.js +1 -1
- package/LexicalAutoLinkPlugin.prod.js +2 -2
- package/LexicalCollaborationContext.d.ts +19 -0
- package/LexicalCollaborationContext.dev.js +38 -0
- package/LexicalCollaborationContext.js +9 -0
- package/LexicalCollaborationContext.js.flow +21 -0
- package/LexicalCollaborationContext.prod.js +8 -0
- package/LexicalCollaborationPlugin.d.ts +0 -10
- package/LexicalCollaborationPlugin.dev.js +12 -20
- package/LexicalCollaborationPlugin.js.flow +0 -9
- package/LexicalCollaborationPlugin.prod.js +9 -10
- package/LexicalLinkPlugin.dev.js +15 -2
- package/LexicalLinkPlugin.prod.js +2 -1
- package/LexicalNestedComposer.dev.js +11 -5
- package/LexicalNestedComposer.prod.js +3 -3
- package/LexicalOnChangePlugin.d.ts +2 -1
- package/LexicalOnChangePlugin.dev.js +6 -3
- package/LexicalOnChangePlugin.js.flow +2 -0
- package/LexicalOnChangePlugin.prod.js +2 -2
- package/LexicalTableOfContents__EXPERIMENTAL.js.flow +2 -2
- package/LexicalTreeView.dev.js +43 -9
- package/LexicalTreeView.prod.js +13 -13
- package/LexicalTypeaheadMenuPlugin.d.ts +11 -3
- package/LexicalTypeaheadMenuPlugin.dev.js +115 -58
- package/LexicalTypeaheadMenuPlugin.prod.js +16 -13
- package/package.json +19 -19
|
@@ -143,7 +143,7 @@ function getFullMatchOffset(documentText, entryText, offset) {
|
|
|
143
143
|
return triggerOffset;
|
|
144
144
|
}
|
|
145
145
|
/**
|
|
146
|
-
* Split
|
|
146
|
+
* Split Lexical TextNode and return a new TextNode only containing matched text.
|
|
147
147
|
* Common use cases include: removing the node, replacing with a new node.
|
|
148
148
|
*/
|
|
149
149
|
|
|
@@ -207,59 +207,27 @@ function isSelectionOnEntityBoundary(editor, offset) {
|
|
|
207
207
|
});
|
|
208
208
|
}
|
|
209
209
|
|
|
210
|
-
function
|
|
210
|
+
function startTransition(callback) {
|
|
211
|
+
if (React.startTransition) {
|
|
212
|
+
React.startTransition(callback);
|
|
213
|
+
} else {
|
|
214
|
+
callback();
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
function LexicalPopoverMenu({
|
|
211
219
|
close,
|
|
212
220
|
editor,
|
|
221
|
+
anchorElement,
|
|
213
222
|
resolution,
|
|
214
223
|
options,
|
|
215
224
|
menuRenderFn,
|
|
216
225
|
onSelectOption
|
|
217
226
|
}) {
|
|
218
227
|
const [selectedIndex, setHighlightedIndex] = React.useState(null);
|
|
219
|
-
const anchorElementRef = React.useRef(document.createElement('div'));
|
|
220
228
|
React.useEffect(() => {
|
|
221
229
|
setHighlightedIndex(0);
|
|
222
230
|
}, [resolution.match.matchingString]);
|
|
223
|
-
React.useEffect(() => {
|
|
224
|
-
const rootElement = editor.getRootElement();
|
|
225
|
-
|
|
226
|
-
function positionMenu() {
|
|
227
|
-
const containerDiv = anchorElementRef.current;
|
|
228
|
-
containerDiv.setAttribute('aria-label', 'Typeahead menu');
|
|
229
|
-
containerDiv.setAttribute('id', 'typeahead-menu');
|
|
230
|
-
containerDiv.setAttribute('role', 'listbox');
|
|
231
|
-
|
|
232
|
-
if (rootElement !== null) {
|
|
233
|
-
const range = resolution.range;
|
|
234
|
-
const {
|
|
235
|
-
left,
|
|
236
|
-
top,
|
|
237
|
-
height
|
|
238
|
-
} = range.getBoundingClientRect();
|
|
239
|
-
containerDiv.style.top = `${top + height + window.pageYOffset}px`;
|
|
240
|
-
containerDiv.style.left = `${left + window.pageXOffset}px`;
|
|
241
|
-
containerDiv.style.display = 'block';
|
|
242
|
-
containerDiv.style.position = 'absolute';
|
|
243
|
-
|
|
244
|
-
if (!containerDiv.isConnected) {
|
|
245
|
-
document.body.append(containerDiv);
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
anchorElementRef.current = containerDiv;
|
|
249
|
-
rootElement.setAttribute('aria-controls', 'typeahead-menu');
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
positionMenu();
|
|
254
|
-
window.addEventListener('resize', positionMenu);
|
|
255
|
-
return () => {
|
|
256
|
-
window.removeEventListener('resize', positionMenu);
|
|
257
|
-
|
|
258
|
-
if (rootElement !== null) {
|
|
259
|
-
rootElement.removeAttribute('aria-controls');
|
|
260
|
-
}
|
|
261
|
-
};
|
|
262
|
-
}, [editor, resolution, options]);
|
|
263
231
|
const selectOptionAndCleanUp = React.useCallback(async selectedEntry => {
|
|
264
232
|
editor.update(() => {
|
|
265
233
|
const textNodeContainingQuery = splitNodeContainingQuery(editor, resolution.match);
|
|
@@ -294,7 +262,7 @@ function ShortcutTypeahead({
|
|
|
294
262
|
return utils.mergeRegister(editor.registerCommand(lexical.KEY_ARROW_DOWN_COMMAND, payload => {
|
|
295
263
|
const event = payload;
|
|
296
264
|
|
|
297
|
-
if (options !== null && selectedIndex !== null) {
|
|
265
|
+
if (options !== null && options.length && selectedIndex !== null) {
|
|
298
266
|
const newSelectedIndex = selectedIndex !== options.length - 1 ? selectedIndex + 1 : 0;
|
|
299
267
|
updateSelectedIndex(newSelectedIndex);
|
|
300
268
|
const option = options[newSelectedIndex];
|
|
@@ -311,7 +279,7 @@ function ShortcutTypeahead({
|
|
|
311
279
|
}, lexical.COMMAND_PRIORITY_LOW), editor.registerCommand(lexical.KEY_ARROW_UP_COMMAND, payload => {
|
|
312
280
|
const event = payload;
|
|
313
281
|
|
|
314
|
-
if (options !== null && selectedIndex !== null) {
|
|
282
|
+
if (options !== null && options.length && selectedIndex !== null) {
|
|
315
283
|
const newSelectedIndex = selectedIndex !== 0 ? selectedIndex - 1 : options.length - 1;
|
|
316
284
|
updateSelectedIndex(newSelectedIndex);
|
|
317
285
|
const option = options[newSelectedIndex];
|
|
@@ -327,11 +295,6 @@ function ShortcutTypeahead({
|
|
|
327
295
|
return true;
|
|
328
296
|
}, lexical.COMMAND_PRIORITY_LOW), editor.registerCommand(lexical.KEY_ESCAPE_COMMAND, payload => {
|
|
329
297
|
const event = payload;
|
|
330
|
-
|
|
331
|
-
if (options === null || selectedIndex === null) {
|
|
332
|
-
return false;
|
|
333
|
-
}
|
|
334
|
-
|
|
335
298
|
event.preventDefault();
|
|
336
299
|
event.stopImmediatePropagation();
|
|
337
300
|
close();
|
|
@@ -366,7 +329,7 @@ function ShortcutTypeahead({
|
|
|
366
329
|
selectedIndex,
|
|
367
330
|
setHighlightedIndex
|
|
368
331
|
}), [selectOptionAndCleanUp, selectedIndex]);
|
|
369
|
-
return menuRenderFn(
|
|
332
|
+
return menuRenderFn(anchorElement, listItemProps, resolution.match.matchingString);
|
|
370
333
|
}
|
|
371
334
|
|
|
372
335
|
function useBasicTypeaheadTriggerMatch(trigger, {
|
|
@@ -394,6 +357,55 @@ function useBasicTypeaheadTriggerMatch(trigger, {
|
|
|
394
357
|
return null;
|
|
395
358
|
}, [maxLength, minLength, trigger]);
|
|
396
359
|
}
|
|
360
|
+
|
|
361
|
+
function useAnchorElementRef(resolution, options) {
|
|
362
|
+
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
363
|
+
const anchorElementRef = React.useRef(document.createElement('div'));
|
|
364
|
+
React.useEffect(() => {
|
|
365
|
+
const rootElement = editor.getRootElement();
|
|
366
|
+
|
|
367
|
+
function positionMenu() {
|
|
368
|
+
const containerDiv = anchorElementRef.current;
|
|
369
|
+
containerDiv.setAttribute('aria-label', 'Typeahead menu');
|
|
370
|
+
containerDiv.setAttribute('id', 'typeahead-menu');
|
|
371
|
+
containerDiv.setAttribute('role', 'listbox');
|
|
372
|
+
|
|
373
|
+
if (rootElement !== null && resolution !== null) {
|
|
374
|
+
const {
|
|
375
|
+
left,
|
|
376
|
+
top,
|
|
377
|
+
height,
|
|
378
|
+
width
|
|
379
|
+
} = resolution.getRect();
|
|
380
|
+
containerDiv.style.top = `${top + height + window.pageYOffset}px`;
|
|
381
|
+
containerDiv.style.left = `${left + width + window.pageXOffset}px`;
|
|
382
|
+
containerDiv.style.display = 'block';
|
|
383
|
+
containerDiv.style.position = 'absolute';
|
|
384
|
+
|
|
385
|
+
if (!containerDiv.isConnected) {
|
|
386
|
+
document.body.append(containerDiv);
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
anchorElementRef.current = containerDiv;
|
|
390
|
+
rootElement.setAttribute('aria-controls', 'typeahead-menu');
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
if (resolution !== null) {
|
|
395
|
+
positionMenu();
|
|
396
|
+
window.addEventListener('resize', positionMenu);
|
|
397
|
+
return () => {
|
|
398
|
+
window.removeEventListener('resize', positionMenu);
|
|
399
|
+
|
|
400
|
+
if (rootElement !== null) {
|
|
401
|
+
rootElement.removeAttribute('aria-controls');
|
|
402
|
+
}
|
|
403
|
+
};
|
|
404
|
+
}
|
|
405
|
+
}, [editor, resolution, options]);
|
|
406
|
+
return anchorElementRef;
|
|
407
|
+
}
|
|
408
|
+
|
|
397
409
|
function LexicalTypeaheadMenuPlugin({
|
|
398
410
|
options,
|
|
399
411
|
onQueryChange,
|
|
@@ -403,6 +415,7 @@ function LexicalTypeaheadMenuPlugin({
|
|
|
403
415
|
}) {
|
|
404
416
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
405
417
|
const [resolution, setResolution] = React.useState(null);
|
|
418
|
+
const anchorElementRef = useAnchorElementRef(resolution, options);
|
|
406
419
|
React.useEffect(() => {
|
|
407
420
|
let activeRange = document.createRange();
|
|
408
421
|
let previousText = null;
|
|
@@ -414,27 +427,27 @@ function LexicalTypeaheadMenuPlugin({
|
|
|
414
427
|
const text = getQueryTextForSearch(editor);
|
|
415
428
|
|
|
416
429
|
if (!lexical.$isRangeSelection(selection) || !selection.isCollapsed() || text === previousText || text === null || range === null) {
|
|
417
|
-
|
|
430
|
+
setResolution(null);
|
|
418
431
|
return;
|
|
419
432
|
}
|
|
420
433
|
|
|
421
434
|
previousText = text;
|
|
422
|
-
const match = triggerFn(text);
|
|
435
|
+
const match = triggerFn(text, editor);
|
|
423
436
|
onQueryChange(match ? match.matchingString : null);
|
|
424
437
|
|
|
425
438
|
if (match !== null && !isSelectionOnEntityBoundary(editor, match.leadOffset)) {
|
|
426
439
|
const isRangePositioned = tryToPositionRange(match.leadOffset, range);
|
|
427
440
|
|
|
428
441
|
if (isRangePositioned !== null) {
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
442
|
+
startTransition(() => setResolution({
|
|
443
|
+
getRect: () => range.getBoundingClientRect(),
|
|
444
|
+
match
|
|
432
445
|
}));
|
|
433
446
|
return;
|
|
434
447
|
}
|
|
435
448
|
}
|
|
436
449
|
|
|
437
|
-
|
|
450
|
+
setResolution(null);
|
|
438
451
|
});
|
|
439
452
|
};
|
|
440
453
|
|
|
@@ -447,16 +460,60 @@ function LexicalTypeaheadMenuPlugin({
|
|
|
447
460
|
const closeTypeahead = React.useCallback(() => {
|
|
448
461
|
setResolution(null);
|
|
449
462
|
}, []);
|
|
450
|
-
return resolution === null || editor === null ? null : /*#__PURE__*/React.createElement(
|
|
463
|
+
return resolution === null || editor === null ? null : /*#__PURE__*/React.createElement(LexicalPopoverMenu, {
|
|
451
464
|
close: closeTypeahead,
|
|
452
465
|
resolution: resolution,
|
|
453
466
|
editor: editor,
|
|
467
|
+
anchorElement: anchorElementRef.current,
|
|
468
|
+
options: options,
|
|
469
|
+
menuRenderFn: menuRenderFn,
|
|
470
|
+
onSelectOption: onSelectOption
|
|
471
|
+
});
|
|
472
|
+
}
|
|
473
|
+
function LexicalNodeMenuPlugin({
|
|
474
|
+
options,
|
|
475
|
+
nodeKey,
|
|
476
|
+
onClose,
|
|
477
|
+
onSelectOption,
|
|
478
|
+
menuRenderFn
|
|
479
|
+
}) {
|
|
480
|
+
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
481
|
+
const [resolution, setResolution] = React.useState(null);
|
|
482
|
+
const anchorElementRef = useAnchorElementRef(resolution, options);
|
|
483
|
+
React.useEffect(() => {
|
|
484
|
+
if (nodeKey && resolution == null) {
|
|
485
|
+
editor.update(() => {
|
|
486
|
+
const node = lexical.$getNodeByKey(nodeKey);
|
|
487
|
+
const domElement = editor.getElementByKey(nodeKey);
|
|
488
|
+
|
|
489
|
+
if (node != null && domElement != null) {
|
|
490
|
+
const text = node.getTextContent();
|
|
491
|
+
startTransition(() => setResolution({
|
|
492
|
+
getRect: () => domElement.getBoundingClientRect(),
|
|
493
|
+
match: {
|
|
494
|
+
leadOffset: text.length,
|
|
495
|
+
matchingString: text,
|
|
496
|
+
replaceableString: text
|
|
497
|
+
}
|
|
498
|
+
}));
|
|
499
|
+
}
|
|
500
|
+
});
|
|
501
|
+
} else if (nodeKey == null && resolution != null) {
|
|
502
|
+
setResolution(null);
|
|
503
|
+
}
|
|
504
|
+
}, [editor, nodeKey, resolution]);
|
|
505
|
+
return resolution === null || editor === null ? null : /*#__PURE__*/React.createElement(LexicalPopoverMenu, {
|
|
506
|
+
close: onClose,
|
|
507
|
+
resolution: resolution,
|
|
508
|
+
editor: editor,
|
|
509
|
+
anchorElement: anchorElementRef.current,
|
|
454
510
|
options: options,
|
|
455
511
|
menuRenderFn: menuRenderFn,
|
|
456
512
|
onSelectOption: onSelectOption
|
|
457
513
|
});
|
|
458
514
|
}
|
|
459
515
|
|
|
516
|
+
exports.LexicalNodeMenuPlugin = LexicalNodeMenuPlugin;
|
|
460
517
|
exports.LexicalTypeaheadMenuPlugin = LexicalTypeaheadMenuPlugin;
|
|
461
518
|
exports.PUNCTUATION = PUNCTUATION;
|
|
462
519
|
exports.TypeaheadOption = TypeaheadOption;
|
|
@@ -4,16 +4,19 @@
|
|
|
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
|
|
8
|
-
let A=
|
|
9
|
-
function
|
|
10
|
-
function
|
|
11
|
-
function
|
|
12
|
-
function
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
7
|
+
'use strict';var m=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(b){this.key=b;this.ref={current:null};this.setRefElement=this.setRefElement.bind(this)}setRefElement(b){this.ref={current:b}}}
|
|
8
|
+
let A=b=>{var a=document.getElementById("typeahead-menu");if(a){a=a.getBoundingClientRect();const c=b.getBoundingClientRect();c.bottom>a.bottom?b.scrollIntoView(!1):c.top<a.top&&b.scrollIntoView()}};function C(b,a){var c=window.getSelection();if(null===c||!c.isCollapsed)return!1;let d=c.anchorNode;c=c.anchorOffset;if(null==d||null==c)return!1;try{a.setStart(d,b),a.setEnd(d,c)}catch(e){return!1}return!0}
|
|
9
|
+
function D(b){let a=null;b.getEditorState().read(()=>{var c=w.$getSelection();if(w.$isRangeSelection(c)){var d=c.anchor;"text"!==d.type?a=null:(c=d.getNode(),c.isSimpleText()?(d=d.offset,a=c.getTextContent().slice(0,d)):a=null)}});return a}
|
|
10
|
+
function E(b,a){b=w.$getSelection();if(!w.$isRangeSelection(b)||!b.isCollapsed())return null;var c=b.anchor;if("text"!==c.type)return null;b=c.getNode();if(!b.isSimpleText())return null;c=c.offset;let d=b.getTextContent().slice(0,c);var e=a.matchingString;a=a.replaceableString.length;for(let f=a;f<=e.length;f++)d.substr(-f)===e.substr(0,f)&&(a=f);a=c-a;if(0>a)return null;let g;0===a?[g]=b.splitText(c):[,g]=b.splitText(a,c);return g}
|
|
11
|
+
function F(b,a){return 0!==a?!1:b.getEditorState().read(()=>{var c=w.$getSelection();return w.$isRangeSelection(c)?(c=c.anchor.getNode().getPreviousSibling(),w.$isTextNode(c)&&c.isTextEntity()):!1})}function G(b){x.startTransition?x.startTransition(b):b()}
|
|
12
|
+
function H({close:b,editor:a,anchorElement:c,resolution:d,options:e,menuRenderFn:g,onSelectOption:f}){let [h,r]=x.useState(null);x.useEffect(()=>{r(0)},[d.match.matchingString]);let q=x.useCallback(async k=>{a.update(()=>{const l=E(a,d.match);f(k,l,b,d.match.matchingString)})},[b,a,d.match,f]),p=x.useCallback(k=>{const l=a.getRootElement();null!==l&&(l.setAttribute("aria-activedescendant","typeahead-item-"+k),r(k))},[a]);x.useEffect(()=>()=>{let k=a.getRootElement();null!==k&&k.removeAttribute("aria-activedescendant")},
|
|
13
|
+
[a]);y(()=>{null===e?r(null):null===h&&p(0)},[e,h,p]);x.useEffect(()=>n.mergeRegister(a.registerCommand(w.KEY_ARROW_DOWN_COMMAND,k=>{if(null!==e&&e.length&&null!==h){var l=h!==e.length-1?h+1:0;p(l);l=e[l];null!=l.ref&&l.ref.current&&A(l.ref.current);k.preventDefault();k.stopImmediatePropagation()}return!0},w.COMMAND_PRIORITY_LOW),a.registerCommand(w.KEY_ARROW_UP_COMMAND,k=>{if(null!==e&&e.length&&null!==h){var l=0!==h?h-1:e.length-1;p(l);l=e[l];null!=l.ref&&l.ref.current&&A(l.ref.current);k.preventDefault();
|
|
14
|
+
k.stopImmediatePropagation()}return!0},w.COMMAND_PRIORITY_LOW),a.registerCommand(w.KEY_ESCAPE_COMMAND,k=>{k.preventDefault();k.stopImmediatePropagation();b();return!0},w.COMMAND_PRIORITY_LOW),a.registerCommand(w.KEY_TAB_COMMAND,k=>{if(null===e||null===h||null==e[h])return!1;k.preventDefault();k.stopImmediatePropagation();q(e[h]);return!0},w.COMMAND_PRIORITY_LOW),a.registerCommand(w.KEY_ENTER_COMMAND,k=>{if(null===e||null===h||null==e[h])return!1;null!==k&&(k.preventDefault(),k.stopImmediatePropagation());
|
|
15
|
+
q(e[h]);return!0},w.COMMAND_PRIORITY_LOW)),[q,b,a,e,h,p]);let t=x.useMemo(()=>({selectOptionAndCleanUp:q,selectedIndex:h,setHighlightedIndex:r}),[q,h]);return g(c,t,d.match.matchingString)}
|
|
16
|
+
function I(b,a){let [c]=m.useLexicalComposerContext(),d=x.useRef(document.createElement("div"));x.useEffect(()=>{function e(){let f=d.current;f.setAttribute("aria-label","Typeahead menu");f.setAttribute("id","typeahead-menu");f.setAttribute("role","listbox");if(null!==g&&null!==b){let {left:h,top:r,height:q,width:p}=b.getRect();f.style.top=`${r+q+window.pageYOffset}px`;f.style.left=`${h+p+window.pageXOffset}px`;f.style.display="block";f.style.position="absolute";f.isConnected||document.body.append(f);
|
|
17
|
+
d.current=f;g.setAttribute("aria-controls","typeahead-menu")}}let g=c.getRootElement();if(null!==b)return e(),window.addEventListener("resize",e),()=>{window.removeEventListener("resize",e);null!==g&&g.removeAttribute("aria-controls")}},[c,b,a]);return d}
|
|
18
|
+
exports.LexicalNodeMenuPlugin=function({options:b,nodeKey:a,onClose:c,onSelectOption:d,menuRenderFn:e}){let [g]=m.useLexicalComposerContext(),[f,h]=x.useState(null),r=I(f,b);x.useEffect(()=>{a&&null==f?g.update(()=>{let q=w.$getNodeByKey(a),p=g.getElementByKey(a);if(null!=q&&null!=p){let t=q.getTextContent();G(()=>h({getRect:()=>p.getBoundingClientRect(),match:{leadOffset:t.length,matchingString:t,replaceableString:t}}))}}):null==a&&null!=f&&h(null)},[g,a,f]);return null===f||null===g?null:x.createElement(H,
|
|
19
|
+
{close:c,resolution:f,editor:g,anchorElement:r.current,options:b,menuRenderFn:e,onSelectOption:d})};
|
|
20
|
+
exports.LexicalTypeaheadMenuPlugin=function({options:b,onQueryChange:a,onSelectOption:c,menuRenderFn:d,triggerFn:e}){let [g]=m.useLexicalComposerContext(),[f,h]=x.useState(null),r=I(f,b);x.useEffect(()=>{let p=document.createRange(),t=null,k=g.registerUpdateListener(()=>{g.getEditorState().read(()=>{const l=p,B=w.$getSelection(),v=D(g);if(w.$isRangeSelection(B)&&B.isCollapsed()&&v!==t&&null!==v&&null!==l){t=v;var u=e(v,g);a(u?u.matchingString:null);null===u||F(g,u.leadOffset)||null===C(u.leadOffset,
|
|
21
|
+
l)?h(null):G(()=>h({getRect:()=>l.getBoundingClientRect(),match:u}))}else h(null)})});return()=>{p=null;k()}},[g,e,a,f]);let q=x.useCallback(()=>{h(null)},[]);return null===f||null===g?null:x.createElement(H,{close:q,resolution:f,editor:g,anchorElement:r.current,options:b,menuRenderFn:d,onSelectOption:c})};exports.PUNCTUATION="\\.,\\+\\*\\?\\$\\@\\|#{}\\(\\)\\^\\-\\[\\]\\\\/!%'\"~=<>_:;";exports.TypeaheadOption=z;
|
|
22
|
+
exports.useBasicTypeaheadTriggerMatch=function(b,{minLength:a=1,maxLength:c=75}){return x.useCallback(d=>{d=(new RegExp("(^|\\s|\\()(["+b+"]((?:[^"+(b+"\\.,\\+\\*\\?\\$\\@\\|#{}\\(\\)\\^\\-\\[\\]\\\\/!%'\"~=<>_:;\\s]){0,")+c+"}))$")).exec(d);if(null!==d){let e=d[1],g=d[3];if(g.length>=a)return{leadOffset:d.index+e.length,matchingString:g,replaceableString:d[2]}}return null},[c,a,b])}
|
package/package.json
CHANGED
|
@@ -8,28 +8,28 @@
|
|
|
8
8
|
"rich-text"
|
|
9
9
|
],
|
|
10
10
|
"license": "MIT",
|
|
11
|
-
"version": "0.3.
|
|
11
|
+
"version": "0.3.11",
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@lexical/clipboard": "0.3.
|
|
14
|
-
"@lexical/code": "0.3.
|
|
15
|
-
"@lexical/dragon": "0.3.
|
|
16
|
-
"@lexical/hashtag": "0.3.
|
|
17
|
-
"@lexical/history": "0.3.
|
|
18
|
-
"@lexical/link": "0.3.
|
|
19
|
-
"@lexical/list": "0.3.
|
|
20
|
-
"@lexical/mark": "0.3.
|
|
21
|
-
"@lexical/markdown": "0.3.
|
|
22
|
-
"@lexical/overflow": "0.3.
|
|
23
|
-
"@lexical/plain-text": "0.3.
|
|
24
|
-
"@lexical/rich-text": "0.3.
|
|
25
|
-
"@lexical/selection": "0.3.
|
|
26
|
-
"@lexical/table": "0.3.
|
|
27
|
-
"@lexical/text": "0.3.
|
|
28
|
-
"@lexical/utils": "0.3.
|
|
29
|
-
"@lexical/yjs": "0.3.
|
|
13
|
+
"@lexical/clipboard": "0.3.11",
|
|
14
|
+
"@lexical/code": "0.3.11",
|
|
15
|
+
"@lexical/dragon": "0.3.11",
|
|
16
|
+
"@lexical/hashtag": "0.3.11",
|
|
17
|
+
"@lexical/history": "0.3.11",
|
|
18
|
+
"@lexical/link": "0.3.11",
|
|
19
|
+
"@lexical/list": "0.3.11",
|
|
20
|
+
"@lexical/mark": "0.3.11",
|
|
21
|
+
"@lexical/markdown": "0.3.11",
|
|
22
|
+
"@lexical/overflow": "0.3.11",
|
|
23
|
+
"@lexical/plain-text": "0.3.11",
|
|
24
|
+
"@lexical/rich-text": "0.3.11",
|
|
25
|
+
"@lexical/selection": "0.3.11",
|
|
26
|
+
"@lexical/table": "0.3.11",
|
|
27
|
+
"@lexical/text": "0.3.11",
|
|
28
|
+
"@lexical/utils": "0.3.11",
|
|
29
|
+
"@lexical/yjs": "0.3.11"
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|
|
32
|
-
"lexical": "0.3.
|
|
32
|
+
"lexical": "0.3.11",
|
|
33
33
|
"react": ">=17.x",
|
|
34
34
|
"react-dom": ">=17.x"
|
|
35
35
|
},
|