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);
|
||||
} else {
|
||||
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() {
|
||||
element.setAttribute("data-subtype", "d");
|
||||
fetchPost("/api/block/getRefText", {id: refBlockId}, (response) => {
|
||||
element.innerHTML = Lute.EscapeHTMLStr(response.data);
|
||||
element.innerHTML = response.data;
|
||||
nodeElement.setAttribute("updated", dayjs().format("YYYYMMDDHHmmss"));
|
||||
updateTransaction(protyle, id, nodeElement.outerHTML, oldHTML);
|
||||
});
|
||||
|
@ -162,7 +162,7 @@ export const refMenu = (protyle: IProtyle, element: HTMLElement) => {
|
|||
submenu = submenu.concat([{
|
||||
label: window.siyuan.languages.text,
|
||||
click() {
|
||||
element.outerHTML = `${element.textContent}<wbr>`;
|
||||
element.outerHTML = `${element.innerHTML}<wbr>`;
|
||||
nodeElement.setAttribute("updated", dayjs().format("YYYYMMDDHHmmss"));
|
||||
updateTransaction(protyle, id, nodeElement.outerHTML, oldHTML);
|
||||
focusByWbr(nodeElement, protyle.toolbar.range);
|
||||
|
@ -179,7 +179,7 @@ export const refMenu = (protyle: IProtyle, element: HTMLElement) => {
|
|||
}, {
|
||||
label: window.siyuan.languages.text + " *",
|
||||
click() {
|
||||
element.insertAdjacentText("beforebegin", element.textContent + " ");
|
||||
element.insertAdjacentHTML("beforebegin", element.innerHTML + " ");
|
||||
element.setAttribute("data-subtype", "s");
|
||||
element.textContent = "*";
|
||||
nodeElement.setAttribute("updated", dayjs().format("YYYYMMDDHHmmss"));
|
||||
|
@ -190,7 +190,7 @@ export const refMenu = (protyle: IProtyle, element: HTMLElement) => {
|
|||
label: window.siyuan.languages.link,
|
||||
icon: "iconLink",
|
||||
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"));
|
||||
updateTransaction(protyle, id, nodeElement.outerHTML, oldHTML);
|
||||
focusByWbr(nodeElement, protyle.toolbar.range);
|
||||
|
|
|
@ -321,7 +321,7 @@ export class Gutter {
|
|||
options.protyle.wysiwyg.element.querySelectorAll('[data-type="block-ref"]').forEach(item => {
|
||||
if (item.textContent === "") {
|
||||
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 => {
|
||||
if (item.textContent === "") {
|
||||
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");
|
||||
if (refElement && refElement.getAttribute("data-subtype") === "d") {
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 => {
|
||||
if (item.getAttribute("data-subtype") === "d") {
|
||||
fetchPost("/api/block/getRefText", {id: id}, (response) => {
|
||||
item.textContent = response.data;
|
||||
item.innerHTML = response.data;
|
||||
const blockElement = hasClosestBlock(item);
|
||||
if (blockElement) {
|
||||
updateRef(protyle, blockElement.getAttribute("data-node-id"), index + 1);
|
||||
|
|
Loading…
Add table
Reference in a new issue