Vanessa 2025-05-07 13:02:00 +08:00
parent e108d10647
commit d1ed86efe7
2 changed files with 17 additions and 7 deletions

View file

@ -631,7 +631,7 @@ export const refMenu = (protyle: IProtyle, element: HTMLElement) => {
label: window.siyuan.languages.copy,
icon: "iconCopy",
click() {
writeText(protyle.lute.BlockDOM2StdMd(element.outerHTML));
writeText(protyle.lute.BlockDOM2StdMd(element.outerHTML).trim());
}
}).element);
if (!protyle.disabled) {

View file

@ -398,12 +398,22 @@ export const paste = async (protyle: IProtyle, event: (ClipboardEvent | DragEven
// 编辑器内部粘贴
const tempElement = document.createElement("div");
tempElement.innerHTML = siyuanHTML;
if (tempElement.childElementCount === 1 && ((tempElement.firstElementChild as HTMLElement).dataset?.type || "").split(" ").includes("block-ref")) {
protyle.toolbar.setInlineMark(protyle, "block-ref", "range", {
type: "id",
color: `${(tempElement.firstElementChild as HTMLElement).dataset.id}${Constants.ZWSP}s${Constants.ZWSP}${range.toString()}`
});
return;
if (tempElement.childElementCount === 1) {
const types = ((tempElement.firstElementChild as HTMLElement).dataset?.type || "").split(" ")
if(types.includes("block-ref")) {
protyle.toolbar.setInlineMark(protyle, "block-ref", "range", {
type: "id",
color: `${(tempElement.firstElementChild as HTMLElement).dataset.id}${Constants.ZWSP}s${Constants.ZWSP}${range.toString()}`
});
return;
}
if(types.includes("a")) {
protyle.toolbar.setInlineMark(protyle, "a", "range", {
type: "a",
color: `${(tempElement.firstElementChild as HTMLElement).dataset.href}${Constants.ZWSP}${range.toString()}`
});
return;
}
}
let isBlock = false;
tempElement.querySelectorAll("[data-node-id]").forEach((e) => {