TextPage.vue 46 KB

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