diff --git a/customize.dist/src/build.js b/customize.dist/src/build.js index c5c5c8d77..fbcc34942 100644 --- a/customize.dist/src/build.js +++ b/customize.dist/src/build.js @@ -60,7 +60,10 @@ var fragments = {}; }); // build static pages -['../www/settings/index'].forEach(function (page) { +[ + '../www/settings/index', + '../www/user/index' +].forEach(function (page) { var source = swap(template, { topbar: fragments.topbar, fork: fragments.fork, diff --git a/customize.dist/translations/messages.fr.js b/customize.dist/translations/messages.fr.js index 24fff7a37..26cfc3129 100644 --- a/customize.dist/translations/messages.fr.js +++ b/customize.dist/translations/messages.fr.js @@ -52,6 +52,8 @@ define(function () { out.language = "Langue"; + out.comingSoon = "Bientôt disponible..."; + out.upgrade = "Améliorer"; out.upgradeTitle = "Améliorer votre compte pour augmenter la limite de stockage"; out.MB = "Mo"; @@ -95,6 +97,8 @@ define(function () { out.templateSaved = "Modèle enregistré !"; out.selectTemplate = "Sélectionner un modèle ou appuyer sur Échap"; + out.previewButtonTitle = "Afficher ou cacher la prévisualisation de Markdown"; + out.presentButtonTitle = "Entrer en mode présentation"; out.presentSuccess = 'Appuyer sur Échap pour quitter le mode présentation'; diff --git a/customize.dist/translations/messages.js b/customize.dist/translations/messages.js index c357cb557..dcafe6283 100644 --- a/customize.dist/translations/messages.js +++ b/customize.dist/translations/messages.js @@ -54,6 +54,8 @@ define(function () { out.language = "Language"; + out.comingSoon = "Coming soon..."; + out.upgrade = "Upgrade"; out.upgradeTitle = "Upgrade your account to increase the storage limit"; out.MB = "MB"; @@ -97,6 +99,8 @@ define(function () { out.templateSaved = "Template saved!"; out.selectTemplate = "Select a template or press escape"; + out.previewButtonTitle = "Display or hide the Markdown preview mode"; + out.presentButtonTitle = "Enter presentation mode"; out.presentSuccess = 'Hit ESC to exit presentation mode'; diff --git a/www/code/inner.html b/www/code/inner.html index 8dd02548a..36d5911ee 100644 --- a/www/code/inner.html +++ b/www/code/inner.html @@ -55,6 +55,11 @@ max-width: 80%; resize: horizontal; } + .CodeMirror.fullPage { + min-width: 100%; + max-width: 100%; + resize: none; + } .CodeMirror-focused .cm-matchhighlight { background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAIAAAACCAYAAABytg0kAAAAFklEQVQI12NgYGBgkKzc8x9CMDAwAAAmhwSbidEoSQAAAABJRU5ErkJggg==); background-position: bottom; diff --git a/www/code/main.js b/www/code/main.js index 04e20141a..6c9fbd0e1 100644 --- a/www/code/main.js +++ b/www/code/main.js @@ -13,14 +13,14 @@ define([ Cryptget, DiffMd) { var Messages = Cryptpad.Messages; - var module = window.APP = { + var APP = window.APP = { Cryptpad: Cryptpad, }; $(function () { Cryptpad.addLoadingScreen(); - var ifrw = module.ifrw = $('#pad-iframe')[0].contentWindow; + var ifrw = APP.ifrw = $('#pad-iframe')[0].contentWindow; var stringify = function (obj) { return JSONSortify(obj); }; @@ -28,6 +28,7 @@ define([ var toolbar; var editor; var $iframe = $('#pad-iframe').contents(); + var $previewContainer = $iframe.find('#previewContainer'); var $preview = $iframe.find('#preview'); $preview.click(function (e) { if (!e.target) { return; } @@ -58,7 +59,7 @@ define([ var isHistoryMode = false; - var setEditable = module.setEditable = function (bool) { + var setEditable = APP.setEditable = function (bool) { if (readOnly && bool) { return; } editor.setOption('readOnly', !bool); }; @@ -121,21 +122,24 @@ define([ var textValue = canonicalize(CodeMirror.$textarea.val()); var shjson = stringifyInner(textValue); - module.patchText(shjson); + APP.patchText(shjson); - if (module.realtime.getUserDoc() !== shjson) { + if (APP.realtime.getUserDoc() !== shjson) { console.error("realtime.getUserDoc() !== shjson"); } }; var onModeChanged = function (mode) { - if (mode === "markdown") { + var $codeMirror = $iframe.find('.CodeMirror'); + if (mode === "markdown") { APP.$previewButton.show(); - $preview.show(); + $previewContainer.show(); + $codeMirror.removeClass('fullPage'); return; } APP.$previewButton.hide(); - $preview.hide(); + $previewContainer.hide(); + $codeMirror.addClass('fullPage'); }; config.onInit = function (info) { @@ -161,7 +165,7 @@ define([ network: info.network, $container: $bar }; - toolbar = module.toolbar = Toolbar.create(configTb); + toolbar = APP.toolbar = Toolbar.create(configTb); Title.setToolbar(toolbar); CodeMirror.init(config.onLocal, Title, toolbar); @@ -219,17 +223,25 @@ define([ var $previewButton = APP.$previewButton = Cryptpad.createButton(null, true); $previewButton.removeClass('fa-question').addClass('fa-eye'); - $previewButton.attr('title', 'TODO Preview'); //TODO + $previewButton.attr('title', Messages.previewButtonTitle); $previewButton.click(function () { + var $codeMirror = $iframe.find('.CodeMirror'); if (CodeMirror.highlightMode !== 'markdown') { - return void $preview.hide(); + $previewContainer.show(); + } + $previewContainer.toggle(); + if ($previewContainer.is(':visible')) { + $codeMirror.removeClass('fullPage'); + } else { + $codeMirror.addClass('fullPage'); } - $preview.toggle(); }); $rightside.append($previewButton); if (!readOnly) { - CodeMirror.configureLanguage(CodeMirror.configureTheme, onModeChanged); + CodeMirror.configureTheme(function () { + CodeMirror.configureLanguage(null, onModeChanged); + }); } else { CodeMirror.configureTheme(); @@ -240,15 +252,15 @@ define([ }; config.onReady = function (info) { - if (module.realtime !== info.realtime) { - var realtime = module.realtime = info.realtime; - module.patchText = TextPatcher.create({ + if (APP.realtime !== info.realtime) { + var realtime = APP.realtime = info.realtime; + APP.patchText = TextPatcher.create({ realtime: realtime, //logging: true }); } - var userDoc = module.realtime.getUserDoc(); + var userDoc = APP.realtime.getUserDoc(); var isNew = false; if (userDoc === "" || userDoc === "{}") { isNew = true; } @@ -301,7 +313,7 @@ define([ if (isHistoryMode) { return; } var oldDoc = canonicalize(CodeMirror.$textarea.val()); - var shjson = module.realtime.getUserDoc(); + var shjson = APP.realtime.getUserDoc(); // Update the user list (metadata) from the hyperjson Metadata.update(shjson); @@ -312,7 +324,7 @@ define([ DiffMd.apply(DiffMd.render(remoteDoc), $preview); var highlightMode = hjson.highlightMode; - if (highlightMode && highlightMode !== module.highlightMode) { + if (highlightMode && highlightMode !== APP.highlightMode) { CodeMirror.setMode(highlightMode, onModeChanged); } @@ -324,7 +336,7 @@ define([ if (shjson2 !== shjson) { console.error("shjson2 !== shjson"); TextPatcher.log(shjson, TextPatcher.diff(shjson, shjson2)); - module.patchText(shjson2); + APP.patchText(shjson2); } } if (oldDoc !== remoteDoc) { Cryptpad.notify(); } @@ -351,7 +363,7 @@ define([ config.onError = onConnectError; - module.realtime = Realtime.start(config); + APP.realtime = Realtime.start(config); editor.on('change', onLocal); diff --git a/www/common/common-codemirror.js b/www/common/common-codemirror.js index 4bc38cc46..429e9bd9a 100644 --- a/www/common/common-codemirror.js +++ b/www/common/common-codemirror.js @@ -158,10 +158,10 @@ define([ }); if ($rightside) { $rightside.append($block); } - cb(); + if (cb) { cb(); } }; - exp.configureTheme = function () { + exp.configureTheme = function (cb) { /* Remember the user's last choice of theme using localStorage */ var themeKey = 'CRYPTPAD_CODE_THEME'; var lastTheme = localStorage.getItem(themeKey) || 'default'; @@ -195,6 +195,7 @@ define([ }); if ($rightside) { $rightside.append($block); } + if (cb) { cb(); } }; exp.exportText = function () { diff --git a/www/common/diffMarked.js b/www/common/diffMarked.js index 2de647e86..f53e01d61 100644 --- a/www/common/diffMarked.js +++ b/www/common/diffMarked.js @@ -6,7 +6,7 @@ define([ var DiffMd = {}; var DiffDOM = window.diffDOM; - var renderer = DiffMd.renderer = new Marked.Renderer(); + var renderer = new Marked.Renderer(); Marked.setOptions({ renderer: renderer @@ -16,6 +16,24 @@ define([ return Marked(md); }; + // Tasks list + var checkedTaskItemPtn = /^\s*\[x\]\s*/; + var uncheckedTaskItemPtn = /^\s*\[ \]\s*/; + renderer.listitem = function (text) { + var isCheckedTaskItem = checkedTaskItemPtn.test(text); + var isUncheckedTaskItem = uncheckedTaskItemPtn.test(text); + if (isCheckedTaskItem) { + text = text.replace(checkedTaskItemPtn, + ' ') + '\n'; + } + if (isUncheckedTaskItem) { + text = text.replace(uncheckedTaskItemPtn, + ' ') + '\n'; + } + var cls = (isCheckedTaskItem || isUncheckedTaskItem) ? ' class="todo-list-item"' : ''; + return '