import { InlineTool, InlineToolConstructorOptions, ToolConfig } from '@editorjs/editorjs'; import { MenuConfig } from '@editorjs/editorjs/types/tools/menu-config'; type ColorReceiver = (defColors: string[]) => false | string[]; type Config = ToolConfig<{ backgroundColors?: false | string[] | ColorReceiver; /** @default 'background color' */ backgroundColorLabel?: string; /** @default 'clear' */ defaultItemLabel?: string; frontColors?: false | string[] | ColorReceiver; /** @default 'front color' */ frontColorLabel?: string; /** @default 'Ctrl+J' */ shortcut?: string; /** @default 'palette' */ title?: string; }>; /** * inline color palette plugin for editorjs * @plugin ColorTool * @config {Config} */ declare class ColorTool implements InlineTool { private api; private config; private actionNodes; private _showActions; private range; private listeners; static get isInline(): boolean; static get sanitize(): { [ColorTool.colorToken.tag]: boolean; }; static _shortcut: string; static get shortcut(): string; static _title: string; static get title(): string; static get defColors(): { frontColors: string[]; backgroundColors: string[]; }; static get colorToken(): { tag: string; className: string; }; static get defTokenSymbol(): { frontColors: string; backgroundColors: string; }; get showActions(): boolean; set showActions(state: boolean); constructor({ api, config }: InlineToolConstructorOptions); handleConfig(config: Config): void; createTokenElement(): HTMLObjectElement | HTMLElement | HTMLAnchorElement | HTMLAreaElement | HTMLAudioElement | HTMLBaseElement | HTMLQuoteElement | HTMLBodyElement | HTMLBRElement | HTMLButtonElement | HTMLCanvasElement | HTMLTableCaptionElement | HTMLTableColElement | HTMLDataElement | HTMLDataListElement | HTMLModElement | HTMLDetailsElement | HTMLDialogElement | HTMLDivElement | HTMLDListElement | HTMLEmbedElement | HTMLFieldSetElement | HTMLFormElement | HTMLHeadingElement | HTMLHeadElement | HTMLHRElement | HTMLHtmlElement | HTMLIFrameElement | HTMLImageElement | HTMLInputElement | HTMLLabelElement | HTMLLegendElement | HTMLLIElement | HTMLLinkElement | HTMLMapElement | HTMLMenuElement | HTMLMetaElement | HTMLMeterElement | HTMLOListElement | HTMLOptGroupElement | HTMLOptionElement | HTMLOutputElement | HTMLParagraphElement | HTMLPictureElement | HTMLPreElement | HTMLProgressElement | HTMLScriptElement | HTMLSelectElement | HTMLSlotElement | HTMLSourceElement | HTMLSpanElement | HTMLStyleElement | HTMLTableElement | HTMLTableSectionElement | HTMLTableCellElement | HTMLTemplateElement | HTMLTextAreaElement | HTMLTimeElement | HTMLTitleElement | HTMLTableRowElement | HTMLTrackElement | HTMLUListElement | HTMLVideoElement; findClosestTokenElement(): HTMLElement | null; isTokenElement(node: Node): boolean; isBlockContainer(node: Node): boolean; render(): MenuConfig; checkState(selection: Selection): boolean; surround(range: Range): void; clear(): void; /** * EditorJS 销毁工具时调用,清理事件监听和 DOM 引用 */ destroy(): void; toggleActions(force?: boolean): void; renderActions(): HTMLElement; renderTextColorAction(): void; renderBgColorAction(): void; /** * 通用颜色操作渲染方法 */ private renderColorAction; /** * 通用默认颜色(清除)操作渲染方法 */ private renderDefaultColorAction; /** * 添加事件监听器并记录引用,用于后续 destroy 时清理 */ private addListener; handleColorChange(color: string, type: "textColor" | "backgroundColor", listEl: HTMLElement, ev?: Event): void; syncColorActive(listEl: HTMLElement, ev?: Event): void; handleRangeStyling(color: string, type: "textColor" | "backgroundColor"): void; handleRangeResetStyling(type: "textColor" | "backgroundColor"): void; handleRangeNormalStyling(color: string, type: "textColor" | "backgroundColor"): void; wrap(color: string, type: "textColor" | "backgroundColor"): void; applyStyling(color: string, type: "textColor" | "backgroundColor", el?: HTMLElement): void; processNode(elOrFr: Element | DocumentFragment, color: string, type: "textColor" | "backgroundColor"): void; isRangeSurroundedByToken(): HTMLElement | null; cleanEmptyBoundaryAndInnerNode(node: Node): void; isResetStyling(color: string, type: "textColor" | "backgroundColor"): boolean; resetStyling(type: "textColor" | "backgroundColor", el: HTMLElement): void; findFathestTokenElement(range: Range): HTMLElement | null; resetFrgsStyling(elOrFr: Element | DocumentFragment, type: "textColor" | "backgroundColor"): void; /** * for performance, we just do very simple judgement here. */ applyStylingReset(type: "textColor" | "backgroundColor", fathestTokenEl: HTMLElement): boolean; } export { ColorTool }; export type { Config };