@lexical/react 0.1.21 → 0.2.2
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_useLexicalList.dev.js +6 -7
- package/DEPRECATED_useLexicalList.prod.js +2 -2
- package/LexicalAutoLinkPlugin.d.ts +1 -1
- package/LexicalAutoScrollPlugin.d.ts +1 -1
- package/LexicalAutoScrollPlugin.js.flow +3 -1
- package/LexicalCharacterLimitPlugin.d.ts +1 -1
- package/LexicalClearEditorPlugin.d.ts +3 -1
- package/LexicalClearEditorPlugin.dev.js +1 -1
- package/LexicalClearEditorPlugin.prod.js +1 -1
- package/LexicalCollaborationPlugin.d.ts +1 -1
- package/LexicalCollaborationPlugin.dev.js +6 -7
- package/LexicalCollaborationPlugin.prod.js +9 -9
- package/LexicalComposer.d.ts +2 -2
- package/LexicalContentEditable.d.ts +3 -1
- package/LexicalHashtagPlugin.d.ts +1 -1
- package/LexicalHistoryPlugin.d.ts +1 -1
- package/LexicalHorizontalRuleNode.d.ts +4 -4
- package/LexicalHorizontalRuleNode.dev.js +1 -1
- package/LexicalHorizontalRuleNode.prod.js +1 -1
- package/LexicalLinkPlugin.dev.js +1 -2
- package/LexicalLinkPlugin.prod.js +1 -1
- package/LexicalListPlugin.dev.js +6 -7
- package/LexicalListPlugin.prod.js +2 -2
- package/LexicalMarkdownShortcutPlugin.d.ts +1 -1
- package/LexicalNestedComposer.d.ts +5 -7
- package/LexicalNestedComposer.dev.js +22 -36
- package/LexicalNestedComposer.js.flow +3 -5
- package/LexicalNestedComposer.prod.js +3 -3
- package/LexicalPlainTextPlugin.d.ts +3 -3
- package/LexicalRichTextPlugin.d.ts +3 -3
- package/LexicalTablePlugin.dev.js +1 -2
- package/LexicalTablePlugin.prod.js +4 -4
- package/LexicalTreeView.d.ts +1 -1
- package/package.json +18 -18
- package/useLexicalDecoratorMap.d.ts +0 -14
- package/useLexicalDecoratorMap.dev.js +0 -83
- package/useLexicalDecoratorMap.js +0 -9
- package/useLexicalDecoratorMap.js.flow +0 -16
- package/useLexicalDecoratorMap.prod.js +0 -8
|
@@ -19,7 +19,6 @@ var react = require('react');
|
|
|
19
19
|
*
|
|
20
20
|
*
|
|
21
21
|
*/
|
|
22
|
-
const LowPriority = 1;
|
|
23
22
|
function useList(editor) {
|
|
24
23
|
react.useEffect(() => {
|
|
25
24
|
return utils.mergeRegister(editor.registerCommand(lexical.INDENT_CONTENT_COMMAND, () => {
|
|
@@ -30,7 +29,7 @@ function useList(editor) {
|
|
|
30
29
|
}
|
|
31
30
|
|
|
32
31
|
return false;
|
|
33
|
-
},
|
|
32
|
+
}, lexical.COMMAND_PRIORITY_LOW), editor.registerCommand(lexical.OUTDENT_CONTENT_COMMAND, () => {
|
|
34
33
|
const hasHandledIndention = list.outdentList();
|
|
35
34
|
|
|
36
35
|
if (hasHandledIndention) {
|
|
@@ -38,16 +37,16 @@ function useList(editor) {
|
|
|
38
37
|
}
|
|
39
38
|
|
|
40
39
|
return false;
|
|
41
|
-
},
|
|
40
|
+
}, lexical.COMMAND_PRIORITY_LOW), editor.registerCommand(list.INSERT_ORDERED_LIST_COMMAND, () => {
|
|
42
41
|
list.insertList(editor, 'ol');
|
|
43
42
|
return true;
|
|
44
|
-
},
|
|
43
|
+
}, lexical.COMMAND_PRIORITY_LOW), editor.registerCommand(list.INSERT_UNORDERED_LIST_COMMAND, () => {
|
|
45
44
|
list.insertList(editor, 'ul');
|
|
46
45
|
return true;
|
|
47
|
-
},
|
|
46
|
+
}, lexical.COMMAND_PRIORITY_LOW), editor.registerCommand(list.REMOVE_LIST_COMMAND, () => {
|
|
48
47
|
list.removeList(editor);
|
|
49
48
|
return true;
|
|
50
|
-
},
|
|
49
|
+
}, lexical.COMMAND_PRIORITY_LOW), editor.registerCommand(lexical.INSERT_PARAGRAPH_COMMAND, () => {
|
|
51
50
|
const hasHandledInsertParagraph = list.$handleListInsertParagraph();
|
|
52
51
|
|
|
53
52
|
if (hasHandledInsertParagraph) {
|
|
@@ -55,7 +54,7 @@ function useList(editor) {
|
|
|
55
54
|
}
|
|
56
55
|
|
|
57
56
|
return false;
|
|
58
|
-
},
|
|
57
|
+
}, lexical.COMMAND_PRIORITY_LOW));
|
|
59
58
|
}, [editor]);
|
|
60
59
|
}
|
|
61
60
|
|
|
@@ -5,5 +5,5 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
var b=require("@lexical/list"),c=require("@lexical/utils"),d=require("lexical"),e=require("react");
|
|
8
|
-
function f(a){e.useEffect(()=>c.mergeRegister(a.registerCommand(d.INDENT_CONTENT_COMMAND,()=>b.indentList()?!0:!1,
|
|
9
|
-
!0:!1,
|
|
8
|
+
function f(a){e.useEffect(()=>c.mergeRegister(a.registerCommand(d.INDENT_CONTENT_COMMAND,()=>b.indentList()?!0:!1,d.COMMAND_PRIORITY_LOW),a.registerCommand(d.OUTDENT_CONTENT_COMMAND,()=>b.outdentList()?!0:!1,d.COMMAND_PRIORITY_LOW),a.registerCommand(b.INSERT_ORDERED_LIST_COMMAND,()=>{b.insertList(a,"ol");return!0},d.COMMAND_PRIORITY_LOW),a.registerCommand(b.INSERT_UNORDERED_LIST_COMMAND,()=>{b.insertList(a,"ul");return!0},d.COMMAND_PRIORITY_LOW),a.registerCommand(b.REMOVE_LIST_COMMAND,()=>{b.removeList(a);
|
|
9
|
+
return!0},d.COMMAND_PRIORITY_LOW),a.registerCommand(d.INSERT_PARAGRAPH_COMMAND,()=>b.$handleListInsertParagraph()?!0:!1,d.COMMAND_PRIORITY_LOW)),[a])}module.exports=function(a){f(a)};
|
|
@@ -11,4 +11,6 @@ import {$ReadOnly} from 'utility-types';
|
|
|
11
11
|
type Props = $ReadOnly<{
|
|
12
12
|
onClear?: () => void;
|
|
13
13
|
}>;
|
|
14
|
-
export default function LexicalClearEditorPlugin(
|
|
14
|
+
export default function LexicalClearEditorPlugin(
|
|
15
|
+
arg0: Props,
|
|
16
|
+
): JSX.Element | null;
|
|
@@ -5,4 +5,4 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
var a=require("@lexical/react/LexicalComposerContext"),d=require("lexical"),g=require("react"),h="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?g.useLayoutEffect:g.useEffect;
|
|
8
|
-
module.exports=function({onClear:b}){const [c]=a.useLexicalComposerContext();h(()=>c.registerCommand(d.CLEAR_EDITOR_COMMAND,()=>{c.update(()=>{if(null==b){const e=d.$getRoot(),k=d.$getSelection(),f=d.$createParagraphNode();e.clear();e.append(f);null!==k&&f.select()}else b()});return!0},
|
|
8
|
+
module.exports=function({onClear:b}){const [c]=a.useLexicalComposerContext();h(()=>c.registerCommand(d.CLEAR_EDITOR_COMMAND,()=>{c.update(()=>{if(null==b){const e=d.$getRoot(),k=d.$getSelection(),f=d.$createParagraphNode();e.clear();e.append(f);null!==k&&f.select()}else b()});return!0},d.COMMAND_PRIORITY_EDITOR),[c,b]);return null};
|
|
@@ -51,6 +51,6 @@ export function CollaborationPlugin(arg0: {
|
|
|
51
51
|
providerFactory: ProviderFactory;
|
|
52
52
|
shouldBootstrap: boolean;
|
|
53
53
|
username?: string;
|
|
54
|
-
}):
|
|
54
|
+
}): JSX.Element | null;
|
|
55
55
|
export declare var CollaborationContext: React.Context<CollaborationContextType>;
|
|
56
56
|
export function useCollaborationContext(): CollaborationContextType;
|
|
@@ -21,7 +21,6 @@ var reactDom = require('react-dom');
|
|
|
21
21
|
*
|
|
22
22
|
*
|
|
23
23
|
*/
|
|
24
|
-
const EditorPriority = 0;
|
|
25
24
|
function useYjsCollaboration(editor, id, provider, docMap, name, color, shouldBootstrap) {
|
|
26
25
|
const isReloadingDoc = React.useRef(false);
|
|
27
26
|
const [doc, setDoc] = React.useState(docMap.get(id));
|
|
@@ -133,7 +132,7 @@ function useYjsCollaboration(editor, id, provider, docMap, name, color, shouldBo
|
|
|
133
132
|
}
|
|
134
133
|
|
|
135
134
|
return true;
|
|
136
|
-
},
|
|
135
|
+
}, lexical.COMMAND_PRIORITY_EDITOR);
|
|
137
136
|
}, [connect, disconnect, editor]);
|
|
138
137
|
return [cursorsContainer, binding];
|
|
139
138
|
}
|
|
@@ -142,10 +141,10 @@ function useYjsFocusTracking(editor, provider, name, color) {
|
|
|
142
141
|
return utils.mergeRegister(editor.registerCommand(lexical.FOCUS_COMMAND, payload => {
|
|
143
142
|
yjs.setLocalStateFocus(provider, name, color, true);
|
|
144
143
|
return true;
|
|
145
|
-
},
|
|
144
|
+
}, lexical.COMMAND_PRIORITY_EDITOR), editor.registerCommand(lexical.BLUR_COMMAND, payload => {
|
|
146
145
|
yjs.setLocalStateFocus(provider, name, color, false);
|
|
147
146
|
return true;
|
|
148
|
-
},
|
|
147
|
+
}, lexical.COMMAND_PRIORITY_EDITOR));
|
|
149
148
|
}, [color, editor, name, provider]);
|
|
150
149
|
}
|
|
151
150
|
function useYjsHistory(editor, binding) {
|
|
@@ -162,10 +161,10 @@ function useYjsHistory(editor, binding) {
|
|
|
162
161
|
return utils.mergeRegister(editor.registerCommand(lexical.UNDO_COMMAND, () => {
|
|
163
162
|
undo();
|
|
164
163
|
return true;
|
|
165
|
-
},
|
|
164
|
+
}, lexical.COMMAND_PRIORITY_EDITOR), editor.registerCommand(lexical.REDO_COMMAND, () => {
|
|
166
165
|
redo();
|
|
167
166
|
return true;
|
|
168
|
-
},
|
|
167
|
+
}, lexical.COMMAND_PRIORITY_EDITOR));
|
|
169
168
|
});
|
|
170
169
|
const clearHistory = React.useCallback(() => {
|
|
171
170
|
undoManager.clear();
|
|
@@ -238,7 +237,7 @@ function clearEditorSkipCollab(editor, binding) {
|
|
|
238
237
|
*
|
|
239
238
|
*/
|
|
240
239
|
const entries = [['Cat', '255,165,0'], ['Dog', '0,200,55'], ['Rabbit', '160,0,200'], ['Frog', '0,172,200'], ['Fox', '197,200,0'], ['Hedgehog', '31,200,0'], ['Pigeon', '200,0,0'], ['Squirrel', '200,0,148'], ['Bear', '255,235,0'], ['Tiger', '86,255,0'], ['Leopard', '0,255,208'], ['Zebra', '0,243,255'], ['Wolf', '0,102,255'], ['Owl', '147,0,255'], ['Gull', '255,0,153'], ['Squid', '0,220,255']];
|
|
241
|
-
const randomEntry = entries[Math.floor(Math.random() *
|
|
240
|
+
const randomEntry = entries[Math.floor(Math.random() * entries.length)];
|
|
242
241
|
function CollaborationPlugin({
|
|
243
242
|
id,
|
|
244
243
|
providerFactory,
|
|
@@ -4,13 +4,13 @@
|
|
|
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
|
-
var e=require("@lexical/react/LexicalComposerContext"),
|
|
8
|
-
function H(b,c,a,d,
|
|
9
|
-
a,
|
|
10
|
-
D);y.off("update",B);
|
|
11
|
-
function K(b,c,a,d){
|
|
12
|
-
function L(b,c){const a=
|
|
7
|
+
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
|
+
function H(b,c,a,d,l,p,q){const 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(()=>{const {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
|
+
a,k)};x.initLocalState(a,l,p,document.activeElement===b.getRootElement());const 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);const 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",
|
|
10
|
+
D);y.off("update",B);m.getSharedType().unobserveDeep(C);R()}},[g,p,t,u,d,b,c,l,a,q]);const 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
|
+
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
|
+
function L(b,c){const 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()){const a=F.$createParagraphNode();c.append(a);c=document.activeElement;(null!==F.$getSelection()||null!==c&&c===b.getRootElement())&&a.select()}},{tag:"history-merge"})}
|
|
14
|
-
function J(b,c){b.update(()=>{const d=F.$getRoot();d.clear();d.select()},{tag:"skip-collab"});if(null!=c.cursors&&(b=c.cursorsContainer,null!=b)){c=Array.from(c.cursors.values());for(let d=0;d<c.length;d++){var a=c[d].selection;if(a&&null!=a.selections){a=a.selections;for(let
|
|
15
|
-
const M=[["Cat","255,165,0"],["Dog","0,200,55"],["Rabbit","160,0,200"],["Frog","0,172,200"],["Fox","197,200,0"],["Hedgehog","31,200,0"],["Pigeon","200,0,0"],["Squirrel","200,0,148"],["Bear","255,235,0"],["Tiger","86,255,0"],["Leopard","0,255,208"],["Zebra","0,243,255"],["Wolf","0,102,255"],["Owl","147,0,255"],["Gull","255,0,153"],["Squid","0,220,255"]],N=M[Math.floor(Math.random()*
|
|
16
|
-
function U(b){const c=
|
|
14
|
+
function J(b,c){b.update(()=>{const d=F.$getRoot();d.clear();d.select()},{tag:"skip-collab"});if(null!=c.cursors&&(b=c.cursorsContainer,null!=b)){c=Array.from(c.cursors.values());for(let d=0;d<c.length;d++){var a=c[d].selection;if(a&&null!=a.selections){a=a.selections;for(let l=0;l<a.length;l++)b.removeChild(a[d])}}}}
|
|
15
|
+
const M=[["Cat","255,165,0"],["Dog","0,200,55"],["Rabbit","160,0,200"],["Frog","0,172,200"],["Fox","197,200,0"],["Hedgehog","31,200,0"],["Pigeon","200,0,0"],["Squirrel","200,0,148"],["Bear","255,235,0"],["Tiger","86,255,0"],["Leopard","0,255,208"],["Zebra","0,243,255"],["Wolf","0,102,255"],["Owl","147,0,255"],["Gull","255,0,153"],["Squid","0,220,255"]],N=M[Math.floor(Math.random()*M.length)],T=f.createContext({clientID:0,color:N[1],name:N[0],yjsDocMap:new Map});
|
|
16
|
+
function U(b){const c=f.useContext(T);null!=b&&(c.name=b);return c}exports.CollaborationContext=T;exports.CollaborationPlugin=function({id:b,providerFactory:c,shouldBootstrap:a,username:d}){d=U(d);const {yjsDocMap:l,name:p,color:q}=d,[n]=e.useLexicalComposerContext(),r=f.useMemo(()=>c(b,l),[b,c,l]),[v,g]=H(n,b,r,l,p,q,a);d.clientID=g.clientID;L(n,g);K(n,r,p,q);return v};exports.useCollaborationContext=U;
|
package/LexicalComposer.d.ts
CHANGED
|
@@ -17,6 +17,6 @@ type Props = {
|
|
|
17
17
|
theme?: EditorThemeClasses;
|
|
18
18
|
onError: (error: Error, editor: LexicalEditor) => void;
|
|
19
19
|
};
|
|
20
|
-
children:
|
|
20
|
+
children: JSX.Element | JSX.Element[] | null;
|
|
21
21
|
};
|
|
22
|
-
export default function LexicalComposer(arg0: Props):
|
|
22
|
+
export default function LexicalComposer(arg0: Props): JSX.Element | null;
|
|
@@ -8,14 +8,14 @@
|
|
|
8
8
|
|
|
9
9
|
import type {LexicalNode, LexicalCommand} from 'lexical';
|
|
10
10
|
import {DecoratorNode} from 'lexical';
|
|
11
|
-
export declare class HorizontalRuleNode extends DecoratorNode<
|
|
12
|
-
getType(): string;
|
|
13
|
-
clone(node: HorizontalRuleNode): HorizontalRuleNode;
|
|
11
|
+
export declare class HorizontalRuleNode extends DecoratorNode<JSX.Element | null> {
|
|
12
|
+
static getType(): string;
|
|
13
|
+
static clone(node: HorizontalRuleNode): HorizontalRuleNode;
|
|
14
14
|
createDOM(): HTMLElement;
|
|
15
15
|
getTextContent(): '\n';
|
|
16
16
|
isTopLevel(): true;
|
|
17
17
|
updateDOM(): false;
|
|
18
|
-
decorate():
|
|
18
|
+
decorate(): JSX.Element | null;
|
|
19
19
|
}
|
|
20
20
|
export function $createHorizontalRuleNode(): HorizontalRuleNode;
|
|
21
21
|
export function $isHorizontalRuleNode(
|
|
@@ -5,5 +5,5 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
var b=require("lexical"),c=require("react");const d=b.createCommand();function e(){return c.createElement("hr",null)}
|
|
8
|
-
class f extends b.DecoratorNode{static getType(){return"horizontalrule"}static clone(a){return new f(a.
|
|
8
|
+
class f extends b.DecoratorNode{static getType(){return"horizontalrule"}static clone(a){return new f(a.__key)}static importDOM(){return{hr:()=>({conversion:g,priority:0})}}exportDOM(){return{element:document.createElement("hr")}}createDOM(){const a=document.createElement("div");a.style.display="contents";return a}getTextContent(){return"\n"}isTopLevel(){return!0}updateDOM(){return!1}decorate(){return c.createElement(e,null)}}function g(){return{node:h()}}function h(){return new f}
|
|
9
9
|
exports.$createHorizontalRuleNode=h;exports.$isHorizontalRuleNode=function(a){return a instanceof f};exports.HorizontalRuleNode=f;exports.INSERT_HORIZONTAL_RULE_COMMAND=d;
|
package/LexicalLinkPlugin.dev.js
CHANGED
|
@@ -19,7 +19,6 @@ var react = require('react');
|
|
|
19
19
|
*
|
|
20
20
|
*
|
|
21
21
|
*/
|
|
22
|
-
const EditorPriority = 0;
|
|
23
22
|
|
|
24
23
|
function toggleLink(url) {
|
|
25
24
|
const selection = lexical.$getSelection();
|
|
@@ -127,7 +126,7 @@ function LinkPlugin() {
|
|
|
127
126
|
const url = payload;
|
|
128
127
|
toggleLink(url);
|
|
129
128
|
return true;
|
|
130
|
-
},
|
|
129
|
+
}, lexical.COMMAND_PRIORITY_EDITOR);
|
|
131
130
|
}, [editor]);
|
|
132
131
|
return null;
|
|
133
132
|
}
|
|
@@ -7,4 +7,4 @@
|
|
|
7
7
|
var g=require("@lexical/link"),k=require("@lexical/react/LexicalComposerContext"),m=require("lexical"),n=require("react");
|
|
8
8
|
function p(e){var b=m.$getSelection();null!==b&&m.$setSelection(b);b=m.$getSelection();if(null!==b)if(b=b.extract(),null===e)b.forEach(f=>{f=f.getParent();if(g.$isLinkNode(f)){const c=f.getChildren();for(let a=0;a<c.length;a++)f.insertBefore(c[a]);f.remove()}});else{if(1===b.length){var h=b[0];if(g.$isLinkNode(h)){h.setURL(e);return}h=h.getParent();if(g.$isLinkNode(h)){h.setURL(e);return}}let f=null,c=null;b.forEach(a=>{var d=a.getParent();if(d!==c&&null!==d&&(!m.$isElementNode(a)||a.isInline()))if(d.is(f)||
|
|
9
9
|
(f=d,c=g.$createLinkNode(e),g.$isLinkNode(d)?null===a.getPreviousSibling()?d.insertBefore(c):d.insertAfter(c):a.insertBefore(c)),g.$isLinkNode(a)){if(null!==c){d=a.getChildren();for(let l=0;l<d.length;l++)c.append(d[l])}a.remove()}else null!==c&&c.append(a)})}}
|
|
10
|
-
module.exports=function(){const [e]=k.useLexicalComposerContext();n.useEffect(()=>{if(!e.hasNodes([g.LinkNode]))throw Error("LinkPlugin: LinkNode not registered on editor");},[e]);n.useEffect(()=>e.registerCommand(g.TOGGLE_LINK_COMMAND,b=>{p(b);return!0},
|
|
10
|
+
module.exports=function(){const [e]=k.useLexicalComposerContext();n.useEffect(()=>{if(!e.hasNodes([g.LinkNode]))throw Error("LinkPlugin: LinkNode not registered on editor");},[e]);n.useEffect(()=>e.registerCommand(g.TOGGLE_LINK_COMMAND,b=>{p(b);return!0},m.COMMAND_PRIORITY_EDITOR),[e]);return null};
|
package/LexicalListPlugin.dev.js
CHANGED
|
@@ -20,7 +20,6 @@ var react = require('react');
|
|
|
20
20
|
*
|
|
21
21
|
*
|
|
22
22
|
*/
|
|
23
|
-
const LowPriority = 1;
|
|
24
23
|
function useList(editor) {
|
|
25
24
|
react.useEffect(() => {
|
|
26
25
|
return utils.mergeRegister(editor.registerCommand(lexical.INDENT_CONTENT_COMMAND, () => {
|
|
@@ -31,7 +30,7 @@ function useList(editor) {
|
|
|
31
30
|
}
|
|
32
31
|
|
|
33
32
|
return false;
|
|
34
|
-
},
|
|
33
|
+
}, lexical.COMMAND_PRIORITY_LOW), editor.registerCommand(lexical.OUTDENT_CONTENT_COMMAND, () => {
|
|
35
34
|
const hasHandledIndention = list.outdentList();
|
|
36
35
|
|
|
37
36
|
if (hasHandledIndention) {
|
|
@@ -39,16 +38,16 @@ function useList(editor) {
|
|
|
39
38
|
}
|
|
40
39
|
|
|
41
40
|
return false;
|
|
42
|
-
},
|
|
41
|
+
}, lexical.COMMAND_PRIORITY_LOW), editor.registerCommand(list.INSERT_ORDERED_LIST_COMMAND, () => {
|
|
43
42
|
list.insertList(editor, 'ol');
|
|
44
43
|
return true;
|
|
45
|
-
},
|
|
44
|
+
}, lexical.COMMAND_PRIORITY_LOW), editor.registerCommand(list.INSERT_UNORDERED_LIST_COMMAND, () => {
|
|
46
45
|
list.insertList(editor, 'ul');
|
|
47
46
|
return true;
|
|
48
|
-
},
|
|
47
|
+
}, lexical.COMMAND_PRIORITY_LOW), editor.registerCommand(list.REMOVE_LIST_COMMAND, () => {
|
|
49
48
|
list.removeList(editor);
|
|
50
49
|
return true;
|
|
51
|
-
},
|
|
50
|
+
}, lexical.COMMAND_PRIORITY_LOW), editor.registerCommand(lexical.INSERT_PARAGRAPH_COMMAND, () => {
|
|
52
51
|
const hasHandledInsertParagraph = list.$handleListInsertParagraph();
|
|
53
52
|
|
|
54
53
|
if (hasHandledInsertParagraph) {
|
|
@@ -56,7 +55,7 @@ function useList(editor) {
|
|
|
56
55
|
}
|
|
57
56
|
|
|
58
57
|
return false;
|
|
59
|
-
},
|
|
58
|
+
}, lexical.COMMAND_PRIORITY_LOW));
|
|
60
59
|
}, [editor]);
|
|
61
60
|
}
|
|
62
61
|
|
|
@@ -5,5 +5,5 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
var b=require("@lexical/react/LexicalComposerContext"),c=require("@lexical/list"),d=require("@lexical/utils"),e=require("lexical"),f=require("react");
|
|
8
|
-
function g(a){f.useEffect(()=>d.mergeRegister(a.registerCommand(e.INDENT_CONTENT_COMMAND,()=>c.indentList()?!0:!1,
|
|
9
|
-
!0:!1,
|
|
8
|
+
function g(a){f.useEffect(()=>d.mergeRegister(a.registerCommand(e.INDENT_CONTENT_COMMAND,()=>c.indentList()?!0:!1,e.COMMAND_PRIORITY_LOW),a.registerCommand(e.OUTDENT_CONTENT_COMMAND,()=>c.outdentList()?!0:!1,e.COMMAND_PRIORITY_LOW),a.registerCommand(c.INSERT_ORDERED_LIST_COMMAND,()=>{c.insertList(a,"ol");return!0},e.COMMAND_PRIORITY_LOW),a.registerCommand(c.INSERT_UNORDERED_LIST_COMMAND,()=>{c.insertList(a,"ul");return!0},e.COMMAND_PRIORITY_LOW),a.registerCommand(c.REMOVE_LIST_COMMAND,()=>{c.removeList(a);
|
|
9
|
+
return!0},e.COMMAND_PRIORITY_LOW),a.registerCommand(e.INSERT_PARAGRAPH_COMMAND,()=>c.$handleListInsertParagraph()?!0:!1,e.COMMAND_PRIORITY_LOW)),[a])}module.exports=function(){const [a]=b.useLexicalComposerContext();g(a);return null};
|
|
@@ -6,12 +6,10 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import type {
|
|
9
|
+
import type {LexicalEditor, EditorThemeClasses} from 'lexical';
|
|
10
10
|
|
|
11
11
|
export default function LexicalNestedComposer(arg0: {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
children: React.ReactNode;
|
|
17
|
-
}): React.ReactNode;
|
|
12
|
+
initialEditor: LexicalEditor;
|
|
13
|
+
initialTheme?: EditorThemeClasses;
|
|
14
|
+
children: JSX.Element | JSX.Element[] | null;
|
|
15
|
+
}): JSX.Element | null;
|
|
@@ -6,9 +6,8 @@
|
|
|
6
6
|
*/
|
|
7
7
|
'use strict';
|
|
8
8
|
|
|
9
|
+
var LexicalCollaborationPlugin = require('@lexical/react/LexicalCollaborationPlugin');
|
|
9
10
|
var LexicalComposerContext = require('@lexical/react/LexicalComposerContext');
|
|
10
|
-
var LexicalOnChangePlugin = require('@lexical/react/LexicalOnChangePlugin');
|
|
11
|
-
var lexical = require('lexical');
|
|
12
11
|
var React = require('react');
|
|
13
12
|
|
|
14
13
|
/**
|
|
@@ -20,8 +19,9 @@ var React = require('react');
|
|
|
20
19
|
*
|
|
21
20
|
*/
|
|
22
21
|
function LexicalNestedComposer({
|
|
23
|
-
|
|
24
|
-
children
|
|
22
|
+
initialEditor,
|
|
23
|
+
children,
|
|
24
|
+
initialTheme
|
|
25
25
|
}) {
|
|
26
26
|
const parentContext = React.useContext(LexicalComposerContext.LexicalComposerContext);
|
|
27
27
|
|
|
@@ -31,45 +31,31 @@ function LexicalNestedComposer({
|
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
const [nestedEditor, setNestedEditor] = React.useState(null);
|
|
35
|
-
const {
|
|
36
|
-
decoratorEditor
|
|
37
|
-
} = initialConfig;
|
|
38
|
-
React.useEffect(() => {
|
|
39
|
-
if (!decoratorEditor.isEmpty() && nestedEditor !== null) {
|
|
40
|
-
decoratorEditor.init(nestedEditor);
|
|
41
|
-
} // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
42
|
-
|
|
43
|
-
}, [nestedEditor]);
|
|
44
34
|
const composerContext = React.useMemo(() => {
|
|
45
35
|
const [parentEditor, parentContextContext] = parentContext;
|
|
46
|
-
const composerTheme =
|
|
36
|
+
const composerTheme = initialTheme || parentContextContext.getTheme() || undefined;
|
|
47
37
|
const context = LexicalComposerContext.createLexicalComposerContext(parentContext, composerTheme);
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
return [editor, context];
|
|
38
|
+
|
|
39
|
+
if (composerTheme !== undefined) {
|
|
40
|
+
initialEditor._config.theme = composerTheme;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
initialEditor._parentEditor = parentEditor;
|
|
44
|
+
initialEditor._nodes = parentEditor._nodes;
|
|
45
|
+
return [initialEditor, context];
|
|
57
46
|
}, // We only do this for init
|
|
58
47
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
59
|
-
[]);
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
[]);
|
|
48
|
+
[]); // If collaboration is enabled, make sure we don't render the children
|
|
49
|
+
// until the collaboration subdocument is ready.
|
|
50
|
+
|
|
51
|
+
const {
|
|
52
|
+
yjsDocMap
|
|
53
|
+
} = LexicalCollaborationPlugin.useCollaborationContext();
|
|
54
|
+
const isCollab = yjsDocMap.get('main') !== undefined;
|
|
55
|
+
const isCollabReady = yjsDocMap.has(initialEditor.getKey());
|
|
68
56
|
return /*#__PURE__*/React.createElement(LexicalComposerContext.LexicalComposerContext.Provider, {
|
|
69
57
|
value: composerContext
|
|
70
|
-
},
|
|
71
|
-
onChange: onChange
|
|
72
|
-
}), children);
|
|
58
|
+
}, !isCollab || isCollabReady ? children : null);
|
|
73
59
|
}
|
|
74
60
|
|
|
75
61
|
module.exports = LexicalNestedComposer;
|
|
@@ -7,12 +7,10 @@
|
|
|
7
7
|
* @flow strict
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import type {
|
|
10
|
+
import type {LexicalEditor, EditorThemeClasses, LexicalNode} from 'lexical';
|
|
11
11
|
|
|
12
12
|
declare export default function LexicalNestedComposer({
|
|
13
|
-
initialConfig: $ReadOnly<{
|
|
14
|
-
decoratorEditor: DecoratorEditor,
|
|
15
|
-
theme?: EditorThemeClasses,
|
|
16
|
-
}>,
|
|
17
13
|
children: React$Node,
|
|
14
|
+
initialEditor: LexicalEditor,
|
|
15
|
+
initialTheme?: EditorThemeClasses,
|
|
18
16
|
}): React$Node;
|
|
@@ -4,6 +4,6 @@
|
|
|
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
|
-
var
|
|
8
|
-
module.exports=function({
|
|
9
|
-
|
|
7
|
+
var c=require("@lexical/react/LexicalCollaborationPlugin"),d=require("@lexical/react/LexicalComposerContext"),h=require("react");
|
|
8
|
+
module.exports=function({initialEditor:a,children:k,initialTheme:l}){const e=h.useContext(d.LexicalComposerContext);if(null==e)throw Error("Minified Lexical error #72; see codes.json for the full message or use the non-minified dev environment for full errors and additional helpful warnings.");const p=h.useMemo(()=>{const [g,m]=e,f=l||m.getTheme()||void 0,n=d.createLexicalComposerContext(e,f);void 0!==f&&(a._config.theme=f);a._parentEditor=g;a._nodes=g._nodes;return[a,n]},[]);var {yjsDocMap:b}=c.useCollaborationContext();
|
|
9
|
+
const q=void 0!==b.get("main");b=b.has(a.getKey());return h.createElement(d.LexicalComposerContext.Provider,{value:p},!q||b?k:null)};
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
import type {EditorState} from 'lexical';
|
|
10
10
|
type InitialEditorStateType = null | string | EditorState | (() => void);
|
|
11
11
|
export default function PlainTextPlugin(arg0: {
|
|
12
|
-
contentEditable:
|
|
12
|
+
contentEditable: JSX.Element | null;
|
|
13
13
|
initialEditorState?: InitialEditorStateType;
|
|
14
|
-
placeholder:
|
|
15
|
-
}):
|
|
14
|
+
placeholder: JSX.Element | null;
|
|
15
|
+
}): JSX.Element | null;
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
import type {EditorState} from 'lexical';
|
|
10
10
|
type InitialEditorStateType = null | string | EditorState | (() => void);
|
|
11
11
|
export default function RichTextPlugin(arg0: {
|
|
12
|
-
contentEditable:
|
|
12
|
+
contentEditable: JSX.Element | null;
|
|
13
13
|
initialEditorState?: InitialEditorStateType;
|
|
14
|
-
placeholder:
|
|
15
|
-
}):
|
|
14
|
+
placeholder: JSX.Element | null;
|
|
15
|
+
}): JSX.Element | null;
|
|
@@ -19,7 +19,6 @@ var react = require('react');
|
|
|
19
19
|
*
|
|
20
20
|
*
|
|
21
21
|
*/
|
|
22
|
-
const EditorPriority = 0;
|
|
23
22
|
function TablePlugin() {
|
|
24
23
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
25
24
|
react.useEffect(() => {
|
|
@@ -67,7 +66,7 @@ function TablePlugin() {
|
|
|
67
66
|
}
|
|
68
67
|
|
|
69
68
|
return true;
|
|
70
|
-
},
|
|
69
|
+
}, lexical.COMMAND_PRIORITY_EDITOR);
|
|
71
70
|
}, [editor]);
|
|
72
71
|
react.useEffect(() => {
|
|
73
72
|
const tableSelections = new Map();
|
|
@@ -4,7 +4,7 @@
|
|
|
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
|
-
var e=require("@lexical/react/LexicalComposerContext"),
|
|
8
|
-
module.exports=function(){const [c]=e.useLexicalComposerContext();m.useEffect(()=>{if(!c.hasNodes([
|
|
9
|
-
Number(h));k.$isRootNode(a)?(d=a.getChildAtIndex(d.offset),null!==d?d.insertBefore(b):a.append(b),b.insertBefore(k.$createParagraphNode())):a.getTopLevelElementOrThrow().insertAfter(b);b.insertAfter(k.$createParagraphNode());b.getFirstChildOrThrow().getFirstChildOrThrow().select()}return!0},
|
|
10
|
-
b,c),a.set(
|
|
7
|
+
var e=require("@lexical/react/LexicalComposerContext"),f=require("@lexical/table"),k=require("lexical"),m=require("react");
|
|
8
|
+
module.exports=function(){const [c]=e.useLexicalComposerContext();m.useEffect(()=>{if(!c.hasNodes([f.TableNode,f.TableCellNode,f.TableRowNode]))throw Error("Minified Lexical error #54; see codes.json for the full message or use the non-minified dev environment for full errors and additional helpful warnings.");return c.registerCommand(f.INSERT_TABLE_COMMAND,a=>{const {columns:h,rows:g}=a;a=k.$getSelection();if(!k.$isRangeSelection(a))return!0;var d=a.focus;a=d.getNode();if(null!==a){const b=f.$createTableNodeWithDimensions(Number(g),
|
|
9
|
+
Number(h));k.$isRootNode(a)?(d=a.getChildAtIndex(d.offset),null!==d?d.insertBefore(b):a.append(b),b.insertBefore(k.$createParagraphNode())):a.getTopLevelElementOrThrow().insertAfter(b);b.insertAfter(k.$createParagraphNode());b.getFirstChildOrThrow().getFirstChildOrThrow().select()}return!0},k.COMMAND_PRIORITY_EDITOR)},[c]);m.useEffect(()=>{const a=new Map;return c.registerMutationListener(f.TableNode,h=>{for(const [g,d]of h)"created"===d?c.update(()=>{var b=c.getElementByKey(g);const l=k.$getNodeByKey(g);
|
|
10
|
+
b&&l&&(b=f.applyTableHandlers(l,b,c),a.set(g,b))}):"destroyed"===d&&(h=a.get(g))&&(h.removeListeners(),a.delete(g))})},[c]);return null};
|
package/LexicalTreeView.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -8,27 +8,27 @@
|
|
|
8
8
|
"rich-text"
|
|
9
9
|
],
|
|
10
10
|
"license": "MIT",
|
|
11
|
-
"version": "0.
|
|
11
|
+
"version": "0.2.2",
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@lexical/clipboard": "0.
|
|
14
|
-
"@lexical/list": "0.
|
|
15
|
-
"@lexical/table": "0.
|
|
16
|
-
"@lexical/yjs": "0.
|
|
17
|
-
"@lexical/hashtag": "0.
|
|
18
|
-
"@lexical/selection": "0.
|
|
19
|
-
"@lexical/utils": "0.
|
|
20
|
-
"@lexical/dragon": "0.
|
|
21
|
-
"@lexical/plain-text": "0.
|
|
22
|
-
"@lexical/rich-text": "0.
|
|
23
|
-
"@lexical/code": "0.
|
|
24
|
-
"@lexical/text": "0.
|
|
25
|
-
"@lexical/link": "0.
|
|
26
|
-
"@lexical/overflow": "0.
|
|
27
|
-
"@lexical/history": "0.
|
|
28
|
-
"@lexical/markdown": "0.
|
|
13
|
+
"@lexical/clipboard": "0.2.2",
|
|
14
|
+
"@lexical/list": "0.2.2",
|
|
15
|
+
"@lexical/table": "0.2.2",
|
|
16
|
+
"@lexical/yjs": "0.2.2",
|
|
17
|
+
"@lexical/hashtag": "0.2.2",
|
|
18
|
+
"@lexical/selection": "0.2.2",
|
|
19
|
+
"@lexical/utils": "0.2.2",
|
|
20
|
+
"@lexical/dragon": "0.2.2",
|
|
21
|
+
"@lexical/plain-text": "0.2.2",
|
|
22
|
+
"@lexical/rich-text": "0.2.2",
|
|
23
|
+
"@lexical/code": "0.2.2",
|
|
24
|
+
"@lexical/text": "0.2.2",
|
|
25
|
+
"@lexical/link": "0.2.2",
|
|
26
|
+
"@lexical/overflow": "0.2.2",
|
|
27
|
+
"@lexical/history": "0.2.2",
|
|
28
|
+
"@lexical/markdown": "0.2.2"
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
31
|
-
"lexical": "0.
|
|
31
|
+
"lexical": "0.2.2",
|
|
32
32
|
"react": ">=17.x",
|
|
33
33
|
"react-dom": ">=17.x"
|
|
34
34
|
},
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import type {DecoratorMap, DecoratorStateValue} from 'lexical';
|
|
10
|
-
export default function useLexicalDecoratorMap<V extends DecoratorStateValue>(
|
|
11
|
-
decoratorMap: DecoratorMap,
|
|
12
|
-
key: string,
|
|
13
|
-
initialValue: (() => V) | V,
|
|
14
|
-
): [V, (arg0: DecoratorStateValue) => void];
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/
|
|
7
|
-
'use strict';
|
|
8
|
-
|
|
9
|
-
var lexical = require('lexical');
|
|
10
|
-
var react = require('react');
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
14
|
-
*
|
|
15
|
-
* This source code is licensed under the MIT license found in the
|
|
16
|
-
* LICENSE file in the root directory of this source tree.
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*/
|
|
20
|
-
const CAN_USE_DOM = typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined';
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
24
|
-
*
|
|
25
|
-
* This source code is licensed under the MIT license found in the
|
|
26
|
-
* LICENSE file in the root directory of this source tree.
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*/
|
|
30
|
-
const useLayoutEffectImpl = CAN_USE_DOM ? react.useLayoutEffect : react.useEffect;
|
|
31
|
-
var useLayoutEffect = useLayoutEffectImpl;
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
35
|
-
*
|
|
36
|
-
* This source code is licensed under the MIT license found in the
|
|
37
|
-
* LICENSE file in the root directory of this source tree.
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*/
|
|
41
|
-
|
|
42
|
-
function getInitialMapValue(decoratorMap, key, initialValue) {
|
|
43
|
-
// $FlowFixMe: Flow struggles with the generic
|
|
44
|
-
const value = decoratorMap.get(key);
|
|
45
|
-
|
|
46
|
-
if (value !== undefined) {
|
|
47
|
-
return value;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
return typeof initialValue === 'function' ? initialValue() : initialValue;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
function useLexicalDecoratorMap(decoratorMap, key, initialValue) {
|
|
54
|
-
const [latestValue, setReactValue] = react.useState(() => getInitialMapValue(decoratorMap, key, initialValue));
|
|
55
|
-
const [, triggerUpdate] = react.useState();
|
|
56
|
-
useLayoutEffect(() => {
|
|
57
|
-
const prevValue = decoratorMap.get(key);
|
|
58
|
-
|
|
59
|
-
if (prevValue !== latestValue) {
|
|
60
|
-
decoratorMap.set(key, latestValue);
|
|
61
|
-
}
|
|
62
|
-
}, [key, latestValue, decoratorMap]);
|
|
63
|
-
useLayoutEffect(() => {
|
|
64
|
-
if (lexical.isDecoratorArray(latestValue)) {
|
|
65
|
-
return latestValue.observe(() => {
|
|
66
|
-
triggerUpdate({});
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
}, [latestValue]);
|
|
70
|
-
useLayoutEffect(() => {
|
|
71
|
-
return decoratorMap.observe((changedKey, value) => {
|
|
72
|
-
if (changedKey === key) {
|
|
73
|
-
decoratorMap._map.set(changedKey, value);
|
|
74
|
-
|
|
75
|
-
setReactValue(value);
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
|
-
}, [decoratorMap, key]); // $FlowFixMe: needs refining
|
|
79
|
-
|
|
80
|
-
return [latestValue, setReactValue];
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
module.exports = useLexicalDecoratorMap;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/
|
|
7
|
-
'use strict'
|
|
8
|
-
const useLexicalDecoratorMap = process.env.NODE_ENV === 'development' ? require('./useLexicalDecoratorMap.dev.js') : require('./useLexicalDecoratorMap.prod.js')
|
|
9
|
-
module.exports = useLexicalDecoratorMap;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
* @flow strict
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
import type {DecoratorMap, DecoratorStateValue} from 'lexical';
|
|
11
|
-
|
|
12
|
-
declare export default function useLexicalDecoratorMap<V: DecoratorStateValue>(
|
|
13
|
-
decoratorMap: DecoratorMap,
|
|
14
|
-
key: string,
|
|
15
|
-
initialValue: (() => V) | V,
|
|
16
|
-
): [V, (DecoratorStateValue) => void];
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/
|
|
7
|
-
var e=require("lexical"),f=require("react"),l="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?f.useLayoutEffect:f.useEffect;
|
|
8
|
-
module.exports=function(a,d,g){const [b,h]=f.useState(()=>{var c=a.get(d);c=void 0!==c?c:"function"===typeof g?g():g;return c}),[,m]=f.useState();l(()=>{a.get(d)!==b&&a.set(d,b)},[d,b,a]);l(()=>{if(e.isDecoratorArray(b))return b.observe(()=>{m({})})},[b]);l(()=>a.observe((c,k)=>{c===d&&(a._map.set(c,k),h(k))}),[a,d]);return[b,h]};
|