Task recipes

Choose between the React and Vue review hooks and the Office.js-shaped editing API, then find the exact symbol for each common task.

Each recipe solves one task with a complete code sample. Choose the API first, then find the symbol for your task.

Which API for which job

Use the React or Vue adapter hooks, the review hooks, and DocxEditorReview from @docx-editor.dev/pro/react or @docx-editor.dev/pro/vue to build browser review controls. Use the editing API in @docx-editor.dev/editor-api for document automation. It follows the Office.js object model and runs in browser and server hosts.

TaskBrowser controls (React or Vue)Document automation
Comment on found texteditor.findMatches, editor.selectMatch, then useReview().commentbody.search, then Range.insertComment
Reply to a threaduseReview().reply(item, text)Comment.reply(text)
Record a tracked replacementSuggesting mode, then editor.exec({ type: 'replaceMatch', match, text })document.changeTrackingMode = 'TrackMineOnly', then Range.insertText(text, 'Replace')
Propose an AI rewrite as tracked changesprepareRewrite through DocxEditor.createBrowserprepareRewrite from @docx-editor.dev/editor-api/agent
Accept or reject a changeuseReview().accept(item) or useReview().reject(item)Revision.accept() or Revision.reject()
Open a change without scrollinguseReview().setActive(key, { reveal: false })Not applicable: no viewport
Highlight rangesuseHighlights(name, source, options)Not applicable
Custom review rail cardsDocxEditorReview with preset set to false, useStackedReviewPositions, and useReviewRailMetricsNot applicable
Comment-on-selection buttonDocxEditorReview.AddComment as a direct child of DocxEditorReview, or useEditorCommand('review.addComment')Not applicable
Page setup and paragraph dialogsDocxEditor.PageSetupDialog or DocxEditor.ParagraphDialogSection.pageSetup, and Paragraph properties such as alignment

Check prerequisites

  • The review hooks need reviewModule() from @docx-editor.dev/pro in the editor's modules.
  • Comments and tracked changes need an author: the editor's author prop, or the runtime's author option.
  • Create a server runtime with DocxEditor.createServer from @docx-editor.dev/editor-api. Create a browser runtime with DocxEditor.createBrowser from @docx-editor.dev/editor-api/browser.
  • Review controls stay separate from the Office.js-shaped document model.
  • @docx-editor.dev/pro and @docx-editor.dev/editor-api require the EigenPal Pro License. For more information, see Pro features.

See also