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