mirror of
https://github.com/raven-pensieve/obsidian-ace-code-editor.git
synced 2026-07-22 05:48:56 +00:00
* refactor: 移除未使用的依赖项 移除项目中未使用的依赖项,包括 dotenv、 builtin-modules、fs-extra、jsonfile 和 universalify。这些依赖项不再被代码使用, 移除它们可以减少项目体积并简化依赖管理。 * refactor: 迁移 ESLint 配置到新版本 将 ESLint 配置迁移到最新的扁平化配置格式, 使用 defineConfig 和 globalIgnores 简化配置 结构。更新 TypeScript 解析器为 typescript-eslint 包,提取 Obsidian 全局变量为常量以提高可维护 性。调整测试环境从 Jest 改为 Mocha,并添加 React 全局变量支持。 * feat: 添加编辑器样式和调整大小光标 添加隐藏的字体测试元素样式用于测量字体 尺寸。添加调整大小状态样式以在拖动时显示 正确的光标和禁用文本选择。这些样式改进 了编辑器的用户交互体验。 * feat: 使用全局对象调用计时和动画函数 将所有 setTimeout、requestAnimationFrame 和 document.createElement 调用改为使用全局对象 (window 或 activeDocument) 来调用。这样做是为了 提高代码的可测试性和兼容性,使得在测试环境中能够 更容易地 mock 这些全局函数,同时确保在不同的执行 上下文中都能正确地访问这些 API。 * feat: 使用 activeDocument 替换全局 document 将所有全局 document 引用替换为 activeDocument,以支持 多文档环境。这包括事件监听器、DOM 操作和样式管理。 主要改动: - Minimap 和 useResize 中的事件监听使用 activeDocument - 将 useResize 中的内联样式改为 CSS 类名管理 - isFontAvailable 函数改用 Canvas API 替代 DOM 测试 - AceService 和 Select 组件中的 DOM 查询使用 activeDocument - 使用 window.requestAnimationFrame 替代全局引用 这些改动提高了代码的可移植性和多文档支持能力。 * feat: 更新设置视图的显示文本 修改 SettingsView 组件中 getDisplayText 方法返回的 文本内容,将显示文本从 "ACE SettingTab" 更新为 "Ace settingtab",以保持与应用命名规范的一致性。 * style: 修复代码格式和样式问题 修复多个文件中的代码格式问题,包括函数参数和 依赖数组末尾的逗号缺失。优化 CSS 选择器特异性 以确保 Ace 搜索框样式正确应用,并移除不必要的 !important 声明。这些改动提高了代码的一致性 和可维护性。 * feat: 移除 ace-builds esm-resolver 导入 移除了 ace-builds 的 esm-resolver 导入语句,因为该模块 在当前环境中不需要自动处理模块路径。同时简化了 AceService 构造函数,移除了不必要的注释说明。这些 改动使代码更加简洁,减少了不必要的依赖。
59 lines
1.2 KiB
JavaScript
59 lines
1.2 KiB
JavaScript
import eslint from "@eslint/js";
|
|
import obsidianmd from "eslint-plugin-obsidianmd";
|
|
import { defineConfig, globalIgnores } from "eslint/config";
|
|
import globals from "globals";
|
|
import tseslint from "typescript-eslint";
|
|
|
|
const obsidianGlobals = {
|
|
createEl: "readonly",
|
|
createDiv: "readonly",
|
|
createSpan: "readonly",
|
|
createSvg: "readonly",
|
|
createFragment: "readonly",
|
|
activeDocument: "readonly",
|
|
activeWindow: "readonly",
|
|
};
|
|
|
|
export default defineConfig([
|
|
eslint.configs.recommended,
|
|
...tseslint.configs.recommended,
|
|
{
|
|
languageOptions: {
|
|
globals: {
|
|
...globals.browser,
|
|
...obsidianGlobals,
|
|
...globals.mocha,
|
|
React: "readonly",
|
|
},
|
|
parserOptions: {
|
|
projectService: {
|
|
allowDefaultProject: [
|
|
"eslint.config.mjs",
|
|
"manifest.json",
|
|
"package.json",
|
|
"tsconfig.json",
|
|
],
|
|
},
|
|
tsconfigRootDir: import.meta.dirname,
|
|
extraFileExtensions: [".json"],
|
|
},
|
|
},
|
|
},
|
|
...obsidianmd.configs.recommended,
|
|
{
|
|
files: ["**/*.json"],
|
|
rules: {
|
|
"obsidianmd/no-plugin-as-component": "off",
|
|
"@typescript-eslint/no-unused-expressions": "off",
|
|
},
|
|
},
|
|
globalIgnores([
|
|
"node_modules",
|
|
"dist",
|
|
".obsidian-cache",
|
|
".vscode",
|
|
"versions.json",
|
|
"main.js",
|
|
"package-lock.json",
|
|
]),
|
|
]);
|