moondown 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,435 @@
1
+ # Moondown
2
+
3
+ ![Moondown Logo](assets/logo_char.png)
4
+
5
+ [English README](README_EN.md)
6
+
7
+ Moondown 是一个基于 CodeMirror 6 的无头 Markdown 编辑器。它提供了成熟的编辑核心,支持 Markdown 语法隐藏、斜杠菜单、气泡菜单、表格编辑、图片组件、Mermaid 图表、LaTeX 预览以及 AI 集成扩展点,同时保持与前端框架无关。
8
+
9
+ Moondown 是一个独立的开源项目,定位是嵌入到你的应用中,而不是提供固定的应用壳。
10
+
11
+ ## 功能特性
12
+
13
+ - 基于 CodeMirror 6 的 Markdown 编辑
14
+ - 浅色与深色主题
15
+ - 语法隐藏,获得更清爽的写作体验
16
+ - 斜杠菜单
17
+ - 选区气泡菜单
18
+ - 行内格式:粗体、斜体、高亮、下划线、删除线、行内代码
19
+ - 标题、有序列表、无序列表、引用、分割线
20
+ - 可编辑 Markdown 表格
21
+ - 图片渲染与编辑
22
+ - Mermaid 代码块预览
23
+ - 基于 KaTeX 的 LaTeX 代码块预览
24
+ - 支持图片、Mermaid、LaTeX 组件的源码编辑
25
+ - AI 续写与润色扩展钩子
26
+ - 通过翻译覆盖实现国际化
27
+ - 插件 API(CodeMirror 扩展、生命周期钩子、自定义斜杠命令)
28
+ - 本地 playground 用于视觉 QA 与集成测试
29
+
30
+ ## 安装
31
+
32
+ ```bash
33
+ npm install moondown
34
+ ```
35
+
36
+ 或者:
37
+
38
+ ```bash
39
+ pnpm add moondown
40
+ ```
41
+
42
+ 导入编辑器及样式:
43
+
44
+ ```ts
45
+ import Moondown from 'moondown';
46
+ import 'moondown/style.css';
47
+ import 'tippy.js/dist/tippy.css';
48
+ ```
49
+
50
+ `tippy` 样式用于表格辅助浮层。
51
+
52
+ ## 快速开始
53
+
54
+ ```ts
55
+ import Moondown from 'moondown';
56
+ import 'moondown/style.css';
57
+ import 'tippy.js/dist/tippy.css';
58
+
59
+ const container = document.querySelector('#editor');
60
+
61
+ if (!container) {
62
+ throw new Error('Editor container not found');
63
+ }
64
+
65
+ const editor = new Moondown(container as HTMLElement, '# Hello Moondown', {
66
+ theme: 'light',
67
+ syntaxHiding: true,
68
+ placeholder: 'Write something...',
69
+ onChange: () => {
70
+ console.log(editor.getValue());
71
+ },
72
+ });
73
+ ```
74
+
75
+ 编辑器实例提供了简洁的命令式 API:
76
+
77
+ ```ts
78
+ editor.getValue();
79
+ editor.setValue('# Updated');
80
+ editor.setTheme('dark');
81
+ editor.toggleSyntaxHiding(false);
82
+ editor.setReadOnly(true);
83
+ editor.focus();
84
+ editor.destroy();
85
+ ```
86
+
87
+ ## 基础 HTML
88
+
89
+ ```html
90
+ <div id="editor"></div>
91
+ ```
92
+
93
+ Moondown 会填充你提供的容器。请在应用内设置容器尺寸:
94
+
95
+ ```css
96
+ #editor {
97
+ min-height: 480px;
98
+ }
99
+ ```
100
+
101
+ ## Markdown 组件
102
+
103
+ ### 图片
104
+
105
+ ```md
106
+ ![Alt text](https://example.com/image.png)
107
+ ```
108
+
109
+ 图片组件支持选中、编辑、删除,并可在只读模式下受保护。
110
+
111
+ ### Mermaid
112
+
113
+ ````md
114
+ ```mermaid
115
+ flowchart TD
116
+ Draft --> Review
117
+ Review --> Publish
118
+ ```
119
+ ````
120
+
121
+ Mermaid 代码块会渲染为图表预览。点击预览可选中对应源码块进行编辑。
122
+
123
+ ### LaTeX
124
+
125
+ ````md
126
+ ```latex
127
+ \int_0^1 x^2 dx = \frac{1}{3}
128
+ \sum_{i=1}^{n} i = \frac{n(n+1)}{2}
129
+ ```
130
+ ````
131
+
132
+ LaTeX 代码块按行渲染,多行源码会保持多行预览。
133
+
134
+ ## 配置
135
+
136
+ ```ts
137
+ import type { EditorConfig } from 'moondown';
138
+
139
+ const config: EditorConfig = {
140
+ theme: 'light',
141
+ syntaxHiding: true,
142
+ placeholder: 'Start writing...',
143
+ readOnly: false,
144
+ locale: 'en',
145
+ translations: {},
146
+ onChange(update) {
147
+ console.log(update.state.doc.toString());
148
+ },
149
+ onFocus() {
150
+ console.log('focused');
151
+ },
152
+ onBlur() {
153
+ console.log('blurred');
154
+ },
155
+ };
156
+ ```
157
+
158
+ ### EditorConfig
159
+
160
+ | 选项 | 类型 | 默认值 | 说明 |
161
+ | --- | --- | --- | --- |
162
+ | `theme` | `'light' \| 'dark'` | `'light'` | 编辑器初始主题。 |
163
+ | `syntaxHiding` | `boolean` | `true` | 尽可能隐藏 Markdown 语法标记。 |
164
+ | `placeholder` | `string` | `''` | 空文档时展示的占位文本。 |
165
+ | `readOnly` | `boolean` | `false` | 禁止文档内容修改。 |
166
+ | `locale` | `string` | `'en'` | 内置 UI 与 AI 提示所用语言区域。 |
167
+ | `translations` | `Record<string, string>` | `{}` | UI 文案覆盖。 |
168
+ | `onAIStream` | `AIStreamHandler` | `null` | 流式 AI 提供方钩子。 |
169
+ | `plugins` | `MoondownPlugin[]` | `[]` | 用户插件列表。 |
170
+ | `onChange` | `(update) => void` | `undefined` | 文档变更后触发。 |
171
+ | `onFocus` | `() => void` | `undefined` | 编辑器获得焦点时触发。 |
172
+ | `onBlur` | `() => void` | `undefined` | 编辑器失去焦点时触发。 |
173
+
174
+ ## AI 集成
175
+
176
+ Moondown 不内置托管 AI 服务。你需要提供一个 `onAIStream` 函数,并返回 `ReadableStream<string>`。
177
+
178
+ ```ts
179
+ import Moondown, type AIStreamHandler from 'moondown';
180
+
181
+ const onAIStream: AIStreamHandler = async (systemPrompt, userPrompt, signal) => {
182
+ const response = await fetch('/api/ai', {
183
+ method: 'POST',
184
+ headers: {
185
+ 'Content-Type': 'application/json',
186
+ },
187
+ body: JSON.stringify({ systemPrompt, userPrompt }),
188
+ signal,
189
+ });
190
+
191
+ if (!response.ok || !response.body) {
192
+ throw new Error(`AI request failed: ${response.status}`);
193
+ }
194
+
195
+ const reader = response.body.getReader();
196
+ const decoder = new TextDecoder();
197
+
198
+ return new ReadableStream<string>({
199
+ async start(controller) {
200
+ while (true) {
201
+ const { done, value } = await reader.read();
202
+ if (done) break;
203
+ controller.enqueue(decoder.decode(value, { stream: true }));
204
+ }
205
+ controller.close();
206
+ },
207
+ });
208
+ };
209
+
210
+ new Moondown(document.querySelector('#editor') as HTMLElement, '', {
211
+ onAIStream,
212
+ });
213
+ ```
214
+
215
+ 不要在浏览器端暴露模型服务商 API Key。请通过你自己的后端转发真实模型调用。
216
+
217
+ ## 插件
218
+
219
+ 插件可以贡献 CodeMirror 扩展、生命周期钩子和斜杠命令。
220
+
221
+ ```ts
222
+ import { defineMoondownPlugin } from 'moondown';
223
+
224
+ const templatePlugin = defineMoondownPlugin({
225
+ name: 'template-plugin',
226
+ slashCommands: [
227
+ {
228
+ id: 'template.decision',
229
+ title: 'Decision Note',
230
+ icon: 'file-plus',
231
+ keywords: ['decision', 'adr'],
232
+ execute(view) {
233
+ const pos = view.state.selection.main.from;
234
+ view.dispatch({
235
+ changes: {
236
+ from: pos,
237
+ insert: '## Decision\n\n- Context:\n- Options:\n- Outcome:\n',
238
+ },
239
+ });
240
+ },
241
+ },
242
+ ],
243
+ });
244
+
245
+ new Moondown(document.querySelector('#editor') as HTMLElement, '', {
246
+ plugins: [templatePlugin],
247
+ });
248
+ ```
249
+
250
+ 你也可以包装原生 CodeMirror 扩展:
251
+
252
+ ```ts
253
+ import { createExtensionPlugin } from 'moondown';
254
+
255
+ const myPlugin = createExtensionPlugin('my-extension', myCodeMirrorExtension);
256
+ ```
257
+
258
+ ## 主题
259
+
260
+ Moondown 样式基于 CSS 自定义属性。你可以在应用层覆盖:
261
+
262
+ ```css
263
+ :root {
264
+ --color-primary-hsl: 211 100% 50%;
265
+ --color-primary-light-hsl: 209 100% 72%;
266
+ --color-primary-dark-hsl: 211 100% 42%;
267
+ }
268
+ ```
269
+
270
+ 这些变量会影响选区颜色、Markdown 标记、列表项目符号、链接、引用强调、组件、菜单和 AI 面板控件。
271
+
272
+ 运行时切换主题:
273
+
274
+ ```ts
275
+ editor.setTheme('dark');
276
+ ```
277
+
278
+ ## 国际化
279
+
280
+ 通过 `translations` 覆盖内置 UI 文案:
281
+
282
+ ```ts
283
+ new Moondown(container, '', {
284
+ locale: 'zh-CN',
285
+ translations: {
286
+ 'moondown.slash.heading1': '一级标题',
287
+ 'moondown.slash.insertTable': '插入表格',
288
+ 'moondown.ai.polish.buttons.retry': '重试',
289
+ 'moondown.ai.polish.buttons.copy': '复制',
290
+ 'moondown.ai.polish.buttons.insert': '插入',
291
+ 'moondown.ai.polish.placeholder': '描述你想如何润色选中文本...',
292
+ },
293
+ });
294
+ ```
295
+
296
+ ## 开发
297
+
298
+ 环境要求:
299
+
300
+ - Node.js `>= 22`
301
+ - pnpm `>= 10`
302
+
303
+ 安装依赖:
304
+
305
+ ```bash
306
+ pnpm install
307
+ ```
308
+
309
+ 运行本地 playground:
310
+
311
+ ```bash
312
+ pnpm run dev
313
+ ```
314
+
315
+ 默认 playground 地址:
316
+
317
+ ```text
318
+ http://localhost:5174
319
+ ```
320
+
321
+ 使用自定义端口:
322
+
323
+ ```bash
324
+ PORT=5175 pnpm run dev
325
+ ```
326
+
327
+ ## 脚本
328
+
329
+ | 命令 | 说明 |
330
+ | --- | --- |
331
+ | `pnpm run check` | 进行 TypeScript 类型检查。 |
332
+ | `pnpm run build` | 构建 ESM、CJS、类型声明和 CSS 到 `dist/`。 |
333
+ | `pnpm run build:playground` | 构建静态 playground 到 `playground-dist/`。 |
334
+ | `pnpm run test:unit` | 运行单元测试。 |
335
+ | `pnpm run test:e2e` | 运行浏览器 E2E 测试。 |
336
+ | `pnpm run test:e2e:real-ai` | 运行可选的真实 AI 集成测试。 |
337
+ | `pnpm run test:ai:smoke` | 对 OpenAI 兼容 AI 接口做冒烟测试。 |
338
+ | `pnpm run test:full` | 类型检查 + 构建 + 单测 + E2E 全量测试。 |
339
+
340
+ ## 测试
341
+
342
+ 在提交 PR 或发布版本前,建议运行:
343
+
344
+ ```bash
345
+ pnpm run test:full
346
+ ```
347
+
348
+ AI 服务集成测试请先配置环境变量,再运行:
349
+
350
+ ```bash
351
+ DEEPSEEK_ENDPOINT='https://example.com/openai/v1/' \
352
+ DEEPSEEK_MODEL='your-model' \
353
+ DEEPSEEK_API_KEY='your-key' \
354
+ pnpm run test:e2e:real-ai
355
+ ```
356
+
357
+ ## 发布
358
+
359
+ 该包已配置为公开发布到 npm:
360
+
361
+ ```json
362
+ {
363
+ "main": "./dist/index.cjs",
364
+ "module": "./dist/index.js",
365
+ "types": "./dist/index.d.ts",
366
+ "exports": {
367
+ ".": {
368
+ "types": "./dist/index.d.ts",
369
+ "import": "./dist/index.js",
370
+ "require": "./dist/index.cjs"
371
+ },
372
+ "./style.css": "./dist/style.css"
373
+ },
374
+ "files": ["dist", "README.md", "LICENSE"],
375
+ "publishConfig": {
376
+ "access": "public"
377
+ }
378
+ }
379
+ ```
380
+
381
+ 推荐发布流程:
382
+
383
+ ```bash
384
+ pnpm install
385
+ pnpm run test:full
386
+ npm login
387
+ npm whoami
388
+ npm version patch
389
+ npm pack --dry-run
390
+ npm publish --access public
391
+ ```
392
+
393
+ 如需升级次版本或主版本,可使用 `npm version minor` 或 `npm version major`。
394
+
395
+ 如果你的 npm 账号或包开启了发布双重认证,发布时 npm 会提示输入 OTP。自动化发布场景建议使用具备发布权限的 granular npm token。
396
+
397
+ npm 官方参考:
398
+
399
+ - [创建并发布非 scoped 公共包](https://docs.npmjs.com/creating-and-publishing-unscoped-public-packages/)
400
+ - [创建并发布 scoped 公共包](https://docs.npmjs.com/creating-and-publishing-scoped-public-packages)
401
+ - [npm publish CLI 命令](https://docs.npmjs.com/cli/v11/commands/npm-publish)
402
+ - [为包发布开启 2FA](https://docs.npmjs.com/requiring-2fa-for-package-publishing-and-settings-modification)
403
+
404
+ ## 包内容
405
+
406
+ 发布后的 npm 包包含:
407
+
408
+ - `dist/index.js`
409
+ - `dist/index.cjs`
410
+ - `dist/index.d.ts`
411
+ - `dist/style.css`
412
+ - `README.md`
413
+ - `LICENSE`
414
+
415
+ 发布前可通过以下命令确认打包文件:
416
+
417
+ ```bash
418
+ npm pack --dry-run
419
+ ```
420
+
421
+ ## 贡献
422
+
423
+ 欢迎提交 issue 和 pull request。请尽量保持改动聚焦,并为会影响编辑器输出、浏览器交互、组件行为或公共 API 的变更补充测试。
424
+
425
+ 建议检查项:
426
+
427
+ ```bash
428
+ pnpm run check
429
+ pnpm run test:unit
430
+ pnpm run test:e2e
431
+ ```
432
+
433
+ ## 许可证
434
+
435
+ Apache-2.0