UNPKG

devextreme

Version:

JavaScript/TypeScript Component Suite for Responsive Web Development

98 lines (96 loc) • 3.57 kB
/** * DevExtreme (cjs/__internal/ui/text_box/texteditor_button_collection/custom.js) * Version: 26.1.6 * Build date: Fri Oct 16 2026 * * Copyright (c) 2012 - 2026 Developer Express Inc. ALL RIGHTS RESERVED * Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/ */ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _click = require("../../../../common/core/events/click"); var _events_engine = _interopRequireDefault(require("../../../../common/core/events/core/events_engine")); var _hover = require("../../../../common/core/events/hover"); var _renderer = _interopRequireDefault(require("../../../../core/renderer")); var _button = _interopRequireDefault(require("../../../../ui/button")); var _button2 = _interopRequireDefault(require("../../../ui/text_box/texteditor_button_collection/button")); function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e } } const CUSTOM_BUTTON_HOVERED_CLASS = "dx-custom-button-hovered"; class CustomButton extends _button2.default { _attachEvents(instance, $element) { _events_engine.default.on($element, _hover.start, () => { var _this$editor; null === (_this$editor = this.editor) || void 0 === _this$editor || _this$editor.$element().addClass("dx-custom-button-hovered") }); _events_engine.default.on($element, _hover.end, () => { var _this$editor2; null === (_this$editor2 = this.editor) || void 0 === _this$editor2 || _this$editor2.$element().removeClass("dx-custom-button-hovered") }); _events_engine.default.on($element, _click.name, e => { e.stopPropagation() }) } _create() { const { editor: editor } = this; if (!editor) { return } const $element = (0, _renderer.default)("<div>"); this._addToContainer($element); const instance = editor._createComponent($element, _button.default, Object.assign({}, this.options, { ignoreParentReadOnly: true, disabled: this._isDisabled(), integrationOptions: this._prepareIntegrationOptions(editor) })); return { instance: instance, $element: $element } } _prepareIntegrationOptions(editor) { const { integrationOptions: integrationOptions } = editor.option(); return Object.assign({}, integrationOptions, { skipTemplates: ["content"] }) } update() { const isUpdated = super.update(); if (this.instance) { this.instance.option("disabled", this._isDisabled()) } return isUpdated } _isVisible() { var _this$editor3; const { visible: visible } = (null === (_this$editor3 = this.editor) || void 0 === _this$editor3 ? void 0 : _this$editor3.option()) ?? {}; return !!visible } _isDisabled() { var _this$editor4; const isDefinedByUser = void 0 !== this.options.disabled; if (isDefinedByUser) { if (this.instance) { return this.instance.option("disabled") } return this.options.disabled } const { readOnly: readOnly } = (null === (_this$editor4 = this.editor) || void 0 === _this$editor4 ? void 0 : _this$editor4.option()) ?? {}; return readOnly } } exports.default = CustomButton;