yapp 3.0.8 → 4.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. package/README.md +7 -7
  2. package/example.js +1414 -1684
  3. package/lib/defaults.js +4 -4
  4. package/lib/example/div/sizeable/left.js +1 -1
  5. package/lib/example/div/sizeable/middle.js +1 -1
  6. package/lib/example/div/sizeable/right.js +1 -1
  7. package/lib/example/div/sizeable/top.js +1 -1
  8. package/lib/example/textarea/bnf.js +1 -1
  9. package/lib/example/textarea/lexicalEntries.js +1 -1
  10. package/lib/example/textarea/parseTree.js +1 -1
  11. package/lib/example/textarea/tokens.js +1 -1
  12. package/lib/example/view/javascript.js +1 -1
  13. package/lib/example/view/json.js +1 -1
  14. package/lib/example/view/xml.js +1 -1
  15. package/lib/example/view.js +23 -42
  16. package/lib/example/yapp.js +5 -3
  17. package/lib/gutter.js +7 -40
  18. package/lib/highlights.js +248 -0
  19. package/lib/lexer/javascript.js +1 -1
  20. package/lib/lexer/json.js +1 -1
  21. package/lib/lexer/plainText.js +1 -1
  22. package/lib/lexer/xml.js +1 -1
  23. package/lib/lineNumbers.js +13 -3
  24. package/lib/mixins/style.js +1 -1
  25. package/lib/parser/javascript.js +1 -1
  26. package/lib/parser/json.js +1 -1
  27. package/lib/parser/plainText.js +1 -1
  28. package/lib/parser/xml.js +1 -1
  29. package/lib/plugin/javascript.js +1 -1
  30. package/lib/plugin/json.js +1 -1
  31. package/lib/plugin/plainText.js +1 -1
  32. package/lib/plugin/xml.js +1 -1
  33. package/lib/plugin.js +1 -1
  34. package/lib/prettyPrinter.js +29 -145
  35. package/lib/processor/javascript.js +1 -1
  36. package/lib/processor/json.js +1 -1
  37. package/lib/processor/plainText.js +1 -1
  38. package/lib/processor/xml.js +1 -1
  39. package/lib/processor.js +1 -1
  40. package/lib/renderYappStyles.js +1 -1
  41. package/lib/richTextarea.js +5 -26
  42. package/lib/styles.js +1 -5
  43. package/lib/syntax.js +77 -19
  44. package/lib/token/significant/argument.js +1 -1
  45. package/lib/token/significant/attribute.js +1 -1
  46. package/lib/token/significant/comment.js +1 -1
  47. package/lib/token/significant/error.js +1 -1
  48. package/lib/token/significant/jsx/attributeName.js +1 -1
  49. package/lib/token/significant/jsx/tagName.js +1 -1
  50. package/lib/token/significant/name.js +1 -1
  51. package/lib/token/significant/string.js +1 -1
  52. package/lib/token/significant/variable.js +1 -1
  53. package/lib/utilities/content.js +1 -1
  54. package/lib/utilities/css.js +1 -1
  55. package/lib/utilities/plugin.js +1 -1
  56. package/lib/utilities/properties.js +1 -1
  57. package/lib/utilities/rules.js +1 -1
  58. package/lib/utilities/scrollbarThickness.js +1 -1
  59. package/lib/utilities/tokens.js +1 -1
  60. package/lib/yapp.js +34 -96
  61. package/package.json +1 -1
  62. package/src/defaults.js +1 -1
  63. package/src/example/view.js +8 -28
  64. package/src/example/yapp.js +3 -2
  65. package/src/gutter.js +9 -41
  66. package/src/highlights.js +70 -0
  67. package/src/lineNumbers.js +13 -2
  68. package/src/prettyPrinter.js +24 -134
  69. package/src/richTextarea.js +4 -28
  70. package/src/styles.js +0 -1
  71. package/src/syntax.js +20 -22
  72. package/src/yapp.js +49 -130
  73. package/lib/element/scrollable.js +0 -338
  74. package/src/element/scrollable.js +0 -166
@@ -2,164 +2,46 @@
2
2
 
3
3
  import withStyle from "easy-with-style"; ///
4
4
 
5
- import { React, Bounds, Element } from "easy";
5
+ import { React, Element } from "easy";
6
6
 
7
7
  import Gutter from "./gutter";
8
- import Syntax from "./syntax";
8
+ import Highlights from "./highlights";
9
+ import RichTextarea from "./richTextarea";
9
10
 
10
11
  class PrettyPrinter extends Element {
11
- getWidth() {
12
- const hidden = this.isHidden();
12
+ scrollHandler = (event, element) => {
13
+ const richTextarea = element, ///
14
+ scrollTop = richTextarea.getScrollTop(),
15
+ scrollLeft = richTextarea.getScrollLeft();
13
16
 
14
- if (hidden) {
15
- this.show();
16
- }
17
-
18
- const width = super.getWidth();
19
-
20
- if (hidden) {
21
- this.hide();
22
- }
23
-
24
- return width;
25
- }
26
-
27
- getHeight() {
28
- const hidden = this.isHidden();
29
-
30
- if (hidden) {
31
- this.show();
32
- }
33
-
34
- const height = super.getHeight();
35
-
36
- if (hidden) {
37
- this.hide();
38
- }
39
-
40
- return height;
41
- }
42
-
43
- scroll(scrollTop, scrollLeft) {
44
17
  this.scrollGutter(scrollTop ,scrollLeft);
45
18
  this.scrollSyntax(scrollTop, scrollLeft);
46
19
  }
47
20
 
48
21
  update(tokens) {
49
- let gutterWidth = this.getGutterWidth(),
50
- previousGutterWidth = this.getPreviousGutterWidth();
51
-
52
22
  this.updateSyntax(tokens);
53
-
54
23
  this.updateGutter(tokens);
55
-
56
- if (previousGutterWidth !== gutterWidth) {
57
- previousGutterWidth = gutterWidth; ///
58
-
59
- this.setPreviousGutterWidth(previousGutterWidth);
60
-
61
- this.resize();
62
- } else {
63
- gutterWidth = null;
64
- }
65
-
66
- return gutterWidth;
67
- }
68
-
69
- getInnerBounds(gutterWidth) {
70
- let top = 0,
71
- left = 0,
72
- width = this.getWidth(),
73
- height = this.getHeight();
74
-
75
- left += gutterWidth;
76
- width -= gutterWidth;
77
-
78
- const bounds = Bounds.fromTopLeftWidthAndHeight(top, left, width, height),
79
- innerBounds = bounds; ///
80
-
81
- return innerBounds;
82
- }
83
-
84
- resize() {
85
- const gutterWidth = this.getGutterWidth(),
86
- innerBounds = this.getInnerBounds(gutterWidth),
87
- syntaxBounds = innerBounds; ///
88
-
89
- this.positionGutter();
90
-
91
- this.setSyntaxBounds(syntaxBounds);
92
-
93
- return gutterWidth;
94
- }
95
-
96
- setBounds(bounds) {
97
- const top = bounds.getTop(),
98
- left = bounds.getLeft(),
99
- width = bounds.getWidth(),
100
- height = bounds.getHeight();
101
-
102
- this.position(top, left);
103
- this.setWidth(width);
104
- this.setHeight(height);
105
- }
106
-
107
- position(top, left) {
108
- top = `${top}px`;
109
- left = `${left}px`;
110
-
111
- const css = {
112
- top,
113
- left
114
- };
115
-
116
- this.css(css);
117
- }
118
-
119
- getPreviousGutterWidth() {
120
- const state = this.getState(),
121
- { previousGutterWidth } = state;
122
-
123
- return previousGutterWidth;
124
- }
125
-
126
- setPreviousGutterWidth(previousGutterWidth) {
127
- this.updateState({
128
- previousGutterWidth
129
- });
130
- }
131
-
132
- setInitialState() {
133
- const previousGutterWidth = 0;
134
-
135
- this.setState({
136
- previousGutterWidth
137
- })
138
24
  }
139
25
 
140
26
  childElements() {
141
- const { hiddenGutter, scrollbarThickness } = this.properties,
142
- hidden = hiddenGutter; ///
27
+ const { onChange, hiddenGutter, fancyScrollbars, hiddenScrollbars, scrollbarThickness } = this.properties,
28
+ hidden = hiddenGutter, ///
29
+ changeHandler = onChange; ///
143
30
 
144
31
  return ([
145
32
 
146
33
  <Gutter hidden={hidden} />,
147
- <Syntax scrollbarThickenss={scrollbarThickness} />,
34
+ <Highlights scrollbarThickness={scrollbarThickness} />,
35
+ <RichTextarea onScroll={this.scrollHandler} onChange={changeHandler} fancyScrollbars={fancyScrollbars} hiddenScrollbars={hiddenScrollbars} active />
148
36
 
149
37
  ]);
150
38
  }
151
39
 
152
40
  parentContext() {
153
41
  const context = this.getContext(),
154
- resizePrettyPrinter = this.resize.bind(this), ///
155
42
  updatePrettyPrinter = this.update.bind(this), ///
156
- scrollPrettyPrinter = this.scroll.bind(this), ///
157
- setPrettyPrinterBounds = this.setBounds.bind(this), ///
158
43
  parentContext = Object.assign({}, context, {
159
- resizePrettyPrinter,
160
- updatePrettyPrinter,
161
- scrollPrettyPrinter,
162
- setPrettyPrinterBounds
44
+ updatePrettyPrinter
163
45
  });
164
46
 
165
47
  return parentContext;
@@ -175,8 +57,6 @@ class PrettyPrinter extends Element {
175
57
  "getGutterWidth",
176
58
  "setSyntaxBounds"
177
59
  ]);
178
-
179
- this.setInitialState();
180
60
  }
181
61
 
182
62
  static tagName = "div";
@@ -186,16 +66,26 @@ class PrettyPrinter extends Element {
186
66
  };
187
67
 
188
68
  static ignoredProperties = [
69
+ "onChange",
189
70
  "hiddenGutter",
71
+ "hiddenGutter",
72
+ "noScrollbars",
73
+ "fancyScrollbars",
190
74
  "scrollbarThickness"
191
75
  ];
192
76
  }
193
77
 
194
78
  export default withStyle(PrettyPrinter)`
195
79
 
80
+ width: 100%;
81
+ height: 100%;
82
+ display: grid;
196
83
  overflow: hidden;
197
- position: absolute;
198
84
 
85
+ grid-template-rows: auto;
86
+ grid-template-columns: min-content auto;
87
+ grid-template-areas: "gutter syntax";
88
+
199
89
  color: inherit;
200
90
  border-color: inherit;
201
91
  background-color: inherit;
@@ -7,29 +7,6 @@ import { scrollbarThickness, scrollbarThumbBorderRadius } from "./styles";
7
7
  import { selectionColour, backgroundColour, selectionBackgroundColour, scrollbarThumbBoxShadowColour, scrollbarThumbBackgroundColour } from "./scheme/colour";
8
8
 
9
9
  export default withStyle(class extends RichTextarea {
10
- position(top, left) {
11
- top = `${top}px`;
12
- left = `${left}px`;
13
-
14
- const css = {
15
- top,
16
- left
17
- };
18
-
19
- this.css(css);
20
- }
21
-
22
- setBounds(bounds) {
23
- const top = bounds.getTop(),
24
- left = bounds.getLeft(),
25
- width = bounds.getWidth(),
26
- height = bounds.getHeight();
27
-
28
- this.position(top, left);
29
- this.setWidth(width);
30
- this.setHeight(height);
31
- }
32
-
33
10
  didMount() {
34
11
  const { fancyScrollbars, hiddenScrollbars } = this.properties;
35
12
 
@@ -60,14 +37,12 @@ export default withStyle(class extends RichTextarea {
60
37
 
61
38
  parentContext() {
62
39
  const getContent = this.getContent.bind(this), ///
63
- setRichTextareaBounds = this.setBounds.bind(this), ///
64
40
  getRichTextareaContent = this.getContent.bind(this), ///
65
41
  setRichTextareaContent = this.setContent.bind(this), ///
66
42
  setRichTextareaReadOnly = this.setReadOnly.bind(this); ///
67
43
 
68
44
  return ({
69
45
  getContent,
70
- setRichTextareaBounds,
71
46
  getRichTextareaContent,
72
47
  setRichTextareaContent,
73
48
  setRichTextareaReadOnly
@@ -79,7 +54,8 @@ export default withStyle(class extends RichTextarea {
79
54
  };
80
55
 
81
56
  static ignoredProperties = [
82
- "fancyScrollbars"
57
+ "fancyScrollbars",
58
+ "hiddenScrollbars"
83
59
  ];
84
60
  })`
