Issue #2212Opened August 22, 2019by angelocala941 reactions

Extending default image component, resizable properties ignored

Question

I'm trying to extend the default image component.

export default function(editor) {
    editor.DomComponents.addType("image", {
        model: {
            defaults: {
                resizable: {
                    autoHeight: true,
                    keepAutoHeight: true,
                    tc: false,
                    bc: false,
                    cl: false,
                    cr: false
                },
                traits: [
                    {
                        type: "checkbox",
                        label: "Test",
                        name: "test",
                        changeProp: 1
                    },
                    "alt"
                ]
            }
        }
    });
}

I can see my "Test" trait, so I assume that the component is correctly overridden, but the resizableproperties are completely ignored.

Could anyone help me to figure out why?

Answers (3)

artfAugust 27, 20191 reactions

Try to use config.avoidDefaults option as true (re-store and reload) Probably I'll set it to true by default in the next release

angelocala94August 23, 20190 reactions
init: function() {
    this.set("resizable", {
        ratioDefault: 1,
        autoHeight: true,
        keepAutoHeight: true,
        tc: false,
        bc: false,
        cl: false,
        cr: false
    });
}

I'm able to set resizable property manually inside the component init function, but this is not the best way to do that.

angelocala94August 23, 20190 reactions

Since the resizable property is part of the component model, the existing components (previously saved on DB) in the canvas have the old resizable settings.

This will replace your resizable configuration with the default one to all image components.

init: function() {
    this.set(
        "resizable",
        editor.DomComponents.getType("image").model.prototype
                        .defaults.resizable
    );
}

Related Questions and Answers

Continue research with similar issue discussions.

Paid Plugins That Match This Issue

Curated by issue keywords and label relevance to help you ship faster.

View all plugins

Loading paid plugin recommendations...

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.