Change and get value of editor.getSelected() block
To get content: editor.getSelected().get('content') To set content: editor.getSelected().set('content', 'myhtml')
Read full answer below โQuestion
How can I change and get the content of current selected block?
Answers (3)
To get content:
editor.getSelected().get('content')
To set content:
editor.getSelected().set('content', 'myhtml')
@JulyanoF be aware that content is for static strings (used mainly for custom RTEs) therefore by doing this editor.getSelected().set('content', '<div>TEXT1</div>...') you wouldn't be able to edit inner elements.
selected.components()
@artf I don't want to create a new component into the selected block,. I need only edit the content. When I use this method, it is creating a new div into the previous block. How can I avoid it?
Related Questions and Answers
Continue research with similar issue discussions.
Issue #1777
How to dynamically change the DomComponents ?
Hello , Thank you for this great library , i am working with a newsletter system that get content from the database and generate the latest...
Issue #1545
How I Get ID From Block?
Hi, i have my block and I get print in Div id results from my javascript class component... How i get ID from my block ??? editor.BlockMana...
Issue #1706
How to get href from rte?
I have this rte toolbar where you can type and click 'save' and it's going to create a link for the selected text. but the problem is that...
Issue #1674
Render block after trait action .
I have created new block called sidebar that have dynamic updates by trait component ,trait contain checkboxes to dynamic change content by...
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.