0
0
mirror of https://github.com/wagtail/wagtail.git synced 2024-11-29 01:22:07 +01:00

Remove initBlockWidget global window function

This commit is contained in:
Karthik Ayangar 2024-03-24 01:51:03 +05:30 committed by LB (Ben Johnston)
parent d2405eefe8
commit 452d9aaa42

View File

@ -38,30 +38,6 @@ wagtailStreamField.blocks = {
StreamBlockDefinition,
};
function initBlockWidget(id) {
/*
Initialises the top-level element of a BlockWidget
(the form widget for a StreamField).
Receives the ID of a DOM element with the attributes:
data-block: JSON-encoded block definition to be passed to telepath.unpack
to obtain a Javascript representation of the block
(an instance of one of the Block classes below)
data-value: JSON-encoded value for this block
*/
const body = document.querySelector('#' + id + '[data-block]');
// unpack the block definition and value
const blockDefData = JSON.parse(body.dataset.block);
const blockDef = window.telepath.unpack(blockDefData);
const blockValue = JSON.parse(body.dataset.value);
const blockError = JSON.parse(body.dataset.error);
// replace the 'body' element with the populated HTML structure for the block
blockDef.render(body, id, blockValue, blockError);
}
window.initBlockWidget = initBlockWidget;
window.telepath.register('wagtail.blocks.FieldBlock', FieldBlockDefinition);
window.telepath.register('wagtail.blocks.StaticBlock', StaticBlockDefinition);
window.telepath.register('wagtail.blocks.StructBlock', StructBlockDefinition);