From d73fef7fe5621f5a3ad52c8553ac2fa17ebc7c2a Mon Sep 17 00:00:00 2001 From: ansuz Date: Wed, 14 Sep 2016 16:00:06 +0200 Subject: [PATCH 1/4] slightly better spacing --- customize.dist/main.css | 16 ++++++++-------- customize.dist/src/cryptpad.less | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/customize.dist/main.css b/customize.dist/main.css index 43169841c..771070bd8 100644 --- a/customize.dist/main.css +++ b/customize.dist/main.css @@ -421,38 +421,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); } From 997b46a3f7b2ca599391bbcf94a8af3fc2e02f62 Mon Sep 17 00:00:00 2001 From: ansuz Date: Wed, 14 Sep 2016 16:02:20 +0200 Subject: [PATCH 2/4] limit the size of rendered images --- www/slide/index.html | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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; + } From 8bf79ef9154f15953fbf9bd9f73eab000379dd3d Mon Sep 17 00:00:00 2001 From: ansuz Date: Wed, 14 Sep 2016 16:02:57 +0200 Subject: [PATCH 3/4] serialize slide pads as a sorted object --- www/slide/main.js | 43 ++++++++++++++++++++++++++++++++++++------- 1 file changed, 36 insertions(+), 7 deletions(-) diff --git a/www/slide/main.js b/www/slide/main.js index 0896b923e..e0ff1ed3b 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) { @@ -227,10 +254,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); @@ -255,7 +283,8 @@ define([ realtime: realtime }); - var content = canonicalize(realtime.getUserDoc()); + var userObj = getUserObj(APP.realtime); + var content = canonicalize(userObj.content || ''); $textarea.val(content); From cc4bca8004872944170765b079cae711d1dc7792 Mon Sep 17 00:00:00 2001 From: ansuz Date: Wed, 14 Sep 2016 16:03:52 +0200 Subject: [PATCH 4/4] execute callbacks on presentation events --- www/slide/slide.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) 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 () {