@curvenote/schema
Version:
Schema and markdown parser for @curvenote/editor
44 lines (43 loc) • 2.13 kB
TypeScript
import type { Node as ProsemirrorNode, Mark, Node } from 'prosemirror-model';
import type { MarkdownSerializerState } from 'prosemirror-markdown';
import type { MdSerializerState } from '../types';
export declare type MarkSerializerMethod = (state: MarkdownSerializerState, mark: Mark, parent: Node, index: number) => void;
declare type MarkSerializerSpec = {
/**
The string that should appear before a piece of content marked
by this mark, either directly or as a function that returns an
appropriate string.
*/
open: string | ((state: MarkdownSerializerState, mark: Mark, parent: Node, index: number) => string);
/**
The string that should appear after a piece of content marked by
this mark.
*/
close: string | ((state: MarkdownSerializerState, mark: Mark, parent: Node, index: number) => string);
/**
When `true`, this indicates that the order in which the mark's
opening and closing syntax appears relative to other mixable
marks can be varied. (For example, you can say `**a *b***` and
`*a **b***`, but not `` `a *b*` ``.)
*/
mixable?: boolean;
/**
When enabled, causes the serializer to move enclosing whitespace
from inside the marks to outside the marks. This is necessary
for emphasis marks as CommonMark does not permit enclosing
whitespace inside emphasis marks, see:
http:spec.commonmark.org/0.26/#example-330
*/
expelEnclosingWhitespace?: boolean;
/**
Can be set to `false` to disable character escaping in a mark. A
non-escaping mark has to have the highest precedence (must
always be the innermost mark).
*/
escape?: boolean;
};
export declare function backticksFor(node: ProsemirrorNode, side: number): string;
export declare function isPlainURL(link: Mark, href: string, parent: Node, index: number, side: number): boolean;
export declare function wrapMark(token: string, close?: MarkSerializerMethod): MarkSerializerSpec;
export declare function writeDirectiveOptions(state: MdSerializerState, options: Record<string, any>): void;
export {};