type DOMElement$1 = Element;

type DOMElement = Element;
/**
Parse the given DOM structure as a document, using the given
schema. By default the set of parse rules will be derived from the
schema, but it is possible to pass in a custom set.
*/
declare function parse(schema: Schema, doc: Element | DocumentFragment, options?: parse.Options): Plot.Doc;
declare namespace parse {
    /**
    Options that can be passed to parsing functions.
    */
    type Options = {
        /**
        Controls whether HTML-style whitespace collapsing is used
        (outside nodes that don't enable `preserveWhitespace`). Defaults
        to true.
        */
        collapseWhiteSpace?: boolean;
        /**
        Function used in in {@link parse.slice} to determine
        whether a given element is open (on either side).
        */
        isOpen?: (elt: Element) => null | "start" | "end" | "start end";
        /**
        The rule set to use. Defaults to the rule set derived from the
        schema.
        */
        ruleSet?: parse.Rule.Set;
    };
    /**
    Parse the given DOM structure as a slice.
    */
    function slice(schema: Schema, doc: Element | DocumentFragment, options?: parse.Options): {
        slice: Slice;
        context: Plot.Tag<unknown>[];
    };
    /**
    Parse rules describe how DOM constructs should map to Wordgard
    document nodes. Many can be automatically derived from node and
    mark {@link Node.Spec.shape shapes}, but it is also often
    useful to provide them directly.
    */
    type Rule<Param = any> = Rule.Element<Param> | Rule.Attribute<Param>;
    namespace Rule {
        /**
        Describes a rule that matches elements by selector.
        */
        interface Element<Param> {
            /**
            The CSS selector that should match the element.
            */
            selector: string;
            /**
            If this is a node-creating rule, this holds the type of node
            to create when this rule matches. If this is a node type
            without default parameter, you _must_ also define {@link
            parse.Rule.Element.param} or {@link
            parse.Rule.Element.readElement}.
            */
            tag?: Leaf<Param> | Plot.Tag<Param> | Node.Type<Param>;
            /**
            Mark-creating rules should provide a mark or mark type here.
            The mark will be applied to the content of the element.
            Again, if the type lacks a parameter, {@link
            parse.Rule.Element.param} or {@link
            parse.Rule.Element.readElement} will be used to find it.
            */
            mark?: Mark.Type<Param> | Mark<Param>;
            /**
            Instead of creating a node or mark, rules may tell the
            parser to ignore a given element. `true` means discard it
            entirely, `"skip"` means ignore the element itself, but do
            parse its child nodes.
            */
            ignore?: boolean | "skip";
            /**
            A parameter for the tag or mark type.
            */
            param?: Param;
            /**
            A function that reads the parameter from the matched
            element. May return {@link parse.Reject} to indicate
            that the rule should not be applied to this element.
            */
            readElement?: (element: DOMElement) => Param | typeof Reject;
            /**
            An optional CSS selector for finding an additional inner
            element to read marks from.
            */
            marksFrom?: string;
            /**
            By default, when applying a rule for a plot or mark type,
            parsing continues with the element's direct children. You
            can pass a selector or function here to select another content element.
            */
            contentElement?: string | ((elt: DOMElement) => DOMElement);
            /**
            Ignore DOM nodes matching this selector or predicate, when
            they appear in this plot's content element.
            */
            ignoreContent?: string | ((elt: DOMElement) => boolean);
            /**
            A number between -10 and 10 (inclusive) that specifies the
            relative precedence of this rule. Defaults to 0.
            */
            precedence?: number;
        }
        /**
        An attribute parse rule matches an attribute, instead of an
        entire element. Such a rule can only create marks, not tags.
        */
        interface Attribute<Param> {
            /**
            The attribute to look for. May have the form `style/color`
            to look at a style property instead.
            */
            attribute: string;
            /**
            When given, this rule only matches when the attribute has
            this value.
            */
            value?: string;
            /**
            The mark to create for this attribute, if any.
            */
            mark?: Mark.Type<Param> | Mark<Param>;
            /**
            Remove a mark from the surrounding set of marks when this
            rule matches.
            */
            clearMark?: (mark: Mark<unknown>) => boolean;
            /**
            Can be set to true to cause the parser to ignore this
            attribute.
            */
            ignore?: boolean;
            /**
            A parameter to give to the mark type in {@link
            parse.Rule.Attribute.mark}.
            */
            param?: Param;
            /**
            Read a parameter value from the attribute value. May return
            {@link parse.Reject} to prevent the rule from matching.
            */
            readAttribute?: (value: string) => Param | typeof Reject;
            /**
            Controls whether other rules may match this attribute after
            this rule matches. Defaults to true.
            */
            consuming?: boolean;
            /**
            A number between -10 and 10 (inclusive) that specifies the
            relative precedence of this rule. Defaults to 0.
            */
            precedence?: number;
        }
        /**
        A collection of parse rules. Usually derived from a schema.
        */
        class Set {
            /**
            The rules in this set.
            */
            readonly rules: readonly Rule[];
            private constructor();
            /**
            Create a rule set with the given parse rules.
            */
            static of(rules: readonly Rule[]): Set;
            /**
            Create a rule set containing all the parse rules attached to
            nodes and marks in the given schema, as well as the rules that
            can be derived from the node and mark shape declarations.
            */
            static fromSchema(schema: Schema): Set;
        }
    }
    /**
    A special value that parse rule functions can return to block
    the rule from matching.
    */
    const Reject: unique symbol;
}

