@stll/folio-core 0.9.0 → 0.11.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 (69) hide show
  1. package/dist/ai-edits/headless.d.ts +52 -12
  2. package/dist/ai-edits/headless.js +181 -55
  3. package/dist/ai-edits/index.d.ts +2 -2
  4. package/dist/ai-edits/index.js +2 -2
  5. package/dist/controller/collaborationModules.d.ts +7 -0
  6. package/dist/controller/collaborationModules.js +15 -0
  7. package/dist/controller/folioEditor.d.ts +1 -1
  8. package/dist/controller/headerFooterEditorManager.d.ts +41 -0
  9. package/dist/controller/headerFooterEditorManager.js +182 -0
  10. package/dist/controller/hiddenEditorManager.d.ts +1 -1
  11. package/dist/controller/layoutPipeline.js +2 -1
  12. package/dist/document-operations.d.ts +11 -2
  13. package/dist/document-operations.js +7 -1
  14. package/dist/document-stories.d.ts +10 -0
  15. package/dist/document-stories.js +27 -0
  16. package/dist/docx/corePropertiesParser.d.ts +8 -0
  17. package/dist/docx/corePropertiesParser.js +53 -0
  18. package/dist/docx/index.d.ts +2 -1
  19. package/dist/docx/index.js +2 -1
  20. package/dist/docx/metadataPrivacy.d.ts +40 -0
  21. package/dist/docx/metadataPrivacy.js +131 -0
  22. package/dist/docx/parser.js +4 -1
  23. package/dist/docx/rezip.d.ts +5 -4
  24. package/dist/docx/rezip.js +6 -8
  25. package/dist/layout-bridge/convert/toFlowBlocks.js +1 -0
  26. package/dist/layout-engine/measure/cache.js +2 -7
  27. package/dist/layout-engine/measure/effectiveLineBreakPolicy.d.ts +29 -0
  28. package/dist/layout-engine/measure/effectiveLineBreakPolicy.js +60 -0
  29. package/dist/layout-engine/measure/measureParagraph.js +32 -36
  30. package/dist/layout-engine/measure/tableCellFloating.js +39 -33
  31. package/dist/layout-engine/types.d.ts +5 -3
  32. package/dist/managers/FindReplaceManager.d.ts +8 -0
  33. package/dist/managers/FindReplaceManager.js +18 -0
  34. package/dist/managers/TableSelectionManager.d.ts +6 -0
  35. package/dist/managers/TableSelectionManager.js +14 -0
  36. package/dist/prosemirror/attrs/index.js +1 -0
  37. package/dist/prosemirror/conversion/effectiveTableCellFormatting.d.ts +62 -0
  38. package/dist/prosemirror/conversion/effectiveTableCellFormatting.js +131 -0
  39. package/dist/prosemirror/conversion/fromProseDoc.js +1 -0
  40. package/dist/prosemirror/conversion/toProseDoc.js +40 -68
  41. package/dist/prosemirror/extensions/core/ParagraphExtension.js +1 -1
  42. package/dist/prosemirror/extensions/marks/HighlightExtension.js +1 -1
  43. package/dist/prosemirror/extensions/marks/RunShadingExtension.js +1 -1
  44. package/dist/prosemirror/extensions/marks/TextColorExtension.js +1 -1
  45. package/dist/prosemirror/extensions/nodes/ImageExtension.js +1 -0
  46. package/dist/prosemirror/extensions/nodes/TableExtension.js +1 -1
  47. package/dist/prosemirror/findReplaceSelection.d.ts +6 -1
  48. package/dist/prosemirror/findReplaceSelection.js +57 -13
  49. package/dist/prosemirror/schema/nodes.d.ts +2 -1
  50. package/dist/redline.d.ts +26 -11
  51. package/dist/redline.js +95 -62
  52. package/dist/render-dom/BodySelectionOverlay.d.ts +31 -0
  53. package/dist/render-dom/BodySelectionOverlay.js +76 -0
  54. package/dist/render-dom/HeaderFooterSelectionOverlay.d.ts +28 -0
  55. package/dist/render-dom/HeaderFooterSelectionOverlay.js +121 -0
  56. package/dist/render-dom/RemoteSelectionOverlay.d.ts +30 -0
  57. package/dist/render-dom/RemoteSelectionOverlay.js +67 -0
  58. package/dist/render-dom/RenderedDomContext.d.ts +40 -0
  59. package/dist/render-dom/RenderedDomContext.js +126 -0
  60. package/dist/render-dom/resolveSidebarItemPositions.d.ts +33 -0
  61. package/dist/render-dom/resolveSidebarItemPositions.js +45 -0
  62. package/dist/server.d.ts +5 -4
  63. package/dist/server.js +5 -4
  64. package/dist/utils/findReplace.d.ts +32 -0
  65. package/dist/utils/findReplace.js +118 -0
  66. package/dist/utils/headerFooter.js +24 -1
  67. package/dist/version-comparison.d.ts +65 -11
  68. package/dist/version-comparison.js +187 -29
  69. package/package.json +1 -1
@@ -0,0 +1,76 @@
1
+ import { findBodyPmAnchor } from "../layout-bridge/dom/findBodyPmSpans.js";
2
+ import { applyCellSelectionHighlight } from "../layout-bridge/cellSelectionHighlight.js";
3
+ import { findImageElement } from "../layout-painter/imageLayout.js";
4
+ import { getCaretPositionFromDom, getSelectionRectsFromDom } from "../layout-bridge/dom/clickToPositionDom.js";
5
+ import { NodeSelection } from "prosemirror-state";
6
+ //#region src/render-dom/BodySelectionOverlay.ts
7
+ /**
8
+ * Imperative body-selection painter shared by framework adapters. The editable
9
+ * ProseMirror view is hidden, so its caret, range selection, and table-cell
10
+ * selection must be projected onto the paginated DOM.
11
+ */
12
+ const CARET_CLASS = "folio-body-selection-caret";
13
+ const RANGE_CLASS = "folio-body-selection-rect";
14
+ const OWNED_OVERLAY_SELECTOR = `.${CARET_CLASS}, .${RANGE_CLASS}`;
15
+ const setOverlayBox = (element, rect, pagesContainer, zoom) => {
16
+ const divisor = zoom > 0 ? zoom : 1;
17
+ element.style.left = `${rect.x / divisor + pagesContainer.scrollLeft}px`;
18
+ element.style.top = `${rect.y / divisor + pagesContainer.scrollTop}px`;
19
+ element.style.width = `${rect.width / divisor}px`;
20
+ element.style.height = `${rect.height / divisor}px`;
21
+ };
22
+ var BodySelectionOverlay = class {
23
+ clear(pagesContainer) {
24
+ for (const element of pagesContainer.querySelectorAll(OWNED_OVERLAY_SELECTOR)) element.remove();
25
+ }
26
+ sync({ pagesContainer, state, zoom, zIndex = 10, caretColor = "var(--doc-caret, #000)", selectionColor = "var(--doc-selection, rgba(66, 133, 244, 0.3))" }) {
27
+ this.clear(pagesContainer);
28
+ applyCellSelectionHighlight(pagesContainer, state);
29
+ const { selection } = state;
30
+ if (selection instanceof NodeSelection && selection.node.type.name === "image") {
31
+ const anchor = findBodyPmAnchor(pagesContainer, selection.from);
32
+ const element = anchor ? findImageElement(anchor) : null;
33
+ if (element) return {
34
+ type: "image",
35
+ element,
36
+ pmPos: selection.from
37
+ };
38
+ }
39
+ if (selection.empty) {
40
+ const caret = getCaretPositionFromDom(pagesContainer, selection.from, pagesContainer.getBoundingClientRect());
41
+ if (!caret) return { type: "text" };
42
+ const element = pagesContainer.ownerDocument.createElement("div");
43
+ element.className = CARET_CLASS;
44
+ element.dataset["folioCaretRect"] = "";
45
+ element.style.position = "absolute";
46
+ element.style.background = caretColor;
47
+ element.style.pointerEvents = "none";
48
+ element.style.zIndex = String(zIndex);
49
+ element.style.animation = "folio-caret-blink 1060ms steps(1, end) infinite";
50
+ setOverlayBox(element, {
51
+ x: caret.x,
52
+ y: caret.y,
53
+ width: 2 * (zoom > 0 ? zoom : 1),
54
+ height: caret.height
55
+ }, pagesContainer, zoom);
56
+ pagesContainer.appendChild(element);
57
+ return { type: "text" };
58
+ }
59
+ const rects = getSelectionRectsFromDom(pagesContainer, selection.from, selection.to, pagesContainer.getBoundingClientRect());
60
+ for (const rect of rects) {
61
+ const element = pagesContainer.ownerDocument.createElement("div");
62
+ element.className = RANGE_CLASS;
63
+ element.dataset["folioSelectionRect"] = "";
64
+ element.dataset["pageIndex"] = String(rect.pageIndex);
65
+ element.style.position = "absolute";
66
+ element.style.background = selectionColor;
67
+ element.style.pointerEvents = "none";
68
+ element.style.zIndex = String(zIndex);
69
+ setOverlayBox(element, rect, pagesContainer, zoom);
70
+ pagesContainer.appendChild(element);
71
+ }
72
+ return { type: "text" };
73
+ }
74
+ };
75
+ //#endregion
76
+ export { BodySelectionOverlay };
@@ -0,0 +1,28 @@
1
+ import { HfSlotKind } from "../layout-bridge/dom/findHfPmSpans.js";
2
+
3
+ //#region src/render-dom/HeaderFooterSelectionOverlay.d.ts
4
+ type HeaderFooterSelection = {
5
+ from: number;
6
+ kind: HfSlotKind;
7
+ pageNumber?: number;
8
+ rId: string;
9
+ to: number;
10
+ };
11
+ type HeaderFooterSelectionRect = {
12
+ height: number;
13
+ width: number;
14
+ x: number;
15
+ y: number;
16
+ };
17
+ type HeaderFooterSelectionGeometry = {
18
+ caret: Omit<HeaderFooterSelectionRect, "width"> | null;
19
+ ranges: HeaderFooterSelectionRect[];
20
+ };
21
+ /** Resolve a persistent header/footer PM selection against its painted DOM. */
22
+ declare const resolveHeaderFooterSelectionGeometry: (pagesContainer: HTMLElement, selection: HeaderFooterSelection, zoom: number) => HeaderFooterSelectionGeometry;
23
+ declare class HeaderFooterSelectionOverlay {
24
+ clear(pagesContainer: HTMLElement): void;
25
+ sync(pagesContainer: HTMLElement, selection: HeaderFooterSelection | null, zoom: number): void;
26
+ }
27
+ //#endregion
28
+ export { HeaderFooterSelection, HeaderFooterSelectionGeometry, HeaderFooterSelectionOverlay, HeaderFooterSelectionRect, resolveHeaderFooterSelectionGeometry };
@@ -0,0 +1,121 @@
1
+ import { findHfCaretSpan, findHfPmSpans } from "../layout-bridge/dom/findHfPmSpans.js";
2
+ //#region src/render-dom/HeaderFooterSelectionOverlay.ts
3
+ const CARET_CLASS = "folio-hf-selection-caret";
4
+ const RANGE_CLASS = "folio-hf-selection-rect";
5
+ const OWNED_SELECTOR = `.${CARET_CLASS}, .${RANGE_CLASS}`;
6
+ const TEXT_NODE_TYPE = 3;
7
+ const relativeRect = (rect, containerRect, zoom) => ({
8
+ x: (rect.left - containerRect.left) / zoom,
9
+ y: (rect.top - containerRect.top) / zoom,
10
+ width: rect.width / zoom,
11
+ height: rect.height / zoom
12
+ });
13
+ /** Resolve a persistent header/footer PM selection against its painted DOM. */
14
+ const resolveHeaderFooterSelectionGeometry = (pagesContainer, selection, zoom) => {
15
+ const containerRect = pagesContainer.getBoundingClientRect();
16
+ const zoomDivisor = zoom === 0 ? 1 : zoom;
17
+ const pageScope = selection.pageNumber ? pagesContainer.querySelector(`.layout-page[data-page-number="${selection.pageNumber}"]`) ?? pagesContainer : pagesContainer;
18
+ if (selection.from === selection.to) {
19
+ const hit = findHfCaretSpan(pageScope, selection.kind, selection.rId, selection.from);
20
+ if (!hit) return {
21
+ caret: null,
22
+ ranges: []
23
+ };
24
+ const anchorRect = hit.element.getBoundingClientRect();
25
+ let left = hit.edge === "right" ? anchorRect.right : anchorRect.left;
26
+ let top = anchorRect.top;
27
+ let height = anchorRect.height || 16;
28
+ const pmStart = Number.parseInt(hit.element.dataset["pmStart"] ?? "", 10);
29
+ const pmEnd = Number.parseInt(hit.element.dataset["pmEnd"] ?? "", 10);
30
+ const textNode = hit.element.firstChild;
31
+ if (textNode?.nodeType === TEXT_NODE_TYPE && Number.isFinite(pmStart) && Number.isFinite(pmEnd)) {
32
+ const offset = Math.min(Math.max(0, selection.from - pmStart), textNode.textContent?.length ?? 0);
33
+ const range = hit.element.ownerDocument.createRange();
34
+ range.setStart(textNode, offset);
35
+ range.setEnd(textNode, offset);
36
+ const rangeRect = range.getBoundingClientRect();
37
+ if (rangeRect.height > 0 || rangeRect.width > 0 || rangeRect.left > 0) {
38
+ left = rangeRect.left;
39
+ top = rangeRect.top;
40
+ height = rangeRect.height || height;
41
+ }
42
+ }
43
+ return {
44
+ caret: {
45
+ x: (left - containerRect.left) / zoomDivisor,
46
+ y: (top - containerRect.top) / zoomDivisor,
47
+ height: height / zoomDivisor
48
+ },
49
+ ranges: []
50
+ };
51
+ }
52
+ const from = Math.min(selection.from, selection.to);
53
+ const to = Math.max(selection.from, selection.to);
54
+ const ranges = [];
55
+ for (const span of findHfPmSpans(pageScope, selection.kind, selection.rId)) {
56
+ const spanStart = Number.parseInt(span.dataset["pmStart"] ?? "", 10);
57
+ const spanEnd = Number.parseInt(span.dataset["pmEnd"] ?? "", 10);
58
+ if (!Number.isFinite(spanStart) || !Number.isFinite(spanEnd)) continue;
59
+ if (spanEnd <= from || spanStart >= to) continue;
60
+ const textNode = span.firstChild;
61
+ if (textNode?.nodeType === TEXT_NODE_TYPE) {
62
+ const length = textNode.textContent?.length ?? 0;
63
+ const startOffset = Math.max(0, from - spanStart);
64
+ const endOffset = Math.min(length, to - spanStart);
65
+ if (startOffset < endOffset) {
66
+ const range = span.ownerDocument.createRange();
67
+ range.setStart(textNode, startOffset);
68
+ range.setEnd(textNode, endOffset);
69
+ for (const rect of Array.from(range.getClientRects())) ranges.push(relativeRect(rect, containerRect, zoomDivisor));
70
+ continue;
71
+ }
72
+ }
73
+ ranges.push(relativeRect(span.getBoundingClientRect(), containerRect, zoomDivisor));
74
+ }
75
+ return {
76
+ caret: null,
77
+ ranges
78
+ };
79
+ };
80
+ const createOverlayElement = (pagesContainer, className) => {
81
+ const element = pagesContainer.ownerDocument.createElement("div");
82
+ element.className = className;
83
+ element.style.position = "absolute";
84
+ element.style.pointerEvents = "none";
85
+ return element;
86
+ };
87
+ var HeaderFooterSelectionOverlay = class {
88
+ clear(pagesContainer) {
89
+ for (const element of pagesContainer.querySelectorAll(OWNED_SELECTOR)) element.remove();
90
+ }
91
+ sync(pagesContainer, selection, zoom) {
92
+ this.clear(pagesContainer);
93
+ if (!selection) return;
94
+ const geometry = resolveHeaderFooterSelectionGeometry(pagesContainer, selection, zoom);
95
+ for (const rect of geometry.ranges) {
96
+ const element = createOverlayElement(pagesContainer, RANGE_CLASS);
97
+ element.dataset["testid"] = "hf-selection-rect";
98
+ element.style.left = `${rect.x}px`;
99
+ element.style.top = `${rect.y}px`;
100
+ element.style.width = `${rect.width}px`;
101
+ element.style.height = `${rect.height}px`;
102
+ element.style.background = "var(--doc-selection, rgba(66, 133, 244, 0.3))";
103
+ element.style.opacity = "0.35";
104
+ element.style.zIndex = "10";
105
+ pagesContainer.append(element);
106
+ }
107
+ if (!geometry.caret) return;
108
+ const caret = createOverlayElement(pagesContainer, CARET_CLASS);
109
+ caret.dataset["testid"] = "hf-caret";
110
+ caret.style.left = `${geometry.caret.x}px`;
111
+ caret.style.top = `${geometry.caret.y}px`;
112
+ caret.style.width = "2px";
113
+ caret.style.height = `${geometry.caret.height}px`;
114
+ caret.style.background = "var(--doc-canvas-text, #000)";
115
+ caret.style.zIndex = "11";
116
+ caret.style.animation = "folio-caret-blink 1060ms steps(1, end) infinite";
117
+ pagesContainer.append(caret);
118
+ }
119
+ };
120
+ //#endregion
121
+ export { HeaderFooterSelectionOverlay, resolveHeaderFooterSelectionGeometry };
@@ -0,0 +1,30 @@
1
+ import { HiddenProseMirrorRemoteSelection } from "../controller/hiddenEditorManager.js";
2
+ import { RenderedDomContext, RenderedDomPoint, RenderedDomRect } from "./RenderedDomContext.js";
3
+
4
+ //#region src/render-dom/RemoteSelectionOverlay.d.ts
5
+ type SyncRemoteSelectionOverlayOptions = {
6
+ pagesContainer: HTMLElement;
7
+ selections: readonly HiddenProseMirrorRemoteSelection[];
8
+ zoom: number;
9
+ zIndex?: number;
10
+ renderedDomContext?: RenderedDomContext;
11
+ };
12
+ type RemoteSelectionOverlayGeometry = {
13
+ caret: RenderedDomPoint | null;
14
+ rects: RenderedDomRect[];
15
+ selection: HiddenProseMirrorRemoteSelection;
16
+ };
17
+ declare const resolveRemoteSelectionOverlayGeometry: (renderedDomContext: RenderedDomContext, selections: readonly HiddenProseMirrorRemoteSelection[]) => RemoteSelectionOverlayGeometry[];
18
+ /** Paint collaborative cursors and selections over the rendered page DOM. */
19
+ declare class RemoteSelectionOverlay {
20
+ clear(pagesContainer: HTMLElement): void;
21
+ sync({
22
+ pagesContainer,
23
+ selections,
24
+ zoom,
25
+ zIndex,
26
+ renderedDomContext
27
+ }: SyncRemoteSelectionOverlayOptions): void;
28
+ }
29
+ //#endregion
30
+ export { RemoteSelectionOverlay, RemoteSelectionOverlayGeometry, SyncRemoteSelectionOverlayOptions, resolveRemoteSelectionOverlayGeometry };
@@ -0,0 +1,67 @@
1
+ import { createRenderedDomContext } from "./RenderedDomContext.js";
2
+ //#region src/render-dom/RemoteSelectionOverlay.ts
3
+ const CARET_CLASS = "folio-remote-selection-caret";
4
+ const LABEL_CLASS = "folio-remote-selection-label";
5
+ const RANGE_CLASS = "folio-remote-selection-rect";
6
+ const OWNED_OVERLAY_SELECTOR = `.${CARET_CLASS}, .${LABEL_CLASS}, .${RANGE_CLASS}`;
7
+ const resolveRemoteSelectionOverlayGeometry = (renderedDomContext, selections) => selections.map((selection) => ({
8
+ caret: renderedDomContext.getCoordinatesForPosition(selection.head),
9
+ rects: renderedDomContext.getRectsForRange(Math.min(selection.anchor, selection.head), Math.max(selection.anchor, selection.head)),
10
+ selection
11
+ }));
12
+ const setBox = (element, rect) => {
13
+ element.style.left = `${rect.x}px`;
14
+ element.style.top = `${rect.y}px`;
15
+ element.style.width = `${rect.width}px`;
16
+ element.style.height = `${rect.height}px`;
17
+ };
18
+ const createOverlayElement = (pagesContainer, className, zIndex) => {
19
+ const element = pagesContainer.ownerDocument.createElement("div");
20
+ element.className = className;
21
+ element.style.position = "absolute";
22
+ element.style.pointerEvents = "none";
23
+ element.style.zIndex = String(zIndex);
24
+ return element;
25
+ };
26
+ /** Paint collaborative cursors and selections over the rendered page DOM. */
27
+ var RemoteSelectionOverlay = class {
28
+ clear(pagesContainer) {
29
+ for (const element of pagesContainer.querySelectorAll(OWNED_OVERLAY_SELECTOR)) element.remove();
30
+ }
31
+ sync({ pagesContainer, selections, zoom, zIndex = 20, renderedDomContext = createRenderedDomContext(pagesContainer, zoom) }) {
32
+ this.clear(pagesContainer);
33
+ for (const { caret, rects, selection } of resolveRemoteSelectionOverlayGeometry(renderedDomContext, selections)) {
34
+ for (const rect of rects) {
35
+ const element = createOverlayElement(pagesContainer, RANGE_CLASS, zIndex);
36
+ element.dataset["clientId"] = String(selection.clientId);
37
+ element.style.background = `color-mix(in srgb, ${selection.color} 24%, transparent)`;
38
+ setBox(element, rect);
39
+ pagesContainer.appendChild(element);
40
+ }
41
+ if (!caret) continue;
42
+ const caretElement = createOverlayElement(pagesContainer, CARET_CLASS, zIndex + 1);
43
+ caretElement.dataset["clientId"] = String(selection.clientId);
44
+ caretElement.style.background = selection.color;
45
+ setBox(caretElement, {
46
+ ...caret,
47
+ width: 2
48
+ });
49
+ pagesContainer.appendChild(caretElement);
50
+ const label = createOverlayElement(pagesContainer, LABEL_CLASS, zIndex + 2);
51
+ label.dataset["clientId"] = String(selection.clientId);
52
+ label.textContent = selection.name;
53
+ label.style.background = selection.color;
54
+ label.style.color = "var(--background, #fff)";
55
+ label.style.fontSize = "10px";
56
+ label.style.lineHeight = "1";
57
+ label.style.padding = "2px 4px";
58
+ label.style.borderRadius = "2px";
59
+ label.style.left = `${caret.x}px`;
60
+ label.style.top = `${Math.max(0, caret.y - 18)}px`;
61
+ label.style.whiteSpace = "nowrap";
62
+ pagesContainer.appendChild(label);
63
+ }
64
+ }
65
+ };
66
+ //#endregion
67
+ export { RemoteSelectionOverlay, resolveRemoteSelectionOverlayGeometry };
@@ -0,0 +1,40 @@
1
+ //#region src/render-dom/RenderedDomContext.d.ts
2
+ /**
3
+ * Framework-neutral mapping from ProseMirror positions to the DOM emitted by
4
+ * the layout painter. Framework adapters use this for decorations, anchored
5
+ * chrome, and plugin surfaces without duplicating range geometry.
6
+ */
7
+ type RenderedDomPoint = {
8
+ x: number;
9
+ y: number;
10
+ height: number;
11
+ };
12
+ type RenderedDomRect = {
13
+ x: number;
14
+ y: number;
15
+ width: number;
16
+ height: number;
17
+ };
18
+ type RenderedDomContext = {
19
+ getCoordinatesForPosition(pmPos: number): RenderedDomPoint | null;
20
+ findElementsForRange(from: number, to: number): Element[];
21
+ getRectsForRange(from: number, to: number): RenderedDomRect[];
22
+ getContainerOffset(): {
23
+ x: number;
24
+ y: number;
25
+ };
26
+ };
27
+ declare class RenderedDomContextImpl implements RenderedDomContext {
28
+ #private;
29
+ constructor(pagesContainer: HTMLElement, zoom?: number);
30
+ getCoordinatesForPosition(pmPos: number): RenderedDomPoint | null;
31
+ findElementsForRange(from: number, to: number): Element[];
32
+ getRectsForRange(from: number, to: number): RenderedDomRect[];
33
+ getContainerOffset(): {
34
+ x: number;
35
+ y: number;
36
+ };
37
+ }
38
+ declare const createRenderedDomContext: (pagesContainer: HTMLElement, zoom?: number) => RenderedDomContext;
39
+ //#endregion
40
+ export { RenderedDomContext, RenderedDomContextImpl, RenderedDomPoint, RenderedDomRect, createRenderedDomContext };
@@ -0,0 +1,126 @@
1
+ import { findBodyEmptyRuns, findBodyPmSpans } from "../layout-bridge/dom/findBodyPmSpans.js";
2
+ import { closestHtmlElement } from "../utils/domGuards.js";
3
+ //#region src/render-dom/RenderedDomContext.ts
4
+ /**
5
+ * Framework-neutral mapping from ProseMirror positions to the DOM emitted by
6
+ * the layout painter. Framework adapters use this for decorations, anchored
7
+ * chrome, and plugin surfaces without duplicating range geometry.
8
+ */
9
+ const isTextNode = (node) => node?.nodeType === Node.TEXT_NODE;
10
+ const textNodeForSpan = (span) => {
11
+ const firstChild = span.firstChild;
12
+ if (isTextNode(firstChild)) return firstChild;
13
+ if (firstChild instanceof HTMLElement && firstChild.tagName === "A" && isTextNode(firstChild.firstChild)) return firstChild.firstChild;
14
+ return null;
15
+ };
16
+ const lineHeightFor = (element, zoom) => {
17
+ const line = closestHtmlElement(element, ".layout-line");
18
+ return line ? line.getBoundingClientRect().height / zoom : 16;
19
+ };
20
+ var RenderedDomContextImpl = class {
21
+ #pagesContainer;
22
+ #zoom;
23
+ constructor(pagesContainer, zoom = 1) {
24
+ this.#pagesContainer = pagesContainer;
25
+ this.#zoom = zoom > 0 ? zoom : 1;
26
+ }
27
+ getCoordinatesForPosition(pmPos) {
28
+ const containerRect = this.#pagesContainer.getBoundingClientRect();
29
+ for (const span of findBodyPmSpans(this.#pagesContainer)) {
30
+ const pmStart = Number(span.dataset["pmStart"]);
31
+ const pmEnd = Number(span.dataset["pmEnd"]);
32
+ if (!(span.classList.contains("layout-run-tab") ? pmPos >= pmStart && pmPos < pmEnd : pmPos >= pmStart && pmPos <= pmEnd)) continue;
33
+ const spanRect = span.getBoundingClientRect();
34
+ if (span.classList.contains("layout-run-tab")) return {
35
+ x: (spanRect.left - containerRect.left) / this.#zoom,
36
+ y: (spanRect.top - containerRect.top) / this.#zoom,
37
+ height: lineHeightFor(span, this.#zoom)
38
+ };
39
+ const textNode = textNodeForSpan(span);
40
+ if (!textNode) return {
41
+ x: (spanRect.left - containerRect.left) / this.#zoom,
42
+ y: (spanRect.top - containerRect.top) / this.#zoom,
43
+ height: lineHeightFor(span, this.#zoom)
44
+ };
45
+ const charIndex = Math.min(Math.max(0, pmPos - pmStart), textNode.length);
46
+ const range = span.ownerDocument.createRange();
47
+ range.setStart(textNode, charIndex);
48
+ range.setEnd(textNode, charIndex);
49
+ const rangeRect = range.getBoundingClientRect();
50
+ return {
51
+ x: (rangeRect.left - containerRect.left) / this.#zoom,
52
+ y: (rangeRect.top - containerRect.top) / this.#zoom,
53
+ height: lineHeightFor(span, this.#zoom)
54
+ };
55
+ }
56
+ for (const emptyRun of findBodyEmptyRuns(this.#pagesContainer)) {
57
+ const paragraph = closestHtmlElement(emptyRun, ".layout-paragraph");
58
+ if (!paragraph) continue;
59
+ const pmStart = Number(paragraph.dataset["pmStart"]);
60
+ const pmEnd = Number(paragraph.dataset["pmEnd"]);
61
+ if (pmPos < pmStart || pmPos > pmEnd) continue;
62
+ const rect = emptyRun.getBoundingClientRect();
63
+ return {
64
+ x: (rect.left - containerRect.left) / this.#zoom,
65
+ y: (rect.top - containerRect.top) / this.#zoom,
66
+ height: lineHeightFor(emptyRun, this.#zoom)
67
+ };
68
+ }
69
+ return null;
70
+ }
71
+ findElementsForRange(from, to) {
72
+ return findBodyPmSpans(this.#pagesContainer).filter((span) => {
73
+ const pmStart = Number(span.dataset["pmStart"]);
74
+ return Number(span.dataset["pmEnd"]) > from && pmStart < to;
75
+ });
76
+ }
77
+ getRectsForRange(from, to) {
78
+ const containerRect = this.#pagesContainer.getBoundingClientRect();
79
+ const rects = [];
80
+ for (const element of this.findElementsForRange(from, to)) {
81
+ if (!(element instanceof HTMLElement)) continue;
82
+ const pmStart = Number(element.dataset["pmStart"]);
83
+ if (element.classList.contains("layout-run-tab")) {
84
+ const rect = element.getBoundingClientRect();
85
+ rects.push({
86
+ x: (rect.left - containerRect.left) / this.#zoom,
87
+ y: (rect.top - containerRect.top) / this.#zoom,
88
+ width: rect.width / this.#zoom,
89
+ height: rect.height / this.#zoom
90
+ });
91
+ continue;
92
+ }
93
+ const textNode = textNodeForSpan(element);
94
+ if (!textNode) continue;
95
+ const startChar = Math.max(0, from - pmStart);
96
+ const endChar = Math.min(textNode.length, to - pmStart);
97
+ if (startChar >= endChar) continue;
98
+ const range = element.ownerDocument.createRange();
99
+ range.setStart(textNode, startChar);
100
+ range.setEnd(textNode, endChar);
101
+ for (const rect of Array.from(range.getClientRects())) rects.push({
102
+ x: (rect.left - containerRect.left) / this.#zoom,
103
+ y: (rect.top - containerRect.top) / this.#zoom,
104
+ width: rect.width / this.#zoom,
105
+ height: rect.height / this.#zoom
106
+ });
107
+ }
108
+ return rects;
109
+ }
110
+ getContainerOffset() {
111
+ const parent = this.#pagesContainer.parentElement;
112
+ if (!parent) return {
113
+ x: 0,
114
+ y: 0
115
+ };
116
+ const containerRect = this.#pagesContainer.getBoundingClientRect();
117
+ const parentRect = parent.getBoundingClientRect();
118
+ return {
119
+ x: (containerRect.left - parentRect.left) / this.#zoom,
120
+ y: (containerRect.top - parentRect.top) / this.#zoom
121
+ };
122
+ }
123
+ };
124
+ const createRenderedDomContext = (pagesContainer, zoom = 1) => new RenderedDomContextImpl(pagesContainer, zoom);
125
+ //#endregion
126
+ export { RenderedDomContextImpl, createRenderedDomContext };
@@ -0,0 +1,33 @@
1
+ import { RenderedDomContext } from "./RenderedDomContext.js";
2
+
3
+ //#region src/render-dom/resolveSidebarItemPositions.d.ts
4
+ type RenderedSidebarItem = {
5
+ id: string;
6
+ anchorPos: number;
7
+ anchorKey?: string;
8
+ priority?: number;
9
+ fixedY?: number;
10
+ estimatedHeight?: number;
11
+ };
12
+ type ResolvedSidebarItemPosition<T extends RenderedSidebarItem = RenderedSidebarItem> = {
13
+ item: T;
14
+ y: number;
15
+ };
16
+ type ResolveSidebarItemPositionsOptions<T extends RenderedSidebarItem> = {
17
+ items: T[];
18
+ anchorPositions: Map<string, number>;
19
+ renderedDomContext: RenderedDomContext | null;
20
+ zoom: number;
21
+ cardHeights: Map<string, number>;
22
+ lastKnown: Map<string, number>;
23
+ };
24
+ declare const resolveSidebarItemPositions: <T extends RenderedSidebarItem>({
25
+ items,
26
+ anchorPositions,
27
+ renderedDomContext,
28
+ zoom,
29
+ cardHeights,
30
+ lastKnown
31
+ }: ResolveSidebarItemPositionsOptions<T>) => ResolvedSidebarItemPosition<T>[];
32
+ //#endregion
33
+ export { RenderedSidebarItem, ResolveSidebarItemPositionsOptions, ResolvedSidebarItemPosition, resolveSidebarItemPositions };
@@ -0,0 +1,45 @@
1
+ //#region src/render-dom/resolveSidebarItemPositions.ts
2
+ const MIN_CARD_GAP = 8;
3
+ const resolveSidebarItemPositions = ({ items, anchorPositions, renderedDomContext, zoom, cardHeights, lastKnown }) => {
4
+ if (items.length === 0) return [];
5
+ const containerOffset = renderedDomContext?.getContainerOffset();
6
+ const positioned = [];
7
+ for (const item of items) {
8
+ let targetY;
9
+ if (item.fixedY !== void 0) targetY = item.fixedY * zoom;
10
+ if (targetY === void 0 && item.anchorKey !== void 0) {
11
+ const anchorY = anchorPositions.get(item.anchorKey);
12
+ if (anchorY !== void 0) targetY = anchorY * zoom;
13
+ }
14
+ if (targetY === void 0 && renderedDomContext && containerOffset) {
15
+ const rect = renderedDomContext.getRectsForRange(item.anchorPos, item.anchorPos + 1).at(0);
16
+ if (rect) targetY = (rect.y + containerOffset.y) * zoom;
17
+ }
18
+ if (targetY === void 0) targetY = lastKnown.get(item.id);
19
+ if (targetY === void 0) continue;
20
+ positioned.push({
21
+ item,
22
+ targetY
23
+ });
24
+ lastKnown.set(item.id, targetY);
25
+ }
26
+ positioned.sort((left, right) => {
27
+ const positionDifference = left.targetY - right.targetY;
28
+ if (positionDifference !== 0) return positionDifference;
29
+ return (left.item.priority ?? 0) - (right.item.priority ?? 0);
30
+ });
31
+ const resolved = [];
32
+ let previousBottom = 0;
33
+ for (const position of positioned) {
34
+ const height = cardHeights.get(position.item.id) ?? position.item.estimatedHeight ?? 80;
35
+ const y = Math.max(position.targetY, previousBottom + MIN_CARD_GAP);
36
+ resolved.push({
37
+ item: position.item,
38
+ y
39
+ });
40
+ previousBottom = y + height;
41
+ }
42
+ return resolved;
43
+ };
44
+ //#endregion
45
+ export { resolveSidebarItemPositions };
package/dist/server.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { FolioAIBlock, FolioAIBlockAnchor, FolioAIBlockKind, FolioAIBlockPreviewRun, FolioAIComment, FolioAIEditApplyMode, FolioAIEditApplyResult, FolioAIEditOperation, FolioAIEditPrecondition, FolioAIEditSnapshot, FolioAIInlineFormatting, FolioAITextRangeHandle, FolioDocumentNavigationTarget, FolioDocumentOutline, FolioDocumentOutlineEntry, FolioDocumentSection, FolioDocumentSectionHandle, FolioDocumentSectionReadResult } from "./ai-edits/types.js";
2
2
  import { FOLIO_DOCUMENT_OPERATION_BATCH_MODES, FOLIO_DOCUMENT_OPERATION_CONTRACT_VERSION, FOLIO_DOCUMENT_OPERATION_MODES, FOLIO_DOCUMENT_OPERATION_MODES_BY_TYPE, FOLIO_DOCUMENT_OPERATION_PRECONDITIONS, FOLIO_DOCUMENT_OPERATION_STORIES, FOLIO_DOCUMENT_OPERATION_TYPES, FolioDocumentOperation, FolioDocumentOperationAffectedTarget, FolioDocumentOperationBatch, FolioDocumentOperationCapabilities, FolioDocumentOperationIssue, FolioDocumentOperationMode, FolioDocumentOperationPrecondition, FolioDocumentOperationReceipt, FolioDocumentOperationRecovery, FolioDocumentOperationResult, FolioDocumentOperationStatus, FolioDocumentOperationStory, FolioDocumentOperationType, FolioDocumentOperationUndoFailureReason, FolioDocumentOperationUndoHandle, FolioDocumentOperationUndoResult, InvalidFolioDocumentOperationBatchError, UnsupportedFolioDocumentOperationVersionError, assertSupportedFolioDocumentOperationVersion, getFolioDocumentOperationCapabilities, getFolioDocumentOperationIssues, getFolioDocumentOperationReceipts, isFolioDocumentOperationModeSupported, isSupportedFolioDocumentOperationVersion, parseFolioDocumentOperationBatch } from "./document-operations.js";
3
3
  import { FolioReviewChange, FolioReviewChangeKind } from "./ai-edits/read.js";
4
- import { ApplyFolioAIEditsToBufferOptions, ApplyFolioAIEditsToBufferResult, FolioApplyDocumentOperationsOptions, FolioApplyDocumentOperationsToStoryOptions, FolioApplyOperationsOptions, FolioDocumentStory, FolioDocumentStoryHandle, FolioDocumentStoryNotFoundError, FolioDocxReviewer, FolioDocxReviewerOptions, FolioEditableDocumentStoryHandle, FolioReviewChangeFilter, FolioReviewComment, FolioReviewCommentFilter, FolioReviewCommentReply, FolioReviewReplyInput, applyFolioAIEditsToBuffer } from "./ai-edits/headless.js";
4
+ import { ApplyFolioAIEditsToBufferOptions, ApplyFolioAIEditsToBufferResult, FOLIO_RESOLVED_REVIEWED_VIEWS, FOLIO_REVIEWED_VIEWS, FolioApplyDocumentOperationsOptions, FolioApplyDocumentOperationsToStoryOptions, FolioApplyOperationsOptions, FolioDocumentStory, FolioDocumentStoryHandle, FolioDocumentStoryNotFoundError, FolioDocxReviewer, FolioDocxReviewerOptions, FolioEditableDocumentStoryHandle, FolioReadReviewedStoryOptions, FolioResolveReviewedStoryOptions, FolioResolvedReviewedView, FolioReviewChangeFilter, FolioReviewComment, FolioReviewCommentFilter, FolioReviewCommentReply, FolioReviewReplyInput, FolioReviewedStory, FolioReviewedView, UnsupportedFolioReviewedViewError, applyFolioAIEditsToBuffer, isFolioResolvedReviewedView, isFolioReviewedView } from "./ai-edits/headless.js";
5
5
  import { createFolioAITextRangeHandle } from "./ai-edits/snapshot.js";
6
6
  import { getFolioDocumentOutline, readFolioDocumentSection } from "./ai-edits/scoped-reading.js";
7
7
  import { DeriveBlockIdInput, FolioBlockId, deriveBlockId, getFolioParaIdFromBlockId, isFolioBlockId, isSequentialFolioBlockId } from "./types/block-id.js";
@@ -11,9 +11,10 @@ import { DocumentStyleCatalog, DocumentStyleCatalogEntry, ExtractDocumentStyleSe
11
11
  import { STELLA_STYLE_SET_NAME, createStellaStyleDocumentPreset, createStellaStyleSet } from "./style-sets/stellaStyle.js";
12
12
  import { createDocx } from "./docx/rezip.js";
13
13
  import { EnsureParaIdsError, EnsureParaIdsOptions, EnsureParaIdsResult, ensureParaIds } from "./docx/ensureParaIds.js";
14
+ import { FOLIO_DOCUMENT_METADATA_PROPERTIES, FOLIO_DOCUMENT_PRIVACY_TRANSFORMS, FolioDocumentMetadataProperty, FolioDocumentPrivacyArchiveError, FolioDocumentPrivacyOptions, FolioDocumentPrivacyReport, FolioDocumentPrivacyTransform, InvalidFolioDocumentPrivacyOptionsError, RewriteDocxMetadataPrivacyResult, isFolioDocumentPrivacyTransform, rewriteDocxMetadataPrivacy } from "./docx/metadataPrivacy.js";
14
15
  import { CreateCommentReplyInput, replyToComment } from "./docx/replyToComment.js";
15
16
  import { DocxArchiveError } from "./docx/server/boundedArchive.js";
16
17
  import { DocxParagraphSource, ExtractedDocxParagraph, ExtractedDocxText, extractDocxText } from "./docx/server/extractDocxText.js";
17
- import { GenerateRedlineDocxOptions, GenerateRedlineDocxResult, generateRedlineDocx } from "./redline.js";
18
- import { FolioBlockDiff, FolioFormatProperty, FolioVersionDiff, FolioVersionDiffSegment, compareDocxVersions } from "./version-comparison.js";
19
- export { type ApplyFolioAIEditsToBufferOptions, type ApplyFolioAIEditsToBufferResult, type CreateCommentReplyInput, type CreateEmptyDocumentOptions, DOCUMENT_PRESET_VERSION, DOCUMENT_STYLE_SET_VERSION, type DeriveBlockIdInput, type DocumentPreset, type DocumentStyleCatalog, type DocumentStyleCatalogEntry, type DocumentStyleSet, DocxArchiveError, type DocxParagraphSource, EnsureParaIdsError, type EnsureParaIdsOptions, type EnsureParaIdsResult, type ExtractDocumentStyleSetOptions, type ExtractedDocxParagraph, type ExtractedDocxText, FOLIO_DOCUMENT_OPERATION_BATCH_MODES, FOLIO_DOCUMENT_OPERATION_CONTRACT_VERSION, FOLIO_DOCUMENT_OPERATION_MODES, FOLIO_DOCUMENT_OPERATION_MODES_BY_TYPE, FOLIO_DOCUMENT_OPERATION_PRECONDITIONS, FOLIO_DOCUMENT_OPERATION_STORIES, FOLIO_DOCUMENT_OPERATION_TYPES, type FolioAIBlock, type FolioAIBlockAnchor, type FolioAIBlockKind, type FolioAIBlockPreviewRun, type FolioAIComment, type FolioAIEditApplyMode, type FolioAIEditApplyResult, type FolioAIEditOperation, type FolioAIEditPrecondition, type FolioAIEditSnapshot, type FolioAIInlineFormatting, type FolioAITextRangeHandle, type FolioApplyDocumentOperationsOptions, type FolioApplyDocumentOperationsToStoryOptions, type FolioApplyOperationsOptions, type FolioBlockDiff, type FolioBlockId, type FolioDocumentNavigationTarget, type FolioDocumentOperation, type FolioDocumentOperationAffectedTarget, type FolioDocumentOperationBatch, type FolioDocumentOperationCapabilities, type FolioDocumentOperationIssue, type FolioDocumentOperationMode, type FolioDocumentOperationPrecondition, type FolioDocumentOperationReceipt, type FolioDocumentOperationRecovery, type FolioDocumentOperationResult, type FolioDocumentOperationStatus, type FolioDocumentOperationStory, type FolioDocumentOperationType, type FolioDocumentOperationUndoFailureReason, type FolioDocumentOperationUndoHandle, type FolioDocumentOperationUndoResult, type FolioDocumentOutline, type FolioDocumentOutlineEntry, type FolioDocumentSection, type FolioDocumentSectionHandle, type FolioDocumentSectionReadResult, type FolioDocumentStory, type FolioDocumentStoryHandle, FolioDocumentStoryNotFoundError, FolioDocxReviewer, type FolioDocxReviewerOptions, type FolioEditableDocumentStoryHandle, type FolioFormatProperty, type FolioReviewChange, type FolioReviewChangeFilter, type FolioReviewChangeKind, type FolioReviewComment, type FolioReviewCommentFilter, type FolioReviewCommentReply, type FolioReviewReplyInput, type FolioVersionDiff, type FolioVersionDiffSegment, type GenerateRedlineDocxOptions, type GenerateRedlineDocxResult, InvalidFolioDocumentOperationBatchError, STELLA_STYLE_SET_NAME, UnsupportedFolioDocumentOperationVersionError, applyFolioAIEditsToBuffer, assertSupportedFolioDocumentOperationVersion, compareDocxVersions, createDocx, createEmptyDocument, createFolioAITextRangeHandle, createStellaStyleDocumentPreset, createStellaStyleSet, deriveBlockId, ensureParaIds, extractDocumentStyleSet, extractDocumentStyleSetFromDocx, extractDocxText, generateRedlineDocx, getFolioDocumentOperationCapabilities, getFolioDocumentOperationIssues, getFolioDocumentOperationReceipts, getFolioDocumentOutline, getFolioParaIdFromBlockId, inspectDocumentStyles, inspectDocumentStylesFromDocx, isFolioBlockId, isFolioDocumentOperationModeSupported, isSequentialFolioBlockId, isSupportedFolioDocumentOperationVersion, parseFolioDocumentOperationBatch, readFolioDocumentSection, replyToComment };
18
+ import { GenerateRedlineDocxOptions, GenerateRedlineDocxResult, GenerateRedlineUnprocessedStory, InvalidGenerateRedlineDocxOptionsError, generateRedlineDocx } from "./redline.js";
19
+ import { FOLIO_VERSION_COMPARISON_PRIVACY_TRANSFORMS, FOLIO_VERSION_COMPARISON_SCOPES, FolioBlockDiff, FolioCompareDocxVersionsOptions, FolioDocumentMetadataValue, FolioFormatProperty, FolioMetadataDiff, FolioStoryDiff, FolioVersionBlockHandle, FolioVersionComparisonPrivacyTransform, FolioVersionComparisonScope, FolioVersionDiff, FolioVersionDiffPrivacyOptions, FolioVersionDiffPrivacyReport, FolioVersionDiffSegment, FolioVersionDiffSummaryCounts, InvalidFolioVersionComparisonOptionsError, applyFolioVersionDiffPrivacy, compareDocxVersions, isFolioVersionComparisonPrivacyTransform, isFolioVersionComparisonScope } from "./version-comparison.js";
20
+ export { type ApplyFolioAIEditsToBufferOptions, type ApplyFolioAIEditsToBufferResult, type CreateCommentReplyInput, type CreateEmptyDocumentOptions, DOCUMENT_PRESET_VERSION, DOCUMENT_STYLE_SET_VERSION, type DeriveBlockIdInput, type DocumentPreset, type DocumentStyleCatalog, type DocumentStyleCatalogEntry, type DocumentStyleSet, DocxArchiveError, type DocxParagraphSource, EnsureParaIdsError, type EnsureParaIdsOptions, type EnsureParaIdsResult, type ExtractDocumentStyleSetOptions, type ExtractedDocxParagraph, type ExtractedDocxText, FOLIO_DOCUMENT_METADATA_PROPERTIES, FOLIO_DOCUMENT_OPERATION_BATCH_MODES, FOLIO_DOCUMENT_OPERATION_CONTRACT_VERSION, FOLIO_DOCUMENT_OPERATION_MODES, FOLIO_DOCUMENT_OPERATION_MODES_BY_TYPE, FOLIO_DOCUMENT_OPERATION_PRECONDITIONS, FOLIO_DOCUMENT_OPERATION_STORIES, FOLIO_DOCUMENT_OPERATION_TYPES, FOLIO_DOCUMENT_PRIVACY_TRANSFORMS, FOLIO_RESOLVED_REVIEWED_VIEWS, FOLIO_REVIEWED_VIEWS, FOLIO_VERSION_COMPARISON_PRIVACY_TRANSFORMS, FOLIO_VERSION_COMPARISON_SCOPES, type FolioAIBlock, type FolioAIBlockAnchor, type FolioAIBlockKind, type FolioAIBlockPreviewRun, type FolioAIComment, type FolioAIEditApplyMode, type FolioAIEditApplyResult, type FolioAIEditOperation, type FolioAIEditPrecondition, type FolioAIEditSnapshot, type FolioAIInlineFormatting, type FolioAITextRangeHandle, type FolioApplyDocumentOperationsOptions, type FolioApplyDocumentOperationsToStoryOptions, type FolioApplyOperationsOptions, type FolioBlockDiff, type FolioBlockId, type FolioCompareDocxVersionsOptions, type FolioDocumentMetadataProperty, type FolioDocumentMetadataValue, type FolioDocumentNavigationTarget, type FolioDocumentOperation, type FolioDocumentOperationAffectedTarget, type FolioDocumentOperationBatch, type FolioDocumentOperationCapabilities, type FolioDocumentOperationIssue, type FolioDocumentOperationMode, type FolioDocumentOperationPrecondition, type FolioDocumentOperationReceipt, type FolioDocumentOperationRecovery, type FolioDocumentOperationResult, type FolioDocumentOperationStatus, type FolioDocumentOperationStory, type FolioDocumentOperationType, type FolioDocumentOperationUndoFailureReason, type FolioDocumentOperationUndoHandle, type FolioDocumentOperationUndoResult, type FolioDocumentOutline, type FolioDocumentOutlineEntry, FolioDocumentPrivacyArchiveError, type FolioDocumentPrivacyOptions, type FolioDocumentPrivacyReport, type FolioDocumentPrivacyTransform, type FolioDocumentSection, type FolioDocumentSectionHandle, type FolioDocumentSectionReadResult, type FolioDocumentStory, type FolioDocumentStoryHandle, FolioDocumentStoryNotFoundError, FolioDocxReviewer, type FolioDocxReviewerOptions, type FolioEditableDocumentStoryHandle, type FolioFormatProperty, type FolioMetadataDiff, type FolioReadReviewedStoryOptions, type FolioResolveReviewedStoryOptions, type FolioResolvedReviewedView, type FolioReviewChange, type FolioReviewChangeFilter, type FolioReviewChangeKind, type FolioReviewComment, type FolioReviewCommentFilter, type FolioReviewCommentReply, type FolioReviewReplyInput, type FolioReviewedStory, type FolioReviewedView, type FolioStoryDiff, type FolioVersionBlockHandle, type FolioVersionComparisonPrivacyTransform, type FolioVersionComparisonScope, type FolioVersionDiff, type FolioVersionDiffPrivacyOptions, type FolioVersionDiffPrivacyReport, type FolioVersionDiffSegment, type FolioVersionDiffSummaryCounts, type GenerateRedlineDocxOptions, type GenerateRedlineDocxResult, type GenerateRedlineUnprocessedStory, InvalidFolioDocumentOperationBatchError, InvalidFolioDocumentPrivacyOptionsError, InvalidFolioVersionComparisonOptionsError, InvalidGenerateRedlineDocxOptionsError, type RewriteDocxMetadataPrivacyResult, STELLA_STYLE_SET_NAME, UnsupportedFolioDocumentOperationVersionError, UnsupportedFolioReviewedViewError, applyFolioAIEditsToBuffer, applyFolioVersionDiffPrivacy, assertSupportedFolioDocumentOperationVersion, compareDocxVersions, createDocx, createEmptyDocument, createFolioAITextRangeHandle, createStellaStyleDocumentPreset, createStellaStyleSet, deriveBlockId, ensureParaIds, extractDocumentStyleSet, extractDocumentStyleSetFromDocx, extractDocxText, generateRedlineDocx, getFolioDocumentOperationCapabilities, getFolioDocumentOperationIssues, getFolioDocumentOperationReceipts, getFolioDocumentOutline, getFolioParaIdFromBlockId, inspectDocumentStyles, inspectDocumentStylesFromDocx, isFolioBlockId, isFolioDocumentOperationModeSupported, isFolioDocumentPrivacyTransform, isFolioResolvedReviewedView, isFolioReviewedView, isFolioVersionComparisonPrivacyTransform, isFolioVersionComparisonScope, isSequentialFolioBlockId, isSupportedFolioDocumentOperationVersion, parseFolioDocumentOperationBatch, readFolioDocumentSection, replyToComment, rewriteDocxMetadataPrivacy };
package/dist/server.js CHANGED
@@ -8,10 +8,11 @@ import { STELLA_STYLE_SET_NAME, createStellaStyleDocumentPreset, createStellaSty
8
8
  import { createDocx } from "./docx/rezip.js";
9
9
  import { getFolioDocumentOutline, readFolioDocumentSection } from "./ai-edits/scoped-reading.js";
10
10
  import { replyToComment } from "./docx/replyToComment.js";
11
- import { FolioDocumentStoryNotFoundError, FolioDocxReviewer, applyFolioAIEditsToBuffer } from "./ai-edits/headless.js";
12
- import { compareDocxVersions } from "./version-comparison.js";
13
- import { generateRedlineDocx } from "./redline.js";
11
+ import { FOLIO_RESOLVED_REVIEWED_VIEWS, FOLIO_REVIEWED_VIEWS, FolioDocumentStoryNotFoundError, FolioDocxReviewer, UnsupportedFolioReviewedViewError, applyFolioAIEditsToBuffer, isFolioResolvedReviewedView, isFolioReviewedView } from "./ai-edits/headless.js";
12
+ import { FOLIO_DOCUMENT_METADATA_PROPERTIES, FOLIO_DOCUMENT_PRIVACY_TRANSFORMS, FolioDocumentPrivacyArchiveError, InvalidFolioDocumentPrivacyOptionsError, isFolioDocumentPrivacyTransform, rewriteDocxMetadataPrivacy } from "./docx/metadataPrivacy.js";
13
+ import { FOLIO_VERSION_COMPARISON_PRIVACY_TRANSFORMS, FOLIO_VERSION_COMPARISON_SCOPES, InvalidFolioVersionComparisonOptionsError, applyFolioVersionDiffPrivacy, compareDocxVersions, isFolioVersionComparisonPrivacyTransform, isFolioVersionComparisonScope } from "./version-comparison.js";
14
+ import { InvalidGenerateRedlineDocxOptionsError, generateRedlineDocx } from "./redline.js";
14
15
  import { EnsureParaIdsError, ensureParaIds } from "./docx/ensureParaIds.js";
15
16
  import { DocxArchiveError } from "./docx/server/boundedArchive.js";
16
17
  import { extractDocxText } from "./docx/server/extractDocxText.js";
17
- export { DOCUMENT_PRESET_VERSION, DOCUMENT_STYLE_SET_VERSION, DocxArchiveError, EnsureParaIdsError, FOLIO_DOCUMENT_OPERATION_BATCH_MODES, FOLIO_DOCUMENT_OPERATION_CONTRACT_VERSION, FOLIO_DOCUMENT_OPERATION_MODES, FOLIO_DOCUMENT_OPERATION_MODES_BY_TYPE, FOLIO_DOCUMENT_OPERATION_PRECONDITIONS, FOLIO_DOCUMENT_OPERATION_STORIES, FOLIO_DOCUMENT_OPERATION_TYPES, FolioDocumentStoryNotFoundError, FolioDocxReviewer, InvalidFolioDocumentOperationBatchError, STELLA_STYLE_SET_NAME, UnsupportedFolioDocumentOperationVersionError, applyFolioAIEditsToBuffer, assertSupportedFolioDocumentOperationVersion, compareDocxVersions, createDocx, createEmptyDocument, createFolioAITextRangeHandle, createStellaStyleDocumentPreset, createStellaStyleSet, deriveBlockId, ensureParaIds, extractDocumentStyleSet, extractDocumentStyleSetFromDocx, extractDocxText, generateRedlineDocx, getFolioDocumentOperationCapabilities, getFolioDocumentOperationIssues, getFolioDocumentOperationReceipts, getFolioDocumentOutline, getFolioParaIdFromBlockId, inspectDocumentStyles, inspectDocumentStylesFromDocx, isFolioBlockId, isFolioDocumentOperationModeSupported, isSequentialFolioBlockId, isSupportedFolioDocumentOperationVersion, parseFolioDocumentOperationBatch, readFolioDocumentSection, replyToComment };
18
+ export { DOCUMENT_PRESET_VERSION, DOCUMENT_STYLE_SET_VERSION, DocxArchiveError, EnsureParaIdsError, FOLIO_DOCUMENT_METADATA_PROPERTIES, FOLIO_DOCUMENT_OPERATION_BATCH_MODES, FOLIO_DOCUMENT_OPERATION_CONTRACT_VERSION, FOLIO_DOCUMENT_OPERATION_MODES, FOLIO_DOCUMENT_OPERATION_MODES_BY_TYPE, FOLIO_DOCUMENT_OPERATION_PRECONDITIONS, FOLIO_DOCUMENT_OPERATION_STORIES, FOLIO_DOCUMENT_OPERATION_TYPES, FOLIO_DOCUMENT_PRIVACY_TRANSFORMS, FOLIO_RESOLVED_REVIEWED_VIEWS, FOLIO_REVIEWED_VIEWS, FOLIO_VERSION_COMPARISON_PRIVACY_TRANSFORMS, FOLIO_VERSION_COMPARISON_SCOPES, FolioDocumentPrivacyArchiveError, FolioDocumentStoryNotFoundError, FolioDocxReviewer, InvalidFolioDocumentOperationBatchError, InvalidFolioDocumentPrivacyOptionsError, InvalidFolioVersionComparisonOptionsError, InvalidGenerateRedlineDocxOptionsError, STELLA_STYLE_SET_NAME, UnsupportedFolioDocumentOperationVersionError, UnsupportedFolioReviewedViewError, applyFolioAIEditsToBuffer, applyFolioVersionDiffPrivacy, assertSupportedFolioDocumentOperationVersion, compareDocxVersions, createDocx, createEmptyDocument, createFolioAITextRangeHandle, createStellaStyleDocumentPreset, createStellaStyleSet, deriveBlockId, ensureParaIds, extractDocumentStyleSet, extractDocumentStyleSetFromDocx, extractDocxText, generateRedlineDocx, getFolioDocumentOperationCapabilities, getFolioDocumentOperationIssues, getFolioDocumentOperationReceipts, getFolioDocumentOutline, getFolioParaIdFromBlockId, inspectDocumentStyles, inspectDocumentStylesFromDocx, isFolioBlockId, isFolioDocumentOperationModeSupported, isFolioDocumentPrivacyTransform, isFolioResolvedReviewedView, isFolioReviewedView, isFolioVersionComparisonPrivacyTransform, isFolioVersionComparisonScope, isSequentialFolioBlockId, isSupportedFolioDocumentOperationVersion, parseFolioDocumentOperationBatch, readFolioDocumentSection, replyToComment, rewriteDocxMetadataPrivacy };