Переделки отображения needle при поиске
This commit is contained in:
@@ -47,16 +47,46 @@ export default class DrawHelper {
|
|||||||
text: String,
|
text: String,
|
||||||
}
|
}
|
||||||
}*/
|
}*/
|
||||||
|
let sel = new Set();
|
||||||
|
if (i == 0 && this.searching) {
|
||||||
|
let pureText = '';
|
||||||
|
for (const part of line.parts) {
|
||||||
|
pureText += part.text;
|
||||||
|
}
|
||||||
|
|
||||||
|
pureText = pureText.toLowerCase();
|
||||||
|
let j = 0;
|
||||||
|
while (1) {// eslint-disable-line no-constant-condition
|
||||||
|
j = pureText.indexOf(this.needle, j);
|
||||||
|
if (j >= 0) {
|
||||||
|
for (let k = 0; k < this.needle.length; k++) {
|
||||||
|
sel.add(j + k);
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
break;
|
||||||
|
j++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let lineText = '';
|
let lineText = '';
|
||||||
let center = false;
|
let center = false;
|
||||||
|
let j = 0;
|
||||||
for (const part of line.parts) {
|
for (const part of line.parts) {
|
||||||
let tOpen = (part.style.bold ? '<b>' : '');
|
let tOpen = (part.style.bold ? '<b>' : '');
|
||||||
tOpen += (part.style.italic ? '<i>' : '');
|
tOpen += (part.style.italic ? '<i>' : '');
|
||||||
let tClose = (part.style.italic ? '</i>' : '');
|
let tClose = (part.style.italic ? '</i>' : '');
|
||||||
tClose += (part.style.bold ? '</b>' : '');
|
tClose += (part.style.bold ? '</b>' : '');
|
||||||
|
|
||||||
lineText += `${tOpen}${part.text}${tClose}`;
|
let text = '';
|
||||||
|
if (i == 0 && this.searching) {
|
||||||
|
for (let k = 0; k < part.text.length; k++) {
|
||||||
|
text += (sel.has(j) ? `<ins>${part.text[k]}</ins>` : part.text[k]);
|
||||||
|
j++;
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
text = part.text;
|
||||||
|
|
||||||
|
lineText += `${tOpen}${text}${tClose}`;
|
||||||
|
|
||||||
center = center || part.style.center;
|
center = center || part.style.center;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -436,15 +436,7 @@ class TextPage extends Vue {
|
|||||||
}
|
}
|
||||||
|
|
||||||
startSearch(needle) {
|
startSearch(needle) {
|
||||||
this.drawHelper.needle = '';
|
this.drawHelper.needle = needle;
|
||||||
const words = needle.split(' ');
|
|
||||||
for (const word of words) {
|
|
||||||
if (word != '') {
|
|
||||||
this.drawHelper.needle = word;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this.drawHelper.searching = true;
|
this.drawHelper.searching = true;
|
||||||
this.draw();
|
this.draw();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user