Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
31f80722e3
9 changed files with 55 additions and 25 deletions
|
@ -86,7 +86,7 @@ export const initConfigSearch = (element: HTMLElement, app: App) => {
|
|||
getLang(["cloudStorage", "trafficStat", "sync", "backup", "cdn", "total", "sizeLimit", "cloudBackup",
|
||||
"cloudBackupTip", "updatePath", "cloudSync", "upload", "download", "syncMode", "syncModeTip",
|
||||
"generateConflictDoc", "generateConflictDocTip", "syncProvider", "syncProviderTip",
|
||||
"syncMode1", "syncMode2", "reposTip", "openSyncTip1", "openSyncTip2", "cloudSyncDir", "config"]),
|
||||
"syncMode1", "syncMode2", "reposTip", "openSyncTip1", "openSyncTip2", "cloudSyncDir", "cloudSyncDirTip", "config"]),
|
||||
|
||||
// 发布
|
||||
getLang(["publishService", "publishServiceTip", "publishServicePort", "publishServicePortTip",
|
||||
|
@ -100,7 +100,8 @@ export const initConfigSearch = (element: HTMLElement, app: App) => {
|
|||
"systemLog", "importKey", "genKey", "genKeyByPW", "copyKey", "resetRepo", "systemLogTip", "export",
|
||||
"downloadLatestVer", "safeQuit", "directConnection", "siyuanNote", "key", "password", "copied", "resetRepoTip",
|
||||
"autoDownloadUpdatePkg", "autoDownloadUpdatePkgTip", "networkProxy", "keyPlaceholder", "initRepoKeyTip",
|
||||
"googleAnalytics", "googleAnalyticsTip"]),
|
||||
"googleAnalytics", "googleAnalyticsTip", "dataRepoPurge", "dataRepoPurgeTip", "dataRepoAutoPurgeIndexRetentionDays",
|
||||
"dataRepoAutoPurgeRetentionIndexesDaily"]),
|
||||
];
|
||||
const inputElement = element.querySelector(".b3-form__icon input") as HTMLInputElement;
|
||||
/// #if !BROWSER
|
||||
|
|
|
@ -172,9 +172,12 @@ export const openEditorTab = (app: App, ids: string[], notebookId?: string, path
|
|||
};
|
||||
|
||||
export const copyPNGByLink = (link: string) => {
|
||||
if (isInAndroid() || isInHarmony()) {
|
||||
if (isInAndroid()) {
|
||||
window.JSAndroid.writeImageClipboard(link);
|
||||
return;
|
||||
} else if (isInHarmony()) {
|
||||
window.JSHarmony.writeImageClipboard(link);
|
||||
return;
|
||||
} else {
|
||||
const canvas = document.createElement("canvas");
|
||||
const tempElement = document.createElement("img");
|
||||
|
|
|
@ -34,7 +34,7 @@ class App {
|
|||
public appId: string;
|
||||
|
||||
constructor() {
|
||||
if (!window.webkit?.messageHandlers && !window.JSAndroid) {
|
||||
if (!window.webkit?.messageHandlers && !window.JSAndroid && !window.JSHarmony) {
|
||||
registerServiceWorker(`${Constants.SERVICE_WORKER_PATH}?v=${Constants.SIYUAN_VERSION}`);
|
||||
}
|
||||
addBaseURL();
|
||||
|
|
|
@ -1653,8 +1653,10 @@ export class Gutter {
|
|||
label: `${window.siyuan.languages.copy} ${window.siyuan.languages.headings1}`,
|
||||
click() {
|
||||
fetchPost("/api/block/getHeadingChildrenDOM", {id}, (response) => {
|
||||
if (isInAndroid() || isInHarmony()) {
|
||||
if (isInAndroid()) {
|
||||
window.JSAndroid.writeHTMLClipboard(protyle.lute.BlockDOM2StdMd(response.data).trimEnd(), response.data + Constants.ZWSP);
|
||||
} else if (isInHarmony()) {
|
||||
window.JSHarmony.writeHTMLClipboard(protyle.lute.BlockDOM2StdMd(response.data).trimEnd(), response.data + Constants.ZWSP);
|
||||
} else {
|
||||
writeText(response.data + Constants.ZWSP);
|
||||
}
|
||||
|
@ -1667,8 +1669,10 @@ export class Gutter {
|
|||
label: `${window.siyuan.languages.cut} ${window.siyuan.languages.headings1}`,
|
||||
click() {
|
||||
fetchPost("/api/block/getHeadingChildrenDOM", {id}, (response) => {
|
||||
if (isInAndroid() || isInHarmony()) {
|
||||
if (isInAndroid()) {
|
||||
window.JSAndroid.writeHTMLClipboard(protyle.lute.BlockDOM2StdMd(response.data).trimEnd(), response.data + Constants.ZWSP);
|
||||
} else if (isInHarmony()) {
|
||||
window.JSHarmony.writeHTMLClipboard(protyle.lute.BlockDOM2StdMd(response.data).trimEnd(), response.data + Constants.ZWSP);
|
||||
} else {
|
||||
writeText(response.data + Constants.ZWSP);
|
||||
}
|
||||
|
|
|
@ -21,16 +21,20 @@ export const openByMobile = (uri: string) => {
|
|||
window.webkit.messageHandlers.openLink.postMessage("https://" + uri);
|
||||
}
|
||||
}
|
||||
} else if (isInAndroid() || isInHarmony()) {
|
||||
} else if (isInAndroid()) {
|
||||
window.JSAndroid.openExternal(uri);
|
||||
} else if (isInHarmony()) {
|
||||
window.JSHarmony.openExternal(uri);
|
||||
} else {
|
||||
window.open(uri);
|
||||
}
|
||||
};
|
||||
|
||||
export const readText = () => {
|
||||
if (isInAndroid() || isInHarmony()) {
|
||||
if (isInAndroid()) {
|
||||
return window.JSAndroid.readClipboard();
|
||||
} else if (isInHarmony()) {
|
||||
return window.JSHarmony.readClipboard();
|
||||
}
|
||||
return navigator.clipboard.readText();
|
||||
};
|
||||
|
@ -42,10 +46,14 @@ export const writeText = (text: string) => {
|
|||
}
|
||||
try {
|
||||
// navigator.clipboard.writeText 抛出异常不进入 catch,这里需要先处理移动端复制
|
||||
if (isInAndroid() || isInHarmony()) {
|
||||
if (isInAndroid()) {
|
||||
window.JSAndroid.writeClipboard(text);
|
||||
return;
|
||||
}
|
||||
if (isInHarmony()) {
|
||||
window.JSHarmony.writeClipboard(text);
|
||||
return;
|
||||
}
|
||||
if (isInIOS()) {
|
||||
window.webkit.messageHandlers.setClipboard.postMessage(text);
|
||||
return;
|
||||
|
@ -54,8 +62,10 @@ export const writeText = (text: string) => {
|
|||
} catch (e) {
|
||||
if (isInIOS()) {
|
||||
window.webkit.messageHandlers.setClipboard.postMessage(text);
|
||||
} else if (isInAndroid() || isInHarmony()) {
|
||||
} else if (isInAndroid()) {
|
||||
window.JSAndroid.writeClipboard(text);
|
||||
} else if (isInHarmony()) {
|
||||
window.JSHarmony.writeClipboard(text);
|
||||
} else {
|
||||
const textElement = document.createElement("textarea");
|
||||
textElement.value = text;
|
||||
|
@ -137,7 +147,7 @@ export const isInIOS = () => {
|
|||
};
|
||||
|
||||
export const isInHarmony = () => {
|
||||
return window.siyuan.config.system.container === "harmony";
|
||||
return window.siyuan.config.system.container === "harmony" && window.JSHarmony;
|
||||
}
|
||||
|
||||
// Mac,Windows 快捷键展示
|
||||
|
|
9
app/src/types/index.d.ts
vendored
9
app/src/types/index.d.ts
vendored
|
@ -178,6 +178,15 @@ interface Window {
|
|||
readClipboard(): string
|
||||
getBlockURL(): string
|
||||
}
|
||||
JSHarmony: {
|
||||
openExternal(url: string): void
|
||||
changeStatusBarColor(color: string, mode: number): void
|
||||
writeClipboard(text: string): void
|
||||
writeHTMLClipboard(text: string, html: string): void
|
||||
writeImageClipboard(uri: string): void
|
||||
readClipboard(): string
|
||||
getBlockURL(): string
|
||||
}
|
||||
|
||||
Protyle: import("../protyle/method").default
|
||||
|
||||
|
|
|
@ -342,8 +342,10 @@ const updateMobileTheme = (OSTheme: string) => {
|
|||
}
|
||||
if (isInIOS()) {
|
||||
window.webkit.messageHandlers.changeStatusBar.postMessage((backgroundColor || (mode === 0 ? "#fff" : "#1e1e1e")) + " " + mode);
|
||||
} else if (isInAndroid() || isInHarmony()) {
|
||||
} else if (isInAndroid()) {
|
||||
window.JSAndroid.changeStatusBarColor(backgroundColor, mode);
|
||||
} else if ( isInHarmony()) {
|
||||
window.JSHarmony.changeStatusBarColor(backgroundColor, mode);
|
||||
}
|
||||
}, 500); // 移动端需要加载完才可以获取到颜色
|
||||
}
|
||||
|
|
|
@ -416,7 +416,7 @@
|
|||
const {ipcRenderer} = require('electron')
|
||||
ipcRenderer.send('siyuan-quit', window.location.port)
|
||||
} catch (e) {
|
||||
if ((window.webkit && window.webkit.messageHandlers) || window.JSAndroid) {
|
||||
if ((window.webkit && window.webkit.messageHandlers) || window.JSAndroid || window.JSHarmony) {
|
||||
window.location.href = 'siyuan://api/system/exit'
|
||||
} else {
|
||||
window.location.reload()
|
||||
|
|
|
@ -695,6 +695,7 @@ func ImportFromLocalPath(boxID, localPath string, toPath string) (err error) {
|
|||
|
||||
hPathsIDs := map[string]string{}
|
||||
idPaths := map[string]string{}
|
||||
moveIDs := map[string]string{}
|
||||
|
||||
if gulu.File.IsDir(localPath) { // 导入文件夹
|
||||
// 收集所有资源文件
|
||||
|
@ -793,6 +794,7 @@ func ImportFromLocalPath(boxID, localPath string, toPath string) (err error) {
|
|||
}
|
||||
|
||||
if "" != yfmRootID {
|
||||
moveIDs[id] = yfmRootID
|
||||
id = yfmRootID
|
||||
}
|
||||
if "" != yfmTitle {
|
||||
|
@ -999,6 +1001,13 @@ func ImportFromLocalPath(boxID, localPath string, toPath string) (err error) {
|
|||
}
|
||||
|
||||
if 0 < len(importTrees) {
|
||||
for id, newID := range moveIDs {
|
||||
for _, importTree := range importTrees {
|
||||
importTree.ID = strings.ReplaceAll(importTree.ID, id, newID)
|
||||
importTree.Path = strings.ReplaceAll(importTree.Path, id, newID)
|
||||
}
|
||||
}
|
||||
|
||||
initSearchLinks()
|
||||
convertWikiLinksAndTags()
|
||||
buildBlockRefInText()
|
||||
|
@ -1184,16 +1193,6 @@ func imgHtmlBlock2InlineImg(tree *parse.Tree) {
|
|||
}
|
||||
|
||||
func reassignIDUpdated(tree *parse.Tree, rootID, updated string) {
|
||||
var blockCount int
|
||||
ast.Walk(tree.Root, func(n *ast.Node, entering bool) ast.WalkStatus {
|
||||
if !entering || "" == n.ID {
|
||||
return ast.WalkContinue
|
||||
}
|
||||
|
||||
blockCount++
|
||||
return ast.WalkContinue
|
||||
})
|
||||
|
||||
ast.Walk(tree.Root, func(n *ast.Node, entering bool) ast.WalkStatus {
|
||||
if !entering || "" == n.ID {
|
||||
return ast.WalkContinue
|
||||
|
@ -1207,8 +1206,10 @@ func reassignIDUpdated(tree *parse.Tree, rootID, updated string) {
|
|||
n.SetIALAttr("id", n.ID)
|
||||
if "" != updated {
|
||||
n.SetIALAttr("updated", updated)
|
||||
n.ID = updated + "-" + gulu.Rand.String(7)
|
||||
n.SetIALAttr("id", n.ID)
|
||||
if "" == rootID {
|
||||
n.ID = updated + "-" + gulu.Rand.String(7)
|
||||
n.SetIALAttr("id", n.ID)
|
||||
}
|
||||
} else {
|
||||
n.SetIALAttr("updated", util.TimeFromID(n.ID))
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue