@nectary/components 4.12.0 → 4.12.1

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 (585) hide show
  1. package/accordion/index.d.ts +22 -1
  2. package/accordion/index.js +39 -41
  3. package/accordion/types.d.ts +1 -21
  4. package/accordion/types.js +1 -1
  5. package/accordion-item/index.d.ts +22 -2
  6. package/accordion-item/index.js +49 -53
  7. package/accordion-item/types.d.ts +1 -21
  8. package/accordion-item/types.js +1 -1
  9. package/accordion-item/utils.js +1 -4
  10. package/action-menu/index.d.ts +22 -1
  11. package/action-menu/index.js +77 -62
  12. package/action-menu/types.d.ts +1 -21
  13. package/action-menu/types.js +1 -1
  14. package/action-menu-option/index.d.ts +22 -1
  15. package/action-menu-option/index.js +41 -39
  16. package/action-menu-option/types.d.ts +1 -21
  17. package/action-menu-option/types.js +1 -1
  18. package/action-menu-option/utils.js +3 -6
  19. package/alert/index.d.ts +22 -2
  20. package/alert/index.js +21 -24
  21. package/alert/types.d.ts +1 -21
  22. package/alert/types.js +1 -1
  23. package/alert/utils.js +1 -4
  24. package/avatar/colors.js +1 -1
  25. package/avatar/index.d.ts +22 -2
  26. package/avatar/index.js +41 -42
  27. package/avatar/types.d.ts +1 -21
  28. package/avatar/types.js +1 -1
  29. package/avatar/utils.js +4 -9
  30. package/badge/index.d.ts +22 -3
  31. package/badge/index.js +51 -52
  32. package/badge/types.d.ts +1 -21
  33. package/badge/types.js +1 -1
  34. package/badge/utils.js +1 -4
  35. package/button/index.d.ts +22 -2
  36. package/button/index.js +111 -101
  37. package/button/types.d.ts +1 -21
  38. package/button/types.js +1 -1
  39. package/button/utils.js +2 -18
  40. package/button-group/index.d.ts +22 -1
  41. package/button-group/index.js +18 -20
  42. package/button-group/types.d.ts +3 -22
  43. package/button-group/types.js +1 -1
  44. package/button-group-item/index.d.ts +22 -2
  45. package/button-group-item/index.js +42 -31
  46. package/button-group-item/types.d.ts +3 -22
  47. package/button-group-item/types.js +1 -1
  48. package/card/index.d.ts +40 -0
  49. package/card/index.js +134 -0
  50. package/card/types.d.ts +17 -0
  51. package/card/types.js +1 -0
  52. package/card-container/index.d.ts +21 -1
  53. package/card-container/index.js +5 -8
  54. package/card-container/types.d.ts +1 -21
  55. package/card-container/types.js +1 -1
  56. package/card-v2/index.d.ts +22 -1
  57. package/card-v2/index.js +57 -59
  58. package/card-v2/types.d.ts +1 -21
  59. package/card-v2/types.js +1 -1
  60. package/card-v2-title/index.d.ts +22 -2
  61. package/card-v2-title/index.js +26 -28
  62. package/card-v2-title/types.d.ts +1 -21
  63. package/card-v2-title/types.js +1 -1
  64. package/checkbox/index.d.ts +22 -1
  65. package/checkbox/index.js +81 -88
  66. package/checkbox/types.d.ts +1 -21
  67. package/checkbox/types.js +1 -1
  68. package/chip/colors.js +1 -1
  69. package/chip/index.d.ts +22 -1
  70. package/chip/index.js +75 -62
  71. package/chip/types.d.ts +1 -21
  72. package/chip/types.js +1 -1
  73. package/chip/utils.js +3 -7
  74. package/code-tag/index.d.ts +22 -1
  75. package/code-tag/index.js +14 -17
  76. package/code-tag/types.d.ts +1 -21
  77. package/code-tag/types.js +1 -1
  78. package/color-menu/index.d.ts +22 -2
  79. package/color-menu/index.js +115 -115
  80. package/color-menu/types.d.ts +1 -21
  81. package/color-menu/types.js +1 -1
  82. package/color-menu/utils.js +3 -6
  83. package/color-menu-option/index.d.ts +22 -1
  84. package/color-menu-option/index.js +26 -30
  85. package/color-menu-option/types.d.ts +1 -21
  86. package/color-menu-option/types.js +1 -1
  87. package/color-menu-option/utils.js +3 -6
  88. package/color-swatch/index.d.ts +22 -1
  89. package/color-swatch/index.js +20 -23
  90. package/color-swatch/types.d.ts +1 -21
  91. package/color-swatch/types.js +1 -1
  92. package/color-swatch/utils.js +3 -7
  93. package/date-picker/index.d.ts +22 -2
  94. package/date-picker/index.js +150 -157
  95. package/date-picker/types.d.ts +1 -21
  96. package/date-picker/types.js +1 -1
  97. package/date-picker/utils.js +42 -59
  98. package/dialog/index.d.ts +22 -1
  99. package/dialog/index.js +58 -71
  100. package/dialog/types.d.ts +1 -21
  101. package/dialog/types.js +1 -1
  102. package/dialog/utils.js +7 -11
  103. package/emoji/index.d.ts +22 -1
  104. package/emoji/index.js +16 -19
  105. package/emoji/types.d.ts +1 -21
  106. package/emoji/types.js +1 -1
  107. package/emoji/utils.js +17 -22
  108. package/emoji-picker/index.d.ts +22 -2
  109. package/emoji-picker/index.js +118 -138
  110. package/emoji-picker/types.d.ts +1 -21
  111. package/emoji-picker/types.js +1 -1
  112. package/field/index.d.ts +22 -1
  113. package/field/index.js +60 -63
  114. package/field/types.d.ts +1 -21
  115. package/field/types.js +1 -1
  116. package/file-drop/index.d.ts +22 -1
  117. package/file-drop/index.js +98 -103
  118. package/file-drop/types.d.ts +1 -21
  119. package/file-drop/types.js +1 -1
  120. package/file-drop/utils.js +22 -27
  121. package/file-picker/index.d.ts +22 -1
  122. package/file-picker/index.js +48 -53
  123. package/file-picker/types.d.ts +1 -21
  124. package/file-picker/types.js +1 -1
  125. package/file-picker/utils.js +3 -6
  126. package/file-status/index.d.ts +22 -2
  127. package/file-status/index.js +22 -33
  128. package/file-status/types.d.ts +1 -21
  129. package/file-status/types.js +1 -1
  130. package/file-status/utils.js +1 -4
  131. package/flag/index.d.ts +22 -1
  132. package/flag/index.js +16 -19
  133. package/flag/types.d.ts +1 -21
  134. package/flag/types.js +1 -1
  135. package/flag/utils.js +8 -11
  136. package/grid/index.d.ts +22 -1
  137. package/grid/index.js +5 -8
  138. package/grid/types.d.ts +1 -21
  139. package/grid/types.js +1 -1
  140. package/grid-item/index.d.ts +22 -1
  141. package/grid-item/index.js +13 -17
  142. package/grid-item/types.d.ts +1 -21
  143. package/grid-item/types.js +1 -1
  144. package/help-tooltip/index.d.ts +22 -1
  145. package/help-tooltip/index.js +26 -29
  146. package/help-tooltip/types.d.ts +1 -21
  147. package/help-tooltip/types.js +1 -1
  148. package/horizontal-stepper/index.d.ts +33 -0
  149. package/horizontal-stepper/index.js +62 -0
  150. package/horizontal-stepper/types.d.ts +42 -0
  151. package/horizontal-stepper/types.js +1 -0
  152. package/horizontal-stepper-item/index.d.ts +38 -0
  153. package/horizontal-stepper-item/index.js +62 -0
  154. package/horizontal-stepper-item/types.d.ts +38 -0
  155. package/horizontal-stepper-item/types.js +1 -0
  156. package/horizontal-stepper-item/utils.d.ts +2 -0
  157. package/horizontal-stepper-item/utils.js +1 -0
  158. package/icon/generated-icon-type.js +1 -1
  159. package/icon/index.d.ts +22 -1
  160. package/icon/index.js +28 -30
  161. package/icon/types.d.ts +1 -21
  162. package/icon/types.js +1 -1
  163. package/inline-alert/index.d.ts +22 -2
  164. package/inline-alert/index.js +39 -58
  165. package/inline-alert/types.d.ts +1 -21
  166. package/inline-alert/types.js +1 -1
  167. package/inline-alert/utils.js +1 -4
  168. package/input/index.d.ts +22 -2
  169. package/input/index.js +317 -295
  170. package/input/types.d.ts +1 -21
  171. package/input/types.js +1 -1
  172. package/input/utils.js +46 -56
  173. package/link/index.d.ts +22 -1
  174. package/link/index.js +79 -88
  175. package/link/types.d.ts +1 -21
  176. package/link/types.js +1 -1
  177. package/list/index.d.ts +21 -1
  178. package/list/index.js +6 -9
  179. package/list/types.d.ts +1 -21
  180. package/list/types.js +1 -1
  181. package/list-item/index.d.ts +22 -1
  182. package/list-item/index.js +6 -9
  183. package/list-item/types.d.ts +1 -21
  184. package/list-item/types.js +1 -1
  185. package/package.json +5 -11
  186. package/pagination/index.d.ts +22 -2
  187. package/pagination/index.js +46 -64
  188. package/pagination/types.d.ts +1 -21
  189. package/pagination/types.js +1 -1
  190. package/persistent-overlay/index.d.ts +22 -1
  191. package/persistent-overlay/index.js +44 -42
  192. package/persistent-overlay/types.d.ts +1 -21
  193. package/persistent-overlay/types.js +1 -1
  194. package/pop/index.d.ts +22 -3
  195. package/pop/index.js +150 -149
  196. package/pop/types.d.ts +1 -21
  197. package/pop/types.js +1 -1
  198. package/pop/utils.js +8 -24
  199. package/popover/index.d.ts +22 -2
  200. package/popover/index.js +68 -75
  201. package/popover/types.d.ts +1 -21
  202. package/popover/types.js +1 -1
  203. package/popover/utils.js +7 -18
  204. package/progress/index.d.ts +22 -1
  205. package/progress/index.js +33 -30
  206. package/progress/types.d.ts +1 -21
  207. package/progress/types.js +1 -1
  208. package/progress-stepper/index.d.ts +22 -2
  209. package/progress-stepper/index.js +66 -64
  210. package/progress-stepper/types.d.ts +1 -21
  211. package/progress-stepper/types.js +1 -1
  212. package/progress-stepper-item/index.d.ts +22 -1
  213. package/progress-stepper-item/index.js +50 -58
  214. package/progress-stepper-item/types.d.ts +1 -21
  215. package/progress-stepper-item/types.js +1 -1
  216. package/progress-stepper-item/utils.js +11 -22
  217. package/radio/index.d.ts +22 -1
  218. package/radio/index.js +83 -79
  219. package/radio/types.d.ts +1 -21
  220. package/radio/types.js +1 -1
  221. package/radio-option/index.d.ts +22 -1
  222. package/radio-option/index.js +41 -47
  223. package/radio-option/types.d.ts +1 -21
  224. package/radio-option/types.js +1 -1
  225. package/rich-text/index.d.ts +22 -1
  226. package/rich-text/index.js +46 -45
  227. package/rich-text/types.d.ts +1 -21
  228. package/rich-text/types.js +1 -1
  229. package/rich-text/utils.js +33 -31
  230. package/rich-textarea/index.d.ts +22 -1
  231. package/rich-textarea/index.js +194 -201
  232. package/rich-textarea/types.d.ts +1 -21
  233. package/rich-textarea/types.js +1 -1
  234. package/rich-textarea/utils.js +340 -313
  235. package/segment/index.d.ts +40 -0
  236. package/segment/index.js +110 -0
  237. package/segment/types.d.ts +23 -0
  238. package/segment/types.js +1 -0
  239. package/segment/utils.d.ts +3 -0
  240. package/segment/utils.js +16 -0
  241. package/segment-collapse/index.d.ts +22 -1
  242. package/segment-collapse/index.js +25 -31
  243. package/segment-collapse/types.d.ts +1 -21
  244. package/segment-collapse/types.js +1 -1
  245. package/segmented-control/index.d.ts +22 -1
  246. package/segmented-control/index.js +45 -45
  247. package/segmented-control/types.d.ts +1 -21
  248. package/segmented-control/types.js +1 -1
  249. package/segmented-control-option/index.d.ts +22 -1
  250. package/segmented-control-option/index.js +46 -44
  251. package/segmented-control-option/types.d.ts +1 -21
  252. package/segmented-control-option/types.js +1 -1
  253. package/segmented-icon-control/index.d.ts +22 -1
  254. package/segmented-icon-control/index.js +50 -51
  255. package/segmented-icon-control/types.d.ts +1 -21
  256. package/segmented-icon-control/types.js +1 -1
  257. package/segmented-icon-control-option/index.d.ts +22 -1
  258. package/segmented-icon-control-option/index.js +37 -36
  259. package/segmented-icon-control-option/types.d.ts +1 -21
  260. package/segmented-icon-control-option/types.js +1 -1
  261. package/select-button/index.d.ts +26 -1
  262. package/select-button/index.js +112 -104
  263. package/select-button/types.d.ts +1 -25
  264. package/select-button/types.js +1 -1
  265. package/select-menu/index.d.ts +22 -1
  266. package/select-menu/index.js +164 -201
  267. package/select-menu/types.d.ts +1 -21
  268. package/select-menu/types.js +1 -1
  269. package/select-menu-option/index.d.ts +22 -1
  270. package/select-menu-option/index.js +33 -41
  271. package/select-menu-option/types.d.ts +1 -21
  272. package/select-menu-option/types.js +1 -1
  273. package/select-menu-option/utils.js +1 -4
  274. package/skeleton/index.d.ts +22 -1
  275. package/skeleton/index.js +38 -35
  276. package/skeleton/types.d.ts +1 -21
  277. package/skeleton/types.js +1 -1
  278. package/skeleton-item/index.d.ts +22 -1
  279. package/skeleton-item/index.js +5 -8
  280. package/skeleton-item/types.d.ts +1 -21
  281. package/skeleton-item/types.js +1 -1
  282. package/spinner/index.d.ts +22 -1
  283. package/spinner/index.js +29 -31
  284. package/spinner/types.d.ts +1 -21
  285. package/spinner/types.js +1 -1
  286. package/standalone.d.ts +8 -0
  287. package/standalone.js +87 -79
  288. package/standalone.ts +8 -0
  289. package/stop-events/index.js +12 -12
  290. package/table/index.d.ts +21 -1
  291. package/table/index.js +6 -9
  292. package/table/types.d.ts +1 -21
  293. package/table/types.js +1 -1
  294. package/table-body/index.d.ts +21 -1
  295. package/table-body/index.js +6 -9
  296. package/table-body/types.d.ts +1 -21
  297. package/table-body/types.js +1 -1
  298. package/table-cell/index.d.ts +22 -2
  299. package/table-cell/index.js +9 -13
  300. package/table-cell/types.d.ts +1 -21
  301. package/table-cell/types.js +1 -1
  302. package/table-cell/utils.js +1 -4
  303. package/table-head/index.d.ts +21 -1
  304. package/table-head/index.js +6 -9
  305. package/table-head/types.d.ts +1 -21
  306. package/table-head/types.js +1 -1
  307. package/table-head-cell/index.d.ts +22 -1
  308. package/table-head-cell/index.js +27 -29
  309. package/table-head-cell/types.d.ts +1 -21
  310. package/table-head-cell/types.js +1 -1
  311. package/table-row/index.d.ts +22 -1
  312. package/table-row/index.js +17 -20
  313. package/table-row/types.d.ts +1 -21
  314. package/table-row/types.js +1 -1
  315. package/tabs/index.d.ts +22 -2
  316. package/tabs/index.js +35 -32
  317. package/tabs/types.d.ts +1 -21
  318. package/tabs/types.js +1 -1
  319. package/tabs-icon-option/index.d.ts +22 -1
  320. package/tabs-icon-option/index.js +40 -38
  321. package/tabs-icon-option/types.d.ts +1 -21
  322. package/tabs-icon-option/types.js +1 -1
  323. package/tabs-option/index.d.ts +22 -1
  324. package/tabs-option/index.js +43 -41
  325. package/tabs-option/types.d.ts +1 -21
  326. package/tabs-option/types.js +1 -1
  327. package/tag/colors.js +1 -1
  328. package/tag/index.d.ts +22 -1
  329. package/tag/index.js +44 -45
  330. package/tag/types.d.ts +1 -21
  331. package/tag/types.js +1 -1
  332. package/tag/utils.js +3 -7
  333. package/text/index.d.ts +22 -2
  334. package/text/index.js +28 -33
  335. package/text/types.d.ts +1 -21
  336. package/text/types.js +1 -1
  337. package/text/utils.js +1 -4
  338. package/textarea/index.d.ts +22 -1
  339. package/textarea/index.js +152 -147
  340. package/textarea/types.d.ts +1 -21
  341. package/textarea/types.js +1 -1
  342. package/tile-control/index.d.ts +39 -0
  343. package/tile-control/index.js +111 -0
  344. package/tile-control/types.d.ts +29 -0
  345. package/tile-control/types.js +1 -0
  346. package/tile-control-option/index.d.ts +40 -0
  347. package/tile-control-option/index.js +99 -0
  348. package/tile-control-option/types.d.ts +52 -0
  349. package/tile-control-option/types.js +1 -0
  350. package/time-picker/index.d.ts +22 -2
  351. package/time-picker/index.js +123 -119
  352. package/time-picker/types.d.ts +1 -21
  353. package/time-picker/types.js +1 -1
  354. package/time-picker/utils.js +33 -31
  355. package/title/index.d.ts +22 -2
  356. package/title/index.js +31 -32
  357. package/title/types.d.ts +1 -21
  358. package/title/types.js +1 -1
  359. package/title/utils.js +14 -18
  360. package/toast/index.d.ts +22 -2
  361. package/toast/index.js +34 -37
  362. package/toast/types.d.ts +1 -21
  363. package/toast/types.js +1 -1
  364. package/toast/utils.js +1 -4
  365. package/toast-manager/index.d.ts +22 -3
  366. package/toast-manager/index.js +63 -77
  367. package/toast-manager/types.d.ts +1 -21
  368. package/toast-manager/types.js +1 -1
  369. package/toast-manager/utils.js +1 -4
  370. package/toggle/index.d.ts +22 -1
  371. package/toggle/index.js +75 -81
  372. package/toggle/types.d.ts +1 -21
  373. package/toggle/types.js +1 -1
  374. package/tooltip/index.d.ts +22 -3
  375. package/tooltip/index.js +93 -105
  376. package/tooltip/tooltip-state.js +64 -56
  377. package/tooltip/types.d.ts +1 -21
  378. package/tooltip/types.js +1 -1
  379. package/tooltip/utils.js +13 -32
  380. package/types.d.ts +29 -12
  381. package/utils/adapters.js +1 -1
  382. package/utils/context.js +42 -32
  383. package/utils/countries.js +2 -490
  384. package/utils/csv.js +6 -13
  385. package/utils/debounce.js +3 -10
  386. package/utils/dom.js +53 -60
  387. package/utils/element.d.ts +15 -107
  388. package/utils/element.js +19 -100
  389. package/utils/event-target.js +5 -11
  390. package/utils/form.js +12 -17
  391. package/utils/get-react-event-handler.js +3 -6
  392. package/utils/index.js +12 -65
  393. package/utils/markdown.js +43 -56
  394. package/utils/rect.js +18 -13
  395. package/utils/size.js +3 -8
  396. package/utils/slot.js +9 -13
  397. package/utils/throttle.js +2 -5
  398. package/utils/uid.js +2 -5
  399. package/vertical-stepper/index.d.ts +33 -0
  400. package/vertical-stepper/index.js +58 -0
  401. package/vertical-stepper/types.d.ts +34 -0
  402. package/vertical-stepper/types.js +1 -0
  403. package/vertical-stepper-item/index.d.ts +38 -0
  404. package/vertical-stepper-item/index.js +62 -0
  405. package/vertical-stepper-item/types.d.ts +42 -0
  406. package/vertical-stepper-item/types.js +1 -0
  407. package/vertical-stepper-item/utils.d.ts +2 -0
  408. package/vertical-stepper-item/utils.js +1 -0
  409. package/accordion/global/index.d.ts +0 -1
  410. package/accordion/global/index.js +0 -2
  411. package/accordion-item/global/index.d.ts +0 -1
  412. package/accordion-item/global/index.js +0 -2
  413. package/action-menu/global/index.d.ts +0 -1
  414. package/action-menu/global/index.js +0 -2
  415. package/action-menu-option/global/index.d.ts +0 -1
  416. package/action-menu-option/global/index.js +0 -2
  417. package/alert/global/index.d.ts +0 -1
  418. package/alert/global/index.js +0 -2
  419. package/avatar/global/index.d.ts +0 -1
  420. package/avatar/global/index.js +0 -2
  421. package/badge/global/index.d.ts +0 -1
  422. package/badge/global/index.js +0 -2
  423. package/bundle.d.ts +0 -78
  424. package/bundle.js +0 -13033
  425. package/bundle.ts +0 -80
  426. package/button/global/index.d.ts +0 -1
  427. package/button/global/index.js +0 -2
  428. package/button-group/global/index.d.ts +0 -1
  429. package/button-group/global/index.js +0 -2
  430. package/button-group-item/global/index.d.ts +0 -1
  431. package/button-group-item/global/index.js +0 -2
  432. package/card-container/global/index.d.ts +0 -1
  433. package/card-container/global/index.js +0 -2
  434. package/card-v2/global/index.d.ts +0 -1
  435. package/card-v2/global/index.js +0 -2
  436. package/card-v2-title/global/index.d.ts +0 -1
  437. package/card-v2-title/global/index.js +0 -2
  438. package/checkbox/global/index.d.ts +0 -1
  439. package/checkbox/global/index.js +0 -2
  440. package/chip/global/index.d.ts +0 -1
  441. package/chip/global/index.js +0 -2
  442. package/code-tag/global/index.d.ts +0 -1
  443. package/code-tag/global/index.js +0 -2
  444. package/color-menu/global/index.d.ts +0 -1
  445. package/color-menu/global/index.js +0 -2
  446. package/color-menu-option/global/index.d.ts +0 -1
  447. package/color-menu-option/global/index.js +0 -2
  448. package/color-swatch/global/index.d.ts +0 -1
  449. package/color-swatch/global/index.js +0 -2
  450. package/date-picker/global/index.d.ts +0 -1
  451. package/date-picker/global/index.js +0 -2
  452. package/dialog/global/index.d.ts +0 -1
  453. package/dialog/global/index.js +0 -2
  454. package/emoji/global/index.d.ts +0 -1
  455. package/emoji/global/index.js +0 -2
  456. package/emoji-picker/global/index.d.ts +0 -1
  457. package/emoji-picker/global/index.js +0 -2
  458. package/field/global/index.d.ts +0 -1
  459. package/field/global/index.js +0 -2
  460. package/file-drop/global/index.d.ts +0 -1
  461. package/file-drop/global/index.js +0 -2
  462. package/file-picker/global/index.d.ts +0 -1
  463. package/file-picker/global/index.js +0 -2
  464. package/file-status/global/index.d.ts +0 -1
  465. package/file-status/global/index.js +0 -2
  466. package/flag/global/index.d.ts +0 -1
  467. package/flag/global/index.js +0 -2
  468. package/grid/global/index.d.ts +0 -1
  469. package/grid/global/index.js +0 -2
  470. package/grid-item/global/index.d.ts +0 -1
  471. package/grid-item/global/index.js +0 -2
  472. package/help-tooltip/global/index.d.ts +0 -1
  473. package/help-tooltip/global/index.js +0 -2
  474. package/icon/global/index.d.ts +0 -1
  475. package/icon/global/index.js +0 -2
  476. package/inline-alert/global/index.d.ts +0 -1
  477. package/inline-alert/global/index.js +0 -2
  478. package/input/global/index.d.ts +0 -1
  479. package/input/global/index.js +0 -2
  480. package/link/global/index.d.ts +0 -1
  481. package/link/global/index.js +0 -2
  482. package/list/global/index.d.ts +0 -1
  483. package/list/global/index.js +0 -2
  484. package/list-item/global/index.d.ts +0 -1
  485. package/list-item/global/index.js +0 -2
  486. package/pagination/global/index.d.ts +0 -1
  487. package/pagination/global/index.js +0 -2
  488. package/persistent-overlay/global/index.d.ts +0 -1
  489. package/persistent-overlay/global/index.js +0 -2
  490. package/pop/global/index.d.ts +0 -1
  491. package/pop/global/index.js +0 -2
  492. package/popover/global/index.d.ts +0 -1
  493. package/popover/global/index.js +0 -2
  494. package/progress/global/index.d.ts +0 -1
  495. package/progress/global/index.js +0 -2
  496. package/progress-stepper/global/index.d.ts +0 -1
  497. package/progress-stepper/global/index.js +0 -2
  498. package/progress-stepper-item/global/index.d.ts +0 -1
  499. package/progress-stepper-item/global/index.js +0 -2
  500. package/radio/global/index.d.ts +0 -1
  501. package/radio/global/index.js +0 -2
  502. package/radio-option/global/index.d.ts +0 -1
  503. package/radio-option/global/index.js +0 -2
  504. package/rich-text/global/index.d.ts +0 -1
  505. package/rich-text/global/index.js +0 -2
  506. package/rich-textarea/global/index.d.ts +0 -1
  507. package/rich-textarea/global/index.js +0 -2
  508. package/segment-collapse/global/index.d.ts +0 -1
  509. package/segment-collapse/global/index.js +0 -2
  510. package/segmented-control/global/index.d.ts +0 -1
  511. package/segmented-control/global/index.js +0 -2
  512. package/segmented-control-option/global/index.d.ts +0 -1
  513. package/segmented-control-option/global/index.js +0 -2
  514. package/segmented-icon-control/global/index.d.ts +0 -1
  515. package/segmented-icon-control/global/index.js +0 -2
  516. package/segmented-icon-control-option/global/index.d.ts +0 -1
  517. package/segmented-icon-control-option/global/index.js +0 -2
  518. package/select-button/global/index.d.ts +0 -1
  519. package/select-button/global/index.js +0 -2
  520. package/select-menu/global/index.d.ts +0 -1
  521. package/select-menu/global/index.js +0 -2
  522. package/select-menu-option/global/index.d.ts +0 -1
  523. package/select-menu-option/global/index.js +0 -2
  524. package/skeleton/global/index.d.ts +0 -1
  525. package/skeleton/global/index.js +0 -2
  526. package/skeleton-item/global/index.d.ts +0 -1
  527. package/skeleton-item/global/index.js +0 -2
  528. package/spinner/global/index.d.ts +0 -1
  529. package/spinner/global/index.js +0 -2
  530. package/table/global/index.d.ts +0 -1
  531. package/table/global/index.js +0 -2
  532. package/table-body/global/index.d.ts +0 -1
  533. package/table-body/global/index.js +0 -2
  534. package/table-cell/global/index.d.ts +0 -1
  535. package/table-cell/global/index.js +0 -2
  536. package/table-head/global/index.d.ts +0 -1
  537. package/table-head/global/index.js +0 -2
  538. package/table-head-cell/global/index.d.ts +0 -1
  539. package/table-head-cell/global/index.js +0 -2
  540. package/table-row/global/index.d.ts +0 -1
  541. package/table-row/global/index.js +0 -2
  542. package/tabs/global/index.d.ts +0 -1
  543. package/tabs/global/index.js +0 -2
  544. package/tabs-icon-option/global/index.d.ts +0 -1
  545. package/tabs-icon-option/global/index.js +0 -2
  546. package/tabs-option/global/index.d.ts +0 -1
  547. package/tabs-option/global/index.js +0 -2
  548. package/tag/global/index.d.ts +0 -1
  549. package/tag/global/index.js +0 -2
  550. package/text/global/index.d.ts +0 -1
  551. package/text/global/index.js +0 -2
  552. package/textarea/global/index.d.ts +0 -1
  553. package/textarea/global/index.js +0 -2
  554. package/time-picker/global/index.d.ts +0 -1
  555. package/time-picker/global/index.js +0 -2
  556. package/title/global/index.d.ts +0 -1
  557. package/title/global/index.js +0 -2
  558. package/toast/global/index.d.ts +0 -1
  559. package/toast/global/index.js +0 -2
  560. package/toast-manager/global/index.d.ts +0 -1
  561. package/toast-manager/global/index.js +0 -2
  562. package/toggle/global/index.d.ts +0 -1
  563. package/toggle/global/index.js +0 -2
  564. package/tooltip/global/index.d.ts +0 -1
  565. package/tooltip/global/index.js +0 -2
  566. package/utils/component-names.d.ts +0 -3
  567. package/utils/component-names.js +0 -85
  568. package/utils/global-components-constants.d.ts +0 -3
  569. package/utils/global-components-constants.js +0 -8
  570. package/utils/global-components-manager.d.ts +0 -71
  571. package/utils/global-components-manager.js +0 -24
  572. package/utils/shared/global-elements-manager.d.js +0 -1
  573. package/utils/shared/global-elements-manager.d.ts +0 -62
  574. package/utils/shared/global-elements-manager.js +0 -163
  575. package/utils/shared/global-elements-store.d.js +0 -1
  576. package/utils/shared/global-elements-store.d.ts +0 -12
  577. package/utils/shared/global-elements-store.js +0 -31
  578. package/utils/shared/index.d.js +0 -11
  579. package/utils/shared/index.d.ts +0 -3
  580. package/utils/shared/index.js +0 -11
  581. package/utils/shared/nectary-element-base.d.js +0 -1
  582. package/utils/shared/nectary-element-base.d.ts +0 -9
  583. package/utils/shared/nectary-element-base.js +0 -25
  584. package/utils/shared/package.json +0 -9
  585. package/utils/shared/tsconfig.json +0 -20
@@ -1,32 +1,32 @@
1
- import { getEmojiUrl, getEmojiBaseUrl } from "../emoji/utils.js";
2
- import { isEmojiString, parseMarkdown } from "../utils/markdown.js";
3
- const TEXT_EMPTY_DATA = "";
4
- const TEXT_WHITESPACE = " ";
5
- const isTextNode = ($n) => $n !== null && $n.nodeType === Node.TEXT_NODE;
6
- const isEmptyText = (value) => value === null || value.length === 0 || value === TEXT_EMPTY_DATA;
7
- const isEmptyTextNode = ($n) => isTextNode($n) && isEmptyText($n.nodeValue);
8
- const getTextValue = ($n) => isEmptyText($n.nodeValue) ? TEXT_EMPTY_DATA : $n.nodeValue;
9
- const isParagraph = ($n) => {
10
- return $n !== null && $n.nodeType === Node.ELEMENT_NODE && $n.classList.contains("p");
11
- };
12
- const isListItem = ($n) => {
1
+ import { getEmojiBaseUrl, getEmojiUrl } from '../emoji/utils';
2
+ import { isEmojiString, parseMarkdown } from '../utils';
3
+ const TEXT_EMPTY_DATA = '';
4
+ const TEXT_WHITESPACE = ' ';
5
+ const isTextNode = $n => $n !== null && $n.nodeType === Node.TEXT_NODE;
6
+ const isEmptyText = value => value === null || value.length === 0 || value === TEXT_EMPTY_DATA;
7
+ const isEmptyTextNode = $n => isTextNode($n) && isEmptyText($n.nodeValue);
8
+ const getTextValue = $n => isEmptyText($n.nodeValue) ? TEXT_EMPTY_DATA : $n.nodeValue;
9
+ const isParagraph = $n => {
10
+ return $n !== null && $n.nodeType === Node.ELEMENT_NODE && $n.classList.contains('p');
11
+ };
12
+ const isListItem = $n => {
13
13
  return isUnorderedListItem($n) || isOrderedListItem($n);
14
14
  };
15
- const isUnorderedListItem = ($n) => {
16
- return $n !== null && $n.nodeType === Node.ELEMENT_NODE && $n.classList.contains("uli");
15
+ const isUnorderedListItem = $n => {
16
+ return $n !== null && $n.nodeType === Node.ELEMENT_NODE && $n.classList.contains('uli');
17
17
  };
18
- const isOrderedListItem = ($n) => {
19
- return $n !== null && $n.nodeType === Node.ELEMENT_NODE && $n.classList.contains("oli");
18
+ const isOrderedListItem = $n => {
19
+ return $n !== null && $n.nodeType === Node.ELEMENT_NODE && $n.classList.contains('oli');
20
20
  };
21
- const isTextBlock = ($n) => isParagraph($n) || isListItem($n);
22
- const isEmoji = ($n) => {
23
- return $n !== null && $n.nodeName === "IMG";
21
+ const isTextBlock = $n => isParagraph($n) || isListItem($n);
22
+ const isEmoji = $n => {
23
+ return $n !== null && $n.nodeName === 'IMG';
24
24
  };
25
- const isInline = ($n) => $n !== null && $n.nodeName === "SPAN";
26
- const isRoot = ($n) => $n !== null && $n.nodeName === "DIV";
27
- const assertNonNull = ($n) => {
25
+ const isInline = $n => $n !== null && $n.nodeName === 'SPAN';
26
+ const isRoot = $n => $n !== null && $n.nodeName === 'DIV';
27
+ const assertNonNull = $n => {
28
28
  if ($n === null) {
29
- throw new Error("Node is NULL");
29
+ throw new Error('Node is NULL');
30
30
  }
31
31
  };
32
32
  const assertEquals = (a, b) => {
@@ -34,64 +34,64 @@ const assertEquals = (a, b) => {
34
34
  throw new Error(`"${a}" not equals "${b}"`);
35
35
  }
36
36
  };
37
- const assertTextNode = ($n) => {
37
+ const assertTextNode = $n => {
38
38
  assertNonNull($n);
39
39
  if (!isTextNode($n)) {
40
40
  throw new Error(`Node is not a TextNode: ${$n?.nodeName}`);
41
41
  }
42
42
  };
43
- const assertTextBlock = ($n) => {
43
+ const assertTextBlock = $n => {
44
44
  assertNonNull($n);
45
45
  if (!isTextBlock($n)) {
46
46
  throw new Error(`Node is not a TextBlock: ${$n?.nodeName}`);
47
47
  }
48
48
  };
49
- const assertListItem = ($n) => {
49
+ const assertListItem = $n => {
50
50
  assertNonNull($n);
51
51
  if (!isListItem($n)) {
52
52
  throw new Error(`Node is not a ListItem: ${$n?.nodeName}`);
53
53
  }
54
54
  };
55
- const markListItemAsBlock = ($li) => {
56
- $li.classList.add("block");
55
+ const markListItemAsBlock = $li => {
56
+ $li.classList.add('block');
57
57
  };
58
- const isListItemMarkedArBlock = ($li) => {
59
- return $li.classList.contains("block");
58
+ const isListItemMarkedArBlock = $li => {
59
+ return $li.classList.contains('block');
60
60
  };
61
61
  const MAX_LISTITEM_LEVEL = 4;
62
- const removeListItemLevel = ($li) => {
63
- $li.classList.remove("l0", "l1", "l2", "l3", "l4");
62
+ const removeListItemLevel = $li => {
63
+ $li.classList.remove('l0', 'l1', 'l2', 'l3', 'l4');
64
64
  };
65
65
  const setListItemLevel = ($li, level) => {
66
66
  removeListItemLevel($li);
67
67
  const clampedLevel = Math.max(0, Math.min(level, MAX_LISTITEM_LEVEL));
68
68
  $li.classList.add(`l${clampedLevel}`);
69
69
  };
70
- const getListItemLevel = ($li) => {
71
- if ($li.classList.contains("l1")) {
70
+ const getListItemLevel = $li => {
71
+ if ($li.classList.contains('l1')) {
72
72
  return 1;
73
73
  }
74
- if ($li.classList.contains("l2")) {
74
+ if ($li.classList.contains('l2')) {
75
75
  return 2;
76
76
  }
77
- if ($li.classList.contains("l3")) {
77
+ if ($li.classList.contains('l3')) {
78
78
  return 3;
79
79
  }
80
- if ($li.classList.contains("l4")) {
80
+ if ($li.classList.contains('l4')) {
81
81
  return 4;
82
82
  }
83
83
  return 0;
84
84
  };
85
- const assertInline = ($n) => {
85
+ const assertInline = $n => {
86
86
  assertNonNull($n);
87
87
  if (!isInline($n)) {
88
88
  throw new Error(`Node is not an Inline: ${$n?.nodeName}`);
89
89
  }
90
90
  };
91
- const isTextContent = ($n) => {
91
+ const isTextContent = $n => {
92
92
  return $n !== null && $n.nodeType === Node.ELEMENT_NODE && (isInline($n) || isEmoji($n));
93
93
  };
94
- const assertTextContent = ($n) => {
94
+ const assertTextContent = $n => {
95
95
  assertNonNull($n);
96
96
  if (!isTextContent($n)) {
97
97
  throw new Error(`Node is not TextContent: ${$n?.nodeName}`);
@@ -100,15 +100,15 @@ const assertTextContent = ($n) => {
100
100
  const createTextNode = (data, doc) => {
101
101
  return doc.createTextNode(data);
102
102
  };
103
- const createEmptyTextNode = (doc) => {
103
+ const createEmptyTextNode = doc => {
104
104
  return createTextNode(TEXT_EMPTY_DATA, doc);
105
105
  };
106
- const createEmptyInline = (doc) => {
107
- const res = doc.createElement("SPAN");
106
+ const createEmptyInline = doc => {
107
+ const res = doc.createElement('SPAN');
108
108
  res.append(createEmptyTextNode(doc));
109
109
  return res;
110
110
  };
111
- const getParentInline = ($n) => {
111
+ const getParentInline = $n => {
112
112
  const $p = $n.parentNode;
113
113
  assertInline($p);
114
114
  return $p;
@@ -118,26 +118,22 @@ const isInsideList = (isOrdered, $n) => {
118
118
  return isOrdered ? isOrderedListItem($block) : isUnorderedListItem($block);
119
119
  };
120
120
  const isAllInsideList = (isOrdered, $a, $b) => {
121
- return allSiblingsIncludingSatisfy(
122
- getParentTextBlock($a),
123
- getParentTextBlock($b),
124
- isOrdered ? isOrderedListItem : isUnorderedListItem
125
- );
121
+ return allSiblingsIncludingSatisfy(getParentTextBlock($a), getParentTextBlock($b), isOrdered ? isOrderedListItem : isUnorderedListItem);
126
122
  };
127
123
  const FORMAT_TYPE_TO_NAME = {
128
- formatBold: "b",
129
- formatCodeTag: "c",
130
- formatItalic: "i",
131
- formatStrikeThrough: "s"
124
+ formatBold: 'b',
125
+ formatCodeTag: 'c',
126
+ formatItalic: 'i',
127
+ formatStrikeThrough: 's'
132
128
  };
133
129
  const isFormatName = ($n, inlineName) => {
134
130
  return $n.classList.contains(inlineName);
135
131
  };
136
- const isFormatBold = ($n) => isFormatName($n, "b");
137
- const isFormatItalic = ($n) => isFormatName($n, "i");
138
- const isFormatStrikethrough = ($n) => isFormatName($n, "s");
139
- const isFormatCodetag = ($n) => isFormatName($n, "c");
140
- const isFormatLink = ($n) => isFormatName($n, "l");
132
+ const isFormatBold = $n => isFormatName($n, 'b');
133
+ const isFormatItalic = $n => isFormatName($n, 'i');
134
+ const isFormatStrikethrough = $n => isFormatName($n, 's');
135
+ const isFormatCodetag = $n => isFormatName($n, 'c');
136
+ const isFormatLink = $n => isFormatName($n, 'l');
141
137
  const isAllInsideFormatName = ($a, $b, formatName) => {
142
138
  const aBlock = getParentTextBlock($a);
143
139
  const bBlock = getParentTextBlock($b);
@@ -162,31 +158,31 @@ const isAllInsideFormatName = ($a, $b, formatName) => {
162
158
  } while ($currentBlock !== null && $prevBlock !== bBlock);
163
159
  return hasTextNodes;
164
160
  };
165
- const isAllInsideBold = ($a, $b) => isAllInsideFormatName($a, $b, "b");
166
- const isAllInsideItalic = ($a, $b) => isAllInsideFormatName($a, $b, "i");
167
- const isAllInsideStrikethrough = ($a, $b) => isAllInsideFormatName($a, $b, "s");
168
- const isAllInsideCodetag = ($a, $b) => isAllInsideFormatName($a, $b, "c");
169
- const isAllInsideLink = ($a, $b) => isAllInsideFormatName($a, $b, "l");
170
- const LINK_HREF_ATTR_NAME = "data-href";
161
+ const isAllInsideBold = ($a, $b) => isAllInsideFormatName($a, $b, 'b');
162
+ const isAllInsideItalic = ($a, $b) => isAllInsideFormatName($a, $b, 'i');
163
+ const isAllInsideStrikethrough = ($a, $b) => isAllInsideFormatName($a, $b, 's');
164
+ const isAllInsideCodetag = ($a, $b) => isAllInsideFormatName($a, $b, 'c');
165
+ const isAllInsideLink = ($a, $b) => isAllInsideFormatName($a, $b, 'l');
166
+ const LINK_HREF_ATTR_NAME = 'data-href';
171
167
  const copyFormatName = ($source, $target) => {
172
168
  const $inline = isTextNode($source) ? getParentInline($source) : $source;
173
169
  $target.className = $inline.className;
174
170
  if (isFormatLink($inline)) {
175
- $target.setAttribute(LINK_HREF_ATTR_NAME, $inline.getAttribute(LINK_HREF_ATTR_NAME) ?? "");
171
+ $target.setAttribute(LINK_HREF_ATTR_NAME, $inline.getAttribute(LINK_HREF_ATTR_NAME) ?? '');
176
172
  }
177
173
  };
178
174
  const setInlineFormat = ($n, formatName, shouldEnable) => {
179
175
  if (shouldEnable) {
180
- if (formatName === "c" || isFormatName($n, "c")) {
181
- $n.className = "";
176
+ if (formatName === 'c' || isFormatName($n, 'c')) {
177
+ $n.className = '';
182
178
  }
183
- if (formatName === "l" || isFormatName($n, "l")) {
184
- $n.className = "";
179
+ if (formatName === 'l' || isFormatName($n, 'l')) {
180
+ $n.className = '';
185
181
  $n.removeAttribute(LINK_HREF_ATTR_NAME);
186
182
  }
187
183
  $n.classList.add(formatName);
188
184
  } else {
189
- if (formatName === "l") {
185
+ if (formatName === 'l') {
190
186
  $n.removeAttribute(LINK_HREF_ATTR_NAME);
191
187
  }
192
188
  $n.classList.remove(formatName);
@@ -221,8 +217,8 @@ const areSameInlineFormat = ($a, $b) => {
221
217
  if ($a.classList.length !== $b.classList.length) {
222
218
  return false;
223
219
  }
224
- if ($a.className === "l") {
225
- return $b.className === "l" && $a.getAttribute(LINK_HREF_ATTR_NAME) === $b.getAttribute(LINK_HREF_ATTR_NAME);
220
+ if ($a.className === 'l') {
221
+ return $b.className === 'l' && $a.getAttribute(LINK_HREF_ATTR_NAME) === $b.getAttribute(LINK_HREF_ATTR_NAME);
226
222
  }
227
223
  for (let i = 0; i < $a.classList.length; i++) {
228
224
  if (!$b.classList.contains($a.classList[i])) {
@@ -232,7 +228,7 @@ const areSameInlineFormat = ($a, $b) => {
232
228
  return true;
233
229
  };
234
230
  const createInlineWithText = (data, doc) => {
235
- const $res = doc.createElement("SPAN");
231
+ const $res = doc.createElement('SPAN');
236
232
  $res.append(createTextNode(data, doc));
237
233
  return $res;
238
234
  };
@@ -244,25 +240,25 @@ const createInlineWithTextOfType = ($text, $source) => {
244
240
  };
245
241
  const createLink = (text, href, doc) => {
246
242
  const $link = createInlineWithText(text, doc);
247
- setInlineFormat($link, "l", true);
243
+ setInlineFormat($link, 'l', true);
248
244
  $link.setAttribute(LINK_HREF_ATTR_NAME, href);
249
245
  return $link;
250
246
  };
251
- const EMOJI_CHAR_ATTR_NAME = "data-char";
247
+ const EMOJI_CHAR_ATTR_NAME = 'data-char';
252
248
  const createEmoji = (emojiChar, baseUrl, doc) => {
253
- const $emoji = doc.createElement("img");
249
+ const $emoji = doc.createElement('img');
254
250
  $emoji.setAttribute(EMOJI_CHAR_ATTR_NAME, emojiChar);
255
- $emoji.setAttribute("src", getEmojiUrl(baseUrl, emojiChar));
256
- $emoji.classList.add("e");
251
+ $emoji.setAttribute('src', getEmojiUrl(baseUrl, emojiChar));
252
+ $emoji.classList.add('e');
257
253
  return $emoji;
258
254
  };
259
- const PARAGRAPH_CLASSNAME = "p";
260
- const createActuallyEmptyParagraph = (doc) => {
261
- const $p = doc.createElement("p");
255
+ const PARAGRAPH_CLASSNAME = 'p';
256
+ const createActuallyEmptyParagraph = doc => {
257
+ const $p = doc.createElement('p');
262
258
  $p.classList.add(PARAGRAPH_CLASSNAME);
263
259
  return $p;
264
260
  };
265
- const createEmptyParagraph = (doc) => {
261
+ const createEmptyParagraph = doc => {
266
262
  const res = createActuallyEmptyParagraph(doc);
267
263
  res.append(createEmptyInline(doc));
268
264
  return res;
@@ -275,19 +271,17 @@ const createParagraphWithChildren = (children, doc) => {
275
271
  $p.append(...children);
276
272
  return $p;
277
273
  };
278
- const ULI_CLASSNAME = "uli";
279
- const OLI_CLASSNAME = "oli";
274
+ const ULI_CLASSNAME = 'uli';
275
+ const OLI_CLASSNAME = 'oli';
280
276
  const createActuallyEmptyListItem = (isOrdered, listLevel, doc) => {
281
- const $li = doc.createElement("p");
277
+ const $li = doc.createElement('p');
282
278
  $li.className = isOrdered ? OLI_CLASSNAME : ULI_CLASSNAME;
283
279
  setListItemLevel($li, listLevel);
284
280
  return $li;
285
281
  };
286
282
  const createEmptyListItem = (isOrdered, listLevel, doc) => {
287
283
  const $li = createActuallyEmptyListItem(isOrdered, listLevel, doc);
288
- $li.append(
289
- createEmptyInline(doc)
290
- );
284
+ $li.append(createEmptyInline(doc));
291
285
  return $li;
292
286
  };
293
287
  const setListItemOrderedType = ($li, isOrdered) => {
@@ -310,7 +304,7 @@ const convertToListItem = ($p, isOrdered) => {
310
304
  setListItemLevel($li, 0);
311
305
  return $li;
312
306
  };
313
- const convertToParagraph = ($li) => {
307
+ const convertToParagraph = $li => {
314
308
  removeListItemLevel($li);
315
309
  $li.classList.remove(ULI_CLASSNAME, OLI_CLASSNAME);
316
310
  $li.classList.add(PARAGRAPH_CLASSNAME);
@@ -325,7 +319,7 @@ const createListItemWithChildren = (children, isOrdered, listLevel, doc) => {
325
319
  $li.append(...children);
326
320
  return $li;
327
321
  };
328
- const getParentTextBlock = ($node) => {
322
+ const getParentTextBlock = $node => {
329
323
  const $inline = isTextNode($node) ? getParentInline($node) : $node;
330
324
  const $p = $inline.parentNode;
331
325
  assertTextBlock($p);
@@ -337,22 +331,22 @@ const childIndexOf = ($parent, $child) => {
337
331
  const getChildByIndex = ($parent, index) => {
338
332
  const children = $parent.childNodes;
339
333
  if (index < 0 || index >= children.length) {
340
- throw new Error("Invalid index");
334
+ throw new Error('Invalid index');
341
335
  }
342
336
  const $ch = index >= children.length ? children[children.length - 1] : children[index];
343
337
  return $ch;
344
338
  };
345
- const afterLastChildIndex = ($parent) => {
339
+ const afterLastChildIndex = $parent => {
346
340
  return $parent.childNodes.length;
347
341
  };
348
342
  const isAfterLastChildIndex = ($parent, index) => {
349
343
  return index >= $parent.childNodes.length;
350
344
  };
351
- const getLastChild = (n) => n.lastChild;
352
- const getFirstChild = (n) => n.firstChild;
353
- const getPrevSibling = (n) => n.previousSibling;
354
- const getNextSibling = (n) => n.nextSibling;
355
- const getSiblingTextBlock = (getSibling) => ($node) => {
345
+ const getLastChild = n => n.lastChild;
346
+ const getFirstChild = n => n.firstChild;
347
+ const getPrevSibling = n => n.previousSibling;
348
+ const getNextSibling = n => n.nextSibling;
349
+ const getSiblingTextBlock = getSibling => $node => {
356
350
  const $sib = getSibling($node);
357
351
  if ($sib !== null) {
358
352
  assertTextBlock($sib);
@@ -364,6 +358,15 @@ const getPrevSiblingTextBlock = getSiblingTextBlock(getPrevSibling);
364
358
  const getNextSiblingTextBlock = getSiblingTextBlock(getNextSibling);
365
359
  const getPrevSiblingTextContent = ($node, ensureValid) => {
366
360
  const $sib = $node.previousSibling;
361
+ if ($sib === null && ensureValid === true) {
362
+ const $currentBlock = getParentTextBlock($node);
363
+ const $prevBlock = getPrevSiblingTextBlock($currentBlock);
364
+ if ($prevBlock === null) {
365
+ $currentBlock.prepend(createEmptyInline($node.ownerDocument));
366
+ return getFirstTextContent($currentBlock);
367
+ }
368
+ return getLastTextContent($prevBlock);
369
+ }
367
370
  if ($sib !== null) {
368
371
  assertTextContent($sib);
369
372
  }
@@ -371,13 +374,25 @@ const getPrevSiblingTextContent = ($node, ensureValid) => {
371
374
  };
372
375
  const getNextSiblingTextContent = ($node, ensureValid) => {
373
376
  const $sib = $node.nextSibling;
377
+ if ($sib === null && ensureValid === true) {
378
+ const $currentBlock = getParentTextBlock($node);
379
+ const $nextBlock = getNextSiblingTextBlock($currentBlock);
380
+ if ($nextBlock === null) {
381
+ $currentBlock.append(createEmptyInline($node.ownerDocument));
382
+ return getLastTextContent($currentBlock);
383
+ }
384
+ return getFirstTextContent($nextBlock);
385
+ }
374
386
  if ($sib !== null) {
375
387
  assertTextContent($sib);
376
388
  }
377
389
  return $sib;
378
390
  };
379
- const createCollapsedRange = (cursor) => {
380
- const { node, offset } = cursorToNodeWithOffset(cursor);
391
+ const createCollapsedRange = cursor => {
392
+ const {
393
+ node,
394
+ offset
395
+ } = cursorToNodeWithOffset(cursor);
381
396
  return {
382
397
  startContainer: node,
383
398
  startOffset: offset,
@@ -386,8 +401,14 @@ const createCollapsedRange = (cursor) => {
386
401
  };
387
402
  };
388
403
  const createSpanningRange = (aCursor, bCursor) => {
389
- const { node: startContainer, offset: startOffset } = cursorToNodeWithOffset(aCursor);
390
- const { node: endContainer, offset: endOffset } = cursorToNodeWithOffset(bCursor);
404
+ const {
405
+ node: startContainer,
406
+ offset: startOffset
407
+ } = cursorToNodeWithOffset(aCursor);
408
+ const {
409
+ node: endContainer,
410
+ offset: endOffset
411
+ } = cursorToNodeWithOffset(bCursor);
391
412
  return {
392
413
  startContainer,
393
414
  startOffset,
@@ -395,13 +416,13 @@ const createSpanningRange = (aCursor, bCursor) => {
395
416
  endOffset
396
417
  };
397
418
  };
398
- const removePrevSiblings = ($node) => {
419
+ const removePrevSiblings = $node => {
399
420
  let $n;
400
421
  while (($n = $node.previousSibling) !== null) {
401
422
  $n.remove();
402
423
  }
403
424
  };
404
- const removeNextSiblings = ($node) => {
425
+ const removeNextSiblings = $node => {
405
426
  let $n;
406
427
  while (($n = $node.nextSibling) !== null) {
407
428
  $n.remove();
@@ -438,11 +459,9 @@ const removeNodesBetween = (aCursor, bCursor) => {
438
459
  }
439
460
  removeSiblingsBetween($cpChildA, $cpChildB);
440
461
  };
441
- const ensureCorrectTextBlockIfEmpty = ($node) => {
462
+ const ensureCorrectTextBlockIfEmpty = $node => {
442
463
  if (!$node.hasChildNodes()) {
443
- $node.append(
444
- createEmptyInline($node.ownerDocument)
445
- );
464
+ $node.append(createEmptyInline($node.ownerDocument));
446
465
  return;
447
466
  }
448
467
  const children = $node.childNodes;
@@ -456,15 +475,15 @@ const ensureCorrectTextBlockIfEmpty = ($node) => {
456
475
  }
457
476
  }
458
477
  };
459
- const getChildText = ($node) => {
478
+ const getChildText = $node => {
460
479
  if ($node.childNodes.length !== 1) {
461
- throw new Error("Should have exact 1 child");
480
+ throw new Error('Should have exact 1 child');
462
481
  }
463
482
  const $child = $node.firstChild;
464
483
  assertTextNode($child);
465
484
  return $child;
466
485
  };
467
- const getChildTextContent = (getFirstOrLastChild) => ($node) => {
486
+ const getChildTextContent = getFirstOrLastChild => $node => {
468
487
  ensureCorrectTextBlockIfEmpty($node);
469
488
  const $child = getFirstOrLastChild($node);
470
489
  assertTextContent($child);
@@ -472,7 +491,7 @@ const getChildTextContent = (getFirstOrLastChild) => ($node) => {
472
491
  };
473
492
  const getLastTextContent = getChildTextContent(getLastChild);
474
493
  const getFirstTextContent = getChildTextContent(getFirstChild);
475
- const getFirstOrLastTextBlock = (getFirstOrLastChild) => ($root) => {
494
+ const getFirstOrLastTextBlock = getFirstOrLastChild => $root => {
476
495
  let $lc = getFirstOrLastChild($root);
477
496
  if ($lc === null) {
478
497
  $lc = createEmptyParagraph($root.ownerDocument);
@@ -493,7 +512,7 @@ const mergeSiblingTextNodes = ($a, aCursor, bCursor) => {
493
512
  const bContent = getTextValue($b);
494
513
  const aContentLength = isEmptyText(aContent) ? 0 : aContent.length;
495
514
  const bContentLength = isEmptyText(bContent) ? 0 : bContent.length;
496
- let resultText = (isEmptyText(aContent) ? "" : aContent) + (isEmptyText(bContent) ? "" : bContent);
515
+ let resultText = (isEmptyText(aContent) ? '' : aContent) + (isEmptyText(bContent) ? '' : bContent);
497
516
  const isEmptyResultText = resultText.length === 0;
498
517
  if (aCursor.$text === $a) {
499
518
  aCursor.offset = isEmptyResultText ? 1 : aCursor.offset;
@@ -589,7 +608,7 @@ const mergeNextTextBlock = ($a, aCursor, bCursor) => {
589
608
  };
590
609
  const sliceChildren = ($parent, index) => {
591
610
  if (index < 0) {
592
- throw new Error("Not found");
611
+ throw new Error('Not found');
593
612
  }
594
613
  const children = Array.from($parent.childNodes);
595
614
  if (index === 0) {
@@ -603,10 +622,7 @@ const splitTextBlock = ($a, childIndex) => {
603
622
  ensureCorrectTextBlockIfEmpty($a);
604
623
  ensureCorrectTextBlockIfEmpty($b);
605
624
  $a.after($b);
606
- return [
607
- $a,
608
- $b
609
- ];
625
+ return [$a, $b];
610
626
  };
611
627
  const splitTextNode = ($aText, offset) => {
612
628
  const content = getTextValue($aText);
@@ -646,42 +662,44 @@ const splitTextNodeAndInsertEmptyInline = ($n, offset) => {
646
662
  }
647
663
  return $inline;
648
664
  };
649
- const formatInline = (formatType, range) => {
665
+ export const formatInline = (formatType, range) => {
650
666
  const aCursor = createIncomingCursorFromNodeWithOffset(range.startContainer, range.startOffset);
651
667
  const bCursor = createIncomingCursorFromNodeWithOffset(range.endContainer, range.endOffset);
652
668
  const formatName = FORMAT_TYPE_TO_NAME[formatType];
653
669
  if (aCursor.$inline === bCursor.$inline && isTextNode(aCursor.$text)) {
654
- const { $text, $inline, offset: startOffset } = aCursor;
655
- const { offset: endOffset } = bCursor;
670
+ const {
671
+ $text,
672
+ $inline,
673
+ offset: startOffset
674
+ } = aCursor;
675
+ const {
676
+ offset: endOffset
677
+ } = bCursor;
656
678
  if (isEmptyText($text.nodeValue)) {
657
679
  assertInline($inline);
658
680
  toggleInlineFormat($inline, formatName);
659
681
  return {
660
682
  prevent: true,
661
- range: createCollapsedRange(
662
- createEndCursorFromTextContent($inline)
663
- )
683
+ range: createCollapsedRange(createEndCursorFromTextContent($inline))
664
684
  };
665
685
  }
666
686
  if (startOffset === endOffset) {
667
- const $newinline2 = splitTextNodeAndInsertEmptyInline($text, startOffset);
668
- toggleInlineFormat($newinline2, formatName);
687
+ const $newinline = splitTextNodeAndInsertEmptyInline($text, startOffset);
688
+ toggleInlineFormat($newinline, formatName);
669
689
  return {
670
690
  prevent: true,
671
- range: createCollapsedRange(
672
- createEndCursorFromTextContent($newinline2)
673
- )
691
+ range: createCollapsedRange(createEndCursorFromTextContent($newinline))
674
692
  };
675
693
  }
676
694
  const $newinline = sliceTextNode($text, startOffset, endOffset);
677
695
  toggleInlineFormat($newinline, formatName);
678
- const aTrackingCursor2 = createBeginCursorFromTextContent($newinline);
679
- const bTrackingCursor2 = createEndCursorFromTextContent($newinline);
680
- mergeNextTextContentSibling($newinline, aTrackingCursor2, bTrackingCursor2);
681
- mergePrevTextContentSibling($newinline, aTrackingCursor2, bTrackingCursor2);
696
+ const aTrackingCursor = createBeginCursorFromTextContent($newinline);
697
+ const bTrackingCursor = createEndCursorFromTextContent($newinline);
698
+ mergeNextTextContentSibling($newinline, aTrackingCursor, bTrackingCursor);
699
+ mergePrevTextContentSibling($newinline, aTrackingCursor, bTrackingCursor);
682
700
  return {
683
701
  prevent: true,
684
- range: createSpanningRange(aTrackingCursor2, bTrackingCursor2)
702
+ range: createSpanningRange(aTrackingCursor, bTrackingCursor)
685
703
  };
686
704
  }
687
705
  const areAllInline = isAllInsideFormatName(aCursor.$inline, bCursor.$inline, formatName);
@@ -724,7 +742,7 @@ const allSiblingsIncludingSatisfy = (aNode, bNode, func) => {
724
742
  }
725
743
  return true;
726
744
  };
727
- const formatIndent = (range) => {
745
+ export const formatIndent = range => {
728
746
  if (range.startContainer === range.endContainer && range.startOffset === range.endOffset && range.startOffset !== 0) {
729
747
  return {
730
748
  prevent: false
@@ -753,7 +771,7 @@ const formatIndent = (range) => {
753
771
  range
754
772
  };
755
773
  };
756
- const ensureListItemLevelsAreCorrect = ($li) => {
774
+ const ensureListItemLevelsAreCorrect = $li => {
757
775
  if ($li === null) {
758
776
  return;
759
777
  }
@@ -770,7 +788,7 @@ const ensureListItemLevelsAreCorrect = ($li) => {
770
788
  $block = getNextSiblingTextBlock($block);
771
789
  }
772
790
  };
773
- const formatOutdent = (range) => {
791
+ export const formatOutdent = range => {
774
792
  if (range.startContainer === range.endContainer && range.startOffset === range.endOffset && range.startOffset !== 0) {
775
793
  return {
776
794
  prevent: false
@@ -798,7 +816,7 @@ const formatOutdent = (range) => {
798
816
  range
799
817
  };
800
818
  };
801
- const formatList = (isOrdered, range) => {
819
+ export const formatList = (isOrdered, range) => {
802
820
  const aCursor = createIncomingCursorFromNodeWithOffset(range.startContainer, range.startOffset);
803
821
  const bCursor = createIncomingCursorFromNodeWithOffset(range.endContainer, range.endOffset);
804
822
  const aBlock = getParentTextBlock(aCursor.$inline);
@@ -807,11 +825,11 @@ const formatList = (isOrdered, range) => {
807
825
  if (isInsideSameListType) {
808
826
  assertListItem(aBlock);
809
827
  assertListItem(bBlock);
810
- const $iterateUpToNode2 = getNextSiblingTextBlock(bBlock);
811
- let $block2 = aBlock;
812
- while ($block2 !== null && $block2 !== $iterateUpToNode2) {
813
- convertToParagraph($block2);
814
- $block2 = getNextSiblingTextBlock($block2);
828
+ const $iterateUpToNode = getNextSiblingTextBlock(bBlock);
829
+ let $block = aBlock;
830
+ while ($block !== null && $block !== $iterateUpToNode) {
831
+ convertToParagraph($block);
832
+ $block = getNextSiblingTextBlock($block);
815
833
  }
816
834
  return {
817
835
  prevent: true,
@@ -841,7 +859,7 @@ const createCursorFromTextNode = (node, offset) => {
841
859
  offset: Math.min(node.length, offset)
842
860
  };
843
861
  };
844
- const createBeginCursorFromTextContent = (node) => {
862
+ const createBeginCursorFromTextContent = node => {
845
863
  if (isInline(node)) {
846
864
  const $text = getChildText(node);
847
865
  const content = getTextValue($text);
@@ -857,7 +875,7 @@ const createBeginCursorFromTextContent = (node) => {
857
875
  offset: 0
858
876
  };
859
877
  };
860
- const createEndCursorFromTextContent = (node) => {
878
+ const createEndCursorFromTextContent = node => {
861
879
  if (isInline(node)) {
862
880
  const $text = getChildText(node);
863
881
  return {
@@ -886,9 +904,7 @@ const createIncomingCursorFromNodeWithOffset = (node, offset) => {
886
904
  }
887
905
  if (isTextBlock(node)) {
888
906
  if (isAfterLastChildIndex(node, offset)) {
889
- return createEndCursorFromTextContent(
890
- getLastTextContent(node)
891
- );
907
+ return createEndCursorFromTextContent(getLastTextContent(node));
892
908
  }
893
909
  return createIncomingCursorFromNodeWithOffset(getChildByIndex(node, offset), 0);
894
910
  }
@@ -906,9 +922,15 @@ const createIncomingCursorFromNodeWithOffset = (node, offset) => {
906
922
  }
907
923
  return createIncomingCursorFromNodeWithOffset(getChildByIndex(node, offset), 0);
908
924
  }
909
- throw new Error("Should not happen");
925
+ throw new Error('Should not happen');
910
926
  };
911
- const cursorToNodeWithOffset = ({ $text, $inline, offset, isAfterInline }) => {
927
+ const cursorToNodeWithOffset = _ref => {
928
+ let {
929
+ $text,
930
+ $inline,
931
+ offset,
932
+ isAfterInline
933
+ } = _ref;
912
934
  if (isTextNode($text)) {
913
935
  return {
914
936
  node: $text,
@@ -922,15 +944,21 @@ const cursorToNodeWithOffset = ({ $text, $inline, offset, isAfterInline }) => {
922
944
  offset: childIndex
923
945
  };
924
946
  };
925
- const removeContentInRange = (range) => {
947
+ const removeContentInRange = range => {
926
948
  const aCursor = createIncomingCursorFromNodeWithOffset(range.startContainer, range.startOffset);
927
949
  const bCursor = createIncomingCursorFromNodeWithOffset(range.endContainer, range.endOffset);
928
950
  if (aCursor.$inline === bCursor.$inline && aCursor.offset === bCursor.offset && aCursor.isAfterInline === bCursor.isAfterInline) {
929
951
  return aCursor;
930
952
  }
931
953
  if (aCursor.$text === bCursor.$text && isTextNode(aCursor.$text)) {
932
- const { $text, $inline, offset: startOffset } = aCursor;
933
- const { offset: endOffset } = bCursor;
954
+ const {
955
+ $text,
956
+ $inline,
957
+ offset: startOffset
958
+ } = aCursor;
959
+ const {
960
+ offset: endOffset
961
+ } = bCursor;
934
962
  const content = getTextValue($text);
935
963
  const nextContent = content.substring(0, startOffset) + content.substring(endOffset);
936
964
  $text.nodeValue = nextContent;
@@ -982,8 +1010,13 @@ const removeContentInRange = (range) => {
982
1010
  }
983
1011
  return trackingCursor;
984
1012
  };
985
- const deleteContentBackward = ($root, range) => {
986
- const { startContainer, endContainer, startOffset, endOffset } = range;
1013
+ export const deleteContentBackward = ($root, range) => {
1014
+ const {
1015
+ startContainer,
1016
+ endContainer,
1017
+ startOffset,
1018
+ endOffset
1019
+ } = range;
987
1020
  if (startContainer === endContainer && startOffset + 1 === endOffset && isTextNode(startContainer)) {
988
1021
  if (startContainer.length > 1) {
989
1022
  return DEFAULT_ACTION_RESULT;
@@ -1033,14 +1066,17 @@ const deleteContentBackward = ($root, range) => {
1033
1066
  }
1034
1067
  return {
1035
1068
  prevent: true,
1036
- range: createCollapsedRange(
1037
- removeContentInRange(range)
1038
- )
1069
+ range: createCollapsedRange(removeContentInRange(range))
1039
1070
  };
1040
1071
  };
1041
- const insertLink = ($root, text, href, range) => {
1072
+ export const insertLink = ($root, text, href, range) => {
1042
1073
  const cursor = removeContentInRange(range);
1043
- const { $text, $inline, offset, isAfterInline: isAfterLastChild } = cursor;
1074
+ const {
1075
+ $text,
1076
+ $inline,
1077
+ offset,
1078
+ isAfterInline: isAfterLastChild
1079
+ } = cursor;
1044
1080
  const $link = createLink(text, href, $root.ownerDocument);
1045
1081
  if (isTextNode($text)) {
1046
1082
  if (isEmptyText($text.nodeValue)) {
@@ -1061,23 +1097,24 @@ const insertLink = ($root, text, href, range) => {
1061
1097
  }
1062
1098
  return {
1063
1099
  prevent: true,
1064
- range: createCollapsedRange(
1065
- createEndCursorFromTextContent($link)
1066
- )
1100
+ range: createCollapsedRange(createEndCursorFromTextContent($link))
1067
1101
  };
1068
1102
  };
1069
- const insertLineBreak = (range) => {
1103
+ export const insertLineBreak = range => {
1070
1104
  const cursor = removeContentInRange(range);
1071
- const { $text, $inline, offset, isAfterInline: isAfterLastChild } = cursor;
1105
+ const {
1106
+ $text,
1107
+ $inline,
1108
+ offset,
1109
+ isAfterInline: isAfterLastChild
1110
+ } = cursor;
1072
1111
  const $block = getParentTextBlock($inline);
1073
1112
  if (isListItem($block)) {
1074
1113
  if (isEmptyTextBlock($block)) {
1075
1114
  convertToParagraph($block);
1076
1115
  return {
1077
1116
  prevent: true,
1078
- range: createCollapsedRange(
1079
- createEndCursorFromTextContent(getLastTextContent($block))
1080
- )
1117
+ range: createCollapsedRange(createEndCursorFromTextContent(getLastTextContent($block)))
1081
1118
  };
1082
1119
  }
1083
1120
  }
@@ -1091,14 +1128,17 @@ const insertLineBreak = (range) => {
1091
1128
  const [_, $bBlock] = splitTextBlock($block, splitIndex);
1092
1129
  return {
1093
1130
  prevent: true,
1094
- range: createCollapsedRange(
1095
- createBeginCursorFromTextContent(getFirstTextContent($bBlock))
1096
- )
1131
+ range: createCollapsedRange(createBeginCursorFromTextContent(getFirstTextContent($bBlock)))
1097
1132
  };
1098
1133
  };
1099
1134
  const insertEmoji = ($root, emojiChar, range) => {
1100
1135
  const cursor = removeContentInRange(range);
1101
- const { $text, $inline, offset, isAfterInline } = cursor;
1136
+ const {
1137
+ $text,
1138
+ $inline,
1139
+ offset,
1140
+ isAfterInline
1141
+ } = cursor;
1102
1142
  const baseUrl = getEmojiBaseUrl($root);
1103
1143
  const $emoji = createEmoji(emojiChar, baseUrl, $root.ownerDocument);
1104
1144
  if (isTextNode($text)) {
@@ -1120,22 +1160,16 @@ const insertEmoji = ($root, emojiChar, range) => {
1120
1160
  }
1121
1161
  return {
1122
1162
  prevent: true,
1123
- range: createCollapsedRange(
1124
- createEndCursorFromTextContent($emoji)
1125
- )
1163
+ range: createCollapsedRange(createEndCursorFromTextContent($emoji))
1126
1164
  };
1127
1165
  };
1128
- const insertText = ($root, data, range) => {
1166
+ export const insertText = ($root, data, range) => {
1129
1167
  if (data !== null && isEmojiString(data)) {
1130
1168
  return insertEmoji($root, data, range);
1131
1169
  }
1132
- if (
1133
- // Is collapsed range
1134
- range.startContainer === range.endContainer && range.startOffset === range.endOffset && // Is non-empty text node
1135
- isTextNode(range.startContainer) && !isEmptyText(range.startContainer.nodeValue)
1136
- ) {
1137
- const $inline2 = getParentInline(range.startContainer);
1138
- const isHotTextWhitespace = range.startOffset === range.startContainer.length && data === TEXT_WHITESPACE && (isFormatCodetag($inline2) || isFormatLink($inline2));
1170
+ if (range.startContainer === range.endContainer && range.startOffset === range.endOffset && isTextNode(range.startContainer) && !isEmptyText(range.startContainer.nodeValue)) {
1171
+ const $inline = getParentInline(range.startContainer);
1172
+ const isHotTextWhitespace = range.startOffset === range.startContainer.length && data === TEXT_WHITESPACE && (isFormatCodetag($inline) || isFormatLink($inline));
1139
1173
  if (!isHotTextWhitespace) {
1140
1174
  return DEFAULT_ACTION_RESULT;
1141
1175
  }
@@ -1147,7 +1181,12 @@ const insertText = ($root, data, range) => {
1147
1181
  range: createCollapsedRange(cursor)
1148
1182
  };
1149
1183
  }
1150
- const { $text, $inline, offset, isAfterInline } = cursor;
1184
+ const {
1185
+ $text,
1186
+ $inline,
1187
+ offset,
1188
+ isAfterInline
1189
+ } = cursor;
1151
1190
  if ($text === null && isEmoji($inline)) {
1152
1191
  const $newInline = createInlineWithText(data, $root.ownerDocument);
1153
1192
  if (isAfterInline === true) {
@@ -1157,9 +1196,7 @@ const insertText = ($root, data, range) => {
1157
1196
  }
1158
1197
  return {
1159
1198
  prevent: true,
1160
- range: createCollapsedRange(
1161
- createEndCursorFromTextContent($newInline)
1162
- )
1199
+ range: createCollapsedRange(createEndCursorFromTextContent($newInline))
1163
1200
  };
1164
1201
  }
1165
1202
  if (isTextNode($text)) {
@@ -1168,9 +1205,7 @@ const insertText = ($root, data, range) => {
1168
1205
  $text.nodeValue = data;
1169
1206
  return {
1170
1207
  prevent: true,
1171
- range: createCollapsedRange(
1172
- createCursorFromTextNode($text, data.length)
1173
- )
1208
+ range: createCollapsedRange(createCursorFromTextNode($text, data.length))
1174
1209
  };
1175
1210
  }
1176
1211
  if (offset === $text.length && data === TEXT_WHITESPACE) {
@@ -1179,9 +1214,7 @@ const insertText = ($root, data, range) => {
1179
1214
  $inline.after($newinline);
1180
1215
  return {
1181
1216
  prevent: true,
1182
- range: createCollapsedRange(
1183
- createEndCursorFromTextContent($newinline)
1184
- )
1217
+ range: createCollapsedRange(createEndCursorFromTextContent($newinline))
1185
1218
  };
1186
1219
  }
1187
1220
  }
@@ -1189,9 +1222,7 @@ const insertText = ($root, data, range) => {
1189
1222
  $text.nodeValue = content.substring(0, offset) + data + content.substring(offset);
1190
1223
  return {
1191
1224
  prevent: true,
1192
- range: createCollapsedRange(
1193
- createCursorFromTextNode($text, offset + data.length)
1194
- )
1225
+ range: createCollapsedRange(createCursorFromTextNode($text, offset + data.length))
1195
1226
  };
1196
1227
  }
1197
1228
  return {
@@ -1199,9 +1230,14 @@ const insertText = ($root, data, range) => {
1199
1230
  range: createCollapsedRange(cursor)
1200
1231
  };
1201
1232
  };
1202
- const insertFromPaste = (data, range, visitor) => {
1233
+ export const insertFromPaste = (data, range, visitor) => {
1203
1234
  const cursor = removeContentInRange(range);
1204
- const { $text, $inline, offset, isAfterInline } = cursor;
1235
+ const {
1236
+ $text,
1237
+ $inline,
1238
+ offset,
1239
+ isAfterInline
1240
+ } = cursor;
1205
1241
  const $mdFragment = parseMarkdown(data, visitor);
1206
1242
  if ($mdFragment.childNodes.length === 0) {
1207
1243
  return {
@@ -1211,7 +1247,7 @@ const insertFromPaste = (data, range, visitor) => {
1211
1247
  }
1212
1248
  const shouldSpreadNodesIntoBlock = $mdFragment.childNodes.length === 1;
1213
1249
  if (shouldSpreadNodesIntoBlock) {
1214
- const $block2 = getParentTextBlock($inline);
1250
+ const $block = getParentTextBlock($inline);
1215
1251
  const $fragment = document.createDocumentFragment();
1216
1252
  $fragment.append(...Array.from($mdFragment.childNodes[0].childNodes));
1217
1253
  const $pasteLastChild = $fragment.lastChild;
@@ -1220,7 +1256,7 @@ const insertFromPaste = (data, range, visitor) => {
1220
1256
  }
1221
1257
  if (isTextNode($text)) {
1222
1258
  if (isEmptyText($text.nodeValue)) {
1223
- $block2.replaceChild($fragment, $inline);
1259
+ $block.replaceChild($fragment, $inline);
1224
1260
  } else {
1225
1261
  const [$before, $after] = splitTextNode($text, offset);
1226
1262
  if ($before === null) {
@@ -1237,9 +1273,7 @@ const insertFromPaste = (data, range, visitor) => {
1237
1273
  }
1238
1274
  return {
1239
1275
  prevent: true,
1240
- range: createCollapsedRange(
1241
- createEndCursorFromTextContent($pasteLastChild ?? getLastTextContent($block2))
1242
- )
1276
+ range: createCollapsedRange(createEndCursorFromTextContent($pasteLastChild ?? getLastTextContent($block)))
1243
1277
  };
1244
1278
  }
1245
1279
  const $block = getParentTextBlock($inline);
@@ -1270,46 +1304,39 @@ const insertFromPaste = (data, range, visitor) => {
1270
1304
  }
1271
1305
  return {
1272
1306
  prevent: true,
1273
- range: createCollapsedRange(
1274
- createEndCursorFromTextContent(
1275
- getLastTextContent($lastBlock)
1276
- )
1277
- )
1307
+ range: createCollapsedRange(createEndCursorFromTextContent(getLastTextContent($lastBlock)))
1278
1308
  };
1279
1309
  };
1280
1310
  const DEFAULT_ACTION_RESULT = {
1281
1311
  prevent: false
1282
1312
  };
1283
- const handleEmojiMousedown = ($n) => {
1313
+ export const handleEmojiMousedown = $n => {
1284
1314
  if (isEmoji($n)) {
1285
1315
  return {
1286
1316
  prevent: true,
1287
- range: createCollapsedRange(
1288
- createEndCursorFromTextContent($n)
1289
- )
1317
+ range: createCollapsedRange(createEndCursorFromTextContent($n))
1290
1318
  };
1291
1319
  }
1292
1320
  return DEFAULT_ACTION_RESULT;
1293
1321
  };
1294
- const getBeginRange = ($root) => {
1322
+ export const getBeginRange = $root => {
1295
1323
  const $block = getFirstTextBlock($root);
1296
1324
  const $inline = getFirstTextContent($block);
1297
- return createCollapsedRange(
1298
- createBeginCursorFromTextContent($inline)
1299
- );
1325
+ return createCollapsedRange(createBeginCursorFromTextContent($inline));
1300
1326
  };
1301
- const getEndRange = ($root) => {
1327
+ export const getEndRange = $root => {
1302
1328
  const $block = getLastTextBlock($root);
1303
1329
  const $inline = getLastTextContent($block);
1304
- return createCollapsedRange(
1305
- createEndCursorFromTextContent($inline)
1306
- );
1330
+ return createCollapsedRange(createEndCursorFromTextContent($inline));
1307
1331
  };
1308
- const getSelectionInfo = (range) => {
1332
+ export const getSelectionInfo = range => {
1309
1333
  const aCursor = createIncomingCursorFromNodeWithOffset(range.startContainer, range.startOffset);
1310
1334
  const bCursor = createIncomingCursorFromNodeWithOffset(range.endContainer, range.endOffset);
1311
1335
  if (aCursor.$inline === bCursor.$inline) {
1312
- const { $text, $inline } = aCursor;
1336
+ const {
1337
+ $text,
1338
+ $inline
1339
+ } = aCursor;
1313
1340
  if ($text !== null || isInline($inline)) {
1314
1341
  assertInline($inline);
1315
1342
  return {
@@ -1342,19 +1369,19 @@ const getSelectionInfo = (range) => {
1342
1369
  ulist: isAllInsideList(false, aCursor.$inline, bCursor.$inline)
1343
1370
  };
1344
1371
  };
1345
- const isSelectionEqual = (a, b) => {
1372
+ export const isSelectionEqual = (a, b) => {
1346
1373
  return a === b || a !== null && b !== null && a.bold === b.bold && a.codetag === b.codetag && a.italic === b.italic && a.link === b.link && a.strikethrough === b.strikethrough && a.olist === b.olist && a.ulist === b.ulist;
1347
1374
  };
1348
- const isEmptyTextBlock = ($block) => {
1375
+ const isEmptyTextBlock = $block => {
1349
1376
  const blockChildren = $block.childNodes;
1350
1377
  if (blockChildren.length > 1) {
1351
1378
  return false;
1352
1379
  }
1353
1380
  const $inline = blockChildren[0];
1354
- const isEmptyText2 = isInline($inline) && !isFormatCodetag($inline) && isEmptyTextNode(getChildText($inline));
1355
- return isEmptyText2;
1381
+ const isEmptyText = isInline($inline) && !isFormatCodetag($inline) && isEmptyTextNode(getChildText($inline));
1382
+ return isEmptyText;
1356
1383
  };
1357
- const isEditorEmpty = ($root) => {
1384
+ export const isEditorEmpty = $root => {
1358
1385
  const rootChildren = $root.childNodes;
1359
1386
  if (rootChildren.length > 1) {
1360
1387
  return false;
@@ -1363,16 +1390,19 @@ const isEditorEmpty = ($root) => {
1363
1390
  assertTextBlock($block);
1364
1391
  return isEmptyTextBlock($block);
1365
1392
  };
1366
- const serializeDescriptorReducer = (range) => (state, $n) => {
1393
+ const serializeDescriptorReducer = range => (state, $n) => {
1367
1394
  if (isEmoji($n)) {
1368
- const text2 = $n.getAttribute(EMOJI_CHAR_ATTR_NAME) ?? "";
1369
- if (text2.length > 0) {
1370
- state.push({ isEmoji: true, text: text2 });
1395
+ const text = $n.getAttribute(EMOJI_CHAR_ATTR_NAME) ?? '';
1396
+ if (text.length > 0) {
1397
+ state.push({
1398
+ isEmoji: true,
1399
+ text
1400
+ });
1371
1401
  }
1372
1402
  return state;
1373
1403
  }
1374
1404
  let text = getTextValue(getChildText($n));
1375
- let trailingSpaces = "";
1405
+ let trailingSpaces = '';
1376
1406
  if (range !== null) {
1377
1407
  const [aCursor, bCursor] = range;
1378
1408
  const isACursorPointingHere = aCursor.$inline === $n;
@@ -1389,21 +1419,34 @@ const serializeDescriptorReducer = (range) => (state, $n) => {
1389
1419
  return state;
1390
1420
  }
1391
1421
  if (isFormatCodetag($n)) {
1392
- state.push({ isCodetag: true, text });
1422
+ state.push({
1423
+ isCodetag: true,
1424
+ text
1425
+ });
1393
1426
  return state;
1394
1427
  }
1395
1428
  if (isFormatLink($n)) {
1396
- const href = $n.getAttribute(LINK_HREF_ATTR_NAME) ?? "#";
1397
- state.push({ isLink: true, text, href });
1429
+ const href = $n.getAttribute(LINK_HREF_ATTR_NAME) ?? '#';
1430
+ state.push({
1431
+ isLink: true,
1432
+ text,
1433
+ href
1434
+ });
1398
1435
  return state;
1399
1436
  }
1400
1437
  const leadingNonSpaceIndex = text.search(/\S/);
1401
1438
  if (leadingNonSpaceIndex < 0) {
1402
- state.push({ isWhitespace: true, text });
1439
+ state.push({
1440
+ isWhitespace: true,
1441
+ text
1442
+ });
1403
1443
  return state;
1404
1444
  }
1405
1445
  if (leadingNonSpaceIndex > 0) {
1406
- state.push({ isWhitespace: true, text: text.substring(0, leadingNonSpaceIndex) });
1446
+ state.push({
1447
+ isWhitespace: true,
1448
+ text: text.substring(0, leadingNonSpaceIndex)
1449
+ });
1407
1450
  text = text.substring(leadingNonSpaceIndex);
1408
1451
  }
1409
1452
  const trailingSpaceIndex = text.search(/\s+$/);
@@ -1418,25 +1461,30 @@ const serializeDescriptorReducer = (range) => (state, $n) => {
1418
1461
  text
1419
1462
  });
1420
1463
  if (trailingSpaces.length > 0) {
1421
- state.push({ isWhitespace: true, text: trailingSpaces });
1464
+ state.push({
1465
+ isWhitespace: true,
1466
+ text: trailingSpaces
1467
+ });
1422
1468
  }
1423
1469
  return state;
1424
1470
  };
1425
- const MD_STRIKE_TOKEN = "~~";
1426
- const MD_EM3_STAR_TOKEN = "***";
1427
- const MD_EM2_STAR_TOKEN = "**";
1428
- const MD_EM1_STAR_TOKEN = "*";
1429
- const MD_EM3_UNDERSCORE_TOKEN = "___";
1430
- const MD_EM2_UNDERSCORE_TOKEN = "__";
1431
- const MD_EM1_UNDERSCORE_TOKEN = "_";
1432
- const MD_LINEBREAK_TOKEN = " \n";
1433
- const MD_CODETAG_TOKEN = "`";
1434
- const MD_ULISTITEM_TOKEN = "*";
1435
- const MD_OLISTITEM_TOKEN = "1.";
1436
- const MD_LISTITEM_JOIN = "\n";
1437
- const MD_PARAGRAPH_JOIN = "\n\n";
1471
+ const MD_STRIKE_TOKEN = '~~';
1472
+ const MD_EM3_STAR_TOKEN = '***';
1473
+ const MD_EM2_STAR_TOKEN = '**';
1474
+ const MD_EM1_STAR_TOKEN = '*';
1475
+ const MD_EM3_UNDERSCORE_TOKEN = '___';
1476
+ const MD_EM2_UNDERSCORE_TOKEN = '__';
1477
+ const MD_EM1_UNDERSCORE_TOKEN = '_';
1478
+ const MD_LINEBREAK_TOKEN = ' \n';
1479
+ const MD_CODETAG_TOKEN = '`';
1480
+ const MD_ULISTITEM_TOKEN = '*';
1481
+ const MD_OLISTITEM_TOKEN = '1.';
1482
+ const MD_LISTITEM_JOIN = '\n';
1483
+ const MD_PARAGRAPH_JOIN = '\n\n';
1438
1484
  const serializeTextReducer = (state, desc, i, descArray) => {
1439
- const { chunks } = state;
1485
+ const {
1486
+ chunks
1487
+ } = state;
1440
1488
  if (desc.isLink === true) {
1441
1489
  chunks.push(`[${desc.text}](${desc.href})`);
1442
1490
  return state;
@@ -1456,7 +1504,11 @@ const serializeTextReducer = (state, desc, i, descArray) => {
1456
1504
  const prev = i === 0 ? null : descArray[i - 1];
1457
1505
  const next = i >= descArray.length - 1 ? null : descArray[i + 1];
1458
1506
  const shouldUseUnderscores = (i - state.lastUnderscoreIndex) % 2 === 0 && (prev === null || prev.isBold === true || prev.isItalic === true || prev.isWhitespace === true || prev.isCodetag === true) && (next === null || next.isBold === true || next.isItalic === true || next.isWhitespace === true || next.isCodetag === true);
1459
- const { isBold, isItalic, isStrikethrough } = desc;
1507
+ const {
1508
+ isBold,
1509
+ isItalic,
1510
+ isStrikethrough
1511
+ } = desc;
1460
1512
  if (shouldUseUnderscores) {
1461
1513
  state.lastUnderscoreIndex = i;
1462
1514
  }
@@ -1495,26 +1547,16 @@ const serializeTextBlock = ($n, range) => {
1495
1547
  } else {
1496
1548
  children = Array.from($n.childNodes);
1497
1549
  }
1498
- const result = children.reduce(
1499
- serializeDescriptorReducer(range),
1500
- []
1501
- ).reduce(
1502
- serializeTextReducer,
1503
- {
1504
- lastUnderscoreIndex: 0,
1505
- chunks: []
1506
- }
1507
- );
1508
- return result.chunks.join("");
1550
+ const result = children.reduce(serializeDescriptorReducer(range), []).reduce(serializeTextReducer, {
1551
+ lastUnderscoreIndex: 0,
1552
+ chunks: []
1553
+ });
1554
+ return result.chunks.join('');
1509
1555
  };
1510
1556
  const serializeListItemIndent = (level, isOrderedStack) => {
1511
- let res = "";
1557
+ let res = '';
1512
1558
  for (let i = 0; i < level; i++) {
1513
- res = res.concat(
1514
- isOrderedStack[i] ? " " : " ",
1515
- // MD_ULISTITEM_TOKEN.length
1516
- " "
1517
- );
1559
+ res = res.concat(isOrderedStack[i] ? ' ' : ' ', ' ');
1518
1560
  }
1519
1561
  return res;
1520
1562
  };
@@ -1543,19 +1585,15 @@ const serializeRoot = ($root, range) => {
1543
1585
  const paragraphChunks = [];
1544
1586
  const flushListChunks = () => {
1545
1587
  if (listChunks.length > 0) {
1546
- chunks.push(
1547
- listChunks.join(MD_LISTITEM_JOIN)
1548
- );
1588
+ chunks.push(listChunks.join(MD_LISTITEM_JOIN));
1549
1589
  listChunks.length = 0;
1550
1590
  }
1551
1591
  };
1552
1592
  const flushParagraphChunks = () => {
1553
1593
  if (paragraphChunks.length > 0) {
1554
- chunks.push(
1555
- paragraphChunks.reduce((a, b) => {
1556
- return b.length > 0 ? a.concat(MD_LINEBREAK_TOKEN, b) : a.concat("<br>");
1557
- })
1558
- );
1594
+ chunks.push(paragraphChunks.reduce((a, b) => {
1595
+ return b.length > 0 ? a.concat(MD_LINEBREAK_TOKEN, b) : a.concat('<br>');
1596
+ }));
1559
1597
  paragraphChunks.length = 0;
1560
1598
  }
1561
1599
  };
@@ -1567,22 +1605,18 @@ const serializeRoot = ($root, range) => {
1567
1605
  if (isMainList) {
1568
1606
  flushListChunks();
1569
1607
  }
1570
- listChunks.push(
1571
- serializeListItem($child, listIsOrderedStack, range)
1572
- );
1608
+ listChunks.push(serializeListItem($child, listIsOrderedStack, range));
1573
1609
  } else {
1574
1610
  assertTextBlock($child);
1575
1611
  flushListChunks();
1576
- paragraphChunks.push(
1577
- serializeTextBlock($child, range)
1578
- );
1612
+ paragraphChunks.push(serializeTextBlock($child, range));
1579
1613
  }
1580
1614
  }
1581
1615
  flushListChunks();
1582
1616
  flushParagraphChunks();
1583
1617
  return chunks.join(MD_PARAGRAPH_JOIN);
1584
1618
  };
1585
- const serializeMarkdown = ($root, range) => {
1619
+ export const serializeMarkdown = ($root, range) => {
1586
1620
  if (range !== null) {
1587
1621
  const aCursor = createIncomingCursorFromNodeWithOffset(range.startContainer, range.startOffset);
1588
1622
  const bCursor = createIncomingCursorFromNodeWithOffset(range.endContainer, range.endOffset);
@@ -1590,7 +1624,7 @@ const serializeMarkdown = ($root, range) => {
1590
1624
  }
1591
1625
  return serializeRoot($root, null);
1592
1626
  };
1593
- const createParseVisitor = (doc) => {
1627
+ export const createParseVisitor = doc => {
1594
1628
  let emojiBaseUrl = null;
1595
1629
  return {
1596
1630
  updateEmojiBaseUrl(url) {
@@ -1617,14 +1651,19 @@ const createParseVisitor = (doc) => {
1617
1651
  },
1618
1652
  codetag(text) {
1619
1653
  const $inline = createInlineWithText(text, doc);
1620
- setInlineFormat($inline, "c", true);
1654
+ setInlineFormat($inline, 'c', true);
1621
1655
  $currentBlock.appendChild($inline);
1622
1656
  },
1623
- inline(text, { isBold, isItalic, isStrikethrough }) {
1657
+ inline(text, _ref2) {
1658
+ let {
1659
+ isBold,
1660
+ isItalic,
1661
+ isStrikethrough
1662
+ } = _ref2;
1624
1663
  const $inline = createInlineWithText(text, doc);
1625
- setInlineFormat($inline, "b", isBold === true);
1626
- setInlineFormat($inline, "i", isItalic === true);
1627
- setInlineFormat($inline, "s", isStrikethrough === true);
1664
+ setInlineFormat($inline, 'b', isBold === true);
1665
+ setInlineFormat($inline, 'i', isItalic === true);
1666
+ setInlineFormat($inline, 's', isStrikethrough === true);
1628
1667
  $currentBlock.appendChild($inline);
1629
1668
  },
1630
1669
  linebreak() {
@@ -1651,7 +1690,9 @@ const createParseVisitor = (doc) => {
1651
1690
  },
1652
1691
  listItem() {
1653
1692
  const listLevel = listsStack.length - 1;
1654
- const { isOrdered } = listsStack.at(-1);
1693
+ const {
1694
+ isOrdered
1695
+ } = listsStack.at(-1);
1655
1696
  const $li = createActuallyEmptyListItem(isOrdered, listLevel, doc);
1656
1697
  if (listsStack.length === 1 && isFirstListItem) {
1657
1698
  markListItemAsBlock($li);
@@ -1679,7 +1720,13 @@ const createParseVisitor = (doc) => {
1679
1720
  }
1680
1721
  };
1681
1722
  };
1682
- const setBrowserCaret = ({ startContainer, startOffset, endContainer, endOffset }) => {
1723
+ export const setBrowserCaret = _ref3 => {
1724
+ let {
1725
+ startContainer,
1726
+ startOffset,
1727
+ endContainer,
1728
+ endOffset
1729
+ } = _ref3;
1683
1730
  const selection = document.getSelection();
1684
1731
  if (selection === null) {
1685
1732
  return;
@@ -1689,24 +1736,4 @@ const setBrowserCaret = ({ startContainer, startOffset, endContainer, endOffset
1689
1736
  range.setStart(startContainer, startOffset);
1690
1737
  range.setEnd(endContainer, endOffset);
1691
1738
  selection.addRange(range);
1692
- };
1693
- export {
1694
- createParseVisitor,
1695
- deleteContentBackward,
1696
- formatIndent,
1697
- formatInline,
1698
- formatList,
1699
- formatOutdent,
1700
- getBeginRange,
1701
- getEndRange,
1702
- getSelectionInfo,
1703
- handleEmojiMousedown,
1704
- insertFromPaste,
1705
- insertLineBreak,
1706
- insertLink,
1707
- insertText,
1708
- isEditorEmpty,
1709
- isSelectionEqual,
1710
- serializeMarkdown,
1711
- setBrowserCaret
1712
- };
1739
+ };