Adding custom read-only block
See original GitHub issueHi, I am trying to make custom button that inserts custom tag with content (in my case <article_id>Article ID Placeholder</article_id>
). Everything is ok when you press the button, the html is appending to the editor, but after that there are problems that I can’t solve:
When you start typing the text is within my custom tag and I can’t get out of it. When you press <enter> the tag is multiplying on the next row.
My question is: Is there a way to insert html content as some kind of block that you can’t edit (read-only) and the cursor can’t get inside of it?
Issue Analytics
- State:
- Created 7 years ago
- Comments:8 (3 by maintainers)
Top Results From Across the Web
How can I make custom rendered block readonly in Draft.js ...
I have a custom block renderer specified correctly via blockRendererFn prop. The component renders the EditorBlock imported from draft-js as ...
Read more >read-only - CSS: Cascading Style Sheets - MDN Web Docs
The :read-only pseudo-class is used to remove all the styling that makes the inputs look like clickable fields, making them look more like...
Read more >Making a Field Read-only - Gravity Forms Documentation
First, you will need to add a custom class to your field Custom CSS Class setting to easily target the field. In this...
Read more >HTML5 Forms: Readonly Type Attribute - Wufoo
A read-only field can't be modified, but, unlike disabled , you can tab into it, highlight it, and copy its contents. Setting the...
Read more >Make Custom Form As Read Only - Oracle Communities
Set block's Insert Allowed, Update Allowed and Delete Allowed property to No. Manu.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I have solved my issue. I am sharing my workaround. You can add disabled input element and it completely act the way I want it to be (as a custom block). Then you can style it the way you want with css. Here is a little snippet of the code:
trumbowyg.execCmd('insertHTML', '<input name="pagebreak" value="My custom block" class="custom_block" type="text" disabled="disabled"/>');
Oh this is genius, @nilievski85