@ -767,407 +767,6 @@ var $0d6abf40542266b3$export$2e2bcd8739ae039 = new $0d6abf40542266b3$var$EditorE
var $bba420c8ea874359$var$attributes = [
"borderBottomWidth" ,
"borderLeftWidth" ,
"borderRightWidth" ,
"borderTopStyle" ,
"borderRightStyle" ,
"borderBottomStyle" ,
"borderLeftStyle" ,
"borderTopWidth" ,
"boxSizing" ,
"fontFamily" ,
"fontSize" ,
"fontWeight" ,
"height" ,
"letterSpacing" ,
"lineHeight" ,
"marginBottom" ,
"marginLeft" ,
"marginRight" ,
"marginTop" ,
"outlineWidth" ,
"overflow" ,
"overflowX" ,
"overflowY" ,
"paddingBottom" ,
"paddingLeft" ,
"paddingRight" ,
"paddingTop" ,
"textAlign" ,
"textOverflow" ,
"textTransform" ,
"whiteSpace" ,
"wordBreak" ,
"wordWrap"
] ;
/ * *
* Create a mirror
*
* @ param { Element } element The element
* @ param { string } html The html
*
* @ return { object } The mirror object
* / v a r $ b b a 4 2 0 c 8 e a 8 7 4 3 5 9 $ v a r $ c r e a t e M i r r o r = f u n c t i o n c r e a t e M i r r o r ( e l e m e n t , h t m l ) {
/ * *
* The mirror element
* / v a r m i r r o r = d o c u m e n t . c r e a t e E l e m e n t ( " d i v " ) ;
/ * *
* Create the CSS for the mirror object
*
* @ return { object } The style object
* / v a r m i r r o r C s s = f u n c t i o n m i r r o r C s s ( ) {
var css = {
position : "absolute" ,
left : - 9999 ,
top : 0 ,
zIndex : - 2000
} ;
if ( element . tagName === "TEXTAREA" ) $bba420c8ea874359$var$attributes . push ( "width" ) ;
$bba420c8ea874359$var$attributes . forEach ( function ( attr ) {
css [ attr ] = getComputedStyle ( element ) [ attr ] ;
} ) ;
return css ;
} ;
/ * *
* Initialize the mirror
*
* @ param { string } html The html
*
* @ return { void }
* / v a r i n i t i a l i z e = f u n c t i o n i n i t i a l i z e ( h t m l ) {
var styles = mirrorCss ( ) ;
Object . keys ( styles ) . forEach ( function ( key ) {
mirror . style [ key ] = styles [ key ] ;
} ) ;
mirror . innerHTML = html ;
element . parentNode . insertBefore ( mirror , element . nextSibling ) ;
} ;
/ * *
* Get the rect
*
* @ return { Rect } The bounding rect
* / v a r r e c t = f u n c t i o n r e c t ( ) {
var marker = mirror . ownerDocument . getElementById ( "caret-position-marker" ) ;
var boundingRect = {
left : marker . offsetLeft ,
top : marker . offsetTop ,
height : marker . offsetHeight
} ;
mirror . parentNode . removeChild ( mirror ) ;
return boundingRect ;
} ;
initialize ( html ) ;
return {
rect : rect
} ;
} ;
function $bba420c8ea874359$var$ _typeof ( obj ) {
"@babel/helpers - typeof" ;
if ( typeof Symbol === "function" && typeof Symbol . iterator === "symbol" ) $bba420c8ea874359$var$ _typeof = function ( obj ) {
return typeof obj ;
} ;
else $bba420c8ea874359$var$ _typeof = function ( obj ) {
return obj && typeof Symbol === "function" && obj . constructor === Symbol && obj !== Symbol . prototype ? "symbol" : typeof obj ;
} ;
return $bba420c8ea874359$var$ _typeof ( obj ) ;
}
/ * *
* Check if a DOM Element is content editable
*
* @ param { Element } element The DOM element
*
* @ return { bool } If it is content editable
* / v a r $ b b a 4 2 0 c 8 e a 8 7 4 3 5 9 $ v a r $ i s C o n t e n t E d i t a b l e = f u n c t i o n i s C o n t e n t E d i t a b l e ( e l e m e n t ) {
return ! ! ( element . contentEditable ? element . contentEditable === "true" : element . getAttribute ( "contenteditable" ) === "true" ) ;
} ;
/ * *
* Get the context from settings passed in
*
* @ param { object } settings The settings object
*
* @ return { object } window and document
* / v a r $ b b a 4 2 0 c 8 e a 8 7 4 3 5 9 $ v a r $ g e t C o n t e x t = f u n c t i o n g e t C o n t e x t ( ) {
var settings = arguments . length > 0 && arguments [ 0 ] !== undefined ? arguments [ 0 ] : { } ;
var customPos = settings . customPos , iframe = settings . iframe , noShadowCaret = settings . noShadowCaret ;
if ( iframe ) return {
iframe : iframe ,
window : iframe . contentWindow ,
document : iframe . contentDocument || iframe . contentWindow . document ,
noShadowCaret : noShadowCaret ,
customPos : customPos
} ;
return {
window : window ,
document : document ,
noShadowCaret : noShadowCaret ,
customPos : customPos
} ;
} ;
/ * *
* Get the offset of an element
*
* @ param { Element } element The DOM element
* @ param { object } ctx The context
*
* @ return { object } top and left
* / v a r $ b b a 4 2 0 c 8 e a 8 7 4 3 5 9 $ e x p o r t $ 6 2 2 c e a 4 4 5 a 1 c 5 b 7 d = f u n c t i o n g e t O f f s e t ( e l e m e n t , c t x ) {
var win = ctx && ctx . window || window ;
var doc = ctx && ctx . document || document ;
var rect = element . getBoundingClientRect ( ) ;
var docEl = doc . documentElement ;
var scrollLeft = win . pageXOffset || docEl . scrollLeft ;
var scrollTop = win . pageYOffset || docEl . scrollTop ;
return {
top : rect . top + scrollTop ,
left : rect . left + scrollLeft
} ;
} ;
/ * *
* Check if a value is an object
*
* @ param { any } value The value to check
*
* @ return { bool } If it is an object
* / v a r $ b b a 4 2 0 c 8 e a 8 7 4 3 5 9 $ v a r $ i s O b j e c t = f u n c t i o n i s O b j e c t ( v a l u e ) {
return $bba420c8ea874359$var$ _typeof ( value ) === "object" && value !== null ;
} ;
/ * *
* Create a Input caret object .
*
* @ param { Element } element The element
* @ param { Object } ctx The context
* / v a r $ b b a 4 2 0 c 8 e a 8 7 4 3 5 9 $ v a r $ c r e a t e I n p u t C a r e t = f u n c t i o n c r e a t e I n p u t C a r e t ( e l e m e n t , c t x ) {
/ * *
* Get the current position
*
* @ returns { int } The caret position
* / v a r g e t P o s = f u n c t i o n g e t P o s ( ) {
return element . selectionStart ;
} ;
/ * *
* Set the position
*
* @ param { int } pos The position
*
* @ return { Element } The element
* / v a r s e t P o s = f u n c t i o n s e t P o s ( p o s ) {
element . setSelectionRange ( pos , pos ) ;
return element ;
} ;
/ * *
* The offset
*
* @ param { int } pos The position
*
* @ return { object } The offset
* / v a r g e t O f f s e t $ 1 = f u n c t i o n g e t O f f s e t $ 1 ( p o s ) {
var rect = $bba420c8ea874359$export$622cea445a1c5b7d ( element ) ;
var position = getPosition ( pos ) ;
return {
top : rect . top + position . top + ctx . document . body . scrollTop ,
left : rect . left + position . left + ctx . document . body . scrollLeft ,
height : position . height
} ;
} ;
/ * *
* Get the current position
*
* @ param { int } pos The position
*
* @ return { object } The position
* / v a r g e t P o s i t i o n = f u n c t i o n g e t P o s i t i o n ( p o s ) {
var format = function format ( val ) {
var value = val . replace ( /<|>|`|"|&/g , "?" ) . replace ( /\r\n|\r|\n/g , "<br/>" ) ;
return value ;
} ;
if ( ctx . customPos || ctx . customPos === 0 ) pos = ctx . customPos ;
var position = pos === undefined ? getPos ( ) : pos ;
var startRange = element . value . slice ( 0 , position ) ;
var endRange = element . value . slice ( position ) ;
var html = '<span style="position: relative; display: inline;">' . concat ( format ( startRange ) , "</span>" ) ;
html += '<span id="caret-position-marker" style="position: relative; display: inline;">|</span>' ;
html += '<span style="position: relative; display: inline;">' . concat ( format ( endRange ) , "</span>" ) ;
var mirror = $bba420c8ea874359$var$createMirror ( element , html ) ;
var rect = mirror . rect ( ) ;
rect . pos = getPos ( ) ;
return rect ;
} ;
return {
getPos : getPos ,
setPos : setPos ,
getOffset : getOffset$1 ,
getPosition : getPosition
} ;
} ;
/ * *
* Create an Editable Caret
* @ param { Element } element The editable element
* @ param { object | null } ctx The context
*
* @ return { EditableCaret }
* / v a r $ b b a 4 2 0 c 8 e a 8 7 4 3 5 9 $ v a r $ c r e a t e E d i t a b l e C a r e t = f u n c t i o n c r e a t e E d i t a b l e C a r e t ( e l e m e n t , c t x ) {
/ * *
* Set the caret position
*
* @ param { int } pos The position to se
*
* @ return { Element } The element
* / v a r s e t P o s = f u n c t i o n s e t P o s ( p o s ) {
var sel = ctx . window . getSelection ( ) ;
if ( sel ) {
var offset = 0 ;
var found = false ;
var find = function find ( position , parent ) {
for ( var i = 0 ; i < parent . childNodes . length ; i ++ ) {
var node = parent . childNodes [ i ] ;
if ( found ) break ;
if ( node . nodeType === 3 ) {
if ( offset + node . length >= position ) {
found = true ;
var range = ctx . document . createRange ( ) ;
range . setStart ( node , position - offset ) ;
sel . removeAllRanges ( ) ;
sel . addRange ( range ) ;
break ;
} else offset += node . length ;
} else find ( pos , node ) ;
}
} ;
find ( pos , element ) ;
}
return element ;
} ;
/ * *
* Get the offset
*
* @ return { object } The offset
* / v a r g e t O f f s e t = f u n c t i o n g e t O f f s e t ( ) {
var range = getRange ( ) ;
var offset = {
height : 0 ,
left : 0 ,
right : 0
} ;
if ( ! range ) return offset ;
var hasCustomPos = ctx . customPos || ctx . customPos === 0 ; // endContainer in Firefox would be the element at the start of
// the line
if ( range . endOffset - 1 > 0 && range . endContainer !== element || hasCustomPos ) {
var clonedRange = range . cloneRange ( ) ;
var fixedPosition = hasCustomPos ? ctx . customPos : range . endOffset ;
clonedRange . setStart ( range . endContainer , fixedPosition - 1 < 0 ? 0 : fixedPosition - 1 ) ;
clonedRange . setEnd ( range . endContainer , fixedPosition ) ;
var rect = clonedRange . getBoundingClientRect ( ) ;
offset = {
height : rect . height ,
left : rect . left + rect . width ,
top : rect . top
} ;
clonedRange . detach ( ) ;
}
if ( ( ! offset || offset && offset . height === 0 ) && ! ctx . noShadowCaret ) {
var _clonedRange = range . cloneRange ( ) ;
var shadowCaret = ctx . document . createTextNode ( "|" ) ;
_clonedRange . insertNode ( shadowCaret ) ;
_clonedRange . selectNode ( shadowCaret ) ;
var _rect = _clonedRange . getBoundingClientRect ( ) ;
offset = {
height : _rect . height ,
left : _rect . left ,
top : _rect . top
} ;
shadowCaret . parentNode . removeChild ( shadowCaret ) ;
_clonedRange . detach ( ) ;
}
if ( offset ) {
var doc = ctx . document . documentElement ;
offset . top += ctx . window . pageYOffset - ( doc . clientTop || 0 ) ;
offset . left += ctx . window . pageXOffset - ( doc . clientLeft || 0 ) ;
}
return offset ;
} ;
/ * *
* Get the position
*
* @ return { object } The position
* / v a r g e t P o s i t i o n = f u n c t i o n g e t P o s i t i o n ( ) {
var offset = getOffset ( ) ;
var pos = getPos ( ) ;
var rect = element . getBoundingClientRect ( ) ;
var inputOffset = {
top : rect . top + ctx . document . body . scrollTop ,
left : rect . left + ctx . document . body . scrollLeft
} ;
offset . left -= inputOffset . left ;
offset . top -= inputOffset . top ;
offset . pos = pos ;
return offset ;
} ;
/ * *
* Get the range
*
* @ return { Range | null }
* / v a r g e t R a n g e = f u n c t i o n g e t R a n g e ( ) {
if ( ! ctx . window . getSelection ) return ;
var sel = ctx . window . getSelection ( ) ;
return sel . rangeCount > 0 ? sel . getRangeAt ( 0 ) : null ;
} ;
/ * *
* Get the caret position
*
* @ return { int } The position
* / v a r g e t P o s = f u n c t i o n g e t P o s ( ) {
var range = getRange ( ) ;
var clonedRange = range . cloneRange ( ) ;
clonedRange . selectNodeContents ( element ) ;
clonedRange . setEnd ( range . endContainer , range . endOffset ) ;
var pos = clonedRange . toString ( ) . length ;
clonedRange . detach ( ) ;
return pos ;
} ;
return {
getPos : getPos ,
setPos : setPos ,
getPosition : getPosition ,
getOffset : getOffset ,
getRange : getRange
} ;
} ;
var $bba420c8ea874359$var$createCaret = function createCaret ( element , ctx ) {
if ( $bba420c8ea874359$var$isContentEditable ( element ) ) return $bba420c8ea874359$var$createEditableCaret ( element , ctx ) ;
return $bba420c8ea874359$var$createInputCaret ( element , ctx ) ;
} ;
var $bba420c8ea874359$export$5880b8b5730aff45 = function position ( element , value ) {
var settings = arguments . length > 2 && arguments [ 2 ] !== undefined ? arguments [ 2 ] : { } ;
var options = settings ;
if ( $bba420c8ea874359$var$isObject ( value ) ) {
options = value ;
value = null ;
}
var ctx = $bba420c8ea874359$var$getContext ( options ) ;
var caret = $bba420c8ea874359$var$createCaret ( element , ctx ) ;
if ( value || value === 0 ) return caret . setPos ( value ) ;
return caret . getPosition ( ) ;
} ;
/ * *
*
* @ param { Element } element The DOM element
* @ param { number | undefined } value The value to set
* @ param { object } settings Any settings for context
* / v a r $ b b a 4 2 0 c 8 e a 8 7 4 3 5 9 $ e x p o r t $ c c 8 0 0 9 2 3 e 9 9 7 b b 8 = f u n c t i o n o f f s e t ( e l e m e n t , v a l u e ) {
var settings = arguments . length > 2 && arguments [ 2 ] !== undefined ? arguments [ 2 ] : { } ;
var options = settings ;
if ( $bba420c8ea874359$var$isObject ( value ) ) {
options = value ;
value = null ;
}
var ctx = $bba420c8ea874359$var$getContext ( options ) ;
var caret = $bba420c8ea874359$var$createCaret ( element , ctx ) ;
return caret . getOffset ( value ) ;
} ;
class $68b475f2a0292491$var$EventEmitter {
//--------------------------
// constructor
@ -7824,4 +7423,4 @@ document.addEventListener("DOMContentLoaded", function() {
} , false ) ;
//# sourceMappingURL= start .js.map
//# sourceMappingURL= dash .js.map