This commit is contained in:
Vanessa 2023-02-17 15:46:46 +08:00
parent 89c93f8ce8
commit 2474db3ab8
16 changed files with 38 additions and 40 deletions

View file

@ -214,7 +214,7 @@ export class Wnd {
it.classList.remove("layout-tab-bars--drag"); it.classList.remove("layout-tab-bars--drag");
return; return;
} }
const tabData = JSON.parse(event.dataTransfer.getData(Constants.SIYUAN_DROP_TAB)) const tabData = JSON.parse(event.dataTransfer.getData(Constants.SIYUAN_DROP_TAB));
let oldTab = getInstanceById(tabData.id) as Tab; let oldTab = getInstanceById(tabData.id) as Tab;
const wnd = getInstanceById(it.parentElement.getAttribute("data-id")) as Wnd; const wnd = getInstanceById(it.parentElement.getAttribute("data-id")) as Wnd;
/// #if !BROWSER /// #if !BROWSER
@ -324,7 +324,7 @@ export class Wnd {
dragElement.classList.add("fn__none"); dragElement.classList.add("fn__none");
const targetWndElement = event.target.parentElement.parentElement; const targetWndElement = event.target.parentElement.parentElement;
const targetWnd = getInstanceById(targetWndElement.getAttribute("data-id")) as Wnd; const targetWnd = getInstanceById(targetWndElement.getAttribute("data-id")) as Wnd;
const tabData = JSON.parse(event.dataTransfer.getData(Constants.SIYUAN_DROP_TAB)) const tabData = JSON.parse(event.dataTransfer.getData(Constants.SIYUAN_DROP_TAB));
let oldTab = getInstanceById(tabData.id) as Tab; let oldTab = getInstanceById(tabData.id) as Tab;
/// #if !BROWSER /// #if !BROWSER
if (!oldTab) { // 从主窗口拖拽到页签新窗口 if (!oldTab) { // 从主窗口拖拽到页签新窗口

View file

@ -28,22 +28,22 @@ export class Dock {
case "Left": case "Left":
this.layout = window.siyuan.layout.layout.children[1].children[0] as Layout; this.layout = window.siyuan.layout.layout.children[1].children[0] as Layout;
this.resizeElement = this.layout.element.nextElementSibling as HTMLElement; this.resizeElement = this.layout.element.nextElementSibling as HTMLElement;
this.layout.element.classList.add("layout--floatl") this.layout.element.classList.add("layout--floatl");
break; break;
case "Right": case "Right":
this.layout = window.siyuan.layout.layout.children[1].children[2] as Layout; this.layout = window.siyuan.layout.layout.children[1].children[2] as Layout;
this.resizeElement = this.layout.element.previousElementSibling as HTMLElement; this.resizeElement = this.layout.element.previousElementSibling as HTMLElement;
this.layout.element.classList.add("layout--floatr") this.layout.element.classList.add("layout--floatr");
break; break;
case "Top": case "Top":
this.layout = window.siyuan.layout.layout.children[0] as Layout; this.layout = window.siyuan.layout.layout.children[0] as Layout;
this.resizeElement = this.layout.element.nextElementSibling as HTMLElement; this.resizeElement = this.layout.element.nextElementSibling as HTMLElement;
this.layout.element.classList.add("layout--floatt") this.layout.element.classList.add("layout--floatt");
break; break;
case "Bottom": case "Bottom":
this.layout = window.siyuan.layout.layout.children[2] as Layout; this.layout = window.siyuan.layout.layout.children[2] as Layout;
this.resizeElement = this.layout.element.previousElementSibling as HTMLElement; this.resizeElement = this.layout.element.previousElementSibling as HTMLElement;
this.layout.element.classList.add("layout--floatb") this.layout.element.classList.add("layout--floatb");
break; break;
} }
this.element = document.getElementById("dock" + options.position); this.element = document.getElementById("dock" + options.position);
@ -112,7 +112,7 @@ export class Dock {
} }
if (!this.pin) { if (!this.pin) {
setTimeout(() => { setTimeout(() => {
this.resetDockPosition(false) this.resetDockPosition(false);
this.hideDock(true); this.hideDock(true);
this.layout.element.classList.add("layout--float"); this.layout.element.classList.add("layout--float");
this.resizeElement.classList.add("fn__none"); this.resizeElement.classList.add("fn__none");
@ -502,7 +502,7 @@ ${this.position === "Top" ? "top" : "bottom"}:0`);
} }
private genButton(data: IDockTab[], index: number) { private genButton(data: IDockTab[], index: number) {
let html = "" let html = "";
data.forEach(item => { data.forEach(item => {
html += `<span data-height="${item.size.height}" data-width="${item.size.width}" data-type="${item.type}" data-index="${index}" data-hotkeylangid="${item.hotkeyLangId}" class="dock__item${item.show ? " dock__item--active" : ""} b3-tooltips b3-tooltips__${this.getClassDirect(index)}" aria-label="${window.siyuan.languages[item.hotkeyLangId] + " " + updateHotkeyTip(window.siyuan.config.keymap.general[item.hotkeyLangId].custom)}${window.siyuan.languages.dockTip}"> html += `<span data-height="${item.size.height}" data-width="${item.size.width}" data-type="${item.type}" data-index="${index}" data-hotkeylangid="${item.hotkeyLangId}" class="dock__item${item.show ? " dock__item--active" : ""} b3-tooltips b3-tooltips__${this.getClassDirect(index)}" aria-label="${window.siyuan.languages[item.hotkeyLangId] + " " + updateHotkeyTip(window.siyuan.config.keymap.general[item.hotkeyLangId].custom)}${window.siyuan.languages.dockTip}">
<svg><use xlink:href="#${item.icon}"></use></svg> <svg><use xlink:href="#${item.icon}"></use></svg>

View file

@ -94,9 +94,9 @@ export const resetFloatDockSize = () => {
window.siyuan.layout.rightDock.showDock(true); window.siyuan.layout.rightDock.showDock(true);
} }
if (!window.siyuan.layout.topDock.pin && window.siyuan.layout.topDock.layout.element.style.opacity === "1") { if (!window.siyuan.layout.topDock.pin && window.siyuan.layout.topDock.layout.element.style.opacity === "1") {
window.siyuan.layout.topDock.showDock(true) window.siyuan.layout.topDock.showDock(true);
} }
if (!window.siyuan.layout.bottomDock.pin && window.siyuan.layout.bottomDock.layout.element.style.opacity === "1") { if (!window.siyuan.layout.bottomDock.pin && window.siyuan.layout.bottomDock.layout.element.style.opacity === "1") {
window.siyuan.layout.bottomDock.showDock(true) window.siyuan.layout.bottomDock.showDock(true);
} }
}; };

View file

@ -1,6 +1,4 @@
/// #if !MOBILE /// #if !MOBILE
import {getAllDocks} from "./getAll";
import {updateHotkeyTip} from "../protyle/util/compatibility";
import {getDockByType, resizeTabs} from "./util"; import {getDockByType, resizeTabs} from "./util";
import {hasClosestByClassName} from "../protyle/util/hasClosest"; import {hasClosestByClassName} from "../protyle/util/hasClosest";
import {fetchPost} from "../util/fetch"; import {fetchPost} from "../util/fetch";

View file

@ -599,7 +599,7 @@ export const getInstanceById = (id: string, layout = window.siyuan.layout.center
export const addResize = (obj: Layout | Wnd) => { export const addResize = (obj: Layout | Wnd) => {
if (!obj.resize) { if (!obj.resize) {
return return;
} }
const resizeWnd = (resizeElement: HTMLElement, direction: string) => { const resizeWnd = (resizeElement: HTMLElement, direction: string) => {
const setSize = (item: HTMLElement, direction: string) => { const setSize = (item: HTMLElement, direction: string) => {

View file

@ -350,7 +350,7 @@ export const initFileMenu = (notebookId: string, pathString: string, liElement:
click() { click() {
openNewWindowById(id); openNewWindowById(id);
} }
}) });
/// #endif /// #endif
openSubmenus.push({type: "separator"}); openSubmenus.push({type: "separator"});
openSubmenus.push({ openSubmenus.push({

View file

@ -44,8 +44,8 @@ const togglePinDock = (dock: Dock, icon: string) => {
dock.layout.element.classList.toggle("layout--float"); dock.layout.element.classList.toggle("layout--float");
resizeTabs(); resizeTabs();
} }
} };
} };
export const workspaceMenu = (rect: DOMRect) => { export const workspaceMenu = (rect: DOMRect) => {
if (!window.siyuan.menus.menu.element.classList.contains("fn__none") && if (!window.siyuan.menus.menu.element.classList.contains("fn__none") &&

View file

@ -645,10 +645,10 @@ const initAbout = () => {
break; break;
} else if (target.id === "openWorkspace") { } else if (target.id === "openWorkspace") {
fetchPost("/api/system/getMobileWorkspaces", {}, (response) => { fetchPost("/api/system/getMobileWorkspaces", {}, (response) => {
let selectHTML = "" let selectHTML = "";
response.data.forEach((item: string, index: number) => { response.data.forEach((item: string, index: number) => {
selectHTML += `<option value="${item}"${index === 0 ? ' selected="selected"' : ""}>${pathPosix().basename(item)}</option>` selectHTML += `<option value="${item}"${index === 0 ? ' selected="selected"' : ""}>${pathPosix().basename(item)}</option>`;
}) });
const openWorkspaceDialog = new Dialog({ const openWorkspaceDialog = new Dialog({
title: window.siyuan.languages.openBy, title: window.siyuan.languages.openBy,
content: `<div class="b3-dialog__content"> content: `<div class="b3-dialog__content">
@ -678,7 +678,7 @@ const initAbout = () => {
}); });
}); });
}); });
}) });
event.preventDefault(); event.preventDefault();
event.stopPropagation(); event.stopPropagation();
break; break;
@ -746,4 +746,4 @@ const initAbout = () => {
exitSiYuan(); exitSiYuan();
}); });
}); });
} };

View file

@ -62,14 +62,14 @@ export const fullscreen = (element: Element, btnElement?: Element) => {
} else { } else {
btnElement.querySelector("use").setAttribute("xlink:href", "#iconContract"); btnElement.querySelector("use").setAttribute("xlink:href", "#iconContract");
} }
const dockLayoutElement = hasClosestByClassName(element, "layout--float") const dockLayoutElement = hasClosestByClassName(element, "layout--float");
if (dockLayoutElement) { if (dockLayoutElement) {
if (isFullscreen) { if (isFullscreen) {
dockLayoutElement.setAttribute("data-temp", dockLayoutElement.style.transform) dockLayoutElement.setAttribute("data-temp", dockLayoutElement.style.transform);
dockLayoutElement.style.transform = "none" dockLayoutElement.style.transform = "none";
} else { } else {
dockLayoutElement.style.transform = dockLayoutElement.getAttribute("data-temp") dockLayoutElement.style.transform = dockLayoutElement.getAttribute("data-temp");
dockLayoutElement.removeAttribute("data-temp") dockLayoutElement.removeAttribute("data-temp");
} }
} }
return; return;

View file

@ -65,7 +65,7 @@ export class Gutter {
if (window.siyuan.dragElement) { if (window.siyuan.dragElement) {
this.element.querySelectorAll("button").forEach((item) => { this.element.querySelectorAll("button").forEach((item) => {
item.style.opacity = ""; item.style.opacity = "";
}) });
window.siyuan.dragElement = undefined; window.siyuan.dragElement = undefined;
} }
}); });

View file

@ -217,7 +217,7 @@ export class Protyle {
} }
}); });
} }
this.protyle.contentElement.classList.add("protyle-content--transition") this.protyle.contentElement.classList.add("protyle-content--transition");
} }
private init() { private init() {

View file

@ -737,7 +737,7 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => {
if (gutterType) { if (gutterType) {
// gutter 或反链面板拖拽 // gutter 或反链面板拖拽
const sourceElements: Element[] = []; const sourceElements: Element[] = [];
const gutterTypes = gutterType.replace(Constants.SIYUAN_DROP_GUTTER, "").split(Constants.ZWSP) const gutterTypes = gutterType.replace(Constants.SIYUAN_DROP_GUTTER, "").split(Constants.ZWSP);
const selectedIds = gutterTypes[2].split(","); const selectedIds = gutterTypes[2].split(",");
if (event.altKey) { if (event.altKey) {
focusByRange(document.caretRangeFromPoint(event.clientX, event.clientY)); focusByRange(document.caretRangeFromPoint(event.clientX, event.clientY));
@ -756,9 +756,9 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => {
insertHTML(protyle.lute.SpinBlockDOM(html), protyle, true); insertHTML(protyle.lute.SpinBlockDOM(html), protyle, true);
blockRender(protyle, protyle.wysiwyg.element); blockRender(protyle, protyle.wysiwyg.element);
} else if (targetElement) { } else if (targetElement) {
let queryClass = '' let queryClass = "";
selectedIds.forEach(item => { selectedIds.forEach(item => {
queryClass = `[data-node-id="${item}"],` queryClass = `[data-node-id="${item}"],`;
}); });
if (window.siyuan.dragElement) { if (window.siyuan.dragElement) {
window.siyuan.dragElement.querySelectorAll(queryClass.substring(0, queryClass.length - 1)).forEach(elementItem => { window.siyuan.dragElement.querySelectorAll(queryClass.substring(0, queryClass.length - 1)).forEach(elementItem => {
@ -768,7 +768,7 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => {
} }
}); });
} else { // 跨窗口拖拽 } else { // 跨窗口拖拽
const targetProtyleElement = document.createElement("template") const targetProtyleElement = document.createElement("template");
targetProtyleElement.innerHTML = event.dataTransfer.getData(gutterType); targetProtyleElement.innerHTML = event.dataTransfer.getData(gutterType);
targetProtyleElement.content.querySelectorAll(queryClass.substring(0, queryClass.length - 1)).forEach(elementItem => { targetProtyleElement.content.querySelectorAll(queryClass.substring(0, queryClass.length - 1)).forEach(elementItem => {
if (elementItem.getAttribute("data-type") === "NodeBlockQueryEmbed" || if (elementItem.getAttribute("data-type") === "NodeBlockQueryEmbed" ||
@ -932,7 +932,7 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => {
disabledPosition = ""; disabledPosition = "";
// gutter 文档内拖拽限制 // gutter 文档内拖拽限制
// 排除自己及子孙 // 排除自己及子孙
const gutterTypes = gutterType.replace(Constants.SIYUAN_DROP_GUTTER, "").split(Constants.ZWSP) const gutterTypes = gutterType.replace(Constants.SIYUAN_DROP_GUTTER, "").split(Constants.ZWSP);
const isSelf = gutterTypes[2].split(",").find((item: string) => { const isSelf = gutterTypes[2].split(",").find((item: string) => {
if (item && hasClosestByAttribute(targetElement, "data-node-id", item)) { if (item && hasClosestByAttribute(targetElement, "data-node-id", item)) {
return true; return true;

View file

@ -220,7 +220,7 @@ export const paste = async (protyle: IProtyle, event: (ClipboardEvent | DragEven
insertHTML(code, protyle, true); insertHTML(code, protyle, true);
highlightRender(protyle.wysiwyg.element); highlightRender(protyle.wysiwyg.element);
} }
hideElements(["hint"], protyle) hideElements(["hint"], protyle);
} else { } else {
let isHTML = false; let isHTML = false;
if (textHTML.replace("<!--StartFragment--><!--EndFragment-->", "").trim() !== "") { if (textHTML.replace("<!--StartFragment--><!--EndFragment-->", "").trim() !== "") {

View file

@ -184,7 +184,7 @@ const syncNow = () => {
fetchPost("/api/sync/performSync", {upload: uploadElement.value === "true"}); fetchPost("/api/sync/performSync", {upload: uploadElement.value === "true"});
manualDialog.destroy(); manualDialog.destroy();
}); });
} };
const setSync = (key?: string, dialog?: Dialog) => { const setSync = (key?: string, dialog?: Dialog) => {
if (key) { if (key) {

View file

@ -469,15 +469,15 @@ export const initWindow = () => {
<use xlink:href="#iconPin"></use> <use xlink:href="#iconPin"></use>
</svg> </svg>
</div></div>`); </div></div>`);
const pinElement = document.getElementById("pinWindow") const pinElement = document.getElementById("pinWindow");
pinElement.addEventListener("click", () => { pinElement.addEventListener("click", () => {
pinElement.classList.toggle("toolbar__item--active") pinElement.classList.toggle("toolbar__item--active");
if (pinElement.classList.contains("toolbar__item--active")) { if (pinElement.classList.contains("toolbar__item--active")) {
pinElement.setAttribute("aria-label", window.siyuan.languages.unpin); pinElement.setAttribute("aria-label", window.siyuan.languages.unpin);
currentWindow.setAlwaysOnTop(true, "pop-up-menu") currentWindow.setAlwaysOnTop(true, "pop-up-menu");
} else { } else {
pinElement.setAttribute("aria-label", window.siyuan.languages.pin); pinElement.setAttribute("aria-label", window.siyuan.languages.pin);
currentWindow.setAlwaysOnTop(false) currentWindow.setAlwaysOnTop(false);
} }
}); });
} }

View file

@ -31,7 +31,7 @@ export const setTabPosition = () => {
// @ts-ignore // @ts-ignore
dragElement.style.WebkitAppRegion = ""; dragElement.style.WebkitAppRegion = "";
} }
const headersLastElement = headerElement.lastElementChild as HTMLElement const headersLastElement = headerElement.lastElementChild as HTMLElement;
if ("darwin" === window.siyuan.config.system.os) { if ("darwin" === window.siyuan.config.system.os) {
if (rect.top <= 0 && rect.left <= 0 && !getCurrentWindow().isFullScreen()) { if (rect.top <= 0 && rect.left <= 0 && !getCurrentWindow().isFullScreen()) {
item.headersElement.style.paddingLeft = "69px"; item.headersElement.style.paddingLeft = "69px";