summaryrefslogtreecommitdiffstats
path: root/client/components
diff options
context:
space:
mode:
authorLauri Ojansivu <x@xet7.org>2020-03-24 20:39:49 +0200
committerLauri Ojansivu <x@xet7.org>2020-03-24 20:39:49 +0200
commitb9099a8b7ea6f63c79bdcbb871cb993b2cb7e325 (patch)
treefe1c68e82f3c773927e471aca748390b98e1ca11 /client/components
parent87a81789d109adcefc754c7cb33bcee395412a84 (diff)
downloadwekan-b9099a8b7ea6f63c79bdcbb871cb993b2cb7e325.tar.gz
wekan-b9099a8b7ea6f63c79bdcbb871cb993b2cb7e325.tar.bz2
wekan-b9099a8b7ea6f63c79bdcbb871cb993b2cb7e325.zip
1) Fix Pasting text into a card is adding a line before and after
(and multiplies by pasting more) by changing paste "p" to "br". 2) Fixes to summernote and markdown comment editors, related to keeping them open when adding comments, having @member mention not close card, and disabling clicking of @member mention. Thanks to xet7 ! Closes #2890
Diffstat (limited to 'client/components')
-rw-r--r--client/components/activities/comments.js7
-rw-r--r--client/components/main/editor.jade7
-rwxr-xr-xclient/components/main/editor.js51
3 files changed, 59 insertions, 6 deletions
diff --git a/client/components/activities/comments.js b/client/components/activities/comments.js
index 50ca019b..e885459e 100644
--- a/client/components/activities/comments.js
+++ b/client/components/activities/comments.js
@@ -33,6 +33,13 @@ BlazeComponent.extendComponent({
cardId,
});
resetCommentInput(input);
+ // With Richer editor is in use, and comment is submitted,
+ // clear comment form with JQuery. Id #summernote is defined
+ // at client/components/main/editor.jade where it previously was
+ // id=id, now it is id="summernote".
+ if (Meteor.settings.public.RICHER_CARD_COMMENT_EDITOR === 'true') {
+ $('#summernote').summernote('code', '');
+ }
Tracker.flush();
autosize.update(input);
input.trigger('submitted');
diff --git a/client/components/main/editor.jade b/client/components/main/editor.jade
index dbd61715..5c5454ee 100644
--- a/client/components/main/editor.jade
+++ b/client/components/main/editor.jade
@@ -1,8 +1,13 @@
template(name="editor")
+ // With Richer editor is in use, and comment is submitted,
+ // clear comment form with JQuery Comment at
+ // client/components/activities/comments.js . Id #summernote is defined
+ // here at client/components/main/editor.jade where it previously was
+ // id=id, now it is id="summernote".
textarea.editor(
dir="auto"
class="{{class}}"
- id=id
+ id="summernote"
autofocus=autofocus
placeholder="{{_ 'comment-placeholder'}}")
+Template.contentBlock
diff --git a/client/components/main/editor.js b/client/components/main/editor.js
index 18b823a2..3f09d284 100755
--- a/client/components/main/editor.js
+++ b/client/components/main/editor.js
@@ -30,7 +30,7 @@ Template.editor.onRendered(() => {
autosize($textarea);
$textarea.escapeableTextComplete(mentions);
};
- if (Meteor.settings.public.RICHER_CARD_COMMENT_EDITOR !== false) {
+ if (Meteor.settings.public.RICHER_CARD_COMMENT_EDITOR === 'true') {
const isSmall = Utils.isMiniScreen();
const toolbar = isSmall
? [
@@ -108,10 +108,37 @@ Template.editor.onRendered(() => {
}
return undefined;
};
+ // Prevent @member mentions on Add Comment input field
+ // from closing card, part 1.
+ let popupShown = false;
inputs.each(function(idx, input) {
mSummernotes[idx] = $(input).summernote({
placeholder,
+ // Prevent @member mentions on Add Comment input field
+ // from closing card, part 2.
+ onKeydown(e) {
+ if (popupShown) {
+ e.preventDefault();
+ }
+ },
+ onKeyup(e) {
+ if (popupShown) {
+ e.preventDefault();
+ }
+ },
callbacks: {
+ // Prevent @member mentions on Add Comment input field
+ // from closing card, part 3.
+ onKeydown(e) {
+ if (popupShown) {
+ e.preventDefault();
+ }
+ },
+ onKeyup(e) {
+ if (popupShown) {
+ e.preventDefault();
+ }
+ },
onInit(object) {
const originalInput = this;
$(originalInput).on('input', function() {
@@ -136,7 +163,6 @@ Template.editor.onRendered(() => {
});
}
},
-
onImageUpload(files) {
const $summernote = getSummernote(this);
if (files && files.length > 0) {
@@ -215,6 +241,12 @@ Template.editor.onRendered(() => {
const thisNote = this;
const updatePastedText = function(object) {
const someNote = getSummernote(object);
+ // Fix Pasting text into a card is adding a line before and after
+ // (and multiplies by pasting more) by changing paste "p" to "br".
+ // Fixes https://github.com/wekan/wekan/2890 .
+ // == Fix Start ==
+ someNote.execCommand('defaultParagraphSeparator', false, 'br');
+ // == Fix End ==
const original = someNote.summernote('code');
const cleaned = cleanPastedHTML(original); //this is where to call whatever clean function you want. I have mine in a different file, called CleanPastedHTML.
someNote.summernote('reset'); //clear original
@@ -291,11 +323,17 @@ Blaze.Template.registerHelper(
}
const linkValue = [' ', at, knowedUser.username];
- let linkClass = 'atMention js-open-member';
+ //let linkClass = 'atMention js-open-member';
+ let linkClass = 'atMention';
if (knowedUser.userId === Meteor.userId()) {
linkClass += ' me';
}
- const link = HTML.A(
+ // This @user mention link generation did open same Wekan
+ // window in new tab, so now A is changed to U so it's
+ // underlined and there is no link popup. This way also
+ // text can be selected more easily.
+ //const link = HTML.A(
+ const link = HTML.U(
{
class: linkClass,
// XXX Hack. Since we stringify this render function result below with
@@ -329,7 +367,10 @@ Template.viewer.events({
const userId = event.currentTarget.dataset.userid;
if (userId) {
- Popup.open('member').call({ userId }, event, templateInstance);
+ // Prevent @member mentions on Add Comment input field
+ // from closing card, part 4.
+ PopupNoClose.open('member').call({ userId }, event, templateInstance);
+ event.preventDefault();
} else {
const href = event.currentTarget.href;
if (href) {