Skip to content
This repository has been archived by the owner on Apr 2, 2024. It is now read-only.

Commit

Permalink
Add clipboard import to schema editor
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexGodbehere committed Mar 14, 2024
1 parent ae06091 commit 61de77b
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions resources/js/components/Containers/SchemaEditorContainer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
<span>Open</span>
<i class="fa-sharp fa-solid ml-2 fa-folder"></i>
</button>
<button @click="importSchemaFromClipboard" class="fpl-button-secondary h-10 ml-auto">
<span>Import from Clipboard</span>
<i class="fa-sharp fa-solid ml-2 fa-clipboard"></i>
</button>
</div>
<input class="font-bold text-brand text-lg bg-gray-100 p-2" v-model="name">
<List @new="create" @rowSelected="handleRowSelection" @rowDeleted="handleRowDeletion" :guides="false" :properties="schema.properties"
Expand Down Expand Up @@ -243,6 +247,21 @@ export default {
this.schemaBrowserVisible = true
},

importSchemaFromClipboard() {
navigator.clipboard.readText().then(text => {
try {
let schema = JSON.parse(text)
this.selectSchema({ rawSchema: schema })
} catch (e) {
window.showNotification({
title: 'Invalid JSON',
description: 'The JSON in the clipboard is not valid.',
type: 'error',
})
}
})
},

selectSchema (schema) {
this.schemaBrowserVisible = false
this.schema = schema.rawSchema
Expand Down

0 comments on commit 61de77b

Please sign in to comment.