An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:art: https://github.com/siyuan-note/siyuan/issues/7923
Vanessa34018f739ee9
diff --git a/app/src/card/makeCard.ts b/app/src/card/makeCard.tsindex bc2b15d7c3..886bb41408 100644--- a/app/src/card/makeCard.ts+++ b/app/src/card/makeCard.ts@@ -7,6 +7,7 @@ import {hideElements} from "../protyle/ui/hideElements";import {viewCards} from "./viewCards";import {Constants} from "../constants";import {escapeAttr, escapeHtml} from "../util/escape";+import {transaction} from "../protyle/wysiwyg/transaction";export const genCardItem = (item: ICardPackage) => {return `<li data-id="${item.id}" data-name="${escapeAttr(item.name)}" class="b3-list-item b3-list-item--narrow${isMobile() ? "" : " b3-list-item--hide-action"}">@@ -176,7 +177,7 @@ export const makeCard = (ids: string[]) => {});};-export const quickMakeCard = (nodeElement: Element[]) => {+export const quickMakeCard = (protyle: IProtyle, nodeElement: Element[]) => {let isRemove = true;const ids: string[] = [];nodeElement.forEach(item => {@@ -190,15 +191,25 @@ export const quickMakeCard = (nodeElement: Element[]) => {}});if (isRemove) {- fetchPost("/api/riff/removeRiffCards", {+ transaction(protyle, [{+ action: "removeFlashcards",deckID: Constants.QUICK_DECK_ID,blockIDs: ids- });+ }], [{+ action: "addFlashcards",+ deckID: Constants.QUICK_DECK_ID,+ blockIDs: ids+ }]);} else {- fetchPost("/api/riff/addRiffCards", {+ transaction(protyle, [{+ action: "addFlashcards",deckID: Constants.QUICK_DECK_ID,blockIDs: ids- });+ }], [{+ action: "removeFlashcards",+ deckID: Constants.QUICK_DECK_ID,+ blockIDs: ids+ }]);}};diff --git a/app/src/mobile/util/touch.ts b/app/src/mobile/util/touch.tsindex 06a681a803..9c3cbdd515 100644--- a/app/src/mobile/util/touch.ts+++ b/app/src/mobile/util/touch.ts@@ -32,6 +32,7 @@ export const handleTouchEnd = (event: TouchEvent) => {const target = event.target as HTMLElement;if (!clientX || !clientY || typeof yDiff === "undefined" ||target.tagName === "AUDIO" ||+ hasClosestByClassName(target, "viewer-container") ||hasClosestByClassName(target, "b3-dialog") ||hasClosestByClassName(target, "keyboard") ||hasClosestByAttribute(target, "id", "commonMenu") ||@@ -158,6 +159,7 @@ export const handleTouchMove = (event: TouchEvent) => {target.tagName === "AUDIO" ||hasClosestByClassName(target, "b3-dialog") ||hasClosestByClassName(target, "keyboard") ||+ hasClosestByClassName(target, "viewer-container") ||hasClosestByAttribute(target, "id", "commonMenu") ||hasClosestByAttribute(target, "id", "model")) {return;diff --git a/app/src/protyle/gutter/index.ts b/app/src/protyle/gutter/index.tsindex bf17f7ba64..2bc5155dda 100644--- a/app/src/protyle/gutter/index.ts+++ b/app/src/protyle/gutter/index.ts@@ -680,7 +680,7 @@ export class Gutter {iconHTML: '<svg class="b3-menu__icon" style="color:var(--b3-theme-primary)"><use xlink:href="#iconRiffCard"></use></svg>',icon: "iconRiffCard",click() {- quickMakeCard(selectsElement);+ quickMakeCard(protyle, selectsElement);}}).element);if (window.siyuan.config.flashcard.deck) {@@ -1468,7 +1468,7 @@ export class Gutter {iconHTML: '<svg class="b3-menu__icon" style="color:var(--b3-theme-primary)"><use xlink:href="#iconRiffCard"></use></svg>',icon: "iconRiffCard",click() {- quickMakeCard([nodeElement]);+ quickMakeCard(protyle, [nodeElement]);}}).element);if (window.siyuan.config.flashcard.deck) {diff --git a/app/src/protyle/header/Title.ts b/app/src/protyle/header/Title.tsindex ee57016ce3..c6d00b1347 100644--- a/app/src/protyle/header/Title.ts+++ b/app/src/protyle/header/Title.ts@@ -135,7 +135,7 @@ export class Title {event.preventDefault();event.stopPropagation();} else if (matchHotKey(window.siyuan.config.keymap.editor.general.quickMakeCard.custom, event)) {- quickMakeCard([this.element]);+ quickMakeCard(protyle, [this.element]);event.preventDefault();event.stopPropagation();return true;@@ -387,7 +387,7 @@ export class Title {label: window.siyuan.languages.quickMakeCard,accelerator: window.siyuan.config.keymap.editor.general.quickMakeCard.custom,click: () => {- quickMakeCard([this.element]);+ quickMakeCard(protyle, [this.element]);}}];if (window.siyuan.config.flashcard.deck) {diff --git a/app/src/protyle/wysiwyg/keydown.ts b/app/src/protyle/wysiwyg/keydown.tsindex ae476da788..53985f4f88 100644--- a/app/src/protyle/wysiwyg/keydown.ts+++ b/app/src/protyle/wysiwyg/keydown.ts@@ -1009,7 +1009,7 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {if (selectElement.length === 0) {selectElement.push(nodeElement);}- quickMakeCard(selectElement);+ quickMakeCard(protyle, selectElement);event.preventDefault();event.stopPropagation();return true;diff --git a/app/src/types/index.d.ts b/app/src/types/index.d.tsindex 22946b50a2..23951bc32f 100644--- a/app/src/types/index.d.ts+++ b/app/src/types/index.d.ts@@ -27,6 +27,8 @@ type TOperation =| "append"| "insertAttrViewBlock"| "removeAttrViewBlock"+ | "addFlashcards"+ | "removeFlashcards"type TBazaarType = "templates" | "icons" | "widgets" | "themes"declare module "blueimp-md5"@@ -247,13 +249,15 @@ interface IScrollAttr {interface IOperation {action: TOperation, // move, delete 不需要传 data- id: string,+ id?: string,data?: string, // updateAttr 时为 { old: IObject, new: IObject }parentID?: string // 为 insertAttrViewBlock 传 avidpreviousID?: stringretData?: anynextID?: string // insert 专享srcIDs?: string[] // insertAttrViewBlock 专享+ deckID?: string // add/removeFlashcards 专享+ blockIDs?: string[] // add/removeFlashcards 专享}interface IObject {