marked extract of search on text (scrolling is not working yet
This commit is contained in:
@@ -5,7 +5,7 @@
|
|||||||
class="tei"
|
class="tei"
|
||||||
:class="{ active: uuid === textid }"
|
:class="{ active: uuid === textid }"
|
||||||
:data-uuid="uuid"
|
:data-uuid="uuid"
|
||||||
v-html="tei"
|
v-html="teiparsed"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@@ -25,12 +25,14 @@ export default {
|
|||||||
tei: String,
|
tei: String,
|
||||||
uuid: String,
|
uuid: String,
|
||||||
textid: String,
|
textid: String,
|
||||||
|
extract: String,
|
||||||
url: String
|
url: String
|
||||||
},
|
},
|
||||||
data: () => ({
|
data: () => ({
|
||||||
template: null,
|
template: null,
|
||||||
html: null,
|
html: null,
|
||||||
pages: []
|
pages: [],
|
||||||
|
teiparsed: null
|
||||||
}),
|
}),
|
||||||
watch: {
|
watch: {
|
||||||
tei: function (newtei, oldtei) {
|
tei: function (newtei, oldtei) {
|
||||||
@@ -41,7 +43,7 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
beforeMount () {
|
beforeMount () {
|
||||||
console.log('EdText beforeMount', this.tei)
|
// console.log('EdText beforeMount', this.tei)
|
||||||
if (this.tei) {
|
if (this.tei) {
|
||||||
// this.buildTemplate()
|
// this.buildTemplate()
|
||||||
this.parseTei()
|
this.parseTei()
|
||||||
@@ -82,11 +84,15 @@ export default {
|
|||||||
// // console.log('EdText: builded html', this.html)
|
// // console.log('EdText: builded html', this.html)
|
||||||
// },
|
// },
|
||||||
parseTei () {
|
parseTei () {
|
||||||
|
this.teiparsed = this.tei
|
||||||
this.parseLinks()
|
this.parseLinks()
|
||||||
this.parseFigures()
|
this.parseFigures()
|
||||||
|
if (this.textid === this.uuid) {
|
||||||
|
this.parseExtract()
|
||||||
|
}
|
||||||
},
|
},
|
||||||
parseLinks () {
|
parseLinks () {
|
||||||
let links = this.tei.match(/<a[^<]+<\/a>/g)
|
let links = this.teiparsed.match(/<a[^<]+<\/a>/g)
|
||||||
// console.log('links', links)
|
// console.log('links', links)
|
||||||
if (links) {
|
if (links) {
|
||||||
// let domparser = new DOMParser()
|
// let domparser = new DOMParser()
|
||||||
@@ -118,15 +124,15 @@ export default {
|
|||||||
`<sup class="mdi mdi-message-text-outline" />` +
|
`<sup class="mdi mdi-message-text-outline" />` +
|
||||||
`</a>`
|
`</a>`
|
||||||
// console.log('newlink', newlink)
|
// console.log('newlink', newlink)
|
||||||
this.tei = this.tei.replace(links[i], newlink)
|
this.teiparsed = this.teiparsed.replace(links[i], newlink)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// console.log('this.html', this.html)
|
// console.log('this.html', this.html)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
parseFigures () {
|
parseFigures () {
|
||||||
console.log('parseFigures this.tei', this.tei)
|
// console.log('parseFigures this.tei', this.teiparsed)
|
||||||
let imgs = this.tei.match(/<img[^>]*>/g)
|
let imgs = this.teiparsed.match(/<img[^>]*>/g)
|
||||||
console.log('imgs', imgs)
|
console.log('imgs', imgs)
|
||||||
if (imgs) {
|
if (imgs) {
|
||||||
let imgparts, newsrc, newimg
|
let imgparts, newsrc, newimg
|
||||||
@@ -143,11 +149,21 @@ export default {
|
|||||||
` alt="${imgparts[2]}"` +
|
` alt="${imgparts[2]}"` +
|
||||||
`/>`
|
`/>`
|
||||||
// console.log('newlink', newlink)
|
// console.log('newlink', newlink)
|
||||||
this.tei = this.tei.replace(imgs[i], newimg)
|
this.teiparsed = this.teiparsed.replace(imgs[i], newimg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
parseExtract () {
|
||||||
|
console.log('Parse extract', this.extract)
|
||||||
|
let regexp = RegExp(this.extract, 'gim')
|
||||||
|
let index = 0
|
||||||
|
function marking (str) {
|
||||||
|
index++
|
||||||
|
return `<mark class="extract" id="mark-${index}">${str}</mark>`
|
||||||
|
}
|
||||||
|
this.teiparsed = this.teiparsed.replace(regexp, marking)
|
||||||
|
},
|
||||||
// parsePageBreaks () {
|
// parsePageBreaks () {
|
||||||
// let pbs = this.html.match(/<span role="pageBreak"[^>]+><\/span>/g)
|
// let pbs = this.html.match(/<span role="pageBreak"[^>]+><\/span>/g)
|
||||||
// console.log('pagebreaks', pbs)
|
// console.log('pagebreaks', pbs)
|
||||||
|
|||||||
@@ -33,6 +33,9 @@ export default {
|
|||||||
result: {
|
result: {
|
||||||
type: Object,
|
type: Object,
|
||||||
required: true
|
required: true
|
||||||
|
},
|
||||||
|
searchedkeys: {
|
||||||
|
type: String
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// data: () => ({
|
// data: () => ({
|
||||||
@@ -69,10 +72,11 @@ export default {
|
|||||||
size: this.result.size
|
size: this.result.size
|
||||||
})
|
})
|
||||||
this.$router.push({
|
this.$router.push({
|
||||||
name: `editiontext`,
|
name: `editiontextextract`,
|
||||||
params: {
|
params: {
|
||||||
id: this.result.textId,
|
id: this.result.textId,
|
||||||
textid: this.result.uuid
|
textid: this.result.uuid,
|
||||||
|
extract: this.searchedkeys
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,6 +43,10 @@ export default {
|
|||||||
this.scrollToRef()
|
this.scrollToRef()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
mounted () {
|
||||||
|
console.log('mounted')
|
||||||
|
this.scrollToRef()
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
onScrollCenter (e) {
|
onScrollCenter (e) {
|
||||||
// console.log('mainLayout onScrollCenter: e', e)
|
// console.log('mainLayout onScrollCenter: e', e)
|
||||||
|
|||||||
@@ -25,7 +25,7 @@
|
|||||||
<div class="wrapper">
|
<div class="wrapper">
|
||||||
<ul v-if="results.length">
|
<ul v-if="results.length">
|
||||||
<li v-for="result in results" :key="result.uuid" class="result">
|
<li v-for="result in results" :key="result.uuid" class="result">
|
||||||
<ResultItem :result="result" />
|
<ResultItem :result="result" :searchedkeys="searchedKeys" />
|
||||||
</li>
|
</li>
|
||||||
<infinite-loading
|
<infinite-loading
|
||||||
v-if="offset < resultsQuantity.quantity"
|
v-if="offset < resultsQuantity.quantity"
|
||||||
|
|||||||
@@ -70,6 +70,7 @@
|
|||||||
:uuid="text.content.uuid"
|
:uuid="text.content.uuid"
|
||||||
:url="text.content.url"
|
:url="text.content.url"
|
||||||
:textid="textid"
|
:textid="textid"
|
||||||
|
:extract="extract"
|
||||||
@onHoverLink="onHoverLink"
|
@onHoverLink="onHoverLink"
|
||||||
@onLeaveLink="onLeaveLink"
|
@onLeaveLink="onLeaveLink"
|
||||||
/>
|
/>
|
||||||
@@ -177,6 +178,13 @@ export default {
|
|||||||
if (to.params.textid) {
|
if (to.params.textid) {
|
||||||
// change textid when route change
|
// change textid when route change
|
||||||
this.textid = to.params.textid
|
this.textid = to.params.textid
|
||||||
|
// change also extract if exists
|
||||||
|
if (to.params.extract) {
|
||||||
|
console.log('extract params from route', to.params.extract)
|
||||||
|
this.extract = to.params.extract
|
||||||
|
// scrolling is not working :(
|
||||||
|
this.reftoscrollto = '#mark-1'
|
||||||
|
}
|
||||||
} else if (this.toc) {
|
} else if (this.toc) {
|
||||||
// if no textid in new route (e.g. edition front)
|
// if no textid in new route (e.g. edition front)
|
||||||
// but we have toc
|
// but we have toc
|
||||||
@@ -187,6 +195,9 @@ export default {
|
|||||||
this.textid = null
|
this.textid = null
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
reftoscrollto (newref, oldref) {
|
||||||
|
console.log('reftoscrollto changed', oldref, newref)
|
||||||
|
},
|
||||||
textid (newid, oldid) {
|
textid (newid, oldid) {
|
||||||
console.log('textid watcher', this, oldid, newid)
|
console.log('textid watcher', this, oldid, newid)
|
||||||
this.texts = []
|
this.texts = []
|
||||||
@@ -220,6 +231,13 @@ export default {
|
|||||||
this.textid = this.$route.params.textid
|
this.textid = this.$route.params.textid
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// get the searchkeys from route param (only comming from result item) for text highlighting
|
||||||
|
if (this.$route.params.extract) {
|
||||||
|
this.extract = this.$route.params.extract
|
||||||
|
// scrolling is not working :(
|
||||||
|
this.reftoscrollto = '#mark-1'
|
||||||
|
}
|
||||||
|
|
||||||
// wait for editions list from Corpus Store if not already loaded
|
// wait for editions list from Corpus Store if not already loaded
|
||||||
if (!this.corpusLoaded) {
|
if (!this.corpusLoaded) {
|
||||||
// this.getCorpuses()
|
// this.getCorpuses()
|
||||||
|
|||||||
@@ -49,6 +49,11 @@ const routes = [
|
|||||||
path: '/edition/:id/:textid',
|
path: '/edition/:id/:textid',
|
||||||
component: Edition
|
component: Edition
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: 'editiontextextract',
|
||||||
|
path: '/edition/:id/:textid/:extract',
|
||||||
|
component: Edition
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: 'indexNominum',
|
name: 'indexNominum',
|
||||||
path: '/nominum',
|
path: '/nominum',
|
||||||
|
|||||||
Reference in New Issue
Block a user