mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-22 09:30:14 +01:00
This commit is contained in:
parent
d26bb04110
commit
852d5fbe52
3 changed files with 20 additions and 5 deletions
|
|
@ -609,25 +609,36 @@ export class Dock {
|
||||||
return max;
|
return max;
|
||||||
}
|
}
|
||||||
|
|
||||||
public genButton(data: IDockTab[], index: number, append = false) {
|
public genButton(data: IDockTab[], index: number, tabIndex?: number) {
|
||||||
let html = "";
|
let html = "";
|
||||||
data.forEach(item => {
|
data.forEach(item => {
|
||||||
|
if (typeof tabIndex === "undefined" && !TYPES.includes(item.type)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
html += `<span data-height="${item.size.height}" data-width="${item.size.width}" data-type="${item.type}" data-index="${index}" data-hotkey="${item.hotkey || ""}" data-hotkeyLangId="${item.hotkeyLangId || ""}" data-title="${item.title}" class="dock__item${item.show ? " dock__item--active" : ""} b3-tooltips b3-tooltips__${this.getClassDirect(index)}" aria-label="${item.title} ${item.hotkey ? updateHotkeyTip(item.hotkey) : ""}${window.siyuan.languages.dockTip}">
|
html += `<span data-height="${item.size.height}" data-width="${item.size.width}" data-type="${item.type}" data-index="${index}" data-hotkey="${item.hotkey || ""}" data-hotkeyLangId="${item.hotkeyLangId || ""}" data-title="${item.title}" class="dock__item${item.show ? " dock__item--active" : ""} b3-tooltips b3-tooltips__${this.getClassDirect(index)}" aria-label="${item.title} ${item.hotkey ? updateHotkeyTip(item.hotkey) : ""}${window.siyuan.languages.dockTip}">
|
||||||
<svg><use xlink:href="#${item.icon}"></use></svg>
|
<svg><use xlink:href="#${item.icon}"></use></svg>
|
||||||
</span>`;
|
</span>`;
|
||||||
this.data[item.type] = true;
|
this.data[item.type] = true;
|
||||||
});
|
});
|
||||||
if (index === 0) {
|
if (index === 0) {
|
||||||
if (append) {
|
if (typeof tabIndex === "number") {
|
||||||
this.element.firstElementChild.lastElementChild.insertAdjacentHTML("beforebegin", html);
|
if (this.element.firstElementChild.children[tabIndex]) {
|
||||||
|
this.element.firstElementChild.children[tabIndex].insertAdjacentHTML("beforebegin", html);
|
||||||
|
} else {
|
||||||
|
this.element.firstElementChild.lastElementChild.insertAdjacentHTML("beforebegin", html);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
this.element.firstElementChild.innerHTML = `${html}<span class="dock__item dock__item--pin b3-tooltips b3-tooltips__${this.getClassDirect(index)}" aria-label="${this.pin ? window.siyuan.languages.unpin : window.siyuan.languages.pin}">
|
this.element.firstElementChild.innerHTML = `${html}<span class="dock__item dock__item--pin b3-tooltips b3-tooltips__${this.getClassDirect(index)}" aria-label="${this.pin ? window.siyuan.languages.unpin : window.siyuan.languages.pin}">
|
||||||
<svg><use xlink:href="#iconPin"></use></svg>
|
<svg><use xlink:href="#iconPin"></use></svg>
|
||||||
</span>`;
|
</span>`;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (append) {
|
if (typeof tabIndex === "number") {
|
||||||
this.element.lastElementChild.insertAdjacentHTML("beforeend", html);
|
if (this.element.lastElementChild.children[tabIndex]) {
|
||||||
|
this.element.lastElementChild.children[tabIndex].insertAdjacentHTML("beforebegin", html);
|
||||||
|
} else {
|
||||||
|
this.element.lastElementChild.insertAdjacentHTML("beforeend", html);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
this.element.lastElementChild.innerHTML = html;
|
this.element.lastElementChild.innerHTML = html;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -170,6 +170,9 @@ export class Plugin {
|
||||||
}) {
|
}) {
|
||||||
/// #if !MOBILE
|
/// #if !MOBILE
|
||||||
const type2 = this.name + options.type;
|
const type2 = this.name + options.type;
|
||||||
|
if (typeof options.config.index === "undefined") {
|
||||||
|
options.config.index = 1000;
|
||||||
|
}
|
||||||
this.docks[type2] = {
|
this.docks[type2] = {
|
||||||
config: options.config,
|
config: options.config,
|
||||||
model: (arg: { tab: Tab }) => {
|
model: (arg: { tab: Tab }) => {
|
||||||
|
|
|
||||||
1
app/src/types/index.d.ts
vendored
1
app/src/types/index.d.ts
vendored
|
|
@ -313,6 +313,7 @@ declare interface IPluginDockTab {
|
||||||
icon: string,
|
icon: string,
|
||||||
hotkey?: string,
|
hotkey?: string,
|
||||||
title: string,
|
title: string,
|
||||||
|
index?: number
|
||||||
}
|
}
|
||||||
|
|
||||||
declare interface IOpenFileOptions {
|
declare interface IOpenFileOptions {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue