-
Notifications
You must be signed in to change notification settings - Fork 156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uploading images with TinyMCE does not replace the src attribute inside the image tag #501
Comments
Upon debugging, I discovered that the Here's how I integrate TinyMCE as a component in my form: <TinyEditorComponent
onInit={(evt, editor) => (editorRef.current = editor)}
init={{
content_style: 'body { font-size:14px };',
height: '100vh',
}}
onEditorChange={onEditorChange}
initialValue={text}
/> Here, the And here's the method I've implemented: const onEditorChange = (newContent) => {
setData('body', newContent);
console.log("Body changed:", newContent);
}; This method simply updates the state of the body, which is later sent via the request. Note that I'm using the Additionally, I have to manually invoke the const submit = (e) => {
e.preventDefault();
editorRef.current.uploadImages().then((uploadResults) => {
const updatedContent = editorRef.current.getContent();
onEditorChange(updatedContent);
}).then(() => {
// Additional actions after image upload
});
}; |
I resolved the issue through sending the updatedContent immediatly with the help of the interiaJS router and not depending on the state of data.body state. |
Apologies, this should've been moved to our React integration. Not updating the state after image upload might be a bug, so I'm reopening it and moving it over. |
If you need any more details or informations feel free to ask. |
Internal ref: INT-3289 |
📝 Provide detailed reproduction steps (if any)
I'm trying to upload images from my React frontend to my Laravel backend using TinyMCE the image plugin that is provided from TinyMCE. My backend and frontend are glued together with inertiajs.
The upload process works fine and saves the image, but when I try to save the form with the image inside of the TinyMCE Editor I get an error. This error comes from my backend where I first validate the request and then allow it to be processed.
This request fails because the image gets omitted as a base64 string inside of the
src
attribute inside of the<img>
tag and the resulting string exceeds my max limit of 65535 characters.Now strangely after that first unsuccessful attempt the
src
attribute wihtin the<img>
tag has been replaced successfully with the location string from my backend and I now can save the form without a problem.I will also provide my a snippet of my current TinyMCE setup. My current implementation is that the image is first added locally as a blob and then uploaded to the server when the user saves the form. After that, TinyMCE should automatically replace the
src
attribute with the appropriate location string.My current implementation is as follows
Is there something wrong with how I'm handling the Promise?
I am grateful for anyone's efforts to point me in the right direction. I have spent hours trying to fix this problem. I just can't seem to get behind it.
If you need additional context, please ask. I'm more than happy to provide it.
I have already tried setting the state of body manually and replacing the base64 string with the url from the promise result
and then using it like this:
Here is my TinyMCE implementation:
✔️ Expected result
The src attribute gets replaced before the form is submitted.
❌ Actual result
The form gets omitted with the blob URI still in the src attribute.
📃 Other details
If you'd like to see this fixed sooner, add a 👍 reaction to this post.
The text was updated successfully, but these errors were encountered: