@themarioga/grid-editor 8.8.2 → 8.9.0
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 +16 -0
- package/README.md +18 -0
- package/dist/grideditor.bundle.min.js +3 -3
- package/dist/grideditor.css +51 -0
- package/dist/grideditor.d.ts +28 -1
- package/dist/grideditor.esm.js +311 -20
- package/dist/grideditor.jquery.js +3 -1
- package/dist/grideditor.jquery.min.js +1 -1
- package/dist/grideditor.jquery.min.js.map +2 -2
- package/dist/grideditor.js +311 -20
- 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/locales/grideditor.es.esm.js +4 -0
- package/dist/locales/grideditor.es.js +4 -0
- package/dist/locales/grideditor.es.min.js +1 -1
- package/dist/locales/grideditor.es.min.js.map +2 -2
- package/docs/events.md +6 -0
- package/docs/locale-keys.md +4 -0
- package/docs/plugins.md +15 -1
- package/example/utilities.html +3 -1
- package/package.json +1 -1
- package/src/js/grideditor.jquery.js +2 -0
- package/src/js/grideditor.js +361 -29
- package/src/js/locales/grideditor.es.js +4 -0
- package/src/less/grideditor.less +59 -0
- package/types/grideditor.d.ts +28 -1
|
@@ -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 };\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,I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
|
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,CA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AMqB,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",
|
|
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,7 +329,9 @@
|
|
|
329
329
|
getUtility: { value: true },
|
|
330
330
|
setUtility: { value: true },
|
|
331
331
|
getActiveTarget: { value: true },
|
|
332
|
-
setActiveTarget: {}
|
|
332
|
+
setActiveTarget: {},
|
|
333
|
+
getSelected: { value: true },
|
|
334
|
+
setSelected: {}
|
|
333
335
|
};
|
|
334
336
|
var PLACEMENTS = ["appendTo", "prependTo", "insertAfter", "insertBefore"];
|
|
335
337
|
var BREAKPOINTS = [
|
|
@@ -413,6 +415,10 @@
|
|
|
413
415
|
tools: true
|
|
414
416
|
// The indent tools in the column's drawer
|
|
415
417
|
},
|
|
418
|
+
sidebar: {
|
|
419
|
+
empty: null
|
|
420
|
+
// function(ge) -> { title, body } shown while nothing is selected, or null for the message
|
|
421
|
+
},
|
|
416
422
|
drag: {
|
|
417
423
|
delay: 0,
|
|
418
424
|
// Milliseconds to hold before a drag starts
|
|
@@ -429,6 +435,8 @@
|
|
|
429
435
|
var warned = {};
|
|
430
436
|
var editorCounter = 0;
|
|
431
437
|
var instances = /* @__PURE__ */ new WeakMap();
|
|
438
|
+
var sidebarHolder = null;
|
|
439
|
+
var EDITOR_CONTROLS = ".ge-mainControls, .ge-settings-panel, .ge-sidebar-toggle, .ge-dialog, .ge-confirm, .ge-size-picker, .modal, .modal-backdrop";
|
|
432
440
|
function translate(settings, key, params) {
|
|
433
441
|
var locales = GridEditor.locales;
|
|
434
442
|
var locale = locales[settings.locale] || {};
|
|
@@ -634,7 +642,9 @@
|
|
|
634
642
|
"confirm_delete": true,
|
|
635
643
|
// Ask before deleting a row or a column
|
|
636
644
|
"settings_panel": "offcanvas",
|
|
637
|
-
// Where a node's settings open: 'offcanvas', 'popover', 'modal' or '
|
|
645
|
+
// Where a node's settings open: 'offcanvas', 'popover', 'modal', 'inline' or 'sidebar'
|
|
646
|
+
"sidebar": NESTED_SETTINGS.sidebar,
|
|
647
|
+
// The 'sidebar' panel: what it shows while nothing is selected
|
|
638
648
|
"drag": NESTED_SETTINGS.drag
|
|
639
649
|
// How a drag behaves, whatever drives it
|
|
640
650
|
}, optionsOrMethod);
|
|
@@ -660,6 +670,17 @@
|
|
|
660
670
|
var sortables = [];
|
|
661
671
|
var instanceId = ++editorCounter;
|
|
662
672
|
var destroyed = false;
|
|
673
|
+
var selected = null;
|
|
674
|
+
var sidebarCollapsed = null;
|
|
675
|
+
var pluginHandle = null;
|
|
676
|
+
if (settings.settings_panel === "sidebar") {
|
|
677
|
+
if (sidebarHolder) {
|
|
678
|
+
warnOnceHere("sidebar", 'settings_panel "sidebar" is in use by another editor on the page, which has one sidebar: using offcanvas');
|
|
679
|
+
settings.settings_panel = "offcanvas";
|
|
680
|
+
} else {
|
|
681
|
+
sidebarHolder = instance;
|
|
682
|
+
}
|
|
683
|
+
}
|
|
663
684
|
var detailsFor = /* @__PURE__ */ new WeakMap();
|
|
664
685
|
var moves = /* @__PURE__ */ new WeakMap();
|
|
665
686
|
var resizes = /* @__PURE__ */ new WeakMap();
|
|
@@ -1097,7 +1118,8 @@
|
|
|
1097
1118
|
e.preventDefault();
|
|
1098
1119
|
}
|
|
1099
1120
|
}, signal);
|
|
1100
|
-
|
|
1121
|
+
var sidebarMode = panelMode() === "sidebar";
|
|
1122
|
+
if (settings.active_target || sidebarMode) {
|
|
1101
1123
|
var pressed = null;
|
|
1102
1124
|
canvas.addEventListener("pointerdown", function(e) {
|
|
1103
1125
|
pressed = { x: e.clientX, y: e.clientY };
|
|
@@ -1111,24 +1133,61 @@
|
|
|
1111
1133
|
if (from && Math.abs(e.clientX - from.x) + Math.abs(e.clientY - from.y) > settings.drag.threshold) {
|
|
1112
1134
|
return;
|
|
1113
1135
|
}
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1136
|
+
if (settings.active_target) {
|
|
1137
|
+
clickTarget(e);
|
|
1138
|
+
}
|
|
1139
|
+
if (sidebarMode && canvas.contains(e.target)) {
|
|
1140
|
+
changeSelection(settingsNodeAt(e.target));
|
|
1118
1141
|
}
|
|
1119
|
-
changeTarget(region && region !== canvas && canvas.contains(region) ? region : null);
|
|
1120
1142
|
}, signal);
|
|
1121
1143
|
document.addEventListener("keydown", function(e) {
|
|
1122
|
-
if (e.key !== "Escape" ||
|
|
1144
|
+
if (e.key !== "Escape" || openSettingsState || dialogState) {
|
|
1145
|
+
return;
|
|
1146
|
+
}
|
|
1147
|
+
if (confirmDialog && hasClass(confirmDialog, "show")) {
|
|
1123
1148
|
return;
|
|
1124
1149
|
}
|
|
1125
1150
|
var focus = document.activeElement;
|
|
1126
1151
|
if (focus && (is(focus, "input, textarea, select") || focus.isContentEditable)) {
|
|
1127
1152
|
return;
|
|
1128
1153
|
}
|
|
1129
|
-
|
|
1154
|
+
if (selected && isEditing()) {
|
|
1155
|
+
changeSelection(null);
|
|
1156
|
+
} else if (activeTarget) {
|
|
1157
|
+
changeTarget(null);
|
|
1158
|
+
}
|
|
1130
1159
|
}, signal);
|
|
1131
1160
|
}
|
|
1161
|
+
if (sidebarMode) {
|
|
1162
|
+
canvas.addEventListener("focusin", function(e) {
|
|
1163
|
+
var node = isEditing() ? settingsNodeAt(e.target) : null;
|
|
1164
|
+
if (node) {
|
|
1165
|
+
changeSelection(node);
|
|
1166
|
+
}
|
|
1167
|
+
}, signal);
|
|
1168
|
+
document.addEventListener("click", function(e) {
|
|
1169
|
+
var target = e.target;
|
|
1170
|
+
if (!selected || !isEditing() || !target || target.nodeType !== 1) {
|
|
1171
|
+
return;
|
|
1172
|
+
}
|
|
1173
|
+
if (!attached(target) || canvas.contains(target)) {
|
|
1174
|
+
return;
|
|
1175
|
+
}
|
|
1176
|
+
if (closest(target, EDITOR_CONTROLS) || canvas.querySelector(".ge-rte-active")) {
|
|
1177
|
+
return;
|
|
1178
|
+
}
|
|
1179
|
+
changeSelection(null);
|
|
1180
|
+
}, signal);
|
|
1181
|
+
window.addEventListener("resize", reserveSidebarRoom, signal);
|
|
1182
|
+
}
|
|
1183
|
+
function clickTarget(e) {
|
|
1184
|
+
var region = closest(e.target, targetSelector());
|
|
1185
|
+
if (region && region === activeTarget && (e.target === region || e.target === child(region, ".ge-tools-drawer"))) {
|
|
1186
|
+
changeTarget(null);
|
|
1187
|
+
return;
|
|
1188
|
+
}
|
|
1189
|
+
changeTarget(region && region !== canvas && canvas.contains(region) ? region : null);
|
|
1190
|
+
}
|
|
1132
1191
|
}
|
|
1133
1192
|
function textReady(block) {
|
|
1134
1193
|
if (!is(block, ".ge-content") || !canvas.contains(block)) {
|
|
@@ -1899,6 +1958,7 @@
|
|
|
1899
1958
|
function openSource() {
|
|
1900
1959
|
deinit();
|
|
1901
1960
|
changeTarget(null);
|
|
1961
|
+
changeSelection(null);
|
|
1902
1962
|
htmlTextArea.style.height = 0.8 * document.documentElement.clientHeight + "px";
|
|
1903
1963
|
htmlTextArea.value = canvas.innerHTML;
|
|
1904
1964
|
show(htmlTextArea);
|
|
@@ -1944,6 +2004,9 @@
|
|
|
1944
2004
|
if (openSettingsState && !attached(openSettingsState.node)) {
|
|
1945
2005
|
closeSettings();
|
|
1946
2006
|
}
|
|
2007
|
+
if (selected && !canvas.contains(selected)) {
|
|
2008
|
+
changeSelection(null);
|
|
2009
|
+
}
|
|
1947
2010
|
if (dialogState && dialogState.home && !attached(dialogState.home)) {
|
|
1948
2011
|
closeDialog();
|
|
1949
2012
|
}
|
|
@@ -1968,9 +2031,11 @@
|
|
|
1968
2031
|
} else if (activeTarget) {
|
|
1969
2032
|
addClass(activeTarget, "ge-active-target");
|
|
1970
2033
|
}
|
|
2034
|
+
showSidebar();
|
|
1971
2035
|
}
|
|
1972
2036
|
function deinit() {
|
|
1973
2037
|
closeSettings();
|
|
2038
|
+
hideSidebar();
|
|
1974
2039
|
removeClass(canvas, "ge-editing ge-drag-drawer ge-dropping");
|
|
1975
2040
|
if (activeTarget) {
|
|
1976
2041
|
removeClass(activeTarget, "ge-active-target");
|
|
@@ -2131,6 +2196,10 @@
|
|
|
2131
2196
|
}
|
|
2132
2197
|
deinit();
|
|
2133
2198
|
activeTarget = null;
|
|
2199
|
+
selected = null;
|
|
2200
|
+
if (sidebarHolder === instance) {
|
|
2201
|
+
sidebarHolder = null;
|
|
2202
|
+
}
|
|
2134
2203
|
removeConfirmModal();
|
|
2135
2204
|
removeSettingsPanels();
|
|
2136
2205
|
removeDialog();
|
|
@@ -2141,7 +2210,7 @@
|
|
|
2141
2210
|
destroyed = true;
|
|
2142
2211
|
}
|
|
2143
2212
|
function loadPlugins() {
|
|
2144
|
-
var api = pluginApi();
|
|
2213
|
+
var api = pluginHandle = pluginApi();
|
|
2145
2214
|
registerFamily("grid", {}, widthFamily());
|
|
2146
2215
|
if (settings.row_cols !== false) {
|
|
2147
2216
|
registerFamily("grid", {}, rowColsFamily());
|
|
@@ -3262,9 +3331,11 @@
|
|
|
3262
3331
|
function addSettingsTool(drawer, node, presets) {
|
|
3263
3332
|
var details = createDetails(node, presets || []);
|
|
3264
3333
|
detailsFor.set(node, details);
|
|
3265
|
-
|
|
3266
|
-
|
|
3267
|
-
|
|
3334
|
+
if (panelMode() !== "sidebar") {
|
|
3335
|
+
createTool(drawer, t("tool.settings"), "ge-settings", "bi bi-gear-fill", function() {
|
|
3336
|
+
toggleSettings(node, details, this);
|
|
3337
|
+
});
|
|
3338
|
+
}
|
|
3268
3339
|
var kind = kindOf(node);
|
|
3269
3340
|
Object.keys(UTILITIES).forEach(function(name) {
|
|
3270
3341
|
if (UTILITIES[name].drawerTools) {
|
|
@@ -3355,7 +3426,7 @@
|
|
|
3355
3426
|
return;
|
|
3356
3427
|
}
|
|
3357
3428
|
var holder = element("div", { "class": "ge-panel-section", "data-ge-plugin": name });
|
|
3358
|
-
if (mode === "offcanvas" || mode === "modal") {
|
|
3429
|
+
if (mode === "offcanvas" || mode === "modal" || mode === "sidebar") {
|
|
3359
3430
|
holder.appendChild(sectionTitle(t(section.labelKey)));
|
|
3360
3431
|
holder.appendChild(section.body);
|
|
3361
3432
|
} else {
|
|
@@ -3379,7 +3450,7 @@
|
|
|
3379
3450
|
});
|
|
3380
3451
|
return sections;
|
|
3381
3452
|
}
|
|
3382
|
-
var PANEL_MODES = ["offcanvas", "popover", "modal", "inline"];
|
|
3453
|
+
var PANEL_MODES = ["offcanvas", "popover", "modal", "inline", "sidebar"];
|
|
3383
3454
|
var settingsPanels = {};
|
|
3384
3455
|
var openSettingsState = null;
|
|
3385
3456
|
var modalState = /* @__PURE__ */ new WeakMap();
|
|
@@ -3394,7 +3465,14 @@
|
|
|
3394
3465
|
return node && detailsFor.get(node) || null;
|
|
3395
3466
|
}
|
|
3396
3467
|
function settingsScope() {
|
|
3397
|
-
|
|
3468
|
+
var scope = [canvas];
|
|
3469
|
+
if (openSettingsState && openSettingsState.mode !== "inline") {
|
|
3470
|
+
scope.push(openSettingsState.details);
|
|
3471
|
+
}
|
|
3472
|
+
if (sidebarShown) {
|
|
3473
|
+
scope.push(sidebarShown.details);
|
|
3474
|
+
}
|
|
3475
|
+
return scope;
|
|
3398
3476
|
}
|
|
3399
3477
|
function toggleSettings(node, details, gear) {
|
|
3400
3478
|
var mode = panelMode();
|
|
@@ -3484,6 +3562,9 @@
|
|
|
3484
3562
|
} else {
|
|
3485
3563
|
hideModal(panel);
|
|
3486
3564
|
}
|
|
3565
|
+
returnPanel(open);
|
|
3566
|
+
}
|
|
3567
|
+
function returnPanel(open) {
|
|
3487
3568
|
removeClass(open.node, "ge-settings-target");
|
|
3488
3569
|
open.details.style.removeProperty("display");
|
|
3489
3570
|
dropEmptyStyle(open.details);
|
|
@@ -3516,6 +3597,11 @@
|
|
|
3516
3597
|
panel = create('<div class="popover bs-popover-bottom ge-settings-panel ge-settings-popover" role="dialog"><div class="popover-arrow"></div><div class="popover-header"><span class="ge-settings-title"></span></div><div class="popover-body ge-settings-body"></div></div>');
|
|
3517
3598
|
one(panel, ".popover-header").appendChild(closeButton());
|
|
3518
3599
|
hide(panel);
|
|
3600
|
+
} else if (mode === "sidebar") {
|
|
3601
|
+
panel = create('<div class="offcanvas offcanvas-end ge-settings-panel ge-settings-sidebar" tabindex="-1" role="complementary"><div class="offcanvas-header"><h5 class="offcanvas-title ge-settings-title"></h5></div><div class="offcanvas-body ge-settings-body"></div></div>');
|
|
3602
|
+
panel.id = "ge-settings-sidebar-" + instanceId;
|
|
3603
|
+
one(panel, ".offcanvas-header").appendChild(closeButton());
|
|
3604
|
+
settingsPanels["sidebar-toggle"] = document.body.appendChild(sidebarToggle(panel));
|
|
3519
3605
|
} else {
|
|
3520
3606
|
panel = create('<div class="modal fade ge-settings-panel ge-settings-modal" tabindex="-1" role="dialog" aria-hidden="true"><div class="modal-dialog modal-dialog-centered modal-dialog-scrollable"><div class="modal-content"><div class="modal-header"><h5 class="modal-title ge-settings-title"></h5></div><div class="modal-body ge-settings-body"></div><div class="modal-footer"></div></div></div></div>');
|
|
3521
3607
|
one(panel, ".modal-header").appendChild(closeButton());
|
|
@@ -3526,13 +3612,19 @@
|
|
|
3526
3612
|
}
|
|
3527
3613
|
delegate(panel, "click", ".ge-settings-close", function(e) {
|
|
3528
3614
|
e.preventDefault();
|
|
3529
|
-
|
|
3615
|
+
if (mode === "sidebar") {
|
|
3616
|
+
changeSelection(null);
|
|
3617
|
+
} else {
|
|
3618
|
+
closeSettings();
|
|
3619
|
+
}
|
|
3530
3620
|
});
|
|
3531
3621
|
settingsPanels[mode] = document.body.appendChild(panel);
|
|
3532
3622
|
return panel;
|
|
3533
3623
|
}
|
|
3534
3624
|
function removeSettingsPanels() {
|
|
3535
3625
|
closeSettings();
|
|
3626
|
+
unshowSidebar();
|
|
3627
|
+
removeClass(document.documentElement, "ge-sidebar-open");
|
|
3536
3628
|
Object.keys(settingsPanels).forEach(function(mode) {
|
|
3537
3629
|
if (mode === "modal") {
|
|
3538
3630
|
retireModal(settingsPanels[mode]);
|
|
@@ -3545,6 +3637,180 @@
|
|
|
3545
3637
|
});
|
|
3546
3638
|
settingsPanels = {};
|
|
3547
3639
|
}
|
|
3640
|
+
var SIDEBAR_MIN_WIDTH = 576;
|
|
3641
|
+
var sidebarShown = null;
|
|
3642
|
+
var sidebarEmpty = null;
|
|
3643
|
+
function isEditing() {
|
|
3644
|
+
return hasClass(canvas, "ge-editing");
|
|
3645
|
+
}
|
|
3646
|
+
function sidebarToggle(panel) {
|
|
3647
|
+
var button = element("button", { type: "button", "class": "ge-sidebar-toggle", "aria-controls": panel.id });
|
|
3648
|
+
button.appendChild(element("i"));
|
|
3649
|
+
button.addEventListener("click", function() {
|
|
3650
|
+
foldSidebar(!sidebarCollapsed);
|
|
3651
|
+
});
|
|
3652
|
+
return button;
|
|
3653
|
+
}
|
|
3654
|
+
function foldSidebar(collapsed) {
|
|
3655
|
+
sidebarCollapsed = collapsed;
|
|
3656
|
+
applySidebar();
|
|
3657
|
+
}
|
|
3658
|
+
function applySidebar() {
|
|
3659
|
+
var panel = settingsPanels.sidebar;
|
|
3660
|
+
var toggle2 = settingsPanels["sidebar-toggle"];
|
|
3661
|
+
if (!panel) {
|
|
3662
|
+
return;
|
|
3663
|
+
}
|
|
3664
|
+
var open = !sidebarCollapsed;
|
|
3665
|
+
if (open && !hasClass(panel, "show")) {
|
|
3666
|
+
removeClass(panel, "hiding");
|
|
3667
|
+
panel.getBoundingClientRect();
|
|
3668
|
+
addClass(panel, "show");
|
|
3669
|
+
} else if (!open && hasClass(panel, "show")) {
|
|
3670
|
+
removeClass(panel, "show");
|
|
3671
|
+
addClass(panel, "hiding");
|
|
3672
|
+
window.setTimeout(function() {
|
|
3673
|
+
removeClass(panel, "hiding");
|
|
3674
|
+
}, 300);
|
|
3675
|
+
}
|
|
3676
|
+
var label = open ? t("panel.collapse") : t("panel.expand");
|
|
3677
|
+
toggle2.setAttribute("aria-expanded", open ? "true" : "false");
|
|
3678
|
+
toggle2.setAttribute("aria-label", label);
|
|
3679
|
+
toggle2.setAttribute("title", label);
|
|
3680
|
+
one(toggle2, "i").className = "bi " + (open ? "bi-chevron-right" : "bi-chevron-left");
|
|
3681
|
+
reserveSidebarRoom();
|
|
3682
|
+
}
|
|
3683
|
+
function reserveSidebarRoom() {
|
|
3684
|
+
toggleClass(
|
|
3685
|
+
document.documentElement,
|
|
3686
|
+
"ge-sidebar-open",
|
|
3687
|
+
!!settingsPanels.sidebar && isEditing() && !sidebarCollapsed && window.innerWidth >= SIDEBAR_MIN_WIDTH
|
|
3688
|
+
);
|
|
3689
|
+
}
|
|
3690
|
+
function showSidebar() {
|
|
3691
|
+
if (panelMode() !== "sidebar") {
|
|
3692
|
+
return;
|
|
3693
|
+
}
|
|
3694
|
+
var panel = settingsPanel("sidebar");
|
|
3695
|
+
if (sidebarCollapsed === null) {
|
|
3696
|
+
sidebarCollapsed = window.innerWidth < SIDEBAR_MIN_WIDTH;
|
|
3697
|
+
}
|
|
3698
|
+
panel.style.removeProperty("display");
|
|
3699
|
+
settingsPanels["sidebar-toggle"].style.removeProperty("display");
|
|
3700
|
+
renderSidebar();
|
|
3701
|
+
applySidebar();
|
|
3702
|
+
}
|
|
3703
|
+
function hideSidebar() {
|
|
3704
|
+
unshowDetails();
|
|
3705
|
+
var panel = settingsPanels.sidebar;
|
|
3706
|
+
if (!panel) {
|
|
3707
|
+
return;
|
|
3708
|
+
}
|
|
3709
|
+
panel.style.display = "none";
|
|
3710
|
+
settingsPanels["sidebar-toggle"].style.display = "none";
|
|
3711
|
+
removeClass(document.documentElement, "ge-sidebar-open");
|
|
3712
|
+
}
|
|
3713
|
+
function setSidebarTitle(text) {
|
|
3714
|
+
var panel = settingsPanels.sidebar;
|
|
3715
|
+
one(panel, ".ge-settings-title").textContent = text;
|
|
3716
|
+
panel.setAttribute("aria-label", text);
|
|
3717
|
+
}
|
|
3718
|
+
function unshowDetails() {
|
|
3719
|
+
var shown = sidebarShown;
|
|
3720
|
+
sidebarShown = null;
|
|
3721
|
+
if (shown) {
|
|
3722
|
+
returnPanel(shown);
|
|
3723
|
+
}
|
|
3724
|
+
}
|
|
3725
|
+
function unshowSidebar() {
|
|
3726
|
+
unshowDetails();
|
|
3727
|
+
if (sidebarEmpty) {
|
|
3728
|
+
sidebarEmpty.body.remove();
|
|
3729
|
+
sidebarEmpty = null;
|
|
3730
|
+
}
|
|
3731
|
+
}
|
|
3732
|
+
function renderSidebar() {
|
|
3733
|
+
var panel = settingsPanels.sidebar;
|
|
3734
|
+
if (!panel || !isEditing()) {
|
|
3735
|
+
return;
|
|
3736
|
+
}
|
|
3737
|
+
var details = selected ? detailsOf(selected) : null;
|
|
3738
|
+
if (details ? sidebarShown && sidebarShown.details === details : !sidebarShown && sidebarEmpty) {
|
|
3739
|
+
return;
|
|
3740
|
+
}
|
|
3741
|
+
unshowSidebar();
|
|
3742
|
+
var holder = one(panel, ".ge-settings-body");
|
|
3743
|
+
if (!details) {
|
|
3744
|
+
var content = emptyContent();
|
|
3745
|
+
var body = content ? content.body : element("p", { "class": "ge-sidebar-empty" }, t("panel.sidebar_empty"));
|
|
3746
|
+
setSidebarTitle(content ? content.title : t("panel.sidebar_title"));
|
|
3747
|
+
holder.appendChild(body);
|
|
3748
|
+
sidebarEmpty = { body };
|
|
3749
|
+
return;
|
|
3750
|
+
}
|
|
3751
|
+
sidebarShown = { node: selected, details, home: details.parentElement, next: details.nextElementSibling };
|
|
3752
|
+
setSidebarTitle(t("panel.title", { kind: kindLabel(selected) }));
|
|
3753
|
+
holder.appendChild(details);
|
|
3754
|
+
show(details);
|
|
3755
|
+
addClass(selected, "ge-settings-target");
|
|
3756
|
+
}
|
|
3757
|
+
function emptyContent() {
|
|
3758
|
+
var fromHost = settings.sidebar.empty;
|
|
3759
|
+
var found = null;
|
|
3760
|
+
if (typeof fromHost === "function") {
|
|
3761
|
+
found = emptyContentOf(fromHost(instance), function(result) {
|
|
3762
|
+
return result.title;
|
|
3763
|
+
});
|
|
3764
|
+
} else if (fromHost !== null && fromHost !== void 0) {
|
|
3765
|
+
warnOnceHere("sidebar.empty", "sidebar.empty is a function(ge) returning { title, body }, not " + typeof fromHost + ": ignored");
|
|
3766
|
+
}
|
|
3767
|
+
[CONTAINERS, FEATURES, UTILITIES].forEach(function(registry) {
|
|
3768
|
+
Object.keys(registry).forEach(function(name) {
|
|
3769
|
+
var plugin = registry[name];
|
|
3770
|
+
if (found || !plugin.sidebarEmpty) {
|
|
3771
|
+
return;
|
|
3772
|
+
}
|
|
3773
|
+
found = emptyContentOf(plugin.sidebarEmpty(pluginHandle), function(result) {
|
|
3774
|
+
return typeof result.titleKey === "string" && result.titleKey !== "" ? t(result.titleKey) : "";
|
|
3775
|
+
});
|
|
3776
|
+
});
|
|
3777
|
+
});
|
|
3778
|
+
return found;
|
|
3779
|
+
}
|
|
3780
|
+
function emptyContentOf(result, titleOf) {
|
|
3781
|
+
if (!result || !result.body || result.body.nodeType !== 1) {
|
|
3782
|
+
return null;
|
|
3783
|
+
}
|
|
3784
|
+
var title = titleOf(result);
|
|
3785
|
+
return { title: typeof title === "string" && title !== "" ? title : t("panel.sidebar_title"), body: result.body };
|
|
3786
|
+
}
|
|
3787
|
+
function settingsNodeAt(target) {
|
|
3788
|
+
var drawer = closest(target, ".ge-tools-drawer", canvas);
|
|
3789
|
+
if (drawer) {
|
|
3790
|
+
var home = drawer.parentElement;
|
|
3791
|
+
var owner = detailsFor.has(home) ? home : children(home).filter(function(each) {
|
|
3792
|
+
return detailsFor.has(each);
|
|
3793
|
+
})[0];
|
|
3794
|
+
if (owner) {
|
|
3795
|
+
return owner;
|
|
3796
|
+
}
|
|
3797
|
+
}
|
|
3798
|
+
for (var node = target; node && node !== canvas; node = node.parentElement) {
|
|
3799
|
+
if (detailsFor.has(node)) {
|
|
3800
|
+
return node;
|
|
3801
|
+
}
|
|
3802
|
+
}
|
|
3803
|
+
return null;
|
|
3804
|
+
}
|
|
3805
|
+
function changeSelection(node) {
|
|
3806
|
+
if (node === selected) {
|
|
3807
|
+
return;
|
|
3808
|
+
}
|
|
3809
|
+
var from = selected;
|
|
3810
|
+
selected = node;
|
|
3811
|
+
renderSidebar();
|
|
3812
|
+
emit("selection-change", { canvas, node, from });
|
|
3813
|
+
}
|
|
3548
3814
|
function placePopover(panel, gear) {
|
|
3549
3815
|
if (!attached(gear)) {
|
|
3550
3816
|
return;
|
|
@@ -4659,6 +4925,23 @@
|
|
|
4659
4925
|
}
|
|
4660
4926
|
changeTarget(node);
|
|
4661
4927
|
}
|
|
4928
|
+
function apiSetSelected(value) {
|
|
4929
|
+
if (panelMode() !== "sidebar") {
|
|
4930
|
+
warnOnceHere("sidebar-api", 'setSelected needs settings_panel "sidebar": without it, it does nothing');
|
|
4931
|
+
return;
|
|
4932
|
+
}
|
|
4933
|
+
if (value === null || value === void 0) {
|
|
4934
|
+
changeSelection(null);
|
|
4935
|
+
return;
|
|
4936
|
+
}
|
|
4937
|
+
var node = nodeFrom(value);
|
|
4938
|
+
if (!node || node === canvas || !canvas.contains(node) || !detailsFor.has(node)) {
|
|
4939
|
+
var named = typeof value === "string" ? value : node ? "<" + node.tagName.toLowerCase() + ">" : String(value);
|
|
4940
|
+
warn("setSelected: " + named + " is not a node of the canvas with settings");
|
|
4941
|
+
return;
|
|
4942
|
+
}
|
|
4943
|
+
changeSelection(node);
|
|
4944
|
+
}
|
|
4662
4945
|
var own = {
|
|
4663
4946
|
getHtml,
|
|
4664
4947
|
getPlainHtml,
|
|
@@ -4697,7 +4980,11 @@
|
|
|
4697
4980
|
getActiveTarget: function() {
|
|
4698
4981
|
return settings.active_target ? activeTarget : null;
|
|
4699
4982
|
},
|
|
4700
|
-
setActiveTarget: apiSetActiveTarget
|
|
4983
|
+
setActiveTarget: apiSetActiveTarget,
|
|
4984
|
+
getSelected: function() {
|
|
4985
|
+
return panelMode() === "sidebar" ? selected : null;
|
|
4986
|
+
},
|
|
4987
|
+
setSelected: apiSetSelected
|
|
4701
4988
|
};
|
|
4702
4989
|
Object.keys(own).forEach(function(name) {
|
|
4703
4990
|
var value = !!(METHODS[name] && METHODS[name].value);
|
|
@@ -4748,7 +5035,7 @@
|
|
|
4748
5035
|
GridEditor._plainHtml = plainHtml;
|
|
4749
5036
|
GridEditor.Sortable = null;
|
|
4750
5037
|
GridEditor.bootstrap = null;
|
|
4751
|
-
GridEditor.version = false ? "dev" : "8.
|
|
5038
|
+
GridEditor.version = false ? "dev" : "8.9.0";
|
|
4752
5039
|
GridEditor.locales = {
|
|
4753
5040
|
en: {
|
|
4754
5041
|
"tool.move": "Move",
|
|
@@ -4781,6 +5068,10 @@
|
|
|
4781
5068
|
"panel.title": "{kind} settings",
|
|
4782
5069
|
"panel.close": "Close",
|
|
4783
5070
|
"panel.done": "Done",
|
|
5071
|
+
"panel.sidebar_title": "Settings",
|
|
5072
|
+
"panel.sidebar_empty": "Click an element to see its settings",
|
|
5073
|
+
"panel.collapse": "Hide settings",
|
|
5074
|
+
"panel.expand": "Show settings",
|
|
4784
5075
|
"panel.id": "Id",
|
|
4785
5076
|
"panel.classes": "Classes",
|
|
4786
5077
|
"panel.section_general": "Id and classes",
|