mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-02 23:08:49 +01:00
This commit is contained in:
parent
47bb845b1d
commit
6acf780269
4 changed files with 20 additions and 17 deletions
|
|
@ -54,6 +54,7 @@ import {avContextmenu, duplicateCompletely} from "../render/av/action";
|
|||
import {getPlainText} from "../util/paste";
|
||||
import {Menu} from "../../plugin/Menu";
|
||||
import {addEditorToDatabase} from "../render/av/addToDatabase";
|
||||
import {processClonePHElement} from "../render/util";
|
||||
|
||||
export class Gutter {
|
||||
public element: HTMLElement;
|
||||
|
|
@ -111,7 +112,7 @@ export class Gutter {
|
|||
getContenteditableElement(embedElement).innerHTML = `<svg class="svg"><use xlink:href="${buttonElement.querySelector("use").getAttribute("xlink:href")}"></use></svg> ${getLangByType(type)}`;
|
||||
ghostElement.append(embedElement);
|
||||
} else {
|
||||
ghostElement.append(item.cloneNode(true));
|
||||
ghostElement.append(processClonePHElement(item.cloneNode(true) as Element));
|
||||
}
|
||||
});
|
||||
ghostElement.setAttribute("style", `position:fixed;opacity:.1;width:${selectElements[0].clientWidth}px;padding:0;`);
|
||||
|
|
|
|||
|
|
@ -13,3 +13,11 @@ export const genIconHTML = (element?: false|HTMLElement) => {
|
|||
<span aria-label="${window.siyuan.languages.more}" class="b3-tooltips__nw b3-tooltips protyle-icon protyle-action__menu protyle-icon--last${enable ? "" : " protyle-icon--first"}"><svg><use xlink:href="#iconMore"></use></svg></span>
|
||||
</div>`;
|
||||
};
|
||||
|
||||
export const processClonePHElement = (item:Element) => {
|
||||
if (item.getAttribute("data-type") === "NodeHTMLBlock") {
|
||||
const phElement = item.querySelector("protyle-html");
|
||||
phElement.setAttribute("data-content", Lute.UnEscapeHTMLStr(phElement.getAttribute("data-content")));
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ import {onGet} from "../util/onGet";
|
|||
import {Constants} from "../../constants";
|
||||
import * as dayjs from "dayjs";
|
||||
import {net2LocalAssets} from "../breadcrumb/action";
|
||||
import {processClonePHElement} from "../render/util";
|
||||
|
||||
export const commonHotkey = (protyle: IProtyle, event: KeyboardEvent, nodeElement?: HTMLElement) => {
|
||||
if (matchHotKey(window.siyuan.config.keymap.editor.general.copyHPath.custom, event)) {
|
||||
|
|
@ -211,15 +212,7 @@ export const duplicateBlock = (nodeElements: Element[], protyle: IProtyle) => {
|
|||
tempElement.setAttribute("data-marker", (orderIndex) + ".");
|
||||
tempElement.querySelector(".protyle-action--order").textContent = (orderIndex) + ".";
|
||||
}
|
||||
if (tempElement.dataset.type === "NodeHTMLBlock") {
|
||||
const phElement = tempElement.querySelector("protyle-html");
|
||||
const content = phElement.getAttribute("data-content");
|
||||
phElement.setAttribute("data-content", "");
|
||||
nodeElements[0].after(tempElement);
|
||||
phElement.setAttribute("data-content", Lute.UnEscapeHTMLStr(content));
|
||||
} else {
|
||||
nodeElements[0].after(tempElement);
|
||||
}
|
||||
nodeElements[0].after(processClonePHElement(tempElement));
|
||||
doOperations.push({
|
||||
action: "insert",
|
||||
data: tempElement.outerHTML,
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ import {reloadProtyle} from "../util/reload";
|
|||
import {countBlockWord} from "../../layout/status";
|
||||
import {isPaidUser, needSubscribe} from "../../util/needSubscribe";
|
||||
import {resize} from "../util/resize";
|
||||
import {processClonePHElement} from "../render/util";
|
||||
|
||||
const removeTopElement = (updateElement: Element, protyle: IProtyle) => {
|
||||
// 移动到其他文档中,该块需移除
|
||||
|
|
@ -207,7 +208,7 @@ const promiseTransaction = () => {
|
|||
if (operation.previousID && updateElements.length > 0) {
|
||||
Array.from(protyle.wysiwyg.element.querySelectorAll(`[data-node-id="${operation.previousID}"]`)).forEach(item => {
|
||||
if (item.getAttribute("data-type") === "NodeBlockQueryEmbed" || !hasClosestByAttribute(item.parentElement, "data-type", "NodeBlockQueryEmbed")) {
|
||||
item.after(updateElements[0].cloneNode(true));
|
||||
item.after(processClonePHElement(updateElements[0].cloneNode(true) as Element));
|
||||
hasFind = true;
|
||||
}
|
||||
});
|
||||
|
|
@ -216,9 +217,9 @@ const promiseTransaction = () => {
|
|||
if (item.getAttribute("data-type") === "NodeBlockQueryEmbed" || !hasClosestByAttribute(item.parentElement, "data-type", "NodeBlockQueryEmbed")) {
|
||||
// 列表特殊处理
|
||||
if (item.firstElementChild?.classList.contains("protyle-action")) {
|
||||
item.firstElementChild.after(updateElements[0].cloneNode(true));
|
||||
item.firstElementChild.after(processClonePHElement(updateElements[0].cloneNode(true) as Element));
|
||||
} else {
|
||||
item.prepend(updateElements[0].cloneNode(true));
|
||||
item.prepend(processClonePHElement(updateElements[0].cloneNode(true) as Element));
|
||||
}
|
||||
hasFind = true;
|
||||
}
|
||||
|
|
@ -638,22 +639,22 @@ export const onTransaction = (protyle: IProtyle, operation: IOperation, isUndo:
|
|||
if (operation.previousID && updateElements.length > 0) {
|
||||
Array.from(protyle.wysiwyg.element.querySelectorAll(`[data-node-id="${operation.previousID}"]`)).forEach(item => {
|
||||
if (!hasClosestByAttribute(item.parentElement, "data-type", "NodeBlockQueryEmbed")) {
|
||||
item.after(updateElements[0].cloneNode(true));
|
||||
item.after(processClonePHElement(updateElements[0].cloneNode(true) as Element));
|
||||
hasFind = true;
|
||||
}
|
||||
});
|
||||
} else if (updateElements.length > 0) {
|
||||
if (!protyle.options.backlinkData && operation.parentID === protyle.block.parentID) {
|
||||
protyle.wysiwyg.element.prepend(updateElements[0].cloneNode(true));
|
||||
protyle.wysiwyg.element.prepend(processClonePHElement(updateElements[0].cloneNode(true) as Element));
|
||||
hasFind = true;
|
||||
} else {
|
||||
Array.from(protyle.wysiwyg.element.querySelectorAll(`[data-node-id="${operation.parentID}"]`)).forEach(item => {
|
||||
if (!hasClosestByAttribute(item.parentElement, "data-type", "NodeBlockQueryEmbed")) {
|
||||
// 列表特殊处理
|
||||
if (item.firstElementChild?.classList.contains("protyle-action")) {
|
||||
item.firstElementChild.after(updateElements[0].cloneNode(true));
|
||||
item.firstElementChild.after(processClonePHElement(updateElements[0].cloneNode(true) as Element));
|
||||
} else {
|
||||
item.prepend(updateElements[0].cloneNode(true));
|
||||
item.prepend(processClonePHElement(updateElements[0].cloneNode(true) as Element));
|
||||
}
|
||||
hasFind = true;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue