@curvenote/schema
Version:
Schema and markdown parser for @curvenote/editor
71 lines (70 loc) • 2 kB
TypeScript
import type { GenericNode } from 'mystjs';
import type { NodeSpec, AttributeSpec, ParseRule } from 'prosemirror-model';
import type { MystNode } from '../spec';
import type { MdastOptions } from '../serialize/types';
export declare enum CaptionKind {
fig = "fig",
eq = "eq",
code = "code",
table = "table"
}
export declare enum ReferenceKind {
cite = "cite",
link = "link",
sec = "sec",
fig = "fig",
eq = "eq",
code = "code",
table = "table"
}
export declare enum NodeGroups {
'top' = "topblock",
'block' = "block",
'heading' = "heading",
'blockOrHeading' = "(block | heading)+",
'blockOrEquation' = "(block | equation)+",
'blockOrEquationOrHeading' = "(block | heading | equation)+",
'inline' = "inline",
'text' = "text",
'cite' = "cite",
'insideFigure' = "(figcaption | image | iframe | table | code_block){1,2}"
}
export declare enum MarkGroups {
'format' = "format"
}
declare type O = Record<string, any>;
export declare type NodeSpecAttrs<T extends O> = Record<keyof T, AttributeSpec>;
export interface MyParseRule<T extends O> extends ParseRule {
getAttrs?: (p: any) => T;
}
export declare type Props<T extends O = O> = T & O & {
key: string;
children?: GenericNode[];
};
export interface MyNodeSpec<T extends O, N extends MystNode> extends NodeSpec {
attrs: NodeSpecAttrs<T>;
parseDOM?: MyParseRule<T>[];
attrsFromMyst: (t: N, ts: GenericNode[]) => T;
toMyst: (props: Props<T>, opts: MdastOptions) => N;
}
export declare type NumberedNode = {
id: string | null;
label: string | null;
numbered: boolean;
};
export declare type AlignOptions = 'left' | 'center' | 'right';
export declare type Attr = {
name: string;
func: boolean | 'only';
default: string | false;
optional: boolean;
};
export declare type NodeDef = {
tag: string;
name: string;
mystType: string;
attrs: Attr[];
inline: boolean;
group: NodeGroups;
};
export {};