mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-20 08:30:12 +01:00
This commit is contained in:
parent
a58642b0da
commit
c3f651b6c9
3 changed files with 14 additions and 2 deletions
|
|
@ -17,6 +17,7 @@ export abstract class Constants {
|
||||||
// drop 事件
|
// drop 事件
|
||||||
public static readonly SIYUAN_DROP_FILE: string = "application/siyuan-file";
|
public static readonly SIYUAN_DROP_FILE: string = "application/siyuan-file";
|
||||||
public static readonly SIYUAN_DROP_TAB: string = "application/siyuan-tab";
|
public static readonly SIYUAN_DROP_TAB: string = "application/siyuan-tab";
|
||||||
|
public static readonly SIYUAN_DROP_TABTOWINDOW: string = "application/siyuan-tabtowindow";
|
||||||
public static readonly SIYUAN_DROP_EDITOR: string = "application/siyuan-editor";
|
public static readonly SIYUAN_DROP_EDITOR: string = "application/siyuan-editor";
|
||||||
|
|
||||||
// 渲染进程调主进程
|
// 渲染进程调主进程
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ import {unicode2Emoji} from "../emoji";
|
||||||
import {fetchPost} from "../util/fetch";
|
import {fetchPost} from "../util/fetch";
|
||||||
import {showTooltip} from "../dialog/tooltip";
|
import {showTooltip} from "../dialog/tooltip";
|
||||||
import {isTouchDevice} from "../util/functions";
|
import {isTouchDevice} from "../util/functions";
|
||||||
|
import {layoutToJSON} from "./util";
|
||||||
|
|
||||||
export class Tab {
|
export class Tab {
|
||||||
public parent: Wnd;
|
public parent: Wnd;
|
||||||
|
|
@ -76,6 +77,9 @@ export class Tab {
|
||||||
if (tabElement) {
|
if (tabElement) {
|
||||||
event.dataTransfer.setData("text/html", tabElement.outerHTML);
|
event.dataTransfer.setData("text/html", tabElement.outerHTML);
|
||||||
event.dataTransfer.setData(Constants.SIYUAN_DROP_TAB, this.id);
|
event.dataTransfer.setData(Constants.SIYUAN_DROP_TAB, this.id);
|
||||||
|
const modeJSON = {}
|
||||||
|
layoutToJSON(this, modeJSON)
|
||||||
|
event.dataTransfer.setData(Constants.SIYUAN_DROP_TABTOWINDOW, JSON.stringify(modeJSON));
|
||||||
event.dataTransfer.dropEffect = "move";
|
event.dataTransfer.dropEffect = "move";
|
||||||
tabElement.style.opacity = "0.1";
|
tabElement.style.opacity = "0.1";
|
||||||
window.siyuan.dragElement = this.headElement;
|
window.siyuan.dragElement = this.headElement;
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ import {Layout} from "./index";
|
||||||
import {genUUID} from "../util/genID";
|
import {genUUID} from "../util/genID";
|
||||||
import {
|
import {
|
||||||
getInstanceById,
|
getInstanceById,
|
||||||
getWndByLayout,
|
getWndByLayout, JSONToCenter,
|
||||||
newCenterEmptyTab,
|
newCenterEmptyTab,
|
||||||
resizeTabs,
|
resizeTabs,
|
||||||
setPanelFocus,
|
setPanelFocus,
|
||||||
|
|
@ -297,7 +297,11 @@ export class Wnd {
|
||||||
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 tabId = event.dataTransfer.getData(Constants.SIYUAN_DROP_TAB);
|
const tabId = event.dataTransfer.getData(Constants.SIYUAN_DROP_TAB);
|
||||||
const oldTab = getInstanceById(tabId) as Tab;
|
let oldTab = getInstanceById(tabId) as Tab;
|
||||||
|
if (isWindow() && !oldTab) { // 从主窗口拖拽到页签新窗口
|
||||||
|
JSONToCenter(JSON.parse(event.dataTransfer.getData(Constants.SIYUAN_DROP_TABTOWINDOW)), this);
|
||||||
|
oldTab = this.children[this.children.length - 1];
|
||||||
|
}
|
||||||
if (oldTab.model instanceof Asset) {
|
if (oldTab.model instanceof Asset) {
|
||||||
// https://github.com/siyuan-note/siyuan/issues/6890
|
// https://github.com/siyuan-note/siyuan/issues/6890
|
||||||
const pdfViewerElement = oldTab.model.element.querySelector("#viewerContainer");
|
const pdfViewerElement = oldTab.model.element.querySelector("#viewerContainer");
|
||||||
|
|
@ -636,6 +640,9 @@ export class Wnd {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
/// #if !BROWSER
|
||||||
|
setTabPosition();
|
||||||
|
/// #endif
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (item.headElement) {
|
if (item.headElement) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue