@themarioga/grid-editor 5.2.0 → 5.3.1

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.
Files changed (48) hide show
  1. package/CHANGELOG.md +41 -0
  2. package/README.md +31 -1
  3. package/dist/grideditor.css +60 -0
  4. package/dist/grideditor.min.css +1 -1
  5. package/dist/grideditor.min.css.map +1 -1
  6. package/dist/jquery.grideditor.bundle.min.js +2 -2
  7. package/dist/jquery.grideditor.js +395 -26
  8. package/dist/jquery.grideditor.min.js +1 -1
  9. package/dist/jquery.grideditor.min.js.map +1 -1
  10. package/dist/locales/grideditor.es.js +11 -0
  11. package/dist/locales/grideditor.es.min.js +1 -1
  12. package/dist/locales/grideditor.es.min.js.map +1 -1
  13. package/dist/plugins/grideditor.ckeditor.js +5 -0
  14. package/dist/plugins/grideditor.ckeditor.min.js +1 -1
  15. package/dist/plugins/grideditor.ckeditor.min.js.map +1 -1
  16. package/dist/plugins/grideditor.clipboard.js +8 -7
  17. package/dist/plugins/grideditor.clipboard.min.js +1 -1
  18. package/dist/plugins/grideditor.clipboard.min.js.map +1 -1
  19. package/dist/plugins/grideditor.spacing.js +1 -1
  20. package/dist/plugins/grideditor.spacing.min.js +1 -1
  21. package/dist/plugins/grideditor.spacing.min.js.map +1 -1
  22. package/dist/plugins/grideditor.summernote.js +5 -0
  23. package/dist/plugins/grideditor.summernote.min.js +1 -1
  24. package/dist/plugins/grideditor.summernote.min.js.map +1 -1
  25. package/dist/plugins/grideditor.textalign.js +1 -1
  26. package/dist/plugins/grideditor.textalign.min.js +1 -1
  27. package/dist/plugins/grideditor.textalign.min.js.map +1 -1
  28. package/dist/plugins/grideditor.tinymce.js +5 -0
  29. package/dist/plugins/grideditor.tinymce.min.js +1 -1
  30. package/dist/plugins/grideditor.tinymce.min.js.map +1 -1
  31. package/dist/plugins/grideditor.visibility.js +3 -3
  32. package/dist/plugins/grideditor.visibility.min.js +1 -1
  33. package/dist/plugins/grideditor.visibility.min.js.map +1 -1
  34. package/docs/events.md +5 -2
  35. package/docs/locale-keys.md +23 -1
  36. package/docs/plugins.md +7 -2
  37. package/example/attributes.html +2 -2
  38. package/package.json +1 -1
  39. package/src/js/jquery.grideditor.js +380 -26
  40. package/src/js/locales/grideditor.es.js +11 -0
  41. package/src/js/plugins/grideditor.ckeditor.js +5 -0
  42. package/src/js/plugins/grideditor.clipboard.js +8 -7
  43. package/src/js/plugins/grideditor.spacing.js +1 -1
  44. package/src/js/plugins/grideditor.summernote.js +5 -0
  45. package/src/js/plugins/grideditor.textalign.js +1 -1
  46. package/src/js/plugins/grideditor.tinymce.js +5 -0
  47. package/src/js/plugins/grideditor.visibility.js +3 -3
  48. package/src/less/grideditor.less +70 -0
@@ -2,8 +2,9 @@
2
2
  * Copy and paste for grid-editor.
3
3
  *
4
4
  * A feature plugin: load this file after the editor and every row, column,
5
- * section, container and element gets a copy tool, and every place one of
6
- * them can go gets a paste tool while there is something copied that fits.
5
+ * section, text block, container and element gets a copy tool, and every
6
+ * place one of them can go gets a paste tool while there is something copied
7
+ * that fits.
7
8
  * What it can ask the editor for is the handle its factory is called with,
8
9
  * described in docs/plugins.md.
9
10
  *
@@ -37,10 +38,10 @@ var editors = 0;
37
38
  /**
38
39
  * What each drawer takes when something is pasted into it, by the kind of the
39
40
  * node the drawer belongs to. A category is what was copied: a row, a column,
40
- * a section, a container of any type, an element.
41
+ * a section, a text block, a container of any type, an element.
41
42
  */
42
43
  var TARGETS = {
43
- column: ['row', 'container', 'element'],
44
+ column: ['row', 'text', 'container', 'element'],
44
45
  row: ['column'],
45
46
  section: ['row'],
46
47
  };
@@ -117,7 +118,7 @@ $.fn.gridEditor.features.clipboard = function(ge) {
117
118
  function categoryOf(kind) {
118
119
  if ($.fn.gridEditor.containers[kind]) { return 'container'; }
119
120
 
120
- return ['row', 'column', 'section', 'element'].indexOf(kind) !== -1 ? kind : null;
121
+ return ['row', 'column', 'section', 'text', 'element'].indexOf(kind) !== -1 ? kind : null;
121
122
  }
122
123
 
123
124
  function copy(node, kind) {
@@ -128,7 +129,7 @@ $.fn.gridEditor.features.clipboard = function(ge) {
128
129
 
129
130
  // The canvas came back with new drawers: the one to flash is the
130
131
  // node's new copy tool
131
- var tool = node.children('.ge-tools-drawer').find('> .ge-copy');
132
+ var tool = ge.drawerOf(node).find('> .ge-copy');
132
133
  tool.addClass('ge-copied').find('i').attr('class', 'bi bi-check2');
133
134
  setTimeout(function() {
134
135
  tool.removeClass('ge-copied').find('i').attr('class', 'bi bi-copy');
@@ -145,7 +146,7 @@ $.fn.gridEditor.features.clipboard = function(ge) {
145
146
  // An element goes into the column's last content area. With none,
146
147
  // the column's next init wraps it in one of its own
147
148
  if (clip.category === 'element') {
148
- var area = target.children('.ge-content').last();
149
+ var area = target.find('> .ge-text-block > .ge-content, > .ge-content').last();
149
150
  if (area.length) { into = area; }
150
151
  }
151
152
 
@@ -252,7 +252,7 @@ $.fn.gridEditor.utilities.spacing = function(ge) {
252
252
  name: key + side,
253
253
  prefix: key + side,
254
254
  values: values,
255
- appliesTo: ['row', 'column', 'element', 'container'],
255
+ appliesTo: ['row', 'column', 'text', 'element', 'container'],
256
256
  labelKey: labelKey,
257
257
  panel: false,
258
258
  choices: function() {
@@ -14,10 +14,15 @@
14
14
  */
15
15
  (function($) {
16
16
 
17
+ $.extend($.fn.gridEditor.locales.en, {
18
+ 'text.summernote': 'Summernote',
19
+ });
20
+
17
21
  var INITIAL_CONTENT = '<p>Lorem ipsum dolores</p>';
18
22
 
19
23
  $.fn.gridEditor.texts.summernote = function(ge) {
20
24
  return {
25
+ labelKey: 'text.summernote',
21
26
  initialContent: INITIAL_CONTENT,
22
27
  missingKey: 'error.summernote_missing',
23
28
 
@@ -39,7 +39,7 @@ $.fn.gridEditor.utilities.textalign = function(ge) {
39
39
  name: 'text-align',
40
40
  prefix: 'text',
41
41
  values: ['start', 'center', 'end'],
42
- appliesTo: ['row', 'column', 'element', 'container'],
42
+ appliesTo: ['row', 'column', 'text', 'element', 'container'],
43
43
  labelKey: 'utility.text_align',
44
44
  label: label,
45
45
 
@@ -14,6 +14,10 @@
14
14
  */
15
15
  (function($) {
16
16
 
17
+ $.extend($.fn.gridEditor.locales.en, {
18
+ 'text.tinymce': 'tinyMCE',
19
+ });
20
+
17
21
  // tinyMCE snapshots the target element's attributes when an inline editor is
18
22
  // created and restores them on remove(), so this has to run *after* remove()
19
23
  // to keep the grid editor's own class and tinyMCE's leftovers off the element.
@@ -33,6 +37,7 @@
33
37
 
34
38
  $.fn.gridEditor.texts.tinymce = function(ge) {
35
39
  return {
40
+ labelKey: 'text.tinymce',
36
41
  initialContent: INITIAL_CONTENT,
37
42
  missingKey: 'error.tinymce_missing',
38
43
 
@@ -32,7 +32,7 @@ $.extend($.fn.gridEditor.locales.en, {
32
32
  /** A node that carries any class of the family, at any breakpoint. */
33
33
  var CLASS_PATTERN = /(?:^|\s)d-(?:(?:sm|md|lg|xl|xxl)-)?(?:none|block|flex)(?:\s|$)/;
34
34
 
35
- var NODES = '.row, .column, .ge-element, [data-ge-container]';
35
+ var NODES = '.row, .column, .ge-content, .ge-element, [data-ge-container]';
36
36
 
37
37
  $.fn.gridEditor.utilities.visibility = function(ge) {
38
38
 
@@ -44,7 +44,7 @@ $.fn.gridEditor.utilities.visibility = function(ge) {
44
44
  }
45
45
 
46
46
  function applies(node, kind) {
47
- return kind === 'row' || kind === 'column' || kind === 'element' ||
47
+ return kind === 'row' || kind === 'column' || kind === 'element' || kind === 'text' ||
48
48
  node.is('[data-ge-container]');
49
49
  }
50
50
 
@@ -143,7 +143,7 @@ $.fn.gridEditor.utilities.visibility = function(ge) {
143
143
  name: 'visibility',
144
144
  prefix: 'd',
145
145
  values: ['none', 'block', 'flex'],
146
- appliesTo: ['row', 'column', 'element', 'container'],
146
+ appliesTo: ['row', 'column', 'text', 'element', 'container'],
147
147
  labelKey: 'utility.visibility',
148
148
 
149
149
  /** Hidden, or shown the way this kind of node is shown. */
@@ -5,6 +5,8 @@
5
5
  @colTextColor: darken(@colColor, 10%);
6
6
  @elementColor: #7B5EA7;
7
7
  @elementTextColor: darken(@elementColor, 5%);
8
+ @textColor: #5A6F8A;
9
+ @textTextColor: darken(@textColor, 5%);
8
10
  @containerColor: #1D8A5E;
9
11
  @containerTextColor: darken(@containerColor, 5%);
10
12
 
@@ -549,6 +551,74 @@
549
551
  }
550
552
  }
551
553
 
554
+ /* A text block: a content area and, beside it rather than inside,
555
+ where the text editor would take it, its drawer */
556
+ .ge-text-block {
557
+ position: relative;
558
+ outline: 1px dashed fadeout(@textColor, 40%);
559
+ margin-bottom: @editGutter;
560
+
561
+ /* Over the text rather than above it: nearly every column has a
562
+ text, and a bar for each would make every column taller. It shows
563
+ while it is wanted - the pointer over the text, the text being
564
+ edited or holding the focus, its settings open, a drag under way -
565
+ and takes no room either way. */
566
+ > .ge-text-drawer {
567
+ position: absolute;
568
+ top: 0;
569
+ right: 0;
570
+ z-index: 5;
571
+ width: auto;
572
+ margin: 0;
573
+ border-radius: 0 0 0 4px;
574
+ background: mix(@textColor, #fff, 18%);
575
+ box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
576
+ opacity: 0;
577
+ visibility: hidden;
578
+ /* Hidden only once it has faded, shown at once */
579
+ transition: opacity 120ms ease, visibility 0s linear 120ms;
580
+
581
+ > a {
582
+ color: @textTextColor;
583
+ padding: 2px 5px;
584
+ }
585
+ > a.ge-text-info {
586
+ cursor: default;
587
+ }
588
+ > a.ge-text-missing {
589
+ color: #b02a37;
590
+ }
591
+ }
592
+
593
+ &:hover,
594
+ &:focus-within,
595
+ &.ge-drag-chosen,
596
+ &:has(> .ge-rte-active),
597
+ &:has(> .ge-text-drawer.ge-picker-open),
598
+ &:has(> .ge-text-drawer > .ge-details[style*="block"]) {
599
+ > .ge-text-drawer {
600
+ opacity: 1;
601
+ visibility: visible;
602
+ transition-delay: 0s;
603
+ }
604
+ }
605
+
606
+ /* With its settings open it spans the text, so the panel has room */
607
+ &:has(> .ge-text-drawer > .ge-details[style*="block"]) > .ge-text-drawer {
608
+ left: 0;
609
+ border-radius: 0;
610
+ }
611
+ }
612
+
613
+ /* A column with nothing in it but its drawer still has room to drop a
614
+ block into */
615
+ .column:not(:has(> :not(.ge-tools-drawer, .ge-resize-handle)))::after {
616
+ content: '';
617
+ display: block;
618
+ min-height: 40px;
619
+ border: 1px dashed fadeout(@colColor, 50%);
620
+ }
621
+
552
622
  /* Sorting. The dragged node stays in the list and shows where it would
553
623
  land - that is the placeholder - while a copy of it follows the
554
624
  pointer. */