mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-03-10 22:52:34 +01:00
This commit is contained in:
parent
0cd68fe571
commit
e94a534b02
9 changed files with 111 additions and 114 deletions
|
|
@ -1,42 +1,9 @@
|
|||
import {Wnd} from "../layout/Wnd";
|
||||
import {getInstanceById, getWndByLayout} from "../layout/util";
|
||||
import {Tab} from "../layout/Tab";
|
||||
import {Custom} from "../layout/dock/Custom";
|
||||
import {bindCardEvent, genCardHTML} from "./openCard";
|
||||
import {fetchPost} from "../util/fetch";
|
||||
import {Protyle} from "../protyle";
|
||||
|
||||
export const newCardTab = (options: {
|
||||
cardType: TCardType,
|
||||
id: string,
|
||||
title?: string
|
||||
}) => {
|
||||
let wnd: Wnd;
|
||||
const element = document.querySelector(".layout__wnd--active");
|
||||
if (element) {
|
||||
wnd = getInstanceById(element.getAttribute("data-id")) as Wnd;
|
||||
}
|
||||
if (!wnd) {
|
||||
wnd = getWndByLayout(window.siyuan.layout.centerLayout);
|
||||
}
|
||||
|
||||
const tab = new Tab({
|
||||
icon: "iconRiffCard",
|
||||
title: window.siyuan.languages.spaceRepetition,
|
||||
callback(tab) {
|
||||
tab.addModel(newCardModel({
|
||||
tab,
|
||||
data: {
|
||||
cardType: options.cardType,
|
||||
id: options.id,
|
||||
title: options.title
|
||||
}
|
||||
}));
|
||||
}
|
||||
});
|
||||
wnd.split("lr").addTab(tab);
|
||||
}
|
||||
|
||||
export const newCardModel = (options: {
|
||||
tab: Tab,
|
||||
data: {
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ import {fullscreen} from "../protyle/breadcrumb/action";
|
|||
import {MenuItem} from "../menus/Menu";
|
||||
import {escapeHtml} from "../util/escape";
|
||||
/// #if !MOBILE
|
||||
import {newCardTab} from "./newCardTab";
|
||||
import {openFile} from "../editor/util";
|
||||
/// #endif
|
||||
import {getDisplayName, movePathTo} from "../util/pathName";
|
||||
|
||||
|
|
@ -203,10 +203,13 @@ export const bindCardEvent = (options: {
|
|||
/// #if !MOBILE
|
||||
const sticktabElement = hasClosestByAttribute(target, "data-type", "sticktab");
|
||||
if (sticktabElement) {
|
||||
newCardTab({
|
||||
cardType: filterElement.getAttribute("data-cardtype") as TCardType,
|
||||
id: filterElement.getAttribute("data-id"),
|
||||
title: options.title
|
||||
openFile({
|
||||
position: "right",
|
||||
customData:{
|
||||
cardType: filterElement.getAttribute("data-cardtype") as TCardType,
|
||||
id: filterElement.getAttribute("data-id"),
|
||||
title: options.title
|
||||
}
|
||||
});
|
||||
if (options.dialog) {
|
||||
options.dialog.destroy();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue