@betteroffice/docx 0.0.3 → 0.1.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/README.md +22 -8
- package/dist/chunk-24DL53QL.mjs +1 -0
- package/dist/chunk-5F6DLQZP.mjs +1 -0
- package/dist/chunk-BUZ2X5CT.mjs +16 -0
- package/dist/chunk-CTBUQRYQ.mjs +1 -0
- package/dist/{chunk-B4IR6YP4.mjs → chunk-GHEHBYQK.mjs} +1 -1
- package/dist/{chunk-NJHOPXZW.mjs → chunk-HLDJMU3R.mjs} +1 -1
- package/dist/chunk-HTDNSQ44.mjs +1 -0
- package/dist/{chunk-IFT6DUJX.mjs → chunk-LTVVQMHB.mjs} +1 -1
- package/dist/chunk-PI2I3TO5.mjs +57 -0
- package/dist/chunk-TMHG7OAZ.mjs +1 -0
- package/dist/chunk-VRGUAKOC.mjs +1 -0
- package/dist/collaboration/index.d.mts +32 -8
- package/dist/collaboration/index.mjs +1 -1
- package/dist/{content-MOZ6hKP4.d.mts → content-DrqzbIr7.d.mts} +582 -666
- package/dist/core.d.mts +7 -7
- package/dist/core.mjs +1 -1
- package/dist/{displayListQueries-BJlo7Jkz.d.mts → displayListQueries-DGDR-OWc.d.mts} +98 -50
- package/dist/docx/index.d.mts +5 -5
- package/dist/docx/index.mjs +1 -1
- package/dist/editor/index.d.mts +8 -8
- package/dist/{fontLoader-aSewHMKF.d.mts → fontLoader-DnixuYST.d.mts} +127 -2
- package/dist/{formatting-D1EPSaJP.d.mts → formatting-BqrFPeev.d.mts} +85 -203
- package/dist/{frameDelta-D965X8yK.d.mts → frameDelta-DMgR8n13.d.mts} +17 -10
- package/dist/generated/edit/docx_edit_bg.wasm +0 -0
- package/dist/generated/layout/docx_layout_bg.wasm +0 -0
- package/dist/generated/opc/ooxml_opc_bg.wasm +0 -0
- package/dist/generated/parse/docx_parse_bg.wasm +0 -0
- package/dist/{index-Dx4Z3lkz.d.mts → index-ImoMd0Ju.d.mts} +97 -67
- package/dist/layout/index.d.mts +40 -12
- package/dist/layout/index.mjs +1 -1
- package/dist/layout/pagination/index.d.mts +4 -4
- package/dist/layout/pagination/index.mjs +1 -1
- package/dist/layout/render/index.d.mts +33 -77
- package/dist/layout/render/index.mjs +1 -1
- package/dist/plugin-api/RenderedDomContext.d.mts +7 -7
- package/dist/plugin-api/index.d.mts +3 -3
- package/dist/plugin-api/resolveItemPositions.d.mts +3 -3
- package/dist/{rustDisplayList-BRuZBqdL.d.mts → rustDisplayList-B9dQoLHI.d.mts} +79 -50
- package/dist/{rustMeasureSource-D1KsQvVC.d.mts → rustMeasureSource-C0EZB055.d.mts} +5 -2
- package/dist/{selectiveSave-CVoajSKE.d.mts → selectiveSave-CRh-_Y_C.d.mts} +3 -3
- package/dist/styles/index.d.mts +3 -3
- package/dist/{styles-Dn_o3Vo5.d.mts → styles-CMybYYHS.d.mts} +1 -1
- package/dist/types/content.d.mts +2 -2
- package/dist/types/document.d.mts +7 -7
- package/dist/{types-BfqUl2h_.d.mts → types-CXLxVF1t.d.mts} +27 -23
- package/dist/utils/comments.d.mts +2 -2
- package/dist/utils/index.d.mts +11 -13
- package/dist/utils/index.mjs +1 -1
- package/dist/utils/stylePreview.d.mts +2 -2
- package/dist/utils/units.d.mts +4 -34
- package/dist/utils/units.mjs +1 -1
- package/dist/wasm-CJHQHBDE.mjs +1 -0
- package/dist/wasm-T2CRCO7S.mjs +1 -0
- package/dist/wasm-edit.d.mts +524 -168
- package/dist/wasm-edit.mjs +1 -1
- package/dist/wasm-layout.d.mts +35 -28
- package/dist/wasm-layout.mjs +1 -1
- package/dist/wasm-opc.mjs +1 -1
- package/dist/wasm-parse.mjs +1 -1
- package/dist/yrs/index.d.mts +6 -6
- package/dist/yrs/index.mjs +1 -1
- package/dist/yrs/residentEngineWorker.mjs +1 -1
- package/package.json +19 -3
- package/dist/chunk-3UBMCDME.mjs +0 -1
- package/dist/chunk-AEQOEQJ7.mjs +0 -57
- package/dist/chunk-AZ52IWB6.mjs +0 -16
- package/dist/chunk-GGEGIQRK.mjs +0 -1
- package/dist/chunk-T4EZMUXM.mjs +0 -1
- package/dist/chunk-WON6K4FY.mjs +0 -1
- package/dist/chunk-Y7RUNRU2.mjs +0 -1
- package/dist/wasm-DO3BUV7C.mjs +0 -1
- package/dist/wasm-NWXX4H5G.mjs +0 -1
package/dist/core.d.mts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
export { a as attemptSelectiveSave, c as createDocx, p as parseDocx, r as repackDocx, u as updateMultipleFiles } from './selectiveSave-
|
|
1
|
+
export { a as attemptSelectiveSave, c as createDocx, p as parseDocx, r as repackDocx, u as updateMultipleFiles } from './selectiveSave-CRh-_Y_C.mjs';
|
|
2
2
|
import { Document } from './types/document.mjs';
|
|
3
3
|
export { DocxPackage } from './types/document.mjs';
|
|
4
|
-
import {
|
|
5
|
-
export { B as BlockContent,
|
|
4
|
+
import { g as DocumentBody, S as SectionProperties, b3 as Table } from './content-DrqzbIr7.mjs';
|
|
5
|
+
export { B as BlockContent, m as BookmarkEnd, n as BookmarkStart, f as Comment, J as CommentRangeEnd, K as CommentRangeStart, T as Deletion, j as Endnote, Y as Field, a1 as FooterReference, i as Footnote, H as HeaderFooter, a4 as HeaderReference, a5 as Hyperlink, a7 as Image, aj as Insertion, an as ListLevel, aq as MoveFrom, at as MoveTo, h as NumberingDefinitions, P as Paragraph, aF as ParagraphContent, aJ as Run, aK as RunContent, aU as Shape, b4 as TableCell, b7 as TableRow, ba as TextBox, bb as TextContent, bd as TrackedChangeInfo, be as TrackedRunChange } from './content-DrqzbIr7.mjs';
|
|
6
6
|
export { emuToPixels, emuToTwips, formatPx, halfPointsToPixels, pixelsToEmu, pixelsToTwips, pointsToPixels, twipsToEmu, twipsToPixels } from './utils/units.mjs';
|
|
7
|
-
export { c as canRenderFont, a as colorsEqual,
|
|
7
|
+
export { T as ThemeMatrixCell, b as blendColors, c as canRenderFont, a as colorsEqual, d as createRgbColor, e as createThemeColor, f as darkenColor, g as ensureHexPrefix, h as generateThemeTintShadeMatrix, i as getContrastingColor, j as getLoadedFonts, k as getThemeTintShadeHex, l as isBlack, m as isFontLoaded, n as isFontsLoading, o as isGoogleFontsEnabled, p as isWhite, q as lightenColor, r as loadFont, s as loadFontFromBuffer, t as loadFonts, u as onFontsLoaded, v as parseColorString, w as preloadCommonFonts, x as resolveColor, y as resolveHighlightColor, z as resolveHighlightToCss, A as resolveShadingColor, B as setGoogleFontsEnabled } from './fontLoader-DnixuYST.mjs';
|
|
8
8
|
export { D as DocxInput, t as toArrayBuffer } from './docxInput-DTbCa48g.mjs';
|
|
9
9
|
export { EditorPluginCore, PanelConfig, PluginPanelProps, PositionCoordinates, RenderedDomContext } from './plugin-api/index.mjs';
|
|
10
|
-
export { B as BlockExtent, F as FootnoteContent, a as Layout, L as LayoutBlock, P as Page, R as ResolvedLine, c as ResolvedSegment } from './types-
|
|
11
|
-
export {
|
|
12
|
-
export { d as Relationship, a as Style, S as StyleDefinitions } from './styles-
|
|
10
|
+
export { B as BlockExtent, F as FootnoteContent, a as Layout, L as LayoutBlock, P as Page, R as ResolvedLine, c as ResolvedSegment } from './types-CXLxVF1t.mjs';
|
|
11
|
+
export { a as ParagraphFormatting, b as TextFormatting, f as Theme, x as ThemeColorScheme, z as ThemeFont, A as ThemeFontScheme } from './formatting-BqrFPeev.mjs';
|
|
12
|
+
export { d as Relationship, a as Style, S as StyleDefinitions } from './styles-CMybYYHS.mjs';
|
|
13
13
|
import './docx/wrapTypes.mjs';
|
|
14
14
|
|
|
15
15
|
/**
|
package/dist/core.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{i as attemptSelectiveSave,h as createDocx,a as parseDocx,f as repackDocx,c as serializeDocumentBody,b as serializeDocx,d as serializeSectionProperties,g as updateMultipleFiles}from'./chunk-
|
|
1
|
+
export{i as attemptSelectiveSave,h as createDocx,a as parseDocx,f as repackDocx,c as serializeDocumentBody,b as serializeDocx,d as serializeSectionProperties,g as updateMultipleFiles}from'./chunk-PI2I3TO5.mjs';export{f as blendColors,r as colorsEqual,o as createRgbColor,n as createThemeColor,d as darkenColor,p as ensureHexPrefix,h as generateThemeTintShadeMatrix,c as getContrastingColor,g as getThemeTintShadeHex,k as isBlack,l as isWhite,e as lightenColor,m as parseColorString,a as resolveColor,i as resolveHighlightColor,q as resolveHighlightToCss,j as resolveShadingColor}from'./chunk-LTVVQMHB.mjs';export{b as emuToPixels,i as emuToTwips,q as formatPx,k as halfPointsToPixels,c as pixelsToEmu,h as pixelsToTwips,d as pointsToPixels,j as twipsToEmu,g as twipsToPixels}from'./chunk-CTBUQRYQ.mjs';export{n as canRenderFont,k as getLoadedFonts,g as isFontLoaded,j as isFontsLoading,i as isGoogleFontsEnabled,e as loadFont,o as loadFontFromBuffer,f as loadFonts,l as onFontsLoaded,v as preloadCommonFonts,h as setGoogleFontsEnabled,a as toArrayBuffer}from'./chunk-BUZ2X5CT.mjs';import'./chunk-TMHG7OAZ.mjs';import'./chunk-HLDJMU3R.mjs';import'./chunk-GHEHBYQK.mjs';import'./chunk-5F6DLQZP.mjs';import {b as b$1}from'./chunk-TTRUPDAB.mjs';var ce={includeHeaders:true,includeFooters:true,includePageNumbers:true,pageRange:null,scale:1,printBackground:true,margins:"default"};function me(){return {...ce}}function de(){typeof window<"u"&&window.print();}var fe="@media print { body { margin: 0; padding: 0; } @page { margin: 0; } }";function ge(t="Document",r){if(typeof window>"u")return null;let e=window.open("","_blank");if(!e)return null;e.opener=null;let n=e.document;n.title=t;let o=n.createElement("style");o.textContent=fe,n.head.appendChild(o);let i=new DOMParser().parseFromString(r,"text/html");for(let l of Array.from(i.body.childNodes))n.body.appendChild(n.importNode(l,true));return e}function he(t,r){if(!t||!t.trim())return null;let e=t.trim();if(/^\d+$/.test(e)){let o=parseInt(e,10);return o>=1&&o<=r?{start:o,end:o}:null}let n=e.match(/^(\d+)-(\d+)$/);if(n){let o=parseInt(n[1],10),i=parseInt(n[2],10);if(o>=1&&i<=r&&o<=i)return {start:o,end:i}}return null}function Te(t,r){return t?t.start===t.end?`Page ${t.start}`:`Pages ${t.start}-${t.end}`:`All (${r} pages)`}function be(){return typeof window<"u"&&typeof window.print=="function"}var s=class{constructor(r){b$1(this,"listeners",new Set);b$1(this,"snapshot");b$1(this,"subscribe",r=>(this.listeners.add(r),()=>{this.listeners.delete(r);}));b$1(this,"getSnapshot",()=>this.snapshot);this.snapshot=r;}setSnapshot(r){this.snapshot=r,this.notify();}notify(){for(let r of this.listeners)r();}};var c={TABLE_INDEX:"data-table-index",ROW_INDEX:"data-row",COLUMN_INDEX:"data-col",TABLE_CELL:"data-table-cell"};function g(t,r){if(!(t instanceof Element))return null;let e=t;for(;e&&e!==r;){if(e.tagName==="TD"||e.tagName==="TH"){let n=e.getAttribute(c.ROW_INDEX),o=e.getAttribute(c.COLUMN_INDEX);if(n!==null&&o!==null){let i=e;for(;i&&i!==r;){if(i.tagName==="TABLE"){let l=i.getAttribute(c.TABLE_INDEX);if(l!==null)return {tableIndex:parseInt(l,10),rowIndex:parseInt(n,10),columnIndex:parseInt(o,10)};break}i=i.parentElement;}}break}e=e.parentElement;}return null}function h(t,r){if(!t.package?.document?.content)return null;let e=0;for(let n of t.package.document.content)if(n.type==="table"){if(e===r)return n;e++;}return null}function T(t,r,e){if(!t.package?.document?.content)return t;let n=0,o=t.package.document.content.map(i=>{if(i.type==="table"){if(n===r)return n++,e;n++;}return i});return {...t,package:{...t.package,document:{...t.package.document,content:o}}}}function b(t,r){if(!t.package?.document?.content)return t;let e=0,n=t.package.document.content.filter(o=>{if(o.type==="table"){let i=e===r;return e++,!i}return true});return {...t,package:{...t.package,document:{...t.package.document,content:n}}}}var m=class extends s{constructor(){super({selectedCell:null});}selectCell(r){this.setSnapshot({selectedCell:r});}clearSelection(){this.setSnapshot({selectedCell:null});}isCellSelected(r,e,n){let{selectedCell:o}=this.getSnapshot();return o?o.tableIndex===r&&o.rowIndex===e&&o.columnIndex===n:false}getSelectedCell(){return this.getSnapshot().selectedCell}};var d=class extends s{constructor(){super({notifications:[]});b$1(this,"notifications",[]);b$1(this,"idCounter",0);b$1(this,"timers",new Set);}showError(e,n){return this.addNotification(e,"error",n)}showWarning(e,n){return this.addNotification(e,"warning",n)}showInfo(e,n){return this.addNotification(e,"info",n)}dismiss(e){this.notifications=this.notifications.map(o=>o.id===e?{...o,dismissed:true}:o),this.emitSnapshot();let n=setTimeout(()=>{this.timers.delete(n),this.notifications=this.notifications.filter(o=>o.id!==e),this.emitSnapshot();},300);this.timers.add(n);}clearAll(){this.notifications=[];for(let e of this.timers)clearTimeout(e);this.timers.clear(),this.emitSnapshot();}destroy(){for(let e of this.timers)clearTimeout(e);this.timers.clear(),this.notifications=[];}addNotification(e,n,o){let i=`error-${++this.idCounter}-${Date.now()}`,l={id:i,message:e,severity:n,details:o,timestamp:Date.now()};if(this.notifications=[...this.notifications,l],this.emitSnapshot(),n!=="error"){let f=setTimeout(()=>{this.timers.delete(f),this.dismiss(i);},5e3);this.timers.add(f);}return i}emitSnapshot(){this.setSnapshot({notifications:this.notifications});}};var Me="0.0.2";export{d as ErrorManager,s as Subscribable,c as TABLE_DATA_ATTRIBUTES,m as TableSelectionManager,Me as VERSION,b as deleteTableFromDocument,g as findTableFromClick,Te as formatPageRange,me as getDefaultPrintOptions,h as getTableFromDocument,be as isPrintSupported,ge as openPrintWindow,he as parsePageRange,de as triggerPrint,T as updateTableInDocument};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { I as ImagePrimitive, D as DisplayList } from './frameDelta-
|
|
2
|
-
import { R as RustDisplayListQueryEngine } from './rustDisplayList-
|
|
1
|
+
import { I as ImagePrimitive, D as DisplayList } from './frameDelta-DMgR8n13.mjs';
|
|
2
|
+
import { R as RustDisplayListQueryEngine } from './rustDisplayList-B9dQoLHI.mjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Locate an image primitive in a built DisplayList by its document position.
|
|
@@ -8,14 +8,13 @@ import { R as RustDisplayListQueryEngine } from './rustDisplayList-BRuZBqdL.mjs'
|
|
|
8
8
|
* rect to place its resize handles, and on the canvas path the painted DOM
|
|
9
9
|
* image (`.layout-run-image`) is parked/hidden — its rect is unusable. The
|
|
10
10
|
* display list carries every inline image as an `ImagePrimitive` stamped with
|
|
11
|
-
* `docStart` (= the image atom's
|
|
11
|
+
* `docStart` (= the image atom's document position, the same value the DOM path reads
|
|
12
12
|
* from `data-doc-start`), so the primitive found here is the geometry source
|
|
13
13
|
* that replaces `imageInfo.element.getBoundingClientRect()`.
|
|
14
14
|
*
|
|
15
15
|
* Body primitives only: header/footer image primitives carry doc positions in a
|
|
16
|
-
* different
|
|
16
|
+
* different doc (the HF editor), so a body image pmPos must never match one.
|
|
17
17
|
*
|
|
18
|
-
* @experimental part of the rust-canvas-engine change; shape may evolve.
|
|
19
18
|
*/
|
|
20
19
|
|
|
21
20
|
type DisplayListImageRegion = 'body' | 'header' | 'footer';
|
|
@@ -23,15 +22,15 @@ interface LocatedImagePrimitive {
|
|
|
23
22
|
primitive: ImagePrimitive;
|
|
24
23
|
/** page the primitive paints on (page-local px are relative to this page) */
|
|
25
24
|
pageIndex: number;
|
|
26
|
-
/**
|
|
25
|
+
/** Document region containing the image. Undefined reads as body. */
|
|
27
26
|
region?: DisplayListImageRegion;
|
|
28
27
|
/** Header/footer relationship id when `region` is not body. */
|
|
29
28
|
rId?: string;
|
|
30
29
|
}
|
|
31
30
|
/**
|
|
32
31
|
* First body image primitive whose `docStart` equals `pos`, or null. `pos` is
|
|
33
|
-
* the image node's
|
|
34
|
-
* one-atom
|
|
32
|
+
* the image node's document position (a node selection's `from`, or the left
|
|
33
|
+
* edge of a one-atom text selection).
|
|
35
34
|
*/
|
|
36
35
|
declare function findImagePrimitiveByDocPos(list: DisplayList, pos: number, region?: DisplayListImageRegion, rId?: string): LocatedImagePrimitive | null;
|
|
37
36
|
/** Topmost positioned image under a page-local point, or null. */
|
|
@@ -49,62 +48,93 @@ declare function captureInlinePositionEmuFromDisplayList(queries: DisplayListQue
|
|
|
49
48
|
} | undefined;
|
|
50
49
|
|
|
51
50
|
/**
|
|
52
|
-
* Synchronous query facade over
|
|
51
|
+
* Synchronous query facade over one built DisplayList, backed by the Rust
|
|
53
52
|
* hit-testing module (`crates/docx-layout/src/hit.rs`).
|
|
54
53
|
*
|
|
55
|
-
* This is the
|
|
56
|
-
*
|
|
57
|
-
*
|
|
54
|
+
* This is the canvas renderer's only source of pointer and selection geometry:
|
|
55
|
+
* every rect comes from the immutable display list, never from DOM rects. A
|
|
56
|
+
* facade is created per display-list build, since the list never mutates in
|
|
57
|
+
* place, and it holds no state a caller has to keep in sync.
|
|
58
58
|
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
* instead of a full re-open. When the session exports are absent (before the
|
|
68
|
-
* integrator re-embeds the wasm) it falls back to the JSON-arg exports,
|
|
69
|
-
* stringifying the list once and reusing the string for every query. Either
|
|
70
|
-
* way the query RESULTS are byte-identical — the handle path is pure perf.
|
|
59
|
+
* **Two sources.** A resident editing engine queries its own display list
|
|
60
|
+
* directly and takes no display-list JSON at all. Otherwise the shared layout
|
|
61
|
+
* wasm answers, and the facade prefers a SESSION HANDLE: the list is parsed
|
|
62
|
+
* into the Rust store once (`openDisplayList`) and every later query goes by
|
|
63
|
+
* handle, with no per-query re-serialization. When the session exports are
|
|
64
|
+
* absent it stringifies the list once and reuses that string for the JSON-arg
|
|
65
|
+
* exports. The two paths run the same hit and range logic, so results are
|
|
66
|
+
* byte-identical and only the cost differs.
|
|
71
67
|
*
|
|
72
|
-
* Handle
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
*
|
|
68
|
+
* **Handle acquisition is lazy** — on the first query that needs one, or when
|
|
69
|
+
* a host calls `prime()` from idle time — so replacing the facade on every
|
|
70
|
+
* keystroke costs no serialization on the input path. A new facade also tries
|
|
71
|
+
* to ADOPT its predecessor's parsed list, shipping a page delta for the pages
|
|
72
|
+
* that changed instead of reopening the whole list; superseded generations
|
|
73
|
+
* chain their donor, so a deferred pickup still costs one delta. The donor's
|
|
74
|
+
* own later queries degrade to its JSON-arg path.
|
|
78
75
|
*
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
*
|
|
76
|
+
* **Handle release.** `dispose()` frees the handle immediately. A facade
|
|
77
|
+
* dropped without it — a `useMemo` replacement, say — is covered by a
|
|
78
|
+
* `FinalizationRegistry`, and the Rust store additionally caps live handles
|
|
79
|
+
* and evicts the oldest, so a missed finalize cannot grow memory without
|
|
80
|
+
* bound.
|
|
84
81
|
*
|
|
85
|
-
*
|
|
82
|
+
* **Failure.** A wasm TRAP poisons the whole instance: a guard held across the
|
|
83
|
+
* query leaks and every later call into it fails, so the engine is marked dead,
|
|
84
|
+
* all queries stop, and `onDisplayListQuerySourceFailure` subscribers are told
|
|
85
|
+
* to rebuild the session. An ordinary error just falls back — a bad handle is
|
|
86
|
+
* dropped and the query retried over JSON.
|
|
87
|
+
*
|
|
88
|
+
* Queries are synchronous and return `null`/`[]` until the lazily imported
|
|
89
|
+
* wasm module resolves. In practice it is already loaded by the time a facade
|
|
90
|
+
* exists, because building the display list went through the same module.
|
|
86
91
|
*/
|
|
87
92
|
|
|
88
|
-
/**
|
|
93
|
+
/**
|
|
94
|
+
* Query surface of an editing engine that already holds the display list.
|
|
95
|
+
* None of these take display-list JSON, so this source never opens a handle
|
|
96
|
+
* and never serializes anything.
|
|
97
|
+
*/
|
|
89
98
|
interface ResidentDisplayListQueryEngine {
|
|
90
99
|
displayHitTestRegionsJson(pageIndex: number, x: number, y: number): string;
|
|
100
|
+
displayVerticalMoveJson(position: number, direction: 'up' | 'down', goalX: number): string;
|
|
91
101
|
displayRangeRectsJson(from: number, to: number): string;
|
|
92
|
-
displayRangeRectsRegionJson(region:
|
|
102
|
+
displayRangeRectsRegionJson(region: DisplayListHitRegion, partId: string, from: number, to: number): string;
|
|
93
103
|
}
|
|
94
104
|
/** which part of a page owns a hit — mirrors `HitRegion` in hit.rs */
|
|
95
|
-
type DisplayListHitRegion = 'body' | 'header' | 'footer';
|
|
105
|
+
type DisplayListHitRegion = 'body' | 'header' | 'footer' | 'footnote' | 'endnote';
|
|
106
|
+
/**
|
|
107
|
+
* What a click at a hit point would act on — mirrors `HoverTarget` in hit.rs.
|
|
108
|
+
* `'text'` is the typeable area (a run's box, or the content box around it),
|
|
109
|
+
* which is what a pointer cursor keys off; `pos` cannot say, since it resolves
|
|
110
|
+
* everywhere on a page that carries text.
|
|
111
|
+
*/
|
|
112
|
+
type DisplayListHoverTarget = 'text' | 'image' | 'none';
|
|
96
113
|
/**
|
|
97
114
|
* Region-aware hit result. For `header`/`footer` the position refers to the
|
|
98
|
-
*
|
|
99
|
-
*
|
|
100
|
-
*
|
|
115
|
+
* header/footer document identified by `rId`, and for `footnote`/`endnote` to
|
|
116
|
+
* the note story named by `noteId` — NOT the body document, so the caller must
|
|
117
|
+
* route the selection to that editor. `pos` is null when the point is inside
|
|
118
|
+
* the region but resolves to no position.
|
|
101
119
|
*/
|
|
102
120
|
interface DisplayListRegionHit {
|
|
103
121
|
region: DisplayListHitRegion;
|
|
104
122
|
rId?: string;
|
|
123
|
+
/** note whose story a `footnote`/`endnote` position addresses */
|
|
124
|
+
noteId?: number;
|
|
105
125
|
pos: number | null;
|
|
126
|
+
/** Absent from a wasm build predating it; read that as "not text". */
|
|
127
|
+
target?: DisplayListHoverTarget;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Result of an up/down caret move. `goalX` is the page-local x to feed back
|
|
131
|
+
* into the next move so a run of them holds one column.
|
|
132
|
+
*/
|
|
133
|
+
interface DisplayListVerticalMove {
|
|
134
|
+
position: number;
|
|
135
|
+
goalX: number;
|
|
106
136
|
}
|
|
107
|
-
/** one highlight rectangle of a
|
|
137
|
+
/** one highlight rectangle of a document range, page-local px */
|
|
108
138
|
interface DisplayListRect {
|
|
109
139
|
pageIndex: number;
|
|
110
140
|
x: number;
|
|
@@ -169,22 +199,30 @@ interface DisplayListQueries {
|
|
|
169
199
|
/** Visual line containing `pos`, or null. */
|
|
170
200
|
visualLineAtPosition(pos: number): DisplayListVisualLine | null;
|
|
171
201
|
/** Topmost image under a page-local point. Body by default. */
|
|
172
|
-
imageAtPoint(pageIndex: number, x: number, y: number, region?:
|
|
202
|
+
imageAtPoint(pageIndex: number, x: number, y: number, region?: DisplayListImageRegion, rId?: string): DisplayListImageGeometry | null;
|
|
173
203
|
/** Image whose atom starts at `pos`. Body by default. */
|
|
174
|
-
imageByPos(pos: number, region?:
|
|
204
|
+
imageByPos(pos: number, region?: DisplayListImageRegion, rId?: string): DisplayListImageGeometry | null;
|
|
175
205
|
/** region-aware point → doc position (page-local coordinates) */
|
|
176
206
|
hitTestRegions(pageIndex: number, x: number, y: number): DisplayListRegionHit | null;
|
|
177
|
-
|
|
207
|
+
verticalMove(position: number, direction: 'up' | 'down', goalX?: number): DisplayListVerticalMove | null;
|
|
208
|
+
/** body document range → highlight rects */
|
|
178
209
|
rangeRects(from: number, to: number): DisplayListRect[];
|
|
179
210
|
/**
|
|
180
|
-
* Header/footer
|
|
181
|
-
* `'header' | 'footer'`; `rId` identifies the HF
|
|
211
|
+
* Header/footer document range → highlight rects for the region's band. `region` is
|
|
212
|
+
* `'header' | 'footer'`; `rId` identifies the HF doc, and
|
|
182
213
|
* `from`/`to` are positions in THAT doc. The same HF doc paints on every page
|
|
183
214
|
* carrying the part, so this returns one rect-set per such page (each tagged
|
|
184
215
|
* with its `pageIndex`) — the caller picks the page it is editing. Returns
|
|
185
|
-
* `[]`
|
|
216
|
+
* `[]` when the region-aware exports are absent, which is feature-detected.
|
|
186
217
|
*/
|
|
187
218
|
hfRangeRects(region: 'header' | 'footer', rId: string, from: number, to: number): DisplayListRect[];
|
|
219
|
+
/**
|
|
220
|
+
* Note document range → highlight rects for that note's story. `from`/`to`
|
|
221
|
+
* are positions in the `fn:{noteId}` / `en:{noteId}` document, never the
|
|
222
|
+
* body's. A note paints on one page only, so every rect shares its
|
|
223
|
+
* `pageIndex`.
|
|
224
|
+
*/
|
|
225
|
+
noteRangeRects(region: 'footnote' | 'endnote', noteId: number, from: number, to: number): DisplayListRect[];
|
|
188
226
|
/**
|
|
189
227
|
* Caret geometry for a collapsed HF selection — the HF twin of `caretRect`.
|
|
190
228
|
* Resolves `[pos, pos+1)` in the HF doc (left edge is the caret), falling back
|
|
@@ -192,6 +230,11 @@ interface DisplayListQueries {
|
|
|
192
230
|
* caret rect per page carrying the part; the caller picks the edited page.
|
|
193
231
|
*/
|
|
194
232
|
hfCaretRects(region: 'header' | 'footer', rId: string, pos: number): DisplayListRect[];
|
|
233
|
+
/**
|
|
234
|
+
* Caret geometry for a collapsed selection in a note story — the note twin of
|
|
235
|
+
* `hfCaretRects`. A note paints on one page, so this returns at most one rect.
|
|
236
|
+
*/
|
|
237
|
+
noteCaretRects(region: 'footnote' | 'endnote', noteId: number, pos: number): DisplayListRect[];
|
|
195
238
|
/** Header/footer sidebar anchors, one per page carrying the part. */
|
|
196
239
|
hfAnchorRects(region: 'header' | 'footer', rId: string, pos: number): DisplayListRect[];
|
|
197
240
|
/**
|
|
@@ -224,6 +267,11 @@ interface DisplayListQueries {
|
|
|
224
267
|
*/
|
|
225
268
|
dispose(): void;
|
|
226
269
|
}
|
|
270
|
+
type DisplayListQuerySource = RustDisplayListQueryEngine | ResidentDisplayListQueryEngine;
|
|
271
|
+
/** True once a query trapped in this engine's wasm instance. */
|
|
272
|
+
declare function isDisplayListQuerySourceDead(engine: DisplayListQuerySource | null | undefined): boolean;
|
|
273
|
+
/** Subscribe to wasm traps so the host can rebuild the dead session. */
|
|
274
|
+
declare function onDisplayListQuerySourceFailure(listener: (error: Error) => void): () => void;
|
|
227
275
|
/**
|
|
228
276
|
* Build a query facade for one display list. The optional `engine` makes the
|
|
229
277
|
* facade synchronous and deterministic in tests; without it the shared wasm
|
|
@@ -237,4 +285,4 @@ interface DisplayListQueries {
|
|
|
237
285
|
*/
|
|
238
286
|
declare function createDisplayListQueries(list: DisplayList, engine?: RustDisplayListQueryEngine | ResidentDisplayListQueryEngine, previous?: DisplayListQueries | null): DisplayListQueries;
|
|
239
287
|
|
|
240
|
-
export { type DisplayListRect as D, type LocatedImagePrimitive as L, type ResidentDisplayListQueryEngine as R, type DisplayListQueries as a, type DisplayListRegionHit as b, type DisplayListHitRegion as c, type
|
|
288
|
+
export { type DisplayListRect as D, type LocatedImagePrimitive as L, type ResidentDisplayListQueryEngine as R, type DisplayListQueries as a, type DisplayListRegionHit as b, type DisplayListHitRegion as c, type DisplayListHoverTarget as d, type DisplayListImageGeometry as e, type DisplayListImageRegion as f, type DisplayListParagraphGeometry as g, type DisplayListQuerySourceState as h, type DisplayListVerticalMove as i, type DisplayListVisualLine as j, captureInlinePositionEmuFromDisplayList as k, createDisplayListQueries as l, findImagePrimitiveAtPoint as m, findImagePrimitiveByDocPos as n, isDisplayListQuerySourceDead as o, onDisplayListQuerySourceFailure as p };
|
package/dist/docx/index.d.mts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export { a as attemptSelectiveSave, c as createDocx, p as parseDocx, r as repackDocx, u as updateMultipleFiles } from '../selectiveSave-
|
|
1
|
+
export { a as attemptSelectiveSave, c as createDocx, p as parseDocx, r as repackDocx, u as updateMultipleFiles } from '../selectiveSave-CRh-_Y_C.mjs';
|
|
2
2
|
import { WrapType } from './wrapTypes.mjs';
|
|
3
|
-
import { B as BlockContent,
|
|
3
|
+
import { B as BlockContent, f as Comment, W as Watermark } from '../content-DrqzbIr7.mjs';
|
|
4
4
|
import { Document } from '../types/document.mjs';
|
|
5
5
|
import '../docxInput-DTbCa48g.mjs';
|
|
6
|
-
import '../formatting-
|
|
7
|
-
import '../styles-
|
|
6
|
+
import '../formatting-BqrFPeev.mjs';
|
|
7
|
+
import '../styles-CMybYYHS.mjs';
|
|
8
8
|
|
|
9
9
|
type AnchorWrapType = Exclude<WrapType, 'inline'>;
|
|
10
10
|
type ImageLayoutTarget = AnchorWrapType | 'squareLeft' | 'squareRight' | 'inline';
|
|
@@ -71,7 +71,7 @@ declare function toolbarValueToLayoutTarget(value: string): ImageLayoutTarget |
|
|
|
71
71
|
* Word / Pages / LibreOffice expect every comment in `comments.xml`
|
|
72
72
|
* (including REPLY threads) to have matching `commentRangeStart` /
|
|
73
73
|
* `commentRangeEnd` / `commentReference` markers in `document.xml`.
|
|
74
|
-
* The
|
|
74
|
+
* The document only stamps marks for the parent comment because
|
|
75
75
|
* replies don't have their own visible range — they share the parent
|
|
76
76
|
* thread's text. So before serialization we walk the body content and
|
|
77
77
|
* synthesize parallel range markers for every reply.
|
package/dist/docx/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {e}from'../chunk-
|
|
1
|
+
import {e}from'../chunk-PI2I3TO5.mjs';export{i as attemptSelectiveSave,h as createDocx,a as parseDocx,f as repackDocx,g as updateMultipleFiles}from'../chunk-PI2I3TO5.mjs';import'../chunk-BUZ2X5CT.mjs';import'../chunk-TMHG7OAZ.mjs';import'../chunk-HLDJMU3R.mjs';import'../chunk-GHEHBYQK.mjs';import'../chunk-5F6DLQZP.mjs';import'../chunk-TTRUPDAB.mjs';function E(e,t,o,r,i,p){let a=e.includes("w")||e.includes("e"),s=e.includes("n")||e.includes("s"),u=e.includes("w")?-1:1,l=e.includes("n")?-1:1,m=a?r+t*u:r,f=s?i+o*l:i;if(a&&s&&p){let g=Math.max(m/r,f/i);m=r*g,f=i*g;}let d=g=>Math.max(20,Math.min(2e3,g));return {width:a?d(m):r,height:s?d(f):i}}function q(e,t,o){let r=()=>t.position?.horizontal&&t.position.vertical?t.position:o?.initialPositionEmu?{horizontal:{relativeTo:"column",posOffset:o.initialPositionEmu.horizontalEmu},vertical:{relativeTo:"paragraph",posOffset:o.initialPositionEmu.verticalEmu}}:{horizontal:{relativeTo:"column",posOffset:0},vertical:{relativeTo:"paragraph",posOffset:0}};switch(e){case "inline":return {wrapType:"inline",displayMode:"inline",cssFloat:"none",wrapText:void 0,position:void 0,distTop:void 0,distBottom:void 0,distLeft:void 0,distRight:void 0};case "squareLeft":case "squareRight":{let i=e==="squareLeft"?"left":"right";return {wrapType:t.wrapType==="tight"||t.wrapType==="through"?t.wrapType:"square",displayMode:"float",cssFloat:i,wrapText:i==="left"?"right":"left",position:r()}}case "square":case "tight":case "through":{let i=t.cssFloat==="left"||t.cssFloat==="right"?t.cssFloat:"left";return {wrapType:e,displayMode:"float",cssFloat:i,wrapText:i==="left"?"right":"left",position:r()}}case "topAndBottom":return {wrapType:"topAndBottom",displayMode:"block",cssFloat:"none",wrapText:"bothSides",position:r()};case "behind":case "inFront":return {wrapType:e,displayMode:"float",cssFloat:"none",wrapText:"bothSides",position:r()}}}function W(e,t){return e==="inline"?"inline":e==="behind"?"behind":e==="inFront"?"inFront":e==="square"||e==="tight"||e==="through"?t==="right"?"squareRight":"squareLeft":null}var _=[{choice:"inline",i18nLabelKey:"inLineWithText",i18nDescKey:"inLineWithText",iconHint:"inline"},{choice:"squareLeft",i18nLabelKey:"squareLeft",i18nDescKey:"squareLeft",iconHint:"squareLeft"},{choice:"squareRight",i18nLabelKey:"squareRight",i18nDescKey:"squareRight",iconHint:"squareRight"},{choice:"behind",i18nLabelKey:"behindText",i18nDescKey:"behindText",iconHint:"behind"},{choice:"inFront",i18nLabelKey:"inFrontOfText",i18nDescKey:"inFrontOfText",iconHint:"inFront"}];function B(e,t){return true}function z(e){switch(e){case "inline":return "inline";case "square":case "tight":case "through":return "squareLeft";case "topAndBottom":return "topAndBottom";case "behind":return "behind";case "inFront":return "inFront";case "wrapRight":return "squareLeft";case "wrapLeft":return "squareRight";default:return}}function K(e,t){let o=t.filter(p=>p.parentId!=null);if(o.length===0)return;let r=new Map;for(let p of o){let a=r.get(p.parentId);a?a.push(p.id):r.set(p.parentId,[p.id]);}function i(p){for(let a of p)if(a.type==="paragraph"){if(!a.content.some(u=>u.type==="commentRangeStart"||u.type==="commentRangeEnd"))continue;let s=[];for(let u of a.content)if(u.type==="commentRangeStart"){s.push(u);let l=r.get(u.id);if(l)for(let m of l)s.push({type:"commentRangeStart",id:m});}else if(u.type==="commentRangeEnd"){s.push(u);let l=r.get(u.id);if(l)for(let m of l)s.push({type:"commentRangeEnd",id:m});}else s.push(u);a.content=s;}else if(a.type==="table")for(let s of a.rows)for(let u of s.cells)i(u.content);}i(e);}function X(e,t){let o=new Set(t.map(a=>a.id)),r=t.filter(a=>a.parentId!=null&&!o.has(a.parentId));if(r.length===0)return;let i=new Map;for(let a of r){let s=i.get(a.parentId);s?s.push(a.id):i.set(a.parentId,[a.id]);}function p(a){for(let s of a)if(s.type==="paragraph"){if(!s.content.some(f=>(f.type==="insertion"||f.type==="deletion")&&i.has(f.info.id)))continue;let l=[],m=s.content;for(let f=0;f<m.length;f++){let d=m[f];if((d.type==="insertion"||d.type==="deletion")&&i.has(d.info.id)){let g=i.get(d.info.id);for(let y of g)l.push({type:"commentRangeStart",id:y});l.push(d);let h=m[f+1];h&&(h.type==="insertion"||h.type==="deletion")&&h.type!==d.type&&h.info.author===d.info.author&&h.info.date===d.info.date&&(l.push(h),f++);for(let y of g)l.push({type:"commentRangeEnd",id:y});}else l.push(d);}s.content=l;}else if(s.type==="table")for(let u of s.rows)for(let l of u.cells)p(l.content);}p(e);}function $(e){let t=e?.package.headers;if(t){for(let o of t.values())if(o.watermark)return o.watermark}}function G(e){let t=e.package.headers;if(!t||t.size===0)return e;let o=false,r=new Map;for(let[i,p]of t)if(p.watermark){let{watermark:a,...s}=p;r.set(i,s),o=true;}else r.set(i,p);return o?{...e,package:{...e.package,headers:r}}:e}function N(e,t){let o=e.package.headers;if(!o||o.size===0)return e;let r=new Map;for(let[i,p]of o)r.set(i,{...p,watermark:{...t}});return {...e,package:{...e.package,headers:r}}}function j(e){let t=e.package.document,o=[];if(t.sections)for(let r of t.sections)r.properties&&o.push(r.properties);return t.finalSectionProperties&&o.push(t.finalSectionProperties),o}function U(e$1,t){let o=e$1.package,r=o.document,i=o.headers,p=j(e$1),a=new Set;if(i)for(let n of i.values())a.add(n.hdrFtrType);let s=!i||i.size===0,u=p.some(n=>n.titlePg),l=p.some(n=>n.evenAndOddHeaders),m=s,f=u&&!a.has("first"),d=l&&!a.has("even");if(!m&&!f&&!d)return e$1;let g=o.relationships?new Map(o.relationships):new Map,h=new Map(i??[]),y=new Set;for(let n of g.values())n.target&&y.add(n.target.replace(/^\/?word\//,"").toLowerCase());function P(){let n=1;for(;y.has(`header${n}.xml`);)n++;let c=`header${n}.xml`;return y.add(c.toLowerCase()),c}function v(n){let c=`rIdWmHdr${n[0].toUpperCase()}${n.slice(1)}`,I=1;for(;g.has(c);)c=`rIdWmHdr${n[0].toUpperCase()}${n.slice(1)}${I++}`;return g.set(c,{id:c,type:e.header,target:P()}),h.set(c,{type:"header",hdrFtrType:n,content:[],watermark:{...t}}),c}let T={};function F(n){return T[n]??(T[n]=v(n))}function L(n,c){let I=n?.headerReferences?[...n.headerReferences]:[];return I.some(S=>S.type===c)?n??{}:(I.push({type:c,rId:F(c)}),{...n??{},headerReferences:I})}function w(n){let c=n;return m&&(c=L(c,"default")),f&&c?.titlePg&&(c=L(c,"first")),d&&c?.evenAndOddHeaders&&(c=L(c,"even")),c}let M=w(r.finalSectionProperties),k=r.sections?.map(n=>({...n,properties:w(n.properties)??n.properties}));return {...e$1,package:{...o,relationships:g,headers:h,document:{...r,finalSectionProperties:M,...k?{sections:k}:{}}}}}function Y(e,t){if(!t)return G(e);let o=N(e,t);return U(o,t)}
|
|
2
2
|
export{_ as IMAGE_LAYOUT_OPTIONS,E as calculateResizedImageDimensions,W as deriveLayoutChoice,$ as getDocumentWatermark,K as injectReplyRangeMarkers,X as injectTCReplyRangeMarkers,B as isImageLayoutOptionEnabled,q as resolveImageLayoutAttrs,Y as setDocumentWatermark,z as toolbarValueToLayoutTarget};
|
package/dist/editor/index.d.mts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { R as ResidentMeasurementConfig } from '../rustMeasureSource-
|
|
2
|
-
import { L as LayoutBlock, B as BlockExtent, a as Layout, b as LayoutOptions } from '../types-
|
|
1
|
+
import { R as ResidentMeasurementConfig } from '../rustMeasureSource-C0EZB055.mjs';
|
|
2
|
+
import { L as LayoutBlock, B as BlockExtent, a as Layout, b as LayoutOptions } from '../types-CXLxVF1t.mjs';
|
|
3
3
|
import { MeasuredBlock } from '../layout/pagination/index.mjs';
|
|
4
|
-
import { D as DisplayListHeadersFooters } from '../rustDisplayList-
|
|
4
|
+
import { D as DisplayListHeadersFooters } from '../rustDisplayList-B9dQoLHI.mjs';
|
|
5
5
|
import { Document } from '../types/document.mjs';
|
|
6
|
-
import { Y as YrsSession, a as YrsRenderEnv } from '../index-
|
|
7
|
-
import { S as SectionProperties, N as NoteKind } from '../content-
|
|
8
|
-
import '../formatting-
|
|
9
|
-
import '../frameDelta-
|
|
10
|
-
import '../styles-
|
|
6
|
+
import { Y as YrsSession, a as YrsRenderEnv } from '../index-ImoMd0Ju.mjs';
|
|
7
|
+
import { S as SectionProperties, N as NoteKind } from '../content-DrqzbIr7.mjs';
|
|
8
|
+
import '../formatting-BqrFPeev.mjs';
|
|
9
|
+
import '../frameDelta-DMgR8n13.mjs';
|
|
10
|
+
import '../styles-CMybYYHS.mjs';
|
|
11
11
|
import '../docx/wrapTypes.mjs';
|
|
12
12
|
|
|
13
13
|
interface ResidentRegionLayoutRequest {
|
|
@@ -1,4 +1,129 @@
|
|
|
1
|
-
import { C as ColorValue,
|
|
1
|
+
import { y as ThemeColorSlot, C as ColorValue, f as Theme, x as ThemeColorScheme } from './formatting-BqrFPeev.mjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Color primitives and math shared across OOXML formats.
|
|
5
|
+
*
|
|
6
|
+
* Handles theme color slot references (accent1, dk1, ...), RGB hex values,
|
|
7
|
+
* tint/shade modifiers, and the derived color helpers (lighten/darken/blend/
|
|
8
|
+
* contrast) built on top of them.
|
|
9
|
+
*
|
|
10
|
+
* Tint/Shade Calculations (ECMA-376 §17.3.2.41):
|
|
11
|
+
* - Tint makes a color lighter (per-channel interpolation toward white)
|
|
12
|
+
* - Shade makes a color darker (per-channel interpolation toward black)
|
|
13
|
+
* - The wire value is a hex byte (00-FF) meaning "how much color to keep"
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Resolve a ColorValue to a CSS color string
|
|
18
|
+
*
|
|
19
|
+
* @param color - ColorValue object with rgb, themeColor, tint/shade, or auto
|
|
20
|
+
* @param theme - Theme for resolving theme colors
|
|
21
|
+
* @param defaultColor - Default color if auto or undefined (default: black)
|
|
22
|
+
* @returns CSS color string (e.g., "#FF0000" or "inherit")
|
|
23
|
+
*
|
|
24
|
+
* @public
|
|
25
|
+
*/
|
|
26
|
+
declare function resolveColor(color: ColorValue | undefined | null, theme: Theme | null | undefined, defaultColor?: string): string;
|
|
27
|
+
/**
|
|
28
|
+
* Resolve any ColorValue (text, fill/shading, border, underline) to a 6-char
|
|
29
|
+
* uppercase hex string — or `undefined` if transparent/unset/unresolvable.
|
|
30
|
+
*
|
|
31
|
+
* Shared display-side resolver. Prefer this over reading `.rgb` directly so
|
|
32
|
+
* that `themeColor` + `themeTint`/`themeShade` are honored consistently across
|
|
33
|
+
* all render paths.
|
|
34
|
+
*
|
|
35
|
+
* When a themed color is present but `theme` is null/undefined, falls back to
|
|
36
|
+
* `color.rgb` if Word wrote one for compat; otherwise returns `undefined`.
|
|
37
|
+
*
|
|
38
|
+
* @returns 6-char uppercase hex without `#`, or `undefined`.
|
|
39
|
+
*
|
|
40
|
+
* @public
|
|
41
|
+
*/
|
|
42
|
+
declare function resolveColorToHex(color: ColorValue | undefined | null, theme: Theme | null | undefined): string | undefined;
|
|
43
|
+
/**
|
|
44
|
+
* Get contrasting text color for a background
|
|
45
|
+
*
|
|
46
|
+
* @param backgroundColor - Background ColorValue
|
|
47
|
+
* @param theme - Theme for resolving theme colors
|
|
48
|
+
* @returns Black or white hex color for best contrast
|
|
49
|
+
*
|
|
50
|
+
* @public
|
|
51
|
+
*/
|
|
52
|
+
declare function getContrastingColor(backgroundColor: ColorValue | undefined | null, theme: Theme | null | undefined): string;
|
|
53
|
+
/**
|
|
54
|
+
* Darken a color by a percentage
|
|
55
|
+
*
|
|
56
|
+
* @param color - ColorValue to darken
|
|
57
|
+
* @param theme - Theme for resolving
|
|
58
|
+
* @param percent - Percentage to darken (0-100)
|
|
59
|
+
* @returns CSS color string
|
|
60
|
+
*
|
|
61
|
+
* @public
|
|
62
|
+
*/
|
|
63
|
+
declare function darkenColor(color: ColorValue | undefined | null, theme: Theme | null | undefined, percent: number): string;
|
|
64
|
+
/**
|
|
65
|
+
* Lighten a color by a percentage
|
|
66
|
+
*
|
|
67
|
+
* @param color - ColorValue to lighten
|
|
68
|
+
* @param theme - Theme for resolving
|
|
69
|
+
* @param percent - Percentage to lighten (0-100)
|
|
70
|
+
* @returns CSS color string
|
|
71
|
+
*
|
|
72
|
+
* @public
|
|
73
|
+
*/
|
|
74
|
+
declare function lightenColor(color: ColorValue | undefined | null, theme: Theme | null | undefined, percent: number): string;
|
|
75
|
+
/**
|
|
76
|
+
* Blend two colors together
|
|
77
|
+
*
|
|
78
|
+
* @param color1 - First color
|
|
79
|
+
* @param color2 - Second color
|
|
80
|
+
* @param ratio - Blend ratio (0 = all color1, 1 = all color2)
|
|
81
|
+
* @param theme - Theme for resolving
|
|
82
|
+
* @returns CSS color string
|
|
83
|
+
*
|
|
84
|
+
* @public
|
|
85
|
+
*/
|
|
86
|
+
declare function blendColors(color1: ColorValue | undefined | null, color2: ColorValue | undefined | null, ratio: number, theme: Theme | null | undefined): string;
|
|
87
|
+
/**
|
|
88
|
+
* Theme color matrix cell
|
|
89
|
+
*
|
|
90
|
+
* @public
|
|
91
|
+
*/
|
|
92
|
+
interface ThemeMatrixCell {
|
|
93
|
+
/** Resolved hex color (6 chars, no #) */
|
|
94
|
+
hex: string;
|
|
95
|
+
/** Theme color slot */
|
|
96
|
+
themeSlot: ThemeColorSlot;
|
|
97
|
+
/** Tint hex modifier if applicable (e.g., "CC") */
|
|
98
|
+
tint?: string;
|
|
99
|
+
/** Shade hex modifier if applicable (e.g., "BF") */
|
|
100
|
+
shade?: string;
|
|
101
|
+
/** Human-readable label (e.g., "Accent 1, Lighter 60%") */
|
|
102
|
+
label: string;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Compute a single tinted or shaded hex color from a base color.
|
|
106
|
+
*
|
|
107
|
+
* @param baseHex - 6-character hex color (no #)
|
|
108
|
+
* @param type - 'tint' to lighten, 'shade' to darken
|
|
109
|
+
* @param fraction - Amount (0-1). For tint: 0=no change, 1=white. For shade: 0=black, 1=no change.
|
|
110
|
+
* @returns 6-character hex color (no #)
|
|
111
|
+
*
|
|
112
|
+
* @public
|
|
113
|
+
*/
|
|
114
|
+
declare function getThemeTintShadeHex(baseHex: string, type: 'tint' | 'shade', fraction: number): string;
|
|
115
|
+
/**
|
|
116
|
+
* Generate the 10×6 theme color matrix for an advanced color picker.
|
|
117
|
+
*
|
|
118
|
+
* Columns: lt1, dk1, lt2, dk2, accent1-6 (matches Word's order)
|
|
119
|
+
* Rows: base, 80% tint, 60% tint, 40% tint, 25% shade, 50% shade
|
|
120
|
+
*
|
|
121
|
+
* @param colorScheme - Theme color scheme (falls back to Office 2016 defaults)
|
|
122
|
+
* @returns 6 rows × 10 columns of ThemeMatrixCell
|
|
123
|
+
*
|
|
124
|
+
* @public
|
|
125
|
+
*/
|
|
126
|
+
declare function generateThemeTintShadeMatrix(colorScheme?: ThemeColorScheme | null): ThemeMatrixCell[][];
|
|
2
127
|
|
|
3
128
|
/**
|
|
4
129
|
* Color Resolver - Convert OOXML colors to CSS
|
|
@@ -326,4 +451,4 @@ declare function extractFontsFromDocument(document: unknown): Set<string>;
|
|
|
326
451
|
*/
|
|
327
452
|
declare function loadDocumentFonts(document: unknown): Promise<void>;
|
|
328
453
|
|
|
329
|
-
export {
|
|
454
|
+
export { resolveShadingColor as A, setGoogleFontsEnabled as B, type FontDefinition as C, extractFontsFromDocument as D, getGoogleFontEquivalent as E, FONT_MAPPING as F, loadDocumentFonts as G, loadFontDefinitions as H, loadFontFromUrl as I, loadFontWithMapping as J, loadFontsWithMapping as K, onFontError as L, resolveColorToHex as M, type ThemeMatrixCell as T, colorsEqual as a, blendColors as b, canRenderFont as c, createRgbColor as d, createThemeColor as e, darkenColor as f, ensureHexPrefix as g, generateThemeTintShadeMatrix as h, getContrastingColor as i, getLoadedFonts as j, getThemeTintShadeHex as k, isBlack as l, isFontLoaded as m, isLoading as n, isGoogleFontsEnabled as o, isWhite as p, lightenColor as q, loadFont as r, loadFontFromBuffer as s, loadFonts as t, onFontsLoaded as u, parseColorString as v, preloadCommonFonts as w, resolveColor as x, resolveHighlightColor as y, resolveHighlightToCss as z };
|