/**
This class describes a DOM element, its attributes, and its
children. It is used in describing the structure of {@link
Node.Spec.shape nodes} and {@link editor.Decoration decorations}.

Elements can provide a wrapping structure by having a content hole
somewhere in their children, which indicates where the structure
they wrap (typically a node's content) goes.

The type parameter indicates the set of additional leaf types. By
default, it holds only `string` (as a shorthand for text nodes),
but elements used in decorations also support {@link editor.Widget
custom widgets}.
*/
declare class Elt<T = string> {
    /**
    The element's tag name. May be prefixed with `"svg:"` or
    `"math:"` to indicate an SVG or MathML element.
    */
    readonly tagName: string;
    /**
    The set of attributes, as an {@link Attributes array of
    strings}.
    */
    readonly attrs: Attributes;
    /**
    The element's children.
    */
    readonly children: readonly (T | Elt<T> | 0)[];
    private constructor();
    /**
    Create an element. See also {@link Elt.mk} for a more ergonomic
    creation function.
    */
    static create<T = string>(tagName: string, attrs: Attributes, children: readonly (T | Elt<T> | 0)[]): Elt<Exclude<T, Elt<any> | 0>>;
    /**
    Create an element, specifying the attributes as an object. Both
    the set of attributesand the array of children are optional. The
    literal number 0 is used to indicate a content hole in the
    array of children.
    */
    static mk<T = string>(name: string, children?: (T | 0 | Elt<T>)[]): Elt<Exclude<T, Elt<any> | 0>>;
    static mk<T = string>(name: string, attrs: Record<string, string>, children?: readonly (T | 0 | Elt<T>)[]): Elt<Exclude<T, Elt<any> | 0>>;
    /**
    True if this element or one of its children has a content hole.
    */
    get hasContent(): boolean;
    /**
    Compare this element's tag name and attributes (not its
    children) to another element.
    */
    eqTag(elt: Elt<any>): boolean;
    /**
    Compare this element (including its children) to another
    element.
    */
    eq(other: any): boolean;
    private modifyBySelector;
    /**
    Convert an element with string content to an HTML string.
    */
    toHTML(this: Elt<string>): string;
    /**
    Convert an element (with only string content) to a DOM tree.
    */
    toDOM(this: Elt<string>, doc?: Document): Element | Text;
}
declare namespace Elt {
    /**
    A collection of elements or other content values.
    */
    class Fragment<T = string> {
        readonly content: readonly (T | Elt<T>)[];
        private constructor();
        /**
        Create a fragment.
        */
        static create<T = string>(content: readonly (T | Elt<T>)[]): Fragment<T>;
        /**
        Convert this fragment to an HTML string.
        */
        toHTML(this: Fragment<string>): string;
        /**
        Convert this fragment to a DOM fragment.
        */
        toDOM(this: Fragment<string>, doc?: Document): DocumentFragment;
    }
}
/**
Sets of attributes are stored in arrays of strings, with the even
indices holding attribute names, the odd ones attribute values. The
attributes are sorted by name.
*/
type Attributes = readonly string[];
declare namespace Attributes {
    /**
    The empty set of attributes.
    */
    const none: Attributes;
    /**
    Compare two attribute sets.
    */
    function eq(a: Attributes, b: Attributes): boolean;
    /**
    Combine two attribute sets, with b having higher precedence when
    they set the same attribute.
    */
    function merge(a: Attributes, b: Attributes): Attributes;
    /**
    Convert an attribute object into a set.
    */
    function read(obj: Record<string, string | null>): Attributes;
    /**
    Get the value of the given attribute.
    */
    function get(attrs: Attributes, name: string): string | null;
}
declare namespace Shape {
    /**
    Declares the shape of a node or mark to be a simple element. A
    parse rule can automatically be derived for it if the node or mark
    has a default parameter or a `read` function is defined to
    determine the parameter.
    */
    type Element<Param> = {
        /**
        The element name to use.
        */
        element: string;
        /**
        A selector to use in the parse rule. Defaults to the element
        name.
        */
        selector?: string;
        /**
        Attributes to add to the element.
        */
        attributes?: Record<string, string> | ((param: Param) => Record<string, string>);
        /**
        A helper to read a parameter value from the element. If this
        returns {@link parse.Reject}, the parse rule will not apply.
        */
        readElement?: (element: DOMElement$1) => Param | typeof parse.Reject;
        /**
        When specifying the shape of a plot, this indicates whether this
        node is an atom, meaning its content isn't editable through the
        editor.
        */
        atom?: boolean;
    };
    /**
    Declares the shape of a node in a way that allows a more
    complicated shape than {@link Shape.Element}. This will not
    automatically create a parse rule, so you'll want to define
    those yourself.
    */
    type Structure<Param> = {
        /**
        The structure as a tree of {@link Elt}s. If this is for a plot
        that is not to be rendered as an atom, the structure should
        contain a hole for the content.
        */
        structure: Elt<string> | ((param: Param) => Elt<string>);
        /**
        If `structure` is a function, and the target node is a plot, use
        this to specify whether the plot should be rendered as an atom
        or with content.
        */
        atom?: boolean;
    };
    /**
    Declares that a mark is represented with a specific DOM attribute.
    This allows a matching parse rule to be derived automatically in
    most situations.
    */
    type Attribute<Param> = {
        /**
        The name of the attribute.
        */
        attribute: string;
        /**
        Its value. When given as 0, which is ony valid when the
        `Param` type is `string`, the value of the mark's parameter is
        used directly.
        */
        value: (Param extends string ? 0 : never) | string | ((param: Param) => string | null);
        /**
        An optional function that converts the value of the attribute
        back into a parameter value. Used in the parse rule.
        */
        readAttribute?: (value: string) => Param | typeof parse.Reject;
        /**
        If the target node may be a composite shape (rather than a
        single DOM element), you can provide a limited form of selector
        here to target a specific element in that shape. Node names and
        class names are supported, as in `"img"`, `"img.my-class"`, or
        `".class1.class2"`. If no matching element is found, the
        attributes will be added to the node's outer element, as normal.
        */
        preferTarget?: string;
    };
    /**
    Declares that a dynamic attribute or set of attributes should be
    added to nodes with this mark. Will not produce an implicit parse
    rule.
    */
    type Attributes<Param> = {
        /**
        The attributes to add, either directly or as a function of the
        mark's parameter.
        */
        attributes: Record<string, string> | ((param: Param) => Record<string, string>);
        /**
        A selector for the {@link Shape.Attribute.preferTarget
        preferred target} element.
        */
        preferTarget?: string;
    };
}

/**
A mark has a type and a value. Some mark types without a
meaningful parameter value (such as {@link types.Emphasis}),
will only use a single mark object.
*/
declare class Mark<Value = unknown> {
    /**
    The type of the mark.
    */
    readonly type: Mark.Type<Value>;
    /**
    The parameter value. This may be something like the link
    target for a link mark, or the alignment side for a text
    alignment mark.
    */
    readonly value: Value;
    private constructor();
    /**
    Compare this mark to another one. Parameter values are compared
    by structure.
    */
    eq(other: Mark): boolean;
    /**
    The name of this mark's type.
    */
    get name(): string;
    /**
    Define a singleton mark, without parameter.
    */
    static define(name: string, spec: Mark.Spec<null>): Mark<null>;
    /**
    Add this mark to the given set. Will overwrite existing
    instances of the mark in the set, unless this is a {@link
    Mark.Spec.set set-valued} mark.
    */
    addToSet(set: Mark.Set): Mark.Set;
    /**
    Remove this mark from the given set.
    */
    removeFromSet(set: Mark.Set): Mark.Set;
    /**
    Test whether this mark is in the given set.
    */
    isInSet(set: Mark.Set): Mark<Value> | null;
    /**
    Compare two sets of marks.
    */
    static sameSet(a: Mark.Set, b: Mark.Set): boolean;
    /**
    The empty mark set.
    */
    static none: Mark.Set;
}
declare namespace Mark {
    class Type<Param = unknown> {
        /**
        The name of the mark's type.
        */
        readonly name: string;
        /**
        The {@link Mark.Spec.defaultParam default} mark for this type,
        if any.
        */
        readonly default: Mark<Param> | null;
        /**
        Whether this is an {@link Mark.Spec.inclusive inclusive} mark.
        */
        readonly inclusive: boolean;
        /**
        Whether this is a {@link Mark.Spec.spanning spanning} mark.
        */
        readonly spanning: boolean;
        /**
        The spec used to define this mark. (Its type parameter is set
        to `any` to circumvent a typing issue where `Mark<T>` isn't a
        subtype of `Mark<unknown>`.)
        */
        readonly spec: Mark.Spec<any>;
        private constructor();
        /**
        Create a mark of this type.
        */
        of(value: Param): Mark<Param>;
        /**
        Remove the mark of this type from the given set, if present.
        */
        removeFromSet(set: Mark.Set): Mark.Set;
        /**
        Test whether there is a mark of this type in the given set. If
        so, return it.
        */
        isInSet(set: Mark.Set): Mark<Param> | null;
        /**
        Whether this mark is rendered with an element.
        */
        get isElement(): boolean;
        /**
        Define a mark type with the given parameter type.
        */
        static define<Param>(name: string, spec: Mark.Spec<Param>, 
        /**
        @internal
        */
        isFlag?: boolean): Type<Param>;
    }
    /**
    Configuration for marks.
    */
    interface Spec<Param> {
        /**
        Which node tags this mark may apply to, as node {@link Node.Query query}.
        The default is `{and: [Node.Group.Inline, Node.Group.Leaf]}`.
        */
        target?: Node.Query;
        /**
        Determines the position of this mark relative to other marks.
        Should be a number between 0 and 100. Marks with lower rank
        appear first in mark set arrays, and are rendered around
        higher rank marks when rendered as an element. Ties are broken
        by name. Defaults to 100.
        */
        rank?: number;
        /**
        Whether this mark should be active when the cursor is positioned
        at its end (or at its start when that is also the start of the
        parent node). Defaults to true.
        */
        inclusive?: boolean;
        /**
        Whether this mark can span across multiple nodes, or refers to
        an individual node. Only spanning marks can be added to text.
        Spanning marks with an element representation can be drawn as
        elements containing multiple nodes, unless another, lower-ranked
        mark requires the nodes to be wrapped separately. Defaults to
        true for specs with an element representation, false
        for specs with an attribute representation.
        */
        spanning?: boolean;
        /**
        Used by {@link Plot.Tag.split `Plot.Tag.split`} to determine
        whether to keep this mark in the split-off tag. `atEnd` will
        be true if the split happens at the end of the node's content.
        */
        keepOnSplit?: boolean | ((tag: Plot.Tag, atEnd: boolean) => boolean);
        /**
        Used by {@link Schema.withMarksFrom} to decide whether marks
        of this type are preserved after the type change.
        */
        keepOnTypeChange?: boolean | ((from: Node.Tag, to: Node.Tag) => boolean);
        /**
        A default value for the parameter. If given, a mark with this
        parameter will be stored in {@link Mark.Type.default
        `Mark.Type.default`}.
        */
        defaultParam?: Param;
        /**
        A function or type name used to validate parameters of this
        mark. See {@link Node.Spec.validate `Node.Spec.validate`}.
        */
        validate?: string | ((value: Param) => void);
        /**
        A mark parameter can be set-valued, which changes how adding
        and removing marks of that type works. This requires the mark
        parameter to be an array type. When adding a set-valued mark
        to a mark set, the value of the mark in the new set is the
        union of the values of its original value and the added mark.
        Similarly, when removing such a mark, only the values in the
        parameter of the removed mark are removed from the mark in the
        set (except when there are none left, in which case the mark
        is removed entirely).
        
        `compare` should be a function that compares two values and
        returns 0 if they are the same, or an ordering number
        otherwise. This is used to sort and compare the values.
        */
        set?: Param extends ReadonlyArray<infer Content> ? {
            compare: (a: Content, b: Content) => number;
        } : never;
        /**
        A mark can be either represented with a wrapping element, or
        with one or more attributes added to the affected nodes.
        */
        shape: Shape.Element<Param> | Shape.Attribute<Param> | Shape.Attributes<Param>;
        /**
        A set of parse rules for this mark. The `mark` field for these
        will automatically be defaulted to the mark type itself.
        */
        parseRules?: readonly parse.Rule<Param>[];
    }
    /**
    A set of marks is a sorted array in which a given mark type can
    occur at most once.
    */
    type Set = readonly Mark[];
}

/**
A schema is a collection of node and mark types, including exactly
one document type, plus an optional set of {@link Schema.Override
overrides} that modify the relations between those elements. It
determines what kind of elements may occur in documents that
follow this schema, and where they can show up.
*/
declare class Schema {
    /**
    All the schema elements that make up this schema. Useful if you
    want to base another schema on this one.
    */
    readonly elements: readonly Schema.Element[];
    /**
    The node types that are part of this schema.
    */
    readonly nodes: readonly Node.Type[];
    /**
    Mark types used in this schema.
    */
    readonly marks: readonly Mark.Type[];
    private plotContent;
    private markTarget;
    private nodeGroup;
    /**
    The plot tag used by documents in this schema.
    */
    readonly docTag: Plot.Tag<null>;
    /**
    The {@link Node.Role.LineBreak line break} node defined in
    this schema, if any.
    */
    readonly lineBreak: Leaf | null;
    private nodesByName;
    private marksByName;
    private wrappingCache;
    private validated;
    private constructor();
    /**
    Create a document in this schema.
    */
    doc(children: readonly Node[]): Plot.Doc;
    /**
    Validate that a node and its content conform to this schema.
    Will run automatically when creating a document.
    */
    validate(node: Node): void;
    /**
    Test whether the given mark or tag type is included in this
    schema.
    */
    has(elt: Mark<any> | Mark.Type | Node.Type.Ref<any>): boolean;
    /**
    Test whether a node type matches the given {@link Node.Query
    node query}.
    */
    matchNode(node: Node.Type, q: Node.Query): boolean;
    /**
    Test whether the given mark is allowed on the given node type.
    */
    markAllowed(mark: Mark.Type, node: Node.Type): boolean;
    /**
    Returns true if there's at least one node type in the schema
    that may occur in both `a` and `b`.
    */
    sharesContent(a: Plot.Type, b: Plot.Type): boolean;
    /**
    Returns a copy of `to` with all the marks from `from` that it
    doesn't already have, and that aren't dropped by the mark's
    {@link Mark.Spec.keepOnTypeChange} configuration.
    */
    withMarksFrom<T extends Node.Tag>(from: Node.Tag, to: T): T;
    /**
    Check whether a given plot type can contain a given node type.
    */
    canContain(parent: Plot.Type, child: Node.Type): boolean;
    /**
    Return the first {@link Leaf.Type.default defaultable} node tag that
    can occur as a child of `parent`.
    */
    defaultContentTag(parent: Plot.Type): Node.Tag | null;
    /**
    Return the first {@link Plot.Type.default defaultable} plot tag
    that can be a child of `parent`.
    */
    defaultContentPlot(parent: Plot.Type): Plot.Tag | null;
    /**
    Create a node from a tag, optionally adding a default child if
    this is a plot that cannot be empty.
    */
    createAndFill(parent: Node.Tag): Node;
    /**
    Find a set of tags that `child` must be wrapped in to be able to
    occur in `parent`. Will return the empty array if it fits
    directly, and `null` if it cannot occur at all.
    */
    findWrapping(parent: Plot.Type, child: Node.Type): readonly Plot.Tag[] | null;
    private findWrappingInner;
    /**
    Get the mark type with the given name in this schema.
    */
    getMark(name: string): Mark.Type | undefined;
    /**
    Get the node type with the given name.
    */
    getNode(name: string): Node.Type | undefined;
    /**
    Define a schema from a set of schema elements. The set must
    contain precisely one document type, and no conflicting node or
    mark names.
    */
    static define(spec: readonly Schema.Element[]): Schema;
    /**
    Deserialize a node from its JSON representation.
    */
    nodeFromJSON(json: Node.JSON): Node;
    /**
    Deserialize a tag from its JSON representation.
    */
    tagFromJSON(json: Node.JSON): Leaf<unknown> | Plot.Tag<unknown>;
    /**
    Read a set of marks from their JSON representation.
    */
    marksFromJSON(json: Record<string, any>): Mark.Set;
    /**
    Read a document from JSON.
    */
    docFromJSON(json: Node.JSON): Plot.Doc;
}
declare namespace Schema {
    /**
    A schema element is any node tag or type, mark or mark type, or
    override.
    */
    type Element = Node.Tag | Node.Type | Mark | Mark.Type | Schema.Override;
    /**
    Though nodes and marks are mostly self-contained, a few of their
    aspects can be overridden per schema.
    */
    class Override {
        private constructor();
        /**
        @hidden
        */
        tag: "schema.override";
        /**
        Create a schema override that changes the target nodes for a
        mark.
        */
        static markTarget(mark: Mark.Type | Mark, target: Node.Query | ((target: Node.Query) => Node.Query)): Override;
        /**
        Create a schema override that changes the content specification
        for a given node. Note that this can not change a node with
        inline content to block content or vice versa.
        */
        static plotContent(plot: Plot.Type | Plot.Tag, content: Node.Query | ((content: Node.Query) => Node.Query)): Override;
        /**
        Override the set of groups that a node may be part of.
        */
        static nodeGroup(node: Node.Type | Node.Tag, group: Node.Group | readonly Node.Group[]): Override;
    }
}

/**
The type of tokens in a slice. A plot tag represents the point
where a plot is opened, {@link Plot.End} the point where a plot is
closed, and nodes just represent the insertion of that node.
*/
type Token = Node | Plot.Tag | typeof Plot.End;
declare namespace Token {
    /**
    Tokens have a `tokenType` property holding oneof these values.
    */
    enum Type {
        Open = 0,
        Close = 1,
        Node = 2
    }
}
/**
A slice represents a part of a document. It is used to represent
inserted content in {@link ChangeSet change sets}, or things like
clipboard content.
*/
declare class Slice {
    readonly content: readonly Token[];
    /**
    The length of the slice's content.
    */
    readonly length: number;
    private constructor();
    /**
    Create a slice.
    */
    static of(content: readonly Token[]): Slice;
    /**
    Compare a slice to another one.
    */
    eq(other: Slice): boolean;
    /**
    Create a sub-slice of this slice.
    */
    slice(from: number, to?: number): Slice;
    /**
    Concatenate this slice to another slice.
    */
    concat(other: Slice): Slice;
    /**
    Get the text content of the slice's tokens.
    */
    textContent(options?: {
        blockSeparator?: string;
        leafText?: string | ((node: Leaf) => string);
    }): string;
    /**
    The empty slice.
    */
    static empty: Slice;
    /**
    Convert this slice to a JSON-serializeable representation.
    */
    toJSON(): Slice.JSON;
    /**
    Build a slice from its JSON representation.
    */
    static fromJSON(schema: Schema, json: Slice.JSON): Slice;
}
declare namespace Slice {
    /**
    A slice's JSON representation.
    */
    type JSON = readonly ({
        node: Node.JSON;
    } | {
        open: Node.JSON;
    } | {
        close: true;
    })[];
}

