Skip to content
This repository has been archived by the owner on Jul 24, 2019. It is now read-only.

Added an image-inserted event to the editor #47

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jordandh
Copy link
Contributor

Added an image-inserted event to the editor. It uses jQuery's trigger on the dom element. I think this would be a better way to do the file upload error callbacks. If they are events then multiple event handlers can be attached at any time instead of once during initialization.

@gojko
Copy link
Contributor

gojko commented Apr 17, 2013

ok, but this is not triggered on error, but on success. what's your use case for this?

@jordandh
Copy link
Contributor Author

I auto grow the editor as the user types. I need to auto grow when an image is inserted as well. To do that I need to know when an image is inserted.

I can make another pull request that replaces the fileUploadError callback with trigger calls.

@gojko
Copy link
Contributor

gojko commented Apr 17, 2013

should we make a proper onchange event that gets triggered? then you can grow it on any change, not just on typing/images (pasting, for example, doesn't trigger change)

@jordandh
Copy link
Contributor Author

Yah a generic change event would work well. I am currently listening to these events:

this.$editor.on('input DOMNodeInserted DOMNodeRemoved DOMCharacterDataModified', grow);

Chrome, FF, and Safari all use the newer input event that contentEditable elements can fire. The 3 dom mutation events are for IE support.

If we add this to the editor then it would essentially be listening for those events and image insertion.

@gojko
Copy link
Contributor

gojko commented Apr 17, 2013

I think "paste keyup" are good events to listen to as well.

@jordandh
Copy link
Contributor Author

input should include both paste and keyup actions.

@jordandh
Copy link
Contributor Author

I just tested those 4 events and they cover paste and keyup.

@liuguichuan666
Copy link

is this based on bootstrap 2.3 ? how can i use this with bootstrp 3.1 ,

@jordandh
Copy link
Contributor Author

This change will work for bootstrap 2.3 and bootstrap 3.1. It's just one line that fires a dom event.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants