-
+
+
+
-
diff --git a/packages/client/src/components/assets/AssetDetails.vue b/packages/client/src/components/assets/AssetDetails.vue
index c07cd05f..0c45a36b 100644
--- a/packages/client/src/components/assets/AssetDetails.vue
+++ b/packages/client/src/components/assets/AssetDetails.vue
@@ -57,7 +57,7 @@ const codeSnippets = computed(() => {
return items
})
-const copy = useCopy()
+const { copy } = useCopy()
const timeAgo = useTimeAgo(() => asset.value.mtime)
const fileSize = computed(() => {
const size = asset.value.size
@@ -159,7 +159,7 @@ const supportsPreview = computed(() => {
icon="i-carbon-copy"
action mr1 mt--2px flex-none
:border="false"
- @click="copy(asset.publicPath, 'assets-public-path')"
+ @click="copy(asset.publicPath, { silent: false, type: 'assets-public-path' })"
/>
()
const selected = shallowRef(props.codeSnippets[0])
-const copy = useCopy()
+const { copy } = useCopy()
const selectedLang = computed(() => (selected.value?.lang || 'text') as BuiltinLanguage)
@@ -45,7 +45,7 @@ watchEffect(() => {
w-full of-auto p3
/>
-
+
Copy
diff --git a/packages/client/src/composables/editor.ts b/packages/client/src/composables/editor.ts
index f4a89cc0..817c2902 100644
--- a/packages/client/src/composables/editor.ts
+++ b/packages/client/src/composables/editor.ts
@@ -1,7 +1,39 @@
+import { showVueNotification } from '@vue/devtools-ui'
+
+interface CopyOptions {
+ silent?: boolean
+ type?: string
+}
+
export function useCopy() {
- const clipboard = useClipboard()
+ const { copy: _copy, copied } = useClipboard()
+
+ const copy = (text: string, options: CopyOptions = {}) => {
+ const {
+ silent = false,
+ type = '',
+ } = options
+ _copy(text).then(() => {
+ if (!silent) {
+ showVueNotification({
+ message: 'Copied to clipboard',
+ type: 'success',
+ duration: 3000,
+ })
+ }
+ }).catch(() => {
+ if (!silent) {
+ showVueNotification({
+ message: 'Failed to copy to clipboard',
+ type: 'error',
+ duration: 3000,
+ })
+ }
+ })
+ }
- return (text: string, type?: string) => {
- clipboard.copy(text)
+ return {
+ copy,
+ copied,
}
}
diff --git a/packages/ui/src/components/Input.vue b/packages/ui/src/components/Input.vue
index 4f544962..486c4be8 100644
--- a/packages/ui/src/components/Input.vue
+++ b/packages/ui/src/components/Input.vue
@@ -15,6 +15,7 @@ const props = withDefaults(defineProps<{
loading?: boolean
autoFocus?: boolean
loadingDebounceTime?: number
+ readonly?: boolean
}>(), {
placeholder: '',
variant: 'normal',
@@ -26,6 +27,7 @@ const props = withDefaults(defineProps<{
loading: false,
autoFocus: false,
loadingDebounceTime: 0,
+ readonly: false,
})
const emit = defineEmits<{
@@ -42,7 +44,7 @@ const focused = refWithControl(false, {
emit('updateFocused', value)
},
})
-const noFocusAnimation = computed(() => props.variant === 'flat' || props.variant === 'warning')
+const noFocusAnimation = computed(() => props.variant === 'flat' || props.variant === 'warning' || props.disabled || props.readonly)
const disabled = computed(() => props.disabled || loading.value)
@@ -100,7 +102,7 @@ watchEffect(() => {