TextPage.vue 45 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323
  1. <template>
  2. <div ref="main" class="main">
  3. <div class="layout back" @wheel.prevent.stop="onMouseWheel">
  4. <div class="absolute" v-html="background"></div>
  5. <div class="absolute" v-html="pageDivider"></div>
  6. </div>
  7. <div ref="scrollBox1" class="layout over-hidden" @wheel.prevent.stop="onMouseWheel">
  8. <div ref="scrollingPage1" class="layout over-hidden" @transitionend="onPage1TransitionEnd" @animationend="onPage1AnimationEnd">
  9. <div @copy.prevent="copyText" v-html="page1"></div>
  10. </div>
  11. </div>
  12. <div ref="scrollBox2" class="layout over-hidden" @wheel.prevent.stop="onMouseWheel">
  13. <div ref="scrollingPage2" class="layout over-hidden" @transitionend="onPage2TransitionEnd" @animationend="onPage2AnimationEnd">
  14. <div @copy.prevent="copyText" v-html="page2"></div>
  15. </div>
  16. </div>
  17. <div v-show="showStatusBar" ref="statusBar" class="layout">
  18. <div v-html="statusBar"></div>
  19. </div>
  20. <div
  21. v-show="clickControl" ref="layoutEvents" class="layout events"
  22. oncontextmenu="return false;"
  23. @mousedown.prevent.stop="onMouseDown" @mouseup.prevent.stop="onMouseUp"
  24. @wheel.prevent.stop="onMouseWheel"
  25. @touchstart.stop="onTouchStart" @touchend.stop="onTouchEnd" @touchmove.stop="onTouchMove" @touchcancel.prevent.stop="onTouchCancel"
  26. >
  27. <div
  28. v-show="showStatusBar && statusBarClickOpen" @mousedown.prevent.stop @touchstart.stop
  29. @click.prevent.stop="onStatusBarClick"
  30. v-html="statusBarClickable"
  31. ></div>
  32. </div>
  33. <div
  34. v-show="!clickControl && showStatusBar && statusBarClickOpen" class="layout"
  35. @mousedown.prevent.stop @touchstart.stop
  36. @click.prevent.stop="onStatusBarClick"
  37. v-html="statusBarClickable"
  38. >
  39. </div>
  40. <!-- невидимым делать нельзя (display: none), вовремя не подгружаютя шрифты -->
  41. <canvas ref="offscreenCanvas" class="layout" style="visibility: hidden"></canvas>
  42. <div ref="measureWidth" style="position: absolute; visibility: hidden"></div>
  43. </div>
  44. </template>
  45. <script>
  46. //-----------------------------------------------------------------------------
  47. import vueComponent from '../../vueComponent.js';
  48. import {loadCSS} from 'fg-loadcss';
  49. import _ from 'lodash';
  50. import he from 'he';
  51. import './TextPage.css';
  52. import * as utils from '../../../share/utils';
  53. import bookManager from '../share/bookManager';
  54. import DrawHelper from './DrawHelper';
  55. import rstore from '../../../store/modules/reader';
  56. import {clickMap} from '../share/clickMap';
  57. const minLayoutWidth = 100;
  58. const componentOptions = {
  59. watch: {
  60. bookPos: function() {
  61. this.$emit('book-pos-changed', {bookPos: this.bookPos, bookPosSeen: this.bookPosSeen});
  62. this.draw();
  63. if (this.userBookPosChange) {
  64. this.$emit('hide-tool-bar', {show: (this.bookPos == 0 || this.bookPos < this.prevBookPos)});
  65. this.prevBookPos = this.bookPos;
  66. this.userBookPosChange = false;
  67. }
  68. },
  69. bookPosSeen: function() {
  70. this.$emit('book-pos-changed', {bookPos: this.bookPos, bookPosSeen: this.bookPosSeen});
  71. },
  72. settings: function() {
  73. this.debouncedLoadSettings();
  74. },
  75. toggleLayout: function() {
  76. this.updateLayout();
  77. },
  78. inAnimation: function() {
  79. this.updateLayout();
  80. },
  81. },
  82. };
  83. class TextPage {
  84. _options = componentOptions;
  85. toggleLayout = false;
  86. showStatusBar = false;
  87. clickControl = true;
  88. background = null;
  89. pageDivider = null;
  90. page1 = null;
  91. page2 = null;
  92. statusBar = null;
  93. statusBarClickable = null;
  94. lastBook = null;
  95. bookPos = 0;
  96. bookPosSeen = null;
  97. prevBookPos = 0;
  98. userBookPosChange = false;
  99. fontStyle = null;
  100. fontSize = null;
  101. fontName = null;
  102. fontWeight = null;
  103. inAnimation = false;
  104. meta = null;
  105. created() {
  106. this.drawHelper = new DrawHelper();
  107. this.commit = this.$store.commit;
  108. this.dispatch = this.$store.dispatch;
  109. this.config = this.$store.state.config;
  110. this.reader = this.$store.state.reader;
  111. this.debouncedStartClickRepeat = _.debounce((x, y) => {
  112. this.startClickRepeat(x, y);
  113. }, 800);
  114. this.debouncedPrepareNextPage = _.debounce(() => {
  115. this.prepareNextPage();
  116. }, 100);
  117. this.debouncedDrawStatusBar = _.throttle(() => {
  118. this.drawStatusBar();
  119. }, 60);
  120. this.debouncedDrawPageDividerAndOrnament = _.throttle(() => {
  121. this.drawPageDividerAndOrnament();
  122. }, 65);
  123. this.debouncedLoadSettings = _.debounce(() => {
  124. this.loadSettings();
  125. }, 50);
  126. this.debouncedUpdatePage = _.debounce(async(lines) => {
  127. if (!this.pageChangeAnimation)
  128. this.toggleLayout = !this.toggleLayout;
  129. else {
  130. this.page2 = this.page1;
  131. this.toggleLayout = true;
  132. }
  133. if (this.toggleLayout)
  134. this.page1 = this.drawHelper.drawPage(lines);
  135. else
  136. this.page2 = this.drawHelper.drawPage(lines);
  137. await this.doPageAnimation();
  138. }, 10);
  139. this.$root.addEventHook('resize', async() => {
  140. this.$nextTick(this.onResize);
  141. await utils.sleep(200);
  142. this.$nextTick(this.onResize);
  143. });
  144. }
  145. mounted() {
  146. this.context = this.$refs.offscreenCanvas.getContext('2d');
  147. }
  148. hex2rgba(hex, alpha = 1) {
  149. const [r, g, b] = hex.match(/\w\w/g).map(x => parseInt(x, 16));
  150. return `rgba(${r},${g},${b},${alpha})`;
  151. }
  152. calcDrawProps() {
  153. const wideLetter = 'Щ';
  154. //preloaded fonts
  155. this.fontList = [`12px '${this.fontName}'`];
  156. //widths
  157. this.realWidth = this.$refs.main.clientWidth;
  158. this.realHeight = this.$refs.main.clientHeight;
  159. this.$refs.layoutEvents.style.width = this.realWidth + 'px';
  160. this.$refs.layoutEvents.style.height = this.realHeight + 'px';
  161. const dual = (this.dualPageMode ? 2 : 1);
  162. this.boxW = this.realWidth - 2*this.indentLR;
  163. this.w = this.boxW/dual - (this.dualPageMode ? 2*this.dualIndentLR : 0);
  164. this.scrollHeight = this.realHeight - (this.showStatusBar ? this.statusBarHeight : 0);
  165. this.h = this.scrollHeight - 2*this.indentTB;
  166. this.lineHeight = this.fontSize + this.lineInterval;
  167. this.pageRowsCount = 1 + Math.floor((this.h - this.lineHeight + this.lineInterval/2)/this.lineHeight);
  168. this.pageLineCount = (this.dualPageMode ? this.pageRowsCount*2 : this.pageRowsCount)
  169. //stuff
  170. this.currentAnimation = '';
  171. this.pageChangeDirectionDown = true;
  172. this.fontShift = this.fontVertShift/100;
  173. this.textShift = this.textVertShift/100 + this.fontShift;
  174. //statusBar
  175. this.$refs.statusBar.style.left = '0px';
  176. this.$refs.statusBar.style.top = (this.statusBarTop ? 1 : this.realHeight - this.statusBarHeight) + 'px';
  177. const sbColor = (this.statusBarColorAsText ? this.textColor : this.statusBarColor);
  178. this.statusBarRgbaColor = this.hex2rgba(sbColor || '#000000', this.statusBarColorAlpha);
  179. const ddColor = (this.dualDivColorAsText ? this.textColor : this.dualDivColor);
  180. this.dualDivRgbaColor = this.hex2rgba(ddColor || '#000000', this.dualDivColorAlpha);
  181. //drawHelper
  182. this.drawHelper.realWidth = this.realWidth;
  183. this.drawHelper.realHeight = this.realHeight;
  184. this.drawHelper.lastBook = this.lastBook;
  185. this.drawHelper.book = this.book;
  186. this.drawHelper.parsed = this.parsed;
  187. this.drawHelper.pageRowsCount = this.pageRowsCount;
  188. this.drawHelper.pageLineCount = this.pageLineCount;
  189. this.drawHelper.dualPageMode = this.dualPageMode;
  190. this.drawHelper.dualIndentLR = this.dualIndentLR;
  191. /*this.drawHelper.dualDivWidth = this.dualDivWidth;
  192. this.drawHelper.dualDivHeight = this.dualDivHeight;
  193. this.drawHelper.dualDivRgbaColor = this.dualDivRgbaColor;
  194. this.drawHelper.dualDivStrokeFill = this.dualDivStrokeFill;
  195. this.drawHelper.dualDivStrokeGap = this.dualDivStrokeGap;
  196. this.drawHelper.dualDivShadowWidth = this.dualDivShadowWidth;*/
  197. this.drawHelper.backgroundColor = this.backgroundColor;
  198. this.drawHelper.statusBarRgbaColor = this.statusBarRgbaColor;
  199. this.drawHelper.fontStyle = this.fontStyle;
  200. this.drawHelper.fontWeight = this.fontWeight;
  201. this.drawHelper.fontSize = this.fontSize;
  202. this.drawHelper.fontName = this.fontName;
  203. this.drawHelper.fontShift = this.fontShift;
  204. this.drawHelper.textColor = this.textColor;
  205. this.drawHelper.textShift = this.textShift;
  206. this.drawHelper.p = this.p;
  207. this.drawHelper.boxW = this.boxW;
  208. this.drawHelper.w = this.w;
  209. this.drawHelper.h = this.h;
  210. this.drawHelper.indentLR = this.indentLR;
  211. this.drawHelper.textAlignJustify = this.textAlignJustify;
  212. this.drawHelper.lineHeight = this.lineHeight;
  213. this.drawHelper.context = this.context;
  214. //альтернатива context.measureText
  215. if (!this.context.measureText(wideLetter).width) {
  216. const ctx = this.$refs.measureWidth;
  217. this.drawHelper.measureText = function(text, style) {
  218. ctx.innerText = text;
  219. ctx.style.font = this.fontByStyle(style);
  220. return ctx.clientWidth;
  221. };
  222. this.drawHelper.measureTextFont = function(text, font) {
  223. ctx.innerText = text;
  224. ctx.style.font = font;
  225. return ctx.clientWidth;
  226. }
  227. }
  228. //statusBar
  229. this.statusBarClickable = this.drawHelper.statusBarClickable(this.statusBarTop, this.statusBarHeight);
  230. //parsed
  231. if (this.parsed) {
  232. let wideLine = wideLetter;
  233. if (!this.drawHelper.measureText(wideLine, {}))
  234. throw new Error('Ошибка measureText');
  235. while (this.drawHelper.measureText(wideLine, {}) < this.w) wideLine += wideLetter;
  236. this.parsed.setSettings({
  237. p: this.p,
  238. w: this.w,
  239. font: this.font,
  240. fontSize: this.fontSize,
  241. wordWrap: this.wordWrap,
  242. cutEmptyParagraphs: this.cutEmptyParagraphs,
  243. addEmptyParagraphs: this.addEmptyParagraphs,
  244. maxWordLength: wideLine.length - 1,
  245. lineHeight: this.lineHeight,
  246. showImages: this.showImages,
  247. showInlineImagesInCenter: this.showInlineImagesInCenter,
  248. imageHeightLines: this.imageHeightLines,
  249. imageFitWidth: this.imageFitWidth,
  250. compactTextPerc: this.compactTextPerc,
  251. testWidth: 0,
  252. measureText: this.drawHelper.measureText.bind(this.drawHelper),
  253. });
  254. }
  255. //scrolling page
  256. const pageSpace = this.scrollHeight - this.pageRowsCount*this.lineHeight;
  257. let top = pageSpace/2;
  258. if (this.showStatusBar)
  259. top += this.statusBarHeight*(this.statusBarTop ? 1 : 0);
  260. let page1 = this.$refs.scrollBox1.style;
  261. let page2 = this.$refs.scrollBox2.style;
  262. page1.perspective = page2.perspective = '3072px';
  263. page1.width = page2.width = this.boxW + this.indentLR + 'px';
  264. page1.height = page2.height = this.scrollHeight - (pageSpace > 0 ? pageSpace : 0) + 'px';
  265. page1.top = page2.top = top + 'px';
  266. page1.left = page2.left = this.indentLR + 'px';
  267. page1 = this.$refs.scrollingPage1.style;
  268. page2 = this.$refs.scrollingPage2.style;
  269. page1.width = page2.width = this.boxW + this.indentLR + 'px';
  270. page1.height = page2.height = this.scrollHeight + this.lineHeight + 'px';
  271. }
  272. async checkLoadedFonts() {
  273. let loaded = await Promise.all(this.fontList.map(font => document.fonts.check(font)));
  274. if (loaded.some(r => !r)) {
  275. await Promise.all(this.fontList.map(font => document.fonts.load(font)));
  276. }
  277. }
  278. async loadFonts() {
  279. this.fontsLoading = true;
  280. let close = null;
  281. (async() => {
  282. await utils.sleep(500);
  283. if (this.fontsLoading)
  284. close = this.$root.notify.info('Загрузка шрифта &nbsp;<i class="la la-snowflake icon-rotate" style="font-size: 150%"></i>');
  285. })();
  286. if (!this.fontsLoaded)
  287. this.fontsLoaded = {};
  288. //загрузка дин.шрифта
  289. const loaded = this.fontsLoaded[this.fontCssUrl];
  290. if (this.fontCssUrl && !loaded) {
  291. loadCSS(this.fontCssUrl);
  292. this.fontsLoaded[this.fontCssUrl] = 1;
  293. }
  294. try {
  295. await this.checkLoadedFonts();
  296. } catch (e) {
  297. this.$root.notify.error('Некоторые шрифты не удалось загрузить', 'Ошибка загрузки');
  298. }
  299. this.fontsLoading = false;
  300. if (close)
  301. close();
  302. }
  303. getSettings() {
  304. const settings = this.settings;
  305. for (let prop in rstore.settingDefaults) {
  306. this[prop] = settings[prop];
  307. }
  308. const wf = this.webFontName;
  309. const i = _.findIndex(rstore.webFonts, ['name', wf]);
  310. if (wf && i >= 0) {
  311. this.fontName = wf;
  312. this.fontCssUrl = rstore.webFonts[i].css;
  313. this.fontVertShift = settings.fontShifts[wf] || 0;
  314. }
  315. }
  316. async calcPropsAndLoadFonts(omitLoadFonts) {
  317. this.calcDrawProps();
  318. this.setBackground();
  319. if (!omitLoadFonts)
  320. await this.loadFonts();
  321. if (omitLoadFonts) {
  322. this.draw();
  323. } else {
  324. // ширина шрифта некоторое время выдается неверно,
  325. // не удалось событийно отловить этот момент, поэтому костыль
  326. while (this.checkingFont) {
  327. this.stopCheckingFont = true;
  328. await utils.sleep(100);
  329. }
  330. this.checkingFont = true;
  331. this.stopCheckingFont = false;
  332. try {
  333. const parsed = this.parsed;
  334. let i = 0;
  335. const t = 'Это тестовый текст. Его ширина выдается системой неправильно некоторое время.';
  336. let twprev = 0;
  337. //5 секунд проверяем изменения шрифта
  338. while (!this.stopCheckingFont && i++ < 50 && this.parsed === parsed) {
  339. const tw = this.drawHelper.measureText(t, {});
  340. if (tw !== twprev) {
  341. this.parsed.setSettings({testWidth: tw});
  342. this.draw();
  343. twprev = tw;
  344. }
  345. await utils.sleep(100);
  346. }
  347. } finally {
  348. this.checkingFont = false;
  349. }
  350. }
  351. }
  352. loadSettings() {
  353. (async() => {
  354. let fontName = this.fontName;
  355. this.getSettings();
  356. await this.calcPropsAndLoadFonts(fontName == this.fontName);
  357. })();
  358. }
  359. showBook() {
  360. this.$refs.main.focus();
  361. this.toggleLayout = false;
  362. this.updateLayout();
  363. this.book = null;
  364. this.meta = null;
  365. this.parsed = null;
  366. this.linesUp = null;
  367. this.linesDown = null;
  368. this.statusBarMessage = '';
  369. this.getSettings();
  370. this.calcDrawProps();
  371. this.draw();// пока не загрузили, очистим канвас
  372. if (this.lastBook) {
  373. (async() => {
  374. try {
  375. //подождем ленивый парсинг
  376. this.stopLazyParse = true;
  377. while (this.doingLazyParse) await utils.sleep(10);
  378. const isParsed = await bookManager.hasBookParsed(this.lastBook);
  379. if (!isParsed) {
  380. return;
  381. }
  382. this.book = await bookManager.getBook(this.lastBook);
  383. this.meta = bookManager.metaOnly(this.book);
  384. const bt = utils.getBookTitle(this.meta.fb2);
  385. this.title = bt.fullTitle;
  386. this.$root.setAppTitle(this.title);
  387. this.parsed = this.book.parsed;
  388. this.page1 = null;
  389. this.page2 = null;
  390. this.statusBar = null;
  391. await this.stopTextScrolling();
  392. await this.calcPropsAndLoadFonts();
  393. this.refreshTime();
  394. if (this.lazyParseEnabled)
  395. this.lazyParsePara();
  396. } catch (e) {
  397. this.$root.stdDialog.alert(e.message, 'Ошибка', {color: 'negative'});
  398. }
  399. })();
  400. }
  401. }
  402. updateLayout() {
  403. if (this.inAnimation) {
  404. this.$refs.scrollBox1.style.visibility = 'visible';
  405. this.$refs.scrollBox2.style.visibility = 'visible';
  406. } else if (this.toggleLayout) {
  407. this.$refs.scrollBox1.style.visibility = 'visible';
  408. this.$refs.scrollBox2.style.visibility = 'hidden';
  409. } else {
  410. this.$refs.scrollBox1.style.visibility = 'hidden';
  411. this.$refs.scrollBox2.style.visibility = 'visible';
  412. }
  413. }
  414. setBackground() {
  415. if (this.wallpaperIgnoreStatusBar) {
  416. this.background = `<div class="layout" style="width: ${this.realWidth}px; height: ${this.realHeight}px;` +
  417. ` background-color: ${this.backgroundColor}">` +
  418. `<div class="layout ${this.wallpaper}" style="width: ${this.realWidth}px; height: ${this.scrollHeight}px; ` +
  419. `top: ${(this.showStatusBar && this.statusBarTop ? this.statusBarHeight + 1 : 0)}px; position: relative;">` +
  420. `</div>` +
  421. `</div>`;
  422. } else {
  423. this.background = `<div class="layout ${this.wallpaper}" style="width: ${this.realWidth}px; height: ${this.realHeight}px;` +
  424. ` background-color: ${this.backgroundColor}"></div>`;
  425. }
  426. }
  427. async onResize() {
  428. if (this.resizing)
  429. return;
  430. this.resizing = true;
  431. try {
  432. const scrolled = this.doingScrolling;
  433. if (scrolled)
  434. await this.stopTextScrolling();
  435. this.calcDrawProps();
  436. this.setBackground();
  437. this.draw();
  438. if (scrolled)
  439. this.startTextScrolling();
  440. } catch (e) {
  441. //
  442. } finally {
  443. this.resizing = false;
  444. }
  445. }
  446. get settings() {
  447. return this.$store.state.reader.settings;
  448. }
  449. get font() {
  450. return `${this.fontStyle} ${this.fontWeight} ${this.fontSize}px '${this.fontName}'`;
  451. }
  452. onPage1TransitionEnd() {
  453. if (this.resolveTransition1Finish)
  454. this.resolveTransition1Finish();
  455. }
  456. onPage2TransitionEnd() {
  457. if (this.resolveTransition2Finish)
  458. this.resolveTransition2Finish();
  459. }
  460. startSearch(needle) {
  461. this.drawHelper.needle = needle;
  462. this.drawHelper.searching = true;
  463. this.draw();
  464. }
  465. stopSearch() {
  466. this.drawHelper.searching = false;
  467. this.draw();
  468. }
  469. generateWaitingFunc(waitingHandlerName, stopPropertyName) {
  470. const func = (timeout) => {
  471. return new Promise((resolve, reject) => { (async() => {
  472. this[waitingHandlerName] = resolve;
  473. let wait = (timeout + 201)/100;
  474. while (wait > 0 && !this[stopPropertyName]) {
  475. wait--;
  476. await utils.sleep(100);
  477. }
  478. resolve();
  479. })().catch(reject); });
  480. };
  481. return func;
  482. }
  483. async startTextScrolling() {
  484. if (this.doingScrolling || !this.book || !this.parsed.textLength || !this.linesDown || this.pageLineCount < 1 ||
  485. this.linesDown.length <= this.pageLineCount || this.dualPageMode) {
  486. this.doStopScrolling();
  487. return;
  488. }
  489. //ждем анимацию
  490. while (this.inAnimation) await utils.sleep(10);
  491. this.stopScrolling = false;
  492. this.doingScrolling = true;
  493. const transitionFinish = this.generateWaitingFunc('resolveTransition1Finish', 'stopScrolling');
  494. if (!this.toggleLayout)
  495. this.page1 = this.page2;
  496. this.toggleLayout = true;
  497. await this.$nextTick();
  498. await utils.sleep(50);
  499. this.cachedPos = -1;
  500. this.draw();
  501. const page = this.$refs.scrollingPage1;
  502. let i = 0;
  503. while (!this.stopScrolling) {
  504. page.style.transition = `${this.scrollingDelay}ms ${this.scrollingType}`;
  505. page.style.transform = `translateY(-${this.lineHeight}px)`;
  506. if (i > 0) {
  507. this.doDown();
  508. if (this.linesDown.length <= this.pageLineCount + 1) {
  509. this.stopScrolling = true;
  510. }
  511. }
  512. await transitionFinish(this.scrollingDelay);
  513. page.style.transition = '';
  514. page.style.transform = 'none';
  515. page.offsetHeight;
  516. i++;
  517. }
  518. this.resolveTransition1Finish = null;
  519. this.doingScrolling = false;
  520. this.doStopScrolling();
  521. this.draw();
  522. }
  523. async stopTextScrolling() {
  524. this.stopScrolling = true;
  525. const page = this.$refs.scrollingPage1;
  526. page.style.transition = '';
  527. page.style.transform = 'none';
  528. page.offsetHeight;
  529. while (this.doingScrolling) await utils.sleep(10);
  530. }
  531. draw() {
  532. //scrolling
  533. if (this.doingScrolling) {
  534. this.currentAnimation = '';
  535. if (this.cachedPos == this.bookPos) {
  536. this.linesDown = this.linesCached.linesDown;
  537. this.linesUp = this.linesCached.linesUp;
  538. this.page1 = this.pageCached;
  539. } else {
  540. const lines = this.getLines(this.bookPos);
  541. this.linesDown = lines.linesDown;
  542. this.linesUp = lines.linesUp;
  543. this.page1 = this.drawHelper.drawPage(lines.linesDown, true);
  544. }
  545. //caching next
  546. if (this.cachedPageTimer)
  547. clearTimeout(this.cachedPageTimer);
  548. this.cachedPageTimer = setTimeout(() => {
  549. if (this.linesDown && this.linesDown.length > this.pageLineCount && this.pageLineCount > 0) {
  550. this.cachedPos = this.linesDown[1].begin;
  551. this.linesCached = this.getLines(this.cachedPos);
  552. this.pageCached = this.drawHelper.drawPage(this.linesCached.linesDown, true);
  553. }
  554. this.cachedPageTimer = null;
  555. }, 20);
  556. this.debouncedDrawStatusBar();
  557. return;
  558. }
  559. //check
  560. if (this.w < minLayoutWidth) {
  561. this.page1 = null;
  562. this.page2 = null;
  563. this.statusBar = null;
  564. return;
  565. }
  566. if (this.book && this.bookPos > 0 && this.bookPos >= this.parsed.textLength) {
  567. this.doEnd(true, false);
  568. return;
  569. }
  570. //fast draw prepared
  571. if (!this.pageChangeAnimation && this.pageChangeDirectionDown && this.pagePrepared && this.bookPos == this.bookPosPrepared) {
  572. this.toggleLayout = !this.toggleLayout;
  573. this.linesDown = this.linesDownNext;
  574. this.linesUp = this.linesUpNext;
  575. } else {//normal debounced draw
  576. const lines = this.getLines(this.bookPos);
  577. this.linesDown = lines.linesDown;
  578. this.linesUp = lines.linesUp;
  579. this.debouncedUpdatePage(lines.linesDown);
  580. }
  581. this.pagePrepared = false;
  582. if (!this.pageChangeAnimation)
  583. this.debouncedPrepareNextPage();
  584. this.debouncedDrawStatusBar();
  585. this.debouncedDrawPageDividerAndOrnament();
  586. if (this.book && this.linesDown && this.linesDown.length < this.pageLineCount) {
  587. this.doEnd(true, false);
  588. return;
  589. }
  590. }
  591. onPage1AnimationEnd() {
  592. if (this.resolveAnimation1Finish)
  593. this.resolveAnimation1Finish();
  594. }
  595. onPage2AnimationEnd() {
  596. if (this.resolveAnimation2Finish)
  597. this.resolveAnimation2Finish();
  598. }
  599. async doPageAnimation() {
  600. if (this.currentAnimation && !this.inAnimation) {
  601. this.inAnimation = true;
  602. const animation1Finish = this.generateWaitingFunc('resolveAnimation1Finish', 'stopAnimation');
  603. const animation2Finish = this.generateWaitingFunc('resolveAnimation2Finish', 'stopAnimation');
  604. const transition1Finish = this.generateWaitingFunc('resolveTransition1Finish', 'stopAnimation');
  605. const transition2Finish = this.generateWaitingFunc('resolveTransition2Finish', 'stopAnimation');
  606. const duration = Math.round(3000*(1 - this.pageChangeAnimationSpeed/100));
  607. let page1 = this.$refs.scrollingPage1;
  608. let page2 = this.$refs.scrollingPage2;
  609. switch (this.currentAnimation) {
  610. case 'thaw':
  611. await this.drawHelper.doPageAnimationThaw(page1, page2,
  612. duration, this.pageChangeDirectionDown, animation1Finish);
  613. break;
  614. case 'blink':
  615. await this.drawHelper.doPageAnimationBlink(page1, page2,
  616. duration, this.pageChangeDirectionDown, animation1Finish, animation2Finish);
  617. break;
  618. case 'rightShift':
  619. await this.drawHelper.doPageAnimationRightShift(page1, page2,
  620. duration, this.pageChangeDirectionDown, transition1Finish);
  621. break;
  622. case 'downShift':
  623. page1.style.height = this.scrollHeight + 'px';
  624. page2.style.height = this.scrollHeight + 'px';
  625. await this.drawHelper.doPageAnimationDownShift(page1, page2,
  626. duration, this.pageChangeDirectionDown, transition1Finish);
  627. page1.style.height = this.scrollHeight + this.lineHeight + 'px';
  628. page2.style.height = this.scrollHeight + this.lineHeight + 'px';
  629. break;
  630. case 'rotate':
  631. await this.drawHelper.doPageAnimationRotate(page1, page2,
  632. duration, this.pageChangeDirectionDown, transition1Finish, transition2Finish);
  633. break;
  634. case 'flip':
  635. await this.drawHelper.doPageAnimationFlip(page1, page2,
  636. duration, this.pageChangeDirectionDown, transition1Finish, transition2Finish, this.backgroundColor);
  637. break;
  638. }
  639. this.resolveAnimation1Finish = null;
  640. this.resolveAnimation2Finish = null;
  641. this.resolveTransition1Finish = null;
  642. this.resolveTransition2Finish = null;
  643. page1.style.animation = '';
  644. page2.style.animation = '';
  645. page1.style.transition = '';
  646. page1.style.transform = 'none';
  647. page1.offsetHeight;
  648. page2.style.transition = '';
  649. page2.style.transform = 'none';
  650. page2.offsetHeight;
  651. this.currentAnimation = '';
  652. this.pageChangeDirectionDown = false;//true только если PgDown
  653. this.inAnimation = false;
  654. this.stopAnimation = false;
  655. }
  656. }
  657. getLines(bookPos) {
  658. if (!this.parsed || this.pageLineCount < 1)
  659. return {};
  660. return {
  661. linesDown: this.parsed.getLines(bookPos, 2*this.pageLineCount),
  662. linesUp: this.parsed.getLines(bookPos, -2*this.pageLineCount)
  663. };
  664. }
  665. drawStatusBar(message) {
  666. if (this.w < minLayoutWidth) {
  667. this.statusBar = null;
  668. return;
  669. }
  670. if (this.showStatusBar && this.linesDown && this.pageLineCount > 0) {
  671. const lines = this.linesDown;
  672. let i = this.pageLineCount;
  673. if (this.keepLastToFirst)
  674. i--;
  675. i = (i > lines.length - 1 ? lines.length - 1 : i);
  676. if (i >= 0) {
  677. if (!message)
  678. message = this.statusBarMessage;
  679. if (!message)
  680. message = this.title;
  681. //check image num
  682. let imageNum = 0;
  683. const len = (lines.length > 2 ? 2 : lines.length);
  684. loop:
  685. for (let j = 0; j < len; j++) {
  686. const line = lines[j];
  687. for (const part of line.parts) {
  688. if (part.image) {
  689. imageNum = part.image.num;
  690. break loop;
  691. }
  692. }
  693. }
  694. //drawing
  695. this.statusBar = this.drawHelper.drawStatusBar(this.statusBarTop, this.statusBarHeight,
  696. lines[i].end, this.parsed.textLength, message, imageNum, this.parsed.images.length);
  697. this.bookPosSeen = lines[i].end;
  698. }
  699. } else {
  700. this.statusBar = '';
  701. }
  702. }
  703. drawPageDividerAndOrnament() {
  704. if (this.dualPageMode) {
  705. this.pageDivider = `<div class="layout" style="width: ${this.realWidth}px; height: ${this.scrollHeight}px; ` +
  706. `top: ${(this.showStatusBar && this.statusBarTop ? this.statusBarHeight + 1 : 0)}px; position: relative;">` +
  707. `<div class="fit row justify-center items-center no-wrap">` +
  708. `<div style="height: ${Math.round(this.scrollHeight*this.dualDivHeight/100)}px; width: ${this.dualDivWidth}px; ` +
  709. `box-shadow: 0 0 ${this.dualDivShadowWidth}px ${this.dualDivRgbaColor}; ` +
  710. `background-image: url(&quot;data:image/svg+xml;utf8,<svg width='100%' height='100%' xmlns='http://www.w3.org/2000/svg'>` +
  711. `<line x1='${this.dualDivWidth/2}' y1='0' x2='${this.dualDivWidth/2}' y2='100%' stroke='${this.dualDivRgbaColor}' ` +
  712. `stroke-width='${this.dualDivWidth}' stroke-dasharray='${this.dualDivStrokeFill} ${this.dualDivStrokeGap}'/>` +
  713. `</svg>&quot;);">` +
  714. `</div>` +
  715. `</div>` +
  716. `</div>`;
  717. } else {
  718. this.pageDivider = null;
  719. }
  720. }
  721. blinkCachedLoadMessage(state) {
  722. if (state === 'finish') {
  723. this.statusBarMessage = '';
  724. } else if (state) {
  725. this.statusBarMessage = 'Книга загружена из кэша';
  726. } else {
  727. this.statusBarMessage = ' ';
  728. }
  729. this.drawStatusBar();
  730. }
  731. async lazyParsePara() {
  732. if (!this.parsed || this.doingLazyParse)
  733. return;
  734. this.doingLazyParse = true;
  735. let j = 0;
  736. let k = 0;
  737. let prevPerc = 0;
  738. this.stopLazyParse = false;
  739. for (let i = 0; i < this.parsed.para.length; i++) {
  740. j++;
  741. if (j > 1) {
  742. await utils.sleep(1);
  743. j = 0;
  744. }
  745. if (this.stopLazyParse)
  746. break;
  747. this.parsed.parsePara(i);
  748. k++;
  749. if (k > 100) {
  750. let perc = Math.round(i/this.parsed.para.length*100);
  751. if (perc != prevPerc)
  752. this.drawStatusBar(`Обработка текста ${perc}%`);
  753. prevPerc = perc;
  754. k = 0;
  755. }
  756. }
  757. this.drawStatusBar();
  758. this.doingLazyParse = false;
  759. }
  760. async refreshTime() {
  761. if (!this.timeRefreshing) {
  762. this.timeRefreshing = true;
  763. await utils.sleep(60*1000);
  764. if (this.book && this.parsed.textLength) {
  765. this.debouncedDrawStatusBar();
  766. }
  767. this.timeRefreshing = false;
  768. this.refreshTime();
  769. }
  770. }
  771. prepareNextPage() {
  772. // подготовка следующей страницы заранее
  773. if (!this.book || !this.parsed.textLength || !this.linesDown || this.pageLineCount < 1)
  774. return;
  775. let i = this.pageLineCount;
  776. if (this.keepLastToFirst)
  777. i--;
  778. if (i >= 0 && this.linesDown.length > i) {
  779. this.bookPosPrepared = this.linesDown[i].begin;
  780. const lines = this.getLines(this.bookPosPrepared);
  781. this.linesDownNext = lines.linesDown;
  782. this.linesUpNext = lines.linesUp;
  783. if (this.toggleLayout)
  784. this.page2 = this.drawHelper.drawPage(lines.linesDown);//наоборот
  785. else
  786. this.page1 = this.drawHelper.drawPage(lines.linesDown);
  787. this.pagePrepared = true;
  788. }
  789. }
  790. doDown() {
  791. if (this.linesDown && this.linesDown.length > this.pageLineCount && this.pageLineCount > 0) {
  792. this.userBookPosChange = true;
  793. this.bookPos = this.linesDown[1].begin;
  794. }
  795. }
  796. doUp() {
  797. if (this.linesUp && this.linesUp.length > 1 && this.pageLineCount > 0) {
  798. this.userBookPosChange = true;
  799. this.bookPos = this.linesUp[1].begin;
  800. }
  801. }
  802. doPageDown() {
  803. if (this.linesDown && this.pageLineCount > 0) {
  804. let i = this.pageLineCount;
  805. if (this.keepLastToFirst)
  806. i--;
  807. if (i >= 0 && this.linesDown.length >= 2*i + (this.keepLastToFirst ? 1 : 0)) {
  808. this.currentAnimation = this.pageChangeAnimation;
  809. this.pageChangeDirectionDown = true;
  810. this.userBookPosChange = true;
  811. this.bookPos = this.linesDown[i].begin;
  812. } else
  813. this.doEnd();
  814. }
  815. }
  816. doPageUp() {
  817. if (this.linesUp && this.pageLineCount > 0) {
  818. let i = this.pageLineCount;
  819. if (this.keepLastToFirst)
  820. i--;
  821. i = (i > this.linesUp.length - 1 ? this.linesUp.length - 1 : i);
  822. if (i >= 0 && this.linesUp.length > i) {
  823. this.currentAnimation = this.pageChangeAnimation;
  824. this.pageChangeDirectionDown = false;
  825. this.userBookPosChange = true;
  826. this.bookPos = this.linesUp[i].begin;
  827. }
  828. }
  829. }
  830. doHome() {
  831. this.currentAnimation = this.pageChangeAnimation;
  832. this.pageChangeDirectionDown = false;
  833. this.userBookPosChange = true;
  834. this.bookPos = 0;
  835. }
  836. doEnd(noAni, isUser = true) {
  837. if (this.parsed.para.length && this.pageLineCount > 0) {
  838. let i = this.parsed.para.length - 1;
  839. let lastPos = this.parsed.para[i].offset + this.parsed.para[i].length - 1;
  840. const lines = this.parsed.getLines(lastPos, -this.pageLineCount);
  841. if (lines) {
  842. i = this.pageLineCount - 1;
  843. i = (i > lines.length - 1 ? lines.length - 1 : i);
  844. if (!noAni)
  845. this.currentAnimation = this.pageChangeAnimation;
  846. this.pageChangeDirectionDown = true;
  847. this.userBookPosChange = isUser;
  848. this.bookPos = lines[i].begin;
  849. }
  850. }
  851. }
  852. doToolBarToggle(event) {
  853. this.$emit('do-action', {action: 'switchToolbar', event});
  854. }
  855. doScrollingToggle() {
  856. this.$emit('do-action', {action: 'scrolling', event});
  857. }
  858. doFullScreenToggle() {
  859. this.$emit('do-action', {action: 'fullScreen', event});
  860. }
  861. doStopScrolling() {
  862. this.$emit('do-action', {action: 'stopScrolling', event});
  863. }
  864. async doFontSizeInc() {
  865. if (!this.settingsChanging) {
  866. this.settingsChanging = true;
  867. const newSize = (this.settings.fontSize + 1 < 200 ? this.settings.fontSize + 1 : 100);
  868. this.commit('reader/setSettings', {fontSize: newSize});
  869. await utils.sleep(50);
  870. this.settingsChanging = false;
  871. }
  872. }
  873. async doFontSizeDec() {
  874. if (!this.settingsChanging) {
  875. this.settingsChanging = true;
  876. const newSize = (this.settings.fontSize - 1 > 5 ? this.settings.fontSize - 1 : 5);
  877. this.commit('reader/setSettings', {fontSize: newSize});
  878. await utils.sleep(50);
  879. this.settingsChanging = false;
  880. }
  881. }
  882. async doScrollingSpeedUp() {
  883. if (!this.settingsChanging) {
  884. this.settingsChanging = true;
  885. const newDelay = (this.settings.scrollingDelay - 50 > 1 ? this.settings.scrollingDelay - 50 : 1);
  886. this.commit('reader/setSettings', {scrollingDelay: newDelay});
  887. await utils.sleep(50);
  888. this.settingsChanging = false;
  889. }
  890. }
  891. async doScrollingSpeedDown() {
  892. if (!this.settingsChanging) {
  893. this.settingsChanging = true;
  894. const newDelay = (this.settings.scrollingDelay + 50 < 10000 ? this.settings.scrollingDelay + 50 : 10000);
  895. this.commit('reader/setSettings', {scrollingDelay: newDelay});
  896. await utils.sleep(50);
  897. this.settingsChanging = false;
  898. }
  899. }
  900. async startClickRepeat(pointX, pointY) {
  901. this.repX = pointX;
  902. this.repY = pointY;
  903. if (!this.repInit && this.repDoing) {
  904. this.repInit = true;
  905. let delay = 400;
  906. while (this.repDoing) {
  907. this.handleClick(pointX, pointY);
  908. await utils.sleep(delay);
  909. if (delay > 15)
  910. delay *= 0.8;
  911. }
  912. this.repInit = false;
  913. }
  914. }
  915. endClickRepeat() {
  916. this.repDoing = false;
  917. }
  918. onTouchStart(event) {
  919. if (!this.$root.isMobileDevice)
  920. return;
  921. this.endClickRepeat();
  922. if (event.touches.length == 1) {
  923. const touch = event.touches[0];
  924. const rect = event.target.getBoundingClientRect();
  925. const x = touch.pageX - rect.left;
  926. const y = touch.pageY - rect.top;
  927. const hc = this.handleClick(x, y, new Set(['Menu']));
  928. if (hc) {
  929. if (hc != 'Menu') {
  930. this.repDoing = true;
  931. this.debouncedStartClickRepeat(x, y);
  932. } else {
  933. this.startTouch = {x, y};
  934. }
  935. }
  936. }
  937. }
  938. onTouchMove(event) {
  939. if (this.startTouch) {
  940. event.preventDefault();
  941. }
  942. }
  943. onTouchEnd(event) {
  944. if (!this.$root.isMobileDevice)
  945. return;
  946. this.endClickRepeat();
  947. if (event.changedTouches.length == 1) {
  948. const touch = event.changedTouches[0];
  949. const rect = event.target.getBoundingClientRect();
  950. const x = touch.pageX - rect.left;
  951. const y = touch.pageY - rect.top;
  952. if (this.startTouch) {
  953. const dy = this.startTouch.y - y;
  954. const dx = this.startTouch.x - x;
  955. const moveDelta = 30;
  956. const touchDelta = 15;
  957. if (dy > 0 && Math.abs(dy) >= moveDelta && Math.abs(dy) > Math.abs(dx)) {
  958. //движение вверх
  959. this.doFullScreenToggle();
  960. } else if (dy < 0 && Math.abs(dy) >= moveDelta && Math.abs(dy) > Math.abs(dx)) {
  961. //движение вниз
  962. this.doScrollingToggle();
  963. } else if (dx > 0 && Math.abs(dx) >= moveDelta && Math.abs(dy) < Math.abs(dx)) {
  964. //движение влево
  965. this.doScrollingSpeedDown();
  966. } else if (dx < 0 && Math.abs(dx) >= moveDelta && Math.abs(dy) < Math.abs(dx)) {
  967. //движение вправо
  968. this.doScrollingSpeedUp();
  969. } else if (Math.abs(dy) < touchDelta && Math.abs(dx) < touchDelta) {
  970. this.doToolBarToggle(event);
  971. }
  972. this.startTouch = null;
  973. }
  974. }
  975. }
  976. onTouchCancel() {
  977. if (!this.$root.isMobileDevice)
  978. return;
  979. this.endClickRepeat();
  980. }
  981. onMouseDown(event) {
  982. if (this.$root.isMobileDevice)
  983. return;
  984. this.endClickRepeat();
  985. if (event.button == 0) {
  986. const hc = this.handleClick(event.offsetX, event.offsetY);
  987. if (hc && hc != 'Menu') {
  988. this.repDoing = true;
  989. this.debouncedStartClickRepeat(event.offsetX, event.offsetY);
  990. }
  991. } else if (event.button == 1) {
  992. this.doScrollingToggle();
  993. } else if (event.button == 2) {
  994. this.doToolBarToggle(event);
  995. }
  996. }
  997. onMouseUp() {
  998. if (this.$root.isMobileDevice)
  999. return;
  1000. this.endClickRepeat();
  1001. }
  1002. onMouseWheel(event) {
  1003. if (this.$root.isMobileDevice)
  1004. return;
  1005. if (event.deltaY > 0) {
  1006. this.doDown();
  1007. } else if (event.deltaY < 0) {
  1008. this.doUp();
  1009. }
  1010. }
  1011. onStatusBarClick() {
  1012. const url = this.meta.url;
  1013. if (url && url.indexOf('disk://') != 0) {
  1014. window.open(url, '_blank');
  1015. } else {
  1016. this.$root.stdDialog.alert('Оригинал недоступен, т.к. файл книги был загружен с локального диска.', ' ', {color: 'info'});
  1017. }
  1018. }
  1019. getClickAction(pointX, pointY) {
  1020. const w = pointX/this.realWidth*100;
  1021. const h = pointY/this.realHeight*100;
  1022. let action = '';
  1023. loops: {
  1024. for (const x in clickMap) {
  1025. for (const y in clickMap[x]) {
  1026. if (w < x && h < y) {
  1027. action = clickMap[x][y];
  1028. break loops;
  1029. }
  1030. }
  1031. }
  1032. }
  1033. return action;
  1034. }
  1035. handleClick(pointX, pointY, exclude) {
  1036. const action = this.getClickAction(pointX, pointY);
  1037. if (!exclude || !exclude.has(action)) {
  1038. switch (action) {
  1039. case 'Down' ://Down
  1040. this.doDown();
  1041. break;
  1042. case 'Up' ://Up
  1043. this.doUp();
  1044. break;
  1045. case 'PgDown' ://PgDown
  1046. this.doPageDown();
  1047. break;
  1048. case 'PgUp' ://PgUp
  1049. this.doPageUp();
  1050. break;
  1051. case 'Menu' :
  1052. this.doToolBarToggle();
  1053. break;
  1054. default :
  1055. // Nothing
  1056. }
  1057. }
  1058. return action;
  1059. }
  1060. copyText(event) {
  1061. //все это для того, чтобы правильно расставить переносы \n при копировании текста
  1062. //прямо с текущей страницы
  1063. //подготовка, вытаскиваем весь текст страницы
  1064. const lines = this.getLines(this.bookPos);
  1065. const decodedLines = [];
  1066. for (const line of lines.linesDown) {
  1067. let lineText = '';
  1068. for (const part of line.parts) {
  1069. lineText += part.text;
  1070. }
  1071. decodedLines.push({text: he.decode(lineText), first: line.first});
  1072. }
  1073. let i = 0;
  1074. const findDecoded = (line) => {
  1075. for (let j = i; j < decodedLines.length; j++) {
  1076. const decoded = decodedLines[j];
  1077. if (decoded.text.indexOf(line) >= 0) {
  1078. i = j;
  1079. return decoded;
  1080. }
  1081. }
  1082. return;
  1083. }
  1084. const selection = document.getSelection();
  1085. const splitted = selection.toString().split(/[\n\r]/);
  1086. let filtered = '';
  1087. //формируем filtered, учитывая переносы из decodedLines
  1088. for (const line of splitted) {
  1089. const found = findDecoded(line);
  1090. if (found && found.first) {
  1091. filtered += (filtered ? '\n' : '') + line;
  1092. } else {
  1093. filtered += (filtered ? '\r ' : '') + line;
  1094. }
  1095. }
  1096. //маленькие хитрости, убираем переносы по слогам
  1097. filtered = filtered.replace(/-\r /g, '').replace(/\r /g, ' ');
  1098. event.clipboardData.setData('text/plain', filtered);
  1099. }
  1100. }
  1101. export default vueComponent(TextPage);
  1102. //-----------------------------------------------------------------------------
  1103. </script>
  1104. <style scoped>
  1105. .main {
  1106. flex: 1;
  1107. margin: 0;
  1108. padding: 0;
  1109. overflow: hidden;
  1110. position: relative;
  1111. min-width: 200px;
  1112. }
  1113. .layout {
  1114. margin: 0;
  1115. padding: 0;
  1116. position: absolute;
  1117. z-index: 10;
  1118. }
  1119. .over-hidden {
  1120. overflow: hidden;
  1121. }
  1122. .on-top {
  1123. z-index: 100;
  1124. }
  1125. .back {
  1126. z-index: 5;
  1127. }
  1128. .events {
  1129. z-index: 20;
  1130. background-color: rgba(0,0,0,0);
  1131. }
  1132. </style>