Repository navigation
chore(release): version packages - #18
Merged
Merged
Conversation
github-actions
Bot
force-pushed
the
changeset-release/main
branch
from
July 4, 2026 15:07
22a8291 to
2120e44
Compare
github-actions
Bot
force-pushed
the
changeset-release/main
branch
8 times, most recently
from
October 6, 2026 02:24
d85b009 to
ead9c29
Compare
github-actions
Bot
force-pushed
the
changeset-release/main
branch
from
October 6, 2026 02:45
ead9c29 to
21bcfb1
Compare
6 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR was opened by the Changesets release GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated.
Releases
@office-kit/docx@0.2.0
Minor Changes
48ed589:
contentControlBlocks(block)reads the paragraphs and tables inside a block-level content control (<w:sdt>), the wrapper Word puts around cover pages, watermarks and tables of contents. The editor canvas uses it to show that content (read-only) instead of a "preserved content" placeholder, so watermarks and cover pages now appear on the page.48ed589:
addTableOfContents,appendMergeFieldandaddBookmarkare deprecated in favour ofinsertTableOfContents,insertMergeFieldandinsertBookmark, which do the same and more (any position, computed TOC entries, bookmarks over part of a paragraph). The deprecated functions keep working until the next major release.49e6e8a:
setParagraphIndentandsetParagraphSpacingtake East Asian units, as Japanese and Chinese Word write them:leftChars,rightChars,firstLineCharsandhangingChars("2 字" is200).beforeLinesandafterLines("0.5 行" is50).48ed589: Headers, footers and notes can now be read and edited as stories of their own.
@office-kit/docx:storyBody/storyViewgive typed access to the body of a header, footer, footnote, endnote or comment. Edits to it are saved with the document.sectionProperties,resolveHeaderFooter,ensureHeaderFooter,isHeaderFooterLinkedandsetHeaderFooterLinkedresolve a section's first, even or default header or footer, including what it inherits from the previous section, and support "Link to Previous".@office-kit/docx-editor:DocPositionmay carry astory, so selection, typing and formatting commands work inside headers, footers and notes.stories.*commands:paginate,documentSections,createFlagResolver,formatNumber) breaks a document into pages. It handles:48ed589: Add Word's Design and Layout features.
@office-kit/docx: section layout (getSectionProperties,setSectionPropertiesandinsertSectionBreakfor columns, line numbering, page borders, the document grid, vertical alignment, text direction and section start), with ascopeforsetPageSize,setPageMarginsandsetPageOrientation. Also themes (setTheme,setThemeColors,setThemeFonts,setThemeEffects,getTheme, plus the built-in Office themes and schemes), style sets (applyStyleSet,currentStyleSet), default paragraph spacing, page colour including gradient fills (setPageColor), and text or picture watermarks (setWatermark,getWatermark). Document settings are now written in schema order.@office-kit/docx-editor:design.*andlayout.*commands for the Design and Layout ribbon tabs and the Page Setup, Columns, Line Numbers, Hyphenation, Text Direction and Page Borders dialogs. Section commands take atargetof the whole document, the caret section or "this point forward". Also adds theresolveSectionLayout,resolvePageBackground,resolveThemeandthemePalettehelpers.48ed589: Word's Home tab formatting.
@office-kit/docxadds character and paragraph formatting helpers:setRunColor) and every underline style with an underline colour (setRunUnderline).setRunFont), character shading and borders (setRunShading,setRunBorder).setParagraphBorder) and tab stops (setParagraphTabs/getParagraphTabs).buildRubyRun/readRuby) and enclosed characters (buildEnclosedCharacterRuns).addListDefinition,restartList).builtinStyles,ensureBuiltinStyle) and style editing (updateStyleFormatting).@office-kit/docx-editoradds Home tab commands:48ed589: feat: Word's Insert tab — fields, links, symbols, equations, pages and page numbers
@office-kit/docxcan now place what Word's Insert tab places at a character offset of a paragraph:insertField,buildComplexField) with computed results. DATE/TIME (\@pictures with localized month and day names vialang), document properties, statistics,=formulas, IF/COMPARE, SEQ, REF/PAGEREF/NOTEREF, USERNAME and more.updateFieldsrecomputes them,complexFieldslists them, andinsertFormFieldwrites legacy form fields.insertHyperlink,editHyperlink,removeHyperlink,paragraphHyperlinks).insertBookmark) and Word's hidden_Refbookmarks for cross-references (ensureReferenceBookmark).w:symand the special hyphens (insertSymbol).insertEquation,buildEquation,equationLinear,setEquation).setDropCap/getDropCap) and VML signature lines (insertSignatureLine).pgNumType), and merging another document's body with its styles, lists and relationships (insertDocumentContent).@office-kit/docx-editoradds commands for all of these, plus:48ed589: Pictures, charts and object arrangement.
@office-kit/docxadds a picture API (src/api/picture.ts):readDrawingreads a<w:drawing>: wrap, anchor position, crop, shape, border, effects, color adjustments and image.setDrawingWrap,setDrawingPosition,setDrawingAnchorOptions,arrangeDrawing(Bring Forward / Send Backward and their variants),setDrawingTransform,setDrawingName,setDrawingHidden,setDrawingAspectLock,setDrawingHyperlinkandremoveDrawing.setPictureCrop,setPictureGeometry,setPictureOutline,setPictureEffects,setPictureColorAdjustments,changePictureandresetPicture.addChartRun,readChartandsetChartwrite a real chart part with an embedded workbook.imagePixelSizeandimageNaturalSizeEmuread image dimensions.Everything is written as ECMA-376 markup, with no Office extension namespaces.
Fixed:
setImageSizeEmuno longer writes into ana:extthat sits inside an extension list.@office-kit/docx-editoradds:layoutFloatingObjectsandfloatFrameStartfor placing floating objects in the browser.drawing.layoutfor the Layout Options dialog andchart.insert/chart.edit.48ed589: feat: Word's References and Mailings features, with field results computed so a saved document reads correctly before Word updates it.
@office-kit/docx):insertTableOfContents,removeTableOfContents,setTocLevel, andupdateTables. Page numbers come from an optional page provider.insertNote,noteMarks(numbering perw:footnotePr/w:endnotePr),setNoteProperties,noteText/setNoteText, andconvertNotes.setBibliographySources,setBibliographyStyle,insertCitationandinsertBibliography. APA and MLA are fully supported; Chicago, IEEE and the numeric styles are approximated.insertCaptionwrites SEQ fields with chapter numbers.addCaptionLabeladds a caption label.markIndexEntry,markAllIndexEntriesandinsertIndex.markAuthorityCitationandinsertTableOfAuthorities.@office-kit/docx):addEnvelopeandcreateLabelDocument.setMailMergeDocumentType, plus CSV recipient lists viaparseRecipientCsvandattachRecipientList. Match Fields and recipient inclusion are stored inw:odso.insertMergeField,insertAddressBlock,insertGreetingLine, andinsertMergeRule, which covers ASK, FILLIN, IF, MERGEREC, MERGESEQ, NEXT, NEXTIF, SET and SKIPIF.previewMailMergeandmergeToNewDocument, which puts one section per record.@office-kit/docx-editor): References and Mailings commands for all of the above, plusfindNoteReferenceandselectedTextqueries for the ribbon UI.48ed589: Review and View features.
@office-kit/docx:revisions,acceptRevisions/rejectRevisionsby id, and recording edits as tracked (insertTrackedText,deleteTrackedText,trackParagraphMark,trackRunFormatChange,trackParagraphFormatChange). Runs inside<w:ins>/<w:del>now parse as runs that carryrevision, so they are editable and save back as the same wrappers.compareDocuments: diffs two documents into a new document of tracked changes.comments,setCommentTextandremoveComment.addCommentaccepts arange.getRunLanguage/setRunLanguage, plus a Word-compatiblewordCount.checkAccessibilityandcontrastRatio.protectDocument/unprotectDocumentwith ECMA-376 SHA-512 password hashes,writeProtection(Always Open Read-Only, password to modify), and editable exceptions.documentView/documentZoom, custom properties (customProperties,setCustomProperty,removeCustomProperty) and thehyperlinkBaseapp property.setDocumentSettingOnOff/Valnow follow the schema order ofCT_Settings.@office-kit/docx-editor:protectionRefusal/isEditingLocked, so a UI can honour Restrict Editing.48ed589: Shapes, text boxes, WordArt, ink and SmartArt.
@office-kit/docx: build and edit VML shapes (addShapewith about 120 Word presets,addWordArt, ink strokes,addDrawingCanvas, groups), with fill (solid, gradient, pattern, picture), outline, shadow, layout, wrapping, z-order, alt text, linked text boxes and vertical text. Insert and edit SmartArt graphics (addSmartArt,setSmartArtNodes, layouts, colours, styles, size,removeSmartArt) as ECMA-376 DrawingML diagram parts. Existing VML from Word documents is read, including shape types.@office-kit/docx-editor: renders VML shapes, text boxes, WordArt, ink and SmartArt on the canvas (renderPictHtmlis exported for watermarks), with commands for every Shape Format, SmartArt Design and Draw tab action, editable text boxes, and Ink to Shape recognition (recognizeInkShape).48ed589: Tables, the way Word edits them.
@office-kit/docxgains Word's table operations: insert and delete rows and columns at any position, delete cells (shifting left or up), merge and split cells, split a table, set table / cell widths, alignment, indent, layout, cell spacing, default and per-cell margins, text direction, floating position and alt text, distribute and AutoFit columns, apply borders to any cell range (including diagonals), sort rows, convert text to a table and back with a chosen separator (unwrapTablenow takes{ separator }), and evaluate table formulas (=SUM(ABOVE)…). It also ships Word's 105 built-in table styles (Table Grid, Plain / Grid / List Tables in every accent), colored from the document's theme, with Table Style Options (w:tblLook) and per-region style formatting. Table property setters now write their children in schema order.@office-kit/docx-editoradds commands for every Table Design and Table Layout action, renders tables with their style's conditional formatting (header / total rows, first / last columns, banding with the style's band sizes, corner cells), merged cells, row heights, cell margins, vertical alignment, text direction, diagonal borders, cell spacing and nested tables, and exposes the cell-range selection, Tab navigation, gallery previews and a Table Properties snapshot.48ed589: fix: highlight is written only as a valid
ST_HighlightColorname<w:highlight w:val>accepts only 16 named colors andnone(ECMA-376§17.18.40). Before this fix,
setRunFormat,appendTextRun,setParagraphTextand
setTableCellTextwrote any string there (e.g.FFFF00), producing a filethat does not conform to the schema. They now throw a
RangeError, withoutchanging the document, for any other value. The new
HIGHLIGHT_COLORSexport(with the
HighlightColortype) lists the accepted values.getRunFormatstillreturns whatever a file holds.
In the editor,
setHighlightCommandtakes{ color: HighlightColor }instead ofa hex string and rejects anything else before changing the document. The site
ribbon's highlight control is now a named list instead of a color picker.
48ed589: fix: run color and font size are written only as schema-valid values
setRunFormat,appendTextRun,setParagraphTextandsetTableCellTextusedto write any
colorstring and anyfontSizeHalfPointsnumber into<w:color w:val>/<w:sz w:val>. Values like"red","#FF0000",-1,23.5orNaNproduced files that do not conform to the schema. These writersnow throw a
RangeError, before changing anything, unless:coloris six hex digits without#(either case) or"auto"(ST_HexColor);fontSizeHalfPointsis a non-negative safe integer (ST_HpsMeasure).0staysvalid; there is no application-specific upper bound.
Untyped JavaScript callers get the same check on the runtime type: a
colorthat is not a string (e.g. the number
123456,null) or a size that is not anumber (e.g.
"24") is rejected rather than stringified.One case that used to pass silently now throws:
appendTextRun(p, text, { color: "" })ignored the empty color, and now rejects it like
setRunFormatdoes.getRunFormatstill returns whatever a file holds, and untouched values aresaved unchanged.
In the editor,
setColorCommand(a leading#is still dropped) andsetFontSizeCommand(points, rounded to half-points) reject invalid valuesbefore the document changes, with undo and redo history kept.
The editor canvas also no longer lets a crafted file break out of a run's
styleattribute: the attribute is HTML-escaped, only six-digit hex colorsbecome CSS, and quotes, backslashes and line breaks are dropped from font names
when rendering. The document itself is not changed.
48ed589:
wrappedRuns(inline)reads the runs inside a hyperlink, simple field, inline content control, smart tag, custom XML or bidi override. The editor canvas uses it so link text shows its own formatting, as Word does: the Hyperlink style for an ordinary link, and plain text for a table of contents entry, instead of always blue and underlined.Patch Changes
48ed589: feat: add
@office-kit/docx-editor— an MS Office-like WYSIWYG editing coreNew package that turns
@office-kit/docxinto a Word-like editor: anEditorModelwith undo/redo, a command layer (text/paragraph/structure/list/table/image/style/section/header-footer/references/review) where every mutation
routes through the
@office-kit/docxpublic API, an AST→HTML canvas renderer,and DOM-selection mapping. A SvelteKit ribbon UI ships at the site's
/editorroute.
The editing surface is interactive: Enter splits the paragraph at the caret and
Backspace/Delete merge across paragraph boundaries (
splitParagraphCommand/mergeBackCommand, backed by the library'ssplitParagraphAt/mergeParagraphIntoPrevious); the caret is preserved across structuralre-renders; Ctrl+Z/Y drive undo/redo; paste inserts plain text (multi-line →
paragraphs) keeping the AST in sync; and the UI adds live word/character count,
find & replace, zoom, caret-synced font/size/style, and heading-styled rendering
so the document reads with real visual hierarchy.
Character formatting is now selection-precise: bolding (or any run format on) a
partial selection splits runs at the selection boundaries and formats only the
selected characters instead of the whole line — backed by the library's
isolateParagraphRunRange/runTextLength. The ribbon UI is localized intosix languages (English, 日本語, Español, Français, Deutsch, 中文) with a
language switcher.
Completeness against the WordprocessingML spec is enforced by a capability
ledger: every element in the ECMA-376 schema universe is classified as
edit/render/preserve, and a test fails the build if any element isunclassified or an editable element's command goes missing.
The library gains generic property setters so the editor can reach the long
tail of WordprocessingML formatting without a bespoke function per element:
setRunOnOff/setRunValProp/getRunPropand thesetParagraphOnOff/setParagraphValProp/getParagraphPropequivalents;setElementOnOff/setElementValProp/getElementProp/makePropsElement(for<w:tcPr>/<w:trPr>/<w:tblPr>/<w:sectPr>);setDocumentSettingOnOff/setDocumentSettingVal/getDocumentSetting(createsword/settings.xmlon demand);setStyleOnOff/setStyleValProp/getStyleProp;setNumberingLevelVal/setNumberingLevelOnOff/getNumberingLevelProp;imageDrawings/setImageSizeEmu/setImageAltText/getImageInfo(resize and alt-text existing pictures);setElementAttr/getElementAttr/childElementsOf/appendChildElement— the universal escape hatch that lets the editor editany element (DrawingML shape geometry, OMML math, legacy VML) by attribute or
child, since these live inline in
document.xmland flush through thedocument AST on save;
xmlPartNames/getRawPartRoot/markRawPartDirty—open, edit, and re-serialize any XML part (fontTable, settings, styles,
numbering, comments, foot-/endnotes, headers, footers, webSettings, docProps),
so every OOXML element in the whole package is reachable and editable;
splitParagraphAt/mergeParagraphIntoPrevious—split a paragraph at a run/offset and merge a paragraph into the previous one
(the primitives behind Enter and Backspace-at-start);
isolateParagraphRunRange/runTextLength— isolate acharacter range into its own run(s) so formatting applies to exactly the
selected text.
Also newly exported from
@office-kit/docx(they are part of the publicsurface as parameter/return/AST types):
BuildStyleOptions,BuildTableOptions,DocumentCoreProperties,DocumentAppProperties, and the raw XML AST typesXmlElement/XmlNode/XmlAttr/QName.Commands are atomic:
runCommandreturns the command's result, and a commandthat throws (including rejected input such as an out-of-range table size or a
non-http(s)/mailto hyperlink) leaves the document, selection and redo history
unchanged (
EditorModel.abortEdit).replaceAllCommand,insertTextCommandanddeleteSelectionCommandroute Find & Replace, paste, and typing or deletingover a selection (also across paragraphs) through the same undoable path.
Consecutive keystrokes undo as one step, Shift+Enter breaks the line at the
caret, and hyperlinks and field results are visible on the canvas. Enter,
Backspace and Delete inside a table cell split and join that cell's
paragraphs. IME input that starts over a selection replaces it in one undo
step.
splitParagraphAtmoves a paragraph'ssection break to the second half instead of duplicating it.
48ed589: fix: saving a document dropped the attributes of
<w:body>,<w:p>,<w:r>,<w:tbl>,<w:tr>and<w:tc>, includingw14:paraId,w14:textIdandw:rsid*. They are now kept on save. The parsed nodes carry them as anoptional
attrsfield.48ed589: fix: find / replace reach table cells, unit font sizes read correctly, and range state sees middle runs
findTextandreplaceText(and the body part offindTextEverywhere/replaceTextEverywhere) skipped every paragraph inside a table cell, despitepromising "every paragraph" / "every occurrence". They now include cell
paragraphs, in document order, so counts and replacements cover tables. A
table nested inside a cell is still kept as raw XML and not searched.
getRunFormatread<w:sz w:val="12pt">as 12 half-points (6 pt) because itignored the unit. Universal measures (
pt,pc,pi,in,cm,mm) arenow converted exactly, so
"12pt"reads as 24. A value that is not a wholenumber of half-points (
"3mm") or is invalid ("-4","12px") leavesfontSizeHalfPointsunset instead of being guessed; the XML keeps the valueas written.
runsInRangereturned every run of the paragraphs at bothends of a range, not just the runs the range touches as documented. It now
returns exactly the covered runs (a collapsed caret still returns its
paragraph's runs). The site ribbon uses it, so a differently formatted run in
the middle of a selection shows the field as "Mixed", and choosing a value
applies it to the whole range.
48ed589: Fix two problems that showed up when the file was opened in Word:
addWordArtnow writes the text-path shape type (_x0000_t136) that the shape refers to. Without it, Word drew a broken-picture placeholder.w:pgMar, tables of contents, indexes and other generated content now place their right tab at Word's default margins (1 in each side). Before, the tab sat at the page edge.@office-kit/docx-editor@0.1.0
Minor Changes
48ed589: feat: add
@office-kit/docx-editor— an MS Office-like WYSIWYG editing coreNew package that turns
@office-kit/docxinto a Word-like editor: anEditorModelwith undo/redo, a command layer (text/paragraph/structure/list/table/image/style/section/header-footer/references/review) where every mutation
routes through the
@office-kit/docxpublic API, an AST→HTML canvas renderer,and DOM-selection mapping. A SvelteKit ribbon UI ships at the site's
/editorroute.
The editing surface is interactive: Enter splits the paragraph at the caret and
Backspace/Delete merge across paragraph boundaries (
splitParagraphCommand/mergeBackCommand, backed by the library'ssplitParagraphAt/mergeParagraphIntoPrevious); the caret is preserved across structuralre-renders; Ctrl+Z/Y drive undo/redo; paste inserts plain text (multi-line →
paragraphs) keeping the AST in sync; and the UI adds live word/character count,
find & replace, zoom, caret-synced font/size/style, and heading-styled rendering
so the document reads with real visual hierarchy.
Character formatting is now selection-precise: bolding (or any run format on) a
partial selection splits runs at the selection boundaries and formats only the
selected characters instead of the whole line — backed by the library's
isolateParagraphRunRange/runTextLength. The ribbon UI is localized intosix languages (English, 日本語, Español, Français, Deutsch, 中文) with a
language switcher.
Completeness against the WordprocessingML spec is enforced by a capability
ledger: every element in the ECMA-376 schema universe is classified as
edit/render/preserve, and a test fails the build if any element isunclassified or an editable element's command goes missing.
The library gains generic property setters so the editor can reach the long
tail of WordprocessingML formatting without a bespoke function per element:
setRunOnOff/setRunValProp/getRunPropand thesetParagraphOnOff/setParagraphValProp/getParagraphPropequivalents;setElementOnOff/setElementValProp/getElementProp/makePropsElement(for<w:tcPr>/<w:trPr>/<w:tblPr>/<w:sectPr>);setDocumentSettingOnOff/setDocumentSettingVal/getDocumentSetting(createsword/settings.xmlon demand);setStyleOnOff/setStyleValProp/getStyleProp;setNumberingLevelVal/setNumberingLevelOnOff/getNumberingLevelProp;imageDrawings/setImageSizeEmu/setImageAltText/getImageInfo(resize and alt-text existing pictures);setElementAttr/getElementAttr/childElementsOf/appendChildElement— the universal escape hatch that lets the editor editany element (DrawingML shape geometry, OMML math, legacy VML) by attribute or
child, since these live inline in
document.xmland flush through thedocument AST on save;
xmlPartNames/getRawPartRoot/markRawPartDirty—open, edit, and re-serialize any XML part (fontTable, settings, styles,
numbering, comments, foot-/endnotes, headers, footers, webSettings, docProps),
so every OOXML element in the whole package is reachable and editable;
splitParagraphAt/mergeParagraphIntoPrevious—split a paragraph at a run/offset and merge a paragraph into the previous one
(the primitives behind Enter and Backspace-at-start);
isolateParagraphRunRange/runTextLength— isolate acharacter range into its own run(s) so formatting applies to exactly the
selected text.
Also newly exported from
@office-kit/docx(they are part of the publicsurface as parameter/return/AST types):
BuildStyleOptions,BuildTableOptions,DocumentCoreProperties,DocumentAppProperties, and the raw XML AST typesXmlElement/XmlNode/XmlAttr/QName.Commands are atomic:
runCommandreturns the command's result, and a commandthat throws (including rejected input such as an out-of-range table size or a
non-http(s)/mailto hyperlink) leaves the document, selection and redo history
unchanged (
EditorModel.abortEdit).replaceAllCommand,insertTextCommandanddeleteSelectionCommandroute Find & Replace, paste, and typing or deletingover a selection (also across paragraphs) through the same undoable path.
Consecutive keystrokes undo as one step, Shift+Enter breaks the line at the
caret, and hyperlinks and field results are visible on the canvas. Enter,
Backspace and Delete inside a table cell split and join that cell's
paragraphs. IME input that starts over a selection replaces it in one undo
step.
splitParagraphAtmoves a paragraph'ssection break to the second half instead of duplicating it.
48ed589: feat: the editor reports and writes formatting the way Microsoft Word does
createStyleResolver(doc)returns a paragraph's and a run's effectiveformatting: document defaults, the paragraph style's
basedOnchain, thecharacter style and direct formatting, with theme fonts looked up. The canvas
renders these values, so headings take their look from
styles.xml.Also new:
pageGeometry(doc),highlightCss(value),RunRef.read the effective value. Turning off formatting that comes from a style
writes an explicit off value (
<w:b w:val="0"/>,<w:u w:val="none"/>),as Word does.
clearFormattingCommandnow matches Word's Clear All Formatting: a caretresets its paragraph to Normal; a range clears every character property
except the highlight and resets the paragraphs whose mark it includes.
Previously it wrote explicit
falsevalues and left color, size and font.indentStepCommand(Increase / Decrease Indent in 0.5 in steps),setLineSpacingCommandwithlineSpacingOf, andsetVertAlignCommand(Subscript / Superscript).
indents and spacing, and draws tables with their own width, columns, cell
margins and borders (none when the document defines none).
48ed589: Headers, footers and notes can now be read and edited as stories of their own.
@office-kit/docx:storyBody/storyViewgive typed access to the body of a header, footer, footnote, endnote or comment. Edits to it are saved with the document.sectionProperties,resolveHeaderFooter,ensureHeaderFooter,isHeaderFooterLinkedandsetHeaderFooterLinkedresolve a section's first, even or default header or footer, including what it inherits from the previous section, and support "Link to Previous".@office-kit/docx-editor:DocPositionmay carry astory, so selection, typing and formatting commands work inside headers, footers and notes.stories.*commands:paginate,documentSections,createFlagResolver,formatNumber) breaks a document into pages. It handles:48ed589: Add Word's Design and Layout features.
@office-kit/docx: section layout (getSectionProperties,setSectionPropertiesandinsertSectionBreakfor columns, line numbering, page borders, the document grid, vertical alignment, text direction and section start), with ascopeforsetPageSize,setPageMarginsandsetPageOrientation. Also themes (setTheme,setThemeColors,setThemeFonts,setThemeEffects,getTheme, plus the built-in Office themes and schemes), style sets (applyStyleSet,currentStyleSet), default paragraph spacing, page colour including gradient fills (setPageColor), and text or picture watermarks (setWatermark,getWatermark). Document settings are now written in schema order.@office-kit/docx-editor:design.*andlayout.*commands for the Design and Layout ribbon tabs and the Page Setup, Columns, Line Numbers, Hyphenation, Text Direction and Page Borders dialogs. Section commands take atargetof the whole document, the caret section or "this point forward". Also adds theresolveSectionLayout,resolvePageBackground,resolveThemeandthemePalettehelpers.48ed589: Word's Home tab formatting.
@office-kit/docxadds character and paragraph formatting helpers:setRunColor) and every underline style with an underline colour (setRunUnderline).setRunFont), character shading and borders (setRunShading,setRunBorder).setParagraphBorder) and tab stops (setParagraphTabs/getParagraphTabs).buildRubyRun/readRuby) and enclosed characters (buildEnclosedCharacterRuns).addListDefinition,restartList).builtinStyles,ensureBuiltinStyle) and style editing (updateStyleFormatting).@office-kit/docx-editoradds Home tab commands:48ed589: feat: Word's Insert tab — fields, links, symbols, equations, pages and page numbers
@office-kit/docxcan now place what Word's Insert tab places at a character offset of a paragraph:insertField,buildComplexField) with computed results. DATE/TIME (\@pictures with localized month and day names vialang), document properties, statistics,=formulas, IF/COMPARE, SEQ, REF/PAGEREF/NOTEREF, USERNAME and more.updateFieldsrecomputes them,complexFieldslists them, andinsertFormFieldwrites legacy form fields.insertHyperlink,editHyperlink,removeHyperlink,paragraphHyperlinks).insertBookmark) and Word's hidden_Refbookmarks for cross-references (ensureReferenceBookmark).w:symand the special hyphens (insertSymbol).insertEquation,buildEquation,equationLinear,setEquation).setDropCap/getDropCap) and VML signature lines (insertSignatureLine).pgNumType), and merging another document's body with its styles, lists and relationships (insertDocumentContent).@office-kit/docx-editoradds commands for all of these, plus:48ed589: Pictures, charts and object arrangement.
@office-kit/docxadds a picture API (src/api/picture.ts):readDrawingreads a<w:drawing>: wrap, anchor position, crop, shape, border, effects, color adjustments and image.setDrawingWrap,setDrawingPosition,setDrawingAnchorOptions,arrangeDrawing(Bring Forward / Send Backward and their variants),setDrawingTransform,setDrawingName,setDrawingHidden,setDrawingAspectLock,setDrawingHyperlinkandremoveDrawing.setPictureCrop,setPictureGeometry,setPictureOutline,setPictureEffects,setPictureColorAdjustments,changePictureandresetPicture.addChartRun,readChartandsetChartwrite a real chart part with an embedded workbook.imagePixelSizeandimageNaturalSizeEmuread image dimensions.Everything is written as ECMA-376 markup, with no Office extension namespaces.
Fixed:
setImageSizeEmuno longer writes into ana:extthat sits inside an extension list.@office-kit/docx-editoradds:layoutFloatingObjectsandfloatFrameStartfor placing floating objects in the browser.drawing.layoutfor the Layout Options dialog andchart.insert/chart.edit.48ed589: feat: Word's References and Mailings features, with field results computed so a saved document reads correctly before Word updates it.
@office-kit/docx):insertTableOfContents,removeTableOfContents,setTocLevel, andupdateTables. Page numbers come from an optional page provider.insertNote,noteMarks(numbering perw:footnotePr/w:endnotePr),setNoteProperties,noteText/setNoteText, andconvertNotes.setBibliographySources,setBibliographyStyle,insertCitationandinsertBibliography. APA and MLA are fully supported; Chicago, IEEE and the numeric styles are approximated.insertCaptionwrites SEQ fields with chapter numbers.addCaptionLabeladds a caption label.markIndexEntry,markAllIndexEntriesandinsertIndex.markAuthorityCitationandinsertTableOfAuthorities.@office-kit/docx):addEnvelopeandcreateLabelDocument.setMailMergeDocumentType, plus CSV recipient lists viaparseRecipientCsvandattachRecipientList. Match Fields and recipient inclusion are stored inw:odso.insertMergeField,insertAddressBlock,insertGreetingLine, andinsertMergeRule, which covers ASK, FILLIN, IF, MERGEREC, MERGESEQ, NEXT, NEXTIF, SET and SKIPIF.previewMailMergeandmergeToNewDocument, which puts one section per record.@office-kit/docx-editor): References and Mailings commands for all of the above, plusfindNoteReferenceandselectedTextqueries for the ribbon UI.48ed589: Review and View features.
@office-kit/docx:revisions,acceptRevisions/rejectRevisionsby id, and recording edits as tracked (insertTrackedText,deleteTrackedText,trackParagraphMark,trackRunFormatChange,trackParagraphFormatChange). Runs inside<w:ins>/<w:del>now parse as runs that carryrevision, so they are editable and save back as the same wrappers.compareDocuments: diffs two documents into a new document of tracked changes.comments,setCommentTextandremoveComment.addCommentaccepts arange.getRunLanguage/setRunLanguage, plus a Word-compatiblewordCount.checkAccessibilityandcontrastRatio.protectDocument/unprotectDocumentwith ECMA-376 SHA-512 password hashes,writeProtection(Always Open Read-Only, password to modify), and editable exceptions.documentView/documentZoom, custom properties (customProperties,setCustomProperty,removeCustomProperty) and thehyperlinkBaseapp property.setDocumentSettingOnOff/Valnow follow the schema order ofCT_Settings.@office-kit/docx-editor:protectionRefusal/isEditingLocked, so a UI can honour Restrict Editing.48ed589: Shapes, text boxes, WordArt, ink and SmartArt.
@office-kit/docx: build and edit VML shapes (addShapewith about 120 Word presets,addWordArt, ink strokes,addDrawingCanvas, groups), with fill (solid, gradient, pattern, picture), outline, shadow, layout, wrapping, z-order, alt text, linked text boxes and vertical text. Insert and edit SmartArt graphics (addSmartArt,setSmartArtNodes, layouts, colours, styles, size,removeSmartArt) as ECMA-376 DrawingML diagram parts. Existing VML from Word documents is read, including shape types.@office-kit/docx-editor: renders VML shapes, text boxes, WordArt, ink and SmartArt on the canvas (renderPictHtmlis exported for watermarks), with commands for every Shape Format, SmartArt Design and Draw tab action, editable text boxes, and Ink to Shape recognition (recognizeInkShape).48ed589: Tables, the way Word edits them.
@office-kit/docxgains Word's table operations: insert and delete rows and columns at any position, delete cells (shifting left or up), merge and split cells, split a table, set table / cell widths, alignment, indent, layout, cell spacing, default and per-cell margins, text direction, floating position and alt text, distribute and AutoFit columns, apply borders to any cell range (including diagonals), sort rows, convert text to a table and back with a chosen separator (unwrapTablenow takes{ separator }), and evaluate table formulas (=SUM(ABOVE)…). It also ships Word's 105 built-in table styles (Table Grid, Plain / Grid / List Tables in every accent), colored from the document's theme, with Table Style Options (w:tblLook) and per-region style formatting. Table property setters now write their children in schema order.@office-kit/docx-editoradds commands for every Table Design and Table Layout action, renders tables with their style's conditional formatting (header / total rows, first / last columns, banding with the style's band sizes, corner cells), merged cells, row heights, cell margins, vertical alignment, text direction, diagonal borders, cell spacing and nested tables, and exposes the cell-range selection, Tab navigation, gallery previews and a Table Properties snapshot.48ed589: fix: highlight is written only as a valid
ST_HighlightColorname<w:highlight w:val>accepts only 16 named colors andnone(ECMA-376§17.18.40). Before this fix,
setRunFormat,appendTextRun,setParagraphTextand
setTableCellTextwrote any string there (e.g.FFFF00), producing a filethat does not conform to the schema. They now throw a
RangeError, withoutchanging the document, for any other value. The new
HIGHLIGHT_COLORSexport(with the
HighlightColortype) lists the accepted values.getRunFormatstillreturns whatever a file holds.
In the editor,
setHighlightCommandtakes{ color: HighlightColor }instead ofa hex string and rejects anything else before changing the document. The site
ribbon's highlight control is now a named list instead of a color picker.
48ed589: fix: run color and font size are written only as schema-valid values
setRunFormat,appendTextRun,setParagraphTextandsetTableCellTextusedto write any
colorstring and anyfontSizeHalfPointsnumber into<w:color w:val>/<w:sz w:val>. Values like"red","#FF0000",-1,23.5orNaNproduced files that do not conform to the schema. These writersnow throw a
RangeError, before changing anything, unless:coloris six hex digits without#(either case) or"auto"(ST_HexColor);fontSizeHalfPointsis a non-negative safe integer (ST_HpsMeasure).0staysvalid; there is no application-specific upper bound.
Untyped JavaScript callers get the same check on the runtime type: a
colorthat is not a string (e.g. the number
123456,null) or a size that is not anumber (e.g.
"24") is rejected rather than stringified.One case that used to pass silently now throws:
appendTextRun(p, text, { color: "" })ignored the empty color, and now rejects it like
setRunFormatdoes.getRunFormatstill returns whatever a file holds, and untouched values aresaved unchanged.
In the editor,
setColorCommand(a leading#is still dropped) andsetFontSizeCommand(points, rounded to half-points) reject invalid valuesbefore the document changes, with undo and redo history kept.
The editor canvas also no longer lets a crafted file break out of a run's
styleattribute: the attribute is HTML-escaped, only six-digit hex colorsbecome CSS, and quotes, backslashes and line breaks are dropped from font names
when rendering. The document itself is not changed.
Patch Changes
48ed589:
contentControlBlocks(block)reads the paragraphs and tables inside a block-level content control (<w:sdt>), the wrapper Word puts around cover pages, watermarks and tables of contents. The editor canvas uses it to show that content (read-only) instead of a "preserved content" placeholder, so watermarks and cover pages now appear on the page.ecb138d: Editing fixes found by adversarial testing:
runPointplaces a caret after the placeholder of an empty run, so text typed there lands in that run.isEmptyParagraphexport.d1523b7:
setFontCommandnow treats East Asian fonts the way Word's font box does:Two new exports,
isEastAsianFontandhasEastAsianText, expose the checks this uses.49e6e8a: The canvas now lays out Japanese and Chinese documents the way Word does. Line heights and spacing were checked against Japanese Word for Mac 16:
textDirectiontbRlis laid out top to bottom, right to left, and pages break where Word breaks them.autoSpaceDE/autoSpaceDN).baf2d5c: The editor keeps a paragraph after a table that ends the document, as Word does. Before, there was no way to type below such a table. This affected documents that end with a table, and tables inserted at the end of a document.
4dd27ca: Formatted paste and pending formatting:
insertFragmentCommandandparseClipboardHtml: pasting HTML (from Word, a web page, Google Docs or the editor itself) keeps bold, italic, underline, strikethrough, superscript / subscript, text color, headings, bullet and numbered lists with their levels, line breaks, tabs and tables. As in Word, the first pasted paragraph continues the caret's paragraph and a pasted table goes between its halves; inside a table cell a pasted table becomes paragraphs.releasePendingFormat: formatting set at a caret (Bold with no selection, say) and left without typing is dropped once the caret moves on, as in Word, instead of leaving an empty run behind.49e6e8a:
layoutSpacingCommandtakes spacing in lines (beforeLines/afterLines, hundredths of a line), the unit Japanese Word's 段落前 / 段落後 boxes use. It also writes the equivalent twips at the section's grid pitch.spacingLineTwipsreturns that pitch.layoutIndentCommandandlayoutSpacingCommandkeep a paragraph's existing character and line units (leftChars,beforeLines…). Setting a value in twips clears the matching unit, so the new value shows. Before, a unit that was set kept overriding the new twips value.48ed589: Style resolution follows more of ECMA-376: toggle properties (bold, italic, caps …) toggle across the table, paragraph and character style levels (§17.7.3), list numbers take their level's run properties (§17.9.24), and complex-script text (Arabic, Hebrew, Thai …) uses its own bold, italic, size and font (
bCs,iCs,szCs,w:cs). The canvas lists the East Asian and complex-script fonts after the Latin one, so each script draws in its own font.48ed589: The canvas now lays out tabs against the paragraph's tab stops, as Word does:
clearstops remove inherited ones.Typing a tab now works too. Tab inserts a tab character, and at the start of a list item Tab and Shift+Tab change the item's level. A caret steps over a tab as a single character.
Drop caps (
w:framePr w:dropCap) float into the lines of the paragraph that follows them, instead of sitting on a line of their own.48ed589: fix: find / replace reach table cells, unit font sizes read correctly, and range state sees middle runs
findTextandreplaceText(and the body part offindTextEverywhere/replaceTextEverywhere) skipped every paragraph inside a table cell, despitepromising "every paragraph" / "every occurrence". They now include cell
paragraphs, in document order, so counts and replacements cover tables. A
table nested inside a cell is still kept as raw XML and not searched.
getRunFormatread<w:sz w:val="12pt">as 12 half-points (6 pt) because itignored the unit. Universal measures (
pt,pc,pi,in,cm,mm) arenow converted exactly, so
"12pt"reads as 24. A value that is not a wholenumber of half-points (
"3mm") or is invalid ("-4","12px") leavesfontSizeHalfPointsunset instead of being guessed; the XML keeps the valueas written.
runsInRangereturned every run of the paragraphs at bothends of a range, not just the runs the range touches as documented. It now
returns exactly the covered runs (a collapsed caret still returns its
paragraph's runs). The site ribbon uses it, so a differently formatted run in
the middle of a selection shows the field as "Mixed", and choosing a value
applies it to the whole range.
48ed589:
wrappedRuns(inline)reads the runs inside a hyperlink, simple field, inline content control, smart tag, custom XML or bidi override. The editor canvas uses it so link text shows its own formatting, as Word does: the Hyperlink style for an ordinary link, and plain text for a table of contents entry, instead of always blue and underlined.Updated dependencies [48ed589]
Updated dependencies [48ed589]
Updated dependencies [48ed589]
Updated dependencies [49e6e8a]
Updated dependencies [48ed589]
Updated dependencies [48ed589]
Updated dependencies [48ed589]
Updated dependencies [48ed589]
Updated dependencies [48ed589]
Updated dependencies [48ed589]
Updated dependencies [48ed589]
Updated dependencies [48ed589]
Updated dependencies [48ed589]
Updated dependencies [48ed589]
Updated dependencies [48ed589]
Updated dependencies [48ed589]
Updated dependencies [48ed589]
Updated dependencies [48ed589]
Updated dependencies [48ed589]
@office-kit/docx-preview@0.1.1
Patch Changes
word-kit-site@0.0.2
Patch Changes