@syncfusion/ej2-documenteditor
Version:
Feature-rich document editor control with built-in support for context menu, options pane and dialogs.
107 lines (106 loc) • 4.36 kB
JavaScript
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
import { RibbonGroupBase } from '../ribbon-interfaces';
// Find and Replace group constants
export var FIND_GROUP_ID = '_find_group';
export var FIND_ID = '_find';
export var REPLACE_ID = '_replace';
/**
* FindGroup class for handling find and replace operations in Document Editor ribbon
* @private
*/
var FindGroup = /** @class */ (function (_super) {
__extends(FindGroup, _super);
function FindGroup() {
return _super !== null && _super.apply(this, arguments) || this;
}
/**
* Get the Ribbon group model for Find
* @returns {RibbonGroupModel} - Ribbon group model for Find
* @private
*/
FindGroup.prototype.getGroupModel = function () {
var _this = this;
var id = this.ribbonId;
return {
id: id + FIND_GROUP_ID,
cssClass: 'e-find-group',
header: this.localObj.getConstant('Find'),
enableGroupOverflow: true,
overflowHeader: this.localObj.getConstant('Find'),
groupIconCss: 'e-icons e-de-ctnr-find',
collections: [
{
id: id + '_find-collection',
items: [
{
type: 'Button',
keyTip: 'FD',
buttonSettings: {
content: this.localObj.getConstant('Find'),
iconCss: 'e-icons e-de-ctnr-find',
clicked: function () {
if (_this.documentEditor.searchModule) {
_this.documentEditor.optionsPaneModule.isFind = true;
_this.documentEditor.showOptionsPane();
}
}
},
id: id + FIND_ID,
ribbonTooltipSettings: { content: this.localObj.getConstant('Find Text') }
},
{
type: 'Button',
keyTip: 'R',
buttonSettings: {
content: this.localObj.getConstant('Replace'),
iconCss: 'e-icons e-de-ctnr-replace',
clicked: function () {
if (!_this.documentEditor.isReadOnly && _this.documentEditor.optionsPaneModule) {
_this.documentEditor.optionsPaneModule.isReplace = true;
_this.documentEditor.documentEditorSettings.showNavigationPane = true;
}
}
},
id: id + REPLACE_ID,
ribbonTooltipSettings: { content: this.localObj.getConstant('Replace Text') }
}
]
}
]
};
};
/**
* Update find buttons based on document state
* @returns {void}
* @private
*/
FindGroup.prototype.updateSelection = function () {
// Get the ribbon from container
var ribbon = this.container.ribbonModule.ribbon;
if (!ribbon) {
return;
}
var id = this.ribbonId;
// If we need to disable replace when the document is read-only:
if (this.documentEditor.isReadOnly) {
ribbon.disableItem(id + REPLACE_ID);
}
else {
ribbon.enableItem(id + REPLACE_ID);
}
};
return FindGroup;
}(RibbonGroupBase));
export { FindGroup };