diff --git a/app/src/assets/scss/business/_config.scss b/app/src/assets/scss/business/_config.scss index c0cc6ffbb..11f3937d7 100644 --- a/app/src/assets/scss/business/_config.scss +++ b/app/src/assets/scss/business/_config.scss @@ -208,6 +208,7 @@ justify-content: center; overflow: auto; flex: 1; + padding: 0 8px; margin-top: 8px; } } diff --git a/app/src/assets/scss/mobile.scss b/app/src/assets/scss/mobile.scss index 2309ea815..d34534a5b 100644 --- a/app/src/assets/scss/mobile.scss +++ b/app/src/assets/scss/mobile.scss @@ -254,6 +254,29 @@ text-align: center; } } + + .config-assets { + display: flex; + flex-direction: column; + height: 100%; + box-sizing: border-box; + + &__list { + overflow: auto; + flex: 1; + } + + &__preview { + display: flex; + flex-direction: row; + align-items: center; + justify-content: center; + overflow: auto; + flex: 1; + margin-top: 8px; + padding: 0 8px; + } + } } #menu { diff --git a/app/src/boot/globalEvent/click.ts b/app/src/boot/globalEvent/click.ts index 12640326b..e43571ee9 100644 --- a/app/src/boot/globalEvent/click.ts +++ b/app/src/boot/globalEvent/click.ts @@ -1,4 +1,6 @@ +/// #if !MOBILE import {getAllModels} from "../../layout/getAll"; +/// #endif import {hasClosestByAttribute, hasClosestByClassName, hasTopClosestByClassName} from "../../protyle/util/hasClosest"; import {hideAllElements} from "../../protyle/ui/hideElements"; import {isWindow} from "../../util/functions"; @@ -22,9 +24,25 @@ export const globalClick = (event: MouseEvent & { target: HTMLElement }) => { globalClickHideMenu(event.target); - if (!hasClosestByClassName(event.target, "pdf__outer")) { - hideAllElements(["pdfutil"]); + const protyleElement = hasClosestByClassName(event.target, "protyle", true); + if (protyleElement) { + const wysiwygElement = protyleElement.querySelector(".protyle-wysiwyg"); + if (wysiwygElement.getAttribute("data-readonly") === "true" || !wysiwygElement.contains(event.target)) { + wysiwygElement.dispatchEvent(new Event("focusin")); + } } + + const copyElement = hasTopClosestByClassName(event.target, "protyle-action__copy"); + if (copyElement) { + let text = copyElement.parentElement.nextElementSibling.textContent.replace(/\n$/, ""); + text = text.replace(/\u00A0/g, " "); // Replace non-breaking spaces with normal spaces when copying https://github.com/siyuan-note/siyuan/issues/9382 + writeText(text); + showMessage(window.siyuan.languages.copied, 2000); + event.preventDefault(); + return; + } + + /// #if !MOBILE // dock float 时,点击空白处,隐藏 dock。场景:文档树上重命名后 if (!isWindow() && window.siyuan.layout.leftDock && !hasClosestByClassName(event.target, "b3-dialog--open", true) && @@ -38,21 +56,8 @@ export const globalClick = (event: MouseEvent & { target: HTMLElement }) => { window.siyuan.layout.rightDock.hideDock(); } - const protyleElement = hasClosestByClassName(event.target, "protyle", true); - if (protyleElement) { - const wysiwygElement = protyleElement.querySelector(".protyle-wysiwyg"); - if (wysiwygElement.getAttribute("data-readonly") === "true" || !wysiwygElement.contains(event.target)) { - wysiwygElement.dispatchEvent(new Event("focusin")); - } - } - const copyElement = hasTopClosestByClassName(event.target, "protyle-action__copy"); - if (copyElement) { - let text = copyElement.parentElement.nextElementSibling.textContent.replace(/\n$/, ""); - text = text.replace(/\u00A0/g, " "); // Replace non-breaking spaces with normal spaces when copying https://github.com/siyuan-note/siyuan/issues/9382 - writeText(text); - showMessage(window.siyuan.languages.copied, 2000); - event.preventDefault(); - return; + if (!hasClosestByClassName(event.target, "pdf__outer")) { + hideAllElements(["pdfutil"]); } // 点击空白,pdf 搜索、更多消失 @@ -81,4 +86,5 @@ export const globalClick = (event: MouseEvent & { target: HTMLElement }) => { ) { currentPDFViewerObject.findBar.close(); } + /// #endif }; diff --git a/app/src/config/image.ts b/app/src/config/image.ts index 164521e90..46a861af8 100644 --- a/app/src/config/image.ts +++ b/app/src/config/image.ts @@ -1,10 +1,12 @@ import {escapeHtml} from "../util/escape"; import {confirmDialog} from "../dialog/confirmDialog"; import {pathPosix} from "../util/pathName"; -import {isBrowser} from "../util/functions"; +import {isBrowser, isMobile} from "../util/functions"; import {hasClosestByClassName} from "../protyle/util/hasClosest"; import {fetchPost} from "../util/fetch"; +/// #if !MOBILE import {getAllModels} from "../layout/getAll"; +/// #endif import {openBy} from "../editor/util"; import {renderAssetsPreview} from "../asset/renderAssets"; import {writeText} from "../protyle/util/compatibility"; @@ -12,6 +14,7 @@ import {writeText} from "../protyle/util/compatibility"; export const image = { element: undefined as Element, genHTML: () => { + const isM = isMobile(); return `
@@ -26,7 +29,7 @@ export const image = {
-
+
@@ -41,7 +44,7 @@ export const image = {
-
+
  • @@ -60,11 +63,13 @@ export const image = { if (target.id === "removeAll") { confirmDialog(window.siyuan.languages.deleteOpConfirm, `${window.siyuan.languages.clearAll}`, () => { fetchPost("/api/asset/removeUnusedAssets", {}, response => { + /// #if !MOBILE getAllModels().asset.forEach(item => { if (response.data.paths.includes(item.path)) { item.parent.close(); } }); + /// #endif assetsListElement.innerHTML = `
  • ${window.siyuan.languages.emptyContent}
  • `; image.element.querySelector(".config-assets__preview").innerHTML = ""; }); @@ -100,11 +105,13 @@ export const image = { fetchPost("/api/asset/removeUnusedAsset", { path: pathString, }, response => { + /// #if !MOBILE getAllModels().asset.forEach(item => { if (response.data.path === item.path) { item.parent.parent.removeTab(item.parent.id); } }); + /// #endif const liElement = target.parentElement; if (liElement.parentElement.querySelectorAll("li").length === 1) { liElement.parentElement.innerHTML = `
  • ${window.siyuan.languages.emptyContent}
  • `; @@ -148,10 +155,11 @@ export const image = { `; } + const isM = isMobile() data.forEach((item) => { const idx = item.indexOf("assets/"); const dataPath = item.substr(idx); - html += `
  • + html += `
  • ${escapeHtml(item)} diff --git a/app/src/layout/getAll.ts b/app/src/layout/getAll.ts index 04dcdcf6c..d104e9b92 100644 --- a/app/src/layout/getAll.ts +++ b/app/src/layout/getAll.ts @@ -59,8 +59,8 @@ export const getAllEditor = () => { return editors; }; +/// #if !MOBILE export const getAllModels = () => { - /// #if !MOBILE const models: IModels = { editor: [], graph: [], @@ -110,7 +110,6 @@ export const getAllModels = () => { getTabs(window.siyuan.layout.layout); } return models; - /// #endif }; export const getAllWnds = (layout: Layout, wnds: Wnd[]) => { @@ -162,3 +161,4 @@ export const getAllDocks = () => { }); return docks; }; +/// #endif diff --git a/app/src/layout/index.ts b/app/src/layout/index.ts index 91e3050dc..50b214d6d 100644 --- a/app/src/layout/index.ts +++ b/app/src/layout/index.ts @@ -6,7 +6,6 @@ import {recordBeforeResizeTop} from "../protyle/util/resize"; /// #if MOBILE // 检测移动端是否引入了桌面端的代码 console.error("Need remove unused code"); - /// #endif export class Layout { diff --git a/app/src/plugin/API.ts b/app/src/plugin/API.ts index eba1bbd25..98d0d6696 100644 --- a/app/src/plugin/API.ts +++ b/app/src/plugin/API.ts @@ -20,7 +20,10 @@ import {openMobileFileById} from "../mobile/editor"; import {lockScreen, exitSiYuan} from "../dialog/processSystem"; import {Model} from "../layout/Model"; import {getDockByType} from "../layout/tabUtil"; -import {getAllEditor, getAllModels} from "../layout/getAll"; +/// #if !MOBILE +import {getAllModels} from "../layout/getAll"; +/// #endif +import {getAllEditor} from "../layout/getAll"; import {openSetting} from "../config"; import {openAttr, openFileAttr} from "../menus/commonMenuItem"; @@ -213,7 +216,9 @@ export const API = { Menu, Setting, getAllEditor, + /// #if !MOBILE getAllModels, + /// #endif platformUtils, openSetting, openAttributePanel, diff --git a/app/src/protyle/index.ts b/app/src/protyle/index.ts index dc863860e..b8351d775 100644 --- a/app/src/protyle/index.ts +++ b/app/src/protyle/index.ts @@ -17,7 +17,8 @@ import {Breadcrumb} from "./breadcrumb"; import { onTransaction, transaction, - turnsIntoOneTransaction, turnsIntoTransaction, + turnsIntoOneTransaction, + turnsIntoTransaction, updateBatchTransaction, updateTransaction } from "./wysiwyg/transaction"; @@ -41,7 +42,9 @@ import {focusBlock, getEditorRange} from "./util/selection"; import {hasClosestBlock} from "./util/hasClosest"; import {setStorageVal} from "./util/compatibility"; import {merge} from "./util/merge"; +/// #if !MOBILE import {getAllModels} from "../layout/getAll"; +/// #endif import {isSupportCSSHL} from "./render/searchMarkRender"; import {renderAVAttribute} from "./render/av/blockAttr"; @@ -128,6 +131,7 @@ export class Protyle { case "reload": if (data.data === this.protyle.block.rootID) { reloadProtyle(this.protyle, false); + /// #if !MOBILE getAllModels().outline.forEach(item => { if (item.blockId === data.data) { fetchPost("/api/outline/getDocOutline", { @@ -138,6 +142,7 @@ export class Protyle { }); } }); + /// #endif } break; case "refreshAttributeView": @@ -159,12 +164,14 @@ export class Protyle { this.protyle.preview.render(this.protyle); } else if (options.backlinkData && ["delete", "move"].includes(item.action)) { // 只对特定情况刷新,否则展开、编辑等操作刷新会频繁 + /// #if !MOBILE getAllModels().backlink.find(backlinkItem => { if (backlinkItem.element.contains(this.protyle.element)) { backlinkItem.refresh(); return true; } }); + /// #endif return true; } else { onTransaction(this.protyle, item, false); diff --git a/app/src/protyle/util/resize.ts b/app/src/protyle/util/resize.ts index 771469c26..c2c1c8875 100644 --- a/app/src/protyle/util/resize.ts +++ b/app/src/protyle/util/resize.ts @@ -3,10 +3,13 @@ import {setPadding} from "../ui/initUI"; import {hasClosestBlock} from "./hasClosest"; import {Constants} from "../../constants"; import {lineNumberRender} from "../render/highlightRender"; -import {stickyRow} from "../render/av/row"; +/// #if !MOBILE import {getAllModels} from "../../layout/getAll"; +/// #endif +import {stickyRow} from "../render/av/row"; export const recordBeforeResizeTop = () => { + /// #if !MOBILE getAllModels().editor.forEach((item) => { if (item.editor && item.editor.protyle && item.element.parentElement && !item.element.classList.contains("fn__none")) { @@ -26,6 +29,7 @@ export const recordBeforeResizeTop = () => { topElement.setAttribute("data-resize-top", topElement.getBoundingClientRect().top.toString()); } }); + /// #endif }; export const resize = (protyle: IProtyle) => {