@lexical/react 0.14.5 → 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 -20
- 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,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');
|
|
@@ -13,6 +15,19 @@ var utils = require('@lexical/utils');
|
|
|
13
15
|
var lexical = require('lexical');
|
|
14
16
|
var React = require('react');
|
|
15
17
|
|
|
18
|
+
function _interopNamespaceDefault(e) {
|
|
19
|
+
var n = Object.create(null);
|
|
20
|
+
if (e) {
|
|
21
|
+
for (var k in e) {
|
|
22
|
+
n[k] = e[k];
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
n.default = e;
|
|
26
|
+
return n;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
|
|
30
|
+
|
|
16
31
|
/**
|
|
17
32
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
18
33
|
*
|
|
@@ -20,6 +35,7 @@ var React = require('react');
|
|
|
20
35
|
* LICENSE file in the root directory of this source tree.
|
|
21
36
|
*
|
|
22
37
|
*/
|
|
38
|
+
|
|
23
39
|
const URL_MATCHER = /((https?:\/\/(www\.)?)|(www\.))[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)/;
|
|
24
40
|
const INSERT_EMBED_COMMAND = lexical.createCommand('INSERT_EMBED_COMMAND');
|
|
25
41
|
class AutoEmbedOption extends LexicalNodeMenuPlugin.MenuOption {
|
|
@@ -119,7 +135,7 @@ function LexicalAutoEmbedPlugin({
|
|
|
119
135
|
closeMenu();
|
|
120
136
|
});
|
|
121
137
|
}, [editor]);
|
|
122
|
-
return nodeKey != null ? /*#__PURE__*/
|
|
138
|
+
return nodeKey != null ? /*#__PURE__*/React__namespace.createElement(LexicalNodeMenuPlugin.LexicalNodeMenuPlugin, {
|
|
123
139
|
nodeKey: nodeKey,
|
|
124
140
|
onClose: reset,
|
|
125
141
|
onSelectOption: onSelectOption,
|
|
@@ -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, LinkNode, AutoLinkNode } from '@lexical/link';
|
|
8
10
|
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
9
11
|
import { MenuOption, LexicalNodeMenuPlugin } from '@lexical/react/LexicalNodeMenuPlugin';
|
|
@@ -19,6 +21,7 @@ import { useState, useCallback, useEffect, useMemo } from 'react';
|
|
|
19
21
|
* LICENSE file in the root directory of this source tree.
|
|
20
22
|
*
|
|
21
23
|
*/
|
|
24
|
+
|
|
22
25
|
const URL_MATCHER = /((https?:\/\/(www\.)?)|(www\.))[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)/;
|
|
23
26
|
const INSERT_EMBED_COMMAND = createCommand('INSERT_EMBED_COMMAND');
|
|
24
27
|
class AutoEmbedOption extends MenuOption {
|
|
@@ -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 LexicalAutoEmbedPlugin = process.env.NODE_ENV === 'development' ? require('./LexicalAutoEmbedPlugin.dev.js') : require('./LexicalAutoEmbedPlugin.prod.js');
|
|
9
11
|
module.exports = LexicalAutoEmbedPlugin;
|
|
@@ -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 './LexicalAutoEmbedPlugin.dev.mjs';
|
|
8
10
|
import * as modProd from './LexicalAutoEmbedPlugin.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('./LexicalAutoEmbedPlugin.dev.mjs') : import('./LexicalAutoEmbedPlugin.prod.mjs'));
|
|
8
10
|
export const AutoEmbedOption = mod.AutoEmbedOption;
|
|
9
11
|
export const INSERT_EMBED_COMMAND = mod.INSERT_EMBED_COMMAND;
|
|
@@ -3,9 +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
|
*/
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
|
|
9
|
+
'use strict';var b=require("@lexical/link"),k=require("@lexical/react/LexicalComposerContext"),l=require("@lexical/react/LexicalNodeMenuPlugin"),q=require("@lexical/utils"),r=require("lexical"),t=require("react"),u=Object.create(null);if(t)for(var B in t)u[B]=t[B];u.default=t;let C=r.createCommand("INSERT_EMBED_COMMAND");class D extends l.MenuOption{constructor(f,n){super(f);this.title=f;this.onSelect=n.onSelect.bind(this)}}exports.AutoEmbedOption=D;exports.INSERT_EMBED_COMMAND=C;
|
|
10
|
+
exports.LexicalAutoEmbedPlugin=function({embedConfigs:f,onOpenEmbedModalForConfig:n,getMenuOptions:v,menuRenderFn:E,menuCommandPriority:F=r.COMMAND_PRIORITY_LOW}){let [d]=k.useLexicalComposerContext(),[g,w]=t.useState(null),[h,x]=t.useState(null),m=t.useCallback(()=>{w(null);x(null)},[]),y=t.useCallback(c=>{d.getEditorState().read(async function(){const a=r.$getNodeByKey(c);if(b.$isLinkNode(a))for(let e=0;e<f.length;e++){const p=f[e];null!=await Promise.resolve(p.parseUrl(a.__url))&&(x(p),w(a.getKey()))}})},
|
|
11
|
+
[d,f]);t.useEffect(()=>{let c=(a,{updateTags:e,dirtyLeaves:p})=>{for(const [z,G]of a)"created"===G&&e.has("paste")&&3>=p.size?y(z):z===g&&m()};return q.mergeRegister(...[b.LinkNode,b.AutoLinkNode].map(a=>d.registerMutationListener(a,(...e)=>c(...e))))},[y,d,f,g,m]);t.useEffect(()=>d.registerCommand(C,c=>{let a=f.find(({type:e})=>e===c);return a?(n(a),!0):!1},r.COMMAND_PRIORITY_EDITOR),[d,f,n]);let A=t.useCallback(async function(){if(null!=h&&null!=g){const c=d.getEditorState().read(()=>{const a=r.$getNodeByKey(g);
|
|
12
|
+
return b.$isLinkNode(a)?a:null});if(b.$isLinkNode(c)){const a=await Promise.resolve(h.parseUrl(c.__url));null!=a&&d.update(()=>{r.$getSelection()||c.selectEnd();h.insertNode(d,a);c.isAttached()&&c.remove()})}}},[h,d,g]),H=t.useMemo(()=>null!=h&&null!=g?v(h,A,m):[],[h,A,v,g,m]),I=t.useCallback((c,a,e)=>{d.update(()=>{c.onSelect(a);e()})},[d]);return null!=g?u.createElement(l.LexicalNodeMenuPlugin,{nodeKey:g,onClose:m,onSelectOption:I,options:H,menuRenderFn:E,commandPriority:F}):null};
|
|
11
13
|
exports.URL_MATCHER=/((https?:\/\/(www\.)?)|(www\.))[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)/
|
|
@@ -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{$isLinkNode as e,LinkNode as t,AutoLinkNode as n}from"@lexical/link";import{useLexicalComposerContext as o}from"@lexical/react/LexicalComposerContext";import{MenuOption as r,LexicalNodeMenuPlugin as l}from"@lexical/react/LexicalNodeMenuPlugin";import{mergeRegister as i}from"@lexical/utils";import{createCommand as s,$getNodeByKey as a,COMMAND_PRIORITY_EDITOR as c,$getSelection as u,COMMAND_PRIORITY_LOW as m}from"lexical";import*as d from"react";import{useState as p,useCallback as f,useEffect as g,useMemo as x}from"react";const w=/((https?:\/\/(www\.)?)|(www\.))[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)/,y=s("INSERT_EMBED_COMMAND");class C extends r{constructor(e,t){super(e),this.title=e,this.onSelect=t.onSelect.bind(this)}}function E({embedConfigs:r,onOpenEmbedModalForConfig:s,getMenuOptions:w,menuRenderFn:C,menuCommandPriority:E=m}){const[_]=o(),[h,M]=p(null),[S,A]=p(null),P=f((()=>{M(null),A(null)}),[]),b=f((t=>{_.getEditorState().read((async function(){const n=a(t);if(e(n))for(let e=0;e<r.length;e++){const t=r[e];null!=await Promise.resolve(t.parseUrl(n.__url))&&(A(t),M(n.getKey()))}}))}),[_,r]);g((()=>i(...[t,n].map((e=>_.registerMutationListener(e,((...e)=>((e,{updateTags:t,dirtyLeaves:n})=>{for(const[o,r]of e)"created"===r&&t.has("paste")&&n.size<=3?b(o):o===h&&P()})(...e))))))),[b,_,r,h,P]),g((()=>_.registerCommand(y,(e=>{const t=r.find((({type:t})=>t===e));return!!t&&(s(t),!0)}),c)),[_,r,s]);const v=f((async function(){if(null!=S&&null!=h){const t=_.getEditorState().read((()=>{const t=a(h);return e(t)?t:null}));if(e(t)){const e=await Promise.resolve(S.parseUrl(t.__url));null!=e&&_.update((()=>{u()||t.selectEnd(),S.insertNode(_,e),t.isAttached()&&t.remove()}))}}}),[S,_,h]),z=x((()=>null!=S&&null!=h?w(S,v,P):[]),[S,v,w,h,P]),L=f(((e,t,n)=>{_.update((()=>{e.onSelect(t),n()}))}),[_]);return null!=h?d.createElement(l,{nodeKey:h,onClose:P,onSelectOption:L,options:z,menuRenderFn:C,commandPriority:E}):null}export{C as AutoEmbedOption,y as INSERT_EMBED_COMMAND,E as LexicalAutoEmbedPlugin,w as URL_MATCHER};
|
|
@@ -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');
|
|
@@ -16,6 +18,7 @@ var react = require('react');
|
|
|
16
18
|
* LICENSE file in the root directory of this source tree.
|
|
17
19
|
*
|
|
18
20
|
*/
|
|
21
|
+
|
|
19
22
|
function AutoFocusPlugin({
|
|
20
23
|
defaultSelection
|
|
21
24
|
}) {
|
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
6
7
|
*/
|
|
8
|
+
|
|
7
9
|
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
8
10
|
import { useEffect } from 'react';
|
|
9
11
|
|
|
@@ -14,6 +16,7 @@ import { useEffect } from 'react';
|
|
|
14
16
|
* LICENSE file in the root directory of this source tree.
|
|
15
17
|
*
|
|
16
18
|
*/
|
|
19
|
+
|
|
17
20
|
function AutoFocusPlugin({
|
|
18
21
|
defaultSelection
|
|
19
22
|
}) {
|
|
@@ -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 LexicalAutoFocusPlugin = process.env.NODE_ENV === 'development' ? require('./LexicalAutoFocusPlugin.dev.js') : require('./LexicalAutoFocusPlugin.prod.js');
|
|
9
11
|
module.exports = LexicalAutoFocusPlugin;
|
|
@@ -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 './LexicalAutoFocusPlugin.dev.mjs';
|
|
8
10
|
import * as modProd from './LexicalAutoFocusPlugin.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('./LexicalAutoFocusPlugin.dev.mjs') : import('./LexicalAutoFocusPlugin.prod.mjs'));
|
|
8
10
|
export const AutoFocusPlugin = mod.AutoFocusPlugin;
|
|
@@ -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
|
'use strict';var e=require("@lexical/react/LexicalComposerContext"),f=require("react");exports.AutoFocusPlugin=function({defaultSelection:c}){let [a]=e.useLexicalComposerContext();f.useEffect(()=>{a.focus(()=>{let d=document.activeElement,b=a.getRootElement();null===b||null!==d&&b.contains(d)||b.focus({preventScroll:!0})},{defaultSelection:c})},[c,a]);return null}
|
|
@@ -3,5 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
6
7
|
*/
|
|
8
|
+
|
|
7
9
|
import{useLexicalComposerContext as e}from"@lexical/react/LexicalComposerContext";import{useEffect as t}from"react";function o({defaultSelection:o}){const[l]=e();return t((()=>{l.focus((()=>{const e=document.activeElement,t=l.getRootElement();null===t||null!==e&&t.contains(e)||t.focus({preventScroll:!0})}),{defaultSelection:o})}),[o,l]),null}export{o as AutoFocusPlugin};
|
|
@@ -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 createLinkMatcherWithRegExp(regExp, urlTransformer = text => text) {
|
|
23
26
|
return text => {
|
|
24
27
|
const match = regExp.exec(text);
|
|
@@ -100,7 +103,7 @@ function extractMatchingNodes(nodes, startIndex, endIndex) {
|
|
|
100
103
|
}
|
|
101
104
|
return [matchingOffset, unmodifiedBeforeNodes, matchingNodes, unmodifiedAfterNodes];
|
|
102
105
|
}
|
|
103
|
-
function
|
|
106
|
+
function $createAutoLinkNode_(nodes, startIndex, endIndex, match) {
|
|
104
107
|
const linkNode = link.$createAutoLinkNode(match.url, match.attributes);
|
|
105
108
|
if (nodes.length === 1) {
|
|
106
109
|
let remainingTextNode = nodes[0];
|
|
@@ -113,6 +116,7 @@ function createAutoLinkNode(nodes, startIndex, endIndex, match) {
|
|
|
113
116
|
const textNode = lexical.$createTextNode(match.text);
|
|
114
117
|
textNode.setFormat(linkTextNode.getFormat());
|
|
115
118
|
textNode.setDetail(linkTextNode.getDetail());
|
|
119
|
+
textNode.setStyle(linkTextNode.getStyle());
|
|
116
120
|
linkNode.append(textNode);
|
|
117
121
|
linkTextNode.replace(linkNode);
|
|
118
122
|
return remainingTextNode;
|
|
@@ -149,6 +153,7 @@ function createAutoLinkNode(nodes, startIndex, endIndex, match) {
|
|
|
149
153
|
const textNode = lexical.$createTextNode(firstLinkTextNode.getTextContent());
|
|
150
154
|
textNode.setFormat(firstLinkTextNode.getFormat());
|
|
151
155
|
textNode.setDetail(firstLinkTextNode.getDetail());
|
|
156
|
+
textNode.setStyle(firstLinkTextNode.getStyle());
|
|
152
157
|
linkNode.append(textNode, ...linkNodes);
|
|
153
158
|
// it does not preserve caret position if caret was at the first text node
|
|
154
159
|
// so we need to restore caret position
|
|
@@ -164,7 +169,7 @@ function createAutoLinkNode(nodes, startIndex, endIndex, match) {
|
|
|
164
169
|
}
|
|
165
170
|
return undefined;
|
|
166
171
|
}
|
|
167
|
-
function handleLinkCreation(nodes, matchers, onChange) {
|
|
172
|
+
function $handleLinkCreation(nodes, matchers, onChange) {
|
|
168
173
|
let currentNodes = [...nodes];
|
|
169
174
|
const initialText = currentNodes.map(node => node.getTextContent()).join('');
|
|
170
175
|
let text = initialText;
|
|
@@ -179,7 +184,7 @@ function handleLinkCreation(nodes, matchers, onChange) {
|
|
|
179
184
|
const [matchingOffset,, matchingNodes, unmodifiedAfterNodes] = extractMatchingNodes(currentNodes, invalidMatchEnd + matchStart, invalidMatchEnd + matchEnd);
|
|
180
185
|
const actualMatchStart = invalidMatchEnd + matchStart - matchingOffset;
|
|
181
186
|
const actualMatchEnd = invalidMatchEnd + matchEnd - matchingOffset;
|
|
182
|
-
const remainingTextNode =
|
|
187
|
+
const remainingTextNode = $createAutoLinkNode_(matchingNodes, actualMatchStart, actualMatchEnd, match);
|
|
183
188
|
currentNodes = remainingTextNode ? [remainingTextNode, ...unmodifiedAfterNodes] : unmodifiedAfterNodes;
|
|
184
189
|
onChange(match.url, null);
|
|
185
190
|
invalidMatchEnd = 0;
|
|
@@ -295,7 +300,7 @@ function useAutoLink(editor, matchers, onChange) {
|
|
|
295
300
|
} else if (!link.$isLinkNode(parent)) {
|
|
296
301
|
if (textNode.isSimpleText() && (startsWithSeparator(textNode.getTextContent()) || !link.$isAutoLinkNode(previous))) {
|
|
297
302
|
const textNodesToMatch = getTextNodesToMatch(textNode);
|
|
298
|
-
handleLinkCreation(textNodesToMatch, matchers, onChangeWrapped);
|
|
303
|
+
$handleLinkCreation(textNodesToMatch, matchers, onChangeWrapped);
|
|
299
304
|
}
|
|
300
305
|
handleBadNeighbors(textNode, matchers, onChangeWrapped);
|
|
301
306
|
}
|
|
@@ -3,11 +3,13 @@
|
|
|
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 { AutoLinkNode, $isAutoLinkNode, $isLinkNode, $createAutoLinkNode } from '@lexical/link';
|
|
8
10
|
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
9
11
|
import { mergeRegister } from '@lexical/utils';
|
|
10
|
-
import { TextNode, $isTextNode, $
|
|
12
|
+
import { TextNode, $isTextNode, $isElementNode, $isLineBreakNode, $createTextNode, $getSelection, $isRangeSelection, $isNodeSelection } from 'lexical';
|
|
11
13
|
import { useEffect } from 'react';
|
|
12
14
|
|
|
13
15
|
/**
|
|
@@ -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 createLinkMatcherWithRegExp(regExp, urlTransformer = text => text) {
|
|
21
24
|
return text => {
|
|
22
25
|
const match = regExp.exec(text);
|
|
@@ -98,7 +101,7 @@ function extractMatchingNodes(nodes, startIndex, endIndex) {
|
|
|
98
101
|
}
|
|
99
102
|
return [matchingOffset, unmodifiedBeforeNodes, matchingNodes, unmodifiedAfterNodes];
|
|
100
103
|
}
|
|
101
|
-
function
|
|
104
|
+
function $createAutoLinkNode_(nodes, startIndex, endIndex, match) {
|
|
102
105
|
const linkNode = $createAutoLinkNode(match.url, match.attributes);
|
|
103
106
|
if (nodes.length === 1) {
|
|
104
107
|
let remainingTextNode = nodes[0];
|
|
@@ -111,6 +114,7 @@ function createAutoLinkNode(nodes, startIndex, endIndex, match) {
|
|
|
111
114
|
const textNode = $createTextNode(match.text);
|
|
112
115
|
textNode.setFormat(linkTextNode.getFormat());
|
|
113
116
|
textNode.setDetail(linkTextNode.getDetail());
|
|
117
|
+
textNode.setStyle(linkTextNode.getStyle());
|
|
114
118
|
linkNode.append(textNode);
|
|
115
119
|
linkTextNode.replace(linkNode);
|
|
116
120
|
return remainingTextNode;
|
|
@@ -147,6 +151,7 @@ function createAutoLinkNode(nodes, startIndex, endIndex, match) {
|
|
|
147
151
|
const textNode = $createTextNode(firstLinkTextNode.getTextContent());
|
|
148
152
|
textNode.setFormat(firstLinkTextNode.getFormat());
|
|
149
153
|
textNode.setDetail(firstLinkTextNode.getDetail());
|
|
154
|
+
textNode.setStyle(firstLinkTextNode.getStyle());
|
|
150
155
|
linkNode.append(textNode, ...linkNodes);
|
|
151
156
|
// it does not preserve caret position if caret was at the first text node
|
|
152
157
|
// so we need to restore caret position
|
|
@@ -162,7 +167,7 @@ function createAutoLinkNode(nodes, startIndex, endIndex, match) {
|
|
|
162
167
|
}
|
|
163
168
|
return undefined;
|
|
164
169
|
}
|
|
165
|
-
function handleLinkCreation(nodes, matchers, onChange) {
|
|
170
|
+
function $handleLinkCreation(nodes, matchers, onChange) {
|
|
166
171
|
let currentNodes = [...nodes];
|
|
167
172
|
const initialText = currentNodes.map(node => node.getTextContent()).join('');
|
|
168
173
|
let text = initialText;
|
|
@@ -177,7 +182,7 @@ function handleLinkCreation(nodes, matchers, onChange) {
|
|
|
177
182
|
const [matchingOffset,, matchingNodes, unmodifiedAfterNodes] = extractMatchingNodes(currentNodes, invalidMatchEnd + matchStart, invalidMatchEnd + matchEnd);
|
|
178
183
|
const actualMatchStart = invalidMatchEnd + matchStart - matchingOffset;
|
|
179
184
|
const actualMatchEnd = invalidMatchEnd + matchEnd - matchingOffset;
|
|
180
|
-
const remainingTextNode =
|
|
185
|
+
const remainingTextNode = $createAutoLinkNode_(matchingNodes, actualMatchStart, actualMatchEnd, match);
|
|
181
186
|
currentNodes = remainingTextNode ? [remainingTextNode, ...unmodifiedAfterNodes] : unmodifiedAfterNodes;
|
|
182
187
|
onChange(match.url, null);
|
|
183
188
|
invalidMatchEnd = 0;
|
|
@@ -293,7 +298,7 @@ function useAutoLink(editor, matchers, onChange) {
|
|
|
293
298
|
} else if (!$isLinkNode(parent)) {
|
|
294
299
|
if (textNode.isSimpleText() && (startsWithSeparator(textNode.getTextContent()) || !$isAutoLinkNode(previous))) {
|
|
295
300
|
const textNodesToMatch = getTextNodesToMatch(textNode);
|
|
296
|
-
handleLinkCreation(textNodesToMatch, matchers, onChangeWrapped);
|
|
301
|
+
$handleLinkCreation(textNodesToMatch, matchers, onChangeWrapped);
|
|
297
302
|
}
|
|
298
303
|
handleBadNeighbors(textNode, matchers, onChangeWrapped);
|
|
299
304
|
}
|
package/LexicalAutoLinkPlugin.js
CHANGED
|
@@ -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 LexicalAutoLinkPlugin = process.env.NODE_ENV === 'development' ? require('./LexicalAutoLinkPlugin.dev.js') : require('./LexicalAutoLinkPlugin.prod.js');
|
|
9
11
|
module.exports = LexicalAutoLinkPlugin;
|
|
@@ -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 './LexicalAutoLinkPlugin.dev.mjs';
|
|
8
10
|
import * as modProd from './LexicalAutoLinkPlugin.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('./LexicalAutoLinkPlugin.dev.mjs') : import('./LexicalAutoLinkPlugin.prod.mjs'));
|
|
8
10
|
export const AutoLinkPlugin = mod.AutoLinkPlugin;
|
|
9
11
|
export const createLinkMatcherWithRegExp = mod.createLinkMatcherWithRegExp;
|
|
@@ -3,15 +3,17 @@
|
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
6
7
|
*/
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
function
|
|
10
|
-
function
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
function E(a,c,b){var d=a
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
c,
|
|
8
|
+
|
|
9
|
+
'use strict';var k=require("@lexical/link"),n=require("@lexical/react/LexicalComposerContext"),p=require("@lexical/utils"),r=require("lexical"),u=require("react"),v;function w(a){let c=new URLSearchParams;c.append("code",a);for(let b=1;b<arguments.length;b++)c.append("v",arguments[b]);throw Error(`Minified Lexical error #${a}; visit https://lexical.dev/docs/error?${c} for the full message or `+"use the non-minified dev environment for full errors and additional helpful warnings.");}
|
|
10
|
+
v=w&&w.__esModule&&Object.prototype.hasOwnProperty.call(w,"default")?w["default"]:w;function x(a,c){for(let b=0;b<c.length;b++){let d=c[b](a);if(d)return d}return null}let y=/[.,;\s]/;function z(a){a=a.getPreviousSibling();r.$isElementNode(a)&&(a=a.getLastDescendant());var c;!(c=null===a||r.$isLineBreakNode(a))&&(c=r.$isTextNode(a))&&(a=a.getTextContent(),c=y.test(a[a.length-1]));return c}
|
|
11
|
+
function A(a){a=a.getNextSibling();r.$isElementNode(a)&&(a=a.getFirstDescendant());return null===a||r.$isLineBreakNode(a)||r.$isTextNode(a)&&y.test(a.getTextContent()[0])}function B(a,c,b,d){return(0<a?y.test(b[a-1]):z(d[0]))?c<b.length?y.test(b[c]):A(d[d.length-1]):!1}function C(a,c,b){let d=[],h=[],e=[],f=0,g=0;for(a=[...a];0<a.length;){let l=a[0],m=l.getTextContent().length,q=g;g+m<=c?(d.push(l),f+=m):q>=b?e.push(l):h.push(l);g+=m;a.shift()}return[f,d,h,e]}
|
|
12
|
+
function D(a,c,b,d){let h=k.$createAutoLinkNode(d.url,d.attributes);if(1===a.length){var e=a[0];0===c?[g,e]=e.splitText(b):[,g,e]=e.splitText(c,b);var f=r.$createTextNode(d.text);f.setFormat(g.getFormat());f.setDetail(g.getDetail());f.setStyle(g.getStyle());h.append(f);g.replace(h);return e}if(1<a.length){d=a[0];var g=d.getTextContent().length;0===c?e=d:[,e]=d.splitText(c);c=[];for(d=1;d<a.length;d++){let l=a[d],m=l.getTextContent().length,q=g,t=g+m;if(q<b)if(t<=b)c.push(l);else{let [G,H]=l.splitText(b-
|
|
13
|
+
q);c.push(G);f=H}g+=m}a=(b=r.$getSelection())?b.getNodes().find(r.$isTextNode):void 0;g=r.$createTextNode(e.getTextContent());g.setFormat(e.getFormat());g.setDetail(e.getDetail());g.setStyle(e.getStyle());h.append(g,...c);a&&a===e&&(r.$isRangeSelection(b)?g.select(b.anchor.offset,b.focus.offset):r.$isNodeSelection(b)&&g.select(0,g.getTextContent().length));e.replace(h);return f}}
|
|
14
|
+
function E(a,c,b){var d=[...a];let h=a=d.map(g=>g.getTextContent()).join(""),e,f=0;for(;(e=x(h,c))&&null!==e;){let g=e.index,l=g+e.length;if(B(f+g,f+l,a,d)){let [m,,q,t]=C(d,f+g,f+l);d=(d=D(q,f+g-m,f+l-m,e))?[d,...t]:t;b(e.url,null);f=0}else f+=l;h=h.substring(l)}}
|
|
15
|
+
function F(a,c,b){var d=a.getChildren();let h=d.length;for(let e=0;e<h;e++){let f=d[e];if(!r.$isTextNode(f)||!f.isSimpleText()){I(a);b(null,a.getURL());return}}d=a.getTextContent();c=x(d,c);null===c||c.text!==d?(I(a),b(null,a.getURL())):z(a)&&A(a)?(d=a.getURL(),d!==c.url&&(a.setURL(c.url),b(c.url,d)),c.attributes&&(d=a.getRel(),d!==c.attributes.rel&&(a.setRel(c.attributes.rel||null),b(c.attributes.rel||null,d)),d=a.getTarget(),d!==c.attributes.target&&(a.setTarget(c.attributes.target||null),b(c.attributes.target||
|
|
16
|
+
null,d)))):(I(a),b(null,a.getURL()))}function I(a){let c=a.getChildren();var b=c.length;for(--b;0<=b;b--)a.insertAfter(c[b]);a.remove();return c.map(d=>d.getLatest())}
|
|
17
|
+
function J(a,c,b){u.useEffect(()=>{a.hasNodes([k.AutoLinkNode])||v(77);let d=(h,e)=>{b&&b(h,e)};return p.mergeRegister(a.registerNodeTransform(r.TextNode,h=>{var e=h.getParentOrThrow(),f=h.getPreviousSibling();if(k.$isAutoLinkNode(e))F(e,c,d);else if(!k.$isLinkNode(e)){if(h.isSimpleText()&&(y.test(h.getTextContent()[0])||!k.$isAutoLinkNode(f))){e=[h];for(f=h.getNextSibling();null!==f&&r.$isTextNode(f)&&f.isSimpleText();){e.push(f);if(/[\s]/.test(f.getTextContent()))break;f=f.getNextSibling()}E(e,
|
|
18
|
+
c,d)}let g=h.getPreviousSibling();e=h.getNextSibling();f=h.getTextContent();k.$isAutoLinkNode(g)&&!y.test(f[0])&&(g.append(h),F(g,c,d),h=g.getURL(),b&&b(null,h));k.$isAutoLinkNode(e)&&!y.test(f[f.length-1])&&(I(e),F(e,c,d),h=e.getURL(),b&&b(null,h))}}))},[a,c,b])}exports.AutoLinkPlugin=function({matchers:a,onChange:c}){let [b]=n.useLexicalComposerContext();J(b,a,c);return null};
|
|
17
19
|
exports.createLinkMatcherWithRegExp=function(a,c=b=>b){return b=>{b=a.exec(b);return null===b?null:{index:b.index,length:b[0].length,text:b[0],url:c(b[0])}}}
|
|
@@ -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{AutoLinkNode as t,$isAutoLinkNode as e,$isLinkNode as n,$createAutoLinkNode as l}from"@lexical/link";import{useLexicalComposerContext as r}from"@lexical/react/LexicalComposerContext";import{mergeRegister as o}from"@lexical/utils";import{TextNode as i,$isTextNode as s,$isElementNode as u,$isLineBreakNode as g,$createTextNode as c,$getSelection as f,$isRangeSelection as a,$isNodeSelection as h}from"lexical";import{useEffect as p}from"react";function x(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var d=x((function(t){const e=new URLSearchParams;e.append("code",t);for(let t=1;t<arguments.length;t++)e.append("v",arguments[t]);throw Error(`Minified Lexical error #${t}; visit https://lexical.dev/docs/error?${e} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}));function m(t,e=(t=>t)){return n=>{const l=t.exec(n);return null===l?null:{index:l.index,length:l[0].length,text:l[0],url:e(l[0])}}}function T(t,e){for(let n=0;n<e.length;n++){const l=e[n](t);if(l)return l}return null}const b=/[.,;\s]/;function C(t){return b.test(t)}function S(t){return C(t[t.length-1])}function v(t){return C(t[0])}function L(t){let e=t.getPreviousSibling();return u(e)&&(e=e.getLastDescendant()),null===e||g(e)||s(e)&&S(e.getTextContent())}function R(t){let e=t.getNextSibling();return u(e)&&(e=e.getFirstDescendant()),null===e||g(e)||s(e)&&v(e.getTextContent())}function U(t,e,n,l){if(!(t>0?C(n[t-1]):L(l[0])))return!1;return e<n.length?C(n[e]):R(l[l.length-1])}function N(t,e,n){const l=[],r=[],o=[];let i=0,s=0;const u=[...t];for(;u.length>0;){const t=u[0],g=t.getTextContent().length,c=s;s+g<=e?(l.push(t),i+=g):c>=n?o.push(t):r.push(t),s+=g,u.shift()}return[i,l,r,o]}function y(t,e,n,r){const o=l(r.url,r.attributes);if(1===t.length){let l,i=t[0];0===e?[l,i]=i.splitText(n):[,l,i]=i.splitText(e,n);const s=c(r.text);return s.setFormat(l.getFormat()),s.setDetail(l.getDetail()),s.setStyle(l.getStyle()),o.append(s),l.replace(o),i}if(t.length>1){const l=t[0];let r,i=l.getTextContent().length;0===e?r=l:[,r]=l.splitText(e);const u=[];let g;for(let e=1;e<t.length;e++){const l=t[e],r=l.getTextContent().length,o=i;if(o<n)if(i+r<=n)u.push(l);else{const[t,e]=l.splitText(n-o);u.push(t),g=e}i+=r}const p=f(),x=p?p.getNodes().find(s):void 0,d=c(r.getTextContent());return d.setFormat(r.getFormat()),d.setDetail(r.getDetail()),d.setStyle(r.getStyle()),o.append(d,...u),x&&x===r&&(a(p)?d.select(p.anchor.offset,p.focus.offset):h(p)&&d.select(0,d.getTextContent().length)),r.replace(o),g}}function D(t,e,n){const l=t.getChildren(),r=l.length;for(let e=0;e<r;e++){const r=l[e];if(!s(r)||!r.isSimpleText())return P(t),void n(null,t.getURL())}const o=t.getTextContent(),i=T(o,e);if(null===i||i.text!==o)return P(t),void n(null,t.getURL());if(!L(t)||!R(t))return P(t),void n(null,t.getURL());const u=t.getURL();if(u!==i.url&&(t.setURL(i.url),n(i.url,u)),i.attributes){const e=t.getRel();e!==i.attributes.rel&&(t.setRel(i.attributes.rel||null),n(i.attributes.rel||null,e));const l=t.getTarget();l!==i.attributes.target&&(t.setTarget(i.attributes.target||null),n(i.attributes.target||null,l))}}function P(t){const e=t.getChildren();for(let n=e.length-1;n>=0;n--)t.insertAfter(e[n]);return t.remove(),e.map((t=>t.getLatest()))}function w(l,r,u){p((()=>{l.hasNodes([t])||d(77);const g=(t,e)=>{u&&u(t,e)};return o(l.registerNodeTransform(i,(t=>{const l=t.getParentOrThrow(),o=t.getPreviousSibling();if(e(l))D(l,r,g);else if(!n(l)){if(t.isSimpleText()&&(v(t.getTextContent())||!e(o))){const e=function(t){const e=[t];let n=t.getNextSibling();for(;null!==n&&s(n)&&n.isSimpleText()&&(e.push(n),!/[\s]/.test(n.getTextContent()));)n=n.getNextSibling();return e}(t);!function(t,e,n){let l=[...t];const r=l.map((t=>t.getTextContent())).join("");let o,i=r,s=0;for(;(o=T(i,e))&&null!==o;){const t=o.index,e=t+o.length;if(U(s+t,s+e,r,l)){const[r,,i,u]=N(l,s+t,s+e),g=y(i,s+t-r,s+e-r,o);l=g?[g,...u]:u,n(o.url,null),s=0}else s+=e;i=i.substring(e)}}(e,r,g)}!function(t,n,l){const r=t.getPreviousSibling(),o=t.getNextSibling(),i=t.getTextContent();e(r)&&!v(i)&&(r.append(t),D(r,n,l),l(null,r.getURL())),e(o)&&!S(i)&&(P(o),D(o,n,l),l(null,o.getURL()))}(t,r,g)}})))}),[l,r,u])}function F({matchers:t,onChange:e}){const[n]=r();return w(n,t,e),null}export{F as AutoLinkPlugin,m as createLinkMatcherWithRegExp};
|
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
6
7
|
*/
|
|
8
|
+
|
|
7
9
|
'use strict';
|
|
8
10
|
|
|
9
11
|
var LexicalComposerContext = require('@lexical/react/LexicalComposerContext');
|
|
@@ -13,6 +15,19 @@ var utils = require('@lexical/utils');
|
|
|
13
15
|
var lexical = require('lexical');
|
|
14
16
|
var React = require('react');
|
|
15
17
|
|
|
18
|
+
function _interopNamespaceDefault(e) {
|
|
19
|
+
var n = Object.create(null);
|
|
20
|
+
if (e) {
|
|
21
|
+
for (var k in e) {
|
|
22
|
+
n[k] = e[k];
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
n.default = e;
|
|
26
|
+
return n;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
|
|
30
|
+
|
|
16
31
|
/**
|
|
17
32
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
18
33
|
*
|
|
@@ -20,6 +35,7 @@ var React = require('react');
|
|
|
20
35
|
* LICENSE file in the root directory of this source tree.
|
|
21
36
|
*
|
|
22
37
|
*/
|
|
38
|
+
|
|
23
39
|
function BlockWithAlignableContents({
|
|
24
40
|
children,
|
|
25
41
|
format,
|
|
@@ -29,7 +45,7 @@ function BlockWithAlignableContents({
|
|
|
29
45
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
30
46
|
const [isSelected, setSelected, clearSelection] = useLexicalNodeSelection.useLexicalNodeSelection(nodeKey);
|
|
31
47
|
const ref = React.useRef(null);
|
|
32
|
-
const onDelete = React.useCallback(event => {
|
|
48
|
+
const $onDelete = React.useCallback(event => {
|
|
33
49
|
if (isSelected && lexical.$isNodeSelection(lexical.$getSelection())) {
|
|
34
50
|
event.preventDefault();
|
|
35
51
|
const node = lexical.$getNodeByKey(nodeKey);
|
|
@@ -73,9 +89,9 @@ function BlockWithAlignableContents({
|
|
|
73
89
|
return true;
|
|
74
90
|
}
|
|
75
91
|
return false;
|
|
76
|
-
}, lexical.COMMAND_PRIORITY_LOW), editor.registerCommand(lexical.KEY_DELETE_COMMAND, onDelete, lexical.COMMAND_PRIORITY_LOW), editor.registerCommand(lexical.KEY_BACKSPACE_COMMAND, onDelete, lexical.COMMAND_PRIORITY_LOW));
|
|
77
|
-
}, [clearSelection, editor, isSelected, nodeKey, onDelete, setSelected]);
|
|
78
|
-
return /*#__PURE__*/
|
|
92
|
+
}, lexical.COMMAND_PRIORITY_LOW), editor.registerCommand(lexical.KEY_DELETE_COMMAND, $onDelete, lexical.COMMAND_PRIORITY_LOW), editor.registerCommand(lexical.KEY_BACKSPACE_COMMAND, $onDelete, lexical.COMMAND_PRIORITY_LOW));
|
|
93
|
+
}, [clearSelection, editor, isSelected, nodeKey, $onDelete, setSelected]);
|
|
94
|
+
return /*#__PURE__*/React__namespace.createElement("div", {
|
|
79
95
|
className: [className.base, isSelected ? className.focus : null].filter(Boolean).join(' '),
|
|
80
96
|
ref: ref,
|
|
81
97
|
style: {
|
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
6
7
|
*/
|
|
8
|
+
|
|
7
9
|
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
8
10
|
import { $isDecoratorBlockNode } from '@lexical/react/LexicalDecoratorBlockNode';
|
|
9
11
|
import { useLexicalNodeSelection } from '@lexical/react/useLexicalNodeSelection';
|
|
@@ -19,6 +21,7 @@ import { useRef, useCallback, useEffect } from 'react';
|
|
|
19
21
|
* LICENSE file in the root directory of this source tree.
|
|
20
22
|
*
|
|
21
23
|
*/
|
|
24
|
+
|
|
22
25
|
function BlockWithAlignableContents({
|
|
23
26
|
children,
|
|
24
27
|
format,
|
|
@@ -28,7 +31,7 @@ function BlockWithAlignableContents({
|
|
|
28
31
|
const [editor] = useLexicalComposerContext();
|
|
29
32
|
const [isSelected, setSelected, clearSelection] = useLexicalNodeSelection(nodeKey);
|
|
30
33
|
const ref = useRef(null);
|
|
31
|
-
const onDelete = useCallback(event => {
|
|
34
|
+
const $onDelete = useCallback(event => {
|
|
32
35
|
if (isSelected && $isNodeSelection($getSelection())) {
|
|
33
36
|
event.preventDefault();
|
|
34
37
|
const node = $getNodeByKey(nodeKey);
|
|
@@ -72,8 +75,8 @@ function BlockWithAlignableContents({
|
|
|
72
75
|
return true;
|
|
73
76
|
}
|
|
74
77
|
return false;
|
|
75
|
-
}, COMMAND_PRIORITY_LOW), editor.registerCommand(KEY_DELETE_COMMAND, onDelete, COMMAND_PRIORITY_LOW), editor.registerCommand(KEY_BACKSPACE_COMMAND, onDelete, COMMAND_PRIORITY_LOW));
|
|
76
|
-
}, [clearSelection, editor, isSelected, nodeKey, onDelete, setSelected]);
|
|
78
|
+
}, COMMAND_PRIORITY_LOW), editor.registerCommand(KEY_DELETE_COMMAND, $onDelete, COMMAND_PRIORITY_LOW), editor.registerCommand(KEY_BACKSPACE_COMMAND, $onDelete, COMMAND_PRIORITY_LOW));
|
|
79
|
+
}, [clearSelection, editor, isSelected, nodeKey, $onDelete, setSelected]);
|
|
77
80
|
return /*#__PURE__*/React.createElement("div", {
|
|
78
81
|
className: [className.base, isSelected ? className.focus : null].filter(Boolean).join(' '),
|
|
79
82
|
ref: ref,
|
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
6
7
|
*/
|
|
8
|
+
|
|
7
9
|
'use strict'
|
|
8
10
|
const LexicalBlockWithAlignableContents = process.env.NODE_ENV === 'development' ? require('./LexicalBlockWithAlignableContents.dev.js') : require('./LexicalBlockWithAlignableContents.prod.js');
|
|
9
11
|
module.exports = LexicalBlockWithAlignableContents;
|
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
6
7
|
*/
|
|
8
|
+
|
|
7
9
|
import * as modDev from './LexicalBlockWithAlignableContents.dev.mjs';
|
|
8
10
|
import * as modProd from './LexicalBlockWithAlignableContents.prod.mjs';
|
|
9
11
|
const mod = process.env.NODE_ENV === 'development' ? modDev : modProd;
|
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
6
7
|
*/
|
|
8
|
+
|
|
7
9
|
const mod = await (process.env.NODE_ENV === 'development' ? import('./LexicalBlockWithAlignableContents.dev.mjs') : import('./LexicalBlockWithAlignableContents.prod.mjs'));
|
|
8
10
|
export const BlockWithAlignableContents = mod.BlockWithAlignableContents;
|