hoàn thành tích hợp FSRS

This commit is contained in:
2026-04-26 19:31:29 +07:00
parent a573acedd0
commit 8459801ca9
33 changed files with 997 additions and 185 deletions
+1
View File
@@ -30,4 +30,5 @@ export * from "./lib/columns";
export * from "./lib/status";
export * from "./lib/pdf";
export * from "./lib/resizable-nodeview";
export * from "./lib/cloze";
+78
View File
@@ -0,0 +1,78 @@
import { Mark, mergeAttributes } from "@tiptap/core";
export interface ClozeOptions {
HTMLAttributes: Record<string, any>;
}
declare module "@tiptap/core" {
interface Commands<ReturnType> {
cloze: {
/**
* Set a cloze mark
*/
setCloze: () => ReturnType;
/**
* Toggle a cloze mark
*/
toggleCloze: () => ReturnType;
/**
* Unset a cloze mark
*/
unsetCloze: () => ReturnType;
};
}
}
export const Cloze = Mark.create<ClozeOptions>({
name: "cloze",
addOptions() {
return {
HTMLAttributes: {
class: "docmost-cloze",
},
};
},
parseHTML() {
return [
{
tag: "span.docmost-cloze",
},
];
},
renderHTML({ HTMLAttributes }) {
return [
"span",
mergeAttributes(this.options.HTMLAttributes, HTMLAttributes),
0,
];
},
addCommands() {
return {
setCloze:
() =>
({ commands }) => {
return commands.setMark(this.name);
},
toggleCloze:
() =>
({ commands }) => {
return commands.toggleMark(this.name);
},
unsetCloze:
() =>
({ commands }) => {
return commands.unsetMark(this.name);
},
};
},
addKeyboardShortcuts() {
return {
"Mod-Shift-c": () => this.editor.commands.toggleCloze(),
};
},
});