lexicaljs - 如何将词法编辑器设置为只读模式

标签 lexicaljs

我正在使用 Facebook 的词法编辑器,但很难将编辑器设置为只读模式。

为了尝试它,我设置了 readyOnly 属性,但没有成功:

 <ContentEditable readOnly={false} className="editor-input" />

这是完整的代码

    <LexicalComposer initialConfig={editorConfig}>
      <div className="editor-container">
        <ToolbarPlugin />
        <div className="editor-inner">
          <RichTextPlugin
            contentEditable={
              <ContentEditable readOnly={true} className="editor-input" />
            }
            placeholder={<Placeholder />}
          />
          <HistoryPlugin />
          {/* <TreeViewPlugin />  */}
          <AutoFocusPlugin />
          <CodeHighlightPlugin />
          <ListPlugin />
          <LinkPlugin />
          <AutoLinkPlugin />
          <ListMaxIndentLevelPlugin maxDepth={7} />
          <MarkdownShortcutPlugin transformers={TRANSFORMERS} />
        </div>
      </div>
      <OnChangePlugin
        onChange={onChange}
        ignoreSelectionChange
        ignoreHistoryMergeTagChange
      />
      <TextLoader note={note} />
    </LexicalComposer>

最佳答案

你可以通过这样的initialConfig来完成

const editorConfig = {
   namespace: 'blahblah',
   editable: false,
   ....
}

<LexicalComposer initialConfig={editorConfig}

关于lexicaljs - 如何将词法编辑器设置为只读模式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/74494777/

相关文章:

lexicaljs - 如何使用词法编辑器以编程方式添加文本?

draftjs - 我们可以在每个单词上存储元数据,让用户修改它并仍然保留它吗?

reactjs - 可以在每次渲染时取消订阅并重新订阅我的所有 @Lexical/react 命令监听器吗?

reactjs - 无法将 Lexical 解析为 HTML