@stll/folio-core 0.45.0 → 0.46.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.
Files changed (207) hide show
  1. package/dist/ai-edits/apply.js +59 -19
  2. package/dist/ai-edits/headless.js +1 -1
  3. package/dist/compare/compare.js +2 -5
  4. package/dist/compare/scenario.js +2 -5
  5. package/dist/compare/types.d.ts +9 -1
  6. package/dist/compare/types.js +12 -1
  7. package/dist/compat/eigenpal.d.ts +2 -1
  8. package/dist/compat/eigenpal.js +2 -1
  9. package/dist/content-controls/checkboxDisplay.d.ts +11 -0
  10. package/dist/content-controls/checkboxDisplay.js +40 -0
  11. package/dist/content-controls/findContentControls.js +3 -1
  12. package/dist/content-controls/mutateContentControls.js +17 -2
  13. package/dist/controller/contentControlWidgetController.d.ts +1 -0
  14. package/dist/controller/contentControlWidgetController.js +3 -0
  15. package/dist/controller/hiddenEditorApi.js +3 -1
  16. package/dist/controller/hiddenEditorManager.d.ts +1 -1
  17. package/dist/controller/hiddenEditorManager.js +6 -3
  18. package/dist/display-list/build/buildDisplayList.js +20 -1
  19. package/dist/display-list/build/imagePrimitives.d.ts +1 -1
  20. package/dist/display-list/build/imagePrimitives.js +3 -1
  21. package/dist/display-list/build/paragraphPrimitives.js +21 -2
  22. package/dist/display-list/dom/renderDisplayListToDom.js +10 -2
  23. package/dist/display-list/types.d.ts +17 -0
  24. package/dist/docx/attributeRemainder.d.ts +43 -0
  25. package/dist/docx/attributeRemainder.js +65 -0
  26. package/dist/docx/blockContentParser.d.ts +1 -1
  27. package/dist/docx/blockContentParser.js +87 -63
  28. package/dist/docx/blockPlainText.d.ts +3 -4
  29. package/dist/docx/blockPlainText.js +1 -0
  30. package/dist/docx/bookmarkPlacement.js +2 -0
  31. package/dist/docx/commentAnchorIndex.d.ts +30 -0
  32. package/dist/docx/commentAnchorIndex.js +50 -0
  33. package/dist/docx/commentParser.d.ts +1 -1
  34. package/dist/docx/commentParser.js +54 -37
  35. package/dist/docx/commentRangeIntegrity.d.ts +16 -1
  36. package/dist/docx/commentRangeIntegrity.js +42 -1
  37. package/dist/docx/commentRangeJoin.d.ts +9 -0
  38. package/dist/docx/commentRangeJoin.js +33 -0
  39. package/dist/docx/commentReferenceCompletion.d.ts +9 -0
  40. package/dist/docx/commentReferenceCompletion.js +47 -0
  41. package/dist/docx/commentReferenceNormalization.js +1 -0
  42. package/dist/docx/commentReplyMarkers.js +11 -19
  43. package/dist/docx/compatibility.js +1 -0
  44. package/dist/docx/containerChildren.d.ts +111 -0
  45. package/dist/docx/containerChildren.gen.d.ts +28 -0
  46. package/dist/docx/containerChildren.gen.js +246 -0
  47. package/dist/docx/containerChildren.js +103 -0
  48. package/dist/docx/documentParser.d.ts +1 -1
  49. package/dist/docx/documentParser.js +3 -3
  50. package/dist/docx/ensureParaIds.js +17 -7
  51. package/dist/docx/fieldParser.d.ts +1 -1
  52. package/dist/docx/fieldParser.js +4 -4
  53. package/dist/docx/fieldState.d.ts +26 -0
  54. package/dist/docx/fieldState.js +53 -0
  55. package/dist/docx/footnoteParser.d.ts +1 -1
  56. package/dist/docx/graphicFrameLocks.d.ts +16 -4
  57. package/dist/docx/graphicFrameLocks.js +19 -6
  58. package/dist/docx/headerFooterParser.js +1 -1
  59. package/dist/docx/headerFooterReferenceNormalization.js +1 -0
  60. package/dist/docx/hyperlinkParser.d.ts +27 -8
  61. package/dist/docx/hyperlinkParser.js +76 -18
  62. package/dist/docx/imageParser.js +33 -8
  63. package/dist/docx/inlineWrapperContent.d.ts +85 -0
  64. package/dist/docx/inlineWrapperContent.js +84 -0
  65. package/dist/docx/normalizeBaseDirection.js +10 -1
  66. package/dist/docx/paraIdAttribute.d.ts +21 -0
  67. package/dist/docx/paraIdAttribute.js +64 -0
  68. package/dist/docx/paragraphParser.d.ts +1 -1
  69. package/dist/docx/paragraphParser.js +277 -168
  70. package/dist/docx/paragraphPropertySource.js +5 -1
  71. package/dist/docx/paragraphTextBoxEnrichment.d.ts +1 -1
  72. package/dist/docx/paragraphTextBoxEnrichment.js +6 -52
  73. package/dist/docx/paragraphTraversal.js +7 -4
  74. package/dist/docx/parseWarningMessage.js +2 -1
  75. package/dist/docx/preservedRunContent.d.ts +32 -0
  76. package/dist/docx/preservedRunContent.js +86 -0
  77. package/dist/docx/renderedPageBreakNormalization.js +2 -4
  78. package/dist/docx/rezip.js +74 -18
  79. package/dist/docx/runParser.d.ts +1 -1
  80. package/dist/docx/runParser.js +16 -12
  81. package/dist/docx/sectionParser.js +8 -1
  82. package/dist/docx/selectiveXmlPatch.d.ts +46 -2
  83. package/dist/docx/selectiveXmlPatch.js +86 -39
  84. package/dist/docx/serializer/borderSerializer.js +2 -2
  85. package/dist/docx/serializer/commentSerializer.js +5 -7
  86. package/dist/docx/serializer/documentSerializer.js +8 -11
  87. package/dist/docx/serializer/headerFooterSerializer.js +7 -9
  88. package/dist/docx/serializer/noteSerializer.js +8 -8
  89. package/dist/docx/serializer/paragraphSerializer.js +76 -56
  90. package/dist/docx/serializer/runSerializer.js +25 -16
  91. package/dist/docx/serializer/sectionPropertiesSerializer.js +8 -4
  92. package/dist/docx/serializer/tableSerializer.js +18 -8
  93. package/dist/docx/server/createBilingualDocument.js +3 -1
  94. package/dist/docx/server/materializeYjsDocx.d.ts +1 -1
  95. package/dist/docx/server/materializeYjsDocx.js +9 -1
  96. package/dist/docx/server/migrateYjsAttrSchema.d.ts +55 -0
  97. package/dist/docx/server/migrateYjsAttrSchema.js +95 -0
  98. package/dist/docx/shapeParser.js +5 -5
  99. package/dist/docx/tableParser.d.ts +1 -1
  100. package/dist/docx/tableParser.js +206 -85
  101. package/dist/docx/textBoxParser.d.ts +25 -2
  102. package/dist/docx/textBoxParser.js +52 -2
  103. package/dist/docx/unzip.js +5 -4
  104. package/dist/docx/vmlImageParser.d.ts +17 -1
  105. package/dist/docx/vmlImageParser.js +17 -1
  106. package/dist/docx/xmlEncoding.d.ts +5 -0
  107. package/dist/docx/xmlEncoding.js +12 -0
  108. package/dist/docx/xmlParser.d.ts +10 -1
  109. package/dist/docx/xmlParser.js +14 -1
  110. package/dist/headless-layout.js +10 -1
  111. package/dist/index.d.ts +2 -1
  112. package/dist/index.js +2 -1
  113. package/dist/internal/pageBreakRunSourceDescendantIndex.js +5 -2
  114. package/dist/layout-bridge/convert/toFlowBlocks.js +102 -12
  115. package/dist/layout-engine/measure/tableCellFloating.d.ts +2 -0
  116. package/dist/layout-engine/measure/tableCellFloating.js +2 -0
  117. package/dist/layout-engine/types.d.ts +23 -1
  118. package/dist/layout-painter/renderImage.d.ts +5 -1
  119. package/dist/layout-painter/renderImage.js +10 -3
  120. package/dist/layout-painter/renderPage.d.ts +2 -0
  121. package/dist/layout-painter/renderPage.js +4 -0
  122. package/dist/layout-painter/renderParagraph.d.ts +13 -1
  123. package/dist/layout-painter/renderParagraph.js +22 -3
  124. package/dist/managers/autoSaveCodec.d.ts +9 -1
  125. package/dist/managers/autoSaveCodec.js +12 -4
  126. package/dist/markdown/renderBlock.js +1 -0
  127. package/dist/markdown/renderRuns.d.ts +1 -1
  128. package/dist/markdown/renderRuns.js +28 -5
  129. package/dist/markdown/renderTable.js +22 -5
  130. package/dist/markdown/trailers.js +4 -1
  131. package/dist/pdf/images.js +142 -6
  132. package/dist/prosemirror/attrs/index.d.ts +14 -3
  133. package/dist/prosemirror/attrs/index.js +155 -2
  134. package/dist/prosemirror/authoredTransformAttrs.d.ts +28 -0
  135. package/dist/prosemirror/authoredTransformAttrs.js +64 -0
  136. package/dist/prosemirror/commands/contentControls.js +10 -2
  137. package/dist/prosemirror/commands/image.d.ts +9 -2
  138. package/dist/prosemirror/commands/image.js +42 -28
  139. package/dist/prosemirror/commands/pageBreak.js +1 -1
  140. package/dist/prosemirror/commentReferenceAttrs.d.ts +8 -0
  141. package/dist/prosemirror/commentReferenceAttrs.js +33 -0
  142. package/dist/prosemirror/commentReferenceIntegrity.d.ts +47 -0
  143. package/dist/prosemirror/commentReferenceIntegrity.js +43 -0
  144. package/dist/prosemirror/conversion/fromProseDoc.d.ts +2 -13
  145. package/dist/prosemirror/conversion/fromProseDoc.js +269 -70
  146. package/dist/prosemirror/conversion/index.d.ts +2 -2
  147. package/dist/prosemirror/conversion/toProseDoc.d.ts +7 -9
  148. package/dist/prosemirror/conversion/toProseDoc.js +468 -308
  149. package/dist/prosemirror/extensions/StarterKit.js +8 -58
  150. package/dist/prosemirror/extensions/core/DocExtension.js +1 -1
  151. package/dist/prosemirror/extensions/core/ParagraphExtension.js +2 -1
  152. package/dist/prosemirror/extensions/features/BaseKeymapExtension.js +45 -27
  153. package/dist/prosemirror/extensions/features/EmptyParagraphFormatExtension.js +3 -1
  154. package/dist/prosemirror/extensions/features/ImagePasteExtension.js +5 -3
  155. package/dist/prosemirror/extensions/features/ParaIdAllocatorExtension.js +1 -0
  156. package/dist/prosemirror/extensions/markRegistry.d.ts +41 -0
  157. package/dist/prosemirror/extensions/markRegistry.js +75 -0
  158. package/dist/prosemirror/extensions/marks/InlineWrapperExtension.d.ts +18 -0
  159. package/dist/prosemirror/extensions/marks/InlineWrapperExtension.js +63 -0
  160. package/dist/prosemirror/extensions/marks/markUtils.d.ts +2 -1
  161. package/dist/prosemirror/extensions/marks/markUtils.js +47 -4
  162. package/dist/prosemirror/extensions/nodes/CommentReferenceExtension.d.ts +11 -0
  163. package/dist/prosemirror/extensions/nodes/CommentReferenceExtension.js +87 -0
  164. package/dist/prosemirror/extensions/nodes/FieldExtension.js +9 -7
  165. package/dist/prosemirror/extensions/nodes/ImageExtension.js +16 -0
  166. package/dist/prosemirror/extensions/nodes/PreservedBlockExtension.d.ts +32 -0
  167. package/dist/prosemirror/extensions/nodes/PreservedBlockExtension.js +67 -0
  168. package/dist/prosemirror/extensions/nodes/PreservedXmlExtension.d.ts +16 -0
  169. package/dist/prosemirror/extensions/nodes/PreservedXmlExtension.js +60 -0
  170. package/dist/prosemirror/extensions/nodes/ShapeExtension.js +3 -0
  171. package/dist/prosemirror/extensions/nodes/TableExtension.js +3 -2
  172. package/dist/prosemirror/extensions/nodes/TextBoxExtension.js +5 -1
  173. package/dist/prosemirror/inlineWrapperStack.d.ts +39 -0
  174. package/dist/prosemirror/inlineWrapperStack.js +75 -0
  175. package/dist/prosemirror/pageBreakRunProjection.d.ts +17 -7
  176. package/dist/prosemirror/pageBreakRunProjection.js +19 -9
  177. package/dist/prosemirror/replacedAnnotations.d.ts +59 -0
  178. package/dist/prosemirror/replacedAnnotations.js +165 -0
  179. package/dist/prosemirror/runFormattingInlineCarriers.d.ts +3 -1
  180. package/dist/prosemirror/runFormattingInlineCarriers.js +5 -1
  181. package/dist/prosemirror/schema/index.d.ts +3 -3
  182. package/dist/prosemirror/schema/marks.d.ts +25 -1
  183. package/dist/prosemirror/schema/nodes.d.ts +90 -3
  184. package/dist/prosemirror/schema/nodes.js +16 -1
  185. package/dist/prosemirror/trackedRunInlineAtoms.d.ts +2 -0
  186. package/dist/prosemirror/trackedRunInlineAtoms.js +2 -0
  187. package/dist/prosemirror/validation.js +16 -2
  188. package/dist/prosemirror/yjsDocumentMetadata.d.ts +73 -0
  189. package/dist/prosemirror/yjsDocumentMetadata.js +171 -0
  190. package/dist/prosemirror/zeroWidthAnchors.js +2 -0
  191. package/dist/render-dom/commentAnchorAttributes.d.ts +37 -0
  192. package/dist/render-dom/commentAnchorAttributes.js +54 -0
  193. package/dist/server.d.ts +3 -1
  194. package/dist/server.js +3 -1
  195. package/dist/types/content.d.ts +2 -2
  196. package/dist/utils/clipboard.d.ts +9 -1
  197. package/dist/utils/clipboard.js +27 -1
  198. package/dist/utils/findReplace.js +1 -1
  199. package/dist/utils/imageLuminance.d.ts +15 -0
  200. package/dist/utils/imageLuminance.js +32 -0
  201. package/dist/utils/mergeDocumentContent.js +7 -17
  202. package/dist/utils/replaceText.js +1 -0
  203. package/package.json +2 -2
  204. package/dist/docx/blockRangeMarkers.d.ts +0 -36
  205. package/dist/docx/blockRangeMarkers.js +0 -59
  206. package/dist/prosemirror/yjsParagraphSourceContract.d.ts +0 -9
  207. package/dist/prosemirror/yjsParagraphSourceContract.js +0 -26
package/dist/index.d.ts CHANGED
@@ -38,7 +38,8 @@ import { fromMarkdown } from "./markdown/fromMarkdown.js";
38
38
  import { toMarkdown, toMarkdownResult } from "./markdown/index.js";
39
39
  import { EmbeddedFont, EmbeddedFontParts, buildEmbeddedFontFamilyMap, extractEmbeddedFonts, getEmbeddedFontFaces, scopeEmbeddedFontFamily } from "./fonts/embeddedFonts.js";
40
40
  import { getGoogleFontsEnabled, setEmbeddedFontFamilyMap, setGoogleFontsEnabled } from "./utils/fontResolver.js";
41
+ import { FOLIO_YJS_ATTR_SCHEMA_VERSION, FolioYjsAttrSchemaVersion, FolioYjsAttrSchemaVersionError } from "./prosemirror/yjsDocumentMetadata.js";
41
42
  import { DOCX_CONFORMANCE_CLASSES } from "@stll/docx-core/model";
42
43
  type Document = document_d_exports.Document;
43
44
  type DocxConformanceClass = document_d_exports.DocxConformanceClass;
44
- export { type AIBarStatus, type AIChatMode, type AICitation, type AICitationRange, type AICitationSource, type AIGenerateInput, type AISuggestion, type AISuggestionApplyMode, type AISuggestionPreset, type AISuggestionSeverity, type AISuggestionStatus, type AcceptAutocompleteResult, type AnonymizationMatch, type AnonymizationTerm, type ApplyFolioDocumentOperationsOptions, type ApplyResult, type AutocompleteSuggestionPluginOptions, type AutocompleteSuggestionState, type AutocompleteSuggestionStatus, type AutocompleteTriggerCheck, type AutocompleteTriggerOptions, type AutocompleteTriggerSkipReason, type BlockRect, COMPARE_REVISION_FORMATS, COMPARE_UNSUPPORTED_REASONS, COMPARE_VERIFICATION_CAUSES, COMPARE_VERIFICATION_INVARIANTS, type CompareChange, type CompareChangeLocation, type CompareCompatibility, type CompareContentOptions, CompareDocxApplyError, type CompareDocxError, CompareDocxFinalParagraphMarkError, CompareDocxOperationLimitError, type CompareDocxOptions, CompareDocxParseError, CompareDocxRoundTripError, CompareDocxSerializeError, type CompareFolioRequirement, type CompareResult, type CompareRevisionFormat, type CompareUnsupportedPart, type CompareUnsupportedReason, type CompareVerification, type CompareVerificationCause, type CompareVerificationFailure, type CompareVerificationInvariant, type CreateEmptyDocumentOptions, DEFAULT_AI_SUGGESTION_PRESETS, DEFAULT_AUTOCOMPLETE_DEAD_ZONE_NODES, DOCUMENT_PRESET_VERSION, DOCUMENT_STYLE_SET_VERSION, DOCX_CONFORMANCE_CLASSES, DRAWING_SAFETY_CLASSES, type DeriveBlockIdInput, type DirectiveKind, type DirectiveRange, type Document, type DocumentPreset, type DocumentPropertiesOptions, type DocumentStyleCatalog, type DocumentStyleCatalogEntry, type DocumentStyleSet, type DocxCompatibility, type DocxCompatibilityContext, type DocxCompatibilityIssue, type DocxCompatibilityLocation, type DocxCompatibilityPart, type DocxConformanceClass, type DocxDrawingClassification, type DrawingSafetyClass, type EmbeddedFont, type EmbeddedFontParts, type ExtractDocumentStyleSetOptions, FOLIO_CONTENT_COMPARISON_LIMITS, FOLIO_DOCUMENT_OPERATION_BATCH_MODES, FOLIO_DOCUMENT_OPERATION_CONTRACT_VERSION, FOLIO_DOCUMENT_OPERATION_MODES, FOLIO_DOCUMENT_OPERATION_MODES_BY_TYPE, FOLIO_DOCUMENT_OPERATION_PRECONDITIONS, FOLIO_DOCUMENT_OPERATION_STORIES, FOLIO_DOCUMENT_OPERATION_TYPES, FOLIO_LINE_SPACING_RULE_VALUES, FOLIO_PARAGRAPH_ALIGNMENT_VALUES, type FinalParagraphMarkRevision, type FolioAIBlock, type FolioAIBlockAnchor, type FolioAIBlockKind, type FolioAIBlockPreviewRun, type FolioAIBlockStructuralBoundary, type FolioAIBlockTableLocation, type FolioAIComment, type FolioAIEditAppliedOperation, type FolioAIEditApplyMode, type FolioAIEditApplyOutcome, type FolioAIEditApplyResult, type FolioAIEditNormalization, type FolioAIEditNormalizationCode, type FolioAIEditOperation, type FolioAIEditPrecondition, type FolioAIEditReviewMeta, type FolioAIEditSeverity, type FolioAIEditSkipReason, type FolioAIEditSkippedOperation, type FolioAIEditSnapshot, type FolioAIInlineBooleanProperty, type FolioAIInlineFormatting, type FolioAIInlineFormattingPatch, type FolioAIParagraphSpacing, type FolioAISignatureParty, type FolioBlockId, type FolioContentBlock, type FolioContentBlockProperty, type FolioContentComparison, type FolioContentComparisonError, type FolioContentComparisonEvent, type FolioContentComparisonLimit, FolioContentComparisonLimitError, type FolioContentContainerPathEntry, type FolioContentFormatRange, type FolioContentFormattingChange, type FolioContentIdStability, type FolioContentInlineBooleanProperty, type FolioContentInlineComparisonResult, type FolioContentInlineFormatting, type FolioContentInlineFormattingPatch, FolioContentInlinePresentationProjectionError, type FolioContentLineSpacingRule, type FolioContentParagraphAlignment, type FolioContentParagraphFormattingPatch, type FolioContentParagraphKind, type FolioContentParagraphSpacing, type FolioContentRun, type FolioContentSnapshot, type FolioContentStructuralChange, type FolioContentTableLocation, type FolioContentTextSegment, type FolioDocumentOperation, type FolioDocumentOperationAffectedTarget, type FolioDocumentOperationBatch, type FolioDocumentOperationCapabilities, type FolioDocumentOperationIssue, type FolioDocumentOperationMode, type FolioDocumentOperationPrecondition, type FolioDocumentOperationReceipt, type FolioDocumentOperationRecovery, type FolioDocumentOperationResult, type FolioDocumentOperationResultBase, type FolioDocumentOperationStatus, type FolioDocumentOperationStory, type FolioDocumentOperationType, type FolioDocumentOperationUndoFailureReason, type FolioDocumentOperationUndoHandle, type FolioDocumentOperationUndoResult, type FolioDocxCompatibilityHost, type FolioDocxCompatibilityProfile, type FolioRevisionStamp, type FolioWordDiffOptions, type ImageMeta, type ImageRef, type InspectDocxCompatibilityOptions, InvalidCompareDocxOptionsError, InvalidFolioContentComparisonError, InvalidFolioDocumentOperationBatchError, MAX_COMPARE_OPERATIONS, type MarkdownOptions, type MarkdownResult, type PositionalText, type ResolvedAnchor, STELLA_STYLE_SET_NAME, type TemplatePreviewHiddenRange, type TemplatePreviewSpan, type TemplatePreviewValue, type TemplatePreviewValues, type TemplateSlashMenuKeyAction, type TemplateSlashMenuState, UnsupportedFolioDocumentOperationVersionError, WORD_DIFF_GRANULARITIES, type WordDiffGranularity, type WordDiffNormalization, type WordDiffOptions, type WordDiffSegment, acceptAutocompleteSuggestion, acceptAutocompleteWord, anonymizationDecorationsKey, appendAutocompleteToken, applyFolioAIEditOperations, applyFolioDocumentOperations, applySuggestions, assertSupportedFolioDocumentOperationVersion, autocompleteSuggestionKey, autocompleteSuggestionPlugin, buildEmbeddedFontFamilyMap, buildPositionalText, clearAutocompleteSuggestion, clearTemplateSlashMenu, compareContent, compareDocx, consumeTemplateSlashQuery, createAICitationDecorationsPlugin, createDocx, createEmptyDocument, createFolioAIEditSnapshot, createStellaStyleDocumentPreset, createStellaStyleSet, currentFolioBlockId, deriveBlockId, diffWordSegments, extractDocumentStyleSet, extractDocumentStyleSetFromDocx, extractEmbeddedFonts, finishAutocompleteSuggestion, fromMarkdown, getAnonymizationMatches, getAutocompleteSuggestion, getEmbeddedFontFaces, getFolioCaretViewportRect, getFolioDocumentOperationCapabilities, getFolioDocumentOperationIssues, getFolioDocumentOperationReceipts, getFolioParaIdFromBlockId, getFolioSelectionViewportRect, getGoogleFontsEnabled, getTemplateDirectives, getTemplateSlashMenu, hashFolioAIBlockText, inspectDocumentStyles, inspectDocumentStylesFromDocx, inspectDocxCompatibility, isFolioAIContentBlock, isFolioBlockId, isFolioDocumentOperationModeSupported, isSequentialFolioBlockId, isSuggestionStale, isSupportedFolioDocumentOperationVersion, mergeDocumentContent, normalizeFolioAIBlockText, parseFolioDocumentOperationBatch, resetTemplateSlashQuery, resolveSuggestionAnchor, scanDirectives, scopeEmbeddedFontFamily, scrollFolioPositionIntoView, setAICitationsMeta, setAISuggestionsMeta, setActiveCitationMeta, setAnonymizationTermsMeta, setEmbeddedFontFamilyMap, setFocusedSuggestionMeta, setGoogleFontsEnabled, setTemplatePreviewValues, shouldTriggerAutocomplete, startAutocompleteSuggestion, templateSlashMenuKey, toMarkdown, toMarkdownResult };
45
+ export { type AIBarStatus, type AIChatMode, type AICitation, type AICitationRange, type AICitationSource, type AIGenerateInput, type AISuggestion, type AISuggestionApplyMode, type AISuggestionPreset, type AISuggestionSeverity, type AISuggestionStatus, type AcceptAutocompleteResult, type AnonymizationMatch, type AnonymizationTerm, type ApplyFolioDocumentOperationsOptions, type ApplyResult, type AutocompleteSuggestionPluginOptions, type AutocompleteSuggestionState, type AutocompleteSuggestionStatus, type AutocompleteTriggerCheck, type AutocompleteTriggerOptions, type AutocompleteTriggerSkipReason, type BlockRect, COMPARE_REVISION_FORMATS, COMPARE_UNSUPPORTED_REASONS, COMPARE_VERIFICATION_CAUSES, COMPARE_VERIFICATION_INVARIANTS, type CompareChange, type CompareChangeLocation, type CompareCompatibility, type CompareContentOptions, CompareDocxApplyError, type CompareDocxError, CompareDocxFinalParagraphMarkError, CompareDocxOperationLimitError, type CompareDocxOptions, CompareDocxParseError, CompareDocxRoundTripError, CompareDocxSerializeError, type CompareFolioRequirement, type CompareResult, type CompareRevisionFormat, type CompareUnsupportedPart, type CompareUnsupportedReason, type CompareVerification, type CompareVerificationCause, type CompareVerificationFailure, type CompareVerificationInvariant, type CreateEmptyDocumentOptions, DEFAULT_AI_SUGGESTION_PRESETS, DEFAULT_AUTOCOMPLETE_DEAD_ZONE_NODES, DOCUMENT_PRESET_VERSION, DOCUMENT_STYLE_SET_VERSION, DOCX_CONFORMANCE_CLASSES, DRAWING_SAFETY_CLASSES, type DeriveBlockIdInput, type DirectiveKind, type DirectiveRange, type Document, type DocumentPreset, type DocumentPropertiesOptions, type DocumentStyleCatalog, type DocumentStyleCatalogEntry, type DocumentStyleSet, type DocxCompatibility, type DocxCompatibilityContext, type DocxCompatibilityIssue, type DocxCompatibilityLocation, type DocxCompatibilityPart, type DocxConformanceClass, type DocxDrawingClassification, type DrawingSafetyClass, type EmbeddedFont, type EmbeddedFontParts, type ExtractDocumentStyleSetOptions, FOLIO_CONTENT_COMPARISON_LIMITS, FOLIO_DOCUMENT_OPERATION_BATCH_MODES, FOLIO_DOCUMENT_OPERATION_CONTRACT_VERSION, FOLIO_DOCUMENT_OPERATION_MODES, FOLIO_DOCUMENT_OPERATION_MODES_BY_TYPE, FOLIO_DOCUMENT_OPERATION_PRECONDITIONS, FOLIO_DOCUMENT_OPERATION_STORIES, FOLIO_DOCUMENT_OPERATION_TYPES, FOLIO_LINE_SPACING_RULE_VALUES, FOLIO_PARAGRAPH_ALIGNMENT_VALUES, FOLIO_YJS_ATTR_SCHEMA_VERSION, type FinalParagraphMarkRevision, type FolioAIBlock, type FolioAIBlockAnchor, type FolioAIBlockKind, type FolioAIBlockPreviewRun, type FolioAIBlockStructuralBoundary, type FolioAIBlockTableLocation, type FolioAIComment, type FolioAIEditAppliedOperation, type FolioAIEditApplyMode, type FolioAIEditApplyOutcome, type FolioAIEditApplyResult, type FolioAIEditNormalization, type FolioAIEditNormalizationCode, type FolioAIEditOperation, type FolioAIEditPrecondition, type FolioAIEditReviewMeta, type FolioAIEditSeverity, type FolioAIEditSkipReason, type FolioAIEditSkippedOperation, type FolioAIEditSnapshot, type FolioAIInlineBooleanProperty, type FolioAIInlineFormatting, type FolioAIInlineFormattingPatch, type FolioAIParagraphSpacing, type FolioAISignatureParty, type FolioBlockId, type FolioContentBlock, type FolioContentBlockProperty, type FolioContentComparison, type FolioContentComparisonError, type FolioContentComparisonEvent, type FolioContentComparisonLimit, FolioContentComparisonLimitError, type FolioContentContainerPathEntry, type FolioContentFormatRange, type FolioContentFormattingChange, type FolioContentIdStability, type FolioContentInlineBooleanProperty, type FolioContentInlineComparisonResult, type FolioContentInlineFormatting, type FolioContentInlineFormattingPatch, FolioContentInlinePresentationProjectionError, type FolioContentLineSpacingRule, type FolioContentParagraphAlignment, type FolioContentParagraphFormattingPatch, type FolioContentParagraphKind, type FolioContentParagraphSpacing, type FolioContentRun, type FolioContentSnapshot, type FolioContentStructuralChange, type FolioContentTableLocation, type FolioContentTextSegment, type FolioDocumentOperation, type FolioDocumentOperationAffectedTarget, type FolioDocumentOperationBatch, type FolioDocumentOperationCapabilities, type FolioDocumentOperationIssue, type FolioDocumentOperationMode, type FolioDocumentOperationPrecondition, type FolioDocumentOperationReceipt, type FolioDocumentOperationRecovery, type FolioDocumentOperationResult, type FolioDocumentOperationResultBase, type FolioDocumentOperationStatus, type FolioDocumentOperationStory, type FolioDocumentOperationType, type FolioDocumentOperationUndoFailureReason, type FolioDocumentOperationUndoHandle, type FolioDocumentOperationUndoResult, type FolioDocxCompatibilityHost, type FolioDocxCompatibilityProfile, type FolioRevisionStamp, type FolioWordDiffOptions, type FolioYjsAttrSchemaVersion, FolioYjsAttrSchemaVersionError, type ImageMeta, type ImageRef, type InspectDocxCompatibilityOptions, InvalidCompareDocxOptionsError, InvalidFolioContentComparisonError, InvalidFolioDocumentOperationBatchError, MAX_COMPARE_OPERATIONS, type MarkdownOptions, type MarkdownResult, type PositionalText, type ResolvedAnchor, STELLA_STYLE_SET_NAME, type TemplatePreviewHiddenRange, type TemplatePreviewSpan, type TemplatePreviewValue, type TemplatePreviewValues, type TemplateSlashMenuKeyAction, type TemplateSlashMenuState, UnsupportedFolioDocumentOperationVersionError, WORD_DIFF_GRANULARITIES, type WordDiffGranularity, type WordDiffNormalization, type WordDiffOptions, type WordDiffSegment, acceptAutocompleteSuggestion, acceptAutocompleteWord, anonymizationDecorationsKey, appendAutocompleteToken, applyFolioAIEditOperations, applyFolioDocumentOperations, applySuggestions, assertSupportedFolioDocumentOperationVersion, autocompleteSuggestionKey, autocompleteSuggestionPlugin, buildEmbeddedFontFamilyMap, buildPositionalText, clearAutocompleteSuggestion, clearTemplateSlashMenu, compareContent, compareDocx, consumeTemplateSlashQuery, createAICitationDecorationsPlugin, createDocx, createEmptyDocument, createFolioAIEditSnapshot, createStellaStyleDocumentPreset, createStellaStyleSet, currentFolioBlockId, deriveBlockId, diffWordSegments, extractDocumentStyleSet, extractDocumentStyleSetFromDocx, extractEmbeddedFonts, finishAutocompleteSuggestion, fromMarkdown, getAnonymizationMatches, getAutocompleteSuggestion, getEmbeddedFontFaces, getFolioCaretViewportRect, getFolioDocumentOperationCapabilities, getFolioDocumentOperationIssues, getFolioDocumentOperationReceipts, getFolioParaIdFromBlockId, getFolioSelectionViewportRect, getGoogleFontsEnabled, getTemplateDirectives, getTemplateSlashMenu, hashFolioAIBlockText, inspectDocumentStyles, inspectDocumentStylesFromDocx, inspectDocxCompatibility, isFolioAIContentBlock, isFolioBlockId, isFolioDocumentOperationModeSupported, isSequentialFolioBlockId, isSuggestionStale, isSupportedFolioDocumentOperationVersion, mergeDocumentContent, normalizeFolioAIBlockText, parseFolioDocumentOperationBatch, resetTemplateSlashQuery, resolveSuggestionAnchor, scanDirectives, scopeEmbeddedFontFamily, scrollFolioPositionIntoView, setAICitationsMeta, setAISuggestionsMeta, setActiveCitationMeta, setAnonymizationTermsMeta, setEmbeddedFontFamilyMap, setFocusedSuggestionMeta, setGoogleFontsEnabled, setTemplatePreviewValues, shouldTriggerAutocomplete, startAutocompleteSuggestion, templateSlashMenuKey, toMarkdown, toMarkdownResult };
package/dist/index.js CHANGED
@@ -25,6 +25,7 @@ import { DEFAULT_AUTOCOMPLETE_DEAD_ZONE_NODES, acceptAutocompleteSuggestion, acc
25
25
  import { getTemplateDirectives, scanDirectives } from "./prosemirror/plugins/templateDirectives.js";
26
26
  import { setTemplatePreviewValues } from "./prosemirror/plugins/templatePreviewValues.js";
27
27
  import { clearTemplateSlashMenu, consumeTemplateSlashQuery, getTemplateSlashMenu, resetTemplateSlashQuery, templateSlashMenuKey } from "./prosemirror/plugins/templateSlashMenu.js";
28
+ import { FOLIO_YJS_ATTR_SCHEMA_VERSION, FolioYjsAttrSchemaVersionError } from "./prosemirror/yjsDocumentMetadata.js";
28
29
  import { extractDocumentStyleSet, extractDocumentStyleSetFromDocx, inspectDocumentStyles, inspectDocumentStylesFromDocx } from "./style-sets/extract.js";
29
30
  import { STELLA_STYLE_SET_NAME, createStellaStyleDocumentPreset, createStellaStyleSet } from "./style-sets/stellaStyle.js";
30
31
  import { DOCUMENT_PRESET_VERSION, DOCUMENT_STYLE_SET_VERSION } from "./style-sets/types.js";
@@ -33,4 +34,4 @@ import { createEmptyDocument } from "./utils/createDocument.js";
33
34
  import { getGoogleFontsEnabled, setEmbeddedFontFamilyMap, setGoogleFontsEnabled } from "./utils/fontResolver.js";
34
35
  import { mergeDocumentContent } from "./utils/mergeDocumentContent.js";
35
36
  import { DOCX_CONFORMANCE_CLASSES } from "@stll/docx-core/model";
36
- export { COMPARE_REVISION_FORMATS, COMPARE_UNSUPPORTED_REASONS, COMPARE_VERIFICATION_CAUSES, COMPARE_VERIFICATION_INVARIANTS, CompareDocxApplyError, CompareDocxFinalParagraphMarkError, CompareDocxOperationLimitError, CompareDocxParseError, CompareDocxRoundTripError, CompareDocxSerializeError, DEFAULT_AI_SUGGESTION_PRESETS, DEFAULT_AUTOCOMPLETE_DEAD_ZONE_NODES, DOCUMENT_PRESET_VERSION, DOCUMENT_STYLE_SET_VERSION, DOCX_CONFORMANCE_CLASSES, DRAWING_SAFETY_CLASSES, FOLIO_CONTENT_COMPARISON_LIMITS, FOLIO_DOCUMENT_OPERATION_BATCH_MODES, FOLIO_DOCUMENT_OPERATION_CONTRACT_VERSION, FOLIO_DOCUMENT_OPERATION_MODES, FOLIO_DOCUMENT_OPERATION_MODES_BY_TYPE, FOLIO_DOCUMENT_OPERATION_PRECONDITIONS, FOLIO_DOCUMENT_OPERATION_STORIES, FOLIO_DOCUMENT_OPERATION_TYPES, FOLIO_LINE_SPACING_RULE_VALUES, FOLIO_PARAGRAPH_ALIGNMENT_VALUES, FolioContentComparisonLimitError, FolioContentInlinePresentationProjectionError, InvalidCompareDocxOptionsError, InvalidFolioContentComparisonError, InvalidFolioDocumentOperationBatchError, MAX_COMPARE_OPERATIONS, STELLA_STYLE_SET_NAME, UnsupportedFolioDocumentOperationVersionError, WORD_DIFF_GRANULARITIES, acceptAutocompleteSuggestion, acceptAutocompleteWord, anonymizationDecorationsKey, appendAutocompleteToken, applyFolioAIEditOperations, applyFolioDocumentOperations, applySuggestions, assertSupportedFolioDocumentOperationVersion, autocompleteSuggestionKey, autocompleteSuggestionPlugin, buildEmbeddedFontFamilyMap, buildPositionalText, clearAutocompleteSuggestion, clearTemplateSlashMenu, compareContent, compareDocx, consumeTemplateSlashQuery, createAICitationDecorationsPlugin, createDocx, createEmptyDocument, createFolioAIEditSnapshot, createStellaStyleDocumentPreset, createStellaStyleSet, currentFolioBlockId, deriveBlockId, diffWordSegments, extractDocumentStyleSet, extractDocumentStyleSetFromDocx, extractEmbeddedFonts, finishAutocompleteSuggestion, fromMarkdown, getAnonymizationMatches, getAutocompleteSuggestion, getEmbeddedFontFaces, getFolioCaretViewportRect, getFolioDocumentOperationCapabilities, getFolioDocumentOperationIssues, getFolioDocumentOperationReceipts, getFolioParaIdFromBlockId, getFolioSelectionViewportRect, getGoogleFontsEnabled, getTemplateDirectives, getTemplateSlashMenu, hashFolioAIBlockText, inspectDocumentStyles, inspectDocumentStylesFromDocx, inspectDocxCompatibility, isFolioAIContentBlock, isFolioBlockId, isFolioDocumentOperationModeSupported, isSequentialFolioBlockId, isSuggestionStale, isSupportedFolioDocumentOperationVersion, mergeDocumentContent, normalizeFolioAIBlockText, parseFolioDocumentOperationBatch, resetTemplateSlashQuery, resolveSuggestionAnchor, scanDirectives, scopeEmbeddedFontFamily, scrollFolioPositionIntoView, setAICitationsMeta, setAISuggestionsMeta, setActiveCitationMeta, setAnonymizationTermsMeta, setEmbeddedFontFamilyMap, setFocusedSuggestionMeta, setGoogleFontsEnabled, setTemplatePreviewValues, shouldTriggerAutocomplete, startAutocompleteSuggestion, templateSlashMenuKey, toMarkdown, toMarkdownResult };
37
+ export { COMPARE_REVISION_FORMATS, COMPARE_UNSUPPORTED_REASONS, COMPARE_VERIFICATION_CAUSES, COMPARE_VERIFICATION_INVARIANTS, CompareDocxApplyError, CompareDocxFinalParagraphMarkError, CompareDocxOperationLimitError, CompareDocxParseError, CompareDocxRoundTripError, CompareDocxSerializeError, DEFAULT_AI_SUGGESTION_PRESETS, DEFAULT_AUTOCOMPLETE_DEAD_ZONE_NODES, DOCUMENT_PRESET_VERSION, DOCUMENT_STYLE_SET_VERSION, DOCX_CONFORMANCE_CLASSES, DRAWING_SAFETY_CLASSES, FOLIO_CONTENT_COMPARISON_LIMITS, FOLIO_DOCUMENT_OPERATION_BATCH_MODES, FOLIO_DOCUMENT_OPERATION_CONTRACT_VERSION, FOLIO_DOCUMENT_OPERATION_MODES, FOLIO_DOCUMENT_OPERATION_MODES_BY_TYPE, FOLIO_DOCUMENT_OPERATION_PRECONDITIONS, FOLIO_DOCUMENT_OPERATION_STORIES, FOLIO_DOCUMENT_OPERATION_TYPES, FOLIO_LINE_SPACING_RULE_VALUES, FOLIO_PARAGRAPH_ALIGNMENT_VALUES, FOLIO_YJS_ATTR_SCHEMA_VERSION, FolioContentComparisonLimitError, FolioContentInlinePresentationProjectionError, FolioYjsAttrSchemaVersionError, InvalidCompareDocxOptionsError, InvalidFolioContentComparisonError, InvalidFolioDocumentOperationBatchError, MAX_COMPARE_OPERATIONS, STELLA_STYLE_SET_NAME, UnsupportedFolioDocumentOperationVersionError, WORD_DIFF_GRANULARITIES, acceptAutocompleteSuggestion, acceptAutocompleteWord, anonymizationDecorationsKey, appendAutocompleteToken, applyFolioAIEditOperations, applyFolioDocumentOperations, applySuggestions, assertSupportedFolioDocumentOperationVersion, autocompleteSuggestionKey, autocompleteSuggestionPlugin, buildEmbeddedFontFamilyMap, buildPositionalText, clearAutocompleteSuggestion, clearTemplateSlashMenu, compareContent, compareDocx, consumeTemplateSlashQuery, createAICitationDecorationsPlugin, createDocx, createEmptyDocument, createFolioAIEditSnapshot, createStellaStyleDocumentPreset, createStellaStyleSet, currentFolioBlockId, deriveBlockId, diffWordSegments, extractDocumentStyleSet, extractDocumentStyleSetFromDocx, extractEmbeddedFonts, finishAutocompleteSuggestion, fromMarkdown, getAnonymizationMatches, getAutocompleteSuggestion, getEmbeddedFontFaces, getFolioCaretViewportRect, getFolioDocumentOperationCapabilities, getFolioDocumentOperationIssues, getFolioDocumentOperationReceipts, getFolioParaIdFromBlockId, getFolioSelectionViewportRect, getGoogleFontsEnabled, getTemplateDirectives, getTemplateSlashMenu, hashFolioAIBlockText, inspectDocumentStyles, inspectDocumentStylesFromDocx, inspectDocxCompatibility, isFolioAIContentBlock, isFolioBlockId, isFolioDocumentOperationModeSupported, isSequentialFolioBlockId, isSuggestionStale, isSupportedFolioDocumentOperationVersion, mergeDocumentContent, normalizeFolioAIBlockText, parseFolioDocumentOperationBatch, resetTemplateSlashQuery, resolveSuggestionAnchor, scanDirectives, scopeEmbeddedFontFamily, scrollFolioPositionIntoView, setAICitationsMeta, setAISuggestionsMeta, setActiveCitationMeta, setAnonymizationTermsMeta, setEmbeddedFontFamilyMap, setFocusedSuggestionMeta, setGoogleFontsEnabled, setTemplatePreviewValues, shouldTriggerAutocomplete, startAutocompleteSuggestion, templateSlashMenuKey, toMarkdown, toMarkdownResult };
@@ -37,6 +37,7 @@ const buildPageBreakRunSourceDescendantIndex = (rootContent) => {
37
37
  case "footnoteRef":
38
38
  case "instrText":
39
39
  case "noBreakHyphen":
40
+ case "preservedXml":
40
41
  case "renderedPageBreak":
41
42
  case "softHyphen":
42
43
  case "symbol":
@@ -60,7 +61,7 @@ const buildPageBreakRunSourceDescendantIndex = (rootContent) => {
60
61
  case "moveFrom":
61
62
  case "moveTo":
62
63
  case "inlineSdt":
63
- case "bidiWrapper": return inspectMany(content.content, inspectParagraphContent);
64
+ case "inlineWrapper": return inspectMany(content.content, inspectParagraphContent);
64
65
  case "simpleField": {
65
66
  const fieldResultFlags = inspectMany(content.content, inspectParagraphContent);
66
67
  if (hasFlag(fieldResultFlags, SOURCE_FLAGS.paragraphPageBreak) && hasFlag(fieldResultFlags, SOURCE_FLAGS.paragraphTextBoxShape)) return fieldResultFlags | SOURCE_FLAGS.pageBreakSharesTextBoxShape;
@@ -82,7 +83,8 @@ const buildPageBreakRunSourceDescendantIndex = (rootContent) => {
82
83
  case "moveFromRangeEnd":
83
84
  case "moveToRangeStart":
84
85
  case "moveToRangeEnd":
85
- case "mathEquation": return 0;
86
+ case "mathEquation":
87
+ case "preservedInline": return 0;
86
88
  default: return content;
87
89
  }
88
90
  });
@@ -94,6 +96,7 @@ const buildPageBreakRunSourceDescendantIndex = (rootContent) => {
94
96
  case "paragraph": return inspectMany(block.content, inspectParagraphContent);
95
97
  case "table": return inspectMany(block.rows, inspectTableRow);
96
98
  case "blockSdt": return inspectBlocks(block.content);
99
+ case "preservedBlock": return 0;
97
100
  default: return block;
98
101
  }
99
102
  });
@@ -8,12 +8,11 @@ import { setParagraphFrame } from "../../layout-engine/paragraphFrame.js";
8
8
  import { setTextBoxGroupId } from "../../layout-engine/textBoxGroup.js";
9
9
  import { DEFAULT_TEXTBOX_MARGINS } from "../../layout-engine/types.js";
10
10
  import { getPageNumbering } from "../../paged-layout/sectionGeometry.js";
11
- import { expectBlockSdtAttrs, expectCharacterSpacingMarkAttrs, expectCharacterStyleMarkAttrs, expectCommentMarkAttrs, expectEmphasisMarkAttrs, expectFieldAttrs, expectFontFamilyMarkAttrs, expectFontSizeMarkAttrs, expectFootnoteRefMarkAttrs, expectHardBreakAttrs, expectHighlightMarkAttrs, expectHyperlinkMarkAttrs, expectImageAttrs, expectLanguageMarkAttrs, expectMathAttrs, expectParagraphAttrs, expectRunFormattingOverrideMarkAttrs, expectRunShadingMarkAttrs, expectSymbolAttrs, expectTableAttrs, expectTableCellAttrs, expectTableRowAttrs, expectTextBoxAttrs, expectTextColorMarkAttrs, expectTextEffectMarkAttrs, expectTrackedChangeMarkAttrs, expectUnderlineMarkAttrs } from "../../prosemirror/attrs/index.js";
11
+ import { expectBlockSdtAttrs, expectCharacterSpacingMarkAttrs, expectCharacterStyleMarkAttrs, expectCommentMarkAttrs, expectEmphasisMarkAttrs, expectFieldAttrs, expectFontFamilyMarkAttrs, expectFontSizeMarkAttrs, expectFootnoteRefMarkAttrs, expectHardBreakAttrs, expectHighlightMarkAttrs, expectHyperlinkMarkAttrs, expectImageAttrs, expectInlineWrapperMarkAttrs, expectLanguageMarkAttrs, expectMathAttrs, expectParagraphAttrs, expectPreservedXmlAttrs, expectRunFormattingOverrideMarkAttrs, expectRunShadingMarkAttrs, expectSymbolAttrs, expectTableAttrs, expectTableCellAttrs, expectTableRowAttrs, expectTextBoxAttrs, expectTextColorMarkAttrs, expectTextEffectMarkAttrs, expectTrackedChangeMarkAttrs, expectUnderlineMarkAttrs } from "../../prosemirror/attrs/index.js";
12
12
  import { autospacingMatchesBase } from "../../prosemirror/autospacingBase.js";
13
13
  import { runShadingAttrsToShading } from "../../prosemirror/conversion/runShadingMark.js";
14
14
  import { advanceListMarker, advanceVisibleListMarker, cloneListCounterState, formatCounter, resolveListTemplate } from "../../prosemirror/listMarker.js";
15
15
  import { resolveNumberedRefFields } from "../../prosemirror/numberedRefFields.js";
16
- import { pageBreakRunParagraphProjectionDisposition } from "../../prosemirror/pageBreakRunProjection.js";
17
16
  import { directionToBidi } from "../../prosemirror/paragraphDirection.js";
18
17
  import { resolveEffectiveRunStyleFormatting } from "../../prosemirror/runStyleFormatting.js";
19
18
  import { expectTextBoxAnchorAttrs } from "../../prosemirror/textBoxAnchorAttrs.js";
@@ -102,6 +101,74 @@ function resetBlockIdCounter() {
102
101
  blockIdCounter = 0;
103
102
  }
104
103
  /**
104
+ * What the painter does with each mark the schema declares.
105
+ *
106
+ * The switch below used to end in `default: break`, so a mark that reached it
107
+ * was silently not painted whether that was the decision or an omission. The
108
+ * table is total over {@link SchemaMarkName}: a mark added to the schema
109
+ * without a paint decision does not compile, and a mark this table says is
110
+ * painted but the switch does not handle panics rather than disappearing.
111
+ */
112
+ const MARK_PAINT_DISPOSITIONS = {
113
+ bold: "runFormatting",
114
+ italic: "runFormatting",
115
+ underline: "runFormatting",
116
+ strike: "runFormatting",
117
+ textColor: "runFormatting",
118
+ runShading: "runFormatting",
119
+ highlight: "runFormatting",
120
+ fontSize: "runFormatting",
121
+ fontFamily: "runFormatting",
122
+ language: "runFormatting",
123
+ superscript: "runFormatting",
124
+ subscript: "runFormatting",
125
+ hyperlink: "runFormatting",
126
+ allCaps: "runFormatting",
127
+ smallCaps: "runFormatting",
128
+ footnoteRef: "runFormatting",
129
+ characterSpacing: "runFormatting",
130
+ emboss: "runFormatting",
131
+ imprint: "runFormatting",
132
+ hidden: "runFormatting",
133
+ textShadow: "runFormatting",
134
+ emphasisMark: "runFormatting",
135
+ textOutline: "runFormatting",
136
+ rtl: "runFormatting",
137
+ textEffect: "runFormatting",
138
+ runFormattingOverride: "runFormatting",
139
+ comment: "runFormatting",
140
+ insertion: "runFormatting",
141
+ deletion: "runFormatting",
142
+ inlineWrapper: "runFormatting",
143
+ characterStyle: "resolvedElsewhere",
144
+ pageBreakRunOwner: "notPainted",
145
+ runPropertyChange: "notPainted"
146
+ };
147
+ const markPaintDisposition = (name) => {
148
+ return MARK_PAINT_DISPOSITIONS[name];
149
+ };
150
+ /**
151
+ * The direction one bidirectional wrapper lays its content out in, as the
152
+ * innermost layer of a stack states it.
153
+ *
154
+ * Only the innermost is read: a wrapper inside another is the one whose
155
+ * direction the text is laid out in, and the outer layers are what the save
156
+ * leg rebuilds the nesting from.
157
+ */
158
+ const innermostBidiWrapper = (stack) => {
159
+ const layer = stack.at(-1);
160
+ if (layer === void 0) return;
161
+ switch (layer.kind) {
162
+ case "bidi": return layer.direction === void 0 ? { control: layer.control } : {
163
+ control: layer.control,
164
+ direction: layer.direction
165
+ };
166
+ default:
167
+ layer.kind;
168
+ return;
169
+ }
170
+ };
171
+ /**
105
172
  * Extract run formatting from ProseMirror marks.
106
173
  */
