Grapesjs: Set href for link block

Created on 11 Jul 2018  路  4Comments  路  Source: artf/grapesjs

I want to set href for link block as there is empty href by default.

outdated

Most helpful comment

@AnkitKachhadiya you can change it by going to "Component settings" tab (gear icon). The same is for link block.

All 4 comments

@AnkitKachhadiya you can change it by going to "Component settings" tab (gear icon). The same is for link block.

@AnkitKachhadiya you can also update dynamically the default one

editor.BlockManager.get('id-of-the-block').set({
    content: {
        type: 'link',
        content:'Text for the link',
        attributes: { href: '...' }
    }
})

Thank you for the help

Can you please re-open these issue
@maryia-kabash @artf I have made a custom block for my custom link see code:

editor.BlockManager.add("unsubscribe-block", {
label: "Unsubscribe",
content: {
type: "link",
content: "unsubscribe_link",
attributes: {href: "{unsubscribe_link}"}
},
attributes: {
title: "Insert Unsubscribe block",
class: "fa fa-ban"
}
});

Every thing works perfectly but the issue is whenever i remove href content using style manager it doesn't remove from my code editor .The code doesn't change (i think href is not editable). (refer image).
Check Fiddle FIDDLE
Do i need to add something or i am missing something
2018-07-16-10-55-localhost 1

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ryandeba picture ryandeba  路  3Comments

YashPrince picture YashPrince  路  3Comments

desilvaNSP picture desilvaNSP  路  3Comments

applibs picture applibs  路  3Comments

krunal039 picture krunal039  路  3Comments