mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-22 17:40:13 +01:00
This commit is contained in:
parent
58dbe39084
commit
ba705cd643
6 changed files with 161 additions and 56 deletions
|
|
@ -36,9 +36,7 @@ svg {
|
||||||
}
|
}
|
||||||
|
|
||||||
@media print {
|
@media print {
|
||||||
.protyle-wysiwyg {
|
.protyle-wysiwyg [data-node-id] {
|
||||||
[data-node-id] {
|
|
||||||
|
|
||||||
// 尽量避免音频块内分页
|
// 尽量避免音频块内分页
|
||||||
&[data-type=NodeAudio],
|
&[data-type=NodeAudio],
|
||||||
// 尽量避免图表块内分页
|
// 尽量避免图表块内分页
|
||||||
|
|
@ -70,5 +68,4 @@ svg {
|
||||||
break-inside: avoid;
|
break-inside: avoid;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
54
app/src/card/newCardTab.ts
Normal file
54
app/src/card/newCardTab.ts
Normal file
|
|
@ -0,0 +1,54 @@
|
||||||
|
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 {genCardHTML} from "./openCard";
|
||||||
|
import {fetchPost} from "../util/fetch";
|
||||||
|
|
||||||
|
export const newCardTab = (options: {
|
||||||
|
type: TCardType,
|
||||||
|
id: string,
|
||||||
|
dialog: Dialog
|
||||||
|
}) => {
|
||||||
|
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) {
|
||||||
|
const custom = new Custom({
|
||||||
|
type: "card",
|
||||||
|
tab,
|
||||||
|
data: {
|
||||||
|
type: options.type,
|
||||||
|
id: options.id
|
||||||
|
},
|
||||||
|
init(element) {
|
||||||
|
fetchPost(options.type === "all" ? "/api/riff/getRiffDueCards" :
|
||||||
|
(options.type === "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.type,
|
||||||
|
blocks: response.data,
|
||||||
|
isTab: true,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
tab.addModel(custom);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
wnd.split("lr").addTab(tab);
|
||||||
|
options.dialog.destroy();
|
||||||
|
}
|
||||||
|
|
@ -11,37 +11,21 @@ import {fullscreen} from "../protyle/breadcrumb/action";
|
||||||
import {MenuItem} from "../menus/Menu";
|
import {MenuItem} from "../menus/Menu";
|
||||||
import {escapeHtml} from "../util/escape";
|
import {escapeHtml} from "../util/escape";
|
||||||
import {getDisplayName, movePathTo} from "../util/pathName";
|
import {getDisplayName, movePathTo} from "../util/pathName";
|
||||||
|
import {newCardTab} from "./newCardTab";
|
||||||
|
|
||||||
export const openCard = () => {
|
export const genCardHTML = (options: {
|
||||||
fetchPost("/api/riff/getRiffDueCards", {deckID: ""}, (cardsResponse) => {
|
id: string,
|
||||||
openCardByData(cardsResponse.data, "all");
|
cardType: TCardType,
|
||||||
});
|
blocks: ICard[],
|
||||||
};
|
isTab: boolean
|
||||||
|
}) => {
|
||||||
export const openCardByData = (cardsData: {
|
return `<div class="card__main">
|
||||||
cards: ICard[],
|
|
||||||
unreviewedCount: number
|
|
||||||
}, cardType: "doc" | "notebook" | "all", id?: string, title?: string) => {
|
|
||||||
const exit = window.siyuan.dialogs.find(item => {
|
|
||||||
if (item.element.getAttribute("data-key") === window.siyuan.config.keymap.general.riffCard.custom) {
|
|
||||||
item.destroy();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
if (exit) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
let blocks = cardsData.cards;
|
|
||||||
let index = 0;
|
|
||||||
const dialog = new Dialog({
|
|
||||||
content: `<div class="card__main">
|
|
||||||
<div class="card__header">
|
<div class="card__header">
|
||||||
<span class="fn__flex-1 fn__flex-center">${window.siyuan.languages.riffCard}</span>
|
<span class="fn__flex-1 fn__flex-center">${window.siyuan.languages.riffCard}</span>
|
||||||
<span class="fn__space"></span>
|
<span class="fn__space"></span>
|
||||||
<div data-type="count" class="ft__on-surface ft__smaller fn__flex-center${blocks.length === 0 ? " fn__none" : ""}">1/${blocks.length}</span></div>
|
<div data-type="count" class="ft__on-surface ft__smaller fn__flex-center${options.blocks.length === 0 ? " fn__none" : ""}">1/${options.blocks.length}</span></div>
|
||||||
<div class="fn__space"></div>
|
<div class="fn__space"></div>
|
||||||
<div data-id="${id || ""}" data-cardtype="${cardType}" data-type="filter" class="block__icon block__icon--show">
|
<div data-id="${options.id || ""}" data-cardtype="${options.cardType}" data-type="filter" class="block__icon block__icon--show">
|
||||||
<svg><use xlink:href="#iconFilter"></use></svg>
|
<svg><use xlink:href="#iconFilter"></use></svg>
|
||||||
</div>
|
</div>
|
||||||
<div class="fn__space"></div>
|
<div class="fn__space"></div>
|
||||||
|
|
@ -49,14 +33,17 @@ export const openCardByData = (cardsData: {
|
||||||
<svg><use xlink:href="#iconCloseRound"></use></svg>
|
<svg><use xlink:href="#iconCloseRound"></use></svg>
|
||||||
</div>` : `<div data-type="fullscreen" class="b3-tooltips b3-tooltips__sw block__icon block__icon--show" aria-label="${window.siyuan.languages.fullscreen}">
|
</div>` : `<div data-type="fullscreen" class="b3-tooltips b3-tooltips__sw block__icon block__icon--show" aria-label="${window.siyuan.languages.fullscreen}">
|
||||||
<svg><use xlink:href="#iconFullscreen"></use></svg>
|
<svg><use xlink:href="#iconFullscreen"></use></svg>
|
||||||
</div>`}
|
</div><div class="fn__space"></div>
|
||||||
|
<div data-type="sticktab" class="b3-tooltips b3-tooltips__sw block__icon block__icon--show" aria-label="${window.siyuan.languages.openInNewTab}">
|
||||||
|
<svg><use xlink:href="#iconLayoutRight"></use></svg>
|
||||||
|
</div>`}
|
||||||
</div>
|
</div>
|
||||||
<div class="card__block fn__flex-1${blocks.length === 0 ? " fn__none" : ""}${window.siyuan.config.flashcard.mark ? " card__block--hidemark" : ""}${window.siyuan.config.flashcard.superBlock ? " card__block--hidesb" : ""}${window.siyuan.config.flashcard.list ? " card__block--hideli" : ""}" data-type="render"></div>
|
<div class="card__block fn__flex-1${options.blocks.length === 0 ? " fn__none" : ""}${window.siyuan.config.flashcard.mark ? " card__block--hidemark" : ""}${window.siyuan.config.flashcard.superBlock ? " card__block--hidesb" : ""}${window.siyuan.config.flashcard.list ? " card__block--hideli" : ""}" data-type="render"></div>
|
||||||
<div class="card__empty card__empty--space${blocks.length === 0 ? "" : " fn__none"}" data-type="empty">
|
<div class="card__empty card__empty--space${options.blocks.length === 0 ? "" : " fn__none"}" data-type="empty">
|
||||||
<div>🔮</div>
|
<div>🔮</div>
|
||||||
${window.siyuan.languages.noDueCard}
|
${window.siyuan.languages.noDueCard}
|
||||||
</div>
|
</div>
|
||||||
<div class="fn__flex card__action${blocks.length === 0 ? " fn__none" : ""}">
|
<div class="fn__flex card__action${options.blocks.length === 0 ? " fn__none" : ""}">
|
||||||
<button class="b3-button b3-button--cancel" disabled="disabled" data-type="-2" style="width: 25%;min-width: 86px;display: flex">
|
<button class="b3-button b3-button--cancel" disabled="disabled" data-type="-2" style="width: 25%;min-width: 86px;display: flex">
|
||||||
<svg><use xlink:href="#iconLeft"></use></svg>
|
<svg><use xlink:href="#iconLeft"></use></svg>
|
||||||
(p)
|
(p)
|
||||||
|
|
@ -101,7 +88,33 @@ export const openCardByData = (cardsData: {
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>`,
|
</div>`;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const openCard = () => {
|
||||||
|
fetchPost("/api/riff/getRiffDueCards", {deckID: ""}, (cardsResponse) => {
|
||||||
|
openCardByData(cardsResponse.data, "all");
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
export const openCardByData = (cardsData: {
|
||||||
|
cards: ICard[],
|
||||||
|
unreviewedCount: number
|
||||||
|
}, cardType: TCardType, id?: string, title?: string) => {
|
||||||
|
const exit = window.siyuan.dialogs.find(item => {
|
||||||
|
if (item.element.getAttribute("data-key") === window.siyuan.config.keymap.general.riffCard.custom) {
|
||||||
|
item.destroy();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (exit) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let blocks = cardsData.cards;
|
||||||
|
let index = 0;
|
||||||
|
const dialog = new Dialog({
|
||||||
|
content: genCardHTML({id, cardType, blocks, isTab: false}),
|
||||||
width: isMobile() ? "100vw" : "80vw",
|
width: isMobile() ? "100vw" : "80vw",
|
||||||
height: isMobile() ? "100vh" : "70vh",
|
height: isMobile() ? "100vh" : "70vh",
|
||||||
destroyCallback() {
|
destroyCallback() {
|
||||||
|
|
@ -198,6 +211,17 @@ export const openCardByData = (cardsData: {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
const sticktabElement = hasClosestByAttribute(target, "data-type", "sticktab");
|
||||||
|
if (sticktabElement) {
|
||||||
|
newCardTab({
|
||||||
|
type: filterElement.getAttribute("data-cardtype") as TCardType,
|
||||||
|
id: filterElement.getAttribute("data-id"),
|
||||||
|
dialog,
|
||||||
|
});
|
||||||
|
event.stopPropagation();
|
||||||
|
event.preventDefault();
|
||||||
|
return;
|
||||||
|
}
|
||||||
const closeElement = hasClosestByAttribute(target, "data-type", "close");
|
const closeElement = hasClosestByAttribute(target, "data-type", "close");
|
||||||
if (closeElement) {
|
if (closeElement) {
|
||||||
dialog.destroy();
|
dialog.destroy();
|
||||||
|
|
|
||||||
29
app/src/layout/dock/Custom.ts
Normal file
29
app/src/layout/dock/Custom.ts
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
import {Tab} from "../Tab";
|
||||||
|
import {setPanelFocus} from "../util";
|
||||||
|
import {Model} from "../Model";
|
||||||
|
|
||||||
|
export class Custom extends Model {
|
||||||
|
private element: Element;
|
||||||
|
|
||||||
|
constructor(options: {
|
||||||
|
tab: Tab,
|
||||||
|
data: any,
|
||||||
|
type: string, // 同一类型的唯一标识
|
||||||
|
init:(element:Element)=>void
|
||||||
|
}) {
|
||||||
|
super({id: options.tab.id});
|
||||||
|
if (window.siyuan.config.fileTree.openFilesUseCurrentTab) {
|
||||||
|
options.tab.headElement.classList.add("item--unupdate");
|
||||||
|
}
|
||||||
|
this.element = options.tab.panelElement;
|
||||||
|
options.init(this.element);
|
||||||
|
this.element.addEventListener("click", () => {
|
||||||
|
setPanelFocus(this.element.parentElement.parentElement);
|
||||||
|
});
|
||||||
|
this.update();
|
||||||
|
}
|
||||||
|
|
||||||
|
private update() {
|
||||||
|
this.element.innerHTML = `eee`
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -129,7 +129,7 @@ export const genSearch = (config: ISearchOption, element: Element, closeCB?: ()
|
||||||
<span id="searchRefresh" aria-label="${window.siyuan.languages.refresh}" class="${closeCB ? "fn__none " : ""}block__icon b3-tooltips b3-tooltips__w">
|
<span id="searchRefresh" aria-label="${window.siyuan.languages.refresh}" class="${closeCB ? "fn__none " : ""}block__icon b3-tooltips b3-tooltips__w">
|
||||||
<svg><use xlink:href="#iconRefresh"></use></svg>
|
<svg><use xlink:href="#iconRefresh"></use></svg>
|
||||||
</span>
|
</span>
|
||||||
<span id="searchOpen" aria-label="${window.siyuan.languages.stickSearch}" class="${closeCB ? "" : "fn__none "}block__icon b3-tooltips b3-tooltips__w">
|
<span id="searchOpen" aria-label="${window.siyuan.languages.openInNewTab}" class="${closeCB ? "" : "fn__none "}block__icon b3-tooltips b3-tooltips__w">
|
||||||
<svg><use xlink:href="#iconLayoutRight"></use></svg>
|
<svg><use xlink:href="#iconLayoutRight"></use></svg>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
1
app/src/types/index.d.ts
vendored
1
app/src/types/index.d.ts
vendored
|
|
@ -30,6 +30,7 @@ type TOperation =
|
||||||
| "addFlashcards"
|
| "addFlashcards"
|
||||||
| "removeFlashcards"
|
| "removeFlashcards"
|
||||||
type TBazaarType = "templates" | "icons" | "widgets" | "themes"
|
type TBazaarType = "templates" | "icons" | "widgets" | "themes"
|
||||||
|
type TCardType = "doc" | "notebook" | "all"
|
||||||
declare module "blueimp-md5"
|
declare module "blueimp-md5"
|
||||||
|
|
||||||
interface Window {
|
interface Window {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue