2018-02-07 19:06:07 +01:00
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import React from 'react';
|
2016-06-24 00:29:55 +02:00
|
|
|
import CodeMirror from 'codemirror';
|
2016-09-07 21:05:25 +02:00
|
|
|
import beautifyJS from 'js-beautify';
|
2016-07-14 01:52:50 +02:00
|
|
|
import 'codemirror/mode/css/css';
|
2016-06-24 00:29:55 +02:00
|
|
|
import 'codemirror/addon/selection/active-line';
|
2016-07-12 23:38:24 +02:00
|
|
|
import 'codemirror/addon/lint/lint';
|
|
|
|
import 'codemirror/addon/lint/javascript-lint';
|
2016-07-14 01:52:50 +02:00
|
|
|
import 'codemirror/addon/lint/css-lint';
|
|
|
|
import 'codemirror/addon/lint/html-lint';
|
2017-07-17 22:07:59 +02:00
|
|
|
import 'codemirror/addon/fold/brace-fold';
|
|
|
|
import 'codemirror/addon/fold/comment-fold';
|
|
|
|
import 'codemirror/addon/fold/foldcode';
|
|
|
|
import 'codemirror/addon/fold/foldgutter';
|
|
|
|
import 'codemirror/addon/fold/indent-fold';
|
2016-07-21 20:33:23 +02:00
|
|
|
import 'codemirror/addon/comment/comment';
|
|
|
|
import 'codemirror/keymap/sublime';
|
2017-06-06 21:20:21 +02:00
|
|
|
import 'codemirror/addon/search/searchcursor';
|
|
|
|
import 'codemirror/addon/search/matchesonscrollbar';
|
|
|
|
import 'codemirror/addon/search/match-highlighter';
|
2016-08-05 22:58:59 +02:00
|
|
|
import 'codemirror/addon/search/jump-to-line';
|
2018-10-08 19:14:59 +02:00
|
|
|
import 'codemirror/addon/edit/matchbrackets';
|
2017-06-06 21:20:21 +02:00
|
|
|
|
2016-07-12 23:38:24 +02:00
|
|
|
import { JSHINT } from 'jshint';
|
2016-07-14 01:52:50 +02:00
|
|
|
import { CSSLint } from 'csslint';
|
|
|
|
import { HTMLHint } from 'htmlhint';
|
2016-09-07 22:33:01 +02:00
|
|
|
import InlineSVG from 'react-inlinesvg';
|
|
|
|
import classNames from 'classnames';
|
2016-10-19 19:29:02 +02:00
|
|
|
import { debounce } from 'lodash';
|
2017-02-22 20:29:35 +01:00
|
|
|
import '../../../utils/htmlmixed';
|
|
|
|
import '../../../utils/p5-javascript';
|
2018-05-31 00:23:32 +02:00
|
|
|
import '../../../utils/webGL-clike';
|
2016-11-09 18:52:14 +01:00
|
|
|
import Timer from '../components/Timer';
|
2017-02-22 20:29:35 +01:00
|
|
|
import EditorAccessibility from '../components/EditorAccessibility';
|
2019-01-16 23:56:18 +01:00
|
|
|
import { metaKey, } from '../../../utils/metaKey';
|
2017-06-06 21:20:21 +02:00
|
|
|
|
|
|
|
import search from '../../../utils/codemirror-search';
|
|
|
|
|
|
|
|
search(CodeMirror);
|
2017-02-22 20:29:35 +01:00
|
|
|
|
|
|
|
const beautifyCSS = beautifyJS.css;
|
|
|
|
const beautifyHTML = beautifyJS.html;
|
|
|
|
|
|
|
|
window.JSHINT = JSHINT;
|
|
|
|
window.CSSLint = CSSLint;
|
|
|
|
window.HTMLHint = HTMLHint;
|
2016-06-24 00:29:55 +02:00
|
|
|
|
2017-02-22 20:29:35 +01:00
|
|
|
const beepUrl = require('../../../sounds/audioAlert.mp3');
|
|
|
|
const unsavedChangesDotUrl = require('../../../images/unsaved-changes-dot.svg');
|
2016-12-19 23:07:04 +01:00
|
|
|
const rightArrowUrl = require('../../../images/right-arrow.svg');
|
|
|
|
const leftArrowUrl = require('../../../images/left-arrow.svg');
|
|
|
|
|
2019-03-24 01:53:07 +01:00
|
|
|
const IS_TAB_INDENT = false;
|
|
|
|
const INDENTATION_AMOUNT = 2;
|
|
|
|
|
2016-06-24 00:29:55 +02:00
|
|
|
class Editor extends React.Component {
|
2016-09-07 22:41:56 +02:00
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
|
|
|
this.tidyCode = this.tidyCode.bind(this);
|
2017-07-26 21:17:05 +02:00
|
|
|
|
|
|
|
this.updateLintingMessageAccessibility = debounce((annotations) => {
|
|
|
|
this.props.clearLintMessage();
|
|
|
|
annotations.forEach((x) => {
|
|
|
|
if (x.from.line > -1) {
|
|
|
|
this.props.updateLintMessage(x.severity, (x.from.line + 1), x.message);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
if (this.props.lintMessages.length > 0 && this.props.lintWarning) {
|
|
|
|
this.beep.play();
|
|
|
|
}
|
|
|
|
}, 2000);
|
2017-09-01 18:40:15 +02:00
|
|
|
this.showFind = this.showFind.bind(this);
|
2017-09-14 22:58:59 +02:00
|
|
|
this.findNext = this.findNext.bind(this);
|
|
|
|
this.findPrev = this.findPrev.bind(this);
|
2019-02-25 22:45:20 +01:00
|
|
|
this.getContent = this.getContent.bind(this);
|
2016-09-07 22:41:56 +02:00
|
|
|
}
|
2017-10-12 21:38:02 +02:00
|
|
|
|
2016-06-24 00:29:55 +02:00
|
|
|
componentDidMount() {
|
2016-08-15 17:51:11 +02:00
|
|
|
this.beep = new Audio(beepUrl);
|
2016-09-12 07:31:30 +02:00
|
|
|
this.widgets = [];
|
2017-02-22 20:29:35 +01:00
|
|
|
this._cm = CodeMirror(this.codemirrorContainer, { // eslint-disable-line
|
2016-09-20 17:51:09 +02:00
|
|
|
theme: `p5-${this.props.theme}`,
|
2019-08-30 18:36:34 +02:00
|
|
|
lineNumbers: this.props.lineNumbers,
|
2016-06-24 00:29:55 +02:00
|
|
|
styleActiveLine: true,
|
2016-07-13 17:59:47 +02:00
|
|
|
inputStyle: 'contenteditable',
|
2019-03-26 20:37:44 +01:00
|
|
|
lineWrapping: this.props.linewrap,
|
2016-10-05 18:26:49 +02:00
|
|
|
fixedGutter: false,
|
2017-07-17 22:07:59 +02:00
|
|
|
foldGutter: true,
|
2017-07-18 21:57:40 +02:00
|
|
|
foldOptions: { widget: '\u2026' },
|
2017-10-12 22:19:18 +02:00
|
|
|
gutters: ['CodeMirror-foldgutter', 'CodeMirror-lint-markers'],
|
2016-08-05 22:58:59 +02:00
|
|
|
keyMap: 'sublime',
|
2017-06-06 21:20:21 +02:00
|
|
|
highlightSelectionMatches: true, // highlight current search match
|
2018-10-08 19:14:59 +02:00
|
|
|
matchBrackets: true,
|
2016-08-05 22:58:59 +02:00
|
|
|
lint: {
|
2017-07-26 21:17:05 +02:00
|
|
|
onUpdateLinting: ((annotations) => {
|
|
|
|
this.props.hideRuntimeErrorWarning();
|
|
|
|
this.updateLintingMessageAccessibility(annotations);
|
|
|
|
}),
|
2016-12-13 22:59:47 +01:00
|
|
|
options: {
|
2017-02-22 20:29:35 +01:00
|
|
|
'asi': true,
|
|
|
|
'eqeqeq': false,
|
2017-09-14 20:32:43 +02:00
|
|
|
'-W041': false,
|
2019-02-25 22:52:07 +01:00
|
|
|
'esversion': 7
|
2016-12-13 22:59:47 +01:00
|
|
|
}
|
2016-08-05 22:58:59 +02:00
|
|
|
}
|
2016-06-24 00:29:55 +02:00
|
|
|
});
|
2016-09-21 00:27:10 +02:00
|
|
|
|
2018-10-10 23:40:47 +02:00
|
|
|
delete this._cm.options.lint.options.errors;
|
|
|
|
|
2017-02-17 19:30:33 +01:00
|
|
|
this._cm.setOption('extraKeys', {
|
2019-09-26 22:58:21 +02:00
|
|
|
Tab: (cm) => {
|
|
|
|
// might need to specify and indent more?
|
|
|
|
const selection = cm.doc.getSelection();
|
|
|
|
if (selection.length > 0) {
|
|
|
|
cm.execCommand('indentMore');
|
|
|
|
} else {
|
|
|
|
cm.replaceSelection(' '.repeat(INDENTATION_AMOUNT));
|
|
|
|
}
|
|
|
|
},
|
2017-06-06 21:20:21 +02:00
|
|
|
[`${metaKey}-Enter`]: () => null,
|
|
|
|
[`Shift-${metaKey}-Enter`]: () => null,
|
|
|
|
[`${metaKey}-F`]: 'findPersistent',
|
|
|
|
[`${metaKey}-G`]: 'findNext',
|
|
|
|
[`Shift-${metaKey}-G`]: 'findPrev',
|
2017-02-17 19:30:33 +01:00
|
|
|
});
|
|
|
|
|
2016-12-07 03:33:12 +01:00
|
|
|
this.initializeDocuments(this.props.files);
|
|
|
|
this._cm.swapDoc(this._docs[this.props.file.id]);
|
|
|
|
|
2016-10-19 19:29:02 +02:00
|
|
|
this._cm.on('change', debounce(() => {
|
2016-09-21 00:27:10 +02:00
|
|
|
this.props.setUnsavedChanges(true);
|
2019-02-25 18:57:10 +01:00
|
|
|
this.props.updateFileContent(this.props.file.id, this._cm.getValue());
|
2016-10-04 21:35:23 +02:00
|
|
|
if (this.props.autorefresh && this.props.isPlaying) {
|
2017-02-17 22:04:47 +01:00
|
|
|
this.props.clearConsole();
|
2018-07-30 18:20:57 +02:00
|
|
|
this.props.startRefreshSketch();
|
2016-10-04 21:35:23 +02:00
|
|
|
}
|
2019-10-03 22:16:54 +02:00
|
|
|
}, 1000));
|
2016-09-21 00:27:10 +02:00
|
|
|
|
2016-08-05 22:58:59 +02:00
|
|
|
this._cm.on('keyup', () => {
|
2016-08-25 18:32:06 +02:00
|
|
|
const temp = `line ${parseInt((this._cm.getCursor().line) + 1, 10)}`;
|
|
|
|
document.getElementById('current-line').innerHTML = temp;
|
2016-08-05 22:58:59 +02:00
|
|
|
});
|
2016-09-07 18:16:26 +02:00
|
|
|
|
|
|
|
this._cm.on('keydown', (_cm, e) => {
|
2016-10-20 00:35:59 +02:00
|
|
|
// 9 === Tab
|
|
|
|
if (e.keyCode === 9 && e.shiftKey) {
|
2016-09-07 22:41:56 +02:00
|
|
|
this.tidyCode();
|
2016-09-07 18:16:26 +02:00
|
|
|
}
|
|
|
|
});
|
2016-09-21 00:27:10 +02:00
|
|
|
|
|
|
|
this._cm.getWrapperElement().style['font-size'] = `${this.props.fontSize}px`;
|
2017-09-01 18:40:15 +02:00
|
|
|
|
|
|
|
this.props.provideController({
|
|
|
|
tidyCode: this.tidyCode,
|
2017-09-14 22:58:59 +02:00
|
|
|
showFind: this.showFind,
|
|
|
|
findNext: this.findNext,
|
2019-02-25 22:45:20 +01:00
|
|
|
findPrev: this.findPrev,
|
|
|
|
getContent: this.getContent
|
2017-09-01 18:40:15 +02:00
|
|
|
});
|
2016-06-24 00:29:55 +02:00
|
|
|
}
|
|
|
|
|
2016-12-07 03:33:12 +01:00
|
|
|
componentWillUpdate(nextProps) {
|
|
|
|
// check if files have changed
|
|
|
|
if (this.props.files[0].id !== nextProps.files[0].id) {
|
|
|
|
// then need to make CodeMirror documents
|
|
|
|
this.initializeDocuments(nextProps.files);
|
|
|
|
}
|
2016-12-09 22:27:10 +01:00
|
|
|
if (this.props.files.length !== nextProps.files.length) {
|
|
|
|
this.initializeDocuments(nextProps.files);
|
|
|
|
}
|
2016-12-07 03:33:12 +01:00
|
|
|
}
|
|
|
|
|
2016-06-24 00:29:55 +02:00
|
|
|
componentDidUpdate(prevProps) {
|
2016-07-08 21:58:49 +02:00
|
|
|
if (this.props.file.content !== prevProps.file.content &&
|
|
|
|
this.props.file.content !== this._cm.getValue()) {
|
2016-12-07 03:33:12 +01:00
|
|
|
const oldDoc = this._cm.swapDoc(this._docs[this.props.file.id]);
|
|
|
|
this._docs[prevProps.file.id] = oldDoc;
|
|
|
|
this._cm.focus();
|
2016-11-08 19:30:41 +01:00
|
|
|
if (!prevProps.unsavedChanges) {
|
|
|
|
setTimeout(() => this.props.setUnsavedChanges(false), 400);
|
|
|
|
}
|
2016-06-24 00:29:55 +02:00
|
|
|
}
|
|
|
|
if (this.props.fontSize !== prevProps.fontSize) {
|
|
|
|
this._cm.getWrapperElement().style['font-size'] = `${this.props.fontSize}px`;
|
|
|
|
}
|
2019-03-26 20:37:44 +01:00
|
|
|
if (this.props.linewrap !== prevProps.linewrap) {
|
|
|
|
this._cm.setOption('lineWrapping', this.props.linewrap);
|
|
|
|
}
|
2016-09-20 17:51:09 +02:00
|
|
|
if (this.props.theme !== prevProps.theme) {
|
|
|
|
this._cm.setOption('theme', `p5-${this.props.theme}`);
|
|
|
|
}
|
2019-08-30 18:36:34 +02:00
|
|
|
if (this.props.lineNumbers !== prevProps.lineNumbers) {
|
|
|
|
this._cm.setOption('lineNumbers', this.props.lineNumbers);
|
|
|
|
}
|
2017-07-26 20:46:59 +02:00
|
|
|
|
|
|
|
if (prevProps.consoleEvents !== this.props.consoleEvents) {
|
|
|
|
this.props.showRuntimeErrorWarning();
|
|
|
|
}
|
2018-02-16 17:56:44 +01:00
|
|
|
for (let i = 0; i < this._cm.lineCount(); i += 1) {
|
2017-07-17 23:27:21 +02:00
|
|
|
this._cm.removeLineClass(i, 'background', 'line-runtime-error');
|
|
|
|
}
|
2019-08-27 19:02:07 +02:00
|
|
|
if (this.props.runtimeErrorWarningVisible) {
|
2017-07-26 20:46:59 +02:00
|
|
|
this.props.consoleEvents.forEach((consoleEvent) => {
|
|
|
|
if (consoleEvent.method === 'error') {
|
2019-02-20 21:57:37 +01:00
|
|
|
if (consoleEvent.data &&
|
|
|
|
consoleEvent.data[0] &&
|
|
|
|
consoleEvent.data[0].indexOf &&
|
|
|
|
consoleEvent.data[0].indexOf(')') > -1) {
|
2018-11-21 00:00:54 +01:00
|
|
|
const n = consoleEvent.data[0].replace(')', '').split(' ');
|
2018-02-08 23:40:21 +01:00
|
|
|
const lineNumber = parseInt(n[n.length - 1], 10) - 1;
|
2019-08-27 19:02:07 +02:00
|
|
|
const { source } = consoleEvent;
|
|
|
|
const fileName = this.props.file.name;
|
|
|
|
const errorFromJavaScriptFile = (`${source}.js` === fileName);
|
|
|
|
const errorFromIndexHTML = ((source === fileName) && (fileName === 'index.html'));
|
|
|
|
if (!Number.isNaN(lineNumber) && (errorFromJavaScriptFile || errorFromIndexHTML)) {
|
2019-02-20 21:57:37 +01:00
|
|
|
this._cm.addLineClass(lineNumber, 'background', 'line-runtime-error');
|
|
|
|
}
|
2018-02-08 23:40:21 +01:00
|
|
|
}
|
2017-07-26 20:46:59 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2016-06-24 00:29:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
componentWillUnmount() {
|
|
|
|
this._cm = null;
|
2017-09-01 18:40:15 +02:00
|
|
|
this.props.provideController(null);
|
2016-06-24 00:29:55 +02:00
|
|
|
}
|
|
|
|
|
2016-12-07 03:33:12 +01:00
|
|
|
getFileMode(fileName) {
|
|
|
|
let mode;
|
|
|
|
if (fileName.match(/.+\.js$/i)) {
|
2016-12-13 22:59:47 +01:00
|
|
|
mode = 'javascript';
|
2016-12-07 03:33:12 +01:00
|
|
|
} else if (fileName.match(/.+\.css$/i)) {
|
|
|
|
mode = 'css';
|
|
|
|
} else if (fileName.match(/.+\.html$/i)) {
|
|
|
|
mode = 'htmlmixed';
|
|
|
|
} else if (fileName.match(/.+\.json$/i)) {
|
|
|
|
mode = 'application/json';
|
2018-05-31 00:23:32 +02:00
|
|
|
} else if (fileName.match(/.+\.(frag|vert)$/i)) {
|
|
|
|
mode = 'clike';
|
2016-12-07 03:33:12 +01:00
|
|
|
} else {
|
|
|
|
mode = 'text/plain';
|
|
|
|
}
|
|
|
|
return mode;
|
|
|
|
}
|
|
|
|
|
2019-02-25 22:45:20 +01:00
|
|
|
getContent() {
|
|
|
|
const content = this._cm.getValue();
|
|
|
|
const updatedFile = Object.assign({}, this.props.file, { content });
|
|
|
|
return updatedFile;
|
|
|
|
}
|
|
|
|
|
|
|
|
findPrev() {
|
|
|
|
this._cm.focus();
|
|
|
|
this._cm.execCommand('findPrev');
|
|
|
|
}
|
|
|
|
|
|
|
|
findNext() {
|
|
|
|
this._cm.focus();
|
|
|
|
this._cm.execCommand('findNext');
|
|
|
|
}
|
|
|
|
|
|
|
|
showFind() {
|
|
|
|
this._cm.execCommand('findPersistent');
|
2016-12-07 03:33:12 +01:00
|
|
|
}
|
|
|
|
|
2016-09-07 22:41:56 +02:00
|
|
|
tidyCode() {
|
|
|
|
const beautifyOptions = {
|
2019-03-24 01:53:07 +01:00
|
|
|
indent_size: INDENTATION_AMOUNT,
|
|
|
|
indent_with_tabs: IS_TAB_INDENT
|
2016-09-07 22:41:56 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
const mode = this._cm.getOption('mode');
|
|
|
|
if (mode === 'javascript') {
|
|
|
|
this._cm.doc.setValue(beautifyJS(this._cm.doc.getValue(), beautifyOptions));
|
|
|
|
} else if (mode === 'css') {
|
|
|
|
this._cm.doc.setValue(beautifyCSS(this._cm.doc.getValue(), beautifyOptions));
|
|
|
|
} else if (mode === 'htmlmixed') {
|
|
|
|
this._cm.doc.setValue(beautifyHTML(this._cm.doc.getValue(), beautifyOptions));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-02-25 22:45:20 +01:00
|
|
|
initializeDocuments(files) {
|
|
|
|
this._docs = {};
|
|
|
|
files.forEach((file) => {
|
|
|
|
if (file.name !== 'root') {
|
|
|
|
this._docs[file.id] = CodeMirror.Doc(file.content, this.getFileMode(file.name)); // eslint-disable-line
|
|
|
|
}
|
|
|
|
});
|
2017-09-01 18:40:15 +02:00
|
|
|
}
|
|
|
|
|
2017-01-09 18:47:32 +01:00
|
|
|
toggleEditorOptions() {
|
|
|
|
if (this.props.editorOptionsVisible) {
|
|
|
|
this.props.closeEditorOptions();
|
|
|
|
} else {
|
2017-02-22 20:29:35 +01:00
|
|
|
this.optionsButton.focus();
|
2017-01-09 18:47:32 +01:00
|
|
|
this.props.showEditorOptions();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-24 00:29:55 +02:00
|
|
|
render() {
|
2016-09-07 22:33:01 +02:00
|
|
|
const editorSectionClass = classNames({
|
2017-02-22 20:29:35 +01:00
|
|
|
'editor': true,
|
2016-12-19 23:07:04 +01:00
|
|
|
'sidebar--contracted': !this.props.isExpanded,
|
2016-09-07 22:33:01 +02:00
|
|
|
'editor--options': this.props.editorOptionsVisible
|
|
|
|
});
|
|
|
|
|
2019-06-12 23:11:35 +02:00
|
|
|
const editorHolderClass = classNames({
|
|
|
|
'editor-holder': true,
|
|
|
|
'editor-holder--hidden': this.props.file.fileType === 'folder' || this.props.file.url
|
|
|
|
});
|
|
|
|
|
2016-08-05 22:58:59 +02:00
|
|
|
return (
|
2016-09-07 18:16:26 +02:00
|
|
|
<section
|
|
|
|
title="code editor"
|
|
|
|
role="main"
|
2016-09-07 22:33:01 +02:00
|
|
|
className={editorSectionClass}
|
2016-09-07 18:16:26 +02:00
|
|
|
>
|
2017-01-05 20:40:04 +01:00
|
|
|
<header className="editor__header">
|
|
|
|
<button
|
|
|
|
aria-label="collapse file navigation"
|
|
|
|
className="sidebar__contract"
|
|
|
|
onClick={this.props.collapseSidebar}
|
|
|
|
>
|
|
|
|
<InlineSVG src={leftArrowUrl} />
|
|
|
|
</button>
|
|
|
|
<button
|
|
|
|
aria-label="expand file navigation"
|
|
|
|
className="sidebar__expand"
|
|
|
|
onClick={this.props.expandSidebar}
|
|
|
|
>
|
|
|
|
<InlineSVG src={rightArrowUrl} />
|
|
|
|
</button>
|
|
|
|
<div className="editor__file-name">
|
2017-01-06 19:08:03 +01:00
|
|
|
<span>
|
|
|
|
{this.props.file.name}
|
|
|
|
{this.props.unsavedChanges ? <InlineSVG src={unsavedChangesDotUrl} /> : null}
|
|
|
|
</span>
|
2017-01-05 20:40:04 +01:00
|
|
|
<Timer
|
|
|
|
projectSavedTime={this.props.projectSavedTime}
|
2017-01-13 17:55:13 +01:00
|
|
|
isUserOwner={this.props.isUserOwner}
|
2017-01-05 20:40:04 +01:00
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</header>
|
2019-06-12 23:11:35 +02:00
|
|
|
<div ref={(element) => { this.codemirrorContainer = element; }} className={editorHolderClass} >
|
2016-08-12 03:26:49 +02:00
|
|
|
</div>
|
|
|
|
<EditorAccessibility
|
|
|
|
lintMessages={this.props.lintMessages}
|
|
|
|
/>
|
2016-08-12 20:19:23 +02:00
|
|
|
</section>
|
2016-08-05 22:58:59 +02:00
|
|
|
);
|
2016-06-24 00:29:55 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-27 22:03:22 +02:00
|
|
|
Editor.propTypes = {
|
2019-08-30 18:36:34 +02:00
|
|
|
lineNumbers: PropTypes.bool.isRequired,
|
2016-08-11 20:09:59 +02:00
|
|
|
lintWarning: PropTypes.bool.isRequired,
|
2019-03-26 20:37:44 +01:00
|
|
|
linewrap: PropTypes.bool.isRequired,
|
2017-02-22 20:29:35 +01:00
|
|
|
lintMessages: PropTypes.arrayOf(PropTypes.shape({
|
|
|
|
severity: PropTypes.string.isRequired,
|
|
|
|
line: PropTypes.number.isRequired,
|
|
|
|
message: PropTypes.string.isRequired,
|
|
|
|
id: PropTypes.number.isRequired
|
|
|
|
})).isRequired,
|
2017-07-17 23:27:21 +02:00
|
|
|
consoleEvents: PropTypes.arrayOf(PropTypes.shape({
|
|
|
|
method: PropTypes.string.isRequired,
|
|
|
|
args: PropTypes.arrayOf(PropTypes.string)
|
|
|
|
})),
|
2016-08-11 19:24:02 +02:00
|
|
|
updateLintMessage: PropTypes.func.isRequired,
|
|
|
|
clearLintMessage: PropTypes.func.isRequired,
|
2016-07-12 05:40:30 +02:00
|
|
|
updateFileContent: PropTypes.func.isRequired,
|
|
|
|
fontSize: PropTypes.number.isRequired,
|
2016-07-08 21:58:49 +02:00
|
|
|
file: PropTypes.shape({
|
|
|
|
name: PropTypes.string.isRequired,
|
2016-12-07 03:33:12 +01:00
|
|
|
content: PropTypes.string.isRequired,
|
2019-06-12 23:11:35 +02:00
|
|
|
id: PropTypes.string.isRequired,
|
|
|
|
fileType: PropTypes.string.isRequired,
|
2019-08-28 22:08:40 +02:00
|
|
|
url: PropTypes.string
|
2017-02-22 20:29:35 +01:00
|
|
|
}).isRequired,
|
2016-09-07 22:33:01 +02:00
|
|
|
editorOptionsVisible: PropTypes.bool.isRequired,
|
|
|
|
showEditorOptions: PropTypes.func.isRequired,
|
2016-09-07 23:47:22 +02:00
|
|
|
closeEditorOptions: PropTypes.func.isRequired,
|
2016-09-20 17:51:09 +02:00
|
|
|
setUnsavedChanges: PropTypes.func.isRequired,
|
2016-09-29 06:54:35 +02:00
|
|
|
startRefreshSketch: PropTypes.func.isRequired,
|
|
|
|
autorefresh: PropTypes.bool.isRequired,
|
2016-09-22 23:17:24 +02:00
|
|
|
isPlaying: PropTypes.bool.isRequired,
|
2016-09-29 06:54:35 +02:00
|
|
|
theme: PropTypes.string.isRequired,
|
2016-11-09 18:52:14 +01:00
|
|
|
unsavedChanges: PropTypes.bool.isRequired,
|
2016-12-07 03:33:12 +01:00
|
|
|
projectSavedTime: PropTypes.string.isRequired,
|
2017-02-22 20:29:35 +01:00
|
|
|
files: PropTypes.arrayOf(PropTypes.shape({
|
|
|
|
id: PropTypes.string.isRequired,
|
|
|
|
name: PropTypes.string.isRequired,
|
|
|
|
content: PropTypes.string.isRequired
|
|
|
|
})).isRequired,
|
2016-12-19 23:07:04 +01:00
|
|
|
isExpanded: PropTypes.bool.isRequired,
|
|
|
|
collapseSidebar: PropTypes.func.isRequired,
|
2017-01-13 17:55:13 +01:00
|
|
|
expandSidebar: PropTypes.func.isRequired,
|
2017-02-17 22:04:47 +01:00
|
|
|
isUserOwner: PropTypes.bool,
|
2017-07-26 20:46:59 +02:00
|
|
|
clearConsole: PropTypes.func.isRequired,
|
|
|
|
showRuntimeErrorWarning: PropTypes.func.isRequired,
|
|
|
|
hideRuntimeErrorWarning: PropTypes.func.isRequired,
|
|
|
|
runtimeErrorWarningVisible: PropTypes.bool.isRequired,
|
2017-09-01 18:40:15 +02:00
|
|
|
provideController: PropTypes.func.isRequired
|
2016-06-27 22:03:22 +02:00
|
|
|
};
|
|
|
|
|
2017-02-22 20:29:35 +01:00
|
|
|
Editor.defaultProps = {
|
2017-07-17 23:27:21 +02:00
|
|
|
isUserOwner: false,
|
2017-07-26 20:46:59 +02:00
|
|
|
consoleEvents: [],
|
2017-02-22 20:29:35 +01:00
|
|
|
};
|
|
|
|
|
2016-06-24 00:29:55 +02:00
|
|
|
export default Editor;
|