From 6ad8d41784e932dfd1cfd647101d3aa3ec0ab0be Mon Sep 17 00:00:00 2001 From: Johannes Kepper Date: Sun, 4 Feb 2024 00:14:46 +0100 Subject: [PATCH] initial xml editor for diploTrans --- src/components/DiploTab.vue | 20 ++++-- src/components/FacsimileComponent.vue | 38 +++++++++++- src/components/XmlEditor.vue | 11 +++- src/store/data/index.js | 89 ++++++++++++++++++++++++++- src/store/gui/index.js | 29 ++++++++- 5 files changed, 175 insertions(+), 12 deletions(-) diff --git a/src/components/DiploTab.vue b/src/components/DiploTab.vue index 25d34a1..c37fc67 100644 --- a/src/components/DiploTab.vue +++ b/src/components/DiploTab.vue @@ -32,9 +32,9 @@ - +
+ +
@@ -55,6 +55,7 @@ import WritingZoneDirectory from '@/components/WritingZoneDirectory.vue' import FacsimileComponent from '@/components/FacsimileComponent.vue' import VerovioComponent from '@/components/shared/VerovioComponent.vue' +import XmlEditor from '@/components/XmlEditor.vue' export default { name: 'DiploTab', @@ -66,7 +67,8 @@ export default { SourceSelector, WritingZoneDirectory, FacsimileComponent, - VerovioComponent + VerovioComponent, + XmlEditor }, methods: { toggleSidebar () { @@ -148,7 +150,7 @@ export default { } }, computed: { - ...mapGetters(['diploTabSidebarVisible', 'diploTransActivationsInShapes', 'diploTransActivationsInAnnotTrans', 'diplomaticTranscriptsOnCurrentPage']), + ...mapGetters(['diploTabSidebarVisible', 'diploTransActivationsInShapes', 'diploTransActivationsInAnnotTrans', 'diplomaticTranscriptsOnCurrentPage', 'activeDiploTransElementId']), showInitializeButton () { const currentWz = this.$store.getters.currentWritingZoneObject if (!currentWz) { @@ -161,6 +163,12 @@ export default { const annotTransAvailable = this.$store.getters.availableAnnotatedTranscripts.indexOf(annotTransLink) !== -1 const diploTransAvailable = this.$store.getters.availableDiplomaticTranscripts.indexOf(diploTransLink) !== -1 return annotTransAvailable && !diploTransAvailable + }, + editorSettings () { + return { + filePath: this.$store.getters.currentWritingZoneObject?.diploTrans, + id: this.$store.getters.activeDiploTransElementId + } } }, created () { @@ -305,7 +313,7 @@ i.showSidebar { } .mainBox { - height: 33%; + height: 25%; padding: .5rem; } diff --git a/src/components/FacsimileComponent.vue b/src/components/FacsimileComponent.vue index c677d79..802c089 100644 --- a/src/components/FacsimileComponent.vue +++ b/src/components/FacsimileComponent.vue @@ -28,6 +28,30 @@ const osdOptions = { silenceMultiImageWarnings: true } +const rawSelectables = [ + 'note', + 'chord', + 'syl', + 'rest', + 'beam', + 'artic', + 'accid', + 'clef', + 'slur', + 'dynam', + 'dir', + 'keySig', + 'meterSig', + 'barLine' + // 'staff', + // 'measure' +] +let selectables = [] +rawSelectables.forEach(elem => { + selectables.push('.' + elem + ':not(.bounding-box)') +}) +selectables = selectables.join(', ') + export default { name: 'FacsimileComponent', props: { @@ -143,7 +167,7 @@ export default { click.page = clickedPagePos // } - // console.log(click) + console.log('-------------\n\nCLICK\n\n------------\n', click) // check for click to svg shape if (click.target.localName === 'path') { @@ -157,6 +181,17 @@ export default { this.$store.dispatch('setActiveSystem', id) } + if (click.target.closest('.diploTrans') && click.target.closest('.measure')) { + const wzId = click.target.closest('.diploTrans').getAttribute('data-diploTrans') + const target = click.target.closest(selectables) + if (target) { + const id = target.getAttribute('data-id') + this.$store.dispatch('setActiveWritingZone', wzId) + this.$store.dispatch('setActiveDiploTransElementId', id) + console.log('selecting activeDiploTransElementId: ', id) + } + } + /* const counterRotate = this.viewer.viewport.getRotation()// this.tileSource.degrees * -1 const center = { x: 0, y: 0 } @@ -822,6 +857,7 @@ export default { element.classList.add('activeDiploTrans') } element.setAttribute('data-diploTrans', dt.wzDetails.id) + element.setAttribute('data-filePath', dt.wzDetails.diploTrans) element.append(diplo) /* const x = viewBox.split(' ')[0] diff --git a/src/components/XmlEditor.vue b/src/components/XmlEditor.vue index 1777ea0..1cb800a 100644 --- a/src/components/XmlEditor.vue +++ b/src/components/XmlEditor.vue @@ -13,6 +13,7 @@