@themarioga/grid-editor 9.0.0-beta.5 → 9.0.0-beta.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (96) hide show
  1. package/CHANGELOG.md +57 -0
  2. package/README.md +43 -24
  3. package/UPGRADING.md +24 -5
  4. package/dist/grideditor.bundle.min.js +3 -3
  5. package/dist/grideditor.css +5 -4
  6. package/dist/grideditor.d.ts +13 -20
  7. package/dist/grideditor.esm.js +174 -104
  8. package/dist/grideditor.jquery.js +1 -3
  9. package/dist/grideditor.jquery.min.js +1 -1
  10. package/dist/grideditor.jquery.min.js.map +2 -2
  11. package/dist/grideditor.js +174 -104
  12. package/dist/grideditor.min.css +1 -1
  13. package/dist/grideditor.min.css.map +1 -1
  14. package/dist/grideditor.min.js +2 -2
  15. package/dist/grideditor.min.js.map +3 -3
  16. package/dist/locales/grideditor.es.esm.js +1 -0
  17. package/dist/locales/grideditor.es.js +1 -0
  18. package/dist/locales/grideditor.es.min.js +1 -1
  19. package/dist/locales/grideditor.es.min.js.map +2 -2
  20. package/dist/plugins/grideditor.accordion.esm.js +16 -0
  21. package/dist/plugins/grideditor.accordion.js +16 -0
  22. package/dist/plugins/grideditor.accordion.min.js +1 -1
  23. package/dist/plugins/grideditor.accordion.min.js.map +3 -3
  24. package/dist/plugins/grideditor.card.esm.js +4 -0
  25. package/dist/plugins/grideditor.card.js +4 -0
  26. package/dist/plugins/grideditor.card.min.js +1 -1
  27. package/dist/plugins/grideditor.card.min.js.map +3 -3
  28. package/dist/plugins/grideditor.carousel.esm.js +7 -0
  29. package/dist/plugins/grideditor.carousel.js +7 -0
  30. package/dist/plugins/grideditor.carousel.min.js +1 -1
  31. package/dist/plugins/grideditor.carousel.min.js.map +3 -3
  32. package/dist/plugins/grideditor.ckeditor.esm.js +9 -0
  33. package/dist/plugins/grideditor.ckeditor.js +9 -0
  34. package/dist/plugins/grideditor.ckeditor.min.js +1 -1
  35. package/dist/plugins/grideditor.ckeditor.min.js.map +3 -3
  36. package/dist/plugins/grideditor.clipboard.esm.js +47 -25
  37. package/dist/plugins/grideditor.clipboard.js +47 -25
  38. package/dist/plugins/grideditor.clipboard.min.js +1 -1
  39. package/dist/plugins/grideditor.clipboard.min.js.map +3 -3
  40. package/dist/plugins/grideditor.codemirror-inline.min.js.map +1 -1
  41. package/dist/plugins/grideditor.codemirror.min.js.map +1 -1
  42. package/dist/plugins/grideditor.elements.esm.js +3 -0
  43. package/dist/plugins/grideditor.elements.js +3 -0
  44. package/dist/plugins/grideditor.elements.min.js +1 -1
  45. package/dist/plugins/grideditor.elements.min.js.map +3 -3
  46. package/dist/plugins/grideditor.gutters.min.js.map +1 -1
  47. package/dist/plugins/grideditor.history.esm.js +2 -7
  48. package/dist/plugins/grideditor.history.js +2 -7
  49. package/dist/plugins/grideditor.history.min.js +1 -1
  50. package/dist/plugins/grideditor.history.min.js.map +3 -3
  51. package/dist/plugins/grideditor.inline-style.min.js.map +1 -1
  52. package/dist/plugins/grideditor.offcanvas.esm.js +4 -0
  53. package/dist/plugins/grideditor.offcanvas.js +4 -0
  54. package/dist/plugins/grideditor.offcanvas.min.js +1 -1
  55. package/dist/plugins/grideditor.offcanvas.min.js.map +3 -3
  56. package/dist/plugins/grideditor.order.min.js +1 -1
  57. package/dist/plugins/grideditor.order.min.js.map +1 -1
  58. package/dist/plugins/grideditor.popup.esm.js +4 -0
  59. package/dist/plugins/grideditor.popup.js +4 -0
  60. package/dist/plugins/grideditor.popup.min.js +1 -1
  61. package/dist/plugins/grideditor.popup.min.js.map +3 -3
  62. package/dist/plugins/grideditor.sections.esm.js +9 -0
  63. package/dist/plugins/grideditor.sections.js +9 -0
  64. package/dist/plugins/grideditor.sections.min.js +1 -1
  65. package/dist/plugins/grideditor.sections.min.js.map +3 -3
  66. package/dist/plugins/grideditor.summernote.esm.js +9 -0
  67. package/dist/plugins/grideditor.summernote.js +9 -0
  68. package/dist/plugins/grideditor.summernote.min.js +1 -1
  69. package/dist/plugins/grideditor.summernote.min.js.map +3 -3
  70. package/dist/plugins/grideditor.tabs.esm.js +7 -0
  71. package/dist/plugins/grideditor.tabs.js +7 -0
  72. package/dist/plugins/grideditor.tabs.min.js +1 -1
  73. package/dist/plugins/grideditor.tabs.min.js.map +3 -3
  74. package/dist/plugins/grideditor.tinymce.esm.js +9 -0
  75. package/dist/plugins/grideditor.tinymce.js +9 -0
  76. package/dist/plugins/grideditor.tinymce.min.js +1 -1
  77. package/dist/plugins/grideditor.tinymce.min.js.map +3 -3
  78. package/docs/events.md +14 -12
  79. package/docs/locale-keys.md +1 -0
  80. package/docs/plugins.md +11 -8
  81. package/example/clipboard.html +20 -14
  82. package/package.json +1 -1
  83. package/src/js/dom.js +6 -0
  84. package/src/js/grideditor.jquery.js +0 -2
  85. package/src/js/grideditor.js +233 -114
  86. package/src/js/locales/grideditor.es.js +1 -0
  87. package/src/js/plugins/grideditor.accordion.js +9 -0
  88. package/src/js/plugins/grideditor.card.js +5 -0
  89. package/src/js/plugins/grideditor.carousel.js +5 -0
  90. package/src/js/plugins/grideditor.clipboard.js +70 -33
  91. package/src/js/plugins/grideditor.history.js +6 -9
  92. package/src/js/plugins/grideditor.offcanvas.js +5 -0
  93. package/src/js/plugins/grideditor.popup.js +5 -0
  94. package/src/js/plugins/grideditor.tabs.js +5 -0
  95. package/src/less/grideditor.less +5 -4
  96. package/types/grideditor.d.ts +13 -20
@@ -1 +1 @@
1
- (()=>{var u=window.GridEditor;if(!u||typeof u.get!="function")throw new Error("grid-editor: load grideditor.js (or grideditor.bundle.min.js) before its plugins, its locales and grideditor.jquery.js");var i=window.jQuery,T=function(a,o){return u.t({locale:"en"},a,o)},m={};function b(a,o){m[a]||(m[a]=!0,window.console&&window.console.warn&&window.console.warn("grid-editor: "+o))}!i||!i.fn?b("no-jquery",T("warning.adapter_no_jquery")):x();function x(){var a={getHtml:{value:!0},getPlainHtml:{value:!0},init:{},deinit:{},reset:{},destroy:{},changeView:{},getView:{value:!0},createRow:{value:!0},createColumn:{value:!0},createElement:{value:!0},createText:{value:!0},createSection:{value:!0},createContainer:{value:!0},addTab:{value:!0},addAccordionItem:{value:!0},setLocale:{},getUtility:{value:!0},setUtility:{value:!0},getActiveTarget:{value:!0},setActiveTarget:{},getSelected:{value:!0},setSelected:{}},o=["row_tools","col_tools","element_tools","container_tools","tab_tools","accordion_tools","text_tools"];function g(r){return!!r&&r.nodeType===1}function l(r){return r instanceof i?r[0]||null:r}function h(r){if(r instanceof i)return l(r);if(r&&typeof r=="object"&&!Array.isArray(r)&&!g(r)){var t={};return Object.keys(r).forEach(function(e){t[e]=l(r[e])}),t}return r}function v(r){return g(r)?i(r):r}var s=new WeakMap;function w(r){if(!r||typeof r!="object")return r;if(s.has(r))return s.get(r);var t=Object.assign({},r);return["node","parent","canvas"].forEach(function(e){e in r&&(t[e]=i(r[e]||[]))}),r.container&&(t.container=i(r.container)),Array.isArray(r.nodes)&&(t.node=i(r.nodes)),["from","to"].forEach(function(e){var n=r[e];n&&typeof n=="object"&&"parent"in n&&(t[e]=Object.assign({},n,{parent:i(n.parent||[])}))}),s.set(r,t),t}var p=i.event.dispatch;i.event.dispatch=function(r){return arguments.length===1&&r instanceof window.CustomEvent&&typeof r.type=="string"&&r.type.indexOf("grideditor:")===0?p.call(this,r,w(r.detail)):p.apply(this,arguments)};function y(r){return function(t){return r.call(this,i.event.fix(t))}}function _(r){if(!r||!r.on)return r;var t;return typeof r.on=="function"?t=y(r.on):(t={},Object.keys(r.on).forEach(function(e){t[e]=y(r.on[e])})),Object.assign({},r,{on:t})}function j(r){return function(t,e){var n=typeof r=="string"?window[r]:r;return n(i(t),e)}}function E(r){if(r=Object.assign({},r||{}),r.callbacks){var t={};Object.keys(r.callbacks).forEach(function(n){var c=r.callbacks[n];t[n]=typeof c=="function"?function(f){return c(w(f))}:c}),r.callbacks=t}if(r.custom_filter&&r.custom_filter.length){var e=typeof r.custom_filter=="string"||typeof r.custom_filter=="function"?[r.custom_filter]:Array.prototype.slice.call(r.custom_filter);r.custom_filter=e.map(j)}return o.forEach(function(n){Array.isArray(r[n])&&(r[n]=r[n].map(_))}),r.source_textarea=l(r.source_textarea),r}function A(r){var t={canvas:i(r.canvas)};return Object.keys(a).forEach(function(e){t[e]=function(){var n=r[e].apply(r,Array.prototype.map.call(arguments,h));return n===r?void 0:v(n)}}),Object.defineProperty(t,"settings",{enumerable:!0,get:function(){return r.settings}}),t}u._created.push(function(r){i.data(r.canvas,"grideditor",A(r));var t=r.destroy;r.destroy=function(){var e=t.apply(this,arguments);return i.removeData(r.canvas,"grideditor"),e}});function O(r,t,e){var n=a[t];if(!n)return b("method:"+t,'unknown method "'+t+'"'),r;if(e=e.map(h),n.value){var c=r.first();if(!c.length)return null;var f=u.get(c[0]);return f?v(f[t].apply(f,e)):t==="getHtml"?c.html():t==="getPlainHtml"?u._plainHtml(c.html()):null}return r.each(function(){var d=u.get(this);d&&d[t].apply(d,e)}),r}i.fn.gridEditor=function(r){if(typeof r=="string")return O(this,r,Array.prototype.slice.call(arguments,1));var t=E(r);return this.each(function(){u.create(this,t)}),this},i.fn.gridEditor.locales=u.locales,i.fn.gridEditor.t=u.t}})();
1
+ (()=>{var u=window.GridEditor;if(!u||typeof u.get!="function")throw new Error("grid-editor: load grideditor.js (or grideditor.bundle.min.js) before its plugins, its locales and grideditor.jquery.js");var i=window.jQuery,T=function(a,o){return u.t({locale:"en"},a,o)},m={};function b(a,o){m[a]||(m[a]=!0,window.console&&window.console.warn&&window.console.warn("grid-editor: "+o))}!i||!i.fn?b("no-jquery",T("warning.adapter_no_jquery")):x();function x(){var a={getHtml:{value:!0},getPlainHtml:{value:!0},init:{},deinit:{},reset:{},destroy:{},changeView:{},getView:{value:!0},createRow:{value:!0},createColumn:{value:!0},createElement:{value:!0},createText:{value:!0},createSection:{value:!0},createContainer:{value:!0},addTab:{value:!0},addAccordionItem:{value:!0},setLocale:{},getUtility:{value:!0},setUtility:{value:!0},getActiveTarget:{value:!0},setActiveTarget:{}},o=["row_tools","col_tools","element_tools","container_tools","tab_tools","accordion_tools","text_tools"];function g(r){return!!r&&r.nodeType===1}function l(r){return r instanceof i?r[0]||null:r}function h(r){if(r instanceof i)return l(r);if(r&&typeof r=="object"&&!Array.isArray(r)&&!g(r)){var t={};return Object.keys(r).forEach(function(e){t[e]=l(r[e])}),t}return r}function w(r){return g(r)?i(r):r}var s=new WeakMap;function p(r){if(!r||typeof r!="object")return r;if(s.has(r))return s.get(r);var t=Object.assign({},r);return["node","parent","canvas"].forEach(function(e){e in r&&(t[e]=i(r[e]||[]))}),r.container&&(t.container=i(r.container)),Array.isArray(r.nodes)&&(t.node=i(r.nodes)),["from","to"].forEach(function(e){var n=r[e];n&&typeof n=="object"&&"parent"in n&&(t[e]=Object.assign({},n,{parent:i(n.parent||[])}))}),s.set(r,t),t}var v=i.event.dispatch;i.event.dispatch=function(r){return arguments.length===1&&r instanceof window.CustomEvent&&typeof r.type=="string"&&r.type.indexOf("grideditor:")===0?v.call(this,r,p(r.detail)):v.apply(this,arguments)};function y(r){return function(t){return r.call(this,i.event.fix(t))}}function _(r){if(!r||!r.on)return r;var t;return typeof r.on=="function"?t=y(r.on):(t={},Object.keys(r.on).forEach(function(e){t[e]=y(r.on[e])})),Object.assign({},r,{on:t})}function j(r){return function(t,e){var n=typeof r=="string"?window[r]:r;return n(i(t),e)}}function E(r){if(r=Object.assign({},r||{}),r.callbacks){var t={};Object.keys(r.callbacks).forEach(function(n){var c=r.callbacks[n];t[n]=typeof c=="function"?function(f){return c(p(f))}:c}),r.callbacks=t}if(r.custom_filter&&r.custom_filter.length){var e=typeof r.custom_filter=="string"||typeof r.custom_filter=="function"?[r.custom_filter]:Array.prototype.slice.call(r.custom_filter);r.custom_filter=e.map(j)}return o.forEach(function(n){Array.isArray(r[n])&&(r[n]=r[n].map(_))}),r.source_textarea=l(r.source_textarea),r}function A(r){var t={canvas:i(r.canvas)};return Object.keys(a).forEach(function(e){t[e]=function(){var n=r[e].apply(r,Array.prototype.map.call(arguments,h));return n===r?void 0:w(n)}}),Object.defineProperty(t,"settings",{enumerable:!0,get:function(){return r.settings}}),t}u._created.push(function(r){i.data(r.canvas,"grideditor",A(r));var t=r.destroy;r.destroy=function(){var e=t.apply(this,arguments);return i.removeData(r.canvas,"grideditor"),e}});function O(r,t,e){var n=a[t];if(!n)return b("method:"+t,'unknown method "'+t+'"'),r;if(e=e.map(h),n.value){var c=r.first();if(!c.length)return null;var f=u.get(c[0]);return f?w(f[t].apply(f,e)):t==="getHtml"?c.html():t==="getPlainHtml"?u._plainHtml(c.html()):null}return r.each(function(){var d=u.get(this);d&&d[t].apply(d,e)}),r}i.fn.gridEditor=function(r){if(typeof r=="string")return O(this,r,Array.prototype.slice.call(arguments,1));var t=E(r);return this.each(function(){u.create(this,t)}),this},i.fn.gridEditor.locales=u.locales,i.fn.gridEditor.t=u.t}})();
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/js/register.js", "../src/js/grideditor.jquery.js"],
4
- "sourcesContent": ["/**\n * What a plugin's or a locale's classic script imports in place of the\n * editor: the GridEditor the page already loaded.\n *\n * The build points `import { GridEditor } from '../grideditor.js'` here for\n * the classic scripts, so each registers on the editor the page has rather\n * than bringing its own. Loaded before the editor there is nothing to\n * register on, and saying so is better than a TypeError three calls later.\n */\nvar GridEditor = window.GridEditor;\n\nif (!GridEditor || typeof GridEditor.get !== 'function') {\n throw new Error('grid-editor: load grideditor.js (or grideditor.bundle.min.js) before its plugins, ' +\n 'its locales and grideditor.jquery.js');\n}\n\nexport { GridEditor };\nexport default GridEditor;\n", "/**\n * The jQuery API of grid-editor 6, on top of the plain DOM editor.\n *\n * A page written for 6.x - one that calls $(el).gridEditor(...), listens\n * with $(el).on('grideditor:...') and reads jQuery objects out of the\n * payloads - loads jQuery 4 and this file after grideditor.js, and runs\n * unchanged:\n *\n * <script src=\"jquery.min.js\"></script>\n * <script src=\"dist/grideditor.min.js\"></script>\n * <script src=\"dist/grideditor.jquery.min.js\"></script>\n * <script src=\"dist/plugins/grideditor.tabs.min.js\"></script>\n *\n * What it keeps is the host's side of 6.x. Plugins are not: they register\n * on GridEditor, and the plugin contract hands out elements.\n *\n * Every value 6.x gave host code as a jQuery object is one again: the event\n * payloads and the callbacks' arguments, what the create* methods return,\n * the handle $(el).data('grideditor') gives, the canvas custom_filter gets,\n * and the event a host tool's handler gets. What the host hands in may be a\n * jQuery object wherever 6.x took one.\n */\nimport { GridEditor } from './grideditor.js';\n\nvar $ = window.jQuery;\n\nvar english = function(key, params) { return GridEditor.t({ locale: 'en' }, key, params); };\n\nvar warned = {};\n\nfunction warnOnce(key, message) {\n if (warned[key]) { return; }\n warned[key] = true;\n if (window.console && window.console.warn) { window.console.warn('grid-editor: ' + message); }\n}\n\nif (!$ || !$.fn) {\n warnOnce('no-jquery', english('warning.adapter_no_jquery'));\n} else {\n install();\n}\n\nfunction install() {\n\n /**\n * Every method 6.x dispatched, and which hand back something other than\n * the jQuery set: those run against the first element only, and do not\n * chain.\n */\n var METHODS = {\n getHtml: { value: true },\n getPlainHtml: { value: true },\n init: {},\n deinit: {},\n reset: {},\n destroy: {},\n changeView: {},\n getView: { value: true },\n createRow: { value: true },\n createColumn: { value: true },\n createElement: { value: true },\n createText: { value: true },\n createSection: { value: true },\n createContainer: { value: true },\n addTab: { value: true },\n addAccordionItem: { value: true },\n setLocale: {},\n getUtility: { value: true },\n setUtility: { value: true },\n getActiveTarget: { value: true },\n setActiveTarget: {},\n getSelected: { value: true },\n setSelected: {},\n };\n\n /** The *_tools settings, whose handlers 6.x bound with jQuery. */\n var TOOL_SETTINGS = ['row_tools', 'col_tools', 'element_tools', 'container_tools',\n 'tab_tools', 'accordion_tools', 'text_tools'];\n\n function isElement(value) {\n return !!value && value.nodeType === 1;\n }\n\n /** What the host handed in, as the editor takes it: a jQuery object is its first element. */\n function unwrap(value) {\n if (value instanceof $) { return value[0] || null; }\n return value;\n }\n\n /** An argument, and the options object an argument may be, unwrapped one level down. */\n function unwrapArgument(value) {\n if (value instanceof $) { return unwrap(value); }\n\n if (value && typeof value === 'object' && !Array.isArray(value) && !isElement(value)) {\n var copy = {};\n Object.keys(value).forEach(function(key) { copy[key] = unwrap(value[key]); });\n return copy;\n }\n\n return value;\n }\n\n /** What the editor handed back, as 6.x did: an element is a jQuery object. */\n function wrapResult(value) {\n return isElement(value) ? $(value) : value;\n }\n\n /**\n * A payload as 6.x built it: its nodes jQuery objects, and an empty set\n * where there is no node - a detached node's parent. The same payload\n * wraps to the same object, so every listener of one notification sees\n * one payload, as they did.\n */\n var wrappedPayloads = new WeakMap();\n\n function wrapPayload(payload) {\n if (!payload || typeof payload !== 'object') { return payload; }\n if (wrappedPayloads.has(payload)) { return wrappedPayloads.get(payload); }\n\n var copy = Object.assign({}, payload);\n\n ['node', 'parent', 'canvas'].forEach(function(key) {\n if (key in payload) { copy[key] = $(payload[key] || []); }\n });\n if (payload.container) { copy.container = $(payload.container); }\n // edit-html writes any number of nodes, which 6.x gave as one set\n if (Array.isArray(payload.nodes)) { copy.node = $(payload.nodes); }\n ['from', 'to'].forEach(function(key) {\n var position = payload[key];\n if (position && typeof position === 'object' && 'parent' in position) {\n copy[key] = Object.assign({}, position, { parent: $(position.parent || []) });\n }\n });\n\n wrappedPayloads.set(payload, copy);\n return copy;\n }\n\n /**\n * The events, as jQuery handlers had them: (event, payload).\n *\n * The editor dispatches DOM events, which jQuery hands its handlers with\n * no second argument. Its dispatcher is where every one of them passes,\n * delegated ones too, so that is where the payload goes back in: once,\n * for each handler, and preventDefault() on the jQuery event is\n * preventDefault() on the editor's.\n */\n var dispatch = $.event.dispatch;\n $.event.dispatch = function(nativeEvent) {\n if (arguments.length === 1 && nativeEvent instanceof window.CustomEvent &&\n typeof nativeEvent.type === 'string' && nativeEvent.type.indexOf('grideditor:') === 0) {\n return dispatch.call(this, nativeEvent, wrapPayload(nativeEvent.detail));\n }\n\n return dispatch.apply(this, arguments);\n };\n\n /** A handler of a host's tool, given a jQuery event as 6.x gave it. */\n function jqueryHandler(handler) {\n return function(event) {\n return handler.call(this, $.event.fix(event));\n };\n }\n\n function adaptTool(tool) {\n if (!tool || !tool.on) { return tool; }\n\n var on;\n if (typeof tool.on === 'function') {\n on = jqueryHandler(tool.on);\n } else {\n on = {};\n Object.keys(tool.on).forEach(function(name) { on[name] = jqueryHandler(tool.on[name]); });\n }\n\n return Object.assign({}, tool, { on: on });\n }\n\n /** A custom_filter, as a function of a jQuery canvas; a name is looked up when it runs. */\n function adaptFilter(filter) {\n return function(canvas, isInit) {\n var func = typeof filter === 'string' ? window[filter] : filter;\n return func($(canvas), isInit);\n };\n }\n\n /** The host's 6.x options, as the editor takes them. */\n function adaptOptions(options) {\n options = Object.assign({}, options || {});\n\n if (options.callbacks) {\n var callbacks = {};\n Object.keys(options.callbacks).forEach(function(name) {\n var callback = options.callbacks[name];\n callbacks[name] = typeof callback === 'function'\n ? function(payload) { return callback(wrapPayload(payload)); }\n : callback;\n });\n options.callbacks = callbacks;\n }\n\n if (options.custom_filter && options.custom_filter.length) {\n var filters = typeof options.custom_filter === 'string' || typeof options.custom_filter === 'function'\n ? [options.custom_filter]\n : Array.prototype.slice.call(options.custom_filter);\n options.custom_filter = filters.map(adaptFilter);\n }\n\n TOOL_SETTINGS.forEach(function(name) {\n if (Array.isArray(options[name])) { options[name] = options[name].map(adaptTool); }\n });\n\n options.source_textarea = unwrap(options.source_textarea);\n\n return options;\n }\n\n /**\n * The handle $(el).data('grideditor') gave in 6.x: the same methods, with\n * jQuery going in and coming out, and the canvas as a jQuery object.\n */\n function handleFor(instance) {\n var handle = { canvas: $(instance.canvas) };\n\n Object.keys(METHODS).forEach(function(name) {\n handle[name] = function() {\n var result = instance[name].apply(instance, Array.prototype.map.call(arguments, unwrapArgument));\n return result === instance ? undefined : wrapResult(result);\n };\n });\n\n Object.defineProperty(handle, 'settings', {\n enumerable: true,\n get: function() { return instance.settings; },\n });\n\n return handle;\n }\n\n /**\n * Every editor gets its 6.x handle, whoever made it: $(el).gridEditor()\n * or new GridEditor(el). It goes with the editor.\n */\n GridEditor._created.push(function(instance) {\n $.data(instance.canvas, 'grideditor', handleFor(instance));\n\n var destroy = instance.destroy;\n instance.destroy = function() {\n var result = destroy.apply(this, arguments);\n $.removeData(instance.canvas, 'grideditor');\n return result;\n };\n });\n\n function dispatchMethod(set, name, args) {\n var descriptor = METHODS[name];\n\n if (!descriptor) {\n warnOnce('method:' + name, 'unknown method \"' + name + '\"');\n return set;\n }\n\n args = args.map(unwrapArgument);\n\n if (descriptor.value) {\n var element = set.first();\n if (!element.length) { return null; }\n\n var instance = GridEditor.get(element[0]);\n if (!instance) {\n if (name === 'getHtml') { return element.html(); }\n if (name === 'getPlainHtml') { return GridEditor._plainHtml(element.html()); }\n return null;\n }\n\n return wrapResult(instance[name].apply(instance, args));\n }\n\n set.each(function() {\n var found = GridEditor.get(this);\n if (found) { found[name].apply(found, args); }\n });\n\n return set;\n }\n\n /**\n * $(el).gridEditor(options): an editor on each element that has none.\n * $(el).gridEditor('method', ...): a method, 6.x style.\n */\n $.fn.gridEditor = function(optionsOrMethod) {\n if (typeof optionsOrMethod == 'string') {\n return dispatchMethod(this, optionsOrMethod, Array.prototype.slice.call(arguments, 1));\n }\n\n var options = adaptOptions(optionsOrMethod);\n\n this.each(function() {\n GridEditor.create(this, options);\n });\n\n return this;\n };\n\n // Strings are the same thing in both: a 6.x locale file loads unchanged\n $.fn.gridEditor.locales = GridEditor.locales;\n $.fn.gridEditor.t = GridEditor.t;\n}\n"],
5
- "mappings": "MASA,IAAIA,EAAa,OAAO,WAExB,GAAI,CAACA,GAAc,OAAOA,EAAW,KAAQ,WACzC,MAAM,IAAI,MAAM,wHAC0B,ECW9C,IAAIC,EAAI,OAAO,OAEXC,EAAU,SAASC,EAAKC,EAAQ,CAAE,OAAOC,EAAW,EAAE,CAAE,OAAQ,IAAK,EAAGF,EAAKC,CAAM,CAAG,EAEtFE,EAAS,CAAC,EAEd,SAASC,EAASJ,EAAKK,EAAS,CACxBF,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M,CACrC,IAAIC,EAAavC,EAAQoB,CAAI,EAE7B,GAAI,CAACmB,EACD,OAAA1C,EAAS,UAAYuB,EAAM,mBAAqBA,EAAO,GAAG,EACnDiB,EAKX,GAFAC,EAAOA,EAAK,IAAIjC,CAAc,EAE1BkC,EAAW,MAAO,CAClB,IAAIC,EAAUH,EAAI,MAAM,EACxB,GAAI,CAACG,EAAQ,OAAU,OAAO,KAE9B,IAAIR,EAAWrC,EAAW,IAAI6C,EAAQ,CAAC,CAAC,EACxC,OAAKR,EAMEzB,EAAWyB,EAASZ,CAAI,EAAE,MAAMY,EAAUM,CAAI,CAAC,EAL9ClB,IAAS,UAAoBoB,EAAQ,KAAK,EAC1CpB,IAAS,eAAyBzB,EAAW,WAAW6C,EAAQ,KAAK,CAAC,EACnE,IAIf,CAEA,OAAAH,EAAI,KAAK,UAAW,CAChB,IAAII,EAAQ9C,EAAW,IAAI,IAAI,EAC3B8C,GAASA,EAAMrB,CAAI,EAAE,MAAMqB,EAAOH,CAAI,CAC9C,CAAC,EAEMD,CACX,CAMA9C,EAAE,GAAG,WAAa,SAASmD,EAAiB,CACxC,GAAI,OAAOA,GAAmB,SAC1B,OAAON,EAAe,KAAMM,EAAiB,MAAM,UAAU,MAAM,KAAK,UAAW,CAAC,CAAC,EAGzF,IAAIf,EAAUD,EAAagB,CAAe,EAE1C,YAAK,KAAK,UAAW,CACjB/C,EAAW,OAAO,KAAMgC,CAAO,CACnC,CAAC,EAEM,IACX,EAGApC,EAAE,GAAG,WAAW,QAAUI,EAAW,QACrCJ,EAAE,GAAG,WAAW,EAAII,EAAW,CACnC",
4
+ "sourcesContent": ["/**\n * What a plugin's or a locale's classic script imports in place of the\n * editor: the GridEditor the page already loaded.\n *\n * The build points `import { GridEditor } from '../grideditor.js'` here for\n * the classic scripts, so each registers on the editor the page has rather\n * than bringing its own. Loaded before the editor there is nothing to\n * register on, and saying so is better than a TypeError three calls later.\n */\nvar GridEditor = window.GridEditor;\n\nif (!GridEditor || typeof GridEditor.get !== 'function') {\n throw new Error('grid-editor: load grideditor.js (or grideditor.bundle.min.js) before its plugins, ' +\n 'its locales and grideditor.jquery.js');\n}\n\nexport { GridEditor };\nexport default GridEditor;\n", "/**\n * The jQuery API of grid-editor 6, on top of the plain DOM editor.\n *\n * A page written for 6.x - one that calls $(el).gridEditor(...), listens\n * with $(el).on('grideditor:...') and reads jQuery objects out of the\n * payloads - loads jQuery 4 and this file after grideditor.js, and runs\n * unchanged:\n *\n * <script src=\"jquery.min.js\"></script>\n * <script src=\"dist/grideditor.min.js\"></script>\n * <script src=\"dist/grideditor.jquery.min.js\"></script>\n * <script src=\"dist/plugins/grideditor.tabs.min.js\"></script>\n *\n * What it keeps is the host's side of 6.x. Plugins are not: they register\n * on GridEditor, and the plugin contract hands out elements.\n *\n * Every value 6.x gave host code as a jQuery object is one again: the event\n * payloads and the callbacks' arguments, what the create* methods return,\n * the handle $(el).data('grideditor') gives, the canvas custom_filter gets,\n * and the event a host tool's handler gets. What the host hands in may be a\n * jQuery object wherever 6.x took one.\n */\nimport { GridEditor } from './grideditor.js';\n\nvar $ = window.jQuery;\n\nvar english = function(key, params) { return GridEditor.t({ locale: 'en' }, key, params); };\n\nvar warned = {};\n\nfunction warnOnce(key, message) {\n if (warned[key]) { return; }\n warned[key] = true;\n if (window.console && window.console.warn) { window.console.warn('grid-editor: ' + message); }\n}\n\nif (!$ || !$.fn) {\n warnOnce('no-jquery', english('warning.adapter_no_jquery'));\n} else {\n install();\n}\n\nfunction install() {\n\n /**\n * Every method 6.x dispatched, and which hand back something other than\n * the jQuery set: those run against the first element only, and do not\n * chain.\n */\n var METHODS = {\n getHtml: { value: true },\n getPlainHtml: { value: true },\n init: {},\n deinit: {},\n reset: {},\n destroy: {},\n changeView: {},\n getView: { value: true },\n createRow: { value: true },\n createColumn: { value: true },\n createElement: { value: true },\n createText: { value: true },\n createSection: { value: true },\n createContainer: { value: true },\n addTab: { value: true },\n addAccordionItem: { value: true },\n setLocale: {},\n getUtility: { value: true },\n setUtility: { value: true },\n getActiveTarget: { value: true },\n setActiveTarget: {},\n };\n\n /** The *_tools settings, whose handlers 6.x bound with jQuery. */\n var TOOL_SETTINGS = ['row_tools', 'col_tools', 'element_tools', 'container_tools',\n 'tab_tools', 'accordion_tools', 'text_tools'];\n\n function isElement(value) {\n return !!value && value.nodeType === 1;\n }\n\n /** What the host handed in, as the editor takes it: a jQuery object is its first element. */\n function unwrap(value) {\n if (value instanceof $) { return value[0] || null; }\n return value;\n }\n\n /** An argument, and the options object an argument may be, unwrapped one level down. */\n function unwrapArgument(value) {\n if (value instanceof $) { return unwrap(value); }\n\n if (value && typeof value === 'object' && !Array.isArray(value) && !isElement(value)) {\n var copy = {};\n Object.keys(value).forEach(function(key) { copy[key] = unwrap(value[key]); });\n return copy;\n }\n\n return value;\n }\n\n /** What the editor handed back, as 6.x did: an element is a jQuery object. */\n function wrapResult(value) {\n return isElement(value) ? $(value) : value;\n }\n\n /**\n * A payload as 6.x built it: its nodes jQuery objects, and an empty set\n * where there is no node - a detached node's parent. The same payload\n * wraps to the same object, so every listener of one notification sees\n * one payload, as they did.\n */\n var wrappedPayloads = new WeakMap();\n\n function wrapPayload(payload) {\n if (!payload || typeof payload !== 'object') { return payload; }\n if (wrappedPayloads.has(payload)) { return wrappedPayloads.get(payload); }\n\n var copy = Object.assign({}, payload);\n\n ['node', 'parent', 'canvas'].forEach(function(key) {\n if (key in payload) { copy[key] = $(payload[key] || []); }\n });\n if (payload.container) { copy.container = $(payload.container); }\n // edit-html writes any number of nodes, which 6.x gave as one set\n if (Array.isArray(payload.nodes)) { copy.node = $(payload.nodes); }\n ['from', 'to'].forEach(function(key) {\n var position = payload[key];\n if (position && typeof position === 'object' && 'parent' in position) {\n copy[key] = Object.assign({}, position, { parent: $(position.parent || []) });\n }\n });\n\n wrappedPayloads.set(payload, copy);\n return copy;\n }\n\n /**\n * The events, as jQuery handlers had them: (event, payload).\n *\n * The editor dispatches DOM events, which jQuery hands its handlers with\n * no second argument. Its dispatcher is where every one of them passes,\n * delegated ones too, so that is where the payload goes back in: once,\n * for each handler, and preventDefault() on the jQuery event is\n * preventDefault() on the editor's.\n */\n var dispatch = $.event.dispatch;\n $.event.dispatch = function(nativeEvent) {\n if (arguments.length === 1 && nativeEvent instanceof window.CustomEvent &&\n typeof nativeEvent.type === 'string' && nativeEvent.type.indexOf('grideditor:') === 0) {\n return dispatch.call(this, nativeEvent, wrapPayload(nativeEvent.detail));\n }\n\n return dispatch.apply(this, arguments);\n };\n\n /** A handler of a host's tool, given a jQuery event as 6.x gave it. */\n function jqueryHandler(handler) {\n return function(event) {\n return handler.call(this, $.event.fix(event));\n };\n }\n\n function adaptTool(tool) {\n if (!tool || !tool.on) { return tool; }\n\n var on;\n if (typeof tool.on === 'function') {\n on = jqueryHandler(tool.on);\n } else {\n on = {};\n Object.keys(tool.on).forEach(function(name) { on[name] = jqueryHandler(tool.on[name]); });\n }\n\n return Object.assign({}, tool, { on: on });\n }\n\n /** A custom_filter, as a function of a jQuery canvas; a name is looked up when it runs. */\n function adaptFilter(filter) {\n return function(canvas, isInit) {\n var func = typeof filter === 'string' ? window[filter] : filter;\n return func($(canvas), isInit);\n };\n }\n\n /** The host's 6.x options, as the editor takes them. */\n function adaptOptions(options) {\n options = Object.assign({}, options || {});\n\n if (options.callbacks) {\n var callbacks = {};\n Object.keys(options.callbacks).forEach(function(name) {\n var callback = options.callbacks[name];\n callbacks[name] = typeof callback === 'function'\n ? function(payload) { return callback(wrapPayload(payload)); }\n : callback;\n });\n options.callbacks = callbacks;\n }\n\n if (options.custom_filter && options.custom_filter.length) {\n var filters = typeof options.custom_filter === 'string' || typeof options.custom_filter === 'function'\n ? [options.custom_filter]\n : Array.prototype.slice.call(options.custom_filter);\n options.custom_filter = filters.map(adaptFilter);\n }\n\n TOOL_SETTINGS.forEach(function(name) {\n if (Array.isArray(options[name])) { options[name] = options[name].map(adaptTool); }\n });\n\n options.source_textarea = unwrap(options.source_textarea);\n\n return options;\n }\n\n /**\n * The handle $(el).data('grideditor') gave in 6.x: the same methods, with\n * jQuery going in and coming out, and the canvas as a jQuery object.\n */\n function handleFor(instance) {\n var handle = { canvas: $(instance.canvas) };\n\n Object.keys(METHODS).forEach(function(name) {\n handle[name] = function() {\n var result = instance[name].apply(instance, Array.prototype.map.call(arguments, unwrapArgument));\n return result === instance ? undefined : wrapResult(result);\n };\n });\n\n Object.defineProperty(handle, 'settings', {\n enumerable: true,\n get: function() { return instance.settings; },\n });\n\n return handle;\n }\n\n /**\n * Every editor gets its 6.x handle, whoever made it: $(el).gridEditor()\n * or new GridEditor(el). It goes with the editor.\n */\n GridEditor._created.push(function(instance) {\n $.data(instance.canvas, 'grideditor', handleFor(instance));\n\n var destroy = instance.destroy;\n instance.destroy = function() {\n var result = destroy.apply(this, arguments);\n $.removeData(instance.canvas, 'grideditor');\n return result;\n };\n });\n\n function dispatchMethod(set, name, args) {\n var descriptor = METHODS[name];\n\n if (!descriptor) {\n warnOnce('method:' + name, 'unknown method \"' + name + '\"');\n return set;\n }\n\n args = args.map(unwrapArgument);\n\n if (descriptor.value) {\n var element = set.first();\n if (!element.length) { return null; }\n\n var instance = GridEditor.get(element[0]);\n if (!instance) {\n if (name === 'getHtml') { return element.html(); }\n if (name === 'getPlainHtml') { return GridEditor._plainHtml(element.html()); }\n return null;\n }\n\n return wrapResult(instance[name].apply(instance, args));\n }\n\n set.each(function() {\n var found = GridEditor.get(this);\n if (found) { found[name].apply(found, args); }\n });\n\n return set;\n }\n\n /**\n * $(el).gridEditor(options): an editor on each element that has none.\n * $(el).gridEditor('method', ...): a method, 6.x style.\n */\n $.fn.gridEditor = function(optionsOrMethod) {\n if (typeof optionsOrMethod == 'string') {\n return dispatchMethod(this, optionsOrMethod, Array.prototype.slice.call(arguments, 1));\n }\n\n var options = adaptOptions(optionsOrMethod);\n\n this.each(function() {\n GridEditor.create(this, options);\n });\n\n return this;\n };\n\n // Strings are the same thing in both: a 6.x locale file loads unchanged\n $.fn.gridEditor.locales = G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AAW,QAAUI,EAAW,QACrCJ,EAAE,GAAG,WAAW,EAAII,EAAW,CACnC",
6
6
  "names": ["GridEditor", "$", "english", "key", "params", "GridEditor", "warned", "warnOnce", "message", "install", "METHODS", "TOOL_SETTINGS", "isElement", "value", "unwrap", "unwrapArgument", "copy", "wrapResult", "wrappedPayloads", "wrapPayload", "payload", "position", "dispatch", "nativeEvent", "jqueryHandler", "handler", "event", "adaptTool", "tool", "on", "name", "adaptFilter", "filter", "canvas", "isInit", "func", "adaptOptions", "options", "callbacks", "callback", "filters", "handleFor", "instance", "handle", "result", "destroy", "dispatchMethod", "set", "args", "descriptor", "element", "found", "optionsOrMethod"]
7
7
  }
