Skip to content
QuireKit
Classic docs
Alpha · evolving API
Classic developmentView Markdown ↗

Develop Word document actions

Connect styles, numbering, tables and page numbers to product controls and distinguish sections from pages.

Start with a mounted Word Classic. instance.editor owns document commands; instance.ui owns workspace controls. Call installed typed methods instead of deriving command strings from button labels.

Identify the semantic target

User goalCanonical objectAvoid
Apply Heading 2Paragraph style identity and definitionEnlarging text or using a generic heading node
Continue numberingDefinitions, instances and paragraph referencesInserting literal 1. text
Insert a tableLogical table, rows and gridEditing painted page fragments
Change marginsDocument sectionChanging paper CSS padding
Show page numbersHeader/footer story and PAGE fieldSaving the current number as literal text

A painted page is a layout result. One section may span pages, as may a logical Word table. Commands modify logical content; layout repaginates it.

1. Apply a paragraph style

Call applyWordParagraphStyle({ styleId: 'Heading2' }) only when that ID exists in the document's style registry. Visible labels are not stable IDs. Imported documents may use other identities; report missing styles or establish definitions through the style-management workflow first.

Word headings usually remain paragraphs with wordParagraph.styleId, rather than StarterKit heading nodes. Character styles and paragraph styles also differ; use the appropriate character style or text-format command for selected text.

2. Numbering and tables use the current selection

toggleWordOrderedList() establishes or removes paragraph numbering references. Continuation, restarting and multilevel numbering follow document definitions, rather than replacing visible text.

insertWordTable({ rowCount: 3, columnCount: 2 }) inserts a logical three-row, two-column table. Table operations use current structural selections or explicit public positions. Read selection again for each action; screen pixels are not document positions.

3. Connect actions to buttons

These four functions each perform one task using the quick start instance. They check the current Core and read-only state; the host still checks business permissions before calling them.

classic/word/tasks.tsts

Call applySectionHeading(instance) or insertComparisonTable(instance) from a click handler. A false result must not display success. Query availability through editor.can() with identical parameters; availability grants no permission. A later false result in a series of commands does not roll back earlier writes.

setOneInchMargins() receives the current document position before a section, not a page number or screen coordinate. Do not permanently use the initial document's 0 for every section. This API uses twips: 1440 twips equals one inch. The page-number example explicitly supplies location, format, start and template; layout updates field results.

4. Assemble professional capabilities separately

Tracked-review workflows, comments, content controls and document templates depend on the selected professional packages. A standard Word preset, license key or hidden button does not install them. See commercial use, product plugins and individual plugin documentation.

Not every page-level or document-level operation can be recorded as a tracked change. Expose actual support and diagnostics rather than labeling every command as an accept/reject change.

5. Verify data and files

After styles, tables and page numbers, inspect canonical IDs and relationships in JSON, then export and reimport DOCX. Compare styles, numbering, grids, sections and header/footer stories, and inspect conversion reports. Matching plain text does not establish preserved Word semantics. Font/layout support affects cross-application pixels; successful export alone proves no pixel guarantee.

QuireKitQuireKit · Core, plugins and Classic docs