mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-03 23:38:49 +01:00
This commit is contained in:
parent
bb814179aa
commit
70ab49f7aa
4 changed files with 25 additions and 1 deletions
|
|
@ -473,6 +473,16 @@ export const activeBlur = () => {
|
|||
export const initKeyboardToolbar = () => {
|
||||
let preventRender = false;
|
||||
document.addEventListener("selectionchange", () => {
|
||||
if (isInAndroid()) {
|
||||
const range = document.getSelection().getRangeAt(0);
|
||||
const editor = getCurrentEditor();
|
||||
if (range.toString() && editor.protyle.wysiwyg.element.contains(range.startContainer) &&
|
||||
range.getBoundingClientRect().top < editor.protyle.contentElement.getBoundingClientRect().top) {
|
||||
window.siyuan.mobile.androidLastRange = range.cloneRange();
|
||||
} else {
|
||||
window.siyuan.mobile.androidLastRange = null;
|
||||
}
|
||||
}
|
||||
if (!preventRender) {
|
||||
renderKeyboardToolbar();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,9 +2,11 @@ import {hasClosestByAttribute, hasClosestByClassName, hasTopClosestByClassName,}
|
|||
import {closeModel, closePanel} from "./closePanel";
|
||||
import {popMenu} from "../menu";
|
||||
import {activeBlur} from "./keyboardToolbar";
|
||||
import {isIPhone} from "../../protyle/util/compatibility";
|
||||
import {isInAndroid, isIPhone} from "../../protyle/util/compatibility";
|
||||
import {App} from "../../index";
|
||||
import {globalTouchEnd, globalTouchStart} from "../../boot/globalEvent/touch";
|
||||
import {focusByRange} from "../../protyle/util/selection";
|
||||
import {getCurrentEditor} from "../editor";
|
||||
|
||||
let clientX: number;
|
||||
let clientY: number;
|
||||
|
|
@ -27,6 +29,15 @@ const popSide = (render = true) => {
|
|||
};
|
||||
|
||||
export const handleTouchEnd = (event: TouchEvent, app: App) => {
|
||||
if (isInAndroid() && window.siyuan.mobile.androidLastRange && getSelection().rangeCount>0) {
|
||||
const range = getSelection().getRangeAt(0);
|
||||
if (range.toString() && range.startContainer === window.siyuan.mobile.androidLastRange.startContainer) {
|
||||
range.setStart(window.siyuan.mobile.androidLastRange.startContainer, window.siyuan.mobile.androidLastRange.startOffset);
|
||||
focusByRange(range);
|
||||
const editor = getCurrentEditor();
|
||||
editor.protyle.toolbar.range = range;
|
||||
}
|
||||
}
|
||||
if (isIPhone() && globalTouchEnd(event, yDiff, time, app)) {
|
||||
event.stopImmediatePropagation();
|
||||
event.preventDefault();
|
||||
|
|
|
|||
|
|
@ -59,6 +59,7 @@ export const scrollEvent = (protyle: IProtyle, element: HTMLElement) => {
|
|||
protyle.scroll.updateIndex(protyle, blockElement.getAttribute("data-node-id"));
|
||||
}, Constants.TIMEOUT_LOAD);
|
||||
}
|
||||
|
||||
if (protyle.wysiwyg.element.getAttribute("data-top") || protyle.block.showAll ||
|
||||
(protyle.scroll && protyle.scroll.element.classList.contains("fn__none")) || !protyle.scroll ||
|
||||
protyle.scroll.lastScrollTop === element.scrollTop || protyle.scroll.lastScrollTop === -1 ||
|
||||
|
|
@ -66,6 +67,7 @@ export const scrollEvent = (protyle: IProtyle, element: HTMLElement) => {
|
|||
!protyle.wysiwyg.element.firstElementChild) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (protyle.scroll.lastScrollTop - element.scrollTop > 0) {
|
||||
// up
|
||||
if (element.scrollTop < element.clientHeight &&
|
||||
|
|
|
|||
1
app/src/types/index.d.ts
vendored
1
app/src/types/index.d.ts
vendored
|
|
@ -436,6 +436,7 @@ interface ISiyuan {
|
|||
emojis?: IEmoji[],
|
||||
backStack?: IBackStack[],
|
||||
mobile?: {
|
||||
androidLastRange?: Range,
|
||||
editor?: import("../protyle").Protyle
|
||||
popEditor?: import("../protyle").Protyle
|
||||
docks?: {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue