Skip to content

Commit

Permalink
Merge pull request #7 from TCOTC/dev
Browse files Browse the repository at this point in the history
PR
  • Loading branch information
TCOTC authored May 17, 2024
2 parents 9f5a735 + 14908db commit 64cf8c8
Show file tree
Hide file tree
Showing 35 changed files with 618 additions and 391 deletions.
2 changes: 0 additions & 2 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
* `git clone --depth=1 [email protected]:siyuan-note/siyuan.git`
* switch to dev branch `git checkout dev`

Note: `app/stage/protyle/**` is managed by git lfs, and you don't need to pay attention to it under normal circumstances, related to [#9253](https://github.com/siyuan-note/siyuan/issues/9253).

## User Interface

Install pnpm: `npm install -g pnpm`
Expand Down
2 changes: 0 additions & 2 deletions .github/CONTRIBUTING_zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
* `git clone --depth=1 [email protected]:siyuan-note/siyuan.git`
* 切换到 dev 分支 `git checkout dev`

备注:`app/stage/protyle/**` 使用 git lfs 管理,正常情况下无需关注,关联 [#9253](https://github.com/siyuan-note/siyuan/issues/9253)

## NPM 依赖

安装 pnpm:`npm install -g pnpm`
Expand Down
1 change: 1 addition & 0 deletions app/.npmrc
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
shell-emulator=true
virtual-store-dir-max-length=80
2 changes: 1 addition & 1 deletion app/appearance/langs/en_US.json
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@
"syncConfGuide4": "Sync now?",
"syncConfGuide5": "If the amount of data is large, the first sync will be slow, please wait patiently<br>Do not switch apps and keep the screen bright while the iOS/iPad is syncing",
"copyPlainText": "Copy plain text",
"findInDoc": "Match ${y} items in ${x} docs",
"findInDoc": "Matches ${y} blocks in ${x} documents",
"jumpToParentNext": "Jump to the next block of the parent block",
"jumpToParentPrev": "Jump to the previous block of the parent block",
"jumpToParent": "Jump to parent block",
Expand Down
2 changes: 1 addition & 1 deletion app/appearance/langs/es_ES.json
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@
"syncConfGuide4": "¿Sincronizar ahora?",
"syncConfGuide5": "Si la cantidad de datos es grande, la primera sincronización será lenta, espere pacientemente<br>No cambie de aplicación y mantenga la pantalla brillante mientras iOS/iPad se sincroniza",
"copyPlainText": "Copiar texto sin formato",
"findInDoc": "Hacer coincidir ${y} elementos en ${x} documentos",
"findInDoc": "Coincide con bloques ${y} en documentos ${x}",
"jumpToParentNext": "Saltar al siguiente bloque del bloque principal",
"jumpToParentPrev": "Saltar al bloque anterior del bloque principal",
"jumpToParent": "Saltar al bloque principal",
Expand Down
2 changes: 1 addition & 1 deletion app/appearance/langs/fr_FR.json
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@
"syncConfGuide4": "Synchroniser maintenant ?",
"syncConfGuide5": "Si la quantité de données est importante, la première synchronisation sera lente, veuillez patienter<br> Ne changez pas d'application et gardez l'écran lumineux pendant la synchronisation de l'iOS/iPad",
"copyPlainText": "Copier du texte brut",
"findInDoc": "Faire correspondre les éléments ${y} dans les documents ${x}",
"findInDoc": "Correspond à ${y} blocs dans ${x} documents",
"jumpToParentNext": "Sauter au bloc suivant du bloc parent",
"jumpToParentPrev": "Sauter au bloc précédent du bloc parent",
"jumpToParent": "Sauter au bloc parent",
Expand Down
2 changes: 1 addition & 1 deletion app/appearance/langs/ja_JP.json
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@
"syncConfGuide4": "今すぐ同期しますか?",
"syncConfGuide5": "データ量が多い場合は最初の同期が遅くなる場合がありますのでしばらくお待ちください。<br>iOS/iPad で同期している間はアプリを切り替えず画面を明るく保ってください",
"copyPlainText": "プレーンテキストとしてコピー",
"findInDoc": "${x} 個のドキュメントに ${y} 件の一致があります",
"findInDoc": "${x} ドキュメント内の ${y} ブロックと一致します",
"jumpToParentNext": "次の親ブロックに移動",
"jumpToParentPrev": "前の親ブロックに移動",
"jumpToParent": "親ブロックに移動",
Expand Down
2 changes: 1 addition & 1 deletion app/appearance/langs/zh_CHT.json
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@
"syncConfGuide4": "立即同步?",
"syncConfGuide5": "如果資料量較大,第一次同步會比較慢,請耐心等待<br>iOS/iPad 端在同步時請勿切換應用並保持螢幕恆亮",
"copyPlainText": "複製純文字",
"findInDoc": "${x} 個文檔中匹配 ${y} ",
"findInDoc": "${x} 個文件中符合 ${y} 個區塊",
"jumpToParentNext": "跳到父區塊的下一個區塊",
"jumpToParentPrev": "跳到父區塊的上一個區塊",
"jumpToParent": "跳到父區塊",
Expand Down
2 changes: 1 addition & 1 deletion app/appearance/langs/zh_CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@
"syncConfGuide4": "立即同步?",
"syncConfGuide5": "如果数据量较大,第一次同步会比较慢,请耐心等待<br>iOS/iPad 端在同步时请勿切换应用并保持亮屏",
"copyPlainText": "复制纯文本",
"findInDoc": "${x} 个文档中匹配 ${y} ",
"findInDoc": "${x} 个文档中匹配 ${y} 个块",
"jumpToParentNext": "跳转到父块的下一个块",
"jumpToParentPrev": "跳转到父块的上一个块",
"jumpToParent": "跳转到父块",
Expand Down
2 changes: 1 addition & 1 deletion app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "Refactor your thinking",
"homepage": "https://b3log.org/siyuan",
"main": "./electron/main.js",
"packageManager": "pnpm@9.0.6",
"packageManager": "pnpm@9.1.1",
"scripts": {
"lint": "eslint . --fix --cache",
"dev": "webpack --mode development",
Expand Down
127 changes: 124 additions & 3 deletions app/src/boot/globalEvent/command/global.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,66 @@ import {Editor} from "../../../editor";
import {openDock} from "../../../mobile/dock/util";
import {popMenu} from "../../../mobile/menu";
import {popSearch} from "../../../mobile/menu/search";
import {getRecentDocs} from "../../../mobile/menu/getRecentDocs";
/// #else
import {openNewWindow} from "../../../window/openNewWindow";
import {toggleDockBar} from "../../../layout/dock/util";
import {openGlobalSearch} from "../../../search/util";
import {workspaceMenu} from "../../../menus/workspace";
import {isWindow} from "../../../util/functions";
import {openRecentDocs} from "../../../business/openRecentDocs";
import {openSearch} from "../../../search/spread";
import {goBack, goForward} from "../../../util/backForward";
import {getAllTabs} from "../../../layout/getAll";
import {getInstanceById} from "../../../layout/util";
import {closeTabByType, getActiveTab, getDockByType, switchTabByIndex} from "../../../layout/tabUtil";
import {
closeTabByType,
copyTab,
getActiveTab,
getDockByType,
resizeTabs,
switchTabByIndex
} from "../../../layout/tabUtil";
import {openSetting} from "../../../config";
import {Tab} from "../../../layout/Tab";
import {Files} from "../../../layout/dock/Files";
/// #endif
/// #if !BROWSER
import {ipcRenderer} from "electron";
/// #endif
import {App} from "../../../index";
import {Constants} from "../../../constants";
import {setReadOnly} from "../../../config/util/setReadOnly";
import {lockScreen} from "../../../dialog/processSystem";
import {newFile} from "../../../util/newFile";
import {openCard} from "../../../card/openCard";
import {syncGuide} from "../../../sync/syncGuide";

const selectOpenTab = () => {
/// #if MOBILE
if (window.siyuan.mobile.editor?.protyle) {
openDock("file");
window.siyuan.mobile.files.selectItem(window.siyuan.mobile.editor.protyle.notebookId, window.siyuan.mobile.editor.protyle.path);
}
/// #else
const dockFile = getDockByType("file");
if (!dockFile) {
return false;
}
const files = dockFile.data.file as Files;
const element = document.querySelector(".layout__wnd--active > .fn__flex > .layout-tab-bar > .item--focus") ||
document.querySelector("ul.layout-tab-bar > .item--focus");
if (element) {
const tab = getInstanceById(element.getAttribute("data-id")) as Tab;
if (tab && tab.model instanceof Editor) {
tab.model.editor.protyle.wysiwyg.element.blur();
tab.model.editor.protyle.title.editElement.blur();
files.selectItem(tab.model.editor.protyle.notebookId, tab.model.editor.protyle.path);
}
}
dockFile.toggleModel("file", true);
/// #endif
};

export const globalCommand = (command: string, app: App) => {
/// #if MOBILE
Expand All @@ -33,12 +81,15 @@ export const globalCommand = (command: string, app: App) => {
case "backlinks":
openDock("backlink");
return true;
case "config":
case "mainMenu":
popMenu();
return true;
case "globalSearch":
popSearch(app);
return true;
case "recentDocs":
getRecentDocs(app);
return true;
}
/// #else
switch (command) {
Expand Down Expand Up @@ -69,8 +120,12 @@ export const globalCommand = (command: string, app: App) => {
openSearch({
app,
hotkey: Constants.DIALOG_GLOBALSEARCH,
key: (getSelection().rangeCount > 0 ? getSelection().getRangeAt(0) : document.createRange()).toString()
});
return true;
case "stickSearch":
openGlobalSearch(app, (getSelection().rangeCount > 0 ? getSelection().getRangeAt(0) : document.createRange()).toString(), true);
return true;
case "goBack":
goBack(app);
return true;
Expand Down Expand Up @@ -110,7 +165,23 @@ export const globalCommand = (command: string, app: App) => {
case "goToTabPrev":
switchTabByIndex(-2);
return true;

case "mainMenu":
if (!isWindow()) {
workspaceMenu(app, document.querySelector("#barWorkspace").getBoundingClientRect());
}
return true;
case "recentDocs":
openRecentDocs();
return true;
case "toggleDock":
toggleDockBar(document.querySelector("#barDock use"));
return true;
case "toggleWin":
/// #if !BROWSER
ipcRenderer.send(Constants.SIYUAN_CMD, "hide");
ipcRenderer.send(Constants.SIYUAN_CMD, "minimize");
/// #endif
return true;
}
if (command === "goToEditTabNext" || command === "goToEditTabPrev") {
let currentTabElement = document.querySelector(".layout__wnd--active ul.layout-tab-bar > .item--focus");
Expand Down Expand Up @@ -219,6 +290,38 @@ export const globalCommand = (command: string, app: App) => {
}
return true;
}
if (command === "splitLR") {
const tab = getActiveTab(false);
if (tab) {
tab.parent.split("lr").addTab(copyTab(app, tab));
}
return true;
}
if (command === "splitTB") {
const tab = getActiveTab(false);
if (tab) {
tab.parent.split("tb").addTab(copyTab(app, tab));
}
return true;
}
if (command === "splitMoveB" || command === "splitMoveR") {
const tab = getActiveTab(false);
if (tab && tab.parent.children.length > 1) {
const newWnd = tab.parent.split(command === "splitMoveB" ? "tb" : "lr");
newWnd.headersElement.append(tab.headElement);
newWnd.headersElement.parentElement.classList.remove("fn__none");
newWnd.moveTab(tab);
resizeTabs();
}
return true;
}
if (command === "tabToWindow") {
const tab = getActiveTab(false);
if (tab) {
openNewWindow(tab);
}
return true;
}
/// #endif

switch (command) {
Expand All @@ -231,6 +334,24 @@ export const globalCommand = (command: string, app: App) => {
case "editReadonly":
setReadOnly(!window.siyuan.config.editor.readOnly);
return true;
case "lockScreen":
lockScreen(app);
return true;
case "newFile":
newFile({
app,
useSavePath: true
});
return true;
case "riffCard":
openCard(app);
return true;
case "selectOpen1":
selectOpenTab();
return true;
case "syncNow":
syncGuide(app);
return true;
}

return false;
Expand Down
Loading

0 comments on commit 64cf8c8

Please sign in to comment.