diff --git a/dist/PublicLab.Editor.js b/dist/PublicLab.Editor.js index 7b4502e5..4f878fe0 100644 --- a/dist/PublicLab.Editor.js +++ b/dist/PublicLab.Editor.js @@ -22758,14 +22758,22 @@ module.exports = function CustomInsert(_module, wysiwyg) { } }); const builder = require("./PublicLab.CustomInsert.Template.js"); - $('.wk-commands').append(''); + $('.wk-commands').append(''); + + $(document).ready(function() { + $('[data-toggle="insert"]').tooltip(); + }); + var Option1 = "Notes"; var Option2 = "List"; $('.woofmark-command-insert').attr('data-content', builder); $('.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); @@ -22799,6 +22807,17 @@ module.exports = function CustomInsert(_module, wysiwyg) { } }); }); + + $(':not(".woofmark-command-insert")').click((e) => { + // check to see that the clicked element isn't fa-insert icon, else when you click on the fa-insert icon, the popover will close + 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(); + } + } + }); }; },{"./PublicLab.CustomInsert.Template.js":185}],187:[function(require,module,exports){ @@ -23345,9 +23364,9 @@ module.exports = function initTables(_module, wysiwyg) { }); var builder = '
'; - builder += ' 4 '; - builder += ' x '; - builder += ' 3 '; + builder += ' 4 '; + builder += ' x '; + builder += ' 3 '; builder += ' Add'; builder += '
'; @@ -23375,7 +23394,9 @@ module.exports = function initTables(_module, wysiwyg) { $('.woofmark-command-table').popover({html: true}); + let popoverIsOpen = false; $('.wk-commands .woofmark-command-table').click(function() { + popoverIsOpen = !popoverIsOpen; $('.ple-table-size').click(function() { wysiwyg.runCommand(function(chunks, mode) { var table = createTable( @@ -23393,6 +23414,19 @@ module.exports = function initTables(_module, wysiwyg) { }); }); }); + + + // close table popover when user click outside the page + $(':not(".woofmark-command-table")').click((e) => { + // check to see that the clicked element isn't fa-table icon, else when you click on the fa-table icon, the popover will close + if (popoverIsOpen && $('.woofmark-command-table').children()[0] != e.target) { + const popoverContainer = document.querySelector('.popover'); + const isChildElement = popoverContainer.contains(e.target); + if (popoverIsOpen && !e.target.classList.contains("woofmark-command-table") && !isChildElement) { + $('.woofmark-command-table').click(); + } + } + }); }; },{}],194:[function(require,module,exports){ diff --git a/src/modules/PublicLab.CustomInsert.js b/src/modules/PublicLab.CustomInsert.js index aba27abc..518d3ef6 100644 --- a/src/modules/PublicLab.CustomInsert.js +++ b/src/modules/PublicLab.CustomInsert.js @@ -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); @@ -113,4 +116,15 @@ module.exports = function CustomInsert(_module, wysiwyg) { } }); }); + + $(':not(".woofmark-command-insert")').click((e) => { + // check to see that the clicked element isn't fa-insert icon, else when you click on the fa-insert icon, the popover will close + 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(); + } + } + }); }; diff --git a/src/modules/PublicLab.RichTextModule.Table.js b/src/modules/PublicLab.RichTextModule.Table.js index 7a8f2165..03cf58a6 100644 --- a/src/modules/PublicLab.RichTextModule.Table.js +++ b/src/modules/PublicLab.RichTextModule.Table.js @@ -48,9 +48,9 @@ module.exports = function initTables(_module, wysiwyg) { }); var builder = '
'; - builder += ' 4 '; - builder += ' x '; - builder += ' 3 '; + builder += ' 4 '; + builder += ' x '; + builder += ' 3 '; builder += ' Add'; builder += '
'; @@ -78,7 +78,9 @@ module.exports = function initTables(_module, wysiwyg) { $('.woofmark-command-table').popover({html: true}); + let popoverIsOpen = false; $('.wk-commands .woofmark-command-table').click(function() { + popoverIsOpen = !popoverIsOpen; $('.ple-table-size').click(function() { wysiwyg.runCommand(function(chunks, mode) { var table = createTable( @@ -96,4 +98,17 @@ module.exports = function initTables(_module, wysiwyg) { }); }); }); + + + // close table popover when user click outside the page + $(':not(".woofmark-command-table")').click((e) => { + // check to see that the clicked element isn't fa-table icon, else when you click on the fa-table icon, the popover will close + if (popoverIsOpen && $('.woofmark-command-table').children()[0] != e.target) { + const popoverContainer = document.querySelector('.popover'); + const isChildElement = popoverContainer.contains(e.target); + if (popoverIsOpen && !e.target.classList.contains("woofmark-command-table") && !isChildElement) { + $('.woofmark-command-table').click(); + } + } + }); };