qarpeo 0.4.12 → 0.4.14

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 (299) hide show
  1. package/README.md +12 -6
  2. package/dist/apps/cms.d.ts +1 -1
  3. package/dist/apps/comments.d.ts +1 -1
  4. package/dist/apps/payments.d.ts +1 -1
  5. package/dist/apps/store.d.ts +1 -1
  6. package/dist/chunks/{manifest.get.mjs → tools.mjs} +445 -430
  7. package/dist/cli/index.mjs +756 -746
  8. package/dist/core/aliases.d.ts +1 -1
  9. package/dist/core/context.d.ts +1 -1
  10. package/dist/core/d1-migrate.d.ts +1 -1
  11. package/dist/core/devtools.d.ts +1 -1
  12. package/dist/core/nitro.d.ts +1 -1
  13. package/dist/core/schema.d.ts +1 -1
  14. package/dist/core/server-utils.d.ts +1 -1
  15. package/dist/core/wrangler.d.ts +1 -1
  16. package/dist/fate/index.d.ts +8 -8
  17. package/dist/fate/index.mjs +3 -1
  18. package/dist/features/agents.d.ts +1 -1
  19. package/dist/features/auth.d.ts +1 -1
  20. package/dist/features/bots.d.ts +1 -1
  21. package/dist/features/console.d.ts +1 -1
  22. package/dist/features/fate.d.ts +1 -1
  23. package/dist/features/mail.d.ts +1 -1
  24. package/dist/features/mcp.d.ts +1 -1
  25. package/dist/features/multitenant.d.ts +1 -1
  26. package/dist/features/notifications.d.ts +1 -1
  27. package/dist/features/realtime.d.ts +1 -1
  28. package/dist/features/studio.d.ts +4 -0
  29. package/dist/module.d.ts +1 -1
  30. package/dist/module.mjs +5293 -5232
  31. package/dist/primitives/ai.d.ts +1 -1
  32. package/dist/primitives/analytics.d.ts +1 -1
  33. package/dist/primitives/blob.d.ts +1 -1
  34. package/dist/primitives/browser.d.ts +1 -1
  35. package/dist/primitives/cache.d.ts +1 -1
  36. package/dist/primitives/d1.d.ts +1 -1
  37. package/dist/primitives/do.d.ts +1 -1
  38. package/dist/primitives/email.d.ts +1 -1
  39. package/dist/primitives/hyperdrive.d.ts +1 -1
  40. package/dist/primitives/kv.d.ts +1 -1
  41. package/dist/primitives/queue.d.ts +1 -1
  42. package/dist/primitives/ratelimit.d.ts +1 -1
  43. package/dist/primitives/vectorize.d.ts +1 -1
  44. package/dist/primitives/workflows.d.ts +1 -1
  45. package/dist/runtime/ai.mjs +4 -1
  46. package/dist/runtime/app/components/CMSEditor.vue +439 -0
  47. package/dist/runtime/app/components/CMSEditorImageNode.vue +90 -0
  48. package/dist/runtime/app/components/CMSEditorLinkPopover.vue +120 -0
  49. package/dist/runtime/app/components/QDropZone.vue +327 -0
  50. package/dist/runtime/app/components/QImageCropper.vue +658 -0
  51. package/dist/runtime/app/components/QImageStudio.vue +300 -0
  52. package/dist/runtime/app/components/QImg.vue +7 -4
  53. package/dist/runtime/app/composables/analytics.d.ts +8 -8
  54. package/dist/runtime/app/composables/api-tokens.d.ts +5 -5
  55. package/dist/runtime/app/composables/auth.d.ts +23 -19
  56. package/dist/runtime/app/composables/chat.d.ts +7 -6
  57. package/dist/runtime/app/composables/cms-preview.d.ts +7 -8
  58. package/dist/runtime/app/composables/cms.d.ts +6 -6
  59. package/dist/runtime/app/composables/comments.d.ts +5 -5
  60. package/dist/runtime/app/composables/comments.mjs +7 -4
  61. package/dist/runtime/app/composables/console.d.ts +6 -14
  62. package/dist/runtime/app/composables/docs-version.d.ts +8 -8
  63. package/dist/runtime/app/composables/impersonation.d.ts +5 -5
  64. package/dist/runtime/app/composables/organization.d.ts +5 -5
  65. package/dist/runtime/app/composables/passkey.d.ts +5 -5
  66. package/dist/runtime/app/composables/passwordless.d.ts +5 -5
  67. package/dist/runtime/app/composables/payments.d.ts +5 -5
  68. package/dist/runtime/app/composables/rbac.d.ts +5 -5
  69. package/dist/runtime/app/composables/site.d.ts +2 -2
  70. package/dist/runtime/app/composables/sse.d.ts +20 -33
  71. package/dist/runtime/app/composables/sse.mjs +6 -3
  72. package/dist/runtime/app/composables/storage.d.ts +6 -8
  73. package/dist/runtime/app/composables/store.d.ts +37 -36
  74. package/dist/runtime/app/composables/store.mjs +7 -6
  75. package/dist/runtime/app/composables/studio.d.ts +59 -0
  76. package/dist/runtime/app/composables/studio.mjs +129 -0
  77. package/dist/runtime/app/composables/tenant.d.ts +7 -7
  78. package/dist/runtime/app/composables/turnstile.d.ts +5 -5
  79. package/dist/runtime/app/composables/two-factor.d.ts +5 -5
  80. package/dist/runtime/app/pages/devtools/notifications.vue +1 -6
  81. package/dist/runtime/app/plugins/pwa.mjs +1 -3
  82. package/dist/runtime/app/utils/cms-editor.d.ts +25 -0
  83. package/dist/runtime/app/utils/cms-editor.mjs +43 -0
  84. package/dist/runtime/auth.d.ts +9 -9
  85. package/dist/runtime/blob.d.ts +1 -3
  86. package/dist/runtime/blob.mjs +3 -1
  87. package/dist/runtime/cache.d.ts +8 -6
  88. package/dist/runtime/cache.mjs +8 -11
  89. package/dist/runtime/db.d.ts +4 -3
  90. package/dist/runtime/drizzle.d.ts +2 -1
  91. package/dist/runtime/drizzle.mjs +2 -2
  92. package/dist/runtime/queue.d.ts +1 -0
  93. package/dist/runtime/replica.d.ts +6 -10
  94. package/dist/runtime/replica.mjs +3 -1
  95. package/dist/runtime/schema-mysql.d.ts +16 -32
  96. package/dist/runtime/schema-pg.d.ts +15 -31
  97. package/dist/runtime/schema-shared.d.ts +20 -17
  98. package/dist/runtime/schema.d.ts +21 -33
  99. package/dist/runtime/server/durable-objects/agent.mjs +4 -1
  100. package/dist/runtime/server/durable-objects/room.d.ts +4 -6
  101. package/dist/runtime/server/durable-objects/room.mjs +18 -8
  102. package/dist/runtime/server/plugins/comments.d.ts +2 -3
  103. package/dist/runtime/server/plugins/email-inbound.d.ts +1 -3
  104. package/dist/runtime/server/plugins/store.d.ts +2 -3
  105. package/dist/runtime/server/routes/__qarpeo/cloud/agents/run.post.d.ts +2 -2
  106. package/dist/runtime/server/routes/__qarpeo/cloud/cms/entry.get.mjs +10 -2
  107. package/dist/runtime/server/routes/__qarpeo/cloud/cms/entry.post.d.ts +2 -2
  108. package/dist/runtime/server/routes/__qarpeo/cloud/cms/entry.post.mjs +10 -2
  109. package/dist/runtime/server/routes/__qarpeo/cloud/cms.get.d.ts +2 -2
  110. package/dist/runtime/server/routes/__qarpeo/cloud/cms.get.mjs +7 -1
  111. package/dist/runtime/server/routes/__qarpeo/cloud/comments/moderate.post.d.ts +2 -2
  112. package/dist/runtime/server/routes/__qarpeo/cloud/comments/moderate.post.mjs +5 -1
  113. package/dist/runtime/server/routes/__qarpeo/cloud/comments.get.d.ts +1 -3
  114. package/dist/runtime/server/routes/__qarpeo/cloud/extras.get.d.ts +2 -2
  115. package/dist/runtime/server/routes/__qarpeo/cloud/extras.get.mjs +15 -4
  116. package/dist/runtime/server/routes/__qarpeo/cloud/mail/unsuppress.post.d.ts +2 -2
  117. package/dist/runtime/server/routes/__qarpeo/cloud/migrate/cms.post.mjs +13 -4
  118. package/dist/runtime/server/routes/__qarpeo/cloud/migrate/products.post.mjs +1 -1
  119. package/dist/runtime/server/routes/__qarpeo/cloud/migrate.post.d.ts +3 -3
  120. package/dist/runtime/server/routes/__qarpeo/cloud/migrate.post.mjs +22 -6
  121. package/dist/runtime/server/routes/__qarpeo/cloud/notifications/test.post.d.ts +2 -2
  122. package/dist/runtime/server/routes/__qarpeo/cloud/operations.get.d.ts +6 -5
  123. package/dist/runtime/server/routes/__qarpeo/cloud/store/order-status.post.d.ts +1 -3
  124. package/dist/runtime/server/routes/__qarpeo/cloud/store/order-status.post.mjs +14 -2
  125. package/dist/runtime/server/routes/__qarpeo/cloud/store/orders.get.d.ts +1 -3
  126. package/dist/runtime/server/routes/__qarpeo/cloud/store/orders.get.mjs +7 -1
  127. package/dist/runtime/server/routes/__qarpeo/cloud/store/products.get.d.ts +1 -3
  128. package/dist/runtime/server/routes/__qarpeo/cloud/tasks/run.post.d.ts +2 -2
  129. package/dist/runtime/server/routes/__qarpeo/cloud/users/action.post.d.ts +2 -2
  130. package/dist/runtime/server/routes/__qarpeo/cloud/users/action.post.mjs +5 -1
  131. package/dist/runtime/server/routes/__qarpeo/cloud/users.get.d.ts +6 -5
  132. package/dist/runtime/server/routes/__qarpeo/cloud/users.get.mjs +1 -3
  133. package/dist/runtime/server/routes/__qarpeo/mail/track/click/[id].get.mjs +2 -2
  134. package/dist/runtime/server/routes/__qarpeo/manifest.get.d.ts +2 -2
  135. package/dist/runtime/server/routes/__qarpeo/og.get.d.ts +2 -2
  136. package/dist/runtime/server/routes/__qarpeo/rbac/me.get.d.ts +2 -2
  137. package/dist/runtime/server/routes/__qarpeo/rbac/roles.delete.d.ts +2 -2
  138. package/dist/runtime/server/routes/__qarpeo/rbac/roles.delete.mjs +5 -1
  139. package/dist/runtime/server/routes/__qarpeo/rbac/roles.get.d.ts +2 -2
  140. package/dist/runtime/server/routes/__qarpeo/rbac/roles.get.mjs +1 -5
  141. package/dist/runtime/server/routes/__qarpeo/rbac/roles.post.d.ts +2 -2
  142. package/dist/runtime/server/routes/__qarpeo/rbac/roles.post.mjs +5 -1
  143. package/dist/runtime/server/routes/__qarpeo/rbac/users.post.d.ts +2 -2
  144. package/dist/runtime/server/routes/agents/[agent]/chat.post.mjs +1 -6
  145. package/dist/runtime/server/routes/agents/[agent]/clear.post.mjs +1 -6
  146. package/dist/runtime/server/routes/agents/[agent]/history.get.mjs +1 -6
  147. package/dist/runtime/server/routes/auth/2fa/disable.post.mjs +5 -1
  148. package/dist/runtime/server/routes/auth/2fa/verify.post.mjs +7 -1
  149. package/dist/runtime/server/routes/auth/magic-link/send.post.mjs +1 -1
  150. package/dist/runtime/server/routes/auth/otp/send.post.mjs +1 -1
  151. package/dist/runtime/server/routes/cms/search.get.mjs +2 -6
  152. package/dist/runtime/server/routes/comments/[id]/report.post.mjs +1 -4
  153. package/dist/runtime/server/routes/comments/[id].patch.mjs +1 -4
  154. package/dist/runtime/server/routes/comments/batch.post.mjs +1 -3
  155. package/dist/runtime/server/routes/comments/index.post.mjs +1 -5
  156. package/dist/runtime/server/routes/fate.mjs +1 -1
  157. package/dist/runtime/server/routes/mail/webhooks.post.mjs +1 -1
  158. package/dist/runtime/server/routes/sitemap.xml.get.mjs +2 -1
  159. package/dist/runtime/server/routes/storage/presigned-r2.post.d.ts +5 -6
  160. package/dist/runtime/server/routes/storage/presigned-r2.post.mjs +1 -1
  161. package/dist/runtime/server/routes/store/cart/items/[id].delete.mjs +1 -1
  162. package/dist/runtime/server/routes/store/cart/items/[id].patch.mjs +1 -1
  163. package/dist/runtime/server/routes/store/currencies.get.mjs +1 -4
  164. package/dist/runtime/server/routes/store/orders/[id].get.mjs +1 -1
  165. package/dist/runtime/server/routes/store/orders/download/[token].get.mjs +13 -4
  166. package/dist/runtime/server/routes/store/orders/index.get.mjs +1 -1
  167. package/dist/runtime/server/routes/store/tax/calculate.post.d.ts +2 -1
  168. package/dist/runtime/server/routes/store/tax/calculate.post.mjs +12 -3
  169. package/dist/runtime/server/routes/tenants/[tenant]/domains/[domain]/index.delete.mjs +4 -1
  170. package/dist/runtime/server/routes/tenants/[tenant]/domains/[domain]/verify.post.mjs +4 -1
  171. package/dist/runtime/server/utils/ai.d.ts +38 -35
  172. package/dist/runtime/server/utils/ai.mjs +7 -11
  173. package/dist/runtime/server/utils/analytics-query.d.ts +4 -4
  174. package/dist/runtime/server/utils/auth.d.ts +25 -25
  175. package/dist/runtime/server/utils/auth.mjs +22 -8
  176. package/dist/runtime/server/utils/bots.d.ts +7 -7
  177. package/dist/runtime/server/utils/browser-utils.d.ts +26 -27
  178. package/dist/runtime/server/utils/cache.d.ts +20 -20
  179. package/dist/runtime/server/utils/cms/collections.mjs +1 -6
  180. package/dist/runtime/server/utils/cms/common.mjs +1 -0
  181. package/dist/runtime/server/utils/cms/markdown.d.ts +2 -2
  182. package/dist/runtime/server/utils/cms/markdown.mjs +5 -5
  183. package/dist/runtime/server/utils/cms/mutations.mjs +8 -23
  184. package/dist/runtime/server/utils/cms/navigation.mjs +4 -4
  185. package/dist/runtime/server/utils/cms/path.d.ts +1 -0
  186. package/dist/runtime/server/utils/cms/path.mjs +8 -2
  187. package/dist/runtime/server/utils/cms/references.mjs +1 -7
  188. package/dist/runtime/server/utils/cms/search.d.ts +2 -2
  189. package/dist/runtime/server/utils/cms/sync.mjs +4 -2
  190. package/dist/runtime/server/utils/cms/taxonomy.d.ts +2 -2
  191. package/dist/runtime/server/utils/cms.d.ts +1 -1
  192. package/dist/runtime/server/utils/cms.mjs +1 -5
  193. package/dist/runtime/server/utils/comments-filter.d.ts +9 -7
  194. package/dist/runtime/server/utils/comments.d.ts +68 -55
  195. package/dist/runtime/server/utils/comments.mjs +21 -9
  196. package/dist/runtime/server/utils/config.d.ts +2 -2
  197. package/dist/runtime/server/utils/console.d.ts +3 -5
  198. package/dist/runtime/server/utils/context.d.ts +10 -10
  199. package/dist/runtime/server/utils/crypto.d.ts +20 -20
  200. package/dist/runtime/server/utils/domains.mjs +3 -1
  201. package/dist/runtime/server/utils/drizzle.d.ts +24 -25
  202. package/dist/runtime/server/utils/drizzle.mjs +17 -17
  203. package/dist/runtime/server/utils/durable-object.d.ts +27 -25
  204. package/dist/runtime/server/utils/durable-object.mjs +3 -10
  205. package/dist/runtime/server/utils/email-inbound.d.ts +10 -10
  206. package/dist/runtime/server/utils/impersonation.d.ts +18 -18
  207. package/dist/runtime/server/utils/legacy-hash.d.ts +23 -27
  208. package/dist/runtime/server/utils/lock.d.ts +20 -23
  209. package/dist/runtime/server/utils/mail.d.ts +19 -19
  210. package/dist/runtime/server/utils/mail.mjs +4 -2
  211. package/dist/runtime/server/utils/mcp.d.ts +20 -20
  212. package/dist/runtime/server/utils/mcp.mjs +22 -38
  213. package/dist/runtime/server/utils/notifications.d.ts +49 -38
  214. package/dist/runtime/server/utils/oauth.d.ts +3 -9
  215. package/dist/runtime/server/utils/organization.d.ts +28 -28
  216. package/dist/runtime/server/utils/organization.mjs +15 -5
  217. package/dist/runtime/server/utils/passwordless.d.ts +24 -24
  218. package/dist/runtime/server/utils/payments/checkout.d.ts +12 -12
  219. package/dist/runtime/server/utils/payments/checkout.mjs +1 -3
  220. package/dist/runtime/server/utils/payments/common.d.ts +3 -3
  221. package/dist/runtime/server/utils/payments/paddle.d.ts +4 -1
  222. package/dist/runtime/server/utils/payments/polar.d.ts +4 -1
  223. package/dist/runtime/server/utils/payments/stripe.mjs +5 -7
  224. package/dist/runtime/server/utils/payments/subscriptions.d.ts +14 -14
  225. package/dist/runtime/server/utils/payments/subscriptions.mjs +2 -6
  226. package/dist/runtime/server/utils/payments/usage.mjs +1 -3
  227. package/dist/runtime/server/utils/payments/webhooks.mjs +2 -2
  228. package/dist/runtime/server/utils/queue.d.ts +54 -58
  229. package/dist/runtime/server/utils/queue.mjs +2 -6
  230. package/dist/runtime/server/utils/rag.d.ts +23 -23
  231. package/dist/runtime/server/utils/rag.mjs +10 -5
  232. package/dist/runtime/server/utils/ratelimit.d.ts +21 -18
  233. package/dist/runtime/server/utils/rbac.d.ts +13 -15
  234. package/dist/runtime/server/utils/rbac.mjs +44 -10
  235. package/dist/runtime/server/utils/realtime.d.ts +53 -52
  236. package/dist/runtime/server/utils/role-env.d.ts +5 -4
  237. package/dist/runtime/server/utils/scheduled-task.d.ts +14 -15
  238. package/dist/runtime/server/utils/session.d.ts +40 -40
  239. package/dist/runtime/server/utils/sse.d.ts +23 -33
  240. package/dist/runtime/server/utils/sse.mjs +5 -14
  241. package/dist/runtime/server/utils/sso.mjs +3 -1
  242. package/dist/runtime/server/utils/storage.d.ts +20 -22
  243. package/dist/runtime/server/utils/storage.mjs +2 -2
  244. package/dist/runtime/server/utils/store/cart.d.ts +5 -3
  245. package/dist/runtime/server/utils/store/cart.mjs +14 -10
  246. package/dist/runtime/server/utils/store/checkout.mjs +4 -1
  247. package/dist/runtime/server/utils/store/common.d.ts +1 -1
  248. package/dist/runtime/server/utils/store/common.mjs +36 -12
  249. package/dist/runtime/server/utils/store/inventory.mjs +3 -1
  250. package/dist/runtime/server/utils/store/orders.mjs +32 -24
  251. package/dist/runtime/server/utils/store-localization.d.ts +9 -27
  252. package/dist/runtime/server/utils/store-localization.mjs +3 -3
  253. package/dist/runtime/server/utils/table-names.d.ts +15 -15
  254. package/dist/runtime/server/utils/table-names.mjs +1 -1
  255. package/dist/runtime/server/utils/tenant.d.ts +12 -12
  256. package/dist/runtime/server/utils/tenant.mjs +7 -4
  257. package/dist/runtime/server/utils/totp.d.ts +18 -18
  258. package/dist/runtime/server/utils/tracker.d.ts +5 -5
  259. package/dist/runtime/server/utils/turnstile.d.ts +9 -9
  260. package/dist/runtime/server/utils/urn.d.ts +5 -8
  261. package/dist/runtime/server/utils/workflows.d.ts +30 -31
  262. package/dist/runtime/server/utils/workflows.mjs +2 -4
  263. package/dist/runtime/server.d.ts +2 -2
  264. package/dist/runtime/service.d.ts +10 -10
  265. package/dist/runtime/test-utils.d.ts +10 -10
  266. package/dist/runtime/test-utils.mjs +9 -2
  267. package/dist/runtime/types/ai.d.ts +14 -14
  268. package/dist/runtime/types/d1.d.ts +6 -11
  269. package/dist/runtime/types/durable-object.d.ts +4 -8
  270. package/dist/runtime/types/email.d.ts +3 -9
  271. package/dist/runtime/types/index.d.ts +15 -21
  272. package/dist/runtime/types/r2.d.ts +5 -5
  273. package/dist/runtime/types/workflows.d.ts +5 -6
  274. package/dist/runtime/workflows.d.ts +1 -3
  275. package/dist/types/ai.d.ts +10 -17
  276. package/dist/types/auth.d.ts +5 -3
  277. package/dist/types/cache.d.ts +7 -7
  278. package/dist/types/cms.d.ts +30 -5
  279. package/dist/types/comments.d.ts +23 -21
  280. package/dist/types/console.d.ts +1 -3
  281. package/dist/types/db.d.ts +7 -7
  282. package/dist/types/index.d.ts +1 -0
  283. package/dist/types/options.d.ts +36 -24
  284. package/dist/types/site.d.ts +8 -2
  285. package/dist/types/storage.d.ts +2 -1
  286. package/dist/types/store-options.d.ts +10 -26
  287. package/dist/types/studio.d.ts +79 -0
  288. package/dist/utils/bots.d.ts +7 -3
  289. package/dist/utils/cms-table-names.d.ts +1 -1
  290. package/dist/utils/drizzle.d.ts +13 -14
  291. package/dist/utils/email-inbound.d.ts +4 -4
  292. package/dist/utils/features.d.ts +19 -5
  293. package/dist/utils/mcp.d.ts +1 -0
  294. package/dist/utils/migration-lock.d.ts +15 -29
  295. package/dist/utils/pkg.d.ts +6 -7
  296. package/dist/utils/schema-diff.d.ts +7 -11
  297. package/dist/utils/store-schema.d.ts +4 -6
  298. package/dist/utils/tools.d.ts +3 -3
  299. package/package.json +55 -5
@@ -0,0 +1,120 @@
1
+ <script setup lang="ts">
2
+ import type { Editor } from "@tiptap/vue-3"
3
+ import { computed, ref, watch } from "vue"
4
+
5
+ const props = defineProps<{
6
+ editor: Editor
7
+ autoOpen?: boolean
8
+ }>()
9
+
10
+ const open = ref(false)
11
+ const url = ref("")
12
+
13
+ const active = computed(() => props.editor.isActive("link"))
14
+ const disabled = computed(() => {
15
+ if (!props.editor.isEditable) return true
16
+ const { selection } = props.editor.state
17
+ return selection.empty && !props.editor.isActive("link")
18
+ })
19
+
20
+ watch(
21
+ () => props.editor,
22
+ (editor, _, onCleanup) => {
23
+ if (!editor) return
24
+ const updateUrl = () => {
25
+ const { href } = editor.getAttributes("link")
26
+ url.value = href || ""
27
+ }
28
+ updateUrl()
29
+ editor.on("selectionUpdate", updateUrl)
30
+ onCleanup(() => {
31
+ editor.off("selectionUpdate", updateUrl)
32
+ })
33
+ },
34
+ { immediate: true },
35
+ )
36
+
37
+ watch(active, (isActive) => {
38
+ if (isActive && props.autoOpen) {
39
+ open.value = true
40
+ }
41
+ })
42
+
43
+ function setLink() {
44
+ if (!url.value) return
45
+ const { selection } = props.editor.state
46
+ const isEmpty = selection.empty
47
+ const hasCode = props.editor.isActive("code")
48
+
49
+ let chain = props.editor.chain().focus()
50
+ if (hasCode && !isEmpty) {
51
+ chain = chain.extendMarkRange("code").setLink({ href: url.value })
52
+ } else {
53
+ chain = chain.extendMarkRange("link").setLink({ href: url.value })
54
+ if (isEmpty) {
55
+ chain = chain.insertContent({ type: "text", text: url.value })
56
+ }
57
+ }
58
+ chain.run()
59
+ open.value = false
60
+ }
61
+
62
+ function removeLink() {
63
+ props.editor
64
+ .chain()
65
+ .focus()
66
+ .extendMarkRange("link")
67
+ .unsetLink()
68
+ .setMeta("preventAutolink", true)
69
+ .run()
70
+ url.value = ""
71
+ open.value = false
72
+ }
73
+ </script>
74
+
75
+ <template>
76
+ <UPopover v-model:open="open" :ui="{ content: 'p-1' }">
77
+ <UTooltip text="Link">
78
+ <UButton
79
+ icon="i-lucide-link"
80
+ color="neutral"
81
+ variant="ghost"
82
+ size="sm"
83
+ :active="active"
84
+ active-color="primary"
85
+ active-variant="soft"
86
+ :disabled="disabled"
87
+ />
88
+ </UTooltip>
89
+
90
+ <template #content>
91
+ <div class="flex items-center gap-1">
92
+ <UInput
93
+ v-model="url"
94
+ type="url"
95
+ placeholder="Paste a link..."
96
+ size="sm"
97
+ variant="none"
98
+ autofocus
99
+ @keydown.enter.prevent="setLink"
100
+ />
101
+ <UButton
102
+ icon="i-lucide-corner-down-left"
103
+ color="neutral"
104
+ variant="ghost"
105
+ size="sm"
106
+ :disabled="!url"
107
+ @click="setLink"
108
+ />
109
+ <UButton
110
+ v-if="active"
111
+ icon="i-lucide-trash"
112
+ color="error"
113
+ variant="ghost"
114
+ size="sm"
115
+ @click="removeLink"
116
+ />
117
+ </div>
118
+ </template>
119
+ </UPopover>
120
+ </template>
@@ -0,0 +1,327 @@
1
+ <script lang="ts" setup>
2
+ import { ref } from "vue"
3
+
4
+ import { fileToDataUrl, urlToDataUrl } from "../composables/studio"
5
+
6
+ const props = withDefaults(
7
+ defineProps<{
8
+ accept?: string
9
+ disabled?: boolean
10
+ multiple?: boolean
11
+ maxSize?: number
12
+ showUrlInput?: boolean
13
+ label?: string
14
+ hint?: string
15
+ }>(),
16
+ {
17
+ accept: "image/*",
18
+ disabled: false,
19
+ multiple: false,
20
+ showUrlInput: true,
21
+ label: "Drop an image here",
22
+ hint: "Supports PNG, JPG, WebP or paste from clipboard",
23
+ },
24
+ )
25
+
26
+ const emit = defineEmits<{
27
+ load: [dataUrl: string, file?: File]
28
+ files: [files: File[]]
29
+ error: [message: string]
30
+ }>()
31
+
32
+ const isDragging = ref(false)
33
+ const urlInput = ref("")
34
+ const urlError = ref("")
35
+ const isLoadingUrl = ref(false)
36
+ const fileInputRef = ref<HTMLInputElement>()
37
+
38
+ function validateFile(file: File): boolean {
39
+ if (props.maxSize && file.size > props.maxSize) {
40
+ const mb = (props.maxSize / (1024 * 1024)).toFixed(1)
41
+ const msg = `File exceeds maximum size of ${mb} MB`
42
+ urlError.value = msg
43
+ emit("error", msg)
44
+ return false
45
+ }
46
+ return true
47
+ }
48
+
49
+ async function handleFiles(fileList: File[] | null) {
50
+ if (props.disabled || !fileList || fileList.length === 0) return
51
+ urlError.value = ""
52
+
53
+ const valid = fileList.filter(validateFile)
54
+ if (valid.length === 0) return
55
+
56
+ emit("files", valid)
57
+
58
+ const first = valid[0]
59
+ if (first && first.type.startsWith("image/")) {
60
+ try {
61
+ const dataUrl = await fileToDataUrl(first)
62
+ emit("load", dataUrl, first)
63
+ } catch (err) {
64
+ const msg = err instanceof Error ? err.message : "Failed to read file"
65
+ urlError.value = msg
66
+ emit("error", msg)
67
+ }
68
+ }
69
+ }
70
+
71
+ function onDragOver(e: DragEvent) {
72
+ if (props.disabled) return
73
+ e.preventDefault()
74
+ isDragging.value = true
75
+ }
76
+
77
+ function onDragLeave(e: DragEvent) {
78
+ if (e.currentTarget === e.target) {
79
+ isDragging.value = false
80
+ }
81
+ }
82
+
83
+ async function onDrop(e: DragEvent) {
84
+ e.preventDefault()
85
+ isDragging.value = false
86
+ if (props.disabled) return
87
+ const files = e.dataTransfer?.files ? Array.from(e.dataTransfer.files) : null
88
+ await handleFiles(files)
89
+ }
90
+
91
+ async function onPaste(e: ClipboardEvent) {
92
+ if (props.disabled) return
93
+ const items = e.clipboardData?.files
94
+ if (items && items.length > 0) {
95
+ await handleFiles(Array.from(items))
96
+ }
97
+ }
98
+
99
+ async function onFileChange(e: Event) {
100
+ const target = e.target as HTMLInputElement
101
+ const files = target.files ? Array.from(target.files) : null
102
+ await handleFiles(files)
103
+ if (fileInputRef.value) fileInputRef.value.value = ""
104
+ }
105
+
106
+ async function loadFromUrl() {
107
+ urlError.value = ""
108
+ const url = urlInput.value.trim()
109
+ if (!url) return
110
+ isLoadingUrl.value = true
111
+ try {
112
+ const dataUrl = await urlToDataUrl(url)
113
+ emit("load", dataUrl)
114
+ urlInput.value = ""
115
+ } catch (err) {
116
+ const msg = err instanceof Error ? err.message : "Failed to load image from URL"
117
+ urlError.value = msg
118
+ emit("error", msg)
119
+ } finally {
120
+ isLoadingUrl.value = false
121
+ }
122
+ }
123
+
124
+ function openFilePicker() {
125
+ if (!props.disabled) fileInputRef.value?.click()
126
+ }
127
+
128
+ defineExpose({
129
+ openFilePicker,
130
+ })
131
+ </script>
132
+
133
+ <template>
134
+ <div
135
+ class="q-dropzone"
136
+ :class="{ 'is-dragging': isDragging, 'is-disabled': disabled }"
137
+ tabindex="0"
138
+ @dragover="onDragOver"
139
+ @dragleave="onDragLeave"
140
+ @drop="onDrop"
141
+ @paste="onPaste"
142
+ >
143
+ <input
144
+ ref="fileInputRef"
145
+ type="file"
146
+ :accept="accept"
147
+ :multiple="multiple"
148
+ :disabled="disabled"
149
+ class="q-dropzone-input"
150
+ @change="onFileChange"
151
+ />
152
+
153
+ <slot :open-file-picker="openFilePicker" :is-dragging="isDragging">
154
+ <div class="q-dropzone-body">
155
+ <div class="q-dropzone-icon" aria-hidden="true">
156
+ <svg
157
+ xmlns="http://www.w3.org/2000/svg"
158
+ width="28"
159
+ height="28"
160
+ viewBox="0 0 24 24"
161
+ fill="none"
162
+ stroke="currentColor"
163
+ stroke-width="1.75"
164
+ stroke-linecap="round"
165
+ stroke-linejoin="round"
166
+ >
167
+ <path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" />
168
+ <polyline points="17 8 12 3 7 8" />
169
+ <line x1="12" x2="12" y1="3" y2="15" />
170
+ </svg>
171
+ </div>
172
+
173
+ <p class="q-dropzone-title">{{ label }}</p>
174
+ <p class="q-dropzone-hint">{{ hint }}</p>
175
+
176
+ <UButton
177
+ icon="i-lucide-upload"
178
+ label="Choose File"
179
+ color="primary"
180
+ variant="solid"
181
+ size="sm"
182
+ :disabled="disabled"
183
+ @click="openFilePicker"
184
+ />
185
+
186
+ <div v-if="showUrlInput" class="q-dropzone-url">
187
+ <UInput
188
+ v-model="urlInput"
189
+ type="url"
190
+ placeholder="Or paste image URL..."
191
+ size="sm"
192
+ :disabled="disabled || isLoadingUrl"
193
+ class="flex-1"
194
+ @keydown.enter.prevent="loadFromUrl"
195
+ />
196
+ <UButton
197
+ :label="isLoadingUrl ? 'Loading...' : 'Load'"
198
+ :loading="isLoadingUrl"
199
+ color="neutral"
200
+ variant="outline"
201
+ size="sm"
202
+ :disabled="disabled || isLoadingUrl || !urlInput.trim()"
203
+ @click="loadFromUrl"
204
+ />
205
+ </div>
206
+
207
+ <p v-if="urlError" class="q-dropzone-error">{{ urlError }}</p>
208
+ </div>
209
+ </slot>
210
+ </div>
211
+ </template>
212
+
213
+ <style scoped>
214
+ .q-dropzone {
215
+ position: relative;
216
+ display: flex;
217
+ align-items: center;
218
+ justify-content: center;
219
+ width: 100%;
220
+ min-height: 220px;
221
+ border: 2px dashed var(--ui-border-accented, #cbd5e1);
222
+ border-radius: 0.75rem;
223
+ background: var(--ui-bg-elevated, transparent);
224
+ transition:
225
+ border-color 0.2s,
226
+ background-color 0.2s;
227
+ outline: none;
228
+ }
229
+ .q-dropzone.is-dragging {
230
+ border-color: var(--ui-primary, #3b82f6);
231
+ background: color-mix(in srgb, var(--ui-primary, #3b82f6) 8%, transparent);
232
+ }
233
+ .q-dropzone.is-disabled {
234
+ opacity: 0.5;
235
+ pointer-events: none;
236
+ }
237
+ .q-dropzone-input {
238
+ position: absolute;
239
+ width: 1px;
240
+ height: 1px;
241
+ padding: 0;
242
+ margin: -1px;
243
+ overflow: hidden;
244
+ clip: rect(0, 0, 0, 0);
245
+ border: 0;
246
+ }
247
+ .q-dropzone-body {
248
+ display: flex;
249
+ flex-direction: column;
250
+ align-items: center;
251
+ gap: 0.625rem;
252
+ padding: 1.5rem;
253
+ text-align: center;
254
+ width: 100%;
255
+ max-width: 24rem;
256
+ }
257
+ .q-dropzone-icon {
258
+ display: flex;
259
+ align-items: center;
260
+ justify-content: center;
261
+ width: 3.5rem;
262
+ height: 3.5rem;
263
+ border-radius: 9999px;
264
+ color: var(--ui-primary, #3b82f6);
265
+ background: color-mix(in srgb, var(--ui-primary, #3b82f6) 14%, transparent);
266
+ }
267
+ .q-dropzone-title {
268
+ margin: 0;
269
+ font-size: 1rem;
270
+ font-weight: 600;
271
+ color: var(--ui-text-highlighted, inherit);
272
+ }
273
+ .q-dropzone-hint {
274
+ margin: 0;
275
+ font-size: 0.8125rem;
276
+ color: var(--ui-text-muted, #64748b);
277
+ }
278
+ .q-dropzone-btn {
279
+ margin-top: 0.25rem;
280
+ padding: 0.5rem 1rem;
281
+ border-radius: 0.5rem;
282
+ border: 1px solid var(--ui-border, #cbd5e1);
283
+ background: var(--ui-bg, #ffffff);
284
+ color: var(--ui-text-highlighted, #0f172a);
285
+ font-size: 0.875rem;
286
+ font-weight: 500;
287
+ cursor: pointer;
288
+ }
289
+ .q-dropzone-btn:hover:not(:disabled) {
290
+ border-color: var(--ui-primary, #3b82f6);
291
+ }
292
+ .q-dropzone-url {
293
+ display: flex;
294
+ gap: 0.375rem;
295
+ width: 100%;
296
+ margin-top: 0.5rem;
297
+ }
298
+ .q-dropzone-url-input {
299
+ flex: 1;
300
+ min-width: 0;
301
+ padding: 0.375rem 0.625rem;
302
+ border-radius: 0.375rem;
303
+ border: 1px solid var(--ui-border, #cbd5e1);
304
+ background: var(--ui-bg, transparent);
305
+ color: inherit;
306
+ font-size: 0.8125rem;
307
+ }
308
+ .q-dropzone-url-btn {
309
+ padding: 0.375rem 0.75rem;
310
+ border-radius: 0.375rem;
311
+ border: none;
312
+ background: var(--ui-primary, #3b82f6);
313
+ color: #ffffff;
314
+ font-size: 0.8125rem;
315
+ font-weight: 500;
316
+ cursor: pointer;
317
+ }
318
+ .q-dropzone-url-btn:disabled {
319
+ opacity: 0.5;
320
+ cursor: not-allowed;
321
+ }
322
+ .q-dropzone-error {
323
+ margin: 0.25rem 0 0;
324
+ font-size: 0.75rem;
325
+ color: var(--ui-error, #ef4444);
326
+ }
327
+ </style>