Comments (5)
Upon debugging, I discovered that the onEditorChange
function isn't triggered after invoking uploadImages()
. Despite implementing a method to update the body state, the body remains unchanged.
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 text
value in the initialValue
prop is simply a state derived from data retrieved from the database.
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 setData
function from the InertiaJS userForm
hook, but I've also experimented with a conventional useState
hook from React with the same outcome: the state data isn't updated.
Additionally, I have to manually invoke the onEditorChange
method because TinyMCE doesn't trigger it automatically after uploadImages()
completes. So, the submission process looks something like this:
const submit = (e) => {
e.preventDefault();
editorRef.current.uploadImages().then((uploadResults) => {
const updatedContent = editorRef.current.getContent();
onEditorChange(updatedContent);
}).then(() => {
// Additional actions after image upload
});
};
from tinymce-react.
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.
from tinymce-react.
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.
from tinymce-react.
If you need any more details or informations feel free to ask.
from tinymce-react.
Internal ref: INT-3289
from tinymce-react.
Related Issues (20)
- Failed to execute 'querySelectorAll' on 'Element': 'map:not(svg map),canvas:not(svg canvas),del:not(svg del),ins:not(svg ins),a:not(svg a)' is not a valid selector HOT 2
- TinyMCE requires standards mode. HOT 2
- Chrome Browser Based Bug and high memory usage after sometime HOT 2
- Useless Image reload triggered at keyup event, when cache is disabled HOT 7
- Cursor jump back to start when pressed any key in the keyboard. HOT 2
- Uncaught ReferenceError: tinymce is not defined HOT 5
- The editor refreshing anytime i click on other element
- Upload large video more than 100 MB HOT 2
- Selector type doesn't support string in react. HOT 2
- react18 + tinymce/tinymce-react, use image_caption and file_picker_callback HOT 2
- Error TS for use readonly with React JS (Editor) HOT 1
- About this.elementRef.current?.OwnerDocument.DefaultView question HOT 3
- Toolbar Sticky not working properly HOT 5
- Cursor jumps to the start when I start typing HOT 4
- I found a bug while trying to use the Merge Tags feature in "codepen"
- "@tinymce/tinymce-react": "^5.1.0" NOT FIND HOT 3
- Cannot find module '@tinymce/tinymce-react' or its corresponding type declarations HOT 2
- GPL usage not working HOT 1
- [Solved] `licenseKey` is not working as intended but `license_key` did. Test failing on `license_key` HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tinymce-react.