diff --git a/.discourse-compatibility b/.discourse-compatibility new file mode 100644 index 0000000..69efb4f --- /dev/null +++ b/.discourse-compatibility @@ -0,0 +1 @@ +3.1.0.beta2: 850e31c83d310a1b52e6105fe201eb96f9e33deb \ No newline at end of file diff --git a/javascripts/discourse/api-initializers/table-editor.js b/javascripts/discourse/api-initializers/table-editor.js index 1e8b75d..99f173c 100644 --- a/javascripts/discourse/api-initializers/table-editor.js +++ b/javascripts/discourse/api-initializers/table-editor.js @@ -59,13 +59,21 @@ export default apiInitializer("0.11.1", (api) => { if (table.parentNode.contains(expandBtn)) { expandBtn.parentNode.insertBefore(popupBtn, expandBtn); } else { - table.parentNode.insertBefore(popupBtn, table); + const buttonWrapper = document.createElement("div"); + buttonWrapper.classList.add("fullscreen-table-wrapper--buttons"); + buttonWrapper.append(popupBtn); + table.parentNode.insertBefore(buttonWrapper, table); } popupBtn.addEventListener("click", generateModal.bind(attrs), false); }); } + function cleanupPopupBtns() { + const popupBtns = document.querySelectorAll("button.open-popup-link"); + popupBtns.forEach((btn) => btn.removeEventListener("click", generateModal)); + } + api.decorateCookedElement( (post, helper) => { const canEdit = helper.widget.attrs.canEdit; @@ -84,4 +92,6 @@ export default apiInitializer("0.11.1", (api) => { id: "edit-table", } ); + + api.cleanupStream(cleanupPopupBtns); }); diff --git a/scss/post/table-edit-decorator.scss b/scss/post/table-edit-decorator.scss index de9de5a..b3b56ca 100644 --- a/scss/post/table-edit-decorator.scss +++ b/scss/post/table-edit-decorator.scss @@ -31,8 +31,10 @@ table { opacity: 0.5; } + .btn-edit-table { display: block; + z-index: 2; } } }