@@ -13,12 +13,14 @@ import {useTypings} from "@/composables/typings";
1313import {useModelStore } from " @/stores/model" ;
1414import {useSyncing } from " @/composables/syncing" ;
1515import {LineCounter , parseDocument } from " yaml" ;
16+ import {copyToClipboard } from " @/utils" ;
1617// import yaml from 'js-yaml';
1718
1819const emit = defineEmits ([' save' , ' create' , ' change' , ' focus' , ' blur' ]);
1920const structure = defineModel <IStructure >({ required: true });
20- const { columns = false , userData } = defineProps <{
21+ const { columns = false , showTabs = false , userData } = defineProps <{
2122 columns? : boolean ,
23+ showTabs? : boolean ,
2224 structureData: IStructureData ,
2325 userData: any
2426}>();
@@ -42,6 +44,8 @@ const blueprintEditorTypings: Ref<VAceEditorInstance | null> = ref(null);
4244const blueprintEditorDefault: Ref <VAceEditorInstance | null > = ref (null );
4345const blueprintTypings = ref (' ' )
4446const blueprintDefault = ref (' ' )
47+ const disableTypings = ref (false )
48+ const disableDefaultObjects = ref (false )
4549const blueprintLanguage = ref <' typescript' >(' typescript' )
4650
4751const sectionMenu = ref (false );
@@ -79,8 +83,8 @@ const sections = ref([{
7983 disabled : () => false ,
8084}, {
8185 key: ' blueprints' ,
82- icon: ' mdi-ruler-square ' ,
83- title: " Blueprints " ,
86+ icon: ' mdi-language-typescript ' ,
87+ title: " Typescript " ,
8488 subtitle: " TypeScript types and default data" ,
8589 disabledSubtitle : (): string => ' Must be logged in' ,
8690 disabled : () => false
@@ -194,6 +198,22 @@ const onBlur = () => {
194198 emit (' blur' );
195199}
196200
201+ const copy = (content : string , type : ' typings' | ' defaults' ) => {
202+ switch (type ) {
203+ case ' typings' : disableTypings .value = true ; break ;
204+ case ' defaults' : disableDefaultObjects .value = true ; break ;
205+ }
206+ copyToClipboard (content );
207+ globalStore .showBottomSheet (' Copied to clipboard!' , null , ' mdi-clipboard-check-outline' );
208+ setTimeout (() => {
209+ globalStore .hideBottomSheet ();
210+ switch (type ) {
211+ case ' typings' : disableTypings .value = false ; break ;
212+ case ' defaults' : disableDefaultObjects .value = false ; break ;
213+ }
214+ }, 1000 );
215+ }
216+
197217const printAnnotations = (content : string ) => {
198218 const instance = structureEditor .value ?.getAceInstance ();
199219 if (instance ) {
@@ -526,7 +546,16 @@ watch(() => globalStore.userSettings.data, () => {
526546 />
527547 <div v-else class =" d-flex flex-column" >
528548 <div v-if =" globalStore.uiConfig.structure_menu" class =" d-flex align-center pa-1" style =" gap : 1rem " >
529- <v-menu v-model =" sectionMenu" contained :close-on-content-click =" false" >
549+ <v-tabs v-if =" showTabs" density =" compact" >
550+ <v-tab
551+ v-for =" section in filteredSections"
552+ :key =" section.key"
553+ :prepend-icon =" section.disabled() ? 'mdi-alert' : section.icon"
554+ :text =" section.title"
555+ @click =" setSection(section)"
556+ />
557+ </v-tabs >
558+ <v-menu v-else v-model =" sectionMenu" contained :close-on-content-click =" false" >
530559 <template #activator =" { props } " >
531560 <v-btn v-bind =" props" >
532561 <v-icon :icon =" selectedSection?.icon" start />
@@ -700,11 +729,19 @@ watch(() => globalStore.userSettings.data, () => {
700729 }]"
701730 >
702731 <div v-if =" globalStore.userSettings.data.blueprintsIncludeTypings" class =" d-flex flex-column" style =" flex : 1 " >
703- <v-alert tile class =" py-4 text-caption" >
732+ <div class =" d-flex justify-space-between bg-sheet pa-2 text-caption" >
704733 <div class =" text-truncate" >
705734 <strong >Readonly:</strong > Typings are generated automatically.
706735 </div >
707- </v-alert >
736+ <v-btn
737+ :disabled =" disableTypings"
738+ size =" x-small"
739+ variant =" tonal"
740+ @click =" () => copy(blueprintTypings, 'typings')"
741+ >
742+ Copy
743+ </v-btn >
744+ </div >
708745 <v-ace-editor
709746 ref =" blueprintEditorTypings"
710747 v-model:value =" blueprintTypings"
@@ -716,11 +753,19 @@ watch(() => globalStore.userSettings.data, () => {
716753 />
717754 </div >
718755 <div class =" d-flex flex-column" style =" flex : 1 " >
719- <v-alert tile class =" py-4 text-caption" >
756+ <div class =" d-flex justify-space-between bg-sheet pa-2 text-caption" >
720757 <div class =" text-truncate" >
721758 <strong >Readonly:</strong > Default objects are generated automatically.
722759 </div >
723- </v-alert >
760+ <v-btn
761+ :disabled =" disableDefaultObjects"
762+ size =" x-small"
763+ variant =" tonal"
764+ @click =" () => copy(blueprintDefault, 'defaults')"
765+ >
766+ Copy
767+ </v-btn >
768+ </div >
724769 <v-ace-editor
725770 ref =" blueprintEditorDefault"
726771 v-model:value =" blueprintDefault"
0 commit comments