@folijs/view 0.5.0 → 1.0.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 +194 -0
- package/README.md +1 -1
- package/dist/clipboard.d.ts +1 -49
- package/dist/clipboard.d.ts.map +1 -1
- package/dist/clipboard.js +65 -13
- package/dist/clipboard.js.map +1 -1
- package/dist/extension.d.ts +90 -0
- package/dist/extension.d.ts.map +1 -0
- package/dist/extension.js +152 -0
- package/dist/extension.js.map +1 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/layout/flow.d.ts +1 -109
- package/dist/layout/flow.d.ts.map +1 -1
- package/dist/layout/flow.js +808 -103
- package/dist/layout/flow.js.map +1 -1
- package/dist/print.d.ts +6 -0
- package/dist/print.d.ts.map +1 -0
- package/dist/print.js +35 -0
- package/dist/print.js.map +1 -0
- package/dist/render.d.ts +1 -24
- package/dist/render.d.ts.map +1 -1
- package/dist/render.js +4 -1
- package/dist/render.js.map +1 -1
- package/dist/view.d.ts +244 -64
- package/dist/view.d.ts.map +1 -1
- package/dist/view.js +1945 -215
- package/dist/view.js.map +1 -1
- package/dist/word/blocks.d.ts +0 -146
- package/dist/word/blocks.d.ts.map +1 -1
- package/dist/word/blocks.js +294 -59
- package/dist/word/blocks.js.map +1 -1
- package/dist/word/columns.d.ts +2 -0
- package/dist/word/columns.d.ts.map +1 -0
- package/dist/word/columns.js +63 -0
- package/dist/word/columns.js.map +1 -0
- package/dist/word/controls.d.ts +2 -0
- package/dist/word/controls.d.ts.map +1 -0
- package/dist/word/controls.js +416 -0
- package/dist/word/controls.js.map +1 -0
- package/dist/word/edit.d.ts +1 -71
- package/dist/word/edit.d.ts.map +1 -1
- package/dist/word/edit.js +338 -29
- package/dist/word/edit.js.map +1 -1
- package/dist/word/matches.d.ts +2 -0
- package/dist/word/matches.d.ts.map +1 -0
- package/dist/word/matches.js +102 -0
- package/dist/word/matches.js.map +1 -0
- package/dist/word/notes.d.ts +2 -0
- package/dist/word/notes.d.ts.map +1 -0
- package/dist/word/notes.js +403 -0
- package/dist/word/notes.js.map +1 -0
- package/dist/word/pages.d.ts +30 -20
- package/dist/word/pages.d.ts.map +1 -1
- package/dist/word/pages.js +421 -229
- package/dist/word/pages.js.map +1 -1
- package/dist/word/regions.d.ts +2 -0
- package/dist/word/regions.d.ts.map +1 -0
- package/dist/word/regions.js +388 -0
- package/dist/word/regions.js.map +1 -0
- package/dist/word/table.d.ts +1 -78
- package/dist/word/table.d.ts.map +1 -1
- package/dist/word/table.js +13 -3
- package/dist/word/table.js.map +1 -1
- package/package.json +6 -3
- package/src/clipboard.ts +93 -20
- package/src/extension.ts +267 -0
- package/src/index.ts +10 -0
- package/src/layout/flow.ts +997 -116
- package/src/print.ts +55 -0
- package/src/render.ts +6 -1
- package/src/view.ts +2178 -245
- package/src/word/blocks.ts +339 -62
- package/src/word/columns.ts +81 -0
- package/src/word/controls.ts +457 -0
- package/src/word/edit.ts +381 -31
- package/src/word/matches.ts +104 -0
- package/src/word/notes.ts +464 -0
- package/src/word/pages.ts +518 -221
- package/src/word/regions.ts +488 -0
- package/src/word/table.ts +33 -8
package/src/print.ts
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
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
|
+
/**
|
|
7
|
+
* The attribute naming a page's page setup (its index among the document's) for print.
|
|
8
|
+
* @internal
|
|
9
|
+
*/
|
|
10
|
+
export const SHEET_ATTR = "data-foli-sheet";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* A page setup as print sees it: its sheet's size (CSS lengths) and its `SHEET_ATTR` value.
|
|
14
|
+
* @internal
|
|
15
|
+
*/
|
|
16
|
+
export interface PrintSheet {
|
|
17
|
+
readonly width: string;
|
|
18
|
+
readonly height: string;
|
|
19
|
+
readonly index: number;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Print rules for the page elements `pages` selects: one sheet of its page setup's size per page
|
|
24
|
+
* (`last`'s, the document's last section, where named pages are not supported), without margins
|
|
25
|
+
* (the page's padding holds them). A page is exactly as tall as a sheet (the flow keeps content
|
|
26
|
+
* inside it; the exact height absorbs its half-pixel slack), with no gap after it. Content taller
|
|
27
|
+
* than a page (a line taller than a page) is not cut: it prints over the next sheet. `name` makes
|
|
28
|
+
* the named pages unique on the web page.
|
|
29
|
+
* @internal
|
|
30
|
+
*/
|
|
31
|
+
export function printStyles(
|
|
32
|
+
pages: string,
|
|
33
|
+
last: Pick<PrintSheet, "width" | "height">,
|
|
34
|
+
sheets: readonly PrintSheet[],
|
|
35
|
+
name: string,
|
|
36
|
+
): string {
|
|
37
|
+
// Sections with other page sizes: a named page each (engines without named pages print
|
|
38
|
+
// every sheet at the last section's size).
|
|
39
|
+
const named = sheets.every((s) => s.width === last.width && s.height === last.height)
|
|
40
|
+
? ""
|
|
41
|
+
: sheets
|
|
42
|
+
.map(({ width, height, index }) => {
|
|
43
|
+
const page = `foli-${name}-${index}`;
|
|
44
|
+
return (
|
|
45
|
+
`@page ${page}{size:${width} ${height};margin:0}` +
|
|
46
|
+
`${pages}[${SHEET_ATTR}="${index}"]{page:${page};height:${height}!important}`
|
|
47
|
+
);
|
|
48
|
+
})
|
|
49
|
+
.join("");
|
|
50
|
+
return (
|
|
51
|
+
`@media print{@page{size:${last.width} ${last.height};margin:0}` +
|
|
52
|
+
`${pages}{height:${last.height}!important;margin-block:0!important;` +
|
|
53
|
+
`break-after:page;break-inside:avoid}${pages}:last-child{break-after:auto}${named}}`
|
|
54
|
+
);
|
|
55
|
+
}
|
package/src/render.ts
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import type { Node as ModelNode } from "@folijs/core";
|
|
2
2
|
|
|
3
|
-
/**
|
|
3
|
+
/**
|
|
4
|
+
* Marks the <br> of an explicit page break.
|
|
5
|
+
* @internal
|
|
6
|
+
*/
|
|
4
7
|
export const PAGE_BREAK_ATTR = "data-page-break";
|
|
5
8
|
|
|
6
9
|
/**
|
|
7
10
|
* A rendered inline leaf (a text node or hard break) and where it sits in its block's content.
|
|
8
11
|
* A text node split across fragments is two leaves, one per fragment.
|
|
12
|
+
* @internal
|
|
9
13
|
*/
|
|
10
14
|
export interface LeafDesc {
|
|
11
15
|
readonly dom: Node;
|
|
@@ -16,6 +20,7 @@ export interface LeafDesc {
|
|
|
16
20
|
/**
|
|
17
21
|
* View descriptor of one block: the model node, its elements and its leaves. A block split
|
|
18
22
|
* across pages has one element per page (its fragments, in order); `dom` is the first.
|
|
23
|
+
* @internal
|
|
19
24
|
*/
|
|
20
25
|
export interface BlockDesc {
|
|
21
26
|
readonly node: ModelNode;
|