@folijs/view 0.6.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.
Files changed (82) hide show
  1. package/CHANGELOG.md +161 -0
  2. package/README.md +1 -1
  3. package/dist/clipboard.d.ts +1 -51
  4. package/dist/clipboard.d.ts.map +1 -1
  5. package/dist/clipboard.js +65 -13
  6. package/dist/clipboard.js.map +1 -1
  7. package/dist/extension.d.ts +90 -0
  8. package/dist/extension.d.ts.map +1 -0
  9. package/dist/extension.js +152 -0
  10. package/dist/extension.js.map +1 -0
  11. package/dist/index.d.ts +2 -1
  12. package/dist/index.d.ts.map +1 -1
  13. package/dist/index.js.map +1 -1
  14. package/dist/layout/flow.d.ts +1 -282
  15. package/dist/layout/flow.d.ts.map +1 -1
  16. package/dist/layout/flow.js +21 -4
  17. package/dist/layout/flow.js.map +1 -1
  18. package/dist/print.d.ts +1 -17
  19. package/dist/print.d.ts.map +1 -1
  20. package/dist/print.js +5 -1
  21. package/dist/print.js.map +1 -1
  22. package/dist/render.d.ts +1 -24
  23. package/dist/render.d.ts.map +1 -1
  24. package/dist/render.js +4 -1
  25. package/dist/render.js.map +1 -1
  26. package/dist/view.d.ts +34 -67
  27. package/dist/view.d.ts.map +1 -1
  28. package/dist/view.js +209 -24
  29. package/dist/view.js.map +1 -1
  30. package/dist/word/blocks.d.ts +0 -175
  31. package/dist/word/blocks.d.ts.map +1 -1
  32. package/dist/word/blocks.js +106 -24
  33. package/dist/word/blocks.js.map +1 -1
  34. package/dist/word/columns.d.ts +1 -22
  35. package/dist/word/columns.d.ts.map +1 -1
  36. package/dist/word/columns.js +15 -3
  37. package/dist/word/columns.js.map +1 -1
  38. package/dist/word/controls.d.ts +1 -62
  39. package/dist/word/controls.d.ts.map +1 -1
  40. package/dist/word/controls.js +6 -1
  41. package/dist/word/controls.js.map +1 -1
  42. package/dist/word/edit.d.ts +1 -83
  43. package/dist/word/edit.d.ts.map +1 -1
  44. package/dist/word/edit.js +183 -5
  45. package/dist/word/edit.js.map +1 -1
  46. package/dist/word/matches.d.ts +1 -22
  47. package/dist/word/matches.d.ts.map +1 -1
  48. package/dist/word/matches.js +6 -1
  49. package/dist/word/matches.js.map +1 -1
  50. package/dist/word/notes.d.ts +0 -103
  51. package/dist/word/notes.d.ts.map +1 -1
  52. package/dist/word/notes.js +15 -4
  53. package/dist/word/notes.js.map +1 -1
  54. package/dist/word/pages.d.ts +15 -10
  55. package/dist/word/pages.d.ts.map +1 -1
  56. package/dist/word/pages.js +3 -2
  57. package/dist/word/pages.js.map +1 -1
  58. package/dist/word/regions.d.ts +0 -111
  59. package/dist/word/regions.d.ts.map +1 -1
  60. package/dist/word/regions.js +19 -5
  61. package/dist/word/regions.js.map +1 -1
  62. package/dist/word/table.d.ts +1 -78
  63. package/dist/word/table.d.ts.map +1 -1
  64. package/dist/word/table.js +13 -3
  65. package/dist/word/table.js.map +1 -1
  66. package/package.json +6 -3
  67. package/src/clipboard.ts +91 -21
  68. package/src/extension.ts +267 -0
  69. package/src/index.ts +10 -0
  70. package/src/layout/flow.ts +59 -13
  71. package/src/print.ts +9 -2
  72. package/src/render.ts +6 -1
  73. package/src/view.ts +245 -40
  74. package/src/word/blocks.ts +124 -30
  75. package/src/word/columns.ts +19 -4
  76. package/src/word/controls.ts +13 -3
  77. package/src/word/edit.ts +207 -9
  78. package/src/word/matches.ts +6 -1
  79. package/src/word/notes.ts +19 -6
  80. package/src/word/pages.ts +19 -3
  81. package/src/word/regions.ts +27 -8
  82. package/src/word/table.ts +33 -8
