Compare commits

...

5 commits

Author SHA1 Message Date
Vanessa
2f9d2afcd3 🎨 https://github.com/siyuan-note/siyuan/issues/15885 2025-09-20 17:02:11 +08:00
Vanessa
c4aee4d601 🎨 https://github.com/siyuan-note/siyuan/issues/15885 2025-09-20 16:46:50 +08:00
Vanessa
f34d8022b8 🎨 https://github.com/siyuan-note/siyuan/pull/15876 2025-09-20 15:55:33 +08:00
Vanessa
690dcb5899 🎨 https://github.com/siyuan-note/siyuan/issues/15797 2025-09-20 15:14:07 +08:00
Vanessa
192db4f306 🎨 https://github.com/siyuan-note/siyuan/issues/15864 2025-09-20 14:49:12 +08:00
6 changed files with 29 additions and 34 deletions

View file

@ -578,7 +578,7 @@ export const layoutToJSON = (layout: Layout | Wnd | Tab | Model, json: any, brea
json.blockId = layout.editor.protyle.block.id; json.blockId = layout.editor.protyle.block.id;
json.rootId = layout.editor.protyle.block.rootID; json.rootId = layout.editor.protyle.block.rootID;
json.mode = layout.editor.protyle.preview.element.classList.contains("fn__none") ? "wysiwyg" : "preview"; json.mode = layout.editor.protyle.preview.element.classList.contains("fn__none") ? "wysiwyg" : "preview";
json.action = layout.editor.protyle.block.showAll ? Constants.CB_GET_ALL : Constants.CB_GET_SCROLL; json.action = (layout.editor.protyle.block.showAll && layout.editor.protyle.block.id !== layout.editor.protyle.block.rootID) ? Constants.CB_GET_ALL : Constants.CB_GET_SCROLL;
json.instance = "Editor"; json.instance = "Editor";
} else if (layout instanceof Asset) { } else if (layout instanceof Asset) {
json.path = layout.path; json.path = layout.path;
@ -744,13 +744,20 @@ export const newModelByInitData = (app: App, tab: Tab, json: any) => {
}); });
} }
} else if (json.instance === "Editor") { } else if (json.instance === "Editor") {
if (json.rootId === json.blockId && json.action) {
if (typeof json.action === "string") {
json.action = json.action.replace(Constants.CB_GET_ALL, "");
} else if (typeof json.action === "object" && Array.isArray(json.action)) {
json.action = json.action.filter((item: string) => item !== Constants.CB_GET_ALL);
}
}
model = new Editor({ model = new Editor({
app, app,
tab, tab,
rootId: json.rootId, rootId: json.rootId,
blockId: json.blockId, blockId: json.blockId,
mode: json.mode, mode: json.mode,
action: typeof json.action === "string" ? [json.action, Constants.CB_GET_FOCUS] : json.action.concat(Constants.CB_GET_FOCUS), action: typeof json.action === "string" ? (json.action ? [json.action, Constants.CB_GET_FOCUS] : [Constants.CB_GET_FOCUS]) : json.action.concat(Constants.CB_GET_FOCUS),
}); });
} }
return model; return model;

View file

@ -1682,7 +1682,10 @@ export class Gutter {
icon: "iconCopy", icon: "iconCopy",
label: `${window.siyuan.languages.copy} ${window.siyuan.languages.headings1}`, label: `${window.siyuan.languages.copy} ${window.siyuan.languages.headings1}`,
click() { click() {
fetchPost("/api/block/getHeadingChildrenDOM", {id, removeFoldAttr: false}, (response) => { fetchPost("/api/block/getHeadingChildrenDOM", {
id,
removeFoldAttr: nodeElement.getAttribute("fold") !== "1"
}, (response) => {
if (isInAndroid()) { if (isInAndroid()) {
window.JSAndroid.writeHTMLClipboard(protyle.lute.BlockDOM2StdMd(response.data).trimEnd(), response.data + Constants.ZWSP); window.JSAndroid.writeHTMLClipboard(protyle.lute.BlockDOM2StdMd(response.data).trimEnd(), response.data + Constants.ZWSP);
} else if (isInHarmony()) { } else if (isInHarmony()) {
@ -1698,7 +1701,10 @@ export class Gutter {
icon: "iconCut", icon: "iconCut",
label: `${window.siyuan.languages.cut} ${window.siyuan.languages.headings1}`, label: `${window.siyuan.languages.cut} ${window.siyuan.languages.headings1}`,
click() { click() {
fetchPost("/api/block/getHeadingChildrenDOM", {id, removeFoldAttr: false}, (response) => { fetchPost("/api/block/getHeadingChildrenDOM", {
id,
removeFoldAttr: nodeElement.getAttribute("fold") !== "1"
}, (response) => {
if (isInAndroid()) { if (isInAndroid()) {
window.JSAndroid.writeHTMLClipboard(protyle.lute.BlockDOM2StdMd(response.data).trimEnd(), response.data + Constants.ZWSP); window.JSAndroid.writeHTMLClipboard(protyle.lute.BlockDOM2StdMd(response.data).trimEnd(), response.data + Constants.ZWSP);
} else if (isInHarmony()) { } else if (isInHarmony()) {

View file

@ -252,13 +252,13 @@ export const toggleUpdateRelationBtn = (menuItemsElement: HTMLElement, avId: str
}; };
const updateCopyRelatedItems = (menuElement: Element) => { const updateCopyRelatedItems = (menuElement: Element) => {
const inputElement = menuElement.querySelector(".b3-form__icona .b3-text-field"); const inputElement = menuElement.querySelector(".b3-form__icona .b3-text-field") as HTMLInputElement;
if (menuElement.querySelector(".b3-menu__icon.fn__grab")) { if (menuElement.querySelector(".b3-menu__icon.fn__grab")) {
inputElement.nextElementSibling.classList.remove("fn__none"); inputElement.nextElementSibling.classList.remove("fn__none");
inputElement.classList.add("b3-form__icona-input"); inputElement.style.paddingRight = "26px";
} else { } else {
inputElement.nextElementSibling.classList.add("fn__none"); inputElement.nextElementSibling.classList.add("fn__none");
inputElement.classList.remove("b3-form__icona-input"); inputElement.style.paddingRight = "";
} }
}; };
@ -326,13 +326,14 @@ draggable="true">${genSelectItemHTML({
}); });
} }
}); });
const refElement = menuElement.querySelector(".popover__block");
menuElement.querySelector(".b3-menu__items").innerHTML = `${selectHTML} menuElement.querySelector(".b3-menu__items").innerHTML = `${selectHTML}
<button class="b3-menu__separator"></button> <button class="b3-menu__separator"></button>
${html} ${html}
${keyword ? genSelectItemHTML({ ${keyword ? genSelectItemHTML({
type: "empty", type: "empty",
newName: Lute.EscapeHTMLStr(keyword), newName: Lute.EscapeHTMLStr(keyword),
text: menuElement.querySelector(".popover__block").outerHTML text: `<span style="color: var(--b3-protyle-inline-blockref-color);" data-id="${refElement.getAttribute("data-id")}">${refElement.textContent}</span>`,
}) : (html ? "" : genSelectItemHTML({type: "empty"}))}`; }) : (html ? "" : genSelectItemHTML({type: "empty"}))}`;
menuElement.querySelector(".b3-menu__items .b3-menu__item:not(.fn__none)").classList.add("b3-menu__item--current"); menuElement.querySelector(".b3-menu__items .b3-menu__item:not(.fn__none)").classList.add("b3-menu__item--current");
updateCopyRelatedItems(menuElement); updateCopyRelatedItems(menuElement);
@ -410,7 +411,7 @@ ${html || genSelectItemHTML({type: "empty"})}`;
event.stopPropagation(); event.stopPropagation();
filterItem(options.menuElement, options.cellElements[0], inputElement.value); filterItem(options.menuElement, options.cellElements[0], inputElement.value);
}); });
updateCopyRelatedItems(options.menuElement) updateCopyRelatedItems(options.menuElement);
options.menuElement.querySelector('[data-type="copyRelatedItems"]').addEventListener("click", () => { options.menuElement.querySelector('[data-type="copyRelatedItems"]').addEventListener("click", () => {
let copyText = ""; let copyText = "";
const selectedElements = options.menuElement.querySelectorAll('.b3-menu__item[draggable="true"]'); const selectedElements = options.menuElement.querySelectorAll('.b3-menu__item[draggable="true"]');
@ -444,9 +445,9 @@ export const getRelationHTML = (data: IAV, cellElements?: HTMLElement[]) => {
if (colRelationData && colRelationData.avID) { if (colRelationData && colRelationData.avID) {
return `<div data-av-id="${colRelationData.avID}" class="fn__flex-column"> return `<div data-av-id="${colRelationData.avID}" class="fn__flex-column">
<div class="b3-menu__item" data-type="nobg"> <div class="b3-menu__item" data-type="nobg">
<div class="b3-form__icona"> <div class="b3-form__icona fn__flex-1">
<input class="b3-text-field fn__flex-1 b3-form__icona-input fn__size200"/> <input class="b3-text-field fn__block" style="min-width: 190px"/>
<svg class="b3-form__icona-icon ariaLabel" data-position="north" data-type="copyRelatedItems" aria-label="${window.siyuan.languages.copy} ${window.siyuan.languages.relatedItems}"><use xlink:href="#iconCopy"></use></svg> <svg class="b3-form__icona-icon ariaLabel fn__none" data-position="north" data-type="copyRelatedItems" aria-label="${window.siyuan.languages.copy} ${window.siyuan.languages.relatedItems}"><use xlink:href="#iconCopy"></use></svg>
</div> </div>
<span class="fn__space"></span> <span class="fn__space"></span>
<span style="color: var(--b3-protyle-inline-blockref-color);max-width: 200px" data-id="" class="popover__block fn__pointer fn__ellipsis"></span> <span style="color: var(--b3-protyle-inline-blockref-color);max-width: 200px" data-id="" class="popover__block fn__pointer fn__ellipsis"></span>

View file

@ -67,7 +67,7 @@ export const getDocByScroll = (options: {
actions = [Constants.CB_GET_UNUNDO]; actions = [Constants.CB_GET_UNUNDO];
} }
} }
if (options.scrollAttr?.zoomInId) { if (options.scrollAttr?.zoomInId && options.scrollAttr?.rootId && options.scrollAttr.zoomInId !== options.scrollAttr.rootId) {
fetchPost("/api/filetree/getDoc", { fetchPost("/api/filetree/getDoc", {
id: options.scrollAttr.zoomInId, id: options.scrollAttr.zoomInId,
size: Constants.SIZE_GET_MAX, size: Constants.SIZE_GET_MAX,

View file

@ -450,26 +450,6 @@ export const insertHTML = (html: string, protyle: IProtyle, isBlock = false,
if (tempElement.content.firstChild.nodeType === 3 || (tempElement.content.firstChild.nodeType === 1 && tempElement.content.firstElementChild.tagName !== "DIV")) { if (tempElement.content.firstChild.nodeType === 3 || (tempElement.content.firstChild.nodeType === 1 && tempElement.content.firstElementChild.tagName !== "DIV")) {
tempElement.innerHTML = protyle.lute.SpinBlockDOM(tempElement.innerHTML); tempElement.innerHTML = protyle.lute.SpinBlockDOM(tempElement.innerHTML);
} }
// let foldHeadingId = "";
// let foldHTML = "";
// 粘贴内容中包含折叠的子节点需后端插入到原节点中
// Array.from(tempElement.content.children).forEach((item) => {
// if (!item.getAttribute("parent-heading") && foldHeadingId && foldHTML) {
// fetchPost("/api/block/appendHeadingChildren", {id: foldHeadingId, dom: foldHTML});
// foldHeadingId = "";
// foldHTML = "";
// }
// if (item.getAttribute("data-type") === "NodeHeading" && item.getAttribute("fold") === "1") {
// foldHeadingId = item.getAttribute("data-node-id");
// return true;
// }
// if (foldHeadingId && item.getAttribute("parent-heading")) {
// foldHTML += item.outerHTML;
// }
// });
// if (foldHeadingId && foldHTML) {
// fetchPost("/api/block/appendHeadingChildren", {id: foldHeadingId, dom: foldHTML});
// }
(insertBefore ? Array.from(tempElement.content.children) : Array.from(tempElement.content.children).reverse()).find((item) => { (insertBefore ? Array.from(tempElement.content.children) : Array.from(tempElement.content.children).reverse()).find((item) => {
let addId = item.getAttribute("data-node-id"); let addId = item.getAttribute("data-node-id");
const hasParentHeading = item.getAttribute("parent-heading"); const hasParentHeading = item.getAttribute("parent-heading");

View file

@ -860,7 +860,8 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
const nextBlockElement = hasClosestBlock(nextRange.startContainer); const nextBlockElement = hasClosestBlock(nextRange.startContainer);
if (nextBlockElement && if (nextBlockElement &&
(!nextBlockElement.classList.contains("code-block") || (!nextBlockElement.classList.contains("code-block") ||
(nextBlockElement.classList.contains("code-block") && getContenteditableElement(nextBlockElement).textContent == "\n")) (nextBlockElement.classList.contains("code-block") &&
(getContenteditableElement(nextBlockElement).textContent == "\n") || nextBlockElement.parentElement.classList.contains("li")))
) { ) {
// 反向删除合并为一个块时,光标应保持在尾部 https://github.com/siyuan-note/siyuan/issues/14290#issuecomment-2849810529 // 反向删除合并为一个块时,光标应保持在尾部 https://github.com/siyuan-note/siyuan/issues/14290#issuecomment-2849810529
cloneRange.insertNode(document.createElement("wbr")); cloneRange.insertNode(document.createElement("wbr"));