qarpeo 0.4.13 → 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.
- package/README.md +12 -6
- package/dist/apps/cms.d.ts +1 -1
- package/dist/apps/comments.d.ts +1 -1
- package/dist/apps/payments.d.ts +1 -1
- package/dist/apps/store.d.ts +1 -1
- package/dist/chunks/{manifest.get.mjs → tools.mjs} +445 -430
- package/dist/cli/index.mjs +756 -746
- package/dist/core/aliases.d.ts +1 -1
- package/dist/core/context.d.ts +1 -1
- package/dist/core/d1-migrate.d.ts +1 -1
- package/dist/core/devtools.d.ts +1 -1
- package/dist/core/nitro.d.ts +1 -1
- package/dist/core/schema.d.ts +1 -1
- package/dist/core/server-utils.d.ts +1 -1
- package/dist/core/wrangler.d.ts +1 -1
- package/dist/fate/index.d.ts +8 -8
- package/dist/fate/index.mjs +3 -1
- package/dist/features/agents.d.ts +1 -1
- package/dist/features/auth.d.ts +1 -1
- package/dist/features/bots.d.ts +1 -1
- package/dist/features/console.d.ts +1 -1
- package/dist/features/fate.d.ts +1 -1
- package/dist/features/mail.d.ts +1 -1
- package/dist/features/mcp.d.ts +1 -1
- package/dist/features/multitenant.d.ts +1 -1
- package/dist/features/notifications.d.ts +1 -1
- package/dist/features/realtime.d.ts +1 -1
- package/dist/features/studio.d.ts +4 -0
- package/dist/module.d.ts +1 -1
- package/dist/module.mjs +5139 -5067
- package/dist/primitives/ai.d.ts +1 -1
- package/dist/primitives/analytics.d.ts +1 -1
- package/dist/primitives/blob.d.ts +1 -1
- package/dist/primitives/browser.d.ts +1 -1
- package/dist/primitives/cache.d.ts +1 -1
- package/dist/primitives/d1.d.ts +1 -1
- package/dist/primitives/do.d.ts +1 -1
- package/dist/primitives/email.d.ts +1 -1
- package/dist/primitives/hyperdrive.d.ts +1 -1
- package/dist/primitives/kv.d.ts +1 -1
- package/dist/primitives/queue.d.ts +1 -1
- package/dist/primitives/ratelimit.d.ts +1 -1
- package/dist/primitives/vectorize.d.ts +1 -1
- package/dist/primitives/workflows.d.ts +1 -1
- package/dist/runtime/ai.mjs +4 -1
- package/dist/runtime/app/components/CMSEditor.vue +439 -0
- package/dist/runtime/app/components/CMSEditorImageNode.vue +90 -0
- package/dist/runtime/app/components/CMSEditorLinkPopover.vue +120 -0
- package/dist/runtime/app/components/QDropZone.vue +327 -0
- package/dist/runtime/app/components/QImageCropper.vue +658 -0
- package/dist/runtime/app/components/QImageStudio.vue +300 -0
- package/dist/runtime/app/components/QImg.vue +7 -4
- package/dist/runtime/app/composables/analytics.d.ts +8 -8
- package/dist/runtime/app/composables/api-tokens.d.ts +5 -5
- package/dist/runtime/app/composables/auth.d.ts +23 -19
- package/dist/runtime/app/composables/chat.d.ts +7 -6
- package/dist/runtime/app/composables/cms-preview.d.ts +7 -8
- package/dist/runtime/app/composables/cms.d.ts +6 -6
- package/dist/runtime/app/composables/comments.d.ts +5 -5
- package/dist/runtime/app/composables/comments.mjs +7 -4
- package/dist/runtime/app/composables/console.d.ts +6 -14
- package/dist/runtime/app/composables/docs-version.d.ts +8 -8
- package/dist/runtime/app/composables/impersonation.d.ts +5 -5
- package/dist/runtime/app/composables/organization.d.ts +5 -5
- package/dist/runtime/app/composables/passkey.d.ts +5 -5
- package/dist/runtime/app/composables/passwordless.d.ts +5 -5
- package/dist/runtime/app/composables/payments.d.ts +5 -5
- package/dist/runtime/app/composables/rbac.d.ts +5 -5
- package/dist/runtime/app/composables/site.d.ts +2 -2
- package/dist/runtime/app/composables/sse.d.ts +20 -33
- package/dist/runtime/app/composables/sse.mjs +6 -3
- package/dist/runtime/app/composables/storage.d.ts +6 -8
- package/dist/runtime/app/composables/store.d.ts +37 -36
- package/dist/runtime/app/composables/store.mjs +7 -6
- package/dist/runtime/app/composables/studio.d.ts +59 -0
- package/dist/runtime/app/composables/studio.mjs +129 -0
- package/dist/runtime/app/composables/tenant.d.ts +7 -7
- package/dist/runtime/app/composables/turnstile.d.ts +5 -5
- package/dist/runtime/app/composables/two-factor.d.ts +5 -5
- package/dist/runtime/app/pages/devtools/notifications.vue +1 -6
- package/dist/runtime/app/plugins/pwa.mjs +1 -3
- package/dist/runtime/app/utils/cms-editor.d.ts +25 -0
- package/dist/runtime/app/utils/cms-editor.mjs +43 -0
- package/dist/runtime/auth.d.ts +9 -9
- package/dist/runtime/blob.d.ts +1 -3
- package/dist/runtime/blob.mjs +3 -1
- package/dist/runtime/cache.d.ts +8 -6
- package/dist/runtime/cache.mjs +8 -11
- package/dist/runtime/db.d.ts +4 -3
- package/dist/runtime/drizzle.d.ts +2 -1
- package/dist/runtime/drizzle.mjs +2 -2
- package/dist/runtime/queue.d.ts +1 -0
- package/dist/runtime/replica.d.ts +6 -10
- package/dist/runtime/replica.mjs +3 -1
- package/dist/runtime/schema-mysql.d.ts +16 -32
- package/dist/runtime/schema-pg.d.ts +15 -31
- package/dist/runtime/schema-shared.d.ts +20 -17
- package/dist/runtime/schema.d.ts +21 -33
- package/dist/runtime/server/durable-objects/agent.mjs +4 -1
- package/dist/runtime/server/durable-objects/room.d.ts +4 -6
- package/dist/runtime/server/durable-objects/room.mjs +18 -8
- package/dist/runtime/server/plugins/comments.d.ts +2 -3
- package/dist/runtime/server/plugins/email-inbound.d.ts +1 -3
- package/dist/runtime/server/plugins/store.d.ts +2 -3
- package/dist/runtime/server/routes/__qarpeo/cloud/agents/run.post.d.ts +2 -2
- package/dist/runtime/server/routes/__qarpeo/cloud/cms/entry.get.mjs +10 -2
- package/dist/runtime/server/routes/__qarpeo/cloud/cms/entry.post.d.ts +2 -2
- package/dist/runtime/server/routes/__qarpeo/cloud/cms/entry.post.mjs +10 -2
- package/dist/runtime/server/routes/__qarpeo/cloud/cms.get.d.ts +2 -2
- package/dist/runtime/server/routes/__qarpeo/cloud/cms.get.mjs +7 -1
- package/dist/runtime/server/routes/__qarpeo/cloud/comments/moderate.post.d.ts +2 -2
- package/dist/runtime/server/routes/__qarpeo/cloud/comments/moderate.post.mjs +5 -1
- package/dist/runtime/server/routes/__qarpeo/cloud/comments.get.d.ts +1 -3
- package/dist/runtime/server/routes/__qarpeo/cloud/extras.get.d.ts +2 -2
- package/dist/runtime/server/routes/__qarpeo/cloud/extras.get.mjs +15 -4
- package/dist/runtime/server/routes/__qarpeo/cloud/mail/unsuppress.post.d.ts +2 -2
- package/dist/runtime/server/routes/__qarpeo/cloud/migrate/cms.post.mjs +13 -4
- package/dist/runtime/server/routes/__qarpeo/cloud/migrate/products.post.mjs +1 -1
- package/dist/runtime/server/routes/__qarpeo/cloud/migrate.post.d.ts +3 -3
- package/dist/runtime/server/routes/__qarpeo/cloud/migrate.post.mjs +22 -6
- package/dist/runtime/server/routes/__qarpeo/cloud/notifications/test.post.d.ts +2 -2
- package/dist/runtime/server/routes/__qarpeo/cloud/operations.get.d.ts +6 -5
- package/dist/runtime/server/routes/__qarpeo/cloud/store/order-status.post.d.ts +1 -3
- package/dist/runtime/server/routes/__qarpeo/cloud/store/order-status.post.mjs +14 -2
- package/dist/runtime/server/routes/__qarpeo/cloud/store/orders.get.d.ts +1 -3
- package/dist/runtime/server/routes/__qarpeo/cloud/store/orders.get.mjs +7 -1
- package/dist/runtime/server/routes/__qarpeo/cloud/store/products.get.d.ts +1 -3
- package/dist/runtime/server/routes/__qarpeo/cloud/tasks/run.post.d.ts +2 -2
- package/dist/runtime/server/routes/__qarpeo/cloud/users/action.post.d.ts +2 -2
- package/dist/runtime/server/routes/__qarpeo/cloud/users/action.post.mjs +5 -1
- package/dist/runtime/server/routes/__qarpeo/cloud/users.get.d.ts +6 -5
- package/dist/runtime/server/routes/__qarpeo/cloud/users.get.mjs +1 -3
- package/dist/runtime/server/routes/__qarpeo/mail/track/click/[id].get.mjs +2 -2
- package/dist/runtime/server/routes/__qarpeo/manifest.get.d.ts +2 -2
- package/dist/runtime/server/routes/__qarpeo/og.get.d.ts +2 -2
- package/dist/runtime/server/routes/__qarpeo/rbac/me.get.d.ts +2 -2
- package/dist/runtime/server/routes/__qarpeo/rbac/roles.delete.d.ts +2 -2
- package/dist/runtime/server/routes/__qarpeo/rbac/roles.delete.mjs +5 -1
- package/dist/runtime/server/routes/__qarpeo/rbac/roles.get.d.ts +2 -2
- package/dist/runtime/server/routes/__qarpeo/rbac/roles.get.mjs +1 -5
- package/dist/runtime/server/routes/__qarpeo/rbac/roles.post.d.ts +2 -2
- package/dist/runtime/server/routes/__qarpeo/rbac/roles.post.mjs +5 -1
- package/dist/runtime/server/routes/__qarpeo/rbac/users.post.d.ts +2 -2
- package/dist/runtime/server/routes/agents/[agent]/chat.post.mjs +1 -6
- package/dist/runtime/server/routes/agents/[agent]/clear.post.mjs +1 -6
- package/dist/runtime/server/routes/agents/[agent]/history.get.mjs +1 -6
- package/dist/runtime/server/routes/auth/2fa/disable.post.mjs +5 -1
- package/dist/runtime/server/routes/auth/2fa/verify.post.mjs +7 -1
- package/dist/runtime/server/routes/auth/magic-link/send.post.mjs +1 -1
- package/dist/runtime/server/routes/auth/otp/send.post.mjs +1 -1
- package/dist/runtime/server/routes/cms/search.get.mjs +2 -6
- package/dist/runtime/server/routes/comments/[id]/report.post.mjs +1 -4
- package/dist/runtime/server/routes/comments/[id].patch.mjs +1 -4
- package/dist/runtime/server/routes/comments/batch.post.mjs +1 -3
- package/dist/runtime/server/routes/comments/index.post.mjs +1 -5
- package/dist/runtime/server/routes/fate.mjs +1 -1
- package/dist/runtime/server/routes/mail/webhooks.post.mjs +1 -1
- package/dist/runtime/server/routes/sitemap.xml.get.mjs +2 -1
- package/dist/runtime/server/routes/storage/presigned-r2.post.d.ts +5 -6
- package/dist/runtime/server/routes/storage/presigned-r2.post.mjs +1 -1
- package/dist/runtime/server/routes/store/cart/items/[id].delete.mjs +1 -1
- package/dist/runtime/server/routes/store/cart/items/[id].patch.mjs +1 -1
- package/dist/runtime/server/routes/store/currencies.get.mjs +1 -4
- package/dist/runtime/server/routes/store/orders/[id].get.mjs +1 -1
- package/dist/runtime/server/routes/store/orders/download/[token].get.mjs +13 -4
- package/dist/runtime/server/routes/store/orders/index.get.mjs +1 -1
- package/dist/runtime/server/routes/store/tax/calculate.post.d.ts +2 -1
- package/dist/runtime/server/routes/store/tax/calculate.post.mjs +12 -3
- package/dist/runtime/server/routes/tenants/[tenant]/domains/[domain]/index.delete.mjs +4 -1
- package/dist/runtime/server/routes/tenants/[tenant]/domains/[domain]/verify.post.mjs +4 -1
- package/dist/runtime/server/utils/ai.d.ts +38 -35
- package/dist/runtime/server/utils/ai.mjs +7 -11
- package/dist/runtime/server/utils/analytics-query.d.ts +4 -4
- package/dist/runtime/server/utils/auth.d.ts +25 -25
- package/dist/runtime/server/utils/auth.mjs +22 -8
- package/dist/runtime/server/utils/bots.d.ts +7 -7
- package/dist/runtime/server/utils/browser-utils.d.ts +26 -27
- package/dist/runtime/server/utils/cache.d.ts +20 -20
- package/dist/runtime/server/utils/cms/collections.mjs +1 -6
- package/dist/runtime/server/utils/cms/common.mjs +1 -0
- package/dist/runtime/server/utils/cms/markdown.d.ts +2 -2
- package/dist/runtime/server/utils/cms/markdown.mjs +5 -5
- package/dist/runtime/server/utils/cms/mutations.mjs +8 -23
- package/dist/runtime/server/utils/cms/navigation.mjs +4 -4
- package/dist/runtime/server/utils/cms/path.d.ts +1 -0
- package/dist/runtime/server/utils/cms/path.mjs +8 -2
- package/dist/runtime/server/utils/cms/references.mjs +1 -7
- package/dist/runtime/server/utils/cms/search.d.ts +2 -2
- package/dist/runtime/server/utils/cms/sync.mjs +4 -2
- package/dist/runtime/server/utils/cms/taxonomy.d.ts +2 -2
- package/dist/runtime/server/utils/cms.d.ts +1 -1
- package/dist/runtime/server/utils/cms.mjs +1 -5
- package/dist/runtime/server/utils/comments-filter.d.ts +9 -7
- package/dist/runtime/server/utils/comments.d.ts +68 -55
- package/dist/runtime/server/utils/comments.mjs +21 -9
- package/dist/runtime/server/utils/config.d.ts +2 -2
- package/dist/runtime/server/utils/console.d.ts +3 -5
- package/dist/runtime/server/utils/context.d.ts +10 -10
- package/dist/runtime/server/utils/crypto.d.ts +20 -20
- package/dist/runtime/server/utils/domains.mjs +3 -1
- package/dist/runtime/server/utils/drizzle.d.ts +24 -25
- package/dist/runtime/server/utils/drizzle.mjs +17 -17
- package/dist/runtime/server/utils/durable-object.d.ts +27 -25
- package/dist/runtime/server/utils/durable-object.mjs +3 -10
- package/dist/runtime/server/utils/email-inbound.d.ts +10 -10
- package/dist/runtime/server/utils/impersonation.d.ts +18 -18
- package/dist/runtime/server/utils/legacy-hash.d.ts +23 -27
- package/dist/runtime/server/utils/lock.d.ts +20 -23
- package/dist/runtime/server/utils/mail.d.ts +19 -19
- package/dist/runtime/server/utils/mail.mjs +4 -2
- package/dist/runtime/server/utils/mcp.d.ts +20 -20
- package/dist/runtime/server/utils/mcp.mjs +22 -38
- package/dist/runtime/server/utils/notifications.d.ts +49 -38
- package/dist/runtime/server/utils/oauth.d.ts +3 -9
- package/dist/runtime/server/utils/organization.d.ts +28 -28
- package/dist/runtime/server/utils/organization.mjs +15 -5
- package/dist/runtime/server/utils/passwordless.d.ts +24 -24
- package/dist/runtime/server/utils/payments/checkout.d.ts +12 -12
- package/dist/runtime/server/utils/payments/checkout.mjs +1 -3
- package/dist/runtime/server/utils/payments/common.d.ts +3 -3
- package/dist/runtime/server/utils/payments/paddle.d.ts +4 -1
- package/dist/runtime/server/utils/payments/polar.d.ts +4 -1
- package/dist/runtime/server/utils/payments/stripe.mjs +5 -7
- package/dist/runtime/server/utils/payments/subscriptions.d.ts +14 -14
- package/dist/runtime/server/utils/payments/subscriptions.mjs +2 -6
- package/dist/runtime/server/utils/payments/usage.mjs +1 -3
- package/dist/runtime/server/utils/payments/webhooks.mjs +2 -2
- package/dist/runtime/server/utils/queue.d.ts +54 -58
- package/dist/runtime/server/utils/queue.mjs +2 -6
- package/dist/runtime/server/utils/rag.d.ts +23 -23
- package/dist/runtime/server/utils/rag.mjs +10 -5
- package/dist/runtime/server/utils/ratelimit.d.ts +21 -18
- package/dist/runtime/server/utils/rbac.d.ts +13 -15
- package/dist/runtime/server/utils/rbac.mjs +44 -10
- package/dist/runtime/server/utils/realtime.d.ts +53 -52
- package/dist/runtime/server/utils/role-env.d.ts +5 -4
- package/dist/runtime/server/utils/scheduled-task.d.ts +14 -15
- package/dist/runtime/server/utils/session.d.ts +40 -40
- package/dist/runtime/server/utils/sse.d.ts +23 -33
- package/dist/runtime/server/utils/sse.mjs +5 -14
- package/dist/runtime/server/utils/sso.mjs +3 -1
- package/dist/runtime/server/utils/storage.d.ts +20 -22
- package/dist/runtime/server/utils/storage.mjs +2 -2
- package/dist/runtime/server/utils/store/cart.d.ts +5 -3
- package/dist/runtime/server/utils/store/cart.mjs +14 -10
- package/dist/runtime/server/utils/store/checkout.mjs +4 -1
- package/dist/runtime/server/utils/store/common.d.ts +1 -1
- package/dist/runtime/server/utils/store/common.mjs +36 -12
- package/dist/runtime/server/utils/store/inventory.mjs +3 -1
- package/dist/runtime/server/utils/store/orders.mjs +32 -24
- package/dist/runtime/server/utils/store-localization.d.ts +9 -27
- package/dist/runtime/server/utils/store-localization.mjs +3 -3
- package/dist/runtime/server/utils/table-names.d.ts +15 -15
- package/dist/runtime/server/utils/table-names.mjs +1 -1
- package/dist/runtime/server/utils/tenant.d.ts +12 -12
- package/dist/runtime/server/utils/tenant.mjs +7 -4
- package/dist/runtime/server/utils/totp.d.ts +18 -18
- package/dist/runtime/server/utils/tracker.d.ts +5 -5
- package/dist/runtime/server/utils/turnstile.d.ts +9 -9
- package/dist/runtime/server/utils/urn.d.ts +5 -8
- package/dist/runtime/server/utils/workflows.d.ts +30 -31
- package/dist/runtime/server/utils/workflows.mjs +2 -4
- package/dist/runtime/server.d.ts +2 -2
- package/dist/runtime/service.d.ts +10 -10
- package/dist/runtime/test-utils.d.ts +10 -10
- package/dist/runtime/test-utils.mjs +9 -2
- package/dist/runtime/types/ai.d.ts +14 -14
- package/dist/runtime/types/d1.d.ts +6 -11
- package/dist/runtime/types/durable-object.d.ts +4 -8
- package/dist/runtime/types/email.d.ts +3 -9
- package/dist/runtime/types/index.d.ts +15 -21
- package/dist/runtime/types/r2.d.ts +5 -5
- package/dist/runtime/types/workflows.d.ts +5 -6
- package/dist/runtime/workflows.d.ts +1 -3
- package/dist/types/ai.d.ts +10 -17
- package/dist/types/auth.d.ts +5 -3
- package/dist/types/cache.d.ts +7 -7
- package/dist/types/cms.d.ts +30 -5
- package/dist/types/comments.d.ts +23 -21
- package/dist/types/console.d.ts +1 -3
- package/dist/types/db.d.ts +7 -7
- package/dist/types/index.d.ts +1 -0
- package/dist/types/options.d.ts +36 -24
- package/dist/types/site.d.ts +8 -2
- package/dist/types/storage.d.ts +2 -1
- package/dist/types/store-options.d.ts +10 -26
- package/dist/types/studio.d.ts +79 -0
- package/dist/utils/bots.d.ts +7 -3
- package/dist/utils/cms-table-names.d.ts +1 -1
- package/dist/utils/drizzle.d.ts +13 -14
- package/dist/utils/email-inbound.d.ts +4 -4
- package/dist/utils/features.d.ts +19 -5
- package/dist/utils/mcp.d.ts +1 -0
- package/dist/utils/migration-lock.d.ts +15 -29
- package/dist/utils/pkg.d.ts +6 -7
- package/dist/utils/schema-diff.d.ts +7 -11
- package/dist/utils/store-schema.d.ts +4 -6
- package/dist/utils/tools.d.ts +3 -3
- 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>
|