@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,17 +2,17 @@
2
2
  * BITS (Book Interchange Tag Suite) book exporter.
3
3
  */
4
4
 
5
- import type { Schema } from "prosemirror-model"
5
+ import type {Schema} from "prosemirror-model"
6
6
  import pretty from "pretty"
7
- import { JATSExporterConverter } from "@fiduswriter/document/exporter/jats/convert"
8
- import { darManifest } from "@fiduswriter/document/exporter/jats/templates"
9
- import { createSlug } from "@fiduswriter/document/exporter/tools/file"
10
- import { ZipFileCreator } from "@fiduswriter/document/exporter/tools/zip"
11
- import { addAlert, gettext } from "fwtoolkit"
7
+ import {JATSExporterConverter} from "@fiduswriter/document/exporter/jats/convert"
8
+ import {darManifest} from "@fiduswriter/document/exporter/jats/templates"
9
+ import {createSlug} from "@fiduswriter/document/exporter/tools/file"
10
+ import {ZipFileCreator} from "@fiduswriter/document/exporter/tools/zip"
11
+ import {addAlert} from "fwtoolkit"
12
12
 
13
- import type { Book, CSL, DocumentListEntry, User } from "../../types.js"
14
- import { getMissingChapterData } from "../tools.js"
15
- import { bitsTemplate } from "./templates.js"
13
+ import type {Book, CSL, DocumentListEntry, User} from "../../types.js"
14
+ import {getMissingChapterData} from "../tools.js"
15
+ import {bitsTemplate} from "./templates.js"
16
16
 
