devextreme
Version:
HTML5 JavaScript Component Suite for Responsive Web Development
96 lines (94 loc) • 3.06 kB
JavaScript
/**
* DevExtreme (cjs/ui/text_box/texteditor_button_collection/button.js)
* Version: 23.2.6
* Build date: Wed May 01 2024
*
* Copyright (c) 2012 - 2024 Developer Express Inc. ALL RIGHTS RESERVED
* Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/
*/
;
exports.default = void 0;
var _renderer = _interopRequireDefault(require("../../../core/renderer"));
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
default: obj
}
}
let TextEditorButton = function() {
function TextEditorButton(name, editor, options) {
this.instance = null;
this.$container = null;
this.$placeMarker = null;
this.editor = editor;
this.name = name;
this.options = options || {}
}
var _proto = TextEditorButton.prototype;
_proto._addPlaceMarker = function($container) {
this.$placeMarker = (0, _renderer.default)("<div>").appendTo($container)
};
_proto._addToContainer = function($element) {
const {
$placeMarker: $placeMarker,
$container: $container
} = this;
$placeMarker ? $placeMarker.replaceWith($element) : $element.appendTo($container)
};
_proto._attachEvents = function() {
throw "Not implemented"
};
_proto._create = function() {
throw "Not implemented"
};
_proto._isRendered = function() {
return !!this.instance
};
_proto._isVisible = function() {
const {
editor: editor,
options: options
} = this;
return options.visible || !editor.option("readOnly")
};
_proto._isDisabled = function() {
throw "Not implemented"
};
_proto._shouldRender = function() {
return this._isVisible() && !this._isRendered()
};
_proto.dispose = function() {
const {
instance: instance,
$placeMarker: $placeMarker
} = this;
if (instance) {
instance.dispose ? instance.dispose() : instance.remove();
this.instance = null
}
$placeMarker && $placeMarker.remove()
};
_proto.render = function() {
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)
}
};
_proto.update = function() {
if (this._shouldRender()) {
this.render()
}
return !!this.instance
};
return TextEditorButton
}();
exports.default = TextEditorButton;
module.exports = exports.default;
module.exports.default = exports.default;