mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-05-17 01:21:14 +08:00
This commit is contained in:
parent
cbad03815d
commit
bd89dd67e1
@ -54,6 +54,24 @@ export const keymap = {
|
|||||||
<input data-key="plugin${Constants.ZWSP}${item.name}${Constants.ZWSP}${command.langKey}" data-value="${command.customHotkey}" data-default="${command.hotkey}" class="b3-text-field fn__none" value="${keyValue}" spellcheck="false">
|
<input data-key="plugin${Constants.ZWSP}${item.name}${Constants.ZWSP}${command.langKey}" data-value="${command.customHotkey}" data-default="${command.hotkey}" class="b3-text-field fn__none" value="${keyValue}" spellcheck="false">
|
||||||
</label>`;
|
</label>`;
|
||||||
});
|
});
|
||||||
|
item.updateProtyleToolbar([]).forEach(toolbarItem => {
|
||||||
|
if (typeof toolbarItem === "string" || Constants.INLINE_TYPE.concat("|").includes(toolbarItem.name) || !toolbarItem.hotkey) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const dockKeymap = window.siyuan.config.keymap.plugin[item.name][toolbarItem.name];
|
||||||
|
const keyValue = updateHotkeyTip(dockKeymap.custom);
|
||||||
|
commandHTML += `<label class="b3-list-item b3-list-item--narrow b3-list-item--hide-action">
|
||||||
|
<span class="b3-list-item__text">${toolbarItem.tip||window.siyuan.languages[toolbarItem.lang]}</span>
|
||||||
|
<span data-type="reset" class="b3-list-item__action b3-tooltips b3-tooltips__w" aria-label="${window.siyuan.languages.reset}">
|
||||||
|
<svg><use xlink:href="#iconUndo"></use></svg>
|
||||||
|
</span>
|
||||||
|
<span data-type="clear" class="b3-list-item__action b3-tooltips b3-tooltips__w" aria-label="${window.siyuan.languages.remove}">
|
||||||
|
<svg><use xlink:href="#iconTrashcan"></use></svg>
|
||||||
|
</span>
|
||||||
|
<span data-type="update" class="config-keymap__key">${keyValue}</span>
|
||||||
|
<input data-key="plugin${Constants.ZWSP}${item.name}${Constants.ZWSP}${toolbarItem.name}" data-value="${dockKeymap.custom}" data-default="${dockKeymap.default}" class="b3-text-field fn__none" value="${keyValue}" spellcheck="false">
|
||||||
|
</label>`;
|
||||||
|
})
|
||||||
Object.keys(item.docks).forEach(key => {
|
Object.keys(item.docks).forEach(key => {
|
||||||
const dockConfig = item.docks[key].config;
|
const dockConfig = item.docks[key].config;
|
||||||
if (!dockConfig.hotkey) {
|
if (!dockConfig.hotkey) {
|
||||||
|
@ -15,6 +15,7 @@ import {hasClosestByAttribute} from "../protyle/util/hasClosest";
|
|||||||
import {BlockPanel} from "../block/Panel";
|
import {BlockPanel} from "../block/Panel";
|
||||||
import {Setting} from "./Setting";
|
import {Setting} from "./Setting";
|
||||||
import {clearOBG} from "../layout/dock/util";
|
import {clearOBG} from "../layout/dock/util";
|
||||||
|
import {Constants} from "../constants";
|
||||||
|
|
||||||
export class Plugin {
|
export class Plugin {
|
||||||
private app: App;
|
private app: App;
|
||||||
@ -75,6 +76,29 @@ export class Plugin {
|
|||||||
value: options.name,
|
value: options.name,
|
||||||
writable: false,
|
writable: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.updateProtyleToolbar([]).forEach(toolbarItem => {
|
||||||
|
if (typeof toolbarItem === "string" || Constants.INLINE_TYPE.concat("|").includes(toolbarItem.name) || !toolbarItem.hotkey) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (!window.siyuan.config.keymap.plugin) {
|
||||||
|
window.siyuan.config.keymap.plugin = {};
|
||||||
|
}
|
||||||
|
if (!window.siyuan.config.keymap.plugin[options.name]) {
|
||||||
|
window.siyuan.config.keymap.plugin[options.name] = {
|
||||||
|
[toolbarItem.name]: {
|
||||||
|
default: toolbarItem.hotkey,
|
||||||
|
custom: toolbarItem.hotkey,
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
if (!window.siyuan.config.keymap.plugin[options.name][toolbarItem.name]) {
|
||||||
|
window.siyuan.config.keymap.plugin[options.name][toolbarItem.name] = {
|
||||||
|
default: toolbarItem.hotkey,
|
||||||
|
custom: toolbarItem.hotkey,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
public onload() {
|
public onload() {
|
||||||
|
@ -69,7 +69,14 @@ export class Toolbar {
|
|||||||
/// #endif
|
/// #endif
|
||||||
this.toolbarHeight = 29;
|
this.toolbarHeight = 29;
|
||||||
protyle.app.plugins.forEach(item => {
|
protyle.app.plugins.forEach(item => {
|
||||||
options.toolbar = toolbarKeyToMenu(item.updateProtyleToolbar(options.toolbar));
|
const pluginToolbar = item.updateProtyleToolbar(options.toolbar)
|
||||||
|
pluginToolbar.forEach(toolbarItem => {
|
||||||
|
if (typeof toolbarItem === "string" || Constants.INLINE_TYPE.concat("|").includes(toolbarItem.name) || !toolbarItem.hotkey) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
toolbarItem.hotkey = window.siyuan.config.keymap.plugin[item.name][toolbarItem.name].custom;
|
||||||
|
})
|
||||||
|
options.toolbar = toolbarKeyToMenu(pluginToolbar);
|
||||||
});
|
});
|
||||||
options.toolbar.forEach((menuItem: IMenuItem) => {
|
options.toolbar.forEach((menuItem: IMenuItem) => {
|
||||||
const itemElement = this.genItem(protyle, menuItem);
|
const itemElement = this.genItem(protyle, menuItem);
|
||||||
@ -81,7 +88,14 @@ export class Toolbar {
|
|||||||
this.element.innerHTML = "";
|
this.element.innerHTML = "";
|
||||||
protyle.options.toolbar = toolbarKeyToMenu(Constants.PROTYLE_TOOLBAR);
|
protyle.options.toolbar = toolbarKeyToMenu(Constants.PROTYLE_TOOLBAR);
|
||||||
protyle.app.plugins.forEach(item => {
|
protyle.app.plugins.forEach(item => {
|
||||||
protyle.options.toolbar = toolbarKeyToMenu(item.updateProtyleToolbar(protyle.options.toolbar));
|
const pluginToolbar = item.updateProtyleToolbar(protyle.options.toolbar)
|
||||||
|
pluginToolbar.forEach(toolbarItem => {
|
||||||
|
if (typeof toolbarItem === "string" || Constants.INLINE_TYPE.concat("|").includes(toolbarItem.name) || !toolbarItem.hotkey) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
toolbarItem.hotkey = window.siyuan.config.keymap.plugin[item.name][toolbarItem.name].custom;
|
||||||
|
})
|
||||||
|
protyle.options.toolbar = toolbarKeyToMenu(pluginToolbar);
|
||||||
});
|
});
|
||||||
protyle.options.toolbar.forEach((menuItem: IMenuItem) => {
|
protyle.options.toolbar.forEach((menuItem: IMenuItem) => {
|
||||||
const itemElement = this.genItem(protyle, menuItem);
|
const itemElement = this.genItem(protyle, menuItem);
|
||||||
|
Loading…
Reference in New Issue
Block a user