I'm building a tune tool and I can't access the block data, but the block id is there and its passed on. Data is correct when instantiating the editor. I see the blocks just fine, I don't understand how data is logging undefined.
export default class MyBlockTune {
static get isTune() {
return true;
}
constructor({ api, data, config, block }) {
//super({ api, data, config, block }); // Se estiver a estender outra classe
this.api = api;
this.data = data;
this.config = config;
this.block = block;
}
render() {
return {
icon: '<svg>...</svg>', // Place your SVG markup here
label: 'My tune',
onActivate: async () => {
console.log('Block Data: ', this.block.data);
console.log('Block ID: ', this.block.id);
console.log('editorInstance: ', this.editorInstance); // Aqui tens acesso à instância do editor (this.editorInstance
const blockIndex = this.api.blocks.getCurrentBlockIndex();
console.log('Block Index: ', blockIndex);
if (blockIndex !== null && blockIndex !== undefined) {
const block = this.api.blocks.getBlockByIndex(blockIndex);
if (block) {
console.log('Block: ', block);
const blockID = block.id;
console.log('Block ID: ', blockID);
if (block.data) {
console.log('Block data: ', block.data);
} else {
console.log('No data found in this block.');
}
} else {
console.log('No block found at this index.');
}
} else {
console.log('No block index found.');
}
//alert('Triggered!');
this.changeBlockText(); // Keep this as it was
},
};
}
I'm able to change the block text, however I have no way to return it since I can't acces .data
I've tried looking at the objet log and indeed there is no .data on it. Why is this not being passed to the tune? What am I missing?