texditor 2.0.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 (330) hide show
  1. package/LICENSE.md +9 -0
  2. package/README.md +232 -0
  3. package/dist/core/base/base-model.d.ts +160 -0
  4. package/dist/core/base/base-model.d.ts.map +1 -0
  5. package/dist/core/base/event-manager.d.ts +20 -0
  6. package/dist/core/base/event-manager.d.ts.map +1 -0
  7. package/dist/core/base/index.d.ts +3 -0
  8. package/dist/core/base/index.d.ts.map +1 -0
  9. package/dist/core/base.d.ts +2 -0
  10. package/dist/core/base.mjs +1 -0
  11. package/dist/core/block-manager.d.ts +91 -0
  12. package/dist/core/block-manager.d.ts.map +1 -0
  13. package/dist/core/commands.d.ts +73 -0
  14. package/dist/core/commands.d.ts.map +1 -0
  15. package/dist/core/config.d.ts +11 -0
  16. package/dist/core/config.d.ts.map +1 -0
  17. package/dist/core/events.d.ts +121 -0
  18. package/dist/core/events.d.ts.map +1 -0
  19. package/dist/core/extensions.d.ts +23 -0
  20. package/dist/core/extensions.d.ts.map +1 -0
  21. package/dist/core/history-manager.d.ts +76 -0
  22. package/dist/core/history-manager.d.ts.map +1 -0
  23. package/dist/core/i18n.d.ts +29 -0
  24. package/dist/core/i18n.d.ts.map +1 -0
  25. package/dist/core/models/action-model.d.ts +54 -0
  26. package/dist/core/models/action-model.d.ts.map +1 -0
  27. package/dist/core/models/block-model.d.ts +396 -0
  28. package/dist/core/models/block-model.d.ts.map +1 -0
  29. package/dist/core/models/extension-model.d.ts +25 -0
  30. package/dist/core/models/extension-model.d.ts.map +1 -0
  31. package/dist/core/models/file-action-model.d.ts +20 -0
  32. package/dist/core/models/file-action-model.d.ts.map +1 -0
  33. package/dist/core/models/index.d.ts +7 -0
  34. package/dist/core/models/index.d.ts.map +1 -0
  35. package/dist/core/models/tool-model.d.ts +69 -0
  36. package/dist/core/models/tool-model.d.ts.map +1 -0
  37. package/dist/core/models.d.ts +2 -0
  38. package/dist/core/models.mjs +6 -0
  39. package/dist/core/security/sanitizer.d.ts +65 -0
  40. package/dist/core/security/sanitizer.d.ts.map +1 -0
  41. package/dist/core/selection-api.d.ts +52 -0
  42. package/dist/core/selection-api.d.ts.map +1 -0
  43. package/dist/core/tools.d.ts +27 -0
  44. package/dist/core/tools.d.ts.map +1 -0
  45. package/dist/core/ui/slider.d.ts +50 -0
  46. package/dist/core/ui/slider.d.ts.map +1 -0
  47. package/dist/core/ui/toasts.d.ts +23 -0
  48. package/dist/core/ui/toasts.d.ts.map +1 -0
  49. package/dist/core/ui/virtual-selection.d.ts +171 -0
  50. package/dist/core/ui/virtual-selection.d.ts.map +1 -0
  51. package/dist/entities/actions/convert-action.d.ts +9 -0
  52. package/dist/entities/actions/convert-action.d.ts.map +1 -0
  53. package/dist/entities/actions/create-action.d.ts +8 -0
  54. package/dist/entities/actions/create-action.d.ts.map +1 -0
  55. package/dist/entities/actions/delete-action.d.ts +8 -0
  56. package/dist/entities/actions/delete-action.d.ts.map +1 -0
  57. package/dist/entities/actions/index.d.ts +7 -0
  58. package/dist/entities/actions/index.d.ts.map +1 -0
  59. package/dist/entities/actions/move-down-action.d.ts +9 -0
  60. package/dist/entities/actions/move-down-action.d.ts.map +1 -0
  61. package/dist/entities/actions/move-up-action.d.ts +9 -0
  62. package/dist/entities/actions/move-up-action.d.ts.map +1 -0
  63. package/dist/entities/actions.d.ts +2 -0
  64. package/dist/entities/actions.mjs +6 -0
  65. package/dist/entities/blocks/code/index.d.ts +48 -0
  66. package/dist/entities/blocks/code/index.d.ts.map +1 -0
  67. package/dist/entities/blocks/code/languages.d.ts +4 -0
  68. package/dist/entities/blocks/code/languages.d.ts.map +1 -0
  69. package/dist/entities/blocks/files/actions/DeleteFileAction.d.ts +7 -0
  70. package/dist/entities/blocks/files/actions/DeleteFileAction.d.ts.map +1 -0
  71. package/dist/entities/blocks/files/actions/DownloadFileAction.d.ts +12 -0
  72. package/dist/entities/blocks/files/actions/DownloadFileAction.d.ts.map +1 -0
  73. package/dist/entities/blocks/files/actions/EditFileAction.d.ts +32 -0
  74. package/dist/entities/blocks/files/actions/EditFileAction.d.ts.map +1 -0
  75. package/dist/entities/blocks/files/actions/MoveLeftFileAction.d.ts +8 -0
  76. package/dist/entities/blocks/files/actions/MoveLeftFileAction.d.ts.map +1 -0
  77. package/dist/entities/blocks/files/actions/MoveRightFileAction.d.ts +8 -0
  78. package/dist/entities/blocks/files/actions/MoveRightFileAction.d.ts.map +1 -0
  79. package/dist/entities/blocks/files/index.d.ts +185 -0
  80. package/dist/entities/blocks/files/index.d.ts.map +1 -0
  81. package/dist/entities/blocks/gallery/index.d.ts +60 -0
  82. package/dist/entities/blocks/gallery/index.d.ts.map +1 -0
  83. package/dist/entities/blocks/header/H1.d.ts +4 -0
  84. package/dist/entities/blocks/header/H1.d.ts.map +1 -0
  85. package/dist/entities/blocks/header/H2.d.ts +6 -0
  86. package/dist/entities/blocks/header/H2.d.ts.map +1 -0
  87. package/dist/entities/blocks/header/H3.d.ts +6 -0
  88. package/dist/entities/blocks/header/H3.d.ts.map +1 -0
  89. package/dist/entities/blocks/header/H4.d.ts +6 -0
  90. package/dist/entities/blocks/header/H4.d.ts.map +1 -0
  91. package/dist/entities/blocks/header/H5.d.ts +6 -0
  92. package/dist/entities/blocks/header/H5.d.ts.map +1 -0
  93. package/dist/entities/blocks/header/H6.d.ts +6 -0
  94. package/dist/entities/blocks/header/H6.d.ts.map +1 -0
  95. package/dist/entities/blocks/header/index.d.ts +6 -0
  96. package/dist/entities/blocks/header/index.d.ts.map +1 -0
  97. package/dist/entities/blocks/index.d.ts +14 -0
  98. package/dist/entities/blocks/index.d.ts.map +1 -0
  99. package/dist/entities/blocks/list/index.d.ts +6 -0
  100. package/dist/entities/blocks/list/index.d.ts.map +1 -0
  101. package/dist/entities/blocks/list/ol.d.ts +6 -0
  102. package/dist/entities/blocks/list/ol.d.ts.map +1 -0
  103. package/dist/entities/blocks/paragraph/index.d.ts +6 -0
  104. package/dist/entities/blocks/paragraph/index.d.ts.map +1 -0
  105. package/dist/entities/blocks.d.ts +2 -0
  106. package/dist/entities/blocks.mjs +13 -0
  107. package/dist/entities/extensions/delete-selected.d.ts +9 -0
  108. package/dist/entities/extensions/delete-selected.d.ts.map +1 -0
  109. package/dist/entities/extensions/index.d.ts +5 -0
  110. package/dist/entities/extensions/index.d.ts.map +1 -0
  111. package/dist/entities/extensions/redo.d.ts +8 -0
  112. package/dist/entities/extensions/redo.d.ts.map +1 -0
  113. package/dist/entities/extensions/undo.d.ts +8 -0
  114. package/dist/entities/extensions/undo.d.ts.map +1 -0
  115. package/dist/entities/extensions.d.ts +2 -0
  116. package/dist/entities/extensions.mjs +4 -0
  117. package/dist/entities/tools/bold.d.ts +6 -0
  118. package/dist/entities/tools/bold.d.ts.map +1 -0
  119. package/dist/entities/tools/clear-formatting.d.ts +7 -0
  120. package/dist/entities/tools/clear-formatting.d.ts.map +1 -0
  121. package/dist/entities/tools/index.d.ts +10 -0
  122. package/dist/entities/tools/index.d.ts.map +1 -0
  123. package/dist/entities/tools/inline-code.d.ts +6 -0
  124. package/dist/entities/tools/inline-code.d.ts.map +1 -0
  125. package/dist/entities/tools/italic.d.ts +6 -0
  126. package/dist/entities/tools/italic.d.ts.map +1 -0
  127. package/dist/entities/tools/link.d.ts +35 -0
  128. package/dist/entities/tools/link.d.ts.map +1 -0
  129. package/dist/entities/tools/marker.d.ts +6 -0
  130. package/dist/entities/tools/marker.d.ts.map +1 -0
  131. package/dist/entities/tools/subscript.d.ts +6 -0
  132. package/dist/entities/tools/subscript.d.ts.map +1 -0
  133. package/dist/entities/tools/superscript.d.ts +6 -0
  134. package/dist/entities/tools/superscript.d.ts.map +1 -0
  135. package/dist/entities/tools.d.ts +2 -0
  136. package/dist/entities/tools.mjs +9 -0
  137. package/dist/icons/index.d.ts +42 -0
  138. package/dist/icons/index.d.ts.map +1 -0
  139. package/dist/locales/en.d.ts +66 -0
  140. package/dist/locales/en.d.ts.map +1 -0
  141. package/dist/locales/index.d.ts +4 -0
  142. package/dist/locales/index.d.ts.map +1 -0
  143. package/dist/locales/ru.d.ts +66 -0
  144. package/dist/locales/ru.d.ts.map +1 -0
  145. package/dist/locales.d.ts +2 -0
  146. package/dist/locales.mjs +3 -0
  147. package/dist/main.d.ts +6 -0
  148. package/dist/node_modules/snappykit/dist/snappykit.mjs +440 -0
  149. package/dist/node_modules/sortum/dist/sortum.mjs +588 -0
  150. package/dist/src/core/base/base-model.mjs +184 -0
  151. package/dist/src/core/base/event-manager.mjs +31 -0
  152. package/dist/src/core/block-manager.mjs +499 -0
  153. package/dist/src/core/commands.mjs +311 -0
  154. package/dist/src/core/config.mjs +12 -0
  155. package/dist/src/core/events.mjs +369 -0
  156. package/dist/src/core/extensions.mjs +48 -0
  157. package/dist/src/core/history-manager.mjs +107 -0
  158. package/dist/src/core/i18n.mjs +25 -0
  159. package/dist/src/core/models/action-model.mjs +72 -0
  160. package/dist/src/core/models/block-model.mjs +619 -0
  161. package/dist/src/core/models/extension-model.mjs +28 -0
  162. package/dist/src/core/models/file-action-model.mjs +24 -0
  163. package/dist/src/core/models/tool-model.mjs +80 -0
  164. package/dist/src/core/security/sanitizer.mjs +130 -0
  165. package/dist/src/core/selection-api.mjs +202 -0
  166. package/dist/src/core/tools.mjs +88 -0
  167. package/dist/src/core/ui/slider.mjs +81 -0
  168. package/dist/src/core/ui/toasts.mjs +55 -0
  169. package/dist/src/core/ui/virtual-selection.mjs +205 -0
  170. package/dist/src/entities/actions/convert-action.mjs +43 -0
  171. package/dist/src/entities/actions/create-action.mjs +39 -0
  172. package/dist/src/entities/actions/delete-action.mjs +19 -0
  173. package/dist/src/entities/actions/move-down-action.mjs +22 -0
  174. package/dist/src/entities/actions/move-up-action.mjs +22 -0
  175. package/dist/src/entities/blocks/code/index.mjs +144 -0
  176. package/dist/src/entities/blocks/code/languages.mjs +54 -0
  177. package/dist/src/entities/blocks/files/actions/DeleteFileAction.mjs +21 -0
  178. package/dist/src/entities/blocks/files/actions/DownloadFileAction.mjs +44 -0
  179. package/dist/src/entities/blocks/files/actions/EditFileAction.mjs +111 -0
  180. package/dist/src/entities/blocks/files/actions/MoveLeftFileAction.mjs +24 -0
  181. package/dist/src/entities/blocks/files/actions/MoveRightFileAction.mjs +24 -0
  182. package/dist/src/entities/blocks/files/index.mjs +424 -0
  183. package/dist/src/entities/blocks/gallery/index.mjs +141 -0
  184. package/dist/src/entities/blocks/header/H1.mjs +5 -0
  185. package/dist/src/entities/blocks/header/H2.mjs +16 -0
  186. package/dist/src/entities/blocks/header/H3.mjs +16 -0
  187. package/dist/src/entities/blocks/header/H4.mjs +16 -0
  188. package/dist/src/entities/blocks/header/H5.mjs +16 -0
  189. package/dist/src/entities/blocks/header/H6.mjs +16 -0
  190. package/dist/src/entities/blocks/header/index.mjs +46 -0
  191. package/dist/src/entities/blocks/list/index.mjs +51 -0
  192. package/dist/src/entities/blocks/list/ol.mjs +16 -0
  193. package/dist/src/entities/blocks/paragraph/index.mjs +46 -0
  194. package/dist/src/entities/extensions/delete-selected.mjs +27 -0
  195. package/dist/src/entities/extensions/redo.mjs +22 -0
  196. package/dist/src/entities/extensions/undo.mjs +22 -0
  197. package/dist/src/entities/tools/bold.mjs +16 -0
  198. package/dist/src/entities/tools/clear-formatting.mjs +20 -0
  199. package/dist/src/entities/tools/inline-code.mjs +19 -0
  200. package/dist/src/entities/tools/italic.mjs +16 -0
  201. package/dist/src/entities/tools/link.mjs +89 -0
  202. package/dist/src/entities/tools/marker.mjs +17 -0
  203. package/dist/src/entities/tools/subscript.mjs +17 -0
  204. package/dist/src/entities/tools/superscript.mjs +18 -0
  205. package/dist/src/icons/index.mjs +4 -0
  206. package/dist/src/locales/en.mjs +68 -0
  207. package/dist/src/locales/ru.mjs +68 -0
  208. package/dist/src/store/currentStore.mjs +8 -0
  209. package/dist/src/store/mainStore.mjs +4 -0
  210. package/dist/src/utils/ajax.mjs +35 -0
  211. package/dist/src/utils/common.mjs +26 -0
  212. package/dist/src/utils/icon.mjs +12 -0
  213. package/dist/src/utils/sanitizer.mjs +20 -0
  214. package/dist/src/views/extensions.mjs +18 -0
  215. package/dist/src/views/main.mjs +19 -0
  216. package/dist/src/views/tools.mjs +9 -0
  217. package/dist/store/currentStore.d.ts +15 -0
  218. package/dist/store/currentStore.d.ts.map +1 -0
  219. package/dist/store/mainStore.d.ts +14 -0
  220. package/dist/store/mainStore.d.ts.map +1 -0
  221. package/dist/styles/animations.css +1 -0
  222. package/dist/styles/core/ui/selection.css +1 -0
  223. package/dist/styles/core/ui/slider.css +1 -0
  224. package/dist/styles/entities/blocks/code.css +1 -0
  225. package/dist/styles/entities/blocks/files.css +1 -0
  226. package/dist/styles/entities/blocks/gallery.css +1 -0
  227. package/dist/styles/entities/blocks/list.css +1 -0
  228. package/dist/styles/entities/blocks/paragraph.css +1 -0
  229. package/dist/styles/entities/tools/inline-code.css +1 -0
  230. package/dist/styles/entities/tools/link.css +1 -0
  231. package/dist/styles/texditor.css +1 -0
  232. package/dist/styles/theme.css +42 -0
  233. package/dist/texditor.d.ts +68 -0
  234. package/dist/texditor.d.ts.map +1 -0
  235. package/dist/texditor.mjs +138 -0
  236. package/dist/types/core/base/base-model.d.ts +212 -0
  237. package/dist/types/core/base/base-model.d.ts.map +1 -0
  238. package/dist/types/core/base/event-manager.d.ts +42 -0
  239. package/dist/types/core/base/event-manager.d.ts.map +1 -0
  240. package/dist/types/core/base/index.d.ts +3 -0
  241. package/dist/types/core/base/index.d.ts.map +1 -0
  242. package/dist/types/core/block-manager.d.ts +223 -0
  243. package/dist/types/core/block-manager.d.ts.map +1 -0
  244. package/dist/types/core/commands.d.ts +93 -0
  245. package/dist/types/core/commands.d.ts.map +1 -0
  246. package/dist/types/core/config.d.ts +86 -0
  247. package/dist/types/core/config.d.ts.map +1 -0
  248. package/dist/types/core/events.d.ts +58 -0
  249. package/dist/types/core/events.d.ts.map +1 -0
  250. package/dist/types/core/extensions.d.ts +19 -0
  251. package/dist/types/core/extensions.d.ts.map +1 -0
  252. package/dist/types/core/history-manager.d.ts +72 -0
  253. package/dist/types/core/history-manager.d.ts.map +1 -0
  254. package/dist/types/core/http/index.d.ts +2 -0
  255. package/dist/types/core/http/index.d.ts.map +1 -0
  256. package/dist/types/core/http/response.d.ts +6 -0
  257. package/dist/types/core/http/response.d.ts.map +1 -0
  258. package/dist/types/core/i18n.d.ts +40 -0
  259. package/dist/types/core/i18n.d.ts.map +1 -0
  260. package/dist/types/core/index.d.ts +15 -0
  261. package/dist/types/core/index.d.ts.map +1 -0
  262. package/dist/types/core/models/action-model.d.ts +46 -0
  263. package/dist/types/core/models/action-model.d.ts.map +1 -0
  264. package/dist/types/core/models/block-model.d.ts +404 -0
  265. package/dist/types/core/models/block-model.d.ts.map +1 -0
  266. package/dist/types/core/models/extension-model.d.ts +41 -0
  267. package/dist/types/core/models/extension-model.d.ts.map +1 -0
  268. package/dist/types/core/models/file-action-model.d.ts +36 -0
  269. package/dist/types/core/models/file-action-model.d.ts.map +1 -0
  270. package/dist/types/core/models/index.d.ts +7 -0
  271. package/dist/types/core/models/index.d.ts.map +1 -0
  272. package/dist/types/core/models/tool-model.d.ts +54 -0
  273. package/dist/types/core/models/tool-model.d.ts.map +1 -0
  274. package/dist/types/core/sanitizer.d.ts +27 -0
  275. package/dist/types/core/sanitizer.d.ts.map +1 -0
  276. package/dist/types/core/selection-api.d.ts +116 -0
  277. package/dist/types/core/selection-api.d.ts.map +1 -0
  278. package/dist/types/core/tools.d.ts +35 -0
  279. package/dist/types/core/tools.d.ts.map +1 -0
  280. package/dist/types/core/ui/index.d.ts +4 -0
  281. package/dist/types/core/ui/index.d.ts.map +1 -0
  282. package/dist/types/core/ui/slider.d.ts +45 -0
  283. package/dist/types/core/ui/slider.d.ts.map +1 -0
  284. package/dist/types/core/ui/toasts.d.ts +58 -0
  285. package/dist/types/core/ui/toasts.d.ts.map +1 -0
  286. package/dist/types/core/ui/virtual-selection.d.ts +83 -0
  287. package/dist/types/core/ui/virtual-selection.d.ts.map +1 -0
  288. package/dist/types/entities/blocks/code.d.ts +4 -0
  289. package/dist/types/entities/blocks/code.d.ts.map +1 -0
  290. package/dist/types/entities/blocks/files.d.ts +170 -0
  291. package/dist/types/entities/blocks/files.d.ts.map +1 -0
  292. package/dist/types/entities/blocks/gallery.d.ts +40 -0
  293. package/dist/types/entities/blocks/gallery.d.ts.map +1 -0
  294. package/dist/types/entities/blocks/header.d.ts +4 -0
  295. package/dist/types/entities/blocks/header.d.ts.map +1 -0
  296. package/dist/types/entities/blocks/index.d.ts +7 -0
  297. package/dist/types/entities/blocks/index.d.ts.map +1 -0
  298. package/dist/types/entities/blocks/list.d.ts +4 -0
  299. package/dist/types/entities/blocks/list.d.ts.map +1 -0
  300. package/dist/types/entities/blocks/paragraph.d.ts +4 -0
  301. package/dist/types/entities/blocks/paragraph.d.ts.map +1 -0
  302. package/dist/types/entities/index.d.ts +2 -0
  303. package/dist/types/entities/index.d.ts.map +1 -0
  304. package/dist/types/index.d.ts +5 -0
  305. package/dist/types/index.d.ts.map +1 -0
  306. package/dist/types/texditor.d.ts +66 -0
  307. package/dist/types/texditor.d.ts.map +1 -0
  308. package/dist/types/utils/ajax.d.ts +31 -0
  309. package/dist/types/utils/ajax.d.ts.map +1 -0
  310. package/dist/types/utils/icon.d.ts +10 -0
  311. package/dist/types/utils/icon.d.ts.map +1 -0
  312. package/dist/types/utils/index.d.ts +3 -0
  313. package/dist/types/utils/index.d.ts.map +1 -0
  314. package/dist/utils/ajax.d.ts +9 -0
  315. package/dist/utils/ajax.d.ts.map +1 -0
  316. package/dist/utils/common.d.ts +28 -0
  317. package/dist/utils/common.d.ts.map +1 -0
  318. package/dist/utils/icon.d.ts +12 -0
  319. package/dist/utils/icon.d.ts.map +1 -0
  320. package/dist/utils/index.d.ts +5 -0
  321. package/dist/utils/index.d.ts.map +1 -0
  322. package/dist/utils/sanitizer.d.ts +8 -0
  323. package/dist/utils/sanitizer.d.ts.map +1 -0
  324. package/dist/views/extensions.d.ts +3 -0
  325. package/dist/views/extensions.d.ts.map +1 -0
  326. package/dist/views/main.d.ts +3 -0
  327. package/dist/views/main.d.ts.map +1 -0
  328. package/dist/views/tools.d.ts +2 -0
  329. package/dist/views/tools.d.ts.map +1 -0
  330. package/package.json +75 -0
@@ -0,0 +1,138 @@
1
+ import { detectMobileOS as e, executeMethodIfExists as t, getCaretPosition as n, getSelectionRect as r } from "./src/utils/common.mjs";
2
+ import { C as i, S as a, j as o, n as s, oe as c, se as l, w as u } from "./node_modules/snappykit/dist/snappykit.mjs";
3
+ import d from "./src/core/events.mjs";
4
+ import { ajax as f } from "./src/utils/ajax.mjs";
5
+ import { renderIcon as p } from "./src/utils/icon.mjs";
6
+ import { sanitizeJson as m } from "./src/utils/sanitizer.mjs";
7
+ import { mainStore as h } from "./src/store/mainStore.mjs";
8
+ import g from "./src/core/block-manager.mjs";
9
+ import _ from "./src/core/config.mjs";
10
+ import v from "./src/core/selection-api.mjs";
11
+ import y from "./src/core/tools.mjs";
12
+ import b from "./src/core/i18n.mjs";
13
+ import x from "./src/core/commands.mjs";
14
+ import S from "./src/core/history-manager.mjs";
15
+ import C from "./src/core/extensions.mjs";
16
+ import w from "./src/views/main.mjs";
17
+ /* empty css */
18
+ /* empty css */
19
+ //#region src/texditor.ts
20
+ var T = class {
21
+ constructor(e) {
22
+ this.config = new _(e), this.i18n = new b(this), this.events = new d(this), this.historyManager = new S(this), this.blockManager = new g(this), this.selectionApi = new v(this), this.tools = new y(this), this.commands = new x(this), this.extensions = new C(this), this.ready();
23
+ }
24
+ ready() {
25
+ this.mount(), this.historyManager.save(), t(this.extensions, "__apply");
26
+ let e = this.config.get("onReady", !1);
27
+ typeof e == "function" && e(this), this.blockManager.detectEmpty(), this.blockManager.normalize(), this.events.refresh();
28
+ }
29
+ getRoot() {
30
+ let e = this.rootElement || null;
31
+ if (!e) throw Error("The root element of the editor was not found.");
32
+ return e;
33
+ }
34
+ getBody() {
35
+ let e = this.getRoot();
36
+ if (!e) return null;
37
+ let [t] = c(".tex", e);
38
+ return t || null;
39
+ }
40
+ isEmpty() {
41
+ let { blockManager: e } = this, t = e.count(), n = e.getModel(0);
42
+ return t === 0 ? !0 : !!(t === 1 && n && n.isEmpty());
43
+ }
44
+ setContent(e, n = 0, r = 0) {
45
+ let { blockManager: i, config: a, events: o } = this, c = i.getBlocksContainer(), d = {
46
+ type: a.get("defaultBlock", "p"),
47
+ data: [""]
48
+ }, f = [d];
49
+ try {
50
+ f = typeof e == "string" ? s(e) ? [] : JSON.parse(m(e.trim()) || "") : e;
51
+ } catch (e) {
52
+ console.warn("The input data is not supported or contains errors when working with JSON", e);
53
+ }
54
+ if (c) {
55
+ l(c, "");
56
+ let e = i.parseBlocks(f), a = n || 0;
57
+ if (!e.length) {
58
+ let t = i.parseBlock(d);
59
+ if (!t) throw Error("The default block model has not been found.");
60
+ e.push(t);
61
+ }
62
+ u(c, e), i.detectEmpty(!1), i.normalize(), e.forEach((e) => {
63
+ t(e.baseModel, "__onMount", [e]);
64
+ }), o.refresh(), n !== -1 && setTimeout(() => {
65
+ i.use(a), i.focus(a);
66
+ }, r || 0), o.change({
67
+ type: "setContent",
68
+ container: c,
69
+ index: a
70
+ });
71
+ }
72
+ }
73
+ getContent() {
74
+ return this.save();
75
+ }
76
+ save() {
77
+ let e = [], { blockManager: n, events: r } = this, i = this.getRoot();
78
+ return r.trigger("save"), i ? (n.getBlocks().forEach((i) => {
79
+ r.trigger("saveEach", { blockElement: i });
80
+ let a = i.baseModel;
81
+ if (a.getName()) {
82
+ let r = o(i, "options"), s = {
83
+ type: a.getName(),
84
+ data: [],
85
+ ...r
86
+ }, c = n.getContentElement(i);
87
+ if (c && a) if (a.isCustomSave()) s = t(a, "__save", [s, i]);
88
+ else if (a.isRaw()) s.data = [c.innerText];
89
+ else {
90
+ let e = n.htmlToData(l(c));
91
+ if (a.isEditableItems() && a.getItemsLength()) {
92
+ let e = 0;
93
+ a.getItems().forEach(() => {
94
+ let t = a.getItemBody(e);
95
+ if (t) {
96
+ let e = n.htmlToData(l(t));
97
+ if (e.length) {
98
+ let t = {
99
+ type: a.getItemName(),
100
+ data: e
101
+ };
102
+ s.data.push(t);
103
+ }
104
+ }
105
+ e++;
106
+ });
107
+ } else s.data = e.filter((e) => typeof e == "string" || typeof e == "object" && !!e);
108
+ }
109
+ s.data.length && e.push(s);
110
+ }
111
+ r.trigger("saveEachEnd", { blockElement: i });
112
+ }), r.trigger("saveEnd"), e) : [];
113
+ }
114
+ destroy() {
115
+ let { blockManager: e, events: t, extensions: n, historyManager: r, tools: i } = this;
116
+ this.rootElement && l(this.rootElement, "");
117
+ let a = h.get("editors");
118
+ h.set("editors", a.filter((e) => e != this.rootElement)), e.destroy(), t.destroy(), n.destroy(), i.destroy(), r.clear();
119
+ }
120
+ mount() {
121
+ let { config: e } = this, t = this.config.get("handle", "texditor");
122
+ if (!i("#" + t)) throw Error("The editor's ID was not found.");
123
+ if (a("#" + t, (e) => {
124
+ let t = e;
125
+ t?.texditor && t.texditor.destroy(), u(e, w(this)), Object.defineProperty(t, "texditor", {
126
+ value: this,
127
+ writable: !0
128
+ }), this.rootElement = t;
129
+ let n = h.get("editors");
130
+ n.push(this.rootElement), h.set("editors", n);
131
+ }), this.getRoot()) {
132
+ let t = e.get("content", []);
133
+ this.setContent(t, e.get("autofocus", !0) ? 0 : -1, e.get("autofocusDelay", 10));
134
+ }
135
+ }
136
+ };
137
+ //#endregion
138
+ export { f as ajax, T as default, e as detectMobileOS, t as executeMethodIfExists, n as getCaretPosition, r as getSelectionRect, p as renderIcon, m as sanitizeJson };
@@ -0,0 +1,212 @@
1
+ import { EventManager, RenderIconContent, Texditor } from '../../../texditor';
2
+ /**
3
+ * Generic model constructor interface
4
+ * @template T - Model interface type that extends BaseModel
5
+ * @template C - Model config type that extends BaseModelConfig
6
+ */
7
+ export interface ModelConstructor<T extends BaseModel = BaseModel, C extends BaseModelConfig = BaseModelConfig> {
8
+ /**
9
+ * Create a new model instance
10
+ * @param editor - Editor instance
11
+ * @returns Model instance of type T
12
+ */
13
+ new (editor: Texditor): T;
14
+ /**
15
+ * Set up global configuration for the model
16
+ * @param config - Configuration object
17
+ * @returns Model constructor
18
+ */
19
+ setup?(config: Partial<C>): ModelConstructor<T, C>;
20
+ }
21
+ /**
22
+ * DOM node interface
23
+ * Extends HTMLElement with base model reference
24
+ */
25
+ export interface BaseElement extends HTMLElement {
26
+ /** Reference to the base model instance */
27
+ baseModel: BaseModel;
28
+ }
29
+ /**
30
+ * Model configuration interface
31
+ * @property name - Model name identifier
32
+ * @property translation - Translation key for localization
33
+ * @property icon - Icon content for the button
34
+ * @property iconWidth - Icon width in pixels
35
+ * @property iconHeight - Icon height in pixels
36
+ * @property className - CSS class name for styling
37
+ * @property visibleTitle - Whether title is always visible
38
+ * @property __modelCode - Model code identifier for parent models
39
+ */
40
+ export interface BaseModelConfig {
41
+ name: string;
42
+ elementTagName: string;
43
+ translation: string;
44
+ icon: RenderIconContent;
45
+ visibleIcon: boolean;
46
+ iconWidth: number;
47
+ iconHeight: number;
48
+ className: string;
49
+ attributeTitle: boolean;
50
+ visibleTitle: boolean;
51
+ __modelCode: string;
52
+ [key: string]: unknown;
53
+ }
54
+ /**
55
+ * Base model constructor type alias
56
+ */
57
+ export type BaseModelConstructor = ModelConstructor<BaseModel, BaseModelConfig>;
58
+ /**
59
+ * Base model behavior interface
60
+ * Defines all public methods for model manipulation
61
+ */
62
+ export interface BaseModel<TElement extends BaseElement = BaseElement> extends EventManager {
63
+ /**
64
+ * Returns the unique identifier for this event listener instance
65
+ * @returns The unique event ID string used to identify and manage event listeners
66
+ */
67
+ getEventId(): string;
68
+ /**
69
+ * Get model name
70
+ * @returns Model name string
71
+ */
72
+ getName(): string;
73
+ /**
74
+ * Get model node tag name
75
+ * @returns Tag name string (default: 'div')
76
+ */
77
+ getElementTagName(): string;
78
+ /**
79
+ * Get model ID
80
+ * @returns Unique model identifier string
81
+ */
82
+ getId(): string;
83
+ /**
84
+ * Get model DOM node
85
+ * @returns Model button element
86
+ */
87
+ getElement(): TElement;
88
+ /**
89
+ * Get CSS class name
90
+ * @returns CSS class name string
91
+ */
92
+ getClassName(): string;
93
+ /**
94
+ * Get the immutable root CSS class name.
95
+ * @returns Root CSS class name string
96
+ */
97
+ getRootClassName(): string;
98
+ /**
99
+ * Get translation for localization
100
+ * @returns Translated string
101
+ */
102
+ getTranslation(): string;
103
+ /**
104
+ * Get icon content for the model button
105
+ * @returns Icon content
106
+ */
107
+ getIcon(): RenderIconContent;
108
+ /**
109
+ * Get icon width
110
+ * @returns Icon width in pixels
111
+ */
112
+ getIconWidth(): number;
113
+ /**
114
+ * Get icon height
115
+ * @returns Icon height in pixels
116
+ */
117
+ getIconHeight(): number;
118
+ /**
119
+ * Get model code identifier
120
+ * @returns Model code string
121
+ */
122
+ getModelCode(): string;
123
+ /**
124
+ * Check if title is always visible
125
+ * @returns True if title should be always visible
126
+ */
127
+ isVisibleTitle(): boolean;
128
+ /**
129
+ * Checks if the attribute title is configured to be always visible.
130
+ * @returns True if the 'attributeTitle' config option is enabled, false otherwise.
131
+ */
132
+ isAttributeTitle(): boolean;
133
+ /**
134
+ * Check if icon is always visible
135
+ * @returns True if icon should be always visible
136
+ */
137
+ isVisibleIcon(): boolean;
138
+ /**
139
+ * Check if model is active
140
+ * @returns True if model is active
141
+ */
142
+ isActive(): boolean;
143
+ /**
144
+ * Check if model is visible
145
+ * @returns True if model should be displayed
146
+ */
147
+ isVisible(): boolean;
148
+ /**
149
+ * Destroy instance and clean up resources
150
+ * @returns void
151
+ */
152
+ destroy(): void;
153
+ /**
154
+ * Get configuration value by key
155
+ * @param key - Configuration key
156
+ * @param defaultValue - Default value
157
+ * @returns Configuration value
158
+ */
159
+ getConfig(key: string, defaultValue: boolean): boolean;
160
+ getConfig(key: string, defaultValue: string): string;
161
+ getConfig(key: string, defaultValue: number): number;
162
+ getConfig<K extends keyof BaseModelConfig>(key: K): BaseModelConfig[K];
163
+ getConfig<K extends keyof BaseModelConfig>(key: K, defaultValue: BaseModelConfig[K]): BaseModelConfig[K];
164
+ getConfig(key: string, defaultValue: unknown): unknown;
165
+ /**
166
+ * Get option value by key
167
+ * @param key - Configuration key
168
+ * @param defaultValue - Default value (optional)
169
+ * @returns Configuration value or null if not found
170
+ */
171
+ getOption<T = unknown>(key: string, defaultValue?: T): T | null;
172
+ /**
173
+ * Set single option value
174
+ * @param key - Configuration key
175
+ * @param value - Value to set
176
+ */
177
+ setOption(key: string, value: unknown): void;
178
+ /**
179
+ * Set multiple options (merges with existing options)
180
+ * @param options - Object with options to merge
181
+ */
182
+ setOptions(options: Record<string, unknown>): void;
183
+ /**
184
+ * Get all options
185
+ * @returns Copy of all options
186
+ */
187
+ getOptions(): Record<string, unknown>;
188
+ /**
189
+ * Remove single option by key
190
+ * @param key - Configuration key to remove
191
+ * @returns True if option existed and was deleted, false otherwise
192
+ */
193
+ removeOption(key: string): boolean;
194
+ /**
195
+ * Clear all options (resets to empty object)
196
+ */
197
+ clearOptions(): void;
198
+ /**
199
+ * Set the value in the store
200
+ * @param key - Storage key
201
+ * @param value - Value to store
202
+ * @returns Current instance for chaining
203
+ */
204
+ setStore(key: string, value: unknown): this;
205
+ /**
206
+ * Get the value in the store
207
+ * @param key - Storage key (null for all)
208
+ * @returns Stored value or null
209
+ */
210
+ getStore(key: string | null): unknown;
211
+ }
212
+ //# sourceMappingURL=base-model.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base-model.d.ts","sourceRoot":"","sources":["../../../../src/types/core/base/base-model.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,iBAAiB,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE5E;;;;GAIG;AACH,MAAM,WAAW,gBAAgB,CAAC,CAAC,SAAS,SAAS,GAAG,SAAS,EAAE,CAAC,SAAS,eAAe,GAAG,eAAe;IAC5G;;;;OAIG;IACH,KAAK,MAAM,EAAE,QAAQ,GAAG,CAAC,CAAC;IAE1B;;;;OAIG;IACH,KAA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,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IAEnD;;;OAGG;IACH,UAAU,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAEtC;;;;OAIG;IACH,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;IAEnC;;OAEG;IACH,YAAY,IAAI,IAAI,CAAC;IAErB;;;;;OAKG;IACH,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI,CAAC;IAE5C;;;;OAIG;IACH,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC;CACvC"}
@@ -0,0 +1,42 @@
1
+ import { TexditorEventBase } from '../..';
2
+ /**
3
+ * Event trigger storage structure
4
+ * Maps event names to collections of callback functions with unique IDs
5
+ */
6
+ export type EventTriggerObject = {
7
+ [name: string]: {
8
+ [id: string]: CallableFunction;
9
+ };
10
+ };
11
+ /**
12
+ * Interface defining the contract for event management
13
+ * All event managers must implement these methods
14
+ */
15
+ export interface EventManager {
16
+ /**
17
+ * Adds an event listener with optional identifier
18
+ * @param name - Event name (can include .id suffix)
19
+ * @param callback - Function to call when event triggers
20
+ */
21
+ on(name: string, callback: CallableFunction): void;
22
+ /**
23
+ * Checks if an event listener exists
24
+ * @param name - Event name (can include .id suffix)
25
+ * @returns True if event exists
26
+ */
27
+ hasEvent(name: string): boolean;
28
+ /**
29
+ * Removes an event listener
30
+ * @param name - Event name
31
+ * @param id - Optional specific event ID to remove
32
+ * @returns True if removal was successful
33
+ */
34
+ off(name: string, id?: string): boolean;
35
+ /**
36
+ * Triggers all callbacks for an event
37
+ * @param name - Event name to trigger
38
+ * @param params - Parameters to pass to callbacks
39
+ */
40
+ trigger(name: string, params?: TexditorEventBase): void;
41
+ }
42
+ //# sourceMappingURL=event-manager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"event-manager.d.ts","sourceRoot":"","sources":["../../../../src/types/core/base/event-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAE5C;;;GAGG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC/B,CAAC,IAAI,EAAE,MAAM,GAAG;QACd,CAAC,EAAE,EAAE,MAAM,GAAG,gBAAgB,CAAC;KAChC,CAAC;CACH,CAAC;AAEF;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B;;;;OAIG;IACH,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,gBAAgB,GAAG,IAAI,CAAC;IAEnD;;;;OAIG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;IAEhC;;;;;OAKG;IACH,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAExC;;;;OAIG;IACH,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,iBAAiB,GAAG,IAAI,CAAC;CACzD"}
@@ -0,0 +1,3 @@
1
+ export * from './event-manager';
2
+ export * from './base-model';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/types/core/base/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC"}
@@ -0,0 +1,223 @@
1
+ import { BlockChildSchema, BlockCreateSchema, BlockModel, BlockModelSchema, BlockElement, BlockSchema, Toasts } from '.';
2
+ import { VirtualSelection } from './ui/virtual-selection';
3
+ export interface BlockManager {
4
+ /**
5
+ * Gets the Toasts service instance
6
+ * @returns {Toasts} The Toasts service
7
+ */
8
+ toasts(): Toasts;
9
+ /**
10
+ * Recreates the VirtualSelection instance with current options.
11
+ * @returns The new VirtualSelection instance, or null.
12
+ */
13
+ refreshVirtualSelection(): VirtualSelection | null;
14
+ /**
15
+ * Returns the current VirtualSelection instance if it exists
16
+ * @returns The new VirtualSelection instance, or null.
17
+ */
18
+ getVirtualSelection(): VirtualSelection | null;
19
+ /**
20
+ * Clear Selection UI
21
+ */
22
+ clearVirtualSelection(): void;
23
+ /**
24
+ * Destroys the current VirtualSelection instance if it exists
25
+ */
26
+ destroyVirtualSelection(): void;
27
+ /**
28
+ * Gets the container element that holds all blocks
29
+ * @returns The blocks container element or null if not found
30
+ */
31
+ getBlocksContainer(): HTMLElement | null;
32
+ /**
33
+ * Gets all block elements in the editor.
34
+ * @returns Array of block elements.
35
+ */
36
+ getBlocks(): BlockElement[];
37
+ /**
38
+ * Gets a specific block element by index
39
+ * @param index - Block index (defaults to current index)
40
+ * @returns Block element or null if not found
41
+ */
42
+ getBlock(index?: number): BlockElement | null;
43
+ /**
44
+ * Gets the content element within a block
45
+ * @param blockElement - Block node (defaults to current block)
46
+ * @returns Content element or null
47
+ */
48
+ getContentElement(blockElement?: BlockElement): HTMLElement | null;
49
+ /**
50
+ * Gets the next block node after current active block
51
+ * @returns Next block node or null
52
+ */
53
+ getNextBlockElement(): BlockElement | null;
54
+ /**
55
+ * Gets the previous block node before current active block
56
+ * @returns Previous block node or null
57
+ */
58
+ getPrevBlockElement(): BlockElement | null;
59
+ /**
60
+ * Finds parent block of a target element
61
+ * @param targetElement - Target element or event target
62
+ * @returns Parent block node or null
63
+ */
64
+ findParent(targetElement: EventTarget | BlockElement | HTMLElement): BlockElement | null;
65
+ /**
66
+ * Gets the index of a block
67
+ * @param el - Target node (defaults to current block)
68
+ * @returns Block index
69
+ */
70
+ getIndex(el?: BlockElement | HTMLElement | EventTarget): number;
71
+ /**
72
+ * Sets the active block index and updates UI
73
+ * @param index - Block index to set as active
74
+ */
75
+ use(index: number): void;
76
+ /**
77
+ * Gets the total number of blocks
78
+ * @returns Block count
79
+ */
80
+ count(): number;
81
+ /**
82
+ * Checks if a block is empty
83
+ * @param index - Block index (defaults to current block)
84
+ * @returns True if block is empty
85
+ */
86
+ isEmpty(index?: number): boolean;
87
+ /**
88
+ * Gets the block model for a specific block
89
+ * @param index - Block index (defaults to current block)
90
+ * @returns Block model or null
91
+ */
92
+ getModel(index?: number): BlockModel | null;
93
+ /**
94
+ * Sets focus to a specific block by index
95
+ * @param index - Block index to focus
96
+ * @param startPos - Starting the selection position
97
+ * @param endPos - End of selection position
98
+ * @param itemIndex - Item index
99
+ * @returns The focused block node or null if focus failed
100
+ */
101
+ focus(index: number, startPos?: number, endPos?: number, itemIndex?: number): BlockElement | null;
102
+ /**
103
+ * Creates a default block based on editor configuration
104
+ * @param index - Index of the block to create (-1 after the current block)
105
+ * @param options - Block Options
106
+ * @returns Created block node or null
107
+ */
108
+ createDefaultBlock(index?: number, options?: BlockCreateSchema): BlockElement | null;
109
+ /**
110
+ * Creates a new block of specified type
111
+ * @param name - Block type name
112
+ * @param index - Index of the block to create (-1 after the current block)
113
+ * @param options - Block Options
114
+ * @param skipEvents - If true, no events will be emitted and focus won't be automatically managed
115
+ * @param scrollIntoView - If true or ScrollIntoViewOptions provided, the created block will be scrolled into view. Default is true
116
+ * @returns Created block node or null
117
+ */
118
+ createBlock(name: string, index?: number, options?: BlockCreateSchema, skipEvents?: boolean, scrollIntoView?: boolean | ScrollIntoViewOptions): BlockElement | null;
119
+ /**
120
+ * Recreates a block at the given index using the existing data.
121
+ *
122
+ * @param index - The index of the block to rebuild
123
+ * @returns A new block element or null
124
+ */
125
+ rebuild(index: number): BlockElement | null;
126
+ /**
127
+ * Move block to new position
128
+ * @param index - Item index
129
+ * @param targetIndex - Target item index
130
+ * @param skipEvents - Skip events
131
+ */
132
+ moveBlock(index: number, targetIndex: number, skipEvents?: boolean): void;
133
+ /**
134
+ * Removes one or multiple blocks
135
+ * @param index - Index of the block to delete (-1 to the current block)
136
+ * @param skipEvents - If true, no events will be emitted and focus won't be automatically managed
137
+ * @returns Index of last removed block or null
138
+ */
139
+ removeBlock(index?: number | number[], skipEvents?: boolean): number | null;
140
+ /**
141
+ * Merges two blocks together
142
+ * @param index - Block index
143
+ * @param targetIndex - Target block index
144
+ * @param focus - The index of the focus block
145
+ * @param useItems - Use all the contents of the editable child elements.
146
+ */
147
+ merge(index: number, targetIndex: number, focus?: number, useItems?: boolean | false): void;
148
+ /**
149
+ * Converts a block to a different type
150
+ * @param block - Block to convert
151
+ * @param targetModel - Target block model
152
+ * @returns Convert status
153
+ */
154
+ convert(block: BlockElement, targetModel: BlockModel): boolean;
155
+ /**
156
+ * Updates empty state data attributes on blocks
157
+ * @param emptyAttr - Whether to set empty attribute
158
+ */
159
+ detectEmpty(emptyAttr?: boolean): void;
160
+ /**
161
+ * Normalizes all blocks that require normalization
162
+ */
163
+ normalize(): void;
164
+ /**
165
+ * Retrieves a list of block models based on nodes
166
+ * @returns List of block models
167
+ */
168
+ getModels(): BlockModel[];
169
+ /**
170
+ * Gets all registered block models
171
+ * @returns Array of block model structures
172
+ */
173
+ getSchemas(): BlockModelSchema[];
174
+ /**
175
+ * Gets the block model schema by supported type name
176
+ * @param name - Supported type name or alias
177
+ * @returns Block model schema, or null if not found
178
+ */
179
+ getSchema(name: string): BlockModelSchema | null;
180
+ /**
181
+ * Gets the real block type name from a related type alias
182
+ * @param name - Supported type name or alias
183
+ * @returns Real block type name, or null if not found
184
+ */
185
+ getRealName(name: string): string | null;
186
+ /**
187
+ * Converts HTML string to an array of BlockSchema objects or text strings.
188
+ *
189
+ * @param html - HTML string to parse
190
+ * @returns Array of BlockSchema for elements or strings for text nodes
191
+ */
192
+ htmlToData(html: string): Array<BlockSchema | string>;
193
+ /**
194
+ * Parses a block schema into a BlockElement instance
195
+ * @param blockSchema - Block schema object containing type and data
196
+ * @param skipDecode - Whether to skip decoding of child content (default: false)
197
+ * @returns Parsed BlockElement instance, or null if parsing failed
198
+ */
199
+ parseBlock(blockSchema: BlockSchema, skipDecode?: boolean): BlockElement | null;
200
+ /**
201
+ * Converts an array of BlockSchema objects into an array of BlockElement objects.
202
+ *
203
+ * @param data - Array of BlockSchema objects to be parsed
204
+ * @param skipDecode - If true, skips HTML entity decoding for text content
205
+ * @returns An array of parsed BlockElement objects
206
+ */
207
+ parseBlocks(data: BlockSchema[], skipDecode?: boolean): BlockElement[];
208
+ /**
209
+ * Recursively parses a BlockSchema structure and converts it into an array of DOM Nodes.
210
+ * For root call returns children nodes, for recursive calls returns the element itself.
211
+ *
212
+ * @param schema - The BlockSchema or BlockChildSchema object containing type, data, and optional attributes
213
+ * @param skipDecode - If true, skips HTML entity decoding for text content
214
+ * @param returnElement - Internal parameter to track if this is a recursive call
215
+ * @returns An array of DOM Nodes
216
+ */
217
+ parseChildren(schema: BlockSchema | BlockChildSchema, skipDecode?: boolean, returnElement?: boolean): Node[];
218
+ /**
219
+ * Cleans up event listeners
220
+ */
221
+ destroy(): void;
222
+ }
223
+ //# sourceMappingURL=block-manager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"block-manager.d.ts","sourceRoot":"","sources":["../../../src/types/core/block-manager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,iBAAiB,EACjB,UAAU,EACV,gBAAgB,EAChB,YAAY,EACZ,WAAW,EACX,MAAM,EACP,MAAM,GAAG,CAAC;AACX,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE1D,MAAM,WAAW,YAAY;IAC3B;;;OAGG;IACH,MAAM,IAAI,MAAM,CAAC;IAEjB;;;OAGG;IACH,uBAAuB,IAAI,gBAAgB,GAAG,IAAI,CAAC;IAEnD;;;OAGG;IACH,mBAAmB,IAAI,gBAAgB,GAAG,IAAI,CAAC;IAE/C;;OAEG;IACH,qBAAqB,IAAI,IAAI,CAAC;IAE9B;;OAEG;IACH,uBAAuB,IAAI,IAAI,CAAC;IAEhC;;;OAGG;IACH,kBAAkB,IAAI,WAAW,GAAG,IAAI,CAAC;IAEzC;;;OAGG;IACH,SAAS,IAAI,YAAY,EAAE,CAAC;IAE5B;;;;OAIG;IACH,QAAQ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