devextreme
Version:
HTML5 JavaScript Component Suite for Responsive Web Development
111 lines (109 loc) • 3.42 kB
JavaScript
/**
* DevExtreme (cjs/__internal/ui/text_box/texteditor_button_collection/m_button.js)
* Version: 25.2.3
* Build date: Fri Dec 12 2025
*
* Copyright (c) 2012 - 2025 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.isButtonInstance = exports.default = void 0;
var _renderer = _interopRequireDefault(require("../../../../core/renderer"));
var _button = _interopRequireDefault(require("../../../../ui/button"));
function _interopRequireDefault(e) {
return e && e.__esModule ? e : {
default: e
}
}
const isButtonInstance = instance => instance instanceof _button.default;
exports.isButtonInstance = isButtonInstance;
class TextEditorButton {
constructor(name, editor, options) {
this.instance = null;
this.$container = null;
this.$placeMarker = null;
this.editor = editor;
this.name = name;
this.options = options || {}
}
_addPlaceMarker($container) {
this.$placeMarker = (0, _renderer.default)("<div>").appendTo($container)
}
_addToContainer($element) {
const {
$placeMarker: $placeMarker,
$container: $container
} = this;
if ($placeMarker) {
$placeMarker.replaceWith($element)
} else {
$element.appendTo($container)
}
}
_attachEvents(instance, $element) {
throw "Not implemented"
}
_create() {
throw "Not implemented"
}
_isRendered() {
return !!this.instance
}
_isVisible() {
const {
editor: editor,
options: options
} = this;
return options.visible || !(null !== editor && void 0 !== editor && editor.option("readOnly"))
}
_isDisabled() {
throw "Not implemented"
}
_shouldRender() {
return this._isVisible() && !this._isRendered()
}
dispose() {
var _this$$placeMarker;
const {
instance: instance
} = this;
if (instance) {
if (isButtonInstance(instance)) {
instance.dispose();
instance.$element().remove();
instance._$element = null
} else {
instance.remove()
}
}
this.instance = null;
this.editor = null;
this.$container = null;
null === (_this$$placeMarker = this.$placeMarker) || void 0 === _this$$placeMarker || _this$$placeMarker.remove();
this.$placeMarker = null
}
render() {
let $container = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : this.$container;
this.$container = $container;
if (this._isVisible()) {
const {
instance: instance,
$element: $element
} = this._create() ?? {};
this.instance = instance;
this._attachEvents(instance, $element)
} else {
this._addPlaceMarker($container)
}
}
update() {
if (this._shouldRender()) {
this.render()
}
return !!this.instance
}
}
exports.default = TextEditorButton;