diff --git a/customize.dist/main.css b/customize.dist/main.css index fc7a13de9..bdae51e18 100644 --- a/customize.dist/main.css +++ b/customize.dist/main.css @@ -426,38 +426,38 @@ div.modal #content pre, div#modal #content pre, div.modal #content code, div#modal #content code { - font-size: 2.5vw; - line-height: 3vw; + font-size: 2.75vw; + line-height: 3.025vw; } div.modal #content h1, div#modal #content h1 { font-size: 5vw; - line-height: 6vw; + line-height: 5.5vw; } div.modal #content h2, div#modal #content h2 { font-size: 4.2vw; - line-height: 5.04vw; + line-height: 4.62vw; } div.modal #content h3, div#modal #content h3 { font-size: 3.6vw; - line-height: 4.32vw; + line-height: 3.96vw; } div.modal #content h4, div#modal #content h4 { font-size: 3vw; - line-height: 3.6vw; + line-height: 3.3vw; } div.modal #content h5, div#modal #content h5 { font-size: 2.2vw; - line-height: 2.64vw; + line-height: 2.42vw; } div.modal #content h6, div#modal #content h6 { font-size: 1.6vw; - line-height: 1.92vw; + line-height: 1.76vw; } div.modal #content pre > code, div#modal #content pre > code { diff --git a/customize.dist/src/cryptpad.less b/customize.dist/src/cryptpad.less index c70bb3168..a713d3e7c 100644 --- a/customize.dist/src/cryptpad.less +++ b/customize.dist/src/cryptpad.less @@ -484,7 +484,7 @@ div.modal, div#modal { box-sizing: border-box; .size (@n) { font-size: @n * 1vw; - line-height: @n * 1.2vw; + line-height: @n * 1.1vw; } border: 1px solid white; @@ -504,7 +504,7 @@ div.modal, div#modal { left:0;right:0; // horizontal center p, li, pre, code { - .size(2.5); + .size(2.75); } h1 { .size(5); } diff --git a/www/slide/index.html b/www/slide/index.html index af2d9d473..a49363098 100644 --- a/www/slide/index.html +++ b/www/slide/index.html @@ -81,7 +81,12 @@ #content ol { font-size: 26px; } - + #content img { + position: relative; + max-width: 90%; + max-height: 90%; + margin: auto; + } diff --git a/www/slide/main.js b/www/slide/main.js index 48d26d1cf..31d73f86d 100644 --- a/www/slide/main.js +++ b/www/slide/main.js @@ -1,3 +1,4 @@ +require.config({ paths: { 'json.sortify': '/bower_components/json.sortify/dist/JSON.sortify'} }); define([ '/api/config?cb=' + Math.random().toString(16).substring(2), '/customize/messages.js', @@ -9,10 +10,11 @@ define([ '/common/notify.js', '/common/visible.js', '/common/clipboard.js', + 'json.sortify', '/bower_components/file-saver/FileSaver.min.js', '/bower_components/jquery/dist/jquery.min.js', '/customize/pad.js' -], function (Config, Messages, Realtime, Crypto, TextPatcher, Cryptpad, Slide, Notify, Visible, Clipboard) { +], function (Config, Messages, Realtime, Crypto, TextPatcher, Cryptpad, Slide, Notify, Visible, Clipboard, JSONSortify) { var $ = window.jQuery; var saveAs = window.saveAs; @@ -36,6 +38,8 @@ define([ Slide: Slide, }; + var Stringify = APP.Stringify = JSONSortify; + var initializing = true; var $textarea = $('textarea'); @@ -69,7 +73,7 @@ define([ Slide.setModal($modal, $content); var config = APP.config = { - initialState: '', + initialState: '{}', websocketURL: Config.websocketURL, channel: secret.channel, crypto: Crypto.createEncryptor(secret.key), @@ -80,11 +84,34 @@ define([ setEditable(false); + var safelyParseContent = function (S, k, first) { + if (!first) { return JSON.parse(S); } + try { return JSON.parse(S); } + catch (err) { + console.log("Migrating text content to object form"); + var O = {}; + O[k] = S; + return O; + } + }; + + var getUserObj = function (rt) { + return safelyParseContent(rt.getUserDoc(), 'content'); + }; + var onLocal = config.onLocal = function () { if (initializing) { return; } - var content = canonicalize($textarea.val()); + + var textContent = canonicalize($textarea.val()); + + var userObj = getUserObj(APP.realtime); + + userObj.content = textContent; + + var content = Stringify(userObj); + APP.patchText(content); - Slide.update(content); + Slide.update(textContent); }; var Button = function (opt) { @@ -228,10 +255,11 @@ define([ .append($export) .append($share); }; - var onRemote = config.onRemote = function (info) { if (initializing) { return; } - var userDoc = APP.realtime.getUserDoc(); + var userObj = getUserObj(APP.realtime); + var userDoc = userObj.content; + var content = canonicalize($textarea.val()); var op = TextPatcher.diff(content, userDoc); @@ -256,7 +284,8 @@ define([ realtime: realtime }); - var content = canonicalize(realtime.getUserDoc()); + var userObj = getUserObj(APP.realtime); + var content = canonicalize(userObj.content || ''); $textarea.val(content); diff --git a/www/slide/slide.js b/www/slide/slide.js index 6c473f5d6..1e2391483 100644 --- a/www/slide/slide.js +++ b/www/slide/slide.js @@ -28,15 +28,11 @@ define([ }; var change = function (oldIndex, newIndex) { - if (oldIndex === newIndex) { - return false; - } if (Slide.changeHandlers.length) { Slide.changeHandlers.some(function (f, i) { // HERE f(oldIndex, newIndex, Slide.content.length); }); - return true; } }; @@ -132,7 +128,9 @@ define([ Slide.content = content.split(/\n\s*\-\-\-\s*\n/).filter(truthy); if (old !== Slide.content[Slide.index]) { draw(Slide.index); + return; } + change(Slide.lastIndex, Slide.index); }; var left = Slide.left = function () {