diff --git a/client/components/Reader/LoaderPage/PasteTextPage/PasteTextPage.vue b/client/components/Reader/LoaderPage/PasteTextPage/PasteTextPage.vue index cfcb01ae..b17fcd05 100644 --- a/client/components/Reader/LoaderPage/PasteTextPage/PasteTextPage.vue +++ b/client/components/Reader/LoaderPage/PasteTextPage/PasteTextPage.vue @@ -5,10 +5,15 @@ - +
+ +
+
+ @@ -20,6 +25,7 @@ import Vue from 'vue'; import Component from 'vue-class-component'; import Window from '../../../share/Window.vue'; +import _ from 'lodash'; export default @Component({ components: { @@ -27,6 +33,8 @@ export default @Component({ }, }) class PasteTextPage extends Vue { + bookTitle = ''; + created() { } @@ -34,8 +42,35 @@ class PasteTextPage extends Vue { this.$refs.textArea.focus(); } + getNonEmptyLine(text, count) { + let result = ''; + const lines = text.split("\n"); + let i = 0; + while (i < lines.length) { + if (lines[i].trim() != '') { + count--; + if (count <= 0) { + result = lines[i]; + break; + } + } + i++; + } + return result; + } + + calcTitle(event) { + if (this.bookTitle == '') { + let text = event.clipboardData.getData('text'); + this.bookTitle = _.compact([ + this.getNonEmptyLine(text, 1), + this.getNonEmptyLine(text, 2) + ]).join(' - '); + } + } + loadBuffer() { - this.$emit('load-buffer', {buffer: this.$refs.textArea.value}); + this.$emit('load-buffer', {buffer: `${this.bookTitle}${this.$refs.textArea.value}`}); this.close(); } @@ -90,4 +125,9 @@ class PasteTextPage extends Vue { .text:focus { outline: none; } + +hr { + margin: 0; + padding: 0; +}