@fiduswriter/editor 0.2.5 → 0.2.7

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 (62) hide show
  1. package/dist/copyright_dialog/templates.d.ts.map +1 -1
  2. package/dist/copyright_dialog/templates.js +11 -31
  3. package/dist/copyright_dialog/templates.js.map +1 -1
  4. package/dist/dialogs/epub_export.d.ts +15 -0
  5. package/dist/dialogs/epub_export.d.ts.map +1 -0
  6. package/dist/dialogs/epub_export.js +43 -0
  7. package/dist/dialogs/epub_export.js.map +1 -0
  8. package/dist/dialogs/html_export.d.ts +3 -0
  9. package/dist/dialogs/html_export.d.ts.map +1 -1
  10. package/dist/dialogs/html_export.js +4 -3
  11. package/dist/dialogs/html_export.js.map +1 -1
  12. package/dist/dialogs/index.d.ts +2 -0
  13. package/dist/dialogs/index.d.ts.map +1 -1
  14. package/dist/dialogs/index.js +2 -0
  15. package/dist/dialogs/index.js.map +1 -1
  16. package/dist/dialogs/template_export.d.ts +13 -0
  17. package/dist/dialogs/template_export.d.ts.map +1 -0
  18. package/dist/dialogs/template_export.js +46 -0
  19. package/dist/dialogs/template_export.js.map +1 -0
  20. package/dist/dialogs/templates.d.ts +9 -0
  21. package/dist/dialogs/templates.d.ts.map +1 -1
  22. package/dist/dialogs/templates.js +54 -12
  23. package/dist/dialogs/templates.js.map +1 -1
  24. package/dist/document_template/index.d.ts.map +1 -1
  25. package/dist/document_template/index.js +23 -4
  26. package/dist/document_template/index.js.map +1 -1
  27. package/dist/menus/headerbar/model.d.ts +1 -1
  28. package/dist/menus/headerbar/model.d.ts.map +1 -1
  29. package/dist/menus/headerbar/model.js +33 -12
  30. package/dist/menus/headerbar/model.js.map +1 -1
  31. package/dist/menus/toolbar/model.d.ts +7 -7
  32. package/dist/menus/toolbar/model.d.ts.map +1 -1
  33. package/locale/ar/messages.json +0 -1
  34. package/locale/bg/messages.json +0 -1
  35. package/locale/cs/messages.json +0 -1
  36. package/locale/da/messages.json +0 -1
  37. package/locale/de/messages.json +0 -1
  38. package/locale/en/messages.json +590 -574
  39. package/locale/en_US/messages.json +590 -574
  40. package/locale/es/messages.json +0 -1
  41. package/locale/fr/messages.json +0 -1
  42. package/locale/it/messages.json +0 -1
  43. package/locale/ja/messages.json +0 -1
  44. package/locale/ko/messages.json +0 -1
  45. package/locale/nb/messages.json +0 -1
  46. package/locale/nl/messages.json +0 -1
  47. package/locale/pl/messages.json +0 -1
  48. package/locale/pt_BR/messages.json +0 -1
  49. package/locale/pt_PT/messages.json +0 -1
  50. package/locale/ru/messages.json +0 -1
  51. package/locale/sv/messages.json +0 -1
  52. package/locale/tr/messages.json +0 -1
  53. package/locale/zh_Hans/messages.json +0 -1
  54. package/package.json +8 -5
  55. package/src/copyright_dialog/templates.ts +35 -31
  56. package/src/dialogs/epub_export.ts +66 -0
  57. package/src/dialogs/html_export.ts +11 -3
  58. package/src/dialogs/index.ts +2 -0
  59. package/src/dialogs/template_export.ts +66 -0
  60. package/src/dialogs/templates.ts +117 -14
  61. package/src/document_template/index.ts +23 -4
  62. package/src/menus/headerbar/model.ts +41 -12
@@ -374,7 +374,6 @@
374
374
  "Portuguese (Brazil)": "Portugués (Brasil)",
375
375
  "Previous": "Anterior",
376
376
  "Print": "Imprimir",
377
- "Print/PDF": "Imprimir PDF",
378
377
  "Proceed to Login page": "Vaya a la página de inicio de sesión",
379
378
  "Proceed to Merge": "Proceder a fusionar",
380
379
  "Read": "Leer",
