Skip to content
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

Image Resize Plugin does not mark Editor Content as "dirty" #903

Closed
realulim opened this issue Dec 20, 2018 · 5 comments
Closed

Image Resize Plugin does not mark Editor Content as "dirty" #903

realulim opened this issue Dec 20, 2018 · 5 comments
Labels
bug:plugin Bug in a plugin

Comments

@realulim
Copy link
Contributor

Informations

Firefox 64.0 on Mac OS.

How to reproduce the bug?

  1. Go to https://alex-d.github.io/Trumbowyg/demos/plugins/resizimg.html
  2. Open Javascript Console and type document.getElementById('editor');
  3. Depending on screen resolution you'll see something like <div id="editor" style="margin: 1rem; height: 237.8px;" class="trumbowyg-editor" dir="ltr" contenteditable="true">
  4. Now resize the image (make it smaller or larger)
  5. Type document.getElementById('editor'); again
  6. You'll see that the image height is unchanged (237.8px in this example), even though the image is actually smaller or larger on screen.

The problem is, if Trumbowyg were used in a real application and that application would have a "Save" button and the user would press it to save after a resize operation, then the old size would be saved. And the user would have no chance of noticing, because on-screen everything looks right. I suspect that the image resize operation doesn't mark the editor content as "dirty" or perhaps forgets to call some update/refresh command on Trumbowyg.

@realulim
Copy link
Contributor Author

realulim commented Dec 27, 2018

My workaround currently is to do $("#myeditor").trumbowyg('toggle') on save and then get the content of the editor. The toggle switches to HTML mode, which seems to trigger an update of the content. After uploading the content to the server, I toggle again to go back to rich text mode.

@Alex-D
Copy link
Owner

Alex-D commented Dec 28, 2018

The cleaner way to force a content refresh is to call $('#editor').trumbowyg('execCmd', {cmd: 'syncCode'})

Also, I think the syncCode method should be called by the resizeimage plugin.

@Alex-D Alex-D added the bug:plugin Bug in a plugin label Dec 28, 2018
@realulim
Copy link
Contributor Author

trumbowyg.$c.trigger('tbwchange'); is called. But I think that is something the editor should call, when it has changed. Here we need to signal an external change to the editor.

@Alex-D
Copy link
Owner

Alex-D commented Dec 28, 2018

Yep, but it should call syncCode internally before tbwchange, and maybe the tbwchange should not be called anymore after that.

realulim added a commit to realulim/Trumbowyg that referenced this issue Dec 28, 2018
@realulim
Copy link
Contributor Author

I agree and tried it with my application and it seems to work. Will create a pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug:plugin Bug in a plugin
Projects
None yet
Development

No branches or pull requests

2 participants