Source and component API
Look up syntax readers, field updates, and the guarded actions available to components.
Field codec
read derives fields from confirmed syntax ranges, while patch encodes precise source edits. You can install semantics without supplying a view.
@quirekit/msfe-coreParser-neutral semantic codec; rendering is optional and never owns persistence.
export interface SourceDefinition<Attrs extends object, Resource = unknown> {
readonly nodes: readonly string[];
readonly syntax?: InlineSyntax;
readonly placement?: "replace" | "before";
readonly showWhenActive?: boolean;
readonly measureHeight?: boolean;
readonly read: (document: SourceDocument, node: SourceNode) => Attrs | null;
readonly source?: (document: SourceDocument, node: SourceNode) => string;
readonly patch: (document: SourceDocument, node: SourceNode, patch: Partial<Attrs>) => SourceEdit | readonly SourceEdit[] | null;
readonly load?: (attrs: Readonly<Attrs>, signal: AbortSignal) => MsfeNodeViewResource<Resource> | Promise<MsfeNodeViewResource<Resource>>;
readonly renderer?: MsfeNodeViewRenderer;
}Documents and syntax ranges
Ranges use UTF-16 offsets with an exclusive end. Syntax access is a derived query, not a second persistent document.
@quirekit/msfe-coreRead-only accepted document access independent of the parser and view implementation.
export interface SourceDocument extends SourceText {
resolveReference(label: string): MarkdownReferenceResult;
}@quirekit/msfe-coreLazy parser-neutral syntax access; no duplicated persistent AST is allocated.
export interface SourceNode {
readonly kind: string;
readonly parentKind: string | null;
readonly from: number;
readonly to: number;
parent(): SourceNode | null;
child(kind: string): SourceNode | null;
children(kind?: string): readonly SourceNode[];
}Node components
attrs are derived from source. Use the supplied guarded actions to update fields, delete nodes, or reveal source. Previously held props may become stale after document changes.
@quirekit/msfe-coreSource-derived component inputs; actions validate this snapshot before changing source.
export interface MsfeNodeViewProps<Attrs extends object = object, Resource = unknown> {
readonly id: string;
readonly attrs: Readonly<Attrs>;
readonly readOnly: boolean;
readonly status: "ready" | "loading" | "error";
readonly resource: Resource | undefined;
getRange(): MsfeSourceRange | null;
updateAttributes(patch: Partial<Attrs>): MsfeResult;
deleteNode(): MsfeResult;
revealSource(): boolean;
}Definitions and parse demand
DefineSource separates reading, writing, fingerprints and resource acquisition. Resources do not replace persistent fields. See the node tutorial.
@quirekit/msfe-core@param definition - Typed source contract. @returns Installable source definition.
function defineSource<Attrs extends object, Resource = unknown>(definition: SourceDefinition<Attrs, Resource>): SourceSpecWhen semantic queries are pending, request parse demand and retry after accepted-state changes. This does not synchronously scan the whole file.
@quirekit/msfe-core@param state - Incomplete accepted snapshot. Records demand without synchronously advancing the parser.
function requestMarkdownParse(state: EditorState): voidQuery results
editor.querySource(name, range?) returns status and matches containing name, extension kind, attributes, range and SourceNode; read node.kind for the actual syntax name. Use UTF-16 logical coordinates. The default queries current selections, not every node in the file.
decodeMarkdownString, decodeMarkdownDestination and encodeMarkdownField serve distinct Markdown fields. Encode only changed fields instead of normalizing the entire file. See Command API for positions and captured intent.