How we can remove default text content from text component 'Insert your text here' ?
Question
I want to remove default text from text component just like placeholder. every time when we drag text component we need to remove default text manually.
Answers (3)
Hey @Asifislam110, I don't know if this is the best solution but this was one that I could come up with.
const textBlock = editor.BlockManager.get("text"); // get the text block
textBlock.attributes.content.content = "";
@theSC0RP it will remove the text from all the text component when editor get loaded.
When inserting a text box into Editor the text "Insert your text here" should automatically disappear when user goes to start typing. Currently, you have to remove the text yourself.
Ohh my bad! I thought you didn't want the text component to have any content when dropped in the canvas.
For your doubt, I guess you can do something like when a component is selected check if it's a text component and in the view, you will find the el in which you can change the innerText to '' if it is 'Insert your text here'
editor.on('component:selected', (comp) => {
if(comp.attributes.type === "text") {
if(comp.view.el.innerText === 'Insert your text here') {
comp.view.el.innerText = "";
}
}
})
Related Questions and Answers
Continue research with similar issue discussions.
Issue #3012
How to avoid tags to be detected as Component
I want to avoid some of the tags not to detect as components like 'B', 'I' etc tag. The problem is I have a component like this <p data-gjs...
Issue #2129
[Question] how to append a button inside default modal and catch it's click event
I want a form inside a modal (using the default modal ), on click of the submit button make an ajax call. I have created a new component wh...
Issue #576
Text content not always editable
Hi @artf, I've noticed that if I add a component that contains a combination of text and an <a> tag, the text is not editable like it norma...
Issue #1990
[QUESTIONS] need to call method before remove the html component
Hi, I need to call the method before remove the HTML component. how can I do that calling method like editor.on('block:drag:stop', function...
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.