@folijs/view 0.4.0 → 0.6.0
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.
- package/CHANGELOG.md +59 -0
- package/dist/clipboard.d.ts +3 -1
- package/dist/clipboard.d.ts.map +1 -1
- package/dist/clipboard.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/layout/flow.d.ts +195 -20
- package/dist/layout/flow.d.ts.map +1 -1
- package/dist/layout/flow.js +790 -102
- package/dist/layout/flow.js.map +1 -1
- package/dist/print.d.ts +22 -0
- package/dist/print.d.ts.map +1 -0
- package/dist/print.js +31 -0
- package/dist/print.js.map +1 -0
- package/dist/view.d.ts +407 -8
- package/dist/view.d.ts.map +1 -1
- package/dist/view.js +2956 -263
- package/dist/view.js.map +1 -1
- package/dist/word/blocks.d.ts +99 -2
- package/dist/word/blocks.d.ts.map +1 -1
- package/dist/word/blocks.js +535 -31
- package/dist/word/blocks.js.map +1 -1
- package/dist/word/columns.d.ts +23 -0
- package/dist/word/columns.d.ts.map +1 -0
- package/dist/word/columns.js +51 -0
- package/dist/word/columns.js.map +1 -0
- package/dist/word/controls.d.ts +63 -0
- package/dist/word/controls.d.ts.map +1 -0
- package/dist/word/controls.js +411 -0
- package/dist/word/controls.js.map +1 -0
- package/dist/word/edit.d.ts +32 -11
- package/dist/word/edit.d.ts.map +1 -1
- package/dist/word/edit.js +215 -33
- package/dist/word/edit.js.map +1 -1
- package/dist/word/matches.d.ts +23 -0
- package/dist/word/matches.d.ts.map +1 -0
- package/dist/word/matches.js +97 -0
- package/dist/word/matches.js.map +1 -0
- package/dist/word/notes.d.ts +105 -0
- package/dist/word/notes.d.ts.map +1 -0
- package/dist/word/notes.js +392 -0
- package/dist/word/notes.js.map +1 -0
- package/dist/word/pages.d.ts +26 -13
- package/dist/word/pages.d.ts.map +1 -1
- package/dist/word/pages.js +439 -203
- package/dist/word/pages.js.map +1 -1
- package/dist/word/regions.d.ts +113 -0
- package/dist/word/regions.d.ts.map +1 -0
- package/dist/word/regions.js +374 -0
- package/dist/word/regions.js.map +1 -0
- package/dist/word/table.d.ts +79 -0
- package/dist/word/table.d.ts.map +1 -0
- package/dist/word/table.js +210 -0
- package/dist/word/table.js.map +1 -0
- package/package.json +2 -2
- package/src/clipboard.ts +3 -0
- package/src/index.ts +8 -1
- package/src/layout/flow.ts +948 -111
- package/src/print.ts +48 -0
- package/src/view.ts +3291 -273
- package/src/word/blocks.ts +611 -28
- package/src/word/columns.ts +66 -0
- package/src/word/controls.ts +447 -0
- package/src/word/edit.ts +253 -30
- package/src/word/matches.ts +99 -0
- package/src/word/notes.ts +451 -0
- package/src/word/pages.ts +524 -192
- package/src/word/regions.ts +469 -0
- package/src/word/table.ts +267 -0
package/src/print.ts
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Print rules shared by the editor's pages and the read-only renderer's (`renderDocument`), so
|
|
3
|
+
* that the editor's `print()` and `@folijs/pdf`'s `exportPdf` print pages the same way (11.12).
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/** The attribute naming a page's page setup (its index among the document's) for print. */
|
|
7
|
+
export const SHEET_ATTR = "data-foli-sheet";
|
|
8
|
+
|
|
9
|
+
/** A page setup as print sees it: its sheet's size (CSS lengths) and its `SHEET_ATTR` value. */
|
|
10
|
+
export interface PrintSheet {
|
|
11
|
+
readonly width: string;
|
|
12
|
+
readonly height: string;
|
|
13
|
+
readonly index: number;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Print rules for the page elements `pages` selects: one sheet of its page setup's size per page
|
|
18
|
+
* (`last`'s, the document's last section, where named pages are not supported), without margins
|
|
19
|
+
* (the page's padding holds them). A page is exactly as tall as a sheet (the flow keeps content
|
|
20
|
+
* inside it; the exact height absorbs its half-pixel slack), with no gap after it. Content taller
|
|
21
|
+
* than a page (a line taller than a page) is not cut: it prints over the next sheet. `name` makes
|
|
22
|
+
* the named pages unique on the web page.
|
|
23
|
+
*/
|
|
24
|
+
export function printStyles(
|
|
25
|
+
pages: string,
|
|
26
|
+
last: Pick<PrintSheet, "width" | "height">,
|
|
27
|
+
sheets: readonly PrintSheet[],
|
|
28
|
+
name: string,
|
|
29
|
+
): string {
|
|
30
|
+
// Sections with other page sizes: a named page each (engines without named pages print
|
|
31
|
+
// every sheet at the last section's size).
|
|
32
|
+
const named = sheets.every((s) => s.width === last.width && s.height === last.height)
|
|
33
|
+
? ""
|
|
34
|
+
: sheets
|
|
35
|
+
.map(({ width, height, index }) => {
|
|
36
|
+
const page = `foli-${name}-${index}`;
|
|
37
|
+
return (
|
|
38
|
+
`@page ${page}{size:${width} ${height};margin:0}` +
|
|
39
|
+
`${pages}[${SHEET_ATTR}="${index}"]{page:${page};height:${height}!important}`
|
|
40
|
+
);
|
|
41
|
+
})
|
|
42
|
+
.join("");
|
|
43
|
+
return (
|
|
44
|
+
`@media print{@page{size:${last.width} ${last.height};margin:0}` +
|
|
45
|
+
`${pages}{height:${last.height}!important;margin-block:0!important;` +
|
|
46
|
+
`break-after:page;break-inside:avoid}${pages}:last-child{break-after:auto}${named}}`
|
|
47
|
+
);
|
|
48
|
+
}
|