question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Adding custom read-only block

See original GitHub issue

Hi, 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:closed
  • Created 7 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

5reactions
nilievski85commented, Aug 1, 2016

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"/>');

0reactions
dearsinacommented, Feb 10, 2021

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

Read more comments on GitHub >

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

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found