mirror of
https://github.com/chinchang/web-maker.git
synced 2025-07-09 16:06:21 +02:00
WIP
This commit is contained in:
@ -638,6 +638,7 @@ export default class ContentWrapFiles extends Component {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<UserCodeMirror
|
<UserCodeMirror
|
||||||
|
mode={'monaco'}
|
||||||
value={
|
value={
|
||||||
this.state.selectedFile ? this.state.selectedFile.content : ''
|
this.state.selectedFile ? this.state.selectedFile.content : ''
|
||||||
}
|
}
|
||||||
|
@ -66,7 +66,22 @@ export default class UserCodeMirror extends Component {
|
|||||||
|
|
||||||
initEditor() {
|
initEditor() {
|
||||||
const { options, prefs } = this.props;
|
const { options, prefs } = this.props;
|
||||||
this.cm = CodeMirror.fromTextArea(this.textarea, {
|
if (this.props.mode === 'monaco') {
|
||||||
|
this.instance = monaco.editor.create(el, {
|
||||||
|
language: options.language,
|
||||||
|
roundedSelection: false,
|
||||||
|
scrollBeyondLastLine: false,
|
||||||
|
theme: 'vs-dark',
|
||||||
|
fontSize: 16,
|
||||||
|
minimap: {
|
||||||
|
enabled: false
|
||||||
|
},
|
||||||
|
wordWrap: 'on',
|
||||||
|
fontLigatures: true
|
||||||
|
});
|
||||||
|
this.instance.onDidChangeModelContent(onChange);
|
||||||
|
} else {
|
||||||
|
this.instance = CodeMirror.fromTextArea(this.textarea, {
|
||||||
mode: options.mode,
|
mode: options.mode,
|
||||||
lineNumbers: true,
|
lineNumbers: true,
|
||||||
lineWrapping: !!prefs.lineWrap,
|
lineWrapping: !!prefs.lineWrap,
|
||||||
@ -114,11 +129,12 @@ export default class UserCodeMirror extends Component {
|
|||||||
},
|
},
|
||||||
Tab: function(editor) {
|
Tab: function(editor) {
|
||||||
if (options.emmet) {
|
if (options.emmet) {
|
||||||
const didEmmetWork = editor.execCommand('emmetExpandAbbreviation');
|
const didEmmetWork = editor.execCommand(
|
||||||
|
'emmetExpandAbbreviation'
|
||||||
|
);
|
||||||
if (didEmmetWork === true) {
|
if (didEmmetWork === true) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
const input = $('[data-setting=indentWith]:checked');
|
const input = $('[data-setting=indentWith]:checked');
|
||||||
if (
|
if (
|
||||||
!editor.somethingSelected() &&
|
!editor.somethingSelected() &&
|
||||||
@ -131,21 +147,26 @@ export default class UserCodeMirror extends Component {
|
|||||||
} else {
|
} else {
|
||||||
CodeMirror.commands.defaultTab(editor);
|
CodeMirror.commands.defaultTab(editor);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
Enter: 'emmetInsertLineBreak'
|
Enter: 'emmetInsertLineBreak'
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.cm.on('focus', editor => {
|
this.instance.on('focus', editor => {
|
||||||
if (typeof this.props.onFocus === 'function') this.props.onFocus(editor);
|
if (typeof this.props.onFocus === 'function')
|
||||||
|
this.props.onFocus(editor);
|
||||||
});
|
});
|
||||||
this.cm.on('change', this.props.onChange);
|
this.instance.on('change', this.props.onChange);
|
||||||
this.cm.addKeyMap({
|
this.instance.addKeyMap({
|
||||||
'Ctrl-Space': 'autocomplete'
|
'Ctrl-Space': 'autocomplete'
|
||||||
});
|
});
|
||||||
this.cm.on('inputRead', (editor, input) => {
|
this.instance.on('inputRead', (editor, input) => {
|
||||||
// Process further If this has autocompletition on and also the global
|
// Process further If this has autocompletition on and also the global
|
||||||
// autocomplete setting is on.
|
// autocomplete setting is on.
|
||||||
if (!this.props.options.noAutocomplete && this.props.prefs.autoComplete) {
|
if (
|
||||||
|
!this.props.options.noAutocomplete &&
|
||||||
|
this.props.prefs.autoComplete
|
||||||
|
) {
|
||||||
if (
|
if (
|
||||||
input.origin !== '+input' ||
|
input.origin !== '+input' ||
|
||||||
input.text[0] === ';' ||
|
input.text[0] === ';' ||
|
||||||
@ -154,12 +175,14 @@ export default class UserCodeMirror extends Component {
|
|||||||
) {
|
) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
CodeMirror.commands.autocomplete(this.cm, null, {
|
CodeMirror.commands.autocomplete(editor, null, {
|
||||||
completeSingle: false
|
completeSingle: false
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.props.onCreation(this.cm);
|
}
|
||||||
|
|
||||||
|
this.props.onCreation(this.instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
@ -1931,6 +1931,10 @@ while the theme CSS file is loading */
|
|||||||
.tabs__tabpanel-wrap {
|
.tabs__tabpanel-wrap {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
}
|
}
|
||||||
|
.monaco-editor {
|
||||||
|
width: 100%;
|
||||||
|
height: 300px !important; /* 25px for header */
|
||||||
|
}
|
||||||
|
|
||||||
@media screen and (max-width: 600px) {
|
@media screen and (max-width: 600px) {
|
||||||
body {
|
body {
|
||||||
|
Reference in New Issue
Block a user