107
174
  function extractRunFormatting(marks, theme, fontAlternates) {
@@ -282,7 +349,14 @@ function extractRunFormatting(marks, theme, fontAlternates) {
282
349
  }
283
350
  break;
284
351
  }
285
- default: break;
352
+ case "inlineWrapper": {
353
+ const bidiWrapper = innermostBidiWrapper(expectInlineWrapperMarkAttrs(mark).stack);
354
+ if (bidiWrapper) formatting.bidiWrapper = bidiWrapper;
355
+ break;
356
+ }
357
+ default:
358
+ if (markPaintDisposition(mark.type.name) === "runFormatting") panic(`Mark ${mark.type.name} is painted as run formatting but has no branch here`);
359
+ break;
286
360
  }
287
361
  if (runFormattingOverride) applyRunFormattingOverrides(formatting, runFormattingOverride);
288
362
  if (hasNoteRef && formatting.subscript) delete formatting.superscript;
@@ -530,6 +604,8 @@ function buildImageRun(attrs, constrained, pmStart, pmEnd, trackedChange) {
530
604
  if (attrs.alt !== void 0) run.alt = attrs.alt;
531
605
  if (attrs.transform !== void 0) run.transform = attrs.transform;
532
606
  if (attrs.opacity != null) run.opacity = attrs.opacity;
607
+ if (attrs.brightness != null) run.brightness = attrs.brightness;
608
+ if (attrs.contrast != null) run.contrast = attrs.contrast;
533
609
  if (attrs.wrapType !== void 0) run.wrapType = attrs.wrapType;
534
610
  if (attrs.displayMode !== void 0) run.displayMode = attrs.displayMode;
535
611
  if (attrs.cssFloat !== void 0) run.cssFloat = attrs.cssFloat;
@@ -684,6 +760,25 @@ function paragraphToRuns(node, startPos, _options, pageBreaks) {
684
760
  });
685
761
  return;
686
762
  }
763
+ if (child.type.name === "preservedXml") {
764
+ const { text } = expectPreservedXmlAttrs(child);
765
+ if (text === "") return;
766
+ const formatting = extractRunFormatting(effectiveMarks, theme, fontAlternates);
767
+ applyCharacterStyleToggleFormatting({
768
+ formatting,
769
+ marks: effectiveMarks,
770
+ paragraphFormatting: pmAttrs.defaultTextFormatting,
771
+ styleResolver: _options.styleResolver
772
+ });
773
+ runs.push({
774
+ kind: "text",
775
+ text,
776
+ ...mergeRunFormatting(paraDefaults, formatting),
777
+ pmStart: childPos,
778
+ pmEnd: childPos + child.nodeSize
779
+ });
780
+ return;
781
+ }
687
782
  if (child.type.name === "hardBreak") {
688
783
  runs.push({
689
784
  kind: "lineBreak",
@@ -1357,8 +1452,7 @@ function convertTableCell(node, startPos, options, tableCellMargins) {
1357
1452
  const blocks = [];
1358
1453
  let offset = startPos + 1;
1359
1454
  const authoredPageBreakPosition = options.firstPageBreakRunPosition(node);
1360
- const leadingParagraph = node.firstChild?.type.name === "paragraph" ? node.firstChild : void 0;
1361
- if (authoredPageBreakPosition !== void 0 && (leadingParagraph === void 0 || countPageBreakRuns(node) !== 1 || options.firstPageBreakRunPosition(leadingParagraph) !== authoredPageBreakPosition)) panic(`An explicit page-break run at ${String(authoredPageBreakPosition)} cannot be projected inside a table cell`);
1455
+ const leadingParagraph = node.firstChild?.type.name === "paragraph" && countPageBreakRuns(node) === 1 && options.firstPageBreakRunPosition(node.firstChild) === authoredPageBreakPosition ? node.firstChild : void 0;
1362
1456
  const pageBreaks = [];
1363
1457
  node.forEach((child) => {
1364
1458
  if (child.type.name === "paragraph") {
@@ -1406,7 +1500,7 @@ function convertTableCell(node, startPos, options, tableCellMargins) {
1406
1500
  if (attrs.noWrap) cell.noWrap = true;
1407
1501
  if (authoredPageBreakPosition === void 0 || pageBreaks.length === 0) return { cell };
1408
1502
  const paragraph = blocks.at(0);
1409
- if (paragraph?.kind !== "paragraph" || !hasSingleLeadingProjectedPageBreak(paragraph.runs, pageBreaks)) panic(`An explicit page-break run at ${String(authoredPageBreakPosition)} cannot be projected inside a table cell`);
1503
+ if (paragraph?.kind !== "paragraph" || !hasSingleLeadingProjectedPageBreak(paragraph.runs, pageBreaks)) return { cell };
1410
1504
  return {
1411
1505
  cell,
1412
1506
  breakBefore: "page"
@@ -1523,6 +1617,8 @@ function convertImage(node, startPos, pageContentHeight) {
1523
1617
  if (attrs.alt) imgBlock.alt = attrs.alt;
1524
1618
  if (attrs.transform) imgBlock.transform = attrs.transform;
1525
1619
  if (attrs.opacity != null) imgBlock.opacity = attrs.opacity;
1620
+ if (attrs.brightness != null) imgBlock.brightness = attrs.brightness;
1621
+ if (attrs.contrast != null) imgBlock.contrast = attrs.contrast;
1526
1622
  if (shouldAnchor) {
1527
1623
  const anchor = {
1528
1624
  isAnchored: true,
@@ -1544,8 +1640,6 @@ function convertImage(node, startPos, pageContentHeight) {
1544
1640
  }
1545
1641
  /** Convert a textBox PM node to a TextBoxBlock. */
1546
1642
  function convertTextBoxNode(node, startPos, opts) {
1547
- const pageBreakPosition = opts.firstPageBreakRunPosition(node);
1548
- if (pageBreakPosition !== void 0) panic(`An explicit page-break run at ${String(pageBreakPosition)} cannot be projected inside a text box`);
1549
1643
  const attrs = expectTextBoxAttrs(node);
1550
1644
  const contentBlocks = [];
1551
1645
  node.forEach((child, offset) => {
@@ -1746,10 +1840,6 @@ function toFlowBlocks(doc, options = {}) {
1746
1840
  const pushParagraphProjection = (node, pos, stripLeadingLineBreak = false) => {
1747
1841
  const pageBreaks = [];
1748
1842
  const paragraph = convertParagraph(node, pos, opts, pageBreaks);
1749
- if (pageBreaks.length > 0) {
1750
- const disposition = pageBreakRunParagraphProjectionDisposition(node);
1751
- if (disposition.status === "unsupported" && (disposition.reason === "textBoxAnchor" || !hasSingleLeadingProjectedPageBreak(paragraph.runs, pageBreaks))) panic(disposition.message);
1752
- }
1753
1843
  if (stripLeadingLineBreak && paragraph.runs.at(0)?.kind === "lineBreak") paragraph.runs.shift();
1754
1844
  for (const block of splitParagraphAtPageBreaks({
1755
1845
  pageBreaks,
@@ -8,6 +8,8 @@ type TableCellFloatingImage = {
8
8
  alt?: string;
9
9
  transform?: string;
10
10
  opacity?: number;
11
+ brightness?: number;
12
+ contrast?: number;
11
13
  cropTop?: number;
12
14
  cropRight?: number;
13
15
  cropBottom?: number;
@@ -68,6 +68,8 @@ function getTableCellFloatingImages(cell, cellMeasure, contentWidth, resolvePosi
68
68
  ...run.alt !== void 0 ? { alt: run.alt } : {},
69
69
  ...run.transform !== void 0 ? { transform: run.transform } : {},
70
70
  ...run.opacity != null ? { opacity: run.opacity } : {},
71
+ ...run.brightness != null ? { brightness: run.brightness } : {},
72
+ ...run.contrast != null ? { contrast: run.contrast } : {},
71
73
  ...run.cropTop != null ? { cropTop: run.cropTop } : {},
72
74
  ...run.cropRight != null ? { cropRight: run.cropRight } : {},
73
75
  ...run.cropBottom != null ? { cropBottom: run.cropBottom } : {},
@@ -1,5 +1,5 @@
1
1
  import { OutlineStyleAttr } from "../types/documentEnumValues.js";
2
- import { ImagePosition, ImageWrap, NumberFormat, SdtProperties, SdtType, ShapeTextBody, TableCellFormatting, TableWidthType, VerticalAlign } from "@stll/docx-core/model";
2
+ import { ImagePosition, ImageWrap, InlineWrapper, NumberFormat, SdtProperties, SdtType, ShapeTextBody, TableCellFormatting, TableWidthType, VerticalAlign } from "@stll/docx-core/model";
3
3
  declare namespace types_d_exports {
4
4
  export { BlockId, BorderStyle, CellBorderSpec, CellBorders, ColumnBreakBlock, ColumnBreakMeasure, ColumnLayout, DEFAULT_TEXTBOX_MARGINS, DEFAULT_TEXTBOX_WIDTH, DocumentPosition, FOOTNOTE_ENTRY_MARGIN_BOTTOM, FOOTNOTE_FALLBACK_LINE_HEIGHT, FOOTNOTE_SEPARATOR_HEIGHT, FieldRun, FloatingTablePosition, FlowBlock, FootnoteContent, Fragment, FragmentBase, HeaderFooterContent, HeaderFooterContentHeights, HeaderFooterLayout, HitTestResult, HyperlinkInfo, ImageBlock, ImageFragment, ImageMeasure, ImageRun, ImageRunPosition, Layout, LayoutOptions, LineBreakRun, ListMarkerFormatting, ListNumPr, MathRun, Measure, MeasuredLine, Page, PageBreakBlock, PageBreakMeasure, PageHeaderFooterRefs, PageMargins, ParagraphAttrs, ParagraphBlock, ParagraphBorders, ParagraphFragment, ParagraphIndent, ParagraphMeasure, ParagraphSpacing, RenderedPageBreakRun, Run, RunFormatting, SdtGroup, SectionBreakBlock, SectionBreakMeasure, SectionPageNumbering, TabAlignment, TabRun, TabStop, TableBlock, TableCell, TableCellMeasure, TableFragment, TableMeasure, TableRow, TableRowMeasure, TextBoxBlock, TextBoxFlowAttrs, TextBoxFragment, TextBoxMeasure, TextRun, floatingTextBoxReservesBand, floatingTextBoxWrapsText, getTableRowLeadingWidth, isFloatingImageRun, isFloatingTextBoxBlock, isTextWrappingFloatingImageRun, resolveTableCellPadding, resolveTableWidthPx, tableColumnsArePinned };
5
5
  }
@@ -99,6 +99,20 @@ type RunFormatting = {
99
99
  * RTL; the painter sets `dir="ltr"` so style/paragraph RTL does not leak in.
100
100
  */
101
101
  rtl?: boolean;
102
+ /**
103
+ * The bidirectional wrapper (`w:bdo` / `w:dir`) the run was authored inside,
104
+ * when it was inside one. An override switches the bidirectional algorithm
105
+ * off for its content, which is what makes a Latin word inside an `rtl`
106
+ * override read backwards; an embedding opens a level and leaves the
107
+ * algorithm on. `direction` is the wrapper's own `w:val`, absent when the
108
+ * wrapper states none.
109
+ *
110
+ * Distinct from `rtl`, which is the run's own `w:rtl` property: the wrapper
111
+ * is a container the author wrote around the run, not a property of it.
112
+ */
113
+ bidiWrapper?: Omit<Extract<InlineWrapper, {
114
+ kind: "bidi";
115
+ }>, "type" | "kind" | "content">;
102
116
  /**
103
117
  * Text effect animation hint (w:effect). Word 2013+ no longer animates,
104
118
  * but the painter emits `docx-text-effect-<name>` plus `data-effect` so
@@ -212,6 +226,10 @@ type ImageRun = {
212
226
  * eigenpal #424 (opacity render pipeline).
213
227
  */
214
228
  opacity?: number;
229
+ /** DrawingML picture brightness as a signed percentage. */
230
+ brightness?: number;
231
+ /** DrawingML picture contrast as a signed percentage. */
232
+ contrast?: number;
215
233
  /** Position for floating/anchored images */
216
234
  position?: ImageRunPosition;
217
235
  /** Whether a table-cell anchor uses the cell as its positioning scope. Undefined defaults true. */
@@ -681,6 +699,10 @@ type ImageBlock = {
681
699
  * eigenpal #424 (opacity render pipeline).
682
700
  */
683
701
  opacity?: number;
702
+ /** DrawingML picture brightness as a signed percentage. */
703
+ brightness?: number;
704
+ /** DrawingML picture contrast as a signed percentage. */
705
+ contrast?: number;
684
706
  anchor?: {
685
707
  isAnchored?: boolean;
686
708
  offsetH?: number;
@@ -15,6 +15,8 @@ declare const IMAGE_CLASS_NAMES: {
15
15
  */
16
16
  type ImageVisualAttrs = {
17
17
  opacity?: number;
18
+ brightness?: number;
19
+ contrast?: number;
18
20
  cropTop?: number;
19
21
  cropRight?: number;
20
22
  cropBottom?: number;
@@ -43,6 +45,8 @@ declare function applyImageBorder(element: HTMLElement, border: ImageBorderAttrs
43
45
  */
44
46
  declare function hasImageVisualAttrs(v: ImageVisualAttrs): boolean;
45
47
  declare function hasImageCrop(v: ImageVisualAttrs): boolean;
48
+ /** Apply non-geometric opacity and luminance effects to an image element. */
49
+ declare function applyImageColorAttrs(img: HTMLImageElement, v: ImageVisualAttrs): void;
46
50
  /**
47
51
  * Apply an OOXML `<a:srcRect>` crop to an `<img>` whose parent already has
48
52
  * `overflow: hidden` and is sized to the *visible* (cropped) dimensions
@@ -96,4 +100,4 @@ type RenderImageFragmentOptions = {
96
100
  */
97
101
  declare function renderImageFragment(fragment: ImageFragment, block: ImageBlock, _measure: ImageMeasure, _context: RenderContext, options?: RenderImageFragmentOptions): HTMLElement;
98
102
  //#endregion
99
- export { IMAGE_CLASS_NAMES, ImageBorderAttrs, ImageVisualAttrs, RenderImageFragmentOptions, applyImageBorder, applyImageVisualAttrs, hasImageCrop, hasImageVisualAttrs, renderImageFragment, wrapImageWithCrop };
103
+ export { IMAGE_CLASS_NAMES, ImageBorderAttrs, ImageVisualAttrs, RenderImageFragmentOptions, applyImageBorder, applyImageColorAttrs, applyImageVisualAttrs, hasImageCrop, hasImageVisualAttrs, renderImageFragment, wrapImageWithCrop };
@@ -1,3 +1,4 @@
1
+ import { imageLuminanceFilter } from "../utils/imageLuminance.js";
1
2
  import { applySanitizedImageSrc } from "../utils/sanitizeImageSrc.js";
2
3
  import { anchorTargetAttrs, sanitizeExternalUrl } from "../utils/urlSecurity.js";
3
4
  //#region src/layout-painter/renderImage.ts
@@ -32,11 +33,17 @@ function applyImageBorder(element, border) {
32
33
  */
33
34
  function hasImageVisualAttrs(v) {
34
35
  if (v.opacity != null && v.opacity < 1) return true;
35
- return hasImageCrop(v);
36
+ return imageLuminanceFilter(v) !== void 0 || hasImageCrop(v);
36
37
  }
37
38
  function hasImageCrop(v) {
38
39
  return Boolean(v.cropTop || v.cropRight || v.cropBottom || v.cropLeft);
39
40
  }
41
+ /** Apply non-geometric opacity and luminance effects to an image element. */
42
+ function applyImageColorAttrs(img, v) {
43
+ if (v.opacity != null && v.opacity < 1) img.style.opacity = String(Math.max(0, v.opacity));
44
+ const filter = imageLuminanceFilter(v);
45
+ if (filter !== void 0) img.style.filter = filter;
46
+ }
40
47
  /**
41
48
  * Apply an OOXML `<a:srcRect>` crop to an `<img>` whose parent already has
42
49
  * `overflow: hidden` and is sized to the *visible* (cropped) dimensions
@@ -58,7 +65,7 @@ function hasImageCrop(v) {
58
65
  * call for plain images.
59
66
  */
60
67
  function applyImageVisualAttrs(img, v) {
61
- if (v.opacity != null && v.opacity < 1) img.style.opacity = String(Math.max(0, v.opacity));
68
+ applyImageColorAttrs(img, v);
62
69
  const top = v.cropTop ?? 0;
63
70
  const right = v.cropRight ?? 0;
64
71
  const bottom = v.cropBottom ?? 0;
@@ -159,4 +166,4 @@ function renderImageFragment(fragment, block, _measure, _context, options = {})
159
166
  return containerEl;
160
167
  }
161
168
  //#endregion
162
- export { IMAGE_CLASS_NAMES, applyImageBorder, applyImageVisualAttrs, hasImageCrop, hasImageVisualAttrs, renderImageFragment, wrapImageWithCrop };
169
+ export { IMAGE_CLASS_NAMES, applyImageBorder, applyImageColorAttrs, applyImageVisualAttrs, hasImageCrop, hasImageVisualAttrs, renderImageFragment, wrapImageWithCrop };
@@ -19,6 +19,8 @@ type PageFloatingImage = {
19
19
  * opaque. eigenpal #424 (opacity render pipeline).
20
20
  */
21
21
  opacity?: number;
22
+ brightness?: number;
23
+ contrast?: number;
22
24
  /** Which side: 'left' for left margin, 'right' for right margin */
23
25
  side: "left" | "right";
24
26
  /** X position relative to content area (0 = left edge of content) */
@@ -371,6 +371,8 @@ function extractFloatingImagesFromParagraph(block, fragmentY, geometry) {
371
371
  ...imgRun.alt !== void 0 ? { alt: imgRun.alt } : {},
372
372
  ...imgRun.transform !== void 0 ? { transform: imgRun.transform } : {},
373
373
  ...imgRun.opacity != null ? { opacity: imgRun.opacity } : {},
374
+ ...imgRun.brightness != null ? { brightness: imgRun.brightness } : {},
375
+ ...imgRun.contrast != null ? { contrast: imgRun.contrast } : {},
374
376
  side,
375
377
  x,
376
378
  y,
@@ -460,6 +462,8 @@ function renderHeaderFooterContent(content, context, options, layout) {
460
462
  height: run.height,
461
463
  ...run.alt !== void 0 ? { alt: run.alt } : {},
462
464
  ...run.opacity != null ? { opacity: run.opacity } : {},
465
+ ...run.brightness != null ? { brightness: run.brightness } : {},
466
+ ...run.contrast != null ? { contrast: run.contrast } : {},
463
467
  ...run.pmStart !== void 0 ? { pmStart: run.pmStart } : {},
464
468
  ...run.pmEnd !== void 0 ? { pmEnd: run.pmEnd } : {},
465
469
  paragraphY: paragraphStartY,
@@ -30,6 +30,18 @@ type RenderParagraphOptions = {
30
30
  renderedInlineImageKeys?: Set<string>;
31
31
  };
32
32
  declare function getRenderableTextColor(run: TextRun | TabRun): string | undefined;
33
+ /**
34
+ * How CSS spells each bidirectional wrapper: an override switches the
35
+ * bidirectional algorithm off for its content, an embedding opens a level and
36
+ * leaves it on.
37
+ *
38
+ * Both painters write the keyword from here, so the DOM painter and the
39
+ * display list cannot spell the pair differently.
40
+ */
41
+ declare const UNICODE_BIDI_BY_WRAPPER_CONTROL: {
42
+ readonly override: "bidi-override";
43
+ readonly embedding: "embed";
44
+ };
33
45
  /**
34
46
  * Get leader character for tab
35
47
  */
@@ -134,4 +146,4 @@ declare function renderLine(block: ParagraphBlock, line: MeasuredLine, alignment
134
146
  */
135
147
  declare function renderParagraphFragment(fragment: ParagraphFragment, block: ParagraphBlock, measure: ParagraphMeasure, context: RenderContext, options?: RenderParagraphOptions): HTMLElement;
136
148
  //#endregion
137
- export { PARAGRAPH_CLASS_NAMES, RenderParagraphOptions, getLeaderChar, getRenderableTextColor, renderLine, renderParagraphFragment, sliceRunsForLine, splitCollapsibleLineEdgeSpaces, splitTextRunsByEastAsia, startsAfterSoftWrap };
149
+ export { PARAGRAPH_CLASS_NAMES, RenderParagraphOptions, UNICODE_BIDI_BY_WRAPPER_CONTROL, getLeaderChar, getRenderableTextColor, renderLine, renderParagraphFragment, sliceRunsForLine, splitCollapsibleLineEdgeSpaces, splitTextRunsByEastAsia, startsAfterSoftWrap };
@@ -8,6 +8,7 @@ import { DOCX_SCRIPT_FONT_SCALE } from "../layout-engine/measure/measureHelpers.
8
8
  import { calculateTabWidth } from "../layout-engine/measure/tabCalculator.js";
9
9
  import { FONT_KERNING_MODE, countCompressibleSpaces, getFontKerningMode, getRunFontKerningMode, toPaintedText } from "../layout-engine/measure/textMeasurementPolicy.js";
10
10
  import { isFloatingImageRun } from "../layout-engine/types.js";
11
+ import { writeCommentAnchorIds } from "../render-dom/commentAnchorAttributes.js";
11
12
  import { AUTHOR_COLORS, getAuthorColorIdx } from "../utils/authorColors.js";
12
13
  import { resolveFontFamily } from "../utils/fontResolver.js";
13
14
  import "../utils/fontWeights.js";
@@ -20,7 +21,7 @@ import { anchorTargetAttrs, sanitizeExternalUrl } from "../utils/urlSecurity.js"
20
21
  import { borderStrokeToCss, resolveParagraphBorderHorizontalOutsets } from "./borderStroke.js";
21
22
  import { planCursiveJoiners, withCursiveJoiners } from "./cursiveJoiners.js";
22
23
  import { getAutomaticTextColorForBackground, setAuthoredBackgroundColor, setAuthoredTextColor } from "./documentColors.js";
23
- import { applyImageBorder, applyImageVisualAttrs, hasImageCrop, hasImageVisualAttrs, wrapImageWithCrop } from "./renderImage.js";
24
+ import { applyImageBorder, applyImageColorAttrs, applyImageVisualAttrs, hasImageCrop, hasImageVisualAttrs, wrapImageWithCrop } from "./renderImage.js";
24
25
  import { resolveImageLineAlign } from "./renderUtils.js";
25
26
  import { applySdtDataAttrs } from "./sdtBoundary.js";
26
27
  //#region src/layout-painter/renderParagraph.ts
@@ -164,6 +165,18 @@ function applyHorizontalScaleTransform(element, horizontalScale) {
164
165
  element.style.transformOrigin = "left center";
165
166
  }
166
167
  /**
168
+ * How CSS spells each bidirectional wrapper: an override switches the
169
+ * bidirectional algorithm off for its content, an embedding opens a level and
170
+ * leaves it on.
171
+ *
172
+ * Both painters write the keyword from here, so the DOM painter and the
173
+ * display list cannot spell the pair differently.
174
+ */
175
+ const UNICODE_BIDI_BY_WRAPPER_CONTROL = {
176
+ override: "bidi-override",
177
+ embedding: "embed"
178
+ };
179
+ /**
167
180
  * Apply text run styles to an element
168
181
  */
169
182
  function applyRunStyles(element, run) {
@@ -192,6 +205,10 @@ function applyRunStyles(element, run) {
192
205
  }
193
206
  if (run.rtl === true) element.dir = RIGHT_TO_LEFT_DIRECTION;
194
207
  else if (run.rtl === false) element.dir = LEFT_TO_RIGHT_DIRECTION;
208
+ if (run.bidiWrapper) {
209
+ element.style.unicodeBidi = UNICODE_BIDI_BY_WRAPPER_CONTROL[run.bidiWrapper.control];
210
+ if (run.bidiWrapper.direction !== void 0 && run.rtl === void 0) element.dir = run.bidiWrapper.direction === "rtl" ? RIGHT_TO_LEFT_DIRECTION : LEFT_TO_RIGHT_DIRECTION;
211
+ }
195
212
  if (run.textEffect) {
196
213
  element.classList.add("docx-text-effect", `docx-text-effect-${run.textEffect}`);
197
214
  element.dataset["effect"] = run.textEffect;
@@ -238,7 +255,7 @@ function applyRunStyles(element, run) {
238
255
  if (run.commentIds && run.commentIds.length > 0) {
239
256
  element.style.backgroundColor = "rgba(255, 212, 0, 0.08)";
240
257
  element.style.borderBottom = "1px solid rgba(180, 130, 0, 0.24)";
241
- element.dataset["commentId"] = String(run.commentIds[0]);
258
+ writeCommentAnchorIds(element, run.commentIds);
242
259
  }
243
260
  if (run.isInsertion) {
244
261
  const authorIdx = getAuthorColorIdx(run.changeAuthor ?? "");
@@ -492,6 +509,7 @@ function renderInlineImageRun(run, doc) {
492
509
  img.style.transform = run.transform;
493
510
  img.style.transformOrigin = "center center";
494
511
  }
512
+ applyImageColorAttrs(img, run);
495
513
  if (!hasImageCrop(run)) applyImageBorder(img, run);
496
514
  const rotation = parseRotationDegrees(run.transform);
497
515
  if (rotation !== 0) {
@@ -558,6 +576,7 @@ function renderBlockImage(run, doc) {
558
576
  img.style.transform = run.transform;
559
577
  img.style.transformOrigin = "center center";
560
578
  }
579
+ applyImageColorAttrs(img, run);
561
580
  if (!hasImageCrop(run)) applyImageBorder(img, run);
562
581
  const rotation = parseRotationDegrees(run.transform);
563
582
  if (rotation !== 0) {
@@ -1667,4 +1686,4 @@ function renderListMarker({ marker, inlineWidth, visualOffset, doc, formatting,
1667
1686
  return span;
1668
1687
  }
1669
1688
  //#endregion
1670
- export { PARAGRAPH_CLASS_NAMES, getLeaderChar, getRenderableTextColor, renderLine, renderParagraphFragment, sliceRunsForLine, splitCollapsibleLineEdgeSpaces, splitTextRunsByEastAsia, startsAfterSoftWrap };
1689
+ export { PARAGRAPH_CLASS_NAMES, UNICODE_BIDI_BY_WRAPPER_CONTROL, getLeaderChar, getRenderableTextColor, renderLine, renderParagraphFragment, sliceRunsForLine, splitCollapsibleLineEdgeSpaces, splitTextRunsByEastAsia, startsAfterSoftWrap };
@@ -1,6 +1,14 @@
1
1
  import { document_d_exports } from "../types/document.js";
2
2
  //#region src/managers/autoSaveCodec.d.ts
3
- declare const AUTOSAVE_FORMAT_VERSION = 2;
3
+ /**
4
+ * Version 3 renamed the model's `bidiWrapper` to `inlineWrapper` and gave it a
5
+ * `kind`. The codec serialises the model itself, so a version-2 envelope holds
6
+ * paragraph content under the old discriminator: the model validator would
7
+ * reject it, and a reader that did not validate would drop the wrapper. The
8
+ * envelope is a local draft of one editing session, so it is refused and
9
+ * re-taken rather than migrated.
10
+ */
11
+ declare const AUTOSAVE_FORMAT_VERSION = 3;
4
12
  type DecodedAutoSave = {
5
13
  document: document_d_exports.Document;
6
14
  savedAt: string;
@@ -1,7 +1,15 @@
1
1
  import { validateFolioDocumentModel } from "../docx/modelValidation.js";
2
2
  import { bytesToBase64 } from "../utils/base64.js";
3
3
  //#region src/managers/autoSaveCodec.ts
4
- const AUTOSAVE_FORMAT_VERSION = 2;
4
+ /**
5
+ * Version 3 renamed the model's `bidiWrapper` to `inlineWrapper` and gave it a
6
+ * `kind`. The codec serialises the model itself, so a version-2 envelope holds
7
+ * paragraph content under the old discriminator: the model validator would
8
+ * reject it, and a reader that did not validate would drop the wrapper. The
9
+ * envelope is a local draft of one editing session, so it is refused and
10
+ * re-taken rather than migrated.
11
+ */
12
+ const AUTOSAVE_FORMAT_VERSION = 3;
5
13
  const decodeBase64 = (value) => {
6
14
  const binary = atob(value);
7
15
  const bytes = new Uint8Array(binary.length);
@@ -80,20 +88,20 @@ const encodeAutoSaveDocument = (document) => {
80
88
  };
81
89
  return { json: JSON.stringify(encodeValue(snapshot)) };
82
90
  };
83
- const encodeAutoSaveEnvelopeFromDocument = (document, savedAt) => `{"document":${document.json},"savedAt":${JSON.stringify(savedAt)},"version":2}`;
91
+ const encodeAutoSaveEnvelopeFromDocument = (document, savedAt) => `{"document":${document.json},"savedAt":${JSON.stringify(savedAt)},"version":3}`;
84
92
  const encodeAutoSaveEnvelope = (document, savedAt) => encodeAutoSaveEnvelopeFromDocument(encodeAutoSaveDocument(document), savedAt);
85
93
  const decodeAutoSaveEnvelope = (json) => {
86
94
  try {
87
95
  const parsed = JSON.parse(json);
88
96
  if (typeof parsed !== "object" || !parsed || !("document" in parsed) || !("savedAt" in parsed) || !("version" in parsed)) return null;
89
- if (parsed.version !== 2 || typeof parsed.savedAt !== "string" || !Number.isFinite(Date.parse(parsed.savedAt))) return null;
97
+ if (parsed.version !== 3 || typeof parsed.savedAt !== "string" || !Number.isFinite(Date.parse(parsed.savedAt))) return null;
90
98
  const document = decodeValue(parsed.document);
91
99
  if (typeof document !== "object" || !document) return null;
92
100
  if (!validateFolioDocumentModel(document).valid) return null;
93
101
  return {
94
102
  document,
95
103
  savedAt: parsed.savedAt,
96
- version: 2
104
+ version: 3
97
105
  };
98
106
  } catch {
99
107
  return null;
@@ -71,6 +71,7 @@ function renderBlocks(ctx, pkg, blocks) {
71
71
  }
72
72
  break;
73
73
  }
74
+ case "preservedBlock": break;
74
75
  default: panic(`Unsupported block content in markdown: ${JSON.stringify(block)}`);
75
76
  }
76
77
  return out.join("\n");
@@ -5,6 +5,6 @@ import { RenderContext } from "./types.js";
5
5
  * Render the full inline content of a paragraph, tracking comment-range
6
6
  * boundaries to apply the configured wrapper.
7
7
  */
8
- declare function renderParagraphInline(ctx: RenderContext, pkg: document_d_exports.DocxPackage | undefined, content: document_d_exports.ParagraphContent[], paraId: string | undefined): string;
8
+ declare function renderParagraphInline(ctx: RenderContext, pkg: document_d_exports.DocxPackage | undefined, content: readonly document_d_exports.ParagraphContent[], paraId: string | undefined): string;
9
9
  //#endregion
10
10
  export { renderParagraphInline };