diff --git a/app/src/block/Panel.ts b/app/src/block/Panel.ts
index 43a1d0dc1..0f49a15c2 100644
--- a/app/src/block/Panel.ts
+++ b/app/src/block/Panel.ts
@@ -5,6 +5,9 @@ import {setPadding} from "../protyle/ui/initUI";
import {setPosition} from "../util/setPosition";
import {hideElements} from "../protyle/ui/hideElements";
import {Constants} from "../constants";
+/// #if !BROWSER
+import {openNewWindowById} from "../window/openNewWindow";
+/// #endif
import {disabledProtyle} from "../protyle/util/onGet";
export class BlockPanel {
@@ -221,6 +224,10 @@ export class BlockPanel {
target.setAttribute("aria-label", window.siyuan.languages.unpin);
this.element.setAttribute("data-pin", "true");
}
+ } else if (type === "open") {
+ /// #if !BROWSER
+ openNewWindowById(this.nodeIds[0])
+ /// #endif
}
event.preventDefault();
event.stopPropagation();
@@ -256,6 +263,12 @@ export class BlockPanel {
editorElement.addEventListener("mouseleave", () => {
hideElements(["gutter"], editor.protyle);
});
+ // 浮窗完整文档面包屑应不显示 退出聚焦
+ if (editor.protyle.breadcrumb && editor.protyle.block.id === editor.protyle.block.rootID) {
+ const exitFocusElement = editor.protyle.breadcrumb.element.parentElement.querySelector('[data-type="exit-focus"]')
+ exitFocusElement.classList.add("fn__none")
+ exitFocusElement.nextElementSibling.classList.add("fn__none")
+ }
}
});
this.editors.push(editor);
@@ -286,8 +299,15 @@ export class BlockPanel {
this.destroy();
return;
}
+ let openHTML = ""
+ /// #if !BROWSER
+ if (this.nodeIds.length === 1) {
+ openHTML = `
+`
+ }
+ /// #endif
let html = `
-
+ ${openHTML}
diff --git a/app/src/menus/protyle.ts b/app/src/menus/protyle.ts
index 6bf314049..32966241d 100644
--- a/app/src/menus/protyle.ts
+++ b/app/src/menus/protyle.ts
@@ -27,6 +27,7 @@ import {pasteAsPlainText, pasteText} from "../protyle/util/paste";
/// #if !MOBILE
import {openFileById, updateBacklinkGraph} from "../editor/util";
import {openGlobalSearch} from "../search/util";
+import {openNewWindowById} from "../window/openNewWindow";
/// #endif
import {getSearch, isMobile} from "../util/functions";
import {removeFoldHeading} from "../protyle/util/heading";
@@ -149,6 +150,14 @@ export const refMenu = (protyle: IProtyle, element: HTMLElement) => {
});
}
}).element);
+ /// #if !BROWSER
+ window.siyuan.menus.menu.append(new MenuItem({
+ label: window.siyuan.languages.openByNewWindow,
+ icon: "iconMove",
+ click() {
+ openNewWindowById(refBlockId)
+ }
+ }).element);
/// #endif
/// #endif
let submenu: IMenu[] = [];
diff --git a/app/src/window/openNewWindow.ts b/app/src/window/openNewWindow.ts
index fd09411ed..1782f8442 100644
--- a/app/src/window/openNewWindow.ts
+++ b/app/src/window/openNewWindow.ts
@@ -1,9 +1,10 @@
import {layoutToJSON} from "../layout/util";
/// #if !BROWSER
-import { ipcRenderer } from "electron";
+import {ipcRenderer} from "electron";
/// #endif
import {Constants} from "../constants";
import {Tab} from "../layout/Tab";
+import {fetchPost} from "../util/fetch";
export const openNewWindow = (tab: Tab) => {
const json = {};
@@ -13,3 +14,45 @@ export const openNewWindow = (tab: Tab) => {
/// #endif
tab.parent.removeTab(tab.id);
};
+
+export const openNewWindowById = (id: string) => {
+ fetchPost("api/block/getBlockInfo", {id}, (response) => {
+ const json: any = {
+ title: response.data.rootTitle,
+ docIcon: response.data.rootIcon,
+ pin: false,
+ active: true,
+ instance: "Tab",
+ action: "Tab",
+ children: {
+ notebookId: response.data.box,
+ blockId: id,
+ rootId: response.data.rootID,
+ mode: "wysiwyg",
+ instance: "Editor",
+ }
+ }
+ if (response.data.rootID === id) {
+ fetchPost("/api/attr/getBlockAttrs", {id}, (attrResponse) => {
+ json.children.scrollAttr = JSON.parse(attrResponse.data.scroll || "{}");
+ /// #if !BROWSER
+ ipcRenderer.send(Constants.SIYUAN_OPENWINDOW, `${window.location.protocol}//${window.location.host}/stage/build/app/window.html?v=${Constants.SIYUAN_VERSION}&json=${JSON.stringify(json)}`);
+ /// #endif
+ });
+ } else {
+ json.children.action = Constants.CB_GET_ALL;
+ json.children.scrollAttr = {
+ startId: id,
+ endId: id,
+ scrollTop: 0,
+ focusId: id,
+ focusStart: 0,
+ focusEnd: 0
+ }
+ /// #if !BROWSER
+ ipcRenderer.send(Constants.SIYUAN_OPENWINDOW, `${window.location.protocol}//${window.location.host}/stage/build/app/window.html?v=${Constants.SIYUAN_VERSION}&json=${JSON.stringify(json)}`);
+ /// #endif
+ }
+ });
+
+};