You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Retrieve block details once and use throughout
const block = this.api.blocks.getBlockByIndex(blockIndex);
console.log('Block data:', block.data, 'Block index:', blockIndex);
if (!block || !block.id) {
throw new Error('No valid ID for the current block.');
}
const originalText = block.data?.text; // Using optional chaining for safety
console.log(block);
Block data is undefined, how do I retrieve the contents of a block, such as the text of a paragraph of heading? Or a list content?
The text was updated successfully, but these errors were encountered:
export default class MyBlockTune { static get isTune() { return true; } constructor({ api, data, config, block }) { this.api = api; this.data = data; this.config = config; this.block = block; console.log('Constructor called'); console.log('Constructor data:', data); console.log('Constructor block:', block); // Set up a listener for when the block data might change }
why?!
here is the initiation:
`const editor = new EditorJS({
holder: 'editorjs',
data: {
blocks: articleBlocks,
},
tools: {
myBlockTune: {
class: MyBlockTune,
config: {
// Important: Does your tune need specific data to work?
// Example
},
},
header: {
class: Header,
},
paragraph: {
class: Paragraph,
tunes: ['myBlockTune'], // Add the tune to the header tool
},
list: List,
image: Image,
// Add more tools as needed
},
});`
// Retrieve block details once and use throughout
const block = this.api.blocks.getBlockByIndex(blockIndex);
The text was updated successfully, but these errors were encountered: