vxe-table-select-area
Version:
一个基于 vxe-table 的可区域选中复制、粘贴的组件
1 lines • 2.3 kB
JavaScript
;function autoResize(){function h(t,e,i){t.addEventListener(e,i,!1)}function t(t,e,i){t.removeEventListener(e,i,!1)}function o(){window.setTimeout(l,0)}function n(t,e,i){var n;d=t,(t=e)&&t.minHeight&&("inherit"==t.minHeight?a.minHeight=d.clientHeight:(n=parseInt(t.minHeight),isNaN(n)||(a.minHeight=n))),t&&t.maxHeight&&("inherit"==t.maxHeight?a.maxHeight=d.clientHeight:(n=parseInt(t.maxHeight),isNaN(n)||(a.maxHeight=n))),t&&t.minWidth&&("inherit"==t.minWidth?a.minWidth=d.clientWidth:(n=parseInt(t.minWidth),isNaN(n)||(a.minWidth=n))),t&&t.maxWidth&&("inherit"==t.maxWidth?a.maxWidth=d.clientWidth:(n=parseInt(t.maxWidth),isNaN(n)||(a.maxWidth=n))),m.firstChild||(m.className="autoResize",m.style.display="inline-block",m.appendChild(s)),"TEXTAREA"==d.nodeName&&(d.style.resize="none",d.style.overflowY="",d.style.height=a.minHeight+"px",d.style.minWidth=a.minWidth+"px",d.style.maxWidth=a.maxWidth+"px",d.style.overflowY="hidden"),i&&(h(d,"change",l),h(d,"cut",o),h(d,"paste",o),h(d,"drop",o),h(d,"keydown",o),h(d,"focus",l),h(d,"compositionstart",o),h(d,"compositionupdate",o),h(d,"compositionend",o)),l()}var d,a={minHeight:200,maxHeight:300,minWidth:100,maxWidth:300,paddingWidth:16},e=document.body,s=document.createTextNode(""),m=document.createElement("SPAN"),l=function(t){t?/^[a-zA-Z \.,\\\/\|0-9]$/.test(t)||(t="."):t="",void 0!==s.textContent?s.textContent=d.value+t:s.data=d.value+t,m.style.fontSize=i(d).fontSize,m.style.fontFamily=i(d).fontFamily,m.style.whiteSpace="pre",e.appendChild(m),t=m.clientWidth+a.paddingWidth,e.removeChild(m),d.style.height=a.minHeight+"px",a.minWidth>t?d.style.width=a.minWidth+"px":t>a.maxWidth?d.style.width=a.maxWidth+"px":d.style.width=t+"px",t=d.scrollHeight?d.scrollHeight-1:0,a.minHeight>t?d.style.height=a.minHeight+"px":a.maxHeight<t?(d.style.height=a.maxHeight+"px",d.style.overflowY="visible"):d.style.height=t+"px"};function i(t){return t.currentStyle||document.defaultView.getComputedStyle(t)}return{init:function(t,e,i){n(t,e,i)},unObserve:function(){if(!d)return!1;t(d,"change",l),t(d,"cut",o),t(d,"paste",o),t(d,"drop",o),t(d,"keydown",o),t(d,"focus",l),t(d,"compositionstart",o),t(d,"compositionupdate",o),t(d,"compositionend",o)},resize:l}}Object.defineProperty(exports,"__esModule",{value:!0}),exports.autoResize=autoResize;