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.rootId = layout.editor.protyle.block.rootID;
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";
} else if (layout instanceof Asset) {
json.path = layout.path;
@ -744,13 +744,20 @@ export const newModelByInitData = (app: App, tab: Tab, json: any) => {
});
}
} 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({
app,
tab,
rootId: json.rootId,
blockId: json.blockId,
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;

View file

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

View file

@ -252,13 +252,13 @@ export const toggleUpdateRelationBtn = (menuItemsElement: HTMLElement, avId: str
};
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")) {
inputElement.nextElementSibling.classList.remove("fn__none");
inputElement.classList.add("b3-form__icona-input");
inputElement.style.paddingRight = "26px";
} else {
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}
<button class="b3-menu__separator"></button>
${html}
${keyword ? genSelectItemHTML({
type: "empty",
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"}))}`;
menuElement.querySelector(".b3-menu__items .b3-menu__item:not(.fn__none)").classList.add("b3-menu__item--current");
updateCopyRelatedItems(menuElement);
@ -410,7 +411,7 @@ ${html || genSelectItemHTML({type: "empty"})}`;
event.stopPropagation();
filterItem(options.menuElement, options.cellElements[0], inputElement.value);
});
updateCopyRelatedItems(options.menuElement)
updateCopyRelatedItems(options.menuElement);
options.menuElement.querySelector('[data-type="copyRelatedItems"]').addEventListener("click", () => {
let copyText = "";
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) {
return `<div data-av-id="${colRelationData.avID}" class="fn__flex-column">
<div class="b3-menu__item" data-type="nobg">
<div class="b3-form__icona">
<input class="b3-text-field fn__flex-1 b3-form__icona-input fn__size200"/>
<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>
<div class="b3-form__icona fn__flex-1">
<input class="b3-text-field fn__block" style="min-width: 190px"/>
<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>
<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>

View file

@ -67,7 +67,7 @@ export const getDocByScroll = (options: {
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", {
id: options.scrollAttr.zoomInId,
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")) {
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) => {
let addId = item.getAttribute("data-node-id");
const hasParentHeading = item.getAttribute("parent-heading");

View file

@ -860,7 +860,8 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
const nextBlockElement = hasClosestBlock(nextRange.startContainer);
if (nextBlockElement &&
(!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
cloneRange.insertNode(document.createElement("wbr"));