Skip to main content

@lexical/y/server

Type Aliases​

UpdateRoots​

UpdateRoots = object

Defined in: packages/lexical-y/src/server.ts:25

Experimental

The result of inspectUpdateRoots.

Properties​

roots​

roots: Set<string>

Defined in: packages/lexical-y/src/server.ts:27

Root names the update writes to (inserts and deletes).

unresolved​

unresolved: number

Defined in: packages/lexical-y/src/server.ts:32

Structs and deleted ranges whose root could not be resolved: their parent is neither in the update nor in doc.

Functions​

inspectUpdateRoots()​

inspectUpdateRoots(update, doc?): UpdateRoots

Defined in: packages/lexical-y/src/server.ts:63

Experimental

Transport-agnostic server helper: the shared roots an incoming Yjs update writes to (inserts and deletions). Pass the server's copy of the document to resolve items nested in types, and deleted ranges, that the update does not contain. Linear in the update size (each struct's root is resolved once, lookups are binary searches).

Parameters​

update​

Uint8Array

doc?​

Doc

Returns​

UpdateRoots


isUpdateForLayout()​

isUpdateForLayout(update, options?): boolean

Defined in: packages/lexical-y/src/server.ts:196

Experimental

Whether an update writes only to the layout root (and so comes from an upgraded client). A server can reject other updates, for example in a y-websocket or Hocuspocus hook. Pass the server's document so that updates nested in existing types and deletions resolve.

Parameters​

update​

Uint8Array

options?​
doc?​

Doc

root?​

string

Returns​

boolean


writeUpgradeNotice()​

writeUpgradeNotice(doc, message?, oldRoot?, options?): void

Defined in: packages/lexical-y/src/server.ts:216

Experimental

Write a notice into an old layout's root (the Yjs 13 bindings' 'root-v2' XmlFragment, or the v1 'root' XmlText) so that a tab still running an old client shows it instead of an empty document. The notice is also recorded in an attribute of the layout root (lexical-y:notice), so that initializing the layout root next to it is not refused.

Parameters​

doc​

Doc

message?​

string = 'This document was upgraded. Please reload the page.'

oldRoot?​

"root" | "root-v2"

options?​
root?​

string

Returns​

void

References​

DEFAULT_ROOT_NAME​

Re-exports DEFAULT_ROOT_NAME


LAYOUT_VERSION​

Re-exports LAYOUT_VERSION