@@ -374,7 +374,6 @@
374
374
  "Portuguese (Brazil)": "Portugais (Brésil)",
375
375
  "Previous": "précédent",
376
376
  "Print": "Imprimer",
377
- "Print/PDF": "Imprimer/PDF",
378
377
  "Proceed to Login page": "Accédez à la page de connexion",
379
378
  "Proceed to Merge": "Procéder à la fusion",
380
379
  "Read": "Lire",
@@ -374,7 +374,6 @@
374
374
  "Portuguese (Brazil)": "Portoghese (Brasile)",
375
375
  "Previous": "Precedente",
376
376
  "Print": "Stampa",
377
- "Print/PDF": "Stampa/PDF",
378
377
  "Proceed to Login page": "Procedi alla pagina di accesso",
379
378
  "Proceed to Merge": "Procedi all'unione",
380
379
  "Read": "Leggere",
@@ -374,7 +374,6 @@
374
374
  "Portuguese (Brazil)": "ポルトガル語 (ブラジル)",
375
375
  "Previous": "前の",
376
376
  "Print": "印刷",
377
- "Print/PDF": "印刷/PDF",
378
377
  "Proceed to Login page": "ログインページに進む",
379
378
  "Proceed to Merge": "結合に進む",
380
379
  "Read": "閲覧",
@@ -374,7 +374,6 @@
374
374
  "Portuguese (Brazil)": "포르투갈어(브라질)",
375
375
  "Previous": "이전의",
376
376
  "Print": "인쇄",
377
- "Print/PDF": "인쇄/PDF",
378
377
  "Proceed to Login page": "로그인 페이지로 이동",
379
378
  "Proceed to Merge": "병합을 진행하세요",
380
379
  "Read": "읽기",
@@ -374,7 +374,6 @@
374
374
  "Portuguese (Brazil)": "Portugisisk (Brasil)",
375
375
  "Previous": "Tidligere",
376
376
  "Print": "Skriv ut",
377
- "Print/PDF": "Print/PDF",
378
377
  "Proceed to Login page": "Fortsett til påloggingssiden",
379
378
  "Proceed to Merge": "Fortsett til sammenslåing",
380
379
  "Read": "Lese",
@@ -374,7 +374,6 @@
374
374
  "Portuguese (Brazil)": "Portugees (Brazilië)",
375
375
  "Previous": "Vorig",
376
376
  "Print": "Afdrukken",
377
- "Print/PDF": "Afdrukken/PDF",
378
377
  "Proceed to Login page": "Ga verder naar de inlogpagina",
379
378
  "Proceed to Merge": "Ga verder naar Samenvoegen",
380
379
  "Read": "Lezen",
@@ -374,7 +374,6 @@
374
374
  "Portuguese (Brazil)": "portugalski (Brazylia)",
375
375
  "Previous": "Poprzedni",
376
376
  "Print": "Drukuj",
377
- "Print/PDF": "Drukuj/PDF",
378
377
  "Proceed to Login page": "Przejdź do strony logowania",
379
378
  "Proceed to Merge": "Przejdź do Scalania",
380
379
  "Read": "Odczyt",
@@ -374,7 +374,6 @@
374
374
  "Portuguese (Brazil)": "Português (Brasil)",
375
375
  "Previous": "Anterior",
376
376
  "Print": "Imprimir",
377
- "Print/PDF": "Imprimir/PDF",
378
377
  "Proceed to Login page": "Prossiga para a página de login",
379
378
  "Proceed to Merge": "Prossiga para a fusão",
380
379
  "Read": "Ler",
@@ -374,7 +374,6 @@
374
374
  "Portuguese (Brazil)": "Português (Brasil)",
375
375
  "Previous": "Anterior",
376
376
  "Print": "Imprimir",
377
- "Print/PDF": "Imprimir/PDF",
378
377
  "Proceed to Login page": "Prossiga para a página de login",
379
378
  "Proceed to Merge": "Prossiga para mesclar",
380
379
  "Read": "Ler",
@@ -374,7 +374,6 @@
374
374
  "Portuguese (Brazil)": "Португальский (Бразилия)",
375
375
  "Previous": "Предыдущий",
376
376
  "Print": "Распечатать",
377
- "Print/PDF": "Распечатать/PDF",
378
377
  "Proceed to Login page": "Перейдите на страницу входа",
379
378
  "Proceed to Merge": "Перейдите к объединению",
