@lexical/react 0.3.5 → 0.3.8
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.d.ts +1 -2
- package/DEPRECATED_useLexical.dev.js +18 -9
- package/DEPRECATED_useLexical.prod.js +2 -3
- package/DEPRECATED_useLexicalCanShowPlaceholder.dev.js +18 -9
- package/DEPRECATED_useLexicalCanShowPlaceholder.prod.js +2 -2
- package/DEPRECATED_useLexicalCharacterLimit.prod.js +3 -3
- package/DEPRECATED_useLexicalEditor.dev.js +18 -9
- package/DEPRECATED_useLexicalEditor.prod.js +2 -2
- package/LexicalAutoFocusPlugin.d.ts +5 -1
- package/LexicalAutoFocusPlugin.dev.js +7 -3
- package/LexicalAutoFocusPlugin.js.flow +5 -1
- package/LexicalAutoFocusPlugin.prod.js +1 -1
- package/LexicalAutoLinkPlugin.d.ts +1 -1
- package/LexicalAutoLinkPlugin.prod.js +3 -3
- package/LexicalAutoScrollPlugin.d.ts +1 -1
- package/LexicalBlockWithAlignableContents.d.ts +2 -1
- package/LexicalBlockWithAlignableContents.dev.js +3 -4
- package/LexicalBlockWithAlignableContents.prod.js +2 -2
- package/LexicalCharacterLimitPlugin.prod.js +3 -3
- package/LexicalCheckListPlugin.dev.js +11 -6
- package/LexicalCheckListPlugin.prod.js +7 -7
- package/LexicalClearEditorPlugin.d.ts +1 -1
- package/LexicalCollaborationPlugin.dev.js +1 -0
- package/LexicalCollaborationPlugin.prod.js +1 -1
- package/LexicalComposer.d.ts +2 -2
- package/LexicalComposerContext.prod.js +2 -1
- package/LexicalContentEditable.dev.js +3 -3
- package/LexicalContentEditable.prod.js +1 -1
- package/LexicalDecoratorBlockNode.d.ts +2 -2
- package/LexicalDecoratorBlockNode.dev.js +1 -1
- package/LexicalDecoratorBlockNode.prod.js +1 -1
- package/LexicalHashtagPlugin.d.ts +1 -1
- package/LexicalNestedComposer.d.ts +2 -1
- package/LexicalNestedComposer.prod.js +2 -2
- package/LexicalPlainTextPlugin.dev.js +20 -12
- package/LexicalPlainTextPlugin.prod.js +4 -4
- package/LexicalRichTextPlugin.dev.js +20 -12
- package/LexicalRichTextPlugin.prod.js +4 -4
- package/LexicalTableOfContents__EXPERIMENTAL.d.ts +14 -0
- package/LexicalTableOfContents__EXPERIMENTAL.dev.js +144 -0
- package/LexicalTableOfContents__EXPERIMENTAL.js +9 -0
- package/LexicalTableOfContents__EXPERIMENTAL.js.flow +17 -0
- package/LexicalTableOfContents__EXPERIMENTAL.prod.js +10 -0
- package/LexicalTablePlugin.d.ts +1 -1
- package/LexicalTablePlugin.dev.js +1 -1
- package/LexicalTablePlugin.prod.js +3 -3
- package/LexicalTypeaheadMenuPlugin.d.ts +44 -0
- package/LexicalTypeaheadMenuPlugin.dev.js +463 -0
- package/LexicalTypeaheadMenuPlugin.js +9 -0
- package/LexicalTypeaheadMenuPlugin.prod.js +19 -0
- package/package.json +19 -22
- package/useLexicalTextEntity.d.ts +2 -3
|
@@ -5,8 +5,7 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
|
-
import type { EditorState, EditorThemeClasses, LexicalEditor, LexicalNode } from 'lexical';
|
|
9
|
-
import type { Klass } from 'shared/types';
|
|
8
|
+
import type { EditorState, EditorThemeClasses, Klass, LexicalEditor, LexicalNode } from 'lexical';
|
|
10
9
|
export declare function useLexical(editorConfig: {
|
|
11
10
|
disableEvents?: boolean;
|
|
12
11
|
editorState?: EditorState;
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
var lexical = require('lexical');
|
|
10
10
|
var react = require('react');
|
|
11
11
|
var text = require('@lexical/text');
|
|
12
|
+
var utils = require('@lexical/utils');
|
|
12
13
|
|
|
13
14
|
/**
|
|
14
15
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
@@ -36,18 +37,26 @@ var useLayoutEffect = useLayoutEffectImpl;
|
|
|
36
37
|
* LICENSE file in the root directory of this source tree.
|
|
37
38
|
*
|
|
38
39
|
*/
|
|
40
|
+
|
|
41
|
+
function canShowPlaceholderFromCurrentEditorState(editor) {
|
|
42
|
+
const currentCanShowPlaceholder = editor.getEditorState().read(text.$canShowPlaceholderCurry(editor.isComposing(), editor.isReadOnly()));
|
|
43
|
+
return currentCanShowPlaceholder;
|
|
44
|
+
}
|
|
45
|
+
|
|
39
46
|
function useCanShowPlaceholder(editor) {
|
|
40
|
-
const [canShowPlaceholder, setCanShowPlaceholder] = react.useState(
|
|
47
|
+
const [canShowPlaceholder, setCanShowPlaceholder] = react.useState(() => canShowPlaceholderFromCurrentEditorState(editor));
|
|
41
48
|
useLayoutEffect(() => {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
return editor.registerUpdateListener(({
|
|
45
|
-
editorState
|
|
46
|
-
}) => {
|
|
47
|
-
const isComposing = editor.isComposing();
|
|
48
|
-
currentCanShowPlaceholder = editorState.read(text.$canShowPlaceholderCurry(isComposing));
|
|
49
|
+
function resetCanShowPlaceholder() {
|
|
50
|
+
const currentCanShowPlaceholder = canShowPlaceholderFromCurrentEditorState(editor);
|
|
49
51
|
setCanShowPlaceholder(currentCanShowPlaceholder);
|
|
50
|
-
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
resetCanShowPlaceholder();
|
|
55
|
+
return utils.mergeRegister(editor.registerUpdateListener(() => {
|
|
56
|
+
resetCanShowPlaceholder();
|
|
57
|
+
}), editor.registerReadOnlyListener(() => {
|
|
58
|
+
resetCanShowPlaceholder();
|
|
59
|
+
}));
|
|
51
60
|
}, [editor]);
|
|
52
61
|
return canShowPlaceholder;
|
|
53
62
|
}
|
|
@@ -4,6 +4,5 @@
|
|
|
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
|
-
function
|
|
9
|
-
exports.useLexical=function(a){let b=f.useMemo(()=>d.createEditor(a),[]),[c,e]=n(b);return[b,c,e]}
|
|
7
|
+
'use strict';var c=require("lexical"),f=require("react"),g=require("@lexical/text"),h=require("@lexical/utils"),k="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?f.useLayoutEffect:f.useEffect;function l(a){return a.getEditorState().read(g.$canShowPlaceholderCurry(a.isComposing(),a.isReadOnly()))}
|
|
8
|
+
function m(a){let [b,d]=f.useState(()=>l(a));k(()=>{function e(){let n=l(a);d(n)}e();return h.mergeRegister(a.registerUpdateListener(()=>{e()}),a.registerReadOnlyListener(()=>{e()}))},[a]);return b}function p(a){let b=m(a);return[f.useCallback(d=>{a.setRootElement(d)},[a]),b]}exports.useLexical=function(a){let b=f.useMemo(()=>c.createEditor(a),[]),[d,e]=p(b);return[b,d,e]}
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
'use strict';
|
|
8
8
|
|
|
9
9
|
var text = require('@lexical/text');
|
|
10
|
+
var utils = require('@lexical/utils');
|
|
10
11
|
var react = require('react');
|
|
11
12
|
|
|
12
13
|
/**
|
|
@@ -35,18 +36,26 @@ var useLayoutEffect = useLayoutEffectImpl;
|
|
|
35
36
|
* LICENSE file in the root directory of this source tree.
|
|
36
37
|
*
|
|
37
38
|
*/
|
|
39
|
+
|
|
40
|
+
function canShowPlaceholderFromCurrentEditorState(editor) {
|
|
41
|
+
const currentCanShowPlaceholder = editor.getEditorState().read(text.$canShowPlaceholderCurry(editor.isComposing(), editor.isReadOnly()));
|
|
42
|
+
return currentCanShowPlaceholder;
|
|
43
|
+
}
|
|
44
|
+
|
|
38
45
|
function useCanShowPlaceholder(editor) {
|
|
39
|
-
const [canShowPlaceholder, setCanShowPlaceholder] = react.useState(
|
|
46
|
+
const [canShowPlaceholder, setCanShowPlaceholder] = react.useState(() => canShowPlaceholderFromCurrentEditorState(editor));
|
|
40
47
|
useLayoutEffect(() => {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
return editor.registerUpdateListener(({
|
|
44
|
-
editorState
|
|
45
|
-
}) => {
|
|
46
|
-
const isComposing = editor.isComposing();
|
|
47
|
-
currentCanShowPlaceholder = editorState.read(text.$canShowPlaceholderCurry(isComposing));
|
|
48
|
+
function resetCanShowPlaceholder() {
|
|
49
|
+
const currentCanShowPlaceholder = canShowPlaceholderFromCurrentEditorState(editor);
|
|
48
50
|
setCanShowPlaceholder(currentCanShowPlaceholder);
|
|
49
|
-
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
resetCanShowPlaceholder();
|
|
54
|
+
return utils.mergeRegister(editor.registerUpdateListener(() => {
|
|
55
|
+
resetCanShowPlaceholder();
|
|
56
|
+
}), editor.registerReadOnlyListener(() => {
|
|
57
|
+
resetCanShowPlaceholder();
|
|
58
|
+
}));
|
|
50
59
|
}, [editor]);
|
|
51
60
|
return canShowPlaceholder;
|
|
52
61
|
}
|
|
@@ -4,5 +4,5 @@
|
|
|
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 b=require("@lexical/text"),
|
|
8
|
-
function
|
|
7
|
+
'use strict';var b=require("@lexical/text"),d=require("@lexical/utils"),e=require("react"),f="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?e.useLayoutEffect:e.useEffect;function g(a){return a.getEditorState().read(b.$canShowPlaceholderCurry(a.isComposing(),a.isReadOnly()))}
|
|
8
|
+
function h(a){let [k,l]=e.useState(()=>g(a));f(()=>{function c(){let m=g(a);l(m)}c();return d.mergeRegister(a.registerUpdateListener(()=>{c()}),a.registerReadOnlyListener(()=>{c()}))},[a]);return k}exports.useLexicalCanShowPlaceholder=function(a){return h(a)}
|
|
@@ -8,6 +8,6 @@
|
|
|
8
8
|
function C(a){let d=a.getChildren(),f=d.length;for(let e=0;e<f;e++)a.insertBefore(d[e]);a.remove();return 0<f?d[f-1]:null}
|
|
9
9
|
function D(a){let d=a.getPreviousSibling();if(k.$isOverflowNode(d)){var f=a.getFirstChild(),e=d.getChildren(),m=e.length;if(null===f)a.append(...e);else for(var c=0;c<m;c++)f.insertBefore(e[c]);c=x.$getSelection();if(x.$isRangeSelection(c)){f=c.anchor;e=f.getNode();c=c.focus;let g=f.getNode();e.is(d)?f.set(a.getKey(),f.offset,"element"):e.is(a)&&f.set(a.getKey(),m+f.offset,"element");g.is(d)?c.set(a.getKey(),c.offset,"element"):g.is(a)&&c.set(a.getKey(),m+c.offset,"element")}d.remove()}}
|
|
10
10
|
exports.mergePrevious=D;
|
|
11
|
-
exports.useCharacterLimit=function(a,d,f=Object.freeze({})){let {strlen:e=c=>c.length,remainingCharacters:m=()=>{}}=f;y.useEffect(()=>{if(!a.hasNodes([k.OverflowNode]))throw Error("Minified Lexical error #57;
|
|
12
|
-
{var r=a.isComposing();n=0<n.size;if(!r&&n){r=e(c);n=r>d||null!==g&&g>d;m(d-r);if(null===g||n){let p=z(c,d,e);a.update(()=>{let B=w.$dfs(),E=B.length,t=0;for(let v=0;v<E;v+=1){var {node:b}=B[v];if(k.$isOverflowNode(b)){var l=t;if(t+b.getTextContentSize()<=p){var h=b.getParent();l=b.getPreviousSibling();var u=b.getNextSibling();C(b);b=x.$getSelection();!x.$isRangeSelection(b)||b.anchor.getNode().isAttached()&&b.focus.getNode().isAttached()||(x.$isTextNode(l)?
|
|
13
|
-
null!==h&&h.select())}else l<p&&(h=b.getFirstDescendant(),u=null!==h?h.getTextContentSize():0,l+=u,h=x.$isTextNode(h)&&h.isSimpleText(),l=l<=p,(h||l)&&C(b))}else x.$isLeafNode(b)&&(l=t,t+=b.getTextContentSize(),t>p&&!k.$isOverflowNode(b.getParent())&&(h=x.$getSelection(),l<p&&x.$isTextNode(b)&&b.isSimpleText()?([,b]=b.splitText(p-l),b=A(b)):b=A(b),null!==h&&x.$setSelection(h),D(b)))}},{tag:"history-merge"})}g=r}}))},[a,d,m,e])}
|
|
11
|
+
exports.useCharacterLimit=function(a,d,f=Object.freeze({})){let {strlen:e=c=>c.length,remainingCharacters:m=()=>{}}=f;y.useEffect(()=>{if(!a.hasNodes([k.OverflowNode]))throw Error("Minified Lexical error #57; visit https://lexical.dev/docs/error?code=57 for the full message or use the non-minified dev environment for full errors and additional helpful warnings.");},[a]);y.useEffect(()=>{let c=a.getEditorState().read(q.$rootTextContent),g=0;return w.mergeRegister(a.registerTextContentListener(n=>{c=
|
|
12
|
+
n}),a.registerUpdateListener(({dirtyLeaves:n})=>{var r=a.isComposing();n=0<n.size;if(!r&&n){r=e(c);n=r>d||null!==g&&g>d;m(d-r);if(null===g||n){let p=z(c,d,e);a.update(()=>{let B=w.$dfs(),E=B.length,t=0;for(let v=0;v<E;v+=1){var {node:b}=B[v];if(k.$isOverflowNode(b)){var l=t;if(t+b.getTextContentSize()<=p){var h=b.getParent();l=b.getPreviousSibling();var u=b.getNextSibling();C(b);b=x.$getSelection();!x.$isRangeSelection(b)||b.anchor.getNode().isAttached()&&b.focus.getNode().isAttached()||(x.$isTextNode(l)?
|
|
13
|
+
l.select():x.$isTextNode(u)?u.select():null!==h&&h.select())}else l<p&&(h=b.getFirstDescendant(),u=null!==h?h.getTextContentSize():0,l+=u,h=x.$isTextNode(h)&&h.isSimpleText(),l=l<=p,(h||l)&&C(b))}else x.$isLeafNode(b)&&(l=t,t+=b.getTextContentSize(),t>p&&!k.$isOverflowNode(b.getParent())&&(h=x.$getSelection(),l<p&&x.$isTextNode(b)&&b.isSimpleText()?([,b]=b.splitText(p-l),b=A(b)):b=A(b),null!==h&&x.$setSelection(h),D(b)))}},{tag:"history-merge"})}g=r}}))},[a,d,m,e])}
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
var react = require('react');
|
|
10
10
|
var text = require('@lexical/text');
|
|
11
|
+
var utils = require('@lexical/utils');
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
14
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
@@ -35,18 +36,26 @@ var useLayoutEffect = useLayoutEffectImpl;
|
|
|
35
36
|
* LICENSE file in the root directory of this source tree.
|
|
36
37
|
*
|
|
37
38
|
*/
|
|
39
|
+
|
|
40
|
+
function canShowPlaceholderFromCurrentEditorState(editor) {
|
|
41
|
+
const currentCanShowPlaceholder = editor.getEditorState().read(text.$canShowPlaceholderCurry(editor.isComposing(), editor.isReadOnly()));
|
|
42
|
+
return currentCanShowPlaceholder;
|
|
43
|
+
}
|
|
44
|
+
|
|
38
45
|
function useCanShowPlaceholder(editor) {
|
|
39
|
-
const [canShowPlaceholder, setCanShowPlaceholder] = react.useState(
|
|
46
|
+
const [canShowPlaceholder, setCanShowPlaceholder] = react.useState(() => canShowPlaceholderFromCurrentEditorState(editor));
|
|
40
47
|
useLayoutEffect(() => {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
return editor.registerUpdateListener(({
|
|
44
|
-
editorState
|
|
45
|
-
}) => {
|
|
46
|
-
const isComposing = editor.isComposing();
|
|
47
|
-
currentCanShowPlaceholder = editorState.read(text.$canShowPlaceholderCurry(isComposing));
|
|
48
|
+
function resetCanShowPlaceholder() {
|
|
49
|
+
const currentCanShowPlaceholder = canShowPlaceholderFromCurrentEditorState(editor);
|
|
48
50
|
setCanShowPlaceholder(currentCanShowPlaceholder);
|
|
49
|
-
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
resetCanShowPlaceholder();
|
|
54
|
+
return utils.mergeRegister(editor.registerUpdateListener(() => {
|
|
55
|
+
resetCanShowPlaceholder();
|
|
56
|
+
}), editor.registerReadOnlyListener(() => {
|
|
57
|
+
resetCanShowPlaceholder();
|
|
58
|
+
}));
|
|
50
59
|
}, [editor]);
|
|
51
60
|
return canShowPlaceholder;
|
|
52
61
|
}
|
|
@@ -4,5 +4,5 @@
|
|
|
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 b=require("react"),
|
|
8
|
-
function
|
|
7
|
+
'use strict';var b=require("react"),f=require("@lexical/text"),g=require("@lexical/utils"),h="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?b.useLayoutEffect:b.useEffect;function k(a){return a.getEditorState().read(f.$canShowPlaceholderCurry(a.isComposing(),a.isReadOnly()))}
|
|
8
|
+
function l(a){let [c,d]=b.useState(()=>k(a));h(()=>{function e(){let m=k(a);d(m)}e();return g.mergeRegister(a.registerUpdateListener(()=>{e()}),a.registerReadOnlyListener(()=>{e()}))},[a]);return c}exports.useLexicalEditor=function(a){let c=l(a);return[b.useCallback(d=>{a.setRootElement(d)},[a]),c]}
|
|
@@ -5,4 +5,8 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
|
-
|
|
8
|
+
declare type Props = {
|
|
9
|
+
defaultSelection?: 'rootStart' | 'rootEnd';
|
|
10
|
+
};
|
|
11
|
+
export declare function AutoFocusPlugin({ defaultSelection }: Props): null;
|
|
12
|
+
export {};
|
|
@@ -16,7 +16,9 @@ var react = require('react');
|
|
|
16
16
|
* LICENSE file in the root directory of this source tree.
|
|
17
17
|
*
|
|
18
18
|
*/
|
|
19
|
-
function AutoFocusPlugin(
|
|
19
|
+
function AutoFocusPlugin({
|
|
20
|
+
defaultSelection
|
|
21
|
+
}) {
|
|
20
22
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
21
23
|
react.useEffect(() => {
|
|
22
24
|
editor.focus(() => {
|
|
@@ -27,14 +29,16 @@ function AutoFocusPlugin() {
|
|
|
27
29
|
const activeElement = document.activeElement;
|
|
28
30
|
const rootElement = editor.getRootElement();
|
|
29
31
|
|
|
30
|
-
if (rootElement !== null || activeElement === null
|
|
32
|
+
if (!rootElement.contains(activeElement) || rootElement !== null || activeElement === null) {
|
|
31
33
|
// Note: preventScroll won't work in Webkit.
|
|
32
34
|
rootElement.focus({
|
|
33
35
|
preventScroll: true
|
|
34
36
|
});
|
|
35
37
|
}
|
|
38
|
+
}, {
|
|
39
|
+
defaultSelection
|
|
36
40
|
});
|
|
37
|
-
}, [editor]);
|
|
41
|
+
}, [defaultSelection, editor]);
|
|
38
42
|
return null;
|
|
39
43
|
}
|
|
40
44
|
|
|
@@ -4,4 +4,4 @@
|
|
|
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
|
|
7
|
+
'use strict';var e=require("@lexical/react/LexicalComposerContext"),f=require("react");exports.AutoFocusPlugin=function({defaultSelection:c}){let [a]=e.useLexicalComposerContext();f.useEffect(()=>{a.focus(()=>{let d=document.activeElement,b=a.getRootElement();b.contains(d)&&null===b&&null!==d||b.focus({preventScroll:!0})},{defaultSelection:c})},[c,a]);return null}
|
|
@@ -16,5 +16,5 @@ export declare type LinkMatcher = (text: string) => LinkMatcherResult | null;
|
|
|
16
16
|
export declare function AutoLinkPlugin({ matchers, onChange, }: {
|
|
17
17
|
matchers: Array<LinkMatcher>;
|
|
18
18
|
onChange?: ChangeHandler;
|
|
19
|
-
}): JSX.Element;
|
|
19
|
+
}): JSX.Element | null;
|
|
20
20
|
export {};
|
|
@@ -7,6 +7,6 @@
|
|
|
7
7
|
'use strict';var h=require("@lexical/link"),l=require("@lexical/react/LexicalComposerContext"),p=require("@lexical/utils"),v=require("lexical"),w=require("react");function x(a,c){for(let b=0;b<c.length;b++){let e=c[b](a);if(e)return e}return null}function y(a){a=a.getPreviousSibling();v.$isElementNode(a)&&(a=a.getLastDescendant());return null===a||v.$isLineBreakNode(a)||v.$isTextNode(a)&&a.getTextContent().endsWith(" ")}
|
|
8
8
|
function A(a){a=a.getNextSibling();v.$isElementNode(a)&&(a=a.getFirstDescendant());return null===a||v.$isLineBreakNode(a)||v.$isTextNode(a)&&a.getTextContent().startsWith(" ")}
|
|
9
9
|
function B(a,c,b){var e=a.getChildren();let d=e.length;for(let f=0;f<d;f++){let g=e[f];if(!v.$isTextNode(g)||!g.isSimpleText()){C(a);b(null,a.getURL());return}}e=a.getTextContent();c=x(e,c);null===c||c.text!==e?(C(a),b(null,a.getURL())):y(a)&&A(a)?(e=a.getURL(),null!==c&&e!==c.url&&(a.setURL(c.url),b(c.url,e))):(C(a),b(null,a.getURL()))}function C(a){let c=a.getChildren();var b=c.length;for(--b;0<=b;b--)a.insertAfter(c[b]);a.remove();return c.map(e=>e.getLatest())}
|
|
10
|
-
function D(a,c,b){w.useEffect(()=>{if(!a.hasNodes([h.AutoLinkNode]))throw Error("Minified Lexical error #7;
|
|
11
|
-
g;){var m=g.index,n=z+m;let q=g.length;var r=void 0;r=0<n?" "===f[n-1]:y(d);n=n+q<E?" "===f[n+q]:A(d);if(r&&n){var k=void 0;0===m?[k,t]=t.splitText(q):[,k,t]=t.splitText(m,m+q);r=h.$createAutoLinkNode(g.url);r.append(v.$createTextNode(g.text));k.replace(r);b&&b(g.url,null)}m+=q;u=u.substring(m);z+=m}}k=d.getPreviousSibling();g=d.getNextSibling();d=d.getTextContent();h.$isAutoLinkNode(k)&&!d.startsWith(" ")&&(C(k),k=k.getURL(),b&&b(null,k));h.$isAutoLinkNode(g)
|
|
12
|
-
b&&b(null,d))}}),a.registerNodeTransform(h.AutoLinkNode,d=>{B(d,c,e)}))},[a,c,b])}exports.AutoLinkPlugin=function({matchers:a,onChange:c}){let [b]=l.useLexicalComposerContext();D(b,a,c);return null}
|
|
10
|
+
function D(a,c,b){w.useEffect(()=>{if(!a.hasNodes([h.AutoLinkNode]))throw Error("Minified Lexical error #7; visit https://lexical.dev/docs/error?code=7 for the full message or use the non-minified dev environment for full errors and additional helpful warnings.");let e=(d,f)=>{b&&b(d,f)};return p.mergeRegister(a.registerNodeTransform(v.TextNode,d=>{var f=d.getParentOrThrow();if(h.$isAutoLinkNode(f))B(f,c,e);else if(!h.$isLinkNode(f)){if(d.isSimpleText()){f=d.getTextContent();let E=f.length,u=f,z=
|
|
11
|
+
0,t=d;for(var g;(g=x(u,c))&&null!==g;){var m=g.index,n=z+m;let q=g.length;var r=void 0;r=0<n?" "===f[n-1]:y(d);n=n+q<E?" "===f[n+q]:A(d);if(r&&n){var k=void 0;0===m?[k,t]=t.splitText(q):[,k,t]=t.splitText(m,m+q);r=h.$createAutoLinkNode(g.url);r.append(v.$createTextNode(g.text));k.replace(r);b&&b(g.url,null)}m+=q;u=u.substring(m);z+=m}}k=d.getPreviousSibling();g=d.getNextSibling();d=d.getTextContent();h.$isAutoLinkNode(k)&&!d.startsWith(" ")&&(C(k),k=k.getURL(),b&&b(null,k));h.$isAutoLinkNode(g)&&
|
|
12
|
+
!d.endsWith(" ")&&(C(g),d=g.getURL(),b&&b(null,d))}}),a.registerNodeTransform(h.AutoLinkNode,d=>{B(d,c,e)}))},[a,c,b])}exports.AutoLinkPlugin=function({matchers:a,onChange:c}){let [b]=l.useLexicalComposerContext();D(b,a,c);return null}
|
|
@@ -6,8 +6,9 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
import type { ElementFormatType, NodeKey } from 'lexical';
|
|
9
|
+
import { ReactNode } from 'react';
|
|
9
10
|
declare type Props = Readonly<{
|
|
10
|
-
children:
|
|
11
|
+
children: ReactNode;
|
|
11
12
|
format: ElementFormatType | null | undefined;
|
|
12
13
|
nodeKey: NodeKey;
|
|
13
14
|
className: Readonly<{
|
|
@@ -28,10 +28,9 @@ function BlockWithAlignableContents({
|
|
|
28
28
|
}) {
|
|
29
29
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
30
30
|
const [isSelected, setSelected, clearSelection] = useLexicalNodeSelection.useLexicalNodeSelection(nodeKey);
|
|
31
|
-
const ref = React.useRef();
|
|
32
|
-
const onDelete = React.useCallback(
|
|
31
|
+
const ref = React.useRef(null);
|
|
32
|
+
const onDelete = React.useCallback(event => {
|
|
33
33
|
if (isSelected && lexical.$isNodeSelection(lexical.$getSelection())) {
|
|
34
|
-
const event = payload;
|
|
35
34
|
event.preventDefault();
|
|
36
35
|
editor.update(() => {
|
|
37
36
|
const node = lexical.$getNodeByKey(nodeKey);
|
|
@@ -93,7 +92,7 @@ function BlockWithAlignableContents({
|
|
|
93
92
|
className: [className.base, isSelected ? className.focus : null].filter(Boolean).join(' '),
|
|
94
93
|
ref: ref,
|
|
95
94
|
style: {
|
|
96
|
-
textAlign: format ? format :
|
|
95
|
+
textAlign: format ? format : undefined
|
|
97
96
|
}
|
|
98
97
|
}, children);
|
|
99
98
|
}
|
|
@@ -5,6 +5,6 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
'use strict';var a=require("@lexical/react/LexicalComposerContext"),h=require("@lexical/react/LexicalDecoratorBlockNode"),m=require("@lexical/react/useLexicalNodeSelection"),n=require("@lexical/utils"),u=require("lexical"),v=require("react");
|
|
8
|
-
exports.BlockWithAlignableContents=function({children:w,format:p,nodeKey:g,className:q}){let [d]=a.useLexicalComposerContext(),[e,k,r]=m.useLexicalNodeSelection(g),t=v.useRef(),l=v.useCallback(b=>{e&&u.$isNodeSelection(u.$getSelection())&&(b.preventDefault(),d.update(()=>{const c=u.$getNodeByKey(g);u.$isDecoratorNode(c)&&c.isTopLevel()&&c.remove();k(!1)}));return!1},[d,e,g,k]);v.useEffect(()=>n.mergeRegister(d.registerCommand(u.FORMAT_ELEMENT_COMMAND,b=>{if(e){var c=u.$getSelection();if(u.$isNodeSelection(c)){var f=
|
|
8
|
+
exports.BlockWithAlignableContents=function({children:w,format:p,nodeKey:g,className:q}){let [d]=a.useLexicalComposerContext(),[e,k,r]=m.useLexicalNodeSelection(g),t=v.useRef(null),l=v.useCallback(b=>{e&&u.$isNodeSelection(u.$getSelection())&&(b.preventDefault(),d.update(()=>{const c=u.$getNodeByKey(g);u.$isDecoratorNode(c)&&c.isTopLevel()&&c.remove();k(!1)}));return!1},[d,e,g,k]);v.useEffect(()=>n.mergeRegister(d.registerCommand(u.FORMAT_ELEMENT_COMMAND,b=>{if(e){var c=u.$getSelection();if(u.$isNodeSelection(c)){var f=
|
|
9
9
|
u.$getNodeByKey(g);h.$isDecoratorBlockNode(f)&&f.setFormat(b)}else if(u.$isRangeSelection(c)){c=c.getNodes();for(f of c)h.$isDecoratorBlockNode(f)?f.setFormat(b):n.$getNearestBlockElementAncestorOrThrow(f).setFormat(b)}return!0}return!1},u.COMMAND_PRIORITY_LOW),d.registerCommand(u.CLICK_COMMAND,b=>{b.preventDefault();return b.target===t.current?(b.shiftKey||r(),k(!e),!0):!1},u.COMMAND_PRIORITY_LOW),d.registerCommand(u.KEY_DELETE_COMMAND,l,u.COMMAND_PRIORITY_LOW),d.registerCommand(u.KEY_BACKSPACE_COMMAND,
|
|
10
|
-
l,u.COMMAND_PRIORITY_LOW)),[r,d,e,g,l,k]);return v.createElement("div",{className:[q.base,e?q.focus:null].filter(Boolean).join(" "),ref:t,style:{textAlign:p?p:
|
|
10
|
+
l,u.COMMAND_PRIORITY_LOW)),[r,d,e,g,l,k]);return v.createElement("div",{className:[q.base,e?q.focus:null].filter(Boolean).join(" "),ref:t,style:{textAlign:p?p:void 0}},w)}
|
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
'use strict';var m=require("@lexical/react/LexicalComposerContext"),u=require("react"),v=require("@lexical/overflow"),z=require("@lexical/text"),A=require("@lexical/utils"),C=require("lexical");
|
|
8
|
-
function D(b,c,n=Object.freeze({})){let {strlen:g=d=>d.length,remainingCharacters:q=()=>{}}=n;u.useEffect(()=>{if(!b.hasNodes([v.OverflowNode]))throw Error("Minified Lexical error #57;
|
|
9
|
-
b.isComposing();p=0<p.size;if(!w&&p){w=g(d);p=w>c||null!==e&&e>c;q(c-w);if(null===e||p){let r=F(d,c,g);b.update(()=>{let B=A.$dfs(),J=B.length,x=0;for(let y=0;y<J;y+=1){var {node:a}=B[y];if(v.$isOverflowNode(a)){var f=x;if(x+a.getTextContentSize()<=r){var h=a.getParent();f=a.getPreviousSibling();var k=a.getNextSibling();G(a);a=C.$getSelection();!C.$isRangeSelection(a)||a.anchor.getNode().isAttached()&&a.focus.getNode().isAttached()||(C.$isTextNode(f)?f.select():C.$isTextNode(k)?k.select():
|
|
10
|
-
h&&h.select())}else f<r&&(h=a.getFirstDescendant(),k=null!==h?h.getTextContentSize():0,f+=k,h=C.$isTextNode(h)&&h.isSimpleText(),f=f<=r,(h||f)&&G(a))}else if(C.$isLeafNode(a)&&(f=x,x+=a.getTextContentSize(),x>r&&!v.$isOverflowNode(a.getParent())&&(h=C.$getSelection(),f<r&&C.$isTextNode(a)&&a.isSimpleText()?([,a]=a.splitText(r-f),a=H(a)):a=H(a),null!==h&&C.$setSelection(h),f=a.getPreviousSibling(),v.$isOverflowNode(f)))){k=a.getFirstChild();var t=f.getChildren();h=t.length;if(null===k)a.append(...t);
|
|
8
|
+
function D(b,c,n=Object.freeze({})){let {strlen:g=d=>d.length,remainingCharacters:q=()=>{}}=n;u.useEffect(()=>{if(!b.hasNodes([v.OverflowNode]))throw Error("Minified Lexical error #57; visit https://lexical.dev/docs/error?code=57 for the full message or use the non-minified dev environment for full errors and additional helpful warnings.");},[b]);u.useEffect(()=>{let d=b.getEditorState().read(z.$rootTextContent),e=0;return A.mergeRegister(b.registerTextContentListener(p=>{d=p}),b.registerUpdateListener(({dirtyLeaves:p})=>
|
|
9
|
+
{var w=b.isComposing();p=0<p.size;if(!w&&p){w=g(d);p=w>c||null!==e&&e>c;q(c-w);if(null===e||p){let r=F(d,c,g);b.update(()=>{let B=A.$dfs(),J=B.length,x=0;for(let y=0;y<J;y+=1){var {node:a}=B[y];if(v.$isOverflowNode(a)){var f=x;if(x+a.getTextContentSize()<=r){var h=a.getParent();f=a.getPreviousSibling();var k=a.getNextSibling();G(a);a=C.$getSelection();!C.$isRangeSelection(a)||a.anchor.getNode().isAttached()&&a.focus.getNode().isAttached()||(C.$isTextNode(f)?f.select():C.$isTextNode(k)?k.select():
|
|
10
|
+
null!==h&&h.select())}else f<r&&(h=a.getFirstDescendant(),k=null!==h?h.getTextContentSize():0,f+=k,h=C.$isTextNode(h)&&h.isSimpleText(),f=f<=r,(h||f)&&G(a))}else if(C.$isLeafNode(a)&&(f=x,x+=a.getTextContentSize(),x>r&&!v.$isOverflowNode(a.getParent())&&(h=C.$getSelection(),f<r&&C.$isTextNode(a)&&a.isSimpleText()?([,a]=a.splitText(r-f),a=H(a)):a=H(a),null!==h&&C.$setSelection(h),f=a.getPreviousSibling(),v.$isOverflowNode(f)))){k=a.getFirstChild();var t=f.getChildren();h=t.length;if(null===k)a.append(...t);
|
|
11
11
|
else for(var l=0;l<h;l++)k.insertBefore(t[l]);l=C.$getSelection();if(C.$isRangeSelection(l)){k=l.anchor;t=k.getNode();l=l.focus;let E=k.getNode();t.is(f)?k.set(a.getKey(),k.offset,"element"):t.is(a)&&k.set(a.getKey(),h+k.offset,"element");E.is(f)?l.set(a.getKey(),l.offset,"element"):E.is(a)&&l.set(a.getKey(),h+l.offset,"element")}f.remove()}}},{tag:"history-merge"})}e=w}}))},[b,c,q,g])}
|
|
12
12
|
function F(b,c,n){var g=Intl.Segmenter;let q=0;var d=0;if("function"===typeof g){b=(new g).segment(b);for(var {segment:e}of b){d+=n(e);if(d>c)break;q+=e.length}}else for(e=Array.from(b),b=e.length,g=0;g<b;g++){let p=e[g];d+=n(p);if(d>c)break;q+=p.length}return q}function H(b){let c=v.$createOverflowNode();b.insertBefore(c);c.append(b);return c}function G(b){let c=b.getChildren(),n=c.length;for(let g=0;g<n;g++)b.insertBefore(c[g]);b.remove();return 0<n?c[n-1]:null}let I=null;
|
|
13
13
|
exports.CharacterLimitPlugin=function({charset:b="UTF-16"}){let [c]=m.useLexicalComposerContext(),[n,g]=u.useState(0),q=u.useMemo(()=>({remainingCharacters:g,strlen:d=>{if("UTF-8"===b){if(void 0===window.TextEncoder)var e=null;else null===I&&(I=new window.TextEncoder),e=I;null===e?(e=encodeURIComponent(d).match(/%[89ABab]/g),d=d.length+(e?e.length:0)):d=e.encode(d).length;return d}if("UTF-16"===b)return d.length;throw Error("Unrecognized charset");}}),[b]);D(c,5,q);return u.createElement("span",{className:`characters-limit ${0>
|
|
@@ -117,7 +117,7 @@ function handleCheckItemEvent(event, callback) {
|
|
|
117
117
|
|
|
118
118
|
const firstChild = target.firstChild;
|
|
119
119
|
|
|
120
|
-
if (firstChild != null && (firstChild.tagName === 'UL' || firstChild.tagName === 'OL')) {
|
|
120
|
+
if (firstChild != null && firstChild instanceof HTMLElement && (firstChild.tagName === 'UL' || firstChild.tagName === 'OL')) {
|
|
121
121
|
return;
|
|
122
122
|
}
|
|
123
123
|
|
|
@@ -137,15 +137,18 @@ function handleCheckItemEvent(event, callback) {
|
|
|
137
137
|
|
|
138
138
|
function handleClick(event) {
|
|
139
139
|
handleCheckItemEvent(event, () => {
|
|
140
|
-
const
|
|
140
|
+
const domNode = event.target;
|
|
141
|
+
const editor = findEditor(domNode);
|
|
141
142
|
|
|
142
143
|
if (editor != null && !editor.isReadOnly()) {
|
|
143
144
|
editor.update(() => {
|
|
144
|
-
|
|
145
|
+
if (event.target) {
|
|
146
|
+
const node = lexical.$getNearestNodeFromDOMNode(domNode);
|
|
145
147
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
148
|
+
if (list.$isListItemNode(node)) {
|
|
149
|
+
domNode.focus();
|
|
150
|
+
node.toggleChecked();
|
|
151
|
+
}
|
|
149
152
|
}
|
|
150
153
|
});
|
|
151
154
|
}
|
|
@@ -163,7 +166,9 @@ function findEditor(target) {
|
|
|
163
166
|
let node = target;
|
|
164
167
|
|
|
165
168
|
while (node) {
|
|
169
|
+
// @ts-ignore internal field
|
|
166
170
|
if (node.__lexicalEditor) {
|
|
171
|
+
// @ts-ignore internal field
|
|
167
172
|
return node.__lexicalEditor;
|
|
168
173
|
}
|
|
169
174
|
|
|
@@ -5,10 +5,10 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
'use strict';var e=require("@lexical/list"),g=require("@lexical/react/LexicalComposerContext"),k=require("@lexical/utils"),l=require("lexical"),m=require("react");let n=0;function p(){0===n++&&(document.addEventListener("click",q),document.addEventListener("pointerdown",r));return()=>{0===--n&&(document.removeEventListener("click",q),document.removeEventListener("pointerdown",r))}}
|
|
8
|
-
function t(a,
|
|
9
|
-
function r(a){t(a,()=>{a.preventDefault()})}function u(a){for(;a;){if(a.__lexicalEditor)return a.__lexicalEditor;a=a.parentNode}return null}function v(){let a=document.activeElement;return null!=a&&"LI"===a.tagName&&null!=a.parentNode&&"check"===a.parentNode.__lexicalListType?a:null}
|
|
10
|
-
function w(a,
|
|
11
|
-
function x(a,
|
|
12
|
-
exports.CheckListPlugin=function(){let [a]=g.useLexicalComposerContext();m.useEffect(()=>k.mergeRegister(a.registerCommand(e.INSERT_CHECK_LIST_COMMAND,()=>{e.insertList(a,"check");return!0},l.COMMAND_PRIORITY_LOW),a.registerCommand(l.KEY_ARROW_DOWN_COMMAND,
|
|
13
|
-
a.registerCommand(l.KEY_SPACE_COMMAND,
|
|
14
|
-
if(e.$isListItemNode(f)&&(b||f.getFirstDescendant()===
|
|
8
|
+
function t(a,d){let b=a.target;if(b instanceof HTMLElement){var c=b.firstChild;null!=c&&c instanceof HTMLElement&&("UL"===c.tagName||"OL"===c.tagName)||(c=b.parentNode)&&"check"===c.__lexicalListType&&(a=a.pageX,c=b.getBoundingClientRect(),("rtl"===b.dir?a<c.right&&a>c.right-20:a>c.left&&a<c.left+20)&&d())}}
|
|
9
|
+
function q(a){t(a,()=>{let d=a.target,b=u(d);null==b||b.isReadOnly()||b.update(()=>{if(a.target){let c=l.$getNearestNodeFromDOMNode(d);e.$isListItemNode(c)&&(d.focus(),c.toggleChecked())}})})}function r(a){t(a,()=>{a.preventDefault()})}function u(a){for(;a;){if(a.__lexicalEditor)return a.__lexicalEditor;a=a.parentNode}return null}function v(){let a=document.activeElement;return null!=a&&"LI"===a.tagName&&null!=a.parentNode&&"check"===a.parentNode.__lexicalListType?a:null}
|
|
10
|
+
function w(a,d){let b=d?a.getPreviousSibling():a.getNextSibling();for(;null==b&&e.$isListItemNode(a);)a=a.getParentOrThrow().getParent(),null!=a&&(b=d?a.getPreviousSibling():a.getNextSibling());for(;e.$isListItemNode(b);){a=d?b.getLastChild():b.getFirstChild();if(!e.$isListNode(a))return b;b=d?a.getLastChild():a.getFirstChild()}return null}
|
|
11
|
+
function x(a,d,b){let c=v();null!=c&&d.update(()=>{var f=l.$getNearestNodeFromDOMNode(c);if(e.$isListItemNode(f)&&(f=w(f,b),null!=f)){f.selectStart();let h=d.getElementByKey(f.__key);null!=h&&(a.preventDefault(),setTimeout(()=>{h.focus()},0))}});return!1}
|
|
12
|
+
exports.CheckListPlugin=function(){let [a]=g.useLexicalComposerContext();m.useEffect(()=>k.mergeRegister(a.registerCommand(e.INSERT_CHECK_LIST_COMMAND,()=>{e.insertList(a,"check");return!0},l.COMMAND_PRIORITY_LOW),a.registerCommand(l.KEY_ARROW_DOWN_COMMAND,d=>x(d,a,!1),l.COMMAND_PRIORITY_LOW),a.registerCommand(l.KEY_ARROW_UP_COMMAND,d=>x(d,a,!0),l.COMMAND_PRIORITY_LOW),a.registerCommand(l.KEY_ESCAPE_COMMAND,()=>{if(null!=v()){let d=a.getRootElement();null!=d&&d.focus();return!0}return!1},l.COMMAND_PRIORITY_LOW),
|
|
13
|
+
a.registerCommand(l.KEY_SPACE_COMMAND,d=>{let b=v();return null==b||a.isReadOnly()?!1:(a.update(()=>{let c=l.$getNearestNodeFromDOMNode(b);e.$isListItemNode(c)&&(d.preventDefault(),c.toggleChecked())}),!0)},l.COMMAND_PRIORITY_LOW),a.registerCommand(l.KEY_ARROW_LEFT_COMMAND,d=>a.getEditorState().read(()=>{var b=l.$getSelection();if(l.$isRangeSelection(b)&&b.isCollapsed()){var {anchor:c}=b;if((b="element"===c.type)||0===c.offset){c=c.getNode();let f=k.$findMatchingParent(c,h=>l.$isElementNode(h)&&!h.isInline());
|
|
14
|
+
if(e.$isListItemNode(f)&&(b||f.getFirstDescendant()===c)&&(b=a.getElementByKey(f.__key),null!=b&&document.activeElement!==b))return b.focus(),d.preventDefault(),!0}}return!1}),l.COMMAND_PRIORITY_LOW),p()));return null}
|
|
@@ -102,6 +102,7 @@ function useYjsCollaboration(editor, id, provider, docMap, name, color, shouldBo
|
|
|
102
102
|
provider.off('reload', onProviderDocReload);
|
|
103
103
|
awareness.off('update', onAwarenessUpdate);
|
|
104
104
|
root.getSharedType().unobserveDeep(onYjsTreeChanges);
|
|
105
|
+
docMap.delete(id);
|
|
105
106
|
removeListener();
|
|
106
107
|
};
|
|
107
108
|
}, [binding, color, connect, disconnect, docMap, editor, id, name, provider, shouldBootstrap]);
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
'use strict';var e=require("@lexical/react/LexicalComposerContext"),f=require("react"),h=require("@lexical/utils"),x=require("@lexical/yjs"),F=require("lexical"),G=require("react-dom");
|
|
8
8
|
function H(b,c,a,d,l,p,q){let n=f.useRef(!1),[r,v]=f.useState(d.get(c)),g=f.useMemo(()=>x.createBinding(b,a,c,r,d),[b,a,c,d,r]),t=f.useCallback(()=>{a.connect()},[a]),u=f.useCallback(()=>{try{a.disconnect()}catch(m){}},[a]);f.useEffect(()=>{let {root:m}=g,{awareness:y}=a,z=({status:k})=>{b.dispatchCommand(x.CONNECTED_COMMAND,"connected"===k)},A=k=>{q&&k&&m.isEmpty()&&0===m._xmlText._length&&!1===n.current&&I(b);n.current=!1},B=()=>{x.syncCursorPositions(g,a)},C=(k,w)=>{w.origin!==g&&x.syncYjsChangesToLexical(g,
|
|
9
9
|
a,k)};x.initLocalState(a,l,p,document.activeElement===b.getRootElement());let D=k=>{J(b,g);v(k);d.set(c,k);n.current=!0};a.on("reload",D);a.on("status",z);a.on("sync",A);y.on("update",B);m.getSharedType().observeDeep(C);let R=b.registerUpdateListener(({prevEditorState:k,editorState:w,dirtyLeaves:O,dirtyElements:P,normalizedNodes:Q,tags:E})=>{!1===E.has("skip-collab")&&x.syncLexicalUpdateToYjs(g,a,k,w,P,O,Q,E)});t();return()=>{!1===n.current&&u();a.off("sync",A);a.off("status",z);a.off("reload",D);
|
|
10
|
-
y.off("update",B);m.getSharedType().unobserveDeep(C);R()}},[g,p,t,u,d,b,c,l,a,q]);let S=f.useMemo(()=>G.createPortal(f.createElement("div",{ref:m=>{g.cursorsContainer=m}}),document.body),[g]);f.useEffect(()=>b.registerCommand(x.TOGGLE_CONNECT_COMMAND,m=>{void 0!==t&&void 0!==u&&(m?(console.log("Collaboration connected!"),t()):(console.log("Collaboration disconnected!"),u()));return!0},F.COMMAND_PRIORITY_EDITOR),[t,u,b]);return[S,g]}
|
|
10
|
+
y.off("update",B);m.getSharedType().unobserveDeep(C);d.delete(c);R()}},[g,p,t,u,d,b,c,l,a,q]);let S=f.useMemo(()=>G.createPortal(f.createElement("div",{ref:m=>{g.cursorsContainer=m}}),document.body),[g]);f.useEffect(()=>b.registerCommand(x.TOGGLE_CONNECT_COMMAND,m=>{void 0!==t&&void 0!==u&&(m?(console.log("Collaboration connected!"),t()):(console.log("Collaboration disconnected!"),u()));return!0},F.COMMAND_PRIORITY_EDITOR),[t,u,b]);return[S,g]}
|
|
11
11
|
function K(b,c,a,d){f.useEffect(()=>h.mergeRegister(b.registerCommand(F.FOCUS_COMMAND,()=>{x.setLocalStateFocus(c,a,d,!0);return!0},F.COMMAND_PRIORITY_EDITOR),b.registerCommand(F.BLUR_COMMAND,()=>{x.setLocalStateFocus(c,a,d,!1);return!0},F.COMMAND_PRIORITY_EDITOR)),[d,b,a,c])}
|
|
12
12
|
function L(b,c){let a=f.useMemo(()=>x.createUndoManager(c,c.root.getSharedType()),[c]);f.useEffect(()=>h.mergeRegister(b.registerCommand(F.UNDO_COMMAND,()=>{a.undo();return!0},F.COMMAND_PRIORITY_EDITOR),b.registerCommand(F.REDO_COMMAND,()=>{a.redo();return!0},F.COMMAND_PRIORITY_EDITOR)));return f.useCallback(()=>{a.clear()},[a])}
|
|
13
13
|
function I(b){b.update(()=>{var c=F.$getRoot();if(null===c.getFirstChild()){let a=F.$createParagraphNode();c.append(a);c=document.activeElement;(null!==F.$getSelection()||null!==c&&c===b.getRootElement())&&a.select()}},{tag:"history-merge"})}
|
package/LexicalComposer.d.ts
CHANGED
|
@@ -5,15 +5,15 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
|
+
import type { Klass } from 'lexical';
|
|
8
9
|
import { EditorState, EditorThemeClasses, LexicalEditor, LexicalNode } from 'lexical';
|
|
9
|
-
import { Class } from 'utility-types';
|
|
10
10
|
export declare type InitialEditorStateType = null | string | EditorState | ((editor: LexicalEditor) => void);
|
|
11
11
|
declare type Props = {
|
|
12
12
|
children: JSX.Element | string | (JSX.Element | string)[];
|
|
13
13
|
initialConfig: Readonly<{
|
|
14
14
|
editor__DEPRECATED?: LexicalEditor | null;
|
|
15
15
|
namespace: string;
|
|
16
|
-
nodes?: ReadonlyArray<
|
|
16
|
+
nodes?: ReadonlyArray<Klass<LexicalNode>>;
|
|
17
17
|
onError: (error: Error, editor: LexicalEditor) => void;
|
|
18
18
|
readOnly?: boolean;
|
|
19
19
|
theme?: EditorThemeClasses;
|
|
@@ -4,4 +4,5 @@
|
|
|
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 c=require("react");let d=c.createContext(null);exports.LexicalComposerContext=d;exports.createLexicalComposerContext=function(a,e){let b=null;null!=a&&(b=a[1]);return{getTheme:function(){return null!=e?e:null!=b?b.getTheme():null}}};
|
|
7
|
+
'use strict';var c=require("react");let d=c.createContext(null);exports.LexicalComposerContext=d;exports.createLexicalComposerContext=function(a,e){let b=null;null!=a&&(b=a[1]);return{getTheme:function(){return null!=e?e:null!=b?b.getTheme():null}}};
|
|
8
|
+
exports.useLexicalComposerContext=function(){let a=c.useContext(d);if(null==a)throw Error("Minified Lexical error #8; visit https://lexical.dev/docs/error?code=8 for the full message or use the non-minified dev environment for full errors and additional helpful warnings.");return a}
|
|
@@ -79,16 +79,16 @@ function ContentEditable({
|
|
|
79
79
|
"aria-multiline": ariaMultiline,
|
|
80
80
|
"aria-owns": isReadOnly ? null : ariaOwneeID,
|
|
81
81
|
"aria-required": ariaRequired,
|
|
82
|
-
autoCapitalize: autoCapitalize !== undefined ? String(autoCapitalize) :
|
|
82
|
+
autoCapitalize: autoCapitalize !== undefined ? String(autoCapitalize) : undefined // @ts-ignore This is a valid attribute
|
|
83
83
|
,
|
|
84
84
|
autoComplete: autoComplete,
|
|
85
|
-
autoCorrect: autoCorrect !== undefined ? String(autoCorrect) :
|
|
85
|
+
autoCorrect: autoCorrect !== undefined ? String(autoCorrect) : undefined,
|
|
86
86
|
className: className,
|
|
87
87
|
contentEditable: !isReadOnly,
|
|
88
88
|
"data-testid": testid,
|
|
89
89
|
id: id,
|
|
90
90
|
ref: ref,
|
|
91
|
-
role: isReadOnly ?
|
|
91
|
+
role: isReadOnly ? undefined : role,
|
|
92
92
|
spellCheck: spellCheck,
|
|
93
93
|
style: style,
|
|
94
94
|
tabIndex: tabIndex
|
|
@@ -6,4 +6,4 @@
|
|
|
6
6
|
*/
|
|
7
7
|
'use strict';var b=require("@lexical/react/LexicalComposerContext"),k=require("react"),l="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?k.useLayoutEffect:k.useEffect;
|
|
8
8
|
exports.ContentEditable=function({ariaActiveDescendantID:m,ariaAutoComplete:n,ariaControls:p,ariaDescribedBy:q,ariaExpanded:r,ariaLabel:t,ariaLabelledBy:u,ariaMultiline:v,ariaOwneeID:w,ariaRequired:x,autoCapitalize:e,autoComplete:y,autoCorrect:f,className:z,id:A,role:g="textbox",spellCheck:B=!0,style:C,tabIndex:D,testid:E}){let [c]=b.useLexicalComposerContext(),[a,h]=k.useState(!0),F=k.useCallback(d=>{c.setRootElement(d)},[c]);l(()=>{h(c.isReadOnly());return c.registerReadOnlyListener(d=>{h(d)})},
|
|
9
|
-
[c]);return k.createElement("div",{"aria-activedescendant":a?null:m,"aria-autocomplete":a?null:n,"aria-controls":a?null:p,"aria-describedby":q,"aria-expanded":a?null:"combobox"===g?!!r:null,"aria-label":t,"aria-labelledby":u,"aria-multiline":v,"aria-owns":a?null:w,"aria-required":x,autoCapitalize:void 0!==e?String(e):
|
|
9
|
+
[c]);return k.createElement("div",{"aria-activedescendant":a?null:m,"aria-autocomplete":a?null:n,"aria-controls":a?null:p,"aria-describedby":q,"aria-expanded":a?null:"combobox"===g?!!r:null,"aria-label":t,"aria-labelledby":u,"aria-multiline":v,"aria-owns":a?null:w,"aria-required":x,autoCapitalize:void 0!==e?String(e):void 0,autoComplete:y,autoCorrect:void 0!==f?String(f):void 0,className:z,contentEditable:!a,"data-testid":E,id:A,ref:F,role:a?void 0:g,spellCheck:B,style:C,tabIndex:D})}
|
|
@@ -8,10 +8,10 @@
|
|
|
8
8
|
import type { ElementFormatType, LexicalNode, NodeKey, SerializedLexicalNode, Spread } from 'lexical';
|
|
9
9
|
import { DecoratorNode } from 'lexical';
|
|
10
10
|
export declare type SerializedDecoratorBlockNode = Spread<{
|
|
11
|
-
format: ElementFormatType
|
|
11
|
+
format: ElementFormatType;
|
|
12
12
|
}, SerializedLexicalNode>;
|
|
13
13
|
export declare class DecoratorBlockNode extends DecoratorNode<JSX.Element> {
|
|
14
|
-
__format: ElementFormatType
|
|
14
|
+
__format: ElementFormatType;
|
|
15
15
|
constructor(format?: ElementFormatType, key?: NodeKey);
|
|
16
16
|
exportJSON(): SerializedDecoratorBlockNode;
|
|
17
17
|
createDOM(): HTMLElement;
|
|
@@ -4,4 +4,4 @@
|
|
|
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 b=require("lexical");class c extends b.DecoratorNode{constructor(a,d){super(d);this.__format=a}exportJSON(){return{format:this.__format||"",type:"decorator-block",version:1}}createDOM(){return document.createElement("div")}updateDOM(){return!1}setFormat(a){this.getWritable().__format=a}}exports.$isDecoratorBlockNode=function(a){return a instanceof c};exports.DecoratorBlockNode=c
|
|
7
|
+
'use strict';var b=require("lexical");class c extends b.DecoratorNode{constructor(a,d){super(d);this.__format=a||""}exportJSON(){return{format:this.__format||"",type:"decorator-block",version:1}}createDOM(){return document.createElement("div")}updateDOM(){return!1}setFormat(a){this.getWritable().__format=a}}exports.$isDecoratorBlockNode=function(a){return a instanceof c};exports.DecoratorBlockNode=c
|
|
@@ -6,8 +6,9 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
import type { EditorThemeClasses, LexicalEditor } from 'lexical';
|
|
9
|
+
import { ReactNode } from 'react';
|
|
9
10
|
export declare function LexicalNestedComposer({ initialEditor, children, initialTheme, }: {
|
|
10
|
-
children:
|
|
11
|
+
children: ReactNode;
|
|
11
12
|
initialEditor: LexicalEditor;
|
|
12
13
|
initialTheme?: EditorThemeClasses;
|
|
13
14
|
}): JSX.Element;
|
|
@@ -5,5 +5,5 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
'use strict';var c=require("@lexical/react/LexicalCollaborationPlugin"),d=require("@lexical/react/LexicalComposerContext"),h=require("react");
|
|
8
|
-
exports.LexicalNestedComposer=function({initialEditor:a,children:k,initialTheme:l}){let e=h.useContext(d.LexicalComposerContext);if(null==e)throw Error("Minified Lexical error #9;
|
|
9
|
-
return[a,n]},[]);var {yjsDocMap:b}=c.useCollaborationContext();let q=void 0!==b.get("main");b=b.has(a.getKey());return h.createElement(d.LexicalComposerContext.Provider,{value:p},!q||b?k:null)}
|
|
8
|
+
exports.LexicalNestedComposer=function({initialEditor:a,children:k,initialTheme:l}){let e=h.useContext(d.LexicalComposerContext);if(null==e)throw Error("Minified Lexical error #9; visit https://lexical.dev/docs/error?code=9 for the full message or use the non-minified dev environment for full errors and additional helpful warnings.");let p=h.useMemo(()=>{const [f,m]=e,g=l||m.getTheme()||void 0,n=d.createLexicalComposerContext(e,g);void 0!==g&&(a._config.theme=g);a._parentEditor=f;a._nodes=f._nodes;
|
|
9
|
+
a._config.namespace=f._config.namespace;return[a,n]},[]);var {yjsDocMap:b}=c.useCollaborationContext();let q=void 0!==b.get("main");b=b.has(a.getKey());return h.createElement(d.LexicalComposerContext.Provider,{value:p},!q||b?k:null)}
|