document-content-model 7.11.5 → 7.13.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 CHANGED
@@ -330,6 +330,12 @@ Well-formedness is a per-entry range check — `0 <= startRun <= endRun <= runs.
330
330
 
331
331
  Two harmonisations the inventories asked for are also deliberately absent. There is **no `fieldType` enum**: `instruction` is required and verbatim, so nothing is lost without one, and #24 asks for exactly one new vocabulary — `link`'s internal targets — rather than one per kind, with the four inventories' own corpus gate still standing before a field-type member set could be frozen honestly. And a **sheet-scoped named range** (xlsx defined names and tables, ODF `table:named-expressions`) is a definitions-table entry, not an `anchor`: a sheet group's children are its images and embedded documents, never a block flow, so there is no extent for an anchor to wrap — which is the odf inventory's own verdict for the identical construct.
332
332
 
333
+ ## The table grid rule
334
+
335
+ A `ContentTable` row's `cells` array is dense: one entry per grid column, so a cell's index is its grid column. A merged region is an anchor entry carrying `colSpan`/`rowSpan` plus a block-less entry at every other position it covers, and `walkTableGrid` classifies every entry as an anchor or as covered. `ContentTableCell` states the rule in full; the schema cannot enforce it, since it is a property of a whole table and not of any one cell.
336
+
337
+ `findTableGridFault(table)` is the one shared definition of when a table contradicts it, in the same way `findConstructMarkerImbalance` is for bracket balance. It never throws: it returns a descriptor of the first fault in reading order, or `undefined` for a conforming table. The faults are rows of differing lengths (`raggedRow`), blocks on a covered position (`coveredContent`), a span stated by a covered position (`coveredSpan`, which is how a second anchor starting inside another region shows up), an anchor reaching past the last column or row (`anchorOverrunsColumns`, `anchorOverrunsRows`), and an anchor reaching a position an earlier region already covers (`overlappingAnchors`). `describeTableGridFault` states a descriptor in one sentence for a writer that refuses or reports it, and every table writer in the family runs the check rather than deciding for itself what a covered position's blocks mean.
338
+
333
339
  ## The residue channel
334
340
 
335
341
  [#22](https://github.com/ExaDev/document-schema.js/issues/22)'s second channel, landed by [#718](https://github.com/ExaDev/documents.js/issues/718) (`src/source.ts`): a quarantined **`source: { format, xml }`** value for what has no cross-format meaning — a WordprocessingML proofing mark, a custom XML payload, a markdown raw-HTML block's remainder, a PDF XMP packet. `format` is a closed enum naming the producing format (one member per reader the workspace has today), so a consumer can tell residue it may restore from residue it must leave alone without reading the text; `xml` is that format's own serialisation, validated as opaque text and nothing more.
package/dist/index.cjs CHANGED
@@ -20,6 +20,7 @@ const require_decompose = require("./decompose.cjs");
20
20
  const require_flatten = require("./flatten.cjs");
21
21
  const require_factor_styles = require("./factor-styles.cjs");
22
22
  require("./font-port.cjs");
23
+ const require_table_grid = require("./table-grid.cjs");
23
24
  require("./text-layout.cjs");
24
25
  require("./math-layout.cjs");
25
26
  exports.AlignmentSchema = require_style.AlignmentSchema;
@@ -205,12 +206,15 @@ exports.contentDocumentSharedFields = require_content.contentDocumentSharedField
205
206
  exports.contentDocumentWithSchema = require_schema_io.contentDocumentWithSchema;
206
207
  exports.dashedBorderWeightForWidthPt = require_border_weight.dashedBorderWeightForWidthPt;
207
208
  exports.decompose = require_decompose.decompose;
209
+ exports.denseTableRows = require_table_grid.denseTableRows;
210
+ exports.describeTableGridFault = require_table_grid.describeTableGridFault;
208
211
  exports.documentFromJson = require_schema_io.documentFromJson;
209
212
  exports.documentSchemaKindOf = require_schema_io.documentSchemaKindOf;
210
213
  exports.documentTreeWithSchema = require_schema_io.documentTreeWithSchema;
211
214
  exports.factorStyles = require_factor_styles.factorStyles;
212
215
  exports.findConstructMarkerImbalance = require_content.findConstructMarkerImbalance;
213
216
  exports.findRunConstructFault = require_content.findRunConstructFault;
217
+ exports.findTableGridFault = require_table_grid.findTableGridFault;
214
218
  exports.flattenTree = require_flatten.flattenTree;
215
219
  exports.isContentBlock = require_content.isContentBlock;
216
220
  exports.isContentConstructEnd = require_content.isContentConstructEnd;
@@ -234,9 +238,14 @@ exports.isTreeNode = require_package_node.isTreeNode;
234
238
  exports.overlayStyleEntries = require_definitions.overlayStyleEntries;
235
239
  exports.parseCellReference = require_a1.parseCellReference;
236
240
  exports.parseRangeReference = require_a1.parseRangeReference;
241
+ exports.placeAnchorTableRows = require_table_grid.placeAnchorTableRows;
237
242
  exports.rangeReference = require_a1.rangeReference;
238
243
  exports.resolveCellFillColor = require_content.resolveCellFillColor;
239
244
  exports.resolveStyleChain = require_definitions.resolveStyleChain;
240
245
  exports.rgbHexToColor = require_color.rgbHexToColor;
241
246
  exports.schemaUriFor = require_schema_io.schemaUriFor;
247
+ exports.tableCellColumnSpan = require_table_grid.tableCellColumnSpan;
248
+ exports.tableCellRowSpan = require_table_grid.tableCellRowSpan;
249
+ exports.tableGridColumnCount = require_table_grid.tableGridColumnCount;
242
250
  exports.unrecognizedFillKind = require_content.unrecognizedFillKind;
251
+ exports.walkTableGrid = require_table_grid.walkTableGrid;
package/dist/index.d.cts CHANGED
@@ -18,7 +18,8 @@ import { assembleTree, factorStyles } from "./factor-styles.cjs";
18
18
  import { flattenTree } from "./flatten.cjs";
19
19
  import { FontFace, FontRegistryOptions, FontSubstitution, ProvidedFont } from "./font-port.cjs";
20
20
  import { LayoutMetadata, LayoutMetadataSchema } from "./metadata.cjs";
21
+ import { AnchorTableRow, PositionedTableCell, PositionedTableRow, TableGridAnchor, TableGridCovered, TableGridFault, TableGridPosition, denseTableRows, describeTableGridFault, findTableGridFault, placeAnchorTableRows, tableCellColumnSpan, tableCellRowSpan, tableGridColumnCount, walkTableGrid } from "./table-grid.cjs";
21
22
  import { ContentDocumentJson, DocumentJsonResult, DocumentPackageRenamedError, DocumentSchemaKind, DocumentTreeJson, LayoutSchemaDemotedError, SCHEMA_FILE_NAMES, SchemaVersionMismatchError, UnrecognizedDocumentSchemaError, contentDocumentWithSchema, documentFromJson, documentSchemaKindOf, documentTreeWithSchema, schemaUriFor } from "./schema-io.cjs";
22
23
  import { StyledFragment, StyledRun, TextMeasurer, UnderlineMetrics, WrapOptions, WrappedLine } from "./text-layout.cjs";
23
24
  import { MathAssembledGlyphs, MathBox, MathColor, MathFontMetrics, MathGlyphMetrics, MathGlyphPlacement, MathGlyphRun, MathLayoutItem, MathRule, MathStretchAxis, MathStretchGlyph, MathStretchResult, MathStroke, PositionedFormula } from "./math-layout.cjs";
24
- export { Alignment, AlignmentSchema, AnchorDescriptor, AnchorDescriptorSchema, AnchorType, AnchorTypeSchema, BORDER_WIDTH_PT, BorderWeight, Box, BoxSchema, COLOR_BLACK, CONTENT_ANNOTATION_FIELDS, CONTENT_DEFS, CONTENT_DOCUMENT_URI, CellPosition, CellRange, Color, ColorSchema, ConstructDescriptor, ConstructDescriptorSchema, ConstructMarkerImbalance, ConstructMarkerImbalanceError, ContentBitmapFill, ContentBitmapFillSchema, ContentBlock, ContentBlockSchema, ContentBorder, ContentBorderSchema, ContentCellBorders, ContentCellBordersSchema, ContentCellFill, ContentCellFillSchema, ContentCellPatternType, ContentCellPatternTypeSchema, ContentCellValue, ContentCellValueSchema, ContentCodec, ContentConstructEnd, ContentConstructEndSchema, ContentConstructStart, ContentConstructStartSchema, ContentControlDescriptor, ContentControlDescriptorSchema, ContentControlLock, ContentControlLockSchema, ContentControlType, ContentControlTypeSchema, ContentDefinedName, ContentDefinedNameSchema, ContentDocument, ContentDocumentJson, ContentDocumentSchema, ContentDrawPage, ContentDrawPageSchema, ContentEmbeddedObject, ContentEmbeddedObjectBlock, ContentEmbeddedObjectBlockSchema, ContentEmbeddedObjectKind, ContentEmbeddedObjectSchema, ContentFillPattern, ContentFillPatternSchema, ContentFloatAlign, ContentFloatAlignSchema, ContentFloatAxis, ContentFloatAxisSchema, ContentFloatOrigin, ContentFloatOriginSchema, ContentFloatPosition, ContentFloatPositionSchema, ContentFont, ContentFontSchema, ContentFormula, ContentFormulaSchema, ContentGradientFill, ContentGradientFillSchema, ContentGradientStyle, ContentGradientStyleSchema, ContentHatchFill, ContentHatchFillSchema, ContentHatchStyle, ContentHatchStyleSchema, ContentImageBlock, ContentImageBlockSchema, ContentImageOriginal, ContentImageOriginalSchema, ContentInterpretation, ContentInterpretationSchema, ContentListMembership, ContentListMembershipSchema, ContentOrigin, ContentOriginSchema, ContentPageBreak, ContentPageBreakSchema, ContentPageFurniture, ContentPageFurnitureSchema, ContentParagraph, ContentParagraphBorders, ContentParagraphBordersSchema, ContentParagraphSchema, ContentPathPoint, ContentPathPointSchema, ContentPathSegment, ContentPathSegmentSchema, ContentRun, ContentRunSchema, ContentSection, ContentSectionSchema, ContentShape, ContentShapeSchema, ContentSheet, ContentSheetCell, ContentSheetCellComment, ContentSheetCellCommentSchema, ContentSheetCellSchema, ContentSheetColumn, ContentSheetColumnSchema, ContentSheetConditionalFormat, ContentSheetConditionalFormatSchema, ContentSheetConditionalFormatStyle, ContentSheetConditionalFormatStyleSchema, ContentSheetConditionalFormatValue, ContentSheetConditionalFormatValueSchema, ContentSheetDataValidation, ContentSheetDataValidationSchema, ContentSheetDataValidationType, ContentSheetDataValidationTypeSchema, ContentSheetImage, ContentSheetImageSchema, ContentSheetPrintRange, ContentSheetPrintRangeSchema, ContentSheetPrintSettings, ContentSheetPrintSettingsSchema, ContentSheetRange, ContentSheetRangeSchema, ContentSheetRepeatRange, ContentSheetRepeatRangeSchema, ContentSheetRow, ContentSheetRowSchema, ContentSheetSchema, ContentSlide, ContentSlideSchema, ContentStroke, ContentStrokeDash, ContentStrokeDashSchema, ContentStrokeSchema, ContentStrokeStyle, ContentStrokeStyleSchema, ContentSubpath, ContentSubpathSchema, ContentTable, ContentTableCell, ContentTableCellSchema, ContentTableRow, ContentTableRowSchema, ContentTableSchema, ContentTranscript, ContentTranscriptSchema, ContentVector, ContentVectorSchema, DEFAULT_LAYOUT_FONT, DecimalString, DecimalStringSchema, DefinitionEntry, DefinitionEntrySchema, DefinitionsTable, DefinitionsTableSchema, DimensionVector, DimensionVectorSchema, DivisionDescriptor, DivisionDescriptorSchema, DivisionSource, DivisionSourceSchema, DocumentJsonResult, DocumentPackageRenamedError, DocumentSchemaKind, DocumentTree, DocumentTreeJson, DocumentTreeSchema, DrawPageChild, DrawPageDescriptor, DrawPageDescriptorSchema, DrawPageGroupNode, DrawPageGroupSchema, EMBEDDED_OBJECT_KINDS, EvaluationValue, EvaluationValueSchema, ExactRational, ExactRationalSchema, FieldDescriptor, FieldDescriptorSchema, FontFace, FontRegistryOptions, FontSubstitution, FormulaBindings, FormulaBindingsSchema, FusedNode, HeadingGroupNode, HeadingGroupSchema, HeadingParagraph, HeadingParagraphSchema, IMAGE_FORMATS, ImageFormat, Interval, IntervalSchema, LayoutFont, LayoutFontSchema, LayoutFrame, LayoutFrameSchema, LayoutMetadata, LayoutMetadataSchema, LayoutSchemaDemotedError, LinkDescriptor, LinkDescriptorSchema, LinkTarget, LinkTargetSchema, ListChild, ListGroupNode, ListGroupSchema, ListParagraph, ListParagraphSchema, MAX_SAFE_INTEGER, Margins, MarginsSchema, MathApp, MathAppSchema, MathAssembledGlyphs, MathBox, MathColor, MathExpression, MathExpressionSchema, MathFontMetrics, MathGlyphMetrics, MathGlyphPlacement, MathGlyphRun, MathLayoutItem, MathMatrix, MathMatrixSchema, MathMlAttribute, MathMlAttributeSchema, MathMlCdata, MathMlCdataSchema, MathMlComment, MathMlCommentSchema, MathMlDeclaration, MathMlDeclarationSchema, MathMlElement, MathMlElementSchema, MathMlNode, MathMlNodeSchema, MathMlPi, MathMlPiSchema, MathMlText, MathMlTextSchema, MathNormalisationContext, MathNormalisationContextSchema, MathNum, MathNumSchema, MathPresentation, MathPresentationSchema, MathProd, MathProdSchema, MathProvenance, MathProvenanceSchema, MathQty, MathQtySchema, MathRule, MathStretchAxis, MathStretchGlyph, MathStretchResult, MathStroke, MathSum, MathSumSchema, MathSym, MathSymSchema, MathSymbolEntry, MathSymbolEntrySchema, MathUncertainty, MathUncertaintySchema, MathUnit, MathUnitSchema, MathUnparsed, MathUnparsedSchema, PAGE_SIZE_A4, PAGE_SIZE_LETTER, PageSize, PageSizeSchema, Point, PositionedFormula, ProvenanceChange, ProvenanceChangeSchema, ProvenanceDescriptor, ProvenanceDescriptorSchema, ProvidedFont, Quantity, QuantitySchema, RUN_FONT_PROPERTY_SHAPE, RunConstructExtent, RunConstructExtentSchema, RunConstructFault, SCHEMA_FILE_NAMES, SI_BASE_DIMENSIONS, SLIDE_SIZE_STANDARD, SLIDE_SIZE_WIDESCREEN, SchemaVersionMismatchError, SectionChild, SectionConstructGroupNode, SectionConstructGroupSchema, SectionDescriptor, SectionDescriptorSchema, SectionGroupNode, SectionGroupSchema, ShapeChild, ShapeConstructGroupNode, ShapeConstructGroupSchema, ShapeDescriptor, ShapeDescriptorSchema, ShapeGroupNode, ShapeGroupSchema, SheetChild, SheetDescriptor, SheetDescriptorSchema, SheetGroupNode, SheetGroupSchema, SheetRuleOperator, SheetRuleOperatorSchema, SiBaseDimension, SlideDescriptor, SlideDescriptorSchema, SlideGroupNode, SlideGroupSchema, SourceFormat, SourceFormatSchema, SourceResidue, SourceResidueSchema, StyleEntry, StyleEntrySchema, StyleParagraphProperties, StyleParagraphPropertiesSchema, StyleRunProperties, StyleRunPropertiesSchema, StyledFragment, StyledRun, StylesTable, StylesTableSchema, SymbolTable, SymbolTableSchema, TextDirection, TextDirectionSchema, TextMeasurer, TreeBlockLeaf, TreeBlockLeafSchema, type TreeChildren, TreeEmbeddedFont, TreeEmbeddedFontSchema, TreeGroup, TreeGroupSchema, TreeLeaf, TreeLeafSchema, TreeNode, TreeNodeSchema, UnderlineMetrics, UnrecognizedDocumentSchemaError, WrapOptions, WrappedLine, applyParagraphStyleProperties, applyRunStyleProperties, assembleTree, borderWeightForWidthPt, cellReference, clampHeadingLevel, colorToRgbHex, columnIndexToLetters, columnLettersToIndex, contentDocumentSharedFields, contentDocumentWithSchema, dashedBorderWeightForWidthPt, decompose, documentFromJson, documentSchemaKindOf, documentTreeWithSchema, factorStyles, findConstructMarkerImbalance, findRunConstructFault, flattenTree, isContentBlock, isContentConstructEnd, isContentConstructStart, isDrawPageGroupNode, isHeadingGroupNode, isListGroupNode, isMathExpression, isMathMlNode, isRunConstructExtent, isSectionConstructGroupNode, isSectionGroupNode, isShapeConstructGroupNode, isShapeGroupNode, isSheetGroupNode, isSlideGroupNode, isTreeBlockLeaf, isTreeGroup, isTreeLeaf, isTreeNode, overlayStyleEntries, parseCellReference, parseRangeReference, rangeReference, resolveCellFillColor, resolveStyleChain, rgbHexToColor, schemaUriFor, unrecognizedFillKind };
25
+ export { Alignment, AlignmentSchema, AnchorDescriptor, AnchorDescriptorSchema, AnchorTableRow, AnchorType, AnchorTypeSchema, BORDER_WIDTH_PT, BorderWeight, Box, BoxSchema, COLOR_BLACK, CONTENT_ANNOTATION_FIELDS, CONTENT_DEFS, CONTENT_DOCUMENT_URI, CellPosition, CellRange, Color, ColorSchema, ConstructDescriptor, ConstructDescriptorSchema, ConstructMarkerImbalance, ConstructMarkerImbalanceError, ContentBitmapFill, ContentBitmapFillSchema, ContentBlock, ContentBlockSchema, ContentBorder, ContentBorderSchema, ContentCellBorders, ContentCellBordersSchema, ContentCellFill, ContentCellFillSchema, ContentCellPatternType, ContentCellPatternTypeSchema, ContentCellValue, ContentCellValueSchema, ContentCodec, ContentConstructEnd, ContentConstructEndSchema, ContentConstructStart, ContentConstructStartSchema, ContentControlDescriptor, ContentControlDescriptorSchema, ContentControlLock, ContentControlLockSchema, ContentControlType, ContentControlTypeSchema, ContentDefinedName, ContentDefinedNameSchema, ContentDocument, ContentDocumentJson, ContentDocumentSchema, ContentDrawPage, ContentDrawPageSchema, ContentEmbeddedObject, ContentEmbeddedObjectBlock, ContentEmbeddedObjectBlockSchema, ContentEmbeddedObjectKind, ContentEmbeddedObjectSchema, ContentFillPattern, ContentFillPatternSchema, ContentFloatAlign, ContentFloatAlignSchema, ContentFloatAxis, ContentFloatAxisSchema, ContentFloatOrigin, ContentFloatOriginSchema, ContentFloatPosition, ContentFloatPositionSchema, ContentFont, ContentFontSchema, ContentFormula, ContentFormulaSchema, ContentGradientFill, ContentGradientFillSchema, ContentGradientStyle, ContentGradientStyleSchema, ContentHatchFill, ContentHatchFillSchema, ContentHatchStyle, ContentHatchStyleSchema, ContentImageBlock, ContentImageBlockSchema, ContentImageOriginal, ContentImageOriginalSchema, ContentInterpretation, ContentInterpretationSchema, ContentListMembership, ContentListMembershipSchema, ContentOrigin, ContentOriginSchema, ContentPageBreak, ContentPageBreakSchema, ContentPageFurniture, ContentPageFurnitureSchema, ContentParagraph, ContentParagraphBorders, ContentParagraphBordersSchema, ContentParagraphSchema, ContentPathPoint, ContentPathPointSchema, ContentPathSegment, ContentPathSegmentSchema, ContentRun, ContentRunSchema, ContentSection, ContentSectionSchema, ContentShape, ContentShapeSchema, ContentSheet, ContentSheetCell, ContentSheetCellComment, ContentSheetCellCommentSchema, ContentSheetCellSchema, ContentSheetColumn, ContentSheetColumnSchema, ContentSheetConditionalFormat, ContentSheetConditionalFormatSchema, ContentSheetConditionalFormatStyle, ContentSheetConditionalFormatStyleSchema, ContentSheetConditionalFormatValue, ContentSheetConditionalFormatValueSchema, ContentSheetDataValidation, ContentSheetDataValidationSchema, ContentSheetDataValidationType, ContentSheetDataValidationTypeSchema, ContentSheetImage, ContentSheetImageSchema, ContentSheetPrintRange, ContentSheetPrintRangeSchema, ContentSheetPrintSettings, ContentSheetPrintSettingsSchema, ContentSheetRange, ContentSheetRangeSchema, ContentSheetRepeatRange, ContentSheetRepeatRangeSchema, ContentSheetRow, ContentSheetRowSchema, ContentSheetSchema, ContentSlide, ContentSlideSchema, ContentStroke, ContentStrokeDash, ContentStrokeDashSchema, ContentStrokeSchema, ContentStrokeStyle, ContentStrokeStyleSchema, ContentSubpath, ContentSubpathSchema, ContentTable, ContentTableCell, ContentTableCellSchema, ContentTableRow, ContentTableRowSchema, ContentTableSchema, ContentTranscript, ContentTranscriptSchema, ContentVector, ContentVectorSchema, DEFAULT_LAYOUT_FONT, DecimalString, DecimalStringSchema, DefinitionEntry, DefinitionEntrySchema, DefinitionsTable, DefinitionsTableSchema, DimensionVector, DimensionVectorSchema, DivisionDescriptor, DivisionDescriptorSchema, DivisionSource, DivisionSourceSchema, DocumentJsonResult, DocumentPackageRenamedError, DocumentSchemaKind, DocumentTree, DocumentTreeJson, DocumentTreeSchema, DrawPageChild, DrawPageDescriptor, DrawPageDescriptorSchema, DrawPageGroupNode, DrawPageGroupSchema, EMBEDDED_OBJECT_KINDS, EvaluationValue, EvaluationValueSchema, ExactRational, ExactRationalSchema, FieldDescriptor, FieldDescriptorSchema, FontFace, FontRegistryOptions, FontSubstitution, FormulaBindings, FormulaBindingsSchema, FusedNode, HeadingGroupNode, HeadingGroupSchema, HeadingParagraph, HeadingParagraphSchema, IMAGE_FORMATS, ImageFormat, Interval, IntervalSchema, LayoutFont, LayoutFontSchema, LayoutFrame, LayoutFrameSchema, LayoutMetadata, LayoutMetadataSchema, LayoutSchemaDemotedError, LinkDescriptor, LinkDescriptorSchema, LinkTarget, LinkTargetSchema, ListChild, ListGroupNode, ListGroupSchema, ListParagraph, ListParagraphSchema, MAX_SAFE_INTEGER, Margins, MarginsSchema, MathApp, MathAppSchema, MathAssembledGlyphs, MathBox, MathColor, MathExpression, MathExpressionSchema, MathFontMetrics, MathGlyphMetrics, MathGlyphPlacement, MathGlyphRun, MathLayoutItem, MathMatrix, MathMatrixSchema, MathMlAttribute, MathMlAttributeSchema, MathMlCdata, MathMlCdataSchema, MathMlComment, MathMlCommentSchema, MathMlDeclaration, MathMlDeclarationSchema, MathMlElement, MathMlElementSchema, MathMlNode, MathMlNodeSchema, MathMlPi, MathMlPiSchema, MathMlText, MathMlTextSchema, MathNormalisationContext, MathNormalisationContextSchema, MathNum, MathNumSchema, MathPresentation, MathPresentationSchema, MathProd, MathProdSchema, MathProvenance, MathProvenanceSchema, MathQty, MathQtySchema, MathRule, MathStretchAxis, MathStretchGlyph, MathStretchResult, MathStroke, MathSum, MathSumSchema, MathSym, MathSymSchema, MathSymbolEntry, MathSymbolEntrySchema, MathUncertainty, MathUncertaintySchema, MathUnit, MathUnitSchema, MathUnparsed, MathUnparsedSchema, PAGE_SIZE_A4, PAGE_SIZE_LETTER, PageSize, PageSizeSchema, Point, PositionedFormula, PositionedTableCell, PositionedTableRow, ProvenanceChange, ProvenanceChangeSchema, ProvenanceDescriptor, ProvenanceDescriptorSchema, ProvidedFont, Quantity, QuantitySchema, RUN_FONT_PROPERTY_SHAPE, RunConstructExtent, RunConstructExtentSchema, RunConstructFault, SCHEMA_FILE_NAMES, SI_BASE_DIMENSIONS, SLIDE_SIZE_STANDARD, SLIDE_SIZE_WIDESCREEN, SchemaVersionMismatchError, SectionChild, SectionConstructGroupNode, SectionConstructGroupSchema, SectionDescriptor, SectionDescriptorSchema, SectionGroupNode, SectionGroupSchema, ShapeChild, ShapeConstructGroupNode, ShapeConstructGroupSchema, ShapeDescriptor, ShapeDescriptorSchema, ShapeGroupNode, ShapeGroupSchema, SheetChild, SheetDescriptor, SheetDescriptorSchema, SheetGroupNode, SheetGroupSchema, SheetRuleOperator, SheetRuleOperatorSchema, SiBaseDimension, SlideDescriptor, SlideDescriptorSchema, SlideGroupNode, SlideGroupSchema, SourceFormat, SourceFormatSchema, SourceResidue, SourceResidueSchema, StyleEntry, StyleEntrySchema, StyleParagraphProperties, StyleParagraphPropertiesSchema, StyleRunProperties, StyleRunPropertiesSchema, StyledFragment, StyledRun, StylesTable, StylesTableSchema, SymbolTable, SymbolTableSchema, TableGridAnchor, TableGridCovered, TableGridFault, TableGridPosition, TextDirection, TextDirectionSchema, TextMeasurer, TreeBlockLeaf, TreeBlockLeafSchema, type TreeChildren, TreeEmbeddedFont, TreeEmbeddedFontSchema, TreeGroup, TreeGroupSchema, TreeLeaf, TreeLeafSchema, TreeNode, TreeNodeSchema, UnderlineMetrics, UnrecognizedDocumentSchemaError, WrapOptions, WrappedLine, applyParagraphStyleProperties, applyRunStyleProperties, assembleTree, borderWeightForWidthPt, cellReference, clampHeadingLevel, colorToRgbHex, columnIndexToLetters, columnLettersToIndex, contentDocumentSharedFields, contentDocumentWithSchema, dashedBorderWeightForWidthPt, decompose, denseTableRows, describeTableGridFault, documentFromJson, documentSchemaKindOf, documentTreeWithSchema, factorStyles, findConstructMarkerImbalance, findRunConstructFault, findTableGridFault, flattenTree, isContentBlock, isContentConstructEnd, isContentConstructStart, isDrawPageGroupNode, isHeadingGroupNode, isListGroupNode, isMathExpression, isMathMlNode, isRunConstructExtent, isSectionConstructGroupNode, isSectionGroupNode, isShapeConstructGroupNode, isShapeGroupNode, isSheetGroupNode, isSlideGroupNode, isTreeBlockLeaf, isTreeGroup, isTreeLeaf, isTreeNode, overlayStyleEntries, parseCellReference, parseRangeReference, placeAnchorTableRows, rangeReference, resolveCellFillColor, resolveStyleChain, rgbHexToColor, schemaUriFor, tableCellColumnSpan, tableCellRowSpan, tableGridColumnCount, unrecognizedFillKind, walkTableGrid };
package/dist/index.d.ts CHANGED
@@ -18,7 +18,8 @@ import { assembleTree, factorStyles } from "./factor-styles.js";
18
18
  import { flattenTree } from "./flatten.js";
19
19
  import { FontFace, FontRegistryOptions, FontSubstitution, ProvidedFont } from "./font-port.js";
20
20
  import { LayoutMetadata, LayoutMetadataSchema } from "./metadata.js";
21
+ import { AnchorTableRow, PositionedTableCell, PositionedTableRow, TableGridAnchor, TableGridCovered, TableGridFault, TableGridPosition, denseTableRows, describeTableGridFault, findTableGridFault, placeAnchorTableRows, tableCellColumnSpan, tableCellRowSpan, tableGridColumnCount, walkTableGrid } from "./table-grid.js";
21
22
  import { ContentDocumentJson, DocumentJsonResult, DocumentPackageRenamedError, DocumentSchemaKind, DocumentTreeJson, LayoutSchemaDemotedError, SCHEMA_FILE_NAMES, SchemaVersionMismatchError, UnrecognizedDocumentSchemaError, contentDocumentWithSchema, documentFromJson, documentSchemaKindOf, documentTreeWithSchema, schemaUriFor } from "./schema-io.js";
22
23
  import { StyledFragment, StyledRun, TextMeasurer, UnderlineMetrics, WrapOptions, WrappedLine } from "./text-layout.js";
23
24
  import { MathAssembledGlyphs, MathBox, MathColor, MathFontMetrics, MathGlyphMetrics, MathGlyphPlacement, MathGlyphRun, MathLayoutItem, MathRule, MathStretchAxis, MathStretchGlyph, MathStretchResult, MathStroke, PositionedFormula } from "./math-layout.js";
24
- export { Alignment, AlignmentSchema, AnchorDescriptor, AnchorDescriptorSchema, AnchorType, AnchorTypeSchema, BORDER_WIDTH_PT, BorderWeight, Box, BoxSchema, COLOR_BLACK, CONTENT_ANNOTATION_FIELDS, CONTENT_DEFS, CONTENT_DOCUMENT_URI, CellPosition, CellRange, Color, ColorSchema, ConstructDescriptor, ConstructDescriptorSchema, ConstructMarkerImbalance, ConstructMarkerImbalanceError, ContentBitmapFill, ContentBitmapFillSchema, ContentBlock, ContentBlockSchema, ContentBorder, ContentBorderSchema, ContentCellBorders, ContentCellBordersSchema, ContentCellFill, ContentCellFillSchema, ContentCellPatternType, ContentCellPatternTypeSchema, ContentCellValue, ContentCellValueSchema, ContentCodec, ContentConstructEnd, ContentConstructEndSchema, ContentConstructStart, ContentConstructStartSchema, ContentControlDescriptor, ContentControlDescriptorSchema, ContentControlLock, ContentControlLockSchema, ContentControlType, ContentControlTypeSchema, ContentDefinedName, ContentDefinedNameSchema, ContentDocument, ContentDocumentJson, ContentDocumentSchema, ContentDrawPage, ContentDrawPageSchema, ContentEmbeddedObject, ContentEmbeddedObjectBlock, ContentEmbeddedObjectBlockSchema, ContentEmbeddedObjectKind, ContentEmbeddedObjectSchema, ContentFillPattern, ContentFillPatternSchema, ContentFloatAlign, ContentFloatAlignSchema, ContentFloatAxis, ContentFloatAxisSchema, ContentFloatOrigin, ContentFloatOriginSchema, ContentFloatPosition, ContentFloatPositionSchema, ContentFont, ContentFontSchema, ContentFormula, ContentFormulaSchema, ContentGradientFill, ContentGradientFillSchema, ContentGradientStyle, ContentGradientStyleSchema, ContentHatchFill, ContentHatchFillSchema, ContentHatchStyle, ContentHatchStyleSchema, ContentImageBlock, ContentImageBlockSchema, ContentImageOriginal, ContentImageOriginalSchema, ContentInterpretation, ContentInterpretationSchema, ContentListMembership, ContentListMembershipSchema, ContentOrigin, ContentOriginSchema, ContentPageBreak, ContentPageBreakSchema, ContentPageFurniture, ContentPageFurnitureSchema, ContentParagraph, ContentParagraphBorders, ContentParagraphBordersSchema, ContentParagraphSchema, ContentPathPoint, ContentPathPointSchema, ContentPathSegment, ContentPathSegmentSchema, ContentRun, ContentRunSchema, ContentSection, ContentSectionSchema, ContentShape, ContentShapeSchema, ContentSheet, ContentSheetCell, ContentSheetCellComment, ContentSheetCellCommentSchema, ContentSheetCellSchema, ContentSheetColumn, ContentSheetColumnSchema, ContentSheetConditionalFormat, ContentSheetConditionalFormatSchema, ContentSheetConditionalFormatStyle, ContentSheetConditionalFormatStyleSchema, ContentSheetConditionalFormatValue, ContentSheetConditionalFormatValueSchema, ContentSheetDataValidation, ContentSheetDataValidationSchema, ContentSheetDataValidationType, ContentSheetDataValidationTypeSchema, ContentSheetImage, ContentSheetImageSchema, ContentSheetPrintRange, ContentSheetPrintRangeSchema, ContentSheetPrintSettings, ContentSheetPrintSettingsSchema, ContentSheetRange, ContentSheetRangeSchema, ContentSheetRepeatRange, ContentSheetRepeatRangeSchema, ContentSheetRow, ContentSheetRowSchema, ContentSheetSchema, ContentSlide, ContentSlideSchema, ContentStroke, ContentStrokeDash, ContentStrokeDashSchema, ContentStrokeSchema, ContentStrokeStyle, ContentStrokeStyleSchema, ContentSubpath, ContentSubpathSchema, ContentTable, ContentTableCell, ContentTableCellSchema, ContentTableRow, ContentTableRowSchema, ContentTableSchema, ContentTranscript, ContentTranscriptSchema, ContentVector, ContentVectorSchema, DEFAULT_LAYOUT_FONT, DecimalString, DecimalStringSchema, DefinitionEntry, DefinitionEntrySchema, DefinitionsTable, DefinitionsTableSchema, DimensionVector, DimensionVectorSchema, DivisionDescriptor, DivisionDescriptorSchema, DivisionSource, DivisionSourceSchema, DocumentJsonResult, DocumentPackageRenamedError, DocumentSchemaKind, DocumentTree, DocumentTreeJson, DocumentTreeSchema, DrawPageChild, DrawPageDescriptor, DrawPageDescriptorSchema, DrawPageGroupNode, DrawPageGroupSchema, EMBEDDED_OBJECT_KINDS, EvaluationValue, EvaluationValueSchema, ExactRational, ExactRationalSchema, FieldDescriptor, FieldDescriptorSchema, FontFace, FontRegistryOptions, FontSubstitution, FormulaBindings, FormulaBindingsSchema, FusedNode, HeadingGroupNode, HeadingGroupSchema, HeadingParagraph, HeadingParagraphSchema, IMAGE_FORMATS, ImageFormat, Interval, IntervalSchema, LayoutFont, LayoutFontSchema, LayoutFrame, LayoutFrameSchema, LayoutMetadata, LayoutMetadataSchema, LayoutSchemaDemotedError, LinkDescriptor, LinkDescriptorSchema, LinkTarget, LinkTargetSchema, ListChild, ListGroupNode, ListGroupSchema, ListParagraph, ListParagraphSchema, MAX_SAFE_INTEGER, Margins, MarginsSchema, MathApp, MathAppSchema, MathAssembledGlyphs, MathBox, MathColor, MathExpression, MathExpressionSchema, MathFontMetrics, MathGlyphMetrics, MathGlyphPlacement, MathGlyphRun, MathLayoutItem, MathMatrix, MathMatrixSchema, MathMlAttribute, MathMlAttributeSchema, MathMlCdata, MathMlCdataSchema, MathMlComment, MathMlCommentSchema, MathMlDeclaration, MathMlDeclarationSchema, MathMlElement, MathMlElementSchema, MathMlNode, MathMlNodeSchema, MathMlPi, MathMlPiSchema, MathMlText, MathMlTextSchema, MathNormalisationContext, MathNormalisationContextSchema, MathNum, MathNumSchema, MathPresentation, MathPresentationSchema, MathProd, MathProdSchema, MathProvenance, MathProvenanceSchema, MathQty, MathQtySchema, MathRule, MathStretchAxis, MathStretchGlyph, MathStretchResult, MathStroke, MathSum, MathSumSchema, MathSym, MathSymSchema, MathSymbolEntry, MathSymbolEntrySchema, MathUncertainty, MathUncertaintySchema, MathUnit, MathUnitSchema, MathUnparsed, MathUnparsedSchema, PAGE_SIZE_A4, PAGE_SIZE_LETTER, PageSize, PageSizeSchema, Point, PositionedFormula, ProvenanceChange, ProvenanceChangeSchema, ProvenanceDescriptor, ProvenanceDescriptorSchema, ProvidedFont, Quantity, QuantitySchema, RUN_FONT_PROPERTY_SHAPE, RunConstructExtent, RunConstructExtentSchema, RunConstructFault, SCHEMA_FILE_NAMES, SI_BASE_DIMENSIONS, SLIDE_SIZE_STANDARD, SLIDE_SIZE_WIDESCREEN, SchemaVersionMismatchError, SectionChild, SectionConstructGroupNode, SectionConstructGroupSchema, SectionDescriptor, SectionDescriptorSchema, SectionGroupNode, SectionGroupSchema, ShapeChild, ShapeConstructGroupNode, ShapeConstructGroupSchema, ShapeDescriptor, ShapeDescriptorSchema, ShapeGroupNode, ShapeGroupSchema, SheetChild, SheetDescriptor, SheetDescriptorSchema, SheetGroupNode, SheetGroupSchema, SheetRuleOperator, SheetRuleOperatorSchema, SiBaseDimension, SlideDescriptor, SlideDescriptorSchema, SlideGroupNode, SlideGroupSchema, SourceFormat, SourceFormatSchema, SourceResidue, SourceResidueSchema, StyleEntry, StyleEntrySchema, StyleParagraphProperties, StyleParagraphPropertiesSchema, StyleRunProperties, StyleRunPropertiesSchema, StyledFragment, StyledRun, StylesTable, StylesTableSchema, SymbolTable, SymbolTableSchema, TextDirection, TextDirectionSchema, TextMeasurer, TreeBlockLeaf, TreeBlockLeafSchema, type TreeChildren, TreeEmbeddedFont, TreeEmbeddedFontSchema, TreeGroup, TreeGroupSchema, TreeLeaf, TreeLeafSchema, TreeNode, TreeNodeSchema, UnderlineMetrics, UnrecognizedDocumentSchemaError, WrapOptions, WrappedLine, applyParagraphStyleProperties, applyRunStyleProperties, assembleTree, borderWeightForWidthPt, cellReference, clampHeadingLevel, colorToRgbHex, columnIndexToLetters, columnLettersToIndex, contentDocumentSharedFields, contentDocumentWithSchema, dashedBorderWeightForWidthPt, decompose, documentFromJson, documentSchemaKindOf, documentTreeWithSchema, factorStyles, findConstructMarkerImbalance, findRunConstructFault, flattenTree, isContentBlock, isContentConstructEnd, isContentConstructStart, isDrawPageGroupNode, isHeadingGroupNode, isListGroupNode, isMathExpression, isMathMlNode, isRunConstructExtent, isSectionConstructGroupNode, isSectionGroupNode, isShapeConstructGroupNode, isShapeGroupNode, isSheetGroupNode, isSlideGroupNode, isTreeBlockLeaf, isTreeGroup, isTreeLeaf, isTreeNode, overlayStyleEntries, parseCellReference, parseRangeReference, rangeReference, resolveCellFillColor, resolveStyleChain, rgbHexToColor, schemaUriFor, unrecognizedFillKind };
25
+ export { Alignment, AlignmentSchema, AnchorDescriptor, AnchorDescriptorSchema, AnchorTableRow, AnchorType, AnchorTypeSchema, BORDER_WIDTH_PT, BorderWeight, Box, BoxSchema, COLOR_BLACK, CONTENT_ANNOTATION_FIELDS, CONTENT_DEFS, CONTENT_DOCUMENT_URI, CellPosition, CellRange, Color, ColorSchema, ConstructDescriptor, ConstructDescriptorSchema, ConstructMarkerImbalance, ConstructMarkerImbalanceError, ContentBitmapFill, ContentBitmapFillSchema, ContentBlock, ContentBlockSchema, ContentBorder, ContentBorderSchema, ContentCellBorders, ContentCellBordersSchema, ContentCellFill, ContentCellFillSchema, ContentCellPatternType, ContentCellPatternTypeSchema, ContentCellValue, ContentCellValueSchema, ContentCodec, ContentConstructEnd, ContentConstructEndSchema, ContentConstructStart, ContentConstructStartSchema, ContentControlDescriptor, ContentControlDescriptorSchema, ContentControlLock, ContentControlLockSchema, ContentControlType, ContentControlTypeSchema, ContentDefinedName, ContentDefinedNameSchema, ContentDocument, ContentDocumentJson, ContentDocumentSchema, ContentDrawPage, ContentDrawPageSchema, ContentEmbeddedObject, ContentEmbeddedObjectBlock, ContentEmbeddedObjectBlockSchema, ContentEmbeddedObjectKind, ContentEmbeddedObjectSchema, ContentFillPattern, ContentFillPatternSchema, ContentFloatAlign, ContentFloatAlignSchema, ContentFloatAxis, ContentFloatAxisSchema, ContentFloatOrigin, ContentFloatOriginSchema, ContentFloatPosition, ContentFloatPositionSchema, ContentFont, ContentFontSchema, ContentFormula, ContentFormulaSchema, ContentGradientFill, ContentGradientFillSchema, ContentGradientStyle, ContentGradientStyleSchema, ContentHatchFill, ContentHatchFillSchema, ContentHatchStyle, ContentHatchStyleSchema, ContentImageBlock, ContentImageBlockSchema, ContentImageOriginal, ContentImageOriginalSchema, ContentInterpretation, ContentInterpretationSchema, ContentListMembership, ContentListMembershipSchema, ContentOrigin, ContentOriginSchema, ContentPageBreak, ContentPageBreakSchema, ContentPageFurniture, ContentPageFurnitureSchema, ContentParagraph, ContentParagraphBorders, ContentParagraphBordersSchema, ContentParagraphSchema, ContentPathPoint, ContentPathPointSchema, ContentPathSegment, ContentPathSegmentSchema, ContentRun, ContentRunSchema, ContentSection, ContentSectionSchema, ContentShape, ContentShapeSchema, ContentSheet, ContentSheetCell, ContentSheetCellComment, ContentSheetCellCommentSchema, ContentSheetCellSchema, ContentSheetColumn, ContentSheetColumnSchema, ContentSheetConditionalFormat, ContentSheetConditionalFormatSchema, ContentSheetConditionalFormatStyle, ContentSheetConditionalFormatStyleSchema, ContentSheetConditionalFormatValue, ContentSheetConditionalFormatValueSchema, ContentSheetDataValidation, ContentSheetDataValidationSchema, ContentSheetDataValidationType, ContentSheetDataValidationTypeSchema, ContentSheetImage, ContentSheetImageSchema, ContentSheetPrintRange, ContentSheetPrintRangeSchema, ContentSheetPrintSettings, ContentSheetPrintSettingsSchema, ContentSheetRange, ContentSheetRangeSchema, ContentSheetRepeatRange, ContentSheetRepeatRangeSchema, ContentSheetRow, ContentSheetRowSchema, ContentSheetSchema, ContentSlide, ContentSlideSchema, ContentStroke, ContentStrokeDash, ContentStrokeDashSchema, ContentStrokeSchema, ContentStrokeStyle, ContentStrokeStyleSchema, ContentSubpath, ContentSubpathSchema, ContentTable, ContentTableCell, ContentTableCellSchema, ContentTableRow, ContentTableRowSchema, ContentTableSchema, ContentTranscript, ContentTranscriptSchema, ContentVector, ContentVectorSchema, DEFAULT_LAYOUT_FONT, DecimalString, DecimalStringSchema, DefinitionEntry, DefinitionEntrySchema, DefinitionsTable, DefinitionsTableSchema, DimensionVector, DimensionVectorSchema, DivisionDescriptor, DivisionDescriptorSchema, DivisionSource, DivisionSourceSchema, DocumentJsonResult, DocumentPackageRenamedError, DocumentSchemaKind, DocumentTree, DocumentTreeJson, DocumentTreeSchema, DrawPageChild, DrawPageDescriptor, DrawPageDescriptorSchema, DrawPageGroupNode, DrawPageGroupSchema, EMBEDDED_OBJECT_KINDS, EvaluationValue, EvaluationValueSchema, ExactRational, ExactRationalSchema, FieldDescriptor, FieldDescriptorSchema, FontFace, FontRegistryOptions, FontSubstitution, FormulaBindings, FormulaBindingsSchema, FusedNode, HeadingGroupNode, HeadingGroupSchema, HeadingParagraph, HeadingParagraphSchema, IMAGE_FORMATS, ImageFormat, Interval, IntervalSchema, LayoutFont, LayoutFontSchema, LayoutFrame, LayoutFrameSchema, LayoutMetadata, LayoutMetadataSchema, LayoutSchemaDemotedError, LinkDescriptor, LinkDescriptorSchema, LinkTarget, LinkTargetSchema, ListChild, ListGroupNode, ListGroupSchema, ListParagraph, ListParagraphSchema, MAX_SAFE_INTEGER, Margins, MarginsSchema, MathApp, MathAppSchema, MathAssembledGlyphs, MathBox, MathColor, MathExpression, MathExpressionSchema, MathFontMetrics, MathGlyphMetrics, MathGlyphPlacement, MathGlyphRun, MathLayoutItem, MathMatrix, MathMatrixSchema, MathMlAttribute, MathMlAttributeSchema, MathMlCdata, MathMlCdataSchema, MathMlComment, MathMlCommentSchema, MathMlDeclaration, MathMlDeclarationSchema, MathMlElement, MathMlElementSchema, MathMlNode, MathMlNodeSchema, MathMlPi, MathMlPiSchema, MathMlText, MathMlTextSchema, MathNormalisationContext, MathNormalisationContextSchema, MathNum, MathNumSchema, MathPresentation, MathPresentationSchema, MathProd, MathProdSchema, MathProvenance, MathProvenanceSchema, MathQty, MathQtySchema, MathRule, MathStretchAxis, MathStretchGlyph, MathStretchResult, MathStroke, MathSum, MathSumSchema, MathSym, MathSymSchema, MathSymbolEntry, MathSymbolEntrySchema, MathUncertainty, MathUncertaintySchema, MathUnit, MathUnitSchema, MathUnparsed, MathUnparsedSchema, PAGE_SIZE_A4, PAGE_SIZE_LETTER, PageSize, PageSizeSchema, Point, PositionedFormula, PositionedTableCell, PositionedTableRow, ProvenanceChange, ProvenanceChangeSchema, ProvenanceDescriptor, ProvenanceDescriptorSchema, ProvidedFont, Quantity, QuantitySchema, RUN_FONT_PROPERTY_SHAPE, RunConstructExtent, RunConstructExtentSchema, RunConstructFault, SCHEMA_FILE_NAMES, SI_BASE_DIMENSIONS, SLIDE_SIZE_STANDARD, SLIDE_SIZE_WIDESCREEN, SchemaVersionMismatchError, SectionChild, SectionConstructGroupNode, SectionConstructGroupSchema, SectionDescriptor, SectionDescriptorSchema, SectionGroupNode, SectionGroupSchema, ShapeChild, ShapeConstructGroupNode, ShapeConstructGroupSchema, ShapeDescriptor, ShapeDescriptorSchema, ShapeGroupNode, ShapeGroupSchema, SheetChild, SheetDescriptor, SheetDescriptorSchema, SheetGroupNode, SheetGroupSchema, SheetRuleOperator, SheetRuleOperatorSchema, SiBaseDimension, SlideDescriptor, SlideDescriptorSchema, SlideGroupNode, SlideGroupSchema, SourceFormat, SourceFormatSchema, SourceResidue, SourceResidueSchema, StyleEntry, StyleEntrySchema, StyleParagraphProperties, StyleParagraphPropertiesSchema, StyleRunProperties, StyleRunPropertiesSchema, StyledFragment, StyledRun, StylesTable, StylesTableSchema, SymbolTable, SymbolTableSchema, TableGridAnchor, TableGridCovered, TableGridFault, TableGridPosition, TextDirection, TextDirectionSchema, TextMeasurer, TreeBlockLeaf, TreeBlockLeafSchema, type TreeChildren, TreeEmbeddedFont, TreeEmbeddedFontSchema, TreeGroup, TreeGroupSchema, TreeLeaf, TreeLeafSchema, TreeNode, TreeNodeSchema, UnderlineMetrics, UnrecognizedDocumentSchemaError, WrapOptions, WrappedLine, applyParagraphStyleProperties, applyRunStyleProperties, assembleTree, borderWeightForWidthPt, cellReference, clampHeadingLevel, colorToRgbHex, columnIndexToLetters, columnLettersToIndex, contentDocumentSharedFields, contentDocumentWithSchema, dashedBorderWeightForWidthPt, decompose, denseTableRows, describeTableGridFault, documentFromJson, documentSchemaKindOf, documentTreeWithSchema, factorStyles, findConstructMarkerImbalance, findRunConstructFault, findTableGridFault, flattenTree, isContentBlock, isContentConstructEnd, isContentConstructStart, isDrawPageGroupNode, isHeadingGroupNode, isListGroupNode, isMathExpression, isMathMlNode, isRunConstructExtent, isSectionConstructGroupNode, isSectionGroupNode, isShapeConstructGroupNode, isShapeGroupNode, isSheetGroupNode, isSlideGroupNode, isTreeBlockLeaf, isTreeGroup, isTreeLeaf, isTreeNode, overlayStyleEntries, parseCellReference, parseRangeReference, placeAnchorTableRows, rangeReference, resolveCellFillColor, resolveStyleChain, rgbHexToColor, schemaUriFor, tableCellColumnSpan, tableCellRowSpan, tableGridColumnCount, unrecognizedFillKind, walkTableGrid };
package/dist/index.js CHANGED
@@ -19,6 +19,7 @@ import { ConstructMarkerImbalanceError, decompose } from "./decompose.js";
19
19
  import { flattenTree } from "./flatten.js";
20
20
  import { assembleTree, factorStyles } from "./factor-styles.js";
21
21
  import "./font-port.js";
22
+ import { denseTableRows, describeTableGridFault, findTableGridFault, placeAnchorTableRows, tableCellColumnSpan, tableCellRowSpan, tableGridColumnCount, walkTableGrid } from "./table-grid.js";
22
23
  import "./text-layout.js";
23
24
  import "./math-layout.js";
24
- export { AlignmentSchema, AnchorDescriptorSchema, AnchorTypeSchema, BORDER_WIDTH_PT, BoxSchema, COLOR_BLACK, CONTENT_ANNOTATION_FIELDS, CONTENT_DEFS, CONTENT_DOCUMENT_URI, ColorSchema, ConstructDescriptorSchema, ConstructMarkerImbalanceError, ContentBitmapFillSchema, ContentBlockSchema, ContentBorderSchema, ContentCellBordersSchema, ContentCellFillSchema, ContentCellPatternTypeSchema, ContentCellValueSchema, ContentConstructEndSchema, ContentConstructStartSchema, ContentControlDescriptorSchema, ContentControlLockSchema, ContentControlTypeSchema, ContentDefinedNameSchema, ContentDocumentSchema, ContentDrawPageSchema, ContentEmbeddedObjectBlockSchema, ContentEmbeddedObjectSchema, ContentFillPatternSchema, ContentFloatAlignSchema, ContentFloatAxisSchema, ContentFloatOriginSchema, ContentFloatPositionSchema, ContentFontSchema, ContentFormulaSchema, ContentGradientFillSchema, ContentGradientStyleSchema, ContentHatchFillSchema, ContentHatchStyleSchema, ContentImageBlockSchema, ContentImageOriginalSchema, ContentInterpretationSchema, ContentListMembershipSchema, ContentOriginSchema, ContentPageBreakSchema, ContentPageFurnitureSchema, ContentParagraphBordersSchema, ContentParagraphSchema, ContentPathPointSchema, ContentPathSegmentSchema, ContentRunSchema, ContentSectionSchema, ContentShapeSchema, ContentSheetCellCommentSchema, ContentSheetCellSchema, ContentSheetColumnSchema, ContentSheetConditionalFormatSchema, ContentSheetConditionalFormatStyleSchema, ContentSheetConditionalFormatValueSchema, ContentSheetDataValidationSchema, ContentSheetDataValidationTypeSchema, ContentSheetImageSchema, ContentSheetPrintRangeSchema, ContentSheetPrintSettingsSchema, ContentSheetRangeSchema, ContentSheetRepeatRangeSchema, ContentSheetRowSchema, ContentSheetSchema, ContentSlideSchema, ContentStrokeDashSchema, ContentStrokeSchema, ContentStrokeStyleSchema, ContentSubpathSchema, ContentTableCellSchema, ContentTableRowSchema, ContentTableSchema, ContentTranscriptSchema, ContentVectorSchema, DEFAULT_LAYOUT_FONT, DecimalStringSchema, DefinitionEntrySchema, DefinitionsTableSchema, DimensionVectorSchema, DivisionDescriptorSchema, DivisionSourceSchema, DocumentPackageRenamedError, DocumentTreeSchema, DrawPageDescriptorSchema, DrawPageGroupSchema, EMBEDDED_OBJECT_KINDS, EvaluationValueSchema, ExactRationalSchema, FieldDescriptorSchema, FormulaBindingsSchema, HeadingGroupSchema, HeadingParagraphSchema, IMAGE_FORMATS, IntervalSchema, LayoutFontSchema, LayoutFrameSchema, LayoutMetadataSchema, LayoutSchemaDemotedError, LinkDescriptorSchema, LinkTargetSchema, ListGroupSchema, ListParagraphSchema, MAX_SAFE_INTEGER, MarginsSchema, MathAppSchema, MathExpressionSchema, MathMatrixSchema, MathMlAttributeSchema, MathMlCdataSchema, MathMlCommentSchema, MathMlDeclarationSchema, MathMlElementSchema, MathMlNodeSchema, MathMlPiSchema, MathMlTextSchema, MathNormalisationContextSchema, MathNumSchema, MathPresentationSchema, MathProdSchema, MathProvenanceSchema, MathQtySchema, MathSumSchema, MathSymSchema, MathSymbolEntrySchema, MathUncertaintySchema, MathUnitSchema, MathUnparsedSchema, PAGE_SIZE_A4, PAGE_SIZE_LETTER, PageSizeSchema, ProvenanceChangeSchema, ProvenanceDescriptorSchema, QuantitySchema, RUN_FONT_PROPERTY_SHAPE, RunConstructExtentSchema, SCHEMA_FILE_NAMES, SI_BASE_DIMENSIONS, SLIDE_SIZE_STANDARD, SLIDE_SIZE_WIDESCREEN, SchemaVersionMismatchError, SectionConstructGroupSchema, SectionDescriptorSchema, SectionGroupSchema, ShapeConstructGroupSchema, ShapeDescriptorSchema, ShapeGroupSchema, SheetDescriptorSchema, SheetGroupSchema, SheetRuleOperatorSchema, SlideDescriptorSchema, SlideGroupSchema, SourceFormatSchema, SourceResidueSchema, StyleEntrySchema, StyleParagraphPropertiesSchema, StyleRunPropertiesSchema, StylesTableSchema, SymbolTableSchema, TextDirectionSchema, TreeBlockLeafSchema, TreeEmbeddedFontSchema, TreeGroupSchema, TreeLeafSchema, TreeNodeSchema, UnrecognizedDocumentSchemaError, applyParagraphStyleProperties, applyRunStyleProperties, assembleTree, borderWeightForWidthPt, cellReference, clampHeadingLevel, colorToRgbHex, columnIndexToLetters, columnLettersToIndex, contentDocumentSharedFields, contentDocumentWithSchema, dashedBorderWeightForWidthPt, decompose, documentFromJson, documentSchemaKindOf, documentTreeWithSchema, factorStyles, findConstructMarkerImbalance, findRunConstructFault, flattenTree, isContentBlock, isContentConstructEnd, isContentConstructStart, isDrawPageGroupNode, isHeadingGroupNode, isListGroupNode, isMathExpression, isMathMlNode, isRunConstructExtent, isSectionConstructGroupNode, isSectionGroupNode, isShapeConstructGroupNode, isShapeGroupNode, isSheetGroupNode, isSlideGroupNode, isTreeBlockLeaf, isTreeGroup, isTreeLeaf, isTreeNode, overlayStyleEntries, parseCellReference, parseRangeReference, rangeReference, resolveCellFillColor, resolveStyleChain, rgbHexToColor, schemaUriFor, unrecognizedFillKind };
25
+ export { AlignmentSchema, AnchorDescriptorSchema, AnchorTypeSchema, BORDER_WIDTH_PT, BoxSchema, COLOR_BLACK, CONTENT_ANNOTATION_FIELDS, CONTENT_DEFS, CONTENT_DOCUMENT_URI, ColorSchema, ConstructDescriptorSchema, ConstructMarkerImbalanceError, ContentBitmapFillSchema, ContentBlockSchema, ContentBorderSchema, ContentCellBordersSchema, ContentCellFillSchema, ContentCellPatternTypeSchema, ContentCellValueSchema, ContentConstructEndSchema, ContentConstructStartSchema, ContentControlDescriptorSchema, ContentControlLockSchema, ContentControlTypeSchema, ContentDefinedNameSchema, ContentDocumentSchema, ContentDrawPageSchema, ContentEmbeddedObjectBlockSchema, ContentEmbeddedObjectSchema, ContentFillPatternSchema, ContentFloatAlignSchema, ContentFloatAxisSchema, ContentFloatOriginSchema, ContentFloatPositionSchema, ContentFontSchema, ContentFormulaSchema, ContentGradientFillSchema, ContentGradientStyleSchema, ContentHatchFillSchema, ContentHatchStyleSchema, ContentImageBlockSchema, ContentImageOriginalSchema, ContentInterpretationSchema, ContentListMembershipSchema, ContentOriginSchema, ContentPageBreakSchema, ContentPageFurnitureSchema, ContentParagraphBordersSchema, ContentParagraphSchema, ContentPathPointSchema, ContentPathSegmentSchema, ContentRunSchema, ContentSectionSchema, ContentShapeSchema, ContentSheetCellCommentSchema, ContentSheetCellSchema, ContentSheetColumnSchema, ContentSheetConditionalFormatSchema, ContentSheetConditionalFormatStyleSchema, ContentSheetConditionalFormatValueSchema, ContentSheetDataValidationSchema, ContentSheetDataValidationTypeSchema, ContentSheetImageSchema, ContentSheetPrintRangeSchema, ContentSheetPrintSettingsSchema, ContentSheetRangeSchema, ContentSheetRepeatRangeSchema, ContentSheetRowSchema, ContentSheetSchema, ContentSlideSchema, ContentStrokeDashSchema, ContentStrokeSchema, ContentStrokeStyleSchema, ContentSubpathSchema, ContentTableCellSchema, ContentTableRowSchema, ContentTableSchema, ContentTranscriptSchema, ContentVectorSchema, DEFAULT_LAYOUT_FONT, DecimalStringSchema, DefinitionEntrySchema, DefinitionsTableSchema, DimensionVectorSchema, DivisionDescriptorSchema, DivisionSourceSchema, DocumentPackageRenamedError, DocumentTreeSchema, DrawPageDescriptorSchema, DrawPageGroupSchema, EMBEDDED_OBJECT_KINDS, EvaluationValueSchema, ExactRationalSchema, FieldDescriptorSchema, FormulaBindingsSchema, HeadingGroupSchema, HeadingParagraphSchema, IMAGE_FORMATS, IntervalSchema, LayoutFontSchema, LayoutFrameSchema, LayoutMetadataSchema, LayoutSchemaDemotedError, LinkDescriptorSchema, LinkTargetSchema, ListGroupSchema, ListParagraphSchema, MAX_SAFE_INTEGER, MarginsSchema, MathAppSchema, MathExpressionSchema, MathMatrixSchema, MathMlAttributeSchema, MathMlCdataSchema, MathMlCommentSchema, MathMlDeclarationSchema, MathMlElementSchema, MathMlNodeSchema, MathMlPiSchema, MathMlTextSchema, MathNormalisationContextSchema, MathNumSchema, MathPresentationSchema, MathProdSchema, MathProvenanceSchema, MathQtySchema, MathSumSchema, MathSymSchema, MathSymbolEntrySchema, MathUncertaintySchema, MathUnitSchema, MathUnparsedSchema, PAGE_SIZE_A4, PAGE_SIZE_LETTER, PageSizeSchema, ProvenanceChangeSchema, ProvenanceDescriptorSchema, QuantitySchema, RUN_FONT_PROPERTY_SHAPE, RunConstructExtentSchema, SCHEMA_FILE_NAMES, SI_BASE_DIMENSIONS, SLIDE_SIZE_STANDARD, SLIDE_SIZE_WIDESCREEN, SchemaVersionMismatchError, SectionConstructGroupSchema, SectionDescriptorSchema, SectionGroupSchema, ShapeConstructGroupSchema, ShapeDescriptorSchema, ShapeGroupSchema, SheetDescriptorSchema, SheetGroupSchema, SheetRuleOperatorSchema, SlideDescriptorSchema, SlideGroupSchema, SourceFormatSchema, SourceResidueSchema, StyleEntrySchema, StyleParagraphPropertiesSchema, StyleRunPropertiesSchema, StylesTableSchema, SymbolTableSchema, TextDirectionSchema, TreeBlockLeafSchema, TreeEmbeddedFontSchema, TreeGroupSchema, TreeLeafSchema, TreeNodeSchema, UnrecognizedDocumentSchemaError, applyParagraphStyleProperties, applyRunStyleProperties, assembleTree, borderWeightForWidthPt, cellReference, clampHeadingLevel, colorToRgbHex, columnIndexToLetters, columnLettersToIndex, contentDocumentSharedFields, contentDocumentWithSchema, dashedBorderWeightForWidthPt, decompose, denseTableRows, describeTableGridFault, documentFromJson, documentSchemaKindOf, documentTreeWithSchema, factorStyles, findConstructMarkerImbalance, findRunConstructFault, findTableGridFault, flattenTree, isContentBlock, isContentConstructEnd, isContentConstructStart, isDrawPageGroupNode, isHeadingGroupNode, isListGroupNode, isMathExpression, isMathMlNode, isRunConstructExtent, isSectionConstructGroupNode, isSectionGroupNode, isShapeConstructGroupNode, isShapeGroupNode, isSheetGroupNode, isSlideGroupNode, isTreeBlockLeaf, isTreeGroup, isTreeLeaf, isTreeNode, overlayStyleEntries, parseCellReference, parseRangeReference, placeAnchorTableRows, rangeReference, resolveCellFillColor, resolveStyleChain, rgbHexToColor, schemaUriFor, tableCellColumnSpan, tableCellRowSpan, tableGridColumnCount, unrecognizedFillKind, walkTableGrid };
@@ -7,7 +7,7 @@ const SCHEMA_FILE_NAMES = {
7
7
  ContentDocument: "content-document.schema.json"
8
8
  };
9
9
  function schemaUriFor(kind) {
10
- return `https://cdn.jsdelivr.net/npm/document-schema.js@7.11.5/schemas/${SCHEMA_FILE_NAMES[kind]}`;
10
+ return `https://cdn.jsdelivr.net/npm/document-schema.js@7.13.0/schemas/${SCHEMA_FILE_NAMES[kind]}`;
11
11
  }
12
12
  const SCHEMA_URI_PATTERN = /^https:\/\/cdn\.jsdelivr\.net\/npm\/document-schema\.js@([^/]+)\/schemas\/(document-tree|document-package|content-document|layout-document)\.schema\.json$/;
13
13
  function parseSchemaUri(uri) {
@@ -102,7 +102,7 @@ function documentFromJson(value) {
102
102
  if (parts.stem === "document-package") throw new DocumentPackageRenamedError(value.$schema);
103
103
  const kind = kindForFileStem(parts.stem);
104
104
  if (kind === void 0) throw new UnrecognizedDocumentSchemaError(value.$schema);
105
- if (majorVersionOf(parts.version) !== majorVersionOf("7.11.5")) throw new SchemaVersionMismatchError(value.$schema, parts.version, "7.11.5");
105
+ if (majorVersionOf(parts.version) !== majorVersionOf("7.13.0")) throw new SchemaVersionMismatchError(value.$schema, parts.version, "7.13.0");
106
106
  switch (kind) {
107
107
  case "DocumentTree": return {
108
108
  kind,
package/dist/schema-io.js CHANGED
@@ -6,7 +6,7 @@ const SCHEMA_FILE_NAMES = {
6
6
  ContentDocument: "content-document.schema.json"
7
7
  };
8
8
  function schemaUriFor(kind) {
9
- return `https://cdn.jsdelivr.net/npm/document-schema.js@7.11.5/schemas/${SCHEMA_FILE_NAMES[kind]}`;
9
+ return `https://cdn.jsdelivr.net/npm/document-schema.js@7.13.0/schemas/${SCHEMA_FILE_NAMES[kind]}`;
10
10
  }
11
11
  const SCHEMA_URI_PATTERN = /^https:\/\/cdn\.jsdelivr\.net\/npm\/document-schema\.js@([^/]+)\/schemas\/(document-tree|document-package|content-document|layout-document)\.schema\.json$/;
12
12
  function parseSchemaUri(uri) {
@@ -101,7 +101,7 @@ function documentFromJson(value) {
101
101
  if (parts.stem === "document-package") throw new DocumentPackageRenamedError(value.$schema);
102
102
  const kind = kindForFileStem(parts.stem);
103
103
  if (kind === void 0) throw new UnrecognizedDocumentSchemaError(value.$schema);
104
- if (majorVersionOf(parts.version) !== majorVersionOf("7.11.5")) throw new SchemaVersionMismatchError(value.$schema, parts.version, "7.11.5");
104
+ if (majorVersionOf(parts.version) !== majorVersionOf("7.13.0")) throw new SchemaVersionMismatchError(value.$schema, parts.version, "7.13.0");
105
105
  switch (kind) {
106
106
  case "DocumentTree": return {
107
107
  kind,
@@ -0,0 +1,204 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ //#region src/table-grid.ts
3
+ /** The number of grid columns a cell occupies; an absent `colSpan` means the cell occupies its own column only. */
4
+ function tableCellColumnSpan(cell) {
5
+ return cell.colSpan ?? 1;
6
+ }
7
+ /** The number of grid rows a cell occupies; an absent `rowSpan` means the cell occupies its own row only. */
8
+ function tableCellRowSpan(cell) {
9
+ return cell.rowSpan ?? 1;
10
+ }
11
+ /**
12
+ * The table's grid width. For a table obeying the dense rule this is `columnWidthsPt.length` and every row's `cells.length` alike; taking the largest of them is what lets a reader mid-construction, or a table whose source declared a grid narrower than a row actually uses, still be walked without the walk inventing a narrower grid than the rows occupy.
13
+ */
14
+ function tableGridColumnCount(table) {
15
+ let count = table.columnWidthsPt.length;
16
+ for (const row of table.rows) count = Math.max(count, row.cells.length);
17
+ return count;
18
+ }
19
+ function coveringAnchor(anchors, rowIndex, columnIndex) {
20
+ for (const anchor of anchors) if (rowIndex < anchor.rowEnd && anchor.column <= columnIndex && columnIndex < anchor.columnEnd) return anchor;
21
+ }
22
+ /**
23
+ * Classify every entry of every row as an anchor or as covered, in row-major order, one inner array per table row.
24
+ *
25
+ * This is the walk a consumer runs instead of accumulating spans itself. A writer targeting a format that stores only anchors (HTML's `<td colspan>`, a docx `w:tc` with `w:gridSpan`) keeps the anchors and drops the covered positions; a writer targeting a format that stores covered positions explicitly (ODF, pptx) writes both; a reader checks its own output against it.
26
+ */
27
+ function walkTableGrid(table) {
28
+ const anchors = [];
29
+ return table.rows.map((row, rowIndex) => row.cells.map((cell, columnIndex) => {
30
+ const anchor = coveringAnchor(anchors, rowIndex, columnIndex);
31
+ if (anchor !== void 0) return {
32
+ rowIndex,
33
+ columnIndex,
34
+ cell,
35
+ anchorRowIndex: anchor.row,
36
+ anchorColumnIndex: anchor.column
37
+ };
38
+ anchors.push({
39
+ row: rowIndex,
40
+ column: columnIndex,
41
+ rowEnd: rowIndex + tableCellRowSpan(cell),
42
+ columnEnd: columnIndex + tableCellColumnSpan(cell)
43
+ });
44
+ return {
45
+ rowIndex,
46
+ columnIndex,
47
+ cell
48
+ };
49
+ }));
50
+ }
51
+ /** The span of a cell that occupies its own grid position only, which is what an absent `colSpan` or `rowSpan` means. */
52
+ const UNMERGED_SPAN = 1;
53
+ function widestRowLength(table) {
54
+ let width = 0;
55
+ for (const row of table.rows) width = Math.max(width, row.cells.length);
56
+ return width;
57
+ }
58
+ function coveredFault(position) {
59
+ const { rowIndex, columnIndex, anchorRowIndex, anchorColumnIndex, cell } = position;
60
+ if (cell.blocks.length > 0) return {
61
+ kind: "coveredContent",
62
+ rowIndex,
63
+ columnIndex,
64
+ anchorRowIndex,
65
+ anchorColumnIndex
66
+ };
67
+ if (tableCellColumnSpan(cell) > UNMERGED_SPAN || tableCellRowSpan(cell) > UNMERGED_SPAN) return {
68
+ kind: "coveredSpan",
69
+ rowIndex,
70
+ columnIndex,
71
+ anchorRowIndex,
72
+ anchorColumnIndex
73
+ };
74
+ }
75
+ function overlappedRegion(anchor, row) {
76
+ const footprintEnd = anchor.columnIndex + tableCellColumnSpan(anchor.cell);
77
+ for (const position of row.slice(anchor.columnIndex + 1, footprintEnd)) if (position.anchorRowIndex !== void 0 && position.anchorRowIndex < anchor.rowIndex) return position;
78
+ }
79
+ function anchorFault(anchor, row, rowCount) {
80
+ const { rowIndex, columnIndex, cell } = anchor;
81
+ if (columnIndex + tableCellColumnSpan(cell) > row.length) return {
82
+ kind: "anchorOverrunsColumns",
83
+ rowIndex,
84
+ columnIndex
85
+ };
86
+ if (rowIndex + tableCellRowSpan(cell) > rowCount) return {
87
+ kind: "anchorOverrunsRows",
88
+ rowIndex,
89
+ columnIndex
90
+ };
91
+ const overlapped = overlappedRegion(anchor, row);
92
+ if (overlapped !== void 0) return {
93
+ kind: "overlappingAnchors",
94
+ rowIndex,
95
+ columnIndex,
96
+ earlierAnchorRowIndex: overlapped.anchorRowIndex,
97
+ earlierAnchorColumnIndex: overlapped.anchorColumnIndex
98
+ };
99
+ }
100
+ /**
101
+ * The first place `table` contradicts the grid rule, or `undefined` when it obeys it. It never throws: a caller decides what a fault means for it, the way findConstructMarkerImbalance leaves that decision to each consumer of a block list.
102
+ *
103
+ * Rows are compared with each other before any position is classified, since an anchor's footprint can only be measured against a grid every row shares; the positions are then checked in row-major order, so the fault returned is the earliest one in reading order.
104
+ *
105
+ * The check states the whole of the rule and nothing beyond it: a table with no rows, or whose rows are all empty, has no fault, and neither `columnWidthsPt` nor a cell's own properties other than its blocks and spans are consulted.
106
+ */
107
+ function findTableGridFault(table) {
108
+ const gridColumnCount = widestRowLength(table);
109
+ for (const [rowIndex, row] of table.rows.entries()) if (row.cells.length !== gridColumnCount) return {
110
+ kind: "raggedRow",
111
+ rowIndex,
112
+ cellCount: row.cells.length,
113
+ gridColumnCount
114
+ };
115
+ const grid = walkTableGrid(table);
116
+ for (const row of grid) for (const position of row) {
117
+ const fault = position.anchorRowIndex === void 0 ? anchorFault(position, row, grid.length) : coveredFault(position);
118
+ if (fault !== void 0) return fault;
119
+ }
120
+ }
121
+ /**
122
+ * One sentence stating a fault in words, for a writer that refuses or reports a table the grid rule does not admit: it names the fault by its position and, where the fault involves a second region, by that region's anchor. Indices are 0-based, matching every index in the descriptor. The sentence carries no entry point or format of its own, so each caller prefixes whatever names its own operation.
123
+ */
124
+ function describeTableGridFault(fault) {
125
+ switch (fault.kind) {
126
+ case "raggedRow": return `row ${String(fault.rowIndex)} holds ${String(fault.cellCount)} cells where the widest row holds ${String(fault.gridColumnCount)}, but every row of a table covers the same grid`;
127
+ case "coveredContent": return `the cell at row ${String(fault.rowIndex)}, column ${String(fault.columnIndex)} lies inside the merged region anchored at row ${String(fault.anchorRowIndex)}, column ${String(fault.anchorColumnIndex)} but carries content of its own, and a merged region's content belongs to its anchor`;
128
+ case "coveredSpan": return `the cell at row ${String(fault.rowIndex)}, column ${String(fault.columnIndex)} lies inside the merged region anchored at row ${String(fault.anchorRowIndex)}, column ${String(fault.anchorColumnIndex)} but states a span of its own, and only a region's anchor carries a span`;
129
+ case "anchorOverrunsColumns": return `the merged region anchored at row ${String(fault.rowIndex)}, column ${String(fault.columnIndex)} spans past the last column of the grid`;
130
+ case "anchorOverrunsRows": return `the merged region anchored at row ${String(fault.rowIndex)}, column ${String(fault.columnIndex)} spans past the last row of the table`;
131
+ case "overlappingAnchors": return `the merged region anchored at row ${String(fault.rowIndex)}, column ${String(fault.columnIndex)} overlaps the region anchored at row ${String(fault.earlierAnchorRowIndex)}, column ${String(fault.earlierAnchorColumnIndex)}, but a grid position belongs to one region only`;
132
+ }
133
+ }
134
+ function placedGridWidth(rows, columnCount) {
135
+ let width = columnCount;
136
+ for (const row of rows) for (const { columnIndex, cell } of row.cells) width = Math.max(width, columnIndex + tableCellColumnSpan(cell));
137
+ return width;
138
+ }
139
+ /**
140
+ * Build dense rows from cells a reader has already positioned, filling every position no cell was placed at with an empty covered cell.
141
+ *
142
+ * `columnCount` is the grid width the source declared (a docx `w:tblGrid`, an ODF `table:table-column` run). The result is that wide, or wider if some row places a cell past it, so that every returned row has the same length whatever the source's own grid declaration said.
143
+ */
144
+ function denseTableRows(rows, columnCount) {
145
+ const width = placedGridWidth(rows, columnCount);
146
+ return rows.map((row) => {
147
+ const cells = Array.from({ length: width }, () => ({ blocks: [] }));
148
+ for (const { columnIndex, cell } of row.cells) cells[columnIndex] = cell;
149
+ return {
150
+ ...row,
151
+ cells
152
+ };
153
+ });
154
+ }
155
+ function occupiedColumns(occupied, rowIndex) {
156
+ const existing = occupied.get(rowIndex);
157
+ if (existing !== void 0) return existing;
158
+ const created = /* @__PURE__ */ new Set();
159
+ occupied.set(rowIndex, created);
160
+ return created;
161
+ }
162
+ function positionAnchorRows(rows) {
163
+ const occupied = /* @__PURE__ */ new Map();
164
+ return rows.map((row, rowIndex) => {
165
+ const taken = occupiedColumns(occupied, rowIndex);
166
+ let column = 0;
167
+ const cells = row.cells.map((cell) => {
168
+ while (taken.has(column)) column++;
169
+ const lastRow = rowIndex + tableCellRowSpan(cell);
170
+ const lastColumn = column + tableCellColumnSpan(cell);
171
+ for (let r = rowIndex; r < lastRow; r++) {
172
+ const rowTaken = occupiedColumns(occupied, r);
173
+ for (let c = column; c < lastColumn; c++) rowTaken.add(c);
174
+ }
175
+ const positioned = {
176
+ columnIndex: column,
177
+ cell
178
+ };
179
+ column = lastColumn;
180
+ return positioned;
181
+ });
182
+ return {
183
+ ...row,
184
+ cells
185
+ };
186
+ });
187
+ }
188
+ /**
189
+ * Build dense rows from anchor cells alone, placing each at the first grid column no earlier cell already reaches -- the placement HTML's own table model needs, where a `rowspan` in one row silently consumes a column in the rows below it and nothing marks the consumed position.
190
+ *
191
+ * `columnCount` is the grid width the source declared, where it declares one at all; pass 0 when it does not and the width follows from the placement.
192
+ */
193
+ function placeAnchorTableRows(rows, columnCount) {
194
+ return denseTableRows(positionAnchorRows(rows), columnCount);
195
+ }
196
+ //#endregion
197
+ exports.denseTableRows = denseTableRows;
198
+ exports.describeTableGridFault = describeTableGridFault;
199
+ exports.findTableGridFault = findTableGridFault;
200
+ exports.placeAnchorTableRows = placeAnchorTableRows;
201
+ exports.tableCellColumnSpan = tableCellColumnSpan;
202
+ exports.tableCellRowSpan = tableCellRowSpan;
203
+ exports.tableGridColumnCount = tableGridColumnCount;
204
+ exports.walkTableGrid = walkTableGrid;
@@ -0,0 +1,112 @@
1
+ import { o as TextDirection } from "./style-BGMcYrD2.cjs";
2
+ import { _n as ContentTableRow, hn as ContentTableCell, mn as ContentTable } from "./content-zNNPbwYY.cjs";
3
+ //#region src/table-grid.d.ts
4
+ /** The number of grid columns a cell occupies; an absent `colSpan` means the cell occupies its own column only. */
5
+ declare function tableCellColumnSpan(cell: ContentTableCell): number;
6
+ /** The number of grid rows a cell occupies; an absent `rowSpan` means the cell occupies its own row only. */
7
+ declare function tableCellRowSpan(cell: ContentTableCell): number;
8
+ /**
9
+ * The table's grid width. For a table obeying the dense rule this is `columnWidthsPt.length` and every row's `cells.length` alike; taking the largest of them is what lets a reader mid-construction, or a table whose source declared a grid narrower than a row actually uses, still be walked without the walk inventing a narrower grid than the rows occupy.
10
+ */
11
+ declare function tableGridColumnCount(table: ContentTable): number;
12
+ /** A grid position holding a merged region's anchor, or an unmerged cell (which is its own one-position region's anchor). */
13
+ interface TableGridAnchor {
14
+ readonly rowIndex: number;
15
+ readonly columnIndex: number;
16
+ readonly cell: ContentTableCell;
17
+ readonly anchorRowIndex?: never;
18
+ readonly anchorColumnIndex?: never;
19
+ }
20
+ /** A grid position covered by a merged region anchored elsewhere. `anchorRowIndex < rowIndex` means the region reaches this position vertically; `anchorRowIndex === rowIndex` means it reaches it horizontally along this same row. */
21
+ interface TableGridCovered {
22
+ readonly rowIndex: number;
23
+ readonly columnIndex: number;
24
+ readonly cell: ContentTableCell;
25
+ readonly anchorRowIndex: number;
26
+ readonly anchorColumnIndex: number;
27
+ }
28
+ /** Discriminated by the presence of the anchor coordinates rather than by a tag field, since the two shapes' required fields are already mutually exclusive: `"anchorRowIndex" in position` narrows to the covered branch. */
29
+ type TableGridPosition = TableGridAnchor | TableGridCovered;
30
+ /**
31
+ * Classify every entry of every row as an anchor or as covered, in row-major order, one inner array per table row.
32
+ *
33
+ * This is the walk a consumer runs instead of accumulating spans itself. A writer targeting a format that stores only anchors (HTML's `<td colspan>`, a docx `w:tc` with `w:gridSpan`) keeps the anchors and drops the covered positions; a writer targeting a format that stores covered positions explicitly (ODF, pptx) writes both; a reader checks its own output against it.
34
+ */
35
+ declare function walkTableGrid(table: ContentTable): TableGridPosition[][];
36
+ /**
37
+ * Where a table stops obeying the grid rule (ContentTableCell in src/content.ts states the rule; walkTableGrid derives the classification every check here is made against). Every variant names a position in the table's own row and column indices.
38
+ *
39
+ * - `raggedRow`: the row holds `cellCount` entries where the table's widest row holds `gridColumnCount`, so the rows do not all cover the same grid.
40
+ * - `coveredContent`: the position is covered by the region anchored at `anchorRowIndex`, `anchorColumnIndex` yet carries blocks of its own; the region's content belongs to its anchor, so a second copy has nowhere to go.
41
+ * - `coveredSpan`: the position is covered by the region anchored at `anchorRowIndex`, `anchorColumnIndex` yet carries a `colSpan` or `rowSpan` of its own. Spans are set on the anchor only and walkTableGrid never consults a covered entry's, so this is how a second anchor starting inside another's footprint shows up: the walk assigns each position to the first anchor covering it, which leaves the second entry classified as covered and its span ignored.
42
+ * - `anchorOverrunsColumns`: the anchor at this position has a `colSpan` reaching past the last grid column.
43
+ * - `anchorOverrunsRows`: the anchor at this position has a `rowSpan` reaching past the last row of the table.
44
+ * - `overlappingAnchors`: the anchor at this position starts outside every other region but its footprint reaches a position already covered by the region anchored at `earlierAnchorRowIndex`, `earlierAnchorColumnIndex`, so two regions claim one position.
45
+ *
46
+ * A `kind` tag discriminates rather than property presence, because the variants' required fields are not mutually exclusive: several variants' fields include another's.
47
+ */
48
+ type TableGridFault = {
49
+ readonly kind: "raggedRow";
50
+ readonly rowIndex: number;
51
+ readonly cellCount: number;
52
+ readonly gridColumnCount: number;
53
+ } | {
54
+ readonly kind: "coveredContent" | "coveredSpan";
55
+ readonly rowIndex: number;
56
+ readonly columnIndex: number;
57
+ readonly anchorRowIndex: number;
58
+ readonly anchorColumnIndex: number;
59
+ } | {
60
+ readonly kind: "anchorOverrunsColumns" | "anchorOverrunsRows";
61
+ readonly rowIndex: number;
62
+ readonly columnIndex: number;
63
+ } | {
64
+ readonly kind: "overlappingAnchors";
65
+ readonly rowIndex: number;
66
+ readonly columnIndex: number;
67
+ readonly earlierAnchorRowIndex: number;
68
+ readonly earlierAnchorColumnIndex: number;
69
+ };
70
+ /**
71
+ * The first place `table` contradicts the grid rule, or `undefined` when it obeys it. It never throws: a caller decides what a fault means for it, the way findConstructMarkerImbalance leaves that decision to each consumer of a block list.
72
+ *
73
+ * Rows are compared with each other before any position is classified, since an anchor's footprint can only be measured against a grid every row shares; the positions are then checked in row-major order, so the fault returned is the earliest one in reading order.
74
+ *
75
+ * The check states the whole of the rule and nothing beyond it: a table with no rows, or whose rows are all empty, has no fault, and neither `columnWidthsPt` nor a cell's own properties other than its blocks and spans are consulted.
76
+ */
77
+ declare function findTableGridFault(table: ContentTable): TableGridFault | undefined;
78
+ /**
79
+ * One sentence stating a fault in words, for a writer that refuses or reports a table the grid rule does not admit: it names the fault by its position and, where the fault involves a second region, by that region's anchor. Indices are 0-based, matching every index in the descriptor. The sentence carries no entry point or format of its own, so each caller prefixes whatever names its own operation.
80
+ */
81
+ declare function describeTableGridFault(fault: TableGridFault): string;
82
+ /** A cell together with the grid column it starts at, for a reader whose source format states that column directly. */
83
+ interface PositionedTableCell {
84
+ readonly columnIndex: number;
85
+ readonly cell: ContentTableCell;
86
+ }
87
+ /** One row's worth of positioned cells, carrying the row-level properties denseTableRows copies through unchanged. */
88
+ interface PositionedTableRow {
89
+ readonly cells: readonly PositionedTableCell[];
90
+ readonly heightPt?: number;
91
+ readonly direction?: TextDirection;
92
+ }
93
+ /**
94
+ * Build dense rows from cells a reader has already positioned, filling every position no cell was placed at with an empty covered cell.
95
+ *
96
+ * `columnCount` is the grid width the source declared (a docx `w:tblGrid`, an ODF `table:table-column` run). The result is that wide, or wider if some row places a cell past it, so that every returned row has the same length whatever the source's own grid declaration said.
97
+ */
98
+ declare function denseTableRows(rows: readonly PositionedTableRow[], columnCount: number): ContentTableRow[];
99
+ /** One row's worth of anchor cells only, for a reader whose source format omits covered positions entirely and leaves their grid columns to be worked out from the spans around them. */
100
+ interface AnchorTableRow {
101
+ readonly cells: readonly ContentTableCell[];
102
+ readonly heightPt?: number;
103
+ readonly direction?: TextDirection;
104
+ }
105
+ /**
106
+ * Build dense rows from anchor cells alone, placing each at the first grid column no earlier cell already reaches -- the placement HTML's own table model needs, where a `rowspan` in one row silently consumes a column in the rows below it and nothing marks the consumed position.
107
+ *
108
+ * `columnCount` is the grid width the source declared, where it declares one at all; pass 0 when it does not and the width follows from the placement.
109
+ */
110
+ declare function placeAnchorTableRows(rows: readonly AnchorTableRow[], columnCount: number): ContentTableRow[];
111
+ //#endregion
112
+ export { AnchorTableRow, PositionedTableCell, PositionedTableRow, TableGridAnchor, TableGridCovered, TableGridFault, TableGridPosition, denseTableRows, describeTableGridFault, findTableGridFault, placeAnchorTableRows, tableCellColumnSpan, tableCellRowSpan, tableGridColumnCount, walkTableGrid };
@@ -0,0 +1,112 @@
1
+ import { o as TextDirection } from "./style-BGMcYrD2.js";
2
+ import { _n as ContentTableRow, hn as ContentTableCell, mn as ContentTable } from "./content-GHj_31uQ.js";
3
+ //#region src/table-grid.d.ts
4
+ /** The number of grid columns a cell occupies; an absent `colSpan` means the cell occupies its own column only. */
5
+ declare function tableCellColumnSpan(cell: ContentTableCell): number;
6
+ /** The number of grid rows a cell occupies; an absent `rowSpan` means the cell occupies its own row only. */
7
+ declare function tableCellRowSpan(cell: ContentTableCell): number;
8
+ /**
9
+ * The table's grid width. For a table obeying the dense rule this is `columnWidthsPt.length` and every row's `cells.length` alike; taking the largest of them is what lets a reader mid-construction, or a table whose source declared a grid narrower than a row actually uses, still be walked without the walk inventing a narrower grid than the rows occupy.
10
+ */
11
+ declare function tableGridColumnCount(table: ContentTable): number;
12
+ /** A grid position holding a merged region's anchor, or an unmerged cell (which is its own one-position region's anchor). */
13
+ interface TableGridAnchor {
14
+ readonly rowIndex: number;
15
+ readonly columnIndex: number;
16
+ readonly cell: ContentTableCell;
17
+ readonly anchorRowIndex?: never;
18
+ readonly anchorColumnIndex?: never;
19
+ }
20
+ /** A grid position covered by a merged region anchored elsewhere. `anchorRowIndex < rowIndex` means the region reaches this position vertically; `anchorRowIndex === rowIndex` means it reaches it horizontally along this same row. */
21
+ interface TableGridCovered {
22
+ readonly rowIndex: number;
23
+ readonly columnIndex: number;
24
+ readonly cell: ContentTableCell;
25
+ readonly anchorRowIndex: number;
26
+ readonly anchorColumnIndex: number;
27
+ }
28
+ /** Discriminated by the presence of the anchor coordinates rather than by a tag field, since the two shapes' required fields are already mutually exclusive: `"anchorRowIndex" in position` narrows to the covered branch. */
29
+ type TableGridPosition = TableGridAnchor | TableGridCovered;
30
+ /**
31
+ * Classify every entry of every row as an anchor or as covered, in row-major order, one inner array per table row.
32
+ *
33
+ * This is the walk a consumer runs instead of accumulating spans itself. A writer targeting a format that stores only anchors (HTML's `<td colspan>`, a docx `w:tc` with `w:gridSpan`) keeps the anchors and drops the covered positions; a writer targeting a format that stores covered positions explicitly (ODF, pptx) writes both; a reader checks its own output against it.
34
+ */
35
+ declare function walkTableGrid(table: ContentTable): TableGridPosition[][];
36
+ /**
37
+ * Where a table stops obeying the grid rule (ContentTableCell in src/content.ts states the rule; walkTableGrid derives the classification every check here is made against). Every variant names a position in the table's own row and column indices.
38
+ *
39
+ * - `raggedRow`: the row holds `cellCount` entries where the table's widest row holds `gridColumnCount`, so the rows do not all cover the same grid.
40
+ * - `coveredContent`: the position is covered by the region anchored at `anchorRowIndex`, `anchorColumnIndex` yet carries blocks of its own; the region's content belongs to its anchor, so a second copy has nowhere to go.
41
+ * - `coveredSpan`: the position is covered by the region anchored at `anchorRowIndex`, `anchorColumnIndex` yet carries a `colSpan` or `rowSpan` of its own. Spans are set on the anchor only and walkTableGrid never consults a covered entry's, so this is how a second anchor starting inside another's footprint shows up: the walk assigns each position to the first anchor covering it, which leaves the second entry classified as covered and its span ignored.
42
+ * - `anchorOverrunsColumns`: the anchor at this position has a `colSpan` reaching past the last grid column.
43
+ * - `anchorOverrunsRows`: the anchor at this position has a `rowSpan` reaching past the last row of the table.
44
+ * - `overlappingAnchors`: the anchor at this position starts outside every other region but its footprint reaches a position already covered by the region anchored at `earlierAnchorRowIndex`, `earlierAnchorColumnIndex`, so two regions claim one position.
45
+ *
46
+ * A `kind` tag discriminates rather than property presence, because the variants' required fields are not mutually exclusive: several variants' fields include another's.
47
+ */
48
+ type TableGridFault = {
49
+ readonly kind: "raggedRow";
50
+ readonly rowIndex: number;
51
+ readonly cellCount: number;
52
+ readonly gridColumnCount: number;
53
+ } | {
54
+ readonly kind: "coveredContent" | "coveredSpan";
55
+ readonly rowIndex: number;
56
+ readonly columnIndex: number;
57
+ readonly anchorRowIndex: number;
58
+ readonly anchorColumnIndex: number;
59
+ } | {
60
+ readonly kind: "anchorOverrunsColumns" | "anchorOverrunsRows";
61
+ readonly rowIndex: number;
62
+ readonly columnIndex: number;
63
+ } | {
64
+ readonly kind: "overlappingAnchors";
65
+ readonly rowIndex: number;
66
+ readonly columnIndex: number;
67
+ readonly earlierAnchorRowIndex: number;
68
+ readonly earlierAnchorColumnIndex: number;
69
+ };
70
+ /**
71
+ * The first place `table` contradicts the grid rule, or `undefined` when it obeys it. It never throws: a caller decides what a fault means for it, the way findConstructMarkerImbalance leaves that decision to each consumer of a block list.
72
+ *
73
+ * Rows are compared with each other before any position is classified, since an anchor's footprint can only be measured against a grid every row shares; the positions are then checked in row-major order, so the fault returned is the earliest one in reading order.
74
+ *
75
+ * The check states the whole of the rule and nothing beyond it: a table with no rows, or whose rows are all empty, has no fault, and neither `columnWidthsPt` nor a cell's own properties other than its blocks and spans are consulted.
76
+ */
77
+ declare function findTableGridFault(table: ContentTable): TableGridFault | undefined;
78
+ /**
79
+ * One sentence stating a fault in words, for a writer that refuses or reports a table the grid rule does not admit: it names the fault by its position and, where the fault involves a second region, by that region's anchor. Indices are 0-based, matching every index in the descriptor. The sentence carries no entry point or format of its own, so each caller prefixes whatever names its own operation.
80
+ */
81
+ declare function describeTableGridFault(fault: TableGridFault): string;
82
+ /** A cell together with the grid column it starts at, for a reader whose source format states that column directly. */
83
+ interface PositionedTableCell {
84
+ readonly columnIndex: number;
85
+ readonly cell: ContentTableCell;
86
+ }
87
+ /** One row's worth of positioned cells, carrying the row-level properties denseTableRows copies through unchanged. */
88
+ interface PositionedTableRow {
89
+ readonly cells: readonly PositionedTableCell[];
90
+ readonly heightPt?: number;
91
+ readonly direction?: TextDirection;
92
+ }
93
+ /**
94
+ * Build dense rows from cells a reader has already positioned, filling every position no cell was placed at with an empty covered cell.
95
+ *
96
+ * `columnCount` is the grid width the source declared (a docx `w:tblGrid`, an ODF `table:table-column` run). The result is that wide, or wider if some row places a cell past it, so that every returned row has the same length whatever the source's own grid declaration said.
97
+ */
98
+ declare function denseTableRows(rows: readonly PositionedTableRow[], columnCount: number): ContentTableRow[];
99
+ /** One row's worth of anchor cells only, for a reader whose source format omits covered positions entirely and leaves their grid columns to be worked out from the spans around them. */
100
+ interface AnchorTableRow {
101
+ readonly cells: readonly ContentTableCell[];
102
+ readonly heightPt?: number;
103
+ readonly direction?: TextDirection;
104
+ }
105
+ /**
106
+ * Build dense rows from anchor cells alone, placing each at the first grid column no earlier cell already reaches -- the placement HTML's own table model needs, where a `rowspan` in one row silently consumes a column in the rows below it and nothing marks the consumed position.
107
+ *
108
+ * `columnCount` is the grid width the source declared, where it declares one at all; pass 0 when it does not and the width follows from the placement.
109
+ */
110
+ declare function placeAnchorTableRows(rows: readonly AnchorTableRow[], columnCount: number): ContentTableRow[];
111
+ //#endregion
112
+ export { AnchorTableRow, PositionedTableCell, PositionedTableRow, TableGridAnchor, TableGridCovered, TableGridFault, TableGridPosition, denseTableRows, describeTableGridFault, findTableGridFault, placeAnchorTableRows, tableCellColumnSpan, tableCellRowSpan, tableGridColumnCount, walkTableGrid };
@@ -0,0 +1,196 @@
1
+ //#region src/table-grid.ts
2
+ /** The number of grid columns a cell occupies; an absent `colSpan` means the cell occupies its own column only. */
3
+ function tableCellColumnSpan(cell) {
4
+ return cell.colSpan ?? 1;
5
+ }
6
+ /** The number of grid rows a cell occupies; an absent `rowSpan` means the cell occupies its own row only. */
7
+ function tableCellRowSpan(cell) {
8
+ return cell.rowSpan ?? 1;
9
+ }
10
+ /**
11
+ * The table's grid width. For a table obeying the dense rule this is `columnWidthsPt.length` and every row's `cells.length` alike; taking the largest of them is what lets a reader mid-construction, or a table whose source declared a grid narrower than a row actually uses, still be walked without the walk inventing a narrower grid than the rows occupy.
12
+ */
13
+ function tableGridColumnCount(table) {
14
+ let count = table.columnWidthsPt.length;
15
+ for (const row of table.rows) count = Math.max(count, row.cells.length);
16
+ return count;
17
+ }
18
+ function coveringAnchor(anchors, rowIndex, columnIndex) {
19
+ for (const anchor of anchors) if (rowIndex < anchor.rowEnd && anchor.column <= columnIndex && columnIndex < anchor.columnEnd) return anchor;
20
+ }
21
+ /**
22
+ * Classify every entry of every row as an anchor or as covered, in row-major order, one inner array per table row.
23
+ *
24
+ * This is the walk a consumer runs instead of accumulating spans itself. A writer targeting a format that stores only anchors (HTML's `<td colspan>`, a docx `w:tc` with `w:gridSpan`) keeps the anchors and drops the covered positions; a writer targeting a format that stores covered positions explicitly (ODF, pptx) writes both; a reader checks its own output against it.
25
+ */
26
+ function walkTableGrid(table) {
27
+ const anchors = [];
28
+ return table.rows.map((row, rowIndex) => row.cells.map((cell, columnIndex) => {
29
+ const anchor = coveringAnchor(anchors, rowIndex, columnIndex);
30
+ if (anchor !== void 0) return {
31
+ rowIndex,
32
+ columnIndex,
33
+ cell,
34
+ anchorRowIndex: anchor.row,
35
+ anchorColumnIndex: anchor.column
36
+ };
37
+ anchors.push({
38
+ row: rowIndex,
39
+ column: columnIndex,
40
+ rowEnd: rowIndex + tableCellRowSpan(cell),
41
+ columnEnd: columnIndex + tableCellColumnSpan(cell)
42
+ });
43
+ return {
44
+ rowIndex,
45
+ columnIndex,
46
+ cell
47
+ };
48
+ }));
49
+ }
50
+ /** The span of a cell that occupies its own grid position only, which is what an absent `colSpan` or `rowSpan` means. */
51
+ const UNMERGED_SPAN = 1;
52
+ function widestRowLength(table) {
53
+ let width = 0;
54
+ for (const row of table.rows) width = Math.max(width, row.cells.length);
55
+ return width;
56
+ }
57
+ function coveredFault(position) {
58
+ const { rowIndex, columnIndex, anchorRowIndex, anchorColumnIndex, cell } = position;
59
+ if (cell.blocks.length > 0) return {
60
+ kind: "coveredContent",
61
+ rowIndex,
62
+ columnIndex,
63
+ anchorRowIndex,
64
+ anchorColumnIndex
65
+ };
66
+ if (tableCellColumnSpan(cell) > UNMERGED_SPAN || tableCellRowSpan(cell) > UNMERGED_SPAN) return {
67
+ kind: "coveredSpan",
68
+ rowIndex,
69
+ columnIndex,
70
+ anchorRowIndex,
71
+ anchorColumnIndex
72
+ };
73
+ }
74
+ function overlappedRegion(anchor, row) {
75
+ const footprintEnd = anchor.columnIndex + tableCellColumnSpan(anchor.cell);
76
+ for (const position of row.slice(anchor.columnIndex + 1, footprintEnd)) if (position.anchorRowIndex !== void 0 && position.anchorRowIndex < anchor.rowIndex) return position;
77
+ }
78
+ function anchorFault(anchor, row, rowCount) {
79
+ const { rowIndex, columnIndex, cell } = anchor;
80
+ if (columnIndex + tableCellColumnSpan(cell) > row.length) return {
81
+ kind: "anchorOverrunsColumns",
82
+ rowIndex,
83
+ columnIndex
84
+ };
85
+ if (rowIndex + tableCellRowSpan(cell) > rowCount) return {
86
+ kind: "anchorOverrunsRows",
87
+ rowIndex,
88
+ columnIndex
89
+ };
90
+ const overlapped = overlappedRegion(anchor, row);
91
+ if (overlapped !== void 0) return {
92
+ kind: "overlappingAnchors",
93
+ rowIndex,
94
+ columnIndex,
95
+ earlierAnchorRowIndex: overlapped.anchorRowIndex,
96
+ earlierAnchorColumnIndex: overlapped.anchorColumnIndex
97
+ };
98
+ }
99
+ /**
100
+ * The first place `table` contradicts the grid rule, or `undefined` when it obeys it. It never throws: a caller decides what a fault means for it, the way findConstructMarkerImbalance leaves that decision to each consumer of a block list.
101
+ *
102
+ * Rows are compared with each other before any position is classified, since an anchor's footprint can only be measured against a grid every row shares; the positions are then checked in row-major order, so the fault returned is the earliest one in reading order.
103
+ *
104
+ * The check states the whole of the rule and nothing beyond it: a table with no rows, or whose rows are all empty, has no fault, and neither `columnWidthsPt` nor a cell's own properties other than its blocks and spans are consulted.
105
+ */
106
+ function findTableGridFault(table) {
107
+ const gridColumnCount = widestRowLength(table);
108
+ for (const [rowIndex, row] of table.rows.entries()) if (row.cells.length !== gridColumnCount) return {
109
+ kind: "raggedRow",
110
+ rowIndex,
111
+ cellCount: row.cells.length,
112
+ gridColumnCount
113
+ };
114
+ const grid = walkTableGrid(table);
115
+ for (const row of grid) for (const position of row) {
116
+ const fault = position.anchorRowIndex === void 0 ? anchorFault(position, row, grid.length) : coveredFault(position);
117
+ if (fault !== void 0) return fault;
118
+ }
119
+ }
120
+ /**
121
+ * One sentence stating a fault in words, for a writer that refuses or reports a table the grid rule does not admit: it names the fault by its position and, where the fault involves a second region, by that region's anchor. Indices are 0-based, matching every index in the descriptor. The sentence carries no entry point or format of its own, so each caller prefixes whatever names its own operation.
122
+ */
123
+ function describeTableGridFault(fault) {
124
+ switch (fault.kind) {
125
+ case "raggedRow": return `row ${String(fault.rowIndex)} holds ${String(fault.cellCount)} cells where the widest row holds ${String(fault.gridColumnCount)}, but every row of a table covers the same grid`;
126
+ case "coveredContent": return `the cell at row ${String(fault.rowIndex)}, column ${String(fault.columnIndex)} lies inside the merged region anchored at row ${String(fault.anchorRowIndex)}, column ${String(fault.anchorColumnIndex)} but carries content of its own, and a merged region's content belongs to its anchor`;
127
+ case "coveredSpan": return `the cell at row ${String(fault.rowIndex)}, column ${String(fault.columnIndex)} lies inside the merged region anchored at row ${String(fault.anchorRowIndex)}, column ${String(fault.anchorColumnIndex)} but states a span of its own, and only a region's anchor carries a span`;
128
+ case "anchorOverrunsColumns": return `the merged region anchored at row ${String(fault.rowIndex)}, column ${String(fault.columnIndex)} spans past the last column of the grid`;
129
+ case "anchorOverrunsRows": return `the merged region anchored at row ${String(fault.rowIndex)}, column ${String(fault.columnIndex)} spans past the last row of the table`;
130
+ case "overlappingAnchors": return `the merged region anchored at row ${String(fault.rowIndex)}, column ${String(fault.columnIndex)} overlaps the region anchored at row ${String(fault.earlierAnchorRowIndex)}, column ${String(fault.earlierAnchorColumnIndex)}, but a grid position belongs to one region only`;
131
+ }
132
+ }
133
+ function placedGridWidth(rows, columnCount) {
134
+ let width = columnCount;
135
+ for (const row of rows) for (const { columnIndex, cell } of row.cells) width = Math.max(width, columnIndex + tableCellColumnSpan(cell));
136
+ return width;
137
+ }
138
+ /**
139
+ * Build dense rows from cells a reader has already positioned, filling every position no cell was placed at with an empty covered cell.
140
+ *
141
+ * `columnCount` is the grid width the source declared (a docx `w:tblGrid`, an ODF `table:table-column` run). The result is that wide, or wider if some row places a cell past it, so that every returned row has the same length whatever the source's own grid declaration said.
142
+ */
143
+ function denseTableRows(rows, columnCount) {
144
+ const width = placedGridWidth(rows, columnCount);
145
+ return rows.map((row) => {
146
+ const cells = Array.from({ length: width }, () => ({ blocks: [] }));
147
+ for (const { columnIndex, cell } of row.cells) cells[columnIndex] = cell;
148
+ return {
149
+ ...row,
150
+ cells
151
+ };
152
+ });
153
+ }
154
+ function occupiedColumns(occupied, rowIndex) {
155
+ const existing = occupied.get(rowIndex);
156
+ if (existing !== void 0) return existing;
157
+ const created = /* @__PURE__ */ new Set();
158
+ occupied.set(rowIndex, created);
159
+ return created;
160
+ }
161
+ function positionAnchorRows(rows) {
162
+ const occupied = /* @__PURE__ */ new Map();
163
+ return rows.map((row, rowIndex) => {
164
+ const taken = occupiedColumns(occupied, rowIndex);
165
+ let column = 0;
166
+ const cells = row.cells.map((cell) => {
167
+ while (taken.has(column)) column++;
168
+ const lastRow = rowIndex + tableCellRowSpan(cell);
169
+ const lastColumn = column + tableCellColumnSpan(cell);
170
+ for (let r = rowIndex; r < lastRow; r++) {
171
+ const rowTaken = occupiedColumns(occupied, r);
172
+ for (let c = column; c < lastColumn; c++) rowTaken.add(c);
173
+ }
174
+ const positioned = {
175
+ columnIndex: column,
176
+ cell
177
+ };
178
+ column = lastColumn;
179
+ return positioned;
180
+ });
181
+ return {
182
+ ...row,
183
+ cells
184
+ };
185
+ });
186
+ }
187
+ /**
188
+ * Build dense rows from anchor cells alone, placing each at the first grid column no earlier cell already reaches -- the placement HTML's own table model needs, where a `rowspan` in one row silently consumes a column in the rows below it and nothing marks the consumed position.
189
+ *
190
+ * `columnCount` is the grid width the source declared, where it declares one at all; pass 0 when it does not and the width follows from the placement.
191
+ */
192
+ function placeAnchorTableRows(rows, columnCount) {
193
+ return denseTableRows(positionAnchorRows(rows), columnCount);
194
+ }
195
+ //#endregion
196
+ export { denseTableRows, describeTableGridFault, findTableGridFault, placeAnchorTableRows, tableCellColumnSpan, tableCellRowSpan, tableGridColumnCount, walkTableGrid };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "document-content-model",
3
- "version": "7.11.5",
3
+ "version": "7.13.0",
4
4
  "description": "The canonical, format-agnostic content and document-tree schemas shared by ooxml.js, odf.js, documents.js, pdf-codec, and markdown-codec, plus the structural transform between them -- no format-specific or I/O behaviour.",
5
5
  "type": "module",
6
6
  "repository": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$schema": "https://json-schema.org/draft/2020-12/schema",
3
- "$id": "https://cdn.jsdelivr.net/npm/document-schema.js@7.11.5/schemas/content-document.schema.json",
3
+ "$id": "https://cdn.jsdelivr.net/npm/document-schema.js@7.13.0/schemas/content-document.schema.json",
4
4
  "oneOf": [
5
5
  {
6
6
  "type": "object",
@@ -133,7 +133,7 @@
133
133
  "blocks": {
134
134
  "type": "array",
135
135
  "items": {
136
- "$ref": "https://cdn.jsdelivr.net/npm/document-schema.js@7.11.5/schemas/undefined#/$defs/schema2"
136
+ "$ref": "https://cdn.jsdelivr.net/npm/document-schema.js@7.13.0/schemas/undefined#/$defs/schema2"
137
137
  }
138
138
  },
139
139
  "breakType": {
@@ -151,19 +151,19 @@
151
151
  "default": {
152
152
  "type": "array",
153
153
  "items": {
154
- "$ref": "https://cdn.jsdelivr.net/npm/document-schema.js@7.11.5/schemas/undefined#/$defs/schema2"
154
+ "$ref": "https://cdn.jsdelivr.net/npm/document-schema.js@7.13.0/schemas/undefined#/$defs/schema2"
155
155
  }
156
156
  },
157
157
  "even": {
158
158
  "type": "array",
159
159
  "items": {
160
- "$ref": "https://cdn.jsdelivr.net/npm/document-schema.js@7.11.5/schemas/undefined#/$defs/schema2"
160
+ "$ref": "https://cdn.jsdelivr.net/npm/document-schema.js@7.13.0/schemas/undefined#/$defs/schema2"
161
161
  }
162
162
  },
163
163
  "first": {
164
164
  "type": "array",
165
165
  "items": {
166
- "$ref": "https://cdn.jsdelivr.net/npm/document-schema.js@7.11.5/schemas/undefined#/$defs/schema2"
166
+ "$ref": "https://cdn.jsdelivr.net/npm/document-schema.js@7.13.0/schemas/undefined#/$defs/schema2"
167
167
  }
168
168
  }
169
169
  },
@@ -175,19 +175,19 @@
175
175
  "default": {
176
176
  "type": "array",
177
177
  "items": {
178
- "$ref": "https://cdn.jsdelivr.net/npm/document-schema.js@7.11.5/schemas/undefined#/$defs/schema2"
178
+ "$ref": "https://cdn.jsdelivr.net/npm/document-schema.js@7.13.0/schemas/undefined#/$defs/schema2"
179
179
  }
180
180
  },
181
181
  "even": {
182
182
  "type": "array",
183
183
  "items": {
184
- "$ref": "https://cdn.jsdelivr.net/npm/document-schema.js@7.11.5/schemas/undefined#/$defs/schema2"
184
+ "$ref": "https://cdn.jsdelivr.net/npm/document-schema.js@7.13.0/schemas/undefined#/$defs/schema2"
185
185
  }
186
186
  },
187
187
  "first": {
188
188
  "type": "array",
189
189
  "items": {
190
- "$ref": "https://cdn.jsdelivr.net/npm/document-schema.js@7.11.5/schemas/undefined#/$defs/schema2"
190
+ "$ref": "https://cdn.jsdelivr.net/npm/document-schema.js@7.13.0/schemas/undefined#/$defs/schema2"
191
191
  }
192
192
  }
193
193
  },
@@ -199,19 +199,19 @@
199
199
  "default": {
200
200
  "type": "array",
201
201
  "items": {
202
- "$ref": "https://cdn.jsdelivr.net/npm/document-schema.js@7.11.5/schemas/undefined#/$defs/schema2"
202
+ "$ref": "https://cdn.jsdelivr.net/npm/document-schema.js@7.13.0/schemas/undefined#/$defs/schema2"
203
203
  }
204
204
  },
205
205
  "even": {
206
206
  "type": "array",
207
207
  "items": {
208
- "$ref": "https://cdn.jsdelivr.net/npm/document-schema.js@7.11.5/schemas/undefined#/$defs/schema2"
208
+ "$ref": "https://cdn.jsdelivr.net/npm/document-schema.js@7.13.0/schemas/undefined#/$defs/schema2"
209
209
  }
210
210
  },
211
211
  "first": {
212
212
  "type": "array",
213
213
  "items": {
214
- "$ref": "https://cdn.jsdelivr.net/npm/document-schema.js@7.11.5/schemas/undefined#/$defs/schema2"
214
+ "$ref": "https://cdn.jsdelivr.net/npm/document-schema.js@7.13.0/schemas/undefined#/$defs/schema2"
215
215
  }
216
216
  }
217
217
  },
@@ -638,7 +638,7 @@
638
638
  "blocks": {
639
639
  "type": "array",
640
640
  "items": {
641
- "$ref": "https://cdn.jsdelivr.net/npm/document-schema.js@7.11.5/schemas/undefined#/$defs/schema2"
641
+ "$ref": "https://cdn.jsdelivr.net/npm/document-schema.js@7.13.0/schemas/undefined#/$defs/schema2"
642
642
  }
643
643
  }
644
644
  },
@@ -2659,7 +2659,7 @@
2659
2659
  ]
2660
2660
  },
2661
2661
  "document": {
2662
- "$ref": "https://cdn.jsdelivr.net/npm/document-schema.js@7.11.5/schemas/content-document.schema.json"
2662
+ "$ref": "https://cdn.jsdelivr.net/npm/document-schema.js@7.13.0/schemas/content-document.schema.json"
2663
2663
  },
2664
2664
  "frame": {
2665
2665
  "type": "object",
@@ -5021,7 +5021,7 @@
5021
5021
  "blocks": {
5022
5022
  "type": "array",
5023
5023
  "items": {
5024
- "$ref": "https://cdn.jsdelivr.net/npm/document-schema.js@7.11.5/schemas/undefined#/$defs/schema2"
5024
+ "$ref": "https://cdn.jsdelivr.net/npm/document-schema.js@7.13.0/schemas/undefined#/$defs/schema2"
5025
5025
  }
5026
5026
  }
5027
5027
  },
@@ -8027,7 +8027,7 @@
8027
8027
  ]
8028
8028
  },
8029
8029
  "document": {
8030
- "$ref": "https://cdn.jsdelivr.net/npm/document-schema.js@7.11.5/schemas/content-document.schema.json"
8030
+ "$ref": "https://cdn.jsdelivr.net/npm/document-schema.js@7.13.0/schemas/content-document.schema.json"
8031
8031
  },
8032
8032
  "frame": {
8033
8033
  "$ref": "#/$defs/Box"
@@ -10353,7 +10353,7 @@
10353
10353
  ]
10354
10354
  },
10355
10355
  "document": {
10356
- "$ref": "https://cdn.jsdelivr.net/npm/document-schema.js@7.11.5/schemas/content-document.schema.json"
10356
+ "$ref": "https://cdn.jsdelivr.net/npm/document-schema.js@7.13.0/schemas/content-document.schema.json"
10357
10357
  },
10358
10358
  "frame": {
10359
10359
  "$ref": "#/$defs/Box"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$schema": "https://json-schema.org/draft/2020-12/schema",
3
- "$id": "https://cdn.jsdelivr.net/npm/document-schema.js@7.11.5/schemas/document-tree.schema.json",
3
+ "$id": "https://cdn.jsdelivr.net/npm/document-schema.js@7.13.0/schemas/document-tree.schema.json",
4
4
  "oneOf": [
5
5
  {
6
6
  "type": "object",
@@ -1993,7 +1993,7 @@
1993
1993
  ]
1994
1994
  },
1995
1995
  "document": {
1996
- "$ref": "https://cdn.jsdelivr.net/npm/document-schema.js@7.11.5/schemas/content-document.schema.json"
1996
+ "$ref": "https://cdn.jsdelivr.net/npm/document-schema.js@7.13.0/schemas/content-document.schema.json"
1997
1997
  },
1998
1998
  "frame": {
1999
1999
  "$ref": "#/$defs/Box"
@@ -4319,7 +4319,7 @@
4319
4319
  ]
4320
4320
  },
4321
4321
  "document": {
4322
- "$ref": "https://cdn.jsdelivr.net/npm/document-schema.js@7.11.5/schemas/content-document.schema.json"
4322
+ "$ref": "https://cdn.jsdelivr.net/npm/document-schema.js@7.13.0/schemas/content-document.schema.json"
4323
4323
  },
4324
4324
  "frame": {
4325
4325
  "$ref": "#/$defs/Box"