@themarioga/grid-editor 6.0.0 → 7.0.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.
Files changed (147) hide show
  1. package/AUTO_SAVE.md +2 -2
  2. package/BUILDING.md +45 -29
  3. package/CHANGELOG.md +47 -0
  4. package/README.md +137 -85
  5. package/UPGRADING.md +119 -0
  6. package/dist/grideditor.bundle.min.js +14 -0
  7. package/dist/grideditor.d.ts +335 -0
  8. package/dist/grideditor.esm.js +3977 -0
  9. package/dist/grideditor.jquery.js +253 -0
  10. package/dist/grideditor.jquery.min.js +1 -0
  11. package/dist/grideditor.jquery.min.js.map +7 -0
  12. package/dist/grideditor.js +3983 -0
  13. package/dist/grideditor.min.js +6 -0
  14. package/dist/grideditor.min.js.map +7 -0
  15. package/dist/locales/grideditor.es.esm.js +158 -0
  16. package/dist/locales/grideditor.es.js +164 -168
  17. package/dist/locales/grideditor.es.min.js +6 -2
  18. package/dist/locales/grideditor.es.min.js.map +7 -1
  19. package/dist/plugins/grideditor.accordion.esm.js +294 -0
  20. package/dist/plugins/grideditor.accordion.js +286 -180
  21. package/dist/plugins/grideditor.accordion.min.js +1 -2
  22. package/dist/plugins/grideditor.accordion.min.js.map +7 -1
  23. package/dist/plugins/grideditor.alignment.esm.js +55 -0
  24. package/dist/plugins/grideditor.alignment.js +58 -77
  25. package/dist/plugins/grideditor.alignment.min.js +1 -2
  26. package/dist/plugins/grideditor.alignment.min.js.map +7 -1
  27. package/dist/plugins/grideditor.card.esm.js +73 -0
  28. package/dist/plugins/grideditor.card.js +74 -64
  29. package/dist/plugins/grideditor.card.min.js +1 -2
  30. package/dist/plugins/grideditor.card.min.js.map +7 -1
  31. package/dist/plugins/grideditor.ckeditor.esm.js +500 -0
  32. package/dist/plugins/grideditor.ckeditor.js +484 -449
  33. package/dist/plugins/grideditor.ckeditor.min.js +1 -2
  34. package/dist/plugins/grideditor.ckeditor.min.js.map +7 -1
  35. package/dist/plugins/grideditor.clipboard.esm.js +326 -0
  36. package/dist/plugins/grideditor.clipboard.js +298 -235
  37. package/dist/plugins/grideditor.clipboard.min.js +1 -2
  38. package/dist/plugins/grideditor.clipboard.min.js.map +7 -1
  39. package/dist/plugins/grideditor.codemirror-inline.esm.js +205 -0
  40. package/dist/plugins/grideditor.codemirror-inline.js +188 -168
  41. package/dist/plugins/grideditor.codemirror-inline.min.js +1 -2
  42. package/dist/plugins/grideditor.codemirror-inline.min.js.map +7 -1
  43. package/dist/plugins/grideditor.codemirror.esm.js +63 -0
  44. package/dist/plugins/grideditor.codemirror.js +60 -71
  45. package/dist/plugins/grideditor.codemirror.min.js +1 -2
  46. package/dist/plugins/grideditor.codemirror.min.js.map +7 -1
  47. package/dist/plugins/grideditor.elements.esm.js +271 -0
  48. package/dist/plugins/grideditor.elements.js +256 -149
  49. package/dist/plugins/grideditor.elements.min.js +1 -2
  50. package/dist/plugins/grideditor.elements.min.js.map +7 -1
  51. package/dist/plugins/grideditor.float.esm.js +34 -0
  52. package/dist/plugins/grideditor.float.js +37 -52
  53. package/dist/plugins/grideditor.float.min.js +1 -2
  54. package/dist/plugins/grideditor.float.min.js.map +7 -1
  55. package/dist/plugins/grideditor.gutters.esm.js +143 -0
  56. package/dist/plugins/grideditor.gutters.js +134 -131
  57. package/dist/plugins/grideditor.gutters.min.js +1 -2
  58. package/dist/plugins/grideditor.gutters.min.js.map +7 -1
  59. package/dist/plugins/grideditor.order.esm.js +189 -0
  60. package/dist/plugins/grideditor.order.js +170 -182
  61. package/dist/plugins/grideditor.order.min.js +1 -2
  62. package/dist/plugins/grideditor.order.min.js.map +7 -1
  63. package/dist/plugins/grideditor.popup.esm.js +187 -0
  64. package/dist/plugins/grideditor.popup.js +183 -134
  65. package/dist/plugins/grideditor.popup.min.js +1 -2
  66. package/dist/plugins/grideditor.popup.min.js.map +7 -1
  67. package/dist/plugins/grideditor.sections.esm.js +271 -0
  68. package/dist/plugins/grideditor.sections.js +250 -173
  69. package/dist/plugins/grideditor.sections.min.js +1 -2
  70. package/dist/plugins/grideditor.sections.min.js.map +7 -1
  71. package/dist/plugins/grideditor.spacing.esm.js +318 -0
  72. package/dist/plugins/grideditor.spacing.js +296 -272
  73. package/dist/plugins/grideditor.spacing.min.js +1 -2
  74. package/dist/plugins/grideditor.spacing.min.js.map +7 -1
  75. package/dist/plugins/grideditor.summernote.esm.js +509 -0
  76. package/dist/plugins/grideditor.summernote.js +493 -427
  77. package/dist/plugins/grideditor.summernote.min.js +1 -2
  78. package/dist/plugins/grideditor.summernote.min.js.map +7 -1
  79. package/dist/plugins/grideditor.tabs.esm.js +237 -0
  80. package/dist/plugins/grideditor.tabs.js +233 -139
  81. package/dist/plugins/grideditor.tabs.min.js +1 -2
  82. package/dist/plugins/grideditor.tabs.min.js.map +7 -1
  83. package/dist/plugins/grideditor.textalign.esm.js +40 -0
  84. package/dist/plugins/grideditor.textalign.js +43 -56
  85. package/dist/plugins/grideditor.textalign.min.js +1 -2
  86. package/dist/plugins/grideditor.textalign.min.js.map +7 -1
  87. package/dist/plugins/grideditor.tinymce.esm.js +519 -0
  88. package/dist/plugins/grideditor.tinymce.js +502 -490
  89. package/dist/plugins/grideditor.tinymce.min.js +1 -2
  90. package/dist/plugins/grideditor.tinymce.min.js.map +7 -1
  91. package/dist/plugins/grideditor.visibility.esm.js +158 -0
  92. package/dist/plugins/grideditor.visibility.js +140 -149
  93. package/dist/plugins/grideditor.visibility.min.js +1 -2
  94. package/dist/plugins/grideditor.visibility.min.js.map +7 -1
  95. package/docs/events.md +47 -21
  96. package/docs/locale-keys.md +6 -0
  97. package/docs/plugins.md +47 -25
  98. package/example/adapter.html +112 -0
  99. package/example/attributes.html +85 -61
  100. package/example/autocols.html +9 -9
  101. package/example/autosave.html +13 -14
  102. package/example/basic.html +4 -5
  103. package/example/breakpoints.html +5 -6
  104. package/example/ckeditor.html +4 -5
  105. package/example/clipboard.html +11 -10
  106. package/example/codemirror.html +9 -7
  107. package/example/containers.html +7 -8
  108. package/example/custom_editor.html +53 -34
  109. package/example/elements.html +10 -11
  110. package/example/index.html +16 -2
  111. package/example/locale.html +6 -7
  112. package/example/plugins.html +44 -29
  113. package/example/summernote.html +6 -5
  114. package/example/utilities.html +17 -13
  115. package/example/wrap_content.html +9 -9
  116. package/package.json +43 -12
  117. package/src/js/dom.js +401 -0
  118. package/src/js/grideditor.classic.js +16 -0
  119. package/src/js/grideditor.jquery.js +325 -0
  120. package/src/js/{jquery.grideditor.js → grideditor.js} +1284 -1124
  121. package/src/js/locales/grideditor.es.js +163 -156
  122. package/src/js/plugins/grideditor.accordion.js +97 -77
  123. package/src/js/plugins/grideditor.alignment.js +5 -7
  124. package/src/js/plugins/grideditor.card.js +23 -23
  125. package/src/js/plugins/grideditor.ckeditor.js +107 -106
  126. package/src/js/plugins/grideditor.clipboard.js +49 -37
  127. package/src/js/plugins/grideditor.codemirror-inline.js +50 -37
  128. package/src/js/plugins/grideditor.codemirror.js +9 -10
  129. package/src/js/plugins/grideditor.elements.js +57 -33
  130. package/src/js/plugins/grideditor.float.js +4 -6
  131. package/src/js/plugins/grideditor.gutters.js +20 -15
  132. package/src/js/plugins/grideditor.order.js +28 -25
  133. package/src/js/plugins/grideditor.popup.js +63 -51
  134. package/src/js/plugins/grideditor.sections.js +39 -32
  135. package/src/js/plugins/grideditor.spacing.js +42 -45
  136. package/src/js/plugins/grideditor.summernote.js +112 -76
  137. package/src/js/plugins/grideditor.tabs.js +65 -57
  138. package/src/js/plugins/grideditor.textalign.js +4 -6
  139. package/src/js/plugins/grideditor.tinymce.js +147 -139
  140. package/src/js/plugins/grideditor.visibility.js +24 -25
  141. package/src/js/register.js +18 -0
  142. package/src/js/text/grideditor.text.js +77 -56
  143. package/types/grideditor.d.ts +335 -0
  144. package/dist/jquery.grideditor.bundle.min.js +0 -10
  145. package/dist/jquery.grideditor.js +0 -4927
  146. package/dist/jquery.grideditor.min.js +0 -2
  147. package/dist/jquery.grideditor.min.js.map +0 -1
