Vanessa
2026-06-06 23:45:07 +08:00
parent 86795a96a6
commit 5398a3e686
12 changed files with 24 additions and 0 deletions
+2
View File
@@ -2326,6 +2326,7 @@ export class Gutter {
const undoOperations: IOperation[] = [];
const operations: IOperation[] = [];
nodeElements.forEach((e) => {
e.setAttribute(Constants.ATTRIBUTE_EDITING, "true");
undoOperations.push({
action: "update",
id: e.getAttribute("data-node-id"),
@@ -2334,6 +2335,7 @@ export class Gutter {
});
inputElement.addEventListener(inputElement.type === "number" ? "blur" : "change", () => {
nodeElements.forEach((e: HTMLElement) => {
e.setAttribute(Constants.ATTRIBUTE_EDITING, "true");
operations.push({
action: "update",
id: e.getAttribute("data-node-id"),
+1
View File
@@ -622,6 +622,7 @@ export const hintMoveBlock = (pathString: string, sourceElements: Element[], pro
if (item.classList.contains("protyle-attr")) {
return;
}
item.setAttribute(Constants.ATTRIBUTE_EDITING, "true");
doOperations.push({
action: "update",
id: item.getAttribute("data-node-id"),
+1
View File
@@ -837,6 +837,7 @@ ${genHintItemHTML(item)}
}
nodeElement.insertAdjacentHTML("afterend", newHTML);
const newId = newHTML.substr(newHTML.indexOf('data-node-id="') + 14, 22);
nodeElement.setAttribute(Constants.ATTRIBUTE_EDITING, "true");
nodeElement = protyle.wysiwyg.element.querySelector(`[data-node-id="${newId}"]`);
// https://github.com/siyuan-note/siyuan/issues/6864
if (nodeElement.getAttribute("data-type") === "NodeTable") {
+1
View File
@@ -1899,6 +1899,7 @@ export class Toolbar {
highlightRender(nodeElement);
}
nodeElement.setAttribute("updated", dayjs().format("YYYYMMDDHHmmss"));
nodeElement.setAttribute(Constants.ATTRIBUTE_EDITING, "true");
doOperations.push({
id,
data: nodeElement.outerHTML,
+2
View File
@@ -362,6 +362,7 @@ export const insertHTML = (html: string, protyle: IProtyle, isBlock = false,
range.deleteContents();
}
range.insertNode(document.createElement("wbr"));
blockElement.setAttribute(Constants.ATTRIBUTE_EDITING, "true");
undoOperation.push({
action: "update",
id,
@@ -463,6 +464,7 @@ export const insertHTML = (html: string, protyle: IProtyle, isBlock = false,
let addId = item.getAttribute("data-node-id");
const hasParentHeading = item.getAttribute("parent-heading");
if (addId === id) {
item.setAttribute(Constants.ATTRIBUTE_EDITING, "true");
doOperation.push({
action: "update",
data: item.outerHTML,
+1
View File
@@ -75,6 +75,7 @@ export const updateCalloutType = (blockElements: HTMLElement[], protyle: IProtyl
item.querySelector(".callout-title").innerHTML = title ||
(textElements[0].value.trim().substring(0, 1).toUpperCase() + textElements[0].value.trim().substring(1).toLowerCase());
item.querySelector(".callout-icon").innerHTML = dialogCalloutIconElement.innerHTML;
item.setAttribute(Constants.ATTRIBUTE_EDITING, "true");
doOperations.push({
id,
data: item.outerHTML,
+1
View File
@@ -388,6 +388,7 @@ export const duplicateBlock = async (nodeElements: Element[], protyle: IProtyle)
});
nextElement.setAttribute("data-marker", starIndex + ".");
nextElement.querySelector(".protyle-action--order").textContent = starIndex + ".";
nextElement.setAttribute(Constants.ATTRIBUTE_EDITING, "true");
doOperations.push({
action: "update",
data: nextElement.outerHTML,
+3
View File
@@ -284,6 +284,7 @@ export const enter = (blockElement: HTMLElement, range: Range, protyle: IProtyle
if (item.dataset.nodeId === id) {
blockElement.before(item);
blockElement.remove();
item.setAttribute(Constants.ATTRIBUTE_EDITING, "true");
doOperation.push({
action: "update",
data: item.outerHTML,
@@ -485,6 +486,7 @@ const listEnter = (protyle: IProtyle, blockElement: HTMLElement, range: Range) =
updateListOrder(listItemElement.parentElement);
}
if (listItemElement.parentElement.classList.contains("protyle-wysiwyg")) {
listItemElement.setAttribute(Constants.ATTRIBUTE_EDITING, "true");
transaction(protyle, [{
action: "update",
data: listItemElement.outerHTML,
@@ -573,6 +575,7 @@ const listEnter = (protyle: IProtyle, blockElement: HTMLElement, range: Range) =
updateListOrder(listItemElement.parentElement);
}
if (listItemElement.parentElement.classList.contains("protyle-wysiwyg")) {
listItemElement.setAttribute(Constants.ATTRIBUTE_EDITING, "true");
transaction(protyle, [{
action: "update",
id: listItemElement.getAttribute("data-node-id"),
+4
View File
@@ -288,6 +288,7 @@ export const listIndent = (protyle: IProtyle, liItemElements: Element[], range:
const count = index + 1 + ".";
item.setAttribute("data-marker", count);
item.querySelector(".protyle-action--order").textContent = count;
item.setAttribute(Constants.ATTRIBUTE_EDITING, "true");
doOperations.push({
action: "update",
id: itemId,
@@ -682,6 +683,7 @@ export const listOutdent = (protyle: IProtyle, liItemElements: Element[], range:
item.setAttribute("data-marker", "*");
item.removeAttribute("data-task");
item.classList.remove("protyle-task--done");
item.setAttribute(Constants.ATTRIBUTE_EDITING, "true");
doOperations.push({
action: "update",
id: itemId,
@@ -698,6 +700,7 @@ export const listOutdent = (protyle: IProtyle, liItemElements: Element[], range:
item.setAttribute("data-subtype", "o");
item.setAttribute("data-marker", "1.");
item.removeAttribute("data-task");
item.setAttribute(Constants.ATTRIBUTE_EDITING, "true");
doOperations.push({
action: "update",
id: itemId,
@@ -714,6 +717,7 @@ export const listOutdent = (protyle: IProtyle, liItemElements: Element[], range:
item.setAttribute("data-subtype", "t");
item.setAttribute("data-marker", "*");
item.setAttribute("data-task", " ");
item.setAttribute(Constants.ATTRIBUTE_EDITING, "true");
doOperations.push({
action: "update",
id: itemId,
+3
View File
@@ -578,6 +578,7 @@ export const removeBlock = async (protyle: IProtyle, blockElement: Element, rang
// extractContents 内容过多时需要进行滚动条重置,否则位置会错位
protyle.contentElement.scrollTop = scroll;
protyle.scroll.lastScrollTop = scroll - 1;
previousLastElement.setAttribute(Constants.ATTRIBUTE_EDITING, "true");
doOperations.push({
action: "update",
data: previousLastElement.outerHTML,
@@ -650,6 +651,8 @@ const removeLi = (protyle: IProtyle, blockElement: Element, range: Range, isDele
if (listElement.getAttribute("data-subtype") === "o") {
updateListOrder(listElement);
}
listElement.setAttribute(Constants.ATTRIBUTE_EDITING, "true");
previousLastElement.parentElement.setAttribute(Constants.ATTRIBUTE_EDITING, "true");
transaction(protyle, [{
action: "update",
id: listElement.getAttribute("data-node-id"),
+2
View File
@@ -1178,6 +1178,7 @@ export const turnsIntoTransaction = (options: {
if (foldData && foldData.doOperations?.length > 0) {
doOperations.push(...foldData.doOperations);
}
item.setAttribute(Constants.ATTRIBUTE_EDITING, "true");
undoOperations.push({
action: "update",
id,
@@ -1545,6 +1546,7 @@ export const updateBatchTransaction = (nodeElements: Element[], protyle: IProtyl
data: element.outerHTML
});
cb(element as HTMLElement);
element.setAttribute(Constants.ATTRIBUTE_EDITING, "true");
operations.push({
action: "update",
id,
+3
View File
@@ -2,6 +2,7 @@ import {transaction, updateTransaction} from "./transaction";
import {focusByWbr} from "../util/selection";
import * as dayjs from "dayjs";
import {decodeHTML, escapeAttr} from "../../util/escape";
import {Constants} from "../../constants";
export const turnIntoTaskList = (protyle: IProtyle, type: string, blockElement: HTMLElement, editElement: HTMLElement, range: Range) => {
const html = decodeHTML(editElement.innerHTML);
@@ -52,6 +53,7 @@ export const turnIntoTaskList = (protyle: IProtyle, type: string, blockElement:
const liItemId = Lute.NewNodeID();
const oldHTML = blockElement.outerHTML;
editElement.innerHTML = html.substring(contextStartIndex);
blockElement.setAttribute(Constants.ATTRIBUTE_EDITING, "true");
transaction(protyle, [{
action: "update",
id,
@@ -98,6 +100,7 @@ export const headingTurnIntoList = (protyle: IProtyle, type: string, blockElemen
const oldHTML = blockElement.outerHTML;
const marker = editElement.innerHTML.substring(0, 1);
editElement.innerHTML = editElement.innerHTML.substring(2);
blockElement.setAttribute(Constants.ATTRIBUTE_EDITING, "true");
transaction(protyle, [{
action: "update",
id,