@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,10 +3,12 @@
|
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
6
7
|
*/
|
|
8
|
+
|
|
7
9
|
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
8
10
|
import { CLEAR_EDITOR_COMMAND, $getRoot, $getSelection, $createParagraphNode, $isRangeSelection, COMMAND_PRIORITY_EDITOR } from 'lexical';
|
|
9
|
-
import { useLayoutEffect
|
|
11
|
+
import { useLayoutEffect, useEffect } from 'react';
|
|
10
12
|
|
|
11
13
|
/**
|
|
12
14
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
@@ -25,8 +27,12 @@ const CAN_USE_DOM = typeof window !== 'undefined' && typeof window.document !==
|
|
|
25
27
|
* LICENSE file in the root directory of this source tree.
|
|
26
28
|
*
|
|
27
29
|
*/
|
|
28
|
-
|
|
29
|
-
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
// This workaround is no longer necessary in React 19,
|
|
33
|
+
// but we currently support React >=17.x
|
|
34
|
+
// https://github.com/facebook/react/pull/26395
|
|
35
|
+
const useLayoutEffectImpl = CAN_USE_DOM ? useLayoutEffect : useEffect;
|
|
30
36
|
|
|
31
37
|
/**
|
|
32
38
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
@@ -35,11 +41,12 @@ var useLayoutEffect = useLayoutEffectImpl;
|
|
|
35
41
|
* LICENSE file in the root directory of this source tree.
|
|
36
42
|
*
|
|
37
43
|
*/
|
|
44
|
+
|
|
38
45
|
function ClearEditorPlugin({
|
|
39
46
|
onClear
|
|
40
47
|
}) {
|
|
41
48
|
const [editor] = useLexicalComposerContext();
|
|
42
|
-
|
|
49
|
+
useLayoutEffectImpl(() => {
|
|
43
50
|
return editor.registerCommand(CLEAR_EDITOR_COMMAND, payload => {
|
|
44
51
|
editor.update(() => {
|
|
45
52
|
if (onClear == null) {
|
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
6
7
|
*/
|
|
8
|
+
|
|
7
9
|
'use strict'
|
|
8
10
|
const LexicalClearEditorPlugin = process.env.NODE_ENV === 'development' ? require('./LexicalClearEditorPlugin.dev.js') : require('./LexicalClearEditorPlugin.prod.js');
|
|
9
11
|
module.exports = LexicalClearEditorPlugin;
|
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
6
7
|
*/
|
|
8
|
+
|
|
7
9
|
import * as modDev from './LexicalClearEditorPlugin.dev.mjs';
|
|
8
10
|
import * as modProd from './LexicalClearEditorPlugin.prod.mjs';
|
|
9
11
|
const mod = process.env.NODE_ENV === 'development' ? modDev : modProd;
|
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
6
7
|
*/
|
|
8
|
+
|
|
7
9
|
const mod = await (process.env.NODE_ENV === 'development' ? import('./LexicalClearEditorPlugin.dev.mjs') : import('./LexicalClearEditorPlugin.prod.mjs'));
|
|
8
10
|
export const ClearEditorPlugin = mod.ClearEditorPlugin;
|
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
6
7
|
*/
|
|
7
|
-
|
|
8
|
+
|
|
9
|
+
'use strict';var a=require("@lexical/react/LexicalComposerContext"),e=require("lexical"),h=require("react");let k="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?h.useLayoutEffect:h.useEffect;
|
|
8
10
|
exports.ClearEditorPlugin=function({onClear:b}){let [c]=a.useLexicalComposerContext();k(()=>c.registerCommand(e.CLEAR_EDITOR_COMMAND,()=>{c.update(()=>{if(null==b){let f=e.$getRoot(),d=e.$getSelection(),g=e.$createParagraphNode();f.clear();f.append(g);null!==d&&g.select();e.$isRangeSelection(d)&&(d.format=0)}else b()});return!0},e.COMMAND_PRIORITY_EDITOR),[c,b]);return null}
|
|
@@ -3,5 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
6
7
|
*/
|
|
7
|
-
|
|
8
|
+
|
|
9
|
+
import{useLexicalComposerContext as e}from"@lexical/react/LexicalComposerContext";import{CLEAR_EDITOR_COMMAND as o,$getRoot as t,$getSelection as n,$createParagraphNode as r,$isRangeSelection as l,COMMAND_PRIORITY_EDITOR as i}from"lexical";import{useLayoutEffect as c,useEffect as m}from"react";const a="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement?c:m;function d({onClear:c}){const[m]=e();return a((()=>m.registerCommand(o,(e=>(m.update((()=>{if(null==c){const e=t(),o=n(),i=r();e.clear(),e.append(i),null!==o&&i.select(),l(o)&&(o.format=0)}else c()})),!0)),i)),[m,c]),null}export{d as ClearEditorPlugin};
|
|
@@ -5,7 +5,9 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
|
-
export
|
|
8
|
+
export declare function ClickableLinkPlugin({ newTab, disabled, }: {
|
|
9
9
|
newTab?: boolean;
|
|
10
10
|
disabled?: boolean;
|
|
11
11
|
}): null;
|
|
12
|
+
/** @deprecated use the named export {@link ClickableLinkPlugin} */
|
|
13
|
+
export default ClickableLinkPlugin;
|
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
6
7
|
*/
|
|
8
|
+
|
|
7
9
|
'use strict';
|
|
8
10
|
|
|
9
11
|
var link = require('@lexical/link');
|
|
@@ -19,6 +21,7 @@ var react = require('react');
|
|
|
19
21
|
* LICENSE file in the root directory of this source tree.
|
|
20
22
|
*
|
|
21
23
|
*/
|
|
24
|
+
|
|
22
25
|
function findMatchingDOM(startNode, predicate) {
|
|
23
26
|
let node = startNode;
|
|
24
27
|
while (node != null) {
|
|
@@ -29,17 +32,13 @@ function findMatchingDOM(startNode, predicate) {
|
|
|
29
32
|
}
|
|
30
33
|
return null;
|
|
31
34
|
}
|
|
32
|
-
function
|
|
35
|
+
function ClickableLinkPlugin({
|
|
33
36
|
newTab = true,
|
|
34
37
|
disabled = false
|
|
35
38
|
}) {
|
|
36
39
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
37
40
|
react.useEffect(() => {
|
|
38
41
|
const onClick = event => {
|
|
39
|
-
if (disabled) {
|
|
40
|
-
event.preventDefault();
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
42
|
const target = event.target;
|
|
44
43
|
if (!(target instanceof Node)) {
|
|
45
44
|
return;
|
|
@@ -54,14 +53,16 @@ function LexicalClickableLinkPlugin({
|
|
|
54
53
|
const clickedNode = lexical.$getNearestNodeFromDOMNode(target);
|
|
55
54
|
if (clickedNode !== null) {
|
|
56
55
|
const maybeLinkNode = utils.$findMatchingParent(clickedNode, lexical.$isElementNode);
|
|
57
|
-
if (
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
56
|
+
if (!disabled) {
|
|
57
|
+
if (link.$isLinkNode(maybeLinkNode)) {
|
|
58
|
+
url = maybeLinkNode.sanitizeUrl(maybeLinkNode.getURL());
|
|
59
|
+
urlTarget = maybeLinkNode.getTarget();
|
|
60
|
+
} else {
|
|
61
|
+
const a = findMatchingDOM(target, utils.isHTMLAnchorElement);
|
|
62
|
+
if (a !== null) {
|
|
63
|
+
url = a.href;
|
|
64
|
+
urlTarget = a.target;
|
|
65
|
+
}
|
|
65
66
|
}
|
|
66
67
|
}
|
|
67
68
|
}
|
|
@@ -81,7 +82,7 @@ function LexicalClickableLinkPlugin({
|
|
|
81
82
|
event.preventDefault();
|
|
82
83
|
};
|
|
83
84
|
const onMouseUp = event => {
|
|
84
|
-
if (
|
|
85
|
+
if (event.button === 1) {
|
|
85
86
|
onClick(event);
|
|
86
87
|
}
|
|
87
88
|
};
|
|
@@ -99,4 +100,5 @@ function LexicalClickableLinkPlugin({
|
|
|
99
100
|
return null;
|
|
100
101
|
}
|
|
101
102
|
|
|
102
|
-
|
|
103
|
+
exports.ClickableLinkPlugin = ClickableLinkPlugin;
|
|
104
|
+
exports.default = ClickableLinkPlugin;
|
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
6
7
|
*/
|
|
8
|
+
|
|
7
9
|
import { $isLinkNode } from '@lexical/link';
|
|
8
10
|
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
9
11
|
import { $findMatchingParent, isHTMLAnchorElement } from '@lexical/utils';
|
|
@@ -17,6 +19,7 @@ import { useEffect } from 'react';
|
|
|
17
19
|
* LICENSE file in the root directory of this source tree.
|
|
18
20
|
*
|
|
19
21
|
*/
|
|
22
|
+
|
|
20
23
|
function findMatchingDOM(startNode, predicate) {
|
|
21
24
|
let node = startNode;
|
|
22
25
|
while (node != null) {
|
|
@@ -27,17 +30,13 @@ function findMatchingDOM(startNode, predicate) {
|
|
|
27
30
|
}
|
|
28
31
|
return null;
|
|
29
32
|
}
|
|
30
|
-
function
|
|
33
|
+
function ClickableLinkPlugin({
|
|
31
34
|
newTab = true,
|
|
32
35
|
disabled = false
|
|
33
36
|
}) {
|
|
34
37
|
const [editor] = useLexicalComposerContext();
|
|
35
38
|
useEffect(() => {
|
|
36
39
|
const onClick = event => {
|
|
37
|
-
if (disabled) {
|
|
38
|
-
event.preventDefault();
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
40
|
const target = event.target;
|
|
42
41
|
if (!(target instanceof Node)) {
|
|
43
42
|
return;
|
|
@@ -52,14 +51,16 @@ function LexicalClickableLinkPlugin({
|
|
|
52
51
|
const clickedNode = $getNearestNodeFromDOMNode(target);
|
|
53
52
|
if (clickedNode !== null) {
|
|
54
53
|
const maybeLinkNode = $findMatchingParent(clickedNode, $isElementNode);
|
|
55
|
-
if (
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
54
|
+
if (!disabled) {
|
|
55
|
+
if ($isLinkNode(maybeLinkNode)) {
|
|
56
|
+
url = maybeLinkNode.sanitizeUrl(maybeLinkNode.getURL());
|
|
57
|
+
urlTarget = maybeLinkNode.getTarget();
|
|
58
|
+
} else {
|
|
59
|
+
const a = findMatchingDOM(target, isHTMLAnchorElement);
|
|
60
|
+
if (a !== null) {
|
|
61
|
+
url = a.href;
|
|
62
|
+
urlTarget = a.target;
|
|
63
|
+
}
|
|
63
64
|
}
|
|
64
65
|
}
|
|
65
66
|
}
|
|
@@ -79,7 +80,7 @@ function LexicalClickableLinkPlugin({
|
|
|
79
80
|
event.preventDefault();
|
|
80
81
|
};
|
|
81
82
|
const onMouseUp = event => {
|
|
82
|
-
if (
|
|
83
|
+
if (event.button === 1) {
|
|
83
84
|
onClick(event);
|
|
84
85
|
}
|
|
85
86
|
};
|
|
@@ -97,4 +98,4 @@ function LexicalClickableLinkPlugin({
|
|
|
97
98
|
return null;
|
|
98
99
|
}
|
|
99
100
|
|
|
100
|
-
export {
|
|
101
|
+
export { ClickableLinkPlugin, ClickableLinkPlugin as default };
|
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
6
7
|
*/
|
|
8
|
+
|
|
7
9
|
'use strict'
|
|
8
10
|
const LexicalClickableLinkPlugin = process.env.NODE_ENV === 'development' ? require('./LexicalClickableLinkPlugin.dev.js') : require('./LexicalClickableLinkPlugin.prod.js');
|
|
9
11
|
module.exports = LexicalClickableLinkPlugin;
|
|
@@ -3,8 +3,11 @@
|
|
|
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 './LexicalClickableLinkPlugin.dev.mjs';
|
|
8
10
|
import * as modProd from './LexicalClickableLinkPlugin.prod.mjs';
|
|
9
11
|
const mod = process.env.NODE_ENV === 'development' ? modDev : modProd;
|
|
12
|
+
export const ClickableLinkPlugin = mod.ClickableLinkPlugin;
|
|
10
13
|
export default mod.default;
|
|
@@ -3,6 +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('./LexicalClickableLinkPlugin.dev.mjs') : import('./LexicalClickableLinkPlugin.prod.mjs'));
|
|
10
|
+
export const ClickableLinkPlugin = mod.ClickableLinkPlugin;
|
|
8
11
|
export default mod.default;
|
|
@@ -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 e=require("@lexical/link"),m=require("@lexical/react/LexicalComposerContext"),n=require("@lexical/utils"),t=require("lexical"),u=require("react");
|
|
10
|
+
function v({newTab:p=!0,disabled:q=!1}){let [h]=m.useLexicalComposerContext();u.useEffect(()=>{let l=b=>{const c=b.target;if(c instanceof Node){var d=t.getNearestEditorFromDOMNode(c);if(null!==d){var f=null,k=null;d.update(()=>{var a=t.$getNearestNodeFromDOMNode(c);if(null!==a&&(a=n.$findMatchingParent(a,t.$isElementNode),!q))if(e.$isLinkNode(a))f=a.sanitizeUrl(a.getURL()),k=a.getTarget();else{a:{a=n.isHTMLAnchorElement;let g=c;for(;null!=g;){if(a(g)){a=g;break a}g=g.parentNode}a=null}null!==a&&(f=
|
|
11
|
+
a.href,k=a.target)}});if(null!==f&&""!==f){d=h.getEditorState().read(t.$getSelection);if(!t.$isRangeSelection(d)||d.isCollapsed())d="auxclick"===b.type&&1===b.button,window.open(f,p||d||b.metaKey||b.ctrlKey||"_blank"===k?"_blank":"_self");b.preventDefault()}}}},r=b=>{1===b.button&&l(b)};return h.registerRootListener((b,c)=>{null!==c&&(c.removeEventListener("click",l),c.removeEventListener("mouseup",r));null!==b&&(b.addEventListener("click",l),b.addEventListener("mouseup",r))})},[h,p,q]);return null}
|
|
12
|
+
exports.ClickableLinkPlugin=v;exports.default=v
|
|
@@ -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{$isLinkNode as e}from"@lexical/link";import{useLexicalComposerContext as t}from"@lexical/react/LexicalComposerContext";import{$findMatchingParent as n,isHTMLAnchorElement as r}from"@lexical/utils";import{getNearestEditorFromDOMNode as l,$getNearestNodeFromDOMNode as o,$isElementNode as i,$getSelection as u,$isRangeSelection as a}from"lexical";import{useEffect as s}from"react";function c({newTab:c=!0,disabled:f=!1}){const[m]=t();return s((()=>{const t=t=>{const s=t.target;if(!(s instanceof Node))return;const p=l(s);if(null===p)return;let d=null,v=null;if(p.update((()=>{const t=o(s);if(null!==t){const l=n(t,i);if(!f)if(e(l))d=l.sanitizeUrl(l.getURL()),v=l.getTarget();else{const e=function(e,t){let n=e;for(;null!=n;){if(t(n))return n;n=n.parentNode}return null}(s,r);null!==e&&(d=e.href,v=e.target)}}})),null===d||""===d)return;const x=m.getEditorState().read(u);if(a(x)&&!x.isCollapsed())return void t.preventDefault();const g="auxclick"===t.type&&1===t.button;window.open(d,c||g||t.metaKey||t.ctrlKey||"_blank"===v?"_blank":"_self"),t.preventDefault()},s=e=>{1===e.button&&t(e)};return m.registerRootListener(((e,n)=>{null!==n&&(n.removeEventListener("click",t),n.removeEventListener("mouseup",s)),null!==e&&(e.addEventListener("click",t),e.addEventListener("mouseup",s))}))}),[m,c,f]),null}export{c as ClickableLinkPlugin,c as default};
|
|
@@ -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 react = require('react');
|
|
@@ -15,6 +17,7 @@ var react = require('react');
|
|
|
15
17
|
* LICENSE file in the root directory of this source tree.
|
|
16
18
|
*
|
|
17
19
|
*/
|
|
20
|
+
|
|
18
21
|
const entries = [['Cat', 'rgb(125, 50, 0)'], ['Dog', 'rgb(100, 0, 0)'], ['Rabbit', 'rgb(150, 0, 0)'], ['Frog', 'rgb(200, 0, 0)'], ['Fox', 'rgb(200, 75, 0)'], ['Hedgehog', 'rgb(0, 75, 0)'], ['Pigeon', 'rgb(0, 125, 0)'], ['Squirrel', 'rgb(75, 100, 0)'], ['Bear', 'rgb(125, 100, 0)'], ['Tiger', 'rgb(0, 0, 150)'], ['Leopard', 'rgb(0, 0, 200)'], ['Zebra', 'rgb(0, 0, 250)'], ['Wolf', 'rgb(0, 100, 150)'], ['Owl', 'rgb(0, 100, 100)'], ['Gull', 'rgb(100, 0, 100)'], ['Squid', 'rgb(150, 0, 150)']];
|
|
19
22
|
const randomEntry = entries[Math.floor(Math.random() * entries.length)];
|
|
20
23
|
const CollaborationContext = /*#__PURE__*/react.createContext({
|
|
@@ -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 { createContext, useContext } from 'react';
|
|
8
10
|
|
|
9
11
|
/**
|
|
@@ -13,6 +15,7 @@ import { createContext, useContext } from 'react';
|
|
|
13
15
|
* LICENSE file in the root directory of this source tree.
|
|
14
16
|
*
|
|
15
17
|
*/
|
|
18
|
+
|
|
16
19
|
const entries = [['Cat', 'rgb(125, 50, 0)'], ['Dog', 'rgb(100, 0, 0)'], ['Rabbit', 'rgb(150, 0, 0)'], ['Frog', 'rgb(200, 0, 0)'], ['Fox', 'rgb(200, 75, 0)'], ['Hedgehog', 'rgb(0, 75, 0)'], ['Pigeon', 'rgb(0, 125, 0)'], ['Squirrel', 'rgb(75, 100, 0)'], ['Bear', 'rgb(125, 100, 0)'], ['Tiger', 'rgb(0, 0, 150)'], ['Leopard', 'rgb(0, 0, 200)'], ['Zebra', 'rgb(0, 0, 250)'], ['Wolf', 'rgb(0, 100, 150)'], ['Owl', 'rgb(0, 100, 100)'], ['Gull', 'rgb(100, 0, 100)'], ['Squid', 'rgb(150, 0, 150)']];
|
|
17
20
|
const randomEntry = entries[Math.floor(Math.random() * entries.length)];
|
|
18
21
|
const CollaborationContext = /*#__PURE__*/createContext({
|
|
@@ -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 LexicalCollaborationContext = process.env.NODE_ENV === 'development' ? require('./LexicalCollaborationContext.dev.js') : require('./LexicalCollaborationContext.prod.js');
|
|
9
11
|
module.exports = LexicalCollaborationContext;
|
|
@@ -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 './LexicalCollaborationContext.dev.mjs';
|
|
8
10
|
import * as modProd from './LexicalCollaborationContext.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('./LexicalCollaborationContext.dev.mjs') : import('./LexicalCollaborationContext.prod.mjs'));
|
|
8
10
|
export const CollaborationContext = mod.CollaborationContext;
|
|
9
11
|
export const useCollaborationContext = mod.useCollaborationContext;
|
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
6
7
|
*/
|
|
8
|
+
|
|
7
9
|
'use strict';var b=require("react");
|
|
8
10
|
let c=[["Cat","rgb(125, 50, 0)"],["Dog","rgb(100, 0, 0)"],["Rabbit","rgb(150, 0, 0)"],["Frog","rgb(200, 0, 0)"],["Fox","rgb(200, 75, 0)"],["Hedgehog","rgb(0, 75, 0)"],["Pigeon","rgb(0, 125, 0)"],["Squirrel","rgb(75, 100, 0)"],["Bear","rgb(125, 100, 0)"],["Tiger","rgb(0, 0, 150)"],["Leopard","rgb(0, 0, 200)"],["Zebra","rgb(0, 0, 250)"],["Wolf","rgb(0, 100, 150)"],["Owl","rgb(0, 100, 100)"],["Gull","rgb(100, 0, 100)"],["Squid","rgb(150, 0, 150)"]],d=c[Math.floor(Math.random()*c.length)],e=b.createContext({clientID:0,
|
|
9
11
|
color:d[1],isCollabActive:!1,name:d[0],yjsDocMap:new Map});exports.CollaborationContext=e;exports.useCollaborationContext=function(f,g){let a=b.useContext(e);null!=f&&(a.name=f);null!=g&&(a.color=g);return a}
|
|
@@ -3,5 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
6
7
|
*/
|
|
8
|
+
|
|
7
9
|
import{createContext as r,useContext as g}from"react";const o=[["Cat","rgb(125, 50, 0)"],["Dog","rgb(100, 0, 0)"],["Rabbit","rgb(150, 0, 0)"],["Frog","rgb(200, 0, 0)"],["Fox","rgb(200, 75, 0)"],["Hedgehog","rgb(0, 75, 0)"],["Pigeon","rgb(0, 125, 0)"],["Squirrel","rgb(75, 100, 0)"],["Bear","rgb(125, 100, 0)"],["Tiger","rgb(0, 0, 150)"],["Leopard","rgb(0, 0, 200)"],["Zebra","rgb(0, 0, 250)"],["Wolf","rgb(0, 100, 150)"],["Owl","rgb(0, 100, 100)"],["Gull","rgb(100, 0, 100)"],["Squid","rgb(150, 0, 150)"]],b=o[Math.floor(Math.random()*o.length)],e=r({clientID:0,color:b[1],isCollabActive:!1,name:b[0],yjsDocMap:new Map});function l(r,o){const b=g(e);return null!=r&&(b.name=r),null!=o&&(b.color=o),b}export{e as CollaborationContext,l as useCollaborationContext};
|
|
@@ -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 LexicalCollaborationContext = require('@lexical/react/LexicalCollaborationContext');
|
|
@@ -14,6 +16,20 @@ var yjs = require('@lexical/yjs');
|
|
|
14
16
|
var lexical = require('lexical');
|
|
15
17
|
var reactDom = require('react-dom');
|
|
16
18
|
var yjs$1 = require('yjs');
|
|
19
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
20
|
+
|
|
21
|
+
function _interopNamespaceDefault(e) {
|
|
22
|
+
var n = Object.create(null);
|
|
23
|
+
if (e) {
|
|
24
|
+
for (var k in e) {
|
|
25
|
+
n[k] = e[k];
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
n.default = e;
|
|
29
|
+
return n;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
|
|
17
33
|
|
|
18
34
|
/**
|
|
19
35
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
@@ -22,6 +38,7 @@ var yjs$1 = require('yjs');
|
|
|
22
38
|
* LICENSE file in the root directory of this source tree.
|
|
23
39
|
*
|
|
24
40
|
*/
|
|
41
|
+
|
|
25
42
|
function useYjsCollaboration(editor, id, provider, docMap, name, color, shouldBootstrap, cursorsContainerRef, initialEditorState, excludedProperties, awarenessData) {
|
|
26
43
|
const isReloadingDoc = React.useRef(false);
|
|
27
44
|
const [doc, setDoc] = React.useState(docMap.get(id));
|
|
@@ -107,7 +124,7 @@ function useYjsCollaboration(editor, id, provider, docMap, name, color, shouldBo
|
|
|
107
124
|
const ref = element => {
|
|
108
125
|
binding.cursorsContainer = element;
|
|
109
126
|
};
|
|
110
|
-
return /*#__PURE__*/reactDom.createPortal( /*#__PURE__*/
|
|
127
|
+
return /*#__PURE__*/reactDom.createPortal( /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
111
128
|
ref: ref
|
|
112
129
|
}), cursorsContainerRef && cursorsContainerRef.current || document.body);
|
|
113
130
|
}, [binding, cursorsContainerRef]);
|
|
@@ -163,7 +180,7 @@ function useYjsHistory(editor, binding) {
|
|
|
163
180
|
}, [undoManager]);
|
|
164
181
|
|
|
165
182
|
// Exposing undo and redo states
|
|
166
|
-
|
|
183
|
+
React__namespace.useEffect(() => {
|
|
167
184
|
const updateUndoRedoStates = () => {
|
|
168
185
|
editor.dispatchCommand(lexical.CAN_UNDO_COMMAND, undoManager.undoStack.length > 0);
|
|
169
186
|
editor.dispatchCommand(lexical.CAN_REDO_COMMAND, undoManager.redoStack.length > 0);
|
|
@@ -270,6 +287,7 @@ function clearEditorSkipCollab(editor, binding) {
|
|
|
270
287
|
* LICENSE file in the root directory of this source tree.
|
|
271
288
|
*
|
|
272
289
|
*/
|
|
290
|
+
|
|
273
291
|
function CollaborationPlugin({
|
|
274
292
|
id,
|
|
275
293
|
providerFactory,
|
|
@@ -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 { useCollaborationContext } from '@lexical/react/LexicalCollaborationContext';
|
|
8
10
|
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
9
11
|
import * as React from 'react';
|
|
@@ -13,6 +15,7 @@ import { createBinding, initLocalState, syncLexicalUpdateToYjs, TOGGLE_CONNECT_C
|
|
|
13
15
|
import { COMMAND_PRIORITY_EDITOR, FOCUS_COMMAND, BLUR_COMMAND, UNDO_COMMAND, REDO_COMMAND, CAN_UNDO_COMMAND, CAN_REDO_COMMAND, $getRoot, $createParagraphNode, $getSelection } from 'lexical';
|
|
14
16
|
import { createPortal } from 'react-dom';
|
|
15
17
|
import { UndoManager } from 'yjs';
|
|
18
|
+
import { jsx } from 'react/jsx-runtime';
|
|
16
19
|
|
|
17
20
|
/**
|
|
18
21
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
@@ -21,6 +24,7 @@ import { UndoManager } from 'yjs';
|
|
|
21
24
|
* LICENSE file in the root directory of this source tree.
|
|
22
25
|
*
|
|
23
26
|
*/
|
|
27
|
+
|
|
24
28
|
function useYjsCollaboration(editor, id, provider, docMap, name, color, shouldBootstrap, cursorsContainerRef, initialEditorState, excludedProperties, awarenessData) {
|
|
25
29
|
const isReloadingDoc = useRef(false);
|
|
26
30
|
const [doc, setDoc] = useState(docMap.get(id));
|
|
@@ -106,7 +110,7 @@ function useYjsCollaboration(editor, id, provider, docMap, name, color, shouldBo
|
|
|
106
110
|
const ref = element => {
|
|
107
111
|
binding.cursorsContainer = element;
|
|
108
112
|
};
|
|
109
|
-
return /*#__PURE__*/createPortal( /*#__PURE__*/
|
|
113
|
+
return /*#__PURE__*/createPortal( /*#__PURE__*/jsx("div", {
|
|
110
114
|
ref: ref
|
|
111
115
|
}), cursorsContainerRef && cursorsContainerRef.current || document.body);
|
|
112
116
|
}, [binding, cursorsContainerRef]);
|
|
@@ -269,6 +273,7 @@ function clearEditorSkipCollab(editor, binding) {
|
|
|
269
273
|
* LICENSE file in the root directory of this source tree.
|
|
270
274
|
*
|
|
271
275
|
*/
|
|
276
|
+
|
|
272
277
|
function CollaborationPlugin({
|
|
273
278
|
id,
|
|
274
279
|
providerFactory,
|
|
@@ -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 LexicalCollaborationPlugin = process.env.NODE_ENV === 'development' ? require('./LexicalCollaborationPlugin.dev.js') : require('./LexicalCollaborationPlugin.prod.js');
|
|
9
11
|
module.exports = LexicalCollaborationPlugin;
|
|
@@ -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 './LexicalCollaborationPlugin.dev.mjs';
|
|
8
10
|
import * as modProd from './LexicalCollaborationPlugin.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('./LexicalCollaborationPlugin.dev.mjs') : import('./LexicalCollaborationPlugin.prod.mjs'));
|
|
8
10
|
export const CollaborationPlugin = mod.CollaborationPlugin;
|
|
@@ -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
|
*/
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
function
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
function
|
|
16
|
-
|
|
8
|
+
|
|
9
|
+
'use strict';var e=require("@lexical/react/LexicalCollaborationContext"),g=require("@lexical/react/LexicalComposerContext"),k=require("react"),B=require("@lexical/utils"),C=require("@lexical/yjs"),D=require("lexical"),L=require("react-dom"),M=require("yjs"),N=require("react/jsx-runtime"),O=Object.create(null);if(k)for(var P in k)O[P]=k[P];O.default=k;
|
|
10
|
+
function Q(b,c,a,d,f,z,A,v,w,n,t){let q=k.useRef(!1),[x,r]=k.useState(d.get(c)),h=k.useMemo(()=>C.createBinding(b,a,c,x,d,n),[b,a,c,d,x,n]),p=k.useCallback(()=>{a.connect()},[a]),y=k.useCallback(()=>{try{a.disconnect()}catch(m){}},[a]);k.useEffect(()=>{let {root:m}=h,{awareness:E}=a,F=({status:l})=>{b.dispatchCommand(C.CONNECTED_COMMAND,"connected"===l)},G=l=>{A&&l&&m.isEmpty()&&0===m._xmlText._length&&!1===q.current&&R(b,w);q.current=!1},H=()=>{C.syncCursorPositions(h,a)},I=(l,u)=>{u=u.origin;u!==
|
|
11
|
+
h&&C.syncYjsChangesToLexical(h,a,l,u instanceof M.UndoManager)};C.initLocalState(a,f,z,document.activeElement===b.getRootElement(),t||{});let J=l=>{S(b,h);r(l);d.set(c,l);q.current=!0};a.on("reload",J);a.on("status",F);a.on("sync",G);E.on("update",H);m.getSharedType().observeDeep(I);let W=b.registerUpdateListener(({prevEditorState:l,editorState:u,dirtyLeaves:T,dirtyElements:U,normalizedNodes:V,tags:K})=>{!1===K.has("skip-collab")&&C.syncLexicalUpdateToYjs(h,a,l,u,U,T,V,K)});p();return()=>{!1===q.current&&
|
|
12
|
+
y();a.off("sync",G);a.off("status",F);a.off("reload",J);E.off("update",H);m.getSharedType().unobserveDeep(I);d.delete(c);W()}},[h,z,p,y,d,b,c,w,f,a,A,t]);let X=k.useMemo(()=>L.createPortal(N.jsx("div",{ref:m=>{h.cursorsContainer=m}}),v&&v.current||document.body),[h,v]);k.useEffect(()=>b.registerCommand(C.TOGGLE_CONNECT_COMMAND,m=>{void 0!==p&&void 0!==y&&(m?(console.log("Collaboration connected!"),p()):(console.log("Collaboration disconnected!"),y()));return!0},D.COMMAND_PRIORITY_EDITOR),[p,y,b]);
|
|
13
|
+
return[X,h]}function Y(b,c,a,d,f){k.useEffect(()=>B.mergeRegister(b.registerCommand(D.FOCUS_COMMAND,()=>{C.setLocalStateFocus(c,a,d,!0,f||{});return!1},D.COMMAND_PRIORITY_EDITOR),b.registerCommand(D.BLUR_COMMAND,()=>{C.setLocalStateFocus(c,a,d,!1,f||{});return!1},D.COMMAND_PRIORITY_EDITOR)),[d,b,a,c,f])}
|
|
14
|
+
function Z(b,c){let a=k.useMemo(()=>C.createUndoManager(c,c.root.getSharedType()),[c]);k.useEffect(()=>B.mergeRegister(b.registerCommand(D.UNDO_COMMAND,()=>{a.undo();return!0},D.COMMAND_PRIORITY_EDITOR),b.registerCommand(D.REDO_COMMAND,()=>{a.redo();return!0},D.COMMAND_PRIORITY_EDITOR)));let d=k.useCallback(()=>{a.clear()},[a]);O.useEffect(()=>{let f=()=>{b.dispatchCommand(D.CAN_UNDO_COMMAND,0<a.undoStack.length);b.dispatchCommand(D.CAN_REDO_COMMAND,0<a.redoStack.length)};a.on("stack-item-added",
|
|
15
|
+
f);a.on("stack-item-popped",f);a.on("stack-cleared",f);return()=>{a.off("stack-item-added",f);a.off("stack-item-popped",f);a.off("stack-cleared",f)}},[b,a]);return d}
|
|
16
|
+
function R(b,c){b.update(()=>{var a=D.$getRoot();if(a.isEmpty())if(c)switch(typeof c){case "string":var d=b.parseEditorState(c);b.setEditorState(d,{tag:"history-merge"});break;case "object":b.setEditorState(c,{tag:"history-merge"});break;case "function":b.update(()=>{D.$getRoot().isEmpty()&&c(b)},{tag:"history-merge"})}else d=D.$createParagraphNode(),a.append(d),{activeElement:a}=document,(null!==D.$getSelection()||null!==a&&a===b.getRootElement())&&d.select()},{tag:"history-merge"})}
|
|
17
|
+
function S(b,c){b.update(()=>{let d=D.$getRoot();d.clear();d.select()},{tag:"skip-collab"});if(null!=c.cursors&&(b=c.cursors,null!=b&&(c=c.cursorsContainer,null!=c))){b=Array.from(b.values());for(let d=0;d<b.length;d++){var a=b[d].selection;if(a&&null!=a.selections){a=a.selections;for(let f=0;f<a.length;f++)c.removeChild(a[d])}}}}
|
|
18
|
+
exports.CollaborationPlugin=function({id:b,providerFactory:c,shouldBootstrap:a,username:d,cursorColor:f,cursorsContainerRef:z,initialEditorState:A,excludedProperties:v,awarenessData:w}){let n=e.useCollaborationContext(d,f),{yjsDocMap:t,name:q,color:x}=n,[r]=g.useLexicalComposerContext();k.useEffect(()=>{n.isCollabActive=!0;return()=>{null==r._parentEditor&&(n.isCollabActive=!1)}},[n,r]);d=k.useMemo(()=>c(b,t),[b,c,t]);let [h,p]=Q(r,b,d,t,q,x,a,z,A,v,w);n.clientID=p.clientID;Z(r,p);Y(r,d,q,x,w);return h}
|