diff --git a/customize.dist/translations/messages.js b/customize.dist/translations/messages.js index fc7c204d9..09d650c7f 100644 --- a/customize.dist/translations/messages.js +++ b/customize.dist/translations/messages.js @@ -166,6 +166,7 @@ define(function () { out.slideOptionsText = "Options"; out.slideOptionsTitle = "Customize your slides"; out.slideOptionsButton = "Save (enter)"; + out.slide_invalidLess = "Invalid custom style"; out.languageButton = "Language"; out.languageButtonTitle = "Select the language to use for the syntax highlighting"; diff --git a/www/code/inner.js b/www/code/inner.js index c6eaf8afd..97a044f4c 100644 --- a/www/code/inner.js +++ b/www/code/inner.js @@ -51,8 +51,6 @@ define([ window.CodeMirror = CMeditor; var Messages = Cryptpad.Messages; - var canonicalize = function (t) { return t.replace(/\r\n/g, '\n'); }; - var MEDIA_TAG_MODES = Object.freeze([ 'markdown', 'html', @@ -142,7 +140,6 @@ define([ framework.onReady(function () { // add the splitter - if ($('.cp-splitter').length) { return; } var splitter = $('
', { 'class': 'cp-splitter' }).appendTo($previewContainer); @@ -266,23 +263,19 @@ define([ //// framework.onContentUpdate(function (newContent) { - var oldDoc = canonicalize(CodeMirror.$textarea.val()); - var remoteDoc = newContent.content; + CodeMirror.contentUpdate(newContent); var highlightMode = newContent.highlightMode; if (highlightMode && highlightMode !== CodeMirror.highlightMode) { CodeMirror.setMode(highlightMode, evModeChange.fire); } - CodeMirror.setValueAndCursor(oldDoc, remoteDoc, TextPatcher); previewPane.draw(); }); framework.setContentGetter(function () { - editor.save(); + var content = CodeMirror.getContent(); + content.highlightMode = CodeMirror.highlightMode; previewPane.draw(); - return { - content: canonicalize(CodeMirror.$textarea.val()), - highlightMode: CodeMirror.highlightMode - }; + return content; }); framework.onEditableChange(function () { diff --git a/www/common/sframe-app-framework.js b/www/common/sframe-app-framework.js index fe4122ae7..7b3f47566 100644 --- a/www/common/sframe-app-framework.js +++ b/www/common/sframe-app-framework.js @@ -376,7 +376,9 @@ define([ }).nThen(function () { - title = common.createTitle({ getHeadingText: titleRecommender }, onLocal); + title = common.createTitle({ + getHeadingText: function () { return titleRecommender(); } + }, onLocal); var configTb = { displayed: ['userlist', 'title', 'useradmin', 'spinner', 'newpad', 'share', 'limit'], title: title.getTitleConfig(), diff --git a/www/common/sframe-common-codemirror.js b/www/common/sframe-common-codemirror.js index 6686a9a55..ea0eea38e 100644 --- a/www/common/sframe-common-codemirror.js +++ b/www/common/sframe-common-codemirror.js @@ -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 = ''; + editor.replaceSelection(mt); + } + }; + framework._.sfCommon.createFileManager(fmConfig); + }; + return exp; }; diff --git a/www/slide/app-slide.less b/www/slide/app-slide.less index f6ebf8cf0..c8080e53c 100644 --- a/www/slide/app-slide.less +++ b/www/slide/app-slide.less @@ -324,3 +324,6 @@ p { min-width:0; } +pre.cp-slide-css-error { + color: white; +} \ No newline at end of file diff --git a/www/slide/index.html b/www/slide/index.html index e3f7eacc4..7ea06cdfc 100644 --- a/www/slide/index.html +++ b/www/slide/index.html @@ -5,7 +5,7 @@ - +