Skip to content

Commit a822968

Browse files
authored
Merge branch 'dev' into feat/16910
2 parents 9fed0a0 + 91a773e commit a822968

File tree

20 files changed

+127
-115
lines changed

20 files changed

+127
-115
lines changed

app/src/assets/scss/business/_av.scss

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@
100100
outline: none;
101101
white-space: nowrap;
102102
overflow: auto;
103+
padding-right: 0;
104+
font-size: 1em;
103105

104106
&::-webkit-scrollbar {
105107
display: none;

app/src/boot/globalEvent/event.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import {openFileById} from "../../editor/util";
2121
import {checkFold} from "../../util/noRelyPCFunction";
2222
import {hideAllElements} from "../../protyle/ui/hideElements";
2323
import {dragOverScroll, stopScrollAnimation} from "./dragover";
24+
import {setWebViewFocusable} from "../../mobile/util/mobileAppUtil";
2425

2526
export const initWindowEvent = (app: App) => {
2627
document.body.addEventListener("mouseleave", () => {
@@ -125,6 +126,9 @@ export const initWindowEvent = (app: App) => {
125126
window.siyuan.ctrlIsPressed = false;
126127
window.siyuan.shiftIsPressed = false;
127128
window.siyuan.altIsPressed = false;
129+
/// #if BROWSER
130+
setWebViewFocusable();
131+
/// #endif
128132
});
129133

130134
window.addEventListener("click", (event: MouseEvent & { target: HTMLElement }) => {

app/src/mobile/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ import {correctHotkey} from "../boot/globalEvent/commonHotkey";
3737
import {processIOSPurchaseResponse} from "../util/iOSPurchase";
3838
import {updateControlAlt} from "../protyle/util/hotKey";
3939
import {nbsp2space} from "../protyle/util/normalizeText";
40-
import {callMobileAppShowKeyboard, canInput} from "./util/mobileAppUtil";
40+
import {callMobileAppShowKeyboard, canInput, setWebViewFocusable} from "./util/mobileAppUtil";
4141
import {emitToEventBus, registerCustomEventBus} from "../plugin/EventBus";
4242

4343
class App {
@@ -180,6 +180,9 @@ class App {
180180
window.siyuan.shiftIsPressed = false;
181181
window.siyuan.altIsPressed = false;
182182
});
183+
window.addEventListener("blur", (event) => {
184+
setWebViewFocusable();
185+
});
183186
// 移动端删除键 https://github.com/siyuan-note/siyuan/issues/9259
184187
window.addEventListener("keydown", (event) => {
185188
mobileKeydown(siyuanApp, event);

app/src/mobile/util/mobileAppUtil.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ export let keyboardLockUntil = 0;
44

55
export const callMobileAppShowKeyboard = () => {
66
// 某些机型(比如鸿蒙 Pura X)在弹起键盘后会立即触发 activeBlur 导致键盘被关闭,所以在主动唤起键盘时锁定一段时间,禁止 activeBlur 关闭键盘
7-
// 每次主动唤起键盘时,锁定接下来的 200ms 不允许通过 activeBlur 关闭
8-
keyboardLockUntil = Date.now() + 200;
7+
// 每次主动唤起键盘时,锁定接下来的 500ms 不允许通过 activeBlur 关闭
8+
keyboardLockUntil = Date.now() + 500;
99

1010
if (window.JSAndroid && window.JSAndroid.showKeyboard) {
1111
window.JSAndroid.showKeyboard();
@@ -30,4 +30,14 @@ export const canInput = (element: Element) => {
3030
return hasClosestByAttribute(element, "contenteditable", "true");
3131
}
3232
return false;
33-
};
33+
};
34+
35+
export const setWebViewFocusable = () => {
36+
if ((window.JSAndroid || window.JSHarmony) && document.activeElement.tagName === "IFRAME") {
37+
if (window.JSAndroid?.setWebViewFocusable) {
38+
window.JSAndroid.setWebViewFocusable(true);
39+
} else if (window.JSHarmony?.setWebViewFocusable) {
40+
window.JSHarmony.setWebViewFocusable(true);
41+
}
42+
}
43+
};

app/src/protyle/header/Background.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ export class Background {
205205
});
206206
});
207207
});
208-
this.element.addEventListener(getEventName(), (event) => {
208+
this.element.addEventListener("click", (event) => {
209209
let target = event.target as HTMLElement;
210210
hideElements(["gutter"], protyle);
211211

app/src/protyle/render/av/action.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ export const avClick = (protyle: IProtyle, event: MouseEvent & { target: HTMLEle
323323
const searchElement = blockElement.querySelector('div[data-type="av-search"]') as HTMLInputElement;
324324
searchElement.style.width = "128px";
325325
searchElement.style.paddingLeft = "";
326-
searchElement.style.paddingRight = "";
326+
searchElement.style.marginRight = "1em";
327327
const viewsElement = hasClosestByClassName(searchElement, "av__views");
328328
if (viewsElement) {
329329
viewsElement.classList.add("av__views--show");

app/src/protyle/render/av/gallery/render.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ export const afterRenderGallery = (options: ITableOptions) => {
250250
viewsElement.classList.remove("av__views--show");
251251
searchInputElement.style.width = "0";
252252
searchInputElement.style.paddingLeft = "0";
253-
searchInputElement.style.paddingRight = "0";
253+
searchInputElement.style.marginRight = "0";
254254
}
255255
});
256256
addClearButton({
@@ -262,7 +262,7 @@ export const afterRenderGallery = (options: ITableOptions) => {
262262
viewsElement.classList.remove("av__views--show");
263263
searchInputElement.style.width = "0";
264264
searchInputElement.style.paddingLeft = "0";
265-
searchInputElement.style.paddingRight = "0";
265+
searchInputElement.style.marginRight = "0";
266266
focusBlock(options.blockElement);
267267
updateSearch(options.blockElement, options.protyle);
268268
/// #if MOBILE

app/src/protyle/render/av/render.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ export const genTabHeaderHTML = (data: IAV, showSearch: boolean, editable: boole
103103
<svg><use xlink:href="#iconSearch"></use></svg>
104104
</button>
105105
<div style="position: relative" class="fn__flex">
106-
<div contenteditable="true" style="${showSearch ? "width:128px" : "width:0;padding-left: 0;padding-right: 0;"}" data-type="av-search" class="b3-text-field b3-text-field--text" placeholder="${window.siyuan.languages.search}"></div>
106+
<div contenteditable="plaintext-only" style="${showSearch ? "width:128px" : "width:0;padding-left: 0;padding-right: 0;"}" data-type="av-search" class="b3-text-field b3-text-field--text" placeholder="${window.siyuan.languages.search}"></div>
107107
</div>
108108
<div class="fn__space"></div>
109109
<span data-type="av-more" aria-label="${window.siyuan.languages.config}" data-position="8south" class="ariaLabel block__icon">
@@ -427,7 +427,7 @@ const afterRenderTable = (options: ITableOptions) => {
427427
viewsElement.classList.remove("av__views--show");
428428
searchInputElement.style.width = "0";
429429
searchInputElement.style.paddingLeft = "0";
430-
searchInputElement.style.paddingRight = "0";
430+
searchInputElement.style.marginRight = "0";
431431
}
432432
});
433433
addClearButton({
@@ -439,7 +439,7 @@ const afterRenderTable = (options: ITableOptions) => {
439439
viewsElement.classList.remove("av__views--show");
440440
searchInputElement.style.width = "0";
441441
searchInputElement.style.paddingLeft = "0";
442-
searchInputElement.style.paddingRight = "0";
442+
searchInputElement.style.marginRight = "0";
443443
focusBlock(options.blockElement);
444444
updateSearch(options.blockElement, options.protyle);
445445
/// #if MOBILE

app/src/protyle/wysiwyg/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2388,7 +2388,7 @@ export class WYSIWYG {
23882388

23892389
this.element.addEventListener("paste", (event: ClipboardEvent & { target: HTMLElement }) => {
23902390
// https://github.com/siyuan-note/siyuan/issues/11241
2391-
if (event.target.getAttribute("data-type") === "av-search") {
2391+
if (hasClosestByAttribute(event.target, "data-type", "av-search")) {
23922392
return;
23932393
}
23942394
if (protyle.disabled) {

app/src/protyle/wysiwyg/keydown.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
9797
event.stopPropagation();
9898
return;
9999
}
100-
if (event.target.getAttribute("data-type") === "av-search") {
100+
if (hasClosestByAttribute(event.target, "data-type", "av-search")) {
101101
if (matchHotKey("⌘A", event)) {
102102
event.preventDefault();
103103
getSelection().getRangeAt(0).selectNodeContents(event.target);

0 commit comments

Comments
 (0)