Vanessa 2024-07-24 22:23:20 +08:00
parent cfdec8fcda
commit ab91541600

View file

@ -471,6 +471,7 @@ export const refMenu = (protyle: IProtyle, element: HTMLElement) => {
let submenu: IMenu[] = [];
if (element.getAttribute("data-subtype") === "s") {
submenu.push({
iconHTML: "",
label: window.siyuan.languages.turnToDynamic,
click() {
element.setAttribute("data-subtype", "d");
@ -485,6 +486,7 @@ export const refMenu = (protyle: IProtyle, element: HTMLElement) => {
});
} else {
submenu.push({
iconHTML: "",
label: window.siyuan.languages.turnToStatic,
click() {
element.setAttribute("data-subtype", "s");
@ -496,6 +498,7 @@ export const refMenu = (protyle: IProtyle, element: HTMLElement) => {
});
}
submenu = submenu.concat([{
iconHTML: "",
label: window.siyuan.languages.text,
click() {
nodeElement.setAttribute("updated", dayjs().format("YYYYMMDDHHmmss"));
@ -504,6 +507,7 @@ export const refMenu = (protyle: IProtyle, element: HTMLElement) => {
oldHTML = nodeElement.outerHTML;
}
}, {
iconHTML: "",
label: "*",
click() {
element.setAttribute("data-subtype", "s");
@ -514,6 +518,7 @@ export const refMenu = (protyle: IProtyle, element: HTMLElement) => {
oldHTML = nodeElement.outerHTML;
}
}, {
iconHTML: "",
label: window.siyuan.languages.text + " *",
click() {
element.insertAdjacentHTML("beforebegin", element.innerHTML + " ");
@ -526,7 +531,7 @@ export const refMenu = (protyle: IProtyle, element: HTMLElement) => {
}
}, {
label: window.siyuan.languages.link,
icon: "iconLink",
iconHTML: "",
click() {
element.outerHTML = `<span data-type="a" data-href="siyuan://blocks/${element.getAttribute("data-id")}">${element.innerHTML}</span><wbr>`;
nodeElement.setAttribute("updated", dayjs().format("YYYYMMDDHHmmss"));
@ -537,8 +542,8 @@ export const refMenu = (protyle: IProtyle, element: HTMLElement) => {
}]);
if (element.parentElement.textContent.trim() === element.textContent.trim() && element.parentElement.tagName === "DIV") {
submenu.push({
iconHTML: "",
label: window.siyuan.languages.blockEmbed,
icon: "iconSQL",
click() {
const html = `<div data-content="select * from blocks where id='${refBlockId}'" data-node-id="${id}" data-type="NodeBlockQueryEmbed" class="render-node" updated="${dayjs().format("YYYYMMDDHHmmss")}">${nodeElement.querySelector(".protyle-attr").outerHTML}</div>`;
nodeElement.outerHTML = html;
@ -549,6 +554,7 @@ export const refMenu = (protyle: IProtyle, element: HTMLElement) => {
});
}
submenu.push({
iconHTML: "",
label: window.siyuan.languages.defBlock,
click() {
fetchPost("/api/block/swapBlockRef", {
@ -559,6 +565,7 @@ export const refMenu = (protyle: IProtyle, element: HTMLElement) => {
}
});
submenu.push({
iconHTML: "",
label: window.siyuan.languages.defBlockChildren,
click() {
fetchPost("/api/block/swapBlockRef", {