@themarioga/grid-editor 8.7.1 → 8.8.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 +21 -0
- package/README.md +23 -6
- package/dist/grideditor.bundle.min.js +2 -2
- package/dist/grideditor.css +32 -0
- package/dist/grideditor.d.ts +44 -1
- package/dist/grideditor.esm.js +43 -5
- package/dist/grideditor.js +43 -5
- package/dist/grideditor.min.css +1 -1
- package/dist/grideditor.min.css.map +1 -1
- package/dist/grideditor.min.js +1 -1
- package/dist/grideditor.min.js.map +3 -3
- package/dist/locales/grideditor.es.esm.js +27 -0
- package/dist/locales/grideditor.es.js +27 -0
- package/dist/locales/grideditor.es.min.js +1 -1
- package/dist/locales/grideditor.es.min.js.map +2 -2
- package/dist/plugins/grideditor.carousel.esm.js +775 -0
- package/dist/plugins/grideditor.carousel.js +780 -0
- package/dist/plugins/grideditor.carousel.min.js +1 -0
- package/dist/plugins/grideditor.carousel.min.js.map +7 -0
- package/docs/events.md +6 -3
- package/docs/locale-keys.md +29 -2
- package/docs/plugins.md +17 -14
- package/example/containers.html +44 -4
- package/package.json +1 -1
- package/src/js/grideditor.js +58 -17
- package/src/js/locales/grideditor.es.js +27 -0
- package/src/js/plugins/grideditor.carousel.js +780 -0
- package/src/less/grideditor.less +35 -0
- package/types/grideditor.d.ts +44 -1
package/dist/grideditor.d.ts
CHANGED
|
@@ -77,6 +77,40 @@ export interface CreateTabsOptions extends Placement, TabsOptions {
|
|
|
77
77
|
labels?: string[];
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
+
/**
|
|
81
|
+
* A carousel's options, which are Bootstrap's classes and attributes: arrows,
|
|
82
|
+
* indicators, fade, dark theme, autoplay and its interval, and the pause,
|
|
83
|
+
* wrap, keyboard and touch behaviours. All on or off unless said, as
|
|
84
|
+
* Bootstrap has them.
|
|
85
|
+
*/
|
|
86
|
+
export interface CarouselOptions {
|
|
87
|
+
/** Previous and next arrows. Default true. */
|
|
88
|
+
controls?: boolean;
|
|
89
|
+
/** One indicator a slide. Default true. */
|
|
90
|
+
indicators?: boolean;
|
|
91
|
+
/** Slides fade into each other instead of sliding. Default false. */
|
|
92
|
+
fade?: boolean;
|
|
93
|
+
/** `data-bs-theme="dark"`. Default false. */
|
|
94
|
+
dark?: boolean;
|
|
95
|
+
/** Autoplay: false, `'carousel'` on load, `'true'` after the first interaction. Default false. */
|
|
96
|
+
ride?: false | 'carousel' | 'true';
|
|
97
|
+
/** Milliseconds, 1000 or more, between slides; null is Bootstrap's own. Default null. */
|
|
98
|
+
interval?: number | null;
|
|
99
|
+
/** Pauses while the pointer is over it. Default true. */
|
|
100
|
+
pause?: boolean;
|
|
101
|
+
/** Goes from the last slide to the first. Default true. */
|
|
102
|
+
wrap?: boolean;
|
|
103
|
+
/** Answers the arrow keys. Default true. */
|
|
104
|
+
keyboard?: boolean;
|
|
105
|
+
/** Answers a swipe. Default true. */
|
|
106
|
+
touch?: boolean;
|
|
107
|
+
/** How many slides a new one has, 1 or more. Default 2. */
|
|
108
|
+
slides?: number;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/** createContainer('carousel', …): the options, and how many slides. */
|
|
112
|
+
export interface CreateCarouselOptions extends Placement, CarouselOptions {}
|
|
113
|
+
|
|
80
114
|
/** The inline-style plugin's settings. */
|
|
81
115
|
export interface InlineStyleOptions {
|
|
82
116
|
/** Every section is on unless it is turned off here. */
|
|
@@ -104,6 +138,8 @@ export interface GridEditorOptions {
|
|
|
104
138
|
container_tools?: HostTool[];
|
|
105
139
|
tab_tools?: HostTool[];
|
|
106
140
|
accordion_tools?: HostTool[];
|
|
141
|
+
/** Host tools on carousel slide drawers. */
|
|
142
|
+
carousel_tools?: HostTool[];
|
|
107
143
|
text_tools?: HostTool[];
|
|
108
144
|
drag_handle?: 'tool' | 'drawer';
|
|
109
145
|
toolbar_drag?: 'auto' | boolean;
|
|
@@ -125,6 +161,8 @@ export interface GridEditorOptions {
|
|
|
125
161
|
inline_style?: InlineStyleOptions;
|
|
126
162
|
/** The tabs plugin: the variant of the tabs containers made new. */
|
|
127
163
|
tabs?: TabsOptions;
|
|
164
|
+
/** The carousel plugin: the options of the carousels made new. */
|
|
165
|
+
carousel?: CarouselOptions;
|
|
128
166
|
elements?: { enabled?: boolean | 'auto'; selector?: string; auto?: boolean; types?: ElementType[] };
|
|
129
167
|
/** The autosave plugin: what is edited, kept in the browser's storage as it changes. */
|
|
130
168
|
autosave?: AutosaveOptions;
|
|
@@ -211,7 +249,7 @@ export interface Cleared {
|
|
|
211
249
|
|
|
212
250
|
/** What every notification carries. */
|
|
213
251
|
export interface Payload {
|
|
214
|
-
/** What the node is: row, column, text, plain, element, tab, accordion-item, a container's type… */
|
|
252
|
+
/** What the node is: row, column, text, plain, element, tab, accordion-item, carousel-item, a container's type… */
|
|
215
253
|
kind: string;
|
|
216
254
|
node: HTMLElement;
|
|
217
255
|
/** Where the node is going, or coming from on a delete; null while it is detached. */
|
|
@@ -297,6 +335,8 @@ export interface GridEditorEventMap {
|
|
|
297
335
|
'grideditor:after-add-tab': Payload;
|
|
298
336
|
'grideditor:before-add-accordion-item': Payload;
|
|
299
337
|
'grideditor:after-add-accordion-item': Payload;
|
|
338
|
+
'grideditor:before-add-carousel-item': Payload;
|
|
339
|
+
'grideditor:after-add-carousel-item': Payload;
|
|
300
340
|
'grideditor:before-add-section': Payload;
|
|
301
341
|
'grideditor:after-add-section': Payload;
|
|
302
342
|
'grideditor:before-delete': Payload;
|
|
@@ -437,9 +477,12 @@ export declare class GridEditor {
|
|
|
437
477
|
createElement(content: string | Node | ArrayLike<Node>, options?: CreateElementOptions): HTMLElement | null;
|
|
438
478
|
createSection(options?: CreateSectionOptions): HTMLElement | null;
|
|
439
479
|
createContainer(type: 'tabs', options?: CreateTabsOptions): HTMLElement | null;
|
|
480
|
+
createContainer(type: 'carousel', options?: CreateCarouselOptions): HTMLElement | null;
|
|
440
481
|
createContainer(type: string, options?: Placement & Record<string, unknown>): HTMLElement | null;
|
|
441
482
|
addTab(container: Target, options?: PaneOptions): HTMLElement | null;
|
|
442
483
|
addAccordionItem(container: Target, options?: PaneOptions): HTMLElement | null;
|
|
484
|
+
/** A pane added to a container of any type that has panes; a carousel's takes `interval`. Null for one that has none. */
|
|
485
|
+
addPane(container: Target, options?: PaneOptions & { interval?: number }): HTMLElement | null;
|
|
443
486
|
/** A utility's value on a node in a view (the current one by default), or null. */
|
|
444
487
|
getUtility(node: Target, family: string, view?: View): string | null;
|
|
445
488
|
/** Write one through the events; null is inherit. False when canceled or nothing changed. */
|
package/dist/grideditor.esm.js
CHANGED
|
@@ -323,6 +323,7 @@ var METHODS = {
|
|
|
323
323
|
createContainer: { value: true },
|
|
324
324
|
addTab: { value: true },
|
|
325
325
|
addAccordionItem: { value: true },
|
|
326
|
+
addPane: { value: true },
|
|
326
327
|
setLocale: {},
|
|
327
328
|
getUtility: { value: true },
|
|
328
329
|
setUtility: { value: true },
|
|
@@ -1032,6 +1033,16 @@ function build(instance, baseElem, optionsOrMethod) {
|
|
|
1032
1033
|
if (node.getAttribute("data-ge-container")) {
|
|
1033
1034
|
return node.getAttribute("data-ge-container");
|
|
1034
1035
|
}
|
|
1036
|
+
var paneKind = null;
|
|
1037
|
+
Object.keys(CONTAINERS).forEach(function(type) {
|
|
1038
|
+
var definition = CONTAINERS[type];
|
|
1039
|
+
if (!paneKind && definition.paneClass && hasClass(node, definition.paneClass)) {
|
|
1040
|
+
paneKind = definition.paneKind;
|
|
1041
|
+
}
|
|
1042
|
+
});
|
|
1043
|
+
if (paneKind) {
|
|
1044
|
+
return paneKind;
|
|
1045
|
+
}
|
|
1035
1046
|
if (hasClass(node, "ge-tab")) {
|
|
1036
1047
|
return "tab";
|
|
1037
1048
|
}
|
|
@@ -2794,6 +2805,9 @@ function build(instance, baseElem, optionsOrMethod) {
|
|
|
2794
2805
|
if (definition.addPane) {
|
|
2795
2806
|
createTool(drawer, t(definition.addPaneKey), "ge-add-pane", "bi bi-plus-circle", function() {
|
|
2796
2807
|
var pane = definition.addPane(container, {});
|
|
2808
|
+
if (!pane) {
|
|
2809
|
+
return;
|
|
2810
|
+
}
|
|
2797
2811
|
addNode(definition.paneKind, pane, function() {
|
|
2798
2812
|
}, {
|
|
2799
2813
|
parent: container,
|
|
@@ -2815,12 +2829,15 @@ function build(instance, baseElem, optionsOrMethod) {
|
|
|
2815
2829
|
});
|
|
2816
2830
|
return drawer;
|
|
2817
2831
|
}
|
|
2832
|
+
var TOGGLE_ATTRIBUTES = ["toggle", "dismiss", "slide", "slide-to", "ride"];
|
|
2818
2833
|
function suspendToggles(scope) {
|
|
2819
2834
|
if (!scope) {
|
|
2820
2835
|
return;
|
|
2821
2836
|
}
|
|
2822
|
-
selfAndAll(scope,
|
|
2823
|
-
["
|
|
2837
|
+
selfAndAll(scope, TOGGLE_ATTRIBUTES.map(function(name) {
|
|
2838
|
+
return "[data-bs-" + name + "]";
|
|
2839
|
+
}).join(", ")).forEach(function(node) {
|
|
2840
|
+
TOGGLE_ATTRIBUTES.forEach(function(name) {
|
|
2824
2841
|
var value = node.getAttribute("data-bs-" + name);
|
|
2825
2842
|
if (value === null) {
|
|
2826
2843
|
return;
|
|
@@ -2834,8 +2851,10 @@ function build(instance, baseElem, optionsOrMethod) {
|
|
|
2834
2851
|
if (!scope) {
|
|
2835
2852
|
return;
|
|
2836
2853
|
}
|
|
2837
|
-
selfAndAll(scope,
|
|
2838
|
-
["
|
|
2854
|
+
selfAndAll(scope, TOGGLE_ATTRIBUTES.map(function(name) {
|
|
2855
|
+
return "[data-ge-bs-" + name + "]";
|
|
2856
|
+
}).join(", ")).forEach(function(node) {
|
|
2857
|
+
TOGGLE_ATTRIBUTES.forEach(function(name) {
|
|
2839
2858
|
var value = node.getAttribute("data-ge-bs-" + name);
|
|
2840
2859
|
if (value === null) {
|
|
2841
2860
|
return;
|
|
@@ -3723,6 +3742,12 @@ function build(instance, baseElem, optionsOrMethod) {
|
|
|
3723
3742
|
if (CONTAINERS[kind] && CONTAINERS[kind].labelKey) {
|
|
3724
3743
|
return t(CONTAINERS[kind].labelKey);
|
|
3725
3744
|
}
|
|
3745
|
+
var paneLabel = Object.keys(CONTAINERS).filter(function(type) {
|
|
3746
|
+
return CONTAINERS[type].paneKind === kind && CONTAINERS[type].paneLabelKey;
|
|
3747
|
+
})[0];
|
|
3748
|
+
if (paneLabel) {
|
|
3749
|
+
return t(CONTAINERS[paneLabel].paneLabelKey);
|
|
3750
|
+
}
|
|
3726
3751
|
switch (kind) {
|
|
3727
3752
|
case "row":
|
|
3728
3753
|
return t("panel.kind_row");
|
|
@@ -4356,6 +4381,9 @@ function build(instance, baseElem, optionsOrMethod) {
|
|
|
4356
4381
|
return null;
|
|
4357
4382
|
}
|
|
4358
4383
|
var pane = definition.addPane(container, options);
|
|
4384
|
+
if (!pane) {
|
|
4385
|
+
return null;
|
|
4386
|
+
}
|
|
4359
4387
|
return addNode(definition.paneKind, pane, function() {
|
|
4360
4388
|
}, {
|
|
4361
4389
|
parent: container,
|
|
@@ -4363,6 +4391,15 @@ function build(instance, baseElem, optionsOrMethod) {
|
|
|
4363
4391
|
container
|
|
4364
4392
|
});
|
|
4365
4393
|
}
|
|
4394
|
+
function apiAddPane(container, options) {
|
|
4395
|
+
container = nodeFrom(container);
|
|
4396
|
+
var type = containerTypeOf(container);
|
|
4397
|
+
if (!CONTAINERS[type] || !CONTAINERS[type].addPane) {
|
|
4398
|
+
warn("addPane: this is not a container with panes");
|
|
4399
|
+
return null;
|
|
4400
|
+
}
|
|
4401
|
+
return addPaneTo(container, type, options);
|
|
4402
|
+
}
|
|
4366
4403
|
function settingsCopy() {
|
|
4367
4404
|
var copy = {};
|
|
4368
4405
|
Object.keys(settings).forEach(function(key) {
|
|
@@ -4652,6 +4689,7 @@ function build(instance, baseElem, optionsOrMethod) {
|
|
|
4652
4689
|
addAccordionItem: function(container, options) {
|
|
4653
4690
|
return addPaneTo(container, "accordion", options);
|
|
4654
4691
|
},
|
|
4692
|
+
addPane: apiAddPane,
|
|
4655
4693
|
setLocale,
|
|
4656
4694
|
getUtility,
|
|
4657
4695
|
setUtility,
|
|
@@ -4709,7 +4747,7 @@ GridEditor.t = translate;
|
|
|
4709
4747
|
GridEditor._plainHtml = plainHtml;
|
|
4710
4748
|
GridEditor.Sortable = null;
|
|
4711
4749
|
GridEditor.bootstrap = null;
|
|
4712
|
-
GridEditor.version = false ? "dev" : "8.
|
|
4750
|
+
GridEditor.version = false ? "dev" : "8.8.0";
|
|
4713
4751
|
GridEditor.locales = {
|
|
4714
4752
|
en: {
|
|
4715
4753
|
"tool.move": "Move",
|
package/dist/grideditor.js
CHANGED
|
@@ -324,6 +324,7 @@
|
|
|
324
324
|
createContainer: { value: true },
|
|
325
325
|
addTab: { value: true },
|
|
326
326
|
addAccordionItem: { value: true },
|
|
327
|
+
addPane: { value: true },
|
|
327
328
|
setLocale: {},
|
|
328
329
|
getUtility: { value: true },
|
|
329
330
|
setUtility: { value: true },
|
|
@@ -1033,6 +1034,16 @@
|
|
|
1033
1034
|
if (node.getAttribute("data-ge-container")) {
|
|
1034
1035
|
return node.getAttribute("data-ge-container");
|
|
1035
1036
|
}
|
|
1037
|
+
var paneKind = null;
|
|
1038
|
+
Object.keys(CONTAINERS).forEach(function(type) {
|
|
1039
|
+
var definition = CONTAINERS[type];
|
|
1040
|
+
if (!paneKind && definition.paneClass && hasClass(node, definition.paneClass)) {
|
|
1041
|
+
paneKind = definition.paneKind;
|
|
1042
|
+
}
|
|
1043
|
+
});
|
|
1044
|
+
if (paneKind) {
|
|
1045
|
+
return paneKind;
|
|
1046
|
+
}
|
|
1036
1047
|
if (hasClass(node, "ge-tab")) {
|
|
1037
1048
|
return "tab";
|
|
1038
1049
|
}
|
|
@@ -2795,6 +2806,9 @@
|
|
|
2795
2806
|
if (definition.addPane) {
|
|
2796
2807
|
createTool(drawer, t(definition.addPaneKey), "ge-add-pane", "bi bi-plus-circle", function() {
|
|
2797
2808
|
var pane = definition.addPane(container, {});
|
|
2809
|
+
if (!pane) {
|
|
2810
|
+
return;
|
|
2811
|
+
}
|
|
2798
2812
|
addNode(definition.paneKind, pane, function() {
|
|
2799
2813
|
}, {
|
|
2800
2814
|
parent: container,
|
|
@@ -2816,12 +2830,15 @@
|
|
|
2816
2830
|
});
|
|
2817
2831
|
return drawer;
|
|
2818
2832
|
}
|
|
2833
|
+
var TOGGLE_ATTRIBUTES = ["toggle", "dismiss", "slide", "slide-to", "ride"];
|
|
2819
2834
|
function suspendToggles(scope) {
|
|
2820
2835
|
if (!scope) {
|
|
2821
2836
|
return;
|
|
2822
2837
|
}
|
|
2823
|
-
selfAndAll(scope,
|
|
2824
|
-
["
|
|
2838
|
+
selfAndAll(scope, TOGGLE_ATTRIBUTES.map(function(name) {
|
|
2839
|
+
return "[data-bs-" + name + "]";
|
|
2840
|
+
}).join(", ")).forEach(function(node) {
|
|
2841
|
+
TOGGLE_ATTRIBUTES.forEach(function(name) {
|
|
2825
2842
|
var value = node.getAttribute("data-bs-" + name);
|
|
2826
2843
|
if (value === null) {
|
|
2827
2844
|
return;
|
|
@@ -2835,8 +2852,10 @@
|
|
|
2835
2852
|
if (!scope) {
|
|
2836
2853
|
return;
|
|
2837
2854
|
}
|
|
2838
|
-
selfAndAll(scope,
|
|
2839
|
-
["
|
|
2855
|
+
selfAndAll(scope, TOGGLE_ATTRIBUTES.map(function(name) {
|
|
2856
|
+
return "[data-ge-bs-" + name + "]";
|
|
2857
|
+
}).join(", ")).forEach(function(node) {
|
|
2858
|
+
TOGGLE_ATTRIBUTES.forEach(function(name) {
|
|
2840
2859
|
var value = node.getAttribute("data-ge-bs-" + name);
|
|
2841
2860
|
if (value === null) {
|
|
2842
2861
|
return;
|
|
@@ -3724,6 +3743,12 @@
|
|
|
3724
3743
|
if (CONTAINERS[kind] && CONTAINERS[kind].labelKey) {
|
|
3725
3744
|
return t(CONTAINERS[kind].labelKey);
|
|
3726
3745
|
}
|
|
3746
|
+
var paneLabel = Object.keys(CONTAINERS).filter(function(type) {
|
|
3747
|
+
return CONTAINERS[type].paneKind === kind && CONTAINERS[type].paneLabelKey;
|
|
3748
|
+
})[0];
|
|
3749
|
+
if (paneLabel) {
|
|
3750
|
+
return t(CONTAINERS[paneLabel].paneLabelKey);
|
|
3751
|
+
}
|
|
3727
3752
|
switch (kind) {
|
|
3728
3753
|
case "row":
|
|
3729
3754
|
return t("panel.kind_row");
|
|
@@ -4357,6 +4382,9 @@
|
|
|
4357
4382
|
return null;
|
|
4358
4383
|
}
|
|
4359
4384
|
var pane = definition.addPane(container, options);
|
|
4385
|
+
if (!pane) {
|
|
4386
|
+
return null;
|
|
4387
|
+
}
|
|
4360
4388
|
return addNode(definition.paneKind, pane, function() {
|
|
4361
4389
|
}, {
|
|
4362
4390
|
parent: container,
|
|
@@ -4364,6 +4392,15 @@
|
|
|
4364
4392
|
container
|
|
4365
4393
|
});
|
|
4366
4394
|
}
|
|
4395
|
+
function apiAddPane(container, options) {
|
|
4396
|
+
container = nodeFrom(container);
|
|
4397
|
+
var type = containerTypeOf(container);
|
|
4398
|
+
if (!CONTAINERS[type] || !CONTAINERS[type].addPane) {
|
|
4399
|
+
warn("addPane: this is not a container with panes");
|
|
4400
|
+
return null;
|
|
4401
|
+
}
|
|
4402
|
+
return addPaneTo(container, type, options);
|
|
4403
|
+
}
|
|
4367
4404
|
function settingsCopy() {
|
|
4368
4405
|
var copy = {};
|
|
4369
4406
|
Object.keys(settings).forEach(function(key) {
|
|
@@ -4653,6 +4690,7 @@
|
|
|
4653
4690
|
addAccordionItem: function(container, options) {
|
|
4654
4691
|
return addPaneTo(container, "accordion", options);
|
|
4655
4692
|
},
|
|
4693
|
+
addPane: apiAddPane,
|
|
4656
4694
|
setLocale,
|
|
4657
4695
|
getUtility,
|
|
4658
4696
|
setUtility,
|
|
@@ -4710,7 +4748,7 @@
|
|
|
4710
4748
|
GridEditor._plainHtml = plainHtml;
|
|
4711
4749
|
GridEditor.Sortable = null;
|
|
4712
4750
|
GridEditor.bootstrap = null;
|
|
4713
|
-
GridEditor.version = false ? "dev" : "8.
|
|
4751
|
+
GridEditor.version = false ? "dev" : "8.8.0";
|
|
4714
4752
|
GridEditor.locales = {
|
|
4715
4753
|
en: {
|
|
4716
4754
|
"tool.move": "Move",
|