type _Node = Node;
type _Plot = Plot;
type _Doc = Plot.Doc;
type _Tag = Plot.Tag;
/**
This class represents a {@link Plot.Doc.resolve resolved}
position.
*/
declare class Pos {
    /**
    The plot that the position points into.
    */
    readonly parent: Pos.Plot;
    /**
    The position itself.
    */
    readonly pos: number;
    /**
    The index into its parent's content array. Note that if
    `inText` is non-zero, this is the index of the text node.
    */
    readonly index: number;
    /**
    Text nodes don't count as parent plots. Rather, positions that
    fall inside a text node have a non-zero value here that
    provides the offset into the text node.
    */
    readonly inText: number;
    private constructor();
    /**
    Find the innermost parent plot for which the given predicate
    returns true.
    */
    matchingParent(pred: (plot: _Plot) => boolean): Pos.Plot | null;
    /**
    Move ahead through the document the given number of positions.
    Don't descend into nodes that fall entirely within the skipped
    range. If `walk` is given, call methods on it for each node
    entered, skipped, or left. Return a new position at the end of
    the range.
    */
    advance(distance: number, walk?: Pos.Walker): Pos;
    /**
    Move ahead through the document, always entering every plot. If
    `walk` is given, call methods on it for each node or node
    boundary passed. Return a new position.
    */
    walk(distance: number, walk: Pos.Walker): Pos;
    /**
    Get the node directly after this position. If `inText` is
    non-zero, return only the part of the text node that's after the
    position.
    */
    get nodeAfter(): Node | null;
    /**
    Get the node directly before this position. If `inText` is
    non-zero, return only the part of the text node before the
    position.
    */
    get nodeBefore(): Node | null;
    /**
    Get the nearest parent that is a {@link Plot.isTextblock
    textblock}.
    */
    get textblockParent(): Pos.Plot | null;
    /**
    Get the depth of this position (the amount of plots that wrap
    it, not counting the document).
    */
    get depth(): number;
    /**
    Get the parent plot at the given depth.
    */
    parentAt(depth: number): Pos.Plot;
    /**
    Returns true if this position is right at the start of the given
    parent plot, or transitively at the start of its first child.
    */
    isAtStart(parent: Pos.Plot): boolean;
    /**
    Returns true if this position is right at the end of the given
    parent plot, or transitively at the end of its last child.
    */
    isAtEnd(parent: Pos.Plot): boolean;
    /**
    Get the document that this position points into.
    */
    get doc(): Plot.Doc;
    /**
    Get the set of active inline marks at this position or, if
    `across` is given, the marks that would apply to content
    replacing the range between that `this` and `across`.
    */
    marks(across?: Pos): Mark.Set;
}
declare namespace Pos {
    /**
    Interface for the walker object that can be passed to {@link
    Pos.advance `Pos.advance`} and {@link Pos.walk}.
    */
    interface Walker {
        /**
        Called when a node is skipped over. Will only be called for
        leaves when using {@link Pos.walk}.
        */
        skip(node: _Node, pos: number, parent: Pos.Plot, index: number): void;
        /**
        Called when a plot is entered.
        */
        enterPlot(node: _Plot, pos: number, parent: Pos.Plot, index: number): void | boolean;
        /**
        Called when leaving a plot.
        */
        leavePlot(tag: _Tag, pos: number, parent: Pos.Plot, index: number): void;
    }
    /**
    Represents the position of a node, with information about its
    parent plots.
    */
    class Node {
        /**
        The node's direct parent.
        */
        readonly parent: Pos.Plot | null;
        /**
        The node object.
        */
        readonly node: _Node;
        /**
        The node's index in its parent plot.
        */
        readonly index: number;
        /**
        @hidden
        */
        protected constructor(
        /**
        The node's direct parent.
        */
        parent: Pos.Plot | null, 
        /**
        The node object.
        */
        node: _Node, 
        /**
        @internal
        */
        pos: number, 
        /**
        The node's index in its parent plot.
        */
        index: number);
        /**
        The position before the node. Will raise an error if this is
        the document top node.
        */
        get before(): number;
        /**
        The position after the node. Throws if this is a document.
        */
        get after(): number;
        /**
        The depth of this node (the number of parent nodes, not
        counting the document).
        */
        get depth(): number;
        /**
        The document that this position points into.
        */
        get doc(): _Doc;
        /**
        Returns true if this is either a document node or the first
        node in its parent.
        */
        get isFirst(): boolean;
        /**
        Returns true if this is a document node or the last node in its parent.
        */
        get isLast(): boolean;
        /**
        The node before this one, if any.
        */
        get nextSibling(): Node | null;
        /**
        The node after this node, if any.
        */
        get previousSibling(): Node | null;
    }
    /**
    Subclass of {@link Pos.Node} that points at a plot node.
    */
    class Plot extends Pos.Node {
        node: _Plot;
        private constructor();
        /**
        The position at the start of this plot's content.
        */
        get start(): number;
        /**
        The position at end of this plot's content.
        */
        get end(): number;
    }
}

