diff options
Diffstat (limited to 'src/editor.mjs')
-rw-r--r-- | src/editor.mjs | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/editor.mjs b/src/editor.mjs index 67df938..af3f629 100644 --- a/src/editor.mjs +++ b/src/editor.mjs | |||
@@ -180,6 +180,7 @@ window.onhashchange = () => { | |||
180 | // Elements about suggestions {{{ | 180 | // Elements about suggestions {{{ |
181 | const suggestionsEle = document.createElement('div') | 181 | const suggestionsEle = document.createElement('div') |
182 | suggestionsEle.classList.add('container__suggestions'); | 182 | suggestionsEle.classList.add('container__suggestions'); |
183 | document.body.append(suggestionsEle) | ||
183 | 184 | ||
184 | const rendererOptions = {} | 185 | const rendererOptions = {} |
185 | 186 | ||
@@ -448,11 +449,13 @@ const addSuggestions = (anchor, suggestions) => { | |||
448 | suggestionsEle.appendChild(option); | 449 | suggestionsEle.appendChild(option); |
449 | }); | 450 | }); |
450 | 451 | ||
451 | cm.addWidget(anchor, suggestionsEle, true) | 452 | const widgetAnchor = document.createElement('div') |
452 | const rect = suggestionsEle.getBoundingClientRect() | 453 | cm.addWidget(anchor, widgetAnchor, true) |
453 | suggestionsEle.style.maxWidth = `calc(${window.innerWidth}px - ${rect.x}px - 2rem)`; | 454 | const rect = widgetAnchor.getBoundingClientRect() |
455 | suggestionsEle.style.left = `calc(${rect.left}px + 2rem)`; | ||
456 | suggestionsEle.style.top = `calc(${rect.bottom}px + 1rem)`; | ||
457 | suggestionsEle.style.maxWidth = `calc(${window.innerWidth}px - ${rect.x}px - 3rem)`; | ||
454 | suggestionsEle.style.display = 'block' | 458 | suggestionsEle.style.display = 'block' |
455 | suggestionsEle.style.transform = 'translate(2em, 1em)' | ||
456 | } | 459 | } |
457 | // }}} | 460 | // }}} |
458 | // EVENT: Suggests for current selection {{{ | 461 | // EVENT: Suggests for current selection {{{ |