-
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat!:
signature-text
and signature-draw
now support v-model file
Signature Text and Signature Draw now support v-model both File object and base64-dataURI. And default v-model now is File Migration: change to every `v-model` to `v-model.base64`
- Loading branch information
Showing
12 changed files
with
163 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { createSpinner } from '../../avatar/utils/create-image' | ||
import { | ||
MaybeRef, | ||
tryOnMounted, | ||
tryOnBeforeUnmount, | ||
} from '@vueuse/core' | ||
import { | ||
Ref, | ||
ref, | ||
unref, | ||
watch, | ||
} from 'vue-demi' | ||
|
||
export function usePreview (file: MaybeRef<string | globalThis.File>, fallback = createSpinner(512, 512)): Ref<string> { | ||
const preview = ref(fallback) | ||
|
||
watch(() => unref(file), (value) => { | ||
if (preview.value?.startsWith('blob')) | ||
window.URL.revokeObjectURL(preview.value) | ||
|
||
preview.value = value instanceof globalThis.File | ||
? window.URL.createObjectURL(value) | ||
: (value ?? fallback) | ||
}) | ||
|
||
tryOnMounted(() => { | ||
const value = unref(file) | ||
|
||
if (value) { | ||
preview.value = value instanceof globalThis.File | ||
? window.URL.createObjectURL(value) | ||
: value | ||
} | ||
}) | ||
|
||
tryOnBeforeUnmount(() => { | ||
if (preview.value?.startsWith('blob')) | ||
window.URL.revokeObjectURL(preview.value) | ||
}) | ||
|
||
return preview | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.