declare abstract class BaseType<Param> {
    /**
    The name of this node type.
    */
    readonly name: string;
    /**
    Test whether this node has the given role.
    */
    hasRole(role: Node.Role): boolean;
    /**
    True when this is an inline node type.
    */
    get isInline(): boolean;
    /**
    True when this is a block node type.
    */
    get isBlock(): boolean;
    /**
    True when this node is a leaf or a plot whose default
    shape is rendered as an atom.
    */
    get isAtom(): boolean;
    abstract isLeaf: boolean;
    abstract isPlot: boolean;
}
declare abstract class BaseTag<Param> {
    readonly param: Param;
    readonly marks: Mark.Set;
    abstract type: Node.Type<Param>;
    constructor(param: Param, marks: Mark.Set);
    mark<Value>(mark: Mark.Type<Value>): Value | undefined;
    get name(): string;
    abstract eq(other: Node | Node.Tag): boolean;
    abstract isLeaf: boolean;
    abstract isPlot: boolean;
    get isText(): boolean;
    is<T>(type: Leaf.Type<T>): this is Leaf<T>;
    is<T>(type: Plot.Type<T>): this is Plot.Tag<T>;
    toJSON(): Node.JSON;
}
/**
A node in the document is either a plot (which may have content)
or a leaf node.
*/
type Node = Plot | Leaf;
declare namespace Node {
    /**
    The interface shared by both {@link Leaf} and {@link Plot}.
    */
    interface Shared {
        /**
        The name of this node's type.
        */
        name: string;
        /**
        The node's {@link Node.Tag tag}. For leaves, this is the leaf
        itself, for plots, the {@link Plot.Tag plot tag}.
        */
        tag: Node.Tag;
        /**
        The length of this node. For a plot, this is its {@link
        Plot.contentLength} plus 2 (for the open and close tokens),
        for leaves this is 1, except for text leaves, where it is the
        length of the text.
        */
        length: number;
        /**
        The set of marks for this node.
        */
        marks: Mark.Set;
        /**
        Get the value of the given mark for this node, if any.
        */
        mark<Value>(mark: Mark.Type<Value>): Value | undefined;
        /**
        Compare this node to another node.
        */
        eq(other: Node): boolean;
        /**
        Create a copy of this node with the given set of marks instead
        of its current mark set.
        */
        withMarks(marks: Mark.Set): Node;
        /**
        True when this is a leaf node. TypeScript will automatically
        narrow from {@link Node} to {@link Leaf} after you check this.
        */
        isLeaf: boolean;
        /**
        Tests whether this is a {@link Leaf.Text text leaf}.
        */
        isText: boolean;
        /**
        True when this is a {@link Plot}.
        */
        isPlot: boolean;
        /**
        Convert this node to its JSON-serializeable representation.
        */
        toJSON(): Node.JSON;
    }
    /**
    A node type can be either a leaf type or a plot type.
    */
    type Type<T = unknown> = Leaf.Type<T> | Plot.Type<T>;
    namespace Type {
        /**
        Used as input type by some functions acting on node types, so
        that you can pass either a bare type or a singleton leaf or
        plot tag.
        */
        type Ref<T> = Plot.Type<T> | Leaf.Type<T> | Plot.Tag<T> | Leaf<T>;
        /**
        Get the type referred to by a {@link Node.Type.Ref reference}.
        */
        function get<T>(ref: Ref<T>): Node.Type<T>;
    }
    /**
    A tag is a node type with a parameter and a set of marks. For
    leaves, the entire node is the tag. For plots, it is a separate
    object in the {@link Plot.tag `tag` property}.
    */
    type Tag = Leaf | Plot.Tag;
    namespace Tag {
        /**
        The interface shared by {@link Leaf leaves} and {@link
        Plot.Tag plot tags}.
        */
        interface Shared<Param> {
            /**
            The type of the tag.
            */
            type: Node.Type<Param>;
            /**
            The tag parameter. Will be `null` for parameter-less types.
            */
            param: Param;
            /**
            The set of marks for this tag.
            */
            marks: Mark.Set;
            /**
            The name of the tag's type.
            */
            name: string;
            /**
            Find the value of the given given make type in this tag's
            set of marks, or return `undefined` if it isn't present.
            */
            mark<Value>(mark: Mark.Type<Value>): Value | undefined;
            /**
            Compare this tag to another tag.
            */
            eq(other: Node.Tag): boolean;
            /**
            Test whether this is a leaf.
            */
            isLeaf: boolean;
            /**
            Test whether this is a plot tag.
            */
            isPlot: boolean;
            /**
            Test whether this tag is of the given type.
            */
            is<T>(type: Leaf.Type<T>): this is Leaf<T>;
            is<T>(type: Plot.Type<T>): this is Plot.Tag<T>;
            /**
            Holds `true` when this is a text leaf.
            */
            isText: boolean;
            /**
            Convert this tag to a JSON-serializeable object.
            */
            toJSON(): Node.JSON;
        }
        /**
        Deduce a tag type for a given node type or tag.
        */
        type For<Type extends Node.Type.Ref<any>> = Type extends Leaf.Type<infer T> ? Leaf<T> : Type extends Plot.Type<infer T> ? Plot.Tag<T> : Type;
    }
    /**
    Shared fields between {@link Leaf.Spec} and {@link Plot.Spec}.
    */
    interface Spec<Param> {
        /**
        Whether this node is an inline or a block node. Defaults to
        block.
        */
        inline?: boolean;
        /**
        The default parameter value for the node type. Only meaningful
        when the type is being defined directly, rather than as a
        singleton tag.
        */
        defaultParam?: Param;
        /**
        A function or type name used to validate this tag's parameter
        value. This will be used when deserializing the attribute from
        JSON. When a string, it should be a `|`-separated string of
        primitive types (`"number"`, `"string"`, `"boolean"`, `"null"`,
        and `"undefined"`). The library will raise an error when the
        value is not one of those types. When a function, it should
        raise an error if the value doesn't have the expected type or
        shape.
        */
        validate?: string | ((param: Param) => void);
        /**
        Assign one or more groups to this node type. Groups are used
        when specifying allowed content for a plot. Schema overrides
        can {@link Schema.Override.nodeGroup change} a node's set of
        groups.
        */
        group?: Group | readonly Group[];
        /**
        Roles to add to this node type, which mark it as having a
        certain semantic role, such as being a list.
        */
        role?: Node.Role | readonly Node.Role[];
        /**
        The default DOM/HTML shape of this node. This will determine
        what the node looks like, both in an editor an in serialized
        HTML form. In most cases, this also specifies the way the node
        is parsed when reading HTML content.
        */
        shape: Shape.Element<Param> | Shape.Structure<Param>;
        /**
        Extra parse rules to associate with this node type.
        */
        parseRules?: readonly parse.Rule.Element<Param>[];
    }
    /**
    The JSON representation for a node or tag.
    */
    interface JSON {
        type: string;
        param?: any;
        marks?: {
            [name: string]: any;
        };
        content?: readonly Node.JSON[];
    }
    /**
    Groups are used to specify parent-child relationships between
    nodes, and valid targets for marks. You can use predefined
    groups provided as static properties on the class, or define
    your own for custom categories.
    */
    class Group {
        /**
        Groups may have a parent group. Membership of a group
        implies membership of its parent groups.
        */
        readonly parent: Group | undefined;
        private tag;
        private constructor();
        /**
        Define a custom node group.
        */
        static define(parent?: Group): Group;
        /**
        A group that contains every node type.
        */
        static All: Group;
        /**
        All inline nodes are automatically assigned to this group.
        */
        static Inline: Group;
        /**
        Block elements automatically get assigned to this group.
        */
        static Block: Group;
        /**
        The group of all leaf nodes.
        */
        static Leaf: Group;
        /**
        The group of all non-leaf nodes.
        */
        static Plot: Group;
        /**
        Block plots with inline content are tagged as textblocks.
        */
        static Textblock: Group;
        /**
        A group used for generic block content, such as paragraphs and
        lists. The basic schema uses this as the content type for the
        top level document, blockquotes, and list items.
        */
        static Content: Group;
        /**
        Group for the cell nodes in tables.
        */
        static TableCell: Group;
        /**
        Generic list item group.
        */
        static ListItem: Group;
    }
    /**
    Describes a set of node types. Can be either a single tag or
    type, which matches exactly that type (tags are assumed to be
    singleton tags—only their type is used), a reference to a {@link
    Node.Group node group}, or a combination of multiple of those.
    An array indicates the union of all the groups in the array
    (matches types that match any of the queries). An object with an
    `and` property indicates an intersection (must match all the
    queries).
    */
    type Query = Node.Tag | Node.Type | Group | readonly Node.Query[] | {
        and: readonly Node.Query[];
    };
    /**
    Roles are used to add some semantic information to node types.
    You can define your own, and use the `hasRole` method to check
    whether a given node has the role attached.
    */
    class Role {
        private constructor();
        /**
        Define a new role.
        */
        static define(): Role;
        /**
        This role indicates that a plot contains code, and makes some
        commands behave differently inside such a plot.
        */
        static Code: Role;
        /**
        Identifies a plot as a list container. This makes some
        commands treat the plot specially.
        */
        static List: Role;
        /**
        A single leaf type in a schema may have the `LineBreak` role,
        which identifies it as the canonical node that represents a
        line break. Nodes marked as line breaks will be parsed from
        and serialized to newline characters inside {@link
        Plot.Spec.preserveWhitespace whitespace-preserving} nodes.
        */
        static LineBreak: Role;
    }
}
/**
A leaf node, which is a node with no content nodes. Used for
things like text, images, line breaks, and so on. Counts as a
{@link Node.Tag}.
*/
declare class Leaf<Param = unknown> extends BaseTag<Param> implements Node.Shared, Node.Tag.Shared<Param> {
    /**
    This leaf's type.
    */
    readonly type: Leaf.Type<Param>;
    private constructor();
    get tag(): this;
    eq(other: Node | Node.Tag): boolean;
    /**
    Define a singleton leaf type, without parameter. If you need to
    store a parameter value in each leaf of the type, use {@link
    Leaf.Type.define} instead.
    */
    static define(name: string, spec: Leaf.Spec<null>): Leaf<null>;
    withMarks(marks: Mark.Set): Leaf<Param>;
    /**
    In {@link Slice slices}, leaf nodes count as node {@link Token
    tokens}.
    */
    get tokenType(): Token.Type.Node;
    get isLeaf(): true;
    get isPlot(): false;
    get length(): number;
    /**
    Create a text node with the given text and mark set.
    */
    static text(text: string, marks?: Mark.Set): Leaf<string>;
}
declare namespace Leaf {
    /**
    Node type for leaves.
    */
    class Type<Param = unknown> extends BaseType<Param> {
        /**
        A default leaf for this type. Available if the leaf was
        defined with {@link Leaf.define}, or a {@link
        Node.Spec.defaultParam} was given.
        */
        default: Leaf<Param> | null;
        /**
        The spec used to define this type. Its type parameter is
        cleared to avoid this field making the class invariant (in the
        type system sense), which would prevent `Leaf.Type<unknown>`
        from being a supertype of specific leaf types.
        */
        readonly spec: Leaf.Spec<any>;
        private constructor();
        /**
        Define a new leaf type.
        */
        static define<T>(name: string, spec: Leaf.Spec<T>): Type<T>;
        /**
        Create a leaf with this type.
        */
        of(param: Param, marks?: Mark.Set): Leaf<Param>;
        /**
        Used to narrow {@link Node.Type} values to {@link Leaf}.
        */
        get isLeaf(): true;
        /**
        Leaves are not plots.
        */
        get isPlot(): false;
        /**
        Whether this leaf is {@link Leaf.Spec.selectable selectable}.
        */
        get isSelectable(): boolean;
    }
    interface Spec<Param> extends Node.Spec<Param> {
        /**
        Can be used to make leaves of this type show up in the output
        of {@link Plot.textContent}.
        */
        toText?: (node: Leaf) => string;
        /**
        When set to `true`, nodes of this type can be selected by
        clicking them or moving the selection into them with the
        keyboard.
        */
        selectable?: boolean;
    }
    /**
    The type of text leaves. Represents a series of characters with
    a given set of marks. The only leaf with a length that isn't
    always 1. Adjacent text leaves with the same marks are merged
    automatically.
    */
    const Text: Leaf.Type<string>;
}
/**
Plots delimit parts of the document, giving a special meaning to
the nodes inside them. They are defined by a {@link Plot.Tag tag}
and an array of {@link Plot.content content}.
*/
declare class Plot implements Node.Shared {
    /**
    The tag that identifies this plot.
    */
    readonly tag: Plot.Tag;
    /**
    The nodes in this plot.
    */
    readonly content: readonly Node[];
    /**
    The sum of the length of this plot's content nodes.
    */
    contentLength: number;
    get name(): string;
    /**
    The type of this plot's tag.
    */
    get type(): Plot.Type<unknown>;
    get marks(): Mark.Set;
    get length(): number;
    eq(other: Node): boolean;
    /**
    @hidden
    */
    is<T>(type: Leaf.Type<T>): false;
    get isText(): false;
    /**
    Tells you whether the content of this plot is inline.
    */
    get inlineContent(): boolean;
    /**
    True if this is a block node with inline content.
    */
    get isTextblock(): boolean;
    get isLeaf(): false;
    get isPlot(): true;
    /**
    True if this is a document node.
    */
    get isDoc(): boolean;
    /**
    Get the plot's first child, if any.
    */
    get firstChild(): Node | null;
    /**
    Get the plot's first child.
    */
    get lastChild(): Node | null;
    /**
    Iterate though the given range (or the entire document, when
    given only one argument), and call the given function on every
    node that overlaps the given range, outer nodes before inner
    nodes. When the function returns `false` for a node, descendents
    of that node are not iterated.
    */
    iterate(from: number, to: number, f: (node: Node, pos: number, parent: Plot | null, index: number) => boolean | void): void;
    iterate(f: (node: Node, pos: number, parent: Plot | null, index: number) => boolean | void): void;
    /**
    Return the node that starts at the given offset from this node's
    content start, if any. Will not return text nodes.
    */
    nodeAt(pos: number): Node | null;
    /**
    Return the plot at the given offset, if any.
    */
    plotAt(pos: number): Plot | null;
    /**
    Return the text content of this plot.
    */
    textContent(options?: {
        /**
        An optional start position, as an offset from the plot's
        content start.
        */
        from?: number;
        /**
        An optional end position.
        */
        to?: number;
        /**
        Text to separate blocks with. Defaults to a single newline
        character.
        */
        blockSeparator?: string;
        /**
        Override the way non-text leaves are converted to string.
        */
        leafText?: string | ((node: Leaf) => string);
    }): string;
    toJSON(): Node.JSON;
    mark<Value>(mark: Mark.Type<Value>): Value | undefined;
    withMarks(marks: Mark.Set): Plot;
    /**
    Plot nodes count as node {@link Token tokens} in a {@link
    Slice}.
    */
    get tokenType(): Token.Type.Node;
    /**
    Define a singleton plot type. If the plot needs a parameter
    value, use {@link Plot.Type.define} instead.
    */
    static define(name: string, spec: Plot.Spec<null>): Plot.Tag<null>;
    /**
    Define a document plot type. Exactly one of these must occur in a schema.
    */
    static defineDoc(spec: {
        inlineContent?: Node.Query | true;
        blockContent?: Node.Query;
        canBeEmpty?: boolean;
    }): Plot.Type<null>;
}
declare namespace Plot {
    /**
    The end token for a plot. Used in {@link Slice slices}.
    */
    const End: {
        tokenType: Token.Type.Close;
    };
    /**
    A plot tag holds the type of the plot, its parameter (if any),
    and a set of marks.
    */
    class Tag<Param = unknown> extends BaseTag<Param> implements Node.Tag.Shared<Param> {
        readonly type: Plot.Type<Param>;
        private constructor();
        eq(other: Node | Node.Tag): boolean;
        /**
        Create a plot with this tag and the given content.
        */
        create(content?: readonly Node[]): Plot;
        /**
        Create a copy of this tag with the given marks.
        */
        withMarks(marks: Mark.Set): Tag<Param>;
        /**
        Return a tag that represents content split off from the plot
        with this tag. Will respect the {@link Mark.Spec.keepOnSplit}
        mark property. `atEnd` should be set to true if the split
        happens at the end of the plot's content.
        */
        split(atEnd: boolean): Tag<Param>;
        /**
        A plot tag counts as an open {@link Token token} in a {@link
        Slice slice}.
        */
        get tokenType(): Token.Type.Open;
        /**
        True when this plot type contains inline content.
        */
        get inlineContent(): boolean;
        /**
        True when this is a block plot with inline content.
        */
        get isTextblock(): boolean;
        get isLeaf(): false;
        get isPlot(): true;
        /**
        Test whether this is a document plot.
        */
        get isDoc(): boolean;
    }
    /**
    A type of {@link Plot plot}.
    */
    class Type<Param = unknown> extends BaseType<Param> {
        /**
        A default tag for this plot type.
        */
        readonly default: Plot.Tag<Param> | null;
        /**
        Whether the {@link Plot.Spec.isolating} flag is set on this
        plot type.
        */
        readonly isolating: boolean;
        /**
        The plot's {@link Plot.Spec.defining} flag.
        */
        readonly defining: boolean;
        /**
        The plot's {@link Plot.Spec.neutral} flag.
        */
        readonly neutral: boolean;
        /**
        Whether whitespace should be preserved inside this plot.
        */
        readonly preserveWhitespace: boolean;
        /**
        The orientation of the content of the plot. Will be `"row"`
        for plots with inline content, and defaults to `"column"` for
        plots with block content unless explicitly {@link
        Plot.Spec.orientation set}.
        */
        readonly orientation: "row" | "column";
        /**
        The spec used to define this plot type.
        */
        readonly spec: Plot.Spec<any>;
        private constructor();
        /**
        Define a plot type.
        */
        static define<T>(name: string, spec: Plot.Spec<T>): Type<T>;
        /**
        Create a plot tag of this type with the given parameter and
        mark set.
        */
        of(param: Param, marks?: Mark.Set): Tag<Param>;
        /**
        Tells you whether this plot type has inline content.
        */
        get inlineContent(): boolean;
        /**
        True if this is a block plot with inline content.
        */
        get isTextblock(): boolean;
        /**
        True if this is a document plot type.
        */
        get isDoc(): boolean;
        /**
        Tells you that this is not a leaf type.
        */
        get isLeaf(): false;
        /**
        This is a plot type. Can be used to narrow `Node.Type` to
        `Plot.Type`.
        */
        get isPlot(): true;
        /**
        Tells you whether this plot type is allowed {@link
        Plot.Spec.canBeEmpty to be empty}.
        */
        get canBeEmpty(): boolean;
    }
    /**
    Object used to define a plot type.
    */
    interface Spec<Param> extends Node.Spec<Param> {
        /**
        When this node has block-level content, provide a query
        matching the nodes it may contain here. You generally don't
        want to use `Node.Group.Block` here, since specialized block
        types (like table cells or list items) should probably only be
        allowed in their designated parent plots.
        */
        blockContent?: Node.Query;
        /**
        When this node has inline content, provide a query specifying
        valid content. If set to `true`, any inline node may appear in
        this node.
        */
        inlineContent?: Node.Query | true;
        /**
        Plots with block content, by default, require at least one
        child. You can set this to true to allow them to be empty.
        Plots with inlne content can always be empty.
        */
        canBeEmpty?: boolean;
        /**
        Whether the sides of this plot act as a 'barrier' when {@link
        state.GardSelection.nextNormalCursor normalizing} a cursor
        position, which means that a separate cursor position exists
        at its boundary. By default, nodes that are {@link
        Plot.Spec.isolating isolating}, {@link
        Plot.Spec.preserveWhitespace whitespace-preserving}, or both
        a {@link Leaf leaf} and a block count as barriers.
        */
        cursorBarrier?: boolean;
        /**
        Indicates that this type of block is the default generic block
        type in parent nodes where it may occur (which is appropriate
        for, for example, paragraphs tags). Default blocks should not
        have a required param. When not specified, the configuration
        precedence order determines which child type is the default.
        */
        defaultBlock?: boolean;
        /**
        Controls whether whitespace inside this type of node should be
        preserved. Disables whitespace collapsing and the replacement
        of newlines with line break nodes in the parser and
        serializer. Defaults to false, unless the node has the {@link
        Node.Role.Code} role.
        */
        preserveWhitespace?: boolean;
        /**
        Isolating plots disallow some kinds of editing across their
        borders (such as backspacing or unwrapping). A table cell is
        an example of a node that you'd use this for.
        */
        isolating?: boolean;
        /**
        Block containers are, by default, assumed to arrange their
        children vertically below each other (`"column"`). You can set this
        to `"row"` to tell the editor that this container's children
        are horizontally next to each other.
        */
        orientation?: "row" | "column";
        /**
        Defining nodes are preserved (when possible) when their content
        is duplicated (dragged, pasted, etc) into a new position.
        Defaults to false.
        */
        defining?: boolean;
        /**
        Neutral nodes may be completely replaced when their entire
        content gets replaced. Defaults to `!`{@link
        Plot.Spec.defining}.
        */
        neutral?: boolean;
        /**
        Whether block nodes of this type should be automatically
        joined when they become adjacent through an edit. Defaults to
        false. Note that editing commands need to explicitly call
        {@link command.autoJoinBlocks} for joining to happen.
        */
        autoJoin?: boolean | ((before: Plot.Tag, after: Plot.Tag) => boolean);
        /**
        By default, splitting a textblock at the end will revert the new
        block to the default type of textblock at that position. Setting
        this to true on a textblock type will prevent that behavior.
        */
        preserveOnSplitAtEnd?: boolean;
        /**
        For inline nodes with inline content, this determines whether
        there are normalized cursor positions directly inside the node.
        The default is to only have cursor positions right outside the
        node.
        */
        cursorInsideBounds?: boolean;
    }
    /**
    Document plots are used as the top level plot in a document.
    They offer some additional methods and, unlike normal plots,
    their {@link Plot.Doc.length `length` property} reports only the
    length of their content, without counting open/close tokens
    (because those are not part of the document).
    */
    class Doc extends Plot {
        /**
        The document's schema.
        */
        readonly schema: Schema;
        private constructor();
        /**
        The length of the document's content.
        */
        get length(): number;
        /**
        Resolve the given position in the document, returning an
        object describing its context.
        */
        resolve(pos: number): Pos;
        /**
        Resolve the node at the given position, providing information
        about its context.
        */
        resolveNode(pos: number): Pos.Node | null;
        /**
        Like {@link Plot.Doc.resolveNode}, but only resolves plot
        nodes.
        */
        resolvePlot(pos: number): Pos.Plot | null;
        /**
        Get the context stack (the array of wrapping plot tags,
        inner-to-outer) at the given position.
        */
        contextAt(pos: number, maxDepth?: number): readonly Plot.Tag[];
        /**
        Create a slice of the content between `from` and `to`.
        */
        slice(from: number, to?: number): Slice;
    }
}

