syncfusion-uwp-docx-editor

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Syncfusion UWP DOCX Editor

Syncfusion UWP DOCX编辑器

Overview

概述

This skill helps developers generate UWP code for integrating the Syncfusion DOCX Editor into their applications. It provides ready-to-use snippets and best practices for embedding a SfRichTextBoxAdv that supports editing, reviewing, formatting, and more.
本技能可帮助开发者生成将Syncfusion DOCX编辑器集成到其UWP应用中的代码。它提供了可直接使用的代码片段和最佳实践,用于嵌入支持编辑、审阅、格式化等功能的SfRichTextBoxAdv。

Key Capabilities

核心功能

  • Document Editing: Create, edit, and view Word documents.
  • Protection: Apply read-only mode, allow comments.
  • Comments: Add comments, replies, and navigate between them.
  • Find and replace: Perform programmatic find and replace operations for automation.
  • Import/Export: Open and save .doc/.docx/.rtf/.html/.xaml/.txt.
  • Clipboard: Copy, cut, paste rich content with formatting.
  • Hyperlinks: Insert, edit, and navigate hyperlinks.
  • 文档编辑:创建、编辑和查看Word文档。
  • 保护功能:应用只读模式、允许添加批注。
  • 批注管理:添加批注、回复批注,并在批注间导航。
  • 查找和替换:通过编程方式执行查找和替换操作以实现自动化。
  • 导入/导出:打开和保存.doc/.docx/.rtf/.html/.xaml/.txt格式文件。
  • 剪贴板操作:复制、剪切、粘贴带格式的富文本内容。
  • 超链接:插入、编辑和导航超链接。

Prerequisites

前置条件

Quick Start Examples

快速入门示例

Example 1: Create Document Editor

示例1:创建文档编辑器

User: "Show me code to create a Document Editor component." Result: A UWP XAML + C# snippet that initializes the Syncfusion document editor control.
用户:“给我展示创建Document Editor组件的代码。” **结果:**一段初始化Syncfusion文档编辑器控件的UWP XAML + C#代码片段。

Example 2: Enable Read‑Only Restriction Mode

示例2:启用只读限制模式

User: "Create a Document Editor with Read‑Only restriction mode." Result: A C# snippet that loads a document and applies read-only protection during initialization.

用户:“创建一个带有只读限制模式的Document Editor。” **结果:**一段在初始化时加载文档并应用只读保护的C#代码片段。

Generate C# Code for the User's Project (default)

为用户项目生成C#代码(默认)

Trigger keywords: "code", "snippet", "how to", "how to write", "show me", "sample", "example code", "generate code", "generate code for", "implement", "implementation", "create", "integrate", "add to component", "add to project", "configure documenteditor", "API example", "usage example", "how do I", "how to use", "document editor", "uwp document editor", "docx editor", "load docx", "comments", "protect document", "find and replace", "MainPage.xaml", "NuGet", "syncfusion"
Workflow:
  1. Analyze the user's request to identify the feature (e.g., comments, find and replace, import and export).
  2. Read the relevant
    references/*.md
    file(s) to understand the APIs and code patterns for the requested feature.
  3. STOP before generating code. Check if the user has already chosen a delivery mode.
  4. If no delivery mode is chosen yet, you MUST ask the user first using this concise multiple-choice question:
    "How would you like to receive the generated code?"
    • Option 1: Replace the code in a specific project file (you'll need to provide the file path and confirm)
    • Option 2: Share the code directly in the chat window
  5. Only after the user selects a delivery mode, proceed to generate UWP code using the APIs and snippets from
    references/*.md
    , substituting concrete placeholders from the user's project.
  6. Do NOT make changes to workspace project files unless the user explicitly chose Option 1 and provided the file path with permission.
  7. Provide complete UWP snippets and concise integration steps after delivering the code.
Refer to
## Rules
section for operational constraints (output directory, temporary files, allowed libraries, etc.)

触发关键词: "code", "snippet", "how to", "how to write", "show me", "sample", "example code", "generate code", "generate code for", "implement", "implementation", "create", "integrate", "add to component", "add to project", "configure documenteditor", "API example", "usage example", "how do I", "how to use", "document editor", "uwp document editor", "docx editor", "load docx", "comments", "protect document", "find and replace", "MainPage.xaml", "NuGet", "syncfusion"
工作流程:
  1. 分析用户请求以确定所需功能(例如批注、查找和替换、导入导出)。
  2. 阅读相关的
    references/*.md
    文件,了解实现该功能所需的API和代码模式。
  3. 生成代码前请暂停。检查用户是否已选择交付方式。
  4. 如果用户尚未选择交付方式,你必须先使用以下简洁的选择题询问用户:
    “你希望以何种方式接收生成的代码?”
    • **选项1:**替换指定项目文件中的代码(你需要提供文件路径并确认)
    • **选项2:**直接在聊天窗口中分享代码
  5. 仅在用户选择交付方式后,使用
    references/*.md
    中的API和代码片段生成UWP代码,替换用户项目中的具体占位符。
  6. 除非用户明确选择选项1并提供了带权限的文件路径,否则请勿修改工作区项目文件
  7. 交付代码后,提供完整的UWP代码片段和简洁的集成步骤。
有关操作限制(输出目录、临时文件、允许使用的库等),请参考
## 规则
部分

Code References

代码参考

All code snippets and examples are in the
references/
folder. Each file contains:
  • Minimal Code — a working, ready-to-use snippet
  • Placeholders — values the user must customize
  • Notes — best practices, additional information to note while using that functionality, constraints
FilePurpose
automatic-suggestion.mdConfigure automatic text suggestions and mentions using the @ character.
background.mdCustomize the background of the document and editor control.
character-format.mdApply character formatting such as font family, size, style, and color.
clipboard.mdPerform copy, cut, and paste operations within the document editor.
commands.mdUse built-in editor commands and configure command bindings.
comments.mdInsert, manage, reply to, navigate and delete document comments.
determine-editing-context-type.mdIdentify the current editing context (text, table, image, etc.).
document-editor.mdCreate, initialize, and configure the UWP DOCX Editor.
document-properties.mdAccess document statistics such as word count, page count, and current page.
find-and-replace.mdSearch for text and perform find-and-replace operations.
hyperlink.mdInsert, edit, and manage hyperlinks in documents.
image.mdInsert and manage images in the document.
layout-types.mdSwitch between page layout modes (Pages / Continuous / Blocks).
lists.mdCreate and manage bulleted and numbered lists.
localization.mdApply localization using resources and UI culture settings.
lost-focus-behavior.mdKeep the caret and selection highlight visible when the editor loses focus.
radial-menu.mdConfigure and use the radial menu for contextual actions.
mvvm.mdIntegrate the document editor with MVVM using data binding and view models.
open-document.mdOpen and load documents from files, streams, and memory using sync and async APIs.
paragraph-format.mdApply paragraph formatting such as alignment, spacing, and indentation.
print.mdPrint document contents and configure print behavior.
save-document.mdSave and export documents to files and streams using sync and async APIs.
section-format.mdConfigure section-level settings such as page size, margins, and headers/footers.
selection.mdWork with text selection APIs, navigation, formatting, and keyboard-based selection.
shapes.mdPreserve and interact with shapes such as text boxes and rectangles from imported documents.
styles.mdCreate, apply, modify, and clear character, paragraph, table, and linked styles.
table.mdCreate and manipulate tables including rows, columns, cells, and alignment.
template-and-styling-document-editor.mdCustomize control templates, styles, context menus, panes, and overall editor UI appearance.
undo-redo.mdUndo and redo document editing actions and configure undo behavior.
virtualization.mdEnable UI virtualization and apply performance optimization techniques.

所有代码片段和示例都位于
references/
文件夹中。每个文件包含:
  • 极简代码 — 可直接运行的可用代码片段
  • 占位符 — 用户必须自定义的值
  • 说明 — 最佳实践、使用该功能时需要注意的附加信息、约束条件
文件用途
automatic-suggestion.md使用@字符配置自动文本建议和提及功能。
background.md自定义文档和编辑器控件的背景。
character-format.md应用字符格式设置,如字体、字号、样式和颜色。
clipboard.md在文档编辑器内执行复制、剪切和粘贴操作。
commands.md使用内置编辑器命令并配置命令绑定。
comments.md插入、管理、回复、导航和删除文档批注。
determine-editing-context-type.md识别当前编辑上下文(文本、表格、图片等)。
document-editor.md创建、初始化和配置UWP DOCX编辑器。
document-properties.md访问文档统计信息,如字数、页数和当前页码。
find-and-replace.md搜索文本并执行查找和替换操作。
hyperlink.md在文档中插入、编辑和管理超链接。
image.md在文档中插入和管理图片。
layout-types.md在页面布局模式(分页/连续/块)之间切换。
lists.md创建和管理项目符号列表和编号列表。
localization.md使用资源和UI区域设置应用本地化。
lost-focus-behavior.md当编辑器失去焦点时,保持插入符和选区高亮可见。
radial-menu.md配置并使用径向菜单执行上下文操作。
mvvm.md使用数据绑定和视图模型将文档编辑器与MVVM集成。
open-document.md使用同步和异步API从文件、流和内存中打开和加载文档。
paragraph-format.md应用段落格式设置,如对齐方式、间距和缩进。
print.md打印文档内容并配置打印行为。
save-document.md使用同步和异步API将文档保存并导出到文件和流中。
section-format.md配置节级设置,如页面大小、边距和页眉/页脚。
selection.md使用文本选择API、导航、格式化和基于键盘的选择功能。
shapes.md保留并与导入文档中的形状(如文本框和矩形)交互。
styles.md创建、应用、修改和清除字符样式、段落样式、表格样式和链接样式。
table.md创建和操作表格,包括行、列、单元格和对齐方式。
template-and-styling-document-editor.md自定义控件模板、样式、上下文菜单、窗格和编辑器整体UI外观。
undo-redo.md撤销和重做文档编辑操作,并配置撤销行为。
virtualization.md启用UI虚拟化并应用性能优化技术。

Key Rules for Code Generation

代码生成核心规则

  1. No inline code in SKILL.md — Always point to snippets in
    references/*.md
    . This file is loaded into context for every prompt; inline code wastes tokens.
  2. Snippets must be tested — All code must build and run against current Syncfusion UWP NuGet packages (e.g., Syncfusion.SfRichTextBoxAdv.UWP)
  3. Minimal Code + Placeholders + Notes — Every reference file must include:
    • Minimal Code (complete, working snippet)
    • Placeholders (values user must substitute — marked with
      {{ }}
      or
      [PLACEHOLDER]
      )
    • Notes (best practices, framework-specific adaptations, constraints)
  4. Share code and notes for the requirement — Never create temporary files or scripts.
  5. License handling — Never hardcode license keys. Point user to environment variables or config files.
  6. Framework adaptation — Default to C# + XAML for UWP unless the user specifies otherwise.
  7. No hallucinated APIs — Use only verified Syncfusion DOCX Editor SDK method names. One wrong method breaks user trust.
  1. SKILL.md中不得包含内联代码 — 始终指向
    references/*.md
    中的代码片段。本文件会加载到每个提示的上下文中,内联代码会浪费令牌。
  2. 代码片段必须经过测试 — 所有代码必须能基于当前Syncfusion UWP NuGet包(例如Syncfusion.SfRichTextBoxAdv.UWP)编译并运行。
  3. 极简代码 + 占位符 + 说明 — 每个参考文件必须包含:
    • 极简代码(完整、可运行的代码片段)
    • 占位符(用户必须替换的值 — 用
      {{ }}
      [PLACEHOLDER]
      标记)
    • 说明(最佳实践、框架特定适配、约束条件)
  4. 仅分享符合需求的代码和说明 — 切勿创建临时文件或脚本。
  5. 许可证处理 — 切勿硬编码许可证密钥。引导用户使用环境变量或配置文件。
  6. 框架适配 — 除非用户另有指定,否则默认使用UWP的C# + XAML。
  7. 不得虚构API — 仅使用经过验证的Syncfusion DOCX Editor SDK方法名称。一个错误的方法会破坏用户的信任。

Rules

规则

  • Only use Syncfusion document editor APIs — never recommend or use alternative Word Editor libraries.
  • No temporary files — never create temporary scripts, intermediate files, or scaffolding outside the output directory.
  • C#-only code — all generated code must be valid C# and XAML for UWP projects. No JavaScript, TypeScript, or other languages.
  • 仅使用Syncfusion文档编辑器API — 切勿推荐或使用其他Word编辑器库。
  • 禁止临时文件 — 切勿在输出目录之外创建临时脚本、中间文件或脚手架。
  • 仅生成C#代码 — 所有生成的代码必须是适用于UWP项目的有效C#和XAML代码。不得使用JavaScript、TypeScript或其他语言。