syncfusion-aspnetcore-docx-editor
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseSyncfusion ASP.NET Core DOCX Editor
Syncfusion ASP.NET Core DOCX Editor
Overview
概述
This skill helps developers generate ASP.NET Core (C#) code for integrating the Syncfusion DOCX Editor into their applications. It provides ready-to-use snippets and best practices for embedding a Document Editor that supports editing, reviewing, formatting, and more.
本Skill帮助开发者生成用于在ASP.NET Core(C#)应用中集成Syncfusion DOCX Editor的代码。它提供了可直接使用的代码片段和最佳实践,用于嵌入支持编辑、审阅、格式化等功能的文档编辑器。
Key Capabilities
核心功能
- Document Editing: Create, edit, and view Word documents.
- Protection: Apply read-only mode, allow comments, allow form filling, enforce tracked changes,and define editable ranges.
- Review: Enable track changes (revisions) and accept/reject changes.
- Comments: Add comments, replies, and author metadata.
- Find and replace: Perform programmatic find and replace operations for automation.
- Form Fields: Insert and fill text fields, check boxes, and dropdown form fields.
- 文档编辑:创建、编辑和查看Word文档。
- 文档保护:应用只读模式、允许添加批注、允许表单填写、强制启用修订功能,并定义可编辑范围。
- 审阅功能:启用修订(追踪更改)以及接受/拒绝更改。
- 批注管理:添加批注、回复和作者元数据。
- 查找替换:执行程序化的查找和替换操作以实现自动化。
- 表单字段:插入并填写文本字段、复选框和下拉表单字段。
Prerequisites
前置条件
- NuGet package:
Syncfusion.EJ2.WordEditor.AspNet.Core - Syncfusion License: https://www.syncfusion.com/products/communitylicense
- NuGet包:
Syncfusion.EJ2.WordEditor.AspNet.Core - Syncfusion许可证:https://www.syncfusion.com/products/communitylicense
Quick Start Examples
快速入门示例
Example 1: Create an editable Document Editor with Ribbon
示例1:创建带Ribbon栏的可编辑文档编辑器
User: "Create a Document Editor component with Ribbon UI"
Result: An ASP.NET Core snippet that renders the Document Editor with Ribbon UI.
用户请求:"创建一个带Ribbon UI的Document Editor组件"
结果:一段可渲染带Ribbon UI的Document Editor的ASP.NET Core代码片段。
Example 2: Load a default document at startup
示例2:启动时加载默认文档
User: "Open a default document when the component mounts"
Result: An ASP.NET Core snippet that opens a SFDT file and loads it into the editor on initialization.
用户请求:"组件初始化时打开一个默认文档"
结果:一段在初始化时打开SFDT文件并加载到编辑器中的ASP.NET Core代码片段。
Getting Started — Minimal ASP.NET Core (C#) Code
快速开始——极简ASP.NET Core(C#)代码
Minimal ASP.NET Core Document Editor setup for plain web project:
Add the Syncfusion<sup style="font-size:70%">®</sup> ASP.NET Core DocumentEditor tag helper in page.
~/Pages/Index.cshtmlFor example, the Document Editor Container component is added to the page.
~/Pages/Index.cshtmlcshtml
<ejs-documenteditorcontainer id="container"></ejs-documenteditorcontainer>针对普通Web项目的极简ASP.NET Core Document Editor设置:
在页面中添加Syncfusion<sup style="font-size:70%">®</sup> ASP.NET Core DocumentEditor标签助手。
~/Pages/Index.cshtml例如,将Document Editor Container组件添加到页面。
~/Pages/Index.cshtmlcshtml
<ejs-documenteditorcontainer id="container"></ejs-documenteditorcontainer>Generate ASP.NET Core (C#) Code for the User's Project
为用户项目生成ASP.NET Core(C#)代码
Trigger keywords: "code", "snippet", "how to", "show me", "sample", "example code", "generate code", "implement", "add to view", "configure documenteditor", "create", "asp.net core document editor", "docx editor", "document editor", "track changes", "load docx", "export pdf", "comments", "accept changes", "insert table", "insert image", "table of contents", "protect document", "content control"
Workflow:
-
Analyze the user's request to identify the feature (e.g., track changes, restrict editing, toolbar customization).
-
Read the relevantfile(s) to understand the APIs and code patterns for the requested feature.
references/*.md -
STOP before generating code. Check if the user has already chosen a delivery mode.
-
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
-
Only after the user selects a delivery mode, proceed to generate ASP.NET Core (C#) code using the APIs and snippets from, substituting concrete placeholders from the user's project.
references/*.md -
Do NOT make changes to workspace project files unless the user explicitly chose Option 1 and provided the file path with permission.
-
Provide complete ASP.NET Core snippets and concise integration steps after delivering the code.
Refer to section for operational constraints (output directory, temporary files, allowed libraries, etc.)
## Key Rules触发关键词:"code"、"snippet"、"how to"、"show me"、"sample"、"example code"、"generate code"、"implement"、"add to view"、"configure documenteditor"、"create"、"asp.net core document editor"、"docx editor"、"document editor"、"track changes"、"load docx"、"export pdf"、"comments"、"accept changes"、"insert table"、"insert image"、"table of contents"、"protect document"、"content control"
工作流程:
-
分析用户请求以确定所需功能(例如修订、编辑限制、工具栏自定义)。
-
阅读相关的文件,了解所请求功能的API和代码模式。
references/*.md -
生成代码前请暂停。检查用户是否已选择代码交付方式。
-
如果用户尚未选择交付方式,你必须首先使用以下简洁的选择题询问用户:"你希望以何种方式接收生成的代码?"
- 选项1:替换指定项目文件中的代码(你需要提供文件路径并确认)
- 选项2:直接在聊天窗口中分享代码
-
仅在用户选择交付方式后,使用中的API和代码片段生成ASP.NET Core(C#)代码,并替换为用户项目中的具体占位符。
references/*.md -
除非用户明确选择选项1并提供了经允许的文件路径,否则请勿修改工作区项目文件。
-
交付代码后,提供完整的ASP.NET Core代码片段和简洁的集成步骤。
有关操作限制(输出目录、临时文件、允许使用的库等),请参考部分
## 核心规则Code References
代码参考
All code snippets and examples are in the folder. Each file contains:
references/- Minimal ASP.NET Core (C#) Code — a working, ready-to-use snippet
- Placeholders — values the user must customize
- Notes — ASP.NET Core best practices and framework-specific adaptations
| File | Topic |
|---|---|
| comments.md | Insert, Manage, and Delete Comments |
| customize-ribbon.md | Customize Ribbon/Toolbar |
| customize-tool-bar.md | Customize Toolbar Items |
| document-editor.md | Initialize Document Editor (Razor/Cshtml) |
| document-protection.md | Protect and Restrict Document Editing |
| editor-only.md | Configure Editor-Only Mode |
| find-and-replace.md | Find and Replace Text |
| form-fields.md | Create and Manage Form Fields |
| paste-formatting.md | Preserve paste formatting (server-side) |
| spell-check.md | Spell Check Integration |
| track-changes.md | Track Changes and Manage Revisions |
所有代码片段和示例均位于文件夹中。每个文件包含:
references/- 极简ASP.NET Core(C#)代码——可直接运行的可用代码片段
- 占位符——用户必须自定义的值
- 说明——ASP.NET Core最佳实践和框架特定适配
| 文件名称 | 主题内容 |
|---|---|
| comments.md | 插入、管理和删除批注 |
| customize-ribbon.md | 自定义Ribbon栏/工具栏 |
| customize-tool-bar.md | 自定义工具栏项 |
| document-editor.md | 初始化Document Editor(Razor/Cshtml) |
| document-protection.md | 保护和限制文档编辑 |
| editor-only.md | 配置仅编辑器模式 |
| find-and-replace.md | 文本查找与替换 |
| form-fields.md | 创建和管理表单字段 |
| paste-formatting.md | 保留粘贴格式(服务器端) |
| spell-check.md | 拼写检查集成 |
| track-changes.md | 追踪更改和管理修订 |
Key Rules for Code Generation
代码生成核心规则
-
No inline code in SKILL.md — Always point to snippets in. This file is loaded into context for every prompt; inline code wastes tokens.
references/*.md -
Snippets must be tested — All code must compile and run against the currentNuGet package version.
Syncfusion.EJ2.WordEditor.AspNet.Core -
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)
-
Use only Syncfusion APIs — Never suggest competing libraries
-
Share code and notes for the requirement — Never create temporary files or scripts.
-
License handling — Never hardcode license keys. Point user to environment variables or config files.
-
Framework adaptation — Default to plain JavaScript/TypeScript. When user specifies framework.
-
No hallucinated APIs — Use only verified Syncfusion DOCX Editor SDK method names. One wrong method breaks user trust.
-
SKILL.md中请勿包含内联代码——始终指向中的代码片段。本文件会在每次请求时加载到上下文,内联代码会浪费令牌。
references/*.md -
代码片段必须经过测试——所有代码必须能针对当前版本的NuGet包编译并运行。
Syncfusion.EJ2.WordEditor.AspNet.Core -
极简代码 + 占位符 + 说明——每个参考文件必须包含:
- 极简代码(完整、可运行的代码片段)
- 占位符(用户必须替换的值——用或
{{ }}标记)[PLACEHOLDER] - 说明(最佳实践、框架特定适配、约束条件)
-
仅使用Syncfusion API——请勿推荐其他竞争库
-
仅分享符合需求的代码和说明——请勿创建临时文件或脚本。
-
许可证处理——请勿硬编码许可证密钥。引导用户使用环境变量或配置文件。
-
框架适配——默认使用纯JavaScript/TypeScript。当用户指定框架时,再进行对应适配。
-
请勿使用虚构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
- ASP.NET Core (C#)-only code — all generated code must be valid ASP.NET Core (C#), never generate vanilla JavaScript, jQuery, or non-ASP.NET Core (C#) patterns
- 仅使用Syncfusion Document Editor API——绝不推荐或使用其他Word编辑器库。
- 禁止创建临时文件——绝不在输出目录外创建临时脚本、中间文件或脚手架
- 仅生成ASP.NET Core(C#)代码——所有生成的代码必须是有效的ASP.NET Core(C#)代码,绝不生成原生JavaScript、jQuery或非ASP.NET Core(C#)模式的代码