mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-02-22 23:14:07 +01:00
This commit is contained in:
parent
74273ebc1c
commit
f49dfa8273
7 changed files with 53 additions and 70 deletions
|
|
@ -1,4 +1,4 @@
|
|||
import {getEventName, writeText} from "../util/compatibility";
|
||||
import {getEventName, openByMobile, writeText} from "../util/compatibility";
|
||||
import {hasClosestByTag} from "../util/hasClosest";
|
||||
import {focusByRange} from "../util/selection";
|
||||
import {showMessage} from "../../dialog/message";
|
||||
|
|
@ -38,11 +38,9 @@ export class Preview {
|
|||
if (event.target.tagName === "A") {
|
||||
const linkAddress = event.target.getAttribute("href");
|
||||
if (isMobile()) {
|
||||
if (window.JSAndroid) {
|
||||
window.JSAndroid.openExternal(linkAddress);
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
}
|
||||
openByMobile(linkAddress);
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
return;
|
||||
}
|
||||
event.stopPropagation();
|
||||
|
|
|
|||
|
|
@ -1,3 +1,16 @@
|
|||
export const openByMobile = (uri:string) => {
|
||||
if (!uri) {
|
||||
return;
|
||||
}
|
||||
if (window.siyuan.config.system.container === "ios") {
|
||||
window.location.href = uri;
|
||||
} else if (window.siyuan.config.system.container === "android" && window.JSAndroid) {
|
||||
window.JSAndroid.openExternal(uri);
|
||||
} else {
|
||||
window.open(uri);
|
||||
}
|
||||
};
|
||||
|
||||
export const writeText = async (text: string) => {
|
||||
try {
|
||||
// navigator.clipboard.writeText 抛出异常不进入 catch,这里需要先处理移动端复制
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ import {openAsset, openBy, openFileById} from "../../editor/util";
|
|||
import {openGlobalSearch} from "../../search/util";
|
||||
/// #endif
|
||||
import {BlockPanel} from "../../block/Panel";
|
||||
import {isCtrl} from "../util/compatibility";
|
||||
import {isCtrl, openByMobile} from "../util/compatibility";
|
||||
import {MenuItem} from "../../menus/Menu";
|
||||
import {fetchPost} from "../../util/fetch";
|
||||
import {onGet} from "../util/onGet";
|
||||
|
|
@ -1419,11 +1419,7 @@ export class WYSIWYG {
|
|||
const fileIds = fileElement.getAttribute("data-id").split("/");
|
||||
const linkAddress = `assets/${fileIds[1]}`;
|
||||
/// #if MOBILE
|
||||
if (typeof window.JSAndroid === "undefined") {
|
||||
window.open(linkAddress);
|
||||
} else {
|
||||
window.JSAndroid.openExternal(linkAddress);
|
||||
}
|
||||
openByMobile(linkAddress)
|
||||
/// #else
|
||||
if (window.siyuan.ctrlIsPressed) {
|
||||
openBy(linkAddress, "folder");
|
||||
|
|
@ -1441,13 +1437,7 @@ export class WYSIWYG {
|
|||
event.preventDefault();
|
||||
const linkAddress = aElement.getAttribute("data-href");
|
||||
/// #if MOBILE
|
||||
if (window.siyuan.config.system.container === "ios") {
|
||||
window.location.href = linkAddress;
|
||||
} else if (window.siyuan.config.system.container === "android" && window.JSAndroid) {
|
||||
window.JSAndroid.openExternal(linkAddress);
|
||||
} else {
|
||||
window.open(linkAddress);
|
||||
}
|
||||
openByMobile(linkAddress);
|
||||
/// #else
|
||||
if (isLocalPath(linkAddress)) {
|
||||
const linkPathname = linkAddress.split("?page")[0];
|
||||
|
|
@ -1471,13 +1461,7 @@ export class WYSIWYG {
|
|||
openBy(linkAddress, "app");
|
||||
}
|
||||
/// #else
|
||||
if (window.siyuan.config.system.container === "ios") {
|
||||
window.location.href = linkAddress;
|
||||
} else if (window.siyuan.config.system.container === "android" && window.JSAndroid) {
|
||||
window.JSAndroid.openExternal(linkAddress);
|
||||
} else {
|
||||
window.open(linkAddress);
|
||||
}
|
||||
openByMobile(linkAddress)
|
||||
/// #endif
|
||||
}
|
||||
} else {
|
||||
|
|
@ -1486,13 +1470,7 @@ export class WYSIWYG {
|
|||
showMessage(e);
|
||||
});
|
||||
/// #else
|
||||
if (window.siyuan.config.system.container === "ios") {
|
||||
window.location.href = linkAddress;
|
||||
} else if (window.siyuan.config.system.container === "android" && window.JSAndroid) {
|
||||
window.JSAndroid.openExternal(linkAddress);
|
||||
} else {
|
||||
window.open(linkAddress);
|
||||
}
|
||||
openByMobile(linkAddress)
|
||||
/// #endif
|
||||
}
|
||||
/// #endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue