document-content-model 7.12.0 → 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
@@ -207,12 +207,14 @@ exports.contentDocumentWithSchema = require_schema_io.contentDocumentWithSchema;
207
207
  exports.dashedBorderWeightForWidthPt = require_border_weight.dashedBorderWeightForWidthPt;
208
208
  exports.decompose = require_decompose.decompose;
209
209
  exports.denseTableRows = require_table_grid.denseTableRows;
210
+ exports.describeTableGridFault = require_table_grid.describeTableGridFault;
210
211
  exports.documentFromJson = require_schema_io.documentFromJson;
211
212
  exports.documentSchemaKindOf = require_schema_io.documentSchemaKindOf;
212
213
  exports.documentTreeWithSchema = require_schema_io.documentTreeWithSchema;
213
214
  exports.factorStyles = require_factor_styles.factorStyles;
214
215
  exports.findConstructMarkerImbalance = require_content.findConstructMarkerImbalance;
215
216
  exports.findRunConstructFault = require_content.findRunConstructFault;
217
+ exports.findTableGridFault = require_table_grid.findTableGridFault;
216
218
  exports.flattenTree = require_flatten.flattenTree;
217
219
  exports.isContentBlock = require_content.isContentBlock;
218
220
  exports.isContentConstructEnd = require_content.isContentConstructEnd;
package/dist/index.d.cts CHANGED
@@ -18,8 +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, TableGridPosition, denseTableRows, placeAnchorTableRows, tableCellColumnSpan, tableCellRowSpan, tableGridColumnCount, walkTableGrid } from "./table-grid.cjs";
21
+ import { AnchorTableRow, PositionedTableCell, PositionedTableRow, TableGridAnchor, TableGridCovered, TableGridFault, TableGridPosition, denseTableRows, describeTableGridFault, findTableGridFault, placeAnchorTableRows, tableCellColumnSpan, tableCellRowSpan, tableGridColumnCount, walkTableGrid } from "./table-grid.cjs";
22
22
  import { ContentDocumentJson, DocumentJsonResult, DocumentPackageRenamedError, DocumentSchemaKind, DocumentTreeJson, LayoutSchemaDemotedError, SCHEMA_FILE_NAMES, SchemaVersionMismatchError, UnrecognizedDocumentSchemaError, contentDocumentWithSchema, documentFromJson, documentSchemaKindOf, documentTreeWithSchema, schemaUriFor } from "./schema-io.cjs";
23
23
  import { StyledFragment, StyledRun, TextMeasurer, UnderlineMetrics, WrapOptions, WrappedLine } from "./text-layout.cjs";
24
24
  import { MathAssembledGlyphs, MathBox, MathColor, MathFontMetrics, MathGlyphMetrics, MathGlyphPlacement, MathGlyphRun, MathLayoutItem, MathRule, MathStretchAxis, MathStretchGlyph, MathStretchResult, MathStroke, PositionedFormula } from "./math-layout.cjs";
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, 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, 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, placeAnchorTableRows, rangeReference, resolveCellFillColor, resolveStyleChain, rgbHexToColor, schemaUriFor, tableCellColumnSpan, tableCellRowSpan, tableGridColumnCount, unrecognizedFillKind, walkTableGrid };
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,8 +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, TableGridPosition, denseTableRows, placeAnchorTableRows, tableCellColumnSpan, tableCellRowSpan, tableGridColumnCount, walkTableGrid } from "./table-grid.js";
21
+ import { AnchorTableRow, PositionedTableCell, PositionedTableRow, TableGridAnchor, TableGridCovered, TableGridFault, TableGridPosition, denseTableRows, describeTableGridFault, findTableGridFault, placeAnchorTableRows, tableCellColumnSpan, tableCellRowSpan, tableGridColumnCount, walkTableGrid } from "./table-grid.js";
22
22
  import { ContentDocumentJson, DocumentJsonResult, DocumentPackageRenamedError, DocumentSchemaKind, DocumentTreeJson, LayoutSchemaDemotedError, SCHEMA_FILE_NAMES, SchemaVersionMismatchError, UnrecognizedDocumentSchemaError, contentDocumentWithSchema, documentFromJson, documentSchemaKindOf, documentTreeWithSchema, schemaUriFor } from "./schema-io.js";
23
23
  import { StyledFragment, StyledRun, TextMeasurer, UnderlineMetrics, WrapOptions, WrappedLine } from "./text-layout.js";
24
24
  import { MathAssembledGlyphs, MathBox, MathColor, MathFontMetrics, MathGlyphMetrics, MathGlyphPlacement, MathGlyphRun, MathLayoutItem, MathRule, MathStretchAxis, MathStretchGlyph, MathStretchResult, MathStroke, PositionedFormula } from "./math-layout.js";
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, 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, 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, placeAnchorTableRows, rangeReference, resolveCellFillColor, resolveStyleChain, rgbHexToColor, schemaUriFor, tableCellColumnSpan, tableCellRowSpan, tableGridColumnCount, unrecognizedFillKind, walkTableGrid };
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,7 +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, placeAnchorTableRows, tableCellColumnSpan, tableCellRowSpan, tableGridColumnCount, walkTableGrid } from "./table-grid.js";
22
+ import { denseTableRows, describeTableGridFault, findTableGridFault, placeAnchorTableRows, tableCellColumnSpan, tableCellRowSpan, tableGridColumnCount, walkTableGrid } from "./table-grid.js";
23
23
  import "./text-layout.js";
