define(["require", "exports", "../../editor-manager/plugin/clipboard-cleanup-action", "../base/constant", "@syncfusion/ej2-base", "../base/util"], function (require, exports, clipboard_cleanup_action_1, events, ej2_base_1, util_1) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var ClipBoardCleanup = (function () {
function ClipBoardCleanup(parent) {
this.parent = parent;
this.addEventListener();
this.isDestroyed = false;
}
ClipBoardCleanup.prototype.addEventListener = function () {
if (!this.parent.isDestroyed) {
this.parent.on(events.clipBoardCleanup, this.clipBoardCleanup, this);
this.parent.on(events.bindOnEnd, this.bindOnEnd, this);
this.parent.on(events.destroy, this.destroy, this);
}
};
ClipBoardCleanup.prototype.destroy = function () {
if (this.isDestroyed) {
return;
}
this.removeEventListener();
this.isDestroyed = true;
};
ClipBoardCleanup.prototype.removeEventListener = function () {
this.parent.off(events.clipBoardCleanup, this.clipBoardCleanup);
this.parent.off(events.destroy, this.destroy);
this.parent.off(events.bindOnEnd, this.bindOnEnd);
};
ClipBoardCleanup.prototype.bindOnEnd = function () {
if (this.parent.editorMode === 'HTML' && this.parent.formatter && this.parent.formatter.editorManager
&& this.parent.contentModule) {
this.clipBoardCleanupObj =
new clipboard_cleanup_action_1.ClipBoardCleanupAction(this.parent.formatter.editorManager);
}
};
ClipBoardCleanup.prototype.clipBoardCleanup = function (e) {
var _this = this;
Eif (!ej2_base_1.isNullOrUndefined(e.args)) {
var range = this.parent.getRange();
var editableElement = this.parent.contentModule.getEditPanel();
var operation = e.args.type;
var clipboardDataArgs = this.clipBoardCleanupObj.handleClipboardProcessing(range, editableElement, operation);
this.parent.trigger(events.beforeClipboardWrite, clipboardDataArgs, function (clipboardWriteArgs) {
var htmlText = util_1.sanitizeHelper(clipboardWriteArgs.htmlContent, _this.parent);
var plainText = util_1.sanitizeHelper(clipboardWriteArgs.plainTextContent, _this.parent);
e.args.clipboardData.setData('text/html', htmlText);
e.args.clipboardData.setData('text/plain', plainText);
});
}
};
ClipBoardCleanup.prototype.getModuleName = function () {
return 'clipBoardCleanup';
};
return ClipBoardCleanup;
}());
exports.ClipBoardCleanup = ClipBoardCleanup;
});
|