Skip to content

Commit 02bdef1

Browse files
authored
Merge branch 'develop' into feature/add-japanese-translation
2 parents d7aa14d + c83efa2 commit 02bdef1

22 files changed

+450
-225
lines changed

.github/CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Hello! We welcome community contributions to the p5.js Web Editor. Contributing
1818

1919
## Code of Conduct
2020

21-
Please follow the guidelines in the [Code of Conduct](https://github.com/processing/p5.js-web-editor/blob/master/.github/CODE_OF_CONDUCT.md).
21+
Please follow the guidelines in the [Code of Conduct](https://github.com/processing/p5.js-web-editor/blob/develop/.github/CODE_OF_CONDUCT.md).
2222

2323
## How Can I Contribute?
2424
If you're new to open source, [read about how to contribute to open source](https://opensource.guide/how-to-contribute/).
@@ -60,7 +60,7 @@ If you feel like an issue is tagged incorrectly (e.g. it's low priority and you
6060

6161
If you'd like to work on an issue, please comment on it to let the maintainers know, so that they can assign it to you. If someone else has already commented and taken up that issue, please refrain from working on it and submitting a PR without asking the maintainers as it leads to unnecessary duplication of effort.
6262

63-
Then, look at the [development guide](https://github.com/processing/p5.js-web-editor/blob/master/developer_docs/development.md) for instructions on how to install the project locally and follow the right development workflow.
63+
Then, look at the [development guide](https://github.com/processing/p5.js-web-editor/blob/develop/developer_docs/development.md) for instructions on how to install the project locally and follow the right development workflow.
6464

6565
### Contribution Guides
6666

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ Fixes #issue-number
33
I have verified that this pull request:
44

55
* [ ] has no linting errors (`npm run lint`)
6-
* [ ] is from a uniquely-named feature branch and has been rebased on top of the latest master. (If I was asked to make more changes, I have made sure to rebase onto master then too)
7-
* [ ] is descriptively named and links to an issue number, i.e. `Fixes #123`
6+
* [ ] is from a uniquely-named feature branch and has been rebased on top of the latest `develop` branch. (If I was asked to make more changes, I have made sure to rebase onto `develop` then too)
7+
* [ ] is descriptively named and links to an issue number, i.e. `Fixes #123`

.github/config.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ newIssueWelcomeComment: >
1010

1111
# Comment to be posted to on PRs from first time contributors in your repository
1212
newPRWelcomeComment: >
13-
🎉 Thanks for opening this pull request! Please check out our [contributing guidelines](https://github.com/processing/p5.js-web-editor/blob/master/.github/CONTRIBUTING.md) if you haven't already.
13+
🎉 Thanks for opening this pull request! Please check out our [contributing guidelines](https://github.com/processing/p5.js-web-editor/blob/develop/.github/CONTRIBUTING.md) if you haven't already.
1414
1515
# Configuration for first-pr-merge - https://github.com/behaviorbot/first-pr-merge
1616

17-
# Comment to be posted to on pull requests merged by a first time user
17+
# Comment to be posted to on pull requests merged by a first time user

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
Documentation is also available in the following languages:
55

6-
[한국어](https://github.com/processing/p5.js-web-editor/blob/master/translations/ko)
6+
[한국어](https://github.com/processing/p5.js-web-editor/blob/develop/translations/ko)
77

88
## Welcome! 👋👋🏿👋🏽👋🏻👋🏾👋🏼
99

@@ -23,7 +23,7 @@ All contributors to the p5.js Web Editor are expected to follow the [Code of Con
2323

2424
The p5.js Web Editor is a collaborative project created by many individuals, and you are invited to help. All types of involvement are welcome! Please check out the [contribution guide](./.github/CONTRIBUTING.md) for more details.
2525

26-
Developers, check the [developer docs](https://github.com/processing/p5.js-web-editor/blob/master/developer_docs/) details about contributing code, bug fixes, and documentation. To start writing code, a great place to start is the [development guide](https://github.com/processing/p5.js-web-editor/blob/master/developer_docs/development.md).
26+
Developers, check the [developer docs](https://github.com/processing/p5.js-web-editor/blob/develop/developer_docs/) details about contributing code, bug fixes, and documentation. To start writing code, a great place to start is the [development guide](https://github.com/processing/p5.js-web-editor/blob/develop/developer_docs/development.md).
2727

2828
## Issues
2929

client/modules/IDE/components/AssetSize.jsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,11 @@ const AssetSize = ({ totalSize }) => {
3030
const percentSize = percentValue < 1 ? percentValue : 1;
3131

3232
return (
33-
<div className="asset-size" style={{ '--percent': percentSize }}>
34-
<div className="asset-size-bar" />
35-
<p className="asset-current">{currentSize} ({percent})</p>
33+
<div className="asset-size">
34+
<div className="asset-size-bar" style={{ '--percent': percentSize }} />
35+
<p className="asset-current">
36+
{currentSize} ({percent})
37+
</p>
3638
<p className="asset-max">Max: {sizeLimit}</p>
3739
</div>
3840
);

client/modules/IDE/components/PreviewFrame.jsx

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -359,22 +359,38 @@ PreviewFrame.defaultProps = {
359359
cmController: {}
360360
};
361361

362-
const mapStateToProps = state => ({
363-
files: state.files,
364-
htmlFile: getHTMLFile(state.files),
365-
content:
366-
(state.files.find(file => file.isSelectedFile) ||
367-
state.files.find(file => file.name === 'sketch.js') ||
368-
state.files.find(file => file.name !== 'root')).content,
369-
isPlaying: state.ide.isPlaying,
370-
isAccessibleOutputPlaying: state.ide.isAccessibleOutputPlaying,
371-
previewIsRefreshing: state.ide.previewIsRefreshing,
372-
textOutput: state.preferences.textOutput,
373-
gridOutput: state.preferences.gridOutput,
374-
soundOutput: state.preferences.soundOutput,
375-
language: state.preferences.language,
376-
autorefresh: state.preferences.autorefresh,
377-
});
362+
function mapStateToProps(state, ownProps) {
363+
if (ownProps.fullView) {
364+
return {
365+
files: state.files,
366+
htmlFile: getHTMLFile(state.files),
367+
isPlaying: true,
368+
isAccessibleOutputPlaying: false,
369+
textOutput: false,
370+
gridOutput: false,
371+
soundOutput: false,
372+
language: state.preferences.language,
373+
autorefresh: false,
374+
previewIsRefreshing: false
375+
};
376+
}
377+
return {
378+
files: state.files,
379+
htmlFile: getHTMLFile(state.files),
380+
content:
381+
(state.files.find(file => file.isSelectedFile) ||
382+
state.files.find(file => file.name === 'sketch.js') ||
383+
state.files.find(file => file.name !== 'root')).content,
384+
isPlaying: state.ide.isPlaying,
385+
isAccessibleOutputPlaying: state.ide.isAccessibleOutputPlaying,
386+
previewIsRefreshing: state.ide.previewIsRefreshing,
387+
textOutput: state.preferences.textOutput,
388+
gridOutput: state.preferences.gridOutput,
389+
soundOutput: state.preferences.soundOutput,
390+
language: state.preferences.language,
391+
autorefresh: state.preferences.autorefresh
392+
};
393+
}
378394

379395

380396
const mapDispatchToProps = {

client/modules/IDE/hooks/useHandleMessageEvent.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { useDispatch } from 'react-redux';
22
import { Decode } from 'console-feed';
33
import { isEqual } from 'lodash';
44
import { dispatchConsoleEvent } from '../actions/console';
5-
import { stopSketch, expandConsole } from '../actions/console';
5+
import { stopSketch, expandConsole } from '../actions/ide';
66

77
export default function useHandleMessageEvent() {
88
const dispatch = useDispatch();

client/modules/IDE/pages/FullView.jsx

Lines changed: 2 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,13 @@ import { bindActionCreators } from 'redux';
55
import { connect } from 'react-redux';
66
import PreviewFrame from '../components/PreviewFrame';
77
import PreviewNav from '../../../components/PreviewNav';
8-
import { getHTMLFile, getJSFiles, getCSSFiles } from '../reducers/files';
98
import * as ProjectActions from '../actions/project';
109

1110
class FullView extends React.Component {
1211
componentDidMount() {
1312
this.props.getProject(this.props.params.project_id, this.props.params.username);
1413
}
1514

16-
ident = () => {}
17-
1815
render() {
1916
return (
2017
<div className="fullscreen-preview">
@@ -27,26 +24,7 @@ class FullView extends React.Component {
2724
/>
2825
<main className="preview-frame-holder">
2926
<PreviewFrame
30-
htmlFile={this.props.htmlFile}
31-
jsFiles={this.props.jsFiles}
32-
cssFiles={this.props.cssFiles}
33-
files={this.props.files}
34-
head={
35-
<link type="text/css" rel="stylesheet" href="/preview-styles.css" />
36-
}
3727
fullView
38-
isPlaying
39-
isAccessibleOutputPlaying={false}
40-
textOutput={false}
41-
gridOutput={false}
42-
soundOutput={false}
43-
dispatchConsoleEvent={this.ident}
44-
endSketchRefresh={this.ident}
45-
previewIsRefreshing={false}
46-
setBlobUrl={this.ident}
47-
stopSketch={this.ident}
48-
expandConsole={this.ident}
49-
clearConsole={this.ident}
5028
/>
5129
</main>
5230
</div>
@@ -65,37 +43,12 @@ FullView.propTypes = {
6543
username: PropTypes.string
6644
})
6745
}).isRequired,
68-
htmlFile: PropTypes.shape({
69-
id: PropTypes.string.isRequired,
70-
content: PropTypes.string.isRequired,
71-
name: PropTypes.string.isRequired
72-
}).isRequired,
73-
jsFiles: PropTypes.arrayOf(PropTypes.shape({
74-
id: PropTypes.string.isRequired,
75-
content: PropTypes.string.isRequired,
76-
name: PropTypes.string.isRequired
77-
})).isRequired,
78-
cssFiles: PropTypes.arrayOf(PropTypes.shape({
79-
id: PropTypes.string.isRequired,
80-
content: PropTypes.string.isRequired,
81-
name: PropTypes.string.isRequired
82-
})).isRequired,
83-
getProject: PropTypes.func.isRequired,
84-
files: PropTypes.arrayOf(PropTypes.shape({
85-
id: PropTypes.string.isRequired,
86-
content: PropTypes.string.isRequired,
87-
name: PropTypes.string.isRequired
88-
})).isRequired,
46+
getProject: PropTypes.func.isRequired
8947
};
9048

9149
function mapStateToProps(state) {
9250
return {
93-
user: state.user,
94-
htmlFile: getHTMLFile(state.files),
95-
jsFiles: getJSFiles(state.files),
96-
cssFiles: getCSSFiles(state.files),
97-
project: state.project,
98-
files: state.files
51+
project: state.project
9952
};
10053
}
10154

client/modules/IDE/pages/IDEView.jsx

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -42,30 +42,16 @@ function getTitle(props) {
4242
return id ? `p5.js Web Editor | ${props.project.name}` : 'p5.js Web Editor';
4343
}
4444

45-
function warnIfUnsavedChanges(props) {
46-
// eslint-disable-line
47-
const { route } = props.route;
48-
if (
49-
route &&
50-
route.action === 'PUSH' &&
51-
(route.pathname === '/login' || route.pathname === '/signup')
52-
) {
53-
// don't warn
54-
props.persistState();
55-
window.onbeforeunload = null;
56-
} else if (
57-
route &&
58-
(props.location.pathname === '/login' ||
59-
props.location.pathname === '/signup')
60-
) {
61-
// don't warn
62-
props.persistState();
63-
window.onbeforeunload = null;
64-
} else if (props.ide.unsavedChanges) {
45+
function warnIfUnsavedChanges(props, nextLocation) {
46+
const toAuth = nextLocation &&
47+
nextLocation.action === 'PUSH' &&
48+
(nextLocation.pathname === '/login' || nextLocation.pathname === '/signup');
49+
const onAuth = nextLocation &&
50+
(props.location.pathname === '/login' || props.location.pathname === '/signup');
51+
if (props.ide.unsavedChanges && (!toAuth && !onAuth)) {
6552
if (!window.confirm(props.t('Nav.WarningUnsavedChanges'))) {
6653
return false;
6754
}
68-
props.setUnsavedChanges(false);
6955
return true;
7056
}
7157
return true;
@@ -103,7 +89,8 @@ class IDEView extends React.Component {
10389
this.handleUnsavedChanges
10490
);
10591

106-
window.onbeforeunload = this.handleUnsavedChanges;
92+
// window.onbeforeunload = this.handleUnsavedChanges;
93+
window.addEventListener('beforeunload', this.handleBeforeUnload);
10794

10895
this.autosaveInterval = null;
10996
}
@@ -247,7 +234,16 @@ class IDEView extends React.Component {
247234
}
248235
}
249236

250-
handleUnsavedChanges = () => warnIfUnsavedChanges(this.props);
237+
handleUnsavedChanges = nextLocation => warnIfUnsavedChanges(this.props, nextLocation);
238+
239+
handleBeforeUnload = (e) => {
240+
const confirmationMessage = this.props.t('Nav.WarningUnsavedChanges');
241+
if (this.props.ide.unsavedChanges) {
242+
(e || window.event).returnValue = confirmationMessage;
243+
return confirmationMessage;
244+
}
245+
return null;
246+
}
251247

252248
render() {
253249
return (

client/styles/components/_keyboard-shortcuts.scss

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
.keyboard-shortcuts {
22
padding: #{20 / $base-font-size}rem;
3+
margin-right: #{20 / $base-font-size}rem;
34
padding-bottom: #{40 / $base-font-size}rem;
45
width: #{450 / $base-font-size}rem;
6+
overflow-y: scroll;
57
}
68

79
.keyboard-shortcuts-note {

0 commit comments

Comments
 (0)