Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions dist/PublicLab.Editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -22770,7 +22770,10 @@ module.exports = function CustomInsert(_module, wysiwyg) {
$('.woofmark-command-insert').attr('data-container', 'body');
$('.woofmark-command-insert').attr('data-placement', 'top');
$('.woofmark-command-insert').popover({html: true, sanitize: false});

let popoverIsOpen = false;
$('.wk-commands .woofmark-command-insert').click(function() {
popoverIsOpen = !popoverIsOpen;
var sel = window.getSelection();
if (sel.anchorNode !== null) {
var range = sel.getRangeAt(0);
Expand Down Expand Up @@ -22803,6 +22806,16 @@ module.exports = function CustomInsert(_module, wysiwyg) {
});
}
});
// for the popover to disappear when clicked anywhere on the screen
$(':not(".woofmark-command-insert")').click((e) => {
if (popoverIsOpen && $('.woofmark-command-insert').children()[0] != e.target) {
const popoverContainer = document.querySelector('.popover');
const isChildElement = popoverContainer.contains(e.target);
if (popoverIsOpen && !e.target.classList.contains("woofmark-command-insert") && !isChildElement) {
$('.woofmark-command-insert').click();
}
}
});
});
};

Expand Down
13 changes: 13 additions & 0 deletions src/modules/PublicLab.CustomInsert.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,10 @@ module.exports = function CustomInsert(_module, wysiwyg) {
$('.woofmark-command-insert').attr('data-container', 'body');
$('.woofmark-command-insert').attr('data-placement', 'top');
$('.woofmark-command-insert').popover({html: true, sanitize: false});

let popoverIsOpen = false;
$('.wk-commands .woofmark-command-insert').click(function() {
popoverIsOpen = !popoverIsOpen;
var sel = window.getSelection();
if (sel.anchorNode !== null) {
var range = sel.getRangeAt(0);
Expand Down Expand Up @@ -112,5 +115,15 @@ module.exports = function CustomInsert(_module, wysiwyg) {
});
}
});
// for the popover to disappear when clicked anywhere on the screen
$(':not(".woofmark-command-insert")').click((e) => {
if (popoverIsOpen && $('.woofmark-command-insert').children()[0] != e.target) {
const popoverContainer = document.querySelector('.popover');
const isChildElement = popoverContainer.contains(e.target);
if (popoverIsOpen && !e.target.classList.contains("woofmark-command-insert") && !isChildElement) {
$('.woofmark-command-insert').click();
}
}
});
});
};