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/7564

Vanessa885b1ffad3c6
diff --git a/app/src/assets/scss/component/_menu.scss b/app/src/assets/scss/component/_menu.scss
index caebe87823..10bb24fd6b 100644
--- a/app/src/assets/scss/component/_menu.scss
+++ b/app/src/assets/scss/component/_menu.scss
@@ -8,6 +8,7 @@
z-index: 210;
max-height: 80vh;
overflow: auto;
+ box-sizing: border-box;
&::-webkit-scrollbar {
display: none;
diff --git a/app/src/assets/scss/mobile.scss b/app/src/assets/scss/mobile.scss
index 66b3b27aa4..63a5352ba2 100644
--- a/app/src/assets/scss/mobile.scss
+++ b/app/src/assets/scss/mobile.scss
@@ -332,8 +332,12 @@
}
}
-.b3-menu__accelerator {
- display: none;
+.b3-menu {
+ width: 100%;
+
+ &__accelerator {
+ display: none;
+ }
}
#historyContainer {
diff --git a/app/src/constants.ts b/app/src/constants.ts
index c44803a0d1..6432d2d177 100644
--- a/app/src/constants.ts
+++ b/app/src/constants.ts
@@ -1,3 +1,5 @@
+import {isMobile} from "./util/functions";
+
declare const SIYUAN_VERSION: string;
declare const NODE_ENV: string;
@@ -36,7 +38,7 @@ export abstract class Constants {
public static readonly SIYUAN_EXPORT_PREVENT: string = "siyuan-export-prevent";
// size
- public static readonly SIZE_TOOLBAR_HEIGHT: number = 32;
+ public static readonly SIZE_TOOLBAR_HEIGHT: number = isMobile() ? 0 : 32;
public static readonly SIZE_GET_MAX = 102400;
public static readonly SIZE_UNDO = 64;
public static readonly SIZE_TITLE = 512;
diff --git a/app/src/mobile/util/keyboardToolbar.ts b/app/src/mobile/util/keyboardToolbar.ts
index dba0aecb2a..91b4cae661 100644
--- a/app/src/mobile/util/keyboardToolbar.ts
+++ b/app/src/mobile/util/keyboardToolbar.ts
@@ -3,7 +3,8 @@ import {hasClosestBlock, hasClosestByClassName, hasClosestByMatchTag} from "../.
import {moveToDown, moveToUp} from "../../protyle/wysiwyg/move";
import {Constants} from "../../constants";
import {focusByRange, getSelectionPosition} from "../../protyle/util/selection";
-import {getEventName} from "../../protyle/util/compatibility";
+import {removeBlock} from "../../protyle/wysiwyg/remove";
+import {hintSlash} from "../../protyle/hint/extend";
export const showKeyboardToolbar = (bottom = 0) => {
if (getSelection().rangeCount === 0 || window.siyuan.config.editor.readOnly || window.siyuan.config.readonly) {
@@ -105,12 +106,12 @@ export const initKeyboardToolbar = () => {
<span class="keyboard__split"></span>
<button data-type="add"><svg><use xlink:href="#iconAdd"></use></svg></button>
<button data-type="goinline"><svg class="keyboard__svg--big"><use xlink:href="#iconBIU"></use></svg></button>
- <button data-type="indent"><svg><use xlink:href="#iconTrashcan"></use></svg></button>
+ <button data-type="remove"><svg><use xlink:href="#iconTrashcan"></use></svg></button>
<span class="keyboard__split"></span>
<button data-type="undo"><svg><use xlink:href="#iconUndo"></use></svg></button>
<button data-type="redo"><svg><use xlink:href="#iconRedo"></use></svg></button>
- <button data-type="appearance"><svg><use xlink:href="#iconFont"></use></svg></button>
- <button data-type="block"><svg><use xlink:href="#iconMore"></use></svg></button>
+ <button data-type="block"><svg><use xlink:href="#iconParagraph"></use></svg></button>
+ <button data-type="more"><svg><use xlink:href="#iconMore"></use></svg></button>
<span class="keyboard__split"></span>
<button data-type="moveup"><svg><use xlink:href="#iconUp"></use></svg></button>
<button data-type="movedown"><svg><use xlink:href="#iconDown"></use></svg></button>
@@ -182,7 +183,7 @@ export const initKeyboardToolbar = () => {
}
// inline element
if (["a", "block-ref", "inline-math", "inline-memo", "text"].includes(type)) {
- protyle.toolbar.element.querySelector(`[data-type="${type}"]`).dispatchEvent(new CustomEvent("text" === type ? getEventName() : "click"));
+ protyle.toolbar.element.querySelector(`[data-type="${type}"]`).dispatchEvent(new CustomEvent("click"));
return;
} else if (["strong", "em", "s", "code", "mark", "tag", "u", "sup", "clear", "sub", "kbd"].includes(type)) {
protyle.toolbar.setInlineMark(protyle, type, "toolbar");
@@ -196,16 +197,26 @@ export const initKeyboardToolbar = () => {
focusByRange(range);
return;
} else if (type === "remove") {
- // TODO
+ nodeElement.classList.add("protyle-wysiwyg--select");
+ removeBlock(protyle, nodeElement, range);
return;
} else if (type === "add") {
- // TODO
+ protyle.hint.splitChar = "/";
+ protyle.hint.lastIndex = -1;
+ protyle.hint.genHTML(hintSlash("", protyle), protyle);
+ focusByRange(range);
return;
- } else if (type === "appearance") {
- // TODO
+ } else if (type === "more") {
+ protyle.breadcrumb.showMenu(protyle, {
+ x: 0,
+ y: 0
+ });
+ focusByRange(range);
return;
} else if (type === "block") {
- // TODO
+ protyle.gutter.renderMenu(protyle, nodeElement);
+ window.siyuan.menus.menu.popup({x: 0, y:0}, true);
+ focusByRange(range);
return;
} else if (type === "outdent") {
listOutdent(protyle, [nodeElement.parentElement], range);
diff --git a/app/src/protyle/breadcrumb/index.ts b/app/src/protyle/breadcrumb/index.ts
index 544f89f871..ffdd391ed6 100644
--- a/app/src/protyle/breadcrumb/index.ts
+++ b/app/src/protyle/breadcrumb/index.ts
@@ -147,7 +147,7 @@ export class Breadcrumb {
this.mediaRecorder.startRecordingNewWavFile();
}
- private showMenu(protyle: IProtyle, position: { x: number, y: number }) {
+ public showMenu(protyle: IProtyle, position: { x: number, y: number }) {
let id;
const cursorNodeElement = hasClosestBlock(getEditorRange(protyle.element).startContainer);
if (cursorNodeElement) {
diff --git a/app/src/protyle/hint/index.ts b/app/src/protyle/hint/index.ts
index 3303c65912..4097e9fc7d 100644
--- a/app/src/protyle/hint/index.ts
+++ b/app/src/protyle/hint/index.ts
@@ -581,7 +581,7 @@ ${unicode2Emoji(emoji.unicode, true)}</button>`;
range.deleteContents();
focusByRange(range);
if (["a", "block-ref", "inline-math", "inline-memo", "text"].includes(value)) {
- protyle.toolbar.element.querySelector(`[data-type="${value}"]`).dispatchEvent(new CustomEvent("block-ref" === value ? getEventName() : "click"));
+ protyle.toolbar.element.querySelector(`[data-type="${value}"]`).dispatchEvent(new CustomEvent("click"));
return;
}
protyle.toolbar.setInlineMark(protyle, value, "range");
diff --git a/app/src/protyle/toolbar/Font.ts b/app/src/protyle/toolbar/Font.ts
index 2e040f4987..94b38530f2 100644
--- a/app/src/protyle/toolbar/Font.ts
+++ b/app/src/protyle/toolbar/Font.ts
@@ -1,4 +1,4 @@
-import {getEventName, setStorageVal, updateHotkeyTip} from "../util/compatibility";
+import {setStorageVal, updateHotkeyTip} from "../util/compatibility";
import {ToolbarItem} from "./ToolbarItem";
import {setPosition} from "../../util/setPosition";
import {focusByRange, getSelectionPosition} from "../util/selection";
@@ -10,7 +10,7 @@ export class Font extends ToolbarItem {
constructor(protyle: IProtyle, menuItem: IMenuItem) {
super(protyle, menuItem);
- this.element.addEventListener(getEventName(), () => {
+ this.element.addEventListener("click", () => {
if (protyle.toolbar.range.toString() === "") {
return;
}
@@ -115,13 +115,13 @@ const fontMenu = (protyle: IProtyle) => {
</div>
<div class="fn__hr"></div>
<button class="b3-button b3-button--cancel" data-type="clear"><svg><use xlink:href="#iconTrashcan"></use></svg>${window.siyuan.languages.clearFontStyle}</button>`;
- element.addEventListener(getEventName(), function (event: Event) {
+ element.addEventListener("click", function (event: Event) {
let target = event.target as HTMLElement;
while (target && !target.isEqualNode(element)) {
const dataType = target.getAttribute("data-type");
if (target.tagName === "BUTTON") {
if (dataType === "clear") {
- protyle.toolbar.setInlineMark(protyle, "clear", "range", {type:"text"});
+ protyle.toolbar.setInlineMark(protyle, "clear", "range", {type: "text"});
} else {
fontEvent(protyle, dataType, target.style.backgroundColor || target.style.color || target.textContent);
}
diff --git a/app/src/protyle/wysiwyg/keydown.ts b/app/src/protyle/wysiwyg/keydown.ts
index 77c251895a..a7ddc0e3fa 100644
--- a/app/src/protyle/wysiwyg/keydown.ts
+++ b/app/src/protyle/wysiwyg/keydown.ts
@@ -1295,7 +1295,7 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
if (matchHotKey(menuItem.hotkey, event)) {
protyle.toolbar.range = getEditorRange(protyle.wysiwyg.element);
if (["a", "block-ref", "inline-math", "inline-memo", "text"].includes(menuItem.name)) {
- protyle.toolbar.element.querySelector(`[data-type="${menuItem.name}"]`).dispatchEvent(new CustomEvent("block-ref" === menuItem.name ? getEventName() : "click"));
+ protyle.toolbar.element.querySelector(`[data-type="${menuItem.name}"]`).dispatchEvent(new CustomEvent("click"));
return true;
}
protyle.toolbar.setInlineMark(protyle, menuItem.name, "range");