@betteroffice/docx 0.0.3 → 0.0.4
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 +20 -7
- package/dist/chunk-4V6MDZIK.mjs +1 -0
- package/dist/chunk-6KDV6AIL.mjs +1 -0
- package/dist/chunk-CTBUQRYQ.mjs +1 -0
- package/dist/{chunk-IFT6DUJX.mjs → chunk-LTVVQMHB.mjs} +1 -1
- package/dist/chunk-NBSLB77E.mjs +1 -0
- package/dist/chunk-NTSSE5QK.mjs +57 -0
- package/dist/chunk-YTILOUAA.mjs +16 -0
- package/dist/collaboration/index.d.mts +32 -8
- package/dist/collaboration/index.mjs +1 -1
- package/dist/{content-MOZ6hKP4.d.mts → content-C3sTRz-u.d.mts} +517 -650
- package/dist/core.d.mts +6 -6
- package/dist/core.mjs +1 -1
- package/dist/{displayListQueries-BJlo7Jkz.d.mts → displayListQueries-DLzpvJV6.d.mts} +14 -3
- package/dist/docx/index.d.mts +3 -3
- package/dist/docx/index.mjs +1 -1
- package/dist/editor/index.d.mts +7 -7
- package/dist/{fontLoader-aSewHMKF.d.mts → fontLoader-CMH3bZ2Z.d.mts} +127 -2
- package/dist/{formatting-D1EPSaJP.d.mts → formatting-BEkIBePP.d.mts} +77 -203
- package/dist/{frameDelta-D965X8yK.d.mts → frameDelta-B2kC6XiP.d.mts} +4 -2
- package/dist/generated/edit/docx_edit_bg.wasm +0 -0
- package/dist/generated/layout/docx_layout_bg.wasm +0 -0
- package/dist/generated/parse/docx_parse_bg.wasm +0 -0
- package/dist/{index-Dx4Z3lkz.d.mts → index-2piKi4gO.d.mts} +66 -3
- package/dist/layout/index.d.mts +8 -7
- 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 +10 -10
- 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-B0M2eBkU.d.mts} +7 -2
- package/dist/styles/index.d.mts +2 -2
- package/dist/{styles-Dn_o3Vo5.d.mts → styles-BK3Jecxs.d.mts} +1 -1
- package/dist/types/content.d.mts +2 -2
- package/dist/types/document.d.mts +6 -6
- package/dist/{types-BfqUl2h_.d.mts → types-C1rv3KM-.d.mts} +2 -2
- package/dist/utils/comments.d.mts +2 -2
- package/dist/utils/index.d.mts +4 -4
- 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-F2ETFAYL.mjs +1 -0
- package/dist/wasm-JE7B3ROD.mjs +1 -0
- package/dist/wasm-edit.d.mts +24 -0
- package/dist/wasm-edit.mjs +1 -1
- package/dist/wasm-layout.d.mts +5 -1
- package/dist/wasm-layout.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 +1 -2
- package/dist/chunk-3UBMCDME.mjs +0 -1
- package/dist/chunk-AEQOEQJ7.mjs +0 -57
- package/dist/chunk-AZ52IWB6.mjs +0 -16
- 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
1
|
export { a as attemptSelectiveSave, c as createDocx, p as parseDocx, r as repackDocx, u as updateMultipleFiles } from './selectiveSave-CVoajSKE.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, b1 as Table } from './content-C3sTRz-u.mjs';
|
|
5
|
+
export { B as BlockContent, m as BookmarkEnd, n as BookmarkStart, f as Comment, G as CommentRangeEnd, I as CommentRangeStart, O as Deletion, j as Endnote, V as Field, $ as FooterReference, i as Footnote, H as HeaderFooter, a2 as HeaderReference, a3 as Hyperlink, a5 as Image, ah as Insertion, al as ListLevel, ao as MoveFrom, ar as MoveTo, h as NumberingDefinitions, P as Paragraph, aD as ParagraphContent, aH as Run, aI as RunContent, aS as Shape, b2 as TableCell, b5 as TableRow, b8 as TextBox, b9 as TextContent, bb as TrackedChangeInfo, bc as TrackedRunChange } from './content-C3sTRz-u.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-CMH3bZ2Z.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-C1rv3KM-.mjs';
|
|
11
|
+
export { a as ParagraphFormatting, b as TextFormatting, f as Theme, x as ThemeColorScheme, z as ThemeFont, A as ThemeFontScheme } from './formatting-BEkIBePP.mjs';
|
|
12
|
+
export { d as Relationship, a as Style, S as StyleDefinitions } from './styles-BK3Jecxs.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-NTSSE5QK.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-YTILOUAA.mjs';import'./chunk-6KDV6AIL.mjs';import'./chunk-NJHOPXZW.mjs';import'./chunk-B4IR6YP4.mjs';import'./chunk-T4EZMUXM.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-B2kC6XiP.mjs';
|
|
2
|
+
import { R as RustDisplayListQueryEngine } from './rustDisplayList-B0M2eBkU.mjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Locate an image primitive in a built DisplayList by its document position.
|
|
@@ -88,6 +88,7 @@ declare function captureInlinePositionEmuFromDisplayList(queries: DisplayListQue
|
|
|
88
88
|
/** Query surface implemented by the editing wasm over its resident list. */
|
|
89
89
|
interface ResidentDisplayListQueryEngine {
|
|
90
90
|
displayHitTestRegionsJson(pageIndex: number, x: number, y: number): string;
|
|
91
|
+
displayVerticalMoveJson(position: number, direction: 'up' | 'down', goalX: number): string;
|
|
91
92
|
displayRangeRectsJson(from: number, to: number): string;
|
|
92
93
|
displayRangeRectsRegionJson(region: 'body' | 'header' | 'footer', rId: string, from: number, to: number): string;
|
|
93
94
|
}
|
|
@@ -104,6 +105,10 @@ interface DisplayListRegionHit {
|
|
|
104
105
|
rId?: string;
|
|
105
106
|
pos: number | null;
|
|
106
107
|
}
|
|
108
|
+
interface DisplayListVerticalMove {
|
|
109
|
+
position: number;
|
|
110
|
+
goalX: number;
|
|
111
|
+
}
|
|
107
112
|
/** one highlight rectangle of a PM range, page-local px */
|
|
108
113
|
interface DisplayListRect {
|
|
109
114
|
pageIndex: number;
|
|
@@ -174,6 +179,7 @@ interface DisplayListQueries {
|
|
|
174
179
|
imageByPos(pos: number, region?: DisplayListHitRegion, rId?: string): DisplayListImageGeometry | null;
|
|
175
180
|
/** region-aware point → doc position (page-local coordinates) */
|
|
176
181
|
hitTestRegions(pageIndex: number, x: number, y: number): DisplayListRegionHit | null;
|
|
182
|
+
verticalMove(position: number, direction: 'up' | 'down', goalX?: number): DisplayListVerticalMove | null;
|
|
177
183
|
/** body PM range → highlight rects */
|
|
178
184
|
rangeRects(from: number, to: number): DisplayListRect[];
|
|
179
185
|
/**
|
|
@@ -224,6 +230,11 @@ interface DisplayListQueries {
|
|
|
224
230
|
*/
|
|
225
231
|
dispose(): void;
|
|
226
232
|
}
|
|
233
|
+
type DisplayListQuerySource = RustDisplayListQueryEngine | ResidentDisplayListQueryEngine;
|
|
234
|
+
/** True once a query trapped in this engine's wasm instance. */
|
|
235
|
+
declare function isDisplayListQuerySourceDead(engine: DisplayListQuerySource | null | undefined): boolean;
|
|
236
|
+
/** Subscribe to wasm traps so the host can rebuild the dead session. */
|
|
237
|
+
declare function onDisplayListQuerySourceFailure(listener: (error: Error) => void): () => void;
|
|
227
238
|
/**
|
|
228
239
|
* Build a query facade for one display list. The optional `engine` makes the
|
|
229
240
|
* facade synchronous and deterministic in tests; without it the shared wasm
|
|
@@ -237,4 +248,4 @@ interface DisplayListQueries {
|
|
|
237
248
|
*/
|
|
238
249
|
declare function createDisplayListQueries(list: DisplayList, engine?: RustDisplayListQueryEngine | ResidentDisplayListQueryEngine, previous?: DisplayListQueries | null): DisplayListQueries;
|
|
239
250
|
|
|
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 DisplayListImageGeometry as d, type DisplayListImageRegion as e, type DisplayListParagraphGeometry as f, type DisplayListQuerySourceState as g, type
|
|
251
|
+
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 DisplayListImageGeometry as d, type DisplayListImageRegion as e, type DisplayListParagraphGeometry as f, type DisplayListQuerySourceState as g, type DisplayListVerticalMove as h, type DisplayListVisualLine as i, captureInlinePositionEmuFromDisplayList as j, createDisplayListQueries as k, findImagePrimitiveAtPoint as l, findImagePrimitiveByDocPos as m, isDisplayListQuerySourceDead as n, onDisplayListQuerySourceFailure as o };
|
package/dist/docx/index.d.mts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
export { a as attemptSelectiveSave, c as createDocx, p as parseDocx, r as repackDocx, u as updateMultipleFiles } from '../selectiveSave-CVoajSKE.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-C3sTRz-u.mjs';
|
|
4
4
|
import { Document } from '../types/document.mjs';
|
|
5
5
|
import '../docxInput-DTbCa48g.mjs';
|
|
6
|
-
import '../formatting-
|
|
7
|
-
import '../styles-
|
|
6
|
+
import '../formatting-BEkIBePP.mjs';
|
|
7
|
+
import '../styles-BK3Jecxs.mjs';
|
|
8
8
|
|
|
9
9
|
type AnchorWrapType = Exclude<WrapType, 'inline'>;
|
|
10
10
|
type ImageLayoutTarget = AnchorWrapType | 'squareLeft' | 'squareRight' | 'inline';
|
package/dist/docx/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {e}from'../chunk-
|
|
1
|
+
import {e}from'../chunk-NTSSE5QK.mjs';export{i as attemptSelectiveSave,h as createDocx,a as parseDocx,f as repackDocx,g as updateMultipleFiles}from'../chunk-NTSSE5QK.mjs';import'../chunk-YTILOUAA.mjs';import'../chunk-6KDV6AIL.mjs';import'../chunk-NJHOPXZW.mjs';import'../chunk-B4IR6YP4.mjs';import'../chunk-T4EZMUXM.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
1
|
import { R as ResidentMeasurementConfig } from '../rustMeasureSource-D1KsQvVC.mjs';
|
|
2
|
-
import { L as LayoutBlock, B as BlockExtent, a as Layout, b as LayoutOptions } from '../types-
|
|
2
|
+
import { L as LayoutBlock, B as BlockExtent, a as Layout, b as LayoutOptions } from '../types-C1rv3KM-.mjs';
|
|
3
3
|
import { MeasuredBlock } from '../layout/pagination/index.mjs';
|
|
4
|
-
import { D as DisplayListHeadersFooters } from '../rustDisplayList-
|
|
4
|
+
import { D as DisplayListHeadersFooters } from '../rustDisplayList-B0M2eBkU.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-2piKi4gO.mjs';
|
|
7
|
+
import { S as SectionProperties, N as NoteKind } from '../content-C3sTRz-u.mjs';
|
|
8
|
+
import '../formatting-BEkIBePP.mjs';
|
|
9
|
+
import '../frameDelta-B2kC6XiP.mjs';
|
|
10
|
+
import '../styles-BK3Jecxs.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-BEkIBePP.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 };
|