@@ -239,7 +239,10 @@
239
239
  var DEFAULT_DURATION = 400;
240
240
  function animateAway(node, frames, duration, done) {
241
241
  duration = duration === void 0 ? DEFAULT_DURATION : duration;
242
+ addClass(node, "ge-leaving");
242
243
  var finish = function() {
244
+ removeClass(node, "ge-leaving");
245
+ dropEmptyClass(node);
243
246
  hide(node);
244
247
  if (done) {
245
248
  done();
@@ -329,9 +332,7 @@
329
332
  getUtility: { value: true },
330
333
  setUtility: { value: true },
331
334
  getActiveTarget: { value: true },
332
- setActiveTarget: {},
333
- getSelected: { value: true },
334
- setSelected: {}
335
+ setActiveTarget: {}
335
336
  };
336
337
  var PLACEMENTS = ["appendTo", "prependTo", "insertAfter", "insertBefore"];
337
338
  var REFERENCES = [
@@ -687,7 +688,6 @@
687
688
  var sortables = [];
688
689
  var instanceId = ++editorCounter;
689
690
  var destroyed = false;
690
- var selected = null;
691
691
  var sidebarCollapsed = null;
692
692
  var pluginHandle = null;
693
693
  if (settings.settings_panel === "sidebar") {
@@ -699,6 +699,8 @@
699
699
  }
700
700
  }
701
701
  var detailsFor = /* @__PURE__ */ new WeakMap();
702
+ var toolActions = /* @__PURE__ */ new WeakMap();
703
+ var pendingDelete = null;
702
704
  var moves = /* @__PURE__ */ new WeakMap();
703
705
  var resizes = /* @__PURE__ */ new WeakMap();
704
706
  var sectionNodes = /* @__PURE__ */ new WeakMap();
@@ -922,12 +924,17 @@
922
924
  });
