question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"Cannot set property defaults of #<n>" error while integrating GrapesJS-blocks-boostrap4 plugin

See original GitHub issue

Hi there. I am trying to add grapesjs-blocks-bootstrap4 plugin in my grapesjs editor in reactjs. When I try adding it, I get the following error. TypeError: Cannot set property defaults of #<n> which has only a getter at eval (grapes.min.js?a826:2:1) at Module.It (grapes.min.js?a826:2:1) at Function.$ [as extend] (grapes.min.js?a826:2:1) at vr (grapesjs-blocks-bootstrap4.min.js?5902:11:1) at eval (grapesjs-blocks-bootstrap4.min.js?5902:11:1) at eval (grapes.min.js?a826:2:1)

I tried deleting the node modules and installing them again, but still had the same issue. Thank you for your help in advance.

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:6

github_iconTop GitHub Comments

2reactions
matthewmichelcommented, Oct 14, 2022

I’m also getting this issue

0reactions
chaegumicommented, Dec 22, 2022

https://github.com/chaegumi/grapesjs-blocks-bootstrap4

Wrong code

domc.addType('alert', {
        model: textModel.extend({
            defaults: Object.assign({}, textModel.prototype.defaults, {
                'custom-name': 'Alert',
                tagName: 'div',
                classes: ['alert'],
                traits: [
                    {
                        type: 'class_select',
                        options: [
                            {value: '', name: 'None'},
                            ... contexts.map(function(v) { return {value: 'alert-'+v, name: capitalize(v)} })
                        ],
                        label: 'Context'
                    }
                ].concat(textModel.prototype.defaults.traits)
            })
        }, {
            isComponent(el) {
                if(el && el.classList && el.classList.contains('alert')) {
                    return {type: 'alert'};
                }
            }
        }),
        view: textView
    });

Correct code

    domc.addType('alert', {
        extend: 'text',
        model: {
            defaults: Object.assign({}, textModel.prototype.defaults, {
                'custom-name': 'Alert',
                tagName: 'div',
                classes: ['alert'],
                traits: [
                    {
                        type: 'class_select',
                        options: [
                            { value: '', name: 'None' },
                            ...contexts.map(function (v) { return { value: 'alert-' + v, name: capitalize(v) } })
                        ],
                        label: 'Context'
                    }
                ].concat(textModel.prototype.defaults.traits)
            })
        },
        isComponent(el) {
            if (el && el.classList && el.classList.contains('alert')) {
                return { type: 'alert' };
            }
        },
        view: textView
    });
Read more comments on GitHub >

github_iconTop Results From Across the Web

"Cannot set property defaults of #<n>" error while integrating ...
I am trying to add grapesjs-blocks-bootstrap4 plugin in my grapesjs editor in reactjs. When I try adding it, I get the following error....
Read more >
Issues · kaoz70/grapesjs-blocks-bootstrap4 - GitHub
Issues list ; how can i add editable blocks. #75 opened last week ; "Cannot set property defaults of #<n>" error while integrating...
Read more >
grapesjs-bootstrap4-blocks - npm
Start using grapesjs-bootstrap4-blocks in your project by running `npm ... link component to re-inherit from default and give toggle setting ...
Read more >
Block Manager - GrapesJS
To change the default configurations you have to pass the blockManager property with the main configuration object. const editor = grapesjs.init ...
Read more >
Spfx import custom css - Caritas Castellaneta
Not able to reference custom CSS in sharepoint framework getting error: ... Jul 24, 2019 · Create SPFx extension command view set project....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found