@onereach/ui-components 4.5.0-beta.2726.0 → 4.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (290) hide show
  1. package/dist/bundled/v2/{OrDateTimePickerMonthSelect-5fa6caa0.js → OrDateTimePickerMonthSelect-75089f80.js} +6 -3
  2. package/dist/bundled/v2/{OrDateTimePickerTimeSelect-aa60911c.js → OrDateTimePickerTimeSelect-3d0ef650.js} +6 -3
  3. package/dist/bundled/v2/components/OrCode/OrCode.js +3792 -6
  4. package/dist/bundled/v2/components/OrCode/index.js +2 -6
  5. package/dist/bundled/v2/components/OrCode/lang.js +3 -3941
  6. package/dist/bundled/v2/components/OrCode/theme.js +1 -2
  7. package/dist/bundled/v2/components/OrConfirm/OrConfirm.js +0 -1
  8. package/dist/bundled/v2/components/OrConfirm/index.js +0 -1
  9. package/dist/bundled/v2/components/OrDatePickerV3/OrDatePicker.js +12 -1
  10. package/dist/bundled/v2/components/OrDatePickerV3/index.js +1 -1
  11. package/dist/bundled/v2/components/OrDateTimePickerV3/OrDateTimePicker.js +13 -2
  12. package/dist/bundled/v2/components/OrDateTimePickerV3/index.js +2 -2
  13. package/dist/bundled/v2/components/OrModal/OrModal.js +1346 -3
  14. package/dist/bundled/v2/components/OrModal/index.js +0 -1
  15. package/dist/bundled/v2/components/OrTabsV3/styles.js +1 -1
  16. package/dist/bundled/v2/components/OrTimePickerV3/OrTimePicker.js +12 -1
  17. package/dist/bundled/v2/components/OrTimePickerV3/index.js +1 -1
  18. package/dist/bundled/v2/components/index.d.ts +2 -1
  19. package/dist/bundled/v2/components/index.js +10 -22
  20. package/dist/bundled/v2/{index-0d224ae5.js → index-cf2c3c27.js} +115 -3
  21. package/dist/bundled/v2/index.js +13 -25
  22. package/dist/bundled/{v3/index-e9f6b2d8.js → v2/lang-0fb8f78b.js} +4009 -73
  23. package/dist/bundled/v3/{index-d92d0b48.js → OrCode.vue_vue_type_script_lang-74060519.js} +235 -14
  24. package/dist/bundled/v3/OrCombinedInput.vue_vue_type_script_lang-cb7a88f3.js +66 -0
  25. package/dist/bundled/v3/{OrConfirm.vue_vue_type_script_lang-ae9422fb.js → OrConfirm.vue_vue_type_script_lang-e5a8f92a.js} +1 -1
  26. package/dist/bundled/v3/{OrDatePicker.vue_vue_type_script_lang-33719f37.js → OrDatePicker.vue_vue_type_script_lang-d071d109.js} +1 -1
  27. package/dist/bundled/v3/{OrDateTimePicker.vue_vue_type_script_lang-ef95eeb6.js → OrDateTimePicker.vue_vue_type_script_lang-8aa80833.js} +2 -2
  28. package/dist/bundled/v3/{OrDateTimePickerMonthSelect-fe878127.js → OrDateTimePickerMonthSelect-387c2096.js} +6 -4
  29. package/dist/bundled/v3/{OrDateTimePickerTimeSelect-b962e4d5.js → OrDateTimePickerTimeSelect-8bdb97b7.js} +6 -4
  30. package/dist/bundled/{v2/useFocusTrap-104d095b.js → v3/OrModal.vue_vue_type_script_lang-ae842e5b.js} +106 -3
  31. package/dist/bundled/v3/{OrTimePicker.vue_vue_type_script_lang-dd7222e8.js → OrTimePicker.vue_vue_type_script_lang-c52a2a0b.js} +1 -1
  32. package/dist/bundled/v3/components/OrCode/OrCode.js +6 -10
  33. package/dist/bundled/v3/components/OrCode/index.js +4 -8
  34. package/dist/bundled/v3/components/OrCode/lang.js +3 -3941
  35. package/dist/bundled/v3/components/OrCode/theme.js +1 -2
  36. package/dist/bundled/v3/components/OrCombinedInputV3/OrCombinedInput.js +11 -66
  37. package/dist/bundled/v3/components/OrCombinedInputV3/index.js +1 -1
  38. package/dist/bundled/v3/components/OrConfirm/OrConfirm.js +3 -4
  39. package/dist/bundled/v3/components/OrConfirm/index.js +2 -3
  40. package/dist/bundled/v3/components/OrDatePickerV3/OrDatePicker.js +6 -6
  41. package/dist/bundled/v3/components/OrDatePickerV3/index.js +2 -2
  42. package/dist/bundled/v3/components/OrDateTimePickerV3/OrDateTimePicker.js +7 -7
  43. package/dist/bundled/v3/components/OrDateTimePickerV3/index.js +3 -3
  44. package/dist/bundled/v3/components/OrModal/OrModal.js +2 -3
  45. package/dist/bundled/v3/components/OrModal/index.js +1 -2
  46. package/dist/bundled/v3/components/OrTabsV3/OrTabs.js +2 -2
  47. package/dist/bundled/v3/components/OrTabsV3/index.js +1 -1
  48. package/dist/bundled/v3/components/OrTabsV3/styles.js +1 -1
  49. package/dist/bundled/v3/components/OrTimePickerV3/OrTimePicker.js +6 -6
  50. package/dist/bundled/v3/components/OrTimePickerV3/index.js +2 -2
  51. package/dist/bundled/v3/components/index.d.ts +2 -1
  52. package/dist/bundled/v3/components/index.js +16 -29
  53. package/dist/bundled/v3/{index-0d224ae5.js → index-cf2c3c27.js} +115 -3
  54. package/dist/bundled/v3/index.js +25 -37
  55. package/dist/bundled/{v2/index-e9f6b2d8.js → v3/lang-0fb8f78b.js} +4009 -73
  56. package/dist/esm/v2/OrCombinedInput-5994d9fc.js +158 -0
  57. package/dist/esm/v2/{OrDatePicker-a8c95da8.js → OrDatePicker-b6ebf44a.js} +12 -1
  58. package/dist/esm/v2/{OrDateTimePicker-9271659e.js → OrDateTimePicker-85c08b90.js} +13 -2
  59. package/dist/esm/v2/{OrDateTimePickerMonthSelect-a3a0fb4e.js → OrDateTimePickerMonthSelect-e35404a7.js} +6 -3
  60. package/dist/esm/v2/{OrDateTimePickerTimeSelect-0b70d0df.js → OrDateTimePickerTimeSelect-aed7d33d.js} +6 -3
  61. package/dist/esm/v2/{OrTabs-b9908867.js → OrTabs-653258a2.js} +1 -1
  62. package/dist/esm/v2/{OrTimePicker-0c6a05f1.js → OrTimePicker-696e29ed.js} +12 -1
  63. package/dist/esm/v2/components/index.d.ts +2 -1
  64. package/dist/esm/v2/components/index.js +10 -33
  65. package/dist/esm/v2/components/or-combined-input-v3/index.js +6 -158
  66. package/dist/esm/v2/components/or-date-picker-v3/index.js +2 -2
  67. package/dist/esm/v2/components/or-date-time-picker-v3/index.js +3 -3
  68. package/dist/esm/v2/components/or-tabs-v3/index.js +1 -1
  69. package/dist/esm/v2/components/or-time-picker-v3/index.js +2 -2
  70. package/dist/esm/v2/index.js +10 -33
  71. package/dist/esm/v3/OrCombinedInput-14c23a04.js +129 -0
  72. package/dist/esm/v3/{OrDatePicker-759653a5.js → OrDatePicker-f144d074.js} +4 -4
  73. package/dist/esm/v3/{OrDateTimePicker-4768a411.js → OrDateTimePicker-2214cd85.js} +5 -5
  74. package/dist/esm/v3/{OrDateTimePickerMonthSelect-c07806a0.js → OrDateTimePickerMonthSelect-5a7b7b5c.js} +6 -4
  75. package/dist/esm/v3/{OrDateTimePickerTimeSelect-9309c434.js → OrDateTimePickerTimeSelect-e404e826.js} +6 -4
  76. package/dist/esm/v3/{OrTabs-f9f0892e.js → OrTabs-a2d87627.js} +1 -1
  77. package/dist/esm/v3/{OrTimePicker-ba6e6857.js → OrTimePicker-68de86d9.js} +4 -4
  78. package/dist/esm/v3/components/index.d.ts +2 -1
  79. package/dist/esm/v3/components/index.js +9 -32
  80. package/dist/esm/v3/components/or-combined-input-v3/index.js +6 -129
  81. package/dist/esm/v3/components/or-date-picker-v3/index.js +2 -2
  82. package/dist/esm/v3/components/or-date-time-picker-v3/index.js +3 -3
  83. package/dist/esm/v3/components/or-tabs-v3/index.js +1 -1
  84. package/dist/esm/v3/components/or-time-picker-v3/index.js +2 -2
  85. package/dist/esm/v3/index.js +9 -32
  86. package/package.json +4 -24
  87. package/src/components/index.ts +2 -1
  88. package/src/components/or-button/OrButton.stories.ts +8 -0
  89. package/src/components/or-date-picker-v3/OrDatePicker.vue +2 -0
  90. package/src/components/or-date-time-picker-v3/OrDateTimePicker.vue +2 -0
  91. package/src/components/or-date-time-picker-v3/partials/or-date-time-picker-date-control/OrDateTimePickerDateControl.vue +7 -2
  92. package/src/components/or-date-time-picker-v3/partials/or-date-time-picker-time-control/OrDateTimePickerTimeControl.vue +7 -2
  93. package/src/components/or-tabs-v3/styles.ts +1 -1
  94. package/src/components/or-time-picker-v3/OrTimePicker.vue +2 -0
  95. package/dist/bundled/v2/components/OrRichTextEditorV3/OrRichTextEditor.js +0 -2200
  96. package/dist/bundled/v2/components/OrRichTextEditorV3/OrRichTextEditor.vue.d.ts +0 -220
  97. package/dist/bundled/v2/components/OrRichTextEditorV3/index.d.ts +0 -1
  98. package/dist/bundled/v2/components/OrRichTextEditorV3/index.js +0 -70
  99. package/dist/bundled/v2/components/OrRichTextEditorV3/props.d.ts +0 -4
  100. package/dist/bundled/v2/components/OrRichTextEditorV3/props.js +0 -7
  101. package/dist/bundled/v2/components/OrRichTextEditorV3/styles.d.ts +0 -6
  102. package/dist/bundled/v2/components/OrRichTextEditorV3/styles.js +0 -38
  103. package/dist/bundled/v2/components/OrRichTextEditorV3/utils/codemirror/codemirrorNode.d.ts +0 -3
  104. package/dist/bundled/v2/components/OrRichTextEditorV3/utils/codemirror/codemirrorNode.js +0 -46
  105. package/dist/bundled/v2/components/OrRichTextEditorV3/utils/codemirror/codemirrorView.d.ts +0 -27
  106. package/dist/bundled/v2/components/OrRichTextEditorV3/utils/codemirror/codemirrorView.js +0 -184
  107. package/dist/bundled/v2/components/OrRichTextEditorV3/utils/codemirror/index.d.ts +0 -1
  108. package/dist/bundled/v2/components/OrRichTextEditorV3/utils/codemirror/index.js +0 -5
  109. package/dist/bundled/v2/components/OrRichTextEditorV3/utils/codemirror/theme.d.ts +0 -24
  110. package/dist/bundled/v2/components/OrRichTextEditorV3/utils/codemirror/theme.js +0 -190
  111. package/dist/bundled/v2/components/OrRichTextEditorV3/utils/codemirror/types.d.ts +0 -19
  112. package/dist/bundled/v2/components/OrRichTextEditorV3/utils/codemirror/types.js +0 -1
  113. package/dist/bundled/v2/components/OrRichTextEditorV3/utils/markdown.d.ts +0 -3
  114. package/dist/bundled/v2/components/OrRichTextEditorV3/utils/markdown.js +0 -5
  115. package/dist/bundled/v2/index-418d5c0d.js +0 -9633
  116. package/dist/bundled/v2/index-85c2efe8.js +0 -7122
  117. package/dist/bundled/v2/index-d92d0b48.js +0 -3805
  118. package/dist/bundled/v2/index.es-3f39f316.js +0 -115
  119. package/dist/bundled/v2/markdown-7c7c4ca6.js +0 -17980
  120. package/dist/bundled/v3/OrCode.vue_vue_type_script_lang-a5b8c6ca.js +0 -237
  121. package/dist/bundled/v3/OrModal.vue_vue_type_script_lang-28541a68.js +0 -108
  122. package/dist/bundled/v3/OrRichTextEditor.vue_vue_type_script_lang-55b73340.js +0 -1890
  123. package/dist/bundled/v3/components/OrRichTextEditorV3/OrRichTextEditor.js +0 -284
  124. package/dist/bundled/v3/components/OrRichTextEditorV3/OrRichTextEditor.vue.d.ts +0 -145
  125. package/dist/bundled/v3/components/OrRichTextEditorV3/index.d.ts +0 -1
  126. package/dist/bundled/v3/components/OrRichTextEditorV3/index.js +0 -86
  127. package/dist/bundled/v3/components/OrRichTextEditorV3/props.d.ts +0 -4
  128. package/dist/bundled/v3/components/OrRichTextEditorV3/props.js +0 -7
  129. package/dist/bundled/v3/components/OrRichTextEditorV3/styles.d.ts +0 -6
  130. package/dist/bundled/v3/components/OrRichTextEditorV3/styles.js +0 -38
  131. package/dist/bundled/v3/components/OrRichTextEditorV3/utils/codemirror/codemirrorNode.d.ts +0 -3
  132. package/dist/bundled/v3/components/OrRichTextEditorV3/utils/codemirror/codemirrorNode.js +0 -46
  133. package/dist/bundled/v3/components/OrRichTextEditorV3/utils/codemirror/codemirrorView.d.ts +0 -27
  134. package/dist/bundled/v3/components/OrRichTextEditorV3/utils/codemirror/codemirrorView.js +0 -184
  135. package/dist/bundled/v3/components/OrRichTextEditorV3/utils/codemirror/index.d.ts +0 -1
  136. package/dist/bundled/v3/components/OrRichTextEditorV3/utils/codemirror/index.js +0 -5
  137. package/dist/bundled/v3/components/OrRichTextEditorV3/utils/codemirror/theme.d.ts +0 -24
  138. package/dist/bundled/v3/components/OrRichTextEditorV3/utils/codemirror/theme.js +0 -190
  139. package/dist/bundled/v3/components/OrRichTextEditorV3/utils/codemirror/types.d.ts +0 -19
  140. package/dist/bundled/v3/components/OrRichTextEditorV3/utils/codemirror/types.js +0 -1
  141. package/dist/bundled/v3/components/OrRichTextEditorV3/utils/markdown.d.ts +0 -3
  142. package/dist/bundled/v3/components/OrRichTextEditorV3/utils/markdown.js +0 -5
  143. package/dist/bundled/v3/index-418d5c0d.js +0 -9633
  144. package/dist/bundled/v3/index-85c2efe8.js +0 -7122
  145. package/dist/bundled/v3/index.es-3f39f316.js +0 -115
  146. package/dist/bundled/v3/markdown-7c7c4ca6.js +0 -17980
  147. package/dist/bundled/v3/useFocusTrap-104d095b.js +0 -1348
  148. package/dist/esm/v2/OrRichTextEditor-8c43bb27.js +0 -923
  149. package/dist/esm/v2/codemirrorView-be2c7423.js +0 -353
  150. package/dist/esm/v2/components/or-rich-text-editor-v3/OrRichTextEditor.vue.d.ts +0 -220
  151. package/dist/esm/v2/components/or-rich-text-editor-v3/index.d.ts +0 -1
  152. package/dist/esm/v2/components/or-rich-text-editor-v3/index.js +0 -59
  153. package/dist/esm/v2/components/or-rich-text-editor-v3/props.d.ts +0 -4
  154. package/dist/esm/v2/components/or-rich-text-editor-v3/styles.d.ts +0 -6
  155. package/dist/esm/v2/components/or-rich-text-editor-v3/utils/codemirror/codemirrorNode.d.ts +0 -3
  156. package/dist/esm/v2/components/or-rich-text-editor-v3/utils/codemirror/codemirrorView.d.ts +0 -27
  157. package/dist/esm/v2/components/or-rich-text-editor-v3/utils/codemirror/index.d.ts +0 -1
  158. package/dist/esm/v2/components/or-rich-text-editor-v3/utils/codemirror/index.js +0 -7
  159. package/dist/esm/v2/components/or-rich-text-editor-v3/utils/codemirror/theme.d.ts +0 -24
  160. package/dist/esm/v2/components/or-rich-text-editor-v3/utils/codemirror/types.d.ts +0 -19
  161. package/dist/esm/v2/components/or-rich-text-editor-v3/utils/markdown.d.ts +0 -3
  162. package/dist/esm/v3/OrRichTextEditor-b20efab9.js +0 -856
  163. package/dist/esm/v3/codemirrorView-be2c7423.js +0 -353
  164. package/dist/esm/v3/components/or-rich-text-editor-v3/OrRichTextEditor.vue.d.ts +0 -145
  165. package/dist/esm/v3/components/or-rich-text-editor-v3/index.d.ts +0 -1
  166. package/dist/esm/v3/components/or-rich-text-editor-v3/index.js +0 -57
  167. package/dist/esm/v3/components/or-rich-text-editor-v3/props.d.ts +0 -4
  168. package/dist/esm/v3/components/or-rich-text-editor-v3/styles.d.ts +0 -6
  169. package/dist/esm/v3/components/or-rich-text-editor-v3/utils/codemirror/codemirrorNode.d.ts +0 -3
  170. package/dist/esm/v3/components/or-rich-text-editor-v3/utils/codemirror/codemirrorView.d.ts +0 -27
  171. package/dist/esm/v3/components/or-rich-text-editor-v3/utils/codemirror/index.d.ts +0 -1
  172. package/dist/esm/v3/components/or-rich-text-editor-v3/utils/codemirror/index.js +0 -7
  173. package/dist/esm/v3/components/or-rich-text-editor-v3/utils/codemirror/theme.d.ts +0 -24
  174. package/dist/esm/v3/components/or-rich-text-editor-v3/utils/codemirror/types.d.ts +0 -19
  175. package/dist/esm/v3/components/or-rich-text-editor-v3/utils/markdown.d.ts +0 -3
  176. package/src/components/or-bottom-sheet-v3/OrBottomSheet.docs.mdx +0 -7
  177. package/src/components/or-bottom-sheet-v3/OrBottomSheet.stories3.ts +0 -110
  178. package/src/components/or-button-v3/OrButton.docs.mdx +0 -14
  179. package/src/components/or-button-v3/OrButton.stories3.ts +0 -130
  180. package/src/components/or-card-collection-v3/OrCardCollection.docs.mdx +0 -7
  181. package/src/components/or-card-collection-v3/OrCardCollection.stories3.ts +0 -378
  182. package/src/components/or-card-v3/OrCard.docs.mdx +0 -10
  183. package/src/components/or-card-v3/OrCard.stories3.ts +0 -74
  184. package/src/components/or-checkbox-group-v3/OrCheckboxGroup.docs.mdx +0 -7
  185. package/src/components/or-checkbox-group-v3/OrCheckboxGroup.stories3.ts +0 -399
  186. package/src/components/or-checkbox-tree-v3/OrCheckboxTree.docs.mdx +0 -7
  187. package/src/components/or-checkbox-tree-v3/OrCheckboxTree.stories3.ts +0 -112
  188. package/src/components/or-checkbox-v3/OrCheckbox.docs.mdx +0 -12
  189. package/src/components/or-checkbox-v3/OrCheckbox.stories3.ts +0 -155
  190. package/src/components/or-combined-input-v3/OrCombinedInput.docs.mdx +0 -7
  191. package/src/components/or-combined-input-v3/OrCombinedInput.stories3.ts +0 -201
  192. package/src/components/or-confirm-v3/OrConfirm.docs.mdx +0 -16
  193. package/src/components/or-confirm-v3/OrConfirm.stories3.ts +0 -252
  194. package/src/components/or-date-picker-v3/OrDatePicker.docs.mdx +0 -7
  195. package/src/components/or-date-picker-v3/OrDatePicker.stories3.ts +0 -174
  196. package/src/components/or-date-time-picker-v3/OrDateTimePicker.docs.mdx +0 -7
  197. package/src/components/or-date-time-picker-v3/OrDateTimePicker.stories3.ts +0 -183
  198. package/src/components/or-empty-state-v3/OrEmptyState.stories3.ts +0 -87
  199. package/src/components/or-error-tag-v3/OrErrorTag.docs.mdx +0 -8
  200. package/src/components/or-error-tag-v3/OrErrorTag.stories3.ts +0 -56
  201. package/src/components/or-expansion-panel-v3/OrExpansionPanel.docs.mdx +0 -7
  202. package/src/components/or-expansion-panel-v3/OrExpansionPanel.stories3.ts +0 -137
  203. package/src/components/or-fab-v3/OrFab.docs.mdx +0 -7
  204. package/src/components/or-fab-v3/OrFab.stories3.ts +0 -81
  205. package/src/components/or-form-group-v3/OrFormGroup.stories3.ts +0 -114
  206. package/src/components/or-icon-button-v3/OrIconButton.docs.mdx +0 -14
  207. package/src/components/or-icon-button-v3/OrIconButton.stories3.ts +0 -105
  208. package/src/components/or-icon-v3/OrIcon.docs.mdx +0 -12
  209. package/src/components/or-icon-v3/OrIcon.stories3.ts +0 -53
  210. package/src/components/or-inline-input-v3/OrInlineInput.docs.mdx +0 -7
  211. package/src/components/or-inline-input-v3/OrInlineInput.stories3.ts +0 -137
  212. package/src/components/or-inline-textarea-v3/OrInlineTextarea.docs.mdx +0 -7
  213. package/src/components/or-inline-textarea-v3/OrInlineTextarea.stories3.ts +0 -126
  214. package/src/components/or-input-v3/OrInput.docs.mdx +0 -16
  215. package/src/components/or-input-v3/OrInput.stories3.ts +0 -222
  216. package/src/components/or-link-v3/OrLink.docs.mdx +0 -7
  217. package/src/components/or-link-v3/OrLink.stories3.ts +0 -163
  218. package/src/components/or-loader-v3/OrLoader.docs.mdx +0 -14
  219. package/src/components/or-loader-v3/OrLoader.stories3.ts +0 -86
  220. package/src/components/or-menu-item-v3/OrMenuItem.docs.mdx +0 -7
  221. package/src/components/or-menu-item-v3/OrMenuItem.stories3.ts +0 -90
  222. package/src/components/or-menu-v3/OrMenu.docs.mdx +0 -7
  223. package/src/components/or-menu-v3/OrMenu.stories3.ts +0 -167
  224. package/src/components/or-modal-v3/OrModal.docs.mdx +0 -10
  225. package/src/components/or-modal-v3/OrModal.stories3.ts +0 -278
  226. package/src/components/or-notification-v3/OrNotification.docs.mdx +0 -7
  227. package/src/components/or-notification-v3/OrNotification.stories3.ts +0 -122
  228. package/src/components/or-overlay-v3/OrOverlay.docs.mdx +0 -11
  229. package/src/components/or-overlay-v3/OrOverlay.stories3.ts +0 -61
  230. package/src/components/or-pagination-v3/OrPagination.docs.mdx +0 -7
  231. package/src/components/or-pagination-v3/OrPagination.stories3.ts +0 -81
  232. package/src/components/or-popover-v3/OrPopover.docs.mdx +0 -11
  233. package/src/components/or-popover-v3/OrPopover.stories3.ts +0 -115
  234. package/src/components/or-progress-v3/OrProgress.docs.mdx +0 -12
  235. package/src/components/or-progress-v3/OrProgress.stories3.ts +0 -220
  236. package/src/components/or-radio-group-v3/OrRadioGroup.stories3.ts +0 -81
  237. package/src/components/or-radio-v3/OrRadio.docs.mdx +0 -11
  238. package/src/components/or-radio-v3/OrRadio.stories3.ts +0 -151
  239. package/src/components/or-rich-text-editor-v3/OrRichTextEditor.docs.mdx +0 -7
  240. package/src/components/or-rich-text-editor-v3/OrRichTextEditor.stories3.ts +0 -142
  241. package/src/components/or-rich-text-editor-v3/OrRichTextEditor.vue +0 -766
  242. package/src/components/or-rich-text-editor-v3/index.ts +0 -1
  243. package/src/components/or-rich-text-editor-v3/props.ts +0 -4
  244. package/src/components/or-rich-text-editor-v3/styles.ts +0 -54
  245. package/src/components/or-rich-text-editor-v3/utils/codemirror/codemirrorNode.ts +0 -40
  246. package/src/components/or-rich-text-editor-v3/utils/codemirror/codemirrorView.ts +0 -254
  247. package/src/components/or-rich-text-editor-v3/utils/codemirror/index.ts +0 -1
  248. package/src/components/or-rich-text-editor-v3/utils/codemirror/theme.ts +0 -213
  249. package/src/components/or-rich-text-editor-v3/utils/codemirror/types.ts +0 -22
  250. package/src/components/or-rich-text-editor-v3/utils/markdown.ts +0 -120
  251. package/src/components/or-search-v3/OrSearch.docs.mdx +0 -16
  252. package/src/components/or-search-v3/OrSearch.stories3.ts +0 -126
  253. package/src/components/or-segmented-control-v3/OrSegmentedControl.docs.mdx +0 -7
  254. package/src/components/or-segmented-control-v3/OrSegmentedControl.stories3.ts +0 -100
  255. package/src/components/or-select-v3/OrSelect.docs.mdx +0 -17
  256. package/src/components/or-select-v3/OrSelect.stories3.ts +0 -508
  257. package/src/components/or-sidebar-v3/OrSidebar.docs.mdx +0 -13
  258. package/src/components/or-sidebar-v3/OrSidebar.stories3.ts +0 -415
  259. package/src/components/or-skeleton-v3/OrSkeleton.docs.mdx +0 -14
  260. package/src/components/or-skeleton-v3/OrSkeleton.stories3.ts +0 -144
  261. package/src/components/or-skeleton-v3/or-skeleton-circle-v3/OrSkeletonCircle.docs.mdx +0 -7
  262. package/src/components/or-skeleton-v3/or-skeleton-circle-v3/OrSkeletonCircle.stories3.ts +0 -59
  263. package/src/components/or-skeleton-v3/or-skeleton-rect-v3/OrSkeletonRect.docs.mdx +0 -6
  264. package/src/components/or-skeleton-v3/or-skeleton-rect-v3/OrSkeletonRect.stories3.ts +0 -80
  265. package/src/components/or-skeleton-v3/or-skeleton-text-v3/OrSkeletonText.docs.mdx +0 -7
  266. package/src/components/or-skeleton-v3/or-skeleton-text-v3/OrSkeletonText.stories3.ts +0 -88
  267. package/src/components/or-switch-v3/OrSwitch.docs.mdx +0 -7
  268. package/src/components/or-switch-v3/OrSwitch.stories3.ts +0 -155
  269. package/src/components/or-tab-v3/OrTab.docs.mdx +0 -7
  270. package/src/components/or-tab-v3/OrTab.stories3.ts +0 -74
  271. package/src/components/or-tabs-v3/OrTabs.docs.mdx +0 -7
  272. package/src/components/or-tabs-v3/OrTabs.stories3.ts +0 -140
  273. package/src/components/or-tag-v3/OrTag.docs.mdx +0 -13
  274. package/src/components/or-tag-v3/OrTag.stories3.ts +0 -213
  275. package/src/components/or-tags-v3/OrTags.docs.mdx +0 -7
  276. package/src/components/or-tags-v3/OrTags.stories3.ts +0 -101
  277. package/src/components/or-teleport-v3/OrTeleport.docs.mdx +0 -7
  278. package/src/components/or-teleport-v3/OrTeleport.stories3.ts +0 -60
  279. package/src/components/or-text-v3/OrText.docs.mdx +0 -7
  280. package/src/components/or-text-v3/OrText.stories3.ts +0 -124
  281. package/src/components/or-textarea-v3/OrTextarea.docs.mdx +0 -14
  282. package/src/components/or-textarea-v3/OrTextarea.stories3.ts +0 -164
  283. package/src/components/or-time-picker-v3/OrTimePicker.docs.mdx +0 -7
  284. package/src/components/or-time-picker-v3/OrTimePicker.stories3.ts +0 -170
  285. package/src/components/or-toast-v3/OrToast.stories3.ts +0 -67
  286. package/src/components/or-toast-v3/or-toast-container-v3/OrToastContainer.docs.mdx +0 -123
  287. package/src/components/or-toast-v3/or-toast-container-v3/OrToastContainer.stories3.ts +0 -119
  288. package/src/components/or-tooltip-v3/OrTooltip.docs.mdx +0 -10
  289. package/src/components/or-tooltip-v3/OrTooltip.stories3.ts +0 -84
  290. /package/dist/bundled/v3/{OrTabs.vue_vue_type_script_lang-b3f213b0.js → OrTabs.vue_vue_type_script_lang-9d4221f1.js} +0 -0
@@ -1,1890 +0,0 @@
1
- import { defineComponent, ref, onMounted, onBeforeUnmount, computed, watch, nextTick } from 'vue-demi';
2
- import { u as useFocusTrap } from './useFocusTrap-104d095b.js';
3
- import { useResizeObserver, onClickOutside } from '@vueuse/core';
4
- import { B as Blockquote, a as Bold, b as BulletList, C as CodeBlock, H as HardBreak, I as Italic, L as ListItem, O as OrderedList, P as Paragraph, S as Strike, s as serialize, d as deserialize, U as Underline, c as Link, e as Highlight } from './markdown-7c7c4ca6.js';
5
- import { EditorContainer, ToolbarContainer, Toolbar, ToolbarButtonFocused, ToolbarButton, EditorInput } from './components/OrRichTextEditorV3/styles.js';
6
- import { Formats } from './components/OrRichTextEditorV3/props.js';
7
- import { M as Mark, m as mergeAttributes, a as markInputRule, b as markPasteRule, N as Node, E as Extension, k as keydownHandler, D as DecorationSet, c as Decoration, d as callOrReturn, g as getExtensionField, t as textblockTypeInputRule, n as nodeInputRule, e as Editor } from './index-418d5c0d.js';
8
- import { P as Plugin, d as dropPoint, S as Selection, N as NodeSelection, F as Fragment, a as Slice, T as TextSelection, b as PluginKey, M as Mapping } from './index-85c2efe8.js';
9
- import codemirrorNode from './components/OrRichTextEditorV3/utils/codemirror/codemirrorNode.js';
10
- import './components/OrIconButtonV3/OrIconButton.js';
11
- import './components/OrLabelV3/OrLabel.js';
12
- import './components/OrMenuItemV3/OrMenuItem.js';
13
- import './components/OrMenuV3/OrMenu.js';
14
- import './components/OrModalV3/OrModal.js';
15
- import { s as script$5 } from './OrModal.vue_vue_type_script_lang-202c4e2f.js';
16
- import './components/OrInputV3/OrInput.js';
17
- import './components/OrButtonV3/OrButton.js';
18
- import { s as script$1 } from './OrIconButton.vue_vue_type_script_lang-5bba9f3f.js';
19
- import { s as script$2 } from './OrLabel.vue_vue_type_script_lang-3e11ab8a.js';
20
- import { s as script$3 } from './OrMenuItem.vue_vue_type_script_lang-b338d68a.js';
21
- import { s as script$4 } from './OrMenu.vue_vue_type_script_lang-115f2c60.js';
22
- import { s as script$6 } from './OrInput.vue_vue_type_script_lang-6242286b.js';
23
- import { s as script$7 } from './OrButton.vue_vue_type_script_lang-f58fa1b8.js';
24
-
25
- const inputRegex = /(?:^|\s)((?:`)((?:[^`]+))(?:`))$/;
26
- const pasteRegex = /(?:^|\s)((?:`)((?:[^`]+))(?:`))/g;
27
- const Code = Mark.create({
28
- name: 'code',
29
- addOptions() {
30
- return {
31
- HTMLAttributes: {}
32
- };
33
- },
34
- excludes: '_',
35
- code: true,
36
- exitable: true,
37
- parseHTML() {
38
- return [{
39
- tag: 'code'
40
- }];
41
- },
42
- renderHTML(_ref) {
43
- let {
44
- HTMLAttributes
45
- } = _ref;
46
- return ['code', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
47
- },
48
- addCommands() {
49
- return {
50
- setCode: () => _ref2 => {
51
- let {
52
- commands
53
- } = _ref2;
54
- return commands.setMark(this.name);
55
- },
56
- toggleCode: () => _ref3 => {
57
- let {
58
- commands
59
- } = _ref3;
60
- return commands.toggleMark(this.name);
61
- },
62
- unsetCode: () => _ref4 => {
63
- let {
64
- commands
65
- } = _ref4;
66
- return commands.unsetMark(this.name);
67
- }
68
- };
69
- },
70
- addKeyboardShortcuts() {
71
- return {
72
- 'Mod-e': () => this.editor.commands.toggleCode()
73
- };
74
- },
75
- addInputRules() {
76
- return [markInputRule({
77
- find: inputRegex,
78
- type: this.type
79
- })];
80
- },
81
- addPasteRules() {
82
- return [markPasteRule({
83
- find: pasteRegex,
84
- type: this.type
85
- })];
86
- }
87
- });
88
-
89
- const Document = Node.create({
90
- name: 'doc',
91
- topNode: true,
92
- content: 'block+'
93
- });
94
-
95
- /**
96
- Create a plugin that, when added to a ProseMirror instance,
97
- causes a decoration to show up at the drop position when something
98
- is dragged over the editor.
99
-
100
- Nodes may add a `disableDropCursor` property to their spec to
101
- control the showing of a drop cursor inside them. This may be a
102
- boolean or a function, which will be called with a view and a
103
- position, and should return a boolean.
104
- */
105
- function dropCursor() {
106
- let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
107
- return new Plugin({
108
- view(editorView) {
109
- return new DropCursorView(editorView, options);
110
- }
111
- });
112
- }
113
- class DropCursorView {
114
- constructor(editorView, options) {
115
- var _a;
116
- this.editorView = editorView;
117
- this.cursorPos = null;
118
- this.element = null;
119
- this.timeout = -1;
120
- this.width = (_a = options.width) !== null && _a !== void 0 ? _a : 1;
121
- this.color = options.color === false ? undefined : options.color || "black";
122
- this.class = options.class;
123
- this.handlers = ["dragover", "dragend", "drop", "dragleave"].map(name => {
124
- let handler = e => {
125
- this[name](e);
126
- };
127
- editorView.dom.addEventListener(name, handler);
128
- return {
129
- name,
130
- handler
131
- };
132
- });
133
- }
134
- destroy() {
135
- this.handlers.forEach(_ref => {
136
- let {
137
- name,
138
- handler
139
- } = _ref;
140
- return this.editorView.dom.removeEventListener(name, handler);
141
- });
142
- }
143
- update(editorView, prevState) {
144
- if (this.cursorPos != null && prevState.doc != editorView.state.doc) {
145
- if (this.cursorPos > editorView.state.doc.content.size) this.setCursor(null);else this.updateOverlay();
146
- }
147
- }
148
- setCursor(pos) {
149
- if (pos == this.cursorPos) return;
150
- this.cursorPos = pos;
151
- if (pos == null) {
152
- this.element.parentNode.removeChild(this.element);
153
- this.element = null;
154
- } else {
155
- this.updateOverlay();
156
- }
157
- }
158
- updateOverlay() {
159
- let $pos = this.editorView.state.doc.resolve(this.cursorPos);
160
- let isBlock = !$pos.parent.inlineContent,
161
- rect;
162
- if (isBlock) {
163
- let before = $pos.nodeBefore,
164
- after = $pos.nodeAfter;
165
- if (before || after) {
166
- let node = this.editorView.nodeDOM(this.cursorPos - (before ? before.nodeSize : 0));
167
- if (node) {
168
- let nodeRect = node.getBoundingClientRect();
169
- let top = before ? nodeRect.bottom : nodeRect.top;
170
- if (before && after) top = (top + this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top) / 2;
171
- rect = {
172
- left: nodeRect.left,
173
- right: nodeRect.right,
174
- top: top - this.width / 2,
175
- bottom: top + this.width / 2
176
- };
177
- }
178
- }
179
- }
180
- if (!rect) {
181
- let coords = this.editorView.coordsAtPos(this.cursorPos);
182
- rect = {
183
- left: coords.left - this.width / 2,
184
- right: coords.left + this.width / 2,
185
- top: coords.top,
186
- bottom: coords.bottom
187
- };
188
- }
189
- let parent = this.editorView.dom.offsetParent;
190
- if (!this.element) {
191
- this.element = parent.appendChild(document.createElement("div"));
192
- if (this.class) this.element.className = this.class;
193
- this.element.style.cssText = "position: absolute; z-index: 50; pointer-events: none;";
194
- if (this.color) {
195
- this.element.style.backgroundColor = this.color;
196
- }
197
- }
198
- this.element.classList.toggle("prosemirror-dropcursor-block", isBlock);
199
- this.element.classList.toggle("prosemirror-dropcursor-inline", !isBlock);
200
- let parentLeft, parentTop;
201
- if (!parent || parent == document.body && getComputedStyle(parent).position == "static") {
202
- parentLeft = -pageXOffset;
203
- parentTop = -pageYOffset;
204
- } else {
205
- let rect = parent.getBoundingClientRect();
206
- parentLeft = rect.left - parent.scrollLeft;
207
- parentTop = rect.top - parent.scrollTop;
208
- }
209
- this.element.style.left = rect.left - parentLeft + "px";
210
- this.element.style.top = rect.top - parentTop + "px";
211
- this.element.style.width = rect.right - rect.left + "px";
212
- this.element.style.height = rect.bottom - rect.top + "px";
213
- }
214
- scheduleRemoval(timeout) {
215
- clearTimeout(this.timeout);
216
- this.timeout = setTimeout(() => this.setCursor(null), timeout);
217
- }
218
- dragover(event) {
219
- if (!this.editorView.editable) return;
220
- let pos = this.editorView.posAtCoords({
221
- left: event.clientX,
222
- top: event.clientY
223
- });
224
- let node = pos && pos.inside >= 0 && this.editorView.state.doc.nodeAt(pos.inside);
225
- let disableDropCursor = node && node.type.spec.disableDropCursor;
226
- let disabled = typeof disableDropCursor == "function" ? disableDropCursor(this.editorView, pos, event) : disableDropCursor;
227
- if (pos && !disabled) {
228
- let target = pos.pos;
229
- if (this.editorView.dragging && this.editorView.dragging.slice) {
230
- let point = dropPoint(this.editorView.state.doc, target, this.editorView.dragging.slice);
231
- if (point != null) target = point;
232
- }
233
- this.setCursor(target);
234
- this.scheduleRemoval(5000);
235
- }
236
- }
237
- dragend() {
238
- this.scheduleRemoval(20);
239
- }
240
- drop() {
241
- this.scheduleRemoval(20);
242
- }
243
- dragleave(event) {
244
- if (event.target == this.editorView.dom || !this.editorView.dom.contains(event.relatedTarget)) this.setCursor(null);
245
- }
246
- }
247
-
248
- const Dropcursor = Extension.create({
249
- name: 'dropCursor',
250
- addOptions() {
251
- return {
252
- color: 'currentColor',
253
- width: 1,
254
- class: undefined
255
- };
256
- },
257
- addProseMirrorPlugins() {
258
- return [dropCursor(this.options)];
259
- }
260
- });
261
-
262
- /**
263
- Gap cursor selections are represented using this class. Its
264
- `$anchor` and `$head` properties both point at the cursor position.
265
- */
266
- class GapCursor extends Selection {
267
- /**
268
- Create a gap cursor.
269
- */
270
- constructor($pos) {
271
- super($pos, $pos);
272
- }
273
- map(doc, mapping) {
274
- let $pos = doc.resolve(mapping.map(this.head));
275
- return GapCursor.valid($pos) ? new GapCursor($pos) : Selection.near($pos);
276
- }
277
- content() {
278
- return Slice.empty;
279
- }
280
- eq(other) {
281
- return other instanceof GapCursor && other.head == this.head;
282
- }
283
- toJSON() {
284
- return {
285
- type: "gapcursor",
286
- pos: this.head
287
- };
288
- }
289
- /**
290
- @internal
291
- */
292
- static fromJSON(doc, json) {
293
- if (typeof json.pos != "number") throw new RangeError("Invalid input for GapCursor.fromJSON");
294
- return new GapCursor(doc.resolve(json.pos));
295
- }
296
- /**
297
- @internal
298
- */
299
- getBookmark() {
300
- return new GapBookmark(this.anchor);
301
- }
302
- /**
303
- @internal
304
- */
305
- static valid($pos) {
306
- let parent = $pos.parent;
307
- if (parent.isTextblock || !closedBefore($pos) || !closedAfter($pos)) return false;
308
- let override = parent.type.spec.allowGapCursor;
309
- if (override != null) return override;
310
- let deflt = parent.contentMatchAt($pos.index()).defaultType;
311
- return deflt && deflt.isTextblock;
312
- }
313
- /**
314
- @internal
315
- */
316
- static findGapCursorFrom($pos, dir) {
317
- let mustMove = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
318
- search: for (;;) {
319
- if (!mustMove && GapCursor.valid($pos)) return $pos;
320
- let pos = $pos.pos,
321
- next = null;
322
- // Scan up from this position
323
- for (let d = $pos.depth;; d--) {
324
- let parent = $pos.node(d);
325
- if (dir > 0 ? $pos.indexAfter(d) < parent.childCount : $pos.index(d) > 0) {
326
- next = parent.child(dir > 0 ? $pos.indexAfter(d) : $pos.index(d) - 1);
327
- break;
328
- } else if (d == 0) {
329
- return null;
330
- }
331
- pos += dir;
332
- let $cur = $pos.doc.resolve(pos);
333
- if (GapCursor.valid($cur)) return $cur;
334
- }
335
- // And then down into the next node
336
- for (;;) {
337
- let inside = dir > 0 ? next.firstChild : next.lastChild;
338
- if (!inside) {
339
- if (next.isAtom && !next.isText && !NodeSelection.isSelectable(next)) {
340
- $pos = $pos.doc.resolve(pos + next.nodeSize * dir);
341
- mustMove = false;
342
- continue search;
343
- }
344
- break;
345
- }
346
- next = inside;
347
- pos += dir;
348
- let $cur = $pos.doc.resolve(pos);
349
- if (GapCursor.valid($cur)) return $cur;
350
- }
351
- return null;
352
- }
353
- }
354
- }
355
- GapCursor.prototype.visible = false;
356
- GapCursor.findFrom = GapCursor.findGapCursorFrom;
357
- Selection.jsonID("gapcursor", GapCursor);
358
- class GapBookmark {
359
- constructor(pos) {
360
- this.pos = pos;
361
- }
362
- map(mapping) {
363
- return new GapBookmark(mapping.map(this.pos));
364
- }
365
- resolve(doc) {
366
- let $pos = doc.resolve(this.pos);
367
- return GapCursor.valid($pos) ? new GapCursor($pos) : Selection.near($pos);
368
- }
369
- }
370
- function closedBefore($pos) {
371
- for (let d = $pos.depth; d >= 0; d--) {
372
- let index = $pos.index(d),
373
- parent = $pos.node(d);
374
- // At the start of this parent, look at next one
375
- if (index == 0) {
376
- if (parent.type.spec.isolating) return true;
377
- continue;
378
- }
379
- // See if the node before (or its first ancestor) is closed
380
- for (let before = parent.child(index - 1);; before = before.lastChild) {
381
- if (before.childCount == 0 && !before.inlineContent || before.isAtom || before.type.spec.isolating) return true;
382
- if (before.inlineContent) return false;
383
- }
384
- }
385
- // Hit start of document
386
- return true;
387
- }
388
- function closedAfter($pos) {
389
- for (let d = $pos.depth; d >= 0; d--) {
390
- let index = $pos.indexAfter(d),
391
- parent = $pos.node(d);
392
- if (index == parent.childCount) {
393
- if (parent.type.spec.isolating) return true;
394
- continue;
395
- }
396
- for (let after = parent.child(index);; after = after.firstChild) {
397
- if (after.childCount == 0 && !after.inlineContent || after.isAtom || after.type.spec.isolating) return true;
398
- if (after.inlineContent) return false;
399
- }
400
- }
401
- return true;
402
- }
403
-
404
- /**
405
- Create a gap cursor plugin. When enabled, this will capture clicks
406
- near and arrow-key-motion past places that don't have a normally
407
- selectable position nearby, and create a gap cursor selection for
408
- them. The cursor is drawn as an element with class
409
- `ProseMirror-gapcursor`. You can either include
410
- `style/gapcursor.css` from the package's directory or add your own
411
- styles to make it visible.
412
- */
413
- function gapCursor() {
414
- return new Plugin({
415
- props: {
416
- decorations: drawGapCursor,
417
- createSelectionBetween(_view, $anchor, $head) {
418
- return $anchor.pos == $head.pos && GapCursor.valid($head) ? new GapCursor($head) : null;
419
- },
420
- handleClick,
421
- handleKeyDown,
422
- handleDOMEvents: {
423
- beforeinput: beforeinput
424
- }
425
- }
426
- });
427
- }
428
- const handleKeyDown = keydownHandler({
429
- "ArrowLeft": arrow("horiz", -1),
430
- "ArrowRight": arrow("horiz", 1),
431
- "ArrowUp": arrow("vert", -1),
432
- "ArrowDown": arrow("vert", 1)
433
- });
434
- function arrow(axis, dir) {
435
- const dirStr = axis == "vert" ? dir > 0 ? "down" : "up" : dir > 0 ? "right" : "left";
436
- return function (state, dispatch, view) {
437
- let sel = state.selection;
438
- let $start = dir > 0 ? sel.$to : sel.$from,
439
- mustMove = sel.empty;
440
- if (sel instanceof TextSelection) {
441
- if (!view.endOfTextblock(dirStr) || $start.depth == 0) return false;
442
- mustMove = false;
443
- $start = state.doc.resolve(dir > 0 ? $start.after() : $start.before());
444
- }
445
- let $found = GapCursor.findGapCursorFrom($start, dir, mustMove);
446
- if (!$found) return false;
447
- if (dispatch) dispatch(state.tr.setSelection(new GapCursor($found)));
448
- return true;
449
- };
450
- }
451
- function handleClick(view, pos, event) {
452
- if (!view || !view.editable) return false;
453
- let $pos = view.state.doc.resolve(pos);
454
- if (!GapCursor.valid($pos)) return false;
455
- let clickPos = view.posAtCoords({
456
- left: event.clientX,
457
- top: event.clientY
458
- });
459
- if (clickPos && clickPos.inside > -1 && NodeSelection.isSelectable(view.state.doc.nodeAt(clickPos.inside))) return false;
460
- view.dispatch(view.state.tr.setSelection(new GapCursor($pos)));
461
- return true;
462
- }
463
- // This is a hack that, when a composition starts while a gap cursor
464
- // is active, quickly creates an inline context for the composition to
465
- // happen in, to avoid it being aborted by the DOM selection being
466
- // moved into a valid position.
467
- function beforeinput(view, event) {
468
- if (event.inputType != "insertCompositionText" || !(view.state.selection instanceof GapCursor)) return false;
469
- let {
470
- $from
471
- } = view.state.selection;
472
- let insert = $from.parent.contentMatchAt($from.index()).findWrapping(view.state.schema.nodes.text);
473
- if (!insert) return false;
474
- let frag = Fragment.empty;
475
- for (let i = insert.length - 1; i >= 0; i--) frag = Fragment.from(insert[i].createAndFill(null, frag));
476
- let tr = view.state.tr.replace($from.pos, $from.pos, new Slice(frag, 0, 0));
477
- tr.setSelection(TextSelection.near(tr.doc.resolve($from.pos + 1)));
478
- view.dispatch(tr);
479
- return false;
480
- }
481
- function drawGapCursor(state) {
482
- if (!(state.selection instanceof GapCursor)) return null;
483
- let node = document.createElement("div");
484
- node.className = "ProseMirror-gapcursor";
485
- return DecorationSet.create(state.doc, [Decoration.widget(state.selection.head, node, {
486
- key: "gapcursor"
487
- })]);
488
- }
489
-
490
- const Gapcursor = Extension.create({
491
- name: 'gapCursor',
492
- addProseMirrorPlugins() {
493
- return [gapCursor()];
494
- },
495
- extendNodeSchema(extension) {
496
- var _a;
497
- const context = {
498
- name: extension.name,
499
- options: extension.options,
500
- storage: extension.storage
501
- };
502
- return {
503
- allowGapCursor: (_a = callOrReturn(getExtensionField(extension, 'allowGapCursor', context))) !== null && _a !== void 0 ? _a : null
504
- };
505
- }
506
- });
507
-
508
- const Heading = Node.create({
509
- name: 'heading',
510
- addOptions() {
511
- return {
512
- levels: [1, 2, 3, 4, 5, 6],
513
- HTMLAttributes: {}
514
- };
515
- },
516
- content: 'inline*',
517
- group: 'block',
518
- defining: true,
519
- addAttributes() {
520
- return {
521
- level: {
522
- default: 1,
523
- rendered: false
524
- }
525
- };
526
- },
527
- parseHTML() {
528
- return this.options.levels.map(level => ({
529
- tag: `h${level}`,
530
- attrs: {
531
- level
532
- }
533
- }));
534
- },
535
- renderHTML(_ref) {
536
- let {
537
- node,
538
- HTMLAttributes
539
- } = _ref;
540
- const hasLevel = this.options.levels.includes(node.attrs.level);
541
- const level = hasLevel ? node.attrs.level : this.options.levels[0];
542
- return [`h${level}`, mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
543
- },
544
- addCommands() {
545
- return {
546
- setHeading: attributes => _ref2 => {
547
- let {
548
- commands
549
- } = _ref2;
550
- if (!this.options.levels.includes(attributes.level)) {
551
- return false;
552
- }
553
- return commands.setNode(this.name, attributes);
554
- },
555
- toggleHeading: attributes => _ref3 => {
556
- let {
557
- commands
558
- } = _ref3;
559
- if (!this.options.levels.includes(attributes.level)) {
560
- return false;
561
- }
562
- return commands.toggleNode(this.name, 'paragraph', attributes);
563
- }
564
- };
565
- },
566
- addKeyboardShortcuts() {
567
- return this.options.levels.reduce((items, level) => ({
568
- ...items,
569
- ...{
570
- [`Mod-Alt-${level}`]: () => this.editor.commands.toggleHeading({
571
- level
572
- })
573
- }
574
- }), {});
575
- },
576
- addInputRules() {
577
- return this.options.levels.map(level => {
578
- return textblockTypeInputRule({
579
- find: new RegExp(`^(#{1,${level}})\\s$`),
580
- type: this.type,
581
- getAttributes: {
582
- level
583
- }
584
- });
585
- });
586
- }
587
- });
588
-
589
- var GOOD_LEAF_SIZE = 200;
590
-
591
- // :: class<T> A rope sequence is a persistent sequence data structure
592
- // that supports appending, prepending, and slicing without doing a
593
- // full copy. It is represented as a mostly-balanced tree.
594
- var RopeSequence = function RopeSequence() {};
595
- RopeSequence.prototype.append = function append(other) {
596
- if (!other.length) {
597
- return this;
598
- }
599
- other = RopeSequence.from(other);
600
- return !this.length && other || other.length < GOOD_LEAF_SIZE && this.leafAppend(other) || this.length < GOOD_LEAF_SIZE && other.leafPrepend(this) || this.appendInner(other);
601
- };
602
-
603
- // :: (union<[T], RopeSequence<T>>) → RopeSequence<T>
604
- // Prepend an array or other rope to this one, returning a new rope.
605
- RopeSequence.prototype.prepend = function prepend(other) {
606
- if (!other.length) {
607
- return this;
608
- }
609
- return RopeSequence.from(other).append(this);
610
- };
611
- RopeSequence.prototype.appendInner = function appendInner(other) {
612
- return new Append(this, other);
613
- };
614
-
615
- // :: (?number, ?number) → RopeSequence<T>
616
- // Create a rope repesenting a sub-sequence of this rope.
617
- RopeSequence.prototype.slice = function slice(from, to) {
618
- if (from === void 0) from = 0;
619
- if (to === void 0) to = this.length;
620
- if (from >= to) {
621
- return RopeSequence.empty;
622
- }
623
- return this.sliceInner(Math.max(0, from), Math.min(this.length, to));
624
- };
625
-
626
- // :: (number) → T
627
- // Retrieve the element at the given position from this rope.
628
- RopeSequence.prototype.get = function get(i) {
629
- if (i < 0 || i >= this.length) {
630
- return undefined;
631
- }
632
- return this.getInner(i);
633
- };
634
-
635
- // :: ((element: T, index: number) → ?bool, ?number, ?number)
636
- // Call the given function for each element between the given
637
- // indices. This tends to be more efficient than looping over the
638
- // indices and calling `get`, because it doesn't have to descend the
639
- // tree for every element.
640
- RopeSequence.prototype.forEach = function forEach(f, from, to) {
641
- if (from === void 0) from = 0;
642
- if (to === void 0) to = this.length;
643
- if (from <= to) {
644
- this.forEachInner(f, from, to, 0);
645
- } else {
646
- this.forEachInvertedInner(f, from, to, 0);
647
- }
648
- };
649
-
650
- // :: ((element: T, index: number) → U, ?number, ?number) → [U]
651
- // Map the given functions over the elements of the rope, producing
652
- // a flat array.
653
- RopeSequence.prototype.map = function map(f, from, to) {
654
- if (from === void 0) from = 0;
655
- if (to === void 0) to = this.length;
656
- var result = [];
657
- this.forEach(function (elt, i) {
658
- return result.push(f(elt, i));
659
- }, from, to);
660
- return result;
661
- };
662
-
663
- // :: (?union<[T], RopeSequence<T>>) → RopeSequence<T>
664
- // Create a rope representing the given array, or return the rope
665
- // itself if a rope was given.
666
- RopeSequence.from = function from(values) {
667
- if (values instanceof RopeSequence) {
668
- return values;
669
- }
670
- return values && values.length ? new Leaf(values) : RopeSequence.empty;
671
- };
672
- var Leaf = /*@__PURE__*/function (RopeSequence) {
673
- function Leaf(values) {
674
- RopeSequence.call(this);
675
- this.values = values;
676
- }
677
- if (RopeSequence) Leaf.__proto__ = RopeSequence;
678
- Leaf.prototype = Object.create(RopeSequence && RopeSequence.prototype);
679
- Leaf.prototype.constructor = Leaf;
680
- var prototypeAccessors = {
681
- length: {
682
- configurable: true
683
- },
684
- depth: {
685
- configurable: true
686
- }
687
- };
688
- Leaf.prototype.flatten = function flatten() {
689
- return this.values;
690
- };
691
- Leaf.prototype.sliceInner = function sliceInner(from, to) {
692
- if (from == 0 && to == this.length) {
693
- return this;
694
- }
695
- return new Leaf(this.values.slice(from, to));
696
- };
697
- Leaf.prototype.getInner = function getInner(i) {
698
- return this.values[i];
699
- };
700
- Leaf.prototype.forEachInner = function forEachInner(f, from, to, start) {
701
- for (var i = from; i < to; i++) {
702
- if (f(this.values[i], start + i) === false) {
703
- return false;
704
- }
705
- }
706
- };
707
- Leaf.prototype.forEachInvertedInner = function forEachInvertedInner(f, from, to, start) {
708
- for (var i = from - 1; i >= to; i--) {
709
- if (f(this.values[i], start + i) === false) {
710
- return false;
711
- }
712
- }
713
- };
714
- Leaf.prototype.leafAppend = function leafAppend(other) {
715
- if (this.length + other.length <= GOOD_LEAF_SIZE) {
716
- return new Leaf(this.values.concat(other.flatten()));
717
- }
718
- };
719
- Leaf.prototype.leafPrepend = function leafPrepend(other) {
720
- if (this.length + other.length <= GOOD_LEAF_SIZE) {
721
- return new Leaf(other.flatten().concat(this.values));
722
- }
723
- };
724
- prototypeAccessors.length.get = function () {
725
- return this.values.length;
726
- };
727
- prototypeAccessors.depth.get = function () {
728
- return 0;
729
- };
730
- Object.defineProperties(Leaf.prototype, prototypeAccessors);
731
- return Leaf;
732
- }(RopeSequence);
733
-
734
- // :: RopeSequence
735
- // The empty rope sequence.
736
- RopeSequence.empty = new Leaf([]);
737
- var Append = /*@__PURE__*/function (RopeSequence) {
738
- function Append(left, right) {
739
- RopeSequence.call(this);
740
- this.left = left;
741
- this.right = right;
742
- this.length = left.length + right.length;
743
- this.depth = Math.max(left.depth, right.depth) + 1;
744
- }
745
- if (RopeSequence) Append.__proto__ = RopeSequence;
746
- Append.prototype = Object.create(RopeSequence && RopeSequence.prototype);
747
- Append.prototype.constructor = Append;
748
- Append.prototype.flatten = function flatten() {
749
- return this.left.flatten().concat(this.right.flatten());
750
- };
751
- Append.prototype.getInner = function getInner(i) {
752
- return i < this.left.length ? this.left.get(i) : this.right.get(i - this.left.length);
753
- };
754
- Append.prototype.forEachInner = function forEachInner(f, from, to, start) {
755
- var leftLen = this.left.length;
756
- if (from < leftLen && this.left.forEachInner(f, from, Math.min(to, leftLen), start) === false) {
757
- return false;
758
- }
759
- if (to > leftLen && this.right.forEachInner(f, Math.max(from - leftLen, 0), Math.min(this.length, to) - leftLen, start + leftLen) === false) {
760
- return false;
761
- }
762
- };
763
- Append.prototype.forEachInvertedInner = function forEachInvertedInner(f, from, to, start) {
764
- var leftLen = this.left.length;
765
- if (from > leftLen && this.right.forEachInvertedInner(f, from - leftLen, Math.max(to, leftLen) - leftLen, start + leftLen) === false) {
766
- return false;
767
- }
768
- if (to < leftLen && this.left.forEachInvertedInner(f, Math.min(from, leftLen), to, start) === false) {
769
- return false;
770
- }
771
- };
772
- Append.prototype.sliceInner = function sliceInner(from, to) {
773
- if (from == 0 && to == this.length) {
774
- return this;
775
- }
776
- var leftLen = this.left.length;
777
- if (to <= leftLen) {
778
- return this.left.slice(from, to);
779
- }
780
- if (from >= leftLen) {
781
- return this.right.slice(from - leftLen, to - leftLen);
782
- }
783
- return this.left.slice(from, leftLen).append(this.right.slice(0, to - leftLen));
784
- };
785
- Append.prototype.leafAppend = function leafAppend(other) {
786
- var inner = this.right.leafAppend(other);
787
- if (inner) {
788
- return new Append(this.left, inner);
789
- }
790
- };
791
- Append.prototype.leafPrepend = function leafPrepend(other) {
792
- var inner = this.left.leafPrepend(other);
793
- if (inner) {
794
- return new Append(inner, this.right);
795
- }
796
- };
797
- Append.prototype.appendInner = function appendInner(other) {
798
- if (this.left.depth >= Math.max(this.right.depth, other.depth) + 1) {
799
- return new Append(this.left, new Append(this.right, other));
800
- }
801
- return new Append(this, other);
802
- };
803
- return Append;
804
- }(RopeSequence);
805
- var ropeSequence = RopeSequence;
806
-
807
- // ProseMirror's history isn't simply a way to roll back to a previous
808
- // state, because ProseMirror supports applying changes without adding
809
- // them to the history (for example during collaboration).
810
- //
811
- // To this end, each 'Branch' (one for the undo history and one for
812
- // the redo history) keeps an array of 'Items', which can optionally
813
- // hold a step (an actual undoable change), and always hold a position
814
- // map (which is needed to move changes below them to apply to the
815
- // current document).
816
- //
817
- // An item that has both a step and a selection bookmark is the start
818
- // of an 'event' — a group of changes that will be undone or redone at
819
- // once. (It stores only the bookmark, since that way we don't have to
820
- // provide a document until the selection is actually applied, which
821
- // is useful when compressing.)
822
- // Used to schedule history compression
823
- const max_empty_items = 500;
824
- class Branch {
825
- constructor(items, eventCount) {
826
- this.items = items;
827
- this.eventCount = eventCount;
828
- }
829
- // Pop the latest event off the branch's history and apply it
830
- // to a document transform.
831
- popEvent(state, preserveItems) {
832
- if (this.eventCount == 0) return null;
833
- let end = this.items.length;
834
- for (;; end--) {
835
- let next = this.items.get(end - 1);
836
- if (next.selection) {
837
- --end;
838
- break;
839
- }
840
- }
841
- let remap, mapFrom;
842
- if (preserveItems) {
843
- remap = this.remapping(end, this.items.length);
844
- mapFrom = remap.maps.length;
845
- }
846
- let transform = state.tr;
847
- let selection, remaining;
848
- let addAfter = [],
849
- addBefore = [];
850
- this.items.forEach((item, i) => {
851
- if (!item.step) {
852
- if (!remap) {
853
- remap = this.remapping(end, i + 1);
854
- mapFrom = remap.maps.length;
855
- }
856
- mapFrom--;
857
- addBefore.push(item);
858
- return;
859
- }
860
- if (remap) {
861
- addBefore.push(new Item(item.map));
862
- let step = item.step.map(remap.slice(mapFrom)),
863
- map;
864
- if (step && transform.maybeStep(step).doc) {
865
- map = transform.mapping.maps[transform.mapping.maps.length - 1];
866
- addAfter.push(new Item(map, undefined, undefined, addAfter.length + addBefore.length));
867
- }
868
- mapFrom--;
869
- if (map) remap.appendMap(map, mapFrom);
870
- } else {
871
- transform.maybeStep(item.step);
872
- }
873
- if (item.selection) {
874
- selection = remap ? item.selection.map(remap.slice(mapFrom)) : item.selection;
875
- remaining = new Branch(this.items.slice(0, end).append(addBefore.reverse().concat(addAfter)), this.eventCount - 1);
876
- return false;
877
- }
878
- }, this.items.length, 0);
879
- return {
880
- remaining: remaining,
881
- transform,
882
- selection: selection
883
- };
884
- }
885
- // Create a new branch with the given transform added.
886
- addTransform(transform, selection, histOptions, preserveItems) {
887
- let newItems = [],
888
- eventCount = this.eventCount;
889
- let oldItems = this.items,
890
- lastItem = !preserveItems && oldItems.length ? oldItems.get(oldItems.length - 1) : null;
891
- for (let i = 0; i < transform.steps.length; i++) {
892
- let step = transform.steps[i].invert(transform.docs[i]);
893
- let item = new Item(transform.mapping.maps[i], step, selection),
894
- merged;
895
- if (merged = lastItem && lastItem.merge(item)) {
896
- item = merged;
897
- if (i) newItems.pop();else oldItems = oldItems.slice(0, oldItems.length - 1);
898
- }
899
- newItems.push(item);
900
- if (selection) {
901
- eventCount++;
902
- selection = undefined;
903
- }
904
- if (!preserveItems) lastItem = item;
905
- }
906
- let overflow = eventCount - histOptions.depth;
907
- if (overflow > DEPTH_OVERFLOW) {
908
- oldItems = cutOffEvents(oldItems, overflow);
909
- eventCount -= overflow;
910
- }
911
- return new Branch(oldItems.append(newItems), eventCount);
912
- }
913
- remapping(from, to) {
914
- let maps = new Mapping();
915
- this.items.forEach((item, i) => {
916
- let mirrorPos = item.mirrorOffset != null && i - item.mirrorOffset >= from ? maps.maps.length - item.mirrorOffset : undefined;
917
- maps.appendMap(item.map, mirrorPos);
918
- }, from, to);
919
- return maps;
920
- }
921
- addMaps(array) {
922
- if (this.eventCount == 0) return this;
923
- return new Branch(this.items.append(array.map(map => new Item(map))), this.eventCount);
924
- }
925
- // When the collab module receives remote changes, the history has
926
- // to know about those, so that it can adjust the steps that were
927
- // rebased on top of the remote changes, and include the position
928
- // maps for the remote changes in its array of items.
929
- rebased(rebasedTransform, rebasedCount) {
930
- if (!this.eventCount) return this;
931
- let rebasedItems = [],
932
- start = Math.max(0, this.items.length - rebasedCount);
933
- let mapping = rebasedTransform.mapping;
934
- let newUntil = rebasedTransform.steps.length;
935
- let eventCount = this.eventCount;
936
- this.items.forEach(item => {
937
- if (item.selection) eventCount--;
938
- }, start);
939
- let iRebased = rebasedCount;
940
- this.items.forEach(item => {
941
- let pos = mapping.getMirror(--iRebased);
942
- if (pos == null) return;
943
- newUntil = Math.min(newUntil, pos);
944
- let map = mapping.maps[pos];
945
- if (item.step) {
946
- let step = rebasedTransform.steps[pos].invert(rebasedTransform.docs[pos]);
947
- let selection = item.selection && item.selection.map(mapping.slice(iRebased + 1, pos));
948
- if (selection) eventCount++;
949
- rebasedItems.push(new Item(map, step, selection));
950
- } else {
951
- rebasedItems.push(new Item(map));
952
- }
953
- }, start);
954
- let newMaps = [];
955
- for (let i = rebasedCount; i < newUntil; i++) newMaps.push(new Item(mapping.maps[i]));
956
- let items = this.items.slice(0, start).append(newMaps).append(rebasedItems);
957
- let branch = new Branch(items, eventCount);
958
- if (branch.emptyItemCount() > max_empty_items) branch = branch.compress(this.items.length - rebasedItems.length);
959
- return branch;
960
- }
961
- emptyItemCount() {
962
- let count = 0;
963
- this.items.forEach(item => {
964
- if (!item.step) count++;
965
- });
966
- return count;
967
- }
968
- // Compressing a branch means rewriting it to push the air (map-only
969
- // items) out. During collaboration, these naturally accumulate
970
- // because each remote change adds one. The `upto` argument is used
971
- // to ensure that only the items below a given level are compressed,
972
- // because `rebased` relies on a clean, untouched set of items in
973
- // order to associate old items with rebased steps.
974
- compress() {
975
- let upto = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.items.length;
976
- let remap = this.remapping(0, upto),
977
- mapFrom = remap.maps.length;
978
- let items = [],
979
- events = 0;
980
- this.items.forEach((item, i) => {
981
- if (i >= upto) {
982
- items.push(item);
983
- if (item.selection) events++;
984
- } else if (item.step) {
985
- let step = item.step.map(remap.slice(mapFrom)),
986
- map = step && step.getMap();
987
- mapFrom--;
988
- if (map) remap.appendMap(map, mapFrom);
989
- if (step) {
990
- let selection = item.selection && item.selection.map(remap.slice(mapFrom));
991
- if (selection) events++;
992
- let newItem = new Item(map.invert(), step, selection),
993
- merged,
994
- last = items.length - 1;
995
- if (merged = items.length && items[last].merge(newItem)) items[last] = merged;else items.push(newItem);
996
- }
997
- } else if (item.map) {
998
- mapFrom--;
999
- }
1000
- }, this.items.length, 0);
1001
- return new Branch(ropeSequence.from(items.reverse()), events);
1002
- }
1003
- }
1004
- Branch.empty = new Branch(ropeSequence.empty, 0);
1005
- function cutOffEvents(items, n) {
1006
- let cutPoint;
1007
- items.forEach((item, i) => {
1008
- if (item.selection && n-- == 0) {
1009
- cutPoint = i;
1010
- return false;
1011
- }
1012
- });
1013
- return items.slice(cutPoint);
1014
- }
1015
- class Item {
1016
- constructor(
1017
- // The (forward) step map for this item.
1018
- map,
1019
- // The inverted step
1020
- step,
1021
- // If this is non-null, this item is the start of a group, and
1022
- // this selection is the starting selection for the group (the one
1023
- // that was active before the first step was applied)
1024
- selection,
1025
- // If this item is the inverse of a previous mapping on the stack,
1026
- // this points at the inverse's offset
1027
- mirrorOffset) {
1028
- this.map = map;
1029
- this.step = step;
1030
- this.selection = selection;
1031
- this.mirrorOffset = mirrorOffset;
1032
- }
1033
- merge(other) {
1034
- if (this.step && other.step && !other.selection) {
1035
- let step = other.step.merge(this.step);
1036
- if (step) return new Item(step.getMap().invert(), step, this.selection);
1037
- }
1038
- }
1039
- }
1040
- // The value of the state field that tracks undo/redo history for that
1041
- // state. Will be stored in the plugin state when the history plugin
1042
- // is active.
1043
- class HistoryState {
1044
- constructor(done, undone, prevRanges, prevTime) {
1045
- this.done = done;
1046
- this.undone = undone;
1047
- this.prevRanges = prevRanges;
1048
- this.prevTime = prevTime;
1049
- }
1050
- }
1051
- const DEPTH_OVERFLOW = 20;
1052
- // Record a transformation in undo history.
1053
- function applyTransaction(history, state, tr, options) {
1054
- let historyTr = tr.getMeta(historyKey),
1055
- rebased;
1056
- if (historyTr) return historyTr.historyState;
1057
- if (tr.getMeta(closeHistoryKey)) history = new HistoryState(history.done, history.undone, null, 0);
1058
- let appended = tr.getMeta("appendedTransaction");
1059
- if (tr.steps.length == 0) {
1060
- return history;
1061
- } else if (appended && appended.getMeta(historyKey)) {
1062
- if (appended.getMeta(historyKey).redo) return new HistoryState(history.done.addTransform(tr, undefined, options, mustPreserveItems(state)), history.undone, rangesFor(tr.mapping.maps[tr.steps.length - 1]), history.prevTime);else return new HistoryState(history.done, history.undone.addTransform(tr, undefined, options, mustPreserveItems(state)), null, history.prevTime);
1063
- } else if (tr.getMeta("addToHistory") !== false && !(appended && appended.getMeta("addToHistory") === false)) {
1064
- // Group transforms that occur in quick succession into one event.
1065
- let newGroup = history.prevTime == 0 || !appended && (history.prevTime < (tr.time || 0) - options.newGroupDelay || !isAdjacentTo(tr, history.prevRanges));
1066
- let prevRanges = appended ? mapRanges(history.prevRanges, tr.mapping) : rangesFor(tr.mapping.maps[tr.steps.length - 1]);
1067
- return new HistoryState(history.done.addTransform(tr, newGroup ? state.selection.getBookmark() : undefined, options, mustPreserveItems(state)), Branch.empty, prevRanges, tr.time);
1068
- } else if (rebased = tr.getMeta("rebased")) {
1069
- // Used by the collab module to tell the history that some of its
1070
- // content has been rebased.
1071
- return new HistoryState(history.done.rebased(tr, rebased), history.undone.rebased(tr, rebased), mapRanges(history.prevRanges, tr.mapping), history.prevTime);
1072
- } else {
1073
- return new HistoryState(history.done.addMaps(tr.mapping.maps), history.undone.addMaps(tr.mapping.maps), mapRanges(history.prevRanges, tr.mapping), history.prevTime);
1074
- }
1075
- }
1076
- function isAdjacentTo(transform, prevRanges) {
1077
- if (!prevRanges) return false;
1078
- if (!transform.docChanged) return true;
1079
- let adjacent = false;
1080
- transform.mapping.maps[0].forEach((start, end) => {
1081
- for (let i = 0; i < prevRanges.length; i += 2) if (start <= prevRanges[i + 1] && end >= prevRanges[i]) adjacent = true;
1082
- });
1083
- return adjacent;
1084
- }
1085
- function rangesFor(map) {
1086
- let result = [];
1087
- map.forEach((_from, _to, from, to) => result.push(from, to));
1088
- return result;
1089
- }
1090
- function mapRanges(ranges, mapping) {
1091
- if (!ranges) return null;
1092
- let result = [];
1093
- for (let i = 0; i < ranges.length; i += 2) {
1094
- let from = mapping.map(ranges[i], 1),
1095
- to = mapping.map(ranges[i + 1], -1);
1096
- if (from <= to) result.push(from, to);
1097
- }
1098
- return result;
1099
- }
1100
- // Apply the latest event from one branch to the document and shift the event
1101
- // onto the other branch.
1102
- function histTransaction(history, state, dispatch, redo) {
1103
- let preserveItems = mustPreserveItems(state);
1104
- let histOptions = historyKey.get(state).spec.config;
1105
- let pop = (redo ? history.undone : history.done).popEvent(state, preserveItems);
1106
- if (!pop) return;
1107
- let selection = pop.selection.resolve(pop.transform.doc);
1108
- let added = (redo ? history.done : history.undone).addTransform(pop.transform, state.selection.getBookmark(), histOptions, preserveItems);
1109
- let newHist = new HistoryState(redo ? added : pop.remaining, redo ? pop.remaining : added, null, 0);
1110
- dispatch(pop.transform.setSelection(selection).setMeta(historyKey, {
1111
- redo,
1112
- historyState: newHist
1113
- }).scrollIntoView());
1114
- }
1115
- let cachedPreserveItems = false,
1116
- cachedPreserveItemsPlugins = null;
1117
- // Check whether any plugin in the given state has a
1118
- // `historyPreserveItems` property in its spec, in which case we must
1119
- // preserve steps exactly as they came in, so that they can be
1120
- // rebased.
1121
- function mustPreserveItems(state) {
1122
- let plugins = state.plugins;
1123
- if (cachedPreserveItemsPlugins != plugins) {
1124
- cachedPreserveItems = false;
1125
- cachedPreserveItemsPlugins = plugins;
1126
- for (let i = 0; i < plugins.length; i++) if (plugins[i].spec.historyPreserveItems) {
1127
- cachedPreserveItems = true;
1128
- break;
1129
- }
1130
- }
1131
- return cachedPreserveItems;
1132
- }
1133
- const historyKey = new PluginKey("history");
1134
- const closeHistoryKey = new PluginKey("closeHistory");
1135
- /**
1136
- Returns a plugin that enables the undo history for an editor. The
1137
- plugin will track undo and redo stacks, which can be used with the
1138
- [`undo`](https://prosemirror.net/docs/ref/#history.undo) and [`redo`](https://prosemirror.net/docs/ref/#history.redo) commands.
1139
-
1140
- You can set an `"addToHistory"` [metadata
1141
- property](https://prosemirror.net/docs/ref/#state.Transaction.setMeta) of `false` on a transaction
1142
- to prevent it from being rolled back by undo.
1143
- */
1144
- function history() {
1145
- let config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1146
- config = {
1147
- depth: config.depth || 100,
1148
- newGroupDelay: config.newGroupDelay || 500
1149
- };
1150
- return new Plugin({
1151
- key: historyKey,
1152
- state: {
1153
- init() {
1154
- return new HistoryState(Branch.empty, Branch.empty, null, 0);
1155
- },
1156
- apply(tr, hist, state) {
1157
- return applyTransaction(hist, state, tr, config);
1158
- }
1159
- },
1160
- config,
1161
- props: {
1162
- handleDOMEvents: {
1163
- beforeinput(view, e) {
1164
- let inputType = e.inputType;
1165
- let command = inputType == "historyUndo" ? undo : inputType == "historyRedo" ? redo : null;
1166
- if (!command) return false;
1167
- e.preventDefault();
1168
- return command(view.state, view.dispatch);
1169
- }
1170
- }
1171
- }
1172
- });
1173
- }
1174
- /**
1175
- A command function that undoes the last change, if any.
1176
- */
1177
- const undo = (state, dispatch) => {
1178
- let hist = historyKey.getState(state);
1179
- if (!hist || hist.done.eventCount == 0) return false;
1180
- if (dispatch) histTransaction(hist, state, dispatch, false);
1181
- return true;
1182
- };
1183
- /**
1184
- A command function that redoes the last undone change, if any.
1185
- */
1186
- const redo = (state, dispatch) => {
1187
- let hist = historyKey.getState(state);
1188
- if (!hist || hist.undone.eventCount == 0) return false;
1189
- if (dispatch) histTransaction(hist, state, dispatch, true);
1190
- return true;
1191
- };
1192
-
1193
- const History = Extension.create({
1194
- name: 'history',
1195
- addOptions() {
1196
- return {
1197
- depth: 100,
1198
- newGroupDelay: 500
1199
- };
1200
- },
1201
- addCommands() {
1202
- return {
1203
- undo: () => _ref => {
1204
- let {
1205
- state,
1206
- dispatch
1207
- } = _ref;
1208
- return undo(state, dispatch);
1209
- },
1210
- redo: () => _ref2 => {
1211
- let {
1212
- state,
1213
- dispatch
1214
- } = _ref2;
1215
- return redo(state, dispatch);
1216
- }
1217
- };
1218
- },
1219
- addProseMirrorPlugins() {
1220
- return [history(this.options)];
1221
- },
1222
- addKeyboardShortcuts() {
1223
- return {
1224
- 'Mod-z': () => this.editor.commands.undo(),
1225
- 'Mod-y': () => this.editor.commands.redo(),
1226
- 'Shift-Mod-z': () => this.editor.commands.redo(),
1227
- // Russian keyboard layouts
1228
- 'Mod-я': () => this.editor.commands.undo(),
1229
- 'Shift-Mod-я': () => this.editor.commands.redo()
1230
- };
1231
- }
1232
- });
1233
-
1234
- const HorizontalRule = Node.create({
1235
- name: 'horizontalRule',
1236
- addOptions() {
1237
- return {
1238
- HTMLAttributes: {}
1239
- };
1240
- },
1241
- group: 'block',
1242
- parseHTML() {
1243
- return [{
1244
- tag: 'hr'
1245
- }];
1246
- },
1247
- renderHTML(_ref) {
1248
- let {
1249
- HTMLAttributes
1250
- } = _ref;
1251
- return ['hr', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes)];
1252
- },
1253
- addCommands() {
1254
- return {
1255
- setHorizontalRule: () => _ref2 => {
1256
- let {
1257
- chain
1258
- } = _ref2;
1259
- return chain().insertContent({
1260
- type: this.name
1261
- })
1262
- // set cursor after horizontal rule
1263
- .command(_ref3 => {
1264
- let {
1265
- tr,
1266
- dispatch
1267
- } = _ref3;
1268
- var _a;
1269
- if (dispatch) {
1270
- const {
1271
- $to
1272
- } = tr.selection;
1273
- const posAfter = $to.end();
1274
- if ($to.nodeAfter) {
1275
- tr.setSelection(TextSelection.create(tr.doc, $to.pos));
1276
- } else {
1277
- // add node after horizontal rule if it’s the end of the document
1278
- const node = (_a = $to.parent.type.contentMatch.defaultType) === null || _a === void 0 ? void 0 : _a.create();
1279
- if (node) {
1280
- tr.insert(posAfter, node);
1281
- tr.setSelection(TextSelection.create(tr.doc, posAfter));
1282
- }
1283
- }
1284
- tr.scrollIntoView();
1285
- }
1286
- return true;
1287
- }).run();
1288
- }
1289
- };
1290
- },
1291
- addInputRules() {
1292
- return [nodeInputRule({
1293
- find: /^(?:---|—-|___\s|\*\*\*\s)$/,
1294
- type: this.type
1295
- })];
1296
- }
1297
- });
1298
-
1299
- const Text = Node.create({
1300
- name: 'text',
1301
- group: 'inline'
1302
- });
1303
-
1304
- const StarterKit = Extension.create({
1305
- name: 'starterKit',
1306
- addExtensions() {
1307
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
1308
- const extensions = [];
1309
- if (this.options.blockquote !== false) {
1310
- extensions.push(Blockquote.configure((_a = this.options) === null || _a === void 0 ? void 0 : _a.blockquote));
1311
- }
1312
- if (this.options.bold !== false) {
1313
- extensions.push(Bold.configure((_b = this.options) === null || _b === void 0 ? void 0 : _b.bold));
1314
- }
1315
- if (this.options.bulletList !== false) {
1316
- extensions.push(BulletList.configure((_c = this.options) === null || _c === void 0 ? void 0 : _c.bulletList));
1317
- }
1318
- if (this.options.code !== false) {
1319
- extensions.push(Code.configure((_d = this.options) === null || _d === void 0 ? void 0 : _d.code));
1320
- }
1321
- if (this.options.codeBlock !== false) {
1322
- extensions.push(CodeBlock.configure((_e = this.options) === null || _e === void 0 ? void 0 : _e.codeBlock));
1323
- }
1324
- if (this.options.document !== false) {
1325
- extensions.push(Document.configure((_f = this.options) === null || _f === void 0 ? void 0 : _f.document));
1326
- }
1327
- if (this.options.dropcursor !== false) {
1328
- extensions.push(Dropcursor.configure((_g = this.options) === null || _g === void 0 ? void 0 : _g.dropcursor));
1329
- }
1330
- if (this.options.gapcursor !== false) {
1331
- extensions.push(Gapcursor.configure((_h = this.options) === null || _h === void 0 ? void 0 : _h.gapcursor));
1332
- }
1333
- if (this.options.hardBreak !== false) {
1334
- extensions.push(HardBreak.configure((_j = this.options) === null || _j === void 0 ? void 0 : _j.hardBreak));
1335
- }
1336
- if (this.options.heading !== false) {
1337
- extensions.push(Heading.configure((_k = this.options) === null || _k === void 0 ? void 0 : _k.heading));
1338
- }
1339
- if (this.options.history !== false) {
1340
- extensions.push(History.configure((_l = this.options) === null || _l === void 0 ? void 0 : _l.history));
1341
- }
1342
- if (this.options.horizontalRule !== false) {
1343
- extensions.push(HorizontalRule.configure((_m = this.options) === null || _m === void 0 ? void 0 : _m.horizontalRule));
1344
- }
1345
- if (this.options.italic !== false) {
1346
- extensions.push(Italic.configure((_o = this.options) === null || _o === void 0 ? void 0 : _o.italic));
1347
- }
1348
- if (this.options.listItem !== false) {
1349
- extensions.push(ListItem.configure((_p = this.options) === null || _p === void 0 ? void 0 : _p.listItem));
1350
- }
1351
- if (this.options.orderedList !== false) {
1352
- extensions.push(OrderedList.configure((_q = this.options) === null || _q === void 0 ? void 0 : _q.orderedList));
1353
- }
1354
- if (this.options.paragraph !== false) {
1355
- extensions.push(Paragraph.configure((_r = this.options) === null || _r === void 0 ? void 0 : _r.paragraph));
1356
- }
1357
- if (this.options.strike !== false) {
1358
- extensions.push(Strike.configure((_s = this.options) === null || _s === void 0 ? void 0 : _s.strike));
1359
- }
1360
- if (this.options.text !== false) {
1361
- extensions.push(Text.configure((_t = this.options) === null || _t === void 0 ? void 0 : _t.text));
1362
- }
1363
- return extensions;
1364
- }
1365
- });
1366
-
1367
- const Placeholder = Extension.create({
1368
- name: 'placeholder',
1369
- addOptions() {
1370
- return {
1371
- emptyEditorClass: 'is-editor-empty',
1372
- emptyNodeClass: 'is-empty',
1373
- placeholder: 'Write something …',
1374
- showOnlyWhenEditable: true,
1375
- showOnlyCurrent: true,
1376
- includeChildren: false
1377
- };
1378
- },
1379
- addProseMirrorPlugins() {
1380
- return [new Plugin({
1381
- key: new PluginKey('placeholder'),
1382
- props: {
1383
- decorations: _ref => {
1384
- let {
1385
- doc,
1386
- selection
1387
- } = _ref;
1388
- const active = this.editor.isEditable || !this.options.showOnlyWhenEditable;
1389
- const {
1390
- anchor
1391
- } = selection;
1392
- const decorations = [];
1393
- if (!active) {
1394
- return null;
1395
- }
1396
- // only calculate isEmpty once due to its performance impacts (see issue #3360)
1397
- const emptyDocInstance = doc.type.createAndFill();
1398
- const isEditorEmpty = (emptyDocInstance === null || emptyDocInstance === void 0 ? void 0 : emptyDocInstance.sameMarkup(doc)) && emptyDocInstance.content.findDiffStart(doc.content) === null;
1399
- doc.descendants((node, pos) => {
1400
- const hasAnchor = anchor >= pos && anchor <= pos + node.nodeSize;
1401
- const isEmpty = !node.isLeaf && !node.childCount;
1402
- if ((hasAnchor || !this.options.showOnlyCurrent) && isEmpty) {
1403
- const classes = [this.options.emptyNodeClass];
1404
- if (isEditorEmpty) {
1405
- classes.push(this.options.emptyEditorClass);
1406
- }
1407
- const decoration = Decoration.node(pos, pos + node.nodeSize, {
1408
- class: classes.join(' '),
1409
- 'data-placeholder': typeof this.options.placeholder === 'function' ? this.options.placeholder({
1410
- editor: this.editor,
1411
- node,
1412
- pos,
1413
- hasAnchor
1414
- }) : this.options.placeholder
1415
- });
1416
- decorations.push(decoration);
1417
- }
1418
- return this.options.includeChildren;
1419
- });
1420
- return DecorationSet.create(doc, decorations);
1421
- }
1422
- }
1423
- })];
1424
- }
1425
- });
1426
-
1427
- var script = defineComponent({
1428
- name: 'OrRichTextEditor',
1429
- components: {
1430
- OrIconButton: script$1,
1431
- OrLabel: script$2,
1432
- OrMenuItem: script$3,
1433
- OrMenu: script$4,
1434
- OrModal: script$5,
1435
- OrInput: script$6,
1436
- OrButton: script$7
1437
- },
1438
- inheritAttrs: false,
1439
- model: {
1440
- prop: 'modelValue',
1441
- event: 'update:modelValue'
1442
- },
1443
- props: {
1444
- modelValue: {
1445
- type: String,
1446
- default: undefined
1447
- },
1448
- toolbar: {
1449
- type: Array,
1450
- default: () => []
1451
- },
1452
- description: {
1453
- type: String,
1454
- default: ''
1455
- },
1456
- placeholder: {
1457
- type: String,
1458
- default: ''
1459
- },
1460
- autofocus: {
1461
- type: Boolean,
1462
- default: false
1463
- },
1464
- format: {
1465
- type: String,
1466
- default: Formats.Markup
1467
- },
1468
- fullHeight: {
1469
- type: Boolean,
1470
- default: false
1471
- }
1472
- },
1473
- emits: ['update:modelValue', 'input', 'file-upload'],
1474
- expose: ['root'],
1475
- setup(props, context) {
1476
- // Refs
1477
- const root = ref();
1478
- let editor = null;
1479
- const editorRef = ref();
1480
- const textareaRef = ref();
1481
- const containerRef = ref();
1482
- const toolbarRef = ref();
1483
- const moreButtonRef = ref();
1484
- const moreRef = ref();
1485
- const toolbarButtonRef = ref();
1486
- const menuRef = ref();
1487
- // isActive should be set with default values for all toolbar buttons, otherwise it will not work in vue2
1488
- const isActive = ref({
1489
- bold: false,
1490
- italic: false,
1491
- underline: false,
1492
- strike: false,
1493
- bulletList: false,
1494
- orderedList: false,
1495
- link: false,
1496
- highlight: false,
1497
- redo: false,
1498
- undo: false,
1499
- codeBlock: false,
1500
- blockquote: false,
1501
- file: false,
1502
- source: false
1503
- });
1504
- const isFocused = ref(props.autofocus);
1505
- const headingLevels = [1, 2, 3, 4];
1506
- const activeHeadingLevel = ref(0);
1507
- const markdownOutput = ref('');
1508
- const isOpenLinkModal = ref(false);
1509
- const disableMarkdown = ref(false);
1510
- const text = ref('');
1511
- const link = ref('');
1512
- const countOfNotVisibleTools = ref(0);
1513
- const sourceValue = ref('');
1514
- let trap = useFocusTrap(editorRef, {
1515
- immediate: true,
1516
- fallbackFocus: '.container',
1517
- allowOutsideClick: true
1518
- });
1519
- const iconsEnum = ref({
1520
- bold: 'format_bold',
1521
- italic: 'format_italic',
1522
- underline: 'format_underlined',
1523
- strike: 'format_strikethrough',
1524
- bulletList: 'format_list_bulleted',
1525
- orderedList: 'format_list_numbered',
1526
- link: 'link',
1527
- highlight: 'highlight',
1528
- redo: 'redo',
1529
- undo: 'undo',
1530
- codeBlock: 'code_blocks',
1531
- blockquote: 'format_quote',
1532
- file: 'attach_file',
1533
- source: 'source_notes'
1534
- });
1535
- const iconTooltipsEnum = ref({
1536
- bold: 'Bold',
1537
- italic: 'Italic',
1538
- underline: 'Underline',
1539
- strike: 'Strike',
1540
- bulletList: 'Bulleted List',
1541
- orderedList: 'Numbered List',
1542
- link: 'Link',
1543
- highlight: 'Highlight',
1544
- redo: 'Redo',
1545
- undo: 'Undo',
1546
- codeBlock: 'Code Block',
1547
- blockquote: 'Quote',
1548
- file: 'File',
1549
- source: 'Source'
1550
- });
1551
- useResizeObserver(root, entries => {
1552
- var _a, _b;
1553
- const entry = entries[0];
1554
- const {
1555
- width
1556
- } = entry.contentRect;
1557
- if (containerRef.value && toolbarRef.value && toolbarLength.value) {
1558
- let lengthOfItem = 0;
1559
- lengthOfItem = ((_b = (_a = toolbarRef.value.firstElementChild) === null || _a === void 0 ? void 0 : _a.firstElementChild) === null || _b === void 0 ? void 0 : _b.offsetWidth) + 16;
1560
- const lengthOfToolbar = lengthOfItem * toolbarLength.value;
1561
- if (lengthOfToolbar >= width) {
1562
- const count = width / lengthOfItem - 2;
1563
- countOfNotVisibleTools.value = Math.round(toolbarLength.value - count);
1564
- }
1565
- }
1566
- });
1567
- onMounted(() => {
1568
- editor = new Editor({
1569
- onUpdate: _ref => {
1570
- let {
1571
- editor
1572
- } = _ref;
1573
- isFocused.value = true;
1574
- setActiveFormats();
1575
- const html = editor.getHTML();
1576
- const text = editor.getText();
1577
- if (props.format === 'markdown') {
1578
- markdownOutput.value = serialize(editor.schema, editor.getJSON());
1579
- proxyModelValue.value = markdownOutput.value;
1580
- } else {
1581
- proxyModelValue.value = text === '' ? text : html;
1582
- }
1583
- },
1584
- onCreate: _ref2 => {
1585
- let {
1586
- editor
1587
- } = _ref2;
1588
- if (props.format === 'markdown') {
1589
- const deserialized = deserialize(editor.schema, proxyModelValue.value);
1590
- editor.commands.setContent(deserialized);
1591
- } else {
1592
- editor.commands.setContent(proxyModelValue.value);
1593
- }
1594
- },
1595
- element: editorRef.value,
1596
- autofocus: props.autofocus,
1597
- enableInputRules: true,
1598
- enablePasteRules: true,
1599
- extensions: [codemirrorNode, StarterKit.configure({
1600
- heading: false,
1601
- codeBlock: false
1602
- }), Heading.configure({
1603
- levels: headingLevels
1604
- }).extend({
1605
- levels: headingLevels,
1606
- renderHTML(_ref3) {
1607
- let {
1608
- node,
1609
- HTMLAttributes
1610
- } = _ref3;
1611
- return ['h' + node.attrs.level, mergeAttributes(HTMLAttributes, {
1612
- class: `typography-headline-${node.attrs.level}`
1613
- }), 0];
1614
- }
1615
- }), Underline, Link.configure({
1616
- openOnClick: true,
1617
- linkOnPaste: true,
1618
- autolink: false,
1619
- protocols: ['ftp', 'mailto', 'http', 'https'],
1620
- validate: href => /^https?:\/\//.test(href),
1621
- HTMLAttributes: {
1622
- class: 'text-primary cursor-pointer'
1623
- }
1624
- }), Highlight, Placeholder.configure({
1625
- placeholder: props.placeholder,
1626
- emptyEditorClass: 'is-editor-empty text-outline'
1627
- })],
1628
- editorProps: {
1629
- attributes: {
1630
- class: 'flex flex-col focus:outline-none gap-xs'
1631
- }
1632
- },
1633
- parseOptions: {
1634
- preserveWhitespace: true
1635
- }
1636
- });
1637
- setActiveFormats();
1638
- trap.activate();
1639
- });
1640
- onBeforeUnmount(() => {
1641
- editor === null || editor === void 0 ? void 0 : editor.destroy();
1642
- });
1643
- onClickOutside(root, () => {
1644
- isFocused.value = false;
1645
- trap.deactivate();
1646
- });
1647
- // Computed
1648
- const proxyModelValue = computed({
1649
- get: () => {
1650
- return props.modelValue;
1651
- },
1652
- set: value => {
1653
- context.emit('input', value);
1654
- context.emit('update:modelValue', value);
1655
- }
1656
- });
1657
- const getIndexOfHeading = computed(() => {
1658
- return props.toolbar.flat().indexOf('heading');
1659
- });
1660
- const headingIcon = computed(() => {
1661
- if (activeHeadingLevel.value && isActive.value.heading) {
1662
- return `format_h${activeHeadingLevel.value}`;
1663
- }
1664
- return 'format_paragraph';
1665
- });
1666
- const toolbarLength = computed(() => {
1667
- return props.toolbar.flat().length;
1668
- });
1669
- const notVisibleTools = computed(() => {
1670
- const count = countOfNotVisibleTools.value;
1671
- const toolbar = props.toolbar.flat();
1672
- let notVisible = toolbar.slice(toolbar.length - count, toolbar.length);
1673
- props.toolbar.forEach(tools => {
1674
- if (tools.some(item => notVisible.includes(item))) {
1675
- notVisible = [...notVisible, ...tools];
1676
- }
1677
- });
1678
- return notVisible;
1679
- });
1680
- //Methods
1681
- const handleEditorClick = () => {
1682
- var _a;
1683
- setActiveFormats();
1684
- isFocused.value = true;
1685
- editor === null || editor === void 0 ? void 0 : editor.commands.focus();
1686
- activeHeadingLevel.value = ((_a = editor === null || editor === void 0 ? void 0 : editor.getAttributes('heading')) === null || _a === void 0 ? void 0 : _a.level) || 0;
1687
- };
1688
- const isVisible = value => {
1689
- if (Array.isArray(value)) {
1690
- const isHaveNotVisibleTools = value.some(item => notVisibleTools.value.includes(item));
1691
- return isHaveNotVisibleTools;
1692
- }
1693
- return !notVisibleTools.value.includes(value);
1694
- };
1695
- const handleInput = event => {
1696
- const target = event.target;
1697
- const value = target.value;
1698
- editor === null || editor === void 0 ? void 0 : editor.commands.setContent(deserialize(editor === null || editor === void 0 ? void 0 : editor.schema, value));
1699
- markdownOutput.value = serialize(editor === null || editor === void 0 ? void 0 : editor.schema, editor === null || editor === void 0 ? void 0 : editor.getJSON());
1700
- proxyModelValue.value = markdownOutput.value;
1701
- };
1702
- const handleToolbarClick = (item, level) => {
1703
- var _a, _b;
1704
- switch (item) {
1705
- case 'source':
1706
- disableMarkdown.value = !disableMarkdown.value;
1707
- sourceValue.value = serialize(editor === null || editor === void 0 ? void 0 : editor.schema, editor === null || editor === void 0 ? void 0 : editor.getJSON());
1708
- nextTick(() => {
1709
- var _a;
1710
- return (_a = textareaRef.value) === null || _a === void 0 ? void 0 : _a.focus();
1711
- });
1712
- break;
1713
- case 'bulletList':
1714
- case 'orderedList':
1715
- item === 'bulletList' ? editor === null || editor === void 0 ? void 0 : editor.commands.toggleBulletList() : editor === null || editor === void 0 ? void 0 : editor.commands.toggleOrderedList();
1716
- break;
1717
- case 'link':
1718
- if (editor) {
1719
- const cursorPosition = (editor === null || editor === void 0 ? void 0 : editor.state.selection.$anchor.pos) || 0;
1720
- const {
1721
- from,
1722
- to,
1723
- empty
1724
- } = editor.state.selection;
1725
- const isLink = (_a = editor.view.state.doc.nodeAt(cursorPosition)) === null || _a === void 0 ? void 0 : _a.marks.filter(mark => mark.type.name === 'link');
1726
- const existedText = (isLink === null || isLink === void 0 ? void 0 : isLink.length) ? ((_b = editor.view.state.doc.nodeAt(cursorPosition)) === null || _b === void 0 ? void 0 : _b.text) || '' : '';
1727
- text.value = empty ? existedText : editor.state.doc.textBetween(from, to, ' ');
1728
- link.value = editor.getAttributes('link').href || '';
1729
- }
1730
- isOpenLinkModal.value = !isOpenLinkModal.value;
1731
- break;
1732
- case 'blockquote':
1733
- editor === null || editor === void 0 ? void 0 : editor.chain().focus().toggleBlockquote().run();
1734
- break;
1735
- case 'codeBlock':
1736
- if (!isActive.value['codeBlock']) {
1737
- editor === null || editor === void 0 ? void 0 : editor.commands.setNode(item, {
1738
- language: 'javascript'
1739
- });
1740
- } else {
1741
- editor === null || editor === void 0 ? void 0 : editor.commands.setNode('paragraph');
1742
- }
1743
- break;
1744
- case 'heading':
1745
- if (!level) {
1746
- editor === null || editor === void 0 ? void 0 : editor.commands.toggleHeading({
1747
- level: 0
1748
- });
1749
- activeHeadingLevel.value = 0;
1750
- } else {
1751
- activeHeadingLevel.value = level;
1752
- editor === null || editor === void 0 ? void 0 : editor.commands.toggleHeading({
1753
- level: level
1754
- });
1755
- }
1756
- editor === null || editor === void 0 ? void 0 : editor.commands.focus();
1757
- break;
1758
- case 'undo':
1759
- case 'redo':
1760
- item === 'undo' ? editor === null || editor === void 0 ? void 0 : editor.commands.undo() : editor === null || editor === void 0 ? void 0 : editor.commands.redo();
1761
- break;
1762
- case 'file':
1763
- context.emit('file-upload');
1764
- break;
1765
- default:
1766
- editor === null || editor === void 0 ? void 0 : editor.chain().focus().toggleMark(item).run();
1767
- break;
1768
- }
1769
- };
1770
- const attachLink = async () => {
1771
- var _a, _b;
1772
- // empty
1773
- if (link.value === '') {
1774
- editor === null || editor === void 0 ? void 0 : editor.chain().focus().extendMarkRange('link').unsetLink().run();
1775
- }
1776
- const isEmptySelection = editor === null || editor === void 0 ? void 0 : editor.state.selection.empty;
1777
- const cursorPosition = (editor === null || editor === void 0 ? void 0 : editor.state.selection.$anchor.pos) || 0;
1778
- const isLink = (_a = editor === null || editor === void 0 ? void 0 : editor.view.state.doc.nodeAt(cursorPosition)) === null || _a === void 0 ? void 0 : _a.marks.filter(mark => mark.type.name === 'link');
1779
- const existedText = (isLink === null || isLink === void 0 ? void 0 : isLink.length) ? (_b = editor === null || editor === void 0 ? void 0 : editor.view.state.doc.nodeAt(cursorPosition)) === null || _b === void 0 ? void 0 : _b.text : '';
1780
- if (link.value && isEmptySelection && !existedText) {
1781
- editor === null || editor === void 0 ? void 0 : editor.chain().focus().setMark('link', {
1782
- href: link.value,
1783
- target: '__blank'
1784
- }).command(_ref4 => {
1785
- let {
1786
- tr
1787
- } = _ref4;
1788
- const preparedValue = text.value[text.value.length - 1] === ' ' ? text.value : `${text.value} `;
1789
- tr.insertText(preparedValue);
1790
- return true;
1791
- }).run();
1792
- }
1793
- if (link.value && existedText === text.value && isEmptySelection) {
1794
- editor === null || editor === void 0 ? void 0 : editor.chain().extendMarkRange('link').updateAttributes('link', {
1795
- href: link.value
1796
- }).run();
1797
- }
1798
- if (link.value && !isEmptySelection) {
1799
- editor === null || editor === void 0 ? void 0 : editor.chain().focus().setMark('link', {
1800
- href: link.value,
1801
- target: '__blank'
1802
- }).run();
1803
- }
1804
- text.value = '';
1805
- link.value = '';
1806
- isOpenLinkModal.value = false;
1807
- };
1808
- const discardLink = () => {
1809
- isOpenLinkModal.value = false;
1810
- };
1811
- const setActiveFormats = () => {
1812
- const toolbarList = props.toolbar.flat();
1813
- toolbarList.forEach(item => {
1814
- if (item === 'source') {
1815
- isActive.value[item] = disableMarkdown.value;
1816
- } else {
1817
- isActive.value[item] = (editor === null || editor === void 0 ? void 0 : editor.isActive(item)) || false;
1818
- }
1819
- });
1820
- };
1821
- // Styles
1822
- const rootStyles = computed(() => {
1823
- return ['or-rich-text-editor', ...(props.fullHeight ? ['h-full'] : [])];
1824
- });
1825
- const containerStyles = computed(() => {
1826
- return [...EditorContainer, ...(props.fullHeight ? ['h-full'] : [])];
1827
- });
1828
- const toolbarContainerStyles = computed(() => {
1829
- return [...ToolbarContainer];
1830
- });
1831
- const toolbarStyles = computed(() => {
1832
- return [...Toolbar,
1833
- // 'overflow-x-hidden',
1834
- ...(isFocused.value ? ToolbarButtonFocused : ToolbarButton)];
1835
- });
1836
- const editorInputStyles = computed(() => {
1837
- return ['tiptap-editor-v3', ...(props.fullHeight ? ['h-full overflow-y-auto'] : []), ...EditorInput];
1838
- });
1839
- //Effects
1840
- watch(proxyModelValue, value => {
1841
- if (value !== (editor === null || editor === void 0 ? void 0 : editor.getHTML()) && props.format !== 'markdown') {
1842
- editor === null || editor === void 0 ? void 0 : editor.commands.setContent(value);
1843
- }
1844
- if (props.format === 'markdown' && value !== markdownOutput.value) {
1845
- // const deserialized = deserialize(editor?.schema, value);
1846
- editor === null || editor === void 0 ? void 0 : editor.commands.setContent(value);
1847
- }
1848
- });
1849
- return {
1850
- editor,
1851
- editorRef,
1852
- toolbarRef,
1853
- containerRef,
1854
- toolbarButtonRef,
1855
- moreButtonRef,
1856
- textareaRef,
1857
- moreRef,
1858
- menuRef,
1859
- iconsEnum,
1860
- handleToolbarClick,
1861
- handleEditorClick,
1862
- isActive,
1863
- iconTooltipsEnum,
1864
- containerStyles,
1865
- toolbarContainerStyles,
1866
- toolbarStyles,
1867
- rootStyles,
1868
- root,
1869
- editorInputStyles,
1870
- getIndexOfHeading,
1871
- headingLevels,
1872
- headingIcon,
1873
- attachLink,
1874
- discardLink,
1875
- isOpenLinkModal,
1876
- text,
1877
- link,
1878
- isFocused,
1879
- isVisible,
1880
- countOfNotVisibleTools,
1881
- notVisibleTools,
1882
- handleInput,
1883
- proxyModelValue,
1884
- disableMarkdown,
1885
- sourceValue
1886
- };
1887
- }
1888
- });
1889
-
1890
- export { script as s };