@@ -1,56 +1,41 @@
1
- /**
2
- * Floating elements for grid-editor.
3
- *
4
- * A utility plugin: load this file after the editor and after the elements
5
- * plugin, and an element can float to the start or the end of its content
6
- * area per breakpoint, with the text around it, using Bootstrap's
7
- * float-{breakpoint}-start, -end and -none classes. What it can ask the
8
- * editor for is the handle its factory is called with, described in
9
- * docs/plugins.md.
10
- *
11
- * <script src="dist/jquery.grideditor.min.js"></script>
12
- * <script src="dist/plugins/grideditor.elements.min.js"></script>
13
- * <script src="dist/plugins/grideditor.float.min.js"></script>
14
- *
15
- * Elements only. A floated row or column stops being part of the grid, and a
16
- * container sits beside the content areas rather than in their text.
17
- */
18
- (function($) {
19
-
20
- $.extend($.fn.gridEditor.locales.en, {
21
- 'utility.float': 'Float',
22
- 'utility.float_start': 'Start',
23
- 'utility.float_end': 'End',
24
- 'utility.float_none': 'None',
25
- });
26
-
27
- /** Start and end are left and right: Bootstrap's css is left to right. */
28
- var CSS = { start: 'left', end: 'right', none: 'none' };
29
-
30
- $.fn.gridEditor.utilities.float = function(ge) {
31
-
1
+ (() => {
2
+ // src/js/register.js
3
+ var GridEditor = window.GridEditor;
4
+ if (!GridEditor || typeof GridEditor.get !== "function") {
5
+ throw new Error("grid-editor: load grideditor.js (or grideditor.bundle.min.js) before its plugins, its locales and grideditor.jquery.js");
6
+ }
7
+
8
+ // src/js/plugins/grideditor.float.js
9
+ Object.assign(GridEditor.locales.en, {
10
+ "utility.float": "Float",
11
+ "utility.float_start": "Start",
12
+ "utility.float_end": "End",
13
+ "utility.float_none": "None"
14
+ });
15
+ var CSS = { start: "left", end: "right", none: "none" };
16
+ GridEditor.utilities.float = function(ge) {
32
17
  function label(value) {
33
- if (value === 'start') { return ge.t('utility.float_start'); }
34
- if (value === 'end') { return ge.t('utility.float_end'); }
35
-
36
- return ge.t('utility.float_none');
18
+ if (value === "start") {
19
+ return ge.t("utility.float_start");
20
+ }
21
+ if (value === "end") {
22
+ return ge.t("utility.float_end");
23
+ }
24
+ return ge.t("utility.float_none");
37
25
  }
38
-
39
26
  return {
40
- families: [{
41
- name: 'float',
42
- prefix: 'float',
43
- values: ['start', 'end', 'none'],
44
- appliesTo: ['element'],
45
- labelKey: 'utility.float',
46
- label: label,
47
-
48
- /** With no class applying here, whatever the host's css floats it as. */
49
- preview: function(value, node) {
50
- return { float: value === null ? ge.bareStyle(node, 'float', 'float') : CSS[value] };
51
- },
52
- }],
27
+ families: [{
28
+ name: "float",
29
+ prefix: "float",
30
+ values: ["start", "end", "none"],
31
+ appliesTo: ["element"],
32
+ labelKey: "utility.float",
33
+ label,
34
+ /** With no class applying here, whatever the host's css floats it as. */
35
+ preview: function(value, node) {
36
+ return { float: value === null ? ge.bareStyle(node, "float", "float") : CSS[value] };
37
+ }
38
+ }]
53
39
  };
54
- };
55
-
56
- })(jQuery);
40
+ };
41
+ })();
@@ -1,2 +1 @@
1
- (t=>{t.extend(t.fn.gridEditor.locales.en,{"utility.float":"Float","utility.float_start":"Start","utility.float_end":"End","utility.float_none":"None"});var n={start:"left",end:"right",none:"none"};t.fn.gridEditor.utilities.float=function(e){return{families:[{name:"float",prefix:"float",values:["start","end","none"],appliesTo:["element"],labelKey:"utility.float",label:function(t){return"start"===t?e.t("utility.float_start"):"end"===t?e.t("utility.float_end"):e.t("utility.float_none")},preview:function(t,l){return{float:null===t?e.bareStyle(l,"float","float"):n[t]}}}]}}})(jQuery);
2
- //# sourceMappingURL=grideditor.float.min.js.map
1
+ (()=>{var i=window.GridEditor;if(!i||typeof i.get!="function")throw new Error("grid-editor: load grideditor.js (or grideditor.bundle.min.js) before its plugins, its locales and grideditor.jquery.js");Object.assign(i.locales.en,{"utility.float":"Float","utility.float_start":"Start","utility.float_end":"End","utility.float_none":"None"});var l={start:"left",end:"right",none:"none"};i.utilities.float=function(e){function r(t){return t==="start"?e.t("utility.float_start"):t==="end"?e.t("utility.float_end"):e.t("utility.float_none")}return{families:[{name:"float",prefix:"float",values:["start","end","none"],appliesTo:["element"],labelKey:"utility.float",label:r,preview:function(t,o){return{float:t===null?e.bareStyle(o,"float","float"):l[t]}}}]}};})();
@@ -1 +1,7 @@
1
- {"version":3,"file":"grideditor.float.min.js","sources":["../../src/js/plugins/grideditor.float.js"],"names":["$","extend","fn","gridEditor","locales","en","utility.float","utility.float_start","utility.float_end","utility.float_none","CSS","start","end","none","utilities","float","ge","families","name","prefix","values","appliesTo","labelKey","label","value","t","preview","node","bareStyle","jQuery"],"mappings":"CAiBUA,IAEVA,EAAEC,OAAOD,EAAEE,GAAGC,WAAWC,QAAQC,GAAI,CACjCC,gBAAiB,QACjBC,sBAAuB,QACvBC,oBAAqB,MACrBC,qBAAsB,MAC1B,CAAC,EAGD,IAAIC,EAAM,CAAEC,MAAO,OAAQC,IAAK,QAASC,KAAM,MAAO,EAEtDb,EAAEE,GAAGC,WAAWW,UAAUC,MAAQ,SAASC,GASvC,MAAO,CACHC,SAAU,CAAC,CACPC,KAAM,QACNC,OAAQ,QACRC,OAAQ,CAAC,QAAS,MAAO,QACzBC,UAAW,CAAC,WACZC,SAAU,gBACVC,MAdR,SAAeC,GACX,MAAc,UAAVA,EAA4BR,EAAGS,EAAE,qBAAqB,EAC5C,QAAVD,EAA0BR,EAAGS,EAAE,mBAAmB,EAE/CT,EAAGS,EAAE,oBAAoB,CACpC,EAYQC,QAAS,SAASF,EAAOG,GACrB,MAAO,CAAEZ,MAAiB,OAAVS,EAAiBR,EAAGY,UAAUD,EAAM,QAAS,OAAO,EAAIjB,EAAIc,EAAO,CACvF,CACJ,EACJ,CACJ,CAEC,GAAEK,MAAM"}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/js/register.js", "../../src/js/plugins/grideditor.float.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 * Floating elements for grid-editor.\n *\n * A utility plugin: load this file after the editor and after the elements\n * plugin, and an element can float to the start or the end of its content\n * area per breakpoint, with the text around it, using Bootstrap's\n * float-{breakpoint}-start, -end and -none classes. What it can ask the\n * editor for is the handle its factory is called with, described in\n * docs/plugins.md.\n *\n * <script src=\"dist/grideditor.min.js\"></script>\n * <script src=\"dist/plugins/grideditor.elements.min.js\"></script>\n * <script src=\"dist/plugins/grideditor.float.min.js\"></script>\n *\n * Elements only. A floated row or column stops being part of the grid, and a\n * container sits beside the content areas rather than in their text.\n */\nimport { GridEditor } from '../grideditor.js';\n\nObject.assign(GridEditor.locales.en, {\n 'utility.float': 'Float',\n 'utility.float_start': 'Start',\n 'utility.float_end': 'End',\n 'utility.float_none': 'None',\n});\n\n/** Start and end are left and right: Bootstrap's css is left to right. */\nvar CSS = { start: 'left', end: 'right', none: 'none' };\n\nGridEditor.utilities.float = function(ge) {\n\n function label(value) {\n if (value === 'start') { return ge.t('utility.float_start'); }\n if (value === 'end') { return ge.t('utility.float_end'); }\n\n return ge.t('utility.float_none');\n }\n\n return {\n families: [{\n name: 'float',\n prefix: 'float',\n values: ['start', 'end', 'none'],\n appliesTo: ['element'],\n labelKey: 'utility.float',\n label: label,\n\n /** With no class applying here, whatever the host's css floats it as. */\n preview: function(value, node) {\n return { float: value === null ? ge.bareStyle(node, 'float', 'float') : CSS[value] };\n },\n }],\n };\n};\n"],
5
+ "mappings": "MASA,IAAIA,EAAa,OAAO,WAExB,GAAI,CAACA,GAAc,OAAOA,EAAW,KAAQ,WACzC,MAAM,IAAI,MAAM,wHAC0B,ECM9C,OAAO,OAAOC,EAAW,QAAQ,GAAI,CACjC,gBAAiB,QACjB,sBAAuB,QACvB,oBAAqB,MACrB,qBAAsB,MAC1B,CAAC,EAGD,IAAIC,EAAM,CAAE,MAAO,OAAQ,IAAK,QAAS,KAAM,MAAO,EAEtDD,EAAW,UAAU,MAAQ,SAASE,EAAI,CAEtC,SAASC,EAAMC,EAAO,CAClB,OAAIA,IAAU,QAAkBF,EAAG,EAAE,qBAAqB,EACtDE,IAAU,MAAgBF,EAAG,EAAE,mBAAmB,EAE/CA,EAAG,EAAE,oBAAoB,CACpC,CAEA,MAAO,CACH,SAAU,CAAC,CACP,KAAM,QACN,OAAQ,QACR,OAAQ,CAAC,QAAS,MAAO,MAAM,EAC/B,UAAW,CAAC,SAAS,EACrB,SAAU,gBACV,MAAOC,EAGP,QAAS,SAASC,EAAOC,EAAM,CAC3B,MAAO,CAAE,MAAOD,IAAU,KAAOF,EAAG,UAAUG,EAAM,QAAS,OAAO,EAAIJ,EAAIG,CAAK,CAAE,CACvF,CACJ,CAAC,CACL,CACJ",
6
+ "names": ["GridEditor", "GridEditor", "CSS", "ge", "label", "value", "node"]
7
+ }
@@ -0,0 +1,143 @@
1
+ // src/js/plugins/grideditor.gutters.js
2
+ import { GridEditor } from "../grideditor.esm.js";
3
+
4
+ // src/js/dom.js
5
+ function all(root, selector) {
6
+ return root ? Array.prototype.slice.call(root.querySelectorAll(selector)) : [];
7
+ }
8
+ function selfAndAll(root, selector) {
9
+ if (!root) {
10
+ return [];
11
+ }
12
+ var found = all(root, selector);
13
+ if (root.nodeType === 1 && root.matches(selector)) {
14
+ found.unshift(root);
15
+ }
16
+ return found;
17
+ }
18
+ function removeClass(node, names) {
19
+ split(names).forEach(function(name) {
20
+ node.classList.remove(name);
21
+ });
22
+ return node;
23
+ }
24
+ function toggleClass(node, names, state) {
25
+ split(names).forEach(function(name) {
26
+ if (state === void 0) {
27
+ node.classList.toggle(name);
28
+ } else {
29
+ node.classList.toggle(name, !!state);
30
+ }
31
+ });
32
+ return node;
33
+ }
34
+ function split(names) {
35
+ return String(names || "").split(/\s+/).filter(Boolean);
36
+ }
37
+
38
+ // src/js/plugins/grideditor.gutters.js
39
+ Object.assign(GridEditor.locales.en, {
40
+ "utility.gutters": "Gutters",
41
+ "utility.gutters_x": "Horizontal gutters",
42
+ "utility.gutters_y": "Vertical gutters"
43
+ });
44
+ var VALUES = ["0", "1", "2", "3", "4", "5"];
45
+ var SCALE = ["0", ".25rem", ".5rem", "1rem", "1.5rem", "3rem"];
46
+ var DEFAULT_X = "1.5rem";
47
+ var DEFAULT_Y = "0";
48
+ var INFIXES = ["", "sm", "md", "lg", "xl", "xxl"];
49
+ var CLASS_PATTERN = /(?:^|\s)g[xy]?-(?:(?:sm|md|lg|xl|xxl)-)?[0-5](?:\s|$)/;
50
+ GridEditor.utilities.gutters = function(ge) {
51
+ var options = Object.assign({ scale: SCALE }, ge.settings.utilities.gutters);
52
+ var listening = null;
53
+ function source(row, prefix, tier) {
54
+ var classes = (row.getAttribute("class") || "").split(/\s+/);
55
+ for (var i = tier; i >= 0; i--) {
56
+ for (var value = VALUES.length - 1; value >= 0; value--) {
57
+ var name = prefix + (INFIXES[i] ? "-" + INFIXES[i] : "") + "-" + value;
58
+ if (classes.indexOf(name) !== -1) {
59
+ return { tier: i, value };
60
+ }
61
+ }
62
+ }
63
+ return null;
64
+ }
65
+ function axis(row, prefix, fallback) {
66
+ var tier = ge.breakpoints.indexOf(ge.view());
67
+ var winner = [source(row, "g", tier), source(row, prefix, tier)].filter(Boolean).sort(function(a, b) {
68
+ return b.tier - a.tier || b.value - a.value;
69
+ })[0];
70
+ return winner ? options.scale[winner.value] : fallback;
71
+ }
72
+ function preview(axes) {
73
+ return function(value, row) {
74
+ var styles = {};
75
+ if (axes.indexOf("x") !== -1) {
76
+ styles["--bs-gutter-x"] = axis(row, "gx", DEFAULT_X);
77
+ }
78
+ if (axes.indexOf("y") !== -1) {
79
+ styles["--bs-gutter-y"] = axis(row, "gy", DEFAULT_Y);
80
+ }
81
+ return styles;
82
+ };
83
+ }
84
+ function afterUtility(e) {
85
+ var payload = e.detail;
86
+ if (payload.family !== "g") {
87
+ return;
88
+ }
89
+ ["gx", "gy"].forEach(function(family) {
90
+ ge.setUtility(payload.node, family, null, { view: payload.breakpoint, source: payload.source });
91
+ });
92
+ }
93
+ function mark(scope) {
94
+ selfAndAll(scope, ".row").forEach(function(row) {
95
+ toggleClass(row, "ge-gutters", CLASS_PATTERN.test(row.getAttribute("class") || ""));
96
+ });
97
+ }
98
+ return {
99
+ families: [
100
+ {
101
+ name: "g",
102
+ prefix: "g",
103
+ values: VALUES,
104
+ appliesTo: ["row"],
105
+ labelKey: "utility.gutters",
106
+ preview: preview(["x", "y"])
107
+ },
108
+ {
109
+ name: "gx",
110
+ prefix: "gx",
111
+ values: VALUES,
112
+ appliesTo: ["row"],
113
+ labelKey: "utility.gutters_x",
114
+ preview: preview(["x"])
115
+ },
116
+ {
117
+ name: "gy",
118
+ prefix: "gy",
119
+ values: VALUES,
120
+ appliesTo: ["row"],
121
+ labelKey: "utility.gutters_y",
122
+ preview: preview(["y"])
123
+ }
124
+ ],
125
+ onInit: function() {
126
+ if (listening) {
127
+ ge.canvas.removeEventListener("grideditor:after-utility", listening);
128
+ }
129
+ listening = afterUtility;
130
+ ge.canvas.addEventListener("grideditor:after-utility", listening);
131
+ },
132
+ onRefresh: mark,
133
+ onDeinit: function() {
134
+ if (listening) {
135
+ ge.canvas.removeEventListener("grideditor:after-utility", listening);
136
+ }
137
+ listening = null;
138
+ all(ge.canvas, ".ge-gutters").forEach(function(row) {
139
+ removeClass(row, "ge-gutters");
140
+ });
141
+ }
142
+ };
143
+ };
@@ -1,145 +1,148 @@
1
- /**
2
- * Gutters for grid-editor.
3
- *
4
- * A utility plugin: load this file after the editor and a row's gutters can
5
- * differ per breakpoint, with Bootstrap's g-{breakpoint}-*, gx-{breakpoint}-*
6
- * and gy-{breakpoint}-* classes. What it can ask the editor for is the handle
7
- * its factory is called with, described in docs/plugins.md.
8
- *
9
- * <script src="dist/jquery.grideditor.min.js"></script>
10
- * <script src="dist/plugins/grideditor.gutters.min.js"></script>
11
- *
12
- * The editor draws its own frame round every column, narrower than any
13
- * gutter, so a row with gutter classes is drawn with its real gutters instead.
14
- *
15
- * utilities.gutters.scale is what 0 to 5 come to, for a page that changed
16
- * Bootstrap's $spacers.
17
- */
18
- (function($) {
19
-
20
- $.extend($.fn.gridEditor.locales.en, {
21
- 'utility.gutters': 'Gutters',
22
- 'utility.gutters_x': 'Horizontal gutters',
23
- 'utility.gutters_y': 'Vertical gutters',
24
- });
25
-
26
- var VALUES = ['0', '1', '2', '3', '4', '5'];
27
-
28
- /** Bootstrap's own: $spacers, and what a row's gutters are with no class. */
29
- var SCALE = ['0', '.25rem', '.5rem', '1rem', '1.5rem', '3rem'];
30
- var DEFAULT_X = '1.5rem';
31
- var DEFAULT_Y = '0';
32
-
33
- var INFIXES = ['', 'sm', 'md', 'lg', 'xl', 'xxl'];
34
- var CLASS_PATTERN = /(?:^|\s)g[xy]?-(?:(?:sm|md|lg|xl|xxl)-)?[0-5](?:\s|$)/;
35
-
36
- $.fn.gridEditor.utilities.gutters = function(ge) {
37
-
38
- var options = $.extend({ scale: SCALE }, ge.settings.utilities.gutters);
39
-
40
- /**
41
- * The class of a family that decides a row's gutters at a breakpoint:
42
- * the widest breakpoint up to it that has one, as { tier, value }.
43
- */
1
+ (() => {
2
+ // src/js/register.js
3
+ var GridEditor = window.GridEditor;
4
+ if (!GridEditor || typeof GridEditor.get !== "function") {
5
+ throw new Error("grid-editor: load grideditor.js (or grideditor.bundle.min.js) before its plugins, its locales and grideditor.jquery.js");
6
+ }
7
+
8
+ // src/js/dom.js
9
+ function all(root, selector) {
10
+ return root ? Array.prototype.slice.call(root.querySelectorAll(selector)) : [];
11
+ }
12
+ function selfAndAll(root, selector) {
13
+ if (!root) {
14
+ return [];
15
+ }
16
+ var found = all(root, selector);
17
+ if (root.nodeType === 1 && root.matches(selector)) {
18
+ found.unshift(root);
19
+ }
20
+ return found;
21
+ }
22
+ function removeClass(node, names) {
23
+ split(names).forEach(function(name) {
24
+ node.classList.remove(name);
25
+ });
26
+ return node;
27
+ }
28
+ function toggleClass(node, names, state) {
29
+ split(names).forEach(function(name) {
30
+ if (state === void 0) {
31
+ node.classList.toggle(name);
32
+ } else {
33
+ node.classList.toggle(name, !!state);
34
+ }
35
+ });
36
+ return node;
37
+ }
38
+ function split(names) {
39
+ return String(names || "").split(/\s+/).filter(Boolean);
40
+ }
41
+
42
+ // src/js/plugins/grideditor.gutters.js
43
+ Object.assign(GridEditor.locales.en, {
44
+ "utility.gutters": "Gutters",
45
+ "utility.gutters_x": "Horizontal gutters",
46
+ "utility.gutters_y": "Vertical gutters"
47
+ });
48
+ var VALUES = ["0", "1", "2", "3", "4", "5"];
49
+ var SCALE = ["0", ".25rem", ".5rem", "1rem", "1.5rem", "3rem"];
50
+ var DEFAULT_X = "1.5rem";
51
+ var DEFAULT_Y = "0";
52
+ var INFIXES = ["", "sm", "md", "lg", "xl", "xxl"];
53
+ var CLASS_PATTERN = /(?:^|\s)g[xy]?-(?:(?:sm|md|lg|xl|xxl)-)?[0-5](?:\s|$)/;
54
+ GridEditor.utilities.gutters = function(ge) {
55
+ var options = Object.assign({ scale: SCALE }, ge.settings.utilities.gutters);
56
+ var listening = null;
44
57
  function source(row, prefix, tier) {
45
- var classes = (row.attr('class') || '').split(/\s+/);
46
-
47
- for (var i = tier; i >= 0; i--) {
48
- for (var value = VALUES.length - 1; value >= 0; value--) {
49
- var name = prefix + (INFIXES[i] ? '-' + INFIXES[i] : '') + '-' + value;
50
- if (classes.indexOf(name) !== -1) { return { tier: i, value: value }; }
51
- }
58
+ var classes = (row.getAttribute("class") || "").split(/\s+/);
59
+ for (var i = tier; i >= 0; i--) {
60
+ for (var value = VALUES.length - 1; value >= 0; value--) {
61
+ var name = prefix + (INFIXES[i] ? "-" + INFIXES[i] : "") + "-" + value;
62
+ if (classes.indexOf(name) !== -1) {
63
+ return { tier: i, value };
64
+ }
52
65
  }
53
-
54
- return null;
66
+ }
67
+ return null;
55
68
  }
56
-
57
- /**
58
- * One axis the way Bootstrap's css settles it. g and gx (or gy) set the
59
- * same variable, every breakpoint's rules come after the smaller ones',
60
- * and within a breakpoint the bigger values come later. So the class
61
- * that wins is the one from the wider breakpoint, then the bigger one -
62
- * not the more specific family, whatever that would suggest.
63
- */
64
69
  function axis(row, prefix, fallback) {
65
- var tier = ge.breakpoints.indexOf(ge.view());
66
- var winner = [source(row, 'g', tier), source(row, prefix, tier)]
67
- .filter(Boolean)
68
- .sort(function(a, b) { return b.tier - a.tier || b.value - a.value; })[0];
69
-
70
- return winner ? options.scale[winner.value] : fallback;
70
+ var tier = ge.breakpoints.indexOf(ge.view());
71
+ var winner = [source(row, "g", tier), source(row, prefix, tier)].filter(Boolean).sort(function(a, b) {
72
+ return b.tier - a.tier || b.value - a.value;
73
+ })[0];
74
+ return winner ? options.scale[winner.value] : fallback;
71
75
  }
72
-
73
76
  function preview(axes) {
74
- return function(value, row) {
75
- var styles = {};
76
-
77
- if (axes.indexOf('x') !== -1) { styles['--bs-gutter-x'] = axis(row, 'gx', DEFAULT_X); }
78
- if (axes.indexOf('y') !== -1) { styles['--bs-gutter-y'] = axis(row, 'gy', DEFAULT_Y); }
79
-
80
- return styles;
81
- };
77
+ return function(value, row) {
78
+ var styles = {};
79
+ if (axes.indexOf("x") !== -1) {
80
+ styles["--bs-gutter-x"] = axis(row, "gx", DEFAULT_X);
81
+ }
82
+ if (axes.indexOf("y") !== -1) {
83
+ styles["--bs-gutter-y"] = axis(row, "gy", DEFAULT_Y);
84
+ }
85
+ return styles;
86
+ };
82
87
  }
83
-
84
- /**
85
- * Choosing g sets both axes, so a gx or gy the same breakpoint had is
86
- * taken off: left on, the bigger of the two would win, and the field the
87
- * user just chose would not be what the row shows.
88
- */
89
- function afterUtility(e, payload) {
90
- if (payload.family !== 'g') { return; }
91
-
92
- ['gx', 'gy'].forEach(function(family) {
93
- ge.setUtility(payload.node, family, null, { view: payload.breakpoint, source: payload.source });
94
- });
88
+ function afterUtility(e) {
89
+ var payload = e.detail;
90
+ if (payload.family !== "g") {
91
+ return;
92
+ }
93
+ ["gx", "gy"].forEach(function(family) {
94
+ ge.setUtility(payload.node, family, null, { view: payload.breakpoint, source: payload.source });
95
+ });
95
96
  }
96
-
97
97
  function mark(scope) {
98
- scope.find('.row').addBack('.row').each(function() {
99
- var row = $(this);
100
- row.toggleClass('ge-gutters', CLASS_PATTERN.test(row.attr('class') || ''));
101
- });
98
+ selfAndAll(scope, ".row").forEach(function(row) {
99
+ toggleClass(row, "ge-gutters", CLASS_PATTERN.test(row.getAttribute("class") || ""));
100
+ });
102
101
  }
103
-
104
102
  return {
105
- families: [
106
- {
107
- name: 'g',
108
- prefix: 'g',
109
- values: VALUES,
110
- appliesTo: ['row'],
111
- labelKey: 'utility.gutters',
112
- preview: preview(['x', 'y']),
113
- },
114
- {
115
- name: 'gx',
116
- prefix: 'gx',
117
- values: VALUES,
118
- appliesTo: ['row'],
119
- labelKey: 'utility.gutters_x',
120
- preview: preview(['x']),
121
- },
122
- {
123
- name: 'gy',
124
- prefix: 'gy',
125
- values: VALUES,
126
- appliesTo: ['row'],
127
- labelKey: 'utility.gutters_y',
128
- preview: preview(['y']),
129
- },
130
- ],
131
-
132
- onInit: function() {
133
- ge.canvas.off('grideditor:after-utility.ge-gutters').on('grideditor:after-utility.ge-gutters', afterUtility);
103
+ families: [
104
+ {
105
+ name: "g",
106
+ prefix: "g",
107
+ values: VALUES,
108
+ appliesTo: ["row"],
109
+ labelKey: "utility.gutters",
110
+ preview: preview(["x", "y"])
134
111
  },
135
-
136
- onRefresh: mark,
137
-
138
- onDeinit: function() {
139
- ge.canvas.off('grideditor:after-utility.ge-gutters');
140
- ge.canvas.find('.ge-gutters').removeClass('ge-gutters');
112
+ {
113
+ name: "gx",
114
+ prefix: "gx",
115
+ values: VALUES,
116
+ appliesTo: ["row"],
117
+ labelKey: "utility.gutters_x",
118
+ preview: preview(["x"])
141
119
  },
120
+ {
121
+ name: "gy",
122
+ prefix: "gy",
123
+ values: VALUES,
124
+ appliesTo: ["row"],
125
+ labelKey: "utility.gutters_y",
126
+ preview: preview(["y"])
127
+ }
128
+ ],
129
+ onInit: function() {
130
+ if (listening) {
131
+ ge.canvas.removeEventListener("grideditor:after-utility", listening);
132
+ }
133
+ listening = afterUtility;
134
+ ge.canvas.addEventListener("grideditor:after-utility", listening);
135
+ },
136
+ onRefresh: mark,
137
+ onDeinit: function() {
138
+ if (listening) {
139
+ ge.canvas.removeEventListener("grideditor:after-utility", listening);
140
+ }
141
+ listening = null;
142
+ all(ge.canvas, ".ge-gutters").forEach(function(row) {
143
+ removeClass(row, "ge-gutters");
144
+ });
145
+ }
142
146
  };
143
- };
144
-
145
- })(jQuery);
147
+ };
148
+ })();
@@ -1,2 +1 @@
1
- (r=>{r.extend(r.fn.gridEditor.locales.en,{"utility.gutters":"Gutters","utility.gutters_x":"Horizontal gutters","utility.gutters_y":"Vertical gutters"});var a=["0","1","2","3","4","5"],i=["0",".25rem",".5rem","1rem","1.5rem","3rem"],g=["","sm","md","lg","xl","xxl"],o=/(?:^|\s)g[xy]?-(?:(?:sm|md|lg|xl|xxl)-)?[0-5](?:\s|$)/;r.fn.gridEditor.utilities.gutters=function(n){var u=r.extend({scale:i},n.settings.utilities.gutters);function s(t,e,r){for(var i=(t.attr("class")||"").split(/\s+/),n=r;0<=n;n--)for(var u=a.length-1;0<=u;u--)if(-1!==i.indexOf(e+(g[n]?"-"+g[n]:"")+"-"+u))return{tier:n,value:u};return null}function l(t,e,r){var i=n.breakpoints.indexOf(n.view()),t=[s(t,"g",i),s(t,e,i)].filter(Boolean).sort(function(t,e){return e.tier-t.tier||e.value-t.value})[0];return t?u.scale[t.value]:r}function t(i){return function(t,e){var r={};return-1!==i.indexOf("x")&&(r["--bs-gutter-x"]=l(e,"gx","1.5rem")),-1!==i.indexOf("y")&&(r["--bs-gutter-y"]=l(e,"gy","0")),r}}function e(t,e){"g"===e.family&&["gx","gy"].forEach(function(t){n.setUtility(e.node,t,null,{view:e.breakpoint,source:e.source})})}return{families:[{name:"g",prefix:"g",values:a,appliesTo:["row"],labelKey:"utility.gutters",preview:t(["x","y"])},{name:"gx",prefix:"gx",values:a,appliesTo:["row"],labelKey:"utility.gutters_x",preview:t(["x"])},{name:"gy",prefix:"gy",values:a,appliesTo:["row"],labelKey:"utility.gutters_y",preview:t(["y"])}],onInit:function(){n.canvas.off("grideditor:after-utility.ge-gutters").on("grideditor:after-utility.ge-gutters",e)},onRefresh:function(t){t.find(".row").addBack(".row").each(function(){var t=r(this);t.toggleClass("ge-gutters",o.test(t.attr("class")||""))})},onDeinit:function(){n.canvas.off("grideditor:after-utility.ge-gutters"),n.canvas.find(".ge-gutters").removeClass("ge-gutters")}}}})(jQuery);
2
- //# sourceMappingURL=grideditor.gutters.min.js.map
1
+ (()=>{var s=window.GridEditor;if(!s||typeof s.get!="function")throw new Error("grid-editor: load grideditor.js (or grideditor.bundle.min.js) before its plugins, its locales and grideditor.jquery.js");function d(t,i){return t?Array.prototype.slice.call(t.querySelectorAll(i)):[]}function m(t,i){if(!t)return[];var e=d(t,i);return t.nodeType===1&&t.matches(i)&&e.unshift(t),e}function x(t,i){return h(i).forEach(function(e){t.classList.remove(e)}),t}function y(t,i,e){return h(i).forEach(function(f){e===void 0?t.classList.toggle(f):t.classList.toggle(f,!!e)}),t}function h(t){return String(t||"").split(/\s+/).filter(Boolean)}Object.assign(s.locales.en,{"utility.gutters":"Gutters","utility.gutters_x":"Horizontal gutters","utility.gutters_y":"Vertical gutters"});var p=["0","1","2","3","4","5"],T=["0",".25rem",".5rem","1rem","1.5rem","3rem"],C="1.5rem",L="0",E=["","sm","md","lg","xl","xxl"],S=/(?:^|\s)g[xy]?-(?:(?:sm|md|lg|xl|xxl)-)?[0-5](?:\s|$)/;s.utilities.gutters=function(t){var i=Object.assign({scale:T},t.settings.utilities.gutters),e=null;function f(r,n,o){for(var u=(r.getAttribute("class")||"").split(/\s+/),l=o;l>=0;l--)for(var a=p.length-1;a>=0;a--){var c=n+(E[l]?"-"+E[l]:"")+"-"+a;if(u.indexOf(c)!==-1)return{tier:l,value:a}}return null}function v(r,n,o){var u=t.breakpoints.indexOf(t.view()),l=[f(r,"g",u),f(r,n,u)].filter(Boolean).sort(function(a,c){return c.tier-a.tier||c.value-a.value})[0];return l?i.scale[l.value]:o}function g(r){return function(n,o){var u={};return r.indexOf("x")!==-1&&(u["--bs-gutter-x"]=v(o,"gx",C)),r.indexOf("y")!==-1&&(u["--bs-gutter-y"]=v(o,"gy",L)),u}}function w(r){var n=r.detail;n.family==="g"&&["gx","gy"].forEach(function(o){t.setUtility(n.node,o,null,{view:n.breakpoint,source:n.source})})}function b(r){m(r,".row").forEach(function(n){y(n,"ge-gutters",S.test(n.getAttribute("class")||""))})}return{families:[{name:"g",prefix:"g",values:p,appliesTo:["row"],labelKey:"utility.gutters",preview:g(["x","y"])},{name:"gx",prefix:"gx",values:p,appliesTo:["row"],labelKey:"utility.gutters_x",preview:g(["x"])},{name:"gy",prefix:"gy",values:p,appliesTo:["row"],labelKey:"utility.gutters_y",preview:g(["y"])}],onInit:function(){e&&t.canvas.removeEventListener("grideditor:after-utility",e),e=w,t.canvas.addEventListener("grideditor:after-utility",e)},onRefresh:b,onDeinit:function(){e&&t.canvas.removeEventListener("grideditor:after-utility",e),e=null,d(t.canvas,".ge-gutters").forEach(function(r){x(r,"ge-gutters")})}}};})();