question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Question: how to get the instance ?

See original GitHub issue

Hi, I am a newbie. I had read the doc several times , but could not find how to get the instance. I try to use useRef to get the editor instance but fail. so is there any sample code to show me. Extra question , How to set a default text ? useState or other methods? I wish i can get the sample code.

@lexical/react: 0.3.7
lexical: 0.3.7

what i want is following code

function App (){
      const toggleReadOnly = () => {
        instance.setReadOnly(false)
      }
      const [defaultValue] = useState('Dude, typing something on here.')

     return <>
            <LexicalComposer  initialConfig={{
                      ...editorConfig,
                      readOnly: true,
                    }}
             />
                       <PlainTextPlugin
                              initialEditorState={defaultValue}
                              contentEditable={<ContentEditable className="editor-input" />}
                           />
            </LexicalComposer>
             <button onClick={toggleReadOnly}></button>
     </>
}

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
HZZformGDcommented, Jul 19, 2022

@HZZformGD Move everything within the context of LexicalComposer:

<LexicalComposer  initialConfig={{...editorConfig, readOnly: true }} >
    <CustomEditor />
</LexicalComposer>

You can set an editor as readOnly without needing to reset the initialConfig prop of the LexicalComposer component. Call editor.setReadOnly within your toggleReadOnly function instead.

Oh!!! Thx. I get it.

0reactions
thegreatercurvecommented, Jul 19, 2022

@HZZformGD Move everything within the context of LexicalComposer:

<LexicalComposer  initialConfig={{...editorConfig, readOnly: true }} >
    <CustomEditor />
</LexicalComposer>

You can set an editor as readOnly without needing to reset the initialConfig prop of the LexicalComposer component. Call editor.setReadOnly within your toggleReadOnly function instead.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to get the instance of class - Stack Overflow
I have made three classes classA, classB and classC in the same package. Now I make three objects of classA inside classB and...
Read more >
How to get instance name/key via API
I don't know if this will help or not, but in Workbench, you can go to Session Information > Connection > Endpoint and...
Read more >
General prerequisites for connecting to your instance
Get the ID of the instance. You can get the ID of your instance using the Amazon EC2 console (from the Instance ID...
Read more >
I want to get the instance ID from the item name.
I want to get the instance ID from the name of the item in the player's inventory. How can I do this? Player...
Read more >
Get instance name for JBOSS servers - ServiceNow Community
you should find your Instance ID in the standalone.xml in the config directory of JBOSS. In the pattern you can use "Parse File"...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found