@fiduswriter/books-document 0.1.24 → 0.1.25
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.
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Print book exporter.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* Renders the book in the browser using the selected pagination engine (see
|
|
5
|
+
* `@fiduswriter/document/exporter/print`).
|
|
5
6
|
*/
|
|
6
7
|
import type { Schema } from "prosemirror-model";
|
|
7
8
|
import type { CSL, User } from "@fiduswriter/document";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/exporter/print/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/exporter/print/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,mBAAmB,CAAA;AAC7C,OAAO,KAAK,EAAC,GAAG,EAAE,IAAI,EAAC,MAAM,uBAAuB,CAAA;AAGpD,OAAO,KAAK,EAAC,IAAI,EAAE,UAAU,EAAE,iBAAiB,EAAC,MAAM,gBAAgB,CAAA;AACvE,OAAO,EAAC,gBAAgB,EAAC,MAAM,kBAAkB,CAAA;AAGjD,qBAAa,iBAAkB,SAAQ,gBAAgB;IACnD,YACI,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,GAAG,EACR,cAAc,EAAE,UAAU,EAC1B,IAAI,EAAE,IAAI,EACV,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,iBAAiB,EAAE,EAM/B;IAED,YAAY,IAAI,OAAO,CAkBtB;IAEK,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC,CAY/B;IAEK,SAAS,CAAC,KAAK,EAAE;QACnB,GAAG,CAAC,EAAE,MAAM,CAAA;QACZ,QAAQ,CAAC,EAAE,MAAM,CAAA;QACjB,QAAQ,CAAC,EAAE,MAAM,CAAA;KACpB,GAAG,OAAO,CAAC;QAAC,GAAG,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAC,CAAC,CAMhE;CACJ"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Print book exporter.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* Renders the book in the browser using the selected pagination engine (see
|
|
5
|
+
* `@fiduswriter/document/exporter/print`).
|
|
5
6
|
*/
|
|
6
|
-
import {
|
|
7
|
+
import { getPrintEngine } from "@fiduswriter/document/exporter/print/index";
|
|
7
8
|
import { HTMLBookExporter } from "../html/index.js";
|
|
8
9
|
import { chapterTemplate } from "./templates.js";
|
|
9
10
|
export class PrintBookExporter extends HTMLBookExporter {
|
|
@@ -28,28 +29,11 @@ export class PrintBookExporter extends HTMLBookExporter {
|
|
|
28
29
|
if (!htmlDoc) {
|
|
29
30
|
return;
|
|
30
31
|
}
|
|
31
|
-
const
|
|
32
|
-
|
|
32
|
+
const engine = getPrintEngine();
|
|
33
|
+
window.printInstance = {
|
|
34
|
+
engine: engine.name
|
|
33
35
|
};
|
|
34
|
-
|
|
35
|
-
config.printCallback = (iframeWin) => {
|
|
36
|
-
const oldBody = document.body;
|
|
37
|
-
document.body.parentElement.dataset.vivliostylePaginated =
|
|
38
|
-
"true";
|
|
39
|
-
document.body = iframeWin.document.body;
|
|
40
|
-
iframeWin.document
|
|
41
|
-
.querySelectorAll("style")
|
|
42
|
-
.forEach(el => document.body.appendChild(el));
|
|
43
|
-
const backgroundStyle = document.createElement("style");
|
|
44
|
-
backgroundStyle.innerHTML = "body {background-color: white;}";
|
|
45
|
-
document.body.appendChild(backgroundStyle);
|
|
46
|
-
window.print();
|
|
47
|
-
document.body = oldBody;
|
|
48
|
-
delete document.body.parentElement.dataset
|
|
49
|
-
.vivliostylePaginated;
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
printHTML(htmlDoc, config);
|
|
36
|
+
await engine.print({ html: htmlDoc, title: this.book.title });
|
|
53
37
|
}
|
|
54
38
|
async loadStyle(sheet) {
|
|
55
39
|
if (sheet.url) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/exporter/print/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/exporter/print/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EAAC,cAAc,EAAC,MAAM,4CAA4C,CAAA;AAGzE,OAAO,EAAC,gBAAgB,EAAC,MAAM,kBAAkB,CAAA;AACjD,OAAO,EAAC,eAAe,EAAC,MAAM,gBAAgB,CAAA;AAE9C,MAAM,OAAO,iBAAkB,SAAQ,gBAAgB;IACnD,YACI,MAAc,EACd,GAAQ,EACR,cAA0B,EAC1B,IAAU,EACV,IAAU,EACV,OAA4B;QAE5B,KAAK,CAAC,MAAM,EAAE,GAAG,EAAE,cAAc,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,EAAE,KAAK,EAAE;YAC9D,YAAY,EAAE,KAAK;SACtB,CAAC,CAAA;QACF,IAAI,CAAC,eAAe,GAAG,eAAe,CAAA;IAC1C,CAAC;IAED,YAAY;QACR,MAAM,SAAS,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,CAClC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,UAAU,CACxD,CAAA;QACD,IAAI,CAAC,SAAS,EAAE,CAAC;YACb,OAAO,KAAK,CAAA;QAChB,CAAC;QACD,IAAI,QAAQ,GAAG,SAAS,CAAC,QAAQ,CAAA;QACjC,SAAS,CAAC,iBAAiB,CAAC,OAAO,CAC/B,CAAC,CAAC,GAAG,EAAE,QAAQ,CAAmB,EAAE,EAAE,CAClC,CAAC,QAAQ,GAAG,QAAQ,CAAC,OAAO,CACxB,IAAI,MAAM,CAAC,QAAQ,EAAE,GAAG,CAAC,EACzB,GAAG,CACN,CAAC,CACT,CAAA;QAED,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,EAAC,QAAQ,EAAC,CAAC,CAAA;QACjC,OAAO,IAAI,CAAA;IACf,CAAC;IAED,KAAK,CAAC,SAAS;QACX,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAC/B,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,QAAQ,KAAK,YAAY,CACzC,EAAE,QAAQ,CAAA;QACX,IAAI,CAAC,OAAO,EAAE,CAAC;YACX,OAAM;QACV,CAAC;QACD,MAAM,MAAM,GAAG,cAAc,EAAE,CAC9B;QAAC,MAA+C,CAAC,aAAa,GAAG;YAC9D,MAAM,EAAE,MAAM,CAAC,IAAI;SACtB,CAAA;QACD,MAAM,MAAM,CAAC,KAAK,CAAC,EAAC,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,IAAI,CAAC,KAAK,EAAC,CAAC,CAAA;IAC/D,CAAC;IAED,KAAK,CAAC,SAAS,CAAC,KAIf;QACG,IAAI,KAAK,CAAC,GAAG,EAAE,CAAC;YACZ,KAAK,CAAC,QAAQ,GAAG,KAAK,CAAC,GAAG,CAAA;YAC1B,OAAO,KAAK,CAAC,GAAG,CAAA;QACpB,CAAC;QACD,OAAO,KAAK,CAAA;IAChB,CAAC;CACJ"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fiduswriter/books-document",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.25",
|
|
4
4
|
"description": "Fidus Writer book importers and exporters",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"fiduswriter",
|
|
@@ -109,12 +109,11 @@
|
|
|
109
109
|
"extract-i18n": "node scripts/extract-i18n.js"
|
|
110
110
|
},
|
|
111
111
|
"dependencies": {
|
|
112
|
-
"@fiduswriter/document": "^0.3.
|
|
113
|
-
"@vivliostyle/print": "^2.44.1",
|
|
112
|
+
"@fiduswriter/document": "^0.3.17",
|
|
114
113
|
"bibliojson": "^4.0.4",
|
|
115
114
|
"downloadjs": "^1.4.7",
|
|
116
115
|
"fast-deep-equal": "^3.1.3",
|
|
117
|
-
"fwtoolkit": "^0.2.
|
|
116
|
+
"fwtoolkit": "^0.2.26",
|
|
118
117
|
"jszip": "^3.10.1",
|
|
119
118
|
"pretty": "^2.0.0"
|
|
120
119
|
},
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Print book exporter.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* Renders the book in the browser using the selected pagination engine (see
|
|
5
|
+
* `@fiduswriter/document/exporter/print`).
|
|
5
6
|
*/
|
|
6
7
|
|
|
7
8
|
import type {Schema} from "prosemirror-model"
|
|
8
9
|
import type {CSL, User} from "@fiduswriter/document"
|
|
9
|
-
import {
|
|
10
|
+
import {getPrintEngine} from "@fiduswriter/document/exporter/print/index"
|
|
10
11
|
|
|
11
12
|
import type {Book, BookStyles, DocumentListEntry} from "../../types.js"
|
|
12
13
|
import {HTMLBookExporter} from "../html/index.js"
|
|
@@ -54,30 +55,11 @@ export class PrintBookExporter extends HTMLBookExporter {
|
|
|
54
55
|
if (!htmlDoc) {
|
|
55
56
|
return
|
|
56
57
|
}
|
|
57
|
-
const
|
|
58
|
-
|
|
58
|
+
const engine = getPrintEngine()
|
|
59
|
+
;(window as unknown as {printInstance?: unknown}).printInstance = {
|
|
60
|
+
engine: engine.name
|
|
59
61
|
}
|
|
60
|
-
|
|
61
|
-
if (navigator.userAgent.includes("Gecko/")) {
|
|
62
|
-
config.printCallback = (iframeWin: Window) => {
|
|
63
|
-
const oldBody = document.body
|
|
64
|
-
document.body.parentElement!.dataset.vivliostylePaginated =
|
|
65
|
-
"true"
|
|
66
|
-
document.body = iframeWin.document.body
|
|
67
|
-
iframeWin.document
|
|
68
|
-
.querySelectorAll("style")
|
|
69
|
-
.forEach(el => document.body.appendChild(el))
|
|
70
|
-
const backgroundStyle = document.createElement("style")
|
|
71
|
-
backgroundStyle.innerHTML = "body {background-color: white;}"
|
|
72
|
-
document.body.appendChild(backgroundStyle)
|
|
73
|
-
window.print()
|
|
74
|
-
document.body = oldBody
|
|
75
|
-
delete document.body.parentElement!.dataset
|
|
76
|
-
.vivliostylePaginated
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
printHTML(htmlDoc, config)
|
|
62
|
+
await engine.print({html: htmlDoc, title: this.book.title})
|
|
81
63
|
}
|
|
82
64
|
|
|
83
65
|
async loadStyle(sheet: {
|
package/src/modules.d.ts
CHANGED