/**
Exception type used for errors related to schema definition.
*/
declare class SchemaError extends Error {
}
/**
Exception type used when validating content against a schema, when
checking JSON input, or when validating change sets.
*/
declare class ValidationError extends Error {
}

type Modification = {
    add: Mark;
} | {
    remove: Mark;
};
/**
A change set contains a series of changes to a given document that
produce a new document. They divide the document in a number of
sections that are either kept as-is, have marks added or removed,
or are replaced entirely by a {@link Slice} of new tokens.

Change sets store the length of their start document and will
raise an error if you try to apply them to a document with a
different length.
*/
declare class ChangeSet {
    /**
    Pairs of integers, with the first one representing the length
    of the section in the start document, the second either -1 for
    a preserved, -2 for a marked range, or a non-negative
    insertion length for a replacement.
    */
    readonly sections: ChangeSet.Sections;
    private _length;
    private _newLength;
    private constructor();
    /**
    The length of the start document.
    */
    get length(): number;
    /**
    The length of the updated document.
    */
    get newLength(): number;
    /**
    Returns true if this set makes no changes.
    */
    get empty(): boolean;
    /**
    Compare this change set to another one.
    */
    eq(other: ChangeSet): boolean;
    /**
    Apply the changes to the given document, producing a new
    document. Will raise an error if the document length doesn't
    match or the change is not well-formed for this document.
    
    The result of this method is cached, so applying the same change
    set to the same document multiple times is cheap.
    */
    apply(doc: Plot.Doc): Plot.Doc;
    /**
    Convert this change set to a JSON-serializeable representation.
    */
    toJSON(): ChangeSet.JSON;
    /**
    Parse a JSON representation into a change set.
    */
    static fromJSON(schema: Schema, json: ChangeSet.JSON): ChangeSet;
    /**
    Perform an [operational
    transformation](https://en.wikipedia.org/wiki/Operational_transformation)
    on this change and the given other change. Both changes should
    start with the given document `doc`. Returns a modified version
    of the change that can be applied _after_ the other change has
    been applied to `doc`.
    
    By default, the semantics of conflicting changes are resolved as
    if `this` came after `other`. That means content inserted in the
    same position by both will put the content inserted by `this`
    last. You can set `before` to true to invert this, making `this`
    come before `other`. Setting this correctly is necessary to make
    the result of independently applied transformed changes converge.
    */
    transform(other: ChangeSet, doc: Plot.Doc, before?: boolean): ChangeSet;
    /**
    Compose two change sets, where `other` starts from the document
    produced by `this`, into a single change set.
    */
    compose(other: ChangeSet): ChangeSet;
    /**
    Compute the inverse of this change set. `doc` is the document
    that the change starts from. For a given change `A`,
    `doc.apply(A).apply(A.invert(doc))` equals `doc`.
    */
    invert(doc: Plot.Doc): ChangeSet;
    /**
    Returns the change itself if it can be applied to this document
    and produce a valid new document, or a modified version of the
    change that _is_ correct.
    */
    correct(doc: Plot.Doc, local?: boolean): ChangeSet;
    /**
    Map a document position through this change, returning either
    the adjusted position, or `null` if a the tracked position is
    deleted.
    
    The `assoc` parameter, which defaults to `-1`, decides to which
    side the position sticks. When content is inserted precisely at
    the mapped position, it will stay before it when `assoc == -1`,
    and move after it when `assoc == 1`.
    
    By default, mapping will always return a new position, even if
    all the content around the position was deleted. You can pass a
    {@link ChangeSet.TrackMode tracking mode} to make it return null
    when either the token before, the token after, or both tokens
    around the position were deleted.
    */
    mapPos(pos: number, assoc?: -1 | 1): number;
    mapPos(pos: number, assoc: -1 | 1, track?: ChangeSet.TrackMode): number | null;
    /**
    Scan through the content inserted by this change until a tag
    that matches the predicate is found. If successful, return the
    position (in the new document) of the tag. This can be useful
    for when creating a new selection after a fitted change.
    */
    findInserted(pred: (tag: Node.Tag) => boolean): number | null;
    /**
    Returns true if any of the replaced ranges in this change set
    overlaps or is adjacent to the given range.
    */
    touchesRange(from: number, to: number): boolean | "cover";
    /**
    Iterate over the ranges in this changeset, calling `replaced`
    for ranges that have been replaced, and `preserved` for ranges
    that are either preserved as-is (when `modifications` is null)
    or only have marks modified.
    */
    iterChanges(replaced: (fromA: number, toA: number, fromB: number, toB: number, inserted: Slice) => void, preserved?: (fromA: number, toA: number, fromB: number, toB: number, modifications: readonly Modification[] | null) => void): void;
    /**
    Iterate over the sections of the document this change leaves
    unchanged or which have only mark changes. `posA` provides the
    position of the range in the original document, `posB` the
    position in the changed document.
    */
    iterGaps(gap: (fromA: number, toA: number, fromB: number, toB: number) => void, change?: (fromA: number, toA: number, fromB: number, toB: number) => void): void;
    /**
    Iterate over the ranges changed (either replaced or modified) by
    this change desc. Joins adjacent changed ranges together.
    */
    iterChangedRanges(range: (fromA: number, toA: number, fromB: number, toB: number) => void): void;
    /**
    Create a change set. All positions in the given change
    description refer to positions in the starting document.
    */
    static create(doc: Plot.Doc, spec: ChangeSet.Spec): ChangeSet;
    /**
    Returns an empty change set for a document of the given length.
    */
    static empty(length: number): ChangeSet;
    /**
    Transform two change set starting from the same document over
    each other, returning two transformed change sets. The returned
    `a` can be applied after the `b` passed in, and the returned `b`
    can be applied after the `a` passed in, resulting the same final
    document on both sides. `a` is taken to happen before `b` when insertions
    at the same position need to be merged.
    
    This method is slightly more efficient than transforming both steps
    separately.
    */
    static transform(doc: Plot.Doc, a: ChangeSet, b: ChangeSet): {
        a: ChangeSet;
        b: ChangeSet;
    };
}
declare namespace ChangeSet {
    /**
    Representation of a single document change, as used in {@link
    ChangeSet.Spec}. Changes can either affect marks (when `add` or
    `remove` is present), or replace a part of the document
    (otherwise).
    */
    type Change = {
        /**
        The start position of the change.
        */
        from: number;
        /**
        The end position. When not given, this defaults to `from` for
        replacement changes, and `from + 1` for changes that add or
        remove marks.
        */
        to?: number;
        /**
        Replace the given range with this slice.
        */
        insert?: Slice | readonly Token[];
        /**
        For deletions or insertions where it isn't obvious that the
        replacement will produce a valid document, set this to `true`
        or a stack of context tags to make the library process the
        replacement to make sure it fits. Context tags (passed with
        the innermost tag first, as in {@link Plot.Doc.contextAt} may
        be used as wrappers when fitting the slice.
        */
        fit?: boolean | readonly Plot.Tag[];
        /**
        Add the given mark to this change's range. Cannot be combined
        with `insert`.
        */
        add?: Mark;
        /**
        Remove the given mark from this range.
        */
        remove?: Mark;
    };
    /**
    This type is used to describe a {@link ChangeSet.create change
    set}. A spec can be a single change, an existing change set, a
    set of changes wrapped in a correction scope, or an array of the
    same.
    
    The {@link ChangeSet.Change.from `from`} and {@link
    ChangeSet.Change.to `to`} positions in the changes in a set spec
    all refer to the origin document. It is not necessary to
    'compensate' for earlier changes in those specified later. If,
    for some reason, you have changes that should be applied after
    each other, create multiple change sets and {@link
    ChangeSet.compose compose} them.
    
    By default, the provider of changes vouches for their
    correctness. It is possible to create change sets that will
    error when you try to apply them, because applying them does not
    create a well formed document.
    
    When making changes where you cannot guarantee that they fit,
    you should either use {@link ChangeSet.Change.fit}, which will
    try to change the range of a change to make it fit, or the
    `{correct}` form, which will combine the changes it is given,
    and then process them as a whole to make sure they produce a
    valid document. The `local` flag indicates that the effect of
    changes should be kept as narrow as possible—for example, that
    nodes opened but not closed by them should not extend to cover
    content after the change.
    */
    type Spec = ChangeSet.Change | {
        correct: ChangeSet.Spec;
        local?: boolean;
    } | ChangeSet | readonly ChangeSet.Spec[];
    /**
    The sections in a change set are represented as an array, with
    each pair of two numbers describing a changed section. The first
    number is the length of the section in the old document. The
    second number is `-1` for unchanged sections, `-2` for updated
    sections, and a non-negative number (the length of the inserted
    content) for replacements.
    */
    type Sections = readonly number[];
    /**
    The JSON representation of a change set.
    */
    type JSON = readonly {
        length: number;
        modifications?: readonly ModificationJSON[];
        replacement?: Slice.JSON;
    }[];
    /**
    Modes available in {@link ChangeSet.mapPos} to control whether
    `null` is returned on nearby deletions.
    */
    type TrackMode = "before" | "after" | "around";
}
type ModificationJSON = {
    add: string;
    value: any;
} | {
    remove: string;
    value: any;
};

