File size: 1,957 Bytes
ca225b4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>GrapesJS Example</title>
    <!-- GrapesJS CSS -->
    <link rel="stylesheet" href="https://unpkg.com/grapesjs/dist/css/grapes.min.css">

</head>
<body>
    <div id="gjs"></div>

    <!-- GrapesJS JS -->
    <script src="https://unpkg.com/grapesjs"></script>
    <!-- GrapesJS Russian Language File -->
    <script src="https://unpkg.com/grapesjs/dist/i18n/ru.js"></script>


    <script type="text/javascript">
        const editor = grapesjs.init({
            container: '#gjs',
            fromElement: true,
            height: '100vh',
            storageManager: { type: 0 },
            plugins: [],
            pluginsOpts: {},
            i18n: {
                locale: 'ru', // Устанавливаем русский язык
                detectLocale: true, // Автоматически определяем язык браузера
                localeFallback: 'en', // Язык по умолчанию, если язык не поддерживается
                messages: {
                    ru: {
                        'blockManager.labels.section': 'Раздел',
                        'blockManager.labels.text': 'Текст',
                        'blockManager.labels.image': 'Изображение',
                        // Добавьте другие переводы здесь
                    }
                }
            }
        });

        // Example of adding a button with JavaScript code
        const blockManager = editor.BlockManager;
        blockManager.add('example-button', {
            label: 'Пример кнопки',
            content: `<button onclick="alert('Привет, Мир!');">Нажми меня</button>`,
            attributes: { class: 'gjs-block-section' }
        });
    </script>
</body>
</html>