@@ -1,79 +1,2 @@
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;
1
+ export {};
79
2
  //# sourceMappingURL=table.d.ts.map
@@ -1 +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,CAAC,MAAM,EAAE,UAAU,CAAC;IAC5B,QAAQ,CAAC,KAAK,EAAE,SAAS,QAAQ,EAAE,CAAC;CACrC;AAED,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,SAAS,EAAE,OAAO,CAA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I,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"}
1
+ {"version":3,"file":"table.d.ts","sourceRoot":"","sources":["../../src/word/table.ts"],"names":[],"mappings":""}
@@ -1,5 +1,8 @@
1
1
  import { borderJsonCss, PX_PER_TWIP } from "./blocks.js";
2
- /** The units and flow items of `doc`, in document order. */
2
+ /**
3
+ * The units and flow items of `doc`, in document order.
4
+ * @internal
5
+ */
3
6
  export function collect(doc, resolver) {
4
7
  const units = [];
5
8
  const items = [];
@@ -87,15 +90,22 @@ function frameOf(table, pos, resolver, units) {
87
90
  end: units.length,
88
91
  };
89
92
  }
90
- /** Marks a table's elements (wrapper, table, rows, cells): they hold blocks, not content. */
93
+ /**
94
+ * Marks a table's elements (wrapper, table, rows, cells): they hold blocks, not content.
95
+ * @internal
96
+ */
91
97
  export const FRAME_ATTR = "data-foli-frame";
92
- /** Marks a repeated header row: shown, not document content. */
98
+ /**
99
+ * Marks a repeated header row: shown, not document content.
100
+ * @internal
101
+ */
93
102
  export const REPEATED_ATTR = "data-foli-repeated";
94
103
  /**
95
104
  * The wrapper and table for `rows` of `frame` (indexes, in order), with `headers` (indexes of
96
105
  * header rows drawn again above them, not editable). `content(row, cell)` gives what a cell
97
106
  * shows on this page; a cell a vertical merge covers is drawn by the merge's first cell when
98
107
  * that is on the page (spanning the rows it covers here), else as an empty cell of its own.
108
+ * @internal
99
109
  */
100
110
  export function frameElement(frame, rows, headers, content, doc) {
101
111
  const wrapper = doc.createElement("div");
@@ -1 +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;A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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.6.0",
3
+ "version": "1.0.0",
4
4
  "description": "Framework-agnostic DOM view for the Foli document engine: rendering, input, selection, layout.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -24,8 +24,11 @@
24
24
  "src",
25
25
  "!src/**/*.test.*"
26
26
  ],
