@lexical/react 0.14.4 → 0.15.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/LexicalAutoEmbedPlugin.dev.js +17 -1
- package/LexicalAutoEmbedPlugin.dev.mjs +3 -0
- package/LexicalAutoEmbedPlugin.js +2 -0
- package/LexicalAutoEmbedPlugin.mjs +2 -0
- package/LexicalAutoEmbedPlugin.node.mjs +2 -0
- package/LexicalAutoEmbedPlugin.prod.js +6 -4
- package/LexicalAutoEmbedPlugin.prod.mjs +2 -0
- package/LexicalAutoFocusPlugin.dev.js +3 -0
- package/LexicalAutoFocusPlugin.dev.mjs +3 -0
- package/LexicalAutoFocusPlugin.js +2 -0
- package/LexicalAutoFocusPlugin.mjs +2 -0
- package/LexicalAutoFocusPlugin.node.mjs +2 -0
- package/LexicalAutoFocusPlugin.prod.js +2 -0
- package/LexicalAutoFocusPlugin.prod.mjs +2 -0
- package/LexicalAutoLinkPlugin.dev.js +9 -4
- package/LexicalAutoLinkPlugin.dev.mjs +10 -5
- package/LexicalAutoLinkPlugin.js +2 -0
- package/LexicalAutoLinkPlugin.mjs +2 -0
- package/LexicalAutoLinkPlugin.node.mjs +2 -0
- package/LexicalAutoLinkPlugin.prod.js +12 -10
- package/LexicalAutoLinkPlugin.prod.mjs +3 -1
- package/LexicalBlockWithAlignableContents.dev.js +20 -4
- package/LexicalBlockWithAlignableContents.dev.mjs +6 -3
- package/LexicalBlockWithAlignableContents.js +2 -0
- package/LexicalBlockWithAlignableContents.mjs +2 -0
- package/LexicalBlockWithAlignableContents.node.mjs +2 -0
- package/LexicalBlockWithAlignableContents.prod.js +6 -4
- package/LexicalBlockWithAlignableContents.prod.mjs +2 -0
- package/LexicalCharacterLimitPlugin.dev.js +21 -4
- package/LexicalCharacterLimitPlugin.dev.mjs +7 -3
- package/LexicalCharacterLimitPlugin.js +2 -0
- package/LexicalCharacterLimitPlugin.mjs +2 -0
- package/LexicalCharacterLimitPlugin.node.mjs +2 -0
- package/LexicalCharacterLimitPlugin.prod.js +11 -9
- package/LexicalCharacterLimitPlugin.prod.mjs +3 -1
- package/LexicalCheckListPlugin.dev.js +3 -0
- package/LexicalCheckListPlugin.dev.mjs +3 -0
- package/LexicalCheckListPlugin.js +2 -0
- package/LexicalCheckListPlugin.mjs +2 -0
- package/LexicalCheckListPlugin.node.mjs +2 -0
- package/LexicalCheckListPlugin.prod.js +2 -0
- package/LexicalCheckListPlugin.prod.mjs +2 -0
- package/LexicalClearEditorPlugin.dev.js +5 -2
- package/LexicalClearEditorPlugin.dev.mjs +7 -4
- package/LexicalClearEditorPlugin.js +2 -0
- package/LexicalClearEditorPlugin.mjs +2 -0
- package/LexicalClearEditorPlugin.node.mjs +2 -0
- package/LexicalClearEditorPlugin.prod.js +3 -1
- package/LexicalClearEditorPlugin.prod.mjs +3 -1
- package/LexicalClickableLinkPlugin.dev.js +14 -13
- package/LexicalClickableLinkPlugin.dev.mjs +14 -13
- package/LexicalClickableLinkPlugin.js +2 -0
- package/LexicalClickableLinkPlugin.mjs +2 -0
- package/LexicalClickableLinkPlugin.node.mjs +2 -0
- package/LexicalClickableLinkPlugin.prod.js +5 -4
- package/LexicalClickableLinkPlugin.prod.mjs +3 -1
- package/LexicalCollaborationContext.dev.js +3 -0
- package/LexicalCollaborationContext.dev.mjs +3 -0
- package/LexicalCollaborationContext.js +2 -0
- package/LexicalCollaborationContext.mjs +2 -0
- package/LexicalCollaborationContext.node.mjs +2 -0
- package/LexicalCollaborationContext.prod.js +2 -0
- package/LexicalCollaborationContext.prod.mjs +2 -0
- package/LexicalCollaborationPlugin.dev.js +19 -2
- package/LexicalCollaborationPlugin.dev.mjs +4 -0
- package/LexicalCollaborationPlugin.js +2 -0
- package/LexicalCollaborationPlugin.mjs +2 -0
- package/LexicalCollaborationPlugin.node.mjs +2 -0
- package/LexicalCollaborationPlugin.prod.js +12 -10
- package/LexicalCollaborationPlugin.prod.mjs +2 -0
- package/LexicalComposer.dev.js +19 -3
- package/LexicalComposer.dev.mjs +7 -4
- package/LexicalComposer.js +2 -0
- package/LexicalComposer.mjs +2 -0
- package/LexicalComposer.node.mjs +2 -0
- package/LexicalComposer.prod.js +5 -3
- package/LexicalComposer.prod.mjs +3 -1
- package/LexicalComposerContext.dev.js +3 -0
- package/LexicalComposerContext.dev.mjs +3 -0
- package/LexicalComposerContext.js +2 -0
- package/LexicalComposerContext.mjs +2 -0
- package/LexicalComposerContext.node.mjs +2 -0
- package/LexicalComposerContext.prod.js +4 -2
- package/LexicalComposerContext.prod.mjs +3 -1
- package/LexicalContentEditable.dev.js +18 -3
- package/LexicalContentEditable.dev.mjs +6 -4
- package/LexicalContentEditable.js +2 -0
- package/LexicalContentEditable.mjs +2 -0
- package/LexicalContentEditable.node.mjs +2 -0
- package/LexicalContentEditable.prod.js +6 -3
- package/LexicalContentEditable.prod.mjs +3 -1
- package/LexicalContextMenuPlugin.dev.js +24 -7
- package/LexicalContextMenuPlugin.dev.mjs +11 -7
- package/LexicalContextMenuPlugin.js +2 -0
- package/LexicalContextMenuPlugin.js.flow +12 -0
- package/LexicalContextMenuPlugin.mjs +2 -0
- package/LexicalContextMenuPlugin.node.mjs +2 -0
- package/LexicalContextMenuPlugin.prod.js +18 -16
- package/LexicalContextMenuPlugin.prod.mjs +3 -1
- package/LexicalDecoratorBlockNode.d.ts +1 -0
- package/LexicalDecoratorBlockNode.dev.js +6 -0
- package/LexicalDecoratorBlockNode.dev.mjs +6 -0
- package/LexicalDecoratorBlockNode.js +2 -0
- package/LexicalDecoratorBlockNode.mjs +2 -0
- package/LexicalDecoratorBlockNode.node.mjs +2 -0
- package/LexicalDecoratorBlockNode.prod.js +3 -1
- package/LexicalDecoratorBlockNode.prod.mjs +3 -1
- package/LexicalEditorRefPlugin.dev.js +17 -1
- package/LexicalEditorRefPlugin.dev.mjs +3 -0
- package/LexicalEditorRefPlugin.js +2 -0
- package/LexicalEditorRefPlugin.js.flow +19 -0
- package/LexicalEditorRefPlugin.mjs +2 -0
- package/LexicalEditorRefPlugin.node.mjs +2 -0
- package/LexicalEditorRefPlugin.prod.js +3 -1
- package/LexicalEditorRefPlugin.prod.mjs +2 -0
- package/LexicalErrorBoundary.dev.js +21 -5
- package/LexicalErrorBoundary.dev.mjs +3 -0
- package/LexicalErrorBoundary.js +2 -0
- package/LexicalErrorBoundary.mjs +2 -0
- package/LexicalErrorBoundary.node.mjs +2 -0
- package/LexicalErrorBoundary.prod.js +6 -4
- package/LexicalErrorBoundary.prod.mjs +2 -0
- package/LexicalHashtagPlugin.dev.js +5 -2
- package/LexicalHashtagPlugin.dev.mjs +5 -2
- package/LexicalHashtagPlugin.js +2 -0
- package/LexicalHashtagPlugin.mjs +2 -0
- package/LexicalHashtagPlugin.node.mjs +2 -0
- package/LexicalHashtagPlugin.prod.js +2 -0
- package/LexicalHashtagPlugin.prod.mjs +2 -0
- package/LexicalHistoryPlugin.dev.js +4 -0
- package/LexicalHistoryPlugin.dev.mjs +4 -0
- package/LexicalHistoryPlugin.js +2 -0
- package/LexicalHistoryPlugin.mjs +2 -0
- package/LexicalHistoryPlugin.node.mjs +2 -0
- package/LexicalHistoryPlugin.prod.js +2 -0
- package/LexicalHistoryPlugin.prod.mjs +2 -0
- package/LexicalHorizontalRuleNode.dev.js +22 -6
- package/LexicalHorizontalRuleNode.dev.mjs +8 -5
- package/LexicalHorizontalRuleNode.js +2 -0
- package/LexicalHorizontalRuleNode.mjs +2 -0
- package/LexicalHorizontalRuleNode.node.mjs +2 -0
- package/LexicalHorizontalRuleNode.prod.js +7 -5
- package/LexicalHorizontalRuleNode.prod.mjs +2 -0
- package/LexicalHorizontalRulePlugin.dev.js +3 -0
- package/LexicalHorizontalRulePlugin.dev.mjs +3 -0
- package/LexicalHorizontalRulePlugin.js +2 -0
- package/LexicalHorizontalRulePlugin.mjs +2 -0
- package/LexicalHorizontalRulePlugin.node.mjs +2 -0
- package/LexicalHorizontalRulePlugin.prod.js +2 -0
- package/LexicalHorizontalRulePlugin.prod.mjs +2 -0
- package/LexicalLinkPlugin.dev.js +6 -3
- package/LexicalLinkPlugin.dev.mjs +7 -4
- package/LexicalLinkPlugin.js +2 -0
- package/LexicalLinkPlugin.mjs +2 -0
- package/LexicalLinkPlugin.node.mjs +2 -0
- package/LexicalLinkPlugin.prod.js +3 -1
- package/LexicalLinkPlugin.prod.mjs +3 -1
- package/LexicalListPlugin.dev.js +4 -0
- package/LexicalListPlugin.dev.mjs +4 -0
- package/LexicalListPlugin.js +2 -0
- package/LexicalListPlugin.mjs +2 -0
- package/LexicalListPlugin.node.mjs +2 -0
- package/LexicalListPlugin.prod.js +2 -0
- package/LexicalListPlugin.prod.mjs +2 -0
- package/LexicalMarkdownShortcutPlugin.dev.js +3 -0
- package/LexicalMarkdownShortcutPlugin.dev.mjs +3 -0
- package/LexicalMarkdownShortcutPlugin.js +2 -0
- package/LexicalMarkdownShortcutPlugin.mjs +2 -0
- package/LexicalMarkdownShortcutPlugin.node.mjs +2 -0
- package/LexicalMarkdownShortcutPlugin.prod.js +2 -0
- package/LexicalMarkdownShortcutPlugin.prod.mjs +2 -0
- package/LexicalNestedComposer.dev.js +17 -1
- package/LexicalNestedComposer.dev.mjs +3 -0
- package/LexicalNestedComposer.js +2 -0
- package/LexicalNestedComposer.mjs +2 -0
- package/LexicalNestedComposer.node.mjs +2 -0
- package/LexicalNestedComposer.prod.js +7 -5
- package/LexicalNestedComposer.prod.mjs +3 -1
- package/LexicalNodeEventPlugin.dev.js +3 -0
- package/LexicalNodeEventPlugin.dev.mjs +3 -0
- package/LexicalNodeEventPlugin.js +2 -0
- package/LexicalNodeEventPlugin.js.flow +12 -0
- package/LexicalNodeEventPlugin.mjs +2 -0
- package/LexicalNodeEventPlugin.node.mjs +2 -0
- package/LexicalNodeEventPlugin.prod.js +2 -0
- package/LexicalNodeEventPlugin.prod.mjs +2 -0
- package/LexicalNodeMenuPlugin.dev.js +25 -8
- package/LexicalNodeMenuPlugin.dev.mjs +11 -7
- package/LexicalNodeMenuPlugin.js +2 -0
- package/LexicalNodeMenuPlugin.mjs +2 -0
- package/LexicalNodeMenuPlugin.node.mjs +2 -0
- package/LexicalNodeMenuPlugin.prod.js +17 -15
- package/LexicalNodeMenuPlugin.prod.mjs +3 -1
- package/LexicalOnChangePlugin.dev.js +5 -2
- package/LexicalOnChangePlugin.dev.mjs +7 -4
- package/LexicalOnChangePlugin.js +2 -0
- package/LexicalOnChangePlugin.mjs +2 -0
- package/LexicalOnChangePlugin.node.mjs +2 -0
- package/LexicalOnChangePlugin.prod.js +3 -1
- package/LexicalOnChangePlugin.prod.mjs +3 -1
- package/LexicalPlainTextPlugin.dev.js +26 -7
- package/LexicalPlainTextPlugin.dev.mjs +13 -7
- package/LexicalPlainTextPlugin.js +2 -0
- package/LexicalPlainTextPlugin.mjs +2 -0
- package/LexicalPlainTextPlugin.node.mjs +2 -0
- package/LexicalPlainTextPlugin.prod.js +6 -4
- package/LexicalPlainTextPlugin.prod.mjs +3 -1
- package/LexicalRichTextPlugin.dev.js +26 -7
- package/LexicalRichTextPlugin.dev.mjs +13 -7
- package/LexicalRichTextPlugin.js +2 -0
- package/LexicalRichTextPlugin.mjs +2 -0
- package/LexicalRichTextPlugin.node.mjs +2 -0
- package/LexicalRichTextPlugin.prod.js +6 -4
- package/LexicalRichTextPlugin.prod.mjs +3 -1
- package/LexicalTabIndentationPlugin.dev.js +5 -2
- package/LexicalTabIndentationPlugin.dev.mjs +5 -2
- package/LexicalTabIndentationPlugin.js +2 -0
- package/LexicalTabIndentationPlugin.mjs +2 -0
- package/LexicalTabIndentationPlugin.node.mjs +2 -0
- package/LexicalTabIndentationPlugin.prod.js +2 -0
- package/LexicalTabIndentationPlugin.prod.mjs +2 -0
- package/LexicalTableOfContents.d.ts +1 -1
- package/LexicalTableOfContents.dev.js +47 -8
- package/LexicalTableOfContents.dev.mjs +48 -9
- package/LexicalTableOfContents.js +2 -0
- package/LexicalTableOfContents.mjs +2 -0
- package/LexicalTableOfContents.node.mjs +2 -0
- package/LexicalTableOfContents.prod.js +6 -4
- package/LexicalTableOfContents.prod.mjs +3 -1
- package/LexicalTablePlugin.dev.js +28 -2
- package/LexicalTablePlugin.dev.mjs +31 -5
- package/LexicalTablePlugin.js +2 -0
- package/LexicalTablePlugin.mjs +2 -0
- package/LexicalTablePlugin.node.mjs +2 -0
- package/LexicalTablePlugin.prod.js +9 -5
- package/LexicalTablePlugin.prod.mjs +3 -1
- package/LexicalTreeView.dev.js +18 -2
- package/LexicalTreeView.dev.mjs +3 -0
- package/LexicalTreeView.js +2 -0
- package/LexicalTreeView.mjs +2 -0
- package/LexicalTreeView.node.mjs +2 -0
- package/LexicalTreeView.prod.js +5 -3
- package/LexicalTreeView.prod.mjs +2 -0
- package/LexicalTypeaheadMenuPlugin.dev.js +25 -8
- package/LexicalTypeaheadMenuPlugin.dev.mjs +11 -7
- package/LexicalTypeaheadMenuPlugin.js +2 -0
- package/LexicalTypeaheadMenuPlugin.mjs +2 -0
- package/LexicalTypeaheadMenuPlugin.node.mjs +2 -0
- package/LexicalTypeaheadMenuPlugin.prod.js +21 -19
- package/LexicalTypeaheadMenuPlugin.prod.mjs +3 -1
- package/package.json +20 -19
- package/shared/useCharacterLimit.d.ts +1 -1
- package/useLexicalEditable.dev.js +6 -2
- package/useLexicalEditable.dev.mjs +8 -4
- package/useLexicalEditable.js +2 -0
- package/useLexicalEditable.mjs +2 -0
- package/useLexicalEditable.node.mjs +2 -0
- package/useLexicalEditable.prod.js +3 -1
- package/useLexicalEditable.prod.mjs +3 -1
- package/useLexicalIsTextContentEmpty.dev.js +5 -2
- package/useLexicalIsTextContentEmpty.dev.mjs +7 -4
- package/useLexicalIsTextContentEmpty.js +2 -0
- package/useLexicalIsTextContentEmpty.mjs +2 -0
- package/useLexicalIsTextContentEmpty.node.mjs +2 -0
- package/useLexicalIsTextContentEmpty.prod.js +3 -1
- package/useLexicalIsTextContentEmpty.prod.mjs +3 -1
- package/useLexicalNodeSelection.dev.js +3 -0
- package/useLexicalNodeSelection.dev.mjs +4 -1
- package/useLexicalNodeSelection.js +2 -0
- package/useLexicalNodeSelection.mjs +2 -0
- package/useLexicalNodeSelection.node.mjs +2 -0
- package/useLexicalNodeSelection.prod.js +2 -0
- package/useLexicalNodeSelection.prod.mjs +3 -1
- package/useLexicalSubscription.dev.js +5 -2
- package/useLexicalSubscription.dev.mjs +7 -4
- package/useLexicalSubscription.js +2 -0
- package/useLexicalSubscription.mjs +2 -0
- package/useLexicalSubscription.node.mjs +2 -0
- package/useLexicalSubscription.prod.js +3 -1
- package/useLexicalSubscription.prod.mjs +3 -1
- package/useLexicalTextEntity.dev.js +3 -0
- package/useLexicalTextEntity.dev.mjs +3 -0
- package/useLexicalTextEntity.js +2 -0
- package/useLexicalTextEntity.mjs +2 -0
- package/useLexicalTextEntity.node.mjs +2 -0
- package/useLexicalTextEntity.prod.js +2 -0
- package/useLexicalTextEntity.prod.mjs +2 -0
|
@@ -3,8 +3,10 @@
|
|
|
3
3
|
*
|
|
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
|
*/
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
{
|
|
8
|
+
|
|
9
|
+
'use strict';var a=require("@lexical/react/LexicalComposerContext"),c=require("@lexical/react/LexicalDecoratorBlockNode"),k=require("@lexical/react/useLexicalNodeSelection"),m=require("@lexical/utils"),n=require("lexical"),p=require("react"),w=Object.create(null);if(p)for(var x in p)w[x]=p[x];w.default=p;
|
|
10
|
+
exports.BlockWithAlignableContents=function({children:y,format:q,nodeKey:f,className:r}){let [g]=a.useLexicalComposerContext(),[d,t,u]=k.useLexicalNodeSelection(f),v=p.useRef(null),l=p.useCallback(b=>d&&n.$isNodeSelection(n.$getSelection())&&(b.preventDefault(),b=n.$getNodeByKey(f),n.$isDecoratorNode(b))?(b.remove(),!0):!1,[d,f]);p.useEffect(()=>m.mergeRegister(g.registerCommand(n.FORMAT_ELEMENT_COMMAND,b=>{if(d){var h=n.$getSelection();if(n.$isNodeSelection(h)){var e=n.$getNodeByKey(f);c.$isDecoratorBlockNode(e)&&
|
|
11
|
+
e.setFormat(b)}else if(n.$isRangeSelection(h)){h=h.getNodes();for(e of h)c.$isDecoratorBlockNode(e)?e.setFormat(b):m.$getNearestBlockElementAncestorOrThrow(e).setFormat(b)}return!0}return!1},n.COMMAND_PRIORITY_LOW),g.registerCommand(n.CLICK_COMMAND,b=>b.target===v.current?(b.preventDefault(),b.shiftKey||u(),t(!d),!0):!1,n.COMMAND_PRIORITY_LOW),g.registerCommand(n.KEY_DELETE_COMMAND,l,n.COMMAND_PRIORITY_LOW),g.registerCommand(n.KEY_BACKSPACE_COMMAND,l,n.COMMAND_PRIORITY_LOW)),[u,g,d,f,l,t]);return w.createElement("div",
|
|
12
|
+
{className:[r.base,d?r.focus:null].filter(Boolean).join(" "),ref:v,style:{textAlign:q?q:void 0}},y)}
|
|
@@ -3,5 +3,7 @@
|
|
|
3
3
|
*
|
|
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
|
*/
|
|
8
|
+
|
|
7
9
|
import{useLexicalComposerContext as e}from"@lexical/react/LexicalComposerContext";import{$isDecoratorBlockNode as r}from"@lexical/react/LexicalDecoratorBlockNode";import{useLexicalNodeSelection as t}from"@lexical/react/useLexicalNodeSelection";import{mergeRegister as o,$getNearestBlockElementAncestorOrThrow as i}from"@lexical/utils";import{$isNodeSelection as a,$getSelection as l,$getNodeByKey as m,$isDecoratorNode as n,FORMAT_ELEMENT_COMMAND as c,$isRangeSelection as s,COMMAND_PRIORITY_LOW as f,CLICK_COMMAND as u,KEY_DELETE_COMMAND as d,KEY_BACKSPACE_COMMAND as p}from"lexical";import*as x from"react";import{useRef as g,useCallback as C,useEffect as v}from"react";function N({children:N,format:y,nodeKey:D,className:F}){const[L]=e(),[h,B,K]=t(D),b=g(null),j=C((e=>{if(h&&a(l())){e.preventDefault();const r=m(D);if(n(r))return r.remove(),!0}return!1}),[h,D]);return v((()=>o(L.registerCommand(c,(e=>{if(h){const t=l();if(a(t)){const t=m(D);r(t)&&t.setFormat(e)}else if(s(t)){const o=t.getNodes();for(const t of o)if(r(t))t.setFormat(e);else{i(t).setFormat(e)}}return!0}return!1}),f),L.registerCommand(u,(e=>e.target===b.current&&(e.preventDefault(),e.shiftKey||K(),B(!h),!0)),f),L.registerCommand(d,j,f),L.registerCommand(p,j,f))),[K,L,h,D,j,B]),x.createElement("div",{className:[F.base,h?F.focus:null].filter(Boolean).join(" "),ref:b,style:{textAlign:y||void 0}},N)}export{N as BlockWithAlignableContents};
|
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
*
|
|
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
|
*/
|
|
8
|
+
|
|
7
9
|
'use strict';
|
|
8
10
|
|
|
9
11
|
var LexicalComposerContext = require('@lexical/react/LexicalComposerContext');
|
|
@@ -13,6 +15,19 @@ var text = require('@lexical/text');
|
|
|
13
15
|
var utils = require('@lexical/utils');
|
|
14
16
|
var lexical = require('lexical');
|
|
15
17
|
|
|
18
|
+
function _interopNamespaceDefault(e) {
|
|
19
|
+
var n = Object.create(null);
|
|
20
|
+
if (e) {
|
|
21
|
+
for (var k in e) {
|
|
22
|
+
n[k] = e[k];
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
n.default = e;
|
|
26
|
+
return n;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
|
|
30
|
+
|
|
16
31
|
/**
|
|
17
32
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
18
33
|
*
|
|
@@ -20,6 +35,7 @@ var lexical = require('lexical');
|
|
|
20
35
|
* LICENSE file in the root directory of this source tree.
|
|
21
36
|
*
|
|
22
37
|
*/
|
|
38
|
+
|
|
23
39
|
function useCharacterLimit(editor, maxCharacters, optional = Object.freeze({})) {
|
|
24
40
|
const {
|
|
25
41
|
strlen = input => input.length,
|
|
@@ -156,14 +172,14 @@ function $wrapOverflowedNodes(offset) {
|
|
|
156
172
|
if (previousSelection !== null) {
|
|
157
173
|
lexical.$setSelection(previousSelection);
|
|
158
174
|
}
|
|
159
|
-
mergePrevious(overflowNode);
|
|
175
|
+
$mergePrevious(overflowNode);
|
|
160
176
|
}
|
|
161
177
|
}
|
|
162
178
|
}
|
|
163
179
|
}
|
|
164
180
|
function $wrapNode(node) {
|
|
165
181
|
const overflowNode = overflow.$createOverflowNode();
|
|
166
|
-
node.
|
|
182
|
+
node.replace(overflowNode);
|
|
167
183
|
overflowNode.append(node);
|
|
168
184
|
return overflowNode;
|
|
169
185
|
}
|
|
@@ -176,7 +192,7 @@ function $unwrapNode(node) {
|
|
|
176
192
|
node.remove();
|
|
177
193
|
return childrenLength > 0 ? children[childrenLength - 1] : null;
|
|
178
194
|
}
|
|
179
|
-
function mergePrevious(overflowNode) {
|
|
195
|
+
function $mergePrevious(overflowNode) {
|
|
180
196
|
const previousNode = overflowNode.getPreviousSibling();
|
|
181
197
|
if (!overflow.$isOverflowNode(previousNode)) {
|
|
182
198
|
return;
|
|
@@ -218,6 +234,7 @@ function mergePrevious(overflowNode) {
|
|
|
218
234
|
* LICENSE file in the root directory of this source tree.
|
|
219
235
|
*
|
|
220
236
|
*/
|
|
237
|
+
|
|
221
238
|
const CHARACTER_LIMIT = 5;
|
|
222
239
|
let textEncoderInstance = null;
|
|
223
240
|
function textEncoder() {
|
|
@@ -241,7 +258,7 @@ function utf8Length(text) {
|
|
|
241
258
|
function DefaultRenderer({
|
|
242
259
|
remainingCharacters
|
|
243
260
|
}) {
|
|
244
|
-
return /*#__PURE__*/
|
|
261
|
+
return /*#__PURE__*/React__namespace.createElement("span", {
|
|
245
262
|
className: `characters-limit ${remainingCharacters < 0 ? 'characters-limit-exceeded' : ''}`
|
|
246
263
|
}, remainingCharacters);
|
|
247
264
|
}
|
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
*
|
|
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
|
*/
|
|
8
|
+
|
|
7
9
|
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
8
10
|
import * as React from 'react';
|
|
9
11
|
import { useEffect, useState, useMemo } from 'react';
|
|
@@ -19,6 +21,7 @@ import { $getSelection, $isRangeSelection, $isTextNode, $isLeafNode, $setSelecti
|
|
|
19
21
|
* LICENSE file in the root directory of this source tree.
|
|
20
22
|
*
|
|
21
23
|
*/
|
|
24
|
+
|
|
22
25
|
function useCharacterLimit(editor, maxCharacters, optional = Object.freeze({})) {
|
|
23
26
|
const {
|
|
24
27
|
strlen = input => input.length,
|
|
@@ -155,14 +158,14 @@ function $wrapOverflowedNodes(offset) {
|
|
|
155
158
|
if (previousSelection !== null) {
|
|
156
159
|
$setSelection(previousSelection);
|
|
157
160
|
}
|
|
158
|
-
mergePrevious(overflowNode);
|
|
161
|
+
$mergePrevious(overflowNode);
|
|
159
162
|
}
|
|
160
163
|
}
|
|
161
164
|
}
|
|
162
165
|
}
|
|
163
166
|
function $wrapNode(node) {
|
|
164
167
|
const overflowNode = $createOverflowNode();
|
|
165
|
-
node.
|
|
168
|
+
node.replace(overflowNode);
|
|
166
169
|
overflowNode.append(node);
|
|
167
170
|
return overflowNode;
|
|
168
171
|
}
|
|
@@ -175,7 +178,7 @@ function $unwrapNode(node) {
|
|
|
175
178
|
node.remove();
|
|
176
179
|
return childrenLength > 0 ? children[childrenLength - 1] : null;
|
|
177
180
|
}
|
|
178
|
-
function mergePrevious(overflowNode) {
|
|
181
|
+
function $mergePrevious(overflowNode) {
|
|
179
182
|
const previousNode = overflowNode.getPreviousSibling();
|
|
180
183
|
if (!$isOverflowNode(previousNode)) {
|
|
181
184
|
return;
|
|
@@ -217,6 +220,7 @@ function mergePrevious(overflowNode) {
|
|
|
217
220
|
* LICENSE file in the root directory of this source tree.
|
|
218
221
|
*
|
|
219
222
|
*/
|
|
223
|
+
|
|
220
224
|
const CHARACTER_LIMIT = 5;
|
|
221
225
|
let textEncoderInstance = null;
|
|
222
226
|
function textEncoder() {
|
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
*
|
|
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
|
*/
|
|
8
|
+
|
|
7
9
|
'use strict'
|
|
8
10
|
const LexicalCharacterLimitPlugin = process.env.NODE_ENV === 'development' ? require('./LexicalCharacterLimitPlugin.dev.js') : require('./LexicalCharacterLimitPlugin.prod.js');
|
|
9
11
|
module.exports = LexicalCharacterLimitPlugin;
|
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
*
|
|
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
|
*/
|
|
8
|
+
|
|
7
9
|
import * as modDev from './LexicalCharacterLimitPlugin.dev.mjs';
|
|
8
10
|
import * as modProd from './LexicalCharacterLimitPlugin.prod.mjs';
|
|
9
11
|
const mod = process.env.NODE_ENV === 'development' ? modDev : modProd;
|
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
*
|
|
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
|
*/
|
|
8
|
+
|
|
7
9
|
const mod = await (process.env.NODE_ENV === 'development' ? import('./LexicalCharacterLimitPlugin.dev.mjs') : import('./LexicalCharacterLimitPlugin.prod.mjs'));
|
|
8
10
|
export const CharacterLimitPlugin = mod.CharacterLimitPlugin;
|
|
@@ -3,13 +3,15 @@
|
|
|
3
3
|
*
|
|
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
|
*/
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
function
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
u.
|
|
13
|
-
|
|
14
|
-
function
|
|
15
|
-
|
|
8
|
+
|
|
9
|
+
'use strict';var p=require("@lexical/react/LexicalComposerContext"),q=require("react"),w=require("@lexical/overflow"),x=require("@lexical/text"),A=require("@lexical/utils"),C=require("lexical"),D=Object.create(null);if(q)for(var E in q)D[E]=q[E];D.default=q;var F;
|
|
10
|
+
function H(a){let c=new URLSearchParams;c.append("code",a);for(let h=1;h<arguments.length;h++)c.append("v",arguments[h]);throw Error(`Minified Lexical error #${a}; visit https://lexical.dev/docs/error?${c} for the full message or `+"use the non-minified dev environment for full errors and additional helpful warnings.");}F=H&&H.__esModule&&Object.prototype.hasOwnProperty.call(H,"default")?H["default"]:H;
|
|
11
|
+
function I(a,c,h=Object.freeze({})){let {strlen:f=l=>l.length,remainingCharacters:r=()=>{}}=h;q.useEffect(()=>{a.hasNodes([w.OverflowNode])||F(57)},[a]);q.useEffect(()=>{let l=a.getEditorState().read(x.$rootTextContent),m=0;return A.mergeRegister(a.registerTextContentListener(d=>{l=d}),a.registerUpdateListener(({dirtyLeaves:d,dirtyElements:t})=>{var y=a.isComposing();d=0<d.size||0<t.size;if(!y&&d){y=f(l);d=y>c||null!==m&&m>c;r(c-y);if(null===m||d){let u=K(l,c,f);a.update(()=>{let G=A.$dfs(),O=G.length,
|
|
12
|
+
z=0;for(let B=0;B<O;B+=1){var {node:b}=G[B];if(w.$isOverflowNode(b)){var e=z;if(z+b.getTextContentSize()<=u){var g=b.getParent();e=b.getPreviousSibling();var k=b.getNextSibling();L(b);b=C.$getSelection();!C.$isRangeSelection(b)||b.anchor.getNode().isAttached()&&b.focus.getNode().isAttached()||(C.$isTextNode(e)?e.select():C.$isTextNode(k)?k.select():null!==g&&g.select())}else e<u&&(g=b.getFirstDescendant(),k=null!==g?g.getTextContentSize():0,e+=k,g=C.$isTextNode(g)&&g.isSimpleText(),e=e<=u,(g||e)&&
|
|
13
|
+
L(b))}else if(C.$isLeafNode(b)&&(e=z,z+=b.getTextContentSize(),z>u&&!w.$isOverflowNode(b.getParent())&&(g=C.$getSelection(),e<u&&C.$isTextNode(b)&&b.isSimpleText()?([,b]=b.splitText(u-e),b=M(b)):b=M(b),null!==g&&C.$setSelection(g),e=b.getPreviousSibling(),w.$isOverflowNode(e)))){k=b.getFirstChild();var v=e.getChildren();g=v.length;if(null===k)b.append(...v);else for(var n=0;n<g;n++)k.insertBefore(v[n]);n=C.$getSelection();if(C.$isRangeSelection(n)){k=n.anchor;v=k.getNode();n=n.focus;let J=k.getNode();
|
|
14
|
+
v.is(e)?k.set(b.getKey(),k.offset,"element"):v.is(b)&&k.set(b.getKey(),g+k.offset,"element");J.is(e)?n.set(b.getKey(),n.offset,"element"):J.is(b)&&n.set(b.getKey(),g+n.offset,"element")}e.remove()}}},{tag:"history-merge"})}m=y}}))},[a,c,r,f])}
|
|
15
|
+
function K(a,c,h){var f=Intl.Segmenter;let r=0;var l=0;if("function"===typeof f){a=(new f).segment(a);for(var {segment:m}of a){l+=h(m);if(l>c)break;r+=m.length}}else for(m=Array.from(a),a=m.length,f=0;f<a;f++){let d=m[f];l+=h(d);if(l>c)break;r+=d.length}return r}function M(a){let c=w.$createOverflowNode();a.replace(c);c.append(a);return c}function L(a){let c=a.getChildren(),h=c.length;for(let f=0;f<h;f++)a.insertBefore(c[f]);a.remove();return 0<h?c[h-1]:null}let N=null;
|
|
16
|
+
function P({remainingCharacters:a}){return D.createElement("span",{className:`characters-limit ${0>a?"characters-limit-exceeded":""}`},a)}
|
|
17
|
+
exports.CharacterLimitPlugin=function({charset:a="UTF-16",maxLength:c=5,renderer:h=P}){let [f]=p.useLexicalComposerContext(),[r,l]=q.useState(c),m=q.useMemo(()=>({remainingCharacters:l,strlen:d=>{if("UTF-8"===a){if(void 0===window.TextEncoder)var t=null;else null===N&&(N=new window.TextEncoder),t=N;null===t?(t=encodeURIComponent(d).match(/%[89ABab]/g),d=d.length+(t?t.length:0)):d=t.encode(d).length;return d}if("UTF-16"===a)return d.length;throw Error("Unrecognized charset");}}),[a]);I(f,c,m);return h({remainingCharacters:r})}
|
|
@@ -3,5 +3,7 @@
|
|
|
3
3
|
*
|
|
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
|
*/
|
|
7
|
-
|
|
8
|
+
|
|
9
|
+
import{useLexicalComposerContext as e}from"@lexical/react/LexicalComposerContext";import*as t from"react";import{useEffect as n,useState as r,useMemo as o}from"react";import{OverflowNode as i,$isOverflowNode as s,$createOverflowNode as l}from"@lexical/overflow";import{$rootTextContent as c}from"@lexical/text";import{mergeRegister as a,$dfs as f}from"@lexical/utils";import{$getSelection as g,$isRangeSelection as u,$isTextNode as d,$isLeafNode as m,$setSelection as h}from"lexical";function p(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var x=p((function(e){const t=new URLSearchParams;t.append("code",e);for(let e=1;e<arguments.length;e++)t.append("v",arguments[e]);throw Error(`Minified Lexical error #${e}; visit https://lexical.dev/docs/error?${t} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}));function C(e,t,r=Object.freeze({})){const{strlen:o=(e=>e.length),remainingCharacters:l=(()=>{})}=r;n((()=>{e.hasNodes([i])||x(57)}),[e]),n((()=>{let n=e.getEditorState().read(c),r=0;return a(e.registerTextContentListener((e=>{n=e})),e.registerUpdateListener((({dirtyLeaves:i,dirtyElements:c})=>{const a=e.isComposing(),p=i.size>0||c.size>0;if(a||!p)return;const x=o(n),C=x>t||null!==r&&r>t;if(l(t-x),null===r||C){const r=function(e,t,n){const r=Intl.Segmenter;let o=0,i=0;if("function"==typeof r){const s=(new r).segment(e);for(const{segment:e}of s){const r=i+n(e);if(r>t)break;i=r,o+=e.length}}else{const r=Array.from(e),s=r.length;for(let e=0;e<s;e++){const s=r[e],l=i+n(s);if(l>t)break;i=l,o+=s.length}}return o}(n,t,o);e.update((()=>{!function(e){const t=f(),n=t.length;let r=0;for(let o=0;o<n;o+=1){const{node:n}=t[o];if(s(n)){const t=r;if(r+n.getTextContentSize()<=e){const e=n.getParent(),t=n.getPreviousSibling(),r=n.getNextSibling();w(n);const o=g();!u(o)||o.anchor.getNode().isAttached()&&o.focus.getNode().isAttached()||(d(t)?t.select():d(r)?r.select():null!==e&&e.select())}else if(t<e){const r=n.getFirstDescendant(),o=t+(null!==r?r.getTextContentSize():0);(d(r)&&r.isSimpleText()||o<=e)&&w(n)}}else if(m(n)){const t=r;if(r+=n.getTextContentSize(),r>e&&!s(n.getParent())){const r=g();let o;if(t<e&&d(n)&&n.isSimpleText()){const[,r]=n.splitText(e-t);o=v(r)}else o=v(n);null!==r&&h(r),T(o)}}}}(r)}),{tag:"history-merge"})}r=x})))}),[e,t,l,o])}function v(e){const t=l();return e.replace(t),t.append(e),t}function w(e){const t=e.getChildren(),n=t.length;for(let r=0;r<n;r++)e.insertBefore(t[r]);return e.remove(),n>0?t[n-1]:null}function T(e){const t=e.getPreviousSibling();if(!s(t))return;const n=e.getFirstChild(),r=t.getChildren(),o=r.length;if(null===n)e.append(...r);else for(let e=0;e<o;e++)n.insertBefore(r[e]);const i=g();if(u(i)){const n=i.anchor,r=n.getNode(),s=i.focus,l=n.getNode();r.is(t)?n.set(e.getKey(),n.offset,"element"):r.is(e)&&n.set(e.getKey(),o+n.offset,"element"),l.is(t)?s.set(e.getKey(),s.offset,"element"):l.is(e)&&s.set(e.getKey(),o+s.offset,"element")}t.remove()}let y=null;function S(e){const t=void 0===window.TextEncoder?null:(null===y&&(y=new window.TextEncoder),y);if(null===t){const t=encodeURIComponent(e).match(/%[89ABab]/g);return e.length+(t?t.length:0)}return t.encode(e).length}function b({remainingCharacters:e}){return t.createElement("span",{className:"characters-limit "+(e<0?"characters-limit-exceeded":"")},e)}function z({charset:t="UTF-16",maxLength:n=5,renderer:i=b}){const[s]=e(),[l,c]=r(n);return C(s,n,o((()=>({remainingCharacters:c,strlen:e=>{if("UTF-8"===t)return S(e);if("UTF-16"===t)return e.length;throw new Error("Unrecognized charset")}})),[t])),i({remainingCharacters:l})}export{z as CharacterLimitPlugin};
|
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
*
|
|
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
|
*/
|
|
8
|
+
|
|
7
9
|
'use strict';
|
|
8
10
|
|
|
9
11
|
var list = require('@lexical/list');
|
|
@@ -19,6 +21,7 @@ var react = require('react');
|
|
|
19
21
|
* LICENSE file in the root directory of this source tree.
|
|
20
22
|
*
|
|
21
23
|
*/
|
|
24
|
+
|
|
22
25
|
function CheckListPlugin() {
|
|
23
26
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
24
27
|
react.useEffect(() => {
|
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
*
|
|
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
|
*/
|
|
8
|
+
|
|
7
9
|
import { INSERT_CHECK_LIST_COMMAND, insertList, $isListItemNode, $isListNode } from '@lexical/list';
|
|
8
10
|
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
9
11
|
import { mergeRegister, $findMatchingParent, isHTMLElement, calculateZoomLevel } from '@lexical/utils';
|
|
@@ -17,6 +19,7 @@ import { useEffect } from 'react';
|
|
|
17
19
|
* LICENSE file in the root directory of this source tree.
|
|
18
20
|
*
|
|
19
21
|
*/
|
|
22
|
+
|
|
20
23
|
function CheckListPlugin() {
|
|
21
24
|
const [editor] = useLexicalComposerContext();
|
|
22
25
|
useEffect(() => {
|
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
*
|
|
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
|
*/
|
|
8
|
+
|
|
7
9
|
'use strict'
|
|
8
10
|
const LexicalCheckListPlugin = process.env.NODE_ENV === 'development' ? require('./LexicalCheckListPlugin.dev.js') : require('./LexicalCheckListPlugin.prod.js');
|
|
9
11
|
module.exports = LexicalCheckListPlugin;
|
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
*
|
|
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
|
*/
|
|
8
|
+
|
|
7
9
|
import * as modDev from './LexicalCheckListPlugin.dev.mjs';
|
|
8
10
|
import * as modProd from './LexicalCheckListPlugin.prod.mjs';
|
|
9
11
|
const mod = process.env.NODE_ENV === 'development' ? modDev : modProd;
|
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
*
|
|
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
|
*/
|
|
8
|
+
|
|
7
9
|
const mod = await (process.env.NODE_ENV === 'development' ? import('./LexicalCheckListPlugin.dev.mjs') : import('./LexicalCheckListPlugin.prod.mjs'));
|
|
8
10
|
export const CheckListPlugin = mod.CheckListPlugin;
|
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
*
|
|
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
|
*/
|
|
8
|
+
|
|
7
9
|
'use strict';var e=require("@lexical/list"),g=require("@lexical/react/LexicalComposerContext"),k=require("@lexical/utils"),l=require("lexical"),m=require("react");function n(a,c){let b=a.target;if(null!==b&&k.isHTMLElement(b)){var d=b.firstChild;(null==d||!k.isHTMLElement(d)||"UL"!==d.tagName&&"OL"!==d.tagName)&&(d=b.parentNode)&&"check"===d.__lexicalListType&&(d=b.getBoundingClientRect(),a=a.pageX/k.calculateZoomLevel(b),("rtl"===b.dir?a<d.right&&a>d.right-20:a>d.left&&a<d.left+20)&&c())}}
|
|
8
10
|
function p(a){n(a,()=>{let c=a.target,b=q(c);null!=b&&b.isEditable()&&b.update(()=>{if(a.target){let d=l.$getNearestNodeFromDOMNode(c);e.$isListItemNode(d)&&(c.focus(),d.toggleChecked())}})})}function r(a){n(a,()=>{a.preventDefault()})}function q(a){for(;a;){if(a.__lexicalEditor)return a.__lexicalEditor;a=a.parentNode}return null}function t(){let a=document.activeElement;return null!=a&&"LI"===a.tagName&&null!=a.parentNode&&"check"===a.parentNode.__lexicalListType?a:null}
|
|
9
11
|
function u(a,c){let b=c?a.getPreviousSibling():a.getNextSibling();for(;null==b&&e.$isListItemNode(a);)a=a.getParentOrThrow().getParent(),null!=a&&(b=c?a.getPreviousSibling():a.getNextSibling());for(;e.$isListItemNode(b);){a=c?b.getLastChild():b.getFirstChild();if(!e.$isListNode(a))return b;b=c?a.getLastChild():a.getFirstChild()}return null}
|
|
@@ -3,5 +3,7 @@
|
|
|
3
3
|
*
|
|
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
|
*/
|
|
8
|
+
|
|
7
9
|
import{INSERT_CHECK_LIST_COMMAND as e,insertList as t,$isListItemNode as n,$isListNode as r}from"@lexical/list";import{useLexicalComposerContext as i}from"@lexical/react/LexicalComposerContext";import{mergeRegister as l,$findMatchingParent as o,isHTMLElement as c,calculateZoomLevel as u}from"@lexical/utils";import{COMMAND_PRIORITY_LOW as s,KEY_ARROW_DOWN_COMMAND as a,KEY_ARROW_UP_COMMAND as g,KEY_ESCAPE_COMMAND as f,KEY_SPACE_COMMAND as d,$getNearestNodeFromDOMNode as m,KEY_ARROW_LEFT_COMMAND as p,$getSelection as C,$isRangeSelection as h,$isElementNode as v}from"lexical";import{useEffect as E}from"react";function L(){const[c]=i();return E((()=>l(c.registerCommand(e,(()=>(t(c,"check"),!0)),s),c.registerCommand(a,(e=>N(e,c,!1)),s),c.registerCommand(g,(e=>N(e,c,!0)),s),c.registerCommand(f,(e=>{if(null!=y()){const e=c.getRootElement();return null!=e&&e.focus(),!0}return!1}),s),c.registerCommand(d,(e=>{const t=y();return!(null==t||!c.isEditable())&&(c.update((()=>{const r=m(t);n(r)&&(e.preventDefault(),r.toggleChecked())})),!0)}),s),c.registerCommand(p,(e=>c.getEditorState().read((()=>{const t=C();if(h(t)&&t.isCollapsed()){const{anchor:i}=t,l="element"===i.type;if(l||0===i.offset){const t=i.getNode(),u=o(t,(e=>v(e)&&!e.isInline()));if(n(u)){const n=u.getParent();if(r(n)&&"check"===n.getListType()&&(l||u.getFirstDescendant()===t)){const t=c.getElementByKey(u.__key);if(null!=t&&document.activeElement!==t)return t.focus(),e.preventDefault(),!0}}}}return!1}))),s),c.registerRootListener(((e,t)=>{null!==e&&(e.addEventListener("click",_),e.addEventListener("pointerdown",k)),null!==t&&(t.removeEventListener("click",_),t.removeEventListener("pointerdown",k))}))))),null}function x(e,t){const n=e.target;if(null===n||!c(n))return;const r=n.firstChild;if(null!=r&&c(r)&&("UL"===r.tagName||"OL"===r.tagName))return;const i=n.parentNode;if(!i||"check"!==i.__lexicalListType)return;const l=n.getBoundingClientRect(),o=e.pageX/u(n);("rtl"===n.dir?o<l.right&&o>l.right-20:o>l.left&&o<l.left+20)&&t()}function _(e){x(e,(()=>{const t=e.target,r=function(e){let t=e;for(;t;){if(t.__lexicalEditor)return t.__lexicalEditor;t=t.parentNode}return null}(t);null!=r&&r.isEditable()&&r.update((()=>{if(e.target){const e=m(t);n(e)&&(t.focus(),e.toggleChecked())}}))}))}function k(e){x(e,(()=>{e.preventDefault()}))}function y(){const e=document.activeElement;return null!=e&&"LI"===e.tagName&&null!=e.parentNode&&"check"===e.parentNode.__lexicalListType?e:null}function N(e,t,i){const l=y();return null!=l&&t.update((()=>{const o=m(l);if(!n(o))return;const c=function(e,t){let i=t?e.getPreviousSibling():e.getNextSibling(),l=e;for(;null==i&&n(l);)l=l.getParentOrThrow().getParent(),null!=l&&(i=t?l.getPreviousSibling():l.getNextSibling());for(;n(i);){const e=t?i.getLastChild():i.getFirstChild();if(!r(e))return i;i=t?e.getLastChild():e.getFirstChild()}return null}(o,i);if(null!=c){c.selectStart();const n=t.getElementByKey(c.__key);null!=n&&(e.preventDefault(),setTimeout((()=>{n.focus()}),0))}})),!1}export{L as CheckListPlugin};
|
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
*
|
|
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
|
*/
|
|
8
|
+
|
|
7
9
|
'use strict';
|
|
8
10
|
|
|
9
11
|
var LexicalComposerContext = require('@lexical/react/LexicalComposerContext');
|
|
@@ -27,8 +29,8 @@ const CAN_USE_DOM = typeof window !== 'undefined' && typeof window.document !==
|
|
|
27
29
|
* LICENSE file in the root directory of this source tree.
|
|
28
30
|
*
|
|
29
31
|
*/
|
|
32
|
+
|
|
30
33
|
const useLayoutEffectImpl = CAN_USE_DOM ? react.useLayoutEffect : react.useEffect;
|
|
31
|
-
var useLayoutEffect = useLayoutEffectImpl;
|
|
32
34
|
|
|
33
35
|
/**
|
|
34
36
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
@@ -37,11 +39,12 @@ var useLayoutEffect = useLayoutEffectImpl;
|
|
|
37
39
|
* LICENSE file in the root directory of this source tree.
|
|
38
40
|
*
|
|
39
41
|
*/
|
|
42
|
+
|
|
40
43
|
function ClearEditorPlugin({
|
|
41
44
|
onClear
|
|
42
45
|
}) {
|
|
43
46
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
44
|
-
|
|
47
|
+
useLayoutEffectImpl(() => {
|
|
45
48
|
return editor.registerCommand(lexical.CLEAR_EDITOR_COMMAND, payload => {
|
|
46
49
|
editor.update(() => {
|
|
47
50
|
if (onClear == null) {
|
|
@@ -3,10 +3,12 @@
|
|
|
3
3
|
*
|
|
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
|
*/
|
|
8
|
+
|
|
7
9
|
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
8
10
|
import { CLEAR_EDITOR_COMMAND, $getRoot, $getSelection, $createParagraphNode, $isRangeSelection, COMMAND_PRIORITY_EDITOR } from 'lexical';
|
|
9
|
-
import { useLayoutEffect
|
|
11
|
+
import { useLayoutEffect, useEffect } from 'react';
|
|
10
12
|
|
|
11
13
|
/**
|
|
12
14
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
@@ -25,8 +27,8 @@ const CAN_USE_DOM = typeof window !== 'undefined' && typeof window.document !==
|
|
|
25
27
|
* LICENSE file in the root directory of this source tree.
|
|
26
28
|
*
|
|
27
29
|
*/
|
|
28
|
-
|
|
29
|
-
|
|
30
|
+
|
|
31
|
+
const useLayoutEffectImpl = CAN_USE_DOM ? useLayoutEffect : useEffect;
|
|
30
32
|
|
|
31
33
|
/**
|
|
32
34
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
@@ -35,11 +37,12 @@ var useLayoutEffect = useLayoutEffectImpl;
|
|
|
35
37
|
* LICENSE file in the root directory of this source tree.
|
|
36
38
|
*
|
|
37
39
|
*/
|
|
40
|
+
|
|
38
41
|
function ClearEditorPlugin({
|
|
39
42
|
onClear
|
|
40
43
|
}) {
|
|
41
44
|
const [editor] = useLexicalComposerContext();
|
|
42
|
-
|
|
45
|
+
useLayoutEffectImpl(() => {
|
|
43
46
|
return editor.registerCommand(CLEAR_EDITOR_COMMAND, payload => {
|
|
44
47
|
editor.update(() => {
|
|
45
48
|
if (onClear == null) {
|
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
*
|
|
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
|
*/
|
|
8
|
+
|
|
7
9
|
'use strict'
|
|
8
10
|
const LexicalClearEditorPlugin = process.env.NODE_ENV === 'development' ? require('./LexicalClearEditorPlugin.dev.js') : require('./LexicalClearEditorPlugin.prod.js');
|
|
9
11
|
module.exports = LexicalClearEditorPlugin;
|
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
*
|
|
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
|
*/
|
|
8
|
+
|
|
7
9
|
import * as modDev from './LexicalClearEditorPlugin.dev.mjs';
|
|
8
10
|
import * as modProd from './LexicalClearEditorPlugin.prod.mjs';
|
|
9
11
|
const mod = process.env.NODE_ENV === 'development' ? modDev : modProd;
|
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
*
|
|
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
|
*/
|
|
8
|
+
|
|
7
9
|
const mod = await (process.env.NODE_ENV === 'development' ? import('./LexicalClearEditorPlugin.dev.mjs') : import('./LexicalClearEditorPlugin.prod.mjs'));
|
|
8
10
|
export const ClearEditorPlugin = mod.ClearEditorPlugin;
|
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
*
|
|
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
|
*/
|
|
7
|
-
|
|
8
|
+
|
|
9
|
+
'use strict';var a=require("@lexical/react/LexicalComposerContext"),e=require("lexical"),h=require("react");let k="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?h.useLayoutEffect:h.useEffect;
|
|
8
10
|
exports.ClearEditorPlugin=function({onClear:b}){let [c]=a.useLexicalComposerContext();k(()=>c.registerCommand(e.CLEAR_EDITOR_COMMAND,()=>{c.update(()=>{if(null==b){let f=e.$getRoot(),d=e.$getSelection(),g=e.$createParagraphNode();f.clear();f.append(g);null!==d&&g.select();e.$isRangeSelection(d)&&(d.format=0)}else b()});return!0},e.COMMAND_PRIORITY_EDITOR),[c,b]);return null}
|
|
@@ -3,5 +3,7 @@
|
|
|
3
3
|
*
|
|
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
|
*/
|
|
7
|
-
|
|
8
|
+
|
|
9
|
+
import{useLexicalComposerContext as e}from"@lexical/react/LexicalComposerContext";import{CLEAR_EDITOR_COMMAND as o,$getRoot as t,$getSelection as n,$createParagraphNode as r,$isRangeSelection as l,COMMAND_PRIORITY_EDITOR as i}from"lexical";import{useLayoutEffect as c,useEffect as m}from"react";const a="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement?c:m;function d({onClear:c}){const[m]=e();return a((()=>m.registerCommand(o,(e=>(m.update((()=>{if(null==c){const e=t(),o=n(),i=r();e.clear(),e.append(i),null!==o&&i.select(),l(o)&&(o.format=0)}else c()})),!0)),i)),[m,c]),null}export{d as ClearEditorPlugin};
|
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
*
|
|
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
|
*/
|
|
8
|
+
|
|
7
9
|
'use strict';
|
|
8
10
|
|
|
9
11
|
var link = require('@lexical/link');
|
|
@@ -19,6 +21,7 @@ var react = require('react');
|
|
|
19
21
|
* LICENSE file in the root directory of this source tree.
|
|
20
22
|
*
|
|
21
23
|
*/
|
|
24
|
+
|
|
22
25
|
function findMatchingDOM(startNode, predicate) {
|
|
23
26
|
let node = startNode;
|
|
24
27
|
while (node != null) {
|
|
@@ -36,10 +39,6 @@ function LexicalClickableLinkPlugin({
|
|
|
36
39
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
37
40
|
react.useEffect(() => {
|
|
38
41
|
const onClick = event => {
|
|
39
|
-
if (disabled) {
|
|
40
|
-
event.preventDefault();
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
42
|
const target = event.target;
|
|
44
43
|
if (!(target instanceof Node)) {
|
|
45
44
|
return;
|
|
@@ -54,14 +53,16 @@ function LexicalClickableLinkPlugin({
|
|
|
54
53
|
const clickedNode = lexical.$getNearestNodeFromDOMNode(target);
|
|
55
54
|
if (clickedNode !== null) {
|
|
56
55
|
const maybeLinkNode = utils.$findMatchingParent(clickedNode, lexical.$isElementNode);
|
|
57
|
-
if (
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
56
|
+
if (!disabled) {
|
|
57
|
+
if (link.$isLinkNode(maybeLinkNode)) {
|
|
58
|
+
url = maybeLinkNode.sanitizeUrl(maybeLinkNode.getURL());
|
|
59
|
+
urlTarget = maybeLinkNode.getTarget();
|
|
60
|
+
} else {
|
|
61
|
+
const a = findMatchingDOM(target, utils.isHTMLAnchorElement);
|
|
62
|
+
if (a !== null) {
|
|
63
|
+
url = a.href;
|
|
64
|
+
urlTarget = a.target;
|
|
65
|
+
}
|
|
65
66
|
}
|
|
66
67
|
}
|
|
67
68
|
}
|
|
@@ -81,7 +82,7 @@ function LexicalClickableLinkPlugin({
|
|
|
81
82
|
event.preventDefault();
|
|
82
83
|
};
|
|
83
84
|
const onMouseUp = event => {
|
|
84
|
-
if (
|
|
85
|
+
if (event.button === 1) {
|
|
85
86
|
onClick(event);
|
|
86
87
|
}
|
|
87
88
|
};
|
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
*
|
|
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
|
*/
|
|
8
|
+
|
|
7
9
|
import { $isLinkNode } from '@lexical/link';
|
|
8
10
|
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
9
11
|
import { $findMatchingParent, isHTMLAnchorElement } from '@lexical/utils';
|
|
@@ -17,6 +19,7 @@ import { useEffect } from 'react';
|
|
|
17
19
|
* LICENSE file in the root directory of this source tree.
|
|
18
20
|
*
|
|
19
21
|
*/
|
|
22
|
+
|
|
20
23
|
function findMatchingDOM(startNode, predicate) {
|
|
21
24
|
let node = startNode;
|
|
22
25
|
while (node != null) {
|
|
@@ -34,10 +37,6 @@ function LexicalClickableLinkPlugin({
|
|
|
34
37
|
const [editor] = useLexicalComposerContext();
|
|
35
38
|
useEffect(() => {
|
|
36
39
|
const onClick = event => {
|
|
37
|
-
if (disabled) {
|
|
38
|
-
event.preventDefault();
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
40
|
const target = event.target;
|
|
42
41
|
if (!(target instanceof Node)) {
|
|
43
42
|
return;
|
|
@@ -52,14 +51,16 @@ function LexicalClickableLinkPlugin({
|
|
|
52
51
|
const clickedNode = $getNearestNodeFromDOMNode(target);
|
|
53
52
|
if (clickedNode !== null) {
|
|
54
53
|
const maybeLinkNode = $findMatchingParent(clickedNode, $isElementNode);
|
|
55
|
-
if (
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
54
|
+
if (!disabled) {
|
|
55
|
+
if ($isLinkNode(maybeLinkNode)) {
|
|
56
|
+
url = maybeLinkNode.sanitizeUrl(maybeLinkNode.getURL());
|
|
57
|
+
urlTarget = maybeLinkNode.getTarget();
|
|
58
|
+
} else {
|
|
59
|
+
const a = findMatchingDOM(target, isHTMLAnchorElement);
|
|
60
|
+
if (a !== null) {
|
|
61
|
+
url = a.href;
|
|
62
|
+
urlTarget = a.target;
|
|
63
|
+
}
|
|
63
64
|
}
|
|
64
65
|
}
|
|
65
66
|
}
|
|
@@ -79,7 +80,7 @@ function LexicalClickableLinkPlugin({
|
|
|
79
80
|
event.preventDefault();
|
|
80
81
|
};
|
|
81
82
|
const onMouseUp = event => {
|
|
82
|
-
if (
|
|
83
|
+
if (event.button === 1) {
|
|
83
84
|
onClick(event);
|
|
84
85
|
}
|
|
85
86
|
};
|
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
*
|
|
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
|
*/
|
|
8
|
+
|
|
7
9
|
'use strict'
|
|
8
10
|
const LexicalClickableLinkPlugin = process.env.NODE_ENV === 'development' ? require('./LexicalClickableLinkPlugin.dev.js') : require('./LexicalClickableLinkPlugin.prod.js');
|
|
9
11
|
module.exports = LexicalClickableLinkPlugin;
|