codex-team / codex-team/editor.js

Is there any way to get the block data inside Blocktune API

Open
#2,378 1 comment 1 reaction 0 assignees View on GitHub
Dominant language
TypeScript
Stars
31.9k
Forks
2.2k
Avg merge
1d 1h
Merged PRs (30d)
1

Description

The question.

Why and how the question has come up.

I am trying to create a copy method inside editorjs for customized and native blocks. In the block API I am getting data = 'undefined;

```
class DuplicateBlockTune {
static get isTune() {
return true;
}
constructor({ api, data, block, config }) {
// console.log({ api, data, block, config }) = there is no value in data and config fields
this.api = api;
this.block = block; - inside block.holder I am getting HTML block
this.wrapper = null;
}
...
```

is there any way I can get the normal JSON data of current block.

I am trying to create a new block with fake data,
```
async duplicateBlock() {
const selectedBlock = this.block;

if (selectedBlock) {
const { name, holder } = selectedBlock

const defaultBlockData = await this.api.blocks.composeBlockData(name);
const blockDataOverrides = { someProp: 'someValue' }; // TODO:: need to get the current block data
const blockData = Object.assign(defaultBlockData, blockDataOverrides);

const duplicateData = JSON.parse(JSON.stringify(blockData));
this.api.blocks.insert(name, duplicateData);
}
}
```

how to get the JSON data?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.