@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.
- package/AUTO_SAVE.md +2 -2
- package/BUILDING.md +45 -29
- package/CHANGELOG.md +47 -0
- package/README.md +137 -85
- package/UPGRADING.md +119 -0
- package/dist/grideditor.bundle.min.js +14 -0
- package/dist/grideditor.d.ts +335 -0
- package/dist/grideditor.esm.js +3977 -0
- package/dist/grideditor.jquery.js +253 -0
- package/dist/grideditor.jquery.min.js +1 -0
- package/dist/grideditor.jquery.min.js.map +7 -0
- package/dist/grideditor.js +3983 -0
- package/dist/grideditor.min.js +6 -0
- package/dist/grideditor.min.js.map +7 -0
- package/dist/locales/grideditor.es.esm.js +158 -0
- package/dist/locales/grideditor.es.js +164 -168
- package/dist/locales/grideditor.es.min.js +6 -2
- package/dist/locales/grideditor.es.min.js.map +7 -1
- package/dist/plugins/grideditor.accordion.esm.js +294 -0
- package/dist/plugins/grideditor.accordion.js +286 -180
- package/dist/plugins/grideditor.accordion.min.js +1 -2
- package/dist/plugins/grideditor.accordion.min.js.map +7 -1
- package/dist/plugins/grideditor.alignment.esm.js +55 -0
- package/dist/plugins/grideditor.alignment.js +58 -77
- package/dist/plugins/grideditor.alignment.min.js +1 -2
- package/dist/plugins/grideditor.alignment.min.js.map +7 -1
- package/dist/plugins/grideditor.card.esm.js +73 -0
- package/dist/plugins/grideditor.card.js +74 -64
- package/dist/plugins/grideditor.card.min.js +1 -2
- package/dist/plugins/grideditor.card.min.js.map +7 -1
- package/dist/plugins/grideditor.ckeditor.esm.js +500 -0
- package/dist/plugins/grideditor.ckeditor.js +484 -449
- package/dist/plugins/grideditor.ckeditor.min.js +1 -2
- package/dist/plugins/grideditor.ckeditor.min.js.map +7 -1
- package/dist/plugins/grideditor.clipboard.esm.js +326 -0
- package/dist/plugins/grideditor.clipboard.js +298 -235
- package/dist/plugins/grideditor.clipboard.min.js +1 -2
- package/dist/plugins/grideditor.clipboard.min.js.map +7 -1
- package/dist/plugins/grideditor.codemirror-inline.esm.js +205 -0
- package/dist/plugins/grideditor.codemirror-inline.js +188 -168
- package/dist/plugins/grideditor.codemirror-inline.min.js +1 -2
- package/dist/plugins/grideditor.codemirror-inline.min.js.map +7 -1
- package/dist/plugins/grideditor.codemirror.esm.js +63 -0
- package/dist/plugins/grideditor.codemirror.js +60 -71
- package/dist/plugins/grideditor.codemirror.min.js +1 -2
- package/dist/plugins/grideditor.codemirror.min.js.map +7 -1
- package/dist/plugins/grideditor.elements.esm.js +271 -0
- package/dist/plugins/grideditor.elements.js +256 -149
- package/dist/plugins/grideditor.elements.min.js +1 -2
- package/dist/plugins/grideditor.elements.min.js.map +7 -1
- package/dist/plugins/grideditor.float.esm.js +34 -0
- package/dist/plugins/grideditor.float.js +37 -52
- package/dist/plugins/grideditor.float.min.js +1 -2
- package/dist/plugins/grideditor.float.min.js.map +7 -1
- package/dist/plugins/grideditor.gutters.esm.js +143 -0
- package/dist/plugins/grideditor.gutters.js +134 -131
- package/dist/plugins/grideditor.gutters.min.js +1 -2
- package/dist/plugins/grideditor.gutters.min.js.map +7 -1
- package/dist/plugins/grideditor.order.esm.js +189 -0
- package/dist/plugins/grideditor.order.js +170 -182
- package/dist/plugins/grideditor.order.min.js +1 -2
- package/dist/plugins/grideditor.order.min.js.map +7 -1
- package/dist/plugins/grideditor.popup.esm.js +187 -0
- package/dist/plugins/grideditor.popup.js +183 -134
- package/dist/plugins/grideditor.popup.min.js +1 -2
- package/dist/plugins/grideditor.popup.min.js.map +7 -1
- package/dist/plugins/grideditor.sections.esm.js +271 -0
- package/dist/plugins/grideditor.sections.js +250 -173
- package/dist/plugins/grideditor.sections.min.js +1 -2
- package/dist/plugins/grideditor.sections.min.js.map +7 -1
- package/dist/plugins/grideditor.spacing.esm.js +318 -0
- package/dist/plugins/grideditor.spacing.js +296 -272
- package/dist/plugins/grideditor.spacing.min.js +1 -2
- package/dist/plugins/grideditor.spacing.min.js.map +7 -1
- package/dist/plugins/grideditor.summernote.esm.js +509 -0
- package/dist/plugins/grideditor.summernote.js +493 -427
- package/dist/plugins/grideditor.summernote.min.js +1 -2
- package/dist/plugins/grideditor.summernote.min.js.map +7 -1
- package/dist/plugins/grideditor.tabs.esm.js +237 -0
- package/dist/plugins/grideditor.tabs.js +233 -139
- package/dist/plugins/grideditor.tabs.min.js +1 -2
- package/dist/plugins/grideditor.tabs.min.js.map +7 -1
- package/dist/plugins/grideditor.textalign.esm.js +40 -0
- package/dist/plugins/grideditor.textalign.js +43 -56
- package/dist/plugins/grideditor.textalign.min.js +1 -2
- package/dist/plugins/grideditor.textalign.min.js.map +7 -1
- package/dist/plugins/grideditor.tinymce.esm.js +519 -0
- package/dist/plugins/grideditor.tinymce.js +502 -490
- package/dist/plugins/grideditor.tinymce.min.js +1 -2
- package/dist/plugins/grideditor.tinymce.min.js.map +7 -1
- package/dist/plugins/grideditor.visibility.esm.js +158 -0
- package/dist/plugins/grideditor.visibility.js +140 -149
- package/dist/plugins/grideditor.visibility.min.js +1 -2
- package/dist/plugins/grideditor.visibility.min.js.map +7 -1
- package/docs/events.md +47 -21
- package/docs/locale-keys.md +6 -0
- package/docs/plugins.md +47 -25
- package/example/adapter.html +112 -0
- package/example/attributes.html +85 -61
- package/example/autocols.html +9 -9
- package/example/autosave.html +13 -14
- package/example/basic.html +4 -5
- package/example/breakpoints.html +5 -6
- package/example/ckeditor.html +4 -5
- package/example/clipboard.html +11 -10
- package/example/codemirror.html +9 -7
- package/example/containers.html +7 -8
- package/example/custom_editor.html +53 -34
- package/example/elements.html +10 -11
- package/example/index.html +16 -2
- package/example/locale.html +6 -7
- package/example/plugins.html +44 -29
- package/example/summernote.html +6 -5
- package/example/utilities.html +17 -13
- package/example/wrap_content.html +9 -9
- package/package.json +43 -12
- package/src/js/dom.js +401 -0
- package/src/js/grideditor.classic.js +16 -0
- package/src/js/grideditor.jquery.js +325 -0
- package/src/js/{jquery.grideditor.js → grideditor.js} +1284 -1124
- package/src/js/locales/grideditor.es.js +163 -156
- package/src/js/plugins/grideditor.accordion.js +97 -77
- package/src/js/plugins/grideditor.alignment.js +5 -7
- package/src/js/plugins/grideditor.card.js +23 -23
- package/src/js/plugins/grideditor.ckeditor.js +107 -106
- package/src/js/plugins/grideditor.clipboard.js +49 -37
- package/src/js/plugins/grideditor.codemirror-inline.js +50 -37
- package/src/js/plugins/grideditor.codemirror.js +9 -10
- package/src/js/plugins/grideditor.elements.js +57 -33
- package/src/js/plugins/grideditor.float.js +4 -6
- package/src/js/plugins/grideditor.gutters.js +20 -15
- package/src/js/plugins/grideditor.order.js +28 -25
- package/src/js/plugins/grideditor.popup.js +63 -51
- package/src/js/plugins/grideditor.sections.js +39 -32
- package/src/js/plugins/grideditor.spacing.js +42 -45
- package/src/js/plugins/grideditor.summernote.js +112 -76
- package/src/js/plugins/grideditor.tabs.js +65 -57
- package/src/js/plugins/grideditor.textalign.js +4 -6
- package/src/js/plugins/grideditor.tinymce.js +147 -139
- package/src/js/plugins/grideditor.visibility.js +24 -25
- package/src/js/register.js +18 -0
- package/src/js/text/grideditor.text.js +77 -56
- package/types/grideditor.d.ts +335 -0
- package/dist/jquery.grideditor.bundle.min.js +0 -10
- package/dist/jquery.grideditor.js +0 -4927
- package/dist/jquery.grideditor.min.js +0 -2
- package/dist/jquery.grideditor.min.js.map +0 -1
package/example/autosave.html
CHANGED
|
@@ -9,7 +9,6 @@
|
|
|
9
9
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.13.1/font/bootstrap-icons.css">
|
|
10
10
|
|
|
11
11
|
<!-- JS dependencies -->
|
|
12
|
-
<script src="https://code.jquery.com/jquery-4.0.0.min.js"></script>
|
|
13
12
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.8/dist/js/bootstrap.bundle.min.js" integrity="sha384-FKyoEForCGlyvwx9Hj09JcYn3nv7wiPVlz7YYwJrWVcXK/BmnVDxM+D2scQbITxI" crossorigin="anonymous"></script>
|
|
14
13
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/tinymce/6.8.6/tinymce.min.js"></script>
|
|
15
14
|
|
|
@@ -17,7 +16,7 @@
|
|
|
17
16
|
<link rel="stylesheet" type="text/css" href="../dist/grideditor.css" />
|
|
18
17
|
<!-- Grid editor javascript -->
|
|
19
18
|
<script src="https://cdn.jsdelivr.net/npm/sortablejs@1.15.6/Sortable.min.js"></script>
|
|
20
|
-
<script src="../dist/
|
|
19
|
+
<script src="../dist/grideditor.min.js"></script>
|
|
21
20
|
<!-- The text editor is a plugin of its own, loaded after the editor -->
|
|
22
21
|
<script src="../dist/plugins/grideditor.tinymce.min.js"></script>
|
|
23
22
|
</head>
|
|
@@ -41,30 +40,30 @@
|
|
|
41
40
|
</div>
|
|
42
41
|
<script>
|
|
43
42
|
const LOCAL_STORAGE_KEY = 'gridEditorLayout';
|
|
43
|
+
const grid = document.getElementById('myGrid');
|
|
44
|
+
let editor = null;
|
|
44
45
|
|
|
45
46
|
function initEditor(initialContent = '') {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
$grid.gridEditor({
|
|
47
|
+
grid.innerHTML = initialContent;
|
|
48
|
+
editor = new GridEditor(grid, {
|
|
49
49
|
new_row_layouts: [[12], [6,6], [4,4,4]],
|
|
50
50
|
content_types: ['tinymce']
|
|
51
51
|
});
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
function autoSave() {
|
|
55
|
-
|
|
56
|
-
localStorage.setItem(LOCAL_STORAGE_KEY, html);
|
|
55
|
+
localStorage.setItem(LOCAL_STORAGE_KEY, editor.getHtml());
|
|
57
56
|
}
|
|
58
57
|
|
|
59
|
-
|
|
58
|
+
document.addEventListener('DOMContentLoaded', function () {
|
|
60
59
|
// Restore the previous draft, falling back to whatever markup is in the page
|
|
61
60
|
const saved = localStorage.getItem(LOCAL_STORAGE_KEY);
|
|
62
|
-
initEditor(saved ||
|
|
61
|
+
initEditor(saved || grid.innerHTML);
|
|
63
62
|
|
|
64
63
|
setInterval(autoSave, 5000);
|
|
65
64
|
|
|
66
|
-
|
|
67
|
-
const html =
|
|
65
|
+
document.getElementById('exportBtn').addEventListener('click', () => {
|
|
66
|
+
const html = editor.getHtml();
|
|
68
67
|
const blob = new Blob([html], { type: 'text/html' });
|
|
69
68
|
const url = URL.createObjectURL(blob);
|
|
70
69
|
const a = document.createElement('a');
|
|
@@ -74,19 +73,19 @@
|
|
|
74
73
|
URL.revokeObjectURL(url);
|
|
75
74
|
});
|
|
76
75
|
|
|
77
|
-
|
|
76
|
+
document.getElementById('importInput').addEventListener('change', function (e) {
|
|
78
77
|
const file = e.target.files[0];
|
|
79
78
|
if (!file) return;
|
|
80
79
|
const reader = new FileReader();
|
|
81
80
|
reader.onload = function (e) {
|
|
82
|
-
|
|
81
|
+
editor.destroy();
|
|
83
82
|
initEditor(e.target.result);
|
|
84
83
|
autoSave();
|
|
85
84
|
};
|
|
86
85
|
reader.readAsText(file);
|
|
87
86
|
});
|
|
88
87
|
|
|
89
|
-
|
|
88
|
+
document.getElementById('resetBtn').addEventListener('click', function () {
|
|
90
89
|
localStorage.removeItem(LOCAL_STORAGE_KEY);
|
|
91
90
|
location.reload();
|
|
92
91
|
});
|
package/example/basic.html
CHANGED
|
@@ -8,7 +8,6 @@
|
|
|
8
8
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.13.1/font/bootstrap-icons.css">
|
|
9
9
|
|
|
10
10
|
<!-- Javascript dependencies -->
|
|
11
|
-
<script src="https://code.jquery.com/jquery-4.0.0.min.js"></script>
|
|
12
11
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.8/dist/js/bootstrap.bundle.min.js" integrity="sha384-FKyoEForCGlyvwx9Hj09JcYn3nv7wiPVlz7YYwJrWVcXK/BmnVDxM+D2scQbITxI" crossorigin="anonymous"></script>
|
|
13
12
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/tinymce/6.8.6/tinymce.min.js"></script>
|
|
14
13
|
|
|
@@ -17,21 +16,21 @@
|
|
|
17
16
|
<!-- Grid editor javascript -->
|
|
18
17
|
<!-- The editor with SortableJS inside it. Every other example loads the
|
|
19
18
|
two files separately; a page does one or the other, never both. -->
|
|
20
|
-
<script src="../dist/
|
|
19
|
+
<script src="../dist/grideditor.bundle.min.js"></script>
|
|
21
20
|
<!-- The text editor is a plugin of its own, loaded after the editor -->
|
|
22
21
|
<script src="../dist/plugins/grideditor.tinymce.min.js"></script>
|
|
23
22
|
|
|
24
23
|
<script>
|
|
25
|
-
|
|
24
|
+
document.addEventListener('DOMContentLoaded', function() {
|
|
26
25
|
// Initialize grid editor
|
|
27
|
-
|
|
26
|
+
var editor = new GridEditor('#myGrid', {
|
|
28
27
|
drag_handle: 'drawer',
|
|
29
28
|
new_row_layouts: [[12], [6,6], [9,3]],
|
|
30
29
|
content_types: ['tinymce'],
|
|
31
30
|
});
|
|
32
31
|
|
|
33
32
|
// // Get resulting html
|
|
34
|
-
// var html =
|
|
33
|
+
// var html = editor.getHtml();
|
|
35
34
|
// console.log(html);
|
|
36
35
|
});
|
|
37
36
|
</script>
|
package/example/breakpoints.html
CHANGED
|
@@ -8,18 +8,17 @@
|
|
|
8
8
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.13.1/font/bootstrap-icons.css">
|
|
9
9
|
|
|
10
10
|
<!-- Javascript dependencies -->
|
|
11
|
-
<script src="https://code.jquery.com/jquery-4.0.0.min.js"></script>
|
|
12
11
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.8/dist/js/bootstrap.bundle.min.js" integrity="sha384-FKyoEForCGlyvwx9Hj09JcYn3nv7wiPVlz7YYwJrWVcXK/BmnVDxM+D2scQbITxI" crossorigin="anonymous"></script>
|
|
13
12
|
|
|
14
13
|
<!-- Grid editor CSS -->
|
|
15
14
|
<link rel="stylesheet" type="text/css" href="../dist/grideditor.css" />
|
|
16
15
|
<!-- Grid editor javascript -->
|
|
17
16
|
<script src="https://cdn.jsdelivr.net/npm/sortablejs@1.15.6/Sortable.min.js"></script>
|
|
18
|
-
<script src="../dist/
|
|
17
|
+
<script src="../dist/grideditor.min.js"></script>
|
|
19
18
|
|
|
20
19
|
<script>
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
document.addEventListener('DOMContentLoaded', function() {
|
|
21
|
+
var editor = new GridEditor('#myGrid', {
|
|
23
22
|
new_row_layouts: [[12], [6,6], [4,4,4], [8,4]],
|
|
24
23
|
content_types: [],
|
|
25
24
|
|
|
@@ -33,8 +32,8 @@
|
|
|
33
32
|
// layout_modes: ['all', 'lg', 'sm', 'xs'],
|
|
34
33
|
});
|
|
35
34
|
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
document.getElementById('output').addEventListener('click', function() {
|
|
36
|
+
document.getElementById('html').textContent = editor.getHtml();
|
|
38
37
|
});
|
|
39
38
|
});
|
|
40
39
|
</script>
|
package/example/ckeditor.html
CHANGED
|
@@ -8,7 +8,6 @@
|
|
|
8
8
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.13.1/font/bootstrap-icons.css">
|
|
9
9
|
|
|
10
10
|
<!-- Javascript dependencies -->
|
|
11
|
-
<script src="https://code.jquery.com/jquery-4.0.0.min.js"></script>
|
|
12
11
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.8/dist/js/bootstrap.bundle.min.js" integrity="sha384-FKyoEForCGlyvwx9Hj09JcYn3nv7wiPVlz7YYwJrWVcXK/BmnVDxM+D2scQbITxI" crossorigin="anonymous"></script>
|
|
13
12
|
|
|
14
13
|
<!-- Ckeditor js -->
|
|
@@ -18,14 +17,14 @@
|
|
|
18
17
|
<link rel="stylesheet" type="text/css" href="../dist/grideditor.css" />
|
|
19
18
|
<!-- Grid editor javascript -->
|
|
20
19
|
<script src="https://cdn.jsdelivr.net/npm/sortablejs@1.15.6/Sortable.min.js"></script>
|
|
21
|
-
<script src="../dist/
|
|
20
|
+
<script src="../dist/grideditor.min.js"></script>
|
|
22
21
|
<!-- The text editor is a plugin of its own, loaded after the editor -->
|
|
23
22
|
<script src="../dist/plugins/grideditor.ckeditor.min.js"></script>
|
|
24
23
|
|
|
25
24
|
<script>
|
|
26
|
-
|
|
25
|
+
document.addEventListener('DOMContentLoaded', function() {
|
|
27
26
|
// Initialize grid editor
|
|
28
|
-
|
|
27
|
+
var editor = new GridEditor('#myGrid', {
|
|
29
28
|
new_row_layouts: [[12], [6, 6], [9, 3]],
|
|
30
29
|
content_types: ['ckeditor'],
|
|
31
30
|
ckeditor: {
|
|
@@ -41,7 +40,7 @@
|
|
|
41
40
|
});
|
|
42
41
|
|
|
43
42
|
// Get resulting html
|
|
44
|
-
var html =
|
|
43
|
+
var html = editor.getHtml();
|
|
45
44
|
console.log(html);
|
|
46
45
|
});
|
|
47
46
|
</script>
|
package/example/clipboard.html
CHANGED
|
@@ -8,7 +8,6 @@
|
|
|
8
8
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.13.1/font/bootstrap-icons.css">
|
|
9
9
|
|
|
10
10
|
<!-- Javascript dependencies -->
|
|
11
|
-
<script src="https://code.jquery.com/jquery-4.0.0.min.js"></script>
|
|
12
11
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.8/dist/js/bootstrap.bundle.min.js" integrity="sha384-FKyoEForCGlyvwx9Hj09JcYn3nv7wiPVlz7YYwJrWVcXK/BmnVDxM+D2scQbITxI" crossorigin="anonymous"></script>
|
|
13
12
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/tinymce/6.8.6/tinymce.min.js"></script>
|
|
14
13
|
|
|
@@ -16,7 +15,7 @@
|
|
|
16
15
|
<link rel="stylesheet" type="text/css" href="../dist/grideditor.css" />
|
|
17
16
|
<!-- Grid editor javascript -->
|
|
18
17
|
<script src="https://cdn.jsdelivr.net/npm/sortablejs@1.15.6/Sortable.min.js"></script>
|
|
19
|
-
<script src="../dist/
|
|
18
|
+
<script src="../dist/grideditor.min.js"></script>
|
|
20
19
|
<!-- The text editor is a plugin of its own, loaded after the editor -->
|
|
21
20
|
<script src="../dist/plugins/grideditor.tinymce.min.js"></script>
|
|
22
21
|
<!-- Copy and paste is a plugin of its own. The others are here so there
|
|
@@ -28,20 +27,22 @@
|
|
|
28
27
|
<script src="../dist/plugins/grideditor.elements.min.js"></script>
|
|
29
28
|
|
|
30
29
|
<script>
|
|
31
|
-
|
|
30
|
+
document.addEventListener('DOMContentLoaded', function() {
|
|
32
31
|
var settings = {
|
|
33
32
|
new_row_layouts: [[12], [6, 6], [4, 4, 4]],
|
|
34
33
|
content_types: ['tinymce'],
|
|
35
34
|
};
|
|
36
35
|
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
['#myGrid', '#otherGrid'].forEach(function(selector) {
|
|
37
|
+
var grid = document.querySelector(selector);
|
|
38
|
+
new GridEditor(grid, settings);
|
|
39
39
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
40
|
+
// A paste is an add like any other, with source 'paste'
|
|
41
|
+
grid.addEventListener('grideditor:after-add', function(e) {
|
|
42
|
+
if (e.detail.source === 'paste') {
|
|
43
|
+
document.getElementById('log').textContent = 'Pasted a ' + e.detail.kind + ' into ' + e.currentTarget.id;
|
|
44
|
+
}
|
|
45
|
+
});
|
|
45
46
|
});
|
|
46
47
|
});
|
|
47
48
|
</script>
|
package/example/codemirror.html
CHANGED
|
@@ -9,7 +9,6 @@
|
|
|
9
9
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/codemirror@5.65.21/lib/codemirror.min.css">
|
|
10
10
|
|
|
11
11
|
<!-- Javascript dependencies -->
|
|
12
|
-
<script src="https://code.jquery.com/jquery-4.0.0.min.js"></script>
|
|
13
12
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.8/dist/js/bootstrap.bundle.min.js" integrity="sha384-FKyoEForCGlyvwx9Hj09JcYn3nv7wiPVlz7YYwJrWVcXK/BmnVDxM+D2scQbITxI" crossorigin="anonymous"></script>
|
|
14
13
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/tinymce/6.8.6/tinymce.min.js"></script>
|
|
15
14
|
|
|
@@ -25,7 +24,7 @@
|
|
|
25
24
|
<link rel="stylesheet" type="text/css" href="../dist/grideditor.css" />
|
|
26
25
|
<!-- Grid editor javascript -->
|
|
27
26
|
<script src="https://cdn.jsdelivr.net/npm/sortablejs@1.15.6/Sortable.min.js"></script>
|
|
28
|
-
<script src="../dist/
|
|
27
|
+
<script src="../dist/grideditor.min.js"></script>
|
|
29
28
|
<script src="../dist/plugins/grideditor.tinymce.min.js"></script>
|
|
30
29
|
<!-- The source view in CodeMirror, a plugin of its own -->
|
|
31
30
|
<script src="../dist/plugins/grideditor.codemirror.min.js"></script>
|
|
@@ -33,14 +32,17 @@
|
|
|
33
32
|
<script src="../dist/plugins/grideditor.codemirror-inline.min.js"></script>
|
|
34
33
|
|
|
35
34
|
<script>
|
|
36
|
-
|
|
35
|
+
document.addEventListener('DOMContentLoaded', function() {
|
|
36
|
+
var checkbox = document.getElementById('editSource');
|
|
37
|
+
|
|
37
38
|
function start() {
|
|
38
|
-
|
|
39
|
+
var running = GridEditor.get('#myGrid');
|
|
40
|
+
if (running) { running.destroy(); }
|
|
39
41
|
|
|
40
|
-
|
|
42
|
+
new GridEditor('#myGrid', {
|
|
41
43
|
new_row_layouts: [[12], [6, 6], [4, 4, 4]],
|
|
42
44
|
// false leaves the toolbar's source button out
|
|
43
|
-
edit_source:
|
|
45
|
+
edit_source: checkbox.checked,
|
|
44
46
|
// Anything CodeMirror.fromTextArea takes, over the
|
|
45
47
|
// plugin's own defaults
|
|
46
48
|
codemirror: {
|
|
@@ -49,7 +51,7 @@
|
|
|
49
51
|
});
|
|
50
52
|
}
|
|
51
53
|
|
|
52
|
-
|
|
54
|
+
checkbox.addEventListener('change', start);
|
|
53
55
|
start();
|
|
54
56
|
});
|
|
55
57
|
</script>
|
package/example/containers.html
CHANGED
|
@@ -8,7 +8,6 @@
|
|
|
8
8
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.13.1/font/bootstrap-icons.css">
|
|
9
9
|
|
|
10
10
|
<!-- Javascript dependencies -->
|
|
11
|
-
<script src="https://code.jquery.com/jquery-4.0.0.min.js"></script>
|
|
12
11
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.8/dist/js/bootstrap.bundle.min.js" integrity="sha384-FKyoEForCGlyvwx9Hj09JcYn3nv7wiPVlz7YYwJrWVcXK/BmnVDxM+D2scQbITxI" crossorigin="anonymous"></script>
|
|
13
12
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/tinymce/6.8.6/tinymce.min.js"></script>
|
|
14
13
|
|
|
@@ -16,7 +15,7 @@
|
|
|
16
15
|
<link rel="stylesheet" type="text/css" href="../dist/grideditor.css" />
|
|
17
16
|
<!-- Grid editor javascript -->
|
|
18
17
|
<script src="https://cdn.jsdelivr.net/npm/sortablejs@1.15.6/Sortable.min.js"></script>
|
|
19
|
-
<script src="../dist/
|
|
18
|
+
<script src="../dist/grideditor.min.js"></script>
|
|
20
19
|
<!-- The text editor is a plugin of its own, loaded after the editor -->
|
|
21
20
|
<script src="../dist/plugins/grideditor.tinymce.min.js"></script>
|
|
22
21
|
<!-- One file per container type: load the ones this page offers -->
|
|
@@ -26,8 +25,8 @@
|
|
|
26
25
|
<script src="../dist/plugins/grideditor.card.min.js"></script>
|
|
27
26
|
|
|
28
27
|
<script>
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
document.addEventListener('DOMContentLoaded', function() {
|
|
29
|
+
var editor = new GridEditor('#myGrid', {
|
|
31
30
|
new_row_layouts: [[12], [6,6]],
|
|
32
31
|
content_types: ['tinymce'],
|
|
33
32
|
|
|
@@ -47,12 +46,12 @@
|
|
|
47
46
|
accordion_tools: [],
|
|
48
47
|
});
|
|
49
48
|
|
|
50
|
-
|
|
51
|
-
|
|
49
|
+
document.getElementById('output').addEventListener('click', function() {
|
|
50
|
+
document.getElementById('html').textContent = editor.getHtml();
|
|
52
51
|
});
|
|
53
52
|
|
|
54
|
-
|
|
55
|
-
var html =
|
|
53
|
+
document.getElementById('authored').addEventListener('click', function() {
|
|
54
|
+
var html = editor.getHtml();
|
|
56
55
|
var page = window.open('', '_blank');
|
|
57
56
|
|
|
58
57
|
// The output, in a page that loads Bootstrap and nothing else:
|
|
@@ -8,7 +8,6 @@
|
|
|
8
8
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.13.1/font/bootstrap-icons.css">
|
|
9
9
|
|
|
10
10
|
<!-- Javascript dependencies -->
|
|
11
|
-
<script src="https://code.jquery.com/jquery-4.0.0.min.js"></script>
|
|
12
11
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.8/dist/js/bootstrap.bundle.min.js" integrity="sha384-FKyoEForCGlyvwx9Hj09JcYn3nv7wiPVlz7YYwJrWVcXK/BmnVDxM+D2scQbITxI" crossorigin="anonymous"></script>
|
|
13
12
|
|
|
14
13
|
<!-- Grid editor CSS -->
|
|
@@ -17,39 +16,47 @@
|
|
|
17
16
|
<!-- The editor, and no text editor of the shipped ones: the one this page
|
|
18
17
|
edits text with is written below -->
|
|
19
18
|
<script src="https://cdn.jsdelivr.net/npm/sortablejs@1.15.6/Sortable.min.js"></script>
|
|
20
|
-
<script src="../dist/
|
|
19
|
+
<script src="../dist/grideditor.min.js"></script>
|
|
21
20
|
|
|
22
21
|
<!-- A text editor of the page's own. It is a feature plugin like any
|
|
23
22
|
other: the core knows nothing of text, and asks the plugins through
|
|
24
23
|
textTypes which types there are. This one edits with the browser's
|
|
25
24
|
own contenteditable. -->
|
|
26
25
|
<script id="simpletext-plugin">
|
|
27
|
-
(function(
|
|
26
|
+
(function() {
|
|
28
27
|
|
|
29
|
-
|
|
28
|
+
Object.assign(GridEditor.locales.en, {
|
|
30
29
|
'simpletext.label': 'Simple text',
|
|
31
30
|
'simpletext.add': 'Simple text',
|
|
32
31
|
});
|
|
33
32
|
|
|
34
33
|
var TYPE = 'simpletext';
|
|
35
34
|
|
|
36
|
-
|
|
35
|
+
GridEditor.features.simpletext = function(ge) {
|
|
37
36
|
|
|
38
37
|
/** A content area of this plugin's: its type is on it. */
|
|
39
38
|
function isOurs(area) {
|
|
40
|
-
return area.
|
|
39
|
+
return !!area && area.getAttribute('data-ge-content-type') === TYPE;
|
|
41
40
|
}
|
|
42
41
|
|
|
43
42
|
function start(area) {
|
|
44
|
-
if (area.
|
|
43
|
+
if (area.classList.contains('ge-rte-active')) { return; }
|
|
45
44
|
|
|
46
|
-
area.
|
|
45
|
+
area.classList.add('ge-rte-active');
|
|
46
|
+
area.setAttribute('contenteditable', 'true');
|
|
47
|
+
area.focus();
|
|
47
48
|
}
|
|
48
49
|
|
|
49
50
|
// Whatever start put on the content area comes off: what is
|
|
50
51
|
// left is what getHtml saves
|
|
51
52
|
function stop(area) {
|
|
52
|
-
area.
|
|
53
|
+
area.classList.remove('ge-rte-active');
|
|
54
|
+
area.removeAttribute('contenteditable');
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** The content area a text block holds. */
|
|
58
|
+
function areaOf(textBlock) {
|
|
59
|
+
return textBlock.querySelector(':scope > .ge-content');
|
|
53
60
|
}
|
|
54
61
|
|
|
55
62
|
/**
|
|
@@ -58,23 +65,32 @@
|
|
|
58
65
|
* drawer of a type a plugin declares to that plugin.
|
|
59
66
|
*/
|
|
60
67
|
function createDrawer(textBlock) {
|
|
61
|
-
var area = textBlock
|
|
62
|
-
var drawer =
|
|
68
|
+
var area = areaOf(textBlock);
|
|
69
|
+
var drawer = document.createElement('div');
|
|
70
|
+
drawer.className = 'ge-tools-drawer ge-text-drawer';
|
|
71
|
+
textBlock.insertBefore(drawer, textBlock.firstChild);
|
|
63
72
|
|
|
64
73
|
ge.createMoveTool(drawer);
|
|
65
74
|
ge.createTool(drawer, ge.t('tool.delete_text'), 'ge-delete-text', 'bi bi-trash', function() {
|
|
66
75
|
ge.deleteNode('text', area, ge.t('confirm.delete_text'), function(removed) {
|
|
67
76
|
stop(area);
|
|
68
|
-
|
|
77
|
+
// Folded away, then gone
|
|
78
|
+
var fold = textBlock.animate(
|
|
79
|
+
[{ height: textBlock.offsetHeight + 'px', opacity: 1 }, { height: '0px', opacity: 0 }],
|
|
80
|
+
{ duration: 400, easing: 'ease-in-out' }
|
|
81
|
+
);
|
|
82
|
+
textBlock.style.overflow = 'hidden';
|
|
83
|
+
fold.onfinish = function() {
|
|
69
84
|
textBlock.remove();
|
|
70
85
|
removed();
|
|
71
|
-
}
|
|
86
|
+
};
|
|
72
87
|
});
|
|
73
88
|
});
|
|
74
89
|
}
|
|
75
90
|
|
|
76
|
-
function onClick() {
|
|
77
|
-
|
|
91
|
+
function onClick(e) {
|
|
92
|
+
var area = e.target.closest('.ge-content');
|
|
93
|
+
if (area && ge.canvas.contains(area) && isOurs(area)) { start(area); }
|
|
78
94
|
}
|
|
79
95
|
|
|
80
96
|
return {
|
|
@@ -87,8 +103,9 @@
|
|
|
87
103
|
type: TYPE,
|
|
88
104
|
label: ge.t('simpletext.label'),
|
|
89
105
|
edit: function(area) {
|
|
90
|
-
var textBlock = area.
|
|
91
|
-
if (textBlock.
|
|
106
|
+
var textBlock = area.parentElement;
|
|
107
|
+
if (textBlock.classList.contains('ge-text-block') &&
|
|
108
|
+
!textBlock.querySelector(':scope > .ge-tools-drawer')) {
|
|
92
109
|
createDrawer(textBlock);
|
|
93
110
|
}
|
|
94
111
|
|
|
@@ -105,47 +122,49 @@
|
|
|
105
122
|
kind: 'text',
|
|
106
123
|
inColumn: true,
|
|
107
124
|
create: function() {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
125
|
+
var area = document.createElement('div');
|
|
126
|
+
area.className = 'ge-content ge-content-type-' + TYPE;
|
|
127
|
+
area.setAttribute('data-ge-content-type', TYPE);
|
|
128
|
+
area.innerHTML = '<p>Write here</p>';
|
|
129
|
+
return area;
|
|
112
130
|
},
|
|
113
131
|
}],
|
|
114
132
|
|
|
115
133
|
onInit: function() {
|
|
116
|
-
ge.canvas.
|
|
117
|
-
|
|
118
|
-
if (textBlock
|
|
119
|
-
if (isOurs(textBlock.children('.ge-content'))) { createDrawer(textBlock); }
|
|
134
|
+
ge.canvas.querySelectorAll('.ge-text-block').forEach(function(textBlock) {
|
|
135
|
+
if (textBlock.querySelector(':scope > .ge-tools-drawer')) { return; }
|
|
136
|
+
if (isOurs(areaOf(textBlock))) { createDrawer(textBlock); }
|
|
120
137
|
});
|
|
121
138
|
|
|
122
|
-
|
|
139
|
+
// One listener, however many times the canvas is initialized
|
|
140
|
+
ge.canvas.removeEventListener('click', onClick);
|
|
141
|
+
ge.canvas.addEventListener('click', onClick);
|
|
123
142
|
},
|
|
124
143
|
|
|
125
144
|
// Before the drawers and the text blocks come off
|
|
126
145
|
onBeforeDeinit: function() {
|
|
127
|
-
ge.canvas.
|
|
128
|
-
if (isOurs(
|
|
146
|
+
ge.canvas.querySelectorAll('.ge-content').forEach(function(area) {
|
|
147
|
+
if (isOurs(area)) { stop(area); }
|
|
129
148
|
});
|
|
130
149
|
},
|
|
131
150
|
|
|
132
151
|
onDeinit: function() {
|
|
133
|
-
ge.canvas.
|
|
152
|
+
ge.canvas.removeEventListener('click', onClick);
|
|
134
153
|
},
|
|
135
154
|
};
|
|
136
155
|
};
|
|
137
156
|
|
|
138
|
-
})(
|
|
157
|
+
})();
|
|
139
158
|
</script>
|
|
140
159
|
|
|
141
160
|
<script>
|
|
142
|
-
|
|
143
|
-
|
|
161
|
+
document.addEventListener('DOMContentLoaded', function() {
|
|
162
|
+
var editor = new GridEditor('#myGrid', {
|
|
144
163
|
new_row_layouts: [[12], [6, 6], [4, 4, 4]],
|
|
145
164
|
});
|
|
146
165
|
|
|
147
|
-
|
|
148
|
-
|
|
166
|
+
document.getElementById('output').addEventListener('click', function() {
|
|
167
|
+
document.getElementById('html').textContent = editor.getHtml();
|
|
149
168
|
});
|
|
150
169
|
});
|
|
151
170
|
</script>
|
package/example/elements.html
CHANGED
|
@@ -8,7 +8,6 @@
|
|
|
8
8
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.13.1/font/bootstrap-icons.css">
|
|
9
9
|
|
|
10
10
|
<!-- Javascript dependencies -->
|
|
11
|
-
<script src="https://code.jquery.com/jquery-4.0.0.min.js"></script>
|
|
12
11
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.8/dist/js/bootstrap.bundle.min.js" integrity="sha384-FKyoEForCGlyvwx9Hj09JcYn3nv7wiPVlz7YYwJrWVcXK/BmnVDxM+D2scQbITxI" crossorigin="anonymous"></script>
|
|
13
12
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/tinymce/6.8.6/tinymce.min.js"></script>
|
|
14
13
|
|
|
@@ -16,7 +15,7 @@
|
|
|
16
15
|
<link rel="stylesheet" type="text/css" href="../dist/grideditor.css" />
|
|
17
16
|
<!-- Grid editor javascript -->
|
|
18
17
|
<script src="https://cdn.jsdelivr.net/npm/sortablejs@1.15.6/Sortable.min.js"></script>
|
|
19
|
-
<script src="../dist/
|
|
18
|
+
<script src="../dist/grideditor.min.js"></script>
|
|
20
19
|
<!-- The text editor is a plugin of its own, loaded after the editor -->
|
|
21
20
|
<script src="../dist/plugins/grideditor.tinymce.min.js"></script>
|
|
22
21
|
<script src="../dist/plugins/grideditor.elements.min.js"></script>
|
|
@@ -37,8 +36,8 @@
|
|
|
37
36
|
</style>
|
|
38
37
|
|
|
39
38
|
<script>
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
document.addEventListener('DOMContentLoaded', function() {
|
|
40
|
+
var editor = new GridEditor('#myGrid', {
|
|
42
41
|
new_row_layouts: [[12], [6,6]],
|
|
43
42
|
content_types: ['tinymce'],
|
|
44
43
|
|
|
@@ -61,9 +60,9 @@
|
|
|
61
60
|
className: 'my-app-edit',
|
|
62
61
|
on: {
|
|
63
62
|
click: function() {
|
|
64
|
-
var element =
|
|
63
|
+
var element = this.closest('.ge-element');
|
|
65
64
|
alert('The host would open its own editor for ' +
|
|
66
|
-
element.
|
|
65
|
+
element.getAttribute('data-ge-element') + ' here.');
|
|
67
66
|
},
|
|
68
67
|
},
|
|
69
68
|
}],
|
|
@@ -73,17 +72,17 @@
|
|
|
73
72
|
// placeholder to see and move while editing, and strips it in its
|
|
74
73
|
// own save step. Grid editor needs no feature for this - the
|
|
75
74
|
// element level controls already apply (spec 4.4).
|
|
76
|
-
|
|
77
|
-
var column =
|
|
75
|
+
document.getElementById('addTag').addEventListener('click', function() {
|
|
76
|
+
var column = document.querySelector('#myGrid .column');
|
|
78
77
|
|
|
79
|
-
|
|
78
|
+
editor.createElement(
|
|
80
79
|
'<span class="my-app-tag-placeholder">Analytics tag</span>',
|
|
81
80
|
{ type: 'analytics-tag', label: 'Analytics', appendTo: column }
|
|
82
81
|
);
|
|
83
82
|
});
|
|
84
83
|
|
|
85
|
-
|
|
86
|
-
|
|
84
|
+
document.getElementById('output').addEventListener('click', function() {
|
|
85
|
+
document.getElementById('html').textContent = editor.getHtml();
|
|
87
86
|
});
|
|
88
87
|
});
|
|
89
88
|
</script>
|
package/example/index.html
CHANGED
|
@@ -25,11 +25,17 @@
|
|
|
25
25
|
Since 4.0 every gesture works with a finger as well as with a
|
|
26
26
|
mouse — sorting, resizing a column, dragging a button off the
|
|
27
27
|
toolbar — so these are worth opening on a phone. The editor
|
|
28
|
-
needs
|
|
28
|
+
needs <a href="https://sortablejs.github.io/Sortable/">SortableJS</a>
|
|
29
29
|
and Bootstrap 5; the first demo loads
|
|
30
|
-
<code>
|
|
30
|
+
<code>grideditor.bundle.min.js</code> instead, which is the
|
|
31
31
|
editor and SortableJS in one file.
|
|
32
32
|
</p>
|
|
33
|
+
<p class="text-body-secondary">
|
|
34
|
+
New in 7.0: no jQuery. The editor is <code>new GridEditor(element)</code>,
|
|
35
|
+
as a script or an ES module, and a page written for 6.x keeps
|
|
36
|
+
working with jQuery and <code>grideditor.jquery.js</code> — see
|
|
37
|
+
<a href="adapter.html">The jQuery API</a>.
|
|
38
|
+
</p>
|
|
33
39
|
<p class="text-body-secondary">
|
|
34
40
|
New in 5.0: equal and auto columns, columns per row, and sections
|
|
35
41
|
for Bootstrap's containers — see
|
|
@@ -173,6 +179,14 @@
|
|
|
173
179
|
<span class="text-body-secondary">Saving the html as the user edits, through the editor’s events</span>
|
|
174
180
|
</a>
|
|
175
181
|
|
|
182
|
+
<a class="list-group-item list-group-item-action" href="adapter.html">
|
|
183
|
+
<div class="d-flex justify-content-between">
|
|
184
|
+
<strong>The jQuery API</strong>
|
|
185
|
+
<code class="text-body-secondary">adapter.html</code>
|
|
186
|
+
</div>
|
|
187
|
+
<span class="text-body-secondary">A page written for grid-editor 6, running unchanged through grideditor.jquery.js</span>
|
|
188
|
+
</a>
|
|
189
|
+
|
|
176
190
|
</div>
|
|
177
191
|
|
|
178
192
|
<p class="text-body-secondary">
|