| 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120 | 1×
1×
1×
1×
1390×
1390×
1×
1390×
1390×
1390×
1390×
1390×
1390×
1390×
1390×
1390×
1390×
1390×
1390×
1390×
1×
1390×
1390×
1390×
1390×
1390×
1390×
1390×
1390×
1390×
1390×
1390×
1390×
1390×
1×
3806×
1×
11374×
1×
33×
1×
127×
127×
127×
1×
171×
1×
28×
1×
27×
1×
26×
1×
1829×
2184×
2184×
2184×
3×
2184×
3×
2184×
1829×
1829×
1829×
1×
34×
34×
2×
34×
1×
33×
33×
2×
33×
1×
85×
1×
1390×
1×
1×
| define(["require", "exports", "../../common/constant", "../../common/constant", "@syncfusion/ej2-base", "../../common/utils/transform"], function (require, exports, constant_1, constants, ej2_base_1, transform_1) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var Intermediate = (function () {
function Intermediate(editor) {
this.editor = editor;
this.wireGlobalEvents();
}
Intermediate.prototype.wireGlobalEvents = function () {
this.editor.blockManager.observer.on('updateEditorBlocks', this.handleModelChanges, this);
this.editor.blockManager.observer.on('selectionChanged', this.handleSelectionChange, this);
this.editor.blockManager.observer.on('beforePaste', this.triggerBeforePaste, this);
this.editor.blockManager.observer.on('afterPaste', this.triggerAfterPaste, this);
this.editor.blockManager.observer.on('blockActionsMenuClose', this.triggerBlockActionsMenuCloseEvent, this);
this.editor.blockManager.observer.on('blockActionsMenuOpen', this.triggerBlockActionsMenuOpenEvent, this);
this.editor.blockManager.observer.on('blockDragging', this.triggerBlockDrag, this);
this.editor.blockManager.observer.on('blockDragStart', this.triggerBlockStart, this);
this.editor.blockManager.observer.on('blockDropped', this.triggerBlockDrop, this);
this.editor.blockManager.observer.on('triggerBlockChange', this.triggerBlockChangeEvent, this);
this.editor.blockManager.observer.on('renderTemplateBlock', this.editor.renderTemplate, this.editor);
this.editor.blockManager.observer.on('renderDropdownList', this.renderDropdownList, this);
this.editor.on(constant_1.events.destroy, this.destroy, this);
};
Intermediate.prototype.unWireGlobalEvents = function () {
this.editor.blockManager.observer.off('updateEditorBlocks', this.handleModelChanges);
this.editor.blockManager.observer.off('selectionChanged', this.handleSelectionChange);
this.editor.blockManager.observer.off('beforePaste', this.triggerBeforePaste);
this.editor.blockManager.observer.off('afterPaste', this.triggerAfterPaste);
this.editor.blockManager.observer.off('blockActionsMenuClose', this.triggerBlockActionsMenuCloseEvent);
this.editor.blockManager.observer.off('blockActionsMenuOpen', this.triggerBlockActionsMenuOpenEvent);
this.editor.blockManager.observer.off('blockDragging', this.triggerBlockDrag);
this.editor.blockManager.observer.off('blockDragStart', this.triggerBlockStart);
this.editor.blockManager.observer.off('blockDropped', this.triggerBlockDrop);
this.editor.blockManager.observer.off('triggerBlockChange', this.triggerBlockChangeEvent);
this.editor.blockManager.observer.off('renderTemplateBlock', this.editor.renderTemplate);
this.editor.blockManager.observer.off('renderDropdownList', this.renderDropdownList);
this.editor.off(constant_1.events.destroy, this.destroy);
};
Intermediate.prototype.processActions = function (action, args) {
this.editor.blockManager.observer.notify(action, args);
};
Intermediate.prototype.handleModelChanges = function (state) {
this.editor.setProperties({ blocks: state.blocks }, true);
};
Intermediate.prototype.handleSelectionChange = function (args) {
this.editor.trigger('selectionChanged', args);
};
Intermediate.prototype.triggerBeforePaste = function (args) {
var eventArgs = {
cancel: args.cancel,
content: args.content
};
this.editor.trigger('beforePaste', eventArgs);
args.callback(eventArgs);
};
Intermediate.prototype.triggerAfterPaste = function (args) {
this.editor.trigger('afterPaste', args);
};
Intermediate.prototype.triggerBlockDrag = function (args) {
this.editor.trigger('blockDragging', args);
};
Intermediate.prototype.triggerBlockStart = function (args) {
this.editor.trigger('blockDragStart', args);
};
Intermediate.prototype.triggerBlockDrop = function (args) {
this.editor.trigger('blockDropped', args);
};
Intermediate.prototype.triggerBlockChangeEvent = function (changes) {
var validChanges = changes
.filter(function (_, index) { return Number.isInteger(index) && changes[index] !== undefined; })
.map(function (change) {
var clonedData = transform_1.cloneObject(change.data, ['targetId', 'isMovingUp']);
if (!ej2_base_1.isNullOrUndefined(change.data.currentParent)) {
clonedData.currentParent = change.data.currentParent;
}
if (!ej2_base_1.isNullOrUndefined(change.data.prevParent)) {
clonedData.prevParent = change.data.prevParent;
}
return {
action: change.action,
data: clonedData
};
});
var blockChangeEventArgs = { changes: validChanges };
this.editor.eventManager.triggerBlockChangeEvent(blockChangeEventArgs);
this.editor.blockManager.observer.notify(constants.CLEAREVENTCHANGES);
};
Intermediate.prototype.triggerBlockActionsMenuCloseEvent = function (args) {
var eventArgs = {
event: args.event,
items: args.items,
cancel: args.cancel
};
if (this.editor.blockActionMenuSettings.closing) {
this.editor.blockActionMenuSettings.closing.call(this, eventArgs);
}
args.callback(eventArgs);
};
Intermediate.prototype.triggerBlockActionsMenuOpenEvent = function (args) {
var eventArgs = {
event: args.event,
items: args.items,
cancel: args.cancel
};
if (this.editor.blockActionMenuSettings.opening) {
this.editor.blockActionMenuSettings.opening.call(this, eventArgs);
}
args.callback(eventArgs);
};
Intermediate.prototype.renderDropdownList = function (args) {
this.editor.dropdownListRenderer.renderDropDownList(args);
};
Intermediate.prototype.destroy = function () {
this.unWireGlobalEvents();
};
return Intermediate;
}());
exports.Intermediate = Intermediate;
});
|