@hartl-services/medusa-base 2.5.0 → 2.6.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 (287) hide show
  1. package/.medusa/server/src/admin/admin-components/features/plugin-features/components/ImageSettingInput.js +48 -0
  2. package/{dist → .medusa/server/src/admin}/admin-components/features/plugin-features/components/PluginActionsSection.js +3 -2
  3. package/.medusa/server/src/admin/admin-components/features/plugin-features/components/PluginFeaturesSettingsPage.js +17 -0
  4. package/.medusa/server/src/admin/admin-components/features/plugin-features/components/PluginPageShell.js +20 -0
  5. package/{dist → .medusa/server/src/admin}/admin-components/features/plugin-features/components/PluginSettingsForm.js +16 -3
  6. package/{dist → .medusa/server/src/admin}/admin-components/features/plugin-features/hooks/usePluginFeatureEnabled.d.ts +5 -1
  7. package/{dist → .medusa/server/src/admin}/admin-components/features/plugin-features/hooks/usePluginFeatures.d.ts +20 -4
  8. package/{dist → .medusa/server/src/admin}/admin-components/features/plugin-features/hooks/usePluginFeatures.js +1 -1
  9. package/{dist → .medusa/server/src/admin}/admin-components/features/plugin-features/hooks/usePluginSettingsForm.d.ts +5 -1
  10. package/{dist → .medusa/server/src/admin}/admin-components/features/plugin-features/lib/action-runs.d.ts +1 -1
  11. package/{dist → .medusa/server/src/admin}/admin-components/features/plugin-features/lib/action-runs.js +3 -2
  12. package/{dist → .medusa/server/src/admin}/admin-components/features/plugin-features/lib/plugin-features-admin-client.d.ts +20 -4
  13. package/{dist → .medusa/server/src/admin}/admin-components/features/plugin-features/lib/plugin-features-admin-client.js +1 -1
  14. package/{dist → .medusa/server/src/admin}/admin-components/features/plugin-features/lib/settings-draft.d.ts +17 -2
  15. package/{dist → .medusa/server/src/admin}/admin-components/features/plugin-features/lib/settings-draft.js +33 -1
  16. package/{dist → .medusa/server/src/admin}/admin-components/i18n/texts.d.ts +3 -0
  17. package/{dist → .medusa/server/src/admin}/admin-components/i18n/texts.js +3 -0
  18. package/.medusa/server/src/admin/admin-components/index.d.ts +36 -0
  19. package/.medusa/server/src/admin/admin-components/index.js +37 -0
  20. package/.medusa/server/src/admin/admin-components/shared/lib/date-input.d.ts +8 -0
  21. package/.medusa/server/src/admin/admin-components/shared/lib/date-input.js +43 -0
  22. package/.medusa/server/src/admin/admin-components/shared/lib/errors.d.ts +9 -0
  23. package/{dist/admin-components → .medusa/server/src/admin/admin-components/shared}/lib/errors.js +4 -6
  24. package/.medusa/server/src/admin/admin-components/shared/lib/file-validation.d.ts +24 -0
  25. package/.medusa/server/src/admin/admin-components/shared/lib/file-validation.js +18 -0
  26. package/.medusa/server/src/admin/admin-components/shared/lib/format.d.ts +32 -0
  27. package/.medusa/server/src/admin/admin-components/shared/lib/format.js +77 -0
  28. package/.medusa/server/src/admin/admin-components/shared/lib/pdf-preview.d.ts +16 -0
  29. package/.medusa/server/src/admin/admin-components/shared/lib/pdf-preview.js +31 -0
  30. package/.medusa/server/src/admin/admin-components/shared/lib/pdf.d.ts +6 -0
  31. package/.medusa/server/src/admin/admin-components/shared/lib/pdf.js +13 -0
  32. package/.medusa/server/src/admin/admin-components/shared/lib/use-debounced-value.d.ts +2 -0
  33. package/.medusa/server/src/admin/admin-components/shared/lib/use-debounced-value.js +10 -0
  34. package/.medusa/server/src/admin/admin-components/shared/lib/use-pdf-preview.d.ts +24 -0
  35. package/.medusa/server/src/admin/admin-components/shared/lib/use-pdf-preview.js +47 -0
  36. package/.medusa/server/src/admin/admin-components/shared/ui/AdminDatePicker.d.ts +8 -0
  37. package/.medusa/server/src/admin/admin-components/shared/ui/AdminDatePicker.js +9 -0
  38. package/.medusa/server/src/admin/admin-components/shared/ui/BackLink.d.ts +8 -0
  39. package/.medusa/server/src/admin/admin-components/shared/ui/BackLink.js +5 -0
  40. package/.medusa/server/src/admin/admin-components/shared/ui/DateRangeFilter.d.ts +20 -0
  41. package/.medusa/server/src/admin/admin-components/shared/ui/DateRangeFilter.js +17 -0
  42. package/.medusa/server/src/admin/admin-components/shared/ui/FilePickerButton.d.ts +14 -0
  43. package/.medusa/server/src/admin/admin-components/shared/ui/FilePickerButton.js +14 -0
  44. package/.medusa/server/src/admin/admin-components/shared/ui/MappedStatusBadge.d.ts +17 -0
  45. package/.medusa/server/src/admin/admin-components/shared/ui/MappedStatusBadge.js +12 -0
  46. package/.medusa/server/src/admin/admin-components/shared/ui/OffsetTablePagination.d.ts +15 -0
  47. package/.medusa/server/src/admin/admin-components/shared/ui/OffsetTablePagination.js +19 -0
  48. package/.medusa/server/src/admin/admin-components/shared/ui/PdfPreviewModal.d.ts +20 -0
  49. package/.medusa/server/src/admin/admin-components/shared/ui/PdfPreviewModal.js +7 -0
  50. package/.medusa/server/src/admin/admin-components/shared/ui/PluginFeatureRoute.d.ts +19 -0
  51. package/.medusa/server/src/admin/admin-components/shared/ui/PluginFeatureRoute.js +16 -0
  52. package/.medusa/server/src/admin/admin-components/shared/ui/QueryState.d.ts +24 -0
  53. package/.medusa/server/src/admin/admin-components/shared/ui/QueryState.js +23 -0
  54. package/.medusa/server/src/admin/admin-components/shared/ui/SearchableReferenceField.d.ts +63 -0
  55. package/.medusa/server/src/admin/admin-components/shared/ui/SearchableReferenceField.js +84 -0
  56. package/.medusa/server/src/admin/admin-components/shared/ui/SectionHeader.d.ts +15 -0
  57. package/.medusa/server/src/admin/admin-components/shared/ui/SectionHeader.js +13 -0
  58. package/.medusa/server/src/admin/admin-components/shared/ui/mapped-status.d.ts +6 -0
  59. package/.medusa/server/src/admin/admin-components/shared/ui/mapped-status.js +10 -0
  60. package/.medusa/server/src/admin/admin-components/shared/ui/offset-pagination.d.ts +17 -0
  61. package/.medusa/server/src/admin/admin-components/shared/ui/offset-pagination.js +15 -0
  62. package/.medusa/server/src/admin/admin-components/shared/ui/reference-results-state.d.ts +16 -0
  63. package/.medusa/server/src/admin/admin-components/shared/ui/reference-results-state.js +13 -0
  64. package/.medusa/server/src/admin/admin-components/shared/ui/rich-text-editor/InsertMenu.d.ts +8 -0
  65. package/.medusa/server/src/admin/admin-components/shared/ui/rich-text-editor/InsertMenu.js +10 -0
  66. package/.medusa/server/src/admin/admin-components/shared/ui/rich-text-editor/LinkPrompt.d.ts +14 -0
  67. package/.medusa/server/src/admin/admin-components/shared/ui/rich-text-editor/LinkPrompt.js +26 -0
  68. package/.medusa/server/src/admin/admin-components/shared/ui/rich-text-editor/RichTextEditor.d.ts +15 -0
  69. package/.medusa/server/src/admin/admin-components/shared/ui/rich-text-editor/RichTextEditor.js +8 -0
  70. package/.medusa/server/src/admin/admin-components/shared/ui/rich-text-editor/RichTextToolbar.d.ts +10 -0
  71. package/.medusa/server/src/admin/admin-components/shared/ui/rich-text-editor/RichTextToolbar.js +49 -0
  72. package/.medusa/server/src/admin/admin-components/shared/ui/rich-text-editor/SlashMenu.d.ts +11 -0
  73. package/.medusa/server/src/admin/admin-components/shared/ui/rich-text-editor/SlashMenu.js +44 -0
  74. package/.medusa/server/src/admin/admin-components/shared/ui/rich-text-editor/build-extensions.d.ts +8 -0
  75. package/.medusa/server/src/admin/admin-components/shared/ui/rich-text-editor/build-extensions.js +43 -0
  76. package/.medusa/server/src/admin/admin-components/shared/ui/rich-text-editor/drag-handle.d.ts +15 -0
  77. package/.medusa/server/src/admin/admin-components/shared/ui/rich-text-editor/drag-handle.js +161 -0
  78. package/.medusa/server/src/admin/admin-components/shared/ui/rich-text-editor/drag-target.d.ts +30 -0
  79. package/.medusa/server/src/admin/admin-components/shared/ui/rich-text-editor/drag-target.js +47 -0
  80. package/.medusa/server/src/admin/admin-components/shared/ui/rich-text-editor/editor-styles.d.ts +6 -0
  81. package/.medusa/server/src/admin/admin-components/shared/ui/rich-text-editor/editor-styles.js +46 -0
  82. package/.medusa/server/src/admin/admin-components/shared/ui/rich-text-editor/index.d.ts +9 -0
  83. package/.medusa/server/src/admin/admin-components/shared/ui/rich-text-editor/index.js +6 -0
  84. package/.medusa/server/src/admin/admin-components/shared/ui/rich-text-editor/link-href.d.ts +8 -0
  85. package/.medusa/server/src/admin/admin-components/shared/ui/rich-text-editor/link-href.js +21 -0
  86. package/.medusa/server/src/admin/admin-components/shared/ui/rich-text-editor/link-policy.d.ts +13 -0
  87. package/.medusa/server/src/admin/admin-components/shared/ui/rich-text-editor/link-policy.js +20 -0
  88. package/.medusa/server/src/admin/admin-components/shared/ui/rich-text-editor/slash-command.d.ts +13 -0
  89. package/.medusa/server/src/admin/admin-components/shared/ui/rich-text-editor/slash-command.js +60 -0
  90. package/.medusa/server/src/admin/admin-components/shared/ui/rich-text-editor/slash-items.d.ts +25 -0
  91. package/.medusa/server/src/admin/admin-components/shared/ui/rich-text-editor/slash-items.js +10 -0
  92. package/.medusa/server/src/admin/admin-components/shared/ui/rich-text-editor/tiptap.d.ts +7 -0
  93. package/.medusa/server/src/admin/admin-components/shared/ui/rich-text-editor/tiptap.js +7 -0
  94. package/.medusa/server/src/admin/admin-components/shared/ui/rich-text-editor/use-rich-text-editor.d.ts +44 -0
  95. package/.medusa/server/src/admin/admin-components/shared/ui/rich-text-editor/use-rich-text-editor.js +37 -0
  96. package/.medusa/server/src/admin/index.js +4513 -1447
  97. package/.medusa/server/src/admin/index.mjs +4515 -1452
  98. package/.medusa/server/src/api/admin/email/attachments/[id]/mail-kinds/route.js +16 -0
  99. package/.medusa/server/src/api/admin/email/attachments/[id]/route.js +15 -0
  100. package/.medusa/server/src/api/admin/email/attachments/[id]/versions/[version_id]/download/route.js +16 -0
  101. package/.medusa/server/src/api/admin/email/attachments/[id]/versions/route.js +41 -0
  102. package/.medusa/server/src/api/admin/email/attachments/route.js +21 -0
  103. package/.medusa/server/src/api/admin/email/templates/[kind]/preview/route.js +31 -0
  104. package/.medusa/server/src/api/admin/email/templates/[kind]/route.js +28 -0
  105. package/.medusa/server/src/api/admin/email/templates/[kind]/send-test/route.js +179 -0
  106. package/.medusa/server/src/api/admin/email/templates/[kind]/test-sources/route.js +19 -0
  107. package/.medusa/server/src/api/admin/email/templates/route.js +15 -0
  108. package/.medusa/server/src/api/admin/plugin-features/[plugin_key]/actions/[action_key]/route.js +2 -2
  109. package/.medusa/server/src/api/admin/plugin-features/[plugin_key]/actions/[action_key]/runs/route.js +2 -2
  110. package/.medusa/server/src/api/admin/plugin-features/[plugin_key]/route.js +2 -2
  111. package/.medusa/server/src/api/admin/plugin-features/[plugin_key]/settings/route.js +2 -2
  112. package/.medusa/server/src/api/admin/plugin-features/route.js +2 -2
  113. package/.medusa/server/src/api/attachment-download-response.js +12 -0
  114. package/.medusa/server/src/api/email-template-response.js +43 -0
  115. package/.medusa/server/src/api/middlewares.js +75 -17
  116. package/.medusa/server/src/api/plugin-actions.js +6 -5
  117. package/.medusa/server/src/api/plugin-features-http.js +4 -9
  118. package/.medusa/server/src/api/store/carts/[id]/completion-check/route.js +2 -2
  119. package/.medusa/server/src/api/store/plugin-features/[plugin_key]/route.js +2 -2
  120. package/.medusa/server/src/api/store/plugin-features/route.js +2 -2
  121. package/.medusa/server/src/documents/plugin-features.js +1 -7
  122. package/.medusa/server/src/documents/templates/financial-document.js +12 -11
  123. package/.medusa/server/src/documents/templates/html-factory.js +1 -1
  124. package/.medusa/server/src/documents/templates/html-utils.js +4 -10
  125. package/.medusa/server/src/documents/templates/layout.js +30 -11
  126. package/.medusa/server/src/documents/templates/packing-list.js +8 -7
  127. package/.medusa/server/src/documents/utils/document-render-settings.js +9 -6
  128. package/.medusa/server/src/email/application/handle-customer-verification-event.js +8 -3
  129. package/.medusa/server/src/email/application/handle-invite-event.js +8 -3
  130. package/.medusa/server/src/email/application/handle-password-reset-event.js +8 -3
  131. package/.medusa/server/src/email/application/notification-attachments.js +86 -0
  132. package/.medusa/server/src/email/application/template-data-from-order.js +339 -0
  133. package/.medusa/server/src/email/config/index.js +5 -29
  134. package/.medusa/server/src/email/domain/business-keys.js +5 -5
  135. package/.medusa/server/src/email/domain/documents-fact-fingerprint.js +3 -3
  136. package/.medusa/server/src/email/domain/order-summary.js +21 -27
  137. package/.medusa/server/src/email/domain/refund-summary.js +7 -12
  138. package/.medusa/server/src/email/domain/return-summary.js +32 -38
  139. package/.medusa/server/src/email/domain/shipment-summary.js +22 -28
  140. package/.medusa/server/src/email/plugin-features.js +2 -10
  141. package/.medusa/server/src/email/rendering/calendar-dates.js +19 -0
  142. package/.medusa/server/src/email/rendering/default-templates.js +99 -682
  143. package/.medusa/server/src/email/rendering/email-html.js +189 -0
  144. package/.medusa/server/src/email/rendering/load-email-shop-details.js +14 -12
  145. package/.medusa/server/src/email/rendering/render-email.js +46 -13
  146. package/.medusa/server/src/email/rendering/resolve-shop-configuration.js +3 -14
  147. package/.medusa/server/src/email/templates/blocks/dynamic-blocks.js +427 -0
  148. package/.medusa/server/src/email/templates/blocks/placeholders.js +71 -0
  149. package/.medusa/server/src/email/templates/blocks/render-document.js +137 -0
  150. package/.medusa/server/src/email/templates/code-override.js +18 -0
  151. package/.medusa/server/src/email/templates/defaults/documents.js +129 -0
  152. package/.medusa/server/src/email/templates/defaults/subjects.js +62 -0
  153. package/.medusa/server/src/email/templates/defaults/texts.js +42 -0
  154. package/.medusa/server/src/email/templates/index.js +22 -0
  155. package/.medusa/server/src/email/templates/load-template.js +39 -0
  156. package/.medusa/server/src/email/templates/preview.js +33 -0
  157. package/.medusa/server/src/email/templates/render.js +70 -0
  158. package/.medusa/server/src/email/templates/sample-data.js +165 -0
  159. package/.medusa/server/src/email/templates/types.js +3 -0
  160. package/.medusa/server/src/email/templates/validate.js +113 -0
  161. package/.medusa/server/src/files/config/index.js +6 -9
  162. package/.medusa/server/src/migration-scripts/move-logo-to-shop-appearance.js +53 -0
  163. package/.medusa/server/src/modules/documents/domain/cancellation-snapshot.js +4 -3
  164. package/.medusa/server/src/modules/documents/domain/merchant.js +4 -3
  165. package/.medusa/server/src/modules/documents/domain/options.js +3 -5
  166. package/.medusa/server/src/modules/documents/domain/tax-breakdown.js +4 -7
  167. package/.medusa/server/src/modules/documents/service.js +12 -33
  168. package/.medusa/server/src/modules/email/domain/attachment.js +22 -8
  169. package/.medusa/server/src/modules/email/migrations/Migration20261009083539.js +80 -0
  170. package/.medusa/server/src/modules/email/migrations/Migration20261009100654.js +17 -0
  171. package/.medusa/server/src/modules/email/models/email-attachment-document-version.js +39 -0
  172. package/.medusa/server/src/modules/email/models/email-attachment-document.js +27 -0
  173. package/.medusa/server/src/modules/email/models/email-template.js +25 -0
  174. package/.medusa/server/src/modules/email/service.js +370 -93
  175. package/.medusa/server/src/modules/plugin-features/domain/plugin-settings.js +9 -11
  176. package/.medusa/server/src/modules/plugin-features/service.js +2 -1
  177. package/.medusa/server/src/providers/s3-cache/cache/cache-manager.js +3 -3
  178. package/.medusa/server/src/providers/s3-cache/s3-object-store.js +3 -9
  179. package/.medusa/server/src/providers/smtp/service.js +13 -13
  180. package/.medusa/server/src/public/descriptor.js +16 -18
  181. package/.medusa/server/src/public/enforcement.js +29 -1
  182. package/.medusa/server/src/public/index.js +8 -2
  183. package/.medusa/server/src/public/module-access.js +9 -2
  184. package/.medusa/server/src/public/shop-master-data.js +109 -18
  185. package/.medusa/server/src/shared/lib/coerce.js +26 -0
  186. package/.medusa/server/src/shared/lib/collections.js +19 -0
  187. package/.medusa/server/src/shared/lib/dates.js +43 -0
  188. package/.medusa/server/src/shared/lib/errors.js +11 -0
  189. package/.medusa/server/src/shared/lib/hash.js +8 -0
  190. package/.medusa/server/src/shared/lib/index.js +29 -0
  191. package/.medusa/server/src/shared/lib/logging.js +61 -0
  192. package/.medusa/server/src/shared/lib/money.js +47 -0
  193. package/.medusa/server/src/shared/lib/text.js +53 -0
  194. package/.medusa/server/src/shared/lib/transaction.js +58 -0
  195. package/.medusa/server/src/{api → shared/lib}/wire-response.js +1 -1
  196. package/.medusa/server/src/shop-config/options.js +3 -5
  197. package/.medusa/server/src/subscribers/packing-list-fulfillment-canceled.js +4 -6
  198. package/.medusa/server/src/workflows/documents/issue-invoice-after-shipment.js +10 -12
  199. package/.medusa/server/src/workflows/documents/issue-packing-list.js +5 -6
  200. package/.medusa/server/src/workflows/documents/reconcile-order-cancellation.js +6 -8
  201. package/.medusa/server/src/workflows/email/dispatch-email-message.js +11 -41
  202. package/.medusa/server/src/workflows/email/prepare-order-received-email.js +2 -2
  203. package/.medusa/server/src/workflows/hooks/complete-cart-participants.js +4 -8
  204. package/README.md +427 -54
  205. package/dist/documents/templates/financial-document.js +11 -10
  206. package/dist/documents/templates/html-factory.d.ts +1 -1
  207. package/dist/documents/templates/html-factory.js +1 -1
  208. package/dist/documents/templates/html-utils.d.ts +0 -1
  209. package/dist/documents/templates/html-utils.js +3 -9
  210. package/dist/documents/templates/layout.js +29 -10
  211. package/dist/documents/templates/packing-list.js +7 -6
  212. package/dist/documents/types/documents.d.ts +7 -1
  213. package/dist/email/config/index.js +4 -28
  214. package/dist/email/types/shop-configuration.d.ts +6 -5
  215. package/dist/files/config/index.js +5 -8
  216. package/dist/modules/documents/domain/options.js +2 -4
  217. package/dist/public/descriptor.js +15 -17
  218. package/dist/public/enforcement.d.ts +21 -1
  219. package/dist/public/enforcement.js +28 -0
  220. package/dist/public/index.d.ts +3 -2
  221. package/dist/public/index.js +7 -1
  222. package/dist/public/module-access.d.ts +8 -0
  223. package/dist/public/module-access.js +8 -1
  224. package/dist/public/shop-master-data.d.ts +22 -5
  225. package/dist/public/shop-master-data.js +108 -17
  226. package/dist/public/types.d.ts +10 -2
  227. package/dist/shared/lib/coerce.d.ts +19 -0
  228. package/dist/shared/lib/coerce.js +25 -0
  229. package/dist/shared/lib/collections.d.ts +3 -0
  230. package/dist/shared/lib/collections.js +18 -0
  231. package/dist/shared/lib/dates.d.ts +12 -0
  232. package/dist/shared/lib/dates.js +42 -0
  233. package/dist/shared/lib/errors.d.ts +2 -0
  234. package/dist/shared/lib/errors.js +10 -0
  235. package/dist/shared/lib/hash.d.ts +2 -0
  236. package/dist/shared/lib/hash.js +7 -0
  237. package/dist/shared/lib/index.d.ts +10 -0
  238. package/dist/shared/lib/index.js +28 -0
  239. package/dist/shared/lib/logging.d.ts +26 -0
  240. package/dist/shared/lib/logging.js +60 -0
  241. package/dist/shared/lib/money.d.ts +13 -0
  242. package/dist/shared/lib/money.js +46 -0
  243. package/dist/shared/lib/text.d.ts +19 -0
  244. package/dist/shared/lib/text.js +52 -0
  245. package/dist/shared/lib/transaction.d.ts +26 -0
  246. package/dist/shared/lib/transaction.js +57 -0
  247. package/dist/shared/lib/wire-response.d.ts +6 -0
  248. package/dist/shared/lib/wire-response.js +9 -0
  249. package/dist/shop-config/options.js +2 -4
  250. package/package.json +19 -4
  251. package/.medusa/server/src/api/admin/email/terms-versions/[id]/download/route.js +0 -16
  252. package/.medusa/server/src/api/admin/email/terms-versions/route.js +0 -47
  253. package/.medusa/server/src/api/terms-download-response.js +0 -12
  254. package/.medusa/server/src/modules/email/models/email-terms-version.js +0 -37
  255. package/dist/admin-components/features/plugin-features/components/ImageSettingInput.js +0 -42
  256. package/dist/admin-components/features/plugin-features/components/PluginFeaturesSettingsPage.js +0 -16
  257. package/dist/admin-components/features/plugin-features/components/PluginPageShell.js +0 -20
  258. package/dist/admin-components/features/plugin-features/lib/image-upload.d.ts +0 -6
  259. package/dist/admin-components/features/plugin-features/lib/image-upload.js +0 -17
  260. package/dist/admin-components/index.d.ts +0 -14
  261. package/dist/admin-components/index.js +0 -14
  262. package/dist/admin-components/lib/errors.d.ts +0 -6
  263. /package/{dist → .medusa/server/src/admin}/admin-components/features/plugin-features/components/ImageSettingInput.d.ts +0 -0
  264. /package/{dist → .medusa/server/src/admin}/admin-components/features/plugin-features/components/PluginActionsSection.d.ts +0 -0
  265. /package/{dist → .medusa/server/src/admin}/admin-components/features/plugin-features/components/PluginDetailPage.d.ts +0 -0
  266. /package/{dist → .medusa/server/src/admin}/admin-components/features/plugin-features/components/PluginDetailPage.js +0 -0
  267. /package/{dist → .medusa/server/src/admin}/admin-components/features/plugin-features/components/PluginFeatureGate.d.ts +0 -0
  268. /package/{dist → .medusa/server/src/admin}/admin-components/features/plugin-features/components/PluginFeatureGate.js +0 -0
  269. /package/{dist → .medusa/server/src/admin}/admin-components/features/plugin-features/components/PluginFeatureSections.d.ts +0 -0
  270. /package/{dist → .medusa/server/src/admin}/admin-components/features/plugin-features/components/PluginFeatureSections.js +0 -0
  271. /package/{dist → .medusa/server/src/admin}/admin-components/features/plugin-features/components/PluginFeaturesCard.d.ts +0 -0
  272. /package/{dist → .medusa/server/src/admin}/admin-components/features/plugin-features/components/PluginFeaturesCard.js +0 -0
  273. /package/{dist → .medusa/server/src/admin}/admin-components/features/plugin-features/components/PluginFeaturesSettingsPage.d.ts +0 -0
  274. /package/{dist → .medusa/server/src/admin}/admin-components/features/plugin-features/components/PluginHubCard.d.ts +0 -0
  275. /package/{dist → .medusa/server/src/admin}/admin-components/features/plugin-features/components/PluginHubCard.js +0 -0
  276. /package/{dist → .medusa/server/src/admin}/admin-components/features/plugin-features/components/PluginPageShell.d.ts +0 -0
  277. /package/{dist → .medusa/server/src/admin}/admin-components/features/plugin-features/components/PluginSettingsForm.d.ts +0 -0
  278. /package/{dist → .medusa/server/src/admin}/admin-components/features/plugin-features/components/PluginStatusChips.d.ts +0 -0
  279. /package/{dist → .medusa/server/src/admin}/admin-components/features/plugin-features/components/PluginStatusChips.js +0 -0
  280. /package/{dist → .medusa/server/src/admin}/admin-components/features/plugin-features/hooks/usePluginFeatureEnabled.js +0 -0
  281. /package/{dist → .medusa/server/src/admin}/admin-components/features/plugin-features/hooks/usePluginSettingsForm.js +0 -0
  282. /package/{dist → .medusa/server/src/admin}/admin-components/features/plugin-features/lib/plugin-paths.d.ts +0 -0
  283. /package/{dist → .medusa/server/src/admin}/admin-components/features/plugin-features/lib/plugin-paths.js +0 -0
  284. /package/{dist → .medusa/server/src/admin}/admin-components/features/plugin-features/queries/pluginFeatureKeys.d.ts +0 -0
  285. /package/{dist → .medusa/server/src/admin}/admin-components/features/plugin-features/queries/pluginFeatureKeys.js +0 -0
  286. /package/{dist/admin-components → .medusa/server/src/admin/admin-components/shared}/lib/sdk.d.ts +0 -0
  287. /package/{dist/admin-components → .medusa/server/src/admin/admin-components/shared}/lib/sdk.js +0 -0
