@liveblocks/react-lexical 2.15.0-debug1 → 2.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/dist/comments/thread-mark-node.js +5 -4
- package/dist/comments/thread-mark-node.js.map +1 -1
- package/dist/comments/thread-mark-node.mjs +5 -4
- package/dist/comments/thread-mark-node.mjs.map +1 -1
- package/dist/mentions/mention-node.js +2 -0
- package/dist/mentions/mention-node.js.map +1 -1
- package/dist/mentions/mention-node.mjs +2 -0
- package/dist/mentions/mention-node.mjs.map +1 -1
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/dist/version.mjs +1 -1
- package/dist/version.mjs.map +1 -1
- package/package.json +10 -15
|
@@ -3,10 +3,7 @@
|
|
|
3
3
|
var lexical = require('lexical');
|
|
4
4
|
|
|
5
5
|
class ThreadMarkNode extends lexical.ElementNode {
|
|
6
|
-
|
|
7
|
-
super(key);
|
|
8
|
-
this.__ids = ids || [];
|
|
9
|
-
}
|
|
6
|
+
__ids;
|
|
10
7
|
static getType() {
|
|
11
8
|
return "lb-thread-mark";
|
|
12
9
|
}
|
|
@@ -31,6 +28,10 @@ class ThreadMarkNode extends lexical.ElementNode {
|
|
|
31
28
|
version: 1
|
|
32
29
|
};
|
|
33
30
|
}
|
|
31
|
+
constructor(ids, key) {
|
|
32
|
+
super(key);
|
|
33
|
+
this.__ids = ids || [];
|
|
34
|
+
}
|
|
34
35
|
createDOM() {
|
|
35
36
|
const element = document.createElement("span");
|
|
36
37
|
return element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"thread-mark-node.js","sources":["../../src/comments/thread-mark-node.ts"],"sourcesContent":["import type {\n BaseSelection,\n LexicalNode,\n NodeKey,\n RangeSelection,\n SerializedElementNode,\n Spread,\n} from \"lexical\";\nimport { $applyNodeReplacement, $isRangeSelection, ElementNode } from \"lexical\";\n\nexport type SerializedThreadMarkNode = Spread<\n {\n ids: Array<string>;\n },\n SerializedElementNode\n>;\n\nexport class ThreadMarkNode extends ElementNode {\n /** @internal */\n __ids: Array<string>; // The ids of the threads that this mark is associated with\n\n static getType(): string {\n return \"lb-thread-mark\";\n }\n\n static clone(node: ThreadMarkNode): ThreadMarkNode {\n return new ThreadMarkNode(Array.from(node.__ids), node.__key);\n }\n\n static importDOM(): null {\n return null;\n }\n\n static importJSON(serializedNode: SerializedThreadMarkNode): ThreadMarkNode {\n const node = $createThreadMarkNode(serializedNode.ids);\n node.setFormat(serializedNode.format);\n node.setIndent(serializedNode.indent);\n node.setDirection(serializedNode.direction);\n return node;\n }\n\n exportJSON(): SerializedThreadMarkNode {\n return {\n ...super.exportJSON(),\n ids: this.getIDs(),\n type: \"lb-thread-mark\",\n version: 1,\n };\n }\n\n constructor(ids: Array<string>, key?: NodeKey) {\n super(key);\n this.__ids = ids || [];\n }\n\n createDOM(): HTMLElement {\n const element = document.createElement(\"span\");\n return element;\n }\n\n updateDOM(): boolean {\n return false;\n }\n\n hasID(id: string): boolean {\n const ids = this.getIDs();\n for (let i = 0; i < ids.length; i++) {\n if (id === ids[i]) {\n return true;\n }\n }\n return false;\n }\n\n getIDs(): Array<string> {\n const self = this.getLatest();\n return $isThreadMarkNode(self) ? self.__ids : [];\n }\n\n addID(id: string): void {\n const self = this.getWritable();\n if ($isThreadMarkNode(self)) {\n const ids = self.__ids;\n self.__ids = ids;\n for (let i = 0; i < ids.length; i++) {\n // If we already have it, don't add again\n if (id === ids[i]) {\n return;\n }\n }\n ids.push(id);\n }\n }\n\n deleteID(id: string): void {\n const self = this.getWritable();\n if ($isThreadMarkNode(self)) {\n const ids = self.__ids;\n self.__ids = ids;\n for (let i = 0; i < ids.length; i++) {\n if (id === ids[i]) {\n ids.splice(i, 1);\n return;\n }\n }\n }\n }\n\n insertNewAfter(\n _: RangeSelection,\n restoreSelection = true\n ): null | ElementNode {\n const markNode = $createThreadMarkNode(this.__ids);\n this.insertAfter(markNode, restoreSelection);\n return markNode;\n }\n\n canInsertTextBefore(): false {\n return false;\n }\n\n canInsertTextAfter(): false {\n return false;\n }\n\n canBeEmpty(): false {\n return false;\n }\n\n isInline(): true {\n return true;\n }\n\n extractWithChild(\n _: LexicalNode,\n selection: BaseSelection,\n destination: \"clone\" | \"html\"\n ): boolean {\n if (!$isRangeSelection(selection) || destination === \"html\") {\n return false;\n }\n const anchor = selection.anchor;\n const focus = selection.focus;\n const anchorNode = anchor.getNode();\n const focusNode = focus.getNode();\n const isBackward = selection.isBackward();\n const selectionLength = isBackward\n ? anchor.offset - focus.offset\n : focus.offset - anchor.offset;\n return (\n this.isParentOf(anchorNode) &&\n this.isParentOf(focusNode) &&\n this.getTextContent().length === selectionLength\n );\n }\n\n excludeFromCopy(destination: \"clone\" | \"html\"): boolean {\n return destination !== \"clone\";\n }\n}\n\nexport function $createThreadMarkNode(ids: Array<string>): ThreadMarkNode {\n return $applyNodeReplacement(new ThreadMarkNode(ids));\n}\n\nexport function $isThreadMarkNode(\n node: LexicalNode | null\n): node is ThreadMarkNode {\n return node instanceof ThreadMarkNode;\n}\n"],"names":["ElementNode","$isRangeSelection","$applyNodeReplacement"],"mappings":";;;;AAiBO,MAAM,uBAAuBA,mBAAY,CAAA;AAAA,
|
|
1
|
+
{"version":3,"file":"thread-mark-node.js","sources":["../../src/comments/thread-mark-node.ts"],"sourcesContent":["import type {\n BaseSelection,\n LexicalNode,\n NodeKey,\n RangeSelection,\n SerializedElementNode,\n Spread,\n} from \"lexical\";\nimport { $applyNodeReplacement, $isRangeSelection, ElementNode } from \"lexical\";\n\nexport type SerializedThreadMarkNode = Spread<\n {\n ids: Array<string>;\n },\n SerializedElementNode\n>;\n\nexport class ThreadMarkNode extends ElementNode {\n /** @internal */\n __ids: Array<string>; // The ids of the threads that this mark is associated with\n\n static getType(): string {\n return \"lb-thread-mark\";\n }\n\n static clone(node: ThreadMarkNode): ThreadMarkNode {\n return new ThreadMarkNode(Array.from(node.__ids), node.__key);\n }\n\n static importDOM(): null {\n return null;\n }\n\n static importJSON(serializedNode: SerializedThreadMarkNode): ThreadMarkNode {\n const node = $createThreadMarkNode(serializedNode.ids);\n node.setFormat(serializedNode.format);\n node.setIndent(serializedNode.indent);\n node.setDirection(serializedNode.direction);\n return node;\n }\n\n exportJSON(): SerializedThreadMarkNode {\n return {\n ...super.exportJSON(),\n ids: this.getIDs(),\n type: \"lb-thread-mark\",\n version: 1,\n };\n }\n\n constructor(ids: Array<string>, key?: NodeKey) {\n super(key);\n this.__ids = ids || [];\n }\n\n createDOM(): HTMLElement {\n const element = document.createElement(\"span\");\n return element;\n }\n\n updateDOM(): boolean {\n return false;\n }\n\n hasID(id: string): boolean {\n const ids = this.getIDs();\n for (let i = 0; i < ids.length; i++) {\n if (id === ids[i]) {\n return true;\n }\n }\n return false;\n }\n\n getIDs(): Array<string> {\n const self = this.getLatest();\n return $isThreadMarkNode(self) ? self.__ids : [];\n }\n\n addID(id: string): void {\n const self = this.getWritable();\n if ($isThreadMarkNode(self)) {\n const ids = self.__ids;\n self.__ids = ids;\n for (let i = 0; i < ids.length; i++) {\n // If we already have it, don't add again\n if (id === ids[i]) {\n return;\n }\n }\n ids.push(id);\n }\n }\n\n deleteID(id: string): void {\n const self = this.getWritable();\n if ($isThreadMarkNode(self)) {\n const ids = self.__ids;\n self.__ids = ids;\n for (let i = 0; i < ids.length; i++) {\n if (id === ids[i]) {\n ids.splice(i, 1);\n return;\n }\n }\n }\n }\n\n insertNewAfter(\n _: RangeSelection,\n restoreSelection = true\n ): null | ElementNode {\n const markNode = $createThreadMarkNode(this.__ids);\n this.insertAfter(markNode, restoreSelection);\n return markNode;\n }\n\n canInsertTextBefore(): false {\n return false;\n }\n\n canInsertTextAfter(): false {\n return false;\n }\n\n canBeEmpty(): false {\n return false;\n }\n\n isInline(): true {\n return true;\n }\n\n extractWithChild(\n _: LexicalNode,\n selection: BaseSelection,\n destination: \"clone\" | \"html\"\n ): boolean {\n if (!$isRangeSelection(selection) || destination === \"html\") {\n return false;\n }\n const anchor = selection.anchor;\n const focus = selection.focus;\n const anchorNode = anchor.getNode();\n const focusNode = focus.getNode();\n const isBackward = selection.isBackward();\n const selectionLength = isBackward\n ? anchor.offset - focus.offset\n : focus.offset - anchor.offset;\n return (\n this.isParentOf(anchorNode) &&\n this.isParentOf(focusNode) &&\n this.getTextContent().length === selectionLength\n );\n }\n\n excludeFromCopy(destination: \"clone\" | \"html\"): boolean {\n return destination !== \"clone\";\n }\n}\n\nexport function $createThreadMarkNode(ids: Array<string>): ThreadMarkNode {\n return $applyNodeReplacement(new ThreadMarkNode(ids));\n}\n\nexport function $isThreadMarkNode(\n node: LexicalNode | null\n): node is ThreadMarkNode {\n return node instanceof ThreadMarkNode;\n}\n"],"names":["ElementNode","$isRangeSelection","$applyNodeReplacement"],"mappings":";;;;AAiBO,MAAM,uBAAuBA,mBAAY,CAAA;AAAA,EAE9C,KAAA,CAAA;AAAA,EAEA,OAAO,OAAkB,GAAA;AACvB,IAAO,OAAA,gBAAA,CAAA;AAAA,GACT;AAAA,EAEA,OAAO,MAAM,IAAsC,EAAA;AACjD,IAAO,OAAA,IAAI,eAAe,KAAM,CAAA,IAAA,CAAK,KAAK,KAAK,CAAA,EAAG,KAAK,KAAK,CAAA,CAAA;AAAA,GAC9D;AAAA,EAEA,OAAO,SAAkB,GAAA;AACvB,IAAO,OAAA,IAAA,CAAA;AAAA,GACT;AAAA,EAEA,OAAO,WAAW,cAA0D,EAAA;AAC1E,IAAM,MAAA,IAAA,GAAO,qBAAsB,CAAA,cAAA,CAAe,GAAG,CAAA,CAAA;AACrD,IAAK,IAAA,CAAA,SAAA,CAAU,eAAe,MAAM,CAAA,CAAA;AACpC,IAAK,IAAA,CAAA,SAAA,CAAU,eAAe,MAAM,CAAA,CAAA;AACpC,IAAK,IAAA,CAAA,YAAA,CAAa,eAAe,SAAS,CAAA,CAAA;AAC1C,IAAO,OAAA,IAAA,CAAA;AAAA,GACT;AAAA,EAEA,UAAuC,GAAA;AACrC,IAAO,OAAA;AAAA,MACL,G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
|
-
|
|
5
|
-
super(key);
|
|
6
|
-
this.__ids = ids || [];
|
|
7
|
-
}
|
|
4
|
+
__ids;
|
|
8
5
|
static getType() {
|
|
9
6
|
return "lb-thread-mark";
|
|
10
7
|
}
|
|
@@ -29,6 +26,10 @@ class ThreadMarkNode extends ElementNode {
|
|
|
29
26
|
version: 1
|
|
30
27
|
};
|
|
31
28
|
}
|
|
29
|
+
constructor(ids, key) {
|
|
30
|
+
super(key);
|
|
31
|
+
this.__ids = ids || [];
|
|
32
|
+
}
|
|
32
33
|
createDOM() {
|
|
33
34
|
const element = document.createElement("span");
|
|
34
35
|
return element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"thread-mark-node.mjs","sources":["../../src/comments/thread-mark-node.ts"],"sourcesContent":["import type {\n BaseSelection,\n LexicalNode,\n NodeKey,\n RangeSelection,\n SerializedElementNode,\n Spread,\n} from \"lexical\";\nimport { $applyNodeReplacement, $isRangeSelection, ElementNode } from \"lexical\";\n\nexport type SerializedThreadMarkNode = Spread<\n {\n ids: Array<string>;\n },\n SerializedElementNode\n>;\n\nexport class ThreadMarkNode extends ElementNode {\n /** @internal */\n __ids: Array<string>; // The ids of the threads that this mark is associated with\n\n static getType(): string {\n return \"lb-thread-mark\";\n }\n\n static clone(node: ThreadMarkNode): ThreadMarkNode {\n return new ThreadMarkNode(Array.from(node.__ids), node.__key);\n }\n\n static importDOM(): null {\n return null;\n }\n\n static importJSON(serializedNode: SerializedThreadMarkNode): ThreadMarkNode {\n const node = $createThreadMarkNode(serializedNode.ids);\n node.setFormat(serializedNode.format);\n node.setIndent(serializedNode.indent);\n node.setDirection(serializedNode.direction);\n return node;\n }\n\n exportJSON(): SerializedThreadMarkNode {\n return {\n ...super.exportJSON(),\n ids: this.getIDs(),\n type: \"lb-thread-mark\",\n version: 1,\n };\n }\n\n constructor(ids: Array<string>, key?: NodeKey) {\n super(key);\n this.__ids = ids || [];\n }\n\n createDOM(): HTMLElement {\n const element = document.createElement(\"span\");\n return element;\n }\n\n updateDOM(): boolean {\n return false;\n }\n\n hasID(id: string): boolean {\n const ids = this.getIDs();\n for (let i = 0; i < ids.length; i++) {\n if (id === ids[i]) {\n return true;\n }\n }\n return false;\n }\n\n getIDs(): Array<string> {\n const self = this.getLatest();\n return $isThreadMarkNode(self) ? self.__ids : [];\n }\n\n addID(id: string): void {\n const self = this.getWritable();\n if ($isThreadMarkNode(self)) {\n const ids = self.__ids;\n self.__ids = ids;\n for (let i = 0; i < ids.length; i++) {\n // If we already have it, don't add again\n if (id === ids[i]) {\n return;\n }\n }\n ids.push(id);\n }\n }\n\n deleteID(id: string): void {\n const self = this.getWritable();\n if ($isThreadMarkNode(self)) {\n const ids = self.__ids;\n self.__ids = ids;\n for (let i = 0; i < ids.length; i++) {\n if (id === ids[i]) {\n ids.splice(i, 1);\n return;\n }\n }\n }\n }\n\n insertNewAfter(\n _: RangeSelection,\n restoreSelection = true\n ): null | ElementNode {\n const markNode = $createThreadMarkNode(this.__ids);\n this.insertAfter(markNode, restoreSelection);\n return markNode;\n }\n\n canInsertTextBefore(): false {\n return false;\n }\n\n canInsertTextAfter(): false {\n return false;\n }\n\n canBeEmpty(): false {\n return false;\n }\n\n isInline(): true {\n return true;\n }\n\n extractWithChild(\n _: LexicalNode,\n selection: BaseSelection,\n destination: \"clone\" | \"html\"\n ): boolean {\n if (!$isRangeSelection(selection) || destination === \"html\") {\n return false;\n }\n const anchor = selection.anchor;\n const focus = selection.focus;\n const anchorNode = anchor.getNode();\n const focusNode = focus.getNode();\n const isBackward = selection.isBackward();\n const selectionLength = isBackward\n ? anchor.offset - focus.offset\n : focus.offset - anchor.offset;\n return (\n this.isParentOf(anchorNode) &&\n this.isParentOf(focusNode) &&\n this.getTextContent().length === selectionLength\n );\n }\n\n excludeFromCopy(destination: \"clone\" | \"html\"): boolean {\n return destination !== \"clone\";\n }\n}\n\nexport function $createThreadMarkNode(ids: Array<string>): ThreadMarkNode {\n return $applyNodeReplacement(new ThreadMarkNode(ids));\n}\n\nexport function $isThreadMarkNode(\n node: LexicalNode | null\n): node is ThreadMarkNode {\n return node instanceof ThreadMarkNode;\n}\n"],"names":[],"mappings":";;AAiBO,MAAM,uBAAuB,WAAY,CAAA;AAAA,
|
|
1
|
+
{"version":3,"file":"thread-mark-node.mjs","sources":["../../src/comments/thread-mark-node.ts"],"sourcesContent":["import type {\n BaseSelection,\n LexicalNode,\n NodeKey,\n RangeSelection,\n SerializedElementNode,\n Spread,\n} from \"lexical\";\nimport { $applyNodeReplacement, $isRangeSelection, ElementNode } from \"lexical\";\n\nexport type SerializedThreadMarkNode = Spread<\n {\n ids: Array<string>;\n },\n SerializedElementNode\n>;\n\nexport class ThreadMarkNode extends ElementNode {\n /** @internal */\n __ids: Array<string>; // The ids of the threads that this mark is associated with\n\n static getType(): string {\n return \"lb-thread-mark\";\n }\n\n static clone(node: ThreadMarkNode): ThreadMarkNode {\n return new ThreadMarkNode(Array.from(node.__ids), node.__key);\n }\n\n static importDOM(): null {\n return null;\n }\n\n static importJSON(serializedNode: SerializedThreadMarkNode): ThreadMarkNode {\n const node = $createThreadMarkNode(serializedNode.ids);\n node.setFormat(serializedNode.format);\n node.setIndent(serializedNode.indent);\n node.setDirection(serializedNode.direction);\n return node;\n }\n\n exportJSON(): SerializedThreadMarkNode {\n return {\n ...super.exportJSON(),\n ids: this.getIDs(),\n type: \"lb-thread-mark\",\n version: 1,\n };\n }\n\n constructor(ids: Array<string>, key?: NodeKey) {\n super(key);\n this.__ids = ids || [];\n }\n\n createDOM(): HTMLElement {\n const element = document.createElement(\"span\");\n return element;\n }\n\n updateDOM(): boolean {\n return false;\n }\n\n hasID(id: string): boolean {\n const ids = this.getIDs();\n for (let i = 0; i < ids.length; i++) {\n if (id === ids[i]) {\n return true;\n }\n }\n return false;\n }\n\n getIDs(): Array<string> {\n const self = this.getLatest();\n return $isThreadMarkNode(self) ? self.__ids : [];\n }\n\n addID(id: string): void {\n const self = this.getWritable();\n if ($isThreadMarkNode(self)) {\n const ids = self.__ids;\n self.__ids = ids;\n for (let i = 0; i < ids.length; i++) {\n // If we already have it, don't add again\n if (id === ids[i]) {\n return;\n }\n }\n ids.push(id);\n }\n }\n\n deleteID(id: string): void {\n const self = this.getWritable();\n if ($isThreadMarkNode(self)) {\n const ids = self.__ids;\n self.__ids = ids;\n for (let i = 0; i < ids.length; i++) {\n if (id === ids[i]) {\n ids.splice(i, 1);\n return;\n }\n }\n }\n }\n\n insertNewAfter(\n _: RangeSelection,\n restoreSelection = true\n ): null | ElementNode {\n const markNode = $createThreadMarkNode(this.__ids);\n this.insertAfter(markNode, restoreSelection);\n return markNode;\n }\n\n canInsertTextBefore(): false {\n return false;\n }\n\n canInsertTextAfter(): false {\n return false;\n }\n\n canBeEmpty(): false {\n return false;\n }\n\n isInline(): true {\n return true;\n }\n\n extractWithChild(\n _: LexicalNode,\n selection: BaseSelection,\n destination: \"clone\" | \"html\"\n ): boolean {\n if (!$isRangeSelection(selection) || destination === \"html\") {\n return false;\n }\n const anchor = selection.anchor;\n const focus = selection.focus;\n const anchorNode = anchor.getNode();\n const focusNode = focus.getNode();\n const isBackward = selection.isBackward();\n const selectionLength = isBackward\n ? anchor.offset - focus.offset\n : focus.offset - anchor.offset;\n return (\n this.isParentOf(anchorNode) &&\n this.isParentOf(focusNode) &&\n this.getTextContent().length === selectionLength\n );\n }\n\n excludeFromCopy(destination: \"clone\" | \"html\"): boolean {\n return destination !== \"clone\";\n }\n}\n\nexport function $createThreadMarkNode(ids: Array<string>): ThreadMarkNode {\n return $applyNodeReplacement(new ThreadMarkNode(ids));\n}\n\nexport function $isThreadMarkNode(\n node: LexicalNode | null\n): node is ThreadMarkNode {\n return node instanceof ThreadMarkNode;\n}\n"],"names":[],"mappings":";;AAiBO,MAAM,uBAAuB,WAAY,CAAA;AAAA,EAE9C,KAAA,CAAA;AAAA,EAEA,OAAO,OAAkB,GAAA;AACvB,IAAO,OAAA,gBAAA,CAAA;AAAA,GACT;AAAA,EAEA,OAAO,MAA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AA,CAAK,UAAW,CAAA,UAAU,CAC1B,IAAA,IAAA,CAAK,UAAW,CAAA,SAAS,CACzB,IAAA,IAAA,CAAK,cAAe,EAAA,CAAE,MAAW,KAAA,eAAA,CAAA;AAAA,GAErC;AAAA,EAEA,gBAAgB,WAAwC,EAAA;AACtD,IAAA,OAAO,WAAgB,KAAA,OAAA,CAAA;AAAA,GACzB;AACF,CAAA;AAEO,SAAS,sBAAsB,GAAoC,EAAA;AACxE,EAAA,OAAO,qBAAsB,CAAA,IAAI,cAAe,CAAA,GAAG,CAAC,CAAA,CAAA;AACtD,CAAA;AAEO,SAAS,kBACd,IACwB,EAAA;AACxB,EAAA,OAAO,IAAgB,YAAA,cAAA,CAAA;AACzB;;;;"}
|
|
@@ -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);\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,
|
|
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);\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,C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A,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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mention-node.mjs","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);\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,
|
|
1
|
+
{"version":3,"file":"mention-node.mjs","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);\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,C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
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const PKG_NAME = "@liveblocks/react-lexical";
|
|
4
|
-
const PKG_VERSION = typeof "2.15.0
|
|
4
|
+
const PKG_VERSION = typeof "2.15.0" === "string" && "2.15.0";
|
|
5
5
|
const PKG_FORMAT = typeof "cjs" === "string" && "cjs";
|
|
6
6
|
|
|
7
7
|
exports.PKG_FORMAT = PKG_FORMAT;
|
package/dist/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sources":["../src/version.ts"],"sourcesContent":["declare const __VERSION__: string;\ndeclare const ROLLUP_FORMAT: string;\n\nexport const PKG_NAME = \"@liveblocks/react-lexical\";\nexport const PKG_VERSION = typeof __VERSION__ === \"string\" && __VERSION__;\nexport const PKG_FORMAT = typeof ROLLUP_FORMAT === \"string\" && ROLLUP_FORMAT;\n"],"names":[],"mappings":";;AAGO,MAAM,QAAW,GAAA,4BAAA;AACX,MAAA,WAAA,GAAc,OAAO,
|
|
1
|
+
{"version":3,"file":"version.js","sources":["../src/version.ts"],"sourcesContent":["declare const __VERSION__: string;\ndeclare const ROLLUP_FORMAT: string;\n\nexport const PKG_NAME = \"@liveblocks/react-lexical\";\nexport const PKG_VERSION = typeof __VERSION__ === \"string\" && __VERSION__;\nexport const PKG_FORMAT = typeof ROLLUP_FORMAT === \"string\" && ROLLUP_FORMAT;\n"],"names":[],"mappings":";;AAGO,MAAM,QAAW,GAAA,4BAAA;AACX,MAAA,WAAA,GAAc,OAAO,QAAA,KAAgB,QAAY,IAAA,SAAA;AACjD,MAAA,UAAA,GAAa,OAAO,KAAA,KAAkB,QAAY,IAAA;;;;;;"}
|
package/dist/version.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const PKG_NAME = "@liveblocks/react-lexical";
|
|
2
|
-
const PKG_VERSION = typeof "2.15.0
|
|
2
|
+
const PKG_VERSION = typeof "2.15.0" === "string" && "2.15.0";
|
|
3
3
|
const PKG_FORMAT = typeof "esm" === "string" && "esm";
|
|
4
4
|
|
|
5
5
|
export { PKG_FORMAT, PKG_NAME, PKG_VERSION };
|
package/dist/version.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.mjs","sources":["../src/version.ts"],"sourcesContent":["declare const __VERSION__: string;\ndeclare const ROLLUP_FORMAT: string;\n\nexport const PKG_NAME = \"@liveblocks/react-lexical\";\nexport const PKG_VERSION = typeof __VERSION__ === \"string\" && __VERSION__;\nexport const PKG_FORMAT = typeof ROLLUP_FORMAT === \"string\" && ROLLUP_FORMAT;\n"],"names":[],"mappings":"AAGO,MAAM,QAAW,GAAA,4BAAA;AACX,MAAA,WAAA,GAAc,OAAO,
|
|
1
|
+
{"version":3,"file":"version.mjs","sources":["../src/version.ts"],"sourcesContent":["declare const __VERSION__: string;\ndeclare const ROLLUP_FORMAT: string;\n\nexport const PKG_NAME = \"@liveblocks/react-lexical\";\nexport const PKG_VERSION = typeof __VERSION__ === \"string\" && __VERSION__;\nexport const PKG_FORMAT = typeof ROLLUP_FORMAT === \"string\" && ROLLUP_FORMAT;\n"],"names":[],"mappings":"AAGO,MAAM,QAAW,GAAA,4BAAA;AACX,MAAA,WAAA,GAAc,OAAO,QAAA,KAAgB,QAAY,IAAA,SAAA;AACjD,MAAA,UAAA,GAAa,OAAO,KAAA,KAAkB,QAAY,IAAA;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@liveblocks/react-lexical",
|
|
3
|
-
"version": "2.15.0
|
|
3
|
+
"version": "2.15.0",
|
|
4
4
|
"description": "A lexical react plugin to enable collaboration, comments, live cursors, and more.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "commonjs",
|
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
"README.md"
|
|
32
32
|
],
|
|
33
33
|
"scripts": {
|
|
34
|
-
"dev": "rollup --config rollup.config.
|
|
35
|
-
"build": "rollup --config rollup.config.
|
|
34
|
+
"dev": "rollup --config rollup.config.mjs --watch",
|
|
35
|
+
"build": "rollup --config rollup.config.mjs",
|
|
36
36
|
"format": "eslint --fix src/; stylelint --fix src/styles/; prettier --write src/",
|
|
37
37
|
"lint": "eslint src/; stylelint src/styles/",
|
|
38
38
|
"lint:package": "publint --strict && attw --pack",
|
|
@@ -42,11 +42,11 @@
|
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
44
|
"@floating-ui/react-dom": "^2.1.1",
|
|
45
|
-
"@liveblocks/client": "2.15.0
|
|
46
|
-
"@liveblocks/core": "2.15.0
|
|
47
|
-
"@liveblocks/react": "2.15.0
|
|
48
|
-
"@liveblocks/react-ui": "2.15.0
|
|
49
|
-
"@liveblocks/yjs": "2.15.0
|
|
45
|
+
"@liveblocks/client": "2.15.0",
|
|
46
|
+
"@liveblocks/core": "2.15.0",
|
|
47
|
+
"@liveblocks/react": "2.15.0",
|
|
48
|
+
"@liveblocks/react-ui": "2.15.0",
|
|
49
|
+
"@liveblocks/yjs": "2.15.0",
|
|
50
50
|
"yjs": "^13.6.18"
|
|
51
51
|
},
|
|
52
52
|
"peerDependencies": {
|
|
@@ -60,17 +60,12 @@
|
|
|
60
60
|
"devDependencies": {
|
|
61
61
|
"@liveblocks/eslint-config": "*",
|
|
62
62
|
"@liveblocks/jest-config": "*",
|
|
63
|
-
"@rollup
|
|
64
|
-
"@rollup/plugin-replace": "^5.0.5",
|
|
65
|
-
"@rollup/plugin-typescript": "^11.1.2",
|
|
63
|
+
"@liveblocks/rollup-config": "*",
|
|
66
64
|
"@testing-library/jest-dom": "^5.16.5",
|
|
67
65
|
"eslint-plugin-react": "^7.33.2",
|
|
68
66
|
"eslint-plugin-react-hooks": "^4.6.0",
|
|
69
67
|
"msw": "^0.27.1",
|
|
70
|
-
"rollup": "
|
|
71
|
-
"rollup-plugin-dts": "^5.3.1",
|
|
72
|
-
"rollup-plugin-esbuild": "^5.0.0",
|
|
73
|
-
"rollup-plugin-preserve-directives": "^0.2.0",
|
|
68
|
+
"rollup": "3.28.0",
|
|
74
69
|
"stylelint": "^15.10.2",
|
|
75
70
|
"stylelint-config-standard": "^34.0.0",
|
|
76
71
|
"stylelint-order": "^6.0.3",
|