Мелкие поправки

This commit is contained in:
Book Pauk
2019-01-16 05:26:09 +07:00
parent 6aa935141b
commit de0eca3097
2 changed files with 15 additions and 5 deletions

View File

@@ -2,7 +2,7 @@
<div ref="main" class="main">
<!--pre>{{ meta }}</pre-->
<p v-for="item in items" :key="item.id">
{{ item.text }}
<pre>{{ item.text }}</pre>
</p>
</div>
</template>
@@ -168,6 +168,10 @@ class TextPage extends Vue {
flex-direction: column;
}
pre {
margin: 0;
padding: 0;
}
p {
margin: 0;
padding: 0;

View File

@@ -259,24 +259,30 @@ export default class BookParser {
}
}*/
// тут начинается самый замес, перенос и выравниване по ширине
const text = this.removeTags(para.text);
const words = text.split(' ');
let line = {begin: para.offset, parts: []};
let part = '';
let j = 0;
let k = 0;
// тут начинается самый замес, перенос и выравниване по ширине
for (let i = 0; i < words.length; i++) {
const word = words[i];
if (i > 0)
if (j > 0)
part += ' ';
j++;
part += word;
if (this.measureText(part) >= parsed.w || i == words.length - 1) {
line.parts.push({style: '', text: part});
line.parts.push({style: '', text: (k == 0 ? ' ' : '') + part});
line.end = line.begin + part.length - 1;
lines.push(line);
part = '';
line = {begin: line.end + 1, parts: []};
part = '';
j = 0;
k++;
}
}