380
379
  "Read": "Читать",
@@ -374,7 +374,6 @@
374
374
  "Portuguese (Brazil)": "portugisiska (Brasilien)",
375
375
  "Previous": "Tidigare",
376
376
  "Print": "Skriva ut",
377
- "Print/PDF": "Skriv ut/PDF",
378
377
  "Proceed to Login page": "Fortsätt till inloggningssidan",
379
378
  "Proceed to Merge": "Fortsätt till Merge",
380
379
  "Read": "Läsa",
@@ -374,7 +374,6 @@
374
374
  "Portuguese (Brazil)": "Portekizce (Brezilya)",
375
375
  "Previous": "Öncesi",
376
376
  "Print": "Yazdır",
377
- "Print/PDF": "Yazdır/PDF",
378
377
  "Proceed to Login page": "Giriş sayfasına ilerleyin",
379
378
  "Proceed to Merge": "Birleştirmeye Devam Et",
380
379
  "Read": "Okumak",
@@ -374,7 +374,6 @@
374
374
  "Portuguese (Brazil)": "葡萄牙语(巴西)",
375
375
  "Previous": "以前的",
376
376
  "Print": "打印",
377
- "Print/PDF": "打印/PDF",
378
377
  "Proceed to Login page": "进入登录页面",
379
378
  "Proceed to Merge": "继续合并",
380
379
  "Read": "读",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fiduswriter/editor",
3
- "version": "0.2.5",
3
+ "version": "0.2.7",
4
4
  "description": "Fidus Writer browser editor",
5
5
  "keywords": [
6
6
  "fiduswriter",
@@ -84,15 +84,17 @@
84
84
  "format": "prettier --write .",
85
85
  "format:check": "prettier --check .",
86
86
  "test": "node --experimental-vm-modules node_modules/jest/bin/jest.js --config jest.config.js && node test/copy-serializer.js && node test/comment-store.js && node test/import-comments.js && node test/contributor-dialog.js",
87
+ "test:e2e": "playwright test",
88
+ "test:e2e:install": "playwright install chromium",
87
89
  "deploy-pages": "./scripts/deploy-pages.sh",
88
90
  "install-hooks": "husky",
89
91
  "demo": "echo 'Open demo/editor/index.html or run: npx http-server .pages-build -p 8080 -c-1'",
90
92
  "testserver": "node scripts/serve-demo.js"
91
93
  },
92
94
  "dependencies": {
93
- "@fiduswriter/bibliography-manager": "^0.1.31",
94
- "@fiduswriter/document": "^0.3.3",
95
- "@fiduswriter/image-manager": "^0.1.23",
95
+ "@fiduswriter/bibliography-manager": "^0.1.32",
96
+ "@fiduswriter/document": "^0.3.11",
97
+ "@fiduswriter/image-manager": "^0.1.24",
96
98
  "@fortawesome/fontawesome-free": "^7.2.0",
97
99
  "cropperjs": "^1.6.2",
98
100
  "diff": "^5.0.0",
@@ -102,7 +104,7 @@
102
104
  "fast-xml-parser": "^4.5.0",
103
105
  "fastdom": "^1.0.11",
104
106
  "fix-utf8": "^2.0.1",
105
- "fwtoolkit": "^0.2.14",
107
+ "fwtoolkit": "^0.2.18",
106
108
  "jszip": "^3.10.1",
107
109
  "mathml-to-latex": "^1.4.3",
108
110
  "mathml2omml": "^0.5.0",
@@ -132,6 +134,7 @@
132
134
  "@eslint/js": "^10.0.1",
133
135
  "@fontsource/jetbrains-mono": "^5.3.0",
134
136
  "@fontsource/source-sans-pro": "^5.3.0",
137
+ "@playwright/test": "^1.49.0",
135
138
  "@swc/core": "^1.16.1",
136
139
  "@swc/jest": "^0.2.39",
137
140
  "@types/jest": "^30.0.0",
@@ -1,4 +1,4 @@
1
- import {escapeText} from "fwtoolkit"
1
+ import {escapeText, InfoRow} from "fwtoolkit"
2
2
  import {LICENSE_URLS} from "./index.js"
3
3
 
4
4
  interface LicenseSelectParams {
@@ -34,38 +34,42 @@ export const licenseInputTemplate = ({url, title}: LicenseInputParams) =>
34
34
  <input type='text' class='license-title' value="${escapeText(title)}" placeholder="${gettext("License Title")}">
35
35
  </div>`
36
36
 
37
+ const copyrightRow = (
38
+ label: string,
39
+ helpText: string,
40
+ field: string,
41
+ fieldClass = ""
42
+ ): string =>
43
+ new InfoRow({
44
+ label,
45
+ helpText,
46
+ field,
47
+ fieldClass
48
+ }).html()
49
+
37
50
  export const copyrightTemplate = ({holder, year, freeToRead}: CopyrightParams) =>
38
51
  `<table class="fw-dialog-table">
39
52
  <tbody>
40
- <tr>
41
- <th><h4 class="fw-tablerow-title fw-wtooltip">
42
- ${gettext("Copyright holder")}
43
- <span class="fw-tooltip">${gettext("If the work is not in the public domain, specify who the copyright holder is.")}</span>
44
- </h4></th>
45
- <td class="fw-entry-field"><input type="text" class="holder" value="${holder ? escapeText(holder) : ""}"></td>
46
- </tr>
47
- <tr>
48
- <th><h4 class="fw-tablerow-title fw-wtooltip">
49
- ${gettext("Copyright year")}
50
- <span class="fw-tooltip">${gettext("If the work is not in the public domain, specify the year of the copyright.")}</span>
51
- </h4></th>
52
- <td class="fw-entry-field"><input type="number" class="year" min=0 max=2100 value="${year ? year : ""}"></td>
53
- </tr>
54
- <tr>
55
- <th><h4 class="fw-tablerow-title fw-wtooltip">
56
- ${gettext("Available to read for free?")}
57
- <span class="fw-tooltip">${gettext("Specify whether the work can be accessed without paying a fee.")}</span>
58
- </h4></th>
59
- <td class="fw-entry-field"><input type="checkbox" class="free-to-read"${freeToRead ? " checked" : ""}></td>
60
- </tr>
61
- <tr>
62
- <th><h4 class="fw-tablerow-title fw-wtooltip">
63
- ${gettext("License(s)")}
64
- <span class="fw-tooltip">${gettext('List any licenses the work is available under. If the license only applies from a given date, please specify the date in the ISO8601 format (such as "2012-10-15").')}</span>
65
- </h4></th>
66
- <td class="fw-entry-field licenses">
67
- <div class="copyright-licenses-list"></div>
68
- </td>
69
- </tr>
53
+ ${copyrightRow(
54
+ gettext("Copyright holder"),
55
+ gettext("If the work is not in the public domain, specify who the copyright holder is."),
56
+ `<input type="text" class="holder" value="${holder ? escapeText(holder) : ""}">`
57
+ )}
58
+ ${copyrightRow(
59
+ gettext("Copyright year"),
60
+ gettext("If the work is not in the public domain, specify the year of the copyright."),
61
+ `<input type="number" class="year" min=0 max=2100 value="${year ? year : ""}">`
62
+ )}
63
+ ${copyrightRow(
64
+ gettext("Available to read for free?"),
65
+ gettext("Specify whether the work can be accessed without paying a fee."),
66
+ `<input type="checkbox" class="free-to-read"${freeToRead ? " checked" : ""}>`
67
+ )}
68
+ ${copyrightRow(
69
+ gettext("License(s)"),
70
+ gettext('List any licenses the work is available under. If the license only applies from a given date, please specify the date in the ISO8601 format (such as "2012-10-15").'),
71
+ `<div class="copyright-licenses-list"></div>`,
72
+ "licenses"
73
+ )}
70
74
  </tbody>
71
75
  </table>`
@@ -0,0 +1,66 @@
1
+ import {Dialog} from "fwtoolkit"
2
+ import {epubExportDialogTemplate, getExportTrackChangesValue} from "./templates.js"
3
+
4
+ export interface EpubExportDialogResult {
5
+ /** Render `equation`/`figure_equation` nodes as SVG images (MathJax)
6
+ instead of MathML. */
7
+ svgMath: boolean
8
+ /** Resolve all tracked changes (accept all) before exporting. When false,
9
+ the tracked changes are kept and rendered in the export. */
10
+ resolveTrackChanges: boolean
11
+ }
12
+
13
+ export class EpubExportDialog {
14
+ dialog: Dialog | false
15
+
16
+ constructor() {
17
+ this.dialog = false
18
+ }
19
+
20
+ init(): Promise<EpubExportDialogResult | false> {
21
+ const buttons: Array<Record<string, unknown>> = []
22
+ const dialogDonePromise = new Promise<EpubExportDialogResult | false>(
23
+ resolve => {
24
+ buttons.push({
25
+ text: gettext("Export"),
26
+ classes: "fw-dark",
27
+ click: () => {
28
+ const dialogEl = (this.dialog as Dialog).dialogEl
29
+ const svgMath = (
30
+ dialogEl.querySelector(
31
+ ".epub-svg-math"
32
+ ) as HTMLInputElement
33
+ )?.checked
34
+ const resolveTrackChanges =
35
+ getExportTrackChangesValue(
36
+ dialogEl,
37
+ "epub-track-changes"
38
+ ) !== "include"
39
+ ;(this.dialog as Dialog).close()
40
+ return resolve({svgMath: !!svgMath, resolveTrackChanges})
41
+ }
42
+ })
43
+
44
+ buttons.push({
45
+ type: "cancel" as const,
46
+ click: () => {
47
+ ;(this.dialog as Dialog).close()
48
+ resolve(false)
49
+ }
50
+ })
51
+ }
52
+ )
53
+
54
+ this.dialog = new Dialog({
55
+ title: gettext("EPUB export options"),
56
+ body: epubExportDialogTemplate(),
57
+ height: 330,
58
+ width: 420,
59
+ buttons,
60
+ restoreActiveElement: false
61
+ })
62
+ this.dialog.open()
63
+
64
+ return dialogDonePromise
65
+ }
66
+ }
@@ -1,10 +1,13 @@
1
1
  import {Dialog} from "fwtoolkit"
2
- import {htmlExportDialogTemplate} from "./templates.js"
2
+ import {getExportTrackChangesValue, htmlExportDialogTemplate} from "./templates.js"
3
3
 
4
4
  export interface HtmlExportDialogResult {
5
5
  /** Render `equation`/`figure_equation` nodes as SVG images (MathJax)
6
6
  instead of MathML. */
7
7
  svgMath: boolean
8
+ /** Resolve all tracked changes (accept all) before exporting. When false,
9
+ the tracked changes are kept and rendered in the export. */
10
+ resolveTrackChanges: boolean
8
11
  }
9
12
 
10
13
  export class HtmlExportDialog {
@@ -28,8 +31,13 @@ export class HtmlExportDialog {
28
31
  ".html-svg-math"
29
32
  ) as HTMLInputElement
30
33
  )?.checked
34
+ const resolveTrackChanges =
35
+ getExportTrackChangesValue(
36
+ dialogEl,
37
+ "html-track-changes"
38
+ ) !== "include"
31
39
  ;(this.dialog as Dialog).close()
32
- return resolve({svgMath: !!svgMath})
40
+ return resolve({svgMath: !!svgMath, resolveTrackChanges})
33
41
  }
34
42
  })
35
43
 
@@ -46,7 +54,7 @@ export class HtmlExportDialog {
46
54
  this.dialog = new Dialog({
47
55
  title: gettext("HTML export options"),
48
56
  body: htmlExportDialogTemplate(),
49
- height: 220,
57
+ height: 330,
50
58
  width: 420,
51
59
  buttons,
52
60
  restoreActiveElement: false
@@ -8,5 +8,7 @@ export {TableDialog, TableConfigurationDialog} from "./table.js"
8
8
  export {RevisionDialog} from "./revision.js"
9
9
  export {PdfExportDialog} from "./pdf_export.js"
10
10
  export {HtmlExportDialog} from "./html_export.js"
11
+ export {EpubExportDialog} from "./epub_export.js"
12
+ export {TemplateExportDialog} from "./template_export.js"
11
13
  export {OrderedListStartDialog} from "./ordered_list.js"
12
14
  export {CodeBlockDialog} from "./code_block.js"
@@ -0,0 +1,66 @@
1
+ import {Dialog} from "fwtoolkit"
2
+ import {
3
+ exportTrackChangesTemplate,
4
+ getExportTrackChangesValue
5
+ } from "./templates.js"
6
+
7
+ export interface TemplateExportDialogResult {
8
+ /** Resolve all tracked changes (accept all) before exporting. When false,
9
+ the tracked changes are kept and rendered in the exported file. */
10
+ resolveTrackChanges: boolean
11
+ }
12
+
13
+ /** Ask how tracked changes should be handled before a DOCX/ODT template export. */
14
+ export class TemplateExportDialog {
15
+ dialog: Dialog | false
16
+
17
+ constructor() {
18
+ this.dialog = false
19
+ }
20
+
21
+ init(fileType: "docx" | "odt"): Promise<TemplateExportDialogResult | false> {
22
+ const title =
23
+ fileType === "docx"
24
+ ? gettext("DOCX export options")
25
+ : gettext("ODT export options")
26
+ const buttons: Array<Record<string, unknown>> = []
27
+ const dialogDonePromise = new Promise<TemplateExportDialogResult | false>(
28
+ resolve => {
29
+ buttons.push({
30
+ text: gettext("Export"),
31
+ classes: "fw-dark",
32
+ click: () => {
33
+ const dialogEl = (this.dialog as Dialog).dialogEl
34
+ const resolveTrackChanges =
35
+ getExportTrackChangesValue(
36
+ dialogEl,
37
+ "template-track-changes"
38
+ ) !== "include"
39
+ ;(this.dialog as Dialog).close()
40
+ return resolve({resolveTrackChanges})
41
+ }
42
+ })
43
+
44
+ buttons.push({
45
+ type: "cancel" as const,
46
+ click: () => {
47
+ ;(this.dialog as Dialog).close()
48
+ resolve(false)
49
+ }
50
+ })
51
+ }
52
+ )
53
+
54
+ this.dialog = new Dialog({
55
+ title,
56
+ body: exportTrackChangesTemplate("template-track-changes"),
57
+ height: 220,
58
+ width: 420,
59
+ buttons,
60
+ restoreActiveElement: false
61
+ })
62
+ this.dialog.open()
63
+
64
+ return dialogDonePromise
65
+ }
66
+ }
@@ -1,5 +1,5 @@
1
1
  import {CATS} from "@fiduswriter/document/schema/i18n"
2
- import {escapeText} from "fwtoolkit"
2
+ import {escapeText, infoTooltip} from "fwtoolkit"
3
3
 
4
4
  interface InternalTarget {
5
5
  id: string
@@ -96,40 +96,143 @@ export const revisionDialogTemplate = ({dir}: {dir: string}): string =>
96
96
  export const pdfExportDialogTemplate = (): string => `
97
97
  <h4>${gettext("Tracked changes")}</h4>
98
98
  <div class="fw-radio">
99
- <input type="radio" name="pdf-track-changes" value="resolve" class="pdf-track-resolve" checked="">
99
+ <input type="radio" name="pdf-track-changes" value="resolve" class="pdf-track-resolve" checked="" aria-describedby="pdf-track-resolve-help">
100
100
  <label class="pdf-track-resolve-label">${gettext("Resolve tracked changes (accept all)")}</label>
101
+ ${infoTooltip(
102
+ gettext(
103
+ "Applies all tracked changes so the PDF shows the document as if every change had already been accepted."
104
+ ),
105
+ "pdf-track-resolve-help"
106
+ )}
101
107
  </div>
102
108
  <div class="fw-radio">
103
- <input type="radio" name="pdf-track-changes" value="include" class="pdf-track-include">
109
+ <input type="radio" name="pdf-track-changes" value="include" class="pdf-track-include" aria-describedby="pdf-track-include-help">
104
110
  <label class="pdf-track-include-label">${gettext("Include tracked changes in the PDF")}</label>
111
+ ${infoTooltip(
112
+ gettext(
113
+ "Prints the tracked changes so reviewers can see what was added, removed or altered."
114
+ ),
115
+ "pdf-track-include-help"
116
+ )}
105
117
  </div>
106
118
  <p>
107
119
  <label>
108
- <input type="checkbox" class="pdf-embed-fidus">
120
+ <input type="checkbox" class="pdf-embed-fidus" aria-describedby="pdf-embed-fidus-help">
109
121
  ${gettext("Embed a Fidus Writer file of this document in the PDF")}
110
122
  </label>
123
+ ${infoTooltip(
124
+ gettext(
125
+ "Embeds the editable Fidus Writer document inside the PDF so it can be reopened for editing."
126
+ ),
127
+ "pdf-embed-fidus-help"
128
+ )}
111
129
  </p>
112
130
  <h4>${gettext("Print production")}</h4>
113
131
  <p>
114
- <label><input type="checkbox" class="pdf-crop-marks"> ${gettext("Crop marks")}</label><br>
115
- <label><input type="checkbox" class="pdf-trim-box"> ${gettext("Trim box")}</label><br>
116
- <label><input type="checkbox" class="pdf-bleed-box"> ${gettext("Bleed box")}</label><br>
117
- <label>${gettext("Bleed")}: <input type="number" class="pdf-bleed-mm" value="3" min="0" step="0.5"> ${gettext("mm")}</label><br>
118
- <label><input type="checkbox" class="pdf-link-borders"> ${gettext("Show link annotation borders")}</label><br>
119
- <label><input type="checkbox" class="pdf-rasterize-svgs"> ${gettext("Rasterize SVG images")}</label>
132
+ <label><input type="checkbox" class="pdf-crop-marks" aria-describedby="pdf-crop-marks-help"> ${gettext("Crop marks")}</label>
133
+ ${infoTooltip(
134
+ gettext("Small lines at the corners of the page that show printers where to cut the paper."),
135
+ "pdf-crop-marks-help"
136
+ )}<br>
137
+ <label><input type="checkbox" class="pdf-trim-box" aria-describedby="pdf-trim-box-help"> ${gettext("Trim box")}</label>
138
+ ${infoTooltip(
139
+ gettext("Marks the final size of the page after it has been cut."),
140
+ "pdf-trim-box-help"
141
+ )}<br>
142
+ <label><input type="checkbox" class="pdf-bleed-box" aria-describedby="pdf-bleed-box-help"> ${gettext("Bleed box")}</label>
143
+ ${infoTooltip(
144
+ gettext("Marks the area beyond the final page size where images and colors must extend so no white edges appear after cutting."),
145
+ "pdf-bleed-box-help"
146
+ )}<br>
147
+ <label>${gettext("Bleed")}: <input type="number" class="pdf-bleed-mm" value="3" min="0" step="0.5" aria-describedby="pdf-bleed-mm-help"> ${gettext("mm")}</label>
148
+ ${infoTooltip(
149
+ gettext("How far, in millimeters, images and colors extend beyond the edge of the page."),
150
+ "pdf-bleed-mm-help"
151
+ )}<br>
152
+ <label><input type="checkbox" class="pdf-link-borders" aria-describedby="pdf-link-borders-help"> ${gettext("Show link annotation borders")}</label>
153
+ ${infoTooltip(
154
+ gettext("Draws a visible border around hyperlinks in the PDF so they are easier to find."),
155
+ "pdf-link-borders-help"
156
+ )}<br>
157
+ <label><input type="checkbox" class="pdf-rasterize-svgs" aria-describedby="pdf-rasterize-svgs-help"> ${gettext("Rasterize SVG images")}</label>
158
+ ${infoTooltip(
159
+ gettext("Converts SVG images to bitmap images in the PDF, which can help when PDF viewers or printers do not render SVG images correctly."),
160
+ "pdf-rasterize-svgs-help"
161
+ )}
120
162
  </p>
121
163
  `
122
164
 
165
+ /**
166
+ * Radio group for choosing whether tracked changes are resolved (accepted) or
167
+ * kept in the exported file. `name` must be unique per dialog; the chosen value
168
+ * is read back with {@link getExportTrackChangesValue}.
169
+ */
170
+ export const exportTrackChangesTemplate = (name: string): string => `
171
+ <h4>${gettext("Tracked changes")}</h4>
172
+ <div class="fw-radio">
173
+ <input type="radio" name="${name}" value="resolve" class="export-track-resolve" checked="" aria-describedby="${name}-resolve-help">
174
+ <label class="export-track-resolve-label">${gettext("Resolve tracked changes (accept all)")}</label>
175
+ ${infoTooltip(
176
+ gettext(
177
+ "Applies all tracked changes so the exported file shows the document as if every change had already been accepted."
178
+ ),
179
+ `${name}-resolve-help`
180
+ )}
181
+ </div>
182
+ <div class="fw-radio">
183
+ <input type="radio" name="${name}" value="include" class="export-track-include" aria-describedby="${name}-include-help">
184
+ <label class="export-track-include-label">${gettext("Include tracked changes in the export")}</label>
185
+ ${infoTooltip(
186
+ gettext(
187
+ "Keeps the tracked changes so reviewers can see what was added, removed or altered."
188
+ ),
189
+ `${name}-include-help`
190
+ )}
191
+ </div>
192
+ `
193
+
194
+ /** Read the tracked-changes radio group value ("resolve" or "include"). */
195
+ export const getExportTrackChangesValue = (
196
+ dialogEl: Element,
197
+ name: string
198
+ ): string => {
199
+ return (
200
+ dialogEl.querySelector(
201
+ `input[name="${name}"]:checked`
202
+ ) as HTMLInputElement | null
203
+ )?.value || "resolve"
204
+ }
205
+
123
206
  export const htmlExportDialogTemplate = (): string => `
207
+ ${exportTrackChangesTemplate("html-track-changes")}
208
+ <p>
209
+ <label>
210
+ <input type="checkbox" class="html-svg-math" aria-describedby="html-svg-math-help">
211
+ ${gettext("Render formulas as SVG images instead of MathML")}
212
+ </label>
213
+ ${infoTooltip(
214
+ gettext(
215
+ "SVG renders consistently across browsers; MathML keeps formulas as text that can be searched and copied, but only newer browsers support it."
216
+ ),
217
+ "html-svg-math-help"
218
+ )}
219
+ </p>
220
+ `
221
+
222
+ export const epubExportDialogTemplate = (): string => `
223
+ ${exportTrackChangesTemplate("epub-track-changes")}
124
224
  <p>
125
225
  <label>
126
- <input type="checkbox" class="html-svg-math">
226
+ <input type="checkbox" class="epub-svg-math" aria-describedby="epub-svg-math-help">
127
227
  ${gettext("Render formulas as SVG images instead of MathML")}
128
228
  </label>
229
+ ${infoTooltip(
230
+ gettext(
231
+ "SVG renders consistently across browsers; MathML keeps formulas as text that can be searched and copied, but only newer browsers support it."
232
+ ),
233
+ "epub-svg-math-help"
234
+ )}
129
235
  </p>
130
- <p class="formula-note">${gettext(
131
- "SVG renders consistently across browsers and is used in PDF export; MathML keeps formulas as text that can be searched and copied, but only newer browsers support it."
132
- )}</p>
133
236
  `
134
237
 
135
238
  export const tableInsertTemplate = (): string => `
@@ -14,6 +14,7 @@ import {
14
14
 
15
15
  import type {Editor} from "../types.js"
16
16
  import {SaveCopy} from "../exporter/native/index.js"
17
+ import {TemplateExportDialog} from "../dialogs/index.js"
17
18
 
18
19
  export {serializeHelp} from "./schema.js"
19
20
 
@@ -388,8 +389,17 @@ export class ModDocumentTemplate {
388
389
  action: (editor: Editor) => {
389
390
  import(
390
391
  "@fiduswriter/document/exporter/docx/index"
391
- ).then(({DOCXExporter}: any) => {
392
- const doc = editor.getDoc() as any
392
+ ).then(async ({DOCXExporter}: any) => {
393
+ const dialog = new TemplateExportDialog()
394
+ const options = await dialog.init("docx")
395
+ if (!options) {
396
+ return
397
+ }
398
+ const doc = editor.getDoc({
399
+ changes: options.resolveTrackChanges
400
+ ? "acceptAllNoInsertions"
401
+ : undefined
402
+ }) as any
393
403
  const title = shortFileTitle(
394
404
  doc.title,
395
405
  doc.path || ""
@@ -426,8 +436,17 @@ export class ModDocumentTemplate {
426
436
  ),
427
437
  action: (editor: Editor) => {
428
438
  import("@fiduswriter/document/exporter/odt/index").then(
429
- ({ODTExporter}: any) => {
430
- const doc = editor.getDoc() as any
439
+ async ({ODTExporter}: any) => {
440
+ const dialog = new TemplateExportDialog()
441
+ const options = await dialog.init("odt")
442
+ if (!options) {
443
+ return
444
+ }
445
+ const doc = editor.getDoc({
446
+ changes: options.resolveTrackChanges
447
+ ? "acceptAllNoInsertions"
448
+ : undefined
449
+ }) as any
431
450
  const title = shortFileTitle(
432
451
  doc.title,
433
452
  doc.path || ""