Last active
June 25, 2023 11:26
-
-
Save nakasyou/3fdfd9b58763c90706351c512c193ef0 to your computer and use it in GitHub Desktop.
TipTapのNanohaNote用プラグイン
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { | |
Editor, | |
Mark, | |
mergeAttributes, | |
} from '@tiptap/core' | |
export const TipTapPluginNanoha = Mark.create({ | |
name: 'sheet', | |
priority: 1000, | |
addOptions() {}, | |
renderHTML({ HTMLAttributes }) { | |
return ['span', mergeAttributes(HTMLAttributes, { | |
style: "background-color: #f88;", | |
class: "nanoha-sheet", | |
}), 0] | |
}, | |
parseHTML() { | |
return [ | |
{ | |
tag: 'span', | |
getAttrs: element => { | |
return element.getAttribute("class") === "nanoha-sheet" | |
} | |
}, | |
]; | |
}, | |
addCommands() { | |
return { | |
toggleSheet: () => ({ commands }) => { | |
return commands.toggleMark(this.name) | |
}, | |
} | |
}, | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment