diff --git a/.github/workflows/demos.yml b/.github/workflows/demos.yml index b8154cf1ac..1d433bf604 100644 --- a/.github/workflows/demos.yml +++ b/.github/workflows/demos.yml @@ -18,27 +18,26 @@ jobs: steps: - uses: actions/checkout@v5 - uses: "./.github/actions/install-and-build" - - name: Install xmllint - run: | - sudo apt-get update - sudo apt-get install -y --no-install-recommends libxml2-utils - # Each shard runs every fourth demo, and checks the document it writes against the bundled schemas + # Microsoft's Open XML SDK validator. It's installed only here, as it is 80 MB + - name: Install the Open XML SDK validator + run: npm install --no-save --no-audit --no-fund @xarsh/ooxml-validator@0.3.0 + # Each shard runs every fourth demo, and checks the document it writes with the Open XML SDK validator, which + # checks every part against Office's schemas, including Word 2010's extensions. It's checked as each version of + # Office since 2010 reads it: older versions skip the newer extensions and read their fallbacks. Office 2007 is + # left out, as it only knows the standard's first edition, from before ISO/IEC 29500, and rejects what Word + # itself writes. + # The validator checks only the first file it's given (each demo writes one), and its option is + # --officeVersion, not the --office-version its README gives. It reads a version it doesn't know as Microsoft365 - name: Run and validate the demos shell: bash - env: - # Demos whose document doesn't match the bundled schemas yet. Demo 19 writes the document as base64 - SKIP_VALIDATION: 19 34 55 60 61 75 85 87 88 89 90 96 98 99 107 108 109 110 111 112 113 115 116 117 118 120 run: | for demo in $(ls demo/[0-9]*.ts | sort -V | awk -v n=${{ strategy.job-total }} -v i=${{ strategy.job-index }} 'NR % n == i'); do echo "::group::$demo" rm -f ./*.docx npm run --silent run-ts -- "$demo" - if [[ " $SKIP_VALIDATION " == *" $(basename "$demo" | cut -d- -f1) "* ]]; then - echo "Not validated" - else - docx=(./*.docx) - unzip -p "${docx[0]}" word/document.xml | xmllint --noout --schema ooxml-schemas/microsoft/wml-2010.xsd - - unzip -p "${docx[0]}" word/theme/theme1.xml | xmllint --noout --schema ooxml-schemas/ISO-IEC29500-4_2016/dml-main.xsd - - fi + for version in Office2010 Office2013 Office2016 Office2019 Office2021 Microsoft365; do + echo "$version" + npx ooxml-validator ./*.docx --officeVersion "$version" + done echo "::endgroup::" done diff --git a/.github/workflows/shape-demos.yml b/.github/workflows/shape-demos.yml index 840c41346d..021c4317b9 100644 --- a/.github/workflows/shape-demos.yml +++ b/.github/workflows/shape-demos.yml @@ -14,10 +14,6 @@ jobs: steps: - uses: actions/checkout@v5 - uses: "./.github/actions/install-and-build" - - name: Install xmllint - run: | - sudo apt-get update - sudo apt-get install -y --no-install-recommends libxml2-utils - uses: docker/setup-buildx-action@v3 # The pinned LibreOffice and fonts the reference images were drawn with - name: Build the image the pages are drawn in diff --git a/demo/11-declarative-styles-2.ts b/demo/11-declarative-styles-2.ts index 9f7981de21..98b362e223 100644 --- a/demo/11-declarative-styles-2.ts +++ b/demo/11-declarative-styles-2.ts @@ -222,6 +222,7 @@ const doc = new Document({ new Paragraph({ children: [ new ImageRun({ + type: "gif", data: fs.readFileSync("./demo/images/pizza.gif"), transformation: { width: 100, @@ -271,6 +272,7 @@ const doc = new Document({ new Paragraph({ children: [ new ImageRun({ + type: "gif", data: fs.readFileSync("./demo/images/pizza.gif"), transformation: { width: 100, @@ -286,6 +288,7 @@ const doc = new Document({ new Paragraph({ children: [ new ImageRun({ + type: "gif", data: fs.readFileSync("./demo/images/pizza.gif"), transformation: { width: 100, diff --git a/demo/12-scaling-images.ts b/demo/12-scaling-images.ts index 84d92e6b7b..00afc9f99d 100644 --- a/demo/12-scaling-images.ts +++ b/demo/12-scaling-images.ts @@ -11,6 +11,7 @@ const doc = new Document({ new Paragraph({ children: [ new ImageRun({ + type: "gif", data: fs.readFileSync("./demo/images/pizza.gif"), transformation: { width: 50, @@ -22,6 +23,7 @@ const doc = new Document({ new Paragraph({ children: [ new ImageRun({ + type: "gif", data: fs.readFileSync("./demo/images/pizza.gif"), transformation: { width: 100, @@ -33,6 +35,7 @@ const doc = new Document({ new Paragraph({ children: [ new ImageRun({ + type: "gif", data: fs.readFileSync("./demo/images/pizza.gif"), transformation: { width: 250, @@ -44,6 +47,7 @@ const doc = new Document({ new Paragraph({ children: [ new ImageRun({ + type: "gif", data: fs.readFileSync("./demo/images/pizza.gif"), transformation: { width: 400, diff --git a/demo/18-image-from-buffer.ts b/demo/18-image-from-buffer.ts index 918cc1958c..c96a7783f8 100644 --- a/demo/18-image-from-buffer.ts +++ b/demo/18-image-from-buffer.ts @@ -12,6 +12,7 @@ const doc = new Document({ new Paragraph({ children: [ new ImageRun({ + type: "png", data: Buffer.from(imageBase64Data, "base64"), transformation: { width: 100, diff --git a/demo/19-export-to-base64.ts b/demo/19-export-to-base64.ts index 669f8f8ca2..fcabe5ef11 100644 --- a/demo/19-export-to-base64.ts +++ b/demo/19-export-to-base64.ts @@ -26,5 +26,6 @@ const doc = new Document({ }); Packer.toBase64String(doc).then((str) => { - fs.writeFileSync("My Document.docx", str); + // The string can be sent on as it is, such as in a data URI. Decoded, it is the document + fs.writeFileSync("My Document.docx", Buffer.from(str, "base64")); }); diff --git a/demo/23-base64-images.ts b/demo/23-base64-images.ts index df2e92217c..f88746fe3d 100644 --- a/demo/23-base64-images.ts +++ b/demo/23-base64-images.ts @@ -13,6 +13,7 @@ const doc = new Document({ children: [ new TextRun("Hello World"), new ImageRun({ + type: "bmp", data: fs.readFileSync("./demo/images/parrots.bmp"), transformation: { width: 100, @@ -24,6 +25,7 @@ const doc = new Document({ new Paragraph({ children: [ new ImageRun({ + type: "jpg", data: fs.readFileSync("./demo/images/image1.jpeg"), transformation: { width: 100, @@ -35,6 +37,7 @@ const doc = new Document({ new Paragraph({ children: [ new ImageRun({ + type: "png", data: fs.readFileSync("./demo/images/dog.png"), transformation: { width: 100, @@ -46,6 +49,7 @@ const doc = new Document({ new Paragraph({ children: [ new ImageRun({ + type: "jpg", data: fs.readFileSync("./demo/images/cat.jpg"), transformation: { width: 100, @@ -57,6 +61,7 @@ const doc = new Document({ new Paragraph({ children: [ new ImageRun({ + type: "bmp", data: fs.readFileSync("./demo/images/parrots.bmp"), transformation: { width: 100, @@ -68,6 +73,7 @@ const doc = new Document({ new Paragraph({ children: [ new ImageRun({ + type: "png", data: Buffer.from(imageBase64Data, "base64"), transformation: { width: 100, diff --git a/demo/24-images-to-table-cell.ts b/demo/24-images-to-table-cell.ts index e2187f6240..de6b9b167f 100644 --- a/demo/24-images-to-table-cell.ts +++ b/demo/24-images-to-table-cell.ts @@ -35,6 +35,7 @@ const doc = new Document({ new Paragraph({ children: [ new ImageRun({ + type: "jpg", data: fs.readFileSync("./demo/images/image1.jpeg"), transformation: { width: 100, diff --git a/demo/35-hyperlinks.ts b/demo/35-hyperlinks.ts index 6af7bab49e..a1c579bd21 100644 --- a/demo/35-hyperlinks.ts +++ b/demo/35-hyperlinks.ts @@ -98,6 +98,7 @@ const doc = new Document({ new ExternalHyperlink({ children: [ new ImageRun({ + type: "jpg", data: fs.readFileSync("./demo/images/image1.jpeg"), transformation: { width: 100, diff --git a/demo/36-image-to-table-cell.ts b/demo/36-image-to-table-cell.ts index 8f2452a3ff..7ad49c57b8 100644 --- a/demo/36-image-to-table-cell.ts +++ b/demo/36-image-to-table-cell.ts @@ -31,6 +31,7 @@ const table = new Table({ new Paragraph({ children: [ new ImageRun({ + type: "jpg", data: fs.readFileSync("./demo/images/image1.jpeg"), transformation: { width: 100, diff --git a/demo/37-images-to-header-and-footer.ts b/demo/37-images-to-header-and-footer.ts index dfecb3b61e..906966f601 100644 --- a/demo/37-images-to-header-and-footer.ts +++ b/demo/37-images-to-header-and-footer.ts @@ -12,6 +12,7 @@ const doc = new Document({ new Paragraph({ children: [ new ImageRun({ + type: "jpg", data: fs.readFileSync("./demo/images/image1.jpeg"), transformation: { width: 100, @@ -23,6 +24,7 @@ const doc = new Document({ new Paragraph({ children: [ new ImageRun({ + type: "gif", data: fs.readFileSync("./demo/images/pizza.gif"), transformation: { width: 100, @@ -34,6 +36,7 @@ const doc = new Document({ new Paragraph({ children: [ new ImageRun({ + type: "jpg", data: fs.readFileSync("./demo/images/image1.jpeg"), transformation: { width: 100, diff --git a/demo/38-text-wrapping.ts b/demo/38-text-wrapping.ts index e726c237ae..8bf6ea6c66 100644 --- a/demo/38-text-wrapping.ts +++ b/demo/38-text-wrapping.ts @@ -20,6 +20,7 @@ const doc = new Document({ new Paragraph({ children: [ new ImageRun({ + type: "gif", data: fs.readFileSync("./demo/images/pizza.gif"), transformation: { width: 200, diff --git a/demo/43-images-to-table-cell-2.ts b/demo/43-images-to-table-cell-2.ts index ed3c919dc2..88f451f963 100644 --- a/demo/43-images-to-table-cell-2.ts +++ b/demo/43-images-to-table-cell-2.ts @@ -27,6 +27,7 @@ const table = new Table({ new Paragraph({ children: [ new ImageRun({ + type: "png", data: Buffer.from(imageBase64Data, "base64"), transformation: { width: 100, @@ -49,6 +50,7 @@ const table = new Table({ new Paragraph({ children: [ new ImageRun({ + type: "jpg", data: fs.readFileSync("./demo/images/image1.jpeg"), transformation: { width: 100, diff --git a/demo/9-images-in-header-and-footer.ts b/demo/9-images-in-header-and-footer.ts index 705ae57eb4..e9cf960404 100644 --- a/demo/9-images-in-header-and-footer.ts +++ b/demo/9-images-in-header-and-footer.ts @@ -12,6 +12,7 @@ const doc = new Document({ new Paragraph({ children: [ new ImageRun({ + type: "gif", data: fs.readFileSync("./demo/images/pizza.gif"), transformation: { width: 100, @@ -29,6 +30,7 @@ const doc = new Document({ new Paragraph({ children: [ new ImageRun({ + type: "gif", data: fs.readFileSync("./demo/images/pizza.gif"), transformation: { width: 100, diff --git a/demo/98-track-revisions-2.ts b/demo/98-track-revisions-2.ts index a733d860da..207a12fb12 100644 --- a/demo/98-track-revisions-2.ts +++ b/demo/98-track-revisions-2.ts @@ -35,7 +35,7 @@ const doc = new Document({ alignment: AlignmentType.CENTER, heading: "Heading1", revision: { - id: 10, + id: 0, author: REVISION_AUTHOR, date: REVISION_DATE, alignment: AlignmentType.LEFT, @@ -70,7 +70,7 @@ const doc = new Document({ children: [new TextRun("Inserted row cell")], run: { insertion: { - id: 0, + id: 1, author: REVISION_AUTHOR, date: REVISION_DATE, }, @@ -84,7 +84,7 @@ const doc = new Document({ children: [new TextRun("Inserted row cell")], run: { insertion: { - id: 0, + id: 2, author: REVISION_AUTHOR, date: REVISION_DATE, }, @@ -94,7 +94,7 @@ const doc = new Document({ }), ], insertion: { - id: 0, + id: 3, author: REVISION_AUTHOR, date: REVISION_DATE, }, @@ -107,7 +107,7 @@ const doc = new Document({ children: [new TextRun("Deleted row cell")], run: { deletion: { - id: 1, + id: 4, author: REVISION_AUTHOR, date: REVISION_DATE, }, @@ -121,7 +121,7 @@ const doc = new Document({ children: [new TextRun("Deleted row cell")], run: { deletion: { - id: 1, + id: 5, author: REVISION_AUTHOR, date: REVISION_DATE, }, @@ -131,7 +131,7 @@ const doc = new Document({ }), ], deletion: { - id: 1, + id: 6, author: REVISION_AUTHOR, date: REVISION_DATE, }, @@ -155,14 +155,14 @@ const doc = new Document({ children: [ new InsertedTextRun({ text: "Inserted cell", - id: 2, + id: 7, author: REVISION_AUTHOR, date: REVISION_DATE, }), ], run: { insertion: { - id: 2, + id: 8, author: REVISION_AUTHOR, date: REVISION_DATE, }, @@ -170,7 +170,7 @@ const doc = new Document({ }), ], insertion: { - id: 2, + id: 9, author: REVISION_AUTHOR, date: REVISION_DATE, }, @@ -186,14 +186,14 @@ const doc = new Document({ children: [ new InsertedTextRun({ text: "Inserted cell", - id: 2, + id: 10, author: REVISION_AUTHOR, date: REVISION_DATE, }), ], run: { insertion: { - id: 2, + id: 11, author: REVISION_AUTHOR, date: REVISION_DATE, }, @@ -201,7 +201,7 @@ const doc = new Document({ }), ], insertion: { - id: 2, + id: 12, author: REVISION_AUTHOR, date: REVISION_DATE, }, @@ -229,14 +229,14 @@ const doc = new Document({ children: [ new DeletedTextRun({ text: "Deleted cell", - id: 3, + id: 13, author: REVISION_AUTHOR, date: REVISION_DATE, }), ], run: { deletion: { - id: 3, + id: 14, author: REVISION_AUTHOR, date: REVISION_DATE, }, @@ -244,7 +244,7 @@ const doc = new Document({ }), ], deletion: { - id: 3, + id: 15, author: REVISION_AUTHOR, date: REVISION_DATE, }, @@ -260,14 +260,14 @@ const doc = new Document({ children: [ new DeletedTextRun({ text: "Deleted cell", - id: 3, + id: 16, author: REVISION_AUTHOR, date: REVISION_DATE, }), ], run: { deletion: { - id: 3, + id: 17, author: REVISION_AUTHOR, date: REVISION_DATE, }, @@ -275,7 +275,7 @@ const doc = new Document({ }), ], deletion: { - id: 3, + id: 18, author: REVISION_AUTHOR, date: REVISION_DATE, }, @@ -304,7 +304,7 @@ const doc = new Document({ verticalAlign: VerticalAlignTable.CENTER, revision: { width: { size: 2000, type: WidthType.DXA }, - id: 4, + id: 19, author: REVISION_AUTHOR, date: REVISION_DATE, verticalAlign: VerticalAlignTable.TOP, @@ -319,7 +319,7 @@ const doc = new Document({ }, revision: { width: { size: 2000, type: WidthType.DXA }, - id: 4, + id: 20, author: REVISION_AUTHOR, date: REVISION_DATE, }, @@ -333,7 +333,7 @@ const doc = new Document({ width: { size: 4000, type: WidthType.DXA }, revision: { width: { size: 2000, type: WidthType.DXA }, - id: 4, + id: 21, author: REVISION_AUTHOR, date: REVISION_DATE, }, @@ -343,7 +343,7 @@ const doc = new Document({ width: { size: 2000, type: WidthType.DXA }, revision: { width: { size: 2000, type: WidthType.DXA }, - id: 4, + id: 22, author: REVISION_AUTHOR, date: REVISION_DATE, }, @@ -367,7 +367,7 @@ const doc = new Document({ tableHeader: true, height: { value: 600, rule: HeightRule.EXACT }, revision: { - id: 5, + id: 23, author: REVISION_AUTHOR, date: REVISION_DATE, tableHeader: false, @@ -414,7 +414,7 @@ const doc = new Document({ }, layout: "fixed", revision: { - id: 6, + id: 24, author: REVISION_AUTHOR, date: REVISION_DATE, borders: { @@ -474,7 +474,7 @@ const doc = new Document({ }, }, revision: { - id: 20, + id: 25, author: REVISION_AUTHOR, date: REVISION_DATE, page: { diff --git a/demo/images/parrots.bmp b/demo/images/parrots.bmp index 9e088598eb..01391af594 100644 Binary files a/demo/images/parrots.bmp and b/demo/images/parrots.bmp differ diff --git a/docs/contribution-guidelines.md b/docs/contribution-guidelines.md index d67d65aa26..6d6d95274f 100644 --- a/docs/contribution-guidelines.md +++ b/docs/contribution-guidelines.md @@ -36,6 +36,9 @@ Key schemas: | `ooxml-schemas/ISO-IEC29500-4_2016/dml-main.xsd` | DrawingML (images, shapes) | | `ooxml-schemas/ISO-IEC29500-4_2016/shared-math.xsd` | Math equations | | `ooxml-schemas/ISO-IEC29500-4_2016/vml-main.xsd` | VML (legacy shapes, textboxes) | +| `ooxml-schemas/microsoft/` | Microsoft's extensions (`w14:`, `wps:`...) | + +`ooxml-schemas/README.md` lists every schema and where it's from. Always cross-reference these schemas when implementing or modifying XML generation: diff --git a/docs/usage/styling-with-xml.md b/docs/usage/styling-with-xml.md index 2f78ea4f15..5e4647367c 100644 --- a/docs/usage/styling-with-xml.md +++ b/docs/usage/styling-with-xml.md @@ -36,6 +36,8 @@ const doc = new docx.Document({ }); ``` +Your styles take the place of the library's default styles with the same ids, and your document defaults take the place of the library's. The library's default styles fill in the ones your `styles.xml` leaves out, such as `Hyperlink` or `FootnoteText`. A default style you set in `styles.default`, such as `heading1` or `document`, takes the place of yours. + You can use paragraphs, `heading1()`, `heading2()` etc and it will be styled according to your `styles.xml` created earlier. You can even use your new style you made by calling the `style` method: ```ts diff --git a/ooxml-schemas/ECMA-376-2_2021/opc-contentTypes.xsd b/ooxml-schemas/ECMA-376-2_2021/opc-contentTypes.xsd new file mode 100644 index 0000000000..a6de9d2733 --- /dev/null +++ b/ooxml-schemas/ECMA-376-2_2021/opc-contentTypes.xsd @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ooxml-schemas/ECMA-376-2_2021/opc-coreProperties.xsd b/ooxml-schemas/ECMA-376-2_2021/opc-coreProperties.xsd new file mode 100644 index 0000000000..2186fff59c --- /dev/null +++ b/ooxml-schemas/ECMA-376-2_2021/opc-coreProperties.xsd @@ -0,0 +1,48 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ooxml-schemas/ECMA-376-2_2021/opc-digSig.xsd b/ooxml-schemas/ECMA-376-2_2021/opc-digSig.xsd new file mode 100644 index 0000000000..4248bf7a39 --- /dev/null +++ b/ooxml-schemas/ECMA-376-2_2021/opc-digSig.xsd @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ooxml-schemas/ECMA-376-2_2021/opc-relationships.xsd b/ooxml-schemas/ECMA-376-2_2021/opc-relationships.xsd new file mode 100644 index 0000000000..5649746712 --- /dev/null +++ b/ooxml-schemas/ECMA-376-2_2021/opc-relationships.xsd @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ooxml-schemas/README.md b/ooxml-schemas/README.md new file mode 100644 index 0000000000..6ee751ee7d --- /dev/null +++ b/ooxml-schemas/README.md @@ -0,0 +1,90 @@ +# OOXML schemas + +The XML schemas for everything a .docx can hold. + +| Folder | What | From | +| --------------------- | ------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `ISO-IEC29500-4_2016` | Office Open XML, transitional: WordprocessingML, DrawingML, VML, math, document properties and the rest | [ISO/IEC 29500-4:2016](https://standards.iso.org/ittf/PubliclyAvailableStandards/c071691_ISO_IEC_29500-4_2016_Electronic_inserts.zip), the same as ECMA-376 Part 4, 5th edition | +| `ECMA-376-2_2021` | Open Packaging Conventions: `[Content_Types].xml`, relationships, core properties and signatures | [ECMA-376 Part 2, 5th edition](https://ecma-international.org/publications-and-standards/standards/ecma-376/) (December 2021), the same as ISO/IEC 29500-2:2021 | +| `mce` | Markup Compatibility (`mc:`), from ECMA-376 Part 3 | [docx4j](https://github.com/plutext/docx4j/blob/master/xsd/mce/markup-compatibility-2006-MINIMAL.xsd), as the standard has no schema for it | +| `dublin-core` | Dublin Core, which the core properties use | [dublincore.org](http://dublincore.org/schemas/xmls/qdc/2003/04/02/), the 2003-04-02 schemas the core properties schema names | +| `microsoft` | Microsoft's extensions, such as Word 2010 shapes (`wps:`) and later Word features (`w14:`, `w15:`, ...) | The "Full XML Schemas" appendices of [MS-DOCX], [MS-ODRAWXML] and [MS-OFFMACRO2], below | + +The Strict schemas (ECMA-376 Part 1) aren't here: docx writes transitional documents, which are in other namespaces. + +## Changes from the originals + +The schemas are as published, except: + +- Each of Microsoft's starts with a comment saying where it's from. + +- **Imports** point at the files here. Microsoft's schemas name files that aren't published (such as `oartbasetypes.xsd` for DrawingML), and the Open Packaging Conventions name Dublin Core's website. +- **Microsoft's schemas** were written against ECMA-376 1st edition, where some simple types were in the WordprocessingML, DrawingML and chart namespaces. ISO/IEC 29500 moved these to the shared types namespace (`s:`), so, for example, `w:ST_OnOff`, `a:ST_Guid` and `c:ST_Xstring` are `s:ST_OnOff`, `s:ST_Guid` and `s:ST_Xstring`. +- `microsoft/wml-2010.xsd` includes `microsoft/wml-2010-contentPart.xsd`, the rest of its namespace, from [MS-ODRAWXML]. +- `microsoft/drawing-2010-main.xsd`: `ST_SaturationAmount` restricts `a:ST_PercentageDecimal`, as `a:ST_Percentage` became a union, which can't be restricted to a range. +- `microsoft/drawing-2014-chartex.xsd`: the space after `CT_GeoHierarchyEntity` in the type of `geoHierarchyEntity` is gone. +- `microsoft/wml-2006.xsd` declares `txbxContent`, which `wps:txbx` refers to, from a schema Microsoft hasn't published. +- `ISO-IEC29500-4_2016/wml.xsd` allows `mc:Ignorable` on `w:document`, and `ISO-IEC29500-4_2016/shared-math.xsd` imports `xml.xsd`, which is W3C's schema for the `xml:` attributes. + +[MS-ODRAWXML] 5.19, PowerPoint's ink actions, isn't here, as it's written against Microsoft's own InkML schema rather than W3C's. + +## Microsoft's schemas + +| File | Namespace | From | +| -------------------------------------- | ---------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------ | +| `wml-2010.xsd` | `http://schemas.microsoft.com/office/word/2010/wordml` | [[MS-DOCX] 5.1](https://learn.microsoft.com/en-us/openspecs/office_standards/ms-docx/9704b59f-bc49-4618-ac66-41beb82a0d7f) | +| `wml-2012.xsd` | `http://schemas.microsoft.com/office/word/2012/wordml` | [[MS-DOCX] 5.2](https://learn.microsoft.com/en-us/openspecs/office_standards/ms-docx/d416013d-c112-44fa-8bef-7819b8898117) | +| `wml-symex-2015.xsd` | `http://schemas.microsoft.com/office/word/2015/wordml/symex` | [[MS-DOCX] 5.3](https://learn.microsoft.com/en-us/openspecs/office_standards/ms-docx/372b619f-f0f4-463f-9d59-02ebb1c8956d) | +| `wml-cid-2016.xsd` | `http://schemas.microsoft.com/office/word/2016/wordml/cid` | [[MS-DOCX] 5.4](https://learn.microsoft.com/en-us/openspecs/office_standards/ms-docx/8e395dbe-ff70-43c3-b9fe-e758c8f69683) | +| `wml-2018.xsd` | `http://schemas.microsoft.com/office/word/2018/wordml` | [[MS-DOCX] 5.5](https://learn.microsoft.com/en-us/openspecs/office_standards/ms-docx/6970e332-57ff-4ab5-a9a4-3b8834bbc477) | +| `wml-cex-2018.xsd` | `http://schemas.microsoft.com/office/word/2018/wordml/cex` | [[MS-DOCX] 5.6](https://learn.microsoft.com/en-us/openspecs/office_standards/ms-docx/0df7c115-b22a-4e09-bab7-4f24fbb8e6f5) | +| `wml-sdtdatahash-2020.xsd` | `http://schemas.microsoft.com/office/word/2020/wordml/sdtdatahash` | [[MS-DOCX] 5.7](https://learn.microsoft.com/en-us/openspecs/office_standards/ms-docx/c865ba38-51df-45bc-91ae-f6beaffeb264) | +| `wml-du-2023.xsd` | `http://schemas.microsoft.com/office/word/2023/wordml/word16du` | [[MS-DOCX] 5.8](https://learn.microsoft.com/en-us/openspecs/office_standards/ms-docx/e5d0aa0c-4ecc-40d9-a0e0-aac8655a8316) | +| `wml-sdtformatlock-2024.xsd` | `http://schemas.microsoft.com/office/word/2024/wordml/sdtformatlock` | [[MS-DOCX] 5.9](https://learn.microsoft.com/en-us/openspecs/office_standards/ms-docx/14bc8126-7c6e-41a8-b042-c199036e2339) | +| `wml-cei-2026.xsd` | `http://schemas.microsoft.com/office/word/2026/wordml/cei` | [[MS-DOCX] 5.10](https://learn.microsoft.com/en-us/openspecs/office_standards/ms-docx/4c5c0c9a-50e6-4d50-a387-9e5aceecd2f9) | +| `drawing-2010-main.xsd` | `http://schemas.microsoft.com/office/drawing/2010/main` | [[MS-ODRAWXML] 5.1](https://learn.microsoft.com/en-us/openspecs/office_standards/ms-odrawxml/869af0ef-665b-4f28-a596-0917474ede26) | +| `word-2010-wordprocessingShape.xsd` | `http://schemas.microsoft.com/office/word/2010/wordprocessingShape` | [[MS-ODRAWXML] 5.2](https://learn.microsoft.com/en-us/openspecs/office_standards/ms-odrawxml/f73ea06d-4749-4611-b20b-755df087eb21) | +| `wml-2010-contentPart.xsd` | `http://schemas.microsoft.com/office/word/2010/wordml` | [[MS-ODRAWXML] 5.3](https://learn.microsoft.com/en-us/openspecs/office_standards/ms-odrawxml/20b04a8a-b93e-4ecd-9522-96d4bb1847c8) | +| `word-2010-wordprocessingGroup.xsd` | `http://schemas.microsoft.com/office/word/2010/wordprocessingGroup` | [[MS-ODRAWXML] 5.4](https://learn.microsoft.com/en-us/openspecs/office_standards/ms-odrawxml/fbe733bf-85e2-46f9-b548-9292b44670ce) | +| `word-2010-wordprocessingCanvas.xsd` | `http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas` | [[MS-ODRAWXML] 5.5](https://learn.microsoft.com/en-us/openspecs/office_standards/ms-odrawxml/0af4dfe1-b07b-41eb-a48b-87aadd16b51b) | +| `drawing-2008-diagram.xsd` | `http://schemas.microsoft.com/office/drawing/2008/diagram` | [[MS-ODRAWXML] 5.6](https://learn.microsoft.com/en-us/openspecs/office_standards/ms-odrawxml/e1b56dd5-305b-4b3b-a983-28df1d4ffc3f) | +| `ink-2010-main.xsd` | `http://schemas.microsoft.com/ink/2010/main` | [[MS-ODRAWXML] 5.7](https://learn.microsoft.com/en-us/openspecs/office_standards/ms-odrawxml/b0e5b36b-68a8-4fd4-874c-e5e187ba574f) | +| `drawing-2010-chartDrawing.xsd` | `http://schemas.microsoft.com/office/drawing/2010/chartDrawing` | [[MS-ODRAWXML] 5.8](https://learn.microsoft.com/en-us/openspecs/office_standards/ms-odrawxml/53d31d11-3b07-4ca3-ac54-e8562713e647) | +| `excel-2010-spreadsheetDrawing.xsd` | `http://schemas.microsoft.com/office/excel/2010/spreadsheetDrawing` | [[MS-ODRAWXML] 5.9](https://learn.microsoft.com/en-us/openspecs/office_standards/ms-odrawxml/ec810aeb-26c0-4f32-a6a4-59abb9a0398f) | +| `drawing-2007-8-2-chart.xsd` | `http://schemas.microsoft.com/office/drawing/2007/8/2/chart` | [[MS-ODRAWXML] 5.10](https://learn.microsoft.com/en-us/openspecs/office_standards/ms-odrawxml/070bea84-2201-463c-aeaa-cf258492b5b5) | +| `word-2010-wordprocessingDrawing.xsd` | `http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing` | [[MS-ODRAWXML] 5.11](https://learn.microsoft.com/en-us/openspecs/office_standards/ms-odrawxml/1a38a99a-16ae-420d-8c79-23dc2e922717) | +| `drawing-2010-picture.xsd` | `http://schemas.microsoft.com/office/drawing/2010/picture` | [[MS-ODRAWXML] 5.12](https://learn.microsoft.com/en-us/openspecs/office_standards/ms-odrawxml/81dd13dc-144f-4099-bb1f-658ce7b65b6d) | +| `drawing-2012-chart.xsd` | `http://schemas.microsoft.com/office/drawing/2012/chart` | [[MS-ODRAWXML] 5.13](https://learn.microsoft.com/en-us/openspecs/office_standards/ms-odrawxml/1c52d959-25d3-4556-9381-cc86c1221029) | +| `drawing-2012-main.xsd` | `http://schemas.microsoft.com/office/drawing/2012/main` | [[MS-ODRAWXML] 5.14](https://learn.microsoft.com/en-us/openspecs/office_standards/ms-odrawxml/a87e4aa0-8ba3-41f1-a6a3-67c2afcca6b3) | +| `drawing-2012-chartStyle.xsd` | `http://schemas.microsoft.com/office/drawing/2012/chartStyle` | [[MS-ODRAWXML] 5.15](https://learn.microsoft.com/en-us/openspecs/office_standards/ms-odrawxml/a7bb9c01-d274-47ee-a16a-90e26877e8a4) | +| `drawing-2010-diagram.xsd` | `http://schemas.microsoft.com/office/drawing/2010/diagram` | [[MS-ODRAWXML] 5.16](https://learn.microsoft.com/en-us/openspecs/office_standards/ms-odrawxml/6a404d68-14de-4124-b7db-bb48398538ac) | +| `thememl-2012-main.xsd` | `http://schemas.microsoft.com/office/thememl/2012/main` | [[MS-ODRAWXML] 5.17](https://learn.microsoft.com/en-us/openspecs/office_standards/ms-odrawxml/de6e746a-c9e3-48ad-884a-774aac2ad80d) | +| `word-2012-wordprocessingDrawing.xsd` | `http://schemas.microsoft.com/office/word/2012/wordprocessingDrawing` | [[MS-ODRAWXML] 5.18](https://learn.microsoft.com/en-us/openspecs/office_standards/ms-odrawxml/44351d27-cd96-461b-89ae-3be25ed82425) | +| `drawing-2014-chart.xsd` | `http://schemas.microsoft.com/office/drawing/2014/chart` | [[MS-ODRAWXML] 5.20](https://learn.microsoft.com/en-us/openspecs/office_standards/ms-odrawxml/40b8f1fc-b266-4f1f-90ec-d8ae7bafb140) | +| `drawing-2014-chart-ac.xsd` | `http://schemas.microsoft.com/office/drawing/2014/chart/ac` | [[MS-ODRAWXML] 5.21](https://learn.microsoft.com/en-us/openspecs/office_standards/ms-odrawxml/5a2048a5-7116-48a9-95b6-9c7b8e70ff44) | +| `drawing-2014-chartex.xsd` | `http://schemas.microsoft.com/office/drawing/2014/chartex` | [[MS-ODRAWXML] 5.22](https://learn.microsoft.com/en-us/openspecs/office_standards/ms-odrawxml/e2723b0a-9120-42a5-bd11-c252ccb13c1e) | +| `drawing-2014-main.xsd` | `http://schemas.microsoft.com/office/drawing/2014/main` | [[MS-ODRAWXML] 5.23](https://learn.microsoft.com/en-us/openspecs/office_standards/ms-odrawxml/55a2958e-599f-46a0-8812-029155d485cb) | +| `drawing-2016-SVG-main.xsd` | `http://schemas.microsoft.com/office/drawing/2016/SVG/main` | [[MS-ODRAWXML] 5.24](https://learn.microsoft.com/en-us/openspecs/office_standards/ms-odrawxml/cc083f6d-bc38-4ff4-b32a-5bc97df8addc) | +| `drawing-2016-11-main.xsd` | `http://schemas.microsoft.com/office/drawing/2016/11/main` | [[MS-ODRAWXML] 5.25](https://learn.microsoft.com/en-us/openspecs/office_standards/ms-odrawxml/96e8cdeb-7774-461b-957e-09b7ec8e2765) | +| `drawing-2016-11-diagram.xsd` | `http://schemas.microsoft.com/office/drawing/2016/11/diagram` | [[MS-ODRAWXML] 5.26](https://learn.microsoft.com/en-us/openspecs/office_standards/ms-odrawxml/8607d4b7-2dc8-45e7-9317-808373935e47) | +| `drawing-2013-main-command.xsd` | `http://schemas.microsoft.com/office/drawing/2013/main/command` | [[MS-ODRAWXML] 5.27](https://learn.microsoft.com/en-us/openspecs/office_standards/ms-odrawxml/f01549ab-276f-461a-a9be-c672a5393b1a) | +| `drawing-2016-ink.xsd` | `http://schemas.microsoft.com/office/drawing/2016/ink` | [[MS-ODRAWXML] 5.28](https://learn.microsoft.com/en-us/openspecs/office_standards/ms-odrawxml/9fb2d49d-0881-4e7d-8b38-95373d76302c) | +| `drawing-2017-model3d.xsd` | `http://schemas.microsoft.com/office/drawing/2017/model3d` | [[MS-ODRAWXML] 5.29](https://learn.microsoft.com/en-us/openspecs/office_standards/ms-odrawxml/6c414e62-4825-4100-9ca1-88fefc5fb699) | +| `drawing-2016-12-diagram.xsd` | `http://schemas.microsoft.com/office/drawing/2016/12/diagram` | [[MS-ODRAWXML] 5.30](https://learn.microsoft.com/en-us/openspecs/office_standards/ms-odrawxml/e2d5dcbc-cb93-40b9-896d-46033bc2711c) | +| `drawing-2017-03-chart.xsd` | `http://schemas.microsoft.com/office/drawing/2017/03/chart` | [[MS-ODRAWXML] 5.31](https://learn.microsoft.com/en-us/openspecs/office_standards/ms-odrawxml/07ad9d54-eb9e-4d52-831e-aa6487b295c2) | +| `drawing-2017-decorative.xsd` | `http://schemas.microsoft.com/office/drawing/2017/decorative` | [[MS-ODRAWXML] 5.32](https://learn.microsoft.com/en-us/openspecs/office_standards/ms-odrawxml/6146d89f-9146-415b-99e2-39e694b5a980) | +| `drawing-2018-hyperlinkcolor.xsd` | `http://schemas.microsoft.com/office/drawing/2018/hyperlinkcolor` | [[MS-ODRAWXML] 5.33](https://learn.microsoft.com/en-us/openspecs/office_standards/ms-odrawxml/014fbc20-3705-4812-b8cd-93f5af05b504) | +| `drawing-2018-animation-model3d.xsd` | `http://schemas.microsoft.com/office/drawing/2018/animation/model3d` | [[MS-ODRAWXML] 5.34](https://learn.microsoft.com/en-us/openspecs/office_standards/ms-odrawxml/c939a613-ae17-423a-9d33-7fb2e07b7b7f) | +| `drawing-2018-animation.xsd` | `http://schemas.microsoft.com/office/drawing/2018/animation` | [[MS-ODRAWXML] 5.35](https://learn.microsoft.com/en-us/openspecs/office_standards/ms-odrawxml/901a7e62-aa4a-48a0-9ecb-cf2401a2b47a) | +| `drawing-2018-sketchyshapes.xsd` | `http://schemas.microsoft.com/office/drawing/2018/sketchyshapes` | [[MS-ODRAWXML] 5.36](https://learn.microsoft.com/en-us/openspecs/office_standards/ms-odrawxml/8d84ecec-8b42-42d7-a51a-ca81862b0dd3) | +| `drawing-2020-classificationShape.xsd` | `http://schemas.microsoft.com/office/drawing/2020/classificationShape` | [[MS-ODRAWXML] 5.37](https://learn.microsoft.com/en-us/openspecs/office_standards/ms-odrawxml/1f3ad775-d46f-4c60-8457-04121d909fe3) | +| `word-2020-oembed.xsd` | `http://schemas.microsoft.com/office/word/2020/oembed` | [[MS-ODRAWXML] 5.38](https://learn.microsoft.com/en-us/openspecs/office_standards/ms-odrawxml/b495a2c4-89bf-47e3-b165-dacb3508bb72) | +| `drawing-2021-scriptlink.xsd` | `http://schemas.microsoft.com/office/drawing/2021/scriptlink` | [[MS-ODRAWXML] 5.39](https://learn.microsoft.com/en-us/openspecs/office_standards/ms-odrawxml/f830ed7e-a16f-4863-9112-711c02e00269) | +| `drawing-2021-livefeed.xsd` | `http://schemas.microsoft.com/office/drawing/2021/livefeed` | [[MS-ODRAWXML] 5.40](https://learn.microsoft.com/en-us/openspecs/office_standards/ms-odrawxml/2084bd49-c84a-4779-b7b6-331902b88dfe) | +| `drawing-2022-imageformula.xsd` | `http://schemas.microsoft.com/office/drawing/2022/imageformula` | [[MS-ODRAWXML] 5.41](https://learn.microsoft.com/en-us/openspecs/office_standards/ms-odrawxml/0c47e53f-d2a7-457d-b7a0-26c7544dd7b2) | +| `drawing-2015-06-chart.xsd` | `http://schemas.microsoft.com/office/drawing/2015/06/chart` | [[MS-ODRAWXML] 5.42](https://learn.microsoft.com/en-us/openspecs/office_standards/ms-odrawxml/4a7a3cd6-1782-4b99-b223-5a811e505d73) | +| `wml-2006.xsd` | `http://schemas.microsoft.com/office/word/2006/wordml` | [[MS-OFFMACRO2] 5.1](https://learn.microsoft.com/en-us/openspecs/office_standards/ms-offmacro2/230e441a-0a5b-4c4c-8239-0a446f235101) | + +[MS-DOCX]: https://learn.microsoft.com/en-us/openspecs/office_standards/ms-docx/d0a2e301-0ff7-4e9e-9bb7-ff47070dce0a +[MS-ODRAWXML]: https://learn.microsoft.com/en-us/openspecs/office_standards/ms-odrawxml/bdc95a77-957c-40f8-9ef2-47cbcdeb8af2 +[MS-OFFMACRO2]: https://learn.microsoft.com/en-us/openspecs/office_standards/ms-offmacro2/230e441a-0a5b-4c4c-8239-0a446f235101 diff --git a/ooxml-schemas/dublin-core/dc.xsd b/ooxml-schemas/dublin-core/dc.xsd new file mode 100644 index 0000000000..fa5bcbf0d3 --- /dev/null +++ b/ooxml-schemas/dublin-core/dc.xsd @@ -0,0 +1,117 @@ + + + + + + DCMES 1.1 XML Schema + XML Schema for http://purl.org/dc/elements/1.1/ namespace + + Created 2003-04-02 + + Created by + + Tim Cole (t-cole3@uiuc.edu) + Tom Habing (thabing@uiuc.edu) + Jane Hunter (jane@dstc.edu.au) + Pete Johnston (p.johnston@ukoln.ac.uk), + Carl Lagoze (lagoze@cs.cornell.edu) + + This schema declares XML elements for the 15 DC elements from the + http://purl.org/dc/elements/1.1/ namespace. + + It defines a complexType SimpleLiteral which permits mixed content + and makes the xml:lang attribute available. It disallows child elements by + use of minOcccurs/maxOccurs. + + However, this complexType does permit the derivation of other complexTypes + which would permit child elements. + + All elements are declared as substitutable for the abstract element any, + which means that the default type for all elements is dc:SimpleLiteral. + + + + + + + + + + + + + This is the default type for all of the DC elements. + It permits text content only with optional + xml:lang attribute. + Text is allowed because mixed="true", but sub-elements + are disallowed because minOccurs="0" and maxOccurs="0" + are on the xs:any tag. + + This complexType allows for restriction or extension permitting + child elements. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + This group is included as a convenience for schema authors + who need to refer to all the elements in the + http://purl.org/dc/elements/1.1/ namespace. + + + + + + + + + + + + + + This complexType is included as a convenience for schema authors who need to define a root + or container element for all of the DC elements. + + + + + + + + + + diff --git a/ooxml-schemas/dublin-core/dcmitype.xsd b/ooxml-schemas/dublin-core/dcmitype.xsd new file mode 100644 index 0000000000..54d9da00a8 --- /dev/null +++ b/ooxml-schemas/dublin-core/dcmitype.xsd @@ -0,0 +1,50 @@ + + + + + + DCMI Type Vocabulary XML Schema + XML Schema for http://purl.org/dc/dcmitype/ namespace + + Created 2003-04-02 + + Created by + + Tim Cole (t-cole3@uiuc.edu) + Tom Habing (thabing@uiuc.edu) + Jane Hunter (jane@dstc.edu.au) + Pete Johnston (p.johnston@ukoln.ac.uk), + Carl Lagoze (lagoze@cs.cornell.edu) + + This schema defines a simpleType which enumerates + the allowable values for the DCMI Type Vocabulary. + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ooxml-schemas/dublin-core/dcterms.xsd b/ooxml-schemas/dublin-core/dcterms.xsd new file mode 100644 index 0000000000..4ada961461 --- /dev/null +++ b/ooxml-schemas/dublin-core/dcterms.xsd @@ -0,0 +1,328 @@ + + + + + + DCterms XML Schema + XML Schema for http://purl.org/dc/terms/ namespace + + Created 2003-04-02 + + Created by + + Tim Cole (t-cole3@uiuc.edu) + Tom Habing (thabing@uiuc.edu) + Jane Hunter (jane@dstc.edu.au) + Pete Johnston (p.johnston@ukoln.ac.uk), + Carl Lagoze (lagoze@cs.cornell.edu) + + This schema declares XML elements for the DC elements and + DC element refinements from the http://purl.org/dc/terms/ namespace. + + It reuses the complexType dc:SimpleLiteral, imported from the dc.xsd + schema, which permits simple element content, and makes the xml:lang + attribute available. + + This complexType permits the derivation of other complexTypes + which would permit child elements. + + DC elements are declared as substitutable for the abstract element dc:any, and + DC element refinements are defined as substitutable for the base elements + which they refine. + + This means that the default type for all XML elements (i.e. all DC elements and + element refinements) is dc:SimpleLiteral. + + Encoding schemes are defined as complexTypes which are restrictions + of the dc:SimpleLiteral complexType. These complexTypes restrict + values to an appropriates syntax or format using data typing, + regular expressions, or enumerated lists. + + In order to specify one of these encodings an xsi:type attribute must + be used in the instance document. + + Also, note that one shortcoming of this approach is that any type can be + applied to any of the elements or refinements. There is no convenient way + to restrict types to specific elements using this approach. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + This group is included as a convenience for schema authors + who need to refer to all the DC elements and element refinements + in the http://purl.org/dc/elements/1.1/ and + http://purl.org/dc/terms namespaces. + N.B. Refinements available via substitution groups. + + + + + + + + + + + + + + This is included as a convenience for schema authors who need to define a root + or container element for all of the DC elements and element refinements. + + + + + + + + + + diff --git a/ooxml-schemas/microsoft/drawing-2007-8-2-chart.xsd b/ooxml-schemas/microsoft/drawing-2007-8-2-chart.xsd new file mode 100644 index 0000000000..e91d7ea406 --- /dev/null +++ b/ooxml-schemas/microsoft/drawing-2007-8-2-chart.xsd @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ooxml-schemas/microsoft/drawing-2008-diagram.xsd b/ooxml-schemas/microsoft/drawing-2008-diagram.xsd new file mode 100644 index 0000000000..11ba5f0aa2 --- /dev/null +++ b/ooxml-schemas/microsoft/drawing-2008-diagram.xsd @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ooxml-schemas/microsoft/drawing-2010-chartDrawing.xsd b/ooxml-schemas/microsoft/drawing-2010-chartDrawing.xsd new file mode 100644 index 0000000000..865903344a --- /dev/null +++ b/ooxml-schemas/microsoft/drawing-2010-chartDrawing.xsd @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ooxml-schemas/microsoft/drawing-2010-diagram.xsd b/ooxml-schemas/microsoft/drawing-2010-diagram.xsd new file mode 100644 index 0000000000..bc3366bc52 --- /dev/null +++ b/ooxml-schemas/microsoft/drawing-2010-diagram.xsd @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/ooxml-schemas/microsoft/drawing-2010-main.xsd b/ooxml-schemas/microsoft/drawing-2010-main.xsd new file mode 100644 index 0000000000..cdacf5b9c5 --- /dev/null +++ b/ooxml-schemas/microsoft/drawing-2010-main.xsd @@ -0,0 +1,282 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ooxml-schemas/microsoft/drawing-2010-picture.xsd b/ooxml-schemas/microsoft/drawing-2010-picture.xsd new file mode 100644 index 0000000000..ede83c71bc --- /dev/null +++ b/ooxml-schemas/microsoft/drawing-2010-picture.xsd @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/ooxml-schemas/microsoft/drawing-2012-chart.xsd b/ooxml-schemas/microsoft/drawing-2012-chart.xsd new file mode 100644 index 0000000000..1c03b2505c --- /dev/null +++ b/ooxml-schemas/microsoft/drawing-2012-chart.xsd @@ -0,0 +1,131 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ooxml-schemas/microsoft/drawing-2012-chartStyle.xsd b/ooxml-schemas/microsoft/drawing-2012-chartStyle.xsd new file mode 100644 index 0000000000..adf1339909 --- /dev/null +++ b/ooxml-schemas/microsoft/drawing-2012-chartStyle.xsd @@ -0,0 +1,162 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ooxml-schemas/microsoft/drawing-2012-main.xsd b/ooxml-schemas/microsoft/drawing-2012-main.xsd new file mode 100644 index 0000000000..5201f2fc1d --- /dev/null +++ b/ooxml-schemas/microsoft/drawing-2012-main.xsd @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ooxml-schemas/microsoft/drawing-2013-main-command.xsd b/ooxml-schemas/microsoft/drawing-2013-main-command.xsd new file mode 100644 index 0000000000..927c646899 --- /dev/null +++ b/ooxml-schemas/microsoft/drawing-2013-main-command.xsd @@ -0,0 +1,256 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ooxml-schemas/microsoft/drawing-2014-chart-ac.xsd b/ooxml-schemas/microsoft/drawing-2014-chart-ac.xsd new file mode 100644 index 0000000000..5e67bc5679 --- /dev/null +++ b/ooxml-schemas/microsoft/drawing-2014-chart-ac.xsd @@ -0,0 +1,6 @@ + + + + + + diff --git a/ooxml-schemas/microsoft/drawing-2014-chart.xsd b/ooxml-schemas/microsoft/drawing-2014-chart.xsd new file mode 100644 index 0000000000..ad81288e7f --- /dev/null +++ b/ooxml-schemas/microsoft/drawing-2014-chart.xsd @@ -0,0 +1,71 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ooxml-schemas/microsoft/drawing-2014-chartex.xsd b/ooxml-schemas/microsoft/drawing-2014-chartex.xsd new file mode 100644 index 0000000000..7c00821540 --- /dev/null +++ b/ooxml-schemas/microsoft/drawing-2014-chartex.xsd @@ -0,0 +1,863 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ooxml-schemas/microsoft/drawing-2014-main.xsd b/ooxml-schemas/microsoft/drawing-2014-main.xsd new file mode 100644 index 0000000000..3fbd8cd8aa --- /dev/null +++ b/ooxml-schemas/microsoft/drawing-2014-main.xsd @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ooxml-schemas/microsoft/drawing-2015-06-chart.xsd b/ooxml-schemas/microsoft/drawing-2015-06-chart.xsd new file mode 100644 index 0000000000..cdd0f348f4 --- /dev/null +++ b/ooxml-schemas/microsoft/drawing-2015-06-chart.xsd @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/ooxml-schemas/microsoft/drawing-2016-11-diagram.xsd b/ooxml-schemas/microsoft/drawing-2016-11-diagram.xsd new file mode 100644 index 0000000000..60dbb44eab --- /dev/null +++ b/ooxml-schemas/microsoft/drawing-2016-11-diagram.xsd @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ooxml-schemas/microsoft/drawing-2016-11-main.xsd b/ooxml-schemas/microsoft/drawing-2016-11-main.xsd new file mode 100644 index 0000000000..7b7269f8f4 --- /dev/null +++ b/ooxml-schemas/microsoft/drawing-2016-11-main.xsd @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/ooxml-schemas/microsoft/drawing-2016-12-diagram.xsd b/ooxml-schemas/microsoft/drawing-2016-12-diagram.xsd new file mode 100644 index 0000000000..c8504b1224 --- /dev/null +++ b/ooxml-schemas/microsoft/drawing-2016-12-diagram.xsd @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/ooxml-schemas/microsoft/drawing-2016-SVG-main.xsd b/ooxml-schemas/microsoft/drawing-2016-SVG-main.xsd new file mode 100644 index 0000000000..ef1ab7e4b3 --- /dev/null +++ b/ooxml-schemas/microsoft/drawing-2016-SVG-main.xsd @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/ooxml-schemas/microsoft/drawing-2016-ink.xsd b/ooxml-schemas/microsoft/drawing-2016-ink.xsd new file mode 100644 index 0000000000..b35893c432 --- /dev/null +++ b/ooxml-schemas/microsoft/drawing-2016-ink.xsd @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ooxml-schemas/microsoft/drawing-2017-03-chart.xsd b/ooxml-schemas/microsoft/drawing-2017-03-chart.xsd new file mode 100644 index 0000000000..b9bd294bbe --- /dev/null +++ b/ooxml-schemas/microsoft/drawing-2017-03-chart.xsd @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/ooxml-schemas/microsoft/drawing-2017-decorative.xsd b/ooxml-schemas/microsoft/drawing-2017-decorative.xsd new file mode 100644 index 0000000000..a8192b6ace --- /dev/null +++ b/ooxml-schemas/microsoft/drawing-2017-decorative.xsd @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/ooxml-schemas/microsoft/drawing-2017-model3d.xsd b/ooxml-schemas/microsoft/drawing-2017-model3d.xsd new file mode 100644 index 0000000000..b03405f4d9 --- /dev/null +++ b/ooxml-schemas/microsoft/drawing-2017-model3d.xsd @@ -0,0 +1,148 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ooxml-schemas/microsoft/drawing-2018-animation-model3d.xsd b/ooxml-schemas/microsoft/drawing-2018-animation-model3d.xsd new file mode 100644 index 0000000000..f9c1f5b475 --- /dev/null +++ b/ooxml-schemas/microsoft/drawing-2018-animation-model3d.xsd @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/ooxml-schemas/microsoft/drawing-2018-animation.xsd b/ooxml-schemas/microsoft/drawing-2018-animation.xsd new file mode 100644 index 0000000000..18327c0551 --- /dev/null +++ b/ooxml-schemas/microsoft/drawing-2018-animation.xsd @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ooxml-schemas/microsoft/drawing-2018-hyperlinkcolor.xsd b/ooxml-schemas/microsoft/drawing-2018-hyperlinkcolor.xsd new file mode 100644 index 0000000000..c0e9b01554 --- /dev/null +++ b/ooxml-schemas/microsoft/drawing-2018-hyperlinkcolor.xsd @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/ooxml-schemas/microsoft/drawing-2018-sketchyshapes.xsd b/ooxml-schemas/microsoft/drawing-2018-sketchyshapes.xsd new file mode 100644 index 0000000000..ef1869a599 --- /dev/null +++ b/ooxml-schemas/microsoft/drawing-2018-sketchyshapes.xsd @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ooxml-schemas/microsoft/drawing-2020-classificationShape.xsd b/ooxml-schemas/microsoft/drawing-2020-classificationShape.xsd new file mode 100644 index 0000000000..79770f14b9 --- /dev/null +++ b/ooxml-schemas/microsoft/drawing-2020-classificationShape.xsd @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + diff --git a/ooxml-schemas/microsoft/drawing-2021-livefeed.xsd b/ooxml-schemas/microsoft/drawing-2021-livefeed.xsd new file mode 100644 index 0000000000..7aa294be4b --- /dev/null +++ b/ooxml-schemas/microsoft/drawing-2021-livefeed.xsd @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ooxml-schemas/microsoft/drawing-2021-scriptlink.xsd b/ooxml-schemas/microsoft/drawing-2021-scriptlink.xsd new file mode 100644 index 0000000000..6b8042d6ad --- /dev/null +++ b/ooxml-schemas/microsoft/drawing-2021-scriptlink.xsd @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/ooxml-schemas/microsoft/drawing-2022-imageformula.xsd b/ooxml-schemas/microsoft/drawing-2022-imageformula.xsd new file mode 100644 index 0000000000..d384ec0a7c --- /dev/null +++ b/ooxml-schemas/microsoft/drawing-2022-imageformula.xsd @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/ooxml-schemas/microsoft/excel-2010-spreadsheetDrawing.xsd b/ooxml-schemas/microsoft/excel-2010-spreadsheetDrawing.xsd new file mode 100644 index 0000000000..10071551c7 --- /dev/null +++ b/ooxml-schemas/microsoft/excel-2010-spreadsheetDrawing.xsd @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ooxml-schemas/microsoft/ink-2010-main.xsd b/ooxml-schemas/microsoft/ink-2010-main.xsd new file mode 100644 index 0000000000..f58afa0627 --- /dev/null +++ b/ooxml-schemas/microsoft/ink-2010-main.xsd @@ -0,0 +1,115 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ooxml-schemas/microsoft/thememl-2012-main.xsd b/ooxml-schemas/microsoft/thememl-2012-main.xsd new file mode 100644 index 0000000000..3af0b1740d --- /dev/null +++ b/ooxml-schemas/microsoft/thememl-2012-main.xsd @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff --git a/ooxml-schemas/microsoft/wml-2006.xsd b/ooxml-schemas/microsoft/wml-2006.xsd new file mode 100644 index 0000000000..1805953565 --- /dev/null +++ b/ooxml-schemas/microsoft/wml-2006.xsd @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ooxml-schemas/microsoft/wml-2010-contentPart.xsd b/ooxml-schemas/microsoft/wml-2010-contentPart.xsd new file mode 100644 index 0000000000..53baea80c1 --- /dev/null +++ b/ooxml-schemas/microsoft/wml-2010-contentPart.xsd @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ooxml-schemas/microsoft/wml-2010.xsd b/ooxml-schemas/microsoft/wml-2010.xsd index dd06b2a9e6..0413b23006 100644 --- a/ooxml-schemas/microsoft/wml-2010.xsd +++ b/ooxml-schemas/microsoft/wml-2010.xsd @@ -1,8 +1,13 @@ - - - - + + + + + + + + + + @@ -24,7 +29,7 @@ - + diff --git a/ooxml-schemas/microsoft/wml-2012.xsd b/ooxml-schemas/microsoft/wml-2012.xsd index 5100d9f0fb..f10facfa18 100644 --- a/ooxml-schemas/microsoft/wml-2012.xsd +++ b/ooxml-schemas/microsoft/wml-2012.xsd @@ -1,5 +1,8 @@ - - + + + + + @@ -21,7 +24,7 @@ - + @@ -37,7 +40,7 @@ - + @@ -62,5 +65,5 @@ - + diff --git a/ooxml-schemas/microsoft/wml-2018.xsd b/ooxml-schemas/microsoft/wml-2018.xsd index ae1b54c1ab..6e8c4414d2 100644 --- a/ooxml-schemas/microsoft/wml-2018.xsd +++ b/ooxml-schemas/microsoft/wml-2018.xsd @@ -1,5 +1,7 @@ - - + + + + diff --git a/ooxml-schemas/microsoft/wml-cei-2026.xsd b/ooxml-schemas/microsoft/wml-cei-2026.xsd new file mode 100644 index 0000000000..b7e7d147bc --- /dev/null +++ b/ooxml-schemas/microsoft/wml-cei-2026.xsd @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/ooxml-schemas/microsoft/wml-cex-2018.xsd b/ooxml-schemas/microsoft/wml-cex-2018.xsd index 99ea601dcc..2276111729 100644 --- a/ooxml-schemas/microsoft/wml-cex-2018.xsd +++ b/ooxml-schemas/microsoft/wml-cex-2018.xsd @@ -1,6 +1,9 @@ - - - + + + + + + @@ -13,7 +16,7 @@ - + diff --git a/ooxml-schemas/microsoft/wml-cid-2016.xsd b/ooxml-schemas/microsoft/wml-cid-2016.xsd index 7091e5fe6c..978a4a9c33 100644 --- a/ooxml-schemas/microsoft/wml-cid-2016.xsd +++ b/ooxml-schemas/microsoft/wml-cid-2016.xsd @@ -1,5 +1,11 @@ - - + + + + + + + + diff --git a/ooxml-schemas/microsoft/wml-du-2023.xsd b/ooxml-schemas/microsoft/wml-du-2023.xsd new file mode 100644 index 0000000000..2bf2d6103e --- /dev/null +++ b/ooxml-schemas/microsoft/wml-du-2023.xsd @@ -0,0 +1,5 @@ + + + + + diff --git a/ooxml-schemas/microsoft/wml-sdtdatahash-2020.xsd b/ooxml-schemas/microsoft/wml-sdtdatahash-2020.xsd index c1e485d408..0322b91a87 100644 --- a/ooxml-schemas/microsoft/wml-sdtdatahash-2020.xsd +++ b/ooxml-schemas/microsoft/wml-sdtdatahash-2020.xsd @@ -1,4 +1,7 @@ - - - + + + + + + diff --git a/ooxml-schemas/microsoft/wml-sdtformatlock-2024.xsd b/ooxml-schemas/microsoft/wml-sdtformatlock-2024.xsd new file mode 100644 index 0000000000..22c83d4fc9 --- /dev/null +++ b/ooxml-schemas/microsoft/wml-sdtformatlock-2024.xsd @@ -0,0 +1,7 @@ + + + + + + + diff --git a/ooxml-schemas/microsoft/wml-symex-2015.xsd b/ooxml-schemas/microsoft/wml-symex-2015.xsd index 2ff95d6b66..5bebab373b 100644 --- a/ooxml-schemas/microsoft/wml-symex-2015.xsd +++ b/ooxml-schemas/microsoft/wml-symex-2015.xsd @@ -1,7 +1,10 @@ - - + + + + + - + diff --git a/ooxml-schemas/microsoft/word-2010-wordprocessingCanvas.xsd b/ooxml-schemas/microsoft/word-2010-wordprocessingCanvas.xsd new file mode 100644 index 0000000000..73fa12edf2 --- /dev/null +++ b/ooxml-schemas/microsoft/word-2010-wordprocessingCanvas.xsd @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ooxml-schemas/microsoft/word-2010-wordprocessingDrawing.xsd b/ooxml-schemas/microsoft/word-2010-wordprocessingDrawing.xsd new file mode 100644 index 0000000000..fd3432cd7e --- /dev/null +++ b/ooxml-schemas/microsoft/word-2010-wordprocessingDrawing.xsd @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ooxml-schemas/microsoft/word-2010-wordprocessingGroup.xsd b/ooxml-schemas/microsoft/word-2010-wordprocessingGroup.xsd new file mode 100644 index 0000000000..34d2c68e44 --- /dev/null +++ b/ooxml-schemas/microsoft/word-2010-wordprocessingGroup.xsd @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ooxml-schemas/microsoft/word-2010-wordprocessingShape.xsd b/ooxml-schemas/microsoft/word-2010-wordprocessingShape.xsd new file mode 100644 index 0000000000..52a88a7618 --- /dev/null +++ b/ooxml-schemas/microsoft/word-2010-wordprocessingShape.xsd @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ooxml-schemas/microsoft/word-2012-wordprocessingDrawing.xsd b/ooxml-schemas/microsoft/word-2012-wordprocessingDrawing.xsd new file mode 100644 index 0000000000..62b623fdd6 --- /dev/null +++ b/ooxml-schemas/microsoft/word-2012-wordprocessingDrawing.xsd @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/ooxml-schemas/microsoft/word-2020-oembed.xsd b/ooxml-schemas/microsoft/word-2020-oembed.xsd new file mode 100644 index 0000000000..d66ea59a1d --- /dev/null +++ b/ooxml-schemas/microsoft/word-2020-oembed.xsd @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/ooxml-schemas/microsoft/word12.xsd b/ooxml-schemas/microsoft/word12.xsd deleted file mode 100644 index e57f38aa3e..0000000000 --- a/ooxml-schemas/microsoft/word12.xsd +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/package-lock.json b/package-lock.json index c81c229a75..7138140252 100644 --- a/package-lock.json +++ b/package-lock.json @@ -25,8 +25,8 @@ "@types/xml": "^1.0.8", "@typescript-eslint/eslint-plugin": "^8.8.1", "@typescript-eslint/parser": "^8.8.1", - "@vitest/coverage-v8": "^4.1.7", - "@vitest/ui": "^5.0.1", + "@vitest/coverage-v8": "^5.0.2", + "@vitest/ui": "^5.0.2", "cspell": "^10.0.0", "docsify-cli": "^5.0.0", "eslint": "^10.11.0", @@ -56,7 +56,7 @@ "vite": "^8.0.0", "vite-plugin-dts": "^5.0.1", "vite-plugin-node-polyfills": "^0.28.0", - "vitest": "^4.1.7" + "vitest": "^5.0.2" }, "engines": { "node": ">=10" @@ -105,9 +105,9 @@ } }, "node_modules/@babel/helper-string-parser": { - "version": "7.27.1", - "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.27.1.tgz", - "integrity": "sha512-qMlSxKbpRlAridDExk92nSobyDdpPijUq2DW6oDnUqd0iOGxmQjyqhMIihI9+zv4LPyZdRje2cavWPbCbWm3eA==", + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.29.7.tgz", + "integrity": "sha512-Pb5ijPrZ89GDH8223L4UP8i6QApWxs04RbPQJTeWDV0/keR2E36MeKnyr6LYmUUvqRRI+Iv87SuF1W6ErINzYw==", "dev": true, "license": "MIT", "engines": { @@ -115,22 +115,23 @@ } }, "node_modules/@babel/helper-validator-identifier": { - "version": "7.28.5", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.28.5.tgz", - "integrity": "sha512-qSs4ifwzKJSV39ucNjsvc6WVHs6b7S03sOh2OcHF9UHfVPqWWALUsNUVzhSBiItjRZoLHx7nIarVjqKVusUZ1Q==", + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.29.7.tgz", + "integrity": "sha512-qehxGkRj55h/ff8EMaJ+cYhyaKlHIxqYDn682wQD7RNp9UujOQsHog2uS0r2vzr4pW+sXf90NeeayjcNaX3fFg==", "dev": true, + "license": "MIT", "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/parser": { - "version": "7.29.0", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.29.0.tgz", - "integrity": "sha512-IyDgFV5GeDUVX4YdF/3CPULtVGSXXMLh1xVIgdCgxApktqnQV0r7/8Nqthg+8YLGaAtdyIlo2qIdZrbCv4+7ww==", + "version": "7.29.9", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.29.9.tgz", + "integrity": "sha512-CjXrNHTnvqBVqHgdBysY3vk2T8tpJHb5/RMeHJBTyVa9xgugCB0CJTx/3oO8RV2QRQP391RWpB7D6hLjm8V9uA==", "dev": true, "license": "MIT", "dependencies": { - "@babel/types": "^7.29.0" + "@babel/types": "^7.29.8" }, "bin": { "parser": "bin/babel-parser.js" @@ -140,14 +141,14 @@ } }, "node_modules/@babel/types": { - "version": "7.29.0", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.29.0.tgz", - "integrity": "sha512-LwdZHpScM4Qz8Xw2iKSzS+cfglZzJGvofQICy7W7v4caru4EaAmyUuO6BGrbyQ2mYV11W0U8j5mBhd14dd3B0A==", + "version": "7.29.8", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.29.8.tgz", + "integrity": "sha512-Vj1jF3cPfxg7OAfoI7QnVKLoILlm2JF9pnVHrX8qx7AHMiYWT+NDAA7jChlNgRS4WTLc/fD1lXLmPixluj+3Gg==", "dev": true, "license": "MIT", "dependencies": { - "@babel/helper-string-parser": "^7.27.1", - "@babel/helper-validator-identifier": "^7.28.5" + "@babel/helper-string-parser": "^7.29.7", + "@babel/helper-validator-identifier": "^7.29.7" }, "engines": { "node": ">=6.9.0" @@ -2019,9 +2020,9 @@ } }, "node_modules/@jridgewell/sourcemap-codec": { - "version": "1.5.5", - "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.5.tgz", - "integrity": "sha512-cYQ9310grqxueWbl+WuIUIaiUaDcj7WOq5fVhEljNVgRfOUhY9fy2zTvfoqWsnebh8Sl70VScFbICvJnLKB0Og==", + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.6.0.tgz", + "integrity": "sha512-T7jf+5zgsZHwNJ4lvQ7/aezbyk0nNX+zJVWpmHA7VYsEx7a7qr5Rg5IbtJFqkgze5Y2sruq1RUY8Q837Od7iFw==", "dev": true, "license": "MIT" }, @@ -2862,13 +2863,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/@standard-schema/spec": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/@standard-schema/spec/-/spec-1.1.0.tgz", - "integrity": "sha512-l2aFy5jALhniG5HgqrD6jXLi/rUWrKvqN/qJx6yoJsgKhblVd+iqqU4RCXavm/jPityDo5TCvKMnpjKnOriy0w==", - "dev": true, - "license": "MIT" - }, "node_modules/@tybys/wasm-util": { "version": "0.10.4", "resolved": "https://registry.npmjs.org/@tybys/wasm-util/-/wasm-util-0.10.4.tgz", @@ -3721,29 +3715,27 @@ ] }, "node_modules/@vitest/coverage-v8": { - "version": "4.1.7", - "resolved": "https://registry.npmjs.org/@vitest/coverage-v8/-/coverage-v8-4.1.7.tgz", - "integrity": "sha512-qsYPeXc5Q9dFLd1i8Ap+Bx8sQgcp+rFVQo4R0dDsWNBzl26ldVF1qOO+RL24K7FDrR6pA+50XedRLSoSG24bVQ==", + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/@vitest/coverage-v8/-/coverage-v8-5.0.2.tgz", + "integrity": "sha512-3ffHBEi8DOOBLwIGBhOBZbRfYFYWjMUuxZicONdhuFEFEG5AVsMOSrVeuROskqnqpbOmEJwxM2eTVZ9N3a1t+A==", "dev": true, "license": "MIT", "dependencies": { "@bcoe/v8-coverage": "^1.0.2", - "@vitest/utils": "4.1.7", - "ast-v8-to-istanbul": "^1.0.0", - "istanbul-lib-coverage": "^3.2.2", - "istanbul-lib-report": "^3.0.1", - "istanbul-reports": "^3.2.0", - "magicast": "^0.5.2", - "obug": "^2.1.1", - "std-env": "^4.0.0-rc.1", - "tinyrainbow": "^3.1.0" + "@vitest/istanbul-lib-coverage": "^1.0.0", + "@vitest/istanbul-lib-report": "^1.0.0", + "ast-v8-to-istanbul": "^1.0.5", + "magicast": "^0.5.4", + "obug": "^2.1.4", + "std-env": "^4.2.0", + "tinyrainbow": "^3.1.1" }, "funding": { "url": "https://opencollective.com/vitest" }, "peerDependencies": { - "@vitest/browser": "4.1.7", - "vitest": "4.1.7" + "@vitest/browser": "5.0.2", + "vitest": "5.0.2" }, "peerDependenciesMeta": { "@vitest/browser": { @@ -3751,34 +3743,40 @@ } } }, - "node_modules/@vitest/expect": { - "version": "4.1.7", - "resolved": "https://registry.npmjs.org/@vitest/expect/-/expect-4.1.7.tgz", - "integrity": "sha512-1R+tw0ortHEbZDGMymm+pN7/AFQ/RkFFdtd7EN+VBpynKmLbP8A3rpEXdshBJ7+8hQ9zBJh/i1s0yKNtxAnU7w==", + "node_modules/@vitest/istanbul-lib-coverage": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@vitest/istanbul-lib-coverage/-/istanbul-lib-coverage-1.0.1.tgz", + "integrity": "sha512-k3DJZ8LhMBK9NS4SclF1ASD3OgXEWDorbIcPTRDK0/Zae6fRvu+fJRxtFdLfHsa9Y24beCdPnoNZ4LviTNstfA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=22" + } + }, + "node_modules/@vitest/istanbul-lib-report": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@vitest/istanbul-lib-report/-/istanbul-lib-report-1.0.1.tgz", + "integrity": "sha512-1EOLRfsTMnyAr3+kEAsP4o9dhaDlGPpD7H5iLBBeq//YpNB1VIahkPhB+eRp9N2Dkfw8oySROjE3yf9XDeaIkQ==", "dev": true, "license": "MIT", "dependencies": { - "@standard-schema/spec": "^1.1.0", - "@types/chai": "^5.2.2", - "@vitest/spy": "4.1.7", - "@vitest/utils": "4.1.7", - "chai": "^6.2.2", - "tinyrainbow": "^3.1.0" + "@vitest/istanbul-lib-coverage": "1.0.1" }, - "funding": { - "url": "https://opencollective.com/vitest" + "engines": { + "node": ">=22" } }, "node_modules/@vitest/mocker": { - "version": "4.1.7", - "resolved": "https://registry.npmjs.org/@vitest/mocker/-/mocker-4.1.7.tgz", - "integrity": "sha512-vY7nuamKgfvpA1Koa3oYIw/k7D6kZnpGyNMZW8loow2bsBYla1TFdqTaXncWdRn4pgwNs+90RhnXhJScDwQeJA==", + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/@vitest/mocker/-/mocker-5.0.2.tgz", + "integrity": "sha512-Z5FS00Q1SJHkB35xATsmWGdQ5WA1/0MV3CDjqyv7GavHv1OfOj145MNfHOlHk7QLes21dKFDHr8EO2zvL+9WGA==", "dev": true, "license": "MIT", "dependencies": { - "@vitest/spy": "4.1.7", + "@jridgewell/trace-mapping": "0.3.31", + "@vitest/spy": "5.0.2", "estree-walker": "^3.0.3", - "magic-string": "^0.30.21" + "magic-string": "^1.2.3" }, "funding": { "url": "https://opencollective.com/vitest" @@ -3806,53 +3804,33 @@ "@types/estree": "^1.0.0" } }, + "node_modules/@vitest/mocker/node_modules/magic-string": { + "version": "1.4.2", + "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-1.4.2.tgz", + "integrity": "sha512-vG+rjFRj1PqdIBozIxAGMjPlOhaVe+GXpbttY/iSK7rGcJRMlwNJO7dcUwmUqkymsFLJiNGI06t4D7Fr7yRC9g==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/sourcemap-codec": "^1.6.0" + } + }, "node_modules/@vitest/pretty-format": { - "version": "4.1.7", - "resolved": "https://registry.npmjs.org/@vitest/pretty-format/-/pretty-format-4.1.7.tgz", - "integrity": "sha512-umgCarTOYQWIaDMvGDRZij+6b9oVeLIyJzfN+AS88e0ZOU3QTgNNSTtjQOpcvWr3np1N0j4WgZj+sb3oYBDscw==", + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/@vitest/pretty-format/-/pretty-format-5.0.2.tgz", + "integrity": "sha512-YHM+mQQ7N1ROHMugJ7P/M+fC/q1G4zs/iAMZZCvhHcY8WkwPQcXBHD+z18oz+808Cfa12K7jOr3XPQMcLIovjw==", "dev": true, "license": "MIT", "dependencies": { - "tinyrainbow": "^3.1.0" - }, - "funding": { - "url": "https://opencollective.com/vitest" - } - }, - "node_modules/@vitest/runner": { - "version": "4.1.7", - "resolved": "https://registry.npmjs.org/@vitest/runner/-/runner-4.1.7.tgz", - "integrity": "sha512-BapjmAQ2aI78WdMEfeUWivnfVzB+VPGwWRQcJE0OUq7qEeEcBsCSf+0T5iREBNE5nBb4wA5Ya0W6IA+sghdEFw==", - "dev": true, - "license": "MIT", - "dependencies": { - "@vitest/utils": "4.1.7", - "pathe": "^2.0.3" - }, - "funding": { - "url": "https://opencollective.com/vitest" - } - }, - "node_modules/@vitest/snapshot": { - "version": "4.1.7", - "resolved": "https://registry.npmjs.org/@vitest/snapshot/-/snapshot-4.1.7.tgz", - "integrity": "sha512-ZacLzja+TmJeZ1h14xW2FB/WpeimUD3haBXQPyJqxvo8jQTmfeA8zv58mtjN2C7EHXZDYVcVYdYmAxjkWVvKCw==", - "dev": true, - "license": "MIT", - "dependencies": { - "@vitest/pretty-format": "4.1.7", - "@vitest/utils": "4.1.7", - "magic-string": "^0.30.21", - "pathe": "^2.0.3" + "tinyrainbow": "^3.1.1" }, "funding": { "url": "https://opencollective.com/vitest" } }, "node_modules/@vitest/spy": { - "version": "4.1.7", - "resolved": "https://registry.npmjs.org/@vitest/spy/-/spy-4.1.7.tgz", - "integrity": "sha512-kbkI5LMWakyuTIvs6fUJ5qdIVb1XVKsYJAT4OJ938cHMROYMSfmoQdZy0aaAnjbbc8F61vkoTqz/Az+/HiIu5Q==", + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/@vitest/spy/-/spy-5.0.2.tgz", + "integrity": "sha512-Ijc7T1nT9efNb5LxvjaBrEqw3f/QwUv5EE0nKqZxgqsaV/FxAAZ8baGylA8X/Z2oS4Lp+K74Jr6dTJsDKxJDeg==", "dev": true, "license": "MIT", "funding": { @@ -3860,13 +3838,13 @@ } }, "node_modules/@vitest/ui": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/@vitest/ui/-/ui-5.0.1.tgz", - "integrity": "sha512-7PvQu/X9/pQoHYfNLAYL22qsD4/+sx2k7zpUA7XvjW0sc40r3/r0lGZ2fsEyOHMuO8Q1KjiO1QQVjJdnWUy/WQ==", + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/@vitest/ui/-/ui-5.0.2.tgz", + "integrity": "sha512-FRGWhLK/S+aaAtty/5d+jTtY5l+9pGNcjz6IHbyUiP3VWs6a+zIgU4lc1SzWCR7H+OXgetAI06i/VpCWQmVorQ==", "dev": true, "license": "MIT", "dependencies": { - "@vitest/utils": "5.0.1", + "@vitest/utils": "5.0.2", "fflate": "^0.8.3", "flatted": "^3.4.4", "pathe": "^2.0.3", @@ -3877,47 +3855,19 @@ "url": "https://opencollective.com/vitest" }, "peerDependencies": { - "vitest": "5.0.1" - } - }, - "node_modules/@vitest/ui/node_modules/@vitest/pretty-format": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/@vitest/pretty-format/-/pretty-format-5.0.1.tgz", - "integrity": "sha512-6guWwj5d9bguuefTOvJoq387tfpkzSv554YdUEGzjJH2PnnmvzTLQ1UQSuAk5wBFVhf2CUmy/S/palOcb6dmpA==", - "dev": true, - "license": "MIT", - "dependencies": { - "tinyrainbow": "^3.1.1" - }, - "funding": { - "url": "https://opencollective.com/vitest" - } - }, - "node_modules/@vitest/ui/node_modules/@vitest/utils": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/@vitest/utils/-/utils-5.0.1.tgz", - "integrity": "sha512-E9+yEA+jsfaoxZcUHFzEqUrQcoNh2EwrPT5efIqkUPUwD5Ua2Li9BRWaYeRwvzvdLgTSVrre8oKNeyrfg7KkdQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "@vitest/pretty-format": "5.0.1", - "convert-source-map": "^2.0.0", - "tinyrainbow": "^3.1.1" - }, - "funding": { - "url": "https://opencollective.com/vitest" + "vitest": "5.0.2" } }, "node_modules/@vitest/utils": { - "version": "4.1.7", - "resolved": "https://registry.npmjs.org/@vitest/utils/-/utils-4.1.7.tgz", - "integrity": "sha512-T532WBu791cBxJlCl6SO+J14l81DQx6uQHm1bQbmCDY7nqlEIgkza/UFnSBNaUtSf41unldDFjdOBYEQC4b5Hw==", + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/@vitest/utils/-/utils-5.0.2.tgz", + "integrity": "sha512-mgpUtxFhKeOKVaArBVHNJGdYHAeRh135o59l13uVmPUCS1OUtis5pBqXEgE25iqRgFqEBwXvJlkhknRsYnMeqg==", "dev": true, "license": "MIT", "dependencies": { - "@vitest/pretty-format": "4.1.7", + "@vitest/pretty-format": "5.0.2", "convert-source-map": "^2.0.0", - "tinyrainbow": "^3.1.0" + "tinyrainbow": "^3.1.1" }, "funding": { "url": "https://opencollective.com/vitest" @@ -4143,9 +4093,9 @@ } }, "node_modules/ast-v8-to-istanbul": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/ast-v8-to-istanbul/-/ast-v8-to-istanbul-1.0.0.tgz", - "integrity": "sha512-1fSfIwuDICFA4LKkCzRPO7F0hzFf0B7+Xqrl27ynQaa+Rh0e1Es0v6kWHPott3lU10AyAr7oKHa65OppjLn3Rg==", + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/ast-v8-to-istanbul/-/ast-v8-to-istanbul-1.0.7.tgz", + "integrity": "sha512-kFL68AG6ajd8fg248zwM9GQrUWEp79gsmjum34OEXjs4yHuUMZfYKwOLW9GMmB4oNvVrj+EAGxsP7ye2UR9UlA==", "dev": true, "license": "MIT", "dependencies": { @@ -5673,9 +5623,9 @@ } }, "node_modules/es-module-lexer": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-2.1.0.tgz", - "integrity": "sha512-n27zTYMjYu1aj4MjCWzSP7G9r75utsaoc8m61weK+W8JMBGGQybd43GstCXZ3WNmSFtGT9wi59qQTW6mhTR5LQ==", + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-2.3.2.tgz", + "integrity": "sha512-poHGpORABojJJucnV9KbOavETW8lBVnphkW77ER5/BQ5Fz7oXSoCNek7IH3vR5nRjdsEz926ibFYX8KtLQmdyw==", "dev": true, "license": "MIT" }, @@ -6499,9 +6449,9 @@ } }, "node_modules/expect-type": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/expect-type/-/expect-type-1.3.0.tgz", - "integrity": "sha512-knvyeauYhqjOYvQ66MznSMs83wmHrCycNEN6Ao+2AeYEfxUIkuiVxdEa1qlGEPK+We3n0THiDciYSsCcgW/DoA==", + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/expect-type/-/expect-type-1.4.0.tgz", + "integrity": "sha512-KfYbmpRm0VbLjEvVa9yGwCi9GI34xvi7A/HXYWQO65CSD2u3MczUJSuwXKFIxlGsgBQizV9q5J9NHj4VG0n+pA==", "dev": true, "license": "Apache-2.0", "engines": { @@ -7196,13 +7146,6 @@ } ] }, - "node_modules/html-escaper": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/html-escaper/-/html-escaper-2.0.2.tgz", - "integrity": "sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg==", - "dev": true, - "license": "MIT" - }, "node_modules/http-errors": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.0.tgz", @@ -7639,84 +7582,6 @@ "node": ">=10" } }, - "node_modules/istanbul-lib-coverage": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/istanbul-lib-coverage/-/istanbul-lib-coverage-3.2.2.tgz", - "integrity": "sha512-O8dpsF+r0WV/8MNRKfnmrtCWhuKjxrq2w+jpzBL5UZKTi2LeVWnWOmWRxFlesJONmc+wLAGvKQZEOanko0LFTg==", - "dev": true, - "license": "BSD-3-Clause", - "engines": { - "node": ">=8" - } - }, - "node_modules/istanbul-lib-report": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/istanbul-lib-report/-/istanbul-lib-report-3.0.1.tgz", - "integrity": "sha512-GCfE1mtsHGOELCU8e/Z7YWzpmybrx/+dSTfLrvY8qRmaY6zXTKWn6WQIjaAFw069icm6GVMNkgu0NzI4iPZUNw==", - "dev": true, - "license": "BSD-3-Clause", - "dependencies": { - "istanbul-lib-coverage": "^3.0.0", - "make-dir": "^4.0.0", - "supports-color": "^7.1.0" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/istanbul-lib-report/node_modules/has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=8" - } - }, - "node_modules/istanbul-lib-report/node_modules/make-dir": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-4.0.0.tgz", - "integrity": "sha512-hXdUTZYIVOt1Ex//jAQi+wTZZpUpwBj/0QsOzqegb3rGMMeJiSEu5xLHnYfBrRV4RH2+OCSOO95Is/7x1WJ4bw==", - "dev": true, - "license": "MIT", - "dependencies": { - "semver": "^7.5.3" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/istanbul-lib-report/node_modules/supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dev": true, - "license": "MIT", - "dependencies": { - "has-flag": "^4.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/istanbul-reports": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/istanbul-reports/-/istanbul-reports-3.2.0.tgz", - "integrity": "sha512-HGYWWS/ehqTV3xN10i23tkPkpH46MLCIMFNCaaKNavAXTF1RkqxawEPtnjnGZ6XKSInBKkiOA5BKS+aZiY3AvA==", - "dev": true, - "license": "BSD-3-Clause", - "dependencies": { - "html-escaper": "^2.0.0", - "istanbul-lib-report": "^3.0.0" - }, - "engines": { - "node": ">=8" - } - }, "node_modules/jiti": { "version": "2.7.0", "resolved": "https://registry.npmjs.org/jiti/-/jiti-2.7.0.tgz", @@ -8281,14 +8146,14 @@ } }, "node_modules/magicast": { - "version": "0.5.2", - "resolved": "https://registry.npmjs.org/magicast/-/magicast-0.5.2.tgz", - "integrity": "sha512-E3ZJh4J3S9KfwdjZhe2afj6R9lGIN5Pher1pF39UGrXRqq/VDaGVIGN13BjHd2u8B61hArAGOnso7nBOouW3TQ==", + "version": "0.5.5", + "resolved": "https://registry.npmjs.org/magicast/-/magicast-0.5.5.tgz", + "integrity": "sha512-UicdXN8zQ3JHlxVq+28afMXPr1z7WNY6+7EJnzTdQWkTAlMLF5fNCCKxJHBQwGaNGR11581EiQmQzx73+MvszA==", "dev": true, "license": "MIT", "dependencies": { - "@babel/parser": "^7.29.0", - "@babel/types": "^7.29.0", + "@babel/parser": "^7.29.7", + "@babel/types": "^7.29.7", "source-map-js": "^1.2.1" } }, @@ -8736,15 +8601,18 @@ } }, "node_modules/obug": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/obug/-/obug-2.1.1.tgz", - "integrity": "sha512-uTqF9MuPraAQ+IsnPf366RG4cP9RtUi7MLO1N3KEc+wb0a6yKpeL0lmk2IB1jY5KHPAlTc6T/JRdC/YqxHNwkQ==", + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/obug/-/obug-2.2.1.tgz", + "integrity": "sha512-XrsrhT5sybtKI6wakr2SPOlGZWWYbUXZ7a0jT8/QOeAPau+1X/bSegNe5YR75oJmEZQbKningirmGOEJCIk61Q==", "dev": true, "funding": [ "https://github.com/sponsors/sxzz", "https://opencollective.com/debug" ], - "license": "MIT" + "license": "MIT", + "engines": { + "node": ">=12.20.0" + } }, "node_modules/on-finished": { "version": "2.3.0", @@ -9920,13 +9788,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/siginfo": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/siginfo/-/siginfo-2.0.0.tgz", - "integrity": "sha512-ybx0WO1/8bSBLEWXZvEd7gMW3Sn3JFlW3TvX1nREbDLRNQNaeNN8WK0meBwPdAaOI7TtRRRJn/Es1zhrrCHu7g==", - "dev": true, - "license": "ISC" - }, "node_modules/signal-exit": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz", @@ -10028,13 +9889,6 @@ "node": ">=12.0.0" } }, - "node_modules/stackback": { - "version": "0.0.2", - "resolved": "https://registry.npmjs.org/stackback/-/stackback-0.0.2.tgz", - "integrity": "sha512-1XMJE5fQo1jGH6Y/7ebnwPOBEkIEnT4QF32d5R1+VXdXveM0IBMJt8zfaxX1P3QhVwrYe+576+jkANtSS2mBbw==", - "dev": true, - "license": "MIT" - }, "node_modules/statuses": { "version": "1.5.0", "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz", @@ -10045,9 +9899,9 @@ } }, "node_modules/std-env": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/std-env/-/std-env-4.1.0.tgz", - "integrity": "sha512-Rq7ybcX2RuC55r9oaPVEW7/xu3tj8u4GeBYHBWCychFtzMIr86A7e3PPEBPT37sHStKX3+TiX/Fr/ACmJLVlLQ==", + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/std-env/-/std-env-4.2.0.tgz", + "integrity": "sha512-oCUKSupKTHX53EyjDtuZQ64pjLJ6yYCtpmEw0goYxtjG9KpbRe8KAsl2tBUGU9DyMcJ0RwJ8GqJAFzMXcXW1Rw==", "dev": true, "license": "MIT" }, @@ -10224,11 +10078,14 @@ } }, "node_modules/tinybench": { - "version": "2.9.0", - "resolved": "https://registry.npmjs.org/tinybench/-/tinybench-2.9.0.tgz", - "integrity": "sha512-0+DUvqWMValLmha6lr4kD8iAMK1HzV0/aKnCtWb9v9641TnP/MFb7Pc2bxoxQjTXAErryXVgUOfv2YqNllqGeg==", + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/tinybench/-/tinybench-6.2.0.tgz", + "integrity": "sha512-78U2TlB2CnVenajOFzf3BKSm0J6oz5L0NV7g32LCPccvYc0lbWvys4d3uUUCS2B1N8PAf2+aekR8i1KbC3HO7Q==", "dev": true, - "license": "MIT" + "license": "MIT", + "engines": { + "node": ">=20.0.0" + } }, "node_modules/tinydate": { "version": "1.3.0", @@ -10240,9 +10097,9 @@ } }, "node_modules/tinyexec": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/tinyexec/-/tinyexec-1.0.2.tgz", - "integrity": "sha512-W/KYk+NFhkmsYpuHq5JykngiOCnxeVL8v8dFnqxSD8qEEdRfXk1SDM6JzNqcERbcGYj9tMrDQBYV9cjgnunFIg==", + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/tinyexec/-/tinyexec-1.3.1.tgz", + "integrity": "sha512-GCvB3aoys96IuDFBMcTB46JOR6mdMtAToqwiW8JlWhsoh1mhHi/xn9ss/Dg7N555GiJyEt2qzoG/NHCwM6h1EA==", "dev": true, "license": "MIT", "engines": { @@ -11132,38 +10989,31 @@ } }, "node_modules/vitest": { - "version": "4.1.7", - "resolved": "https://registry.npmjs.org/vitest/-/vitest-4.1.7.tgz", - "integrity": "sha512-flYyaFd2CgoCoU+0UKt3pxksgC+S02iTDN0n3LtqaMeXsI9SBcdNujc2k0DeFLzUn/0k538yNjOSdwgCqcrwJA==", + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/vitest/-/vitest-5.0.2.tgz", + "integrity": "sha512-7MQrx9pDv5aHiUcovIb/70Ys3tgtkUVgCtledvKdCmEO+/1Dicq5ZqoSxOW034m03oqC+oHOKui2dM6qtMLoJg==", "dev": true, "license": "MIT", "dependencies": { - "@vitest/expect": "4.1.7", - "@vitest/mocker": "4.1.7", - "@vitest/pretty-format": "4.1.7", - "@vitest/runner": "4.1.7", - "@vitest/snapshot": "4.1.7", - "@vitest/spy": "4.1.7", - "@vitest/utils": "4.1.7", - "es-module-lexer": "^2.0.0", - "expect-type": "^1.3.0", - "magic-string": "^0.30.21", - "obug": "^2.1.1", - "pathe": "^2.0.3", - "picomatch": "^4.0.3", - "std-env": "^4.0.0-rc.1", - "tinybench": "^2.9.0", - "tinyexec": "^1.0.2", - "tinyglobby": "^0.2.15", - "tinyrainbow": "^3.1.0", - "vite": "^6.0.0 || ^7.0.0 || ^8.0.0", - "why-is-node-running": "^2.3.0" + "@types/chai": "^5.2.2", + "@vitest/mocker": "5.0.2", + "chai": "^6.2.2", + "es-module-lexer": "^2.3.2", + "expect-type": "^1.4.0", + "magic-string": "^1.2.3", + "obug": "^2.1.4", + "picomatch": "^4.0.7", + "std-env": "^4.2.0", + "tinybench": "^6.1.4", + "tinyexec": "^1.3.0", + "tinyglobby": "^0.2.17", + "why-is-node-running": "^3.2.1" }, "bin": { "vitest": "vitest.mjs" }, "engines": { - "node": "^20.0.0 || ^22.0.0 || >=24.0.0" + "node": "^22.12.0 || ^24.0.0 || >=26.0.0" }, "funding": { "url": "https://opencollective.com/vitest" @@ -11171,16 +11021,16 @@ "peerDependencies": { "@edge-runtime/vm": "*", "@opentelemetry/api": "^1.9.0", - "@types/node": "^20.0.0 || ^22.0.0 || >=24.0.0", - "@vitest/browser-playwright": "4.1.7", - "@vitest/browser-preview": "4.1.7", - "@vitest/browser-webdriverio": "4.1.7", - "@vitest/coverage-istanbul": "4.1.7", - "@vitest/coverage-v8": "4.1.7", - "@vitest/ui": "4.1.7", + "@types/node": "^22.0.0 || >=24.0.0", + "@vitest/browser-playwright": "5.0.2", + "@vitest/browser-preview": "5.0.2", + "@vitest/browser-webdriverio": "^5.0.0-beta.5 || >=5.0.0", + "@vitest/coverage-istanbul": "5.0.2", + "@vitest/coverage-v8": "5.0.2", + "@vitest/ui": "5.0.2", "happy-dom": "*", "jsdom": "*", - "vite": "^6.0.0 || ^7.0.0 || ^8.0.0" + "vite": "^6.4.0 || ^7.0.0 || ^8.0.0" }, "peerDependenciesMeta": { "@edge-runtime/vm": { @@ -11221,10 +11071,20 @@ } } }, + "node_modules/vitest/node_modules/magic-string": { + "version": "1.4.2", + "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-1.4.2.tgz", + "integrity": "sha512-vG+rjFRj1PqdIBozIxAGMjPlOhaVe+GXpbttY/iSK7rGcJRMlwNJO7dcUwmUqkymsFLJiNGI06t4D7Fr7yRC9g==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/sourcemap-codec": "^1.6.0" + } + }, "node_modules/vitest/node_modules/picomatch": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.4.tgz", - "integrity": "sha512-QP88BAKvMam/3NxH6vj2o21R6MjxZUAd6nlwAS/pnGvN9IVLocLHxGYIzFhg6fUQ+5th6P4dv4eW9jX3DSIj7A==", + "version": "4.0.7", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.7.tgz", + "integrity": "sha512-qcJu88Q2IWqJsDD529JKMdwGm/dvInW4HvQnRwiH9JtihJvzGOscDtHE3x1pBKeUOTysQ8kVmLnJ2kJu7yhcGA==", "dev": true, "license": "MIT", "engines": { @@ -11366,20 +11226,16 @@ } }, "node_modules/why-is-node-running": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/why-is-node-running/-/why-is-node-running-2.3.0.tgz", - "integrity": "sha512-hUrmaWBdVDcxvYqnyh09zunKzROWjbZTiNy8dBEjkS7ehEDQibXJ7XvlmtbwuTclUiIyN+CyXQD4Vmko8fNm8w==", + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/why-is-node-running/-/why-is-node-running-3.2.2.tgz", + "integrity": "sha512-NKUzAelcoCXhXL4dJzKIwXeR8iEVqsA0Lq6Vnd0UXvgaKbzVo4ZTHROF2Jidrv+SgxOQ03fMinnNhzZATxOD3A==", "dev": true, "license": "MIT", - "dependencies": { - "siginfo": "^2.0.0", - "stackback": "0.0.2" - }, "bin": { "why-is-node-running": "cli.js" }, "engines": { - "node": ">=8" + "node": ">=20.11" } }, "node_modules/wrap-ansi": { @@ -11649,34 +11505,34 @@ } }, "@babel/helper-string-parser": { - "version": "7.27.1", - "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.27.1.tgz", - "integrity": "sha512-qMlSxKbpRlAridDExk92nSobyDdpPijUq2DW6oDnUqd0iOGxmQjyqhMIihI9+zv4LPyZdRje2cavWPbCbWm3eA==", + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.29.7.tgz", + "integrity": "sha512-Pb5ijPrZ89GDH8223L4UP8i6QApWxs04RbPQJTeWDV0/keR2E36MeKnyr6LYmUUvqRRI+Iv87SuF1W6ErINzYw==", "dev": true }, "@babel/helper-validator-identifier": { - "version": "7.28.5", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.28.5.tgz", - "integrity": "sha512-qSs4ifwzKJSV39ucNjsvc6WVHs6b7S03sOh2OcHF9UHfVPqWWALUsNUVzhSBiItjRZoLHx7nIarVjqKVusUZ1Q==", + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.29.7.tgz", + "integrity": "sha512-qehxGkRj55h/ff8EMaJ+cYhyaKlHIxqYDn682wQD7RNp9UujOQsHog2uS0r2vzr4pW+sXf90NeeayjcNaX3fFg==", "dev": true }, "@babel/parser": { - "version": "7.29.0", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.29.0.tgz", - "integrity": "sha512-IyDgFV5GeDUVX4YdF/3CPULtVGSXXMLh1xVIgdCgxApktqnQV0r7/8Nqthg+8YLGaAtdyIlo2qIdZrbCv4+7ww==", + "version": "7.29.9", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.29.9.tgz", + "integrity": "sha512-CjXrNHTnvqBVqHgdBysY3vk2T8tpJHb5/RMeHJBTyVa9xgugCB0CJTx/3oO8RV2QRQP391RWpB7D6hLjm8V9uA==", "dev": true, "requires": { - "@babel/types": "^7.29.0" + "@babel/types": "^7.29.8" } }, "@babel/types": { - "version": "7.29.0", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.29.0.tgz", - "integrity": "sha512-LwdZHpScM4Qz8Xw2iKSzS+cfglZzJGvofQICy7W7v4caru4EaAmyUuO6BGrbyQ2mYV11W0U8j5mBhd14dd3B0A==", + "version": "7.29.8", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.29.8.tgz", + "integrity": "sha512-Vj1jF3cPfxg7OAfoI7QnVKLoILlm2JF9pnVHrX8qx7AHMiYWT+NDAA7jChlNgRS4WTLc/fD1lXLmPixluj+3Gg==", "dev": true, "requires": { - "@babel/helper-string-parser": "^7.27.1", - "@babel/helper-validator-identifier": "^7.28.5" + "@babel/helper-string-parser": "^7.29.7", + "@babel/helper-validator-identifier": "^7.29.7" } }, "@bcoe/v8-coverage": { @@ -12866,9 +12722,9 @@ "dev": true }, "@jridgewell/sourcemap-codec": { - "version": "1.5.5", - "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.5.tgz", - "integrity": "sha512-cYQ9310grqxueWbl+WuIUIaiUaDcj7WOq5fVhEljNVgRfOUhY9fy2zTvfoqWsnebh8Sl70VScFbICvJnLKB0Og==", + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.6.0.tgz", + "integrity": "sha512-T7jf+5zgsZHwNJ4lvQ7/aezbyk0nNX+zJVWpmHA7VYsEx7a7qr5Rg5IbtJFqkgze5Y2sruq1RUY8Q837Od7iFw==", "dev": true }, "@jridgewell/trace-mapping": { @@ -13363,12 +13219,6 @@ "integrity": "sha512-tlqY9xq5ukxTUZBmoOp+m61cqwQD5pHJtFY3Mn8CA8ps6yghLH/Hw8UPdqg4OLmFW3IFlcXnQNmo/dh8HzXYIQ==", "dev": true }, - "@standard-schema/spec": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/@standard-schema/spec/-/spec-1.1.0.tgz", - "integrity": "sha512-l2aFy5jALhniG5HgqrD6jXLi/rUWrKvqN/qJx6yoJsgKhblVd+iqqU4RCXavm/jPityDo5TCvKMnpjKnOriy0w==", - "dev": true - }, "@tybys/wasm-util": { "version": "0.10.4", "resolved": "https://registry.npmjs.org/@tybys/wasm-util/-/wasm-util-0.10.4.tgz", @@ -13871,46 +13721,46 @@ "optional": true }, "@vitest/coverage-v8": { - "version": "4.1.7", - "resolved": "https://registry.npmjs.org/@vitest/coverage-v8/-/coverage-v8-4.1.7.tgz", - "integrity": "sha512-qsYPeXc5Q9dFLd1i8Ap+Bx8sQgcp+rFVQo4R0dDsWNBzl26ldVF1qOO+RL24K7FDrR6pA+50XedRLSoSG24bVQ==", + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/@vitest/coverage-v8/-/coverage-v8-5.0.2.tgz", + "integrity": "sha512-3ffHBEi8DOOBLwIGBhOBZbRfYFYWjMUuxZicONdhuFEFEG5AVsMOSrVeuROskqnqpbOmEJwxM2eTVZ9N3a1t+A==", "dev": true, "requires": { "@bcoe/v8-coverage": "^1.0.2", - "@vitest/utils": "4.1.7", - "ast-v8-to-istanbul": "^1.0.0", - "istanbul-lib-coverage": "^3.2.2", - "istanbul-lib-report": "^3.0.1", - "istanbul-reports": "^3.2.0", - "magicast": "^0.5.2", - "obug": "^2.1.1", - "std-env": "^4.0.0-rc.1", - "tinyrainbow": "^3.1.0" + "@vitest/istanbul-lib-coverage": "^1.0.0", + "@vitest/istanbul-lib-report": "^1.0.0", + "ast-v8-to-istanbul": "^1.0.5", + "magicast": "^0.5.4", + "obug": "^2.1.4", + "std-env": "^4.2.0", + "tinyrainbow": "^3.1.1" } }, - "@vitest/expect": { - "version": "4.1.7", - "resolved": "https://registry.npmjs.org/@vitest/expect/-/expect-4.1.7.tgz", - "integrity": "sha512-1R+tw0ortHEbZDGMymm+pN7/AFQ/RkFFdtd7EN+VBpynKmLbP8A3rpEXdshBJ7+8hQ9zBJh/i1s0yKNtxAnU7w==", + "@vitest/istanbul-lib-coverage": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@vitest/istanbul-lib-coverage/-/istanbul-lib-coverage-1.0.1.tgz", + "integrity": "sha512-k3DJZ8LhMBK9NS4SclF1ASD3OgXEWDorbIcPTRDK0/Zae6fRvu+fJRxtFdLfHsa9Y24beCdPnoNZ4LviTNstfA==", + "dev": true + }, + "@vitest/istanbul-lib-report": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@vitest/istanbul-lib-report/-/istanbul-lib-report-1.0.1.tgz", + "integrity": "sha512-1EOLRfsTMnyAr3+kEAsP4o9dhaDlGPpD7H5iLBBeq//YpNB1VIahkPhB+eRp9N2Dkfw8oySROjE3yf9XDeaIkQ==", "dev": true, "requires": { - "@standard-schema/spec": "^1.1.0", - "@types/chai": "^5.2.2", - "@vitest/spy": "4.1.7", - "@vitest/utils": "4.1.7", - "chai": "^6.2.2", - "tinyrainbow": "^3.1.0" + "@vitest/istanbul-lib-coverage": "1.0.1" } }, "@vitest/mocker": { - "version": "4.1.7", - "resolved": "https://registry.npmjs.org/@vitest/mocker/-/mocker-4.1.7.tgz", - "integrity": "sha512-vY7nuamKgfvpA1Koa3oYIw/k7D6kZnpGyNMZW8loow2bsBYla1TFdqTaXncWdRn4pgwNs+90RhnXhJScDwQeJA==", + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/@vitest/mocker/-/mocker-5.0.2.tgz", + "integrity": "sha512-Z5FS00Q1SJHkB35xATsmWGdQ5WA1/0MV3CDjqyv7GavHv1OfOj145MNfHOlHk7QLes21dKFDHr8EO2zvL+9WGA==", "dev": true, "requires": { - "@vitest/spy": "4.1.7", + "@jridgewell/trace-mapping": "0.3.31", + "@vitest/spy": "5.0.2", "estree-walker": "^3.0.3", - "magic-string": "^0.30.21" + "magic-string": "^1.2.3" }, "dependencies": { "estree-walker": { @@ -13921,91 +13771,56 @@ "requires": { "@types/estree": "^1.0.0" } + }, + "magic-string": { + "version": "1.4.2", + "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-1.4.2.tgz", + "integrity": "sha512-vG+rjFRj1PqdIBozIxAGMjPlOhaVe+GXpbttY/iSK7rGcJRMlwNJO7dcUwmUqkymsFLJiNGI06t4D7Fr7yRC9g==", + "dev": true, + "requires": { + "@jridgewell/sourcemap-codec": "^1.6.0" + } } } }, "@vitest/pretty-format": { - "version": "4.1.7", - "resolved": "https://registry.npmjs.org/@vitest/pretty-format/-/pretty-format-4.1.7.tgz", - "integrity": "sha512-umgCarTOYQWIaDMvGDRZij+6b9oVeLIyJzfN+AS88e0ZOU3QTgNNSTtjQOpcvWr3np1N0j4WgZj+sb3oYBDscw==", + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/@vitest/pretty-format/-/pretty-format-5.0.2.tgz", + "integrity": "sha512-YHM+mQQ7N1ROHMugJ7P/M+fC/q1G4zs/iAMZZCvhHcY8WkwPQcXBHD+z18oz+808Cfa12K7jOr3XPQMcLIovjw==", "dev": true, "requires": { - "tinyrainbow": "^3.1.0" - } - }, - "@vitest/runner": { - "version": "4.1.7", - "resolved": "https://registry.npmjs.org/@vitest/runner/-/runner-4.1.7.tgz", - "integrity": "sha512-BapjmAQ2aI78WdMEfeUWivnfVzB+VPGwWRQcJE0OUq7qEeEcBsCSf+0T5iREBNE5nBb4wA5Ya0W6IA+sghdEFw==", - "dev": true, - "requires": { - "@vitest/utils": "4.1.7", - "pathe": "^2.0.3" - } - }, - "@vitest/snapshot": { - "version": "4.1.7", - "resolved": "https://registry.npmjs.org/@vitest/snapshot/-/snapshot-4.1.7.tgz", - "integrity": "sha512-ZacLzja+TmJeZ1h14xW2FB/WpeimUD3haBXQPyJqxvo8jQTmfeA8zv58mtjN2C7EHXZDYVcVYdYmAxjkWVvKCw==", - "dev": true, - "requires": { - "@vitest/pretty-format": "4.1.7", - "@vitest/utils": "4.1.7", - "magic-string": "^0.30.21", - "pathe": "^2.0.3" + "tinyrainbow": "^3.1.1" } }, "@vitest/spy": { - "version": "4.1.7", - "resolved": "https://registry.npmjs.org/@vitest/spy/-/spy-4.1.7.tgz", - "integrity": "sha512-kbkI5LMWakyuTIvs6fUJ5qdIVb1XVKsYJAT4OJ938cHMROYMSfmoQdZy0aaAnjbbc8F61vkoTqz/Az+/HiIu5Q==", + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/@vitest/spy/-/spy-5.0.2.tgz", + "integrity": "sha512-Ijc7T1nT9efNb5LxvjaBrEqw3f/QwUv5EE0nKqZxgqsaV/FxAAZ8baGylA8X/Z2oS4Lp+K74Jr6dTJsDKxJDeg==", "dev": true }, "@vitest/ui": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/@vitest/ui/-/ui-5.0.1.tgz", - "integrity": "sha512-7PvQu/X9/pQoHYfNLAYL22qsD4/+sx2k7zpUA7XvjW0sc40r3/r0lGZ2fsEyOHMuO8Q1KjiO1QQVjJdnWUy/WQ==", + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/@vitest/ui/-/ui-5.0.2.tgz", + "integrity": "sha512-FRGWhLK/S+aaAtty/5d+jTtY5l+9pGNcjz6IHbyUiP3VWs6a+zIgU4lc1SzWCR7H+OXgetAI06i/VpCWQmVorQ==", "dev": true, "requires": { - "@vitest/utils": "5.0.1", + "@vitest/utils": "5.0.2", "fflate": "^0.8.3", "flatted": "^3.4.4", "pathe": "^2.0.3", "sirv": "^3.0.2", "tinyrainbow": "^3.1.1" - }, - "dependencies": { - "@vitest/pretty-format": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/@vitest/pretty-format/-/pretty-format-5.0.1.tgz", - "integrity": "sha512-6guWwj5d9bguuefTOvJoq387tfpkzSv554YdUEGzjJH2PnnmvzTLQ1UQSuAk5wBFVhf2CUmy/S/palOcb6dmpA==", - "dev": true, - "requires": { - "tinyrainbow": "^3.1.1" - } - }, - "@vitest/utils": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/@vitest/utils/-/utils-5.0.1.tgz", - "integrity": "sha512-E9+yEA+jsfaoxZcUHFzEqUrQcoNh2EwrPT5efIqkUPUwD5Ua2Li9BRWaYeRwvzvdLgTSVrre8oKNeyrfg7KkdQ==", - "dev": true, - "requires": { - "@vitest/pretty-format": "5.0.1", - "convert-source-map": "^2.0.0", - "tinyrainbow": "^3.1.1" - } - } } }, "@vitest/utils": { - "version": "4.1.7", - "resolved": "https://registry.npmjs.org/@vitest/utils/-/utils-4.1.7.tgz", - "integrity": "sha512-T532WBu791cBxJlCl6SO+J14l81DQx6uQHm1bQbmCDY7nqlEIgkza/UFnSBNaUtSf41unldDFjdOBYEQC4b5Hw==", + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/@vitest/utils/-/utils-5.0.2.tgz", + "integrity": "sha512-mgpUtxFhKeOKVaArBVHNJGdYHAeRh135o59l13uVmPUCS1OUtis5pBqXEgE25iqRgFqEBwXvJlkhknRsYnMeqg==", "dev": true, "requires": { - "@vitest/pretty-format": "4.1.7", + "@vitest/pretty-format": "5.0.2", "convert-source-map": "^2.0.0", - "tinyrainbow": "^3.1.0" + "tinyrainbow": "^3.1.1" } }, "@volar/language-core": { @@ -14179,9 +13994,9 @@ "dev": true }, "ast-v8-to-istanbul": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/ast-v8-to-istanbul/-/ast-v8-to-istanbul-1.0.0.tgz", - "integrity": "sha512-1fSfIwuDICFA4LKkCzRPO7F0hzFf0B7+Xqrl27ynQaa+Rh0e1Es0v6kWHPott3lU10AyAr7oKHa65OppjLn3Rg==", + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/ast-v8-to-istanbul/-/ast-v8-to-istanbul-1.0.7.tgz", + "integrity": "sha512-kFL68AG6ajd8fg248zwM9GQrUWEp79gsmjum34OEXjs4yHuUMZfYKwOLW9GMmB4oNvVrj+EAGxsP7ye2UR9UlA==", "dev": true, "requires": { "@jridgewell/trace-mapping": "^0.3.31", @@ -15314,9 +15129,9 @@ "dev": true }, "es-module-lexer": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-2.1.0.tgz", - "integrity": "sha512-n27zTYMjYu1aj4MjCWzSP7G9r75utsaoc8m61weK+W8JMBGGQybd43GstCXZ3WNmSFtGT9wi59qQTW6mhTR5LQ==", + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-2.3.2.tgz", + "integrity": "sha512-poHGpORABojJJucnV9KbOavETW8lBVnphkW77ER5/BQ5Fz7oXSoCNek7IH3vR5nRjdsEz926ibFYX8KtLQmdyw==", "dev": true }, "es-object-atoms": { @@ -15834,9 +15649,9 @@ } }, "expect-type": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/expect-type/-/expect-type-1.3.0.tgz", - "integrity": "sha512-knvyeauYhqjOYvQ66MznSMs83wmHrCycNEN6Ao+2AeYEfxUIkuiVxdEa1qlGEPK+We3n0THiDciYSsCcgW/DoA==", + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/expect-type/-/expect-type-1.4.0.tgz", + "integrity": "sha512-KfYbmpRm0VbLjEvVa9yGwCi9GI34xvi7A/HXYWQO65CSD2u3MczUJSuwXKFIxlGsgBQizV9q5J9NHj4VG0n+pA==", "dev": true }, "exsolve": { @@ -16312,12 +16127,6 @@ "integrity": "sha512-kig+rMn/QOVRvr7c86gQ8lWXq+Hkv6CbAH1hLu+RG338StTpE8Z0b44SDVaqVu7HGKf27frdmUYEs9hTUX/cLQ==", "dev": true }, - "html-escaper": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/html-escaper/-/html-escaper-2.0.2.tgz", - "integrity": "sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg==", - "dev": true - }, "http-errors": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.0.tgz", @@ -16593,59 +16402,6 @@ "integrity": "sha512-u4sej9B1LPSxTGKB/HiuzvEQnXH0ECYkSVQU39koSwmFAxhlEAFl9RdTvLv4TOTQUgBS5O3O5fwUxk6byBZ+IQ==", "dev": true }, - "istanbul-lib-coverage": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/istanbul-lib-coverage/-/istanbul-lib-coverage-3.2.2.tgz", - "integrity": "sha512-O8dpsF+r0WV/8MNRKfnmrtCWhuKjxrq2w+jpzBL5UZKTi2LeVWnWOmWRxFlesJONmc+wLAGvKQZEOanko0LFTg==", - "dev": true - }, - "istanbul-lib-report": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/istanbul-lib-report/-/istanbul-lib-report-3.0.1.tgz", - "integrity": "sha512-GCfE1mtsHGOELCU8e/Z7YWzpmybrx/+dSTfLrvY8qRmaY6zXTKWn6WQIjaAFw069icm6GVMNkgu0NzI4iPZUNw==", - "dev": true, - "requires": { - "istanbul-lib-coverage": "^3.0.0", - "make-dir": "^4.0.0", - "supports-color": "^7.1.0" - }, - "dependencies": { - "has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "dev": true - }, - "make-dir": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-4.0.0.tgz", - "integrity": "sha512-hXdUTZYIVOt1Ex//jAQi+wTZZpUpwBj/0QsOzqegb3rGMMeJiSEu5xLHnYfBrRV4RH2+OCSOO95Is/7x1WJ4bw==", - "dev": true, - "requires": { - "semver": "^7.5.3" - } - }, - "supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dev": true, - "requires": { - "has-flag": "^4.0.0" - } - } - } - }, - "istanbul-reports": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/istanbul-reports/-/istanbul-reports-3.2.0.tgz", - "integrity": "sha512-HGYWWS/ehqTV3xN10i23tkPkpH46MLCIMFNCaaKNavAXTF1RkqxawEPtnjnGZ6XKSInBKkiOA5BKS+aZiY3AvA==", - "dev": true, - "requires": { - "html-escaper": "^2.0.0", - "istanbul-lib-report": "^3.0.0" - } - }, "jiti": { "version": "2.7.0", "resolved": "https://registry.npmjs.org/jiti/-/jiti-2.7.0.tgz", @@ -16962,13 +16718,13 @@ } }, "magicast": { - "version": "0.5.2", - "resolved": "https://registry.npmjs.org/magicast/-/magicast-0.5.2.tgz", - "integrity": "sha512-E3ZJh4J3S9KfwdjZhe2afj6R9lGIN5Pher1pF39UGrXRqq/VDaGVIGN13BjHd2u8B61hArAGOnso7nBOouW3TQ==", + "version": "0.5.5", + "resolved": "https://registry.npmjs.org/magicast/-/magicast-0.5.5.tgz", + "integrity": "sha512-UicdXN8zQ3JHlxVq+28afMXPr1z7WNY6+7EJnzTdQWkTAlMLF5fNCCKxJHBQwGaNGR11581EiQmQzx73+MvszA==", "dev": true, "requires": { - "@babel/parser": "^7.29.0", - "@babel/types": "^7.29.0", + "@babel/parser": "^7.29.7", + "@babel/types": "^7.29.7", "source-map-js": "^1.2.1" } }, @@ -17304,9 +17060,9 @@ } }, "obug": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/obug/-/obug-2.1.1.tgz", - "integrity": "sha512-uTqF9MuPraAQ+IsnPf366RG4cP9RtUi7MLO1N3KEc+wb0a6yKpeL0lmk2IB1jY5KHPAlTc6T/JRdC/YqxHNwkQ==", + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/obug/-/obug-2.2.1.tgz", + "integrity": "sha512-XrsrhT5sybtKI6wakr2SPOlGZWWYbUXZ7a0jT8/QOeAPau+1X/bSegNe5YR75oJmEZQbKningirmGOEJCIk61Q==", "dev": true }, "on-finished": { @@ -18131,12 +17887,6 @@ "side-channel-map": "^1.0.1" } }, - "siginfo": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/siginfo/-/siginfo-2.0.0.tgz", - "integrity": "sha512-ybx0WO1/8bSBLEWXZvEd7gMW3Sn3JFlW3TvX1nREbDLRNQNaeNN8WK0meBwPdAaOI7TtRRRJn/Es1zhrrCHu7g==", - "dev": true - }, "signal-exit": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz", @@ -18206,12 +17956,6 @@ "integrity": "sha512-o3yWv49B/o4QZk5ZcsALc6t0+eCelPc44zZsLtCQnZPDwFpDYSWcDnrv2TtMmMbQ7uKo3J0HTURCqckw23czNQ==", "dev": true }, - "stackback": { - "version": "0.0.2", - "resolved": "https://registry.npmjs.org/stackback/-/stackback-0.0.2.tgz", - "integrity": "sha512-1XMJE5fQo1jGH6Y/7ebnwPOBEkIEnT4QF32d5R1+VXdXveM0IBMJt8zfaxX1P3QhVwrYe+576+jkANtSS2mBbw==", - "dev": true - }, "statuses": { "version": "1.5.0", "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz", @@ -18219,9 +17963,9 @@ "dev": true }, "std-env": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/std-env/-/std-env-4.1.0.tgz", - "integrity": "sha512-Rq7ybcX2RuC55r9oaPVEW7/xu3tj8u4GeBYHBWCychFtzMIr86A7e3PPEBPT37sHStKX3+TiX/Fr/ACmJLVlLQ==", + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/std-env/-/std-env-4.2.0.tgz", + "integrity": "sha512-oCUKSupKTHX53EyjDtuZQ64pjLJ6yYCtpmEw0goYxtjG9KpbRe8KAsl2tBUGU9DyMcJ0RwJ8GqJAFzMXcXW1Rw==", "dev": true }, "stream-browserify": { @@ -18360,9 +18104,9 @@ } }, "tinybench": { - "version": "2.9.0", - "resolved": "https://registry.npmjs.org/tinybench/-/tinybench-2.9.0.tgz", - "integrity": "sha512-0+DUvqWMValLmha6lr4kD8iAMK1HzV0/aKnCtWb9v9641TnP/MFb7Pc2bxoxQjTXAErryXVgUOfv2YqNllqGeg==", + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/tinybench/-/tinybench-6.2.0.tgz", + "integrity": "sha512-78U2TlB2CnVenajOFzf3BKSm0J6oz5L0NV7g32LCPccvYc0lbWvys4d3uUUCS2B1N8PAf2+aekR8i1KbC3HO7Q==", "dev": true }, "tinydate": { @@ -18372,9 +18116,9 @@ "dev": true }, "tinyexec": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/tinyexec/-/tinyexec-1.0.2.tgz", - "integrity": "sha512-W/KYk+NFhkmsYpuHq5JykngiOCnxeVL8v8dFnqxSD8qEEdRfXk1SDM6JzNqcERbcGYj9tMrDQBYV9cjgnunFIg==", + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/tinyexec/-/tinyexec-1.3.1.tgz", + "integrity": "sha512-GCvB3aoys96IuDFBMcTB46JOR6mdMtAToqwiW8JlWhsoh1mhHi/xn9ss/Dg7N555GiJyEt2qzoG/NHCwM6h1EA==", "dev": true }, "tinyglobby": { @@ -18902,37 +18646,39 @@ } }, "vitest": { - "version": "4.1.7", - "resolved": "https://registry.npmjs.org/vitest/-/vitest-4.1.7.tgz", - "integrity": "sha512-flYyaFd2CgoCoU+0UKt3pxksgC+S02iTDN0n3LtqaMeXsI9SBcdNujc2k0DeFLzUn/0k538yNjOSdwgCqcrwJA==", + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/vitest/-/vitest-5.0.2.tgz", + "integrity": "sha512-7MQrx9pDv5aHiUcovIb/70Ys3tgtkUVgCtledvKdCmEO+/1Dicq5ZqoSxOW034m03oqC+oHOKui2dM6qtMLoJg==", "dev": true, "requires": { - "@vitest/expect": "4.1.7", - "@vitest/mocker": "4.1.7", - "@vitest/pretty-format": "4.1.7", - "@vitest/runner": "4.1.7", - "@vitest/snapshot": "4.1.7", - "@vitest/spy": "4.1.7", - "@vitest/utils": "4.1.7", - "es-module-lexer": "^2.0.0", - "expect-type": "^1.3.0", - "magic-string": "^0.30.21", - "obug": "^2.1.1", - "pathe": "^2.0.3", - "picomatch": "^4.0.3", - "std-env": "^4.0.0-rc.1", - "tinybench": "^2.9.0", - "tinyexec": "^1.0.2", - "tinyglobby": "^0.2.15", - "tinyrainbow": "^3.1.0", - "vite": "^6.0.0 || ^7.0.0 || ^8.0.0", - "why-is-node-running": "^2.3.0" + "@types/chai": "^5.2.2", + "@vitest/mocker": "5.0.2", + "chai": "^6.2.2", + "es-module-lexer": "^2.3.2", + "expect-type": "^1.4.0", + "magic-string": "^1.2.3", + "obug": "^2.1.4", + "picomatch": "^4.0.7", + "std-env": "^4.2.0", + "tinybench": "^6.1.4", + "tinyexec": "^1.3.0", + "tinyglobby": "^0.2.17", + "why-is-node-running": "^3.2.1" }, "dependencies": { + "magic-string": { + "version": "1.4.2", + "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-1.4.2.tgz", + "integrity": "sha512-vG+rjFRj1PqdIBozIxAGMjPlOhaVe+GXpbttY/iSK7rGcJRMlwNJO7dcUwmUqkymsFLJiNGI06t4D7Fr7yRC9g==", + "dev": true, + "requires": { + "@jridgewell/sourcemap-codec": "^1.6.0" + } + }, "picomatch": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.4.tgz", - "integrity": "sha512-QP88BAKvMam/3NxH6vj2o21R6MjxZUAd6nlwAS/pnGvN9IVLocLHxGYIzFhg6fUQ+5th6P4dv4eW9jX3DSIj7A==", + "version": "4.0.7", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.7.tgz", + "integrity": "sha512-qcJu88Q2IWqJsDD529JKMdwGm/dvInW4HvQnRwiH9JtihJvzGOscDtHE3x1pBKeUOTysQ8kVmLnJ2kJu7yhcGA==", "dev": true } } @@ -19030,14 +18776,10 @@ } }, "why-is-node-running": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/why-is-node-running/-/why-is-node-running-2.3.0.tgz", - "integrity": "sha512-hUrmaWBdVDcxvYqnyh09zunKzROWjbZTiNy8dBEjkS7ehEDQibXJ7XvlmtbwuTclUiIyN+CyXQD4Vmko8fNm8w==", - "dev": true, - "requires": { - "siginfo": "^2.0.0", - "stackback": "0.0.2" - } + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/why-is-node-running/-/why-is-node-running-3.2.2.tgz", + "integrity": "sha512-NKUzAelcoCXhXL4dJzKIwXeR8iEVqsA0Lq6Vnd0UXvgaKbzVo4ZTHROF2Jidrv+SgxOQ03fMinnNhzZATxOD3A==", + "dev": true }, "wrap-ansi": { "version": "6.2.0", diff --git a/package.json b/package.json index 1c2f5e8f1e..b7ffd5b6d0 100644 --- a/package.json +++ b/package.json @@ -111,8 +111,8 @@ "@types/xml": "^1.0.8", "@typescript-eslint/eslint-plugin": "^8.8.1", "@typescript-eslint/parser": "^8.8.1", - "@vitest/coverage-v8": "^4.1.7", - "@vitest/ui": "^5.0.1", + "@vitest/coverage-v8": "^5.0.2", + "@vitest/ui": "^5.0.2", "cspell": "^10.0.0", "docsify-cli": "^5.0.0", "eslint": "^10.11.0", @@ -142,7 +142,7 @@ "vite": "^8.0.0", "vite-plugin-dts": "^5.0.1", "vite-plugin-node-polyfills": "^0.28.0", - "vitest": "^4.1.7" + "vitest": "^5.0.2" }, "engines": { "node": ">=10" diff --git a/scripts/render-shape-demos.sh b/scripts/render-shape-demos.sh index e08dd23a1a..4de22f9c13 100755 --- a/scripts/render-shape-demos.sh +++ b/scripts/render-shape-demos.sh @@ -1,10 +1,11 @@ #!/usr/bin/env bash -# Runs the shape demos, checks their XML against the schemas, and draws each page as a PNG with LibreOffice. +# Runs the shape demos, checks where their drawings' Word 2010 extensions are and that their drawing ids are unique, +# and draws each page as a PNG with LibreOffice. The Demos workflow checks them with the Open XML SDK validator. # # Usage: scripts/render-shape-demos.sh [output directory] [demo ...] # # The output directory (default build/shape-demos) gets each demo's .docx, .pdf and one PNG per page. -# Without demo names, all the shape demos are run. Needs the package built (npm run build) and xmllint. +# Without demo names, all the shape demos are run. Needs the package built (npm run build) and perl. # # The pages are drawn with LibreOffice (set SOFFICE if soffice isn't on the PATH) and pdftoppm from Poppler. # When SHAPE_RENDER_IMAGE names a Docker image built from scripts/shape-demos/Dockerfile, they are drawn in @@ -13,9 +14,6 @@ # docker build --platform linux/amd64 -t docx-shape-renderer scripts/shape-demos # SHAPE_RENDER_IMAGE=docx-shape-renderer scripts/render-shape-demos.sh # npm run run-ts -- scripts/compare-shape-renders.ts -# -# The bundled Microsoft schemas don't declare the Word 2010 wps/wpg/wpc namespaces, so the document is -# checked against the ISO schemas' definitions of the same elements in the wp namespace. Needs perl. set -euo pipefail @@ -26,7 +24,6 @@ if [ ${#DEMOS[@]} -eq 0 ]; then DEMOS=(107-inline-shapes 108-shapes 109-shape-groups 110-shape-connectors 111-shape-styles 112-shape-diagrams 113-shape-layout 115-shape-document-styles 116-shape-swimlanes 117-shape-page-layout 118-theme 120-custom-shapes) fi SOFFICE="${SOFFICE:-soffice}" -WP="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing" mkdir -p "$OUT" # Pages left over from an earlier run would be compared as if they were new @@ -38,22 +35,10 @@ for demo in "${DEMOS[@]}"; do npm run --silent run-ts -- "./demo/$demo.ts" cp "My Document.docx" "$OUT/$demo.docx" - # Check the XML, with the Word 2010 drawing namespaces moved to the wp namespace. Content that has a fallback - # (mc:AlternateContent) is checked twice: as read by applications that use the choice, and by those that don't + # Where the Word 2010 drawing extensions (wp14) are: a floating drawing's relative sizes come after its graphic, and + # a percentage offset is the choice for a position, with its offset in EMUs as the fallback extracted="$(mktemp -d)" unzip -q -o "$OUT/$demo.docx" -d "$extracted" - - # The Word 2010 drawing extensions (wp14), which the ISO schemas don't have, are checked against their own schema, - # and where they are: a floating drawing's relative sizes come after its graphic, and a percentage offset is the - # choice for a position, with its offset in EMUs as the fallback - perl -0ne 'print qq(); - print "$1\n" while /(|.*?<\/wp14:\3>)/gs; - print "\n"' "$extracted/word/document.xml" > "$extracted/wp14.xml" - if ! xmllint --noout --schema scripts/shape-demos/wp14.xsd "$extracted/wp14.xml" 2> "$extracted/errors.txt"; then - cat "$extracted/errors.txt" - echo "::error::$demo has Word 2010 drawing extensions that don't match their schema" - failed=1 - fi misplaced="$(perl -0ne '$all = () = /-?\d+<\/wp14:pctPos\1Offset><\/mc:Choice>-?\d+<\/wp:posOffset><\/mc:Fallback><\/mc:AlternateContent><\/wp:position\1>/g; while (/<\/a:graphic>((?:)+)<\/wp:anchor>/gs) { my $sizes = $1; $placed += () = $sizes =~ /##g" \ - > "$extracted/document-as-wp.xml" - if ! xmllint --noout --schema ooxml-schemas/microsoft/wml-2010.xsd "$extracted/document-as-wp.xml" 2> "$extracted/errors.txt"; then - cat "$extracted/errors.txt" - echo "::error::$demo doesn't match the schema, read with the $view" - failed=1 - fi - done - - # The document's theme - if ! xmllint --noout --schema ooxml-schemas/ISO-IEC29500-4_2016/dml-main.xsd "$extracted/word/theme/theme1.xml" 2> "$extracted/errors.txt"; then - cat "$extracted/errors.txt" - echo "::error::$demo has a theme that doesn't match the schema" - failed=1 - fi - # Drawing ids must be unique across the document repeated="$(grep -ho '\(wp:docPr\|wps:cNvPr\|pic:cNvPr\|wpg:cNvPr\) id="[0-9]*"' "$extracted"/word/*.xml | sed 's/.*id=//' | sort | uniq -d)" if [ -n "$repeated" ]; then diff --git a/scripts/shape-demos/wp14.xsd b/scripts/shape-demos/wp14.xsd deleted file mode 100644 index c1c625b0ff..0000000000 --- a/scripts/shape-demos/wp14.xsd +++ /dev/null @@ -1,63 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/file/document/body/section-properties/section-properties.spec.ts b/src/file/document/body/section-properties/section-properties.spec.ts index b538225dfa..455957cd6f 100644 --- a/src/file/document/body/section-properties/section-properties.spec.ts +++ b/src/file/document/body/section-properties/section-properties.spec.ts @@ -374,5 +374,18 @@ describe("SectionProperties", () => { "w:textDirection": { _attr: { "w:val": "lrTb" } }, }); }); + + it("should write the previous section properties last, after the document grid, as the schema requires", () => { + const properties = new SectionProperties({ + revision: { + id: 1, + author: "Firstname Lastname", + date: "123", + }, + }); + const tree = new Formatter().format(properties); + const elements = (tree["w:sectPr"] as readonly Record[]).map((child) => Object.keys(child)[0]); + expect(elements.slice(-2)).to.deep.equal(["w:docGrid", "w:sectPrChange"]); + }); }); }); diff --git a/src/file/document/body/section-properties/section-properties.ts b/src/file/document/body/section-properties/section-properties.ts index b5da99a646..4fcc2f9a12 100644 --- a/src/file/document/body/section-properties/section-properties.ts +++ b/src/file/document/body/section-properties/section-properties.ts @@ -317,11 +317,12 @@ export class SectionProperties extends XmlComponent { this.root.push(new PageTextDirection(textDirection)); } + this.root.push(createDocumentGrid({ linePitch, charSpace, type: gridType })); + + // CT_SectPr puts the previous section properties after all the others if (revision) { this.root.push(new SectionPropertiesChange(revision)); } - - this.root.push(createDocumentGrid({ linePitch, charSpace, type: gridType })); } /** diff --git a/src/file/file.spec.ts b/src/file/file.spec.ts index 8852807a2b..2a46c93f08 100644 --- a/src/file/file.spec.ts +++ b/src/file/file.spec.ts @@ -6,6 +6,7 @@ import { sectionMarginDefaults, sectionPageSizeDefaults } from "./document"; import { File } from "./file"; import { Footer, Header } from "./header"; import { Paragraph, TextRun } from "./paragraph"; +import { createDefaultStyles } from "./styles/factory"; const PAGE_SIZE_DEFAULTS = { "w:h": sectionPageSizeDefaults.HEIGHT, @@ -641,6 +642,10 @@ describe("File", () => { + + + + `, styles: { default: { @@ -653,7 +658,45 @@ describe("File", () => { }, }); - expect(doc.Styles).to.not.be.undefined; + const tree = new Formatter().format(doc.Styles)["w:styles"]; + const names = tree.map((child: object) => Object.keys(child)[0]); + const ids = tree.map( + (child: { readonly "w:style"?: readonly { readonly _attr?: Record }[] }) => + child["w:style"]?.find((part) => part._attr)?._attr?.["w:styleId"], + ); + + // The external document defaults take the place of docx's, and come first + expect(names.filter((name: string) => name === "w:docDefaults")).to.have.length(1); + expect(tree[1]).to.deep.equal({ "w:docDefaults": [{ "w:rPrDefault": {} }] }); + // The external Title takes the place of docx's + expect(ids.filter((id: string) => id === "Title")).to.have.length(1); + expect(tree[ids.indexOf("Title")]).to.deep.equal({ + "w:style": [{ _attr: { "w:type": "paragraph", "w:styleId": "Title" } }, { "w:name": { _attr: { "w:val": "Title" } } }], + }); + // The Heading1 given in styles.default takes the place of the external one, and docx's styles fill in the rest + expect(ids.filter((id: string) => id === "Heading1")).to.have.length(1); + expect(tree[ids.indexOf("Heading1")]).to.deep.equal( + new Formatter().format(createDefaultStyles({ heading1: { run: { size: 28 } } }).heading1), + ); + expect(ids).to.include("Heading2"); + }); + + it("should replace the external document defaults with those given in styles.default", () => { + const doc = new File({ + sections: [], + externalStyles: ` + + + `, + styles: { default: { document: { run: { font: "Arial" } } } }, + }); + + const tree = new Formatter().format(doc.Styles)["w:styles"]; + const defaults = tree.filter((child: object) => "w:docDefaults" in child); + expect(defaults).to.deep.equal([ + new Formatter().format(createDefaultStyles({ document: { run: { font: "Arial" } } }).document), + ]); + expect(tree[1]).to.deep.equal(defaults[0]); }); }); diff --git a/src/file/file.ts b/src/file/file.ts index 3a86920277..8a4806b763 100644 --- a/src/file/file.ts +++ b/src/file/file.ts @@ -27,8 +27,9 @@ import { Relationships } from "./relationships"; import { Settings } from "./settings"; import { Styles } from "./styles"; import { ExternalStylesFactory } from "./styles/external-styles-factory"; -import { DefaultStylesFactory } from "./styles/factory"; +import { DefaultStylesFactory, createDefaultStyles } from "./styles/factory"; import { Theme } from "./theme"; +import type { XmlComponent } from "./xml-components"; /** * Options for a document section. @@ -217,13 +218,20 @@ export class File { this.media = new Media(); if (options.externalStyles !== undefined) { - const defaultFactory = new DefaultStylesFactory(); - const defaultStyles = defaultFactory.newInstance(options.styles?.default); + const given = options.styles?.default ?? {}; + const defaultStyles = Object.entries(createDefaultStyles(given)); + const isGiven = ([key]: readonly [string, XmlComponent]): boolean => given[key as keyof typeof given] !== undefined; const externalFactory = new ExternalStylesFactory(); const externalStyles = externalFactory.newInstance(options.externalStyles); + // A style replaces an earlier one with its id. So the external styles replace docx's default styles, and the + // default styles given in styles.default replace the external ones this.styles = new Styles({ ...externalStyles, - importedStyles: [...defaultStyles.importedStyles!, ...externalStyles.importedStyles!], + importedStyles: [ + ...defaultStyles.filter((entry) => !isGiven(entry)).map(([, style]) => style), + ...externalStyles.importedStyles!, + ...defaultStyles.filter(isGiven).map(([, style]) => style), + ], }); } else if (options.styles) { const stylesFactory = new DefaultStylesFactory(); diff --git a/src/file/fonts/font.spec.ts b/src/file/fonts/font.spec.ts index bfb0bc2efc..7cfc6b3774 100644 --- a/src/file/fonts/font.spec.ts +++ b/src/file/fonts/font.spec.ts @@ -220,4 +220,29 @@ describe("font", () => { ]), }); }); + + it("should write a lower-case font key in upper case, as ST_Guid only allows upper-case hex digits", () => { + const tree = new Formatter().format( + createFont({ + name: "Times New Roman", + embedRegular: { + id: "rId0", + fontKey: "8fe2cf26-5e68-f0dc-37a8-b5d5c909da91", + }, + }), + ); + + expect(tree).toStrictEqual({ + "w:font": expect.arrayContaining([ + { + "w:embedRegular": { + _attr: { + "r:id": "rId0", + "w:fontKey": "{8FE2CF26-5E68-F0DC-37A8-B5D5C909DA91}", + }, + }, + }, + ]), + }); + }); }); diff --git a/src/file/fonts/font.ts b/src/file/fonts/font.ts index a2dd152995..ac7e4c2911 100644 --- a/src/file/fonts/font.ts +++ b/src/file/fonts/font.ts @@ -121,7 +121,8 @@ const createFontRelationship = ({ id, fontKey, subsetted }: IFontRelationshipOpt name, attributes: { id: { key: "r:id", value: id }, - ...(fontKey ? { fontKey: { key: "w:fontKey", value: `{${fontKey}}` } } : {}), + // ST_Guid only allows upper-case hex digits. The obfuscation reads the key's hex digits in either case + ...(fontKey ? { fontKey: { key: "w:fontKey", value: `{${fontKey.toUpperCase()}}` } } : {}), }, children: [...(subsetted ? [new OnOffElement("w:subsetted", subsetted)] : [])], }); diff --git a/src/file/fonts/obsfuscate-ttf-to-odttf.spec.ts b/src/file/fonts/obsfuscate-ttf-to-odttf.spec.ts index f8561b43b9..4e94bdfef4 100644 --- a/src/file/fonts/obsfuscate-ttf-to-odttf.spec.ts +++ b/src/file/fonts/obsfuscate-ttf-to-odttf.spec.ts @@ -17,6 +17,11 @@ describe("obfuscate", () => { expect(buffer[0]).toBe(0xff); }); + it("should obfuscate the same way with a lower-case key as with the upper-case key written in the font table", () => { + const input = new Uint8Array(64).map((_, i) => i); + expect(obfuscate(input, "8fe2cf26-5e68-f0dc-37a8-b5d5c909da91")).toEqual(obfuscate(input, "8FE2CF26-5E68-F0DC-37A8-B5D5C909DA91")); + }); + it("should throw error if uuid is not correct", () => { expect(() => obfuscate(Buffer.from(""), "bad-uuid")).toThrowError(); }); diff --git a/src/file/numbering/abstract-numbering.spec.ts b/src/file/numbering/abstract-numbering.spec.ts index 77a3dd7b94..5a5f954341 100644 --- a/src/file/numbering/abstract-numbering.spec.ts +++ b/src/file/numbering/abstract-numbering.spec.ts @@ -67,13 +67,13 @@ describe("AbstractNumbering", () => { { "w:lvlJc": { _attr: { - "w:val": "end", + "w:val": "right", }, }, }, { _attr: { - "w15:tentative": 1, + "w:tentative": 1, "w:ilvl": 3, }, }, @@ -83,7 +83,7 @@ describe("AbstractNumbering", () => { }); }); - it("uses 'start' as the default alignment", () => { + it("writes the default alignment, start, as left", () => { const abstractNumbering = new AbstractNumbering(1, [ { level: 3, @@ -133,13 +133,13 @@ describe("AbstractNumbering", () => { { "w:lvlJc": { _attr: { - "w:val": "start", + "w:val": "left", }, }, }, { _attr: { - "w15:tentative": 1, + "w:tentative": 1, "w:ilvl": 3, }, }, @@ -208,13 +208,13 @@ describe("AbstractNumbering", () => { { "w:lvlJc": { _attr: { - "w:val": "end", + "w:val": "right", }, }, }, { _attr: { - "w15:tentative": 1, + "w:tentative": 1, "w:ilvl": 3, }, }, @@ -281,7 +281,7 @@ describe("AbstractNumbering", () => { { "w:lvlJc": { _attr: { - "w:val": "start", + "w:val": "left", }, }, }, @@ -298,7 +298,7 @@ describe("AbstractNumbering", () => { }, { _attr: { - "w15:tentative": 1, + "w:tentative": 1, "w:ilvl": 0, }, }, @@ -363,7 +363,7 @@ describe("AbstractNumbering", () => { { "w:lvlJc": { _attr: { - "w:val": "start", + "w:val": "left", }, }, }, @@ -381,7 +381,7 @@ describe("AbstractNumbering", () => { }, { _attr: { - "w15:tentative": 1, + "w:tentative": 1, "w:ilvl": 0, }, }, @@ -446,7 +446,7 @@ describe("AbstractNumbering", () => { { "w:lvlJc": { _attr: { - "w:val": "start", + "w:val": "left", }, }, }, @@ -463,7 +463,7 @@ describe("AbstractNumbering", () => { }, { _attr: { - "w15:tentative": 1, + "w:tentative": 1, "w:ilvl": 0, }, }, @@ -528,7 +528,7 @@ describe("AbstractNumbering", () => { { "w:lvlJc": { _attr: { - "w:val": "start", + "w:val": "left", }, }, }, @@ -545,7 +545,7 @@ describe("AbstractNumbering", () => { }, { _attr: { - "w15:tentative": 1, + "w:tentative": 1, "w:ilvl": 0, }, }, @@ -610,7 +610,7 @@ describe("AbstractNumbering", () => { { "w:lvlJc": { _attr: { - "w:val": "start", + "w:val": "left", }, }, }, @@ -627,7 +627,7 @@ describe("AbstractNumbering", () => { }, { _attr: { - "w15:tentative": 1, + "w:tentative": 1, "w:ilvl": 0, }, }, @@ -692,7 +692,7 @@ describe("AbstractNumbering", () => { { "w:lvlJc": { _attr: { - "w:val": "start", + "w:val": "left", }, }, }, @@ -709,7 +709,7 @@ describe("AbstractNumbering", () => { }, { _attr: { - "w15:tentative": 1, + "w:tentative": 1, "w:ilvl": 0, }, }, @@ -774,7 +774,7 @@ describe("AbstractNumbering", () => { { "w:lvlJc": { _attr: { - "w:val": "start", + "w:val": "left", }, }, }, @@ -798,7 +798,7 @@ describe("AbstractNumbering", () => { }, { _attr: { - "w15:tentative": 1, + "w:tentative": 1, "w:ilvl": 0, }, }, @@ -863,7 +863,7 @@ describe("AbstractNumbering", () => { { "w:lvlJc": { _attr: { - "w:val": "start", + "w:val": "left", }, }, }, @@ -885,7 +885,7 @@ describe("AbstractNumbering", () => { }, { _attr: { - "w15:tentative": 1, + "w:tentative": 1, "w:ilvl": 0, }, }, @@ -950,7 +950,7 @@ describe("AbstractNumbering", () => { { "w:lvlJc": { _attr: { - "w:val": "start", + "w:val": "left", }, }, }, @@ -972,7 +972,7 @@ describe("AbstractNumbering", () => { }, { _attr: { - "w15:tentative": 1, + "w:tentative": 1, "w:ilvl": 0, }, }, @@ -1037,7 +1037,7 @@ describe("AbstractNumbering", () => { { "w:lvlJc": { _attr: { - "w:val": "start", + "w:val": "left", }, }, }, @@ -1050,7 +1050,7 @@ describe("AbstractNumbering", () => { }, { _attr: { - "w15:tentative": 1, + "w:tentative": 1, "w:ilvl": 0, }, }, @@ -1115,7 +1115,7 @@ describe("AbstractNumbering", () => { { "w:lvlJc": { _attr: { - "w:val": "start", + "w:val": "left", }, }, }, @@ -1128,7 +1128,7 @@ describe("AbstractNumbering", () => { }, { _attr: { - "w15:tentative": 1, + "w:tentative": 1, "w:ilvl": 0, }, }, @@ -1215,7 +1215,7 @@ describe("AbstractNumbering", () => { { "w:lvlJc": { _attr: { - "w:val": "start", + "w:val": "left", }, }, }, @@ -1224,7 +1224,7 @@ describe("AbstractNumbering", () => { }, { _attr: { - "w15:tentative": 1, + "w:tentative": 1, "w:ilvl": 0, }, }, @@ -1290,7 +1290,7 @@ describe("AbstractNumbering", () => { { "w:lvlJc": { _attr: { - "w:val": "start", + "w:val": "left", }, }, }, @@ -1303,7 +1303,7 @@ describe("AbstractNumbering", () => { }, { _attr: { - "w15:tentative": 1, + "w:tentative": 1, "w:ilvl": 0, }, }, @@ -1368,7 +1368,7 @@ describe("AbstractNumbering", () => { { "w:lvlJc": { _attr: { - "w:val": "start", + "w:val": "left", }, }, }, @@ -1381,7 +1381,7 @@ describe("AbstractNumbering", () => { }, { _attr: { - "w15:tentative": 1, + "w:tentative": 1, "w:ilvl": 0, }, }, @@ -1447,7 +1447,7 @@ describe("AbstractNumbering", () => { { "w:lvlJc": { _attr: { - "w:val": "start", + "w:val": "left", }, }, }, @@ -1460,7 +1460,7 @@ describe("AbstractNumbering", () => { }, { _attr: { - "w15:tentative": 1, + "w:tentative": 1, "w:ilvl": 0, }, }, @@ -1525,7 +1525,7 @@ describe("AbstractNumbering", () => { { "w:lvlJc": { _attr: { - "w:val": "start", + "w:val": "left", }, }, }, @@ -1538,7 +1538,7 @@ describe("AbstractNumbering", () => { }, { _attr: { - "w15:tentative": 1, + "w:tentative": 1, "w:ilvl": 0, }, }, @@ -1603,7 +1603,7 @@ describe("AbstractNumbering", () => { { "w:lvlJc": { _attr: { - "w:val": "start", + "w:val": "left", }, }, }, @@ -1612,7 +1612,7 @@ describe("AbstractNumbering", () => { }, { _attr: { - "w15:tentative": 1, + "w:tentative": 1, "w:ilvl": 0, }, }, @@ -1677,7 +1677,7 @@ describe("AbstractNumbering", () => { { "w:lvlJc": { _attr: { - "w:val": "start", + "w:val": "left", }, }, }, @@ -1686,7 +1686,7 @@ describe("AbstractNumbering", () => { }, { _attr: { - "w15:tentative": 1, + "w:tentative": 1, "w:ilvl": 0, }, }, @@ -1751,7 +1751,7 @@ describe("AbstractNumbering", () => { { "w:lvlJc": { _attr: { - "w:val": "start", + "w:val": "left", }, }, }, @@ -1771,7 +1771,7 @@ describe("AbstractNumbering", () => { }, { _attr: { - "w15:tentative": 1, + "w:tentative": 1, "w:ilvl": 0, }, }, @@ -1839,7 +1839,7 @@ describe("AbstractNumbering", () => { { "w:lvlJc": { _attr: { - "w:val": "start", + "w:val": "left", }, }, }, @@ -1857,7 +1857,7 @@ describe("AbstractNumbering", () => { }, { _attr: { - "w15:tentative": 1, + "w:tentative": 1, "w:ilvl": 0, }, }, @@ -1937,7 +1937,7 @@ describe("AbstractNumbering", () => { { "w:lvlJc": { _attr: { - "w:val": "start", + "w:val": "left", }, }, }, @@ -1946,7 +1946,7 @@ describe("AbstractNumbering", () => { }, { _attr: { - "w15:tentative": 1, + "w:tentative": 1, "w:ilvl": 0, }, }, @@ -2027,7 +2027,7 @@ describe("AbstractNumbering", () => { { "w:lvlJc": { _attr: { - "w:val": "start", + "w:val": "left", }, }, }, @@ -2036,7 +2036,7 @@ describe("AbstractNumbering", () => { }, { _attr: { - "w15:tentative": 1, + "w:tentative": 1, "w:ilvl": 0, }, }, @@ -2047,99 +2047,26 @@ describe("AbstractNumbering", () => { }); }); - const highlightTests = [ - { - highlight: HighlightColor.YELLOW, - expected: [{ "w:highlight": { _attr: { "w:val": "yellow" } } }, { "w:highlightCs": { _attr: { "w:val": "yellow" } } }], - }, - { - highlight: HighlightColor.YELLOW, - highlightComplexScript: true, - expected: [{ "w:highlight": { _attr: { "w:val": "yellow" } } }, { "w:highlightCs": { _attr: { "w:val": "yellow" } } }], - }, - { - highlight: HighlightColor.YELLOW, - highlightComplexScript: false, - expected: [{ "w:highlight": { _attr: { "w:val": "yellow" } } }], - }, - { - highlight: HighlightColor.YELLOW, - highlightComplexScript: "550099", - expected: [{ "w:highlight": { _attr: { "w:val": "yellow" } } }, { "w:highlightCs": { _attr: { "w:val": "550099" } } }], - }, - ]; - highlightTests.forEach(({ highlight, highlightComplexScript, expected }) => { - it(`#highlight ${highlight} cs ${highlightComplexScript}`, () => { - const abstractNumbering = new AbstractNumbering(1, [ - { - level: 0, - format: LevelFormat.LOWER_ROMAN, - text: "%0.", - style: { - run: { highlight, highlightComplexScript }, - }, + it("#highlight isn't written, since Office doesn't allow a level's number to be highlighted", () => { + const abstractNumbering = new AbstractNumbering(1, [ + { + level: 0, + format: LevelFormat.LOWER_ROMAN, + text: "%0.", + style: { + run: { highlight: HighlightColor.YELLOW, highlightComplexScript: true }, }, - ]); - const tree = new Formatter().format(abstractNumbering); - expect(tree).to.deep.equal({ - "w:abstractNum": [ - { - _attr: { - "w15:restartNumberingAfterBreak": 0, - "w:abstractNumId": 1, - }, - }, - { - "w:multiLevelType": { - _attr: { - "w:val": "hybridMultilevel", - }, - }, - }, - { - "w:lvl": [ - { - "w:start": { - _attr: { - "w:val": 1, - }, - }, - }, - { - "w:numFmt": { - _attr: { - "w:val": "lowerRoman", - }, - }, - }, - { - "w:lvlText": { - _attr: { - "w:val": "%0.", - }, - }, - }, - { - "w:lvlJc": { - _attr: { - "w:val": "start", - }, - }, - }, - { - "w:rPr": expected, - }, - { - _attr: { - "w15:tentative": 1, - "w:ilvl": 0, - }, - }, - ], - }, - ], - }); - }); + }, + ]); + const tree = new Formatter().format(abstractNumbering); + const level = tree["w:abstractNum"].find((child: object) => "w:lvl" in child)["w:lvl"]; + expect(level.map((child: object) => Object.keys(child)[0])).to.deep.equal([ + "w:start", + "w:numFmt", + "w:lvlText", + "w:lvlJc", + "_attr", + ]); }); const shadingTests = [ @@ -2214,7 +2141,7 @@ describe("AbstractNumbering", () => { { "w:lvlJc": { _attr: { - "w:val": "start", + "w:val": "left", }, }, }, @@ -2223,7 +2150,7 @@ describe("AbstractNumbering", () => { }, { _attr: { - "w15:tentative": 1, + "w:tentative": 1, "w:ilvl": 0, }, }, @@ -2290,7 +2217,7 @@ describe("AbstractNumbering", () => { { "w:lvlJc": { _attr: { - "w:val": "start", + "w:val": "left", }, }, }, @@ -2299,7 +2226,7 @@ describe("AbstractNumbering", () => { }, { _attr: { - "w15:tentative": 1, + "w:tentative": 1, "w:ilvl": 0, }, }, @@ -2366,7 +2293,7 @@ describe("AbstractNumbering", () => { { "w:lvlJc": { _attr: { - "w:val": "start", + "w:val": "left", }, }, }, @@ -2375,7 +2302,7 @@ describe("AbstractNumbering", () => { }, { _attr: { - "w15:tentative": 1, + "w:tentative": 1, "w:ilvl": 0, }, }, @@ -2443,7 +2370,7 @@ describe("AbstractNumbering", () => { { "w:lvlJc": { _attr: { - "w:val": "start", + "w:val": "left", }, }, }, @@ -2452,7 +2379,7 @@ describe("AbstractNumbering", () => { }, { _attr: { - "w15:tentative": 1, + "w:tentative": 1, "w:ilvl": 0, }, }, @@ -2519,7 +2446,7 @@ describe("AbstractNumbering", () => { { "w:lvlJc": { _attr: { - "w:val": "start", + "w:val": "left", }, }, }, @@ -2528,7 +2455,7 @@ describe("AbstractNumbering", () => { }, { _attr: { - "w15:tentative": 1, + "w:tentative": 1, "w:ilvl": 0, }, }, @@ -2595,7 +2522,7 @@ describe("AbstractNumbering", () => { { "w:lvlJc": { _attr: { - "w:val": "start", + "w:val": "left", }, }, }, @@ -2604,7 +2531,7 @@ describe("AbstractNumbering", () => { }, { _attr: { - "w15:tentative": 1, + "w:tentative": 1, "w:ilvl": 0, }, }, @@ -2670,7 +2597,7 @@ describe("AbstractNumbering", () => { { "w:lvlJc": { _attr: { - "w:val": "start", + "w:val": "left", }, }, }, @@ -2679,7 +2606,7 @@ describe("AbstractNumbering", () => { }, { _attr: { - "w15:tentative": 1, + "w:tentative": 1, "w:ilvl": 0, }, }, diff --git a/src/file/numbering/level.spec.ts b/src/file/numbering/level.spec.ts index 645de1f246..de0cfaf5fd 100644 --- a/src/file/numbering/level.spec.ts +++ b/src/file/numbering/level.spec.ts @@ -23,6 +23,72 @@ describe("Level", () => { }); }); + it("writes its children in the schema's order", () => { + const tree = new Formatter().format( + new Level({ + level: 0, + format: LevelFormat.DECIMAL, + text: "%1.", + suffix: LevelSuffix.SPACE, + isLegalNumberingStyle: true, + style: { style: "ListHeading", paragraph: { indent: { left: 720 } }, run: { bold: true } }, + }), + ); + + expect(tree["w:lvl"].map((child: object) => Object.keys(child)[0])).to.deep.equal([ + "w:start", + "w:numFmt", + "w:pStyle", + "w:isLgl", + "w:suff", + "w:lvlText", + "w:lvlJc", + "w:pPr", + "w:rPr", + "_attr", + ]); + }); + + it("leaves highlight, math and revision out of its run properties, since Office doesn't allow them for a number", () => { + const tree = new Formatter().format( + new Level({ + level: 0, + style: { + run: { + bold: true, + highlight: "yellow", + math: true, + revision: { id: 1, author: "Firstname Lastname", date: "123", bold: false }, + }, + }, + }), + ); + + expect(tree["w:lvl"].find((child: object) => "w:rPr" in child)).to.deep.equal({ "w:rPr": [{ "w:b": {} }, { "w:bCs": {} }] }); + }); + + describe("alignment", () => { + const levelAlignment = (alignment: (typeof AlignmentType)[keyof typeof AlignmentType]): unknown => + new Formatter().format(new Level({ level: 0, alignment }))["w:lvl"].find((child: object) => "w:lvlJc" in child); + + it("writes left, center and right as they are, since they're the only values Office allows for a level", () => { + expect(levelAlignment(AlignmentType.LEFT)).to.deep.equal({ "w:lvlJc": { _attr: { "w:val": "left" } } }); + expect(levelAlignment(AlignmentType.CENTER)).to.deep.equal({ "w:lvlJc": { _attr: { "w:val": "center" } } }); + expect(levelAlignment(AlignmentType.RIGHT)).to.deep.equal({ "w:lvlJc": { _attr: { "w:val": "right" } } }); + }); + + it("writes start as left and end as right", () => { + expect(levelAlignment(AlignmentType.START)).to.deep.equal({ "w:lvlJc": { _attr: { "w:val": "left" } } }); + expect(levelAlignment(AlignmentType.END)).to.deep.equal({ "w:lvlJc": { _attr: { "w:val": "right" } } }); + }); + + it("writes the justified alignments as left", () => { + expect(levelAlignment(AlignmentType.JUSTIFIED)).to.deep.equal({ "w:lvlJc": { _attr: { "w:val": "left" } } }); + expect(levelAlignment(AlignmentType.DISTRIBUTE)).to.deep.equal({ "w:lvlJc": { _attr: { "w:val": "left" } } }); + expect(levelAlignment(AlignmentType.THAI_DISTRIBUTE)).to.deep.equal({ "w:lvlJc": { _attr: { "w:val": "left" } } }); + }); + }); + describe("isLegalNumberingStyle", () => { it("should work", () => { const concreteNumbering = new Level({ @@ -45,13 +111,13 @@ describe("Level", () => { { "w:lvlJc": { _attr: { - "w:val": "start", + "w:val": "left", }, }, }, { _attr: { - "w15:tentative": 1, + "w:tentative": 1, "w:ilvl": 9, }, }, diff --git a/src/file/numbering/level.ts b/src/file/numbering/level.ts index 58a245f714..e78552c271 100644 --- a/src/file/numbering/level.ts +++ b/src/file/numbering/level.ts @@ -180,7 +180,7 @@ class LevelAttributes extends XmlAttributeComponent<{ }> { protected readonly xmlKeys = { ilvl: "w:ilvl", - tentative: "w15:tentative", + tentative: "w:tentative", }; } @@ -217,6 +217,20 @@ class LevelText extends XmlComponent { } } +// Office's schema only allows left, center and right for a level's number, where a paragraph's w:jc takes any +// AlignmentType. So START and the justified alignments are written as left, and END as right +const levelAlignment = (value: (typeof AlignmentType)[keyof typeof AlignmentType]): "left" | "center" | "right" => { + switch (value) { + case AlignmentType.CENTER: + return "center"; + case AlignmentType.END: + case AlignmentType.RIGHT: + return "right"; + default: + return "left"; + } +}; + /** * Alignment specification for level numbering. */ @@ -225,7 +239,7 @@ class LevelJc extends XmlComponent { super("w:lvlJc"); this.root.push( new Attributes({ - val: value, + val: levelAlignment(value), }), ); } @@ -278,7 +292,10 @@ export type ILevelsOptions = { readonly format?: (typeof LevelFormat)[keyof typeof LevelFormat]; /** Level text template with placeholders like %1, %2. */ readonly text?: string; - /** Text alignment for the numbering. */ + /** + * Alignment of the level's number: left, center or right. START and the justified alignments are written as left, + * and END as right, since Office doesn't allow the others here. Defaults to START. + */ readonly alignment?: (typeof AlignmentType)[keyof typeof AlignmentType]; /** Starting number for this level. */ readonly start?: number; @@ -288,7 +305,10 @@ export type ILevelsOptions = { readonly isLegalNumberingStyle?: boolean; /** Run and paragraph style properties. */ readonly style?: { - /** Run style properties for the numbering text. */ + /** + * Run style properties for the numbering text. Its highlight, math and revision aren't written, since Office + * doesn't allow them for a level's number. + */ readonly run?: IRunStylePropertiesOptions; /** Paragraph style properties for the level. */ readonly paragraph?: ILevelParagraphStylePropertiesOptions; @@ -384,33 +404,35 @@ export class LevelBase extends XmlComponent { }: ILevelsOptions) { super("w:lvl"); + // In CT_Lvl's order this.root.push(new NumberValueElement("w:start", decimalNumber(start))); if (format) { this.root.push(new NumberFormat(format)); } - if (suffix) { - this.root.push(new Suffix(suffix)); + if (style?.style) { + this.root.push(createParagraphStyle(style.style)); } if (isLegalNumberingStyle) { this.root.push(new IsLegalNumberingStyle()); } + if (suffix) { + this.root.push(new Suffix(suffix)); + } + if (text) { this.root.push(new LevelText(text)); } this.root.push(new LevelJc(alignment)); - if (style?.style) { - this.root.push(createParagraphStyle(style.style)); - } - // A level's paragraph properties are a definition, so no implicit `ListParagraph` reference belongs here. this.paragraphProperties = new ParagraphProperties(style && style.paragraph, { implicitListParagraphStyle: false }); - this.runProperties = new RunProperties(style && style.run); + // Office's schema has no w:highlight, w:oMath or w:rPrChange in a level's run properties + this.runProperties = new RunProperties(style?.run && { ...style.run, highlight: undefined, math: undefined, revision: undefined }); this.root.push(this.paragraphProperties); this.root.push(this.runProperties); diff --git a/src/file/numbering/numbering.spec.ts b/src/file/numbering/numbering.spec.ts index 4efbc75b01..267c5961ff 100644 --- a/src/file/numbering/numbering.spec.ts +++ b/src/file/numbering/numbering.spec.ts @@ -27,7 +27,7 @@ describe("Numbering", () => { expect(Object.keys(el)).to.have.lengthOf(1); expect(Object.keys(el["w:lvl"])).to.deep.equal(["_attr", "w:start", "w:lvlJc", "w:numFmt", "w:pPr", "w:rPr"]); expect(el["w:lvl"]).to.have.deep.members([ - { _attr: { "w:ilvl": ix, "w15:tentative": 1 } }, + { _attr: { "w:ilvl": ix, "w:tentative": 1 } }, { "w:start": [{ _attr: { "w:val": 1 } }] }, { "w:lvlJc": [{ _attr: { "w:val": "left" } }] }, { "w:numFmt": [{ _attr: { "w:val": "bullet" } }] }, diff --git a/src/file/paragraph/formatting/border.spec.ts b/src/file/paragraph/formatting/border.spec.ts index 4011310421..6c7e5c758c 100644 --- a/src/file/paragraph/formatting/border.spec.ts +++ b/src/file/paragraph/formatting/border.spec.ts @@ -7,7 +7,7 @@ import { Border, ThematicBreak } from "./border"; describe("Border", () => { describe("#constructor", () => { - it("should create", () => { + it("should write the borders in the schema's order: top, left, bottom, right, between", () => { const border = new Border({ top: { color: "FF0000", @@ -55,16 +55,6 @@ describe("Border", () => { }, }, }, - { - "w:bottom": { - _attr: { - "w:color": "FF0000", - "w:space": 3, - "w:sz": 4, - "w:val": "wave", - }, - }, - }, { "w:left": { _attr: { @@ -75,6 +65,16 @@ describe("Border", () => { }, }, }, + { + "w:bottom": { + _attr: { + "w:color": "FF0000", + "w:space": 3, + "w:sz": 4, + "w:val": "wave", + }, + }, + }, { "w:right": { _attr: { diff --git a/src/file/paragraph/formatting/border.ts b/src/file/paragraph/formatting/border.ts index a5a314341b..d0110a46e9 100644 --- a/src/file/paragraph/formatting/border.ts +++ b/src/file/paragraph/formatting/border.ts @@ -70,18 +70,19 @@ export class Border extends IgnoreIfEmptyXmlComponent { public constructor(options: IBordersOptions) { super("w:pBdr"); + // In the schema's order: top, left, bottom, right, between if (options.top) { this.root.push(createBorderElement("w:top", options.top)); } - if (options.bottom) { - this.root.push(createBorderElement("w:bottom", options.bottom)); - } - if (options.left) { this.root.push(createBorderElement("w:left", options.left)); } + if (options.bottom) { + this.root.push(createBorderElement("w:bottom", options.bottom)); + } + if (options.right) { this.root.push(createBorderElement("w:right", options.right)); } diff --git a/src/file/paragraph/formatting/tab-stop.spec.ts b/src/file/paragraph/formatting/tab-stop.spec.ts index 1ca808180d..d67ba2bfc0 100644 --- a/src/file/paragraph/formatting/tab-stop.spec.ts +++ b/src/file/paragraph/formatting/tab-stop.spec.ts @@ -2,7 +2,7 @@ import { describe, expect, it } from "vitest"; import { Formatter } from "@export/formatter"; -import { LeaderType, TabStopType, createTabStop } from "./tab-stop"; +import { LeaderType, TabStopPosition, TabStopType, createTabStop } from "./tab-stop"; describe("LeftTabStop", () => { describe("#createTabStop()", () => { @@ -46,3 +46,19 @@ describe("RightTabStop", () => { }); }); }); + +describe("TabStop position", () => { + it("should write a position worked out as a fraction as whole twips, as ST_SignedTwipsMeasure requires", () => { + const tabStop = createTabStop([ + { type: TabStopType.RIGHT, position: TabStopPosition.MAX * 0.75 }, + { type: TabStopType.LEFT, position: -100.5 }, + ]); + const tree = new Formatter().format(tabStop); + expect(tree).to.deep.equal({ + "w:tabs": [ + { "w:tab": { _attr: { "w:val": "right", "w:pos": 6769 } } }, + { "w:tab": { _attr: { "w:val": "left", "w:pos": -101 } } }, + ], + }); + }); +}); diff --git a/src/file/paragraph/formatting/tab-stop.ts b/src/file/paragraph/formatting/tab-stop.ts index d93abcef49..e3508a5487 100644 --- a/src/file/paragraph/formatting/tab-stop.ts +++ b/src/file/paragraph/formatting/tab-stop.ts @@ -8,12 +8,13 @@ * @module */ import { BuilderElement, type XmlComponent } from "@file/xml-components"; +import { signedTwipsMeasureValue } from "@util/values"; /** * Definition for a single tab stop. * * @property type - The type of tab stop alignment - * @property position - The position of the tab stop in twips + * @property position - The position of the tab stop in twips. A fraction is rounded down to a whole number of twips * @property leader - Optional leader character to fill space before the tab * * @see {@link TabStop} @@ -21,7 +22,7 @@ import { BuilderElement, type XmlComponent } from "@file/xml-components"; export type TabStopDefinition = { /** The type of tab stop alignment */ readonly type: (typeof TabStopType)[keyof typeof TabStopType]; - /** The position of the tab stop in twips */ + /** The position of the tab stop in twips. A fraction is rounded down to a whole number of twips */ readonly position: number | (typeof TabStopPosition)[keyof typeof TabStopPosition]; /** Optional leader character to fill space before the tab */ readonly leader?: (typeof LeaderType)[keyof typeof LeaderType]; @@ -108,7 +109,8 @@ export const createTabStopItem = ({ type, position, leader }: TabStopDefinition) name: "w:tab", attributes: { val: { key: "w:val", value: type }, - pos: { key: "w:pos", value: position }, + // A whole number of twips, so a position worked out as a fraction, such as a quarter of the page, is still valid + pos: { key: "w:pos", value: signedTwipsMeasureValue(position) }, leader: { key: "w:leader", value: leader }, }, }); diff --git a/src/file/paragraph/math/n-ary/math-integral.spec.ts b/src/file/paragraph/math/n-ary/math-integral.spec.ts index 243be8150d..b05603619c 100644 --- a/src/file/paragraph/math/n-ary/math-integral.spec.ts +++ b/src/file/paragraph/math/n-ary/math-integral.spec.ts @@ -65,7 +65,7 @@ describe("MathIntegral", () => { }); }); - it("should create a MathIntegral with correct root key without sub-script and super-scripts", () => { + it("should hide both limits, and still write them empty, without sub-script and super-scripts", () => { const mathIntegral = new MathIntegral({ children: [new MathRun("1")], }); @@ -82,13 +82,6 @@ describe("MathIntegral", () => { }, }, }, - { - "m:supHide": { - _attr: { - "m:val": 1, - }, - }, - }, { "m:subHide": { _attr: { @@ -96,8 +89,21 @@ describe("MathIntegral", () => { }, }, }, + { + "m:supHide": { + _attr: { + "m:val": 1, + }, + }, + }, ], }, + { + "m:sub": {}, + }, + { + "m:sup": {}, + }, { "m:e": [ { diff --git a/src/file/paragraph/math/n-ary/math-integral.ts b/src/file/paragraph/math/n-ary/math-integral.ts index 1cd79ceeac..91b7ca6b66 100644 --- a/src/file/paragraph/math/n-ary/math-integral.ts +++ b/src/file/paragraph/math/n-ary/math-integral.ts @@ -73,13 +73,9 @@ export class MathIntegral extends XmlComponent { }), ); - if (!!options.subScript) { - this.root.push(createMathSubScriptElement({ children: options.subScript })); - } - - if (!!options.superScript) { - this.root.push(createMathSuperScriptElement({ children: options.superScript })); - } + // The schema needs both limits, so a hidden one is written empty + this.root.push(createMathSubScriptElement({ children: options.subScript ?? [] })); + this.root.push(createMathSuperScriptElement({ children: options.superScript ?? [] })); this.root.push(createMathBase({ children: options.children })); } diff --git a/src/file/paragraph/math/n-ary/math-n-ary-properties.spec.ts b/src/file/paragraph/math/n-ary/math-n-ary-properties.spec.ts index b03a6aad0b..135141f7a4 100644 --- a/src/file/paragraph/math/n-ary/math-n-ary-properties.spec.ts +++ b/src/file/paragraph/math/n-ary/math-n-ary-properties.spec.ts @@ -104,7 +104,7 @@ describe("createMathNAryProperties", () => { }); }); - it("should add both super-script and sub-script hide attributes", () => { + it("should hide the sub-script before the super-script, as the schema orders them", () => { const mathNAryProperties = createMathNAryProperties({ accent: "∑", hasSuperScript: false, @@ -129,14 +129,14 @@ describe("createMathNAryProperties", () => { }, }, { - "m:supHide": { + "m:subHide": { _attr: { "m:val": 1, }, }, }, { - "m:subHide": { + "m:supHide": { _attr: { "m:val": 1, }, diff --git a/src/file/paragraph/math/n-ary/math-n-ary-properties.ts b/src/file/paragraph/math/n-ary/math-n-ary-properties.ts index 0efa7d794d..f564406389 100644 --- a/src/file/paragraph/math/n-ary/math-n-ary-properties.ts +++ b/src/file/paragraph/math/n-ary/math-n-ary-properties.ts @@ -61,7 +61,7 @@ export const createMathNAryProperties = ({ children: [ ...(!!accent ? [createMathAccentCharacter({ accent })] : []), createMathLimitLocation({ value: limitLocationVal }), - ...(!hasSuperScript ? [createMathSuperScriptHide()] : []), ...(!hasSubScript ? [createMathSubScriptHide()] : []), + ...(!hasSuperScript ? [createMathSuperScriptHide()] : []), ], }); diff --git a/src/file/paragraph/math/n-ary/math-sum.spec.ts b/src/file/paragraph/math/n-ary/math-sum.spec.ts index eba2aa0448..32a2a1173d 100644 --- a/src/file/paragraph/math/n-ary/math-sum.spec.ts +++ b/src/file/paragraph/math/n-ary/math-sum.spec.ts @@ -72,7 +72,7 @@ describe("MathSum", () => { }); }); - it("should add a hide when there is no subScript or superScript", () => { + it("should hide both limits, and still write them empty, when there is no subScript or superScript", () => { const mathSum = new MathSum({ children: [new MathRun("1")], }); @@ -96,13 +96,6 @@ describe("MathSum", () => { }, }, }, - { - "m:supHide": { - _attr: { - "m:val": 1, - }, - }, - }, { "m:subHide": { _attr: { @@ -110,8 +103,21 @@ describe("MathSum", () => { }, }, }, + { + "m:supHide": { + _attr: { + "m:val": 1, + }, + }, + }, ], }, + { + "m:sub": {}, + }, + { + "m:sup": {}, + }, { "m:e": [ { @@ -126,5 +132,28 @@ describe("MathSum", () => { ], }); }); + + it("should write an empty, hidden superscript when there is only a subScript", () => { + const mathSum = new MathSum({ + children: [new MathRun("1")], + subScript: [new MathRun("i")], + }); + + const tree = new Formatter().format(mathSum); + expect(tree).to.deep.equal({ + "m:nary": [ + { + "m:naryPr": [ + { "m:chr": { _attr: { "m:val": "∑" } } }, + { "m:limLoc": { _attr: { "m:val": "undOvr" } } }, + { "m:supHide": { _attr: { "m:val": 1 } } }, + ], + }, + { "m:sub": [{ "m:r": [{ "m:t": ["i"] }] }] }, + { "m:sup": {} }, + { "m:e": [{ "m:r": [{ "m:t": ["1"] }] }] }, + ], + }); + }); }); }); diff --git a/src/file/paragraph/math/n-ary/math-sum.ts b/src/file/paragraph/math/n-ary/math-sum.ts index b97e10ac14..a275d76ec9 100644 --- a/src/file/paragraph/math/n-ary/math-sum.ts +++ b/src/file/paragraph/math/n-ary/math-sum.ts @@ -72,13 +72,9 @@ export class MathSum extends XmlComponent { }), ); - if (!!options.subScript) { - this.root.push(createMathSubScriptElement({ children: options.subScript })); - } - - if (!!options.superScript) { - this.root.push(createMathSuperScriptElement({ children: options.superScript })); - } + // The schema needs both limits, so a hidden one is written empty + this.root.push(createMathSubScriptElement({ children: options.subScript ?? [] })); + this.root.push(createMathSuperScriptElement({ children: options.superScript ?? [] })); this.root.push(createMathBase({ children: options.children })); } diff --git a/src/file/paragraph/math/script/pre-sub-super-script/math-pre-sub-super-script-function.spec.ts b/src/file/paragraph/math/script/pre-sub-super-script/math-pre-sub-super-script-function.spec.ts index 2ced225ca4..9bf36f768b 100644 --- a/src/file/paragraph/math/script/pre-sub-super-script/math-pre-sub-super-script-function.spec.ts +++ b/src/file/paragraph/math/script/pre-sub-super-script/math-pre-sub-super-script-function.spec.ts @@ -7,7 +7,7 @@ import { MathRun } from "../../math-run"; describe("MathPreSubScript", () => { describe("#constructor()", () => { - it("should create a MathPreSubScript with correct root key", () => { + it("should write the pre-scripts before the base, as the schema orders them", () => { const mathPreSubScript = new MathPreSubSuperScript({ children: [new MathRun("e")], subScript: [new MathRun("2")], @@ -20,17 +20,6 @@ describe("MathPreSubScript", () => { { "m:sPrePr": {}, }, - { - "m:e": [ - { - "m:r": [ - { - "m:t": ["e"], - }, - ], - }, - ], - }, { "m:sub": [ { @@ -53,6 +42,17 @@ describe("MathPreSubScript", () => { }, ], }, + { + "m:e": [ + { + "m:r": [ + { + "m:t": ["e"], + }, + ], + }, + ], + }, ], }); }); diff --git a/src/file/paragraph/math/script/pre-sub-super-script/math-pre-sub-super-script-function.ts b/src/file/paragraph/math/script/pre-sub-super-script/math-pre-sub-super-script-function.ts index aa4d7793f7..0c94126567 100644 --- a/src/file/paragraph/math/script/pre-sub-super-script/math-pre-sub-super-script-function.ts +++ b/src/file/paragraph/math/script/pre-sub-super-script/math-pre-sub-super-script-function.ts @@ -66,9 +66,9 @@ export class MathPreSubSuperScript extends BuilderElement { name: "m:sPre", children: [ createMathPreSubSuperScriptProperties(), - createMathBase({ children: children }), createMathSubScriptElement({ children: subScript }), createMathSuperScriptElement({ children: superScript }), + createMathBase({ children: children }), ], }); } diff --git a/src/file/paragraph/run/comment-run.spec.ts b/src/file/paragraph/run/comment-run.spec.ts index 5ff1546132..13b95f9513 100644 --- a/src/file/paragraph/run/comment-run.spec.ts +++ b/src/file/paragraph/run/comment-run.spec.ts @@ -200,6 +200,7 @@ describe("Comments", () => { "xmlns:wpi": "http://schemas.microsoft.com/office/word/2010/wordprocessingInk", "xmlns:wne": "http://schemas.microsoft.com/office/word/2006/wordml", "xmlns:wps": "http://schemas.microsoft.com/office/word/2010/wordprocessingShape", + "mc:Ignorable": "w14 w15 wp14", }, }, { diff --git a/src/file/paragraph/run/comment-run.ts b/src/file/paragraph/run/comment-run.ts index 1870b3f498..8e8c32837e 100644 --- a/src/file/paragraph/run/comment-run.ts +++ b/src/file/paragraph/run/comment-run.ts @@ -105,6 +105,7 @@ class RootCommentsAttributes extends XmlAttributeComponent<{ readonly "xmlns:wpi"?: string; readonly "xmlns:wne"?: string; readonly "xmlns:wps"?: string; + readonly "mc:Ignorable"?: string; }> { protected readonly xmlKeys = { "xmlns:cx": "xmlns:cx", @@ -138,6 +139,7 @@ class RootCommentsAttributes extends XmlAttributeComponent<{ "xmlns:wpi": "xmlns:wpi", "xmlns:wne": "xmlns:wne", "xmlns:wps": "xmlns:wps", + "mc:Ignorable": "mc:Ignorable", }; } @@ -425,6 +427,8 @@ export class Comments extends XmlComponent { "xmlns:wpi": "http://schemas.microsoft.com/office/word/2010/wordprocessingInk", "xmlns:wne": "http://schemas.microsoft.com/office/word/2006/wordml", "xmlns:wps": "http://schemas.microsoft.com/office/word/2010/wordprocessingShape", + // The comments' paragraphs have w14:paraId and w14:textId, which applications that don't know them skip + "mc:Ignorable": "w14 w15 wp14", }), ); diff --git a/src/file/paragraph/run/formatting.ts b/src/file/paragraph/run/formatting.ts index 2d7a3fca9d..83aba2ce09 100644 --- a/src/file/paragraph/run/formatting.ts +++ b/src/file/paragraph/run/formatting.ts @@ -118,22 +118,3 @@ export class Highlight extends XmlComponent { ); } } - -/** - * Represents text highlighting for complex scripts. - * - * Used for highlighting text in complex script languages - * (e.g., Arabic, Hebrew, Thai). - * - * @internal - */ -export class HighlightComplexScript extends XmlComponent { - public constructor(color: string) { - super("w:highlightCs"); - this.root.push( - new Attributes({ - val: color, - }), - ); - } -} diff --git a/src/file/paragraph/run/properties.ts b/src/file/paragraph/run/properties.ts index 2002aebe8a..2754c1a08e 100644 --- a/src/file/paragraph/run/properties.ts +++ b/src/file/paragraph/run/properties.ts @@ -26,7 +26,7 @@ import { import type { PositiveUniversalMeasure, UniversalMeasure } from "@util/values"; import { type EmphasisMarkType, createEmphasisMark } from "./emphasis-mark"; -import { CharacterSpacing, Color, Highlight, HighlightComplexScript } from "./formatting"; +import { CharacterSpacing, Color, Highlight } from "./formatting"; import { type ILanguageOptions, createLanguageComponent } from "./language"; import { type IFontAttributesProperties, type IThemeFontReference, createRunFonts } from "./run-fonts"; import { createSubScript, createSuperScript } from "./script"; @@ -189,6 +189,10 @@ export type IRunStylePropertiesOptions = { */ readonly font?: string | IFontOptions | IFontAttributesProperties | IThemeFontReference; readonly highlight?: (typeof HighlightColor)[keyof typeof HighlightColor]; + /** + * @deprecated Has no effect. WordprocessingML has no highlight of its own for complex script text: `highlight` + * highlights all the run's text. docx used to write it as `w:highlightCs`, which is in no schema. + */ readonly highlightComplexScript?: boolean | string; readonly characterSpacing?: number; readonly shading?: IShadingAttributesProperties; @@ -355,13 +359,6 @@ export class RunProperties extends IgnoreIfEmptyXmlComponent { if (options.highlight) { this.push(new Highlight(options.highlight)); } - const highlightCs = - options.highlightComplexScript === undefined || options.highlightComplexScript === true - ? options.highlight - : options.highlightComplexScript; - if (highlightCs) { - this.push(new HighlightComplexScript(highlightCs)); - } if (options.underline) { this.push(createUnderline(options.underline.type, options.underline.color)); diff --git a/src/file/paragraph/run/run.spec.ts b/src/file/paragraph/run/run.spec.ts index 5f4ed09e80..13088453ea 100644 --- a/src/file/paragraph/run/run.spec.ts +++ b/src/file/paragraph/run/run.spec.ts @@ -2,6 +2,8 @@ import { describe, expect, it } from "vitest"; import { Formatter } from "@export/formatter"; import { BorderStyle } from "@file/border"; +import { FootnoteReferenceRun } from "@file/footnotes/footnote/run/reference-run"; +import { Paragraph } from "@file/paragraph"; import { ShadingType } from "@file/shading"; import { EmphasisMarkType } from "./emphasis-mark"; @@ -214,7 +216,7 @@ describe("Run", () => { }); describe("#highlight()", () => { - it("it should add highlight to the properties", () => { + it("should add the highlight to the properties, without w:highlightCs, which is in no schema", () => { const run = new Run({ highlight: HighlightColor.YELLOW, }); @@ -222,16 +224,7 @@ describe("Run", () => { expect(tree).to.deep.equal({ "w:r": [ { - "w:rPr": [ - { "w:highlight": { _attr: { "w:val": "yellow" } } }, - { - "w:highlightCs": { - _attr: { - "w:val": "yellow", - }, - }, - }, - ], + "w:rPr": [{ "w:highlight": { _attr: { "w:val": "yellow" } } }], }, ], }); @@ -767,4 +760,51 @@ describe("Run", () => { }); }); }); + describe("#children with a run", () => { + const text = (value: string) => ({ "w:t": [{ _attr: { "xml:space": "preserve" } }, value] }); + const bold = { "w:rPr": [{ "w:b": {} }, { "w:bCs": {} }] }; + const reference = (id: number) => ({ + "w:r": [ + { "w:rPr": [{ "w:rStyle": { _attr: { "w:val": "FootnoteReference" } } }] }, + { "w:footnoteReference": { _attr: { "w:id": id } } }, + ], + }); + + it("should end the run before a footnote reference, and write the children after it in a run with the same properties", () => { + const paragraph = new Paragraph({ + children: [new Run({ bold: true, children: ["Before", new FootnoteReferenceRun(1), "After"] })], + }); + + const tree = new Formatter().format(paragraph); + expect(tree).to.deep.equal({ + "w:p": [{ "w:r": [bold, text("Before")] }, reference(1), { "w:r": [bold, text("After")] }], + }); + }); + + it("should split the run at each run in its children", () => { + const paragraph = new Paragraph({ + children: [new Run({ children: ["A", new FootnoteReferenceRun(1), "B", new FootnoteReferenceRun(2), "C"] })], + }); + + const tree = new Formatter().format(paragraph); + expect(tree).to.deep.equal({ + "w:p": [{ "w:r": [text("A")] }, reference(1), { "w:r": [text("B")] }, reference(2), { "w:r": [text("C")] }], + }); + }); + + it("should not write an empty run after a run at the end of the children, and only break before the first", () => { + const paragraph = new Paragraph({ + children: [new Run({ break: 1, children: ["A", new FootnoteReferenceRun(1)] })], + }); + + const tree = new Formatter().format(paragraph); + expect(tree).to.deep.equal({ + "w:p": [{ "w:r": [{ "w:br": {} }, text("A")] }, reference(1)], + }); + }); + + it("should be written as itself when it has no run in its children", () => { + expect(new Run({ children: ["A"] }).writtenAs).to.equal(undefined); + }); + }); }); diff --git a/src/file/paragraph/run/run.ts b/src/file/paragraph/run/run.ts index 3f928f901f..afbddd7a73 100644 --- a/src/file/paragraph/run/run.ts +++ b/src/file/paragraph/run/run.ts @@ -10,7 +10,7 @@ */ import type { FootnoteReferenceRun } from "@file/footnotes/footnote/run/reference-run"; import type { FieldInstruction } from "@file/table-of-contents/field-instruction"; -import { XmlComponent } from "@file/xml-components"; +import { type BaseXmlComponent, XmlComponent } from "@file/xml-components"; import { createBreak } from "./break"; import type { @@ -168,6 +168,8 @@ export const PageNumber = { */ export class Run extends XmlComponent { protected readonly properties: RunProperties; + // A run given in the children, such as a FootnoteReferenceRun, and the run of the children after it + private readonly following: readonly Run[] = []; public constructor(options: IRunOptions) { super("w:r"); @@ -181,7 +183,15 @@ export class Run extends XmlComponent { } if (options.children) { - for (const child of options.children) { + for (const [index, child] of options.children.entries()) { + if (child instanceof Run) { + // A run can't be inside another, so this run ends before it, and the children after it go in a run + // with this run's properties + const rest = options.children.slice(index + 1); + this.following = [child, ...(rest.length > 0 ? [new Run({ ...options, break: undefined, children: rest })] : [])]; + break; + } + if (typeof child === "string") { switch (child) { case PageNumber.CURRENT: @@ -221,4 +231,9 @@ export class Run extends XmlComponent { this.root.push(new Text(options.text)); } } + + public get writtenAs(): readonly BaseXmlComponent[] | undefined { + // This run, then the ones after it, each written as it would be on its own + return this.following.length > 0 ? [this, ...this.following.flatMap((run) => run.writtenAs ?? run)] : undefined; + } } diff --git a/src/file/paragraph/run/symbol-run.spec.ts b/src/file/paragraph/run/symbol-run.spec.ts index db3971686a..44c511c2de 100644 --- a/src/file/paragraph/run/symbol-run.spec.ts +++ b/src/file/paragraph/run/symbol-run.spec.ts @@ -65,7 +65,6 @@ describe("SymbolRun", () => { { "w:sz": { _attr: { "w:val": 40 } } }, { "w:szCs": { _attr: { "w:val": 40 } } }, { "w:highlight": { _attr: { "w:val": "yellow" } } }, - { "w:highlightCs": { _attr: { "w:val": "yellow" } } }, { "w:u": { _attr: { "w:val": "double", "w:color": "ff0000" } } }, { "w:em": { _attr: { "w:val": "dot" } } }, ], diff --git a/src/file/paragraph/run/text-run.spec.ts b/src/file/paragraph/run/text-run.spec.ts index 4108c174c6..e0fd5a7e36 100644 --- a/src/file/paragraph/run/text-run.spec.ts +++ b/src/file/paragraph/run/text-run.spec.ts @@ -2,6 +2,7 @@ import { describe, expect, it } from "vitest"; import { Formatter } from "@export/formatter"; import { FootnoteReferenceRun } from "@file/footnotes/footnote/run/reference-run"; +import { Paragraph } from "@file/paragraph"; import { TextRun } from "./text-run"; @@ -27,15 +28,15 @@ describe("TextRun", () => { }); describe("#referenceFootnote()", () => { - it("should add a valid footnote reference", () => { + it("should write a footnote reference in the children as a run after the text's run, not inside it", () => { run = new TextRun({ children: ["test", new FootnoteReferenceRun(1)], }); - const tree = new Formatter().format(run); + const tree = new Formatter().format(new Paragraph({ children: [run] })); expect(tree).to.deep.equal({ - "w:r": [ - { "w:t": [{ _attr: { "xml:space": "preserve" } }, "test"] }, + "w:p": [ + { "w:r": [{ "w:t": [{ _attr: { "xml:space": "preserve" } }, "test"] }] }, { "w:r": [ { "w:rPr": [{ "w:rStyle": { _attr: { "w:val": "FootnoteReference" } } }] }, diff --git a/src/file/settings/compatibility.spec.ts b/src/file/settings/compatibility.spec.ts index 129e0d1266..118eeb87c2 100644 --- a/src/file/settings/compatibility.spec.ts +++ b/src/file/settings/compatibility.spec.ts @@ -35,6 +35,31 @@ describe("Compatibility", () => { ], }); }); + + it("should write the compatibility mode after the other compatibility options, as the schema requires", () => { + const compatibility = new Compatibility({ + version: 15, + useSingleBorderforContiguousCells: true, + cachedColumnBalance: true, + }); + + const tree = new Formatter().format(compatibility); + expect(tree).to.deep.equal({ + "w:compat": [ + { "w:useSingleBorderforContiguousCells": {} }, + { "w:cachedColBalance": {} }, + { + "w:compatSetting": { + _attr: { + "w:name": "compatibilityMode", + "w:uri": "http://schemas.microsoft.com/office/word", + "w:val": 15, + }, + }, + }, + ], + }); + }); }); describe("#useSingleBorderforContiguousCells", () => { diff --git a/src/file/settings/compatibility.ts b/src/file/settings/compatibility.ts index 9c718034c1..f474585708 100644 --- a/src/file/settings/compatibility.ts +++ b/src/file/settings/compatibility.ts @@ -245,8 +245,8 @@ export type ICompatibilityOptions = { * * * - * * + * * * * ``` @@ -270,10 +270,6 @@ export class Compatibility extends XmlComponent { public constructor(options: ICompatibilityOptions) { super("w:compat"); - if (options.version) { - this.root.push(createCompatibilitySetting(options.version)); - } - if (options.useSingleBorderforContiguousCells) { this.root.push(new OnOffElement("w:useSingleBorderforContiguousCells", options.useSingleBorderforContiguousCells)); } @@ -533,5 +529,10 @@ export class Compatibility extends XmlComponent { if (options.cachedColumnBalance) { this.root.push(new OnOffElement("w:cachedColBalance", options.cachedColumnBalance)); } + + // CT_Compat puts the compatibility settings after every other element + if (options.version) { + this.root.push(createCompatibilitySetting(options.version)); + } } } diff --git a/src/file/settings/settings.spec.ts b/src/file/settings/settings.spec.ts index 65a18d0e98..3b868d42d6 100644 --- a/src/file/settings/settings.spec.ts +++ b/src/file/settings/settings.spec.ts @@ -197,6 +197,37 @@ describe("Settings", () => { }); }); + it("should write every setting in the schema's order, whatever order the options are given in", () => { + const settings = new Settings({ + updateFields: true, + evenAndOddHeaders: true, + hyphenation: { + doNotHyphenateCaps: true, + hyphenationZone: 200, + consecutiveHyphenLimit: 3, + autoHyphenation: true, + }, + defaultTabStop: 100, + trackRevisions: true, + }); + + const tree = new Formatter().format(settings); + const elements = (tree["w:settings"] as readonly Record[]).map((child) => Object.keys(child)[0]); + expect(elements).to.deep.equal([ + "_attr", + "w:displayBackgroundShape", + "w:trackRevisions", + "w:defaultTabStop", + "w:autoHyphenation", + "w:consecutiveHyphenLimit", + "w:hyphenationZone", + "w:doNotHyphenateCaps", + "w:evenAndOddHeaders", + "w:updateFields", + "w:compat", + ]); + }); + // TODO: Remove when deprecating compatibilityModeVersion it("should add compatibility setting with legacy version", () => { const settings = new Settings({ diff --git a/src/file/settings/settings.ts b/src/file/settings/settings.ts index 91025806a5..0c9e085635 100644 --- a/src/file/settings/settings.ts +++ b/src/file/settings/settings.ts @@ -216,12 +216,12 @@ export type IHyphenationOptions = { * * * - * * * * * * + * * * * @@ -278,21 +278,12 @@ export class Settings extends XmlComponent { // https://c-rex.net/projects/samples/ooxml/e1/Part4/OOXML_P4_DOCX_displayBackgroundSha_topic_ID0ET4SX.html this.root.push(new OnOffElement("w:displayBackgroundShape", true)); + // The elements are written in CT_Settings' order, which the schema requires // https://c-rex.net/projects/samples/ooxml/e1/Part4/OOXML_P4_DOCX_trackRevisions_topic_ID0EKXKY.html if (options.trackRevisions !== undefined) { this.root.push(new OnOffElement("w:trackRevisions", options.trackRevisions)); } - // http://officeopenxml.com/WPSectionFooterReference.php - // https://c-rex.net/projects/samples/ooxml/e1/Part4/OOXML_P4_DOCX_evenAndOddHeaders_topic_ID0ET1WU.html - if (options.evenAndOddHeaders !== undefined) { - this.root.push(new OnOffElement("w:evenAndOddHeaders", options.evenAndOddHeaders)); - } - - if (options.updateFields !== undefined) { - this.root.push(new OnOffElement("w:updateFields", options.updateFields)); - } - // https://c-rex.net/samples/ooxml/e1/Part4/OOXML_P4_DOCX_defaultTabStop_topic_ID0EIXSX.html if (options.defaultTabStop !== undefined) { this.root.push(new NumberValueElement("w:defaultTabStop", options.defaultTabStop)); @@ -303,21 +294,31 @@ export class Settings extends XmlComponent { this.root.push(new OnOffElement("w:autoHyphenation", options.hyphenation.autoHyphenation)); } - // https://c-rex.net/samples/ooxml/e1/Part4/OOXML_P4_DOCX_hyphenationZone_topic_ID0ERI3X.html - if (options.hyphenation?.hyphenationZone !== undefined) { - this.root.push(new NumberValueElement("w:hyphenationZone", options.hyphenation.hyphenationZone)); - } - // https://c-rex.net/samples/ooxml/e1/Part4/OOXML_P4_DOCX_consecutiveHyphenLim_topic_ID0EQ6RX.html if (options.hyphenation?.consecutiveHyphenLimit !== undefined) { this.root.push(new NumberValueElement("w:consecutiveHyphenLimit", options.hyphenation.consecutiveHyphenLimit)); } + // https://c-rex.net/samples/ooxml/e1/Part4/OOXML_P4_DOCX_hyphenationZone_topic_ID0ERI3X.html + if (options.hyphenation?.hyphenationZone !== undefined) { + this.root.push(new NumberValueElement("w:hyphenationZone", options.hyphenation.hyphenationZone)); + } + // https://c-rex.net/samples/ooxml/e1/Part4/OOXML_P4_DOCX_doNotHyphenateCaps_topic_ID0EW4XX.html if (options.hyphenation?.doNotHyphenateCaps !== undefined) { this.root.push(new OnOffElement("w:doNotHyphenateCaps", options.hyphenation.doNotHyphenateCaps)); } + // http://officeopenxml.com/WPSectionFooterReference.php + // https://c-rex.net/projects/samples/ooxml/e1/Part4/OOXML_P4_DOCX_evenAndOddHeaders_topic_ID0ET1WU.html + if (options.evenAndOddHeaders !== undefined) { + this.root.push(new OnOffElement("w:evenAndOddHeaders", options.evenAndOddHeaders)); + } + + if (options.updateFields !== undefined) { + this.root.push(new OnOffElement("w:updateFields", options.updateFields)); + } + this.root.push( new Compatibility({ ...(options.compatibility ?? {}), diff --git a/src/file/shading/shading.spec.ts b/src/file/shading/shading.spec.ts index 31e54f43ab..5c95ee3df0 100644 --- a/src/file/shading/shading.spec.ts +++ b/src/file/shading/shading.spec.ts @@ -6,12 +6,27 @@ import { ShadingType, createShading } from "./shading"; describe("Shading", () => { describe("#createShading", () => { - it("should create", () => { + it("should write clear shading when no pattern is given, as w:val is required", () => { const shading = createShading({}); const tree = new Formatter().format(shading); expect(tree).to.deep.equal({ "w:shd": { - _attr: {}, + _attr: { + "w:val": "clear", + }, + }, + }); + }); + + it("should write a fill with no pattern as clear shading", () => { + const shading = createShading({ fill: "00FF00" }); + const tree = new Formatter().format(shading); + expect(tree).to.deep.equal({ + "w:shd": { + _attr: { + "w:fill": "00FF00", + "w:val": "clear", + }, }, }); }); diff --git a/src/file/shading/shading.ts b/src/file/shading/shading.ts index a1de6f2aff..c0a300aced 100644 --- a/src/file/shading/shading.ts +++ b/src/file/shading/shading.ts @@ -34,7 +34,7 @@ import type { XmlComponent } from "@file/xml-components"; * * @property fill - Background fill color in hex format (e.g., "FF0000" for red), or a color of the document's theme * @property color - Pattern color in hex format, or a color of the document's theme - * @property type - Shading pattern type + * @property type - Shading pattern type. Without one, the shading is clear: the fill color only */ export type IShadingAttributesProperties = { readonly fill?: string | ThemeColor; @@ -54,7 +54,8 @@ export const createShading = ({ fill, color, type }: IShadingAttributesPropertie createColorElement("w:shd", [ { keys: { color: "w:fill", theme: "w:themeFill", tint: "w:themeFillTint", shade: "w:themeFillShade" }, color: fill }, { keys: COLOR_ATTRIBUTES, color }, - { key: "w:val", value: type }, + // w:val is required. Without a pattern, the shading is clear: the fill color only, as Word writes it + { key: "w:val", value: type ?? ShadingType.CLEAR }, ]); /** diff --git a/src/file/styles/factory.ts b/src/file/styles/factory.ts index dfaa7b947b..bc31d7e38e 100644 --- a/src/file/styles/factory.ts +++ b/src/file/styles/factory.ts @@ -7,6 +7,8 @@ * * @module */ +import type { XmlComponent } from "@file/xml-components"; + import { DocumentDefaults, type IDocumentDefaultsOptions } from "./defaults"; import { EndnoteReferenceStyle, @@ -85,6 +87,77 @@ export type IDefaultStylesOptions = { readonly endnoteTextChar?: IBaseCharacterStyleOptions; }; +/** + * docx's default styles, each under the option of `styles.default` that configures it. + * + * @internal + */ +export const createDefaultStyles = ( + options: IDefaultStylesOptions = {}, +): { readonly [Key in keyof IDefaultStylesOptions]-?: XmlComponent } => ({ + document: new DocumentDefaults(options.document ?? {}), + title: new TitleStyle({ + run: { + size: 56, + }, + ...options.title, + }), + heading1: new Heading1Style({ + run: { + color: "2E74B5", + size: 32, + }, + ...options.heading1, + }), + heading2: new Heading2Style({ + run: { + color: "2E74B5", + size: 26, + }, + ...options.heading2, + }), + heading3: new Heading3Style({ + run: { + color: "1F4D78", + size: 24, + }, + ...options.heading3, + }), + heading4: new Heading4Style({ + run: { + color: "2E74B5", + italics: true, + }, + ...options.heading4, + }), + heading5: new Heading5Style({ + run: { + color: "2E74B5", + }, + ...options.heading5, + }), + heading6: new Heading6Style({ + run: { + color: "1F4D78", + }, + ...options.heading6, + }), + strong: new StrongStyle({ + run: { + bold: true, + }, + ...options.strong, + }), + listParagraph: new ListParagraph(options.listParagraph || {}), + hyperlink: new HyperlinkStyle(options.hyperlink || {}), + footnoteReference: new FootnoteReferenceStyle(options.footnoteReference || {}), + footnoteText: new FootnoteText(options.footnoteText || {}), + footnoteTextChar: new FootnoteTextChar(options.footnoteTextChar || {}), + endnoteReference: new EndnoteReferenceStyle(options.endnoteReference || {}), + endnoteText: new EndnoteText(options.endnoteText || {}), + endnoteTextChar: new EndnoteTextChar(options.endnoteTextChar || {}), +}); + /** * Factory for creating default document styles. * @@ -110,69 +183,7 @@ export class DefaultStylesFactory { const documentAttributes = new DocumentAttributes(["mc", "r", "w", "w14", "w15"], "w14 w15"); return { initialStyles: documentAttributes, - importedStyles: [ - new DocumentDefaults(options.document ?? {}), - new TitleStyle({ - run: { - size: 56, - }, - ...options.title, - }), - new Heading1Style({ - run: { - color: "2E74B5", - size: 32, - }, - ...options.heading1, - }), - new Heading2Style({ - run: { - color: "2E74B5", - size: 26, - }, - ...options.heading2, - }), - new Heading3Style({ - run: { - color: "1F4D78", - size: 24, - }, - ...options.heading3, - }), - new Heading4Style({ - run: { - color: "2E74B5", - italics: true, - }, - ...options.heading4, - }), - new Heading5Style({ - run: { - color: "2E74B5", - }, - ...options.heading5, - }), - new Heading6Style({ - run: { - color: "1F4D78", - }, - ...options.heading6, - }), - new StrongStyle({ - run: { - bold: true, - }, - ...options.strong, - }), - new ListParagraph(options.listParagraph || {}), - new HyperlinkStyle(options.hyperlink || {}), - new FootnoteReferenceStyle(options.footnoteReference || {}), - new FootnoteText(options.footnoteText || {}), - new FootnoteTextChar(options.footnoteTextChar || {}), - new EndnoteReferenceStyle(options.endnoteReference || {}), - new EndnoteText(options.endnoteText || {}), - new EndnoteTextChar(options.endnoteTextChar || {}), - ], + importedStyles: Object.values(createDefaultStyles(options)), }; } } diff --git a/src/file/styles/style/character-style.spec.ts b/src/file/styles/style/character-style.spec.ts index 68a62135b1..46f702288c 100644 --- a/src/file/styles/style/character-style.spec.ts +++ b/src/file/styles/style/character-style.spec.ts @@ -730,12 +730,12 @@ describe("CharacterStyle", () => { const highlightTests = [ { highlight: HighlightColor.YELLOW, - expected: [{ "w:highlight": { _attr: { "w:val": "yellow" } } }, { "w:highlightCs": { _attr: { "w:val": "yellow" } } }], + expected: [{ "w:highlight": { _attr: { "w:val": "yellow" } } }], }, { highlight: HighlightColor.YELLOW, highlightComplexScript: true, - expected: [{ "w:highlight": { _attr: { "w:val": "yellow" } } }, { "w:highlightCs": { _attr: { "w:val": "yellow" } } }], + expected: [{ "w:highlight": { _attr: { "w:val": "yellow" } } }], }, { highlight: HighlightColor.YELLOW, @@ -745,11 +745,11 @@ describe("CharacterStyle", () => { { highlight: HighlightColor.YELLOW, highlightComplexScript: "550099", - expected: [{ "w:highlight": { _attr: { "w:val": "yellow" } } }, { "w:highlightCs": { _attr: { "w:val": "550099" } } }], + expected: [{ "w:highlight": { _attr: { "w:val": "yellow" } } }], }, ]; highlightTests.forEach(({ highlight, highlightComplexScript, expected }) => { - it(`#highlight ${highlight} cs ${highlightComplexScript}`, () => { + it(`#highlight ${highlight} writes only w:highlight, as highlightComplexScript (${highlightComplexScript}) has no effect`, () => { const style = new StyleForCharacter({ id: "myStyleId", run: { highlight, highlightComplexScript }, diff --git a/src/file/styles/style/paragraph-style.spec.ts b/src/file/styles/style/paragraph-style.spec.ts index 2709d81da7..42e754e720 100644 --- a/src/file/styles/style/paragraph-style.spec.ts +++ b/src/file/styles/style/paragraph-style.spec.ts @@ -656,12 +656,12 @@ describe("ParagraphStyle", () => { const highlightTests = [ { highlight: HighlightColor.YELLOW, - expected: [{ "w:highlight": { _attr: { "w:val": "yellow" } } }, { "w:highlightCs": { _attr: { "w:val": "yellow" } } }], + expected: [{ "w:highlight": { _attr: { "w:val": "yellow" } } }], }, { highlight: HighlightColor.YELLOW, highlightComplexScript: true, - expected: [{ "w:highlight": { _attr: { "w:val": "yellow" } } }, { "w:highlightCs": { _attr: { "w:val": "yellow" } } }], + expected: [{ "w:highlight": { _attr: { "w:val": "yellow" } } }], }, { highlight: HighlightColor.YELLOW, @@ -671,11 +671,11 @@ describe("ParagraphStyle", () => { { highlight: HighlightColor.YELLOW, highlightComplexScript: "550099", - expected: [{ "w:highlight": { _attr: { "w:val": "yellow" } } }, { "w:highlightCs": { _attr: { "w:val": "550099" } } }], + expected: [{ "w:highlight": { _attr: { "w:val": "yellow" } } }], }, ]; highlightTests.forEach(({ highlight, highlightComplexScript, expected }) => { - it(`#highlight ${highlight} cs ${highlightComplexScript}`, () => { + it(`#highlight ${highlight} writes only w:highlight, as highlightComplexScript (${highlightComplexScript}) has no effect`, () => { const style = new StyleForParagraph({ id: "myStyleId", run: { highlight, highlightComplexScript }, diff --git a/src/file/styles/styles.spec.ts b/src/file/styles/styles.spec.ts index 2c1bc8b126..2213aa9dfe 100644 --- a/src/file/styles/styles.spec.ts +++ b/src/file/styles/styles.spec.ts @@ -6,6 +6,9 @@ import { DocumentWrapper } from "@file/document-wrapper"; import type { File } from "@file/file"; import { EMPTY_OBJECT } from "@file/xml-components"; +import { DocumentDefaults } from "./defaults"; +import { ExternalStylesFactory } from "./external-styles-factory"; +import { DefaultStylesFactory } from "./factory"; import { Styles } from "./styles"; describe("Styles", () => { @@ -149,4 +152,66 @@ describe("Styles", () => { ]); }); }); + + describe("#prepForXml", () => { + it("should replace a default style with a paragraph style of the same id", () => { + const styles = new Styles({ + ...new DefaultStylesFactory().newInstance(), + paragraphStyles: [{ id: "Heading2", name: "My Heading 2" }], + }); + const tree = new Formatter().format(styles)["w:styles"]; + const headings = tree.filter((x: any) => [x["w:style"]].flat().some((part: any) => part?._attr?.["w:styleId"] === "Heading2")); + expect(headings).to.deep.equal([ + { + "w:style": [ + { _attr: { "w:type": "paragraph", "w:styleId": "Heading2" } }, + { "w:name": { _attr: { "w:val": "My Heading 2" } } }, + ], + }, + ]); + expect(tree).to.have.length(new Formatter().format(new Styles(new DefaultStylesFactory().newInstance()))["w:styles"].length); + }); + + it("should put the document defaults and the latent styles first, and keep the last of each", () => { + const external = new ExternalStylesFactory().newInstance(` + + + + `); + const styles = new Styles({ ...external, importedStyles: [new DocumentDefaults({}), ...external.importedStyles!] }); + expect(new Formatter().format(styles)).to.deep.equal({ + "w:styles": [ + { _attr: { "xmlns:w": "main" } }, + { "w:docDefaults": [{ "w:rPrDefault": EMPTY_OBJECT }] }, + { "w:latentStyles": { _attr: { "w:defQFormat": "0" } } }, + { + "w:style": [ + { _attr: { "w:type": "paragraph", "w:styleId": "Normal" } }, + { "w:name": { _attr: { "w:val": "Normal" } } }, + ], + }, + ], + }); + }); + + it("should write styles with nothing in them as an empty element", () => { + expect(new Formatter().format(new Styles({}))).to.deep.equal({ "w:styles": EMPTY_OBJECT }); + }); + + it("should keep every style without an id, and text, where they are", () => { + const styles = new Styles( + new ExternalStylesFactory().newInstance( + `text`, + ), + ); + expect(new Formatter().format(styles)).to.deep.equal({ + "w:styles": [ + { _attr: { "xmlns:w": "main" } }, + "text", + { "w:style": EMPTY_OBJECT }, + { "w:style": [{ "w:name": { _attr: { "w:val": "No id" } } }] }, + ], + }); + }); + }); }); diff --git a/src/file/styles/styles.ts b/src/file/styles/styles.ts index 2b40bb1aa2..28f5b4cfbb 100644 --- a/src/file/styles/styles.ts +++ b/src/file/styles/styles.ts @@ -8,7 +8,7 @@ * @module */ import type { IDefaultStylesOptions } from "@file/styles/factory"; -import { type BaseXmlComponent, type ImportedXmlComponent, XmlComponent } from "@file/xml-components"; +import { type BaseXmlComponent, type IContext, type IXmlableObject, type ImportedXmlComponent, XmlComponent } from "@file/xml-components"; import { StyleForCharacter, StyleForParagraph } from "./style"; import type { ICharacterStyleOptions } from "./style/character-style"; @@ -26,7 +26,10 @@ import type { IParagraphStyleOptions } from "./style/paragraph-style"; * @see {@link Styles} */ export type IStylesOptions = { - /** Default styles for document, headings, and common elements */ + /** + * Default styles for document, headings, and common elements. With `externalStyles`, each one given here takes the + * place of the external style with its id, or of the external document defaults + */ readonly default?: IDefaultStylesOptions; /** Initial base XML component for styles root element */ readonly initialStyles?: BaseXmlComponent; @@ -38,6 +41,12 @@ export type IStylesOptions = { readonly importedStyles?: readonly (XmlComponent | StyleForParagraph | StyleForCharacter | ImportedXmlComponent)[]; }; +/** The name of a formatted element, such as `w:style`, or `_attr` for its parent's attributes */ +const nameOf = (child: unknown): string | undefined => (typeof child === "object" ? Object.keys(child as object)[0] : undefined); + +/** The id of a formatted `w:style` */ +const styleIdOf = (style: IXmlableObject): string | undefined => [style["w:style"]].flat().find((part) => part._attr)?._attr["w:styleId"]; + /** * Represents the styles definitions in a WordprocessingML document. * @@ -102,4 +111,28 @@ export class Styles extends XmlComponent { } } } + + /** + * Writes the styles in the schema's order: the document defaults, the latent styles, then the styles. A style id + * can only be used once, so a style replaces an earlier one with its id. That way external styles replace docx's + * default styles, and paragraph and character styles replace the default and imported ones. Of several document + * defaults, or several latent styles, the last is kept. + */ + public prepForXml(context: IContext): IXmlableObject { + const xml = super.prepForXml(context) as IXmlableObject; + const children: unknown = xml["w:styles"]; + if (!Array.isArray(children)) { + return xml; + } + const named = (name: string): readonly unknown[] => children.filter((child) => nameOf(child) === name); + const ids = children.map((child) => (nameOf(child) === "w:style" ? styleIdOf(child) : undefined)); + const styles = children.filter( + (child, index) => + !["_attr", "w:docDefaults", "w:latentStyles"].includes(nameOf(child) as string) && + (ids[index] === undefined || ids.lastIndexOf(ids[index]) === index), + ); + return { + "w:styles": [...named("_attr"), ...named("w:docDefaults").slice(-1), ...named("w:latentStyles").slice(-1), ...styles], + }; + } } diff --git a/src/file/table/on-off-only-element.ts b/src/file/table/on-off-only-element.ts new file mode 100644 index 0000000000..35762064e5 --- /dev/null +++ b/src/file/table/on-off-only-element.ts @@ -0,0 +1,27 @@ +/** + * On/off elements of tables that Office only takes "on" and "off" for. + * + * @module + */ +import { OnOffElement, StringValueElement, type XmlComponent } from "@file/xml-components"; + +/** + * Creates an on/off element that Office only takes "on" and "off" for. + * + * ISO 29500 types a table's w:bidiVisual and a row's w:cantSplit and w:tblHeader as CT_OnOff, which takes true, false, + * 1, 0, on and off. Office's schema types them as CT_OnOffOnly, which only takes on and off, so Word's validator rejects + * w:val="false". Off is written as "off", which both accept. + * + * @example + * ```typescript + * createOnOffOnlyElement("w:cantSplit", true); + * // Generates: + * + * createOnOffOnlyElement("w:cantSplit", false); + * // Generates: + * ``` + * + * @internal + */ +export const createOnOffOnlyElement = (name: string, value: boolean): XmlComponent => + value ? new OnOffElement(name) : new StringValueElement(name, "off"); diff --git a/src/file/table/table-cell/table-cell-properties.spec.ts b/src/file/table/table-cell/table-cell-properties.spec.ts index 396f6e92dc..be58dc4171 100644 --- a/src/file/table/table-cell/table-cell-properties.spec.ts +++ b/src/file/table/table-cell/table-cell-properties.spec.ts @@ -66,7 +66,9 @@ describe("TableCellProperties", () => { }, }); const tree = new Formatter().format(properties); - expect(tree).to.deep.equal({ "w:tcPr": [{ "w:shd": { _attr: { "w:fill": "ffffff", "w:color": "000000" } } }] }); + expect(tree).to.deep.equal({ + "w:tcPr": [{ "w:shd": { _attr: { "w:fill": "ffffff", "w:color": "000000", "w:val": "clear" } } }], + }); }); it("should set the TableCellBorders", () => { @@ -173,5 +175,19 @@ describe("TableCellProperties", () => { ], }); }); + + it("should write a merge revision before the previous cell properties, as the schema wants", () => { + const cellProperties = new TableCellProperties({ + cellMerge: { id: 1, author: "Firstname Lastname", date: "123", verticalMerge: "rest" }, + revision: { id: 2, author: "Firstname Lastname", date: "123" }, + }); + const tree = new Formatter().format(cellProperties); + expect(tree).to.deep.equal({ + "w:tcPr": [ + { "w:cellMerge": { _attr: { "w:id": 1, "w:author": "Firstname Lastname", "w:date": "123", "w:vMerge": "rest" } } }, + { "w:tcPrChange": [{ _attr: { "w:author": "Firstname Lastname", "w:date": "123", "w:id": 2 } }, { "w:tcPr": {} }] }, + ], + }); + }); }); }); diff --git a/src/file/table/table-cell/table-cell-properties.ts b/src/file/table/table-cell/table-cell-properties.ts index 84668f0881..2c4c46fd93 100644 --- a/src/file/table/table-cell/table-cell-properties.ts +++ b/src/file/table/table-cell/table-cell-properties.ts @@ -191,13 +191,14 @@ export class TableCellProperties extends IgnoreIfEmptyXmlComponent { this.root.push(new DeletedTableCell(options.deletion)); } - if (options.revision) { - this.root.push(new TableCellPropertiesChange(options.revision)); - } - if (options.cellMerge) { this.root.push(new CellMerge(options.cellMerge)); } + + // CT_TcPr puts the previous cell properties after all the others + if (options.revision) { + this.root.push(new TableCellPropertiesChange(options.revision)); + } } } diff --git a/src/file/table/table-properties/table-float-properties.spec.ts b/src/file/table/table-properties/table-float-properties.spec.ts index 6b8157decd..112d920b75 100644 --- a/src/file/table/table-properties/table-float-properties.spec.ts +++ b/src/file/table/table-properties/table-float-properties.spec.ts @@ -29,25 +29,16 @@ describe("Table Float Properties", () => { expect(tree).to.deep.equal(DEFAULT_TFP); }); - it("should add overlap", () => { + it("should leave overlap out of w:tblpPr, which can't have children", () => { const properties = createTableFloatProperties({ overlap: OverlapType.NEVER, }); const tree = new Formatter().format(properties); expect(tree).to.deep.equal({ - "w:tblpPr": [ - { - _attr: {}, - }, - { - "w:tblOverlap": { - _attr: { - "w:val": "never", - }, - }, - }, - ], + "w:tblpPr": { + _attr: {}, + }, }); }); }); diff --git a/src/file/table/table-properties/table-float-properties.ts b/src/file/table/table-properties/table-float-properties.ts index a7abf5bca7..32899fcd13 100644 --- a/src/file/table/table-properties/table-float-properties.ts +++ b/src/file/table/table-properties/table-float-properties.ts @@ -151,27 +151,20 @@ export type ITableFloatOptions = { * to the right of the table. The value is in twentieths of a point. If omitted, the value is assumed to be zero. */ readonly rightFromText?: number | PositiveUniversalMeasure; + + /** + * Specifies whether the table may overlap other floating tables. It is written in the table's properties as + * w:tblOverlap, beside w:tblpPr. + */ readonly overlap?: (typeof OverlapType)[keyof typeof OverlapType]; }; -/** - * Creates a table overlap element. - * - * @internal - */ -const createOverlapElement = (overlap: (typeof OverlapType)[keyof typeof OverlapType]): XmlComponent => - new BuilderElement<{ readonly val: (typeof OverlapType)[keyof typeof OverlapType] }>({ - name: "w:tblOverlap", - attributes: { - val: { key: "w:val", value: overlap }, - }, - }); - /** * Creates floating table properties in a WordprocessingML document. * * This element specifies the positioning of a floating table, * including anchor points, offsets, and text wrapping behavior. + * The overlap option isn't part of it: the table properties write it as w:tblOverlap. * * Reference: http://officeopenxml.com/WPtableFloating.php * @@ -212,7 +205,6 @@ export const createTableFloatProperties = ({ topFromText, leftFromText, rightFromText, - overlap, }: ITableFloatOptions): XmlComponent => new BuilderElement>({ name: "w:tblpPr", @@ -258,5 +250,4 @@ export const createTableFloatProperties = ({ value: verticalAnchor, }, }, - children: overlap ? [createOverlapElement(overlap)] : undefined, }); diff --git a/src/file/table/table-properties/table-properties.spec.ts b/src/file/table/table-properties/table-properties.spec.ts index a4a66a6244..8fc524276a 100644 --- a/src/file/table/table-properties/table-properties.spec.ts +++ b/src/file/table/table-properties/table-properties.spec.ts @@ -5,6 +5,7 @@ import { AlignmentType } from "@file/paragraph"; import { ShadingType } from "@file/shading"; import { WidthType } from "../table-width"; +import { OverlapType, TableAnchorType } from "./table-float-properties"; import { TableLayoutType } from "./table-layout"; import { TableProperties } from "./table-properties"; import { CellSpacingType } from "../table-cell-spacing"; @@ -106,6 +107,55 @@ describe("TableProperties", () => { }); }); + it("should write the cell spacing after the alignment and before the indent and borders, as the schema requires", () => { + const tp = new TableProperties({ + cellSpacing: { + value: 1234, + type: CellSpacingType.DXA, + }, + tableLook: { firstRow: true }, + borders: {}, + indent: { size: 100, type: WidthType.DXA }, + alignment: AlignmentType.CENTER, + width: { size: 5000, type: WidthType.DXA }, + }); + const tree = new Formatter().format(tp); + const elements = (tree["w:tblPr"] as readonly Record[]).map((child) => Object.keys(child)[0]); + expect(elements).to.deep.equal(["w:tblW", "w:jc", "w:tblCellSpacing", "w:tblInd", "w:tblBorders", "w:tblLook"]); + }); + + it("should write a floating table's overlap beside w:tblpPr, not inside it", () => { + const tp = new TableProperties({ + style: "TableNormal", + float: { + horizontalAnchor: TableAnchorType.MARGIN, + overlap: OverlapType.NEVER, + }, + visuallyRightToLeft: true, + }); + const tree = new Formatter().format(tp); + expect(tree).to.deep.equal({ + "w:tblPr": [ + { "w:tblStyle": { _attr: { "w:val": "TableNormal" } } }, + { "w:tblpPr": { _attr: { "w:horzAnchor": "margin" } } }, + { "w:tblOverlap": { _attr: { "w:val": "never" } } }, + { "w:bidiVisual": {} }, + ], + }); + }); + + it("should not write an overlap for a floating table without one", () => { + const tp = new TableProperties({ + float: { + horizontalAnchor: TableAnchorType.MARGIN, + }, + }); + const tree = new Formatter().format(tp); + expect(tree).to.deep.equal({ + "w:tblPr": [{ "w:tblpPr": { _attr: { "w:horzAnchor": "margin" } } }], + }); + }); + it("should add a revision property", () => { const tp = new TableProperties({ revision: { @@ -234,6 +284,16 @@ describe("TableProperties", () => { ], }); }); + + it("writes a table that isn't visually right to left as off, the only false value Office takes there", () => { + const tp = new TableProperties({ + visuallyRightToLeft: false, + }); + const tree = new Formatter().format(tp); + expect(tree).to.deep.equal({ + "w:tblPr": [{ "w:bidiVisual": { _attr: { "w:val": "off" } } }], + }); + }); }); describe("#tableLook", () => { diff --git a/src/file/table/table-properties/table-properties.ts b/src/file/table/table-properties/table-properties.ts index 0784eb2c06..b11062d65a 100644 --- a/src/file/table/table-properties/table-properties.ts +++ b/src/file/table/table-properties/table-properties.ts @@ -44,14 +44,15 @@ * @module */ import { ChangeAttributes, type IChangedAttributesProperties } from "@file/track-revision/track-revision"; -import { IgnoreIfEmptyXmlComponent, OnOffElement, StringValueElement, XmlComponent } from "@file/xml-components"; +import { BuilderElement, IgnoreIfEmptyXmlComponent, StringValueElement, XmlComponent } from "@file/xml-components"; import { type AlignmentType, createAlignment } from "../../paragraph"; import { type IShadingAttributesProperties, createShading } from "../../shading"; +import { createOnOffOnlyElement } from "../on-off-only-element"; import { type ITableWidthProperties, createTableWidthElement } from "../table-width"; import { type ITableBordersOptions, TableBorders } from "./table-borders"; import { type ITableCellMarginOptions, createTableCellMargin } from "./table-cell-margin"; -import { type ITableFloatOptions, createTableFloatProperties } from "./table-float-properties"; +import { type ITableFloatOptions, type OverlapType, createTableFloatProperties } from "./table-float-properties"; import { type TableLayoutType, createTableLayout } from "./table-layout"; import { type ITableCellSpacingProperties, createTableCellSpacing } from "../table-cell-spacing"; import { type ITableLookOptions, createTableLook } from "./table-look"; @@ -73,6 +74,17 @@ export type ITablePropertiesOptionsBase = { export type ITablePropertiesChangeOptions = ITablePropertiesOptions & IChangedAttributesProperties; +// +// +// +const createTableOverlap = (overlap: (typeof OverlapType)[keyof typeof OverlapType]): XmlComponent => + new BuilderElement<{ readonly val: (typeof OverlapType)[keyof typeof OverlapType] }>({ + name: "w:tblOverlap", + attributes: { + val: { key: "w:val", value: overlap }, + }, + }); + /** * Options for configuring table properties. * @@ -103,8 +115,13 @@ export class TableProperties extends IgnoreIfEmptyXmlComponent { this.root.push(createTableFloatProperties(options.float)); } + // w:tblOverlap goes beside w:tblpPr, which can't have children + if (options.float?.overlap) { + this.root.push(createTableOverlap(options.float.overlap)); + } + if (options.visuallyRightToLeft !== undefined) { - this.root.push(new OnOffElement("w:bidiVisual", options.visuallyRightToLeft)); + this.root.push(createOnOffOnlyElement("w:bidiVisual", options.visuallyRightToLeft)); } if (options.width) { @@ -115,6 +132,10 @@ export class TableProperties extends IgnoreIfEmptyXmlComponent { this.root.push(createAlignment(options.alignment)); } + if (options.cellSpacing) { + this.root.push(createTableCellSpacing(options.cellSpacing)); + } + if (options.indent) { this.root.push(createTableWidthElement("w:tblInd", options.indent)); } @@ -142,10 +163,6 @@ export class TableProperties extends IgnoreIfEmptyXmlComponent { this.root.push(createTableLook(options.tableLook)); } - if (options.cellSpacing) { - this.root.push(createTableCellSpacing(options.cellSpacing)); - } - if (options.revision) { this.root.push(new TablePropertiesChange(options.revision)); } diff --git a/src/file/table/table-row/table-row-properties.spec.ts b/src/file/table/table-row/table-row-properties.spec.ts index e12e98f2d7..3a3d787173 100644 --- a/src/file/table/table-row/table-row-properties.spec.ts +++ b/src/file/table/table-row/table-row-properties.spec.ts @@ -45,6 +45,14 @@ describe("TableRowProperties", () => { expect(tree).to.deep.equal({ "w:trPr": [{ "w:tblHeader": {} }] }); }); + it("writes a row that can split and isn't a header row as off, the only false value Office takes there", () => { + const rowProperties = new TableRowProperties({ cantSplit: false, tableHeader: false }); + const tree = new Formatter().format(rowProperties); + expect(tree).to.deep.equal({ + "w:trPr": [{ "w:cantSplit": { _attr: { "w:val": "off" } } }, { "w:tblHeader": { _attr: { "w:val": "off" } } }], + }); + }); + it("sets row height exact", () => { const rowProperties = new TableRowProperties({ height: { @@ -119,5 +127,43 @@ describe("TableRowProperties", () => { ], }); }); + + it("writes a revision's previous cantSplit and tableHeader of false as off", () => { + const rowProperties = new TableRowProperties({ + cantSplit: true, + tableHeader: true, + revision: { + id: 1, + author: "Firstname Lastname", + date: "123", + cantSplit: false, + tableHeader: false, + }, + }); + const tree = new Formatter().format(rowProperties); + expect(tree).to.deep.equal({ + "w:trPr": [ + { "w:cantSplit": {} }, + { "w:tblHeader": {} }, + { + "w:trPrChange": [ + { + _attr: { + "w:author": "Firstname Lastname", + "w:date": "123", + "w:id": 1, + }, + }, + { + "w:trPr": [ + { "w:cantSplit": { _attr: { "w:val": "off" } } }, + { "w:tblHeader": { _attr: { "w:val": "off" } } }, + ], + }, + ], + }, + ], + }); + }); }); }); diff --git a/src/file/table/table-row/table-row-properties.ts b/src/file/table/table-row/table-row-properties.ts index 373979d2d8..1277a427e1 100644 --- a/src/file/table/table-row/table-row-properties.ts +++ b/src/file/table/table-row/table-row-properties.ts @@ -49,9 +49,10 @@ */ import { DeletedTableRow, InsertedTableRow } from "@file/track-revision"; import { ChangeAttributes, type IChangedAttributesProperties } from "@file/track-revision/track-revision"; -import { IgnoreIfEmptyXmlComponent, OnOffElement, XmlComponent } from "@file/xml-components"; +import { IgnoreIfEmptyXmlComponent, XmlComponent } from "@file/xml-components"; import type { PositiveUniversalMeasure } from "@util/values"; +import { createOnOffOnlyElement } from "../on-off-only-element"; import { type HeightRule, createTableRowHeight } from "./table-row-height"; import { type ITableCellSpacingProperties, createTableCellSpacing } from "../table-cell-spacing"; @@ -110,11 +111,11 @@ export class TableRowProperties extends IgnoreIfEmptyXmlComponent { super("w:trPr", options.includeIfEmpty); if (options.cantSplit !== undefined) { - this.root.push(new OnOffElement("w:cantSplit", options.cantSplit)); + this.root.push(createOnOffOnlyElement("w:cantSplit", options.cantSplit)); } if (options.tableHeader !== undefined) { - this.root.push(new OnOffElement("w:tblHeader", options.tableHeader)); + this.root.push(createOnOffOnlyElement("w:tblHeader", options.tableHeader)); } if (options.height) { diff --git a/src/file/table/table-row/table-row.spec.ts b/src/file/table/table-row/table-row.spec.ts index ef6f9ab5d0..0b1f773426 100644 --- a/src/file/table/table-row/table-row.spec.ts +++ b/src/file/table/table-row/table-row.spec.ts @@ -189,14 +189,14 @@ describe("TableRow", () => { { "w:cantSplit": { _attr: { - "w:val": false, + "w:val": "off", }, }, }, { "w:tblHeader": { _attr: { - "w:val": false, + "w:val": "off", }, }, }, diff --git a/src/file/textbox/shape/shape.spec.ts b/src/file/textbox/shape/shape.spec.ts index 021abeed45..ce114d8b83 100644 --- a/src/file/textbox/shape/shape.spec.ts +++ b/src/file/textbox/shape/shape.spec.ts @@ -22,7 +22,7 @@ describe("createShape", () => { { _attr: { id: "test-id", type: "#_x0000_t202", style: "width:10pt" } }, { "v:textbox": [ - { _attr: { insetmode: "auto", style: "mso-fit-shape-to-text:t;" } }, + { _attr: { style: "mso-fit-shape-to-text:t;" } }, { "w:txbxContent": [ { "w:p": [{ "w:r": [{ "w:t": [{ _attr: { "xml:space": "preserve" } }, "test-content"] }] }] }, @@ -46,7 +46,7 @@ describe("createShape", () => { { _attr: { id: "test-id", type: "#_x0000_t202" } }, { "v:textbox": [ - { _attr: { insetmode: "auto", style: "mso-fit-shape-to-text:t;" } }, + { _attr: { style: "mso-fit-shape-to-text:t;" } }, { "w:txbxContent": {}, }, diff --git a/src/file/textbox/textbox.spec.ts b/src/file/textbox/textbox.spec.ts index 168adde03d..76dbc0937f 100644 --- a/src/file/textbox/textbox.spec.ts +++ b/src/file/textbox/textbox.spec.ts @@ -25,7 +25,7 @@ const TEXTBOX_RUN = { { _attr: { id: expect.any(String), type: "#_x0000_t202", style: "width:10pt" } }, { "v:textbox": [ - { _attr: { insetmode: "auto", style: "mso-fit-shape-to-text:t;" } }, + { _attr: { style: "mso-fit-shape-to-text:t;" } }, { "w:txbxContent": [ { diff --git a/src/file/textbox/vml-textbox/vml-texbox.ts b/src/file/textbox/vml-textbox/vml-texbox.ts index 8669d6c645..2c43cd07ca 100644 --- a/src/file/textbox/vml-textbox/vml-texbox.ts +++ b/src/file/textbox/vml-textbox/vml-texbox.ts @@ -9,7 +9,6 @@ */ import type { ParagraphChild } from "@file/paragraph"; import { BuilderElement, type XmlComponent } from "@file/xml-components"; -import type { InsetMode } from "@util/types"; import { createTextboxContent } from "../texbox-content/textbox-content"; import type { LengthUnit } from "../types"; @@ -82,17 +81,15 @@ export type IVTextboxOptions = { * ``` */ export const createVmlTextbox = ({ style, children, inset }: IVTextboxOptions): XmlComponent => - new BuilderElement<{ readonly style?: string; readonly inset?: string; readonly insetMode?: InsetMode }>({ + new BuilderElement<{ readonly style?: string; readonly inset?: string }>({ name: "v:textbox", + // No o:insetmode: Office only takes it on the shape. Its default, custom, uses the inset attribute, which + // defaults to Word's usual margins when it's left out attributes: { style: { key: "style", value: style, }, - insetMode: { - key: "insetmode", - value: inset ? "custom" : "auto", - }, inset: { key: "inset", value: inset ? `${inset.left}, ${inset.top}, ${inset.right}, ${inset.bottom}` : undefined, diff --git a/src/file/textbox/vml-textbox/vml-textbox.spec.ts b/src/file/textbox/vml-textbox/vml-textbox.spec.ts index 26fd1652a7..c025a9b2f6 100644 --- a/src/file/textbox/vml-textbox/vml-textbox.spec.ts +++ b/src/file/textbox/vml-textbox/vml-textbox.spec.ts @@ -6,7 +6,7 @@ import { Paragraph } from "@file/paragraph"; import { createVmlTextbox } from "./vml-texbox"; describe("VmlTextbox", () => { - it("should work", () => { + it("should write the style, and no o:insetmode, which Office only takes on the shape", () => { const tree = new Formatter().format( createVmlTextbox({ style: "test-style", @@ -16,13 +16,13 @@ describe("VmlTextbox", () => { expect(tree).toStrictEqual({ "v:textbox": [ - { _attr: { insetmode: "auto", style: "test-style" } }, + { _attr: { style: "test-style" } }, { "w:txbxContent": [{ "w:p": [{ "w:r": [{ "w:t": [{ _attr: { "xml:space": "preserve" } }, "test-content"] }] }] }] }, ], }); }); - it("should work with inset", () => { + it("should write the inset as left, top, right and bottom", () => { const tree = new Formatter().format( createVmlTextbox({ style: "test-style", @@ -38,7 +38,7 @@ describe("VmlTextbox", () => { expect(tree).toStrictEqual({ "v:textbox": [ - { _attr: { insetmode: "custom", style: "test-style", inset: "0, 0, 0, 0" } }, + { _attr: { style: "test-style", inset: "0, 0, 0, 0" } }, { "w:txbxContent": [{ "w:p": [{ "w:r": [{ "w:t": [{ _attr: { "xml:space": "preserve" } }, "test-content"] }] }] }] }, ], }); diff --git a/src/file/track-revision/track-revision-components/deleted-text-run.spec.ts b/src/file/track-revision/track-revision-components/deleted-text-run.spec.ts index ba0d3b80cd..4223d08509 100644 --- a/src/file/track-revision/track-revision-components/deleted-text-run.spec.ts +++ b/src/file/track-revision/track-revision-components/deleted-text-run.spec.ts @@ -2,7 +2,7 @@ import { describe, expect, it } from "vitest"; import { Formatter } from "@export/formatter"; import { FootnoteReferenceRun } from "@file/footnotes"; -import { PageNumber } from "@file/paragraph"; +import { PageNumber, Tab } from "@file/paragraph"; import { DeletedTextRun } from "./deleted-text-run"; @@ -344,7 +344,7 @@ describe("DeletedTextRun", () => { }); describe("footnote references", () => { - it("should add a valid footnote reference", () => { + it("should write a footnote reference in the children as a run after the deleted run, not inside it", () => { const deletedTextRun = new DeletedTextRun({ children: ["some text", new FootnoteReferenceRun(1)], id: 0, @@ -373,16 +373,55 @@ describe("DeletedTextRun", () => { "some text", ], }, - { - "w:r": [ - { "w:rPr": [{ "w:rStyle": { _attr: { "w:val": "FootnoteReference" } } }] }, - { "w:footnoteReference": { _attr: { "w:id": 1 } } }, - ], - }, + ], + }, + { + "w:r": [ + { "w:rPr": [{ "w:rStyle": { _attr: { "w:val": "FootnoteReference" } } }] }, + { "w:footnoteReference": { _attr: { "w:id": 1 } } }, ], }, ], }); }); + + it("should keep other elements in the children, such as a tab, in the deleted run", () => { + const deletedTextRun = new DeletedTextRun({ children: [new Tab(), "A"], id: 0, date: "123", author: "Author" }); + const tree = new Formatter().format(deletedTextRun); + expect(tree).to.deep.equal({ + "w:del": [ + { _attr: { "w:author": "Author", "w:date": "123", "w:id": 0 } }, + { "w:r": [{ "w:tab": {} }, { "w:delText": [{ _attr: { "xml:space": "preserve" } }, "A"] }] }, + ], + }); + }); + + it("should split the deleted run at each footnote reference, and keep its properties for the text after it", () => { + const deletedTextRun = new DeletedTextRun({ + children: ["A", new FootnoteReferenceRun(1), "B", new FootnoteReferenceRun(2)], + bold: true, + id: 0, + date: "123", + author: "Author", + }); + const tree = new Formatter().format(deletedTextRun); + const bold = { "w:rPr": [{ "w:b": {} }, { "w:bCs": {} }] }; + const deleted = (text: string) => ({ "w:r": [bold, { "w:delText": [{ _attr: { "xml:space": "preserve" } }, text] }] }); + const reference = (id: number) => ({ + "w:r": [ + { "w:rPr": [{ "w:rStyle": { _attr: { "w:val": "FootnoteReference" } } }] }, + { "w:footnoteReference": { _attr: { "w:id": id } } }, + ], + }); + expect(tree).to.deep.equal({ + "w:del": [ + { _attr: { "w:author": "Author", "w:date": "123", "w:id": 0 } }, + deleted("A"), + reference(1), + deleted("B"), + reference(2), + ], + }); + }); }); }); diff --git a/src/file/track-revision/track-revision-components/deleted-text-run.ts b/src/file/track-revision/track-revision-components/deleted-text-run.ts index 727eec451b..780c189c9a 100644 --- a/src/file/track-revision/track-revision-components/deleted-text-run.ts +++ b/src/file/track-revision/track-revision-components/deleted-text-run.ts @@ -5,14 +5,14 @@ * * @module */ -import { XmlComponent } from "@file/xml-components"; +import { type BaseXmlComponent, XmlComponent } from "@file/xml-components"; import { DeletedNumberOfPages, DeletedNumberOfPagesSection, DeletedPage } from "./deleted-page-number"; import { DeletedText } from "./deleted-text"; import { createBreak } from "../../paragraph/run/break"; import { createBegin, createEnd, createSeparate } from "../../paragraph/run/field"; import { RunProperties } from "../../paragraph/run/properties"; -import { type IRunOptions, PageNumber } from "../../paragraph/run/run"; +import { type IRunOptions, PageNumber, Run } from "../../paragraph/run/run"; import { ChangeAttributes, type IChangedAttributesProperties } from "../track-revision"; /** @@ -101,12 +101,26 @@ export class DeletedTextRun extends XmlComponent { * @internal */ class DeletedTextRunWrapper extends XmlComponent { + // A run given in the children, such as a FootnoteReferenceRun, and the run of the children after it + private readonly following: readonly XmlComponent[] = []; + public constructor(options: IRunOptions) { super("w:r"); this.root.push(new RunProperties(options)); if (options.children) { - for (const child of options.children) { + for (const [index, child] of options.children.entries()) { + if (child instanceof Run) { + // A run can't be inside another, so this run ends before it, and the children after it go in a run + // with this run's properties + const rest = options.children.slice(index + 1); + this.following = [ + child, + ...(rest.length > 0 ? [new DeletedTextRunWrapper({ ...options, break: undefined, children: rest })] : []), + ]; + break; + } + if (typeof child === "string") { switch (child) { case PageNumber.CURRENT: @@ -146,4 +160,9 @@ class DeletedTextRunWrapper extends XmlComponent { } } } + + public get writtenAs(): readonly BaseXmlComponent[] | undefined { + // This run, then the ones after it, each written as it would be on its own + return this.following.length > 0 ? [this, ...this.following.flatMap((run) => run.writtenAs ?? run)] : undefined; + } } diff --git a/src/file/xml-components/base.ts b/src/file/xml-components/base.ts index a9f2b0719f..40c10bad90 100644 --- a/src/file/xml-components/base.ts +++ b/src/file/xml-components/base.ts @@ -74,4 +74,14 @@ export abstract class BaseXmlComponent { * @returns The XML-serializable object, or undefined to exclude from output */ public abstract prepForXml(context: IContext): IXmlableObject | undefined; + + /** + * The components written in this one's place, one after another, when it can't be written as a single element, + * such as a run with another run in its children. Undefined when it is written as itself. + * + * @internal + */ + public get writtenAs(): readonly BaseXmlComponent[] | undefined { + return undefined; + } } diff --git a/src/file/xml-components/xml-component.ts b/src/file/xml-components/xml-component.ts index 39cefb5a53..e2e89c4b08 100644 --- a/src/file/xml-components/xml-component.ts +++ b/src/file/xml-components/xml-component.ts @@ -91,11 +91,13 @@ export abstract class XmlComponent extends BaseXmlComponent { // eslint-disable-next-line functional/immutable-data context.stack.push(this); - // Recursively prepare all children for serialization + // Recursively prepare all children for serialization. A child written as several components, such as a run with + // a run in its children, is written as each of them in turn const children = this.root - .map((comp) => { + .flatMap((comp) => { if (comp instanceof BaseXmlComponent) { - return comp.prepForXml(context); + const parts = comp.writtenAs; + return parts ? parts.map((part) => part.prepForXml(context)) : comp.prepForXml(context); } return comp; }) diff --git a/src/patcher/replacer.spec.ts b/src/patcher/replacer.spec.ts index a1b3b531bf..59c8212d2d 100644 --- a/src/patcher/replacer.spec.ts +++ b/src/patcher/replacer.spec.ts @@ -3,6 +3,7 @@ import type { Element } from "xml-js"; import type { IViewWrapper } from "@file/document-wrapper"; import type { File } from "@file/file"; +import { FootnoteReferenceRun } from "@file/footnotes/footnote/run/reference-run"; import { ConcreteHyperlink, Paragraph, type ParagraphChild, TextRun } from "@file/paragraph"; import { PatchType } from "./from-docx"; @@ -975,6 +976,18 @@ describe("replacer", () => { expect(textsOf({ elements: [body] })).to.deep.equal(["X", "END", "X"]); }); + it("should write a run with a footnote reference in its children as runs side by side, not one inside another", () => { + const paragraph = createParagraph(createRun(createText("{{ph}}"))); + + replaceWith({ elements: [paragraph] }, [new TextRun({ children: ["X", new FootnoteReferenceRun(1)] })]); + + const runs = (paragraph.elements ?? []).filter((element) => element.name === "w:r"); + expect(runs.flatMap((run) => namesOf(run.elements))) + .to.include("w:footnoteReference") + .and.not.include("w:r"); + expect(textsOf({ elements: [paragraph] })).to.deep.equal(["X"]); + }); + it("should replace every occurrence in a paragraph", () => { const paragraph = createParagraph(createRun(createText("{{ph}} and {{ph}}"))); @@ -1051,13 +1064,75 @@ describe("replacer", () => { const insertedRun = paragraph.elements![1]; expect(namesOf(insertedRun.elements)).to.deep.equal(["w:rPr", "w:t"]); expect(insertedRun.elements![0].elements).toMatchObject([ - { name: "w:i" }, { name: "w:b" }, { name: "w:bCs" }, + { name: "w:i" }, { name: "w:color", attributes: { "w:val": "00FF00" } }, ]); }); + it("should put the merged run properties in the schema's order, whichever run they come from", () => { + const originalProperties: Element = { + type: "element", + name: "w:rPr", + elements: [ + { type: "element", name: "w:sz", attributes: { "w:val": "56" } }, + { type: "element", name: "w:szCs", attributes: { "w:val": "56" } }, + ], + }; + const paragraph = createParagraph(createRun(originalProperties, createText("{{ph}}"))); + + replaceWith({ elements: [paragraph] }, [new TextRun({ text: "X", font: "Trebuchet MS", underline: {} })]); + + expect(namesOf(paragraph.elements![1].elements![0].elements)).to.deep.equal(["w:rFonts", "w:sz", "w:szCs", "w:u"]); + }); + + it("should put Word 2010's run properties after the others, and properties it doesn't know after those", () => { + const originalProperties: Element = { + type: "element", + name: "w:rPr", + elements: [ + { type: "element", name: "w14:ligatures", attributes: { "w14:val": "standard" } }, + { type: "element", name: "w16:unknown" }, + { type: "element", name: "w14:textOutline" }, + { type: "element", name: "w:lang", attributes: { "w:val": "en-GB" } }, + ], + }; + const paragraph = createParagraph(createRun(originalProperties, createText("{{ph}}"))); + + replaceWith({ elements: [paragraph] }, [new TextRun({ text: "X", bold: true })]); + + expect(namesOf(paragraph.elements![1].elements![0].elements)).to.deep.equal([ + "w:b", + "w:bCs", + "w:lang", + "w14:textOutline", + "w14:ligatures", + "w16:unknown", + ]); + }); + + it("should keep content without a name, such as an XML comment, after the run properties", () => { + const originalProperties: Element = { + type: "element", + name: "w:rPr", + elements: [ + { type: "comment", comment: "kept" }, + { type: "element", name: "w:i" }, + ], + }; + const paragraph = createParagraph(createRun(originalProperties, createText("{{ph}}"))); + + replaceWith({ elements: [paragraph] }, [new TextRun({ text: "X", bold: true })]); + + expect(paragraph.elements![1].elements![0].elements!.map((e) => e.name ?? e.type)).to.deep.equal([ + "w:b", + "w:bCs", + "w:i", + "comment", + ]); + }); + it("should keep w:rPrChange after the other run properties when merging them", () => { const originalProperties: Element = { type: "element", @@ -1071,7 +1146,7 @@ describe("replacer", () => { replaceWith({ elements: [paragraph] }, [new TextRun({ text: "X", bold: true })]); - expect(namesOf(paragraph.elements![1].elements![0].elements)).to.deep.equal(["w:i", "w:b", "w:bCs", "w:rPrChange"]); + expect(namesOf(paragraph.elements![1].elements![0].elements)).to.deep.equal(["w:b", "w:bCs", "w:i", "w:rPrChange"]); }); it("should keep a run's own properties when the placeholder's w:rPr is empty", () => { diff --git a/src/patcher/replacer.ts b/src/patcher/replacer.ts index e827a90106..e0344f509d 100644 --- a/src/patcher/replacer.ts +++ b/src/patcher/replacer.ts @@ -117,7 +117,10 @@ export const replacer = ({ }; const formatChildren = (patch: IPatch, context: IContext): readonly Element[] => - patch.children.map((c) => toJson(xml(formatter.format(c as XmlComponent, context)))).map((c) => c.elements![0]); + patch.children + .flatMap((c) => (c as XmlComponent).writtenAs ?? (c as XmlComponent)) + .map((c) => toJson(xml(formatter.format(c, context)))) + .map((c) => c.elements![0]); /** * Replaces the first occurrence of the placeholder from `fromIndex` on, splitting the run it starts in. @@ -183,13 +186,79 @@ const withRunProperties = (runElement: Element, originalRunProperties: Element): ]; const mergedRunProperties = { ...ownRunProperties, - // w:rPrChange has to come after every other property - elements: [...properties.filter((e) => e.name !== "w:rPrChange"), ...properties.filter((e) => e.name === "w:rPrChange")], + elements: [...properties].sort((a, b) => runPropertyRank(a) - runPropertyRank(b)), }; return { ...runElement, elements: childElementsOf(runElement).map((e) => (e === ownRunProperties ? mergedRunProperties : e)) }; }; +/** + * The order Office's schema puts a run's properties in: CT_RPr's elements, then Word 2010's text effects and + * OpenType features. ISO 29500 allows any order, but Office and the Open XML SDK validator don't. + */ +const RUN_PROPERTY_ORDER = [ + "w:rStyle", + "w:rFonts", + "w:b", + "w:bCs", + "w:i", + "w:iCs", + "w:caps", + "w:smallCaps", + "w:strike", + "w:dstrike", + "w:outline", + "w:shadow", + "w:emboss", + "w:imprint", + "w:noProof", + "w:snapToGrid", + "w:vanish", + "w:webHidden", + "w:color", + "w:spacing", + "w:w", + "w:kern", + "w:position", + "w:sz", + "w:szCs", + "w:highlight", + "w:u", + "w:effect", + "w:bdr", + "w:shd", + "w:fitText", + "w:vertAlign", + "w:rtl", + "w:cs", + "w:em", + "w:lang", + "w:eastAsianLayout", + "w:specVanish", + "w:oMath", + "w14:glow", + "w14:shadow", + "w14:reflection", + "w14:textOutline", + "w14:textFill", + "w14:scene3d", + "w14:props3d", + "w14:ligatures", + "w14:numForm", + "w14:numSpacing", + "w14:stylisticSets", + "w14:cntxtAlts", +]; + +// A property that isn't listed keeps its place after the listed ones. w:rPrChange has to come after every other property +const runPropertyRank = (element: Element): number => { + if (element.name === "w:rPrChange") { + return RUN_PROPERTY_ORDER.length + 1; + } + const index = RUN_PROPERTY_ORDER.indexOf(element.name ?? ""); + return index === -1 ? RUN_PROPERTY_ORDER.length : index; +}; + const childElementsOf = (element: Element): readonly Element[] => element.elements ?? []; const isInsideElementAtPath = (path: readonly number[], ancestorPath: readonly number[]): boolean => diff --git a/src/shapes/preset-shape/shape-line.spec.ts b/src/shapes/preset-shape/shape-line.spec.ts index f1038de690..b1b9fc1965 100644 --- a/src/shapes/preset-shape/shape-line.spec.ts +++ b/src/shapes/preset-shape/shape-line.spec.ts @@ -102,6 +102,21 @@ describe("createShapeLine", () => { }); }); + it("should write a custom dash or gap of 0 as the smallest length Office accepts", () => { + const tree = new Formatter().format( + createShapeLine({ + cap: "round", + dash: [ + { length: 0, gap: 2 }, + { length: 3, gap: 0 }, + ], + }), + ); + expect(tree["a:ln"][2]).to.deep.equal({ + "a:custDash": [{ "a:ds": { _attr: { d: 1, sp: 200000 } } }, { "a:ds": { _attr: { d: 300000, sp: 1 } } }], + }); + }); + it("should reject a custom dash without dashes, or with negative lengths", () => { expect(() => createShapeLine({ dash: [] })).to.throw("Invalid custom line dash. Expected at least 1 dash"); expect(() => createShapeLine({ dash: [{ length: -1, gap: 1 }] })).to.throw("Invalid custom line dash { length: -1, gap: 1 }"); diff --git a/src/shapes/preset-shape/shape-line.ts b/src/shapes/preset-shape/shape-line.ts index a3e953080c..862ed09cf8 100644 --- a/src/shapes/preset-shape/shape-line.ts +++ b/src/shapes/preset-shape/shape-line.ts @@ -208,9 +208,10 @@ const createDash = (dash: LineDash | CustomLineDash): XmlComponent => { return new BuilderElement<{ readonly length: number; readonly gap: number }>({ name: "a:ds", attributes: { - // Thousandths of a percent of the line width - length: { key: "d", value: Math.round(length * 100000) }, - gap: { key: "sp", value: Math.round(gap * 100000) }, + // Thousandths of a percent of the line width. Office wants at least 1, so a dash or gap of 0, such as a + // dash that its round caps draw as a dot, is written as 1 + length: { key: "d", value: Math.max(1, Math.round(length * 100000)) }, + gap: { key: "sp", value: Math.max(1, Math.round(gap * 100000)) }, }, }); }), diff --git a/src/shapes/shape-text-styles.ts b/src/shapes/shape-text-styles.ts index 1d68fe1828..d301e30505 100644 --- a/src/shapes/shape-text-styles.ts +++ b/src/shapes/shape-text-styles.ts @@ -217,7 +217,7 @@ const readThemeFonts = (xml: XmlObject): ThemeFonts => { */ export const readTextStyles = (xml: XmlObject, themeFonts: ThemeFonts = OFFICE_THEME_FONTS): TextStyles => { const root = childrenOf(xml["w:styles"]); - // A document given styles of its own can have two sets of defaults: the library's, then the document's + // Styles writes one set of defaults: the library's, or those of the styles a document is given const defaults = root.filter((child) => "w:docDefaults" in child).map((child) => childrenOf(child["w:docDefaults"])); const styles = root .filter((child) => "w:style" in child)