Доделки CopyTextPage, в настроки добвлен параметр "copyFullText"
This commit is contained in:
@@ -6,6 +6,9 @@
|
|||||||
Скопировать текст
|
Скопировать текст
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
<div ref="text" class="text" tabindex="-1">
|
||||||
|
<div v-html="text"></div>
|
||||||
|
</div>
|
||||||
</Window>
|
</Window>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -25,6 +28,7 @@ export default @Component({
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
class CopyTextPage extends Vue {
|
class CopyTextPage extends Vue {
|
||||||
|
text = null;
|
||||||
initStep = null;
|
initStep = null;
|
||||||
initPercentage = 0;
|
initPercentage = 0;
|
||||||
|
|
||||||
@@ -33,19 +37,37 @@ class CopyTextPage extends Vue {
|
|||||||
this.reader = this.$store.state.reader;
|
this.reader = this.$store.state.reader;
|
||||||
}
|
}
|
||||||
|
|
||||||
async init(bookPos, parsed) {
|
async init(bookPos, parsed, copyFullText) {
|
||||||
if (this.parsed != parsed) {
|
if (parsed && this.parsed != parsed) {
|
||||||
|
this.text = 'Загрузка';
|
||||||
|
await this.$nextTick();
|
||||||
|
|
||||||
|
const paraIndex = parsed.findParaIndex(bookPos);
|
||||||
this.initStep = true;
|
this.initStep = true;
|
||||||
this.stopInit = false;
|
this.stopInit = false;
|
||||||
|
|
||||||
let nextPerc = 0;
|
let nextPerc = 0;
|
||||||
let text = '';
|
let text = '';
|
||||||
for (let i = 0; i < parsed.para.length; i++) {
|
let cut = '';
|
||||||
|
let from = 0;
|
||||||
|
let to = parsed.para.length;
|
||||||
|
if (!copyFullText) {
|
||||||
|
from = paraIndex - 100;
|
||||||
|
from = (from < 0 ? 0 : from);
|
||||||
|
to = paraIndex + 100;
|
||||||
|
to = (to > parsed.para.length ? parsed.para.length : to);
|
||||||
|
cut = '<p>..... Текст вырезан. Если хотите скопировать больше, поставьте в настройках галочку "Загружать весь текст"';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (from > 0)
|
||||||
|
text += cut;
|
||||||
|
for (let i = from; i < to; i++) {
|
||||||
const p = parsed.para[i];
|
const p = parsed.para[i];
|
||||||
const parts = parsed.splitToStyle(p.text);
|
const parts = parsed.splitToStyle(p.text);
|
||||||
if (this.stopInit)
|
if (this.stopInit)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
text += `<p id="p${i}" class="copyPara">`;
|
||||||
for (const part of parts)
|
for (const part of parts)
|
||||||
text += part.text;
|
text += part.text;
|
||||||
|
|
||||||
@@ -57,9 +79,20 @@ class CopyTextPage extends Vue {
|
|||||||
nextPerc = perc + 10;
|
nextPerc = perc + 10;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (to < parsed.para.length)
|
||||||
|
text += cut;
|
||||||
|
|
||||||
|
this.text = text;
|
||||||
this.initStep = false;
|
this.initStep = false;
|
||||||
this.parsed = parsed;
|
this.parsed = parsed;
|
||||||
|
|
||||||
|
await this.$nextTick();
|
||||||
|
this.$refs.text.focus();
|
||||||
|
|
||||||
|
const p = document.getElementById('p' + paraIndex);
|
||||||
|
if (p) {
|
||||||
|
this.$refs.text.scrollTop = p.offsetTop;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -92,40 +125,27 @@ class CopyTextPage extends Vue {
|
|||||||
|
|
||||||
.mainWindow {
|
.mainWindow {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
max-width: 500px;
|
height: 100%;
|
||||||
height: 125px;
|
|
||||||
display: flex;
|
display: flex;
|
||||||
position: relative;
|
|
||||||
top: -50px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.content {
|
.text {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
display: flex;
|
overflow-wrap: anywhere;
|
||||||
justify-content: center;
|
overflow-y: auto;
|
||||||
align-items: center;
|
margin: 0 10px 0 10px;
|
||||||
padding: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.input {
|
|
||||||
display: flex;
|
|
||||||
margin: 0;
|
|
||||||
padding: 0;
|
|
||||||
width: 100%;
|
|
||||||
position: relative;
|
position: relative;
|
||||||
|
font-size: 120%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.button-group {
|
.text:focus {
|
||||||
width: 150px;
|
outline: none;
|
||||||
margin: 0;
|
}
|
||||||
padding: 0;
|
</style>
|
||||||
}
|
<style>
|
||||||
|
.copyPara {
|
||||||
.el-button {
|
margin: 0;
|
||||||
padding: 9px 17px 9px 17px;
|
padding: 0;
|
||||||
}
|
text-indent: 30px;
|
||||||
|
|
||||||
i {
|
|
||||||
font-size: 20px;
|
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
@@ -125,6 +125,7 @@ export default @Component({
|
|||||||
},
|
},
|
||||||
settings: function(newValue) {
|
settings: function(newValue) {
|
||||||
this.allowUrlParamBookPos = newValue.allowUrlParamBookPos;
|
this.allowUrlParamBookPos = newValue.allowUrlParamBookPos;
|
||||||
|
this.copyFullText = newValue.copyFullText;
|
||||||
this.updateRoute();
|
this.updateRoute();
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -170,6 +171,7 @@ class Reader extends Vue {
|
|||||||
});
|
});
|
||||||
|
|
||||||
this.allowUrlParamBookPos = this.settings.allowUrlParamBookPos;
|
this.allowUrlParamBookPos = this.settings.allowUrlParamBookPos;
|
||||||
|
this.copyFullText = this.settings.copyFullText;
|
||||||
}
|
}
|
||||||
|
|
||||||
mounted() {
|
mounted() {
|
||||||
@@ -353,7 +355,7 @@ class Reader extends Vue {
|
|||||||
this.copyTextActive = true;
|
this.copyTextActive = true;
|
||||||
|
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
this.$refs.copyTextPage.init(this.mostRecentBook().bookPos, page.parsed);
|
this.$refs.copyTextPage.init(this.mostRecentBook().bookPos, page.parsed, this.copyFullText);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
this.searchActive = false;
|
this.searchActive = false;
|
||||||
|
|||||||
@@ -257,6 +257,15 @@
|
|||||||
<el-checkbox v-model="lazyParseEnabled">Предварительная обработка текста</el-checkbox>
|
<el-checkbox v-model="lazyParseEnabled">Предварительная обработка текста</el-checkbox>
|
||||||
</el-tooltip>
|
</el-tooltip>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
<el-form-item label="Копирование">
|
||||||
|
<el-tooltip :open-delay="500" effect="light">
|
||||||
|
<template slot="content">
|
||||||
|
Загружать весь текст в окно<br>
|
||||||
|
копирования текста со страницы
|
||||||
|
</template>
|
||||||
|
<el-checkbox v-model="copyFullText">Загружать весь текст</el-checkbox>
|
||||||
|
</el-tooltip>
|
||||||
|
</el-form-item>
|
||||||
|
|
||||||
</el-form>
|
</el-form>
|
||||||
|
|
||||||
|
|||||||
@@ -157,6 +157,7 @@ const settingDefaults = {
|
|||||||
|
|
||||||
allowUrlParamBookPos: false,
|
allowUrlParamBookPos: false,
|
||||||
lazyParseEnabled: false,
|
lazyParseEnabled: false,
|
||||||
|
copyFullText: false,
|
||||||
fontShifts: {},
|
fontShifts: {},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user