如何实现块的生命周期钩子?
https://editorjs.io/tools-api#lifecycle-hooks
我有这个:
let config = {
/**
* Id of Element that should contain the Editor
*/
holder : 'alinea-5',
/**
* Available Tools list.
* Pass Tool's class or Settings object for each Tool you want to use
*/
tools: {
header : Header,
list : List
}
};
const elEditorData = document.querySelector('.js-editor-data');
if (elEditorData.value) {
config.data = {};
config.data.blocks = JSON.parse(elEditorData.value);
}
new EditorJS(config);
正如你所看到的,有一些editor.js的东西在那里。
我需要清理我的html当删除一个块。现在我必须做一些与生命周期挂钩"删除",但如何?当删除块通过工具栏我想清理整个html块:
document.querySelector('.alinea-5').remove();
这是否干扰了文档中关于删除事件的说明?
removed:在从页中移除Block内容后但在删除Block示例前调用
1条答案
按热度按时间2exbekwf1#
块生命周期钩可在块内使用: