@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,12 +3,27 @@
|
|
|
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
12
|
var React = require('react');
|
|
11
13
|
|
|
14
|
+
function _interopNamespaceDefault(e) {
|
|
15
|
+
var n = Object.create(null);
|
|
16
|
+
if (e) {
|
|
17
|
+
for (var k in e) {
|
|
18
|
+
n[k] = e[k];
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
n.default = e;
|
|
22
|
+
return n;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
|
|
26
|
+
|
|
12
27
|
function _extends() {
|
|
13
28
|
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
14
29
|
for (var i = 1; i < arguments.length; i++) {
|
|
@@ -41,8 +56,8 @@ const CAN_USE_DOM = typeof window !== 'undefined' && typeof window.document !==
|
|
|
41
56
|
* LICENSE file in the root directory of this source tree.
|
|
42
57
|
*
|
|
43
58
|
*/
|
|
59
|
+
|
|
44
60
|
const useLayoutEffectImpl = CAN_USE_DOM ? React.useLayoutEffect : React.useEffect;
|
|
45
|
-
var useLayoutEffect = useLayoutEffectImpl;
|
|
46
61
|
|
|
47
62
|
function ContentEditable({
|
|
48
63
|
ariaActiveDescendant,
|
|
@@ -74,13 +89,13 @@ function ContentEditable({
|
|
|
74
89
|
editor.setRootElement(rootElement);
|
|
75
90
|
}
|
|
76
91
|
}, [editor]);
|
|
77
|
-
|
|
92
|
+
useLayoutEffectImpl(() => {
|
|
78
93
|
setEditable(editor.isEditable());
|
|
79
94
|
return editor.registerEditableListener(currentIsEditable => {
|
|
80
95
|
setEditable(currentIsEditable);
|
|
81
96
|
});
|
|
82
97
|
}, [editor]);
|
|
83
|
-
return /*#__PURE__*/
|
|
98
|
+
return /*#__PURE__*/React__namespace.createElement("div", _extends({}, rest, {
|
|
84
99
|
"aria-activedescendant": !isEditable ? undefined : ariaActiveDescendant,
|
|
85
100
|
"aria-autocomplete": !isEditable ? 'none' : ariaAutoComplete,
|
|
86
101
|
"aria-controls": !isEditable ? undefined : ariaControls,
|
|
@@ -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 * as React from 'react';
|
|
9
|
-
import { useLayoutEffect
|
|
11
|
+
import { useLayoutEffect, useEffect, useState, useCallback } from 'react';
|
|
10
12
|
|
|
11
13
|
function _extends() {
|
|
12
14
|
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
@@ -40,8 +42,8 @@ const CAN_USE_DOM = typeof window !== 'undefined' && typeof window.document !==
|
|
|
40
42
|
* LICENSE file in the root directory of this source tree.
|
|
41
43
|
*
|
|
42
44
|
*/
|
|
43
|
-
|
|
44
|
-
|
|
45
|
+
|
|
46
|
+
const useLayoutEffectImpl = CAN_USE_DOM ? useLayoutEffect : useEffect;
|
|
45
47
|
|
|
46
48
|
function ContentEditable({
|
|
47
49
|
ariaActiveDescendant,
|
|
@@ -73,7 +75,7 @@ function ContentEditable({
|
|
|
73
75
|
editor.setRootElement(rootElement);
|
|
74
76
|
}
|
|
75
77
|
}, [editor]);
|
|
76
|
-
|
|
78
|
+
useLayoutEffectImpl(() => {
|
|
77
79
|
setEditable(editor.isEditable());
|
|
78
80
|
return editor.registerEditableListener(currentIsEditable => {
|
|
79
81
|
setEditable(currentIsEditable);
|
|
@@ -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 LexicalContentEditable = process.env.NODE_ENV === 'development' ? require('./LexicalContentEditable.dev.js') : require('./LexicalContentEditable.prod.js');
|
|
9
11
|
module.exports = LexicalContentEditable;
|
|
@@ -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 './LexicalContentEditable.dev.mjs';
|
|
8
10
|
import * as modProd from './LexicalContentEditable.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('./LexicalContentEditable.dev.mjs') : import('./LexicalContentEditable.prod.mjs'));
|
|
8
10
|
export const ContentEditable = mod.ContentEditable;
|
|
@@ -3,7 +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
|
-
|
|
8
|
+
|
|
9
|
+
'use strict';var a=require("@lexical/react/LexicalComposerContext"),k=require("react"),l=Object.create(null);if(k)for(var m in k)l[m]=k[m];l.default=k;function q(){q=Object.assign?Object.assign.bind():function(h){for(var e=1;e<arguments.length;e++){var f=arguments[e],c;for(c in f)Object.prototype.hasOwnProperty.call(f,c)&&(h[c]=f[c])}return h};return q.apply(this,arguments)}
|
|
10
|
+
let r="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?k.useLayoutEffect:k.useEffect;
|
|
11
|
+
exports.ContentEditable=function({ariaActiveDescendant:h,ariaAutoComplete:e,ariaControls:f,ariaDescribedBy:c,ariaExpanded:t,ariaLabel:u,ariaLabelledBy:v,ariaMultiline:w,ariaOwns:x,ariaRequired:y,autoCapitalize:z,className:A,id:B,role:n="textbox",spellCheck:C=!0,style:D,tabIndex:E,"data-testid":F,...G}){let [g]=a.useLexicalComposerContext(),[b,p]=k.useState(!1),H=k.useCallback(d=>{d&&d.ownerDocument&&d.ownerDocument.defaultView&&g.setRootElement(d)},[g]);r(()=>{p(g.isEditable());return g.registerEditableListener(d=>
|
|
12
|
+
{p(d)})},[g]);return l.createElement("div",q({},G,{"aria-activedescendant":b?h:void 0,"aria-autocomplete":b?e:"none","aria-controls":b?f:void 0,"aria-describedby":c,"aria-expanded":b?"combobox"===n?!!t:void 0:void 0,"aria-label":u,"aria-labelledby":v,"aria-multiline":w,"aria-owns":b?x:void 0,"aria-readonly":b?void 0:!0,"aria-required":y,autoCapitalize:z,className:A,contentEditable:b,"data-testid":F,id:B,ref:H,role:n,spellCheck:C,style:D,tabIndex:E}))}
|
|
@@ -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 a from"react";import{useLayoutEffect as t,useEffect as i,useState as r,useCallback as o}from"react";function n(){return n=Object.assign?Object.assign.bind():function(e){for(var a=1;a<arguments.length;a++){var t=arguments[a];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])}return e},n.apply(this,arguments)}const d="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement?t:i;function l({ariaActiveDescendant:t,ariaAutoComplete:i,ariaControls:l,ariaDescribedBy:c,ariaExpanded:s,ariaLabel:b,ariaLabelledBy:m,ariaMultiline:u,ariaOwns:p,ariaRequired:v,autoCapitalize:f,className:w,id:x,role:y="textbox",spellCheck:C=!0,style:E,tabIndex:h,"data-testid":O,...g}){const[D]=e(),[L,j]=r(!1),k=o((e=>{e&&e.ownerDocument&&e.ownerDocument.defaultView&&D.setRootElement(e)}),[D]);return d((()=>(j(D.isEditable()),D.registerEditableListener((e=>{j(e)})))),[D]),a.createElement("div",n({},g,{"aria-activedescendant":L?t:void 0,"aria-autocomplete":L?i:"none","aria-controls":L?l:void 0,"aria-describedby":c,"aria-expanded":L&&"combobox"===y?!!s:void 0,"aria-label":b,"aria-labelledby":m,"aria-multiline":u,"aria-owns":L?p:void 0,"aria-readonly":!L||void 0,"aria-required":v,autoCapitalize:f,className:w,contentEditable:L,"data-testid":O,id:x,ref:k,role:y,spellCheck:C,style:E,tabIndex:h}))}export{l as ContentEditable};
|
|
@@ -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');
|
|
@@ -11,6 +13,19 @@ var utils = require('@lexical/utils');
|
|
|
11
13
|
var lexical = require('lexical');
|
|
12
14
|
var React = require('react');
|
|
13
15
|
|
|
16
|
+
function _interopNamespaceDefault(e) {
|
|
17
|
+
var n = Object.create(null);
|
|
18
|
+
if (e) {
|
|
19
|
+
for (var k in e) {
|
|
20
|
+
n[k] = e[k];
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
n.default = e;
|
|
24
|
+
return n;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
|
|
28
|
+
|
|
14
29
|
/**
|
|
15
30
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
16
31
|
*
|
|
@@ -28,8 +43,8 @@ const CAN_USE_DOM = typeof window !== 'undefined' && typeof window.document !==
|
|
|
28
43
|
* LICENSE file in the root directory of this source tree.
|
|
29
44
|
*
|
|
30
45
|
*/
|
|
46
|
+
|
|
31
47
|
const useLayoutEffectImpl = CAN_USE_DOM ? React.useLayoutEffect : React.useEffect;
|
|
32
|
-
var useLayoutEffect = useLayoutEffectImpl;
|
|
33
48
|
|
|
34
49
|
/**
|
|
35
50
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
@@ -38,6 +53,7 @@ var useLayoutEffect = useLayoutEffectImpl;
|
|
|
38
53
|
* LICENSE file in the root directory of this source tree.
|
|
39
54
|
*
|
|
40
55
|
*/
|
|
56
|
+
|
|
41
57
|
class MenuOption {
|
|
42
58
|
constructor(key) {
|
|
43
59
|
this.key = key;
|
|
@@ -125,7 +141,7 @@ function $splitNodeContainingQuery(match) {
|
|
|
125
141
|
function getScrollParent(element, includeHidden) {
|
|
126
142
|
let style = getComputedStyle(element);
|
|
127
143
|
const excludeStaticParent = style.position === 'absolute';
|
|
128
|
-
const overflowRegex =
|
|
144
|
+
const overflowRegex = /(auto|scroll)/;
|
|
129
145
|
if (style.position === 'fixed') {
|
|
130
146
|
return document.body;
|
|
131
147
|
}
|
|
@@ -152,7 +168,7 @@ function useDynamicPositioning(resolution, targetElement, onReposition, onVisibi
|
|
|
152
168
|
React.useEffect(() => {
|
|
153
169
|
if (targetElement != null && resolution != null) {
|
|
154
170
|
const rootElement = editor.getRootElement();
|
|
155
|
-
const rootScrollParent = rootElement != null ? getScrollParent(rootElement
|
|
171
|
+
const rootScrollParent = rootElement != null ? getScrollParent(rootElement) : document.body;
|
|
156
172
|
let ticking = false;
|
|
157
173
|
let previousIsInView = isTriggerVisibleInNearestScrollContainer(targetElement, rootScrollParent);
|
|
158
174
|
const handleScroll = function () {
|
|
@@ -224,7 +240,7 @@ function LexicalMenu({
|
|
|
224
240
|
}
|
|
225
241
|
};
|
|
226
242
|
}, [editor]);
|
|
227
|
-
|
|
243
|
+
useLayoutEffectImpl(() => {
|
|
228
244
|
if (options === null) {
|
|
229
245
|
setHighlightedIndex(null);
|
|
230
246
|
} else if (selectedIndex === null) {
|
|
@@ -336,7 +352,7 @@ function useMenuAnchorRef(resolution, setResolution, className, parent = documen
|
|
|
336
352
|
if (left + menuWidth > rootElementRect.right) {
|
|
337
353
|
containerDiv.style.left = `${rootElementRect.right - menuWidth + window.pageXOffset}px`;
|
|
338
354
|
}
|
|
339
|
-
if ((top + menuHeight > window.innerHeight || top + menuHeight > rootElementRect.bottom) && top - rootElementRect.top > menuHeight) {
|
|
355
|
+
if ((top + menuHeight > window.innerHeight || top + menuHeight > rootElementRect.bottom) && top - rootElementRect.top > menuHeight + height) {
|
|
340
356
|
containerDiv.style.top = `${top - menuHeight + window.pageYOffset - height}px`;
|
|
341
357
|
}
|
|
342
358
|
}
|
|
@@ -388,6 +404,7 @@ function useMenuAnchorRef(resolution, setResolution, className, parent = documen
|
|
|
388
404
|
* LICENSE file in the root directory of this source tree.
|
|
389
405
|
*
|
|
390
406
|
*/
|
|
407
|
+
|
|
391
408
|
const PRE_PORTAL_DIV_SIZE = 1;
|
|
392
409
|
function LexicalContextMenuPlugin({
|
|
393
410
|
options,
|
|
@@ -402,7 +419,7 @@ function LexicalContextMenuPlugin({
|
|
|
402
419
|
}) {
|
|
403
420
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
404
421
|
const [resolution, setResolution] = React.useState(null);
|
|
405
|
-
const menuRef =
|
|
422
|
+
const menuRef = React__namespace.useRef(null);
|
|
406
423
|
const anchorElementRef = useMenuAnchorRef(resolution, setResolution, anchorClassName, parent);
|
|
407
424
|
const closeNodeMenu = React.useCallback(() => {
|
|
408
425
|
setResolution(null);
|
|
@@ -442,7 +459,7 @@ function LexicalContextMenuPlugin({
|
|
|
442
459
|
document.addEventListener('click', handleClick);
|
|
443
460
|
return () => document.removeEventListener('click', handleClick);
|
|
444
461
|
}, [editor, handleClick]);
|
|
445
|
-
return resolution === null || editor === null ? null : /*#__PURE__*/
|
|
462
|
+
return resolution === null || editor === null ? null : /*#__PURE__*/React__namespace.createElement(LexicalMenu, {
|
|
446
463
|
close: closeNodeMenu,
|
|
447
464
|
resolution: resolution,
|
|
448
465
|
editor: editor,
|
|
@@ -3,12 +3,14 @@
|
|
|
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 { mergeRegister, calculateZoomLevel } from '@lexical/utils';
|
|
9
11
|
import { createCommand, KEY_ARROW_DOWN_COMMAND, KEY_ARROW_UP_COMMAND, KEY_ESCAPE_COMMAND, KEY_TAB_COMMAND, KEY_ENTER_COMMAND, COMMAND_PRIORITY_LOW, $getSelection, $isRangeSelection } from 'lexical';
|
|
10
12
|
import * as React from 'react';
|
|
11
|
-
import { useLayoutEffect
|
|
13
|
+
import { useLayoutEffect, useEffect, useState, useCallback, useMemo, useRef } from 'react';
|
|
12
14
|
|
|
13
15
|
/**
|
|
14
16
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
@@ -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
|
*/
|
|
30
|
-
|
|
31
|
-
|
|
32
|
+
|
|
33
|
+
const useLayoutEffectImpl = CAN_USE_DOM ? useLayoutEffect : useEffect;
|
|
32
34
|
|
|
33
35
|
/**
|
|
34
36
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
@@ -37,6 +39,7 @@ var useLayoutEffect = useLayoutEffectImpl;
|
|
|
37
39
|
* LICENSE file in the root directory of this source tree.
|
|
38
40
|
*
|
|
39
41
|
*/
|
|
42
|
+
|
|
40
43
|
class MenuOption {
|
|
41
44
|
constructor(key) {
|
|
42
45
|
this.key = key;
|
|
@@ -124,7 +127,7 @@ function $splitNodeContainingQuery(match) {
|
|
|
124
127
|
function getScrollParent(element, includeHidden) {
|
|
125
128
|
let style = getComputedStyle(element);
|
|
126
129
|
const excludeStaticParent = style.position === 'absolute';
|
|
127
|
-
const overflowRegex =
|
|
130
|
+
const overflowRegex = /(auto|scroll)/;
|
|
128
131
|
if (style.position === 'fixed') {
|
|
129
132
|
return document.body;
|
|
130
133
|
}
|
|
@@ -151,7 +154,7 @@ function useDynamicPositioning(resolution, targetElement, onReposition, onVisibi
|
|
|
151
154
|
useEffect(() => {
|
|
152
155
|
if (targetElement != null && resolution != null) {
|
|
153
156
|
const rootElement = editor.getRootElement();
|
|
154
|
-
const rootScrollParent = rootElement != null ? getScrollParent(rootElement
|
|
157
|
+
const rootScrollParent = rootElement != null ? getScrollParent(rootElement) : document.body;
|
|
155
158
|
let ticking = false;
|
|
156
159
|
let previousIsInView = isTriggerVisibleInNearestScrollContainer(targetElement, rootScrollParent);
|
|
157
160
|
const handleScroll = function () {
|
|
@@ -223,7 +226,7 @@ function LexicalMenu({
|
|
|
223
226
|
}
|
|
224
227
|
};
|
|
225
228
|
}, [editor]);
|
|
226
|
-
|
|
229
|
+
useLayoutEffectImpl(() => {
|
|
227
230
|
if (options === null) {
|
|
228
231
|
setHighlightedIndex(null);
|
|
229
232
|
} else if (selectedIndex === null) {
|
|
@@ -335,7 +338,7 @@ function useMenuAnchorRef(resolution, setResolution, className, parent = documen
|
|
|
335
338
|
if (left + menuWidth > rootElementRect.right) {
|
|
336
339
|
containerDiv.style.left = `${rootElementRect.right - menuWidth + window.pageXOffset}px`;
|
|
337
340
|
}
|
|
338
|
-
if ((top + menuHeight > window.innerHeight || top + menuHeight > rootElementRect.bottom) && top - rootElementRect.top > menuHeight) {
|
|
341
|
+
if ((top + menuHeight > window.innerHeight || top + menuHeight > rootElementRect.bottom) && top - rootElementRect.top > menuHeight + height) {
|
|
339
342
|
containerDiv.style.top = `${top - menuHeight + window.pageYOffset - height}px`;
|
|
340
343
|
}
|
|
341
344
|
}
|
|
@@ -387,6 +390,7 @@ function useMenuAnchorRef(resolution, setResolution, className, parent = documen
|
|
|
387
390
|
* LICENSE file in the root directory of this source tree.
|
|
388
391
|
*
|
|
389
392
|
*/
|
|
393
|
+
|
|
390
394
|
const PRE_PORTAL_DIV_SIZE = 1;
|
|
391
395
|
function LexicalContextMenuPlugin({
|
|
392
396
|
options,
|
|
@@ -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 LexicalContextMenuPlugin = process.env.NODE_ENV === 'development' ? require('./LexicalContextMenuPlugin.dev.js') : require('./LexicalContextMenuPlugin.prod.js');
|
|
9
11
|
module.exports = LexicalContextMenuPlugin;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @flow strict
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* LexicalContextMenuPlugin
|
|
12
|
+
*/
|
|
@@ -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 './LexicalContextMenuPlugin.dev.mjs';
|
|
8
10
|
import * as modProd from './LexicalContextMenuPlugin.prod.mjs';
|
|
9
11
|
const mod = process.env.NODE_ENV === 'development' ? modDev : modProd;
|
|
@@ -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
|
const mod = await (process.env.NODE_ENV === 'development' ? import('./LexicalContextMenuPlugin.dev.mjs') : import('./LexicalContextMenuPlugin.prod.mjs'));
|
|
8
10
|
export const LexicalContextMenuPlugin = mod.LexicalContextMenuPlugin;
|
|
9
11
|
export const MenuOption = mod.MenuOption;
|
|
@@ -3,20 +3,22 @@
|
|
|
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
|
-
function
|
|
11
|
-
function H(c
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
g=
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
8
|
+
|
|
9
|
+
'use strict';var g=require("@lexical/react/LexicalComposerContext"),w=require("@lexical/utils"),y=require("lexical"),A=require("react"),B=Object.create(null);if(A)for(var C in A)B[C]=A[C];B.default=A;let D="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?A.useLayoutEffect:A.useEffect;class E{constructor(c){this.key=c;this.ref={current:null};this.setRefElement=this.setRefElement.bind(this)}setRefElement(c){this.ref={current:c}}}
|
|
10
|
+
let F=c=>{const a=document.getElementById("typeahead-menu");if(a){var f=a.getBoundingClientRect();f.top+f.height>window.innerHeight&&a.scrollIntoView({block:"center"});0>f.top&&a.scrollIntoView({block:"center"});c.scrollIntoView({block:"nearest"})}};
|
|
11
|
+
function G(c){var a=y.$getSelection();if(!y.$isRangeSelection(a)||!a.isCollapsed())return null;var f=a.anchor;if("text"!==f.type)return null;a=f.getNode();if(!a.isSimpleText())return null;f=f.offset;let k=a.getTextContent().slice(0,f);var d=c.matchingString;c=c.replaceableString.length;for(let n=c;n<=d.length;n++)k.substr(-n)===d.substr(0,n)&&(c=n);c=f-c;if(0>c)return null;let p;0===c?[p]=a.splitText(f):[,p]=a.splitText(c,f);return p}
|
|
12
|
+
function H(c){let a=getComputedStyle(c),f="absolute"===a.position,k=/(auto|scroll)/;if("fixed"===a.position)return document.body;for(;c=c.parentElement;)if(a=getComputedStyle(c),(!f||"static"!==a.position)&&k.test(a.overflow+a.overflowY+a.overflowX))return c;return document.body}function I(c,a){c=c.getBoundingClientRect();a=a.getBoundingClientRect();return c.top>a.top&&c.top<a.bottom}
|
|
13
|
+
function J(c,a,f,k){let [d]=g.useLexicalComposerContext();A.useEffect(()=>{if(null!=a&&null!=c){let p=d.getRootElement(),n=null!=p?H(p):document.body,x=!1,m=I(a,n),b=function(){x||(window.requestAnimationFrame(function(){f();x=!1}),x=!0);const q=I(a,n);q!==m&&(m=q,null!=k&&k(q))},h=new ResizeObserver(f);window.addEventListener("resize",f);document.addEventListener("scroll",b,{capture:!0,passive:!0});h.observe(a);return()=>{h.unobserve(a);window.removeEventListener("resize",f);document.removeEventListener("scroll",
|
|
14
|
+
b,!0)}}},[a,d,k,f,c])}let K=y.createCommand("SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND");
|
|
15
|
+
function L({close:c,editor:a,anchorElementRef:f,resolution:k,options:d,menuRenderFn:p,onSelectOption:n,shouldSplitNodeWithQuery:x=!1,commandPriority:m=y.COMMAND_PRIORITY_LOW}){let [b,h]=A.useState(null);A.useEffect(()=>{h(0)},[k.match&&k.match.matchingString]);let q=A.useCallback(e=>{a.update(()=>{const l=null!=k.match&&x?G(k.match):null;n(e,l,c,k.match?k.match.matchingString:"")})},[a,x,k.match,n,c]),t=A.useCallback(e=>{const l=a.getRootElement();null!==l&&(l.setAttribute("aria-activedescendant",
|
|
16
|
+
"typeahead-item-"+e),h(e))},[a]);A.useEffect(()=>()=>{let e=a.getRootElement();null!==e&&e.removeAttribute("aria-activedescendant")},[a]);D(()=>{null===d?h(null):null===b&&t(0)},[d,b,t]);A.useEffect(()=>w.mergeRegister(a.registerCommand(K,({option:e})=>e.ref&&null!=e.ref.current?(F(e.ref.current),!0):!1,m)),[a,t,m]);A.useEffect(()=>w.mergeRegister(a.registerCommand(y.KEY_ARROW_DOWN_COMMAND,e=>{if(null!==d&&d.length&&null!==b){let l=b!==d.length-1?b+1:0;t(l);let u=d[l];null!=u.ref&&u.ref.current&&
|
|
17
|
+
a.dispatchCommand(K,{index:l,option:u});e.preventDefault();e.stopImmediatePropagation()}return!0},m),a.registerCommand(y.KEY_ARROW_UP_COMMAND,e=>{if(null!==d&&d.length&&null!==b){var l=0!==b?b-1:d.length-1;t(l);l=d[l];null!=l.ref&&l.ref.current&&F(l.ref.current);e.preventDefault();e.stopImmediatePropagation()}return!0},m),a.registerCommand(y.KEY_ESCAPE_COMMAND,e=>{e.preventDefault();e.stopImmediatePropagation();c();return!0},m),a.registerCommand(y.KEY_TAB_COMMAND,e=>{if(null===d||null===b||null==
|
|
18
|
+
d[b])return!1;e.preventDefault();e.stopImmediatePropagation();q(d[b]);return!0},m),a.registerCommand(y.KEY_ENTER_COMMAND,e=>{if(null===d||null===b||null==d[b])return!1;null!==e&&(e.preventDefault(),e.stopImmediatePropagation());q(d[b]);return!0},m)),[q,c,a,d,b,t,m]);let v=A.useMemo(()=>({options:d,selectOptionAndCleanUp:q,selectedIndex:b,setHighlightedIndex:h}),[q,b,d]);return p(f,v,k.match?k.match.matchingString:"")}
|
|
19
|
+
function M(c,a,f,k=document.body){let [d]=g.useLexicalComposerContext(),p=A.useRef(document.createElement("div")),n=A.useCallback(()=>{p.current.style.top=p.current.style.bottom;const m=d.getRootElement(),b=p.current;var h=b.firstChild;if(null!==m&&null!==c){const {left:t,top:v,width:e,height:l}=c.getRect();b.style.top=`${v+window.pageYOffset+p.current.offsetHeight+3}px`;b.style.left=`${t+window.pageXOffset}px`;b.style.height=`${l}px`;b.style.width=`${e}px`;if(null!==h){h.style.top=`${v}`;var q=h.getBoundingClientRect();
|
|
20
|
+
h=q.height;q=q.width;const u=m.getBoundingClientRect();t+q>u.right&&(b.style.left=`${u.right-q+window.pageXOffset}px`);(v+h>window.innerHeight||v+h>u.bottom)&&v-u.top>h+l&&(b.style.top=`${v-h+window.pageYOffset-l}px`)}b.isConnected||(null!=f&&(b.className=f),b.setAttribute("aria-label","Typeahead menu"),b.setAttribute("id","typeahead-menu"),b.setAttribute("role","listbox"),b.style.display="block",b.style.position="absolute",k.append(b));p.current=b;m.setAttribute("aria-controls","typeahead-menu")}},
|
|
21
|
+
[d,c,f,k]);A.useEffect(()=>{let m=d.getRootElement();if(null!==c)return n(),()=>{null!==m&&m.removeAttribute("aria-controls");let b=p.current;null!==b&&b.isConnected&&b.remove()}},[d,n,c]);let x=A.useCallback(m=>{null!==c&&(m||a(null))},[c,a]);J(c,p.current,n,x);return p}
|
|
22
|
+
exports.LexicalContextMenuPlugin=function({options:c,onWillOpen:a,onClose:f,onOpen:k,onSelectOption:d,menuRenderFn:p,anchorClassName:n,commandPriority:x=y.COMMAND_PRIORITY_LOW,parent:m}){let [b]=g.useLexicalComposerContext(),[h,q]=A.useState(null),t=B.useRef(null);n=M(h,q,n,m);let v=A.useCallback(()=>{q(null);null!=f&&null!==h&&f()},[f,h]),e=A.useCallback(r=>{q(r);null!=k&&null===h&&k(r)},[k,h]),l=A.useCallback(r=>{r.preventDefault();null!=a&&a(r);const z=w.calculateZoomLevel(r.target);e({getRect:()=>
|
|
23
|
+
new DOMRect(r.clientX/z,r.clientY/z,1,1)})},[e,a]),u=A.useCallback(r=>{null===h||null==t.current||null==r.target||t.current.contains(r.target)||v()},[v,h]);A.useEffect(()=>{let r=b.getRootElement();if(r)return r.addEventListener("contextmenu",l),()=>r.removeEventListener("contextmenu",l)},[b,l]);A.useEffect(()=>{document.addEventListener("click",u);return()=>document.removeEventListener("click",u)},[b,u]);return null===h||null===b?null:B.createElement(L,{close:v,resolution:h,editor:b,anchorElementRef:n,
|
|
24
|
+
options:c,menuRenderFn:(r,z)=>p(r,z,{setMenuRef:N=>{t.current=N}}),onSelectOption:d,commandPriority:x})};exports.MenuOption=E
|
|
@@ -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 t}from"@lexical/react/LexicalComposerContext";import{mergeRegister as e,calculateZoomLevel as n}from"@lexical/utils";import{createCommand as o,KEY_ARROW_DOWN_COMMAND as l,KEY_ARROW_UP_COMMAND as r,KEY_ESCAPE_COMMAND as i,KEY_TAB_COMMAND as u,KEY_ENTER_COMMAND as c,COMMAND_PRIORITY_LOW as s,$getSelection as a,$isRangeSelection as m}from"lexical";import*as d from"react";import{useLayoutEffect as p,useEffect as f,useState as g,useCallback as h,useMemo as w,useRef as v}from"react";const y="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement?p:f;class b{constructor(t){this.key=t,this.ref={current:null},this.setRefElement=this.setRefElement.bind(this)}setRefElement(t){this.ref={current:t}}}const E=t=>{const e=document.getElementById("typeahead-menu");if(!e)return;const n=e.getBoundingClientRect();n.top+n.height>window.innerHeight&&e.scrollIntoView({block:"center"}),n.top<0&&e.scrollIntoView({block:"center"}),t.scrollIntoView({block:"nearest"})};function C(t,e){const n=t.getBoundingClientRect(),o=e.getBoundingClientRect();return n.top>o.top&&n.top<o.bottom}function R(e,n,o,l){const[r]=t();f((()=>{if(null!=n&&null!=e){const t=r.getRootElement(),e=null!=t?function(t,e){let n=getComputedStyle(t);const o="absolute"===n.position,l=/(auto|scroll)/;if("fixed"===n.position)return document.body;for(let e=t;e=e.parentElement;)if(n=getComputedStyle(e),(!o||"static"!==n.position)&&l.test(n.overflow+n.overflowY+n.overflowX))return e;return document.body}(t):document.body;let i=!1,u=C(n,e);const c=function(){i||(window.requestAnimationFrame((function(){o(),i=!1})),i=!0);const t=C(n,e);t!==u&&(u=t,null!=l&&l(t))},s=new ResizeObserver(o);return window.addEventListener("resize",o),document.addEventListener("scroll",c,{capture:!0,passive:!0}),s.observe(n),()=>{s.unobserve(n),window.removeEventListener("resize",o),document.removeEventListener("scroll",c,!0)}}}),[n,r,l,o,e])}const x=o("SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND");function O({close:t,editor:n,anchorElementRef:o,resolution:d,options:p,menuRenderFn:v,onSelectOption:b,shouldSplitNodeWithQuery:C=!1,commandPriority:R=s}){const[O,I]=g(null),S=d.match&&d.match.matchingString;f((()=>{I(0)}),[S]);const A=h((e=>{n.update((()=>{const n=null!=d.match&&C?function(t){const e=a();if(!m(e)||!e.isCollapsed())return null;const n=e.anchor;if("text"!==n.type)return null;const o=n.getNode();if(!o.isSimpleText())return null;const l=n.offset,r=o.getTextContent().slice(0,l),i=t.replaceableString.length,u=l-function(t,e,n){let o=n;for(let n=o;n<=e.length;n++)t.substr(-n)===e.substr(0,n)&&(o=n);return o}(r,t.matchingString,i);if(u<0)return null;let c;return 0===u?[c]=o.splitText(l):[,c]=o.splitText(u,l),c}(d.match):null;b(e,n,t,d.match?d.match.matchingString:"")}))}),[n,C,d.match,b,t]),L=h((t=>{const e=n.getRootElement();null!==e&&(e.setAttribute("aria-activedescendant","typeahead-item-"+t),I(t))}),[n]);f((()=>()=>{const t=n.getRootElement();null!==t&&t.removeAttribute("aria-activedescendant")}),[n]),y((()=>{null===p?I(null):null===O&&L(0)}),[p,O,L]),f((()=>e(n.registerCommand(x,(({option:t})=>!(!t.ref||null==t.ref.current)&&(E(t.ref.current),!0)),R))),[n,L,R]),f((()=>e(n.registerCommand(l,(t=>{const e=t;if(null!==p&&p.length&&null!==O){const t=O!==p.length-1?O+1:0;L(t);const o=p[t];null!=o.ref&&o.ref.current&&n.dispatchCommand(x,{index:t,option:o}),e.preventDefault(),e.stopImmediatePropagation()}return!0}),R),n.registerCommand(r,(t=>{const e=t;if(null!==p&&p.length&&null!==O){const t=0!==O?O-1:p.length-1;L(t);const n=p[t];null!=n.ref&&n.ref.current&&E(n.ref.current),e.preventDefault(),e.stopImmediatePropagation()}return!0}),R),n.registerCommand(i,(e=>{const n=e;return n.preventDefault(),n.stopImmediatePropagation(),t(),!0}),R),n.registerCommand(u,(t=>{const e=t;return null!==p&&null!==O&&null!=p[O]&&(e.preventDefault(),e.stopImmediatePropagation(),A(p[O]),!0)}),R),n.registerCommand(c,(t=>null!==p&&null!==O&&null!=p[O]&&(null!==t&&(t.preventDefault(),t.stopImmediatePropagation()),A(p[O]),!0)),R))),[A,t,n,p,O,L,R]);return v(o,w((()=>({options:p,selectOptionAndCleanUp:A,selectedIndex:O,setHighlightedIndex:I})),[A,O,p]),d.match?d.match.matchingString:"")}function I({options:e,onWillOpen:o,onClose:l,onOpen:r,onSelectOption:i,menuRenderFn:u,anchorClassName:c,commandPriority:a=s,parent:m}){const[p]=t(),[w,y]=g(null),b=d.useRef(null),E=function(e,n,o,l=document.body){const[r]=t(),i=v(document.createElement("div")),u=h((()=>{i.current.style.top=i.current.style.bottom;const t=r.getRootElement(),n=i.current,u=n.firstChild;if(null!==t&&null!==e){const{left:r,top:c,width:s,height:a}=e.getRect(),m=i.current.offsetHeight;if(n.style.top=`${c+window.pageYOffset+m+3}px`,n.style.left=`${r+window.pageXOffset}px`,n.style.height=`${a}px`,n.style.width=`${s}px`,null!==u){u.style.top=`${c}`;const e=u.getBoundingClientRect(),o=e.height,l=e.width,i=t.getBoundingClientRect();r+l>i.right&&(n.style.left=`${i.right-l+window.pageXOffset}px`),(c+o>window.innerHeight||c+o>i.bottom)&&c-i.top>o+a&&(n.style.top=c-o+window.pageYOffset-a+"px")}n.isConnected||(null!=o&&(n.className=o),n.setAttribute("aria-label","Typeahead menu"),n.setAttribute("id","typeahead-menu"),n.setAttribute("role","listbox"),n.style.display="block",n.style.position="absolute",l.append(n)),i.current=n,t.setAttribute("aria-controls","typeahead-menu")}}),[r,e,o,l]);f((()=>{const t=r.getRootElement();if(null!==e)return u(),()=>{null!==t&&t.removeAttribute("aria-controls");const e=i.current;null!==e&&e.isConnected&&e.remove()}}),[r,u,e]);const c=h((t=>{null!==e&&(t||n(null))}),[e,n]);return R(e,i.current,u,c),i}(w,y,c,m),C=h((()=>{y(null),null!=l&&null!==w&&l()}),[l,w]),x=h((t=>{y(t),null!=r&&null===w&&r(t)}),[r,w]),I=h((t=>{t.preventDefault(),null!=o&&o(t);const e=n(t.target);x({getRect:()=>new DOMRect(t.clientX/e,t.clientY/e,1,1)})}),[x,o]),S=h((t=>{null===w||null==b.current||null==t.target||b.current.contains(t.target)||C()}),[C,w]);return f((()=>{const t=p.getRootElement();if(t)return t.addEventListener("contextmenu",I),()=>t.removeEventListener("contextmenu",I)}),[p,I]),f((()=>(document.addEventListener("click",S),()=>document.removeEventListener("click",S))),[p,S]),null===w||null===p?null:d.createElement(O,{close:C,resolution:w,editor:p,anchorElementRef:E,options:e,menuRenderFn:(t,e)=>u(t,e,{setMenuRef:t=>{b.current=t}}),onSelectOption:i,commandPriority:a})}export{I as LexicalContextMenuPlugin,b as MenuOption};
|
|
@@ -15,6 +15,7 @@ export declare class DecoratorBlockNode extends DecoratorNode<JSX.Element> {
|
|
|
15
15
|
__format: ElementFormatType;
|
|
16
16
|
constructor(format?: ElementFormatType, key?: NodeKey);
|
|
17
17
|
exportJSON(): SerializedDecoratorBlockNode;
|
|
18
|
+
canIndent(): false;
|
|
18
19
|
createDOM(): HTMLElement;
|
|
19
20
|
updateDOM(): false;
|
|
20
21
|
setFormat(format: ElementFormatType): void;
|
|
@@ -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 lexical = require('lexical');
|
|
@@ -15,6 +17,7 @@ var lexical = require('lexical');
|
|
|
15
17
|
* LICENSE file in the root directory of this source tree.
|
|
16
18
|
*
|
|
17
19
|
*/
|
|
20
|
+
|
|
18
21
|
class DecoratorBlockNode extends lexical.DecoratorNode {
|
|
19
22
|
constructor(format, key) {
|
|
20
23
|
super(key);
|
|
@@ -27,6 +30,9 @@ class DecoratorBlockNode extends lexical.DecoratorNode {
|
|
|
27
30
|
version: 1
|
|
28
31
|
};
|
|
29
32
|
}
|
|
33
|
+
canIndent() {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
30
36
|
createDOM() {
|
|
31
37
|
return document.createElement('div');
|
|
32
38
|
}
|
|
@@ -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 { DecoratorNode } from 'lexical';
|
|
8
10
|
|
|
9
11
|
/**
|
|
@@ -13,6 +15,7 @@ import { DecoratorNode } from 'lexical';
|
|
|
13
15
|
* LICENSE file in the root directory of this source tree.
|
|
14
16
|
*
|
|
15
17
|
*/
|
|
18
|
+
|
|
16
19
|
class DecoratorBlockNode extends DecoratorNode {
|
|
17
20
|
constructor(format, key) {
|
|
18
21
|
super(key);
|
|
@@ -25,6 +28,9 @@ class DecoratorBlockNode extends DecoratorNode {
|
|
|
25
28
|
version: 1
|
|
26
29
|
};
|
|
27
30
|
}
|
|
31
|
+
canIndent() {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
28
34
|
createDOM() {
|
|
29
35
|
return document.createElement('div');
|
|
30
36
|
}
|
|
@@ -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 LexicalDecoratorBlockNode = process.env.NODE_ENV === 'development' ? require('./LexicalDecoratorBlockNode.dev.js') : require('./LexicalDecoratorBlockNode.prod.js');
|
|
9
11
|
module.exports = LexicalDecoratorBlockNode;
|
|
@@ -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 './LexicalDecoratorBlockNode.dev.mjs';
|
|
8
10
|
import * as modProd from './LexicalDecoratorBlockNode.prod.mjs';
|
|
9
11
|
const mod = process.env.NODE_ENV === 'development' ? modDev : modProd;
|
|
@@ -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
|
const mod = await (process.env.NODE_ENV === 'development' ? import('./LexicalDecoratorBlockNode.dev.mjs') : import('./LexicalDecoratorBlockNode.prod.mjs'));
|
|
8
10
|
export const $isDecoratorBlockNode = mod.$isDecoratorBlockNode;
|
|
9
11
|
export const DecoratorBlockNode = mod.DecoratorBlockNode;
|
|
@@ -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
|
+
'use strict';var b=require("lexical");class c extends b.DecoratorNode{constructor(a,d){super(d);this.__format=a||""}exportJSON(){return{format:this.__format||"",type:"decorator-block",version:1}}canIndent(){return!1}createDOM(){return document.createElement("div")}updateDOM(){return!1}setFormat(a){this.getWritable().__format=a}isInline(){return!1}}exports.$isDecoratorBlockNode=function(a){return a instanceof c};exports.DecoratorBlockNode=c
|
|
@@ -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{DecoratorNode as t}from"lexical";class r extends t{constructor(t,r){super(r),this.__format=t||""}exportJSON(){return{format:this.__format||"",type:"decorator-block",version:1}}canIndent(){return!1}createDOM(){return document.createElement("div")}updateDOM(){return!1}setFormat(t){this.getWritable().__format=t}isInline(){return!1}}function e(t){return t instanceof r}export{e as $isDecoratorBlockNode,r as DecoratorBlockNode};
|