@liveblocks/react-lexical 2.18.3 → 2.18.4-uns2
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/dist/{classnames.mjs → classnames.cjs} +4 -2
- package/dist/{classnames.mjs.map → classnames.cjs.map} +1 -1
- package/dist/classnames.js +1 -3
- package/dist/classnames.js.map +1 -1
- package/dist/comments/{anchored-threads.mjs → anchored-threads.cjs} +44 -41
- package/dist/comments/{anchored-threads.mjs.map → anchored-threads.cjs.map} +1 -1
- package/dist/comments/anchored-threads.js +40 -43
- package/dist/comments/anchored-threads.js.map +1 -1
- package/dist/comments/{comment-plugin-provider.mjs → comment-plugin-provider.cjs} +62 -55
- package/dist/comments/{comment-plugin-provider.mjs.map → comment-plugin-provider.cjs.map} +1 -1
- package/dist/comments/comment-plugin-provider.js +54 -61
- package/dist/comments/comment-plugin-provider.js.map +1 -1
- package/dist/comments/{floating-composer.mjs → floating-composer.cjs} +68 -64
- package/dist/comments/{floating-composer.mjs.map → floating-composer.cjs.map} +1 -1
- package/dist/comments/floating-composer.js +63 -67
- package/dist/comments/floating-composer.js.map +1 -1
- package/dist/comments/{floating-threads.mjs → floating-threads.cjs} +51 -48
- package/dist/comments/{floating-threads.mjs.map → floating-threads.cjs.map} +1 -1
- package/dist/comments/floating-threads.js +47 -50
- package/dist/comments/floating-threads.js.map +1 -1
- package/dist/comments/get-thread-mark-ids.cjs +23 -0
- package/dist/comments/{get-thread-mark-ids.mjs.map → get-thread-mark-ids.cjs.map} +1 -1
- package/dist/comments/get-thread-mark-ids.js +6 -8
- package/dist/comments/get-thread-mark-ids.js.map +1 -1
- package/dist/comments/{thread-mark-node.mjs → thread-mark-node.cjs} +10 -6
- package/dist/comments/{thread-mark-node.mjs.map → thread-mark-node.cjs.map} +1 -1
- package/dist/comments/thread-mark-node.js +5 -9
- package/dist/comments/thread-mark-node.js.map +1 -1
- package/dist/comments/{unwrap-thread-mark-node.mjs → unwrap-thread-mark-node.cjs} +4 -2
- package/dist/comments/unwrap-thread-mark-node.cjs.map +1 -0
- package/dist/comments/unwrap-thread-mark-node.js +1 -3
- package/dist/comments/unwrap-thread-mark-node.js.map +1 -1
- package/dist/comments/{wrap-selection-in-thread-mark-node.mjs → wrap-selection-in-thread-mark-node.cjs} +12 -10
- package/dist/comments/{wrap-selection-in-thread-mark-node.mjs.map → wrap-selection-in-thread-mark-node.cjs.map} +1 -1
- package/dist/comments/wrap-selection-in-thread-mark-node.js +9 -11
- package/dist/comments/wrap-selection-in-thread-mark-node.js.map +1 -1
- package/dist/{create-dom-range.mjs → create-dom-range.cjs} +7 -5
- package/dist/{create-dom-range.mjs.map → create-dom-range.cjs.map} +1 -1
- package/dist/create-dom-range.js +4 -6
- package/dist/create-dom-range.js.map +1 -1
- package/dist/{create-rects-from-dom-range.mjs → create-rects-from-dom-range.cjs} +4 -2
- package/dist/{create-rects-from-dom-range.mjs.map → create-rects-from-dom-range.cjs.map} +1 -1
- package/dist/create-rects-from-dom-range.js +1 -3
- package/dist/create-rects-from-dom-range.js.map +1 -1
- package/dist/index.cjs +33 -0
- package/dist/{index.mjs.map → index.cjs.map} +1 -1
- package/dist/index.js +14 -31
- package/dist/index.js.map +1 -1
- package/dist/{is-block-node-active.mjs → is-block-node-active.cjs} +12 -10
- package/dist/{is-block-node-active.mjs.map → is-block-node-active.cjs.map} +1 -1
- package/dist/is-block-node-active.js +9 -11
- package/dist/is-block-node-active.js.map +1 -1
- package/dist/is-command-registered.cjs +11 -0
- package/dist/{is-command-registered.mjs.map → is-command-registered.cjs.map} +1 -1
- package/dist/is-command-registered.js +3 -5
- package/dist/is-command-registered.js.map +1 -1
- package/dist/is-text-format-active.cjs +16 -0
- package/dist/{is-text-format-active.mjs.map → is-text-format-active.cjs.map} +1 -1
- package/dist/is-text-format-active.js +4 -6
- package/dist/is-text-format-active.js.map +1 -1
- package/dist/liveblocks-config.cjs +17 -0
- package/dist/{liveblocks-config.mjs.map → liveblocks-config.cjs.map} +1 -1
- package/dist/liveblocks-config.js +4 -6
- package/dist/liveblocks-config.js.map +1 -1
- package/dist/liveblocks-plugin-provider.cjs +151 -0
- package/dist/liveblocks-plugin-provider.cjs.map +1 -0
- package/dist/liveblocks-plugin-provider.js +43 -47
- package/dist/liveblocks-plugin-provider.js.map +1 -1
- package/dist/mentions/{avatar.mjs → avatar.cjs} +16 -14
- package/dist/mentions/avatar.cjs.map +1 -0
- package/dist/mentions/avatar.js +13 -15
- package/dist/mentions/avatar.js.map +1 -1
- package/dist/mentions/mention-component.cjs +51 -0
- package/dist/mentions/{mention-component.mjs.map → mention-component.cjs.map} +1 -1
- package/dist/mentions/mention-component.js +14 -16
- package/dist/mentions/mention-component.js.map +1 -1
- package/dist/mentions/{mention-node.mjs → mention-node.cjs} +16 -12
- package/dist/mentions/{mention-node.mjs.map → mention-node.cjs.map} +1 -1
- package/dist/mentions/mention-node.js +11 -15
- package/dist/mentions/mention-node.js.map +1 -1
- package/dist/mentions/{mention-plugin.mjs → mention-plugin.cjs} +81 -78
- package/dist/mentions/{mention-plugin.mjs.map → mention-plugin.cjs.map} +1 -1
- package/dist/mentions/mention-plugin.js +77 -80
- package/dist/mentions/mention-plugin.js.map +1 -1
- package/dist/mentions/{suggestions.mjs → suggestions.cjs} +43 -37
- package/dist/mentions/{suggestions.mjs.map → suggestions.cjs.map} +1 -1
- package/dist/mentions/suggestions.js +36 -42
- package/dist/mentions/suggestions.js.map +1 -1
- package/dist/mentions/user.cjs +26 -0
- package/dist/mentions/{user.mjs.map → user.cjs.map} +1 -1
- package/dist/mentions/user.js +11 -13
- package/dist/mentions/user.js.map +1 -1
- package/dist/toolbar/{floating-toolbar.mjs → floating-toolbar.cjs} +73 -70
- package/dist/toolbar/{floating-toolbar.mjs.map → floating-toolbar.cjs.map} +1 -1
- package/dist/toolbar/floating-toolbar.js +69 -72
- package/dist/toolbar/floating-toolbar.js.map +1 -1
- package/dist/toolbar/shared.cjs +36 -0
- package/dist/toolbar/{shared.mjs.map → shared.cjs.map} +1 -1
- package/dist/toolbar/shared.js +12 -15
- package/dist/toolbar/shared.js.map +1 -1
- package/dist/toolbar/toolbar.cjs +433 -0
- package/dist/toolbar/{toolbar.mjs.map → toolbar.cjs.map} +1 -1
- package/dist/toolbar/toolbar.js +131 -156
- package/dist/toolbar/toolbar.js.map +1 -1
- package/dist/use-root-element.cjs +21 -0
- package/dist/use-root-element.cjs.map +1 -0
- package/dist/use-root-element.js +7 -9
- package/dist/use-root-element.js.map +1 -1
- package/dist/version-history/{history-version-preview.mjs → history-version-preview.cjs} +52 -50
- package/dist/version-history/{history-version-preview.mjs.map → history-version-preview.cjs.map} +1 -1
- package/dist/version-history/history-version-preview.js +49 -51
- package/dist/version-history/history-version-preview.js.map +1 -1
- package/dist/version.cjs +10 -0
- package/dist/{version.mjs.map → version.cjs.map} +1 -1
- package/dist/version.js +3 -7
- package/dist/version.js.map +1 -1
- package/package.json +18 -17
- package/styles.css.d.cts +1 -0
- package/dist/comments/get-thread-mark-ids.mjs +0 -21
- package/dist/comments/unwrap-thread-mark-node.mjs.map +0 -1
- package/dist/index.mjs +0 -16
- package/dist/is-command-registered.mjs +0 -9
- package/dist/is-text-format-active.mjs +0 -14
- package/dist/liveblocks-config.mjs +0 -15
- package/dist/liveblocks-plugin-provider.mjs +0 -147
- package/dist/liveblocks-plugin-provider.mjs.map +0 -1
- package/dist/mentions/avatar.mjs.map +0 -1
- package/dist/mentions/mention-component.mjs +0 -49
- package/dist/mentions/user.mjs +0 -24
- package/dist/toolbar/shared.mjs +0 -33
- package/dist/toolbar/toolbar.mjs +0 -408
- package/dist/use-root-element.mjs +0 -19
- package/dist/use-root-element.mjs.map +0 -1
- package/dist/version.mjs +0 -6
- /package/dist/{index.d.mts → index.d.cts} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mention-component.
|
|
1
|
+
{"version":3,"file":"mention-component.cjs","sources":["../../src/mentions/mention-component.tsx"],"sourcesContent":["import { useLexicalComposerContext } from \"@lexical/react/LexicalComposerContext\";\nimport type { NodeKey } from \"lexical\";\nimport { $createNodeSelection, $getNodeByKey, $setSelection } from \"lexical\";\nimport type { MouseEvent, ReactNode } from \"react\";\nimport { useCallback, useSyncExternalStore } from \"react\";\n\nexport function Mention({\n nodeKey,\n children,\n}: {\n nodeKey: NodeKey;\n children: ReactNode;\n}) {\n const [editor] = useLexicalComposerContext();\n const isSelected = useIsNodeSelected(nodeKey);\n\n function handleClick(event: MouseEvent) {\n editor.update(() => {\n event.stopPropagation();\n event.preventDefault();\n\n const selection = $createNodeSelection();\n selection.add(nodeKey);\n $setSelection(selection);\n });\n }\n\n return (\n <span\n onClick={handleClick}\n data-selected={isSelected ? \"\" : undefined}\n className=\"lb-root lb-lexical-mention\"\n >\n {children}\n </span>\n );\n}\n\nfunction $isNodeSelected(key: NodeKey): boolean {\n const node = $getNodeByKey(key);\n if (node === null) return false;\n return node.isSelected();\n}\n\nfunction useIsNodeSelected(key: NodeKey) {\n const [editor] = useLexicalComposerContext();\n\n const subscribe = useCallback(\n (onStoreChange: () => void) => {\n return editor.registerUpdateListener(onStoreChange);\n },\n [editor]\n );\n\n const getSnapshot = useCallback(() => {\n return editor.getEditorState().read(() => $isNodeSelected(key));\n }, [editor, key]);\n\n return useSyncExternalStore(subscribe, getSnapshot, getSnapshot);\n}\n"],"names":["useLexicalComposerContext","$createNodeSelection","$setSelection","jsx","$getNodeByKey","useCallback","useSyncExternalStore"],"mappings":";;;;;;;AAMO,SAAS,OAAQ,CAAA;AAAA,EACtB,OAAA;AAAA,EACA,QAAA;AACF,CAGG,EAAA;AACD,EAAM,MAAA,CAAC,MAAM,CAAA,GAAIA,gDAA0B,EAAA,CAAA;AAC3C,EAAM,MAAA,UAAA,GAAa,kBAAkB,OAAO,CAAA,CAAA;AAE5C,EAAA,SAAS,YAAY,KAAmB,EAAA;AACtC,IAAA,MAAA,CAAO,OAAO,MAAM;AAClB,MAAA,KAAA,CAAM,eAAgB,EAAA,CAAA;AACtB,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|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var lexical = require('lexical');
|
|
6
|
-
var react = require('react');
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
3
|
+
import { $createNodeSelection, $setSelection, $getNodeByKey } from 'lexical';
|
|
4
|
+
import { useCallback, useSyncExternalStore } from 'react';
|
|
7
5
|
|
|
8
6
|
function Mention({
|
|
9
7
|
nodeKey,
|
|
10
8
|
children
|
|
11
9
|
}) {
|
|
12
|
-
const [editor] =
|
|
10
|
+
const [editor] = useLexicalComposerContext();
|
|
13
11
|
const isSelected = useIsNodeSelected(nodeKey);
|
|
14
12
|
function handleClick(event) {
|
|
15
13
|
editor.update(() => {
|
|
16
14
|
event.stopPropagation();
|
|
17
15
|
event.preventDefault();
|
|
18
|
-
const selection =
|
|
16
|
+
const selection = $createNodeSelection();
|
|
19
17
|
selection.add(nodeKey);
|
|
20
|
-
|
|
18
|
+
$setSelection(selection);
|
|
21
19
|
});
|
|
22
20
|
}
|
|
23
|
-
return /* @__PURE__ */
|
|
21
|
+
return /* @__PURE__ */ jsx("span", {
|
|
24
22
|
onClick: handleClick,
|
|
25
23
|
"data-selected": isSelected ? "" : void 0,
|
|
26
24
|
className: "lb-root lb-lexical-mention",
|
|
@@ -28,24 +26,24 @@ function Mention({
|
|
|
28
26
|
});
|
|
29
27
|
}
|
|
30
28
|
function $isNodeSelected(key) {
|
|
31
|
-
const node =
|
|
29
|
+
const node = $getNodeByKey(key);
|
|
32
30
|
if (node === null)
|
|
33
31
|
return false;
|
|
34
32
|
return node.isSelected();
|
|
35
33
|
}
|
|
36
34
|
function useIsNodeSelected(key) {
|
|
37
|
-
const [editor] =
|
|
38
|
-
const subscribe =
|
|
35
|
+
const [editor] = useLexicalComposerContext();
|
|
36
|
+
const subscribe = useCallback(
|
|
39
37
|
(onStoreChange) => {
|
|
40
38
|
return editor.registerUpdateListener(onStoreChange);
|
|
41
39
|
},
|
|
42
40
|
[editor]
|
|
43
41
|
);
|
|
44
|
-
const getSnapshot =
|
|
42
|
+
const getSnapshot = useCallback(() => {
|
|
45
43
|
return editor.getEditorState().read(() => $isNodeSelected(key));
|
|
46
44
|
}, [editor, key]);
|
|
47
|
-
return
|
|
45
|
+
return useSyncExternalStore(subscribe, getSnapshot, getSnapshot);
|
|
48
46
|
}
|
|
49
47
|
|
|
50
|
-
|
|
48
|
+
export { Mention };
|
|
51
49
|
//# sourceMappingURL=mention-component.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mention-component.js","sources":["../../src/mentions/mention-component.tsx"],"sourcesContent":["import { useLexicalComposerContext } from \"@lexical/react/LexicalComposerContext\";\nimport type { NodeKey } from \"lexical\";\nimport { $createNodeSelection, $getNodeByKey, $setSelection } from \"lexical\";\nimport type { MouseEvent, ReactNode } from \"react\";\nimport { useCallback, useSyncExternalStore } from \"react\";\n\nexport function Mention({\n nodeKey,\n children,\n}: {\n nodeKey: NodeKey;\n children: ReactNode;\n}) {\n const [editor] = useLexicalComposerContext();\n const isSelected = useIsNodeSelected(nodeKey);\n\n function handleClick(event: MouseEvent) {\n editor.update(() => {\n event.stopPropagation();\n event.preventDefault();\n\n const selection = $createNodeSelection();\n selection.add(nodeKey);\n $setSelection(selection);\n });\n }\n\n return (\n <span\n onClick={handleClick}\n data-selected={isSelected ? \"\" : undefined}\n className=\"lb-root lb-lexical-mention\"\n >\n {children}\n </span>\n );\n}\n\nfunction $isNodeSelected(key: NodeKey): boolean {\n const node = $getNodeByKey(key);\n if (node === null) return false;\n return node.isSelected();\n}\n\nfunction useIsNodeSelected(key: NodeKey) {\n const [editor] = useLexicalComposerContext();\n\n const subscribe = useCallback(\n (onStoreChange: () => void) => {\n return editor.registerUpdateListener(onStoreChange);\n },\n [editor]\n );\n\n const getSnapshot = useCallback(() => {\n return editor.getEditorState().read(() => $isNodeSelected(key));\n }, [editor, key]);\n\n return useSyncExternalStore(subscribe, getSnapshot, getSnapshot);\n}\n"],"names":[
|
|
1
|
+
{"version":3,"file":"mention-component.js","sources":["../../src/mentions/mention-component.tsx"],"sourcesContent":["import { useLexicalComposerContext } from \"@lexical/react/LexicalComposerContext\";\nimport type { NodeKey } from \"lexical\";\nimport { $createNodeSelection, $getNodeByKey, $setSelection } from \"lexical\";\nimport type { MouseEvent, ReactNode } from \"react\";\nimport { useCallback, useSyncExternalStore } from \"react\";\n\nexport function Mention({\n nodeKey,\n children,\n}: {\n nodeKey: NodeKey;\n children: ReactNode;\n}) {\n const [editor] = useLexicalComposerContext();\n const isSelected = useIsNodeSelected(nodeKey);\n\n function handleClick(event: MouseEvent) {\n editor.update(() => {\n event.stopPropagation();\n event.preventDefault();\n\n const selection = $createNodeSelection();\n selection.add(nodeKey);\n $setSelection(selection);\n });\n }\n\n return (\n <span\n onClick={handleClick}\n data-selected={isSelected ? \"\" : undefined}\n className=\"lb-root lb-lexical-mention\"\n >\n {children}\n </span>\n );\n}\n\nfunction $isNodeSelected(key: NodeKey): boolean {\n const node = $getNodeByKey(key);\n if (node === null) return false;\n return node.isSelected();\n}\n\nfunction useIsNodeSelected(key: NodeKey) {\n const [editor] = useLexicalComposerContext();\n\n const subscribe = useCallback(\n (onStoreChange: () => void) => {\n return editor.registerUpdateListener(onStoreChange);\n },\n [editor]\n );\n\n const getSnapshot = useCallback(() => {\n return editor.getEditorState().read(() => $isNodeSelected(key));\n }, [editor, key]);\n\n return useSyncExternalStore(subscribe, getSnapshot, getSnapshot);\n}\n"],"names":[],"mappings":";;;;;AAMO,SAAS,OAAQ,CAAA;AAAA,EACtB,OAAA;AAAA,EACA,QAAA;AACF,CAGG,EAAA;AACD,EAAM,MAAA,CAAC,MAAM,CAAA,GAAI,yBAA0B,EAAA,CAAA;AAC3C,EAAM,MAAA,UAAA,GAAa,kBAAkB,OAAO,CAAA,CAAA;AAE5C,EAAA,SAAS,YAAY,KAAmB,EAAA;AACtC,IAAA,MA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AW,CAAA,CAAA;AACjE;;;;"}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
+
var core = require('@liveblocks/core');
|
|
5
|
+
var lexical = require('lexical');
|
|
6
|
+
var mentionComponent = require('./mention-component.cjs');
|
|
7
|
+
var user = require('./user.cjs');
|
|
6
8
|
|
|
7
9
|
const MENTION_CHARACTER = "@";
|
|
8
|
-
class MentionNode extends DecoratorNode {
|
|
10
|
+
class MentionNode extends lexical.DecoratorNode {
|
|
9
11
|
__id;
|
|
10
12
|
__userId;
|
|
11
13
|
constructor(id, userId, key) {
|
|
@@ -67,11 +69,11 @@ class MentionNode extends DecoratorNode {
|
|
|
67
69
|
return self.__id;
|
|
68
70
|
}
|
|
69
71
|
decorate() {
|
|
70
|
-
return /* @__PURE__ */ jsxs(Mention, {
|
|
72
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(mentionComponent.Mention, {
|
|
71
73
|
nodeKey: this.getKey(),
|
|
72
74
|
children: [
|
|
73
75
|
MENTION_CHARACTER,
|
|
74
|
-
/* @__PURE__ */ jsx(User, {
|
|
76
|
+
/* @__PURE__ */ jsxRuntime.jsx(user.User, {
|
|
75
77
|
userId: this.getUserId()
|
|
76
78
|
})
|
|
77
79
|
]
|
|
@@ -82,9 +84,11 @@ function $isMentionNode(node) {
|
|
|
82
84
|
return node instanceof MentionNode;
|
|
83
85
|
}
|
|
84
86
|
function $createMentionNode(userId) {
|
|
85
|
-
const node = new MentionNode(createInboxNotificationId(), userId);
|
|
86
|
-
return
|
|
87
|
+
const node = new MentionNode(core.createInboxNotificationId(), userId);
|
|
88
|
+
return lexical.$applyNodeReplacement(node);
|
|
87
89
|
}
|
|
88
90
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
+
exports.$createMentionNode = $createMentionNode;
|
|
92
|
+
exports.$isMentionNode = $isMentionNode;
|
|
93
|
+
exports.MentionNode = MentionNode;
|
|
94
|
+
//# sourceMappingURL=mention-node.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mention-node.
|
|
1
|
+
{"version":3,"file":"mention-node.cjs","sources":["../../src/mentions/mention-node.tsx"],"sourcesContent":["import { createInboxNotificationId } from \"@liveblocks/core\";\nimport type {\n DOMConversionMap,\n DOMExportOutput,\n LexicalNode,\n NodeKey,\n SerializedLexicalNode,\n Spread,\n} from \"lexical\";\nimport { $applyNodeReplacement, DecoratorNode } from \"lexical\";\nimport type { JSX } from \"react\";\n\nimport { Mention } from \"./mention-component\";\nimport { User } from \"./user\";\n\nconst MENTION_CHARACTER = \"@\";\n\nexport type SerializedMentionNode = Spread<\n {\n userId: string;\n },\n SerializedLexicalNode\n>;\nexport class MentionNode extends DecoratorNode<JSX.Element> {\n __id: string;\n __userId: string;\n\n constructor(id: string, userId: string, key?: NodeKey) {\n super(key);\n this.__id = id;\n this.__userId = userId;\n }\n\n static getType(): string {\n return \"lb-mention\";\n }\n\n static clone(node: MentionNode): MentionNode {\n return new MentionNode(node.__id, node.__userId, node.__key);\n }\n\n createDOM(): HTMLElement {\n const element = document.createElement(\"span\");\n element.style.display = \"inline-block\";\n element.style.userSelect = \"none\";\n return element;\n }\n\n updateDOM(): boolean {\n return false;\n }\n\n static importDom(): DOMConversionMap<HTMLElement> | null {\n return {\n span: () => ({\n conversion: (element) => {\n const value = atob(element.getAttribute(\"data-lexical-lb-mention\")!);\n const node = $createMentionNode(value);\n return { node };\n },\n priority: 1,\n }),\n };\n }\n\n exportDOM(): DOMExportOutput {\n const element = document.createElement(\"span\");\n const value = this.getTextContent();\n element.setAttribute(\"data-lexical-lb-mention\", btoa(value));\n element.textContent = this.getTextContent();\n return { element };\n }\n\n static importJSON(serializedNode: SerializedMentionNode): MentionNode {\n const node = $createMentionNode(serializedNode.userId);\n return node;\n }\n\n exportJSON(): SerializedMentionNode {\n return {\n userId: this.__userId,\n type: \"lb-mention\",\n version: 1,\n };\n }\n\n getUserId(): string {\n const self = this.getLatest();\n return self.__userId;\n }\n\n getId(): string {\n const self = this.getLatest();\n return self.__id;\n }\n\n decorate(): JSX.Element {\n return (\n <Mention nodeKey={this.getKey()}>\n {MENTION_CHARACTER}\n <User userId={this.getUserId()} />\n </Mention>\n );\n }\n}\n\nexport function $isMentionNode(\n node: LexicalNode | null | undefined\n): node is MentionNode {\n return node instanceof MentionNode;\n}\n\nexport function $createMentionNode(userId: string): MentionNode {\n const node = new MentionNode(createInboxNotificationId(), userId);\n return $applyNodeReplacement(node);\n}\n"],"names":["DecoratorNode","jsxs","Mention","jsx","User","createInboxNotificationId","$applyNodeReplacement"],"mappings":";;;;;;;;AAeA,MAAM,iBAAoB,GAAA,GAAA,CAAA;AAQnB,MAAM,oBAAoBA,qBAA2B,CAAA;AAAA,EAC1D,IAAA,CAAA;AAAA,EACA,QAAA,CAAA;AAAA,EAEA,WAAA,CAAY,EAAY,EAAA,MAAA,EAAgB,GAAe,EAAA;AACrD,IAAA,KAAA,CAAM,GAAG,CAAA,CAAA;AACT,IAAA,IAAA,CAAK,IAAO,GAAA,EAAA,CAAA;AACZ,IAAA,IAAA,CAAK,QAAW,GAAA,MAAA,CAAA;AAAA,GAClB;AAAA,EAEA,OAAO,OAAkB,GAAA;AACvB,IAAO,OAAA,YAAA,CAAA;AAAA,GACT;AAAA,EAEA,OAAO,MAAM,IAAgC,EAAA;AAC3C,IAAA,OAAO,IAAI,WAAY,CAAA,IAAA,CAAK,MAAM,IAAK,CAAA,QAAA,EAAU,KAAK,KAAK,CAAA,CAAA;AAAA,GAC7D;AAAA,EAEA,SAAyB,GAAA;AACvB,IAAM,MAAA,OAAA,GAAU,QAAS,CAAA,aAAA,CAAc,MAAM,CAAA,CAAA;AAC7C,IAAA,OAAA,CAAQ,MAAM,OAAU,GAAA,cAAA,CAAA;AACxB,IAAA,OAAA,CAAQ,MAAM,UAAa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IAAM,MAAA,IAAA,GAAO,KAAK,SAAU,EAAA,CAAA;AAC5B,IAAA,OAAO,IAAK,CAAA,QAAA,CAAA;AAAA,GACd;AAAA,EAEA,KAAgB,GAAA;AACd,IAAM,MAAA,IAAA,GAAO,KAAK,SAAU,EAAA,CAAA;AAC5B,IAAA,OAAO,IAAK,CAAA,IAAA,CAAA;AAAA,GACd;AAAA,EAEA,QAAwB,GAAA;AACtB,IAAA,uBACGC,eAAA,CAAAC,wBAAA,EAAA;AAAA,MAAQ,OAAA,EAAS,KAAK,MAAO,EAAA;AAAA,MAC3B,QAAA,EAAA;AAAA,QAAA,iBAAA;AAAA,wBACAC,cAAA,CAAAC,SAAA,EAAA;AAAA,UAAK,MAAA,EAAQ,KAAK,SAAU,EAAA;AAAA,SAAG,CAAA;AAAA,OAAA;AAAA,KAClC,CAAA,CAAA;AAAA,GAEJ;AACF,CAAA;AAEO,SAAS,eACd,IACqB,EAAA;AACrB,EAAA,OAAO,IAAgB,YAAA,WAAA,CAAA;AACzB,CAAA;AAEO,SAAS,mBAAmB,MAA6B,EAAA;AAC9D,EAAA,MAAM,IAAO,GAAA,IAAI,WAAY,CAAAC,8BAAA,IAA6B,MAAM,CAAA,CAAA;AAChE,EAAA,OAAOC,8BAAsB,IAAI,CAAA,CAAA;AACnC;;;;;;"}
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var mentionComponent = require('./mention-component.js');
|
|
7
|
-
var user = require('./user.js');
|
|
1
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { createInboxNotificationId } from '@liveblocks/core';
|
|
3
|
+
import { DecoratorNode, $applyNodeReplacement } from 'lexical';
|
|
4
|
+
import { Mention } from './mention-component.js';
|
|
5
|
+
import { User } from './user.js';
|
|
8
6
|
|
|
9
7
|
const MENTION_CHARACTER = "@";
|
|
10
|
-
class MentionNode extends
|
|
8
|
+
class MentionNode extends DecoratorNode {
|
|
11
9
|
__id;
|
|
12
10
|
__userId;
|
|
13
11
|
constructor(id, userId, key) {
|
|
@@ -69,11 +67,11 @@ class MentionNode extends lexical.DecoratorNode {
|
|
|
69
67
|
return self.__id;
|
|
70
68
|
}
|
|
71
69
|
decorate() {
|
|
72
|
-
return /* @__PURE__ */
|
|
70
|
+
return /* @__PURE__ */ jsxs(Mention, {
|
|
73
71
|
nodeKey: this.getKey(),
|
|
74
72
|
children: [
|
|
75
73
|
MENTION_CHARACTER,
|
|
76
|
-
/* @__PURE__ */
|
|
74
|
+
/* @__PURE__ */ jsx(User, {
|
|
77
75
|
userId: this.getUserId()
|
|
78
76
|
})
|
|
79
77
|
]
|
|
@@ -84,11 +82,9 @@ function $isMentionNode(node) {
|
|
|
84
82
|
return node instanceof MentionNode;
|
|
85
83
|
}
|
|
86
84
|
function $createMentionNode(userId) {
|
|
87
|
-
const node = new MentionNode(
|
|
88
|
-
return
|
|
85
|
+
const node = new MentionNode(createInboxNotificationId(), userId);
|
|
86
|
+
return $applyNodeReplacement(node);
|
|
89
87
|
}
|
|
90
88
|
|
|
91
|
-
|
|
92
|
-
exports.$isMentionNode = $isMentionNode;
|
|
93
|
-
exports.MentionNode = MentionNode;
|
|
89
|
+
export { $createMentionNode, $isMentionNode, MentionNode };
|
|
94
90
|
//# sourceMappingURL=mention-node.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mention-node.js","sources":["../../src/mentions/mention-node.tsx"],"sourcesContent":["import { createInboxNotificationId } from \"@liveblocks/core\";\nimport type {\n DOMConversionMap,\n DOMExportOutput,\n LexicalNode,\n NodeKey,\n SerializedLexicalNode,\n Spread,\n} from \"lexical\";\nimport { $applyNodeReplacement, DecoratorNode } from \"lexical\";\nimport type { JSX } from \"react\";\n\nimport { Mention } from \"./mention-component\";\nimport { User } from \"./user\";\n\nconst MENTION_CHARACTER = \"@\";\n\nexport type SerializedMentionNode = Spread<\n {\n userId: string;\n },\n SerializedLexicalNode\n>;\nexport class MentionNode extends DecoratorNode<JSX.Element> {\n __id: string;\n __userId: string;\n\n constructor(id: string, userId: string, key?: NodeKey) {\n super(key);\n this.__id = id;\n this.__userId = userId;\n }\n\n static getType(): string {\n return \"lb-mention\";\n }\n\n static clone(node: MentionNode): MentionNode {\n return new MentionNode(node.__id, node.__userId, node.__key);\n }\n\n createDOM(): HTMLElement {\n const element = document.createElement(\"span\");\n element.style.display = \"inline-block\";\n element.style.userSelect = \"none\";\n return element;\n }\n\n updateDOM(): boolean {\n return false;\n }\n\n static importDom(): DOMConversionMap<HTMLElement> | null {\n return {\n span: () => ({\n conversion: (element) => {\n const value = atob(element.getAttribute(\"data-lexical-lb-mention\")!);\n const node = $createMentionNode(value);\n return { node };\n },\n priority: 1,\n }),\n };\n }\n\n exportDOM(): DOMExportOutput {\n const element = document.createElement(\"span\");\n const value = this.getTextContent();\n element.setAttribute(\"data-lexical-lb-mention\", btoa(value));\n element.textContent = this.getTextContent();\n return { element };\n }\n\n static importJSON(serializedNode: SerializedMentionNode): MentionNode {\n const node = $createMentionNode(serializedNode.userId);\n return node;\n }\n\n exportJSON(): SerializedMentionNode {\n return {\n userId: this.__userId,\n type: \"lb-mention\",\n version: 1,\n };\n }\n\n getUserId(): string {\n const self = this.getLatest();\n return self.__userId;\n }\n\n getId(): string {\n const self = this.getLatest();\n return self.__id;\n }\n\n decorate(): JSX.Element {\n return (\n <Mention nodeKey={this.getKey()}>\n {MENTION_CHARACTER}\n <User userId={this.getUserId()} />\n </Mention>\n );\n }\n}\n\nexport function $isMentionNode(\n node: LexicalNode | null | undefined\n): node is MentionNode {\n return node instanceof MentionNode;\n}\n\nexport function $createMentionNode(userId: string): MentionNode {\n const node = new MentionNode(createInboxNotificationId(), userId);\n return $applyNodeReplacement(node);\n}\n"],"names":[
|
|
1
|
+
{"version":3,"file":"mention-node.js","sources":["../../src/mentions/mention-node.tsx"],"sourcesContent":["import { createInboxNotificationId } from \"@liveblocks/core\";\nimport type {\n DOMConversionMap,\n DOMExportOutput,\n LexicalNode,\n NodeKey,\n SerializedLexicalNode,\n Spread,\n} from \"lexical\";\nimport { $applyNodeReplacement, DecoratorNode } from \"lexical\";\nimport type { JSX } from \"react\";\n\nimport { Mention } from \"./mention-component\";\nimport { User } from \"./user\";\n\nconst MENTION_CHARACTER = \"@\";\n\nexport type SerializedMentionNode = Spread<\n {\n userId: string;\n },\n SerializedLexicalNode\n>;\nexport class MentionNode extends DecoratorNode<JSX.Element> {\n __id: string;\n __userId: string;\n\n constructor(id: string, userId: string, key?: NodeKey) {\n super(key);\n this.__id = id;\n this.__userId = userId;\n }\n\n static getType(): string {\n return \"lb-mention\";\n }\n\n static clone(node: MentionNode): MentionNode {\n return new MentionNode(node.__id, node.__userId, node.__key);\n }\n\n createDOM(): HTMLElement {\n const element = document.createElement(\"span\");\n element.style.display = \"inline-block\";\n element.style.userSelect = \"none\";\n return element;\n }\n\n updateDOM(): boolean {\n return false;\n }\n\n static importDom(): DOMConversionMap<HTMLElement> | null {\n return {\n span: () => ({\n conversion: (element) => {\n const value = atob(element.getAttribute(\"data-lexical-lb-mention\")!);\n const node = $createMentionNode(value);\n return { node };\n },\n priority: 1,\n }),\n };\n }\n\n exportDOM(): DOMExportOutput {\n const element = document.createElement(\"span\");\n const value = this.getTextContent();\n element.setAttribute(\"data-lexical-lb-mention\", btoa(value));\n element.textContent = this.getTextContent();\n return { element };\n }\n\n static importJSON(serializedNode: SerializedMentionNode): MentionNode {\n const node = $createMentionNode(serializedNode.userId);\n return node;\n }\n\n exportJSON(): SerializedMentionNode {\n return {\n userId: this.__userId,\n type: \"lb-mention\",\n version: 1,\n };\n }\n\n getUserId(): string {\n const self = this.getLatest();\n return self.__userId;\n }\n\n getId(): string {\n const self = this.getLatest();\n return self.__id;\n }\n\n decorate(): JSX.Element {\n return (\n <Mention nodeKey={this.getKey()}>\n {MENTION_CHARACTER}\n <User userId={this.getUserId()} />\n </Mention>\n );\n }\n}\n\nexport function $isMentionNode(\n node: LexicalNode | null | undefined\n): node is MentionNode {\n return node instanceof MentionNode;\n}\n\nexport function $createMentionNode(userId: string): MentionNode {\n const node = new MentionNode(createInboxNotificationId(), userId);\n return $applyNodeReplacement(node);\n}\n"],"names":[],"mappings":";;;;;;AAeA,MAAM,iBAAoB,GAAA,GAAA,CAAA;AAQnB,MAAM,oBAAoB,aAA2B,CAAA;AAAA,EAC1D,IAAA,CAAA;AAAA,EACA,QAAA,CAAA;AAAA,EAEA,WAAA,CAAY,EAAY,EAAA,MAAA,EAAgB,GAAe,EAAA;AACrD,IAAA,KAAA,CAAM,GAAG,CAAA,CAAA;AACT,IAAA,IAAA,CAAK,IAAO,GAAA,EAAA,CAAA;AACZ,IAAA,IAAA,CAAK,QAAW,GAAA,MAAA,CAAA;AAAA,GAClB;AAAA,EAEA,OAAO,OAAkB,GAAA;AACvB,IAAO,OAAA,YAAA,CAAA;AAAA,GACT;AAAA,EAEA,OAAO,MAAM,IAAgC,EAAA;AAC3C,IAAA,OAAO,IAAI,WAAY,CAAA,IAAA,CAAK,MAAM,IAAK,CAAA,QAAA,EAAU,KAAK,KAAK,CAAA,CAAA;AAAA,GAC7D;AAAA,EAEA,SAAyB,GAAA;AACvB,IAAM,MAAA,OAAA,GAAU,QAAS,CAAA,aAAA,CAAc,MAAM,CAAA,CAAA;AAC7C,IAAA,OAAA,CAAQ,MAAM,OAAU,GAAA,cAAA,CAAA;AACxB,IAAA,OAAA,CAAQ,MAAM,UAAa,GAAA,MAAA,CAAA;AAC3B,IAAO,OAAA,OAAA,CAAA;AAAA,GACT;AAAA,EAEA,SAAqB,GAAA;AACnB,IAAO,OAAA,KAAA,CAAA;AAAA,GACT;AAAA,EAEA,OAAO,SAAkD,GAAA;AACvD,IAAO,OAAA;AAAA,MACL,MAAM,OAAO;AAAA,QACX,UAAA,EAAY,CAAC,OAAY,KAAA;AACvB,UAAA,MAAM,KAAQ,GAAA,IAAA,CAAK,OAAQ,CAAA,YAAA,CAAa,yBAAyB,CA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,EAAS,KAAK,MAAO,EAAA;AAAA,MAC3B,QAAA,EAAA;AAAA,QAAA,iBAAA;AAAA,wBACA,GAAA,CAAA,IAAA,EAAA;AAAA,UAAK,MAAA,EAAQ,KAAK,SAAU,EAAA;AAAA,SAAG,CAAA;AAAA,OAAA;AAAA,KAClC,CAAA,CAAA;AAAA,GAEJ;AACF,CAAA;AAEO,SAAS,eACd,IACqB,EAAA;AACrB,EAAA,OAAO,IAAgB,YAAA,WAAA,CAAA;AACzB,CAAA;AAEO,SAAS,mBAAmB,MAA6B,EAAA;AAC9D,EAAA,MAAM,IAAO,GAAA,IAAI,WAAY,CAAA,yBAAA,IAA6B,MAAM,CAAA,CAAA;AAChE,EAAA,OAAO,sBAAsB,IAAI,CAAA,CAAA;AACnC;;;;"}
|
|
@@ -1,15 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
+
var reactDom$1 = require('@floating-ui/react-dom');
|
|
5
|
+
var LexicalComposerContext = require('@lexical/react/LexicalComposerContext');
|
|
6
|
+
var react = require('@liveblocks/react');
|
|
7
|
+
var _private = require('@liveblocks/react/_private');
|
|
8
|
+
var lexical = require('lexical');
|
|
9
|
+
var react$1 = require('react');
|
|
10
|
+
var reactDom = require('react-dom');
|
|
11
|
+
var avatar = require('./avatar.cjs');
|
|
12
|
+
var mentionNode = require('./mention-node.cjs');
|
|
13
|
+
var suggestions = require('./suggestions.cjs');
|
|
14
|
+
var user = require('./user.cjs');
|
|
13
15
|
|
|
14
16
|
const MENTION_TRIGGER = "@";
|
|
15
17
|
const PUNCTUATIONS = `\\.,\\+\\*\\?\\$\\@\\|#{}\\(\\)\\^\\-\\[\\]\\\\/!%'"~=<>_:;`;
|
|
@@ -20,8 +22,8 @@ const MentionRegex = new RegExp(
|
|
|
20
22
|
"(^|\\s|\\()([" + MENTION_TRIGGER + "]((?:" + VALID_CHARACTERS + VALID_JOINS + "){0," + LENGTH_LIMIT + "}))$"
|
|
21
23
|
);
|
|
22
24
|
function $getAnchorNodeTextContent() {
|
|
23
|
-
const selection =
|
|
24
|
-
if (
|
|
25
|
+
const selection = lexical.$getSelection();
|
|
26
|
+
if (!lexical.$isRangeSelection(selection))
|
|
25
27
|
return null;
|
|
26
28
|
const anchor = selection.anchor;
|
|
27
29
|
if (anchor.type !== "text")
|
|
@@ -44,12 +46,12 @@ function getFullMatchOffset(documentText, entryText, offset2) {
|
|
|
44
46
|
function $isCurrentSelectionAtBoundary(offset2) {
|
|
45
47
|
if (offset2 !== 0)
|
|
46
48
|
return false;
|
|
47
|
-
const selection =
|
|
48
|
-
if (
|
|
49
|
+
const selection = lexical.$getSelection();
|
|
50
|
+
if (!lexical.$isRangeSelection(selection))
|
|
49
51
|
return false;
|
|
50
52
|
const anchor = selection.anchor.getNode();
|
|
51
53
|
const prevSibling = anchor.getPreviousSibling();
|
|
52
|
-
if (
|
|
54
|
+
if (!lexical.$isTextNode(prevSibling))
|
|
53
55
|
return false;
|
|
54
56
|
if (!prevSibling.isTextEntity())
|
|
55
57
|
return false;
|
|
@@ -80,33 +82,33 @@ function $getRangeAtMatch(match) {
|
|
|
80
82
|
}
|
|
81
83
|
}
|
|
82
84
|
function MentionPlugin() {
|
|
83
|
-
const [editor] = useLexicalComposerContext();
|
|
84
|
-
const room = useRoom();
|
|
85
|
-
const [match, setMatch] = useState(null);
|
|
85
|
+
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
86
|
+
const room = react.useRoom();
|
|
87
|
+
const [match, setMatch] = react$1.useState(null);
|
|
86
88
|
const matchingString = match?.[3];
|
|
87
|
-
const suggestions = useMentionSuggestions(room.id, matchingString);
|
|
88
|
-
const createTextMention = useCreateTextMention();
|
|
89
|
-
const deleteTextMention = useDeleteTextMention();
|
|
90
|
-
useEffect(() => {
|
|
89
|
+
const suggestions$1 = _private.useMentionSuggestions(room.id, matchingString);
|
|
90
|
+
const createTextMention = _private.useCreateTextMention();
|
|
91
|
+
const deleteTextMention = _private.useDeleteTextMention();
|
|
92
|
+
react$1.useEffect(() => {
|
|
91
93
|
function $handleMutation(mutations, {
|
|
92
94
|
prevEditorState
|
|
93
95
|
}) {
|
|
94
96
|
for (const [key, mutation] of mutations) {
|
|
95
97
|
if (mutation === "created") {
|
|
96
98
|
editor.getEditorState().read(() => {
|
|
97
|
-
const node =
|
|
99
|
+
const node = lexical.$getNodeByKey(key);
|
|
98
100
|
if (node === null)
|
|
99
101
|
return;
|
|
100
|
-
if (
|
|
102
|
+
if (!mentionNode.$isMentionNode(node))
|
|
101
103
|
return;
|
|
102
104
|
createTextMention(node.getUserId(), node.getId());
|
|
103
105
|
});
|
|
104
106
|
} else if (mutation === "destroyed") {
|
|
105
107
|
prevEditorState.read(() => {
|
|
106
|
-
const node =
|
|
108
|
+
const node = lexical.$getNodeByKey(key);
|
|
107
109
|
if (node === null)
|
|
108
110
|
return;
|
|
109
|
-
if (
|
|
111
|
+
if (!mentionNode.$isMentionNode(node))
|
|
110
112
|
return;
|
|
111
113
|
deleteTextMention(node.getId());
|
|
112
114
|
});
|
|
@@ -114,7 +116,7 @@ function MentionPlugin() {
|
|
|
114
116
|
}
|
|
115
117
|
}
|
|
116
118
|
return editor.registerMutationListener(
|
|
117
|
-
MentionNode,
|
|
119
|
+
mentionNode.MentionNode,
|
|
118
120
|
(mutations, payload) => {
|
|
119
121
|
if (payload.updateTags.has("collaboration") || payload.updateTags.has("history-merge")) {
|
|
120
122
|
return;
|
|
@@ -123,7 +125,7 @@ function MentionPlugin() {
|
|
|
123
125
|
}
|
|
124
126
|
);
|
|
125
127
|
}, [editor, createTextMention, deleteTextMention]);
|
|
126
|
-
useEffect(() => {
|
|
128
|
+
react$1.useEffect(() => {
|
|
127
129
|
function $onStateRead() {
|
|
128
130
|
const text = $getAnchorNodeTextContent();
|
|
129
131
|
if (text === null) {
|
|
@@ -137,47 +139,47 @@ function MentionPlugin() {
|
|
|
137
139
|
state.read($onStateRead);
|
|
138
140
|
});
|
|
139
141
|
}, [editor]);
|
|
140
|
-
useEffect(() => {
|
|
142
|
+
react$1.useEffect(() => {
|
|
141
143
|
function $handleBackspace(event) {
|
|
142
|
-
const selection =
|
|
144
|
+
const selection = lexical.$getSelection();
|
|
143
145
|
if (selection === null)
|
|
144
146
|
return false;
|
|
145
|
-
if (
|
|
147
|
+
if (lexical.$isNodeSelection(selection)) {
|
|
146
148
|
const nodes = selection.getNodes();
|
|
147
149
|
if (nodes.length !== 1)
|
|
148
150
|
return false;
|
|
149
151
|
const node = nodes[0];
|
|
150
|
-
if (
|
|
152
|
+
if (!mentionNode.$isMentionNode(node))
|
|
151
153
|
return false;
|
|
152
|
-
const text =
|
|
154
|
+
const text = lexical.$createTextNode("@");
|
|
153
155
|
node.replace(text);
|
|
154
|
-
const newSelection =
|
|
156
|
+
const newSelection = lexical.$createRangeSelection();
|
|
155
157
|
newSelection.setTextNodeRange(text, 1, text, 1);
|
|
156
|
-
|
|
158
|
+
lexical.$setSelection(newSelection);
|
|
157
159
|
event.preventDefault();
|
|
158
160
|
return true;
|
|
159
|
-
} else if (
|
|
161
|
+
} else if (lexical.$isRangeSelection(selection)) {
|
|
160
162
|
if (!selection.isCollapsed())
|
|
161
163
|
return false;
|
|
162
164
|
const anchor = selection.anchor.getNode();
|
|
163
165
|
const prevSibling = anchor.getPreviousSibling();
|
|
164
|
-
if (selection.anchor.offset === 0 &&
|
|
165
|
-
const text =
|
|
166
|
+
if (selection.anchor.offset === 0 && mentionNode.$isMentionNode(prevSibling)) {
|
|
167
|
+
const text = lexical.$createTextNode("@");
|
|
166
168
|
prevSibling.replace(text);
|
|
167
|
-
const newSelection =
|
|
169
|
+
const newSelection = lexical.$createRangeSelection();
|
|
168
170
|
newSelection.setTextNodeRange(text, 1, text, 1);
|
|
169
|
-
|
|
171
|
+
lexical.$setSelection(newSelection);
|
|
170
172
|
event.preventDefault();
|
|
171
173
|
return true;
|
|
172
|
-
} else if (
|
|
174
|
+
} else if (lexical.$isElementNode(anchor)) {
|
|
173
175
|
const child = anchor.getChildAtIndex(selection.anchor.offset - 1);
|
|
174
|
-
if (
|
|
176
|
+
if (!mentionNode.$isMentionNode(child))
|
|
175
177
|
return false;
|
|
176
|
-
const text =
|
|
178
|
+
const text = lexical.$createTextNode("@");
|
|
177
179
|
child.replace(text);
|
|
178
|
-
const newSelection =
|
|
180
|
+
const newSelection = lexical.$createRangeSelection();
|
|
179
181
|
newSelection.setTextNodeRange(text, 1, text, 1);
|
|
180
|
-
|
|
182
|
+
lexical.$setSelection(newSelection);
|
|
181
183
|
event.preventDefault();
|
|
182
184
|
return true;
|
|
183
185
|
}
|
|
@@ -186,19 +188,19 @@ function MentionPlugin() {
|
|
|
186
188
|
return false;
|
|
187
189
|
}
|
|
188
190
|
return editor.registerCommand(
|
|
189
|
-
KEY_BACKSPACE_COMMAND,
|
|
191
|
+
lexical.KEY_BACKSPACE_COMMAND,
|
|
190
192
|
$handleBackspace,
|
|
191
|
-
COMMAND_PRIORITY_LOW
|
|
193
|
+
lexical.COMMAND_PRIORITY_LOW
|
|
192
194
|
);
|
|
193
195
|
}, [editor]);
|
|
194
|
-
const handleValueSelect = useCallback(
|
|
196
|
+
const handleValueSelect = react$1.useCallback(
|
|
195
197
|
(userId) => {
|
|
196
198
|
function $onValueSelect() {
|
|
197
199
|
if (match === null)
|
|
198
200
|
return;
|
|
199
201
|
setMatch(null);
|
|
200
|
-
const selection =
|
|
201
|
-
if (
|
|
202
|
+
const selection = lexical.$getSelection();
|
|
203
|
+
if (!lexical.$isRangeSelection(selection))
|
|
202
204
|
return;
|
|
203
205
|
if (!selection.isCollapsed())
|
|
204
206
|
return;
|
|
@@ -215,13 +217,13 @@ function MentionPlugin() {
|
|
|
215
217
|
const startOffset = selectionOffset - queryOffset;
|
|
216
218
|
if (startOffset < 0)
|
|
217
219
|
return;
|
|
218
|
-
const mentionNode =
|
|
220
|
+
const mentionNode$1 = mentionNode.$createMentionNode(userId);
|
|
219
221
|
if (startOffset === 0) {
|
|
220
222
|
const [node] = anchorNode.splitText(selectionOffset);
|
|
221
|
-
node.replace(mentionNode);
|
|
223
|
+
node.replace(mentionNode$1);
|
|
222
224
|
} else {
|
|
223
225
|
const [, node] = anchorNode.splitText(startOffset, selectionOffset);
|
|
224
|
-
node.replace(mentionNode);
|
|
226
|
+
node.replace(mentionNode$1);
|
|
225
227
|
}
|
|
226
228
|
}
|
|
227
229
|
editor.update($onValueSelect);
|
|
@@ -230,32 +232,32 @@ function MentionPlugin() {
|
|
|
230
232
|
);
|
|
231
233
|
if (match === null || matchingString === void 0)
|
|
232
234
|
return null;
|
|
233
|
-
if (suggestions === void 0 || suggestions.length === 0)
|
|
235
|
+
if (suggestions$1 === void 0 || suggestions$1.length === 0)
|
|
234
236
|
return null;
|
|
235
237
|
const range = editor.getEditorState().read(() => $getRangeAtMatch(match));
|
|
236
238
|
if (range === null)
|
|
237
239
|
return null;
|
|
238
|
-
return createPortal(
|
|
239
|
-
/* @__PURE__ */ jsx(SuggestionsContext.Provider, {
|
|
240
|
-
value: suggestions,
|
|
241
|
-
children: /* @__PURE__ */ jsx(OnValueSelectCallbackContext.Provider, {
|
|
240
|
+
return reactDom.createPortal(
|
|
241
|
+
/* @__PURE__ */ jsxRuntime.jsx(suggestions.SuggestionsContext.Provider, {
|
|
242
|
+
value: suggestions$1,
|
|
243
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(suggestions.OnValueSelectCallbackContext.Provider, {
|
|
242
244
|
value: handleValueSelect,
|
|
243
|
-
children: /* @__PURE__ */ jsx(OnResetMatchCallbackContext.Provider, {
|
|
245
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(suggestions.OnResetMatchCallbackContext.Provider, {
|
|
244
246
|
value: () => setMatch(null),
|
|
245
|
-
children: /* @__PURE__ */ jsx(SuggestionsPortal, {
|
|
247
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(SuggestionsPortal, {
|
|
246
248
|
range,
|
|
247
249
|
container: document.body,
|
|
248
|
-
children: /* @__PURE__ */ jsx(List, {
|
|
250
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(suggestions.List, {
|
|
249
251
|
className: "lb-lexical-suggestions-list lb-lexical-mention-suggestions-list",
|
|
250
|
-
children: suggestions.map((userId) => /* @__PURE__ */ jsxs(Item, {
|
|
252
|
+
children: suggestions$1.map((userId) => /* @__PURE__ */ jsxRuntime.jsxs(suggestions.Item, {
|
|
251
253
|
value: userId,
|
|
252
254
|
className: "lb-lexical-suggestions-list-item lb-lexical-mention-suggestion",
|
|
253
255
|
children: [
|
|
254
|
-
/* @__PURE__ */ jsx(Avatar, {
|
|
256
|
+
/* @__PURE__ */ jsxRuntime.jsx(avatar.Avatar, {
|
|
255
257
|
userId,
|
|
256
258
|
className: "lb-lexical-mention-suggestion-avatar"
|
|
257
259
|
}),
|
|
258
|
-
/* @__PURE__ */ jsx(User, {
|
|
260
|
+
/* @__PURE__ */ jsxRuntime.jsx(user.User, {
|
|
259
261
|
userId,
|
|
260
262
|
className: "lb-lexical-mention-suggestion-user"
|
|
261
263
|
})
|
|
@@ -280,29 +282,29 @@ function SuggestionsPortal({
|
|
|
280
282
|
strategy,
|
|
281
283
|
x,
|
|
282
284
|
y
|
|
283
|
-
} = useFloating({
|
|
285
|
+
} = reactDom$1.useFloating({
|
|
284
286
|
strategy: "fixed",
|
|
285
287
|
placement: "top-start",
|
|
286
288
|
middleware: [
|
|
287
|
-
flip({ padding: SUGGESTIONS_COLLISION_PADDING, crossAxis: false }),
|
|
288
|
-
offset(10),
|
|
289
|
-
hide({ padding: SUGGESTIONS_COLLISION_PADDING }),
|
|
290
|
-
shift({ padding: SUGGESTIONS_COLLISION_PADDING, limiter: limitShift() }),
|
|
291
|
-
size({ padding: SUGGESTIONS_COLLISION_PADDING })
|
|
289
|
+
reactDom$1.flip({ padding: SUGGESTIONS_COLLISION_PADDING, crossAxis: false }),
|
|
290
|
+
reactDom$1.offset(10),
|
|
291
|
+
reactDom$1.hide({ padding: SUGGESTIONS_COLLISION_PADDING }),
|
|
292
|
+
reactDom$1.shift({ padding: SUGGESTIONS_COLLISION_PADDING, limiter: reactDom$1.limitShift() }),
|
|
293
|
+
reactDom$1.size({ padding: SUGGESTIONS_COLLISION_PADDING })
|
|
292
294
|
],
|
|
293
295
|
whileElementsMounted: (...args) => {
|
|
294
|
-
return autoUpdate(...args, {
|
|
296
|
+
return reactDom$1.autoUpdate(...args, {
|
|
295
297
|
animationFrame: true
|
|
296
298
|
});
|
|
297
299
|
}
|
|
298
300
|
});
|
|
299
|
-
useLayoutEffect(() => {
|
|
301
|
+
_private.useLayoutEffect(() => {
|
|
300
302
|
setReference({
|
|
301
303
|
getBoundingClientRect: () => range.getBoundingClientRect()
|
|
302
304
|
});
|
|
303
305
|
}, [setReference, range]);
|
|
304
|
-
return createPortal(
|
|
305
|
-
/* @__PURE__ */ jsx("div", {
|
|
306
|
+
return reactDom.createPortal(
|
|
307
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", {
|
|
306
308
|
ref: setFloating,
|
|
307
309
|
style: {
|
|
308
310
|
position: strategy,
|
|
@@ -318,5 +320,6 @@ function SuggestionsPortal({
|
|
|
318
320
|
);
|
|
319
321
|
}
|
|
320
322
|
|
|
321
|
-
|
|
322
|
-
|
|
323
|
+
exports.MentionPlugin = MentionPlugin;
|
|
324
|
+
exports.SUGGESTIONS_COLLISION_PADDING = SUGGESTIONS_COLLISION_PADDING;
|
|
325
|
+
//# sourceMappingURL=mention-plugin.cjs.map
|