import { ElementNode, LexicalNode, RangeSelection, LexicalEditor } from 'lexical'; import type { PointType } from 'lexical/LexicalSelection'; import type { TranslationBlock, NonTextNodeMatch, TranslateAPI, TranslationBlockWithSelection } from './types'; export declare const defaultTranslateAPI: TranslateAPI; export declare function $copyNodeDeep(node: T): T; export declare const insertNodesAfter: (node: LexicalNode, nodesToInsert: LexicalNode[]) => void; /** * 遍历顶层结点,获取需要翻译的结点列表 * - HeadingNode * - ParagraphNode * - ListItemNode * - QuoteNode */ export declare const $extractTranslationNodes: (topLevelNodes: ElementNode[]) => ElementNode[]; /** * 以下 node 符合 translation node: * - heading node * - paragraph node * - list item node * - quote node */ export declare const $extractTextContentFromTranslationNode: (translationNode: ElementNode, selectedNodes?: LexicalNode[]) => string; export declare const $extractTranslationBlocks: (editor: LexicalEditor, translationNodes?: ElementNode[]) => TranslationBlock[]; /** * 处理带有 `###key###` 的文本, 将普通文本转成 TextNode, 将 `###key###` 替换成 key 对应的 Node * @param {string} text - 如: "a ###1### b ###20### c" * @param {NonTextNodeMatch[]} matches - 如: [{key: 1, index: 2, length: 7}, {key: 20, index: 12, length: 8}] * @returns LexicalNode 数组, 如: [, , , , , ] */ export declare const rearrangeNodes: (text: string, matches: NonTextNodeMatch[]) => LexicalNode[]; /** * 处理带有 `###key###` 的文本 (对应一个 translation node 的文本), 解析文本中 `###key###` 的信息, * 包括 Node Key, 在文本中的 index, 自身字符长度 * 比如: "a ###1### b ###20### c" => [{key: 1, index: 2, length: 7}, {key: 20, index: 12, length: 8}] */ export declare const matchNonTextNodes: (text: string) => NonTextNodeMatch[]; export declare const $replaceTranslation: (translationBlock: TranslationBlock, editor: LexicalEditor) => LexicalNode | ElementNode | null; export declare const $replaceTranslations: (editor: LexicalEditor, translationBlocks: TranslationBlock[]) => (LexicalNode | ElementNode | null)[]; export declare const $insertTranslations: (translationBlocks: TranslationBlock[], selection: RangeSelection) => void; export declare const $preview: (translationBlocks: TranslationBlock[]) => string; /** * TODO: 剥除未选中的部分 */ export declare const $extractTranslationBlockWithSelection: (translationNode: ElementNode, point: PointType, backward?: boolean) => TranslationBlockWithSelection | null; export declare const getTopLevelNodesFromSelection: (selection: RangeSelection) => ElementNode[]; export declare const $extractTranslationBlocksFromSelection: (editor: LexicalEditor, selection: RangeSelection) => TranslationBlockWithSelection[];