24
24
  import "./math-layout.js";
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, 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, placeAnchorTableRows, rangeReference, resolveCellFillColor, resolveStyleChain, rgbHexToColor, schemaUriFor, tableCellColumnSpan, tableCellRowSpan, tableGridColumnCount, unrecognizedFillKind, walkTableGrid };
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.12.0/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.12.0")) throw new SchemaVersionMismatchError(value.$schema, parts.version, "7.12.0");
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.12.0/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.12.0")) throw new SchemaVersionMismatchError(value.$schema, parts.version, "7.12.0");
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,
@@ -48,6 +48,89 @@ function walkTableGrid(table) {
48
48
  };
49
49
  }));
50
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
+ }
51
134
  function placedGridWidth(rows, columnCount) {
52
135
  let width = columnCount;
53
136
  for (const row of rows) for (const { columnIndex, cell } of row.cells) width = Math.max(width, columnIndex + tableCellColumnSpan(cell));
@@ -112,6 +195,8 @@ function placeAnchorTableRows(rows, columnCount) {
112
195
  }
113
196
  //#endregion
114
197
  exports.denseTableRows = denseTableRows;
198
+ exports.describeTableGridFault = describeTableGridFault;
199
+ exports.findTableGridFault = findTableGridFault;
115
200
  exports.placeAnchorTableRows = placeAnchorTableRows;
116
201
  exports.tableCellColumnSpan = tableCellColumnSpan;
117
202
  exports.tableCellRowSpan = tableCellRowSpan;
@@ -33,6 +33,52 @@ type TableGridPosition = TableGridAnchor | TableGridCovered;
33
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
34
  */
35
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;
36
82
  /** A cell together with the grid column it starts at, for a reader whose source format states that column directly. */
37
83
  interface PositionedTableCell {
38
84
  readonly columnIndex: number;
@@ -63,4 +109,4 @@ interface AnchorTableRow {
63
109
  */
64
110
  declare function placeAnchorTableRows(rows: readonly AnchorTableRow[], columnCount: number): ContentTableRow[];
65
111
  //#endregion
66
- export { AnchorTableRow, PositionedTableCell, PositionedTableRow, TableGridAnchor, TableGridCovered, TableGridPosition, denseTableRows, placeAnchorTableRows, tableCellColumnSpan, tableCellRowSpan, tableGridColumnCount, walkTableGrid };
112
+ export { AnchorTableRow, PositionedTableCell, PositionedTableRow, TableGridAnchor, TableGridCovered, TableGridFault, TableGridPosition, denseTableRows, describeTableGridFault, findTableGridFault, placeAnchorTableRows, tableCellColumnSpan, tableCellRowSpan, tableGridColumnCount, walkTableGrid };
@@ -33,6 +33,52 @@ type TableGridPosition = TableGridAnchor | TableGridCovered;
33
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
34
  */
35
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;
36
82
  /** A cell together with the grid column it starts at, for a reader whose source format states that column directly. */
37
83
  interface PositionedTableCell {
38
84
  readonly columnIndex: number;
@@ -63,4 +109,4 @@ interface AnchorTableRow {
63
109
  */
64
110
  declare function placeAnchorTableRows(rows: readonly AnchorTableRow[], columnCount: number): ContentTableRow[];
65
111
  //#endregion
66
- export { AnchorTableRow, PositionedTableCell, PositionedTableRow, TableGridAnchor, TableGridCovered, TableGridPosition, denseTableRows, placeAnchorTableRows, tableCellColumnSpan, tableCellRowSpan, tableGridColumnCount, walkTableGrid };
112
+ export { AnchorTableRow, PositionedTableCell, PositionedTableRow, TableGridAnchor, TableGridCovered, TableGridFault, TableGridPosition, denseTableRows, describeTableGridFault, findTableGridFault, placeAnchorTableRows, tableCellColumnSpan, tableCellRowSpan, tableGridColumnCount, walkTableGrid };
@@ -47,6 +47,89 @@ function walkTableGrid(table) {
47
47
  };
48
48
  }));
49
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
+ }
50
133
  function placedGridWidth(rows, columnCount) {
51
134
  let width = columnCount;
52
135
  for (const row of rows) for (const { columnIndex, cell } of row.cells) width = Math.max(width, columnIndex + tableCellColumnSpan(cell));
@@ -110,4 +193,4 @@ function placeAnchorTableRows(rows, columnCount) {
110
193
  return denseTableRows(positionAnchorRows(rows), columnCount);
111
194
  }
112
195
  //#endregion
113
- export { denseTableRows, placeAnchorTableRows, tableCellColumnSpan, tableCellRowSpan, tableGridColumnCount, walkTableGrid };
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.12.0",
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.12.0/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.12.0/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.12.0/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.12.0/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.12.0/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.12.0/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.12.0/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.12.0/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.12.0/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.12.0/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.12.0/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.12.0/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.12.0/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.12.0/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.12.0/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.12.0/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.12.0/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.12.0/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.12.0/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"