27
- "dependencies": {
28
- "@folijs/core": "^0.6.0"
27
+ "peerDependencies": {
28
+ "@folijs/core": "1.0.0"
29
+ },
30
+ "devDependencies": {
31
+ "@folijs/core": "1.0.0"
29
32
  },
30
33
  "scripts": {
31
34
  "build": "node -e \"require('node:fs').rmSync('dist',{recursive:true,force:true})\" && tsc -p tsconfig.build.json",
package/src/clipboard.ts CHANGED
@@ -1,18 +1,21 @@
1
1
  import {
2
2
  type Alignment,
3
- copiedDefinitions,
4
3
  type DocJSON,
5
- type FittedPaste,
6
4
  Fragment,
7
5
  type InlineJSON,
8
6
  isSafeHref,
9
7
  type MarkJSON,
10
8
  type Node as ModelNode,
11
9
  type ParagraphJSON,
10
+ type ResourceJSON,
12
11
  type SimpleMarkName,
12
+ } from "@folijs/core";
13
+ import {
14
+ copiedDefinitions,
15
+ type FittedPaste,
13
16
  type WordContext,
14
17
  type WordEnvelope,
15
- } from "@folijs/core";
18
+ } from "@folijs/core/internal";
16
19
  import { PAGE_BREAK_ATTR } from "./render.js";
17
20
  import { opaqueParagraphsText, parseOpaque } from "./word/blocks.js";
18
21
  import { clipboardBlocks } from "./word/edit.js";
@@ -24,7 +27,39 @@ import { clipboardBlocks } from "./word/edit.js";
24
27
  */
25
28
  export const FOLI_MIME = "application/x-foli+json";
26
29
 
27
- /** One clipboard format's content, before validation. */
30
+ /**
31
+ * The attribute on the clipboard HTML's wrapper that holds the Foli JSON when the copy has custom
32
+ * nodes or marks (ADR-0008): some browsers (Firefox) give a paste only `text/html` and
33
+ * `text/plain`, and HTML alone cannot say what a custom type is.
34
+ */
35
+ const JSON_ATTR = "data-foli-clipboard";
36
+
37
+ /** Whether `content` holds a custom or foreign node or mark. */
38
+ function hasCustom(content: ModelNode): boolean {
39
+ let found = false;
40
+ content.descendants((node) => {
41
+ found ||=
42
+ !!node.type.spec.text ||
43
+ // Pictures too: an HTML-only paste (Firefox) would lose their images.
44
+ node.type.name === "picture" ||
45
+ node.marks.some((m) => m.type.name.includes(":") || m.type.name === "foreign");
46
+ return !found;
47
+ });
48
+ return found;
49
+ }
50
+
51
+ /** The Foli JSON of the clipboard (`FOLI_MIME`'s), as a format to try. */
52
+ function foliJSON(json: string): Found | null {
53
+ const value: unknown = JSON.parse(json);
54
+ if (typeof value !== "object" || value === null) return null;
55
+ const { open, content, word } = value as { open?: unknown; content?: unknown; word?: unknown };
56
+ return { content, open: open === true, word };
57
+ }
58
+
59
+ /**
60
+ * One clipboard format's content, before validation.
61
+ * @internal
62
+ */
28
63
  export interface Found {
29
64
  content: unknown;
30
65
  open: boolean;
@@ -34,7 +69,10 @@ export interface Found {
34
69
  word?: unknown;
35
70
  }
36
71
 
37
- /** Validated clipboard content. */
72
+ /**
73
+ * Validated clipboard content.
74
+ * @internal
75
+ */
38
76
  export interface Pasted {
39
77
  doc: ModelNode;
40
78
  /** The target's envelope with what the content needs (styles, lists...), when it changed. */
@@ -49,6 +87,7 @@ export interface Pasted {
49
87
  open: boolean;
50
88
  }
51
89
 
90
+ /** @internal */
52
91
  export interface ClipboardContent {
53
92
  text: string;
54
93
  html: string;
@@ -59,13 +98,19 @@ export interface ClipboardContent {
59
98
  * Serializes `from..to` of `doc` for the clipboard. Hard breaks and block ends become "\n". The
60
99
  * HTML is the document as its Word renderer draws it (`word`: its context and the fonts' line
61
100
  * height ratios): resolved formatting as inline CSS, list numbers as Word's HTML has them.
101
+ * @internal
62
102
  */
63
103
  export function serializeRange(
64
104
  doc: ModelNode,
65
105
  from: number,
66
106
  to: number,
67
107
  ownerDocument: Document,
68
- word: { context: WordContext; ratio: (family: string) => number },
108
+ word: {
109
+ context: WordContext;
110
+ ratio: (family: string) => number;
111
+ /** A copied picture's image as another document can show it (the view's own source). */
112
+ portable?: (key: string, resource: ResourceJSON) => ResourceJSON;
113
+ },
69
114
  ): ClipboardContent {
70
115
  // A slice inside one textblock holds only inline content: wrap it back in its ancestors.
71
116
  const $from = doc.resolve(from);
@@ -90,14 +135,27 @@ export function serializeRange(
90
135
  // How other apps (and print) recognize a page break; the editor itself does not need it.
91
136
  for (const br of container.querySelectorAll(`br[${PAGE_BREAK_ATTR}]`))
92
137
  (br as HTMLElement).style.cssText = "page-break-before: always; break-before: page";
138
+ const definitions = copiedDefinitions(word.context, blocks);
139
+ const { portable } = word;
140
+ if (definitions.resources && portable)
141
+ definitions.resources = Object.fromEntries(
142
+ Object.entries(definitions.resources).map(([key, r]) => [key, portable(key, r)]),
143
+ );
144
+ const json = JSON.stringify({
145
+ open: $from.sharedDepth(to) > 0,
146
+ content: blocks.toJSON(),
147
+ word: definitions,
148
+ });
149
+ let html = container.innerHTML;
150
+ if (hasCustom(blocks)) {
151
+ // An attribute (escaped by the DOM) on the wrapper, read back by `docFromClipboard`.
152
+ container.setAttribute(JSON_ATTR, json);
153
+ html = container.outerHTML;
154
+ }
93
155
  return {
94
156
  text: doc.textBetween(from, to, "\n", (leaf) => leafText(leaf, ownerDocument)),
95
- html: container.innerHTML,
96
- json: JSON.stringify({
97
- open: $from.sharedDepth(to) > 0,
98
- content: blocks.toJSON(),
99
- word: copiedDefinitions(word.context, blocks),
100
- }),
157
+ html,
158
+ json,
101
159
  };
102
160
  }
103
161
 
@@ -108,6 +166,8 @@ export function serializeRange(
108
166
  function leafText(leaf: ModelNode, doc: Document): string {
109
167
  const name = leaf.type.name;
110
168
  if (name === "tab") return "\t";
169
+ const stands = leaf.type.spec.text;
170
+ if (stands) return leaf.isBlock ? `\n${stands(leaf.attrs)}` : stands(leaf.attrs);
111
171
  if (name === "opaqueInline" || name === "opaqueBlock") {
112
172
  const xml = parseOpaque(String(leaf.attrs.xml ?? ""), doc);
113
173
  const text = xml ? opaqueParagraphsText(xml) : "";
@@ -123,6 +183,7 @@ function leafText(leaf: ModelNode, doc: Document): string {
123
183
  * text. Every format is validated and fitted to the document by `parse` (`fitPaste`,
124
184
  * `fitPastedV2`); a format that fails falls through to the next. `marks` are given to plain text
125
185
  * (the marks typing would get at the insertion point).
186
+ * @internal
126
187
  */
127
188
  export function docFromClipboard(
128
189
  data: Pick<DataTransfer, "getData">,
@@ -133,16 +194,24 @@ export function docFromClipboard(
133
194
  const html = data.getData("text/html");
134
195
  const text = data.getData("text/plain");
135
196
  const candidates: (() => Found | null)[] = [
197
+ () => (json ? foliJSON(json) : null),
136
198
  () => {
137
- if (!json) return null;
138
- const value: unknown = JSON.parse(json);
139
- if (typeof value !== "object" || value === null) return null;
140
- const { open, content, word } = value as {
141
- open?: unknown;
142
- content?: unknown;
143
- word?: unknown;
144
- };
145
- return { content, open: open === true, word };
199
+ // Foli's HTML with custom content carries its JSON (parsed inert, never inserted).
200
+ if (!html.includes(JSON_ATTR)) return null;
201
+ const { body } = new DOMParser().parseFromString(html, "text/html");
202
+ // Only when the wrapper is all there is: a Foli copy inside other content (an email
203
+ // quoting it) is read as HTML, so the text around it is kept.
204
+ const alone = [...body.childNodes].every(
205
+ (n) =>
206
+ n.nodeType === 8 ||
207
+ (n.nodeType === 3 && !n.textContent?.trim()) ||
208
+ n === body.firstElementChild,
209
+ );
210
+ const carried =
211
+ alone && body.childElementCount === 1
212
+ ? body.firstElementChild?.getAttribute(JSON_ATTR)
213
+ : null;
214
+ return carried ? foliJSON(carried) : null;
146
215
  },
147
216
  () => {
148
217
  const read = html ? readHTML(html) : null;
@@ -286,6 +355,7 @@ const hex2 = (n: number) =>
286
355
  * A CSS color as the schema stores it (lowercase `#rrggbb`), or null: transparent, unknown
287
356
  * (system colors such as Word's `windowtext`) or empty. Hex (3 or 6 digits), `rgb()`/`rgba()`
288
357
  * and the basic named colors.
358
+ * @internal
289
359
  */
290
360
  export function parseColor(value: string): string | null {
291
361
  const color = value.trim().toLowerCase();
@@ -0,0 +1,267 @@
1
+ /**
2
+ * The view's side of extensions (ADR-0008, 12.4): node views draw custom nodes, mark views style
3
+ * runs of custom marks, decorations put classes and attributes on drawn ranges, and plugin views
4
+ * live as long as the `EditorView`. Core has no DOM: these hooks are on `ViewExtension`, which an
5
+ * app gives to `createEditor` as an ordinary extension; the view reads them from
6
+ * `editor.extensions`.
7
+ *
8
+ * Everything here is drawn with DOM calls, never parsed from HTML: attribute names are checked
9
+ * (no `on*` handlers, no `contenteditable`, none of the view's own `data-foli-*`), and URL
10
+ * attributes must be safe links (`isSafeHref`).
11
+ */
12
+ import {
13
+ type EditorState,
14
+ type Extension,
15
+ isSafeHref,
16
+ type Mark,
17
+ type Node as ModelNode,
18
+ } from "@folijs/core";
19
+ import type { EditorView } from "./view.js";
20
+
21
+ /**
22
+ * Attributes put on a drawn element: `class` is added to its classes, `style` to its style, any
23
+ * other name set (`aria-*`, `data-*`, `title`…).
24
+ */
25
+ export interface DecorationAttrs {
26
+ class?: string;
27
+ style?: string;
28
+ [name: string]: string | undefined;
29
+ }
30
+
31
+ /**
32
+ * Attributes on a range of the document as drawn, never content: the text and inline leaves
33
+ * from `from` to `to` (body positions of the state the decorations are for), or with `node` the
34
+ * node at `from`: a block (its element on every page it is on) or an inline leaf. A table, row
35
+ * or cell takes none.
36
+ */
37
+ export interface Decoration {
38
+ from: number;
39
+ to: number;
40
+ node?: boolean;
41
+ attrs: DecorationAttrs;
42
+ }
43
+
44
+ /**
45
+ * What a node view draws with: its document, and `h`, which makes elements safely. A node view may
46
+ * build its DOM by other means: what `render` returns is used as it is, unchecked (extension code
47
+ * is trusted, the node's attributes are not: never put them through HTML).
48
+ */
49
+ export interface NodeViewDOM {
50
+ readonly document: Document;
51
+ /**
52
+ * An element `tag` (from an allowlist of content elements: no `script`, `style`, `base`,
53
+ * `form`, frames…) with attributes `attrs` (checked as decorations' are) and children, strings
54
+ * as text nodes: data from the document never goes through HTML.
55
+ */
56
+ h(
57
+ tag: string,
58
+ attrs?: Readonly<Record<string, string>> | null,
59
+ ...children: readonly (Node | string)[]
60
+ ): HTMLElement;
61
+ }
62
+
63
+ /**
64
+ * How a custom node is drawn. Inline: in its line, which wraps around it as the browser sizes it.
65
+ * Block: on the pages, measured by the flow; one taller than the room left on a page splits
66
+ * between its root element's children (each part drawn again by `render`, clipped), unless
67
+ * `split` is false, which keeps it whole on one page.
68
+ */
69
+ export interface NodeView {
70
+ /**
71
+ * Called whenever the node is drawn again: a changed node, or a block split differently. Its
72
+ * DOM may change later (content loaded, a chart drawn): the view does not read it back.
73
+ */
74
+ render(node: ModelNode, dom: NodeViewDOM): Node;
75
+ split?: boolean;
76
+ /** Called with what `render` returned once the view no longer shows it (or is destroyed). */
77
+ destroy?(dom: Node): void;
78
+ }
79
+
80
+ /** How a run of a custom mark is drawn: attributes on the run's element. */
81
+ export type MarkView = (mark: Mark) => DecorationAttrs;
82
+
83
+ /** What a view extension keeps beside an `EditorView`: told of each update, destroyed with it. */
84
+ export interface PluginView {
85
+ /** After the view drew a new state; `previous` is the state before. */
86
+ update?(view: EditorView, previous: EditorState): void;
87
+ destroy?(): void;
88
+ }
89
+
90
+ /**
91
+ * An extension with view hooks (ADR-0008), given to `createEditor({ extensions })` (and React's
92
+ * `extensions` prop) like any extension.
93
+ */
94
+ export interface ViewExtension extends Extension {
95
+ /** By node type: one of the extension's (or another extension's) custom nodes. */
96
+ nodeViews?: Readonly<Record<string, NodeView>>;
97
+ /** By mark type. */
98
+ markViews?: Readonly<Record<string, MarkView>>;
99
+ /**
100
+ * The decorations for a state, asked on every update: keep it cheap (plugin state is a good
101
+ * place to keep them). Only blocks whose decorations changed are drawn again.
102
+ */
103
+ decorations?(state: EditorState): readonly Decoration[];
104
+ /** Called when a view of the editor is made (a story open on its page has a view too). */
105
+ view?(view: EditorView): PluginView;
106
+ }
107
+
108
+ /** The node and mark views of a view's extensions. @internal */
109
+ export interface Views {
110
+ nodes: ReadonlyMap<string, NodeView>;
111
+ marks: ReadonlyMap<string, MarkView>;
112
+ }
113
+
114
+ /** A node view's drawing, in its box, until the view drops it. @internal */
115
+ export interface Drawn {
116
+ view: NodeView;
117
+ root: Node;
118
+ box: Element;
119
+ }
120
+
121
+ /** @internal */
122
+ export function viewsOf(extensions: readonly ViewExtension[]): Views {
123
+ return {
124
+ nodes: new Map(extensions.flatMap((e) => Object.entries(e.nodeViews ?? {}))),
125
+ marks: new Map(extensions.flatMap((e) => Object.entries(e.markViews ?? {}))),
126
+ };
127
+ }
128
+
129
+ const NAME = /^[a-z_][\w.:-]*$/i;
130
+ const URL_ATTRS = new Set([
131
+ "href",
132
+ "src",
133
+ "xlink:href",
134
+ "action",
135
+ "formaction",
136
+ "poster",
137
+ "background",
138
+ ]);
139
+ /** Attributes holding several URLs: `srcset` (comma separated, each before its size), `ping`. */
140
+ const URL_LISTS: Record<string, (value: string) => string[]> = {
141
+ srcset: (value) => value.split(",").map((part) => part.trim().split(/\s+/)[0] ?? ""),
142
+ ping: (value) => value.split(/\s+/).filter(Boolean),
143
+ };
144
+ /** Style that fetches or runs something (escapes could spell it otherwise). */
145
+ const UNSAFE_STYLE = /url\s*\(|image-set|expression|@import|-moz-binding|behavior|\\/i;
146
+ /** Content elements a node view may make with `h` (no scripts, styles, forms, frames, `base`). */
147
+ const TAGS = new Set(
148
+ (
149
+ "a abbr address article aside audio b bdi bdo blockquote br button canvas caption cite code " +
150
+ "col colgroup data dd del details dfn div dl dt em figcaption figure footer h1 h2 h3 h4 h5 h6 " +
151
+ "header hgroup hr i img ins kbd label li mark meter ol p picture pre progress q rp rt ruby s " +
152
+ "samp section small source span strong sub summary sup table tbody td tfoot th thead time tr " +
153
+ "track u ul var video wbr"
154
+ ).split(" "),
155
+ );
156
+
157
+ /** Throws on an attribute a view must not set: handlers, editing, the view's own, unsafe URLs. */
158
+ function check(name: string, value: string): void {
159
+ const lower = name.toLowerCase();
160
+ if (
161
+ !NAME.test(name) ||
162
+ lower.startsWith("on") ||
163
+ lower === "contenteditable" ||
164
+ lower === "srcdoc" ||
165
+ lower.startsWith("data-foli-") ||
166
+ (URL_ATTRS.has(lower) && !isSafeHref(value)) ||
167
+ URL_LISTS[lower]?.(value).some((url) => !isSafeHref(url)) ||
168
+ (lower === "style" && UNSAFE_STYLE.test(value)) ||
169
+ (lower === "class" && /(^|\s)foli-/.test(value))
170
+ )
171
+ throw new TypeError(`Foli: attribute ${name} is not allowed on drawn content`);
172
+ }
173
+
174
+ /**
175
+ * Throws when `attrs` holds one an extension must not set (`check`).
176
+ * @internal
177
+ */
178
+ export function checkAttrs(attrs: DecorationAttrs): void {
179
+ for (const [name, value] of Object.entries(attrs)) if (value !== undefined) check(name, value);
180
+ }
181
+
182
+ /**
183
+ * Puts `attrs` on `element` (classes and style added, the rest set).
184
+ * @internal
185
+ */
186
+ export function applyAttrs(element: HTMLElement, attrs: DecorationAttrs): void {
187
+ checkAttrs(attrs);
188
+ for (const [name, value] of Object.entries(attrs)) {
189
+ if (value === undefined) continue;
190
+ if (name === "class") element.classList.add(...value.split(/\s+/).filter(Boolean));
191
+ else if (name === "style") {
192
+ const style = element.getAttribute("style")?.trim() ?? "";
193
+ element.setAttribute(
194
+ "style",
195
+ style && !style.endsWith(";") ? `${style};${value}` : style + value,
196
+ );
197
+ } else element.setAttribute(name, value);
198
+ }
199
+ }
200
+
201
+ /**
202
+ * Reports an extension's failure without stopping the editor.
203
+ * @internal
204
+ */
205
+ export function reportError(error: unknown): void {
206
+ console.error("Foli: an extension failed", error);
207
+ }
208
+
209
+ /** The DOM API node views draw with. @internal */
210
+ export function nodeViewDOM(document: Document): NodeViewDOM {
211
+ return {
212
+ document,
213
+ h(tag, attrs, ...children) {
214
+ if (!TAGS.has(tag.toLowerCase()))
215
+ throw new TypeError(`Foli: element ${tag} is not allowed in a node view`);
216
+ const element = document.createElement(tag);
217
+ if (attrs) applyAttrs(element, attrs);
218
+ element.append(...children);
219
+ return element;
220
+ },
221
+ };
222
+ }
223
+
224
+ /**
225
+ * The decorations of each block (`units`: the blocks drawn, in document order, with the position
226
+ * before each), relative to its content's start: a node decoration on the block itself is at -1.
227
+ * @internal
228
+ */
229
+ export function decorationsByBlock(
230
+ units: readonly { pos: number; node: ModelNode }[],
231
+ decorations: readonly Decoration[],
232
+ ): (readonly Decoration[] | undefined)[] {
233
+ const out: Decoration[][] = [];
234
+ const add = (i: number, d: Decoration) => {
235
+ const list = out[i] ?? [];
236
+ out[i] = list;
237
+ list.push(d);
238
+ };
239
+ for (const decoration of decorations) {
240
+ const { from, to } = decoration;
241
+ if (!(from <= to) || (!decoration.node && from === to)) continue;
242
+ // The first block ending after `from` (blocks do not overlap: their ends are sorted too).
243
+ let low = 0;
244
+ let high = units.length;
245
+ while (low < high) {
246
+ const mid = (low + high) >> 1;
247
+ const unit = units[mid] as { pos: number; node: ModelNode };
248
+ if (unit.pos + unit.node.nodeSize <= from) low = mid + 1;
249
+ else high = mid;
250
+ }
251
+ for (let i = low; i < units.length; i++) {
252
+ const { pos, node } = units[i] as { pos: number; node: ModelNode };
253
+ const start = pos + 1;
254
+ if (decoration.node) {
255
+ if (from >= pos && from < pos + node.nodeSize)
256
+ add(i, { ...decoration, from: from - start, to: to - start });
257
+ break;
258
+ }
259
+ if (pos >= to) break;
260
+ const end = pos + node.nodeSize - 1;
261
+ // A block leaf has no text to decorate.
262
+ if (!node.isLeaf && from < end && to > start)
263
+ add(i, { ...decoration, from: from - start, to: to - start });
264
+ }
265
+ }
266
+ return out;
267
+ }
package/src/index.ts CHANGED
@@ -1,4 +1,13 @@
1
1
  export { FOLI_MIME, htmlToDoc, textToDoc } from "./clipboard.js";
2
+ export type {
3
+ Decoration,
4
+ DecorationAttrs,
5
+ MarkView,
6
+ NodeView,
7
+ NodeViewDOM,
8
+ PluginView,
9
+ ViewExtension,
10
+ } from "./extension.js";
2
11
  export {
3
12
  EditorView,
4
13
  type EditorViewOptions,
@@ -9,6 +18,7 @@ export {
9
18
  export { EMU_PER_PX } from "./word/blocks.js";
10
19
  export {
11
20
  type DocumentPages,
21
+ type RenderDocumentOptions,
12
22
  type ReviewView,
13
23
  renderDocument,
14
24
  WORD_PAGE_CLASS,