/* extension credits: Angelika Tyborska: https://angelika.me/2023/02/26/how-to-add-editing-image-alt-text-tiptap/ */ import Image from '@tiptap/extension-image' import { NodeViewWrapper, ReactNodeViewRenderer } from '@tiptap/react'; import { Button } from 'reactstrap'; function ImageNode(props) { const { src, alt } = props.node.attrs const { updateAttributes } = props const onEditAlt = () => { const newAlt = prompt('Set alt text:', alt || '') updateAttributes({ alt: newAlt }) } let className = 'image' if (props.selected) { className += ' ProseMirror-selectednode'} return (
{alt}
{ alt ? : ! } { alt ? Alt text: "{alt}".: Alt text missing. }
) } export default Image.extend({ addNodeView() { return ReactNodeViewRenderer(ImageNode) } })