@youcan/celeste 0.6.57 → 0.6.60

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 (449) hide show
  1. package/dist/celeste.css +3316 -2516
  2. package/dist/cjs/alert.js +1 -0
  3. package/dist/cjs/badge.js +1 -0
  4. package/dist/cjs/button.js +1 -0
  5. package/dist/cjs/checkbox-card.js +1 -0
  6. package/dist/cjs/checkbox-label.js +1 -0
  7. package/dist/cjs/checkbox.js +3 -2
  8. package/dist/cjs/chunks/alpha-slider.js +1 -1
  9. package/dist/cjs/chunks/collapsible-content.js +27 -0
  10. package/dist/cjs/chunks/collapsible-trigger.js +22 -0
  11. package/dist/cjs/chunks/collapsible.js +28 -0
  12. package/dist/cjs/chunks/index.js +385 -1
  13. package/dist/cjs/chunks/index2.js +18 -0
  14. package/dist/cjs/chunks/index3.js +240 -1425
  15. package/dist/cjs/chunks/index4.js +1336 -16336
  16. package/dist/cjs/chunks/index5.js +16457 -0
  17. package/dist/cjs/chunks/pagination-first.js +32 -0
  18. package/dist/cjs/chunks/pagination-item.js +32 -0
  19. package/dist/cjs/chunks/pagination-last.js +32 -0
  20. package/dist/cjs/chunks/pagination-next.js +32 -0
  21. package/dist/cjs/chunks/pagination-previous.js +32 -0
  22. package/dist/cjs/chunks/rich-editor.vue_vue_type_style_index_0_scoped_dbc85b1a_lang.js +4575 -0
  23. package/dist/cjs/chunks/sheet-trigger.js +22 -0
  24. package/dist/cjs/chunks/sheet.js +26 -0
  25. package/dist/cjs/chunks/sidebar-content.js +21 -0
  26. package/dist/cjs/chunks/sidebar-element.js +28 -0
  27. package/dist/cjs/chunks/sidebar-footer.js +21 -0
  28. package/dist/cjs/chunks/sidebar-group-label.js +29 -0
  29. package/dist/cjs/chunks/sidebar-group.js +21 -0
  30. package/dist/cjs/chunks/sidebar-header.js +21 -0
  31. package/dist/cjs/chunks/sidebar-menu-action.js +34 -0
  32. package/dist/cjs/chunks/sidebar-menu-badge.js +29 -0
  33. package/dist/cjs/chunks/sidebar-menu-button.js +39 -0
  34. package/dist/cjs/chunks/sidebar-menu-item.js +21 -0
  35. package/dist/cjs/chunks/sidebar-menu-sub-button.js +37 -0
  36. package/dist/cjs/chunks/sidebar-menu-sub-item.js +21 -0
  37. package/dist/cjs/chunks/sidebar-menu-sub.js +21 -0
  38. package/dist/cjs/chunks/sidebar-menu.js +21 -0
  39. package/dist/cjs/chunks/sidebar-provider.vue_vue_type_style_index_0_lang.js +63 -0
  40. package/dist/cjs/chunks/sidebar-separator.vue_vue_type_style_index_0_lang.js +128 -0
  41. package/dist/cjs/chunks/sidebar.js +84 -0
  42. package/dist/cjs/chunks/{use-color-model.js → tinycolor.js} +0 -30
  43. package/dist/cjs/chunks/tooltip-provider.js +26 -0
  44. package/dist/cjs/chunks/tooltip-root.js +36 -0
  45. package/dist/cjs/chunks/tooltip-trigger.js +23 -0
  46. package/dist/cjs/chunks/tooltip.js +84 -0
  47. package/dist/cjs/collapsible-content.js +4 -0
  48. package/dist/cjs/collapsible-trigger.js +3 -0
  49. package/dist/cjs/collapsible.js +3 -0
  50. package/dist/cjs/color-area.js +2 -1
  51. package/dist/cjs/color-picker.js +13 -11
  52. package/dist/cjs/color-swatch.js +5 -3
  53. package/dist/cjs/combobox-empty.js +1 -0
  54. package/dist/cjs/combobox-group.js +1 -0
  55. package/dist/cjs/combobox-input.js +1 -0
  56. package/dist/cjs/combobox-item.js +4 -2
  57. package/dist/cjs/combobox-list.js +1 -0
  58. package/dist/cjs/combobox-root.js +1 -0
  59. package/dist/cjs/combobox-separator.js +1 -0
  60. package/dist/cjs/combobox-trigger.js +1 -0
  61. package/dist/cjs/combobox.js +1 -0
  62. package/dist/cjs/compact-button.js +1 -0
  63. package/dist/cjs/counter-input.js +3 -2
  64. package/dist/cjs/digit-input-group.js +1 -0
  65. package/dist/cjs/digit-input-slot.js +1 -0
  66. package/dist/cjs/digit-input.js +1 -0
  67. package/dist/cjs/dropdown-menu-content.js +1 -0
  68. package/dist/cjs/dropdown-menu-group.js +1 -0
  69. package/dist/cjs/dropdown-menu-item.js +1 -0
  70. package/dist/cjs/dropdown-menu-label.js +1 -0
  71. package/dist/cjs/dropdown-menu-separator.js +1 -0
  72. package/dist/cjs/dropdown-menu-sub-content.js +1 -0
  73. package/dist/cjs/dropdown-menu-sub-trigger.js +1 -0
  74. package/dist/cjs/dropdown-menu-trigger.js +1 -0
  75. package/dist/cjs/dropdown-menu.js +1 -0
  76. package/dist/cjs/extra-settings.js +3 -2
  77. package/dist/cjs/file-upload-area.js +3 -142
  78. package/dist/cjs/hint-text.js +1 -0
  79. package/dist/cjs/hue-slider.js +1 -0
  80. package/dist/cjs/index.js +180 -21
  81. package/dist/cjs/label.js +3 -2
  82. package/dist/cjs/link-bubble.js +5 -3
  83. package/dist/cjs/modal-body.js +1 -0
  84. package/dist/cjs/modal-content.js +1 -0
  85. package/dist/cjs/modal-footer.js +1 -0
  86. package/dist/cjs/modal-header.js +1 -0
  87. package/dist/cjs/pagination-content.js +31 -0
  88. package/dist/cjs/pagination-ellipsis.js +35 -0
  89. package/dist/cjs/pagination-first.js +3 -0
  90. package/dist/cjs/pagination-item.js +3 -0
  91. package/dist/cjs/pagination-last.js +3 -0
  92. package/dist/cjs/pagination-next.js +3 -0
  93. package/dist/cjs/pagination-previous.js +3 -0
  94. package/dist/cjs/pagination.js +60 -0
  95. package/dist/cjs/popover-content.js +1 -0
  96. package/dist/cjs/popover-trigger.js +1 -0
  97. package/dist/cjs/progress-bar.js +1 -0
  98. package/dist/cjs/progress-circle.js +1 -0
  99. package/dist/cjs/radio-group-card.js +1 -0
  100. package/dist/cjs/radio-group-item.js +3 -2
  101. package/dist/cjs/radio-group-label.js +1 -0
  102. package/dist/cjs/radio-group.js +3 -2
  103. package/dist/cjs/rich-editor.js +11 -4577
  104. package/dist/cjs/scroll-bar.js +1 -0
  105. package/dist/cjs/segmented-control-item.js +1 -0
  106. package/dist/cjs/segmented-control.js +1 -0
  107. package/dist/cjs/select-content.js +1 -0
  108. package/dist/cjs/select-item.js +1 -0
  109. package/dist/cjs/select-trigger.js +1 -0
  110. package/dist/cjs/select-value.js +1 -0
  111. package/dist/cjs/sheet-close.js +29 -0
  112. package/dist/cjs/sheet-content.js +61 -0
  113. package/dist/cjs/sheet-description.js +31 -0
  114. package/dist/cjs/sheet-footer.js +28 -0
  115. package/dist/cjs/sheet-header.js +23 -0
  116. package/dist/cjs/sheet-title.js +31 -0
  117. package/dist/cjs/sheet-trigger.js +3 -0
  118. package/dist/cjs/sheet.js +3 -0
  119. package/dist/cjs/sidebar-content.js +4 -0
  120. package/dist/cjs/sidebar-element.js +4 -0
  121. package/dist/cjs/sidebar-footer.js +4 -0
  122. package/dist/cjs/sidebar-group-content.js +24 -0
  123. package/dist/cjs/sidebar-group-label.js +4 -0
  124. package/dist/cjs/sidebar-group.js +4 -0
  125. package/dist/cjs/sidebar-header.js +4 -0
  126. package/dist/cjs/sidebar-menu-action.js +4 -0
  127. package/dist/cjs/sidebar-menu-badge.js +4 -0
  128. package/dist/cjs/sidebar-menu-button.js +4 -0
  129. package/dist/cjs/sidebar-menu-item.js +4 -0
  130. package/dist/cjs/sidebar-menu-sub-button.js +4 -0
  131. package/dist/cjs/sidebar-menu-sub-item.js +4 -0
  132. package/dist/cjs/sidebar-menu-sub.js +4 -0
  133. package/dist/cjs/sidebar-menu.js +4 -0
  134. package/dist/cjs/sidebar-provider.js +3 -0
  135. package/dist/cjs/sidebar-separator.js +3 -0
  136. package/dist/cjs/sidebar-trigger.js +34 -0
  137. package/dist/cjs/sidebar.js +4 -0
  138. package/dist/cjs/slider.js +3 -2
  139. package/dist/cjs/sonner-alert.js +1 -0
  140. package/dist/cjs/status-badge.js +1 -0
  141. package/dist/cjs/switch.js +3 -2
  142. package/dist/cjs/tab-menu-content.js +1 -0
  143. package/dist/cjs/tab-menu-item.js +1 -0
  144. package/dist/cjs/tab-menu-list.js +1 -0
  145. package/dist/cjs/tab-menu.js +1 -0
  146. package/dist/cjs/tag.js +1 -0
  147. package/dist/cjs/text-input-button.js +1 -0
  148. package/dist/cjs/text-input.js +1 -0
  149. package/dist/cjs/textarea.js +1 -0
  150. package/dist/cjs/tooltip-content.js +94 -0
  151. package/dist/cjs/tooltip-provider.js +3 -0
  152. package/dist/cjs/tooltip-root.js +3 -0
  153. package/dist/cjs/tooltip-trigger.js +3 -0
  154. package/dist/cjs/tooltip.js +2 -114
  155. package/dist/cjs/use-color-model.js +31 -4
  156. package/dist/cjs/use-sidebar.js +18 -0
  157. package/dist/components/collapsible/collapsible-content.d.ts +14 -0
  158. package/dist/components/collapsible/collapsible-trigger.d.ts +12 -0
  159. package/dist/components/collapsible/collapsible.d.ts +18 -0
  160. package/dist/components/collapsible/index.d.ts +6 -0
  161. package/dist/components/combobox/combobox-root.d.ts +2 -2
  162. package/dist/components/combobox/combobox.d.ts +2 -2
  163. package/dist/components/index.d.ts +4 -0
  164. package/dist/components/pagination/index.d.ts +16 -0
  165. package/dist/components/pagination/pagination-content.d.ts +21 -0
  166. package/dist/components/pagination/pagination-ellipsis.d.ts +14 -0
  167. package/dist/components/pagination/pagination-first.d.ts +14 -0
  168. package/dist/components/pagination/pagination-item.d.ts +16 -0
  169. package/dist/components/pagination/pagination-last.d.ts +14 -0
  170. package/dist/components/pagination/pagination-next.d.ts +14 -0
  171. package/dist/components/pagination/pagination-previous.d.ts +14 -0
  172. package/dist/components/pagination/pagination.d.ts +32 -0
  173. package/dist/components/select/select.d.ts +2 -2
  174. package/dist/components/sheet/index.d.ts +16 -0
  175. package/dist/components/sheet/sheet-close.d.ts +14 -0
  176. package/dist/components/sheet/sheet-content.d.ts +31 -0
  177. package/dist/components/sheet/sheet-description.d.ts +14 -0
  178. package/dist/components/sheet/sheet-footer.d.ts +13 -0
  179. package/dist/components/sheet/sheet-header.d.ts +13 -0
  180. package/dist/components/sheet/sheet-title.d.ts +14 -0
  181. package/dist/components/sheet/sheet-trigger.d.ts +12 -0
  182. package/dist/components/sheet/sheet.d.ts +22 -0
  183. package/dist/components/sidebar/index.d.ts +38 -0
  184. package/dist/components/sidebar/sidebar-content.d.ts +21 -0
  185. package/dist/components/sidebar/sidebar-element.d.ts +16 -0
  186. package/dist/components/sidebar/sidebar-footer.d.ts +13 -0
  187. package/dist/components/sidebar/sidebar-group-content.d.ts +21 -0
  188. package/dist/components/sidebar/sidebar-group-label.d.ts +22 -0
  189. package/dist/components/sidebar/sidebar-group.d.ts +21 -0
  190. package/dist/components/sidebar/sidebar-header.d.ts +13 -0
  191. package/dist/components/sidebar/sidebar-menu-action.d.ts +17 -0
  192. package/dist/components/sidebar/sidebar-menu-badge.d.ts +14 -0
  193. package/dist/components/sidebar/sidebar-menu-button.d.ts +28 -0
  194. package/dist/components/sidebar/sidebar-menu-item.d.ts +21 -0
  195. package/dist/components/sidebar/sidebar-menu-sub-button.d.ts +20 -0
  196. package/dist/components/sidebar/sidebar-menu-sub-item.d.ts +21 -0
  197. package/dist/components/sidebar/sidebar-menu-sub.d.ts +21 -0
  198. package/dist/components/sidebar/sidebar-menu.d.ts +21 -0
  199. package/dist/components/sidebar/sidebar-provider.d.ts +30 -0
  200. package/dist/components/sidebar/sidebar-separator.d.ts +6 -0
  201. package/dist/components/sidebar/sidebar-trigger.d.ts +6 -0
  202. package/dist/components/sidebar/sidebar.d.ts +19 -0
  203. package/dist/components/tooltip/index.d.ts +8 -0
  204. package/dist/components/tooltip/tooltip-content.d.ts +31 -0
  205. package/dist/components/tooltip/tooltip-provider.d.ts +14 -0
  206. package/dist/components/tooltip/tooltip-root.d.ts +16 -0
  207. package/dist/components/tooltip/tooltip-trigger.d.ts +12 -0
  208. package/dist/composables/index.d.ts +2 -0
  209. package/dist/composables/use-sidebar.d.ts +56 -0
  210. package/dist/es/alert.js +1 -0
  211. package/dist/es/badge.js +1 -0
  212. package/dist/es/button.js +2 -1
  213. package/dist/es/checkbox-card.js +2 -1
  214. package/dist/es/checkbox-label.js +2 -1
  215. package/dist/es/checkbox.js +2 -1
  216. package/dist/es/chunks/alpha-slider.js +1 -1
  217. package/dist/es/chunks/collapsible-content.js +28 -0
  218. package/dist/es/chunks/collapsible-trigger.js +23 -0
  219. package/dist/es/chunks/collapsible.js +29 -0
  220. package/dist/es/chunks/combobox-anchor.js +1 -1
  221. package/dist/es/chunks/content-divider.vue_vue_type_style_index_0_lang.js +1 -1
  222. package/dist/es/chunks/{counter-input.vue_vue_type_style_index_0_lang.js → counter-input.js} +1 -1
  223. package/dist/es/chunks/index.js +463 -79
  224. package/dist/es/chunks/index2.js +19 -1
  225. package/dist/es/chunks/index3.js +241 -1425
  226. package/dist/es/chunks/index4.js +1335 -16336
  227. package/dist/es/chunks/index5.js +16458 -0
  228. package/dist/es/chunks/pagination-first.js +33 -0
  229. package/dist/es/chunks/pagination-item.js +33 -0
  230. package/dist/es/chunks/pagination-last.js +33 -0
  231. package/dist/es/chunks/pagination-next.js +33 -0
  232. package/dist/es/chunks/pagination-previous.js +33 -0
  233. package/dist/es/chunks/popover.js +1 -1
  234. package/dist/es/chunks/{radio-group-item.vue_vue_type_style_index_0_lang.js → radio-group-item.js} +1 -1
  235. package/dist/es/chunks/rich-editor.vue_vue_type_style_index_0_scoped_dbc85b1a_lang.js +4576 -0
  236. package/dist/es/chunks/select-group.js +1 -1
  237. package/dist/es/chunks/sheet-trigger.js +23 -0
  238. package/dist/es/chunks/sheet.js +27 -0
  239. package/dist/es/chunks/sidebar-content.js +22 -0
  240. package/dist/es/chunks/sidebar-element.js +29 -0
  241. package/dist/es/chunks/sidebar-footer.js +22 -0
  242. package/dist/es/chunks/sidebar-group-label.js +30 -0
  243. package/dist/es/chunks/sidebar-group.js +22 -0
  244. package/dist/es/chunks/sidebar-header.js +22 -0
  245. package/dist/es/chunks/sidebar-menu-action.js +35 -0
  246. package/dist/es/chunks/sidebar-menu-badge.js +30 -0
  247. package/dist/es/chunks/sidebar-menu-button.js +40 -0
  248. package/dist/es/chunks/sidebar-menu-item.js +22 -0
  249. package/dist/es/chunks/sidebar-menu-sub-button.js +38 -0
  250. package/dist/es/chunks/sidebar-menu-sub-item.js +22 -0
  251. package/dist/es/chunks/sidebar-menu-sub.js +22 -0
  252. package/dist/es/chunks/sidebar-menu.js +22 -0
  253. package/dist/es/chunks/sidebar-provider.vue_vue_type_style_index_0_lang.js +64 -0
  254. package/dist/es/chunks/sidebar-separator.vue_vue_type_style_index_0_lang.js +129 -0
  255. package/dist/es/chunks/sidebar.js +85 -0
  256. package/dist/es/chunks/{slider.vue_vue_type_style_index_0_lang.js → slider.js} +1 -1
  257. package/dist/es/chunks/{switch.vue_vue_type_style_index_0_lang.js → switch.js} +1 -1
  258. package/dist/es/chunks/{use-color-model.js → tinycolor.js} +0 -30
  259. package/dist/es/chunks/tooltip-provider.js +27 -0
  260. package/dist/es/chunks/tooltip-root.js +37 -0
  261. package/dist/es/chunks/tooltip-trigger.js +24 -0
  262. package/dist/es/chunks/tooltip.js +85 -0
  263. package/dist/es/collapsible-content.js +5 -0
  264. package/dist/es/collapsible-trigger.js +4 -0
  265. package/dist/es/collapsible.js +4 -0
  266. package/dist/es/color-area.js +2 -1
  267. package/dist/es/color-picker.js +5 -3
  268. package/dist/es/color-swatch.js +3 -1
  269. package/dist/es/combobox-empty.js +1 -0
  270. package/dist/es/combobox-group.js +2 -1
  271. package/dist/es/combobox-input.js +2 -1
  272. package/dist/es/combobox-item.js +3 -1
  273. package/dist/es/combobox-list.js +2 -1
  274. package/dist/es/combobox-root.js +2 -1
  275. package/dist/es/combobox-separator.js +2 -1
  276. package/dist/es/combobox-trigger.js +2 -1
  277. package/dist/es/combobox.js +1 -0
  278. package/dist/es/command-group.js +1 -1
  279. package/dist/es/command-input.js +1 -1
  280. package/dist/es/command-list.js +1 -1
  281. package/dist/es/command-root.js +1 -1
  282. package/dist/es/command-separator.js +1 -1
  283. package/dist/es/compact-button.js +2 -1
  284. package/dist/es/counter-input.js +2 -1
  285. package/dist/es/digit-input-group.js +2 -1
  286. package/dist/es/digit-input-slot.js +2 -1
  287. package/dist/es/digit-input.js +2 -1
  288. package/dist/es/dropdown-menu-content.js +2 -1
  289. package/dist/es/dropdown-menu-group.js +2 -1
  290. package/dist/es/dropdown-menu-item.js +2 -1
  291. package/dist/es/dropdown-menu-label.js +2 -1
  292. package/dist/es/dropdown-menu-separator.js +2 -1
  293. package/dist/es/dropdown-menu-sub-content.js +2 -1
  294. package/dist/es/dropdown-menu-sub-trigger.js +2 -1
  295. package/dist/es/dropdown-menu-trigger.js +2 -1
  296. package/dist/es/dropdown-menu.js +2 -1
  297. package/dist/es/extra-settings.js +3 -2
  298. package/dist/es/fancy-button.js +1 -1
  299. package/dist/es/file-upload-area.js +3 -142
  300. package/dist/es/hint-text.js +1 -0
  301. package/dist/es/hue-slider.js +1 -0
  302. package/dist/es/index.js +212 -53
  303. package/dist/es/label.js +4 -3
  304. package/dist/es/link-bubble.js +4 -2
  305. package/dist/es/link-button.js +1 -1
  306. package/dist/es/modal-body.js +1 -0
  307. package/dist/es/modal-content.js +2 -1
  308. package/dist/es/modal-footer.js +1 -0
  309. package/dist/es/modal-header.js +2 -1
  310. package/dist/es/pagination-content.js +32 -0
  311. package/dist/es/pagination-ellipsis.js +36 -0
  312. package/dist/es/pagination-first.js +4 -0
  313. package/dist/es/pagination-item.js +4 -0
  314. package/dist/es/pagination-last.js +4 -0
  315. package/dist/es/pagination-next.js +4 -0
  316. package/dist/es/pagination-previous.js +4 -0
  317. package/dist/es/pagination.js +61 -0
  318. package/dist/es/popover-content.js +2 -1
  319. package/dist/es/popover-trigger.js +2 -1
  320. package/dist/es/progress-bar.js +2 -1
  321. package/dist/es/progress-circle.js +2 -1
  322. package/dist/es/radio-group-card.js +2 -1
  323. package/dist/es/radio-group-item.js +2 -1
  324. package/dist/es/radio-group-label.js +2 -1
  325. package/dist/es/radio-group.js +2 -1
  326. package/dist/es/rich-editor.js +16 -4582
  327. package/dist/es/scroll-bar.js +2 -1
  328. package/dist/es/segmented-control-item.js +2 -1
  329. package/dist/es/segmented-control.js +2 -1
  330. package/dist/es/select-content.js +2 -1
  331. package/dist/es/select-item.js +2 -1
  332. package/dist/es/select-label.js +1 -1
  333. package/dist/es/select-separator.js +1 -1
  334. package/dist/es/select-trigger.js +2 -1
  335. package/dist/es/select-value.js +2 -1
  336. package/dist/es/sheet-close.js +30 -0
  337. package/dist/es/sheet-content.js +62 -0
  338. package/dist/es/sheet-description.js +32 -0
  339. package/dist/es/sheet-footer.js +29 -0
  340. package/dist/es/sheet-header.js +24 -0
  341. package/dist/es/sheet-title.js +32 -0
  342. package/dist/es/sheet-trigger.js +4 -0
  343. package/dist/es/sheet.js +4 -0
  344. package/dist/es/sidebar-content.js +5 -0
  345. package/dist/es/sidebar-element.js +5 -0
  346. package/dist/es/sidebar-footer.js +5 -0
  347. package/dist/es/sidebar-group-content.js +25 -0
  348. package/dist/es/sidebar-group-label.js +5 -0
  349. package/dist/es/sidebar-group.js +5 -0
  350. package/dist/es/sidebar-header.js +5 -0
  351. package/dist/es/sidebar-menu-action.js +5 -0
  352. package/dist/es/sidebar-menu-badge.js +5 -0
  353. package/dist/es/sidebar-menu-button.js +5 -0
  354. package/dist/es/sidebar-menu-item.js +5 -0
  355. package/dist/es/sidebar-menu-sub-button.js +5 -0
  356. package/dist/es/sidebar-menu-sub-item.js +5 -0
  357. package/dist/es/sidebar-menu-sub.js +5 -0
  358. package/dist/es/sidebar-menu.js +5 -0
  359. package/dist/es/sidebar-provider.js +4 -0
  360. package/dist/es/sidebar-separator.js +4 -0
  361. package/dist/es/sidebar-trigger.js +35 -0
  362. package/dist/es/sidebar.js +5 -0
  363. package/dist/es/slider.js +2 -1
  364. package/dist/es/social-button.js +1 -1
  365. package/dist/es/sonner-alert.js +1 -0
  366. package/dist/es/status-badge.js +1 -0
  367. package/dist/es/switch.js +2 -1
  368. package/dist/es/tab-menu-content.js +2 -1
  369. package/dist/es/tab-menu-item.js +2 -1
  370. package/dist/es/tab-menu-list.js +2 -1
  371. package/dist/es/tab-menu.js +2 -1
  372. package/dist/es/tag.js +2 -1
  373. package/dist/es/text-input-button.js +1 -0
  374. package/dist/es/text-input.js +2 -1
  375. package/dist/es/textarea.js +1 -0
  376. package/dist/es/tooltip-content.js +95 -0
  377. package/dist/es/tooltip-provider.js +4 -0
  378. package/dist/es/tooltip-root.js +4 -0
  379. package/dist/es/tooltip-trigger.js +4 -0
  380. package/dist/es/tooltip.js +2 -114
  381. package/dist/es/use-color-model.js +31 -4
  382. package/dist/es/use-sidebar.js +18 -0
  383. package/dist/index.d.ts +1 -0
  384. package/package.json +4 -3
  385. package/src/components/collapsible/collapsible-content.vue +38 -0
  386. package/src/components/collapsible/collapsible-trigger.vue +16 -0
  387. package/src/components/collapsible/collapsible.vue +19 -0
  388. package/src/components/collapsible/index.ts +6 -0
  389. package/src/components/collapsible/stories/collapsible.stories.ts +67 -0
  390. package/src/components/index.ts +4 -0
  391. package/src/components/pagination/index.ts +23 -0
  392. package/src/components/pagination/pagination-content.vue +36 -0
  393. package/src/components/pagination/pagination-ellipsis.vue +47 -0
  394. package/src/components/pagination/pagination-first.vue +29 -0
  395. package/src/components/pagination/pagination-item.vue +28 -0
  396. package/src/components/pagination/pagination-last.vue +29 -0
  397. package/src/components/pagination/pagination-next.vue +29 -0
  398. package/src/components/pagination/pagination-previous.vue +33 -0
  399. package/src/components/pagination/pagination.vue +157 -0
  400. package/src/components/pagination/stories/pagination.stories.ts +154 -0
  401. package/src/components/sheet/index.ts +16 -0
  402. package/src/components/sheet/sheet-close.vue +26 -0
  403. package/src/components/sheet/sheet-content.vue +163 -0
  404. package/src/components/sheet/sheet-description.vue +33 -0
  405. package/src/components/sheet/sheet-footer.vue +40 -0
  406. package/src/components/sheet/sheet-header.vue +36 -0
  407. package/src/components/sheet/sheet-title.vue +33 -0
  408. package/src/components/sheet/sheet-trigger.vue +16 -0
  409. package/src/components/sheet/sheet.vue +15 -0
  410. package/src/components/sheet/stories/sheet.stories.ts +88 -0
  411. package/src/components/sidebar/index.ts +38 -0
  412. package/src/components/sidebar/sidebar-content.vue +32 -0
  413. package/src/components/sidebar/sidebar-element.vue +68 -0
  414. package/src/components/sidebar/sidebar-footer.vue +34 -0
  415. package/src/components/sidebar/sidebar-group-content.vue +24 -0
  416. package/src/components/sidebar/sidebar-group-label.vue +55 -0
  417. package/src/components/sidebar/sidebar-group.vue +28 -0
  418. package/src/components/sidebar/sidebar-header.vue +34 -0
  419. package/src/components/sidebar/sidebar-menu-action.vue +118 -0
  420. package/src/components/sidebar/sidebar-menu-badge.vue +70 -0
  421. package/src/components/sidebar/sidebar-menu-button.vue +141 -0
  422. package/src/components/sidebar/sidebar-menu-item.vue +23 -0
  423. package/src/components/sidebar/sidebar-menu-sub-button.vue +110 -0
  424. package/src/components/sidebar/sidebar-menu-sub-item.vue +23 -0
  425. package/src/components/sidebar/sidebar-menu-sub.vue +35 -0
  426. package/src/components/sidebar/sidebar-menu.vue +27 -0
  427. package/src/components/sidebar/sidebar-provider.vue +101 -0
  428. package/src/components/sidebar/sidebar-separator.vue +31 -0
  429. package/src/components/sidebar/sidebar-trigger.vue +39 -0
  430. package/src/components/sidebar/sidebar.vue +201 -0
  431. package/src/components/sidebar/stories/sidebar.stories.ts +358 -0
  432. package/src/components/switch/switch.vue +34 -16
  433. package/src/components/tooltip/index.ts +12 -0
  434. package/src/components/tooltip/tooltip-content.vue +249 -0
  435. package/src/components/tooltip/tooltip-provider.vue +17 -0
  436. package/src/components/tooltip/tooltip-root.vue +23 -0
  437. package/src/components/tooltip/tooltip-trigger.vue +17 -0
  438. package/src/components/tooltip/tooltip.vue +21 -214
  439. package/src/composables/index.ts +2 -0
  440. package/src/composables/use-sidebar.ts +19 -0
  441. package/src/index.ts +1 -0
  442. /package/dist/cjs/chunks/{checkbox.vue_vue_type_style_index_0_lang.js → checkbox.js} +0 -0
  443. /package/dist/cjs/chunks/{counter-input.vue_vue_type_style_index_0_lang.js → counter-input.js} +0 -0
  444. /package/dist/cjs/chunks/{radio-group-item.vue_vue_type_style_index_0_lang.js → radio-group-item.js} +0 -0
  445. /package/dist/cjs/chunks/{radio-group.vue_vue_type_style_index_0_lang.js → radio-group.js} +0 -0
  446. /package/dist/cjs/chunks/{slider.vue_vue_type_style_index_0_lang.js → slider.js} +0 -0
  447. /package/dist/cjs/chunks/{switch.vue_vue_type_style_index_0_lang.js → switch.js} +0 -0
  448. /package/dist/es/chunks/{checkbox.vue_vue_type_style_index_0_lang.js → checkbox.js} +0 -0
  449. /package/dist/es/chunks/{radio-group.vue_vue_type_style_index_0_lang.js → radio-group.js} +0 -0
@@ -0,0 +1,4576 @@
1
+ import { M as Mark, m as mergeAttributes, f as markPasteRule, c as Plugin, P as PluginKey, h as combineTransactionSteps, j as getChangedRanges, l as findChildrenInRange, n as getMarksBetween, o as getAttributes, E as Extension, q as dropPoint, S as Selection, k as keydownHandler, N as NodeSelection, F as Fragment, b as Slice, T as TextSelection, D as DecorationSet, r as Decoration, s as Mapping, t as callOrReturn, u as getExtensionField, v as isNodeEmpty, w as isNodeSelection, x as Node3, y as wrappingInputRule, z as markInputRule, A as textblockTypeInputRule, B as canInsertNode, C as nodeInputRule, G as getNodeType, H as getNodeAtPosition, I as isNodeActive, J as isAtStartOfNode, K as isAtEndOfNode } from "./index5.js";
2
+ const encodedTlds = "aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0america6xi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2";
3
+ const encodedUtlds = "ελ1υ2бг1ел3дети4ею2католик6ом3мкд2он1сква6онлайн5рг3рус2ф2сайт3рб3укр3қаз3հայ3ישראל5קום3ابوظبي5رامكو5لاردن4بحرين5جزائر5سعودية6عليان5مغرب5مارات5یران5بارت2زار4يتك3ھارت5تونس4سودان3رية5شبكة4عراق2ب2مان4فلسطين6قطر3كاثوليك6وم3مصر2ليسيا5وريتانيا7قع4همراه5پاکستان7ڀارت4कॉम3नेट3भारत0म्3ोत5संगठन5বাংলা5ভারত2ৰত4ਭਾਰਤ4ભારત4ଭାରତ4இந்தியா6லங்கை6சிங்கப்பூர்11భారత్5ಭಾರತ4ഭാരതം5ලංකා4คอม3ไทย3ລາວ3გე2みんな3アマゾン4クラウド4グーグル4コム2ストア3セール3ファッション6ポイント4世界2中信1国1國1文网3亚马逊3企业2佛山2信息2健康2八卦2公司1益2台湾1灣2商城1店1标2嘉里0大酒店5在线2大拿2天主教3娱乐2家電2广东2微博2慈善2我爱你3手机2招聘2政务1府2新加坡2闻2时尚2書籍2机构2淡马锡3游戏2澳門2点看2移动2组织机构4网址1店1站1络2联通2谷歌2购物2通販2集团2電訊盈科4飞利浦3食品2餐厅2香格里拉3港2닷넷1컴2삼성2한국2";
4
+ const assign = (target, properties) => {
5
+ for (const key in properties) {
6
+ target[key] = properties[key];
7
+ }
8
+ return target;
9
+ };
10
+ const numeric = "numeric";
11
+ const ascii = "ascii";
12
+ const alpha = "alpha";
13
+ const asciinumeric = "asciinumeric";
14
+ const alphanumeric = "alphanumeric";
15
+ const domain = "domain";
16
+ const emoji = "emoji";
17
+ const scheme = "scheme";
18
+ const slashscheme = "slashscheme";
19
+ const whitespace = "whitespace";
20
+ function registerGroup(name, groups) {
21
+ if (!(name in groups)) {
22
+ groups[name] = [];
23
+ }
24
+ return groups[name];
25
+ }
26
+ function addToGroups(t, flags, groups) {
27
+ if (flags[numeric]) {
28
+ flags[asciinumeric] = true;
29
+ flags[alphanumeric] = true;
30
+ }
31
+ if (flags[ascii]) {
32
+ flags[asciinumeric] = true;
33
+ flags[alpha] = true;
34
+ }
35
+ if (flags[asciinumeric]) {
36
+ flags[alphanumeric] = true;
37
+ }
38
+ if (flags[alpha]) {
39
+ flags[alphanumeric] = true;
40
+ }
41
+ if (flags[alphanumeric]) {
42
+ flags[domain] = true;
43
+ }
44
+ if (flags[emoji]) {
45
+ flags[domain] = true;
46
+ }
47
+ for (const k in flags) {
48
+ const group = registerGroup(k, groups);
49
+ if (group.indexOf(t) < 0) {
50
+ group.push(t);
51
+ }
52
+ }
53
+ }
54
+ function flagsForToken(t, groups) {
55
+ const result = {};
56
+ for (const c in groups) {
57
+ if (groups[c].indexOf(t) >= 0) {
58
+ result[c] = true;
59
+ }
60
+ }
61
+ return result;
62
+ }
63
+ function State(token = null) {
64
+ this.j = {};
65
+ this.jr = [];
66
+ this.jd = null;
67
+ this.t = token;
68
+ }
69
+ State.groups = {};
70
+ State.prototype = {
71
+ accepts() {
72
+ return !!this.t;
73
+ },
74
+ /**
75
+ * Follow an existing transition from the given input to the next state.
76
+ * Does not mutate.
77
+ * @param {string} input character or token type to transition on
78
+ * @returns {?State<T>} the next state, if any
79
+ */
80
+ go(input) {
81
+ const state = this;
82
+ const nextState = state.j[input];
83
+ if (nextState) {
84
+ return nextState;
85
+ }
86
+ for (let i = 0; i < state.jr.length; i++) {
87
+ const regex = state.jr[i][0];
88
+ const nextState2 = state.jr[i][1];
89
+ if (nextState2 && regex.test(input)) {
90
+ return nextState2;
91
+ }
92
+ }
93
+ return state.jd;
94
+ },
95
+ /**
96
+ * Whether the state has a transition for the given input. Set the second
97
+ * argument to true to only look for an exact match (and not a default or
98
+ * regular-expression-based transition)
99
+ * @param {string} input
100
+ * @param {boolean} exactOnly
101
+ */
102
+ has(input, exactOnly = false) {
103
+ return exactOnly ? input in this.j : !!this.go(input);
104
+ },
105
+ /**
106
+ * Short for "transition all"; create a transition from the array of items
107
+ * in the given list to the same final resulting state.
108
+ * @param {string | string[]} inputs Group of inputs to transition on
109
+ * @param {Transition<T> | State<T>} [next] Transition options
110
+ * @param {Flags} [flags] Collections flags to add token to
111
+ * @param {Collections<T>} [groups] Master list of token groups
112
+ */
113
+ ta(inputs, next, flags, groups) {
114
+ for (let i = 0; i < inputs.length; i++) {
115
+ this.tt(inputs[i], next, flags, groups);
116
+ }
117
+ },
118
+ /**
119
+ * Short for "take regexp transition"; defines a transition for this state
120
+ * when it encounters a token which matches the given regular expression
121
+ * @param {RegExp} regexp Regular expression transition (populate first)
122
+ * @param {T | State<T>} [next] Transition options
123
+ * @param {Flags} [flags] Collections flags to add token to
124
+ * @param {Collections<T>} [groups] Master list of token groups
125
+ * @returns {State<T>} taken after the given input
126
+ */
127
+ tr(regexp, next, flags, groups) {
128
+ groups = groups || State.groups;
129
+ let nextState;
130
+ if (next && next.j) {
131
+ nextState = next;
132
+ } else {
133
+ nextState = new State(next);
134
+ if (flags && groups) {
135
+ addToGroups(next, flags, groups);
136
+ }
137
+ }
138
+ this.jr.push([regexp, nextState]);
139
+ return nextState;
140
+ },
141
+ /**
142
+ * Short for "take transitions", will take as many sequential transitions as
143
+ * the length of the given input and returns the
144
+ * resulting final state.
145
+ * @param {string | string[]} input
146
+ * @param {T | State<T>} [next] Transition options
147
+ * @param {Flags} [flags] Collections flags to add token to
148
+ * @param {Collections<T>} [groups] Master list of token groups
149
+ * @returns {State<T>} taken after the given input
150
+ */
151
+ ts(input, next, flags, groups) {
152
+ let state = this;
153
+ const len = input.length;
154
+ if (!len) {
155
+ return state;
156
+ }
157
+ for (let i = 0; i < len - 1; i++) {
158
+ state = state.tt(input[i]);
159
+ }
160
+ return state.tt(input[len - 1], next, flags, groups);
161
+ },
162
+ /**
163
+ * Short for "take transition", this is a method for building/working with
164
+ * state machines.
165
+ *
166
+ * If a state already exists for the given input, returns it.
167
+ *
168
+ * If a token is specified, that state will emit that token when reached by
169
+ * the linkify engine.
170
+ *
171
+ * If no state exists, it will be initialized with some default transitions
172
+ * that resemble existing default transitions.
173
+ *
174
+ * If a state is given for the second argument, that state will be
175
+ * transitioned to on the given input regardless of what that input
176
+ * previously did.
177
+ *
178
+ * Specify a token group flags to define groups that this token belongs to.
179
+ * The token will be added to corresponding entires in the given groups
180
+ * object.
181
+ *
182
+ * @param {string} input character, token type to transition on
183
+ * @param {T | State<T>} [next] Transition options
184
+ * @param {Flags} [flags] Collections flags to add token to
185
+ * @param {Collections<T>} [groups] Master list of groups
186
+ * @returns {State<T>} taken after the given input
187
+ */
188
+ tt(input, next, flags, groups) {
189
+ groups = groups || State.groups;
190
+ const state = this;
191
+ if (next && next.j) {
192
+ state.j[input] = next;
193
+ return next;
194
+ }
195
+ const t = next;
196
+ let nextState, templateState = state.go(input);
197
+ if (templateState) {
198
+ nextState = new State();
199
+ assign(nextState.j, templateState.j);
200
+ nextState.jr.push.apply(nextState.jr, templateState.jr);
201
+ nextState.jd = templateState.jd;
202
+ nextState.t = templateState.t;
203
+ } else {
204
+ nextState = new State();
205
+ }
206
+ if (t) {
207
+ if (groups) {
208
+ if (nextState.t && typeof nextState.t === "string") {
209
+ const allFlags = assign(flagsForToken(nextState.t, groups), flags);
210
+ addToGroups(t, allFlags, groups);
211
+ } else if (flags) {
212
+ addToGroups(t, flags, groups);
213
+ }
214
+ }
215
+ nextState.t = t;
216
+ }
217
+ state.j[input] = nextState;
218
+ return nextState;
219
+ }
220
+ };
221
+ const ta = (state, input, next, flags, groups) => state.ta(input, next, flags, groups);
222
+ const tr = (state, regexp, next, flags, groups) => state.tr(regexp, next, flags, groups);
223
+ const ts = (state, input, next, flags, groups) => state.ts(input, next, flags, groups);
224
+ const tt = (state, input, next, flags, groups) => state.tt(input, next, flags, groups);
225
+ const WORD = "WORD";
226
+ const UWORD = "UWORD";
227
+ const ASCIINUMERICAL = "ASCIINUMERICAL";
228
+ const ALPHANUMERICAL = "ALPHANUMERICAL";
229
+ const LOCALHOST = "LOCALHOST";
230
+ const TLD = "TLD";
231
+ const UTLD = "UTLD";
232
+ const SCHEME = "SCHEME";
233
+ const SLASH_SCHEME = "SLASH_SCHEME";
234
+ const NUM = "NUM";
235
+ const WS = "WS";
236
+ const NL = "NL";
237
+ const OPENBRACE = "OPENBRACE";
238
+ const CLOSEBRACE = "CLOSEBRACE";
239
+ const OPENBRACKET = "OPENBRACKET";
240
+ const CLOSEBRACKET = "CLOSEBRACKET";
241
+ const OPENPAREN = "OPENPAREN";
242
+ const CLOSEPAREN = "CLOSEPAREN";
243
+ const OPENANGLEBRACKET = "OPENANGLEBRACKET";
244
+ const CLOSEANGLEBRACKET = "CLOSEANGLEBRACKET";
245
+ const FULLWIDTHLEFTPAREN = "FULLWIDTHLEFTPAREN";
246
+ const FULLWIDTHRIGHTPAREN = "FULLWIDTHRIGHTPAREN";
247
+ const LEFTCORNERBRACKET = "LEFTCORNERBRACKET";
248
+ const RIGHTCORNERBRACKET = "RIGHTCORNERBRACKET";
249
+ const LEFTWHITECORNERBRACKET = "LEFTWHITECORNERBRACKET";
250
+ const RIGHTWHITECORNERBRACKET = "RIGHTWHITECORNERBRACKET";
251
+ const FULLWIDTHLESSTHAN = "FULLWIDTHLESSTHAN";
252
+ const FULLWIDTHGREATERTHAN = "FULLWIDTHGREATERTHAN";
253
+ const AMPERSAND = "AMPERSAND";
254
+ const APOSTROPHE = "APOSTROPHE";
255
+ const ASTERISK = "ASTERISK";
256
+ const AT = "AT";
257
+ const BACKSLASH = "BACKSLASH";
258
+ const BACKTICK = "BACKTICK";
259
+ const CARET = "CARET";
260
+ const COLON = "COLON";
261
+ const COMMA = "COMMA";
262
+ const DOLLAR = "DOLLAR";
263
+ const DOT = "DOT";
264
+ const EQUALS = "EQUALS";
265
+ const EXCLAMATION = "EXCLAMATION";
266
+ const HYPHEN = "HYPHEN";
267
+ const PERCENT = "PERCENT";
268
+ const PIPE = "PIPE";
269
+ const PLUS = "PLUS";
270
+ const POUND = "POUND";
271
+ const QUERY = "QUERY";
272
+ const QUOTE = "QUOTE";
273
+ const FULLWIDTHMIDDLEDOT = "FULLWIDTHMIDDLEDOT";
274
+ const SEMI = "SEMI";
275
+ const SLASH = "SLASH";
276
+ const TILDE = "TILDE";
277
+ const UNDERSCORE = "UNDERSCORE";
278
+ const EMOJI$1 = "EMOJI";
279
+ const SYM = "SYM";
280
+ var tk = /* @__PURE__ */ Object.freeze({
281
+ __proto__: null,
282
+ ALPHANUMERICAL,
283
+ AMPERSAND,
284
+ APOSTROPHE,
285
+ ASCIINUMERICAL,
286
+ ASTERISK,
287
+ AT,
288
+ BACKSLASH,
289
+ BACKTICK,
290
+ CARET,
291
+ CLOSEANGLEBRACKET,
292
+ CLOSEBRACE,
293
+ CLOSEBRACKET,
294
+ CLOSEPAREN,
295
+ COLON,
296
+ COMMA,
297
+ DOLLAR,
298
+ DOT,
299
+ EMOJI: EMOJI$1,
300
+ EQUALS,
301
+ EXCLAMATION,
302
+ FULLWIDTHGREATERTHAN,
303
+ FULLWIDTHLEFTPAREN,
304
+ FULLWIDTHLESSTHAN,
305
+ FULLWIDTHMIDDLEDOT,
306
+ FULLWIDTHRIGHTPAREN,
307
+ HYPHEN,
308
+ LEFTCORNERBRACKET,
309
+ LEFTWHITECORNERBRACKET,
310
+ LOCALHOST,
311
+ NL,
312
+ NUM,
313
+ OPENANGLEBRACKET,
314
+ OPENBRACE,
315
+ OPENBRACKET,
316
+ OPENPAREN,
317
+ PERCENT,
318
+ PIPE,
319
+ PLUS,
320
+ POUND,
321
+ QUERY,
322
+ QUOTE,
323
+ RIGHTCORNERBRACKET,
324
+ RIGHTWHITECORNERBRACKET,
325
+ SCHEME,
326
+ SEMI,
327
+ SLASH,
328
+ SLASH_SCHEME,
329
+ SYM,
330
+ TILDE,
331
+ TLD,
332
+ UNDERSCORE,
333
+ UTLD,
334
+ UWORD,
335
+ WORD,
336
+ WS
337
+ });
338
+ const ASCII_LETTER = /[a-z]/;
339
+ const LETTER = new RegExp("\\p{L}", "u");
340
+ const EMOJI = new RegExp("\\p{Emoji}", "u");
341
+ const DIGIT = /\d/;
342
+ const SPACE = /\s/;
343
+ const CR = "\r";
344
+ const LF = "\n";
345
+ const EMOJI_VARIATION = "️";
346
+ const EMOJI_JOINER = "‍";
347
+ const OBJECT_REPLACEMENT = "";
348
+ let tlds = null, utlds = null;
349
+ function init$2(customSchemes = []) {
350
+ const groups = {};
351
+ State.groups = groups;
352
+ const Start = new State();
353
+ if (tlds == null) {
354
+ tlds = decodeTlds(encodedTlds);
355
+ }
356
+ if (utlds == null) {
357
+ utlds = decodeTlds(encodedUtlds);
358
+ }
359
+ tt(Start, "'", APOSTROPHE);
360
+ tt(Start, "{", OPENBRACE);
361
+ tt(Start, "}", CLOSEBRACE);
362
+ tt(Start, "[", OPENBRACKET);
363
+ tt(Start, "]", CLOSEBRACKET);
364
+ tt(Start, "(", OPENPAREN);
365
+ tt(Start, ")", CLOSEPAREN);
366
+ tt(Start, "<", OPENANGLEBRACKET);
367
+ tt(Start, ">", CLOSEANGLEBRACKET);
368
+ tt(Start, "(", FULLWIDTHLEFTPAREN);
369
+ tt(Start, ")", FULLWIDTHRIGHTPAREN);
370
+ tt(Start, "「", LEFTCORNERBRACKET);
371
+ tt(Start, "」", RIGHTCORNERBRACKET);
372
+ tt(Start, "『", LEFTWHITECORNERBRACKET);
373
+ tt(Start, "』", RIGHTWHITECORNERBRACKET);
374
+ tt(Start, "<", FULLWIDTHLESSTHAN);
375
+ tt(Start, ">", FULLWIDTHGREATERTHAN);
376
+ tt(Start, "&", AMPERSAND);
377
+ tt(Start, "*", ASTERISK);
378
+ tt(Start, "@", AT);
379
+ tt(Start, "`", BACKTICK);
380
+ tt(Start, "^", CARET);
381
+ tt(Start, ":", COLON);
382
+ tt(Start, ",", COMMA);
383
+ tt(Start, "$", DOLLAR);
384
+ tt(Start, ".", DOT);
385
+ tt(Start, "=", EQUALS);
386
+ tt(Start, "!", EXCLAMATION);
387
+ tt(Start, "-", HYPHEN);
388
+ tt(Start, "%", PERCENT);
389
+ tt(Start, "|", PIPE);
390
+ tt(Start, "+", PLUS);
391
+ tt(Start, "#", POUND);
392
+ tt(Start, "?", QUERY);
393
+ tt(Start, '"', QUOTE);
394
+ tt(Start, "/", SLASH);
395
+ tt(Start, ";", SEMI);
396
+ tt(Start, "~", TILDE);
397
+ tt(Start, "_", UNDERSCORE);
398
+ tt(Start, "\\", BACKSLASH);
399
+ tt(Start, "・", FULLWIDTHMIDDLEDOT);
400
+ const Num = tr(Start, DIGIT, NUM, {
401
+ [numeric]: true
402
+ });
403
+ tr(Num, DIGIT, Num);
404
+ const Asciinumeric = tr(Num, ASCII_LETTER, ASCIINUMERICAL, {
405
+ [asciinumeric]: true
406
+ });
407
+ const Alphanumeric = tr(Num, LETTER, ALPHANUMERICAL, {
408
+ [alphanumeric]: true
409
+ });
410
+ const Word = tr(Start, ASCII_LETTER, WORD, {
411
+ [ascii]: true
412
+ });
413
+ tr(Word, DIGIT, Asciinumeric);
414
+ tr(Word, ASCII_LETTER, Word);
415
+ tr(Asciinumeric, DIGIT, Asciinumeric);
416
+ tr(Asciinumeric, ASCII_LETTER, Asciinumeric);
417
+ const UWord = tr(Start, LETTER, UWORD, {
418
+ [alpha]: true
419
+ });
420
+ tr(UWord, ASCII_LETTER);
421
+ tr(UWord, DIGIT, Alphanumeric);
422
+ tr(UWord, LETTER, UWord);
423
+ tr(Alphanumeric, DIGIT, Alphanumeric);
424
+ tr(Alphanumeric, ASCII_LETTER);
425
+ tr(Alphanumeric, LETTER, Alphanumeric);
426
+ const Nl2 = tt(Start, LF, NL, {
427
+ [whitespace]: true
428
+ });
429
+ const Cr = tt(Start, CR, WS, {
430
+ [whitespace]: true
431
+ });
432
+ const Ws = tr(Start, SPACE, WS, {
433
+ [whitespace]: true
434
+ });
435
+ tt(Start, OBJECT_REPLACEMENT, Ws);
436
+ tt(Cr, LF, Nl2);
437
+ tt(Cr, OBJECT_REPLACEMENT, Ws);
438
+ tr(Cr, SPACE, Ws);
439
+ tt(Ws, CR);
440
+ tt(Ws, LF);
441
+ tr(Ws, SPACE, Ws);
442
+ tt(Ws, OBJECT_REPLACEMENT, Ws);
443
+ const Emoji = tr(Start, EMOJI, EMOJI$1, {
444
+ [emoji]: true
445
+ });
446
+ tt(Emoji, "#");
447
+ tr(Emoji, EMOJI, Emoji);
448
+ tt(Emoji, EMOJI_VARIATION, Emoji);
449
+ const EmojiJoiner = tt(Emoji, EMOJI_JOINER);
450
+ tt(EmojiJoiner, "#");
451
+ tr(EmojiJoiner, EMOJI, Emoji);
452
+ const wordjr = [[ASCII_LETTER, Word], [DIGIT, Asciinumeric]];
453
+ const uwordjr = [[ASCII_LETTER, null], [LETTER, UWord], [DIGIT, Alphanumeric]];
454
+ for (let i = 0; i < tlds.length; i++) {
455
+ fastts(Start, tlds[i], TLD, WORD, wordjr);
456
+ }
457
+ for (let i = 0; i < utlds.length; i++) {
458
+ fastts(Start, utlds[i], UTLD, UWORD, uwordjr);
459
+ }
460
+ addToGroups(TLD, {
461
+ tld: true,
462
+ ascii: true
463
+ }, groups);
464
+ addToGroups(UTLD, {
465
+ utld: true,
466
+ alpha: true
467
+ }, groups);
468
+ fastts(Start, "file", SCHEME, WORD, wordjr);
469
+ fastts(Start, "mailto", SCHEME, WORD, wordjr);
470
+ fastts(Start, "http", SLASH_SCHEME, WORD, wordjr);
471
+ fastts(Start, "https", SLASH_SCHEME, WORD, wordjr);
472
+ fastts(Start, "ftp", SLASH_SCHEME, WORD, wordjr);
473
+ fastts(Start, "ftps", SLASH_SCHEME, WORD, wordjr);
474
+ addToGroups(SCHEME, {
475
+ scheme: true,
476
+ ascii: true
477
+ }, groups);
478
+ addToGroups(SLASH_SCHEME, {
479
+ slashscheme: true,
480
+ ascii: true
481
+ }, groups);
482
+ customSchemes = customSchemes.sort((a, b) => a[0] > b[0] ? 1 : -1);
483
+ for (let i = 0; i < customSchemes.length; i++) {
484
+ const sch = customSchemes[i][0];
485
+ const optionalSlashSlash = customSchemes[i][1];
486
+ const flags = optionalSlashSlash ? {
487
+ [scheme]: true
488
+ } : {
489
+ [slashscheme]: true
490
+ };
491
+ if (sch.indexOf("-") >= 0) {
492
+ flags[domain] = true;
493
+ } else if (!ASCII_LETTER.test(sch)) {
494
+ flags[numeric] = true;
495
+ } else if (DIGIT.test(sch)) {
496
+ flags[asciinumeric] = true;
497
+ } else {
498
+ flags[ascii] = true;
499
+ }
500
+ ts(Start, sch, sch, flags);
501
+ }
502
+ ts(Start, "localhost", LOCALHOST, {
503
+ ascii: true
504
+ });
505
+ Start.jd = new State(SYM);
506
+ return {
507
+ start: Start,
508
+ tokens: assign({
509
+ groups
510
+ }, tk)
511
+ };
512
+ }
513
+ function run$1(start, str) {
514
+ const iterable = stringToArray(str.replace(/[A-Z]/g, (c) => c.toLowerCase()));
515
+ const charCount = iterable.length;
516
+ const tokens = [];
517
+ let cursor = 0;
518
+ let charCursor = 0;
519
+ while (charCursor < charCount) {
520
+ let state = start;
521
+ let nextState = null;
522
+ let tokenLength = 0;
523
+ let latestAccepting = null;
524
+ let sinceAccepts = -1;
525
+ let charsSinceAccepts = -1;
526
+ while (charCursor < charCount && (nextState = state.go(iterable[charCursor]))) {
527
+ state = nextState;
528
+ if (state.accepts()) {
529
+ sinceAccepts = 0;
530
+ charsSinceAccepts = 0;
531
+ latestAccepting = state;
532
+ } else if (sinceAccepts >= 0) {
533
+ sinceAccepts += iterable[charCursor].length;
534
+ charsSinceAccepts++;
535
+ }
536
+ tokenLength += iterable[charCursor].length;
537
+ cursor += iterable[charCursor].length;
538
+ charCursor++;
539
+ }
540
+ cursor -= sinceAccepts;
541
+ charCursor -= charsSinceAccepts;
542
+ tokenLength -= sinceAccepts;
543
+ tokens.push({
544
+ t: latestAccepting.t,
545
+ // token type/name
546
+ v: str.slice(cursor - tokenLength, cursor),
547
+ // string value
548
+ s: cursor - tokenLength,
549
+ // start index
550
+ e: cursor
551
+ // end index (excluding)
552
+ });
553
+ }
554
+ return tokens;
555
+ }
556
+ function stringToArray(str) {
557
+ const result = [];
558
+ const len = str.length;
559
+ let index = 0;
560
+ while (index < len) {
561
+ let first = str.charCodeAt(index);
562
+ let second;
563
+ let char = first < 55296 || first > 56319 || index + 1 === len || (second = str.charCodeAt(index + 1)) < 56320 || second > 57343 ? str[index] : str.slice(index, index + 2);
564
+ result.push(char);
565
+ index += char.length;
566
+ }
567
+ return result;
568
+ }
569
+ function fastts(state, input, t, defaultt, jr) {
570
+ let next;
571
+ const len = input.length;
572
+ for (let i = 0; i < len - 1; i++) {
573
+ const char = input[i];
574
+ if (state.j[char]) {
575
+ next = state.j[char];
576
+ } else {
577
+ next = new State(defaultt);
578
+ next.jr = jr.slice();
579
+ state.j[char] = next;
580
+ }
581
+ state = next;
582
+ }
583
+ next = new State(t);
584
+ next.jr = jr.slice();
585
+ state.j[input[len - 1]] = next;
586
+ return next;
587
+ }
588
+ function decodeTlds(encoded) {
589
+ const words = [];
590
+ const stack = [];
591
+ let i = 0;
592
+ let digits = "0123456789";
593
+ while (i < encoded.length) {
594
+ let popDigitCount = 0;
595
+ while (digits.indexOf(encoded[i + popDigitCount]) >= 0) {
596
+ popDigitCount++;
597
+ }
598
+ if (popDigitCount > 0) {
599
+ words.push(stack.join(""));
600
+ for (let popCount = parseInt(encoded.substring(i, i + popDigitCount), 10); popCount > 0; popCount--) {
601
+ stack.pop();
602
+ }
603
+ i += popDigitCount;
604
+ } else {
605
+ stack.push(encoded[i]);
606
+ i++;
607
+ }
608
+ }
609
+ return words;
610
+ }
611
+ const defaults = {
612
+ defaultProtocol: "http",
613
+ events: null,
614
+ format: noop,
615
+ formatHref: noop,
616
+ nl2br: false,
617
+ tagName: "a",
618
+ target: null,
619
+ rel: null,
620
+ validate: true,
621
+ truncate: Infinity,
622
+ className: null,
623
+ attributes: null,
624
+ ignoreTags: [],
625
+ render: null
626
+ };
627
+ function Options(opts, defaultRender = null) {
628
+ let o = assign({}, defaults);
629
+ if (opts) {
630
+ o = assign(o, opts instanceof Options ? opts.o : opts);
631
+ }
632
+ const ignoredTags = o.ignoreTags;
633
+ const uppercaseIgnoredTags = [];
634
+ for (let i = 0; i < ignoredTags.length; i++) {
635
+ uppercaseIgnoredTags.push(ignoredTags[i].toUpperCase());
636
+ }
637
+ this.o = o;
638
+ if (defaultRender) {
639
+ this.defaultRender = defaultRender;
640
+ }
641
+ this.ignoreTags = uppercaseIgnoredTags;
642
+ }
643
+ Options.prototype = {
644
+ o: defaults,
645
+ /**
646
+ * @type string[]
647
+ */
648
+ ignoreTags: [],
649
+ /**
650
+ * @param {IntermediateRepresentation} ir
651
+ * @returns {any}
652
+ */
653
+ defaultRender(ir) {
654
+ return ir;
655
+ },
656
+ /**
657
+ * Returns true or false based on whether a token should be displayed as a
658
+ * link based on the user options.
659
+ * @param {MultiToken} token
660
+ * @returns {boolean}
661
+ */
662
+ check(token) {
663
+ return this.get("validate", token.toString(), token);
664
+ },
665
+ // Private methods
666
+ /**
667
+ * Resolve an option's value based on the value of the option and the given
668
+ * params. If operator and token are specified and the target option is
669
+ * callable, automatically calls the function with the given argument.
670
+ * @template {keyof Opts} K
671
+ * @param {K} key Name of option to use
672
+ * @param {string} [operator] will be passed to the target option if it's a
673
+ * function. If not specified, RAW function value gets returned
674
+ * @param {MultiToken} [token] The token from linkify.tokenize
675
+ * @returns {Opts[K] | any}
676
+ */
677
+ get(key, operator, token) {
678
+ const isCallable = operator != null;
679
+ let option = this.o[key];
680
+ if (!option) {
681
+ return option;
682
+ }
683
+ if (typeof option === "object") {
684
+ option = token.t in option ? option[token.t] : defaults[key];
685
+ if (typeof option === "function" && isCallable) {
686
+ option = option(operator, token);
687
+ }
688
+ } else if (typeof option === "function" && isCallable) {
689
+ option = option(operator, token.t, token);
690
+ }
691
+ return option;
692
+ },
693
+ /**
694
+ * @template {keyof Opts} L
695
+ * @param {L} key Name of options object to use
696
+ * @param {string} [operator]
697
+ * @param {MultiToken} [token]
698
+ * @returns {Opts[L] | any}
699
+ */
700
+ getObj(key, operator, token) {
701
+ let obj = this.o[key];
702
+ if (typeof obj === "function" && operator != null) {
703
+ obj = obj(operator, token.t, token);
704
+ }
705
+ return obj;
706
+ },
707
+ /**
708
+ * Convert the given token to a rendered element that may be added to the
709
+ * calling-interface's DOM
710
+ * @param {MultiToken} token Token to render to an HTML element
711
+ * @returns {any} Render result; e.g., HTML string, DOM element, React
712
+ * Component, etc.
713
+ */
714
+ render(token) {
715
+ const ir = token.render(this);
716
+ const renderFn = this.get("render", null, token) || this.defaultRender;
717
+ return renderFn(ir, token.t, token);
718
+ }
719
+ };
720
+ function noop(val) {
721
+ return val;
722
+ }
723
+ function MultiToken(value, tokens) {
724
+ this.t = "token";
725
+ this.v = value;
726
+ this.tk = tokens;
727
+ }
728
+ MultiToken.prototype = {
729
+ isLink: false,
730
+ /**
731
+ * Return the string this token represents.
732
+ * @return {string}
733
+ */
734
+ toString() {
735
+ return this.v;
736
+ },
737
+ /**
738
+ * What should the value for this token be in the `href` HTML attribute?
739
+ * Returns the `.toString` value by default.
740
+ * @param {string} [scheme]
741
+ * @return {string}
742
+ */
743
+ toHref(scheme2) {
744
+ return this.toString();
745
+ },
746
+ /**
747
+ * @param {Options} options Formatting options
748
+ * @returns {string}
749
+ */
750
+ toFormattedString(options) {
751
+ const val = this.toString();
752
+ const truncate = options.get("truncate", val, this);
753
+ const formatted = options.get("format", val, this);
754
+ return truncate && formatted.length > truncate ? formatted.substring(0, truncate) + "…" : formatted;
755
+ },
756
+ /**
757
+ *
758
+ * @param {Options} options
759
+ * @returns {string}
760
+ */
761
+ toFormattedHref(options) {
762
+ return options.get("formatHref", this.toHref(options.get("defaultProtocol")), this);
763
+ },
764
+ /**
765
+ * The start index of this token in the original input string
766
+ * @returns {number}
767
+ */
768
+ startIndex() {
769
+ return this.tk[0].s;
770
+ },
771
+ /**
772
+ * The end index of this token in the original input string (up to this
773
+ * index but not including it)
774
+ * @returns {number}
775
+ */
776
+ endIndex() {
777
+ return this.tk[this.tk.length - 1].e;
778
+ },
779
+ /**
780
+ Returns an object of relevant values for this token, which includes keys
781
+ * type - Kind of token ('url', 'email', etc.)
782
+ * value - Original text
783
+ * href - The value that should be added to the anchor tag's href
784
+ attribute
785
+ @method toObject
786
+ @param {string} [protocol] `'http'` by default
787
+ */
788
+ toObject(protocol = defaults.defaultProtocol) {
789
+ return {
790
+ type: this.t,
791
+ value: this.toString(),
792
+ isLink: this.isLink,
793
+ href: this.toHref(protocol),
794
+ start: this.startIndex(),
795
+ end: this.endIndex()
796
+ };
797
+ },
798
+ /**
799
+ *
800
+ * @param {Options} options Formatting option
801
+ */
802
+ toFormattedObject(options) {
803
+ return {
804
+ type: this.t,
805
+ value: this.toFormattedString(options),
806
+ isLink: this.isLink,
807
+ href: this.toFormattedHref(options),
808
+ start: this.startIndex(),
809
+ end: this.endIndex()
810
+ };
811
+ },
812
+ /**
813
+ * Whether this token should be rendered as a link according to the given options
814
+ * @param {Options} options
815
+ * @returns {boolean}
816
+ */
817
+ validate(options) {
818
+ return options.get("validate", this.toString(), this);
819
+ },
820
+ /**
821
+ * Return an object that represents how this link should be rendered.
822
+ * @param {Options} options Formattinng options
823
+ */
824
+ render(options) {
825
+ const token = this;
826
+ const href = this.toHref(options.get("defaultProtocol"));
827
+ const formattedHref = options.get("formatHref", href, this);
828
+ const tagName = options.get("tagName", href, token);
829
+ const content = this.toFormattedString(options);
830
+ const attributes = {};
831
+ const className = options.get("className", href, token);
832
+ const target = options.get("target", href, token);
833
+ const rel = options.get("rel", href, token);
834
+ const attrs = options.getObj("attributes", href, token);
835
+ const eventListeners = options.getObj("events", href, token);
836
+ attributes.href = formattedHref;
837
+ if (className) {
838
+ attributes.class = className;
839
+ }
840
+ if (target) {
841
+ attributes.target = target;
842
+ }
843
+ if (rel) {
844
+ attributes.rel = rel;
845
+ }
846
+ if (attrs) {
847
+ assign(attributes, attrs);
848
+ }
849
+ return {
850
+ tagName,
851
+ attributes,
852
+ content,
853
+ eventListeners
854
+ };
855
+ }
856
+ };
857
+ function createTokenClass(type, props) {
858
+ class Token extends MultiToken {
859
+ constructor(value, tokens) {
860
+ super(value, tokens);
861
+ this.t = type;
862
+ }
863
+ }
864
+ for (const p in props) {
865
+ Token.prototype[p] = props[p];
866
+ }
867
+ Token.t = type;
868
+ return Token;
869
+ }
870
+ const Email = createTokenClass("email", {
871
+ isLink: true,
872
+ toHref() {
873
+ return "mailto:" + this.toString();
874
+ }
875
+ });
876
+ const Text$1 = createTokenClass("text");
877
+ const Nl = createTokenClass("nl");
878
+ const Url = createTokenClass("url", {
879
+ isLink: true,
880
+ /**
881
+ Lowercases relevant parts of the domain and adds the protocol if
882
+ required. Note that this will not escape unsafe HTML characters in the
883
+ URL.
884
+ @param {string} [scheme] default scheme (e.g., 'https')
885
+ @return {string} the full href
886
+ */
887
+ toHref(scheme2 = defaults.defaultProtocol) {
888
+ return this.hasProtocol() ? this.v : `${scheme2}://${this.v}`;
889
+ },
890
+ /**
891
+ * Check whether this URL token has a protocol
892
+ * @return {boolean}
893
+ */
894
+ hasProtocol() {
895
+ const tokens = this.tk;
896
+ return tokens.length >= 2 && tokens[0].t !== LOCALHOST && tokens[1].t === COLON;
897
+ }
898
+ });
899
+ const makeState = (arg) => new State(arg);
900
+ function init$1({
901
+ groups
902
+ }) {
903
+ const qsAccepting = groups.domain.concat([AMPERSAND, ASTERISK, AT, BACKSLASH, BACKTICK, CARET, DOLLAR, EQUALS, HYPHEN, NUM, PERCENT, PIPE, PLUS, POUND, SLASH, SYM, TILDE, UNDERSCORE]);
904
+ const qsNonAccepting = [APOSTROPHE, COLON, COMMA, DOT, EXCLAMATION, PERCENT, QUERY, QUOTE, SEMI, OPENANGLEBRACKET, CLOSEANGLEBRACKET, OPENBRACE, CLOSEBRACE, CLOSEBRACKET, OPENBRACKET, OPENPAREN, CLOSEPAREN, FULLWIDTHLEFTPAREN, FULLWIDTHRIGHTPAREN, LEFTCORNERBRACKET, RIGHTCORNERBRACKET, LEFTWHITECORNERBRACKET, RIGHTWHITECORNERBRACKET, FULLWIDTHLESSTHAN, FULLWIDTHGREATERTHAN];
905
+ const localpartAccepting = [AMPERSAND, APOSTROPHE, ASTERISK, BACKSLASH, BACKTICK, CARET, DOLLAR, EQUALS, HYPHEN, OPENBRACE, CLOSEBRACE, PERCENT, PIPE, PLUS, POUND, QUERY, SLASH, SYM, TILDE, UNDERSCORE];
906
+ const Start = makeState();
907
+ const Localpart = tt(Start, TILDE);
908
+ ta(Localpart, localpartAccepting, Localpart);
909
+ ta(Localpart, groups.domain, Localpart);
910
+ const Domain = makeState(), Scheme = makeState(), SlashScheme = makeState();
911
+ ta(Start, groups.domain, Domain);
912
+ ta(Start, groups.scheme, Scheme);
913
+ ta(Start, groups.slashscheme, SlashScheme);
914
+ ta(Domain, localpartAccepting, Localpart);
915
+ ta(Domain, groups.domain, Domain);
916
+ const LocalpartAt = tt(Domain, AT);
917
+ tt(Localpart, AT, LocalpartAt);
918
+ tt(Scheme, AT, LocalpartAt);
919
+ tt(SlashScheme, AT, LocalpartAt);
920
+ const LocalpartDot = tt(Localpart, DOT);
921
+ ta(LocalpartDot, localpartAccepting, Localpart);
922
+ ta(LocalpartDot, groups.domain, Localpart);
923
+ const EmailDomain = makeState();
924
+ ta(LocalpartAt, groups.domain, EmailDomain);
925
+ ta(EmailDomain, groups.domain, EmailDomain);
926
+ const EmailDomainDot = tt(EmailDomain, DOT);
927
+ ta(EmailDomainDot, groups.domain, EmailDomain);
928
+ const Email$1 = makeState(Email);
929
+ ta(EmailDomainDot, groups.tld, Email$1);
930
+ ta(EmailDomainDot, groups.utld, Email$1);
931
+ tt(LocalpartAt, LOCALHOST, Email$1);
932
+ const EmailDomainHyphen = tt(EmailDomain, HYPHEN);
933
+ tt(EmailDomainHyphen, HYPHEN, EmailDomainHyphen);
934
+ ta(EmailDomainHyphen, groups.domain, EmailDomain);
935
+ ta(Email$1, groups.domain, EmailDomain);
936
+ tt(Email$1, DOT, EmailDomainDot);
937
+ tt(Email$1, HYPHEN, EmailDomainHyphen);
938
+ const EmailColon = tt(Email$1, COLON);
939
+ ta(EmailColon, groups.numeric, Email);
940
+ const DomainHyphen = tt(Domain, HYPHEN);
941
+ const DomainDot = tt(Domain, DOT);
942
+ tt(DomainHyphen, HYPHEN, DomainHyphen);
943
+ ta(DomainHyphen, groups.domain, Domain);
944
+ ta(DomainDot, localpartAccepting, Localpart);
945
+ ta(DomainDot, groups.domain, Domain);
946
+ const DomainDotTld = makeState(Url);
947
+ ta(DomainDot, groups.tld, DomainDotTld);
948
+ ta(DomainDot, groups.utld, DomainDotTld);
949
+ ta(DomainDotTld, groups.domain, Domain);
950
+ ta(DomainDotTld, localpartAccepting, Localpart);
951
+ tt(DomainDotTld, DOT, DomainDot);
952
+ tt(DomainDotTld, HYPHEN, DomainHyphen);
953
+ tt(DomainDotTld, AT, LocalpartAt);
954
+ const DomainDotTldColon = tt(DomainDotTld, COLON);
955
+ const DomainDotTldColonPort = makeState(Url);
956
+ ta(DomainDotTldColon, groups.numeric, DomainDotTldColonPort);
957
+ const Url$1 = makeState(Url);
958
+ const UrlNonaccept = makeState();
959
+ ta(Url$1, qsAccepting, Url$1);
960
+ ta(Url$1, qsNonAccepting, UrlNonaccept);
961
+ ta(UrlNonaccept, qsAccepting, Url$1);
962
+ ta(UrlNonaccept, qsNonAccepting, UrlNonaccept);
963
+ tt(DomainDotTld, SLASH, Url$1);
964
+ tt(DomainDotTldColonPort, SLASH, Url$1);
965
+ const SchemeColon = tt(Scheme, COLON);
966
+ const SlashSchemeColon = tt(SlashScheme, COLON);
967
+ const SlashSchemeColonSlash = tt(SlashSchemeColon, SLASH);
968
+ const UriPrefix = tt(SlashSchemeColonSlash, SLASH);
969
+ ta(Scheme, groups.domain, Domain);
970
+ tt(Scheme, DOT, DomainDot);
971
+ tt(Scheme, HYPHEN, DomainHyphen);
972
+ ta(SlashScheme, groups.domain, Domain);
973
+ tt(SlashScheme, DOT, DomainDot);
974
+ tt(SlashScheme, HYPHEN, DomainHyphen);
975
+ ta(SchemeColon, groups.domain, Url$1);
976
+ tt(SchemeColon, SLASH, Url$1);
977
+ tt(SchemeColon, QUERY, Url$1);
978
+ ta(UriPrefix, groups.domain, Url$1);
979
+ ta(UriPrefix, qsAccepting, Url$1);
980
+ tt(UriPrefix, SLASH, Url$1);
981
+ const bracketPairs = [
982
+ [OPENBRACE, CLOSEBRACE],
983
+ // {}
984
+ [OPENBRACKET, CLOSEBRACKET],
985
+ // []
986
+ [OPENPAREN, CLOSEPAREN],
987
+ // ()
988
+ [OPENANGLEBRACKET, CLOSEANGLEBRACKET],
989
+ // <>
990
+ [FULLWIDTHLEFTPAREN, FULLWIDTHRIGHTPAREN],
991
+ // ()
992
+ [LEFTCORNERBRACKET, RIGHTCORNERBRACKET],
993
+ // 「」
994
+ [LEFTWHITECORNERBRACKET, RIGHTWHITECORNERBRACKET],
995
+ // 『』
996
+ [FULLWIDTHLESSTHAN, FULLWIDTHGREATERTHAN]
997
+ // <>
998
+ ];
999
+ for (let i = 0; i < bracketPairs.length; i++) {
1000
+ const [OPEN, CLOSE] = bracketPairs[i];
1001
+ const UrlOpen = tt(Url$1, OPEN);
1002
+ tt(UrlNonaccept, OPEN, UrlOpen);
1003
+ tt(UrlOpen, CLOSE, Url$1);
1004
+ const UrlOpenQ = makeState(Url);
1005
+ ta(UrlOpen, qsAccepting, UrlOpenQ);
1006
+ const UrlOpenSyms = makeState();
1007
+ ta(UrlOpen, qsNonAccepting);
1008
+ ta(UrlOpenQ, qsAccepting, UrlOpenQ);
1009
+ ta(UrlOpenQ, qsNonAccepting, UrlOpenSyms);
1010
+ ta(UrlOpenSyms, qsAccepting, UrlOpenQ);
1011
+ ta(UrlOpenSyms, qsNonAccepting, UrlOpenSyms);
1012
+ tt(UrlOpenQ, CLOSE, Url$1);
1013
+ tt(UrlOpenSyms, CLOSE, Url$1);
1014
+ }
1015
+ tt(Start, LOCALHOST, DomainDotTld);
1016
+ tt(Start, NL, Nl);
1017
+ return {
1018
+ start: Start,
1019
+ tokens: tk
1020
+ };
1021
+ }
1022
+ function run(start, input, tokens) {
1023
+ let len = tokens.length;
1024
+ let cursor = 0;
1025
+ let multis = [];
1026
+ let textTokens = [];
1027
+ while (cursor < len) {
1028
+ let state = start;
1029
+ let secondState = null;
1030
+ let nextState = null;
1031
+ let multiLength = 0;
1032
+ let latestAccepting = null;
1033
+ let sinceAccepts = -1;
1034
+ while (cursor < len && !(secondState = state.go(tokens[cursor].t))) {
1035
+ textTokens.push(tokens[cursor++]);
1036
+ }
1037
+ while (cursor < len && (nextState = secondState || state.go(tokens[cursor].t))) {
1038
+ secondState = null;
1039
+ state = nextState;
1040
+ if (state.accepts()) {
1041
+ sinceAccepts = 0;
1042
+ latestAccepting = state;
1043
+ } else if (sinceAccepts >= 0) {
1044
+ sinceAccepts++;
1045
+ }
1046
+ cursor++;
1047
+ multiLength++;
1048
+ }
1049
+ if (sinceAccepts < 0) {
1050
+ cursor -= multiLength;
1051
+ if (cursor < len) {
1052
+ textTokens.push(tokens[cursor]);
1053
+ cursor++;
1054
+ }
1055
+ } else {
1056
+ if (textTokens.length > 0) {
1057
+ multis.push(initMultiToken(Text$1, input, textTokens));
1058
+ textTokens = [];
1059
+ }
1060
+ cursor -= sinceAccepts;
1061
+ multiLength -= sinceAccepts;
1062
+ const Multi = latestAccepting.t;
1063
+ const subtokens = tokens.slice(cursor - multiLength, cursor);
1064
+ multis.push(initMultiToken(Multi, input, subtokens));
1065
+ }
1066
+ }
1067
+ if (textTokens.length > 0) {
1068
+ multis.push(initMultiToken(Text$1, input, textTokens));
1069
+ }
1070
+ return multis;
1071
+ }
1072
+ function initMultiToken(Multi, input, tokens) {
1073
+ const startIdx = tokens[0].s;
1074
+ const endIdx = tokens[tokens.length - 1].e;
1075
+ const value = input.slice(startIdx, endIdx);
1076
+ return new Multi(value, tokens);
1077
+ }
1078
+ const warn = typeof console !== "undefined" && console && console.warn || (() => {
1079
+ });
1080
+ const warnAdvice = "until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.";
1081
+ const INIT = {
1082
+ scanner: null,
1083
+ parser: null,
1084
+ tokenQueue: [],
1085
+ pluginQueue: [],
1086
+ customSchemes: [],
1087
+ initialized: false
1088
+ };
1089
+ function reset() {
1090
+ State.groups = {};
1091
+ INIT.scanner = null;
1092
+ INIT.parser = null;
1093
+ INIT.tokenQueue = [];
1094
+ INIT.pluginQueue = [];
1095
+ INIT.customSchemes = [];
1096
+ INIT.initialized = false;
1097
+ return INIT;
1098
+ }
1099
+ function registerCustomProtocol(scheme2, optionalSlashSlash = false) {
1100
+ if (INIT.initialized) {
1101
+ warn(`linkifyjs: already initialized - will not register custom scheme "${scheme2}" ${warnAdvice}`);
1102
+ }
1103
+ if (!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(scheme2)) {
1104
+ throw new Error(`linkifyjs: incorrect scheme format.
1105
+ 1. Must only contain digits, lowercase ASCII letters or "-"
1106
+ 2. Cannot start or end with "-"
1107
+ 3. "-" cannot repeat`);
1108
+ }
1109
+ INIT.customSchemes.push([scheme2, optionalSlashSlash]);
1110
+ }
1111
+ function init() {
1112
+ INIT.scanner = init$2(INIT.customSchemes);
1113
+ for (let i = 0; i < INIT.tokenQueue.length; i++) {
1114
+ INIT.tokenQueue[i][1]({
1115
+ scanner: INIT.scanner
1116
+ });
1117
+ }
1118
+ INIT.parser = init$1(INIT.scanner.tokens);
1119
+ for (let i = 0; i < INIT.pluginQueue.length; i++) {
1120
+ INIT.pluginQueue[i][1]({
1121
+ scanner: INIT.scanner,
1122
+ parser: INIT.parser
1123
+ });
1124
+ }
1125
+ INIT.initialized = true;
1126
+ return INIT;
1127
+ }
1128
+ function tokenize(str) {
1129
+ if (!INIT.initialized) {
1130
+ init();
1131
+ }
1132
+ return run(INIT.parser.start, str, run$1(INIT.scanner.start, str));
1133
+ }
1134
+ tokenize.scan = run$1;
1135
+ function find(str, type = null, opts = null) {
1136
+ if (type && typeof type === "object") {
1137
+ if (opts) {
1138
+ throw Error(`linkifyjs: Invalid link type ${type}; must be a string`);
1139
+ }
1140
+ opts = type;
1141
+ type = null;
1142
+ }
1143
+ const options = new Options(opts);
1144
+ const tokens = tokenize(str);
1145
+ const filtered = [];
1146
+ for (let i = 0; i < tokens.length; i++) {
1147
+ const token = tokens[i];
1148
+ if (token.isLink && (!type || token.t === type) && options.check(token)) {
1149
+ filtered.push(token.toFormattedObject(options));
1150
+ }
1151
+ }
1152
+ return filtered;
1153
+ }
1154
+ var UNICODE_WHITESPACE_PATTERN = "[\0-   ᠎ -\u2029  ]";
1155
+ var UNICODE_WHITESPACE_REGEX = new RegExp(UNICODE_WHITESPACE_PATTERN);
1156
+ var UNICODE_WHITESPACE_REGEX_END = new RegExp(`${UNICODE_WHITESPACE_PATTERN}$`);
1157
+ var UNICODE_WHITESPACE_REGEX_GLOBAL = new RegExp(UNICODE_WHITESPACE_PATTERN, "g");
1158
+ function isValidLinkStructure(tokens) {
1159
+ if (tokens.length === 1) {
1160
+ return tokens[0].isLink;
1161
+ }
1162
+ if (tokens.length === 3 && tokens[1].isLink) {
1163
+ return ["()", "[]"].includes(tokens[0].value + tokens[2].value);
1164
+ }
1165
+ return false;
1166
+ }
1167
+ function autolink(options) {
1168
+ return new Plugin({
1169
+ key: new PluginKey("autolink"),
1170
+ appendTransaction: (transactions, oldState, newState) => {
1171
+ const docChanges = transactions.some((transaction) => transaction.docChanged) && !oldState.doc.eq(newState.doc);
1172
+ const preventAutolink = transactions.some((transaction) => transaction.getMeta("preventAutolink"));
1173
+ if (!docChanges || preventAutolink) {
1174
+ return;
1175
+ }
1176
+ const { tr: tr2 } = newState;
1177
+ const transform = combineTransactionSteps(oldState.doc, [...transactions]);
1178
+ const changes = getChangedRanges(transform);
1179
+ changes.forEach(({ newRange }) => {
1180
+ const nodesInChangedRanges = findChildrenInRange(newState.doc, newRange, (node) => node.isTextblock);
1181
+ let textBlock;
1182
+ let textBeforeWhitespace;
1183
+ if (nodesInChangedRanges.length > 1) {
1184
+ textBlock = nodesInChangedRanges[0];
1185
+ textBeforeWhitespace = newState.doc.textBetween(
1186
+ textBlock.pos,
1187
+ textBlock.pos + textBlock.node.nodeSize,
1188
+ void 0,
1189
+ " "
1190
+ );
1191
+ } else if (nodesInChangedRanges.length) {
1192
+ const endText = newState.doc.textBetween(newRange.from, newRange.to, " ", " ");
1193
+ if (!UNICODE_WHITESPACE_REGEX_END.test(endText)) {
1194
+ return;
1195
+ }
1196
+ textBlock = nodesInChangedRanges[0];
1197
+ textBeforeWhitespace = newState.doc.textBetween(textBlock.pos, newRange.to, void 0, " ");
1198
+ }
1199
+ if (textBlock && textBeforeWhitespace) {
1200
+ const wordsBeforeWhitespace = textBeforeWhitespace.split(UNICODE_WHITESPACE_REGEX).filter(Boolean);
1201
+ if (wordsBeforeWhitespace.length <= 0) {
1202
+ return false;
1203
+ }
1204
+ const lastWordBeforeSpace = wordsBeforeWhitespace[wordsBeforeWhitespace.length - 1];
1205
+ const lastWordAndBlockOffset = textBlock.pos + textBeforeWhitespace.lastIndexOf(lastWordBeforeSpace);
1206
+ if (!lastWordBeforeSpace) {
1207
+ return false;
1208
+ }
1209
+ const linksBeforeSpace = tokenize(lastWordBeforeSpace).map((t) => t.toObject(options.defaultProtocol));
1210
+ if (!isValidLinkStructure(linksBeforeSpace)) {
1211
+ return false;
1212
+ }
1213
+ linksBeforeSpace.filter((link) => link.isLink).map((link) => ({
1214
+ ...link,
1215
+ from: lastWordAndBlockOffset + link.start + 1,
1216
+ to: lastWordAndBlockOffset + link.end + 1
1217
+ })).filter((link) => {
1218
+ if (!newState.schema.marks.code) {
1219
+ return true;
1220
+ }
1221
+ return !newState.doc.rangeHasMark(link.from, link.to, newState.schema.marks.code);
1222
+ }).filter((link) => options.validate(link.value)).filter((link) => options.shouldAutoLink(link.value)).forEach((link) => {
1223
+ if (getMarksBetween(link.from, link.to, newState.doc).some((item) => item.mark.type === options.type)) {
1224
+ return;
1225
+ }
1226
+ tr2.addMark(
1227
+ link.from,
1228
+ link.to,
1229
+ options.type.create({
1230
+ href: link.href
1231
+ })
1232
+ );
1233
+ });
1234
+ }
1235
+ });
1236
+ if (!tr2.steps.length) {
1237
+ return;
1238
+ }
1239
+ return tr2;
1240
+ }
1241
+ });
1242
+ }
1243
+ function clickHandler(options) {
1244
+ return new Plugin({
1245
+ key: new PluginKey("handleClickLink"),
1246
+ props: {
1247
+ handleClick: (view, pos, event) => {
1248
+ var _a, _b;
1249
+ if (event.button !== 0) {
1250
+ return false;
1251
+ }
1252
+ if (!view.editable) {
1253
+ return false;
1254
+ }
1255
+ let link = null;
1256
+ if (event.target instanceof HTMLAnchorElement) {
1257
+ link = event.target;
1258
+ } else {
1259
+ let a = event.target;
1260
+ const els = [];
1261
+ while (a.nodeName !== "DIV") {
1262
+ els.push(a);
1263
+ a = a.parentNode;
1264
+ }
1265
+ link = els.find((value) => value.nodeName === "A");
1266
+ }
1267
+ if (!link) {
1268
+ return false;
1269
+ }
1270
+ const attrs = getAttributes(view.state, options.type.name);
1271
+ const href = (_a = link == null ? void 0 : link.href) != null ? _a : attrs.href;
1272
+ const target = (_b = link == null ? void 0 : link.target) != null ? _b : attrs.target;
1273
+ if (options.enableClickSelection) {
1274
+ options.editor.commands.extendMarkRange(options.type.name);
1275
+ }
1276
+ if (link && href) {
1277
+ window.open(href, target);
1278
+ return true;
1279
+ }
1280
+ return false;
1281
+ }
1282
+ }
1283
+ });
1284
+ }
1285
+ function pasteHandler(options) {
1286
+ return new Plugin({
1287
+ key: new PluginKey("handlePasteLink"),
1288
+ props: {
1289
+ handlePaste: (view, event, slice2) => {
1290
+ const { state } = view;
1291
+ const { selection } = state;
1292
+ const { empty } = selection;
1293
+ if (empty) {
1294
+ return false;
1295
+ }
1296
+ let textContent = "";
1297
+ slice2.content.forEach((node) => {
1298
+ textContent += node.textContent;
1299
+ });
1300
+ const link = find(textContent, { defaultProtocol: options.defaultProtocol }).find(
1301
+ (item) => item.isLink && item.value === textContent
1302
+ );
1303
+ if (!textContent || !link) {
1304
+ return false;
1305
+ }
1306
+ return options.editor.commands.setMark(options.type, {
1307
+ href: link.href
1308
+ });
1309
+ }
1310
+ }
1311
+ });
1312
+ }
1313
+ function isAllowedUri(uri, protocols) {
1314
+ const allowedProtocols = ["http", "https", "ftp", "ftps", "mailto", "tel", "callto", "sms", "cid", "xmpp"];
1315
+ if (protocols) {
1316
+ protocols.forEach((protocol) => {
1317
+ const nextProtocol = typeof protocol === "string" ? protocol : protocol.scheme;
1318
+ if (nextProtocol) {
1319
+ allowedProtocols.push(nextProtocol);
1320
+ }
1321
+ });
1322
+ }
1323
+ return !uri || uri.replace(UNICODE_WHITESPACE_REGEX_GLOBAL, "").match(
1324
+ new RegExp(
1325
+ // eslint-disable-next-line no-useless-escape
1326
+ `^(?:(?:${allowedProtocols.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,
1327
+ "i"
1328
+ )
1329
+ );
1330
+ }
1331
+ var Link = Mark.create({
1332
+ name: "link",
1333
+ priority: 1e3,
1334
+ keepOnSplit: false,
1335
+ exitable: true,
1336
+ onCreate() {
1337
+ if (this.options.validate && !this.options.shouldAutoLink) {
1338
+ this.options.shouldAutoLink = this.options.validate;
1339
+ console.warn("The `validate` option is deprecated. Rename to the `shouldAutoLink` option instead.");
1340
+ }
1341
+ this.options.protocols.forEach((protocol) => {
1342
+ if (typeof protocol === "string") {
1343
+ registerCustomProtocol(protocol);
1344
+ return;
1345
+ }
1346
+ registerCustomProtocol(protocol.scheme, protocol.optionalSlashes);
1347
+ });
1348
+ },
1349
+ onDestroy() {
1350
+ reset();
1351
+ },
1352
+ inclusive() {
1353
+ return this.options.autolink;
1354
+ },
1355
+ addOptions() {
1356
+ return {
1357
+ openOnClick: true,
1358
+ enableClickSelection: false,
1359
+ linkOnPaste: true,
1360
+ autolink: true,
1361
+ protocols: [],
1362
+ defaultProtocol: "http",
1363
+ HTMLAttributes: {
1364
+ target: "_blank",
1365
+ rel: "noopener noreferrer nofollow",
1366
+ class: null
1367
+ },
1368
+ isAllowedUri: (url, ctx) => !!isAllowedUri(url, ctx.protocols),
1369
+ validate: (url) => !!url,
1370
+ shouldAutoLink: (url) => !!url
1371
+ };
1372
+ },
1373
+ addAttributes() {
1374
+ return {
1375
+ href: {
1376
+ default: null,
1377
+ parseHTML(element) {
1378
+ return element.getAttribute("href");
1379
+ }
1380
+ },
1381
+ target: {
1382
+ default: this.options.HTMLAttributes.target
1383
+ },
1384
+ rel: {
1385
+ default: this.options.HTMLAttributes.rel
1386
+ },
1387
+ class: {
1388
+ default: this.options.HTMLAttributes.class
1389
+ }
1390
+ };
1391
+ },
1392
+ parseHTML() {
1393
+ return [
1394
+ {
1395
+ tag: "a[href]",
1396
+ getAttrs: (dom) => {
1397
+ const href = dom.getAttribute("href");
1398
+ if (!href || !this.options.isAllowedUri(href, {
1399
+ defaultValidate: (url) => !!isAllowedUri(url, this.options.protocols),
1400
+ protocols: this.options.protocols,
1401
+ defaultProtocol: this.options.defaultProtocol
1402
+ })) {
1403
+ return false;
1404
+ }
1405
+ return null;
1406
+ }
1407
+ }
1408
+ ];
1409
+ },
1410
+ renderHTML({ HTMLAttributes }) {
1411
+ if (!this.options.isAllowedUri(HTMLAttributes.href, {
1412
+ defaultValidate: (href) => !!isAllowedUri(href, this.options.protocols),
1413
+ protocols: this.options.protocols,
1414
+ defaultProtocol: this.options.defaultProtocol
1415
+ })) {
1416
+ return ["a", mergeAttributes(this.options.HTMLAttributes, { ...HTMLAttributes, href: "" }), 0];
1417
+ }
1418
+ return ["a", mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
1419
+ },
1420
+ addCommands() {
1421
+ return {
1422
+ setLink: (attributes) => ({ chain }) => {
1423
+ const { href } = attributes;
1424
+ if (!this.options.isAllowedUri(href, {
1425
+ defaultValidate: (url) => !!isAllowedUri(url, this.options.protocols),
1426
+ protocols: this.options.protocols,
1427
+ defaultProtocol: this.options.defaultProtocol
1428
+ })) {
1429
+ return false;
1430
+ }
1431
+ return chain().setMark(this.name, attributes).setMeta("preventAutolink", true).run();
1432
+ },
1433
+ toggleLink: (attributes) => ({ chain }) => {
1434
+ const { href } = attributes || {};
1435
+ if (href && !this.options.isAllowedUri(href, {
1436
+ defaultValidate: (url) => !!isAllowedUri(url, this.options.protocols),
1437
+ protocols: this.options.protocols,
1438
+ defaultProtocol: this.options.defaultProtocol
1439
+ })) {
1440
+ return false;
1441
+ }
1442
+ return chain().toggleMark(this.name, attributes, { extendEmptyMarkRange: true }).setMeta("preventAutolink", true).run();
1443
+ },
1444
+ unsetLink: () => ({ chain }) => {
1445
+ return chain().unsetMark(this.name, { extendEmptyMarkRange: true }).setMeta("preventAutolink", true).run();
1446
+ }
1447
+ };
1448
+ },
1449
+ addPasteRules() {
1450
+ return [
1451
+ markPasteRule({
1452
+ find: (text) => {
1453
+ const foundLinks = [];
1454
+ if (text) {
1455
+ const { protocols, defaultProtocol } = this.options;
1456
+ const links = find(text).filter(
1457
+ (item) => item.isLink && this.options.isAllowedUri(item.value, {
1458
+ defaultValidate: (href) => !!isAllowedUri(href, protocols),
1459
+ protocols,
1460
+ defaultProtocol
1461
+ })
1462
+ );
1463
+ if (links.length) {
1464
+ links.forEach(
1465
+ (link) => foundLinks.push({
1466
+ text: link.value,
1467
+ data: {
1468
+ href: link.href
1469
+ },
1470
+ index: link.start
1471
+ })
1472
+ );
1473
+ }
1474
+ }
1475
+ return foundLinks;
1476
+ },
1477
+ type: this.type,
1478
+ getAttributes: (match) => {
1479
+ var _a;
1480
+ return {
1481
+ href: (_a = match.data) == null ? void 0 : _a.href
1482
+ };
1483
+ }
1484
+ })
1485
+ ];
1486
+ },
1487
+ addProseMirrorPlugins() {
1488
+ const plugins = [];
1489
+ const { protocols, defaultProtocol } = this.options;
1490
+ if (this.options.autolink) {
1491
+ plugins.push(
1492
+ autolink({
1493
+ type: this.type,
1494
+ defaultProtocol: this.options.defaultProtocol,
1495
+ validate: (url) => this.options.isAllowedUri(url, {
1496
+ defaultValidate: (href) => !!isAllowedUri(href, protocols),
1497
+ protocols,
1498
+ defaultProtocol
1499
+ }),
1500
+ shouldAutoLink: this.options.shouldAutoLink
1501
+ })
1502
+ );
1503
+ }
1504
+ if (this.options.openOnClick === true) {
1505
+ plugins.push(
1506
+ clickHandler({
1507
+ type: this.type,
1508
+ editor: this.editor,
1509
+ enableClickSelection: this.options.enableClickSelection
1510
+ })
1511
+ );
1512
+ }
1513
+ if (this.options.linkOnPaste) {
1514
+ plugins.push(
1515
+ pasteHandler({
1516
+ editor: this.editor,
1517
+ defaultProtocol: this.options.defaultProtocol,
1518
+ type: this.type
1519
+ })
1520
+ );
1521
+ }
1522
+ return plugins;
1523
+ }
1524
+ });
1525
+ var index_default$2 = Link;
1526
+ var TextAlign = Extension.create({
1527
+ name: "textAlign",
1528
+ addOptions() {
1529
+ return {
1530
+ types: [],
1531
+ alignments: ["left", "center", "right", "justify"],
1532
+ defaultAlignment: null
1533
+ };
1534
+ },
1535
+ addGlobalAttributes() {
1536
+ return [
1537
+ {
1538
+ types: this.options.types,
1539
+ attributes: {
1540
+ textAlign: {
1541
+ default: this.options.defaultAlignment,
1542
+ parseHTML: (element) => {
1543
+ const alignment = element.style.textAlign;
1544
+ return this.options.alignments.includes(alignment) ? alignment : this.options.defaultAlignment;
1545
+ },
1546
+ renderHTML: (attributes) => {
1547
+ if (!attributes.textAlign) {
1548
+ return {};
1549
+ }
1550
+ return { style: `text-align: ${attributes.textAlign}` };
1551
+ }
1552
+ }
1553
+ }
1554
+ }
1555
+ ];
1556
+ },
1557
+ addCommands() {
1558
+ return {
1559
+ setTextAlign: (alignment) => ({ commands }) => {
1560
+ if (!this.options.alignments.includes(alignment)) {
1561
+ return false;
1562
+ }
1563
+ return this.options.types.map((type) => commands.updateAttributes(type, { textAlign: alignment })).every((response) => response);
1564
+ },
1565
+ unsetTextAlign: () => ({ commands }) => {
1566
+ return this.options.types.map((type) => commands.resetAttributes(type, "textAlign")).every((response) => response);
1567
+ },
1568
+ toggleTextAlign: (alignment) => ({ editor, commands }) => {
1569
+ if (!this.options.alignments.includes(alignment)) {
1570
+ return false;
1571
+ }
1572
+ if (editor.isActive({ textAlign: alignment })) {
1573
+ return commands.unsetTextAlign();
1574
+ }
1575
+ return commands.setTextAlign(alignment);
1576
+ }
1577
+ };
1578
+ },
1579
+ addKeyboardShortcuts() {
1580
+ return {
1581
+ "Mod-Shift-l": () => this.editor.commands.setTextAlign("left"),
1582
+ "Mod-Shift-e": () => this.editor.commands.setTextAlign("center"),
1583
+ "Mod-Shift-r": () => this.editor.commands.setTextAlign("right"),
1584
+ "Mod-Shift-j": () => this.editor.commands.setTextAlign("justify")
1585
+ };
1586
+ }
1587
+ });
1588
+ var index_default$1 = TextAlign;
1589
+ var mergeNestedSpanStyles = (element) => {
1590
+ if (!element.children.length) {
1591
+ return;
1592
+ }
1593
+ const childSpans = element.querySelectorAll("span");
1594
+ if (!childSpans) {
1595
+ return;
1596
+ }
1597
+ childSpans.forEach((childSpan) => {
1598
+ var _a, _b;
1599
+ const childStyle = childSpan.getAttribute("style");
1600
+ const closestParentSpanStyleOfChild = (_b = (_a = childSpan.parentElement) == null ? void 0 : _a.closest("span")) == null ? void 0 : _b.getAttribute("style");
1601
+ childSpan.setAttribute("style", `${closestParentSpanStyleOfChild};${childStyle}`);
1602
+ });
1603
+ };
1604
+ var TextStyle = Mark.create({
1605
+ name: "textStyle",
1606
+ priority: 101,
1607
+ addOptions() {
1608
+ return {
1609
+ HTMLAttributes: {},
1610
+ mergeNestedSpanStyles: true
1611
+ };
1612
+ },
1613
+ parseHTML() {
1614
+ return [
1615
+ {
1616
+ tag: "span",
1617
+ consuming: false,
1618
+ getAttrs: (element) => {
1619
+ const hasStyles = element.hasAttribute("style");
1620
+ if (!hasStyles) {
1621
+ return false;
1622
+ }
1623
+ if (this.options.mergeNestedSpanStyles) {
1624
+ mergeNestedSpanStyles(element);
1625
+ }
1626
+ return {};
1627
+ }
1628
+ }
1629
+ ];
1630
+ },
1631
+ renderHTML({ HTMLAttributes }) {
1632
+ return ["span", mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
1633
+ },
1634
+ addCommands() {
1635
+ return {
1636
+ toggleTextStyle: (attributes) => ({ commands }) => {
1637
+ return commands.toggleMark(this.name, attributes);
1638
+ },
1639
+ removeEmptyTextStyle: () => ({ tr: tr2 }) => {
1640
+ const { selection } = tr2;
1641
+ tr2.doc.nodesBetween(selection.from, selection.to, (node, pos) => {
1642
+ if (node.isTextblock) {
1643
+ return true;
1644
+ }
1645
+ if (!node.marks.filter((mark) => mark.type === this.type).some((mark) => Object.values(mark.attrs).some((value) => !!value))) {
1646
+ tr2.removeMark(pos, pos + node.nodeSize, this.type);
1647
+ }
1648
+ });
1649
+ return true;
1650
+ }
1651
+ };
1652
+ }
1653
+ });
1654
+ var BackgroundColor = Extension.create({
1655
+ name: "backgroundColor",
1656
+ addOptions() {
1657
+ return {
1658
+ types: ["textStyle"]
1659
+ };
1660
+ },
1661
+ addGlobalAttributes() {
1662
+ return [
1663
+ {
1664
+ types: this.options.types,
1665
+ attributes: {
1666
+ backgroundColor: {
1667
+ default: null,
1668
+ parseHTML: (element) => {
1669
+ var _a;
1670
+ return (_a = element.style.backgroundColor) == null ? void 0 : _a.replace(/['"]+/g, "");
1671
+ },
1672
+ renderHTML: (attributes) => {
1673
+ if (!attributes.backgroundColor) {
1674
+ return {};
1675
+ }
1676
+ return {
1677
+ style: `background-color: ${attributes.backgroundColor}`
1678
+ };
1679
+ }
1680
+ }
1681
+ }
1682
+ }
1683
+ ];
1684
+ },
1685
+ addCommands() {
1686
+ return {
1687
+ setBackgroundColor: (backgroundColor) => ({ chain }) => {
1688
+ return chain().setMark("textStyle", { backgroundColor }).run();
1689
+ },
1690
+ unsetBackgroundColor: () => ({ chain }) => {
1691
+ return chain().setMark("textStyle", { backgroundColor: null }).removeEmptyTextStyle().run();
1692
+ }
1693
+ };
1694
+ }
1695
+ });
1696
+ var Color = Extension.create({
1697
+ name: "color",
1698
+ addOptions() {
1699
+ return {
1700
+ types: ["textStyle"]
1701
+ };
1702
+ },
1703
+ addGlobalAttributes() {
1704
+ return [
1705
+ {
1706
+ types: this.options.types,
1707
+ attributes: {
1708
+ color: {
1709
+ default: null,
1710
+ parseHTML: (element) => {
1711
+ var _a;
1712
+ return (_a = element.style.color) == null ? void 0 : _a.replace(/['"]+/g, "");
1713
+ },
1714
+ renderHTML: (attributes) => {
1715
+ if (!attributes.color) {
1716
+ return {};
1717
+ }
1718
+ return {
1719
+ style: `color: ${attributes.color}`
1720
+ };
1721
+ }
1722
+ }
1723
+ }
1724
+ }
1725
+ ];
1726
+ },
1727
+ addCommands() {
1728
+ return {
1729
+ setColor: (color) => ({ chain }) => {
1730
+ return chain().setMark("textStyle", { color }).run();
1731
+ },
1732
+ unsetColor: () => ({ chain }) => {
1733
+ return chain().setMark("textStyle", { color: null }).removeEmptyTextStyle().run();
1734
+ }
1735
+ };
1736
+ }
1737
+ });
1738
+ var FontFamily = Extension.create({
1739
+ name: "fontFamily",
1740
+ addOptions() {
1741
+ return {
1742
+ types: ["textStyle"]
1743
+ };
1744
+ },
1745
+ addGlobalAttributes() {
1746
+ return [
1747
+ {
1748
+ types: this.options.types,
1749
+ attributes: {
1750
+ fontFamily: {
1751
+ default: null,
1752
+ parseHTML: (element) => element.style.fontFamily,
1753
+ renderHTML: (attributes) => {
1754
+ if (!attributes.fontFamily) {
1755
+ return {};
1756
+ }
1757
+ return {
1758
+ style: `font-family: ${attributes.fontFamily}`
1759
+ };
1760
+ }
1761
+ }
1762
+ }
1763
+ }
1764
+ ];
1765
+ },
1766
+ addCommands() {
1767
+ return {
1768
+ setFontFamily: (fontFamily) => ({ chain }) => {
1769
+ return chain().setMark("textStyle", { fontFamily }).run();
1770
+ },
1771
+ unsetFontFamily: () => ({ chain }) => {
1772
+ return chain().setMark("textStyle", { fontFamily: null }).removeEmptyTextStyle().run();
1773
+ }
1774
+ };
1775
+ }
1776
+ });
1777
+ var FontSize = Extension.create({
1778
+ name: "fontSize",
1779
+ addOptions() {
1780
+ return {
1781
+ types: ["textStyle"]
1782
+ };
1783
+ },
1784
+ addGlobalAttributes() {
1785
+ return [
1786
+ {
1787
+ types: this.options.types,
1788
+ attributes: {
1789
+ fontSize: {
1790
+ default: null,
1791
+ parseHTML: (element) => element.style.fontSize,
1792
+ renderHTML: (attributes) => {
1793
+ if (!attributes.fontSize) {
1794
+ return {};
1795
+ }
1796
+ return {
1797
+ style: `font-size: ${attributes.fontSize}`
1798
+ };
1799
+ }
1800
+ }
1801
+ }
1802
+ }
1803
+ ];
1804
+ },
1805
+ addCommands() {
1806
+ return {
1807
+ setFontSize: (fontSize) => ({ chain }) => {
1808
+ return chain().setMark("textStyle", { fontSize }).run();
1809
+ },
1810
+ unsetFontSize: () => ({ chain }) => {
1811
+ return chain().setMark("textStyle", { fontSize: null }).removeEmptyTextStyle().run();
1812
+ }
1813
+ };
1814
+ }
1815
+ });
1816
+ var LineHeight = Extension.create({
1817
+ name: "lineHeight",
1818
+ addOptions() {
1819
+ return {
1820
+ types: ["textStyle"]
1821
+ };
1822
+ },
1823
+ addGlobalAttributes() {
1824
+ return [
1825
+ {
1826
+ types: this.options.types,
1827
+ attributes: {
1828
+ lineHeight: {
1829
+ default: null,
1830
+ parseHTML: (element) => element.style.lineHeight,
1831
+ renderHTML: (attributes) => {
1832
+ if (!attributes.lineHeight) {
1833
+ return {};
1834
+ }
1835
+ return {
1836
+ style: `line-height: ${attributes.lineHeight}`
1837
+ };
1838
+ }
1839
+ }
1840
+ }
1841
+ }
1842
+ ];
1843
+ },
1844
+ addCommands() {
1845
+ return {
1846
+ setLineHeight: (lineHeight) => ({ chain }) => {
1847
+ return chain().setMark("textStyle", { lineHeight }).run();
1848
+ },
1849
+ unsetLineHeight: () => ({ chain }) => {
1850
+ return chain().setMark("textStyle", { lineHeight: null }).removeEmptyTextStyle().run();
1851
+ }
1852
+ };
1853
+ }
1854
+ });
1855
+ var TextStyleKit = Extension.create({
1856
+ name: "textStyleKit",
1857
+ addExtensions() {
1858
+ const extensions = [];
1859
+ if (this.options.backgroundColor !== false) {
1860
+ extensions.push(BackgroundColor.configure(this.options.backgroundColor));
1861
+ }
1862
+ if (this.options.color !== false) {
1863
+ extensions.push(Color.configure(this.options.color));
1864
+ }
1865
+ if (this.options.fontFamily !== false) {
1866
+ extensions.push(FontFamily.configure(this.options.fontFamily));
1867
+ }
1868
+ if (this.options.fontSize !== false) {
1869
+ extensions.push(FontSize.configure(this.options.fontSize));
1870
+ }
1871
+ if (this.options.lineHeight !== false) {
1872
+ extensions.push(LineHeight.configure(this.options.lineHeight));
1873
+ }
1874
+ if (this.options.textStyle !== false) {
1875
+ extensions.push(TextStyle.configure(this.options.textStyle));
1876
+ }
1877
+ return extensions;
1878
+ }
1879
+ });
1880
+ function dropCursor(options = {}) {
1881
+ return new Plugin({
1882
+ view(editorView) {
1883
+ return new DropCursorView(editorView, options);
1884
+ }
1885
+ });
1886
+ }
1887
+ class DropCursorView {
1888
+ constructor(editorView, options) {
1889
+ var _a;
1890
+ this.editorView = editorView;
1891
+ this.cursorPos = null;
1892
+ this.element = null;
1893
+ this.timeout = -1;
1894
+ this.width = (_a = options.width) !== null && _a !== void 0 ? _a : 1;
1895
+ this.color = options.color === false ? void 0 : options.color || "black";
1896
+ this.class = options.class;
1897
+ this.handlers = ["dragover", "dragend", "drop", "dragleave"].map((name) => {
1898
+ let handler = (e) => {
1899
+ this[name](e);
1900
+ };
1901
+ editorView.dom.addEventListener(name, handler);
1902
+ return { name, handler };
1903
+ });
1904
+ }
1905
+ destroy() {
1906
+ this.handlers.forEach(({ name, handler }) => this.editorView.dom.removeEventListener(name, handler));
1907
+ }
1908
+ update(editorView, prevState) {
1909
+ if (this.cursorPos != null && prevState.doc != editorView.state.doc) {
1910
+ if (this.cursorPos > editorView.state.doc.content.size)
1911
+ this.setCursor(null);
1912
+ else
1913
+ this.updateOverlay();
1914
+ }
1915
+ }
1916
+ setCursor(pos) {
1917
+ if (pos == this.cursorPos)
1918
+ return;
1919
+ this.cursorPos = pos;
1920
+ if (pos == null) {
1921
+ this.element.parentNode.removeChild(this.element);
1922
+ this.element = null;
1923
+ } else {
1924
+ this.updateOverlay();
1925
+ }
1926
+ }
1927
+ updateOverlay() {
1928
+ let $pos = this.editorView.state.doc.resolve(this.cursorPos);
1929
+ let isBlock = !$pos.parent.inlineContent, rect;
1930
+ let editorDOM = this.editorView.dom, editorRect = editorDOM.getBoundingClientRect();
1931
+ let scaleX = editorRect.width / editorDOM.offsetWidth, scaleY = editorRect.height / editorDOM.offsetHeight;
1932
+ if (isBlock) {
1933
+ let before = $pos.nodeBefore, after = $pos.nodeAfter;
1934
+ if (before || after) {
1935
+ let node = this.editorView.nodeDOM(this.cursorPos - (before ? before.nodeSize : 0));
1936
+ if (node) {
1937
+ let nodeRect = node.getBoundingClientRect();
1938
+ let top = before ? nodeRect.bottom : nodeRect.top;
1939
+ if (before && after)
1940
+ top = (top + this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top) / 2;
1941
+ let halfWidth = this.width / 2 * scaleY;
1942
+ rect = { left: nodeRect.left, right: nodeRect.right, top: top - halfWidth, bottom: top + halfWidth };
1943
+ }
1944
+ }
1945
+ }
1946
+ if (!rect) {
1947
+ let coords = this.editorView.coordsAtPos(this.cursorPos);
1948
+ let halfWidth = this.width / 2 * scaleX;
1949
+ rect = { left: coords.left - halfWidth, right: coords.left + halfWidth, top: coords.top, bottom: coords.bottom };
1950
+ }
1951
+ let parent = this.editorView.dom.offsetParent;
1952
+ if (!this.element) {
1953
+ this.element = parent.appendChild(document.createElement("div"));
1954
+ if (this.class)
1955
+ this.element.className = this.class;
1956
+ this.element.style.cssText = "position: absolute; z-index: 50; pointer-events: none;";
1957
+ if (this.color) {
1958
+ this.element.style.backgroundColor = this.color;
1959
+ }
1960
+ }
1961
+ this.element.classList.toggle("prosemirror-dropcursor-block", isBlock);
1962
+ this.element.classList.toggle("prosemirror-dropcursor-inline", !isBlock);
1963
+ let parentLeft, parentTop;
1964
+ if (!parent || parent == document.body && getComputedStyle(parent).position == "static") {
1965
+ parentLeft = -pageXOffset;
1966
+ parentTop = -pageYOffset;
1967
+ } else {
1968
+ let rect2 = parent.getBoundingClientRect();
1969
+ let parentScaleX = rect2.width / parent.offsetWidth, parentScaleY = rect2.height / parent.offsetHeight;
1970
+ parentLeft = rect2.left - parent.scrollLeft * parentScaleX;
1971
+ parentTop = rect2.top - parent.scrollTop * parentScaleY;
1972
+ }
1973
+ this.element.style.left = (rect.left - parentLeft) / scaleX + "px";
1974
+ this.element.style.top = (rect.top - parentTop) / scaleY + "px";
1975
+ this.element.style.width = (rect.right - rect.left) / scaleX + "px";
1976
+ this.element.style.height = (rect.bottom - rect.top) / scaleY + "px";
1977
+ }
1978
+ scheduleRemoval(timeout) {
1979
+ clearTimeout(this.timeout);
1980
+ this.timeout = setTimeout(() => this.setCursor(null), timeout);
1981
+ }
1982
+ dragover(event) {
1983
+ if (!this.editorView.editable)
1984
+ return;
1985
+ let pos = this.editorView.posAtCoords({ left: event.clientX, top: event.clientY });
1986
+ let node = pos && pos.inside >= 0 && this.editorView.state.doc.nodeAt(pos.inside);
1987
+ let disableDropCursor = node && node.type.spec.disableDropCursor;
1988
+ let disabled = typeof disableDropCursor == "function" ? disableDropCursor(this.editorView, pos, event) : disableDropCursor;
1989
+ if (pos && !disabled) {
1990
+ let target = pos.pos;
1991
+ if (this.editorView.dragging && this.editorView.dragging.slice) {
1992
+ let point = dropPoint(this.editorView.state.doc, target, this.editorView.dragging.slice);
1993
+ if (point != null)
1994
+ target = point;
1995
+ }
1996
+ this.setCursor(target);
1997
+ this.scheduleRemoval(5e3);
1998
+ }
1999
+ }
2000
+ dragend() {
2001
+ this.scheduleRemoval(20);
2002
+ }
2003
+ drop() {
2004
+ this.scheduleRemoval(20);
2005
+ }
2006
+ dragleave(event) {
2007
+ if (!this.editorView.dom.contains(event.relatedTarget))
2008
+ this.setCursor(null);
2009
+ }
2010
+ }
2011
+ class GapCursor extends Selection {
2012
+ /**
2013
+ Create a gap cursor.
2014
+ */
2015
+ constructor($pos) {
2016
+ super($pos, $pos);
2017
+ }
2018
+ map(doc, mapping) {
2019
+ let $pos = doc.resolve(mapping.map(this.head));
2020
+ return GapCursor.valid($pos) ? new GapCursor($pos) : Selection.near($pos);
2021
+ }
2022
+ content() {
2023
+ return Slice.empty;
2024
+ }
2025
+ eq(other) {
2026
+ return other instanceof GapCursor && other.head == this.head;
2027
+ }
2028
+ toJSON() {
2029
+ return { type: "gapcursor", pos: this.head };
2030
+ }
2031
+ /**
2032
+ @internal
2033
+ */
2034
+ static fromJSON(doc, json) {
2035
+ if (typeof json.pos != "number")
2036
+ throw new RangeError("Invalid input for GapCursor.fromJSON");
2037
+ return new GapCursor(doc.resolve(json.pos));
2038
+ }
2039
+ /**
2040
+ @internal
2041
+ */
2042
+ getBookmark() {
2043
+ return new GapBookmark(this.anchor);
2044
+ }
2045
+ /**
2046
+ @internal
2047
+ */
2048
+ static valid($pos) {
2049
+ let parent = $pos.parent;
2050
+ if (parent.isTextblock || !closedBefore($pos) || !closedAfter($pos))
2051
+ return false;
2052
+ let override = parent.type.spec.allowGapCursor;
2053
+ if (override != null)
2054
+ return override;
2055
+ let deflt = parent.contentMatchAt($pos.index()).defaultType;
2056
+ return deflt && deflt.isTextblock;
2057
+ }
2058
+ /**
2059
+ @internal
2060
+ */
2061
+ static findGapCursorFrom($pos, dir, mustMove = false) {
2062
+ search: for (; ; ) {
2063
+ if (!mustMove && GapCursor.valid($pos))
2064
+ return $pos;
2065
+ let pos = $pos.pos, next = null;
2066
+ for (let d = $pos.depth; ; d--) {
2067
+ let parent = $pos.node(d);
2068
+ if (dir > 0 ? $pos.indexAfter(d) < parent.childCount : $pos.index(d) > 0) {
2069
+ next = parent.child(dir > 0 ? $pos.indexAfter(d) : $pos.index(d) - 1);
2070
+ break;
2071
+ } else if (d == 0) {
2072
+ return null;
2073
+ }
2074
+ pos += dir;
2075
+ let $cur = $pos.doc.resolve(pos);
2076
+ if (GapCursor.valid($cur))
2077
+ return $cur;
2078
+ }
2079
+ for (; ; ) {
2080
+ let inside = dir > 0 ? next.firstChild : next.lastChild;
2081
+ if (!inside) {
2082
+ if (next.isAtom && !next.isText && !NodeSelection.isSelectable(next)) {
2083
+ $pos = $pos.doc.resolve(pos + next.nodeSize * dir);
2084
+ mustMove = false;
2085
+ continue search;
2086
+ }
2087
+ break;
2088
+ }
2089
+ next = inside;
2090
+ pos += dir;
2091
+ let $cur = $pos.doc.resolve(pos);
2092
+ if (GapCursor.valid($cur))
2093
+ return $cur;
2094
+ }
2095
+ return null;
2096
+ }
2097
+ }
2098
+ }
2099
+ GapCursor.prototype.visible = false;
2100
+ GapCursor.findFrom = GapCursor.findGapCursorFrom;
2101
+ Selection.jsonID("gapcursor", GapCursor);
2102
+ class GapBookmark {
2103
+ constructor(pos) {
2104
+ this.pos = pos;
2105
+ }
2106
+ map(mapping) {
2107
+ return new GapBookmark(mapping.map(this.pos));
2108
+ }
2109
+ resolve(doc) {
2110
+ let $pos = doc.resolve(this.pos);
2111
+ return GapCursor.valid($pos) ? new GapCursor($pos) : Selection.near($pos);
2112
+ }
2113
+ }
2114
+ function closedBefore($pos) {
2115
+ for (let d = $pos.depth; d >= 0; d--) {
2116
+ let index = $pos.index(d), parent = $pos.node(d);
2117
+ if (index == 0) {
2118
+ if (parent.type.spec.isolating)
2119
+ return true;
2120
+ continue;
2121
+ }
2122
+ for (let before = parent.child(index - 1); ; before = before.lastChild) {
2123
+ if (before.childCount == 0 && !before.inlineContent || before.isAtom || before.type.spec.isolating)
2124
+ return true;
2125
+ if (before.inlineContent)
2126
+ return false;
2127
+ }
2128
+ }
2129
+ return true;
2130
+ }
2131
+ function closedAfter($pos) {
2132
+ for (let d = $pos.depth; d >= 0; d--) {
2133
+ let index = $pos.indexAfter(d), parent = $pos.node(d);
2134
+ if (index == parent.childCount) {
2135
+ if (parent.type.spec.isolating)
2136
+ return true;
2137
+ continue;
2138
+ }
2139
+ for (let after = parent.child(index); ; after = after.firstChild) {
2140
+ if (after.childCount == 0 && !after.inlineContent || after.isAtom || after.type.spec.isolating)
2141
+ return true;
2142
+ if (after.inlineContent)
2143
+ return false;
2144
+ }
2145
+ }
2146
+ return true;
2147
+ }
2148
+ function gapCursor() {
2149
+ return new Plugin({
2150
+ props: {
2151
+ decorations: drawGapCursor,
2152
+ createSelectionBetween(_view, $anchor, $head) {
2153
+ return $anchor.pos == $head.pos && GapCursor.valid($head) ? new GapCursor($head) : null;
2154
+ },
2155
+ handleClick,
2156
+ handleKeyDown,
2157
+ handleDOMEvents: { beforeinput }
2158
+ }
2159
+ });
2160
+ }
2161
+ const handleKeyDown = keydownHandler({
2162
+ "ArrowLeft": arrow("horiz", -1),
2163
+ "ArrowRight": arrow("horiz", 1),
2164
+ "ArrowUp": arrow("vert", -1),
2165
+ "ArrowDown": arrow("vert", 1)
2166
+ });
2167
+ function arrow(axis, dir) {
2168
+ const dirStr = axis == "vert" ? dir > 0 ? "down" : "up" : dir > 0 ? "right" : "left";
2169
+ return function(state, dispatch, view) {
2170
+ let sel = state.selection;
2171
+ let $start = dir > 0 ? sel.$to : sel.$from, mustMove = sel.empty;
2172
+ if (sel instanceof TextSelection) {
2173
+ if (!view.endOfTextblock(dirStr) || $start.depth == 0)
2174
+ return false;
2175
+ mustMove = false;
2176
+ $start = state.doc.resolve(dir > 0 ? $start.after() : $start.before());
2177
+ }
2178
+ let $found = GapCursor.findGapCursorFrom($start, dir, mustMove);
2179
+ if (!$found)
2180
+ return false;
2181
+ if (dispatch)
2182
+ dispatch(state.tr.setSelection(new GapCursor($found)));
2183
+ return true;
2184
+ };
2185
+ }
2186
+ function handleClick(view, pos, event) {
2187
+ if (!view || !view.editable)
2188
+ return false;
2189
+ let $pos = view.state.doc.resolve(pos);
2190
+ if (!GapCursor.valid($pos))
2191
+ return false;
2192
+ let clickPos = view.posAtCoords({ left: event.clientX, top: event.clientY });
2193
+ if (clickPos && clickPos.inside > -1 && NodeSelection.isSelectable(view.state.doc.nodeAt(clickPos.inside)))
2194
+ return false;
2195
+ view.dispatch(view.state.tr.setSelection(new GapCursor($pos)));
2196
+ return true;
2197
+ }
2198
+ function beforeinput(view, event) {
2199
+ if (event.inputType != "insertCompositionText" || !(view.state.selection instanceof GapCursor))
2200
+ return false;
2201
+ let { $from } = view.state.selection;
2202
+ let insert = $from.parent.contentMatchAt($from.index()).findWrapping(view.state.schema.nodes.text);
2203
+ if (!insert)
2204
+ return false;
2205
+ let frag = Fragment.empty;
2206
+ for (let i = insert.length - 1; i >= 0; i--)
2207
+ frag = Fragment.from(insert[i].createAndFill(null, frag));
2208
+ let tr2 = view.state.tr.replace($from.pos, $from.pos, new Slice(frag, 0, 0));
2209
+ tr2.setSelection(TextSelection.near(tr2.doc.resolve($from.pos + 1)));
2210
+ view.dispatch(tr2);
2211
+ return false;
2212
+ }
2213
+ function drawGapCursor(state) {
2214
+ if (!(state.selection instanceof GapCursor))
2215
+ return null;
2216
+ let node = document.createElement("div");
2217
+ node.className = "ProseMirror-gapcursor";
2218
+ return DecorationSet.create(state.doc, [Decoration.widget(state.selection.head, node, { key: "gapcursor" })]);
2219
+ }
2220
+ var GOOD_LEAF_SIZE = 200;
2221
+ var RopeSequence = function RopeSequence2() {
2222
+ };
2223
+ RopeSequence.prototype.append = function append(other) {
2224
+ if (!other.length) {
2225
+ return this;
2226
+ }
2227
+ other = RopeSequence.from(other);
2228
+ return !this.length && other || other.length < GOOD_LEAF_SIZE && this.leafAppend(other) || this.length < GOOD_LEAF_SIZE && other.leafPrepend(this) || this.appendInner(other);
2229
+ };
2230
+ RopeSequence.prototype.prepend = function prepend(other) {
2231
+ if (!other.length) {
2232
+ return this;
2233
+ }
2234
+ return RopeSequence.from(other).append(this);
2235
+ };
2236
+ RopeSequence.prototype.appendInner = function appendInner(other) {
2237
+ return new Append(this, other);
2238
+ };
2239
+ RopeSequence.prototype.slice = function slice(from2, to) {
2240
+ if (from2 === void 0) from2 = 0;
2241
+ if (to === void 0) to = this.length;
2242
+ if (from2 >= to) {
2243
+ return RopeSequence.empty;
2244
+ }
2245
+ return this.sliceInner(Math.max(0, from2), Math.min(this.length, to));
2246
+ };
2247
+ RopeSequence.prototype.get = function get(i) {
2248
+ if (i < 0 || i >= this.length) {
2249
+ return void 0;
2250
+ }
2251
+ return this.getInner(i);
2252
+ };
2253
+ RopeSequence.prototype.forEach = function forEach(f, from2, to) {
2254
+ if (from2 === void 0) from2 = 0;
2255
+ if (to === void 0) to = this.length;
2256
+ if (from2 <= to) {
2257
+ this.forEachInner(f, from2, to, 0);
2258
+ } else {
2259
+ this.forEachInvertedInner(f, from2, to, 0);
2260
+ }
2261
+ };
2262
+ RopeSequence.prototype.map = function map(f, from2, to) {
2263
+ if (from2 === void 0) from2 = 0;
2264
+ if (to === void 0) to = this.length;
2265
+ var result = [];
2266
+ this.forEach(function(elt, i) {
2267
+ return result.push(f(elt, i));
2268
+ }, from2, to);
2269
+ return result;
2270
+ };
2271
+ RopeSequence.from = function from(values) {
2272
+ if (values instanceof RopeSequence) {
2273
+ return values;
2274
+ }
2275
+ return values && values.length ? new Leaf(values) : RopeSequence.empty;
2276
+ };
2277
+ var Leaf = /* @__PURE__ */ function(RopeSequence3) {
2278
+ function Leaf2(values) {
2279
+ RopeSequence3.call(this);
2280
+ this.values = values;
2281
+ }
2282
+ Leaf2.__proto__ = RopeSequence3;
2283
+ Leaf2.prototype = Object.create(RopeSequence3.prototype);
2284
+ Leaf2.prototype.constructor = Leaf2;
2285
+ var prototypeAccessors = { length: { configurable: true }, depth: { configurable: true } };
2286
+ Leaf2.prototype.flatten = function flatten() {
2287
+ return this.values;
2288
+ };
2289
+ Leaf2.prototype.sliceInner = function sliceInner(from2, to) {
2290
+ if (from2 == 0 && to == this.length) {
2291
+ return this;
2292
+ }
2293
+ return new Leaf2(this.values.slice(from2, to));
2294
+ };
2295
+ Leaf2.prototype.getInner = function getInner(i) {
2296
+ return this.values[i];
2297
+ };
2298
+ Leaf2.prototype.forEachInner = function forEachInner(f, from2, to, start) {
2299
+ for (var i = from2; i < to; i++) {
2300
+ if (f(this.values[i], start + i) === false) {
2301
+ return false;
2302
+ }
2303
+ }
2304
+ };
2305
+ Leaf2.prototype.forEachInvertedInner = function forEachInvertedInner(f, from2, to, start) {
2306
+ for (var i = from2 - 1; i >= to; i--) {
2307
+ if (f(this.values[i], start + i) === false) {
2308
+ return false;
2309
+ }
2310
+ }
2311
+ };
2312
+ Leaf2.prototype.leafAppend = function leafAppend(other) {
2313
+ if (this.length + other.length <= GOOD_LEAF_SIZE) {
2314
+ return new Leaf2(this.values.concat(other.flatten()));
2315
+ }
2316
+ };
2317
+ Leaf2.prototype.leafPrepend = function leafPrepend(other) {
2318
+ if (this.length + other.length <= GOOD_LEAF_SIZE) {
2319
+ return new Leaf2(other.flatten().concat(this.values));
2320
+ }
2321
+ };
2322
+ prototypeAccessors.length.get = function() {
2323
+ return this.values.length;
2324
+ };
2325
+ prototypeAccessors.depth.get = function() {
2326
+ return 0;
2327
+ };
2328
+ Object.defineProperties(Leaf2.prototype, prototypeAccessors);
2329
+ return Leaf2;
2330
+ }(RopeSequence);
2331
+ RopeSequence.empty = new Leaf([]);
2332
+ var Append = /* @__PURE__ */ function(RopeSequence3) {
2333
+ function Append2(left, right) {
2334
+ RopeSequence3.call(this);
2335
+ this.left = left;
2336
+ this.right = right;
2337
+ this.length = left.length + right.length;
2338
+ this.depth = Math.max(left.depth, right.depth) + 1;
2339
+ }
2340
+ Append2.__proto__ = RopeSequence3;
2341
+ Append2.prototype = Object.create(RopeSequence3.prototype);
2342
+ Append2.prototype.constructor = Append2;
2343
+ Append2.prototype.flatten = function flatten() {
2344
+ return this.left.flatten().concat(this.right.flatten());
2345
+ };
2346
+ Append2.prototype.getInner = function getInner(i) {
2347
+ return i < this.left.length ? this.left.get(i) : this.right.get(i - this.left.length);
2348
+ };
2349
+ Append2.prototype.forEachInner = function forEachInner(f, from2, to, start) {
2350
+ var leftLen = this.left.length;
2351
+ if (from2 < leftLen && this.left.forEachInner(f, from2, Math.min(to, leftLen), start) === false) {
2352
+ return false;
2353
+ }
2354
+ if (to > leftLen && this.right.forEachInner(f, Math.max(from2 - leftLen, 0), Math.min(this.length, to) - leftLen, start + leftLen) === false) {
2355
+ return false;
2356
+ }
2357
+ };
2358
+ Append2.prototype.forEachInvertedInner = function forEachInvertedInner(f, from2, to, start) {
2359
+ var leftLen = this.left.length;
2360
+ if (from2 > leftLen && this.right.forEachInvertedInner(f, from2 - leftLen, Math.max(to, leftLen) - leftLen, start + leftLen) === false) {
2361
+ return false;
2362
+ }
2363
+ if (to < leftLen && this.left.forEachInvertedInner(f, Math.min(from2, leftLen), to, start) === false) {
2364
+ return false;
2365
+ }
2366
+ };
2367
+ Append2.prototype.sliceInner = function sliceInner(from2, to) {
2368
+ if (from2 == 0 && to == this.length) {
2369
+ return this;
2370
+ }
2371
+ var leftLen = this.left.length;
2372
+ if (to <= leftLen) {
2373
+ return this.left.slice(from2, to);
2374
+ }
2375
+ if (from2 >= leftLen) {
2376
+ return this.right.slice(from2 - leftLen, to - leftLen);
2377
+ }
2378
+ return this.left.slice(from2, leftLen).append(this.right.slice(0, to - leftLen));
2379
+ };
2380
+ Append2.prototype.leafAppend = function leafAppend(other) {
2381
+ var inner = this.right.leafAppend(other);
2382
+ if (inner) {
2383
+ return new Append2(this.left, inner);
2384
+ }
2385
+ };
2386
+ Append2.prototype.leafPrepend = function leafPrepend(other) {
2387
+ var inner = this.left.leafPrepend(other);
2388
+ if (inner) {
2389
+ return new Append2(inner, this.right);
2390
+ }
2391
+ };
2392
+ Append2.prototype.appendInner = function appendInner2(other) {
2393
+ if (this.left.depth >= Math.max(this.right.depth, other.depth) + 1) {
2394
+ return new Append2(this.left, new Append2(this.right, other));
2395
+ }
2396
+ return new Append2(this, other);
2397
+ };
2398
+ return Append2;
2399
+ }(RopeSequence);
2400
+ const max_empty_items = 500;
2401
+ class Branch {
2402
+ constructor(items, eventCount) {
2403
+ this.items = items;
2404
+ this.eventCount = eventCount;
2405
+ }
2406
+ // Pop the latest event off the branch's history and apply it
2407
+ // to a document transform.
2408
+ popEvent(state, preserveItems) {
2409
+ if (this.eventCount == 0)
2410
+ return null;
2411
+ let end = this.items.length;
2412
+ for (; ; end--) {
2413
+ let next = this.items.get(end - 1);
2414
+ if (next.selection) {
2415
+ --end;
2416
+ break;
2417
+ }
2418
+ }
2419
+ let remap, mapFrom;
2420
+ if (preserveItems) {
2421
+ remap = this.remapping(end, this.items.length);
2422
+ mapFrom = remap.maps.length;
2423
+ }
2424
+ let transform = state.tr;
2425
+ let selection, remaining;
2426
+ let addAfter = [], addBefore = [];
2427
+ this.items.forEach((item, i) => {
2428
+ if (!item.step) {
2429
+ if (!remap) {
2430
+ remap = this.remapping(end, i + 1);
2431
+ mapFrom = remap.maps.length;
2432
+ }
2433
+ mapFrom--;
2434
+ addBefore.push(item);
2435
+ return;
2436
+ }
2437
+ if (remap) {
2438
+ addBefore.push(new Item(item.map));
2439
+ let step = item.step.map(remap.slice(mapFrom)), map2;
2440
+ if (step && transform.maybeStep(step).doc) {
2441
+ map2 = transform.mapping.maps[transform.mapping.maps.length - 1];
2442
+ addAfter.push(new Item(map2, void 0, void 0, addAfter.length + addBefore.length));
2443
+ }
2444
+ mapFrom--;
2445
+ if (map2)
2446
+ remap.appendMap(map2, mapFrom);
2447
+ } else {
2448
+ transform.maybeStep(item.step);
2449
+ }
2450
+ if (item.selection) {
2451
+ selection = remap ? item.selection.map(remap.slice(mapFrom)) : item.selection;
2452
+ remaining = new Branch(this.items.slice(0, end).append(addBefore.reverse().concat(addAfter)), this.eventCount - 1);
2453
+ return false;
2454
+ }
2455
+ }, this.items.length, 0);
2456
+ return { remaining, transform, selection };
2457
+ }
2458
+ // Create a new branch with the given transform added.
2459
+ addTransform(transform, selection, histOptions, preserveItems) {
2460
+ let newItems = [], eventCount = this.eventCount;
2461
+ let oldItems = this.items, lastItem = !preserveItems && oldItems.length ? oldItems.get(oldItems.length - 1) : null;
2462
+ for (let i = 0; i < transform.steps.length; i++) {
2463
+ let step = transform.steps[i].invert(transform.docs[i]);
2464
+ let item = new Item(transform.mapping.maps[i], step, selection), merged;
2465
+ if (merged = lastItem && lastItem.merge(item)) {
2466
+ item = merged;
2467
+ if (i)
2468
+ newItems.pop();
2469
+ else
2470
+ oldItems = oldItems.slice(0, oldItems.length - 1);
2471
+ }
2472
+ newItems.push(item);
2473
+ if (selection) {
2474
+ eventCount++;
2475
+ selection = void 0;
2476
+ }
2477
+ if (!preserveItems)
2478
+ lastItem = item;
2479
+ }
2480
+ let overflow = eventCount - histOptions.depth;
2481
+ if (overflow > DEPTH_OVERFLOW) {
2482
+ oldItems = cutOffEvents(oldItems, overflow);
2483
+ eventCount -= overflow;
2484
+ }
2485
+ return new Branch(oldItems.append(newItems), eventCount);
2486
+ }
2487
+ remapping(from2, to) {
2488
+ let maps = new Mapping();
2489
+ this.items.forEach((item, i) => {
2490
+ let mirrorPos = item.mirrorOffset != null && i - item.mirrorOffset >= from2 ? maps.maps.length - item.mirrorOffset : void 0;
2491
+ maps.appendMap(item.map, mirrorPos);
2492
+ }, from2, to);
2493
+ return maps;
2494
+ }
2495
+ addMaps(array) {
2496
+ if (this.eventCount == 0)
2497
+ return this;
2498
+ return new Branch(this.items.append(array.map((map2) => new Item(map2))), this.eventCount);
2499
+ }
2500
+ // When the collab module receives remote changes, the history has
2501
+ // to know about those, so that it can adjust the steps that were
2502
+ // rebased on top of the remote changes, and include the position
2503
+ // maps for the remote changes in its array of items.
2504
+ rebased(rebasedTransform, rebasedCount) {
2505
+ if (!this.eventCount)
2506
+ return this;
2507
+ let rebasedItems = [], start = Math.max(0, this.items.length - rebasedCount);
2508
+ let mapping = rebasedTransform.mapping;
2509
+ let newUntil = rebasedTransform.steps.length;
2510
+ let eventCount = this.eventCount;
2511
+ this.items.forEach((item) => {
2512
+ if (item.selection)
2513
+ eventCount--;
2514
+ }, start);
2515
+ let iRebased = rebasedCount;
2516
+ this.items.forEach((item) => {
2517
+ let pos = mapping.getMirror(--iRebased);
2518
+ if (pos == null)
2519
+ return;
2520
+ newUntil = Math.min(newUntil, pos);
2521
+ let map2 = mapping.maps[pos];
2522
+ if (item.step) {
2523
+ let step = rebasedTransform.steps[pos].invert(rebasedTransform.docs[pos]);
2524
+ let selection = item.selection && item.selection.map(mapping.slice(iRebased + 1, pos));
2525
+ if (selection)
2526
+ eventCount++;
2527
+ rebasedItems.push(new Item(map2, step, selection));
2528
+ } else {
2529
+ rebasedItems.push(new Item(map2));
2530
+ }
2531
+ }, start);
2532
+ let newMaps = [];
2533
+ for (let i = rebasedCount; i < newUntil; i++)
2534
+ newMaps.push(new Item(mapping.maps[i]));
2535
+ let items = this.items.slice(0, start).append(newMaps).append(rebasedItems);
2536
+ let branch = new Branch(items, eventCount);
2537
+ if (branch.emptyItemCount() > max_empty_items)
2538
+ branch = branch.compress(this.items.length - rebasedItems.length);
2539
+ return branch;
2540
+ }
2541
+ emptyItemCount() {
2542
+ let count = 0;
2543
+ this.items.forEach((item) => {
2544
+ if (!item.step)
2545
+ count++;
2546
+ });
2547
+ return count;
2548
+ }
2549
+ // Compressing a branch means rewriting it to push the air (map-only
2550
+ // items) out. During collaboration, these naturally accumulate
2551
+ // because each remote change adds one. The `upto` argument is used
2552
+ // to ensure that only the items below a given level are compressed,
2553
+ // because `rebased` relies on a clean, untouched set of items in
2554
+ // order to associate old items with rebased steps.
2555
+ compress(upto = this.items.length) {
2556
+ let remap = this.remapping(0, upto), mapFrom = remap.maps.length;
2557
+ let items = [], events = 0;
2558
+ this.items.forEach((item, i) => {
2559
+ if (i >= upto) {
2560
+ items.push(item);
2561
+ if (item.selection)
2562
+ events++;
2563
+ } else if (item.step) {
2564
+ let step = item.step.map(remap.slice(mapFrom)), map2 = step && step.getMap();
2565
+ mapFrom--;
2566
+ if (map2)
2567
+ remap.appendMap(map2, mapFrom);
2568
+ if (step) {
2569
+ let selection = item.selection && item.selection.map(remap.slice(mapFrom));
2570
+ if (selection)
2571
+ events++;
2572
+ let newItem = new Item(map2.invert(), step, selection), merged, last = items.length - 1;
2573
+ if (merged = items.length && items[last].merge(newItem))
2574
+ items[last] = merged;
2575
+ else
2576
+ items.push(newItem);
2577
+ }
2578
+ } else if (item.map) {
2579
+ mapFrom--;
2580
+ }
2581
+ }, this.items.length, 0);
2582
+ return new Branch(RopeSequence.from(items.reverse()), events);
2583
+ }
2584
+ }
2585
+ Branch.empty = new Branch(RopeSequence.empty, 0);
2586
+ function cutOffEvents(items, n) {
2587
+ let cutPoint;
2588
+ items.forEach((item, i) => {
2589
+ if (item.selection && n-- == 0) {
2590
+ cutPoint = i;
2591
+ return false;
2592
+ }
2593
+ });
2594
+ return items.slice(cutPoint);
2595
+ }
2596
+ class Item {
2597
+ constructor(map2, step, selection, mirrorOffset) {
2598
+ this.map = map2;
2599
+ this.step = step;
2600
+ this.selection = selection;
2601
+ this.mirrorOffset = mirrorOffset;
2602
+ }
2603
+ merge(other) {
2604
+ if (this.step && other.step && !other.selection) {
2605
+ let step = other.step.merge(this.step);
2606
+ if (step)
2607
+ return new Item(step.getMap().invert(), step, this.selection);
2608
+ }
2609
+ }
2610
+ }
2611
+ class HistoryState {
2612
+ constructor(done, undone, prevRanges, prevTime, prevComposition) {
2613
+ this.done = done;
2614
+ this.undone = undone;
2615
+ this.prevRanges = prevRanges;
2616
+ this.prevTime = prevTime;
2617
+ this.prevComposition = prevComposition;
2618
+ }
2619
+ }
2620
+ const DEPTH_OVERFLOW = 20;
2621
+ function applyTransaction(history2, state, tr2, options) {
2622
+ let historyTr = tr2.getMeta(historyKey), rebased;
2623
+ if (historyTr)
2624
+ return historyTr.historyState;
2625
+ if (tr2.getMeta(closeHistoryKey))
2626
+ history2 = new HistoryState(history2.done, history2.undone, null, 0, -1);
2627
+ let appended = tr2.getMeta("appendedTransaction");
2628
+ if (tr2.steps.length == 0) {
2629
+ return history2;
2630
+ } else if (appended && appended.getMeta(historyKey)) {
2631
+ if (appended.getMeta(historyKey).redo)
2632
+ return new HistoryState(history2.done.addTransform(tr2, void 0, options, mustPreserveItems(state)), history2.undone, rangesFor(tr2.mapping.maps), history2.prevTime, history2.prevComposition);
2633
+ else
2634
+ return new HistoryState(history2.done, history2.undone.addTransform(tr2, void 0, options, mustPreserveItems(state)), null, history2.prevTime, history2.prevComposition);
2635
+ } else if (tr2.getMeta("addToHistory") !== false && !(appended && appended.getMeta("addToHistory") === false)) {
2636
+ let composition = tr2.getMeta("composition");
2637
+ let newGroup = history2.prevTime == 0 || !appended && history2.prevComposition != composition && (history2.prevTime < (tr2.time || 0) - options.newGroupDelay || !isAdjacentTo(tr2, history2.prevRanges));
2638
+ let prevRanges = appended ? mapRanges(history2.prevRanges, tr2.mapping) : rangesFor(tr2.mapping.maps);
2639
+ return new HistoryState(history2.done.addTransform(tr2, newGroup ? state.selection.getBookmark() : void 0, options, mustPreserveItems(state)), Branch.empty, prevRanges, tr2.time, composition == null ? history2.prevComposition : composition);
2640
+ } else if (rebased = tr2.getMeta("rebased")) {
2641
+ return new HistoryState(history2.done.rebased(tr2, rebased), history2.undone.rebased(tr2, rebased), mapRanges(history2.prevRanges, tr2.mapping), history2.prevTime, history2.prevComposition);
2642
+ } else {
2643
+ return new HistoryState(history2.done.addMaps(tr2.mapping.maps), history2.undone.addMaps(tr2.mapping.maps), mapRanges(history2.prevRanges, tr2.mapping), history2.prevTime, history2.prevComposition);
2644
+ }
2645
+ }
2646
+ function isAdjacentTo(transform, prevRanges) {
2647
+ if (!prevRanges)
2648
+ return false;
2649
+ if (!transform.docChanged)
2650
+ return true;
2651
+ let adjacent = false;
2652
+ transform.mapping.maps[0].forEach((start, end) => {
2653
+ for (let i = 0; i < prevRanges.length; i += 2)
2654
+ if (start <= prevRanges[i + 1] && end >= prevRanges[i])
2655
+ adjacent = true;
2656
+ });
2657
+ return adjacent;
2658
+ }
2659
+ function rangesFor(maps) {
2660
+ let result = [];
2661
+ for (let i = maps.length - 1; i >= 0 && result.length == 0; i--)
2662
+ maps[i].forEach((_from, _to, from2, to) => result.push(from2, to));
2663
+ return result;
2664
+ }
2665
+ function mapRanges(ranges, mapping) {
2666
+ if (!ranges)
2667
+ return null;
2668
+ let result = [];
2669
+ for (let i = 0; i < ranges.length; i += 2) {
2670
+ let from2 = mapping.map(ranges[i], 1), to = mapping.map(ranges[i + 1], -1);
2671
+ if (from2 <= to)
2672
+ result.push(from2, to);
2673
+ }
2674
+ return result;
2675
+ }
2676
+ function histTransaction(history2, state, redo2) {
2677
+ let preserveItems = mustPreserveItems(state);
2678
+ let histOptions = historyKey.get(state).spec.config;
2679
+ let pop = (redo2 ? history2.undone : history2.done).popEvent(state, preserveItems);
2680
+ if (!pop)
2681
+ return null;
2682
+ let selection = pop.selection.resolve(pop.transform.doc);
2683
+ let added = (redo2 ? history2.done : history2.undone).addTransform(pop.transform, state.selection.getBookmark(), histOptions, preserveItems);
2684
+ let newHist = new HistoryState(redo2 ? added : pop.remaining, redo2 ? pop.remaining : added, null, 0, -1);
2685
+ return pop.transform.setSelection(selection).setMeta(historyKey, { redo: redo2, historyState: newHist });
2686
+ }
2687
+ let cachedPreserveItems = false, cachedPreserveItemsPlugins = null;
2688
+ function mustPreserveItems(state) {
2689
+ let plugins = state.plugins;
2690
+ if (cachedPreserveItemsPlugins != plugins) {
2691
+ cachedPreserveItems = false;
2692
+ cachedPreserveItemsPlugins = plugins;
2693
+ for (let i = 0; i < plugins.length; i++)
2694
+ if (plugins[i].spec.historyPreserveItems) {
2695
+ cachedPreserveItems = true;
2696
+ break;
2697
+ }
2698
+ }
2699
+ return cachedPreserveItems;
2700
+ }
2701
+ const historyKey = new PluginKey("history");
2702
+ const closeHistoryKey = new PluginKey("closeHistory");
2703
+ function history(config = {}) {
2704
+ config = {
2705
+ depth: config.depth || 100,
2706
+ newGroupDelay: config.newGroupDelay || 500
2707
+ };
2708
+ return new Plugin({
2709
+ key: historyKey,
2710
+ state: {
2711
+ init() {
2712
+ return new HistoryState(Branch.empty, Branch.empty, null, 0, -1);
2713
+ },
2714
+ apply(tr2, hist, state) {
2715
+ return applyTransaction(hist, state, tr2, config);
2716
+ }
2717
+ },
2718
+ config,
2719
+ props: {
2720
+ handleDOMEvents: {
2721
+ beforeinput(view, e) {
2722
+ let inputType = e.inputType;
2723
+ let command = inputType == "historyUndo" ? undo : inputType == "historyRedo" ? redo : null;
2724
+ if (!command)
2725
+ return false;
2726
+ e.preventDefault();
2727
+ return command(view.state, view.dispatch);
2728
+ }
2729
+ }
2730
+ }
2731
+ });
2732
+ }
2733
+ function buildCommand(redo2, scroll) {
2734
+ return (state, dispatch) => {
2735
+ let hist = historyKey.getState(state);
2736
+ if (!hist || (redo2 ? hist.undone : hist.done).eventCount == 0)
2737
+ return false;
2738
+ if (dispatch) {
2739
+ let tr2 = histTransaction(hist, state, redo2);
2740
+ if (tr2)
2741
+ dispatch(scroll ? tr2.scrollIntoView() : tr2);
2742
+ }
2743
+ return true;
2744
+ };
2745
+ }
2746
+ const undo = buildCommand(false, true);
2747
+ const redo = buildCommand(true, true);
2748
+ var CharacterCount = Extension.create({
2749
+ name: "characterCount",
2750
+ addOptions() {
2751
+ return {
2752
+ limit: null,
2753
+ mode: "textSize",
2754
+ textCounter: (text) => text.length,
2755
+ wordCounter: (text) => text.split(" ").filter((word) => word !== "").length
2756
+ };
2757
+ },
2758
+ addStorage() {
2759
+ return {
2760
+ characters: () => 0,
2761
+ words: () => 0
2762
+ };
2763
+ },
2764
+ onBeforeCreate() {
2765
+ this.storage.characters = (options) => {
2766
+ const node = (options == null ? void 0 : options.node) || this.editor.state.doc;
2767
+ const mode = (options == null ? void 0 : options.mode) || this.options.mode;
2768
+ if (mode === "textSize") {
2769
+ const text = node.textBetween(0, node.content.size, void 0, " ");
2770
+ return this.options.textCounter(text);
2771
+ }
2772
+ return node.nodeSize;
2773
+ };
2774
+ this.storage.words = (options) => {
2775
+ const node = (options == null ? void 0 : options.node) || this.editor.state.doc;
2776
+ const text = node.textBetween(0, node.content.size, " ", " ");
2777
+ return this.options.wordCounter(text);
2778
+ };
2779
+ },
2780
+ addProseMirrorPlugins() {
2781
+ let initialEvaluationDone = false;
2782
+ return [
2783
+ new Plugin({
2784
+ key: new PluginKey("characterCount"),
2785
+ appendTransaction: (transactions, oldState, newState) => {
2786
+ if (initialEvaluationDone) {
2787
+ return;
2788
+ }
2789
+ const limit = this.options.limit;
2790
+ if (limit === null || limit === void 0 || limit === 0) {
2791
+ initialEvaluationDone = true;
2792
+ return;
2793
+ }
2794
+ const initialContentSize = this.storage.characters({ node: newState.doc });
2795
+ if (initialContentSize > limit) {
2796
+ const over = initialContentSize - limit;
2797
+ const from2 = 0;
2798
+ const to = over;
2799
+ console.warn(
2800
+ `[CharacterCount] Initial content exceeded limit of ${limit} characters. Content was automatically trimmed.`
2801
+ );
2802
+ const tr2 = newState.tr.deleteRange(from2, to);
2803
+ initialEvaluationDone = true;
2804
+ return tr2;
2805
+ }
2806
+ initialEvaluationDone = true;
2807
+ },
2808
+ filterTransaction: (transaction, state) => {
2809
+ const limit = this.options.limit;
2810
+ if (!transaction.docChanged || limit === 0 || limit === null || limit === void 0) {
2811
+ return true;
2812
+ }
2813
+ const oldSize = this.storage.characters({ node: state.doc });
2814
+ const newSize = this.storage.characters({ node: transaction.doc });
2815
+ if (newSize <= limit) {
2816
+ return true;
2817
+ }
2818
+ if (oldSize > limit && newSize > limit && newSize <= oldSize) {
2819
+ return true;
2820
+ }
2821
+ if (oldSize > limit && newSize > limit && newSize > oldSize) {
2822
+ return false;
2823
+ }
2824
+ const isPaste = transaction.getMeta("paste");
2825
+ if (!isPaste) {
2826
+ return false;
2827
+ }
2828
+ const pos = transaction.selection.$head.pos;
2829
+ const over = newSize - limit;
2830
+ const from2 = pos - over;
2831
+ const to = pos;
2832
+ transaction.deleteRange(from2, to);
2833
+ const updatedSize = this.storage.characters({ node: transaction.doc });
2834
+ if (updatedSize > limit) {
2835
+ return false;
2836
+ }
2837
+ return true;
2838
+ }
2839
+ })
2840
+ ];
2841
+ }
2842
+ });
2843
+ var Dropcursor = Extension.create({
2844
+ name: "dropCursor",
2845
+ addOptions() {
2846
+ return {
2847
+ color: "currentColor",
2848
+ width: 1,
2849
+ class: void 0
2850
+ };
2851
+ },
2852
+ addProseMirrorPlugins() {
2853
+ return [dropCursor(this.options)];
2854
+ }
2855
+ });
2856
+ Extension.create({
2857
+ name: "focus",
2858
+ addOptions() {
2859
+ return {
2860
+ className: "has-focus",
2861
+ mode: "all"
2862
+ };
2863
+ },
2864
+ addProseMirrorPlugins() {
2865
+ return [
2866
+ new Plugin({
2867
+ key: new PluginKey("focus"),
2868
+ props: {
2869
+ decorations: ({ doc, selection }) => {
2870
+ const { isEditable, isFocused } = this.editor;
2871
+ const { anchor } = selection;
2872
+ const decorations = [];
2873
+ if (!isEditable || !isFocused) {
2874
+ return DecorationSet.create(doc, []);
2875
+ }
2876
+ let maxLevels = 0;
2877
+ if (this.options.mode === "deepest") {
2878
+ doc.descendants((node, pos) => {
2879
+ if (node.isText) {
2880
+ return;
2881
+ }
2882
+ const isCurrent = anchor >= pos && anchor <= pos + node.nodeSize - 1;
2883
+ if (!isCurrent) {
2884
+ return false;
2885
+ }
2886
+ maxLevels += 1;
2887
+ });
2888
+ }
2889
+ let currentLevel = 0;
2890
+ doc.descendants((node, pos) => {
2891
+ if (node.isText) {
2892
+ return false;
2893
+ }
2894
+ const isCurrent = anchor >= pos && anchor <= pos + node.nodeSize - 1;
2895
+ if (!isCurrent) {
2896
+ return false;
2897
+ }
2898
+ currentLevel += 1;
2899
+ const outOfScope = this.options.mode === "deepest" && maxLevels - currentLevel > 0 || this.options.mode === "shallowest" && currentLevel > 1;
2900
+ if (outOfScope) {
2901
+ return this.options.mode === "deepest";
2902
+ }
2903
+ decorations.push(
2904
+ Decoration.node(pos, pos + node.nodeSize, {
2905
+ class: this.options.className
2906
+ })
2907
+ );
2908
+ });
2909
+ return DecorationSet.create(doc, decorations);
2910
+ }
2911
+ }
2912
+ })
2913
+ ];
2914
+ }
2915
+ });
2916
+ var Gapcursor = Extension.create({
2917
+ name: "gapCursor",
2918
+ addProseMirrorPlugins() {
2919
+ return [gapCursor()];
2920
+ },
2921
+ extendNodeSchema(extension) {
2922
+ var _a;
2923
+ const context = {
2924
+ name: extension.name,
2925
+ options: extension.options,
2926
+ storage: extension.storage
2927
+ };
2928
+ return {
2929
+ allowGapCursor: (_a = callOrReturn(getExtensionField(extension, "allowGapCursor", context))) != null ? _a : null
2930
+ };
2931
+ }
2932
+ });
2933
+ var Placeholder = Extension.create({
2934
+ name: "placeholder",
2935
+ addOptions() {
2936
+ return {
2937
+ emptyEditorClass: "is-editor-empty",
2938
+ emptyNodeClass: "is-empty",
2939
+ placeholder: "Write something …",
2940
+ showOnlyWhenEditable: true,
2941
+ showOnlyCurrent: true,
2942
+ includeChildren: false
2943
+ };
2944
+ },
2945
+ addProseMirrorPlugins() {
2946
+ return [
2947
+ new Plugin({
2948
+ key: new PluginKey("placeholder"),
2949
+ props: {
2950
+ decorations: ({ doc, selection }) => {
2951
+ const active = this.editor.isEditable || !this.options.showOnlyWhenEditable;
2952
+ const { anchor } = selection;
2953
+ const decorations = [];
2954
+ if (!active) {
2955
+ return null;
2956
+ }
2957
+ const isEmptyDoc = this.editor.isEmpty;
2958
+ doc.descendants((node, pos) => {
2959
+ const hasAnchor = anchor >= pos && anchor <= pos + node.nodeSize;
2960
+ const isEmpty = !node.isLeaf && isNodeEmpty(node);
2961
+ if ((hasAnchor || !this.options.showOnlyCurrent) && isEmpty) {
2962
+ const classes = [this.options.emptyNodeClass];
2963
+ if (isEmptyDoc) {
2964
+ classes.push(this.options.emptyEditorClass);
2965
+ }
2966
+ const decoration = Decoration.node(pos, pos + node.nodeSize, {
2967
+ class: classes.join(" "),
2968
+ "data-placeholder": typeof this.options.placeholder === "function" ? this.options.placeholder({
2969
+ editor: this.editor,
2970
+ node,
2971
+ pos,
2972
+ hasAnchor
2973
+ }) : this.options.placeholder
2974
+ });
2975
+ decorations.push(decoration);
2976
+ }
2977
+ return this.options.includeChildren;
2978
+ });
2979
+ return DecorationSet.create(doc, decorations);
2980
+ }
2981
+ }
2982
+ })
2983
+ ];
2984
+ }
2985
+ });
2986
+ Extension.create({
2987
+ name: "selection",
2988
+ addOptions() {
2989
+ return {
2990
+ className: "selection"
2991
+ };
2992
+ },
2993
+ addProseMirrorPlugins() {
2994
+ const { editor, options } = this;
2995
+ return [
2996
+ new Plugin({
2997
+ key: new PluginKey("selection"),
2998
+ props: {
2999
+ decorations(state) {
3000
+ if (state.selection.empty || editor.isFocused || !editor.isEditable || isNodeSelection(state.selection) || editor.view.dragging) {
3001
+ return null;
3002
+ }
3003
+ return DecorationSet.create(state.doc, [
3004
+ Decoration.inline(state.selection.from, state.selection.to, {
3005
+ class: options.className
3006
+ })
3007
+ ]);
3008
+ }
3009
+ }
3010
+ })
3011
+ ];
3012
+ }
3013
+ });
3014
+ function nodeEqualsType({ types, node }) {
3015
+ return node && Array.isArray(types) && types.includes(node.type) || (node == null ? void 0 : node.type) === types;
3016
+ }
3017
+ var TrailingNode = Extension.create({
3018
+ name: "trailingNode",
3019
+ addOptions() {
3020
+ return {
3021
+ node: "paragraph",
3022
+ notAfter: []
3023
+ };
3024
+ },
3025
+ addProseMirrorPlugins() {
3026
+ const plugin = new PluginKey(this.name);
3027
+ const disabledNodes = Object.entries(this.editor.schema.nodes).map(([, value]) => value).filter((node) => (this.options.notAfter || []).concat(this.options.node).includes(node.name));
3028
+ return [
3029
+ new Plugin({
3030
+ key: plugin,
3031
+ appendTransaction: (_, __, state) => {
3032
+ const { doc, tr: tr2, schema } = state;
3033
+ const shouldInsertNodeAtEnd = plugin.getState(state);
3034
+ const endPosition = doc.content.size;
3035
+ const type = schema.nodes[this.options.node];
3036
+ if (!shouldInsertNodeAtEnd) {
3037
+ return;
3038
+ }
3039
+ return tr2.insert(endPosition, type.create());
3040
+ },
3041
+ state: {
3042
+ init: (_, state) => {
3043
+ const lastNode = state.tr.doc.lastChild;
3044
+ return !nodeEqualsType({ node: lastNode, types: disabledNodes });
3045
+ },
3046
+ apply: (tr2, value) => {
3047
+ if (!tr2.docChanged) {
3048
+ return value;
3049
+ }
3050
+ const lastNode = tr2.doc.lastChild;
3051
+ return !nodeEqualsType({ node: lastNode, types: disabledNodes });
3052
+ }
3053
+ }
3054
+ })
3055
+ ];
3056
+ }
3057
+ });
3058
+ var UndoRedo = Extension.create({
3059
+ name: "undoRedo",
3060
+ addOptions() {
3061
+ return {
3062
+ depth: 100,
3063
+ newGroupDelay: 500
3064
+ };
3065
+ },
3066
+ addCommands() {
3067
+ return {
3068
+ undo: () => ({ state, dispatch }) => {
3069
+ return undo(state, dispatch);
3070
+ },
3071
+ redo: () => ({ state, dispatch }) => {
3072
+ return redo(state, dispatch);
3073
+ }
3074
+ };
3075
+ },
3076
+ addProseMirrorPlugins() {
3077
+ return [history(this.options)];
3078
+ },
3079
+ addKeyboardShortcuts() {
3080
+ return {
3081
+ "Mod-z": () => this.editor.commands.undo(),
3082
+ "Shift-Mod-z": () => this.editor.commands.redo(),
3083
+ "Mod-y": () => this.editor.commands.redo(),
3084
+ // Russian keyboard layouts
3085
+ "Mod-я": () => this.editor.commands.undo(),
3086
+ "Shift-Mod-я": () => this.editor.commands.redo()
3087
+ };
3088
+ }
3089
+ });
3090
+ var h = (tag, attributes) => {
3091
+ if (tag === "slot") {
3092
+ return 0;
3093
+ }
3094
+ if (tag instanceof Function) {
3095
+ return tag(attributes);
3096
+ }
3097
+ const { children, ...rest } = attributes != null ? attributes : {};
3098
+ if (tag === "svg") {
3099
+ throw new Error("SVG elements are not supported in the JSX syntax, use the array syntax instead");
3100
+ }
3101
+ return [tag, rest, children];
3102
+ };
3103
+ var inputRegex$3 = /^\s*>\s$/;
3104
+ var Blockquote = Node3.create({
3105
+ name: "blockquote",
3106
+ addOptions() {
3107
+ return {
3108
+ HTMLAttributes: {}
3109
+ };
3110
+ },
3111
+ content: "block+",
3112
+ group: "block",
3113
+ defining: true,
3114
+ parseHTML() {
3115
+ return [{ tag: "blockquote" }];
3116
+ },
3117
+ renderHTML({ HTMLAttributes }) {
3118
+ return /* @__PURE__ */ h("blockquote", { ...mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), children: /* @__PURE__ */ h("slot", {}) });
3119
+ },
3120
+ addCommands() {
3121
+ return {
3122
+ setBlockquote: () => ({ commands }) => {
3123
+ return commands.wrapIn(this.name);
3124
+ },
3125
+ toggleBlockquote: () => ({ commands }) => {
3126
+ return commands.toggleWrap(this.name);
3127
+ },
3128
+ unsetBlockquote: () => ({ commands }) => {
3129
+ return commands.lift(this.name);
3130
+ }
3131
+ };
3132
+ },
3133
+ addKeyboardShortcuts() {
3134
+ return {
3135
+ "Mod-Shift-b": () => this.editor.commands.toggleBlockquote()
3136
+ };
3137
+ },
3138
+ addInputRules() {
3139
+ return [
3140
+ wrappingInputRule({
3141
+ find: inputRegex$3,
3142
+ type: this.type
3143
+ })
3144
+ ];
3145
+ }
3146
+ });
3147
+ var starInputRegex$1 = /(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/;
3148
+ var starPasteRegex$1 = /(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g;
3149
+ var underscoreInputRegex$1 = /(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/;
3150
+ var underscorePasteRegex$1 = /(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g;
3151
+ var Bold = Mark.create({
3152
+ name: "bold",
3153
+ addOptions() {
3154
+ return {
3155
+ HTMLAttributes: {}
3156
+ };
3157
+ },
3158
+ parseHTML() {
3159
+ return [
3160
+ {
3161
+ tag: "strong"
3162
+ },
3163
+ {
3164
+ tag: "b",
3165
+ getAttrs: (node) => node.style.fontWeight !== "normal" && null
3166
+ },
3167
+ {
3168
+ style: "font-weight=400",
3169
+ clearMark: (mark) => mark.type.name === this.name
3170
+ },
3171
+ {
3172
+ style: "font-weight",
3173
+ getAttrs: (value) => /^(bold(er)?|[5-9]\d{2,})$/.test(value) && null
3174
+ }
3175
+ ];
3176
+ },
3177
+ renderHTML({ HTMLAttributes }) {
3178
+ return /* @__PURE__ */ h("strong", { ...mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), children: /* @__PURE__ */ h("slot", {}) });
3179
+ },
3180
+ addCommands() {
3181
+ return {
3182
+ setBold: () => ({ commands }) => {
3183
+ return commands.setMark(this.name);
3184
+ },
3185
+ toggleBold: () => ({ commands }) => {
3186
+ return commands.toggleMark(this.name);
3187
+ },
3188
+ unsetBold: () => ({ commands }) => {
3189
+ return commands.unsetMark(this.name);
3190
+ }
3191
+ };
3192
+ },
3193
+ addKeyboardShortcuts() {
3194
+ return {
3195
+ "Mod-b": () => this.editor.commands.toggleBold(),
3196
+ "Mod-B": () => this.editor.commands.toggleBold()
3197
+ };
3198
+ },
3199
+ addInputRules() {
3200
+ return [
3201
+ markInputRule({
3202
+ find: starInputRegex$1,
3203
+ type: this.type
3204
+ }),
3205
+ markInputRule({
3206
+ find: underscoreInputRegex$1,
3207
+ type: this.type
3208
+ })
3209
+ ];
3210
+ },
3211
+ addPasteRules() {
3212
+ return [
3213
+ markPasteRule({
3214
+ find: starPasteRegex$1,
3215
+ type: this.type
3216
+ }),
3217
+ markPasteRule({
3218
+ find: underscorePasteRegex$1,
3219
+ type: this.type
3220
+ })
3221
+ ];
3222
+ }
3223
+ });
3224
+ var inputRegex$2 = /(^|[^`])`([^`]+)`(?!`)/;
3225
+ var pasteRegex$1 = /(^|[^`])`([^`]+)`(?!`)/g;
3226
+ var Code = Mark.create({
3227
+ name: "code",
3228
+ addOptions() {
3229
+ return {
3230
+ HTMLAttributes: {}
3231
+ };
3232
+ },
3233
+ excludes: "_",
3234
+ code: true,
3235
+ exitable: true,
3236
+ parseHTML() {
3237
+ return [{ tag: "code" }];
3238
+ },
3239
+ renderHTML({ HTMLAttributes }) {
3240
+ return ["code", mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
3241
+ },
3242
+ addCommands() {
3243
+ return {
3244
+ setCode: () => ({ commands }) => {
3245
+ return commands.setMark(this.name);
3246
+ },
3247
+ toggleCode: () => ({ commands }) => {
3248
+ return commands.toggleMark(this.name);
3249
+ },
3250
+ unsetCode: () => ({ commands }) => {
3251
+ return commands.unsetMark(this.name);
3252
+ }
3253
+ };
3254
+ },
3255
+ addKeyboardShortcuts() {
3256
+ return {
3257
+ "Mod-e": () => this.editor.commands.toggleCode()
3258
+ };
3259
+ },
3260
+ addInputRules() {
3261
+ return [
3262
+ markInputRule({
3263
+ find: inputRegex$2,
3264
+ type: this.type
3265
+ })
3266
+ ];
3267
+ },
3268
+ addPasteRules() {
3269
+ return [
3270
+ markPasteRule({
3271
+ find: pasteRegex$1,
3272
+ type: this.type
3273
+ })
3274
+ ];
3275
+ }
3276
+ });
3277
+ var backtickInputRegex = /^```([a-z]+)?[\s\n]$/;
3278
+ var tildeInputRegex = /^~~~([a-z]+)?[\s\n]$/;
3279
+ var CodeBlock = Node3.create({
3280
+ name: "codeBlock",
3281
+ addOptions() {
3282
+ return {
3283
+ languageClassPrefix: "language-",
3284
+ exitOnTripleEnter: true,
3285
+ exitOnArrowDown: true,
3286
+ defaultLanguage: null,
3287
+ HTMLAttributes: {}
3288
+ };
3289
+ },
3290
+ content: "text*",
3291
+ marks: "",
3292
+ group: "block",
3293
+ code: true,
3294
+ defining: true,
3295
+ addAttributes() {
3296
+ return {
3297
+ language: {
3298
+ default: this.options.defaultLanguage,
3299
+ parseHTML: (element) => {
3300
+ var _a;
3301
+ const { languageClassPrefix } = this.options;
3302
+ const classNames = [...((_a = element.firstElementChild) == null ? void 0 : _a.classList) || []];
3303
+ const languages = classNames.filter((className) => className.startsWith(languageClassPrefix)).map((className) => className.replace(languageClassPrefix, ""));
3304
+ const language = languages[0];
3305
+ if (!language) {
3306
+ return null;
3307
+ }
3308
+ return language;
3309
+ },
3310
+ rendered: false
3311
+ }
3312
+ };
3313
+ },
3314
+ parseHTML() {
3315
+ return [
3316
+ {
3317
+ tag: "pre",
3318
+ preserveWhitespace: "full"
3319
+ }
3320
+ ];
3321
+ },
3322
+ renderHTML({ node, HTMLAttributes }) {
3323
+ return [
3324
+ "pre",
3325
+ mergeAttributes(this.options.HTMLAttributes, HTMLAttributes),
3326
+ [
3327
+ "code",
3328
+ {
3329
+ class: node.attrs.language ? this.options.languageClassPrefix + node.attrs.language : null
3330
+ },
3331
+ 0
3332
+ ]
3333
+ ];
3334
+ },
3335
+ addCommands() {
3336
+ return {
3337
+ setCodeBlock: (attributes) => ({ commands }) => {
3338
+ return commands.setNode(this.name, attributes);
3339
+ },
3340
+ toggleCodeBlock: (attributes) => ({ commands }) => {
3341
+ return commands.toggleNode(this.name, "paragraph", attributes);
3342
+ }
3343
+ };
3344
+ },
3345
+ addKeyboardShortcuts() {
3346
+ return {
3347
+ "Mod-Alt-c": () => this.editor.commands.toggleCodeBlock(),
3348
+ // remove code block when at start of document or code block is empty
3349
+ Backspace: () => {
3350
+ const { empty, $anchor } = this.editor.state.selection;
3351
+ const isAtStart = $anchor.pos === 1;
3352
+ if (!empty || $anchor.parent.type.name !== this.name) {
3353
+ return false;
3354
+ }
3355
+ if (isAtStart || !$anchor.parent.textContent.length) {
3356
+ return this.editor.commands.clearNodes();
3357
+ }
3358
+ return false;
3359
+ },
3360
+ // exit node on triple enter
3361
+ Enter: ({ editor }) => {
3362
+ if (!this.options.exitOnTripleEnter) {
3363
+ return false;
3364
+ }
3365
+ const { state } = editor;
3366
+ const { selection } = state;
3367
+ const { $from, empty } = selection;
3368
+ if (!empty || $from.parent.type !== this.type) {
3369
+ return false;
3370
+ }
3371
+ const isAtEnd = $from.parentOffset === $from.parent.nodeSize - 2;
3372
+ const endsWithDoubleNewline = $from.parent.textContent.endsWith("\n\n");
3373
+ if (!isAtEnd || !endsWithDoubleNewline) {
3374
+ return false;
3375
+ }
3376
+ return editor.chain().command(({ tr: tr2 }) => {
3377
+ tr2.delete($from.pos - 2, $from.pos);
3378
+ return true;
3379
+ }).exitCode().run();
3380
+ },
3381
+ // exit node on arrow down
3382
+ ArrowDown: ({ editor }) => {
3383
+ if (!this.options.exitOnArrowDown) {
3384
+ return false;
3385
+ }
3386
+ const { state } = editor;
3387
+ const { selection, doc } = state;
3388
+ const { $from, empty } = selection;
3389
+ if (!empty || $from.parent.type !== this.type) {
3390
+ return false;
3391
+ }
3392
+ const isAtEnd = $from.parentOffset === $from.parent.nodeSize - 2;
3393
+ if (!isAtEnd) {
3394
+ return false;
3395
+ }
3396
+ const after = $from.after();
3397
+ if (after === void 0) {
3398
+ return false;
3399
+ }
3400
+ const nodeAfter = doc.nodeAt(after);
3401
+ if (nodeAfter) {
3402
+ return editor.commands.command(({ tr: tr2 }) => {
3403
+ tr2.setSelection(Selection.near(doc.resolve(after)));
3404
+ return true;
3405
+ });
3406
+ }
3407
+ return editor.commands.exitCode();
3408
+ }
3409
+ };
3410
+ },
3411
+ addInputRules() {
3412
+ return [
3413
+ textblockTypeInputRule({
3414
+ find: backtickInputRegex,
3415
+ type: this.type,
3416
+ getAttributes: (match) => ({
3417
+ language: match[1]
3418
+ })
3419
+ }),
3420
+ textblockTypeInputRule({
3421
+ find: tildeInputRegex,
3422
+ type: this.type,
3423
+ getAttributes: (match) => ({
3424
+ language: match[1]
3425
+ })
3426
+ })
3427
+ ];
3428
+ },
3429
+ addProseMirrorPlugins() {
3430
+ return [
3431
+ // this plugin creates a code block for pasted content from VS Code
3432
+ // we can also detect the copied code language
3433
+ new Plugin({
3434
+ key: new PluginKey("codeBlockVSCodeHandler"),
3435
+ props: {
3436
+ handlePaste: (view, event) => {
3437
+ if (!event.clipboardData) {
3438
+ return false;
3439
+ }
3440
+ if (this.editor.isActive(this.type.name)) {
3441
+ return false;
3442
+ }
3443
+ const text = event.clipboardData.getData("text/plain");
3444
+ const vscode = event.clipboardData.getData("vscode-editor-data");
3445
+ const vscodeData = vscode ? JSON.parse(vscode) : void 0;
3446
+ const language = vscodeData == null ? void 0 : vscodeData.mode;
3447
+ if (!text || !language) {
3448
+ return false;
3449
+ }
3450
+ const { tr: tr2, schema } = view.state;
3451
+ const textNode = schema.text(text.replace(/\r\n?/g, "\n"));
3452
+ tr2.replaceSelectionWith(this.type.create({ language }, textNode));
3453
+ if (tr2.selection.$from.parent.type !== this.type) {
3454
+ tr2.setSelection(TextSelection.near(tr2.doc.resolve(Math.max(0, tr2.selection.from - 2))));
3455
+ }
3456
+ tr2.setMeta("paste", true);
3457
+ view.dispatch(tr2);
3458
+ return true;
3459
+ }
3460
+ }
3461
+ })
3462
+ ];
3463
+ }
3464
+ });
3465
+ var Document = Node3.create({
3466
+ name: "doc",
3467
+ topNode: true,
3468
+ content: "block+"
3469
+ });
3470
+ var HardBreak = Node3.create({
3471
+ name: "hardBreak",
3472
+ addOptions() {
3473
+ return {
3474
+ keepMarks: true,
3475
+ HTMLAttributes: {}
3476
+ };
3477
+ },
3478
+ inline: true,
3479
+ group: "inline",
3480
+ selectable: false,
3481
+ linebreakReplacement: true,
3482
+ parseHTML() {
3483
+ return [{ tag: "br" }];
3484
+ },
3485
+ renderHTML({ HTMLAttributes }) {
3486
+ return ["br", mergeAttributes(this.options.HTMLAttributes, HTMLAttributes)];
3487
+ },
3488
+ renderText() {
3489
+ return "\n";
3490
+ },
3491
+ addCommands() {
3492
+ return {
3493
+ setHardBreak: () => ({ commands, chain, state, editor }) => {
3494
+ return commands.first([
3495
+ () => commands.exitCode(),
3496
+ () => commands.command(() => {
3497
+ const { selection, storedMarks } = state;
3498
+ if (selection.$from.parent.type.spec.isolating) {
3499
+ return false;
3500
+ }
3501
+ const { keepMarks } = this.options;
3502
+ const { splittableMarks } = editor.extensionManager;
3503
+ const marks = storedMarks || selection.$to.parentOffset && selection.$from.marks();
3504
+ return chain().insertContent({ type: this.name }).command(({ tr: tr2, dispatch }) => {
3505
+ if (dispatch && marks && keepMarks) {
3506
+ const filteredMarks = marks.filter((mark) => splittableMarks.includes(mark.type.name));
3507
+ tr2.ensureMarks(filteredMarks);
3508
+ }
3509
+ return true;
3510
+ }).run();
3511
+ })
3512
+ ]);
3513
+ }
3514
+ };
3515
+ },
3516
+ addKeyboardShortcuts() {
3517
+ return {
3518
+ "Mod-Enter": () => this.editor.commands.setHardBreak(),
3519
+ "Shift-Enter": () => this.editor.commands.setHardBreak()
3520
+ };
3521
+ }
3522
+ });
3523
+ var Heading = Node3.create({
3524
+ name: "heading",
3525
+ addOptions() {
3526
+ return {
3527
+ levels: [1, 2, 3, 4, 5, 6],
3528
+ HTMLAttributes: {}
3529
+ };
3530
+ },
3531
+ content: "inline*",
3532
+ group: "block",
3533
+ defining: true,
3534
+ addAttributes() {
3535
+ return {
3536
+ level: {
3537
+ default: 1,
3538
+ rendered: false
3539
+ }
3540
+ };
3541
+ },
3542
+ parseHTML() {
3543
+ return this.options.levels.map((level) => ({
3544
+ tag: `h${level}`,
3545
+ attrs: { level }
3546
+ }));
3547
+ },
3548
+ renderHTML({ node, HTMLAttributes }) {
3549
+ const hasLevel = this.options.levels.includes(node.attrs.level);
3550
+ const level = hasLevel ? node.attrs.level : this.options.levels[0];
3551
+ return [`h${level}`, mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
3552
+ },
3553
+ addCommands() {
3554
+ return {
3555
+ setHeading: (attributes) => ({ commands }) => {
3556
+ if (!this.options.levels.includes(attributes.level)) {
3557
+ return false;
3558
+ }
3559
+ return commands.setNode(this.name, attributes);
3560
+ },
3561
+ toggleHeading: (attributes) => ({ commands }) => {
3562
+ if (!this.options.levels.includes(attributes.level)) {
3563
+ return false;
3564
+ }
3565
+ return commands.toggleNode(this.name, "paragraph", attributes);
3566
+ }
3567
+ };
3568
+ },
3569
+ addKeyboardShortcuts() {
3570
+ return this.options.levels.reduce(
3571
+ (items, level) => ({
3572
+ ...items,
3573
+ ...{
3574
+ [`Mod-Alt-${level}`]: () => this.editor.commands.toggleHeading({ level })
3575
+ }
3576
+ }),
3577
+ {}
3578
+ );
3579
+ },
3580
+ addInputRules() {
3581
+ return this.options.levels.map((level) => {
3582
+ return textblockTypeInputRule({
3583
+ find: new RegExp(`^(#{${Math.min(...this.options.levels)},${level}})\\s$`),
3584
+ type: this.type,
3585
+ getAttributes: {
3586
+ level
3587
+ }
3588
+ });
3589
+ });
3590
+ }
3591
+ });
3592
+ var HorizontalRule = Node3.create({
3593
+ name: "horizontalRule",
3594
+ addOptions() {
3595
+ return {
3596
+ HTMLAttributes: {}
3597
+ };
3598
+ },
3599
+ group: "block",
3600
+ parseHTML() {
3601
+ return [{ tag: "hr" }];
3602
+ },
3603
+ renderHTML({ HTMLAttributes }) {
3604
+ return ["hr", mergeAttributes(this.options.HTMLAttributes, HTMLAttributes)];
3605
+ },
3606
+ addCommands() {
3607
+ return {
3608
+ setHorizontalRule: () => ({ chain, state }) => {
3609
+ if (!canInsertNode(state, state.schema.nodes[this.name])) {
3610
+ return false;
3611
+ }
3612
+ const { selection } = state;
3613
+ const { $to: $originTo } = selection;
3614
+ const currentChain = chain();
3615
+ if (isNodeSelection(selection)) {
3616
+ currentChain.insertContentAt($originTo.pos, {
3617
+ type: this.name
3618
+ });
3619
+ } else {
3620
+ currentChain.insertContent({ type: this.name });
3621
+ }
3622
+ return currentChain.command(({ tr: tr2, dispatch }) => {
3623
+ var _a;
3624
+ if (dispatch) {
3625
+ const { $to } = tr2.selection;
3626
+ const posAfter = $to.end();
3627
+ if ($to.nodeAfter) {
3628
+ if ($to.nodeAfter.isTextblock) {
3629
+ tr2.setSelection(TextSelection.create(tr2.doc, $to.pos + 1));
3630
+ } else if ($to.nodeAfter.isBlock) {
3631
+ tr2.setSelection(NodeSelection.create(tr2.doc, $to.pos));
3632
+ } else {
3633
+ tr2.setSelection(TextSelection.create(tr2.doc, $to.pos));
3634
+ }
3635
+ } else {
3636
+ const node = (_a = $to.parent.type.contentMatch.defaultType) == null ? void 0 : _a.create();
3637
+ if (node) {
3638
+ tr2.insert(posAfter, node);
3639
+ tr2.setSelection(TextSelection.create(tr2.doc, posAfter + 1));
3640
+ }
3641
+ }
3642
+ tr2.scrollIntoView();
3643
+ }
3644
+ return true;
3645
+ }).run();
3646
+ }
3647
+ };
3648
+ },
3649
+ addInputRules() {
3650
+ return [
3651
+ nodeInputRule({
3652
+ find: /^(?:---|—-|___\s|\*\*\*\s)$/,
3653
+ type: this.type
3654
+ })
3655
+ ];
3656
+ }
3657
+ });
3658
+ var starInputRegex = /(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/;
3659
+ var starPasteRegex = /(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g;
3660
+ var underscoreInputRegex = /(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/;
3661
+ var underscorePasteRegex = /(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g;
3662
+ var Italic = Mark.create({
3663
+ name: "italic",
3664
+ addOptions() {
3665
+ return {
3666
+ HTMLAttributes: {}
3667
+ };
3668
+ },
3669
+ parseHTML() {
3670
+ return [
3671
+ {
3672
+ tag: "em"
3673
+ },
3674
+ {
3675
+ tag: "i",
3676
+ getAttrs: (node) => node.style.fontStyle !== "normal" && null
3677
+ },
3678
+ {
3679
+ style: "font-style=normal",
3680
+ clearMark: (mark) => mark.type.name === this.name
3681
+ },
3682
+ {
3683
+ style: "font-style=italic"
3684
+ }
3685
+ ];
3686
+ },
3687
+ renderHTML({ HTMLAttributes }) {
3688
+ return ["em", mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
3689
+ },
3690
+ addCommands() {
3691
+ return {
3692
+ setItalic: () => ({ commands }) => {
3693
+ return commands.setMark(this.name);
3694
+ },
3695
+ toggleItalic: () => ({ commands }) => {
3696
+ return commands.toggleMark(this.name);
3697
+ },
3698
+ unsetItalic: () => ({ commands }) => {
3699
+ return commands.unsetMark(this.name);
3700
+ }
3701
+ };
3702
+ },
3703
+ addKeyboardShortcuts() {
3704
+ return {
3705
+ "Mod-i": () => this.editor.commands.toggleItalic(),
3706
+ "Mod-I": () => this.editor.commands.toggleItalic()
3707
+ };
3708
+ },
3709
+ addInputRules() {
3710
+ return [
3711
+ markInputRule({
3712
+ find: starInputRegex,
3713
+ type: this.type
3714
+ }),
3715
+ markInputRule({
3716
+ find: underscoreInputRegex,
3717
+ type: this.type
3718
+ })
3719
+ ];
3720
+ },
3721
+ addPasteRules() {
3722
+ return [
3723
+ markPasteRule({
3724
+ find: starPasteRegex,
3725
+ type: this.type
3726
+ }),
3727
+ markPasteRule({
3728
+ find: underscorePasteRegex,
3729
+ type: this.type
3730
+ })
3731
+ ];
3732
+ }
3733
+ });
3734
+ var __defProp = Object.defineProperty;
3735
+ var __export = (target, all) => {
3736
+ for (var name in all)
3737
+ __defProp(target, name, { get: all[name], enumerable: true });
3738
+ };
3739
+ var ListItemName = "listItem";
3740
+ var TextStyleName = "textStyle";
3741
+ var bulletListInputRegex = /^\s*([-+*])\s$/;
3742
+ var BulletList = Node3.create({
3743
+ name: "bulletList",
3744
+ addOptions() {
3745
+ return {
3746
+ itemTypeName: "listItem",
3747
+ HTMLAttributes: {},
3748
+ keepMarks: false,
3749
+ keepAttributes: false
3750
+ };
3751
+ },
3752
+ group: "block list",
3753
+ content() {
3754
+ return `${this.options.itemTypeName}+`;
3755
+ },
3756
+ parseHTML() {
3757
+ return [{ tag: "ul" }];
3758
+ },
3759
+ renderHTML({ HTMLAttributes }) {
3760
+ return ["ul", mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
3761
+ },
3762
+ addCommands() {
3763
+ return {
3764
+ toggleBulletList: () => ({ commands, chain }) => {
3765
+ if (this.options.keepAttributes) {
3766
+ return chain().toggleList(this.name, this.options.itemTypeName, this.options.keepMarks).updateAttributes(ListItemName, this.editor.getAttributes(TextStyleName)).run();
3767
+ }
3768
+ return commands.toggleList(this.name, this.options.itemTypeName, this.options.keepMarks);
3769
+ }
3770
+ };
3771
+ },
3772
+ addKeyboardShortcuts() {
3773
+ return {
3774
+ "Mod-Shift-8": () => this.editor.commands.toggleBulletList()
3775
+ };
3776
+ },
3777
+ addInputRules() {
3778
+ let inputRule = wrappingInputRule({
3779
+ find: bulletListInputRegex,
3780
+ type: this.type
3781
+ });
3782
+ if (this.options.keepMarks || this.options.keepAttributes) {
3783
+ inputRule = wrappingInputRule({
3784
+ find: bulletListInputRegex,
3785
+ type: this.type,
3786
+ keepMarks: this.options.keepMarks,
3787
+ keepAttributes: this.options.keepAttributes,
3788
+ getAttributes: () => {
3789
+ return this.editor.getAttributes(TextStyleName);
3790
+ },
3791
+ editor: this.editor
3792
+ });
3793
+ }
3794
+ return [inputRule];
3795
+ }
3796
+ });
3797
+ var ListItem = Node3.create({
3798
+ name: "listItem",
3799
+ addOptions() {
3800
+ return {
3801
+ HTMLAttributes: {},
3802
+ bulletListTypeName: "bulletList",
3803
+ orderedListTypeName: "orderedList"
3804
+ };
3805
+ },
3806
+ content: "paragraph block*",
3807
+ defining: true,
3808
+ parseHTML() {
3809
+ return [
3810
+ {
3811
+ tag: "li"
3812
+ }
3813
+ ];
3814
+ },
3815
+ renderHTML({ HTMLAttributes }) {
3816
+ return ["li", mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
3817
+ },
3818
+ addKeyboardShortcuts() {
3819
+ return {
3820
+ Enter: () => this.editor.commands.splitListItem(this.name),
3821
+ Tab: () => this.editor.commands.sinkListItem(this.name),
3822
+ "Shift-Tab": () => this.editor.commands.liftListItem(this.name)
3823
+ };
3824
+ }
3825
+ });
3826
+ var listHelpers_exports = {};
3827
+ __export(listHelpers_exports, {
3828
+ findListItemPos: () => findListItemPos,
3829
+ getNextListDepth: () => getNextListDepth,
3830
+ handleBackspace: () => handleBackspace,
3831
+ handleDelete: () => handleDelete,
3832
+ hasListBefore: () => hasListBefore,
3833
+ hasListItemAfter: () => hasListItemAfter,
3834
+ hasListItemBefore: () => hasListItemBefore,
3835
+ listItemHasSubList: () => listItemHasSubList,
3836
+ nextListIsDeeper: () => nextListIsDeeper,
3837
+ nextListIsHigher: () => nextListIsHigher
3838
+ });
3839
+ var findListItemPos = (typeOrName, state) => {
3840
+ const { $from } = state.selection;
3841
+ const nodeType = getNodeType(typeOrName, state.schema);
3842
+ let currentNode = null;
3843
+ let currentDepth = $from.depth;
3844
+ let currentPos = $from.pos;
3845
+ let targetDepth = null;
3846
+ while (currentDepth > 0 && targetDepth === null) {
3847
+ currentNode = $from.node(currentDepth);
3848
+ if (currentNode.type === nodeType) {
3849
+ targetDepth = currentDepth;
3850
+ } else {
3851
+ currentDepth -= 1;
3852
+ currentPos -= 1;
3853
+ }
3854
+ }
3855
+ if (targetDepth === null) {
3856
+ return null;
3857
+ }
3858
+ return { $pos: state.doc.resolve(currentPos), depth: targetDepth };
3859
+ };
3860
+ var getNextListDepth = (typeOrName, state) => {
3861
+ const listItemPos = findListItemPos(typeOrName, state);
3862
+ if (!listItemPos) {
3863
+ return false;
3864
+ }
3865
+ const [, depth] = getNodeAtPosition(state, typeOrName, listItemPos.$pos.pos + 4);
3866
+ return depth;
3867
+ };
3868
+ var hasListBefore = (editorState, name, parentListTypes) => {
3869
+ const { $anchor } = editorState.selection;
3870
+ const previousNodePos = Math.max(0, $anchor.pos - 2);
3871
+ const previousNode = editorState.doc.resolve(previousNodePos).node();
3872
+ if (!previousNode || !parentListTypes.includes(previousNode.type.name)) {
3873
+ return false;
3874
+ }
3875
+ return true;
3876
+ };
3877
+ var hasListItemBefore = (typeOrName, state) => {
3878
+ var _a;
3879
+ const { $anchor } = state.selection;
3880
+ const $targetPos = state.doc.resolve($anchor.pos - 2);
3881
+ if ($targetPos.index() === 0) {
3882
+ return false;
3883
+ }
3884
+ if (((_a = $targetPos.nodeBefore) == null ? void 0 : _a.type.name) !== typeOrName) {
3885
+ return false;
3886
+ }
3887
+ return true;
3888
+ };
3889
+ var listItemHasSubList = (typeOrName, state, node) => {
3890
+ if (!node) {
3891
+ return false;
3892
+ }
3893
+ const nodeType = getNodeType(typeOrName, state.schema);
3894
+ let hasSubList = false;
3895
+ node.descendants((child) => {
3896
+ if (child.type === nodeType) {
3897
+ hasSubList = true;
3898
+ }
3899
+ });
3900
+ return hasSubList;
3901
+ };
3902
+ var handleBackspace = (editor, name, parentListTypes) => {
3903
+ if (editor.commands.undoInputRule()) {
3904
+ return true;
3905
+ }
3906
+ if (editor.state.selection.from !== editor.state.selection.to) {
3907
+ return false;
3908
+ }
3909
+ if (!isNodeActive(editor.state, name) && hasListBefore(editor.state, name, parentListTypes)) {
3910
+ const { $anchor } = editor.state.selection;
3911
+ const $listPos = editor.state.doc.resolve($anchor.before() - 1);
3912
+ const listDescendants = [];
3913
+ $listPos.node().descendants((node, pos) => {
3914
+ if (node.type.name === name) {
3915
+ listDescendants.push({ node, pos });
3916
+ }
3917
+ });
3918
+ const lastItem = listDescendants.at(-1);
3919
+ if (!lastItem) {
3920
+ return false;
3921
+ }
3922
+ const $lastItemPos = editor.state.doc.resolve($listPos.start() + lastItem.pos + 1);
3923
+ return editor.chain().cut({ from: $anchor.start() - 1, to: $anchor.end() + 1 }, $lastItemPos.end()).joinForward().run();
3924
+ }
3925
+ if (!isNodeActive(editor.state, name)) {
3926
+ return false;
3927
+ }
3928
+ if (!isAtStartOfNode(editor.state)) {
3929
+ return false;
3930
+ }
3931
+ const listItemPos = findListItemPos(name, editor.state);
3932
+ if (!listItemPos) {
3933
+ return false;
3934
+ }
3935
+ const $prev = editor.state.doc.resolve(listItemPos.$pos.pos - 2);
3936
+ const prevNode = $prev.node(listItemPos.depth);
3937
+ const previousListItemHasSubList = listItemHasSubList(name, editor.state, prevNode);
3938
+ if (hasListItemBefore(name, editor.state) && !previousListItemHasSubList) {
3939
+ return editor.commands.joinItemBackward();
3940
+ }
3941
+ return editor.chain().liftListItem(name).run();
3942
+ };
3943
+ var nextListIsDeeper = (typeOrName, state) => {
3944
+ const listDepth = getNextListDepth(typeOrName, state);
3945
+ const listItemPos = findListItemPos(typeOrName, state);
3946
+ if (!listItemPos || !listDepth) {
3947
+ return false;
3948
+ }
3949
+ if (listDepth > listItemPos.depth) {
3950
+ return true;
3951
+ }
3952
+ return false;
3953
+ };
3954
+ var nextListIsHigher = (typeOrName, state) => {
3955
+ const listDepth = getNextListDepth(typeOrName, state);
3956
+ const listItemPos = findListItemPos(typeOrName, state);
3957
+ if (!listItemPos || !listDepth) {
3958
+ return false;
3959
+ }
3960
+ if (listDepth < listItemPos.depth) {
3961
+ return true;
3962
+ }
3963
+ return false;
3964
+ };
3965
+ var handleDelete = (editor, name) => {
3966
+ if (!isNodeActive(editor.state, name)) {
3967
+ return false;
3968
+ }
3969
+ if (!isAtEndOfNode(editor.state, name)) {
3970
+ return false;
3971
+ }
3972
+ const { selection } = editor.state;
3973
+ const { $from, $to } = selection;
3974
+ if (!selection.empty && $from.sameParent($to)) {
3975
+ return false;
3976
+ }
3977
+ if (nextListIsDeeper(name, editor.state)) {
3978
+ return editor.chain().focus(editor.state.selection.from + 4).lift(name).joinBackward().run();
3979
+ }
3980
+ if (nextListIsHigher(name, editor.state)) {
3981
+ return editor.chain().joinForward().joinBackward().run();
3982
+ }
3983
+ return editor.commands.joinItemForward();
3984
+ };
3985
+ var hasListItemAfter = (typeOrName, state) => {
3986
+ var _a;
3987
+ const { $anchor } = state.selection;
3988
+ const $targetPos = state.doc.resolve($anchor.pos - $anchor.parentOffset - 2);
3989
+ if ($targetPos.index() === $targetPos.parent.childCount - 1) {
3990
+ return false;
3991
+ }
3992
+ if (((_a = $targetPos.nodeAfter) == null ? void 0 : _a.type.name) !== typeOrName) {
3993
+ return false;
3994
+ }
3995
+ return true;
3996
+ };
3997
+ var ListKeymap = Extension.create({
3998
+ name: "listKeymap",
3999
+ addOptions() {
4000
+ return {
4001
+ listTypes: [
4002
+ {
4003
+ itemName: "listItem",
4004
+ wrapperNames: ["bulletList", "orderedList"]
4005
+ },
4006
+ {
4007
+ itemName: "taskItem",
4008
+ wrapperNames: ["taskList"]
4009
+ }
4010
+ ]
4011
+ };
4012
+ },
4013
+ addKeyboardShortcuts() {
4014
+ return {
4015
+ Delete: ({ editor }) => {
4016
+ let handled = false;
4017
+ this.options.listTypes.forEach(({ itemName }) => {
4018
+ if (editor.state.schema.nodes[itemName] === void 0) {
4019
+ return;
4020
+ }
4021
+ if (handleDelete(editor, itemName)) {
4022
+ handled = true;
4023
+ }
4024
+ });
4025
+ return handled;
4026
+ },
4027
+ "Mod-Delete": ({ editor }) => {
4028
+ let handled = false;
4029
+ this.options.listTypes.forEach(({ itemName }) => {
4030
+ if (editor.state.schema.nodes[itemName] === void 0) {
4031
+ return;
4032
+ }
4033
+ if (handleDelete(editor, itemName)) {
4034
+ handled = true;
4035
+ }
4036
+ });
4037
+ return handled;
4038
+ },
4039
+ Backspace: ({ editor }) => {
4040
+ let handled = false;
4041
+ this.options.listTypes.forEach(({ itemName, wrapperNames }) => {
4042
+ if (editor.state.schema.nodes[itemName] === void 0) {
4043
+ return;
4044
+ }
4045
+ if (handleBackspace(editor, itemName, wrapperNames)) {
4046
+ handled = true;
4047
+ }
4048
+ });
4049
+ return handled;
4050
+ },
4051
+ "Mod-Backspace": ({ editor }) => {
4052
+ let handled = false;
4053
+ this.options.listTypes.forEach(({ itemName, wrapperNames }) => {
4054
+ if (editor.state.schema.nodes[itemName] === void 0) {
4055
+ return;
4056
+ }
4057
+ if (handleBackspace(editor, itemName, wrapperNames)) {
4058
+ handled = true;
4059
+ }
4060
+ });
4061
+ return handled;
4062
+ }
4063
+ };
4064
+ }
4065
+ });
4066
+ var ListItemName2 = "listItem";
4067
+ var TextStyleName2 = "textStyle";
4068
+ var orderedListInputRegex = /^(\d+)\.\s$/;
4069
+ var OrderedList = Node3.create({
4070
+ name: "orderedList",
4071
+ addOptions() {
4072
+ return {
4073
+ itemTypeName: "listItem",
4074
+ HTMLAttributes: {},
4075
+ keepMarks: false,
4076
+ keepAttributes: false
4077
+ };
4078
+ },
4079
+ group: "block list",
4080
+ content() {
4081
+ return `${this.options.itemTypeName}+`;
4082
+ },
4083
+ addAttributes() {
4084
+ return {
4085
+ start: {
4086
+ default: 1,
4087
+ parseHTML: (element) => {
4088
+ return element.hasAttribute("start") ? parseInt(element.getAttribute("start") || "", 10) : 1;
4089
+ }
4090
+ },
4091
+ type: {
4092
+ default: null,
4093
+ parseHTML: (element) => element.getAttribute("type")
4094
+ }
4095
+ };
4096
+ },
4097
+ parseHTML() {
4098
+ return [
4099
+ {
4100
+ tag: "ol"
4101
+ }
4102
+ ];
4103
+ },
4104
+ renderHTML({ HTMLAttributes }) {
4105
+ const { start, ...attributesWithoutStart } = HTMLAttributes;
4106
+ return start === 1 ? ["ol", mergeAttributes(this.options.HTMLAttributes, attributesWithoutStart), 0] : ["ol", mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
4107
+ },
4108
+ addCommands() {
4109
+ return {
4110
+ toggleOrderedList: () => ({ commands, chain }) => {
4111
+ if (this.options.keepAttributes) {
4112
+ return chain().toggleList(this.name, this.options.itemTypeName, this.options.keepMarks).updateAttributes(ListItemName2, this.editor.getAttributes(TextStyleName2)).run();
4113
+ }
4114
+ return commands.toggleList(this.name, this.options.itemTypeName, this.options.keepMarks);
4115
+ }
4116
+ };
4117
+ },
4118
+ addKeyboardShortcuts() {
4119
+ return {
4120
+ "Mod-Shift-7": () => this.editor.commands.toggleOrderedList()
4121
+ };
4122
+ },
4123
+ addInputRules() {
4124
+ let inputRule = wrappingInputRule({
4125
+ find: orderedListInputRegex,
4126
+ type: this.type,
4127
+ getAttributes: (match) => ({ start: +match[1] }),
4128
+ joinPredicate: (match, node) => node.childCount + node.attrs.start === +match[1]
4129
+ });
4130
+ if (this.options.keepMarks || this.options.keepAttributes) {
4131
+ inputRule = wrappingInputRule({
4132
+ find: orderedListInputRegex,
4133
+ type: this.type,
4134
+ keepMarks: this.options.keepMarks,
4135
+ keepAttributes: this.options.keepAttributes,
4136
+ getAttributes: (match) => ({ start: +match[1], ...this.editor.getAttributes(TextStyleName2) }),
4137
+ joinPredicate: (match, node) => node.childCount + node.attrs.start === +match[1],
4138
+ editor: this.editor
4139
+ });
4140
+ }
4141
+ return [inputRule];
4142
+ }
4143
+ });
4144
+ var inputRegex$1 = /^\s*(\[([( |x])?\])\s$/;
4145
+ var TaskItem = Node3.create({
4146
+ name: "taskItem",
4147
+ addOptions() {
4148
+ return {
4149
+ nested: false,
4150
+ HTMLAttributes: {},
4151
+ taskListTypeName: "taskList",
4152
+ a11y: void 0
4153
+ };
4154
+ },
4155
+ content() {
4156
+ return this.options.nested ? "paragraph block*" : "paragraph+";
4157
+ },
4158
+ defining: true,
4159
+ addAttributes() {
4160
+ return {
4161
+ checked: {
4162
+ default: false,
4163
+ keepOnSplit: false,
4164
+ parseHTML: (element) => {
4165
+ const dataChecked = element.getAttribute("data-checked");
4166
+ return dataChecked === "" || dataChecked === "true";
4167
+ },
4168
+ renderHTML: (attributes) => ({
4169
+ "data-checked": attributes.checked
4170
+ })
4171
+ }
4172
+ };
4173
+ },
4174
+ parseHTML() {
4175
+ return [
4176
+ {
4177
+ tag: `li[data-type="${this.name}"]`,
4178
+ priority: 51
4179
+ }
4180
+ ];
4181
+ },
4182
+ renderHTML({ node, HTMLAttributes }) {
4183
+ return [
4184
+ "li",
4185
+ mergeAttributes(this.options.HTMLAttributes, HTMLAttributes, {
4186
+ "data-type": this.name
4187
+ }),
4188
+ [
4189
+ "label",
4190
+ [
4191
+ "input",
4192
+ {
4193
+ type: "checkbox",
4194
+ checked: node.attrs.checked ? "checked" : null
4195
+ }
4196
+ ],
4197
+ ["span"]
4198
+ ],
4199
+ ["div", 0]
4200
+ ];
4201
+ },
4202
+ addKeyboardShortcuts() {
4203
+ const shortcuts = {
4204
+ Enter: () => this.editor.commands.splitListItem(this.name),
4205
+ "Shift-Tab": () => this.editor.commands.liftListItem(this.name)
4206
+ };
4207
+ if (!this.options.nested) {
4208
+ return shortcuts;
4209
+ }
4210
+ return {
4211
+ ...shortcuts,
4212
+ Tab: () => this.editor.commands.sinkListItem(this.name)
4213
+ };
4214
+ },
4215
+ addNodeView() {
4216
+ return ({ node, HTMLAttributes, getPos, editor }) => {
4217
+ const listItem = document.createElement("li");
4218
+ const checkboxWrapper = document.createElement("label");
4219
+ const checkboxStyler = document.createElement("span");
4220
+ const checkbox = document.createElement("input");
4221
+ const content = document.createElement("div");
4222
+ const updateA11Y = () => {
4223
+ var _a, _b;
4224
+ checkbox.ariaLabel = ((_b = (_a = this.options.a11y) == null ? void 0 : _a.checkboxLabel) == null ? void 0 : _b.call(_a, node, checkbox.checked)) || `Task item checkbox for ${node.textContent || "empty task item"}`;
4225
+ };
4226
+ updateA11Y();
4227
+ checkboxWrapper.contentEditable = "false";
4228
+ checkbox.type = "checkbox";
4229
+ checkbox.addEventListener("mousedown", (event) => event.preventDefault());
4230
+ checkbox.addEventListener("change", (event) => {
4231
+ if (!editor.isEditable && !this.options.onReadOnlyChecked) {
4232
+ checkbox.checked = !checkbox.checked;
4233
+ return;
4234
+ }
4235
+ const { checked } = event.target;
4236
+ if (editor.isEditable && typeof getPos === "function") {
4237
+ editor.chain().focus(void 0, { scrollIntoView: false }).command(({ tr: tr2 }) => {
4238
+ const position = getPos();
4239
+ if (typeof position !== "number") {
4240
+ return false;
4241
+ }
4242
+ const currentNode = tr2.doc.nodeAt(position);
4243
+ tr2.setNodeMarkup(position, void 0, {
4244
+ ...currentNode == null ? void 0 : currentNode.attrs,
4245
+ checked
4246
+ });
4247
+ return true;
4248
+ }).run();
4249
+ }
4250
+ if (!editor.isEditable && this.options.onReadOnlyChecked) {
4251
+ if (!this.options.onReadOnlyChecked(node, checked)) {
4252
+ checkbox.checked = !checkbox.checked;
4253
+ }
4254
+ }
4255
+ });
4256
+ Object.entries(this.options.HTMLAttributes).forEach(([key, value]) => {
4257
+ listItem.setAttribute(key, value);
4258
+ });
4259
+ listItem.dataset.checked = node.attrs.checked;
4260
+ checkbox.checked = node.attrs.checked;
4261
+ checkboxWrapper.append(checkbox, checkboxStyler);
4262
+ listItem.append(checkboxWrapper, content);
4263
+ Object.entries(HTMLAttributes).forEach(([key, value]) => {
4264
+ listItem.setAttribute(key, value);
4265
+ });
4266
+ return {
4267
+ dom: listItem,
4268
+ contentDOM: content,
4269
+ update: (updatedNode) => {
4270
+ if (updatedNode.type !== this.type) {
4271
+ return false;
4272
+ }
4273
+ listItem.dataset.checked = updatedNode.attrs.checked;
4274
+ checkbox.checked = updatedNode.attrs.checked;
4275
+ updateA11Y();
4276
+ return true;
4277
+ }
4278
+ };
4279
+ };
4280
+ },
4281
+ addInputRules() {
4282
+ return [
4283
+ wrappingInputRule({
4284
+ find: inputRegex$1,
4285
+ type: this.type,
4286
+ getAttributes: (match) => ({
4287
+ checked: match[match.length - 1] === "x"
4288
+ })
4289
+ })
4290
+ ];
4291
+ }
4292
+ });
4293
+ var TaskList = Node3.create({
4294
+ name: "taskList",
4295
+ addOptions() {
4296
+ return {
4297
+ itemTypeName: "taskItem",
4298
+ HTMLAttributes: {}
4299
+ };
4300
+ },
4301
+ group: "block list",
4302
+ content() {
4303
+ return `${this.options.itemTypeName}+`;
4304
+ },
4305
+ parseHTML() {
4306
+ return [
4307
+ {
4308
+ tag: `ul[data-type="${this.name}"]`,
4309
+ priority: 51
4310
+ }
4311
+ ];
4312
+ },
4313
+ renderHTML({ HTMLAttributes }) {
4314
+ return ["ul", mergeAttributes(this.options.HTMLAttributes, HTMLAttributes, { "data-type": this.name }), 0];
4315
+ },
4316
+ addCommands() {
4317
+ return {
4318
+ toggleTaskList: () => ({ commands }) => {
4319
+ return commands.toggleList(this.name, this.options.itemTypeName);
4320
+ }
4321
+ };
4322
+ },
4323
+ addKeyboardShortcuts() {
4324
+ return {
4325
+ "Mod-Shift-9": () => this.editor.commands.toggleTaskList()
4326
+ };
4327
+ }
4328
+ });
4329
+ Extension.create({
4330
+ name: "listKit",
4331
+ addExtensions() {
4332
+ const extensions = [];
4333
+ if (this.options.bulletList !== false) {
4334
+ extensions.push(BulletList.configure(this.options.bulletList));
4335
+ }
4336
+ if (this.options.listItem !== false) {
4337
+ extensions.push(ListItem.configure(this.options.listItem));
4338
+ }
4339
+ if (this.options.listKeymap !== false) {
4340
+ extensions.push(ListKeymap.configure(this.options.listKeymap));
4341
+ }
4342
+ if (this.options.orderedList !== false) {
4343
+ extensions.push(OrderedList.configure(this.options.orderedList));
4344
+ }
4345
+ if (this.options.taskItem !== false) {
4346
+ extensions.push(TaskItem.configure(this.options.taskItem));
4347
+ }
4348
+ if (this.options.taskList !== false) {
4349
+ extensions.push(TaskList.configure(this.options.taskList));
4350
+ }
4351
+ return extensions;
4352
+ }
4353
+ });
4354
+ var Paragraph = Node3.create({
4355
+ name: "paragraph",
4356
+ priority: 1e3,
4357
+ addOptions() {
4358
+ return {
4359
+ HTMLAttributes: {}
4360
+ };
4361
+ },
4362
+ group: "block",
4363
+ content: "inline*",
4364
+ parseHTML() {
4365
+ return [{ tag: "p" }];
4366
+ },
4367
+ renderHTML({ HTMLAttributes }) {
4368
+ return ["p", mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
4369
+ },
4370
+ addCommands() {
4371
+ return {
4372
+ setParagraph: () => ({ commands }) => {
4373
+ return commands.setNode(this.name);
4374
+ }
4375
+ };
4376
+ },
4377
+ addKeyboardShortcuts() {
4378
+ return {
4379
+ "Mod-Alt-0": () => this.editor.commands.setParagraph()
4380
+ };
4381
+ }
4382
+ });
4383
+ var inputRegex = /(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/;
4384
+ var pasteRegex = /(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g;
4385
+ var Strike = Mark.create({
4386
+ name: "strike",
4387
+ addOptions() {
4388
+ return {
4389
+ HTMLAttributes: {}
4390
+ };
4391
+ },
4392
+ parseHTML() {
4393
+ return [
4394
+ {
4395
+ tag: "s"
4396
+ },
4397
+ {
4398
+ tag: "del"
4399
+ },
4400
+ {
4401
+ tag: "strike"
4402
+ },
4403
+ {
4404
+ style: "text-decoration",
4405
+ consuming: false,
4406
+ getAttrs: (style) => style.includes("line-through") ? {} : false
4407
+ }
4408
+ ];
4409
+ },
4410
+ renderHTML({ HTMLAttributes }) {
4411
+ return ["s", mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
4412
+ },
4413
+ addCommands() {
4414
+ return {
4415
+ setStrike: () => ({ commands }) => {
4416
+ return commands.setMark(this.name);
4417
+ },
4418
+ toggleStrike: () => ({ commands }) => {
4419
+ return commands.toggleMark(this.name);
4420
+ },
4421
+ unsetStrike: () => ({ commands }) => {
4422
+ return commands.unsetMark(this.name);
4423
+ }
4424
+ };
4425
+ },
4426
+ addKeyboardShortcuts() {
4427
+ return {
4428
+ "Mod-Shift-s": () => this.editor.commands.toggleStrike()
4429
+ };
4430
+ },
4431
+ addInputRules() {
4432
+ return [
4433
+ markInputRule({
4434
+ find: inputRegex,
4435
+ type: this.type
4436
+ })
4437
+ ];
4438
+ },
4439
+ addPasteRules() {
4440
+ return [
4441
+ markPasteRule({
4442
+ find: pasteRegex,
4443
+ type: this.type
4444
+ })
4445
+ ];
4446
+ }
4447
+ });
4448
+ var Text = Node3.create({
4449
+ name: "text",
4450
+ group: "inline"
4451
+ });
4452
+ var Underline = Mark.create({
4453
+ name: "underline",
4454
+ addOptions() {
4455
+ return {
4456
+ HTMLAttributes: {}
4457
+ };
4458
+ },
4459
+ parseHTML() {
4460
+ return [
4461
+ {
4462
+ tag: "u"
4463
+ },
4464
+ {
4465
+ style: "text-decoration",
4466
+ consuming: false,
4467
+ getAttrs: (style) => style.includes("underline") ? {} : false
4468
+ }
4469
+ ];
4470
+ },
4471
+ renderHTML({ HTMLAttributes }) {
4472
+ return ["u", mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
4473
+ },
4474
+ addCommands() {
4475
+ return {
4476
+ setUnderline: () => ({ commands }) => {
4477
+ return commands.setMark(this.name);
4478
+ },
4479
+ toggleUnderline: () => ({ commands }) => {
4480
+ return commands.toggleMark(this.name);
4481
+ },
4482
+ unsetUnderline: () => ({ commands }) => {
4483
+ return commands.unsetMark(this.name);
4484
+ }
4485
+ };
4486
+ },
4487
+ addKeyboardShortcuts() {
4488
+ return {
4489
+ "Mod-u": () => this.editor.commands.toggleUnderline(),
4490
+ "Mod-U": () => this.editor.commands.toggleUnderline()
4491
+ };
4492
+ }
4493
+ });
4494
+ var StarterKit = Extension.create({
4495
+ name: "starterKit",
4496
+ addExtensions() {
4497
+ var _a, _b, _c, _d;
4498
+ const extensions = [];
4499
+ if (this.options.bold !== false) {
4500
+ extensions.push(Bold.configure(this.options.bold));
4501
+ }
4502
+ if (this.options.blockquote !== false) {
4503
+ extensions.push(Blockquote.configure(this.options.blockquote));
4504
+ }
4505
+ if (this.options.bulletList !== false) {
4506
+ extensions.push(BulletList.configure(this.options.bulletList));
4507
+ }
4508
+ if (this.options.code !== false) {
4509
+ extensions.push(Code.configure(this.options.code));
4510
+ }
4511
+ if (this.options.codeBlock !== false) {
4512
+ extensions.push(CodeBlock.configure(this.options.codeBlock));
4513
+ }
4514
+ if (this.options.document !== false) {
4515
+ extensions.push(Document.configure(this.options.document));
4516
+ }
4517
+ if (this.options.dropcursor !== false) {
4518
+ extensions.push(Dropcursor.configure(this.options.dropcursor));
4519
+ }
4520
+ if (this.options.gapcursor !== false) {
4521
+ extensions.push(Gapcursor.configure(this.options.gapcursor));
4522
+ }
4523
+ if (this.options.hardBreak !== false) {
4524
+ extensions.push(HardBreak.configure(this.options.hardBreak));
4525
+ }
4526
+ if (this.options.heading !== false) {
4527
+ extensions.push(Heading.configure(this.options.heading));
4528
+ }
4529
+ if (this.options.undoRedo !== false) {
4530
+ extensions.push(UndoRedo.configure(this.options.undoRedo));
4531
+ }
4532
+ if (this.options.horizontalRule !== false) {
4533
+ extensions.push(HorizontalRule.configure(this.options.horizontalRule));
4534
+ }
4535
+ if (this.options.italic !== false) {
4536
+ extensions.push(Italic.configure(this.options.italic));
4537
+ }
4538
+ if (this.options.listItem !== false) {
4539
+ extensions.push(ListItem.configure(this.options.listItem));
4540
+ }
4541
+ if (this.options.listKeymap !== false) {
4542
+ extensions.push(ListKeymap.configure((_a = this.options) == null ? void 0 : _a.listKeymap));
4543
+ }
4544
+ if (this.options.link !== false) {
4545
+ extensions.push(Link.configure((_b = this.options) == null ? void 0 : _b.link));
4546
+ }
4547
+ if (this.options.orderedList !== false) {
4548
+ extensions.push(OrderedList.configure(this.options.orderedList));
4549
+ }
4550
+ if (this.options.paragraph !== false) {
4551
+ extensions.push(Paragraph.configure(this.options.paragraph));
4552
+ }
4553
+ if (this.options.strike !== false) {
4554
+ extensions.push(Strike.configure(this.options.strike));
4555
+ }
4556
+ if (this.options.text !== false) {
4557
+ extensions.push(Text.configure(this.options.text));
4558
+ }
4559
+ if (this.options.underline !== false) {
4560
+ extensions.push(Underline.configure((_c = this.options) == null ? void 0 : _c.underline));
4561
+ }
4562
+ if (this.options.trailingNode !== false) {
4563
+ extensions.push(TrailingNode.configure((_d = this.options) == null ? void 0 : _d.trailingNode));
4564
+ }
4565
+ return extensions;
4566
+ }
4567
+ });
4568
+ var index_default = StarterKit;
4569
+ export {
4570
+ CharacterCount as C,
4571
+ Placeholder as P,
4572
+ TextStyleKit as T,
4573
+ index_default$1 as a,
4574
+ index_default$2 as b,
4575
+ index_default as i
4576
+ };