Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do I add multiple tabs functionality in the react Ace editor ? , Can somebody please provide a workaround, I am beginner in programming, If somebody could help me out it would be great #786

Closed
mohsinxx365 opened this issue Feb 15, 2020 · 6 comments

Comments

@mohsinxx365
Copy link

Problem

Detail the problem here, including any possible solutions.

Sample code to reproduce your issue

References

Progress on: #

@mikebarkmin
Copy link

@mohsinxx365
Copy link
Author

Thanks for the info.

@mohsinxx365
Copy link
Author

But the above solution does not retain undo functionality .

@mikebarkmin
Copy link

mikebarkmin commented Mar 26, 2020

This is because we use one editor for all tabs. Think we would need to implement something likes this
ajaxorg/ace#1452 (comment)

Store each session in state and then reapplying it when the tab is changed.

@mohsinxx365
Copy link
Author

I will check it out .

@MatthewCaseres
Copy link

MatthewCaseres commented May 12, 2023

Having multiple editors and keeping some of them hidden seems like it will work for me, haven't tested extensively.

{tabs.map((tab, i) => (
        <AceEditor
          key={i}
          value={tab.content}
          mode="python"
          name={`CodeBlock_${i}`}
          fontSize="0.9rem"
          className="-mt-1 min-h-[4rem] overflow-clip rounded shadow-md"
          style={{ display: i === tabIndex ? 'block' : 'none' }}
          theme="idle_fingers"
          onChange={(newValue) =>
            dispatch({
              type: 'SET_TABS',
              payload: produce(tabs, (draft) => {
                draft[i].content = newValue
              }),
            })
          }
          width="100%"
          maxLines={Infinity}
          onLoad={editorOnLoad}
          editorProps={{ $blockScrolling: true }}
          setOptions={editorOptions}
        />
      ))}
      {showOutput && (
        <pre className=" overflow-auto text-left">
          <code>{stdout}</code>
          <code className="text-red-500">{stderr}</code>
        </pre>
      )}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants