@lexical/react 0.35.1-nightly.20250919.0 → 0.35.1-nightly.20250923.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.
- package/LexicalCollaborationContext.d.ts +4 -1
- package/LexicalCollaborationContext.dev.js +35 -7
- package/LexicalCollaborationContext.dev.mjs +36 -9
- package/LexicalCollaborationContext.mjs +1 -0
- package/LexicalCollaborationContext.node.mjs +1 -0
- package/LexicalCollaborationContext.prod.js +1 -1
- package/LexicalCollaborationContext.prod.mjs +1 -1
- package/LexicalContextMenuPlugin.d.ts +2 -2
- package/LexicalContextMenuPlugin.dev.js +2 -1
- package/LexicalContextMenuPlugin.dev.mjs +2 -1
- package/LexicalContextMenuPlugin.prod.js +1 -1
- package/LexicalContextMenuPlugin.prod.mjs +1 -1
- package/LexicalEditorRefPlugin.d.ts +2 -2
- package/LexicalErrorBoundary.dev.js +2 -140
- package/LexicalErrorBoundary.dev.mjs +1 -126
- package/LexicalErrorBoundary.prod.js +1 -1
- package/LexicalErrorBoundary.prod.mjs +1 -1
- package/LexicalNestedComposer.dev.js +3 -2
- package/LexicalNestedComposer.dev.mjs +4 -3
- package/LexicalNestedComposer.prod.js +1 -1
- package/LexicalNestedComposer.prod.mjs +1 -1
- package/LexicalNodeContextMenuPlugin.d.ts +2 -2
- package/LexicalNodeContextMenuPlugin.dev.js +27 -5221
- package/LexicalNodeContextMenuPlugin.dev.mjs +3 -5184
- package/LexicalNodeContextMenuPlugin.prod.js +1 -5
- package/LexicalNodeContextMenuPlugin.prod.mjs +1 -5
- package/LexicalNodeMenuPlugin.dev.js +2 -1
- package/LexicalNodeMenuPlugin.dev.mjs +2 -1
- package/LexicalNodeMenuPlugin.prod.js +1 -1
- package/LexicalNodeMenuPlugin.prod.mjs +1 -1
- package/LexicalTypeaheadMenuPlugin.dev.js +2 -1
- package/LexicalTypeaheadMenuPlugin.dev.mjs +2 -1
- package/LexicalTypeaheadMenuPlugin.prod.js +1 -1
- package/LexicalTypeaheadMenuPlugin.prod.mjs +1 -1
- package/package.json +19 -19
- package/shared/LexicalMenu.d.ts +5 -5
- package/shared/mergeRefs.d.ts +1 -1
- package/shared/useYjsCollaboration.d.ts +1 -1
|
@@ -6,4 +6,4 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import{useLexicalComposerContext as t}from"@lexical/react/LexicalComposerContext";import{createCommand as e,KEY_ARROW_DOWN_COMMAND as n,KEY_ARROW_UP_COMMAND as o,KEY_ESCAPE_COMMAND as r,KEY_TAB_COMMAND as l,KEY_ENTER_COMMAND as i,COMMAND_PRIORITY_LOW as u,$getSelection as s,$isRangeSelection as c,getDOMSelection as a,$isTextNode as d}from"lexical";import m,{useLayoutEffect as f,useEffect as p,useState as g,useCallback as h,useMemo as w,useRef as y}from"react";import{mergeRegister as v}from"@lexical/utils";import{jsx as b}from"react/jsx-runtime";const C="startTransition";const E="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,x=E?f:p;class R{constructor(t){this.key=t,this.ref={current:null},this.setRefElement=this.setRefElement.bind(this)}setRefElement(t){this.ref={current:t}}}const S=t=>{const e=document.getElementById("typeahead-menu");if(!e)return;const n=e.getBoundingClientRect();n.top+n.height>window.innerHeight&&e.scrollIntoView({block:"center"}),n.top<0&&e.scrollIntoView({block:"center"}),t.scrollIntoView({block:"nearest"})};function O(t,e){const n=t.getBoundingClientRect(),o=e.getBoundingClientRect();return n.top
|
|
9
|
+
import{useLexicalComposerContext as t}from"@lexical/react/LexicalComposerContext";import{createCommand as e,KEY_ARROW_DOWN_COMMAND as n,KEY_ARROW_UP_COMMAND as o,KEY_ESCAPE_COMMAND as r,KEY_TAB_COMMAND as l,KEY_ENTER_COMMAND as i,COMMAND_PRIORITY_LOW as u,$getSelection as s,$isRangeSelection as c,getDOMSelection as a,$isTextNode as d}from"lexical";import m,{useLayoutEffect as f,useEffect as p,useState as g,useCallback as h,useMemo as w,useRef as y}from"react";import{mergeRegister as v}from"@lexical/utils";import{jsx as b}from"react/jsx-runtime";const C="startTransition";const E="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,x=E?f:p;class R{constructor(t){this.key=t,this.ref={current:null},this.setRefElement=this.setRefElement.bind(this)}setRefElement(t){this.ref={current:t}}}const S=t=>{const e=document.getElementById("typeahead-menu");if(!e)return;const n=e.getBoundingClientRect();n.top+n.height>window.innerHeight&&e.scrollIntoView({block:"center"}),n.top<0&&e.scrollIntoView({block:"center"}),t.scrollIntoView({block:"nearest"})};function O(t,e){const n=t.getBoundingClientRect(),o=e.getBoundingClientRect();return n.top>=o.top-6&&n.top<=o.bottom+6}function I(e,n,o,r){const[l]=t();p((()=>{if(null!=n&&null!=e){const t=l.getRootElement(),e=null!=t?function(t,e){let n=getComputedStyle(t);const o="absolute"===n.position,r=/(auto|scroll)/;if("fixed"===n.position)return document.body;for(let e=t;e=e.parentElement;)if(n=getComputedStyle(e),(!o||"static"!==n.position)&&r.test(n.overflow+n.overflowY+n.overflowX))return e;return document.body}(t):document.body;let i=!1,u=O(n,e);const s=function(){i||(window.requestAnimationFrame((function(){o(),i=!1})),i=!0);const t=O(n,e);t!==u&&(u=t,null!=r&&r(t))},c=new ResizeObserver(o);return window.addEventListener("resize",o),document.addEventListener("scroll",s,{capture:!0,passive:!0}),c.observe(n),()=>{c.unobserve(n),window.removeEventListener("resize",o),document.removeEventListener("scroll",s,!0)}}}),[n,l,r,o,e])}const A=e("SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND");function T({close:t,editor:e,anchorElementRef:a,resolution:d,options:m,menuRenderFn:f,onSelectOption:y,shouldSplitNodeWithQuery:b=!1,commandPriority:C=u,preselectFirstItem:E=!0}){const[R,O]=g(null),I=d.match&&d.match.matchingString;p((()=>{E&&O(0)}),[I,E]);const T=h((n=>{e.update((()=>{const e=null!=d.match&&b?function(t){const e=s();if(!c(e)||!e.isCollapsed())return null;const n=e.anchor;if("text"!==n.type)return null;const o=n.getNode();if(!o.isSimpleText())return null;const r=n.offset,l=o.getTextContent().slice(0,r),i=t.replaceableString.length,u=r-function(t,e,n){let o=n;for(let n=o;n<=e.length;n++)t.slice(-n)===e.substring(0,n)&&(o=n);return o}(l,t.matchingString,i);if(u<0)return null;let a;return 0===u?[a]=o.splitText(r):[,a]=o.splitText(u,r),a}(d.match):null;y(n,e,t,d.match?d.match.matchingString:"")}))}),[e,b,d.match,y,t]),N=h((t=>{const n=e.getRootElement();null!==n&&(n.setAttribute("aria-activedescendant","typeahead-item-"+t),O(t))}),[e]);p((()=>()=>{const t=e.getRootElement();null!==t&&t.removeAttribute("aria-activedescendant")}),[e]),x((()=>{null===m?O(null):null===R&&E&&N(0)}),[m,R,N,E]),p((()=>v(e.registerCommand(A,(({option:t})=>!(!t.ref||null==t.ref.current)&&(S(t.ref.current),!0)),C))),[e,N,C]),p((()=>v(e.registerCommand(n,(t=>{const n=t;if(null!==m&&m.length){const t=null===R?0:R!==m.length-1?R+1:0;N(t);const o=m[t];null!=o.ref&&o.ref.current&&e.dispatchCommand(A,{index:t,option:o}),n.preventDefault(),n.stopImmediatePropagation()}return!0}),C),e.registerCommand(o,(t=>{const e=t;if(null!==m&&m.length){const t=null===R?m.length-1:0!==R?R-1:m.length-1;N(t);const n=m[t];null!=n.ref&&n.ref.current&&S(n.ref.current),e.preventDefault(),e.stopImmediatePropagation()}return!0}),C),e.registerCommand(r,(e=>{const n=e;return n.preventDefault(),n.stopImmediatePropagation(),t(),!0}),C),e.registerCommand(l,(t=>{const e=t;return null!==m&&null!==R&&null!=m[R]&&(e.preventDefault(),e.stopImmediatePropagation(),T(m[R]),!0)}),C),e.registerCommand(i,(t=>null!==m&&null!==R&&null!=m[R]&&(null!==t&&(t.preventDefault(),t.stopImmediatePropagation()),T(m[R]),!0)),C))),[T,t,e,m,R,N,C]);return f(a,w((()=>({options:m,selectOptionAndCleanUp:T,selectedIndex:R,setHighlightedIndex:O})),[T,R,m]),d.match?d.match.matchingString:"")}function N(t,e){null!=e&&(t.className=e),t.setAttribute("aria-label","Typeahead menu"),t.setAttribute("role","listbox"),t.style.display="block",t.style.position="absolute"}const L="\\.,\\+\\*\\?\\$\\@\\|#{}\\(\\)\\^\\-\\[\\]\\\\/!%'\"~=<>_:;";function P(t,e){let n=getComputedStyle(t);const o="absolute"===n.position,r=e?/(auto|scroll|hidden)/:/(auto|scroll)/;if("fixed"===n.position)return document.body;for(let e=t;e=e.parentElement;)if(n=getComputedStyle(e),(!o||"static"!==n.position)&&r.test(n.overflow+n.overflowY+n.overflowX))return e;return document.body}const _=e("SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND");function D(t,{minLength:e=1,maxLength:n=75,punctuation:o=L,allowWhitespace:r=!1}){return h((l=>{const i=new RegExp("(^|\\s|\\()(["+t+"]((?:"+("[^"+t+o+(r?"":"\\s")+"]")+"){0,"+n+"}))$").exec(l);if(null!==i){const t=i[1],n=i[3];if(n.length>=e)return{leadOffset:i.index+t.length,matchingString:n,replaceableString:i[2]}}return null}),[r,t,o,n,e])}function $({options:e,onQueryChange:n,onSelectOption:o,onOpen:r,onClose:l,menuRenderFn:i,triggerFn:f,anchorClassName:w,commandPriority:v=u,parent:x,preselectFirstItem:R=!0,ignoreEntityBoundary:S=!1}){const[O]=t(),[A,L]=g(null),P=function(e,n,o,r=(E?document.body:void 0),l=!0){const[i]=t(),u=E?document.createElement("div"):null,s=y(u),c=h((()=>{if(null===s.current||void 0===r)return;s.current.style.top=s.current.style.bottom;const t=i.getRootElement(),n=s.current,u=n.firstChild;if(null!==t&&null!==e){const{left:i,top:c,width:a,height:d}=e.getRect(),m=s.current.offsetHeight;if(n.style.top=`${c+m+3+(l?window.pageYOffset:0)}px`,n.style.left=`${i+window.pageXOffset}px`,n.style.height=`${d}px`,n.style.width=`${a}px`,null!==u){u.style.top=`${c}`;const e=u.getBoundingClientRect(),o=e.height,r=e.width,s=t.getBoundingClientRect();i+r>s.right&&(n.style.left=`${s.right-r+window.pageXOffset}px`),(c+o>window.innerHeight||c+o>s.bottom)&&c-s.top>o+d&&(n.style.top=`${c-o-d+(l?window.pageYOffset:0)}px`)}n.isConnected||(N(n,o),r.append(n)),n.setAttribute("id","typeahead-menu"),t.setAttribute("aria-controls","typeahead-menu")}}),[i,e,l,o,r]);p((()=>{const t=i.getRootElement();return null!==e&&c(),()=>{null!==t&&t.removeAttribute("aria-controls");const e=s.current;null!==e&&e.isConnected&&(e.remove(),e.removeAttribute("id"))}}),[i,c,e]);const a=h((t=>{null!==e&&(t||n(null))}),[e,n]);return I(e,s.current,c,a),null!=u&&u===s.current&&(N(u,o),null!=r&&r.append(u)),s}(A,L,w,x),_=h((()=>{L(null),null!=l&&null!==A&&l()}),[l,A]),D=h((t=>{L(t),null!=r&&null===A&&r(t)}),[r,A]);return p((()=>{const t=O.registerUpdateListener((()=>{O.getEditorState().read((()=>{if(!O.isEditable())return void _();const t=O._window||window,e=t.document.createRange(),o=s(),r=function(t){let e=null;return t.getEditorState().read((()=>{const t=s();c(t)&&(e=function(t){const e=t.anchor;if("text"!==e.type)return null;const n=e.getNode();if(!n.isSimpleText())return null;const o=e.offset;return n.getTextContent().slice(0,o)}(t))})),e}(O);if(!c(o)||!o.isCollapsed()||null===r||null===e)return void _();const l=f(r,O);if(n(l?l.matchingString:null),null!==l&&(S||!function(t,e){return 0===e&&t.getEditorState().read((()=>{const t=s();if(c(t)){const e=t.anchor.getNode().getPreviousSibling();return d(e)&&e.isTextEntity()}return!1}))}(O,l.leadOffset))){const n=function(t,e,n){const o=a(n);if(null===o||!o.isCollapsed)return!1;const r=o.anchorNode,l=t,i=o.anchorOffset;if(null==r||null==i)return!1;try{e.setStart(r,l),e.setEnd(r,i)}catch(t){return!1}return!0}(l.leadOffset,e,t);if(null!==n)return i=()=>D({getRect:()=>e.getBoundingClientRect(),match:l}),void(C in m?m[C](i):i())}var i;_()}))}));return()=>{t()}}),[O,f,n,A,_,D,S]),p((()=>O.registerEditableListener((t=>{t||_()}))),[O,_]),null===A||null===O||null===P.current?null:b(T,{close:_,resolution:A,editor:O,anchorElementRef:P,options:e,menuRenderFn:i,shouldSplitNodeWithQuery:!0,onSelectOption:o,commandPriority:v,preselectFirstItem:R})}export{$ as LexicalTypeaheadMenuPlugin,R as MenuOption,L as PUNCTUATION,_ as SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND,P as getScrollParent,D as useBasicTypeaheadTriggerMatch,I as useDynamicPositioning};
|
package/package.json
CHANGED
|
@@ -8,26 +8,26 @@
|
|
|
8
8
|
"rich-text"
|
|
9
9
|
],
|
|
10
10
|
"license": "MIT",
|
|
11
|
-
"version": "0.35.1-nightly.
|
|
11
|
+
"version": "0.35.1-nightly.20250923.0",
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@floating-ui/react": "^0.27.
|
|
14
|
-
"@lexical/devtools-core": "0.35.1-nightly.
|
|
15
|
-
"@lexical/dragon": "0.35.1-nightly.
|
|
16
|
-
"@lexical/hashtag": "0.35.1-nightly.
|
|
17
|
-
"@lexical/history": "0.35.1-nightly.
|
|
18
|
-
"@lexical/link": "0.35.1-nightly.
|
|
19
|
-
"@lexical/list": "0.35.1-nightly.
|
|
20
|
-
"@lexical/mark": "0.35.1-nightly.
|
|
21
|
-
"@lexical/markdown": "0.35.1-nightly.
|
|
22
|
-
"@lexical/overflow": "0.35.1-nightly.
|
|
23
|
-
"@lexical/plain-text": "0.35.1-nightly.
|
|
24
|
-
"@lexical/rich-text": "0.35.1-nightly.
|
|
25
|
-
"@lexical/table": "0.35.1-nightly.
|
|
26
|
-
"@lexical/text": "0.35.1-nightly.
|
|
27
|
-
"@lexical/utils": "0.35.1-nightly.
|
|
28
|
-
"@lexical/yjs": "0.35.1-nightly.
|
|
29
|
-
"lexical": "0.35.1-nightly.
|
|
30
|
-
"react-error-boundary": "^
|
|
13
|
+
"@floating-ui/react": "^0.27.16",
|
|
14
|
+
"@lexical/devtools-core": "0.35.1-nightly.20250923.0",
|
|
15
|
+
"@lexical/dragon": "0.35.1-nightly.20250923.0",
|
|
16
|
+
"@lexical/hashtag": "0.35.1-nightly.20250923.0",
|
|
17
|
+
"@lexical/history": "0.35.1-nightly.20250923.0",
|
|
18
|
+
"@lexical/link": "0.35.1-nightly.20250923.0",
|
|
19
|
+
"@lexical/list": "0.35.1-nightly.20250923.0",
|
|
20
|
+
"@lexical/mark": "0.35.1-nightly.20250923.0",
|
|
21
|
+
"@lexical/markdown": "0.35.1-nightly.20250923.0",
|
|
22
|
+
"@lexical/overflow": "0.35.1-nightly.20250923.0",
|
|
23
|
+
"@lexical/plain-text": "0.35.1-nightly.20250923.0",
|
|
24
|
+
"@lexical/rich-text": "0.35.1-nightly.20250923.0",
|
|
25
|
+
"@lexical/table": "0.35.1-nightly.20250923.0",
|
|
26
|
+
"@lexical/text": "0.35.1-nightly.20250923.0",
|
|
27
|
+
"@lexical/utils": "0.35.1-nightly.20250923.0",
|
|
28
|
+
"@lexical/yjs": "0.35.1-nightly.20250923.0",
|
|
29
|
+
"lexical": "0.35.1-nightly.20250923.0",
|
|
30
|
+
"react-error-boundary": "^6.0.0"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
33
|
"react": ">=17.x",
|
package/shared/LexicalMenu.d.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import type { JSX } from 'react';
|
|
9
9
|
import { CommandListenerPriority, LexicalCommand, LexicalEditor, TextNode } from 'lexical';
|
|
10
|
-
import {
|
|
10
|
+
import { ReactPortal, RefObject } from 'react';
|
|
11
11
|
export type MenuTextMatch = {
|
|
12
12
|
leadOffset: number;
|
|
13
13
|
matchingString: string;
|
|
@@ -20,11 +20,11 @@ export type MenuResolution = {
|
|
|
20
20
|
export declare const PUNCTUATION = "\\.,\\+\\*\\?\\$\\@\\|#{}\\(\\)\\^\\-\\[\\]\\\\/!%'\"~=<>_:;";
|
|
21
21
|
export declare class MenuOption {
|
|
22
22
|
key: string;
|
|
23
|
-
ref?:
|
|
23
|
+
ref?: RefObject<HTMLElement | null>;
|
|
24
24
|
constructor(key: string);
|
|
25
25
|
setRefElement(element: HTMLElement | null): void;
|
|
26
26
|
}
|
|
27
|
-
export type MenuRenderFn<TOption extends MenuOption> = (anchorElementRef:
|
|
27
|
+
export type MenuRenderFn<TOption extends MenuOption> = (anchorElementRef: RefObject<HTMLElement | null>, itemProps: {
|
|
28
28
|
selectedIndex: number | null;
|
|
29
29
|
selectOptionAndCleanUp: (option: TOption) => void;
|
|
30
30
|
setHighlightedIndex: (index: number) => void;
|
|
@@ -39,7 +39,7 @@ export declare const SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND: LexicalCommand<{
|
|
|
39
39
|
export declare function LexicalMenu<TOption extends MenuOption>({ close, editor, anchorElementRef, resolution, options, menuRenderFn, onSelectOption, shouldSplitNodeWithQuery, commandPriority, preselectFirstItem, }: {
|
|
40
40
|
close: () => void;
|
|
41
41
|
editor: LexicalEditor;
|
|
42
|
-
anchorElementRef:
|
|
42
|
+
anchorElementRef: RefObject<HTMLElement | null>;
|
|
43
43
|
resolution: MenuResolution;
|
|
44
44
|
options: Array<TOption>;
|
|
45
45
|
shouldSplitNodeWithQuery?: boolean;
|
|
@@ -48,5 +48,5 @@ export declare function LexicalMenu<TOption extends MenuOption>({ close, editor,
|
|
|
48
48
|
commandPriority?: CommandListenerPriority;
|
|
49
49
|
preselectFirstItem?: boolean;
|
|
50
50
|
}): JSX.Element | null;
|
|
51
|
-
export declare function useMenuAnchorRef(resolution: MenuResolution | null, setResolution: (r: MenuResolution | null) => void, className?: string, parent?: HTMLElement | undefined, shouldIncludePageYOffset__EXPERIMENTAL?: boolean):
|
|
51
|
+
export declare function useMenuAnchorRef(resolution: MenuResolution | null, setResolution: (r: MenuResolution | null) => void, className?: string, parent?: HTMLElement | undefined, shouldIncludePageYOffset__EXPERIMENTAL?: boolean): RefObject<HTMLElement | null>;
|
|
52
52
|
export type TriggerFn = (text: string, editor: LexicalEditor) => MenuTextMatch | null;
|
package/shared/mergeRefs.d.ts
CHANGED
|
@@ -5,4 +5,4 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
|
-
export declare function mergeRefs<T>(...refs: Array<React.
|
|
8
|
+
export declare function mergeRefs<T>(...refs: Array<React.RefObject<T> | React.LegacyRef<T> | undefined | null>): React.RefCallback<T>;
|
|
@@ -11,7 +11,7 @@ import type { JSX } from 'react';
|
|
|
11
11
|
import * as React from 'react';
|
|
12
12
|
import { Doc } from 'yjs';
|
|
13
13
|
import { InitialEditorStateType } from '../LexicalComposer';
|
|
14
|
-
export type CursorsContainerRef = React.
|
|
14
|
+
export type CursorsContainerRef = React.RefObject<HTMLElement | null>;
|
|
15
15
|
export declare function useYjsCollaboration(editor: LexicalEditor, id: string, provider: Provider, docMap: Map<string, Doc>, name: string, color: string, shouldBootstrap: boolean, binding: Binding, setDoc: React.Dispatch<React.SetStateAction<Doc | undefined>>, cursorsContainerRef?: CursorsContainerRef, initialEditorState?: InitialEditorStateType, awarenessData?: object, syncCursorPositionsFn?: SyncCursorPositionsFn): JSX.Element;
|
|
16
16
|
export declare function useYjsFocusTracking(editor: LexicalEditor, provider: Provider, name: string, color: string, awarenessData?: object): void;
|
|
17
17
|
export declare function useYjsHistory(editor: LexicalEditor, binding: Binding): () => void;
|