Remove the toolbar in ckeditor history mode + history configurable
This commit is contained in:
parent
92ea03d7d9
commit
5fc2e4cf71
@ -32,7 +32,10 @@ define(function() {
|
|||||||
'#FF00C0', // hot pink
|
'#FF00C0', // hot pink
|
||||||
'#800080', // purple
|
'#800080', // purple
|
||||||
];
|
];
|
||||||
|
|
||||||
config.enableTemplates = true;
|
config.enableTemplates = true;
|
||||||
|
|
||||||
|
config.enableHistory = true;
|
||||||
|
|
||||||
return config;
|
return config;
|
||||||
});
|
});
|
||||||
|
|||||||
@ -12,21 +12,14 @@ define([
|
|||||||
var getStates = function (rt) {
|
var getStates = function (rt) {
|
||||||
var states = [];
|
var states = [];
|
||||||
var b = rt.getAuthBlock();
|
var b = rt.getAuthBlock();
|
||||||
if (b) { states.unshift(b.getContent().doc); }
|
if (b) { states.unshift(b); }
|
||||||
while (b.getParent()) {
|
while (b.getParent()) {
|
||||||
b = b.getParent();
|
b = b.getParent();
|
||||||
states.unshift(b.getContent().doc);
|
states.unshift(b);
|
||||||
}
|
}
|
||||||
return states;
|
return states;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* TODO
|
|
||||||
* Implement GET_FULL_HISTORY serverside
|
|
||||||
* All the history messages should be ['FULL_HISTORY', wc.id, msg]
|
|
||||||
* Send [FULL_HISTORY_END, wc.id]
|
|
||||||
*
|
|
||||||
* We also need a chainpad without pruning and with the ability to get old messages
|
|
||||||
*/
|
|
||||||
var loadHistory = function (common, cb) {
|
var loadHistory = function (common, cb) {
|
||||||
var network = common.getNetwork();
|
var network = common.getNetwork();
|
||||||
var hkn = network.historyKeeper;
|
var hkn = network.historyKeeper;
|
||||||
@ -38,7 +31,7 @@ define([
|
|||||||
userName: 'history',
|
userName: 'history',
|
||||||
initialState: '',
|
initialState: '',
|
||||||
transformFunction: JsonOT.validate,
|
transformFunction: JsonOT.validate,
|
||||||
logLevel: 1,
|
logLevel: 0,
|
||||||
noPrune: true
|
noPrune: true
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@ -95,12 +88,13 @@ define([
|
|||||||
|
|
||||||
var realtime;
|
var realtime;
|
||||||
|
|
||||||
var states = []; //getStates(rt); //['a', 'b', 'c'];
|
var states = [];
|
||||||
var c = states.length - 1;
|
var c = states.length - 1;
|
||||||
|
|
||||||
var $hist = $toolbar.find('.cryptpad-toolbar-history');
|
var $hist = $toolbar.find('.cryptpad-toolbar-history');
|
||||||
var $left = $toolbar.find('.cryptpad-toolbar-leftside');
|
var $left = $toolbar.find('.cryptpad-toolbar-leftside');
|
||||||
var $right = $toolbar.find('.cryptpad-toolbar-rightside');
|
var $right = $toolbar.find('.cryptpad-toolbar-rightside');
|
||||||
|
var $cke = $toolbar.find('.cke_toolbox_main');
|
||||||
|
|
||||||
var onUpdate;
|
var onUpdate;
|
||||||
|
|
||||||
@ -117,7 +111,7 @@ define([
|
|||||||
if (isNaN(i)) { return; }
|
if (isNaN(i)) { return; }
|
||||||
if (i < 0) { i = 0; }
|
if (i < 0) { i = 0; }
|
||||||
if (i > states.length - 1) { i = states.length - 1; }
|
if (i > states.length - 1) { i = states.length - 1; }
|
||||||
var val = states[i];
|
var val = states[i].getContent().doc;
|
||||||
c = i;
|
c = i;
|
||||||
if (typeof onUpdate === "function") { onUpdate(); }
|
if (typeof onUpdate === "function") { onUpdate(); }
|
||||||
$hist.find('.next, .previous').show();
|
$hist.find('.next, .previous').show();
|
||||||
@ -138,6 +132,7 @@ define([
|
|||||||
$hist.html('').show();
|
$hist.html('').show();
|
||||||
$left.hide();
|
$left.hide();
|
||||||
$right.hide();
|
$right.hide();
|
||||||
|
$cke.hide();
|
||||||
var $prev =$('<button>', {
|
var $prev =$('<button>', {
|
||||||
'class': 'previous fa fa-step-backward',
|
'class': 'previous fa fa-step-backward',
|
||||||
title: Messages.history_prev
|
title: Messages.history_prev
|
||||||
@ -179,6 +174,7 @@ define([
|
|||||||
$hist.hide();
|
$hist.hide();
|
||||||
$left.show();
|
$left.show();
|
||||||
$right.show();
|
$right.show();
|
||||||
|
$cke.show();
|
||||||
};
|
};
|
||||||
|
|
||||||
// Buttons actions
|
// Buttons actions
|
||||||
@ -211,7 +207,6 @@ define([
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
// Display the latest content
|
// Display the latest content
|
||||||
render(get(c));
|
render(get(c));
|
||||||
};
|
};
|
||||||
|
|||||||
@ -807,6 +807,10 @@ define([
|
|||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case 'history':
|
case 'history':
|
||||||
|
if (!AppConfig.enableHistory) {
|
||||||
|
button = $('<span>');
|
||||||
|
break;
|
||||||
|
}
|
||||||
button = $('<button>', {
|
button = $('<button>', {
|
||||||
title: Messages.historyButton,
|
title: Messages.historyButton,
|
||||||
'class': "fa fa-history",
|
'class': "fa fa-history",
|
||||||
@ -816,7 +820,7 @@ define([
|
|||||||
button.click(function () {
|
button.click(function () {
|
||||||
common.getHistory(data.histConfig);
|
common.getHistory(data.histConfig);
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
button = $('<button>', {
|
button = $('<button>', {
|
||||||
|
|||||||
@ -632,11 +632,7 @@ define([
|
|||||||
histConfig.onRender = function (val) {
|
histConfig.onRender = function (val) {
|
||||||
if (typeof val === "undefined") { return; }
|
if (typeof val === "undefined") { return; }
|
||||||
try {
|
try {
|
||||||
applyHjson(val || '');
|
applyHjson(val || '["BODY",{},[]]');
|
||||||
/*var hjson = JSON.parse(val || '{}'); // TODO
|
|
||||||
var remoteDoc = hjson.content;
|
|
||||||
editor.setValue(remoteDoc || ''); // TODO
|
|
||||||
editor.save(); // TODO*/
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// Probably a parse error
|
// Probably a parse error
|
||||||
console.error(e);
|
console.error(e);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user