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 事件
|
||||
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_TABTOWINDOW: string = "application/siyuan-tabtowindow";
|
||||
public static readonly SIYUAN_DROP_EDITOR: string = "application/siyuan-editor";
|
||||
|
||||
// 渲染进程调主进程
|
||||
|
|
|
@ -9,6 +9,7 @@ import {unicode2Emoji} from "../emoji";
|
|||
import {fetchPost} from "../util/fetch";
|
||||
import {showTooltip} from "../dialog/tooltip";
|
||||
import {isTouchDevice} from "../util/functions";
|
||||
import {layoutToJSON} from "./util";
|
||||
|
||||
export class Tab {
|
||||
public parent: Wnd;
|
||||
|
@ -76,6 +77,9 @@ export class Tab {
|
|||
if (tabElement) {
|
||||
event.dataTransfer.setData("text/html", tabElement.outerHTML);
|
||||
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";
|
||||
tabElement.style.opacity = "0.1";
|
||||
window.siyuan.dragElement = this.headElement;
|
||||
|
|
|
@ -2,7 +2,7 @@ import {Layout} from "./index";
|
|||
import {genUUID} from "../util/genID";
|
||||
import {
|
||||
getInstanceById,
|
||||
getWndByLayout,
|
||||
getWndByLayout, JSONToCenter,
|
||||
newCenterEmptyTab,
|
||||
resizeTabs,
|
||||
setPanelFocus,
|
||||
|
@ -297,7 +297,11 @@ export class Wnd {
|
|||
const targetWndElement = event.target.parentElement.parentElement;
|
||||
const targetWnd = getInstanceById(targetWndElement.getAttribute("data-id")) as Wnd;
|
||||
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) {
|
||||
// https://github.com/siyuan-note/siyuan/issues/6890
|
||||
const pdfViewerElement = oldTab.model.element.querySelector("#viewerContainer");
|
||||
|
@ -636,6 +640,9 @@ export class Wnd {
|
|||
}
|
||||
});
|
||||
}
|
||||
/// #if !BROWSER
|
||||
setTabPosition();
|
||||
/// #endif
|
||||
return;
|
||||
}
|
||||
if (item.headElement) {
|
||||
|
|
Loading…
Add table
Reference in a new issue