Vanessa 2024-03-27 18:35:19 +08:00
parent 284ec21b3b
commit 65d677984f
2 changed files with 62 additions and 22 deletions

View File

@ -368,7 +368,7 @@ const editKeydown = (app: App, event: KeyboardEvent) => {
} }
if (!isFileFocus && matchHotKey(window.siyuan.config.keymap.editor.general.spaceRepetition.custom, event)) { if (!isFileFocus && matchHotKey(window.siyuan.config.keymap.editor.general.spaceRepetition.custom, event)) {
fetchPost("/api/riff/getTreeRiffDueCards", {rootID: protyle.block.rootID}, (response) => { fetchPost("/api/riff/getTreeRiffDueCards", {rootID: protyle.block.rootID}, (response) => {
openCardByData(app, response.data, "doc", protyle.block.rootID, protyle.title.editElement.textContent || window.siyuan.languages.untitled); openCardByData(app, response.data, "doc", protyle.block.rootID, protyle.title?.editElement.textContent || window.siyuan.languages.untitled);
}); });
event.preventDefault(); event.preventDefault();
return true; return true;

View File

@ -13,6 +13,9 @@ import {escapeHtml} from "../util/escape";
/// #if !MOBILE /// #if !MOBILE
import {openFile} from "../editor/util"; import {openFile} from "../editor/util";
/// #endif /// #endif
/// #if !BROWSER
import {ipcRenderer} from "electron";
/// #endif
import * as dayjs from "dayjs"; import * as dayjs from "dayjs";
import {getDisplayName, movePathTo} from "../util/pathName"; import {getDisplayName, movePathTo} from "../util/pathName";
import {App} from "../index"; import {App} from "../index";
@ -84,8 +87,8 @@ export const genCardHTML = (options: {
<svg><use xlink:href="#iconMore"></use></svg> <svg><use xlink:href="#iconMore"></use></svg>
</div> </div>
<div class="fn__space${options.isTab ? " fn__none" : ""}"></div> <div class="fn__space${options.isTab ? " fn__none" : ""}"></div>
<div data-type="sticktab" class="b3-tooltips b3-tooltips__sw block__icon block__icon--show${options.isTab ? " fn__none" : ""}" aria-label="${window.siyuan.languages.openInNewTab}"> <div data-type="sticktab" class="b3-tooltips b3-tooltips__sw block__icon block__icon--show${options.isTab ? " fn__none" : ""}" aria-label="${window.siyuan.languages.openBy}">
<svg><use xlink:href="#iconLayoutRight"></use></svg> <svg><use xlink:href="#iconOpen"></use></svg>
</div> </div>
</div>`; </div>`;
/// #endif /// #endif
@ -406,7 +409,7 @@ export const bindCardEvent = async (options: {
/// #if MOBILE /// #if MOBILE
menu.fullscreen(); menu.fullscreen();
/// #else /// #else
const rect = target.getBoundingClientRect(); const rect = moreElement.getBoundingClientRect();
menu.open({ menu.open({
x: rect.left, x: rect.left,
y: rect.bottom y: rect.bottom
@ -417,25 +420,62 @@ export const bindCardEvent = async (options: {
/// #if !MOBILE /// #if !MOBILE
const sticktabElement = hasClosestByAttribute(target, "data-type", "sticktab"); const sticktabElement = hasClosestByAttribute(target, "data-type", "sticktab");
if (sticktabElement) { if (sticktabElement) {
openFile({ const stickMenu = new Menu();
app: options.app, stickMenu.addItem({
position: "right", icon: "iconLayoutRight",
custom: { label: window.siyuan.languages.insertRight,
icon: "iconRiffCard", click() {
title: window.siyuan.languages.spaceRepetition, openFile({
data: { app: options.app,
cardsData: options.cardsData, position: "right",
index, custom: {
cardType: filterElement.getAttribute("data-cardtype") as TCardType, icon: "iconRiffCard",
id: docId, title: window.siyuan.languages.spaceRepetition,
title: options.title data: {
}, cardsData: options.cardsData,
id: "siyuan-card" index,
}, cardType: filterElement.getAttribute("data-cardtype") as TCardType,
id: docId,
title: options.title
},
id: "siyuan-card"
},
});
options.dialog.destroy();
}
});
/// #if !BROWSER
stickMenu.addItem({
icon: "iconOpenWindow",
label: window.siyuan.languages.openByNewWindow,
click() {
const json = {
"title": window.siyuan.languages.spaceRepetition,
"icon": "iconRiffCard",
"instance": "Tab",
"children": {
"instance": "Custom",
"customModelType": "siyuan-card",
"customModelData": {
"cardType": filterElement.getAttribute("data-cardtype"),
"id": docId,
"title": options.title
}
}
};
ipcRenderer.send(Constants.SIYUAN_OPEN_WINDOW, {
// 需要 encode 否则 https://github.com/siyuan-note/siyuan/issues/9343
url: `${window.location.protocol}//${window.location.host}/stage/build/app/window.html?v=${Constants.SIYUAN_VERSION}&json=${encodeURIComponent(JSON.stringify(json))}`
});
options.dialog.destroy();
}
});
/// #endif
const rect = sticktabElement.getBoundingClientRect();
stickMenu.open({
x: rect.left,
y: rect.bottom
}); });
if (options.dialog) {
options.dialog.destroy();
}
event.stopPropagation(); event.stopPropagation();
event.preventDefault(); event.preventDefault();
return; return;