You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I created a custom mode, with its own folding rules. The folds show up, but we would like the editor to load with everything folded. We load the editor with a saved value.
If I call editor.getSession().foldAll(); too early, it doesn't do anything because the editor hasn't finished loading.
Is there an event that is emitted after setValue is called? Or another way to handle this issue?
Any advice wold be greatly appreciated!
Sample code to reproduce your issue
I use a ref to keep track of the component like so public render() { return (<AceEditor mode="sql" theme="textmate" focus={true} onChange={this.handleChange} name="ace-editor" value={this.state.query} style={editorFont} ref={this.reactAceRef} />); }
and I've tried this: public componentDidMount() { const customMode = new HiveMode(); if (this.reactAceRef.current) { this.reactAceRef.current.editor.getSession().setMode(customMode); this.reactAceRef.current.editor.getSession().foldAll(); } }
But that's too early in the lifecycle of the component to fold.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Problem
I created a custom mode, with its own folding rules. The folds show up, but we would like the editor to load with everything folded. We load the editor with a saved value.
If I call editor.getSession().foldAll(); too early, it doesn't do anything because the editor hasn't finished loading.
Is there an event that is emitted after setValue is called? Or another way to handle this issue?
Any advice wold be greatly appreciated!
Sample code to reproduce your issue
I use a ref to keep track of the component like so
public render() { return (<AceEditor mode="sql" theme="textmate" focus={true} onChange={this.handleChange} name="ace-editor" value={this.state.query} style={editorFont} ref={this.reactAceRef} />); }and I've tried this:
public componentDidMount() { const customMode = new HiveMode(); if (this.reactAceRef.current) { this.reactAceRef.current.editor.getSession().setMode(customMode); this.reactAceRef.current.editor.getSession().foldAll(); } }But that's too early in the lifecycle of the component to fold.
References
Progress on: #
Beta Was this translation helpful? Give feedback.
All reactions