923
925
  }
924
926
  function deleteNode(kind, node, message, animate) {
927
+ var asked = pendingDelete || {};
928
+ pendingDelete = null;
925
929
  operate(function() {
926
- var payload = payloadFor(kind, node, { source: "tool" });
930
+ var payload = payloadFor(kind, node, { source: asked.source || "tool" });
927
931
  if (!emit("before-delete", payload)) {
928
932
  return;
929
933
  }
930
- askToDelete(message, function() {
934
+ if (asked.before) {
935
+ asked.before();
936
+ }
937
+ var remove = function() {
931
938
  operate(function() {
932
939
  animate(function() {
933
940
  node.remove();
@@ -937,9 +944,40 @@
937
944
  });
938
945
  });
939
946
  });
940
- });
947
+ };
948
+ if (asked.confirm === false) {
949
+ remove();
950
+ } else {
951
+ askToDelete(message, remove);
952
+ }
941
953
  });
942
954
  }
955
+ function removeNode(node, options) {
956
+ options = options || {};
957
+ var drawer = node ? drawerOf(node) : null;
958
+ var tool = drawer ? child(drawer, '[class*="ge-delete-"]') : null;
959
+ var action = tool ? toolActions.get(tool) : null;
960
+ if (!action) {
961
+ return false;
962
+ }
963
+ var went = false;
964
+ pendingDelete = {
965
+ source: options.source,
966
+ confirm: options.confirm,
967
+ before: function() {
968
+ went = true;
969
+ if (options.before) {
970
+ options.before();
971
+ }
972
+ }
973
+ };
974
+ try {
975
+ action.call(tool);
976
+ } finally {
977
+ pendingDelete = null;
978
+ }
979
+ return went;
980
+ }
943
981
  function planSize(col, size, view) {
944
982
  view = view || curView;
945
983
  if (view !== ALL_VIEW) {
@@ -1130,8 +1168,7 @@
1130
1168
  var signal = { signal: lifetime.signal };
1131
1169
  window.addEventListener("scroll", onScroll, signal);
1132
1170
  delegate(canvas, "click", ".ge-content", onContentClick, signal);
1133
- var sidebarMode = panelMode() === "sidebar";
1134
- if (settings.active_target || sidebarMode) {
1171
+ if (settings.active_target) {
1135
1172
  var pressed = null;
1136
1173
  canvas.addEventListener("pointerdown", function(e) {
1137
1174
  pressed = { x: e.clientX, y: e.clientY };
@@ -1145,12 +1182,7 @@
1145
1182
  if (from && Math.abs(e.clientX - from.x) + Math.abs(e.clientY - from.y) > settings.drag.threshold) {
1146
1183
  return;
1147
1184
  }
1148
- if (settings.active_target) {
1149
- clickTarget(e);
1150
- }
1151
- if (sidebarMode && canvas.contains(e.target)) {
1152
- changeSelection(settingsNodeAt(e.target));
1153
- }
1185
+ clickTarget(e);
1154
1186
  }, signal);
1155
1187
  document.addEventListener("keydown", function(e) {
1156
1188
  if (e.key !== "Escape" || openSettingsState || dialogState) {
@@ -1163,23 +1195,28 @@
1163
1195
  if (focus && (is(focus, "input, textarea, select") || focus.isContentEditable)) {
1164
1196
  return;
1165
1197
  }
1166
- if (selected && isEditing()) {
1167
- changeSelection(null);
1168
- } else if (activeTarget) {
1198
+ if (activeTarget) {
1169
1199
  changeTarget(null);
1170
1200
  }
1171
1201
  }, signal);
1172
- }
1173
- if (sidebarMode) {
1174
1202
  canvas.addEventListener("focusin", function(e) {
1175
1203
  var node = isEditing() ? settingsNodeAt(e.target) : null;
1176
1204
  if (node) {
1177
- changeSelection(node);
1205
+ changeTarget(node);
1178
1206
  }
1179
1207
  }, signal);
1208
+ var pressedOn = null;
1209
+ document.addEventListener("pointerdown", function(e) {
1210
+ pressedOn = e.target;
1211
+ }, { capture: true, signal: signal.signal });
1180
1212
  document.addEventListener("click", function(e) {
1181
1213
  var target = e.target;
1182
- if (!selected || !isEditing() || !target || target.nodeType !== 1) {
1214
+ var from = pressedOn;
1215
+ pressedOn = null;
1216
+ if (!activeTarget || !isEditing() || !target || target.nodeType !== 1) {
1217
+ return;
1218
+ }
1219
+ if (from && from.nodeType === 1 && (canvas.contains(from) || closest(from, EDITOR_CONTROLS))) {
1183
1220
  return;
1184
1221
  }
1185
1222
  if (!attached(target) || canvas.contains(target)) {
@@ -1188,17 +1225,22 @@
1188
1225
  if (closest(target, EDITOR_CONTROLS) || canvas.querySelector(".ge-rte-active")) {
1189
1226
  return;
1190
1227
  }
1191
- changeSelection(null);
1228
+ changeTarget(null);
1192
1229
  }, signal);
1230
+ }
1231
+ if (panelMode() === "sidebar") {
1193
1232
  window.addEventListener("resize", reserveSidebarRoom, signal);
1194
1233
  }
1195
1234
  function clickTarget(e) {
1196
- var region = closest(e.target, targetSelector());
1197
- if (region && region === activeTarget && (e.target === region || e.target === child(region, ".ge-tools-drawer"))) {
1235
+ if (!canvas.contains(e.target)) {
1236
+ return;
1237
+ }
1238
+ var node = settingsNodeAt(e.target);
1239
+ if (node && node === activeTarget && (e.target === drawerOf(node) || e.target === node && !hasClass(node, "ge-content"))) {
1198
1240
  changeTarget(null);
1199
1241
  return;
1200
1242
  }
1201
- changeTarget(region && region !== canvas && canvas.contains(region) ? region : null);
1243
+ changeTarget(node);
1202
1244
  }
1203
1245
  }
1204
1246
  function textReady(block) {
@@ -1683,13 +1725,11 @@
1683
1725
  }
1684
1726
  var placed = made;
1685
1727
  if (item.inColumn) {
1686
- if (!is(where.region, ".column")) {
1687
- placed = inRowOfItsOwn(made);
1688
- }
1728
+ placed = wrapFor(where.region, made);
1689
1729
  } else if (!acceptsBlock(where.region, made)) {
1690
- var ancestors = where.region === canvas ? [] : parentsUntil(where.region, canvas).reverse().concat([where.region]);
1691
- var top = ancestors[0] || null;
1692
- where = { region: canvas, before: top ? top.nextElementSibling : null };
1730
+ where = canvasAfterTopOf(where.region);
1731
+ } else if (is(where.region, ".row")) {
1732
+ placed = wrapFor(where.region, made);
1693
1733
  }
1694
1734
  return addNode(item.kind, made, function() {
1695
1735
  if (where.before) {
@@ -1699,10 +1739,32 @@
1699
1739
  }
1700
1740
  }, { parent: where.region, source: item.source || source || "dragdrop" });
1701
1741
  }
1742
+ function canvasAfterTopOf(region) {
1743
+ var ancestors = region === canvas ? [] : parentsUntil(region, canvas).reverse().concat([region]);
1744
+ var top = ancestors[0] || null;
1745
+ return { region: canvas, before: top ? top.nextElementSibling : null };
1746
+ }
1747
+ function placeInTarget(node, kind, source) {
1748
+ if (!activeTarget) {
1749
+ return null;
1750
+ }
1751
+ var where = { region: effectiveRegion(activeTarget), before: null };
1752
+ var placed = wrapFor(where.region, node);
1753
+ var holder = placed === node ? null : node.parentElement;
1754
+ if (!acceptsBlock(where.region, placed) || holder && !acceptsBlock(holder, node)) {
1755
+ where = canvasAfterTopOf(where.region);
1756
+ placed = node;
1757
+ }
1758
+ return addNode(kind, node, function() {
1759
+ if (where.before) {
1760
+ where.before.parentNode.insertBefore(placed, where.before);
1761
+ } else {
1762
+ where.region.appendChild(placed);
1763
+ }
1764
+ }, { parent: where.region, source: source || "api" });
1765
+ }
1702
1766
  function inRowOfItsOwn(node) {
1703
- var row = createRow();
1704
- row.appendChild(createColumn(MAX_COL_SIZE)).appendChild(node);
1705
- return row;
1767
+ return rowHolding(createColumn(MAX_COL_SIZE), node);
1706
1768
  }
1707
1769
  function showDropMarker(pageX, pageY) {
1708
1770
  var where = dropPlaceAt(pageX, pageY);
@@ -1731,10 +1793,7 @@
1731
1793
  var container = button.getAttribute("data-ge-toolbar") === "container";
1732
1794
  var type = button.getAttribute("data-ge-container-type");
1733
1795
  var made = container ? CONTAINERS[type].create({}) : rowFromLayout(button.getAttribute("data-ge-layout"));
1734
- var placed = made;
1735
- if (container && !is(where.region, ".column")) {
1736
- placed = inRowOfItsOwn(made);
1737
- }
1796
+ var placed = wrapFor(where.region, made);
1738
1797
  return addNode(container ? type : "row", made, function() {
1739
1798
  if (where.before) {
1740
1799
  where.before.parentNode.insertBefore(placed, where.before);
@@ -1997,7 +2056,6 @@
1997
2056
  setPreview(false);
1998
2057
  deinit();
1999
2058
  changeTarget(null);
2000
- changeSelection(null);
2001
2059
  htmlTextArea.style.height = 0.8 * document.documentElement.clientHeight + "px";
2002
2060
  htmlTextArea.value = canvas.innerHTML;
2003
2061
  show(htmlTextArea);
@@ -2013,11 +2071,8 @@
2013
2071
  init();
2014
2072
  hide(htmlTextArea);
2015
2073
  }
2016
- function targetSelector() {
2017
- return [".column"].concat(pluginHooks("regions")).join(", ");
2018
- }
2019
2074
  function isTarget(node) {
2020
- return !!node && node !== canvas && canvas.contains(node) && is(node, targetSelector());
2075
+ return !!node && node !== canvas && canvas.contains(node) && detailsFor.has(node);
2021
2076
  }
2022
2077
  function changeTarget(node) {
2023
2078
  if (node === activeTarget) {
@@ -2025,16 +2080,63 @@
2025
2080
  }
2026
2081
  var from = activeTarget;
2027
2082
  if (from) {
2028
- removeClass(from, "ge-active-target");
2083
+ removeClass(from, "ge-selected");
2029
2084
  }
2030
2085
  activeTarget = node;
2031
2086
  if (node && hasClass(canvas, "ge-editing")) {
2032
- addClass(node, "ge-active-target");
2087
+ addClass(node, "ge-selected");
2033
2088
  }
2089
+ renderSidebar();
2034
2090
  emit("target-change", { canvas, target: node, from });
2035
2091
  }
2092
+ function regionSelector() {
2093
+ return [".column"].concat(pluginHooks("regions")).join(", ");
2094
+ }
2095
+ function effectiveRegion(target) {
2096
+ if (is(target, ".row, " + regionSelector())) {
2097
+ return target;
2098
+ }
2099
+ var inside = isContainerOrPane(target) ? paneRegionOf(target) : null;
2100
+ return inside || closest(target.parentElement, regionSelector()) || canvas;
2101
+ }
2102
+ function isContainerOrPane(node) {
2103
+ if (node.getAttribute("data-ge-container")) {
2104
+ return true;
2105
+ }
2106
+ var container = closest(node.parentElement, "[data-ge-container]", canvas);
2107
+ var definition = container && CONTAINERS[containerTypeOf(container)];
2108
+ return !!definition && !!definition.paneKind && kindOf(node) === definition.paneKind;
2109
+ }
2110
+ function paneRegionOf(node) {
2111
+ var isContainer = !!node.getAttribute("data-ge-container");
2112
+ var container = isContainer ? node : closest(node.parentElement, "[data-ge-container]", canvas);
2113
+ var definition = CONTAINERS[containerTypeOf(container)];
2114
+ return definition && definition.regionOf ? definition.regionOf(container, isContainer ? null : node) || null : null;
2115
+ }
2116
+ function wrapFor(region, node) {
2117
+ if (is(node, ".column")) {
2118
+ return is(region, ".row") ? node : rowHolding(node);
2119
+ }
2120
+ if (is(region, ".row")) {
2121
+ var column = createColumn(rowColsSource(region, leadingTier()) ? null : settings.add_column.size);
2122
+ column.appendChild(node);
2123
+ return column;
2124
+ }
2125
+ if (is(region, ".column") || is(node, ".row")) {
2126
+ return node;
2127
+ }
2128
+ return rowHolding(createColumn(MAX_COL_SIZE), node);
2129
+ }
2130
+ function rowHolding(column, node) {
2131
+ var row = createRow();
2132
+ if (node) {
2133
+ column.appendChild(node);
2134
+ }
2135
+ row.appendChild(column);
2136
+ return row;
2137
+ }
2036
2138
  function addToTarget(button, source) {
2037
- var made = insertFromToolbar(button, { region: activeTarget, before: null }, source);
2139
+ var made = insertFromToolbar(button, { region: effectiveRegion(activeTarget), before: null }, source);
2038
2140
  if (made && made.scrollIntoView) {
2039
2141
  made.scrollIntoView({ behavior: "smooth" });
2040
2142
  }
@@ -2043,8 +2145,8 @@
2043
2145
  if (openSettingsState && !attached(openSettingsState.node)) {
2044
2146
  closeSettings();
2045
2147
  }
2046
- if (selected && !canvas.contains(selected)) {
2047
- changeSelection(null);
2148
+ if (activeTarget && !canvas.contains(activeTarget)) {
2149
+ changeTarget(null);
2048
2150
  }
2049
2151
  if (dialogState && dialogState.home && !attached(dialogState.home)) {
2050
2152
  closeDialog();
@@ -2068,7 +2170,7 @@
2068
2170
  if (activeTarget && !canvas.contains(activeTarget)) {
2069
2171
  changeTarget(null);
2070
2172
  } else if (activeTarget) {
2071
- addClass(activeTarget, "ge-active-target");
2173
+ addClass(activeTarget, "ge-selected");
2072
2174
  }
2073
2175
  showSidebar();
2074
2176
  }
@@ -2077,7 +2179,7 @@
2077
2179
  hideSidebar();
2078
2180
  removeClass(canvas, "ge-editing ge-drag-drawer ge-dropping");
2079
2181
  if (activeTarget) {
2080
- removeClass(activeTarget, "ge-active-target");
2182
+ removeClass(activeTarget, "ge-selected");
2081
2183
  }
2082
2184
  plugins("onBeforeDeinit");
2083
2185
  closeSizePicker();
@@ -2154,8 +2256,8 @@
2154
2256
  }
2155
2257
  var copy = copyCanvas();
2156
2258
  var root = copy.root;
2157
- [root].concat(all(root, ".ge-active-target, .ge-settings-target")).forEach(function(node) {
2158
- removeClass(node, "ge-active-target ge-settings-target");
2259
+ [root].concat(all(root, ".ge-selected, .ge-settings-target, .ge-leaving")).forEach(function(node) {
2260
+ removeClass(node, "ge-selected ge-settings-target ge-leaving");
2159
2261
  dropEmptyClass(node);
2160
2262
  });
2161
2263
  all(root, ".ge-drop-marker").forEach(function(marker) {
@@ -2237,7 +2339,6 @@
2237
2339
  setPreview(false);
2238
2340
  deinit();
2239
2341
  activeTarget = null;
2240
- selected = null;
2241
2342
  if (sidebarHolder === instance) {
2242
2343
  sidebarHolder = null;
2243
2344
  }
@@ -2318,6 +2419,9 @@
2318
2419
  addSettingsTool,
2319
2420
  deleteNode,
2320
2421
  place,
2422
+ // A node made, added to the active target as the toolbar adds
2423
+ // what it makes: null with no target, or when it was canceled
2424
+ placeInTarget,
2321
2425
  createPaneControls,
2322
2426
  makeLabelEditable,
2323
2427
  labelIn,
@@ -2374,30 +2478,23 @@
2374
2478
  toolbarItems: function(name) {
2375
2479
  return mainControls ? all(mainControls, '[data-ge-toolbar="feature"][data-ge-feature="' + name + '"]') : [];
2376
2480
  },
2377
- getSelected: function() {
2378
- return panelMode() === "sidebar" ? selected : null;
2379
- },
2380
2481
  getActiveTarget: function() {
2381
2482
  return settings.active_target ? activeTarget : null;
2382
2483
  },
2383
2484
  // True when it took: a node that cannot be, or no setting
2384
2485
  // for it, says nothing, since a plugin putting back what it
2385
2486
  // remembers cannot know the node is still one
2386
- setSelected: function(node) {
2387
- var chosen = panelMode() === "sidebar" && !!node && node !== canvas && canvas.contains(node) && detailsFor.has(node);
2388
- if (chosen) {
2389
- changeSelection(node);
2390
- }
2391
- return chosen;
2392
- },
2487
+ // null takes it away
2393
2488
  setActiveTarget: function(node) {
2394
- var chosen = !!settings.active_target && isTarget(node);
2489
+ var chosen = !!settings.active_target && (node === null || isTarget(node));
2395
2490
  if (chosen) {
2396
2491
  changeTarget(node);
2397
2492
  }
2398
2493
  return chosen;
2399
2494
  },
2400
- // What keeps Escape from the selection and the target, and an
2495
+ // A node removed as its delete tool does, as asked
2496
+ removeNode,
2497
+ // What keeps Escape from the target, and an
2401
2498
  // inline panel unfolded in a drawer, which Escape leaves alone
2402
2499
  panelOpen: function() {
2403
2500
  if (openSettingsState || dialogState) {
@@ -3447,11 +3544,15 @@
3447
3544
  drawer.appendChild(tool);
3448
3545
  if (typeof eventHandlers == "function") {
3449
3546
  tool.addEventListener("click", eventHandlers);
3547
+ toolActions.set(tool, eventHandlers);
3450
3548
  }
3451
3549
  if (eventHandlers && typeof eventHandlers == "object") {
3452
3550
  Object.keys(eventHandlers).forEach(function(name) {
3453
3551
  on(tool, name, eventHandlers[name]);
3454
3552
  });
3553
+ if (typeof eventHandlers.click == "function") {
3554
+ toolActions.set(tool, eventHandlers.click);
3555
+ }
3455
3556
  }
3456
3557
  return tool;
3457
3558
  }
@@ -3770,7 +3871,7 @@
3770
3871
  delegate(panel, "click", ".ge-settings-close", function(e) {
3771
3872
  e.preventDefault();
3772
3873
  if (mode === "sidebar") {
3773
- changeSelection(null);
3874
+ changeTarget(null);
3774
3875
  } else {
3775
3876
  closeSettings();
3776
3877
  }
@@ -3891,7 +3992,7 @@
3891
3992
  if (!panel || !isEditing()) {
3892
3993
  return;
3893
3994
  }
3894
- var details = selected ? detailsOf(selected) : null;
3995
+ var details = activeTarget ? detailsOf(activeTarget) : null;
3895
3996
  if (details ? sidebarShown && sidebarShown.details === details : !sidebarShown && sidebarEmpty) {
3896
3997
  return;
3897
3998
  }
@@ -3905,11 +4006,10 @@
3905
4006
  sidebarEmpty = { body };
3906
4007
  return;
3907
4008
  }
3908
- sidebarShown = { node: selected, details, home: details.parentElement, next: details.nextElementSibling };
3909
- setSidebarTitle(t("panel.title", { kind: kindLabel(selected) }));
4009
+ sidebarShown = { node: activeTarget, details, home: details.parentElement, next: details.nextElementSibling };
4010
+ setSidebarTitle(t("panel.title", { kind: kindLabel(activeTarget) }));
3910
4011
  holder.appendChild(details);
3911
4012
  show(details);
3912
- addClass(selected, "ge-settings-target");
3913
4013
  }
3914
4014
  function emptyContent() {
3915
4015
  var fromHost = settings.sidebar.empty;
@@ -3959,15 +4059,6 @@
3959
4059
  }
3960
4060
  return null;
3961
4061
  }
3962
- function changeSelection(node) {
3963
- if (node === selected) {
3964
- return;
3965
- }
3966
- var from = selected;
3967
- selected = node;
3968
- renderSidebar();
3969
- emit("selection-change", { canvas, node, from });
3970
- }
3971
4062
  function placePopover(panel, gear) {
3972
4063
  if (!attached(gear)) {
3973
4064
  return;
@@ -5077,28 +5168,11 @@
5077
5168
  var node = nodeFrom(value);
5078
5169
  if (!isTarget(node)) {
5079
5170
  var named = typeof value === "string" ? value : node ? "<" + node.tagName.toLowerCase() + ">" : String(value);
5080
- warn("setActiveTarget: " + named + " is not a column or a region of the canvas");
5171
+ warn("setActiveTarget: " + named + " is not a node of the canvas with settings");
5081
5172
  return;
5082
5173
  }
5083
5174
  changeTarget(node);
5084
5175
  }
5085
- function apiSetSelected(value) {
5086
- if (panelMode() !== "sidebar") {
5087
- warnOnceHere("sidebar-api", 'setSelected needs settings_panel "sidebar": without it, it does nothing');
5088
- return;
5089
- }
5090
- if (value === null || value === void 0) {
5091
- changeSelection(null);
5092
- return;
5093
- }
5094
- var node = nodeFrom(value);
5095
- if (!node || node === canvas || !canvas.contains(node) || !detailsFor.has(node)) {
5096
- var named = typeof value === "string" ? value : node ? "<" + node.tagName.toLowerCase() + ">" : String(value);
5097
- warn("setSelected: " + named + " is not a node of the canvas with settings");
5098
- return;
5099
- }
5100
- changeSelection(node);
5101
- }
5102
5176
  var own = {
5103
5177
  getHtml,
5104
5178
  getPlainHtml,
@@ -5137,11 +5211,7 @@
5137
5211
  getActiveTarget: function() {
5138
5212
  return settings.active_target ? activeTarget : null;
5139
5213
  },
5140
- setActiveTarget: apiSetActiveTarget,
5141
- getSelected: function() {
5142
- return panelMode() === "sidebar" ? selected : null;
5143
- },
5144
- setSelected: apiSetSelected
5214
+ setActiveTarget: apiSetActiveTarget
5145
5215
  };
5146
5216
  Object.keys(own).forEach(function(name) {
5147
5217
  var value = !!(METHODS[name] && METHODS[name].value);
@@ -5192,7 +5262,7 @@
5192
5262
  GridEditor._plainHtml = plainHtml;
5193
5263
  GridEditor.Sortable = null;
5194
5264
  GridEditor.bootstrap = null;
5195
- GridEditor.version = false ? "dev" : "9.0.0-beta.5";
5265
+ GridEditor.version = false ? "dev" : "9.0.0-beta.7";
5196
5266
  GridEditor.locales = {
5197
5267
  en: {
5198
5268
  "tool.move": "Move",