editor.js
editor.js copied to clipboard
can we display placeholder only when editor.js is not in readonly mode
can we display editor.js placeholder only when editor.js is not in readonly mode?
const editor = new EditorJS({
...
placeholder: 'Let`s write an awesome story!' <----- only display when readOnly is false.
...
});
Thank you.
Makes so much sense
I'm currently having an issue (v 2.29.0) where when I put the editor as readOnly mode, an empty paragraph is added at the top of the editor.
This is even the case when I don't add placeholder to my config. When I do add it, the message is added after data-placeholder, but it's not shown in the editor itself. And putting the placeholder to false, also doesn't help with this.
When turning off readOnly mode, the bug is gone as well. So it's only a readOnly issue.
I'm currently having an issue (v 2.29.0) where when I put the editor as readOnly mode, an empty paragraph is added at the top of the editor.
I have the same bug
For time being I have implemented a workaround for it to remove empty paragraph blocks from the editor when it is in readOnly mode. Below is the function which we can pass in Editor instance to remove empty paragraphs from the editor js.
onReady: ()=>{
if(readOnly){
const array = document.getElementsByClassName('ce-paragraph')
const elementsArray = [...array];
const elementsTobeRemoved = elementsArray.filter(p => p.innerHTML === '')
elementsTobeRemoved.map(element => element.remove())
}
}
I have switched to a different package for my project that met my requirements better, but it seems like there is an open pr right now that would fix this issue.