diff --git a/meta_configurator/src/components/panels/code-editor/aceUtility.ts b/meta_configurator/src/components/panels/code-editor/aceUtility.ts index 8a112052..ba9bda22 100644 --- a/meta_configurator/src/components/panels/code-editor/aceUtility.ts +++ b/meta_configurator/src/components/panels/code-editor/aceUtility.ts @@ -30,7 +30,9 @@ export function updateCursorPositionBasedOnPath( currentPath: Path ) { const position = determineCursorPosition(editor, editorContent, currentPath); - editor.gotoLine(position.row + 1, position.column, true); // row is 1-based, column is 0-based + editor.clearSelection(); + editor.moveCursorToPosition(position); + editor.renderer.scrollCursorIntoView(); } /** diff --git a/meta_configurator/src/components/panels/schema-diagram/VueFlowPanel.vue b/meta_configurator/src/components/panels/schema-diagram/VueFlowPanel.vue index 039d9f52..1c3b44d5 100644 --- a/meta_configurator/src/components/panels/schema-diagram/VueFlowPanel.vue +++ b/meta_configurator/src/components/panels/schema-diagram/VueFlowPanel.vue @@ -48,7 +48,11 @@ import SchemaExternalReferenceNode from '@/components/panels/schema-diagram/Sche import $RefParser from '@apidevtools/json-schema-ref-parser'; import {useErrorService} from '@/utility/errorServiceInstance.ts'; import {pathToJsonPointer} from '@/utility/pathUtils.ts'; -import {stringToIdentifier, urlStringToIdentifier} from '@/utility/stringToIdentifier.ts'; +import {urlStringToIdentifier} from '@/utility/stringToIdentifier.ts'; +import { + copySelectedSchemaToClipboard, + pasteSchemaFromClipboard, +} from '@/components/panels/schema-diagram/schemaClipboardUtils'; const emit = defineEmits<{ (e: 'update_current_path', path: Path): void; @@ -110,6 +114,33 @@ onMounted(() => { }); }); +async function handleCopy(event?: ClipboardEvent) { + await copyToClipboard(event); + event?.preventDefault(); // override default browser copy +} +async function handlePaste(event?: ClipboardEvent) { + await pasteFromClipboard(event); + event?.preventDefault(); // override default browser paste +} + +async function copyToClipboard(event?: ClipboardEvent) { + await copySelectedSchemaToClipboard( + event, + schemaData, + selectedData.value, + schemaSession.currentSelectedElement.value + ); +} + +async function pasteFromClipboard(event?: ClipboardEvent) { + try { + const pastedPath = await pasteSchemaFromClipboard(event, schemaData, selectedData.value); + selectElement(pastedPath); + } catch (err) { + console.error('Failed to read from clipboard:', err); + } +} + // scroll to the current selected element when it changes watch( schemaSession.currentSelectedElement, @@ -424,7 +455,7 @@ function updateExternalReferenceValue(