<commit_before>$.Redactor.prototype.WoltLabAttachment = function() {
	"use strict";
	
	return {
		init: function() {
			require(['EventHandler'], (function(EventHandler) {
				EventHandler.add('com.woltlab.wcf.redactor2', 'insertAttachment_' + this.$element[0].id, this.WoltLabAttachment._insert.bind(this))
				EventHandler.add('com.woltlab.wcf.redactor2', 'deleteAttachment_' + this.$element[0].id, this.WoltLabAttachment._delete.bind(this))
			}).bind(this));
		},
		
		_insert: function(data) {
			var attachmentId = data.attachmentId;
			
			if (data.url) {
				this.insert.html('<img src="' + data.url + '" class="woltlabAttachment" data-attachment-id="' + attachmentId + '">');
			}
			else {
				// non-image attachment
				this.insert.text('[attach=' + attachmentId + '][/attach]');
			}
		},
		
		_delete: function(data) {
			var attachmentId = data.attachmentId;
			
			var editor = this.core.editor()[0];
			elBySelAll('.woltlabAttachment[data-attachment-id="' + attachmentId + '"]', editor, function(attachment) {
				elRemove(attachment);<commit_msg>Allow undoing of inserted attachments<commit_after>$.Redactor.prototype.WoltLabAttachment = function() {
	"use strict";
	
	return {
		init: function() {
			require(['EventHandler'], (function(EventHandler) {
				EventHandler.add('com.woltlab.wcf.redactor2', 'insertAttachment_' + this.$element[0].id, this.WoltLabAttachment._insert.bind(this))
				EventHandler.add('com.woltlab.wcf.redactor2', 'deleteAttachment_' + this.$element[0].id, this.WoltLabAttachment._delete.bind(this))
			}).bind(this));
		},
		
		_insert: function(data) {
			var attachmentId = data.attachmentId;
			
			this.buffer.set();
			
			if (data.url) {
				this.insert.html('<img src="' + data.url + '" class="woltlabAttachment" data-attachment-id="' + attachmentId + '">');
			}
			else {
				// non-image attachment
				this.insert.text('[attach=' + attachmentId + '][/attach]');
			}
		},
		
		_delete: function(data) {
			var attachmentId = data.attachmentId;
			
			var editor = this.core.editor()[0];
			elBySelAll('.woltlabAttachment[data-attachment-id="' + attachmentId + '"]', editor, function(attachment) {
				elRemove(attachment);
{'fraction_non_alphanumeric': 0.17401285583103765, 'fraction_numerical': 0.004591368227731864, 'mean_word_length': 4.175771971496437, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '18787', 'n_tokens_mistral': 822, 'n_tokens_neox': 708, 'n_words': 104}