Skip to content

Commit 1bc2106

Browse files
committed
updates for community plugins review
obsidianmd/obsidian-releases#1196
1 parent 3729e39 commit 1bc2106

File tree

9 files changed

+104
-103
lines changed

9 files changed

+104
-103
lines changed

main.js

Lines changed: 46 additions & 43 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

manifest.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
2-
"id": "obsidian-keyboard-analyzer",
2+
"id": "keyboard-analyzer",
33
"name": "Keyboard Analyzer",
4-
"version": "0.1.2",
4+
"version": "0.1.3",
55
"minAppVersion": "0.12.10",
66
"description": "See and analyse your keyboard hotkeys and shortcuts",
7-
"author": "Cogscieds",
8-
"authorUrl": "https://github.com/cogscides/obsidian-keyboard-analyzer",
7+
"author": "cogscides",
8+
"authorUrl": "https://github.com/cogscides",
99
"isDesktopOnly": false
1010
}

src/AppShortcuts.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type { Command, Hotkey, Modifier, App } from 'obsidian'
2+
import { Platform } from 'obsidian'
23
import type { EntryType } from 'perf_hooks'
34
import type { hotkeyDict, hotkeyEntry } from 'src/Interfaces'
45

@@ -139,15 +140,15 @@ export function getConvertedModifiers(modifiers: Modifier[]) {
139140
let convertedModifiers = modifiers.map((modifier: Modifier) => {
140141
if (modifier === 'Mod') {
141142
// check macos
142-
if (process.platform === 'darwin') {
143+
if (Platform.isMacOS === true) {
143144
return 'Cmd'
144145
} else {
145146
return 'Ctrl'
146147
}
147148
}
148149
if (modifier === 'Meta') {
149150
// check macos
150-
if (process.platform === 'darwin') {
151+
if (Platform.isMacOS === true) {
151152
return 'Cmd'
152153
} else {
153154
return 'Win'
@@ -168,13 +169,13 @@ export function getUnconvertedModifiers(modifiers: Modifier[]) {
168169
if (modifier === 'Ctrl') {
169170
return 'Ctrl'
170171
}
171-
if (modifier === 'Cmd' && process.platform === 'darwin') {
172+
if (modifier === 'Cmd' && Platform.isMacOS === true) {
172173
return 'Mod'
173174
}
174175
if (modifier === 'Win') {
175176
return 'Meta'
176177
}
177-
if (modifier === 'Cmd' && process.platform === 'darwin') {
178+
if (modifier === 'Cmd' && Platform.isMacOS === true) {
178179
return 'Meta'
179180
}
180181
})

src/Components/KeyboardComponent.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
} from 'src/AppShortcuts'
2727
2828
// STORE
29-
import { activeKey, activeModifiers } from './atciveKeysStore'
29+
import { activeKey, activeModifiers } from './activeKeysStore'
3030
3131
// CONSTANTS
3232
import {

src/Components/KeyboardLayout.svelte

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
<script lang="ts">
2+
import type { Modifier } from 'obsidian'
3+
import { Platform } from 'obsidian'
24
import { Coffee as CofeeIcon } from 'lucide-svelte'
35
import { JavaSciptKeyCodes } from 'src/Constants'
46
import { getConvertedModifiers } from 'src/AppShortcuts'
5-
import type { Modifier } from 'obsidian'
67
import KeyboardKey from './KeyboardKey.svelte'
78
89
// TYPES
910
import type { Keyboard, commandsArray } from 'src/Interfaces'
1011
1112
// STORE
12-
import { activeKey, activeModifiers } from './atciveKeysStore'
13+
import { activeKey, activeModifiers } from './activeKeysStore'
1314
1415
export let visibleCommands: commandsArray
1516
@@ -98,7 +99,7 @@
9899
unicode: 'Ctrl',
99100
}
100101
} else if (keyOutput === 'Meta') {
101-
if (process.platform === 'darwin') {
102+
if (Platform.isMacOS === true) {
102103
outputKeyObj = {
103104
output: '',
104105
keyCode: 18,
@@ -115,7 +116,7 @@
115116
}
116117
}
117118
} else if (keyOutput === 'Alt') {
118-
if (process.platform === 'darwin') {
119+
if (Platform.isMacOS === true) {
119120
outputKeyObj = {
120121
output: '',
121122
smallText: key.smallText ? true : false,

src/Components/SearchMenu.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import { JavaSciptKeyCodes, SpecialSymbols } from 'src/Constants'
1919
2020
// STORE
21-
import { activeKey, activeModifiers } from './atciveKeysStore'
21+
import { activeKey, activeModifiers } from './activeKeysStore'
2222
2323
// UTILS
2424
import { getConvertedModifiers, sortModifiers } from 'src/AppShortcuts'
File renamed without changes.

src/ShortcutsView.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ export default class ShortcutsView extends ItemView {
2727
return 'Keyboard Shortcuts'
2828
}
2929

30-
icon = 'keyboard-glyph'
31-
3230
async onOpen(): Promise<void> {
3331
await this.draw()
3432
}

src/main.ts

Lines changed: 42 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export default class KeyboardAnalizerPlugin extends Plugin {
4545
)
4646

4747
// This adds a settings tab so the user can configure various aspects of the plugin
48-
this.addSettingTab(new KeyboardAnalyzerSettingTab(this.app, this))
48+
// this.addSettingTab(new KeyboardAnalyzerSettingTab(this.app, this))
4949
}
5050

5151
async onunload() {
@@ -83,36 +83,34 @@ export default class KeyboardAnalizerPlugin extends Plugin {
8383

8484
async onStatusBarClick(evt: MouseEvent) {
8585
if (evt.ctrlKey == true) {
86-
let checkResult =
87-
this.app.workspace.getLeavesOfType(VIEW_TYPE_SHORTCUTS_ANALYZER)
88-
.length === 0
89-
90-
if (checkResult) {
91-
this.app.workspace
92-
.getLeaf(true)
93-
.setViewState({ type: VIEW_TYPE_SHORTCUTS_ANALYZER })
94-
}
86+
this.addShortcutsView(true)
9587
} else {
9688
this.addShortcutsView()
9789
}
9890
}
9991

100-
async addShortcutsView(startup: boolean = false) {
92+
async addShortcutsView(newLeaf: boolean = false) {
10193
let checkResult =
10294
this.app.workspace.getLeavesOfType(VIEW_TYPE_SHORTCUTS_ANALYZER)
10395
.length === 0
10496

10597
if (checkResult) {
106-
this.app.workspace
107-
.getLeaf()
108-
.setViewState({ type: VIEW_TYPE_SHORTCUTS_ANALYZER })
98+
if (newLeaf) {
99+
this.app.workspace
100+
.getLeaf(true)
101+
.setViewState({ type: VIEW_TYPE_SHORTCUTS_ANALYZER })
102+
} else {
103+
this.app.workspace
104+
.getLeaf()
105+
.setViewState({ type: VIEW_TYPE_SHORTCUTS_ANALYZER })
106+
}
109107
}
110108
}
111109

112110
registerPluginHotkeys() {
113111
this.addCommand({
114112
id: 'show-shortcuts-analyzer-view',
115-
name: 'Open Shorcuts View',
113+
name: 'Open keyboard shortcuts view',
116114
checkCallback: (checking: boolean) => {
117115
let checkResult =
118116
this.app.workspace.getLeavesOfType(VIEW_TYPE_SHORTCUTS_ANALYZER)
@@ -132,32 +130,32 @@ export default class KeyboardAnalizerPlugin extends Plugin {
132130
// END OF PLUGIN DECLARATION
133131
}
134132

135-
class KeyboardAnalyzerSettingTab extends PluginSettingTab {
136-
plugin: KeyboardAnalizerPlugin
137-
138-
constructor(app: App, plugin: KeyboardAnalizerPlugin) {
139-
super(app, plugin)
140-
this.plugin = plugin
141-
}
142-
143-
display(): void {
144-
const { containerEl } = this
145-
146-
containerEl.empty()
147-
148-
containerEl.createEl('h2', { text: 'Settings for my awesome plugin.' })
149-
150-
// checkbox for showing status bar item
151-
new Setting(containerEl)
152-
.setName('Show Status Bar Item')
153-
.setDesc('Show the status bar item')
154-
.addToggle((checkbox: any) =>
155-
checkbox
156-
.setChecked(this.plugin.settings.showStatusBarItem)
157-
.onChange(async (value: boolean) => {
158-
this.plugin.settings.showStatusBarItem = value
159-
await this.plugin.saveSettings()
160-
})
161-
)
162-
}
163-
}
133+
// class KeyboardAnalyzerSettingTab extends PluginSettingTab {
134+
// plugin: KeyboardAnalizerPlugin
135+
136+
// constructor(app: App, plugin: KeyboardAnalizerPlugin) {
137+
// super(app, plugin)
138+
// this.plugin = plugin
139+
// }
140+
141+
// display(): void {
142+
// const { containerEl } = this
143+
144+
// containerEl.empty()
145+
146+
// containerEl.createEl('h2', { text: 'Settings for my awesome plugin.' })
147+
148+
// // checkbox for showing status bar item
149+
// new Setting(containerEl)
150+
// .setName('Show Status Bar Item')
151+
// .setDesc('Show the status bar item')
152+
// .addToggle((checkbox: any) =>
153+
// checkbox
154+
// .setChecked(this.plugin.settings.showStatusBarItem)
155+
// .onChange(async (value: boolean) => {
156+
// this.plugin.settings.showStatusBarItem = value
157+
// await this.plugin.saveSettings()
158+
// })
159+
// )
160+
// }
161+
// }

0 commit comments

Comments
 (0)