@lexical/react 0.14.5 → 0.16.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 +15 -11
- package/LexicalAutoEmbedPlugin.dev.mjs +5 -2
- package/LexicalAutoEmbedPlugin.js +2 -0
- package/LexicalAutoEmbedPlugin.mjs +2 -0
- package/LexicalAutoEmbedPlugin.node.mjs +2 -0
- package/LexicalAutoEmbedPlugin.prod.js +6 -5
- package/LexicalAutoEmbedPlugin.prod.mjs +3 -1
- 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 +14 -9
- package/LexicalBlockWithAlignableContents.dev.mjs +11 -7
- 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 +3 -1
- package/LexicalCharacterLimitPlugin.dev.js +17 -12
- package/LexicalCharacterLimitPlugin.dev.mjs +12 -8
- 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 +5 -0
- package/LexicalCheckListPlugin.dev.mjs +5 -0
- package/LexicalCheckListPlugin.js +2 -0
- package/LexicalCheckListPlugin.mjs +2 -0
- package/LexicalCheckListPlugin.node.mjs +2 -0
- package/LexicalCheckListPlugin.prod.js +4 -2
- package/LexicalCheckListPlugin.prod.mjs +3 -1
- package/LexicalClearEditorPlugin.dev.js +9 -2
- package/LexicalClearEditorPlugin.dev.mjs +11 -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.d.ts +3 -1
- package/LexicalClickableLinkPlugin.dev.js +17 -15
- package/LexicalClickableLinkPlugin.dev.mjs +16 -15
- package/LexicalClickableLinkPlugin.js +2 -0
- package/LexicalClickableLinkPlugin.js.flow +3 -1
- package/LexicalClickableLinkPlugin.mjs +3 -0
- package/LexicalClickableLinkPlugin.node.mjs +3 -0
- package/LexicalClickableLinkPlugin.prod.js +6 -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 +20 -2
- package/LexicalCollaborationPlugin.dev.mjs +6 -1
- 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 +3 -1
- package/LexicalComposer.dev.js +17 -8
- package/LexicalComposer.dev.mjs +16 -8
- package/LexicalComposer.js +2 -0
- package/LexicalComposer.mjs +2 -0
- package/LexicalComposer.node.mjs +2 -0
- package/LexicalComposer.prod.js +5 -4
- 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 +24 -23
- package/LexicalContentEditable.dev.mjs +22 -22
- package/LexicalContentEditable.js +2 -0
- package/LexicalContentEditable.mjs +2 -0
- package/LexicalContentEditable.node.mjs +2 -0
- package/LexicalContentEditable.prod.js +5 -3
- package/LexicalContentEditable.prod.mjs +3 -1
- package/LexicalContextMenuPlugin.dev.js +29 -7
- package/LexicalContextMenuPlugin.dev.mjs +17 -8
- 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.d.ts +3 -1
- package/LexicalErrorBoundary.dev.js +30 -10
- package/LexicalErrorBoundary.dev.mjs +13 -7
- package/LexicalErrorBoundary.js +2 -0
- package/LexicalErrorBoundary.js.flow +4 -1
- package/LexicalErrorBoundary.mjs +3 -0
- package/LexicalErrorBoundary.node.mjs +3 -0
- package/LexicalErrorBoundary.prod.js +6 -4
- package/LexicalErrorBoundary.prod.mjs +3 -1
- 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.d.ts +2 -2
- package/LexicalHorizontalRuleNode.dev.js +23 -12
- package/LexicalHorizontalRuleNode.dev.mjs +21 -11
- 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 +3 -1
- 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 +14 -9
- package/LexicalNestedComposer.dev.mjs +8 -4
- 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 +30 -8
- package/LexicalNodeMenuPlugin.dev.mjs +17 -8
- 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 +9 -2
- package/LexicalOnChangePlugin.dev.mjs +11 -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 +34 -19
- package/LexicalPlainTextPlugin.dev.mjs +31 -17
- package/LexicalPlainTextPlugin.js +2 -0
- package/LexicalPlainTextPlugin.js.flow +1 -1
- 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 +34 -19
- package/LexicalRichTextPlugin.dev.mjs +31 -17
- package/LexicalRichTextPlugin.js +2 -0
- package/LexicalRichTextPlugin.js.flow +1 -1
- 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 +6 -13
- package/LexicalTableOfContents.dev.js +57 -10
- package/LexicalTableOfContents.dev.mjs +58 -11
- package/LexicalTableOfContents.js +2 -0
- package/LexicalTableOfContents.js.flow +3 -7
- package/LexicalTableOfContents.mjs +2 -0
- package/LexicalTableOfContents.node.mjs +2 -0
- package/LexicalTableOfContents.prod.js +6 -4
- package/LexicalTableOfContents.prod.mjs +3 -1
- package/LexicalTableOfContentsPlugin.d.ts +20 -0
- package/LexicalTableOfContentsPlugin.dev.js +198 -0
- package/LexicalTableOfContentsPlugin.dev.mjs +196 -0
- package/LexicalTableOfContentsPlugin.js +11 -0
- package/LexicalTableOfContentsPlugin.js.flow +18 -0
- package/LexicalTableOfContentsPlugin.mjs +12 -0
- package/LexicalTableOfContentsPlugin.node.mjs +10 -0
- package/LexicalTableOfContentsPlugin.prod.js +12 -0
- package/LexicalTableOfContentsPlugin.prod.mjs +9 -0
- 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.d.ts +3 -1
- package/LexicalTreeView.dev.js +22 -4
- package/LexicalTreeView.dev.mjs +8 -3
- package/LexicalTreeView.js +2 -0
- package/LexicalTreeView.js.flow +2 -0
- package/LexicalTreeView.mjs +2 -0
- package/LexicalTreeView.node.mjs +2 -0
- package/LexicalTreeView.prod.js +5 -3
- package/LexicalTreeView.prod.mjs +3 -1
- package/LexicalTypeaheadMenuPlugin.dev.js +30 -8
- package/LexicalTypeaheadMenuPlugin.dev.mjs +17 -8
- 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 +50 -20
- package/shared/useCharacterLimit.d.ts +1 -1
- package/useLexicalEditable.d.ts +11 -1
- package/useLexicalEditable.dev.js +22 -3
- package/useLexicalEditable.dev.mjs +23 -5
- package/useLexicalEditable.js +2 -0
- package/useLexicalEditable.js.flow +4 -1
- package/useLexicalEditable.mjs +4 -1
- package/useLexicalEditable.node.mjs +4 -1
- package/useLexicalEditable.prod.js +4 -2
- package/useLexicalEditable.prod.mjs +3 -1
- package/useLexicalIsTextContentEmpty.dev.js +9 -2
- package/useLexicalIsTextContentEmpty.dev.mjs +11 -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.d.ts +4 -1
- package/useLexicalSubscription.dev.js +12 -3
- package/useLexicalSubscription.dev.mjs +13 -5
- package/useLexicalSubscription.js +2 -0
- package/useLexicalSubscription.js.flow +4 -1
- package/useLexicalSubscription.mjs +4 -1
- package/useLexicalSubscription.node.mjs +4 -1
- package/useLexicalSubscription.prod.js +4 -2
- 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,14 +3,16 @@
|
|
|
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 { $isDecoratorBlockNode } from '@lexical/react/LexicalDecoratorBlockNode';
|
|
9
11
|
import { useLexicalNodeSelection } from '@lexical/react/useLexicalNodeSelection';
|
|
10
12
|
import { mergeRegister, $getNearestBlockElementAncestorOrThrow } from '@lexical/utils';
|
|
11
13
|
import { $isNodeSelection, $getSelection, $getNodeByKey, $isDecoratorNode, FORMAT_ELEMENT_COMMAND, $isRangeSelection, COMMAND_PRIORITY_LOW, CLICK_COMMAND, KEY_DELETE_COMMAND, KEY_BACKSPACE_COMMAND } from 'lexical';
|
|
12
|
-
import * as React from 'react';
|
|
13
14
|
import { useRef, useCallback, useEffect } from 'react';
|
|
15
|
+
import { jsx } from 'react/jsx-runtime';
|
|
14
16
|
|
|
15
17
|
/**
|
|
16
18
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
@@ -19,6 +21,7 @@ import { useRef, useCallback, useEffect } from 'react';
|
|
|
19
21
|
* LICENSE file in the root directory of this source tree.
|
|
20
22
|
*
|
|
21
23
|
*/
|
|
24
|
+
|
|
22
25
|
function BlockWithAlignableContents({
|
|
23
26
|
children,
|
|
24
27
|
format,
|
|
@@ -28,7 +31,7 @@ function BlockWithAlignableContents({
|
|
|
28
31
|
const [editor] = useLexicalComposerContext();
|
|
29
32
|
const [isSelected, setSelected, clearSelection] = useLexicalNodeSelection(nodeKey);
|
|
30
33
|
const ref = useRef(null);
|
|
31
|
-
const onDelete = useCallback(event => {
|
|
34
|
+
const $onDelete = useCallback(event => {
|
|
32
35
|
if (isSelected && $isNodeSelection($getSelection())) {
|
|
33
36
|
event.preventDefault();
|
|
34
37
|
const node = $getNodeByKey(nodeKey);
|
|
@@ -72,15 +75,16 @@ function BlockWithAlignableContents({
|
|
|
72
75
|
return true;
|
|
73
76
|
}
|
|
74
77
|
return false;
|
|
75
|
-
}, COMMAND_PRIORITY_LOW), editor.registerCommand(KEY_DELETE_COMMAND, onDelete, COMMAND_PRIORITY_LOW), editor.registerCommand(KEY_BACKSPACE_COMMAND, onDelete, COMMAND_PRIORITY_LOW));
|
|
76
|
-
}, [clearSelection, editor, isSelected, nodeKey, onDelete, setSelected]);
|
|
77
|
-
return /*#__PURE__*/
|
|
78
|
+
}, COMMAND_PRIORITY_LOW), editor.registerCommand(KEY_DELETE_COMMAND, $onDelete, COMMAND_PRIORITY_LOW), editor.registerCommand(KEY_BACKSPACE_COMMAND, $onDelete, COMMAND_PRIORITY_LOW));
|
|
79
|
+
}, [clearSelection, editor, isSelected, nodeKey, $onDelete, setSelected]);
|
|
80
|
+
return /*#__PURE__*/jsx("div", {
|
|
78
81
|
className: [className.base, isSelected ? className.focus : null].filter(Boolean).join(' '),
|
|
79
82
|
ref: ref,
|
|
80
83
|
style: {
|
|
81
84
|
textAlign: format ? format : undefined
|
|
82
|
-
}
|
|
83
|
-
|
|
85
|
+
},
|
|
86
|
+
children: children
|
|
87
|
+
});
|
|
84
88
|
}
|
|
85
89
|
|
|
86
90
|
export { 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
|
const LexicalBlockWithAlignableContents = process.env.NODE_ENV === 'development' ? require('./LexicalBlockWithAlignableContents.dev.js') : require('./LexicalBlockWithAlignableContents.prod.js');
|
|
9
11
|
module.exports = LexicalBlockWithAlignableContents;
|
|
@@ -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 './LexicalBlockWithAlignableContents.dev.mjs';
|
|
8
10
|
import * as modProd from './LexicalBlockWithAlignableContents.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('./LexicalBlockWithAlignableContents.dev.mjs') : import('./LexicalBlockWithAlignableContents.prod.mjs'));
|
|
8
10
|
export const BlockWithAlignableContents = mod.BlockWithAlignableContents;
|
|
@@ -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"),h=require("@lexical/react/LexicalDecoratorBlockNode"),l=require("@lexical/react/useLexicalNodeSelection"),m=require("@lexical/utils"),u=require("lexical"),v=require("react"),w=require("react/jsx-runtime");
|
|
10
|
+
exports.BlockWithAlignableContents=function({children:x,format:n,nodeKey:e,className:p}){let [f]=a.useLexicalComposerContext(),[c,q,r]=l.useLexicalNodeSelection(e),t=v.useRef(null),k=v.useCallback(b=>c&&u.$isNodeSelection(u.$getSelection())&&(b.preventDefault(),b=u.$getNodeByKey(e),u.$isDecoratorNode(b))?(b.remove(),!0):!1,[c,e]);v.useEffect(()=>m.mergeRegister(f.registerCommand(u.FORMAT_ELEMENT_COMMAND,b=>{if(c){var g=u.$getSelection();if(u.$isNodeSelection(g)){var d=u.$getNodeByKey(e);h.$isDecoratorBlockNode(d)&&
|
|
11
|
+
d.setFormat(b)}else if(u.$isRangeSelection(g)){g=g.getNodes();for(d of g)h.$isDecoratorBlockNode(d)?d.setFormat(b):m.$getNearestBlockElementAncestorOrThrow(d).setFormat(b)}return!0}return!1},u.COMMAND_PRIORITY_LOW),f.registerCommand(u.CLICK_COMMAND,b=>b.target===t.current?(b.preventDefault(),b.shiftKey||r(),q(!c),!0):!1,u.COMMAND_PRIORITY_LOW),f.registerCommand(u.KEY_DELETE_COMMAND,k,u.COMMAND_PRIORITY_LOW),f.registerCommand(u.KEY_BACKSPACE_COMMAND,k,u.COMMAND_PRIORITY_LOW)),[r,f,c,e,k,q]);return w.jsx("div",
|
|
12
|
+
{className:[p.base,c?p.focus:null].filter(Boolean).join(" "),ref:t,style:{textAlign:n?n:void 0},children:x})}
|
|
@@ -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{$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 l,$getSelection as a,$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 x}from"lexical";import{useRef as p,useCallback as g,useEffect as C}from"react";import{jsx as v}from"react/jsx-runtime";function N({children:N,format:h,nodeKey:y,className:D}){const[F]=e(),[L,j,B]=t(y),K=p(null),b=g((e=>{if(L&&l(a())){e.preventDefault();const r=m(y);if(n(r))return r.remove(),!0}return!1}),[L,y]);return C((()=>o(F.registerCommand(c,(e=>{if(L){const t=a();if(l(t)){const t=m(y);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),F.registerCommand(u,(e=>e.target===K.current&&(e.preventDefault(),e.shiftKey||B(),j(!L),!0)),f),F.registerCommand(d,b,f),F.registerCommand(x,b,f))),[B,F,L,y,b,j]),v("div",{className:[D.base,L?D.focus:null].filter(Boolean).join(" "),ref:K,style:{textAlign:h||void 0},children:N})}export{N as BlockWithAlignableContents};
|
|
@@ -3,15 +3,18 @@
|
|
|
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');
|
|
10
|
-
var
|
|
12
|
+
var react = require('react');
|
|
11
13
|
var overflow = require('@lexical/overflow');
|
|
12
14
|
var text = require('@lexical/text');
|
|
13
15
|
var utils = require('@lexical/utils');
|
|
14
16
|
var lexical = require('lexical');
|
|
17
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
15
18
|
|
|
16
19
|
/**
|
|
17
20
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
@@ -20,6 +23,7 @@ var lexical = require('lexical');
|
|
|
20
23
|
* LICENSE file in the root directory of this source tree.
|
|
21
24
|
*
|
|
22
25
|
*/
|
|
26
|
+
|
|
23
27
|
function useCharacterLimit(editor, maxCharacters, optional = Object.freeze({})) {
|
|
24
28
|
const {
|
|
25
29
|
strlen = input => input.length,
|
|
@@ -28,14 +32,14 @@ function useCharacterLimit(editor, maxCharacters, optional = Object.freeze({}))
|
|
|
28
32
|
return;
|
|
29
33
|
}
|
|
30
34
|
} = optional;
|
|
31
|
-
|
|
35
|
+
react.useEffect(() => {
|
|
32
36
|
if (!editor.hasNodes([overflow.OverflowNode])) {
|
|
33
37
|
{
|
|
34
38
|
throw Error(`useCharacterLimit: OverflowNode not registered on editor`);
|
|
35
39
|
}
|
|
36
40
|
}
|
|
37
41
|
}, [editor]);
|
|
38
|
-
|
|
42
|
+
react.useEffect(() => {
|
|
39
43
|
let text$1 = editor.getEditorState().read(text.$rootTextContent);
|
|
40
44
|
let lastComputedTextLength = 0;
|
|
41
45
|
return utils.mergeRegister(editor.registerTextContentListener(currentText => {
|
|
@@ -66,7 +70,6 @@ function useCharacterLimit(editor, maxCharacters, optional = Object.freeze({}))
|
|
|
66
70
|
}, [editor, maxCharacters, remainingCharacters, strlen]);
|
|
67
71
|
}
|
|
68
72
|
function findOffset(text, maxCharacters, strlen) {
|
|
69
|
-
// @ts-ignore This is due to be added in a later version of TS
|
|
70
73
|
const Segmenter = Intl.Segmenter;
|
|
71
74
|
let offsetUtf16 = 0;
|
|
72
75
|
let offset = 0;
|
|
@@ -156,14 +159,14 @@ function $wrapOverflowedNodes(offset) {
|
|
|
156
159
|
if (previousSelection !== null) {
|
|
157
160
|
lexical.$setSelection(previousSelection);
|
|
158
161
|
}
|
|
159
|
-
mergePrevious(overflowNode);
|
|
162
|
+
$mergePrevious(overflowNode);
|
|
160
163
|
}
|
|
161
164
|
}
|
|
162
165
|
}
|
|
163
166
|
}
|
|
164
167
|
function $wrapNode(node) {
|
|
165
168
|
const overflowNode = overflow.$createOverflowNode();
|
|
166
|
-
node.
|
|
169
|
+
node.replace(overflowNode);
|
|
167
170
|
overflowNode.append(node);
|
|
168
171
|
return overflowNode;
|
|
169
172
|
}
|
|
@@ -176,7 +179,7 @@ function $unwrapNode(node) {
|
|
|
176
179
|
node.remove();
|
|
177
180
|
return childrenLength > 0 ? children[childrenLength - 1] : null;
|
|
178
181
|
}
|
|
179
|
-
function mergePrevious(overflowNode) {
|
|
182
|
+
function $mergePrevious(overflowNode) {
|
|
180
183
|
const previousNode = overflowNode.getPreviousSibling();
|
|
181
184
|
if (!overflow.$isOverflowNode(previousNode)) {
|
|
182
185
|
return;
|
|
@@ -218,6 +221,7 @@ function mergePrevious(overflowNode) {
|
|
|
218
221
|
* LICENSE file in the root directory of this source tree.
|
|
219
222
|
*
|
|
220
223
|
*/
|
|
224
|
+
|
|
221
225
|
const CHARACTER_LIMIT = 5;
|
|
222
226
|
let textEncoderInstance = null;
|
|
223
227
|
function textEncoder() {
|
|
@@ -241,9 +245,10 @@ function utf8Length(text) {
|
|
|
241
245
|
function DefaultRenderer({
|
|
242
246
|
remainingCharacters
|
|
243
247
|
}) {
|
|
244
|
-
return /*#__PURE__*/
|
|
245
|
-
className: `characters-limit ${remainingCharacters < 0 ? 'characters-limit-exceeded' : ''}
|
|
246
|
-
|
|
248
|
+
return /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
249
|
+
className: `characters-limit ${remainingCharacters < 0 ? 'characters-limit-exceeded' : ''}`,
|
|
250
|
+
children: remainingCharacters
|
|
251
|
+
});
|
|
247
252
|
}
|
|
248
253
|
function CharacterLimitPlugin({
|
|
249
254
|
charset = 'UTF-16',
|
|
@@ -251,8 +256,8 @@ function CharacterLimitPlugin({
|
|
|
251
256
|
renderer = DefaultRenderer
|
|
252
257
|
}) {
|
|
253
258
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
254
|
-
const [remainingCharacters, setRemainingCharacters] =
|
|
255
|
-
const characterLimitProps =
|
|
259
|
+
const [remainingCharacters, setRemainingCharacters] = react.useState(maxLength);
|
|
260
|
+
const characterLimitProps = react.useMemo(() => ({
|
|
256
261
|
remainingCharacters: setRemainingCharacters,
|
|
257
262
|
strlen: text => {
|
|
258
263
|
if (charset === 'UTF-8') {
|
|
@@ -3,14 +3,16 @@
|
|
|
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
|
-
import * as React from 'react';
|
|
9
10
|
import { useEffect, useState, useMemo } from 'react';
|
|
10
11
|
import { OverflowNode, $isOverflowNode, $createOverflowNode } from '@lexical/overflow';
|
|
11
12
|
import { $rootTextContent } from '@lexical/text';
|
|
12
13
|
import { mergeRegister, $dfs } from '@lexical/utils';
|
|
13
14
|
import { $getSelection, $isRangeSelection, $isTextNode, $isLeafNode, $setSelection } from 'lexical';
|
|
15
|
+
import { jsx } from 'react/jsx-runtime';
|
|
14
16
|
|
|
15
17
|
/**
|
|
16
18
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
@@ -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,
|
|
@@ -65,7 +68,6 @@ function useCharacterLimit(editor, maxCharacters, optional = Object.freeze({}))
|
|
|
65
68
|
}, [editor, maxCharacters, remainingCharacters, strlen]);
|
|
66
69
|
}
|
|
67
70
|
function findOffset(text, maxCharacters, strlen) {
|
|
68
|
-
// @ts-ignore This is due to be added in a later version of TS
|
|
69
71
|
const Segmenter = Intl.Segmenter;
|
|
70
72
|
let offsetUtf16 = 0;
|
|
71
73
|
let offset = 0;
|
|
@@ -155,14 +157,14 @@ function $wrapOverflowedNodes(offset) {
|
|
|
155
157
|
if (previousSelection !== null) {
|
|
156
158
|
$setSelection(previousSelection);
|
|
157
159
|
}
|
|
158
|
-
mergePrevious(overflowNode);
|
|
160
|
+
$mergePrevious(overflowNode);
|
|
159
161
|
}
|
|
160
162
|
}
|
|
161
163
|
}
|
|
162
164
|
}
|
|
163
165
|
function $wrapNode(node) {
|
|
164
166
|
const overflowNode = $createOverflowNode();
|
|
165
|
-
node.
|
|
167
|
+
node.replace(overflowNode);
|
|
166
168
|
overflowNode.append(node);
|
|
167
169
|
return overflowNode;
|
|
168
170
|
}
|
|
@@ -175,7 +177,7 @@ function $unwrapNode(node) {
|
|
|
175
177
|
node.remove();
|
|
176
178
|
return childrenLength > 0 ? children[childrenLength - 1] : null;
|
|
177
179
|
}
|
|
178
|
-
function mergePrevious(overflowNode) {
|
|
180
|
+
function $mergePrevious(overflowNode) {
|
|
179
181
|
const previousNode = overflowNode.getPreviousSibling();
|
|
180
182
|
if (!$isOverflowNode(previousNode)) {
|
|
181
183
|
return;
|
|
@@ -217,6 +219,7 @@ function mergePrevious(overflowNode) {
|
|
|
217
219
|
* LICENSE file in the root directory of this source tree.
|
|
218
220
|
*
|
|
219
221
|
*/
|
|
222
|
+
|
|
220
223
|
const CHARACTER_LIMIT = 5;
|
|
221
224
|
let textEncoderInstance = null;
|
|
222
225
|
function textEncoder() {
|
|
@@ -240,9 +243,10 @@ function utf8Length(text) {
|
|
|
240
243
|
function DefaultRenderer({
|
|
241
244
|
remainingCharacters
|
|
242
245
|
}) {
|
|
243
|
-
return /*#__PURE__*/
|
|
244
|
-
className: `characters-limit ${remainingCharacters < 0 ? 'characters-limit-exceeded' : ''}
|
|
245
|
-
|
|
246
|
+
return /*#__PURE__*/jsx("span", {
|
|
247
|
+
className: `characters-limit ${remainingCharacters < 0 ? 'characters-limit-exceeded' : ''}`,
|
|
248
|
+
children: remainingCharacters
|
|
249
|
+
});
|
|
246
250
|
}
|
|
247
251
|
function CharacterLimitPlugin({
|
|
248
252
|
charset = 'UTF-16',
|
|
@@ -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 G(a
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
function
|
|
15
|
-
|
|
8
|
+
|
|
9
|
+
'use strict';var p=require("@lexical/react/LexicalComposerContext"),v=require("react"),w=require("@lexical/overflow"),z=require("@lexical/text"),B=require("@lexical/utils"),C=require("lexical"),D=require("react/jsx-runtime"),F;
|
|
10
|
+
function G(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=G&&G.__esModule&&Object.prototype.hasOwnProperty.call(G,"default")?G["default"]:G;
|
|
11
|
+
function I(a,c,h=Object.freeze({})){let {strlen:f=l=>l.length,remainingCharacters:q=()=>{}}=h;v.useEffect(()=>{a.hasNodes([w.OverflowNode])||F(57)},[a]);v.useEffect(()=>{let l=a.getEditorState().read(z.$rootTextContent),m=0;return B.mergeRegister(a.registerTextContentListener(d=>{l=d}),a.registerUpdateListener(({dirtyLeaves:d,dirtyElements:r})=>{var x=a.isComposing();d=0<d.size||0<r.size;if(!x&&d){x=f(l);d=x>c||null!==m&&m>c;q(c-x);if(null===m||d){let t=J(l,c,f);a.update(()=>{let E=B.$dfs(),N=E.length,
|
|
12
|
+
y=0;for(let A=0;A<N;A+=1){var {node:b}=E[A];if(w.$isOverflowNode(b)){var e=y;if(y+b.getTextContentSize()<=t){var g=b.getParent();e=b.getPreviousSibling();var k=b.getNextSibling();K(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<t&&(g=b.getFirstDescendant(),k=null!==g?g.getTextContentSize():0,e+=k,g=C.$isTextNode(g)&&g.isSimpleText(),e=e<=t,(g||e)&&
|
|
13
|
+
K(b))}else if(C.$isLeafNode(b)&&(e=y,y+=b.getTextContentSize(),y>t&&!w.$isOverflowNode(b.getParent())&&(g=C.$getSelection(),e<t&&C.$isTextNode(b)&&b.isSimpleText()?([,b]=b.splitText(t-e),b=L(b)):b=L(b),null!==g&&C.$setSelection(g),e=b.getPreviousSibling(),w.$isOverflowNode(e)))){k=b.getFirstChild();var u=e.getChildren();g=u.length;if(null===k)b.append(...u);else for(var n=0;n<g;n++)k.insertBefore(u[n]);n=C.$getSelection();if(C.$isRangeSelection(n)){k=n.anchor;u=k.getNode();n=n.focus;let H=k.getNode();
|
|
14
|
+
u.is(e)?k.set(b.getKey(),k.offset,"element"):u.is(b)&&k.set(b.getKey(),g+k.offset,"element");H.is(e)?n.set(b.getKey(),n.offset,"element"):H.is(b)&&n.set(b.getKey(),g+n.offset,"element")}e.remove()}}},{tag:"history-merge"})}m=x}}))},[a,c,q,f])}
|
|
15
|
+
function J(a,c,h){var f=Intl.Segmenter;let q=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;q+=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;q+=d.length}return q}function L(a){let c=w.$createOverflowNode();a.replace(c);c.append(a);return c}function K(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 M=null;
|
|
16
|
+
function O({remainingCharacters:a}){return D.jsx("span",{className:`characters-limit ${0>a?"characters-limit-exceeded":""}`,children:a})}
|
|
17
|
+
exports.CharacterLimitPlugin=function({charset:a="UTF-16",maxLength:c=5,renderer:h=O}){let [f]=p.useLexicalComposerContext(),[q,l]=v.useState(c),m=v.useMemo(()=>({remainingCharacters:l,strlen:d=>{if("UTF-8"===a){if(void 0===window.TextEncoder)var r=null;else null===M&&(M=new window.TextEncoder),r=M;null===r?(r=encodeURIComponent(d).match(/%[89ABab]/g),d=d.length+(r?r.length:0)):d=r.encode(d).length;return d}if("UTF-16"===a)return d.length;throw Error("Unrecognized charset");}}),[a]);I(f,c,m);return h({remainingCharacters:q})}
|
|
@@ -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{useEffect as t,useState as n,useMemo as r}from"react";import{OverflowNode as o,$isOverflowNode as i,$createOverflowNode as s}from"@lexical/overflow";import{$rootTextContent as l}from"@lexical/text";import{mergeRegister as c,$dfs as a}from"@lexical/utils";import{$getSelection as f,$isRangeSelection as g,$isTextNode as u,$isLeafNode as d,$setSelection as m}from"lexical";import{jsx as h}from"react/jsx-runtime";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,n,r=Object.freeze({})){const{strlen:s=(e=>e.length),remainingCharacters:h=(()=>{})}=r;t((()=>{e.hasNodes([o])||x(57)}),[e]),t((()=>{let t=e.getEditorState().read(l),r=0;return c(e.registerTextContentListener((e=>{t=e})),e.registerUpdateListener((({dirtyLeaves:o,dirtyElements:l})=>{const c=e.isComposing(),p=o.size>0||l.size>0;if(c||!p)return;const x=s(t),C=x>n||null!==r&&r>n;if(h(n-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}(t,n,s);e.update((()=>{!function(e){const t=a(),n=t.length;let r=0;for(let o=0;o<n;o+=1){const{node:n}=t[o];if(i(n)){const t=r;if(r+n.getTextContentSize()<=e){const e=n.getParent(),t=n.getPreviousSibling(),r=n.getNextSibling();w(n);const o=f();!g(o)||o.anchor.getNode().isAttached()&&o.focus.getNode().isAttached()||(u(t)?t.select():u(r)?r.select():null!==e&&e.select())}else if(t<e){const r=n.getFirstDescendant(),o=t+(null!==r?r.getTextContentSize():0);(u(r)&&r.isSimpleText()||o<=e)&&w(n)}}else if(d(n)){const t=r;if(r+=n.getTextContentSize(),r>e&&!i(n.getParent())){const r=f();let o;if(t<e&&u(n)&&n.isSimpleText()){const[,r]=n.splitText(e-t);o=v(r)}else o=v(n);null!==r&&m(r),T(o)}}}}(r)}),{tag:"history-merge"})}r=x})))}),[e,n,h,s])}function v(e){const t=s();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(!i(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 s=f();if(g(s)){const n=s.anchor,r=n.getNode(),i=s.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)?i.set(e.getKey(),i.offset,"element"):l.is(e)&&i.set(e.getKey(),o+i.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 h("span",{className:"characters-limit "+(e<0?"characters-limit-exceeded":""),children:e})}function z({charset:t="UTF-16",maxLength:o=5,renderer:i=b}){const[s]=e(),[l,c]=n(o);return C(s,o,r((()=>({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(() => {
|
|
@@ -130,12 +133,14 @@ function handleClick(event) {
|
|
|
130
133
|
});
|
|
131
134
|
}
|
|
132
135
|
});
|
|
136
|
+
event.stopPropagation(); // Prevents potential parent-editor listeners from firing, causing the checkbox toggle to be undone
|
|
133
137
|
}
|
|
134
138
|
function handlePointerDown(event) {
|
|
135
139
|
handleCheckItemEvent(event, () => {
|
|
136
140
|
// Prevents caret moving when clicking on check mark
|
|
137
141
|
event.preventDefault();
|
|
138
142
|
});
|
|
143
|
+
event.stopPropagation();
|
|
139
144
|
}
|
|
140
145
|
function findEditor(target) {
|
|
141
146
|
let node = target;
|
|
@@ -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(() => {
|
|
@@ -128,12 +131,14 @@ function handleClick(event) {
|
|
|
128
131
|
});
|
|
129
132
|
}
|
|
130
133
|
});
|
|
134
|
+
event.stopPropagation(); // Prevents potential parent-editor listeners from firing, causing the checkbox toggle to be undone
|
|
131
135
|
}
|
|
132
136
|
function handlePointerDown(event) {
|
|
133
137
|
handleCheckItemEvent(event, () => {
|
|
134
138
|
// Prevents caret moving when clicking on check mark
|
|
135
139
|
event.preventDefault();
|
|
136
140
|
});
|
|
141
|
+
event.stopPropagation();
|
|
137
142
|
}
|
|
138
143
|
function findEditor(target) {
|
|
139
144
|
let node = target;
|
|
@@ -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,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
|
'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
|
-
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}
|
|
9
|
-
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}
|
|
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())}})});a.stopPropagation()}function r(a){n(a,()=>{a.preventDefault()});a.stopPropagation()}function q(a){for(;a;){if(a.__lexicalEditor)return a.__lexicalEditor;a=a.parentNode}return null}
|
|
11
|
+
function t(){let a=document.activeElement;return null!=a&&"LI"===a.tagName&&null!=a.parentNode&&"check"===a.parentNode.__lexicalListType?a:null}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}
|
|
10
12
|
function v(a,c,b){let d=t();null!=d&&c.update(()=>{var f=l.$getNearestNodeFromDOMNode(d);if(e.$isListItemNode(f)&&(f=u(f,b),null!=f)){f.selectStart();let h=c.getElementByKey(f.__key);null!=h&&(a.preventDefault(),setTimeout(()=>{h.focus()},0))}});return!1}
|
|
11
13
|
exports.CheckListPlugin=function(){let [a]=g.useLexicalComposerContext();m.useEffect(()=>k.mergeRegister(a.registerCommand(e.INSERT_CHECK_LIST_COMMAND,()=>{e.insertList(a,"check");return!0},l.COMMAND_PRIORITY_LOW),a.registerCommand(l.KEY_ARROW_DOWN_COMMAND,c=>v(c,a,!1),l.COMMAND_PRIORITY_LOW),a.registerCommand(l.KEY_ARROW_UP_COMMAND,c=>v(c,a,!0),l.COMMAND_PRIORITY_LOW),a.registerCommand(l.KEY_ESCAPE_COMMAND,()=>{if(null!=t()){let c=a.getRootElement();null!=c&&c.focus();return!0}return!1},l.COMMAND_PRIORITY_LOW),
|
|
12
14
|
a.registerCommand(l.KEY_SPACE_COMMAND,c=>{let b=t();return null!=b&&a.isEditable()?(a.update(()=>{let d=l.$getNearestNodeFromDOMNode(b);e.$isListItemNode(d)&&(c.preventDefault(),d.toggleChecked())}),!0):!1},l.COMMAND_PRIORITY_LOW),a.registerCommand(l.KEY_ARROW_LEFT_COMMAND,c=>a.getEditorState().read(()=>{var b=l.$getSelection();if(l.$isRangeSelection(b)&&b.isCollapsed()){var {anchor:d}=b;if((b="element"===d.type)||0===d.offset){d=d.getNode();let f=k.$findMatchingParent(d,h=>l.$isElementNode(h)&&!h.isInline());
|
|
@@ -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{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 s}from"@lexical/utils";import{COMMAND_PRIORITY_LOW as u,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)),u),c.registerCommand(a,(e=>N(e,c,!1)),u),c.registerCommand(g,(e=>N(e,c,!0)),u),c.registerCommand(f,(e=>{if(null!=y()){const e=c.getRootElement();return null!=e&&e.focus(),!0}return!1}),u),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)}),u),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(),s=o(t,(e=>v(e)&&!e.isInline()));if(n(s)){const n=s.getParent();if(r(n)&&"check"===n.getListType()&&(l||s.getFirstDescendant()===t)){const t=c.getElementByKey(s.__key);if(null!=t&&document.activeElement!==t)return t.focus(),e.preventDefault(),!0}}}}return!1}))),u),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/s(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())}}))})),e.stopPropagation()}function k(e){x(e,(()=>{e.preventDefault()})),e.stopPropagation()}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,12 @@ 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
|
+
|
|
33
|
+
|
|
34
|
+
// This workaround is no longer necessary in React 19,
|
|
35
|
+
// but we currently support React >=17.x
|
|
36
|
+
// https://github.com/facebook/react/pull/26395
|
|
30
37
|
const useLayoutEffectImpl = CAN_USE_DOM ? react.useLayoutEffect : react.useEffect;
|
|
31
|
-
var useLayoutEffect = useLayoutEffectImpl;
|
|
32
38
|
|
|
33
39
|
/**
|
|
34
40
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
@@ -37,11 +43,12 @@ var useLayoutEffect = useLayoutEffectImpl;
|
|
|
37
43
|
* LICENSE file in the root directory of this source tree.
|
|
38
44
|
*
|
|
39
45
|
*/
|
|
46
|
+
|
|
40
47
|
function ClearEditorPlugin({
|
|
41
48
|
onClear
|
|
42
49
|
}) {
|
|
43
50
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
44
|
-
|
|
51
|
+
useLayoutEffectImpl(() => {
|
|
45
52
|
return editor.registerCommand(lexical.CLEAR_EDITOR_COMMAND, payload => {
|
|
46
53
|
editor.update(() => {
|
|
47
54
|
if (onClear == null) {
|