Merge branch 'staging' of github.com:xwiki-labs/cryptpad into staging

This commit is contained in:
yflory
2018-02-07 13:08:12 +01:00
8 changed files with 206 additions and 9 deletions

View File

@@ -7,6 +7,7 @@ define([
'/common/sframe-common.js',
'/customize/messages.js',
'/common/common-util.js',
'/common/common-hash.js',
'/common/common-interface.js',
'/common/common-thumbnail.js',
'/common/common-feedback.js',
@@ -27,6 +28,7 @@ define([
SFCommon,
Messages,
Util,
Hash,
UI,
Thumb,
Feedback,
@@ -84,6 +86,7 @@ define([
});
});
var textContentGetter;
var titleRecommender = function () { return false; };
var contentGetter = function () { return UNINITIALIZED; };
var normalize0 = function (x) { return x; };
@@ -287,11 +290,17 @@ define([
UI.removeLoadingScreen(emitResize);
var privateDat = cpNfInner.metadataMgr.getPrivateData();
var hash = privateDat.availableHashes.editHash ||
privateDat.availableHashes.viewHash;
var href = privateDat.pathname + '#' + hash;
if (AppConfig.textAnalyzer && textContentGetter) {
var channelId = Hash.hrefToHexChannelId(href);
AppConfig.textAnalyzer(textContentGetter, channelId);
}
if (options.thumbnail && privateDat.thumbnails) {
var hash = privateDat.availableHashes.editHash ||
privateDat.availableHashes.viewHash;
if (hash) {
options.thumbnail.href = privateDat.pathname + '#' + hash;
options.thumbnail.href = href;
options.thumbnail.getContent = function () {
if (!cpNfInner.chainpad) { return; }
return cpNfInner.chainpad.getUserDoc();
@@ -567,6 +576,10 @@ define([
// in the pad when requested by the framework.
setContentGetter: function (cg) { contentGetter = cg; },
// Set a text content supplier, this is a function which will give a text
// representation of the pad content if a text analyzer is configured
setTextContentGetter: function (tcg) { textContentGetter = tcg; },
// Inform the framework that the content of the pad has been changed locally.
localChange: onLocal,

View File

@@ -402,6 +402,17 @@ define([
}
});
framework.setTextContentGetter(function () {
var innerCopy = inner.cloneNode(true);
displayMediaTags(framework, innerCopy, mediaTagMap);
innerCopy.normalize();
$(innerCopy).find('*').each(function (i, el) {
$(el).append(' ');
});
var str = $(innerCopy).text();
str = str.replace(/\s\s+/g, ' ');
return str;
});
framework.setContentGetter(function () {
displayMediaTags(framework, inner, mediaTagMap);
inner.normalize();

View File

@@ -96,6 +96,7 @@ define([
};
var addTaskUI = function (el, animate) {
if (!el) { return; }
var $taskDiv = $('<div>', {
'class': 'cp-app-todo-task'
});

View File

@@ -39,6 +39,24 @@ define([
if (typeof(proxy.data) !== 'object') { proxy.data = {}; }
if (!Array.isArray(proxy.order)) { proxy.order = []; }
if (typeof(proxy.type) !== 'string') { proxy.type = 'todo'; }
// if a key exists in order, but there is no data for it...
// remove that key
var i = proxy.order.length - 1;
for (;i >= 0; i--) {
if (typeof(proxy.data[proxy.order[i]]) === 'undefined') {
console.log('removing todo entry with no data at [%s]', i);
proxy.order.splice(i, 1);
}
}
// if you have data, but it's not in the order array...
// add it to the order array...
Object.keys(proxy.data).forEach(function (key) {
if (proxy.order.indexOf(key) > -1) { return; }
console.log("restoring entry with missing key");
proxy.order.unshift(key);
});
};
/* add (id, obj) push id to order, add object to data */