Issue #3422Opened April 29, 2021by Asifislam1100 reactions

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)

theSC0RPApril 29, 20210 reactions

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 = "";
Asifislam110April 29, 20210 reactions

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

theSC0RPApril 29, 20210 reactions

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.

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

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.