@@ -0,0 +1,11 @@
1
+ import type { SlashItem } from "./slash-items";
2
+ export interface SlashMenuHandle {
3
+ /** Returns whether the key was used by the menu. */
4
+ onKeyDown: (event: KeyboardEvent) => boolean;
5
+ }
6
+ interface SlashMenuProps {
7
+ items: SlashItem[];
8
+ command: (item: SlashItem) => void;
9
+ }
10
+ export declare const SlashMenu: import("react").ForwardRefExoticComponent<SlashMenuProps & import("react").RefAttributes<SlashMenuHandle>>;
11
+ export {};
@@ -0,0 +1,44 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Text } from "@medusajs/ui";
3
+ import { forwardRef, useEffect, useImperativeHandle, useRef, useState } from "react";
4
+ // The popup list of the slash menu. Keys come from the editor (it keeps the
5
+ // focus), so the list is driven through the imperative `onKeyDown`.
6
+ export const SlashMenu = forwardRef(({ items, command }, ref) => {
7
+ const [selected, setSelected] = useState(0);
8
+ const selectedRef = useRef(null);
9
+ useEffect(() => {
10
+ setSelected(0);
11
+ }, [items]);
12
+ useEffect(() => {
13
+ selectedRef.current?.scrollIntoView({ block: "nearest" });
14
+ }, [selected]);
15
+ const choose = (index) => {
16
+ const item = items[index];
17
+ if (item) {
18
+ command(item);
19
+ }
20
+ };
21
+ useImperativeHandle(ref, () => ({
22
+ onKeyDown: (event) => {
23
+ if (event.key === "ArrowDown") {
24
+ setSelected((current) => (items.length ? (current + 1) % items.length : 0));
25
+ return true;
26
+ }
27
+ if (event.key === "ArrowUp") {
28
+ setSelected((current) => items.length ? (current - 1 + items.length) % items.length : 0);
29
+ return true;
30
+ }
31
+ if (event.key === "Enter" && items.length) {
32
+ choose(selected);
33
+ return true;
34
+ }
35
+ return false;
36
+ },
37
+ }));
38
+ return (_jsx("div", { className: "bg-ui-bg-base border-ui-border-base shadow-elevation-flyout max-h-72 min-w-56 overflow-y-auto rounded-lg border p-1", role: "listbox", "aria-label": "Befehle", children: items.length ? (items.map((item, index) => (
39
+ // eslint-disable-next-line no-restricted-syntax -- Slash-Menü-Eintrag mit Fokus im Editor
40
+ _jsxs("button", { "aria-selected": index === selected, className: `flex w-full items-center justify-between gap-4 rounded-md px-2 py-1.5 text-left ${index === selected ? "bg-ui-bg-base-pressed" : "hover:bg-ui-bg-base-hover"}`,
41
+ // Keep the focus in the editor.
42
+ onMouseDown: (event) => event.preventDefault(), onClick: () => choose(index), onMouseEnter: () => setSelected(index), ref: index === selected ? selectedRef : undefined, role: "option", type: "button", children: [_jsx(Text, { size: "small", children: item.label }), _jsx(Text, { className: "text-ui-fg-muted", size: "xsmall", children: item.hint })] }, item.id)))) : (_jsx(Text, { className: "text-ui-fg-subtle px-2 py-1.5", size: "small", children: "Keine Treffer" })) }));
43
+ });
44
+ SlashMenu.displayName = "SlashMenu";
@@ -0,0 +1,8 @@
1
+ import type { AnyExtension } from "@tiptap/react";
2
+ import type { MutableRefObject } from "react";
3
+ import type { RichTextEditorConfig } from "./use-rich-text-editor";
4
+ /**
5
+ * The extensions of one editor. `configRef` is read on use (link policy and
6
+ * slash items), everything else from `config` when the editor is created.
7
+ */
8
+ export declare const buildExtensions: (config: RichTextEditorConfig, configRef: MutableRefObject<RichTextEditorConfig>) => AnyExtension[];
@@ -0,0 +1,43 @@
1
+ import Link from "@tiptap/extension-link";
2
+ import StarterKit from "@tiptap/starter-kit";
3
+ import { DragHandle } from "./drag-handle";
4
+ import { isDefaultAllowedHref } from "./link-href";
5
+ import { LinkPolicy } from "./link-policy";
6
+ import { SlashCommand } from "./slash-command";
7
+ const currentIsAllowedHref = (configRef, href) => {
8
+ const { link } = configRef.current;
9
+ return (link ? link.isAllowedHref : isDefaultAllowedHref)(href);
10
+ };
11
+ /**
12
+ * The extensions of one editor. `configRef` is read on use (link policy and
13
+ * slash items), everything else from `config` when the editor is created.
14
+ */
15
+ export const buildExtensions = (config, configRef) => {
16
+ const extensions = [
17
+ StarterKit.configure({ ...config.starterKit, link: false }),
18
+ ];
19
+ if (config.link !== false) {
20
+ extensions.push(LinkPolicy.configure({
21
+ isAllowedHref: (href) => currentIsAllowedHref(configRef, href),
22
+ }), Link.configure({
23
+ autolink: false,
24
+ linkOnPaste: false,
25
+ openOnClick: false,
26
+ isAllowedUri: (url) => currentIsAllowedHref(configRef, url),
27
+ }));
28
+ }
29
+ extensions.push(...(config.extensions ?? []));
30
+ if (config.slashItems) {
31
+ extensions.push(SlashCommand.configure({
32
+ items: (context) => configRef.current.slashItems?.(context) ?? [],
33
+ }));
34
+ }
35
+ if (config.dragHandle) {
36
+ extensions.push(DragHandle.configure({
37
+ nestedContainers: typeof config.dragHandle === "object"
38
+ ? (config.dragHandle.nestedContainers ?? [])
39
+ : [],
40
+ }));
41
+ }
42
+ return extensions;
43
+ };
@@ -0,0 +1,15 @@
1
+ import { Extension } from "@tiptap/react";
2
+ import { PluginKey } from "@tiptap/pm/state";
3
+ import type { NestedContainer } from "./drag-target";
4
+ export declare const dragHandleKey: PluginKey<any>;
5
+ interface DragHandleOptions {
6
+ /** Containers whose children get a grip of their own. */
7
+ nestedContainers: NestedContainer[];
8
+ }
9
+ /**
10
+ * A grip left of the block under the pointer; dragging it moves the whole
11
+ * top-level block. Inside a nested container the grip belongs to the child
12
+ * under the pointer. The grip sits in the editor's left padding.
13
+ */
14
+ export declare const DragHandle: Extension<DragHandleOptions, any>;
15
+ export {};
@@ -0,0 +1,161 @@
1
+ import { Extension } from "@tiptap/react";
2
+ import { NodeSelection, Plugin, PluginKey } from "@tiptap/pm/state";
3
+ import { resolveDragTarget } from "./drag-target";
4
+ const HANDLE_CLASS = "rte-drag-handle";
5
+ const HANDLE_GLYPH = "⠿";
6
+ const HANDLE_TITLE = "Block verschieben";
7
+ export const dragHandleKey = new PluginKey("rteDragHandle");
8
+ const HANDLE_WIDTH = 22;
9
+ const contains = (rect, x, y) => x >= rect.left && x <= rect.right && y >= rect.top && y <= rect.bottom;
10
+ class DragHandleView {
11
+ constructor(view, containers) {
12
+ this.view = view;
13
+ this.containers = containers;
14
+ this.blockPos = null;
15
+ this.hide = () => {
16
+ this.blockPos = null;
17
+ this.handle.style.display = "none";
18
+ };
19
+ // Moving between the editor and its handle keeps the handle.
20
+ this.onLeave = (event) => {
21
+ const next = event.relatedTarget;
22
+ if (next instanceof Node &&
23
+ (this.handle.contains(next) || this.view.dom.contains(next))) {
24
+ return;
25
+ }
26
+ this.hide();
27
+ };
28
+ this.onMouseMove = (event) => {
29
+ const container = this.handle.parentElement;
30
+ if (!this.view.editable || !container) {
31
+ this.hide();
32
+ return;
33
+ }
34
+ // Over the handle itself the target stays, so the handle can be grabbed.
35
+ if (this.handle.style.display !== "none" &&
36
+ contains(this.handle.getBoundingClientRect(), event.clientX, event.clientY)) {
37
+ return;
38
+ }
39
+ container.style.position = "relative";
40
+ // The handle sits in the editor's left padding; look up the block at the
41
+ // text column so hovering the padding still finds it.
42
+ const contentRect = this.view.dom.getBoundingClientRect();
43
+ const paddingLeft = Number.parseFloat(getComputedStyle(this.view.dom).paddingLeft);
44
+ const left = Math.max(event.clientX, contentRect.left + paddingLeft + 1);
45
+ const hit = this.view.posAtCoords({ left, top: event.clientY });
46
+ if (!hit) {
47
+ this.hide();
48
+ return;
49
+ }
50
+ const pos = resolveDragTarget(this.view.state.doc, hit, this.containers, (containerPos, container) => this.pointerInContainerContent(containerPos, container, event));
51
+ if (pos === null) {
52
+ this.hide();
53
+ return;
54
+ }
55
+ if (pos === this.blockPos) {
56
+ return;
57
+ }
58
+ const dom = this.view.nodeDOM(pos);
59
+ if (!(dom instanceof HTMLElement)) {
60
+ this.hide();
61
+ return;
62
+ }
63
+ const domRect = dom.getBoundingClientRect();
64
+ const containerRect = container.getBoundingClientRect();
65
+ const nested = this.view.state.doc.resolve(pos).depth > 0;
66
+ this.blockPos = pos;
67
+ this.handle.style.top = `${domRect.top - containerRect.top}px`;
68
+ // A child of a nested container gets the handle at its own left edge,
69
+ // inside the container's padding; top-level blocks use the stylesheet's.
70
+ this.handle.style.left = nested
71
+ ? `${domRect.left - containerRect.left - HANDLE_WIDTH}px`
72
+ : "";
73
+ this.handle.style.display = "block";
74
+ };
75
+ this.onDragStart = (event) => {
76
+ const { view, blockPos } = this;
77
+ const node = blockPos === null ? null : view.state.doc.nodeAt(blockPos);
78
+ if (blockPos === null || !node || !event.dataTransfer) {
79
+ event.preventDefault();
80
+ return;
81
+ }
82
+ // Select the block and tell ProseMirror a move of the selection is under
83
+ // way; its drop handling then inserts at the drop point and deletes the
84
+ // original.
85
+ const selection = NodeSelection.create(view.state.doc, blockPos);
86
+ view.dispatch(view.state.tr.setSelection(selection));
87
+ view.dragging = { slice: selection.content(), move: true };
88
+ event.dataTransfer.effectAllowed = "copyMove";
89
+ event.dataTransfer.setData("text/plain", node.textContent || " ");
90
+ const dom = view.nodeDOM(blockPos);
91
+ if (dom instanceof HTMLElement) {
92
+ event.dataTransfer.setDragImage(dom, 0, 0);
93
+ }
94
+ };
95
+ // A cancelled drag never reaches ProseMirror's drop handler.
96
+ this.onDragEnd = () => {
97
+ setTimeout(() => {
98
+ this.view.dragging = null;
99
+ }, 50);
100
+ };
101
+ this.handle = document.createElement("div");
102
+ this.handle.className = HANDLE_CLASS;
103
+ this.handle.textContent = HANDLE_GLYPH;
104
+ this.handle.title = HANDLE_TITLE;
105
+ this.handle.draggable = true;
106
+ this.handle.style.display = "none";
107
+ // The handle is a sibling of the editor's DOM, in the same container.
108
+ // React's EditorContent moves all siblings into its own element on mount,
109
+ // so the container is looked up when it is needed, not stored.
110
+ view.dom.parentElement?.append(this.handle);
111
+ view.dom.addEventListener("mousemove", this.onMouseMove);
112
+ view.dom.addEventListener("mouseleave", this.onLeave);
113
+ this.handle.addEventListener("mouseleave", this.onLeave);
114
+ this.handle.addEventListener("dragstart", this.onDragStart);
115
+ this.handle.addEventListener("dragend", this.onDragEnd);
116
+ }
117
+ // The positions the handle remembers are stale after any document change.
118
+ update(view, previousState) {
119
+ if (!view.state.doc.eq(previousState.doc) || !view.editable) {
120
+ this.hide();
121
+ }
122
+ }
123
+ destroy() {
124
+ this.view.dom.removeEventListener("mousemove", this.onMouseMove);
125
+ this.view.dom.removeEventListener("mouseleave", this.onLeave);
126
+ this.handle.removeEventListener("mouseleave", this.onLeave);
127
+ this.handle.removeEventListener("dragstart", this.onDragStart);
128
+ this.handle.removeEventListener("dragend", this.onDragEnd);
129
+ this.handle.remove();
130
+ }
131
+ // Whether the real pointer is in the (padded) content column of the
132
+ // container at `containerPos`, not on its header or border.
133
+ pointerInContainerContent(containerPos, container, event) {
134
+ const dom = this.view.nodeDOM(containerPos);
135
+ const content = dom instanceof HTMLElement
136
+ ? dom.querySelector(container.contentSelector)
137
+ : null;
138
+ return (content !== null &&
139
+ contains(content.getBoundingClientRect(), event.clientX, event.clientY));
140
+ }
141
+ }
142
+ /**
143
+ * A grip left of the block under the pointer; dragging it moves the whole
144
+ * top-level block. Inside a nested container the grip belongs to the child
145
+ * under the pointer. The grip sits in the editor's left padding.
146
+ */
147
+ export const DragHandle = Extension.create({
148
+ name: "dragHandle",
149
+ addOptions() {
150
+ return { nestedContainers: [] };
151
+ },
152
+ addProseMirrorPlugins() {
153
+ const { nestedContainers } = this.options;
154
+ return [
155
+ new Plugin({
156
+ key: dragHandleKey,
157
+ view: (view) => new DragHandleView(view, nestedContainers),
158
+ }),
159
+ ];
160
+ },
161
+ });
@@ -0,0 +1,30 @@
1
+ import type { Node as ProseMirrorNode } from "@tiptap/pm/model";
2
+ /** What `EditorView.posAtCoords` returns. */
3
+ export interface CoordsHit {
4
+ pos: number;
5
+ inside: number;
6
+ }
7
+ /**
8
+ * A top-level node whose children get a drag handle of their own: its
9
+ * `nodeName`, and the `contentSelector` of the element holding the children
10
+ * (the area the handle follows the child in, not the container's header).
11
+ */
12
+ export interface NestedContainer {
13
+ nodeName: string;
14
+ contentSelector: string;
15
+ }
16
+ /**
17
+ * Document position of the block under a hit at the given depth: 1 = top-level
18
+ * block, 2 = child of a top-level container. Falls back to the shallower
19
+ * block when the hit is not nested that deep.
20
+ */
21
+ export declare const blockPosAtDepth: (doc: ProseMirrorNode, hit: CoordsHit, depth: 1 | 2) => number | null;
22
+ /**
23
+ * The block the drag handle belongs to. Normally the top-level block; with
24
+ * the pointer in the content area of a nested container (`isPointerInContent`
25
+ * is asked with the container's position and the container) it is the child
26
+ * under the pointer. The only child of a container has no handle (`null`):
27
+ * moving it would leave an empty container behind, so the container moves as
28
+ * a whole.
29
+ */
30
+ export declare const resolveDragTarget: (doc: ProseMirrorNode, hit: CoordsHit, containers: readonly NestedContainer[], isPointerInContent: (containerPos: number, container: NestedContainer) => boolean) => number | null;
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Document position of the block under a hit at the given depth: 1 = top-level
3
+ * block, 2 = child of a top-level container. Falls back to the shallower
4
+ * block when the hit is not nested that deep.
5
+ */
6
+ export const blockPosAtDepth = (doc, hit, depth) => {
7
+ if (hit.inside >= 0) {
8
+ const $inside = doc.resolve(hit.inside);
9
+ return $inside.depth < depth ? hit.inside : $inside.before(depth);
10
+ }
11
+ // Between blocks.
12
+ const $pos = doc.resolve(hit.pos);
13
+ if ($pos.depth >= depth) {
14
+ return $pos.before(depth);
15
+ }
16
+ if ($pos.nodeAfter) {
17
+ return hit.pos;
18
+ }
19
+ return $pos.nodeBefore ? hit.pos - $pos.nodeBefore.nodeSize : null;
20
+ };
21
+ /**
22
+ * The block the drag handle belongs to. Normally the top-level block; with
23
+ * the pointer in the content area of a nested container (`isPointerInContent`
24
+ * is asked with the container's position and the container) it is the child
25
+ * under the pointer. The only child of a container has no handle (`null`):
26
+ * moving it would leave an empty container behind, so the container moves as
27
+ * a whole.
28
+ */
29
+ export const resolveDragTarget = (doc, hit, containers, isPointerInContent) => {
30
+ const top = blockPosAtDepth(doc, hit, 1);
31
+ if (top === null) {
32
+ return null;
33
+ }
34
+ const topNode = doc.nodeAt(top);
35
+ const container = containers.find((candidate) => candidate.nodeName === topNode?.type.name);
36
+ if (!topNode || !container || !isPointerInContent(top, container)) {
37
+ return top;
38
+ }
39
+ if (topNode.childCount <= 1) {
40
+ return null;
41
+ }
42
+ const child = blockPosAtDepth(doc, hit, 2);
43
+ // A hit on the container itself (e.g. its border) stays the container.
44
+ return child !== null && child > top && child < top + topNode.nodeSize
45
+ ? child
46
+ : top;
47
+ };
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Base styles of the rich-text editor: the writing area, paragraphs, lists,
3
+ * links, selected nodes and the drag handle. The left padding is where the
4
+ * drag handle sits.
5
+ */
6
+ export declare const RICH_TEXT_EDITOR_STYLES = "\n.rte-editor .ProseMirror {\n min-height: 160px;\n padding: 12px 16px 12px 40px;\n outline: none;\n font-size: 14px;\n line-height: 1.5;\n}\n.rte-editor .ProseMirror p { margin: 0 0 0.75em; }\n.rte-editor .ProseMirror ul { margin: 0 0 0.75em; padding-left: 1.5rem; list-style: disc; }\n.rte-editor .ProseMirror li p { margin: 0 0 0.25em; }\n.rte-editor .ProseMirror a {\n color: var(--fg-interactive, #3b82f6);\n text-decoration: underline;\n cursor: text;\n}\n.rte-editor .ProseMirror-selectednode,\n.rte-editor [data-selected=\"true\"] {\n outline: 2px solid var(--border-interactive, #3b82f6);\n outline-offset: 1px;\n}\n.rte-editor .ProseMirror-gapcursor:after { border-top-color: var(--fg-base, #111); }\n.rte-drag-handle {\n position: absolute;\n left: 10px;\n width: 22px;\n height: 22px;\n border-radius: 4px;\n color: var(--fg-muted, #9ca3af);\n font-size: 16px;\n line-height: 22px;\n text-align: center;\n cursor: grab;\n user-select: none;\n}\n.rte-drag-handle:hover {\n background: var(--bg-base-hover, #f4f4f5);\n color: var(--fg-base, #111);\n}\n.rte-drag-handle:active { cursor: grabbing; }\n";
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Base styles of the rich-text editor: the writing area, paragraphs, lists,
3
+ * links, selected nodes and the drag handle. The left padding is where the
4
+ * drag handle sits.
5
+ */
6
+ export const RICH_TEXT_EDITOR_STYLES = `
7
+ .rte-editor .ProseMirror {
8
+ min-height: 160px;
9
+ padding: 12px 16px 12px 40px;
10
+ outline: none;
11
+ font-size: 14px;
12
+ line-height: 1.5;
13
+ }
14
+ .rte-editor .ProseMirror p { margin: 0 0 0.75em; }
15
+ .rte-editor .ProseMirror ul { margin: 0 0 0.75em; padding-left: 1.5rem; list-style: disc; }
16
+ .rte-editor .ProseMirror li p { margin: 0 0 0.25em; }
17
+ .rte-editor .ProseMirror a {
18
+ color: var(--fg-interactive, #3b82f6);
19
+ text-decoration: underline;
20
+ cursor: text;
21
+ }
22
+ .rte-editor .ProseMirror-selectednode,
23
+ .rte-editor [data-selected="true"] {
24
+ outline: 2px solid var(--border-interactive, #3b82f6);
25
+ outline-offset: 1px;
26
+ }
27
+ .rte-editor .ProseMirror-gapcursor:after { border-top-color: var(--fg-base, #111); }
28
+ .rte-drag-handle {
29
+ position: absolute;
30
+ left: 10px;
31
+ width: 22px;
32
+ height: 22px;
33
+ border-radius: 4px;
34
+ color: var(--fg-muted, #9ca3af);
35
+ font-size: 16px;
36
+ line-height: 22px;
37
+ text-align: center;
38
+ cursor: grab;
39
+ user-select: none;
40
+ }
41
+ .rte-drag-handle:hover {
42
+ background: var(--bg-base-hover, #f4f4f5);
43
+ color: var(--fg-base, #111);
44
+ }
45
+ .rte-drag-handle:active { cursor: grabbing; }
46
+ `;
@@ -0,0 +1,9 @@
1
+ export { RichTextEditor } from "./RichTextEditor";
2
+ export { InsertMenu } from "./InsertMenu";
3
+ export { useRichTextEditor } from "./use-rich-text-editor";
4
+ export type { RichTextEditorConfig } from "./use-rich-text-editor";
5
+ export { filterSlashItems } from "./slash-items";
6
+ export type { SlashContext, SlashItem } from "./slash-items";
7
+ export type { NestedContainer } from "./drag-target";
8
+ export { isDefaultAllowedHref, normalizeLinkHref } from "./link-href";
9
+ export * from "./tiptap";
@@ -0,0 +1,6 @@
1
+ export { RichTextEditor } from "./RichTextEditor";
2
+ export { InsertMenu } from "./InsertMenu";
3
+ export { useRichTextEditor } from "./use-rich-text-editor";
4
+ export { filterSlashItems } from "./slash-items";
5
+ export { isDefaultAllowedHref, normalizeLinkHref } from "./link-href";
6
+ export * from "./tiptap";
@@ -0,0 +1,8 @@
1
+ /** Link targets allowed unless an editor says otherwise: http(s) and mailto. */
2
+ export declare const isDefaultAllowedHref: (href: string) => boolean;
3
+ /**
4
+ * A link target typed by the Admin to an allowed href: a bare address becomes
5
+ * `mailto:`, a bare host `https://`. `null` when `isAllowed` accepts nothing
6
+ * that results.
7
+ */
8
+ export declare const normalizeLinkHref: (input: string, isAllowed: (href: string) => boolean) => string | null;
@@ -0,0 +1,21 @@
1
+ const HAS_SCHEME = /^[a-z][a-z0-9+.-]*:/i;
2
+ /** Link targets allowed unless an editor says otherwise: http(s) and mailto. */
3
+ export const isDefaultAllowedHref = (href) => /^(https?:\/\/|mailto:)[^\s"<>]+$/i.test(href);
4
+ /**
5
+ * A link target typed by the Admin to an allowed href: a bare address becomes
6
+ * `mailto:`, a bare host `https://`. `null` when `isAllowed` accepts nothing
7
+ * that results.
8
+ */
9
+ export const normalizeLinkHref = (input, isAllowed) => {
10
+ const value = input.trim();
11
+ if (!value) {
12
+ return null;
13
+ }
14
+ let href = value;
15
+ if (!HAS_SCHEME.test(value)) {
16
+ href = /^[^\s@/]+@[^\s@/]+$/.test(value)
17
+ ? `mailto:${value}`
18
+ : `https://${value}`;
19
+ }
20
+ return isAllowed(href) ? href : null;
21
+ };
@@ -0,0 +1,13 @@
1
+ import { Extension } from "@tiptap/react";
2
+ import type { Editor } from "@tiptap/react";
3
+ interface LinkPolicyOptions {
4
+ isAllowedHref: (href: string) => boolean;
5
+ }
6
+ /**
7
+ * Holds the link policy of an editor in its storage, so the Link mark, the
8
+ * toolbar and the link prompt all read the same function from the editor.
9
+ */
10
+ export declare const LinkPolicy: Extension<LinkPolicyOptions, any>;
11
+ /** The link targets `editor` accepts; http(s) and mailto without a policy. */
12
+ export declare const getLinkPolicy: (editor: Editor) => ((href: string) => boolean);
13
+ export {};
@@ -0,0 +1,20 @@
1
+ import { Extension } from "@tiptap/react";
2
+ import { isDefaultAllowedHref } from "./link-href";
3
+ /**
4
+ * Holds the link policy of an editor in its storage, so the Link mark, the
5
+ * toolbar and the link prompt all read the same function from the editor.
6
+ */
7
+ export const LinkPolicy = Extension.create({
8
+ name: "linkPolicy",
9
+ addOptions() {
10
+ return { isAllowedHref: isDefaultAllowedHref };
11
+ },
12
+ addStorage() {
13
+ return { isAllowedHref: this.options.isAllowedHref };
14
+ },
15
+ });
16
+ /** The link targets `editor` accepts; http(s) and mailto without a policy. */
17
+ export const getLinkPolicy = (editor) => {
18
+ const storage = editor.storage;
19
+ return storage.linkPolicy?.isAllowedHref ?? isDefaultAllowedHref;
20
+ };
@@ -0,0 +1,13 @@
1
+ import { Extension } from "@tiptap/react";
2
+ import type { SlashContext, SlashItem } from "./slash-items";
3
+ interface SlashCommandOptions {
4
+ /** The entries for the typed query; already filtered by it. */
5
+ items: (context: SlashContext) => SlashItem[];
6
+ }
7
+ /**
8
+ * "/" at the start of a line or after a space opens a filterable list of what
9
+ * can be inserted. The entries come from the `items` option; Tiptap's
10
+ * suggestion plugin handles the trigger, Escape and the anchor position.
11
+ */
12
+ export declare const SlashCommand: Extension<SlashCommandOptions, any>;
13
+ export {};
@@ -0,0 +1,60 @@
1
+ import { Extension, ReactRenderer } from "@tiptap/react";
2
+ import Suggestion from "@tiptap/suggestion";
3
+ import { SlashMenu } from "./SlashMenu";
4
+ const POPUP_Z_INDEX = "60";
5
+ /**
6
+ * "/" at the start of a line or after a space opens a filterable list of what
7
+ * can be inserted. The entries come from the `items` option; Tiptap's
8
+ * suggestion plugin handles the trigger, Escape and the anchor position.
9
+ */
10
+ export const SlashCommand = Extension.create({
11
+ name: "slashCommand",
12
+ addOptions() {
13
+ return { items: () => [] };
14
+ },
15
+ addProseMirrorPlugins() {
16
+ const { items } = this.options;
17
+ return [
18
+ Suggestion({
19
+ editor: this.editor,
20
+ char: "/",
21
+ allowedPrefixes: [" "],
22
+ items: ({ query, editor }) => items({ query, editor }),
23
+ command: ({ editor, range, props }) => {
24
+ props.run(editor, range);
25
+ },
26
+ render: () => {
27
+ let component = null;
28
+ let unmount = null;
29
+ return {
30
+ onStart: (props) => {
31
+ component = new ReactRenderer(SlashMenu, {
32
+ props,
33
+ editor: props.editor,
34
+ });
35
+ component.element.style.zIndex = POPUP_Z_INDEX;
36
+ // The plugin mounts the popup, anchors it at the "/" and keeps
37
+ // it positioned with Floating UI.
38
+ unmount = props.mount(component.element);
39
+ },
40
+ onUpdate: (props) => {
41
+ component?.updateProps(props);
42
+ },
43
+ onKeyDown: ({ event }) => {
44
+ if (event.key === "Escape") {
45
+ return true;
46
+ }
47
+ return component?.ref?.onKeyDown(event) ?? false;
48
+ },
49
+ onExit: () => {
50
+ unmount?.();
51
+ unmount = null;
52
+ component?.destroy();
53
+ component = null;
54
+ },
55
+ };
56
+ },
57
+ }),
58
+ ];
59
+ },
60
+ });
@@ -0,0 +1,25 @@
1
+ import type { Editor, Range } from "@tiptap/react";
2
+ /** One entry of the slash menu. */
3
+ export interface SlashItem<T = unknown> {
4
+ /** Unique within one menu. */
5
+ id: string;
6
+ label: string;
7
+ /** What the entry is, shown beside the label. */
8
+ hint?: string;
9
+ /** The owner's own description of the entry, for its own code and tests. */
10
+ data: T;
11
+ /** Runs the entry; `range` is the typed "/query", still in the document. */
12
+ run: (editor: Editor, range: Range) => void;
13
+ }
14
+ /** What the slash menu knows when it asks for its entries. */
15
+ export interface SlashContext {
16
+ query: string;
17
+ editor: Editor;
18
+ }
19
+ /**
20
+ * The entries whose label contains the typed query (case-insensitive, outer
21
+ * whitespace ignored); all of them for an empty query.
22
+ */
23
+ export declare const filterSlashItems: <I extends {
24
+ label: string;
25
+ }>(items: I[], query: string) => I[];
@@ -0,0 +1,10 @@
1
+ /**
2
+ * The entries whose label contains the typed query (case-insensitive, outer
3
+ * whitespace ignored); all of them for an empty query.
4
+ */
5
+ export const filterSlashItems = (items, query) => {
6
+ const needle = query.trim().toLowerCase();
7
+ return needle
8
+ ? items.filter((item) => item.label.toLowerCase().includes(needle))
9
+ : items;
10
+ };
@@ -0,0 +1,7 @@
1
+ /**
2
+ * TipTap building blocks for nodes and marks written outside of base, so a
3
+ * plugin needs no @tiptap dependency (and no second copy of it) of its own.
4
+ */
5
+ export { Extension, Mark, mergeAttributes, Node, NodeViewContent, NodeViewWrapper, ReactNodeViewRenderer, useEditorState, } from "@tiptap/react";
6
+ export { NodeSelection, Plugin, PluginKey, TextSelection, } from "@tiptap/pm/state";
7
+ export type { AnyExtension, ChainedCommands, Editor, JSONContent, NodeViewProps, Range, } from "@tiptap/react";
@@ -0,0 +1,7 @@
1
+ /**
2
+ * TipTap building blocks for nodes and marks written outside of base, so a
3
+ * plugin needs no @tiptap dependency (and no second copy of it) of its own.
4
+ */
5
+ export { Extension, Mark, mergeAttributes, Node, NodeViewContent, NodeViewWrapper, ReactNodeViewRenderer, useEditorState, } from "@tiptap/react";
6
+ // ProseMirror pieces that extension authors need (plugins, selections).
7
+ export { NodeSelection, Plugin, PluginKey, TextSelection, } from "@tiptap/pm/state";