mirror of
https://github.com/directus/directus.git
synced 2026-02-09 01:04:56 -05:00
Fix json serialization (#16558)
* fix copying json fields * fixed preset filter type * handling fallback in copyToClipboard function * add test * try parsing json content on paste Co-authored-by: Azri Kahar <42867097+azrikahar@users.noreply.github.com>
This commit is contained in:
@@ -81,6 +81,7 @@ import FormFieldMenu from './form-field-menu.vue';
|
||||
import { formatFieldFunction } from '@/utils/format-field-function';
|
||||
import { useClipboard } from '@/composables/use-clipboard';
|
||||
import FormFieldRawEditor from './form-field-raw-editor.vue';
|
||||
import { parseJSON } from '@directus/shared/utils';
|
||||
|
||||
interface Props {
|
||||
field: Field;
|
||||
@@ -178,8 +179,12 @@ function useRaw() {
|
||||
async function pasteRaw() {
|
||||
const pastedValue = await pasteFromClipboard();
|
||||
if (!pastedValue) return;
|
||||
internalValue.value = pastedValue;
|
||||
emitValue(pastedValue);
|
||||
try {
|
||||
internalValue.value = parseJSON(pastedValue);
|
||||
} catch (e) {
|
||||
internalValue.value = pastedValue;
|
||||
}
|
||||
emitValue(internalValue.value);
|
||||
}
|
||||
|
||||
return { showRaw, copyRaw, pasteRaw, onRawValueSubmit };
|
||||
|
||||
Reference in New Issue
Block a user