@themarioga/grid-editor 9.0.0-beta.5 → 9.0.0-beta.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +57 -0
- package/README.md +43 -24
- package/UPGRADING.md +24 -5
- package/dist/grideditor.bundle.min.js +3 -3
- package/dist/grideditor.css +5 -4
- package/dist/grideditor.d.ts +13 -20
- package/dist/grideditor.esm.js +174 -104
- 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 +174 -104
- 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 +1 -0
- package/dist/locales/grideditor.es.js +1 -0
- package/dist/locales/grideditor.es.min.js +1 -1
- package/dist/locales/grideditor.es.min.js.map +2 -2
- package/dist/plugins/grideditor.accordion.esm.js +16 -0
- package/dist/plugins/grideditor.accordion.js +16 -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 +7 -0
- package/dist/plugins/grideditor.carousel.js +7 -0
- package/dist/plugins/grideditor.carousel.min.js +1 -1
- package/dist/plugins/grideditor.carousel.min.js.map +3 -3
- package/dist/plugins/grideditor.ckeditor.esm.js +9 -0
- package/dist/plugins/grideditor.ckeditor.js +9 -0
- package/dist/plugins/grideditor.ckeditor.min.js +1 -1
- package/dist/plugins/grideditor.ckeditor.min.js.map +3 -3
- package/dist/plugins/grideditor.clipboard.esm.js +47 -25
- package/dist/plugins/grideditor.clipboard.js +47 -25
- package/dist/plugins/grideditor.clipboard.min.js +1 -1
- package/dist/plugins/grideditor.clipboard.min.js.map +3 -3
- package/dist/plugins/grideditor.codemirror-inline.min.js.map +1 -1
- package/dist/plugins/grideditor.codemirror.min.js.map +1 -1
- package/dist/plugins/grideditor.elements.esm.js +3 -0
- package/dist/plugins/grideditor.elements.js +3 -0
- package/dist/plugins/grideditor.elements.min.js +1 -1
- package/dist/plugins/grideditor.elements.min.js.map +3 -3
- package/dist/plugins/grideditor.gutters.min.js.map +1 -1
- package/dist/plugins/grideditor.history.esm.js +2 -7
- package/dist/plugins/grideditor.history.js +2 -7
- package/dist/plugins/grideditor.history.min.js +1 -1
- package/dist/plugins/grideditor.history.min.js.map +3 -3
- package/dist/plugins/grideditor.inline-style.min.js.map +1 -1
- package/dist/plugins/grideditor.offcanvas.esm.js +4 -0
- package/dist/plugins/grideditor.offcanvas.js +4 -0
- package/dist/plugins/grideditor.offcanvas.min.js +1 -1
- package/dist/plugins/grideditor.offcanvas.min.js.map +3 -3
- package/dist/plugins/grideditor.order.min.js +1 -1
- package/dist/plugins/grideditor.order.min.js.map +1 -1
- package/dist/plugins/grideditor.popup.esm.js +4 -0
- package/dist/plugins/grideditor.popup.js +4 -0
- package/dist/plugins/grideditor.popup.min.js +1 -1
- package/dist/plugins/grideditor.popup.min.js.map +3 -3
- package/dist/plugins/grideditor.sections.esm.js +9 -0
- package/dist/plugins/grideditor.sections.js +9 -0
- package/dist/plugins/grideditor.sections.min.js +1 -1
- package/dist/plugins/grideditor.sections.min.js.map +3 -3
- package/dist/plugins/grideditor.summernote.esm.js +9 -0
- package/dist/plugins/grideditor.summernote.js +9 -0
- package/dist/plugins/grideditor.summernote.min.js +1 -1
- package/dist/plugins/grideditor.summernote.min.js.map +3 -3
- package/dist/plugins/grideditor.tabs.esm.js +7 -0
- package/dist/plugins/grideditor.tabs.js +7 -0
- package/dist/plugins/grideditor.tabs.min.js +1 -1
- package/dist/plugins/grideditor.tabs.min.js.map +3 -3
- package/dist/plugins/grideditor.tinymce.esm.js +9 -0
- package/dist/plugins/grideditor.tinymce.js +9 -0
- package/dist/plugins/grideditor.tinymce.min.js +1 -1
- package/dist/plugins/grideditor.tinymce.min.js.map +3 -3
- package/docs/events.md +14 -12
- package/docs/locale-keys.md +1 -0
- package/docs/plugins.md +11 -8
- package/example/clipboard.html +20 -14
- package/package.json +1 -1
- package/src/js/dom.js +6 -0
- package/src/js/grideditor.jquery.js +0 -2
- package/src/js/grideditor.js +233 -114
- package/src/js/locales/grideditor.es.js +1 -0
- 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 +70 -33
- package/src/js/plugins/grideditor.history.js +6 -9
- package/src/js/plugins/grideditor.offcanvas.js +5 -0
- package/src/js/plugins/grideditor.popup.js +5 -0
- package/src/js/plugins/grideditor.tabs.js +5 -0
- package/src/less/grideditor.less +5 -4
- package/types/grideditor.d.ts +13 -20
package/dist/grideditor.css
CHANGED
|
@@ -586,13 +586,14 @@ html.ge-sidebar-open {
|
|
|
586
586
|
outline: 2px solid var(--bs-primary, #0d6efd);
|
|
587
587
|
outline-offset: 1px;
|
|
588
588
|
}
|
|
589
|
-
/*
|
|
590
|
-
shows
|
|
591
|
-
|
|
589
|
+
/* The target, with active_target: where the toolbar's buttons add and what
|
|
590
|
+
the sidebar shows. A node that also has its panel open shows both: this
|
|
591
|
+
one a little further out */
|
|
592
|
+
.ge-canvas.ge-editing .ge-selected {
|
|
592
593
|
outline: 2px dashed var(--bs-success, #198754);
|
|
593
594
|
outline-offset: -2px;
|
|
594
595
|
}
|
|
595
|
-
.ge-canvas.ge-editing .ge-
|
|
596
|
+
.ge-canvas.ge-editing .ge-selected.ge-settings-target {
|
|
596
597
|
box-shadow: 0 0 0 4px var(--bs-success, #198754);
|
|
597
598
|
}
|
|
598
599
|
/* While editing */
|
package/dist/grideditor.d.ts
CHANGED
|
@@ -190,7 +190,7 @@ export interface GridEditorOptions {
|
|
|
190
190
|
drawer_overflow?: 'menu' | 'wrap';
|
|
191
191
|
/** The add buttons in categories - rows, content, and a plugin's own - one shown at a time, chosen with tabs. Default false. */
|
|
192
192
|
toolbar_groups?: boolean;
|
|
193
|
-
/** A click
|
|
193
|
+
/** A click on any node with settings - a row, a column, a container, a text - makes it the target: where the toolbar's buttons add, and what the sidebar shows. Default false, and true with settings_panel 'sidebar', which throws if it is given false. */
|
|
194
194
|
active_target?: boolean;
|
|
195
195
|
/** The plugins to use, of any kind; null is every one loaded. */
|
|
196
196
|
plugins?: string[] | null;
|
|
@@ -209,7 +209,7 @@ export interface GridEditorOptions {
|
|
|
209
209
|
elements?: { enabled?: boolean | 'auto'; selector?: string; auto?: boolean; types?: ElementType[] };
|
|
210
210
|
/** The autosave plugin: what is edited, kept in the browser's storage as it changes. */
|
|
211
211
|
autosave?: AutosaveOptions;
|
|
212
|
-
/** The clipboard plugin. `shortcuts`: Ctrl+C and Ctrl+V on the
|
|
212
|
+
/** The clipboard plugin. `shortcuts`: Ctrl+C and Ctrl+V on the active target; default active_target. */
|
|
213
213
|
clipboard?: { shortcuts?: boolean };
|
|
214
214
|
/** The history plugin: undo and redo. */
|
|
215
215
|
history?: HistoryOptions;
|
|
@@ -230,7 +230,7 @@ export interface GridEditorOptions {
|
|
|
230
230
|
locale_strings?: Record<string, string>;
|
|
231
231
|
callbacks?: Partial<GridEditorCallbacks>;
|
|
232
232
|
confirm_delete?: boolean;
|
|
233
|
-
/** Where a node's settings open. 'sidebar' is a panel that stays on the right while editing, showing the
|
|
233
|
+
/** Where a node's settings open. 'sidebar' is a panel that stays on the right while editing, showing the active target's; one editor per page has it. It turns active_target on, and the constructor throws a TypeError if active_target is false. */
|
|
234
234
|
settings_panel?: 'offcanvas' | 'popover' | 'modal' | 'inline' | 'sidebar';
|
|
235
235
|
/** The 'sidebar' panel. */
|
|
236
236
|
sidebar?: SidebarSettings;
|
|
@@ -331,11 +331,16 @@ export interface Payload {
|
|
|
331
331
|
parent: HTMLElement | null;
|
|
332
332
|
canvas: HTMLElement;
|
|
333
333
|
breakpoint: View;
|
|
334
|
-
source: 'api' | 'tool' | 'dragdrop' | 'paste' | 'panel' | 'shortcut' | string;
|
|
334
|
+
source: 'api' | 'tool' | 'dragdrop' | 'paste' | 'cut' | 'panel' | 'shortcut' | string;
|
|
335
335
|
/** A pane inside a container. */
|
|
336
336
|
container?: HTMLElement;
|
|
337
337
|
}
|
|
338
338
|
|
|
339
|
+
/** A node was copied, or cut: with the clipboard plugin, `source` is 'tool' or 'shortcut', and `cut` says whether the node is leaving. */
|
|
340
|
+
export interface CopyPayload extends Payload {
|
|
341
|
+
cut: boolean;
|
|
342
|
+
}
|
|
343
|
+
|
|
339
344
|
export interface MovePayload extends Payload {
|
|
340
345
|
from: Position;
|
|
341
346
|
to?: Position;
|
|
@@ -389,7 +394,7 @@ export interface ViewChangePayload {
|
|
|
389
394
|
to: View;
|
|
390
395
|
}
|
|
391
396
|
|
|
392
|
-
/** The active target changed: the
|
|
397
|
+
/** The active target changed: the node the toolbar adds to and the sidebar shows - any with settings - or null for the canvas. */
|
|
393
398
|
export interface TargetChangePayload {
|
|
394
399
|
canvas: HTMLElement;
|
|
395
400
|
target: HTMLElement | null;
|
|
@@ -402,13 +407,6 @@ export interface PreviewChangePayload {
|
|
|
402
407
|
previewing: boolean;
|
|
403
408
|
}
|
|
404
409
|
|
|
405
|
-
/** The selection changed, with settings_panel 'sidebar': the node whose settings the sidebar shows, or null. */
|
|
406
|
-
export interface SelectionChangePayload {
|
|
407
|
-
canvas: HTMLElement;
|
|
408
|
-
node: HTMLElement | null;
|
|
409
|
-
from: HTMLElement | null;
|
|
410
|
-
}
|
|
411
|
-
|
|
412
410
|
/** The events, by name, with their payloads. Adding fires a specific name and the generic one. */
|
|
413
411
|
export interface GridEditorEventMap {
|
|
414
412
|
'grideditor:before-add': Payload;
|
|
@@ -445,13 +443,12 @@ export interface GridEditorEventMap {
|
|
|
445
443
|
'grideditor:after-convert': ConvertPayload;
|
|
446
444
|
'grideditor:before-edit-html': EditHtmlPayload;
|
|
447
445
|
'grideditor:after-edit-html': EditHtmlPayload;
|
|
448
|
-
'grideditor:after-copy':
|
|
446
|
+
'grideditor:after-copy': CopyPayload;
|
|
449
447
|
'grideditor:popup-orphan': PopupOrphanPayload;
|
|
450
448
|
'grideditor:offcanvas-orphan': OffcanvasOrphanPayload;
|
|
451
449
|
'grideditor:view-change': ViewChangePayload;
|
|
452
450
|
'grideditor:preview-change': PreviewChangePayload;
|
|
453
451
|
'grideditor:target-change': TargetChangePayload;
|
|
454
|
-
'grideditor:selection-change': SelectionChangePayload;
|
|
455
452
|
'grideditor:after-autosave': AutosavePayload;
|
|
456
453
|
'grideditor:after-restore-draft': RestoreDraftPayload;
|
|
457
454
|
'grideditor:autosave-error': AutosaveErrorPayload;
|
|
@@ -562,14 +559,10 @@ export declare class GridEditor {
|
|
|
562
559
|
/** Take the editor off: the markup stays, everything else goes. */
|
|
563
560
|
destroy(): this;
|
|
564
561
|
changeView(view: View): this;
|
|
565
|
-
/** The
|
|
562
|
+
/** The node the toolbar adds to, and the sidebar shows, or null: any node with settings, a row, a column, a container, a text. Null without active_target, which settings_panel 'sidebar' turns on. */
|
|
566
563
|
getActiveTarget(): HTMLElement | null;
|
|
567
|
-
/** Make a
|
|
564
|
+
/** Make a node with settings, or the first a selector matches, the one the toolbar adds to; null for none. */
|
|
568
565
|
setActiveTarget(target: HTMLElement | string | null): this;
|
|
569
|
-
/** The node whose settings the sidebar shows, or null. Null unless settings_panel is 'sidebar'. */
|
|
570
|
-
getSelected(): HTMLElement | null;
|
|
571
|
-
/** Select a node with settings, or the first a selector matches, or null for none. Does nothing unless settings_panel is 'sidebar'. */
|
|
572
|
-
setSelected(node: HTMLElement | string | null): this;
|
|
573
566
|
getView(): View;
|
|
574
567
|
setLocale(code: string): this;
|
|
575
568
|
createRow(layout?: RowLayout, options?: Placement): HTMLElement | null;
|
package/dist/grideditor.esm.js
CHANGED
|
@@ -238,7 +238,10 @@ function off(target, types, handler, options) {
|
|
|
238
238
|
var DEFAULT_DURATION = 400;
|
|
239
239
|
function animateAway(node, frames, duration, done) {
|
|
240
240
|
duration = duration === void 0 ? DEFAULT_DURATION : duration;
|
|
241
|
+
addClass(node, "ge-leaving");
|
|
241
242
|
var finish = function() {
|
|
243
|
+
removeClass(node, "ge-leaving");
|
|
244
|
+
dropEmptyClass(node);
|
|
242
245
|
hide(node);
|
|
243
246
|
if (done) {
|
|
244
247
|
done();
|
|
@@ -328,9 +331,7 @@ var METHODS = {
|
|
|
328
331
|
getUtility: { value: true },
|
|
329
332
|
setUtility: { value: true },
|
|
330
333
|
getActiveTarget: { value: true },
|
|
331
|
-
setActiveTarget: {}
|
|
332
|
-
getSelected: { value: true },
|
|
333
|
-
setSelected: {}
|
|
334
|
+
setActiveTarget: {}
|
|
334
335
|
};
|
|
335
336
|
var PLACEMENTS = ["appendTo", "prependTo", "insertAfter", "insertBefore"];
|
|
336
337
|
var REFERENCES = [
|
|
@@ -686,7 +687,6 @@ function build(instance, baseElem, optionsOrMethod) {
|
|
|
686
687
|
var sortables = [];
|
|
687
688
|
var instanceId = ++editorCounter;
|
|
688
689
|
var destroyed = false;
|
|
689
|
-
var selected = null;
|
|
690
690
|
var sidebarCollapsed = null;
|
|
691
691
|
var pluginHandle = null;
|
|
692
692
|
if (settings.settings_panel === "sidebar") {
|
|
@@ -698,6 +698,8 @@ function build(instance, baseElem, optionsOrMethod) {
|
|
|
698
698
|
}
|
|
699
699
|
}
|
|
700
700
|
var detailsFor = /* @__PURE__ */ new WeakMap();
|
|
701
|
+
var toolActions = /* @__PURE__ */ new WeakMap();
|
|
702
|
+
var pendingDelete = null;
|
|
701
703
|
var moves = /* @__PURE__ */ new WeakMap();
|
|
702
704
|
var resizes = /* @__PURE__ */ new WeakMap();
|
|
703
705
|
var sectionNodes = /* @__PURE__ */ new WeakMap();
|
|
@@ -921,12 +923,17 @@ function build(instance, baseElem, optionsOrMethod) {
|
|
|
921
923
|
});
|
|
922
924
|
}
|
|
923
925
|
function deleteNode(kind, node, message, animate) {
|
|
926
|
+
var asked = pendingDelete || {};
|
|
927
|
+
pendingDelete = null;
|
|
924
928
|
operate(function() {
|
|
925
|
-
var payload = payloadFor(kind, node, { source: "tool" });
|
|
929
|
+
var payload = payloadFor(kind, node, { source: asked.source || "tool" });
|
|
926
930
|
if (!emit("before-delete", payload)) {
|
|
927
931
|
return;
|
|
928
932
|
}
|
|
929
|
-
|
|
933
|
+
if (asked.before) {
|
|
934
|
+
asked.before();
|
|
935
|
+
}
|
|
936
|
+
var remove = function() {
|
|
930
937
|
operate(function() {
|
|
931
938
|
animate(function() {
|
|
932
939
|
node.remove();
|
|
@@ -936,9 +943,40 @@ function build(instance, baseElem, optionsOrMethod) {
|
|
|
936
943
|
});
|
|
937
944
|
});
|
|
938
945
|
});
|
|
939
|
-
}
|
|
946
|
+
};
|
|
947
|
+
if (asked.confirm === false) {
|
|
948
|
+
remove();
|
|
949
|
+
} else {
|
|
950
|
+
askToDelete(message, remove);
|
|
951
|
+
}
|
|
940
952
|
});
|
|
941
953
|
}
|
|
954
|
+
function removeNode(node, options) {
|
|
955
|
+
options = options || {};
|
|
956
|
+
var drawer = node ? drawerOf(node) : null;
|
|
957
|
+
var tool = drawer ? child(drawer, '[class*="ge-delete-"]') : null;
|
|
958
|
+
var action = tool ? toolActions.get(tool) : null;
|
|
959
|
+
if (!action) {
|
|
960
|
+
return false;
|
|
961
|
+
}
|
|
962
|
+
var went = false;
|
|
963
|
+
pendingDelete = {
|
|
964
|
+
source: options.source,
|
|
965
|
+
confirm: options.confirm,
|
|
966
|
+
before: function() {
|
|
967
|
+
went = true;
|
|
968
|
+
if (options.before) {
|
|
969
|
+
options.before();
|
|
970
|
+
}
|
|
971
|
+
}
|
|
972
|
+
};
|
|
973
|
+
try {
|
|
974
|
+
action.call(tool);
|
|
975
|
+
} finally {
|
|
976
|
+
pendingDelete = null;
|
|
977
|
+
}
|
|
978
|
+
return went;
|
|
979
|
+
}
|
|
942
980
|
function planSize(col, size, view) {
|
|
943
981
|
view = view || curView;
|
|
944
982
|
if (view !== ALL_VIEW) {
|
|
@@ -1129,8 +1167,7 @@ function build(instance, baseElem, optionsOrMethod) {
|
|
|
1129
1167
|
var signal = { signal: lifetime.signal };
|
|
1130
1168
|
window.addEventListener("scroll", onScroll, signal);
|
|
1131
1169
|
delegate(canvas, "click", ".ge-content", onContentClick, signal);
|
|
1132
|
-
|
|
1133
|
-
if (settings.active_target || sidebarMode) {
|
|
1170
|
+
if (settings.active_target) {
|
|
1134
1171
|
var pressed = null;
|
|
1135
1172
|
canvas.addEventListener("pointerdown", function(e) {
|
|
1136
1173
|
pressed = { x: e.clientX, y: e.clientY };
|
|
@@ -1144,12 +1181,7 @@ function build(instance, baseElem, optionsOrMethod) {
|
|
|
1144
1181
|
if (from && Math.abs(e.clientX - from.x) + Math.abs(e.clientY - from.y) > settings.drag.threshold) {
|
|
1145
1182
|
return;
|
|
1146
1183
|
}
|
|
1147
|
-
|
|
1148
|
-
clickTarget(e);
|
|
1149
|
-
}
|
|
1150
|
-
if (sidebarMode && canvas.contains(e.target)) {
|
|
1151
|
-
changeSelection(settingsNodeAt(e.target));
|
|
1152
|
-
}
|
|
1184
|
+
clickTarget(e);
|
|
1153
1185
|
}, signal);
|
|
1154
1186
|
document.addEventListener("keydown", function(e) {
|
|
1155
1187
|
if (e.key !== "Escape" || openSettingsState || dialogState) {
|
|
@@ -1162,23 +1194,28 @@ function build(instance, baseElem, optionsOrMethod) {
|
|
|
1162
1194
|
if (focus && (is(focus, "input, textarea, select") || focus.isContentEditable)) {
|
|
1163
1195
|
return;
|
|
1164
1196
|
}
|
|
1165
|
-
if (
|
|
1166
|
-
changeSelection(null);
|
|
1167
|
-
} else if (activeTarget) {
|
|
1197
|
+
if (activeTarget) {
|
|
1168
1198
|
changeTarget(null);
|
|
1169
1199
|
}
|
|
1170
1200
|
}, signal);
|
|
1171
|
-
}
|
|
1172
|
-
if (sidebarMode) {
|
|
1173
1201
|
canvas.addEventListener("focusin", function(e) {
|
|
1174
1202
|
var node = isEditing() ? settingsNodeAt(e.target) : null;
|
|
1175
1203
|
if (node) {
|
|
1176
|
-
|
|
1204
|
+
changeTarget(node);
|
|
1177
1205
|
}
|
|
1178
1206
|
}, signal);
|
|
1207
|
+
var pressedOn = null;
|
|
1208
|
+
document.addEventListener("pointerdown", function(e) {
|
|
1209
|
+
pressedOn = e.target;
|
|
1210
|
+
}, { capture: true, signal: signal.signal });
|
|
1179
1211
|
document.addEventListener("click", function(e) {
|
|
1180
1212
|
var target = e.target;
|
|
1181
|
-
|
|
1213
|
+
var from = pressedOn;
|
|
1214
|
+
pressedOn = null;
|
|
1215
|
+
if (!activeTarget || !isEditing() || !target || target.nodeType !== 1) {
|
|
1216
|
+
return;
|
|
1217
|
+
}
|
|
1218
|
+
if (from && from.nodeType === 1 && (canvas.contains(from) || closest(from, EDITOR_CONTROLS))) {
|
|
1182
1219
|
return;
|
|
1183
1220
|
}
|
|
1184
1221
|
if (!attached(target) || canvas.contains(target)) {
|
|
@@ -1187,17 +1224,22 @@ function build(instance, baseElem, optionsOrMethod) {
|
|
|
1187
1224
|
if (closest(target, EDITOR_CONTROLS) || canvas.querySelector(".ge-rte-active")) {
|
|
1188
1225
|
return;
|
|
1189
1226
|
}
|
|
1190
|
-
|
|
1227
|
+
changeTarget(null);
|
|
1191
1228
|
}, signal);
|
|
1229
|
+
}
|
|
1230
|
+
if (panelMode() === "sidebar") {
|
|
1192
1231
|
window.addEventListener("resize", reserveSidebarRoom, signal);
|
|
1193
1232
|
}
|
|
1194
1233
|
function clickTarget(e) {
|
|
1195
|
-
|
|
1196
|
-
|
|
1234
|
+
if (!canvas.contains(e.target)) {
|
|
1235
|
+
return;
|
|
1236
|
+
}
|
|
1237
|
+
var node = settingsNodeAt(e.target);
|
|
1238
|
+
if (node && node === activeTarget && (e.target === drawerOf(node) || e.target === node && !hasClass(node, "ge-content"))) {
|
|
1197
1239
|
changeTarget(null);
|
|
1198
1240
|
return;
|
|
1199
1241
|
}
|
|
1200
|
-
changeTarget(
|
|
1242
|
+
changeTarget(node);
|
|
1201
1243
|
}
|
|
1202
1244
|
}
|
|
1203
1245
|
function textReady(block) {
|
|
@@ -1682,13 +1724,11 @@ function build(instance, baseElem, optionsOrMethod) {
|
|
|
1682
1724
|
}
|
|
1683
1725
|
var placed = made;
|
|
1684
1726
|
if (item.inColumn) {
|
|
1685
|
-
|
|
1686
|
-
placed = inRowOfItsOwn(made);
|
|
1687
|
-
}
|
|
1727
|
+
placed = wrapFor(where.region, made);
|
|
1688
1728
|
} else if (!acceptsBlock(where.region, made)) {
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1729
|
+
where = canvasAfterTopOf(where.region);
|
|
1730
|
+
} else if (is(where.region, ".row")) {
|
|
1731
|
+
placed = wrapFor(where.region, made);
|
|
1692
1732
|
}
|
|
1693
1733
|
return addNode(item.kind, made, function() {
|
|
1694
1734
|
if (where.before) {
|
|
@@ -1698,10 +1738,32 @@ function build(instance, baseElem, optionsOrMethod) {
|
|
|
1698
1738
|
}
|
|
1699
1739
|
}, { parent: where.region, source: item.source || source || "dragdrop" });
|
|
1700
1740
|
}
|
|
1741
|
+
function canvasAfterTopOf(region) {
|
|
1742
|
+
var ancestors = region === canvas ? [] : parentsUntil(region, canvas).reverse().concat([region]);
|
|
1743
|
+
var top = ancestors[0] || null;
|
|
1744
|
+
return { region: canvas, before: top ? top.nextElementSibling : null };
|
|
1745
|
+
}
|
|
1746
|
+
function placeInTarget(node, kind, source) {
|
|
1747
|
+
if (!activeTarget) {
|
|
1748
|
+
return null;
|
|
1749
|
+
}
|
|
1750
|
+
var where = { region: effectiveRegion(activeTarget), before: null };
|
|
1751
|
+
var placed = wrapFor(where.region, node);
|
|
1752
|
+
var holder = placed === node ? null : node.parentElement;
|
|
1753
|
+
if (!acceptsBlock(where.region, placed) || holder && !acceptsBlock(holder, node)) {
|
|
1754
|
+
where = canvasAfterTopOf(where.region);
|
|
1755
|
+
placed = node;
|
|
1756
|
+
}
|
|
1757
|
+
return addNode(kind, node, function() {
|
|
1758
|
+
if (where.before) {
|
|
1759
|
+
where.before.parentNode.insertBefore(placed, where.before);
|
|
1760
|
+
} else {
|
|
1761
|
+
where.region.appendChild(placed);
|
|
1762
|
+
}
|
|
1763
|
+
}, { parent: where.region, source: source || "api" });
|
|
1764
|
+
}
|
|
1701
1765
|
function inRowOfItsOwn(node) {
|
|
1702
|
-
|
|
1703
|
-
row.appendChild(createColumn(MAX_COL_SIZE)).appendChild(node);
|
|
1704
|
-
return row;
|
|
1766
|
+
return rowHolding(createColumn(MAX_COL_SIZE), node);
|
|
1705
1767
|
}
|
|
1706
1768
|
function showDropMarker(pageX, pageY) {
|
|
1707
1769
|
var where = dropPlaceAt(pageX, pageY);
|
|
@@ -1730,10 +1792,7 @@ function build(instance, baseElem, optionsOrMethod) {
|
|
|
1730
1792
|
var container = button.getAttribute("data-ge-toolbar") === "container";
|
|
1731
1793
|
var type = button.getAttribute("data-ge-container-type");
|
|
1732
1794
|
var made = container ? CONTAINERS[type].create({}) : rowFromLayout(button.getAttribute("data-ge-layout"));
|
|
1733
|
-
var placed = made;
|
|
1734
|
-
if (container && !is(where.region, ".column")) {
|
|
1735
|
-
placed = inRowOfItsOwn(made);
|
|
1736
|
-
}
|
|
1795
|
+
var placed = wrapFor(where.region, made);
|
|
1737
1796
|
return addNode(container ? type : "row", made, function() {
|
|
1738
1797
|
if (where.before) {
|
|
1739
1798
|
where.before.parentNode.insertBefore(placed, where.before);
|
|
@@ -1996,7 +2055,6 @@ function build(instance, baseElem, optionsOrMethod) {
|
|
|
1996
2055
|
setPreview(false);
|
|
1997
2056
|
deinit();
|
|
1998
2057
|
changeTarget(null);
|
|
1999
|
-
changeSelection(null);
|
|
2000
2058
|
htmlTextArea.style.height = 0.8 * document.documentElement.clientHeight + "px";
|
|
2001
2059
|
htmlTextArea.value = canvas.innerHTML;
|
|
2002
2060
|
show(htmlTextArea);
|
|
@@ -2012,11 +2070,8 @@ function build(instance, baseElem, optionsOrMethod) {
|
|
|
2012
2070
|
init();
|
|
2013
2071
|
hide(htmlTextArea);
|
|
2014
2072
|
}
|
|
2015
|
-
function targetSelector() {
|
|
2016
|
-
return [".column"].concat(pluginHooks("regions")).join(", ");
|
|
2017
|
-
}
|
|
2018
2073
|
function isTarget(node) {
|
|
2019
|
-
return !!node && node !== canvas && canvas.contains(node) &&
|
|
2074
|
+
return !!node && node !== canvas && canvas.contains(node) && detailsFor.has(node);
|
|
2020
2075
|
}
|
|
2021
2076
|
function changeTarget(node) {
|
|
2022
2077
|
if (node === activeTarget) {
|
|
@@ -2024,16 +2079,63 @@ function build(instance, baseElem, optionsOrMethod) {
|
|
|
2024
2079
|
}
|
|
2025
2080
|
var from = activeTarget;
|
|
2026
2081
|
if (from) {
|
|
2027
|
-
removeClass(from, "ge-
|
|
2082
|
+
removeClass(from, "ge-selected");
|
|
2028
2083
|
}
|
|
2029
2084
|
activeTarget = node;
|
|
2030
2085
|
if (node && hasClass(canvas, "ge-editing")) {
|
|
2031
|
-
addClass(node, "ge-
|
|
2086
|
+
addClass(node, "ge-selected");
|
|
2032
2087
|
}
|
|
2088
|
+
renderSidebar();
|
|
2033
2089
|
emit("target-change", { canvas, target: node, from });
|
|
2034
2090
|
}
|
|
2091
|
+
function regionSelector() {
|
|
2092
|
+
return [".column"].concat(pluginHooks("regions")).join(", ");
|
|
2093
|
+
}
|
|
2094
|
+
function effectiveRegion(target) {
|
|
2095
|
+
if (is(target, ".row, " + regionSelector())) {
|
|
2096
|
+
return target;
|
|
2097
|
+
}
|
|
2098
|
+
var inside = isContainerOrPane(target) ? paneRegionOf(target) : null;
|
|
2099
|
+
return inside || closest(target.parentElement, regionSelector()) || canvas;
|
|
2100
|
+
}
|
|
2101
|
+
function isContainerOrPane(node) {
|
|
2102
|
+
if (node.getAttribute("data-ge-container")) {
|
|
2103
|
+
return true;
|
|
2104
|
+
}
|
|
2105
|
+
var container = closest(node.parentElement, "[data-ge-container]", canvas);
|
|
2106
|
+
var definition = container && CONTAINERS[containerTypeOf(container)];
|
|
2107
|
+
return !!definition && !!definition.paneKind && kindOf(node) === definition.paneKind;
|
|
2108
|
+
}
|
|
2109
|
+
function paneRegionOf(node) {
|
|
2110
|
+
var isContainer = !!node.getAttribute("data-ge-container");
|
|
2111
|
+
var container = isContainer ? node : closest(node.parentElement, "[data-ge-container]", canvas);
|
|
2112
|
+
var definition = CONTAINERS[containerTypeOf(container)];
|
|
2113
|
+
return definition && definition.regionOf ? definition.regionOf(container, isContainer ? null : node) || null : null;
|
|
2114
|
+
}
|
|
2115
|
+
function wrapFor(region, node) {
|
|
2116
|
+
if (is(node, ".column")) {
|
|
2117
|
+
return is(region, ".row") ? node : rowHolding(node);
|
|
2118
|
+
}
|
|
2119
|
+
if (is(region, ".row")) {
|
|
2120
|
+
var column = createColumn(rowColsSource(region, leadingTier()) ? null : settings.add_column.size);
|
|
2121
|
+
column.appendChild(node);
|
|
2122
|
+
return column;
|
|
2123
|
+
}
|
|
2124
|
+
if (is(region, ".column") || is(node, ".row")) {
|
|
2125
|
+
return node;
|
|
2126
|
+
}
|
|
2127
|
+
return rowHolding(createColumn(MAX_COL_SIZE), node);
|
|
2128
|
+
}
|
|
2129
|
+
function rowHolding(column, node) {
|
|
2130
|
+
var row = createRow();
|
|
2131
|
+
if (node) {
|
|
2132
|
+
column.appendChild(node);
|
|
2133
|
+
}
|
|
2134
|
+
row.appendChild(column);
|
|
2135
|
+
return row;
|
|
2136
|
+
}
|
|
2035
2137
|
function addToTarget(button, source) {
|
|
2036
|
-
var made = insertFromToolbar(button, { region: activeTarget, before: null }, source);
|
|
2138
|
+
var made = insertFromToolbar(button, { region: effectiveRegion(activeTarget), before: null }, source);
|
|
2037
2139
|
if (made && made.scrollIntoView) {
|
|
2038
2140
|
made.scrollIntoView({ behavior: "smooth" });
|
|
2039
2141
|
}
|
|
@@ -2042,8 +2144,8 @@ function build(instance, baseElem, optionsOrMethod) {
|
|
|
2042
2144
|
if (openSettingsState && !attached(openSettingsState.node)) {
|
|
2043
2145
|
closeSettings();
|
|
2044
2146
|
}
|
|
2045
|
-
if (
|
|
2046
|
-
|
|
2147
|
+
if (activeTarget && !canvas.contains(activeTarget)) {
|
|
2148
|
+
changeTarget(null);
|
|
2047
2149
|
}
|
|
2048
2150
|
if (dialogState && dialogState.home && !attached(dialogState.home)) {
|
|
2049
2151
|
closeDialog();
|
|
@@ -2067,7 +2169,7 @@ function build(instance, baseElem, optionsOrMethod) {
|
|
|
2067
2169
|
if (activeTarget && !canvas.contains(activeTarget)) {
|
|
2068
2170
|
changeTarget(null);
|
|
2069
2171
|
} else if (activeTarget) {
|
|
2070
|
-
addClass(activeTarget, "ge-
|
|
2172
|
+
addClass(activeTarget, "ge-selected");
|
|
2071
2173
|
}
|
|
2072
2174
|
showSidebar();
|
|
2073
2175
|
}
|
|
@@ -2076,7 +2178,7 @@ function build(instance, baseElem, optionsOrMethod) {
|
|
|
2076
2178
|
hideSidebar();
|
|
2077
2179
|
removeClass(canvas, "ge-editing ge-drag-drawer ge-dropping");
|
|
2078
2180
|
if (activeTarget) {
|
|
2079
|
-
removeClass(activeTarget, "ge-
|
|
2181
|
+
removeClass(activeTarget, "ge-selected");
|
|
2080
2182
|
}
|
|
2081
2183
|
plugins("onBeforeDeinit");
|
|
2082
2184
|
closeSizePicker();
|
|
@@ -2153,8 +2255,8 @@ function build(instance, baseElem, optionsOrMethod) {
|
|
|
2153
2255
|
}
|
|
2154
2256
|
var copy = copyCanvas();
|
|
2155
2257
|
var root = copy.root;
|
|
2156
|
-
[root].concat(all(root, ".ge-
|
|
2157
|
-
removeClass(node, "ge-
|
|
2258
|
+
[root].concat(all(root, ".ge-selected, .ge-settings-target, .ge-leaving")).forEach(function(node) {
|
|
2259
|
+
removeClass(node, "ge-selected ge-settings-target ge-leaving");
|
|
2158
2260
|
dropEmptyClass(node);
|
|
2159
2261
|
});
|
|
2160
2262
|
all(root, ".ge-drop-marker").forEach(function(marker) {
|
|
@@ -2236,7 +2338,6 @@ function build(instance, baseElem, optionsOrMethod) {
|
|
|
2236
2338
|
setPreview(false);
|
|
2237
2339
|
deinit();
|
|
2238
2340
|
activeTarget = null;
|
|
2239
|
-
selected = null;
|
|
2240
2341
|
if (sidebarHolder === instance) {
|
|
2241
2342
|
sidebarHolder = null;
|
|
2242
2343
|
}
|
|
@@ -2317,6 +2418,9 @@ function build(instance, baseElem, optionsOrMethod) {
|
|
|
2317
2418
|
addSettingsTool,
|
|
2318
2419
|
deleteNode,
|
|
2319
2420
|
place,
|
|
2421
|
+
// A node made, added to the active target as the toolbar adds
|
|
2422
|
+
// what it makes: null with no target, or when it was canceled
|
|
2423
|
+
placeInTarget,
|
|
2320
2424
|
createPaneControls,
|
|
2321
2425
|
makeLabelEditable,
|
|
2322
2426
|
labelIn,
|
|
@@ -2373,30 +2477,23 @@ function build(instance, baseElem, optionsOrMethod) {
|
|
|
2373
2477
|
toolbarItems: function(name) {
|
|
2374
2478
|
return mainControls ? all(mainControls, '[data-ge-toolbar="feature"][data-ge-feature="' + name + '"]') : [];
|
|
2375
2479
|
},
|
|
2376
|
-
getSelected: function() {
|
|
2377
|
-
return panelMode() === "sidebar" ? selected : null;
|
|
2378
|
-
},
|
|
2379
2480
|
getActiveTarget: function() {
|
|
2380
2481
|
return settings.active_target ? activeTarget : null;
|
|
2381
2482
|
},
|
|
2382
2483
|
// True when it took: a node that cannot be, or no setting
|
|
2383
2484
|
// for it, says nothing, since a plugin putting back what it
|
|
2384
2485
|
// remembers cannot know the node is still one
|
|
2385
|
-
|
|
2386
|
-
var chosen = panelMode() === "sidebar" && !!node && node !== canvas && canvas.contains(node) && detailsFor.has(node);
|
|
2387
|
-
if (chosen) {
|
|
2388
|
-
changeSelection(node);
|
|
2389
|
-
}
|
|
2390
|
-
return chosen;
|
|
2391
|
-
},
|
|
2486
|
+
// null takes it away
|
|
2392
2487
|
setActiveTarget: function(node) {
|
|
2393
|
-
var chosen = !!settings.active_target && isTarget(node);
|
|
2488
|
+
var chosen = !!settings.active_target && (node === null || isTarget(node));
|
|
2394
2489
|
if (chosen) {
|
|
2395
2490
|
changeTarget(node);
|
|
2396
2491
|
}
|
|
2397
2492
|
return chosen;
|
|
2398
2493
|
},
|
|
2399
|
-
//
|
|
2494
|
+
// A node removed as its delete tool does, as asked
|
|
2495
|
+
removeNode,
|
|
2496
|
+
// What keeps Escape from the target, and an
|
|
2400
2497
|
// inline panel unfolded in a drawer, which Escape leaves alone
|
|
2401
2498
|
panelOpen: function() {
|
|
2402
2499
|
if (openSettingsState || dialogState) {
|
|
@@ -3446,11 +3543,15 @@ function build(instance, baseElem, optionsOrMethod) {
|
|
|
3446
3543
|
drawer.appendChild(tool);
|
|
3447
3544
|
if (typeof eventHandlers == "function") {
|
|
3448
3545
|
tool.addEventListener("click", eventHandlers);
|
|
3546
|
+
toolActions.set(tool, eventHandlers);
|
|
3449
3547
|
}
|
|
3450
3548
|
if (eventHandlers && typeof eventHandlers == "object") {
|
|
3451
3549
|
Object.keys(eventHandlers).forEach(function(name) {
|
|
3452
3550
|
on(tool, name, eventHandlers[name]);
|
|
3453
3551
|
});
|
|
3552
|
+
if (typeof eventHandlers.click == "function") {
|
|
3553
|
+
toolActions.set(tool, eventHandlers.click);
|
|
3554
|
+
}
|
|
3454
3555
|
}
|
|
3455
3556
|
return tool;
|
|
3456
3557
|
}
|
|
@@ -3769,7 +3870,7 @@ function build(instance, baseElem, optionsOrMethod) {
|
|
|
3769
3870
|
delegate(panel, "click", ".ge-settings-close", function(e) {
|
|
3770
3871
|
e.preventDefault();
|
|
3771
3872
|
if (mode === "sidebar") {
|
|
3772
|
-
|
|
3873
|
+
changeTarget(null);
|
|
3773
3874
|
} else {
|
|
3774
3875
|
closeSettings();
|
|
3775
3876
|
}
|
|
@@ -3890,7 +3991,7 @@ function build(instance, baseElem, optionsOrMethod) {
|
|
|
3890
3991
|
if (!panel || !isEditing()) {
|
|
3891
3992
|
return;
|
|
3892
3993
|
}
|
|
3893
|
-
var details =
|
|
3994
|
+
var details = activeTarget ? detailsOf(activeTarget) : null;
|
|
3894
3995
|
if (details ? sidebarShown && sidebarShown.details === details : !sidebarShown && sidebarEmpty) {
|
|
3895
3996
|
return;
|
|
3896
3997
|
}
|
|
@@ -3904,11 +4005,10 @@ function build(instance, baseElem, optionsOrMethod) {
|
|
|
3904
4005
|
sidebarEmpty = { body };
|
|
3905
4006
|
return;
|
|
3906
4007
|
}
|
|
3907
|
-
sidebarShown = { node:
|
|
3908
|
-
setSidebarTitle(t("panel.title", { kind: kindLabel(
|
|
4008
|
+
sidebarShown = { node: activeTarget, details, home: details.parentElement, next: details.nextElementSibling };
|
|
4009
|
+
setSidebarTitle(t("panel.title", { kind: kindLabel(activeTarget) }));
|
|
3909
4010
|
holder.appendChild(details);
|
|
3910
4011
|
show(details);
|
|
3911
|
-
addClass(selected, "ge-settings-target");
|
|
3912
4012
|
}
|
|
3913
4013
|
function emptyContent() {
|
|
3914
4014
|
var fromHost = settings.sidebar.empty;
|
|
@@ -3958,15 +4058,6 @@ function build(instance, baseElem, optionsOrMethod) {
|
|
|
3958
4058
|
}
|
|
3959
4059
|
return null;
|
|
3960
4060
|
}
|
|
3961
|
-
function changeSelection(node) {
|
|
3962
|
-
if (node === selected) {
|
|
3963
|
-
return;
|
|
3964
|
-
}
|
|
3965
|
-
var from = selected;
|
|
3966
|
-
selected = node;
|
|
3967
|
-
renderSidebar();
|
|
3968
|
-
emit("selection-change", { canvas, node, from });
|
|
3969
|
-
}
|
|
3970
4061
|
function placePopover(panel, gear) {
|
|
3971
4062
|
if (!attached(gear)) {
|
|
3972
4063
|
return;
|
|
@@ -5076,28 +5167,11 @@ function build(instance, baseElem, optionsOrMethod) {
|
|
|
5076
5167
|
var node = nodeFrom(value);
|
|
5077
5168
|
if (!isTarget(node)) {
|
|
5078
5169
|
var named = typeof value === "string" ? value : node ? "<" + node.tagName.toLowerCase() + ">" : String(value);
|
|
5079
|
-
warn("setActiveTarget: " + named + " is not a
|
|
5170
|
+
warn("setActiveTarget: " + named + " is not a node of the canvas with settings");
|
|
5080
5171
|
return;
|
|
5081
5172
|
}
|
|
5082
5173
|
changeTarget(node);
|
|
5083
5174
|
}
|
|
5084
|
-
function apiSetSelected(value) {
|
|
5085
|
-
if (panelMode() !== "sidebar") {
|
|
5086
|
-
warnOnceHere("sidebar-api", 'setSelected needs settings_panel "sidebar": without it, it does nothing');
|
|
5087
|
-
return;
|
|
5088
|
-
}
|
|
5089
|
-
if (value === null || value === void 0) {
|
|
5090
|
-
changeSelection(null);
|
|
5091
|
-
return;
|
|
5092
|
-
}
|
|
5093
|
-
var node = nodeFrom(value);
|
|
5094
|
-
if (!node || node === canvas || !canvas.contains(node) || !detailsFor.has(node)) {
|
|
5095
|
-
var named = typeof value === "string" ? value : node ? "<" + node.tagName.toLowerCase() + ">" : String(value);
|
|
5096
|
-
warn("setSelected: " + named + " is not a node of the canvas with settings");
|
|
5097
|
-
return;
|
|
5098
|
-
}
|
|
5099
|
-
changeSelection(node);
|
|
5100
|
-
}
|
|
5101
5175
|
var own = {
|
|
5102
5176
|
getHtml,
|
|
5103
5177
|
getPlainHtml,
|
|
@@ -5136,11 +5210,7 @@ function build(instance, baseElem, optionsOrMethod) {
|
|
|
5136
5210
|
getActiveTarget: function() {
|
|
5137
5211
|
return settings.active_target ? activeTarget : null;
|
|
5138
5212
|
},
|
|
5139
|
-
setActiveTarget: apiSetActiveTarget
|
|
5140
|
-
getSelected: function() {
|
|
5141
|
-
return panelMode() === "sidebar" ? selected : null;
|
|
5142
|
-
},
|
|
5143
|
-
setSelected: apiSetSelected
|
|
5213
|
+
setActiveTarget: apiSetActiveTarget
|
|
5144
5214
|
};
|
|
5145
5215
|
Object.keys(own).forEach(function(name) {
|
|
5146
5216
|
var value = !!(METHODS[name] && METHODS[name].value);
|
|
@@ -5191,7 +5261,7 @@ GridEditor.t = translate;
|
|
|
5191
5261
|
GridEditor._plainHtml = plainHtml;
|
|
5192
5262
|
GridEditor.Sortable = null;
|
|
5193
5263
|
GridEditor.bootstrap = null;
|
|
5194
|
-
GridEditor.version = false ? "dev" : "9.0.0-beta.
|
|
5264
|
+
GridEditor.version = false ? "dev" : "9.0.0-beta.7";
|
|
5195
5265
|
GridEditor.locales = {
|
|
5196
5266
|
en: {
|
|
5197
5267
|
"tool.move": "Move",
|