@fiduswriter/books-document 0.1.2 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/README.md +3 -3
  2. package/dist/exporter/bits/index.d.ts.map +1 -1
  3. package/dist/exporter/bits/index.js +3 -7
  4. package/dist/exporter/bits/index.js.map +1 -1
  5. package/dist/exporter/bits/templates.d.ts.map +1 -1
  6. package/dist/exporter/bits/templates.js.map +1 -1
  7. package/dist/exporter/docx/index.d.ts.map +1 -1
  8. package/dist/exporter/docx/index.js +2 -4
  9. package/dist/exporter/docx/index.js.map +1 -1
  10. package/dist/exporter/docx/render.d.ts.map +1 -1
  11. package/dist/exporter/docx/render.js.map +1 -1
  12. package/dist/exporter/epub/index.d.ts.map +1 -1
  13. package/dist/exporter/epub/index.js +5 -12
  14. package/dist/exporter/epub/index.js.map +1 -1
  15. package/dist/exporter/epub/templates.d.ts.map +1 -1
  16. package/dist/exporter/epub/templates.js.map +1 -1
  17. package/dist/exporter/epub/tools.d.ts.map +1 -1
  18. package/dist/exporter/epub/tools.js.map +1 -1
  19. package/dist/exporter/html/index.d.ts.map +1 -1
  20. package/dist/exporter/html/index.js +2 -5
  21. package/dist/exporter/html/index.js.map +1 -1
  22. package/dist/exporter/html/templates.d.ts.map +1 -1
  23. package/dist/exporter/html/templates.js +3 -1
  24. package/dist/exporter/html/templates.js.map +1 -1
  25. package/dist/exporter/html/tools.d.ts.map +1 -1
  26. package/dist/exporter/html/tools.js +1 -2
  27. package/dist/exporter/html/tools.js.map +1 -1
  28. package/dist/exporter/latex/index.d.ts.map +1 -1
  29. package/dist/exporter/latex/index.js.map +1 -1
  30. package/dist/exporter/latex/templates.d.ts.map +1 -1
  31. package/dist/exporter/latex/templates.js.map +1 -1
  32. package/dist/exporter/native/index.d.ts.map +1 -1
  33. package/dist/exporter/native/index.js.map +1 -1
  34. package/dist/exporter/odt/index.d.ts.map +1 -1
  35. package/dist/exporter/odt/index.js +2 -4
  36. package/dist/exporter/odt/index.js.map +1 -1
  37. package/dist/exporter/odt/render.d.ts.map +1 -1
  38. package/dist/exporter/odt/render.js.map +1 -1
  39. package/dist/exporter/print/index.d.ts.map +1 -1
  40. package/dist/exporter/print/index.js +2 -1
  41. package/dist/exporter/print/index.js.map +1 -1
  42. package/dist/exporter/print/templates.js.map +1 -1
  43. package/dist/exporter/tools.d.ts.map +1 -1
  44. package/dist/exporter/tools.js +2 -4
  45. package/dist/exporter/tools.js.map +1 -1
  46. package/dist/importer/native/index.d.ts +13 -2
  47. package/dist/importer/native/index.d.ts.map +1 -1
  48. package/dist/importer/native/index.js +20 -8
  49. package/dist/importer/native/index.js.map +1 -1
  50. package/dist/importer/native/reader.d.ts.map +1 -1
  51. package/dist/importer/native/reader.js +1 -3
  52. package/dist/importer/native/reader.js.map +1 -1
  53. package/dist/index.d.ts.map +1 -1
  54. package/dist/index.js.map +1 -1
  55. package/dist/types.d.ts.map +1 -1
  56. package/package.json +1 -1
  57. package/src/exporter/bits/index.ts +27 -31
  58. package/src/exporter/bits/templates.ts +4 -4
  59. package/src/exporter/docx/index.ts +33 -32
  60. package/src/exporter/docx/render.ts +16 -17
  61. package/src/exporter/epub/index.ts +23 -43
  62. package/src/exporter/epub/templates.ts +12 -14
  63. package/src/exporter/epub/tools.ts +3 -5
  64. package/src/exporter/html/index.ts +32 -46
  65. package/src/exporter/html/templates.ts +15 -13
  66. package/src/exporter/html/tools.ts +4 -9
  67. package/src/exporter/latex/index.ts +17 -20
  68. package/src/exporter/latex/templates.ts +2 -6
  69. package/src/exporter/native/index.ts +14 -14
  70. package/src/exporter/odt/index.ts +27 -26
  71. package/src/exporter/odt/render.ts +16 -17
  72. package/src/exporter/print/index.ts +15 -11
  73. package/src/exporter/print/templates.ts +1 -1
  74. package/src/exporter/tools.ts +15 -44
  75. package/src/global.d.ts +2 -0
  76. package/src/importer/native/index.ts +56 -32
  77. package/src/importer/native/reader.ts +9 -18
  78. package/src/index.ts +1 -1
  79. package/src/modules.d.ts +1 -1
  80. package/src/types.ts +2 -2
