Edit Plan Operations¶
scripts/edit_document_from_plan.ps1 accepts JSON edit plans for scripted
.docx rewrites. This page documents the plan shape, summary output, and the
most-used operation parameters so the language-local API page is useful without
opening the dispatcher script.
Plan Shape¶
An edit plan can be either a JSON array or an object with an operations
array. Every operation must provide op. Hyphenated operation names are
normalized to underscores, so append-image and append_image route to the
same dispatcher branch.
{
"operations": [
{
"op": "replace_text",
"find": "Draft",
"replace": "Final",
"match_case": true
},
{
"op": "append_hyperlink",
"text": "FeatherDoc",
"target": "https://github.com/wuxianggujun/FeatherDoc"
}
]
}
The input DOCX, output DOCX, optional summary_json path, build directory, and
skip_build flag are command parameters of
scripts/edit_document_from_plan.ps1. Individual operations normally do not
set input_path or output_path; apply_table_position_plan injects the
current input_path into the table-position plan before calling the CLI.
Execution Result¶
The script writes a summary object with the run status and per-operation records.
Field |
Meaning |
|---|---|
|
|
|
Resolved source and destination DOCX paths. |
|
Resolved JSON edit-plan path. |
|
Optional summary file path requested by the caller. |
|
Number of operation objects loaded from the plan. |
|
Per-operation records with |
|
Present only when the run fails before or during an operation. |
Operation Reference¶
The table below focuses on operations that are most often used from JSON plans. See the complete operation index further down for the full dispatcher surface.
Review And Revision Operations¶
Operation |
Required fields |
Optional fields and aliases |
Effect |
|---|---|---|---|
|
|
None. |
Calls |
|
|
|
Calls |
|
|
|
Adds a comment anchored to matching document text. |
|
|
Do not combine a plan file with an inline plan. |
Replays comment mutation operations through
|
Notes And Fields¶
Operation |
Required fields |
Optional fields and aliases |
Effect |
|---|---|---|---|
|
|
|
Calls |
|
|
|
Appends a Word hyperlink field that targets a bookmark. |
|
|
|
Sets the document-level update-fields-on-open flag. |
Template Slots And Content Controls¶
Operation |
Required fields |
Optional fields and aliases |
Effect |
|---|---|---|---|
|
|
|
Calls |
|
Selector fields and |
Part selection fields; empty rows are accepted for this operation. |
Replaces rows in a content-control table. |
|
|
Bookmark selector options. |
Replaces bookmark content with text. |
Images, Links, And OMML¶
Operation |
Required fields |
Optional fields and aliases |
Effect |
|---|---|---|---|
|
|
Part selection; |
Calls |
|
|
None. |
Calls |
|
|
None. |
Appends an OMML equation. |
Text And Paragraph Mutations¶
Operation |
Required fields |
Optional fields and aliases |
Effect |
|---|---|---|---|
|
|
|
Replaces text in |
|
One target: |
|
Applies run styling to paragraphs selected from the body or a table cell. |
|
Target |
Alignment aliases: |
Sets body paragraph horizontal alignment. |
Tables And Numbering¶
Operation |
Required fields |
Optional fields and aliases |
Effect |
|---|---|---|---|
|
|
None beyond the listed aliases. |
Sets the body table grid column and cell width. |
|
|
|
Calls |
|
|
None. |
Calls |
|
|
|
Applies table-position changes and writes the edit-plan output DOCX. |
|
|
None. |
Calls |
JSON Examples¶
Replace a content control, append an image, and set paragraph style:
{
"operations": [
{
"op": "replace_content_control_text_by_tag",
"tag": "customer_name",
"text": "Ada Lovelace"
},
{
"op": "append_image",
"image_path": "assets/logo.png",
"part": "body",
"width": 320
},
{
"op": "set_text_style",
"text_contains": "Ada Lovelace",
"bold": true,
"font_family": "Aptos",
"east_asia_font_family": "Microsoft YaHei",
"color": "1F4E79",
"font_size_points": 12
}
]
}
Update table layout and numbering:
{
"operations": [
{
"op": "set_table_col_width",
"table_index": 0,
"column_index": 1,
"width_twips": 2880
},
{
"op": "apply_table_position_plan",
"table_position_plan": {
"tables": [
{
"table_index": 0,
"alignment": "center"
}
]
}
},
{
"op": "import_numbering_catalog",
"catalog_file": "numbering.catalog.json"
}
]
}
Complete Operation Index¶
Review And Revision Operations¶
accept_all_revisionsreject_all_revisionsset_comment_resolvedset_comment_metadataappend_commentappend_comment_replyreplace_commentremove_commentapply_review_mutation_plan(CLI route:apply-review-mutation-plan)append_insertion_revisionappend_deletion_revisioninsert_run_revision_afterdelete_run_revisionreplace_run_revisionaccept_revisionreject_revisionset_revision_metadata
Notes And Fields¶
append_footnotereplace_footnoteremove_footnoteappend_endnotereplace_endnoteremove_endnoteappend_page_number_field(CLI route:append-page-number-field)append_total_pages_fieldappend_table_of_contents_fieldappend_document_property_fieldappend_fieldappend_date_fieldappend_reference_fieldappend_page_reference_fieldappend_style_reference_fieldappend_hyperlink_fieldappend_captionappend_index_entry_fieldappend_index_fieldappend_sequence_fieldappend_complex_fieldreplace_fieldset_update_fields_on_openenable_update_fields_on_opendisable_update_fields_on_openclear_update_fields_on_open
Template Slots And Content Controls¶
replace_content_control_textreplace_content_control_text_by_tagreplace_content_control_text_by_aliasreplace_content_control_paragraphsreplace_content_control_tablereplace_content_control_table_rowsreplace_content_control_imageset_content_control_form_statesync_content_controls_from_custom_xmlsync_content_control_from_custom_xmlreplace_bookmark_textreplace_bookmark_paragraphsreplace_bookmark_table_rowsreplace_bookmark_tableremove_bookmark_blockdelete_bookmark_blockreplace_bookmark_imagereplace_bookmark_floating_image
Images, Links, And OMML¶
append_image(CLI route:append-image)append_floating_imagereplace_imageremove_imageappend_hyperlink(CLI route:append-hyperlink)replace_hyperlinkremove_hyperlinkdelete_hyperlinkappend_omml(CLI route:append-omml)replace_ommlremove_ommldelete_omml
Text And Paragraph Mutations¶
insert_paragraph_text_revisiondelete_paragraph_text_revisionreplace_paragraph_text_revisioninsert_text_range_revisiondelete_text_range_revisionreplace_text_range_revisionappend_paragraph_text_commentappend_text_range_commentset_paragraph_text_comment_rangeset_text_range_comment_rangereplace_textreplace_document_textset_text_styleset_text_formatset_paragraph_text_styledelete_paragraphremove_paragraphset_paragraph_horizontal_alignmentset_paragraph_alignmentclear_paragraph_horizontal_alignmentclear_paragraph_alignmentset_paragraph_line_spacingclear_paragraph_spacing
Tables And Numbering¶
apply_table_position_plan(CLI route:apply-table-position-plan)import_numbering_catalogset_table_col_widthclear_table_col_widthclear_table_widthclear_table_alignmentclear_table_indentclear_table_layout_modeclear_table_style_idclear_table_style_lookclear_table_cell_spacingclear_table_default_cell_marginclear_table_borderdelete_table_rowdelete_table_columndelete_tableinsert_table_beforeinsert_table_like_beforemerge_table_cellunmerge_table_cellsunmerge_table_cell