@lexical/y
Classes
YBinding
Defined in: packages/lexical-y/src/internal/Binding.ts:625
Experimental
A Yjs 14 binding for one editor and one shared root.
Every container (the root, and every node stored as its own Y.Node) holds one sequence of text, child nodes and line markers; see the package README for the layout.
Warnings (read only states, recoveries, the opt-in self-check) go to the
editor's onWarn, typed by their code (see YWarning and isYWarning), once a
remote change has been applied in full: never from inside a Yjs observer
or transaction. A handler that throws does not affect syncing.
Constructors
Constructor
new YBinding(
editor,doc,options):YBinding
Defined in: packages/lexical-y/src/internal/Binding.ts:924
Experimental
Parameters
editor
doc
options
Returns
Accessors
doc
Get Signature
get doc():
YDoc
Defined in: packages/lexical-y/src/internal/Binding.ts:897
Experimental
The shared document.
Returns
editor
Get Signature
get editor():
LexicalEditor
Defined in: packages/lexical-y/src/internal/Binding.ts:892
Experimental
The bound editor.
Returns
pins
Get Signature
get pins():
ReadonlyMap<string, {by?: readonlystring[];kind:StorageKind; }>
Defined in: packages/lexical-y/src/internal/Binding.ts:912
Experimental
Storage kinds the document records per node type (see the README).
Returns
ReadonlyMap<string, { by?: readonly string[]; kind: StorageKind; }>
root
Get Signature
get root():
YNode
Defined in: packages/lexical-y/src/internal/Binding.ts:902
Experimental
The shared root this binding reads and writes.
Returns
status
Get Signature
get status():
YBindingStatus
Defined in: packages/lexical-y/src/internal/Binding.ts:907
Experimental
See YBindingStatus; onStatus reports changes.
Returns
undoManager
Get Signature
get undoManager():
UndoManager|null
Defined in: packages/lexical-y/src/internal/Binding.ts:920
Experimental
The collaborative undo manager; null when undo is disabled.
Returns
UndoManager | null
Methods
$resolveCursor()
$resolveCursor(
cursor): {anchor:PointType;focus:PointType; } |null
Defined in: packages/lexical-y/src/internal/Binding.ts:5404
Experimental
Resolve a cursor to Lexical points (call inside a read or update).
Parameters
cursor
Returns
{ anchor: PointType; focus: PointType; } | null
dispose()
dispose():
void
Defined in: packages/lexical-y/src/internal/Binding.ts:1186
Experimental
Disconnect from the document and the editor (start returns this).
Returns
void
getCursor()
getCursor():
YCursor|null
Defined in: packages/lexical-y/src/internal/Binding.ts:5237
Experimental
The local selection as relative positions (JSON), or null.
Returns
YCursor | null
initialize()
initialize():
void
Defined in: packages/lexical-y/src/internal/Binding.ts:1248
Experimental
Call after the provider's first sync. An empty root is marked with this
layout and gets the editor's current content, unless an older layout's
root (root, root-v2) has content: such a document is read only, and
must be converted instead (a binding with convert: true writes the
layout root next to the old one). Anything else is read.
The initial content (including an update still pending, such as
editor.update(seed) right before this call) is not part of the undo
history. Into a pristine top-level root (one that has never held an
item or an attribute), it is written once, under a client id derived
from those exact bytes (see seedUpdate), applied to the document as they
are and read back like any document, so that two clients initializing
the same document with the same content at once write the same items
(one copy), and one id never holds two payloads; anywhere else, with
this client's own id.
Called before start() (from an extension's register, before
YCollabExtension starts the binding), it runs when the binding starts,
once the editor has its initial state.
Returns
void
redo()
redo():
boolean
Defined in: packages/lexical-y/src/internal/Binding.ts:4965
Experimental
Redo what undo undid; see undo.
Returns
boolean
start()
start(): () =>
void
Defined in: packages/lexical-y/src/internal/Binding.ts:950
Experimental
Start listening; read the document if it is already initialized.
Returns
() => void
undo()
undo():
boolean
Defined in: packages/lexical-y/src/internal/Binding.ts:4960
Experimental
Undo this client's last change in the document (collaborative undo). Returns whether there was one; false while the binding is not active.
Returns
boolean
Interfaces
YBindingOptions
Defined in: packages/lexical-y/src/internal/Binding.ts:353
Experimental
Options of YBinding (and YCollabExtension).
Properties
captureTimeout?
optionalcaptureTimeout?:number|null
Defined in: packages/lexical-y/src/internal/Binding.ts:365
Experimental
Undo capture timeout in ms (default 500); null disables undo.
clientIDRange?
optionalclientIDRange?:ClientIDRange
Defined in: packages/lexical-y/src/internal/Binding.ts:400
Experimental
The range of the document's client ids: 'uint53' (default, Yjs 14's
ids, left as they are) or 'uint32' (kept in 32 bits, for servers on
yrs before 0.28; see ClientIDRange).
convert?
optionalconvert?:boolean
Defined in: packages/lexical-y/src/internal/Binding.ts:394
Experimental
Initialize even when an older layout's root has content: for a converter writing the layout root of an existing document.
onStatus?
optionalonStatus?: (status) =>void
Defined in: packages/lexical-y/src/internal/Binding.ts:371
Experimental
Called when status changes, once the binding's work is done and Yjs is
idle (like warnings, never inside a Yjs observer or transaction). Several
changes in one such step report the last.
Parameters
status
Returns
void
root?
optionalroot?:YNode<any>
Defined in: packages/lexical-y/src/internal/Binding.ts:363
Experimental
The shared root to bind; defaults to doc.get('lexical-y').
schemaVersion
schemaVersion:
number
Defined in: packages/lexical-y/src/internal/Binding.ts:361
Experimental
The version of the app's document schema: its node types and the fields they store. Required: start at 1 and increase it whenever a node's stored fields or node types change. The document records the highest version that wrote to it; a binding whose version is lower opens it read only (UNSUPPORTED_SCHEMA_WARNING). An integer from 1.
selfCheck?
optionalselfCheck?:boolean
Defined in: packages/lexical-y/src/internal/Binding.ts:382
Experimental
Read every line a local write touched back from Yjs and compare it with
the editor; mismatches are reported to the editor's onWarn (see
SELF_CHECK_WARNING).
Structural changes (and remote changes) also compare a fresh read of
the whole container: every time for containers of up to 256 lines and
nodes, and with probability 256 / size for bigger ones, so the expected
cost of an edit stays bounded. Default: off. A debugging aid: turn it
on in tests and development builds to catch binding bugs.
selfCheckSample?
optionalselfCheckSample?:number
Defined in: packages/lexical-y/src/internal/Binding.ts:389
Experimental
The fraction of changes the self-check samples (default 1): of local
writes, and of remote changes, where a sampled check that finds the
editor differing from the shared content also reads those containers
again (see selfCheck).
YCollabConfig
Defined in: packages/lexical-y/src/internal/YExtension.ts:41
Experimental
The configuration of YCollabExtension.
Properties
captureTimeout
captureTimeout:
number|null
Defined in: packages/lexical-y/src/internal/YExtension.ts:66
Experimental
Undo capture timeout in ms; null disables collaborative undo.
clientIDRange
clientIDRange:
ClientIDRange
Defined in: packages/lexical-y/src/internal/YExtension.ts:68
Experimental
See YBindingOptions.clientIDRange (default 'uint53').
convert
convert:
boolean
Defined in: packages/lexical-y/src/internal/YExtension.ts:77
Experimental
See YBindingOptions.convert (default false).
doc
doc:
YDoc|null
Defined in: packages/lexical-y/src/internal/YExtension.ts:46
Experimental
The shared document, made by createYDoc (with a stored state:
createYDoc(state)). Required.
root
root:
YNode<any> |null
Defined in: packages/lexical-y/src/internal/YExtension.ts:58
Experimental
The shared root; defaults to doc.get('lexical-y').
schemaVersion
schemaVersion:
number
Defined in: packages/lexical-y/src/internal/YExtension.ts:56
Experimental
The version of the app's document schema: its node types and the fields
they store. Required: start at 1 and increase it whenever a node's
stored fields or node types change. The document records the highest
version that wrote to it, and a client whose version is lower opens it
read only (UNSUPPORTED_SCHEMA_WARNING), so an out-of-date client never
edits content it cannot read in full. An integer from 1; the extension
throws without one.
selfCheck
selfCheck:
boolean|null
Defined in: packages/lexical-y/src/internal/YExtension.ts:73
Experimental
See YBindingOptions.selfCheck; null keeps the default (off). Warnings
go to the editor's onWarn.
selfCheckSample
selfCheckSample:
number|null
Defined in: packages/lexical-y/src/internal/YExtension.ts:75
Experimental
See YBindingOptions.selfCheckSample; null keeps the default (1).
synced
synced:
boolean
Defined in: packages/lexical-y/src/internal/YExtension.ts:64
Experimental
Initialize as soon as the binding starts: use it when the document is
already synced (a headless writer, a converter, tests). Otherwise call
binding.initialize() after the provider's first sync.
YCursor
Defined in: packages/lexical-y/src/internal/Binding.ts:407
Experimental
A selection as Yjs relative positions, from
YBinding#getCursor (for an awareness-based cursor UI).
Properties
anchor
anchor:
unknown
Defined in: packages/lexical-y/src/internal/Binding.ts:408
Experimental
focus
focus:
unknown
Defined in: packages/lexical-y/src/internal/Binding.ts:409
Experimental
YDoc
Defined in: packages/lexical-y/src/internal/YDoc.ts:38
Experimental
A Y.Doc made by createYDoc: Yjs's format cleanup
is off from its creation, so applying an update to it never deletes
format items of its own accord.
Extends
Properties
_item
_item:
any
Defined in: @y/y/dist/src/utils/Doc.d.ts:66
Experimental
If this document is a subdocument - a document integrated into another document - then _item is defined.
Inherited from
Doc._item
_observers
Defined in: lib0/dist/observable.d.ts:15
Experimental
Some desc.
Inherited from
Doc._observers
_transaction
_transaction:
any
Defined in: @y/y/dist/src/utils/Doc.d.ts:53
Experimental
Inherited from
Doc._transaction
_transactionCleanups
_transactionCleanups:
Transaction[]
Defined in: @y/y/dist/src/utils/Doc.d.ts:57
Experimental
Inherited from
Doc._transactionCleanups
[createdByCreateYDoc]
readonly[createdByCreateYDoc]:true
Defined in: packages/lexical-y/src/internal/YDoc.ts:40
Experimental
Phantom brand: only createYDoc makes a YDoc.
$type
Defined in: @y/y/dist/src/utils/Doc.d.ts:140
Experimental
Inherited from
Doc.$type
autoLoad
autoLoad:
boolean
Defined in: @y/y/dist/src/utils/Doc.d.ts:68
Experimental
Inherited from
Doc.autoLoad
cleanupFormatting
cleanupFormatting:
boolean
Defined in: @y/y/dist/src/utils/Doc.d.ts:44
Experimental
Inherited from
Doc.cleanupFormatting
clientID
clientID:
number
Defined in: @y/y/dist/src/utils/Doc.d.ts:40
Experimental
Inherited from
Doc.clientID
collectionid
collectionid:
string|null
Defined in: @y/y/dist/src/utils/Doc.d.ts:42
Experimental
Inherited from
Doc.collectionid
gc
gc:
boolean
Defined in: @y/y/dist/src/utils/Doc.d.ts:38
Experimental
Inherited from
Doc.gc
gcFilter
gcFilter: (
arg0) =>boolean
Defined in: @y/y/dist/src/utils/Doc.d.ts:39
Experimental
Parameters
arg0
Item
Returns
boolean
Inherited from
Doc.gcFilter
guid
guid:
string
Defined in: @y/y/dist/src/utils/Doc.d.ts:41
Experimental
Inherited from
Doc.guid
isDestroyed
isDestroyed:
boolean
Defined in: @y/y/dist/src/utils/Doc.d.ts:85
Experimental
Inherited from
Doc.isDestroyed
isLoaded
isLoaded:
boolean
Defined in: @y/y/dist/src/utils/Doc.d.ts:76
Experimental
This is set to true when the persistence provider loaded the document from the database or when the sync event fires.
Note that not all providers implement this feature. Provider authors are encouraged to fire the load event when the doc content is loaded from the database.
Inherited from
Doc.isLoaded
isSuggestionDoc
isSuggestionDoc:
boolean
Defined in: @y/y/dist/src/utils/Doc.d.ts:43
Experimental
Inherited from
Doc.isSuggestionDoc
isSynced
isSynced:
boolean
Defined in: @y/y/dist/src/utils/Doc.d.ts:84
Experimental
This is set to true when the connection provider has successfully synced with a backend.
Note that when using peer-to-peer providers this event may not provide very useful.
Also note that not all providers implement this feature. Provider authors are encouraged to fire
the sync event when the doc has been synced (with true as a parameter) or if connection is
lost (with false as a parameter).
Inherited from
Doc.isSynced
meta
meta:
any
Defined in: @y/y/dist/src/utils/Doc.d.ts:69
Experimental
Inherited from
Doc.meta
share
Defined in: @y/y/dist/src/utils/Doc.d.ts:48
Experimental
Inherited from
Doc.share
shouldLoad
shouldLoad:
boolean
Defined in: @y/y/dist/src/utils/Doc.d.ts:67
Experimental
Inherited from
Doc.shouldLoad
store
store:
StructStore
Defined in: @y/y/dist/src/utils/Doc.d.ts:49
Experimental
Inherited from
Doc.store
subdocs
Defined in: @y/y/dist/src/utils/Doc.d.ts:61
Experimental
Inherited from
Doc.subdocs
whenLoaded
whenLoaded:
Promise<any>
Defined in: @y/y/dist/src/utils/Doc.d.ts:89
Experimental
Promise that resolves once the document has been loaded from a persistence provider.
Inherited from
Doc.whenLoaded
whenSynced
whenSynced:
Promise<any>
Defined in: @y/y/dist/src/utils/Doc.d.ts:90
Experimental
Inherited from
Doc.whenSynced
Methods
destroy()
destroy():
void
Defined in: lib0/dist/observable.d.ts:45
Experimental
Returns
void
Inherited from
Doc.destroy
emit()
emit<
NAME>(name,args):void
Defined in: lib0/dist/observable.d.ts:44
Experimental
Emit a named event. All registered event listeners that listen to the specified name will receive the event.
Type Parameters
NAME
NAME extends "load" | "update" | "sync" | "destroy" | "updateV2" | "beforeAllTransactions" | "beforeTransaction" | "beforeObserverCalls" | "afterTransaction" | "afterTransactionCleanup" | "afterAllTransactions" | "subdocs"
Parameters
name
NAME
The event name.
args
Parameters<DocEvents[NAME]>
The arguments that are applied to the event listener.
Returns
void
Todo
This should catch exceptions
Inherited from
Doc.emit
get()
get(
key?,name?):YNode
Defined in: @y/y/dist/src/utils/Doc.d.ts:128
Experimental
Define a shared data type.
Multiple calls of ydoc.get(name) yield the same result
and do not overwrite each other. I.e.
ydoc.get(name) === ydoc.get(name)
After this method is called, the type is also available on ydoc.share.get(name).
Parameters
key?
string
name?
string | null
Type-name
Returns
Inherited from
Doc.get
getSubdocGuids()
getSubdocGuids():
Set<string>
Defined in: @y/y/dist/src/utils/Doc.d.ts:100
Experimental
Returns
Set<string>
Inherited from
Doc.getSubdocGuids
getSubdocs()
Defined in: @y/y/dist/src/utils/Doc.d.ts:99
Experimental
Returns
Inherited from
Doc.getSubdocs
load()
load():
void
Defined in: @y/y/dist/src/utils/Doc.d.ts:98
Experimental
Notify the parent document that you request to load data into this subdocument (if it is a subdocument).
load() might be used in the future to request any provider to load the most current data.
It is safe to call load() multiple times.
Returns
void
Inherited from
Doc.load
off()
off<
NAME>(name,f):void
Defined in: lib0/dist/observable.d.ts:33
Experimental
Type Parameters
NAME
NAME extends "load" | "update" | "sync" | "destroy" | "updateV2" | "beforeAllTransactions" | "beforeTransaction" | "beforeObserverCalls" | "afterTransaction" | "afterTransactionCleanup" | "afterAllTransactions" | "subdocs"
Parameters
name
NAME
f
DocEvents[NAME]
Returns
void
Inherited from
Doc.off
on()
on<
NAME>(name,f):DocEvents[NAME]
Defined in: lib0/dist/observable.d.ts:21
Experimental
Type Parameters
NAME
NAME extends "load" | "update" | "sync" | "destroy" | "updateV2" | "beforeAllTransactions" | "beforeTransaction" | "beforeObserverCalls" | "afterTransaction" | "afterTransactionCleanup" | "afterAllTransactions" | "subdocs"
Parameters
name
NAME
f
DocEvents[NAME]
Returns
DocEvents[NAME]
Inherited from
Doc.on
once()
once<
NAME>(name,f):void
Defined in: lib0/dist/observable.d.ts:27
Experimental
Type Parameters
NAME
NAME extends "load" | "update" | "sync" | "destroy" | "updateV2" | "beforeAllTransactions" | "beforeTransaction" | "beforeObserverCalls" | "afterTransaction" | "afterTransactionCleanup" | "afterAllTransactions" | "subdocs"
Parameters
name
NAME
f
DocEvents[NAME]
Returns
void
Inherited from
Doc.once
toJSON()
toJSON():
object
Defined in: @y/y/dist/src/utils/Doc.d.ts:137
Experimental
Converts the entire document into a js object, recursively traversing each yjs type Doesn't log types that have not been defined (using ydoc.getType(..)).
Returns
object
Deprecated
Do not use this method and rather call toJSON directly on the shared types.
Inherited from
Doc.toJSON
transact()
transact<
T>(f,origin?,local?):T
Defined in: @y/y/dist/src/utils/Doc.d.ts:113
Experimental
Changes that happen inside of a transaction are bundled. This means that the observer fires after the transaction is finished and that all changes that happened inside of the transaction are sent as one message to the other peers.
Type Parameters
T
T
Parameters
f
(arg0) => T
The function that should be executed as a transaction
origin?
any
Origin of who started the transaction. Will be stored on transaction.origin
local?
boolean
Returns
T
T
Inherited from
Doc.transact
YRecoveredReadData
Defined in: packages/lexical-y/src/internal/Warnings.ts:259
Experimental
data of a RECOVERED_READ_WARNING: a remote change
('remote-change') or a read of the binding's own ('reread') threw
error, and the editor was rebuilt from the document.
Properties
error
readonlyerror:unknown
Defined in: packages/lexical-y/src/internal/Warnings.ts:261
Experimental
reason
readonlyreason:"remote-change"|"reread"
Defined in: packages/lexical-y/src/internal/Warnings.ts:260
Experimental
YRecoveredWriteData
Defined in: packages/lexical-y/src/internal/Warnings.ts:268
Experimental
data of a RECOVERED_WRITE_WARNING: writing a local change
threw error, and the document was rewritten from the editor.
Properties
error
readonlyerror:unknown
Defined in: packages/lexical-y/src/internal/Warnings.ts:270
Experimental
reason
readonlyreason:"local-change"
Defined in: packages/lexical-y/src/internal/Warnings.ts:269
Experimental
YSelfCheckData
Defined in: packages/lexical-y/src/internal/Warnings.ts:249
Experimental
data of a SELF_CHECK_WARNING: the self-check found the
editor and the document disagree after a local change ('local') or a
remote one ('remote', read again in full).
Properties
problems
readonlyproblems: readonlystring[]
Defined in: packages/lexical-y/src/internal/Warnings.ts:251
Experimental
reason
readonlyreason:"local"|"remote"
Defined in: packages/lexical-y/src/internal/Warnings.ts:250
Experimental
YStoredAs
Defined in: packages/lexical-y/src/internal/Warnings.ts:156
Experimental
How the document stores a node type, or how a class would.
Properties
by?
readonlyoptionalby?: readonlystring[]
Defined in: packages/lexical-y/src/internal/Warnings.ts:159
Experimental
A group's or format's identity: the fields it merges by.
kind
readonlykind:"format"|"nested"|"line"|"group"
Defined in: packages/lexical-y/src/internal/Warnings.ts:157
Experimental
YUnknownNodeTypesData
Defined in: packages/lexical-y/src/internal/Warnings.ts:188
Experimental
data of an UNKNOWN_NODE_TYPES_WARNING (the binding is read
only): types the editor does not register ('unregistered'), or slots the
document holds that are not a block node ('malformed-slot': the slot's
key, or the type of the inline node in it).
Properties
reason
readonlyreason:"unregistered"|"malformed-slot"
Defined in: packages/lexical-y/src/internal/Warnings.ts:189
Experimental
types
readonlytypes: readonlystring[]
Defined in: packages/lexical-y/src/internal/Warnings.ts:190
Experimental
YUnreadableContentData
Defined in: packages/lexical-y/src/internal/Warnings.ts:202
Experimental
data of an UNKNOWN_NODE_TYPES_WARNING whose reason is
'unreadable' (the binding is read only): stored content the editor's
classes throw on when they read it (its importJSON or updateFromJSON, a
NodeState parse), of types, with the first error thrown. The editor
shows the rest of the document. types is empty, and the editor keeps
what it showed before and reads nothing more, where a read failed without
a class to name (it threw again on a fresh read of the document).
Properties
error
readonlyerror:unknown
Defined in: packages/lexical-y/src/internal/Warnings.ts:205
Experimental
reason
readonlyreason:"unreadable"
Defined in: packages/lexical-y/src/internal/Warnings.ts:203
Experimental
types
readonlytypes: readonlystring[]
Defined in: packages/lexical-y/src/internal/Warnings.ts:204
Experimental
YUnsupportedEditData
Defined in: packages/lexical-y/src/internal/Warnings.ts:240
Experimental
data of an UNSUPPORTED_EDIT_WARNING: a local update
(code that edits the editor, which is not editable) changed content while
the binding is read only ('read-only').
Properties
reason
readonlyreason:"read-only"
Defined in: packages/lexical-y/src/internal/Warnings.ts:241
Experimental
YUnsupportedSlotsData
Defined in: packages/lexical-y/src/internal/Warnings.ts:214
Experimental
data of an UNSUPPORTED_SLOTS_WARNING (the change is not
written and the binding is read only): types hold named slots on a node
stored as a line, a format or a group ('stored-host'), or on the root
('root').
Properties
reason
readonlyreason:"root"|"stored-host"
Defined in: packages/lexical-y/src/internal/Warnings.ts:215
Experimental
types
readonlytypes: readonlystring[]
Defined in: packages/lexical-y/src/internal/Warnings.ts:216
Experimental
YUnsyncedValueData
Defined in: packages/lexical-y/src/internal/Warnings.ts:324
Experimental
data of an UNSYNCED_VALUE_WARNING: property
('<type>.<field>' or 'NodeState <key>') holds a value that is not plain
JSON, so it is not synchronized.
Properties
property
readonlyproperty:string
Defined in: packages/lexical-y/src/internal/Warnings.ts:326
Experimental
reason
readonlyreason:"not-json"
Defined in: packages/lexical-y/src/internal/Warnings.ts:325
Experimental
Type Aliases
ClientIDRange
ClientIDRange =
"uint53"|"uint32"
Defined in: packages/lexical-y/src/internal/ClientID.ts:25
Experimental
The range of the client ids a document writes with.
'uint53': Yjs 14's default (random 53-bit ids).'uint32': ids that fit in 32 bits, for servers that read client ids as 32-bit numbers (yrs before 0.28, e.g. y-crdt relays on 0.23): with a 53-bit id, such a server stores the author's content under a truncated id, and the author receives its own content back as another client's on reconnect, duplicating the document.
StorageKind
StorageKind =
"line"|"format"|"group"|"nested"
Defined in: packages/lexical-y/src/internal/Schema.ts:270
Experimental
How @lexical/y stores an element type; see describeStorage.
YBindingStatus
YBindingStatus =
"pending"|"active"|"readonly"
Defined in: packages/lexical-y/src/internal/Binding.ts:340
Experimental
The state of a YBinding.
YDocOptions
YDocOptions =
ConstructorParameters<typeofDoc>[0]
Defined in: packages/lexical-y/src/internal/YDoc.ts:44
Experimental
The options of new Y.Doc(options).
YNestedFallbackData
YNestedFallbackData = {
method:string;reason:"merge-override";type:string; } | {properties: readonlystring[];reason:"undeclared-properties";type:string; } | {reason:Exclude<YNestedFallbackReason,"merge-override"|"undeclared-properties">;type:string; }
Defined in: packages/lexical-y/src/internal/Warnings.ts:300
Experimental
data of a NESTED_FALLBACK_WARNING.
YNestedFallbackReason
YNestedFallbackReason =
"merge-override"|"inline-slots"|"inline-incomplete-schema"|"type-name"|"merge-incomplete-schema"|"merge-slots"|"group-children"|"group-state-merge"|"group-incomplete-schema"|"undeclared-properties"
Defined in: packages/lexical-y/src/internal/Warnings.ts:277
Experimental
Why a class type whose declarations make it a line, a
format or a group is stored as a nested node.
YStorageMismatchData
YStorageMismatchData = {
found:unknown;key:string;reason:"malformed";type:string; } | {declared:YStoredAs;reason:"declaration-changed";stored:YStoredAs;type:string; }
Defined in: packages/lexical-y/src/internal/Warnings.ts:166
Experimental
data of a STORAGE_MISMATCH_WARNING (the binding is read
only), one per node type.
Union Members
Type Literal
{ found: unknown; key: string; reason: "malformed"; type: string; }
The record at key for type is not a storage record.
Type Literal
{ declared: YStoredAs; reason: "declaration-changed"; stored: YStoredAs; type: string; }
The class of type cannot be stored as the document stores it.
YUnsupportedConfigData
YUnsupportedConfigData = {
options: readonlystring[];reason:"repair-transforms"; } | {reason:"cleanup-formatting"; }
Defined in: packages/lexical-y/src/internal/Warnings.ts:223
Experimental
data of an UNSUPPORTED_CONFIG_WARNING (nothing is written
and the binding is read only), one warning per reason.
Union Members
Type Literal
{ options: readonly string[]; reason: "repair-transforms"; }
options ('<extension>.<option>') are set to a value the binding
cannot write with.
Type Literal
{ reason: "cleanup-formatting"; }
The document runs Yjs's format cleanup (doc.cleanupFormatting is not
false): it was not made by createYDoc.
YUnsupportedLayoutData
YUnsupportedLayoutData = {
found:number;reason:"newer";supported:number; } | {found:unknown;key:string;reason:"malformed";supported:number; } | {reason:"missing"|"removed";supported:number; } | {reason:"legacy-roots";roots: readonlystring[];supported:number; }
Defined in: packages/lexical-y/src/internal/Warnings.ts:106
Experimental
data of an UNSUPPORTED_LAYOUT_WARNING (the binding is read
only). supported: the newest layout this version reads (it reads 1 to
supported).
Union Members
Type Literal
{ found: number; reason: "newer"; supported: number; }
The layout record names a newer layout, found.
Type Literal
{ found: unknown; key: string; reason: "malformed"; supported: number; }
The record at key is not a layout record; found is its value.
Type Literal
{ reason: "missing" | "removed"; supported: number; }
The root has content but no layout record ('missing'), or the record
was removed while the binding was writing ('removed').
Type Literal
{ reason: "legacy-roots"; roots: readonly string[]; supported: number; }
Older layouts' roots, roots, hold content.
YUnsupportedSchemaData
YUnsupportedSchemaData = {
found:number;reason:"newer";supported:number; } | {found:unknown;key:string;reason:"malformed";supported:number; }
Defined in: packages/lexical-y/src/internal/Warnings.ts:136
Experimental
data of an UNSUPPORTED_SCHEMA_WARNING (the binding is read
only). supported: the binding's schemaVersion.
Union Members
Type Literal
{ found: number; reason: "newer"; supported: number; }
A client whose schemaVersion is found, higher than supported, wrote
to the document: the app is out of date (render your own banner, such as
one that asks to reload).
Type Literal
{ found: unknown; key: string; reason: "malformed"; supported: number; }
The record at key is not a schema record; found is its value.
YWarning
YWarning =
{ [C in YWarningCode]: LexicalWarning & { code: C; data: YWarningData<C> } }[YWarningCode]
Defined in: packages/lexical-y/src/internal/Warnings.ts:353
Experimental
A warning the binding passes to the editor's onWarn: a
LexicalWarning whose code decides the type of its data (narrow it
with isYWarning, then switch over code, and over data.reason).
YWarningCode
YWarningCode = typeof
UNSUPPORTED_LAYOUT_WARNING| typeofUNKNOWN_NODE_TYPES_WARNING| typeofSTORAGE_MISMATCH_WARNING| typeofSELF_CHECK_WARNING| typeofRECOVERED_READ_WARNING| typeofRECOVERED_WRITE_WARNING| typeofNESTED_FALLBACK_WARNING| typeofUNSYNCED_VALUE_WARNING| typeofUNSUPPORTED_SLOTS_WARNING| typeofUNSUPPORTED_CONFIG_WARNING| typeofUNSUPPORTED_EDIT_WARNING| typeofUNSUPPORTED_SCHEMA_WARNING
Defined in: packages/lexical-y/src/internal/Warnings.ts:87
Experimental
The codes of the LexicalWarnings the binding passes to the
editor's onWarn. Codes are public API: a code is never renamed, and never
reused for another condition; new codes may be added in any release.
YWarningData
YWarningData<
C> =YWarningDataByCode[C]
Defined in: packages/lexical-y/src/internal/Warnings.ts:346
Experimental
The data of the warnings with code C.
Type Parameters
C
C extends YWarningCode
Variables
DEFAULT_ROOT_NAME
constDEFAULT_ROOT_NAME:"lexical-y"='lexical-y'
Defined in: packages/lexical-y/src/internal/constants.ts:17
Experimental
The default name of the shared root, which @lexical/yjs
clients never write to (they use root and root-v2).
LAYOUT_VERSION
constLAYOUT_VERSION:2=2
Defined in: packages/lexical-y/src/internal/constants.ts:35
Experimental
The newest layout version this binding reads and writes. A new document records version 1; the first member entry of a set-valued NodeState written into a document also records 2 (clients that only read version 1 then open it read only instead of missing the members).
NESTED_FALLBACK_WARNING
constNESTED_FALLBACK_WARNING:"@lexical/y/nested-fallback"='@lexical/y/nested-fallback'
Defined in: packages/lexical-y/src/internal/Warnings.ts:50
Experimental
A class whose declarations make it a line, a format or a
group is stored as a nested node. Once per class and reason. data:
YNestedFallbackData.
RECOVERED_READ_WARNING
constRECOVERED_READ_WARNING:"@lexical/y/recovered-read"='@lexical/y/recovered-read'
Defined in: packages/lexical-y/src/internal/Warnings.ts:39
Experimental
A change could not be read: the editor was rebuilt from the
document. data: YRecoveredReadData.
RECOVERED_WRITE_WARNING
constRECOVERED_WRITE_WARNING:"@lexical/y/recovered-write"='@lexical/y/recovered-write'
Defined in: packages/lexical-y/src/internal/Warnings.ts:44
Experimental
A local change could not be written: the document was
rewritten from the editor. data: YRecoveredWriteData.
SELF_CHECK_WARNING
constSELF_CHECK_WARNING:"@lexical/y/self-check"='@lexical/y/self-check'
Defined in: packages/lexical-y/src/internal/Warnings.ts:34
Experimental
The self-check (selfCheck, off by default) found the editor
and the document disagree. data: YSelfCheckData.
STORAGE_MISMATCH_WARNING
constSTORAGE_MISMATCH_WARNING:"@lexical/y/storage-mismatch"='@lexical/y/storage-mismatch'
Defined in: packages/lexical-y/src/internal/Warnings.ts:29
Experimental
The document stores a node type in a way its class cannot be
stored: read only. data: YStorageMismatchData.
UNKNOWN_NODE_TYPES_WARNING
constUNKNOWN_NODE_TYPES_WARNING:"@lexical/y/unknown-node-types"='@lexical/y/unknown-node-types'
Defined in: packages/lexical-y/src/internal/Warnings.ts:24
Experimental
The document has node types the editor cannot build, or
stored content its classes throw on: read only. data:
YUnknownNodeTypesData, or YUnreadableContentData.
UNSUPPORTED_CONFIG_WARNING
constUNSUPPORTED_CONFIG_WARNING:"@lexical/y/unsupported-config"='@lexical/y/unsupported-config'
Defined in: packages/lexical-y/src/internal/Warnings.ts:66
Experimental
The editor or the document is configured in a way the
binding cannot write with: nothing is written, read only. data:
YUnsupportedConfigData.
UNSUPPORTED_EDIT_WARNING
constUNSUPPORTED_EDIT_WARNING:"@lexical/y/unsupported-edit"='@lexical/y/unsupported-edit'
Defined in: packages/lexical-y/src/internal/Warnings.ts:74
Experimental
A local update changed the editor while the binding is read
only: nothing is written, and what it changed is read again (once the
document cannot be read, the editor shows what it showed before the update
again), so the editor keeps showing the document. Reported once each time
the binding goes read only. data: YUnsupportedEditData.
UNSUPPORTED_LAYOUT_WARNING
constUNSUPPORTED_LAYOUT_WARNING:"@lexical/y/unsupported-layout"='@lexical/y/unsupported-layout'
Defined in: packages/lexical-y/src/internal/Warnings.ts:18
Experimental
The document's layout is one this version cannot read or
write: read only. data: YUnsupportedLayoutData.
UNSUPPORTED_SCHEMA_WARNING
constUNSUPPORTED_SCHEMA_WARNING:"@lexical/y/unsupported-schema"='@lexical/y/unsupported-schema'
Defined in: packages/lexical-y/src/internal/Warnings.ts:80
Experimental
A client of a newer version of the app (a higher
schemaVersion) wrote to the document: read only. data:
YUnsupportedSchemaData.
UNSUPPORTED_SLOTS_WARNING
constUNSUPPORTED_SLOTS_WARNING:"@lexical/y/unsupported-slots"='@lexical/y/unsupported-slots'
Defined in: packages/lexical-y/src/internal/Warnings.ts:60
Experimental
A node holds named slots where the document cannot store
them: not written, read only. data: YUnsupportedSlotsData.
UNSYNCED_VALUE_WARNING
constUNSYNCED_VALUE_WARNING:"@lexical/y/unsynced-value"='@lexical/y/unsynced-value'
Defined in: packages/lexical-y/src/internal/Warnings.ts:55
Experimental
A node property or NodeState value is not plain JSON, so it
is not synchronized. Once per property. data: YUnsyncedValueData.
YCollabExtension
constYCollabExtension:LexicalExtension<YCollabConfig,"@lexical/y/Collab", {binding:YBinding;status:ReadonlySignal<YBindingStatus>; },unknown>
Defined in: packages/lexical-y/src/internal/YExtension.ts:95
Experimental
Binds the editor to a Yjs 14 document with the block-marker
layout, and provides collaborative undo (UNDO_COMMAND / REDO_COMMAND,
CAN_UNDO_COMMAND / CAN_REDO_COMMAND). Its output has the binding and a
status signal ('pending' until the layout record is read, then 'active'
or 'readonly'). It conflicts with the history extensions.
The binding starts once the editor has its initial state: after every
extension has registered, and after InitialStateExtension has applied
$initialEditorState. That state is only ever the content of an empty
document (initialize() writes it there; called while extensions
register, it runs when the binding starts). On a document that has
content, the editor shows the document. An extension that depends on this
one and changes content in its own afterRegistration makes an edit.
Functions
createYDoc()
createYDoc(
state?,options?):YDoc
Defined in: packages/lexical-y/src/internal/YDoc.ts:57
Experimental
A Y.Doc for @lexical/y: a client's (YCollabExtension's
doc), or a relay's or server's that loads a document's state (to store,
compact or merge it). Yjs's format cleanup is turned off
(cleanupFormatting = false) before anything is applied to it: applying
an update to a document with it on deletes format items the binding keeps,
and the document then reads differently from its peers once someone types
there. state, a stored state, is applied when given; options are those
of new Y.Doc(options) (the default document is garbage collected, as
clients store one). Merging updates with mergeUpdates needs no document.
Parameters
state?
Uint8Array<ArrayBufferLike> | null
options?
Returns
describeStorage()
describeStorage(
editor,binding?):Record<string,StorageKind|"text">
Defined in: packages/lexical-y/src/internal/Describe.ts:30
Experimental
How @lexical/y stores each node type: 'line', 'format', 'group' or
'nested' for elements (derived from the classes' $config()
declarations, or the kind a document recorded when binding is given),
'text' for text and line breaks, 'nested' for decorators. The root is
left out.
Parameters
editor
binding?
pins
ReadonlyMap<string, { kind: StorageKind; }>
Returns
Record<string, StorageKind | "text">
isYWarning()
isYWarning(
error):error is YWarning
Defined in: packages/lexical-y/src/internal/Warnings.ts:379
Experimental
Whether error (what the editor's onWarn receives) is a
warning of the binding's, typed by its code.
Parameters
error
unknown
Returns
error is YWarning