An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:bug: Prevent selecting document titles with content on Android https://github.com/siyuan-note/siyuan/issues/14789
Danielf4ac89a68edb
diff --git a/app/src/assets/scss/main/_mobile.scss b/app/src/assets/scss/main/_mobile.scssindex 7c5163f605..aef29149ef 100644--- a/app/src/assets/scss/main/_mobile.scss+++ b/app/src/assets/scss/main/_mobile.scss@@ -6,6 +6,16 @@width: 80vw;}+.protyle-breadcrumb {+ -webkit-user-select: none;+ user-select: none;+}++.protyle-preview__title {+ -webkit-user-select: none;+ user-select: none;+}+.fn__flex-column[data-type="sidebar-file"],.fn__flex-column[data-type="sidebar-outline"] {.b3-list-item {@@ -90,6 +100,8 @@align-items: center;max-width: 100vw;background: var(--b3-theme-background);+ -webkit-user-select: none;+ user-select: none;&--border {border-bottom: .5px solid var(--b3-theme-background-light);@@ -138,6 +150,19 @@border: 0;background-color: transparent;color: var(--b3-theme-on-background);++ &:not(.toolbar__title--readonly) {+ -webkit-user-select: text;+ user-select: text;+ }++ &--readonly {+ -webkit-user-select: none;+ user-select: none;+ overflow: hidden;+ white-space: nowrap;+ text-overflow: ellipsis;+ }}&__text {diff --git a/app/src/assets/template/mobile/index.tpl b/app/src/assets/template/mobile/index.tplindex 6198831fff..ce3bd55618 100644--- a/app/src/assets/template/mobile/index.tpl+++ b/app/src/assets/template/mobile/index.tpl@@ -16,6 +16,7 @@<use xlink:href="#iconMenu"></use></svg><input class="toolbar__title fn__hidden" id="toolbarName">+ <span class="toolbar__title toolbar__title--readonly fn__hidden fn__none" id="toolbarNameReadonly"></span><svg id="toolbarSync" class="toolbar__icon toolbar__icon-deactivate fn__none"><use xlink:href="#iconCloudSucc"></use></svg>diff --git a/app/src/mobile/util/setEmpty.ts b/app/src/mobile/util/setEmpty.tsindex e8d2d699a2..3123ae4ffd 100644--- a/app/src/mobile/util/setEmpty.ts+++ b/app/src/mobile/util/setEmpty.ts@@ -10,6 +10,7 @@ import {setTitle} from "../../util/processTitle";export const setEmpty = (app: App) => {setTitle("", true);document.getElementById("toolbarName").classList.add("fn__hidden");+ document.getElementById("toolbarNameReadonly").classList.add("fn__hidden");document.getElementById("editor").classList.add("fn__none");const emptyElement = document.getElementById("empty");emptyElement.classList.remove("fn__none");@@ -77,6 +78,7 @@ export const setEditor = () => {const toolbarNameElement = document.getElementById("toolbarName") as HTMLInputElement;setTitle(toolbarNameElement.value);toolbarNameElement.classList.remove("fn__hidden");+ document.getElementById("toolbarNameReadonly").classList.remove("fn__hidden");document.getElementById("editor").classList.remove("fn__none");document.getElementById("empty").classList.add("fn__none");};diff --git a/app/src/protyle/header/Title.ts b/app/src/protyle/header/Title.tsindex aeda6fb9a2..d43c7b106d 100644--- a/app/src/protyle/header/Title.ts+++ b/app/src/protyle/header/Title.ts@@ -377,6 +377,7 @@ export class Title {if (nbsp2space(title) !== nbsp2space(inputElement.value)) {inputElement.value = empty ? "" : title;}+ document.getElementById("toolbarNameReadonly").textContent = inputElement.value;}/// #elseif (nbsp2space(title) !== nbsp2space(this.editElement.textContent)) {diff --git a/app/src/protyle/preview/index.ts b/app/src/protyle/preview/index.tsindex e4b1cde16e..9a690da871 100644--- a/app/src/protyle/preview/index.ts+++ b/app/src/protyle/preview/index.ts@@ -258,6 +258,10 @@ export class Preview {}, response => {const oldScrollTop = protyle.preview.previewElement.scrollTop;protyle.preview.previewElement.innerHTML = response.data.html;+ /// #if MOBILE+ protyle.preview.previewElement.querySelector(`#${CSS.escape(protyle.block.rootID)}`)+ ?.classList.add("protyle-preview__title");+ /// #endifprocessRender(protyle.preview.previewElement);highlightRender(protyle.preview.previewElement);avRender(protyle.preview.previewElement, protyle);diff --git a/app/src/protyle/util/onGet.ts b/app/src/protyle/util/onGet.tsindex 4b6f48a173..b48b18f3a7 100644--- a/app/src/protyle/util/onGet.ts+++ b/app/src/protyle/util/onGet.ts@@ -28,6 +28,9 @@ import {} from "./headingNumber";import {updateDocumentBottomEof} from "./documentRange";import {disabledWYSIWYG} from "./disabledWYSIWYG";+/// #if MOBILE+import {updateMobileTitleReadonly} from "./setEditMode";+/// #endifexport const onGet = (options: {data: IWebSocketData,@@ -418,7 +421,7 @@ export const disabledProtyle = (protyle: IProtyle) => {protyle.title.editElement.style.userSelect = "text";}/// #if MOBILE- document.getElementById("toolbarName").setAttribute("readonly", "readonly");+ updateMobileTitleReadonly(protyle);/// #endifif (protyle.background) {protyle.background.element.classList.remove("protyle-background--enable");@@ -449,7 +452,9 @@ export const enableProtyle = (protyle: IProtyle) => {if (isMobile()) {// Android 端空块输入法弹出会收起 https://ld246.com/article/1689713888289// iPhone,iPad 端 protyle.wysiwyg.element contenteditable 为 true 时,输入会在块中间插入 span 导致保存失败 https://ld246.com/article/1643473862873/comment/1643813765839#comments- document.getElementById("toolbarName").removeAttribute("readonly");+ /// #if MOBILE+ updateMobileTitleReadonly(protyle);+ /// #endif} else {protyle.wysiwyg.element.setAttribute("contenteditable", "true");protyle.wysiwyg.element.style.userSelect = "";diff --git a/app/src/protyle/util/setEditMode.ts b/app/src/protyle/util/setEditMode.tsindex edde9f9ccc..e04d055c5d 100644--- a/app/src/protyle/util/setEditMode.ts+++ b/app/src/protyle/util/setEditMode.ts@@ -3,6 +3,24 @@ import {getAllModels} from "../../layout/getAll";import {updateOutline} from "../../editor/util";import {resize} from "./resize";+/// #if MOBILE+export const updateMobileTitleReadonly = (protyle: IProtyle) => {+ const inputElement = document.getElementById("toolbarName") as HTMLInputElement;+ const readonlyElement = document.getElementById("toolbarNameReadonly");+ if (!inputElement || !readonlyElement) {+ return;+ }+ const readonly = protyle.disabled || !protyle.preview.element.classList.contains("fn__none");+ if (readonly && !inputElement.readOnly && document.activeElement === inputElement) {+ inputElement.blur();+ }+ inputElement.readOnly = readonly;+ readonlyElement.textContent = inputElement.value;+ inputElement.classList.toggle("fn__none", readonly);+ readonlyElement.classList.toggle("fn__none", !readonly);+};+/// #endif+export const setEditMode = (protyle: IProtyle, type: TEditorMode) => {if (type === "preview") {if (!protyle.preview.element.classList.contains("fn__none")) {@@ -35,6 +53,9 @@ export const setEditMode = (protyle: IProtyle, type: TEditorMode) => {/// #endifresize(protyle);}+ /// #if MOBILE+ updateMobileTitleReadonly(protyle);+ /// #endifhideElements(["gutterOnly", "toolbar", "select", "hint", "util"], protyle);protyle.app.plugins.forEach(item => {item.eventBus.emit("switch-protyle-mode", {protyle});