<commit_before>"use strict";
/* globals bootbox, config */

$(document).ready(function() {
	var defaults;

	$.get(config.relative_path + '/canned-responses/defaults', function(data) {
		defaults = data;
	});

	
	$(window).on('action:composer.loaded', function(e, data) {
		require(['composer/controls'], function(controls) {
			var cid = parseInt(data.composerData.cid, 10);
			var textarea = $('#cmp-uuid-' + data.post_uuid + ' textarea');
			if (defaults[cid]) {
				controls.insertIntoTextarea(textarea, defaults[cid]);
			}	
		});
	});

	$(window).on('action:composer.enhanced', function() {
		require(['composer/formatting', 'composer/controls'], function(formatting, controls) {
			formatting.addButtonDispatch('canned-responses', function(textarea, selectionStart, selectionEnd) {
				openModal(function () {
					var submitEl = this.find('.btn-primary').attr('disabled', 'disabled');
					var responseText = submitEl.data('text');
					controls.insertIntoTextarea(textarea, responseText);
					controls.updateTextareaSelection(textarea, selectionStart, selectionStart + responseText.length);

					// Go back to focusing on the textarea after modal closes (since that action steals focus)
					this.one('hidden.bs.modal', function() {
						$(textarea).focus();
					});
				})
			});<commit_msg>feat: compatibility with Quill's toolbar<commit_after>"use strict";
/* globals bootbox, config */

$(document).ready(function() {
	var defaults;

	$.get(config.relative_path + '/canned-responses/defaults', function(data) {
		defaults = data;
	});

	$(window).on('action:composer.loaded', function(e, data) {
		require(['composer/controls'], function(controls) {
			var cid = parseInt(data.composerData.cid, 10);
			var textarea = $('#cmp-uuid-' + data.post_uuid + ' textarea');
			if (defaults[cid]) {
				controls.insertIntoTextarea(textarea, defaults[cid]);
			}
		});
	});

	require(['composer/formatting', 'composer/controls'], function(formatting, controls) {
		$(window).on('action:composer.enhanced', function() {
			formatting.addButtonDispatch('canned-responses', function(textarea, selectionStart, selectionEnd) {
				// Context for Quill, etc.
				var context = this;

				openModal(function () {
					var submitEl = this.find('.btn-primary').attr('disabled', 'disabled');
					var responseText = submitEl.data('text');
					controls.insertIntoTextarea.bind(context)(textarea, responseText);
					controls.updateTextareaSelection.bind(context)(textarea, selectionStart, selectionStart + responseText.length);

					// Go back to focusing on the textarea after modal closes (since that action steals focus)
					this.one('hidden.bs.modal', function() {
						$(textarea).focus();
					});
				})
			});
{'fraction_non_alphanumeric': 0.16200294550810015, 'fraction_numerical': 0.0014727540500736377, 'mean_word_length': 4.5336048879837065, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '68064', 'n_tokens_mistral': 939, 'n_tokens_neox': 792, 'n_words': 157}