This commit is contained in:
Vanessa 2025-04-03 15:13:01 +08:00
parent 8b5eb89148
commit b186398052
6 changed files with 17 additions and 17 deletions

View file

@ -46,7 +46,7 @@ export const cancelSB = async (protyle: IProtyle, nodeElement: Element, range?:
id,
});
if (range) {
getContenteditableElement(nodeElement).insertAdjacentHTML("afterbegin", "<wbr>")
getContenteditableElement(nodeElement).insertAdjacentHTML("afterbegin", "<wbr>");
}
nodeElement.lastElementChild.remove();
// 超级块中的 html 块需要反转义再赋值 https://github.com/siyuan-note/siyuan/issues/13155

View file

@ -146,18 +146,18 @@ export const initConfigSearch = (element: HTMLElement, app: App) => {
keymap.search(searchElement.value, searchKeymapElement.value);
} else if (type === "search") {
panelElement.querySelectorAll(`.config__tab-container[data-name="${type}"] .b3-label`).forEach((itemElement: HTMLElement) => {
let showItemElement = false
let showItemElement = false;
itemElement.querySelectorAll("label > .fn__flex-1").forEach(labelItem => {
if (!labelItem.parentElement.classList.contains("fn__none")) {
const text = labelItem.textContent.toLowerCase();
if (text.indexOf(inputValue.toLowerCase()) > -1 || inputValue.toLowerCase().indexOf(text) > -1) {
labelItem.parentElement.style.display = "";
showItemElement = true
showItemElement = true;
} else {
labelItem.parentElement.style.display = "none";
}
}
})
});
if (!itemElement.classList.contains("fn__none")) {
if (showItemElement) {
itemElement.style.display = "";

View file

@ -8,7 +8,7 @@ import {escapeGreat, escapeHtml} from "../util/escape";
import {unicode2Emoji} from "../emoji";
import {fetchPost} from "../util/fetch";
import {hideTooltip, showTooltip} from "../dialog/tooltip";
import {isTouchDevice, isWindow} from "../util/functions";
import {isTouchDevice} from "../util/functions";
/// #if !BROWSER
import {openNewWindow} from "../window/openNewWindow";
import {ipcRenderer} from "electron";

View file

@ -535,7 +535,7 @@ const dragSb = async (protyle: IProtyle, sourceElements: Element[], targetElemen
/// #if !MOBILE
const otherProtyleElement = hasClosestByClassName(oldSourceParentElement, "protyle", true);
if (otherProtyleElement) {
const allEditor = getAllEditor()
const allEditor = getAllEditor();
for (let i = 0; i < allEditor.length; i++) {
if (allEditor[i].protyle.element.isSameNode(otherProtyleElement)) {
const otherSbData = await cancelSB(allEditor[i].protyle, oldSourceParentElement);
@ -738,7 +738,7 @@ const dragSame = async (protyle: IProtyle, sourceElements: Element[], targetElem
/// #if !MOBILE
const otherProtyleElement = hasClosestByClassName(oldSourceParentElement, "protyle", true);
if (otherProtyleElement) {
const allEditor = getAllEditor()
const allEditor = getAllEditor();
for (let i = 0; i < allEditor.length; i++) {
if (allEditor[i].protyle.element.isSameNode(otherProtyleElement)) {
const otherSbData = await cancelSB(allEditor[i].protyle, oldSourceParentElement);

View file

@ -1,5 +1,5 @@
import {genEmptyElement, insertEmptyBlock} from "../../block/util";
import {focusBlock, focusByRange, focusByWbr, getSelectionOffset, setLastNodeRange} from "../util/selection";
import {focusByRange, focusByWbr, getSelectionOffset, setLastNodeRange} from "../util/selection";
import {
getContenteditableElement,
getTopEmptyElement,

View file

@ -274,14 +274,14 @@ const updateEmbed = (protyle: IProtyle, operation: IOperation) => {
});
tempElement.content.querySelectorAll(".protyle-wysiwyg--select").forEach(selectItem => {
selectItem.classList.remove("protyle-wysiwyg--select");
})
});
const wbrElement = tempElement.querySelector("wbr");
if (wbrElement) {
wbrElement.remove();
}
item.outerHTML = tempElement.innerHTML;
updatedEmbed = true;
}
};
const allTempElement = document.createElement("template");
allTempElement.innerHTML = operation.data;
@ -290,7 +290,7 @@ const updateEmbed = (protyle: IProtyle, operation: IOperation) => {
if (matchElement.length > 0) {
matchElement.forEach(embedItem => {
updateHTML(embedItem, operation.data);
})
});
} else {
item.querySelectorAll(".protyle-wysiwyg__embed").forEach(embedBlockItem => {
const newTempElement = allTempElement.content.querySelector(`[data-node-id="${embedBlockItem.getAttribute("data-id")}"]`);
@ -667,10 +667,10 @@ export const onTransaction = (protyle: IProtyle, operation: IOperation, isUndo:
}
let hasFind = false;
if (operation.previousID && updateElements.length > 0) {
const previousElement = protyle.wysiwyg.element.querySelectorAll(`[data-node-id="${operation.previousID}"]`)
const previousElement = protyle.wysiwyg.element.querySelectorAll(`[data-node-id="${operation.previousID}"]`);
if (previousElement.length === 0 && protyle.options.backlinkData && isUndo && getSelection().rangeCount > 0) {
// 反链面板删除超级块中的最后一个段落块后撤销重做
const blockElement = hasTopClosestByAttribute(range.startContainer, "data-node-id", null)
const blockElement = hasTopClosestByAttribute(range.startContainer, "data-node-id", null);
if (blockElement) {
blockElement.before(processClonePHElement(updateElements[0].cloneNode(true) as Element));
hasFind = true;
@ -684,13 +684,13 @@ export const onTransaction = (protyle: IProtyle, operation: IOperation, isUndo:
});
}
} else if (updateElements.length > 0) {
const parentElement = protyle.wysiwyg.element.querySelectorAll(`[data-node-id="${operation.parentID}"]`)
const parentElement = protyle.wysiwyg.element.querySelectorAll(`[data-node-id="${operation.parentID}"]`);
if (!protyle.options.backlinkData && operation.parentID === protyle.block.parentID) {
protyle.wysiwyg.element.prepend(processClonePHElement(updateElements[0].cloneNode(true) as Element));
hasFind = true;
} else if (parentElement.length === 0 && protyle.options.backlinkData && isUndo && getSelection().rangeCount > 0) {
// 反链面板删除超级块中的段落块后撤销再重做 https://github.com/siyuan-note/siyuan/issues/14496#issuecomment-2771372486
const topBlockElement = hasTopClosestByAttribute(getSelection().getRangeAt(0).startContainer, "data-node-id", null)
const topBlockElement = hasTopClosestByAttribute(getSelection().getRangeAt(0).startContainer, "data-node-id", null);
if (topBlockElement) {
topBlockElement.before(processClonePHElement(updateElements[0].cloneNode(true) as Element));
hasFind = true;
@ -749,7 +749,7 @@ export const onTransaction = (protyle: IProtyle, operation: IOperation, isUndo:
const previousElement = protyle.wysiwyg.element.querySelectorAll(`[data-node-id="${operation.previousID}"]`);
if (previousElement.length === 0 && protyle.options.backlinkData && isUndo && getSelection().rangeCount > 0) {
// 反链面板删除超级块中的最后一个段落块后撤销
const blockElement = hasClosestBlock(getSelection().getRangeAt(0).startContainer)
const blockElement = hasClosestBlock(getSelection().getRangeAt(0).startContainer);
if (blockElement) {
blockElement.insertAdjacentHTML("beforebegin", operation.data);
cursorElements.push(blockElement.previousElementSibling);
@ -786,7 +786,7 @@ export const onTransaction = (protyle: IProtyle, operation: IOperation, isUndo:
cursorElements.push(protyle.wysiwyg.element.firstElementChild);
} else if (parentElement.length === 0 && protyle.options.backlinkData && isUndo && getSelection().rangeCount > 0) {
// 反链面板删除超级块中的段落块后撤销
const blockElement = hasClosestBlock(getSelection().getRangeAt(0).startContainer)
const blockElement = hasClosestBlock(getSelection().getRangeAt(0).startContainer);
if (blockElement) {
blockElement.insertAdjacentHTML("beforebegin", operation.data);
cursorElements.push(blockElement.previousElementSibling);