CKeditor own dialog plugin

I wrote my own plugin that generates a simple link. The strange thing is that I cannot edit the "href" attribute. Other attributes can be edited.

This item does not work:

{
    type: 'text',
    id: 'url',
    label: 'URL',
    commit: function(element) {
        element.setAttribute('href', this.getValue());
    },
    setup: function(element) {
        this.setValue(element.getAttribute('href'));
    }
}

When I create the link, the href attribute is written. When I edit the link, the "href" attribute does not change. Weird!

When I change the code above and rewrite the attribute name, for example, to "href-s":

{
    type: 'text',
    id: 'url',
    label: 'URL',
    commit: function(element) {
        element.setAttribute('href-s', this.getValue());
    },
    setup: function(element) {
        this.setValue(element.getAttribute('href-s'));
    }
}

The create and edit attribute works great.

You do not know what the problem is?

Thank.

+4
source share
1 answer

CKEditor data-cke-saved-href href . ,

<p>I&#39;m a <a href="http://foo.com">plain&nbsp;link</a>.</p>

<p>I&#39;m a <a href="mailto:foo@bar.com?subject=Subject&amp;body=Body">mailto link</a>.</p>

- DOM

<p>I'm a <a data-cke-saved-href="http://foo.com" href="http://foo.com">plain&nbsp;link</a>.</p>

<p>I'm a <a data-cke-saved-href="mailto:foo@bar.com?subject=Subject&amp;body=Body" href="mailto:foo@bar.com?subject=Subject&amp;body=Body">mailto link</a>.</p>

data- href, .

+3

All Articles