codex-team / editor.js

A block-style editor with clean JSON output
https://editorjs.io
Apache License 2.0
28.27k stars 2.06k forks source link

💡ReadyOnly on a per Block basis #1589

Open imryanjay opened 3 years ago

imryanjay commented 3 years ago

With the great addition to ReadOnly setting the entire editor to contentEditable=false, it would great to implement this on a per block basis.

An example use case could be blocks received from an API where a parent user has set certain blocks that must be in an editor, while allowing a child user the ability to add / edit more.

a Block.ReadOnly could function the same as the editorJS readOnly by disabling the inline toolbar, as well as block settings.

To currently achieve this, I am passing readOnly: true to a block's data object

blocks: [
    {
        "type": "paragraph",
        "data": {
            readOnly: true,
            "text": "Hello World",
        },
    },
]

Disabling contentEditable on the Block element, then hiding the inline toolbar and block settings button. Works, but not ideal.

Thoughts on this as a feature?

imryanjay commented 3 years ago

Could be an additional property to each Block in data.

blocks: [
    {
        "type": "paragraph",
        "data": {
            "text": "Hello World",
        },
       "config":  {
           "readOnly": true,
       }
    },
]
MeFelixWang commented 2 years ago

Wonderful feature, hope to use it.

betaSavvy commented 2 years ago

+1 to this feature!

chenguzhen87 commented 2 years ago

Is this function implemented?

ekwus commented 2 years ago

I'd like to use editor.js to create simple forms / survey type pages and then display the page in readonly mode but allow the viewer to enter data in to textbox, checkbox, radio button fields and then have that data saved. This feature would help with this but maybe not deliver the full functionality

madsem commented 2 months ago

I'd like to use editor.js to create simple forms / survey type pages and then display the page in readonly mode but allow the viewer to enter data in to textbox, checkbox, radio button fields and then have that data saved. This feature would help with this but maybe not deliver the full functionality

actually looking into editorjs for this as well, is there a solution to this by now?

When you create form elements, save them to database and let form owners edit the forms, the block name / id should never change again or data structure would constantly change for the same form...

ps: actually, it's probably enough if removing a form element can be disabled. Not sure yet, but that should be possible