mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-12-20 15:30:39 +01:00
fix: ace
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
'use strict';
|
||||
|
||||
define('admin/appearance/customise', ['admin/settings', 'ace-editor'], function (Settings, ace) {
|
||||
define('admin/appearance/customise', ['admin/settings', 'ace/ace'], function (Settings, ace) {
|
||||
const Customise = {};
|
||||
|
||||
Customise.init = function () {
|
||||
@@ -9,36 +9,9 @@ define('admin/appearance/customise', ['admin/settings', 'ace-editor'], function
|
||||
$('#customJS').text($('#customJS-holder').val());
|
||||
$('#customHTML').text($('#customHTML-holder').val());
|
||||
|
||||
const customCSS = ace.edit('customCSS');
|
||||
const customJS = ace.edit('customJS');
|
||||
const customHTML = ace.edit('customHTML');
|
||||
|
||||
customCSS.setTheme('ace/theme/twilight');
|
||||
customCSS.getSession().setMode('ace/mode/less');
|
||||
|
||||
customCSS.on('change', function () {
|
||||
app.flags = app.flags || {};
|
||||
app.flags._unsaved = true;
|
||||
$('#customCSS-holder').val(customCSS.getValue());
|
||||
});
|
||||
|
||||
customJS.setTheme('ace/theme/twilight');
|
||||
customJS.getSession().setMode('ace/mode/javascript');
|
||||
|
||||
customJS.on('change', function () {
|
||||
app.flags = app.flags || {};
|
||||
app.flags._unsaved = true;
|
||||
$('#customJS-holder').val(customJS.getValue());
|
||||
});
|
||||
|
||||
customHTML.setTheme('ace/theme/twilight');
|
||||
customHTML.getSession().setMode('ace/mode/html');
|
||||
|
||||
customHTML.on('change', function () {
|
||||
app.flags = app.flags || {};
|
||||
app.flags._unsaved = true;
|
||||
$('#customHTML-holder').val(customHTML.getValue());
|
||||
});
|
||||
initACE('customCSS', 'less', '#customCSS-holder');
|
||||
initACE('customJS', 'javascript', '#customJS-holder');
|
||||
initACE('customHTML', 'html', '#customHTML-holder');
|
||||
|
||||
$('#save').on('click', function () {
|
||||
if ($('#enableLiveReload').is(':checked')) {
|
||||
@@ -48,5 +21,20 @@ define('admin/appearance/customise', ['admin/settings', 'ace-editor'], function
|
||||
});
|
||||
};
|
||||
|
||||
function initACE(aceElementId, mode, holder) {
|
||||
var editorEl = ace.edit(aceElementId, {
|
||||
mode: 'ace/mode/' + mode,
|
||||
theme: 'ace/theme/twilight',
|
||||
maxLines: 30,
|
||||
minLines: 30,
|
||||
fontSize: 14,
|
||||
});
|
||||
editorEl.on('change', function () {
|
||||
app.flags = app.flags || {};
|
||||
app.flags._unsaved = true;
|
||||
$(holder).val(editorEl.getValue());
|
||||
});
|
||||
}
|
||||
|
||||
return Customise;
|
||||
});
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
|
||||
define('admin/settings/email', ['alerts', 'admin/settings', 'ace-editor'], function (ace, alerts) {
|
||||
define('admin/settings/email', ['ace/ace', 'alerts', 'admin/settings'], function (ace, alerts) {
|
||||
const module = {};
|
||||
let emailEditor;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import ace from 'ace-builds';
|
||||
export * from 'ace-builds';
|
||||
|
||||
// only import the modes and theme we use
|
||||
import 'ace-builds/src-noconflict/mode-javascript';
|
||||
|
||||
@@ -52,6 +52,7 @@ module.exports = {
|
||||
Chart: path.resolve(__dirname, 'node_modules/chart.js'),
|
||||
Sortable: path.resolve(__dirname, 'node_modules/sortablejs'),
|
||||
'jquery-ui/widgets': path.resolve(__dirname, 'node_modules/jquery-ui/ui/widgets'),
|
||||
'ace/ace': path.resolve(__dirname, 'build/public/src/modules/ace-editor.js'),
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user