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

pull/1/head
yflory 4 years ago
commit e34c78580f

@ -10,7 +10,7 @@ nThen(function (w) {
config.log = _log;
}));
}).nThen(function (w) {
FileStorage.create(config, w(function (_store) {
FileStorage.create(config, w(function (err, _store) {
config.store = _store;
// config.taskPath

@ -13,6 +13,18 @@
return b;
}
// COPYPASTED from mediatag-plugin-dialog.js
var isReadOnly = function (el) {
if (!el) { return; }
var parent = el;
while (parent) {
if (parent.nodeName.toUpperCase() === 'BODY') {
return parent.getAttribute("contenteditable") === 'false';
}
parent = parent.parentElement;
}
};
var color1 = 'rgba(249, 230, 65, 1.0)';
var color2 = 'rgba(252, 181, 0, 1.0)';
@ -44,7 +56,10 @@
path = path || editor.elementPath();
sel = sel || editor.getSelection();
var applicable = removeStyle.checkApplicable(path, editor);
var hasComments = editor.getSelectedHtml().$.querySelectorAll('comment').length;
var selectedHtml = editor.getSelectedHtml();
if (selectedHtml === null) { return; }
var comments = selectedHtml.$.querySelectorAll('comment');
var hasComments = comments && comments.length;
var isComment = removeStyle.checkActive(path, editor);
var empty = !sel.getSelectedText();
return applicable && !empty && !hasComments && !isComment;
@ -164,7 +179,8 @@
*/
editor.contextMenu.addListener(function(element, sel, path) {
var applicable = isApplicable(path, sel);
if (!applicable) { return; }
if (!applicable || isReadOnly(element.$)) { return; }
return {
comment: CKEDITOR.TRISTATE_OFF,
};

@ -747,6 +747,14 @@ define([
Env.$contentContainer.append(h('div.cp-comment-bubble', button));
};
var isEditable = function (document) {
try {
return document.body.getAttribute('contenteditable') === 'true';
} catch (err) {
return false;
}
};
var addAddCommentHandler = function(Env) {
Env.editor.plugins.comments.addComment = function(uid, addMark) {
if (!Env.ready) { return; }
@ -809,7 +817,7 @@ define([
$(Env.ifrWindow.document).on('selectionchange', function() {
removeCommentBubble(Env);
var applicable = Env.editor.plugins.comments.isApplicable();
if (!applicable) { return; }
if (!applicable || !isEditable(Env.ifrWindow.document)) { return; }
addCommentBubble(Env);
});
};

Loading…
Cancel
Save