tinymce / tinymce-react

Offical TinyMCE React component
MIT License
937 stars 152 forks source link

Image upload does not insert image at cursor position #468

Closed rositca-yancheva closed 6 months ago

rositca-yancheva commented 10 months ago

Hi guys 👋, we are experiencing some issues with the image upload:

What is the current behavior?

When an image is uploaded, the cursor position is ignored and the image always moves at the very beginning of the text. No error appears. Drag and drop image upload works as expected, only uploading via the editor's toolbar causes this issue.

https://github.com/tinymce/tinymce-react/assets/83578430/3ffbea6f-d3ef-4ced-a485-532d5bbe16a5

The editor is configured with the following props:

               <Editor
                  apiKey="<API_KEY>"
                  onInit={(evt, editor) => {
                    editorRef.current = editor
                  }}
                  initialValue={some initial value}
                  init={{
                    entity_encoding: 'numeric',
                    table_sizing_mode: 'fixed',
                    menubar: false,
                    height: 600,
                    plugins: 'image media',
                    images_upload_handler: <function that returns blob storage url>,
                  }}
                  plugins="table image"
                  toolbar="undo redo | formatselect |
                    bold italic underline strikethrough | superscript subscript | table |
                    removeformat | image"
                  onChange={(event: any, editor: any) => {
                    updateLocalTextBlock('html', editor.getContent())
                  }}
                />

What is the expected behavior?

Image is uploaded at cursor position.

Which versions of TinyMCE, and which browser / OS are affected by this issue? Did this work in previous versions of TinyMCE or tinymce-react?

tinymce-react: 4.3.0 Chrome: 115.0.5790.170 (Official Build) (arm64) macBook: Ventura 13.4.1

TinyITAdmin commented 10 months ago

Ref: INT-3222

danoaky-tiny commented 7 months ago

I couldn't replicate your issue with your provided implementation, see: https://codesandbox.io/p/devbox/int-3222-n9sgpm Please provide more info.

github-actions[bot] commented 6 months ago

This issue is stale because it has been open for 30 days with no activity. Respond with a comment or this will be closed in 7 days.