@@ -2,22 +2,17 @@
2
2
  * HTML book exporter.
3
3
  */
4
4
 
5
- import type { Schema } from "prosemirror-model"
6
- import type { CSL, User } from "@fiduswriter/document"
7
- import { HTMLExporter } from "@fiduswriter/document/exporter/html/index"
8
- import { createSlug } from "@fiduswriter/document/exporter/tools/file"
9
- import { ZipFileCreator } from "@fiduswriter/document/exporter/tools/zip"
10
- import { LANGUAGES } from "@fiduswriter/document/schema/const"
11
- import { addAlert, get, gettext, staticUrl } from "fwtoolkit"
5
+ import type {Schema} from "prosemirror-model"
6
+ import type {CSL, User} from "@fiduswriter/document"
7
+ import {HTMLExporter} from "@fiduswriter/document/exporter/html/index"
8
+ import {createSlug} from "@fiduswriter/document/exporter/tools/file"
9
+ import {ZipFileCreator} from "@fiduswriter/document/exporter/tools/zip"
10
+ import {LANGUAGES} from "@fiduswriter/document/schema/const"
11
+ import {addAlert, get, staticUrl} from "fwtoolkit"
12
12
  import pretty from "pretty"
13
13
 
14
- import type {
15
- Book,
16
- BookStyle,
17
- BookStyles,
18
- DocumentListEntry
19
- } from "../../types.js"
20
- import { getMissingChapterData } from "../tools.js"
14
+ import type {Book, BookStyle, BookStyles, DocumentListEntry} from "../../types.js"
15
+ import {getMissingChapterData} from "../tools.js"
21
16
  import {
22
17
  htmlBookChapterTemplate,
23
18
  htmlBookExportTemplate,
@@ -27,7 +22,7 @@ import {
27
22
  singleFileHTMLBookChapterTemplate,
28
23
  singleFileHTMLBookTemplate
29
24
  } from "./templates.js"
30
- import { orderLinks } from "./tools.js"
25
+ import {orderLinks} from "./tools.js"
31
26
 
32
27
  interface StyleSheet {
33
28
  url?: string
@@ -89,7 +84,7 @@ export class HTMLBookExporter {
89
84
  docList: DocumentListEntry[],
90
85
  updated: any,
91
86
  multiDoc = true,
92
- { relativeUrls = true } = {}
87
+ {relativeUrls = true} = {}
93
88
  ) {
94
89
  this.schema = schema
95
90
  this.csl = csl
@@ -114,7 +109,7 @@ export class HTMLBookExporter {
114
109
  : htmlBookIndexBodyTemplate
115
110
  this.singleFileHTMLBookTemplate = singleFileHTMLBookTemplate
116
111
  this.singleFileHTMLBookCSSTemplate = singleFileHTMLBookCSSTemplate
117
- this.styleSheets = [{ url: staticUrl("css/book.css") }]
112
+ this.styleSheets = [{url: staticUrl("css/book.css")}]
118
113
  }
119
114
 
120
115
  async init(): Promise<Blob | false | void> {
@@ -170,8 +165,8 @@ export class HTMLBookExporter {
170
165
  continue
171
166
  }
172
167
 
173
- const imageDB = { db: doc.images || {} }
174
- const bibDB = { db: doc.bibliography || {} }
168
+ const imageDB = {db: doc.images || {}}
169
+ const bibDB = {db: doc.bibliography || {}}
175
170
  const styleSheets = this.styleSheets.slice()
176
171
 
177
172
  const options = {
@@ -203,7 +198,7 @@ export class HTMLBookExporter {
203
198
  )
204
199
 
205
200
  await documentHTMLExporter.process()
206
- const { metaData, converter, textFiles, httpFiles } =
201
+ const {metaData, converter, textFiles, httpFiles} =
207
202
  documentHTMLExporter.getProcessedFiles() as any
208
203
 
209
204
  const contents = textFiles.find(
@@ -224,7 +219,7 @@ export class HTMLBookExporter {
224
219
 
225
220
  if (converter.features.math) {
226
221
  this.math = true
227
- styleSheets.push({ filename: "css/mathlive.css" })
222
+ styleSheets.push({filename: "css/mathlive.css"})
228
223
  }
229
224
 
230
225
  if (converter.citations.bibCSS) {
@@ -233,7 +228,7 @@ export class HTMLBookExporter {
233
228
  ocd: true
234
229
  })
235
230
  }
236
- styleSheets.push({ filename: "css/bibliography.css" })
231
+ styleSheets.push({filename: "css/bibliography.css"})
237
232
  }
238
233
 
239
234
  const chapterHTML = this.chapterTemplate({
@@ -247,7 +242,7 @@ export class HTMLBookExporter {
247
242
 
248
243
  this.textFiles.push({
249
244
  filename: `document-${chapterNumber}.html`,
250
- contents: pretty(chapterHTML, { ocd: true })
245
+ contents: pretty(chapterHTML, {ocd: true})
251
246
  })
252
247
 
253
248
  this.chapters.push({
@@ -326,7 +321,7 @@ export class HTMLBookExporter {
326
321
  language,
327
322
  multiDoc: this.multiDoc
328
323
  }),
329
- { ocd: true }
324
+ {ocd: true}
330
325
  )
331
326
  })
332
327
  if (!this.multiDoc) {
@@ -340,15 +335,15 @@ export class HTMLBookExporter {
340
335
  if (this.bibCSS) {
341
336
  styleSheets.push(
342
337
  this.relativeUrls
343
- ? { filename: "css/bibliography.css" }
344
- : { contents: this.bibCSS }
338
+ ? {filename: "css/bibliography.css"}
339
+ : {contents: this.bibCSS}
345
340
  )
346
341
  }
347
342
  if (this.math) {
348
343
  styleSheets.push(
349
344
  this.relativeUrls
350
- ? { filename: "css/mathlive.css" }
351
- : { filename: staticUrl("css/mathlive.css") }
345
+ ? {filename: "css/mathlive.css"}
346
+ : {filename: staticUrl("css/mathlive.css")}
352
347
  )
353
348
  }
354
349
  let html = ""
@@ -360,12 +355,8 @@ export class HTMLBookExporter {
360
355
  if (b.filename === "index.html") {
361
356
  return 1
362
357
  }
363
- const aNum = Number.parseInt(
364
- a.filename.match(/\d+/g)?.[0] || "0"
365
- )
366
- const bNum = Number.parseInt(
367
- b.filename.match(/\d+/g)?.[0] || "0"
368
- )
358
+ const aNum = Number.parseInt(a.filename.match(/\d+/g)?.[0] || "0")
359
+ const bNum = Number.parseInt(b.filename.match(/\d+/g)?.[0] || "0")
369
360
  if (aNum < bNum) {
370
361
  return -1
371
362
  }
@@ -374,7 +365,7 @@ export class HTMLBookExporter {
374
365
  }
375
366
  return 0
376
367
  })
377
- .filter(({ filename, contents }) => {
368
+ .filter(({filename, contents}) => {
378
369
  if (filename.slice(-5) !== ".html") {
379
370
  return true
380
371
  }
@@ -396,7 +387,7 @@ export class HTMLBookExporter {
396
387
 
397
388
  this.textFiles.push({
398
389
  filename: "index.html",
399
- contents: pretty(htmlDoc, { ocd: true })
390
+ contents: pretty(htmlDoc, {ocd: true})
400
391
  })
401
392
  }
402
393
 
@@ -416,17 +407,12 @@ export class HTMLBookExporter {
416
407
  ))
417
408
  )
418
409
 
419
- this.styleSheets.push({
420
- contents,
421
- filename: `css/${bookStyle.slug}.css`
422
- })
410
+ this.styleSheets.push({contents, filename: `css/${bookStyle.slug}.css`})
423
411
  this.httpFiles = this.httpFiles.concat(
424
- bookStyle.bookstylefile_set.map(
425
- ([url, filename]: [string, string]) => ({
426
- filename: `css/media/${filename}`,
427
- url
428
- })
429
- )
412
+ bookStyle.bookstylefile_set.map(([url, filename]: [string, string]) => ({
413
+ filename: `css/media/${filename}`,
414
+ url
415
+ }))
430
416
  )
431
417
  return true
432
418
  }
@@ -1,15 +1,13 @@
1
- import { escapeText, localizeDate } from "fwtoolkit"
1
+ import {escapeText, localizeDate} from "fwtoolkit"
2
2
 
3
- import type { Book } from "../../types.js"
4
- import { bookTerm } from "../../i18n.js"
3
+ import type {Book} from "../../types.js"
4
+ import {bookTerm} from "../../i18n.js"
5
5
 
6
- export const htmlBookChapterTemplate = ({
7
- body,
8
- back
9
- }: Record<string, unknown>) => `${body}${back}`
6
+ export const htmlBookChapterTemplate = ({body, back}: Record<string, unknown>) =>
7
+ `${body}${back}`
10
8
 
11
9
  interface HtmlBookExportParams {
12
- styleSheets: Array<{ filename: string }>
10
+ styleSheets: Array<{filename: string}>
13
11
  part?: string
14
12
  currentPart?: string
15
13
  contents: string
@@ -43,7 +41,11 @@ export const htmlBookExportTemplate = ({
43
41
  ? ` ${currentPart.toLowerCase().replace(/[^a-z]/g, "")}`
44
42
  : ""
45
43
  }">
46
- ${part?.length ? `<h1 class="part">${escapeText(part)}</h1>` : ""}
44
+ ${
45
+ part?.length
46
+ ? `<h1 class="part">${escapeText(part)}</h1>`
47
+ : ""
48
+ }
47
49
  ${contents}
48
50
  </body>
49
51
  </html>`
@@ -73,7 +75,7 @@ const htmlBookIndexItemTemplate = ({
73
75
  ? `<ol>
74
76
  ${(item.subItems as Array<Record<string, unknown>>)
75
77
  .map(subItem =>
76
- htmlBookIndexItemTemplate({ item: subItem, multiDoc })
78
+ htmlBookIndexItemTemplate({item: subItem, multiDoc})
77
79
  )
78
80
  .join("")}
79
81
  </ol>`
@@ -176,7 +178,7 @@ export const htmlBookIndexBodyTemplate = ({
176
178
  <div class="tocpage frontmatter">
177
179
  <nav role="doc-toc"><ol>
178
180
  ${contentItems
179
- .map(item => htmlBookIndexItemTemplate({ item, multiDoc }))
181
+ .map(item => htmlBookIndexItemTemplate({item, multiDoc}))
180
182
  .join("")}
181
183
  </ol></nav>
182
184
  </div>`
@@ -186,7 +188,7 @@ interface HtmlBookIndexParams {
186
188
  contentItems: Array<Record<string, unknown>>
187
189
  language: string
188
190
  creator: string
189
- styleSheets: Array<{ filename: string }>
191
+ styleSheets: Array<{filename: string}>
190
192
  multiDoc: boolean
191
193
  }
192
194
 
@@ -249,7 +251,7 @@ export const singleFileHTMLBookTemplate = ({
249
251
  <style>
250
252
  ${css}
251
253
  </style>
252
- ${(styleSheets as Array<{ filename?: string; contents?: string }>)
254
+ ${(styleSheets as Array<{filename?: string; contents?: string}>)
253
255
  .map(sheet =>
254
256
  sheet.filename
255
257
  ? `<link type="text/css" rel="stylesheet" href="${sheet.filename}" />`
@@ -5,15 +5,10 @@ export function orderLinks(
5
5
  contentItems[i].subItems = []
6
6
  if (i > 0) {
7
7
  for (let j = i - 1; j > -1; j--) {
8
- if (
9
- (contentItems[j].level as number) <
10
- (contentItems[i].level as number)
11
- ) {
12
- ;(
13
- contentItems[j].subItems as Array<
14
- Record<string, unknown>
15
- >
16
- ).push(contentItems[i])
8
+ if ((contentItems[j].level as number) < (contentItems[i].level as number)) {
9
+ ;(contentItems[j].subItems as Array<Record<string, unknown>>).push(
10
+ contentItems[i]
11
+ )
17
12
  contentItems[i].delete = true
18
13
  break
19
14
  }
@@ -2,17 +2,17 @@
2
2
  * LaTeX book exporter.
3
3
  */
4
4
 
5
- import type { Schema } from "prosemirror-model"
6
- import type { User } from "@fiduswriter/document"
7
- import { BibLatexExporter } from "biblatex-csl-converter"
8
- import { LatexExporterConvert } from "@fiduswriter/document/exporter/latex/convert"
9
- import { removeHidden } from "@fiduswriter/document/exporter/tools/doc_content"
10
- import { createSlug } from "@fiduswriter/document/exporter/tools/file"
11
- import { ZipFileCreator } from "@fiduswriter/document/exporter/tools/zip"
5
+ import type {Schema} from "prosemirror-model"
6
+ import type {User} from "@fiduswriter/document"
7
+ import {BibLatexExporter} from "biblatex-csl-converter"
8
+ import {LatexExporterConvert} from "@fiduswriter/document/exporter/latex/convert"
9
+ import {removeHidden} from "@fiduswriter/document/exporter/tools/doc_content"
10
+ import {createSlug} from "@fiduswriter/document/exporter/tools/file"
11
+ import {ZipFileCreator} from "@fiduswriter/document/exporter/tools/zip"
12
12
 
13
- import type { Book, DocumentListEntry } from "../../types.js"
14
- import { getMissingChapterData } from "../tools.js"
15
- import { bookTexTemplate } from "./templates.js"
13
+ import type {Book, DocumentListEntry} from "../../types.js"
14
+ import {getMissingChapterData} from "../tools.js"
15
+ import {bookTexTemplate} from "./templates.js"
16
16
 
17
17
  interface TextFile {
18
18
  filename: string
@@ -65,7 +65,7 @@ export class LatexBookExporter {
65
65
  let imageIds: string[] = []
66
66
  const features: Record<string, boolean> = {}
67
67
  const combinedBibliography: Record<string, unknown> = {}
68
- const combinedImages: Record<string, { image: string }> = {}
68
+ const combinedImages: Record<string, {image: string}> = {}
69
69
  this.book.chapters.forEach((chapter, index) => {
70
70
  const doc = this.docList.find(d => d.id === chapter.text)
71
71
  if (!doc) {
@@ -73,8 +73,8 @@ export class LatexBookExporter {
73
73
  }
74
74
  const converter = new LatexExporterConvert(
75
75
  this as any,
76
- { db: doc.images || {} },
77
- { db: doc.bibliography || {} },
76
+ {db: doc.images || {}},
77
+ {db: doc.bibliography || {}},
78
78
  doc.settings
79
79
  )
80
80
  const chapterContent = removeHidden(doc.content as any)
@@ -87,10 +87,7 @@ export class LatexBookExporter {
87
87
  ...new Set(bibIds.concat(Object.keys(convertedDoc.usedBibDB)))
88
88
  ]
89
89
  imageIds = [...new Set(imageIds.concat(convertedDoc.imageIds))]
90
- Object.assign(
91
- features,
92
- converter.features as Record<string, boolean>
93
- )
90
+ Object.assign(features, converter.features as Record<string, boolean>)
94
91
  Object.keys(convertedDoc.usedBibDB).forEach(
95
92
  bibId =>
96
93
  (combinedBibliography[bibId] = doc.bibliography?.[bibId])
@@ -123,9 +120,9 @@ export class LatexBookExporter {
123
120
  })
124
121
  const bookConverter = new LatexExporterConvert(
125
122
  this as any,
126
- { db: combinedImages as any },
127
- { db: combinedBibliography as any },
128
- { language: this.book.settings.language, bibliography_header: {} }
123
+ {db: combinedImages as any},
124
+ {db: combinedBibliography as any},
125
+ {language: this.book.settings.language, bibliography_header: {}}
129
126
  )
130
127
  bookConverter.features = features
131
128
  const preamble = bookConverter.assemblePreamble()
@@ -1,11 +1,7 @@
1
- import type { BookTexTemplateParams } from "../../types.js"
1
+ import type {BookTexTemplateParams} from "../../types.js"
2
2
 
3
3
  /** A template to create the latex book.tex file. */
4
- export const bookTexTemplate = ({
5
- preamble,
6
- book,
7
- epilogue
8
- }: BookTexTemplateParams) =>
4
+ export const bookTexTemplate = ({preamble, book, epilogue}: BookTexTemplateParams) =>
9
5
  `\\documentclass[11pt]{book}
10
6
  ${preamble}
11
7
  \\usepackage{docmute}
@@ -2,15 +2,15 @@
2
2
  * Native `.fidusbook` exporter.
3
3
  */
4
4
 
5
- import type { Schema } from "prosemirror-model"
6
- import { ShrinkFidus } from "@fiduswriter/document/exporter/native/shrink"
7
- import { createSlug } from "@fiduswriter/document/exporter/tools/file"
8
- import { ZipFileCreator } from "@fiduswriter/document/exporter/tools/zip"
9
- import { addAlert, gettext } from "fwtoolkit"
5
+ import type {Schema} from "prosemirror-model"
6
+ import {ShrinkFidus} from "@fiduswriter/document/exporter/native/shrink"
7
+ import {createSlug} from "@fiduswriter/document/exporter/tools/file"
8
+ import {ZipFileCreator} from "@fiduswriter/document/exporter/tools/zip"
9
+ import {addAlert, gettext} from "fwtoolkit"
10
10
 
11
- import { FIDUSBOOK_VERSION } from "../../schema/index.js"
12
- import type { Book, DocumentListEntry, User } from "../../types.js"
13
- import { getMissingChapterData } from "../tools.js"
11
+ import {FIDUSBOOK_VERSION} from "../../schema/index.js"
12
+ import type {Book, DocumentListEntry, User} from "../../types.js"
13
+ import {getMissingChapterData} from "../tools.js"
14
14
 
15
15
  interface FileInclude {
16
16
  url: string
@@ -22,7 +22,7 @@ interface TextFile {
22
22
  contents: string
23
23
  }
24
24
 
25
- export { FIDUSBOOK_VERSION }
25
+ export {FIDUSBOOK_VERSION}
26
26
 
27
27
  export class NativeBookExporter {
28
28
  schema: Schema
@@ -100,7 +100,7 @@ export class NativeBookExporter {
100
100
  file_type: coverImage.file_type,
101
101
  image: `cover/${filename}`
102
102
  }
103
- httpFiles.push({ url: imageUrl, filename: `cover/${filename}` })
103
+ httpFiles.push({url: imageUrl, filename: `cover/${filename}`})
104
104
  }
105
105
 
106
106
  const processChapter = (index: number): Promise<void> => {
@@ -115,8 +115,8 @@ export class NativeBookExporter {
115
115
 
116
116
  const shrinker = new ShrinkFidus(
117
117
  doc as any,
118
- { db: doc.images || {} },
119
- { db: doc.bibliography || {} },
118
+ {db: doc.images || {}},
119
+ {db: doc.bibliography || {}},
120
120
  true
121
121
  )
122
122
 
@@ -160,8 +160,8 @@ export class NativeBookExporter {
160
160
 
161
161
  return processChapter(0).then(() => {
162
162
  textFiles.push(
163
- { filename: "book.json", contents: JSON.stringify(bookData) },
164
- { filename: "filetype-version", contents: FIDUSBOOK_VERSION }
163
+ {filename: "book.json", contents: JSON.stringify(bookData)},
164
+ {filename: "filetype-version", contents: FIDUSBOOK_VERSION}
165
165
  )
166
166
 
167
167
  const zipper = new ZipFileCreator(
@@ -2,28 +2,28 @@
2
2
  * ODT book exporter.
3
3
  */
4
4
 
5
- import type { Schema } from "prosemirror-model"
6
- import type { CSL, User } from "@fiduswriter/document"
5
+ import type {Schema} from "prosemirror-model"
6
+ import type {CSL, User} from "@fiduswriter/document"
7
7
  import {
8
8
  fixTables,
9
9
  removeHidden
10
10
  } from "@fiduswriter/document/exporter/tools/doc_content"
11
- import { createSlug } from "@fiduswriter/document/exporter/tools/file"
12
- import { XmlZip } from "@fiduswriter/document/exporter/tools/xml_zip"
13
- import { addAlert, gettext } from "fwtoolkit"
11
+ import {createSlug} from "@fiduswriter/document/exporter/tools/file"
12
+ import {XmlZip} from "@fiduswriter/document/exporter/tools/xml_zip"
13
+ import {addAlert} from "fwtoolkit"
14
14
 
15
- import { ODTExporterCitations } from "@fiduswriter/document/exporter/odt/citations"
16
- import { ODTExporterImages } from "@fiduswriter/document/exporter/odt/images"
17
- import { ODTExporterFootnotes } from "@fiduswriter/document/exporter/odt/footnotes"
18
- import { ODTExporterMath } from "@fiduswriter/document/exporter/odt/math"
19
- import { ODTExporterMetadata } from "@fiduswriter/document/exporter/odt/metadata"
20
- import { ODTExporterRichtext } from "@fiduswriter/document/exporter/odt/richtext"
21
- import { ODTExporterStyles } from "@fiduswriter/document/exporter/odt/styles"
22
- import { ODTExporterTracks } from "@fiduswriter/document/exporter/odt/track"
15
+ import {ODTExporterCitations} from "@fiduswriter/document/exporter/odt/citations"
16
+ import {ODTExporterImages} from "@fiduswriter/document/exporter/odt/images"
17
+ import {ODTExporterFootnotes} from "@fiduswriter/document/exporter/odt/footnotes"
18
+ import {ODTExporterMath} from "@fiduswriter/document/exporter/odt/math"
19
+ import {ODTExporterMetadata} from "@fiduswriter/document/exporter/odt/metadata"
20
+ import {ODTExporterRichtext} from "@fiduswriter/document/exporter/odt/richtext"
21
+ import {ODTExporterStyles} from "@fiduswriter/document/exporter/odt/styles"
22
+ import {ODTExporterTracks} from "@fiduswriter/document/exporter/odt/track"
23
23
 
24
- import type { Book, DocumentListEntry } from "../../types.js"
25
- import { getMissingChapterData } from "../tools.js"
26
- import { ODTBookExporterRender } from "./render.js"
24
+ import type {Book, DocumentListEntry} from "../../types.js"
25
+ import {getMissingChapterData} from "../tools.js"
26
+ import {ODTBookExporterRender} from "./render.js"
27
27
 
28
28
  export class ODTBookExporter {
29
29
  schema: Schema
@@ -66,9 +66,12 @@ export class ODTBookExporter {
66
66
  )
67
67
  return false
68
68
  }
69
- return getMissingChapterData(this.book, this.docList, this.schema, {
70
- rawContent: true
71
- }).then(() => this.export())
69
+ return getMissingChapterData(
70
+ this.book,
71
+ this.docList,
72
+ this.schema,
73
+ {rawContent: true}
74
+ ).then(() => this.export())
72
75
  }
73
76
 
74
77
  export(): Promise<Blob> {
@@ -91,9 +94,7 @@ export class ODTBookExporter {
91
94
  .then(() => render.init())
92
95
  .then(() => metadata.init())
93
96
  .then(() => math.init())
94
- .then(() =>
95
- this.exportChapters(xml as any, render, styles, math, tracks)
96
- )
97
+ .then(() => this.exportChapters(xml as any, render, styles, math, tracks))
97
98
  .then(() => xml.prepareBlob())
98
99
  .then(blob => this.download(blob))
99
100
  }
@@ -119,7 +120,7 @@ export class ODTBookExporter {
119
120
  docContent as any,
120
121
  doc.settings,
121
122
  styles,
122
- { db: doc.bibliography || {} },
123
+ {db: doc.bibliography || {}},
123
124
  this.csl
124
125
  )
125
126
  const footnotes = new ODTExporterFootnotes(
@@ -128,8 +129,8 @@ export class ODTBookExporter {
128
129
  xml,
129
130
  citations,
130
131
  styles,
131
- { db: doc.bibliography || {} },
132
- { db: doc.images || {} },
132
+ {db: doc.bibliography || {}},
133
+ {db: doc.images || {}},
133
134
  this.csl
134
135
  )
135
136
 
@@ -185,7 +186,7 @@ export class ODTBookExporter {
185
186
 
186
187
  getBaseMetadata(): Record<string, unknown> {
187
188
  const authors = this.book.metadata.author?.length
188
- ? [{ institution: this.book.metadata.author }]
189
+ ? [{institution: this.book.metadata.author}]
189
190
  : []
190
191
  const keywords = this.book.metadata.keywords?.length
191
192
  ? this.book.metadata.keywords
@@ -1,4 +1,4 @@
1
- import { ODTExporterRender } from "@fiduswriter/document/exporter/odt/render"
1
+ import {ODTExporterRender} from "@fiduswriter/document/exporter/odt/render"
2
2
 
3
3
  export class ODTBookExporterRender extends ODTExporterRender {
4
4
  styles: any
@@ -59,8 +59,7 @@ export class ODTBookExporterRender extends ODTExporterRender {
59
59
  }
60
60
 
61
61
  render(...args: any[]): void {
62
- const [docContent, pmBib, settings, richtext, citations, chapterIndex] =
63
- args
62
+ const [docContent, pmBib, settings, richtext, citations, chapterIndex] = args
64
63
  this.text = this.bodyTemplate.cloneNode(true)
65
64
  const bodyBookmark = (this.text as any).query("text:bookmark", {
66
65
  "text:name": "body"
@@ -91,19 +90,19 @@ export class ODTBookExporterRender extends ODTExporterRender {
91
90
  series_position
92
91
  }: Record<string, unknown>): void {
93
92
  const tags = [
94
- { title: "book.title", content: title },
95
- { title: "book.subtitle", content: subtitle },
96
- { title: "book.version", content: version },
97
- { title: "book.publisher", content: publisher },
98
- { title: "book.copyright", content: copyright },
99
- { title: "book.author", content: author },
100
- { title: "book.keywords", content: keywords },
101
- { title: "book.language", content: language },
102
- { title: "book.description", content: description },
103
- { title: "book.isbn", content: isbn },
104
- { title: "book.publication_date", content: publication_date },
105
- { title: "book.series_title", content: series_title },
106
- { title: "book.series_position", content: series_position }
93
+ {title: "book.title", content: title},
94
+ {title: "book.subtitle", content: subtitle},
95
+ {title: "book.version", content: version},
96
+ {title: "book.publisher", content: publisher},
97
+ {title: "book.copyright", content: copyright},
98
+ {title: "book.author", content: author},
99
+ {title: "book.keywords", content: keywords},
100
+ {title: "book.language", content: language},
101
+ {title: "book.description", content: description},
102
+ {title: "book.isbn", content: isbn},
103
+ {title: "book.publication_date", content: publication_date},
104
+ {title: "book.series_title", content: series_title},
105
+ {title: "book.series_position", content: series_position}
107
106
  ]
108
107
  const usedTags: any[] = []
109
108
  const ambles = [this.preamble, this.postamble]
@@ -117,7 +116,7 @@ export class ODTBookExporterRender extends ODTExporterRender {
117
116
  tags.forEach(tag => {
118
117
  const tagString = tag.title
119
118
  if (text.includes(`{${tagString}}`)) {
120
- usedTags.push(Object.assign({ block }, tag))
119
+ usedTags.push(Object.assign({block}, tag))
121
120
  }
122
121
  })
123
122
  })
@@ -4,13 +4,13 @@
4
4
  * Uses @vivliostyle/print to render the book in the browser.
5
5
  */
6
6
 
7
- import type { Schema } from "prosemirror-model"
8
- import type { CSL, User } from "@fiduswriter/document"
9
- import { printHTML } from "@vivliostyle/print"
7
+ import type {Schema} from "prosemirror-model"
8
+ import type {CSL, User} from "@fiduswriter/document"
9
+ import {printHTML} from "@vivliostyle/print"
10
10
 
11
- import type { Book, BookStyles, DocumentListEntry } from "../../types.js"
12
- import { HTMLBookExporter } from "../html/index.js"
13
- import { chapterTemplate } from "./templates.js"
11
+ import type {Book, BookStyles, DocumentListEntry} from "../../types.js"
12
+ import {HTMLBookExporter} from "../html/index.js"
13
+ import {chapterTemplate} from "./templates.js"
14
14
 
15
15
  export class PrintBookExporter extends HTMLBookExporter {
16
16
  constructor(
@@ -37,10 +37,13 @@ export class PrintBookExporter extends HTMLBookExporter {
37
37
  let contents = bookStyle.contents
38
38
  bookStyle.bookstylefile_set.forEach(
39
39
  ([url, filename]: [string, string]) =>
40
- (contents = contents.replace(new RegExp(filename, "g"), url))
40
+ (contents = contents.replace(
41
+ new RegExp(filename, "g"),
42
+ url
43
+ ))
41
44
  )
42
45
 
43
- this.styleSheets.push({ contents })
46
+ this.styleSheets.push({contents})
44
47
  return true
45
48
  }
46
49
 
@@ -51,7 +54,7 @@ export class PrintBookExporter extends HTMLBookExporter {
51
54
  if (!htmlDoc) {
52
55
  return
53
56
  }
54
- const config: any = { title: this.book.title }
57
+ const config: any = {title: this.book.title}
55
58
 
56
59
  if (navigator.userAgent.includes("Gecko/")) {
57
60
  config.printCallback = (iframeWin: Window) => {
@@ -67,7 +70,8 @@ export class PrintBookExporter extends HTMLBookExporter {
67
70
  document.body.appendChild(backgroundStyle)
68
71
  window.print()
69
72
  document.body = oldBody
70
- delete document.body.parentElement!.dataset.vivliostylePaginated
73
+ delete document.body.parentElement!.dataset
74
+ .vivliostylePaginated
71
75
  }
72
76
  }
73
77
 
@@ -78,7 +82,7 @@ export class PrintBookExporter extends HTMLBookExporter {
78
82
  url?: string
79
83
  filename?: string
80
84
  contents?: string
81
- }): Promise<{ url?: string; filename?: string; contents?: string }> {
85
+ }): Promise<{url?: string; filename?: string; contents?: string}> {
82
86
  if (sheet.url) {
83
87
  sheet.filename = sheet.url
84
88
  delete sheet.url
@@ -1,4 +1,4 @@
1
- import { escapeText } from "fwtoolkit"
1
+ import {escapeText} from "fwtoolkit"
2
2
 
3
3
  export const chapterTemplate = ({
4
4
  part,