| 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 | 1×
1×
1×
1×
1390×
1390×
30×
30×
30×
30×
30×
30×
30×
30×
26×
1390×
1×
158×
158×
158×
158×
158×
158×
158×
158×
20×
158×
158×
115×
115×
43×
43×
158×
158×
158×
158×
158×
199×
199×
158×
158×
158×
158×
158×
158×
1×
158×
158×
158×
158×
158×
158×
1×
1×
| define(["require", "exports", "../../../common/utils/index", "../../../common/constant", "../../../models/enums", "@syncfusion/ej2-base"], function (require, exports, index_1, constants, enums_1, ej2_base_1) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var CollapsibleRenderer = (function () {
function CollapsibleRenderer(manager) {
var _this = this;
this.updateCollapsibleBlockExpansion = function (blockElement, newState, isUndoRedoAction) {
var contentContainer = blockElement.querySelector('.' + constants.TOGGLE_CONTENT_CLS);
var blockModel = index_1.getBlockModelById(blockElement.id, _this.parent.getEditorBlocks());
var updatedState = newState;
blockModel.properties.isExpanded = updatedState;
_this.parent.stateManager.updateManagerBlocks();
blockElement.setAttribute('data-collapsed', String(!updatedState));
ej2_base_1.updateCSSText(contentContainer, "display: " + (updatedState ? 'block' : 'none') + ";");
if (!isUndoRedoAction) {
_this.parent.undoRedoAction.trackExpandedStateForUndoRedo(blockModel.id, blockModel.properties.isExpanded);
}
};
this.parent = manager;
}
CollapsibleRenderer.prototype.renderCollapsibleBlock = function (block, blockElement) {
var _this = this;
var collapsibleProps = block.properties;
blockElement.setAttribute('data-collapsed', String(!collapsibleProps.isExpanded));
var blockContent = ej2_base_1.createElement('div');
var toggleHeaderWrapper = ej2_base_1.createElement('div', {
className: 'e-toggle-header'
});
var toggleIcon = ej2_base_1.createElement('div', {
className: 'e-toggle-icon',
attrs: { contenteditable: 'false' }
});
toggleIcon.appendChild(this.renderToggleIcon());
toggleIcon.addEventListener('click', function () {
_this.updateCollapsibleBlockExpansion(blockElement, !collapsibleProps.isExpanded);
});
var headerElement;
switch (block.blockType) {
case enums_1.BlockType.CollapsibleParagraph:
headerElement = this.parent.blockRenderer.paragraphRenderer.renderParagraph(block);
break;
case enums_1.BlockType.CollapsibleHeading:
headerElement = this.parent.blockRenderer.headingRenderer.renderHeading(block);
break;
}
ej2_base_1.updateCSSText(headerElement, 'width: 100%;');
headerElement.classList.add('e-block-content');
var contentContainer = ej2_base_1.createElement('div', {
className: 'e-toggle-content',
attrs: { contenteditable: 'true' }
});
ej2_base_1.updateCSSText(contentContainer, "display: " + (collapsibleProps.isExpanded ? 'block' : 'none') + ";");
collapsibleProps.children.forEach(function (childBlock) {
var childBlockElement = _this.parent.blockRenderer.createBlockElement(childBlock);
contentContainer.appendChild(childBlockElement);
});
toggleHeaderWrapper.appendChild(toggleIcon);
toggleHeaderWrapper.appendChild(headerElement);
blockContent.appendChild(toggleHeaderWrapper);
blockContent.appendChild(contentContainer);
blockElement.classList.add('e-toggle-block');
return blockContent;
};
CollapsibleRenderer.prototype.renderToggleIcon = function () {
var svg = index_1.createBaseSvg();
var commonPathD = 'M5 20.1315V3.86852C5 3.06982 5.89014 2.59343 6.5547 3.03647L18.7519 11.1679C19.3457 11.5638 19.3457 12.4362 18.7519 12.8321L6.5547 20.9635C5.89015 21.4066 5 20.9302 5 20.1315Z';
var pathStroke = index_1.createSvgElement('path', {
d: commonPathD,
stroke: '#4D4B4B',
'stroke-width': '2',
'stroke-linecap': 'round',
'stroke-linejoin': 'round'
});
var pathFill = index_1.createSvgElement('path', {
d: commonPathD,
fill: '#4D4B4B'
});
svg.append(pathStroke, pathFill);
return svg;
};
return CollapsibleRenderer;
}());
exports.CollapsibleRenderer = CollapsibleRenderer;
});
|