A CodeMirror 6 based rule editor with Regex validation, search, and theme switching.
هذه إصدارات لهذا البرنامج النصي حيث تم تحديث الكود. عرض كل الإصدارات.
本次更新将编辑器重构为标准的 全局类(RuleEditor),改进了 API 设计,并增加了生命周期销毁与快照还原等功能。
RuleEditor
window.CodeMirror6.createEditor(target)
new RuleEditor(parent, options)
setTheme(isDark)
editor.darkMode = true / false
getRules()
regexps
regexes
options
new RuleEditor(container, { content: '...', darkMode: true })
restoreToSnapshot
restoreToSnapshot()
destroy
destroy()
旧版代码:
const editor = window.CodeMirror6.createEditor(document.getElementById('editor')); editor.setContent('...'); editor.setTheme(true);
新版代码(IIFE):
// 直接使用全局 RuleEditor 类 const editor = new RuleEditor(document.getElementById('editor'), { content: '...', darkMode: true }); // 主题切换 editor.darkMode = false; // 页面/组件销毁时 editor.destroy();