0

当我写

<a data-x='test' href='testlink' target='_blank'>testlinnk</a>

在一个字符串中,我尝试通过我在编辑器中得到的代码将它添加到编辑器中

<a href='testlink' target='_blank'>testlinnk</a>

任何建议如何使用 a 标签将 data-x='test' 带到编辑器?

这是我的代码

const readMoreLink = ` <a data-x='test' href='testlink' target='_blank'>testlinnk</a>`;

const newContent = Modifier.replaceWithFragment(
 editorState.getCurrentContent(),
 editorState.getSelection(), 
 BlockMapBuilder.createFromArray(htmlToDraft(readMoreLink).contentBlocks)
);
  
  const newState = EditorState.push(
    editorState,
    newContent,
    "insert-fragment"
  );
4

0 回答 0