append property editor api methods to the block object for better developer experience.

This commit is contained in:
Niels Lyngsø
2020-08-21 12:28:10 +02:00
committed by Sebastiaan Janssen
parent e7ad346d93
commit 330c113da2
2 changed files with 19 additions and 0 deletions

View File

@@ -243,6 +243,22 @@
block.showSettings = block.config.settingsElementTypeKey != null;
block.showCopy = vm.supportCopy && block.config.contentElementTypeKey != null;// if we have content, otherwise it doesn't make sense to copy.
block.setParentForm = function (parentForm) {
this._parentForm = parentForm;
}
block.activate = activateBlock.bind(null, block);
block.edit = function () {
var blockIndex = vm.layout.indexOf(this.layout);
editBlock(this, false, blockIndex, this._parentForm);
}
block.editSettings = function () {
var blockIndex = vm.layout.indexOf(this.layout);
editBlock(this, true, blockIndex, this._parentForm);
}
block.requestDelete = requestDeleteBlock.bind(null, block);
block.delete = deleteBlock.bind(null, block);
block.copy = copyBlock.bind(null, block);
return block;
}

View File

@@ -41,6 +41,9 @@
// Guess we'll leave it for now but means all things need to be copied to the $scope and then all
// primitives need to be watched.
// let the Block know about its form
model.block.setParentForm(model.parentForm);
$scope.block = model.block;
$scope.api = model.api;
$scope.index = model.index;