DmitrMakeev commited on
Commit
4a4339a
·
verified ·
1 Parent(s): 60a5e51

Update builder.html

Browse files
Files changed (1) hide show
  1. builder.html +262 -216
builder.html CHANGED
@@ -1,236 +1,282 @@
1
  <!DOCTYPE html>
2
  <html lang="en">
3
- <head>
4
- <meta charset="utf-8">
5
- <title>GrapesJS</title>
6
- <link rel="stylesheet" href="https://unpkg.com/grapesjs/dist/css/grapes.min.css">
7
- <script src="https://unpkg.com/grapesjs"></script>
8
- <script src="https://unpkg.com/grapesjs-custom-code/dist/grapesjs-custom-code.min.js"></script>
9
- <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/sweetalert2@11/dist/sweetalert2.min.css">
10
- <script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
  <style>
12
- body,
13
- html {
14
- height: 100%;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
  margin: 0;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
  }
17
  </style>
18
- </head>
19
 
20
- <body>
21
- <div id="gjs" style="height:0px; overflow:hidden;">
22
- <div class="panel">
23
- <h1 class="welcome">Welcome to</h1>
24
- <div class="big-title">
25
- <svg class="logo" viewBox="0 0 100 100">
26
- <path d="M40 5l-12.9 7.4 -12.9 7.4c-1.4 0.8-2.7 2.3-3.7 3.9 -0.9 1.6-1.5 3.5-1.5 5.1v14.9 14.9c0 1.7 0.6 3.5 1.5 5.1 0.9 1.6 2.2 3.1 3.7 3.9l12.9 7.4 12.9 7.4c1.4 0.8 3.3 1.2 5.2 1.2 1.9 0 3.8-0.4 5.2-1.2l12.9-7.4 12.9-7.4c1.4-0.8 2.7-2.2 3.7-3.9 0.9-1.6 1.5-3.5 1.5-5.1v-14.9 -12.7c0-4.6-3.8-6-6.8-4.2l-28 16.2"/>
27
- </svg>
28
- <span>GrapesJS</span>
29
- </div>
30
- <div class="description">
31
- This is a demo content from index.html. For the development, you shouldn't edit this file, instead you can
32
- copy and rename it to _index.html, on next server start the new file will be served, and it will be ignored by git.
33
- </div>
34
- <button class="add-button" onclick="addCustomScript()">Добавить свой скрипт</button>
35
- <button class="add-button" onclick="exportHtml()">Скачать HTML</button>
36
- </div>
37
- <style>
38
- .panel {
39
- width: 90%;
40
- max-width: 700px;
41
- border-radius: 3px;
42
- padding: 30px 20px;
43
- margin: 150px auto 0px;
44
- background-color: #d983a6;
45
- box-shadow: 0px 3px 10px 0px rgba(0,0,0,0.25);
46
- color:rgba(255,255,255,0.75);
47
- font: caption;
48
- font-weight: 100;
49
- }
50
- .welcome {
51
- text-align: center;
52
- font-weight: 100;
53
- margin: 0px;
54
- }
55
- .logo {
56
- width: 70px;
57
- height: 70px;
58
- vertical-align: middle;
59
- }
60
- .logo path {
61
- pointer-events: none;
62
- fill: none;
63
- stroke-linecap: round;
64
- stroke-width: 7;
65
- stroke: #fff
66
- }
67
- .big-title {
68
- text-align: center;
69
- font-size: 3.5rem;
70
- margin: 15px 0;
71
- }
72
- .description {
73
- text-align: justify;
74
- font-size: 1rem;
75
- line-height: 1.5rem;
76
- }
77
- .add-button {
78
- display: block;
79
- margin: 20px auto 0;
80
- padding: 10px 20px;
81
- font-size: 1rem;
82
- color: #fff;
83
- background-color: #007bff;
84
- border: none;
85
- border-radius: 5px;
86
- cursor: pointer;
87
- }
88
- </style>
89
- </div>
90
 
91
- <script type="text/javascript">
92
- var editor = grapesjs.init({
93
- showOffsets: 1,
94
- noticeOnUnload: 0,
95
- container: '#gjs',
96
- height: '100%',
97
- fromElement: true,
98
- storageManager: { autoload: 0 },
99
- styleManager : {
100
- sectors: [{
101
- name: 'General',
102
- open: false,
103
- buildProps: ['float', 'display', 'position', 'top', 'right', 'left', 'bottom']
104
- },{
105
- name: 'Flex',
106
- open: false,
107
- buildProps: ['flex-direction', 'flex-wrap', 'justify-content', 'align-items', 'align-content', 'order', 'flex-basis', 'flex-grow', 'flex-shrink', 'align-self']
108
- },{
109
- name: 'Dimension',
110
- open: false,
111
- buildProps: ['width', 'height', 'max-width', 'min-height', 'margin', 'padding'],
112
- },{
113
- name: 'Typography',
114
- open: false,
115
- buildProps: ['font-family', 'font-size', 'font-weight', 'letter-spacing', 'color', 'line-height', 'text-shadow'],
116
- },{
117
- name: 'Decorations',
118
- open: false,
119
- buildProps: ['border-radius-c', 'background-color', 'border-radius', 'border', 'box-shadow', 'background'],
120
- },{
121
- name: 'Extra',
122
- open: false,
123
- buildProps: ['transition', 'perspective', 'transform'],
124
- }
125
- ],
126
  },
127
- });
128
- // Add blocks for each element
129
- editor.BlockManager.add('welcome-block', {
130
- label: 'Welcome Title',
131
- content: `<h1 class="welcome">Welcome to</h1>`
132
- });
133
- editor.BlockManager.add('big-title-block', {
134
- label: 'Big Title',
135
- content: `
136
- <div class="big-title">
137
- <svg class="logo" viewBox="0 0 100 100">
138
- <path d="M40 5l-12.9 7.4 -12.9 7.4c-1.4 0.8-2.7 2.3-3.7 3.9 -0.9 1.6-1.5 3.5-1.5 5.1v14.9 14.9c0 1.7 0.6 3.5 1.5 5.1 0.9 1.6 2.2 3.1 3.7 3.9l12.9 7.4 12.9 7.4c1.4 0.8 3.3 1.2 5.2 1.2 1.9 0 3.8-0.4 5.2-1.2l12.9-7.4 12.9-7.4c1.4-0.8 2.7-2.2 3.7-3.9 0.9-1.6 1.5-3.5 1.5-5.1v-14.9 -12.7c0-4.6-3.8-6-6.8-4.2l-28 16.2"/>
139
- </svg>
140
- <span>GrapesJS</span>
141
- </div>
142
- `
143
- });
144
- editor.BlockManager.add('description-block', {
145
- label: 'Description',
146
- content: `<div class="description">This is a demo content from index.html. For the development, you shouldn't edit this file, instead you can copy and rename it to _index.html, on next server start the new file will be served, and it will be ignored by git.</div>`
147
- });
148
- editor.BlockManager.add('button-block', {
149
- label: 'Add Button',
150
- content: `<button class="add-button">Ещё добавь</button>`
151
- });
152
- </script>
153
 
154
- <script type="text/javascript">
155
- var editor = grapesjs.init({
156
- container : '#gjs',
157
- ...
158
- plugins: ['grapesjs-custom-code'],
159
- pluginsOpts: {
160
- 'grapesjs-custom-code': {
161
- // options
162
- }
 
 
163
  }
 
 
 
 
 
 
 
 
164
  });
165
- </script>
166
 
167
- <script>
168
- function addCustomScript() {
169
- Swal.fire({
170
- title: 'Добавить свой скрипт',
171
- input: 'textarea',
172
- inputPlaceholder: 'Введите ваш скрипт здесь...',
173
- showCancelButton: true,
174
- confirmButtonText: 'Добавить',
175
- cancelButtonText: 'Отмена',
176
- inputValidator: (value) => {
177
- if (!value) {
178
- return 'Вы должны ввести скрипт!'
179
- }
180
- }
181
- }).then((result) => {
182
- if (result.isConfirmed) {
183
- const script = `<script>${result.value}<\/script>`;
184
- const htmlCode = editor.getHtml();
185
- const newHtml = htmlCode + script;
186
- editor.setComponents(newHtml);
187
- }
188
- });
189
  }
190
 
