@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
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tables in the editable view (10.5, ADR-0006): the document's blocks as the view renders them
|
|
3
|
+
* (top-level paragraphs and opaque blocks, and every block inside table cells, in document
|
|
4
|
+
* order: each a unit with its own position, leaves and fragments), and each table's frame: the
|
|
5
|
+
* table, row and cell elements around its units, built from the model for the rows a page holds.
|
|
6
|
+
* Built with createElement only.
|
|
7
|
+
*/
|
|
8
|
+
import type { CellFormat, Node as ModelNode, Resolver } from "@folijs/core";
|
|
9
|
+
/** A block the view renders: its node, the position before it, and the cell format it is in. */
|
|
10
|
+
export interface Unit {
|
|
11
|
+
readonly node: ModelNode;
|
|
12
|
+
readonly pos: number;
|
|
13
|
+
readonly cell: CellFormat | null;
|
|
14
|
+
}
|
|
15
|
+
/** What a cell holds, in order: units (by index) and nested tables. */
|
|
16
|
+
export type CellItem = {
|
|
17
|
+
unit: number;
|
|
18
|
+
} | {
|
|
19
|
+
frame: Frame;
|
|
20
|
+
};
|
|
21
|
+
export interface FrameCell {
|
|
22
|
+
readonly node: ModelNode;
|
|
23
|
+
/** The first grid column it covers, and how many. */
|
|
24
|
+
readonly column: number;
|
|
25
|
+
readonly span: number;
|
|
26
|
+
readonly vMerge: "restart" | "continue" | null;
|
|
27
|
+
readonly format: CellFormat;
|
|
28
|
+
readonly items: readonly CellItem[];
|
|
29
|
+
}
|
|
30
|
+
export interface FrameRow {
|
|
31
|
+
readonly node: ModelNode;
|
|
32
|
+
readonly header: boolean;
|
|
33
|
+
readonly cantSplit: boolean;
|
|
34
|
+
/** Twips; `exact` is drawn as at least (shortcut: cells never clip their content). */
|
|
35
|
+
readonly height: number | null;
|
|
36
|
+
readonly cells: readonly FrameCell[];
|
|
37
|
+
}
|
|
38
|
+
/** A table as the view draws it. */
|
|
39
|
+
export interface Frame {
|
|
40
|
+
readonly node: ModelNode;
|
|
41
|
+
readonly pos: number;
|
|
42
|
+
readonly rows: readonly FrameRow[];
|
|
43
|
+
/** Twips per grid column. */
|
|
44
|
+
readonly grid: readonly number[];
|
|
45
|
+
/** The leading header rows (repeated on each page the table continues on). */
|
|
46
|
+
readonly headers: number;
|
|
47
|
+
readonly css: {
|
|
48
|
+
marginLeft: string;
|
|
49
|
+
justify: string | null;
|
|
50
|
+
};
|
|
51
|
+
/** The units inside it, nested tables' included: `[first, end)`. */
|
|
52
|
+
readonly first: number;
|
|
53
|
+
readonly end: number;
|
|
54
|
+
}
|
|
55
|
+
/** A top-level item of the page flow: a unit (paragraph, opaque block) or a table. */
|
|
56
|
+
export type FlowItem = {
|
|
57
|
+
unit: number;
|
|
58
|
+
frame?: undefined;
|
|
59
|
+
} | {
|
|
60
|
+
frame: Frame;
|
|
61
|
+
unit?: undefined;
|
|
62
|
+
};
|
|
63
|
+
/** The units and flow items of `doc`, in document order. */
|
|
64
|
+
export declare function collect(doc: ModelNode, resolver: Resolver): {
|
|
65
|
+
units: Unit[];
|
|
66
|
+
items: FlowItem[];
|
|
67
|
+
};
|
|
68
|
+
/** Marks a table's elements (wrapper, table, rows, cells): they hold blocks, not content. */
|
|
69
|
+
export declare const FRAME_ATTR = "data-foli-frame";
|
|
70
|
+
/** Marks a repeated header row: shown, not document content. */
|
|
71
|
+
export declare const REPEATED_ATTR = "data-foli-repeated";
|
|
72
|
+
/**
|
|
73
|
+
* The wrapper and table for `rows` of `frame` (indexes, in order), with `headers` (indexes of
|
|
74
|
+
* header rows drawn again above them, not editable). `content(row, cell)` gives what a cell
|
|
75
|
+
* shows on this page; a cell a vertical merge covers is drawn by the merge's first cell when
|
|
76
|
+
* that is on the page (spanning the rows it covers here), else as an empty cell of its own.
|
|
77
|
+
*/
|
|
78
|
+
export declare function frameElement(frame: Frame, rows: readonly number[], headers: readonly number[], content: (row: number, cell: number) => readonly Node[], doc: Document): HTMLElement;
|
|
79
|
+
//# sourceMappingURL=table.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"table.d.ts","sourceRoot":"","sources":["../../src/word/table.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,IAAI,IAAI,SAAS,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAG5E,gGAAgG;AAChG,MAAM,WAAW,IAAI;IACnB,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,IAAI,EAAE,UAAU,GAAG,IAAI,CAAC;CAClC;AAED,uEAAuE;AACvE,MAAM,MAAM,QAAQ,GAAG;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,KAAK,EAAE,KAAK,CAAA;CAAE,CAAC;AAE3D,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB,qDAAqD;IACrD,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,SAAS,GAAG,UAAU,GAAG,IAAI,CAAC;IAC/C,QAAQ,CAA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AAE,CAAC;IAAC,KAAK,EAAE,QAAQ,EAAE,CAAA;CAAE,CAWhG;AA2ED,6FAA6F;AAC7F,eAAO,MAAM,UAAU,oBAAoB,CAAC;AAC5C,gEAAgE;AAChE,eAAO,MAAM,aAAa,uBAAuB,CAAC;AAElD;;;;;GAKG;AACH,wBAAgB,YAAY,CAC1B,KAAK,EAAE,KAAK,EACZ,IAAI,EAAE,SAAS,MAAM,EAAE,EACvB,OAAO,EAAE,SAAS,MAAM,EAAE,EAC1B,OAAO,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,SAAS,IAAI,EAAE,EACvD,GAAG,EAAE,QAAQ,GACZ,WAAW,CAuCb"}
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import { borderJsonCss, PX_PER_TWIP } from "./blocks.js";
|
|
2
|
+
/** The units and flow items of `doc`, in document order. */
|
|
3
|
+
export function collect(doc, resolver) {
|
|
4
|
+
const units = [];
|
|
5
|
+
const items = [];
|
|
6
|
+
doc.forEach((node, offset) => {
|
|
7
|
+
if (node.type.name === "table")
|
|
8
|
+
items.push({ frame: frameOf(node, offset, resolver, units) });
|
|
9
|
+
else {
|
|
10
|
+
items.push({ unit: units.length });
|
|
11
|
+
units.push({ node, pos: offset, cell: null });
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
return { units, items };
|
|
15
|
+
}
|
|
16
|
+
function frameOf(table, pos, resolver, units) {
|
|
17
|
+
const first = units.length;
|
|
18
|
+
const attrs = table.attrs;
|
|
19
|
+
const format = resolver.table(attrs);
|
|
20
|
+
const rows = [];
|
|
21
|
+
let rowPos = pos + 1;
|
|
22
|
+
table.forEach((row, _r, r) => {
|
|
23
|
+
const rowAttrs = row.attrs;
|
|
24
|
+
let column = rowAttrs.gridBefore ?? 0;
|
|
25
|
+
const cells = [];
|
|
26
|
+
let cellPos = rowPos + 1;
|
|
27
|
+
row.forEach((cell, _c, c) => {
|
|
28
|
+
const cellAttrs = cell.attrs;
|
|
29
|
+
const cellFormat = resolver.cell(attrs, rowAttrs, cellAttrs, {
|
|
30
|
+
row: r,
|
|
31
|
+
rows: table.childCount,
|
|
32
|
+
cell: c,
|
|
33
|
+
cells: row.childCount,
|
|
34
|
+
});
|
|
35
|
+
const items = [];
|
|
36
|
+
cell.forEach((block, offset) => {
|
|
37
|
+
const at = cellPos + 1 + offset;
|
|
38
|
+
if (block.type.name === "table")
|
|
39
|
+
items.push({ frame: frameOf(block, at, resolver, units) });
|
|
40
|
+
else {
|
|
41
|
+
items.push({ unit: units.length });
|
|
42
|
+
units.push({ node: block, pos: at, cell: cellFormat });
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
const span = cellAttrs.gridSpan ?? 1;
|
|
46
|
+
cells.push({
|
|
47
|
+
node: cell,
|
|
48
|
+
column,
|
|
49
|
+
span,
|
|
50
|
+
vMerge: cellAttrs.vMerge ?? null,
|
|
51
|
+
format: cellFormat,
|
|
52
|
+
items,
|
|
53
|
+
});
|
|
54
|
+
column += span;
|
|
55
|
+
cellPos += cell.nodeSize;
|
|
56
|
+
});
|
|
57
|
+
const height = rowAttrs.height;
|
|
58
|
+
rows.push({
|
|
59
|
+
node: row,
|
|
60
|
+
header: !!rowAttrs.header,
|
|
61
|
+
cantSplit: !!rowAttrs.cantSplit,
|
|
62
|
+
height: height?.value ?? null,
|
|
63
|
+
cells,
|
|
64
|
+
});
|
|
65
|
+
rowPos += row.nodeSize;
|
|
66
|
+
});
|
|
67
|
+
let headers = 0;
|
|
68
|
+
while (headers < rows.length && rows[headers]?.header)
|
|
69
|
+
headers++;
|
|
70
|
+
// Word repeats header rows only while some body row follows them.
|
|
71
|
+
if (headers === rows.length)
|
|
72
|
+
headers = 0;
|
|
73
|
+
const indent = format.indent?.type === "dxa" ? format.indent.value : 0;
|
|
74
|
+
return {
|
|
75
|
+
node: table,
|
|
76
|
+
pos,
|
|
77
|
+
rows,
|
|
78
|
+
grid: attrs.grid ?? [],
|
|
79
|
+
headers,
|
|
80
|
+
css: {
|
|
81
|
+
marginLeft: `${indent * PX_PER_TWIP}px`,
|
|
82
|
+
justify: format.justification === "center" || format.justification === "right"
|
|
83
|
+
? format.justification
|
|
84
|
+
: null,
|
|
85
|
+
},
|
|
86
|
+
first,
|
|
87
|
+
end: units.length,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
/** Marks a table's elements (wrapper, table, rows, cells): they hold blocks, not content. */
|
|
91
|
+
export const FRAME_ATTR = "data-foli-frame";
|
|
92
|
+
/** Marks a repeated header row: shown, not document content. */
|
|
93
|
+
export const REPEATED_ATTR = "data-foli-repeated";
|
|
94
|
+
/**
|
|
95
|
+
* The wrapper and table for `rows` of `frame` (indexes, in order), with `headers` (indexes of
|
|
96
|
+
* header rows drawn again above them, not editable). `content(row, cell)` gives what a cell
|
|
97
|
+
* shows on this page; a cell a vertical merge covers is drawn by the merge's first cell when
|
|
98
|
+
* that is on the page (spanning the rows it covers here), else as an empty cell of its own.
|
|
99
|
+
*/
|
|
100
|
+
export function frameElement(frame, rows, headers, content, doc) {
|
|
101
|
+
const wrapper = doc.createElement("div");
|
|
102
|
+
wrapper.setAttribute(FRAME_ATTR, "table");
|
|
103
|
+
wrapper.style.display = "flow-root";
|
|
104
|
+
const table = doc.createElement("table");
|
|
105
|
+
table.setAttribute(FRAME_ATTR, "");
|
|
106
|
+
const { style } = table;
|
|
107
|
+
style.borderCollapse = "collapse";
|
|
108
|
+
// shortcut: autofit tables keep the grid Word saved; widths are not recomputed from content.
|
|
109
|
+
style.tableLayout = "fixed";
|
|
110
|
+
const total = frame.grid.reduce((a, b) => a + b, 0);
|
|
111
|
+
if (total)
|
|
112
|
+
style.width = `${total * PX_PER_TWIP}px`;
|
|
113
|
+
if (frame.css.justify === "center")
|
|
114
|
+
style.margin = "0 auto";
|
|
115
|
+
else if (frame.css.justify === "right")
|
|
116
|
+
style.marginLeft = "auto";
|
|
117
|
+
else
|
|
118
|
+
style.marginLeft = frame.css.marginLeft;
|
|
119
|
+
const colgroup = doc.createElement("colgroup");
|
|
120
|
+
for (const width of frame.grid) {
|
|
121
|
+
const col = doc.createElement("col");
|
|
122
|
+
col.style.width = `${width * PX_PER_TWIP}px`;
|
|
123
|
+
colgroup.append(col);
|
|
124
|
+
}
|
|
125
|
+
const body = doc.createElement("tbody");
|
|
126
|
+
body.setAttribute(FRAME_ATTR, "");
|
|
127
|
+
table.append(colgroup, body);
|
|
128
|
+
for (const r of headers) {
|
|
129
|
+
const repeated = rowElement(frame, r, [r], () => [], doc);
|
|
130
|
+
repeated.setAttribute(REPEATED_ATTR, "");
|
|
131
|
+
repeated.setAttribute("contenteditable", "false");
|
|
132
|
+
repeated.setAttribute("aria-hidden", "true");
|
|
133
|
+
// The header's text, drawn again: copied from the model's cells, not leaves.
|
|
134
|
+
const source = frame.rows[r];
|
|
135
|
+
[...repeated.children].forEach((td, c) => {
|
|
136
|
+
td.textContent = source.cells[c]?.node.textContent ?? "";
|
|
137
|
+
});
|
|
138
|
+
body.append(repeated);
|
|
139
|
+
}
|
|
140
|
+
for (const r of rows)
|
|
141
|
+
body.append(rowElement(frame, r, rows, content, doc));
|
|
142
|
+
wrapper.append(table);
|
|
143
|
+
return wrapper;
|
|
144
|
+
}
|
|
145
|
+
function rowElement(frame, r, shown, content, doc) {
|
|
146
|
+
const row = frame.rows[r];
|
|
147
|
+
const tr = doc.createElement("tr");
|
|
148
|
+
tr.setAttribute(FRAME_ATTR, "");
|
|
149
|
+
if (row.header)
|
|
150
|
+
tr.dataset.foliHeader = "";
|
|
151
|
+
if (row.height)
|
|
152
|
+
tr.style.height = `${row.height * PX_PER_TWIP}px`;
|
|
153
|
+
row.cells.forEach((cell, c) => {
|
|
154
|
+
// Covered by a merge whose first cell is drawn on this page: not shown. Its blocks (the
|
|
155
|
+
// empty paragraph Word keeps) stay in document order, in a cell the table does not lay out.
|
|
156
|
+
if (cell.vMerge === "continue" && mergeStartShown(frame, r, cell.column, shown)) {
|
|
157
|
+
const td = doc.createElement("td");
|
|
158
|
+
td.setAttribute(FRAME_ATTR, "covered");
|
|
159
|
+
td.style.display = "none";
|
|
160
|
+
td.append(...content(r, c));
|
|
161
|
+
tr.append(td);
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
const td = doc.createElement("td");
|
|
165
|
+
td.setAttribute(FRAME_ATTR, "");
|
|
166
|
+
if (cell.span > 1)
|
|
167
|
+
td.colSpan = cell.span;
|
|
168
|
+
const rowSpan = covered(frame, r, cell.column, shown);
|
|
169
|
+
if (rowSpan > 1)
|
|
170
|
+
td.rowSpan = rowSpan;
|
|
171
|
+
const { format } = cell;
|
|
172
|
+
const s = td.style;
|
|
173
|
+
if (format.shading)
|
|
174
|
+
s.backgroundColor = `#${format.shading}`;
|
|
175
|
+
const m = format.margins;
|
|
176
|
+
s.padding = `${m.top * PX_PER_TWIP}px ${m.right * PX_PER_TWIP}px ${m.bottom * PX_PER_TWIP}px ${m.left * PX_PER_TWIP}px`;
|
|
177
|
+
s.verticalAlign = format.verticalAlign === "center" ? "middle" : format.verticalAlign;
|
|
178
|
+
for (const side of ["top", "left", "bottom", "right"]) {
|
|
179
|
+
const css = borderJsonCss(format.borders[side]);
|
|
180
|
+
if (css)
|
|
181
|
+
s.setProperty(`border-${side}`, css);
|
|
182
|
+
}
|
|
183
|
+
td.append(...content(r, c));
|
|
184
|
+
tr.append(td);
|
|
185
|
+
});
|
|
186
|
+
return tr;
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Whether a covered cell at (`r`, `column`) is drawn by a cell above it here: the row above is
|
|
190
|
+
* shown and its cell there is part of the merge (its first cell, or one drawn for it because
|
|
191
|
+
* the first is on an earlier page).
|
|
192
|
+
*/
|
|
193
|
+
function mergeStartShown(frame, r, column, shown) {
|
|
194
|
+
if (!shown.includes(r - 1))
|
|
195
|
+
return false;
|
|
196
|
+
const above = frame.rows[r - 1]?.cells.find((x) => x.column === column);
|
|
197
|
+
return above?.vMerge === "restart" || above?.vMerge === "continue";
|
|
198
|
+
}
|
|
199
|
+
/** How many shown rows from `r` a cell at `column` covers (itself and the merge below it). */
|
|
200
|
+
function covered(frame, r, column, shown) {
|
|
201
|
+
let n = 1;
|
|
202
|
+
for (let below = r + 1; shown.includes(below); below++) {
|
|
203
|
+
const cell = frame.rows[below]?.cells.find((x) => x.column === column);
|
|
204
|
+
if (cell?.vMerge !== "continue")
|
|
205
|
+
break;
|
|
206
|
+
n++;
|
|
207
|
+
}
|
|
208
|
+
return n;
|
|
209
|
+
}
|
|
210
|
+
//# sourceMappingURL=table.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"table.js","sourceRoot":"","sources":["../../src/word/table.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAiDzD,4DAA4D;AAC5D,MAAM,UAAU,OAAO,CAAC,GAAc,EAAE,QAAkB;IACxD,MAAM,KAAK,GAAW,EAAE,CAAC;IACzB,MAAM,KAAK,GAAe,EAAE,CAAC;IAC7B,GAAG,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE;QAC3B,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,OAAO;YAAE,KAAK,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC,CAAC;aACzF,CAAC;YACJ,KAAK,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC;YACnC,KAAK,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;QAChD,CAAC;IACH,CAAC,CAAC,CAAC;IACH,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;AAC1B,CAAC;AAED,SAAS,OAAO,CAAC,KAAgB,EAAE,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AAC9F,SAAS,OAAO,CAAC,KAAY,EAAE,CAAS,EAAE,MAAc,EAAE,KAAwB;IAChF,IAAI,CAAC,GAAG,CAAC,CAAC;IACV,KAAK,IAAI,KAAK,GAAG,CAAC,GAAG,CAAC,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,EAAE,CAAC;QACvD,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,MAAM,CAAC,CAAC;QACvE,IAAI,IAAI,EAAE,MAAM,KAAK,UAAU;YAAE,MAAM;QACvC,CAAC,EAAE,CAAC;IACN,CAAC;IACD,OAAO,CAAC,CAAC;AACX,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@folijs/view",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Framework-agnostic DOM view for the Foli document engine: rendering, input, selection, layout.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"!src/**/*.test.*"
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@folijs/core": "^0.
|
|
28
|
+
"@folijs/core": "^0.6.0"
|
|
29
29
|
},
|
|
30
30
|
"scripts": {
|
|
31
31
|
"build": "node -e \"require('node:fs').rmSync('dist',{recursive:true,force:true})\" && tsc -p tsconfig.build.json",
|
package/src/clipboard.ts
CHANGED
|
@@ -2,6 +2,7 @@ import {
|
|
|
2
2
|
type Alignment,
|
|
3
3
|
copiedDefinitions,
|
|
4
4
|
type DocJSON,
|
|
5
|
+
type FittedPaste,
|
|
5
6
|
Fragment,
|
|
6
7
|
type InlineJSON,
|
|
7
8
|
isSafeHref,
|
|
@@ -38,6 +39,8 @@ export interface Pasted {
|
|
|
38
39
|
doc: ModelNode;
|
|
39
40
|
/** The target's envelope with what the content needs (styles, lists...), when it changed. */
|
|
40
41
|
envelope?: WordEnvelope;
|
|
42
|
+
/** New notes for the references in `doc`: added with it. */
|
|
43
|
+
notes?: FittedPaste["notes"];
|
|
41
44
|
/**
|
|
42
45
|
* True when no block boundary was copied (text from inside one block, plain text, inline
|
|
43
46
|
* HTML): the content always joins the block it is pasted into, which keeps its type. Closed
|
package/src/index.ts
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
export { FOLI_MIME, htmlToDoc, textToDoc } from "./clipboard.js";
|
|
2
|
-
export {
|
|
2
|
+
export {
|
|
3
|
+
EditorView,
|
|
4
|
+
type EditorViewOptions,
|
|
5
|
+
keyName,
|
|
6
|
+
measureImageFile,
|
|
7
|
+
textWidthEmu,
|
|
8
|
+
} from "./view.js";
|
|
9
|
+
export { EMU_PER_PX } from "./word/blocks.js";
|
|
3
10
|
export {
|
|
4
11
|
type DocumentPages,
|
|
5
12
|
type ReviewView,
|