diff --git a/CHANGELOG.md b/CHANGELOG.md index ded6dd5..d66f6bb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,24 @@ All notable changes to MetonaEditor will be documented in this file. +## [0.4.1] - 2026-08-11 + +### Added +- **`zenMaxWidth` 配置项**: Zen 专注模式内容区宽度可配置(`number` 为 px / `string` 原样作为 CSS 值 / `false` 不限制),默认由硬编码 820px 提升至 960px,经 CSS 变量 `--md-zen-max-width` 实现实例级隔离。 +- **运行时 API**: `editor.setZenMaxWidth(width)` / `editor.getZenMaxWidth()` 随时调整专注模式宽度。 + +### Fixed +- **`wordWrap: false` 配置不生效**: 构造函数此前将 `_wordWrap` 硬编码为 `true`,忽略配置项,导致初始仍自动换行;现读取配置并在构建时应用 `white-space: pre`。 +- **`outline: true` 启动时不显示大纲面板**: 构造函数此前只注册滚动跟踪、未构建面板,须等首次输入才出现;现构造后自动构建,且 `setMode()` 切换回预览类模式时同步重建。 +- **edit 模式初始行号不渲染**: `_render()` 在 edit 模式直接返回导致 gutter 为空;现 edit 模式也维护行号装订线。 +- **exportTool 卸载泄漏**: `unuse('exportTool')` / `destroy()` 此前不清理挂载在实例上的 `exportMarkdown` / `exportHTML` / `exportPDF` 方法;现卸载时一并删除。 +- **searchReplace 替换后字数统计过期**: `replaceOne` / `replaceAll` 直接改值后未刷新状态栏统计;现调用 `_updateWordCount()`。 + +### Added +- 回归测试 15 个(zenMaxWidth 默认/数字/字符串/false/运行时更新/启动应用、wordWrap: false 生效、outline 构造自动构建与模式切换重建、edit/preview 模式初始行号、exportTool 卸载清理),总数 826 → 841。 + +--- + ## [0.4.0] - 2026-08-11 ### Added diff --git a/README.md b/README.md index 530a55f..08cd68e 100644 --- a/README.md +++ b/README.md @@ -2,9 +2,9 @@ > TypeScript 重构 · 零运行时依赖 · 轻量级桌面端 Markdown Editor 库 -[![version](https://img.shields.io/badge/version-0.4.0-blue)](https://git.metona.cn/MetonaTeam/-/packages/npm/@metona-team%2Fmetona-editor) +[![version](https://img.shields.io/badge/version-0.4.1-blue)](https://git.metona.cn/MetonaTeam/-/packages/npm/@metona-team%2Fmetona-editor) [![license](https://img.shields.io/badge/license-MIT-green)](./LICENSE) -[![tests](https://img.shields.io/badge/tests-826%20passed-brightgreen)](./tests) +[![tests](https://img.shields.io/badge/tests-841%20passed-brightgreen)](./tests) [![coverage](https://img.shields.io/badge/coverage-parser%2099%25-brightgreen)](./tests) [![types](https://img.shields.io/badge/types-TypeScript%20strict-blue)](./tsconfig.json) @@ -17,11 +17,11 @@ - **三模式视图** — edit / split / preview,拖拽分隔条调整比例,双向滚动同步 - **主题系统** — light / dark / warm / auto,CSS 变量可定制,实例级隔离,主题继承,外部跟随 - **国际化** — zh-CN / en-US / ja / ko / fr / de 六种语言完整翻译,实例级语言隔离,远程加载翻译包 -- **编辑体验** — 行号装订线、智能 Enter、括号自动闭合、拖放文件、大纲面板、Zen 专注模式、右键上下文菜单 +- **编辑体验** — 行号装订线、智能 Enter、括号自动闭合、拖放文件、大纲面板、Zen 专注模式(宽度可配置,默认 960px)、右键上下文菜单 - **内置语法高亮** — 零依赖轻量高亮器,js/ts/python/bash/css/html 等 16 个语言标识,规则缓存零重建开销,`MeEditor.highlight` 即插即用 - **性能** — 字数 / 词数 / 行数差异增量统计,击键零全量扫描;大纲 O(n) 线性构建,长文档即时响应 - **安全** — HTML 转义,XSS 协议过滤(javascript / vbscript / file / data),属性级注入防护(含脚注 id),白名单裸标签透传,sanitize 钩子 -- **工程化** — 826 个单元测试 + Playwright 真实浏览器冒烟测试,CI 并行 4 job,`sideEffects: false` 便于 tree-shaking +- **工程化** — 841 个单元测试 + Playwright 真实浏览器冒烟测试,CI 并行 4 job,`sideEffects: false` 便于 tree-shaking - **桌面端优先** — 纯电脑端设计,无移动端冗余代码 - **引用链接** — 支持 `[text][ref]` / `![alt][ref]` 引用式链接和图片,含 title 属性 - **RTL 支持** — 完整的从右到左布局适配(阿拉伯语、希伯来语等) @@ -79,10 +79,10 @@ const editor = MeEditor.create('#editor', { mode: 'split' }); ```html - + - + @@ -144,6 +144,7 @@ MeEditor.create(container, { syncScroll: true, // 分屏同步滚动 autoBrackets: true, // 括号自动闭合 zenMode: false, // 启动即进入 Zen 专注模式 + zenMaxWidth: 960, // Zen 内容区最大宽度:数字为 px / 字符串原样作为 CSS 值 / false 不限制 wordWrap: true, // 自动换行 maxLength: 0, // 最大字符数(0=不限) floatingToolbar: true, // 选中文本浮动格式栏 @@ -346,6 +347,8 @@ editor.removeToolbarButton(action: string): this ```typescript editor.toggleZen(): this editor.isZen(): boolean +editor.setZenMaxWidth(width: number | string | false): this // 运行时调整专注模式宽度 +editor.getZenMaxWidth(): number | string | false editor.toggleWordWrap(): this editor.setWordWrap(on: boolean): this editor.isWordWrap(): boolean @@ -809,7 +812,7 @@ src/ |------|------| | 语言 | TypeScript 5 (strict) | | 构建 | Rollup 3 | -| 测试 | Jest 29 + jsdom(826 用例) | +| 测试 | Jest 29 + jsdom(841 用例) | | 浏览器冒烟 | Playwright + Chromium(22 项断言) | | 类型生成 | rollup-plugin-dts | | 零运行时依赖 | ✅ | diff --git a/package.json b/package.json index 512d446..d2bdcb3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@metona-team/metona-editor", - "version": "0.4.0", + "version": "0.4.1", "description": "Type-safe, lightweight, zero-dependency Markdown Editor. Desktop-first. React-free. Single-file bundle.", "type": "module", "main": "dist/metona-editor.cjs", diff --git a/site/demo.html b/site/demo.html index c454678..0bc9b5a 100644 --- a/site/demo.html +++ b/site/demo.html @@ -4,7 +4,7 @@ -MetonaEditor v0.4.0 — 全功能演示 +MetonaEditor v0.4.1 — 全功能演示