191
- function exportHtml() {
192
- const htmlCode = editor.getHtml();
193
- const cssCode = editor.getCss();
194
- const jsCode = editor.getJs();
195
 
196
- // Собираем выбранные скрипты
197
- const selectedScripts = [];
198
- if (document.getElementById('script1-checkbox').checked) {
199
- selectedScripts.push(document.getElementById('script1-checkbox').value);
200
- }
201
- if (document.getElementById('script2-checkbox').checked) {
202
- selectedScripts.push(document.getElementById('script2-checkbox').value);
203
- }
204
- if (document.getElementById('script3-checkbox').checked) {
205
- selectedScripts.push(document.getElementById('script3-checkbox').value);
206
- }
 
 
 
207
 
208
- // Собираем дополнительные скрипты
209
- const additionalScripts = selectedScripts.map(script => `<script src="${script}"><\/script>`).join('');
 
 
 
 
 
 
 
210
 
211
- // Объединение всего в один HTML-файл
212
- const fullHtml = `
213
- <!DOCTYPE html>
214
- <html>
215
- <head>
216
- <style>${cssCode}</style>
217
- </head>
218
- <body>
219
- ${htmlCode}
220
- <script>${jsCode}<\/script>
221
- ${additionalScripts}
222
- </body>
223
- </html>
224
- `;
225
 
226
- // Сохранение HTML-файла
227
- const blob = new Blob([fullHtml], { type: 'text/html' });
228
- const url = URL.createObjectURL(blob);
229
- const a = document.createElement('a');
230
- a.href = url;
231
- a.download = 'page.html';
232
- a.click();
233
- }
234
- </script>
235
- </body>
236
  </html>
 
1
  <!DOCTYPE html>
2
  <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <title>GrapesJS with Forms Plugin</title>
6
+ <link rel="stylesheet" href="https://unpkg.com/grapesjs/dist/css/grapes.min.css">
7
+ <script src="https://unpkg.com/grapesjs"></script>
8
+ <script src="https://unpkg.com/grapesjs-plugin-forms"></script>
9
+ <script src="https://unpkg.com/grapesjs-custom-code"></script>
10
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/sweetalert2@11/dist/sweetalert2.min.css">
11
+ <script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
12
+ <style>
13
+ /* Ваш существующий CSS */
14
+ body, html {
15
+ height: 100%;
16
+ margin: 0;
17
+ }
18
+ .image-container {
19
+ display: flex;
20
+ justify-content: space-between;
21
+ margin-top: 20px; /* Поднятие картинок выше формы */
22
+ }
23
+ .image-container img {
24
+ width: 30%;
25
+ height: auto;
26
+ margin: 0 10px; /* Увеличение расстояния между картинками */
27
+ }
28
+ @media (max-width: 768px) {
29
+ .image-container {
30
+ flex-direction: column;
31
+ }
32
+ .image-container img {
33
+ width: 100%;
34
+ margin: 10px 0; /* Увеличение расстояния между картинками на мобильных устройствах */
35
+ }
36
+ }
37
+ /* Стили для контейнера управления */
38
+ .controls-container {
39
+ background-color: #302f2f; /* Черный фон контейнера */
40
+ padding: 15px 0; /* Отступы сверху и снизу */
41
+ text-align: center; /* Выравнивание по центру */
42
+ }
43
+ .controls-container label,
44
+ .controls-container button {
45
+ margin-left: 15px; /* Отступ слева */
46
+ }
47
+ /* Стили для кнопки "Скачать HTML" */
48
+ #export-html {
49
+ background-color: #ccc; /* Серый фон кнопки */
50
+ color: #000; /* Черный цвет текста кнопки */
51
+ border: none;
52
+ padding: 10px 15px; /* Размер кнопки */
53
+ font-size: 16px; /* Размер текста кнопки */
54
+ cursor: pointer;
55
+ border-radius: 5px; /* Скругление углов */
56
+ transition: background-color 0.3s ease; /* Плавный переход при наведении */
57
+ }
58
+ #export-html:hover {
59
+ background-color: #bbb; /* Фон кнопки при наведении */
60
+ }
61
+ /* Стили для надписей возле галочек */
62
+ .controls-container label {
63
+ color: #fff; /* Белый цвет текста */
64
+ }
65
+ </style>
66
+ </head>
67
+ <body>
68
+ <div id="gjs" style="height:0px; overflow:hidden;">
69
+ <!-- Ваш существующий HTML контент -->
70
+ <div class="panel">
71
+ <h1 class="welcome">Добро пожаловать!</h1>
72
+ <div class="big-title">
73
+ <img class="logo" src="https://via.placeholder.com/70x70.png?text=Logo" alt="Logo">
74
+ <span>Конструктор лендингов и подписных ВК</span>
75
+ </div>
76
+ <div class="description">
77
+ В связке с WhatsMasterCRM, VK Mini Apps, Автопилот. Ботхелп. Тильда, Геткурс.
78
+ </div>
79
+ <form class="centered-form">
80
+ <input type="text" name="name" placeholder="Имя">
81
+ <input type="email" name="email" placeholder="Email">
82
+ <input type="tel" name="phone" placeholder="Телефон">
83
+ <label class="checkbox-label"><input type="checkbox" name="subscribe" autocomplete="off"> I agree to the newsletter</label>
84
+ </form>
85
+ <button class="add-button">Зарегистрироваться</button>
86
+ <div class="image-container">
87
+ <img src="https://via.placeholder.com/150" alt="Placeholder Image 1">
88
+ <img src="https://via.placeholder.com/150" alt="Placeholder Image 2">
89
+ <img src="https://via.placeholder.com/150" alt="Placeholder Image 3">
90
+ </div>
91
+ </div>
92
  <style>
