From 072e139c11aac806aec40f31336083929cfe3556 Mon Sep 17 00:00:00 2001 From: Denis Grushkin Date: Thu, 28 Jan 2021 00:09:55 +0600 Subject: [PATCH 1/8] Update README.md --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index d741993..012997a 100644 --- a/README.md +++ b/README.md @@ -22,3 +22,7 @@ Obsidian plugin to check & fix orthography errors in text * Search for spelling errors in the text * Displaying options for correcting word mistakes * Correct a word mistake in one click + +## Todo + +- [ ] Integration [Grammarly](https://www.grammarly.com) From 559e0af29ec525c07f104b06271fae5bb4d77cd5 Mon Sep 17 00:00:00 2001 From: Denisoed Date: Sat, 6 Mar 2021 22:04:25 +0600 Subject: [PATCH 2/8] Added support for multiple windows --- src/orthography/orthographyRunner.ts | 1 - src/orthography/orthographyTooltip.ts | 57 +++++++++++++++------------ 2 files changed, 32 insertions(+), 26 deletions(-) diff --git a/src/orthography/orthographyRunner.ts b/src/orthography/orthographyRunner.ts index 090dc44..b3b84d6 100644 --- a/src/orthography/orthographyRunner.ts +++ b/src/orthography/orthographyRunner.ts @@ -103,7 +103,6 @@ export class OrthographyRunner implements IOrthographyRunner { const runnerIcon = document.querySelector('.' + RUNNER_CSS_CLASS + ' span'); runnerIcon.classList.remove(RUNNER_CLEAR_CSS_CLASS); runner.classList.add(RUNNER_ACTIVE_CSS_CLASS); - localStorage.removeItem('obsidian-orthography'); // Delay for button animation setTimeout(() => { diff --git a/src/orthography/orthographyTooltip.ts b/src/orthography/orthographyTooltip.ts index 250cd7b..9b9b95f 100644 --- a/src/orthography/orthographyTooltip.ts +++ b/src/orthography/orthographyTooltip.ts @@ -12,6 +12,8 @@ interface IOrthographyTooltip { init(): void; } +let self: any; + export class OrthographyTooltip implements IOrthographyTooltip { private app: App; private settings: OrthographySettings; @@ -19,9 +21,6 @@ export class OrthographyTooltip implements IOrthographyTooltip { private checker: OrthographyChecker; private emitter: any; private editor: any; - private eventUdpateWordPos: any; - private eventTooltipToggle: any; - private eventReplaceWord: any; constructor(app: App, settings: OrthographySettings, emitter: Events) { this.app = app; @@ -30,14 +29,17 @@ export class OrthographyTooltip implements IOrthographyTooltip { } public init(): void { + self = this; this.createTooltip(); this.checker = new OrthographyChecker(this.app, this.settings); this.getEditor(); + this.app.workspace.on('active-leaf-change', self.activeLeafChange); } public destroy(): void { - document.removeEventListener('mouseover', this.eventTooltipToggle); - this.tooltip.removeEventListener('click', this.eventReplaceWord); + document.removeEventListener('mouseover', self.toggleTooltip); + this.app.workspace.off('active-leaf-change', self.activeLeafChange); + this.tooltip.removeEventListener('click', self.replaceWord); const tooltips = document.querySelectorAll('.' + TOOLTIP_CSS_CLASS); if (tooltips) tooltips.forEach((tooltip: any) => tooltip.remove()); } @@ -46,11 +48,9 @@ export class OrthographyTooltip implements IOrthographyTooltip { const tooltip = document.createElement('div'); tooltip.classList.add(TOOLTIP_CSS_CLASS); document.body.appendChild(tooltip); - this.eventTooltipToggle = this.toggleTooltip.bind(this); - document.addEventListener('mouseover', this.eventTooltipToggle); + document.addEventListener('mouseover', self.toggleTooltip); this.tooltip = document.querySelector('.' + TOOLTIP_CSS_CLASS); - this.eventReplaceWord = this.replaceWord.bind(this); - this.tooltip.addEventListener('click', this.eventReplaceWord); + this.tooltip.addEventListener('click', self.replaceWord); } private setDataToTooltip(element: any): void { @@ -70,18 +70,18 @@ export class OrthographyTooltip implements IOrthographyTooltip { private toggleTooltip(event: any): void { if (event.type === 'mouseover') { if (event.target.className.includes(HIGHLIGHT_CSS_CLASS)) { - this.setDataToTooltip(event.target); - this.tooltip.classList.add(TOOLTIP_VISIBLE_CSS_CLASS); - this.tooltip.style.left = this.getLeftPos(event); - this.tooltip.style.top = this.getTopPos(event); + self.setDataToTooltip(event.target); + self.tooltip.classList.add(TOOLTIP_VISIBLE_CSS_CLASS); + self.tooltip.style.left = self.getLeftPos(event); + self.tooltip.style.top = self.getTopPos(event); } } if ( !event.target.className.includes(TOOLTIP_CSS_CLASS) && !event.target.className.includes(HIGHLIGHT_CSS_CLASS) ) { - this.tooltip.classList.remove(TOOLTIP_VISIBLE_CSS_CLASS); - this.tooltip.innerHTML = ''; + self.tooltip.classList.remove(TOOLTIP_VISIBLE_CSS_CLASS); + self.tooltip.innerHTML = ''; } } @@ -90,7 +90,7 @@ export class OrthographyTooltip implements IOrthographyTooltip { if (word.x + this.tooltip.clientWidth + 10 < document.body.clientWidth) { return word.x + 'px'; } - return document.body.clientWidth + 5 - this.tooltip.clientWidth + 'px'; + return (document.body.clientWidth + 5) - this.tooltip.clientWidth + 'px'; } private getTopPos(event: any) { @@ -101,7 +101,7 @@ export class OrthographyTooltip implements IOrthographyTooltip { ) { return word.y + word.height + 'px'; } - return document.body.clientHeight + 10 - this.tooltip.clientHeight + 'px'; + return (document.body.clientHeight + 10) - this.tooltip.clientHeight + 'px'; } private appendHintButton(hint: any) { @@ -130,9 +130,9 @@ export class OrthographyTooltip implements IOrthographyTooltip { if (!word) return; - this.editor.off('change', this.eventUdpateWordPos); + self.editor.off('change', self.onUpdateWordPos); - const activeLeaf: any = this.app.workspace.activeLeaf; + const activeLeaf: any = self.app.workspace.activeLeaf; const editor = activeLeaf.view.sourceMode.cmEditor; const doc = editor.getDoc(); @@ -149,8 +149,8 @@ export class OrthographyTooltip implements IOrthographyTooltip { doc.replaceRange(event.target.innerText, from, to); // Updating data pos for highlight words - this.checker.updateDataPos(); - this.editor.on('change', this.eventUdpateWordPos); + self.checker.updateDataPos(); + self.editor.on('change', self.onUpdateWordPos); } } @@ -158,13 +158,20 @@ export class OrthographyTooltip implements IOrthographyTooltip { setTimeout(() => { const activeLeaf: any = this.app.workspace.activeLeaf; this.editor = activeLeaf.view.sourceMode.cmEditor; - this.eventUdpateWordPos = this.onUpdateWordPos.bind(this); - this.editor.on('change', this.eventUdpateWordPos); + this.editor.on('change', self.onUpdateWordPos); }, 1000); } + private activeLeafChange() { + if (self.editor) { + self.editor.off('change', self.onUpdateWordPos); + self.onUpdateWordPos(); + self.getEditor(); + } + } + private onUpdateWordPos() { - this.emitter.trigger('onUpdateWordPos'); - this.checker.clear(); + self.emitter.trigger('onUpdateWordPos'); + self.checker.clear(); } } From 67bb6a8d1cea19ce68528ef10c0853fc67a00aa8 Mon Sep 17 00:00:00 2001 From: Denisoed Date: Sat, 6 Mar 2021 22:26:55 +0600 Subject: [PATCH 3/8] fix condition for toggle tooltip --- src/orthography/orthographyTooltip.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/orthography/orthographyTooltip.ts b/src/orthography/orthographyTooltip.ts index 9b9b95f..1938867 100644 --- a/src/orthography/orthographyTooltip.ts +++ b/src/orthography/orthographyTooltip.ts @@ -69,7 +69,7 @@ export class OrthographyTooltip implements IOrthographyTooltip { private toggleTooltip(event: any): void { if (event.type === 'mouseover') { - if (event.target.className.includes(HIGHLIGHT_CSS_CLASS)) { + if (event.target && event.target.className.includes(HIGHLIGHT_CSS_CLASS)) { self.setDataToTooltip(event.target); self.tooltip.classList.add(TOOLTIP_VISIBLE_CSS_CLASS); self.tooltip.style.left = self.getLeftPos(event); From 69b18ecf97356a50a41002c89cbbf3367e9c7c8e Mon Sep 17 00:00:00 2001 From: Denisoed Date: Sat, 6 Mar 2021 22:36:01 +0600 Subject: [PATCH 4/8] updated version to 1.0.3 --- manifest.json | 4 ++-- package.json | 2 +- versions.json | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/manifest.json b/manifest.json index ee07e33..c79c069 100644 --- a/manifest.json +++ b/manifest.json @@ -1,8 +1,8 @@ { "id": "obsidian-orthography", "name": "Obsidian Orthography", - "version": "1.0.2", - "minAppVersion": "0.10.8", + "version": "1.0.3", + "minAppVersion": "0.11.3", "description": "Obsidian plugin to check & fix orthography errors in text", "author": "Denisoed", "authorUrl": "https://github.com/denisoed", diff --git a/package.json b/package.json index 7b7f906..5b30460 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "obsidian-orthography", - "version": "1.0.2", + "version": "1.0.3", "description": "Check orthography plugin for Obsidian (https://obsidian.md)", "repository": { "type": "git", diff --git a/versions.json b/versions.json index de46ba1..c2b8f24 100644 --- a/versions.json +++ b/versions.json @@ -1,3 +1,3 @@ { - "1.0.2": "0.10.8" + "1.0.3": "0.11.3" } From 851647bec7989f3b309629d8b51b81067beac092 Mon Sep 17 00:00:00 2001 From: Denisoed Date: Sat, 6 Mar 2021 22:46:27 +0600 Subject: [PATCH 5/8] fixed linter errors --- src/orthography/orthographyTooltip.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/orthography/orthographyTooltip.ts b/src/orthography/orthographyTooltip.ts index 1938867..38cbdc6 100644 --- a/src/orthography/orthographyTooltip.ts +++ b/src/orthography/orthographyTooltip.ts @@ -69,7 +69,10 @@ export class OrthographyTooltip implements IOrthographyTooltip { private toggleTooltip(event: any): void { if (event.type === 'mouseover') { - if (event.target && event.target.className.includes(HIGHLIGHT_CSS_CLASS)) { + if ( + event.target && + event.target.className.includes(HIGHLIGHT_CSS_CLASS) + ) { self.setDataToTooltip(event.target); self.tooltip.classList.add(TOOLTIP_VISIBLE_CSS_CLASS); self.tooltip.style.left = self.getLeftPos(event); @@ -90,7 +93,7 @@ export class OrthographyTooltip implements IOrthographyTooltip { if (word.x + this.tooltip.clientWidth + 10 < document.body.clientWidth) { return word.x + 'px'; } - return (document.body.clientWidth + 5) - this.tooltip.clientWidth + 'px'; + return document.body.clientWidth + 5 - this.tooltip.clientWidth + 'px'; } private getTopPos(event: any) { @@ -101,7 +104,7 @@ export class OrthographyTooltip implements IOrthographyTooltip { ) { return word.y + word.height + 'px'; } - return (document.body.clientHeight + 10) - this.tooltip.clientHeight + 'px'; + return document.body.clientHeight + 10 - this.tooltip.clientHeight + 'px'; } private appendHintButton(hint: any) { From a99a1a61f7304e4d3481a3cf13a686b3ebbeb8a6 Mon Sep 17 00:00:00 2001 From: denisoed Date: Thu, 28 Oct 2021 10:28:17 +0600 Subject: [PATCH 6/8] Updated README.md --- README.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/README.md b/README.md index 012997a..56b998f 100644 --- a/README.md +++ b/README.md @@ -26,3 +26,17 @@ Obsidian plugin to check & fix orthography errors in text ## Todo - [ ] Integration [Grammarly](https://www.grammarly.com) + +## For Developers + +### How to get started developing + +1. Create new vault(folder) in Obsidian. For example `Orthography` + +2. In the terminal, go to the `./Orthography/.obsidian` folder and create there the `plugins` folder + +3. Clone the repository into the `plugins` folder: `git clone https://github.com/denisoed/obsidian-orthography.git` + +4. Install dependencies: `npm i` + +5. And run for develop: `npm run dev` From ba501d8f5f70d594b7678c45bae67128a80ff941 Mon Sep 17 00:00:00 2001 From: Vidath Dissanayake <65162540+VidathD@users.noreply.github.com> Date: Thu, 17 Feb 2022 16:39:15 +0530 Subject: [PATCH 7/8] Change simple l to capital L Simple L looks like a capital i. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 56b998f..1fdf5df 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ Obsidian plugin to check & fix orthography errors in text | Keys | Description | |---|---| -| Ctrl + Shift + l | Run the orthography checker | +| Ctrl + Shift + L | Run the orthography checker | ## Features From 45809fc6236336409f631439a0815a3ed48bc404 Mon Sep 17 00:00:00 2001 From: Vidath Dissanayake <65162540+VidathD@users.noreply.github.com> Date: Thu, 17 Feb 2022 17:30:12 +0530 Subject: [PATCH 8/8] Clean up the table --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 1fdf5df..f971b72 100644 --- a/README.md +++ b/README.md @@ -13,8 +13,8 @@ Obsidian plugin to check & fix orthography errors in text ## Hotkeys -| Keys | Description | -|---|---| +| Keys | Description | +|------------------|-----------------------------| | Ctrl + Shift + L | Run the orthography checker | ## Features