@stll/folio-core 0.44.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.
- package/dist/ai-edits/__fixtures__/paragraphs.js +2 -2
- package/dist/ai-edits/apply.js +59 -19
- package/dist/ai-edits/headless.js +2 -1
- package/dist/compare/compare.js +2 -5
- package/dist/compare/content-alignment.js +78 -53
- package/dist/compare/inline-atoms.js +34 -20
- package/dist/compare/scenario.js +2 -5
- package/dist/compare/types.d.ts +9 -1
- package/dist/compare/types.js +12 -1
- package/dist/compat/eigenpal.d.ts +2 -1
- package/dist/compat/eigenpal.js +2 -1
- package/dist/content-controls/checkboxDisplay.d.ts +11 -0
- package/dist/content-controls/checkboxDisplay.js +40 -0
- package/dist/content-controls/findContentControls.js +3 -1
- package/dist/content-controls/mutateContentControls.js +21 -4
- package/dist/controller/contentControlWidgetController.d.ts +1 -0
- package/dist/controller/contentControlWidgetController.js +3 -0
- package/dist/controller/hiddenEditorApi.js +3 -1
- package/dist/controller/hiddenEditorManager.d.ts +1 -1
- package/dist/controller/hiddenEditorManager.js +6 -3
- package/dist/display-list/build/buildDisplayList.js +20 -1
- package/dist/display-list/build/imagePrimitives.d.ts +1 -1
- package/dist/display-list/build/imagePrimitives.js +3 -1
- package/dist/display-list/build/paragraphPrimitives.js +21 -2
- package/dist/display-list/dom/renderDisplayListToDom.js +18 -10
- package/dist/display-list/types.d.ts +17 -0
- package/dist/document-operations.js +14 -3
- package/dist/docx/attributeRemainder.d.ts +43 -0
- package/dist/docx/attributeRemainder.js +65 -0
- package/dist/docx/blockContentParser.d.ts +1 -1
- package/dist/docx/blockContentParser.js +87 -63
- package/dist/docx/blockPlainText.d.ts +3 -4
- package/dist/docx/blockPlainText.js +1 -0
- package/dist/docx/bookmarkPlacement.js +2 -0
- package/dist/docx/borderParser.js +5 -5
- package/dist/docx/commentAnchorIndex.d.ts +30 -0
- package/dist/docx/commentAnchorIndex.js +50 -0
- package/dist/docx/commentParser.d.ts +1 -1
- package/dist/docx/commentParser.js +78 -50
- package/dist/docx/commentRangeIntegrity.d.ts +16 -1
- package/dist/docx/commentRangeIntegrity.js +42 -1
- package/dist/docx/commentRangeJoin.d.ts +9 -0
- package/dist/docx/commentRangeJoin.js +33 -0
- package/dist/docx/commentReferenceCompletion.d.ts +9 -0
- package/dist/docx/commentReferenceCompletion.js +47 -0
- package/dist/docx/commentReferenceNormalization.js +1 -0
- package/dist/docx/commentReplyMarkers.js +11 -19
- package/dist/docx/commentThreadKey.d.ts +18 -0
- package/dist/docx/commentThreadKey.js +22 -0
- package/dist/docx/compatibility.js +1 -0
- package/dist/docx/containerChildren.d.ts +111 -0
- package/dist/docx/containerChildren.gen.d.ts +28 -0
- package/dist/docx/containerChildren.gen.js +246 -0
- package/dist/docx/containerChildren.js +103 -0
- package/dist/docx/diagramPreview.js +87 -27
- package/dist/docx/documentParser.d.ts +1 -1
- package/dist/docx/documentParser.js +3 -3
- package/dist/docx/ensureParaIds.js +17 -7
- package/dist/docx/fieldParser.d.ts +1 -1
- package/dist/docx/fieldParser.js +4 -4
- package/dist/docx/fieldState.d.ts +26 -0
- package/dist/docx/fieldState.js +53 -0
- package/dist/docx/footnoteParser.d.ts +1 -1
- package/dist/docx/graphicFrameLocks.d.ts +16 -4
- package/dist/docx/graphicFrameLocks.js +19 -6
- package/dist/docx/groupDrawingParser.js +3 -3
- package/dist/docx/headerFooterParser.js +1 -1
- package/dist/docx/headerFooterReferenceNormalization.js +1 -0
- package/dist/docx/hyperlinkParser.d.ts +27 -8
- package/dist/docx/hyperlinkParser.js +78 -20
- package/dist/docx/imageParser.d.ts +9 -1
- package/dist/docx/imageParser.js +91 -20
- package/dist/docx/imageRawXml.d.ts +14 -1
- package/dist/docx/imageRawXml.js +30 -6
- package/dist/docx/inlineWrapperContent.d.ts +85 -0
- package/dist/docx/inlineWrapperContent.js +84 -0
- package/dist/docx/mathToMathml.js +12 -14
- package/dist/docx/nonVisualDrawingProps.d.ts +34 -0
- package/dist/docx/nonVisualDrawingProps.js +46 -0
- package/dist/docx/normalizeBaseDirection.js +10 -1
- package/dist/docx/paraIdAttribute.d.ts +21 -0
- package/dist/docx/paraIdAttribute.js +64 -0
- package/dist/docx/paragraphParser.d.ts +1 -1
- package/dist/docx/paragraphParser.js +277 -168
- package/dist/docx/paragraphPropertySource.js +5 -1
- package/dist/docx/paragraphTextBoxEnrichment.d.ts +1 -1
- package/dist/docx/paragraphTextBoxEnrichment.js +9 -52
- package/dist/docx/paragraphTraversal.js +7 -4
- package/dist/docx/parseWarningMessage.js +2 -1
- package/dist/docx/parser.js +2 -2
- package/dist/docx/preservedRunContent.d.ts +32 -0
- package/dist/docx/preservedRunContent.js +86 -0
- package/dist/docx/previewBudget.d.ts +64 -0
- package/dist/docx/previewBudget.js +88 -0
- package/dist/docx/renderedPageBreakNormalization.js +2 -4
- package/dist/docx/revisionIdNormalization.js +17 -5
- package/dist/docx/rezip.js +91 -36
- package/dist/docx/runParser.d.ts +1 -1
- package/dist/docx/runParser.js +16 -12
- package/dist/docx/sdtPropertiesPatch.js +24 -18
- package/dist/docx/sectionParser.js +8 -1
- package/dist/docx/sectionReferenceHistory.js +2 -2
- package/dist/docx/selectiveSave.js +6 -6
- package/dist/docx/selectiveXmlPatch.d.ts +46 -2
- package/dist/docx/selectiveXmlPatch.js +86 -39
- package/dist/docx/serializer/blockSdtSerializer.js +38 -26
- package/dist/docx/serializer/borderSerializer.d.ts +1 -1
- package/dist/docx/serializer/borderSerializer.js +15 -14
- package/dist/docx/serializer/commentSerializer.d.ts +41 -16
- package/dist/docx/serializer/commentSerializer.js +87 -92
- package/dist/docx/serializer/documentSerializer.js +8 -11
- package/dist/docx/serializer/fontTableSerializer.js +6 -6
- package/dist/docx/serializer/headerFooterSerializer.js +12 -14
- package/dist/docx/serializer/markupRangeAttributes.js +2 -2
- package/dist/docx/serializer/noteSerializer.js +8 -8
- package/dist/docx/serializer/numberingSerializer.js +7 -6
- package/dist/docx/serializer/paragraphSerializer.js +93 -72
- package/dist/docx/serializer/partNamespaces.js +2 -2
- package/dist/docx/serializer/runSerializer.js +73 -44
- package/dist/docx/serializer/sectionPropertiesSerializer.js +19 -14
- package/dist/docx/serializer/settingsSerializer.js +4 -3
- package/dist/docx/serializer/stylesSerializer.js +6 -6
- package/dist/docx/serializer/tableSerializer.js +28 -17
- package/dist/docx/serializer/textFormattingSerializer.js +29 -28
- package/dist/docx/serializer/themeSerializer.js +6 -6
- package/dist/docx/serializer/trackedChangeAttributes.js +2 -2
- package/dist/docx/serializer/xmlUtils.d.ts +1 -2
- package/dist/docx/serializer/xmlUtils.js +1 -13
- package/dist/docx/server/boundedArchive.d.ts +12 -0
- package/dist/docx/server/boundedArchive.js +20 -1
- package/dist/docx/server/createBilingualDocument.js +3 -1
- package/dist/docx/server/materializeYjsDocx.d.ts +1 -1
- package/dist/docx/server/materializeYjsDocx.js +9 -1
- package/dist/docx/server/migrateYjsAttrSchema.d.ts +55 -0
- package/dist/docx/server/migrateYjsAttrSchema.js +95 -0
- package/dist/docx/server/validateDocxConformance.js +22 -1
- package/dist/docx/shapeParser.js +12 -10
- package/dist/docx/tableParser.d.ts +1 -1
- package/dist/docx/tableParser.js +206 -85
- package/dist/docx/textBoxParser.d.ts +25 -2
- package/dist/docx/textBoxParser.js +59 -4
- package/dist/docx/unzip.d.ts +23 -0
- package/dist/docx/unzip.js +37 -26
- package/dist/docx/verbatimCapture.js +1 -1
- package/dist/docx/vmlImageParser.d.ts +17 -1
- package/dist/docx/vmlImageParser.js +20 -3
- package/dist/docx/vmlPreview.d.ts +1 -3
- package/dist/docx/vmlPreview.js +2 -30
- package/dist/docx/xmlEncoding.d.ts +5 -0
- package/dist/docx/xmlEncoding.js +12 -0
- package/dist/docx/xmlParser.d.ts +26 -2
- package/dist/docx/xmlParser.js +70 -27
- package/dist/docx/xmlResourceLimits.d.ts +89 -9
- package/dist/docx/xmlResourceLimits.js +105 -24
- package/dist/headless-layout.js +10 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/internal/pageBreakRunSourceDescendantIndex.js +5 -2
- package/dist/internal/paragraphFormattingSerialization.js +3 -2
- package/dist/layout-bridge/convert/toFlowBlocks.js +102 -12
- package/dist/layout-engine/measure/tableCellFloating.d.ts +2 -0
- package/dist/layout-engine/measure/tableCellFloating.js +2 -0
- package/dist/layout-engine/types.d.ts +23 -1
- package/dist/layout-painter/renderImage.d.ts +5 -1
- package/dist/layout-painter/renderImage.js +14 -6
- package/dist/layout-painter/renderPage.d.ts +2 -0
- package/dist/layout-painter/renderPage.js +4 -0
- package/dist/layout-painter/renderParagraph.d.ts +13 -1
- package/dist/layout-painter/renderParagraph.js +26 -6
- package/dist/managers/autoSaveCodec.d.ts +9 -1
- package/dist/managers/autoSaveCodec.js +14 -12
- package/dist/markdown/images.js +1 -4
- package/dist/markdown/renderBlock.js +1 -0
- package/dist/markdown/renderRuns.d.ts +1 -1
- package/dist/markdown/renderRuns.js +28 -5
- package/dist/markdown/renderTable.js +22 -5
- package/dist/markdown/trailers.js +4 -1
- package/dist/pdf/images.js +142 -6
- package/dist/prosemirror/attrs/index.d.ts +14 -3
- package/dist/prosemirror/attrs/index.js +224 -2
- package/dist/prosemirror/authoredTransformAttrs.d.ts +28 -0
- package/dist/prosemirror/authoredTransformAttrs.js +64 -0
- package/dist/prosemirror/commands/contentControls.js +10 -2
- package/dist/prosemirror/commands/image.d.ts +9 -2
- package/dist/prosemirror/commands/image.js +43 -28
- package/dist/prosemirror/commands/pageBreak.js +1 -1
- package/dist/prosemirror/commentReferenceAttrs.d.ts +8 -0
- package/dist/prosemirror/commentReferenceAttrs.js +33 -0
- package/dist/prosemirror/commentReferenceIntegrity.d.ts +47 -0
- package/dist/prosemirror/commentReferenceIntegrity.js +43 -0
- package/dist/prosemirror/conversion/fromProseDoc.d.ts +2 -13
- package/dist/prosemirror/conversion/fromProseDoc.js +338 -99
- package/dist/prosemirror/conversion/index.d.ts +2 -2
- package/dist/prosemirror/conversion/toProseDoc.d.ts +7 -9
- package/dist/prosemirror/conversion/toProseDoc.js +551 -327
- package/dist/prosemirror/extensions/StarterKit.js +8 -58
- package/dist/prosemirror/extensions/core/DocExtension.js +1 -1
- package/dist/prosemirror/extensions/core/ParagraphExtension.js +2 -1
- package/dist/prosemirror/extensions/features/BaseKeymapExtension.js +45 -27
- package/dist/prosemirror/extensions/features/EmptyParagraphFormatExtension.js +3 -1
- package/dist/prosemirror/extensions/features/ImagePasteExtension.js +5 -3
- package/dist/prosemirror/extensions/features/ParaIdAllocatorExtension.js +1 -0
- package/dist/prosemirror/extensions/markRegistry.d.ts +41 -0
- package/dist/prosemirror/extensions/markRegistry.js +75 -0
- package/dist/prosemirror/extensions/marks/HyperlinkExtension.js +2 -3
- package/dist/prosemirror/extensions/marks/InlineWrapperExtension.d.ts +18 -0
- package/dist/prosemirror/extensions/marks/InlineWrapperExtension.js +63 -0
- package/dist/prosemirror/extensions/marks/markUtils.d.ts +2 -1
- package/dist/prosemirror/extensions/marks/markUtils.js +47 -4
- package/dist/prosemirror/extensions/nodes/CommentReferenceExtension.d.ts +11 -0
- package/dist/prosemirror/extensions/nodes/CommentReferenceExtension.js +87 -0
- package/dist/prosemirror/extensions/nodes/FieldExtension.js +9 -7
- package/dist/prosemirror/extensions/nodes/ImageExtension.js +20 -0
- package/dist/prosemirror/extensions/nodes/PreservedBlockExtension.d.ts +32 -0
- package/dist/prosemirror/extensions/nodes/PreservedBlockExtension.js +67 -0
- package/dist/prosemirror/extensions/nodes/PreservedXmlExtension.d.ts +16 -0
- package/dist/prosemirror/extensions/nodes/PreservedXmlExtension.js +60 -0
- package/dist/prosemirror/extensions/nodes/ShapeExtension.js +10 -2
- package/dist/prosemirror/extensions/nodes/TableExtension.js +3 -2
- package/dist/prosemirror/extensions/nodes/TextBoxExtension.js +13 -5
- package/dist/prosemirror/inlineWrapperStack.d.ts +39 -0
- package/dist/prosemirror/inlineWrapperStack.js +75 -0
- package/dist/prosemirror/pageBreakRunProjection.d.ts +17 -7
- package/dist/prosemirror/pageBreakRunProjection.js +19 -9
- package/dist/prosemirror/paragraphFormattingProvenance.d.ts +6 -3
- package/dist/prosemirror/paragraphFormattingProvenance.js +12 -3
- package/dist/prosemirror/replacedAnnotations.d.ts +59 -0
- package/dist/prosemirror/replacedAnnotations.js +165 -0
- package/dist/prosemirror/runFormattingInlineCarriers.d.ts +3 -1
- package/dist/prosemirror/runFormattingInlineCarriers.js +5 -1
- package/dist/prosemirror/schema/index.d.ts +3 -3
- package/dist/prosemirror/schema/marks.d.ts +25 -1
- package/dist/prosemirror/schema/nodes.d.ts +139 -3
- package/dist/prosemirror/schema/nodes.js +16 -1
- package/dist/prosemirror/trackedRunInlineAtoms.d.ts +2 -0
- package/dist/prosemirror/trackedRunInlineAtoms.js +2 -0
- package/dist/prosemirror/validation.js +16 -2
- package/dist/prosemirror/yjsDocumentMetadata.d.ts +73 -0
- package/dist/prosemirror/yjsDocumentMetadata.js +171 -0
- package/dist/prosemirror/zeroWidthAnchors.js +2 -0
- package/dist/render-dom/commentAnchorAttributes.d.ts +37 -0
- package/dist/render-dom/commentAnchorAttributes.js +54 -0
- package/dist/server.d.ts +3 -1
- package/dist/server.js +3 -1
- package/dist/types/content.d.ts +2 -2
- package/dist/utils/base64.d.ts +36 -0
- package/dist/utils/base64.js +40 -0
- package/dist/utils/clipboard.d.ts +9 -1
- package/dist/utils/clipboard.js +29 -2
- package/dist/utils/findReplace.js +1 -1
- package/dist/utils/imageLuminance.d.ts +15 -0
- package/dist/utils/imageLuminance.js +32 -0
- package/dist/utils/mergeDocumentContent.js +7 -17
- package/dist/utils/replaceText.js +1 -0
- package/dist/utils/units.d.ts +10 -1
- package/dist/utils/units.js +12 -1
- package/dist/utils/urlSecurity.d.ts +8 -2
- package/dist/utils/urlSecurity.js +21 -3
- package/package.json +2 -2
- package/dist/docx/blockRangeMarkers.d.ts +0 -36
- package/dist/docx/blockRangeMarkers.js +0 -59
- package/dist/prosemirror/yjsParagraphSourceContract.d.ts +0 -9
- package/dist/prosemirror/yjsParagraphSourceContract.js +0 -26
package/dist/pdf/images.js
CHANGED
|
@@ -12,9 +12,10 @@ import { inflateSync } from "node:zlib";
|
|
|
12
12
|
* so a 4-bit palette image stays 4-bit and an alpha channel becomes an
|
|
13
13
|
* `/SMask` rather than being composited against a guess at the backdrop.
|
|
14
14
|
*
|
|
15
|
-
* A form this module cannot represent exactly (16-bit samples,
|
|
16
|
-
*
|
|
17
|
-
*
|
|
15
|
+
* A form this module cannot represent exactly (16-bit samples) is an error,
|
|
16
|
+
* never an approximation: painting the wrong pixels silently is worse than
|
|
17
|
+
* refusing the page. Adam7 interlacing is not such a form — it is seven
|
|
18
|
+
* ordinary rasters of the same samples — so it is decoded rather than refused.
|
|
18
19
|
*/
|
|
19
20
|
var PdfImageError = class extends TaggedError("PdfImageError") {};
|
|
20
21
|
const PNG_SIGNATURE = [
|
|
@@ -43,6 +44,8 @@ const CHANNELS_PER_COLOR_TYPE = {
|
|
|
43
44
|
};
|
|
44
45
|
const FULLY_OPAQUE = 255;
|
|
45
46
|
const EIGHT_BIT = 8;
|
|
47
|
+
/** IHDR interlace method 1: the only one PNG defines besides "none". */
|
|
48
|
+
const ADAM7_INTERLACE = 1;
|
|
46
49
|
const toHex = (bytes) => {
|
|
47
50
|
let out = "";
|
|
48
51
|
for (const byte of bytes) out += byte.toString(16).padStart(2, "0").toUpperCase();
|
|
@@ -138,6 +141,131 @@ const unfilterPng = ({ filtered, bytesPerRow, bytesPerPixel, height }) => {
|
|
|
138
141
|
}
|
|
139
142
|
return Result.ok(out);
|
|
140
143
|
};
|
|
144
|
+
/**
|
|
145
|
+
* The seven Adam7 passes, in the order the IDAT stream carries them: the
|
|
146
|
+
* offset of the pass's first pixel and the stride between its pixels.
|
|
147
|
+
*/
|
|
148
|
+
const ADAM7_PASSES = [
|
|
149
|
+
{
|
|
150
|
+
xOffset: 0,
|
|
151
|
+
yOffset: 0,
|
|
152
|
+
xStep: 8,
|
|
153
|
+
yStep: 8
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
xOffset: 4,
|
|
157
|
+
yOffset: 0,
|
|
158
|
+
xStep: 8,
|
|
159
|
+
yStep: 8
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
xOffset: 0,
|
|
163
|
+
yOffset: 4,
|
|
164
|
+
xStep: 4,
|
|
165
|
+
yStep: 8
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
xOffset: 2,
|
|
169
|
+
yOffset: 0,
|
|
170
|
+
xStep: 4,
|
|
171
|
+
yStep: 4
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
xOffset: 0,
|
|
175
|
+
yOffset: 2,
|
|
176
|
+
xStep: 2,
|
|
177
|
+
yStep: 4
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
xOffset: 1,
|
|
181
|
+
yOffset: 0,
|
|
182
|
+
xStep: 2,
|
|
183
|
+
yStep: 2
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
xOffset: 0,
|
|
187
|
+
yOffset: 1,
|
|
188
|
+
xStep: 1,
|
|
189
|
+
yStep: 2
|
|
190
|
+
}
|
|
191
|
+
];
|
|
192
|
+
/**
|
|
193
|
+
* The passes that carry data, with their own geometry.
|
|
194
|
+
*
|
|
195
|
+
* A narrow or short image leaves later passes empty — a 1x1 image has only
|
|
196
|
+
* pass 1 — and an empty pass contributes no bytes at all, not even a filter
|
|
197
|
+
* byte, so it must be dropped rather than read as a zero-row raster.
|
|
198
|
+
*/
|
|
199
|
+
const adam7Passes = (width, height, bitsPerPixel) => {
|
|
200
|
+
const passes = [];
|
|
201
|
+
for (const { xOffset, yOffset, xStep, yStep } of ADAM7_PASSES) {
|
|
202
|
+
const passWidth = Math.ceil(Math.max(0, width - xOffset) / xStep);
|
|
203
|
+
const passHeight = Math.ceil(Math.max(0, height - yOffset) / yStep);
|
|
204
|
+
if (passWidth === 0 || passHeight === 0) continue;
|
|
205
|
+
passes.push({
|
|
206
|
+
xOffset,
|
|
207
|
+
yOffset,
|
|
208
|
+
xStep,
|
|
209
|
+
yStep,
|
|
210
|
+
width: passWidth,
|
|
211
|
+
height: passHeight,
|
|
212
|
+
bytesPerRow: Math.ceil(bitsPerPixel * passWidth / EIGHT_BIT)
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
return passes;
|
|
216
|
+
};
|
|
217
|
+
/** One filter byte per row of every pass: the whole inflated size Adam7 needs. */
|
|
218
|
+
const adam7FilteredBytes = (passes) => passes.reduce((sum, pass) => sum + pass.height * (pass.bytesPerRow + 1), 0);
|
|
219
|
+
/** Write one unfiltered pass into the pixels of the full raster it owns. */
|
|
220
|
+
const scatterPass = ({ pass, rows, out, bytesPerRow, bitDepth, bytesPerPixel }) => {
|
|
221
|
+
if (bitDepth >= EIGHT_BIT) {
|
|
222
|
+
for (let row = 0; row < pass.height; row += 1) {
|
|
223
|
+
const targetRow = pass.yOffset + row * pass.yStep;
|
|
224
|
+
for (let column = 0; column < pass.width; column += 1) {
|
|
225
|
+
const source = row * pass.bytesPerRow + column * bytesPerPixel;
|
|
226
|
+
const target = targetRow * bytesPerRow + (pass.xOffset + column * pass.xStep) * bytesPerPixel;
|
|
227
|
+
for (let byte = 0; byte < bytesPerPixel; byte += 1) out[target + byte] = rows[source + byte] ?? 0;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
return;
|
|
231
|
+
}
|
|
232
|
+
const perByte = EIGHT_BIT / bitDepth;
|
|
233
|
+
const mask = (1 << bitDepth) - 1;
|
|
234
|
+
for (let row = 0; row < pass.height; row += 1) {
|
|
235
|
+
const targetRow = pass.yOffset + row * pass.yStep;
|
|
236
|
+
for (let column = 0; column < pass.width; column += 1) {
|
|
237
|
+
const value = (rows[row * pass.bytesPerRow + Math.floor(column / perByte)] ?? 0) >> EIGHT_BIT - bitDepth * (column % perByte + 1) & mask;
|
|
238
|
+
const targetColumn = pass.xOffset + column * pass.xStep;
|
|
239
|
+
const targetIndex = targetRow * bytesPerRow + Math.floor(targetColumn / perByte);
|
|
240
|
+
const targetShift = EIGHT_BIT - bitDepth * (targetColumn % perByte + 1);
|
|
241
|
+
out[targetIndex] = (out[targetIndex] ?? 0) & ~(mask << targetShift) | value << targetShift;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
};
|
|
245
|
+
/** Unfilter each Adam7 pass and scatter it into the raster it describes. */
|
|
246
|
+
const deinterlacePng = ({ filtered, passes, height, bytesPerRow, bytesPerPixel, bitDepth }) => {
|
|
247
|
+
const out = new Uint8Array(height * bytesPerRow);
|
|
248
|
+
let cursor = 0;
|
|
249
|
+
for (const pass of passes) {
|
|
250
|
+
const unfiltered = unfilterPng({
|
|
251
|
+
filtered: filtered.subarray(cursor),
|
|
252
|
+
bytesPerRow: pass.bytesPerRow,
|
|
253
|
+
bytesPerPixel,
|
|
254
|
+
height: pass.height
|
|
255
|
+
});
|
|
256
|
+
if (unfiltered.isErr()) return Result.err(unfiltered.error);
|
|
257
|
+
scatterPass({
|
|
258
|
+
pass,
|
|
259
|
+
rows: unfiltered.value,
|
|
260
|
+
out,
|
|
261
|
+
bytesPerRow,
|
|
262
|
+
bitDepth,
|
|
263
|
+
bytesPerPixel
|
|
264
|
+
});
|
|
265
|
+
cursor += pass.height * (pass.bytesPerRow + 1);
|
|
266
|
+
}
|
|
267
|
+
return Result.ok(out);
|
|
268
|
+
};
|
|
141
269
|
/** One byte per pixel index, for sub-byte palette and greyscale depths. */
|
|
142
270
|
const expandIndices = ({ rows, bytesPerRow, width, height, bitDepth }) => {
|
|
143
271
|
if (bitDepth === EIGHT_BIT) return rows;
|
|
@@ -162,7 +290,7 @@ const decodePng = (bytes) => {
|
|
|
162
290
|
const colorType = header[9] ?? 0;
|
|
163
291
|
const interlace = header[12] ?? 0;
|
|
164
292
|
if (width === 0 || height === 0) return Result.err(new PdfImageError({ message: "PNG has a zero dimension" }));
|
|
165
|
-
if (interlace !== 0) return Result.err(new PdfImageError({ message:
|
|
293
|
+
if (interlace !== 0 && interlace !== ADAM7_INTERLACE) return Result.err(new PdfImageError({ message: `unknown PNG interlace method ${String(interlace)}` }));
|
|
166
294
|
const channels = CHANNELS_PER_COLOR_TYPE[colorType];
|
|
167
295
|
if (channels === void 0) return Result.err(new PdfImageError({ message: `unknown PNG colour type ${String(colorType)}` }));
|
|
168
296
|
if (!(colorType === PNG_COLOR_TYPE.greyscale || colorType === PNG_COLOR_TYPE.palette ? [
|
|
@@ -174,18 +302,26 @@ const decodePng = (bytes) => {
|
|
|
174
302
|
const bitsPerPixel = bitDepth * channels;
|
|
175
303
|
const bytesPerRow = Math.ceil(bitsPerPixel * width / EIGHT_BIT);
|
|
176
304
|
const bytesPerPixel = Math.max(1, Math.ceil(bitsPerPixel / EIGHT_BIT));
|
|
177
|
-
const
|
|
305
|
+
const passes = interlace === ADAM7_INTERLACE ? adam7Passes(width, height, bitsPerPixel) : null;
|
|
306
|
+
const inflatedBytesExpected = passes === null ? height * (bytesPerRow + 1) : adam7FilteredBytes(passes);
|
|
178
307
|
const inflated = Result.try({
|
|
179
308
|
try: () => inflateSync(pixels, { maxOutputLength: inflatedBytesExpected }),
|
|
180
309
|
catch: (cause) => new PdfImageError({ message: `PNG IDAT does not inflate to the ${String(inflatedBytesExpected)} bytes its IHDR declares: ${cause instanceof Error ? cause.message : String(cause)}` })
|
|
181
310
|
});
|
|
182
311
|
if (inflated.isErr()) return Result.err(inflated.error);
|
|
183
312
|
const filtered = new Uint8Array(inflated.value.buffer, inflated.value.byteOffset, inflated.value.byteLength);
|
|
184
|
-
const unfiltered = unfilterPng({
|
|
313
|
+
const unfiltered = passes === null ? unfilterPng({
|
|
185
314
|
filtered,
|
|
186
315
|
bytesPerRow,
|
|
187
316
|
bytesPerPixel,
|
|
188
317
|
height
|
|
318
|
+
}) : deinterlacePng({
|
|
319
|
+
filtered,
|
|
320
|
+
passes,
|
|
321
|
+
height,
|
|
322
|
+
bytesPerRow,
|
|
323
|
+
bytesPerPixel,
|
|
324
|
+
bitDepth
|
|
189
325
|
});
|
|
190
326
|
if (unfiltered.isErr()) return Result.err(unfiltered.error);
|
|
191
327
|
const rows = unfiltered.value;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { CharacterSpacingAttrs, CharacterStyleAttrs, CommentAttrs, EmphasisMarkAttrs, FontFamilyAttrs, FontSizeAttrs, FootnoteRefAttrs, HighlightAttrs, HyperlinkAttrs, LanguageAttrs, PageBreakRunOwnerMarkAttrs, RunFormattingOverrideAttrs, RunPropertyChangeMarkAttrs, RunShadingAttrs, StrikeAttrs, TextColorAttrs, TextEffectAttrs, TrackedChangeMarkAttrs, UnderlineAttrs } from "../schema/marks.js";
|
|
2
|
-
import { BlockSdtAttrs, FieldAttrs, HardBreakAttrs, ImageAttrs, MathAttrs, PageBreakRunAttrs, ParagraphAttrs, SdtAttrs, ShapeAttrs, SymbolAttrs, TabAttrs, TableAttrs, TableCellAttrs, TableRowAttrs, TextBoxAttrs } from "../schema/nodes.js";
|
|
1
|
+
import { CharacterSpacingAttrs, CharacterStyleAttrs, CommentAttrs, EmphasisMarkAttrs, FontFamilyAttrs, FontSizeAttrs, FootnoteRefAttrs, HighlightAttrs, HyperlinkAttrs, InlineWrapperAttrs, InlineWrapperLayer, LanguageAttrs, PageBreakRunOwnerMarkAttrs, RunFormattingOverrideAttrs, RunPropertyChangeMarkAttrs, RunShadingAttrs, StrikeAttrs, TextColorAttrs, TextEffectAttrs, TrackedChangeMarkAttrs, UnderlineAttrs } from "../schema/marks.js";
|
|
2
|
+
import { BlockSdtAttrs, FieldAttrs, HardBreakAttrs, ImageAttrs, MathAttrs, PageBreakRunAttrs, ParagraphAttrs, PreservedBlockAttrs, PreservedXmlAttrs, SdtAttrs, ShapeAttrs, SymbolAttrs, TabAttrs, TableAttrs, TableCellAttrs, TableRowAttrs, TextBoxAttrs } from "../schema/nodes.js";
|
|
3
3
|
import "../schema/index.js";
|
|
4
4
|
import { Mark, Node } from "prosemirror-model";
|
|
5
5
|
//#region src/prosemirror/attrs/index.d.ts
|
|
@@ -24,6 +24,10 @@ declare const readTabAttrs: (node: Node) => ReadProseMirrorAttrsResult<TabAttrs>
|
|
|
24
24
|
declare const expectTabAttrs: (node: Node) => TabAttrs;
|
|
25
25
|
declare const readSymbolAttrs: (node: Node) => ReadProseMirrorAttrsResult<SymbolAttrs>;
|
|
26
26
|
declare const expectSymbolAttrs: (node: Node) => SymbolAttrs;
|
|
27
|
+
declare const readPreservedXmlAttrs: (node: Node) => ReadProseMirrorAttrsResult<PreservedXmlAttrs>;
|
|
28
|
+
declare const expectPreservedXmlAttrs: (node: Node) => PreservedXmlAttrs;
|
|
29
|
+
declare const readPreservedBlockAttrs: (node: Node) => ReadProseMirrorAttrsResult<PreservedBlockAttrs>;
|
|
30
|
+
declare const expectPreservedBlockAttrs: (node: Node) => PreservedBlockAttrs;
|
|
27
31
|
declare const readTableAttrs: (node: Node) => ReadProseMirrorAttrsResult<TableAttrs>;
|
|
28
32
|
declare const expectTableAttrs: (node: Node) => TableAttrs;
|
|
29
33
|
declare const readTableRowAttrs: (node: Node) => ReadProseMirrorAttrsResult<TableRowAttrs>;
|
|
@@ -78,6 +82,13 @@ declare const readRunPropertyChangeMarkAttrs: (mark: Mark) => ReadProseMirrorAtt
|
|
|
78
82
|
declare const expectRunPropertyChangeMarkAttrs: (mark: Mark) => RunPropertyChangeMarkAttrs;
|
|
79
83
|
declare const readPageBreakRunOwnerMarkAttrs: (mark: Mark) => ReadProseMirrorAttrsResult<PageBreakRunOwnerMarkAttrs>;
|
|
80
84
|
declare const expectPageBreakRunOwnerMarkAttrs: (mark: Mark) => PageBreakRunOwnerMarkAttrs;
|
|
85
|
+
/**
|
|
86
|
+
* A wrapper stack read from outside the editor — the DOM on paste, a stored
|
|
87
|
+
* snapshot — validated layer by layer.
|
|
88
|
+
*/
|
|
89
|
+
declare const readInlineWrapperStack: (value: unknown, path?: string) => ReadProseMirrorAttrsResult<readonly InlineWrapperLayer[]>;
|
|
90
|
+
declare const readInlineWrapperMarkAttrs: (mark: Mark) => ReadProseMirrorAttrsResult<InlineWrapperAttrs>;
|
|
91
|
+
declare const expectInlineWrapperMarkAttrs: (mark: Mark) => InlineWrapperAttrs;
|
|
81
92
|
declare const readRunFormattingOverrideMarkAttrs: (mark: Mark) => ReadProseMirrorAttrsResult<RunFormattingOverrideAttrs>;
|
|
82
93
|
declare const expectRunFormattingOverrideMarkAttrs: (mark: Mark) => RunFormattingOverrideAttrs;
|
|
83
94
|
declare const readHyperlinkMarkAttrs: (mark: Mark) => ReadProseMirrorAttrsResult<HyperlinkAttrs>;
|
|
@@ -89,4 +100,4 @@ declare const mergeTableAttrs: (node: Node, patch: NodeAttrPatch<TableAttrs>) =>
|
|
|
89
100
|
declare const mergeTableRowAttrs: (node: Node, patch: NodeAttrPatch<TableRowAttrs>) => TableRowAttrs;
|
|
90
101
|
declare const mergeTableCellAttrs: (node: Node, patch: NodeAttrPatch<TableCellAttrs>) => TableCellAttrs;
|
|
91
102
|
//#endregion
|
|
92
|
-
export { ProseMirrorAttrIssue, ReadProseMirrorAttrsResult, expectBlockSdtAttrs, expectCharacterSpacingMarkAttrs, expectCharacterStyleMarkAttrs, expectCommentMarkAttrs, expectEmphasisMarkAttrs, expectFieldAttrs, expectFontFamilyMarkAttrs, expectFontSizeMarkAttrs, expectFootnoteRefMarkAttrs, expectHardBreakAttrs, expectHighlightMarkAttrs, expectHyperlinkMarkAttrs, expectImageAttrs, expectLanguageMarkAttrs, expectMathAttrs, expectPageBreakRunAttrs, expectPageBreakRunOwnerMarkAttrs, expectParagraphAttrs, expectRunFormattingOverrideMarkAttrs, expectRunPropertyChangeMarkAttrs, expectRunShadingMarkAttrs, expectSdtAttrs, expectShapeAttrs, expectStrikeMarkAttrs, expectSymbolAttrs, expectTabAttrs, expectTableAttrs, expectTableCellAttrs, expectTableRowAttrs, expectTextBoxAttrs, expectTextColorMarkAttrs, expectTextEffectMarkAttrs, expectTrackedChangeMarkAttrs, expectUnderlineMarkAttrs, mergeImageAttrs, mergeParagraphAttrs, mergeTableAttrs, mergeTableCellAttrs, mergeTableRowAttrs, readBlockSdtAttrs, readCharacterSpacingMarkAttrs, readCharacterStyleMarkAttrs, readCommentMarkAttrs, readEmphasisMarkAttrs, readFieldAttrs, readFontFamilyMarkAttrs, readFontSizeMarkAttrs, readFootnoteRefMarkAttrs, readHardBreakAttrs, readHighlightMarkAttrs, readHyperlinkMarkAttrs, readImageAttrs, readLanguageMarkAttrs, readMathAttrs, readPageBreakRunAttrs, readPageBreakRunOwnerMarkAttrs, readParagraphAttrs, readRunFormattingOverrideMarkAttrs, readRunPropertyChangeMarkAttrs, readRunShadingMarkAttrs, readSdtAttrs, readShapeAttrs, readStrikeMarkAttrs, readSymbolAttrs, readTabAttrs, readTableAttrs, readTableCellAttrs, readTableRowAttrs, readTextBoxAttrs, readTextColorMarkAttrs, readTextEffectMarkAttrs, readTrackedChangeMarkAttrs, readUnderlineMarkAttrs };
|
|
103
|
+
export { ProseMirrorAttrIssue, ReadProseMirrorAttrsResult, expectBlockSdtAttrs, expectCharacterSpacingMarkAttrs, expectCharacterStyleMarkAttrs, expectCommentMarkAttrs, expectEmphasisMarkAttrs, expectFieldAttrs, expectFontFamilyMarkAttrs, expectFontSizeMarkAttrs, expectFootnoteRefMarkAttrs, expectHardBreakAttrs, expectHighlightMarkAttrs, expectHyperlinkMarkAttrs, expectImageAttrs, expectInlineWrapperMarkAttrs, expectLanguageMarkAttrs, expectMathAttrs, expectPageBreakRunAttrs, expectPageBreakRunOwnerMarkAttrs, expectParagraphAttrs, expectPreservedBlockAttrs, expectPreservedXmlAttrs, expectRunFormattingOverrideMarkAttrs, expectRunPropertyChangeMarkAttrs, expectRunShadingMarkAttrs, expectSdtAttrs, expectShapeAttrs, expectStrikeMarkAttrs, expectSymbolAttrs, expectTabAttrs, expectTableAttrs, expectTableCellAttrs, expectTableRowAttrs, expectTextBoxAttrs, expectTextColorMarkAttrs, expectTextEffectMarkAttrs, expectTrackedChangeMarkAttrs, expectUnderlineMarkAttrs, mergeImageAttrs, mergeParagraphAttrs, mergeTableAttrs, mergeTableCellAttrs, mergeTableRowAttrs, readBlockSdtAttrs, readCharacterSpacingMarkAttrs, readCharacterStyleMarkAttrs, readCommentMarkAttrs, readEmphasisMarkAttrs, readFieldAttrs, readFontFamilyMarkAttrs, readFontSizeMarkAttrs, readFootnoteRefMarkAttrs, readHardBreakAttrs, readHighlightMarkAttrs, readHyperlinkMarkAttrs, readImageAttrs, readInlineWrapperMarkAttrs, readInlineWrapperStack, readLanguageMarkAttrs, readMathAttrs, readPageBreakRunAttrs, readPageBreakRunOwnerMarkAttrs, readParagraphAttrs, readPreservedBlockAttrs, readPreservedXmlAttrs, readRunFormattingOverrideMarkAttrs, readRunPropertyChangeMarkAttrs, readRunShadingMarkAttrs, readSdtAttrs, readShapeAttrs, readStrikeMarkAttrs, readSymbolAttrs, readTabAttrs, readTableAttrs, readTableCellAttrs, readTableRowAttrs, readTextBoxAttrs, readTextColorMarkAttrs, readTextEffectMarkAttrs, readTrackedChangeMarkAttrs, readUnderlineMarkAttrs };
|
|
@@ -5,10 +5,11 @@ import { canonicalJson } from "../../utils/canonicalJson.js";
|
|
|
5
5
|
import { normalizeHorizontalScalePercent } from "../../utils/horizontalScale.js";
|
|
6
6
|
import { isParagraphDirection } from "../paragraphDirection.js";
|
|
7
7
|
import { COMPLEX_SCRIPT_RUN_PROPERTY_KEYS, RUN_FORMATTING_BOOLEAN_PROPERTIES, RUN_FORMATTING_VALUE_PROPERTIES, TRACKED_CHANGE_PROVENANCE_VALUES } from "../schema/marks.js";
|
|
8
|
-
import { TEXT_BOX_TEXT_BODY_CONTENT_STATE_TYPES } from "../schema/nodes.js";
|
|
8
|
+
import { PRESERVED_XML_LEVELS, TEXT_BOX_TEXT_BODY_CONTENT_STATE_TYPES } from "../schema/nodes.js";
|
|
9
9
|
import { panic } from "better-result";
|
|
10
10
|
import { DRAWING_RAW_XML_MODES, isOoxmlSymbolCharacter } from "@stll/docx-core/model";
|
|
11
11
|
//#region src/prosemirror/attrs/index.ts
|
|
12
|
+
const PRESERVED_XML_LEVEL_VALUES = new Set(Object.values(PRESERVED_XML_LEVELS));
|
|
12
13
|
const SECTION_BREAK_TYPES = [
|
|
13
14
|
"nextPage",
|
|
14
15
|
"continuous",
|
|
@@ -53,6 +54,11 @@ const SHAPE_OUTLINE_CAPS = [
|
|
|
53
54
|
"round",
|
|
54
55
|
"square"
|
|
55
56
|
];
|
|
57
|
+
const SHAPE_OUTLINE_JOINS = [
|
|
58
|
+
"bevel",
|
|
59
|
+
"miter",
|
|
60
|
+
"round"
|
|
61
|
+
];
|
|
56
62
|
const SHAPE_LINE_END_TYPES = [
|
|
57
63
|
"none",
|
|
58
64
|
"triangle",
|
|
@@ -141,6 +147,8 @@ const hardBreakAttrsCache = /* @__PURE__ */ new WeakMap();
|
|
|
141
147
|
const pageBreakRunAttrsCache = /* @__PURE__ */ new WeakMap();
|
|
142
148
|
const tabAttrsCache = /* @__PURE__ */ new WeakMap();
|
|
143
149
|
const symbolAttrsCache = /* @__PURE__ */ new WeakMap();
|
|
150
|
+
const preservedXmlAttrsCache = /* @__PURE__ */ new WeakMap();
|
|
151
|
+
const preservedBlockAttrsCache = /* @__PURE__ */ new WeakMap();
|
|
144
152
|
const tableAttrsCache = /* @__PURE__ */ new WeakMap();
|
|
145
153
|
const tableRowAttrsCache = /* @__PURE__ */ new WeakMap();
|
|
146
154
|
const tableCellAttrsCache = /* @__PURE__ */ new WeakMap();
|
|
@@ -167,6 +175,7 @@ const commentAttrsCache = /* @__PURE__ */ new WeakMap();
|
|
|
167
175
|
const trackedChangeAttrsCache = /* @__PURE__ */ new WeakMap();
|
|
168
176
|
const runPropertyChangeAttrsCache = /* @__PURE__ */ new WeakMap();
|
|
169
177
|
const pageBreakRunOwnerAttrsCache = /* @__PURE__ */ new WeakMap();
|
|
178
|
+
const inlineWrapperAttrsCache = /* @__PURE__ */ new WeakMap();
|
|
170
179
|
const runFormattingOverrideAttrsCache = /* @__PURE__ */ new WeakMap();
|
|
171
180
|
const hyperlinkAttrsCache = /* @__PURE__ */ new WeakMap();
|
|
172
181
|
const readParagraphAttrs = (node) => {
|
|
@@ -252,6 +261,7 @@ const readParagraphAttrs = (node) => {
|
|
|
252
261
|
optionalAutospacingBase(attrs, "paragraph.attrs._autospacingBase", issues);
|
|
253
262
|
optionalSectionProperties(attrs, "_sectionProperties", "paragraph.attrs._sectionProperties", issues);
|
|
254
263
|
optionalPropertyChanges(attrs, "_propertyChanges", "paragraph.attrs._propertyChanges", issues, ["paragraphPropertyChange"]);
|
|
264
|
+
optionalPreservedAttributes(attrs, "paragraph.attrs._preservedAttributes", issues);
|
|
255
265
|
return attrsResult(attrs, issues);
|
|
256
266
|
};
|
|
257
267
|
const expectParagraphAttrs = (node) => expectCachedNodeAttrs(node, paragraphAttrsCache, readParagraphAttrs, "paragraph attrs");
|
|
@@ -299,6 +309,27 @@ const readSymbolAttrs = (node) => {
|
|
|
299
309
|
return attrsResult(attrs, issues);
|
|
300
310
|
};
|
|
301
311
|
const expectSymbolAttrs = (node) => expectCachedNodeAttrs(node, symbolAttrsCache, readSymbolAttrs, "symbol attrs");
|
|
312
|
+
const readPreservedXmlAttrs = (node) => {
|
|
313
|
+
const attrs = attrsRecord(node.attrs);
|
|
314
|
+
const issues = [];
|
|
315
|
+
expectNodeType(node, "preservedXml", issues);
|
|
316
|
+
requiredString(attrs, "xml", "preservedXml.attrs.xml", issues);
|
|
317
|
+
requiredString(attrs, "text", "preservedXml.attrs.text", issues);
|
|
318
|
+
if (!PRESERVED_XML_LEVEL_VALUES.has(attrs["level"])) issues.push({
|
|
319
|
+
path: "preservedXml.attrs.level",
|
|
320
|
+
message: `Expected one of ${[...PRESERVED_XML_LEVEL_VALUES].join(", ")}.`
|
|
321
|
+
});
|
|
322
|
+
return attrsResult(attrs, issues);
|
|
323
|
+
};
|
|
324
|
+
const expectPreservedXmlAttrs = (node) => expectCachedNodeAttrs(node, preservedXmlAttrsCache, readPreservedXmlAttrs, "preservedXml attrs");
|
|
325
|
+
const readPreservedBlockAttrs = (node) => {
|
|
326
|
+
const attrs = attrsRecord(node.attrs);
|
|
327
|
+
const issues = [];
|
|
328
|
+
expectNodeType(node, "preservedBlock", issues);
|
|
329
|
+
requiredString(attrs, "xml", "preservedBlock.attrs.xml", issues);
|
|
330
|
+
return attrsResult(attrs, issues);
|
|
331
|
+
};
|
|
332
|
+
const expectPreservedBlockAttrs = (node) => expectCachedNodeAttrs(node, preservedBlockAttrsCache, readPreservedBlockAttrs, "preservedBlock attrs");
|
|
302
333
|
const readTableAttrs = (node) => {
|
|
303
334
|
const attrs = attrsRecord(node.attrs);
|
|
304
335
|
const issues = [];
|
|
@@ -341,6 +372,7 @@ const readTableRowAttrs = (node) => {
|
|
|
341
372
|
path: "tableRow.attrs",
|
|
342
373
|
message: "Expected at most one structural revision marker."
|
|
343
374
|
});
|
|
375
|
+
optionalPreservedAttributes(attrs, "tableRow.attrs._preservedAttributes", issues);
|
|
344
376
|
return attrsResult(attrs, issues);
|
|
345
377
|
};
|
|
346
378
|
const expectTableRowAttrs = (node) => expectCachedNodeAttrs(node, tableRowAttrsCache, readTableRowAttrs, "table row attrs");
|
|
@@ -389,11 +421,16 @@ const readImageAttrs = (node) => {
|
|
|
389
421
|
optionalOneOf(attrs, "displayMode", "image.attrs.displayMode", issues, IMAGE_DISPLAY_MODES);
|
|
390
422
|
optionalOneOf(attrs, "cssFloat", "image.attrs.cssFloat", issues, IMAGE_CSS_FLOATS);
|
|
391
423
|
optionalString(attrs, "transform", "image.attrs.transform", issues);
|
|
424
|
+
optionalNumber(attrs, "docxRotation", "image.attrs.docxRotation", issues);
|
|
425
|
+
optionalBoolean(attrs, "docxFlipH", "image.attrs.docxFlipH", issues);
|
|
426
|
+
optionalBoolean(attrs, "docxFlipV", "image.attrs.docxFlipV", issues);
|
|
392
427
|
optionalNumber(attrs, "distTop", "image.attrs.distTop", issues);
|
|
393
428
|
optionalNumber(attrs, "distBottom", "image.attrs.distBottom", issues);
|
|
394
429
|
optionalNumber(attrs, "distLeft", "image.attrs.distLeft", issues);
|
|
395
430
|
optionalNumber(attrs, "distRight", "image.attrs.distRight", issues);
|
|
396
431
|
optionalNumber(attrs, "opacity", "image.attrs.opacity", issues);
|
|
432
|
+
optionalNumber(attrs, "brightness", "image.attrs.brightness", issues);
|
|
433
|
+
optionalNumber(attrs, "contrast", "image.attrs.contrast", issues);
|
|
397
434
|
optionalNumber(attrs, "cropTop", "image.attrs.cropTop", issues);
|
|
398
435
|
optionalNumber(attrs, "cropRight", "image.attrs.cropRight", issues);
|
|
399
436
|
optionalNumber(attrs, "cropBottom", "image.attrs.cropBottom", issues);
|
|
@@ -404,7 +441,11 @@ const readImageAttrs = (node) => {
|
|
|
404
441
|
optionalNumber(attrs, "paddingLeft", "image.attrs.paddingLeft", issues);
|
|
405
442
|
optionalImagePosition(attrs, "position", "image.attrs.position", issues);
|
|
406
443
|
optionalBoolean(attrs, "layoutInCell", "image.attrs.layoutInCell", issues);
|
|
444
|
+
optionalBoolean(attrs, "decorative", "image.attrs.decorative", issues);
|
|
445
|
+
optionalBoolean(attrs, "hidden", "image.attrs.hidden", issues);
|
|
446
|
+
optionalStringArray(attrs, "docPrExtensions", "image.attrs.docPrExtensions", issues);
|
|
407
447
|
optionalImageFrameLocks(attrs, "frameLocks", "image.attrs.frameLocks", issues);
|
|
448
|
+
optionalAuthoredEmu(attrs, "_docxAuthoredEmu", "image.attrs._docxAuthoredEmu", issues, IMAGE_AUTHORED_EMU_ATTRS);
|
|
408
449
|
optionalNumber(attrs, "borderWidth", "image.attrs.borderWidth", issues);
|
|
409
450
|
optionalString(attrs, "borderColor", "image.attrs.borderColor", issues);
|
|
410
451
|
optionalString(attrs, "borderStyle", "image.attrs.borderStyle", issues);
|
|
@@ -487,8 +528,12 @@ const readShapeAttrs = (node) => {
|
|
|
487
528
|
optionalString(attrs, "shapeType", "shape.attrs.shapeType", issues);
|
|
488
529
|
optionalString(attrs, "geometryAdjustments", "shape.attrs.geometryAdjustments", issues);
|
|
489
530
|
optionalString(attrs, "shapeId", "shape.attrs.shapeId", issues);
|
|
531
|
+
optionalString(attrs, "shapeName", "shape.attrs.shapeName", issues);
|
|
532
|
+
optionalString(attrs, "alt", "shape.attrs.alt", issues);
|
|
533
|
+
optionalString(attrs, "title", "shape.attrs.title", issues);
|
|
490
534
|
optionalNumber(attrs, "width", "shape.attrs.width", issues);
|
|
491
535
|
optionalNumber(attrs, "height", "shape.attrs.height", issues);
|
|
536
|
+
optionalAuthoredEmu(attrs, "_docxAuthoredEmu", "shape.attrs._docxAuthoredEmu", issues, SHAPE_AUTHORED_EMU_ATTRS);
|
|
492
537
|
optionalString(attrs, "fillColor", "shape.attrs.fillColor", issues);
|
|
493
538
|
optionalColorValue(attrs, "fillColorValue", "shape.attrs.fillColorValue", issues);
|
|
494
539
|
optionalOneOf(attrs, "fillType", "shape.attrs.fillType", issues, SHAPE_FILL_TYPES);
|
|
@@ -500,9 +545,13 @@ const readShapeAttrs = (node) => {
|
|
|
500
545
|
optionalColorValue(attrs, "outlineColorValue", "shape.attrs.outlineColorValue", issues);
|
|
501
546
|
optionalOneOf(attrs, "outlineStyle", "shape.attrs.outlineStyle", issues, OUTLINE_STYLE_ATTR_VALUES);
|
|
502
547
|
optionalOneOf(attrs, "outlineCap", "shape.attrs.outlineCap", issues, SHAPE_OUTLINE_CAPS);
|
|
548
|
+
optionalOneOf(attrs, "outlineJoin", "shape.attrs.outlineJoin", issues, SHAPE_OUTLINE_JOINS);
|
|
503
549
|
optionalShapeLineEnd(attrs, "outlineHeadEnd", "shape.attrs.outlineHeadEnd", issues);
|
|
504
550
|
optionalShapeLineEnd(attrs, "outlineTailEnd", "shape.attrs.outlineTailEnd", issues);
|
|
505
551
|
optionalString(attrs, "transform", "shape.attrs.transform", issues);
|
|
552
|
+
optionalNumber(attrs, "docxRotation", "shape.attrs.docxRotation", issues);
|
|
553
|
+
optionalBoolean(attrs, "docxFlipH", "shape.attrs.docxFlipH", issues);
|
|
554
|
+
optionalBoolean(attrs, "docxFlipV", "shape.attrs.docxFlipV", issues);
|
|
506
555
|
optionalOneOf(attrs, "displayMode", "shape.attrs.displayMode", issues, IMAGE_DISPLAY_MODES);
|
|
507
556
|
optionalOneOf(attrs, "cssFloat", "shape.attrs.cssFloat", issues, IMAGE_CSS_FLOATS);
|
|
508
557
|
optionalOneOf(attrs, "wrapType", "shape.attrs.wrapType", issues, IMAGE_WRAP_TYPE_VALUES);
|
|
@@ -531,11 +580,18 @@ const readTextBoxAttrs = (node) => {
|
|
|
531
580
|
optionalWordArt(attrs, "wordArt", "textBox.attrs.wordArt", issues);
|
|
532
581
|
optionalOneOf(attrs, "textWrap", "textBox.attrs.textWrap", issues, TEXT_BOX_TEXT_WRAP_VALUES);
|
|
533
582
|
optionalString(attrs, "textBoxId", "textBox.attrs.textBoxId", issues);
|
|
583
|
+
optionalString(attrs, "textBoxName", "textBox.attrs.textBoxName", issues);
|
|
584
|
+
optionalString(attrs, "alt", "textBox.attrs.alt", issues);
|
|
585
|
+
optionalString(attrs, "title", "textBox.attrs.title", issues);
|
|
534
586
|
optionalString(attrs, "fillColor", "textBox.attrs.fillColor", issues);
|
|
535
587
|
optionalNumber(attrs, "outlineWidth", "textBox.attrs.outlineWidth", issues);
|
|
588
|
+
optionalAuthoredEmu(attrs, "_docxAuthoredEmu", "textBox.attrs._docxAuthoredEmu", issues, TEXT_BOX_AUTHORED_EMU_ATTRS);
|
|
536
589
|
optionalString(attrs, "outlineColor", "textBox.attrs.outlineColor", issues);
|
|
537
590
|
optionalOneOf(attrs, "outlineStyle", "textBox.attrs.outlineStyle", issues, OUTLINE_STYLE_ATTR_VALUES);
|
|
538
591
|
optionalTextBoxTransform(attrs, "transform", "textBox.attrs.transform", issues);
|
|
592
|
+
optionalNumber(attrs, "docxRotation", "textBox.attrs.docxRotation", issues);
|
|
593
|
+
optionalBoolean(attrs, "docxFlipH", "textBox.attrs.docxFlipH", issues);
|
|
594
|
+
optionalBoolean(attrs, "docxFlipV", "textBox.attrs.docxFlipV", issues);
|
|
539
595
|
optionalNumber(attrs, "marginTop", "textBox.attrs.marginTop", issues);
|
|
540
596
|
optionalNumber(attrs, "marginBottom", "textBox.attrs.marginBottom", issues);
|
|
541
597
|
optionalNumber(attrs, "marginLeft", "textBox.attrs.marginLeft", issues);
|
|
@@ -556,6 +612,7 @@ const readTextBoxAttrs = (node) => {
|
|
|
556
612
|
requiredTextBoxBodyContentState(attrs, issues);
|
|
557
613
|
optionalTextBoxTrackedChange(attrs, issues);
|
|
558
614
|
optionalTextBoxInlineSdts(attrs, issues);
|
|
615
|
+
optionalPreservedAttributes(attrs, "textBox.attrs._preservedAttributes", issues);
|
|
559
616
|
return attrsResult(attrs, issues);
|
|
560
617
|
};
|
|
561
618
|
const expectTextBoxAttrs = (node) => expectCachedNodeAttrs(node, textBoxAttrsCache, readTextBoxAttrs, "text box attrs");
|
|
@@ -734,6 +791,89 @@ const readPageBreakRunOwnerMarkAttrs = (mark) => {
|
|
|
734
791
|
return attrsResult(attrs, issues);
|
|
735
792
|
};
|
|
736
793
|
const expectPageBreakRunOwnerMarkAttrs = (mark) => expectCachedMarkAttrs(mark, pageBreakRunOwnerAttrsCache, readPageBreakRunOwnerMarkAttrs, "page break run owner attrs");
|
|
794
|
+
const BIDI_LAYER_CONTROLS = ["embedding", "override"];
|
|
795
|
+
const BIDI_LAYER_DIRECTIONS = ["ltr", "rtl"];
|
|
796
|
+
const BIDI_LAYER_KEYS = /* @__PURE__ */ new Set([
|
|
797
|
+
"kind",
|
|
798
|
+
"control",
|
|
799
|
+
"direction"
|
|
800
|
+
]);
|
|
801
|
+
/**
|
|
802
|
+
* One validator per wrapper kind, total over the kinds the model declares: a
|
|
803
|
+
* kind added without a field-by-field check does not compile, and a layer that
|
|
804
|
+
* states a field its kind does not carry (a smart tag with a bidi `control`)
|
|
805
|
+
* is rejected rather than stored and written back.
|
|
806
|
+
*/
|
|
807
|
+
const INLINE_WRAPPER_LAYER_VALIDATORS = { bidi: (layer, path, issues) => {
|
|
808
|
+
requiredOneOf(layer, "control", `${path}.control`, issues, BIDI_LAYER_CONTROLS);
|
|
809
|
+
optionalOneOf(layer, "direction", `${path}.direction`, issues, BIDI_LAYER_DIRECTIONS);
|
|
810
|
+
for (const key of Object.keys(layer)) if (!BIDI_LAYER_KEYS.has(key)) issues.push({
|
|
811
|
+
path: `${path}.${key}`,
|
|
812
|
+
message: "Unexpected bidi wrapper property."
|
|
813
|
+
});
|
|
814
|
+
} };
|
|
815
|
+
const inlineWrapperLayerValidator = (kind) => {
|
|
816
|
+
return typeof kind === "string" ? INLINE_WRAPPER_LAYER_VALIDATORS[kind] : void 0;
|
|
817
|
+
};
|
|
818
|
+
const validateInlineWrapperStack = (value, path, issues) => {
|
|
819
|
+
if (!Array.isArray(value)) {
|
|
820
|
+
issues.push({
|
|
821
|
+
path,
|
|
822
|
+
message: "Expected an array of inline wrapper layers."
|
|
823
|
+
});
|
|
824
|
+
return;
|
|
825
|
+
}
|
|
826
|
+
if (value.length === 0) {
|
|
827
|
+
issues.push({
|
|
828
|
+
path,
|
|
829
|
+
message: "Expected at least one inline wrapper layer."
|
|
830
|
+
});
|
|
831
|
+
return;
|
|
832
|
+
}
|
|
833
|
+
for (const [index, layer] of value.entries()) {
|
|
834
|
+
const layerPath = `${path}[${index}]`;
|
|
835
|
+
if (!isRecord(layer)) {
|
|
836
|
+
issues.push({
|
|
837
|
+
path: layerPath,
|
|
838
|
+
message: "Expected an inline wrapper layer object."
|
|
839
|
+
});
|
|
840
|
+
continue;
|
|
841
|
+
}
|
|
842
|
+
const validator = inlineWrapperLayerValidator(layer["kind"]);
|
|
843
|
+
if (!validator) {
|
|
844
|
+
issues.push({
|
|
845
|
+
path: `${layerPath}.kind`,
|
|
846
|
+
message: `Expected one of ${Object.keys(INLINE_WRAPPER_LAYER_VALIDATORS).join(", ")}.`
|
|
847
|
+
});
|
|
848
|
+
continue;
|
|
849
|
+
}
|
|
850
|
+
validator(layer, layerPath, issues);
|
|
851
|
+
}
|
|
852
|
+
};
|
|
853
|
+
/**
|
|
854
|
+
* A wrapper stack read from outside the editor — the DOM on paste, a stored
|
|
855
|
+
* snapshot — validated layer by layer.
|
|
856
|
+
*/
|
|
857
|
+
const readInlineWrapperStack = (value, path = "inlineWrapper.attrs.stack") => {
|
|
858
|
+
const issues = [];
|
|
859
|
+
validateInlineWrapperStack(value, path, issues);
|
|
860
|
+
if (issues.length > 0) return {
|
|
861
|
+
ok: false,
|
|
862
|
+
issues
|
|
863
|
+
};
|
|
864
|
+
return {
|
|
865
|
+
ok: true,
|
|
866
|
+
value
|
|
867
|
+
};
|
|
868
|
+
};
|
|
869
|
+
const readInlineWrapperMarkAttrs = (mark) => {
|
|
870
|
+
const attrs = attrsRecord(mark.attrs);
|
|
871
|
+
const issues = [];
|
|
872
|
+
expectMarkType(mark, "inlineWrapper", issues);
|
|
873
|
+
validateInlineWrapperStack(attrs["stack"], "inlineWrapper.attrs.stack", issues);
|
|
874
|
+
return attrsResult(attrs, issues);
|
|
875
|
+
};
|
|
876
|
+
const expectInlineWrapperMarkAttrs = (mark) => expectCachedMarkAttrs(mark, inlineWrapperAttrsCache, readInlineWrapperMarkAttrs, "inline wrapper attrs");
|
|
737
877
|
const readRunFormattingOverrideMarkAttrs = (mark) => {
|
|
738
878
|
const attrs = attrsRecord(mark.attrs);
|
|
739
879
|
const issues = [];
|
|
@@ -1288,6 +1428,37 @@ const validateSdtAttrsRecord = (attrs, path, issues) => {
|
|
|
1288
1428
|
optionalString(attrs, "rawPropertiesXml", `${path}.rawPropertiesXml`, issues);
|
|
1289
1429
|
optionalString(attrs, "rawEndPropertiesXml", `${path}.rawEndPropertiesXml`, issues);
|
|
1290
1430
|
};
|
|
1431
|
+
/**
|
|
1432
|
+
* The attribute remainder an authored element's record carries.
|
|
1433
|
+
*
|
|
1434
|
+
* Every entry is a resolved name and a string value; nothing here is a
|
|
1435
|
+
* spelling, which is why the namespace is a URI and optional rather than a
|
|
1436
|
+
* prefix. See `docx/attributeRemainder.ts`.
|
|
1437
|
+
*/
|
|
1438
|
+
const optionalPreservedAttributes = (attrs, path, issues) => {
|
|
1439
|
+
const value = attrs["_preservedAttributes"];
|
|
1440
|
+
if (value === void 0 || value === null) return;
|
|
1441
|
+
if (!Array.isArray(value)) {
|
|
1442
|
+
issues.push({
|
|
1443
|
+
path,
|
|
1444
|
+
message: "Expected an array."
|
|
1445
|
+
});
|
|
1446
|
+
return;
|
|
1447
|
+
}
|
|
1448
|
+
for (const [index, entry] of value.entries()) {
|
|
1449
|
+
const entryPath = `${path}[${index}]`;
|
|
1450
|
+
if (!isRecord(entry)) {
|
|
1451
|
+
issues.push({
|
|
1452
|
+
path: entryPath,
|
|
1453
|
+
message: "Expected an object."
|
|
1454
|
+
});
|
|
1455
|
+
continue;
|
|
1456
|
+
}
|
|
1457
|
+
requiredString(entry, "name", `${entryPath}.name`, issues);
|
|
1458
|
+
requiredString(entry, "value", `${entryPath}.value`, issues);
|
|
1459
|
+
optionalString(entry, "namespace", `${entryPath}.namespace`, issues);
|
|
1460
|
+
}
|
|
1461
|
+
};
|
|
1291
1462
|
const optionalAutospacingBase = (attrs, path, issues) => {
|
|
1292
1463
|
const value = attrs["_autospacingBase"];
|
|
1293
1464
|
if (value === void 0 || value === null) return;
|
|
@@ -1784,6 +1955,57 @@ const validatePropertyChangeInfo = (value, path, issues) => {
|
|
|
1784
1955
|
optionalOneOf(value, "provenance", `${path}.provenance`, issues, TRACKED_CHANGE_PROVENANCE_VALUES);
|
|
1785
1956
|
optionalString(value, "suggestionId", `${path}.suggestionId`, issues);
|
|
1786
1957
|
};
|
|
1958
|
+
/**
|
|
1959
|
+
* The authored-EMU carrier: a sparse record of finite numbers keyed by the
|
|
1960
|
+
* pixel attribute each one was projected into. The keys are the node's own, so
|
|
1961
|
+
* they are checked against the list the caller passes rather than a shared one.
|
|
1962
|
+
*/
|
|
1963
|
+
const optionalAuthoredEmu = (attrs, key, path, issues, allowed) => {
|
|
1964
|
+
const value = attrs[key];
|
|
1965
|
+
if (value === void 0 || value === null) return;
|
|
1966
|
+
if (!isRecord(value)) {
|
|
1967
|
+
issues.push({
|
|
1968
|
+
path,
|
|
1969
|
+
message: "Expected an object."
|
|
1970
|
+
});
|
|
1971
|
+
return;
|
|
1972
|
+
}
|
|
1973
|
+
for (const name of Object.keys(value)) {
|
|
1974
|
+
if (!allowed.includes(name)) {
|
|
1975
|
+
issues.push({
|
|
1976
|
+
path: `${path}.${name}`,
|
|
1977
|
+
message: "Not a pixel attribute of this node."
|
|
1978
|
+
});
|
|
1979
|
+
continue;
|
|
1980
|
+
}
|
|
1981
|
+
optionalNumber(value, name, `${path}.${name}`, issues);
|
|
1982
|
+
}
|
|
1983
|
+
};
|
|
1984
|
+
const WRAP_DISTANCE_ATTRS = [
|
|
1985
|
+
"distTop",
|
|
1986
|
+
"distBottom",
|
|
1987
|
+
"distLeft",
|
|
1988
|
+
"distRight"
|
|
1989
|
+
];
|
|
1990
|
+
const TEXT_BOX_MARGIN_ATTRS = [
|
|
1991
|
+
"marginTop",
|
|
1992
|
+
"marginBottom",
|
|
1993
|
+
"marginLeft",
|
|
1994
|
+
"marginRight"
|
|
1995
|
+
];
|
|
1996
|
+
const IMAGE_AUTHORED_EMU_ATTRS = [
|
|
1997
|
+
"width",
|
|
1998
|
+
"height",
|
|
1999
|
+
"borderWidth",
|
|
2000
|
+
...WRAP_DISTANCE_ATTRS
|
|
2001
|
+
];
|
|
2002
|
+
const SHAPE_AUTHORED_EMU_ATTRS = [
|
|
2003
|
+
"width",
|
|
2004
|
+
"height",
|
|
2005
|
+
"outlineWidth",
|
|
2006
|
+
...WRAP_DISTANCE_ATTRS
|
|
2007
|
+
];
|
|
2008
|
+
const TEXT_BOX_AUTHORED_EMU_ATTRS = [...SHAPE_AUTHORED_EMU_ATTRS, ...TEXT_BOX_MARGIN_ATTRS];
|
|
1787
2009
|
const optionalImageFrameLocks = (attrs, key, path, issues) => {
|
|
1788
2010
|
const value = attrs[key];
|
|
1789
2011
|
if (value === void 0 || value === null) return;
|
|
@@ -1955,4 +2177,4 @@ const optionalEmptyHyperlinkArray = (value, issues) => {
|
|
|
1955
2177
|
}
|
|
1956
2178
|
};
|
|
1957
2179
|
//#endregion
|
|
1958
|
-
export { expectBlockSdtAttrs, expectCharacterSpacingMarkAttrs, expectCharacterStyleMarkAttrs, expectCommentMarkAttrs, expectEmphasisMarkAttrs, expectFieldAttrs, expectFontFamilyMarkAttrs, expectFontSizeMarkAttrs, expectFootnoteRefMarkAttrs, expectHardBreakAttrs, expectHighlightMarkAttrs, expectHyperlinkMarkAttrs, expectImageAttrs, expectLanguageMarkAttrs, expectMathAttrs, expectPageBreakRunAttrs, expectPageBreakRunOwnerMarkAttrs, expectParagraphAttrs, expectRunFormattingOverrideMarkAttrs, expectRunPropertyChangeMarkAttrs, expectRunShadingMarkAttrs, expectSdtAttrs, expectShapeAttrs, expectStrikeMarkAttrs, expectSymbolAttrs, expectTabAttrs, expectTableAttrs, expectTableCellAttrs, expectTableRowAttrs, expectTextBoxAttrs, expectTextColorMarkAttrs, expectTextEffectMarkAttrs, expectTrackedChangeMarkAttrs, expectUnderlineMarkAttrs, mergeImageAttrs, mergeParagraphAttrs, mergeTableAttrs, mergeTableCellAttrs, mergeTableRowAttrs, readBlockSdtAttrs, readCharacterSpacingMarkAttrs, readCharacterStyleMarkAttrs, readCommentMarkAttrs, readEmphasisMarkAttrs, readFieldAttrs, readFontFamilyMarkAttrs, readFontSizeMarkAttrs, readFootnoteRefMarkAttrs, readHardBreakAttrs, readHighlightMarkAttrs, readHyperlinkMarkAttrs, readImageAttrs, readLanguageMarkAttrs, readMathAttrs, readPageBreakRunAttrs, readPageBreakRunOwnerMarkAttrs, readParagraphAttrs, readRunFormattingOverrideMarkAttrs, readRunPropertyChangeMarkAttrs, readRunShadingMarkAttrs, readSdtAttrs, readShapeAttrs, readStrikeMarkAttrs, readSymbolAttrs, readTabAttrs, readTableAttrs, readTableCellAttrs, readTableRowAttrs, readTextBoxAttrs, readTextColorMarkAttrs, readTextEffectMarkAttrs, readTrackedChangeMarkAttrs, readUnderlineMarkAttrs };
|
|
2180
|
+
export { expectBlockSdtAttrs, expectCharacterSpacingMarkAttrs, expectCharacterStyleMarkAttrs, expectCommentMarkAttrs, expectEmphasisMarkAttrs, expectFieldAttrs, expectFontFamilyMarkAttrs, expectFontSizeMarkAttrs, expectFootnoteRefMarkAttrs, expectHardBreakAttrs, expectHighlightMarkAttrs, expectHyperlinkMarkAttrs, expectImageAttrs, expectInlineWrapperMarkAttrs, expectLanguageMarkAttrs, expectMathAttrs, expectPageBreakRunAttrs, expectPageBreakRunOwnerMarkAttrs, expectParagraphAttrs, expectPreservedBlockAttrs, expectPreservedXmlAttrs, expectRunFormattingOverrideMarkAttrs, expectRunPropertyChangeMarkAttrs, expectRunShadingMarkAttrs, expectSdtAttrs, expectShapeAttrs, expectStrikeMarkAttrs, expectSymbolAttrs, expectTabAttrs, expectTableAttrs, expectTableCellAttrs, expectTableRowAttrs, expectTextBoxAttrs, expectTextColorMarkAttrs, expectTextEffectMarkAttrs, expectTrackedChangeMarkAttrs, expectUnderlineMarkAttrs, mergeImageAttrs, mergeParagraphAttrs, mergeTableAttrs, mergeTableCellAttrs, mergeTableRowAttrs, readBlockSdtAttrs, readCharacterSpacingMarkAttrs, readCharacterStyleMarkAttrs, readCommentMarkAttrs, readEmphasisMarkAttrs, readFieldAttrs, readFontFamilyMarkAttrs, readFontSizeMarkAttrs, readFootnoteRefMarkAttrs, readHardBreakAttrs, readHighlightMarkAttrs, readHyperlinkMarkAttrs, readImageAttrs, readInlineWrapperMarkAttrs, readInlineWrapperStack, readLanguageMarkAttrs, readMathAttrs, readPageBreakRunAttrs, readPageBreakRunOwnerMarkAttrs, readParagraphAttrs, readPreservedBlockAttrs, readPreservedXmlAttrs, readRunFormattingOverrideMarkAttrs, readRunPropertyChangeMarkAttrs, readRunShadingMarkAttrs, readSdtAttrs, readShapeAttrs, readStrikeMarkAttrs, readSymbolAttrs, readTabAttrs, readTableAttrs, readTableCellAttrs, readTableRowAttrs, readTextBoxAttrs, readTextColorMarkAttrs, readTextEffectMarkAttrs, readTrackedChangeMarkAttrs, readUnderlineMarkAttrs };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { document_d_exports } from "../types/document.js";
|
|
2
|
+
//#region src/prosemirror/authoredTransformAttrs.d.ts
|
|
3
|
+
/** The transform attrs a drawing node (`image`, `shape`, `textBox`) carries. */
|
|
4
|
+
type AuthoredTransformAttrs = {
|
|
5
|
+
docxFlipH: boolean | null;
|
|
6
|
+
docxFlipV: boolean | null;
|
|
7
|
+
docxRotation: number | null;
|
|
8
|
+
/** The rendered CSS, derived from the three above. */
|
|
9
|
+
transform: string | undefined;
|
|
10
|
+
};
|
|
11
|
+
/** What a drawing node's attrs say, as they arrive from a persisted document. */
|
|
12
|
+
type ReadableTransformAttrs = {
|
|
13
|
+
docxFlipH?: boolean | null;
|
|
14
|
+
docxFlipV?: boolean | null;
|
|
15
|
+
docxRotation?: number | null;
|
|
16
|
+
transform?: string;
|
|
17
|
+
};
|
|
18
|
+
/** Project a model transform onto a drawing node's attrs. */
|
|
19
|
+
declare const authoredTransformAttrs: (transform: document_d_exports.ImageTransform | undefined) => AuthoredTransformAttrs;
|
|
20
|
+
/**
|
|
21
|
+
* Read a drawing node's authored transform back.
|
|
22
|
+
*
|
|
23
|
+
* The attrs are the record; the CSS string answers only for a node that states
|
|
24
|
+
* none of them, which is how a node persisted before they existed arrives.
|
|
25
|
+
*/
|
|
26
|
+
declare const readAuthoredTransform: (attrs: ReadableTransformAttrs) => document_d_exports.ImageTransform | undefined;
|
|
27
|
+
//#endregion
|
|
28
|
+
export { authoredTransformAttrs, readAuthoredTransform };
|