generated from mirrors/plugin-sample-vite-svelte
Reorganize document menus
All checks were successful
Build on Push and create Release on Tag / build (push) Successful in 40s
All checks were successful
Build on Push and create Release on Tag / build (push) Successful in 40s
This commit is contained in:
parent
f27227b3a0
commit
0e392c9dea
2 changed files with 25 additions and 21 deletions
|
|
@ -1,4 +1,5 @@
|
||||||
{
|
{
|
||||||
|
"syspell": "SySpell",
|
||||||
"settings":{
|
"settings":{
|
||||||
"info": {
|
"info": {
|
||||||
"title": "Information",
|
"title": "Information",
|
||||||
|
|
|
||||||
45
src/menus.ts
45
src/menus.ts
|
|
@ -3,6 +3,7 @@ import SpellCheckPlugin from "@/index";
|
||||||
import {getBlockAttrs, setBlockAttrs} from "@/api";
|
import {getBlockAttrs, setBlockAttrs} from "@/api";
|
||||||
import {Settings} from "@/settings";
|
import {Settings} from "@/settings";
|
||||||
import {ProtyleHelper} from "@/protyleHelper";
|
import {ProtyleHelper} from "@/protyleHelper";
|
||||||
|
import {Analytics} from "@/analytics";
|
||||||
|
|
||||||
export class Menus {
|
export class Menus {
|
||||||
|
|
||||||
|
|
@ -67,7 +68,9 @@ export class Menus {
|
||||||
|
|
||||||
public async addSettingsToDocMenu(docID: string, menu: subMenu) {
|
public async addSettingsToDocMenu(docID: string, menu: subMenu) {
|
||||||
|
|
||||||
menu.addItem({
|
let submenu = []
|
||||||
|
|
||||||
|
submenu.push({
|
||||||
icon: 'info',
|
icon: 'info',
|
||||||
label: this.plugin.i18nx.docMenu.documentStatus,
|
label: this.plugin.i18nx.docMenu.documentStatus,
|
||||||
click: async () => {
|
click: async () => {
|
||||||
|
|
@ -86,7 +89,7 @@ export class Menus {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
menu.addItem({
|
submenu.push({
|
||||||
icon: 'toggle',
|
icon: 'toggle',
|
||||||
label: this.plugin.i18nx.docMenu.toggleSpellCheck,
|
label: this.plugin.i18nx.docMenu.toggleSpellCheck,
|
||||||
click: async () => {
|
click: async () => {
|
||||||
|
|
@ -104,7 +107,17 @@ export class Menus {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
menu.addItem({
|
async function setLang(lang: string, analytics: Analytics) {
|
||||||
|
const attrs = await getBlockAttrs(docID)
|
||||||
|
attrs[SpellCheckPlugin.LANGUAGE_ATTR] = lang
|
||||||
|
await setBlockAttrs(docID, attrs)
|
||||||
|
void analytics.sendEvent('docmenu-click-setlang-2', {
|
||||||
|
'language': lang
|
||||||
|
});
|
||||||
|
location.reload()
|
||||||
|
}
|
||||||
|
|
||||||
|
submenu.push({
|
||||||
icon: 'language',
|
icon: 'language',
|
||||||
label: this.plugin.i18nx.docMenu.setDocumentLanguage,
|
label: this.plugin.i18nx.docMenu.setDocumentLanguage,
|
||||||
click: async (_, ev: MouseEvent) => {
|
click: async (_, ev: MouseEvent) => {
|
||||||
|
|
@ -114,29 +127,13 @@ export class Menus {
|
||||||
langMenu.addItem({
|
langMenu.addItem({
|
||||||
icon: 'autodetect',
|
icon: 'autodetect',
|
||||||
label: this.plugin.i18nx.docMenu.autodetectLanguage,
|
label: this.plugin.i18nx.docMenu.autodetectLanguage,
|
||||||
click: async () => {
|
click: async () => setLang('auto', this.plugin.analytics)
|
||||||
const attrs = await getBlockAttrs(docID)
|
|
||||||
attrs[SpellCheckPlugin.LANGUAGE_ATTR] = 'auto'
|
|
||||||
await setBlockAttrs(docID, attrs)
|
|
||||||
void this.plugin.analytics.sendEvent('docmenu-click-setlang-2', {
|
|
||||||
'language': 'auto'
|
|
||||||
});
|
|
||||||
location.reload()
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
languages.forEach(language => {
|
languages.forEach(language => {
|
||||||
langMenu.addItem({
|
langMenu.addItem({
|
||||||
icon: 'language',
|
icon: 'language',
|
||||||
label: language.name + ' [' + language.longCode + ']',
|
label: language.name + ' [' + language.longCode + ']',
|
||||||
click: async () => {
|
click: async () => setLang(language.longCode, this.plugin.analytics)
|
||||||
const attrs = await getBlockAttrs(docID)
|
|
||||||
attrs[SpellCheckPlugin.LANGUAGE_ATTR] = language.longCode
|
|
||||||
await setBlockAttrs(docID, attrs)
|
|
||||||
void this.plugin.analytics.sendEvent('docmenu-click-setlang-2', {
|
|
||||||
'language': language.longCode
|
|
||||||
});
|
|
||||||
location.reload()
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
langMenu.open({ x: ev.clientX, y: ev.clientY });
|
langMenu.open({ x: ev.clientX, y: ev.clientY });
|
||||||
|
|
@ -144,6 +141,12 @@ export class Menus {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
menu.addItem({
|
||||||
|
icon: 'spellcheck',
|
||||||
|
label: this.plugin.i18nx.syspell,
|
||||||
|
submenu: submenu
|
||||||
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue