mirror of
https://github.com/itflow-org/itflow
synced 2026-11-11 07:01:16 +00:00
21 lines
873 B
JavaScript
21 lines
873 B
JavaScript
/*
|
|
* The canned response window (includes/canned_response_form.php):
|
|
* a placeholder under the editor goes in where the cursor is. The window is an
|
|
* ajax modal that runs this each time it opens, so the listener is bound once.
|
|
*/
|
|
itflowBindOnce('itflowCannedPlaceholder', 'click', '[data-canned-placeholder]', function () {
|
|
const text = '[' + this.dataset.cannedPlaceholder + ']';
|
|
const editor = window.tinymce ? tinymce.get('cannedResponseBody') : null;
|
|
if (editor) {
|
|
editor.insertContent(text);
|
|
editor.focus();
|
|
return;
|
|
}
|
|
const textarea = document.getElementById('cannedResponseBody');
|
|
if (textarea) {
|
|
const at = textarea.selectionStart ?? textarea.value.length;
|
|
textarea.value = textarea.value.slice(0, at) + text + textarea.value.slice(textarea.selectionEnd ?? at);
|
|
textarea.focus();
|
|
}
|
|
});
|