react-rte toolbarConfig={[]} 和 showToolbar={false}

react-rte toolbarConfig={[]} and showToolbar={false}

我正在尝试从 react-rte 中删除工具栏,所以我尝试了

        toolbarConfig={[]},
        showToolbar={false}

我只是想展示一些html,仅此而已

但它给了我这个:

如何在 react-rte 中删除工具栏?

codesandbox.io

好像没有showToolbar这样的选项。您可以将 readOnly 选项设置为 true,这将阻止工具栏的呈现(参见 RichtTextEditor.js:122.). Check this Codesandbox, please note that I used createValueFromString(...) (Source) for state initialization (requires the markup as string and a format option (string) ). You can adapt the format of the markup, I've used html for the sandbox (See available all available options here)。此外,请随意删除 toolbarConfig 参数,您的用例不需要它。

配置你想在 toolbarConfig 变量中显示的内容,如果你 want.this 有效,请删除所有内容,刚刚测试过。

const toolbarConfig = {
  display: [],
};

然后在你的 JSX 中

        <RichTextEditor
          toolbarConfig={toolbarConfig}
        />

这有效