yapp 2.1.13 → 2.2.0
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.
- package/README.md +2 -2
- package/example.js +614 -392
- package/lib/colours.js +1 -1
- package/lib/constants.js +1 -1
- package/lib/defaults.js +4 -2
- package/lib/element/scrollable.js +309 -0
- package/lib/example/constants.js +1 -1
- package/lib/example/div/columns.js +1 -1
- package/lib/example/div/sizeable/left.js +1 -1
- package/lib/example/div/sizeable/middle.js +1 -1
- package/lib/example/div/sizeable/right.js +1 -1
- package/lib/example/div/sizeable/top.js +1 -1
- package/lib/example/div/splitter/horizontal.js +1 -1
- package/lib/example/div/splitter/vertical.js +1 -1
- package/lib/example/input.js +1 -1
- package/lib/example/subHeading.js +1 -1
- package/lib/example/textarea/bnf.js +1 -1
- package/lib/example/textarea/lexicalEntries.js +1 -1
- package/lib/example/textarea/parseTree.js +1 -1
- package/lib/example/textarea/tokens.js +3 -3
- package/lib/example/textarea.js +1 -1
- package/lib/example/view/javascript.js +1 -1
- package/lib/example/view/json.js +1 -1
- package/lib/example/view/xml.js +1 -1
- package/lib/example/view.js +2 -5
- package/lib/example/yapp.js +77 -3
- package/lib/example.js +1 -1
- package/lib/gutter.js +1 -1
- package/lib/index.js +1 -1
- package/lib/languages.js +1 -1
- package/lib/lexer/javascript.js +3 -3
- package/lib/lexer/json.js +3 -3
- package/lib/lexer/plainText.js +3 -3
- package/lib/lexer/xml.js +3 -3
- package/lib/lineNumbers.js +1 -1
- package/lib/mixins/style.js +68 -0
- package/lib/parser/javascript.js +1 -1
- package/lib/parser/json.js +1 -1
- package/lib/parser/plainText.js +1 -1
- package/lib/parser/xml.js +1 -1
- package/lib/plugin/javascript.js +1 -1
- package/lib/plugin/json.js +1 -1
- package/lib/plugin/plainText.js +1 -1
- package/lib/plugin/xml.js +1 -1
- package/lib/plugin.js +1 -1
- package/lib/prettyPrinter.js +46 -26
- package/lib/processor/javascript.js +1 -1
- package/lib/processor/json.js +1 -1
- package/lib/processor/plainText.js +1 -1
- package/lib/processor/xml.js +1 -1
- package/lib/processor.js +5 -5
- package/lib/renderYappStyles.js +1 -1
- package/lib/richTextarea.js +21 -21
- package/lib/scheme/colour.js +1 -1
- package/lib/scheme/syntax/default.js +1 -1
- package/lib/scheme/syntax/javaScript.js +1 -1
- package/lib/scheme/syntax/json.js +1 -1
- package/lib/scheme/syntax/xml.js +1 -1
- package/lib/style/firaCode.js +1 -1
- package/lib/style/syntax/default.js +1 -1
- package/lib/style/syntax/javaScript.js +1 -1
- package/lib/style/syntax/json.js +1 -1
- package/lib/style/syntax/xml.js +1 -1
- package/lib/style/syntax.js +1 -1
- package/lib/styles.js +1 -1
- package/lib/syntax.js +16 -7
- package/lib/token/nonSignificant/comment/multiLine/endOf.js +1 -1
- package/lib/token/nonSignificant/comment/multiLine/middleOf.js +1 -1
- package/lib/token/nonSignificant/comment/multiLine/startOf.js +1 -1
- package/lib/token/nonSignificant/comment/singleLine.js +1 -1
- package/lib/token/significant/argument.js +1 -1
- package/lib/token/significant/attribute.js +1 -1
- package/lib/token/significant/comment.js +1 -1
- package/lib/token/significant/error.js +1 -1
- package/lib/token/significant/jsx.js +1 -1
- package/lib/token/significant/name.js +1 -1
- package/lib/token/significant/string.js +1 -1
- package/lib/token/significant/variable.js +1 -1
- package/lib/tokenTypes.js +1 -1
- package/lib/utilities/content.js +1 -1
- package/lib/utilities/css.js +1 -1
- package/lib/utilities/plugin.js +1 -1
- package/lib/utilities/properties.js +1 -1
- package/lib/utilities/rules.js +3 -3
- package/lib/utilities/scrollbarThickness.js +1 -1
- package/lib/utilities/tokens.js +1 -1
- package/lib/yapp.js +41 -58
- package/package.json +7 -7
- package/src/defaults.js +1 -0
- package/src/element/{bounded/scrollable.js → scrollable.js} +1 -11
- package/src/example/view.js +1 -1
- package/src/example/yapp.js +7 -2
- package/src/mixins/style.js +97 -0
- package/src/prettyPrinter.js +54 -33
- package/src/richTextarea.js +28 -20
- package/src/syntax.js +14 -3
- package/src/yapp.js +58 -56
- package/lib/element/bounded/scrollable.js +0 -317
- package/lib/element/bounded.js +0 -164
- package/src/element/bounded.js +0 -32
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { stripPixels } from "../utilities/css";
|
|
4
|
+
import { TOP, LEFT, RIGHT, BOTTOM, LINE_HEIGHT } from "../constants";
|
|
5
|
+
|
|
6
|
+
function getLineHeight() {
|
|
7
|
+
const lineHeightInPixels = this.css(LINE_HEIGHT),
|
|
8
|
+
lineHeight = stripPixels(lineHeightInPixels);
|
|
9
|
+
|
|
10
|
+
return lineHeight;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function getPadding(side) {
|
|
14
|
+
const paddingInPixels = this.css(`padding-${side}`),
|
|
15
|
+
padding = stripPixels(paddingInPixels);
|
|
16
|
+
|
|
17
|
+
return padding;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function getBorderWidth(side) {
|
|
21
|
+
const borderWidthInPixels = this.css(`border-${side}-width`),
|
|
22
|
+
borderWidth = stripPixels(borderWidthInPixels);
|
|
23
|
+
|
|
24
|
+
return borderWidth;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function getPaddingTop() {
|
|
28
|
+
const side = TOP,
|
|
29
|
+
paddingTop = this.getPadding(side);
|
|
30
|
+
|
|
31
|
+
return paddingTop;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function getPaddingLeft() {
|
|
35
|
+
const side = LEFT,
|
|
36
|
+
paddingLeft = this.getPadding(side);
|
|
37
|
+
|
|
38
|
+
return paddingLeft;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function getPaddingRight() {
|
|
42
|
+
const side = RIGHT,
|
|
43
|
+
paddingRight = this.getPadding(side);
|
|
44
|
+
|
|
45
|
+
return paddingRight;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function getPaddingBottom() {
|
|
49
|
+
const side = BOTTOM,
|
|
50
|
+
paddingBottom = this.getPadding(side);
|
|
51
|
+
|
|
52
|
+
return paddingBottom;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function getBorderTopWidth() {
|
|
56
|
+
const side = TOP,
|
|
57
|
+
borderTopWidth = this.getBorderWidth(side);
|
|
58
|
+
|
|
59
|
+
return borderTopWidth;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function getBorderLeftWidth() {
|
|
63
|
+
const side = LEFT,
|
|
64
|
+
borderLeftWidth = this.getBorderWidth(side);
|
|
65
|
+
|
|
66
|
+
return borderLeftWidth;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function getBorderRightWidth() {
|
|
70
|
+
const side = RIGHT,
|
|
71
|
+
borderRightWidth = this.getBorderWidth(side);
|
|
72
|
+
|
|
73
|
+
return borderRightWidth;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function getBorderBottomWidth() {
|
|
77
|
+
const side = BOTTOM,
|
|
78
|
+
borderBottomWidth = this.getBorderWidth(side);
|
|
79
|
+
|
|
80
|
+
return borderBottomWidth;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const styleMixins = {
|
|
84
|
+
getLineHeight,
|
|
85
|
+
getPadding,
|
|
86
|
+
getPaddingTop,
|
|
87
|
+
getPaddingLeft,
|
|
88
|
+
getPaddingRight,
|
|
89
|
+
getPaddingBottom,
|
|
90
|
+
getBorderWidth,
|
|
91
|
+
getBorderTopWidth,
|
|
92
|
+
getBorderLeftWidth,
|
|
93
|
+
getBorderRightWidth,
|
|
94
|
+
getBorderBottomWidth
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
export default styleMixins;
|
package/src/prettyPrinter.js
CHANGED
|
@@ -40,57 +40,80 @@ class PrettyPrinter extends Element {
|
|
|
40
40
|
return height;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
getInnerBounds() {
|
|
44
|
-
const gutterWidth = this.getGutterWidth();
|
|
45
|
-
|
|
46
|
-
let top = 0, ///
|
|
47
|
-
left = 0, ///
|
|
48
|
-
width = this.getWidth(),
|
|
49
|
-
height = this.getHeight();
|
|
50
|
-
|
|
51
|
-
left += gutterWidth;
|
|
52
|
-
width -= gutterWidth;
|
|
53
|
-
|
|
54
|
-
const innerBounds = Bounds.fromTopLeftWidthAndHeight(top, left, width, height);
|
|
55
|
-
|
|
56
|
-
return innerBounds;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
43
|
scroll(scrollTop, scrollLeft) {
|
|
60
44
|
this.scrollGutter(scrollTop ,scrollLeft);
|
|
61
45
|
this.scrollSyntax(scrollTop, scrollLeft);
|
|
62
46
|
}
|
|
63
47
|
|
|
64
48
|
update(tokens) {
|
|
65
|
-
let
|
|
49
|
+
let gutterWidth = this.getGutterWidth(),
|
|
66
50
|
previousGutterWidth = this.getPreviousGutterWidth();
|
|
67
51
|
|
|
68
52
|
this.updateSyntax(tokens);
|
|
69
53
|
|
|
70
54
|
this.updateGutter(tokens);
|
|
71
55
|
|
|
72
|
-
const gutterWidth = this.getGutterWidth();
|
|
73
|
-
|
|
74
56
|
if (previousGutterWidth !== gutterWidth) {
|
|
75
57
|
previousGutterWidth = gutterWidth; ///
|
|
76
58
|
|
|
77
59
|
this.setPreviousGutterWidth(previousGutterWidth);
|
|
78
60
|
|
|
79
|
-
|
|
61
|
+
this.resize();
|
|
62
|
+
} else {
|
|
63
|
+
gutterWidth = null;
|
|
80
64
|
}
|
|
81
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
|
+
|
|
82
81
|
return innerBounds;
|
|
83
82
|
}
|
|
84
83
|
|
|
85
84
|
resize() {
|
|
86
|
-
const
|
|
87
|
-
|
|
85
|
+
const gutterWidth = this.getGutterWidth(),
|
|
86
|
+
innerBounds = this.getInnerBounds(gutterWidth),
|
|
87
|
+
syntaxBounds = innerBounds; ///
|
|
88
88
|
|
|
89
89
|
this.positionGutter();
|
|
90
90
|
|
|
91
|
-
this.setSyntaxBounds(
|
|
91
|
+
this.setSyntaxBounds(syntaxBounds);
|
|
92
92
|
|
|
93
|
-
return
|
|
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);
|
|
94
117
|
}
|
|
95
118
|
|
|
96
119
|
getPreviousGutterWidth() {
|
|
@@ -123,14 +146,12 @@ class PrettyPrinter extends Element {
|
|
|
123
146
|
resizePrettyPrinter = this.resize.bind(this), ///
|
|
124
147
|
updatePrettyPrinter = this.update.bind(this), ///
|
|
125
148
|
scrollPrettyPrinter = this.scroll.bind(this), ///
|
|
126
|
-
|
|
127
|
-
setPrettyPrinterHeight = this.setHeight.bind(this), ///
|
|
149
|
+
setPrettyPrinterBounds = this.setBounds.bind(this), ///
|
|
128
150
|
parentContext = Object.assign({}, context, {
|
|
129
151
|
resizePrettyPrinter,
|
|
130
152
|
updatePrettyPrinter,
|
|
131
153
|
scrollPrettyPrinter,
|
|
132
|
-
|
|
133
|
-
setPrettyPrinterHeight
|
|
154
|
+
setPrettyPrinterBounds
|
|
134
155
|
});
|
|
135
156
|
|
|
136
157
|
return parentContext;
|
|
@@ -146,13 +167,13 @@ class PrettyPrinter extends Element {
|
|
|
146
167
|
|
|
147
168
|
initialise() {
|
|
148
169
|
this.assignContext([
|
|
149
|
-
"getGutterWidth",
|
|
150
|
-
"setSyntaxBounds",
|
|
151
|
-
"positionGutter",
|
|
152
170
|
"updateGutter",
|
|
153
171
|
"updateSyntax",
|
|
154
172
|
"scrollGutter",
|
|
155
|
-
"scrollSyntax"
|
|
173
|
+
"scrollSyntax",
|
|
174
|
+
"positionGutter",
|
|
175
|
+
"getGutterWidth",
|
|
176
|
+
"setSyntaxBounds"
|
|
156
177
|
]);
|
|
157
178
|
|
|
158
179
|
this.setInitialState();
|
|
@@ -172,8 +193,8 @@ class PrettyPrinter extends Element {
|
|
|
172
193
|
|
|
173
194
|
export default withStyle(PrettyPrinter)`
|
|
174
195
|
|
|
175
|
-
position: relative;
|
|
176
196
|
overflow: hidden;
|
|
197
|
+
position: absolute;
|
|
177
198
|
|
|
178
199
|
color: inherit;
|
|
179
200
|
border-color: inherit;
|
package/src/richTextarea.js
CHANGED
|
@@ -7,21 +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
|
-
setBounds(bounds) {
|
|
11
|
-
const top = bounds.getTop(),
|
|
12
|
-
left = bounds.getLeft(),
|
|
13
|
-
width = bounds.getWidth(),
|
|
14
|
-
height = bounds.getHeight();
|
|
15
|
-
|
|
16
|
-
this.resize(width, height);
|
|
17
|
-
this.position(top, left);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
resize(width, height) {
|
|
21
|
-
this.setWidth(width);
|
|
22
|
-
this.setHeight(height);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
10
|
position(top, left) {
|
|
26
11
|
top = `${top}px`;
|
|
27
12
|
left = `${left}px`;
|
|
@@ -34,35 +19,54 @@ export default withStyle(class extends RichTextarea {
|
|
|
34
19
|
this.css(css);
|
|
35
20
|
}
|
|
36
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
|
+
|
|
37
33
|
didMount() {
|
|
38
|
-
const { fancyScrollbars } = this.properties;
|
|
34
|
+
const { fancyScrollbars, hiddenScrollbars } = this.properties;
|
|
39
35
|
|
|
40
36
|
if (fancyScrollbars) {
|
|
41
37
|
this.addClass("fancy-scrollbars");
|
|
42
38
|
}
|
|
43
39
|
|
|
40
|
+
if (hiddenScrollbars) {
|
|
41
|
+
this.addClass("hidden-scrollbars");
|
|
42
|
+
}
|
|
43
|
+
|
|
44
44
|
super.didMount();
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
willUnmount() {
|
|
48
|
-
const { fancyScrollbars } = this.properties;
|
|
48
|
+
const { fancyScrollbars, hiddenScrollbars } = this.properties;
|
|
49
49
|
|
|
50
50
|
if (fancyScrollbars) {
|
|
51
51
|
this.removeClass("fancy-scrollbars");
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
+
if (hiddenScrollbars) {
|
|
55
|
+
this.removeClass("hidden-scrollbars");
|
|
56
|
+
}
|
|
57
|
+
|
|
54
58
|
super.willUnmount();
|
|
55
59
|
}
|
|
56
60
|
|
|
57
61
|
parentContext() {
|
|
58
|
-
const
|
|
59
|
-
|
|
62
|
+
const setRichTextareaBounds = this.setBounds.bind(this), ///
|
|
63
|
+
getRichTextareaContent = this.getContent.bind(this), ///
|
|
60
64
|
setRichTextareaContent = this.setContent.bind(this), ///
|
|
61
65
|
setRichTextareaReadOnly = this.setReadOnly.bind(this); ///
|
|
62
66
|
|
|
63
67
|
return ({
|
|
64
|
-
getRichTextareaContent,
|
|
65
68
|
setRichTextareaBounds,
|
|
69
|
+
getRichTextareaContent,
|
|
66
70
|
setRichTextareaContent,
|
|
67
71
|
setRichTextareaReadOnly
|
|
68
72
|
});
|
|
@@ -97,6 +101,10 @@ export default withStyle(class extends RichTextarea {
|
|
|
97
101
|
background-color: ${selectionBackgroundColour};
|
|
98
102
|
}
|
|
99
103
|
|
|
104
|
+
.hidden-scrollbars {
|
|
105
|
+
overflow: hidden;
|
|
106
|
+
}
|
|
107
|
+
|
|
100
108
|
.fancy-scrollbars::-webkit-scrollbar {
|
|
101
109
|
width: ${scrollbarThickness};
|
|
102
110
|
height: ${scrollbarThickness};
|
package/src/syntax.js
CHANGED
|
@@ -2,9 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
import withStyle from "easy-with-style"; ///
|
|
4
4
|
|
|
5
|
-
import
|
|
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
|
+
}
|
|
6
18
|
|
|
7
|
-
class Syntax extends ScrollableBoundedElement {
|
|
8
19
|
setLanguage(language) {
|
|
9
20
|
const state = {
|
|
10
21
|
language
|
|
@@ -55,7 +66,7 @@ class Syntax extends ScrollableBoundedElement {
|
|
|
55
66
|
const setLanguage = this.setLanguage.bind(this),
|
|
56
67
|
updateSyntax = this.update.bind(this), ///
|
|
57
68
|
scrollSyntax = this.scroll.bind(this), ///
|
|
58
|
-
setSyntaxBounds = this.setBounds.bind(this);
|
|
69
|
+
setSyntaxBounds = this.setBounds.bind(this); //
|
|
59
70
|
|
|
60
71
|
return ({
|
|
61
72
|
setLanguage,
|
package/src/yapp.js
CHANGED
|
@@ -2,19 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
import withStyle from "easy-with-style"; ///
|
|
4
4
|
|
|
5
|
-
import { React, Element } from "easy";
|
|
5
|
+
import { React, Bounds, Element } from "easy";
|
|
6
6
|
|
|
7
|
+
import styleMixins from "./mixins/style";
|
|
7
8
|
import RichTextarea from "./richTextarea";
|
|
8
9
|
import PrettyPrinter from "./prettyPrinter";
|
|
9
10
|
|
|
10
|
-
import { stripPixels } from "./utilities/css";
|
|
11
11
|
import { getScrollbarThickness } from "./utilities/scrollbarThickness";
|
|
12
12
|
import { pluginFromLanguageAndPlugin } from "./utilities/plugin";
|
|
13
|
-
import { TOP, LEFT, RIGHT, LINE_HEIGHT, BOTTOM } from "./constants";
|
|
14
13
|
import { propertiesFromContentLanguagePluginAndOptions } from "./utilities/properties";
|
|
15
14
|
import { lineCountFromContent, contentFromChildElements } from "./utilities/content";
|
|
16
15
|
import { colour, caretColour, borderColour, backgroundColour } from "./scheme/colour";
|
|
17
|
-
import { DEFAULT_EDITABLE, DEFAULT_FIRA_CODE, DEFAULT_DEFER_RENDER, DEFAULT_HIDDEN_GUTTER, DEFAULT_FANCY_SCROLLBARS } from "./defaults";
|
|
16
|
+
import { DEFAULT_EDITABLE, DEFAULT_FIRA_CODE, DEFAULT_DEFER_RENDER, DEFAULT_HIDDEN_GUTTER, DEFAULT_HIDDEN_SCROLLBARS, DEFAULT_FANCY_SCROLLBARS } from "./defaults";
|
|
18
17
|
|
|
19
18
|
class Yapp extends Element {
|
|
20
19
|
constructor(selector, plugin) {
|
|
@@ -34,32 +33,36 @@ class Yapp extends Element {
|
|
|
34
33
|
return content;
|
|
35
34
|
}
|
|
36
35
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}
|
|
36
|
+
getInnerBounds(gutterWidth) {
|
|
37
|
+
let top,
|
|
38
|
+
left,
|
|
39
|
+
width = this.getWidth(),
|
|
40
|
+
height = this.getHeight();
|
|
43
41
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
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();
|
|
47
50
|
|
|
48
|
-
|
|
49
|
-
|
|
51
|
+
top = borderTopWidth + paddingTop;
|
|
52
|
+
left = borderLeftWidth + paddingLeft;
|
|
50
53
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
borderTopWidth = this.getBorderWidth(side);
|
|
54
|
+
width -= ( borderLeftWidth + paddingLeft + paddingRight + borderRightWidth );
|
|
55
|
+
height -= ( borderTopWidth + paddingTop + paddingBottom + borderBottomWidth );
|
|
54
56
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
+
if (gutterWidth !== null) {
|
|
58
|
+
left += gutterWidth;
|
|
59
|
+
width -= gutterWidth;
|
|
60
|
+
}
|
|
57
61
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
borderLeftWidth = this.getBorderWidth(side);
|
|
62
|
+
const bounds = Bounds.fromTopLeftWidthAndHeight(top, left, width, height),
|
|
63
|
+
innerBounds = bounds; ///
|
|
61
64
|
|
|
62
|
-
return
|
|
65
|
+
return innerBounds;
|
|
63
66
|
}
|
|
64
67
|
|
|
65
68
|
getInitialLineCount() {
|
|
@@ -70,23 +73,16 @@ class Yapp extends Element {
|
|
|
70
73
|
return initialLineCount;
|
|
71
74
|
}
|
|
72
75
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
borderRightWidth = this.getBorderWidth(side);
|
|
76
|
-
|
|
77
|
-
return borderRightWidth;
|
|
78
|
-
}
|
|
76
|
+
getScrollbarThickness() {
|
|
77
|
+
let scrollbarThickness = 0;
|
|
79
78
|
|
|
80
|
-
|
|
81
|
-
const side = BOTTOM,
|
|
82
|
-
borderBottomWidth = this.getBorderWidth(side);
|
|
79
|
+
const { hiddenScrollbars = DEFAULT_HIDDEN_SCROLLBARS } = this.properties;
|
|
83
80
|
|
|
84
|
-
|
|
85
|
-
|
|
81
|
+
if (!hiddenScrollbars) {
|
|
82
|
+
const { fancyScrollbars = DEFAULT_FANCY_SCROLLBARS } = this.properties;
|
|
86
83
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
scrollbarThickness = getScrollbarThickness(fancyScrollbars);
|
|
84
|
+
scrollbarThickness = getScrollbarThickness(fancyScrollbars);
|
|
85
|
+
}
|
|
90
86
|
|
|
91
87
|
return scrollbarThickness;
|
|
92
88
|
}
|
|
@@ -125,43 +121,46 @@ class Yapp extends Element {
|
|
|
125
121
|
this.plugin.update(content);
|
|
126
122
|
|
|
127
123
|
const tokens = this.plugin.getTokens(),
|
|
128
|
-
|
|
124
|
+
gutterWidth = this.updatePrettyPrinter(tokens);
|
|
129
125
|
|
|
130
|
-
if (
|
|
131
|
-
const
|
|
126
|
+
if (gutterWidth !== null) {
|
|
127
|
+
const innerBounds = this.getInnerBounds(gutterWidth),
|
|
128
|
+
richTextareaBounds = innerBounds; ///
|
|
132
129
|
|
|
133
130
|
this.setRichTextareaBounds(richTextareaBounds);
|
|
134
131
|
}
|
|
135
132
|
}
|
|
136
133
|
|
|
137
134
|
resize() {
|
|
138
|
-
let
|
|
139
|
-
|
|
135
|
+
let innerBounds,
|
|
136
|
+
gutterWidth;
|
|
140
137
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
borderBottomWidth = this.getBorderBottomWidth();
|
|
138
|
+
gutterWidth = null;
|
|
139
|
+
|
|
140
|
+
innerBounds = this.getInnerBounds(gutterWidth);
|
|
145
141
|
|
|
146
|
-
|
|
147
|
-
width -= ( borderLeftWidth + borderRightWidth );
|
|
142
|
+
const prettyPrinterBounds = innerBounds; ///
|
|
148
143
|
|
|
149
|
-
this.
|
|
150
|
-
this.setPrettyPrinterHeight(height);
|
|
144
|
+
this.setPrettyPrinterBounds(prettyPrinterBounds);
|
|
151
145
|
|
|
152
|
-
|
|
153
|
-
|
|
146
|
+
gutterWidth = this.resizePrettyPrinter();
|
|
147
|
+
|
|
148
|
+
innerBounds = this.getInnerBounds(gutterWidth);
|
|
149
|
+
|
|
150
|
+
const richTextareaBounds = innerBounds; ///
|
|
154
151
|
|
|
155
152
|
this.setRichTextareaBounds(richTextareaBounds);
|
|
156
153
|
}
|
|
157
154
|
|
|
158
155
|
render() {
|
|
159
156
|
const lineHeight = this.getLineHeight(),
|
|
157
|
+
paddingTop = this.getPaddingTop(),
|
|
158
|
+
paddingBottom = this.getPaddingBottom(),
|
|
160
159
|
borderTopWidth = this.getBorderTopWidth(),
|
|
161
160
|
initialLineCount = this.getInitialLineCount(),
|
|
162
161
|
borderBottomWidth = this.getBorderBottomWidth(),
|
|
163
162
|
scrollbarThickness = this.getScrollbarThickness(),
|
|
164
|
-
height = initialLineCount * lineHeight +
|
|
163
|
+
height = borderTopWidth + paddingTop + initialLineCount * lineHeight + paddingBottom + borderBottomWidth + scrollbarThickness;
|
|
165
164
|
|
|
166
165
|
this.setHeight(height);
|
|
167
166
|
|
|
@@ -193,7 +192,7 @@ class Yapp extends Element {
|
|
|
193
192
|
}
|
|
194
193
|
|
|
195
194
|
childElements() {
|
|
196
|
-
const { hiddenGutter = DEFAULT_HIDDEN_GUTTER, fancyScrollbars = DEFAULT_FANCY_SCROLLBARS } = this.properties,
|
|
195
|
+
const { hiddenGutter = DEFAULT_HIDDEN_GUTTER, hiddenScrollbars = DEFAULT_HIDDEN_SCROLLBARS, fancyScrollbars = DEFAULT_FANCY_SCROLLBARS } = this.properties,
|
|
197
196
|
changeHandler = this.changeHandler.bind(this),
|
|
198
197
|
scrollHandler = this.scrollHandler.bind(this),
|
|
199
198
|
scrollbarThickness = this.getScrollbarThickness();
|
|
@@ -201,7 +200,7 @@ class Yapp extends Element {
|
|
|
201
200
|
return ([
|
|
202
201
|
|
|
203
202
|
<PrettyPrinter hiddenGutter={hiddenGutter} scrollbarThickness={scrollbarThickness} />,
|
|
204
|
-
<RichTextarea onChange={changeHandler} onScroll={scrollHandler} fancyScrollbars={fancyScrollbars} active />
|
|
203
|
+
<RichTextarea onChange={changeHandler} onScroll={scrollHandler} hiddenScrollbars={hiddenScrollbars} fancyScrollbars={fancyScrollbars} active />
|
|
205
204
|
|
|
206
205
|
]);
|
|
207
206
|
}
|
|
@@ -260,6 +259,7 @@ class Yapp extends Element {
|
|
|
260
259
|
"editable",
|
|
261
260
|
"deferRender",
|
|
262
261
|
"hiddenGutter",
|
|
262
|
+
"noScrollbars",
|
|
263
263
|
"fancyScrollbars"
|
|
264
264
|
];
|
|
265
265
|
|
|
@@ -281,6 +281,8 @@ class Yapp extends Element {
|
|
|
281
281
|
}
|
|
282
282
|
}
|
|
283
283
|
|
|
284
|
+
Object.assign(Yapp.prototype, styleMixins);
|
|
285
|
+
|
|
284
286
|
export default withStyle(Yapp)`
|
|
285
287
|
|
|
286
288
|
width: 100%;
|