mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-06 16:58:49 +01:00
This commit is contained in:
parent
33f8def8ce
commit
3464708aae
5 changed files with 30 additions and 27 deletions
|
|
@ -84,13 +84,6 @@ export class Menu {
|
|||
}
|
||||
}
|
||||
|
||||
public addSeparator(index?: number, id?: string) {
|
||||
if (id) {
|
||||
return this.addItem({id: "separator_" + id, type: "separator", index});
|
||||
}
|
||||
return this.addItem({type: "separator", index});
|
||||
}
|
||||
|
||||
public addItem(option: IMenu) {
|
||||
const menuItem = new MenuItem(option);
|
||||
this.append(menuItem.element, option.index);
|
||||
|
|
@ -384,11 +377,11 @@ export class subMenu {
|
|||
this.menus = [];
|
||||
}
|
||||
|
||||
addSeparator(index?: number) {
|
||||
addSeparator(index?: number, id?: string) {
|
||||
if (typeof index === "number") {
|
||||
this.menus.splice(index, 0, {type: "separator"});
|
||||
this.menus.splice(index, 0, {type: "separator", id});
|
||||
} else {
|
||||
this.menus.push({type: "separator"});
|
||||
this.menus.push({type: "separator", id});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -34,17 +34,27 @@ export class Menu {
|
|||
return this.menu.addItem(option);
|
||||
}
|
||||
|
||||
addSeparator(index?: number, ignore = false, id?: string) {
|
||||
if (ignore) {
|
||||
addSeparator(options?: number | {
|
||||
index?: number,
|
||||
id?: string,
|
||||
ignore?: boolean
|
||||
}, ignoreParam = false) {
|
||||
// 兼容 3.1.24 之前的版本 addSeparator(index?: number, ignore?: boolean): HTMLElement;
|
||||
let id: string;
|
||||
let index: number;
|
||||
let ignore = false;
|
||||
if (typeof options === "object") {
|
||||
ignore = options.ignore || false;
|
||||
index = options.index;
|
||||
id = options.id;
|
||||
} else if (typeof options === "number") {
|
||||
index = options;
|
||||
ignore = ignoreParam;
|
||||
}
|
||||
if (ignore || this.isOpen) {
|
||||
return;
|
||||
}
|
||||
if (this.isOpen) {
|
||||
return;
|
||||
}
|
||||
if (id) {
|
||||
return this.menu.addSeparator(index, id);
|
||||
}
|
||||
return this.menu.addSeparator(index);
|
||||
return this.menu.addItem({id, type: "separator", index});
|
||||
}
|
||||
|
||||
open(options: IPosition) {
|
||||
|
|
|
|||
|
|
@ -522,7 +522,7 @@ export const avContextmenu = (protyle: IProtyle, rowElement: HTMLElement, positi
|
|||
});
|
||||
if (rowElements.length === 1) {
|
||||
if (keyCellElement.getAttribute("data-detached") !== "true") {
|
||||
menu.addSeparator(undefined, undefined, "1");
|
||||
menu.addSeparator({id: "separator_1"});
|
||||
}
|
||||
menu.addItem({
|
||||
id: "insertRowBefore",
|
||||
|
|
@ -570,7 +570,7 @@ ${window.siyuan.languages.insertRowAfter.replace("${x}", `<span class="fn__space
|
|||
});
|
||||
}
|
||||
});
|
||||
menu.addSeparator(undefined, undefined, "2");
|
||||
menu.addSeparator({id: "separator_2"});
|
||||
if (keyCellElement.getAttribute("data-detached") !== "true") {
|
||||
menu.addItem({
|
||||
id: "unbindBlock",
|
||||
|
|
|
|||
|
|
@ -244,7 +244,7 @@ export const editAssetItem = (options: {
|
|||
});
|
||||
}
|
||||
});
|
||||
menu.addSeparator(undefined, undefined, "1");
|
||||
menu.addSeparator({id: "separator_1"});
|
||||
menu.addItem({
|
||||
id: "copy",
|
||||
label: window.siyuan.languages.copy,
|
||||
|
|
@ -280,7 +280,7 @@ export const editAssetItem = (options: {
|
|||
});
|
||||
}
|
||||
});
|
||||
menu.addSeparator(undefined, undefined, "1");
|
||||
menu.addSeparator({id: "separator_1"});
|
||||
menu.addItem({
|
||||
id: "copy",
|
||||
label: window.siyuan.languages.copy,
|
||||
|
|
@ -324,7 +324,7 @@ export const editAssetItem = (options: {
|
|||
}
|
||||
const openSubMenu = openMenu(options.protyle ? options.protyle.app : window.siyuan.ws.app, linkAddress, true, false);
|
||||
if (type !== "file" || openSubMenu.length > 0) {
|
||||
menu.addSeparator(undefined, undefined, "2");
|
||||
menu.addSeparator({id: "separator_2"});
|
||||
}
|
||||
if (type !== "file") {
|
||||
menu.addItem({
|
||||
|
|
|
|||
|
|
@ -761,7 +761,7 @@ export const showColMenu = (protyle: IProtyle, blockElement: Element, cellElemen
|
|||
});
|
||||
}
|
||||
});
|
||||
menu.addSeparator(undefined, undefined, "1");
|
||||
menu.addSeparator({id: "separator_1"});
|
||||
|
||||
// 行号 类型不参与 排序和筛选
|
||||
if (type !== "lineNumber") {
|
||||
|
|
@ -851,7 +851,7 @@ export const showColMenu = (protyle: IProtyle, blockElement: Element, cellElemen
|
|||
}
|
||||
});
|
||||
}
|
||||
menu.addSeparator(undefined, undefined, "2");
|
||||
menu.addSeparator({id: "separator_2"});
|
||||
}
|
||||
menu.addItem({
|
||||
id: "insertColumnLeft",
|
||||
|
|
@ -1034,7 +1034,7 @@ export const showColMenu = (protyle: IProtyle, blockElement: Element, cellElemen
|
|||
});
|
||||
}
|
||||
});
|
||||
menu.addSeparator(undefined, undefined, "3");
|
||||
menu.addSeparator({id: "separator_3"});
|
||||
}
|
||||
menu.addItem({
|
||||
id: "wrap",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue