From 32d180735047494e84f4e60903bebed0cd42c10e Mon Sep 17 00:00:00 2001 From: ansuz Date: Wed, 27 Apr 2016 12:25:19 +0200 Subject: [PATCH] import unused functions from /p/, to be integrated later --- www/pad/main.js | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/www/pad/main.js b/www/pad/main.js index cb536cfac..084d57746 100644 --- a/www/pad/main.js +++ b/www/pad/main.js @@ -47,7 +47,7 @@ define([ var isNotMagicLine = function (el) { // factor as: // return !(el.tagName === 'SPAN' && el.contentEditable === 'false'); - var filter = (el.tagName === 'SPAN' && el.contentEditable === 'false'); + var filter = (el.tagName === 'SPAN' && el.getAttribute('contentEditable') === 'false'); if (filter) { console.log("[hyperjson.serializer] prevented an element" + "from being serialized:", el); @@ -62,6 +62,20 @@ define([ return hj; }; + /* TODO integrate into flow to prevent browser fights over style */ + var setStyle = function (elem, newStyleAttr) { + elem.setAttribute("data-chainpad-origstyle", newStyleAttr); + elem.setAttribute("style", newStyleAttr); + elem.setAttribute("data-chainpad-styleclone", elem.getAttribute("style")); + }; + + /* TODO integrate into flow to prevent browser fights over style */ + var getStyle = function (elem) { + var st = elem.getAttribute("style"); + if (elem.getAttribute("data-chainpad-styleclone") !== st) { return st; } + return elem.getAttribute("data-chainpad-origstyle"); + }; + var andThen = function (Ckeditor) { /* This is turned off because we prefer that the channel name be chosen by the server, not generated by the client. @@ -225,6 +239,9 @@ define([ // apply patches, and try not to lose the cursor in the process! var applyHjson = function (shjson) { var userDocStateDom = hjsonToDom(JSON.parse(shjson)); + + // we *might* be able to remove this now + // changes to hyperscript fixed this bug *maybe* --ansuz userDocStateDom.setAttribute("contenteditable", "true"); // lol wtf var patch = (DD).diff(inner, userDocStateDom); (DD).apply(inner, patch);