Support

Account

Home Forums Gutenberg Block.json : Disable mode

Solving

Block.json : Disable mode

  • Hello,

    Is it possible to disable the “mode” button with the block.json ?

    I found how to do it with the old function “acf_register_block” :
    https://support.advancedcustomfields.com/forums/topic/switch-to-edit-mode-by-default/

    I tried to add “mode” : false in supports on the block.json, but it doesn’t work.

    Thank you

  • Did you try to put mode false in the acf part of block.json, not supports? So in your block.json, it would be something like:

    {
        "name": "your-block",
        "title": "Your Block",
        "description": "A dummy block",
        "apiVersion": 2,
        "acf": {
            "mode": false,
            "renderTemplate": "blocks/your-block/your-block.php"
        }
    }
  • The working solution:

    {
        "name": "acf/your-block",
        "title": "Your Block",
        "supports": {
            "jsx": true,
            "mode": false  // disable mode switch in toolbar
        },
        "acf": {
            "mode": "preview", // default mode (preview / edit / auto)
            "blockVersion": 2
        },
        "align": "full"
    }
    

    Please remove the comments before copy & paste it as a JSON format doesn’t allow it.

  • Thanks for sharing the solution. This has always been a pain (a client getting stuck in “edit” mode on a block with inner blocks) and I’m glad it can now be solved.

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.