@syncfusion/ej2-documenteditor
Version:
Feature-rich document editor control with built-in support for context menu, options pane and dialogs.
125 lines (124 loc) • 5.29 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';
// Clipboard group constants
export var CLIPBOARD_GROUP_ID = '_clipboard_group';
export var CUT_ID = '_cut';
export var COPY_ID = '_copy';
export var PASTE_ID = '_paste';
export var LOCAL_CLIPBOARD_ID = '_local_clipboard';
/**
* ClipboardGroup class for handling clipboard operations in Document Editor ribbon
* @private
*/
var ClipboardGroup = /** @class */ (function (_super) {
__extends(ClipboardGroup, _super);
function ClipboardGroup() {
return _super !== null && _super.apply(this, arguments) || this;
}
/**
* Get the Ribbon group model for Clipboard
* @returns {RibbonGroupModel} - The ribbon group model for Clipboard
* @private
*/
ClipboardGroup.prototype.getGroupModel = function () {
var _this = this;
var id = this.ribbonId;
return {
id: id + CLIPBOARD_GROUP_ID,
cssClass: 'e-clipboard-group',
header: this.localObj.getConstant('Clipboard'),
enableGroupOverflow: true,
overflowHeader: this.localObj.getConstant('Clipboard'),
// orientation: ItemOrientation.Row,
groupIconCss: 'e-icons e-de-ctnr-paste',
collections: [
{
items: [
{
type: 'Button',
keyTip: 'X',
buttonSettings: {
content: this.localObj.getConstant('Cut'),
iconCss: 'e-icons e-de-ctnr-cut',
isToggle: false,
clicked: function () {
if (!_this.documentEditor.isReadOnly && _this.documentEditor.editor) {
_this.documentEditor.editor.cut();
}
}
},
id: id + CUT_ID,
ribbonTooltipSettings: { content: this.localObj.getConstant('Cut Tooltip') }
}, {
type: 'Button',
keyTip: 'C',
buttonSettings: {
content: this.localObj.getConstant('Copy'),
iconCss: 'e-icons e-de-ctnr-copy',
isToggle: false,
clicked: function () {
if (_this.documentEditor.selection) {
_this.documentEditor.selection.copy();
}
}
},
id: id + COPY_ID,
ribbonTooltipSettings: { content: this.localObj.getConstant('Copy Tooltip') }
},
{
type: 'Button',
keyTip: 'V',
buttonSettings: {
content: this.localObj.getConstant('Local Clipboard'),
iconCss: 'e-icons e-de-ctnr-paste',
isToggle: true,
clicked: function () {
_this.container.enableLocalPaste = !_this.container.enableLocalPaste;
}
},
id: id + LOCAL_CLIPBOARD_ID,
ribbonTooltipSettings: { content: this.localObj.getConstant('Toggle between the internal clipboard and system clipboard') }
}
]
}
]
};
};
/**
* Update clipboard buttons based on selection state
* @returns {void}
* @private
*/
ClipboardGroup.prototype.updateSelection = function () {
// Get the ribbon from container
var ribbon = this.container.ribbonModule.ribbon;
if (!ribbon) {
return;
}
var id = this.ribbonId;
var isSelectionEmpty = this.container.documentEditor.selection.isEmpty;
// Update Cut and Copy buttons state based on selection
if (isSelectionEmpty) {
ribbon.disableItem(id + CUT_ID);
ribbon.disableItem(id + COPY_ID);
}
else {
ribbon.enableItem(id + CUT_ID);
ribbon.enableItem(id + COPY_ID);
}
};
return ClipboardGroup;
}(RibbonGroupBase));
export { ClipboardGroup };