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