import { Node, Slice, Schema, MarkType, NodeType } from 'ak-editor-prosemirror'; /** * Represents a ProseMirror "position" in a document. */ export declare type position = number; /** * A useful feature of the builder is being able to declaratively mark positions * in content using the curly braces e.g. `{<>}`. * * These positions are called "refs" (inspired by React), and are tracked on * every node in the tree that has a ref on any of its descendants. */ export declare type Refs = { [name: string]: position; }; /** * Content that contains refs information. */ export declare type RefsContentItem = RefsNode | RefsTracker; /** * Content node or mark builders can consume, e.g. * * const builder = nodeFactory('p'); * builder('string'); * builder(aNode); * builder(aRefsNode); * builder(aRefsTracker); * builder([aNode, aRefsNode, aRefsTracker]); */ export declare type BuilderContent = string | Node | RefsContentItem | (Node | RefsContentItem)[]; /** * ProseMirror doesn't support empty text nodes, which can be quite * inconvenient when you want to capture a position ref without introducing * text. * * Take a couple of examples: * * p('{<>}') * p('Hello ', '{<>}', 'world!') * * After the ref syntax is stripped you're left with: * * p('') * p('Hello ', '', 'world!') * * This violates the rule of text nodes being non-empty. This class solves the * problem by providing an alternative data structure that *only* stores refs, * and can be used in scenarios where an empty text would be forbidden. * * This is done under the hood when using `text()` factory, and instead of * always returning a text node, it'll instead return one of two things: * * - a text node -- when given a non-empty string * - a refs tracker -- when given a string that *only* contains refs. */ export declare class RefsTracker { refs: Refs; } /** * A standard ProseMirror Node that also tracks refs. */ export interface RefsNode extends Node { refs: Refs; } /** * Create a text node. * * Special markers called "refs" can be put in the text. Refs provide a way to * declaratively describe a position within some text, and then access the * position in the resulting node. */ export declare function text(value: string, _schema?: Schema): RefsContentItem; /** * Offset ref position values by some amount. */ export declare function offsetRefs(refs: Refs, offset: number): Refs; /** * Given a collection of nodes, sequence them in an array and return the result * along with the updated refs. */ export declare function sequence(...content: RefsContentItem[]): { nodes: RefsNode[]; refs: Refs; }; /** * Given a jagged array, flatten it down to a single level. */ export declare function flatten(deep: (T | T[])[]): T[]; /** * Coerce builder content into ref nodes. */ export declare function coerce(content: BuilderContent[], schema: Schema): { nodes: RefsNode[]; refs: Refs; }; /** * Create a factory for nodes. */ export declare function nodeFactory(type: NodeType, attrs?: {}): (...content: BuilderContent[]) => RefsNode; /** * Create a factory for marks. */ export declare function markFactory(type: MarkType, attrs?: {}): (...content: BuilderContent[]) => RefsNode[]; export declare const doc: (...content: BuilderContent[]) => RefsNode; export declare const p: (...content: BuilderContent[]) => RefsNode; export declare const blockquote: (...content: BuilderContent[]) => RefsNode; export declare const h1: (...content: BuilderContent[]) => RefsNode; export declare const h2: (...content: BuilderContent[]) => RefsNode; export declare const h3: (...content: BuilderContent[]) => RefsNode; export declare const h4: (...content: BuilderContent[]) => RefsNode; export declare const h5: (...content: BuilderContent[]) => RefsNode; export declare const h6: (...content: BuilderContent[]) => RefsNode; export declare const li: (...content: BuilderContent[]) => RefsNode; export declare const ul: (...content: BuilderContent[]) => RefsNode; export declare const ol: (...content: BuilderContent[]) => RefsNode; export declare const br: Node; export declare const code_block: (attrs?: {}) => (...content: BuilderContent[]) => RefsNode; export declare const img: (attrs: { src: string; alt?: string | undefined; title?: string | undefined; }) => Node; export declare const emoji: (attrs: { id: string; }) => Node; export declare const mention: (attrs: { id: string; displayName?: string | undefined; }) => Node; export declare const hr: Node; export declare const em: (...content: BuilderContent[]) => RefsNode[]; export declare const strong: (...content: BuilderContent[]) => RefsNode[]; export declare const code: (...content: BuilderContent[]) => RefsNode[]; export declare const del: (...content: BuilderContent[]) => RefsNode[]; export declare const a: (attrs: { href: string; title?: string | undefined; }) => (...content: BuilderContent[]) => RefsNode[]; export declare const fragment: (...content: BuilderContent[]) => BuilderContent[]; export declare const slice: (...content: BuilderContent[]) => Slice;