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: Avoid opening the keyboard during tablet navigation https://github.com/siyuan-note/siyuan/issues/13840
Vanessaf47b7e0ef4b0
diff --git a/app/src/editor/util.ts b/app/src/editor/util.tsindex f315eb6f64..ddf126203d 100644--- a/app/src/editor/util.ts+++ b/app/src/editor/util.ts@@ -1,3 +1,4 @@+import {isPhablet} from "../protyle/util/compatibility";import {Tab} from "../layout/Tab";import {Editor} from "./index";import {Wnd} from "../layout/Wnd";@@ -396,7 +397,7 @@ const getUnInitTab = (options: IOpenFileOptions) => {initObj.notebookId = options.notebookId;initObj.mode = options.mode;if (options.zoomIn) {- initObj.action = [Constants.CB_GET_ALL, Constants.CB_GET_FOCUS];+ initObj.action = [Constants.CB_GET_ALL, isPhablet() ? Constants.CB_GET_HL : Constants.CB_GET_FOCUS];} else {initObj.action = options.action;}@@ -626,7 +627,7 @@ const newTab = (options: IOpenFileOptions) => {blockId: options.id,rootId: options.rootID,notebookId: options.notebookId,- action: [Constants.CB_GET_ALL, Constants.CB_GET_FOCUS],+ action: [Constants.CB_GET_ALL, isPhablet() ? Constants.CB_GET_HL : Constants.CB_GET_FOCUS],scrollPosition: options.scrollPosition,});} else {diff --git a/app/src/layout/Wnd.ts b/app/src/layout/Wnd.tsindex 809e5fd928..47c0f26afb 100644--- a/app/src/layout/Wnd.ts+++ b/app/src/layout/Wnd.ts@@ -48,7 +48,7 @@ import {newCenterEmptyTab, resizeTabs, setTabPosition} from "./tabUtil";import {setPosition} from "../util/setPosition";import {clearOBG} from "./dock/util";import {recordBeforeResizeTop} from "../protyle/util/resize";-import {sanitizeClosedTabs, setStorageVal} from "../protyle/util/compatibility";+import {isPhablet, sanitizeClosedTabs, setStorageVal} from "../protyle/util/compatibility";import {setTitle} from "../util/processTitle";import {dragOverScroll} from "../boot/globalEvent/dragover";import {@@ -420,7 +420,7 @@ export class Wnd {openFileById({app,id: item,- action: [Constants.CB_GET_FOCUS, Constants.CB_GET_SCROLL],+ action: isPhablet() ? [Constants.CB_GET_SCROLL] : [Constants.CB_GET_FOCUS, Constants.CB_GET_SCROLL],forceCurrentWindow: true,});}@@ -735,7 +735,7 @@ export class Wnd {openFileById({app: this.app,id: keepCursorId,- action: [Constants.CB_GET_FOCUS, Constants.CB_GET_SCROLL]+ action: isPhablet() ? [Constants.CB_GET_SCROLL] : [Constants.CB_GET_FOCUS, Constants.CB_GET_SCROLL]});}currentTab.headElement.removeAttribute("keep-cursor");@@ -744,7 +744,7 @@ export class Wnd {if (update) {updatePanelByEditor({protyle: currentTab.model.editor.protyle,- focus: true,+ focus: !isPhablet(),pushBackStack: pushBack,reload: false,resize,diff --git a/app/src/layout/dock/BacklinkContent.ts b/app/src/layout/dock/BacklinkContent.tsindex fa9a9f03ef..c4bca590dd 100644--- a/app/src/layout/dock/BacklinkContent.ts+++ b/app/src/layout/dock/BacklinkContent.ts@@ -11,7 +11,7 @@ import {registerMobileSecondaryEditor} from "../../mobile/util/secondaryEditors"/// #endifimport {fetchPost} from "../../util/fetch";import {Constants} from "../../constants";-import {updateHotkeyAfterTip} from "../../protyle/util/compatibility";+import {isPhablet, updateHotkeyAfterTip} from "../../protyle/util/compatibility";import {Protyle} from "../../protyle";import {MenuItem} from "../../menus/Menu";import type {App} from "../../index";@@ -338,7 +338,7 @@ export class BacklinkContent extends Model {app: options.app,id: element.getAttribute("data-node-id"),position: "right",- action: [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT]+ action: [isPhablet() ? Constants.CB_GET_HL : Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT]});this.mTree.element.querySelector(".b3-list-item--focus")?.classList.remove("b3-list-item--focus");},@@ -347,7 +347,7 @@ export class BacklinkContent extends Model {app: options.app,id: element.getAttribute("data-node-id"),position: "bottom",- action: [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT]+ action: [isPhablet() ? Constants.CB_GET_HL : Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT]});this.mTree.element.querySelector(".b3-list-item--focus")?.classList.remove("b3-list-item--focus");},@@ -379,7 +379,7 @@ export class BacklinkContent extends Model {app: options.app,id: element.getAttribute("data-node-id"),position: "right",- action: [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT]+ action: [isPhablet() ? Constants.CB_GET_HL : Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT]});this.tree.element.querySelector(".b3-list-item--focus")?.classList.remove("b3-list-item--focus");},@@ -388,7 +388,7 @@ export class BacklinkContent extends Model {app: options.app,id: element.getAttribute("data-node-id"),position: "bottom",- action: [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT]+ action: [isPhablet() ? Constants.CB_GET_HL : Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT]});this.tree.element.querySelector(".b3-list-item--focus")?.classList.remove("b3-list-item--focus");},diff --git a/app/src/layout/dock/Files.ts b/app/src/layout/dock/Files.tsindex fac415241f..c4f2e5daf0 100644--- a/app/src/layout/dock/Files.ts+++ b/app/src/layout/dock/Files.ts@@ -24,7 +24,7 @@ import {updateFileTreeItemIcon,} from "../../emoji/fileTreeIcon";import {importNotebook, newEncryptedNotebook, newNotebook, openEncryptedNotebook} from "../../util/mount";-import {isNotCtrl, isOnlyMeta, setStorageVal, updateHotkeyAfterTip} from "../../protyle/util/compatibility";+import {isNotCtrl, isOnlyMeta, isPhablet, setStorageVal, updateHotkeyAfterTip} from "../../protyle/util/compatibility";import {openFileById} from "../../editor/util";import {hasClosestByClassName,@@ -232,7 +232,7 @@ export class Files extends Model {app: options.app,removeCurrentTab: false,id: target.getAttribute("data-node-id"),- action: [Constants.CB_GET_FOCUS, Constants.CB_GET_SCROLL],+ action: isPhablet() ? [Constants.CB_GET_SCROLL] : [Constants.CB_GET_FOCUS, Constants.CB_GET_SCROLL],afterOpen() {target.removeAttribute("data-opening");}@@ -271,7 +271,7 @@ export class Files extends Model {openFileById({app: options.app,id: liElement.getAttribute("data-node-id"),- action: [Constants.CB_GET_FOCUS, Constants.CB_GET_SCROLL],+ action: isPhablet() ? [Constants.CB_GET_SCROLL] : [Constants.CB_GET_FOCUS, Constants.CB_GET_SCROLL],afterOpen() {liElement.removeAttribute("data-opening");}@@ -414,7 +414,7 @@ export class Files extends Model {app: options.app,id: target.getAttribute("data-node-id"),position: "right",- action: [Constants.CB_GET_FOCUS, Constants.CB_GET_SCROLL],+ action: isPhablet() ? [Constants.CB_GET_SCROLL] : [Constants.CB_GET_FOCUS, Constants.CB_GET_SCROLL],afterOpen() {target.removeAttribute("data-opening");}@@ -424,7 +424,7 @@ export class Files extends Model {app: options.app,id: target.getAttribute("data-node-id"),position: "bottom",- action: [Constants.CB_GET_FOCUS, Constants.CB_GET_SCROLL],+ action: isPhablet() ? [Constants.CB_GET_SCROLL] : [Constants.CB_GET_FOCUS, Constants.CB_GET_SCROLL],afterOpen() {target.removeAttribute("data-opening");}@@ -435,7 +435,7 @@ export class Files extends Model {app: options.app,removeCurrentTab: false,id: target.getAttribute("data-node-id"),- action: [Constants.CB_GET_FOCUS, Constants.CB_GET_SCROLL],+ action: isPhablet() ? [Constants.CB_GET_SCROLL] : [Constants.CB_GET_FOCUS, Constants.CB_GET_SCROLL],afterOpen() {target.removeAttribute("data-opening");}@@ -444,7 +444,7 @@ export class Files extends Model {openFileById({app: options.app,id: target.getAttribute("data-node-id"),- action: [Constants.CB_GET_FOCUS, Constants.CB_GET_SCROLL],+ action: isPhablet() ? [Constants.CB_GET_SCROLL] : [Constants.CB_GET_FOCUS, Constants.CB_GET_SCROLL],afterOpen() {target.removeAttribute("data-opening");}diff --git a/app/src/layout/dock/Outline.ts b/app/src/layout/dock/Outline.tsindex 606a158d19..7918a050d3 100644--- a/app/src/layout/dock/Outline.ts+++ b/app/src/layout/dock/Outline.ts@@ -8,6 +8,7 @@ import {confirmBlockRef} from "../../util/checkBlockRef";import {getAllModels} from "../getAll";import {hasClosestBlock, hasClosestByClassName, hasTopClosestByClassName} from "../../protyle/util/hasClosest";import {+ isPhablet,setStorageVal,updateHotkeyAfterTip,writeBlockDOMClipboard@@ -152,11 +153,12 @@ export class Outline extends Model {}} else {checkFold(id, (zoomIn) => {+ const action = isPhablet() ? Constants.CB_GET_HL : Constants.CB_GET_FOCUS;openFileById({app: options.app,id,scrollPosition: "start",- action: zoomIn ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL, Constants.CB_GET_HTML, Constants.CB_GET_OUTLINE] : [Constants.CB_GET_FOCUS, Constants.CB_GET_OUTLINE, Constants.CB_GET_SETID, Constants.CB_GET_CONTEXT, Constants.CB_GET_HTML],+ action: zoomIn ? [action, Constants.CB_GET_ALL, Constants.CB_GET_HTML, Constants.CB_GET_OUTLINE] : [action, Constants.CB_GET_OUTLINE, Constants.CB_GET_SETID, Constants.CB_GET_CONTEXT, Constants.CB_GET_HTML],});});}@@ -171,7 +173,7 @@ export class Outline extends Model {openFileById({app: options.app,id,- action: [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL, Constants.CB_GET_HTML],+ action: [isPhablet() ? Constants.CB_GET_HL : Constants.CB_GET_FOCUS, Constants.CB_GET_ALL, Constants.CB_GET_HTML],zoomIn: true,});},@@ -1041,11 +1043,12 @@ export class Outline extends Model {// 带子标题转换checkFold(id, (zoomIn) => {+ const action = isPhablet() ? Constants.CB_GET_HL : Constants.CB_GET_FOCUS;openFileById({app: this.app,id,scrollPosition: "start",- action: zoomIn ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL, Constants.CB_GET_HTML, Constants.CB_GET_OUTLINE] : [Constants.CB_GET_FOCUS, Constants.CB_GET_OUTLINE, Constants.CB_GET_SETID, Constants.CB_GET_CONTEXT, Constants.CB_GET_HTML],+ action: zoomIn ? [action, Constants.CB_GET_ALL, Constants.CB_GET_HTML, Constants.CB_GET_OUTLINE] : [action, Constants.CB_GET_OUTLINE, Constants.CB_GET_SETID, Constants.CB_GET_CONTEXT, Constants.CB_GET_HTML],});});this.setCurrentById(id, false);diff --git a/app/src/layout/util.ts b/app/src/layout/util.tsindex c3aad611d9..92ab75db01 100644--- a/app/src/layout/util.ts+++ b/app/src/layout/util.ts@@ -31,6 +31,7 @@ import {afterLayoutReady} from "../plugin/loader";import {newCenterEmptyTab, resizeTabs, setTabPosition} from "./tabUtil";import {isDisabledFeature,+ isPhablet,isSensitiveLayoutData,isSensitiveSearchConfig,setStorageVal,@@ -909,6 +910,11 @@ export const newModelByInitData = (app: App, tab: Tab, json: any) => {json.action = json.action.filter((item: string) => item !== Constants.CB_GET_ALL);}}+ const action = Array.isArray(json.action) ? [...json.action] : (json.action ? [json.action] : []);+ // 手机和平板恢复页签时只恢复浏览位置,避免自动聚焦弹出输入法。+ if (!isPhablet()) {+ action.push(Constants.CB_GET_FOCUS);+ }const editorModel = new Editor({app,tab,@@ -917,8 +923,7 @@ export const newModelByInitData = (app: App, tab: Tab, json: any) => {notebookId: json.notebookId,mode: json.mode,scrollPosition: json.scrollPosition,- action: Array.isArray(json.action) ? json.action.concat(Constants.CB_GET_FOCUS) :- (json.action ? [json.action, Constants.CB_GET_FOCUS] : [Constants.CB_GET_FOCUS]),+ action,afterInitProtyle(editor) {if (json.databaseRowId) {editor.protyle.databaseAttributePanel?.expand();diff --git a/app/src/menus/navigation.ts b/app/src/menus/navigation.tsindex b8027a9c89..09815c2b90 100644--- a/app/src/menus/navigation.ts+++ b/app/src/menus/navigation.ts@@ -32,7 +32,7 @@ import {openEditorTab} from "./util";import {makeCard} from "../card/makeCard";import {transaction} from "../protyle/wysiwyg/transaction";import {emitOpenMenu} from "../plugin/EventBus";-import {saveExportFile} from "../protyle/util/compatibility";+import {isPhablet, saveExportFile} from "../protyle/util/compatibility";import {exportMarkdownZip} from "../protyle/export/exportMd";import {addFilesToDatabase} from "../protyle/render/av/addToDatabase";import {getDocTreeMenuItems, getDocTreeMenuType} from "./navigationSelection";@@ -419,7 +419,7 @@ export const initNavigationMenu = (app: App, liElement: HTMLElement) => {openFileById({app,id: boxDocID,- action: [Constants.CB_GET_FOCUS, Constants.CB_GET_SCROLL],+ action: isPhablet() ? [Constants.CB_GET_SCROLL] : [Constants.CB_GET_FOCUS, Constants.CB_GET_SCROLL],});}}).element);@@ -710,7 +710,7 @@ export const initFileMenu = (app: App, notebookId: string, pathString: string, lopenFileById({app,id,- action: [Constants.CB_GET_FOCUS, Constants.CB_GET_SCROLL],+ action: isPhablet() ? [Constants.CB_GET_SCROLL] : [Constants.CB_GET_FOCUS, Constants.CB_GET_SCROLL],});}}).element);diff --git a/app/src/menus/navigationFocus.test.ts b/app/src/menus/navigationFocus.test.tsnew file mode 100644index 0000000000..c1454bfd44--- /dev/null+++ b/app/src/menus/navigationFocus.test.ts@@ -0,0 +1,112 @@+import * as assert from "node:assert/strict";+import {readFileSync} from "node:fs";+import {test} from "node:test";+import {runInNewContext} from "node:vm";+import {createSourceFile, isVariableStatement, ModuleKind, ScriptTarget, transpileModule} from "typescript";+import {getZoomFocusScrollAttr, shouldFocusAfterZoom} from "../protyle/util/focusRestore";++const source = createSourceFile("protyle.ts", readFileSync("src/menus/protyle.ts", "utf8"), ScriptTarget.ES2021, true);+const declaration = source.statements.find(statement => isVariableStatement(statement) &&+ statement.declarationList.declarations.some(item => item.name.getText(source) === "zoomOut"));+const compiled = transpileModule(declaration.getText(source), {+ compilerOptions: {module: ModuleKind.CommonJS, target: ScriptTarget.ES2021},+}).outputText;++const fixture = (tablet: boolean, alreadyZoomed = false, missingTarget = false) => {+ const loads: any[] = [];+ const pending: Promise<void>[] = [];+ let focused = 0;+ let scrolled = 0;+ const target = {+ getBoundingClientRect: () => ({height: 20}),+ classList: {contains: () => false},+ scrollIntoView: () => scrolled++,+ };+ const exports: any = {};+ runInNewContext(compiled, {+ exports,+ isPhablet: () => tablet,+ hasClosestByClassName: (): undefined => undefined,+ isEncryptedBox: () => false,+ Constants: {+ CB_GET_HTML: "html", CB_GET_ALL: "all", CB_GET_FOCUS: "focus", CB_GET_UNUNDO: "unundo",+ },+ window: {siyuan: {config: {editor: {dynamicLoadBlocks: 64, backlinkShowBottom: true}}}},+ fetchPost: (_url: string, _data: any, callback: (data: any) => Promise<void>) => {+ pending.push(Promise.resolve(callback({data: {}})));+ },+ fetchSyncPost: async () => ({data: {parentID: "target"}}),+ onGet: (options: any) => loads.push(options),+ focusBlock: () => focused++,+ focusByOffset: () => focused++,+ scrollCenter: () => scrolled++,+ getFirstBlock: (element: any) => element,+ getZoomFocusScrollAttr,+ shouldFocusAfterZoom,+ });+ const protyle = {+ options: {},+ block: {rootID: "root"},+ breadcrumb: alreadyZoomed ? {element: {+ parentElement: {querySelector: (): undefined => undefined},+ querySelector: () => ({getAttribute: () => "target"}),+ }} : undefined,+ wysiwyg: {element: {querySelector: () => missingTarget ? undefined : target}},+ };+ return {+ loads,+ focused: () => focused,+ scrolled: () => scrolled,+ settle: () => Promise.all(pending),+ zoom: (options: any = {}) => exports.zoomOut({protyle, id: "target", ...options}),+ };+};++test("tablet block navigation suppresses focus during document loading", () => {+ const f = fixture(true);+ f.zoom();+ assert.equal(f.loads.length, 1);+ assert.equal(f.loads[0].suppressFocus, true);+ assert.equal(f.loads[0].action.includes("focus"), true);+ assert.equal(f.focused(), 0);+});++test("clicking the current breadcrumb scrolls without focusing on tablets", () => {+ const f = fixture(true, true);+ f.zoom();+ assert.equal(f.loads.length, 0);+ assert.equal(f.scrolled(), 1);+ assert.equal(f.focused(), 0);+});++test("tablet exit-focus navigation scrolls to its saved target without restoring a selection", () => {+ const f = fixture(true);+ f.zoom({id: "root", focusId: "target", focusPosition: {start: 2, end: 5}, suppressFocus: true});+ assert.equal(f.loads[0].suppressFocus, true);+ assert.equal(f.scrolled(), 1);+ assert.equal(f.focused(), 0);+});++test("a dynamically loaded exit-focus target retains focus suppression", async () => {+ const f = fixture(true, false, true);+ f.zoom({id: "root", focusId: "target", suppressFocus: true});+ await f.settle();+ assert.equal(f.loads.length, 2);+ assert.ok(f.loads.every(load => load.suppressFocus));+ assert.equal(f.loads[1].scrollAttr.focusId, "target");+ assert.equal(f.focused(), 0);+});++test("tablet editing recovery still restores explicit cursor offsets", () => {+ const f = fixture(true);+ f.zoom({id: "root", focusId: "target", focusPosition: {start: 2, end: 5}, isPushBack: false});+ assert.equal(f.loads[0].suppressFocus, false);+ assert.equal(f.focused(), 1);+});++test("desktop breadcrumb navigation retains focus", () => {+ const f = fixture(false, true);+ f.zoom();+ assert.equal(f.focused(), 1);+ assert.equal(f.scrolled(), 1);+});diff --git a/app/src/menus/protyle.ts b/app/src/menus/protyle.tsindex 764a46e804..7171ab45ff 100644--- a/app/src/menus/protyle.ts+++ b/app/src/menus/protyle.ts@@ -33,7 +33,7 @@ import {transaction, updateTransaction} from "../protyle/wysiwyg/transaction";import {openMenu} from "./commonMenuItem";import {fetchPost, fetchSyncPost} from "../util/fetch";import {Constants} from "../constants";-import {copyPlainText, readClipboard, setStorageVal, updateHotkeyTip, writeText} from "../protyle/util/compatibility";+import {copyPlainText, isPhablet, readClipboard, setStorageVal, updateHotkeyTip, writeText} from "../protyle/util/compatibility";import {onGet} from "../protyle/util/onGet";import {getAllModels} from "../layout/getAll";import {paste, pasteAndKeepSourceFormat, pasteAsPlainText, pasteEscaped} from "../protyle/util/paste";@@ -78,6 +78,7 @@ import {} from "../protyle/util/tableColumnWidth";import {getParentDocumentID} from "../protyle/util/parentDocument";import {getZoomFocusScrollAttr, shouldFocusAfterZoom} from "../protyle/util/focusRestore";+import {scrollCenter} from "../util/highlightById";import {getSemanticInlineVisibleText,normalizeSemanticInlineElement@@ -969,17 +970,17 @@ export const enterBack = (protyle: IProtyle, id: string, focusPosition?: { start});if (parentDocumentID) {/// #if MOBILE- openMobileFileById(protyle.app, parentDocumentID, [Constants.CB_GET_FOCUS, Constants.CB_GET_SCROLL]);+ openMobileFileById(protyle.app, parentDocumentID, [Constants.CB_GET_SCROLL]);/// #elseopenFileById({app: protyle.app,id: parentDocumentID,- action: [Constants.CB_GET_FOCUS, Constants.CB_GET_SCROLL]+ action: isPhablet() ? [Constants.CB_GET_SCROLL] : [Constants.CB_GET_FOCUS, Constants.CB_GET_SCROLL]});/// #endif}} else {- zoomOut({protyle, id: protyle.block.parent2ID, focusId: id, focusPosition});+ zoomOut({protyle, id: protyle.block.parent2ID, focusId: id, focusPosition, suppressFocus: isPhablet()});}};@@ -991,11 +992,14 @@ export const zoomOut = (options: {isPushBack?: boolean,callback?: () => void,reload?: boolean,+ suppressFocus?: boolean,dataDocType?: string}) => {if (options.protyle.lite || options.protyle.options.backlinkData) {return;}+ // 浏览跳转不唤起输入法;带定位目标的编辑恢复和主动重载仍可恢复光标。+ const suppressFocus = options.suppressFocus ?? (isPhablet() && !options.focusId && !options.reload);if (options.id !== options.protyle.block.rootID) {options.protyle.breadcrumb?.element.parentElement.querySelector('[data-type="context"]')?.classList.remove("block__icon--active");@@ -1022,7 +1026,9 @@ export const zoomOut = (options: {}const focusElement = options.protyle.wysiwyg.element.querySelector(`[data-node-id="${options.focusId || options.id}"]`);if (focusElement) {- focusBlock(focusElement, undefined, true, true);+ if (!suppressFocus) {+ focusBlock(focusElement, undefined, true, true);+ }focusElement.scrollIntoView();return;}@@ -1069,6 +1075,7 @@ export const zoomOut = (options: {afterCB: options.callback,dataDocType: options.dataDocType,focusAfterZoom,+ suppressFocus,});// https://github.com/siyuan-note/siyuan/issues/4874if (options.focusId) {@@ -1090,7 +1097,9 @@ export const zoomOut = (options: {} else {showElement = getFirstBlock(showElement);}- if (showElement === focusElement && options.focusPosition) {+ if (suppressFocus) {+ scrollCenter(options.protyle, showElement, "start");+ } else if (showElement === focusElement && options.focusPosition) {focusByOffset(showElement, options.focusPosition.start, options.focusPosition.end);} else {focusBlock(showElement, undefined, true, true);@@ -1110,6 +1119,7 @@ export const zoomOut = (options: {action: options.isPushBack ? [Constants.CB_GET_FOCUS] : [Constants.CB_GET_FOCUS, Constants.CB_GET_UNUNDO],dataDocType: options.dataDocType,focusAfterZoom: true,+ suppressFocus,});});return;@@ -1133,6 +1143,7 @@ export const zoomOut = (options: {},dataDocType: options.dataDocType,focusAfterZoom: true,+ suppressFocus,});});return;diff --git a/app/src/menus/util.ts b/app/src/menus/util.tsindex 70b84cb54d..3d69f09c65 100644--- a/app/src/menus/util.ts+++ b/app/src/menus/util.ts@@ -9,7 +9,7 @@ import {Constants} from "../constants";import {openNewWindowById} from "../window/openNewWindow";import {MenuItem} from "./Menu";import type {App} from "../index";-import {isInAndroid, saveExportFile, updateHotkeyTip} from "../protyle/util/compatibility";+import {isInAndroid, isPhablet, saveExportFile, updateHotkeyTip} from "../protyle/util/compatibility";import {checkFold} from "../util/noRelyPCFunction";import {showMessage} from "../dialog/message";import type {Editor} from "../editor";@@ -86,7 +86,7 @@ export const openEditorTab = (app: App, ids: string[], notebookId?: string, pathapp,id: ids[0],position: "right",- action: [Constants.CB_GET_FOCUS, Constants.CB_GET_SCROLL]+ action: isPhablet() ? [Constants.CB_GET_SCROLL] : [Constants.CB_GET_FOCUS, Constants.CB_GET_SCROLL]});} else {ids.forEach((id) => {@@ -113,7 +113,7 @@ export const openEditorTab = (app: App, ids: string[], notebookId?: string, pathapp,id: ids[0],position: "bottom",- action: [Constants.CB_GET_FOCUS, Constants.CB_GET_SCROLL]+ action: isPhablet() ? [Constants.CB_GET_SCROLL] : [Constants.CB_GET_FOCUS, Constants.CB_GET_SCROLL]});} else {ids.forEach((id) => {@@ -140,7 +140,7 @@ export const openEditorTab = (app: App, ids: string[], notebookId?: string, pathopenFileById({app,id: ids[0],- action: [Constants.CB_GET_FOCUS, Constants.CB_GET_SCROLL],+ action: isPhablet() ? [Constants.CB_GET_SCROLL] : [Constants.CB_GET_FOCUS, Constants.CB_GET_SCROLL],removeCurrentTab: false});} else {diff --git a/app/src/protyle/breadcrumb/index.ts b/app/src/protyle/breadcrumb/index.tsindex 3112bc9a90..5eab3deb63 100644--- a/app/src/protyle/breadcrumb/index.ts+++ b/app/src/protyle/breadcrumb/index.ts@@ -29,7 +29,7 @@ import {Menu} from "../../plugin/Menu";import {getNoContainerElement} from "../wysiwyg/getBlock";import {openTitleMenu} from "../header/openTitleMenu";import {emitOpenMenu} from "../../plugin/EventBus";-import {isInAndroid, isInHarmony, isIPad, isMac, updateHotkeyTip} from "../util/compatibility";+import {isInAndroid, isInHarmony, isIPad, isMac, isPhablet, updateHotkeyTip} from "../util/compatibility";import {isEncryptedBox} from "../../util/pathName";import {listIndent, listOutdent} from "../wysiwyg/list";import {improveBreadcrumbAppearance} from "../wysiwyg/renderBacklink";@@ -119,7 +119,7 @@ ${padHTML}openFileById({app: protyle.app,id,- action: id === protyle.block.rootID ? [Constants.CB_GET_FOCUS] : [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL]+ action: id === protyle.block.rootID ? [isPhablet() ? Constants.CB_GET_HL : Constants.CB_GET_FOCUS] : [isPhablet() ? Constants.CB_GET_HL : Constants.CB_GET_FOCUS, Constants.CB_GET_ALL]});} else {zoomOut({protyle, id});@@ -172,6 +172,7 @@ ${padHTML}protyle,id: protyle.block.rootID,focusId: protyle.block.id,+ suppressFocus: isPhablet(),dataDocType: "NodeDocument",callback: () => {element.querySelector('[data-type="context"]').classList.add("block__icon--active");diff --git a/app/src/search/index.ts b/app/src/search/index.tsindex 6d49e1acf0..0465e52756 100644--- a/app/src/search/index.ts+++ b/app/src/search/index.ts@@ -6,6 +6,7 @@ import {setPanelFocus} from "../layout/util";import type {App} from "../index";import {clearOBG} from "../layout/dock/util";import {cancelSearchRequest} from "./request";+import {isPhablet} from "../protyle/util/compatibility";export class Search extends Model {public element: HTMLElement;@@ -46,7 +47,9 @@ export class Search extends Model {}}inputElement.value = text;- inputElement.select();+ if (!isPhablet()) {+ inputElement.select();+ }inputElement.dispatchEvent(new CustomEvent("input"));}diff --git a/app/src/search/util.ts b/app/src/search/util.tsindex f1fabb517c..26bbbb36db 100644--- a/app/src/search/util.ts+++ b/app/src/search/util.ts@@ -17,7 +17,7 @@ import {getIconByType} from "../editor/getIcon";import {unicode2Emoji} from "../emoji";import {getFileTreeIconHTML} from "../emoji/fileTreeIcon";import {hasClosestBlock, hasClosestByClassName, hasClosestByTag} from "../protyle/util/hasClosest";-import {isIPad, isNotCtrl, setStorageVal, updateHotkeyTip} from "../protyle/util/compatibility";+import {isIPad, isNotCtrl, isPhablet, setStorageVal, updateHotkeyTip} from "../protyle/util/compatibility";import {newFile} from "../util/newFile";import {filterMenu,@@ -329,7 +329,9 @@ export const genSearch = (app: App, config: Config.IUILayoutTabSearchConfig, elesearchInputElement.value = config.k || "";replaceInputElement.value = config.r || "";- searchInputElement.select();+ if (!isPhablet() || !config.k) {+ searchInputElement.select();+ }const dragElement = element.querySelector(".search__drag");dragElement.addEventListener("mousedown", (event: MouseEvent) => {@@ -1067,7 +1069,8 @@ const openSearchBlockEditor = (options: {openFileById({app: options.protyle.app,id: options.id,- action: currentRange ?+ action: isPhablet() ?+ (zoomIn ? [Constants.CB_GET_ALL, Constants.CB_GET_HL] : [Constants.CB_GET_CONTEXT, Constants.CB_GET_HL]) : currentRange ?(zoomIn ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL, Constants.CB_GET_SCROLL, Constants.CB_GET_SEARCH] : [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT, Constants.CB_GET_SCROLL, Constants.CB_GET_SEARCH]) :(zoomIn ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL, Constants.CB_GET_HL] : [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT, Constants.CB_GET_HL]),zoomIn,diff --git a/app/src/util/backForward.ts b/app/src/util/backForward.tsindex 9827206760..4484d55f0a 100644--- a/app/src/util/backForward.ts+++ b/app/src/util/backForward.ts@@ -134,6 +134,7 @@ const focusStack = async (app: App, stack: IBackStack) => {protyle: stack.protyle,id: stack.zoomId || stack.protyle.block.rootID,isPushBack: false,+ suppressFocus: false,callback: focusTitle,});} else {@@ -215,6 +216,7 @@ const focusStack = async (app: App, stack: IBackStack) => {protyle: stack.protyle,id: stack.zoomId || stack.protyle.block.rootID,isPushBack: false,+ suppressFocus: false,callback: () => {Array.from(stack.protyle.wysiwyg.element.querySelectorAll(`[data-node-id="${stack.id}"]`)).find((item: HTMLElement) => {if (!isInEmbedBlock(item)) {diff --git a/app/src/util/noRelyPCFunction.ts b/app/src/util/noRelyPCFunction.tsindex a357e32085..9f9842d088 100644--- a/app/src/util/noRelyPCFunction.ts+++ b/app/src/util/noRelyPCFunction.ts@@ -9,7 +9,7 @@ import {Tag} from "../layout/dock/Tag";import {upDownHint} from "./upDownHint";import {escapeHtml} from "./escape";import {hasClosestByClassName} from "../protyle/util/hasClosest";-import {isNotCtrl} from "../protyle/util/compatibility";+import {isNotCtrl, isPhablet} from "../protyle/util/compatibility";import {electronUndo} from "../protyle/undo";export const genTagList = (listElement: Element, k: string) => {@@ -122,8 +122,9 @@ export const checkFold = (id: string, cb: (zoomIn: boolean, action: TProtyleActireturn;}fetchPost("/api/block/checkBlockFold", {id}, (foldResponse) => {+ const action = isPhablet() ? Constants.CB_GET_HL : Constants.CB_GET_FOCUS;cb(foldResponse.data.isFolded,- foldResponse.data.isFolded ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL] : [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT, Constants.CB_GET_ROOTSCROLL],+ foldResponse.data.isFolded ? [action, Constants.CB_GET_ALL] : [action, Constants.CB_GET_CONTEXT, Constants.CB_GET_ROOTSCROLL],foldResponse.data.isRoot);});};