[QUESTION] Change and get value of editor.getSelected() block
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.
const selected = editor.getSelected();
// Get the JSON of the Component
JSON.stringify(selected.toJSON())
// Get its HTML
selected.toHTML();
// Set new components
selected.components('<div>Text1</div><div>Text2</div>')
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
[Question] 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
[Question] 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
[Question]: 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...
Browse Plugin Categories
Jump directly to plugin category pages on the marketplace.