tinymce.d.ts 121 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185
  1. interface StringPathBookmark {
  2. start: string;
  3. end?: string;
  4. forward?: boolean;
  5. }
  6. interface RangeBookmark {
  7. rng: Range;
  8. forward?: boolean;
  9. }
  10. interface IdBookmark {
  11. id: string;
  12. keep?: boolean;
  13. forward?: boolean;
  14. }
  15. interface IndexBookmark {
  16. name: string;
  17. index: number;
  18. }
  19. interface PathBookmark {
  20. start: number[];
  21. end?: number[];
  22. isFakeCaret?: boolean;
  23. forward?: boolean;
  24. }
  25. declare type Bookmark = StringPathBookmark | RangeBookmark | IdBookmark | IndexBookmark | PathBookmark;
  26. declare type NormalizedEvent<E, T = any> = E & {
  27. readonly type: string;
  28. readonly target: T;
  29. readonly isDefaultPrevented: () => boolean;
  30. readonly preventDefault: () => void;
  31. readonly isPropagationStopped: () => boolean;
  32. readonly stopPropagation: () => void;
  33. readonly isImmediatePropagationStopped: () => boolean;
  34. readonly stopImmediatePropagation: () => void;
  35. };
  36. declare type MappedEvent<T extends {}, K extends string> = K extends keyof T ? T[K] : any;
  37. interface NativeEventMap {
  38. 'beforepaste': Event;
  39. 'blur': FocusEvent;
  40. 'beforeinput': InputEvent;
  41. 'click': MouseEvent;
  42. 'compositionend': Event;
  43. 'compositionstart': Event;
  44. 'compositionupdate': Event;
  45. 'contextmenu': PointerEvent;
  46. 'copy': ClipboardEvent;
  47. 'cut': ClipboardEvent;
  48. 'dblclick': MouseEvent;
  49. 'drag': DragEvent;
  50. 'dragdrop': DragEvent;
  51. 'dragend': DragEvent;
  52. 'draggesture': DragEvent;
  53. 'dragover': DragEvent;
  54. 'dragstart': DragEvent;
  55. 'drop': DragEvent;
  56. 'focus': FocusEvent;
  57. 'focusin': FocusEvent;
  58. 'focusout': FocusEvent;
  59. 'input': InputEvent;
  60. 'keydown': KeyboardEvent;
  61. 'keypress': KeyboardEvent;
  62. 'keyup': KeyboardEvent;
  63. 'mousedown': MouseEvent;
  64. 'mouseenter': MouseEvent;
  65. 'mouseleave': MouseEvent;
  66. 'mousemove': MouseEvent;
  67. 'mouseout': MouseEvent;
  68. 'mouseover': MouseEvent;
  69. 'mouseup': MouseEvent;
  70. 'paste': ClipboardEvent;
  71. 'selectionchange': Event;
  72. 'submit': Event;
  73. 'touchend': TouchEvent;
  74. 'touchmove': TouchEvent;
  75. 'touchstart': TouchEvent;
  76. 'touchcancel': TouchEvent;
  77. 'wheel': WheelEvent;
  78. }
  79. declare type EditorEvent<T> = NormalizedEvent<T>;
  80. interface EventDispatcherSettings {
  81. scope?: any;
  82. toggleEvent?: (name: string, state: boolean) => void | boolean;
  83. beforeFire?: <T>(args: EditorEvent<T>) => void;
  84. }
  85. interface EventDispatcherConstructor<T extends {}> {
  86. readonly prototype: EventDispatcher<T>;
  87. new (settings?: EventDispatcherSettings): EventDispatcher<T>;
  88. isNative: (name: string) => boolean;
  89. }
  90. declare class EventDispatcher<T extends {}> {
  91. static isNative(name: string): boolean;
  92. private readonly settings;
  93. private readonly scope;
  94. private readonly toggleEvent;
  95. private bindings;
  96. constructor(settings?: EventDispatcherSettings);
  97. fire<K extends string, U extends MappedEvent<T, K>>(name: K, args?: U): EditorEvent<U>;
  98. dispatch<K extends string, U extends MappedEvent<T, K>>(name: K, args?: U): EditorEvent<U>;
  99. on<K extends string>(name: K, callback: false | ((event: EditorEvent<MappedEvent<T, K>>) => void | boolean), prepend?: boolean, extra?: {}): this;
  100. off<K extends string>(name?: K, callback?: (event: EditorEvent<MappedEvent<T, K>>) => void): this;
  101. once<K extends string>(name: K, callback: (event: EditorEvent<MappedEvent<T, K>>) => void, prepend?: boolean): this;
  102. has(name: string): boolean;
  103. }
  104. declare const enum UndoLevelType {
  105. Fragmented = "fragmented",
  106. Complete = "complete"
  107. }
  108. interface BaseUndoLevel {
  109. type: UndoLevelType;
  110. bookmark: Bookmark | null;
  111. beforeBookmark: Bookmark | null;
  112. }
  113. interface FragmentedUndoLevel extends BaseUndoLevel {
  114. type: UndoLevelType.Fragmented;
  115. fragments: string[];
  116. content: '';
  117. }
  118. interface CompleteUndoLevel extends BaseUndoLevel {
  119. type: UndoLevelType.Complete;
  120. fragments: null;
  121. content: string;
  122. }
  123. declare type NewUndoLevel = CompleteUndoLevel | FragmentedUndoLevel;
  124. declare type UndoLevel = NewUndoLevel & {
  125. bookmark: Bookmark;
  126. };
  127. interface UndoManager {
  128. data: UndoLevel[];
  129. typing: boolean;
  130. add: (level?: Partial<UndoLevel>, event?: EditorEvent<any>) => UndoLevel | null;
  131. dispatchChange: () => void;
  132. beforeChange: () => void;
  133. undo: () => UndoLevel | undefined;
  134. redo: () => UndoLevel | undefined;
  135. clear: () => void;
  136. reset: () => void;
  137. hasUndo: () => boolean;
  138. hasRedo: () => boolean;
  139. transact: (callback: () => void) => UndoLevel | null;
  140. ignore: (callback: () => void) => void;
  141. extra: (callback1: () => void, callback2: () => void) => void;
  142. }
  143. declare type SchemaType = 'html4' | 'html5' | 'html5-strict';
  144. interface ElementSettings {
  145. block_elements?: string;
  146. boolean_attributes?: string;
  147. move_caret_before_on_enter_elements?: string;
  148. non_empty_elements?: string;
  149. self_closing_elements?: string;
  150. text_block_elements?: string;
  151. text_inline_elements?: string;
  152. void_elements?: string;
  153. whitespace_elements?: string;
  154. transparent_elements?: string;
  155. }
  156. interface SchemaSettings extends ElementSettings {
  157. custom_elements?: string;
  158. extended_valid_elements?: string;
  159. invalid_elements?: string;
  160. invalid_styles?: string | Record<string, string>;
  161. schema?: SchemaType;
  162. valid_children?: string;
  163. valid_classes?: string | Record<string, string>;
  164. valid_elements?: string;
  165. valid_styles?: string | Record<string, string>;
  166. verify_html?: boolean;
  167. padd_empty_block_inline_children?: boolean;
  168. }
  169. interface Attribute {
  170. required?: boolean;
  171. defaultValue?: string;
  172. forcedValue?: string;
  173. validValues?: Record<string, {}>;
  174. }
  175. interface DefaultAttribute {
  176. name: string;
  177. value: string;
  178. }
  179. interface AttributePattern extends Attribute {
  180. pattern: RegExp;
  181. }
  182. interface ElementRule {
  183. attributes: Record<string, Attribute>;
  184. attributesDefault?: DefaultAttribute[];
  185. attributesForced?: DefaultAttribute[];
  186. attributesOrder: string[];
  187. attributePatterns?: AttributePattern[];
  188. attributesRequired?: string[];
  189. paddEmpty?: boolean;
  190. removeEmpty?: boolean;
  191. removeEmptyAttrs?: boolean;
  192. paddInEmptyBlock?: boolean;
  193. }
  194. interface SchemaElement extends ElementRule {
  195. outputName?: string;
  196. parentsRequired?: string[];
  197. pattern?: RegExp;
  198. }
  199. interface SchemaMap {
  200. [name: string]: {};
  201. }
  202. interface SchemaRegExpMap {
  203. [name: string]: RegExp;
  204. }
  205. interface Schema {
  206. type: SchemaType;
  207. children: Record<string, SchemaMap>;
  208. elements: Record<string, SchemaElement>;
  209. getValidStyles: () => Record<string, string[]> | undefined;
  210. getValidClasses: () => Record<string, SchemaMap> | undefined;
  211. getBlockElements: () => SchemaMap;
  212. getInvalidStyles: () => Record<string, SchemaMap> | undefined;
  213. getVoidElements: () => SchemaMap;
  214. getTextBlockElements: () => SchemaMap;
  215. getTextInlineElements: () => SchemaMap;
  216. getBoolAttrs: () => SchemaMap;
  217. getElementRule: (name: string) => SchemaElement | undefined;
  218. getSelfClosingElements: () => SchemaMap;
  219. getNonEmptyElements: () => SchemaMap;
  220. getMoveCaretBeforeOnEnterElements: () => SchemaMap;
  221. getWhitespaceElements: () => SchemaMap;
  222. getTransparentElements: () => SchemaMap;
  223. getSpecialElements: () => SchemaRegExpMap;
  224. isValidChild: (name: string, child: string) => boolean;
  225. isValid: (name: string, attr?: string) => boolean;
  226. getCustomElements: () => SchemaMap;
  227. addValidElements: (validElements: string) => void;
  228. setValidElements: (validElements: string) => void;
  229. addCustomElements: (customElements: string) => void;
  230. addValidChildren: (validChildren: any) => void;
  231. }
  232. declare type Attributes$1 = Array<{
  233. name: string;
  234. value: string;
  235. }> & {
  236. map: Record<string, string>;
  237. };
  238. interface AstNodeConstructor {
  239. readonly prototype: AstNode;
  240. new (name: string, type: number): AstNode;
  241. create(name: string, attrs?: Record<string, string>): AstNode;
  242. }
  243. declare class AstNode {
  244. static create(name: string, attrs?: Record<string, string>): AstNode;
  245. name: string;
  246. type: number;
  247. attributes?: Attributes$1;
  248. value?: string;
  249. parent?: AstNode | null;
  250. firstChild?: AstNode | null;
  251. lastChild?: AstNode | null;
  252. next?: AstNode | null;
  253. prev?: AstNode | null;
  254. raw?: boolean;
  255. constructor(name: string, type: number);
  256. replace(node: AstNode): AstNode;
  257. attr(name: string, value: string | null | undefined): AstNode | undefined;
  258. attr(name: Record<string, string | null | undefined> | undefined): AstNode | undefined;
  259. attr(name: string): string | undefined;
  260. clone(): AstNode;
  261. wrap(wrapper: AstNode): AstNode;
  262. unwrap(): void;
  263. remove(): AstNode;
  264. append(node: AstNode): AstNode;
  265. insert(node: AstNode, refNode: AstNode, before?: boolean): AstNode;
  266. getAll(name: string): AstNode[];
  267. children(): AstNode[];
  268. empty(): AstNode;
  269. isEmpty(elements: SchemaMap, whitespace?: SchemaMap, predicate?: (node: AstNode) => boolean): boolean;
  270. walk(prev?: boolean): AstNode | null | undefined;
  271. }
  272. declare type Content = string | AstNode;
  273. declare type ContentFormat = 'raw' | 'text' | 'html' | 'tree';
  274. interface GetContentArgs {
  275. format: ContentFormat;
  276. get: boolean;
  277. getInner: boolean;
  278. no_events?: boolean;
  279. save?: boolean;
  280. source_view?: boolean;
  281. [key: string]: any;
  282. }
  283. interface SetContentArgs {
  284. format: string;
  285. set: boolean;
  286. content: Content;
  287. no_events?: boolean;
  288. no_selection?: boolean;
  289. paste?: boolean;
  290. load?: boolean;
  291. initial?: boolean;
  292. [key: string]: any;
  293. }
  294. interface GetSelectionContentArgs extends GetContentArgs {
  295. selection?: boolean;
  296. contextual?: boolean;
  297. }
  298. interface SetSelectionContentArgs extends SetContentArgs {
  299. content: string;
  300. selection?: boolean;
  301. }
  302. interface BlobInfoData {
  303. id?: string;
  304. name?: string;
  305. filename?: string;
  306. blob: Blob;
  307. base64: string;
  308. blobUri?: string;
  309. uri?: string;
  310. }
  311. interface BlobInfo {
  312. id: () => string;
  313. name: () => string;
  314. filename: () => string;
  315. blob: () => Blob;
  316. base64: () => string;
  317. blobUri: () => string;
  318. uri: () => string | undefined;
  319. }
  320. interface BlobCache {
  321. create: {
  322. (o: BlobInfoData): BlobInfo;
  323. (id: string, blob: Blob, base64: string, name?: string, filename?: string): BlobInfo;
  324. };
  325. add: (blobInfo: BlobInfo) => void;
  326. get: (id: string) => BlobInfo | undefined;
  327. getByUri: (blobUri: string) => BlobInfo | undefined;
  328. getByData: (base64: string, type: string) => BlobInfo | undefined;
  329. findFirst: (predicate: (blobInfo: BlobInfo) => boolean) => BlobInfo | undefined;
  330. removeByUri: (blobUri: string) => void;
  331. destroy: () => void;
  332. }
  333. interface BlobInfoImagePair {
  334. image: HTMLImageElement;
  335. blobInfo: BlobInfo;
  336. }
  337. declare class NodeChange {
  338. private readonly editor;
  339. private lastPath;
  340. constructor(editor: Editor);
  341. nodeChanged(args?: Record<string, any>): void;
  342. private isSameElementPath;
  343. }
  344. interface SelectionOverrides {
  345. showCaret: (direction: number, node: HTMLElement, before: boolean, scrollIntoView?: boolean) => Range | null;
  346. showBlockCaretContainer: (blockCaretContainer: HTMLElement) => void;
  347. hideFakeCaret: () => void;
  348. destroy: () => void;
  349. }
  350. interface Quirks {
  351. refreshContentEditable(): void;
  352. isHidden(): boolean;
  353. }
  354. declare type DecoratorData = Record<string, any>;
  355. declare type Decorator = (uid: string, data: DecoratorData) => {
  356. attributes?: {};
  357. classes?: string[];
  358. };
  359. declare type AnnotationListener = (state: boolean, name: string, data?: {
  360. uid: string;
  361. nodes: any[];
  362. }) => void;
  363. declare type AnnotationListenerApi = AnnotationListener;
  364. interface AnnotatorSettings {
  365. decorate: Decorator;
  366. persistent?: boolean;
  367. }
  368. interface Annotator {
  369. register: (name: string, settings: AnnotatorSettings) => void;
  370. annotate: (name: string, data: DecoratorData) => void;
  371. annotationChanged: (name: string, f: AnnotationListenerApi) => void;
  372. remove: (name: string) => void;
  373. removeAll: (name: string) => void;
  374. getAll: (name: string) => Record<string, Element[]>;
  375. }
  376. interface GeomRect {
  377. readonly x: number;
  378. readonly y: number;
  379. readonly w: number;
  380. readonly h: number;
  381. }
  382. interface Rect {
  383. inflate: (rect: GeomRect, w: number, h: number) => GeomRect;
  384. relativePosition: (rect: GeomRect, targetRect: GeomRect, rel: string) => GeomRect;
  385. findBestRelativePosition: (rect: GeomRect, targetRect: GeomRect, constrainRect: GeomRect, rels: string[]) => string | null;
  386. intersect: (rect: GeomRect, cropRect: GeomRect) => GeomRect | null;
  387. clamp: (rect: GeomRect, clampRect: GeomRect, fixedSize?: boolean) => GeomRect;
  388. create: (x: number, y: number, w: number, h: number) => GeomRect;
  389. fromClientRect: (clientRect: DOMRect) => GeomRect;
  390. }
  391. interface NotificationManagerImpl {
  392. open: (spec: NotificationSpec, closeCallback: () => void) => NotificationApi;
  393. close: <T extends NotificationApi>(notification: T) => void;
  394. getArgs: <T extends NotificationApi>(notification: T) => NotificationSpec;
  395. }
  396. interface NotificationSpec {
  397. type?: 'info' | 'warning' | 'error' | 'success';
  398. text: string;
  399. icon?: string;
  400. progressBar?: boolean;
  401. timeout?: number;
  402. closeButton?: boolean;
  403. }
  404. interface NotificationApi {
  405. close: () => void;
  406. progressBar: {
  407. value: (percent: number) => void;
  408. };
  409. text: (text: string) => void;
  410. reposition: () => void;
  411. getEl: () => HTMLElement;
  412. settings: NotificationSpec;
  413. }
  414. interface NotificationManager {
  415. open: (spec: NotificationSpec) => NotificationApi;
  416. close: () => void;
  417. getNotifications: () => NotificationApi[];
  418. }
  419. interface UploadFailure {
  420. message: string;
  421. remove?: boolean;
  422. }
  423. declare type ProgressFn = (percent: number) => void;
  424. declare type UploadHandler = (blobInfo: BlobInfo, progress: ProgressFn) => Promise<string>;
  425. interface UploadResult$2 {
  426. url: string;
  427. blobInfo: BlobInfo;
  428. status: boolean;
  429. error?: UploadFailure;
  430. }
  431. interface RawPattern {
  432. start?: any;
  433. end?: any;
  434. format?: any;
  435. cmd?: any;
  436. value?: any;
  437. replacement?: any;
  438. }
  439. interface InlineBasePattern {
  440. readonly start: string;
  441. readonly end: string;
  442. }
  443. interface InlineFormatPattern extends InlineBasePattern {
  444. readonly type: 'inline-format';
  445. readonly format: string[];
  446. }
  447. interface InlineCmdPattern extends InlineBasePattern {
  448. readonly type: 'inline-command';
  449. readonly cmd: string;
  450. readonly value?: any;
  451. }
  452. declare type InlinePattern = InlineFormatPattern | InlineCmdPattern;
  453. interface BlockBasePattern {
  454. readonly start: string;
  455. }
  456. interface BlockFormatPattern extends BlockBasePattern {
  457. readonly type: 'block-format';
  458. readonly format: string;
  459. }
  460. interface BlockCmdPattern extends BlockBasePattern {
  461. readonly type: 'block-command';
  462. readonly cmd: string;
  463. readonly value?: any;
  464. }
  465. declare type BlockPattern = BlockFormatPattern | BlockCmdPattern;
  466. declare type Pattern = InlinePattern | BlockPattern;
  467. interface DynamicPatternContext {
  468. readonly text: string;
  469. readonly block: Element;
  470. }
  471. declare type DynamicPatternsLookup = (ctx: DynamicPatternContext) => Pattern[];
  472. declare type RawDynamicPatternsLookup = (ctx: DynamicPatternContext) => RawPattern[];
  473. interface AlertBannerSpec {
  474. type: 'alertbanner';
  475. level: 'info' | 'warn' | 'error' | 'success';
  476. text: string;
  477. icon: string;
  478. url?: string;
  479. }
  480. interface ButtonSpec {
  481. type: 'button';
  482. text: string;
  483. enabled?: boolean;
  484. primary?: boolean;
  485. name?: string;
  486. icon?: string;
  487. borderless?: boolean;
  488. buttonType?: 'primary' | 'secondary' | 'toolbar';
  489. }
  490. interface FormComponentSpec {
  491. type: string;
  492. name: string;
  493. }
  494. interface FormComponentWithLabelSpec extends FormComponentSpec {
  495. label?: string;
  496. }
  497. interface CheckboxSpec extends FormComponentSpec {
  498. type: 'checkbox';
  499. label: string;
  500. enabled?: boolean;
  501. }
  502. interface CollectionSpec extends FormComponentWithLabelSpec {
  503. type: 'collection';
  504. }
  505. interface CollectionItem {
  506. value: string;
  507. text: string;
  508. icon: string;
  509. }
  510. interface ColorInputSpec extends FormComponentWithLabelSpec {
  511. type: 'colorinput';
  512. storageKey?: string;
  513. }
  514. interface ColorPickerSpec extends FormComponentWithLabelSpec {
  515. type: 'colorpicker';
  516. }
  517. interface CustomEditorInit {
  518. setValue: (value: string) => void;
  519. getValue: () => string;
  520. destroy: () => void;
  521. }
  522. declare type CustomEditorInitFn = (elm: HTMLElement, settings: any) => Promise<CustomEditorInit>;
  523. interface CustomEditorOldSpec extends FormComponentSpec {
  524. type: 'customeditor';
  525. tag?: string;
  526. init: (e: HTMLElement) => Promise<CustomEditorInit>;
  527. }
  528. interface CustomEditorNewSpec extends FormComponentSpec {
  529. type: 'customeditor';
  530. tag?: string;
  531. scriptId: string;
  532. scriptUrl: string;
  533. settings?: any;
  534. }
  535. declare type CustomEditorSpec = CustomEditorOldSpec | CustomEditorNewSpec;
  536. interface DropZoneSpec extends FormComponentWithLabelSpec {
  537. type: 'dropzone';
  538. }
  539. interface GridSpec {
  540. type: 'grid';
  541. columns: number;
  542. items: BodyComponentSpec[];
  543. }
  544. interface HtmlPanelSpec {
  545. type: 'htmlpanel';
  546. html: string;
  547. presets?: 'presentation' | 'document';
  548. }
  549. interface IframeSpec extends FormComponentWithLabelSpec {
  550. type: 'iframe';
  551. sandboxed?: boolean;
  552. transparent?: boolean;
  553. }
  554. interface ImagePreviewSpec extends FormComponentSpec {
  555. type: 'imagepreview';
  556. height?: string;
  557. }
  558. interface InputSpec extends FormComponentWithLabelSpec {
  559. type: 'input';
  560. inputMode?: string;
  561. placeholder?: string;
  562. maximized?: boolean;
  563. enabled?: boolean;
  564. }
  565. interface LabelSpec {
  566. type: 'label';
  567. label: string;
  568. items: BodyComponentSpec[];
  569. }
  570. interface ListBoxSingleItemSpec {
  571. text: string;
  572. value: string;
  573. }
  574. interface ListBoxNestedItemSpec {
  575. text: string;
  576. items: ListBoxItemSpec[];
  577. }
  578. declare type ListBoxItemSpec = ListBoxNestedItemSpec | ListBoxSingleItemSpec;
  579. interface ListBoxSpec extends FormComponentWithLabelSpec {
  580. type: 'listbox';
  581. items: ListBoxItemSpec[];
  582. disabled?: boolean;
  583. }
  584. interface PanelSpec {
  585. type: 'panel';
  586. classes?: string[];
  587. items: BodyComponentSpec[];
  588. }
  589. interface SelectBoxItemSpec {
  590. text: string;
  591. value: string;
  592. }
  593. interface SelectBoxSpec extends FormComponentWithLabelSpec {
  594. type: 'selectbox';
  595. items: SelectBoxItemSpec[];
  596. size?: number;
  597. enabled?: boolean;
  598. }
  599. interface SizeInputSpec extends FormComponentWithLabelSpec {
  600. type: 'sizeinput';
  601. constrain?: boolean;
  602. enabled?: boolean;
  603. }
  604. interface SliderSpec extends FormComponentSpec {
  605. type: 'slider';
  606. label: string;
  607. min?: number;
  608. max?: number;
  609. }
  610. interface TableSpec {
  611. type: 'table';
  612. header: string[];
  613. cells: string[][];
  614. }
  615. interface TextAreaSpec extends FormComponentWithLabelSpec {
  616. type: 'textarea';
  617. placeholder?: string;
  618. maximized?: boolean;
  619. enabled?: boolean;
  620. }
  621. interface BaseToolbarButtonSpec<I extends BaseToolbarButtonInstanceApi> {
  622. enabled?: boolean;
  623. tooltip?: string;
  624. icon?: string;
  625. text?: string;
  626. onSetup?: (api: I) => (api: I) => void;
  627. }
  628. interface BaseToolbarButtonInstanceApi {
  629. isEnabled: () => boolean;
  630. setEnabled: (state: boolean) => void;
  631. setText: (text: string) => void;
  632. setIcon: (icon: string) => void;
  633. }
  634. interface ToolbarButtonSpec extends BaseToolbarButtonSpec<ToolbarButtonInstanceApi> {
  635. type?: 'button';
  636. onAction: (api: ToolbarButtonInstanceApi) => void;
  637. }
  638. interface ToolbarButtonInstanceApi extends BaseToolbarButtonInstanceApi {
  639. }
  640. interface ToolbarGroupSetting {
  641. name: string;
  642. items: string[];
  643. }
  644. declare type ToolbarConfig = string | ToolbarGroupSetting[];
  645. interface GroupToolbarButtonInstanceApi extends BaseToolbarButtonInstanceApi {
  646. }
  647. interface GroupToolbarButtonSpec extends BaseToolbarButtonSpec<GroupToolbarButtonInstanceApi> {
  648. type?: 'grouptoolbarbutton';
  649. items?: ToolbarConfig;
  650. }
  651. interface CardImageSpec {
  652. type: 'cardimage';
  653. src: string;
  654. alt?: string;
  655. classes?: string[];
  656. }
  657. interface CardTextSpec {
  658. type: 'cardtext';
  659. text: string;
  660. name?: string;
  661. classes?: string[];
  662. }
  663. declare type CardItemSpec = CardContainerSpec | CardImageSpec | CardTextSpec;
  664. declare type CardContainerDirection = 'vertical' | 'horizontal';
  665. declare type CardContainerAlign = 'left' | 'right';
  666. declare type CardContainerValign = 'top' | 'middle' | 'bottom';
  667. interface CardContainerSpec {
  668. type: 'cardcontainer';
  669. items: CardItemSpec[];
  670. direction?: CardContainerDirection;
  671. align?: CardContainerAlign;
  672. valign?: CardContainerValign;
  673. }
  674. interface CommonMenuItemSpec {
  675. enabled?: boolean;
  676. text?: string;
  677. value?: string;
  678. meta?: Record<string, any>;
  679. shortcut?: string;
  680. }
  681. interface CommonMenuItemInstanceApi {
  682. isEnabled: () => boolean;
  683. setEnabled: (state: boolean) => void;
  684. }
  685. interface CardMenuItemInstanceApi extends CommonMenuItemInstanceApi {
  686. }
  687. interface CardMenuItemSpec extends Omit<CommonMenuItemSpec, 'text' | 'shortcut'> {
  688. type: 'cardmenuitem';
  689. label?: string;
  690. items: CardItemSpec[];
  691. onSetup?: (api: CardMenuItemInstanceApi) => (api: CardMenuItemInstanceApi) => void;
  692. onAction?: (api: CardMenuItemInstanceApi) => void;
  693. }
  694. interface ChoiceMenuItemSpec extends CommonMenuItemSpec {
  695. type?: 'choiceitem';
  696. icon?: string;
  697. }
  698. interface ChoiceMenuItemInstanceApi extends CommonMenuItemInstanceApi {
  699. isActive: () => boolean;
  700. setActive: (state: boolean) => void;
  701. }
  702. interface ContextMenuItem extends CommonMenuItemSpec {
  703. text: string;
  704. icon?: string;
  705. type?: 'item';
  706. onAction: () => void;
  707. }
  708. interface ContextSubMenu extends CommonMenuItemSpec {
  709. type: 'submenu';
  710. text: string;
  711. icon?: string;
  712. getSubmenuItems: () => string | Array<ContextMenuContents>;
  713. }
  714. declare type ContextMenuContents = string | ContextMenuItem | SeparatorMenuItemSpec | ContextSubMenu;
  715. interface ContextMenuApi {
  716. update: (element: Element) => string | Array<ContextMenuContents>;
  717. }
  718. interface FancyActionArgsMap {
  719. 'inserttable': {
  720. numRows: number;
  721. numColumns: number;
  722. };
  723. 'colorswatch': {
  724. value: string;
  725. };
  726. }
  727. interface BaseFancyMenuItemSpec<T extends keyof FancyActionArgsMap> {
  728. type: 'fancymenuitem';
  729. fancytype: T;
  730. initData?: Record<string, unknown>;
  731. onAction?: (data: FancyActionArgsMap[T]) => void;
  732. }
  733. interface InsertTableMenuItemSpec extends BaseFancyMenuItemSpec<'inserttable'> {
  734. fancytype: 'inserttable';
  735. initData?: {};
  736. }
  737. interface ColorSwatchMenuItemSpec extends BaseFancyMenuItemSpec<'colorswatch'> {
  738. fancytype: 'colorswatch';
  739. select?: (value: string) => boolean;
  740. initData?: {
  741. allowCustomColors?: boolean;
  742. colors?: ChoiceMenuItemSpec[];
  743. storageKey?: string;
  744. };
  745. }
  746. declare type FancyMenuItemSpec = InsertTableMenuItemSpec | ColorSwatchMenuItemSpec;
  747. interface MenuItemSpec extends CommonMenuItemSpec {
  748. type?: 'menuitem';
  749. icon?: string;
  750. onSetup?: (api: MenuItemInstanceApi) => (api: MenuItemInstanceApi) => void;
  751. onAction?: (api: MenuItemInstanceApi) => void;
  752. }
  753. interface MenuItemInstanceApi extends CommonMenuItemInstanceApi {
  754. }
  755. interface SeparatorMenuItemSpec {
  756. type?: 'separator';
  757. text?: string;
  758. }
  759. interface ToggleMenuItemSpec extends CommonMenuItemSpec {
  760. type?: 'togglemenuitem';
  761. icon?: string;
  762. active?: boolean;
  763. onSetup?: (api: ToggleMenuItemInstanceApi) => void;
  764. onAction: (api: ToggleMenuItemInstanceApi) => void;
  765. }
  766. interface ToggleMenuItemInstanceApi extends CommonMenuItemInstanceApi {
  767. isActive: () => boolean;
  768. setActive: (state: boolean) => void;
  769. }
  770. declare type NestedMenuItemContents = string | MenuItemSpec | NestedMenuItemSpec | ToggleMenuItemSpec | SeparatorMenuItemSpec | FancyMenuItemSpec;
  771. interface NestedMenuItemSpec extends CommonMenuItemSpec {
  772. type?: 'nestedmenuitem';
  773. icon?: string;
  774. getSubmenuItems: () => string | Array<NestedMenuItemContents>;
  775. onSetup?: (api: NestedMenuItemInstanceApi) => (api: NestedMenuItemInstanceApi) => void;
  776. }
  777. interface NestedMenuItemInstanceApi extends CommonMenuItemInstanceApi {
  778. setIconFill: (id: string, value: string) => void;
  779. }
  780. declare type MenuButtonItemTypes = NestedMenuItemContents;
  781. declare type SuccessCallback$1 = (menu: string | MenuButtonItemTypes[]) => void;
  782. interface MenuButtonFetchContext {
  783. pattern: string;
  784. }
  785. interface BaseMenuButtonSpec {
  786. text?: string;
  787. tooltip?: string;
  788. icon?: string;
  789. search?: boolean | {
  790. placeholder?: string;
  791. };
  792. fetch: (success: SuccessCallback$1, fetchContext: MenuButtonFetchContext, api: BaseMenuButtonInstanceApi) => void;
  793. onSetup?: (api: BaseMenuButtonInstanceApi) => (api: BaseMenuButtonInstanceApi) => void;
  794. }
  795. interface BaseMenuButtonInstanceApi {
  796. isEnabled: () => boolean;
  797. setEnabled: (state: boolean) => void;
  798. isActive: () => boolean;
  799. setActive: (state: boolean) => void;
  800. setText: (text: string) => void;
  801. setIcon: (icon: string) => void;
  802. }
  803. interface ToolbarMenuButtonSpec extends BaseMenuButtonSpec {
  804. type?: 'menubutton';
  805. onSetup?: (api: ToolbarMenuButtonInstanceApi) => (api: ToolbarMenuButtonInstanceApi) => void;
  806. }
  807. interface ToolbarMenuButtonInstanceApi extends BaseMenuButtonInstanceApi {
  808. }
  809. declare type ToolbarSplitButtonItemTypes = ChoiceMenuItemSpec | SeparatorMenuItemSpec;
  810. declare type SuccessCallback = (menu: ToolbarSplitButtonItemTypes[]) => void;
  811. declare type SelectPredicate = (value: string) => boolean;
  812. declare type PresetTypes = 'color' | 'normal' | 'listpreview';
  813. declare type ColumnTypes$1 = number | 'auto';
  814. interface ToolbarSplitButtonSpec {
  815. type?: 'splitbutton';
  816. tooltip?: string;
  817. icon?: string;
  818. text?: string;
  819. select?: SelectPredicate;
  820. presets?: PresetTypes;
  821. columns?: ColumnTypes$1;
  822. fetch: (success: SuccessCallback) => void;
  823. onSetup?: (api: ToolbarSplitButtonInstanceApi) => (api: ToolbarSplitButtonInstanceApi) => void;
  824. onAction: (api: ToolbarSplitButtonInstanceApi) => void;
  825. onItemAction: (api: ToolbarSplitButtonInstanceApi, value: string) => void;
  826. }
  827. interface ToolbarSplitButtonInstanceApi {
  828. isEnabled: () => boolean;
  829. setEnabled: (state: boolean) => void;
  830. setIconFill: (id: string, value: string) => void;
  831. isActive: () => boolean;
  832. setActive: (state: boolean) => void;
  833. setText: (text: string) => void;
  834. setIcon: (icon: string) => void;
  835. }
  836. interface BaseToolbarToggleButtonSpec<I extends BaseToolbarButtonInstanceApi> extends BaseToolbarButtonSpec<I> {
  837. active?: boolean;
  838. }
  839. interface BaseToolbarToggleButtonInstanceApi extends BaseToolbarButtonInstanceApi {
  840. isActive: () => boolean;
  841. setActive: (state: boolean) => void;
  842. }
  843. interface ToolbarToggleButtonSpec extends BaseToolbarToggleButtonSpec<ToolbarToggleButtonInstanceApi> {
  844. type?: 'togglebutton';
  845. onAction: (api: ToolbarToggleButtonInstanceApi) => void;
  846. }
  847. interface ToolbarToggleButtonInstanceApi extends BaseToolbarToggleButtonInstanceApi {
  848. }
  849. declare type Id = string;
  850. interface TreeSpec {
  851. type: 'tree';
  852. items: TreeItemSpec[];
  853. onLeafAction?: (id: Id) => void;
  854. }
  855. interface BaseTreeItemSpec {
  856. title: string;
  857. id: Id;
  858. menu?: ToolbarMenuButtonSpec;
  859. }
  860. interface DirectorySpec extends BaseTreeItemSpec {
  861. type: 'directory';
  862. children: TreeItemSpec[];
  863. }
  864. interface LeafSpec extends BaseTreeItemSpec {
  865. type: 'leaf';
  866. }
  867. declare type TreeItemSpec = DirectorySpec | LeafSpec;
  868. interface UrlInputSpec extends FormComponentWithLabelSpec {
  869. type: 'urlinput';
  870. filetype?: 'image' | 'media' | 'file';
  871. enabled?: boolean;
  872. }
  873. interface UrlInputData {
  874. value: string;
  875. meta: {
  876. text?: string;
  877. };
  878. }
  879. declare type BodyComponentSpec = BarSpec | ButtonSpec | CheckboxSpec | TextAreaSpec | InputSpec | ListBoxSpec | SelectBoxSpec | SizeInputSpec | SliderSpec | IframeSpec | HtmlPanelSpec | UrlInputSpec | DropZoneSpec | ColorInputSpec | GridSpec | ColorPickerSpec | ImagePreviewSpec | AlertBannerSpec | CollectionSpec | LabelSpec | TableSpec | TreeSpec | PanelSpec | CustomEditorSpec;
  880. interface BarSpec {
  881. type: 'bar';
  882. items: BodyComponentSpec[];
  883. }
  884. interface DialogToggleMenuItemSpec extends CommonMenuItemSpec {
  885. type?: 'togglemenuitem';
  886. name: string;
  887. }
  888. declare type DialogFooterMenuButtonItemSpec = DialogToggleMenuItemSpec;
  889. interface BaseDialogFooterButtonSpec {
  890. name?: string;
  891. align?: 'start' | 'end';
  892. primary?: boolean;
  893. enabled?: boolean;
  894. icon?: string;
  895. buttonType?: 'primary' | 'secondary';
  896. }
  897. interface DialogFooterNormalButtonSpec extends BaseDialogFooterButtonSpec {
  898. type: 'submit' | 'cancel' | 'custom';
  899. text: string;
  900. }
  901. interface DialogFooterMenuButtonSpec extends BaseDialogFooterButtonSpec {
  902. type: 'menu';
  903. text?: string;
  904. tooltip?: string;
  905. icon?: string;
  906. items: DialogFooterMenuButtonItemSpec[];
  907. }
  908. interface DialogFooterToggleButtonSpec extends BaseDialogFooterButtonSpec {
  909. type: 'togglebutton';
  910. tooltip?: string;
  911. icon?: string;
  912. text?: string;
  913. active?: boolean;
  914. }
  915. declare type DialogFooterButtonSpec = DialogFooterNormalButtonSpec | DialogFooterMenuButtonSpec | DialogFooterToggleButtonSpec;
  916. interface TabSpec {
  917. name?: string;
  918. title: string;
  919. items: BodyComponentSpec[];
  920. }
  921. interface TabPanelSpec {
  922. type: 'tabpanel';
  923. tabs: TabSpec[];
  924. }
  925. declare type DialogDataItem = any;
  926. declare type DialogData = Record<string, DialogDataItem>;
  927. interface DialogInstanceApi<T extends DialogData> {
  928. getData: () => T;
  929. setData: (data: Partial<T>) => void;
  930. setEnabled: (name: string, state: boolean) => void;
  931. focus: (name: string) => void;
  932. showTab: (name: string) => void;
  933. redial: (nu: DialogSpec<T>) => void;
  934. block: (msg: string) => void;
  935. unblock: () => void;
  936. toggleFullscreen: () => void;
  937. close: () => void;
  938. }
  939. interface DialogActionDetails {
  940. name: string;
  941. value?: any;
  942. }
  943. interface DialogChangeDetails<T> {
  944. name: keyof T;
  945. }
  946. interface DialogTabChangeDetails {
  947. newTabName: string;
  948. oldTabName: string;
  949. }
  950. declare type DialogActionHandler<T extends DialogData> = (api: DialogInstanceApi<T>, details: DialogActionDetails) => void;
  951. declare type DialogChangeHandler<T extends DialogData> = (api: DialogInstanceApi<T>, details: DialogChangeDetails<T>) => void;
  952. declare type DialogSubmitHandler<T extends DialogData> = (api: DialogInstanceApi<T>) => void;
  953. declare type DialogCloseHandler = () => void;
  954. declare type DialogCancelHandler<T extends DialogData> = (api: DialogInstanceApi<T>) => void;
  955. declare type DialogTabChangeHandler<T extends DialogData> = (api: DialogInstanceApi<T>, details: DialogTabChangeDetails) => void;
  956. declare type DialogSize = 'normal' | 'medium' | 'large';
  957. interface DialogSpec<T extends DialogData> {
  958. title: string;
  959. size?: DialogSize;
  960. body: TabPanelSpec | PanelSpec;
  961. buttons: DialogFooterButtonSpec[];
  962. initialData?: Partial<T>;
  963. onAction?: DialogActionHandler<T>;
  964. onChange?: DialogChangeHandler<T>;
  965. onSubmit?: DialogSubmitHandler<T>;
  966. onClose?: DialogCloseHandler;
  967. onCancel?: DialogCancelHandler<T>;
  968. onTabChange?: DialogTabChangeHandler<T>;
  969. }
  970. interface UrlDialogInstanceApi {
  971. block: (msg: string) => void;
  972. unblock: () => void;
  973. close: () => void;
  974. sendMessage: (msg: any) => void;
  975. }
  976. interface UrlDialogActionDetails {
  977. name: string;
  978. value?: any;
  979. }
  980. interface UrlDialogMessage {
  981. mceAction: string;
  982. [key: string]: any;
  983. }
  984. declare type UrlDialogActionHandler = (api: UrlDialogInstanceApi, actions: UrlDialogActionDetails) => void;
  985. declare type UrlDialogCloseHandler = () => void;
  986. declare type UrlDialogCancelHandler = (api: UrlDialogInstanceApi) => void;
  987. declare type UrlDialogMessageHandler = (api: UrlDialogInstanceApi, message: UrlDialogMessage) => void;
  988. interface UrlDialogFooterButtonSpec extends DialogFooterNormalButtonSpec {
  989. type: 'cancel' | 'custom';
  990. }
  991. interface UrlDialogSpec {
  992. title: string;
  993. url: string;
  994. height?: number;
  995. width?: number;
  996. buttons?: UrlDialogFooterButtonSpec[];
  997. onAction?: UrlDialogActionHandler;
  998. onClose?: UrlDialogCloseHandler;
  999. onCancel?: UrlDialogCancelHandler;
  1000. onMessage?: UrlDialogMessageHandler;
  1001. }
  1002. declare type ColumnTypes = number | 'auto';
  1003. declare type SeparatorItemSpec = SeparatorMenuItemSpec;
  1004. interface AutocompleterItemSpec {
  1005. type?: 'autocompleteitem';
  1006. value: string;
  1007. text?: string;
  1008. icon?: string;
  1009. meta?: Record<string, any>;
  1010. }
  1011. declare type AutocompleterContents = SeparatorItemSpec | AutocompleterItemSpec | CardMenuItemSpec;
  1012. interface AutocompleterSpec {
  1013. type?: 'autocompleter';
  1014. ch?: string;
  1015. trigger?: string;
  1016. minChars?: number;
  1017. columns?: ColumnTypes;
  1018. matches?: (rng: Range, text: string, pattern: string) => boolean;
  1019. fetch: (pattern: string, maxResults: number, fetchOptions: Record<string, any>) => Promise<AutocompleterContents[]>;
  1020. onAction: (autocompleterApi: AutocompleterInstanceApi, rng: Range, value: string, meta: Record<string, any>) => void;
  1021. maxResults?: number;
  1022. highlightOn?: string[];
  1023. }
  1024. interface AutocompleterInstanceApi {
  1025. hide: () => void;
  1026. reload: (fetchOptions: Record<string, any>) => void;
  1027. }
  1028. declare type ContextPosition = 'node' | 'selection' | 'line';
  1029. declare type ContextScope = 'node' | 'editor';
  1030. interface ContextBarSpec {
  1031. predicate?: (elem: Element) => boolean;
  1032. position?: ContextPosition;
  1033. scope?: ContextScope;
  1034. }
  1035. interface ContextFormLaunchButtonApi extends BaseToolbarButtonSpec<BaseToolbarButtonInstanceApi> {
  1036. type: 'contextformbutton';
  1037. }
  1038. interface ContextFormLaunchToggleButtonSpec extends BaseToolbarToggleButtonSpec<BaseToolbarToggleButtonInstanceApi> {
  1039. type: 'contextformtogglebutton';
  1040. }
  1041. interface ContextFormButtonInstanceApi extends BaseToolbarButtonInstanceApi {
  1042. }
  1043. interface ContextFormToggleButtonInstanceApi extends BaseToolbarToggleButtonInstanceApi {
  1044. }
  1045. interface ContextFormButtonSpec extends BaseToolbarButtonSpec<ContextFormButtonInstanceApi> {
  1046. type?: 'contextformbutton';
  1047. primary?: boolean;
  1048. onAction: (formApi: ContextFormInstanceApi, api: ContextFormButtonInstanceApi) => void;
  1049. }
  1050. interface ContextFormToggleButtonSpec extends BaseToolbarToggleButtonSpec<ContextFormToggleButtonInstanceApi> {
  1051. type?: 'contextformtogglebutton';
  1052. onAction: (formApi: ContextFormInstanceApi, buttonApi: ContextFormToggleButtonInstanceApi) => void;
  1053. primary?: boolean;
  1054. }
  1055. interface ContextFormInstanceApi {
  1056. hide: () => void;
  1057. getValue: () => string;
  1058. }
  1059. interface ContextFormSpec extends ContextBarSpec {
  1060. type?: 'contextform';
  1061. initValue?: () => string;
  1062. label?: string;
  1063. launch?: ContextFormLaunchButtonApi | ContextFormLaunchToggleButtonSpec;
  1064. commands: Array<ContextFormToggleButtonSpec | ContextFormButtonSpec>;
  1065. }
  1066. interface ContextToolbarSpec extends ContextBarSpec {
  1067. type?: 'contexttoolbar';
  1068. items: string;
  1069. }
  1070. type PublicDialog_d_AlertBannerSpec = AlertBannerSpec;
  1071. type PublicDialog_d_BarSpec = BarSpec;
  1072. type PublicDialog_d_BodyComponentSpec = BodyComponentSpec;
  1073. type PublicDialog_d_ButtonSpec = ButtonSpec;
  1074. type PublicDialog_d_CheckboxSpec = CheckboxSpec;
  1075. type PublicDialog_d_CollectionItem = CollectionItem;
  1076. type PublicDialog_d_CollectionSpec = CollectionSpec;
  1077. type PublicDialog_d_ColorInputSpec = ColorInputSpec;
  1078. type PublicDialog_d_ColorPickerSpec = ColorPickerSpec;
  1079. type PublicDialog_d_CustomEditorSpec = CustomEditorSpec;
  1080. type PublicDialog_d_CustomEditorInit = CustomEditorInit;
  1081. type PublicDialog_d_CustomEditorInitFn = CustomEditorInitFn;
  1082. type PublicDialog_d_DialogData = DialogData;
  1083. type PublicDialog_d_DialogSize = DialogSize;
  1084. type PublicDialog_d_DialogSpec<T extends DialogData> = DialogSpec<T>;
  1085. type PublicDialog_d_DialogInstanceApi<T extends DialogData> = DialogInstanceApi<T>;
  1086. type PublicDialog_d_DialogFooterButtonSpec = DialogFooterButtonSpec;
  1087. type PublicDialog_d_DialogActionDetails = DialogActionDetails;
  1088. type PublicDialog_d_DialogChangeDetails<T> = DialogChangeDetails<T>;
  1089. type PublicDialog_d_DialogTabChangeDetails = DialogTabChangeDetails;
  1090. type PublicDialog_d_DropZoneSpec = DropZoneSpec;
  1091. type PublicDialog_d_GridSpec = GridSpec;
  1092. type PublicDialog_d_HtmlPanelSpec = HtmlPanelSpec;
  1093. type PublicDialog_d_IframeSpec = IframeSpec;
  1094. type PublicDialog_d_ImagePreviewSpec = ImagePreviewSpec;
  1095. type PublicDialog_d_InputSpec = InputSpec;
  1096. type PublicDialog_d_LabelSpec = LabelSpec;
  1097. type PublicDialog_d_ListBoxSpec = ListBoxSpec;
  1098. type PublicDialog_d_ListBoxItemSpec = ListBoxItemSpec;
  1099. type PublicDialog_d_ListBoxNestedItemSpec = ListBoxNestedItemSpec;
  1100. type PublicDialog_d_ListBoxSingleItemSpec = ListBoxSingleItemSpec;
  1101. type PublicDialog_d_PanelSpec = PanelSpec;
  1102. type PublicDialog_d_SelectBoxSpec = SelectBoxSpec;
  1103. type PublicDialog_d_SelectBoxItemSpec = SelectBoxItemSpec;
  1104. type PublicDialog_d_SizeInputSpec = SizeInputSpec;
  1105. type PublicDialog_d_SliderSpec = SliderSpec;
  1106. type PublicDialog_d_TableSpec = TableSpec;
  1107. type PublicDialog_d_TabSpec = TabSpec;
  1108. type PublicDialog_d_TabPanelSpec = TabPanelSpec;
  1109. type PublicDialog_d_TextAreaSpec = TextAreaSpec;
  1110. type PublicDialog_d_TreeSpec = TreeSpec;
  1111. type PublicDialog_d_TreeItemSpec = TreeItemSpec;
  1112. type PublicDialog_d_UrlInputData = UrlInputData;
  1113. type PublicDialog_d_UrlInputSpec = UrlInputSpec;
  1114. type PublicDialog_d_UrlDialogSpec = UrlDialogSpec;
  1115. type PublicDialog_d_UrlDialogFooterButtonSpec = UrlDialogFooterButtonSpec;
  1116. type PublicDialog_d_UrlDialogInstanceApi = UrlDialogInstanceApi;
  1117. type PublicDialog_d_UrlDialogActionDetails = UrlDialogActionDetails;
  1118. type PublicDialog_d_UrlDialogMessage = UrlDialogMessage;
  1119. declare namespace PublicDialog_d {
  1120. export { PublicDialog_d_AlertBannerSpec as AlertBannerSpec, PublicDialog_d_BarSpec as BarSpec, PublicDialog_d_BodyComponentSpec as BodyComponentSpec, PublicDialog_d_ButtonSpec as ButtonSpec, PublicDialog_d_CheckboxSpec as CheckboxSpec, PublicDialog_d_CollectionItem as CollectionItem, PublicDialog_d_CollectionSpec as CollectionSpec, PublicDialog_d_ColorInputSpec as ColorInputSpec, PublicDialog_d_ColorPickerSpec as ColorPickerSpec, PublicDialog_d_CustomEditorSpec as CustomEditorSpec, PublicDialog_d_CustomEditorInit as CustomEditorInit, PublicDialog_d_CustomEditorInitFn as CustomEditorInitFn, PublicDialog_d_DialogData as DialogData, PublicDialog_d_DialogSize as DialogSize, PublicDialog_d_DialogSpec as DialogSpec, PublicDialog_d_DialogInstanceApi as DialogInstanceApi, PublicDialog_d_DialogFooterButtonSpec as DialogFooterButtonSpec, PublicDialog_d_DialogActionDetails as DialogActionDetails, PublicDialog_d_DialogChangeDetails as DialogChangeDetails, PublicDialog_d_DialogTabChangeDetails as DialogTabChangeDetails, PublicDialog_d_DropZoneSpec as DropZoneSpec, PublicDialog_d_GridSpec as GridSpec, PublicDialog_d_HtmlPanelSpec as HtmlPanelSpec, PublicDialog_d_IframeSpec as IframeSpec, PublicDialog_d_ImagePreviewSpec as ImagePreviewSpec, PublicDialog_d_InputSpec as InputSpec, PublicDialog_d_LabelSpec as LabelSpec, PublicDialog_d_ListBoxSpec as ListBoxSpec, PublicDialog_d_ListBoxItemSpec as ListBoxItemSpec, PublicDialog_d_ListBoxNestedItemSpec as ListBoxNestedItemSpec, PublicDialog_d_ListBoxSingleItemSpec as ListBoxSingleItemSpec, PublicDialog_d_PanelSpec as PanelSpec, PublicDialog_d_SelectBoxSpec as SelectBoxSpec, PublicDialog_d_SelectBoxItemSpec as SelectBoxItemSpec, PublicDialog_d_SizeInputSpec as SizeInputSpec, PublicDialog_d_SliderSpec as SliderSpec, PublicDialog_d_TableSpec as TableSpec, PublicDialog_d_TabSpec as TabSpec, PublicDialog_d_TabPanelSpec as TabPanelSpec, PublicDialog_d_TextAreaSpec as TextAreaSpec, PublicDialog_d_TreeSpec as TreeSpec, PublicDialog_d_TreeItemSpec as TreeItemSpec, DirectorySpec as TreeDirectorySpec, LeafSpec as TreeLeafSpec, PublicDialog_d_UrlInputData as UrlInputData, PublicDialog_d_UrlInputSpec as UrlInputSpec, PublicDialog_d_UrlDialogSpec as UrlDialogSpec, PublicDialog_d_UrlDialogFooterButtonSpec as UrlDialogFooterButtonSpec, PublicDialog_d_UrlDialogInstanceApi as UrlDialogInstanceApi, PublicDialog_d_UrlDialogActionDetails as UrlDialogActionDetails, PublicDialog_d_UrlDialogMessage as UrlDialogMessage, };
  1121. }
  1122. type PublicInlineContent_d_AutocompleterSpec = AutocompleterSpec;
  1123. type PublicInlineContent_d_AutocompleterItemSpec = AutocompleterItemSpec;
  1124. type PublicInlineContent_d_AutocompleterContents = AutocompleterContents;
  1125. type PublicInlineContent_d_AutocompleterInstanceApi = AutocompleterInstanceApi;
  1126. type PublicInlineContent_d_ContextPosition = ContextPosition;
  1127. type PublicInlineContent_d_ContextScope = ContextScope;
  1128. type PublicInlineContent_d_ContextFormSpec = ContextFormSpec;
  1129. type PublicInlineContent_d_ContextFormInstanceApi = ContextFormInstanceApi;
  1130. type PublicInlineContent_d_ContextFormButtonSpec = ContextFormButtonSpec;
  1131. type PublicInlineContent_d_ContextFormButtonInstanceApi = ContextFormButtonInstanceApi;
  1132. type PublicInlineContent_d_ContextFormToggleButtonSpec = ContextFormToggleButtonSpec;
  1133. type PublicInlineContent_d_ContextFormToggleButtonInstanceApi = ContextFormToggleButtonInstanceApi;
  1134. type PublicInlineContent_d_ContextToolbarSpec = ContextToolbarSpec;
  1135. type PublicInlineContent_d_SeparatorItemSpec = SeparatorItemSpec;
  1136. declare namespace PublicInlineContent_d {
  1137. export { PublicInlineContent_d_AutocompleterSpec as AutocompleterSpec, PublicInlineContent_d_AutocompleterItemSpec as AutocompleterItemSpec, PublicInlineContent_d_AutocompleterContents as AutocompleterContents, PublicInlineContent_d_AutocompleterInstanceApi as AutocompleterInstanceApi, PublicInlineContent_d_ContextPosition as ContextPosition, PublicInlineContent_d_ContextScope as ContextScope, PublicInlineContent_d_ContextFormSpec as ContextFormSpec, PublicInlineContent_d_ContextFormInstanceApi as ContextFormInstanceApi, PublicInlineContent_d_ContextFormButtonSpec as ContextFormButtonSpec, PublicInlineContent_d_ContextFormButtonInstanceApi as ContextFormButtonInstanceApi, PublicInlineContent_d_ContextFormToggleButtonSpec as ContextFormToggleButtonSpec, PublicInlineContent_d_ContextFormToggleButtonInstanceApi as ContextFormToggleButtonInstanceApi, PublicInlineContent_d_ContextToolbarSpec as ContextToolbarSpec, PublicInlineContent_d_SeparatorItemSpec as SeparatorItemSpec, };
  1138. }
  1139. type PublicMenu_d_MenuItemSpec = MenuItemSpec;
  1140. type PublicMenu_d_MenuItemInstanceApi = MenuItemInstanceApi;
  1141. type PublicMenu_d_NestedMenuItemContents = NestedMenuItemContents;
  1142. type PublicMenu_d_NestedMenuItemSpec = NestedMenuItemSpec;
  1143. type PublicMenu_d_NestedMenuItemInstanceApi = NestedMenuItemInstanceApi;
  1144. type PublicMenu_d_FancyMenuItemSpec = FancyMenuItemSpec;
  1145. type PublicMenu_d_ColorSwatchMenuItemSpec = ColorSwatchMenuItemSpec;
  1146. type PublicMenu_d_InsertTableMenuItemSpec = InsertTableMenuItemSpec;
  1147. type PublicMenu_d_ToggleMenuItemSpec = ToggleMenuItemSpec;
  1148. type PublicMenu_d_ToggleMenuItemInstanceApi = ToggleMenuItemInstanceApi;
  1149. type PublicMenu_d_ChoiceMenuItemSpec = ChoiceMenuItemSpec;
  1150. type PublicMenu_d_ChoiceMenuItemInstanceApi = ChoiceMenuItemInstanceApi;
  1151. type PublicMenu_d_SeparatorMenuItemSpec = SeparatorMenuItemSpec;
  1152. type PublicMenu_d_ContextMenuApi = ContextMenuApi;
  1153. type PublicMenu_d_ContextMenuContents = ContextMenuContents;
  1154. type PublicMenu_d_ContextMenuItem = ContextMenuItem;
  1155. type PublicMenu_d_ContextSubMenu = ContextSubMenu;
  1156. type PublicMenu_d_CardMenuItemSpec = CardMenuItemSpec;
  1157. type PublicMenu_d_CardMenuItemInstanceApi = CardMenuItemInstanceApi;
  1158. type PublicMenu_d_CardItemSpec = CardItemSpec;
  1159. type PublicMenu_d_CardContainerSpec = CardContainerSpec;
  1160. type PublicMenu_d_CardImageSpec = CardImageSpec;
  1161. type PublicMenu_d_CardTextSpec = CardTextSpec;
  1162. declare namespace PublicMenu_d {
  1163. 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, };
  1164. }
  1165. interface SidebarInstanceApi {
  1166. element: () => HTMLElement;
  1167. }
  1168. interface SidebarSpec {
  1169. icon?: string;
  1170. tooltip?: string;
  1171. onShow?: (api: SidebarInstanceApi) => void;
  1172. onSetup?: (api: SidebarInstanceApi) => (api: SidebarInstanceApi) => void;
  1173. onHide?: (api: SidebarInstanceApi) => void;
  1174. }
  1175. type PublicSidebar_d_SidebarSpec = SidebarSpec;
  1176. type PublicSidebar_d_SidebarInstanceApi = SidebarInstanceApi;
  1177. declare namespace PublicSidebar_d {
  1178. export { PublicSidebar_d_SidebarSpec as SidebarSpec, PublicSidebar_d_SidebarInstanceApi as SidebarInstanceApi, };
  1179. }
  1180. type PublicToolbar_d_ToolbarButtonSpec = ToolbarButtonSpec;
  1181. type PublicToolbar_d_ToolbarButtonInstanceApi = ToolbarButtonInstanceApi;
  1182. type PublicToolbar_d_ToolbarSplitButtonSpec = ToolbarSplitButtonSpec;
  1183. type PublicToolbar_d_ToolbarSplitButtonInstanceApi = ToolbarSplitButtonInstanceApi;
  1184. type PublicToolbar_d_ToolbarMenuButtonSpec = ToolbarMenuButtonSpec;
  1185. type PublicToolbar_d_ToolbarMenuButtonInstanceApi = ToolbarMenuButtonInstanceApi;
  1186. type PublicToolbar_d_ToolbarToggleButtonSpec = ToolbarToggleButtonSpec;
  1187. type PublicToolbar_d_ToolbarToggleButtonInstanceApi = ToolbarToggleButtonInstanceApi;
  1188. type PublicToolbar_d_GroupToolbarButtonSpec = GroupToolbarButtonSpec;
  1189. type PublicToolbar_d_GroupToolbarButtonInstanceApi = GroupToolbarButtonInstanceApi;
  1190. declare namespace PublicToolbar_d {
  1191. 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, };
  1192. }
  1193. interface ViewButtonApi {
  1194. setIcon: (newIcon: string) => void;
  1195. }
  1196. interface ViewToggleButtonApi extends ViewButtonApi {
  1197. isActive: () => boolean;
  1198. setActive: (state: boolean) => void;
  1199. }
  1200. interface BaseButtonSpec<Api extends ViewButtonApi> {
  1201. text?: string;
  1202. icon?: string;
  1203. tooltip?: string;
  1204. buttonType?: 'primary' | 'secondary';
  1205. borderless?: boolean;
  1206. onAction: (api: Api) => void;
  1207. }
  1208. interface ViewNormalButtonSpec extends BaseButtonSpec<ViewButtonApi> {
  1209. text: string;
  1210. type: 'button';
  1211. }
  1212. interface ViewToggleButtonSpec extends BaseButtonSpec<ViewToggleButtonApi> {
  1213. type: 'togglebutton';
  1214. active?: boolean;
  1215. onAction: (api: ViewToggleButtonApi) => void;
  1216. }
  1217. interface ViewButtonsGroupSpec {
  1218. type: 'group';
  1219. buttons: Array<ViewNormalButtonSpec | ViewToggleButtonSpec>;
  1220. }
  1221. declare type ViewButtonSpec = ViewNormalButtonSpec | ViewToggleButtonSpec | ViewButtonsGroupSpec;
  1222. interface ViewInstanceApi {
  1223. getContainer: () => HTMLElement;
  1224. }
  1225. interface ViewSpec {
  1226. buttons?: ViewButtonSpec[];
  1227. onShow: (api: ViewInstanceApi) => void;
  1228. onHide: (api: ViewInstanceApi) => void;
  1229. }
  1230. type PublicView_d_ViewSpec = ViewSpec;
  1231. type PublicView_d_ViewInstanceApi = ViewInstanceApi;
  1232. declare namespace PublicView_d {
  1233. export { PublicView_d_ViewSpec as ViewSpec, PublicView_d_ViewInstanceApi as ViewInstanceApi, };
  1234. }
  1235. interface Registry$1 {
  1236. addButton: (name: string, spec: ToolbarButtonSpec) => void;
  1237. addGroupToolbarButton: (name: string, spec: GroupToolbarButtonSpec) => void;
  1238. addToggleButton: (name: string, spec: ToolbarToggleButtonSpec) => void;
  1239. addMenuButton: (name: string, spec: ToolbarMenuButtonSpec) => void;
  1240. addSplitButton: (name: string, spec: ToolbarSplitButtonSpec) => void;
  1241. addMenuItem: (name: string, spec: MenuItemSpec) => void;
  1242. addNestedMenuItem: (name: string, spec: NestedMenuItemSpec) => void;
  1243. addToggleMenuItem: (name: string, spec: ToggleMenuItemSpec) => void;
  1244. addContextMenu: (name: string, spec: ContextMenuApi) => void;
  1245. addContextToolbar: (name: string, spec: ContextToolbarSpec) => void;
  1246. addContextForm: (name: string, spec: ContextFormSpec) => void;
  1247. addIcon: (name: string, svgData: string) => void;
  1248. addAutocompleter: (name: string, spec: AutocompleterSpec) => void;
  1249. addSidebar: (name: string, spec: SidebarSpec) => void;
  1250. addView: (name: string, spec: ViewSpec) => void;
  1251. getAll: () => {
  1252. buttons: Record<string, ToolbarButtonSpec | GroupToolbarButtonSpec | ToolbarMenuButtonSpec | ToolbarSplitButtonSpec | ToolbarToggleButtonSpec>;
  1253. menuItems: Record<string, MenuItemSpec | NestedMenuItemSpec | ToggleMenuItemSpec>;
  1254. popups: Record<string, AutocompleterSpec>;
  1255. contextMenus: Record<string, ContextMenuApi>;
  1256. contextToolbars: Record<string, ContextToolbarSpec | ContextFormSpec>;
  1257. icons: Record<string, string>;
  1258. sidebars: Record<string, SidebarSpec>;
  1259. views: Record<string, ViewSpec>;
  1260. };
  1261. }
  1262. interface AutocompleteLookupData {
  1263. readonly matchText: string;
  1264. readonly items: AutocompleterContents[];
  1265. readonly columns: ColumnTypes;
  1266. readonly onAction: (autoApi: AutocompleterInstanceApi, rng: Range, value: string, meta: Record<string, any>) => void;
  1267. readonly highlightOn: string[];
  1268. }
  1269. interface AutocompleterEventArgs {
  1270. readonly lookupData: AutocompleteLookupData[];
  1271. }
  1272. interface RangeLikeObject {
  1273. startContainer: Node;
  1274. startOffset: number;
  1275. endContainer: Node;
  1276. endOffset: number;
  1277. }
  1278. declare type ApplyFormat = BlockFormat | InlineFormat | SelectorFormat;
  1279. declare type RemoveFormat = RemoveBlockFormat | RemoveInlineFormat | RemoveSelectorFormat;
  1280. declare type Format = ApplyFormat | RemoveFormat;
  1281. declare type Formats = Record<string, Format | Format[]>;
  1282. declare type FormatAttrOrStyleValue = string | ((vars?: FormatVars) => string | null);
  1283. declare type FormatVars = Record<string, string | null>;
  1284. interface BaseFormat<T> {
  1285. ceFalseOverride?: boolean;
  1286. classes?: string | string[];
  1287. collapsed?: boolean;
  1288. exact?: boolean;
  1289. expand?: boolean;
  1290. links?: boolean;
  1291. mixed?: boolean;
  1292. block_expand?: boolean;
  1293. onmatch?: (node: Element, fmt: T, itemName: string) => boolean;
  1294. remove?: 'none' | 'empty' | 'all';
  1295. remove_similar?: boolean;
  1296. split?: boolean;
  1297. deep?: boolean;
  1298. preserve_attributes?: string[];
  1299. }
  1300. interface Block {
  1301. block: string;
  1302. list_block?: string;
  1303. wrapper?: boolean;
  1304. }
  1305. interface Inline {
  1306. inline: string;
  1307. }
  1308. interface Selector {
  1309. selector: string;
  1310. inherit?: boolean;
  1311. }
  1312. interface CommonFormat<T> extends BaseFormat<T> {
  1313. attributes?: Record<string, FormatAttrOrStyleValue>;
  1314. styles?: Record<string, FormatAttrOrStyleValue>;
  1315. toggle?: boolean;
  1316. preview?: string | false;
  1317. onformat?: (elm: Element, fmt: T, vars?: FormatVars, node?: Node | RangeLikeObject | null) => void;
  1318. clear_child_styles?: boolean;
  1319. merge_siblings?: boolean;
  1320. merge_with_parents?: boolean;
  1321. }
  1322. interface BlockFormat extends Block, CommonFormat<BlockFormat> {
  1323. }
  1324. interface InlineFormat extends Inline, CommonFormat<InlineFormat> {
  1325. }
  1326. interface SelectorFormat extends Selector, CommonFormat<SelectorFormat> {
  1327. }
  1328. interface CommonRemoveFormat<T> extends BaseFormat<T> {
  1329. attributes?: string[] | Record<string, FormatAttrOrStyleValue>;
  1330. styles?: string[] | Record<string, FormatAttrOrStyleValue>;
  1331. }
  1332. interface RemoveBlockFormat extends Block, CommonRemoveFormat<RemoveBlockFormat> {
  1333. }
  1334. interface RemoveInlineFormat extends Inline, CommonRemoveFormat<RemoveInlineFormat> {
  1335. }
  1336. interface RemoveSelectorFormat extends Selector, CommonRemoveFormat<RemoveSelectorFormat> {
  1337. }
  1338. interface Filter<C extends Function> {
  1339. name: string;
  1340. callbacks: C[];
  1341. }
  1342. interface ParserArgs {
  1343. getInner?: boolean | number;
  1344. forced_root_block?: boolean | string;
  1345. context?: string;
  1346. isRootContent?: boolean;
  1347. format?: string;
  1348. invalid?: boolean;
  1349. no_events?: boolean;
  1350. [key: string]: any;
  1351. }
  1352. declare type ParserFilterCallback = (nodes: AstNode[], name: string, args: ParserArgs) => void;
  1353. interface ParserFilter extends Filter<ParserFilterCallback> {
  1354. }
  1355. interface DomParserSettings {
  1356. allow_html_data_urls?: boolean;
  1357. allow_svg_data_urls?: boolean;
  1358. allow_conditional_comments?: boolean;
  1359. allow_html_in_named_anchor?: boolean;
  1360. allow_script_urls?: boolean;
  1361. allow_unsafe_link_target?: boolean;
  1362. blob_cache?: BlobCache;
  1363. convert_fonts_to_spans?: boolean;
  1364. document?: Document;
  1365. fix_list_elements?: boolean;
  1366. font_size_legacy_values?: string;
  1367. forced_root_block?: boolean | string;
  1368. forced_root_block_attrs?: Record<string, string>;
  1369. inline_styles?: boolean;
  1370. preserve_cdata?: boolean;
  1371. remove_trailing_brs?: boolean;
  1372. root_name?: string;
  1373. sanitize?: boolean;
  1374. validate?: boolean;
  1375. }
  1376. interface DomParser {
  1377. schema: Schema;
  1378. addAttributeFilter: (name: string, callback: ParserFilterCallback) => void;
  1379. getAttributeFilters: () => ParserFilter[];
  1380. removeAttributeFilter: (name: string, callback?: ParserFilterCallback) => void;
  1381. addNodeFilter: (name: string, callback: ParserFilterCallback) => void;
  1382. getNodeFilters: () => ParserFilter[];
  1383. removeNodeFilter: (name: string, callback?: ParserFilterCallback) => void;
  1384. parse: (html: string, args?: ParserArgs) => AstNode;
  1385. }
  1386. interface StyleSheetLoaderSettings {
  1387. maxLoadTime?: number;
  1388. contentCssCors?: boolean;
  1389. referrerPolicy?: ReferrerPolicy;
  1390. }
  1391. interface StyleSheetLoader {
  1392. load: (url: string) => Promise<void>;
  1393. loadAll: (urls: string[]) => Promise<string[]>;
  1394. unload: (url: string) => void;
  1395. unloadAll: (urls: string[]) => void;
  1396. _setReferrerPolicy: (referrerPolicy: ReferrerPolicy) => void;
  1397. _setContentCssCors: (contentCssCors: boolean) => void;
  1398. }
  1399. declare type Registry = Registry$1;
  1400. interface EditorUiApi {
  1401. show: () => void;
  1402. hide: () => void;
  1403. setEnabled: (state: boolean) => void;
  1404. isEnabled: () => boolean;
  1405. }
  1406. interface EditorUi extends EditorUiApi {
  1407. registry: Registry;
  1408. styleSheetLoader: StyleSheetLoader;
  1409. }
  1410. type Ui_d_Registry = Registry;
  1411. type Ui_d_EditorUiApi = EditorUiApi;
  1412. type Ui_d_EditorUi = EditorUi;
  1413. declare namespace Ui_d {
  1414. export { Ui_d_Registry as Registry, PublicDialog_d as Dialog, PublicInlineContent_d as InlineContent, PublicMenu_d as Menu, PublicView_d as View, PublicSidebar_d as Sidebar, PublicToolbar_d as Toolbar, Ui_d_EditorUiApi as EditorUiApi, Ui_d_EditorUi as EditorUi, };
  1415. }
  1416. interface WindowParams {
  1417. readonly inline?: 'cursor' | 'toolbar';
  1418. readonly ariaAttrs?: boolean;
  1419. }
  1420. declare type InstanceApi<T extends DialogData> = UrlDialogInstanceApi | DialogInstanceApi<T>;
  1421. interface WindowManagerImpl {
  1422. open: <T extends DialogData>(config: DialogSpec<T>, params: WindowParams | undefined, closeWindow: (dialog: DialogInstanceApi<T>) => void) => DialogInstanceApi<T>;
  1423. openUrl: (config: UrlDialogSpec, closeWindow: (dialog: UrlDialogInstanceApi) => void) => UrlDialogInstanceApi;
  1424. alert: (message: string, callback: () => void) => void;
  1425. confirm: (message: string, callback: (state: boolean) => void) => void;
  1426. close: (dialog: InstanceApi<any>) => void;
  1427. }
  1428. interface WindowManager {
  1429. open: <T extends DialogData>(config: DialogSpec<T>, params?: WindowParams) => DialogInstanceApi<T>;
  1430. openUrl: (config: UrlDialogSpec) => UrlDialogInstanceApi;
  1431. alert: (message: string, callback?: () => void, scope?: any) => void;
  1432. confirm: (message: string, callback?: (state: boolean) => void, scope?: any) => void;
  1433. close: () => void;
  1434. }
  1435. interface ExecCommandEvent {
  1436. command: string;
  1437. ui: boolean;
  1438. value?: any;
  1439. }
  1440. interface BeforeGetContentEvent extends GetContentArgs {
  1441. selection?: boolean;
  1442. }
  1443. interface GetContentEvent extends BeforeGetContentEvent {
  1444. content: string;
  1445. }
  1446. interface BeforeSetContentEvent extends SetContentArgs {
  1447. content: string;
  1448. selection?: boolean;
  1449. }
  1450. interface SetContentEvent extends BeforeSetContentEvent {
  1451. content: string;
  1452. }
  1453. interface SaveContentEvent extends GetContentEvent {
  1454. save: boolean;
  1455. }
  1456. interface NewBlockEvent {
  1457. newBlock: Element;
  1458. }
  1459. interface NodeChangeEvent {
  1460. element: Element;
  1461. parents: Node[];
  1462. selectionChange?: boolean;
  1463. initial?: boolean;
  1464. }
  1465. interface FormatEvent {
  1466. format: string;
  1467. vars?: FormatVars;
  1468. node?: Node | RangeLikeObject | null;
  1469. }
  1470. interface ObjectResizeEvent {
  1471. target: HTMLElement;
  1472. width: number;
  1473. height: number;
  1474. origin: string;
  1475. }
  1476. interface ObjectSelectedEvent {
  1477. target: Node;
  1478. targetClone?: Node;
  1479. }
  1480. interface ScrollIntoViewEvent {
  1481. elm: HTMLElement;
  1482. alignToTop: boolean | undefined;
  1483. }
  1484. interface SetSelectionRangeEvent {
  1485. range: Range;
  1486. forward: boolean | undefined;
  1487. }
  1488. interface ShowCaretEvent {
  1489. target: Node;
  1490. direction: number;
  1491. before: boolean;
  1492. }
  1493. interface SwitchModeEvent {
  1494. mode: string;
  1495. }
  1496. interface ChangeEvent {
  1497. level: UndoLevel;
  1498. lastLevel: UndoLevel | undefined;
  1499. }
  1500. interface AddUndoEvent extends ChangeEvent {
  1501. originalEvent: Event | undefined;
  1502. }
  1503. interface UndoRedoEvent {
  1504. level: UndoLevel;
  1505. }
  1506. interface WindowEvent<T extends DialogData> {
  1507. dialog: InstanceApi<T>;
  1508. }
  1509. interface ProgressStateEvent {
  1510. state: boolean;
  1511. time?: number;
  1512. }
  1513. interface AfterProgressStateEvent {
  1514. state: boolean;
  1515. }
  1516. interface PlaceholderToggleEvent {
  1517. state: boolean;
  1518. }
  1519. interface LoadErrorEvent {
  1520. message: string;
  1521. }
  1522. interface PreProcessEvent extends ParserArgs {
  1523. node: Element;
  1524. }
  1525. interface PostProcessEvent extends ParserArgs {
  1526. content: string;
  1527. }
  1528. interface PastePlainTextToggleEvent {
  1529. state: boolean;
  1530. }
  1531. interface PastePreProcessEvent {
  1532. content: string;
  1533. readonly internal: boolean;
  1534. }
  1535. interface PastePostProcessEvent {
  1536. node: HTMLElement;
  1537. readonly internal: boolean;
  1538. }
  1539. interface NewTableRowEvent {
  1540. node: HTMLTableRowElement;
  1541. }
  1542. interface NewTableCellEvent {
  1543. node: HTMLTableCellElement;
  1544. }
  1545. interface TableEventData {
  1546. readonly structure: boolean;
  1547. readonly style: boolean;
  1548. }
  1549. interface TableModifiedEvent extends TableEventData {
  1550. readonly table: HTMLTableElement;
  1551. }
  1552. interface BeforeOpenNotificationEvent {
  1553. notification: NotificationSpec;
  1554. }
  1555. interface OpenNotificationEvent {
  1556. notification: NotificationApi;
  1557. }
  1558. interface EditorEventMap extends Omit<NativeEventMap, 'blur' | 'focus'> {
  1559. 'activate': {
  1560. relatedTarget: Editor | null;
  1561. };
  1562. 'deactivate': {
  1563. relatedTarget: Editor;
  1564. };
  1565. 'focus': {
  1566. blurredEditor: Editor | null;
  1567. };
  1568. 'blur': {
  1569. focusedEditor: Editor | null;
  1570. };
  1571. 'resize': UIEvent;
  1572. 'scroll': UIEvent;
  1573. 'detach': {};
  1574. 'remove': {};
  1575. 'init': {};
  1576. 'ScrollIntoView': ScrollIntoViewEvent;
  1577. 'AfterScrollIntoView': ScrollIntoViewEvent;
  1578. 'ObjectResized': ObjectResizeEvent;
  1579. 'ObjectResizeStart': ObjectResizeEvent;
  1580. 'SwitchMode': SwitchModeEvent;
  1581. 'ScrollWindow': Event;
  1582. 'ResizeWindow': UIEvent;
  1583. 'SkinLoaded': {};
  1584. 'SkinLoadError': LoadErrorEvent;
  1585. 'PluginLoadError': LoadErrorEvent;
  1586. 'ModelLoadError': LoadErrorEvent;
  1587. 'IconsLoadError': LoadErrorEvent;
  1588. 'ThemeLoadError': LoadErrorEvent;
  1589. 'LanguageLoadError': LoadErrorEvent;
  1590. 'BeforeExecCommand': ExecCommandEvent;
  1591. 'ExecCommand': ExecCommandEvent;
  1592. 'NodeChange': NodeChangeEvent;
  1593. 'FormatApply': FormatEvent;
  1594. 'FormatRemove': FormatEvent;
  1595. 'ShowCaret': ShowCaretEvent;
  1596. 'SelectionChange': {};
  1597. 'ObjectSelected': ObjectSelectedEvent;
  1598. 'BeforeObjectSelected': ObjectSelectedEvent;
  1599. 'GetSelectionRange': {
  1600. range: Range;
  1601. };
  1602. 'SetSelectionRange': SetSelectionRangeEvent;
  1603. 'AfterSetSelectionRange': SetSelectionRangeEvent;
  1604. 'BeforeGetContent': BeforeGetContentEvent;
  1605. 'GetContent': GetContentEvent;
  1606. 'BeforeSetContent': BeforeSetContentEvent;
  1607. 'SetContent': SetContentEvent;
  1608. 'SaveContent': SaveContentEvent;
  1609. 'RawSaveContent': SaveContentEvent;
  1610. 'LoadContent': {
  1611. load: boolean;
  1612. element: HTMLElement;
  1613. };
  1614. 'PreviewFormats': {};
  1615. 'AfterPreviewFormats': {};
  1616. 'ScriptsLoaded': {};
  1617. 'PreInit': {};
  1618. 'PostRender': {};
  1619. 'NewBlock': NewBlockEvent;
  1620. 'ClearUndos': {};
  1621. 'TypingUndo': {};
  1622. 'Redo': UndoRedoEvent;
  1623. 'Undo': UndoRedoEvent;
  1624. 'BeforeAddUndo': AddUndoEvent;
  1625. 'AddUndo': AddUndoEvent;
  1626. 'change': ChangeEvent;
  1627. 'CloseWindow': WindowEvent<any>;
  1628. 'OpenWindow': WindowEvent<any>;
  1629. 'ProgressState': ProgressStateEvent;
  1630. 'AfterProgressState': AfterProgressStateEvent;
  1631. 'PlaceholderToggle': PlaceholderToggleEvent;
  1632. 'tap': TouchEvent;
  1633. 'longpress': TouchEvent;
  1634. 'longpresscancel': {};
  1635. 'PreProcess': PreProcessEvent;
  1636. 'PostProcess': PostProcessEvent;
  1637. 'AutocompleterStart': AutocompleterEventArgs;
  1638. 'AutocompleterUpdate': AutocompleterEventArgs;
  1639. 'AutocompleterEnd': {};
  1640. 'PastePlainTextToggle': PastePlainTextToggleEvent;
  1641. 'PastePreProcess': PastePreProcessEvent;
  1642. 'PastePostProcess': PastePostProcessEvent;
  1643. 'TableModified': TableModifiedEvent;
  1644. 'NewRow': NewTableRowEvent;
  1645. 'NewCell': NewTableCellEvent;
  1646. 'SetAttrib': SetAttribEvent;
  1647. 'hide': {};
  1648. 'show': {};
  1649. 'dirty': {};
  1650. 'BeforeOpenNotification': BeforeOpenNotificationEvent;
  1651. 'OpenNotification': OpenNotificationEvent;
  1652. }
  1653. interface EditorManagerEventMap {
  1654. 'AddEditor': {
  1655. editor: Editor;
  1656. };
  1657. 'RemoveEditor': {
  1658. editor: Editor;
  1659. };
  1660. 'BeforeUnload': {
  1661. returnValue: any;
  1662. };
  1663. }
  1664. type EventTypes_d_ExecCommandEvent = ExecCommandEvent;
  1665. type EventTypes_d_BeforeGetContentEvent = BeforeGetContentEvent;
  1666. type EventTypes_d_GetContentEvent = GetContentEvent;
  1667. type EventTypes_d_BeforeSetContentEvent = BeforeSetContentEvent;
  1668. type EventTypes_d_SetContentEvent = SetContentEvent;
  1669. type EventTypes_d_SaveContentEvent = SaveContentEvent;
  1670. type EventTypes_d_NewBlockEvent = NewBlockEvent;
  1671. type EventTypes_d_NodeChangeEvent = NodeChangeEvent;
  1672. type EventTypes_d_FormatEvent = FormatEvent;
  1673. type EventTypes_d_ObjectResizeEvent = ObjectResizeEvent;
  1674. type EventTypes_d_ObjectSelectedEvent = ObjectSelectedEvent;
  1675. type EventTypes_d_ScrollIntoViewEvent = ScrollIntoViewEvent;
  1676. type EventTypes_d_SetSelectionRangeEvent = SetSelectionRangeEvent;
  1677. type EventTypes_d_ShowCaretEvent = ShowCaretEvent;
  1678. type EventTypes_d_SwitchModeEvent = SwitchModeEvent;
  1679. type EventTypes_d_ChangeEvent = ChangeEvent;
  1680. type EventTypes_d_AddUndoEvent = AddUndoEvent;
  1681. type EventTypes_d_UndoRedoEvent = UndoRedoEvent;
  1682. type EventTypes_d_WindowEvent<T extends DialogData> = WindowEvent<T>;
  1683. type EventTypes_d_ProgressStateEvent = ProgressStateEvent;
  1684. type EventTypes_d_AfterProgressStateEvent = AfterProgressStateEvent;
  1685. type EventTypes_d_PlaceholderToggleEvent = PlaceholderToggleEvent;
  1686. type EventTypes_d_LoadErrorEvent = LoadErrorEvent;
  1687. type EventTypes_d_PreProcessEvent = PreProcessEvent;
  1688. type EventTypes_d_PostProcessEvent = PostProcessEvent;
  1689. type EventTypes_d_PastePlainTextToggleEvent = PastePlainTextToggleEvent;
  1690. type EventTypes_d_PastePreProcessEvent = PastePreProcessEvent;
  1691. type EventTypes_d_PastePostProcessEvent = PastePostProcessEvent;
  1692. type EventTypes_d_NewTableRowEvent = NewTableRowEvent;
  1693. type EventTypes_d_NewTableCellEvent = NewTableCellEvent;
  1694. type EventTypes_d_TableEventData = TableEventData;
  1695. type EventTypes_d_TableModifiedEvent = TableModifiedEvent;
  1696. type EventTypes_d_BeforeOpenNotificationEvent = BeforeOpenNotificationEvent;
  1697. type EventTypes_d_OpenNotificationEvent = OpenNotificationEvent;
  1698. type EventTypes_d_EditorEventMap = EditorEventMap;
  1699. type EventTypes_d_EditorManagerEventMap = EditorManagerEventMap;
  1700. declare namespace EventTypes_d {
  1701. export { EventTypes_d_ExecCommandEvent as ExecCommandEvent, EventTypes_d_BeforeGetContentEvent as BeforeGetContentEvent, EventTypes_d_GetContentEvent as GetContentEvent, EventTypes_d_BeforeSetContentEvent as BeforeSetContentEvent, EventTypes_d_SetContentEvent as SetContentEvent, EventTypes_d_SaveContentEvent as SaveContentEvent, 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_ChangeEvent as ChangeEvent, 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_PastePlainTextToggleEvent as PastePlainTextToggleEvent, EventTypes_d_PastePreProcessEvent as PastePreProcessEvent, EventTypes_d_PastePostProcessEvent as PastePostProcessEvent, EventTypes_d_NewTableRowEvent as NewTableRowEvent, EventTypes_d_NewTableCellEvent as NewTableCellEvent, EventTypes_d_TableEventData as TableEventData, EventTypes_d_TableModifiedEvent as TableModifiedEvent, EventTypes_d_BeforeOpenNotificationEvent as BeforeOpenNotificationEvent, EventTypes_d_OpenNotificationEvent as OpenNotificationEvent, EventTypes_d_EditorEventMap as EditorEventMap, EventTypes_d_EditorManagerEventMap as EditorManagerEventMap, };
  1702. }
  1703. type Format_d_Formats = Formats;
  1704. type Format_d_Format = Format;
  1705. type Format_d_ApplyFormat = ApplyFormat;
  1706. type Format_d_BlockFormat = BlockFormat;
  1707. type Format_d_InlineFormat = InlineFormat;
  1708. type Format_d_SelectorFormat = SelectorFormat;
  1709. type Format_d_RemoveFormat = RemoveFormat;
  1710. type Format_d_RemoveBlockFormat = RemoveBlockFormat;
  1711. type Format_d_RemoveInlineFormat = RemoveInlineFormat;
  1712. type Format_d_RemoveSelectorFormat = RemoveSelectorFormat;
  1713. declare namespace Format_d {
  1714. export { Format_d_Formats as Formats, Format_d_Format as Format, Format_d_ApplyFormat as ApplyFormat, Format_d_BlockFormat as BlockFormat, Format_d_InlineFormat as InlineFormat, Format_d_SelectorFormat as SelectorFormat, Format_d_RemoveFormat as RemoveFormat, Format_d_RemoveBlockFormat as RemoveBlockFormat, Format_d_RemoveInlineFormat as RemoveInlineFormat, Format_d_RemoveSelectorFormat as RemoveSelectorFormat, };
  1715. }
  1716. declare type StyleFormat = BlockStyleFormat | InlineStyleFormat | SelectorStyleFormat;
  1717. declare type AllowedFormat = Separator | FormatReference | StyleFormat | NestedFormatting;
  1718. interface Separator {
  1719. title: string;
  1720. }
  1721. interface FormatReference {
  1722. title: string;
  1723. format: string;
  1724. icon?: string;
  1725. }
  1726. interface NestedFormatting {
  1727. title: string;
  1728. items: Array<FormatReference | StyleFormat>;
  1729. }
  1730. interface CommonStyleFormat {
  1731. name?: string;
  1732. title: string;
  1733. icon?: string;
  1734. }
  1735. interface BlockStyleFormat extends BlockFormat, CommonStyleFormat {
  1736. }
  1737. interface InlineStyleFormat extends InlineFormat, CommonStyleFormat {
  1738. }
  1739. interface SelectorStyleFormat extends SelectorFormat, CommonStyleFormat {
  1740. }
  1741. declare type EntityEncoding = 'named' | 'numeric' | 'raw' | 'named,numeric' | 'named+numeric' | 'numeric,named' | 'numeric+named';
  1742. interface ContentLanguage {
  1743. readonly title: string;
  1744. readonly code: string;
  1745. readonly customCode?: string;
  1746. }
  1747. declare type ThemeInitFunc = (editor: Editor, elm: HTMLElement) => {
  1748. editorContainer: HTMLElement;
  1749. iframeContainer: HTMLElement;
  1750. height?: number;
  1751. iframeHeight?: number;
  1752. api?: EditorUiApi;
  1753. };
  1754. declare type SetupCallback = (editor: Editor) => void;
  1755. declare type FilePickerCallback = (callback: (value: string, meta?: Record<string, any>) => void, value: string, meta: Record<string, any>) => void;
  1756. declare type FilePickerValidationStatus = 'valid' | 'unknown' | 'invalid' | 'none';
  1757. declare type FilePickerValidationCallback = (info: {
  1758. type: string;
  1759. url: string;
  1760. }, callback: (validation: {
  1761. status: FilePickerValidationStatus;
  1762. message: string;
  1763. }) => void) => void;
  1764. declare type PastePreProcessFn = (editor: Editor, args: PastePreProcessEvent) => void;
  1765. declare type PastePostProcessFn = (editor: Editor, args: PastePostProcessEvent) => void;
  1766. declare type URLConverter = (url: string, name: string, elm?: string | Element) => string;
  1767. declare type URLConverterCallback = (url: string, node: Node | string | undefined, on_save: boolean, name: string) => string;
  1768. interface ToolbarGroup {
  1769. name?: string;
  1770. items: string[];
  1771. }
  1772. declare type ToolbarMode = 'floating' | 'sliding' | 'scrolling' | 'wrap';
  1773. declare type ToolbarLocation = 'top' | 'bottom' | 'auto';
  1774. interface BaseEditorOptions {
  1775. a11y_advanced_options?: boolean;
  1776. add_form_submit_trigger?: boolean;
  1777. add_unload_trigger?: boolean;
  1778. allow_conditional_comments?: boolean;
  1779. allow_html_data_urls?: boolean;
  1780. allow_html_in_named_anchor?: boolean;
  1781. allow_script_urls?: boolean;
  1782. allow_svg_data_urls?: boolean;
  1783. allow_unsafe_link_target?: boolean;
  1784. anchor_bottom?: false | string;
  1785. anchor_top?: false | string;
  1786. auto_focus?: string | true;
  1787. automatic_uploads?: boolean;
  1788. base_url?: string;
  1789. block_formats?: string;
  1790. block_unsupported_drop?: boolean;
  1791. body_id?: string;
  1792. body_class?: string;
  1793. br_in_pre?: boolean;
  1794. br_newline_selector?: string;
  1795. browser_spellcheck?: boolean;
  1796. branding?: boolean;
  1797. cache_suffix?: string;
  1798. color_cols?: number;
  1799. color_cols_foreground?: number;
  1800. color_cols_background?: number;
  1801. color_map?: string[];
  1802. color_map_foreground?: string[];
  1803. color_map_background?: string[];
  1804. color_default_foreground?: string;
  1805. color_default_background?: string;
  1806. content_css?: boolean | string | string[];
  1807. content_css_cors?: boolean;
  1808. content_security_policy?: string;
  1809. content_style?: string;
  1810. content_langs?: ContentLanguage[];
  1811. contextmenu?: string | string[] | false;
  1812. contextmenu_never_use_native?: boolean;
  1813. convert_fonts_to_spans?: boolean;
  1814. convert_urls?: boolean;
  1815. custom_colors?: boolean;
  1816. custom_elements?: string;
  1817. custom_ui_selector?: string;
  1818. custom_undo_redo_levels?: number;
  1819. deprecation_warnings?: boolean;
  1820. directionality?: 'ltr' | 'rtl';
  1821. doctype?: string;
  1822. document_base_url?: string;
  1823. draggable_modal?: boolean;
  1824. editable_class?: string;
  1825. element_format?: 'xhtml' | 'html';
  1826. elementpath?: boolean;
  1827. encoding?: string;
  1828. end_container_on_empty_block?: boolean | string;
  1829. entities?: string;
  1830. entity_encoding?: EntityEncoding;
  1831. extended_valid_elements?: string;
  1832. event_root?: string;
  1833. file_picker_callback?: FilePickerCallback;
  1834. file_picker_types?: string;
  1835. file_picker_validator_handler?: FilePickerValidationCallback;
  1836. fix_list_elements?: boolean;
  1837. fixed_toolbar_container?: string;
  1838. fixed_toolbar_container_target?: HTMLElement;
  1839. font_css?: string | string[];
  1840. font_family_formats?: string;
  1841. font_size_classes?: string;
  1842. font_size_legacy_values?: string;
  1843. font_size_style_values?: string;
  1844. font_size_formats?: string;
  1845. font_size_input_default_unit?: string;
  1846. forced_root_block?: string;
  1847. forced_root_block_attrs?: Record<string, string>;
  1848. formats?: Formats;
  1849. format_noneditable_selector?: string;
  1850. height?: number | string;
  1851. hidden_input?: boolean;
  1852. highlight_on_focus?: boolean;
  1853. icons?: string;
  1854. icons_url?: string;
  1855. id?: string;
  1856. iframe_aria_text?: string;
  1857. iframe_attrs?: Record<string, string>;
  1858. images_file_types?: string;
  1859. images_replace_blob_uris?: boolean;
  1860. images_reuse_filename?: boolean;
  1861. images_upload_base_path?: string;
  1862. images_upload_credentials?: boolean;
  1863. images_upload_handler?: UploadHandler;
  1864. images_upload_url?: string;
  1865. indent?: boolean;
  1866. indent_after?: string;
  1867. indent_before?: string;
  1868. indent_use_margin?: boolean;
  1869. indentation?: string;
  1870. init_instance_callback?: SetupCallback;
  1871. inline?: boolean;
  1872. inline_boundaries?: boolean;
  1873. inline_boundaries_selector?: string;
  1874. inline_styles?: boolean;
  1875. invalid_elements?: string;
  1876. invalid_styles?: string | Record<string, string>;
  1877. keep_styles?: boolean;
  1878. language?: string;
  1879. language_load?: boolean;
  1880. language_url?: string;
  1881. line_height_formats?: string;
  1882. max_height?: number;
  1883. max_width?: number;
  1884. menu?: Record<string, {
  1885. title: string;
  1886. items: string;
  1887. }>;
  1888. menubar?: boolean | string;
  1889. min_height?: number;
  1890. min_width?: number;
  1891. model?: string;
  1892. model_url?: string;
  1893. newline_behavior?: 'block' | 'linebreak' | 'invert' | 'default';
  1894. no_newline_selector?: string;
  1895. noneditable_class?: string;
  1896. noneditable_regexp?: RegExp | RegExp[];
  1897. nowrap?: boolean;
  1898. object_resizing?: boolean | string;
  1899. paste_as_text?: boolean;
  1900. paste_block_drop?: boolean;
  1901. paste_data_images?: boolean;
  1902. paste_merge_formats?: boolean;
  1903. paste_postprocess?: PastePostProcessFn;
  1904. paste_preprocess?: PastePreProcessFn;
  1905. paste_remove_styles_if_webkit?: boolean;
  1906. paste_tab_spaces?: number;
  1907. paste_webkit_styles?: string;
  1908. placeholder?: string;
  1909. preserve_cdata?: boolean;
  1910. preview_styles?: false | string;
  1911. promotion?: boolean;
  1912. protect?: RegExp[];
  1913. readonly?: boolean;
  1914. referrer_policy?: ReferrerPolicy;
  1915. relative_urls?: boolean;
  1916. remove_script_host?: boolean;
  1917. remove_trailing_brs?: boolean;
  1918. removed_menuitems?: string;
  1919. resize?: boolean | 'both';
  1920. resize_img_proportional?: boolean;
  1921. root_name?: string;
  1922. schema?: SchemaType;
  1923. selector?: string;
  1924. setup?: SetupCallback;
  1925. sidebar_show?: string;
  1926. skin?: boolean | string;
  1927. skin_url?: string;
  1928. smart_paste?: boolean;
  1929. statusbar?: boolean;
  1930. style_formats?: AllowedFormat[];
  1931. style_formats_autohide?: boolean;
  1932. style_formats_merge?: boolean;
  1933. submit_patch?: boolean;
  1934. suffix?: string;
  1935. table_tab_navigation?: boolean;
  1936. target?: HTMLElement;
  1937. text_patterns?: RawPattern[] | false;
  1938. text_patterns_lookup?: RawDynamicPatternsLookup;
  1939. theme?: string | ThemeInitFunc | false;
  1940. theme_url?: string;
  1941. toolbar?: boolean | string | string[] | Array<ToolbarGroup>;
  1942. toolbar1?: string;
  1943. toolbar2?: string;
  1944. toolbar3?: string;
  1945. toolbar4?: string;
  1946. toolbar5?: string;
  1947. toolbar6?: string;
  1948. toolbar7?: string;
  1949. toolbar8?: string;
  1950. toolbar9?: string;
  1951. toolbar_groups?: Record<string, GroupToolbarButtonSpec>;
  1952. toolbar_location?: ToolbarLocation;
  1953. toolbar_mode?: ToolbarMode;
  1954. toolbar_sticky?: boolean;
  1955. toolbar_sticky_offset?: number;
  1956. typeahead_urls?: boolean;
  1957. ui_mode?: 'combined' | 'split';
  1958. url_converter?: URLConverter;
  1959. url_converter_scope?: any;
  1960. urlconverter_callback?: URLConverterCallback;
  1961. valid_children?: string;
  1962. valid_classes?: string | Record<string, string>;
  1963. valid_elements?: string;
  1964. valid_styles?: string | Record<string, string>;
  1965. verify_html?: boolean;
  1966. visual?: boolean;
  1967. visual_anchor_class?: string;
  1968. visual_table_class?: string;
  1969. width?: number | string;
  1970. xss_sanitization?: boolean;
  1971. disable_nodechange?: boolean;
  1972. forced_plugins?: string | string[];
  1973. plugin_base_urls?: Record<string, string>;
  1974. service_message?: string;
  1975. [key: string]: any;
  1976. }
  1977. interface RawEditorOptions extends BaseEditorOptions {
  1978. external_plugins?: Record<string, string>;
  1979. mobile?: RawEditorOptions;
  1980. plugins?: string | string[];
  1981. }
  1982. interface NormalizedEditorOptions extends BaseEditorOptions {
  1983. external_plugins: Record<string, string>;
  1984. forced_plugins: string[];
  1985. plugins: string[];
  1986. }
  1987. interface EditorOptions extends NormalizedEditorOptions {
  1988. a11y_advanced_options: boolean;
  1989. allow_unsafe_link_target: boolean;
  1990. anchor_bottom: string;
  1991. anchor_top: string;
  1992. automatic_uploads: boolean;
  1993. block_formats: string;
  1994. body_class: string;
  1995. body_id: string;
  1996. br_newline_selector: string;
  1997. color_map: string[];
  1998. color_cols: number;
  1999. color_cols_foreground: number;
  2000. color_cols_background: number;
  2001. color_default_background: string;
  2002. color_default_foreground: string;
  2003. content_css: string[];
  2004. contextmenu: string[];
  2005. custom_colors: boolean;
  2006. document_base_url: string;
  2007. draggable_modal: boolean;
  2008. editable_class: string;
  2009. font_css: string[];
  2010. font_family_formats: string;
  2011. font_size_classes: string;
  2012. font_size_formats: string;
  2013. font_size_input_default_unit: string;
  2014. font_size_legacy_values: string;
  2015. font_size_style_values: string;
  2016. forced_root_block: string;
  2017. forced_root_block_attrs: Record<string, string>;
  2018. format_noneditable_selector: string;
  2019. height: number | string;
  2020. highlight_on_focus: boolean;
  2021. iframe_attrs: Record<string, string>;
  2022. images_file_types: string;
  2023. images_upload_base_path: string;
  2024. images_upload_credentials: boolean;
  2025. images_upload_url: string;
  2026. indent_use_margin: boolean;
  2027. indentation: string;
  2028. inline: boolean;
  2029. inline_boundaries_selector: string;
  2030. language: string;
  2031. language_load: boolean;
  2032. language_url: string;
  2033. line_height_formats: string;
  2034. menu: Record<string, {
  2035. title: string;
  2036. items: string;
  2037. }>;
  2038. menubar: boolean | string;
  2039. model: string;
  2040. no_newline_selector: string;
  2041. noneditable_class: string;
  2042. noneditable_regexp: RegExp[];
  2043. object_resizing: string;
  2044. paste_as_text: boolean;
  2045. preview_styles: string;
  2046. promotion: boolean;
  2047. readonly: boolean;
  2048. removed_menuitems: string;
  2049. toolbar: boolean | string | string[] | Array<ToolbarGroup>;
  2050. toolbar_groups: Record<string, GroupToolbarButtonSpec>;
  2051. toolbar_location: ToolbarLocation;
  2052. toolbar_mode: ToolbarMode;
  2053. toolbar_persist: boolean;
  2054. toolbar_sticky: boolean;
  2055. toolbar_sticky_offset: number;
  2056. text_patterns: Pattern[];
  2057. text_patterns_lookup: DynamicPatternsLookup;
  2058. visual: boolean;
  2059. visual_anchor_class: string;
  2060. visual_table_class: string;
  2061. width: number | string;
  2062. xss_sanitization: boolean;
  2063. }
  2064. declare type StyleMap = Record<string, string | number>;
  2065. interface StylesSettings {
  2066. allow_script_urls?: boolean;
  2067. allow_svg_data_urls?: boolean;
  2068. url_converter?: URLConverter;
  2069. url_converter_scope?: any;
  2070. }
  2071. interface Styles {
  2072. parse: (css: string | undefined) => Record<string, string>;
  2073. serialize: (styles: StyleMap, elementName?: string) => string;
  2074. }
  2075. declare type EventUtilsCallback<T> = (event: EventUtilsEvent<T>) => void | boolean;
  2076. declare type EventUtilsEvent<T> = NormalizedEvent<T> & {
  2077. metaKey: boolean;
  2078. };
  2079. interface Callback$1<T> {
  2080. func: EventUtilsCallback<T>;
  2081. scope: any;
  2082. }
  2083. interface CallbackList<T> extends Array<Callback$1<T>> {
  2084. fakeName: string | false;
  2085. capture: boolean;
  2086. nativeHandler: EventListener;
  2087. }
  2088. interface EventUtilsConstructor {
  2089. readonly prototype: EventUtils;
  2090. new (): EventUtils;
  2091. Event: EventUtils;
  2092. }
  2093. declare class EventUtils {
  2094. static Event: EventUtils;
  2095. domLoaded: boolean;
  2096. events: Record<number, Record<string, CallbackList<any>>>;
  2097. private readonly expando;
  2098. private hasFocusIn;
  2099. private count;
  2100. constructor();
  2101. bind<K extends keyof HTMLElementEventMap>(target: any, name: K, callback: EventUtilsCallback<HTMLElementEventMap[K]>, scope?: any): EventUtilsCallback<HTMLElementEventMap[K]>;
  2102. bind<T = any>(target: any, names: string, callback: EventUtilsCallback<T>, scope?: any): EventUtilsCallback<T>;
  2103. unbind<K extends keyof HTMLElementEventMap>(target: any, name: K, callback?: EventUtilsCallback<HTMLElementEventMap[K]>): this;
  2104. unbind<T = any>(target: any, names: string, callback?: EventUtilsCallback<T>): this;
  2105. unbind(target: any): this;
  2106. fire(target: any, name: string, args?: {}): this;
  2107. dispatch(target: any, name: string, args?: {}): this;
  2108. clean(target: any): this;
  2109. destroy(): void;
  2110. cancel<T>(e: EventUtilsEvent<T>): boolean;
  2111. private executeHandlers;
  2112. }
  2113. interface SetAttribEvent {
  2114. attrElm: HTMLElement;
  2115. attrName: string;
  2116. attrValue: string | boolean | number | null;
  2117. }
  2118. interface DOMUtilsSettings {
  2119. schema: Schema;
  2120. url_converter: URLConverter;
  2121. url_converter_scope: any;
  2122. ownEvents: boolean;
  2123. keep_values: boolean;
  2124. update_styles: boolean;
  2125. root_element: HTMLElement | null;
  2126. collect: boolean;
  2127. onSetAttrib: (event: SetAttribEvent) => void;
  2128. contentCssCors: boolean;
  2129. referrerPolicy: ReferrerPolicy;
  2130. }
  2131. declare type Target = Node | Window;
  2132. declare type RunArguments<T extends Node = Node> = string | T | Array<string | T> | null;
  2133. declare type BoundEvent = [
  2134. Target,
  2135. string,
  2136. EventUtilsCallback<any>,
  2137. any
  2138. ];
  2139. declare type Callback<K extends string> = EventUtilsCallback<MappedEvent<HTMLElementEventMap, K>>;
  2140. declare type RunResult<T, R> = T extends Array<any> ? R[] : false | R;
  2141. interface DOMUtils {
  2142. doc: Document;
  2143. settings: Partial<DOMUtilsSettings>;
  2144. win: Window;
  2145. files: Record<string, boolean>;
  2146. stdMode: boolean;
  2147. boxModel: boolean;
  2148. styleSheetLoader: StyleSheetLoader;
  2149. boundEvents: BoundEvent[];
  2150. styles: Styles;
  2151. schema: Schema;
  2152. events: EventUtils;
  2153. root: Node | null;
  2154. isBlock: {
  2155. (node: Node | null): node is HTMLElement;
  2156. (node: string): boolean;
  2157. };
  2158. clone: (node: Node, deep: boolean) => Node;
  2159. getRoot: () => HTMLElement;
  2160. getViewPort: (argWin?: Window) => GeomRect;
  2161. getRect: (elm: string | HTMLElement) => GeomRect;
  2162. getSize: (elm: string | HTMLElement) => {
  2163. w: number;
  2164. h: number;
  2165. };
  2166. getParent: {
  2167. <K extends keyof HTMLElementTagNameMap>(node: string | Node | null, selector: K, root?: Node): HTMLElementTagNameMap[K] | null;
  2168. <T extends Element>(node: string | Node | null, selector: string | ((node: Node) => node is T), root?: Node): T | null;
  2169. (node: string | Node | null, selector?: string | ((node: Node) => boolean | void), root?: Node): Node | null;
  2170. };
  2171. getParents: {
  2172. <K extends keyof HTMLElementTagNameMap>(elm: string | HTMLElementTagNameMap[K] | null, selector: K, root?: Node, collect?: boolean): Array<HTMLElementTagNameMap[K]>;
  2173. <T extends Element>(node: string | Node | null, selector: string | ((node: Node) => node is T), root?: Node, collect?: boolean): T[];
  2174. (elm: string | Node | null, selector?: string | ((node: Node) => boolean | void), root?: Node, collect?: boolean): Node[];
  2175. };
  2176. get: {
  2177. <T extends Node>(elm: T): T;
  2178. (elm: string): HTMLElement | null;
  2179. };
  2180. getNext: (node: Node | null, selector: string | ((node: Node) => boolean)) => Node | null;
  2181. getPrev: (node: Node | null, selector: string | ((node: Node) => boolean)) => Node | null;
  2182. select: {
  2183. <K extends keyof HTMLElementTagNameMap>(selector: K, scope?: string | Node): Array<HTMLElementTagNameMap[K]>;
  2184. <T extends HTMLElement = HTMLElement>(selector: string, scope?: string | Node): T[];
  2185. };
  2186. is: {
  2187. <T extends Element>(elm: Node | Node[] | null, selector: string): elm is T;
  2188. (elm: Node | Node[] | null, selector: string): boolean;
  2189. };
  2190. add: (parentElm: RunArguments, name: string | Element, attrs?: Record<string, string | boolean | number | null>, html?: string | Node | null, create?: boolean) => HTMLElement;
  2191. create: {
  2192. <K extends keyof HTMLElementTagNameMap>(name: K, attrs?: Record<string, string | boolean | number | null>, html?: string | Node | null): HTMLElementTagNameMap[K];
  2193. (name: string, attrs?: Record<string, string | boolean | number | null>, html?: string | Node | null): HTMLElement;
  2194. };
  2195. createHTML: (name: string, attrs?: Record<string, string | null>, html?: string) => string;
  2196. createFragment: (html?: string) => DocumentFragment;
  2197. remove: {
  2198. <T extends Node>(node: T | T[], keepChildren?: boolean): typeof node extends Array<any> ? T[] : T;
  2199. <T extends Node>(node: string, keepChildren?: boolean): T | false;
  2200. };
  2201. getStyle: {
  2202. (elm: Element, name: string, computed: true): string;
  2203. (elm: string | Element | null, name: string, computed?: boolean): string | undefined;
  2204. };
  2205. setStyle: (elm: string | Element | Element[], name: string, value: string | number | null) => void;
  2206. setStyles: (elm: string | Element | Element[], stylesArg: StyleMap) => void;
  2207. removeAllAttribs: (e: RunArguments<Element>) => void;
  2208. setAttrib: (elm: RunArguments<Element>, name: string, value: string | boolean | number | null) => void;
  2209. setAttribs: (elm: RunArguments<Element>, attrs: Record<string, string | boolean | number | null>) => void;
  2210. getAttrib: (elm: string | Element | null, name: string, defaultVal?: string) => string;
  2211. getAttribs: (elm: string | Element) => NamedNodeMap | Attr[];
  2212. getPos: (elm: string | Element, rootElm?: Node) => {
  2213. x: number;
  2214. y: number;
  2215. };
  2216. parseStyle: (cssText: string) => Record<string, string>;
  2217. serializeStyle: (stylesArg: StyleMap, name?: string) => string;
  2218. addStyle: (cssText: string) => void;
  2219. loadCSS: (url: string) => void;
  2220. hasClass: (elm: string | Element, cls: string) => boolean;
  2221. addClass: (elm: RunArguments<Element>, cls: string) => void;
  2222. removeClass: (elm: RunArguments<Element>, cls: string) => void;
  2223. toggleClass: (elm: RunArguments<Element>, cls: string, state?: boolean) => void;
  2224. show: (elm: string | Node | Node[]) => void;
  2225. hide: (elm: string | Node | Node[]) => void;
  2226. isHidden: (elm: string | Node) => boolean;
  2227. uniqueId: (prefix?: string) => string;
  2228. setHTML: (elm: RunArguments<Element>, html: string) => void;
  2229. getOuterHTML: (elm: string | Node) => string;
  2230. setOuterHTML: (elm: string | Node | Node[], html: string) => void;
  2231. decode: (text: string) => string;
  2232. encode: (text: string) => string;
  2233. insertAfter: {
  2234. <T extends Node>(node: T | T[], reference: string | Node): T;
  2235. <T extends Node>(node: RunArguments<T>, reference: string | Node): RunResult<typeof node, T>;
  2236. };
  2237. replace: {
  2238. <T extends Node>(newElm: Node, oldElm: T | T[], keepChildren?: boolean): T;
  2239. <T extends Node>(newElm: Node, oldElm: RunArguments<T>, keepChildren?: boolean): false | T;
  2240. };
  2241. rename: {
  2242. <K extends keyof HTMLElementTagNameMap>(elm: Element, name: K): HTMLElementTagNameMap[K];
  2243. (elm: Element, name: string): Element;
  2244. };
  2245. findCommonAncestor: (a: Node, b: Node) => Node | null;
  2246. run<R, T extends Node>(this: DOMUtils, elm: T | T[], func: (node: T) => R, scope?: any): typeof elm extends Array<any> ? R[] : R;
  2247. run<R, T extends Node>(this: DOMUtils, elm: RunArguments<T>, func: (node: T) => R, scope?: any): RunResult<typeof elm, R>;
  2248. isEmpty: (node: Node, elements?: Record<string, any>) => boolean;
  2249. createRng: () => Range;
  2250. nodeIndex: (node: Node, normalized?: boolean) => number;
  2251. split: {
  2252. <T extends Node>(parentElm: Node, splitElm: Node, replacementElm: T): T | undefined;
  2253. <T extends Node>(parentElm: Node, splitElm: T): T | undefined;
  2254. };
  2255. bind: {
  2256. <K extends string>(target: Target, name: K, func: Callback<K>, scope?: any): Callback<K>;
  2257. <K extends string>(target: Target[], name: K, func: Callback<K>, scope?: any): Callback<K>[];
  2258. };
  2259. unbind: {
  2260. <K extends string>(target: Target, name?: K, func?: EventUtilsCallback<MappedEvent<HTMLElementEventMap, K>>): EventUtils;
  2261. <K extends string>(target: Target[], name?: K, func?: EventUtilsCallback<MappedEvent<HTMLElementEventMap, K>>): EventUtils[];
  2262. };
  2263. fire: (target: Node | Window, name: string, evt?: {}) => EventUtils;
  2264. dispatch: (target: Node | Window, name: string, evt?: {}) => EventUtils;
  2265. getContentEditable: (node: Node) => string | null;
  2266. getContentEditableParent: (node: Node) => string | null;
  2267. isEditable: (node: Node | null | undefined) => boolean;
  2268. destroy: () => void;
  2269. isChildOf: (node: Node, parent: Node) => boolean;
  2270. dumpRng: (r: Range) => string;
  2271. }
  2272. interface ClientRect {
  2273. left: number;
  2274. top: number;
  2275. bottom: number;
  2276. right: number;
  2277. width: number;
  2278. height: number;
  2279. }
  2280. interface BookmarkManager {
  2281. getBookmark: (type?: number, normalized?: boolean) => Bookmark;
  2282. moveToBookmark: (bookmark: Bookmark) => void;
  2283. }
  2284. interface ControlSelection {
  2285. isResizable: (elm: Element) => boolean;
  2286. showResizeRect: (elm: HTMLElement) => void;
  2287. hideResizeRect: () => void;
  2288. updateResizeRect: (evt: EditorEvent<any>) => void;
  2289. destroy: () => void;
  2290. }
  2291. interface WriterSettings {
  2292. element_format?: 'xhtml' | 'html';
  2293. entities?: string;
  2294. entity_encoding?: EntityEncoding;
  2295. indent?: boolean;
  2296. indent_after?: string;
  2297. indent_before?: string;
  2298. }
  2299. declare type Attributes = Array<{
  2300. name: string;
  2301. value: string;
  2302. }>;
  2303. interface Writer {
  2304. cdata: (text: string) => void;
  2305. comment: (text: string) => void;
  2306. doctype: (text: string) => void;
  2307. end: (name: string) => void;
  2308. getContent: () => string;
  2309. pi: (name: string, text?: string) => void;
  2310. reset: () => void;
  2311. start: (name: string, attrs?: Attributes | null, empty?: boolean) => void;
  2312. text: (text: string, raw?: boolean) => void;
  2313. }
  2314. interface HtmlSerializerSettings extends WriterSettings {
  2315. inner?: boolean;
  2316. validate?: boolean;
  2317. }
  2318. interface HtmlSerializer {
  2319. serialize: (node: AstNode) => string;
  2320. }
  2321. interface DomSerializerSettings extends DomParserSettings, WriterSettings, SchemaSettings, HtmlSerializerSettings {
  2322. url_converter?: URLConverter;
  2323. url_converter_scope?: {};
  2324. }
  2325. interface DomSerializerImpl {
  2326. schema: Schema;
  2327. addNodeFilter: (name: string, callback: ParserFilterCallback) => void;
  2328. addAttributeFilter: (name: string, callback: ParserFilterCallback) => void;
  2329. getNodeFilters: () => ParserFilter[];
  2330. getAttributeFilters: () => ParserFilter[];
  2331. removeNodeFilter: (name: string, callback?: ParserFilterCallback) => void;
  2332. removeAttributeFilter: (name: string, callback?: ParserFilterCallback) => void;
  2333. serialize: {
  2334. (node: Element, parserArgs: {
  2335. format: 'tree';
  2336. } & ParserArgs): AstNode;
  2337. (node: Element, parserArgs?: ParserArgs): string;
  2338. };
  2339. addRules: (rules: string) => void;
  2340. setRules: (rules: string) => void;
  2341. addTempAttr: (name: string) => void;
  2342. getTempAttrs: () => string[];
  2343. }
  2344. interface DomSerializer extends DomSerializerImpl {
  2345. }
  2346. interface EditorSelection {
  2347. bookmarkManager: BookmarkManager;
  2348. controlSelection: ControlSelection;
  2349. dom: DOMUtils;
  2350. win: Window;
  2351. serializer: DomSerializer;
  2352. editor: Editor;
  2353. collapse: (toStart?: boolean) => void;
  2354. setCursorLocation: {
  2355. (node: Node, offset: number): void;
  2356. (): void;
  2357. };
  2358. getContent: {
  2359. (args: {
  2360. format: 'tree';
  2361. } & Partial<GetSelectionContentArgs>): AstNode;
  2362. (args?: Partial<GetSelectionContentArgs>): string;
  2363. };
  2364. setContent: (content: string, args?: Partial<SetSelectionContentArgs>) => void;
  2365. getBookmark: (type?: number, normalized?: boolean) => Bookmark;
  2366. moveToBookmark: (bookmark: Bookmark) => void;
  2367. select: (node: Node, content?: boolean) => Node;
  2368. isCollapsed: () => boolean;
  2369. isEditable: () => boolean;
  2370. isForward: () => boolean;
  2371. setNode: (elm: Element) => Element;
  2372. getNode: () => HTMLElement;
  2373. getSel: () => Selection | null;
  2374. setRng: (rng: Range, forward?: boolean) => void;
  2375. getRng: () => Range;
  2376. getStart: (real?: boolean) => Element;
  2377. getEnd: (real?: boolean) => Element;
  2378. getSelectedBlocks: (startElm?: Element, endElm?: Element) => Element[];
  2379. normalize: () => Range;
  2380. selectorChanged: (selector: string, callback: (active: boolean, args: {
  2381. node: Node;
  2382. selector: String;
  2383. parents: Node[];
  2384. }) => void) => EditorSelection;
  2385. selectorChangedWithUnbind: (selector: string, callback: (active: boolean, args: {
  2386. node: Node;
  2387. selector: String;
  2388. parents: Node[];
  2389. }) => void) => {
  2390. unbind: () => void;
  2391. };
  2392. getScrollContainer: () => HTMLElement | undefined;
  2393. scrollIntoView: (elm?: HTMLElement, alignToTop?: boolean) => void;
  2394. placeCaretAt: (clientX: number, clientY: number) => void;
  2395. getBoundingClientRect: () => ClientRect | DOMRect;
  2396. destroy: () => void;
  2397. expand: (options?: {
  2398. type: 'word';
  2399. }) => void;
  2400. }
  2401. declare type EditorCommandCallback<S> = (this: S, ui: boolean, value: any) => void;
  2402. declare type EditorCommandsCallback = (command: string, ui: boolean, value?: any) => void;
  2403. interface Commands {
  2404. state: Record<string, (command: string) => boolean>;
  2405. exec: Record<string, EditorCommandsCallback>;
  2406. value: Record<string, (command: string) => string>;
  2407. }
  2408. interface ExecCommandArgs {
  2409. skip_focus?: boolean;
  2410. }
  2411. interface EditorCommandsConstructor {
  2412. readonly prototype: EditorCommands;
  2413. new (editor: Editor): EditorCommands;
  2414. }
  2415. declare class EditorCommands {
  2416. private readonly editor;
  2417. private commands;
  2418. constructor(editor: Editor);
  2419. execCommand(command: string, ui?: boolean, value?: any, args?: ExecCommandArgs): boolean;
  2420. queryCommandState(command: string): boolean;
  2421. queryCommandValue(command: string): string;
  2422. addCommands<K extends keyof Commands>(commandList: Commands[K], type: K): void;
  2423. addCommands(commandList: Record<string, EditorCommandsCallback>): void;
  2424. addCommand<S>(command: string, callback: EditorCommandCallback<S>, scope: S): void;
  2425. addCommand(command: string, callback: EditorCommandCallback<Editor>): void;
  2426. queryCommandSupported(command: string): boolean;
  2427. addQueryStateHandler<S>(command: string, callback: (this: S) => boolean, scope: S): void;
  2428. addQueryStateHandler(command: string, callback: (this: Editor) => boolean): void;
  2429. addQueryValueHandler<S>(command: string, callback: (this: S) => string, scope: S): void;
  2430. addQueryValueHandler(command: string, callback: (this: Editor) => string): void;
  2431. }
  2432. interface RawString {
  2433. raw: string;
  2434. }
  2435. declare type Primitive = string | number | boolean | Record<string | number, any> | Function;
  2436. declare type TokenisedString = [
  2437. string,
  2438. ...Primitive[]
  2439. ];
  2440. declare type Untranslated = Primitive | TokenisedString | RawString | null | undefined;
  2441. declare type TranslatedString = string;
  2442. interface I18n {
  2443. getData: () => Record<string, Record<string, string>>;
  2444. setCode: (newCode: string) => void;
  2445. getCode: () => string;
  2446. add: (code: string, items: Record<string, string>) => void;
  2447. translate: (text: Untranslated) => TranslatedString;
  2448. isRtl: () => boolean;
  2449. hasCode: (code: string) => boolean;
  2450. }
  2451. interface Observable<T extends {}> {
  2452. fire<K extends string, U extends MappedEvent<T, K>>(name: K, args?: U, bubble?: boolean): EditorEvent<U>;
  2453. dispatch<K extends string, U extends MappedEvent<T, K>>(name: K, args?: U, bubble?: boolean): EditorEvent<U>;
  2454. on<K extends string>(name: K, callback: (event: EditorEvent<MappedEvent<T, K>>) => void, prepend?: boolean): EventDispatcher<T>;
  2455. off<K extends string>(name?: K, callback?: (event: EditorEvent<MappedEvent<T, K>>) => void): EventDispatcher<T>;
  2456. once<K extends string>(name: K, callback: (event: EditorEvent<MappedEvent<T, K>>) => void): EventDispatcher<T>;
  2457. hasEventListeners(name: string): boolean;
  2458. }
  2459. interface URISettings {
  2460. base_uri?: URI;
  2461. }
  2462. interface URIConstructor {
  2463. readonly prototype: URI;
  2464. new (url: string, settings?: URISettings): URI;
  2465. getDocumentBaseUrl: (loc: {
  2466. protocol: string;
  2467. host?: string;
  2468. href?: string;
  2469. pathname?: string;
  2470. }) => string;
  2471. parseDataUri: (uri: string) => {
  2472. type: string;
  2473. data: string;
  2474. };
  2475. }
  2476. interface SafeUriOptions {
  2477. readonly allow_html_data_urls?: boolean;
  2478. readonly allow_script_urls?: boolean;
  2479. readonly allow_svg_data_urls?: boolean;
  2480. }
  2481. declare class URI {
  2482. static parseDataUri(uri: string): {
  2483. type: string | undefined;
  2484. data: string;
  2485. };
  2486. static isDomSafe(uri: string, context?: string, options?: SafeUriOptions): boolean;
  2487. static getDocumentBaseUrl(loc: {
  2488. protocol: string;
  2489. host?: string;
  2490. href?: string;
  2491. pathname?: string;
  2492. }): string;
  2493. source: string;
  2494. protocol: string | undefined;
  2495. authority: string | undefined;
  2496. userInfo: string | undefined;
  2497. user: string | undefined;
  2498. password: string | undefined;
  2499. host: string | undefined;
  2500. port: string | undefined;
  2501. relative: string | undefined;
  2502. path: string;
  2503. directory: string;
  2504. file: string | undefined;
  2505. query: string | undefined;
  2506. anchor: string | undefined;
  2507. settings: URISettings;
  2508. constructor(url: string, settings?: URISettings);
  2509. setPath(path: string): void;
  2510. toRelative(uri: string): string;
  2511. toAbsolute(uri: string, noHost?: boolean): string;
  2512. isSameOrigin(uri: URI): boolean;
  2513. toRelPath(base: string, path: string): string;
  2514. toAbsPath(base: string, path: string): string;
  2515. getURI(noProtoHost?: boolean): string;
  2516. }
  2517. interface EditorManager extends Observable<EditorManagerEventMap> {
  2518. defaultOptions: RawEditorOptions;
  2519. majorVersion: string;
  2520. minorVersion: string;
  2521. releaseDate: string;
  2522. activeEditor: Editor | null;
  2523. focusedEditor: Editor | null;
  2524. baseURI: URI;
  2525. baseURL: string;
  2526. documentBaseURL: string;
  2527. i18n: I18n;
  2528. suffix: string;
  2529. add(this: EditorManager, editor: Editor): Editor;
  2530. addI18n: (code: string, item: Record<string, string>) => void;
  2531. createEditor(this: EditorManager, id: string, options: RawEditorOptions): Editor;
  2532. execCommand(this: EditorManager, cmd: string, ui: boolean, value: any): boolean;
  2533. get(this: EditorManager): Editor[];
  2534. get(this: EditorManager, id: number | string): Editor | null;
  2535. init(this: EditorManager, options: RawEditorOptions): Promise<Editor[]>;
  2536. overrideDefaults(this: EditorManager, defaultOptions: Partial<RawEditorOptions>): void;
  2537. remove(this: EditorManager): void;
  2538. remove(this: EditorManager, selector: string): void;
  2539. remove(this: EditorManager, editor: Editor): Editor | null;
  2540. setActive(this: EditorManager, editor: Editor): void;
  2541. setup(this: EditorManager): void;
  2542. translate: (text: Untranslated) => TranslatedString;
  2543. triggerSave: () => void;
  2544. _setBaseUrl(this: EditorManager, baseUrl: string): void;
  2545. }
  2546. interface EditorObservable extends Observable<EditorEventMap> {
  2547. bindPendingEventDelegates(this: Editor): void;
  2548. toggleNativeEvent(this: Editor, name: string, state: boolean): void;
  2549. unbindAllNativeEvents(this: Editor): void;
  2550. }
  2551. interface ProcessorSuccess<T> {
  2552. valid: true;
  2553. value: T;
  2554. }
  2555. interface ProcessorError {
  2556. valid: false;
  2557. message: string;
  2558. }
  2559. declare type SimpleProcessor = (value: unknown) => boolean;
  2560. declare type Processor<T> = (value: unknown) => ProcessorSuccess<T> | ProcessorError;
  2561. interface BuiltInOptionTypeMap {
  2562. 'string': string;
  2563. 'number': number;
  2564. 'boolean': boolean;
  2565. 'array': any[];
  2566. 'function': Function;
  2567. 'object': any;
  2568. 'string[]': string[];
  2569. 'object[]': any[];
  2570. 'regexp': RegExp;
  2571. }
  2572. declare type BuiltInOptionType = keyof BuiltInOptionTypeMap;
  2573. interface BaseOptionSpec {
  2574. immutable?: boolean;
  2575. deprecated?: boolean;
  2576. docsUrl?: string;
  2577. }
  2578. interface BuiltInOptionSpec<K extends BuiltInOptionType> extends BaseOptionSpec {
  2579. processor: K;
  2580. default?: BuiltInOptionTypeMap[K];
  2581. }
  2582. interface SimpleOptionSpec<T> extends BaseOptionSpec {
  2583. processor: SimpleProcessor;
  2584. default?: T;
  2585. }
  2586. interface OptionSpec<T, U> extends BaseOptionSpec {
  2587. processor: Processor<U>;
  2588. default?: T;
  2589. }
  2590. interface Options {
  2591. register: {
  2592. <K extends BuiltInOptionType>(name: string, spec: BuiltInOptionSpec<K>): void;
  2593. <K extends keyof NormalizedEditorOptions>(name: K, spec: OptionSpec<NormalizedEditorOptions[K], EditorOptions[K]> | SimpleOptionSpec<NormalizedEditorOptions[K]>): void;
  2594. <T, U>(name: string, spec: OptionSpec<T, U>): void;
  2595. <T>(name: string, spec: SimpleOptionSpec<T>): void;
  2596. };
  2597. isRegistered: (name: string) => boolean;
  2598. get: {
  2599. <K extends keyof EditorOptions>(name: K): EditorOptions[K];
  2600. <T>(name: string): T | undefined;
  2601. };
  2602. set: <K extends string, T>(name: K, value: K extends keyof NormalizedEditorOptions ? NormalizedEditorOptions[K] : T) => boolean;
  2603. unset: (name: string) => boolean;
  2604. isSet: (name: string) => boolean;
  2605. }
  2606. interface UploadResult$1 {
  2607. element: HTMLImageElement;
  2608. status: boolean;
  2609. blobInfo: BlobInfo;
  2610. uploadUri: string;
  2611. removed: boolean;
  2612. }
  2613. interface EditorUpload {
  2614. blobCache: BlobCache;
  2615. addFilter: (filter: (img: HTMLImageElement) => boolean) => void;
  2616. uploadImages: () => Promise<UploadResult$1[]>;
  2617. uploadImagesAuto: () => Promise<UploadResult$1[]>;
  2618. scanForImages: () => Promise<BlobInfoImagePair[]>;
  2619. destroy: () => void;
  2620. }
  2621. declare type FormatChangeCallback = (state: boolean, data: {
  2622. node: Node;
  2623. format: string;
  2624. parents: Element[];
  2625. }) => void;
  2626. interface FormatRegistry {
  2627. get: {
  2628. (name: string): Format[] | undefined;
  2629. (): Record<string, Format[]>;
  2630. };
  2631. has: (name: string) => boolean;
  2632. register: (name: string | Formats, format?: Format[] | Format) => void;
  2633. unregister: (name: string) => Formats;
  2634. }
  2635. interface Formatter extends FormatRegistry {
  2636. apply: (name: string, vars?: FormatVars, node?: Node | RangeLikeObject | null) => void;
  2637. remove: (name: string, vars?: FormatVars, node?: Node | Range, similar?: boolean) => void;
  2638. toggle: (name: string, vars?: FormatVars, node?: Node) => void;
  2639. match: (name: string, vars?: FormatVars, node?: Node, similar?: boolean) => boolean;
  2640. closest: (names: string[]) => string | null;
  2641. matchAll: (names: string[], vars?: FormatVars) => string[];
  2642. matchNode: (node: Node | null, name: string, vars?: FormatVars, similar?: boolean) => Format | undefined;
  2643. canApply: (name: string) => boolean;
  2644. formatChanged: (names: string, callback: FormatChangeCallback, similar?: boolean, vars?: FormatVars) => {
  2645. unbind: () => void;
  2646. };
  2647. getCssText: (format: string | ApplyFormat) => string;
  2648. }
  2649. interface EditorMode {
  2650. isReadOnly: () => boolean;
  2651. set: (mode: string) => void;
  2652. get: () => string;
  2653. register: (mode: string, api: EditorModeApi) => void;
  2654. }
  2655. interface EditorModeApi {
  2656. activate: () => void;
  2657. deactivate: () => void;
  2658. editorReadOnly: boolean;
  2659. }
  2660. interface Model {
  2661. readonly table: {
  2662. readonly getSelectedCells: () => HTMLTableCellElement[];
  2663. readonly clearSelectedCells: (container: Node) => void;
  2664. };
  2665. }
  2666. declare type ModelManager = AddOnManager<Model>;
  2667. interface Plugin {
  2668. getMetadata?: () => {
  2669. name: string;
  2670. url: string;
  2671. };
  2672. init?: (editor: Editor, url: string) => void;
  2673. [key: string]: any;
  2674. }
  2675. declare type PluginManager = AddOnManager<void | Plugin>;
  2676. interface ShortcutsConstructor {
  2677. readonly prototype: Shortcuts;
  2678. new (editor: Editor): Shortcuts;
  2679. }
  2680. declare type CommandFunc = string | [
  2681. string,
  2682. boolean,
  2683. any
  2684. ] | (() => void);
  2685. declare class Shortcuts {
  2686. private readonly editor;
  2687. private readonly shortcuts;
  2688. private pendingPatterns;
  2689. constructor(editor: Editor);
  2690. add(pattern: string, desc: string | null, cmdFunc: CommandFunc, scope?: any): boolean;
  2691. remove(pattern: string): boolean;
  2692. private normalizeCommandFunc;
  2693. private createShortcut;
  2694. private hasModifier;
  2695. private isFunctionKey;
  2696. private matchShortcut;
  2697. private executeShortcutAction;
  2698. }
  2699. interface RenderResult {
  2700. iframeContainer?: HTMLElement;
  2701. editorContainer: HTMLElement;
  2702. api?: Partial<EditorUiApi>;
  2703. }
  2704. interface Theme {
  2705. ui?: any;
  2706. inline?: any;
  2707. execCommand?: (command: string, ui?: boolean, value?: any) => boolean;
  2708. destroy?: () => void;
  2709. init?: (editor: Editor, url: string) => void;
  2710. renderUI?: () => Promise<RenderResult> | RenderResult;
  2711. getNotificationManagerImpl?: () => NotificationManagerImpl;
  2712. getWindowManagerImpl?: () => WindowManagerImpl;
  2713. }
  2714. declare type ThemeManager = AddOnManager<void | Theme>;
  2715. interface EditorConstructor {
  2716. readonly prototype: Editor;
  2717. new (id: string, options: RawEditorOptions, editorManager: EditorManager): Editor;
  2718. }
  2719. declare class Editor implements EditorObservable {
  2720. documentBaseUrl: string;
  2721. baseUri: URI;
  2722. id: string;
  2723. plugins: Record<string, Plugin>;
  2724. documentBaseURI: URI;
  2725. baseURI: URI;
  2726. contentCSS: string[];
  2727. contentStyles: string[];
  2728. ui: EditorUi;
  2729. mode: EditorMode;
  2730. options: Options;
  2731. editorUpload: EditorUpload;
  2732. shortcuts: Shortcuts;
  2733. loadedCSS: Record<string, any>;
  2734. editorCommands: EditorCommands;
  2735. suffix: string;
  2736. editorManager: EditorManager;
  2737. hidden: boolean;
  2738. inline: boolean;
  2739. hasVisual: boolean;
  2740. isNotDirty: boolean;
  2741. annotator: Annotator;
  2742. bodyElement: HTMLElement | undefined;
  2743. bookmark: any;
  2744. composing: boolean;
  2745. container: HTMLElement;
  2746. contentAreaContainer: HTMLElement;
  2747. contentDocument: Document;
  2748. contentWindow: Window;
  2749. delegates: Record<string, EventUtilsCallback<any>> | undefined;
  2750. destroyed: boolean;
  2751. dom: DOMUtils;
  2752. editorContainer: HTMLElement;
  2753. eventRoot: Element | undefined;
  2754. formatter: Formatter;
  2755. formElement: HTMLElement | undefined;
  2756. formEventDelegate: ((e: Event) => void) | undefined;
  2757. hasHiddenInput: boolean;
  2758. iframeElement: HTMLIFrameElement | null;
  2759. iframeHTML: string | undefined;
  2760. initialized: boolean;
  2761. notificationManager: NotificationManager;
  2762. orgDisplay: string;
  2763. orgVisibility: string | undefined;
  2764. parser: DomParser;
  2765. quirks: Quirks;
  2766. readonly: boolean;
  2767. removed: boolean;
  2768. schema: Schema;
  2769. selection: EditorSelection;
  2770. serializer: DomSerializer;
  2771. startContent: string;
  2772. targetElm: HTMLElement;
  2773. theme: Theme;
  2774. model: Model;
  2775. undoManager: UndoManager;
  2776. windowManager: WindowManager;
  2777. _beforeUnload: (() => void) | undefined;
  2778. _eventDispatcher: EventDispatcher<NativeEventMap> | undefined;
  2779. _nodeChangeDispatcher: NodeChange;
  2780. _pendingNativeEvents: string[];
  2781. _selectionOverrides: SelectionOverrides;
  2782. _skinLoaded: boolean;
  2783. bindPendingEventDelegates: EditorObservable['bindPendingEventDelegates'];
  2784. toggleNativeEvent: EditorObservable['toggleNativeEvent'];
  2785. unbindAllNativeEvents: EditorObservable['unbindAllNativeEvents'];
  2786. fire: EditorObservable['fire'];
  2787. dispatch: EditorObservable['dispatch'];
  2788. on: EditorObservable['on'];
  2789. off: EditorObservable['off'];
  2790. once: EditorObservable['once'];
  2791. hasEventListeners: EditorObservable['hasEventListeners'];
  2792. constructor(id: string, options: RawEditorOptions, editorManager: EditorManager);
  2793. render(): void;
  2794. focus(skipFocus?: boolean): void;
  2795. hasFocus(): boolean;
  2796. translate(text: Untranslated): TranslatedString;
  2797. getParam<K extends BuiltInOptionType>(name: string, defaultVal: BuiltInOptionTypeMap[K], type: K): BuiltInOptionTypeMap[K];
  2798. getParam<K extends keyof NormalizedEditorOptions>(name: K, defaultVal?: NormalizedEditorOptions[K], type?: BuiltInOptionType): NormalizedEditorOptions[K];
  2799. getParam<T>(name: string, defaultVal: T, type?: BuiltInOptionType): T;
  2800. hasPlugin(name: string, loaded?: boolean): boolean;
  2801. nodeChanged(args?: any): void;
  2802. addCommand<S>(name: string, callback: EditorCommandCallback<S>, scope: S): void;
  2803. addCommand(name: string, callback: EditorCommandCallback<Editor>): void;
  2804. addQueryStateHandler<S>(name: string, callback: (this: S) => boolean, scope?: S): void;
  2805. addQueryStateHandler(name: string, callback: (this: Editor) => boolean): void;
  2806. addQueryValueHandler<S>(name: string, callback: (this: S) => string, scope: S): void;
  2807. addQueryValueHandler(name: string, callback: (this: Editor) => string): void;
  2808. addShortcut(pattern: string, desc: string, cmdFunc: string | [
  2809. string,
  2810. boolean,
  2811. any
  2812. ] | (() => void), scope?: any): void;
  2813. execCommand(cmd: string, ui?: boolean, value?: any, args?: ExecCommandArgs): boolean;
  2814. queryCommandState(cmd: string): boolean;
  2815. queryCommandValue(cmd: string): string;
  2816. queryCommandSupported(cmd: string): boolean;
  2817. show(): void;
  2818. hide(): void;
  2819. isHidden(): boolean;
  2820. setProgressState(state: boolean, time?: number): void;
  2821. load(args?: Partial<SetContentArgs>): string;
  2822. save(args?: Partial<GetContentArgs>): string;
  2823. setContent(content: string, args?: Partial<SetContentArgs>): string;
  2824. setContent(content: AstNode, args?: Partial<SetContentArgs>): AstNode;
  2825. setContent(content: Content, args?: Partial<SetContentArgs>): Content;
  2826. getContent(args: {
  2827. format: 'tree';
  2828. } & Partial<GetContentArgs>): AstNode;
  2829. getContent(args?: Partial<GetContentArgs>): string;
  2830. insertContent(content: string, args?: any): void;
  2831. resetContent(initialContent?: string): void;
  2832. isDirty(): boolean;
  2833. setDirty(state: boolean): void;
  2834. getContainer(): HTMLElement;
  2835. getContentAreaContainer(): HTMLElement;
  2836. getElement(): HTMLElement;
  2837. getWin(): Window;
  2838. getDoc(): Document;
  2839. getBody(): HTMLElement;
  2840. convertURL(url: string, name: string, elm?: string | Element): string;
  2841. addVisual(elm?: HTMLElement): void;
  2842. remove(): void;
  2843. destroy(automatic?: boolean): void;
  2844. uploadImages(): Promise<UploadResult$1[]>;
  2845. _scanForImages(): Promise<BlobInfoImagePair[]>;
  2846. }
  2847. interface UrlObject {
  2848. prefix: string;
  2849. resource: string;
  2850. suffix: string;
  2851. }
  2852. declare type WaitState = 'added' | 'loaded';
  2853. declare type AddOnConstructor<T> = (editor: Editor, url: string) => T;
  2854. interface AddOnManager<T> {
  2855. items: AddOnConstructor<T>[];
  2856. urls: Record<string, string>;
  2857. lookup: Record<string, {
  2858. instance: AddOnConstructor<T>;
  2859. }>;
  2860. get: (name: string) => AddOnConstructor<T> | undefined;
  2861. requireLangPack: (name: string, languages?: string) => void;
  2862. add: (id: string, addOn: AddOnConstructor<T>) => AddOnConstructor<T>;
  2863. remove: (name: string) => void;
  2864. createUrl: (baseUrl: UrlObject, dep: string | UrlObject) => UrlObject;
  2865. load: (name: string, addOnUrl: string | UrlObject) => Promise<void>;
  2866. waitFor: (name: string, state?: WaitState) => Promise<void>;
  2867. }
  2868. interface RangeUtils {
  2869. walk: (rng: Range, callback: (nodes: Node[]) => void) => void;
  2870. split: (rng: Range) => RangeLikeObject;
  2871. normalize: (rng: Range) => boolean;
  2872. expand: (rng: Range, options?: {
  2873. type: 'word';
  2874. }) => Range;
  2875. }
  2876. interface ScriptLoaderSettings {
  2877. referrerPolicy?: ReferrerPolicy;
  2878. }
  2879. interface ScriptLoaderConstructor {
  2880. readonly prototype: ScriptLoader;
  2881. new (): ScriptLoader;
  2882. ScriptLoader: ScriptLoader;
  2883. }
  2884. declare class ScriptLoader {
  2885. static ScriptLoader: ScriptLoader;
  2886. private settings;
  2887. private states;
  2888. private queue;
  2889. private scriptLoadedCallbacks;
  2890. private queueLoadedCallbacks;
  2891. private loading;
  2892. constructor(settings?: ScriptLoaderSettings);
  2893. _setReferrerPolicy(referrerPolicy: ReferrerPolicy): void;
  2894. loadScript(url: string): Promise<void>;
  2895. isDone(url: string): boolean;
  2896. markDone(url: string): void;
  2897. add(url: string): Promise<void>;
  2898. load(url: string): Promise<void>;
  2899. remove(url: string): void;
  2900. loadQueue(): Promise<void>;
  2901. loadScripts(scripts: string[]): Promise<void>;
  2902. }
  2903. declare type TextProcessCallback = (node: Text, offset: number, text: string) => number;
  2904. interface Spot {
  2905. container: Text;
  2906. offset: number;
  2907. }
  2908. interface TextSeeker {
  2909. backwards: (node: Node, offset: number, process: TextProcessCallback, root?: Node) => Spot | null;
  2910. forwards: (node: Node, offset: number, process: TextProcessCallback, root?: Node) => Spot | null;
  2911. }
  2912. interface DomTreeWalkerConstructor {
  2913. readonly prototype: DomTreeWalker;
  2914. new (startNode: Node, rootNode: Node): DomTreeWalker;
  2915. }
  2916. declare class DomTreeWalker {
  2917. private readonly rootNode;
  2918. private node;
  2919. constructor(startNode: Node, rootNode: Node);
  2920. current(): Node | null | undefined;
  2921. next(shallow?: boolean): Node | null | undefined;
  2922. prev(shallow?: boolean): Node | null | undefined;
  2923. prev2(shallow?: boolean): Node | null | undefined;
  2924. private findSibling;
  2925. private findPreviousNode;
  2926. }
  2927. interface Version {
  2928. major: number;
  2929. minor: number;
  2930. }
  2931. interface Env {
  2932. transparentSrc: string;
  2933. documentMode: number;
  2934. cacheSuffix: any;
  2935. container: any;
  2936. canHaveCSP: boolean;
  2937. windowsPhone: boolean;
  2938. browser: {
  2939. current: string | undefined;
  2940. version: Version;
  2941. isEdge: () => boolean;
  2942. isChromium: () => boolean;
  2943. isIE: () => boolean;
  2944. isOpera: () => boolean;
  2945. isFirefox: () => boolean;
  2946. isSafari: () => boolean;
  2947. };
  2948. os: {
  2949. current: string | undefined;
  2950. version: Version;
  2951. isWindows: () => boolean;
  2952. isiOS: () => boolean;
  2953. isAndroid: () => boolean;
  2954. isMacOS: () => boolean;
  2955. isLinux: () => boolean;
  2956. isSolaris: () => boolean;
  2957. isFreeBSD: () => boolean;
  2958. isChromeOS: () => boolean;
  2959. };
  2960. deviceType: {
  2961. isiPad: () => boolean;
  2962. isiPhone: () => boolean;
  2963. isTablet: () => boolean;
  2964. isPhone: () => boolean;
  2965. isTouch: () => boolean;
  2966. isWebView: () => boolean;
  2967. isDesktop: () => boolean;
  2968. };
  2969. }
  2970. interface FakeClipboardItem {
  2971. readonly items: Record<string, any>;
  2972. readonly types: ReadonlyArray<string>;
  2973. readonly getType: <D = any>(type: string) => D | undefined;
  2974. }
  2975. interface FakeClipboard {
  2976. readonly FakeClipboardItem: (items: Record<string, any>) => FakeClipboardItem;
  2977. readonly write: (data: FakeClipboardItem[]) => void;
  2978. readonly read: () => FakeClipboardItem[] | undefined;
  2979. readonly clear: () => void;
  2980. }
  2981. interface FocusManager {
  2982. isEditorUIElement: (elm: Element) => boolean;
  2983. }
  2984. interface EntitiesMap {
  2985. [name: string]: string;
  2986. }
  2987. interface Entities {
  2988. encodeRaw: (text: string, attr?: boolean) => string;
  2989. encodeAllRaw: (text: string) => string;
  2990. encodeNumeric: (text: string, attr?: boolean) => string;
  2991. encodeNamed: (text: string, attr?: boolean, entities?: EntitiesMap) => string;
  2992. getEncodeFunc: (name: string, entities?: string) => (text: string, attr?: boolean) => string;
  2993. decode: (text: string) => string;
  2994. }
  2995. interface IconPack {
  2996. icons: Record<string, string>;
  2997. }
  2998. interface IconManager {
  2999. add: (id: string, iconPack: IconPack) => void;
  3000. get: (id: string) => IconPack;
  3001. has: (id: string) => boolean;
  3002. }
  3003. interface Resource {
  3004. load: <T = any>(id: string, url: string) => Promise<T>;
  3005. add: (id: string, data: any) => void;
  3006. unload: (id: string) => void;
  3007. }
  3008. type TextPatterns_d_Pattern = Pattern;
  3009. type TextPatterns_d_RawPattern = RawPattern;
  3010. type TextPatterns_d_DynamicPatternsLookup = DynamicPatternsLookup;
  3011. type TextPatterns_d_RawDynamicPatternsLookup = RawDynamicPatternsLookup;
  3012. type TextPatterns_d_DynamicPatternContext = DynamicPatternContext;
  3013. type TextPatterns_d_BlockCmdPattern = BlockCmdPattern;
  3014. type TextPatterns_d_BlockPattern = BlockPattern;
  3015. type TextPatterns_d_BlockFormatPattern = BlockFormatPattern;
  3016. type TextPatterns_d_InlineCmdPattern = InlineCmdPattern;
  3017. type TextPatterns_d_InlinePattern = InlinePattern;
  3018. type TextPatterns_d_InlineFormatPattern = InlineFormatPattern;
  3019. declare namespace TextPatterns_d {
  3020. export { TextPatterns_d_Pattern as Pattern, TextPatterns_d_RawPattern as RawPattern, TextPatterns_d_DynamicPatternsLookup as DynamicPatternsLookup, TextPatterns_d_RawDynamicPatternsLookup as RawDynamicPatternsLookup, TextPatterns_d_DynamicPatternContext as DynamicPatternContext, TextPatterns_d_BlockCmdPattern as BlockCmdPattern, TextPatterns_d_BlockPattern as BlockPattern, TextPatterns_d_BlockFormatPattern as BlockFormatPattern, TextPatterns_d_InlineCmdPattern as InlineCmdPattern, TextPatterns_d_InlinePattern as InlinePattern, TextPatterns_d_InlineFormatPattern as InlineFormatPattern, };
  3021. }
  3022. interface Delay {
  3023. setEditorInterval: (editor: Editor, callback: () => void, time?: number) => number;
  3024. setEditorTimeout: (editor: Editor, callback: () => void, time?: number) => number;
  3025. }
  3026. declare type UploadResult = UploadResult$2;
  3027. interface ImageUploader {
  3028. upload: (blobInfos: BlobInfo[], showNotification?: boolean) => Promise<UploadResult[]>;
  3029. }
  3030. declare type ArrayCallback$1<T, R> = (this: any, x: T, i: number, xs: ArrayLike<T>) => R;
  3031. declare type ObjCallback$1<T, R> = (this: any, value: T, key: string, obj: Record<string, T>) => R;
  3032. declare type ArrayCallback<T, R> = ArrayCallback$1<T, R>;
  3033. declare type ObjCallback<T, R> = ObjCallback$1<T, R>;
  3034. declare type WalkCallback<T> = (this: any, o: T, i: string, n: keyof T | undefined) => boolean | void;
  3035. interface Tools {
  3036. is: (obj: any, type?: string) => boolean;
  3037. isArray: <T>(arr: any) => arr is Array<T>;
  3038. inArray: <T>(arr: ArrayLike<T>, value: T) => number;
  3039. grep: {
  3040. <T>(arr: ArrayLike<T> | null | undefined, pred?: ArrayCallback<T, boolean>): T[];
  3041. <T>(arr: Record<string, T> | null | undefined, pred?: ObjCallback<T, boolean>): T[];
  3042. };
  3043. trim: (str: string | null | undefined) => string;
  3044. toArray: <T>(obj: ArrayLike<T>) => T[];
  3045. hasOwn: (obj: any, name: string) => boolean;
  3046. makeMap: (items: ArrayLike<string> | string | undefined, delim?: string | RegExp, map?: Record<string, {}>) => Record<string, {}>;
  3047. each: {
  3048. <T>(arr: ArrayLike<T> | null | undefined, cb: ArrayCallback<T, void | boolean>, scope?: any): boolean;
  3049. <T>(obj: Record<string, T> | null | undefined, cb: ObjCallback<T, void | boolean>, scope?: any): boolean;
  3050. };
  3051. map: {
  3052. <T, R>(arr: ArrayLike<T> | null | undefined, cb: ArrayCallback<T, R>): R[];
  3053. <T, R>(obj: Record<string, T> | null | undefined, cb: ObjCallback<T, R>): R[];
  3054. };
  3055. extend: (obj: Object, ext: Object, ...objs: Object[]) => any;
  3056. walk: <T extends Record<string, any>>(obj: T, f: WalkCallback<T>, n?: keyof T, scope?: any) => void;
  3057. resolve: (path: string, o?: Object) => any;
  3058. explode: (s: string | string[], d?: string | RegExp) => string[];
  3059. _addCacheSuffix: (url: string) => string;
  3060. }
  3061. interface KeyboardLikeEvent {
  3062. shiftKey: boolean;
  3063. ctrlKey: boolean;
  3064. altKey: boolean;
  3065. metaKey: boolean;
  3066. }
  3067. interface VK {
  3068. BACKSPACE: number;
  3069. DELETE: number;
  3070. DOWN: number;
  3071. ENTER: number;
  3072. ESC: number;
  3073. LEFT: number;
  3074. RIGHT: number;
  3075. SPACEBAR: number;
  3076. TAB: number;
  3077. UP: number;
  3078. PAGE_UP: number;
  3079. PAGE_DOWN: number;
  3080. END: number;
  3081. HOME: number;
  3082. modifierPressed: (e: KeyboardLikeEvent) => boolean;
  3083. metaKeyPressed: (e: KeyboardLikeEvent) => boolean;
  3084. }
  3085. interface DOMUtilsNamespace {
  3086. (doc: Document, settings: Partial<DOMUtilsSettings>): DOMUtils;
  3087. DOM: DOMUtils;
  3088. nodeIndex: (node: Node, normalized?: boolean) => number;
  3089. }
  3090. interface RangeUtilsNamespace {
  3091. (dom: DOMUtils): RangeUtils;
  3092. compareRanges: (rng1: RangeLikeObject, rng2: RangeLikeObject) => boolean;
  3093. getCaretRangeFromPoint: (clientX: number, clientY: number, doc: Document) => Range;
  3094. getSelectedNode: (range: Range) => Node;
  3095. getNode: (container: Node, offset: number) => Node;
  3096. }
  3097. interface AddOnManagerNamespace {
  3098. <T>(): AddOnManager<T>;
  3099. language: string | undefined;
  3100. languageLoad: boolean;
  3101. baseURL: string;
  3102. PluginManager: PluginManager;
  3103. ThemeManager: ThemeManager;
  3104. ModelManager: ModelManager;
  3105. }
  3106. interface BookmarkManagerNamespace {
  3107. (selection: EditorSelection): BookmarkManager;
  3108. isBookmarkNode: (node: Node) => boolean;
  3109. }
  3110. interface TinyMCE extends EditorManager {
  3111. geom: {
  3112. Rect: Rect;
  3113. };
  3114. util: {
  3115. Delay: Delay;
  3116. Tools: Tools;
  3117. VK: VK;
  3118. URI: URIConstructor;
  3119. EventDispatcher: EventDispatcherConstructor<any>;
  3120. Observable: Observable<any>;
  3121. I18n: I18n;
  3122. LocalStorage: Storage;
  3123. ImageUploader: ImageUploader;
  3124. };
  3125. dom: {
  3126. EventUtils: EventUtilsConstructor;
  3127. TreeWalker: DomTreeWalkerConstructor;
  3128. TextSeeker: (dom: DOMUtils, isBlockBoundary?: (node: Node) => boolean) => TextSeeker;
  3129. DOMUtils: DOMUtilsNamespace;
  3130. ScriptLoader: ScriptLoaderConstructor;
  3131. RangeUtils: RangeUtilsNamespace;
  3132. Serializer: (settings: DomSerializerSettings, editor?: Editor) => DomSerializer;
  3133. ControlSelection: (selection: EditorSelection, editor: Editor) => ControlSelection;
  3134. BookmarkManager: BookmarkManagerNamespace;
  3135. Selection: (dom: DOMUtils, win: Window, serializer: DomSerializer, editor: Editor) => EditorSelection;
  3136. StyleSheetLoader: (documentOrShadowRoot: Document | ShadowRoot, settings: StyleSheetLoaderSettings) => StyleSheetLoader;
  3137. Event: EventUtils;
  3138. };
  3139. html: {
  3140. Styles: (settings?: StylesSettings, schema?: Schema) => Styles;
  3141. Entities: Entities;
  3142. Node: AstNodeConstructor;
  3143. Schema: (settings?: SchemaSettings) => Schema;
  3144. DomParser: (settings?: DomParserSettings, schema?: Schema) => DomParser;
  3145. Writer: (settings?: WriterSettings) => Writer;
  3146. Serializer: (settings?: HtmlSerializerSettings, schema?: Schema) => HtmlSerializer;
  3147. };
  3148. AddOnManager: AddOnManagerNamespace;
  3149. Annotator: (editor: Editor) => Annotator;
  3150. Editor: EditorConstructor;
  3151. EditorCommands: EditorCommandsConstructor;
  3152. EditorManager: EditorManager;
  3153. EditorObservable: EditorObservable;
  3154. Env: Env;
  3155. FocusManager: FocusManager;
  3156. Formatter: (editor: Editor) => Formatter;
  3157. NotificationManager: (editor: Editor) => NotificationManager;
  3158. Shortcuts: ShortcutsConstructor;
  3159. UndoManager: (editor: Editor) => UndoManager;
  3160. WindowManager: (editor: Editor) => WindowManager;
  3161. DOM: DOMUtils;
  3162. ScriptLoader: ScriptLoader;
  3163. PluginManager: PluginManager;
  3164. ThemeManager: ThemeManager;
  3165. ModelManager: ModelManager;
  3166. IconManager: IconManager;
  3167. Resource: Resource;
  3168. FakeClipboard: FakeClipboard;
  3169. trim: Tools['trim'];
  3170. isArray: Tools['isArray'];
  3171. is: Tools['is'];
  3172. toArray: Tools['toArray'];
  3173. makeMap: Tools['makeMap'];
  3174. each: Tools['each'];
  3175. map: Tools['map'];
  3176. grep: Tools['grep'];
  3177. inArray: Tools['inArray'];
  3178. extend: Tools['extend'];
  3179. walk: Tools['walk'];
  3180. resolve: Tools['resolve'];
  3181. explode: Tools['explode'];
  3182. _addCacheSuffix: Tools['_addCacheSuffix'];
  3183. }
  3184. declare const tinymce: TinyMCE;
  3185. export { AddOnManager, Annotator, AstNode, Bookmark, BookmarkManager, ControlSelection, DOMUtils, Delay, DomParser, DomParserSettings, DomSerializer, DomSerializerSettings, DomTreeWalker, Editor, EditorCommands, EditorEvent, EditorManager, EditorModeApi, EditorObservable, EditorOptions, EditorSelection, Entities, Env, EventDispatcher, EventUtils, EventTypes_d as Events, FakeClipboard, FocusManager, Format_d as Formats, Formatter, GeomRect, HtmlSerializer, HtmlSerializerSettings, I18n, IconManager, Model, ModelManager, NotificationApi, NotificationManager, NotificationSpec, Observable, Plugin, PluginManager, RangeUtils, RawEditorOptions, Rect, Resource, Schema, SchemaSettings, ScriptLoader, Shortcuts, StyleSheetLoader, Styles, TextPatterns_d as TextPatterns, TextSeeker, Theme, ThemeManager, TinyMCE, Tools, URI, Ui_d as Ui, UndoManager, VK, WindowManager, Writer, WriterSettings, tinymce as default };