96 lines
2.7 KiB
JavaScript
96 lines
2.7 KiB
JavaScript
import { d as _inherits, e as _createSuper, a as _classCallCheck, _ as _createClass } from '../_rollupPluginBabelHelpers-b054ecd2.js';
|
|
import HTMLMaskElement from './html-mask-element.js';
|
|
import IMask from '../core/holder.js';
|
|
import './mask-element.js';
|
|
|
|
var HTMLContenteditableMaskElement = /*#__PURE__*/function (_HTMLMaskElement) {
|
|
_inherits(HTMLContenteditableMaskElement, _HTMLMaskElement);
|
|
|
|
var _super = _createSuper(HTMLContenteditableMaskElement);
|
|
|
|
function HTMLContenteditableMaskElement() {
|
|
_classCallCheck(this, HTMLContenteditableMaskElement);
|
|
|
|
return _super.apply(this, arguments);
|
|
}
|
|
|
|
_createClass(HTMLContenteditableMaskElement, [{
|
|
key: "_unsafeSelectionStart",
|
|
get:
|
|
/**
|
|
Returns HTMLElement selection start
|
|
@override
|
|
*/
|
|
function get() {
|
|
var root = this.rootElement;
|
|
var selection = root.getSelection && root.getSelection();
|
|
var anchorOffset = selection && selection.anchorOffset;
|
|
var focusOffset = selection && selection.focusOffset;
|
|
|
|
if (focusOffset == null || anchorOffset == null || anchorOffset < focusOffset) {
|
|
return anchorOffset;
|
|
}
|
|
|
|
return focusOffset;
|
|
}
|
|
/**
|
|
Returns HTMLElement selection end
|
|
@override
|
|
*/
|
|
|
|
}, {
|
|
key: "_unsafeSelectionEnd",
|
|
get: function get() {
|
|
var root = this.rootElement;
|
|
var selection = root.getSelection && root.getSelection();
|
|
var anchorOffset = selection && selection.anchorOffset;
|
|
var focusOffset = selection && selection.focusOffset;
|
|
|
|
if (focusOffset == null || anchorOffset == null || anchorOffset > focusOffset) {
|
|
return anchorOffset;
|
|
}
|
|
|
|
return focusOffset;
|
|
}
|
|
/**
|
|
Sets HTMLElement selection
|
|
@override
|
|
*/
|
|
|
|
}, {
|
|
key: "_unsafeSelect",
|
|
value: function _unsafeSelect(start, end) {
|
|
if (!this.rootElement.createRange) return;
|
|
var range = this.rootElement.createRange();
|
|
range.setStart(this.input.firstChild || this.input, start);
|
|
range.setEnd(this.input.lastChild || this.input, end);
|
|
var root = this.rootElement;
|
|
var selection = root.getSelection && root.getSelection();
|
|
|
|
if (selection) {
|
|
selection.removeAllRanges();
|
|
selection.addRange(range);
|
|
}
|
|
}
|
|
/**
|
|
HTMLElement value
|
|
@override
|
|
*/
|
|
|
|
}, {
|
|
key: "value",
|
|
get: function get() {
|
|
// $FlowFixMe
|
|
return this.input.textContent;
|
|
},
|
|
set: function set(value) {
|
|
this.input.textContent = value;
|
|
}
|
|
}]);
|
|
|
|
return HTMLContenteditableMaskElement;
|
|
}(HTMLMaskElement);
|
|
IMask.HTMLContenteditableMaskElement = HTMLContenteditableMaskElement;
|
|
|
|
export { HTMLContenteditableMaskElement as default };
|