Skip to content

Add DOCX template integration - #1113

Open
Sabrina-devops wants to merge 37 commits into
MindWorkAI:mainfrom
Sabrina-devops:feature/docx-template-integration
Open

Sabrina-devops wants to merge 37 commits into
MindWorkAI:mainfrom
Sabrina-devops:feature/docx-template-integration

Conversation

@Sabrina-devops

@Sabrina-devops Sabrina-devops commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Answers can now be exported into Word templates, such as the templates of an organization, and the Slide Assistant chooses its PowerPoint template from a list instead of a file picker. Both kinds of templates are kept as format templates in the app settings.

  • Format templates in the settings. A new section "Configure Format Templates" in the app settings lists the templates of the user and of the organization, together with the type of each, e.g., "PowerPoint template (.potx)". Users add, edit, delete, import, and (with the administration settings) export them; templates of a configuration plugin are read-only. AI Studio stores the path only, so a new version of the template takes effect at once. A format template is a Word document or template (.docx, .dotx) or a PowerPoint presentation or template (.pptx, .potx). The filter FileTypes.FORMAT_TEMPLATE is ready for further kinds, e.g., OpenDocument templates, once something uses them.
  • Export into a Word template. The export menu of an answer gets a submenu for Word: export without a template (Pandoc, as before), export into one of the Word templates, or manage the templates. DocumentExport now carries what both ways share: the text, the AI disclosure, the save dialog, and the feedback.
  • Word writer (Tools/Word/, Open XML SDK). The answer replaces the body of a copy of the template. Styles are found by their built-in names, so templates of any Word language work. It keeps headers and footers (also inherited ones of several sections), a cover page with what follows it up to the text (e.g., a table of contents, which Word updates on opening), the layout of the main section, a first page with columns of its own, and the shapes of the design. It fills the title box with the first heading of the answer, takes the list numbering and indentation of the template, spaces the blocks like the template, and keeps the text clear of shapes in the footers. Everything only the removed body used is removed, so Word offers no repair.
  • Slide Assistant. The file picker for the PowerPoint template and the button "Use no template" give way to FormatTemplateSelection: a select of the PowerPoint format templates, with "No template" as its first entry and a button which opens the template management. The settings of the Slide Assistant offer the same entries through ConfigurationSelect. Both share ConfigurationSelectDataFactory.GetFormatTemplatesData; the export menu and the selection share FormatTemplateExtensions and SettingsDialogFormatTemplates.ShowAsync. The choice stays the path of the file (DataSlideBuilder.TemplatePath), so configuration plugins which set this path keep their lock and preselection without a migration. A path which no format template names stays in the list under the name of its file.
  • Shared Open XML helpers (Tools/OpenXml/): TemplateCopy, TemplateFile, and OpenXmlText came out of the PowerPoint code and serve both writers.
  • Configuration plugins: CONFIG["FORMAT_TEMPLATES"] and the setting DataApp.AllowUserToImportFormatTemplate. The example plugin.lua documents both, and how DataSlideBuilder.TemplatePath preselects or locks a PowerPoint format template.
  • Documentation: the new area guide app/MindWork AI Studio/Tools/Word/AGENTS.md describes how a document comes about and the rules which are easy to break. app/AGENTS.md and Tools/PowerPoint/AGENTS.md describe format templates and why the Slide Assistant keeps the path. The changelog of v26.11.1 has entries for both kinds of templates.

Not part of this pull request: placeholders (content controls) on a cover page, such as [Title] or [Author], stay as they are; only the title box is filled.

Related proposal or issue

none

How did you test it?

  • dotnet build "app/MindWork AI Studio.slnx" and dotnet test in app/Tests: all 5,436 tests pass, among them more than 50 tests of the Word writer, which build their templates in code and check the written documents with the OpenXmlValidator.
  • cd app/Build && dotnet run verify passed all five checks (.NET tests, trim smoke test with all 244 JSON roots, Rust tests, Clippy, model sources). After the last changes, the .NET tests, the trim smoke test, the Rust tests, and Clippy passed again.
  • In the app:
    • added Word and PowerPoint templates under "Configure Format Templates" and checked their type in the list;
    • exported answers into Word templates and opened the documents in Word;
    • chose a PowerPoint template in the Slide Assistant from the list and opened the template management from the button next to it;
    • imported a test configuration plugin which ships a Word template (.docx) and a PowerPoint template (.pptx) and preselects the PowerPoint template in the Slide Assistant: both appear in the settings as templates of the organization, the Word template appears in the export menu, and the Slide Assistant preselects the PowerPoint template.

Wiki

For users (user guide: app settings, exporting answers, Slide Assistant):

  • The app settings have a new section "Configure Format Templates" (German: "Dokumentvorlagen konfigurieren"). Users add Word templates (.docx or .dotx) and PowerPoint templates (.pptx or .potx) there. AI Studio remembers where the file is, so a new version of the template takes effect at once. The list shows the type of each template, e.g., "PowerPoint template (.potx)", and a warning icon marks a template whose file cannot be found.
  • The export menu of an answer offers a submenu for Word: "Export without template" (Pandoc, as before), one entry per Word template, and "Manage your templates".
  • The exported document keeps the styles, page layout, headers and footers, and logos of the template; the answer replaces the sample text. A cover page stays, a table of contents lists the headings of the answer once Word updates the fields on opening, and a title box on the first page receives the first heading of the answer.
  • The Slide Assistant offers the PowerPoint templates in a list instead of a file picker: "No template" first, then the templates. The button next to the list opens the template management. The settings of the Slide Assistant preselect a template from the same list. A template chosen before this version stays in the list under the name of its file.

For IT departments (Enterprise IT, configuration plugins):

  • New configuration objects CONFIG["FORMAT_TEMPLATES"], each with Id (GUID), Name, and FilePath:

    CONFIG["FORMAT_TEMPLATES"][#CONFIG["FORMAT_TEMPLATES"]+1] = {
        ["Id"] = "00000000-0000-0000-0000-000000000000",
        ["Name"] = "Report",
        ["FilePath"] = "templates/Report.dotx"
    }
  • A relative path names a file shipped with the plugin, below its plugin.lua; .. segments and links out of the plugin directory are rejected, and a missing file leaves the template out with a warning in the log. An absolute path, e.g., on a network share, is not checked when the configuration is read; it has to be readable on every computer, inside the sandbox for Flatpak installations. The settings and the export warn users who cannot reach the file. Every client downloads the whole plugin, templates included, at every start and change of the configuration.

  • Users see the templates of the organization in the settings, but cannot change or delete them.

  • PowerPoint templates (.pptx, .potx) in FORMAT_TEMPLATES appear in the Slide Assistant. To preselect or lock one of them there, set DataSlideBuilder.TemplatePath to the same path (relative paths resolve against the plugin directory in both places). A DataSlideBuilder.TemplatePath which no format template names keeps working and appears in the list under the name of its file.

  • New setting DataApp.AllowUserToImportFormatTemplate (default true) for importing exported format templates; table "Import permissions". Format templates join the list of objects which open in their form before an import is saved ("Reviewed before it is saved"), the list of objects with an export button ("Exporting configurations from the app": the format template list in the app settings, templates you created yourself), and the objects a backup leaves out when a configuration plugin manages them.

  • How an export follows a Word template (useful for template authors):

    • Styles by their built-in names: heading 1 to heading 6, List Paragraph, List Bullet, List Number, Quote, HTML Preformatted for code, and the character styles Hyperlink and HTML Code. Tables take the default table style of the template, otherwise Table Grid. A missing style gets a plain definition.
    • The top heading level of the answer becomes heading 1, so numbered chapters start at 1.
    • The first page: when it holds text, the answer starts where that text starts. When it holds none, it is a cover page and stays, with everything up to the first heading, e.g., document properties and a table of contents; the answer starts on a new page.
    • The pages of the answer take the layout, headers, and footers of the section with the chapters (the section of the last heading); pages after it, e.g., instructions, are left out.
    • A first page with columns of its own keeps its layout; AI Studio estimates how much text fits there and leaves some room.
    • Shapes in the margins, above the text of the first page, or behind the text stay; shapes within the text belong to the sample text and go. VML-only shapes, frames, and embedded objects are not taken over.
    • Lists take the bullets and numbers of List Bullet, List Number, or List Paragraph; each numbered list counts anew.
    • When the default paragraph style leaves no space after a paragraph, empty paragraphs separate the blocks of the answer.
    • The bottom margin moves up as far as a shape in the footer, e.g., an address in a text box, reaches across the text.
    • Best results: built-in styles for headings, lists, and the title; design elements in headers, footers, margins, or behind the text; sample chapters starting with built-in headings.

