mirror of
https://github.com/Qortal/Qortal-Hub.git
synced 2025-04-25 04:17:52 +00:00
60 lines
1.0 KiB
TypeScript
60 lines
1.0 KiB
TypeScript
import { Node, mergeAttributes } from '@tiptap/core';
|
|
import { ReactNodeViewRenderer } from '@tiptap/react';
|
|
import ResizableImage from './ResizableImage'; // Import your ResizableImage component
|
|
|
|
const CustomImage = Node.create({
|
|
name: 'image',
|
|
|
|
inline: false,
|
|
group: 'block',
|
|
draggable: true,
|
|
|
|
addAttributes() {
|
|
return {
|
|
src: {
|
|
default: null,
|
|
},
|
|
alt: {
|
|
default: null,
|
|
},
|
|
title: {
|
|
default: null,
|
|
},
|
|
width: {
|
|
default: 'auto',
|
|
},
|
|
};
|
|
},
|
|
|
|
parseHTML() {
|
|
return [
|
|
{
|
|
tag: 'img[src]',
|
|
},
|
|
];
|
|
},
|
|
|
|
renderHTML({ HTMLAttributes }) {
|
|
return ['img', mergeAttributes(HTMLAttributes)];
|
|
},
|
|
|
|
addNodeView() {
|
|
return ReactNodeViewRenderer(ResizableImage);
|
|
},
|
|
|
|
addCommands() {
|
|
return {
|
|
setImage:
|
|
(options) =>
|
|
({ commands }) => {
|
|
return commands.insertContent({
|
|
type: this.name,
|
|
attrs: options,
|
|
});
|
|
},
|
|
};
|
|
},
|
|
});
|
|
|
|
export default CustomImage;
|