52 Commits

Author SHA1 Message Date
Ben Ogle
0829da53b0 Properly unmount the component when the shadow DOM is enabled. 2014-12-16 14:36:51 -08:00
Max Brunsfeld
5c37d208f5 Don't throw when ::getDefaultCharacterWidth is called while detached 2014-12-08 16:56:46 -08:00
Max Brunsfeld
d03cfda6c4 📝 new TextEditorElement methods 2014-12-08 16:38:57 -08:00
Max Brunsfeld
8f02b21d08 Add TextEditorElement::onDidAttach, ::onDidDetach 2014-12-08 16:21:59 -08:00
Max Brunsfeld
953f2c61f7 Add TextEditorElement::getDefaultCharacterWidth 2014-12-08 16:14:26 -08:00
Max Brunsfeld
631bca6c89 Don't use a transaction in cursor/selection movement commands
Previously, a transaction was used to set an undo grouping interval
for every editor command except `undo` and `redo`. The problem is
that currently, moving a marker inside of a transaction causes the
buffer's redo stack to be cleared. For now, just don't use
transactions for commands that don't modify the buffer's contents."
2014-12-08 13:06:59 -08:00
Max Brunsfeld
4afe133f85 Allow setting editor text content in HTML 2014-12-05 09:30:33 -08:00
Max Brunsfeld
e4bcb96dcc Change ::setModel to ::initialize on all element classes 2014-12-01 17:52:19 -08:00
Kevin Sawicki
be2d49a410 Remove unused subscriptions ivar
Closes #4343
2014-12-01 08:37:51 -08:00
Nathan Sobo
b341749d54 Add TextEditorElement::setUpdatedSynchronously
To allow testing of async editor rendering in packages. This is helpful
for overlay decorations which behave differently when rendering is
async.

Signed-off-by: Max Brunsfeld <maxbrunsfeld@gmail.com>
2014-11-26 18:13:12 -07:00
Nathan Sobo
e62ecbab6b Work around chromium bug where focus gets stolen from shadow DOM
Fixes #4255
2014-11-21 11:04:42 -07:00
Nathan Sobo
95ec0d8162 Replaces usages of .mini selector with [mini] 2014-11-13 16:04:57 -08:00
Nathan Sobo
b6b6b6d12b Add ‘mini’ attribute to TextEditorElement if .isMini() is true on model 2014-11-13 16:04:57 -08:00
Nathan Sobo
ed6ca9cd06 Remove .editor class to force themes to style background via :host
The goal is to allow the editor’s styling to be overridden as follows:

atom-text-editor {
  background: black;
  color: white;
}

If we retain these classes, themes will continue to style the root
element of the editor and destroy the ability to style the editor in
this way. You would instead have to do the following:

atom-text-editor::shadow .editor {
  background: black;
  color: white;
}

This is way less intuitive and confusing for people.
2014-11-13 16:04:57 -08:00
Nathan Sobo
08971562cd Store useShadowDOM setting when TextEditorElement is created
Rather than reading it repeatedly, since the value could potentially
change over time.
2014-11-13 16:04:56 -08:00
Nathan Sobo
99b08826dd Style non-shadow DOM editor with it’s own style sheet
Trying to style both modes of the text editor with the same style sheet
is proving to be more trouble than it’s worth. This prepares the shadow
DOM style sheet to diverge more radically to enable the background color
to be overridden from the outside more easily.
2014-11-13 16:04:24 -08:00
Max Brunsfeld
003c101f14 W/o shadow-dom, don't add global atom-styles element for text editor
Signed-off-by: Nathan Sobo <nathan@github.com>
2014-11-07 13:05:46 -08:00
Max Brunsfeld
d97c81bf6a Make undo grouping interval configurable 2014-11-06 09:25:10 -08:00
Max Brunsfeld
d85c07e7e2 Don't wrap undo/redo calls in transactions 2014-11-05 16:59:06 -08:00
Max Brunsfeld
4077e791c9 Update signature of calls to TextBuffer::transact 2014-11-05 15:58:13 -08:00
Max Brunsfeld
e7eef89fa5 Remove TextEditor::withGroupingInterval
Just use ::transact
2014-11-05 15:58:13 -08:00
Max Brunsfeld
5437236304 Use undo grouping in editor command listeners 2014-11-05 15:58:13 -08:00
Nathan Sobo
670b44f250 Only set both height and width of editor when shadow DOM is used
These work inside a shadow root, but break the flexbox behavior when
the shadow DOM is disabled.
2014-11-05 11:21:29 -07:00
Nathan Sobo
39cc463e24 Add .editor and .editor-colors classes regardless of shadow DOM setting 2014-11-05 09:57:13 -07:00
Nathan Sobo
badf1725fa Handle focus on hidden input when shadow DOM is disabled
Signed-off-by: Max Brunsfeld <maxbrunsfeld@gmail.com>
2014-11-04 16:37:29 -07:00
Nathan Sobo
100af7d27d Fix corner cases related to lifecycle state of EditorComponent on events
Signed-off-by: Max Brunsfeld <maxbrunsfeld@gmail.com>
2014-11-04 16:37:28 -07:00
Nathan Sobo
9b70cf2044 Make blur event on text editor element work with shadow DOM disabled
When the shadow DOM is enabled, this happens organically because the
focus is abstracted across the shadow boundary. Without that abstraction
boundary, we need to pretend that a blur of the hidden input is actually
a blur of the entire editor.