93
+ .panel {
94
+ width: 90%;
95
+ max-width: 700px;
96
+ border-radius: 3px;
97
+ padding: 30px 20px;
98
+ margin: 150px auto 0px;
99
+ background-color: #d983a6;
100
+ box-shadow: 0px 3px 10px 0px rgba(0,0,0,0.25);
101
+ color: rgba(255,255,255,0.75);
102
+ font: caption;
103
+ font-weight: 100;
104
+ text-align: center;
105
+ }
106
+ .welcome {
107
+ text-align: center;
108
+ font-weight: 100;
109
+ margin: 0px;
110
+ }
111
+ .logo {
112
+ width: 70px;
113
+ height: 70px;
114
+ vertical-align: middle;
115
+ border-radius: 50%; /* Скругление углов для логотипа */
116
+ }
117
+ .big-title {
118
+ text-align: center;
119
+ font-size: 3.5rem;
120
+ margin: 15px 0;
121
+ }
122
+ .description {
123
+ text-align: justify;
124
+ font-size: 1rem;
125
+ line-height: 1.5rem;
126
+ }
127
+ .centered-form {
128
+ display: inline-block;
129
+ text-align: left;
130
+ }
131
+ .centered-form input {
132
+ display: block;
133
+ width: 100%;
134
+ margin-bottom: 10px;
135
+ }
136
+ .checkbox-label {
137
+ display: flex;
138
+ align-items: center;
139
+ margin-bottom: 10px;
140
+ padding: 0;
141
+ }
142
+ .checkbox-label input[type="checkbox"] {
143
  margin: 0;
144
+ width: 100%;
145
+ height: 100%;
146
+ flex-basis: 0;
147
+ autocomplete: off;
148
+ }
149
+ .checkbox-label span {
150
+ margin-left: 15px; /* Добавление отступа справа */
151
+ }
152
+ .add-button {
153
+ display: block;
154
+ margin: 20px auto 0;
155
+ padding: 10px 20px;
156
+ font-size: 1rem;
157
+ color: #fff;
158
+ background-color: #007bff;
159
+ border: none;
160
+ border-radius: 5px;
161
+ cursor: pointer;
162
  }
163
  </style>
164
+ </div>
165
 
166
+ <!-- Интерфейс для выбора скриптов -->
167
+ <div class="controls-container">
168
+ <label><input type="checkbox" id="script1-checkbox" value="https://example.com/your-additional-script1.js" checked> Соб. хост</label>
169
+ <label><input type="checkbox" id="script2-checkbox" value="https://example.com/your-additional-script2.js"> ВК + АП</label>
170
+ <label><input type="checkbox" id="script3-checkbox" value="https://example.com/your-additional-script3.js"> Виджет Тильда</label>
171
+ <label><input type="checkbox" id="script4-checkbox" value="https://example.com/your-additional-script4.js"> Виджет Геткурс</label>
172
+ <button id="add-custom-script">Добавить свой скрипт</button>
173
+ <button id="export-html">Скачать HTML</button>
174
+ </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
175
 
