Browse Source

:art: fix https://github.com/siyuan-note/siyuan/issues/7724

Vanessa 2 years ago
parent
commit
de8f881106
2 changed files with 60 additions and 52 deletions
  1. 25 21
      app/src/protyle/gutter/index.ts
  2. 35 31
      app/src/protyle/header/Title.ts

+ 25 - 21
app/src/protyle/gutter/index.ts

@@ -683,20 +683,22 @@ export class Gutter {
                 quickMakeCard(selectsElement);
                 quickMakeCard(selectsElement);
             }
             }
         }).element);
         }).element);
-        window.siyuan.menus.menu.append(new MenuItem({
-            label: window.siyuan.languages.addToDeck,
-            icon: "iconRiffCard",
-            click() {
-                const ids: string[] = [];
-                selectsElement.forEach(item => {
-                    if (item.getAttribute("data-type") === "NodeThematicBreak") {
-                        return;
-                    }
-                    ids.push(item.getAttribute("data-node-id"));
-                });
-                makeCard(ids);
-            }
-        }).element);
+        if (window.siyuan.config.flashcard.deck) {
+            window.siyuan.menus.menu.append(new MenuItem({
+                label: window.siyuan.languages.addToDeck,
+                icon: "iconRiffCard",
+                click() {
+                    const ids: string[] = [];
+                    selectsElement.forEach(item => {
+                        if (item.getAttribute("data-type") === "NodeThematicBreak") {
+                            return;
+                        }
+                        ids.push(item.getAttribute("data-node-id"));
+                    });
+                    makeCard(ids);
+                }
+            }).element);
+        }
         return window.siyuan.menus.menu;
         return window.siyuan.menus.menu;
     }
     }
 
 
@@ -1469,13 +1471,15 @@ export class Gutter {
                     quickMakeCard([nodeElement]);
                     quickMakeCard([nodeElement]);
                 }
                 }
             }).element);
             }).element);
-            window.siyuan.menus.menu.append(new MenuItem({
-                label: window.siyuan.languages.addToDeck,
-                icon: "iconRiffCard",
-                click() {
-                    makeCard([nodeElement.getAttribute("data-node-id")]);
-                }
-            }).element);
+            if (window.siyuan.config.flashcard.deck) {
+                window.siyuan.menus.menu.append(new MenuItem({
+                    label: window.siyuan.languages.addToDeck,
+                    icon: "iconRiffCard",
+                    click() {
+                        makeCard([nodeElement.getAttribute("data-node-id")]);
+                    }
+                }).element);
+            }
             window.siyuan.menus.menu.append(new MenuItem({type: "separator"}).element);
             window.siyuan.menus.menu.append(new MenuItem({type: "separator"}).element);
         }
         }
         let updateHTML = nodeElement.getAttribute("updated") || "";
         let updateHTML = nodeElement.getAttribute("updated") || "";

+ 35 - 31
app/src/protyle/header/Title.ts

@@ -364,42 +364,46 @@ export class Title {
                     openFileWechatNotify(protyle);
                     openFileWechatNotify(protyle);
                 }
                 }
             }).element);
             }).element);
-            window.siyuan.menus.menu.append(new MenuItem({
-                label: window.siyuan.languages.riffCard,
-                type: "submenu",
-                icon: "iconRiffCard",
-                submenu: [{
-                    iconHTML: Constants.ZWSP,
-                    label: window.siyuan.languages.spaceRepetition,
-                    click: () => {
-                        fetchPost("/api/riff/getTreeRiffDueCards", {rootID: protyle.block.rootID}, (response) => {
-                            openCardByData(response.data, `<span data-id="${protyle.block.rootID}"  class="fn__flex-center">${escapeHtml(this.editElement.textContent)}</span>`);
-                        });
-                    }
-                }, {
-                    iconHTML: Constants.ZWSP,
-                    label: window.siyuan.languages.mgmt,
-                    click: () => {
-                        fetchPost("/api/filetree/getHPathByID", {
-                            id: protyle.block.rootID
-                        }, (response) => {
-                            viewCards(protyle.block.rootID, pathPosix().join(getNotebookName(protyle.notebookId), (response.data)), "Tree");
-                        });
-                    }
-                }, {
-                    iconHTML: Constants.ZWSP,
-                    label: window.siyuan.languages.quickMakeCard,
-                    accelerator: window.siyuan.config.keymap.editor.general.quickMakeCard.custom,
-                    click: () => {
-                        quickMakeCard([this.element]);
-                    }
-                }, {
+            const riffCardMenu = [{
+                iconHTML: Constants.ZWSP,
+                label: window.siyuan.languages.spaceRepetition,
+                click: () => {
+                    fetchPost("/api/riff/getTreeRiffDueCards", {rootID: protyle.block.rootID}, (response) => {
+                        openCardByData(response.data, `<span data-id="${protyle.block.rootID}"  class="fn__flex-center">${escapeHtml(this.editElement.textContent)}</span>`);
+                    });
+                }
+            }, {
+                iconHTML: Constants.ZWSP,
+                label: window.siyuan.languages.mgmt,
+                click: () => {
+                    fetchPost("/api/filetree/getHPathByID", {
+                        id: protyle.block.rootID
+                    }, (response) => {
+                        viewCards(protyle.block.rootID, pathPosix().join(getNotebookName(protyle.notebookId), (response.data)), "Tree");
+                    });
+                }
+            }, {
+                iconHTML: Constants.ZWSP,
+                label: window.siyuan.languages.quickMakeCard,
+                accelerator: window.siyuan.config.keymap.editor.general.quickMakeCard.custom,
+                click: () => {
+                    quickMakeCard([this.element]);
+                }
+            }]
+            if (window.siyuan.config.flashcard.deck) {
+                riffCardMenu.push({
                     iconHTML: Constants.ZWSP,
                     iconHTML: Constants.ZWSP,
                     label: window.siyuan.languages.addToDeck,
                     label: window.siyuan.languages.addToDeck,
                     click: () => {
                     click: () => {
                         makeCard([protyle.block.rootID]);
                         makeCard([protyle.block.rootID]);
                     }
                     }
-                }],
+                })
+            }
+            window.siyuan.menus.menu.append(new MenuItem({
+                label: window.siyuan.languages.riffCard,
+                type: "submenu",
+                icon: "iconRiffCard",
+                submenu: riffCardMenu,
             }).element);
             }).element);
             window.siyuan.menus.menu.append(new MenuItem({type: "separator"}).element);
             window.siyuan.menus.menu.append(new MenuItem({type: "separator"}).element);
             window.siyuan.menus.menu.append(new MenuItem({
             window.siyuan.menus.menu.append(new MenuItem({