Collects the markers a USJ document actually uses, for passing to a read-only editor as
nodes.extraValidMarkers so it doesn't warn "Unexpected marker" for non-built-in markers
(e.g. handbook/commentary markers like \pn, \jmp). The set is scoped per-resource to the
displayed USJ — never a global list — and is additive, so listing built-in markers is a harmless
no-op.
The returned array keeps a stable identity as long as the SET of markers doesn't change, even
across new usj object identities (every fetch produces a fresh usj object). This matters
because editor options are typically memoized on this array: a churning identity would rebuild
options on every fetch and force the editor to reconcile its Lexical config (a full
re-serialize when view is part of those options, and — for panes that apply external annotation
marks — the destruction of every applied mark). Keying on the sorted marker VALUE avoids that
churn; sorting makes the key depend only on the set, not first-seen order, and order does not
affect marker validity so this is behavior-neutral for the editor.
Intentionally returns every marker the resource uses — appropriate for a read-only panel where
extraValidMarkers only silences a warn-only diagnostic. See collectUsjMarkers for the
every-marker trade-off.
Parameters
usj: undefined|Usj
The USJ being displayed, or undefined while it is still loading.
Returns string[]
The extra valid markers, with a stable array identity while the marker set is unchanged.
Empty when usj is undefined or uses no markers.
Collects the markers a USJ document actually uses, for passing to a read-only editor as marker" for non-built-in markers
(e.g. handbook/commentary markers like
nodes.extraValidMarkersso it doesn't warn "Unexpected\pn,\jmp). The set is scoped per-resource to the displayed USJ — never a global list — and is additive, so listing built-in markers is a harmless no-op.The returned array keeps a stable identity as long as the SET of markers doesn't change, even across new
usjobject identities (every fetch produces a freshusjobject). This matters because editoroptionsare typically memoized on this array: a churning identity would rebuildoptionson every fetch and force the editor to reconcile its Lexical config (a full re-serialize whenviewis part of those options, and — for panes that apply external annotation marks — the destruction of every applied mark). Keying on the sorted marker VALUE avoids that churn; sorting makes the key depend only on the set, not first-seen order, and order does not affect marker validity so this is behavior-neutral for the editor.Intentionally returns every marker the resource uses — appropriate for a read-only panel where
extraValidMarkersonly silences a warn-only diagnostic. SeecollectUsjMarkersfor the every-marker trade-off.