/**
Serialize a document to an array of {@link Elt elements} and
strings. These can be converted to a DOM structure with {@link
Elt.Fragment.toDOM} or an HTML string with {@link
Elt.Fragment.toHTML}. Will use the shapes specified in the {@link
Node.Spec.shape node specs}, unless {@link
serialize.Options.override overridden}.
*/
declare function serialize(doc: Plot.Doc, options?: serialize.Options): Elt.Fragment;
declare namespace serialize {
    /**
    The options passed to serializer functions.
    */
    interface Options {
        /**
        Set this to true to replace nodes with the {@link
        Node.Role.LineBreak `LineBreak`} role with newline characters.
        */
        emitNewlines?: boolean;
        /**
        Override the shape used for some tags. Return null to fall
        back to the node's default shape.
        */
        override?: (tag: Node.Tag) => Elt | null;
    }
    /**
    Serialize a single node.
    */
    function node(node: Node, options: serialize.Options): Elt | string;
    /**
    Serialize a slice.
    */
    function slice(slice: Slice, options: slice.Options): Elt.Fragment;
    namespace slice {
        /**
        Options passed to {@link serialize.slice}.
        */
        interface Options extends serialize.Options {
            /**
            If given, the serializer will set this attribute to
            `"start"`, `"end"`, or `"start end"` for nodes that are open
            at the start and/or end of the slice.
            */
            openAttr?: string;
            /**
            The slice's context. Will be used to determine the type of
            open nodes at the start of the slice.
            */
            context?: readonly Plot.Tag[];
            /**
            The amount of context nodes to include in the output.
            Defaults to 0, meaning only use those that are open at the
            start of the slice.
            */
            includeContext?: number;
        }
    }
}

export { Attributes, ChangeSet, Elt, Leaf, Mark, Node, Plot, Pos, Schema, SchemaError, Shape, Slice, Token, ValidationError, parse, serialize };