Signed-off-by: Max Brunsfeld <maxbrunsfeld@gmail.com>
2014-11-04 16:37:28 -07:00
Nathan Sobo
7fe9c14772 💄 2014-11-04 16:37:28 -07:00
Nathan Sobo
9690e44ffe Correctly handle focus when shadow DOM is disabled
Signed-off-by: Max Brunsfeld <maxbrunsfeld@gmail.com>
2014-11-04 16:37:27 -07:00
Nathan Sobo
0e57ede712 Only create a shadow root if editor.useShadowDOM config setting is true
Signed-off-by: Max Brunsfeld <maxbrunsfeld@gmail.com>
2014-11-04 16:37:27 -07:00
Nathan Sobo
dd7335c30b Simplify focus/blur handling
Signed-off-by: Max Brunsfeld <maxbrunsfeld@gmail.com>
2014-11-04 16:37:27 -07:00
Nathan Sobo
160bb29034 Null-guard component in blur handler 2014-11-04 16:37:27 -07:00
Nathan Sobo
6f3c53a17a Only cancel focus events if the editor is or contains the related target 2014-11-04 16:37:26 -07:00
Nathan Sobo
cf3f1aa2eb Don’t handle text editor focus when it already has focus 2014-11-04 16:37:26 -07:00
Nathan Sobo
eb19989ecd Handle focus at the host element level
Detecting focus and blur at the level of the input is creating problems
when we blur and then immediately refocus. This is simpler.
2014-11-04 16:37:25 -07:00
Nathan Sobo
b2bc09c13d Apply stylesheets with atom-editor-context in text editor specs 2014-11-04 16:37:22 -07:00
Nathan Sobo
2ab5fa405c Apply mini and is-focused class to both editor host element and root
This preserves existing theming behavior
2014-11-04 16:37:22 -07:00
Nathan Sobo
5f4fb23057 Initialize atom-styles element in editor shadow dom before measuring 2014-11-04 16:37:22 -07:00
Nathan Sobo
582066915b Apply syntax theme stylesheets in text editor shadow DOM via atom.styles 2014-11-04 16:37:21 -07:00
Nathan Sobo
c2d0b6d4f5 Load editor stylesheet in shadow root with style manager context param 2014-11-04 16:37:21 -07:00
Nathan Sobo
963c92eb4e Hack: Add editor stylesheets to atom-text-editor shadow root 2014-11-04 16:37:20 -07:00
Nathan Sobo
22212be90d Give atom-text-editor elements a shadow root
Themes aren’t applying correctly and there are issues with mini editors
but this basically works. I’m leaving the .editor node in the shadow
DOM for theme compatibility and because React still wants to render
into a wrapper element.
2014-11-04 16:37:20 -07:00
Kevin Sawicki
2e0bb66a9a Remove unneeded add encoding attr call 2014-10-29 16:03:57 -07:00
Kevin Sawicki
d205c4d664 Add data attribute for encoding
Mirrors the grammar data attribute
2014-10-29 16:03:10 -07:00
Nathan Sobo
02d20e3155 Call legacy SpacePen remove hooks before unmounting TextEditorComponent 2014-10-27 15:29:59 -06:00
Nathan Sobo
2910e017bb Unmount TextEditorComponent when TextEditor is destroyed
We don’t want to do it when the element is detached because it might
be caused by moving the editor rather than destroying it. Unmounting
the component entirely and then remounting it causes the hidden input
to not be recycled, interfering with focus restoration. Watching for
destruction of the model is a good way to ensure we always tear down
the view at the right time without doing it prematurely.
2014-10-27 15:12:30 -06:00
Nathan Sobo
2965398062 Throw on non-release builds if translating positions on destroyed editor
It’s possible that bundled packages stray into this corner case, so I’d
like us to catch and fix misbehaving packages before exposing users to 
any exceptions. Once we go one release with this turned on, we can
enable the exception for all builds.
2014-10-27 07:38:18 -06:00
Nathan Sobo
1eb3d8bf99 Use ‘atom-text-editor’ custom tag name for TextEditorElement 2014-10-09 07:39:14 -07:00
Nathan Sobo
fab0ac814d Fix checkout-head-revision command 2014-10-08 12:13:13 -07:00
Nathan Sobo
eaa3a27328 Add text-editor-element-spec and fix handling of focus and attributes 2014-10-08 12:13:13 -07:00