Files
@ 1759a07630a8
Branch filter:
Location: symposion_app/static/src/pyconau2017/js/load_editors.js - annotation
1759a07630a8
1.3 KiB
application/javascript
A few mods to be able to use the runserver site for debugging. We'll back these out once the real
(via apache) site is up and running.
(via apache) site is up and running.
c42159468ede c42159468ede c42159468ede c42159468ede c42159468ede c42159468ede c42159468ede c42159468ede c42159468ede c42159468ede c42159468ede c42159468ede c42159468ede c42159468ede c42159468ede c42159468ede c42159468ede c42159468ede c42159468ede c42159468ede c42159468ede c42159468ede c42159468ede c42159468ede c42159468ede c42159468ede c42159468ede c42159468ede c42159468ede c42159468ede c42159468ede c42159468ede c42159468ede c42159468ede c42159468ede c42159468ede c42159468ede c42159468ede c42159468ede c42159468ede c42159468ede c42159468ede c42159468ede c42159468ede c42159468ede c42159468ede c42159468ede c42159468ede c42159468ede c42159468ede c42159468ede c42159468ede c42159468ede |
function setupEditor(editor, textarea) {
const session = editor.getSession();
//editor.setTheme('ace/theme/tomorrow');
editor.$blockScrolling = Infinity;
editor.setOption('scrollPastEnd', false);
session.setMode('ace/mode/markdown');
session.setValue(textarea.val());
session.setUseWrapMode(true);
session.on('change', () => {
textarea.val(session.getValue());
});
editor.renderer.setShowGutter(true);
session.setTabSize(4);
session.setUseSoftTabs(true);
}
function setEditorSize(reportDiv, textArea)
{
var w = textArea.width();
var h = textArea.height();
var border = textArea.css("border");
reportDiv.width(w);
reportDiv.height(h);
reportDiv.css("position", "relative");
reportDiv.css("border", border);
textArea.css("display", "none");
}
function loadEditor(id) {
var i = id;
var el = `#${i}`;
const editorId = `markdown-editor-${i}`;
const reportDiv = $('<div>').attr('id', editorId);
const $formGroup = $(el).closest('.form-group');
const $textarea = $(el);
$textarea.after(reportDiv);
editor = ace.edit(editorId);
setupEditor(editor, $textarea);
$textarea.resize(() => {
setEditorSize(reportDiv, $textarea);
editor.resize();
});
$textarea.resize();
return editor;
}
|