@themarioga/grid-editor 9.0.0-beta.4 → 9.0.0-beta.6
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.
- package/CHANGELOG.md +49 -0
- package/README.md +29 -17
- package/UPGRADING.md +24 -5
- package/dist/grideditor.bundle.min.js +3 -3
- package/dist/grideditor.css +5 -4
- package/dist/grideditor.d.ts +10 -15
- package/dist/grideditor.esm.js +151 -113
- package/dist/grideditor.jquery.js +1 -3
- package/dist/grideditor.jquery.min.js +1 -1
- package/dist/grideditor.jquery.min.js.map +2 -2
- package/dist/grideditor.js +151 -113
- package/dist/grideditor.min.css +1 -1
- package/dist/grideditor.min.css.map +1 -1
- package/dist/grideditor.min.js +2 -2
- package/dist/grideditor.min.js.map +3 -3
- package/dist/plugins/grideditor.accordion.esm.js +7 -0
- package/dist/plugins/grideditor.accordion.js +7 -0
- package/dist/plugins/grideditor.accordion.min.js +1 -1
- package/dist/plugins/grideditor.accordion.min.js.map +3 -3
- package/dist/plugins/grideditor.card.esm.js +4 -0
- package/dist/plugins/grideditor.card.js +4 -0
- package/dist/plugins/grideditor.card.min.js +1 -1
- package/dist/plugins/grideditor.card.min.js.map +3 -3
- package/dist/plugins/grideditor.carousel.esm.js +4 -0
- package/dist/plugins/grideditor.carousel.js +4 -0
- package/dist/plugins/grideditor.carousel.min.js +1 -1
- package/dist/plugins/grideditor.carousel.min.js.map +2 -2
- package/dist/plugins/grideditor.clipboard.esm.js +3 -18
- package/dist/plugins/grideditor.clipboard.js +3 -18
- package/dist/plugins/grideditor.clipboard.min.js +1 -1
- package/dist/plugins/grideditor.clipboard.min.js.map +3 -3
- package/dist/plugins/grideditor.history.esm.js +1 -6
- package/dist/plugins/grideditor.history.js +1 -6
- package/dist/plugins/grideditor.history.min.js +1 -1
- package/dist/plugins/grideditor.history.min.js.map +3 -3
- package/dist/plugins/grideditor.offcanvas.esm.js +185 -4
- package/dist/plugins/grideditor.offcanvas.js +185 -4
- package/dist/plugins/grideditor.offcanvas.min.js +1 -1
- package/dist/plugins/grideditor.offcanvas.min.js.map +3 -3
- package/dist/plugins/grideditor.popup.esm.js +185 -4
- package/dist/plugins/grideditor.popup.js +185 -4
- package/dist/plugins/grideditor.popup.min.js +1 -1
- package/dist/plugins/grideditor.popup.min.js.map +3 -3
- package/dist/plugins/grideditor.tabs.esm.js +4 -0
- package/dist/plugins/grideditor.tabs.js +4 -0
- package/dist/plugins/grideditor.tabs.min.js +1 -1
- package/dist/plugins/grideditor.tabs.min.js.map +2 -2
- package/docs/events.md +14 -11
- package/docs/plugins.md +20 -8
- package/example/clipboard.html +13 -10
- package/package.json +1 -1
- package/src/js/grideditor.jquery.js +0 -2
- package/src/js/grideditor.js +211 -125
- package/src/js/plugins/grideditor.accordion.js +9 -0
- package/src/js/plugins/grideditor.card.js +5 -0
- package/src/js/plugins/grideditor.carousel.js +5 -0
- package/src/js/plugins/grideditor.clipboard.js +11 -24
- package/src/js/plugins/grideditor.history.js +3 -6
- package/src/js/plugins/grideditor.offcanvas.js +8 -0
- package/src/js/plugins/grideditor.popup.js +7 -0
- package/src/js/plugins/grideditor.tabs.js +5 -0
- package/src/js/triggers/triggers.js +211 -11
- package/src/less/grideditor.less +5 -4
- package/types/grideditor.d.ts +10 -15
|
@@ -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,EAAOH,CAAG,IACdG,EAAOH,CAAG,EAAI,GACV,OAAO,SAAW,OAAO,QAAQ,MAAQ,OAAO,QAAQ,KAAK,gBAAkBK,CAAO,EAC9F,CAEI,CAACP,GAAK,CAACA,EAAE,GACTM,EAAS,YAAaL,EAAQ,2BAA2B,CAAC,EAE1DO,EAAQ,EAGZ,SAASA,GAAU,CAOf,IAAIC,EAAU,CACV,QAAkB,CAAE,MAAO,EAAK,EAChC,aAAkB,CAAE,MAAO,EAAK,EAChC,KAAkB,CAAC,EACnB,OAAkB,CAAC,EACnB,MAAkB,CAAC,EACnB,QAAkB,CAAC,EACnB,WAAkB,CAAC,EACnB,QAAkB,CAAE,MAAO,EAAK,EAChC,UAAkB,CAAE,MAAO,EAAK,EAChC,aAAkB,CAAE,MAAO,EAAK,EAChC,cAAkB,CAAE,MAAO,EAAK,EAChC,WAAkB,CAAE,MAAO,EAAK,EAChC,cAAkB,CAAE,MAAO,EAAK,EAChC,gBAAkB,CAAE,MAAO,EAAK,EAChC,OAAkB,CAAE,MAAO,EAAK,EAChC,iBAAkB,CAAE,MAAO,EAAK,EAChC,UAAkB,CAAC,EACnB,WAAkB,CAAE,MAAO,EAAK,EAChC,WAAkB,CAAE,MAAO,EAAK,EAChC,gBAAkB,CAAE,MAAO,EAAK,EAChC,gBAAkB,CAAC,
|
|
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 = 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,EAAOH,CAAG,IACdG,EAAOH,CAAG,EAAI,GACV,OAAO,SAAW,OAAO,QAAQ,MAAQ,OAAO,QAAQ,KAAK,gBAAkBK,CAAO,EAC9F,CAEI,CAACP,GAAK,CAACA,EAAE,GACTM,EAAS,YAAaL,EAAQ,2BAA2B,CAAC,EAE1DO,EAAQ,EAGZ,SAASA,GAAU,CAOf,IAAIC,EAAU,CACV,QAAkB,CAAE,MAAO,EAAK,EAChC,aAAkB,CAAE,MAAO,EAAK,EAChC,KAAkB,CAAC,EACnB,OAAkB,CAAC,EACnB,MAAkB,CAAC,EACnB,QAAkB,CAAC,EACnB,WAAkB,CAAC,EACnB,QAAkB,CAAE,MAAO,EAAK,EAChC,UAAkB,CAAE,MAAO,EAAK,EAChC,aAAkB,CAAE,MAAO,EAAK,EAChC,cAAkB,CAAE,MAAO,EAAK,EAChC,WAAkB,CAAE,MAAO,EAAK,EAChC,cAAkB,CAAE,MAAO,EAAK,EAChC,gBAAkB,CAAE,MAAO,EAAK,EAChC,OAAkB,CAAE,MAAO,EAAK,EAChC,iBAAkB,CAAE,MAAO,EAAK,EAChC,UAAkB,CAAC,EACnB,WAAkB,CAAE,MAAO,EAAK,EACh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AC,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",
|
|
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
|
}
|
package/dist/grideditor.js
CHANGED
|
@@ -329,9 +329,7 @@
|
|
|
329
329
|
getUtility: { value: true },
|
|
330
330
|
setUtility: { value: true },
|
|
331
331
|
getActiveTarget: { value: true },
|
|
332
|
-
setActiveTarget: {}
|
|
333
|
-
getSelected: { value: true },
|
|
334
|
-
setSelected: {}
|
|
332
|
+
setActiveTarget: {}
|
|
335
333
|
};
|
|
336
334
|
var PLACEMENTS = ["appendTo", "prependTo", "insertAfter", "insertBefore"];
|
|
337
335
|
var REFERENCES = [
|
|
@@ -672,6 +670,7 @@
|
|
|
672
670
|
var confirmDialog = null;
|
|
673
671
|
var sizePicker = null;
|
|
674
672
|
var sourceOpen = false;
|
|
673
|
+
var previewing = false;
|
|
675
674
|
var dropMarker = null;
|
|
676
675
|
var activeTarget = null;
|
|
677
676
|
var toolbarLifetime = null;
|
|
@@ -686,7 +685,6 @@
|
|
|
686
685
|
var sortables = [];
|
|
687
686
|
var instanceId = ++editorCounter;
|
|
688
687
|
var destroyed = false;
|
|
689
|
-
var selected = null;
|
|
690
688
|
var sidebarCollapsed = null;
|
|
691
689
|
var pluginHandle = null;
|
|
692
690
|
if (settings.settings_panel === "sidebar") {
|
|
@@ -1129,8 +1127,7 @@
|
|
|
1129
1127
|
var signal = { signal: lifetime.signal };
|
|
1130
1128
|
window.addEventListener("scroll", onScroll, signal);
|
|
1131
1129
|
delegate(canvas, "click", ".ge-content", onContentClick, signal);
|
|
1132
|
-
|
|
1133
|
-
if (settings.active_target || sidebarMode) {
|
|
1130
|
+
if (settings.active_target) {
|
|
1134
1131
|
var pressed = null;
|
|
1135
1132
|
canvas.addEventListener("pointerdown", function(e) {
|
|
1136
1133
|
pressed = { x: e.clientX, y: e.clientY };
|
|
@@ -1144,12 +1141,7 @@
|
|
|
1144
1141
|
if (from && Math.abs(e.clientX - from.x) + Math.abs(e.clientY - from.y) > settings.drag.threshold) {
|
|
1145
1142
|
return;
|
|
1146
1143
|
}
|
|
1147
|
-
|
|
1148
|
-
clickTarget(e);
|
|
1149
|
-
}
|
|
1150
|
-
if (sidebarMode && canvas.contains(e.target)) {
|
|
1151
|
-
changeSelection(settingsNodeAt(e.target));
|
|
1152
|
-
}
|
|
1144
|
+
clickTarget(e);
|
|
1153
1145
|
}, signal);
|
|
1154
1146
|
document.addEventListener("keydown", function(e) {
|
|
1155
1147
|
if (e.key !== "Escape" || openSettingsState || dialogState) {
|
|
@@ -1162,23 +1154,28 @@
|
|
|
1162
1154
|
if (focus && (is(focus, "input, textarea, select") || focus.isContentEditable)) {
|
|
1163
1155
|
return;
|
|
1164
1156
|
}
|
|
1165
|
-
if (
|
|
1166
|
-
changeSelection(null);
|
|
1167
|
-
} else if (activeTarget) {
|
|
1157
|
+
if (activeTarget) {
|
|
1168
1158
|
changeTarget(null);
|
|
1169
1159
|
}
|
|
1170
1160
|
}, signal);
|
|
1171
|
-
}
|
|
1172
|
-
if (sidebarMode) {
|
|
1173
1161
|
canvas.addEventListener("focusin", function(e) {
|
|
1174
1162
|
var node = isEditing() ? settingsNodeAt(e.target) : null;
|
|
1175
1163
|
if (node) {
|
|
1176
|
-
|
|
1164
|
+
changeTarget(node);
|
|
1177
1165
|
}
|
|
1178
1166
|
}, signal);
|
|
1167
|
+
var pressedOn = null;
|
|
1168
|
+
document.addEventListener("pointerdown", function(e) {
|
|
1169
|
+
pressedOn = e.target;
|
|
1170
|
+
}, { capture: true, signal: signal.signal });
|
|
1179
1171
|
document.addEventListener("click", function(e) {
|
|
1180
1172
|
var target = e.target;
|
|
1181
|
-
|
|
1173
|
+
var from = pressedOn;
|
|
1174
|
+
pressedOn = null;
|
|
1175
|
+
if (!activeTarget || !isEditing() || !target || target.nodeType !== 1) {
|
|
1176
|
+
return;
|
|
1177
|
+
}
|
|
1178
|
+
if (from && from.nodeType === 1 && (canvas.contains(from) || closest(from, EDITOR_CONTROLS))) {
|
|
1182
1179
|
return;
|
|
1183
1180
|
}
|
|
1184
1181
|
if (!attached(target) || canvas.contains(target)) {
|
|
@@ -1187,17 +1184,22 @@
|
|
|
1187
1184
|
if (closest(target, EDITOR_CONTROLS) || canvas.querySelector(".ge-rte-active")) {
|
|
1188
1185
|
return;
|
|
1189
1186
|
}
|
|
1190
|
-
|
|
1187
|
+
changeTarget(null);
|
|
1191
1188
|
}, signal);
|
|
1189
|
+
}
|
|
1190
|
+
if (panelMode() === "sidebar") {
|
|
1192
1191
|
window.addEventListener("resize", reserveSidebarRoom, signal);
|
|
1193
1192
|
}
|
|
1194
1193
|
function clickTarget(e) {
|
|
1195
|
-
|
|
1196
|
-
|
|
1194
|
+
if (!canvas.contains(e.target)) {
|
|
1195
|
+
return;
|
|
1196
|
+
}
|
|
1197
|
+
var node = settingsNodeAt(e.target);
|
|
1198
|
+
if (node && node === activeTarget && (e.target === drawerOf(node) || e.target === node && !hasClass(node, "ge-content"))) {
|
|
1197
1199
|
changeTarget(null);
|
|
1198
1200
|
return;
|
|
1199
1201
|
}
|
|
1200
|
-
changeTarget(
|
|
1202
|
+
changeTarget(node);
|
|
1201
1203
|
}
|
|
1202
1204
|
}
|
|
1203
1205
|
function textReady(block) {
|
|
@@ -1321,20 +1323,19 @@
|
|
|
1321
1323
|
btnGroup.appendChild(htmlButton);
|
|
1322
1324
|
}
|
|
1323
1325
|
var previewButton = create('<button type="button" class="btn btn-sm btn-primary gm-preview"><i class="bi bi-eye-fill"></i></button>');
|
|
1324
|
-
var endPreview = function() {
|
|
1325
|
-
if (!hasClass(previewButton, "active")) {
|
|
1326
|
-
addClass(canvas, "ge-editing");
|
|
1327
|
-
}
|
|
1328
|
-
};
|
|
1329
1326
|
previewButton.setAttribute("title", t("tool.preview"));
|
|
1327
|
+
toggleClass(previewButton, "active btn-danger", previewing);
|
|
1330
1328
|
previewButton.addEventListener("mouseenter", function() {
|
|
1331
1329
|
removeClass(canvas, "ge-editing");
|
|
1332
1330
|
});
|
|
1333
1331
|
previewButton.addEventListener("click", function() {
|
|
1334
|
-
|
|
1335
|
-
|
|
1332
|
+
setPreview(!previewing);
|
|
1333
|
+
});
|
|
1334
|
+
previewButton.addEventListener("mouseleave", function() {
|
|
1335
|
+
if (!previewing) {
|
|
1336
|
+
addClass(canvas, "ge-editing");
|
|
1337
|
+
}
|
|
1336
1338
|
});
|
|
1337
|
-
previewButton.addEventListener("mouseleave", endPreview);
|
|
1338
1339
|
btnGroup.appendChild(previewButton);
|
|
1339
1340
|
if (endItems.length) {
|
|
1340
1341
|
var end = wrapper.appendChild(element("div", { "class": "pull-right ge-toolbar-end" }));
|
|
@@ -1426,12 +1427,8 @@
|
|
|
1426
1427
|
if (!mainControls || destroyed) {
|
|
1427
1428
|
return;
|
|
1428
1429
|
}
|
|
1429
|
-
var previewing = !!one(mainControls, ".gm-preview.active");
|
|
1430
1430
|
removeMainControls();
|
|
1431
1431
|
createMainControls();
|
|
1432
|
-
if (previewing) {
|
|
1433
|
-
addClass(one(mainControls, ".gm-preview"), "active btn-danger");
|
|
1434
|
-
}
|
|
1435
1432
|
onScroll();
|
|
1436
1433
|
}
|
|
1437
1434
|
function removeMainControls() {
|
|
@@ -1687,13 +1684,11 @@
|
|
|
1687
1684
|
}
|
|
1688
1685
|
var placed = made;
|
|
1689
1686
|
if (item.inColumn) {
|
|
1690
|
-
|
|
1691
|
-
placed = inRowOfItsOwn(made);
|
|
1692
|
-
}
|
|
1687
|
+
placed = wrapFor(where.region, made);
|
|
1693
1688
|
} else if (!acceptsBlock(where.region, made)) {
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1689
|
+
where = canvasAfterTopOf(where.region);
|
|
1690
|
+
} else if (is(where.region, ".row")) {
|
|
1691
|
+
placed = wrapFor(where.region, made);
|
|
1697
1692
|
}
|
|
1698
1693
|
return addNode(item.kind, made, function() {
|
|
1699
1694
|
if (where.before) {
|
|
@@ -1703,10 +1698,32 @@
|
|
|
1703
1698
|
}
|
|
1704
1699
|
}, { parent: where.region, source: item.source || source || "dragdrop" });
|
|
1705
1700
|
}
|
|
1701
|
+
function canvasAfterTopOf(region) {
|
|
1702
|
+
var ancestors = region === canvas ? [] : parentsUntil(region, canvas).reverse().concat([region]);
|
|
1703
|
+
var top = ancestors[0] || null;
|
|
1704
|
+
return { region: canvas, before: top ? top.nextElementSibling : null };
|
|
1705
|
+
}
|
|
1706
|
+
function placeInTarget(node, kind, source) {
|
|
1707
|
+
if (!activeTarget) {
|
|
1708
|
+
return null;
|
|
1709
|
+
}
|
|
1710
|
+
var where = { region: effectiveRegion(activeTarget), before: null };
|
|
1711
|
+
var placed = wrapFor(where.region, node);
|
|
1712
|
+
var holder = placed === node ? null : node.parentElement;
|
|
1713
|
+
if (!acceptsBlock(where.region, placed) || holder && !acceptsBlock(holder, node)) {
|
|
1714
|
+
where = canvasAfterTopOf(where.region);
|
|
1715
|
+
placed = node;
|
|
1716
|
+
}
|
|
1717
|
+
return addNode(kind, node, function() {
|
|
1718
|
+
if (where.before) {
|
|
1719
|
+
where.before.parentNode.insertBefore(placed, where.before);
|
|
1720
|
+
} else {
|
|
1721
|
+
where.region.appendChild(placed);
|
|
1722
|
+
}
|
|
1723
|
+
}, { parent: where.region, source: source || "api" });
|
|
1724
|
+
}
|
|
1706
1725
|
function inRowOfItsOwn(node) {
|
|
1707
|
-
|
|
1708
|
-
row.appendChild(createColumn(MAX_COL_SIZE)).appendChild(node);
|
|
1709
|
-
return row;
|
|
1726
|
+
return rowHolding(createColumn(MAX_COL_SIZE), node);
|
|
1710
1727
|
}
|
|
1711
1728
|
function showDropMarker(pageX, pageY) {
|
|
1712
1729
|
var where = dropPlaceAt(pageX, pageY);
|
|
@@ -1735,10 +1752,7 @@
|
|
|
1735
1752
|
var container = button.getAttribute("data-ge-toolbar") === "container";
|
|
1736
1753
|
var type = button.getAttribute("data-ge-container-type");
|
|
1737
1754
|
var made = container ? CONTAINERS[type].create({}) : rowFromLayout(button.getAttribute("data-ge-layout"));
|
|
1738
|
-
var placed = made;
|
|
1739
|
-
if (container && !is(where.region, ".column")) {
|
|
1740
|
-
placed = inRowOfItsOwn(made);
|
|
1741
|
-
}
|
|
1755
|
+
var placed = wrapFor(where.region, made);
|
|
1742
1756
|
return addNode(container ? type : "row", made, function() {
|
|
1743
1757
|
if (where.before) {
|
|
1744
1758
|
where.before.parentNode.insertBefore(placed, where.before);
|
|
@@ -1983,10 +1997,24 @@
|
|
|
1983
1997
|
deinit();
|
|
1984
1998
|
init();
|
|
1985
1999
|
}
|
|
2000
|
+
function setPreview(on2) {
|
|
2001
|
+
on2 = !!on2;
|
|
2002
|
+
if (on2 === previewing) {
|
|
2003
|
+
return;
|
|
2004
|
+
}
|
|
2005
|
+
previewing = on2;
|
|
2006
|
+
var button = mainControls ? one(mainControls, ".gm-preview") : null;
|
|
2007
|
+
if (button) {
|
|
2008
|
+
toggleClass(button, "active btn-danger", on2);
|
|
2009
|
+
}
|
|
2010
|
+
toggleClass(canvas, "ge-editing", !on2);
|
|
2011
|
+
plugins("onPreviewChange", on2);
|
|
2012
|
+
emit("preview-change", { canvas, previewing: on2 });
|
|
2013
|
+
}
|
|
1986
2014
|
function openSource() {
|
|
2015
|
+
setPreview(false);
|
|
1987
2016
|
deinit();
|
|
1988
2017
|
changeTarget(null);
|
|
1989
|
-
changeSelection(null);
|
|
1990
2018
|
htmlTextArea.style.height = 0.8 * document.documentElement.clientHeight + "px";
|
|
1991
2019
|
htmlTextArea.value = canvas.innerHTML;
|
|
1992
2020
|
show(htmlTextArea);
|
|
@@ -2002,11 +2030,8 @@
|
|
|
2002
2030
|
init();
|
|
2003
2031
|
hide(htmlTextArea);
|
|
2004
2032
|
}
|
|
2005
|
-
function targetSelector() {
|
|
2006
|
-
return [".column"].concat(pluginHooks("regions")).join(", ");
|
|
2007
|
-
}
|
|
2008
2033
|
function isTarget(node) {
|
|
2009
|
-
return !!node && node !== canvas && canvas.contains(node) &&
|
|
2034
|
+
return !!node && node !== canvas && canvas.contains(node) && detailsFor.has(node);
|
|
2010
2035
|
}
|
|
2011
2036
|
function changeTarget(node) {
|
|
2012
2037
|
if (node === activeTarget) {
|
|
@@ -2014,16 +2039,63 @@
|
|
|
2014
2039
|
}
|
|
2015
2040
|
var from = activeTarget;
|
|
2016
2041
|
if (from) {
|
|
2017
|
-
removeClass(from, "ge-
|
|
2042
|
+
removeClass(from, "ge-selected");
|
|
2018
2043
|
}
|
|
2019
2044
|
activeTarget = node;
|
|
2020
2045
|
if (node && hasClass(canvas, "ge-editing")) {
|
|
2021
|
-
addClass(node, "ge-
|
|
2046
|
+
addClass(node, "ge-selected");
|
|
2022
2047
|
}
|
|
2048
|
+
renderSidebar();
|
|
2023
2049
|
emit("target-change", { canvas, target: node, from });
|
|
2024
2050
|
}
|
|
2051
|
+
function regionSelector() {
|
|
2052
|
+
return [".column"].concat(pluginHooks("regions")).join(", ");
|
|
2053
|
+
}
|
|
2054
|
+
function effectiveRegion(target) {
|
|
2055
|
+
if (is(target, ".row, " + regionSelector())) {
|
|
2056
|
+
return target;
|
|
2057
|
+
}
|
|
2058
|
+
var inside = isContainerOrPane(target) ? paneRegionOf(target) : null;
|
|
2059
|
+
return inside || closest(target.parentElement, regionSelector()) || canvas;
|
|
2060
|
+
}
|
|
2061
|
+
function isContainerOrPane(node) {
|
|
2062
|
+
if (node.getAttribute("data-ge-container")) {
|
|
2063
|
+
return true;
|
|
2064
|
+
}
|
|
2065
|
+
var container = closest(node.parentElement, "[data-ge-container]", canvas);
|
|
2066
|
+
var definition = container && CONTAINERS[containerTypeOf(container)];
|
|
2067
|
+
return !!definition && !!definition.paneKind && kindOf(node) === definition.paneKind;
|
|
2068
|
+
}
|
|
2069
|
+
function paneRegionOf(node) {
|
|
2070
|
+
var isContainer = !!node.getAttribute("data-ge-container");
|
|
2071
|
+
var container = isContainer ? node : closest(node.parentElement, "[data-ge-container]", canvas);
|
|
2072
|
+
var definition = CONTAINERS[containerTypeOf(container)];
|
|
2073
|
+
return definition && definition.regionOf ? definition.regionOf(container, isContainer ? null : node) || null : null;
|
|
2074
|
+
}
|
|
2075
|
+
function wrapFor(region, node) {
|
|
2076
|
+
if (is(node, ".column")) {
|
|
2077
|
+
return is(region, ".row") ? node : rowHolding(node);
|
|
2078
|
+
}
|
|
2079
|
+
if (is(region, ".row")) {
|
|
2080
|
+
var column = createColumn(rowColsSource(region, leadingTier()) ? null : settings.add_column.size);
|
|
2081
|
+
column.appendChild(node);
|
|
2082
|
+
return column;
|
|
2083
|
+
}
|
|
2084
|
+
if (is(region, ".column") || is(node, ".row")) {
|
|
2085
|
+
return node;
|
|
2086
|
+
}
|
|
2087
|
+
return rowHolding(createColumn(MAX_COL_SIZE), node);
|
|
2088
|
+
}
|
|
2089
|
+
function rowHolding(column, node) {
|
|
2090
|
+
var row = createRow();
|
|
2091
|
+
if (node) {
|
|
2092
|
+
column.appendChild(node);
|
|
2093
|
+
}
|
|
2094
|
+
row.appendChild(column);
|
|
2095
|
+
return row;
|
|
2096
|
+
}
|
|
2025
2097
|
function addToTarget(button, source) {
|
|
2026
|
-
var made = insertFromToolbar(button, { region: activeTarget, before: null }, source);
|
|
2098
|
+
var made = insertFromToolbar(button, { region: effectiveRegion(activeTarget), before: null }, source);
|
|
2027
2099
|
if (made && made.scrollIntoView) {
|
|
2028
2100
|
made.scrollIntoView({ behavior: "smooth" });
|
|
2029
2101
|
}
|
|
@@ -2032,14 +2104,14 @@
|
|
|
2032
2104
|
if (openSettingsState && !attached(openSettingsState.node)) {
|
|
2033
2105
|
closeSettings();
|
|
2034
2106
|
}
|
|
2035
|
-
if (
|
|
2036
|
-
|
|
2107
|
+
if (activeTarget && !canvas.contains(activeTarget)) {
|
|
2108
|
+
changeTarget(null);
|
|
2037
2109
|
}
|
|
2038
2110
|
if (dialogState && dialogState.home && !attached(dialogState.home)) {
|
|
2039
2111
|
closeDialog();
|
|
2040
2112
|
}
|
|
2041
2113
|
runFilter(true);
|
|
2042
|
-
|
|
2114
|
+
toggleClass(canvas, "ge-editing", !previewing);
|
|
2043
2115
|
toggleClass(canvas, "ge-drag-drawer", settings.drag_handle === "drawer");
|
|
2044
2116
|
addAllColClasses();
|
|
2045
2117
|
var cutter = textCutter();
|
|
@@ -2057,7 +2129,7 @@
|
|
|
2057
2129
|
if (activeTarget && !canvas.contains(activeTarget)) {
|
|
2058
2130
|
changeTarget(null);
|
|
2059
2131
|
} else if (activeTarget) {
|
|
2060
|
-
addClass(activeTarget, "ge-
|
|
2132
|
+
addClass(activeTarget, "ge-selected");
|
|
2061
2133
|
}
|
|
2062
2134
|
showSidebar();
|
|
2063
2135
|
}
|
|
@@ -2066,7 +2138,7 @@
|
|
|
2066
2138
|
hideSidebar();
|
|
2067
2139
|
removeClass(canvas, "ge-editing ge-drag-drawer ge-dropping");
|
|
2068
2140
|
if (activeTarget) {
|
|
2069
|
-
removeClass(activeTarget, "ge-
|
|
2141
|
+
removeClass(activeTarget, "ge-selected");
|
|
2070
2142
|
}
|
|
2071
2143
|
plugins("onBeforeDeinit");
|
|
2072
2144
|
closeSizePicker();
|
|
@@ -2143,8 +2215,8 @@
|
|
|
2143
2215
|
}
|
|
2144
2216
|
var copy = copyCanvas();
|
|
2145
2217
|
var root = copy.root;
|
|
2146
|
-
[root].concat(all(root, ".ge-
|
|
2147
|
-
removeClass(node, "ge-
|
|
2218
|
+
[root].concat(all(root, ".ge-selected, .ge-settings-target")).forEach(function(node) {
|
|
2219
|
+
removeClass(node, "ge-selected ge-settings-target");
|
|
2148
2220
|
dropEmptyClass(node);
|
|
2149
2221
|
});
|
|
2150
2222
|
all(root, ".ge-drop-marker").forEach(function(marker) {
|
|
@@ -2213,6 +2285,7 @@
|
|
|
2213
2285
|
});
|
|
2214
2286
|
}
|
|
2215
2287
|
}
|
|
2288
|
+
setPreview(false);
|
|
2216
2289
|
deinit();
|
|
2217
2290
|
setHtml(canvas, html);
|
|
2218
2291
|
init();
|
|
@@ -2222,9 +2295,9 @@
|
|
|
2222
2295
|
if (sourceOpen) {
|
|
2223
2296
|
closeSource();
|
|
2224
2297
|
}
|
|
2298
|
+
setPreview(false);
|
|
2225
2299
|
deinit();
|
|
2226
2300
|
activeTarget = null;
|
|
2227
|
-
selected = null;
|
|
2228
2301
|
if (sidebarHolder === instance) {
|
|
2229
2302
|
sidebarHolder = null;
|
|
2230
2303
|
}
|
|
@@ -2305,6 +2378,9 @@
|
|
|
2305
2378
|
addSettingsTool,
|
|
2306
2379
|
deleteNode,
|
|
2307
2380
|
place,
|
|
2381
|
+
// A node made, added to the active target as the toolbar adds
|
|
2382
|
+
// what it makes: null with no target, or when it was canceled
|
|
2383
|
+
placeInTarget,
|
|
2308
2384
|
createPaneControls,
|
|
2309
2385
|
makeLabelEditable,
|
|
2310
2386
|
labelIn,
|
|
@@ -2316,6 +2392,9 @@
|
|
|
2316
2392
|
operate,
|
|
2317
2393
|
kindOf,
|
|
2318
2394
|
view: getView,
|
|
2395
|
+
previewing: function() {
|
|
2396
|
+
return previewing;
|
|
2397
|
+
},
|
|
2319
2398
|
viewTiers: function() {
|
|
2320
2399
|
return tiersFor(curView).map(function(tier) {
|
|
2321
2400
|
return tier.key;
|
|
@@ -2358,22 +2437,12 @@
|
|
|
2358
2437
|
toolbarItems: function(name) {
|
|
2359
2438
|
return mainControls ? all(mainControls, '[data-ge-toolbar="feature"][data-ge-feature="' + name + '"]') : [];
|
|
2360
2439
|
},
|
|
2361
|
-
getSelected: function() {
|
|
2362
|
-
return panelMode() === "sidebar" ? selected : null;
|
|
2363
|
-
},
|
|
2364
2440
|
getActiveTarget: function() {
|
|
2365
2441
|
return settings.active_target ? activeTarget : null;
|
|
2366
2442
|
},
|
|
2367
2443
|
// True when it took: a node that cannot be, or no setting
|
|
2368
2444
|
// for it, says nothing, since a plugin putting back what it
|
|
2369
2445
|
// remembers cannot know the node is still one
|
|
2370
|
-
setSelected: function(node) {
|
|
2371
|
-
var chosen = panelMode() === "sidebar" && !!node && node !== canvas && canvas.contains(node) && detailsFor.has(node);
|
|
2372
|
-
if (chosen) {
|
|
2373
|
-
changeSelection(node);
|
|
2374
|
-
}
|
|
2375
|
-
return chosen;
|
|
2376
|
-
},
|
|
2377
2446
|
setActiveTarget: function(node) {
|
|
2378
2447
|
var chosen = !!settings.active_target && isTarget(node);
|
|
2379
2448
|
if (chosen) {
|
|
@@ -2381,7 +2450,7 @@
|
|
|
2381
2450
|
}
|
|
2382
2451
|
return chosen;
|
|
2383
2452
|
},
|
|
2384
|
-
// What keeps Escape from the
|
|
2453
|
+
// What keeps Escape from the target, and an
|
|
2385
2454
|
// inline panel unfolded in a drawer, which Escape leaves alone
|
|
2386
2455
|
panelOpen: function() {
|
|
2387
2456
|
if (openSettingsState || dialogState) {
|
|
@@ -3754,7 +3823,7 @@
|
|
|
3754
3823
|
delegate(panel, "click", ".ge-settings-close", function(e) {
|
|
3755
3824
|
e.preventDefault();
|
|
3756
3825
|
if (mode === "sidebar") {
|
|
3757
|
-
|
|
3826
|
+
changeTarget(null);
|
|
3758
3827
|
} else {
|
|
3759
3828
|
closeSettings();
|
|
3760
3829
|
}
|
|
@@ -3875,7 +3944,7 @@
|
|
|
3875
3944
|
if (!panel || !isEditing()) {
|
|
3876
3945
|
return;
|
|
3877
3946
|
}
|
|
3878
|
-
var details =
|
|
3947
|
+
var details = activeTarget ? detailsOf(activeTarget) : null;
|
|
3879
3948
|
if (details ? sidebarShown && sidebarShown.details === details : !sidebarShown && sidebarEmpty) {
|
|
3880
3949
|
return;
|
|
3881
3950
|
}
|
|
@@ -3889,11 +3958,10 @@
|
|
|
3889
3958
|
sidebarEmpty = { body };
|
|
3890
3959
|
return;
|
|
3891
3960
|
}
|
|
3892
|
-
sidebarShown = { node:
|
|
3893
|
-
setSidebarTitle(t("panel.title", { kind: kindLabel(
|
|
3961
|
+
sidebarShown = { node: activeTarget, details, home: details.parentElement, next: details.nextElementSibling };
|
|
3962
|
+
setSidebarTitle(t("panel.title", { kind: kindLabel(activeTarget) }));
|
|
3894
3963
|
holder.appendChild(details);
|
|
3895
3964
|
show(details);
|
|
3896
|
-
addClass(selected, "ge-settings-target");
|
|
3897
3965
|
}
|
|
3898
3966
|
function emptyContent() {
|
|
3899
3967
|
var fromHost = settings.sidebar.empty;
|
|
@@ -3943,15 +4011,6 @@
|
|
|
3943
4011
|
}
|
|
3944
4012
|
return null;
|
|
3945
4013
|
}
|
|
3946
|
-
function changeSelection(node) {
|
|
3947
|
-
if (node === selected) {
|
|
3948
|
-
return;
|
|
3949
|
-
}
|
|
3950
|
-
var from = selected;
|
|
3951
|
-
selected = node;
|
|
3952
|
-
renderSidebar();
|
|
3953
|
-
emit("selection-change", { canvas, node, from });
|
|
3954
|
-
}
|
|
3955
4014
|
function placePopover(panel, gear) {
|
|
3956
4015
|
if (!attached(gear)) {
|
|
3957
4016
|
return;
|
|
@@ -5061,28 +5120,11 @@
|
|
|
5061
5120
|
var node = nodeFrom(value);
|
|
5062
5121
|
if (!isTarget(node)) {
|
|
5063
5122
|
var named = typeof value === "string" ? value : node ? "<" + node.tagName.toLowerCase() + ">" : String(value);
|
|
5064
|
-
warn("setActiveTarget: " + named + " is not a
|
|
5123
|
+
warn("setActiveTarget: " + named + " is not a node of the canvas with settings");
|
|
5065
5124
|
return;
|
|
5066
5125
|
}
|
|
5067
5126
|
changeTarget(node);
|
|
5068
5127
|
}
|
|
5069
|
-
function apiSetSelected(value) {
|
|
5070
|
-
if (panelMode() !== "sidebar") {
|
|
5071
|
-
warnOnceHere("sidebar-api", 'setSelected needs settings_panel "sidebar": without it, it does nothing');
|
|
5072
|
-
return;
|
|
5073
|
-
}
|
|
5074
|
-
if (value === null || value === void 0) {
|
|
5075
|
-
changeSelection(null);
|
|
5076
|
-
return;
|
|
5077
|
-
}
|
|
5078
|
-
var node = nodeFrom(value);
|
|
5079
|
-
if (!node || node === canvas || !canvas.contains(node) || !detailsFor.has(node)) {
|
|
5080
|
-
var named = typeof value === "string" ? value : node ? "<" + node.tagName.toLowerCase() + ">" : String(value);
|
|
5081
|
-
warn("setSelected: " + named + " is not a node of the canvas with settings");
|
|
5082
|
-
return;
|
|
5083
|
-
}
|
|
5084
|
-
changeSelection(node);
|
|
5085
|
-
}
|
|
5086
5128
|
var own = {
|
|
5087
5129
|
getHtml,
|
|
5088
5130
|
getPlainHtml,
|
|
@@ -5121,11 +5163,7 @@
|
|
|
5121
5163
|
getActiveTarget: function() {
|
|
5122
5164
|
return settings.active_target ? activeTarget : null;
|
|
5123
5165
|
},
|
|
5124
|
-
setActiveTarget: apiSetActiveTarget
|
|
5125
|
-
getSelected: function() {
|
|
5126
|
-
return panelMode() === "sidebar" ? selected : null;
|
|
5127
|
-
},
|
|
5128
|
-
setSelected: apiSetSelected
|
|
5166
|
+
setActiveTarget: apiSetActiveTarget
|
|
5129
5167
|
};
|
|
5130
5168
|
Object.keys(own).forEach(function(name) {
|
|
5131
5169
|
var value = !!(METHODS[name] && METHODS[name].value);
|
|
@@ -5176,7 +5214,7 @@
|
|
|
5176
5214
|
GridEditor._plainHtml = plainHtml;
|
|
5177
5215
|
GridEditor.Sortable = null;
|
|
5178
5216
|
GridEditor.bootstrap = null;
|
|
5179
|
-
GridEditor.version = false ? "dev" : "9.0.0-beta.
|
|
5217
|
+
GridEditor.version = false ? "dev" : "9.0.0-beta.6";
|
|
5180
5218
|
GridEditor.locales = {
|
|
5181
5219
|
en: {
|
|
5182
5220
|
"tool.move": "Move",
|