From be7eb9269c8a69be992ecadd046e86403edfc67c Mon Sep 17 00:00:00 2001 From: Book Pauk Date: Sun, 3 Feb 2019 20:30:07 +0700 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B4=D0=B5=D0=BB=D0=BA=D0=B8=20Co?= =?UTF-8?q?pyTextPage,=20=D0=B2=20=D0=BD=D0=B0=D1=81=D1=82=D1=80=D0=BE?= =?UTF-8?q?=D0=BA=D0=B8=20=D0=B4=D0=BE=D0=B1=D0=B2=D0=BB=D0=B5=D0=BD=20?= =?UTF-8?q?=D0=BF=D0=B0=D1=80=D0=B0=D0=BC=D0=B5=D1=82=D1=80=20"copyFullTex?= =?UTF-8?q?t"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Reader/CopyTextPage/CopyTextPage.vue | 80 ++++++++++++------- client/components/Reader/Reader.vue | 4 +- .../Reader/SettingsPage/SettingsPage.vue | 9 +++ client/store/modules/reader.js | 1 + 4 files changed, 63 insertions(+), 31 deletions(-) diff --git a/client/components/Reader/CopyTextPage/CopyTextPage.vue b/client/components/Reader/CopyTextPage/CopyTextPage.vue index dcb6177c..d28bbec5 100644 --- a/client/components/Reader/CopyTextPage/CopyTextPage.vue +++ b/client/components/Reader/CopyTextPage/CopyTextPage.vue @@ -6,6 +6,9 @@ Скопировать текст +
+
+
@@ -25,6 +28,7 @@ export default @Component({ }, }) class CopyTextPage extends Vue { + text = null; initStep = null; initPercentage = 0; @@ -33,19 +37,37 @@ class CopyTextPage extends Vue { this.reader = this.$store.state.reader; } - async init(bookPos, parsed) { - if (this.parsed != parsed) { + async init(bookPos, parsed, copyFullText) { + if (parsed && this.parsed != parsed) { + this.text = 'Загрузка'; + await this.$nextTick(); + + const paraIndex = parsed.findParaIndex(bookPos); this.initStep = true; this.stopInit = false; let nextPerc = 0; 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 = '

..... Текст вырезан. Если хотите скопировать больше, поставьте в настройках галочку "Загружать весь текст"'; + } + + if (from > 0) + text += cut; + for (let i = from; i < to; i++) { const p = parsed.para[i]; const parts = parsed.splitToStyle(p.text); if (this.stopInit) return; + text += `

`; for (const part of parts) text += part.text; @@ -56,10 +78,21 @@ class CopyTextPage extends Vue { await sleep(1); nextPerc = perc + 10; } - } + } + if (to < parsed.para.length) + text += cut; + this.text = text; this.initStep = false; 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 { width: 100%; - max-width: 500px; - height: 125px; + height: 100%; display: flex; - position: relative; - top: -50px; } -.content { +.text { flex: 1; - display: flex; - justify-content: center; - align-items: center; - padding: 10px; -} - -.input { - display: flex; - margin: 0; - padding: 0; - width: 100%; + overflow-wrap: anywhere; + overflow-y: auto; + margin: 0 10px 0 10px; position: relative; + font-size: 120%; } -.button-group { - width: 150px; +.text:focus { + outline: none; +} + + \ No newline at end of file diff --git a/client/components/Reader/Reader.vue b/client/components/Reader/Reader.vue index daecd469..32f5c3bf 100644 --- a/client/components/Reader/Reader.vue +++ b/client/components/Reader/Reader.vue @@ -125,6 +125,7 @@ export default @Component({ }, settings: function(newValue) { this.allowUrlParamBookPos = newValue.allowUrlParamBookPos; + this.copyFullText = newValue.copyFullText; this.updateRoute(); }, }, @@ -170,6 +171,7 @@ class Reader extends Vue { }); this.allowUrlParamBookPos = this.settings.allowUrlParamBookPos; + this.copyFullText = this.settings.copyFullText; } mounted() { @@ -353,7 +355,7 @@ class Reader extends Vue { this.copyTextActive = true; this.$nextTick(() => { - this.$refs.copyTextPage.init(this.mostRecentBook().bookPos, page.parsed); + this.$refs.copyTextPage.init(this.mostRecentBook().bookPos, page.parsed, this.copyFullText); }); } else { this.searchActive = false; diff --git a/client/components/Reader/SettingsPage/SettingsPage.vue b/client/components/Reader/SettingsPage/SettingsPage.vue index 9a64ae7a..3bd3b7fc 100644 --- a/client/components/Reader/SettingsPage/SettingsPage.vue +++ b/client/components/Reader/SettingsPage/SettingsPage.vue @@ -257,6 +257,15 @@ Предварительная обработка текста + + + + Загружать весь текст + + diff --git a/client/store/modules/reader.js b/client/store/modules/reader.js index 8c27f26a..9e522b6f 100644 --- a/client/store/modules/reader.js +++ b/client/store/modules/reader.js @@ -157,6 +157,7 @@ const settingDefaults = { allowUrlParamBookPos: false, lazyParseEnabled: false, + copyFullText: false, fontShifts: {}, };