mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-06 08:48:49 +01:00
This commit is contained in:
parent
a01ac85bdb
commit
d0700b7527
9 changed files with 80 additions and 27 deletions
|
|
@ -208,6 +208,7 @@
|
|||
justify-content: center;
|
||||
overflow: auto;
|
||||
flex: 1;
|
||||
padding: 0 8px;
|
||||
margin-top: 8px;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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 `<div class="fn__flex-column" style="height: 100%">
|
||||
<div class="layout-tab-bar fn__flex">
|
||||
<div class="item item--full item--focus" data-type="remove">
|
||||
|
|
@ -26,7 +29,7 @@ export const image = {
|
|||
</div>
|
||||
</div>
|
||||
<div class="fn__flex-1">
|
||||
<div class="config-assets" data-type="remove" data-init="true">
|
||||
<div class="config-assets${isM ? " b3-list--mobile" : ""}" data-type="remove" data-init="true">
|
||||
<div class="fn__hr--b"></div>
|
||||
<div class="fn__flex">
|
||||
<div class="fn__space"></div>
|
||||
|
|
@ -41,7 +44,7 @@ export const image = {
|
|||
</ul>
|
||||
<div class="config-assets__preview"></div>
|
||||
</div>
|
||||
<div class="fn__none config-assets" data-type="missing">
|
||||
<div class="fn__none config-assets${isM ? " b3-list--mobile" : ""}" data-type="missing">
|
||||
<div class="fn__hr"></div>
|
||||
<ul class="b3-list b3-list--background config-assets__list">
|
||||
<li class="fn__loading"><img src="/stage/loading-pure.svg"></li>
|
||||
|
|
@ -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 = `<li class="b3-list--empty">${window.siyuan.languages.emptyContent}</li>`;
|
||||
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 = `<li class="b3-list--empty">${window.siyuan.languages.emptyContent}</li>`;
|
||||
|
|
@ -148,10 +155,11 @@ export const image = {
|
|||
<svg><use xlink:href="#iconTrashcan"></use></svg>
|
||||
</span>`;
|
||||
}
|
||||
const isM = isMobile()
|
||||
data.forEach((item) => {
|
||||
const idx = item.indexOf("assets/");
|
||||
const dataPath = item.substr(idx);
|
||||
html += `<li data-path="${dataPath}" class="b3-list-item b3-list-item--hide-action">
|
||||
html += `<li data-path="${dataPath}" class="b3-list-item${isM ? "" : " b3-list-item--hide-action"}">
|
||||
<span class="b3-list-item__text">${escapeHtml(item)}</span>
|
||||
<span data-type="copy" class="ariaLabel b3-list-item__action" aria-label="${window.siyuan.languages.copy}">
|
||||
<svg><use xlink:href="#iconCopy"></use></svg>
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ import {recordBeforeResizeTop} from "../protyle/util/resize";
|
|||
/// #if MOBILE
|
||||
// 检测移动端是否引入了桌面端的代码
|
||||
console.error("Need remove unused code");
|
||||
|
||||
/// #endif
|
||||
|
||||
export class Layout {
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue