fix magicline filter and strange interaction with cursor

pull/1/head
ansuz 9 years ago
parent 303e8d6c3e
commit 36baf498ce

@ -45,21 +45,10 @@ define([
var userName = Crypto.rand64(8), var userName = Crypto.rand64(8),
toolbar; toolbar;
// TODO update this filter to use the .non-realtime class
var isNotMagicLine = function (el) { var isNotMagicLine = function (el) {
// factor as: return !(el && typeof(el.getAttribute) === 'function' &&
// return !(el.tagName === 'SPAN' && el.contentEditable === 'false'); el.getAttribute('class') &&
var filter = (el.tagName === 'SPAN' && el.getAttribute('class').split(' ').indexOf('non-realtime') !== -1);
el.getAttribute('contentEditable') === 'false' &&
/dashed/.test(el.getAttribute('style')) &&
/(rgb\(255|red)/.test(el.getAttribute('style')));
///magicline/.test(el.getAttribute('style')));
if (filter) {
console.log("[hyperjson.serializer] prevented an element" +
"from being serialized:", el);
return false;
}
return true;
}; };
/* catch `type="_moz"` before it goes over the wire */ /* catch `type="_moz"` before it goes over the wire */
@ -68,20 +57,6 @@ define([
return hj; 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) { var andThen = function (Ckeditor) {
/* This is turned off because we prefer that the channel name /* This is turned off because we prefer that the channel name
be chosen by the server, not generated by the client. be chosen by the server, not generated by the client.
@ -120,12 +95,13 @@ define([
editor.on('instanceReady', function (Ckeditor) { editor.on('instanceReady', function (Ckeditor) {
/* add a class to the magicline plugin so we can pick it out more easily */ /* add a class to the magicline plugin so we can pick it out more easily */
$('iframe')[0].contentWindow.CKEDITOR.instances.editor1.plugins.magicline
.backdoor.that.line.$.setAttribute('class', 'non-realtime');
/* in XWiki this is var ml = $('iframe')[0].contentWindow.CKEDITOR.instances.editor1.plugins.magicline
CKEDITOR.instances.content.plugins.magicline.backdoor.that.line .backdoor.that.line.$;
.$.setAttribute('class', 'non-realtime') */
[ml, ml.parentElement].forEach(function (el) {
el.setAttribute('class', 'non-realtime');
});
editor.execCommand('maximize'); editor.execCommand('maximize');
var documentBody = ifrw.$('iframe')[0].contentDocument.body; var documentBody = ifrw.$('iframe')[0].contentDocument.body;
@ -263,7 +239,7 @@ define([
(DD).apply(inner, patch); (DD).apply(inner, patch);
}; };
var stringifyDOM = function (dom) { var stringifyDOM = module.stringifyDOM = function (dom) {
var hjson = Hyperjson.fromDOM(dom, isNotMagicLine, brFilter); var hjson = Hyperjson.fromDOM(dom, isNotMagicLine, brFilter);
hjson[3] = {metadata: userList}; hjson[3] = {metadata: userList};
return stringify(hjson); return stringify(hjson);
@ -398,8 +374,8 @@ define([
// stringify the json and send it into chainpad // stringify the json and send it into chainpad
var shjson = stringifyDOM(inner); var shjson = stringifyDOM(inner);
module.patchText(shjson);
module.patchText(shjson);
if (module.realtime.getUserDoc() !== shjson) { if (module.realtime.getUserDoc() !== shjson) {
console.error("realtime.getUserDoc() !== shjson"); console.error("realtime.getUserDoc() !== shjson");
} }

Loading…
Cancel
Save