import { IServiceID } from "../../../types/kernel.js"; import "../../../types/index.js"; import { LexicalNode } from "lexical"; /** * XML Reader function type - converts XML element to Lexical node */ type XMLReaderFunc = (xmlElement: any, children: any[]) => any | any[] | false; /** * XML Writer function type - converts Lexical node to XML string */ type XMLWriterFunc = (node: LexicalNode, ctx: IWriterContext, indent: number, nodeToXML: (node: any, lines: string[], indent?: number) => void) => IXmlNode | HandleChildrenResult | false; /** * Record of XML readers indexed by tag name */ type XMLReaderRecord = { [tagName: string]: XMLReaderFunc | XMLReaderFunc[]; }; /** * Record of XML writers indexed by node type */ type XMLWriterRecord = { [nodeType: string]: XMLWriterFunc | XMLWriterFunc[]; }; interface IXmlNode { attributes: { [key: string]: string; }; children?: IXmlNode[]; tagName: string; textContent?: string; } interface HandleChildrenResult { lines: string[]; } interface IWriterContext { createXmlNode(tagName: string, attributes?: { [key: string]: string; }, textContent?: string): IXmlNode; } /** * ILitexmlService - Service interface for extending Litexml plugin * Allows other plugins to register custom XML readers and writers */ interface ILitexmlService { /** * Get all registered XML readers */ getXMLReaders(): XMLReaderRecord; /** * Get all registered XML writers */ getXMLWriters(): XMLWriterRecord; /** * Check if a reader is registered for a tag */ hasXMLReader(tagName: string): boolean; /** * Check if a writer is registered for a node type */ hasXMLWriter(nodeType: string): boolean; /** * Register a custom XML reader for a specific tag name * @param tagName - XML tag name to handle (case-insensitive) * @param reader - Function that converts XML element to Lexical node */ registerXMLReader(tagName: string, reader: XMLReaderFunc): void; /** * Register a custom XML writer for a specific Lexical node type * @param nodeType - Lexical node type to handle * @param writer - Function that converts Lexical node to XML string */ registerXMLWriter(nodeType: string, writer: XMLWriterFunc): void; } /** * Service ID for Litexml service */ declare const ILitexmlService: IServiceID; /** * Default implementation of ILitexmlService */ declare class LitexmlService implements ILitexmlService { private readers; private writers; registerXMLReader(tagName: string, reader: XMLReaderFunc): void; registerXMLWriter(nodeType: string, writer: XMLWriterFunc): void; getXMLReaders(): XMLReaderRecord; getXMLWriters(): XMLWriterRecord; hasXMLReader(tagName: string): boolean; hasXMLWriter(nodeType: string): boolean; } export { HandleChildrenResult, ILitexmlService, IWriterContext, IXmlNode, LitexmlService, XMLReaderFunc, XMLReaderRecord, XMLWriterFunc, XMLWriterRecord };