Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: https://github.com/siyuan-note/siyuan/issues/18103

Vanessa535205a3ead6
diff --git a/app/src/mobile/util/keyboardToolbar.ts b/app/src/mobile/util/keyboardToolbar.ts
index a5038bc87c..34fdac2688 100644
--- a/app/src/mobile/util/keyboardToolbar.ts
+++ b/app/src/mobile/util/keyboardToolbar.ts
@@ -363,7 +363,10 @@ const renderKeyboardToolbar = () => {
protyle.toolbar.range = range;
if (!dynamicElements[0].classList.contains("fn__none")) {
// 撤销权威栈在 kernel,本地按 rootID 读镜像设按钮态(零 fetch)
- const undoState = protyle.block?.rootID ? getMirror(protyle.block.rootID) : {canUndo: false, canRedo: false};
+ const undoState = protyle.block?.rootID ? getMirror(protyle.block.rootID) : {
+ canUndo: false,
+ canRedo: false
+ };
if (!undoState.canUndo) {
dynamicElements[0].querySelector('[data-type="undo"]').setAttribute("disabled", "disabled");
} else {
@@ -616,7 +619,6 @@ export const initKeyboardToolbar = () => {
<button class="keyboard__action" data-type="tag"><svg><use xlink:href="#iconTag"></use></svg></button>
<button class="keyboard__action" data-type="inline-math"><svg><use xlink:href="#iconMath"></use></svg></button>
<button class="keyboard__action" data-type="inline-memo"><svg><use xlink:href="#iconM"></use></svg></button>
- <button class="keyboard__action" data-type="goback"><svg><use xlink:href="#iconCloseRound"></use></svg></button>
</div>
</div>
<span class="keyboard__split"></span>
@@ -829,6 +831,8 @@ export const initKeyboardToolbar = () => {
}
focusByRange(range);
return;
+ } else if (type) {
+ protyle.toolbar.element.querySelector(`[data-type="${type}"]`)?.dispatchEvent(new CustomEvent("click"));
}
});
};
diff --git a/app/src/protyle/toolbar/index.ts b/app/src/protyle/toolbar/index.ts
index 0a6dd05f85..41d7942983 100644
--- a/app/src/protyle/toolbar/index.ts
+++ b/app/src/protyle/toolbar/index.ts
@@ -17,7 +17,12 @@ import {Link} from "./Link";
import {setPosition} from "../../util/setPosition";
import {transaction, updateTransaction} from "../wysiwyg/transaction";
import {Constants} from "../../constants";
-import {copyPlainText, readClipboard, saveExportFile, setStorageVal} from "../util/compatibility";
+import {
+ copyPlainText,
+ readClipboard,
+ saveExportFile,
+ setStorageVal
+} from "../util/compatibility";
import {upDownHint} from "../../util/upDownHint";
import {highlightRender} from "../render/highlightRender";
import {getContenteditableElement, hasNextSibling, hasPreviousSibling} from "../wysiwyg/getBlock";
@@ -68,6 +73,7 @@ export class Toolbar {
this.subElement.className = "protyle-util fn__none";
/// #endif
this.toolbarHeight = 29;
+ const inlineToolbarElement = document.querySelector('#keyboardToolbar .keyboard__action[data-type="inline-memo"]')?.parentElement;
protyle.app.plugins.forEach(item => {
const pluginToolbar = item.updateProtyleToolbar(options.toolbar);
pluginToolbar.forEach(toolbarItem => {
@@ -80,6 +86,17 @@ export class Toolbar {
if (window.siyuan.config.keymap.plugin && window.siyuan.config.keymap.plugin[item.name] && window.siyuan.config.keymap.plugin[item.name][toolbarItem.name]) {
toolbarItem.hotkey = window.siyuan.config.keymap.plugin[item.name][toolbarItem.name].custom;
}
+ /// #if MOBILE
+ if (inlineToolbarElement) {
+ const itemElement = new ToolbarItem(protyle, toolbarItem).element;
+ itemElement.className = "keyboard__action";
+ const oldItemElement = inlineToolbarElement.querySelector(`[data-type="${toolbarItem.name}"]`);
+ if (!oldItemElement) {
+ inlineToolbarElement.insertAdjacentHTML("beforeend",
+ `<button class="keyboard__action" data-type="${toolbarItem.name}"><svg><use xlink:href="#${toolbarItem.icon}"></use></svg></button>`);
+ }
+ }
+ /// #endif
});
options.toolbar = toolbarKeyToMenu(pluginToolbar);
});