import { Node as PmNode, Mark as PmMark, MarkType, NodeType, ParseRule as PmParseRule } from 'prosemirror-model'; import { EditorState } from 'prosemirror-state'; /** * Primitive attribute value types */ export type AttributePrimitive = string | number | boolean | null | undefined; /** * Allowed attribute values (recursive to permit nested objects/arrays) */ export type AttributeValue = AttributePrimitive | AttributeValue[] | { [key: string]: AttributeValue; }; /** * Supported attribute default value (raw value or lazy getter) */ export type AttributeDefault = AttributeValue | (() => AttributeValue); /** * Attribute specification for extensions. */ export interface AttributeSpec { /** Default value for the attribute */ default: AttributeDefault; /** Whether the attribute should be rendered in the DOM */ rendered: boolean; /** Function to render the attribute to the DOM */ renderDOM: ((attrs: Record) => Record | null) | null; /** Function to parse the attribute from the DOM */ parseDOM: ((node: HTMLElement) => AttributeValue) | null; /** Whether the attribute should be kept when splitting */ keepOnSplit: boolean; } /** * Extension attribute item with type and name. */ export interface ExtensionAttribute { /** The type (extension name) this attribute belongs to */ type: string; /** The attribute name */ name: string; /** The attribute specification */ attribute: AttributeSpec; } /** * Global attribute configuration. */ export interface GlobalAttribute { /** Types this global attribute applies to */ types: string[]; /** Map of attribute names to specs */ attributes: Record>; } /** * Extension with type information. */ export interface ExtensionLike { type: string; name: string; options: Record; storage: Record; config: Record; } /** * ProseMirror ParseRule type (imported from prosemirror-model) */ export type ParseRule = PmParseRule; /** * Attribute class is a space that contains * methods for working with attributes. */ export declare class Attribute { #private; /** * Get a list of all attributes defined in the extensions. * @param extensions List of all extensions. * @returns Extension attributes. */ static getAttributesFromExtensions(extensions: ExtensionLike[]): ExtensionAttribute[]; /** * Inserts extension attributes into parseRule attributes. * @param parseRule PM ParseRule. * @param extensionAttrs List of attributes to insert. */ static insertExtensionAttrsToParseRule(parseRule: ParseRule, extensionAttrs: ExtensionAttribute[]): ParseRule; /** * Get attributes to render. * @param nodeOrMark Node or Mark. * @param extensionAttrs Extension attributes. */ static getAttributesToRender(nodeOrMark: PmNode | PmMark, extensionAttrs: ExtensionAttribute[]): Record; /** * Merges attributes. * @param objects Objects with attributes. * @returns Object with merged attributes. */ static mergeAttributes(...objects: (Record | null | undefined)[]): Record; /** * Get extension attributes that should be splitted by keepOnSplit flag. * @param extensionAttrs Array of attributes. * @param typeName The type of the extension. * @param attributes The extension attributes. * @returns The splitted attributes. */ static getSplittedAttributes(extensionAttrs: ExtensionAttribute[], typeName: string, attributes: Record): Record; /** * Get mark attrs on the current editor state. * @param state The current editor state. * @param typeOrName The mark type or name. * @returns The mark attrs. */ static getMarkAttributes(state: EditorState, typeOrName: string | MarkType): Record; /** * Get node attrs on the current editor state. * @param state The current editor state. * @param typeOrName The node type or name. * @returns The node attrs. */ static getNodeAttributes(state: EditorState, typeOrName: string | NodeType): Record; /** * Get node or mark attrs on the current editor state. * @param state The current editor state. * @param typeOrName The node/mark type or name. * @returns The attrs of the node/mark or an empty object. */ static getAttributes(state: EditorState, typeOrName: string | NodeType | MarkType): Record; } //# sourceMappingURL=Attribute.d.ts.map