diff --git a/app/src/assets/scss/base.scss b/app/src/assets/scss/base.scss index 2f3b26277..629885ef0 100644 --- a/app/src/assets/scss/base.scss +++ b/app/src/assets/scss/base.scss @@ -93,12 +93,14 @@ html { border-radius: 0; & > .protyle-breadcrumb, - & > .block__icons { // 关系图 + & > .block__icons { // 关系图、card padding-left: var(--b3-toolbar-left-mac); height: 32px; + min-height: 32px; } - .protyle-breadcrumb > .protyle-breadcrumb__space { + .protyle-breadcrumb > .protyle-breadcrumb__space, + & > .block__icons > .fn__flex-1{ -webkit-app-region: drag; min-width: 32px; diff --git a/app/src/assets/scss/business/_card.scss b/app/src/assets/scss/business/_card.scss index 7c9a65ed5..b1b170916 100644 --- a/app/src/assets/scss/business/_card.scss +++ b/app/src/assets/scss/business/_card.scss @@ -4,15 +4,6 @@ box-sizing: border-box; max-height: 100%; background-color: var(--b3-theme-surface); - - &.fullscreen > .card__header { - padding: 2px 8px 2px var(--b3-toolbar-left-mac); - } - } - - &__header { - display: flex; - padding: 8px 8px 8px 12px; } &__empty { diff --git a/app/src/assets/scss/util/_reset.scss b/app/src/assets/scss/util/_reset.scss index 6ab9aec4c..9d7532299 100644 --- a/app/src/assets/scss/util/_reset.scss +++ b/app/src/assets/scss/util/_reset.scss @@ -58,13 +58,6 @@ body { padding: 0 0 0 5px; } - .card__main.fullscreen > .card__header { - padding: 2px 108px 2px 12px; - & > .fn__flex-1 { - -webkit-app-region: drag; - } - } - .fullscreen { & > .protyle-breadcrumb, & > .block__icons { diff --git a/app/src/card/newCardTab.ts b/app/src/card/newCardTab.ts index 1c034c09f..e1fb95bac 100644 --- a/app/src/card/newCardTab.ts +++ b/app/src/card/newCardTab.ts @@ -2,7 +2,6 @@ import {Wnd} from "../layout/Wnd"; import {getInstanceById, getWndByLayout} from "../layout/util"; import {Tab} from "../layout/Tab"; import {Custom} from "../layout/dock/Custom"; -import {Dialog} from "../dialog"; import {bindCardEvent, genCardHTML} from "./openCard"; import {fetchPost} from "../util/fetch"; import {Protyle} from "../protyle"; @@ -10,7 +9,6 @@ import {Protyle} from "../protyle"; export const newCardTab = (options: { cardType: TCardType, id: string, - dialog: Dialog, title?: string }) => { let wnd: Wnd; @@ -21,53 +19,85 @@ export const newCardTab = (options: { if (!wnd) { wnd = getWndByLayout(window.siyuan.layout.centerLayout); } - let editor: Protyle + const tab = new Tab({ icon: "iconRiffCard", title: window.siyuan.languages.spaceRepetition, callback(tab) { - const custom = new Custom({ - type: "card", + tab.addModel(newCardModel({ tab, data: { - title: options.title, cardType: options.cardType, - id: options.id - }, - init(element) { - fetchPost(options.cardType === "all" ? "/api/riff/getRiffDueCards" : - (options.cardType === "doc" ? "/api/riff/getTreeRiffDueCards" : "/api/riff/getNotebookRiffDueCards"), { - rootID: options.id, - deckID: options.id, - notebook: options.id, - }, (response) => { - element.innerHTML = genCardHTML({ - id: options.id, - cardType: options.cardType, - blocks: response.data.cards, - isTab: true, - }); - - editor = bindCardEvent({ - element, - id: options.id, - title: options.title, - cardType: options.cardType, - blocks: response.data.cards, - dialog: options.dialog, - }) - }); - }, - destroy() { - editor.destroy(); - }, - resize(){ - editor.resize(); + id: options.id, + title: options.title } - }); - tab.addModel(custom); + })); } }); wnd.split("lr").addTab(tab); - options.dialog.destroy(); +} + +export const newCardModel = (options: { + tab: Tab, + data: { + cardType: TCardType, + id: string, + title?: string + } +}) => { + let editor: Protyle; + const custom = new Custom({ + type: "card", + tab: options.tab, + data: options.data, + init() { + fetchPost(this.data.cardType === "all" ? "/api/riff/getRiffDueCards" : + (this.data.cardType === "doc" ? "/api/riff/getTreeRiffDueCards" : "/api/riff/getNotebookRiffDueCards"), { + rootID: this.data.id, + deckID: this.data.id, + notebook: this.data.id, + }, (response) => { + this.element.innerHTML = genCardHTML({ + id: this.data.id, + cardType: this.data.cardType, + blocks: response.data.cards, + isTab: true, + }); + + editor = bindCardEvent({ + element: this.element, + id: this.data.id, + title: this.data.title, + cardType: this.data.cardType, + blocks: response.data.cards, + }); + }); + }, + destroy() { + if (editor) { + editor.destroy(); + } + }, + resize() { + if (editor) { + editor.resize(); + } + }, + update() { + fetchPost(this.data.cardType === "all" ? "/api/riff/getRiffDueCards" : + (this.data.cardType === "doc" ? "/api/riff/getTreeRiffDueCards" : "/api/riff/getNotebookRiffDueCards"), { + rootID: this.data.id, + deckID: this.data.id, + notebook: this.data.id, + }, (response) => { + this.element.innerHTML = genCardHTML({ + id: this.data.id, + cardType: this.data.cardType, + blocks: response.data.cards, + isTab: true, + }); + }); + } + }); + return custom } diff --git a/app/src/card/openCard.ts b/app/src/card/openCard.ts index 94c32114c..22866c84b 100644 --- a/app/src/card/openCard.ts +++ b/app/src/card/openCard.ts @@ -20,8 +20,8 @@ export const genCardHTML = (options: { isTab: boolean }) => { return `