Pages concerned: Enterprise IT (configuration plugin reference, exporting and importing configurations, backups, "The Slide Assistant in your corporate design"), user guide (settings, exporting answers, Slide Assistant).

Required statements

  • Review: I have reviewed every change in this pull request and can explain it when asked.
  • License: I license my contribution in this pull request, including all commits I add to it later, under the MIT License, and I agree that it is distributed as part of MindWork AI Studio under the project license or under the MIT License.
  • Right to contribute: The contribution is my own work, or I have permission to submit it, including the consent of my employer or client where needed. To the best of my knowledge, it does not infringe the rights of others, and AI-generated parts do not reproduce third-party code under incompatible terms.
  • Changes by maintainers: I understand that the maintainers will change this pull request to fit the product, and that they may close it.

Credits (optional)

  • Credit me with my GitHub username only.
  • Do not credit me.

@Sabrina-devops Sabrina-devops self-assigned this Oct 26, 2026
Adapted the format templates to the rules main brought along: extension
blocks and properties instead of extension methods, settable JSON properties
for the source generator, MudBlazor 9, NUnit's EnterMultipleScope, and a
maximum height for the menu of the Word templates.

The documentation for IT departments moved to the wiki on main, so the
format template sections of "Enterprise IT.md" are left out; they go into
the "Wiki" section of the pull request. The changelog entry follows in
v26.11.1, since v26.10.1 is released.
Nothing used the PowerPoint templates of the list, while the texts promised
them. The filter of format templates takes Word templates only; PowerPoint
and OpenDocument templates join it once something uses them.
Called the missing template file the same everywhere, titled the dialog
like the one of the chat templates, and took "Dokumentvorlage" for the
German term: German Word calls a style a "Formatvorlage".
v26.10.1 is released. The entry is split into short ones for users and IT
departments, and the supporters page names the export into Word templates.
Reviewed the German translation: addressed the reader formally, used
"Dokumentvorlage" and the wording of the other missing-file messages, and
replaced a reply of the model which had ended up as the dialog title.
The Slide Assistant is about to choose its template from the format
templates, so PowerPoint presentations and templates join them again. The
export menu and the coming selection share which templates of a kind they
list, their icon, and how they open the management of the templates.
A select of the format templates of one kind, with a way to their
management, for the Slide Assistant and its settings. Both choose the path
of a file, so a path no format template names stays among the entries.
The file picker gives way to the selection of the PowerPoint format
templates, which also offers no template and leads to their management.
The choice stays the path of the file, so locks and preselections of
configuration plugins keep working.
…ates

The settings of the Slide Assistant offer the same entries as its
selection, through ConfigurationSelect, and keep storing the path.
Explained in the guides why the Slide Assistant keeps the path of its
template, told IT departments how to preselect a format template, and
added the changes to the changelog.
A column names the kind of template and the extension of its file, e.g.,
"PowerPoint template (.potx)", now that the list holds Word and PowerPoint
templates alike. A test makes sure every kind of format template has a name.
The row centers its items, as SecretInputField does: an icon button has no
baseline of text, so aligning by the baseline moved it off the field.
Reviewed the German translation: addressed the reader formally, said
"Vorlage" instead of "Template", named Word templates as such, used
"Dokumentvorlagen" without the typo, and kept the established wording of
the Slide Assistant.
@Sabrina-devops
Sabrina-devops marked this pull request as ready for review November 5, 2026 10:19
@Sabrina-devops
Sabrina-devops requested review from a team as code owners November 5, 2026 10:19

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant