mirror of
https://github.com/wekan/wekan.git
synced 2025-12-18 00:10:13 +01:00
Feature: Copy Card Details code block to clipboard.
Thanks to C0rn3j and xet7 ! Fixes #5149
This commit is contained in:
parent
7724b0d5bb
commit
0cc63b810c
4 changed files with 48 additions and 6 deletions
|
|
@ -196,6 +196,9 @@
|
||||||
margin-right: 10px;
|
margin-right: 10px;
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
}
|
}
|
||||||
|
.card-details .card-description i.fa.fa-pencil-square-o {
|
||||||
|
float: right;
|
||||||
|
}
|
||||||
.card-details .card-description textarea {
|
.card-details .card-description textarea {
|
||||||
min-height: 100px;
|
min-height: 100px;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -524,12 +524,13 @@ template(name="cardDetails")
|
||||||
a.fa.fa-times-thin.js-close-inlined-form
|
a.fa.fa-times-thin.js-close-inlined-form
|
||||||
else
|
else
|
||||||
if currentBoard.allowsDescriptionText
|
if currentBoard.allowsDescriptionText
|
||||||
a.js-open-inlined-form
|
a.js-open-inlined-form.right(title="{{_ 'edit'}}" value=title)
|
||||||
if getDescription
|
i.fa.fa-pencil-square-o
|
||||||
+viewer
|
if getDescription
|
||||||
= getDescription
|
+viewer
|
||||||
else
|
= getDescription
|
||||||
| {{_ 'edit'}}
|
else
|
||||||
|
| {{_ 'edit'}}
|
||||||
if (hasUnsavedValue 'cardDescription' _id)
|
if (hasUnsavedValue 'cardDescription' _id)
|
||||||
p.quiet
|
p.quiet
|
||||||
| {{_ 'unsaved-description'}}
|
| {{_ 'unsaved-description'}}
|
||||||
|
|
|
||||||
|
|
@ -12,3 +12,8 @@
|
||||||
top: 20px;
|
top: 20px;
|
||||||
right: 6px;
|
right: 6px;
|
||||||
}
|
}
|
||||||
|
.js-inlined-form.viewer.btn-sm {
|
||||||
|
position: absolute;
|
||||||
|
top: 20px;
|
||||||
|
right: 6px;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import { ReactiveCache } from '/imports/reactiveCache';
|
import { ReactiveCache } from '/imports/reactiveCache';
|
||||||
|
import { TAPi18n } from '/imports/i18n';
|
||||||
var converter = require('@wekanteam/html-to-markdown');
|
var converter = require('@wekanteam/html-to-markdown');
|
||||||
|
|
||||||
const specialHandles = [
|
const specialHandles = [
|
||||||
|
|
@ -10,6 +11,33 @@ const specialHandleNames = specialHandles.map(m => m.username);
|
||||||
|
|
||||||
BlazeComponent.extendComponent({
|
BlazeComponent.extendComponent({
|
||||||
onRendered() {
|
onRendered() {
|
||||||
|
// Start: Copy <pre> code https://github.com/wekan/wekan/issues/5149
|
||||||
|
// TODO: Try to make copyPre visible at Card Details after editing or closing editor or Card Details.
|
||||||
|
// - Also this same TODO below at event, if someone gets it working.
|
||||||
|
var copy = function(target) {
|
||||||
|
var textArea = document.createElement('textarea');
|
||||||
|
textArea.setAttribute('style','width:1px;border:0;opacity:0;');
|
||||||
|
document.body.appendChild(textArea);
|
||||||
|
textArea.value = target.innerHTML;
|
||||||
|
textArea.select();
|
||||||
|
document.execCommand('copy');
|
||||||
|
document.body.removeChild(textArea);
|
||||||
|
}
|
||||||
|
var pres = document.querySelectorAll(".viewer > pre");
|
||||||
|
pres.forEach(function(pre){
|
||||||
|
var button = document.createElement("a");
|
||||||
|
button.className = "fa fa-copy btn btn-sm right";
|
||||||
|
// TODO: Translate text 'Copy text to clipboard'
|
||||||
|
button.setAttribute('title','Copy text to clipboard');
|
||||||
|
button.innerHTML = '';
|
||||||
|
pre.parentNode.insertBefore(button, pre);
|
||||||
|
button.addEventListener('click', function(e){
|
||||||
|
e.preventDefault();
|
||||||
|
copy(pre.childNodes[0]);
|
||||||
|
})
|
||||||
|
})
|
||||||
|
// End: Copy <pre> code
|
||||||
|
|
||||||
const textareaSelector = 'textarea';
|
const textareaSelector = 'textarea';
|
||||||
const mentions = [
|
const mentions = [
|
||||||
// User mentions
|
// User mentions
|
||||||
|
|
@ -45,6 +73,7 @@ BlazeComponent.extendComponent({
|
||||||
index: 1,
|
index: 1,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
const enableTextarea = function() {
|
const enableTextarea = function() {
|
||||||
const $textarea = this.$(textareaSelector);
|
const $textarea = this.$(textareaSelector);
|
||||||
autosize($textarea);
|
autosize($textarea);
|
||||||
|
|
@ -288,6 +317,10 @@ BlazeComponent.extendComponent({
|
||||||
const $editor = this.$('textarea.editor');
|
const $editor = this.$('textarea.editor');
|
||||||
$editor[0].value = converter.convert($editor[0].value);
|
$editor[0].value = converter.convert($editor[0].value);
|
||||||
},
|
},
|
||||||
|
// TODO: Try to make copyPre visible at Card Details after editing or closing editor or Card Details.
|
||||||
|
//'click .js-close-inlined-form'(event) {
|
||||||
|
// Utils.copyPre();
|
||||||
|
//},
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue