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

pull/1/head
yflory 4 years ago
commit 351b4cddf9

@ -1033,6 +1033,7 @@
flex-flow: column; flex-flow: column;
z-index: 10000; //Z cp-toolbar-drawer-content z-index: 10000; //Z cp-toolbar-drawer-content
color: black; color: black;
.tools_unselectable();
.fa { .fa {
font-size: 17px; font-size: 17px;
} }

@ -2299,7 +2299,9 @@ define([
value = val; value = val;
var $val = $innerblock.find('[data-value="'+val+'"]'); var $val = $innerblock.find('[data-value="'+val+'"]');
var textValue = name || $val.html() || val; var textValue = name || $val.html() || val;
$button.find('.cp-dropdown-button-title').html(textValue); setTimeout(function () {
$button.find('.cp-dropdown-button-title').html(textValue);
});
}; };
$container.getValue = function () { $container.getValue = function () {
return value || ''; return value || '';

@ -1604,6 +1604,26 @@ define([
var allocated = Login.allocateBytes(bytes); var allocated = Login.allocateBytes(bytes);
blockKeys = allocated.blockKeys; blockKeys = allocated.blockKeys;
})); }));
}).nThen(function (waitFor) {
var blockUrl = Block.getBlockUrl(blockKeys);
// Check whether there is a block at that location
Util.fetch(blockUrl, waitFor(function (err, block) {
// If there is no block or the block is invalid, continue.
if (err) {
console.log("no block found");
return;
}
var decryptedBlock = Block.decrypt(block, blockKeys);
if (!decryptedBlock) {
console.error("Found a login block but failed to decrypt");
return;
}
// If there is already a valid block, abort! We risk overriding another user's data
waitFor.abort();
cb({ error: 'EEXISTS' });
}));
}).nThen(function (waitFor) { }).nThen(function (waitFor) {
// Write the new login block // Write the new login block
var temp = { var temp = {

@ -2779,30 +2779,34 @@ define([
$sortBlock.on('click', 'a', onSortByClick); $sortBlock.on('click', 'a', onSortByClick);
return $fhSort; return $fhSort;
}; };
var getFolderListHeader = function () { var getFolderListHeader = function (clickable, small) {
var $fohElement = $('<li>', { var $fohElement = $('<li>', {
'class': 'cp-app-drive-element-header cp-app-drive-element-list' 'class': 'cp-app-drive-element-header cp-app-drive-element-list'
}); });
var clickCls = clickable ? 'cp-app-drive-sort-clickable ' : '';
var onClick = clickable ? onSortByClick : function () {};
//var $fohElement = $('<span>', {'class': 'element'}).appendTo($folderHeader); //var $fohElement = $('<span>', {'class': 'element'}).appendTo($folderHeader);
var $fhIcon = $('<span>', {'class': 'cp-app-drive-content-icon'}); var $fhIcon = $('<span>', {'class': 'cp-app-drive-content-icon'});
var $name = $('<span>', { var $name = $('<span>', {
'class': 'cp-app-drive-element-name cp-app-drive-sort-foldername ' + 'class': 'cp-app-drive-element-name cp-app-drive-sort-foldername ' + clickCls
'cp-app-drive-sort-clickable' }).text(Messages.fm_folderName).click(onClick);
}).text(Messages.fm_folderName).click(onSortByClick);
var $state = $('<span>', {'class': 'cp-app-drive-element-state'}); var $state = $('<span>', {'class': 'cp-app-drive-element-state'});
var $subfolders = $('<span>', { var $subfolders, $files;
'class': 'cp-app-drive-element-folders cp-app-drive-element-list' if (!small) {
}).text(Messages.fm_numberOfFolders); $subfolders = $('<span>', {
var $files = $('<span>', { 'class': 'cp-app-drive-element-folders cp-app-drive-element-list'
'class': 'cp-app-drive-element-files cp-app-drive-element-list' }).text(Messages.fm_numberOfFolders);
}).text(Messages.fm_numberOfFiles); $files = $('<span>', {
'class': 'cp-app-drive-element-files cp-app-drive-element-list'
}).text(Messages.fm_numberOfFiles);
}
var $filler = $('<span>', { var $filler = $('<span>', {
'class': 'cp-app-drive-element-filler cp-app-drive-element-list' 'class': 'cp-app-drive-element-filler cp-app-drive-element-list'
}); });
$fohElement.append($fhIcon).append($name).append($state) $fohElement.append($fhIcon).append($name).append($state)
.append($subfolders).append($files).append($filler); .append($subfolders).append($files).append($filler);
addFolderSortIcon($fohElement); if (clickable) { addFolderSortIcon($fohElement); }
return $fohElement; return $fohElement;
}; };
var addFileSortIcon = function ($list) { var addFileSortIcon = function ($list) {
@ -2859,15 +2863,16 @@ define([
}); });
if (keys.length < 2) { return keys; } if (keys.length < 2) { return keys; }
var mult = asc ? 1 : -1; var mult = asc ? 1 : -1;
var getProp = function (el) { var getProp = function (_el) {
if (folder && root[el] && manager.isSharedFolder(root[el])) { var el = useId ? _el : root[_el];
var title = manager.getSharedFolderData(root[el]).title || el; var sfId = (el && el.root && el.key) ? el.root[el.key] : el;
if (folder && el && manager.isSharedFolder(sfId)) {
var title = manager.getSharedFolderData(sfId).title || el;
return String(title).toLowerCase(); return String(title).toLowerCase();
} else if (folder) { } else if (folder) {
return el.toLowerCase(); return String((el && el.key) || el).toLowerCase();
} }
var id = useId ? el : root[el]; var data = manager.getFileData(el);
var data = manager.getFileData(id);
if (!data) { return ''; } if (!data) { return ''; }
if (prop === 'type') { if (prop === 'type') {
var hrefData = Hash.parsePadUrl(data.href || data.roHref); var hrefData = Hash.parsePadUrl(data.href || data.roHref);
@ -2876,15 +2881,19 @@ define([
if (prop === 'atime' || prop === 'ctime') { if (prop === 'atime' || prop === 'ctime') {
return typeof(data[prop]) === "number" ? data[prop] : new Date(data[prop]); return typeof(data[prop]) === "number" ? data[prop] : new Date(data[prop]);
} }
return (manager.getTitle(id) || "").toLowerCase(); return (manager.getTitle(el) || "").toLowerCase();
}; };
var props = {}; var props = {};
keys.forEach(function (k) { keys.forEach(function (k) {
props[k] = getProp(k); var uid = k;
if (typeof(k) === "object") {
uid = k.uid = Util.uid();
}
props[uid] = getProp(k);
}); });
keys.sort(function(a, b) { keys.sort(function(a, b) {
var _a = props[a]; var _a = props[(a && a.uid) || a];
var _b = props[b]; var _b = props[(b && b.uid) || b];
if (_a < _b) { return mult * -1; } if (_a < _b) { return mult * -1; }
if (_b < _a) { return mult; } if (_b < _a) { return mult; }
return 0; return 0;
@ -3233,9 +3242,10 @@ define([
$input.focus(); $input.focus();
}); });
getFileListHeader(false).appendTo($list);
$list.closest('#cp-app-drive-content-folder').addClass('cp-app-drive-content-list'); $list.closest('#cp-app-drive-content-folder').addClass('cp-app-drive-content-list');
var filesList = manager.search(value); var filesList = manager.search(value);
var sortable = {};
var sortableFolders = [];
filesList.forEach(function (r) { filesList.forEach(function (r) {
// if r.id === null, then it's a folder, not a file // if r.id === null, then it's a folder, not a file
r.paths.forEach(function (path) { r.paths.forEach(function (path) {
@ -3244,33 +3254,56 @@ define([
var _path = path.slice(); var _path = path.slice();
var key = path.pop(); var key = path.pop();
var root = manager.find(path); var root = manager.find(path);
var isFolder = manager.isFolder(root[key]); var obj = {
var $element = createElement(path, key, root, isFolder); path: path,
$element.addClass('cp-app-drive-element-notrash cp-app-drive-search-result'); _path: _path,
$element.off('contextmenu'); key: key,
$element.contextmenu(openContextMenu('default')); root: root,
$element.data('context', 'default'); data: r.data
if (isFolder) { };
$element.find('.cp-app-drive-element-list').css({ if (manager.isFolder(root[key])) {
visibility: 'hidden' sortableFolders.push(obj);
}).text(''); return;
$element.find('.cp-app-drive-element-folders').css({
visibility: ''
}).text(Messages.fm_folder);
}
if (manager.isPathIn(_path, ['hrefArray'])) {
_path.pop();
_path.push(r.data.title);
} }
var $path = $('<span>', { sortable[root[key]] = obj;
'class': 'cp-app-drive-search-path'
}).appendTo($element.find('.cp-app-drive-element-name'));
createTitle($path, _path);
$list.append($element);
}); });
}); });
var _folders = sortElements(true, [ROOT], sortableFolders, null, !getSortFolderDesc(), true);
var sortableKeys = Object.keys(sortable).map(Number);
var _files = sortElements(false, [ROOT], sortableKeys, APP.store[SORT_FILE_BY], !getSortFileDesc(), true);
var addEl = function (obj, folder) {
var $element = createElement(obj.path, obj.key, obj.root, folder);
$element.addClass('cp-app-drive-element-notrash cp-app-drive-search-result');
$element.off('contextmenu');
$element.contextmenu(openContextMenu('default'));
$element.data('context', 'default');
if (folder) {
$element.find('.cp-app-drive-element-list').css({
visibility: 'hidden'
}).text('');
}
if (manager.isPathIn(obj._path, ['hrefArray'])) {
obj._path.pop();
obj._path.push(obj.data.title);
}
var $path = $('<span>', {
'class': 'cp-app-drive-search-path'
}).appendTo($element.find('.cp-app-drive-element-name'));
createTitle($path, obj._path);
$list.append($element);
};
if (_folders.length) { getFolderListHeader(true, true).appendTo($list); }
_folders.forEach(function (el) {
var obj = el;
addEl(obj, true);
});
if (_files.length) { getFileListHeader(true).appendTo($list); }
_files.forEach(function (el) {
var obj = sortable[el];
addEl(obj, false);
});
setTimeout(collapseDrivePath); setTimeout(collapseDrivePath);
}; };
@ -3415,7 +3448,7 @@ define([
} }
var fId = APP.newSharedFolder; var fId = APP.newSharedFolder;
var data = folders[fId]; var data = folders[fId];
var $folderHeader = getFolderListHeader(); var $folderHeader = getFolderListHeader(true);
var $fileHeader = getFileListHeader(true); var $fileHeader = getFileListHeader(true);
var path = currentPath.slice(1); var path = currentPath.slice(1);
var root = Util.find(data, path); var root = Util.find(data, path);
@ -3593,7 +3626,7 @@ define([
} }
updateContextButton(); updateContextButton();
var $folderHeader = getFolderListHeader(); var $folderHeader = getFolderListHeader(true);
var $fileHeader = getFileListHeader(true); var $fileHeader = getFileListHeader(true);
if (isTemplate) { if (isTemplate) {

@ -478,6 +478,7 @@ define([
store: store, store: store,
}; };
var myData = Messaging.createData(userObject); var myData = Messaging.createData(userObject);
if (!myData.curvePublic) { return void done(); }
Mailbox.sendTo(ctx, 'SAFE_LINKS_DEFAULT', { Mailbox.sendTo(ctx, 'SAFE_LINKS_DEFAULT', {
user: myData, user: myData,

@ -1394,5 +1394,6 @@
"support_cat_bug": "Fehlerbericht", "support_cat_bug": "Fehlerbericht",
"oo_refresh": "Neu laden", "oo_refresh": "Neu laden",
"support_category": "Wähle eine Kategorie", "support_category": "Wähle eine Kategorie",
"oo_refreshText": "Dieses Dokument wurde aktualisiert" "oo_refreshText": "Dieses Dokument wurde aktualisiert",
"support_formCategoryError": "Fehler: Kategorie ist leer"
} }

@ -1394,5 +1394,6 @@
"notification_folderSharedTeam": "{0} has shared a folder with the team {2}: <b>{1}</b>", "notification_folderSharedTeam": "{0} has shared a folder with the team {2}: <b>{1}</b>",
"oo_refresh": "Refresh", "oo_refresh": "Refresh",
"oo_refreshText": "This document has been updated", "oo_refreshText": "This document has been updated",
"support_category": "Choose a category" "support_category": "Choose a category",
"support_formCategoryError": "Error: category is empty"
} }

@ -640,6 +640,7 @@ define([
var res = []; var res = [];
// Search title // Search title
var allFilesList = files[FILES_DATA]; var allFilesList = files[FILES_DATA];
var allSFList = files[SHARED_FOLDERS];
var lValue = value.toLowerCase(); var lValue = value.toLowerCase();
// parse the search string into tags // parse the search string into tags
@ -661,13 +662,14 @@ define([
}); });
}; };
getFiles([FILES_DATA]).forEach(function (id) { getFiles([FILES_DATA, SHARED_FOLDERS]).forEach(function (id) {
var data = allFilesList[id]; var data = allFilesList[id] || allSFList[id];
if (!data) { return; } if (!data) { return; }
if (Array.isArray(data.tags) && containsSearchedTag(data.tags)) { if (Array.isArray(data.tags) && containsSearchedTag(data.tags)) {
res.push(id); return void res.push(id);
} else }
if ((data.title && data.title.toLowerCase().indexOf(lValue) !== -1) || var title = data.title || data.lastTitle;
if ((title && title.toLowerCase().indexOf(lValue) !== -1) ||
(data.filename && data.filename.toLowerCase().indexOf(lValue) !== -1)) { (data.filename && data.filename.toLowerCase().indexOf(lValue) !== -1)) {
res.push(id); res.push(id);
} }

@ -25,10 +25,12 @@
typeof document[hidden] === "undefined"); typeof document[hidden] === "undefined");
}; };
Visible.onChange = function (f) { Visible.onChange = function (f, once) {
document.addEventListener(visibilityChange, function (ev) { document.addEventListener(visibilityChange, function (ev) {
f(!document[hidden], ev); f(!document[hidden], ev);
}, false); }, {
once: once
});
}; };
Visible.currently = function () { Visible.currently = function () {

@ -1,8 +1,9 @@
define([ define([
'jquery', 'jquery',
'/customize/messages.js', '/customize/messages.js',
'/common/visible.js',
'/bower_components/dragula.js/dist/dragula.min.js', '/bower_components/dragula.js/dist/dragula.min.js',
], function ($, Messages, Dragula) { ], function ($, Messages, Visible, Dragula) {
/** /**
* jKanban * jKanban
* Vanilla Javascript plugin for manage kanban boards * Vanilla Javascript plugin for manage kanban boards
@ -739,6 +740,8 @@ define([
return self; return self;
}; };
var todoOnVisible = function () {};
var onVisibleHandler = false;
this.setBoards = function (boards) { this.setBoards = function (boards) {
var scroll = {}; var scroll = {};
// Fix the tags // Fix the tags
@ -754,15 +757,30 @@ define([
this.removeBoard(boardkey); this.removeBoard(boardkey);
} }
this.options.boards = boards; this.options.boards = boards;
// Add all new boards
this.addBoards(); todoOnVisible = function () {
self.options.refresh(); // Add all new boards
// Preserve scroll self.addBoards();
this.options.boards.list.forEach(function (id) { self.options.refresh();
if (!scroll[id]) { return; } // Preserve scroll
$('.kanban-board[data-id="'+id+'"] .kanban-drag').scrollTop(scroll[id]); self.options.boards.list.forEach(function (id) {
}); if (!scroll[id]) { return; }
$el.scrollLeft(scrollLeft); $('.kanban-board[data-id="'+id+'"] .kanban-drag').scrollTop(scroll[id]);
});
$el.scrollLeft(scrollLeft);
};
// If the tab is not focused, redraw on focus
if (!Visible.currently()) {
if (onVisibleHandler) { return; }
onVisibleHandler = true;
return void Visible.onChange(function (visible) {
if (!visible) { return; }
todoOnVisible();
onVisibleHandler = false;
}, true);
}
todoOnVisible();
}; };
this.findBoard = function (id) { this.findBoard = function (id) {

@ -36,6 +36,9 @@ body.cp-app-pad {
align-items: center; align-items: center;
padding: 4px; padding: 4px;
} }
.cke_button__print {
display: none !important;
}
} }
.cke_wysiwyg_frame { .cke_wysiwyg_frame {
width: 100%; width: 100%;

@ -456,6 +456,15 @@ define([
}); });
}; };
var mkPrintButton = function (framework, editor) {
var $printButton = framework._.sfCommon.createButton('print', true);
$printButton.click(function () {
editor.execCommand('print');
framework.feedback('PRINT_PAD');
});
framework._.toolbar.$drawer.append($printButton);
};
var andThen2 = function(editor, Ckeditor, framework) { var andThen2 = function(editor, Ckeditor, framework) {
var mediaTagMap = {}; var mediaTagMap = {};
var $contentContainer = $('#cke_1_contents'); var $contentContainer = $('#cke_1_contents');
@ -480,6 +489,8 @@ define([
framework._.sfCommon.addShortcuts(ifrWindow); framework._.sfCommon.addShortcuts(ifrWindow);
mkPrintButton(framework, editor, Ckeditor);
var documentBody = ifrWindow.document.body; var documentBody = ifrWindow.document.body;
var inner = window.inner = documentBody; var inner = window.inner = documentBody;
var $inner = $(inner); var $inner = $(inner);

@ -488,6 +488,7 @@ define([
UI.removeLoadingScreen(); UI.removeLoadingScreen();
if (obj && obj.error) { if (obj && obj.error) {
// TODO // TODO
// XXX EEXISTS error message?
UI.alert(Messages.settings_changePasswordError); UI.alert(Messages.settings_changePasswordError);
} }
}); });

Loading…
Cancel
Save