An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:art: https://github.com/siyuan-note/siyuan/issues/13664
Vanessab9eeaa1453f0
diff --git a/app/src/protyle/gutter/index.ts b/app/src/protyle/gutter/index.tsindex 3d43971c02..e74491ccd5 100644--- a/app/src/protyle/gutter/index.ts+++ b/app/src/protyle/gutter/index.ts@@ -380,7 +380,7 @@ export class Gutter {this.renderMenu(protyle, buttonElement);// https://ld246.com/article/1648433751993if (!protyle.toolbar.range) {- protyle.toolbar.range = getEditorRange(protyle.wysiwyg.element.firstElementChild);+ protyle.toolbar.range = getEditorRange(protyle.wysiwyg.element.querySelector(`[data-node-id="${id}"]`) || protyle.wysiwyg.element.firstElementChild);}/// #if MOBILEwindow.siyuan.menus.menu.fullscreen();@@ -418,7 +418,9 @@ export class Gutter {} else if (buttonElement.dataset.type !== "NodeAttributeViewRow") {this.renderMenu(protyle, buttonElement);if (!protyle.toolbar.range) {- protyle.toolbar.range = getEditorRange(protyle.wysiwyg.element.firstElementChild);+ protyle.toolbar.range = getEditorRange(+ protyle.wysiwyg.element.querySelector(`[data-node-id="${buttonElement.getAttribute("data-node-id")}"]`) ||+ protyle.wysiwyg.element.firstElementChild);}/// #if MOBILEwindow.siyuan.menus.menu.fullscreen();@@ -1382,9 +1384,11 @@ export class Gutter {id: "separator_cancelSuperBlock",type: "separator"}).element);+ const isCol = nodeElement.getAttribute("data-sb-layout") === "col";window.siyuan.menus.menu.append(new MenuItem({id: "cancelSuperBlock",label: window.siyuan.languages.cancel + " " + window.siyuan.languages.superBlock,+ accelerator: window.siyuan.config.keymap.editor.general[isCol ? "hLayout" : "vLayout"].custom,click() {const sbData = cancelSB(protyle, nodeElement);transaction(protyle, sbData.doOperations, sbData.undoOperations);@@ -1392,6 +1396,22 @@ export class Gutter {hideElements(["gutter"], protyle);}}).element);+ window.siyuan.menus.menu.append(new MenuItem({+ accelerator: window.siyuan.config.keymap.editor.general[isCol ? "vLayout" : "hLayout"].custom,+ label: window.siyuan.languages.turnInto + " " + window.siyuan.languages[isCol ? "vLayout" : "hLayout"],+ click() {+ const oldHTML = nodeElement.outerHTML;+ if (isCol) {+ nodeElement.setAttribute("data-sb-layout", "row")+ } else {+ nodeElement.setAttribute("data-sb-layout", "col")+ }+ nodeElement.setAttribute("updated", dayjs().format("YYYYMMDDHHmmss"));+ updateTransaction(protyle, id, nodeElement.outerHTML, oldHTML);+ focusByRange(protyle.toolbar.range);+ hideElements(["gutter"], protyle);+ }+ }).element);} else if (type === "NodeCodeBlock" && !protyle.disabled && !nodeElement.getAttribute("data-subtype")) {window.siyuan.menus.menu.append(new MenuItem({id: "separator_code", type: "separator"}).element);const linewrap = nodeElement.getAttribute("linewrap");diff --git a/app/src/protyle/wysiwyg/keydown.ts b/app/src/protyle/wysiwyg/keydown.tsindex dd089bc605..ce7c1924ef 100644--- a/app/src/protyle/wysiwyg/keydown.ts+++ b/app/src/protyle/wysiwyg/keydown.ts@@ -35,6 +35,7 @@ import {matchHotKey} from "../util/hotKey";import {enter, softEnter} from "./enter";import {clearTableCell, fixTable} from "../util/table";import {+ transaction,turnsIntoOneTransaction,turnsIntoTransaction,turnsOneInto,@@ -44,7 +45,7 @@ import {import {fontEvent} from "../toolbar/Font";import {addSubList, listIndent, listOutdent} from "./list";import {newFileContentBySelect, rename, replaceFileName} from "../../editor/rename";-import {insertEmptyBlock, jumpToParent} from "../../block/util";+import {cancelSB, insertEmptyBlock, jumpToParent} from "../../block/util";import {isLocalPath} from "../../util/pathName";/// #if !MOBILEimport {openBy, openFileById} from "../../editor/util";@@ -1565,6 +1566,20 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {event.preventDefault();event.stopPropagation();const selectsElement: HTMLElement[] = Array.from(protyle.wysiwyg.element.querySelectorAll(".protyle-wysiwyg--select"));+ if (selectsElement.length === 1 && selectsElement[0].getAttribute("data-type") === "NodeSuperBlock") {+ if (selectsElement[0].getAttribute("data-sb-layout") === "col") {+ const oldHTML = selectsElement[0].outerHTML;+ selectsElement[0].setAttribute("data-sb-layout", "row")+ selectsElement[0].setAttribute("updated", dayjs().format("YYYYMMDDHHmmss"));+ updateTransaction(protyle, selectsElement[0].getAttribute("data-node-id"), selectsElement[0].outerHTML, oldHTML);+ } else {+ range.insertNode(document.createElement("wbr"))+ const sbData = cancelSB(protyle, selectsElement[0]);+ transaction(protyle, sbData.doOperations, sbData.undoOperations);+ focusByWbr(protyle.wysiwyg.element, range)+ }+ return;+ }if (selectsElement.length < 2 || selectsElement[0]?.classList.contains("li")) {return;}@@ -1580,6 +1595,20 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {event.preventDefault();event.stopPropagation();const selectsElement: HTMLElement[] = Array.from(protyle.wysiwyg.element.querySelectorAll(".protyle-wysiwyg--select"));+ if (selectsElement.length === 1 && selectsElement[0].getAttribute("data-type") === "NodeSuperBlock") {+ if (selectsElement[0].getAttribute("data-sb-layout") === "row") {+ const oldHTML = selectsElement[0].outerHTML;+ selectsElement[0].setAttribute("data-sb-layout", "col")+ selectsElement[0].setAttribute("updated", dayjs().format("YYYYMMDDHHmmss"));+ updateTransaction(protyle, selectsElement[0].getAttribute("data-node-id"), selectsElement[0].outerHTML, oldHTML);+ } else {+ range.insertNode(document.createElement("wbr"))+ const sbData = cancelSB(protyle, selectsElement[0]);+ transaction(protyle, sbData.doOperations, sbData.undoOperations);+ focusByWbr(protyle.wysiwyg.element, range)+ }+ return;+ }if (selectsElement.length < 2 || selectsElement[0]?.classList.contains("li")) {return;}