X-Git-Url: http://git.roojs.org/?p=roojs1;a=blobdiff_plain;f=roojs-bootstrap-debug.js;h=e93cd47f191a6e01a0df017d3a85b8ae24ef10ae;hp=5dc0d1d1d9096eeb8075d3be2c8a6bedffef9607;hb=135ac93bf938512823e8371385e746a9587ed92e;hpb=f84ec43831366737bda95be1bfb0e41aed92d03b diff --git a/roojs-bootstrap-debug.js b/roojs-bootstrap-debug.js index 5dc0d1d1d9..e93cd47f19 100644 --- a/roojs-bootstrap-debug.js +++ b/roojs-bootstrap-debug.js @@ -26025,7 +26025,7 @@ Roo.htmleditor.Filter.prototype = { Roo.each( Array.from(dom.childNodes), function( e ) { switch(true) { - case e.nodeType == 8 && typeof(this.replaceComment) != 'undefined': // comment + case e.nodeType == 8 && this.replaceComment !== false: // comment this.replaceComment(e); return; @@ -26225,7 +26225,7 @@ Roo.extend(Roo.htmleditor.FilterBlack, Roo.htmleditor.Filter, { tag : true, // all elements. - replace : function(n) + replaceTag : function(n) { n.parentNode.removeChild(n); } @@ -27002,6 +27002,9 @@ Roo.extend(Roo.htmleditor.BlockFigure, Roo.htmleditor.Block, { caption : '', caption_display : 'block', width : '100%', + cls : '', + href: '', + video_url : '', // margin: '2%', not used @@ -27033,24 +27036,86 @@ Roo.extend(Roo.htmleditor.BlockFigure, Roo.htmleditor.Block, { xns : rooui.Toolbar //Boostrap? }, { - xtype : 'TextField', - allowBlank : false, - width : 150, - name : 'image_src', + xtype : 'Button', + text: 'Change Image URL', + listeners : { - keyup : function (combo, e) - { - toolbar.editorcore.selectNode(toolbar.tb.selectedNode); + click: function (btn, state) + { var b = block(); - b.image_src = this.getValue(); - b.updateElement(); - syncValue(); - toolbar.editorcore.onEditorEvent(); + + Roo.MessageBox.show({ + title : "Image Source URL", + msg : "Enter the url for the image", + buttons: Roo.MessageBox.OKCANCEL, + fn: function(btn, val){ + if (btn != 'ok') { + return; + } + b.image_src = val; + b.updateElement(); + syncValue(); + toolbar.editorcore.onEditorEvent(); + }, + minWidth:250, + prompt:true, + //multiline: multiline, + modal : true, + value : b.image_src + }); } }, - xns : rooui.form - + xns : rooui.Toolbar + }, + + { + xtype : 'Button', + text: 'Change Link URL', + + listeners : { + click: function (btn, state) + { + var b = block(); + + Roo.MessageBox.show({ + title : "Link URL", + msg : "Enter the url for the link - leave blank to have no link", + buttons: Roo.MessageBox.OKCANCEL, + fn: function(btn, val){ + if (btn != 'ok') { + return; + } + b.href = val; + b.updateElement(); + syncValue(); + toolbar.editorcore.onEditorEvent(); + }, + minWidth:250, + prompt:true, + //multiline: multiline, + modal : true, + value : b.href + }); + } + }, + xns : rooui.Toolbar }, + { + xtype : 'Button', + text: 'Show Video URL', + + listeners : { + click: function (btn, state) + { + Roo.MessageBox.alert("Video URL", + block().video_url == '' ? 'This image is not linked ot a video' : + 'The image is linked to: ' + block().video_url + ''); + } + }, + xns : rooui.Toolbar + }, + + { xtype : 'TextItem', text : "Width: ", @@ -27166,6 +27231,56 @@ Roo.extend(Roo.htmleditor.BlockFigure, Roo.htmleditor.Block, { var d = document.createElement('div'); d.innerHTML = this.caption; + var m = this.width == '50%' && this.align == 'center' ? '0 auto' : 0; + + var img = { + tag : 'img', + contenteditable : 'false', + src : this.image_src, + alt : d.innerText.replace(/\n/g, " ").replace(/\s+/g, ' ').trim(), // removeHTML and reduce spaces.. + style: { + width : 'auto', + 'max-width': '100%', + margin : '0px' + + + } + }; + /* + '
' + + '' + + '' + + '' + + '
', + */ + + if (this.href.length > 0) { + img = { + tag : 'a', + href: this.href, + contenteditable : 'true', + cn : [ + img + ] + }; + } + + + if (this.video_url.length > 0) { + img = { + tag : 'div', + cls : this.cls, + frameborder : 0, + allowfullscreen : true, + width : 420, // these are for video tricks - that we replace the outer + height : 315, + src : this.video_url, + cn : [ + img + ] + }; + } + return { tag: 'figure', 'data-block' : 'Figure', @@ -27175,24 +27290,16 @@ Roo.extend(Roo.htmleditor.BlockFigure, Roo.htmleditor.Block, { float : this.align , 'max-width': this.width, width : 'auto', - margin: 0, + margin: m, padding: '10px' }, + + align : this.align, cn : [ - { - tag : 'img', - src : this.image_src, - alt : d.innerText.replace(/\n/g, " "), // removeHTML.. - style: { - width : 'auto', - 'max-width': '100%', - margin : '0px' - - - } - }, + img, + { tag: 'figcaption', contenteditable : true, @@ -27204,6 +27311,7 @@ Roo.extend(Roo.htmleditor.BlockFigure, Roo.htmleditor.Block, { 'font-style': 'italic', display : this.caption_display }, + cls : this.cls.length > 0 ? (this.cls + '-thumbnail' ) : '', html : this.caption } @@ -27214,7 +27322,13 @@ Roo.extend(Roo.htmleditor.BlockFigure, Roo.htmleditor.Block, { readElement : function(node) { + // this should not really come from the link... + this.video_url = this.getVal(node, 'div', 'src'); + this.cls = this.getVal(node, 'div', 'class'); + this.href = this.getVal(node, 'a', 'href'); + this.image_src = this.getVal(node, 'img', 'src'); + this.align = this.getVal(node, 'figure', 'align'); this.caption = this.getVal(node, 'figcaption', 'html'); //this.text_align = this.getVal(node, 'figcaption', 'style','text-align'); @@ -28671,14 +28785,16 @@ Roo.extend(Roo.HtmlEditorCore, Roo.Component, { st += ''; - - var cls = 'roo-htmleditor-body'; + + st += ''; + + var cls = 'notranslate roo-htmleditor-body'; if(this.bodyCls.length){ cls += ' ' + this.bodyCls; } - return '' + st + + return '' + st + //' + @@ -28805,7 +28921,8 @@ Roo.extend(Roo.HtmlEditorCore, Roo.Component, { * @param {String} html The HTML to be cleaned * return {String} The cleaned HTML */ - cleanHtml : function(html){ + cleanHtml : function(html) + { html = String(html); if(html.length > 5){ if(Roo.isSafari){ // strip safari nonsense @@ -28834,18 +28951,27 @@ Roo.extend(Roo.HtmlEditorCore, Roo.Component, { var bd = (this.doc.body || this.doc.documentElement); + var sel = this.win.getSelection(); var div = document.createElement('div'); div.innerHTML = bd.innerHTML; - + var gtx = div.getElementsByClassName('gtx-trans-icon'); // google translate - really annoying and difficult to get rid of. + if (gtx.length > 0) { + var rm = gtx.item(0).parentNode; + rm.parentNode.removeChild(rm); + } + if (this.enableBlocks) { new Roo.htmleditor.FilterBlock({ node : div }); } //?? tidy? + var tidy = new Roo.htmleditor.TidySerializer({ + inner: true + }); + var html = tidy.serialize(div); - var html = div.innerHTML; if(Roo.isSafari){ var bs = bd.getAttribute('style'); // Safari puts text-align styles on the body element! var m = bs ? bs.match(/text-align:(.*?);/i) : false; @@ -28984,9 +29110,11 @@ Roo.extend(Roo.HtmlEditorCore, Roo.Component, { //var ss = this.el.getStyles( 'background-image', 'background-repeat'); //ss['background-attachment'] = 'fixed'; // w3c dbody.bgProperties = 'fixed'; // ie + dbody.setAttribute("translate", "no"); + //Roo.DomHelper.applyStyles(dbody, ss); Roo.EventManager.on(this.doc, { - //'mousedown': this.onEditorEvent, + 'mouseup': this.onEditorEvent, 'dblclick': this.onEditorEvent, 'click': this.onEditorEvent, @@ -29017,7 +29145,8 @@ Roo.extend(Roo.HtmlEditorCore, Roo.Component, { this.owner.fireEvent('initialize', this); this.pushValue(); }, - + // this is to prevent a href clicks resulting in a redirect? + onPasteEvent : function(e,v) { // I think we better assume paste is going to be a dirty load of rubish from word.. @@ -29078,7 +29207,7 @@ Roo.extend(Roo.HtmlEditorCore, Roo.Component, { }); new Roo.htmleditor.FilterBlack({ node : d, tag : this.black}); // should be fonts.. - new Roo.htmleditor.FilterKeepChildren({node : d, tag : [ 'FONT' ]} ); + new Roo.htmleditor.FilterKeepChildren({node : d, tag : [ 'FONT', 'O:P' ]} ); new Roo.htmleditor.FilterParagraph({ node : d }); new Roo.htmleditor.FilterSpan({ node : d }); new Roo.htmleditor.FilterLongBr({ node : d }); @@ -29176,6 +29305,7 @@ Roo.extend(Roo.HtmlEditorCore, Roo.Component, { onEditorEvent : function(e) { + if (e && (e.ctrlKey || e.metaKey) && e.keyCode === 90) { return; // we do not handle this.. (undo manager does..) @@ -29910,7 +30040,10 @@ Roo.extend(Roo.HtmlEditorCore, Roo.Component, { updateLanguage : function() { - Roo.get(_this.ifream.content.body).attr("lang", this.language); + if (!this.iframe || !this.iframe.contentDocument) { + return; + } + Roo.get(this.iframe.contentDocument.body).attr("lang", this.language); }, @@ -30003,7 +30136,8 @@ Roo.HtmlEditorCore.black = [ 'IFRAME', 'LAYER', 'LINK', 'META', 'OBJECT', 'SCRIPT', 'STYLE' ,'TITLE', 'XML', //'FONT' // CLEAN LATER.. - 'COLGROUP', 'COL' // messy tables. + 'COLGROUP', 'COL' // messy tables. + ]; Roo.HtmlEditorCore.clean = [ // ?? needed???