Skip to content

v17.1.0

Latest

Choose a tag to compare

@JSv4 JSv4 released this 30 Nov 12:51
· 2 commits to main since this release
286c26e

Docxodus 17.1.0 adds Word's Update Field, cross-references, the document outline and tab stops to the editing API, and fixes how links written as fields, tables of contents and fields nested in field codes render in HTML and edit in the browser editor; see the full changelog.

Added

  • Word's Update Field (F9): UpdateFields builds tables of contents again from the headings (\o levels, \h hyperlinks; each entry a TOC n paragraph with the heading's number and text, a tab and a PAGEREF to a hidden _Toc bookmark on the heading), gives REF fields their bookmark's current text or number (\r, \n, \w, \t, \p), PAGEREF fields the page from UpdateFieldsOptions.Pages (keyed by anchor id or unid; the caller's pagination) and numbers SEQ fields again. A field it cannot work out exactly keeps its result (a locked field, a table of figures or authorities, a switch it does not know, a result holding tracked changes or comments), and w:updateFields is cleared from settings only when no field is left that needs Word. Range limits it to the fields that start in those paragraphs; without it every field in the body is updated. TablesOfContentsOnly is Word's Update Table. One undo step, none when nothing changes; refused while changes are tracked. The TOC Heading style it adds turns Heading 1's numbering off. On the .NET API, WASM, npm (updateFields), Python (update_fields), the stdio host (update_fields) and MCP (docxodus_edit action update_fields).
  • Cross-references as Word's Cross-reference dialog makes them, to a heading or numbered item as well as a bookmark. AddReferenceBookmark puts the hidden _Ref bookmark (nine digits) over a paragraph's text, not its list number, and reuses one that already spans it; the name comes back in EditResult.BookmarkName. CrossReferenceOptions gains PageNumber (a PAGEREF, the target's page, with CachedPage as its result, else 1 and the field dirty so Word updates it), NumberNoContext (\n) and NumberFullContext (\w). WmlToHtmlConverterSettings.StampReferenceFields wraps REF, PAGEREF and NOTEREF results in data-field spans naming their bookmark, for an editor to keep each reference whole (off by default; the referenceFields editor render option). The cached number is the one Word shows: without its trailing period, and in full context for \w (2.3.1(a)(i)). On the .NET API, WASM, npm (addReferenceBookmark, CrossReferenceOptions.pageNumber, numberNoContext, numberFullContext, cachedPage), Python (add_reference_bookmark, CrossReferenceOptions.page_number, number_no_context, number_full_context, cached_page), the stdio host (add_reference_bookmark) and MCP (docxodus_links action add_reference_bookmark and the new options fields of insert_cross_reference).
  • The document outline, as Word's Navigation Pane shows it. ListOutline lists the body's headings in order: each top-level paragraph with an outline level 1-9, resolved as Word resolves it (the paragraph's own w:outlineLvl, else its style chain's), so a localized heading style counts by its outline level, not its name; each entry gives the heading's anchor, level, text, style and lastAnchorId, the last block of its part (up to the next heading of its level or a higher one). MoveBlockRange moves a run of top-level blocks before or after another block as one edit, as the Navigation Pane drags a heading with its text: one undo step, refused across a section break, when it would cut a bookmark or comment range, onto a target inside the run, and under tracked changes. On the .NET API, WASM, npm (listOutline, moveBlockRange), Python (list_outline, move_block_range, with OutlineEntry), the stdio host and MCP (docxodus_get_content format outline, docxodus_edit action move_block_range).
  • DocxSession.GetTabStops, SetTabStops and SetDefaultTabStop. Read a paragraph's tab stops in effect (its style chain and its own, with cleared ones removed), the ones its styles give it, and the document's default tab interval; set the stops in effect the way Word does (its own w:tabs holds the stops its styles lack and clear entries for unwanted style stops; one undo step, one w:pPrChange when tracked); set w:defaultTabStop in settings (refused while changes are tracked: no revision records a settings change). On the .NET API, WASM, npm (setTabStops, getTabStops, setDefaultTabStop), Python (set_tab_stops, get_tab_stops, set_default_tab_stop, with TabStop and TabStopsInfo), the stdio host and MCP (docxodus_format actions set_tab_stops, get_tab_stops, set_default_tab_stop).

Fixed

  • Moving a block (MoveBlock, the editor's drag and move commands) no longer breaks a bookmark, comment or permission range with a marker directly in the body or in a content control, joins two tables, or puts a block inside a table of contents (#1861). Word ends a bookmark over a whole paragraph directly in the body; moving that paragraph left the end behind, before its start or after a paragraph the bookmark never covered. Such a marker now moves with the block when the range's other end does, and a move that would change what a range or a complex field covers is refused. Where a move would leave two tables touching, which Word reads as one, or a table ending the body, it adds the empty paragraph InsertTable would, with changes tracked too. ValidMoveTargets and MoveBlockRange decide by the same rules, so MoveBlockRange also takes both markers of a bookmark around its run, and InsertTable keeps its table apart by them too, past permission markers and the edges of content controls. Accepting or rejecting a revision decides by the same rule which empty paragraph a table needs: it no longer keeps one after a table at the end of a content control that something follows, and no longer removes the one between two tables when only the edge of a content control or custom XML element, or a permission marker, stands between them. A bookmark whose end is before its start, as the old move left one, no longer stops every move, and no move puts its start back before its end. A text box's fields and ranges are its own story's: they no longer pair with the body's. The paragraph added between two tables goes outside the ranges that start or end between them, on either side of where it was put; it is kept wherever the markup as it stands would leave two tables touching, as when a table is inserted with changes tracked beside a deleted one; it belongs to a tracked move or table only when the same edit inserted it, as Docxodus's own sub-second revision stamp shows (so rejecting one move first no longer strands the other's paragraph), never with a section break, and past a permission range's end too. A field's result keeps to its side of the field's separator, and its instructions keep their order across paragraphs; markup in a branch of alternate content that is not shown is left out. An untracked move keeps tables apart however each pending change between them is resolved, not only when all are accepted or all rejected. Removing an empty paragraph while resolving a revision keeps the bookmark, comment and move range markers that were in it, and a paragraph that holds a comment's reference is kept. A tracked InsertTable after a pending split paragraph is now refused past a permission range's end too, as it was past a bookmark's.

  • HTML no longer shows the text #x200e or #x200f where the converter writes an invisible direction mark (#1862): after a line break, and around a run whose direction differs from its paragraph's or that is in a right-to-left paragraph. Moving a piece of rendered text to a new parent copied those marks as plain text in two places: a paragraph split by a page or column break in paginated HTML (so also convertDocxToPaginatedHtml and PDF export), and a link inside a HYPERLINK field's result, in flow HTML as well, where the moved runs also lost their formatting and a link nested inside that link stayed nested. Column-break splits had it since 13.0.0, the field link since 14.2.0 and page-break splits since 16.0.0.

  • paginateHtml, usePagination and PaginatedDocument keep the scroll offsets of the element they paginate into, and of every scroll container around it, when they lay a document out again (#1863). Passing new HTML, such as each projectAnnotationsOntoHtml result, or a new scale replaced the pages, which emptied the element for the layout pagination measures in, and the browser clamped scroll offsets to that empty size: always for an element that scrolls itself, such as a PaginatedDocument with a fixed height, and for a scroll container around it that is narrower than the pages or taller than the window. The offsets, across shadow roots and smooth-scrolling containers too, are now put back at once when the new pages are in, before anything paints, so in most layouts no scroll event fires, and an offset that was not clamped is left alone, so a smooth scroll under way goes on; if the new pages are shorter, an offset stops at their end. A host that loads a different document into an element that scrolls itself and wants it to open at the top now scrolls it there. usePagination now paginates through paginateHtml, so HTML without pagination elements reports paginateHtml's error message.

  • Moving a paragraph or table with changes tracked (MoveBlock, and the editor's drag and move commands) no longer copies the permission ranges inside it, the editable regions Word's Restrict Editing marks, with their ids (#1864). A tracked move leaves the block in both places until it is accepted or rejected, so the saved document had two ranges with one id, which the Open XML validator rejects; and accepting a moved paragraph, or rejecting it in the session, left the range of the copy that went behind, empty, in a paragraph next to it. The moved copy's ranges now take ids no other range uses, and in a paragraph each copy's markers sit inside that copy's revision marks, so accepting the move leaves one range over the moved block and rejecting it leaves the original, ids and all. Comment ranges in the moved paragraph go inside the same marks, so resolving the move in the session leaves no empty comment range behind either.

  • The text of a complex HYPERLINK field (w:fldChar), a link written as a field code rather than as a w:hyperlink, no longer renders in the browser's default link style, blue and underlined, whatever its own formatting says (#1869). The field's link now leaves colour and underline to its runs, as a w:hyperlink's link does, in flow and paginated HTML, with fabricated CSS classes or inline styles, and in the editor's block renders: plain text in the field stays plain, and text in the Hyperlink character style is still blue and underlined by that style. A HYPERLINK field's \l location now goes into the link (#Target, or after the address), so such a link leads where it says, and a HYPERLINK field in another's result is no longer a link inside a link. The HTML converter and the document model behind the markdown projection and the comparison now read a HYPERLINK field's target with one parser. It also skips the value of a general switch (\* MERGEFORMAT) or of one written with no space before it (\o"tip"), and ignores an empty one, where the model used to read these as the address. It reads a quoted path's escapes as Word writes them ("\\\\server\\share" is \\server\share), as the session's own field reader already did.

  • The ribbon editor (createRibbonEditor, mountRibbon) opens documents in page view again (#1868). With page view on, a new document, File › Open, the header/footer toggle and a ribbon created with paginated: true all failed with "Pagination requires staging and container elements attached to their document", and the previous document stayed on screen. The ribbon lays out a document it opens before it closes the current one, so that a file it cannot open leaves the current document and its undo history alone, and it did that in an element outside the page, where page view cannot measure. In page view it now lays the new document out in the page, beside the current one and off screen, with the current document's stylesheets switched off meanwhile so that only the new document's own styles apply (and the reader's scroll position kept), and removes that element whether the open succeeds or fails. Continuous view is unchanged.

  • A link written as a simple field, a w:fldSimple with a HYPERLINK instruction, is a link in HTML (#1870). It rendered as plain text that could not be followed; it now renders as the complex field form does, an <a> to the field's address or \l location that leaves colour and underline to its runs. A table of contents whose entries are written as HYPERLINK fields, complex or simple, rather than as w:hyperlink elements now renders each entry as a link to its heading, also when the entries sit in tracked insertions or deletions, as Word writes a table of contents updated with changes tracked; and it draws them as Word prints them, without the blue and underline of the Hyperlink character style, as entries written as w:hyperlink already were (#427). Behind this, a field in another field's result now converts as it does on its own: a HYPERLINK field there is a link without StampReferenceFields, and in paginated HTML (or with StampPageNumberFields) a PAGE field there gets the page-number marker the paginator fills in. Fields in another field's instruction (an IF field's condition, say) convert as before. A HYPERLINK field whose name is written in lower case (hyperlink "…") is a link too, as Word and the document model behind the markdown projection and the comparison already read it.

  • The HTML converter no longer writes a link target that a browser would run as script into href (#1880). A w:hyperlink, a HYPERLINK field (complex or simple) or a picture's click link whose target is a javascript:, vbscript: or data: URL, in any case and with blanks a browser ignores around or inside it, now renders as a link without an href (its text stays; a picture is no longer wrapped in a link). Every other target, relative ones and file: included, is the link's as before.

  • A complex HYPERLINK field (w:fldChar) in a footnote or endnote, or in a header or footer outside paginated HTML, is a link, as in the body and as a w:hyperlink there is (#1876). Its runs used to convert one by one, because the converter grouped a complex field's runs in notes only with StampReferenceFields and in headers and footers only in paginated HTML or with page-number or reference stamps. Notes, headers and footers now group their fields in every mode, as the body does: in paginated HTML a page-number field in a note gets the page-number marker one in the body gets (headers and footers already did), and reference markers still need StampReferenceFields. Each note and text box is read as a story of its own, so a field left open in one (malformed markup) no longer runs into the next note or out of the text box. A stray separate or end field character with no field open, which made the conversion throw (as in a document whose tracked field insertion was rejected), is now ignored.

  • The HTML converter no longer shows the cached result of a field nested in another field's code, and a HYPERLINK field whose address is built from a nested field links to that field's result (#1875). Word shows a field's result only: whatever sits between its begin and separate characters is its code, and a nested field's result feeds that code. So { IF { PAGE } > 1 "Later" "First" } rendered 1First and now renders First, and { HYPERLINK "{ MERGEFIELD Url }" } rendered the merged address before its text and linked to the nested field's code; it now shows only its own text and links to the merged address. The converter hid such content only in parts that also held a field it evaluates (a form field, TITLE, DOCPROPERTY or STYLEREF); it now hides it in every story it renders, and a page-number or reference field in another field's code is no longer marked for the paginator or an editor. In HTML an editor addresses, such a field renders as one atom, a data-field="atom" marker (its type in data-field-type) whose data-field-cached is the session's text for the whole field, inside the link for a link, so a click on it is not followed (the editor also stops a click on a link in such a field's result), so the browser editor keeps its offsets beside it, types before or after it, and deletes it whole; a tab or symbol in a field's code is hidden with the rest of it, and a tab there no longer stops the conversion. ReplaceTextAtSpan over a span that starts in a field's code and reaches past it, as typing over such an atom sends, puts the new text before the field (for a field begun in an earlier paragraph, at the start of its result there), where it shows, rather than into the hidden nested result; a span wholly inside the code, such as part of a merged address, is still edited in place. The editor sends typing over such an atom as an insertion beside the field and then the deletion of the field's text wherever the insertion left it, in one undo step, so the text shows even over a field that shows nothing; text typed beside an atom stays beside it; a field copied and pasted in the editor is the clipboard's plain text, what it shows, and a cut across paragraphs writes each field as the text it shows. A nested result is read literally in a link's address (a path's backslashes or a quote in a query stay as written), a simple field's content counts as its result (a deleted link's deleted one too), an empty nested result, or a nested field with none, is an empty operand (so a \l location from one names nothing, with no trailing #), a nested result tracked as removed is left out, and a stamped REF field names the bookmark its code gives with the nested result in place. Bookmarks and revision marks inside a field's code stay; a nested field in a field's result renders as before.

  • A table-of-contents entry written as a HYPERLINK field, complex or simple, rather than as a w:hyperlink now ends its page number on the right tab stop in HTML, as a w:hyperlink entry does (#1877). The field's leader tab got a width fixed up front from estimated text widths, so in paginated HTML and PDF export its page number could end several points short of the stop. A link's content now lays out its tabs the same way whichever form the link takes: the leader fills a box that ends on the stop, with the page number (and its StampReferenceFields marker) at the end of that box, inside the one link, in flow and paginated HTML, with or without a TOC field around the entry. Some links still lay their tabs out as before, now in every form: one with a line break before its first tab (whose tab and page number stay on the line after the break; a w:hyperlink there used to put them beside the first line, past the margin), and one whose first tab is inside a field the converter keeps whole, such as a PAGE field or a cross-reference marked by StampReferenceFields, which used to be cut in two at the tab and marked twice (a w:hyperlink holding such a reference was cut too). A link, or a tracked insertion, that ends after its right tab while the paragraph's text goes on no longer pushes that text past the stop: its tab's box ends before the stop by the width of the text after it that the rendering shows, leaving that text room to end on the stop. Hidden text, web-hidden text outside paginated HTML, deleted text that is not shown and the spaces that end the line take no room. That width is the converter's measurement, which the browser cannot correct as it does for text inside the box: where the converter can measure the document's fonts, the text ends on the stop; where it cannot and estimates every character's width instead, as the browser build does, the text ends short of the stop by the estimate's error, which grows with the text (a few points for a word or two, tens of points for a long run of text), as it did with the fixed-width tab before. Where the stop lies past the line end (in the right indent), such a tab keeps the fixed-width tab, which ends the text after the link on the stop, unless the entry's title wraps, which keeps its box. One limit remains: a contents entry whose title wraps and that has text after its link wraps every line of the title within the narrower box, not only the last, and draws that text beside the first line of the title rather than after the page number. In a block render for an editor (StampReferenceFields), a cross-reference holding a paragraph's later tab now keeps one marker instead of two, and that paragraph's tabs then take the widths estimated for them, as they already did when the reference held the first tab. The same goes for a field an editor's HTML (StampAnchors) shows as one atom, one whose code holds another field's result, such as { IF { PAGE } = 1 "one" "other" }: when its result holds a tab, in a link of any form or in the paragraph's own runs, it stays one atom holding the whole result, instead of an atom holding the text before the tab and editable text after it. Its tabs then take their estimated widths, as a marked cross-reference's do, rather than the box that ends on the stop; in the paragraph's own runs that holds for every tab in the paragraph, including one after the atom. A simple HYPERLINK field's content now converts as a w:hyperlink's does, so a field in it is marked or kept whole as it would be there. A HYPERLINK field named in lower or mixed case (hyperlink) is kept whole across a tab as an upper-case one is, instead of being split into two links.

  • A table-of-contents entry keeps a colour or underline set on its own runs in HTML, as Word prints it (#1878). The converter drops the colour and underline the Hyperlink character style gives an entry, as Word does (#427), but it dropped one the run sets itself too, so an entry's red text or double underline rendered plain: in an entry written as a w:hyperlink since #427, and in one written as a HYPERLINK field since #1870. A tab in such a run draws the run's underline too. What styles give an entry's runs is still dropped. Also, a complex field (w:fldChar) inside a simple field (w:fldSimple) of any kind now converts as a field, as it does in a paragraph: a HYPERLINK field there is a link, and with StampReferenceFields a reference field there is marked, such as the PAGEREF of a contents entry written as a simple field. Word does not normally write this shape. With StampReferenceFields, a reference field around a link whose text holds a tab, such as a table-of-contents entry, is now marked once: it was marked again for each stretch of the link's text between tabs, three times for an entry with one tab. And a footnote or endnote reference, or a comment marker, inside a link no longer cuts the link short in a browser: its own <a> sat inside the link's, and an HTML parser ends the outer link there, so the link's text after it was no link. The link is now split around such an anchor, each piece with the link's target and style, whether the link is a w:hyperlink or a HYPERLINK field, complex or simple; the anchor keeps its own target, id and classes. A picture with its own click link inside a link splits the link the same way: the picture keeps its target, and the link's text after it keeps the link's. A w:hyperlink nested in another w:hyperlink, which the file format allows, likewise renders as links side by side, each to its own target: the outer link's text before the inner link, the inner link, and the outer link's text after it, which used to lose its link in a browser. And a field whose code was edited with changes tracked, which keeps its old code beside the new, is read by its new code when the converter decides whether it is a field it fills in (TITLE, DOCPROPERTY, STYLEREF) or a table of contents, as it already was when drawing it: with tracked changes shown, one edited from PAGE into TITLE now shows the document's title rather than its cached result (HTML that accepts revisions first was already right).

  • The browser editor no longer rewrites a field atom that an edit left alone, and takes typing in a paragraph that shows only fields (#1887). Chromium sometimes replaces the element of the atom next to the caret with a copy during a key press that changes nothing, such as ArrowRight and then Delete beside a link built from a merged address that is followed by another atom; the editor told removed atoms from surviving ones by their element, so it read the copy as a removed field and saved its text, hidden code text included, as plain text (Lead Visit1b end for a field that shows b). It now matches the atoms left in the paragraph to the ones it recorded by kind, type and counted text and by where the text around them is unchanged, so a field the edit did not remove stays a field. Typing in a paragraph whose only content is a tracked-deleted page field in the page view, or at the end of a paragraph that shows only a field whose result is empty, was refused as an edit past the end of the paragraph and the keystroke lost: the editor looked for a field inside the rendered deletion when it decided the paragraph was empty, and counted the placeholder space it shows in such a paragraph as the paragraph's text. It now ignores fields inside a deletion there, and leaves out the placeholder when the session's own text shows it is not part of the paragraph; typing over the field itself in such a paragraph put the text into the field's hidden result, where it did not show, and now puts it beside the field. A link inside such an atom's result is guarded against a click or middle click from one handler on the block, listening as the event goes down to the link, rather than from a handler on each link, so it stays inert in an atom Chromium has replaced with a copy and when a page handler stops the event at the link.