mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-20 08:30:12 +01:00
This commit is contained in:
parent
5d70f3cf64
commit
fb2cb8edbf
5 changed files with 9 additions and 9 deletions
|
|
@ -72,7 +72,7 @@ export const refMenu = (protyle: IProtyle, element: HTMLElement) => {
|
||||||
element.textContent = Lute.EscapeHTMLStr(inputElement.value);
|
element.textContent = Lute.EscapeHTMLStr(inputElement.value);
|
||||||
} else {
|
} else {
|
||||||
fetchPost("/api/block/getRefText", {id: refBlockId}, (response) => {
|
fetchPost("/api/block/getRefText", {id: refBlockId}, (response) => {
|
||||||
element.textContent = Lute.EscapeHTMLStr(response.data);
|
element.innerHTML = response.data;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -141,7 +141,7 @@ export const refMenu = (protyle: IProtyle, element: HTMLElement) => {
|
||||||
click() {
|
click() {
|
||||||
element.setAttribute("data-subtype", "d");
|
element.setAttribute("data-subtype", "d");
|
||||||
fetchPost("/api/block/getRefText", {id: refBlockId}, (response) => {
|
fetchPost("/api/block/getRefText", {id: refBlockId}, (response) => {
|
||||||
element.innerHTML = Lute.EscapeHTMLStr(response.data);
|
element.innerHTML = response.data;
|
||||||
nodeElement.setAttribute("updated", dayjs().format("YYYYMMDDHHmmss"));
|
nodeElement.setAttribute("updated", dayjs().format("YYYYMMDDHHmmss"));
|
||||||
updateTransaction(protyle, id, nodeElement.outerHTML, oldHTML);
|
updateTransaction(protyle, id, nodeElement.outerHTML, oldHTML);
|
||||||
});
|
});
|
||||||
|
|
@ -162,7 +162,7 @@ export const refMenu = (protyle: IProtyle, element: HTMLElement) => {
|
||||||
submenu = submenu.concat([{
|
submenu = submenu.concat([{
|
||||||
label: window.siyuan.languages.text,
|
label: window.siyuan.languages.text,
|
||||||
click() {
|
click() {
|
||||||
element.outerHTML = `${element.textContent}<wbr>`;
|
element.outerHTML = `${element.innerHTML}<wbr>`;
|
||||||
nodeElement.setAttribute("updated", dayjs().format("YYYYMMDDHHmmss"));
|
nodeElement.setAttribute("updated", dayjs().format("YYYYMMDDHHmmss"));
|
||||||
updateTransaction(protyle, id, nodeElement.outerHTML, oldHTML);
|
updateTransaction(protyle, id, nodeElement.outerHTML, oldHTML);
|
||||||
focusByWbr(nodeElement, protyle.toolbar.range);
|
focusByWbr(nodeElement, protyle.toolbar.range);
|
||||||
|
|
@ -179,7 +179,7 @@ export const refMenu = (protyle: IProtyle, element: HTMLElement) => {
|
||||||
}, {
|
}, {
|
||||||
label: window.siyuan.languages.text + " *",
|
label: window.siyuan.languages.text + " *",
|
||||||
click() {
|
click() {
|
||||||
element.insertAdjacentText("beforebegin", element.textContent + " ");
|
element.insertAdjacentHTML("beforebegin", element.innerHTML + " ");
|
||||||
element.setAttribute("data-subtype", "s");
|
element.setAttribute("data-subtype", "s");
|
||||||
element.textContent = "*";
|
element.textContent = "*";
|
||||||
nodeElement.setAttribute("updated", dayjs().format("YYYYMMDDHHmmss"));
|
nodeElement.setAttribute("updated", dayjs().format("YYYYMMDDHHmmss"));
|
||||||
|
|
@ -190,7 +190,7 @@ export const refMenu = (protyle: IProtyle, element: HTMLElement) => {
|
||||||
label: window.siyuan.languages.link,
|
label: window.siyuan.languages.link,
|
||||||
icon: "iconLink",
|
icon: "iconLink",
|
||||||
click() {
|
click() {
|
||||||
element.outerHTML = `<span data-type="a" data-href="siyuan://blocks/${element.getAttribute("data-id")}">${element.textContent}</span><wbr>`;
|
element.outerHTML = `<span data-type="a" data-href="siyuan://blocks/${element.getAttribute("data-id")}">${element.innerHTML}</span><wbr>`;
|
||||||
nodeElement.setAttribute("updated", dayjs().format("YYYYMMDDHHmmss"));
|
nodeElement.setAttribute("updated", dayjs().format("YYYYMMDDHHmmss"));
|
||||||
updateTransaction(protyle, id, nodeElement.outerHTML, oldHTML);
|
updateTransaction(protyle, id, nodeElement.outerHTML, oldHTML);
|
||||||
focusByWbr(nodeElement, protyle.toolbar.range);
|
focusByWbr(nodeElement, protyle.toolbar.range);
|
||||||
|
|
|
||||||
|
|
@ -321,7 +321,7 @@ export class Gutter {
|
||||||
options.protyle.wysiwyg.element.querySelectorAll('[data-type="block-ref"]').forEach(item => {
|
options.protyle.wysiwyg.element.querySelectorAll('[data-type="block-ref"]').forEach(item => {
|
||||||
if (item.textContent === "") {
|
if (item.textContent === "") {
|
||||||
fetchPost("/api/block/getRefText", {id: item.getAttribute("data-id")}, (response) => {
|
fetchPost("/api/block/getRefText", {id: item.getAttribute("data-id")}, (response) => {
|
||||||
item.textContent = response.data;
|
item.innerHTML = response.data;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -255,7 +255,7 @@ export const paste = async (protyle: IProtyle, event: (ClipboardEvent | DragEven
|
||||||
protyle.wysiwyg.element.querySelectorAll('[data-type="block-ref"]').forEach(item => {
|
protyle.wysiwyg.element.querySelectorAll('[data-type="block-ref"]').forEach(item => {
|
||||||
if (item.textContent === "") {
|
if (item.textContent === "") {
|
||||||
fetchPost("/api/block/getRefText", {id: item.getAttribute("data-id")}, (response) => {
|
fetchPost("/api/block/getRefText", {id: item.getAttribute("data-id")}, (response) => {
|
||||||
item.textContent = response.data;
|
item.innerHTML = response.data;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -75,7 +75,7 @@ export const input = async (protyle: IProtyle, blockElement: HTMLElement, range:
|
||||||
const refElement = hasClosestByAttribute(range.startContainer, "data-type", "block-ref");
|
const refElement = hasClosestByAttribute(range.startContainer, "data-type", "block-ref");
|
||||||
if (refElement && refElement.getAttribute("data-subtype") === "d") {
|
if (refElement && refElement.getAttribute("data-subtype") === "d") {
|
||||||
const response = await fetchSyncPost("/api/block/getRefText", {id: refElement.getAttribute("data-id")});
|
const response = await fetchSyncPost("/api/block/getRefText", {id: refElement.getAttribute("data-id")});
|
||||||
if (response.data !== refElement.textContent) {
|
if (response.data !== refElement.innerHTML) {
|
||||||
refElement.setAttribute("data-subtype", "s");
|
refElement.setAttribute("data-subtype", "s");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -659,7 +659,7 @@ const updateRef = (protyle: IProtyle, id: string, index = 0) => {
|
||||||
protyle.wysiwyg.element.querySelectorAll(`[data-type="block-ref"][data-id="${id}"]`).forEach(item => {
|
protyle.wysiwyg.element.querySelectorAll(`[data-type="block-ref"][data-id="${id}"]`).forEach(item => {
|
||||||
if (item.getAttribute("data-subtype") === "d") {
|
if (item.getAttribute("data-subtype") === "d") {
|
||||||
fetchPost("/api/block/getRefText", {id: id}, (response) => {
|
fetchPost("/api/block/getRefText", {id: id}, (response) => {
|
||||||
item.textContent = response.data;
|
item.innerHTML = response.data;
|
||||||
const blockElement = hasClosestBlock(item);
|
const blockElement = hasClosestBlock(item);
|
||||||
if (blockElement) {
|
if (blockElement) {
|
||||||
updateRef(protyle, blockElement.getAttribute("data-node-id"), index + 1);
|
updateRef(protyle, blockElement.getAttribute("data-node-id"), index + 1);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue