From 8360fa1064d364309bd83eb95e0bedd1dbd6f328 Mon Sep 17 00:00:00 2001 From: Alan Date: Thu, 16 Feb 2023 17:02:22 +0800 Subject: [PATCH] roojs-bootstrap.js roojs-bootstrap-debug.js --- roojs-bootstrap-debug.js | 4 +++- roojs-bootstrap.js | 37 ++++++++++++++++++++----------------- 2 files changed, 23 insertions(+), 18 deletions(-) diff --git a/roojs-bootstrap-debug.js b/roojs-bootstrap-debug.js index 705de4713d..7d30cd8757 100644 --- a/roojs-bootstrap-debug.js +++ b/roojs-bootstrap-debug.js @@ -33008,7 +33008,9 @@ Roo.extend(Roo.bootstrap.form.HtmlEditorToolbar.Standard, Roo.bootstrap.nav.Simp btn('align-left', 'justifyleft',true); btn('align-center', 'justifycenter',true); btn('align-right' , 'justifyright',true); - btn('link', false, true, function(btn) { + btn('link', false, true, this.onLinkClick); + + function(btn) { var url = this.selectedNode && this.selectedNode.tagName.toUpperCase() == 'A' ? this.selectedNode.getAttribute('href') : ''; diff --git a/roojs-bootstrap.js b/roojs-bootstrap.js index 0ca3e9a276..d0a811cfde 100644 --- a/roojs-bootstrap.js +++ b/roojs-bootstrap.js @@ -1414,23 +1414,26 @@ this.wrap.remove();}},onFirstFocus:function(){this.editorcore.onFirstFocus();for // Roo/bootstrap/form/HtmlEditorToolbar/Standard.js Roo.bootstrap.form.HtmlEditorToolbar.Standard=function(A){Roo.apply(this,A);this.disable=this.disable||{};Roo.applyIf(this.disable,{fontSize:true,colors:true,specialElements:true});Roo.bootstrap.form.HtmlEditorToolbar.Standard.superclass.constructor.call(this,A); -this.editor=A.editor;this.editorcore=A.editor.editorcore;this.buttons=new Roo.util.MixedCollection(false,function(o){return o.btnid;});};Roo.extend(Roo.bootstrap.form.HtmlEditorToolbar.Standard,Roo.bootstrap.nav.Simplebar,{bar:true,editor:false,editorcore:false,formats:["p","h1","h2","h3","h4","h5","h6","pre","code","abbr","acronym","address","cite","samp","var",'div','span'],deleteBtn:false,onRender:function(ct,A){Roo.bootstrap.form.HtmlEditorToolbar.Standard.superclass.onRender.call(this,ct,A); -Roo.log(this.el);this.el.dom.style.marginBottom='0';var B=this;var C=this.editorcore;var D=this.editor;var E=[];var F=function(id,G,H,I,J){var K=H?'toggle':'click';var a={size:'sm',xtype:'Button',xns:Roo.bootstrap,btnid:id,fa:id,cmd:G,enableToggle:H!==false,html:J||'',pressed:H?false:null,listeners:{} -};a.listeners[H?'toggle':'click']=function(){I?I.call(B,this):B.onBtnClick.call(B,G||id);};E.push(a);return a;};var style={xtype:'Button',size:'sm',xns:Roo.bootstrap,fa:'font',menu:{xtype:'Menu',xns:Roo.bootstrap,items:[]}};Roo.each(this.formats,function(f){style.menu.items.push({xtype:'MenuItem',xns:Roo.bootstrap,html:'<'+f+' style="margin:2px">'+f+'',tagname:f,listeners:{click:function(){C.insertTag(this.tagname); -D.focus();}}});});E.push(style);F('bold',false,true);F('italic',false,true);F('align-left','justifyleft',true);F('align-center','justifycenter',true);F('align-right','justifyright',true);F('link',false,true,function(G){var H=this.selectedNode&&this.selectedNode.tagName.toUpperCase()=='A'?this.selectedNode.getAttribute('href'):''; -Roo.bootstrap.MessageBox.show({title:"Add / Edit Link URL",msg:"Enter the URL for the link",buttons:Roo.bootstrap.MessageBox.OKCANCEL,minWidth:250,scope:this,prompt:true,multiline:false,modal:true,value:H,fn:function(I,J){if(I!='ok'){return;}if(H!=''){this.selectedNode.setAttribute('href',J); -return;}if(J&&J.match(/http(s):\/\/.+/)){this.editorcore.relayCmd('createlink',J);}}});});F('image',false,true,function(){});F('list','insertunorderedlist',true);F('list-ol','insertorderedlist',true);F('pencil',false,true,function(G){Roo.log(this);this.toggleSourceEdit(G.pressed); -});if(this.editor.btns.length>0){for(var i=0;i0?db.className+' ':'')+' roo-ed-selection';B=this.selectedNode=db;}}var tn=B&&B.tagName.toUpperCase()||'';if(!H&&B&&tn!='A'){var I=B.closest('A'); -if(I){B=I;}}C.get('link').setActive(tn=='A'&&this.selectedNode.hasAttribute('href'));Roo.bootstrap.menu.Manager.hideAll();if(E||(tn.length&&tn=='BODY')){this.deleteBtn.hide();return;}this.deleteBtn.show();},onFirstFocus:function(){this.buttons.each(function(A){A.enable(); -});},onDelete:function(){var A=this.editorcore.createRange();var B=this.editorcore.getSelection();var sn=this.selectedNode;A.setStart(sn,0);A.setEnd(sn,0);if(sn.hasAttribute('data-block')){var C=Roo.htmleditor.Block.factory(this.selectedNode);if(C){sn=C.removeNode(); -sn.parentNode.removeChild(sn);B.removeAllRanges();B.addRange(A);this.updateToolbar(null,null,null);this.editorcore.fireEditorEvent(false);return;}}if(!sn){return;}if(sn&&sn.tagName=='BODY'){return;}var D=sn.childNodes[0]||sn.nextSibling||sn.previousSibling||sn.parentNode; -a=new Roo.htmleditor.FilterKeepChildren({tag:false});a.replaceTag(sn);B.removeAllRanges();B.addRange(A);this.editorcore.fireEditorEvent(false);},toggleSourceEdit:function(A){if(A){Roo.log("disabling buttons");this.buttons.each(function(B){if(B.cmd!='pencil'){B.disable(); -}});}else{Roo.log("enabling buttons");if(this.editorcore.initialized){this.buttons.each(function(B){B.enable();});}}Roo.log("calling toggole on editor");this.editor.toggleSourceEdit(A);}}); +this.editor=A.editor;this.editorcore=A.editor.editorcore;this.buttons=new Roo.util.MixedCollection(false,function(o){return o.btnid;});};Roo.extend(Roo.bootstrap.form.HtmlEditorToolbar.Standard,Roo.bootstrap.nav.Simplebar,{bar:true,editor:false,editorcore:false,formats:["p","h1","h2","h3","h4","h5","h6","pre","code","abbr","acronym","address","cite","samp","var",'div','span'],deleteBtn:false,onRender:function(ct,position){Roo.bootstrap.form.HtmlEditorToolbar.Standard.superclass.onRender.call(this,ct,position); +Roo.log(this.el);this.el.dom.style.marginBottom='0';var _this=this;var editorcore=this.editorcore;var editor=this.editor;var children=[];var btn=function(id,cmd,toggle,handler,html){var event=toggle?'toggle':'click';var a={size:'sm',xtype:'Button',xns:Roo.bootstrap,btnid:id,fa:id,cmd:cmd,enableToggle:toggle!==false,html:html||'',pressed:toggle?false:null,listeners:{} +};a.listeners[toggle?'toggle':'click']=function(){handler?handler.call(_this,this):_this.onBtnClick.call(_this,cmd||id);};children.push(a);return a;};var style={xtype:'Button',size:'sm',xns:Roo.bootstrap,fa:'font',menu:{xtype:'Menu',xns:Roo.bootstrap,items:[]} +};Roo.each(this.formats,function(f){style.menu.items.push({xtype:'MenuItem',xns:Roo.bootstrap,html:'<'+f+' style="margin:2px">'+f+'',tagname:f,listeners:{click:function(){editorcore.insertTag(this.tagname);editor.focus();}}});});children.push(style); +btn('bold',false,true);btn('italic',false,true);btn('align-left','justifyleft',true);btn('align-center','justifycenter',true);btn('align-right','justifyright',true);btn('link',false,true,this.onLinkClick);function(btn){var url=this.selectedNode&&this.selectedNode.tagName.toUpperCase()=='A'?this.selectedNode.getAttribute('href'):''; +Roo.bootstrap.MessageBox.show({title:"Add / Edit Link URL",msg:"Enter the URL for the link",buttons:Roo.bootstrap.MessageBox.OKCANCEL,minWidth:250,scope:this,prompt:true,multiline:false,modal:true,value:url,fn:function(pressed,newurl){if(pressed!='ok'){return; +}if(url!=''){this.selectedNode.setAttribute('href',newurl);return;}if(newurl&&newurl.match(/http(s):\/\/.+/)){this.editorcore.relayCmd('createlink',newurl);}}});});btn('image',false,true,function(){});btn('list','insertunorderedlist',true);btn('list-ol','insertorderedlist',true); +btn('pencil',false,true,function(A){Roo.log(this);this.toggleSourceEdit(A.pressed);});if(this.editor.btns.length>0){for(var i=0;i0?db.className+' ':'')+' roo-ed-selection';sel=this.selectedNode=db;}}var tn=sel&&sel.tagName.toUpperCase()||'';if(!block&&sel&&tn!='A'){var asel=sel.closest('A'); +if(asel){sel=asel;}}btns.get('link').setActive(tn=='A'&&this.selectedNode.hasAttribute('href'));Roo.bootstrap.menu.Manager.hideAll();if(hasToggle||(tn.length&&tn=='BODY')){this.deleteBtn.hide();return;}this.deleteBtn.show();},onFirstFocus:function(){this.buttons.each(function(item){item.enable(); +});},onDelete:function(){var range=this.editorcore.createRange();var selection=this.editorcore.getSelection();var sn=this.selectedNode;range.setStart(sn,0);range.setEnd(sn,0);if(sn.hasAttribute('data-block')){var block=Roo.htmleditor.Block.factory(this.selectedNode); +if(block){sn=block.removeNode();sn.parentNode.removeChild(sn);selection.removeAllRanges();selection.addRange(range);this.updateToolbar(null,null,null);this.editorcore.fireEditorEvent(false);return;}}if(!sn){return;}if(sn&&sn.tagName=='BODY'){return;}var stn=sn.childNodes[0]||sn.nextSibling||sn.previousSibling||sn.parentNode; +a=new Roo.htmleditor.FilterKeepChildren({tag:false});a.replaceTag(sn);selection.removeAllRanges();selection.addRange(range);this.editorcore.fireEditorEvent(false);},toggleSourceEdit:function(sourceEditMode){if(sourceEditMode){Roo.log("disabling buttons"); +this.buttons.each(function(item){if(item.cmd!='pencil'){item.disable();}});}else{Roo.log("enabling buttons");if(this.editorcore.initialized){this.buttons.each(function(item){item.enable();});}}Roo.log("calling toggole on editor");this.editor.toggleSourceEdit(sourceEditMode); +}}); // Roo/bootstrap/form/HtmlEditorToolbar/Context.js Roo.bootstrap.form.HtmlEditorToolbar.Context=function(A){Roo.apply(this,A);Roo.bootstrap.form.HtmlEditorToolbar.Context.superclass.constructor.call(this,A);this.editor=A.editor;this.editorcore=A.editor.editorcore;this.buttons=new Roo.util.MixedCollection(false,function(o){return o.cmd; });};Roo.bootstrap.form.HtmlEditorToolbar.Context.types={'IMG':[{name:'width',title:"Width",width:40},{name:'height',title:"Height",width:40},{name:'align',title:"Align",opts:[[""],["left"],["right"],["center"],["top"]],width:80},{name:'border',title:"Border",width:40} -- 2.39.2