@ckeditor/ckeditor5-core 0.0.0-internal-20241017.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (417) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/LICENSE.md +21 -0
  3. package/README.md +24 -0
  4. package/dist/accessibility.d.ts +365 -0
  5. package/dist/augmentation.d.ts +14 -0
  6. package/dist/command.d.ts +193 -0
  7. package/dist/commandcollection.d.ts +87 -0
  8. package/dist/context.d.ts +241 -0
  9. package/dist/contextplugin.d.ts +73 -0
  10. package/dist/editingkeystrokehandler.d.ts +60 -0
  11. package/dist/editor/editor.d.ts +524 -0
  12. package/dist/editor/editorconfig.d.ts +992 -0
  13. package/dist/editor/utils/attachtoform.d.ts +19 -0
  14. package/dist/editor/utils/dataapimixin.d.ts +83 -0
  15. package/dist/editor/utils/editorusagedata.d.ts +62 -0
  16. package/dist/editor/utils/elementapimixin.d.ts +39 -0
  17. package/dist/editor/utils/securesourceelement.d.ts +21 -0
  18. package/dist/index-content.css +4 -0
  19. package/dist/index-editor.css +4 -0
  20. package/dist/index.css +4 -0
  21. package/dist/index.d.ts +94 -0
  22. package/dist/index.js +3027 -0
  23. package/dist/index.js.map +1 -0
  24. package/dist/multicommand.d.ts +70 -0
  25. package/dist/pendingactions.d.ts +126 -0
  26. package/dist/plugin.d.ts +294 -0
  27. package/dist/plugincollection.d.ts +121 -0
  28. package/dist/translations/af.d.ts +8 -0
  29. package/dist/translations/af.js +5 -0
  30. package/dist/translations/af.umd.js +11 -0
  31. package/dist/translations/ar.d.ts +8 -0
  32. package/dist/translations/ar.js +5 -0
  33. package/dist/translations/ar.umd.js +11 -0
  34. package/dist/translations/ast.d.ts +8 -0
  35. package/dist/translations/ast.js +5 -0
  36. package/dist/translations/ast.umd.js +11 -0
  37. package/dist/translations/az.d.ts +8 -0
  38. package/dist/translations/az.js +5 -0
  39. package/dist/translations/az.umd.js +11 -0
  40. package/dist/translations/bg.d.ts +8 -0
  41. package/dist/translations/bg.js +5 -0
  42. package/dist/translations/bg.umd.js +11 -0
  43. package/dist/translations/bn.d.ts +8 -0
  44. package/dist/translations/bn.js +5 -0
  45. package/dist/translations/bn.umd.js +11 -0
  46. package/dist/translations/bs.d.ts +8 -0
  47. package/dist/translations/bs.js +5 -0
  48. package/dist/translations/bs.umd.js +11 -0
  49. package/dist/translations/ca.d.ts +8 -0
  50. package/dist/translations/ca.js +5 -0
  51. package/dist/translations/ca.umd.js +11 -0
  52. package/dist/translations/cs.d.ts +8 -0
  53. package/dist/translations/cs.js +5 -0
  54. package/dist/translations/cs.umd.js +11 -0
  55. package/dist/translations/da.d.ts +8 -0
  56. package/dist/translations/da.js +5 -0
  57. package/dist/translations/da.umd.js +11 -0
  58. package/dist/translations/de-ch.d.ts +8 -0
  59. package/dist/translations/de-ch.js +5 -0
  60. package/dist/translations/de-ch.umd.js +11 -0
  61. package/dist/translations/de.d.ts +8 -0
  62. package/dist/translations/de.js +5 -0
  63. package/dist/translations/de.umd.js +11 -0
  64. package/dist/translations/el.d.ts +8 -0
  65. package/dist/translations/el.js +5 -0
  66. package/dist/translations/el.umd.js +11 -0
  67. package/dist/translations/en-au.d.ts +8 -0
  68. package/dist/translations/en-au.js +5 -0
  69. package/dist/translations/en-au.umd.js +11 -0
  70. package/dist/translations/en-gb.d.ts +8 -0
  71. package/dist/translations/en-gb.js +5 -0
  72. package/dist/translations/en-gb.umd.js +11 -0
  73. package/dist/translations/en.d.ts +8 -0
  74. package/dist/translations/en.js +5 -0
  75. package/dist/translations/en.umd.js +11 -0
  76. package/dist/translations/eo.d.ts +8 -0
  77. package/dist/translations/eo.js +5 -0
  78. package/dist/translations/eo.umd.js +11 -0
  79. package/dist/translations/es-co.d.ts +8 -0
  80. package/dist/translations/es-co.js +5 -0
  81. package/dist/translations/es-co.umd.js +11 -0
  82. package/dist/translations/es.d.ts +8 -0
  83. package/dist/translations/es.js +5 -0
  84. package/dist/translations/es.umd.js +11 -0
  85. package/dist/translations/et.d.ts +8 -0
  86. package/dist/translations/et.js +5 -0
  87. package/dist/translations/et.umd.js +11 -0
  88. package/dist/translations/eu.d.ts +8 -0
  89. package/dist/translations/eu.js +5 -0
  90. package/dist/translations/eu.umd.js +11 -0
  91. package/dist/translations/fa.d.ts +8 -0
  92. package/dist/translations/fa.js +5 -0
  93. package/dist/translations/fa.umd.js +11 -0
  94. package/dist/translations/fi.d.ts +8 -0
  95. package/dist/translations/fi.js +5 -0
  96. package/dist/translations/fi.umd.js +11 -0
  97. package/dist/translations/fr.d.ts +8 -0
  98. package/dist/translations/fr.js +5 -0
  99. package/dist/translations/fr.umd.js +11 -0
  100. package/dist/translations/gl.d.ts +8 -0
  101. package/dist/translations/gl.js +5 -0
  102. package/dist/translations/gl.umd.js +11 -0
  103. package/dist/translations/gu.d.ts +8 -0
  104. package/dist/translations/gu.js +5 -0
  105. package/dist/translations/gu.umd.js +11 -0
  106. package/dist/translations/he.d.ts +8 -0
  107. package/dist/translations/he.js +5 -0
  108. package/dist/translations/he.umd.js +11 -0
  109. package/dist/translations/hi.d.ts +8 -0
  110. package/dist/translations/hi.js +5 -0
  111. package/dist/translations/hi.umd.js +11 -0
  112. package/dist/translations/hr.d.ts +8 -0
  113. package/dist/translations/hr.js +5 -0
  114. package/dist/translations/hr.umd.js +11 -0
  115. package/dist/translations/hu.d.ts +8 -0
  116. package/dist/translations/hu.js +5 -0
  117. package/dist/translations/hu.umd.js +11 -0
  118. package/dist/translations/hy.d.ts +8 -0
  119. package/dist/translations/hy.js +5 -0
  120. package/dist/translations/hy.umd.js +11 -0
  121. package/dist/translations/id.d.ts +8 -0
  122. package/dist/translations/id.js +5 -0
  123. package/dist/translations/id.umd.js +11 -0
  124. package/dist/translations/it.d.ts +8 -0
  125. package/dist/translations/it.js +5 -0
  126. package/dist/translations/it.umd.js +11 -0
  127. package/dist/translations/ja.d.ts +8 -0
  128. package/dist/translations/ja.js +5 -0
  129. package/dist/translations/ja.umd.js +11 -0
  130. package/dist/translations/jv.d.ts +8 -0
  131. package/dist/translations/jv.js +5 -0
  132. package/dist/translations/jv.umd.js +11 -0
  133. package/dist/translations/km.d.ts +8 -0
  134. package/dist/translations/km.js +5 -0
  135. package/dist/translations/km.umd.js +11 -0
  136. package/dist/translations/kn.d.ts +8 -0
  137. package/dist/translations/kn.js +5 -0
  138. package/dist/translations/kn.umd.js +11 -0
  139. package/dist/translations/ko.d.ts +8 -0
  140. package/dist/translations/ko.js +5 -0
  141. package/dist/translations/ko.umd.js +11 -0
  142. package/dist/translations/ku.d.ts +8 -0
  143. package/dist/translations/ku.js +5 -0
  144. package/dist/translations/ku.umd.js +11 -0
  145. package/dist/translations/lt.d.ts +8 -0
  146. package/dist/translations/lt.js +5 -0
  147. package/dist/translations/lt.umd.js +11 -0
  148. package/dist/translations/lv.d.ts +8 -0
  149. package/dist/translations/lv.js +5 -0
  150. package/dist/translations/lv.umd.js +11 -0
  151. package/dist/translations/ms.d.ts +8 -0
  152. package/dist/translations/ms.js +5 -0
  153. package/dist/translations/ms.umd.js +11 -0
  154. package/dist/translations/nb.d.ts +8 -0
  155. package/dist/translations/nb.js +5 -0
  156. package/dist/translations/nb.umd.js +11 -0
  157. package/dist/translations/ne.d.ts +8 -0
  158. package/dist/translations/ne.js +5 -0
  159. package/dist/translations/ne.umd.js +11 -0
  160. package/dist/translations/nl.d.ts +8 -0
  161. package/dist/translations/nl.js +5 -0
  162. package/dist/translations/nl.umd.js +11 -0
  163. package/dist/translations/no.d.ts +8 -0
  164. package/dist/translations/no.js +5 -0
  165. package/dist/translations/no.umd.js +11 -0
  166. package/dist/translations/oc.d.ts +8 -0
  167. package/dist/translations/oc.js +5 -0
  168. package/dist/translations/oc.umd.js +11 -0
  169. package/dist/translations/pl.d.ts +8 -0
  170. package/dist/translations/pl.js +5 -0
  171. package/dist/translations/pl.umd.js +11 -0
  172. package/dist/translations/pt-br.d.ts +8 -0
  173. package/dist/translations/pt-br.js +5 -0
  174. package/dist/translations/pt-br.umd.js +11 -0
  175. package/dist/translations/pt.d.ts +8 -0
  176. package/dist/translations/pt.js +5 -0
  177. package/dist/translations/pt.umd.js +11 -0
  178. package/dist/translations/ro.d.ts +8 -0
  179. package/dist/translations/ro.js +5 -0
  180. package/dist/translations/ro.umd.js +11 -0
  181. package/dist/translations/ru.d.ts +8 -0
  182. package/dist/translations/ru.js +5 -0
  183. package/dist/translations/ru.umd.js +11 -0
  184. package/dist/translations/si.d.ts +8 -0
  185. package/dist/translations/si.js +5 -0
  186. package/dist/translations/si.umd.js +11 -0
  187. package/dist/translations/sk.d.ts +8 -0
  188. package/dist/translations/sk.js +5 -0
  189. package/dist/translations/sk.umd.js +11 -0
  190. package/dist/translations/sl.d.ts +8 -0
  191. package/dist/translations/sl.js +5 -0
  192. package/dist/translations/sl.umd.js +11 -0
  193. package/dist/translations/sq.d.ts +8 -0
  194. package/dist/translations/sq.js +5 -0
  195. package/dist/translations/sq.umd.js +11 -0
  196. package/dist/translations/sr-latn.d.ts +8 -0
  197. package/dist/translations/sr-latn.js +5 -0
  198. package/dist/translations/sr-latn.umd.js +11 -0
  199. package/dist/translations/sr.d.ts +8 -0
  200. package/dist/translations/sr.js +5 -0
  201. package/dist/translations/sr.umd.js +11 -0
  202. package/dist/translations/sv.d.ts +8 -0
  203. package/dist/translations/sv.js +5 -0
  204. package/dist/translations/sv.umd.js +11 -0
  205. package/dist/translations/th.d.ts +8 -0
  206. package/dist/translations/th.js +5 -0
  207. package/dist/translations/th.umd.js +11 -0
  208. package/dist/translations/ti.d.ts +8 -0
  209. package/dist/translations/ti.js +5 -0
  210. package/dist/translations/ti.umd.js +11 -0
  211. package/dist/translations/tk.d.ts +8 -0
  212. package/dist/translations/tk.js +5 -0
  213. package/dist/translations/tk.umd.js +11 -0
  214. package/dist/translations/tr.d.ts +8 -0
  215. package/dist/translations/tr.js +5 -0
  216. package/dist/translations/tr.umd.js +11 -0
  217. package/dist/translations/tt.d.ts +8 -0
  218. package/dist/translations/tt.js +5 -0
  219. package/dist/translations/tt.umd.js +11 -0
  220. package/dist/translations/ug.d.ts +8 -0
  221. package/dist/translations/ug.js +5 -0
  222. package/dist/translations/ug.umd.js +11 -0
  223. package/dist/translations/uk.d.ts +8 -0
  224. package/dist/translations/uk.js +5 -0
  225. package/dist/translations/uk.umd.js +11 -0
  226. package/dist/translations/ur.d.ts +8 -0
  227. package/dist/translations/ur.js +5 -0
  228. package/dist/translations/ur.umd.js +11 -0
  229. package/dist/translations/uz.d.ts +8 -0
  230. package/dist/translations/uz.js +5 -0
  231. package/dist/translations/uz.umd.js +11 -0
  232. package/dist/translations/vi.d.ts +8 -0
  233. package/dist/translations/vi.js +5 -0
  234. package/dist/translations/vi.umd.js +11 -0
  235. package/dist/translations/zh-cn.d.ts +8 -0
  236. package/dist/translations/zh-cn.js +5 -0
  237. package/dist/translations/zh-cn.umd.js +11 -0
  238. package/dist/translations/zh.d.ts +8 -0
  239. package/dist/translations/zh.js +5 -0
  240. package/dist/translations/zh.umd.js +11 -0
  241. package/dist/typings.d.ts +16 -0
  242. package/lang/contexts.json +31 -0
  243. package/lang/translations/af.po +134 -0
  244. package/lang/translations/ar.po +134 -0
  245. package/lang/translations/ast.po +134 -0
  246. package/lang/translations/az.po +134 -0
  247. package/lang/translations/bg.po +134 -0
  248. package/lang/translations/bn.po +134 -0
  249. package/lang/translations/bs.po +134 -0
  250. package/lang/translations/ca.po +134 -0
  251. package/lang/translations/cs.po +134 -0
  252. package/lang/translations/da.po +134 -0
  253. package/lang/translations/de-ch.po +134 -0
  254. package/lang/translations/de.po +134 -0
  255. package/lang/translations/el.po +134 -0
  256. package/lang/translations/en-au.po +134 -0
  257. package/lang/translations/en-gb.po +134 -0
  258. package/lang/translations/en.po +134 -0
  259. package/lang/translations/eo.po +134 -0
  260. package/lang/translations/es-co.po +134 -0
  261. package/lang/translations/es.po +134 -0
  262. package/lang/translations/et.po +134 -0
  263. package/lang/translations/eu.po +134 -0
  264. package/lang/translations/fa.po +134 -0
  265. package/lang/translations/fi.po +134 -0
  266. package/lang/translations/fr.po +134 -0
  267. package/lang/translations/gl.po +134 -0
  268. package/lang/translations/gu.po +134 -0
  269. package/lang/translations/he.po +134 -0
  270. package/lang/translations/hi.po +134 -0
  271. package/lang/translations/hr.po +134 -0
  272. package/lang/translations/hu.po +134 -0
  273. package/lang/translations/hy.po +134 -0
  274. package/lang/translations/id.po +134 -0
  275. package/lang/translations/it.po +134 -0
  276. package/lang/translations/ja.po +134 -0
  277. package/lang/translations/jv.po +134 -0
  278. package/lang/translations/km.po +134 -0
  279. package/lang/translations/kn.po +134 -0
  280. package/lang/translations/ko.po +134 -0
  281. package/lang/translations/ku.po +134 -0
  282. package/lang/translations/lt.po +134 -0
  283. package/lang/translations/lv.po +134 -0
  284. package/lang/translations/ms.po +134 -0
  285. package/lang/translations/nb.po +134 -0
  286. package/lang/translations/ne.po +134 -0
  287. package/lang/translations/nl.po +134 -0
  288. package/lang/translations/no.po +134 -0
  289. package/lang/translations/oc.po +134 -0
  290. package/lang/translations/pl.po +134 -0
  291. package/lang/translations/pt-br.po +134 -0
  292. package/lang/translations/pt.po +134 -0
  293. package/lang/translations/ro.po +134 -0
  294. package/lang/translations/ru.po +134 -0
  295. package/lang/translations/si.po +134 -0
  296. package/lang/translations/sk.po +134 -0
  297. package/lang/translations/sl.po +134 -0
  298. package/lang/translations/sq.po +134 -0
  299. package/lang/translations/sr-latn.po +134 -0
  300. package/lang/translations/sr.po +134 -0
  301. package/lang/translations/sv.po +134 -0
  302. package/lang/translations/th.po +134 -0
  303. package/lang/translations/ti.po +134 -0
  304. package/lang/translations/tk.po +134 -0
  305. package/lang/translations/tr.po +134 -0
  306. package/lang/translations/tt.po +134 -0
  307. package/lang/translations/ug.po +134 -0
  308. package/lang/translations/uk.po +134 -0
  309. package/lang/translations/ur.po +134 -0
  310. package/lang/translations/uz.po +134 -0
  311. package/lang/translations/vi.po +134 -0
  312. package/lang/translations/zh-cn.po +134 -0
  313. package/lang/translations/zh.po +134 -0
  314. package/package.json +51 -0
  315. package/src/accessibility.d.ts +361 -0
  316. package/src/accessibility.js +325 -0
  317. package/src/augmentation.d.ts +10 -0
  318. package/src/augmentation.js +5 -0
  319. package/src/command.d.ts +189 -0
  320. package/src/command.js +185 -0
  321. package/src/commandcollection.d.ts +83 -0
  322. package/src/commandcollection.js +83 -0
  323. package/src/context.d.ts +237 -0
  324. package/src/context.js +229 -0
  325. package/src/contextplugin.d.ts +69 -0
  326. package/src/contextplugin.js +55 -0
  327. package/src/editingkeystrokehandler.d.ts +56 -0
  328. package/src/editingkeystrokehandler.js +57 -0
  329. package/src/editor/editor.d.ts +520 -0
  330. package/src/editor/editor.js +701 -0
  331. package/src/editor/editorconfig.d.ts +988 -0
  332. package/src/editor/editorconfig.js +5 -0
  333. package/src/editor/utils/attachtoform.d.ts +15 -0
  334. package/src/editor/utils/attachtoform.js +57 -0
  335. package/src/editor/utils/dataapimixin.d.ts +79 -0
  336. package/src/editor/utils/dataapimixin.js +12 -0
  337. package/src/editor/utils/editorusagedata.d.ts +58 -0
  338. package/src/editor/utils/editorusagedata.js +120 -0
  339. package/src/editor/utils/elementapimixin.d.ts +35 -0
  340. package/src/editor/utils/elementapimixin.js +43 -0
  341. package/src/editor/utils/securesourceelement.d.ts +17 -0
  342. package/src/editor/utils/securesourceelement.js +35 -0
  343. package/src/index.d.ts +90 -0
  344. package/src/index.js +147 -0
  345. package/src/multicommand.d.ts +66 -0
  346. package/src/multicommand.js +82 -0
  347. package/src/pendingactions.d.ts +122 -0
  348. package/src/pendingactions.js +123 -0
  349. package/src/plugin.d.ts +290 -0
  350. package/src/plugin.js +118 -0
  351. package/src/plugincollection.d.ts +117 -0
  352. package/src/plugincollection.js +473 -0
  353. package/src/typings.d.ts +12 -0
  354. package/src/typings.js +5 -0
  355. package/theme/icons/align-bottom.svg +1 -0
  356. package/theme/icons/align-center.svg +1 -0
  357. package/theme/icons/align-justify.svg +1 -0
  358. package/theme/icons/align-left.svg +1 -0
  359. package/theme/icons/align-middle.svg +1 -0
  360. package/theme/icons/align-right.svg +1 -0
  361. package/theme/icons/align-top.svg +1 -0
  362. package/theme/icons/bold.svg +1 -0
  363. package/theme/icons/browse-files.svg +1 -0
  364. package/theme/icons/bulletedlist.svg +1 -0
  365. package/theme/icons/cancel.svg +1 -0
  366. package/theme/icons/caption.svg +1 -0
  367. package/theme/icons/check.svg +1 -0
  368. package/theme/icons/codeblock.svg +1 -0
  369. package/theme/icons/cog.svg +1 -0
  370. package/theme/icons/color-palette.svg +1 -0
  371. package/theme/icons/drag-indicator.svg +1 -0
  372. package/theme/icons/eraser.svg +1 -0
  373. package/theme/icons/heading1.svg +1 -0
  374. package/theme/icons/heading2.svg +1 -0
  375. package/theme/icons/heading3.svg +1 -0
  376. package/theme/icons/heading4.svg +1 -0
  377. package/theme/icons/heading5.svg +1 -0
  378. package/theme/icons/heading6.svg +1 -0
  379. package/theme/icons/history.svg +1 -0
  380. package/theme/icons/horizontalline.svg +1 -0
  381. package/theme/icons/html.svg +1 -0
  382. package/theme/icons/image-asset-manager.svg +1 -0
  383. package/theme/icons/image-upload.svg +1 -0
  384. package/theme/icons/image-url.svg +1 -0
  385. package/theme/icons/image.svg +1 -0
  386. package/theme/icons/importexport.svg +1 -0
  387. package/theme/icons/indent.svg +1 -0
  388. package/theme/icons/loupe.svg +1 -0
  389. package/theme/icons/low-vision.svg +1 -0
  390. package/theme/icons/next-arrow.svg +1 -0
  391. package/theme/icons/numberedlist.svg +1 -0
  392. package/theme/icons/object-center.svg +1 -0
  393. package/theme/icons/object-full-width.svg +1 -0
  394. package/theme/icons/object-inline-left.svg +1 -0
  395. package/theme/icons/object-inline-right.svg +1 -0
  396. package/theme/icons/object-inline.svg +1 -0
  397. package/theme/icons/object-left.svg +1 -0
  398. package/theme/icons/object-right.svg +1 -0
  399. package/theme/icons/object-size-custom.svg +1 -0
  400. package/theme/icons/object-size-full.svg +1 -0
  401. package/theme/icons/object-size-large.svg +1 -0
  402. package/theme/icons/object-size-medium.svg +1 -0
  403. package/theme/icons/object-size-small.svg +1 -0
  404. package/theme/icons/outdent.svg +1 -0
  405. package/theme/icons/paragraph.svg +1 -0
  406. package/theme/icons/pencil.svg +1 -0
  407. package/theme/icons/pilcrow.svg +1 -0
  408. package/theme/icons/plus.svg +1 -0
  409. package/theme/icons/previous-arrow.svg +1 -0
  410. package/theme/icons/quote.svg +1 -0
  411. package/theme/icons/redo.svg +1 -0
  412. package/theme/icons/table.svg +1 -0
  413. package/theme/icons/text-alternative.svg +1 -0
  414. package/theme/icons/text.svg +1 -0
  415. package/theme/icons/three-vertical-dots.svg +1 -0
  416. package/theme/icons/todolist.svg +1 -0
  417. package/theme/icons/undo.svg +1 -0
@@ -0,0 +1,701 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ /**
6
+ * @module core/editor/editor
7
+ */
8
+ import { set, get } from 'lodash-es';
9
+ import { Config, CKEditorError, ObservableMixin, logError, parseBase64EncodedObject, releaseDate, toArray, uid, crc32 } from '@ckeditor/ckeditor5-utils';
10
+ import { Conversion, DataController, EditingController, Model, StylesProcessor } from '@ckeditor/ckeditor5-engine';
11
+ import { ContextWatchdog, EditorWatchdog } from '@ckeditor/ckeditor5-watchdog';
12
+ import Context from '../context.js';
13
+ import PluginCollection from '../plugincollection.js';
14
+ import CommandCollection from '../commandcollection.js';
15
+ import EditingKeystrokeHandler from '../editingkeystrokehandler.js';
16
+ import Accessibility from '../accessibility.js';
17
+ import { getEditorUsageData } from './utils/editorusagedata.js';
18
+ /**
19
+ * The class representing a basic, generic editor.
20
+ *
21
+ * Check out the list of its subclasses to learn about specific editor implementations.
22
+ *
23
+ * All editor implementations (like {@link module:editor-classic/classiceditor~ClassicEditor} or
24
+ * {@link module:editor-inline/inlineeditor~InlineEditor}) should extend this class. They can add their
25
+ * own methods and properties.
26
+ *
27
+ * When you are implementing a plugin, this editor represents the API
28
+ * which your plugin can expect to get when using its {@link module:core/plugin~Plugin#editor} property.
29
+ *
30
+ * This API should be sufficient in order to implement the "editing" part of your feature
31
+ * (schema definition, conversion, commands, keystrokes, etc.).
32
+ * It does not define the editor UI, which is available only if
33
+ * the specific editor implements also the {@link ~Editor#ui} property
34
+ * (as most editor implementations do).
35
+ */
36
+ class Editor extends /* #__PURE__ */ ObservableMixin() {
37
+ /**
38
+ * A required name of the editor class. The name should reflect the constructor name.
39
+ */
40
+ static get editorName() {
41
+ return 'Editor';
42
+ }
43
+ /**
44
+ * Creates a new instance of the editor class.
45
+ *
46
+ * Usually, not to be used directly. See the static {@link module:core/editor/editor~Editor.create `create()`} method.
47
+ *
48
+ * @param config The editor configuration.
49
+ */
50
+ constructor(config = {}) {
51
+ super();
52
+ if ('sanitizeHtml' in config) {
53
+ /**
54
+ * Configuration property `config.sanitizeHtml` was removed in CKEditor version 43.1.0 and is no longer supported.
55
+ *
56
+ * Please use `config.htmlEmbed.sanitizeHtml` and/or `config.mergeFields.sanitizeHtml` instead.
57
+ *
58
+ * @error editor-config-sanitizehtml-not-supported
59
+ */
60
+ throw new CKEditorError('editor-config-sanitizehtml-not-supported');
61
+ }
62
+ const constructor = this.constructor;
63
+ // We don't pass translations to the config, because its behavior of splitting keys
64
+ // with dots (e.g. `resize.width` => `resize: { width }`) breaks the translations.
65
+ const { translations: defaultTranslations, ...defaultConfig } = constructor.defaultConfig || {};
66
+ const { translations = defaultTranslations, ...rest } = config;
67
+ // Prefer the language passed as the argument to the constructor instead of the constructor's `defaultConfig`, if both are set.
68
+ const language = config.language || defaultConfig.language;
69
+ this._context = config.context || new Context({ language, translations });
70
+ this._context._addEditor(this, !config.context);
71
+ // Clone the plugins to make sure that the plugin array will not be shared
72
+ // between editors and make the watchdog feature work correctly.
73
+ const availablePlugins = Array.from(constructor.builtinPlugins || []);
74
+ this.config = new Config(rest, defaultConfig);
75
+ this.config.define('plugins', availablePlugins);
76
+ this.config.define(this._context._getEditorConfig());
77
+ checkLicenseKeyIsDefined(this.config);
78
+ this.plugins = new PluginCollection(this, availablePlugins, this._context.plugins);
79
+ this.locale = this._context.locale;
80
+ this.t = this.locale.t;
81
+ this._readOnlyLocks = new Set();
82
+ this.commands = new CommandCollection();
83
+ this.set('state', 'initializing');
84
+ this.once('ready', () => (this.state = 'ready'), { priority: 'high' });
85
+ this.once('destroy', () => (this.state = 'destroyed'), { priority: 'high' });
86
+ this.model = new Model();
87
+ this.on('change:isReadOnly', () => {
88
+ this.model.document.isReadOnly = this.isReadOnly;
89
+ });
90
+ const stylesProcessor = new StylesProcessor();
91
+ this.data = new DataController(this.model, stylesProcessor);
92
+ this.editing = new EditingController(this.model, stylesProcessor);
93
+ this.editing.view.document.bind('isReadOnly').to(this);
94
+ this.conversion = new Conversion([this.editing.downcastDispatcher, this.data.downcastDispatcher], this.data.upcastDispatcher);
95
+ this.conversion.addAlias('dataDowncast', this.data.downcastDispatcher);
96
+ this.conversion.addAlias('editingDowncast', this.editing.downcastDispatcher);
97
+ this.keystrokes = new EditingKeystrokeHandler(this);
98
+ this.keystrokes.listenTo(this.editing.view.document);
99
+ this.accessibility = new Accessibility(this);
100
+ verifyLicenseKey(this);
101
+ // Checks if the license key is defined and throws an error if it is not.
102
+ function checkLicenseKeyIsDefined(config) {
103
+ let licenseKey = config.get('licenseKey');
104
+ if (!licenseKey && window.CKEDITOR_GLOBAL_LICENSE_KEY) {
105
+ licenseKey = window.CKEDITOR_GLOBAL_LICENSE_KEY;
106
+ config.set('licenseKey', licenseKey);
107
+ }
108
+ if (!licenseKey) {
109
+ /**
110
+ * The `licenseKey` is missing in the editor configuration. If you use premium features,
111
+ * please provide your license key. If you do not have a key yet, please contact us at
112
+ * [https://ckeditor.com/contact/](https://ckeditor.com/contact/) or order a trial at
113
+ * [https://orders.ckeditor.com/trial/premium-features](https://orders.ckeditor.com/trial/premium-features).
114
+ *
115
+ * If you do not use premium features, add the `'GPL'` license key instead.
116
+ *
117
+ * ```js
118
+ * Editor.create( document.querySelector( '#editor' ), {
119
+ * licenseKey: '<YOUR_LICENSE_KEY>', // Or 'GPL'.
120
+ * } );
121
+ * ```
122
+ *
123
+ * @error editor-license-key-missing
124
+ */
125
+ throw new CKEditorError('editor-license-key-missing');
126
+ }
127
+ }
128
+ function verifyLicenseKey(editor) {
129
+ const licenseKey = editor.config.get('licenseKey');
130
+ const distributionChannel = window[Symbol.for('cke distribution')] || 'sh';
131
+ if (licenseKey == 'GPL') {
132
+ if (distributionChannel == 'cloud') {
133
+ blockEditor('distributionChannel');
134
+ }
135
+ return;
136
+ }
137
+ const encodedPayload = getPayload(licenseKey);
138
+ if (!encodedPayload) {
139
+ blockEditor('invalid');
140
+ return;
141
+ }
142
+ const licensePayload = parseBase64EncodedObject(encodedPayload);
143
+ if (!licensePayload) {
144
+ blockEditor('invalid');
145
+ return;
146
+ }
147
+ if (!hasAllRequiredFields(licensePayload)) {
148
+ blockEditor('invalid');
149
+ return;
150
+ }
151
+ if (licensePayload.distributionChannel && !toArray(licensePayload.distributionChannel).includes(distributionChannel)) {
152
+ blockEditor('distributionChannel');
153
+ return;
154
+ }
155
+ if (crc32(getCrcInputData(licensePayload)) != licensePayload.vc.toLowerCase()) {
156
+ blockEditor('invalid');
157
+ return;
158
+ }
159
+ const expirationDate = new Date(licensePayload.exp * 1000);
160
+ if (expirationDate < releaseDate) {
161
+ blockEditor('expired');
162
+ return;
163
+ }
164
+ const licensedHosts = licensePayload.licensedHosts;
165
+ if (licensedHosts && licensedHosts.length > 0 && !checkLicensedHosts(licensedHosts)) {
166
+ blockEditor('domainLimit');
167
+ return;
168
+ }
169
+ if (['evaluation', 'trial'].includes(licensePayload.licenseType) && licensePayload.exp * 1000 < Date.now()) {
170
+ blockEditor('expired');
171
+ return;
172
+ }
173
+ if (['evaluation', 'trial', 'development'].includes(licensePayload.licenseType)) {
174
+ const licenseType = licensePayload.licenseType;
175
+ console.info(`You are using the ${licenseType} version of CKEditor 5 with limited usage. ` +
176
+ 'Make sure you will not use it in the production environment.');
177
+ const timerId = setTimeout(() => {
178
+ blockEditor(`${licenseType}Limit`);
179
+ }, 600000);
180
+ editor.on('destroy', () => {
181
+ clearTimeout(timerId);
182
+ });
183
+ }
184
+ if (licensePayload.usageEndpoint) {
185
+ editor.once('ready', () => {
186
+ const request = {
187
+ requestId: uid(),
188
+ requestTime: Math.round(Date.now() / 1000),
189
+ license: licenseKey,
190
+ editor: collectUsageData(editor)
191
+ };
192
+ editor._sendUsageRequest(licensePayload.usageEndpoint, request).then(response => {
193
+ const { status, message } = response;
194
+ if (message) {
195
+ console.warn(message);
196
+ }
197
+ if (status != 'ok') {
198
+ blockEditor('usageLimit');
199
+ }
200
+ }, () => {
201
+ /**
202
+ * Your license key cannot be validated because of a network issue.
203
+ * Please make sure that your setup does not block the request.
204
+ *
205
+ * @error license-key-validation-endpoint-not-reachable
206
+ * @param {String} url The URL that was attempted to reach.
207
+ */
208
+ logError('license-key-validation-endpoint-not-reachable', { url: licensePayload.usageEndpoint });
209
+ });
210
+ }, { priority: 'high' });
211
+ }
212
+ function getPayload(licenseKey) {
213
+ const parts = licenseKey.split('.');
214
+ if (parts.length != 3) {
215
+ return null;
216
+ }
217
+ return parts[1];
218
+ }
219
+ function blockEditor(reason) {
220
+ editor.enableReadOnlyMode(Symbol('invalidLicense'));
221
+ editor._showLicenseError(reason);
222
+ }
223
+ function hasAllRequiredFields(licensePayload) {
224
+ const requiredFields = ['exp', 'jti', 'vc'];
225
+ return requiredFields.every(field => field in licensePayload);
226
+ }
227
+ function getCrcInputData(licensePayload) {
228
+ const keysToCheck = Object.getOwnPropertyNames(licensePayload).sort();
229
+ const filteredValues = keysToCheck
230
+ .filter(key => key != 'vc' && licensePayload[key] != null)
231
+ .map(key => licensePayload[key]);
232
+ return filteredValues;
233
+ }
234
+ function checkLicensedHosts(licensedHosts) {
235
+ const { hostname } = new URL(window.location.href);
236
+ if (licensedHosts.includes(hostname)) {
237
+ return true;
238
+ }
239
+ const segments = hostname.split('.');
240
+ return licensedHosts
241
+ .filter(host => host.includes('*'))
242
+ .map(host => host.split('.'))
243
+ .some(octets => segments.every((segment, index) => octets[index] === segment || octets[index] === '*'));
244
+ }
245
+ }
246
+ }
247
+ /**
248
+ * Defines whether the editor is in the read-only mode.
249
+ *
250
+ * In read-only mode the editor {@link #commands commands} are disabled so it is not possible
251
+ * to modify the document by using them. Also, the editable element(s) become non-editable.
252
+ *
253
+ * In order to make the editor read-only, you need to call the {@link #enableReadOnlyMode} method:
254
+ *
255
+ * ```ts
256
+ * editor.enableReadOnlyMode( 'feature-id' );
257
+ * ```
258
+ *
259
+ * Later, to turn off the read-only mode, call {@link #disableReadOnlyMode}:
260
+ *
261
+ * ```ts
262
+ * editor.disableReadOnlyMode( 'feature-id' );
263
+ * ```
264
+ *
265
+ * @readonly
266
+ * @observable
267
+ */
268
+ get isReadOnly() {
269
+ return this._readOnlyLocks.size > 0;
270
+ }
271
+ set isReadOnly(value) {
272
+ /**
273
+ * The {@link module:core/editor/editor~Editor#isReadOnly Editor#isReadOnly} property is read-only since version `34.0.0`
274
+ * and can be set only using {@link module:core/editor/editor~Editor#enableReadOnlyMode `Editor#enableReadOnlyMode( lockId )`} and
275
+ * {@link module:core/editor/editor~Editor#disableReadOnlyMode `Editor#disableReadOnlyMode( lockId )`}.
276
+ *
277
+ * Usage before version `34.0.0`:
278
+ *
279
+ * ```ts
280
+ * editor.isReadOnly = true;
281
+ * editor.isReadOnly = false;
282
+ * ```
283
+ *
284
+ * Usage since version `34.0.0`:
285
+ *
286
+ * ```ts
287
+ * editor.enableReadOnlyMode( 'my-feature-id' );
288
+ * editor.disableReadOnlyMode( 'my-feature-id' );
289
+ * ```
290
+ *
291
+ * @error editor-isreadonly-has-no-setter
292
+ */
293
+ throw new CKEditorError('editor-isreadonly-has-no-setter');
294
+ }
295
+ /**
296
+ * Turns on the read-only mode in the editor.
297
+ *
298
+ * Editor can be switched to or out of the read-only mode by many features, under various circumstances. The editor supports locking
299
+ * mechanism for the read-only mode. It enables easy control over the read-only mode when many features wants to turn it on or off at
300
+ * the same time, without conflicting with each other. It guarantees that you will not make the editor editable accidentally (which
301
+ * could lead to errors).
302
+ *
303
+ * Each read-only mode request is identified by a unique id (also called "lock"). If multiple plugins requested to turn on the
304
+ * read-only mode, then, the editor will become editable only after all these plugins turn the read-only mode off (using the same ids).
305
+ *
306
+ * Note, that you cannot force the editor to disable the read-only mode if other plugins set it.
307
+ *
308
+ * After the first `enableReadOnlyMode()` call, the {@link #isReadOnly `isReadOnly` property} will be set to `true`:
309
+ *
310
+ * ```ts
311
+ * editor.isReadOnly; // `false`.
312
+ * editor.enableReadOnlyMode( 'my-feature-id' );
313
+ * editor.isReadOnly; // `true`.
314
+ * ```
315
+ *
316
+ * You can turn off the read-only mode ("clear the lock") using the {@link #disableReadOnlyMode `disableReadOnlyMode()`} method:
317
+ *
318
+ * ```ts
319
+ * editor.enableReadOnlyMode( 'my-feature-id' );
320
+ * // ...
321
+ * editor.disableReadOnlyMode( 'my-feature-id' );
322
+ * editor.isReadOnly; // `false`.
323
+ * ```
324
+ *
325
+ * All "locks" need to be removed to enable editing:
326
+ *
327
+ * ```ts
328
+ * editor.enableReadOnlyMode( 'my-feature-id' );
329
+ * editor.enableReadOnlyMode( 'my-other-feature-id' );
330
+ * // ...
331
+ * editor.disableReadOnlyMode( 'my-feature-id' );
332
+ * editor.isReadOnly; // `true`.
333
+ * editor.disableReadOnlyMode( 'my-other-feature-id' );
334
+ * editor.isReadOnly; // `false`.
335
+ * ```
336
+ *
337
+ * @param lockId A unique ID for setting the editor to the read-only state.
338
+ */
339
+ enableReadOnlyMode(lockId) {
340
+ if (typeof lockId !== 'string' && typeof lockId !== 'symbol') {
341
+ /**
342
+ * The lock ID is missing or it is not a string or symbol.
343
+ *
344
+ * @error editor-read-only-lock-id-invalid
345
+ */
346
+ throw new CKEditorError('editor-read-only-lock-id-invalid', null, { lockId });
347
+ }
348
+ if (this._readOnlyLocks.has(lockId)) {
349
+ return;
350
+ }
351
+ this._readOnlyLocks.add(lockId);
352
+ if (this._readOnlyLocks.size === 1) {
353
+ // Manually fire the `change:isReadOnly` event as only getter is provided.
354
+ this.fire('change:isReadOnly', 'isReadOnly', true, false);
355
+ }
356
+ }
357
+ /**
358
+ * Removes the read-only lock from the editor with given lock ID.
359
+ *
360
+ * When no lock is present on the editor anymore, then the {@link #isReadOnly `isReadOnly` property} will be set to `false`.
361
+ *
362
+ * @param lockId The lock ID for setting the editor to the read-only state.
363
+ */
364
+ disableReadOnlyMode(lockId) {
365
+ if (typeof lockId !== 'string' && typeof lockId !== 'symbol') {
366
+ throw new CKEditorError('editor-read-only-lock-id-invalid', null, { lockId });
367
+ }
368
+ if (!this._readOnlyLocks.has(lockId)) {
369
+ return;
370
+ }
371
+ this._readOnlyLocks.delete(lockId);
372
+ if (this._readOnlyLocks.size === 0) {
373
+ // Manually fire the `change:isReadOnly` event as only getter is provided.
374
+ this.fire('change:isReadOnly', 'isReadOnly', false, true);
375
+ }
376
+ }
377
+ /**
378
+ * Sets the data in the editor.
379
+ *
380
+ * ```ts
381
+ * editor.setData( '<p>This is editor!</p>' );
382
+ * ```
383
+ *
384
+ * If your editor implementation uses multiple roots, you should pass an object with keys corresponding
385
+ * to the editor root names and values equal to the data that should be set in each root:
386
+ *
387
+ * ```ts
388
+ * editor.setData( {
389
+ * header: '<p>Content for header part.</p>',
390
+ * content: '<p>Content for main part.</p>',
391
+ * footer: '<p>Content for footer part.</p>'
392
+ * } );
393
+ * ```
394
+ *
395
+ * By default the editor accepts HTML. This can be controlled by injecting a different data processor.
396
+ * See the {@glink features/markdown Markdown output} guide for more details.
397
+ *
398
+ * @param data Input data.
399
+ */
400
+ setData(data) {
401
+ this.data.set(data);
402
+ }
403
+ /**
404
+ * Gets the data from the editor.
405
+ *
406
+ * ```ts
407
+ * editor.getData(); // -> '<p>This is editor!</p>'
408
+ * ```
409
+ *
410
+ * If your editor implementation uses multiple roots, you should pass root name as one of the options:
411
+ *
412
+ * ```ts
413
+ * editor.getData( { rootName: 'header' } ); // -> '<p>Content for header part.</p>'
414
+ * ```
415
+ *
416
+ * By default, the editor outputs HTML. This can be controlled by injecting a different data processor.
417
+ * See the {@glink features/markdown Markdown output} guide for more details.
418
+ *
419
+ * A warning is logged when you try to retrieve data for a detached root, as most probably this is a mistake. A detached root should
420
+ * be treated like it is removed, and you should not save its data. Note, that the detached root data is always an empty string.
421
+ *
422
+ * @param options Additional configuration for the retrieved data.
423
+ * Editor features may introduce more configuration options that can be set through this parameter.
424
+ * @param options.rootName Root name. Defaults to `'main'`.
425
+ * @param options.trim Whether returned data should be trimmed. This option is set to `'empty'` by default,
426
+ * which means that whenever editor content is considered empty, an empty string is returned. To turn off trimming
427
+ * use `'none'`. In such cases exact content will be returned (for example `'<p>&nbsp;</p>'` for an empty editor).
428
+ * @returns Output data.
429
+ */
430
+ getData(options) {
431
+ return this.data.get(options);
432
+ }
433
+ /**
434
+ * Loads and initializes plugins specified in the configuration.
435
+ *
436
+ * @returns A promise which resolves once the initialization is completed, providing an array of loaded plugins.
437
+ */
438
+ initPlugins() {
439
+ const config = this.config;
440
+ const plugins = config.get('plugins');
441
+ const removePlugins = config.get('removePlugins') || [];
442
+ const extraPlugins = config.get('extraPlugins') || [];
443
+ const substitutePlugins = config.get('substitutePlugins') || [];
444
+ return this.plugins.init(plugins.concat(extraPlugins), removePlugins, substitutePlugins);
445
+ }
446
+ /**
447
+ * Destroys the editor instance, releasing all resources used by it.
448
+ *
449
+ * **Note** The editor cannot be destroyed during the initialization phase so if it is called
450
+ * while the editor {@link #state is being initialized}, it will wait for the editor initialization before destroying it.
451
+ *
452
+ * @fires destroy
453
+ * @returns A promise that resolves once the editor instance is fully destroyed.
454
+ */
455
+ destroy() {
456
+ let readyPromise = Promise.resolve();
457
+ if (this.state == 'initializing') {
458
+ readyPromise = new Promise(resolve => this.once('ready', resolve));
459
+ }
460
+ return readyPromise
461
+ .then(() => {
462
+ this.fire('destroy');
463
+ this.stopListening();
464
+ this.commands.destroy();
465
+ })
466
+ .then(() => this.plugins.destroy())
467
+ .then(() => {
468
+ this.model.destroy();
469
+ this.data.destroy();
470
+ this.editing.destroy();
471
+ this.keystrokes.destroy();
472
+ })
473
+ // Remove the editor from the context.
474
+ // When the context was created by this editor, the context will be destroyed.
475
+ .then(() => this._context._removeEditor(this));
476
+ }
477
+ /**
478
+ * Executes the specified command with given parameters.
479
+ *
480
+ * Shorthand for:
481
+ *
482
+ * ```ts
483
+ * editor.commands.get( commandName ).execute( ... );
484
+ * ```
485
+ *
486
+ * @param commandName The name of the command to execute.
487
+ * @param commandParams Command parameters.
488
+ * @returns The value returned by the {@link module:core/commandcollection~CommandCollection#execute `commands.execute()`}.
489
+ */
490
+ execute(commandName, ...commandParams) {
491
+ try {
492
+ return this.commands.execute(commandName, ...commandParams);
493
+ }
494
+ catch (err) {
495
+ // @if CK_DEBUG // throw err;
496
+ /* istanbul ignore next -- @preserve */
497
+ CKEditorError.rethrowUnexpectedError(err, this);
498
+ }
499
+ }
500
+ /**
501
+ * Focuses the editor.
502
+ *
503
+ * **Note** To explicitly focus the editing area of the editor, use the
504
+ * {@link module:engine/view/view~View#focus `editor.editing.view.focus()`} method of the editing view.
505
+ *
506
+ * Check out the {@glink framework/deep-dive/ui/focus-tracking#focus-in-the-editor-ui Focus in the editor UI} section
507
+ * of the {@glink framework/deep-dive/ui/focus-tracking Deep dive into focus tracking} guide to learn more.
508
+ */
509
+ focus() {
510
+ this.editing.view.focus();
511
+ }
512
+ /* istanbul ignore next -- @preserve */
513
+ /**
514
+ * Creates and initializes a new editor instance.
515
+ *
516
+ * This is an abstract method. Every editor type needs to implement its own initialization logic.
517
+ *
518
+ * See the `create()` methods of the existing editor types to learn how to use them:
519
+ *
520
+ * * {@link module:editor-classic/classiceditor~ClassicEditor.create `ClassicEditor.create()`}
521
+ * * {@link module:editor-balloon/ballooneditor~BalloonEditor.create `BalloonEditor.create()`}
522
+ * * {@link module:editor-decoupled/decouplededitor~DecoupledEditor.create `DecoupledEditor.create()`}
523
+ * * {@link module:editor-inline/inlineeditor~InlineEditor.create `InlineEditor.create()`}
524
+ */
525
+ static create(...args) {
526
+ throw new Error('This is an abstract method.');
527
+ }
528
+ _showLicenseError(reason, pluginName) {
529
+ setTimeout(() => {
530
+ if (reason == 'invalid') {
531
+ /**
532
+ * Invalid license key. Please contact our customer support at
533
+ * [https://ckeditor.com/contact/](https://ckeditor.com/contact/).
534
+ *
535
+ * @error invalid-license-key
536
+ */
537
+ throw new CKEditorError('invalid-license-key', this);
538
+ }
539
+ if (reason == 'expired') {
540
+ /**
541
+ * Your license key has expired. Please renew your license at
542
+ * [https://portal.ckeditor.com/](https://portal.ckeditor.com/).
543
+ *
544
+ * @error license-key-expired
545
+ */
546
+ throw new CKEditorError('license-key-expired', this);
547
+ }
548
+ if (reason == 'domainLimit') {
549
+ /**
550
+ * The hostname is not allowed by your license. Please update your license configuration at
551
+ * [https://portal.ckeditor.com/](https://portal.ckeditor.com/).
552
+ *
553
+ * @error license-key-domain-limit
554
+ */
555
+ throw new CKEditorError('license-key-domain-limit', this);
556
+ }
557
+ if (reason == 'featureNotAllowed') {
558
+ /**
559
+ * The plugin is not allowed by your license.
560
+ *
561
+ * Please check your license or contact support at
562
+ * [https://ckeditor.com/contact/](https://ckeditor.com/contact/)
563
+ * for more information.
564
+ *
565
+ * @error license-key-feature-not-allowed
566
+ * @param {String} pluginName
567
+ */
568
+ throw new CKEditorError('license-key-feature-not-allowed', this, { pluginName });
569
+ }
570
+ if (reason == 'evaluationLimit') {
571
+ /**
572
+ * You have reached the usage limit of your evaluation license key. Restart the editor.
573
+ *
574
+ * Please contact our customer support to get full access at
575
+ * [https://ckeditor.com/contact/](https://ckeditor.com/contact/).
576
+ *
577
+ * @error license-key-evaluation-limit
578
+ */
579
+ throw new CKEditorError('license-key-evaluation-limit', this);
580
+ }
581
+ if (reason == 'trialLimit') {
582
+ /**
583
+ * You have reached the usage limit of your trial license key. Restart the editor.
584
+ *
585
+ * Please contact our customer support to get full access at
586
+ * [https://ckeditor.com/contact/](https://ckeditor.com/contact/).
587
+ *
588
+ * @error license-key-trial-limit
589
+ */
590
+ throw new CKEditorError('license-key-trial-limit', this);
591
+ }
592
+ if (reason == 'developmentLimit') {
593
+ /**
594
+ * You have reached the usage limit of your development license key. Restart the editor.
595
+ *
596
+ * Please contact our customer support to get full access at
597
+ * [https://ckeditor.com/contact/](https://ckeditor.com/contact/).
598
+ *
599
+ * @error license-key-development-limit
600
+ */
601
+ throw new CKEditorError('license-key-development-limit', this);
602
+ }
603
+ if (reason == 'usageLimit') {
604
+ /**
605
+ * You have reached the usage limit of your license key.
606
+ *
607
+ * Please contact our customer support to extend the limit at
608
+ * [https://ckeditor.com/contact/](https://ckeditor.com/contact/).
609
+ *
610
+ * @error license-key-usage-limit
611
+ */
612
+ throw new CKEditorError('license-key-usage-limit', this);
613
+ }
614
+ if (reason == 'distributionChannel') {
615
+ /**
616
+ * Your license doesn't allow using the editor in this distribution channel.
617
+ *
618
+ * Having the `'GPL'` license key, you can use the editor installed from npm (self-hosted). If you have
619
+ * a commercial license, you can use the editor from CDN or — if your plan allows — from npm.
620
+ *
621
+ * Please check your installation or contact support at [https://ckeditor.com/contact/](https://ckeditor.com/contact/)
622
+ * for more information.
623
+ *
624
+ * @error license-key-distribution-channel
625
+ */
626
+ throw new CKEditorError('license-key-distribution-channel', this);
627
+ }
628
+ /* istanbul ignore next -- @preserve */
629
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
630
+ const unreachable = reason;
631
+ }, 0);
632
+ this._showLicenseError = () => { };
633
+ }
634
+ async _sendUsageRequest(endpoint, request) {
635
+ const headers = new Headers({ 'Content-Type': 'application/json' });
636
+ const response = await fetch(new URL(endpoint), {
637
+ method: 'POST',
638
+ headers,
639
+ body: JSON.stringify(request)
640
+ });
641
+ if (!response.ok) {
642
+ // TODO: refine message.
643
+ throw new Error(`HTTP Response: ${response.status}`);
644
+ }
645
+ return response.json();
646
+ }
647
+ }
648
+ /**
649
+ * The {@link module:core/context~Context} class.
650
+ *
651
+ * Exposed as static editor field for easier access in editor builds.
652
+ */
653
+ Editor.Context = Context;
654
+ /**
655
+ * The {@link module:watchdog/editorwatchdog~EditorWatchdog} class.
656
+ *
657
+ * Exposed as static editor field for easier access in editor builds.
658
+ */
659
+ Editor.EditorWatchdog = EditorWatchdog;
660
+ /**
661
+ * The {@link module:watchdog/contextwatchdog~ContextWatchdog} class.
662
+ *
663
+ * Exposed as static editor field for easier access in editor builds.
664
+ */
665
+ Editor.ContextWatchdog = ContextWatchdog;
666
+ export default Editor;
667
+ function collectUsageData(editor) {
668
+ const collectedData = getEditorUsageData(editor);
669
+ function setUsageData(path, value) {
670
+ if (get(collectedData, path) !== undefined) {
671
+ /**
672
+ * The error thrown when trying to set the usage data path that was already set.
673
+ * Make sure that you are not setting the same path multiple times.
674
+ *
675
+ * @error editor-usage-data-path-already-set
676
+ */
677
+ throw new CKEditorError('editor-usage-data-path-already-set', { path });
678
+ }
679
+ set(collectedData, path, value);
680
+ }
681
+ editor.fire('collectUsageData', {
682
+ setUsageData
683
+ });
684
+ return collectedData;
685
+ }
686
+ /**
687
+ * This error is thrown when trying to pass a `<textarea>` element to a `create()` function of an editor class.
688
+ *
689
+ * The only editor type which can be initialized on `<textarea>` elements is
690
+ * the {@glink getting-started/setup/editor-types#classic-editor classic editor}.
691
+ * This editor hides the passed element and inserts its own UI next to it. Other types of editors reuse the passed element as their root
692
+ * editable element and therefore `<textarea>` is not appropriate for them. Use a `<div>` or another text container instead:
693
+ *
694
+ * ```html
695
+ * <div id="editor">
696
+ * <p>Initial content.</p>
697
+ * </div>
698
+ * ```
699
+ *
700
+ * @error editor-wrong-element
701
+ */