Skip to content
This repository was archived by the owner on Mar 3, 2023. It is now read-only.

Make react the default editor - #2423

Merged
benogle merged 1 commit into
masterfrom
cj-make-react-the-default-editor
Jul 22, 2014
Merged

benogle merged 1 commit into
masterfrom
cj-make-react-the-default-editor

Conversation

@probablycorey

Copy link
Copy Markdown

This will make react the default editor.

All issues related to the react editor: https://github.com/atom/atom/issues?labels=react-editor-bug

Todo

These are the blockers to releasing the react editor as the default

  • Do a pass on React updates and see if we can boost cursor and text insertion performance

Completed Tasks

Fixes these issues

Fixes #2443
Fixes #1850
Fixes #1790
Fixes #1711
Fixes #2778
Fixes #2764
Fixed #2710
Fixed #2785
Fixed atom/find-and-replace#245
Fixes #2375

@nathansobo

Copy link
Copy Markdown
Contributor

I added a checkbox for getting the build green. It's hard coded to use the old editor in specs currently.

@lee-dohm

Copy link
Copy Markdown
Contributor

Will the old editor architecture be removed? If so, should this Issue be renamed to "Make react the editor"? 😀

@benogle

benogle commented May 29, 2014

Copy link
Copy Markdown
Contributor

I think we should keep the old stuff in there for a bit after switching to the default. But eventually, yes.

@lee-dohm

Copy link
Copy Markdown
Contributor

Thanks @benogle! I figured that was the case.

@smashwilson

Copy link
Copy Markdown
Contributor

I'm assuming the class names (EditorView, ReactEditorView) will stay intact?

Actually, should ReactEditorView be exported through the atom global, too? I'm using not instanceof EditorView to toggle behavior off of the editor type at present, which feels a little brittle, especially if the eventual plan would be to make ReactEditorView the new EditorView...

@thedaniel

Copy link
Copy Markdown
Contributor

Perhaps an is_react attribute on that class or is_legacy on the other would be worth adding to smooth this transition.

@smashwilson

Copy link
Copy Markdown
Contributor

Perhaps an is_react attribute on that class or is_legacy on the other would be worth adding to smooth this transition.

Actually, an easier option would be for me to just check the CSS classes applied to the view -- the react editor has a react-wrapper class on its root element. That seems less invasive, and more tolerant of cases when the active view isn't an EditorView at all, for example. 💭

@benogle benogle mentioned this pull request May 29, 2014
2 of 3 tasks
@balupton

Copy link
Copy Markdown

A few bugs?

Double clicking a word, then typing, does not overtype the word.

Spellcheck is also enabled for my javascript code, not the case with the non-react editor.

@probablycorey

Copy link
Copy Markdown
Author

@ustun thanks for the correction.

@probablycorey

Copy link
Copy Markdown
Author

Thanks for mentioning those problems @balupton. I created issues for both of them #2459 #2460.

@balupton

Copy link
Copy Markdown

No worries, I'll create separate issue in the future :)

@nathansobo

Copy link
Copy Markdown
Contributor

Actually, an easier option would be for me to just check the CSS classes applied to the view -- the react editor has a react-wrapper class on its root element. That seems less invasive, and more tolerant of cases when the active view isn't an EditorView at all, for example. 💭

I definitely agree that we shouldn't be using instanceof checks for this kind of situation, but I'm not sure that classes are going to work out long-term either. Eventually, I'd like to move away from the assumption that views are always jQuery wrappers around DOM fragments. They could be React components, for example. My ideal situation for views would be any object that exposes a ::getDOMNode() method, and maybe a couple other methods related to lifecycle as part of its interface.

The hasClass method is super easy to shim, however, so I think it's safe to use for now. I wonder though, how can we ask views what they are or what kind of documents they edit without resorting to explicit type checks? Would the view exposing a particular interface be enough? Would we want to ask the view "are you a text editor", "are you an image editor"? I'd like to be able to register particular editors for different types of documents. Maybe we can use that same system to get notified of every current and future editor for a particular resource type.

@ilanbiala

Copy link
Copy Markdown

What's the benefit of using the react editor instead of the current editor?

@lee-dohm

Copy link
Copy Markdown
Contributor

@nathansobo For identifying what document type an editor is for, I think we could use either the language specifier scheme, i.e. .source.ruby or .image.jpeg, or MIME types.

As far as determining whether something is an editor or a settings view or some other type of view ... I like the approach taken in Avdi Grimm's Confident Ruby. It's a form of the maxim, "Tell, Don't Ask". Rather than asking something "Are you an editor?" and then doing something with it if it is, you just say "Convert yourself to an editor" and then do something with it if it doesn't return null. I envision something like this:

class Foo
  frobTheEditor: (editor) ->
    editor.toEditor()?.frob()

That way if a SettingsView gets passed in, everything is just fine because nothing happens (unless you want to implement toEditor() to throw an exception on SettingsView). But if something that isn't an editor, but can act like an editor gets passed in ... it can implement the toEditor() method and poof ... magic.

@nathansobo

Copy link
Copy Markdown
Contributor

@ilanbiala: I wrote a pretty good explanation of the motivation in #1863. For users, the main benefits will hopefully be that it puts us in a better position to improve performance and add APIs to the editor. For core developers, the new editor will be easier to maintain.

Edit: Of course, we want users to be comfortable sending PRs on core, too, and this will help that.

@ilanbiala

Copy link
Copy Markdown

@nathansobo sounds like a good plan. Ultimately, the biggest issue I have with Atom right now is that it is quite slow in comparison to other text editors and it still lacks some features that I would expect out of the box. As of now, I am using the React Editor; however, I have not noticed any real speed difference. I'd love to see Atom get better and faster, so let me know if there's anything I can do to help.

@abe33 abe33 mentioned this pull request Jun 4, 2014
1 of 6 tasks
benogle added a commit that referenced this pull request Jun 12, 2014
Previously it was only moving the scrollTop, but not the cursors. 
Affected on the react editor.

Refs #2423
benogle added a commit that referenced this pull request Jun 12, 2014
When you had a 1000 line file and you fold everything
into 10 lines, it would make the gutter width only large
enough for the 10 lines, so line 999 wouldnt properly
fit in the gutter.

Refs #2423
Comment thread spec/workspace-view-spec.coffee Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be removed from this PR.

@nathansobo

Copy link
Copy Markdown
Contributor

The last remaining issue is performance related but absolutely needs to be fixed before we flip the default. It makes performance pretty bad in the presence of large quantities of nested folds.

benogle added a commit that referenced this pull request Jul 22, 2014
@benogle
benogle merged commit 36f1ebf into master Jul 22, 2014
@benogle
benogle deleted the cj-make-react-the-default-editor branch July 22, 2014 15:59
@probablycorey

Copy link
Copy Markdown
Author

👍 💥 👍

@nathansobo

Copy link
Copy Markdown
Contributor

Just fixed so many issues w00t.

@batjko

batjko commented Jul 22, 2014

Copy link
Copy Markdown
Contributor

👍 Quite the milestone!

@mdibaiee

Copy link
Copy Markdown

👍 💥

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.