Skip to content
8,066 changes: 8,039 additions & 27 deletions dist/doboard-widget-bundle.js

Large diffs are not rendered by default.

54 changes: 23 additions & 31 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.

34 changes: 13 additions & 21 deletions js/src/loaders/SpotFixTemplatesLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,21 +77,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 @@ -161,10 +151,9 @@ class SpotFixTemplatesLoader {
<label class="spotfix_placeholder_title" for="doboard_task_widget-title">Report about</label>
</div>

<div class="doboard_task_widget-input-container" style="flex-grow: 1">
<textarea id="doboard_task_widget-description"
class="doboard_task_widget-field" name="description" required>{{descriptionText}}</textarea>
<label class="spotfix_placeholder_description" 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 Expand Up @@ -291,8 +280,11 @@ class SpotFixTemplatesLoader {
</div>
<div style="display: flex; flex-direction: column; align-items: center">
<img class="doboard_task_widget-user_menu-header-avatar" src="{{avatar}}" alt="">
<span class="doboard_task_widget-user_menu-header-user-name" style="font-size: 16px; font-weight: 700">{{userName}}</span>
<span class="doboard_task_widget-user_menu-header-email" style="font-size: 12px;">{{email}}</span>
<span style="font-size: 16px; font-weight: 700">{{userName}}</span>
<span style="font-size: 12px;">{{email}}</span>
<span id="doboard_task_widget-user_menu-signlog_button">
<a style="cursor: pointer" rel="nofollow" target="_blank">Sign up or Log in</a>
</span>
</div>
</div>
<div class="doboard_task_widget-content" style="min-height:200px ">
Expand Down
16 changes: 16 additions & 0 deletions js/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,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
78 changes: 74 additions & 4 deletions js/src/widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ class CleanTalkWidgetDoboard {
forgotPasswordButton.addEventListener('click', async () => {
const forgotPasswordForm = document.getElementById('doboard_task_widget-container-login-forgot-password-form');
const loginContainer = document.getElementById('doboard_task_widget-input-container-login');

if (forgotPasswordForm) {
forgotPasswordForm.classList.remove('doboard_task_widget-hidden');
}
Expand Down Expand Up @@ -371,7 +371,7 @@ class CleanTalkWidgetDoboard {
forgotPasswordButtonMenu.addEventListener('click', async () => {
const forgotPasswordForm = document.getElementById('doboard_task_widget-container-login-forgot-password-form');
const loginContainer = document.querySelector('.doboard_task_widget-input-container-login-menu');

if (forgotPasswordForm) {
forgotPasswordForm.classList.remove('doboard_task_widget-hidden');
}
Expand Down Expand Up @@ -462,7 +462,7 @@ class CleanTalkWidgetDoboard {
}
const passwordToggle = document.getElementById('doboard_task_widget-password-toggle');
const passwordInput = document.getElementById('doboard_task_widget-login_password');

if (passwordToggle && passwordInput) {
passwordToggle.addEventListener('click', function() {
const isPassword = passwordInput.type === 'password';
Expand Down Expand Up @@ -677,6 +677,40 @@ class CleanTalkWidgetDoboard {
// bind creation events
this.bindCreateTaskEvents();
this.bindShowLoginFormEvents();

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);
//
// },
// });
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 @@ -979,7 +1013,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 @@ -956,12 +956,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 @@ -1000,7 +994,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 @@ -1276,6 +1279,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 @@ -1377,3 +1393,25 @@ input:checked + .slider:before {
z-index: 10;

}
.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;
}