UNPKG

@syncfusion/ej2-documenteditor

Version:

Feature-rich document editor control with built-in support for context menu, options pane and dialogs.

116 lines (115 loc) 3.81 kB
/** * Constants for mapping group identification */ export var MAPPING_GROUP = '_mapping_group'; export var XMLMAPPING_ID = '_xmlmapping'; /** * MappingGroup module * @private */ var MappingGroup = /** @class */ (function () { /** * Constructor for MappingGroup class * @param {DocumentEditorContainer} container - DocumentEditorContainer instance */ function MappingGroup(container) { this.container = container; this.ribbonId = this.container.element.id + '_ribbon'; } Object.defineProperty(MappingGroup.prototype, "documentEditor", { /** * Get the DocumentEditor instance * @returns {DocumentEditor} The DocumentEditor instance */ get: function () { return this.container.documentEditor; }, enumerable: true, configurable: true }); /** * Get the Mapping group model * @returns {RibbonGroupModel} The Mapping group model */ MappingGroup.prototype.getGroupModel = function () { var locale = this.container.localObj; var id = this.ribbonId + MAPPING_GROUP; return { id: id, header: locale.getConstant('Mapping'), orientation: 'Row', enableGroupOverflow: true, overflowHeader: locale.getConstant('Mapping'), collections: [ { items: [ this.getXmlMappingButtonModel() ] } ] }; }; /** * Get the XML Mapping button model * @returns {RibbonItemModel} The XML Mapping button model */ MappingGroup.prototype.getXmlMappingButtonModel = function () { var locale = this.container.localObj; var id = this.ribbonId + MAPPING_GROUP; return { type: 'Button', id: id + XMLMAPPING_ID, buttonSettings: { iconCss: 'e-icons e-de-ctnr-xml-mapping', content: locale.getConstant('XML Mapping Pane'), clicked: this.onXmlMappingClick.bind(this) }, ribbonTooltipSettings: { content: locale.getConstant('XML Mapping Pane') } }; }; /** * Handle XML Mapping button click * @returns {void} */ MappingGroup.prototype.onXmlMappingClick = function () { var _this = this; if (!this.documentEditor.isXmlPaneTool) { this.documentEditor.showXmlPane(); } this.container.statusBar.toggleWebLayout(); setTimeout(function () { _this.documentEditor.focusIn(); }, 30); }; /** * Update UI based on current selection * @returns {void} * @private */ MappingGroup.prototype.updateSelection = function () { // Update UI state based on current selection var isReadOnly = this.documentEditor.isReadOnly; var isDocumentProtected = this.documentEditor.documentHelper.isDocumentProtected; // Disable XML mapping in read-only mode or protected document var enableXmlMapping = !isReadOnly && !isDocumentProtected; // Implementation to enable/disable XML mapping button var xmlMappingElement = document.getElementById(this.ribbonId + MAPPING_GROUP + XMLMAPPING_ID); if (xmlMappingElement) { xmlMappingElement.classList.toggle('e-disabled', !enableXmlMapping); } }; /** * Destroy the MappingGroup instance * @returns {void} * @private */ MappingGroup.prototype.destroy = function () { // Clear all references this.container = undefined; this.ribbonId = undefined; }; return MappingGroup; }()); export { MappingGroup };