aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/editor.mjs11
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 {{{
181const suggestionsEle = document.createElement('div') 181const suggestionsEle = document.createElement('div')
182suggestionsEle.classList.add('container__suggestions'); 182suggestionsEle.classList.add('container__suggestions');
183document.body.append(suggestionsEle)
183 184
184const rendererOptions = {} 185const 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 {{{