index -> text : highlight item in text with id #806

This commit is contained in:
2022-05-13 15:27:58 +02:00
parent 10c4abfa82
commit b958a09cfa
6 changed files with 28 additions and 24 deletions
+5 -3
View File
@@ -25,7 +25,7 @@ export default {
tei: String, tei: String,
uuid: String, uuid: String,
textid: String, textid: String,
extract: String, extractid: String,
url: String url: String
}, },
data: () => ({ data: () => ({
@@ -155,8 +155,10 @@ export default {
} }
}, },
parseExtract () { parseExtract () {
console.log('Parse extract', this.extract) console.log('Parse extract', this.extractid)
let regexp = RegExp(this.extract, 'gim') // let regexp = RegExp(this.extract, 'gim')
let regexp = RegExp(`<span[^>]* id="${this.extractid}"[^>]*>[^<]*</span>`)
// let regexp = RegExp(`<(\w+)((?:\s+\w+(?:\s*=\s*(?:"[\s\S]*?"|'[\s\S]*?'|[^'">\s]+))?)+\s*|\s*)>([\s\S]*?)<\/\1>`)
let index = 0 let index = 0
function marking (str) { function marking (str) {
index++ index++
@@ -24,7 +24,7 @@
> >
<h3> <h3>
<a <a
:href="'/edition/'+ed.item" :href="'/texts/'+ed.item"
:uuid="ed.item" :uuid="ed.item"
v-html="ed.biblio" v-html="ed.biblio"
/> />
+15 -13
View File
@@ -2,12 +2,13 @@
<section :class="{opened: isopened}"> <section :class="{opened: isopened}">
<h4> <h4>
<a <a
:href="'/edition/'+ed.item+'/'+oc.uuid+'/'+oc.form" :href="'/texts/'+ed.item+'/'+oc.uuid+'/'+oc.ids[0]"
:uuid="oc.uuid" :uuid="oc.uuid"
:eduuid="ed.item" :eduuid="ed.item"
:form="oc.form" :form="oc.form"
@click.prevent="onGoToText" :ocid="oc.ids[0]"
@keyup.enter="onGoToText" @click.prevent="onGoToText($event, ed.item, oc.uuid, oc.ids[0])"
@keyup.enter="onGoToText($event, ed.item, oc.uuid, oc.ids[0])"
> >
<span v-html="oc.title" /> <span v-if="oc.form" class="form">( "{{ oc.form }}" )</span> <span v-html="oc.title" /> <span v-if="oc.form" class="form">( "{{ oc.form }}" )</span>
</a> </a>
@@ -79,15 +80,16 @@ export default {
...mapActions({ ...mapActions({
addHistoryItem: 'History/addItem' addHistoryItem: 'History/addItem'
}), }),
onGoToText (e) { onGoToText (e, edid, textid, ocid) {
console.log('clicked on text occurence', e, this.oc.title, this.ed) console.log('clicked on text occurence', e, edid, textid, ocid)
if (e.target.getAttribute('eduuid')) { if (textid) {
this.addHistoryItem({ this.addHistoryItem({
id: e.target.getAttribute('eduuid'), id: edid,
textid: e.target.getAttribute('uuid'), textid: textid,
title: this.oc.title, title: this.oc.title,
editionTitle: this.editionTitle editionTitle: this.editionTitle,
ocid: ocid
}) })
// if (e.target.getAttribute('form')) { // if (e.target.getAttribute('form')) {
// this.$router.push({ // this.$router.push({
@@ -101,9 +103,9 @@ export default {
this.$router.push({ this.$router.push({
name: `editiontextextract`, name: `editiontextextract`,
params: { params: {
id: e.target.getAttribute('eduuid'), id: edid,
textid: e.target.getAttribute('uuid'), textid: textid,
extract: e.target.getAttribute('form') ocid: ocid
} }
}) })
// } // }
@@ -111,7 +113,7 @@ export default {
this.$router.push({ this.$router.push({
name: `edition`, name: `edition`,
params: { params: {
id: e.target.getAttribute('uuid') id: edid
} }
}) })
} }
+1 -1
View File
@@ -49,7 +49,7 @@ export default {
}, },
methods: { methods: {
onScrollCenter (e) { onScrollCenter (e) {
console.log('mainLayout onScrollCenter: e', e) // console.log('mainLayout onScrollCenter: e', e)
this.$emit('onCenterScrolled', e) this.$emit('onCenterScrolled', e)
}, },
scrollToRef () { scrollToRef () {
+5 -5
View File
@@ -81,7 +81,7 @@
:uuid="text.content.uuid" :uuid="text.content.uuid"
:url="text.content.url" :url="text.content.url"
:textid="textid" :textid="textid"
:extract="extract" :extractid="extractid"
@onHoverLink="onHoverLink" @onHoverLink="onHoverLink"
@onLeaveLink="onLeaveLink" @onLeaveLink="onLeaveLink"
/> />
@@ -195,7 +195,7 @@ export default {
// change also extract if exists // change also extract if exists
if (to.params.extract) { if (to.params.extract) {
console.log('extract params from route', to.params.extract) console.log('extract params from route', to.params.extract)
this.extract = to.params.extract this.extractid = to.params.ocid
// scrolling is not working :( // scrolling is not working :(
this.reftoscrollto = '#mark-1' this.reftoscrollto = '#mark-1'
} }
@@ -246,8 +246,8 @@ export default {
} }
// get the searchkeys from route param (only comming from result item) for text highlighting // get the searchkeys from route param (only comming from result item) for text highlighting
if (this.$route.params.extract) { if (this.$route.params.ocid) {
this.extract = this.$route.params.extract this.extractid = this.$route.params.ocid
// scrolling is not working :( // scrolling is not working :(
this.reftoscrollto = '#mark-1' this.reftoscrollto = '#mark-1'
} }
@@ -351,7 +351,7 @@ export default {
}) })
}, },
onCenterScrolled (e) { onCenterScrolled (e) {
console.log('Edition centerScrolled(e)', e.target.scrollTop) // console.log('Edition centerScrolled(e)', e.target.scrollTop)
if (!this.center_scrolled && e.target.scrollTop > this.inifinite_load_distance * 1.5) { if (!this.center_scrolled && e.target.scrollTop > this.inifinite_load_distance * 1.5) {
this.center_scrolled = true this.center_scrolled = true
} }
+1 -1
View File
@@ -51,7 +51,7 @@ const routes = [
}, },
{ {
name: 'editiontextextract', name: 'editiontextextract',
path: '/texts/:id/:textid/:extract', path: '/texts/:id/:textid/:ocid',
component: Edition component: Edition
}, },
{ {