Commit Graph

15110 Commits

Author SHA1 Message Date
Nathan Sobo
a271e52a4e Never assign a 0 height or width when measuring editor scroll view 2014-04-22 17:10:22 -06:00
Nathan Sobo
274ca33959 Don't measure height and width unless component is mounted
Since we measure in requestAnimationFrame, it's possible to request
measurement prior to be unmounted and have it occur afterward.
2014-04-22 17:10:22 -06:00
Nathan Sobo
10d6ec156f Unsubscribe EditorComponent before unmounting 2014-04-22 17:10:22 -06:00
Nathan Sobo
4e27e765d0 Measure width and height when window size changes
Since overflowchanged events are paused for a bit after updates to
prevent thrashing, this ensures the editor is still updated promptly
when resizing.
2014-04-22 17:10:22 -06:00
Nathan Sobo
168cda4f75 Pause measurement on overflowchanged during updates
Content updates trigger overflowchanged, but we're mainly using it to
detect when the editor component has been resized. Pausing measurement
during content updates makes them faster.
2014-04-22 17:10:21 -06:00
Nathan Sobo
fdccc0bcc2 Measure DOM dimensions before rendering elements that depend on them
This commit breaks the initial render of the editor component into two
stages.

The first stage just renders the shell of the editor so the height,
width, line height, and default character width can be measured. Nothing
that depends on these values is rendered on the first render pass.

Once the editor component is mounted, all these values are measured and
we force another update, which fills in the lines, line numbers,
selections, etc.

We also refrain from assigning an explicit height and width on the
model if these values aren't explicitly styled in the DOM, and just
assume the editor will stretch to accommodate its contents.
2014-04-22 17:10:21 -06:00
Nathan Sobo
d566726b9f Use negative z-indices so attached views are visible in react editor 2014-04-22 17:10:21 -06:00
Nathan Sobo
e9f2a536ed Add more shims to ReactEditorView 2014-04-22 17:10:21 -06:00
Nathan Sobo
2532527a6a Add editor-colors class to EditorComponent 2014-04-22 17:10:21 -06:00
Nathan Sobo
f10076c87d Prevent activation events from bubbling
The react editor is wrapped in another div with the class of .editor for
backward compatibility. This prevents activation events registered on
the .editor selector from being triggered twice.
2014-04-22 17:10:21 -06:00
Nathan Sobo
083f65ed5d Remove envify dependency 2014-04-22 17:10:21 -06:00
Nathan Sobo
f59a8f1e68 Return function arg's result from Editor::batchUpdates 2014-04-22 17:09:45 -06:00
Nathan Sobo
bef554709f Emit 'cursor:moved' event to update cursor position in status bar
Emitting the event *before* update, rather than after. This is because
we read from the DOM after update to measure new characters, which
forces layout, so emitting the event after measuring forces another
layout when the position is updated.
2014-04-22 17:09:45 -06:00
Nathan Sobo
e5379515b9 Transfer focus to ReactComponent when wrapper view is focused 2014-04-22 17:09:45 -06:00
Nathan Sobo
a0ff6f5325 Handle 'autoscroll' option in model when setting selected buffer range 2014-04-22 17:09:45 -06:00
Nathan Sobo
dd4b6a6d28 Don't render empty selections 2014-04-22 17:09:45 -06:00
Nathan Sobo
51ee591282 Don't render cursors for non-empty selections 2014-04-22 17:09:45 -06:00
Nathan Sobo
19a5269a5f Remove metaprogrammed method delegators 2014-04-22 17:09:45 -06:00
Nathan Sobo
9b6fa967be Handle the editor:consolidate-selections command in the React editor 2014-04-22 17:09:45 -06:00
Nathan Sobo
201e00aa83 Don't measure new lines when scrolling with the mousewheel
It impacts scrolling performance. We can measure when scrolling comes
to a halt.
2014-04-22 17:09:44 -06:00
Nathan Sobo
f02d956362 Preserve the only the target screen row when scrolling via mousewheel
When the target of a mousewheel event is removed, it breaks velocity
scrolling.

Previously, we were preserving the entire screen range when scrolling
with the mouse wheel, which caused a lot of DOM nodes to accumulate. Now
we only preserve the individual line and line number associated with the
target of the mousewheel event, moving them just off screen below all
the on-screen lines and line numbers. This keeps the number of DOM nodes
limited while retaining velocity effects.
2014-04-22 17:09:44 -06:00
Nathan Sobo
798739f837 Use beforeRemove instead of non-existent beforeDetach 2014-04-22 17:09:44 -06:00
Nathan Sobo
216d561c79 Delay creating range and node iterator until we actually need to measure 2014-04-22 17:09:44 -06:00
Nathan Sobo
6607f99c6c Use padding-top/bottom rather than spacer divs in lines and gutter
It creates a simpler DOM structure.
2014-04-22 17:09:44 -06:00
Nathan Sobo
3a42346e5e Pause cursor blink as part of the overall editor update
This ensures we don't perform two updates of the cursors component when
cursors move as part of a larger change, such as typing text.
2014-04-22 17:09:44 -06:00
Nathan Sobo
ae9f79bfc4 Only add indent guide to trailing whitespace on whitespace-only lines 2014-04-22 17:09:44 -06:00
Nathan Sobo
5a9a3c62e1 Implement shouldComponentUpdate for LinesComponent
We accumulate pending changes and pass them to the lines and the gutter
to help them determine whether to update. The lines only update if the
visible row range changed or if there was a change in the visible row
range.
2014-04-22 17:09:44 -06:00
Nathan Sobo
d678f367db Clear cursor blink interval when editor component unmounts 2014-04-22 17:09:44 -06:00
Nathan Sobo
febfb120c8 Fix typo 2014-04-22 17:09:44 -06:00
Nathan Sobo
addbe80e8a Update the gutter if the scrollTop has changed 2014-04-22 17:09:44 -06:00
Nathan Sobo
b96abfffb7 Add more displayNames 2014-04-22 17:09:44 -06:00
Nathan Sobo
a6f2e926fe Upgrade to underscore-plus@1.2.1 for optimized isEqualForProperties 2014-04-22 17:09:44 -06:00
Nathan Sobo
550a4ce906 Use isEqualForProperties in LinesComponent to decide when to re-measure 2014-04-22 17:09:43 -06:00
Nathan Sobo
1a56b487a1 Stop propagation of input events to prevent react from doing extra work
React seems to be handling these events when they bubble to the root of
the document. We want to avoid wasting time on this.
2014-04-22 17:09:43 -06:00
Nathan Sobo
4fa9c64c2b Drop batchedUpdates on input since we're batching in the model anyway 2014-04-22 17:09:43 -06:00
Nathan Sobo
56e5fb7a63 Set process.env.NODE_ENV to 'production' to speed up React 2014-04-22 17:09:43 -06:00
Nathan Sobo
efa72bcb1c Implement shouldComponentUpdate for GutterComponent
Only update the gutter when the visible row range has changed or if
a screen lines change has occurred within the visible row range.
2014-04-22 17:09:43 -06:00
Nathan Sobo
033db8997b Batch updates when moving cursors
This ensures that updates associated with autoscroll and cursor movement
get combined.
2014-04-22 17:09:43 -06:00
Nathan Sobo
64a487eebb Implement shouldComponentUpdate for ScrollbarComponent
It checks that the incoming scrollTop/Left and scrollHeight/Width differ
from their current values. The scrollTop/Left value are updated in
the component properties to always reflect the state of the DOM when
scrolling or when assigning a new value.
2014-04-22 17:09:43 -06:00
Nathan Sobo
ddc677fb30 Batch multiple view updates with Editor::batchUpdates 2014-04-22 17:09:43 -06:00
Nathan Sobo
fe6a007774 Call requestUpdate instead of forceUpdate so we can track all updates 2014-04-22 17:09:43 -06:00
Nathan Sobo
48d90e3dfc Funnel cursor and selection updates through EditorComponent 2014-04-22 17:09:43 -06:00
Nathan Sobo
f457b41a81 Assign a key to cursor and selection components 2014-04-22 17:09:43 -06:00
Nathan Sobo
93388c2048 Make Cursor and Selection models for automatic id assignment 2014-04-22 17:09:43 -06:00
Nathan Sobo
66f3f2d883 Add displayName to components 2014-04-22 17:09:42 -06:00
Nathan Sobo
3657dc0bf4 💄 2014-04-22 17:09:42 -06:00
Nathan Sobo
274288161d Make line number components immutable 2014-04-22 17:09:42 -06:00
Nathan Sobo
0d03e388f1 💄 spec description 2014-04-22 17:09:42 -06:00
Nathan Sobo
507106d35b 💄 method order 2014-04-22 17:09:42 -06:00
Nathan Sobo
eeba559ec7 Add a SelectionsComponent containing all selections 2014-04-22 17:09:42 -06:00