Skip to content

Commit

Permalink
Merge pull request #5 from moham96/fixes+react-18
Browse files Browse the repository at this point in the history
Fixes+react 18
  • Loading branch information
breakerh authored May 1, 2024
2 parents a784a57 + 6dc43ca commit a1bcbcd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 20 deletions.
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
],
"peerDependencies": {
"@tiptap/core": "^2.0.0-beta.1",
"@tiptap/react": "^2.0.0-beta.109",
"@tiptap/extension-image": "^2.0.0-beta.27",
"react": "^17.0.2"
"@tiptap/react": "^2.0.0-beta.109",
"react": "^17.0.2 || ^18"
},
"main": "src/index.ts",
"files": [
Expand All @@ -23,5 +23,6 @@
"url": "https://github.com/breakerh/tiptap-image-resize"
},
"dependencies": {
"@types/react": "^18.0.38"
}
}
20 changes: 2 additions & 18 deletions src/image.ts → src/image.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Component, FC, ReactElement} from "react";
import React, {Component, FC, ReactElement} from "react";
import {mergeAttributes, nodeInputRule, Node} from "@tiptap/core";
import {ReactNodeViewRenderer} from "@tiptap/react";
import ImageResizeComponent from "./component/ImageResizeComponent";
Expand Down Expand Up @@ -32,6 +32,7 @@ export const ImageResize = Image.extend<ImageOptions>({
},
addAttributes() {
return {
...this.parent?.(),
width: {
default: '100%',
renderHTML: (attributes) => {
Expand All @@ -48,25 +49,8 @@ export const ImageResize = Image.extend<ImageOptions>({
};
}
},
isDraggable: {
default: true,
renderHTML: (attributes) => {
return {};
}
}
};
},
parseHTML() {
return [
{
tag: 'image-resizer',
},
]
},

renderHTML({ HTMLAttributes }) {
return ['image-resizer', mergeAttributes(this.options.HTMLAttributes,HTMLAttributes)]
},

addNodeView() {
return ReactNodeViewRenderer(ImageResizeComponent)
Expand Down

0 comments on commit a1bcbcd

Please sign in to comment.