@datalking/begonia-table 0.0.0-stage → 0.3.6
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/LICENSE.md +661 -0
- package/dist/chunk-2OAH5RMT.js +0 -0
- package/dist/chunk-36EAGHXY.js +0 -0
- package/dist/chunk-4VNOCJ4Y.js +1 -0
- package/dist/chunk-DODR4QN4.js +1 -0
- package/dist/chunk-N2TXWMCR.js +1 -0
- package/dist/chunk-RVGFFYBA.js +0 -0
- package/dist/chunk-T3O7N3HW.js +1 -0
- package/dist/chunk-VRAHV7NM.js +1 -0
- package/dist/contracts.d.ts +19 -0
- package/dist/contracts.js +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +1 -0
- package/dist/table-block-metrics.d.ts +58 -0
- package/dist/table-cell-anchor-position.d.ts +31 -0
- package/dist/table-cell-anchor-position.js +1 -0
- package/dist/table-cell-blocks.d.ts +51 -0
- package/dist/table-cell-blocks.js +1 -0
- package/dist/table-cell-margins.d.ts +17 -0
- package/dist/table-cell-margins.js +1 -0
- package/dist/table-cell-placement.d.ts +23 -0
- package/dist/table-cell-placement.js +1 -0
- package/dist/table-cell-text-segment.d.ts +37 -0
- package/dist/table-cell-text-segment.js +1 -0
- package/dist/table-cell-vertical-align.d.ts +19 -0
- package/dist/table-cell-vertical-align.js +1 -0
- package/dist/table-column-box.d.ts +13 -0
- package/dist/table-layout.d.ts +106 -0
- package/dist/table-layout.js +1 -0
- package/dist/table-primitives.d.ts +227 -0
- package/dist/table-row-measure-memo.d.ts +15 -0
- package/dist/table-text-space.d.ts +120 -0
- package/package.json +63 -4
- package/README.md +0 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function w(e,n,i){return e.toOffset>n&&e.fromOffset<i}function O(e,n,i,m){let a=Math.max(n,e.fromOffset),l=Math.min(i,e.toOffset);if(l<=a)return null;let t=a-e.fromOffset,s=l-e.fromOffset,g=e.text.slice(t,s),B=m(e.segment.inlineSpans,t,s),y=e.lineSlices??[],p=y.flatMap((r,o)=>r.toOffset>t&&r.fromOffset<s?[o]:[]),c=p.map((r,o,u)=>{let f=y[r],h=Math.max(t,f.fromOffset),C=Math.min(s,f.toOffset);return{...f,lineIndex:o,lineCount:u.length,text:e.text.slice(h,C),fromOffset:h-t,toOffset:C-t}}),S=e.lineFrames??[],x=p.map((r,o,u)=>({...S[r]??{leftInset:0,rightInset:0,availableWidth:e.containerWidth??1},lineIndex:o,lineCount:u.length})),T=t===0?e.segment.spacingBefore:0,b=s===e.text.length?e.segment.spacingAfter:0,d=r=>{let o=Number(r??0);return Number.isFinite(o)?Math.max(0,o):0},R=c.length>0?c.length*Math.max(1,Number(e.segment.lineHeight??1)):Math.max(0,e.flowHeight-d(e.segment.spacingBefore)-d(e.segment.spacingAfter));return{...e,fromOffset:a-n,toOffset:l-n,text:g,flowHeight:R+d(T)+d(b),lineSlices:c.length>0?c:null,lineFrames:x.length>0?x:null,segment:{...e.segment,text:g,spacingBefore:T,spacingAfter:b,inlineSpans:B??null}}}function P(e,n,i,m){if(!e||i<=n)return null;let a=[];for(let l of e)if(w(l,n,i)){if(l.kind==="text"){let t=O(l,n,i,m);t&&a.push(t);continue}a.push({...l,fromOffset:l.fromOffset-n,toOffset:l.toOffset-n})}return a.length>0?a:null}export{P as a};
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as y}from"./chunk-VRAHV7NM.js";var G=" | ",V=1;function C(e){let n=e.length;for(;n>0&&e.charCodeAt(n-1)===32;)n-=1;return e.slice(0,n)}function S(e){return e.join(" | ")}function k(e){return S(e).length+1}function O(e){return e.map(n=>C(n).trim()).filter(n=>n.length>0).join(" | ")}function B(e,n=0){let t=[],l=0;for(let o=0;o<e.length;o+=1){let a=typeof e[o]=="string"?e[o]:"";o>0&&(l+=3);let c=C(a);t.push({textStart:l,textLength:a.length,addressableLength:c.length,text:a,addressableText:c}),l+=a.length}let r=S(e);return{from:n,to:n+r.length,text:r,paintText:O(e),cells:t}}function L(e){let n=[],t=0;for(let l of e)n.push(B(l,t)),t+=k(l);return{rows:n,length:n.length>0?n[n.length-1].to:0}}function z(e,n,t,l){let r=e.rows[n],o=r?.cells[t];return!r||!o?null:r.from+o.textStart+l}function H(e,n){for(let t=0;t<e.rows.length;t+=1){let l=e.rows[t];if(!(n<l.from||n>l.to)){for(let r=0;r<l.cells.length;r+=1){let o=l.cells[r],a=l.from+o.textStart;if(n>=a&&n<=a+o.addressableLength)return{rowIndex:t,cellIndex:r,cell:o,inCell:n-a}}return null}}return null}var q=10,J=0,f=4096;function b(e){try{if(!Array.isArray(e))return!1;let n=Number(e.length);if(!Number.isSafeInteger(n)||n<0||n>f)return!1;for(let t=0;t<n;t+=1)if(!Object.prototype.hasOwnProperty.call(e,t))return!1;return!0}catch{return!1}}function i(e,n=0){try{let t=Number(e);return Number.isFinite(t)?t:n}catch{return n}}function g(e,n){let t=i(e,n);return t<0?n:Math.min(f,Math.max(0,Math.round(t)))}function A(e){return Math.max(1,g(e,1))}function N(e){return e==="start"||e==="continue"?e:null}function K(e,n,t){return{text:e,blocks:null,inlineSpans:null,lineSlices:null,originRow:n,originColumn:t,rowSpan:1,colSpan:1,mergeKind:null}}function F(e,n){let t=i(e?.[n],-1);return Number.isInteger(t)&&t>=0?t:n}function P(e){return b(e)?e.length:0}function D(e,n){return Math.max(P(e),P(n))}function M(e){return`${e.originRow}:${e.originColumn}`}function X(e,n){return e.cells.some(t=>M(t)===n)}function W(e,n,t){let l=0;for(let r=n;r<e.length&&X(e[r],t);r+=1)l+=1;return Math.max(1,l)}function j(e){let{row:n=[],cellLayouts:t=[],fragmentRowIndex:l=0,sourceRowIndex:r=l}=e,o=n??[],a=t??[],c=[],s=0;for(let m=0;m<D(o,a);m+=1){let w=o[m]??"",u=a[m]??K(w,r,s),R=u.text??w,d=A(u.colSpan),T=g(u.originColumn,s),x=N(u.mergeKind),v=g(u.originRow,r),p=Math.min(r,v),_=x==="continue"?r-p+1:1,h=Math.max(_,A(u.rowSpan)),I={...u,text:R,originRow:p,originColumn:T,rowSpan:h,colSpan:d,mergeKind:x};c.push({text:R,layout:I,physicalIndex:m,fragmentRowIndex:l,sourceRowIndex:r,originRow:p,originColumn:T,rowSpan:h,colSpan:d,mergeKind:x}),s=Math.max(s,T+d)}return c}function E(e){let n=y(e),t=b(n?.rows)?n.rows:[],l=b(n?.cells)?n.cells:[];return Array.from({length:Math.max(t.length,l.length)},(r,o)=>{let a=F(n?.rowSourceIndexes,o),c=t[o]??[],s=l[o]??[];return{row:c,cellLayouts:s,fragmentRowIndex:o,sourceRowIndex:a,cells:j({row:c,cellLayouts:s,fragmentRowIndex:o,sourceRowIndex:a})}})}function Q(e,n,t){let l=Math.max(0,Math.min(Math.trunc(i(n,0)),Math.max(0,t)));return l<=0?0:Math.trunc(i(e.sourceRowIndex,0))<l?1:0}function Y(e){let n=E(e),t=new Set;return n.map((l,r)=>{let o=L([l.row]).rows[0];return{...l,cells:l.cells.flatMap(a=>{let c=M(a);return t.has(c)?[]:(t.add(c),[{...a,rowSpanInFragment:W(n,r,c),textStart:o.cells[a.physicalIndex]?.textStart??0}])})}})}function ee(e){let n=e.table?.columnWidths,t=b(n)?n.length:0;for(let l of E(e))for(let r of l.cells)t=Math.max(t,r.originColumn+r.colSpan);return Math.min(f,Math.max(t,1))}function ne(e,n){let t=Math.max(0,n.originColumn),l=Math.max(t+1,t+Math.max(1,n.colSpan)),r=b(e)?e.slice(t,l).reduce((a,c)=>a+Math.max(0,i(c)),0):0;return r>0?r:Math.max(0,i(e[e.length-1]))*Math.max(1,n.colSpan)}export{G as a,V as b,C as c,S as d,k as e,O as f,B as g,L as h,z as i,H as j,q as k,J as l,N as m,j as n,E as o,Q as p,Y as q,ee as r,ne as s};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function e(l){return l?.table??null}export{e as a};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The table contract surface: the leaf primitives, the table metrics reader and
|
|
3
|
+
* the table types every table planner consumes.
|
|
4
|
+
*
|
|
5
|
+
* The cell and planner modules are re-exported as types only, so this entry
|
|
6
|
+
* never pulls runtime placement code: a consumer that only types a snapshot or
|
|
7
|
+
* reads table metrics imports this subpath and never loads `table-layout`.
|
|
8
|
+
* Callers that need the placement planners import the module subpaths.
|
|
9
|
+
*/
|
|
10
|
+
export * from './table-primitives.ts';
|
|
11
|
+
export * from './table-block-metrics.ts';
|
|
12
|
+
export type { TableCellAnchorHorizontalAlignment, TableCellAnchorVerticalAlignment, } from './table-cell-anchor-position.ts';
|
|
13
|
+
export type { TableCellBlockPlacement, TableCellDrawingBlockPlacement, TableCellImageBlockPlacement, TableCellInlineSpanSlicer, TableCellMediaBlockPlacement, TableCellTextBlockPlacement, } from './table-cell-blocks.ts';
|
|
14
|
+
export type { LayoutTableCellMargins } from './table-cell-margins.ts';
|
|
15
|
+
export type { TableCellMergeKind, TableCellPlacement, } from './table-cell-placement.ts';
|
|
16
|
+
export type { TableCellParagraphTextFlowOptions, TableCellTextSegment, } from './table-cell-text-segment.ts';
|
|
17
|
+
export type { TableCellVerticalAlign } from './table-cell-vertical-align.ts';
|
|
18
|
+
export type { RenderableTableCellPlacement, RenderableTableRowPlacement, ResolvedTableCellPlacement, ResolvedTableRowPlacement, TableFragmentLike, } from './table-layout.ts';
|
|
19
|
+
export type { LayoutTableRowMeasureMemo } from './table-row-measure-memo.ts';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as e}from"./chunk-VRAHV7NM.js";export{e as resolveLayoutTableBlockMetrics};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export * from './table-primitives.ts';
|
|
2
|
+
export * from './table-cell-text-segment.ts';
|
|
3
|
+
export * from './table-layout.ts';
|
|
4
|
+
export * from './table-text-space.ts';
|
|
5
|
+
export * from './table-block-metrics.ts';
|
|
6
|
+
export * from './table-cell-blocks.ts';
|
|
7
|
+
export * from './table-cell-margins.ts';
|
|
8
|
+
export * from './table-cell-vertical-align.ts';
|
|
9
|
+
export * from './table-cell-placement.ts';
|
|
10
|
+
export * from './table-column-box.ts';
|
|
11
|
+
export * from './table-cell-anchor-position.ts';
|
|
12
|
+
export * from './table-row-measure-memo.ts';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as l,b,c as h,d as M,e as c,f as d,g as s,h as g,i as w,j as N,k,l as v,m as y,n as B,o as C,p as F,q as T,r as j,s as q}from"./chunk-T3O7N3HW.js";import{a as u}from"./chunk-VRAHV7NM.js";import{a as E,b as G}from"./chunk-DODR4QN4.js";import{a as z}from"./chunk-N2TXWMCR.js";import"./chunk-RVGFFYBA.js";import"./chunk-36EAGHXY.js";import"./chunk-2OAH5RMT.js";import{a as A,b as D}from"./chunk-4VNOCJ4Y.js";function H(e,t,x,a,p){let o=Math.max(0,Math.min(t,e.length)),i=Math.max(o,Math.min(o+Math.max(1,x),e.length)),m=0;for(let r=0;r<o;r+=1)m+=f(e[r]);let n=0;for(let r=o;r<i;r+=1)n+=f(e[r]);return p?{left:Math.max(0,a-m-n),width:n}:{left:m,width:n}}function f(e){let t=Number(e);return Number.isFinite(t)&&t>0?t:0}export{k as TABLE_CELL_HORIZONTAL_PADDING,l as TABLE_CELL_TEXT_SEPARATOR,v as TABLE_CELL_VERTICAL_PADDING,b as TABLE_ROW_TEXT_ADVANCE,y as normalizeMergeKind,A as normalizeTableCellVerticalAlign,u as resolveLayoutTableBlockMetrics,T as resolveRenderableTableRows,E as resolveTableCellAnchorOffsetX,G as resolveTableCellAnchorOffsetY,N as resolveTableCellAtTextOffset,q as resolveTableCellColumnWidth,w as resolveTableCellTextOffset,D as resolveTableCellVerticalOffset,H as resolveTableColumnBox,C as resolveTableFragmentRows,F as resolveTableHeaderStyleRowCount,j as resolveTableLogicalColumnCount,c as resolveTableRowAdvance,B as resolveTableRowCells,d as resolveTableRowPaintText,M as resolveTableRowText,s as resolveTableRowTextSpace,g as resolveTableTextSpace,z as sliceTableCellBlocksByOffsets,h as trimTableCellAddressableText};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { TableCellPlacement } from './table-cell-placement.ts';
|
|
2
|
+
import type { LayoutTableCellMargins } from './table-cell-margins.ts';
|
|
3
|
+
/**
|
|
4
|
+
* Table-specific measurements a laid out block carries.
|
|
5
|
+
*
|
|
6
|
+
* The fields were historically flattened onto `LayoutBlockEstimate` as
|
|
7
|
+
* `tableRows`, `tableWidth` and so on. Keeping them behind one optional object
|
|
8
|
+
* gives the table contract a single type edge instead of one field per concern;
|
|
9
|
+
* the names inside drop the redundant `table` prefix because the object already
|
|
10
|
+
* says it.
|
|
11
|
+
*/
|
|
12
|
+
export interface LayoutTableBlockMetrics {
|
|
13
|
+
/** Row texts, in fragment order. */
|
|
14
|
+
rows?: readonly (readonly string[])[];
|
|
15
|
+
/** Cell placements parallel to `rows`. */
|
|
16
|
+
cells?: readonly (readonly TableCellPlacement[])[];
|
|
17
|
+
/** Authored column widths, in CSS pixels. */
|
|
18
|
+
columnWidths?: readonly number[] | null;
|
|
19
|
+
/** Authored table width, in CSS pixels. */
|
|
20
|
+
width?: number | null;
|
|
21
|
+
/** Measured row heights for the rows in this fragment. */
|
|
22
|
+
rowHeights?: readonly number[] | null;
|
|
23
|
+
/** Source document row index for each fragment row. */
|
|
24
|
+
rowSourceIndexes?: readonly number[] | null;
|
|
25
|
+
/** `w:cantSplit`: a row that may not be broken across pages. */
|
|
26
|
+
rowCantSplit?: readonly boolean[] | null;
|
|
27
|
+
/** Footnote ids owned by each row. */
|
|
28
|
+
rowNoteIds?: readonly (readonly string[])[] | null;
|
|
29
|
+
/** Endnote ids owned by each row. */
|
|
30
|
+
rowEndnoteIds?: readonly (readonly string[])[] | null;
|
|
31
|
+
/** Leading rows the paginator repeats per fragment - OOXML `w:tblHeader`. */
|
|
32
|
+
headerRowCount?: number;
|
|
33
|
+
/**
|
|
34
|
+
* Leading rows formatted as a header. Distinct from the repeat count:
|
|
35
|
+
* `w:tblLook/@w:firstRow` styles a row without repeating it.
|
|
36
|
+
*/
|
|
37
|
+
headerStyleRowCount?: number;
|
|
38
|
+
/** Authored cell margins, or null when the table inherits them. */
|
|
39
|
+
cellMargins?: Readonly<LayoutTableCellMargins> | null;
|
|
40
|
+
/** Horizontal offset `w:tblInd` puts on an inline table, in CSS pixels. */
|
|
41
|
+
leftIndent?: number | null;
|
|
42
|
+
/** `w:bidiVisual`: `rtl` mirrors column order, `ltr` leaves it alone. */
|
|
43
|
+
direction?: 'ltr' | 'rtl' | null;
|
|
44
|
+
displayMode?: string | null;
|
|
45
|
+
wrapMode?: string | null;
|
|
46
|
+
offsetX?: number | null;
|
|
47
|
+
offsetY?: number | null;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Reads the table metrics from a block.
|
|
51
|
+
*
|
|
52
|
+
* `block.table` is the only representation: the flat `tableRows`,
|
|
53
|
+
* `tableWidth` and friends were retired when the table contract moved into
|
|
54
|
+
* this package, and nothing writes or reads them anymore.
|
|
55
|
+
*/
|
|
56
|
+
export declare function resolveLayoutTableBlockMetrics(block: {
|
|
57
|
+
readonly table?: LayoutTableBlockMetrics | null;
|
|
58
|
+
} | null | undefined): LayoutTableBlockMetrics | null;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export type TableCellAnchorHorizontalAlignment = 'left' | 'center' | 'right';
|
|
2
|
+
export type TableCellAnchorVerticalAlignment = 'top' | 'center' | 'bottom';
|
|
3
|
+
type AnchorRecord = Readonly<Record<string, unknown>>;
|
|
4
|
+
/**
|
|
5
|
+
* Resolves the horizontal position of anchored media in a table-cell content
|
|
6
|
+
* box. OOXML alignment is relative to the containing column; a positive offset
|
|
7
|
+
* moves left for right alignment, matching Word's `posOffset` semantics.
|
|
8
|
+
*/
|
|
9
|
+
export declare function resolveTableCellAnchorOffsetX(input: {
|
|
10
|
+
containerWidth: number;
|
|
11
|
+
objectWidth: number;
|
|
12
|
+
offsetX: number | null | undefined;
|
|
13
|
+
alignment?: string | null;
|
|
14
|
+
position?: AnchorRecord | null;
|
|
15
|
+
}): number;
|
|
16
|
+
/**
|
|
17
|
+
* Resolves a table-cell anchor's local top offset. Paragraph-relative anchors
|
|
18
|
+
* use the anchor paragraph's first-line box, while page/margin-relative anchors
|
|
19
|
+
* use the supplied cell content height when it is known. Unknown non-paragraph
|
|
20
|
+
* geometry intentionally falls back to the authored offset.
|
|
21
|
+
*/
|
|
22
|
+
export declare function resolveTableCellAnchorOffsetY(input: {
|
|
23
|
+
objectHeight: number;
|
|
24
|
+
offsetY: number | null | undefined;
|
|
25
|
+
alignment?: string | null;
|
|
26
|
+
position?: AnchorRecord | null;
|
|
27
|
+
paragraphTop?: number;
|
|
28
|
+
firstLineHeight?: number;
|
|
29
|
+
containerHeight?: number | null;
|
|
30
|
+
}): number;
|
|
31
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a,b}from"./chunk-DODR4QN4.js";export{a as resolveTableCellAnchorOffsetX,b as resolveTableCellAnchorOffsetY};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { TableCellTextSegment } from './table-cell-text-segment.ts';
|
|
2
|
+
import type { InlineRevisionSpan, LayoutDrawingPayload, MeasuredLineSlice, TextLineFrame } from './table-primitives.ts';
|
|
3
|
+
/** Rebases one block's inline revision spans onto a sliced text range. */
|
|
4
|
+
export type TableCellInlineSpanSlicer = (spans: readonly InlineRevisionSpan[] | null | undefined, fromOffset: number, toOffset: number) => readonly InlineRevisionSpan[] | null;
|
|
5
|
+
interface TableCellBlockRange {
|
|
6
|
+
/** Offsets in the flattened table-cell text, including media placeholders. */
|
|
7
|
+
readonly fromOffset: number;
|
|
8
|
+
readonly toOffset: number;
|
|
9
|
+
/** Height contributed to normal flow. Anchored objects may contribute zero. */
|
|
10
|
+
readonly flowHeight: number;
|
|
11
|
+
}
|
|
12
|
+
export interface TableCellTextBlockPlacement extends TableCellBlockRange {
|
|
13
|
+
readonly kind: 'text';
|
|
14
|
+
readonly text: string;
|
|
15
|
+
readonly segment: Readonly<TableCellTextSegment>;
|
|
16
|
+
readonly containerWidth?: number | null;
|
|
17
|
+
readonly lineSlices?: readonly MeasuredLineSlice[] | null;
|
|
18
|
+
readonly lineFrames?: readonly TextLineFrame[] | null;
|
|
19
|
+
}
|
|
20
|
+
export interface TableCellImageBlockPlacement extends TableCellBlockRange {
|
|
21
|
+
readonly kind: 'image';
|
|
22
|
+
readonly src: string;
|
|
23
|
+
readonly width: number;
|
|
24
|
+
readonly height: number;
|
|
25
|
+
readonly alt: string | null;
|
|
26
|
+
readonly title: string | null;
|
|
27
|
+
readonly objectId: string | null;
|
|
28
|
+
readonly displayMode: 'inline' | 'anchor';
|
|
29
|
+
readonly wrapMode: string | null;
|
|
30
|
+
readonly wrapSide: string | null;
|
|
31
|
+
readonly offsetX: number | null;
|
|
32
|
+
readonly offsetY: number | null;
|
|
33
|
+
readonly position: Readonly<Record<string, unknown>> | null;
|
|
34
|
+
readonly wrapDistances: Readonly<Record<string, unknown>> | null;
|
|
35
|
+
readonly anchorOptions: Readonly<Record<string, unknown>> | null;
|
|
36
|
+
readonly rotation: number | null;
|
|
37
|
+
readonly flipHorizontal: boolean;
|
|
38
|
+
readonly flipVertical: boolean;
|
|
39
|
+
readonly crop: Readonly<Record<string, unknown>> | null;
|
|
40
|
+
readonly decorative: boolean;
|
|
41
|
+
readonly hyperlink: Readonly<Record<string, unknown>> | null;
|
|
42
|
+
}
|
|
43
|
+
export interface TableCellDrawingBlockPlacement extends TableCellBlockRange {
|
|
44
|
+
readonly kind: 'drawing';
|
|
45
|
+
readonly drawing: Readonly<LayoutDrawingPayload>;
|
|
46
|
+
}
|
|
47
|
+
export type TableCellMediaBlockPlacement = TableCellImageBlockPlacement | TableCellDrawingBlockPlacement;
|
|
48
|
+
export type TableCellBlockPlacement = TableCellTextBlockPlacement | TableCellMediaBlockPlacement;
|
|
49
|
+
/** Selects and rebases ordered cell blocks for a paginated row fragment. */
|
|
50
|
+
export declare function sliceTableCellBlocksByOffsets(blocks: readonly TableCellBlockPlacement[] | null | undefined, fromOffset: number, toOffset: number, sliceInlineSpans: TableCellInlineSpanSlicer): TableCellBlockPlacement[] | null;
|
|
51
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a}from"./chunk-N2TXWMCR.js";export{a as sliceTableCellBlocksByOffsets};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Authored table cell margins in CSS pixels, one entry per side.
|
|
3
|
+
*
|
|
4
|
+
* A side stays `null` when the document does not author it, which is not the
|
|
5
|
+
* same as zero: the layout has to fall back to the default padding for that side
|
|
6
|
+
* alone. Collapsing an unauthored side to zero would shrink the cell below what
|
|
7
|
+
* the renderer paints and put every caret in the cell on the wrong line.
|
|
8
|
+
*
|
|
9
|
+
* The importer already converts `w:tblCellMar` twips to pixels, so these values
|
|
10
|
+
* are layout units and need no further scaling.
|
|
11
|
+
*/
|
|
12
|
+
export interface LayoutTableCellMargins {
|
|
13
|
+
top: number | null;
|
|
14
|
+
right: number | null;
|
|
15
|
+
bottom: number | null;
|
|
16
|
+
left: number | null;
|
|
17
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./chunk-RVGFFYBA.js";
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { TableCellBlockPlacement } from './table-cell-blocks.ts';
|
|
2
|
+
import type { TableCellVerticalAlign } from './table-cell-vertical-align.ts';
|
|
3
|
+
import type { InlineRevisionSpan, MeasuredLineSlice } from './table-primitives.ts';
|
|
4
|
+
import type { TableCellTextSegment } from './table-cell-text-segment.ts';
|
|
5
|
+
export type { TableCellParagraphTextFlowOptions, TableCellTextSegment, } from './table-cell-text-segment.ts';
|
|
6
|
+
/** Whether a cell starts a merge or continues the cell above it. */
|
|
7
|
+
export type TableCellMergeKind = 'start' | 'continue';
|
|
8
|
+
/** One cell of a laid out table row. */
|
|
9
|
+
export interface TableCellPlacement {
|
|
10
|
+
text: string;
|
|
11
|
+
blocks?: readonly TableCellBlockPlacement[] | null;
|
|
12
|
+
inlineSpans?: readonly InlineRevisionSpan[] | null;
|
|
13
|
+
lineSlices?: readonly MeasuredLineSlice[] | null;
|
|
14
|
+
lineHeights?: readonly number[] | null;
|
|
15
|
+
segments?: readonly TableCellTextSegment[] | null;
|
|
16
|
+
originRow?: number | null;
|
|
17
|
+
originColumn?: number | null;
|
|
18
|
+
rowSpan?: number | null;
|
|
19
|
+
colSpan?: number | null;
|
|
20
|
+
mergeKind?: TableCellMergeKind | null;
|
|
21
|
+
/** `w:vAlign`: where the cell's content sits inside the row's height. */
|
|
22
|
+
verticalAlign?: TableCellVerticalAlign | null;
|
|
23
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./chunk-36EAGHXY.js";
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { InlineRevisionSpan } from './table-primitives.ts';
|
|
2
|
+
/**
|
|
3
|
+
* Text-flow switches a table cell's paragraphs carry.
|
|
4
|
+
*
|
|
5
|
+
* Declared here rather than imported from `paragraph-text-flow.ts` so the table
|
|
6
|
+
* contract modules do not depend on the rest of layout-contracts. The shape is
|
|
7
|
+
* the same seven nullable booleans, so it remains assignable to the host's
|
|
8
|
+
* `ParagraphTextFlowOptions`.
|
|
9
|
+
*/
|
|
10
|
+
export interface TableCellParagraphTextFlowOptions {
|
|
11
|
+
kinsoku?: boolean | null;
|
|
12
|
+
wordWrap?: boolean | null;
|
|
13
|
+
overflowPunct?: boolean | null;
|
|
14
|
+
topLinePunct?: boolean | null;
|
|
15
|
+
autoSpaceDE?: boolean | null;
|
|
16
|
+
autoSpaceDN?: boolean | null;
|
|
17
|
+
snapToGrid?: boolean | null;
|
|
18
|
+
}
|
|
19
|
+
export interface TableCellTextSegment {
|
|
20
|
+
text: string;
|
|
21
|
+
nodeType?: string | null;
|
|
22
|
+
fontSize?: number | null;
|
|
23
|
+
lineHeight?: number | null;
|
|
24
|
+
spacingBefore?: number | null;
|
|
25
|
+
spacingAfter?: number | null;
|
|
26
|
+
indentLeft?: number | null;
|
|
27
|
+
indentRight?: number | null;
|
|
28
|
+
firstLineIndent?: number | null;
|
|
29
|
+
tabs?: readonly {
|
|
30
|
+
position: number;
|
|
31
|
+
align?: string | null;
|
|
32
|
+
leader?: string | null;
|
|
33
|
+
}[] | null;
|
|
34
|
+
decimalSeparator?: string | null;
|
|
35
|
+
paragraphTextFlow?: TableCellParagraphTextFlowOptions | null;
|
|
36
|
+
inlineSpans?: readonly InlineRevisionSpan[] | null;
|
|
37
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./chunk-2OAH5RMT.js";
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vertical alignment of a table cell's content, from `w:vAlign`.
|
|
3
|
+
*
|
|
4
|
+
* A cell is as tall as its row, and the content can sit at the top, in the
|
|
5
|
+
* middle or at the bottom of that box. LibreOffice paints the same cell text at
|
|
6
|
+
* three different heights for the three values, so this is a real vertical
|
|
7
|
+
* offset and not a paint-time decoration.
|
|
8
|
+
*/
|
|
9
|
+
export type TableCellVerticalAlign = 'top' | 'center' | 'bottom';
|
|
10
|
+
/** Normalize a raw `w:vAlign` value. */
|
|
11
|
+
export declare function normalizeTableCellVerticalAlign(value: unknown): TableCellVerticalAlign | null;
|
|
12
|
+
/**
|
|
13
|
+
* Offset from the row's content top down to the cell's first line.
|
|
14
|
+
*
|
|
15
|
+
* Centring has to split the leftover space, which is why it needs both the row
|
|
16
|
+
* box and the content height rather than just a flag. A cell taller than the row
|
|
17
|
+
* has no leftover space, so every alignment collapses to the top there.
|
|
18
|
+
*/
|
|
19
|
+
export declare function resolveTableCellVerticalOffset(align: TableCellVerticalAlign | null | undefined, rowContentHeight: number, cellContentHeight: number): number;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a,b}from"./chunk-4VNOCJ4Y.js";export{a as normalizeTableCellVerticalAlign,b as resolveTableCellVerticalOffset};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Horizontal box of one logical column inside a table.
|
|
3
|
+
*
|
|
4
|
+
* `w:bidiVisual` flips a table's column order without touching the cell data:
|
|
5
|
+
* LibreOffice paints the text of a two column table at x 72.1 then 288.1 in the
|
|
6
|
+
* default direction and at 288.1 then 72.1 once the flag is set. The cells keep
|
|
7
|
+
* their logical indices, so only the box moves - mirroring the data would
|
|
8
|
+
* reorder the document text itself.
|
|
9
|
+
*/
|
|
10
|
+
export declare function resolveTableColumnBox(columnWidths: readonly number[], originColumn: number, colSpan: number, totalWidth: number, mirrored: boolean): {
|
|
11
|
+
left: number;
|
|
12
|
+
width: number;
|
|
13
|
+
};
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { type LayoutTableBlockMetrics } from './table-block-metrics.ts';
|
|
2
|
+
import type { TableCellMergeKind, TableCellPlacement } from './table-cell-placement.ts';
|
|
3
|
+
/**
|
|
4
|
+
* Space between a cell's border and its text, on one horizontal side.
|
|
5
|
+
*
|
|
6
|
+
* Text is laid out inside the cell's content box, which is narrower than the
|
|
7
|
+
* column by this padding on each side. Wrapping against the column width instead
|
|
8
|
+
* lets a line accept text the browser then has to break, so the model and the
|
|
9
|
+
* paint disagree about how many lines a cell holds. Live measurement showed a
|
|
10
|
+
* 320px column with this padding wrapping 142 characters into 4 model lines
|
|
11
|
+
* while the browser painted 6, which put every caret in a wrapped cell on the
|
|
12
|
+
* wrong line.
|
|
13
|
+
*/
|
|
14
|
+
export declare const TABLE_CELL_HORIZONTAL_PADDING = 10;
|
|
15
|
+
/**
|
|
16
|
+
* Space between a cell's border and its text, on one vertical side, when the
|
|
17
|
+
* document does not author one.
|
|
18
|
+
*
|
|
19
|
+
* Zero, because that is what OOXML says: a `tblCellMar` that omits `top` or
|
|
20
|
+
* `bottom` means no inset on that side. Word only writes the element when it
|
|
21
|
+
* means something, and a table produced without it paints its text flush to the
|
|
22
|
+
* border.
|
|
23
|
+
*
|
|
24
|
+
* Measured twice, on differently shaped tables. A 5x3 table with no `tblCellMar`
|
|
25
|
+
* renders its rows 13.40pt apart against a 13.20pt single-spaced line box for
|
|
26
|
+
* 11pt text - a 0.20pt difference, which is rounding, not inset. The same holds
|
|
27
|
+
* for a 3x2 table and, decisively, for a 30-row one: at 8px per side the rows
|
|
28
|
+
* measure 40.3px each against the reference 17.87px, and the 673px that
|
|
29
|
+
* accumulates over 30 rows turns a one-page document into two.
|
|
30
|
+
*
|
|
31
|
+
* The horizontal default stays non-zero - it has its own measurement behind it,
|
|
32
|
+
* and the two sides are set by different parts of Word's layout.
|
|
33
|
+
*/
|
|
34
|
+
export declare const TABLE_CELL_VERTICAL_PADDING = 0;
|
|
35
|
+
export interface TableFragmentLike {
|
|
36
|
+
table?: LayoutTableBlockMetrics | null;
|
|
37
|
+
}
|
|
38
|
+
export interface ResolvedTableCellPlacement {
|
|
39
|
+
text: string;
|
|
40
|
+
layout: TableCellPlacement;
|
|
41
|
+
physicalIndex: number;
|
|
42
|
+
fragmentRowIndex: number;
|
|
43
|
+
sourceRowIndex: number;
|
|
44
|
+
originRow: number;
|
|
45
|
+
originColumn: number;
|
|
46
|
+
rowSpan: number;
|
|
47
|
+
colSpan: number;
|
|
48
|
+
mergeKind: TableCellMergeKind | null;
|
|
49
|
+
}
|
|
50
|
+
export interface ResolvedTableRowPlacement {
|
|
51
|
+
row: readonly string[];
|
|
52
|
+
cellLayouts: readonly TableCellPlacement[];
|
|
53
|
+
fragmentRowIndex: number;
|
|
54
|
+
sourceRowIndex: number;
|
|
55
|
+
cells: readonly ResolvedTableCellPlacement[];
|
|
56
|
+
}
|
|
57
|
+
export interface RenderableTableCellPlacement extends ResolvedTableCellPlacement {
|
|
58
|
+
rowSpanInFragment: number;
|
|
59
|
+
/**
|
|
60
|
+
* Offset of this cell's text inside the row's flattened text.
|
|
61
|
+
*
|
|
62
|
+
* A cell owns a slice of the row string, not the whole of it. Resolving a hit
|
|
63
|
+
* against the cell therefore needs this base to convert an in-cell character
|
|
64
|
+
* offset back into a row-relative one.
|
|
65
|
+
*/
|
|
66
|
+
textStart: number;
|
|
67
|
+
}
|
|
68
|
+
export interface RenderableTableRowPlacement extends ResolvedTableRowPlacement {
|
|
69
|
+
cells: readonly RenderableTableCellPlacement[];
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Narrows an unknown merge marker to the merge shape it names.
|
|
73
|
+
*
|
|
74
|
+
* Exported because the projection layer re-reads the same marker off a placed
|
|
75
|
+
* cell and must agree with the layout about what counts as a merge. Two copies of
|
|
76
|
+
* this predicate would drift exactly as the cell padding constants once did.
|
|
77
|
+
*/
|
|
78
|
+
export declare function normalizeMergeKind(value: unknown): TableCellMergeKind | null;
|
|
79
|
+
export declare function resolveTableRowCells(input: {
|
|
80
|
+
row?: readonly string[] | null;
|
|
81
|
+
cellLayouts?: readonly TableCellPlacement[] | null;
|
|
82
|
+
fragmentRowIndex?: number;
|
|
83
|
+
sourceRowIndex?: number;
|
|
84
|
+
}): ResolvedTableCellPlacement[];
|
|
85
|
+
export declare function resolveTableFragmentRows(fragment: TableFragmentLike): ResolvedTableRowPlacement[];
|
|
86
|
+
/**
|
|
87
|
+
* How many leading rows of a table fragment carry the header look.
|
|
88
|
+
*
|
|
89
|
+
* A table's header is a property of the WHOLE table, but a fragment only holds
|
|
90
|
+
* the rows that fit on one page. Comparing a fragment-local row number against
|
|
91
|
+
* the table-wide header count marks row 0 of every fragment as a header - the
|
|
92
|
+
* second and third pages of a long table painted their first data row ("Row 8",
|
|
93
|
+
* "Row 16") bold on the tinted background, as though the header repeated, even
|
|
94
|
+
* with repetition switched off.
|
|
95
|
+
*
|
|
96
|
+
* So the test is made in whole-table coordinates: a row is a header when its
|
|
97
|
+
* SOURCE index is below the count. On the fragment that actually holds the
|
|
98
|
+
* header the two numberings agree and nothing changes; on later fragments no
|
|
99
|
+
* row qualifies and the rows paint as ordinary ones.
|
|
100
|
+
*/
|
|
101
|
+
export declare function resolveTableHeaderStyleRowCount(row: {
|
|
102
|
+
sourceRowIndex: number;
|
|
103
|
+
}, headerCount: number | null | undefined, rowCount: number): number;
|
|
104
|
+
export declare function resolveRenderableTableRows(fragment: TableFragmentLike): RenderableTableRowPlacement[];
|
|
105
|
+
export declare function resolveTableLogicalColumnCount(fragment: TableFragmentLike): number;
|
|
106
|
+
export declare function resolveTableCellColumnWidth(columnWidths: readonly number[], cell: Pick<ResolvedTableCellPlacement, 'originColumn' | 'colSpan'>): number;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{k as a,l as b,m as c,n as d,o as e,p as f,q as g,r as h,s as i}from"./chunk-T3O7N3HW.js";import"./chunk-VRAHV7NM.js";export{a as TABLE_CELL_HORIZONTAL_PADDING,b as TABLE_CELL_VERTICAL_PADDING,c as normalizeMergeKind,g as resolveRenderableTableRows,i as resolveTableCellColumnWidth,e as resolveTableFragmentRows,f as resolveTableHeaderStyleRowCount,h as resolveTableLogicalColumnCount,d as resolveTableRowCells};
|