我正在使用Editor.js,但我不知道如何通过 javascript 在编辑器中添加新块,例如
我已经通过 docs 创建了编辑器:
const editor = new EditorJS({
holderId: 'codex-editor',
autofocus: true,
data: {
"time": 1550476186479,
"blocks": [
{
type: 'paragraph',
data: {
text: 'Hello world'
}
}
]
},
onReady: () => {
console.log('Editor.js is ready to work!');
}
})
但我无法添加任何新文本,我尝试了以下方法:
const newBlock = {
type: 'paragraph',
data: {
text: 'Hello world'
}
};
editor.configuration.data.blocks.push(newBlock);
它没有帮助,editor.configuration.data.blocks
更新自己的值,但添加的值不会显示在 Editor.js 视图中。