17
17
  interface TextFile {
18
18
  filename: string
@@ -73,39 +73,37 @@ export class BITSBookExporter {
73
73
  export(): Promise<Blob> {
74
74
  this.book.chapters.sort((a, b) => (a.number > b.number ? 1 : -1))
75
75
 
76
- const imageDict: Record<string, { image: string; title?: string }> = {}
76
+ const imageDict: Record<string, {image: string; title?: string}> = {}
77
77
  return Promise.all(
78
78
  this.book.chapters.map(chapter => {
79
79
  const doc = this.docList.find(d => d.id === chapter.text)
80
80
  if (!doc) {
81
- return Promise.resolve({ front: "", body: "", back: "" })
81
+ return Promise.resolve({front: "", body: "", back: ""})
82
82
  }
83
83
  const converter = new JATSExporterConverter(
84
84
  this.type,
85
85
  doc,
86
86
  this.csl,
87
- { db: doc.images || {} },
88
- { db: doc.bibliography || {} }
87
+ {db: doc.images || {}},
88
+ {db: doc.bibliography || {}}
89
89
  )
90
- return converter
91
- .init()
92
- .then(({ front, body, back, imageIds }) => {
93
- imageIds.forEach(
94
- (imageId: string | number) =>
95
- (imageDict[imageId] = doc.images?.[imageId] as {
96
- image: string
97
- title?: string
98
- })
99
- )
100
- return { front, body, back }
101
- })
90
+ return converter.init().then(({front, body, back, imageIds}) => {
91
+ imageIds.forEach(
92
+ (imageId: string | number) =>
93
+ (imageDict[imageId] = doc.images?.[imageId] as {
94
+ image: string
95
+ title?: string
96
+ })
97
+ )
98
+ return {front, body, back}
99
+ })
102
100
  })
103
101
  ).then(chapters => this.createFiles(chapters, imageDict))
104
102
  }
105
103
 
106
104
  createFiles(
107
- chapters: Array<{ front: string; body: string; back: string }>,
108
- imageDict: Record<string, { image: string; title?: string }>
105
+ chapters: Array<{front: string; body: string; back: string}>,
106
+ imageDict: Record<string, {image: string; title?: string}>
109
107
  ): Promise<Blob> {
110
108
  const images = Object.values(imageDict).map(image => ({
111
109
  filename: image.image.split("/").pop()?.split("?")[0] || "",
@@ -118,9 +116,7 @@ export class BITSBookExporter {
118
116
  this.textFiles = [
119
117
  {
120
118
  filename: "manuscript.xml",
121
- contents: pretty(bitsTemplate(this.book, chapters), {
122
- ocd: true
123
- })
119
+ contents: pretty(bitsTemplate(this.book, chapters), {ocd: true})
124
120
  },
125
121
  {
126
122
  filename: "manifest.xml",
@@ -130,7 +126,7 @@ export class BITSBookExporter {
130
126
  type: this.type,
131
127
  images
132
128
  }),
133
- { ocd: true }
129
+ {ocd: true}
134
130
  )
135
131
  }
136
132
  ]
@@ -1,13 +1,13 @@
1
- import { escapeText } from "fwtoolkit"
1
+ import {escapeText} from "fwtoolkit"
2
2
 
3
- import type { Book, BitsTemplateParams } from "../../types.js"
3
+ import type {Book, BitsTemplateParams} from "../../types.js"
4
4
 
5
- const bookPartTemplate = ({ front, body, back }: BitsTemplateParams) =>
5
+ const bookPartTemplate = ({front, body, back}: BitsTemplateParams) =>
6
6
  `<book-part book-part-type="chapter" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:ali="http://www.niso.org/schemas/ali/1.0/" xmlns:mml="http://www.w3.org/1998/Math/MathML">${front}${body}${back}</book-part>`
7
7
 
8
8
  export const bitsTemplate = (
9
9
  book: Book,
10
- chapters: Array<{ front: string; body: string; back: string }>
10
+ chapters: Array<{front: string; body: string; back: string}>
11
11
  ) => {
12
12
  const updated = new Date((book.updated || 0) * 1000)
13
13
  return `<?xml version="1.0" encoding="UTF-8"?>
@@ -2,31 +2,31 @@
2
2
  * DOCX 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"
14
-
15
- import { DOCXExporterCitations } from "@fiduswriter/document/exporter/docx/citations"
16
- import { DOCXExporterComments } from "@fiduswriter/document/exporter/docx/comments"
17
- import { DOCXExporterFootnotes } from "@fiduswriter/document/exporter/docx/footnotes"
18
- import { DOCXExporterImages } from "@fiduswriter/document/exporter/docx/images"
19
- import { DOCXExporterLists } from "@fiduswriter/document/exporter/docx/lists"
20
- import { DOCXExporterMath } from "@fiduswriter/document/exporter/docx/math"
21
- import { DOCXExporterMetadata } from "@fiduswriter/document/exporter/docx/metadata"
22
- import { DOCXExporterRels } from "@fiduswriter/document/exporter/docx/rels"
23
- import { DOCXExporterRichtext } from "@fiduswriter/document/exporter/docx/richtext"
24
- import { DOCXExporterTables } from "@fiduswriter/document/exporter/docx/tables"
25
- import { moveFootnoteComments } from "@fiduswriter/document/exporter/docx/tools"
26
-
27
- import type { Book, DocumentListEntry } from "../../types.js"
28
- import { getMissingChapterData } from "../tools.js"
29
- import { DOCXBookExporterRender } from "./render.js"
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
+
15
+ import {DOCXExporterCitations} from "@fiduswriter/document/exporter/docx/citations"
16
+ import {DOCXExporterComments} from "@fiduswriter/document/exporter/docx/comments"
17
+ import {DOCXExporterFootnotes} from "@fiduswriter/document/exporter/docx/footnotes"
18
+ import {DOCXExporterImages} from "@fiduswriter/document/exporter/docx/images"
19
+ import {DOCXExporterLists} from "@fiduswriter/document/exporter/docx/lists"
20
+ import {DOCXExporterMath} from "@fiduswriter/document/exporter/docx/math"
21
+ import {DOCXExporterMetadata} from "@fiduswriter/document/exporter/docx/metadata"
22
+ import {DOCXExporterRels} from "@fiduswriter/document/exporter/docx/rels"
23
+ import {DOCXExporterRichtext} from "@fiduswriter/document/exporter/docx/richtext"
24
+ import {DOCXExporterTables} from "@fiduswriter/document/exporter/docx/tables"
25
+ import {moveFootnoteComments} from "@fiduswriter/document/exporter/docx/tools"
26
+
27
+ import type {Book, DocumentListEntry} from "../../types.js"
28
+ import {getMissingChapterData} from "../tools.js"
29
+ import {DOCXBookExporterRender} from "./render.js"
30
30
 
31
31
  export class DOCXBookExporter {
32
32
  schema: Schema
@@ -70,9 +70,12 @@ export class DOCXBookExporter {
70
70
  )
71
71
  return false
72
72
  }
73
- return getMissingChapterData(this.book, this.docList, this.schema, {
74
- rawContent: true
75
- }).then(() => this.export())
73
+ return getMissingChapterData(
74
+ this.book,
75
+ this.docList,
76
+ this.schema,
77
+ {rawContent: true}
78
+ ).then(() => this.export())
76
79
  }
77
80
 
78
81
  export(): Promise<Blob> {
@@ -95,9 +98,7 @@ export class DOCXBookExporter {
95
98
  .then(() => math.init())
96
99
  .then(() => render.init())
97
100
  .then(() => rels.init())
98
- .then(() =>
99
- this.exportChapters(xml as any, render, rels, math, tables)
100
- )
101
+ .then(() => this.exportChapters(xml as any, render, rels, math, tables))
101
102
  .then(() => xml.prepareBlob())
102
103
  .then(blob => this.download(blob))
103
104
  }
@@ -124,7 +125,7 @@ export class DOCXBookExporter {
124
125
 
125
126
  const images = new DOCXExporterImages(
126
127
  docContent as any,
127
- { db: doc.images || {} },
128
+ {db: doc.images || {}},
128
129
  xml,
129
130
  rels
130
131
  )
@@ -132,7 +133,7 @@ export class DOCXBookExporter {
132
133
  const citations = new DOCXExporterCitations(
133
134
  docContent,
134
135
  doc.settings,
135
- { db: doc.bibliography || {} },
136
+ {db: doc.bibliography || {}},
136
137
  this.csl,
137
138
  xml
138
139
  )
@@ -141,8 +142,8 @@ export class DOCXBookExporter {
141
142
  doc as any,
142
143
  docContent,
143
144
  doc.settings,
144
- { db: doc.images || {} },
145
- { db: doc.bibliography || {} },
145
+ {db: doc.images || {}},
146
+ {db: doc.bibliography || {}},
146
147
  xml,
147
148
  citations,
148
149
  this.csl,
@@ -213,7 +214,7 @@ export class DOCXBookExporter {
213
214
 
214
215
  getBaseMetadata(): Record<string, unknown> {
215
216
  const authors = this.book.metadata.author?.length
216
- ? [{ institution: this.book.metadata.author }]
217
+ ? [{institution: this.book.metadata.author}]
217
218
  : []
218
219
  const keywords = this.book.metadata.keywords?.length
219
220
  ? this.book.metadata.keywords
@@ -1,4 +1,4 @@
1
- import { DOCXExporterRender } from "@fiduswriter/document/exporter/docx/render"
1
+ import {DOCXExporterRender} from "@fiduswriter/document/exporter/docx/render"
2
2
 
3
3
  export class DOCXBookExporterRender extends DOCXExporterRender {
4
4
  preamble: any
@@ -47,8 +47,7 @@ export class DOCXBookExporterRender extends DOCXExporterRender {
47
47
  }
48
48
 
49
49
  render(...args: any[]): void {
50
- const [docContent, pmBib, settings, richtext, citations, chapterIndex] =
51
- args
50
+ const [docContent, pmBib, settings, richtext, citations, chapterIndex] = args
52
51
  this.text = this.bodyTemplate.cloneNode(true)
53
52
  const bodyBookmark = (this.text as any).query("w:bookmarkStart", {
54
53
  "w:name": "body"
@@ -76,19 +75,19 @@ export class DOCXBookExporterRender extends DOCXExporterRender {
76
75
  series_position
77
76
  }: Record<string, unknown>): void {
78
77
  const tags = [
79
- { title: "book.title", content: title },
80
- { title: "book.subtitle", content: subtitle },
81
- { title: "book.version", content: version },
82
- { title: "book.publisher", content: publisher },
83
- { title: "book.copyright", content: copyright },
84
- { title: "book.author", content: author },
85
- { title: "book.keywords", content: keywords },
86
- { title: "book.language", content: language },
87
- { title: "book.description", content: description },
88
- { title: "book.isbn", content: isbn },
89
- { title: "book.publication_date", content: publication_date },
90
- { title: "book.series_title", content: series_title },
91
- { title: "book.series_position", content: series_position }
78
+ {title: "book.title", content: title},
79
+ {title: "book.subtitle", content: subtitle},
80
+ {title: "book.version", content: version},
81
+ {title: "book.publisher", content: publisher},
82
+ {title: "book.copyright", content: copyright},
83
+ {title: "book.author", content: author},
84
+ {title: "book.keywords", content: keywords},
85
+ {title: "book.language", content: language},
86
+ {title: "book.description", content: description},
87
+ {title: "book.isbn", content: isbn},
88
+ {title: "book.publication_date", content: publication_date},
89
+ {title: "book.series_title", content: series_title},
90
+ {title: "book.series_position", content: series_position}
92
91
  ]
93
92
  const usedTags: any[] = []
94
93
  const ambles = [this.preamble, this.postamble]
@@ -99,7 +98,7 @@ export class DOCXBookExporterRender extends DOCXExporterRender {
99
98
  tags.forEach(tag => {
100
99
  const tagString = tag.title
101
100
  if (text.includes(`{${tagString}}`)) {
102
- usedTags.push(Object.assign({ block }, tag))
101
+ usedTags.push(Object.assign({block}, tag))
103
102
  }
104
103
  })
105
104
  })
@@ -2,23 +2,17 @@
2
2
  * EPUB book exporter.
3
3
  */
4
4
 
5
- import type { Schema } from "prosemirror-model"
6
- import { HTMLExporterConvert } from "@fiduswriter/document/exporter/html/convert"
7
- import { htmlExportTemplate } from "@fiduswriter/document/exporter/html/templates"
8
- import { removeHidden } from "@fiduswriter/document/exporter/tools/doc_content"
9
- import { createSlug } from "@fiduswriter/document/exporter/tools/file"
10
- import { ZipFileCreator } from "@fiduswriter/document/exporter/tools/zip"
11
- import { addAlert, get, gettext, staticUrl } from "fwtoolkit"
5
+ import type {Schema} from "prosemirror-model"
6
+ import {HTMLExporterConvert} from "@fiduswriter/document/exporter/html/convert"
7
+ import {htmlExportTemplate} from "@fiduswriter/document/exporter/html/templates"
8
+ import {removeHidden} from "@fiduswriter/document/exporter/tools/doc_content"
9
+ import {createSlug} from "@fiduswriter/document/exporter/tools/file"
10
+ import {ZipFileCreator} from "@fiduswriter/document/exporter/tools/zip"
11
+ import {addAlert, get, staticUrl} from "fwtoolkit"
12
12
  import pretty from "pretty"
13
13
 
14
- import type {
15
- Book,
16
- BookStyles,
17
- CSL,
18
- DocumentListEntry,
19
- User
20
- } from "../../types.js"
21
- import { getMissingChapterData } from "../tools.js"
14
+ import type {Book, BookStyles, CSL, DocumentListEntry, User} from "../../types.js"
15
+ import {getMissingChapterData} from "../tools.js"
22
16
  import {
23
17
  containerTemplate,
24
18
  epubBookCopyrightTemplate,
@@ -110,7 +104,7 @@ export class EpubBookExporter {
110
104
  this.images = []
111
105
  this.fontFiles = []
112
106
  this.httpFiles = []
113
- this.styleSheets = [{ url: staticUrl("css/book.css") }]
107
+ this.styleSheets = [{url: staticUrl("css/book.css")}]
114
108
  this.chapters = []
115
109
  this.contentItems = []
116
110
  this.includeZips = []
@@ -148,10 +142,7 @@ export class EpubBookExporter {
148
142
  )
149
143
  })
150
144
 
151
- this.styleSheets.push({
152
- contents,
153
- filename: `css/${bookStyle.slug}.css`
154
- })
145
+ this.styleSheets.push({contents, filename: `css/${bookStyle.slug}.css`})
155
146
  this.fontFiles = this.fontFiles.concat(
156
147
  bookStyle.bookstylefile_set.map(([url, filename]) => ({
157
148
  filename: `css/media/${filename}`,
@@ -171,9 +162,7 @@ export class EpubBookExporter {
171
162
  if (coverImage?.image) {
172
163
  this.images.push({
173
164
  url: coverImage.image.split("?")[0],
174
- filename:
175
- coverImage.image.split("/").pop()?.split("?")[0] ||
176
- "cover",
165
+ filename: coverImage.image.split("/").pop()?.split("?")[0] || "cover",
177
166
  coverImage: true
178
167
  })
179
168
 
@@ -212,17 +201,15 @@ export class EpubBookExporter {
212
201
  return false
213
202
  }
214
203
 
215
- const docContent = removeHidden(
216
- doc.content as any
217
- ) as any
204
+ const docContent = removeHidden(doc.content as any) as any
218
205
 
219
206
  const converter = new HTMLExporterConvert(
220
207
  doc.title,
221
208
  doc.settings,
222
209
  docContent,
223
210
  htmlExportTemplate,
224
- { db: doc.images || {} },
225
- { db: doc.bibliography || {} },
211
+ {db: doc.images || {}},
212
+ {db: doc.bibliography || {}},
226
213
  this.csl,
227
214
  this.styleSheets,
228
215
  {
@@ -233,7 +220,7 @@ export class EpubBookExporter {
233
220
  idPrefix: `c-${chapter.number}-`
234
221
  }
235
222
  )
236
- const { html, imageIds, metaData, extraStyleSheets } =
223
+ const {html, imageIds, metaData, extraStyleSheets} =
237
224
  await converter.init()
238
225
 
239
226
  if (!html) {
@@ -242,10 +229,7 @@ export class EpubBookExporter {
242
229
 
243
230
  imageIds.forEach((id: string | number) => {
244
231
  const image = doc.images?.[id]
245
- if (
246
- image?.image &&
247
- typeof image.image === "string"
248
- ) {
232
+ if (image?.image && typeof image.image === "string") {
249
233
  this.images.push({
250
234
  filename: `images/${image.image.split("/").pop()}`,
251
235
  url: image.image
@@ -254,8 +238,8 @@ export class EpubBookExporter {
254
238
  })
255
239
 
256
240
  await Promise.all(
257
- extraStyleSheets.map(async (sheet: StyleSheet) =>
258
- this.loadStyle(sheet)
241
+ extraStyleSheets.map(
242
+ async (sheet: StyleSheet) => this.loadStyle(sheet)
259
243
  )
260
244
  )
261
245
 
@@ -302,9 +286,7 @@ export class EpubBookExporter {
302
286
  })
303
287
  }
304
288
  items = items.concat(
305
- (
306
- chapter.metaData.toc as Array<Record<string, unknown>>
307
- ).map(item => ({
289
+ (chapter.metaData.toc as Array<Record<string, unknown>>).map(item => ({
308
290
  ...item,
309
291
  docNum: chapter.number,
310
292
  link: `document-${chapter.number}.xhtml#c-${chapter.number}-${item.id}`
@@ -412,15 +394,13 @@ export class EpubBookExporter {
412
394
  ) {
413
395
  return file
414
396
  }
415
- return Object.assign({}, file, {
416
- filename: `EPUB/${file.filename}`
417
- })
397
+ return Object.assign({}, file, {filename: `EPUB/${file.filename}`})
418
398
  })
419
399
  this.fontFiles = this.fontFiles.map(file =>
420
- Object.assign({}, file, { filename: `EPUB/${file.filename}` })
400
+ Object.assign({}, file, {filename: `EPUB/${file.filename}`})
421
401
  )
422
402
  this.includeZips = this.includeZips.map(file =>
423
- Object.assign({}, file, { directory: `EPUB/${file.directory}` })
403
+ Object.assign({}, file, {directory: `EPUB/${file.directory}`})
424
404
  )
425
405
  }
426
406
 
@@ -1,9 +1,9 @@
1
- import { LANGUAGES } from "@fiduswriter/document/schema/const"
2
- import { escapeText, localizeDate } from "fwtoolkit"
3
- import { mathliveOpfIncludes } from "@fiduswriter/document/mathlive/opf_includes"
1
+ import {LANGUAGES} from "@fiduswriter/document/schema/const"
2
+ import {escapeText, localizeDate} from "fwtoolkit"
3
+ import {mathliveOpfIncludes} from "@fiduswriter/document/mathlive/opf_includes"
4
4
 
5
- import type { Book } from "../../types.js"
6
- import { bookTerm } from "../../i18n.js"
5
+ import type {Book} from "../../types.js"
6
+ import {bookTerm} from "../../i18n.js"
7
7
 
8
8
  export const containerTemplate = () => `<?xml version="1.0" encoding="UTF-8"?>
9
9
  <container xmlns="urn:oasis:names:tc:opendocument:xmlns:container" version="1.0">
@@ -184,11 +184,11 @@ export const epubBookOpfTemplate = ({
184
184
  idType: string
185
185
  date: string
186
186
  modified: string
187
- styleSheets: Array<{ filename: string }>
187
+ styleSheets: Array<{filename: string}>
188
188
  math: boolean
189
- images: Array<{ coverImage?: boolean; filename: string; mimeType?: string }>
190
- fontFiles: Array<{ filename: string; mimeType?: string }>
191
- chapters: Array<{ number: number }>
189
+ images: Array<{coverImage?: boolean; filename: string; mimeType?: string}>
190
+ fontFiles: Array<{filename: string; mimeType?: string}>
191
+ chapters: Array<{number: number}>
192
192
  user: Record<string, string>
193
193
  }) => `<?xml version="1.0" encoding="UTF-8"?>
194
194
  <package xmlns="http://www.idpf.org/2007/opf" version="3.0"
@@ -296,9 +296,7 @@ export const epubBookOpfTemplate = ({
296
296
  ${book.cover_image ? '<itemref idref="cover" linear="no"/>' : ""}
297
297
  <itemref idref="titlepage" linear="yes"/>
298
298
  ${chapters
299
- .map(
300
- chapter => `<itemref idref="t${chapter.number}" linear="yes" />`
301
- )
299
+ .map(chapter => `<itemref idref="t${chapter.number}" linear="yes" />`)
302
300
  .join("")}
303
301
  <itemref idref="copyright" linear="yes"/>
304
302
  <itemref idref="nav" linear="no"/>
@@ -318,7 +316,7 @@ export const navTemplate = ({
318
316
  }: {
319
317
  shortLang: string
320
318
  toc: TocItem[]
321
- styleSheets: Array<{ filename: string }>
319
+ styleSheets: Array<{filename: string}>
322
320
  }) =>
323
321
  `<?xml version="1.0" encoding="UTF-8"?>
324
322
  <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="${shortLang}"
@@ -386,7 +384,7 @@ export const ncxTemplate = ({
386
384
 
387
385
  const renderNcxItems = (
388
386
  items: TocItem[],
389
- counter: { count: number } = { count: 1 }
387
+ counter: {count: number} = {count: 1}
390
388
  ): string =>
391
389
  items
392
390
  .map(
@@ -55,11 +55,9 @@ export function buildHierarchy(
55
55
  parentLevel--
56
56
  }
57
57
  if (parent) {
58
- ;(
59
- idMap[parent.id as string | number].children as Array<
60
- Record<string, unknown>
61
- >
62
- ).push(node)
58
+ ;(idMap[parent.id as string | number].children as Array<
59
+ Record<string, unknown>
60
+ >).push(node)
63
61
  } else {
64
62
  root.push(node)
65
63
  }