85
61
 
@@ -91,13 +67,13 @@ export default withStyle(class extends RichTextarea {
91
67
  outline: none;
92
68
  z-index: 1;
93
69
  tab-size: 2;
94
- position: absolute;
95
70
  overflow: scroll;
71
+ grid-area: syntax;
96
72
  border-top: none;
97
73
  white-space: pre;
98
74
  overflow-wrap: normal;
99
75
  background-color: transparent;
100
-
76
+
101
77
  ::selection {
102
78
  color: ${selectionColour};
103
79
  background-color: ${selectionBackgroundColour};
package/src/styles.js CHANGED
@@ -1,5 +1,4 @@
1
1
  "use strict";
2
2
 
3
- export const gutterHeight = "100000px";
4
3
  export const scrollbarThickness = "12px";
5
4
  export const scrollbarThumbBorderRadius = "8px";
package/src/syntax.js CHANGED
@@ -2,20 +2,11 @@
2
2
 
3
3
  import withStyle from "easy-with-style"; ///
4
4
 
5
- import ScrollableElement from "./element/scrollable";
6
-
7
- class Syntax extends ScrollableElement {
8
- setBounds(bounds) {
9
- const top = bounds.getTop(),
10
- left = bounds.getLeft(),
11
- width = bounds.getWidth(),
12
- height = bounds.getHeight();
13
-
14
- this.position(top, left);
15
- this.setWidth(width);
16
- this.setHeight(height);
17
- }
5
+ import { Element } from "easy";
6
+
7
+ import { EMPTY_STRING } from "./constants";
18
8
 
9
+ class Syntax extends Element {
19
10
  setLanguage(language) {
20
11
  const state = {
21
12
  language
@@ -57,11 +48,22 @@ class Syntax extends ScrollableElement {
57
48
  html += tokenWithSelectionHTML;
58
49
 
59
50
  return html;
60
- }, "");
51
+ }, EMPTY_STRING);
61
52
 
62
53
  this.html(html);
63
54
  }
64
55
 
56
+ scroll(scrollTop, scrollLeft) {
57
+ const top = `${-scrollTop}px`,
58
+ left = `${-scrollLeft}px`,
59
+ css = {
60
+ top,
61
+ left
62
+ };
63
+
64
+ this.css(css);
65
+ }
66
+
65
67
  setInitialState() {
66
68
  const language = null;
67
69
 
@@ -73,14 +75,12 @@ class Syntax extends ScrollableElement {
73
75
  parentContext() {
74
76
  const setLanguage = this.setLanguage.bind(this),
75
77
  updateSyntax = this.update.bind(this), ///
76
- scrollSyntax = this.scroll.bind(this), ///
77
- setSyntaxBounds = this.setBounds.bind(this); //
78
+ scrollSyntax = this.scroll.bind(this); ///
78
79
 
79
80
  return ({
80
81
  setLanguage,
81
82
  updateSyntax,
82
- scrollSyntax,
83
- setSyntaxBounds
83
+ scrollSyntax
84
84
  });
85
85
  }
86
86
 
@@ -97,12 +97,10 @@ class Syntax extends ScrollableElement {
97
97
 
98
98
  export default withStyle(Syntax)`
99
99
 
100
- z-index: 0;
101
- overflow: hidden;
102
- position: absolute;
100
+ position: relative;
103
101
  white-space: pre;
102
+ user-select: none;
104
103
  pointer-events: none;
105
- background-color: inherit;
106
104
 
107
105
  font-size: inherit;
108
106
  line-height: inherit;
package/src/yapp.js CHANGED
@@ -2,10 +2,9 @@
2
2
 
3
3
  import withStyle from "easy-with-style"; ///
4
4
 
5
- import { React, Bounds, Element } from "easy";
5
+ import { React, Element } from "easy";
6
6
 
7
7
  import styleMixins from "./mixins/style";
8
- import RichTextarea from "./richTextarea";
9
8
  import PrettyPrinter from "./prettyPrinter";
10
9
 
11
10
  import { getScrollbarThickness } from "./utilities/scrollbarThickness";
@@ -13,7 +12,7 @@ import { pluginFromLanguageAndPlugin } from "./utilities/plugin";
13
12
  import { propertiesFromContentLanguagePluginAndOptions } from "./utilities/properties";
14
13
  import { lineCountFromContent, contentFromChildElements } from "./utilities/content";
15
14
  import { colour, caretColour, borderColour, backgroundColour } from "./scheme/colour";
16
- import { DEFAULT_EDITABLE, DEFAULT_FIRA_CODE, DEFAULT_DEFER_RENDER, DEFAULT_HIDDEN_GUTTER, DEFAULT_HIDDEN_SCROLLBARS, DEFAULT_FANCY_SCROLLBARS } from "./defaults";
15
+ import { DEFAULT_EDITABLE, DEFAULT_FIRA_CODE, DEFAULT_AUTO_HEIGHT, DEFAULT_HIDDEN_GUTTER, DEFAULT_HIDDEN_SCROLLBARS, DEFAULT_FANCY_SCROLLBARS } from "./defaults";
17
16
 
18
17
  class Yapp extends Element {
19
18
  constructor(selector, plugin) {
@@ -22,6 +21,24 @@ class Yapp extends Element {
22
21
  this.plugin = plugin;
23
22
  }
24
23
 
24
+ changeHandler = (event, element) => {
25
+ const richTextarea = element, ///
26
+ contentChanged = richTextarea.hasContentChanged();
27
+
28
+ if (contentChanged) {
29
+ const { onContentChange = null } = this.properties,
30
+ contentChangeHandler = onContentChange; ///
31
+
32
+ this.update();
33
+
34
+ if (contentChangeHandler) {
35
+ element = this; ///
36
+
37
+ contentChangeHandler(event, element);
38
+ }
39
+ }
40
+ }
41
+
25
42
  getPlugin() {
26
43
  return this.plugin;
27
44
  }
@@ -33,38 +50,6 @@ class Yapp extends Element {
33
50
  return content;
34
51
  }
35
52
 
36
- getInnerBounds(gutterWidth) {
37
- let top,
38
- left,
39
- width = this.getWidth(),
40
- height = this.getHeight();
41
-
42
- const paddingTop = this.getPaddingTop(),
43
- paddingLeft = this.getPaddingLeft(),
44
- paddingRight = this.getPaddingRight(),
45
- paddingBottom = this.getPaddingBottom(),
46
- borderTopWidth = this.getBorderTopWidth(),
47
- borderLeftWidth = this.getBorderLeftWidth(),
48
- borderRightWidth = this.getBorderRightWidth(),
49
- borderBottomWidth = this.getBorderBottomWidth();
50
-
51
- top = paddingTop;
52
- left = paddingLeft;
53
-
54
- width -= ( borderLeftWidth + paddingLeft + paddingRight + borderRightWidth );
55
- height -= ( borderTopWidth + paddingTop + paddingBottom + borderBottomWidth );
56
-
57
- if (gutterWidth !== null) {
58
- left += gutterWidth;
59
- width -= gutterWidth;
60
- }
61
-
62
- const bounds = Bounds.fromTopLeftWidthAndHeight(top, left, width, height),
63
- innerBounds = bounds; ///
64
-
65
- return innerBounds;
66
- }
67
-
68
53
  getInitialLineCount() {
69
54
  const content = this.getContent(),
70
55
  lineCount = lineCountFromContent(content),
@@ -91,96 +76,35 @@ class Yapp extends Element {
91
76
 
92
77
  setParser(parser) { this.plugin.setParser(parser); }
93
78
 
94
- changeHandler(event, element) {
95
- const richTextarea = element, ///
96
- contentChanged = richTextarea.hasContentChanged();
97
-
98
- if (contentChanged) {
99
- const { onContentChange } = this.properties,
100
- contentChangeHandler = onContentChange; ///
101
-
102
- this.update();
103
-
104
- element = this; ///
105
-
106
- contentChangeHandler && contentChangeHandler(event, element); ///
107
- }
108
- }
109
-
110
- scrollHandler(event, element) {
111
- const richTextarea = element, ///
112
- scrollTop = richTextarea.getScrollTop(),
113
- scrollLeft = richTextarea.getScrollLeft();
114
-
115
- this.scrollPrettyPrinter(scrollTop, scrollLeft);
116
- }
117
-
118
79
  update() {
119
80
  const content = this.getContent();
120
81
 
121
82
  this.plugin.update(content);
122
83
 
123
- const tokens = this.plugin.getTokens(),
124
- gutterWidth = this.updatePrettyPrinter(tokens);
125
-
126
- if (gutterWidth !== null) {
127
- const innerBounds = this.getInnerBounds(gutterWidth),
128
- richTextareaBounds = innerBounds; ///
129
-
130
- this.setRichTextareaBounds(richTextareaBounds);
131
- }
132
- }
133
-
134
- resize() {
135
- let innerBounds,
136
- gutterWidth;
137
-
138
- gutterWidth = null;
139
-
140
- innerBounds = this.getInnerBounds(gutterWidth);
141
-
142
- const prettyPrinterBounds = innerBounds; ///
143
-
144
- this.setPrettyPrinterBounds(prettyPrinterBounds);
145
-
146
- gutterWidth = this.resizePrettyPrinter();
147
-
148
- innerBounds = this.getInnerBounds(gutterWidth);
84
+ const tokens = this.plugin.getTokens();
149
85
 
150
- const richTextareaBounds = innerBounds; ///
151
-
152
- this.setRichTextareaBounds(richTextareaBounds);
153
- }
154
-
155
- render() {
156
- const lineHeight = this.getLineHeight(),
157
- paddingTop = this.getPaddingTop(),
158
- paddingBottom = this.getPaddingBottom(),
159
- borderTopWidth = this.getBorderTopWidth(),
160
- initialLineCount = this.getInitialLineCount(),
161
- borderBottomWidth = this.getBorderBottomWidth(),
162
- scrollbarThickness = this.getScrollbarThickness(),
163
- height = borderTopWidth + paddingTop + initialLineCount * lineHeight + paddingBottom + borderBottomWidth + scrollbarThickness;
164
-
165
- this.setHeight(height);
166
-
167
- this.resize();
168
-
169
- this.update();
86
+ this.updatePrettyPrinter(tokens);
170
87
  }
171
88
 
172
89
  didMount() {
173
- const { firaCode = DEFAULT_FIRA_CODE, deferRender = DEFAULT_DEFER_RENDER } = this.properties;
90
+ const { firaCode = DEFAULT_FIRA_CODE, autoHeight = DEFAULT_AUTO_HEIGHT } = this.properties;
174
91
 
175
92
  if (firaCode) {
176
93
  this.addClass("fira-code");
177
94
  }
178
95
 
179
- if (deferRender) {
180
- return;
96
+ if (autoHeight) {
97
+ const lineHeight = this.getLineHeight(),
98
+ paddingTop = this.getPaddingTop(),
99
+ paddingBottom = this.getPaddingBottom(),
100
+ borderTopWidth = this.getBorderTopWidth(),
101
+ initialLineCount = this.getInitialLineCount(),
102
+ borderBottomWidth = this.getBorderBottomWidth(),
103
+ scrollbarThickness = this.getScrollbarThickness(),
104
+ height = borderTopWidth + paddingTop + initialLineCount * lineHeight + paddingBottom + borderBottomWidth + scrollbarThickness;
105
+
106
+ this.setHeight(height);
181
107
  }
182
-
183
- this.render();
184
108
  }
185
109
 
186
110
  willUnmount() {
@@ -193,36 +117,35 @@ class Yapp extends Element {
193
117
 
194
118
  childElements() {
195
119
  const { hiddenGutter = DEFAULT_HIDDEN_GUTTER, hiddenScrollbars = DEFAULT_HIDDEN_SCROLLBARS, fancyScrollbars = DEFAULT_FANCY_SCROLLBARS } = this.properties,
196
- changeHandler = this.changeHandler.bind(this),
197
- scrollHandler = this.scrollHandler.bind(this),
198
120
  scrollbarThickness = this.getScrollbarThickness();
199
121
 
200
- return ([
122
+ return (
201
123
 
202
- <PrettyPrinter hiddenGutter={hiddenGutter} scrollbarThickness={scrollbarThickness} />,
203
- <RichTextarea onChange={changeHandler} onScroll={scrollHandler} hiddenScrollbars={hiddenScrollbars} fancyScrollbars={fancyScrollbars} active />
124
+ <PrettyPrinter onChange={this.changeHandler}
125
+ hiddenGutter={hiddenGutter}
126
+ fancyScrollbars={fancyScrollbars}
127
+ hiddenScrollbars={hiddenScrollbars}
128
+ scrollbarThickness={scrollbarThickness} />
204
129
 
205
- ]);
130
+ );
206
131
  }
207
132
 
208
133
  parentContext() {
209
134
  const getPlugin = this.getPlugin.bind(this),
210
135
  getContent = this.getContent.bind(this),
211
136
  updateYapp = this.update.bind(this), ///
212
- resizeYapp = this.resize.bind(this), ///
137
+ setYappLexer = this.setLexer.bind(this), ///
213
138
  setYappWidth = this.setWidth.bind(this), ///
214
139
  setYappHeight = this.setHeight.bind(this), ///
215
- setYappLexer = this.setLexer.bind(this), ///
216
140
  setYappParser = this.setParser.bind(this); ///
217
141
 
218
142
  return ({
219
143
  getPlugin,
220
144
  getContent,
221
145
  updateYapp,
222
- resizeYapp,
146
+ setYappLexer,
223
147
  setYappWidth,
224
148
  setYappHeight,
225
- setYappLexer,
226
149
  setYappParser
227
150
  });
228
151
  }
@@ -233,19 +156,15 @@ class Yapp extends Element {
233
156
  const { childElements, editable = DEFAULT_EDITABLE } = this.properties,
234
157
  language = this.plugin.getLanguage(),
235
158
  content = contentFromChildElements(childElements),
236
- readOnly = !editable,
237
- scrollTop = 0, ///
238
- scrollLeft = 0; ///
159
+ readOnly = !editable;
239
160
 
240
161
  this.setLanguage(language);
241
162
 
242
- this.scrollPrettyPrinter(scrollTop, scrollLeft);
243
-
244
163
  this.setRichTextareaContent(content);
245
164
 
246
165
  this.setRichTextareaReadOnly(readOnly);
247
166
 
248
- this.onResize((event, element) => this.resize());
167
+ this.update();
249
168
  }
250
169
 
251
170
  static tagName = "div";
@@ -259,10 +178,11 @@ class Yapp extends Element {
259
178
  "language",
260
179
  "firaCode",
261
180
  "editable",
262
- "deferRender",
181
+ "autoHeight",
263
182
  "hiddenGutter",
264
183
  "noScrollbars",
265
- "fancyScrollbars"
184
+ "fancyScrollbars",
185
+ "onContentChange"
266
186
  ];
267
187
 
268
188
  static fromContent(content, language, Plugin, options) {
@@ -288,8 +208,7 @@ Object.assign(Yapp.prototype, styleMixins);
288
208
  export default withStyle(Yapp)`
289
209
 
290
210
  width: 100%;
291
- overflow: hidden;
292
- position: relative;
211
+ height: 100%;
293
212
 
294
213
  border: 1px solid;
295
214