From d4d0d9e66200e16c12f16a0916d4fd8092debdf5 Mon Sep 17 00:00:00 2001 From: Menci Date: Mon, 15 Apr 2019 22:01:15 +0800 Subject: [PATCH] Workaround click response offset issue --- static/self/monaco-editor.css | 17 ++++++++++++++++- static/self/monaco-editor.js | 7 +++++-- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/static/self/monaco-editor.css b/static/self/monaco-editor.css index 71b46c3..4a078dd 100644 --- a/static/self/monaco-editor.css +++ b/static/self/monaco-editor.css @@ -10,6 +10,13 @@ outline: none; } +.editor > .editor-wrapped { + position: absolute; + width: 100%; + height: 100%; + top: 9px; +} + .editor.editor-with-border:focus-within { border-color: #85b7d9; } @@ -19,7 +26,6 @@ } .editor.editor-with-border .monaco-editor .lines-content.monaco-editor-background { - margin-top: 9px; margin-left: 4px; } @@ -58,10 +64,19 @@ } .editor.editor-with-border .monaco-editor .monaco-scrollable-element .scrollbar.vertical { + top: -9px !important; background: rgba(0,0,0,.1); border-radius: 0; } +.editor.editor-with-border .monaco-editor .monaco-scrollable-element.editor-scrollable { + overflow: visible !important; +} + +.editor.editor-with-border .monaco-editor .overflow-guard { + overflow: visible !important; +} + .editor.editor-with-border .monaco-editor .monaco-scrollable-element .scrollbar.vertical .slider { border-radius: 5px; background: rgba(0,0,0,.25); diff --git a/static/self/monaco-editor.js b/static/self/monaco-editor.js index 3ffc1cd..e39d89f 100644 --- a/static/self/monaco-editor.js +++ b/static/self/monaco-editor.js @@ -609,8 +609,11 @@ require(['vs/editor/editor.main'], function () { }); }; - window.createMarkdownEditor = function (editorElement, content, input) { - editorElement.innerHTML = ''; + window.createMarkdownEditor = function (wrapperElement, content, input) { + wrapperElement.innerHTML = ''; + var editorElement = document.createElement('div'); + editorElement.classList.add('editor-wrapped'); + wrapperElement.appendChild(editorElement); var editor = monaco.editor.create(editorElement, { value: content, language: 'markdown',