mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
ui: scratchpad: check model existance
This commit is contained in:
1 parent
c6837a16e7
commit
8d3d6c022e
2 files changed
+4
-4
No files matched your search
@@ -56,10 +56,10 @@ export default connect(mapStateToProps, mapDispatchToProps)(class MonacoEditor e
|
|||||||
const {
|
const {
|
||||||
value, language, mainSize, recordSize, pretestSize,
|
value, language, mainSize, recordSize, pretestSize,
|
||||||
} = this.props;
|
} = this.props;
|
||||||
const { editor, model } = this;
|
|
||||||
const { monaco } = await load([language]);
|
const { monaco } = await load([language]);
|
||||||
|
const { editor, model } = this;
|
||||||
const { LF } = monaco.editor.EndOfLinePreference;
|
const { LF } = monaco.editor.EndOfLinePreference;
|
||||||
if (this.props.value != null && this.props.value !== model.getValue(LF, false)) {
|
if (model && editor && this.props.value != null && this.props.value !== model.getValue(LF, false)) {
|
||||||
this.__prevent_trigger_change_event = true;
|
this.__prevent_trigger_change_event = true;
|
||||||
editor.pushUndoStop();
|
editor.pushUndoStop();
|
||||||
model.pushEditOperations(
|
model.pushEditOperations(
|
||||||
@@ -74,7 +74,7 @@ export default connect(mapStateToProps, mapDispatchToProps)(class MonacoEditor e
|
|||||||
editor.pushUndoStop();
|
editor.pushUndoStop();
|
||||||
this.__prevent_trigger_change_event = false;
|
this.__prevent_trigger_change_event = false;
|
||||||
}
|
}
|
||||||
if (prevProps.language !== language) {
|
if (model && editor && prevProps.language !== language) {
|
||||||
const val = model.getValue(LF, false);
|
const val = model.getValue(LF, false);
|
||||||
model.dispose();
|
model.dispose();
|
||||||
const uri = monaco.Uri.parse(`hydro://${UiContext.pdoc.pid || UiContext.pdoc.docId}.${language}`);
|
const uri = monaco.Uri.parse(`hydro://${UiContext.pdoc.pid || UiContext.pdoc.docId}.${language}`);
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@hydrooj/ui-default",
|
"name": "@hydrooj/ui-default",
|
||||||
"version": "4.39.5",
|
"version": "4.39.6",
|
||||||
"author": "undefined <i@undefined.moe>",
|
"author": "undefined <i@undefined.moe>",
|
||||||
"license": "AGPL-3.0",
|
"license": "AGPL-3.0",
|
||||||
"main": "hydro.js",
|
"main": "hydro.js",
|
||||||
|
|||||||
Reference in new issue
Block a user