176
+ <script type="text/javascript" src="https://huggingface.co/spaces/DMTuit/psy_vk/resolve/main/js/sav_html.js"></script>
177
+
178
+ <script type="text/javascript">
179
+ var editor = grapesjs.init({
180
+ showOffsets: 1,
181
+ noticeOnUnload: 0,
182
+ container: '#gjs',
183
+ height: '100%',
184
+ fromElement: true,
185
+ storageManager: { autoload: 0 },
186
+ plugins: ['grapesjs-plugin-forms', 'grapesjs-custom-code'],
187
+ pluginsOpts: {
188
+ 'grapesjs-plugin-forms': {
189
+ // options
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
190
  },
191
+ 'grapesjs-custom-code': {
192
+ blockCustomCode: {
193
+ label: 'Custom Code',
194
+ category: 'Extra',
195
+ attributes: { class: 'fa fa-code' }
196
+ },
197
+ modalTitle: 'Insert your code',
198
+ buttonLabel: 'Save',
199
+ placeholderScript: '// Your JavaScript code here', // Плейсхолдер для скрипта
200
+ codeViewOptions: {
201
+ theme: 'hopscotch',
202
+ readOnly: 0
203
+ }
204
+ }
205
+ }
206
+ });
 
 
 
 
 
 
 
 
 
 
207
 
208
+ document.getElementById('add-custom-script').addEventListener('click', function() {
209
+ Swal.fire({
210
+ title: 'Добавить свой скрипт',
211
+ input: 'textarea',
212
+ inputPlaceholder: 'Введите ваш скрипт здесь...',
213
+ showCancelButton: true,
214
+ confirmButtonText: 'Добавить',
215
+ cancelButtonText: 'Отмена',
216
+ inputValidator: (value) => {
217
+ if (!value) {
218
+ return 'Вы должны ввести скрипт!'
219
  }
220
+ }
221
+ }).then((result) => {
222
+ if (result.isConfirmed) {
223
+ const script = `<script>${result.value}<\/script>`;
224
+ const htmlCode = editor.getHtml();
225
+ const newHtml = htmlCode + script;
226
+ editor.setComponents(newHtml);
227
+ }
228
  });
229
+ });
230
 
231
+ document.getElementById('export-html').addEventListener('click', function() {
232
+ const htmlCode = editor.getHtml();
233
+ const cssCode = editor.getCss();
234
+ const jsCode = editor.getJs();
235
+
236
+ // Собираем выбранные скрипты
237
+ const selectedScripts = [];
238
+ if (document.getElementById('script1-checkbox').checked) {
239
+ selectedScripts.push(document.getElementById('script1-checkbox').value);
240
+ }
241
+ if (document.getElementById('script2-checkbox').checked) {
242
+ selectedScripts.push(document.getElementById('script2-checkbox').value);
243
+ }
244
+ if (document.getElementById('script3-checkbox').checked) {
245
+ selectedScripts.push(document.getElementById('script3-checkbox').value);
246
+ }
247
+ if (document.getElementById('script4-checkbox').checked) {
248
+ selectedScripts.push(document.getElementById('script4-checkbox').value);
 
 
 
 
249
  }
250
 
251
+ // Собираем дополнительные скрипты
252
+ const additionalScripts = selectedScripts.map(script => `<script src="${script}"><\/script>`).join('');
 
 
253
 
254
+ // Объединение всего в один HTML-файл
255
+ const fullHtml = `
256
+ <!DOCTYPE html>
257
+ <html>
258
+ <head>
259
+ <style>${cssCode}</style>
260
+ </head>
261
+ <body>
262
+ ${htmlCode}
263
+ <script>${jsCode}<\/script>
264
+ ${additionalScripts}
265
+ </body>
266
+ </html>
267
+ `;
268
 
269
+ // Сохранение HTML-файла
270
+ const blob = new Blob([fullHtml], { type: 'text/html' });
271
+ const url = URL.createObjectURL(blob);
272
+ const a = document.createElement('a');
273
+ a.href = url;
274
+ a.download = 'page.html';
275
+ a.click();
276
+ });
277
+ </script>
278
 
279
+ <!-- Функцию экспорта вынес в sav_html.js-->
 
 
 
 
 
 
 
 
 
 
 
 
 
280
 
281
+ </body>
 
 
 
 
 
 
 
 
 
282
  </html>