Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
// This file is part of Moodle - http://moodle.org/
2
//
3
// Moodle is free software: you can redistribute it and/or modify
4
// it under the terms of the GNU General Public License as published by
5
// the Free Software Foundation, either version 3 of the License, or
6
// (at your option) any later version.
7
//
8
// Moodle is distributed in the hope that it will be useful,
9
// but WITHOUT ANY WARRANTY; without even the implied warranty of
10
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
// GNU General Public License for more details.
12
//
13
// You should have received a copy of the GNU General Public License
14
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
15
 
16
/* eslint-disable max-len,  */
17
 
18
/**
19
 * TinyMCE Editor Upstream defaults.
20
 *
21
 * @module     editor_tiny/defaults
22
 * @copyright  2022 Andrew Lyons <andrew@nicols.co.uk>
23
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
24
 */
25
 
26
/**
27
 * The upstream defaults for the TinyMCE Menu.
28
 *
29
 * This value is defined in the TinyMCE documentation, but not exported anywhere useful.
30
 * https://www.tiny.cloud/docs/tinymce/6/menus-configuration-options/#menu
31
 *
32
 * @returns {Object}
33
 */
34
export const getDefaultMenu = () => {
35
    return {
36
        file: {title: 'File', items: 'newdocument restoredraft | preview | export print | deleteallconversations'},
37
        edit: {title: 'Edit', items: 'undo redo | cut copy paste pastetext | selectall | searchreplace'},
38
        view: {title: 'View', items: 'code | visualaid visualchars visualblocks | spellchecker | preview fullscreen | showcomments'},
39
        insert: {title: 'Insert', items: 'image link media addcomment pageembed template codesample inserttable | charmap emoticons hr | pagebreak nonbreaking anchor tableofcontents | insertdatetime'},
40
        format: {title: 'Format', items: 'bold italic underline strikethrough superscript subscript codeformat | styles blocks fontfamily fontsize align lineheight | forecolor backcolor | language | removeformat'},
41
        tools: {title: 'Tools', items: 'spellchecker spellcheckerlanguage | a11ycheck code wordcount'},
42
        table: {title: 'Table', items: 'inserttable | cell row column | advtablesort | tableprops deletetable'},
43
        help: {title: 'Help', items: 'help'}
44
    };
45
};
46
 
47
/**
48
 * The default toolbar configuration to use.
49
 *
50
 * This is based upon the default value used if no toolbar is specified.
51
 *
52
 * https://www.tiny.cloud/docs/tinymce/6/menus-configuration-options/#menu
53
 *
54
 * @returns {Object}
55
 */
56
export const getDefaultToolbar = () => {
57
    return [
58
        {
59
            name: 'history',
60
            items: [
61
                'undo',
62
                'redo',
63
            ],
64
        },
65
        {
66
            name: 'formatting',
67
            items: [
68
                'bold',
69
                'italic',
70
            ],
71
        },
72
        {
73
            name: 'view',
74
            items: ['fullscreen'],
75
        },
76
        {
77
            name: 'alignment',
78
            items: [
79
                'alignleft',
80
                'aligncenter',
81
                'alignright',
82
                'alignjustify',
83
            ],
84
        },
85
        {
86
            name: 'indentation',
87
            items: [
88
                'outdent',
89
                'indent',
90
            ],
91
        },
92
        {
93
            name: 'lists',
94
            items: [
95
                'bullist',
96
                'numlist',
97
            ],
98
        },
99
        {
100
            name: 'comments',
101
            items: ['addcomment'],
102
        },
103
    ];
104
};
105
 
106
/**
107
 * The default quickbars_insert_toolbar configuration to use.
108
 *
109
 * This is based upon the default value used if no toolbar is specified.
110
 *
111
 * https://www.tiny.cloud/docs/tinymce/6/quickbars/#quickbars_selection_toolbar
112
 *
113
 * @returns {string}
114
 */
115
export const getDefaultQuickbarsSelectionToolbar = () => 'bold italic | quicklink h2 h3 blockquote';
116
 
117
/**
118
 * The default quickbars_insert_toolbar configuration to use.
119
 *
120
 * This is based upon the default value used if no toolbar is specified.
121
 *
122
 * https://www.tiny.cloud/docs/tinymce/6/quickbars/#quickbars_insert_toolbar
123
 *
124
 * @returns {string}
125
 */
126
export const getDefaultQuickbarsInsertToolbar = () => 'quickimage quicktable';
127
 
128
/**
129
 * The default quickbars_insert_toolbar configuration to use.
130
 *
131
 * This is based upon the default value used if no toolbar is specified.
132
 *
133
 * https://www.tiny.cloud/docs/tinymce/6/quickbars/#quickbars_image_toolbar
134
 *
135
 * @returns {string}
136
 */
137
export const getDefaultQuickbarsImageToolbar = () => 'alignleft aligncenter alignright';
138
 
139
/**
140
 * Get the default configuration provided by TinyMCE.
141
 *
142
 * @returns {object}
143
 */
144
export const getDefaultConfiguration = () => ({
145
    // Toolbar configuration.
146
    // https://www.tiny.cloud/docs/tinymce/6/toolbar-configuration-options/
147
    // TODO: Move this configuration to a passed-in option.
148
    // eslint-disable-next-line camelcase
149
    toolbar_mode: 'sliding',
150
    toolbar: getDefaultToolbar(),
151
 
152
    // Quickbars Selection Toolbar configuration.
153
    // https://www.tiny.cloud/docs/tinymce/6/quickbars/#quickbars_selection_toolbar
154
    // eslint-disable-next-line camelcase
155
    quickbars_selection_toolbar: getDefaultQuickbarsSelectionToolbar(),
156
 
157
    // Quickbars Select Toolbar configuration.
158
    // https://www.tiny.cloud/docs/tinymce/6/quickbars/#quickbars_insert_toolbar
159
    // eslint-disable-next-line camelcase
160
    quickbars_insert_toolbar: getDefaultQuickbarsInsertToolbar(),
161
 
162
    // Quickbars Image Toolbar configuration.
163
    // https://www.tiny.cloud/docs/tinymce/6/quickbars/#quickbars_image_toolbar
164
    // eslint-disable-next-line camelcase
165
    quickbars_image_toolbar: getDefaultQuickbarsImageToolbar(),
166
 
167
 
168
    // Menu configuration.
169
    // https://www.tiny.cloud/docs/tinymce/6/menus-configuration-options/
170
    // TODO: Move this configuration to a passed-in option.
171
    menu: getDefaultMenu(),
172
 
173
    // Mobile configuration.
174
    // At this time we will use the default TinyMCE mobile configuration.
175
    // https://www.tiny.cloud/docs/tinymce/6/tinymce-for-mobile/
176
 
177
    // Skins
178
    skin: 'oxide',
179
});