Closed ulitol97 closed 2 years ago
You´ll need to include the Codemirror Placeholder Addon and then I think it will work adding the placeholder
option to the textarea. Check the source code of this example.
Let me know if you have any problem :)
I've tried with the add-on but I'm afraid I'm not seeing any change yet, even trying and combining these different ways:
y.setOption("placeholder", "My Placeholder")
)<textarea... placeholder="My Placeholder"/>
)The thing is everything's working normally in another file that uses a basic CodeMirror instance and an options object. In that case, importing some add-ons (placeholder, closetag...) did work:
<CodeMirror... options={{ placeholder: "My placeholder" }} />
I'm probably missing something here... but maybe the change should come from YASHE, since it is the one eventually building the CodeMirror
The working example looks exactly how I wanted.
I'm finally going to try this, where is the placeholder.js file that must be changed?
I saw the gist, I meant the original placeholder.js that must be changed with the gist's contents 😅
Oh sorry xD Unless you have imported it before, there is no original placeholder.js. I mean, in the working example I was using YASHE via CDN with the new placeholder.js as a script. Let me know if I´m not being clear.
Thanks! I managed to make it work. It's a little hacky indeed but it will do for now. I applied the same code on YATE and and got placeholders for it as well 😇
When using YASHE I'd like to have a placeholder text shown when the textarea is empty, like HTML textareas do. I've tried passing the
placeholder
option, like this:const options = { placeholder: "My placeholder text" };
const y = Yashe.fromTextArea(textAreaRef.current, options);
but nothing's changing (same issue with YATE).
Maybe this codemirror add-on is missing somewhere?