|
@@ -19,6 +19,10 @@ export default class Editor extends AbstractEditor {
|
|
|
isUploading: false,
|
|
isUploading: false,
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
+ this.getEditorSubstance = this.getEditorSubstance.bind(this);
|
|
|
|
|
+
|
|
|
|
|
+ this.setCaretLine = this.setCaretLine.bind(this);
|
|
|
|
|
+
|
|
|
this.dragEnterHandler = this.dragEnterHandler.bind(this);
|
|
this.dragEnterHandler = this.dragEnterHandler.bind(this);
|
|
|
this.dragLeaveHandler = this.dragLeaveHandler.bind(this);
|
|
this.dragLeaveHandler = this.dragLeaveHandler.bind(this);
|
|
|
this.dropHandler = this.dropHandler.bind(this);
|
|
this.dropHandler = this.dropHandler.bind(this);
|
|
@@ -33,42 +37,38 @@ export default class Editor extends AbstractEditor {
|
|
|
this.setCaretLine(0);
|
|
this.setCaretLine(0);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ getEditorSubstance() {
|
|
|
|
|
+ return this.props.isMobile
|
|
|
|
|
+ ? this.refs.simpleEditor
|
|
|
|
|
+ : this.refs.cmEditor;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * @inheritDoc
|
|
|
|
|
+ */
|
|
|
forceToFocus() {
|
|
forceToFocus() {
|
|
|
- if (this.props.isMobile) {
|
|
|
|
|
- }
|
|
|
|
|
- else {
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ this.getEditorSubstance().forceToFocus();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * set caret position of codemirror
|
|
|
|
|
- * @param {string} number
|
|
|
|
|
|
|
+ * @inheritDoc
|
|
|
*/
|
|
*/
|
|
|
setCaretLine(line) {
|
|
setCaretLine(line) {
|
|
|
- if (this.props.isMobile) {
|
|
|
|
|
- }
|
|
|
|
|
- else {
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ this.getEditorSubstance().setCaretLine(line);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* @inheritDoc
|
|
* @inheritDoc
|
|
|
*/
|
|
*/
|
|
|
setScrollTopByLine(line) {
|
|
setScrollTopByLine(line) {
|
|
|
- if (this.props.isMobile) {
|
|
|
|
|
- }
|
|
|
|
|
- else {
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ this.getEditorSubstance().setScrollTopByLine(line);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* @inheritDoc
|
|
* @inheritDoc
|
|
|
*/
|
|
*/
|
|
|
insertText(text) {
|
|
insertText(text) {
|
|
|
- if (this.props.isMobile) {
|
|
|
|
|
- }
|
|
|
|
|
- else {
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ this.getEditorSubstance().insertText(text);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -227,6 +227,7 @@ export default class Editor extends AbstractEditor {
|
|
|
{/* for PC */}
|
|
{/* for PC */}
|
|
|
{ !isMobile &&
|
|
{ !isMobile &&
|
|
|
<CodeMirrorEditor
|
|
<CodeMirrorEditor
|
|
|
|
|
+ ref="cmEditor"
|
|
|
onPasteFiles={this.pasteFilesHandler}
|
|
onPasteFiles={this.pasteFilesHandler}
|
|
|
onDragEnter={this.dragEnterHandler}
|
|
onDragEnter={this.dragEnterHandler}
|
|
|
{...this.props}
|
|
{...this.props}
|
|
@@ -235,7 +236,9 @@ export default class Editor extends AbstractEditor {
|
|
|
|
|
|
|
|
{/* for mobile */}
|
|
{/* for mobile */}
|
|
|
{ isMobile &&
|
|
{ isMobile &&
|
|
|
- <FormControl componentClass="textarea" className="textarea-for-mobile"
|
|
|
|
|
|
|
+ <FormControl
|
|
|
|
|
+ ref="simpleEditor"
|
|
|
|
|
+ componentClass="textarea" className="textarea-for-mobile"
|
|
|
inputRef={ref => { this.mobileeditor = ref }}
|
|
inputRef={ref => { this.mobileeditor = ref }}
|
|
|
defaultValue={this.state.value}
|
|
defaultValue={this.state.value}
|
|
|
onChange={(e) => {
|
|
onChange={(e) => {
|