【发布时间】:2022-11-20 06:46:04
【问题描述】:
我在我的 ReactJS 应用程序中使用 Editor.js。一切都很完美,除了我无法将唯一的块 ID 作为“id”属性传递。
例如,数据是:
{
"time": 1658299444298,
"blocks": [
{
"id": "sheNwCUP5A",
"data": {
"text": "Acceptable Use Policy",
"level": 2
},
"type": "header"
}
],
"version": "2.25.0"
}
DOM树是
<div class="codex-editor__redactor" style="padding-bottom: 300px;">
<div class="ce-block">
<div class="ce-block__content">
<h2 class="ce-header" contenteditable="false" data-placeholder="">Audit Policy</h2>
</div>
</div>
</div>
要在当前文档中实现锚链接,我需要为从数据传递的每个元素设置“id”属性。
...
<h2 id="sheNwCUP5A" class="ce-header" contenteditable="false" data-placeholder="">Audit Policy</h2>
...
有什么建议吗?
【问题讨论】:
标签: javascript html reactjs editorjs