@lexical/react 0.4.1 → 0.5.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/DEPRECATED_useLexical.js.flow +0 -1
- package/DEPRECATED_useLexicalPlainText.d.ts +2 -2
- package/DEPRECATED_useLexicalPlainText.dev.js +4 -4
- package/DEPRECATED_useLexicalPlainText.js.flow +0 -1
- package/DEPRECATED_useLexicalPlainText.prod.js +2 -2
- package/DEPRECATED_useLexicalRichText.d.ts +2 -2
- package/DEPRECATED_useLexicalRichText.dev.js +4 -4
- package/DEPRECATED_useLexicalRichText.js.flow +0 -1
- package/DEPRECATED_useLexicalRichText.prod.js +2 -2
- package/LexicalAutoEmbedPlugin.d.ts +0 -2
- package/LexicalAutoEmbedPlugin.dev.js +0 -1
- package/LexicalAutoEmbedPlugin.prod.js +4 -4
- package/LexicalAutoLinkPlugin.dev.js +2 -1
- package/LexicalAutoLinkPlugin.prod.js +3 -3
- package/LexicalBlockWithAlignableContents.dev.js +1 -1
- package/LexicalBlockWithAlignableContents.prod.js +1 -1
- package/LexicalCollaborationPlugin.d.ts +5 -1
- package/LexicalCollaborationPlugin.dev.js +54 -16
- package/LexicalCollaborationPlugin.js.flow +1 -0
- package/LexicalCollaborationPlugin.prod.js +9 -9
- package/LexicalComposer.d.ts +1 -2
- package/LexicalComposer.dev.js +15 -1
- package/LexicalComposer.js.flow +14 -7
- package/LexicalComposer.prod.js +3 -3
- package/LexicalContentEditable.dev.js +1 -1
- package/LexicalContentEditable.prod.js +1 -1
- package/LexicalHorizontalRuleNode.d.ts +4 -2
- package/LexicalHorizontalRuleNode.dev.js +24 -2
- package/LexicalHorizontalRuleNode.js.flow +0 -1
- package/LexicalHorizontalRuleNode.prod.js +5 -5
- package/LexicalNestedComposer.d.ts +4 -2
- package/LexicalNestedComposer.dev.js +25 -3
- package/LexicalNestedComposer.js.flow +1 -0
- package/LexicalNestedComposer.prod.js +3 -3
- package/LexicalOnChangePlugin.d.ts +1 -2
- package/LexicalOnChangePlugin.dev.js +3 -9
- package/LexicalOnChangePlugin.js.flow +0 -2
- package/LexicalOnChangePlugin.prod.js +2 -2
- package/LexicalPlainTextPlugin.d.ts +1 -3
- package/LexicalPlainTextPlugin.dev.js +4 -29
- package/LexicalPlainTextPlugin.js.flow +0 -1
- package/LexicalPlainTextPlugin.prod.js +4 -4
- package/LexicalRichTextPlugin.d.ts +1 -3
- package/LexicalRichTextPlugin.dev.js +4 -29
- package/LexicalRichTextPlugin.js.flow +0 -1
- package/LexicalRichTextPlugin.prod.js +4 -4
- package/LexicalTableOfContents__EXPERIMENTAL.js.flow +1 -1
- package/LexicalTablePlugin.dev.js +1 -1
- package/LexicalTablePlugin.prod.js +1 -1
- package/LexicalTreeView.dev.js +4 -4
- package/LexicalTreeView.prod.js +4 -4
- package/LexicalTypeaheadMenuPlugin.d.ts +5 -2
- package/LexicalTypeaheadMenuPlugin.dev.js +13 -10
- package/LexicalTypeaheadMenuPlugin.prod.js +16 -16
- package/package.json +19 -19
- package/shared/usePlainTextSetup.d.ts +1 -2
- package/shared/useRichTextSetup.d.ts +1 -2
- package/shared/useYjsCollaboration.d.ts +4 -1
|
@@ -4,19 +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 m=require("@lexical/react/LexicalComposerContext"),n=require("@lexical/utils"),
|
|
8
|
-
let
|
|
9
|
-
function D(b){let a=null;b.getEditorState().read(()=>{var c=
|
|
10
|
-
function E(b,a){b=
|
|
11
|
-
function F(b,a){return 0!==a?!1:b.getEditorState().read(()=>{var c=
|
|
12
|
-
function H({close:b,editor:a,anchorElement:c,resolution:
|
|
13
|
-
[a]);
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
function I(b){let [a]=m.useLexicalComposerContext(),c=
|
|
17
|
-
|
|
18
|
-
exports.LexicalNodeMenuPlugin=function({options:b,nodeKey:a,
|
|
19
|
-
{close:
|
|
20
|
-
exports.LexicalTypeaheadMenuPlugin=function({options:b,onQueryChange:a,onSelectOption:c,menuRenderFn:
|
|
21
|
-
l)?
|
|
22
|
-
exports.useBasicTypeaheadTriggerMatch=function(b,{minLength:a=1,maxLength:c=75}){return
|
|
7
|
+
'use strict';var m=require("@lexical/react/LexicalComposerContext"),n=require("@lexical/utils"),v=require("lexical"),w=require("react"),x="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?w.useLayoutEffect:w.useEffect;class y{constructor(b){this.key=b;this.ref={current:null};this.setRefElement=this.setRefElement.bind(this)}setRefElement(b){this.ref={current:b}}}
|
|
8
|
+
let z=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=v.$getSelection();if(v.$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=v.$getSelection();if(!v.$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 h=a;h<=e.length;h++)d.substr(-h)===e.substr(0,h)&&(a=h);a=c-a;if(0>a)return null;let k;0===a?[k]=b.splitText(c):[,k]=b.splitText(a,c);return k}
|
|
11
|
+
function F(b,a){return 0!==a?!1:b.getEditorState().read(()=>{var c=v.$getSelection();return v.$isRangeSelection(c)?(c=c.anchor.getNode().getPreviousSibling(),v.$isTextNode(c)&&c.isTextEntity()):!1})}function G(b){w.startTransition?w.startTransition(b):b()}
|
|
12
|
+
function H({close:b,editor:a,anchorElement:c,resolution:d,options:e,menuRenderFn:k,onSelectOption:h}){let [f,p]=w.useState(null);w.useEffect(()=>{p(0)},[d.match.matchingString]);let q=w.useCallback(g=>{a.update(()=>{const l=E(a,d.match);h(g,l,b,d.match.matchingString)})},[b,a,d.match,h]),r=w.useCallback(g=>{const l=a.getRootElement();null!==l&&(l.setAttribute("aria-activedescendant","typeahead-item-"+g),p(g))},[a]);w.useEffect(()=>()=>{let g=a.getRootElement();null!==g&&g.removeAttribute("aria-activedescendant")},
|
|
13
|
+
[a]);x(()=>{null===e?p(null):null===f&&r(0)},[e,f,r]);w.useEffect(()=>n.mergeRegister(a.registerCommand(v.KEY_ARROW_DOWN_COMMAND,g=>{if(null!==e&&e.length&&null!==f){var l=f!==e.length-1?f+1:0;r(l);l=e[l];null!=l.ref&&l.ref.current&&z(l.ref.current);g.preventDefault();g.stopImmediatePropagation()}return!0},v.COMMAND_PRIORITY_NORMAL),a.registerCommand(v.KEY_ARROW_UP_COMMAND,g=>{if(null!==e&&e.length&&null!==f){var l=0!==f?f-1:e.length-1;r(l);l=e[l];null!=l.ref&&l.ref.current&&z(l.ref.current);g.preventDefault();
|
|
14
|
+
g.stopImmediatePropagation()}return!0},v.COMMAND_PRIORITY_NORMAL),a.registerCommand(v.KEY_ESCAPE_COMMAND,g=>{g.preventDefault();g.stopImmediatePropagation();b();return!0},v.COMMAND_PRIORITY_NORMAL),a.registerCommand(v.KEY_TAB_COMMAND,g=>{if(null===e||null===f||null==e[f])return!1;g.preventDefault();g.stopImmediatePropagation();q(e[f]);return!0},v.COMMAND_PRIORITY_NORMAL),a.registerCommand(v.KEY_ENTER_COMMAND,g=>{if(null===e||null===f||null==e[f])return!1;null!==g&&(g.preventDefault(),g.stopImmediatePropagation());
|
|
15
|
+
q(e[f]);return!0},v.COMMAND_PRIORITY_NORMAL)),[q,b,a,e,f,r]);let t=w.useMemo(()=>({selectOptionAndCleanUp:q,selectedIndex:f,setHighlightedIndex:p}),[q,f]);return k(c,t,d.match.matchingString)}
|
|
16
|
+
function I(b){let [a]=m.useLexicalComposerContext(),c=w.useRef(document.createElement("div"));w.useEffect(()=>{function d(){let k=c.current;k.setAttribute("aria-label","Typeahead menu");k.setAttribute("id","typeahead-menu");k.setAttribute("role","listbox");if(null!==e&&null!==b){let {left:h,top:f,width:p,height:q}=b.getRect();k.style.top=`${f+q+5+window.pageYOffset}px`;k.style.left=`${h+("start"===b.position?0:p)+window.pageXOffset}px`;k.style.display="block";k.style.position="absolute";k.isConnected||
|
|
17
|
+
document.body.append(k);c.current=k;e.setAttribute("aria-controls","typeahead-menu")}}let e=a.getRootElement();if(null!==b)return d(),window.addEventListener("resize",d),()=>{window.removeEventListener("resize",d);null!==e&&e.removeAttribute("aria-controls")}},[a,b]);return c}
|
|
18
|
+
exports.LexicalNodeMenuPlugin=function({options:b,nodeKey:a,position:c="end",onClose:d,onSelectOption:e,menuRenderFn:k}){let [h]=m.useLexicalComposerContext(),[f,p]=w.useState(null),q=I(f);w.useEffect(()=>{a&&null==f?h.update(()=>{let r=v.$getNodeByKey(a),t=h.getElementByKey(a);if(null!=r&&null!=t){let g=r.getTextContent();G(()=>p({getRect:()=>t.getBoundingClientRect(),match:{leadOffset:g.length,matchingString:g,replaceableString:g},position:c}))}}):null==a&&null!=f&&p(null)},[h,a,c,f]);return null===
|
|
19
|
+
f||null===h?null:w.createElement(H,{close:d,resolution:f,editor:h,anchorElement:q.current,options:b,menuRenderFn:k,onSelectOption:e})};
|
|
20
|
+
exports.LexicalTypeaheadMenuPlugin=function({options:b,onQueryChange:a,onSelectOption:c,menuRenderFn:d,triggerFn:e,position:k="start"}){let [h]=m.useLexicalComposerContext(),[f,p]=w.useState(null),q=I(f);w.useEffect(()=>{let t=document.createRange(),g=h.registerUpdateListener(()=>{h.getEditorState().read(()=>{const l=t,A=v.$getSelection(),B=D(h);if(v.$isRangeSelection(A)&&A.isCollapsed()&&null!==B&&null!==l){var u=e(B,h);a(u?u.matchingString:null);null===u||F(h,u.leadOffset)||null===C(u.leadOffset,
|
|
21
|
+
l)?p(null):G(()=>p({getRect:()=>l.getBoundingClientRect(),match:u,position:k}))}else p(null)})});return()=>{t=null;g()}},[h,e,a,f,k]);let r=w.useCallback(()=>{p(null)},[]);return null===f||null===h?null:w.createElement(H,{close:r,resolution:f,editor:h,anchorElement:q.current,options:b,menuRenderFn:d,onSelectOption:c})};exports.PUNCTUATION="\\.,\\+\\*\\?\\$\\@\\|#{}\\(\\)\\^\\-\\[\\]\\\\/!%'\"~=<>_:;";exports.TypeaheadOption=y;
|
|
22
|
+
exports.useBasicTypeaheadTriggerMatch=function(b,{minLength:a=1,maxLength:c=75}){return w.useCallback(d=>{d=(new RegExp("(^|\\s|\\()(["+b+"]((?:[^"+(b+"\\.,\\+\\*\\?\\$\\@\\|#{}\\(\\)\\^\\-\\[\\]\\\\/!%'\"~=<>_:;\\s]){0,")+c+"}))$")).exec(d);if(null!==d){let e=d[1],k=d[3];if(k.length>=a)return{leadOffset:d.index+e.length,matchingString:k,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.
|
|
11
|
+
"version": "0.5.0",
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@lexical/clipboard": "0.
|
|
14
|
-
"@lexical/code": "0.
|
|
15
|
-
"@lexical/dragon": "0.
|
|
16
|
-
"@lexical/hashtag": "0.
|
|
17
|
-
"@lexical/history": "0.
|
|
18
|
-
"@lexical/link": "0.
|
|
19
|
-
"@lexical/list": "0.
|
|
20
|
-
"@lexical/mark": "0.
|
|
21
|
-
"@lexical/markdown": "0.
|
|
22
|
-
"@lexical/overflow": "0.
|
|
23
|
-
"@lexical/plain-text": "0.
|
|
24
|
-
"@lexical/rich-text": "0.
|
|
25
|
-
"@lexical/selection": "0.
|
|
26
|
-
"@lexical/table": "0.
|
|
27
|
-
"@lexical/text": "0.
|
|
28
|
-
"@lexical/utils": "0.
|
|
29
|
-
"@lexical/yjs": "0.
|
|
13
|
+
"@lexical/clipboard": "0.5.0",
|
|
14
|
+
"@lexical/code": "0.5.0",
|
|
15
|
+
"@lexical/dragon": "0.5.0",
|
|
16
|
+
"@lexical/hashtag": "0.5.0",
|
|
17
|
+
"@lexical/history": "0.5.0",
|
|
18
|
+
"@lexical/link": "0.5.0",
|
|
19
|
+
"@lexical/list": "0.5.0",
|
|
20
|
+
"@lexical/mark": "0.5.0",
|
|
21
|
+
"@lexical/markdown": "0.5.0",
|
|
22
|
+
"@lexical/overflow": "0.5.0",
|
|
23
|
+
"@lexical/plain-text": "0.5.0",
|
|
24
|
+
"@lexical/rich-text": "0.5.0",
|
|
25
|
+
"@lexical/selection": "0.5.0",
|
|
26
|
+
"@lexical/table": "0.5.0",
|
|
27
|
+
"@lexical/text": "0.5.0",
|
|
28
|
+
"@lexical/utils": "0.5.0",
|
|
29
|
+
"@lexical/yjs": "0.5.0"
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|
|
32
|
-
"lexical": "0.
|
|
32
|
+
"lexical": "0.5.0",
|
|
33
33
|
"react": ">=17.x",
|
|
34
34
|
"react-dom": ">=17.x"
|
|
35
35
|
},
|
|
@@ -6,5 +6,4 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
import type { LexicalEditor } from 'lexical';
|
|
9
|
-
|
|
10
|
-
export declare function usePlainTextSetup(editor: LexicalEditor, initialEditorState?: InitialEditorStateType): void;
|
|
9
|
+
export declare function usePlainTextSetup(editor: LexicalEditor): void;
|
|
@@ -5,6 +5,5 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
|
-
import type { InitialEditorStateType } from '@lexical/rich-text';
|
|
9
8
|
import type { LexicalEditor } from 'lexical';
|
|
10
|
-
export declare function useRichTextSetup(editor: LexicalEditor
|
|
9
|
+
export declare function useRichTextSetup(editor: LexicalEditor): void;
|
|
@@ -8,7 +8,10 @@
|
|
|
8
8
|
import type { Binding } from '@lexical/yjs';
|
|
9
9
|
import type { LexicalEditor } from 'lexical';
|
|
10
10
|
import type { Doc } from 'yjs';
|
|
11
|
+
import * as React from 'react';
|
|
11
12
|
import { WebsocketProvider } from 'y-websocket';
|
|
12
|
-
|
|
13
|
+
import { InitialEditorStateType } from '../LexicalComposer';
|
|
14
|
+
export declare type CursorsContainerRef = React.MutableRefObject<HTMLElement | null>;
|
|
15
|
+
export declare function useYjsCollaboration(editor: LexicalEditor, id: string, provider: WebsocketProvider, docMap: Map<string, Doc>, name: string, color: string, shouldBootstrap: boolean, cursorsContainerRef?: CursorsContainerRef, initialEditorState?: InitialEditorStateType): [JSX.Element, Binding];
|
|
13
16
|
export declare function useYjsFocusTracking(editor: LexicalEditor, provider: WebsocketProvider, name: string, color: string): void;
|
|
14
17
|
export declare function useYjsHistory(editor: LexicalEditor, binding: Binding): () => void;
|