GetmeUK / ContentTools

A JS library for building WYSIWYG editors for HTML content.
http://getcontenttools.com
MIT License
3.94k stars 393 forks source link

Updating embedd url don't convert it. #539

Open Cweet opened 5 years ago

Cweet commented 5 years ago

When you add an embedd element it converts the url to a valid embed url (for youtube in my case). I noticed when you open the property dialog to change the url it does not convert.

I made a quick fix for anyone needing it now, but hoping it can be fixed in the next update:

    ContentTools.PropertiesDialog.prototype.save = function (domElement) {
        var detail, innerHTML;
        innerHTML = null;
        if (this._supportsCoding) {
            innerHTML = this._domInnerHTML.value;
        }
        detail = {
            changedAttributes: this.changedAttributes(),
            changedStyles: this.changedStyles(),
            innerHTML: innerHTML
        };

        if ( this.element._tagName === "iframe" && detail.changedAttributes.src ) {
            detail.changedAttributes.src = ContentTools.getEmbedVideoURL( detail.changedAttributes.src );
        }
        return this.dispatchEvent(this.createEvent('save', detail));
    } 

Also, when you click on the embed element (clicking on embedd then embed icon) you can't replace it, but doing the same action on a image lets you replace the image. (clicking on image then image icon). It's a bit confusing.

Other than that, great plugin, thanks!

anthonyjb commented 5 years ago

Thans for this @Candielope I'll look to include it in a small bug fix release shortly. :+1: