An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:lock: Block flashcards for encrypted notebooks #18034
Daniel55630fc09e9a
diff --git a/app/src/boot/globalEvent/keydown.ts b/app/src/boot/globalEvent/keydown.tsindex 0699b7283a..ee0a559772 100644--- a/app/src/boot/globalEvent/keydown.ts+++ b/app/src/boot/globalEvent/keydown.ts@@ -290,7 +290,7 @@ const editKeydown = (app: App, event: KeyboardEvent) => {event.preventDefault();return true;}- if (!isFileFocus && matchHotKey(window.siyuan.config.keymap.editor.general.quickMakeCard.custom, event) && !window.siyuan.config.readonly) {+ if (!isFileFocus && matchHotKey(window.siyuan.config.keymap.editor.general.quickMakeCard.custom, event) && !window.siyuan.config.readonly && !isEncryptedBox(protyle.notebookId)) {if (protyle.title?.editElement.contains(range.startContainer)) {quickMakeCard(protyle, [protyle.title.element]);} else {@@ -612,7 +612,7 @@ const fileTreeKeydown = (app: App, event: KeyboardEvent) => {}});- if (matchHotKey(window.siyuan.config.keymap.editor.general.spaceRepetition.custom, event) && !window.siyuan.config.readonly) {+ if (matchHotKey(window.siyuan.config.keymap.editor.general.spaceRepetition.custom, event) && !window.siyuan.config.readonly && !isEncryptedBox(notebookId)) {if (isFile) {const id = liElements[0].getAttribute("data-node-id");fetchPost("/api/riff/getTreeRiffDueCards", {rootID: id}, (response) => {@@ -627,7 +627,7 @@ const fileTreeKeydown = (app: App, event: KeyboardEvent) => {return true;}- if (matchHotKey(window.siyuan.config.keymap.editor.general.quickMakeCard.custom, event)) {+ if (matchHotKey(window.siyuan.config.keymap.editor.general.quickMakeCard.custom, event) && !isEncryptedBox(notebookId)) {if (ids.length > 0) {transaction(undefined, [{action: "addFlashcards",diff --git a/app/src/menus/navigation.ts b/app/src/menus/navigation.tsindex d7abcdc574..1a71f1d8aa 100644--- a/app/src/menus/navigation.ts+++ b/app/src/menus/navigation.ts@@ -257,7 +257,7 @@ export const initNavigationMenu = (app: App, liElement: HTMLElement) => {submenu: subMenu,}).element);}- if (!window.siyuan.config.readonly) {+ if (!window.siyuan.config.readonly && !isEncryptedBox(notebookId)) {window.siyuan.menus.menu.append(new MenuItem({id: "riffCard",label: window.siyuan.languages.riffCard,@@ -535,7 +535,7 @@ export const initFileMenu = (app: App, notebookId: string, pathString: string, l});}}).element);- if (!window.siyuan.config.readonly) {+ if (!window.siyuan.config.readonly && !isEncryptedBox(notebookId)) {const riffCardMenu = [{id: "spaceRepetition",iconHTML: "",diff --git a/app/src/protyle/gutter/index.ts b/app/src/protyle/gutter/index.tsindex 14bc969cb5..4b85568f0e 100644--- a/app/src/protyle/gutter/index.ts+++ b/app/src/protyle/gutter/index.ts@@ -1125,7 +1125,7 @@ export class Gutter {this.genWidths(selectsElement, protyle);// this.genHeights(selectsElement, protyle);}- if (!window.siyuan.config.readonly) {+ if (!window.siyuan.config.readonly && !isEncryptedBox(protyle.notebookId)) {window.siyuan.menus.menu.append(new MenuItem({id: "separator_quickMakeCard",type: "separator"@@ -2363,7 +2363,7 @@ export class Gutter {}}).element);}- if (type !== "NodeThematicBreak" && !window.siyuan.config.readonly) {+ if (type !== "NodeThematicBreak" && !window.siyuan.config.readonly && !isEncryptedBox(protyle.notebookId)) {const isCardMade = nodeElement.hasAttribute(Constants.CUSTOM_RIFF_DECKS);window.siyuan.menus.menu.append(new MenuItem({id: isCardMade ? "removeCard" : "quickMakeCard",diff --git a/app/src/protyle/header/openTitleMenu.ts b/app/src/protyle/header/openTitleMenu.tsindex 6b8e01c1cd..3172e73858 100644--- a/app/src/protyle/header/openTitleMenu.ts+++ b/app/src/protyle/header/openTitleMenu.ts@@ -172,6 +172,7 @@ export const openTitleMenu = (protyle: IProtyle, position: IPosition, from: stri}).element);}const isCardMade = !!response.data.ial[Constants.CUSTOM_RIFF_DECKS];+ if (!isEncryptedBox(protyle.notebookId)) {const riffCardMenu: IMenu[] = [{id: "spaceRepetition",iconHTML: "",@@ -225,6 +226,7 @@ export const openTitleMenu = (protyle: IProtyle, position: IPosition, from: striicon: "iconRiffCard",submenu: riffCardMenu,}).element);+ }}window.siyuan.menus.menu.append(new MenuItem({id: "search",diff --git a/kernel/model/flashcard.go b/kernel/model/flashcard.goindex 31258f8215..6cb6f70288 100644--- a/kernel/model/flashcard.go+++ b/kernel/model/flashcard.go@@ -215,6 +215,10 @@ func GetFlashcardNotebooks() (ret []*Box) {deckBlockIDs := deck.GetBlockIDs()boxes := Conf.GetOpenedBoxes()for _, box := range boxes {+ // 加密笔记本不支持闪卡,不在闪卡笔记本列表中展示+ if IsEncryptedBox(box.ID) {+ continue+ }newFlashcardCount, dueFlashcardCount, flashcardCount := countBoxFlashcard(box.ID, deck, deckBlockIDs)if 0 < flashcardCount {box.NewFlashcardCount = newFlashcardCount@@ -778,6 +782,10 @@ func (tx *Transaction) removeBlocksDeckAttr(blockIDs []string, deckID string) (eif nil == bt {continue}+ // 加密笔记本不支持闪卡,移除时也跳过,避免无谓写入加密 tree+ if IsEncryptedBox(bt.BoxID) {+ continue+ }rootIDs = append(rootIDs, bt.RootID)blockRoots[blockID] = bt.RootID@@ -886,6 +894,10 @@ func (tx *Transaction) doAddFlashcards(operation *Operation) (ret *TxErr) {if nil == bt {continue}+ // 闪卡是全局调度与存储,加密笔记本不支持闪卡,跳过其块避免明文复习计划落盘全局 riff+ if IsEncryptedBox(bt.BoxID) {+ continue+ }blockRoots[blockID] = bt.RootID}