From 23cf742569a8dada7f5763e0db7512f363e52b14 Mon Sep 17 00:00:00 2001 From: oqyude Date: Sat, 11 Jul 2026 03:05:42 +0300 Subject: [PATCH] license and fixup --- LICENSE | 21 +++++++++++ README.md | 89 ++++++++++++++++++++++++++++---------------- src/locales/index.ts | 2 +- tsconfig.json | 3 +- 4 files changed, 80 insertions(+), 35 deletions(-) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..14fac91 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2026 + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md index 1bb6697..779fea9 100644 --- a/README.md +++ b/README.md @@ -2,35 +2,71 @@ Модульный плагин для **Obsidian** с набором QoL-функций, которые можно включать и отключать в настройках. -## Установка +Modular **Obsidian** plugin with toggleable QoL modules in settings. + +## Установка / Installation 1. Скачайте `main.js`, `manifest.json` и `styles.css` из [релизов](https://github.com/your/repo/releases) 2. Поместите их в папку `.obsidian/plugins/zeroq-qol-modules/` вашего хранилища 3. В Obsidian: **Настройки** → **Community plugins** → **Включить** 4. Активируйте плагин **ZeroQ QoL Modules** -## Модули +## Язык / Language -| Модуль | Описание | -|--------|----------| -| **Attachment Clean Paste** | Заменяет `![[вложение]]` на `[[вложение|имя]]` при вставке/перетаскивании файлов с указанными расширениями | +Язык плагина синхронизируется с **языком интерфейса Obsidian** (Settings → About → Language). + +- Obsidian на русском → плагин на русском +- Obsidian на другом языке → плагин на английском + +The plugin language syncs with **Obsidian's UI language** setting. + +- Obsidian in English → plugin in English +- Obsidian in any other language → falls back to English + +## Модули / Modules + +- **Attachment Clean Paste** — Заменяет `![[embed]]` на `[[path/file|name]]` для файлов с указанными расширениями при вставке/перетаскивании Каждый модуль включается/отключается в настройках плагина. -## Разработка +## Разработка / Development -### Добавление нового модуля +### Архитектура / Architecture + +``` +src/ +├── main.ts # точка входа, Plugin class +├── settings.ts # общая панель настроек +├── types.ts # базовые типы +├── locales/ +│ ├── en.ts # тип Locale + EN-словарь +│ ├── ru.ts # RU-словарь +│ └── index.ts # авто-определение языка +└── modules/ + ├── index.ts # реестр модулей (статический импорт) + ├── base-module.ts # абстрактный класс модуля + └── attachment-clean-paste/ + └── index.ts # реализация модуля +``` + +**Принцип работы:** +- `main.ts` загружает настройки, итерирует `MODULES` и вызывает `onload()` для включённых +- Каждый модуль через `registerCleanup()` регистрирует функции очистки, которые вызываются при выключении модуля или выгрузке плагина +- В настройках отображаются все модули с чекбоксами вкл/выкл + +### Добавление нового модуля / Adding a module 1. Создайте папку `src/modules/my-module/` 2. Создайте класс, унаследованный от `BaseModule`: ```typescript import { BaseModule } from '../base-module'; +import { locale } from '../../locales'; export class MyModule extends BaseModule { id = 'my-module'; - name = 'My Module'; - description = 'Описание модуля'; + name = locale.modules['my-module'].name; + description = locale.modules['my-module'].description; get defaultSettings() { return { /* настройки по умолчанию */ }; @@ -46,7 +82,8 @@ export class MyModule extends BaseModule { } ``` -3. Зарегистрируйте модуль в `src/modules/index.ts`: +3. Добавьте переводы в `src/locales/en.ts` и `src/locales/ru.ts` +4. Зарегистрируйте модуль в `src/modules/index.ts`: ```typescript import { MyModule } from './my-module'; @@ -57,34 +94,22 @@ export const MODULES: QoLModule[] = [ ]; ``` -4. Если модулю нужна своя вкладка настроек — создайте `PluginSettingTab` и добавьте её через `plugin.addSettingTab()` в `onload` +### Добавление нового языка / Adding a language -### Сборка +1. Создайте `src/locales/de.ts` со структурой `Locale` +2. Импортируйте и добавьте в словарь в `src/locales/index.ts`: +```typescript +import { de } from './de'; +const locales: Record = { en, ru, de }; +``` + +### Сборка / Build ```bash npm run build # production-сборка npm run dev # dev-сборка с sourcemap ``` -### Архитектура - -``` -src/ -├── main.ts # точка входа, Plugin class -├── settings.ts # общая панель настроек -├── types.ts # базовые типы -└── modules/ - ├── index.ts # реестр модулей (статический импорт) - ├── base-module.ts # абстрактный класс модуля - └── attachment-clean-paste/ - └── index.ts # реализация модуля -``` - -**Принцип работы:** -- `main.ts` загружает настройки, итерирует `MODULES` и вызывает `onload()` для включённых -- Каждый модуль через `registerCleanup()` регистрирует функции отчистки, которые вызываются при выключении модуля или выгрузке плагина -- В настройках отображаются все модули с чекбоксами вкл/выкл - -## Лицензия +## Лицензия / License MIT diff --git a/src/locales/index.ts b/src/locales/index.ts index 809159a..050c566 100644 --- a/src/locales/index.ts +++ b/src/locales/index.ts @@ -4,7 +4,7 @@ import { ru } from './ru'; const locales: Record = { en, ru }; function detectLocale(): Locale { - const lang = (navigator.language || 'en').slice(0, 2); + const lang = (document.documentElement.lang || 'en').slice(0, 2); return locales[lang] || en; } diff --git a/tsconfig.json b/tsconfig.json index 363092e..b199296 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,13 +1,12 @@ { "compilerOptions": { - "baseUrl": ".", "inlineSourceMap": true, "inlineSources": true, "module": "ESNext", "target": "ES6", "allowJs": true, "noImplicitAny": true, - "moduleResolution": "node", + "moduleResolution": "bundler", "importHelpers": true, "lib": ["DOM", "ES5", "ES6", "ES7"], "allowSyntheticDefaultImports": true,