@themarioga/grid-editor 8.0.0 → 8.2.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 +30 -0
- package/README.md +19 -2
- package/dist/grideditor.bundle.min.js +3 -3
- package/dist/grideditor.css +9 -0
- package/dist/grideditor.d.ts +18 -1
- package/dist/grideditor.esm.js +147 -32
- 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 +147 -32
- 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.inline-style.esm.js +9 -0
- package/dist/plugins/grideditor.inline-style.js +9 -0
- package/dist/plugins/grideditor.inline-style.min.js +3 -3
- package/dist/plugins/grideditor.inline-style.min.js.map +3 -3
- package/docs/events.md +7 -0
- package/docs/locale-keys.md +1 -0
- package/package.json +1 -1
- package/src/js/grideditor.jquery.js +2 -0
- package/src/js/grideditor.js +139 -27
- package/src/js/inline-style/fields.js +10 -0
- package/src/js/locales/grideditor.es.js +1 -0
- package/src/js/plugins/grideditor.inline-style.js +1 -0
- package/src/less/grideditor.less +10 -0
- package/types/grideditor.d.ts +18 -1
package/docs/events.md
CHANGED
|
@@ -89,6 +89,7 @@ about every insertion can bind `grideditor:before-add` and switch on
|
|
|
89
89
|
| `grideditor:before-utility` | — | yes | before a utility class is written, from the panel, a plugin's tool or `setUtility` |
|
|
90
90
|
| `grideditor:after-utility` | — | no | after the class is written and the preview redrawn, only if something changed |
|
|
91
91
|
| `grideditor:view-change` | — | no | after the view changes, only if it actually changed |
|
|
92
|
+
| `grideditor:target-change` | — | no | with `active_target`, after the column or section the toolbar adds to changes, only if it actually changed |
|
|
92
93
|
| `grideditor:after-copy` | — | no | with the clipboard plugin, after a node is copied |
|
|
93
94
|
|
|
94
95
|
Two things here are not in the 3.0 specification's catalogue. The indent pair,
|
|
@@ -160,6 +161,12 @@ view), `from` and `to`. A utility's `breakpoint` is the view it was written
|
|
|
160
161
|
in, which `setUtility` can be asked to make a different one from the view on
|
|
161
162
|
screen, and its `source` is `panel`, `tool` or `api`.
|
|
162
163
|
|
|
164
|
+
`target-change` carries no node either: its payload is `canvas`, `target` - the
|
|
165
|
+
column or section the toolbar adds to now, or `null` for the end of the canvas
|
|
166
|
+
- and `from`, the one before. What a toolbar button then adds fires its add
|
|
167
|
+
events as any click does, with `source: 'tool'` (or `'paste'`) and the target,
|
|
168
|
+
or the canvas for a section, as the `parent`.
|
|
169
|
+
|
|
163
170
|
`source` matters to a host that both drives the editor from its own palette and
|
|
164
171
|
listens for what the user does: `api` is your own call coming back to you,
|
|
165
172
|
`tool` is a click in the editor, `dragdrop` is a gesture, and `paste` is a node
|
package/docs/locale-keys.md
CHANGED
|
@@ -329,6 +329,7 @@ The inline-style plugin's accordion, in a node's settings panel or in the dialog
|
|
|
329
329
|
| `inline_style.shadow_color` | Color | A part of the shadow builder |
|
|
330
330
|
| `inline_style.shadow_inset` | Inset | The shadow builder's inset checkbox |
|
|
331
331
|
| `inline_style.shadow_text_mode` | Edit as text | Link under the shadow builder that edits the value as text |
|
|
332
|
+
| `inline_style.shadow_builder_mode` | Edit with the builder | Link under a shadow edited as text that goes back to the builder, when the value is one shadow or none |
|
|
332
333
|
| `inline_style.prop_width` | Width | Label of the `width` field |
|
|
333
334
|
| `inline_style.prop_height` | Height | Label of the `height` field |
|
|
334
335
|
| `inline_style.prop_min_width` | Min width | Label of the `min-width` field |
|
package/package.json
CHANGED
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"comment": "A scoped package publishes restricted unless it is told otherwise.",
|
|
34
34
|
"access": "public"
|
|
35
35
|
},
|
|
36
|
-
"version": "8.
|
|
36
|
+
"version": "8.2.0",
|
|
37
37
|
"main": "dist/grideditor.js",
|
|
38
38
|
"module": "dist/grideditor.esm.js",
|
|
39
39
|
"types": "dist/grideditor.d.ts",
|
package/src/js/grideditor.js
CHANGED
|
@@ -35,6 +35,8 @@ var METHODS = {
|
|
|
35
35
|
setLocale: {},
|
|
36
36
|
getUtility: { value: true },
|
|
37
37
|
setUtility: { value: true },
|
|
38
|
+
getActiveTarget: { value: true },
|
|
39
|
+
setActiveTarget: {},
|
|
38
40
|
};
|
|
39
41
|
|
|
40
42
|
/**
|
|
@@ -142,10 +144,14 @@ var NESTED_SETTINGS = {
|
|
|
142
144
|
auto: false, // Treat every child of a content area as an element
|
|
143
145
|
},
|
|
144
146
|
resize: {
|
|
145
|
-
enabled: true,
|
|
147
|
+
enabled: true, // The handle on the column's edge
|
|
148
|
+
tools: true, // The narrower and wider tools in the column's drawer
|
|
146
149
|
handles: 'e', // Which edges carry a handle: 'e', 'w', or 'e, w'
|
|
147
150
|
balance: 'next', // 'next' takes the units out of the following column
|
|
148
151
|
},
|
|
152
|
+
indent: {
|
|
153
|
+
tools: true, // The indent tools in the column's drawer
|
|
154
|
+
},
|
|
149
155
|
drag: {
|
|
150
156
|
delay: 0, // Milliseconds to hold before a drag starts
|
|
151
157
|
touch_delay: 100, // The same for touch, where 0 eats the page's scrolling
|
|
@@ -360,6 +366,7 @@ function build(instance, baseElem, optionsOrMethod) {
|
|
|
360
366
|
'row_tools' : [],
|
|
361
367
|
'drag_handle' : 'tool', // 'tool' for the move tool, 'drawer' for the whole drawer
|
|
362
368
|
'toolbar_drag' : 'auto', // Drag the toolbar's buttons onto the canvas. 'auto' follows drag_handle
|
|
369
|
+
'active_target' : false, // A click in a column makes it where the toolbar's buttons add
|
|
363
370
|
'element_tools' : [], // Host tools on element drawers, same shape as row_tools
|
|
364
371
|
'element_classes' : [], // Preset class toggles on an element's settings panel
|
|
365
372
|
// content_types, text_tools and text_classes are the text editor
|
|
@@ -380,6 +387,7 @@ function build(instance, baseElem, optionsOrMethod) {
|
|
|
380
387
|
'layout_modes' : VIEW_KEYS.slice(), // Which views the dropdown offers
|
|
381
388
|
'default_view' : ALL_VIEW,
|
|
382
389
|
'resize' : NESTED_SETTINGS.resize, // Resizing a column by dragging its edge
|
|
390
|
+
'indent' : NESTED_SETTINGS.indent, // Indenting a column, offset-*
|
|
383
391
|
'source_textarea' : '',
|
|
384
392
|
'edit_source' : true, // The toolbar's button to edit the canvas as html
|
|
385
393
|
'locale' : 'en', // Code of a locale in GridEditor.locales
|
|
@@ -411,6 +419,7 @@ function build(instance, baseElem, optionsOrMethod) {
|
|
|
411
419
|
var sizePicker = null; // The open column size picker, if there is one
|
|
412
420
|
var sourceOpen = false; // Whether the canvas is being edited as html
|
|
413
421
|
var dropMarker = null; // The line showing where a dragged toolbar button would land
|
|
422
|
+
var activeTarget = null; // The column or region the toolbar adds to, with active_target
|
|
414
423
|
var warnedHere = {}; // Some warnings are worth saying once per instance, not once per call
|
|
415
424
|
var sortables = []; // Every list made sortable, so deinit destroys exactly those
|
|
416
425
|
var instanceId = ++editorCounter; // Scopes the sortable groups to this editor
|
|
@@ -974,6 +983,35 @@ function build(instance, baseElem, optionsOrMethod) {
|
|
|
974
983
|
dom.delegate(canvas, 'click', '.ge-popup-trigger, [data-ge-popup-target]', function(e) {
|
|
975
984
|
if (dom.hasClass(canvas, 'ge-editing')) { e.preventDefault(); }
|
|
976
985
|
}, signal);
|
|
986
|
+
|
|
987
|
+
if (settings.active_target) {
|
|
988
|
+
// Whatever the click was for - a text, a tool - it also says
|
|
989
|
+
// where the toolbar adds next. A click on no column or region
|
|
990
|
+
// says nowhere, and the toolbar adds to the canvas again.
|
|
991
|
+
// The click a drag ends in - a resize, a move - is not one:
|
|
992
|
+
// it comes where the pointer let go, not where it pressed
|
|
993
|
+
var pressed = null;
|
|
994
|
+
canvas.addEventListener('pointerdown', function(e) {
|
|
995
|
+
pressed = { x: e.clientX, y: e.clientY };
|
|
996
|
+
}, signal);
|
|
997
|
+
canvas.addEventListener('click', function(e) {
|
|
998
|
+
var from = pressed;
|
|
999
|
+
pressed = null;
|
|
1000
|
+
if (!dom.hasClass(canvas, 'ge-editing')) { return; }
|
|
1001
|
+
if (from && Math.abs(e.clientX - from.x) + Math.abs(e.clientY - from.y) > settings.drag.threshold) { return; }
|
|
1002
|
+
var region = dom.closest(e.target, targetSelector());
|
|
1003
|
+
changeTarget(region && region !== canvas && canvas.contains(region) ? region : null);
|
|
1004
|
+
}, signal);
|
|
1005
|
+
|
|
1006
|
+
// Escape is the panel's, the dialog's, and a field's or a
|
|
1007
|
+
// text's while one has the focus; after those, it is this
|
|
1008
|
+
document.addEventListener('keydown', function(e) {
|
|
1009
|
+
if (e.key !== 'Escape' || !activeTarget || openSettingsState || dialogState) { return; }
|
|
1010
|
+
var focus = document.activeElement;
|
|
1011
|
+
if (focus && (dom.is(focus, 'input, textarea, select') || focus.isContentEditable)) { return; }
|
|
1012
|
+
changeTarget(null);
|
|
1013
|
+
}, signal);
|
|
1014
|
+
}
|
|
977
1015
|
}
|
|
978
1016
|
|
|
979
1017
|
/**
|
|
@@ -1014,6 +1052,8 @@ function build(instance, baseElem, optionsOrMethod) {
|
|
|
1014
1052
|
});
|
|
1015
1053
|
|
|
1016
1054
|
btn.addEventListener('click', function() {
|
|
1055
|
+
if (activeTarget) { addToTarget(btn, 'tool'); return; }
|
|
1056
|
+
|
|
1017
1057
|
var row = rowFromLayoutValue(layout);
|
|
1018
1058
|
|
|
1019
1059
|
var added = addNode('row', row, function() {
|
|
@@ -1050,6 +1090,8 @@ function build(instance, baseElem, optionsOrMethod) {
|
|
|
1050
1090
|
|
|
1051
1091
|
dom.attr(button, { 'data-ge-toolbar': 'container', 'data-ge-container-type': type });
|
|
1052
1092
|
button.addEventListener('click', function() {
|
|
1093
|
+
if (activeTarget) { addToTarget(button, 'tool'); return; }
|
|
1094
|
+
|
|
1053
1095
|
var row = createRow();
|
|
1054
1096
|
var column = row.appendChild(createColumn(MAX_COL_SIZE));
|
|
1055
1097
|
var container = column.appendChild(definition.create({}));
|
|
@@ -1179,6 +1221,8 @@ function build(instance, baseElem, optionsOrMethod) {
|
|
|
1179
1221
|
'data-ge-item': index,
|
|
1180
1222
|
});
|
|
1181
1223
|
button.addEventListener('click', function() {
|
|
1224
|
+
if (activeTarget) { addToTarget(button, item.source || 'tool'); return; }
|
|
1225
|
+
|
|
1182
1226
|
var made = item.create();
|
|
1183
1227
|
|
|
1184
1228
|
// One that belongs in a column brings a row and a column
|
|
@@ -1334,7 +1378,7 @@ function build(instance, baseElem, optionsOrMethod) {
|
|
|
1334
1378
|
* not have what it makes - a section dropped on a column - gives way
|
|
1335
1379
|
* to the canvas, just after the top level block the pointer was in.
|
|
1336
1380
|
*/
|
|
1337
|
-
function insertFeatureFromToolbar(button, where) {
|
|
1381
|
+
function insertFeatureFromToolbar(button, where, source) {
|
|
1338
1382
|
var item = FEATURES[button.getAttribute('data-ge-feature')].toolbar[parseInt(button.getAttribute('data-ge-item'), 10)];
|
|
1339
1383
|
var made = item.create();
|
|
1340
1384
|
var placed = made;
|
|
@@ -1355,7 +1399,7 @@ function build(instance, baseElem, optionsOrMethod) {
|
|
|
1355
1399
|
} else {
|
|
1356
1400
|
where.region.appendChild(placed);
|
|
1357
1401
|
}
|
|
1358
|
-
}, { parent: where.region, source: item.source || 'dragdrop' });
|
|
1402
|
+
}, { parent: where.region, source: item.source || source || 'dragdrop' });
|
|
1359
1403
|
}
|
|
1360
1404
|
|
|
1361
1405
|
/** A detached row with one full width column holding `node`. */
|
|
@@ -1391,9 +1435,9 @@ function build(instance, baseElem, optionsOrMethod) {
|
|
|
1391
1435
|
* The row or container a toolbar button stands for, made and put where
|
|
1392
1436
|
* the pointer left it.
|
|
1393
1437
|
*/
|
|
1394
|
-
function insertFromToolbar(button, where) {
|
|
1438
|
+
function insertFromToolbar(button, where, source) {
|
|
1395
1439
|
if (button.getAttribute('data-ge-toolbar') === 'feature') {
|
|
1396
|
-
return insertFeatureFromToolbar(button, where);
|
|
1440
|
+
return insertFeatureFromToolbar(button, where, source);
|
|
1397
1441
|
}
|
|
1398
1442
|
|
|
1399
1443
|
var container = button.getAttribute('data-ge-toolbar') === 'container';
|
|
@@ -1413,7 +1457,7 @@ function build(instance, baseElem, optionsOrMethod) {
|
|
|
1413
1457
|
} else {
|
|
1414
1458
|
where.region.appendChild(placed);
|
|
1415
1459
|
}
|
|
1416
|
-
}, { parent: where.region, source: 'dragdrop' });
|
|
1460
|
+
}, { parent: where.region, source: source || 'dragdrop' });
|
|
1417
1461
|
}
|
|
1418
1462
|
|
|
1419
1463
|
/**
|
|
@@ -1705,6 +1749,8 @@ function build(instance, baseElem, optionsOrMethod) {
|
|
|
1705
1749
|
*/
|
|
1706
1750
|
function openSource() {
|
|
1707
1751
|
deinit();
|
|
1752
|
+
// The canvas is made again from the html when it comes back
|
|
1753
|
+
changeTarget(null);
|
|
1708
1754
|
htmlTextArea.style.height = (0.8 * document.documentElement.clientHeight) + 'px';
|
|
1709
1755
|
htmlTextArea.value = canvas.innerHTML;
|
|
1710
1756
|
dom.show(htmlTextArea);
|
|
@@ -1727,6 +1773,39 @@ function build(instance, baseElem, optionsOrMethod) {
|
|
|
1727
1773
|
dom.hide(htmlTextArea);
|
|
1728
1774
|
}
|
|
1729
1775
|
|
|
1776
|
+
/**
|
|
1777
|
+
* What can be the active target: a column, or a plugin's region - a
|
|
1778
|
+
* section. Not the canvas, which is where the toolbar adds without one.
|
|
1779
|
+
*/
|
|
1780
|
+
function targetSelector() {
|
|
1781
|
+
return ['.column'].concat(pluginHooks('regions')).join(', ');
|
|
1782
|
+
}
|
|
1783
|
+
|
|
1784
|
+
function isTarget(node) {
|
|
1785
|
+
return !!node && node !== canvas && canvas.contains(node) && dom.is(node, targetSelector());
|
|
1786
|
+
}
|
|
1787
|
+
|
|
1788
|
+
/** The one way the active target changes, told only when it does. */
|
|
1789
|
+
function changeTarget(node) {
|
|
1790
|
+
if (node === activeTarget) { return; }
|
|
1791
|
+
|
|
1792
|
+
var from = activeTarget;
|
|
1793
|
+
if (from) { dom.removeClass(from, 'ge-active-target'); }
|
|
1794
|
+
activeTarget = node;
|
|
1795
|
+
if (node && dom.hasClass(canvas, 'ge-editing')) { dom.addClass(node, 'ge-active-target'); }
|
|
1796
|
+
|
|
1797
|
+
emit('target-change', { canvas: canvas, target: node, from: from });
|
|
1798
|
+
}
|
|
1799
|
+
|
|
1800
|
+
/**
|
|
1801
|
+
* A toolbar button's click with an active target: what it makes goes
|
|
1802
|
+
* where a drop at the target's end would put it.
|
|
1803
|
+
*/
|
|
1804
|
+
function addToTarget(button, source) {
|
|
1805
|
+
var made = insertFromToolbar(button, { region: activeTarget, before: null }, source);
|
|
1806
|
+
if (made && made.scrollIntoView) { made.scrollIntoView({ behavior: 'smooth' }); }
|
|
1807
|
+
}
|
|
1808
|
+
|
|
1730
1809
|
function init() {
|
|
1731
1810
|
// The node whose settings were open is gone - deleted, say - and
|
|
1732
1811
|
// its panel with it
|
|
@@ -1754,12 +1833,21 @@ function build(instance, baseElem, optionsOrMethod) {
|
|
|
1754
1833
|
makeResizable();
|
|
1755
1834
|
switchLayout(curView);
|
|
1756
1835
|
refreshPreviews(canvas);
|
|
1836
|
+
|
|
1837
|
+
// Deleted, or taken out some other way, it is a target no more
|
|
1838
|
+
if (activeTarget && !canvas.contains(activeTarget)) {
|
|
1839
|
+
changeTarget(null);
|
|
1840
|
+
} else if (activeTarget) {
|
|
1841
|
+
dom.addClass(activeTarget, 'ge-active-target');
|
|
1842
|
+
}
|
|
1757
1843
|
}
|
|
1758
1844
|
|
|
1759
1845
|
function deinit() {
|
|
1760
1846
|
// Its panel goes home to its drawer first, and both go together
|
|
1761
1847
|
closeSettings();
|
|
1762
1848
|
dom.removeClass(canvas, 'ge-editing ge-drag-drawer ge-dropping');
|
|
1849
|
+
// The mark goes, the target stays: getHtml comes straight back
|
|
1850
|
+
if (activeTarget) { dom.removeClass(activeTarget, 'ge-active-target'); }
|
|
1763
1851
|
// Before the drawers and the text blocks come off: an editor
|
|
1764
1852
|
// plugin closes its editors here, and finds them where it left them
|
|
1765
1853
|
plugins('onBeforeDeinit');
|
|
@@ -1821,6 +1909,7 @@ function build(instance, baseElem, optionsOrMethod) {
|
|
|
1821
1909
|
// The html being edited is what the canvas is left with
|
|
1822
1910
|
if (sourceOpen) { closeSource(); }
|
|
1823
1911
|
deinit();
|
|
1912
|
+
activeTarget = null;
|
|
1824
1913
|
removeConfirmModal();
|
|
1825
1914
|
removeSettingsPanels();
|
|
1826
1915
|
removeDialog();
|
|
@@ -2973,30 +3062,34 @@ function build(instance, baseElem, optionsOrMethod) {
|
|
|
2973
3062
|
|
|
2974
3063
|
createMoveTool(drawer);
|
|
2975
3064
|
|
|
2976
|
-
|
|
2977
|
-
|
|
2978
|
-
|
|
2979
|
-
|
|
2980
|
-
|
|
2981
|
-
|
|
3065
|
+
if (settings.resize.tools !== false) {
|
|
3066
|
+
createTool(drawer, t('tool.column_narrower'), 'ge-decrease-col-width', 'bi bi-dash-lg', function(e) {
|
|
3067
|
+
resizeColumn(col, e.shiftKey
|
|
3068
|
+
? smallest(settings.valid_col_sizes)
|
|
3069
|
+
: stepThrough(settings.valid_col_sizes.filter(isUnits), currentUnits(col), -1),
|
|
3070
|
+
'tool');
|
|
3071
|
+
});
|
|
2982
3072
|
|
|
2983
|
-
|
|
2984
|
-
|
|
2985
|
-
|
|
2986
|
-
|
|
2987
|
-
|
|
2988
|
-
|
|
3073
|
+
createTool(drawer, t('tool.column_wider'), 'ge-increase-col-width', 'bi bi-plus-lg', function(e) {
|
|
3074
|
+
resizeColumn(col, e.shiftKey
|
|
3075
|
+
? widestFor(col)
|
|
3076
|
+
: stepThrough(settings.valid_col_sizes.filter(isUnits), currentUnits(col), 1),
|
|
3077
|
+
'tool');
|
|
3078
|
+
});
|
|
3079
|
+
}
|
|
2989
3080
|
|
|
2990
|
-
|
|
2991
|
-
|
|
2992
|
-
|
|
2993
|
-
|
|
2994
|
-
|
|
2995
|
-
|
|
3081
|
+
if (settings.indent.tools !== false) {
|
|
3082
|
+
createTool(drawer, t('tool.indent_decrease'), 'ge-decrease-col-offset', 'bi bi-text-indent-right', function(e) {
|
|
3083
|
+
indentColumn(col, e.shiftKey
|
|
3084
|
+
? smallest(settings.valid_col_offsets)
|
|
3085
|
+
: stepThrough(settings.valid_col_offsets, currentOffset(col), -1),
|
|
3086
|
+
'tool');
|
|
3087
|
+
});
|
|
2996
3088
|
|
|
2997
|
-
|
|
2998
|
-
|
|
2999
|
-
|
|
3089
|
+
createTool(drawer, t('tool.indent_increase'), 'ge-increase-col-offset', 'bi bi-text-indent-left', function(e) {
|
|
3090
|
+
indentColumn(col, e.shiftKey ? deepestFor(col) : stepThrough(settings.valid_col_offsets, currentOffset(col), 1), 'tool');
|
|
3091
|
+
});
|
|
3092
|
+
}
|
|
3000
3093
|
|
|
3001
3094
|
addSettingsTool(drawer, col, settings.col_classes);
|
|
3002
3095
|
|
|
@@ -5141,6 +5234,23 @@ function build(instance, baseElem, optionsOrMethod) {
|
|
|
5141
5234
|
* finishes before the canvas is rebuilt. The ones that do something,
|
|
5142
5235
|
* rather than answer something, hand back the instance, to chain.
|
|
5143
5236
|
*/
|
|
5237
|
+
function apiSetActiveTarget(value) {
|
|
5238
|
+
if (!settings.active_target) {
|
|
5239
|
+
warnOnceHere('active_target', 'setActiveTarget needs the active_target setting: without it, it does nothing');
|
|
5240
|
+
return;
|
|
5241
|
+
}
|
|
5242
|
+
if (value === null || value === undefined) { changeTarget(null); return; }
|
|
5243
|
+
|
|
5244
|
+
var node = nodeFrom(value);
|
|
5245
|
+
if (!isTarget(node)) {
|
|
5246
|
+
var named = typeof value === 'string' ? value : (node ? '<' + node.tagName.toLowerCase() + '>' : String(value));
|
|
5247
|
+
warn('setActiveTarget: ' + named + ' is not a column or a region of the canvas');
|
|
5248
|
+
return;
|
|
5249
|
+
}
|
|
5250
|
+
|
|
5251
|
+
changeTarget(node);
|
|
5252
|
+
}
|
|
5253
|
+
|
|
5144
5254
|
var own = {
|
|
5145
5255
|
getHtml: getHtml,
|
|
5146
5256
|
getPlainHtml: getPlainHtml,
|
|
@@ -5171,6 +5281,8 @@ function build(instance, baseElem, optionsOrMethod) {
|
|
|
5171
5281
|
setLocale: setLocale,
|
|
5172
5282
|
getUtility: getUtility,
|
|
5173
5283
|
setUtility: setUtility,
|
|
5284
|
+
getActiveTarget: function() { return settings.active_target ? activeTarget : null; },
|
|
5285
|
+
setActiveTarget: apiSetActiveTarget,
|
|
5174
5286
|
};
|
|
5175
5287
|
|
|
5176
5288
|
Object.keys(own).forEach(function(name) {
|
|
@@ -276,6 +276,16 @@ function shadowControl(ge, node, property, changed) {
|
|
|
276
276
|
}
|
|
277
277
|
writeValue(input.value, input);
|
|
278
278
|
});
|
|
279
|
+
|
|
280
|
+
// Back to the builder, when it can hold the value: one shadow, or none
|
|
281
|
+
if (parseShadow(value, box)) {
|
|
282
|
+
var toBuilder = holder.appendChild(dom.element('a', { href: '#', 'class': 'ge-inline-style-shadow-mode' }, ge.t('inline_style.shadow_builder_mode')));
|
|
283
|
+
toBuilder.addEventListener('click', function(e) {
|
|
284
|
+
e.preventDefault();
|
|
285
|
+
textMode = false;
|
|
286
|
+
render();
|
|
287
|
+
});
|
|
288
|
+
}
|
|
279
289
|
}
|
|
280
290
|
|
|
281
291
|
var shown = null; // The value the builder or the text was last built for
|
|
@@ -210,6 +210,7 @@ GridEditor.locales.es = {
|
|
|
210
210
|
'inline_style.shadow_color': 'Color',
|
|
211
211
|
'inline_style.shadow_inset': 'Interior',
|
|
212
212
|
'inline_style.shadow_text_mode': 'Editar como texto',
|
|
213
|
+
'inline_style.shadow_builder_mode': 'Editar con el constructor',
|
|
213
214
|
'inline_style.prop_width': 'Ancho',
|
|
214
215
|
'inline_style.prop_height': 'Alto',
|
|
215
216
|
'inline_style.prop_min_width': 'Ancho mínimo',
|
|
@@ -59,6 +59,7 @@ Object.assign(GridEditor.locales.en, {
|
|
|
59
59
|
'inline_style.shadow_color': 'Color',
|
|
60
60
|
'inline_style.shadow_inset': 'Inset',
|
|
61
61
|
'inline_style.shadow_text_mode': 'Edit as text',
|
|
62
|
+
'inline_style.shadow_builder_mode': 'Edit with the builder',
|
|
62
63
|
'inline_style.prop_width': 'Width',
|
|
63
64
|
'inline_style.prop_height': 'Height',
|
|
64
65
|
'inline_style.prop_min_width': 'Min width',
|
package/src/less/grideditor.less
CHANGED
|
@@ -516,6 +516,16 @@
|
|
|
516
516
|
outline-offset: 1px;
|
|
517
517
|
}
|
|
518
518
|
|
|
519
|
+
/* Where the toolbar's buttons add, with active_target. A node that is both
|
|
520
|
+
shows both: this one a little further out */
|
|
521
|
+
.ge-canvas.ge-editing .ge-active-target {
|
|
522
|
+
outline: 2px dashed var(--bs-success, #198754);
|
|
523
|
+
outline-offset: -2px;
|
|
524
|
+
}
|
|
525
|
+
.ge-canvas.ge-editing .ge-active-target.ge-settings-target {
|
|
526
|
+
box-shadow: 0 0 0 4px var(--bs-success, #198754);
|
|
527
|
+
}
|
|
528
|
+
|
|
519
529
|
/* While editing */
|
|
520
530
|
.ge-canvas.ge-editing {
|
|
521
531
|
|
package/types/grideditor.d.ts
CHANGED
|
@@ -107,6 +107,8 @@ export interface GridEditorOptions {
|
|
|
107
107
|
text_tools?: HostTool[];
|
|
108
108
|
drag_handle?: 'tool' | 'drawer';
|
|
109
109
|
toolbar_drag?: 'auto' | boolean;
|
|
110
|
+
/** A click in a column or a section makes it where the toolbar's buttons add. Default false. */
|
|
111
|
+
active_target?: boolean;
|
|
110
112
|
/** The plugins to use, of any kind; null is every one loaded. */
|
|
111
113
|
plugins?: string[] | null;
|
|
112
114
|
/** The text editors offered, in order. */
|
|
@@ -124,7 +126,10 @@ export interface GridEditorOptions {
|
|
|
124
126
|
add_column?: { size?: ColumnSize | null; picker?: boolean; delay?: number };
|
|
125
127
|
layout_modes?: View[];
|
|
126
128
|
default_view?: View;
|
|
127
|
-
|
|
129
|
+
/** enabled is the handle on the column's edge, tools the narrower and wider tools in its drawer. */
|
|
130
|
+
resize?: { enabled?: boolean; tools?: boolean; handles?: string; balance?: 'next' | false };
|
|
131
|
+
/** tools is the indent tools in a column's drawer. */
|
|
132
|
+
indent?: { tools?: boolean };
|
|
128
133
|
/** A textarea whose html the canvas starts with. */
|
|
129
134
|
source_textarea?: Target | '';
|
|
130
135
|
edit_source?: boolean;
|
|
@@ -215,6 +220,13 @@ export interface ViewChangePayload {
|
|
|
215
220
|
to: View;
|
|
216
221
|
}
|
|
217
222
|
|
|
223
|
+
/** The active target changed: the column or region the toolbar adds to, or null for the canvas. */
|
|
224
|
+
export interface TargetChangePayload {
|
|
225
|
+
canvas: HTMLElement;
|
|
226
|
+
target: HTMLElement | null;
|
|
227
|
+
from: HTMLElement | null;
|
|
228
|
+
}
|
|
229
|
+
|
|
218
230
|
/** The events, by name, with their payloads. Adding fires a specific name and the generic one. */
|
|
219
231
|
export interface GridEditorEventMap {
|
|
220
232
|
'grideditor:before-add': Payload;
|
|
@@ -252,6 +264,7 @@ export interface GridEditorEventMap {
|
|
|
252
264
|
'grideditor:after-copy': Payload;
|
|
253
265
|
'grideditor:popup-orphan': PopupOrphanPayload;
|
|
254
266
|
'grideditor:view-change': ViewChangePayload;
|
|
267
|
+
'grideditor:target-change': TargetChangePayload;
|
|
255
268
|
}
|
|
256
269
|
|
|
257
270
|
/** An event the editor dispatches on its canvas: a CustomEvent whose detail is the payload. */
|
|
@@ -340,6 +353,10 @@ export declare class GridEditor {
|
|
|
340
353
|
/** Take the editor off: the markup stays, everything else goes. */
|
|
341
354
|
destroy(): this;
|
|
342
355
|
changeView(view: View): this;
|
|
356
|
+
/** The column or region the toolbar adds to, or null. Null without active_target. */
|
|
357
|
+
getActiveTarget(): HTMLElement | null;
|
|
358
|
+
/** Make a column or region, or the first a selector matches, where the toolbar adds; null for none. */
|
|
359
|
+
setActiveTarget(target: HTMLElement | string | null): this;
|
|
343
360
|
getView(): View;
|
|
344
361
|
setLocale(code: string): this;
|
|
345
362
|
createRow(layout?: RowLayout, options?: Placement): HTMLElement | null;
|