Skip to content

Instantly share code, notes, and snippets.

@nakasyou
Last active June 25, 2023 11:26
Show Gist options
  • Save nakasyou/3fdfd9b58763c90706351c512c193ef0 to your computer and use it in GitHub Desktop.
Save nakasyou/3fdfd9b58763c90706351c512c193ef0 to your computer and use it in GitHub Desktop.
TipTapのNanohaNote用プラグイン
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