@liveblocks/node-lexical
Advanced tools
Comparing version 2.0.0-alpha4 to 2.0.0-alpha5
@@ -19,4 +19,34 @@ import { Liveblocks } from '@liveblocks/node'; | ||
}; | ||
/** | ||
* | ||
* `withLexicalDocument` is the main entry point to access and modify Lexical documents on your backend. | ||
* This function internally instantiates a Lexical headless editor and allows you to modify and export its values asynchronously | ||
* with a simplified interface. | ||
* | ||
* @param options Specify the roomId, client, and nodes. | ||
* @param callback The call back function is optionally async and receives the document API as its only argument. | ||
* | ||
* @example | ||
* | ||
* import { Liveblocks } from "@liveblocks/node"; | ||
* import { withLexicalDocument } from "@liveblocks/node-lexical"; | ||
* | ||
* const client = new Liveblocks({secret: "sk_your_secret_key"}); | ||
* const text = await withLexicalDocument( | ||
* { client, roomId: "your-room" }, | ||
* async (doc) => { | ||
* await doc.update(() => { | ||
* const root = $getRoot(); | ||
* const paragraphNode = $createParagraphNode(); | ||
* const textNode = $createTextNode("Hello from node"); | ||
* paragraphNode.append(textNode); | ||
* root.append(paragraphNode); | ||
* }); | ||
* return doc.getTextContent(); | ||
* } | ||
* ); | ||
* | ||
*/ | ||
declare function withLexicalDocument<T>({ roomId, nodes, client }: LiveblocksLexicalOptions, callback: (api: LiveblocksDocumentApi) => Promise<T> | T): Promise<T>; | ||
export { type LiveblocksDocumentApi, type LiveblocksLexicalOptions, withLexicalDocument }; |
@@ -169,3 +169,3 @@ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }// src/index.ts | ||
var PKG_NAME = "@liveblocks/node-lexical"; | ||
var PKG_VERSION = "2.0.0-alpha4"; | ||
var PKG_VERSION = "2.0.0-alpha5"; | ||
var PKG_FORMAT = "cjs"; | ||
@@ -194,2 +194,5 @@ | ||
const val = await callback({ | ||
/** | ||
* Fetches and resyncs the latest document with Liveblocks | ||
*/ | ||
refresh: async () => { | ||
@@ -203,2 +206,5 @@ const latest = new Uint8Array( | ||
}, | ||
/** | ||
* Provide a callback to modify documetns with Lexical's standard api. All calls are discrete. | ||
*/ | ||
update: async (modifyFn) => { | ||
@@ -217,2 +223,5 @@ editor.update(() => { | ||
}, | ||
/** | ||
* Helper function to easily provide the text content from the root, i.e. `$getRoot().getTextContent()` | ||
*/ | ||
getTextContent: () => { | ||
@@ -225,5 +234,11 @@ let content = ""; | ||
}, | ||
/** | ||
* Helper function to return editorState in JSON form | ||
*/ | ||
toJSON: () => { | ||
return editor.getEditorState().toJSON(); | ||
}, | ||
/** | ||
* Helper function to return editor state as Markdown | ||
*/ | ||
toMarkdown: () => { | ||
@@ -236,5 +251,11 @@ let markdown = ""; | ||
}, | ||
/** | ||
* Helper function to return the editor's current state | ||
*/ | ||
getEditorState: () => { | ||
return editor.getEditorState(); | ||
}, | ||
/** | ||
* Helper function to return the current headless editor instance | ||
*/ | ||
getLexicalEditor: () => { | ||
@@ -241,0 +262,0 @@ return editor; |
{ | ||
"name": "@liveblocks/node-lexical", | ||
"version": "2.0.0-alpha4", | ||
"version": "2.0.0-alpha5", | ||
"description": "A server-side utility that lets you modify lexical documents hosted in Liveblocks.", | ||
@@ -37,4 +37,4 @@ "license": "Apache-2.0", | ||
"dependencies": { | ||
"@liveblocks/core": "2.0.0-alpha4", | ||
"@liveblocks/node": "2.0.0-alpha4", | ||
"@liveblocks/core": "2.0.0-alpha5", | ||
"@liveblocks/node": "2.0.0-alpha5", | ||
"yjs": "^13.6.15" | ||
@@ -41,0 +41,0 @@ }, |
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
55362
558
+ Added@liveblocks/core@2.0.0-alpha5(transitive)
+ Added@liveblocks/node@2.0.0-alpha5(transitive)
- Removed@liveblocks/core@2.0.0-alpha4(transitive)
- Removed@liveblocks/node@2.0.0-alpha4(transitive)