Kanban improvements (images, autobrackets)

pull/1/head
yflory 5 years ago
parent 2ff5acdbd1
commit faa150be90

@ -200,7 +200,6 @@ define([
// The blob is already in memory, it should be super-fast to make a thumbnail // The blob is already in memory, it should be super-fast to make a thumbnail
// ==> 1s timeout // ==> 1s timeout
setTimeout(function () { setTimeout(function () {
console.error("Thumbnail timeout");
cb('TIMEOUT'); cb('TIMEOUT');
}, 1000); }, 1000);
try { try {

@ -176,14 +176,14 @@ define([
updateIndentSettings(); updateIndentSettings();
}; };
module.create = function (defaultMode, CMeditor) { module.create = function (defaultMode, CMeditor, textarea) {
var exp = {}; var exp = {};
var CodeMirror = exp.CodeMirror = CMeditor; var CodeMirror = exp.CodeMirror = CMeditor;
CodeMirror.modeURL = "cm/mode/%N/%N"; CodeMirror.modeURL = "cm/mode/%N/%N";
var $pad = $('#pad-iframe'); var $pad = $('#pad-iframe');
var $textarea = exp.$textarea = $('#editor1'); var $textarea = exp.$textarea = textarea ? $(textarea) : $('#editor1');
if (!$textarea.length) { $textarea = exp.$textarea = $pad.contents().find('#editor1'); } if (!$textarea.length) { $textarea = exp.$textarea = $pad.contents().find('#editor1'); }
var Title; var Title;

@ -21,6 +21,12 @@ define([
'/kanban/jkanban_cp.js', '/kanban/jkanban_cp.js',
'cm/mode/gfm/gfm', 'cm/mode/gfm/gfm',
'cm/addon/edit/closebrackets',
'cm/addon/edit/matchbrackets',
'cm/addon/edit/trailingspace',
'cm/addon/selection/active-line',
'cm/addon/search/search',
'cm/addon/search/match-highlighter',
'css!/bower_components/codemirror/lib/codemirror.css', 'css!/bower_components/codemirror/lib/codemirror.css',
'css!/bower_components/codemirror/addon/dialog/dialog.css', 'css!/bower_components/codemirror/addon/dialog/dialog.css',
@ -211,15 +217,11 @@ define([
}; };
// Body // Body
var editor = CodeMirror.fromTextArea(text, { var cm = SFCodeMirror.create("gfm", CodeMirror, text);
allowDropFileTypes: [], var editor = cm.editor;
lineWrapping: true, editor.setOption('gutters', []);
styleActiveLine: true, editor.setOption('lineNumbers', false);
autoCloseBrackets: true, editor.setOption('readOnly', false);
inputStyle: 'contenteditable',
extraKeys: {"Shift-Ctrl-R": undefined},
mode: "gfm"
});
editor.on('keydown', function (editor, e) { editor.on('keydown', function (editor, e) {
if (e.which === 27) { if (e.which === 27) {
// Focus the next form element but don't close the modal (stopPropagation) // Focus the next form element but don't close the modal (stopPropagation)
@ -257,6 +259,25 @@ define([
commit(); commit();
}); });
setTimeout(function () {
var privateData = framework._.cpNfInner.metadataMgr.getPrivateData();
var fmConfig = {
dropArea: $('.CodeMirror'),
body: $('body'),
onUploaded: function (ev, data) {
var parsed = Hash.parsePadUrl(data.url);
var secret = Hash.getSecrets('file', parsed.hash, data.password);
var fileHost = privateData.fileHost || privateData.origin;
var src = fileHost + Hash.getBlobPathFromHex(secret.channel);
var key = Hash.encodeBase64(secret.keys.cryptKey);
var mt = '<media-tag src="' + src + '" data-crypto-key="cryptpad:' + key + '"></media-tag>';
editor.replaceSelection(mt);
}
};
common.createFileManager(fmConfig);
});
// Tags // Tags
var _field, initialTags; var _field, initialTags;
var tags = { var tags = {
@ -775,8 +796,11 @@ define([
} }
}); });
}, },
applyHtml: function (html, node) {
DiffMd.apply(html, $(node),framework._.sfCommon);
},
renderMd: function (md) { renderMd: function (md) {
return DiffMd.render(md, true, false); return DiffMd.render(md);
}, },
addItemButton: true, addItemButton: true,
getTextColor: getTextColor, getTextColor: getTextColor,

@ -50,6 +50,7 @@ define([
boardTitleclick: function (/*el, boardId*/) {}, boardTitleclick: function (/*el, boardId*/) {},
addItemClick: function (/*el, boardId*/) {}, addItemClick: function (/*el, boardId*/) {},
renderMd: function (/*md*/) {}, renderMd: function (/*md*/) {},
applyHtml: function (/*html, node*/) {},
refresh: function () {}, refresh: function () {},
onChange: function () {} onChange: function () {}
}; };
@ -522,7 +523,7 @@ define([
}; };
} }
var nodeBody = document.createElement('div'); var nodeBody = document.createElement('div');
nodeBody.classList.add('kanban-item-body'); nodeBody.setAttribute('id', 'kanban-body-' + element.id);
$(nodeBody).on('click', 'a', function (e) { $(nodeBody).on('click', 'a', function (e) {
e.preventDefault(); e.preventDefault();
var a = e.target; var a = e.target;
@ -533,7 +534,9 @@ define([
nodeBody.onclick = function (e) { nodeBody.onclick = function (e) {
e.preventDefault(); e.preventDefault();
}; };
nodeBody.innerHTML = html; //nodeBody.innerHTML = html;
self.applyHtml(html, nodeBody);
nodeBody.classList.add('kanban-item-body');
nodeItem.appendChild(nodeBody); nodeItem.appendChild(nodeBody);
} }
if (Array.isArray(element.tags)) { if (Array.isArray(element.tags)) {
@ -796,6 +799,9 @@ define([
return self; return self;
}; };
this.applyHtml = function (html, node) {
return self.options.applyHtml(html, node);
};
this.renderMd = function (md) { this.renderMd = function (md) {
return self.options.renderMd(md); return self.options.renderMd(md);
}; };

Loading…
Cancel
Save