mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-23 01:50:12 +01:00
🚨
This commit is contained in:
parent
c5d6f41805
commit
d332328726
4 changed files with 39 additions and 39 deletions
|
|
@ -4,15 +4,15 @@ import {Menu} from "../../../plugin/API";
|
|||
import {getIconByType} from "./render";
|
||||
|
||||
export const avClick = (protyle: IProtyle, event: MouseEvent & { target: HTMLElement }) => {
|
||||
const blockElement = hasClosestBlock(event.target)
|
||||
const addElement = hasClosestByAttribute(event.target, "data-type", "av-header-add")
|
||||
const blockElement = hasClosestBlock(event.target);
|
||||
const addElement = hasClosestByAttribute(event.target, "data-type", "av-header-add");
|
||||
if (addElement && blockElement) {
|
||||
const menu = new Menu("av-header-add")
|
||||
const menu = new Menu("av-header-add");
|
||||
menu.addItem({
|
||||
icon: "iconAlignLeft",
|
||||
label: window.siyuan.languages.text,
|
||||
click() {
|
||||
const id = Lute.NewNodeID()
|
||||
const id = Lute.NewNodeID();
|
||||
transaction(protyle, [{
|
||||
action: "addAttrViewCol",
|
||||
name: "Text",
|
||||
|
|
@ -25,28 +25,28 @@ export const avClick = (protyle: IProtyle, event: MouseEvent & { target: HTMLEle
|
|||
parentID: blockElement.getAttribute("data-av-type"),
|
||||
}]);
|
||||
}
|
||||
})
|
||||
const addRect = addElement.getBoundingClientRect()
|
||||
});
|
||||
const addRect = addElement.getBoundingClientRect();
|
||||
menu.open({
|
||||
x: addRect.left,
|
||||
y: addRect.bottom,
|
||||
h: addRect.height
|
||||
})
|
||||
});
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
return true
|
||||
return true;
|
||||
}
|
||||
const cellElement = hasClosestByClassName(event.target, "av__cell")
|
||||
const cellElement = hasClosestByClassName(event.target, "av__cell");
|
||||
if (cellElement && blockElement) {
|
||||
const type = cellElement.getAttribute("data-dtype")
|
||||
const menu = new Menu("av-header-cell")
|
||||
const type = cellElement.getAttribute("data-dtype");
|
||||
const menu = new Menu("av-header-cell");
|
||||
menu.addItem({
|
||||
icon: getIconByType(type),
|
||||
label: `<input style="margin: 4px 0" class="b3-text-field" type="text" value="${cellElement.innerText.trim()}">`,
|
||||
bind() {
|
||||
|
||||
}
|
||||
})
|
||||
});
|
||||
if (type !== "block") {
|
||||
menu.addItem({
|
||||
icon: "iconEdit",
|
||||
|
|
@ -54,31 +54,31 @@ export const avClick = (protyle: IProtyle, event: MouseEvent & { target: HTMLEle
|
|||
click() {
|
||||
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
menu.addSeparator()
|
||||
menu.addSeparator();
|
||||
menu.addItem({
|
||||
icon: "iconUp",
|
||||
label: window.siyuan.languages.fileNameNatASC,
|
||||
click() {
|
||||
|
||||
}
|
||||
})
|
||||
});
|
||||
menu.addItem({
|
||||
icon: "iconDown",
|
||||
label: window.siyuan.languages.fileNameNatDESC,
|
||||
click() {
|
||||
|
||||
}
|
||||
})
|
||||
});
|
||||
menu.addItem({
|
||||
icon: "iconFilter",
|
||||
label: window.siyuan.languages.filter,
|
||||
click() {
|
||||
|
||||
}
|
||||
})
|
||||
menu.addSeparator()
|
||||
});
|
||||
menu.addSeparator();
|
||||
if (type !== "block") {
|
||||
menu.addItem({
|
||||
icon: "iconEyeoff",
|
||||
|
|
@ -86,22 +86,22 @@ export const avClick = (protyle: IProtyle, event: MouseEvent & { target: HTMLEle
|
|||
click() {
|
||||
|
||||
}
|
||||
})
|
||||
});
|
||||
menu.addItem({
|
||||
icon: "iconCopy",
|
||||
label: window.siyuan.languages.duplicate,
|
||||
click() {
|
||||
|
||||
}
|
||||
})
|
||||
});
|
||||
menu.addItem({
|
||||
icon: "iconTrashcan",
|
||||
label: window.siyuan.languages.delete,
|
||||
click() {
|
||||
|
||||
}
|
||||
})
|
||||
menu.addSeparator()
|
||||
});
|
||||
menu.addSeparator();
|
||||
}
|
||||
menu.addItem({
|
||||
label: `<div class="fn__flex" style="margin-bottom: 4px"><span>${window.siyuan.languages.wrap}</span><span class="fn__space fn__flex-1"></span>
|
||||
|
|
@ -109,16 +109,16 @@ export const avClick = (protyle: IProtyle, event: MouseEvent & { target: HTMLEle
|
|||
click() {
|
||||
|
||||
}
|
||||
})
|
||||
const cellRect = cellElement.getBoundingClientRect()
|
||||
});
|
||||
const cellRect = cellElement.getBoundingClientRect();
|
||||
menu.open({
|
||||
x: cellRect.left,
|
||||
y: cellRect.bottom,
|
||||
h: cellRect.height
|
||||
})
|
||||
});
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
return true
|
||||
return true;
|
||||
}
|
||||
return false
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue