release: v0.1.1 — bug fixes, CSS scoping, parser improvements

Bug Fixes:
- fix(core): insert() replace param was non-functional due to identical ternary branches
- fix(types): correct project URL typo (MetonaToast → MetonaEditor)

Improvements:
- feat(core): scope CSS theme variables to .me-wrapper per-instance, preventing global style pollution
- feat(themes): add optional target parameter to setThemeVariables() for element-scoped theming
- perf(parser): improve bold/strikethrough regex to support inline delimiter chars (e.g. **a*b**, ~~a~b~~)
- fix(parser): prevent *** cross-tag nesting by requiring first content char ≠ delimiter
- docs(animations): clarify module purpose as future-use animation metadata registry

Tests:
- test(core): add 2 cases for insert() replace:true / replace:false behavior
- All 409 tests passing (+2 new)

Chores:
- bump version 0.1.0 → 0.1.1 across all source files, package.json, README, and demo
This commit is contained in:
2026-07-23 20:02:04 +08:00
parent 83357c3f22
commit 9e0c1d7a7f
18 changed files with 55 additions and 31 deletions
+9 -4
View File
@@ -1,7 +1,7 @@
/**
* MetonaEditor Core - 编辑器核心
* @module core
* @version 0.1.0
* @version 0.1.1
* @description MarkdownEditor 类实现:DOM 构建、事件、渲染、历史栈、选区操作、模式切换
*/
@@ -11,7 +11,7 @@ import { injectStyles } from './styles.js';
import { t as i18nT, getCurrentLocale, getLocaleDirection } from './i18n.js';
import { parseMarkdown } from './parser.js';
import { presetPlugins } from './plugins.js';
import { getTheme, applyTheme, saveTheme } from './themes.js';
import { getTheme, applyTheme, saveTheme, getThemeConfig, setThemeVariables } from './themes.js';
const MODES = ['edit', 'split', 'preview'];
@@ -104,6 +104,10 @@ class MarkdownEditor {
saveTheme(this.config.theme);
}
// 将 CSS 变量限定到当前实例的 wrapper 元素,避免污染全局样式
const resolvedThemeConfig = getThemeConfig(this.config.theme);
setThemeVariables(resolvedThemeConfig, this.el);
this._buildToolbar();
this._bindEvents();
@@ -773,8 +777,9 @@ class MarkdownEditor {
const ta = this.textarea;
const start = ta.selectionStart;
const end = ta.selectionEnd;
const replace = opts.replace || false;
ta.value = ta.value.slice(0, replace ? start : start) + text + ta.value.slice(replace ? end : end);
const replace = opts.replace === true;
// replace=true: 替换选区内容;replace=false: 在光标处插入,保留选区
ta.value = ta.value.slice(0, start) + text + ta.value.slice(replace ? end : start);
ta.focus();
const pos = start + text.length;
ta.selectionStart = ta.selectionEnd = pos;