클립보드에서 그림 2 붙여넣기

1658 단어 그림
function doPaste(tar, event, win) {
	if (event) {
		var theClipboardData = event.clipboardData || win.clipboardData;
		if (theClipboardData) {
			var items = theClipboardData.items;
			for (var i = 0; i < items.length; ++i) {
				var item = theClipboardData.items[i];
				if (items[i].kind == 'file' && items[i].type == 'image/png') {
					var fileReader = new FileReader();
					fileReader.onloadend = function () {
						var d = this.result.substr( this.result.indexOf(',')+1);
						tar.innerHTML += ("<img src='data:image/png;base64," + d + "' />");
					};
					fileReader.readAsDataURL(item.getAsFile());
					break;
				}
			}
		}
	}
}

Ext.define('PasteAble.HtmlEditor', { 
	extend: 'Ext.form.field.HtmlEditor', 
	alias: ['widget.pahtmleditor'], 
	getDocMarkup: function() {
	    var me = this,
	        h = me.iframeEl.getHeight() - me.iframePad * 2;
	    return Ext.String.format('<html><head><style type="text/css">body{border:0;margin:0;padding:{0}px;height:{1}px;box-sizing: border-box; -moz-box-sizing: border-box; -webkit-box-sizing: border-box;cursor:text}</style><script type="text/javascript">function iframePaste(tar, e) {e = e || window.event; window.parent.doPaste(tar, e, window);}</script></head><body onpaste="iframePaste(this);"></body></html>', me.iframePad, h);
	}
}); 

좋은 웹페이지 즐겨찾기