mirror of
https://github.com/raven-pensieve/obsidian-ace-code-editor.git
synced 2026-07-22 05:48:56 +00:00
feat: 统一使用路径别名将工程中的相对/相对路径导入改统一的路径别名 (#45)
@src 和 @styles),并更新 tsconfig 中的 paths 配置以支持这些 别名。主要修改集中在多个组件、hook、service 和 i18n 文件的 import 语句,替换原先的 "@/src/..." 等路径为 "@src/..." 或 "@styles/..."。此外调整了 SettingsStore 的导入位置以保持一 致性。 这样做的原因是简化模块导入、提高代码可读性并避免相对路 径带来的维护成本,方便重构和移动文件时不需大量修改导入 路径。
This commit is contained in:
parent
81275639ba
commit
27ed130899
36 changed files with 69 additions and 71 deletions
|
|
@ -1,5 +1,5 @@
|
|||
import { t } from "@/src/i18n/i18n";
|
||||
import AceCodeEditorPlugin from "@/src/main";
|
||||
import { t } from "@src/i18n/i18n";
|
||||
import AceCodeEditorPlugin from "@src/main";
|
||||
import { Modal } from "obsidian";
|
||||
import * as React from "react";
|
||||
import { createRoot, Root } from "react-dom/client";
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import AceCodeEditorPlugin from "@/src/main";
|
||||
import AceCodeEditorPlugin from "@src/main";
|
||||
import { X } from "lucide-react";
|
||||
import { App, Modal } from "obsidian";
|
||||
import * as React from "react";
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { Input } from "@/src/component/input/Input";
|
||||
import { Select } from "@/src/component/select/Select";
|
||||
import { useModal } from "@/src/hooks/useModal";
|
||||
import { t } from "@/src/i18n/i18n";
|
||||
import { Input } from "@src/component/input/Input";
|
||||
import { Select } from "@src/component/select/Select";
|
||||
import { useModal } from "@src/hooks/useModal";
|
||||
import { t } from "@src/i18n/i18n";
|
||||
import { normalizePath, Notice } from "obsidian";
|
||||
import * as React from "react";
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { useModal } from "@/src/hooks/useModal";
|
||||
import { t } from "@/src/i18n/i18n";
|
||||
import { AceService } from "@/src/service/AceService";
|
||||
import { ICodeEditorConfig } from "@/src/type/types";
|
||||
import { useModal } from "@src/hooks/useModal";
|
||||
import { t } from "@src/i18n/i18n";
|
||||
import { AceService } from "@src/service/AceService";
|
||||
import { ICodeEditorConfig } from "@src/type/types";
|
||||
import { Ace } from "ace-builds";
|
||||
import * as React from "react";
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
import { t } from "@/src/i18n/i18n";
|
||||
import { t } from "@src/i18n/i18n";
|
||||
import {
|
||||
AceDarkThemesList,
|
||||
AceKeyboardList,
|
||||
AceLightThemesList,
|
||||
} from "@/src/service/AceThemes";
|
||||
import { ICodeEditorConfig } from "@/src/type/types";
|
||||
} from "@src/service/AceThemes";
|
||||
import { ICodeEditorConfig } from "@src/type/types";
|
||||
import { App } from "obsidian";
|
||||
import {
|
||||
ConfigOption,
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
import { ConfirmDialog } from "@/src/component/confirm-dialog/ConfirmDialog";
|
||||
import { Input } from "@/src/component/input/Input";
|
||||
import { Toggle } from "@/src/component/toggle/Toggle";
|
||||
import { useModal } from "@/src/hooks/useModal";
|
||||
import { t } from "@/src/i18n/i18n";
|
||||
import { ConfirmDialog } from "@src/component/confirm-dialog/ConfirmDialog";
|
||||
import { Input } from "@src/component/input/Input";
|
||||
import { Toggle } from "@src/component/toggle/Toggle";
|
||||
import { useModal } from "@src/hooks/useModal";
|
||||
import { t } from "@src/i18n/i18n";
|
||||
import {
|
||||
Code2,
|
||||
FilePlus2,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import SettingsStore from "@src/settings/SettingsStore";
|
||||
import { createContext } from "react";
|
||||
import SettingsStore from "../settings/SettingsStore";
|
||||
|
||||
export const SettingsStoreContext = createContext<SettingsStore | undefined>(
|
||||
undefined
|
||||
|
|
|
|||
|
|
@ -1,7 +1,4 @@
|
|||
import {
|
||||
ModalContext,
|
||||
ModalContextType,
|
||||
} from "@/src/component/modal/BaseModal";
|
||||
import { ModalContext, ModalContextType } from "@src/component/modal/BaseModal";
|
||||
import * as React from "react";
|
||||
|
||||
// Custom hook to access modal context
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import SettingsStore from "@src/settings/SettingsStore";
|
||||
import { ICodeEditorConfig } from "@src/type/types";
|
||||
import { useSyncExternalStore } from "react";
|
||||
import SettingsStore from "../settings/SettingsStore";
|
||||
import { ICodeEditorConfig } from "../type/types";
|
||||
|
||||
export default function usePluginSettings(
|
||||
settingsStore: SettingsStore
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import AceCodeEditorPlugin from "@/src/main";
|
||||
import { ICodeEditorConfig } from "@/src/type/types";
|
||||
import AceCodeEditorPlugin from "@src/main";
|
||||
import { ICodeEditorConfig } from "@src/type/types";
|
||||
import * as React from "react";
|
||||
|
||||
export const SettingsBus = {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { SettingsStoreContext } from "@src/context/SettingsStoreContext";
|
||||
import SettingsStore from "@src/settings/SettingsStore";
|
||||
import { useContext } from "react";
|
||||
import { SettingsStoreContext } from "../context/SettingsStoreContext";
|
||||
import SettingsStore from "../settings/SettingsStore";
|
||||
|
||||
export default function useSettingsStore(): SettingsStore {
|
||||
const store = useContext(SettingsStoreContext);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { BaseMessage } from "../types";
|
||||
import { BaseMessage } from "@src/i18n/types";
|
||||
|
||||
const translations: BaseMessage = {
|
||||
common: {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { BaseMessage } from "../types";
|
||||
import { BaseMessage } from "@src/i18n/types";
|
||||
|
||||
const translations: BaseMessage = {
|
||||
common: {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { BaseMessage } from "../types";
|
||||
import { BaseMessage } from "@src/i18n/types";
|
||||
|
||||
const translations: BaseMessage = {
|
||||
common: {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import "@/style/styles";
|
||||
import "@styles/styles";
|
||||
import { Editor, Menu, Plugin, setIcon, TFile, TFolder } from "obsidian";
|
||||
import { BaseModal } from "./component/modal/BaseModal";
|
||||
import { QuickConfigModal } from "./component/modal/QuickConfigModal";
|
||||
|
|
|
|||
|
|
@ -12,8 +12,8 @@ import "./AceExtensions";
|
|||
// import "ace-builds/src-noconflict/keybinding-vim";
|
||||
// import "ace-builds/src-noconflict/keybinding-vscode";
|
||||
|
||||
import { ICodeEditorConfig, LineRange } from "@/src/type/types";
|
||||
import { extractLineRange } from "@/src/utils/LineRange";
|
||||
import { ICodeEditorConfig, LineRange } from "@src/type/types";
|
||||
import { extractLineRange } from "@src/utils/LineRange";
|
||||
import { getLanguageMode } from "./AceLanguages";
|
||||
import { getAceTheme } from "./AceThemes";
|
||||
|
||||
|
|
|
|||
|
|
@ -1,22 +1,22 @@
|
|||
import { IconPicker } from "@/src/component/icon-picker/IconPicker";
|
||||
import { Input } from "@/src/component/input/Input";
|
||||
import { Select } from "@/src/component/select/Select";
|
||||
import { TabNav, TabNavItem } from "@/src/component/tab-nav/TabNav";
|
||||
import { TagInput } from "@/src/component/tag-input/TagInput";
|
||||
import { Toggle } from "@/src/component/toggle/Toggle";
|
||||
import { t } from "@/src/i18n/i18n";
|
||||
import AceCodeEditorPlugin from "@/src/main";
|
||||
import { languageModeMap } from "@/src/service/AceLanguages";
|
||||
import { IconPicker } from "@src/component/icon-picker/IconPicker";
|
||||
import { Input } from "@src/component/input/Input";
|
||||
import { Select } from "@src/component/select/Select";
|
||||
import { TabNav, TabNavItem } from "@src/component/tab-nav/TabNav";
|
||||
import { TagInput } from "@src/component/tag-input/TagInput";
|
||||
import { Toggle } from "@src/component/toggle/Toggle";
|
||||
import usePluginSettings from "@src/hooks/usePluginSettings";
|
||||
import useSettingsStore from "@src/hooks/useSettingsStore";
|
||||
import { t } from "@src/i18n/i18n";
|
||||
import AceCodeEditorPlugin from "@src/main";
|
||||
import { languageModeMap } from "@src/service/AceLanguages";
|
||||
import {
|
||||
AceDarkThemesList,
|
||||
AceKeyboardList,
|
||||
AceLightThemesList,
|
||||
} from "@/src/service/AceThemes";
|
||||
} from "@src/service/AceThemes";
|
||||
import parse from "html-react-parser";
|
||||
import { Notice, Platform } from "obsidian";
|
||||
import * as React from "react";
|
||||
import usePluginSettings from "../hooks/usePluginSettings";
|
||||
import useSettingsStore from "../hooks/useSettingsStore";
|
||||
import { SettingsItem } from "./item/SettingItem";
|
||||
|
||||
interface FontData {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import AceCodeEditorPlugin from "../main";
|
||||
import { DEFAULT_CONFIG, ICodeEditorConfig } from "../type/types";
|
||||
import AceCodeEditorPlugin from "@src/main";
|
||||
import { DEFAULT_CONFIG, ICodeEditorConfig } from "@src/type/types";
|
||||
|
||||
export default class SettingsStore {
|
||||
#plugin: AceCodeEditorPlugin;
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
import AceCodeEditorPlugin from "@/src/main";
|
||||
import { SettingsStoreContext } from "@src/context/SettingsStoreContext";
|
||||
import AceCodeEditorPlugin from "@src/main";
|
||||
import { App, PluginSettingTab } from "obsidian";
|
||||
import * as React from "react";
|
||||
import { createRoot, Root } from "react-dom/client";
|
||||
import { SettingsStoreContext } from "../context/SettingsStoreContext";
|
||||
import { AceSettings } from "./AceSettings";
|
||||
|
||||
export default class AceCodeEditorSettingTab extends PluginSettingTab {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import AceCodeEditorPlugin from "@/src/main";
|
||||
import AceCodeEditorPlugin from "@src/main";
|
||||
import { Component } from "obsidian";
|
||||
|
||||
export class AcePluginComponent extends Component {
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import {
|
|||
AceDarkThemes,
|
||||
AceKeyboard,
|
||||
AceLightThemes,
|
||||
} from "@/src/service/AceThemes";
|
||||
} from "@src/service/AceThemes";
|
||||
|
||||
export const CODE_EDITOR_VIEW_TYPE = "ace-code-editor";
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { getLanguageMode } from "@/src/service/AceLanguages";
|
||||
import { ICodeBlock } from "@/src/type/types";
|
||||
import { getLanguageMode } from "@src/service/AceLanguages";
|
||||
import { ICodeBlock } from "@src/type/types";
|
||||
import { App, Editor, EditorPosition, MarkdownView } from "obsidian";
|
||||
|
||||
export async function getCodeBlockAtCursor(
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import type AceCodeEditorPlugin from "@/src/main";
|
||||
import { AceService } from "@/src/service/AceService";
|
||||
import { CODE_EDITOR_VIEW_TYPE, ICodeEditorConfig } from "@/src/type/types";
|
||||
import { ObsidianUtils } from "@/src/utils/ObsidianUtils";
|
||||
import type AceCodeEditorPlugin from "@src/main";
|
||||
import { AceService } from "@src/service/AceService";
|
||||
import { CODE_EDITOR_VIEW_TYPE, ICodeEditorConfig } from "@src/type/types";
|
||||
import { ObsidianUtils } from "@src/utils/ObsidianUtils";
|
||||
import { IconName, Scope, TextFileView, TFile, WorkspaceLeaf } from "obsidian";
|
||||
|
||||
export class CodeEditorView extends TextFileView {
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
import { useSettings } from "@/src/hooks/useSettings";
|
||||
import AceCodeEditorPlugin from "@/src/main";
|
||||
import { getLanguageMode } from "@/src/service/AceLanguages";
|
||||
import { AceService } from "@/src/service/AceService";
|
||||
import { AcePluginComponent } from "@/src/type/component";
|
||||
import { Embed } from "@/src/type/obsidian-extend";
|
||||
import { LineRange } from "@/src/type/types";
|
||||
import { parseLinkWithRange } from "@/src/utils/LineRange";
|
||||
import { useSettings } from "@src/hooks/useSettings";
|
||||
import AceCodeEditorPlugin from "@src/main";
|
||||
import { getLanguageMode } from "@src/service/AceLanguages";
|
||||
import { AceService } from "@src/service/AceService";
|
||||
import { AcePluginComponent } from "@src/type/component";
|
||||
import { Embed } from "@src/type/obsidian-extend";
|
||||
import { LineRange } from "@src/type/types";
|
||||
import { parseLinkWithRange } from "@src/utils/LineRange";
|
||||
import { Ace } from "ace-builds";
|
||||
import { Maximize2 } from "lucide-react";
|
||||
import { TFile } from "obsidian";
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import AceCodeEditorPlugin from "@/src/main";
|
||||
import { AceSettings } from "@/src/settings/AceSettings";
|
||||
import AceCodeEditorPlugin from "@src/main";
|
||||
import { AceSettings } from "@src/settings/AceSettings";
|
||||
import { IconName, ItemView, WorkspaceLeaf } from "obsidian";
|
||||
import * as React from "react";
|
||||
import { createRoot, Root } from "react-dom/client";
|
||||
|
|
|
|||
|
|
@ -14,7 +14,8 @@
|
|||
"jsx": "react-jsx",
|
||||
"lib": ["DOM", "ES5", "ES6", "ES2017", "ES2018", "ES2019", "ES2020"],
|
||||
"paths": {
|
||||
"@/*": ["./*"]
|
||||
"@src/*": ["src/*"],
|
||||
"@styles/*": ["styles/*"]
|
||||
},
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in a new issue