Update builder2.html
Browse files- builder2.html +50 -98
builder2.html
CHANGED
@@ -1,106 +1,58 @@
|
|
1 |
<!DOCTYPE html>
|
2 |
<html lang="en">
|
3 |
<head>
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
#gjs {
|
17 |
-
height: 100vh;
|
18 |
-
}
|
19 |
-
.controls-container {
|
20 |
-
background-color: #302f2f;
|
21 |
-
padding: 15px 0;
|
22 |
-
text-align: center;
|
23 |
-
}
|
24 |
-
.controls-container label,
|
25 |
-
.controls-container button {
|
26 |
-
margin-left: 15px;
|
27 |
-
}
|
28 |
-
#export-html {
|
29 |
-
background-color: #ccc;
|
30 |
-
color: #000;
|
31 |
-
border: none;
|
32 |
-
padding: 10px 15px;
|
33 |
-
font-size: 16px;
|
34 |
-
cursor: pointer;
|
35 |
-
border-radius: 5px;
|
36 |
-
transition: background-color 0.3s ease;
|
37 |
-
}
|
38 |
-
#export-html:hover {
|
39 |
-
background-color: #bbb;
|
40 |
-
}
|
41 |
-
.controls-container label {
|
42 |
-
color: #fff;
|
43 |
-
}
|
44 |
-
</style>
|
45 |
</head>
|
46 |
<body>
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
panelId: 'views-container', // ID панель, куда добавляется редактор кода
|
62 |
-
codeViewOptions: {
|
63 |
-
theme: 'hopscotch', // Тема редактора кода
|
64 |
-
}
|
65 |
-
}
|
66 |
-
},
|
67 |
-
panels: {
|
68 |
-
defaults: [
|
69 |
-
{
|
70 |
-
id: 'views',
|
71 |
-
buttons: [
|
72 |
-
{
|
73 |
-
attributes: { title: 'Open Code' },
|
74 |
-
className: 'fa fa-code',
|
75 |
-
command: 'open-code',
|
76 |
-
id: 'open-code'
|
77 |
-
}
|
78 |
-
],
|
79 |
-
appendTo: '.gjs-pn-views-container'
|
80 |
-
}
|
81 |
-
]
|
82 |
-
}
|
83 |
-
});
|
84 |
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
|
|
|
|
|
|
|
|
105 |
</body>
|
106 |
-
</html>
|
|
|
1 |
<!DOCTYPE html>
|
2 |
<html lang="en">
|
3 |
<head>
|
4 |
+
<meta charset="UTF-8">
|
5 |
+
<title>GrapesJS Code Editor Example</title>
|
6 |
+
<link rel="stylesheet" href="https://unpkg.com/grapesjs/dist/css/grapes.min.css">
|
7 |
+
<script src="https://unpkg.com/grapesjs"></script>
|
8 |
+
<link rel="stylesheet" href="https://unpkg.com/grapesjs-component-code-editor/dist/grapesjs-component-code-editor.min.css">
|
9 |
+
<script src="https://unpkg.com/grapesjs-component-code-editor"></script>
|
10 |
+
<style>
|
11 |
+
body, html {
|
12 |
+
margin: 0;
|
13 |
+
height: 100%;
|
14 |
+
}
|
15 |
+
</style>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
</head>
|
17 |
<body>
|
18 |
+
<div id="gjs"></div>
|
19 |
+
<script type="text/javascript">
|
20 |
+
const editor = grapesjs.init({
|
21 |
+
container: '#gjs',
|
22 |
+
height: '100%',
|
23 |
+
fromElement: true,
|
24 |
+
storageManager: false,
|
25 |
+
plugins: ['grapesjs-component-code-editor'],
|
26 |
+
pluginsOpts: {
|
27 |
+
'grapesjs-component-code-editor': {
|
28 |
+
// options
|
29 |
+
}
|
30 |
+
}
|
31 |
+
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
|
33 |
+
// Добавляем команду для открытия редактора кода
|
34 |
+
editor.Commands.add('open-code', {
|
35 |
+
run: function(editor) {
|
36 |
+
editor.runCommand('open-code-editor');
|
37 |
+
}
|
38 |
+
});
|
39 |
|
40 |
+
// Добавляем кнопку для открытия редактора кода
|
41 |
+
const pn = editor.Panels;
|
42 |
+
const panelViews = pn.addPanel({
|
43 |
+
id: "views",
|
44 |
+
});
|
45 |
+
panelViews.get("buttons").add([
|
46 |
+
{
|
47 |
+
attributes: {
|
48 |
+
title: "Open Code",
|
49 |
+
},
|
50 |
+
className: "fa fa-file-code-o",
|
51 |
+
command: "open-code",
|
52 |
+
togglable: false, // Не закрывать при повторном нажатии
|
53 |
+
id: "open-code",
|
54 |
+
},
|
55 |
+
]);
|
56 |
+
</script>
|
57 |
</body>
|
58 |
+
</html>
|