diff --git a/wagtail/blocks/field_block.py b/wagtail/blocks/field_block.py
index f415fe5297..1e5885e4ea 100644
--- a/wagtail/blocks/field_block.py
+++ b/wagtail/blocks/field_block.py
@@ -112,6 +112,7 @@ class FieldBlockAdapter(Adapter):
"label": block.label,
"required": block.required,
"icon": block.meta.icon,
+ "blockDefId": block.definition_prefix,
"classname": " ".join(classname),
"showAddCommentButton": getattr(
block.field.widget, "show_add_comment_button", True
diff --git a/wagtail/blocks/list_block.py b/wagtail/blocks/list_block.py
index ebc99faf69..618e1bfa46 100644
--- a/wagtail/blocks/list_block.py
+++ b/wagtail/blocks/list_block.py
@@ -450,6 +450,7 @@ class ListBlockAdapter(Adapter):
meta = {
"label": block.label,
"icon": block.meta.icon,
+ "blockDefId": block.definition_prefix,
"classname": block.meta.form_classname,
"collapsed": block.meta.collapsed,
"strings": {
diff --git a/wagtail/blocks/static_block.py b/wagtail/blocks/static_block.py
index 88ca712481..a0fe74544b 100644
--- a/wagtail/blocks/static_block.py
+++ b/wagtail/blocks/static_block.py
@@ -58,6 +58,7 @@ class StaticBlockAdapter(Adapter):
text_or_html: admin_text,
"icon": block.meta.icon,
"label": block.label,
+ "blockDefId": block.definition_prefix,
},
]
diff --git a/wagtail/blocks/stream_block.py b/wagtail/blocks/stream_block.py
index 48145bef90..592d1e1e17 100644
--- a/wagtail/blocks/stream_block.py
+++ b/wagtail/blocks/stream_block.py
@@ -828,6 +828,7 @@ class StreamBlockAdapter(Adapter):
"label": block.label,
"required": block.required,
"icon": block.meta.icon,
+ "blockDefId": block.definition_prefix,
"classname": block.meta.form_classname,
"maxNum": block.meta.max_num,
"minNum": block.meta.min_num,
diff --git a/wagtail/blocks/struct_block.py b/wagtail/blocks/struct_block.py
index 2ff7962f02..b12018c094 100644
--- a/wagtail/blocks/struct_block.py
+++ b/wagtail/blocks/struct_block.py
@@ -403,6 +403,7 @@ class StructBlockAdapter(Adapter):
"label": block.label,
"required": block.required,
"icon": block.meta.icon,
+ "blockDefId": block.definition_prefix,
"classname": block.meta.form_classname,
}
diff --git a/wagtail/contrib/table_block/tests.py b/wagtail/contrib/table_block/tests.py
index 98fb8ef074..d3f292d03a 100644
--- a/wagtail/contrib/table_block/tests.py
+++ b/wagtail/contrib/table_block/tests.py
@@ -571,6 +571,7 @@ class TestTableBlockForm(WagtailTestUtils, SimpleTestCase):
"label": "Test tableblock",
"required": True,
"icon": "table",
+ "blockDefId": block.definition_prefix,
"classname": "w-field w-field--char_field w-field--table_input",
"showAddCommentButton": True,
"strings": {"ADD_COMMENT": "Add Comment"},
diff --git a/wagtail/contrib/typed_table_block/blocks.py b/wagtail/contrib/typed_table_block/blocks.py
index ba108fdfdb..84f9088aab 100644
--- a/wagtail/contrib/typed_table_block/blocks.py
+++ b/wagtail/contrib/typed_table_block/blocks.py
@@ -334,6 +334,7 @@ class TypedTableBlockAdapter(Adapter):
"label": block.label,
"required": block.required,
"icon": block.meta.icon,
+ "blockDefId": block.definition_prefix,
"strings": {
"CAPTION": _("Caption"),
"CAPTION_HELP_TEXT": _(
diff --git a/wagtail/contrib/typed_table_block/tests.py b/wagtail/contrib/typed_table_block/tests.py
index 66437801fc..8b60a41388 100644
--- a/wagtail/contrib/typed_table_block/tests.py
+++ b/wagtail/contrib/typed_table_block/tests.py
@@ -9,6 +9,7 @@ from wagtail.blocks.struct_block import StructBlockValidationError
from wagtail.contrib.typed_table_block.blocks import (
TypedTable,
TypedTableBlock,
+ TypedTableBlockAdapter,
TypedTableBlockValidationError,
)
@@ -223,6 +224,36 @@ class TestTableBlock(TestCase):
# rendering should use the block renderings of the child blocks ('FR' not 'fr')
self.assertIn("
FR | ", html)
+ def test_adapt(self):
+ block = TypedTableBlock()
+
+ block.set_name("test_typedtableblock")
+ js_args = TypedTableBlockAdapter().js_args(block)
+
+ self.assertEqual(js_args[0], "test_typedtableblock")
+ self.assertEqual(
+ js_args[-1],
+ {
+ "label": "Test typedtableblock",
+ "required": False,
+ "icon": "table",
+ "blockDefId": block.definition_prefix,
+ "strings": {
+ "CAPTION": "Caption",
+ "CAPTION_HELP_TEXT": (
+ "A heading that identifies the overall topic of the table, and is useful for screen reader users."
+ ),
+ "ADD_COLUMN": "Add column",
+ "ADD_ROW": "Add row",
+ "COLUMN_HEADING": "Column heading",
+ "INSERT_COLUMN": "Insert column",
+ "DELETE_COLUMN": "Delete column",
+ "INSERT_ROW": "Insert row",
+ "DELETE_ROW": "Delete row",
+ },
+ },
+ )
+
def test_validation_error_as_json(self):
error = TypedTableBlockValidationError(
cell_errors={
diff --git a/wagtail/snippets/tests/test_snippets.py b/wagtail/snippets/tests/test_snippets.py
index 611d744053..52bdc066e3 100644
--- a/wagtail/snippets/tests/test_snippets.py
+++ b/wagtail/snippets/tests/test_snippets.py
@@ -5538,6 +5538,7 @@ class TestSnippetChooserBlock(TestCase):
"label": "Test snippetchooserblock",
"required": True,
"icon": "snippet",
+ "blockDefId": block.definition_prefix,
"helpText": "pick an advert, any advert",
"classname": "w-field w-field--model_choice_field w-field--admin_snippet_chooser",
"showAddCommentButton": True,
@@ -5846,6 +5847,7 @@ class TestSnippetChooserBlockWithCustomPrimaryKey(TestCase):
"label": "Test snippetchooserblock",
"required": True,
"icon": "snippet",
+ "blockDefId": block.definition_prefix,
"helpText": "pick an advert, any advert",
"classname": "w-field w-field--model_choice_field w-field--admin_snippet_chooser",
"showAddCommentButton": True,
diff --git a/wagtail/tests/test_blocks.py b/wagtail/tests/test_blocks.py
index c8032c9c9d..7561d99982 100644
--- a/wagtail/tests/test_blocks.py
+++ b/wagtail/tests/test_blocks.py
@@ -98,6 +98,7 @@ class TestFieldBlock(WagtailTestUtils, SimpleTestCase):
"helpText": "Some helpful text",
"required": True,
"icon": "placeholder",
+ "blockDefId": block.definition_prefix,
"classname": "w-field w-field--char_field w-field--text_input",
"showAddCommentButton": True,
"strings": {"ADD_COMMENT": "Add Comment"},
@@ -204,6 +205,7 @@ class TestFieldBlock(WagtailTestUtils, SimpleTestCase):
"label": "Test choiceblock",
"required": True,
"icon": "placeholder",
+ "blockDefId": block.definition_prefix,
"classname": "w-field w-field--choice_field w-field--select",
"showAddCommentButton": True,
"strings": {"ADD_COMMENT": "Add Comment"},
@@ -613,6 +615,7 @@ class TestRichTextBlock(TestCase):
"classname": "w-field w-field--char_field w-field--custom_rich_text_area",
"icon": "pilcrow",
"label": "Test richtextblock",
+ "blockDefId": block.definition_prefix,
"required": True,
"showAddCommentButton": True,
"strings": {"ADD_COMMENT": "Add Comment"},
@@ -635,6 +638,7 @@ class TestRichTextBlock(TestCase):
"label": "Test richtextblock",
"required": True,
"icon": "pilcrow",
+ "blockDefId": block.definition_prefix,
"classname": "w-field w-field--char_field w-field--draftail_rich_text_area",
"showAddCommentButton": False, # Draftail manages its own comments
"strings": {"ADD_COMMENT": "Add Comment"},
@@ -657,6 +661,7 @@ class TestRichTextBlock(TestCase):
"label": "Test richtextblock",
"required": True,
"icon": "pilcrow",
+ "blockDefId": block.definition_prefix,
"classname": "w-field w-field--char_field w-field--draftail_rich_text_area",
"showAddCommentButton": False, # Draftail manages its own comments
"strings": {"ADD_COMMENT": "Add Comment"},
@@ -772,6 +777,7 @@ class TestChoiceBlock(WagtailTestUtils, SimpleTestCase):
"label": "Test choiceblock",
"required": True,
"icon": "placeholder",
+ "blockDefId": block.definition_prefix,
"classname": "w-field w-field--choice_field w-field--select",
"showAddCommentButton": True,
"strings": {"ADD_COMMENT": "Add Comment"},
@@ -1173,6 +1179,7 @@ class TestMultipleChoiceBlock(WagtailTestUtils, SimpleTestCase):
"label": "Test choiceblock",
"required": True,
"icon": "placeholder",
+ "blockDefId": block.definition_prefix,
"classname": "w-field w-field--multiple_choice_field w-field--select_multiple",
"showAddCommentButton": True,
"strings": {"ADD_COMMENT": "Add Comment"},
@@ -1609,6 +1616,7 @@ class TestRawHTMLBlock(unittest.TestCase):
"label": "Test rawhtmlblock",
"required": True,
"icon": "code",
+ "blockDefId": block.definition_prefix,
"classname": "w-field w-field--char_field w-field--textarea",
"showAddCommentButton": True,
"strings": {"ADD_COMMENT": "Add Comment"},
@@ -1951,6 +1959,7 @@ class TestStructBlock(SimpleTestCase):
"label": "Test structblock",
"required": False,
"icon": "placeholder",
+ "blockDefId": block.definition_prefix,
"classname": "struct-block",
},
)
@@ -1980,6 +1989,7 @@ class TestStructBlock(SimpleTestCase):
"label": "Test structblock",
"required": False,
"icon": "placeholder",
+ "blockDefId": block.definition_prefix,
"classname": "struct-block",
"formTemplate": "Hello
",
},
@@ -2004,6 +2014,7 @@ class TestStructBlock(SimpleTestCase):
"label": "Test structblock",
"required": False,
"icon": "placeholder",
+ "blockDefId": block.definition_prefix,
"classname": "struct-block",
"formTemplate": "Hello
",
},
@@ -2037,6 +2048,7 @@ class TestStructBlock(SimpleTestCase):
"label": "Test structblock",
"required": False,
"icon": "placeholder",
+ "blockDefId": block.definition_prefix,
"classname": "struct-block",
"helpIcon": (
'