Issue #460πŸ’¬ AnsweredOpened October 28, 2017by roytang2 reactions

When the component's view modifies the HTML, text components are no longer editable

Quick answerby roytang❀ 1

I tried the above, as follows: But I'm still unable to edit the text in the h1 and p elements after dropping the component on the canvas. :(

Read full answer below ↓

Question

I'm trying to build a custom component that contains some lorem ipsum text in the content, for editing once it's on the canvas. But I also want to modify the HTML in the view (to add some content that I want shown in the editor but not in the saved HTML). I tried something like this: The issue is if I modify the render() function as above, the text components in the Text section (the h1 and the p) can no longer have their text edited by double-clicking on the text. Is there a better way to do what I want to do? Thanks!

Answers (3)

roytangβ€’ November 4, 2017

I tried the above, as follows: But I'm still unable to edit the text in the h1 and p elements after dropping the component on the canvas. :(

artfβ€’ November 7, 2017

Sorry I didn't notice this you basically remove elements with models and attach a new string as HTML (the editor can't access their models anymore). If you want to add a new component you should do it via models (eg. view.model.append('<div>stuff</div>'))

artfβ€’ October 30, 2017

You can extend the Text Component instead of the base one

const defaultType = comps.getType('default');
const textType = comps.getType('text');
...
view: textType.view.extend({ ...

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.