Skip to content

Commit

Permalink
#43
Browse files Browse the repository at this point in the history
  • Loading branch information
GraemeFulton committed Jun 23, 2024
1 parent b9493b3 commit 90e9f7f
Show file tree
Hide file tree
Showing 6 changed files with 510 additions and 460 deletions.
32 changes: 29 additions & 3 deletions components/Editor/CustomExtensions/Figure2/CustomImage.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import React from 'react';
import { ReactNodeViewRenderer } from "@tiptap/react";
import {
mergeAttributes,
Node,
nodeInputRule,
} from '@tiptap/core'
import { PluginKey , Plugin} from "prosemirror-state";
import {Decoration, DecorationSet} from "prosemirror-view"
import ImageNodeView from './ImageNodeView/ImageNodeView';

export const ImageDecorationKey = new PluginKey('image-decoration');

Expand All @@ -31,13 +34,20 @@ export const ImageDecorationKey = new PluginKey('image-decoration');
return this.options.inline ? 'inline' : 'block'
},

draggable: false,
draggable: true,

addAttributes() {
return {
src: {
default: null,
},
// blob:{
// default:null,
// parseHTML: async (element) => {
// const blob = await imgToBlob()
// return blob
// }
// },
alt: {
default: null,
},
Expand Down Expand Up @@ -144,6 +154,13 @@ export const ImageDecorationKey = new PluginKey('image-decoration');
props: {
decorations(state) { return this.getState(state) },
},
// filterTransaction: (transaction, state) => {
// let result = true; // true for keep, false for stop transaction
// if (transaction?.curSelection?.node?.type.name == "image") {
// result = false;
// }
// return result;
// },

})
];
Expand Down Expand Up @@ -189,11 +206,20 @@ export const ImageDecorationKey = new PluginKey('image-decoration');
find: inputRegex,
type: this.type,
getAttributes: match => {
const [,, alt, src, title] = match
const [alt, src, title] = match

return { src, alt, title }
},
}),
]
},
})
// addNodeView() {
// return ReactNodeViewRenderer(React.memo(ImageNodeView));
// }
})

const imgToBlob = async () => {
const response = await fetch(`https://req.prototypr.io/${props.node.attrs.src}`);
const blob = await response.blob();
return (URL.createObjectURL(blob));
};
Loading

0 comments on commit 90e9f7f

Please sign in to comment.