-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/sisvietnamvn_main/html_snippets/top-banner.html b/sisvietnamvn_main/html_snippets/top-banner.html
index e3be33f5..3482a51d 100644
--- a/sisvietnamvn_main/html_snippets/top-banner.html
+++ b/sisvietnamvn_main/html_snippets/top-banner.html
@@ -33,57 +33,35 @@
Create Menu
diff --git a/sisvietnamvn_main/src/main/resources/templates/manage/snippets/form.html b/sisvietnamvn_main/src/main/resources/templates/manage/snippets/form.html
index 97ef8920..f5c860b0 100644
--- a/sisvietnamvn_main/src/main/resources/templates/manage/snippets/form.html
+++ b/sisvietnamvn_main/src/main/resources/templates/manage/snippets/form.html
@@ -4,6 +4,11 @@
Edit Snippet
+
+
+
+
+
' : '');
+ var rawOutput;
+
+ if (isGrapesJsModified) {
+ // User made visual changes, pull from GrapesJS
+ var html = editor.getHtml();
+ var css = editor.getCss();
+ var combined = html + (css && css.trim() !== '' && css.trim() !== '* { box-sizing: border-box; } body {margin: 0;}' ? '' : '');
+
+ rawOutput = html_beautify(combined, {
+ indent_size: 4,
+ wrap_line_length: 0,
+ preserve_newlines: true
+ });
+ } else {
+ // User didn't make visual changes, KEEP IT RAW exactly as it was
+ rawOutput = textArea.value;
+ }
+
+ textArea.value = rawOutput;
gjsWrap.style.display = 'none';
- textArea.style.display = 'block';
+ // We don't display textArea because CodeMirror handles the UI
+ textArea.style.display = 'none';
+
+ // Initialize CodeMirror if not already
+ if (!cmEditor) {
+ cmEditor = CodeMirror.fromTextArea(textArea, {
+ mode: "htmlmixed",
+ theme: "monokai",
+ lineNumbers: true,
+ matchBrackets: true,
+ autoCloseTags: true,
+ indentUnit: 4,
+ lineWrapping: true
+ });
+ // Fix for initially hidden textarea
+ setTimeout(function() {
+ cmEditor.refresh();
+ }, 10);
+ } else {
+ cmEditor.setValue(rawOutput);
+ setTimeout(function() {
+ cmEditor.refresh();
+ }, 10);
+ }
+
+ // CodeMirror wrapper needs to be visible
+ if(cmEditor.getWrapperElement()) {
+ cmEditor.getWrapperElement().style.display = 'block';
+ }
+
toggleBtn.innerHTML = '
Use Visual Builder';
} else {
+ // Get value from CodeMirror back to textarea and GrapesJS
+ if (cmEditor) {
+ textArea.value = cmEditor.getValue();
+ cmEditor.getWrapperElement().style.display = 'none';
+ }
editor.setComponents(textArea.value);
+ isGrapesJsModified = false; // Reset flag since we just synced
+
textArea.style.display = 'none';
gjsWrap.style.display = 'block';
toggleBtn.innerHTML = '
Use Code Editor';
@@ -647,13 +722,19 @@
form.addEventListener('submit', function() {
if (isVisual) {
- var html = editor.getHtml();
- var css = editor.getCss();
- var finalOutput = html;
- if (css && css.trim() !== '' && css.trim() !== '* { box-sizing: border-box; } body {margin: 0;}') {
- finalOutput += '';
+ if (isGrapesJsModified) {
+ var html = editor.getHtml();
+ var css = editor.getCss();
+ var finalOutput = html;
+ if (css && css.trim() !== '' && css.trim() !== '* { box-sizing: border-box; } body {margin: 0;}') {
+ finalOutput += '';
+ }
+ textArea.value = finalOutput;
+ }
+ } else {
+ if (cmEditor) {
+ textArea.value = cmEditor.getValue();
}
- textArea.value = finalOutput;
}
});
});
diff --git a/sisvietnamvn_main/src/main/resources/templates/manage/widgets/list.html b/sisvietnamvn_main/src/main/resources/templates/manage/widgets/list.html
index c9717a65..04bd7546 100644
--- a/sisvietnamvn_main/src/main/resources/templates/manage/widgets/list.html
+++ b/sisvietnamvn_main/src/main/resources/templates/manage/widgets/list.html
@@ -31,6 +31,7 @@
Sidebar
Footer
+ Stats Block
Content...