tinymce.d.ts 121 KB

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