Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8,052 changes: 8,031 additions & 21 deletions dist/doboard-widget-bundle.js

Large diffs are not rendered by default.

46 changes: 18 additions & 28 deletions dist/doboard-widget-bundle.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/doboard-widget-bundle.min.js.map

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ let browserSync = require('browser-sync').create();
function bundle_src_js() {
const cssStream = processCSS();
const jsStream = gulp.src([
'js/src/lib/html2canvas.js',
'js/src/localDB.js',
'js/src/api.js',
'js/src/websocket.js',
Expand Down
48 changes: 47 additions & 1 deletion js/src/fileuploader.js
Original file line number Diff line number Diff line change
Expand Up @@ -388,4 +388,50 @@ class FileUploader {

return results;
}
}

/**
* Make a screenshot and add it as a file
* @returns {Promise<void>}
*/
async makeScreenshot() {
if (typeof html2canvas === 'undefined') {
console.error("SpotFix Error: in Screenshot Library");
return null;
}
try {
const canvas = await html2canvas(document.body, {
useCORS: true,
allowTaint: true,
logging: false,
scale: window.devicePixelRatio || 1
});

const blob = await new Promise(resolve => canvas.toBlob(resolve, 'image/png'));
if (!blob) return null;

const now = new Date();
const hours = String(now.getHours()).padStart(2, '0');
const minutes = String(now.getMinutes()).padStart(2, '0');
const day = String(now.getDate()).padStart(2, '0');
const month = String(now.getMonth() + 1).padStart(2, '0');
const year = now.getFullYear();

const fileName = `Screenshot_${hours}-${minutes}_${day}_${month}_${year}.png`;
const file = new File([blob], fileName, {
type: 'image/png',
lastModified: Date.now()
});

if (this.uploaderWrapper && this.uploaderWrapper.style.display !== 'block') {
this.uploaderWrapper.style.display = 'block';
}

this.clearError();
this.addFile(file);

} catch (err) {
console.error("SpotFix Error: creating screenshot:", err);
return null;
}
}
}
59 changes: 59 additions & 0 deletions js/src/handlers.js

Large diffs are not rendered by default.

7,830 changes: 7,830 additions & 0 deletions js/src/lib/html2canvas.js

Large diffs are not rendered by default.

26 changes: 8 additions & 18 deletions js/src/loaders/SpotFixTemplatesLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,21 +79,11 @@ class SpotFixTemplatesLoader {
<div class="doboard_task_widget-concrete_issues-container">
</div>
<div class="doboard_task_widget-send_message">
<div class="doboard_task_widget-send_message_elements_wrapper">
<button type="button" class="doboard_task_widget-send_message_paperclip">
<img src="{{buttonPaperClip}}" alt="Attach a file">
<div class="doboard_task_widget-paperclip-tooltip">
Upload up to 5 JPG, PNG, GIF, PDF, TXT or DOC files (5MB each, 25MB total).
</div>
</button>

<div class="doboard_task_widget-send_message_input_wrapper">
<textarea name="doboard_task_widget_message" class="doboard_task_widget-send_message_input" placeholder="Write a message..."></textarea>
</div>

<button type="button" class="doboard_task_widget-send_message_button">
<img src="{{buttonSendMessage}}" alt="Send message" title="Send message">
</button>
<textarea name="doboard_task_widget_message" class="doboard_task_widget-send_message_input" placeholder="Write a message..."></textarea>
<div>
<div class="doboard_task_widget-field">
<button id="doboard_task_widget-submit_button" class="doboard_task_widget-submit_button doboard_task_widget-send_message_button">Submit</button>
</div>
</div>
<div class="doboard_task_widget__file-upload__wrapper" id="doboard_task_widget__file-upload__wrapper">
<div class="doboard_task_widget__file-upload__list-header">Attached files</div>
Expand Down Expand Up @@ -163,9 +153,9 @@ class SpotFixTemplatesLoader {
<label for="doboard_task_widget-title">Report about</label>
</div>

<div class="doboard_task_widget-input-container">
<textarea id="doboard_task_widget-description" class="doboard_task_widget-field" name="description" required></textarea>
<label for="doboard_task_widget-description">Description</label>
<div class="doboard_task_widget-input-container doboard_task_widget-input-container-textarea">
<textarea id="doboard_task_widget-description" class="doboard_task_widget-field" name="description" placeholder=" " required></textarea>
<label for="doboard_task_widget-description" class="doboard_task_widget-field-textarea-label" >Description</label>
</div>

<div class="doboard_task_widget-login">
Expand Down
16 changes: 16 additions & 0 deletions js/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,22 @@ if (document.querySelector('script[src="https://moderate.cleantalk.org/ct-bot-de
script.async = true;
script.id = 'ct-bot-detector-script';
document.head.appendChild(script);
loadTinyMCE();
}

/**
* Downloads TinyMCE script from doboard.com
*/
function loadTinyMCE() {
const script = document.createElement('script');
script.src = 'https://doboard.com/tinymce/tinymce.min.js';
script.async = true;

script.onload = function() {
addIconPack();
};

document.head.appendChild(script);
}

document.addEventListener('selectionchange', function(e) {
Expand Down
72 changes: 71 additions & 1 deletion js/src/widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,40 @@ class CleanTalkWidgetDoboard {
}
// bind creation events
this.bindCreateTaskEvents();

tinymce.init({
selector: '#doboard_task_widget-description',
plugins: 'link lists',
menubar: false,
statusbar: false,
toolbar_location: 'bottom',
toolbar: 'screenshotButton emoticons bullist numlist bold italic strikethrough underline blockquote',
height: 120,
icons: 'my_icon_pack',
file_picker_types: 'file image media',
setup: function (editor) {
editor.on('change', function () {
editor.save();
});
// editor.ui.registry.addButton('attachmentButton', {
// icon: 'paperclip',
// tooltip: 'Add file',
// disabled: true,
// onAction: (e) => {
// // fileUploader?.fileInput?.click(e);
//
// },
// });
Comment on lines +409 to +417
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this comment necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the code for the button. The functionality will be implemented later.

editor.ui.registry.addButton('screenshotButton', {
icon: 'screenshot',
tooltip: 'In development',
disabled: true,
onAction: (e) => {
// fileUploader?.makeScreenshot();
},
});
}
})
break;
case 'wrap':
await this.getTaskCount();
Expand Down Expand Up @@ -657,7 +691,43 @@ class CleanTalkWidgetDoboard {
}
textarea.addEventListener('input', handleTextareaChange)
textarea.addEventListener('change', handleTextareaChange)
}

const fileUploader = this.fileUploader;

tinymce.init({
selector: '.doboard_task_widget-send_message_input',
plugins: 'link lists',
menubar: false,
statusbar: false,
toolbar_location: 'bottom',
toolbar: 'attachmentButton screenshotButton emoticons bullist numlist bold italic strikethrough underline blockquote',
height: 120,
icons: 'my_icon_pack',
file_picker_types: 'file image media',
setup: function (editor) {
editor.on('change', function () {
editor.save();
});
editor.ui.registry.addButton('attachmentButton', {
icon: 'paperclip',
tooltip: 'Add file',
disabled: true,
onAction: (e) => {
fileUploader?.fileInput?.click(e);

},
});
editor.ui.registry.addButton('screenshotButton', {
icon: 'screenshot',
tooltip: 'Screenshot',
disabled: true,
onAction: (e) => {
fileUploader?.makeScreenshot();
},
});
}
});
}

// Hide spinner preloader
hideContainersSpinner();
Expand Down
52 changes: 45 additions & 7 deletions styles/doboard-widget.css
Original file line number Diff line number Diff line change
Expand Up @@ -907,12 +907,6 @@
}


.doboard_task_widget-send_message_elements_wrapper button {
height: 37px;
background: none;
margin: 0;
}

.doboard_task_widget-send_message_elements_wrapper img {
margin: 0;
}
Expand Down Expand Up @@ -951,7 +945,16 @@
outline: none;
}

.doboard_task_widget-send_message_button, .doboard_task_widget-send_message_paperclip {
.doboard_task_widget-send_message_button {
display: inline-grid;
border: none;
cursor: pointer;
padding: 0;
width: 100%;
align-items: center;
margin: 20px 0 0 0;
}
.doboard_task_widget-send_message_paperclip {
display: inline-grid;
border: none;
background: none;
Expand Down Expand Up @@ -1225,6 +1228,19 @@
justify-content: space-between;
}

.doboard_task_widget-content .tox .tox-toolbar__group {
padding: 0 8px !important;
}

.doboard_task_widget-content .tox-tinymce {
border: 1px solid #BBC7D1;
border-radius: 4px;
}

.doboard_task_widget-content ul, .doboard_task_widget-content ol {
margin: 0 0 0 1em !important;
}

.toggle {
position: relative;
display: inline-block;
Expand Down Expand Up @@ -1275,3 +1291,25 @@ input:checked + .slider:before {
cursor: pointer;
}

.doboard_task_widget-input-container-textarea {
position: relative;
margin-top: 20px;
}

.doboard_task_widget-field-textarea-label {
position: absolute;
left: 10px;
top: 10px;
padding: 0 5px;
color: #666;
background-color: white;
transition: 0.2s ease all;
pointer-events: none;
}

.doboard_task_widget-input-container-textarea .doboard_task_widget-field ~ label {
top: -10px;
left: 14px;
font-size: 10px;
color: #252A2F;
}