var urlAPI = (window.createObjectURL && window) ||
(window.URL && URL.revokeObjectURL && URL) ||
(window.webkitURL && webkitURL);
-
- var url = urlAPI.createObjectURL( cd.files[0]);
- var d = (new DOMParser().parseFromString('<img src="' + url + '">', 'text/html')).body;
- // is insert asycn?
- if (this.enableBlocks) {
+
+ var r = new FileReader();
+ var t = this;
+ r.addEventListener('load',function()
+ {
- Array.from(d.getElementsByTagName('img')).forEach(function(img) {
- if (img.closest('figure')) { // assume!! that it's aready
- return;
- }
- var fig = new Roo.htmleditor.BlockFigure({
- image_src : img.src
- });
- fig.updateElement(img); // replace it..
+ var d = (new DOMParser().parseFromString('<img src="' + r.result+ '">', 'text/html')).body;
+ // is insert asycn?
+ if (t.enableBlocks) {
- });
- }
- this.insertAtCursor(d.innerHTML.replace(/ /g,' '));
+ Array.from(d.getElementsByTagName('img')).forEach(function(img) {
+ if (img.closest('figure')) { // assume!! that it's aready
+ return;
+ }
+ var fig = new Roo.htmleditor.BlockFigure({
+ image_src : img.src
+ });
+ fig.updateElement(img); // replace it..
+
+ });
+ }
+ t.insertAtCursor(d.innerHTML.replace(/ /g,' '));
+ t.owner.fireEvent('paste', this);
+ });
+ r.readAsDataURL(cd.files[0]);
+
e.preventDefault();
- this.owner.fireEvent('paste', this);
+
return false;
}
if (cd.types.indexOf('text/html') < 0 ) {
if (e && (e.ctrlKey || e.metaKey) && e.keyCode === 90) {
return; // we do not handle this.. (undo manager does..)
}
+ // clicking a 'block'?
+
// in theory this detects if the last element is not a br, then we try and do that.
// its so clicking in space at bottom triggers adding a br and moving the cursor.
if (e &&
break;
case 'bold':
case 'italic':
+ case 'underline':
// if there is no selection, then we insert, and set the curson inside it..
this.execCmd('styleWithCSS', false);
break;