Extending Link component not working properly.
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.
Read full answer below ↓Question
hello @hello @artf
I am trying to extend the link component and add new traits like href and target the code is given below.
``function loadWithOption(opts) {
editor.DomComponents.addType('link', {
model: dModel.extend({
defaults: Object.assign({}, dModel.prototype.defaults, {
traits: [
// strings are automatically converted to text types
// title,
{
type: 'text',
label: 'text',
name: 'text',
},
{
type: 'select',
label: 'Target',
name: 'target',
options: [
{ value: '', name: 'This window' },
{ value: '_blank', name: 'New window' },
]
},
{
type: 'select',
label: 'Href',
name: 'href',
options: [
{value: 'index.html', name: 'Home'},
{value: 'index2.html', name: 'Home2'},
{value: 'index3.html', name: 'Home3'},
{value: 'index4.html', name: 'Home4'},
]
},
],
}),
}, {
isComponent: function (el) {
if (el.tagName == 'A' || el.tagName == 'LINK') {
return { type: 'link' };
}
},
}),
view: dView,
}); `
`
It is working only after importing the code otherwise nothing changes...
please helpAnswers (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.
Related Questions and Answers
Continue research with similar issue discussions.
Issue #1113
[QUESTIONS] New trait type is not working with rendered components?
Hello, thanks for the great framework. I'm trying to apply this to my project. I want to add a new trait for existing LINK '<a>' component....
Issue #1817
Change HTML content while block is render in editor
Hello @artf I have one block into block manager like As per above script inside the block, i want to add dynamic HTML content while this bl...
Issue #407
Defining new markup language
Hi @artf, I want to define a new markup language like mjml to make design more easy and readable. I started with <error>tag as a POC. Write...
Issue #555
Add external script in script while creating new component
Hello @artf How can I pass external script link while creating a component? like this way, bm.add('test-block2', { label: 'Test block2', at...
Paid Plugins That Match This Issue
Curated by issue keywords and label relevance to help you ship faster.
Loading paid plugin recommendations...
Check the open-source GrapesJS plugins on GitHub or run a quick search in our free catalog.
Browse free plugins →Premium plugins ship with support, regular updates, and production-ready features — save days of integration work.
Browse premium plugins →Related tutorials
In-depth guides on the same topic.
Browse Plugin Categories
Jump directly to plugin category pages on the marketplace.