@liveblocks/node-lexical
Advanced tools
Comparing version 1.12.0-lexical4 to 1.12.0-lexical6
import { Liveblocks } from '@liveblocks/node'; | ||
import { Klass, LexicalNode, LexicalNodeReplacement, EditorState, RootNode } from 'lexical'; | ||
import { Klass, LexicalNode, LexicalNodeReplacement, LexicalEditor, EditorState } from 'lexical'; | ||
export { $createParagraphNode, $createTextNode, $getRoot } from 'lexical'; | ||
declare function getEditor(client: Liveblocks, roomId: string, nodes: ReadonlyArray<Klass<LexicalNode> | LexicalNodeReplacement>): Promise<LexicalEditor>; | ||
declare function getTextContent(client: Liveblocks, roomId: string, nodes: ReadonlyArray<Klass<LexicalNode> | LexicalNodeReplacement>): Promise<string>; | ||
declare function getEditorState(client: Liveblocks, roomId: string, nodes: ReadonlyArray<Klass<LexicalNode> | LexicalNodeReplacement>): Promise<EditorState>; | ||
declare function modifyDocument(client: Liveblocks, roomId: string, nodes: ReadonlyArray<Klass<LexicalNode> | LexicalNodeReplacement>, modifyFn: (root: RootNode) => void): Promise<void>; | ||
declare function modifyDocument(client: Liveblocks, roomId: string, nodes: ReadonlyArray<Klass<LexicalNode> | LexicalNodeReplacement>, modifyFn: (editor: LexicalEditor) => void): Promise<void>; | ||
export { getEditorState, modifyDocument }; | ||
export { getEditor, getEditorState, getTextContent, modifyDocument }; |
@@ -184,3 +184,3 @@ "use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/index.ts | ||
var PKG_NAME = "@liveblocks/node-lexical"; | ||
var PKG_VERSION = "1.12.0-lexical4"; | ||
var PKG_VERSION = "1.12.0-lexical6"; | ||
var PKG_FORMAT = "cjs"; | ||
@@ -192,2 +192,32 @@ | ||
var LIVEBLOCKS_NODES = [ThreadMarkNode, MentionNode]; | ||
async function getEditor(client, roomId, nodes) { | ||
const doc = await client.getYjsDocumentAsBinaryUpdate(roomId); | ||
const update = new Uint8Array(doc); | ||
return withHeadlessCollaborationEditor( | ||
[...LIVEBLOCKS_NODES, ...nodes], | ||
(editor, binding) => { | ||
_yjs.applyUpdate.call(void 0, binding.doc, update); | ||
editor.update(() => { | ||
}, { discrete: true }); | ||
return editor; | ||
} | ||
); | ||
} | ||
async function getTextContent(client, roomId, nodes) { | ||
const doc = await client.getYjsDocumentAsBinaryUpdate(roomId); | ||
const update = new Uint8Array(doc); | ||
return withHeadlessCollaborationEditor( | ||
[...LIVEBLOCKS_NODES, ...nodes], | ||
(editor, binding) => { | ||
_yjs.applyUpdate.call(void 0, binding.doc, update); | ||
editor.update(() => { | ||
}, { discrete: true }); | ||
let content = ""; | ||
editor.getEditorState().read(() => { | ||
content = _lexical.$getRoot.call(void 0, ).getTextContent(); | ||
}); | ||
return content; | ||
} | ||
); | ||
} | ||
async function getEditorState(client, roomId, nodes) { | ||
@@ -218,4 +248,3 @@ const doc = await client.getYjsDocumentAsBinaryUpdate(roomId); | ||
() => { | ||
const root = _lexical.$getRoot.call(void 0, ); | ||
modifyFn(root); | ||
modifyFn(editor); | ||
}, | ||
@@ -235,3 +264,5 @@ { discrete: true } | ||
exports.$createParagraphNode = _lexical.$createParagraphNode; exports.$createTextNode = _lexical.$createTextNode; exports.$getRoot = _lexical.$getRoot; exports.getEditorState = getEditorState; exports.modifyDocument = modifyDocument; | ||
exports.$createParagraphNode = _lexical.$createParagraphNode; exports.$createTextNode = _lexical.$createTextNode; exports.$getRoot = _lexical.$getRoot; exports.getEditor = getEditor; exports.getEditorState = getEditorState; exports.getTextContent = getTextContent; exports.modifyDocument = modifyDocument; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@liveblocks/node-lexical", | ||
"version": "1.12.0-lexical4", | ||
"version": "1.12.0-lexical6", | ||
"description": "A server-side utility that lets you modify lexical documents hosted in Liveblocks.", | ||
@@ -36,4 +36,4 @@ "license": "Apache-2.0", | ||
"dependencies": { | ||
"@liveblocks/core": "1.12.0-lexical4", | ||
"@liveblocks/node": "1.12.0-lexical4", | ||
"@liveblocks/core": "1.12.0-lexical6", | ||
"@liveblocks/node": "1.12.0-lexical6", | ||
"yjs": "^13.6.15" | ||
@@ -43,2 +43,3 @@ }, | ||
"@lexical/headless": "0.14.5", | ||
"@lexical/selection": "0.14.3", | ||
"@lexical/yjs": "0.14.5", | ||
@@ -45,0 +46,0 @@ "lexical": "0.14.5" |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
50044
505
0
7
+ Added@lexical/selection@0.14.3(transitive)
+ Added@liveblocks/core@1.12.0-lexical6(transitive)
+ Added@liveblocks/node@1.12.0-lexical6(transitive)
+ Addedlexical@0.14.3(transitive)
- Removed@liveblocks/core@1.12.0-lexical4(transitive)
- Removed@liveblocks/node@1.12.0-lexical4(transitive)