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

Pasting images doesn't work #163

Open
mschering opened this issue Mar 31, 2015 · 2 comments
Open

Pasting images doesn't work #163

mschering opened this issue Mar 31, 2015 · 2 comments

Comments

@mschering
Copy link

I'm implementing automatic image upload when you paste an image in the editor. This didn't work for firefox because the editor calls event.preventDefault() on the paste event in _initParser(). I made a small change to only do that when text is returned from the paste event. This way the image is inserted in the editor and my code can grab that image for uploading. Any chance that you can make this change in the core?

Thanks!
Merijn Schering

@mschering
Copy link
Author

I load this javascript to allow pasting in firefox:

wysihtml5.Editor.prototype._initParser = function() {
      var oldHtml,
          cleanHtml;

      if (wysihtml5.browser.supportsModenPaste()) {
        this.on("paste:composer", function(event) {

          oldHtml = wysihtml5.dom.getPastedHtml(event);
          if (oldHtml) {
                        event.preventDefault();
            this._cleanAndPaste(oldHtml);
          }
        }.bind(this));

      } else {
        this.on("beforepaste:composer", function(event) {
          event.preventDefault();
          var scrollPos = this.composer.getScrollPos();

          wysihtml5.dom.getPastedHtmlWithDiv(this.composer, function(pastedHTML) {
            if (pastedHTML) {
              this._cleanAndPaste(pastedHTML);
            }
            this.composer.setScrollPos(scrollPos);
          }.bind(this));

        }.bind(this));
      }
    };

@dandv
Copy link

dandv commented May 29, 2015

Pasting images would bring this editor closer to Summernote or Froala.

I'm comparing WYSIWYG editors and have been looking for this feature.

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

No branches or pull requests

2 participants