when editor loses focus, update its block so others can be edited

This commit is contained in:
2021-11-03 02:05:07 -04:00
parent b88cb062be
commit 5e9cbbb9b3

View File

@@ -128,7 +128,7 @@
(var &mut :Dynamic activeEditor)
(var &mut :Array<Dynamic> editors [])
(function monacoEditor [div style content language readOnly :Dynamic->Void onChange]
(function monacoEditor [div style content language readOnly :Dynamic->Void updateBlock]
(let [eIdx
editors.length
:Dynamic e
@@ -148,9 +148,12 @@
->[&opt _] {
(div.setAttribute "style" "${style} height: $(e.getContentHeight)px;")
(e.layout)
}]
}
onChange
->editor (addEditTimeout eIdx ->(updateBlock editor))]
(updateSize)
(e.onDidFocusEditorText (activateEditor eIdx))
(e.onDidBlurEditorText ->(updateBlock e))
(e.onDidChangeCursorPosition
->evt
(when (Range.isEmpty (activeEditor.getSelection))
@@ -290,14 +293,10 @@
(content.appendChild (document.createElement "br"))
(monacoEditor sourceDiv "width: 50%;" source /* TODO get the real extension of the source file: */ "txt" locked
->editor (addEditTimeout idx ->{
(replaceSourceBlock (nth ktxt2Elements idx) (editor.getValue))
}))
->editor (replaceSourceBlock (nth ktxt2Elements idx) (editor.getValue)))
(monacoEditor outputDiv "flex-grow: 1;" output /* TODO get the real extension of the output file: */ "txt" locked
->editor (addEditTimeout idx ->{
(replaceOutputBlock (nth ktxt2Elements idx) (editor.getValue))
}))
->editor (replaceOutputBlock (nth ktxt2Elements idx) (editor.getValue)))
// Link that will delete the whole block:
(set xLink.innerHTML "x")