1. Migrated /slide/ to use framework

2. Fixed CSS not being applied on /slide/
3. Minor changes to /code/ to reuse code which is also used on /slide/
This commit is contained in:
Caleb James DeLisle
2017-10-02 17:34:37 +03:00
parent 1e5bc5da14
commit fa6938baa8
9 changed files with 352 additions and 602 deletions

View File

@@ -3,9 +3,10 @@ define([
'/common/modes.js',
'/common/themes.js',
'/common/cryptpad-common.js',
'/bower_components/textpatcher/TextPatcher.js',
'/bower_components/file-saver/FileSaver.min.js'
], function ($, Modes, Themes, Cryptpad) {
], function ($, Modes, Themes, Cryptpad, TextPatcher) {
var saveAs = window.saveAs;
var module = {};
@@ -305,6 +306,42 @@ define([
editor.scrollTo(scroll.left, scroll.top);
};
/////
var canonicalize = function (t) { return t.replace(/\r\n/g, '\n'); };
exp.contentUpdate = function (newContent) {
var oldDoc = canonicalize($textarea.val());
var remoteDoc = newContent.content;
exp.setValueAndCursor(oldDoc, remoteDoc, TextPatcher);
};
exp.getContent = function () {
editor.save();
return { content: canonicalize($textarea.val()) };
};
exp.mkFileManager = function (framework) {
var fmConfig = {
dropArea: $('.CodeMirror'),
body: $('body'),
onUploaded: function (ev, data) {
//var cursor = editor.getCursor();
//var cleanName = data.name.replace(/[\[\]]/g, '');
//var text = '!['+cleanName+']('+data.url+')';
var parsed = Cryptpad.parsePadUrl(data.url);
var hexFileName = Cryptpad.base64ToHex(parsed.hashData.channel);
var src = '/blob/' + hexFileName.slice(0,2) + '/' + hexFileName;
var mt = '<media-tag src="' + src + '" data-crypto-key="cryptpad:' +
parsed.hashData.key + '"></media-tag>';
editor.replaceSelection(mt);
}
};
framework._.sfCommon.createFileManager(fmConfig);
};
return exp;
};