@liveblocks/node-lexical 3.6.0 → 3.7.0-preview1
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/index.cjs +61 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +66 -9
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -68,9 +68,66 @@ function createNoOpProvider() {
|
|
|
68
68
|
};
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
+
// src/GroupMentionNodeLite.ts
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
var GroupMentionNode = class _GroupMentionNode extends _lexical.DecoratorNode {
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
constructor(id, groupId, userIds, key) {
|
|
79
|
+
super(key);
|
|
80
|
+
this.__id = id;
|
|
81
|
+
this.__groupId = groupId;
|
|
82
|
+
this.__userIds = userIds;
|
|
83
|
+
}
|
|
84
|
+
static getType() {
|
|
85
|
+
return "lb-group-mention";
|
|
86
|
+
}
|
|
87
|
+
static clone(node) {
|
|
88
|
+
return new _GroupMentionNode(node.__id, node.__groupId, node.__userIds);
|
|
89
|
+
}
|
|
90
|
+
static importJSON(serializedNode) {
|
|
91
|
+
const node = new _GroupMentionNode(
|
|
92
|
+
serializedNode.id,
|
|
93
|
+
serializedNode.groupId,
|
|
94
|
+
serializedNode.userIds
|
|
95
|
+
);
|
|
96
|
+
return _lexical.$applyNodeReplacement.call(void 0, node);
|
|
97
|
+
}
|
|
98
|
+
exportJSON() {
|
|
99
|
+
return {
|
|
100
|
+
id: this.getId(),
|
|
101
|
+
groupId: this.getGroupId(),
|
|
102
|
+
userIds: this.getUserIds(),
|
|
103
|
+
type: "lb-group-mention",
|
|
104
|
+
version: 1
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
getId() {
|
|
108
|
+
const self = this.getLatest();
|
|
109
|
+
return self.__id;
|
|
110
|
+
}
|
|
111
|
+
getGroupId() {
|
|
112
|
+
const self = this.getLatest();
|
|
113
|
+
return self.__groupId;
|
|
114
|
+
}
|
|
115
|
+
getUserIds() {
|
|
116
|
+
const self = this.getLatest();
|
|
117
|
+
return self.__userIds;
|
|
118
|
+
}
|
|
119
|
+
getTextContent() {
|
|
120
|
+
const groupId = this.getGroupId();
|
|
121
|
+
return _core.MENTION_CHARACTER + groupId;
|
|
122
|
+
}
|
|
123
|
+
decorate() {
|
|
124
|
+
return null;
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
|
|
71
128
|
// src/MentionNodeLite.ts
|
|
72
129
|
|
|
73
|
-
|
|
130
|
+
|
|
74
131
|
var MentionNode = class _MentionNode extends _lexical.DecoratorNode {
|
|
75
132
|
|
|
76
133
|
|
|
@@ -111,7 +168,7 @@ var MentionNode = class _MentionNode extends _lexical.DecoratorNode {
|
|
|
111
168
|
getTextContent() {
|
|
112
169
|
const userId = this.getUserId();
|
|
113
170
|
if (userId) {
|
|
114
|
-
return MENTION_CHARACTER + userId;
|
|
171
|
+
return _core.MENTION_CHARACTER + userId;
|
|
115
172
|
}
|
|
116
173
|
return this.getId();
|
|
117
174
|
}
|
|
@@ -188,13 +245,13 @@ var ThreadMarkNode = class _ThreadMarkNode extends _lexical.ElementNode {
|
|
|
188
245
|
|
|
189
246
|
// src/version.ts
|
|
190
247
|
var PKG_NAME = "@liveblocks/node-lexical";
|
|
191
|
-
var PKG_VERSION = "3.
|
|
248
|
+
var PKG_VERSION = "3.7.0-preview1";
|
|
192
249
|
var PKG_FORMAT = "cjs";
|
|
193
250
|
|
|
194
251
|
// src/index.ts
|
|
195
252
|
|
|
196
253
|
_core.detectDupes.call(void 0, PKG_NAME, PKG_VERSION, PKG_FORMAT);
|
|
197
|
-
var LIVEBLOCKS_NODES = [ThreadMarkNode, MentionNode];
|
|
254
|
+
var LIVEBLOCKS_NODES = [ThreadMarkNode, MentionNode, GroupMentionNode];
|
|
198
255
|
async function withLexicalDocument({ roomId, nodes, client }, callback) {
|
|
199
256
|
const update = new Uint8Array(
|
|
200
257
|
await client.getYjsDocumentAsBinaryUpdate(roomId)
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/liveblocks/liveblocks/packages/liveblocks-node-lexical/dist/index.cjs","../src/index.ts","../src/collab.ts","../src/MentionNodeLite.ts","../src/ThreadNodeLite.ts","../src/version.ts"],"names":["$applyNodeReplacement","createHeadlessEditor","Doc","createBinding"],"mappings":"AAAA;ACAA,6CAAqC;AACrC,6CAAuD;AACvD,mCAA8B;AAC9B,wCAA4B;AAW5B,kCAAyB;AACzB,2BAAyE;ADRzE;AACA;AERA;AAEA;AACE;AACA;AACA;AAAA;AASF;AAyBO,SAAS,8BAAA,CACd,MAAA,EACA,QAAA,EACA,OAAA,EACY;AACZ,EAAA,MAAM,0BAAA,EAA4B,MAAA,CAAO,sBAAA;AAAA,IACvC,CAAC;AAAA,MACC,aAAA;AAAA,MACA,WAAA;AAAA,MACA,WAAA;AAAA,MACA,eAAA;AAAA,MACA,eAAA;AAAA,MACA;AAAA,IACF,CAAA,EAAA,GAAM;AACJ,MAAA,GAAA,CAAI,IAAA,CAAK,GAAA,CAAI,aAAa,EAAA,IAAM,KAAA,EAAO;AACrC,QAAA,yCAAA;AAAA,UACE,OAAA;AAAA,UACA,QAAA;AAAA,UACA,eAAA;AAAA,UACA,WAAA;AAAA,UACA,aAAA;AAAA,UACA,WAAA;AAAA,UACA,eAAA;AAAA,UACA;AAAA,QACF,CAAA;AAAA,MACF;AAAA,IACF;AAAA,EACF,CAAA;AAGA,EAAA,MAAM,SAAA,EAAW,CAAC,MAAA,EAA4B,WAAA,EAAA,GAA6B;AACzE,IAAA,GAAA,CAAI,WAAA,CAAY,OAAA,IAAW,OAAA,EAAS;AAElC,MAAA,0CAAA,OAAwB,EAAS,QAAA,EAAU,MAAA,EAAQ,KAAK,CAAA;AAAA,IAC1D;AAAA,EACF,CAAA;AAE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AAO,CAAA;AAAA,IACxC,CAAA;AAAA;AAAA;AAAA;AAAA,IAIA,UAAA,EAAY,CAAA,EAAA,GAAM;AAChB,MAAA,IAAI,SAAA,EAAmB,EAAA;AACvB,MAAA,MAAA,CAAO,cAAA,CAAe,CAAA,CAAE,IAAA,CAAK,CAAA,EAAA,GAAM;AACjC,QAAA,SAAA,EAAW,gDAAA,sBAAqC,CAAA;AAAA,MAClD,CAAC,CAAA;AACD,MAAA,OAAO,QAAA;AAAA,IACT,CAAA;AAAA;AAAA;AAAA;AAAA,IAIA,cAAA,EAAgB,CAAA,EAAA,GAAM;AACpB,MAAA,OAAO,MAAA,CAAO,cAAA,CAAe,CAAA;AAAA,IAC/B,CAAA;AAAA;AAAA;AAAA;AAAA,IAIA,gBAAA,EAAkB,CAAA,EAAA,GAAM;AACtB,MAAA,OAAO,MAAA;AAAA,IACT;AAAA,EACF,CAAC,CAAA;AACD,EAAA,WAAA,CAAY,CAAA;AAEZ,EAAA,OAAO,GAAA;AACT;ADwHA;AACE;AACA;AACA;AACA;AACF,0MAAC","file":"/home/runner/work/liveblocks/liveblocks/packages/liveblocks-node-lexical/dist/index.cjs","sourcesContent":[null,"import { createHeadlessEditor } from \"@lexical/headless\";\nimport { $convertToMarkdownString, TRANSFORMERS } from \"@lexical/markdown\";\nimport { createBinding } from \"@lexical/yjs\";\nimport { detectDupes } from \"@liveblocks/core\";\nimport type { Liveblocks } from \"@liveblocks/node\";\nimport type {\n EditorState,\n Klass,\n LexicalEditor,\n LexicalNode,\n LexicalNodeReplacement,\n SerializedEditorState,\n SerializedLexicalNode,\n} from \"lexical\";\nimport { $getRoot } from \"lexical\";\nimport { applyUpdate, Doc, encodeStateAsUpdate, encodeStateVector } from \"yjs\";\n\nimport { createNoOpProvider, registerCollaborationListeners } from \"./collab\";\nimport { MentionNode } from \"./MentionNodeLite\";\nimport { ThreadMarkNode } from \"./ThreadNodeLite\";\nimport { PKG_FORMAT, PKG_NAME, PKG_VERSION } from \"./version\";\n\ndetectDupes(PKG_NAME, PKG_VERSION, PKG_FORMAT);\n\nconst LIVEBLOCKS_NODES = [ThreadMarkNode, MentionNode];\n\nexport { $createParagraphNode, $createTextNode, $getRoot } from \"lexical\";\n\nexport type LiveblocksLexicalOptions = {\n roomId: string;\n nodes?: ReadonlyArray<Klass<LexicalNode> | LexicalNodeReplacement>;\n client: Liveblocks;\n};\n\nexport type LiveblocksDocumentApi = {\n refresh: () => Promise<void>;\n update: (modifyFn: () => void) => Promise<void>;\n getTextContent: () => string;\n getEditorState: () => EditorState;\n getLexicalEditor: () => LexicalEditor;\n toJSON: () => SerializedEditorState<SerializedLexicalNode>;\n toMarkdown: () => string;\n};\n\n/**\n *\n * `withLexicalDocument` is the main entry point to access and modify Lexical documents on your backend.\n * This function internally instantiates a Lexical headless editor and allows you to modify and export its values asynchronously\n * with a simplified interface.\n *\n * @param options Specify the roomId, client, and nodes.\n * @param callback The call back function is optionally async and receives the document API as its only argument.\n *\n * @example\n *\n * import { Liveblocks } from \"@liveblocks/node\";\n * import { withLexicalDocument } from \"@liveblocks/node-lexical\";\n *\n * const client = new Liveblocks({secret: \"sk_your_secret_key\"});\n * const text = await withLexicalDocument(\n * { client, roomId: \"your-room\" },\n * async (doc) => {\n * await doc.update(() => {\n * const root = $getRoot();\n * const paragraphNode = $createParagraphNode();\n * const textNode = $createTextNode(\"Hello from node\");\n * paragraphNode.append(textNode);\n * root.append(paragraphNode);\n * });\n * return doc.getTextContent();\n * }\n * );\n *\n */\nexport async function withLexicalDocument<T>(\n { roomId, nodes, client }: LiveblocksLexicalOptions,\n callback: (api: LiveblocksDocumentApi) => Promise<T> | T\n): Promise<T> {\n const update = new Uint8Array(\n await client.getYjsDocumentAsBinaryUpdate(roomId)\n );\n const editor = createHeadlessEditor({\n nodes: [...LIVEBLOCKS_NODES, ...(nodes ?? [])],\n });\n const id = \"root\";\n const doc = new Doc();\n const docMap = new Map([[id, doc]]);\n const provider = createNoOpProvider();\n const binding = createBinding(editor, provider, id, doc, docMap);\n const unsubscribe = registerCollaborationListeners(editor, provider, binding);\n applyUpdate(binding.doc, update);\n editor.update(() => {}, { discrete: true });\n\n const val = await callback({\n /**\n * Fetches and resyncs the latest document with Liveblocks\n */\n refresh: async () => {\n const latest = new Uint8Array(\n await client.getYjsDocumentAsBinaryUpdate(roomId)\n );\n applyUpdate(binding.doc, latest);\n editor.update(() => {}, { discrete: true });\n },\n /**\n * Provide a callback to modify documetns with Lexical's standard api. All calls are discrete.\n */\n update: async (modifyFn) => {\n // Flush any pending updates (there really shouldn't be any?), this may be a NOOP\n editor.update(() => {}, { discrete: true });\n const beforeVector = encodeStateVector(binding.doc);\n editor.update(\n () => {\n modifyFn();\n },\n { discrete: true }\n );\n // grab update after diffing\n const diffUpdate = encodeStateAsUpdate(binding.doc, beforeVector);\n return client.sendYjsBinaryUpdate(roomId, diffUpdate);\n },\n /**\n * Helper function to easily provide the text content from the root, i.e. `$getRoot().getTextContent()`\n */\n getTextContent: () => {\n let content = \"\";\n editor.getEditorState().read(() => {\n content = $getRoot().getTextContent();\n });\n return content;\n },\n /**\n * Helper function to return editorState in JSON form\n */\n toJSON: () => {\n return editor.getEditorState().toJSON();\n },\n /**\n * Helper function to return editor state as Markdown\n */\n toMarkdown: () => {\n let markdown: string = \"\";\n editor.getEditorState().read(() => {\n markdown = $convertToMarkdownString(TRANSFORMERS);\n });\n return markdown;\n },\n /**\n * Helper function to return the editor's current state\n */\n getEditorState: () => {\n return editor.getEditorState();\n },\n /**\n * Helper function to return the current headless editor instance\n */\n getLexicalEditor: () => {\n return editor;\n },\n });\n unsubscribe();\n\n return val;\n}\n","import { createHeadlessEditor } from \"@lexical/headless\";\nimport type { Binding, Provider } from \"@lexical/yjs\";\nimport {\n createBinding,\n syncLexicalUpdateToYjs,\n syncYjsChangesToLexical,\n} from \"@lexical/yjs\";\nimport type {\n Klass,\n LexicalEditor,\n LexicalNode,\n LexicalNodeReplacement,\n} from \"lexical\";\nimport type { Transaction, YEvent } from \"yjs\";\nimport { Doc } from \"yjs\";\n\nexport function withHeadlessCollaborationEditor<T>(\n nodes: ReadonlyArray<Klass<LexicalNode> | LexicalNodeReplacement>,\n callback: (editor: LexicalEditor, binding: Binding, provider: Provider) => T\n): T {\n const editor = createHeadlessEditor({\n nodes,\n });\n\n const id = \"root\";\n const doc = new Doc();\n const docMap = new Map([[id, doc]]);\n const provider = createNoOpProvider();\n const binding = createBinding(editor, provider, id, doc, docMap);\n\n const unsubscribe = registerCollaborationListeners(editor, provider, binding);\n\n const res = callback(editor, binding, provider);\n\n unsubscribe();\n\n return res;\n}\n\nexport function registerCollaborationListeners(\n editor: LexicalEditor,\n provider: Provider,\n binding: Binding\n): () => void {\n const unsubscribeUpdateListener = editor.registerUpdateListener(\n ({\n dirtyElements,\n dirtyLeaves,\n editorState,\n normalizedNodes,\n prevEditorState,\n tags,\n }) => {\n if (tags.has(\"skip-collab\") === false) {\n syncLexicalUpdateToYjs(\n binding,\n provider,\n prevEditorState,\n editorState,\n dirtyElements,\n dirtyLeaves,\n normalizedNodes,\n tags\n );\n }\n }\n );\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const observer = (events: Array<YEvent<any>>, transaction: Transaction) => {\n if (transaction.origin !== binding) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n syncYjsChangesToLexical(binding, provider, events, false);\n }\n };\n\n binding.root.getSharedType().observeDeep(observer);\n\n return () => {\n unsubscribeUpdateListener();\n binding.root.getSharedType().unobserveDeep(observer);\n };\n}\n\nexport function createNoOpProvider(): Provider {\n const emptyFunction = () => {};\n\n return {\n awareness: {\n getLocalState: () => null,\n setLocalStateField: emptyFunction,\n getStates: () => new Map(),\n off: emptyFunction,\n on: emptyFunction,\n setLocalState: emptyFunction,\n },\n connect: emptyFunction,\n disconnect: emptyFunction,\n off: emptyFunction,\n on: emptyFunction,\n };\n}\n","import type { NodeKey, SerializedLexicalNode, Spread } from \"lexical\";\nimport { $applyNodeReplacement, DecoratorNode } from \"lexical\";\n\nconst MENTION_CHARACTER = \"@\";\n\ntype LegacySerializedMentionNode = Spread<\n {\n // Legacy field now named `id`\n value: string;\n // Not present in legacy nodes\n userId: never;\n },\n SerializedLexicalNode\n>;\n\nexport type SerializedMentionNode = Spread<\n {\n id: string;\n userId: string | undefined;\n },\n SerializedLexicalNode\n>;\n\nexport class MentionNode extends DecoratorNode<null> {\n __id: string;\n __userId: string | undefined;\n\n constructor(id: string, userId: string | undefined, 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 static importJSON(\n serializedNode: SerializedMentionNode | LegacySerializedMentionNode\n ): MentionNode {\n const node = new MentionNode(\n (serializedNode as LegacySerializedMentionNode).value ??\n (serializedNode as SerializedMentionNode).id,\n (serializedNode as SerializedMentionNode).userId\n );\n return $applyNodeReplacement(node);\n }\n\n exportJSON(): SerializedMentionNode {\n return {\n id: this.getId(),\n userId: this.getUserId(),\n type: \"lb-mention\",\n version: 1,\n };\n }\n\n getId(): string {\n const self = this.getLatest();\n return self.__id;\n }\n\n getUserId(): string | undefined {\n const self = this.getLatest();\n return self.__userId;\n }\n\n getTextContent(): string {\n const userId = this.getUserId();\n\n if (userId) {\n return MENTION_CHARACTER + userId;\n }\n\n // Legacy behavior: return the ID as text content\n // Since the ID is an inbox notification ID (\"in_xxx\") and not a user ID, this isn't ideal\n return this.getId();\n }\n\n decorate(): null {\n return null;\n }\n}\n","import type {\n BaseSelection,\n LexicalNode,\n NodeKey,\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 importJSON(serializedNode: SerializedThreadMarkNode): ThreadMarkNode {\n const node = $applyNodeReplacement<ThreadMarkNode>(\n new ThreadMarkNode(serializedNode.ids)\n );\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 getIDs(): Array<string> {\n const self = this.getLatest();\n return self instanceof ThreadMarkNode ? self.__ids : [];\n }\n\n constructor(ids: Array<string>, key?: NodeKey) {\n super(key);\n this.__ids = ids || [];\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","declare const __VERSION__: string;\ndeclare const TSUP_FORMAT: string;\n\nexport const PKG_NAME = \"@liveblocks/node-lexical\";\nexport const PKG_VERSION = typeof __VERSION__ === \"string\" && __VERSION__;\nexport const PKG_FORMAT = typeof TSUP_FORMAT === \"string\" && TSUP_FORMAT;\n"]}
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/liveblocks/liveblocks/packages/liveblocks-node-lexical/dist/index.cjs","../src/index.ts","../src/collab.ts","../src/GroupMentionNodeLite.ts","../src/MentionNodeLite.ts","../src/ThreadNodeLite.ts","../src/version.ts"],"names":["DecoratorNode","$applyNodeReplacement","MENTION_CHARACTER","createHeadlessEditor","Doc","createBinding"],"mappings":"AAAA;ACAA,6CAAqC;AACrC,6CAAuD;AACvD,mCAA8B;AAC9B,wCAA4B;AAW5B,kCAAyB;AACzB,2BAAyE;ADRzE;AACA;AERA;AAEA;AACE;AACA;AACA;AAAA;AASF;AAyBO,SAAS,8BAAA,CACd,MAAA,EACA,QAAA,EACA,OAAA,EACY;AACZ,EAAA,MAAM,0BAAA,EAA4B,MAAA,CAAO,sBAAA;AAAA,IACvC,CAAC;AAAA,MACC,aAAA;AAAA,MACA,WAAA;AAAA,MACA,WAAA;AAAA,MACA,eAAA;AAAA,MACA,eAAA;AAAA,MACA;AAAA,IACF,CAAA,EAAA,GAAM;AACJ,MAAA,GAAA,CAAI,IAAA,CAAK,GAAA,CAAI,aAAa,EAAA,IAAM,KAAA,EAAO;AACrC,QAAA,yCAAA;AAAA,UACE,OAAA;AAAA,UACA,QAAA;AAAA,UACA,eAAA;AAAA,UACA,WAAA;AAAA,UACA,aAAA;AAAA,UACA,WAAA;AAAA,UACA,eAAA;AAAA,UACA;AAAA,QACF,CAAA;AAAA,MACF;AAAA,IACF;AAAA,EACF,CAAA;AAGA,EAAA,MAAM,SAAA,EAAW,CAAC,MAAA,EAA4B,WAAA,EAAA,GAA6B;AACzE,IAAA,GAAA,CAAI,WAAA,CAAY,OAAA,IAAW,OAAA,EAAS;AAElC,MAAA,0CAAA,OAAwB,EAAS,QAAA,EAAU,MAAA,EAAQ,KAAK,CAAA;AAAA,IAC1D;AAAA,EACF,CAAA;AAEA,EAAA,OAAA,CAAQ,IAAA,CAAK,aAAA,CAAc,CAAA,CAAE,WAAA,CAAY,QAAQ,CAAA;AAEjD,EAAA,OAAO,CAAA,EAAA,GAAM;AAC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,cAAA,EAAgB,CAAA,EAAA,GAAM;AACpB,MAAA,IAAI,QAAA,EAAU,EAAA;AACd,MAAA,MAAA,CAAO,cAAA,CAAe,CAAA,CAAE,IAAA,CAAK,CAAA,EAAA,GAAM;AACjC,QAAA,QAAA,EAAU,+BAAA,CAAS,CAAE,cAAA,CAAe,CAAA;AAAA,MACtC,CAAC,CAAA;AACD,MAAA,OAAO,OAAA;AAAA,IACT,CAAA;AAAA;AAAA;AAAA;AAAA,IAIA,MAAA,EAAQ,CAAA,EAAA,GAAM;AACZ,MAAA,OAAO,MAAA,CAAO,cAAA,CAAe,CAAA,CAAE,MAAA,CAAO,CAAA;AAAA,IACxC,CAAA;AAAA;AAAA;AAAA;AAAA,IAIA,UAAA,EAAY,CAAA,EAAA,GAAM;AAChB,MAAA,IAAI,SAAA,EAAmB,EAAA;AACvB,MAAA,MAAA,CAAO,cAAA,CAAe,CAAA,CAAE,IAAA,CAAK,CAAA,EAAA,GAAM;AACjC,QAAA,SAAA,EAAW,gDAAA,sBAAqC,CAAA;AAAA,MAClD,CAAC,CAAA;AACD,MAAA,OAAO,QAAA;AAAA,IACT,CAAA;AAAA;AAAA;AAAA;AAAA,IAIA,cAAA,EAAgB,CAAA,EAAA,GAAM;AACpB,MAAA,OAAO,MAAA,CAAO,cAAA,CAAe,CAAA;AAAA,IAC/B,CAAA;AAAA;AAAA;AAAA;AAAA,IAIA,gBAAA,EAAkB,CAAA,EAAA,GAAM;AACtB,MAAA,OAAO,MAAA;AAAA,IACT;AAAA,EACF,CAAC,CAAA;AACD,EAAA,WAAA,CAAY,CAAA;AAEZ,EAAA,OAAO,GAAA;AACT;ADgLA;AACE;AACA;AACA;AACA;AACF,0MAAC","file":"/home/runner/work/liveblocks/liveblocks/packages/liveblocks-node-lexical/dist/index.cjs","sourcesContent":[null,"import { createHeadlessEditor } from \"@lexical/headless\";\nimport { $convertToMarkdownString, TRANSFORMERS } from \"@lexical/markdown\";\nimport { createBinding } from \"@lexical/yjs\";\nimport { detectDupes } from \"@liveblocks/core\";\nimport type { Liveblocks } from \"@liveblocks/node\";\nimport type {\n EditorState,\n Klass,\n LexicalEditor,\n LexicalNode,\n LexicalNodeReplacement,\n SerializedEditorState,\n SerializedLexicalNode,\n} from \"lexical\";\nimport { $getRoot } from \"lexical\";\nimport { applyUpdate, Doc, encodeStateAsUpdate, encodeStateVector } from \"yjs\";\n\nimport { createNoOpProvider, registerCollaborationListeners } from \"./collab\";\nimport { GroupMentionNode } from \"./GroupMentionNodeLite\";\nimport { MentionNode } from \"./MentionNodeLite\";\nimport { ThreadMarkNode } from \"./ThreadNodeLite\";\nimport { PKG_FORMAT, PKG_NAME, PKG_VERSION } from \"./version\";\n\ndetectDupes(PKG_NAME, PKG_VERSION, PKG_FORMAT);\n\nconst LIVEBLOCKS_NODES = [ThreadMarkNode, MentionNode, GroupMentionNode];\n\nexport { $createParagraphNode, $createTextNode, $getRoot } from \"lexical\";\n\nexport type LiveblocksLexicalOptions = {\n roomId: string;\n nodes?: ReadonlyArray<Klass<LexicalNode> | LexicalNodeReplacement>;\n client: Liveblocks;\n};\n\nexport type LiveblocksDocumentApi = {\n refresh: () => Promise<void>;\n update: (modifyFn: () => void) => Promise<void>;\n getTextContent: () => string;\n getEditorState: () => EditorState;\n getLexicalEditor: () => LexicalEditor;\n toJSON: () => SerializedEditorState<SerializedLexicalNode>;\n toMarkdown: () => string;\n};\n\n/**\n *\n * `withLexicalDocument` is the main entry point to access and modify Lexical documents on your backend.\n * This function internally instantiates a Lexical headless editor and allows you to modify and export its values asynchronously\n * with a simplified interface.\n *\n * @param options Specify the roomId, client, and nodes.\n * @param callback The call back function is optionally async and receives the document API as its only argument.\n *\n * @example\n *\n * import { Liveblocks } from \"@liveblocks/node\";\n * import { withLexicalDocument } from \"@liveblocks/node-lexical\";\n *\n * const client = new Liveblocks({secret: \"sk_your_secret_key\"});\n * const text = await withLexicalDocument(\n * { client, roomId: \"your-room\" },\n * async (doc) => {\n * await doc.update(() => {\n * const root = $getRoot();\n * const paragraphNode = $createParagraphNode();\n * const textNode = $createTextNode(\"Hello from node\");\n * paragraphNode.append(textNode);\n * root.append(paragraphNode);\n * });\n * return doc.getTextContent();\n * }\n * );\n *\n */\nexport async function withLexicalDocument<T>(\n { roomId, nodes, client }: LiveblocksLexicalOptions,\n callback: (api: LiveblocksDocumentApi) => Promise<T> | T\n): Promise<T> {\n const update = new Uint8Array(\n await client.getYjsDocumentAsBinaryUpdate(roomId)\n );\n const editor = createHeadlessEditor({\n nodes: [...LIVEBLOCKS_NODES, ...(nodes ?? [])],\n });\n const id = \"root\";\n const doc = new Doc();\n const docMap = new Map([[id, doc]]);\n const provider = createNoOpProvider();\n const binding = createBinding(editor, provider, id, doc, docMap);\n const unsubscribe = registerCollaborationListeners(editor, provider, binding);\n applyUpdate(binding.doc, update);\n editor.update(() => {}, { discrete: true });\n\n const val = await callback({\n /**\n * Fetches and resyncs the latest document with Liveblocks\n */\n refresh: async () => {\n const latest = new Uint8Array(\n await client.getYjsDocumentAsBinaryUpdate(roomId)\n );\n applyUpdate(binding.doc, latest);\n editor.update(() => {}, { discrete: true });\n },\n /**\n * Provide a callback to modify documetns with Lexical's standard api. All calls are discrete.\n */\n update: async (modifyFn) => {\n // Flush any pending updates (there really shouldn't be any?), this may be a NOOP\n editor.update(() => {}, { discrete: true });\n const beforeVector = encodeStateVector(binding.doc);\n editor.update(\n () => {\n modifyFn();\n },\n { discrete: true }\n );\n // grab update after diffing\n const diffUpdate = encodeStateAsUpdate(binding.doc, beforeVector);\n return client.sendYjsBinaryUpdate(roomId, diffUpdate);\n },\n /**\n * Helper function to easily provide the text content from the root, i.e. `$getRoot().getTextContent()`\n */\n getTextContent: () => {\n let content = \"\";\n editor.getEditorState().read(() => {\n content = $getRoot().getTextContent();\n });\n return content;\n },\n /**\n * Helper function to return editorState in JSON form\n */\n toJSON: () => {\n return editor.getEditorState().toJSON();\n },\n /**\n * Helper function to return editor state as Markdown\n */\n toMarkdown: () => {\n let markdown: string = \"\";\n editor.getEditorState().read(() => {\n markdown = $convertToMarkdownString(TRANSFORMERS);\n });\n return markdown;\n },\n /**\n * Helper function to return the editor's current state\n */\n getEditorState: () => {\n return editor.getEditorState();\n },\n /**\n * Helper function to return the current headless editor instance\n */\n getLexicalEditor: () => {\n return editor;\n },\n });\n unsubscribe();\n\n return val;\n}\n","import { createHeadlessEditor } from \"@lexical/headless\";\nimport type { Binding, Provider } from \"@lexical/yjs\";\nimport {\n createBinding,\n syncLexicalUpdateToYjs,\n syncYjsChangesToLexical,\n} from \"@lexical/yjs\";\nimport type {\n Klass,\n LexicalEditor,\n LexicalNode,\n LexicalNodeReplacement,\n} from \"lexical\";\nimport type { Transaction, YEvent } from \"yjs\";\nimport { Doc } from \"yjs\";\n\nexport function withHeadlessCollaborationEditor<T>(\n nodes: ReadonlyArray<Klass<LexicalNode> | LexicalNodeReplacement>,\n callback: (editor: LexicalEditor, binding: Binding, provider: Provider) => T\n): T {\n const editor = createHeadlessEditor({\n nodes,\n });\n\n const id = \"root\";\n const doc = new Doc();\n const docMap = new Map([[id, doc]]);\n const provider = createNoOpProvider();\n const binding = createBinding(editor, provider, id, doc, docMap);\n\n const unsubscribe = registerCollaborationListeners(editor, provider, binding);\n\n const res = callback(editor, binding, provider);\n\n unsubscribe();\n\n return res;\n}\n\nexport function registerCollaborationListeners(\n editor: LexicalEditor,\n provider: Provider,\n binding: Binding\n): () => void {\n const unsubscribeUpdateListener = editor.registerUpdateListener(\n ({\n dirtyElements,\n dirtyLeaves,\n editorState,\n normalizedNodes,\n prevEditorState,\n tags,\n }) => {\n if (tags.has(\"skip-collab\") === false) {\n syncLexicalUpdateToYjs(\n binding,\n provider,\n prevEditorState,\n editorState,\n dirtyElements,\n dirtyLeaves,\n normalizedNodes,\n tags\n );\n }\n }\n );\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const observer = (events: Array<YEvent<any>>, transaction: Transaction) => {\n if (transaction.origin !== binding) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n syncYjsChangesToLexical(binding, provider, events, false);\n }\n };\n\n binding.root.getSharedType().observeDeep(observer);\n\n return () => {\n unsubscribeUpdateListener();\n binding.root.getSharedType().unobserveDeep(observer);\n };\n}\n\nexport function createNoOpProvider(): Provider {\n const emptyFunction = () => {};\n\n return {\n awareness: {\n getLocalState: () => null,\n setLocalStateField: emptyFunction,\n getStates: () => new Map(),\n off: emptyFunction,\n on: emptyFunction,\n setLocalState: emptyFunction,\n },\n connect: emptyFunction,\n disconnect: emptyFunction,\n off: emptyFunction,\n on: emptyFunction,\n };\n}\n","import { MENTION_CHARACTER } from \"@liveblocks/core\";\nimport type { NodeKey, SerializedLexicalNode, Spread } from \"lexical\";\nimport { $applyNodeReplacement, DecoratorNode } from \"lexical\";\n\nexport type SerializedGroupMentionNode = Spread<\n {\n id: string;\n groupId: string;\n userIds: string[] | undefined;\n },\n SerializedLexicalNode\n>;\n\nexport class GroupMentionNode extends DecoratorNode<null> {\n __id: string;\n __groupId: string;\n __userIds: string[] | undefined;\n\n constructor(\n id: string,\n groupId: string,\n userIds: string[] | undefined,\n key?: NodeKey\n ) {\n super(key);\n this.__id = id;\n this.__groupId = groupId;\n this.__userIds = userIds;\n }\n\n static getType(): string {\n return \"lb-group-mention\";\n }\n\n static clone(node: GroupMentionNode): GroupMentionNode {\n return new GroupMentionNode(node.__id, node.__groupId, node.__userIds);\n }\n\n static importJSON(\n serializedNode: SerializedGroupMentionNode\n ): GroupMentionNode {\n const node = new GroupMentionNode(\n serializedNode.id,\n serializedNode.groupId,\n serializedNode.userIds\n );\n return $applyNodeReplacement(node);\n }\n\n exportJSON(): SerializedGroupMentionNode {\n return {\n id: this.getId(),\n groupId: this.getGroupId(),\n userIds: this.getUserIds(),\n type: \"lb-group-mention\",\n version: 1,\n };\n }\n\n getId(): string {\n const self = this.getLatest();\n return self.__id;\n }\n\n getGroupId(): string {\n const self = this.getLatest();\n return self.__groupId;\n }\n\n getUserIds(): string[] | undefined {\n const self = this.getLatest();\n return self.__userIds;\n }\n\n getTextContent(): string {\n const groupId = this.getGroupId();\n\n return MENTION_CHARACTER + groupId;\n }\n\n decorate(): null {\n return null;\n }\n}\n","import { MENTION_CHARACTER } from \"@liveblocks/core\";\nimport type { NodeKey, SerializedLexicalNode, Spread } from \"lexical\";\nimport { $applyNodeReplacement, DecoratorNode } from \"lexical\";\n\ntype LegacySerializedMentionNode = Spread<\n {\n // Legacy field now named `id`\n value: string;\n // Not present in legacy nodes\n userId: never;\n },\n SerializedLexicalNode\n>;\n\nexport type SerializedMentionNode = Spread<\n {\n id: string;\n userId: string | undefined;\n },\n SerializedLexicalNode\n>;\n\nexport class MentionNode extends DecoratorNode<null> {\n __id: string;\n __userId: string | undefined;\n\n constructor(id: string, userId: string | undefined, 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 static importJSON(\n serializedNode: SerializedMentionNode | LegacySerializedMentionNode\n ): MentionNode {\n const node = new MentionNode(\n (serializedNode as LegacySerializedMentionNode).value ??\n (serializedNode as SerializedMentionNode).id,\n (serializedNode as SerializedMentionNode).userId\n );\n return $applyNodeReplacement(node);\n }\n\n exportJSON(): SerializedMentionNode {\n return {\n id: this.getId(),\n userId: this.getUserId(),\n type: \"lb-mention\",\n version: 1,\n };\n }\n\n getId(): string {\n const self = this.getLatest();\n return self.__id;\n }\n\n getUserId(): string | undefined {\n const self = this.getLatest();\n return self.__userId;\n }\n\n getTextContent(): string {\n const userId = this.getUserId();\n\n if (userId) {\n return MENTION_CHARACTER + userId;\n }\n\n // Legacy behavior: return the ID as text content\n // Since the ID is an inbox notification ID (\"in_xxx\") and not a user ID, this isn't ideal\n return this.getId();\n }\n\n decorate(): null {\n return null;\n }\n}\n","import type {\n BaseSelection,\n LexicalNode,\n NodeKey,\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 importJSON(serializedNode: SerializedThreadMarkNode): ThreadMarkNode {\n const node = $applyNodeReplacement<ThreadMarkNode>(\n new ThreadMarkNode(serializedNode.ids)\n );\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 getIDs(): Array<string> {\n const self = this.getLatest();\n return self instanceof ThreadMarkNode ? self.__ids : [];\n }\n\n constructor(ids: Array<string>, key?: NodeKey) {\n super(key);\n this.__ids = ids || [];\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","declare const __VERSION__: string;\ndeclare const TSUP_FORMAT: string;\n\nexport const PKG_NAME = \"@liveblocks/node-lexical\";\nexport const PKG_VERSION = typeof __VERSION__ === \"string\" && __VERSION__;\nexport const PKG_FORMAT = typeof TSUP_FORMAT === \"string\" && TSUP_FORMAT;\n"]}
|
package/dist/index.js
CHANGED
|
@@ -68,10 +68,67 @@ function createNoOpProvider() {
|
|
|
68
68
|
};
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
-
// src/
|
|
71
|
+
// src/GroupMentionNodeLite.ts
|
|
72
|
+
import { MENTION_CHARACTER } from "@liveblocks/core";
|
|
72
73
|
import { $applyNodeReplacement, DecoratorNode } from "lexical";
|
|
73
|
-
var
|
|
74
|
-
|
|
74
|
+
var GroupMentionNode = class _GroupMentionNode extends DecoratorNode {
|
|
75
|
+
__id;
|
|
76
|
+
__groupId;
|
|
77
|
+
__userIds;
|
|
78
|
+
constructor(id, groupId, userIds, key) {
|
|
79
|
+
super(key);
|
|
80
|
+
this.__id = id;
|
|
81
|
+
this.__groupId = groupId;
|
|
82
|
+
this.__userIds = userIds;
|
|
83
|
+
}
|
|
84
|
+
static getType() {
|
|
85
|
+
return "lb-group-mention";
|
|
86
|
+
}
|
|
87
|
+
static clone(node) {
|
|
88
|
+
return new _GroupMentionNode(node.__id, node.__groupId, node.__userIds);
|
|
89
|
+
}
|
|
90
|
+
static importJSON(serializedNode) {
|
|
91
|
+
const node = new _GroupMentionNode(
|
|
92
|
+
serializedNode.id,
|
|
93
|
+
serializedNode.groupId,
|
|
94
|
+
serializedNode.userIds
|
|
95
|
+
);
|
|
96
|
+
return $applyNodeReplacement(node);
|
|
97
|
+
}
|
|
98
|
+
exportJSON() {
|
|
99
|
+
return {
|
|
100
|
+
id: this.getId(),
|
|
101
|
+
groupId: this.getGroupId(),
|
|
102
|
+
userIds: this.getUserIds(),
|
|
103
|
+
type: "lb-group-mention",
|
|
104
|
+
version: 1
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
getId() {
|
|
108
|
+
const self = this.getLatest();
|
|
109
|
+
return self.__id;
|
|
110
|
+
}
|
|
111
|
+
getGroupId() {
|
|
112
|
+
const self = this.getLatest();
|
|
113
|
+
return self.__groupId;
|
|
114
|
+
}
|
|
115
|
+
getUserIds() {
|
|
116
|
+
const self = this.getLatest();
|
|
117
|
+
return self.__userIds;
|
|
118
|
+
}
|
|
119
|
+
getTextContent() {
|
|
120
|
+
const groupId = this.getGroupId();
|
|
121
|
+
return MENTION_CHARACTER + groupId;
|
|
122
|
+
}
|
|
123
|
+
decorate() {
|
|
124
|
+
return null;
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
// src/MentionNodeLite.ts
|
|
129
|
+
import { MENTION_CHARACTER as MENTION_CHARACTER2 } from "@liveblocks/core";
|
|
130
|
+
import { $applyNodeReplacement as $applyNodeReplacement2, DecoratorNode as DecoratorNode2 } from "lexical";
|
|
131
|
+
var MentionNode = class _MentionNode extends DecoratorNode2 {
|
|
75
132
|
__id;
|
|
76
133
|
__userId;
|
|
77
134
|
constructor(id, userId, key) {
|
|
@@ -90,7 +147,7 @@ var MentionNode = class _MentionNode extends DecoratorNode {
|
|
|
90
147
|
serializedNode.value ?? serializedNode.id,
|
|
91
148
|
serializedNode.userId
|
|
92
149
|
);
|
|
93
|
-
return $
|
|
150
|
+
return $applyNodeReplacement2(node);
|
|
94
151
|
}
|
|
95
152
|
exportJSON() {
|
|
96
153
|
return {
|
|
@@ -111,7 +168,7 @@ var MentionNode = class _MentionNode extends DecoratorNode {
|
|
|
111
168
|
getTextContent() {
|
|
112
169
|
const userId = this.getUserId();
|
|
113
170
|
if (userId) {
|
|
114
|
-
return
|
|
171
|
+
return MENTION_CHARACTER2 + userId;
|
|
115
172
|
}
|
|
116
173
|
return this.getId();
|
|
117
174
|
}
|
|
@@ -121,7 +178,7 @@ var MentionNode = class _MentionNode extends DecoratorNode {
|
|
|
121
178
|
};
|
|
122
179
|
|
|
123
180
|
// src/ThreadNodeLite.ts
|
|
124
|
-
import { $applyNodeReplacement as $
|
|
181
|
+
import { $applyNodeReplacement as $applyNodeReplacement3, $isRangeSelection, ElementNode } from "lexical";
|
|
125
182
|
var ThreadMarkNode = class _ThreadMarkNode extends ElementNode {
|
|
126
183
|
/** @internal */
|
|
127
184
|
__ids;
|
|
@@ -133,7 +190,7 @@ var ThreadMarkNode = class _ThreadMarkNode extends ElementNode {
|
|
|
133
190
|
return new _ThreadMarkNode(Array.from(node.__ids), node.__key);
|
|
134
191
|
}
|
|
135
192
|
static importJSON(serializedNode) {
|
|
136
|
-
const node = $
|
|
193
|
+
const node = $applyNodeReplacement3(
|
|
137
194
|
new _ThreadMarkNode(serializedNode.ids)
|
|
138
195
|
);
|
|
139
196
|
node.setFormat(serializedNode.format);
|
|
@@ -188,13 +245,13 @@ var ThreadMarkNode = class _ThreadMarkNode extends ElementNode {
|
|
|
188
245
|
|
|
189
246
|
// src/version.ts
|
|
190
247
|
var PKG_NAME = "@liveblocks/node-lexical";
|
|
191
|
-
var PKG_VERSION = "3.
|
|
248
|
+
var PKG_VERSION = "3.7.0-preview1";
|
|
192
249
|
var PKG_FORMAT = "esm";
|
|
193
250
|
|
|
194
251
|
// src/index.ts
|
|
195
252
|
import { $createParagraphNode, $createTextNode, $getRoot as $getRoot2 } from "lexical";
|
|
196
253
|
detectDupes(PKG_NAME, PKG_VERSION, PKG_FORMAT);
|
|
197
|
-
var LIVEBLOCKS_NODES = [ThreadMarkNode, MentionNode];
|
|
254
|
+
var LIVEBLOCKS_NODES = [ThreadMarkNode, MentionNode, GroupMentionNode];
|
|
198
255
|
async function withLexicalDocument({ roomId, nodes, client }, callback) {
|
|
199
256
|
const update = new Uint8Array(
|
|
200
257
|
await client.getYjsDocumentAsBinaryUpdate(roomId)
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/collab.ts","../src/MentionNodeLite.ts","../src/ThreadNodeLite.ts","../src/version.ts"],"sourcesContent":["import { createHeadlessEditor } from \"@lexical/headless\";\nimport { $convertToMarkdownString, TRANSFORMERS } from \"@lexical/markdown\";\nimport { createBinding } from \"@lexical/yjs\";\nimport { detectDupes } from \"@liveblocks/core\";\nimport type { Liveblocks } from \"@liveblocks/node\";\nimport type {\n EditorState,\n Klass,\n LexicalEditor,\n LexicalNode,\n LexicalNodeReplacement,\n SerializedEditorState,\n SerializedLexicalNode,\n} from \"lexical\";\nimport { $getRoot } from \"lexical\";\nimport { applyUpdate, Doc, encodeStateAsUpdate, encodeStateVector } from \"yjs\";\n\nimport { createNoOpProvider, registerCollaborationListeners } from \"./collab\";\nimport { MentionNode } from \"./MentionNodeLite\";\nimport { ThreadMarkNode } from \"./ThreadNodeLite\";\nimport { PKG_FORMAT, PKG_NAME, PKG_VERSION } from \"./version\";\n\ndetectDupes(PKG_NAME, PKG_VERSION, PKG_FORMAT);\n\nconst LIVEBLOCKS_NODES = [ThreadMarkNode, MentionNode];\n\nexport { $createParagraphNode, $createTextNode, $getRoot } from \"lexical\";\n\nexport type LiveblocksLexicalOptions = {\n roomId: string;\n nodes?: ReadonlyArray<Klass<LexicalNode> | LexicalNodeReplacement>;\n client: Liveblocks;\n};\n\nexport type LiveblocksDocumentApi = {\n refresh: () => Promise<void>;\n update: (modifyFn: () => void) => Promise<void>;\n getTextContent: () => string;\n getEditorState: () => EditorState;\n getLexicalEditor: () => LexicalEditor;\n toJSON: () => SerializedEditorState<SerializedLexicalNode>;\n toMarkdown: () => string;\n};\n\n/**\n *\n * `withLexicalDocument` is the main entry point to access and modify Lexical documents on your backend.\n * This function internally instantiates a Lexical headless editor and allows you to modify and export its values asynchronously\n * with a simplified interface.\n *\n * @param options Specify the roomId, client, and nodes.\n * @param callback The call back function is optionally async and receives the document API as its only argument.\n *\n * @example\n *\n * import { Liveblocks } from \"@liveblocks/node\";\n * import { withLexicalDocument } from \"@liveblocks/node-lexical\";\n *\n * const client = new Liveblocks({secret: \"sk_your_secret_key\"});\n * const text = await withLexicalDocument(\n * { client, roomId: \"your-room\" },\n * async (doc) => {\n * await doc.update(() => {\n * const root = $getRoot();\n * const paragraphNode = $createParagraphNode();\n * const textNode = $createTextNode(\"Hello from node\");\n * paragraphNode.append(textNode);\n * root.append(paragraphNode);\n * });\n * return doc.getTextContent();\n * }\n * );\n *\n */\nexport async function withLexicalDocument<T>(\n { roomId, nodes, client }: LiveblocksLexicalOptions,\n callback: (api: LiveblocksDocumentApi) => Promise<T> | T\n): Promise<T> {\n const update = new Uint8Array(\n await client.getYjsDocumentAsBinaryUpdate(roomId)\n );\n const editor = createHeadlessEditor({\n nodes: [...LIVEBLOCKS_NODES, ...(nodes ?? [])],\n });\n const id = \"root\";\n const doc = new Doc();\n const docMap = new Map([[id, doc]]);\n const provider = createNoOpProvider();\n const binding = createBinding(editor, provider, id, doc, docMap);\n const unsubscribe = registerCollaborationListeners(editor, provider, binding);\n applyUpdate(binding.doc, update);\n editor.update(() => {}, { discrete: true });\n\n const val = await callback({\n /**\n * Fetches and resyncs the latest document with Liveblocks\n */\n refresh: async () => {\n const latest = new Uint8Array(\n await client.getYjsDocumentAsBinaryUpdate(roomId)\n );\n applyUpdate(binding.doc, latest);\n editor.update(() => {}, { discrete: true });\n },\n /**\n * Provide a callback to modify documetns with Lexical's standard api. All calls are discrete.\n */\n update: async (modifyFn) => {\n // Flush any pending updates (there really shouldn't be any?), this may be a NOOP\n editor.update(() => {}, { discrete: true });\n const beforeVector = encodeStateVector(binding.doc);\n editor.update(\n () => {\n modifyFn();\n },\n { discrete: true }\n );\n // grab update after diffing\n const diffUpdate = encodeStateAsUpdate(binding.doc, beforeVector);\n return client.sendYjsBinaryUpdate(roomId, diffUpdate);\n },\n /**\n * Helper function to easily provide the text content from the root, i.e. `$getRoot().getTextContent()`\n */\n getTextContent: () => {\n let content = \"\";\n editor.getEditorState().read(() => {\n content = $getRoot().getTextContent();\n });\n return content;\n },\n /**\n * Helper function to return editorState in JSON form\n */\n toJSON: () => {\n return editor.getEditorState().toJSON();\n },\n /**\n * Helper function to return editor state as Markdown\n */\n toMarkdown: () => {\n let markdown: string = \"\";\n editor.getEditorState().read(() => {\n markdown = $convertToMarkdownString(TRANSFORMERS);\n });\n return markdown;\n },\n /**\n * Helper function to return the editor's current state\n */\n getEditorState: () => {\n return editor.getEditorState();\n },\n /**\n * Helper function to return the current headless editor instance\n */\n getLexicalEditor: () => {\n return editor;\n },\n });\n unsubscribe();\n\n return val;\n}\n","import { createHeadlessEditor } from \"@lexical/headless\";\nimport type { Binding, Provider } from \"@lexical/yjs\";\nimport {\n createBinding,\n syncLexicalUpdateToYjs,\n syncYjsChangesToLexical,\n} from \"@lexical/yjs\";\nimport type {\n Klass,\n LexicalEditor,\n LexicalNode,\n LexicalNodeReplacement,\n} from \"lexical\";\nimport type { Transaction, YEvent } from \"yjs\";\nimport { Doc } from \"yjs\";\n\nexport function withHeadlessCollaborationEditor<T>(\n nodes: ReadonlyArray<Klass<LexicalNode> | LexicalNodeReplacement>,\n callback: (editor: LexicalEditor, binding: Binding, provider: Provider) => T\n): T {\n const editor = createHeadlessEditor({\n nodes,\n });\n\n const id = \"root\";\n const doc = new Doc();\n const docMap = new Map([[id, doc]]);\n const provider = createNoOpProvider();\n const binding = createBinding(editor, provider, id, doc, docMap);\n\n const unsubscribe = registerCollaborationListeners(editor, provider, binding);\n\n const res = callback(editor, binding, provider);\n\n unsubscribe();\n\n return res;\n}\n\nexport function registerCollaborationListeners(\n editor: LexicalEditor,\n provider: Provider,\n binding: Binding\n): () => void {\n const unsubscribeUpdateListener = editor.registerUpdateListener(\n ({\n dirtyElements,\n dirtyLeaves,\n editorState,\n normalizedNodes,\n prevEditorState,\n tags,\n }) => {\n if (tags.has(\"skip-collab\") === false) {\n syncLexicalUpdateToYjs(\n binding,\n provider,\n prevEditorState,\n editorState,\n dirtyElements,\n dirtyLeaves,\n normalizedNodes,\n tags\n );\n }\n }\n );\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const observer = (events: Array<YEvent<any>>, transaction: Transaction) => {\n if (transaction.origin !== binding) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n syncYjsChangesToLexical(binding, provider, events, false);\n }\n };\n\n binding.root.getSharedType().observeDeep(observer);\n\n return () => {\n unsubscribeUpdateListener();\n binding.root.getSharedType().unobserveDeep(observer);\n };\n}\n\nexport function createNoOpProvider(): Provider {\n const emptyFunction = () => {};\n\n return {\n awareness: {\n getLocalState: () => null,\n setLocalStateField: emptyFunction,\n getStates: () => new Map(),\n off: emptyFunction,\n on: emptyFunction,\n setLocalState: emptyFunction,\n },\n connect: emptyFunction,\n disconnect: emptyFunction,\n off: emptyFunction,\n on: emptyFunction,\n };\n}\n","import type { NodeKey, SerializedLexicalNode, Spread } from \"lexical\";\nimport { $applyNodeReplacement, DecoratorNode } from \"lexical\";\n\nconst MENTION_CHARACTER = \"@\";\n\ntype LegacySerializedMentionNode = Spread<\n {\n // Legacy field now named `id`\n value: string;\n // Not present in legacy nodes\n userId: never;\n },\n SerializedLexicalNode\n>;\n\nexport type SerializedMentionNode = Spread<\n {\n id: string;\n userId: string | undefined;\n },\n SerializedLexicalNode\n>;\n\nexport class MentionNode extends DecoratorNode<null> {\n __id: string;\n __userId: string | undefined;\n\n constructor(id: string, userId: string | undefined, 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 static importJSON(\n serializedNode: SerializedMentionNode | LegacySerializedMentionNode\n ): MentionNode {\n const node = new MentionNode(\n (serializedNode as LegacySerializedMentionNode).value ??\n (serializedNode as SerializedMentionNode).id,\n (serializedNode as SerializedMentionNode).userId\n );\n return $applyNodeReplacement(node);\n }\n\n exportJSON(): SerializedMentionNode {\n return {\n id: this.getId(),\n userId: this.getUserId(),\n type: \"lb-mention\",\n version: 1,\n };\n }\n\n getId(): string {\n const self = this.getLatest();\n return self.__id;\n }\n\n getUserId(): string | undefined {\n const self = this.getLatest();\n return self.__userId;\n }\n\n getTextContent(): string {\n const userId = this.getUserId();\n\n if (userId) {\n return MENTION_CHARACTER + userId;\n }\n\n // Legacy behavior: return the ID as text content\n // Since the ID is an inbox notification ID (\"in_xxx\") and not a user ID, this isn't ideal\n return this.getId();\n }\n\n decorate(): null {\n return null;\n }\n}\n","import type {\n BaseSelection,\n LexicalNode,\n NodeKey,\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 importJSON(serializedNode: SerializedThreadMarkNode): ThreadMarkNode {\n const node = $applyNodeReplacement<ThreadMarkNode>(\n new ThreadMarkNode(serializedNode.ids)\n );\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 getIDs(): Array<string> {\n const self = this.getLatest();\n return self instanceof ThreadMarkNode ? self.__ids : [];\n }\n\n constructor(ids: Array<string>, key?: NodeKey) {\n super(key);\n this.__ids = ids || [];\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","declare const __VERSION__: string;\ndeclare const TSUP_FORMAT: string;\n\nexport const PKG_NAME = \"@liveblocks/node-lexical\";\nexport const PKG_VERSION = typeof __VERSION__ === \"string\" && __VERSION__;\nexport const PKG_FORMAT = typeof TSUP_FORMAT === \"string\" && TSUP_FORMAT;\n"],"mappings":";AAAA,SAAS,wBAAAA,6BAA4B;AACrC,SAAS,0BAA0B,oBAAoB;AACvD,SAAS,iBAAAC,sBAAqB;AAC9B,SAAS,mBAAmB;AAW5B,SAAS,gBAAgB;AACzB,SAAS,aAAa,OAAAC,MAAK,qBAAqB,yBAAyB;;;ACfzE,SAAS,4BAA4B;AAErC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAQP,SAAS,WAAW;AAyBb,SAAS,+BACd,QACA,UACA,SACY;AACZ,QAAM,4BAA4B,OAAO;AAAA,IACvC,CAAC;AAAA,MACC;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF,MAAM;AACJ,UAAI,KAAK,IAAI,aAAa,MAAM,OAAO;AACrC;AAAA,UACE;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAGA,QAAM,WAAW,CAAC,QAA4B,gBAA6B;AACzE,QAAI,YAAY,WAAW,SAAS;AAElC,8BAAwB,SAAS,UAAU,QAAQ,KAAK;AAAA,IAC1D;AAAA,EACF;AAEA,UAAQ,KAAK,cAAc,EAAE,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":["createHeadlessEditor","createBinding","Doc","$applyNodeReplacement","$getRoot","createHeadlessEditor","Doc","createBinding"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/collab.ts","../src/GroupMentionNodeLite.ts","../src/MentionNodeLite.ts","../src/ThreadNodeLite.ts","../src/version.ts"],"sourcesContent":["import { createHeadlessEditor } from \"@lexical/headless\";\nimport { $convertToMarkdownString, TRANSFORMERS } from \"@lexical/markdown\";\nimport { createBinding } from \"@lexical/yjs\";\nimport { detectDupes } from \"@liveblocks/core\";\nimport type { Liveblocks } from \"@liveblocks/node\";\nimport type {\n EditorState,\n Klass,\n LexicalEditor,\n LexicalNode,\n LexicalNodeReplacement,\n SerializedEditorState,\n SerializedLexicalNode,\n} from \"lexical\";\nimport { $getRoot } from \"lexical\";\nimport { applyUpdate, Doc, encodeStateAsUpdate, encodeStateVector } from \"yjs\";\n\nimport { createNoOpProvider, registerCollaborationListeners } from \"./collab\";\nimport { GroupMentionNode } from \"./GroupMentionNodeLite\";\nimport { MentionNode } from \"./MentionNodeLite\";\nimport { ThreadMarkNode } from \"./ThreadNodeLite\";\nimport { PKG_FORMAT, PKG_NAME, PKG_VERSION } from \"./version\";\n\ndetectDupes(PKG_NAME, PKG_VERSION, PKG_FORMAT);\n\nconst LIVEBLOCKS_NODES = [ThreadMarkNode, MentionNode, GroupMentionNode];\n\nexport { $createParagraphNode, $createTextNode, $getRoot } from \"lexical\";\n\nexport type LiveblocksLexicalOptions = {\n roomId: string;\n nodes?: ReadonlyArray<Klass<LexicalNode> | LexicalNodeReplacement>;\n client: Liveblocks;\n};\n\nexport type LiveblocksDocumentApi = {\n refresh: () => Promise<void>;\n update: (modifyFn: () => void) => Promise<void>;\n getTextContent: () => string;\n getEditorState: () => EditorState;\n getLexicalEditor: () => LexicalEditor;\n toJSON: () => SerializedEditorState<SerializedLexicalNode>;\n toMarkdown: () => string;\n};\n\n/**\n *\n * `withLexicalDocument` is the main entry point to access and modify Lexical documents on your backend.\n * This function internally instantiates a Lexical headless editor and allows you to modify and export its values asynchronously\n * with a simplified interface.\n *\n * @param options Specify the roomId, client, and nodes.\n * @param callback The call back function is optionally async and receives the document API as its only argument.\n *\n * @example\n *\n * import { Liveblocks } from \"@liveblocks/node\";\n * import { withLexicalDocument } from \"@liveblocks/node-lexical\";\n *\n * const client = new Liveblocks({secret: \"sk_your_secret_key\"});\n * const text = await withLexicalDocument(\n * { client, roomId: \"your-room\" },\n * async (doc) => {\n * await doc.update(() => {\n * const root = $getRoot();\n * const paragraphNode = $createParagraphNode();\n * const textNode = $createTextNode(\"Hello from node\");\n * paragraphNode.append(textNode);\n * root.append(paragraphNode);\n * });\n * return doc.getTextContent();\n * }\n * );\n *\n */\nexport async function withLexicalDocument<T>(\n { roomId, nodes, client }: LiveblocksLexicalOptions,\n callback: (api: LiveblocksDocumentApi) => Promise<T> | T\n): Promise<T> {\n const update = new Uint8Array(\n await client.getYjsDocumentAsBinaryUpdate(roomId)\n );\n const editor = createHeadlessEditor({\n nodes: [...LIVEBLOCKS_NODES, ...(nodes ?? [])],\n });\n const id = \"root\";\n const doc = new Doc();\n const docMap = new Map([[id, doc]]);\n const provider = createNoOpProvider();\n const binding = createBinding(editor, provider, id, doc, docMap);\n const unsubscribe = registerCollaborationListeners(editor, provider, binding);\n applyUpdate(binding.doc, update);\n editor.update(() => {}, { discrete: true });\n\n const val = await callback({\n /**\n * Fetches and resyncs the latest document with Liveblocks\n */\n refresh: async () => {\n const latest = new Uint8Array(\n await client.getYjsDocumentAsBinaryUpdate(roomId)\n );\n applyUpdate(binding.doc, latest);\n editor.update(() => {}, { discrete: true });\n },\n /**\n * Provide a callback to modify documetns with Lexical's standard api. All calls are discrete.\n */\n update: async (modifyFn) => {\n // Flush any pending updates (there really shouldn't be any?), this may be a NOOP\n editor.update(() => {}, { discrete: true });\n const beforeVector = encodeStateVector(binding.doc);\n editor.update(\n () => {\n modifyFn();\n },\n { discrete: true }\n );\n // grab update after diffing\n const diffUpdate = encodeStateAsUpdate(binding.doc, beforeVector);\n return client.sendYjsBinaryUpdate(roomId, diffUpdate);\n },\n /**\n * Helper function to easily provide the text content from the root, i.e. `$getRoot().getTextContent()`\n */\n getTextContent: () => {\n let content = \"\";\n editor.getEditorState().read(() => {\n content = $getRoot().getTextContent();\n });\n return content;\n },\n /**\n * Helper function to return editorState in JSON form\n */\n toJSON: () => {\n return editor.getEditorState().toJSON();\n },\n /**\n * Helper function to return editor state as Markdown\n */\n toMarkdown: () => {\n let markdown: string = \"\";\n editor.getEditorState().read(() => {\n markdown = $convertToMarkdownString(TRANSFORMERS);\n });\n return markdown;\n },\n /**\n * Helper function to return the editor's current state\n */\n getEditorState: () => {\n return editor.getEditorState();\n },\n /**\n * Helper function to return the current headless editor instance\n */\n getLexicalEditor: () => {\n return editor;\n },\n });\n unsubscribe();\n\n return val;\n}\n","import { createHeadlessEditor } from \"@lexical/headless\";\nimport type { Binding, Provider } from \"@lexical/yjs\";\nimport {\n createBinding,\n syncLexicalUpdateToYjs,\n syncYjsChangesToLexical,\n} from \"@lexical/yjs\";\nimport type {\n Klass,\n LexicalEditor,\n LexicalNode,\n LexicalNodeReplacement,\n} from \"lexical\";\nimport type { Transaction, YEvent } from \"yjs\";\nimport { Doc } from \"yjs\";\n\nexport function withHeadlessCollaborationEditor<T>(\n nodes: ReadonlyArray<Klass<LexicalNode> | LexicalNodeReplacement>,\n callback: (editor: LexicalEditor, binding: Binding, provider: Provider) => T\n): T {\n const editor = createHeadlessEditor({\n nodes,\n });\n\n const id = \"root\";\n const doc = new Doc();\n const docMap = new Map([[id, doc]]);\n const provider = createNoOpProvider();\n const binding = createBinding(editor, provider, id, doc, docMap);\n\n const unsubscribe = registerCollaborationListeners(editor, provider, binding);\n\n const res = callback(editor, binding, provider);\n\n unsubscribe();\n\n return res;\n}\n\nexport function registerCollaborationListeners(\n editor: LexicalEditor,\n provider: Provider,\n binding: Binding\n): () => void {\n const unsubscribeUpdateListener = editor.registerUpdateListener(\n ({\n dirtyElements,\n dirtyLeaves,\n editorState,\n normalizedNodes,\n prevEditorState,\n tags,\n }) => {\n if (tags.has(\"skip-collab\") === false) {\n syncLexicalUpdateToYjs(\n binding,\n provider,\n prevEditorState,\n editorState,\n dirtyElements,\n dirtyLeaves,\n normalizedNodes,\n tags\n );\n }\n }\n );\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const observer = (events: Array<YEvent<any>>, transaction: Transaction) => {\n if (transaction.origin !== binding) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n syncYjsChangesToLexical(binding, provider, events, false);\n }\n };\n\n binding.root.getSharedType().observeDeep(observer);\n\n return () => {\n unsubscribeUpdateListener();\n binding.root.getSharedType().unobserveDeep(observer);\n };\n}\n\nexport function createNoOpProvider(): Provider {\n const emptyFunction = () => {};\n\n return {\n awareness: {\n getLocalState: () => null,\n setLocalStateField: emptyFunction,\n getStates: () => new Map(),\n off: emptyFunction,\n on: emptyFunction,\n setLocalState: emptyFunction,\n },\n connect: emptyFunction,\n disconnect: emptyFunction,\n off: emptyFunction,\n on: emptyFunction,\n };\n}\n","import { MENTION_CHARACTER } from \"@liveblocks/core\";\nimport type { NodeKey, SerializedLexicalNode, Spread } from \"lexical\";\nimport { $applyNodeReplacement, DecoratorNode } from \"lexical\";\n\nexport type SerializedGroupMentionNode = Spread<\n {\n id: string;\n groupId: string;\n userIds: string[] | undefined;\n },\n SerializedLexicalNode\n>;\n\nexport class GroupMentionNode extends DecoratorNode<null> {\n __id: string;\n __groupId: string;\n __userIds: string[] | undefined;\n\n constructor(\n id: string,\n groupId: string,\n userIds: string[] | undefined,\n key?: NodeKey\n ) {\n super(key);\n this.__id = id;\n this.__groupId = groupId;\n this.__userIds = userIds;\n }\n\n static getType(): string {\n return \"lb-group-mention\";\n }\n\n static clone(node: GroupMentionNode): GroupMentionNode {\n return new GroupMentionNode(node.__id, node.__groupId, node.__userIds);\n }\n\n static importJSON(\n serializedNode: SerializedGroupMentionNode\n ): GroupMentionNode {\n const node = new GroupMentionNode(\n serializedNode.id,\n serializedNode.groupId,\n serializedNode.userIds\n );\n return $applyNodeReplacement(node);\n }\n\n exportJSON(): SerializedGroupMentionNode {\n return {\n id: this.getId(),\n groupId: this.getGroupId(),\n userIds: this.getUserIds(),\n type: \"lb-group-mention\",\n version: 1,\n };\n }\n\n getId(): string {\n const self = this.getLatest();\n return self.__id;\n }\n\n getGroupId(): string {\n const self = this.getLatest();\n return self.__groupId;\n }\n\n getUserIds(): string[] | undefined {\n const self = this.getLatest();\n return self.__userIds;\n }\n\n getTextContent(): string {\n const groupId = this.getGroupId();\n\n return MENTION_CHARACTER + groupId;\n }\n\n decorate(): null {\n return null;\n }\n}\n","import { MENTION_CHARACTER } from \"@liveblocks/core\";\nimport type { NodeKey, SerializedLexicalNode, Spread } from \"lexical\";\nimport { $applyNodeReplacement, DecoratorNode } from \"lexical\";\n\ntype LegacySerializedMentionNode = Spread<\n {\n // Legacy field now named `id`\n value: string;\n // Not present in legacy nodes\n userId: never;\n },\n SerializedLexicalNode\n>;\n\nexport type SerializedMentionNode = Spread<\n {\n id: string;\n userId: string | undefined;\n },\n SerializedLexicalNode\n>;\n\nexport class MentionNode extends DecoratorNode<null> {\n __id: string;\n __userId: string | undefined;\n\n constructor(id: string, userId: string | undefined, 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 static importJSON(\n serializedNode: SerializedMentionNode | LegacySerializedMentionNode\n ): MentionNode {\n const node = new MentionNode(\n (serializedNode as LegacySerializedMentionNode).value ??\n (serializedNode as SerializedMentionNode).id,\n (serializedNode as SerializedMentionNode).userId\n );\n return $applyNodeReplacement(node);\n }\n\n exportJSON(): SerializedMentionNode {\n return {\n id: this.getId(),\n userId: this.getUserId(),\n type: \"lb-mention\",\n version: 1,\n };\n }\n\n getId(): string {\n const self = this.getLatest();\n return self.__id;\n }\n\n getUserId(): string | undefined {\n const self = this.getLatest();\n return self.__userId;\n }\n\n getTextContent(): string {\n const userId = this.getUserId();\n\n if (userId) {\n return MENTION_CHARACTER + userId;\n }\n\n // Legacy behavior: return the ID as text content\n // Since the ID is an inbox notification ID (\"in_xxx\") and not a user ID, this isn't ideal\n return this.getId();\n }\n\n decorate(): null {\n return null;\n }\n}\n","import type {\n BaseSelection,\n LexicalNode,\n NodeKey,\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 importJSON(serializedNode: SerializedThreadMarkNode): ThreadMarkNode {\n const node = $applyNodeReplacement<ThreadMarkNode>(\n new ThreadMarkNode(serializedNode.ids)\n );\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 getIDs(): Array<string> {\n const self = this.getLatest();\n return self instanceof ThreadMarkNode ? self.__ids : [];\n }\n\n constructor(ids: Array<string>, key?: NodeKey) {\n super(key);\n this.__ids = ids || [];\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","declare const __VERSION__: string;\ndeclare const TSUP_FORMAT: string;\n\nexport const PKG_NAME = \"@liveblocks/node-lexical\";\nexport const PKG_VERSION = typeof __VERSION__ === \"string\" && __VERSION__;\nexport const PKG_FORMAT = typeof TSUP_FORMAT === \"string\" && TSUP_FORMAT;\n"],"mappings":";AAAA,SAAS,wBAAAA,6BAA4B;AACrC,SAAS,0BAA0B,oBAAoB;AACvD,SAAS,iBAAAC,sBAAqB;AAC9B,SAAS,mBAAmB;AAW5B,SAAS,gBAAgB;AACzB,SAAS,aAAa,OAAAC,MAAK,qBAAqB,yBAAyB;;;ACfzE,SAAS,4BAA4B;AAErC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAQP,SAAS,WAAW;AAyBb,SAAS,+BACd,QACA,UACA,SACY;AACZ,QAAM,4BAA4B,OAAO;AAAA,IACvC,CAAC;AAAA,MACC;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF,MAAM;AACJ,UAAI,KAAK,IAAI,aAAa,MAAM,OAAO;AACrC;AAAA,UACE;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAGA,QAAM,WAAW,CAAC,QAA4B,gBAA6B;AACzE,QAAI,YAAY,WAAW,SAAS;AAElC,8BAAwB,SAAS,UAAU,QAAQ,KAAK;AAAA,IAC1D;AAAA,EACF;AAEA,UAAQ,KAAK,cAA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AAS,IAAI;AAAA,QACjB,MAAM,OAAO,6BAA6B,MAAM;AAAA,MAClD;AACA,kBAAY,QAAQ,KAAK,MAAM;AAC/B,aAAO,OAAO,MAAM;AAAA,MAAC,GAAG,EAAE,UAAU,KAAK,CAAC;AAAA,IAC5C;AAAA;AAAA;AAAA;AAAA,IAIA,QAAQ,OAAO,aAAa;AAE1B,aAAO,OAAO,MAAM;AAAA,MAAC,GAAG,EAAE,UAAU,KAAK,CAAC;AAC1C,YAAM,eAAe,kBAAkB,QAAQ,GAAG;AAClD,aAAO;AAAA,QACL,MAAM;AACJ,mBAAS;AAAA,QACX;AAAA,QACA,EAAE,UAAU,KAAK;AAAA,MACnB;AAEA,YAAM,aAAa,oBAAoB,QAAQ,KAAK,YAAY;AAChE,aAAO,OAAO,oBAAoB,QAAQ,UAAU;AAAA,IACtD;AAAA;AAAA;AAAA;AAAA,IAIA,gBAAgB,MAAM;AACpB,UAAI,UAAU;AACd,aAAO,eAAe,EAAE,KAAK,MAAM;AACjC,kBAAU,SAAS,EAAE,eAAe;AAAA,MACtC,CAAC;AACD,aAAO;AAAA,IACT;AAAA;AAAA;AAAA;AAAA,IAIA,QAAQ,MAAM;AACZ,aAAO,OAAO,eAAe,EAAE,OAAO;AAAA,IACxC;AAAA;AAAA;AAAA;AAAA,IAIA,YAAY,MAAM;AAChB,UAAI,WAAmB;AACvB,aAAO,eAAe,EAAE,KAAK,MAAM;AACjC,mBAAW,yBAAyB,YAAY;AAAA,MAClD,CAAC;AACD,aAAO;AAAA,IACT;AAAA;AAAA;AAAA;AAAA,IAIA,gBAAgB,MAAM;AACpB,aAAO,OAAO,eAAe;AAAA,IAC/B;AAAA;AAAA;AAAA;AAAA,IAIA,kBAAkB,MAAM;AACtB,aAAO;AAAA,IACT;AAAA,EACF,CAAC;AACD,cAAY;AAEZ,SAAO;AACT;","names":["createHeadlessEditor","createBinding","Doc","MENTION_CHARACTER","$applyNodeReplacement","DecoratorNode","$applyNodeReplacement","$getRoot","createHeadlessEditor","Doc","createBinding"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@liveblocks/node-lexical",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.7.0-preview1",
|
|
4
4
|
"description": "A server-side utility that lets you modify lexical documents hosted in Liveblocks.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -34,8 +34,8 @@
|
|
|
34
34
|
"test:watch": "NODE_OPTIONS=\"--no-deprecation\" vitest"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@liveblocks/core": "3.
|
|
38
|
-
"@liveblocks/node": "3.
|
|
37
|
+
"@liveblocks/core": "3.7.0-preview1",
|
|
38
|
+
"@liveblocks/node": "3.7.0-preview1",
|
|
39
39
|
"yjs": "^13.6.18"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|