Skip to content

Commit f1e11af

Browse files
committed
replacing entire plugin with obsidian-dictionary making it a new starting point.
1 parent 17771c5 commit f1e11af

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+3940
-75
lines changed

LICENSE

Lines changed: 661 additions & 0 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 72 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,89 @@
1-
## Obsidian Sample Plugin
1+
<img align="right" width="550" src="https://media.discordapp.net/attachments/796853434397360128/847198380878069771/Screen_Shot_2021-05-26_at_12.43.43_PM.png?width=736&height=676">
22

3-
This is a sample plugin for Obsidian (https://obsidian.md).
3+
# Obsidian Dictionary Plugin [![GitHub tag (Latest by date)](https://img.shields.io/github/v/tag/phibr0/obsidian-dictionary)](https://github.com/phibr0/obsidian-dictionary/releases) ![GitHub all releases](https://img.shields.io/github/downloads/phibr0/obsidian-dictionary/total)
44

5-
This project uses Typescript to provide type checking and documentation.
6-
The repo depends on the latest plugin API (obsidian.d.ts) in Typescript Definition format, which contains TSDoc comments describing what it does.
5+
This Plugin adds a Dictionary to the [Obsidian](https://obsidian.md) Note-Taking tool.
76

8-
**Note:** The Obsidian API is still in early alpha and is subject to change at any time!
7+
## Usage
98

10-
This sample plugin demonstrates some of the basic functionality the plugin API can do.
11-
- Changes the default font color to red using `styles.css`.
12-
- Adds a ribbon icon, which shows a Notice when clicked.
13-
- Adds a command "Open Sample Modal" which opens a Modal.
14-
- Adds a plugin setting tab to the settings page.
15-
- Registers a global click event and output 'click' to the console.
16-
- Registers a global interval which logs 'setInterval' to the console.
9+
Open the *Command Palette* (default: `ctrl` + `p`), search for *Open Dictionary View* and run the command. You will see that a new View appears in the right Sidebar of Obsidian. You can set your default Language in Obsidian's Settings under *Plugin Options* > *Obsidian Dictionary* > *Default Language*.
1710

18-
### First time developing plugins?
11+
## Supported Languages
1912

20-
Quick starting guide for new plugin devs:
13+
The following Languages are currently supported:
2114

22-
- Make a copy of this repo as a template with the "Use this template" button (login to GitHub if you don't see it).
23-
- Clone your repo to a local development folder. For convenience, you can place this folder in your `.obsidian/plugins/your-plugin-name` folder.
24-
- Install NodeJS, then run `npm i` in the command line under your repo folder.
25-
- Run `npm run dev` to compile your plugin from `main.ts` to `main.js`.
26-
- Make changes to `main.ts` (or create new `.ts` files). Those changes should be automatically compiled into `main.js`.
27-
- Reload Obsidian to load the new version of your plugin.
28-
- Enable plugin in settings window.
29-
- For updates to the Obsidian API run `npm update` in the command line under your repo folder.
15+
| Language | Synonym Popover | Sidebar Lookup (Offline Support) | UI Translated? |
16+
|:-------------------- |:---------------:|:--------------:|:-----------:|
17+
| English (US) | 🗸 | 🗸 (🗸) |🗸|
18+
| English (UK) | | 🗸 (🗸) ||
19+
| Hindi | | 🗸 ||
20+
| Spanish | 🗸 | 🗸 ||
21+
| French | 🗸 | 🗸 ||
22+
| Japanese | | 🗸 ||
23+
| Russian | | 🗸 ||
24+
| German | 🗸 | 🗸 |🗸|
25+
| Italian | 🗸 | 🗸 ||
26+
| Korean | | 🗸 ||
27+
| Brazilian Portuguese | | 🗸 ||
28+
| Arabic | | 🗸 ||
29+
| Turkish | | 🗸 | |
30+
| Chinese | | 🗸 (🗸) | 🗸 |
3031

31-
### Releasing new releases
32+
## Offline Dictionary
3233

33-
- Update your `manifest.json` with your new version number, such as `1.0.1`, and the minimum Obsidian version required for your latest release.
34-
- Update your `versions.json` file with `"new-plugin-version": "minimum-obsidian-version"` so older versions of Obsidian can download an older version of your plugin that's compatible.
35-
- Create new GitHub release using your new version number as the "Tag version". Use the exact version number, don't include a prefix `v`. See here for an example: https://github.com/obsidianmd/obsidian-sample-plugin/releases
36-
- Upload the files `manifest.json`, `main.js`, `styles.css` as binary attachments.
37-
- Publish the release.
34+
As of Release 2.13.0 this Plugin has experimental offline Support for English and Chinese. The offline Dictionary is pretty big (about 35 megabytes), which is why it's not bundled with this Plugin by default. It will download the neccessary files **when you are using it for the first time**. That means your first look-up still requires an internet connection.
3835

39-
### Adding your plugin to the community plugin list
36+
## Privacy
4037

41-
- Publish an initial version.
42-
- Make sure you have a `README.md` file in the root of your repo.
43-
- Make a pull request at https://github.com/obsidianmd/obsidian-releases to add your plugin.
38+
This Plugin relies on third-party [API's](https://en.wikipedia.org/wiki/API) to find Definitions, Synonyms, etc. You can select from a Range of API’s and choose which one to trust, the Plugin will not make requests to API’s you didn’t allow it to. To find more Information about the different API’s click the “More Info“ Button in the Settings.
4439

45-
### How to use
40+
If you explicitly activate the **Advanced Synonym Search**, there will be one additional API Call to analyze the *whole* Sentence the selected Word appears in. This will make the suggested Synonyms more accurate based on the context.
4641

47-
- Clone this repo.
48-
- `npm i` or `yarn` to install dependencies
49-
- `npm run dev` to start compilation in watch mode.
42+
Even though this Plugin is fully Open-Source and thus can be looked over by anyone, the third-party API’s might not be.
5043

51-
### Manually installing the plugin
44+
## How to make this Plugin better
5245

53-
- Copy over `main.js`, `styles.css`, `manifest.json` to your vault `VaultFolder/.obsidian/plugins/your-plugin-id/`.
46+
### Translations
5447

55-
### API Documentation
48+
If you want to help and translate this Plugin to new languages, see [locales](https://github.com/phibr0/obsidian-dictionary/tree/master/src/l10n/locale).
5649

57-
See https://github.com/obsidianmd/obsidian-api
50+
### New API's
51+
52+
This Plugin is meant to be easily extensible! If you want to add a new API for a new (or already supported) Language see: [API Manager](src/apiManager.ts).
53+
54+
You will need to create a new class for the new API, which implements [DefinitionProvider](src/api/types.ts) or [SynonymProvider](src/api/types.ts) (or both).
55+
56+
If the Language you are working with doesn't exist yet, add it to the `LANGUAGES` in [_constants.ts](src/_constants.ts).
57+
58+
After that, add the API to the respective List in the [API Manager](src/apiManager.ts) and finally open a Pull Request here on GitHub.
59+
This will automatically make it selectable in the Settings.
60+
61+
> Special Thanks to [@mgmeyers](https://github.com/mgmeyers) for already making this Plugin a lot better!
62+
63+
## Variables
64+
65+
You can edit the Note Template for your local Dictionary in the Settings. Here is a List of Variables you can use:
66+
67+
- `{{notice}}` → "Autogenerated by Obsidian Dictionary" (Localized)
68+
- `{{word}}` → The Word the File is created for
69+
- `{{pronunciationHeader}}` → "Pronunciations" (Localized)
70+
- `{{meaningHeader}}` → Same as above, but for "Meanings" (Localized)
71+
- `{{phoneticList}}` → A List of all phonetics the Plugin found.
72+
- `{{meanings}}` → Same as above, but for meanings the Plugin found.
73+
74+
Localized means, that the Text changes based on Obsidians internal Language.
75+
76+
## How to install
77+
78+
1. Go to **Community Plugins** in your [Obsidian](https://www.obsidian.md) Settings and **disable** Safe Mode
79+
2. Click on **Browse** and search for “Obsidian Dictionary”
80+
3. Click install
81+
4. Toggle the Plugin on in the **Community Plugins** Tab
82+
83+
## Support me
84+
85+
If you find this Plugin helpful, consider supporting me:
86+
87+
<a href="https://www.buymeacoffee.com/phibr0"><img src="https://img.buymeacoffee.com/button-api/?text=Buy me a coffee&emoji=&slug=phibr0&button_colour=5F7FFF&font_colour=ffffff&font_family=Inter&outline_colour=000000&coffee_colour=FFDD00"></a>
88+
89+
> This Plugin relies on the [Free Dictionary API](https://dictionaryapi.dev/) by [meetDeveloper](https://github.com/meetDeveloper). He is providing this API to the public for free and needs help from the community. [**More Information**](https://github.com/meetDeveloper/freeDictionaryAPI#important-note)

dictionary.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

package.json

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,29 @@
1414
"@rollup/plugin-commonjs": "^18.0.0",
1515
"@rollup/plugin-node-resolve": "^11.2.1",
1616
"@rollup/plugin-typescript": "^8.2.1",
17+
"@tsconfig/svelte": "^1.0.13",
1718
"@types/node": "^14.14.37",
18-
"obsidian": "^0.12.0",
19+
"@typescript-eslint/eslint-plugin": "^4.25.0",
20+
"@typescript-eslint/parser": "^4.25.0",
21+
"eslint": "^7.27.0",
1922
"rollup": "^2.32.1",
23+
"rollup-plugin-svelte": "^7.1.0",
24+
"sass": "^1.34.0",
25+
"scss": "^0.2.4",
26+
"svelte": "^3.40.3",
27+
"svelte-check": "^1.4.0",
28+
"svelte-preprocess": "^4.7.0",
2029
"tslib": "^2.2.0",
21-
"typescript": "^4.2.4"
30+
"typescript": "^4.3.2",
31+
"typescript-eslint": "^0.0.1-alpha.0"
32+
},
33+
"moduleFileExtensions": [
34+
"js",
35+
"ts",
36+
"svelte"
37+
],
38+
"dependencies": {
39+
"match-casing": "^2.0.0",
40+
"obsidian": "^0.12.5"
2241
}
2342
}

rollup.config.js

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,38 @@
1-
import typescript from '@rollup/plugin-typescript';
2-
import {nodeResolve} from '@rollup/plugin-node-resolve';
3-
import commonjs from '@rollup/plugin-commonjs';
1+
import svelte from "rollup-plugin-svelte";
2+
import commonjs from "@rollup/plugin-commonjs";
3+
import resolve from "@rollup/plugin-node-resolve";
4+
import autoPreprocess from "svelte-preprocess";
5+
import typescript from "@rollup/plugin-typescript";
46

7+
// eslint-disable-next-line no-undef
58
const isProd = (process.env.BUILD === 'production');
69

710
const banner =
811
`/*
912
THIS IS A GENERATED/BUNDLED FILE BY ROLLUP
10-
if you want to view the source visit the plugins github repository
13+
if you want to view the source visit the plugins github repository (https://github.com/phibr0/obsidian-dictionary)
1114
*/
1215
`;
1316

1417
export default {
15-
input: 'main.ts',
16-
output: {
17-
dir: '.',
18-
sourcemap: 'inline',
19-
sourcemapExcludeSources: isProd,
20-
format: 'cjs',
21-
exports: 'default',
22-
banner,
23-
},
24-
external: ['obsidian'],
25-
plugins: [
26-
typescript(),
27-
nodeResolve({browser: true}),
28-
commonjs(),
29-
]
18+
input: "src/main.ts",
19+
output: {
20+
dir: '.',
21+
sourcemap: isProd ? 'none' : 'inline',
22+
format: 'cjs',
23+
exports: 'default',
24+
banner,
25+
},
26+
external: ["obsidian"],
27+
plugins: [
28+
svelte({
29+
emitCss: false,
30+
preprocess: autoPreprocess(),
31+
}),
32+
typescript(),
33+
resolve({
34+
browser: true,
35+
}),
36+
commonjs(),
37+
],
3038
};

src/_constants.ts

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
import type { DictionaryCache, DictionarySettings } from "src/types";
2+
import t from 'src/l10n/helpers';
3+
4+
export const VIEW_TYPE = 'dictionary-view';
5+
export const VIEW_DISPLAY_TEXT = t('Dictionary');
6+
export const VIEW_ICON = 'quote-glyph';
7+
8+
export const LANGUAGES = {
9+
"en_US": "English (US)",
10+
"hi": "हिन्दी (Hindi)",
11+
"es": "Español (Spanish)",
12+
"fr": "Français (French)",
13+
"ja": "日本語 (Japanese)",
14+
"ru": "Русский (Russian)",
15+
"en_GB": "English (UK)",
16+
"de": "Deutsch (German)",
17+
"it": "Italiano (Italian)",
18+
"ko": "한국어 (Korean)",
19+
"pt_BR": "Português do Brasil (Brazilian Portuguese)",
20+
"ar": "اَلْعَرَبِيَّةُ‎ (Arabic)",
21+
"tr": "Türkçe (Turkish)",
22+
"cn": "中国人 (Chinese)"
23+
}
24+
25+
export const RFC = {
26+
"en_US": "en-US",
27+
"hi": "hi",
28+
"es": "es",
29+
"fr": "fr",
30+
"ja": "ja",
31+
"ru": "ru",
32+
"en_GB": "en-GB",
33+
"de": "de",
34+
"it": "it",
35+
"ko": "ko",
36+
"pt_BR": "pt-BR",
37+
"ar": "ar",
38+
"tr": "tr",
39+
"cn": "zh"
40+
}
41+
42+
43+
export const DEFAULT_CACHE: DictionaryCache = {
44+
cachedDefinitions: [],
45+
cachedSynonyms: [],
46+
}
47+
48+
export const DEFAULT_SETTINGS: DictionarySettings = {
49+
defaultLanguage: "en_US",
50+
shouldShowSynonymPopover: true,
51+
shouldShowCustomContextMenu: false,
52+
definitionApiName: "Free Dictionary API",
53+
synonymApiName: "Free Dictionary API",
54+
partOfSpeechApiName: "Systran API",
55+
advancedSynonymAnalysis: false,
56+
useCaching: false,
57+
folder: '',
58+
capitalizedFileName: true,
59+
prefix: "",
60+
suffix: " ({{lang}})",
61+
template: `---
62+
# {{notice}}
63+
aliases: ["{{word}}"]
64+
---
65+
66+
# {{word}}
67+
68+
## {{pronunciationHeader}}
69+
70+
{{phoneticList}}
71+
72+
## {{meaningHeader}}
73+
74+
{{meanings}}
75+
`,
76+
languageSpecificSubFolders: false
77+
}
78+

0 commit comments

Comments
 (0)