Issue #509💬 AnsweredOpened November 12, 2017by asvine-p0 reactions

Span are not editable as text

Quick answerby artf

For editable contents, you have to use content

Read full answer below ↓

Question

Hello Artf, I have a problem when importing some html templates. I was initially not able to see span texts. But after helping the editor reconizing them, i'm not able to edit them as texts. let domc = this.editor.DomComponents; let textType = domc.getType("text"); domc.addType('span', { // Define the Model model: textType.model.extend({}, { isComponent(el) { if (el.tagName === 'SPAN') { return {type: 'Span', src: el.src, tagName: el.tagName.toLowerCase(), components: el.innerHTML } } } }), view: textType.view }); Here is my html template: 5 octobre.html.zip Thanks for your help! :)

Answers (3)

artfNovember 14, 2017

For editable contents, you have to use content

...
content: el.innerHTML
...
asvine-pNovember 21, 2017

Hello artf, I have replaced "components: el.innerHTML" by "content: el.innerHTML" but the content is still not editable. Here is my code: ' let domc = this.editor.DomComponents; let textType = domc.getType("text");' domc.addType('span', { // Define the Model model: textType.model.extend({}, { isCom...

bakgatOctober 4, 2018

``` return {type: 'Span', src: el.src, tagName: el.tagName.toLowerCase(), // components: el.innerHTML, content: el.innerHTML, editable: true }

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...

Free option

Check the open-source GrapesJS plugins on GitHub or run a quick search in our free catalog.

Browse free plugins →
Premium option

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.

All tutorials →

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.