webapp/src/components/Editor/extensions/Figcaption.ts
Ilya Y 784bb435c3
Feature/lint (#317)
* prettier

---------

Co-authored-by: Igor Lobanov <igor.lobanov@onetwotrip.com>
2023-11-14 18:10:00 +03:00

46 lines
760 B
TypeScript

import { mergeAttributes, Node } from '@tiptap/core'
declare module '@tiptap/core' {
interface Commands<ReturnType> {
Figcaption: {
setFigcaptionFocus: (value: boolean) => ReturnType
}
}
}
export const Figcaption = Node.create({
name: 'figcaption',
addOptions() {
return {
HTMLAttributes: {},
}
},
content: 'inline*',
selectable: false,
draggable: false,
parseHTML() {
return [
{
tag: 'figcaption',
},
]
},
renderHTML({ HTMLAttributes }) {
return ['figcaption', mergeAttributes(HTMLAttributes), 0]
},
addCommands() {
return {
setFigcaptionFocus:
(value) =>
({ commands }) => {
return commands.focus(value)
},
}
},
})