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

Commit 51e79e6

Browse files
Merge pull request #706 from mozilla/705-max-line-limit-error
Fix broken max line limit in react version
2 parents a17132d + 5ee91fc commit 51e79e6

File tree

4 files changed

+103
-11
lines changed

4 files changed

+103
-11
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import React from 'react';
2+
3+
function CloseIcon(props) {
4+
return (
5+
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" x="0px" y="0px"
6+
viewBox="0 0 16 16" enableBackground="new 0 0 16 16" xmlSpace="preserve">
7+
<path d="M9.1,8l3.5-3.5c0.3-0.3,0.3-0.8,0-1.1c-0.3-0.3-0.8-0.3-1,0L8,6.9L4.5,3.5c-0.3-0.3-0.8-0.3-1.1,0c-0.3,0.3-0.3,0.7,0,1
8+
L6.9,8l-3.5,3.5c-0.3,0.3-0.3,0.8,0,1.1c0.3,0.3,0.8,0.3,1.1,0c0,0,0,0,0,0L8,9.1l3.5,3.5c0.3,0.3,0.8,0.3,1.1,0
9+
c0.3-0.3,0.3-0.8,0-1L9.1,8z"/>
10+
</svg>
11+
12+
);
13+
}
14+
15+
export default CloseIcon;

src/sidebar/app/components/Editor.js

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import React from 'react';
22

3+
import CloseIcon from './CloseIcon';
4+
35
import { getPadStats, customizeEditor, insertSelectedText } from '../utils/editor';
46

57
import INITIAL_CONFIG from '../data/editorConfig';
@@ -11,6 +13,7 @@ class Editor extends React.Component {
1113
this.state = {
1214
ignoreNextLoadEvent: false,
1315
ignoreTextSynced: false,
16+
wasLimitReached: false,
1417
isKintoLoaded: false,
1518
content: null
1619
};
@@ -93,6 +96,12 @@ class Editor extends React.Component {
9396
});
9497
};
9598

99+
this.closeNotification = () => {
100+
this.setState({
101+
wasLimitReached: false
102+
});
103+
};
104+
96105
this.init = (content) => {
97106
this.setState({
98107
content
@@ -128,11 +137,18 @@ class Editor extends React.Component {
128137
});
129138
if (content.length > 15000) {
130139
console.error('Maximum notepad size reached:', content.length); // eslint-disable-line no-console
131-
migrationBody.textContent = browser.i18n.getMessage('maximumPadSizeExceeded');
140+
// TODO: display 'maximumPadSizeExceeded' notification
141+
this.setState({
142+
wasLimitReached: true,
143+
});
132144
browser.runtime.sendMessage({
133145
action: 'metrics-limit-reached',
134146
context: getPadStats(editor)
135147
});
148+
} else {
149+
this.setState({
150+
wasLimitReached: false,
151+
});
136152
}
137153

138154
chrome.runtime.sendMessage({
@@ -165,21 +181,27 @@ class Editor extends React.Component {
165181
this.loadContent();
166182
}
167183

168-
169184
componentWillUnmount() {
170185
chrome.runtime.onMessage.removeListener(this.events);
171186
}
172187

173188
render() {
174189

175190
return (
176-
<div
177-
id="editor"
178-
ref={node => {
179-
this.node = node;
180-
}}
181-
dangerouslySetInnerHTML={{ __html: this.state.content }}
182-
>
191+
<div className="editorWrapper">
192+
<div
193+
id="editor"
194+
ref={node => {
195+
this.node = node;
196+
}}
197+
dangerouslySetInnerHTML={{ __html: this.state.content }}
198+
>
199+
</div>
200+
{ this.state.wasLimitReached ?
201+
<div id="sync-note" style={{display: 'block'}}>
202+
<button onClick={this.closeNotification}><CloseIcon /></button>
203+
<p>{ browser.i18n.getMessage('maximumPadSizeExceeded') }</p>
204+
</div> : null }
183205
</div>
184206
);
185207
}

src/sidebar/static/scss/ckeditor.scss

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,27 @@
22
CKEditor overrides
33
*/
44

5+
.editorWrapper {
6+
display: flex;
7+
flex: calc(100% - 40px);
8+
flex-direction: column;
9+
flex-grow: 1;
10+
margin: 0;
11+
padding: 0;
12+
overflow: hidden;
13+
position: relative;
14+
15+
}
16+
17+
.ck-editor {
18+
display: flex;
19+
flex-direction: column;
20+
height: 100%;
21+
margin: 0;
22+
overflow: hidden;
23+
padding: 0;
24+
}
25+
526
#notes {
627
.ck-toolbar {
728
border: 0;
@@ -98,3 +119,38 @@
98119
box-shadow: none;
99120
}
100121
}
122+
123+
// CSS related to Notifications
124+
#sync-note {
125+
background: #00FFFE; // green background is: #B6FEB4;
126+
width: 100%;
127+
position: relative;
128+
margin: 0 auto;
129+
border: 0;
130+
border-top: 1px solid #ccc;
131+
color: #424242;
132+
font-size: 12px;
133+
padding: 0px 15% 0px 10px;
134+
135+
button {
136+
width: 16px;
137+
position: absolute;
138+
top: 6px;
139+
right: 6px;
140+
padding: 0 0;
141+
opacity: 0.4;
142+
143+
&:hover {
144+
cursor: pointer;
145+
opacity: 0.6
146+
}
147+
&:active {
148+
cursor: pointer;
149+
opacity: 0.8
150+
}
151+
}
152+
}
153+
154+
155+
156+

src/sidebar/static/scss/styles.scss

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ html {
1212
}
1313

1414
body,
15-
body > div,
16-
body .ck-editor {
15+
body > div {
1716
display: flex;
1817
flex-direction: column;
1918
height: 100%;

0 commit comments

Comments
 (0)