@lexical/react 0.2.9 → 0.3.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.dev.js +55 -4
- package/DEPRECATED_useLexical.js.flow +23 -0
- package/DEPRECATED_useLexical.prod.js +3 -1
- package/DEPRECATED_useLexicalAutoFormatter.dev.js +1 -2
- package/DEPRECATED_useLexicalAutoFormatter.js.flow +12 -0
- package/DEPRECATED_useLexicalAutoFormatter.prod.js +1 -1
- package/DEPRECATED_useLexicalCanShowPlaceholder.dev.js +6 -8
- package/DEPRECATED_useLexicalCanShowPlaceholder.js.flow +12 -0
- package/DEPRECATED_useLexicalCanShowPlaceholder.prod.js +2 -1
- package/DEPRECATED_useLexicalCharacterLimit.dev.js +5 -3
- package/DEPRECATED_useLexicalCharacterLimit.js.flow +28 -0
- package/DEPRECATED_useLexicalCharacterLimit.prod.js +6 -6
- package/DEPRECATED_useLexicalDecorators.dev.js +7 -5
- package/DEPRECATED_useLexicalDecorators.js.flow +14 -0
- package/DEPRECATED_useLexicalDecorators.prod.js +2 -2
- package/DEPRECATED_useLexicalEditor.dev.js +55 -3
- package/DEPRECATED_useLexicalEditor.prod.js +2 -1
- package/DEPRECATED_useLexicalEditorEvents.dev.js +1 -5
- package/DEPRECATED_useLexicalEditorEvents.js.flow +19 -0
- package/DEPRECATED_useLexicalEditorEvents.prod.js +2 -2
- package/DEPRECATED_useLexicalHistory.dev.js +0 -2
- package/DEPRECATED_useLexicalHistory.js.flow +31 -0
- package/DEPRECATED_useLexicalHistory.prod.js +1 -1
- package/DEPRECATED_useLexicalList.dev.js +3 -5
- package/DEPRECATED_useLexicalList.js.flow +10 -0
- package/DEPRECATED_useLexicalList.prod.js +2 -2
- package/DEPRECATED_useLexicalPlainText.dev.js +1 -7
- package/DEPRECATED_useLexicalPlainText.js.flow +15 -0
- package/DEPRECATED_useLexicalPlainText.prod.js +2 -2
- package/DEPRECATED_useLexicalRichText.dev.js +1 -7
- package/DEPRECATED_useLexicalRichText.js.flow +15 -0
- package/DEPRECATED_useLexicalRichText.prod.js +2 -2
- package/LexicalAutoFocusPlugin.d.ts +1 -1
- package/LexicalAutoFocusPlugin.dev.js +17 -4
- package/LexicalAutoFocusPlugin.js.flow +1 -1
- package/LexicalAutoFocusPlugin.prod.js +1 -1
- package/LexicalAutoLinkPlugin.d.ts +1 -1
- package/LexicalAutoLinkPlugin.dev.js +4 -5
- package/LexicalAutoLinkPlugin.js.flow +2 -1
- package/LexicalAutoLinkPlugin.prod.js +5 -5
- package/LexicalAutoScrollPlugin.d.ts +1 -1
- package/LexicalAutoScrollPlugin.dev.js +2 -5
- package/LexicalAutoScrollPlugin.js.flow +1 -3
- package/LexicalAutoScrollPlugin.prod.js +2 -2
- package/LexicalBlockWithAlignableContents.d.ts +1 -3
- package/LexicalBlockWithAlignableContents.dev.js +7 -9
- package/LexicalBlockWithAlignableContents.prod.js +4 -4
- package/LexicalCharacterLimitPlugin.d.ts +1 -1
- package/LexicalCharacterLimitPlugin.dev.js +6 -5
- package/LexicalCharacterLimitPlugin.js.flow +1 -1
- package/LexicalCharacterLimitPlugin.prod.js +8 -8
- package/LexicalCheckListPlugin.d.ts +1 -1
- package/LexicalCheckListPlugin.dev.js +7 -15
- package/LexicalCheckListPlugin.js.flow +1 -1
- package/LexicalCheckListPlugin.prod.js +7 -7
- package/LexicalClearEditorPlugin.d.ts +2 -6
- package/LexicalClearEditorPlugin.dev.js +2 -5
- package/LexicalClearEditorPlugin.js.flow +1 -1
- package/LexicalClearEditorPlugin.prod.js +2 -2
- package/LexicalCollaborationPlugin.d.ts +1 -0
- package/LexicalCollaborationPlugin.dev.js +9 -5
- package/LexicalCollaborationPlugin.prod.js +9 -9
- package/LexicalComposer.d.ts +2 -2
- package/LexicalComposer.dev.js +1 -6
- package/LexicalComposer.js.flow +1 -1
- package/LexicalComposer.prod.js +2 -2
- package/LexicalComposerContext.dev.js +0 -1
- package/LexicalComposerContext.prod.js +1 -1
- package/LexicalContentEditable.d.ts +2 -5
- package/LexicalContentEditable.dev.js +5 -7
- package/LexicalContentEditable.js.flow +1 -3
- package/LexicalContentEditable.prod.js +3 -3
- package/LexicalDecoratorBlockNode.d.ts +11 -2
- package/LexicalDecoratorBlockNode.dev.js +8 -1
- package/LexicalDecoratorBlockNode.prod.js +1 -1
- package/LexicalHashtagPlugin.d.ts +1 -1
- package/LexicalHashtagPlugin.dev.js +2 -3
- package/LexicalHashtagPlugin.js.flow +1 -1
- package/LexicalHashtagPlugin.prod.js +3 -3
- package/LexicalHistoryPlugin.d.ts +1 -0
- package/LexicalHistoryPlugin.dev.js +0 -2
- package/LexicalHistoryPlugin.prod.js +1 -1
- package/LexicalHorizontalRuleNode.d.ts +1 -1
- package/LexicalHorizontalRuleNode.dev.js +11 -1
- package/LexicalHorizontalRuleNode.prod.js +3 -3
- package/LexicalLinkPlugin.d.ts +1 -1
- package/LexicalLinkPlugin.dev.js +3 -107
- package/LexicalLinkPlugin.js.flow +1 -1
- package/LexicalLinkPlugin.prod.js +1 -4
- package/LexicalListPlugin.d.ts +1 -1
- package/LexicalListPlugin.dev.js +9 -6
- package/LexicalListPlugin.js.flow +1 -1
- package/LexicalListPlugin.prod.js +3 -3
- package/LexicalMarkdownShortcutPlugin.d.ts +2 -2
- package/LexicalMarkdownShortcutPlugin.dev.js +7 -83
- package/LexicalMarkdownShortcutPlugin.js.flow +2 -2
- package/LexicalMarkdownShortcutPlugin.prod.js +2 -3
- package/LexicalNestedComposer.d.ts +1 -1
- package/LexicalNestedComposer.dev.js +1 -2
- package/LexicalNestedComposer.js.flow +1 -1
- package/LexicalNestedComposer.prod.js +3 -3
- package/LexicalOnChangePlugin.d.ts +2 -1
- package/LexicalOnChangePlugin.dev.js +1 -4
- package/LexicalOnChangePlugin.js.flow +1 -1
- package/LexicalOnChangePlugin.prod.js +2 -2
- package/LexicalPlainTextPlugin.d.ts +3 -2
- package/LexicalPlainTextPlugin.dev.js +12 -10
- package/LexicalPlainTextPlugin.js.flow +1 -1
- package/LexicalPlainTextPlugin.prod.js +4 -4
- package/LexicalRichTextPlugin.d.ts +3 -2
- package/LexicalRichTextPlugin.dev.js +12 -10
- package/LexicalRichTextPlugin.js.flow +1 -1
- package/LexicalRichTextPlugin.prod.js +4 -4
- package/LexicalTablePlugin.d.ts +1 -1
- package/LexicalTablePlugin.dev.js +7 -8
- package/LexicalTablePlugin.js.flow +1 -1
- package/LexicalTablePlugin.prod.js +4 -4
- package/LexicalTreeView.d.ts +2 -1
- package/LexicalTreeView.dev.js +4 -5
- package/LexicalTreeView.js.flow +1 -1
- package/LexicalTreeView.prod.js +11 -11
- package/README.md +10 -6
- package/package.json +19 -19
- package/useLexicalIsTextContentEmpty.d.ts +2 -1
- package/useLexicalIsTextContentEmpty.dev.js +2 -5
- package/useLexicalIsTextContentEmpty.js.flow +1 -1
- package/useLexicalIsTextContentEmpty.prod.js +1 -1
- package/useLexicalNodeSelection.d.ts +2 -1
- package/useLexicalNodeSelection.dev.js +1 -2
- package/useLexicalNodeSelection.js.flow +1 -1
- package/useLexicalNodeSelection.prod.js +2 -2
- package/useLexicalTextEntity.d.ts +2 -1
- package/useLexicalTextEntity.dev.js +1 -2
- package/useLexicalTextEntity.js.flow +1 -1
- package/useLexicalTextEntity.prod.js +1 -1
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
import type {LexicalNode, LexicalCommand} from 'lexical';
|
|
10
10
|
import {DecoratorNode} from 'lexical';
|
|
11
|
+
|
|
11
12
|
export declare class HorizontalRuleNode extends DecoratorNode<JSX.Element | null> {
|
|
12
13
|
static getType(): string;
|
|
13
14
|
static clone(node: HorizontalRuleNode): HorizontalRuleNode;
|
|
@@ -21,5 +22,4 @@ export function $createHorizontalRuleNode(): HorizontalRuleNode;
|
|
|
21
22
|
export function $isHorizontalRuleNode(
|
|
22
23
|
node: LexicalNode | null | undefined,
|
|
23
24
|
): node is HorizontalRuleNode;
|
|
24
|
-
|
|
25
25
|
export var INSERT_HORIZONTAL_RULE_COMMAND: LexicalCommand<void>;
|
|
@@ -15,7 +15,6 @@ var React = require('react');
|
|
|
15
15
|
* This source code is licensed under the MIT license found in the
|
|
16
16
|
* LICENSE file in the root directory of this source tree.
|
|
17
17
|
*
|
|
18
|
-
*
|
|
19
18
|
*/
|
|
20
19
|
const INSERT_HORIZONTAL_RULE_COMMAND = lexical.createCommand();
|
|
21
20
|
|
|
@@ -47,6 +46,17 @@ class HorizontalRuleNode extends lexical.DecoratorNode {
|
|
|
47
46
|
};
|
|
48
47
|
}
|
|
49
48
|
|
|
49
|
+
static importJSON(serializedNode) {
|
|
50
|
+
return $createHorizontalRuleNode();
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
exportJSON() {
|
|
54
|
+
return {
|
|
55
|
+
type: 'horizontalrule',
|
|
56
|
+
version: 1
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
|
|
50
60
|
createDOM() {
|
|
51
61
|
const div = document.createElement('div');
|
|
52
62
|
div.style.display = 'contents';
|
|
@@ -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 b=require("lexical"),c=require("react");
|
|
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(){
|
|
9
|
-
exports.$createHorizontalRuleNode=h;exports.$isHorizontalRuleNode=function(a){return a instanceof f};exports.HorizontalRuleNode=f;exports.INSERT_HORIZONTAL_RULE_COMMAND=d
|
|
7
|
+
'use strict';var b=require("lexical"),c=require("react");let 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.__key)}static importDOM(){return{hr:()=>({conversion:g,priority:0})}}exportDOM(){return{element:document.createElement("hr")}}static importJSON(){return h()}exportJSON(){return{type:"horizontalrule",version:1}}createDOM(){let a=document.createElement("div");a.style.display="contents";return a}getTextContent(){return"\n"}isTopLevel(){return!0}updateDOM(){return!1}decorate(){return c.createElement(e,
|
|
9
|
+
null)}}function g(){return{node:h()}}function h(){return new f}exports.$createHorizontalRuleNode=h;exports.$isHorizontalRuleNode=function(a){return a instanceof f};exports.HorizontalRuleNode=f;exports.INSERT_HORIZONTAL_RULE_COMMAND=d
|
package/LexicalLinkPlugin.d.ts
CHANGED
package/LexicalLinkPlugin.dev.js
CHANGED
|
@@ -16,110 +16,7 @@ var react = require('react');
|
|
|
16
16
|
*
|
|
17
17
|
* This source code is licensed under the MIT license found in the
|
|
18
18
|
* LICENSE file in the root directory of this source tree.
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
19
|
*/
|
|
22
|
-
|
|
23
|
-
function toggleLink(url) {
|
|
24
|
-
const selection = lexical.$getSelection();
|
|
25
|
-
|
|
26
|
-
if (selection !== null) {
|
|
27
|
-
lexical.$setSelection(selection);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const sel = lexical.$getSelection();
|
|
31
|
-
|
|
32
|
-
if (sel !== null) {
|
|
33
|
-
const nodes = sel.extract();
|
|
34
|
-
|
|
35
|
-
if (url === null) {
|
|
36
|
-
// Remove LinkNodes
|
|
37
|
-
nodes.forEach(node => {
|
|
38
|
-
const parent = node.getParent();
|
|
39
|
-
|
|
40
|
-
if (link.$isLinkNode(parent)) {
|
|
41
|
-
const children = parent.getChildren();
|
|
42
|
-
|
|
43
|
-
for (let i = 0; i < children.length; i++) {
|
|
44
|
-
parent.insertBefore(children[i]);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
parent.remove();
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
} else {
|
|
51
|
-
// Add or merge LinkNodes
|
|
52
|
-
if (nodes.length === 1) {
|
|
53
|
-
const firstNode = nodes[0]; // if the first node is a LinkNode or if its
|
|
54
|
-
// parent is a LinkNode, we update the URL.
|
|
55
|
-
|
|
56
|
-
if (link.$isLinkNode(firstNode)) {
|
|
57
|
-
firstNode.setURL(url);
|
|
58
|
-
return;
|
|
59
|
-
} else {
|
|
60
|
-
const parent = firstNode.getParent();
|
|
61
|
-
|
|
62
|
-
if (link.$isLinkNode(parent)) {
|
|
63
|
-
// set parent to be the current linkNode
|
|
64
|
-
// so that other nodes in the same parent
|
|
65
|
-
// aren't handled separately below.
|
|
66
|
-
parent.setURL(url);
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
let prevParent = null;
|
|
73
|
-
let linkNode = null;
|
|
74
|
-
nodes.forEach(node => {
|
|
75
|
-
const parent = node.getParent();
|
|
76
|
-
|
|
77
|
-
if (parent === linkNode || parent === null || lexical.$isElementNode(node) && !node.isInline()) {
|
|
78
|
-
return;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
if (link.$isLinkNode(parent)) {
|
|
82
|
-
linkNode = parent;
|
|
83
|
-
parent.setURL(url);
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
if (!parent.is(prevParent)) {
|
|
88
|
-
prevParent = parent;
|
|
89
|
-
linkNode = link.$createLinkNode(url);
|
|
90
|
-
|
|
91
|
-
if (link.$isLinkNode(parent)) {
|
|
92
|
-
if (node.getPreviousSibling() === null) {
|
|
93
|
-
parent.insertBefore(linkNode);
|
|
94
|
-
} else {
|
|
95
|
-
parent.insertAfter(linkNode);
|
|
96
|
-
}
|
|
97
|
-
} else {
|
|
98
|
-
node.insertBefore(linkNode);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
if (link.$isLinkNode(node)) {
|
|
103
|
-
if (linkNode !== null) {
|
|
104
|
-
const children = node.getChildren();
|
|
105
|
-
|
|
106
|
-
for (let i = 0; i < children.length; i++) {
|
|
107
|
-
linkNode.append(children[i]);
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
node.remove();
|
|
112
|
-
return;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
if (linkNode !== null) {
|
|
116
|
-
linkNode.append(node);
|
|
117
|
-
}
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
|
|
123
20
|
function LinkPlugin() {
|
|
124
21
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
125
22
|
react.useEffect(() => {
|
|
@@ -128,13 +25,12 @@ function LinkPlugin() {
|
|
|
128
25
|
}
|
|
129
26
|
}, [editor]);
|
|
130
27
|
react.useEffect(() => {
|
|
131
|
-
return editor.registerCommand(link.TOGGLE_LINK_COMMAND,
|
|
132
|
-
|
|
133
|
-
toggleLink(url);
|
|
28
|
+
return editor.registerCommand(link.TOGGLE_LINK_COMMAND, url => {
|
|
29
|
+
link.toggleLink(url);
|
|
134
30
|
return true;
|
|
135
31
|
}, lexical.COMMAND_PRIORITY_EDITOR);
|
|
136
32
|
}, [editor]);
|
|
137
33
|
return null;
|
|
138
34
|
}
|
|
139
35
|
|
|
140
|
-
|
|
36
|
+
exports.LinkPlugin = LinkPlugin;
|
|
@@ -4,7 +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
|
-
var
|
|
8
|
-
function p(e){var d=m.$getSelection();null!==d&&m.$setSelection(d);d=m.$getSelection();if(null!==d)if(d=d.extract(),null===e)d.forEach(g=>{g=g.getParent();if(f.$isLinkNode(g)){const a=g.getChildren();for(let b=0;b<a.length;b++)g.insertBefore(a[b]);g.remove()}});else{if(1===d.length){var h=d[0];if(f.$isLinkNode(h)){h.setURL(e);return}h=h.getParent();if(f.$isLinkNode(h)){h.setURL(e);return}}let g=null,a=null;d.forEach(b=>{var c=b.getParent();if(c!==a&&null!==c&&(!m.$isElementNode(b)||b.isInline()))if(f.$isLinkNode(c))a=
|
|
9
|
-
c,c.setURL(e);else if(c.is(g)||(g=c,a=f.$createLinkNode(e),f.$isLinkNode(c)?null===b.getPreviousSibling()?c.insertBefore(a):c.insertAfter(a):b.insertBefore(a)),f.$isLinkNode(b)){if(null!==a){c=b.getChildren();for(let l=0;l<c.length;l++)a.append(c[l])}b.remove()}else null!==a&&a.append(b)})}}
|
|
10
|
-
module.exports=function(){const [e]=k.useLexicalComposerContext();n.useEffect(()=>{if(!e.hasNodes([f.LinkNode]))throw Error("LinkPlugin: LinkNode not registered on editor");},[e]);n.useEffect(()=>e.registerCommand(f.TOGGLE_LINK_COMMAND,d=>{p(d);return!0},m.COMMAND_PRIORITY_EDITOR),[e]);return null};
|
|
7
|
+
'use strict';var b=require("@lexical/link"),c=require("@lexical/react/LexicalComposerContext"),d=require("lexical"),e=require("react");exports.LinkPlugin=function(){let [a]=c.useLexicalComposerContext();e.useEffect(()=>{if(!a.hasNodes([b.LinkNode]))throw Error("LinkPlugin: LinkNode not registered on editor");},[a]);e.useEffect(()=>a.registerCommand(b.TOGGLE_LINK_COMMAND,f=>{b.toggleLink(f);return!0},d.COMMAND_PRIORITY_EDITOR),[a]);return null}
|
package/LexicalListPlugin.d.ts
CHANGED
package/LexicalListPlugin.dev.js
CHANGED
|
@@ -6,19 +6,18 @@
|
|
|
6
6
|
*/
|
|
7
7
|
'use strict';
|
|
8
8
|
|
|
9
|
-
var LexicalComposerContext = require('@lexical/react/LexicalComposerContext');
|
|
10
9
|
var list = require('@lexical/list');
|
|
10
|
+
var LexicalComposerContext = require('@lexical/react/LexicalComposerContext');
|
|
11
|
+
var react = require('react');
|
|
11
12
|
var utils = require('@lexical/utils');
|
|
12
13
|
var lexical = require('lexical');
|
|
13
|
-
var react = require('react');
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
|
-
* Copyright (c)
|
|
16
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
17
17
|
*
|
|
18
18
|
* This source code is licensed under the MIT license found in the
|
|
19
19
|
* LICENSE file in the root directory of this source tree.
|
|
20
20
|
*
|
|
21
|
-
*
|
|
22
21
|
*/
|
|
23
22
|
function useList(editor) {
|
|
24
23
|
react.useEffect(() => {
|
|
@@ -55,12 +54,16 @@ function useList(editor) {
|
|
|
55
54
|
* This source code is licensed under the MIT license found in the
|
|
56
55
|
* LICENSE file in the root directory of this source tree.
|
|
57
56
|
*
|
|
58
|
-
*
|
|
59
57
|
*/
|
|
60
58
|
function ListPlugin() {
|
|
61
59
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
60
|
+
react.useEffect(() => {
|
|
61
|
+
if (!editor.hasNodes([list.ListNode, list.ListItemNode])) {
|
|
62
|
+
throw new Error('ListPlugin: ListNode and/or ListItemNode not registered on editor');
|
|
63
|
+
}
|
|
64
|
+
}, [editor]);
|
|
62
65
|
useList(editor);
|
|
63
66
|
return null;
|
|
64
67
|
}
|
|
65
68
|
|
|
66
|
-
|
|
69
|
+
exports.ListPlugin = ListPlugin;
|
|
@@ -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 b=require("@lexical/
|
|
8
|
-
function g(a){
|
|
9
|
-
()=>{
|
|
7
|
+
'use strict';var b=require("@lexical/list"),c=require("@lexical/react/LexicalComposerContext"),d=require("react"),e=require("@lexical/utils"),f=require("lexical");
|
|
8
|
+
function g(a){d.useEffect(()=>e.mergeRegister(a.registerCommand(f.INDENT_CONTENT_COMMAND,()=>{b.indentList();return!1},f.COMMAND_PRIORITY_LOW),a.registerCommand(f.OUTDENT_CONTENT_COMMAND,()=>{b.outdentList();return!1},f.COMMAND_PRIORITY_LOW),a.registerCommand(b.INSERT_ORDERED_LIST_COMMAND,()=>{b.insertList(a,"number");return!0},f.COMMAND_PRIORITY_LOW),a.registerCommand(b.INSERT_UNORDERED_LIST_COMMAND,()=>{b.insertList(a,"bullet");return!0},f.COMMAND_PRIORITY_LOW),a.registerCommand(b.REMOVE_LIST_COMMAND,
|
|
9
|
+
()=>{b.removeList(a);return!0},f.COMMAND_PRIORITY_LOW),a.registerCommand(f.INSERT_PARAGRAPH_COMMAND,()=>b.$handleListInsertParagraph()?!0:!1,f.COMMAND_PRIORITY_LOW)),[a])}exports.ListPlugin=function(){let [a]=c.useLexicalComposerContext();d.useEffect(()=>{if(!a.hasNodes([b.ListNode,b.ListItemNode]))throw Error("ListPlugin: ListNode and/or ListItemNode not registered on editor");},[a]);g(a);return null}
|
|
@@ -8,6 +8,6 @@
|
|
|
8
8
|
|
|
9
9
|
import type {Transformer} from '@lexical/markdown';
|
|
10
10
|
|
|
11
|
-
export
|
|
12
|
-
transformers
|
|
11
|
+
export function MarkdownShortcutPlugin(arg0: {
|
|
12
|
+
transformers?: Array<Transformer>;
|
|
13
13
|
}): JSX.Element | null;
|
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
|
|
9
9
|
var markdown = require('@lexical/markdown');
|
|
10
10
|
var LexicalComposerContext = require('@lexical/react/LexicalComposerContext');
|
|
11
|
-
var
|
|
12
|
-
var
|
|
11
|
+
var LexicalHorizontalRuleNode = require('@lexical/react/LexicalHorizontalRuleNode');
|
|
12
|
+
var react = require('react');
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
@@ -17,90 +17,14 @@ var lexical = require('lexical');
|
|
|
17
17
|
* This source code is licensed under the MIT license found in the
|
|
18
18
|
* LICENSE file in the root directory of this source tree.
|
|
19
19
|
*
|
|
20
|
-
*
|
|
21
|
-
*/
|
|
22
|
-
lexical.createCommand();
|
|
23
|
-
|
|
24
|
-
function HorizontalRuleComponent() {
|
|
25
|
-
return /*#__PURE__*/React.createElement("hr", null);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
class HorizontalRuleNode extends lexical.DecoratorNode {
|
|
29
|
-
static getType() {
|
|
30
|
-
return 'horizontalrule';
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
static clone(node) {
|
|
34
|
-
return new HorizontalRuleNode(node.__key);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
static importDOM() {
|
|
38
|
-
return {
|
|
39
|
-
hr: node => ({
|
|
40
|
-
conversion: convertHorizontalRuleElement,
|
|
41
|
-
priority: 0
|
|
42
|
-
})
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
exportDOM() {
|
|
47
|
-
return {
|
|
48
|
-
element: document.createElement('hr')
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
createDOM() {
|
|
53
|
-
const div = document.createElement('div');
|
|
54
|
-
div.style.display = 'contents';
|
|
55
|
-
return div;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
getTextContent() {
|
|
59
|
-
return '\n';
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
isTopLevel() {
|
|
63
|
-
return true;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
updateDOM() {
|
|
67
|
-
return false;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
decorate() {
|
|
71
|
-
return /*#__PURE__*/React.createElement(HorizontalRuleComponent, null);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
function convertHorizontalRuleElement() {
|
|
77
|
-
return {
|
|
78
|
-
node: $createHorizontalRuleNode()
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
function $createHorizontalRuleNode() {
|
|
83
|
-
return new HorizontalRuleNode();
|
|
84
|
-
}
|
|
85
|
-
function $isHorizontalRuleNode(node) {
|
|
86
|
-
return node instanceof HorizontalRuleNode;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
91
|
-
*
|
|
92
|
-
* This source code is licensed under the MIT license found in the
|
|
93
|
-
* LICENSE file in the root directory of this source tree.
|
|
94
|
-
*
|
|
95
|
-
*
|
|
96
20
|
*/
|
|
97
21
|
const HR = {
|
|
98
22
|
export: node => {
|
|
99
|
-
return
|
|
23
|
+
return LexicalHorizontalRuleNode.$isHorizontalRuleNode(node) ? '***' : null;
|
|
100
24
|
},
|
|
101
25
|
regExp: /^(---|\*\*\*|___)\s?$/,
|
|
102
26
|
replace: (parentNode, _1, _2, isImport) => {
|
|
103
|
-
const line =
|
|
27
|
+
const line = LexicalHorizontalRuleNode.$createHorizontalRuleNode(); // TODO: Get rid of isImport flag
|
|
104
28
|
|
|
105
29
|
if (isImport || parentNode.getNextSibling() != null) {
|
|
106
30
|
parentNode.replace(line);
|
|
@@ -113,14 +37,14 @@ const HR = {
|
|
|
113
37
|
type: 'element'
|
|
114
38
|
};
|
|
115
39
|
const DEFAULT_TRANSFORMERS = [HR, ...markdown.TRANSFORMERS];
|
|
116
|
-
function
|
|
40
|
+
function MarkdownShortcutPlugin({
|
|
117
41
|
transformers = DEFAULT_TRANSFORMERS
|
|
118
42
|
}) {
|
|
119
43
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
120
|
-
|
|
44
|
+
react.useEffect(() => {
|
|
121
45
|
return markdown.registerMarkdownShortcuts(editor, transformers);
|
|
122
46
|
}, [editor, transformers]);
|
|
123
47
|
return null;
|
|
124
48
|
}
|
|
125
49
|
|
|
126
|
-
|
|
50
|
+
exports.MarkdownShortcutPlugin = MarkdownShortcutPlugin;
|
|
@@ -9,6 +9,6 @@
|
|
|
9
9
|
|
|
10
10
|
import type {Transformer} from '@lexical/markdown';
|
|
11
11
|
|
|
12
|
-
declare export
|
|
13
|
-
transformers
|
|
12
|
+
declare export function MarkdownShortcutPlugin({
|
|
13
|
+
transformers?: Array<Transformer>,
|
|
14
14
|
}): React$Node;
|
|
@@ -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
|
-
var c=require("@lexical/markdown"),d=require("@lexical/react/LexicalComposerContext"),e=require("react"),f=require("
|
|
8
|
-
|
|
9
|
-
const m=[{export:a=>a instanceof h?"***":null,regExp:/^(---|\*\*\*|___)\s?$/,replace:(a,b,n,l)=>{b=new h;l||null!=a.getNextSibling()?a.replace(b):a.insertBefore(b);b.selectNext()},type:"element"},...c.TRANSFORMERS];module.exports=function({transformers:a=m}){const [b]=d.useLexicalComposerContext();e.useEffect(()=>c.registerMarkdownShortcuts(b,a),[b,a]);return null};
|
|
7
|
+
'use strict';var c=require("@lexical/markdown"),d=require("@lexical/react/LexicalComposerContext"),e=require("@lexical/react/LexicalHorizontalRuleNode"),f=require("react");let h=[{export:a=>e.$isHorizontalRuleNode(a)?"***":null,regExp:/^(---|\*\*\*|___)\s?$/,replace:(a,b,k,g)=>{b=e.$createHorizontalRuleNode();g||null!=a.getNextSibling()?a.replace(b):a.insertBefore(b);b.selectNext()},type:"element"},...c.TRANSFORMERS];
|
|
8
|
+
exports.MarkdownShortcutPlugin=function({transformers:a=h}){let [b]=d.useLexicalComposerContext();f.useEffect(()=>c.registerMarkdownShortcuts(b,a),[b,a]);return null}
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
import type {LexicalEditor, EditorThemeClasses} from 'lexical';
|
|
10
10
|
|
|
11
|
-
export
|
|
11
|
+
export function LexicalNestedComposer(arg0: {
|
|
12
12
|
initialEditor: LexicalEditor;
|
|
13
13
|
initialTheme?: EditorThemeClasses;
|
|
14
14
|
children: JSX.Element | (JSX.Element | string | null)[] | null;
|
|
@@ -16,7 +16,6 @@ var React = require('react');
|
|
|
16
16
|
* This source code is licensed under the MIT license found in the
|
|
17
17
|
* LICENSE file in the root directory of this source tree.
|
|
18
18
|
*
|
|
19
|
-
*
|
|
20
19
|
*/
|
|
21
20
|
function LexicalNestedComposer({
|
|
22
21
|
initialEditor,
|
|
@@ -58,4 +57,4 @@ function LexicalNestedComposer({
|
|
|
58
57
|
}, !isCollab || isCollabReady ? children : null);
|
|
59
58
|
}
|
|
60
59
|
|
|
61
|
-
|
|
60
|
+
exports.LexicalNestedComposer = LexicalNestedComposer;
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
import type {LexicalEditor, EditorThemeClasses, LexicalNode} from 'lexical';
|
|
11
11
|
|
|
12
|
-
declare export
|
|
12
|
+
declare export function LexicalNestedComposer({
|
|
13
13
|
children: React$Node,
|
|
14
14
|
initialEditor: LexicalEditor,
|
|
15
15
|
initialTheme?: EditorThemeClasses,
|
|
@@ -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 c=require("@lexical/react/LexicalCollaborationPlugin"),d=require("@lexical/react/LexicalComposerContext"),h=require("react");
|
|
8
|
-
|
|
9
|
-
|
|
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; see codes.json for the full message or use the non-minified dev environment for full errors and additional helpful warnings.");let 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}=
|
|
9
|
+
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)}
|
|
@@ -7,7 +7,8 @@
|
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import type {EditorState, LexicalEditor} from 'lexical';
|
|
10
|
-
|
|
10
|
+
|
|
11
|
+
export function OnChangePlugin(arg0: {
|
|
11
12
|
ignoreInitialChange?: boolean;
|
|
12
13
|
ignoreSelectionChange?: boolean;
|
|
13
14
|
onChange: (editorState: EditorState, editor: LexicalEditor) => void;
|
|
@@ -15,7 +15,6 @@ var react = require('react');
|
|
|
15
15
|
* This source code is licensed under the MIT license found in the
|
|
16
16
|
* LICENSE file in the root directory of this source tree.
|
|
17
17
|
*
|
|
18
|
-
*
|
|
19
18
|
*/
|
|
20
19
|
const CAN_USE_DOM = typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined';
|
|
21
20
|
|
|
@@ -25,7 +24,6 @@ const CAN_USE_DOM = typeof window !== 'undefined' && typeof window.document !==
|
|
|
25
24
|
* This source code is licensed under the MIT license found in the
|
|
26
25
|
* LICENSE file in the root directory of this source tree.
|
|
27
26
|
*
|
|
28
|
-
*
|
|
29
27
|
*/
|
|
30
28
|
const useLayoutEffectImpl = CAN_USE_DOM ? react.useLayoutEffect : react.useEffect;
|
|
31
29
|
var useLayoutEffect = useLayoutEffectImpl;
|
|
@@ -36,7 +34,6 @@ var useLayoutEffect = useLayoutEffectImpl;
|
|
|
36
34
|
* This source code is licensed under the MIT license found in the
|
|
37
35
|
* LICENSE file in the root directory of this source tree.
|
|
38
36
|
*
|
|
39
|
-
*
|
|
40
37
|
*/
|
|
41
38
|
function OnChangePlugin({
|
|
42
39
|
ignoreInitialChange = true,
|
|
@@ -67,4 +64,4 @@ function OnChangePlugin({
|
|
|
67
64
|
return null;
|
|
68
65
|
}
|
|
69
66
|
|
|
70
|
-
|
|
67
|
+
exports.OnChangePlugin = OnChangePlugin;
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
import type {EditorState, LexicalEditor} from 'lexical';
|
|
11
11
|
|
|
12
|
-
declare export
|
|
12
|
+
declare export function OnChangePlugin({
|
|
13
13
|
ignoreInitialChange?: boolean,
|
|
14
14
|
ignoreSelectionChange?: boolean,
|
|
15
15
|
onChange: (editorState: EditorState, editor: LexicalEditor) => void,
|
|
@@ -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
|
-
var c=require("@lexical/react/LexicalComposerContext"),f=require("react"),g="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?f.useLayoutEffect:f.useEffect;
|
|
8
|
-
|
|
7
|
+
'use strict';var c=require("@lexical/react/LexicalComposerContext"),f=require("react"),g="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?f.useLayoutEffect:f.useEffect;
|
|
8
|
+
exports.OnChangePlugin=function({ignoreInitialChange:d=!0,ignoreSelectionChange:e=!1,onChange:a}){let [b]=c.useLexicalComposerContext();g(()=>{if(a)return b.registerUpdateListener(({editorState:h,dirtyElements:k,dirtyLeaves:l,prevEditorState:m})=>{e&&0===k.size&&0===l.size||d&&m.isEmpty()||a(h,b)})},[b,d,e,a]);return null}
|
|
@@ -7,9 +7,10 @@
|
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import type {EditorState} from 'lexical';
|
|
10
|
+
|
|
10
11
|
type InitialEditorStateType = null | string | EditorState | (() => void);
|
|
11
|
-
export
|
|
12
|
+
export function PlainTextPlugin(arg0: {
|
|
12
13
|
contentEditable: JSX.Element | null;
|
|
13
14
|
initialEditorState?: InitialEditorStateType;
|
|
14
|
-
placeholder: JSX.Element | null;
|
|
15
|
+
placeholder: JSX.Element | string | null;
|
|
15
16
|
}): JSX.Element | null;
|
|
@@ -20,7 +20,6 @@ var utils = require('@lexical/utils');
|
|
|
20
20
|
* This source code is licensed under the MIT license found in the
|
|
21
21
|
* LICENSE file in the root directory of this source tree.
|
|
22
22
|
*
|
|
23
|
-
*
|
|
24
23
|
*/
|
|
25
24
|
const CAN_USE_DOM = typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined';
|
|
26
25
|
|
|
@@ -30,7 +29,6 @@ const CAN_USE_DOM = typeof window !== 'undefined' && typeof window.document !==
|
|
|
30
29
|
* This source code is licensed under the MIT license found in the
|
|
31
30
|
* LICENSE file in the root directory of this source tree.
|
|
32
31
|
*
|
|
33
|
-
*
|
|
34
32
|
*/
|
|
35
33
|
const useLayoutEffectImpl = CAN_USE_DOM ? React.useLayoutEffect : React.useEffect;
|
|
36
34
|
var useLayoutEffect = useLayoutEffectImpl;
|
|
@@ -41,16 +39,17 @@ var useLayoutEffect = useLayoutEffectImpl;
|
|
|
41
39
|
* This source code is licensed under the MIT license found in the
|
|
42
40
|
* LICENSE file in the root directory of this source tree.
|
|
43
41
|
*
|
|
44
|
-
*
|
|
45
42
|
*/
|
|
46
|
-
function
|
|
43
|
+
function useCanShowPlaceholder(editor) {
|
|
47
44
|
const [canShowPlaceholder, setCanShowPlaceholder] = React.useState(editor.getEditorState().read(text.$canShowPlaceholderCurry(editor.isComposing())));
|
|
48
45
|
useLayoutEffect(() => {
|
|
46
|
+
let currentCanShowPlaceholder = editor.getEditorState().read(text.$canShowPlaceholderCurry(editor.isComposing()));
|
|
47
|
+
setCanShowPlaceholder(currentCanShowPlaceholder);
|
|
49
48
|
return editor.registerUpdateListener(({
|
|
50
49
|
editorState
|
|
51
50
|
}) => {
|
|
52
51
|
const isComposing = editor.isComposing();
|
|
53
|
-
|
|
52
|
+
currentCanShowPlaceholder = editorState.read(text.$canShowPlaceholderCurry(isComposing));
|
|
54
53
|
setCanShowPlaceholder(currentCanShowPlaceholder);
|
|
55
54
|
});
|
|
56
55
|
}, [editor]);
|
|
@@ -63,7 +62,6 @@ function useLexicalCanShowPlaceholder(editor) {
|
|
|
63
62
|
* This source code is licensed under the MIT license found in the
|
|
64
63
|
* LICENSE file in the root directory of this source tree.
|
|
65
64
|
*
|
|
66
|
-
*
|
|
67
65
|
*/
|
|
68
66
|
function useDecorators(editor) {
|
|
69
67
|
const [decorators, setDecorators] = React.useState(() => editor.getDecorators()); // Subscribe to changes
|
|
@@ -74,6 +72,12 @@ function useDecorators(editor) {
|
|
|
74
72
|
setDecorators(nextDecorators);
|
|
75
73
|
});
|
|
76
74
|
});
|
|
75
|
+
}, [editor]);
|
|
76
|
+
React.useEffect(() => {
|
|
77
|
+
// If the content editable mounts before the subscription is added, then
|
|
78
|
+
// nothing will be rendered on initial pass. We can get around that by
|
|
79
|
+
// ensuring that we set the value.
|
|
80
|
+
setDecorators(editor.getDecorators());
|
|
77
81
|
}, [editor]); // Return decorators defined as React Portals
|
|
78
82
|
|
|
79
83
|
return React.useMemo(() => {
|
|
@@ -100,7 +104,6 @@ function useDecorators(editor) {
|
|
|
100
104
|
* This source code is licensed under the MIT license found in the
|
|
101
105
|
* LICENSE file in the root directory of this source tree.
|
|
102
106
|
*
|
|
103
|
-
*
|
|
104
107
|
*/
|
|
105
108
|
function usePlainTextSetup(editor, initialEditorState) {
|
|
106
109
|
useLayoutEffect(() => {
|
|
@@ -115,7 +118,6 @@ function usePlainTextSetup(editor, initialEditorState) {
|
|
|
115
118
|
* This source code is licensed under the MIT license found in the
|
|
116
119
|
* LICENSE file in the root directory of this source tree.
|
|
117
120
|
*
|
|
118
|
-
*
|
|
119
121
|
*/
|
|
120
122
|
function PlainTextPlugin({
|
|
121
123
|
contentEditable,
|
|
@@ -123,10 +125,10 @@ function PlainTextPlugin({
|
|
|
123
125
|
initialEditorState
|
|
124
126
|
}) {
|
|
125
127
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
126
|
-
const showPlaceholder =
|
|
128
|
+
const showPlaceholder = useCanShowPlaceholder(editor);
|
|
127
129
|
usePlainTextSetup(editor, initialEditorState);
|
|
128
130
|
const decorators = useDecorators(editor);
|
|
129
131
|
return /*#__PURE__*/React.createElement(React.Fragment, null, contentEditable, showPlaceholder && placeholder, decorators);
|
|
130
132
|
}
|
|
131
133
|
|
|
132
|
-
|
|
134
|
+
exports.PlainTextPlugin = PlainTextPlugin;
|
|
@@ -11,7 +11,7 @@ import type {EditorState} from 'lexical';
|
|
|
11
11
|
|
|
12
12
|
type InitialEditorStateType = null | string | EditorState | (() => void);
|
|
13
13
|
|
|
14
|
-
declare export
|
|
14
|
+
declare export function PlainTextPlugin({
|
|
15
15
|
contentEditable: React$Node,
|
|
16
16
|
initialEditorState?: InitialEditorStateType,
|
|
17
17
|
placeholder: React$Node,
|