vendor/assets/javascripts/tinymce/tinymce.d.ts in tinymce-rails-5.8.2 vs vendor/assets/javascripts/tinymce/tinymce.d.ts in tinymce-rails-5.9.0

- old
+ new

@@ -14,12 +14,23 @@ index: number; } interface PathBookmark { start: number[]; end?: number[]; + isFakeCaret?: boolean; } declare type Bookmark = StringPathBookmark | RangeBookmark | IdBookmark | IndexBookmark | PathBookmark; +declare type NormalizedEvent<E, T = any> = E & { + readonly type: string; + readonly target: T; + readonly isDefaultPrevented: () => boolean; + readonly preventDefault: () => void; + readonly isPropagationStopped: () => boolean; + readonly stopPropagation: () => void; + readonly isImmediatePropagationStopped: () => boolean; + readonly stopImmediatePropagation: () => void; +}; declare type MappedEvent<T, K extends string> = K extends keyof T ? T[K] : any; interface NativeEventMap { 'beforepaste': Event; 'blur': FocusEvent; 'beforeinput': InputEvent; @@ -59,20 +70,11 @@ 'touchmove': TouchEvent; 'touchstart': TouchEvent; 'touchcancel': TouchEvent; 'wheel': WheelEvent; } -declare type EditorEvent<T> = T & { - target: any; - type: string; - preventDefault: () => void; - isDefaultPrevented: () => boolean; - stopPropagation: () => void; - isPropagationStopped: () => boolean; - stopImmediatePropagation: () => void; - isImmediatePropagationStopped: () => boolean; -}; +declare type EditorEvent<T> = NormalizedEvent<T>; interface EventDispatcherSettings { scope?: any; toggleEvent?: (name: string, state: boolean) => void | boolean; beforeFire?: <T>(args: EditorEvent<T>) => void; } @@ -86,11 +88,11 @@ private readonly settings; private readonly scope; private readonly toggleEvent; private bindings; constructor(settings?: Record<string, any>); - fire<K extends string, U extends MappedEvent<T, K>>(nameIn: K, argsIn?: U): EditorEvent<U>; + fire<K extends string, U extends MappedEvent<T, K>>(name: K, args?: U): EditorEvent<U>; on<K extends string>(name: K, callback: false | ((event: EditorEvent<MappedEvent<T, K>>) => void), prepend?: boolean, extra?: {}): this; off<K extends string>(name?: K, callback?: (event: EditorEvent<MappedEvent<T, K>>) => void): this; once<K extends string>(name: K, callback: (event: EditorEvent<MappedEvent<T, K>>) => void, prepend?: boolean): this; has(name: string): boolean; } @@ -118,52 +120,45 @@ hasRedo: () => boolean; transact: (callback: () => void) => UndoLevel; ignore: (callback: () => void) => void; extra: (callback1: () => void, callback2: () => void) => void; } -declare type ArrayCallback<T, R> = (x: T, i: number, xs: ReadonlyArray<T>) => R; -declare type ObjCallback<T, R> = (value: T, key: string, obj: Record<string, T>) => R; -declare type ArrayCallback$1<T, R> = ArrayCallback<T, R>; -declare type ObjCallback$1<T, R> = ObjCallback<T, R>; +declare type ArrayCallback$1<T, R> = (x: T, i: number, xs: ReadonlyArray<T>) => R; +declare type ObjCallback$1<T, R> = (value: T, key: string, obj: Record<string, T>) => R; +declare type ArrayCallback<T, R> = ArrayCallback$1<T, R>; +declare type ObjCallback<T, R> = ObjCallback$1<T, R>; interface Tools { is: (obj: any, type: string) => boolean; isArray: <T>(arr: any) => arr is Array<T>; inArray: <T>(arr: ArrayLike<T>, value: T) => number; grep: { - <T>(arr: ArrayLike<T> | null | undefined, pred?: ArrayCallback$1<T, boolean>): T[]; - <T>(arr: Record<string, T> | null | undefined, pred?: ObjCallback$1<T, boolean>): T[]; + <T>(arr: ArrayLike<T> | null | undefined, pred?: ArrayCallback<T, boolean>): T[]; + <T>(arr: Record<string, T> | null | undefined, pred?: ObjCallback<T, boolean>): T[]; }; trim: (str: string) => string; toArray: <T>(obj: ArrayLike<T>) => T[]; hasOwn: (obj: any, name: string) => boolean; makeMap: <T>(items: ArrayLike<T> | string, delim?: string | RegExp, map?: Record<string, T | string>) => Record<string, T | string>; each: { - <T>(arr: ArrayLike<T> | null | undefined, cb: ArrayCallback$1<T, void | boolean>, scope?: any): boolean; - <T>(obj: Record<string, T> | null | undefined, cb: ObjCallback$1<T, void | boolean>, scope?: any): boolean; + <T>(arr: ArrayLike<T> | null | undefined, cb: ArrayCallback<T, void | boolean>, scope?: any): boolean; + <T>(obj: Record<string, T> | null | undefined, cb: ObjCallback<T, void | boolean>, scope?: any): boolean; }; map: { - <T, R>(arr: ArrayLike<T> | null | undefined, cb: ArrayCallback$1<T, R>): R[]; - <T, R>(obj: Record<string, T> | null | undefined, cb: ObjCallback$1<T, R>): R[]; + <T, R>(arr: ArrayLike<T> | null | undefined, cb: ArrayCallback<T, R>): R[]; + <T, R>(obj: Record<string, T> | null | undefined, cb: ObjCallback<T, R>): R[]; }; extend: (obj: Object, ext: Object, ...objs: Object[]) => any; create: (name: string, p: Object, root?: Object) => void; walk: <T = any>(obj: T, f: Function, n?: keyof T, scope?: any) => void; createNS: (name: string, o?: Object) => any; resolve: (path: string, o?: Object) => any; explode: (s: string, d?: string | RegExp) => string[]; _addCacheSuffix: (url: string) => string; } declare type EventUtilsCallback<T> = (event: EventUtilsEvent<T>) => void; -declare type EventUtilsEvent<T> = T & { - type: string; - target: any; - isDefaultPrevented: () => boolean; - preventDefault: () => void; - isPropagationStopped: () => boolean; - stopPropagation: () => void; - isImmediatePropagationStopped: () => boolean; - stopImmediatePropagation: () => void; +declare type EventUtilsEvent<T> = NormalizedEvent<T> & { + metaKey: boolean; }; interface EventUtilsConstructor { readonly prototype: EventUtils; new (): EventUtils; Event: EventUtils; @@ -229,11 +224,11 @@ each<T>(obj: T, callback: (key: string, obj: T[keyof T]) => void): void; trim(str: string): string; grep<T>(array: T[], callback: (item: any, i: number) => boolean): T[]; unique<T>(results: T[]): T[]; text(elem: Node): string; - contains(context: any, elem: Node): number; + contains(context: any, elem: Node): boolean; filter(expr: string, elems: Node[], not?: boolean): any; } interface DomQuery<T extends Node = Node> extends ArrayLike<T> { init: (selector?: DomQueryInitSelector<T>, context?: Node) => void; context: T; @@ -246,14 +241,14 @@ appendTo(val: DomQuerySelector<T>): this; attr(name: string, value: string | boolean | number | null): this; attr(attrs: Record<string, string | boolean | number | null>): this; attr(name: string): string; before(content: DomQuerySelector<T>): this; - children(selector?: string): DomQuery<ChildNode>; + children(selector?: string): DomQuery<Node & ChildNode>; clone(): this; closest(selector: DomQuerySelector<T>): this; - contents(selector?: string): DomQuery<ChildNode>; + contents(selector?: string): DomQuery<Node & ChildNode>; css(name: string, value: string | number | null): this; css(styles: Record<string, string | number | null>): this; css(name: string): string; each(callback: (i: number, value: T) => void): this; empty(): this; @@ -266,24 +261,24 @@ hide(): this; html(value: string): this; html(): string; is(selector: string | ((i: number, item: any) => boolean)): boolean; last(): this; - next(selector?: string): DomQuery<ChildNode>; - nextUntil(selector: DomQuerySelector<T>, until?: string): DomQuery<ChildNode>; + next(selector?: string): DomQuery<Node & ChildNode>; + nextUntil(selector: DomQuerySelector<T>, until?: string): DomQuery<Node & ChildNode>; off<K extends keyof HTMLElementEventMap>(name: K, callback?: EventUtilsCallback<HTMLElementEventMap[K]>): this; off<U>(name?: string, callback?: EventUtilsCallback<U>): this; offset(offset?: {}): {} | this; on<K extends keyof HTMLElementEventMap>(name: K, callback: EventUtilsCallback<HTMLElementEventMap[K]>): this; on<U>(name: string, callback: EventUtilsCallback<U>): this; parent(selector?: string): DomQuery<Node>; parents(selector?: string): DomQuery<Node>; parentsUntil(selector: DomQuerySelector<T>, filter?: string): DomQuery<Node>; prepend(content: DomQuerySelector<T>): this; prependTo(val: DomQuerySelector<T>): this; - prev(selector?: string): DomQuery<ChildNode>; - prevUntil(selector: DomQuerySelector<T>, filter?: string): DomQuery<ChildNode>; + prev(selector?: string): DomQuery<Node & ChildNode>; + prevUntil(selector: DomQuerySelector<T>, filter?: string): DomQuery<Node & ChildNode>; prop(name: string, value: string): this; prop(props: Record<string, string | number>): this; prop(name: string): string; push(...items: T[]): number; remove(): this; @@ -367,21 +362,21 @@ } interface SchemaRegExpMap { [name: string]: RegExp; } interface Schema { - children: Record<string, {}>; + children: Record<string, SchemaMap>; elements: Record<string, SchemaElement>; - getValidStyles: () => SchemaMap; - getValidClasses: () => SchemaMap; + getValidStyles: () => Record<string, string[]> | undefined; + getValidClasses: () => Record<string, SchemaMap> | undefined; getBlockElements: () => SchemaMap; - getInvalidStyles: () => SchemaMap; + getInvalidStyles: () => Record<string, SchemaMap> | undefined; getShortEndedElements: () => SchemaMap; getTextBlockElements: () => SchemaMap; getTextInlineElements: () => SchemaMap; getBoolAttrs: () => SchemaMap; - getElementRule: (name: string) => SchemaElement; + getElementRule: (name: string) => SchemaElement | undefined; getSelfClosingElements: () => SchemaMap; getNonEmptyElements: () => SchemaMap; getMoveCaretBeforeOnEnterElements: () => SchemaMap; getWhiteSpaceElements: () => SchemaMap; getSpecialElements: () => SchemaRegExpMap; @@ -391,11 +386,11 @@ addValidElements: (validElements: string) => void; setValidElements: (validElements: string) => void; addCustomElements: (customElements: string) => void; addValidChildren: (validChildren: any) => void; } -declare type Attributes = Array<{ +declare type Attributes$1 = Array<{ name: string; value: string; }> & { map: Record<string, string>; }; @@ -406,30 +401,33 @@ } declare class AstNode { static create(name: string, attrs?: Record<string, string>): AstNode; name: string; type: number; - attributes?: Attributes; + attributes?: Attributes$1; value?: string; shortEnded?: boolean; parent?: AstNode; firstChild?: AstNode; lastChild?: AstNode; next?: AstNode; prev?: AstNode; + raw?: boolean; + fixed?: boolean; constructor(name: string, type: number); replace(node: AstNode): AstNode; - attr(name: string, value: string | null): AstNode; - attr(name: Record<string, string | null>): AstNode; - attr(name: string): string; + attr(name: string, value: string | null): AstNode | undefined; + attr(name: Record<string, string | null>): AstNode | undefined; + attr(name: string): string | undefined; clone(): AstNode; wrap(wrapper: AstNode): AstNode; unwrap(): void; remove(): AstNode; append(node: AstNode): AstNode; insert(node: AstNode, refNode: AstNode, before?: boolean): AstNode; getAll(name: string): AstNode[]; + children(): AstNode[]; empty(): AstNode; isEmpty(elements: SchemaMap, whitespace?: SchemaMap, predicate?: (node: AstNode) => boolean): boolean; walk(prev?: boolean): AstNode; } declare type Content = string | AstNode; @@ -445,21 +443,12 @@ interface SetContentArgs { format?: string; set?: boolean; content?: string; no_events?: boolean; + no_selection?: boolean; } -interface BlobCache { - create: (o: string | BlobInfoData, blob?: Blob, base64?: string, name?: string, filename?: string) => BlobInfo; - add: (blobInfo: BlobInfo) => void; - get: (id: string) => BlobInfo | undefined; - getByUri: (blobUri: string) => BlobInfo | undefined; - getByData: (base64: string, type: string) => BlobInfo | undefined; - findFirst: (predicate: (blobInfo: BlobInfo) => boolean) => BlobInfo | undefined; - removeByUri: (blobUri: string) => void; - destroy: () => void; -} interface BlobInfoData { id?: string; name?: string; filename?: string; blob: Blob; @@ -474,10 +463,20 @@ blob: () => Blob; base64: () => string; blobUri: () => string; uri: () => string | undefined; } +interface BlobCache { + create: (o: string | BlobInfoData, blob?: Blob, base64?: string, name?: string, filename?: string) => BlobInfo; + add: (blobInfo: BlobInfo) => void; + get: (id: string) => BlobInfo | undefined; + getByUri: (blobUri: string) => BlobInfo | undefined; + getByData: (base64: string, type: string) => BlobInfo | undefined; + findFirst: (predicate: (blobInfo: BlobInfo) => boolean) => BlobInfo | undefined; + removeByUri: (blobUri: string) => void; + destroy: () => void; +} interface NotificationManagerImpl { open: (spec: NotificationSpec, closeCallback?: () => void) => NotificationApi; close: <T extends NotificationApi>(notification: T) => void; reposition: <T extends NotificationApi>(notifications: T[]) => void; getArgs: <T extends NotificationApi>(notification: T) => NotificationSpec; @@ -508,11 +507,11 @@ } interface UploadFailureOptions { remove?: boolean; } declare type UploadHandler = (blobInfo: BlobInfo, success: (url: string) => void, failure: (err: string, options?: UploadFailureOptions) => void, progress?: (percent: number) => void) => void; -interface UploadResult { +interface UploadResult$2 { url: string; blobInfo: BlobInfo; status: boolean; error?: { options: UploadFailureOptions; @@ -528,62 +527,65 @@ declare type ApplyFormat = BlockFormat | InlineFormat | SelectorFormat; declare type RemoveFormat = RemoveBlockFormat | RemoveInlineFormat | RemoveSelectorFormat; declare type Format = ApplyFormat | RemoveFormat; declare type Formats = Record<string, Format | Format[]>; declare type FormatAttrOrStyleValue = string | ((vars?: FormatVars) => string); -declare type FormatVars = Record<string, string>; -interface CommonFormat<T> { +declare type FormatVars = Record<string, string | null>; +interface BaseFormat<T> { ceFalseOverride?: boolean; classes?: string | string[]; collapsed?: boolean; exact?: boolean; expand?: boolean; links?: boolean; + mixed?: boolean; + block_expand?: boolean; onmatch?: (node: Node, fmt: T, itemName: string) => boolean; - onformat?: (elm: Node, fmt: T, vars?: FormatVars, node?: Node | RangeLikeObject) => void; + remove?: 'none' | 'empty' | 'all'; remove_similar?: boolean; + split?: boolean; + deep?: boolean; + preserve_attributes?: string[]; } -interface CommonApplyFormat<T> extends CommonFormat<T> { +interface Block { + block: string; + list_block?: string; + wrapper?: boolean; +} +interface Inline { + inline: string; +} +interface Selector { + selector: string; + inherit?: boolean; +} +interface CommonFormat<T> extends BaseFormat<T> { attributes?: Record<string, FormatAttrOrStyleValue>; - preview?: string | boolean; styles?: Record<string, FormatAttrOrStyleValue>; toggle?: boolean; - wrapper?: boolean; + preview?: string | false; + onformat?: (elm: Node, fmt: T, vars?: FormatVars, node?: Node | RangeLikeObject) => void; + clear_child_styles?: boolean; merge_siblings?: boolean; merge_with_parents?: boolean; + defaultBlock?: string; } -interface BlockFormat extends CommonApplyFormat<BlockFormat> { - block: string; - block_expand?: boolean; +interface BlockFormat extends Block, CommonFormat<BlockFormat> { } -interface InlineFormat extends CommonApplyFormat<InlineFormat> { - inline: string; - clear_child_styles?: boolean; +interface InlineFormat extends Inline, CommonFormat<InlineFormat> { } -interface SelectorFormat extends CommonApplyFormat<SelectorFormat> { - selector: string; - defaultBlock?: string; - inherit?: boolean; +interface SelectorFormat extends Selector, CommonFormat<SelectorFormat> { } -interface CommonRemoveFormat<T> extends CommonFormat<T> { - remove?: 'none' | 'empty' | 'all'; +interface CommonRemoveFormat<T> extends BaseFormat<T> { attributes?: string[] | Record<string, FormatAttrOrStyleValue>; styles?: string[] | Record<string, FormatAttrOrStyleValue>; - split?: boolean; - deep?: boolean; - mixed?: boolean; } -interface RemoveBlockFormat extends CommonRemoveFormat<RemoveBlockFormat> { - block: string; - list_block?: string; +interface RemoveBlockFormat extends Block, CommonRemoveFormat<RemoveBlockFormat> { } -interface RemoveInlineFormat extends CommonRemoveFormat<RemoveInlineFormat> { - inline: string; - preserve_attributes?: string[]; +interface RemoveInlineFormat extends Inline, CommonRemoveFormat<RemoveInlineFormat> { } -interface RemoveSelectorFormat extends CommonRemoveFormat<RemoveSelectorFormat> { - selector: string; +interface RemoveSelectorFormat extends Selector, CommonRemoveFormat<RemoveSelectorFormat> { } type Format_d_Formats = Formats; type Format_d_Format = Format; type Format_d_ApplyFormat = ApplyFormat; type Format_d_BlockFormat = BlockFormat; @@ -925,11 +927,11 @@ } interface SeparatorMenuItemSpec { type?: 'separator'; text?: string; } -declare type ColumnTypes = number | 'auto'; +declare type ColumnTypes$1 = number | 'auto'; declare type SeparatorItemSpec = SeparatorMenuItemSpec; interface AutocompleterItemSpec { type?: 'autocompleteitem'; value: string; text?: string; @@ -939,11 +941,11 @@ declare type AutocompleterContents = SeparatorItemSpec | AutocompleterItemSpec | CardMenuItemSpec; interface AutocompleterSpec { type?: 'autocompleter'; ch: string; minChars?: number; - columns?: ColumnTypes; + columns?: ColumnTypes$1; matches?: (rng: Range, text: string, pattern: string) => boolean; fetch: (pattern: string, maxResults: number, fetchOptions: Record<string, any>) => Promise<AutocompleterContents[]>; onAction: (autocompleterApi: AutocompleterInstanceApi, rng: any, value: string, meta: Record<string, any>) => void; maxResults?: number; highlightOn?: string[]; @@ -1046,15 +1048,38 @@ } declare type ContextMenuContents = string | ContextMenuItem | SeparatorMenuItemSpec | ContextSubMenu; interface ContextMenuApi { update: (element: Element) => string | Array<ContextMenuContents>; } -interface FancyMenuItemSpec { +interface FancyActionArgsMap { + 'inserttable': { + numRows: number; + numColumns: number; + }; + 'colorswatch': { + value: string; + }; +} +interface BaseFancyMenuItemSpec { type: 'fancymenuitem'; fancytype: string; - onAction: (data: any) => void; + initData?: Record<string, unknown>; + onAction?: (data: Record<string, unknown>) => void; } +interface InsertTableMenuItemSpec extends BaseFancyMenuItemSpec { + fancytype: 'inserttable'; + onAction?: (data: FancyActionArgsMap['inserttable']) => void; +} +interface ColorSwatchMenuItemSpec extends BaseFancyMenuItemSpec { + fancytype: 'colorswatch'; + initData?: { + allowCustomColors?: boolean; + colors: ChoiceMenuItemSpec[]; + }; + onAction?: (data: FancyActionArgsMap['colorswatch']) => void; +} +declare type FancyMenuItemSpec = InsertTableMenuItemSpec | ColorSwatchMenuItemSpec; interface MenuItemSpec extends CommonMenuItemSpec { type?: 'menuitem'; icon?: string; onSetup?: (api: MenuItemInstanceApi) => (api: MenuItemInstanceApi) => void; onAction?: (api: MenuItemInstanceApi) => void; @@ -1149,10 +1174,12 @@ type PublicMenu_d_MenuItemInstanceApi = MenuItemInstanceApi; type PublicMenu_d_NestedMenuItemContents = NestedMenuItemContents; type PublicMenu_d_NestedMenuItemSpec = NestedMenuItemSpec; type PublicMenu_d_NestedMenuItemInstanceApi = NestedMenuItemInstanceApi; type PublicMenu_d_FancyMenuItemSpec = FancyMenuItemSpec; +type PublicMenu_d_ColorSwatchMenuItemSpec = ColorSwatchMenuItemSpec; +type PublicMenu_d_InsertTableMenuItemSpec = InsertTableMenuItemSpec; type PublicMenu_d_ToggleMenuItemSpec = ToggleMenuItemSpec; type PublicMenu_d_ToggleMenuItemInstanceApi = ToggleMenuItemInstanceApi; type PublicMenu_d_ChoiceMenuItemSpec = ChoiceMenuItemSpec; type PublicMenu_d_ChoiceMenuItemInstanceApi = ChoiceMenuItemInstanceApi; type PublicMenu_d_SeparatorMenuItemSpec = SeparatorMenuItemSpec; @@ -1165,11 +1192,11 @@ type PublicMenu_d_CardItemSpec = CardItemSpec; type PublicMenu_d_CardContainerSpec = CardContainerSpec; type PublicMenu_d_CardImageSpec = CardImageSpec; type PublicMenu_d_CardTextSpec = CardTextSpec; declare namespace PublicMenu_d { - export { PublicMenu_d_MenuItemSpec as MenuItemSpec, PublicMenu_d_MenuItemInstanceApi as MenuItemInstanceApi, PublicMenu_d_NestedMenuItemContents as NestedMenuItemContents, PublicMenu_d_NestedMenuItemSpec as NestedMenuItemSpec, PublicMenu_d_NestedMenuItemInstanceApi as NestedMenuItemInstanceApi, PublicMenu_d_FancyMenuItemSpec as FancyMenuItemSpec, PublicMenu_d_ToggleMenuItemSpec as ToggleMenuItemSpec, PublicMenu_d_ToggleMenuItemInstanceApi as ToggleMenuItemInstanceApi, PublicMenu_d_ChoiceMenuItemSpec as ChoiceMenuItemSpec, PublicMenu_d_ChoiceMenuItemInstanceApi as ChoiceMenuItemInstanceApi, PublicMenu_d_SeparatorMenuItemSpec as SeparatorMenuItemSpec, PublicMenu_d_ContextMenuApi as ContextMenuApi, PublicMenu_d_ContextMenuContents as ContextMenuContents, PublicMenu_d_ContextMenuItem as ContextMenuItem, PublicMenu_d_ContextSubMenu as ContextSubMenu, PublicMenu_d_CardMenuItemSpec as CardMenuItemSpec, PublicMenu_d_CardMenuItemInstanceApi as CardMenuItemInstanceApi, PublicMenu_d_CardItemSpec as CardItemSpec, PublicMenu_d_CardContainerSpec as CardContainerSpec, PublicMenu_d_CardImageSpec as CardImageSpec, PublicMenu_d_CardTextSpec as CardTextSpec, }; + export { PublicMenu_d_MenuItemSpec as MenuItemSpec, PublicMenu_d_MenuItemInstanceApi as MenuItemInstanceApi, PublicMenu_d_NestedMenuItemContents as NestedMenuItemContents, PublicMenu_d_NestedMenuItemSpec as NestedMenuItemSpec, PublicMenu_d_NestedMenuItemInstanceApi as NestedMenuItemInstanceApi, PublicMenu_d_FancyMenuItemSpec as FancyMenuItemSpec, PublicMenu_d_ColorSwatchMenuItemSpec as ColorSwatchMenuItemSpec, PublicMenu_d_InsertTableMenuItemSpec as InsertTableMenuItemSpec, PublicMenu_d_ToggleMenuItemSpec as ToggleMenuItemSpec, PublicMenu_d_ToggleMenuItemInstanceApi as ToggleMenuItemInstanceApi, PublicMenu_d_ChoiceMenuItemSpec as ChoiceMenuItemSpec, PublicMenu_d_ChoiceMenuItemInstanceApi as ChoiceMenuItemInstanceApi, PublicMenu_d_SeparatorMenuItemSpec as SeparatorMenuItemSpec, PublicMenu_d_ContextMenuApi as ContextMenuApi, PublicMenu_d_ContextMenuContents as ContextMenuContents, PublicMenu_d_ContextMenuItem as ContextMenuItem, PublicMenu_d_ContextSubMenu as ContextSubMenu, PublicMenu_d_CardMenuItemSpec as CardMenuItemSpec, PublicMenu_d_CardMenuItemInstanceApi as CardMenuItemInstanceApi, PublicMenu_d_CardItemSpec as CardItemSpec, PublicMenu_d_CardContainerSpec as CardContainerSpec, PublicMenu_d_CardImageSpec as CardImageSpec, PublicMenu_d_CardTextSpec as CardTextSpec, }; } interface SidebarInstanceApi { element: () => HTMLElement; } interface SidebarSpec { @@ -1194,16 +1221,16 @@ interface GroupToolbarButtonSpec extends BaseToolbarButtonSpec<GroupToolbarButtonInstanceApi> { type?: 'grouptoolbarbutton'; items?: ToolbarConfig; } declare type MenuButtonItemTypes = NestedMenuItemContents; -declare type SuccessCallback = (menu: string | MenuButtonItemTypes[]) => void; +declare type SuccessCallback$1 = (menu: string | MenuButtonItemTypes[]) => void; interface BaseMenuButtonSpec { text?: string; tooltip?: string; icon?: string; - fetch: (success: SuccessCallback) => void; + fetch: (success: SuccessCallback$1) => void; onSetup?: (api: BaseMenuButtonInstanceApi) => (api: BaseMenuButtonInstanceApi) => void; } interface BaseMenuButtonInstanceApi { isDisabled: () => boolean; setDisabled: (state: boolean) => void; @@ -1215,23 +1242,23 @@ onSetup?: (api: ToolbarMenuButtonInstanceApi) => (api: ToolbarMenuButtonInstanceApi) => void; } interface ToolbarMenuButtonInstanceApi extends BaseMenuButtonInstanceApi { } declare type ToolbarSplitButtonItemTypes = ChoiceMenuItemSpec | SeparatorMenuItemSpec; -declare type SuccessCallback$1 = (menu: ToolbarSplitButtonItemTypes[]) => void; +declare type SuccessCallback = (menu: ToolbarSplitButtonItemTypes[]) => void; declare type SelectPredicate = (value: string) => boolean; declare type PresetTypes = 'color' | 'normal' | 'listpreview'; -declare type ColumnTypes$1 = number | 'auto'; +declare type ColumnTypes = number | 'auto'; interface ToolbarSplitButtonSpec { type?: 'splitbutton'; tooltip?: string; icon?: string; text?: string; select?: SelectPredicate; presets?: PresetTypes; - columns?: ColumnTypes$1; - fetch: (success: SuccessCallback$1) => void; + columns?: ColumnTypes; + fetch: (success: SuccessCallback) => void; onSetup?: (api: ToolbarSplitButtonInstanceApi) => (api: ToolbarSplitButtonInstanceApi) => void; onAction: (api: ToolbarSplitButtonInstanceApi) => void; onItemAction: (api: ToolbarSplitButtonInstanceApi, value: string) => void; } interface ToolbarSplitButtonInstanceApi { @@ -1253,11 +1280,11 @@ type PublicToolbar_d_GroupToolbarButtonSpec = GroupToolbarButtonSpec; type PublicToolbar_d_GroupToolbarButtonInstanceApi = GroupToolbarButtonInstanceApi; declare namespace PublicToolbar_d { export { PublicToolbar_d_ToolbarButtonSpec as ToolbarButtonSpec, PublicToolbar_d_ToolbarButtonInstanceApi as ToolbarButtonInstanceApi, PublicToolbar_d_ToolbarSplitButtonSpec as ToolbarSplitButtonSpec, PublicToolbar_d_ToolbarSplitButtonInstanceApi as ToolbarSplitButtonInstanceApi, PublicToolbar_d_ToolbarMenuButtonSpec as ToolbarMenuButtonSpec, PublicToolbar_d_ToolbarMenuButtonInstanceApi as ToolbarMenuButtonInstanceApi, PublicToolbar_d_ToolbarToggleButtonSpec as ToolbarToggleButtonSpec, PublicToolbar_d_ToolbarToggleButtonInstanceApi as ToolbarToggleButtonInstanceApi, PublicToolbar_d_GroupToolbarButtonSpec as GroupToolbarButtonSpec, PublicToolbar_d_GroupToolbarButtonInstanceApi as GroupToolbarButtonInstanceApi, }; } -interface Registry { +interface Registry$1 { addButton: (name: string, spec: ToolbarButtonSpec) => void; addGroupToolbarButton: (name: string, spec: GroupToolbarButtonSpec) => void; addToggleButton: (name: string, spec: ToolbarToggleButtonSpec) => void; addMenuButton: (name: string, spec: ToolbarMenuButtonSpec) => void; addSplitButton: (name: string, spec: ToolbarSplitButtonSpec) => void; @@ -1278,40 +1305,46 @@ contextToolbars: Record<string, ContextToolbarSpec | ContextFormSpec>; icons: Record<string, string>; sidebars: Record<string, SidebarSpec>; }; } +interface StyleSheetLoaderSettings { + maxLoadTime?: number; + contentCssCors?: boolean; + referrerPolicy?: ReferrerPolicy; +} interface StyleSheetLoader { load: (url: string, success: () => void, failure?: () => void) => void; loadAll: (urls: string[], success: (urls: string[]) => void, failure: (urls: string[]) => void) => void; unload: (url: string) => void; unloadAll: (urls: string[]) => void; _setReferrerPolicy: (referrerPolicy: ReferrerPolicy) => void; } -interface StyleSheetLoaderSettings { - maxLoadTime?: number; - contentCssCors?: boolean; - referrerPolicy?: ReferrerPolicy; -} -declare type Registry$1 = Registry; +declare type Registry = Registry$1; interface EditorUiApi { show: () => void; hide: () => void; enable: () => void; disable: () => void; isDisabled: () => boolean; } interface EditorUi extends EditorUiApi { - registry: Registry$1; + registry: Registry; styleSheetLoader: StyleSheetLoader; } +type Ui_d_Registry = Registry; type Ui_d_EditorUiApi = EditorUiApi; type Ui_d_EditorUi = EditorUi; declare namespace Ui_d { - export { Ui_d_EditorUiApi as EditorUiApi, Ui_d_EditorUi as EditorUi, Registry$1 as Registry, PublicDialog_d as Dialog, PublicInlineContent_d as InlineContent, PublicMenu_d as Menu, PublicSidebar_d as Sidebar, PublicToolbar_d as Toolbar, }; + export { Ui_d_Registry as Registry, PublicDialog_d as Dialog, PublicInlineContent_d as InlineContent, PublicMenu_d as Menu, PublicSidebar_d as Sidebar, PublicToolbar_d as Toolbar, Ui_d_EditorUiApi as EditorUiApi, Ui_d_EditorUi as EditorUi, }; } declare type EntityEncoding = 'named' | 'numeric' | 'raw' | 'named,numeric' | 'named+numeric' | 'numeric,named' | 'numeric+named'; +interface ContentLanguage { + readonly title: string; + readonly code: string; + readonly customCode?: string; +} declare type ThemeInitFunc = (editor: Editor, elm: HTMLElement) => { editorContainer: HTMLElement; iframeContainer: HTMLElement; height?: number; iframeHeight?: number; @@ -1362,10 +1395,11 @@ content_css?: boolean | string | string[]; content_css_cors?: boolean; content_security_policy?: string; content_style?: string; font_css?: string | string[]; + content_langs?: ContentLanguage[]; contextmenu?: string | false; contextmenu_never_use_native?: boolean; convert_fonts_to_spans?: boolean; convert_urls?: boolean; custom_colors?: boolean; @@ -1402,10 +1436,11 @@ height?: number | string; hidden_input?: boolean; icons?: string; icons_url?: string; id?: string; + iframe_aria_text?: string; images_dataimg_filter?: (imgElm: HTMLImageElement) => boolean; images_file_types?: string; images_replace_blob_uris?: boolean; images_reuse_filename?: boolean; images_upload_base_path?: string; @@ -1421,11 +1456,11 @@ inline?: boolean; inline_boundaries?: boolean; inline_boundaries_selector?: string; inline_styles?: boolean; invalid_elements?: string; - invalid_styles?: string; + invalid_styles?: string | Record<string, string>; keep_styles?: boolean; language?: string; language_load?: boolean; language_url?: string; lineheight_formats?: string; @@ -1439,10 +1474,11 @@ min_height?: number; min_width?: number; no_newline_selector?: string; nowrap?: boolean; object_resizing?: boolean | string; + padd_empty_with_br?: boolean; placeholder?: string; preserve_cdata?: boolean; preview_styles?: boolean | string; protect?: RegExp[]; readonly?: boolean; @@ -1485,10 +1521,11 @@ urlconverter_callback?: string | URLConverterCallback; valid_children?: string; valid_classes?: string | Record<string, string>; valid_elements?: string; valid_styles?: string | Record<string, string>; + verify_html?: boolean; visual?: boolean; visual_anchor_class?: string; visual_table_class?: string; width?: number | string; toolbar_drawer?: false | 'floating' | 'sliding' | 'scrolling'; @@ -1505,10 +1542,11 @@ self_closing_elements?: string; short_ended_elements?: string; text_block_elements?: string; text_inline_elements?: string; whitespace_elements?: string; + special?: string; disable_nodechange?: boolean; forced_plugins?: string | string[]; plugin_base_urls?: Record<string, string>; service_message?: string; validate?: boolean; @@ -1584,11 +1622,11 @@ relativePosition: (rect: GeomRect, targetRect: GeomRect, rel: string) => GeomRect; findBestRelativePosition: (rect: GeomRect, targetRect: GeomRect, constrainRect: GeomRect, rels: string[]) => string | null; intersect: (rect: GeomRect, cropRect: GeomRect) => GeomRect | null; clamp: (rect: GeomRect, clampRect: GeomRect, fixedSize?: boolean) => GeomRect; create: (x: number, y: number, w: number, h: number) => GeomRect; - fromClientRect: (clientRect: ClientRect) => GeomRect; + fromClientRect: (clientRect: DOMRect) => GeomRect; } interface StyleMap { [s: string]: string | number; } interface StylesSettings { @@ -1746,10 +1784,18 @@ getContentEditableParent: (node: Node) => string | null; destroy: () => void; isChildOf: (node: Node, parent: Node) => boolean; dumpRng: (r: Range) => string; } +interface ClientRect { + left: number; + top: number; + bottom: number; + right: number; + width: number; + height: number; +} interface GetSelectionContentArgs extends GetContentArgs { selection?: boolean; contextual?: boolean; } interface SelectionSetContentArgs extends SetContentArgs { @@ -1770,10 +1816,12 @@ getInner?: boolean | number; forced_root_block?: boolean | string; context?: string; isRootContent?: boolean; format?: string; + invalid?: boolean; + no_events?: boolean; [key: string]: any; } declare type ParserFilterCallback = (nodes: AstNode[], name: string, args: ParserArgs) => void; interface ParserFilter { name: string; @@ -1796,10 +1844,11 @@ remove_trailing_brs?: boolean; root_name?: string; validate?: boolean; inline_styles?: boolean; blob_cache?: BlobCache; + document?: Document; images_dataimg_filter?: (img: HTMLImageElement) => boolean; } interface DomParser { schema: Schema; addAttributeFilter: (name: string, callback: (nodes: AstNode[], name: string, args: ParserArgs) => void) => void; @@ -1815,11 +1864,11 @@ entity_encoding?: EntityEncoding; indent?: boolean; indent_after?: string; indent_before?: string; } -declare type Attributes$1 = Array<{ +declare type Attributes = Array<{ name: string; value: string; }>; interface Writer { cdata: (text: string) => void; @@ -1827,23 +1876,20 @@ doctype: (text: string) => void; end: (name: string) => void; getContent: () => string; pi: (name: string, text?: string) => void; reset: () => void; - start: (name: string, attrs?: Attributes$1, empty?: boolean) => void; + start: (name: string, attrs?: Attributes, empty?: boolean) => void; text: (text: string, raw?: boolean) => void; } interface HtmlSerializerSettings extends WriterSettings { inner?: boolean; validate?: boolean; } interface HtmlSerializer { serialize: (node: AstNode) => string; } -interface DomSerializerArgs extends ParserArgs { - format?: string; -} interface DomSerializerSettings extends DomParserSettings, WriterSettings, SchemaSettings, HtmlSerializerSettings { url_converter?: URLConverter; url_converter_scope?: {}; } interface DomSerializerImpl { @@ -1853,12 +1899,12 @@ getNodeFilters: () => ParserFilter[]; getAttributeFilters: () => ParserFilter[]; serialize: { (node: Element, parserArgs: { format: 'tree'; - } & DomSerializerArgs): AstNode; - (node: Element, parserArgs?: DomSerializerArgs): string; + } & ParserArgs): AstNode; + (node: Element, parserArgs?: ParserArgs): string; }; addRules: (rules: string) => void; setRules: (rules: string) => void; addTempAttr: (name: string) => void; getTempAttrs: () => string[]; @@ -1911,11 +1957,11 @@ unbind: () => void; }; getScrollContainer: () => HTMLElement; scrollIntoView: (elm: Element, alignToTop?: boolean) => void; placeCaretAt: (clientX: number, clientY: number) => void; - getBoundingClientRect: () => ClientRect; + getBoundingClientRect: () => ClientRect | DOMRect; destroy: () => void; } declare type EditorCommandCallback = (ui: boolean, value: any, args: any) => void; declare type EditorCommandsCallback = (command: string, ui: boolean, value: any, args: any) => void; interface Commands { @@ -1951,25 +1997,25 @@ } interface WindowParams { readonly inline?: 'cursor' | 'toolbar'; readonly ariaAttrs?: boolean; } -interface WindowManager { - open: <T>(config: DialogSpec<T>, params?: WindowParams) => DialogInstanceApi<T>; - openUrl: (config: UrlDialogSpec) => UrlDialogInstanceApi; - alert: (message: string, callback?: () => void, scope?: any) => void; - confirm: (message: string, callback?: (state: boolean) => void, scope?: any) => void; - close: () => void; -} declare type InstanceApi<T> = UrlDialogInstanceApi | DialogInstanceApi<T>; interface WindowManagerImpl { open: <T>(config: DialogSpec<T>, params: WindowParams, closeWindow: (dialog: DialogInstanceApi<T>) => void) => DialogInstanceApi<T>; openUrl: (config: UrlDialogSpec, closeWindow: (dialog: UrlDialogInstanceApi) => void) => UrlDialogInstanceApi; alert: (message: string, callback: () => void) => void; confirm: (message: string, callback: (state: boolean) => void) => void; close: (dialog: InstanceApi<any>) => void; } +interface WindowManager { + open: <T>(config: DialogSpec<T>, params?: WindowParams) => DialogInstanceApi<T>; + openUrl: (config: UrlDialogSpec) => UrlDialogInstanceApi; + alert: (message: string, callback?: () => void, scope?: any) => void; + confirm: (message: string, callback?: (state: boolean) => void, scope?: any) => void; + close: () => void; +} interface ExecCommandEvent { command: string; ui?: boolean; value?: any; } @@ -1977,10 +2023,11 @@ source_view?: boolean; selection?: boolean; save?: boolean; }; declare type SetContentEvent = SetContentArgs & { + source_view?: boolean; paste?: boolean; selection?: boolean; }; interface NewBlockEvent { newBlock: Element; @@ -1989,10 +2036,15 @@ element: Element; parents: Node[]; selectionChange?: boolean; initial?: boolean; } +interface FormatEvent { + format: string; + vars?: FormatVars; + node?: Node | RangeLikeObject; +} interface ObjectResizeEvent { target: HTMLElement; width: number; height: number; origin: string; @@ -2039,10 +2091,16 @@ state: boolean; } interface LoadErrorEvent { message: string; } +interface PreProcessEvent extends ParserArgs { + node: Element; +} +interface PostProcessEvent extends ParserArgs { + content: string; +} interface EditorEventMap extends Omit<NativeEventMap, 'blur' | 'focus'> { 'activate': { relatedTarget: Editor; }; 'deactivate': { @@ -2072,10 +2130,12 @@ 'IconsLoadError': LoadErrorEvent; 'LanguageLoadError': LoadErrorEvent; 'BeforeExecCommand': ExecCommandEvent; 'ExecCommand': ExecCommandEvent; 'NodeChange': NodeChangeEvent; + 'FormatApply': FormatEvent; + 'FormatRemove': FormatEvent; 'ShowCaret': ShowCaretEvent; 'SelectionChange': {}; 'ObjectSelected': ObjectSelectedEvent; 'BeforeObjectSelected': ObjectSelectedEvent; 'GetSelectionRange': { @@ -2106,10 +2166,12 @@ 'AfterProgressState': AfterProgressStateEvent; 'PlaceholderToggle': PlaceholderToggleEvent; 'tap': TouchEvent; 'longpress': TouchEvent; 'longpresscancel': {}; + 'PreProcess': PreProcessEvent; + 'PostProcess': PostProcessEvent; } interface EditorManagerEventMap { 'AddEditor': { editor: Editor; }; @@ -2123,10 +2185,11 @@ type EventTypes_d_ExecCommandEvent = ExecCommandEvent; type EventTypes_d_GetContentEvent = GetContentEvent; type EventTypes_d_SetContentEvent = SetContentEvent; type EventTypes_d_NewBlockEvent = NewBlockEvent; type EventTypes_d_NodeChangeEvent = NodeChangeEvent; +type EventTypes_d_FormatEvent = FormatEvent; type EventTypes_d_ObjectResizeEvent = ObjectResizeEvent; type EventTypes_d_ObjectSelectedEvent = ObjectSelectedEvent; type EventTypes_d_ScrollIntoViewEvent = ScrollIntoViewEvent; type EventTypes_d_SetSelectionRangeEvent = SetSelectionRangeEvent; type EventTypes_d_ShowCaretEvent = ShowCaretEvent; @@ -2136,14 +2199,16 @@ type EventTypes_d_WindowEvent<_0> = WindowEvent<_0>; type EventTypes_d_ProgressStateEvent = ProgressStateEvent; type EventTypes_d_AfterProgressStateEvent = AfterProgressStateEvent; type EventTypes_d_PlaceholderToggleEvent = PlaceholderToggleEvent; type EventTypes_d_LoadErrorEvent = LoadErrorEvent; +type EventTypes_d_PreProcessEvent = PreProcessEvent; +type EventTypes_d_PostProcessEvent = PostProcessEvent; type EventTypes_d_EditorEventMap = EditorEventMap; type EventTypes_d_EditorManagerEventMap = EditorManagerEventMap; declare namespace EventTypes_d { - export { EventTypes_d_ExecCommandEvent as ExecCommandEvent, EventTypes_d_GetContentEvent as GetContentEvent, EventTypes_d_SetContentEvent as SetContentEvent, EventTypes_d_NewBlockEvent as NewBlockEvent, EventTypes_d_NodeChangeEvent as NodeChangeEvent, EventTypes_d_ObjectResizeEvent as ObjectResizeEvent, EventTypes_d_ObjectSelectedEvent as ObjectSelectedEvent, EventTypes_d_ScrollIntoViewEvent as ScrollIntoViewEvent, EventTypes_d_SetSelectionRangeEvent as SetSelectionRangeEvent, EventTypes_d_ShowCaretEvent as ShowCaretEvent, EventTypes_d_SwitchModeEvent as SwitchModeEvent, EventTypes_d_AddUndoEvent as AddUndoEvent, EventTypes_d_UndoRedoEvent as UndoRedoEvent, EventTypes_d_WindowEvent as WindowEvent, EventTypes_d_ProgressStateEvent as ProgressStateEvent, EventTypes_d_AfterProgressStateEvent as AfterProgressStateEvent, EventTypes_d_PlaceholderToggleEvent as PlaceholderToggleEvent, EventTypes_d_LoadErrorEvent as LoadErrorEvent, EventTypes_d_EditorEventMap as EditorEventMap, EventTypes_d_EditorManagerEventMap as EditorManagerEventMap, }; + export { EventTypes_d_ExecCommandEvent as ExecCommandEvent, EventTypes_d_GetContentEvent as GetContentEvent, EventTypes_d_SetContentEvent as SetContentEvent, EventTypes_d_NewBlockEvent as NewBlockEvent, EventTypes_d_NodeChangeEvent as NodeChangeEvent, EventTypes_d_FormatEvent as FormatEvent, EventTypes_d_ObjectResizeEvent as ObjectResizeEvent, EventTypes_d_ObjectSelectedEvent as ObjectSelectedEvent, EventTypes_d_ScrollIntoViewEvent as ScrollIntoViewEvent, EventTypes_d_SetSelectionRangeEvent as SetSelectionRangeEvent, EventTypes_d_ShowCaretEvent as ShowCaretEvent, EventTypes_d_SwitchModeEvent as SwitchModeEvent, EventTypes_d_AddUndoEvent as AddUndoEvent, EventTypes_d_UndoRedoEvent as UndoRedoEvent, EventTypes_d_WindowEvent as WindowEvent, EventTypes_d_ProgressStateEvent as ProgressStateEvent, EventTypes_d_AfterProgressStateEvent as AfterProgressStateEvent, EventTypes_d_PlaceholderToggleEvent as PlaceholderToggleEvent, EventTypes_d_LoadErrorEvent as LoadErrorEvent, EventTypes_d_PreProcessEvent as PreProcessEvent, EventTypes_d_PostProcessEvent as PostProcessEvent, EventTypes_d_EditorEventMap as EditorEventMap, EventTypes_d_EditorManagerEventMap as EditorManagerEventMap, }; } interface RawString { raw: string; } declare type Primitive = string | number | boolean | Record<string | number, any> | Function; @@ -2277,27 +2342,27 @@ format: string; parents: any; }) => void; interface FormatRegistry { get: { - (name: string): Format[]; + (name: string): Format[] | undefined; (): Record<string, Format[]>; }; has: (name: string) => boolean; register: (name: string | Formats, format?: Format[] | Format) => void; unregister: (name: string) => Formats; } interface Formatter extends FormatRegistry { apply: (name: string, vars?: FormatVars, node?: Node | RangeLikeObject) => void; remove: (name: string, vars?: FormatVars, node?: Node | Range, similar?: boolean) => void; toggle: (name: string, vars?: FormatVars, node?: Node) => void; - match: (name: string, vars?: FormatVars, node?: Node) => boolean; - closest: (names: any) => string | null; + match: (name: string, vars?: FormatVars, node?: Node, similar?: boolean) => boolean; + closest: (names: string[]) => string | null; matchAll: (names: string[], vars?: FormatVars) => string[]; - matchNode: (node: Node, name: string, vars?: FormatVars, similar?: boolean) => boolean; + matchNode: (node: Node, name: string, vars?: FormatVars, similar?: boolean) => Format | undefined; canApply: (name: string) => boolean; - formatChanged: (names: string, callback: FormatChangeCallback, similar?: boolean) => { + formatChanged: (names: string, callback: FormatChangeCallback, similar?: boolean, vars?: FormatVars) => { unbind: () => void; }; getCssText: (format: string | Format) => string; } interface EditorMode { @@ -2665,10 +2730,11 @@ fix_self_closing?: boolean; preserve_cdata?: boolean; remove_internals?: boolean; self_closing_elements?: Record<string, {}>; validate?: boolean; + document?: Document; cdata?: (text: string) => void; comment?: (text: string) => void; doctype?: (text: string) => void; end?: (name: string) => void; pi?: (name: string, text: string) => void; @@ -2717,17 +2783,17 @@ interface HSV { h: number; s: number; v: number; } +declare type ColorConstructor = new (value?: string | RGB | HSV) => Color; interface Color { toRgb: () => RGB; toHsv: () => HSV; toHex: () => string; parse: (value: string | RGB | HSV) => Color; } -declare type ColorConstructor = new (value?: string | RGB | HSV) => Color; interface DebounceFunc<T extends (...args: any[]) => void> { (...args: Parameters<T>): void; stop: () => void; } interface Delay { @@ -2739,12 +2805,12 @@ clearInterval: (id?: number) => void; clearTimeout: (id?: number) => void; debounce: <T extends (...args: any[]) => any>(callback: T, time?: number) => DebounceFunc<T>; throttle: <T extends (...args: any[]) => any>(callback: T, time?: number) => DebounceFunc<T>; } -declare type UploadResult$2 = UploadResult; +declare type UploadResult = UploadResult$2; interface ImageUploader { - upload: (blobInfos: BlobInfo[], showNotification?: boolean) => Promise<UploadResult$2[]>; + upload: (blobInfos: BlobInfo[], showNotification?: boolean) => Promise<UploadResult[]>; } interface JSONUtils { serialize: (obj: any) => string; parse: (text: string) => any; }