Update builder.html
Browse files- builder.html +262 -216
builder.html
CHANGED
@@ -1,236 +1,282 @@
|
|
1 |
<!DOCTYPE html>
|
2 |
<html lang="en">
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
<style>
|
12 |
-
|
13 |
-
|
14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
margin: 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
}
|
17 |
</style>
|
18 |
-
</
|
19 |
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
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 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
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 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
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 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
|
|
|
|
163 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
164 |
});
|
165 |
-
|
166 |
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
const newHtml = htmlCode + script;
|
186 |
-
editor.setComponents(newHtml);
|
187 |
-
}
|
188 |
-
});
|
189 |
}
|
190 |
|
191 |
-
|
192 |
-
|
193 |
-
const cssCode = editor.getCss();
|
194 |
-
const jsCode = editor.getJs();
|
195 |
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
|
|
|
|
|
|
207 |
|
208 |
-
|
209 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
210 |
|
211 |
-
|
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 |
-
|
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>
|