Only the HTML code would be recognised by the current function, and there was a updatePreview function to transfer the content on the editor to the preview window. Specifically, the function would input the code on the HTML box as the "Body" part of the preview box. See codes below:
function updatePreview () {
var editorContent = aceEditor.getSession().getValue();
$preview.contents().find('body').html(editorContent);
}
Below is the function of setting up the html editor:
(function (){
var $editorContainer = $('.news-item-container'),
$html_editor = $('#editor'),
//added a new variable as the css editor
$css_editor = $('#csseditor'),
$preview = $('#preview'),
aceEditor,
aceEditorCss,
resizable = true,
testMarkupCss="";
function setupEditor () {
aceEditor = ace.edit("editor");
aceEditor.setShowPrintMargin(false);
aceEditor.getSession().setUseWorker(false);
aceEditor.getSession().setMode("ace/mode/html");
aceEditor.getSession().on('change', updatePreview);
aceEditor.setValue(testMarkup);
}
To make the css editor works, I recreate another editor using the same formatted function of existing HTML editor. However, CSS languages were set up for letting the ACE editor recognise and generate the suitable editor for the editing. Codes below:
function setupCssEditor () {
aceEditorCss = ace.edit("csseditor");
aceEditorCss.setShowPrintMargin(false);
aceEditorCss.getSession().setUseWorker(false);
aceEditorCss.getSession().setMode("ace/mode/css");
aceEditorCss.getSession().on('change', updateCssPreview);
aceEditorCss.setValue(testMarkupCss);
aceEditorCss.getSession().setUseWrapMode(true);
}
To make the css function to work for the preview box. As the previous html editor has been occupied the "body" part of the preview section, the css content would then be put into the "head" part of the preview section, codes below:
function updateCssPreview () {
var editorContent = aceEditorCss.getSession().getValue();
$preview.contents().find('head').html(editorContent);
}
Because of the characteristic of css content, putting them into the head part of page would still make the styling functioned for the page. After adding an opening and closing tag in the css window, the styling works for the preview page instantly!



