From e28295d9bf2622b5292557e0935b71b03f537647 Mon Sep 17 00:00:00 2001 From: Alan Date: Tue, 18 Jan 2022 11:56:50 +0800 Subject: [PATCH] fix dialog on htmleditor link --- Roo/form/HtmlEditor/ToolbarStandard.js | 42 ++++++++++++++---- ...oo_form_HtmlEditor_ToolbarStandard.js.html | 2 +- roojs-all.js | 11 ++--- roojs-debug.js | 44 +++++++++++++++---- roojs-ui-debug.js | 44 +++++++++++++++---- roojs-ui.js | 11 ++--- 6 files changed, 117 insertions(+), 37 deletions(-) diff --git a/Roo/form/HtmlEditor/ToolbarStandard.js b/Roo/form/HtmlEditor/ToolbarStandard.js index d054fab06b..b58a4cfc93 100644 --- a/Roo/form/HtmlEditor/ToolbarStandard.js +++ b/Roo/form/HtmlEditor/ToolbarStandard.js @@ -526,15 +526,41 @@ Roo.form.HtmlEditor.ToolbarStandard.prototype = { createLink : function(){ //Roo.log("create link?"); var ec = this.editorcore; - (function() { - Roo.MessageBox.prompt("Add Link URL",this.createLinkText, function(btn, url) { - if (btn != 'ok') { - return; - } - if(url && url != 'http:/'+'/'){ - ec.relayCmd('createlink', url); - } + var ar = ec.getAllAncestors(); + var n = false; + for(var i = 0;i< ar.length;i++) { + if (ar[i] && ar[i].nodeName == 'A') { + n = ar[i]; + break; + } + } + + (function() { + + Roo.MessageBox.show({ + title : "Add / Edit Link URL", + msg : "Enter the url for the link", + buttons: Roo.MessageBox.OKCANCEL, + fn: function(btn, url){ + if (btn != 'ok') { + return; + } + if(url && url != 'http:/'+'/'){ + if (n) { + n.setAttribute('href', url); + } else { + ec.relayCmd('createlink', url); + } + } + }, + minWidth:250, + prompt:true, + //multiline: multiline, + modal : true, + value : n ? n.getAttribute('href') : '' }); + + }).defer(100, this); // we have to defer this , otherwise the mouse click gives focus to the main window. }, diff --git a/docs/src/Roo_form_HtmlEditor_ToolbarStandard.js.html b/docs/src/Roo_form_HtmlEditor_ToolbarStandard.js.html index efd183dbee..9820f06393 100644 --- a/docs/src/Roo_form_HtmlEditor_ToolbarStandard.js.html +++ b/docs/src/Roo_form_HtmlEditor_ToolbarStandard.js.html @@ -535,7 +535,7 @@ ec.relayCmd('createlink', url); } }); - }).defer(100, this); // we have to defer this , otherwise the mouse click gives focus to the main window. + }).defer(100, this); // we have to defer this , otherwise the mouse click gives focus to the main window. }, diff --git a/roojs-all.js b/roojs-all.js index 9c06bd59b0..06fdfdb209 100644 --- a/roojs-all.js +++ b/roojs-all.js @@ -2153,11 +2153,12 @@ F.menu.items.push({actiontype:'word',html:'Remove MS Word Formating',handler:fun );F.menu.items.push({actiontype:'tidy',html:'Tidy HTML Source',handler:function(a,b){new Roo.htmleditor.Tidy(B.doc.body);B.syncValue();},tabIndex:-1});tb.add(F);}if(!this.disable.specialElements){var G={text:"Other;",cls:'x-edit-none',menu:{items:[]}};for(var i=0; i':'>'),ff,''); }return A.join('');},toggleSourceEdit:function(A){Roo.log("toolbar toogle");if(A===undefined){A=!this.sourceEditMode;}this.sourceEditMode=A===true;var B=this.tb.items.get(this.editorcore.frameId+'-sourceedit');if(B.pressed!==this.sourceEditMode){B.toggle(this.sourceEditMode); return;}if(A){Roo.log("disabling buttons");this.tb.items.each(function(C){if(C.cmd!='sourceedit'&&(typeof(C.cls)!='undefined'&&C.cls.indexOf('x-init-enable')===-1)){C.disable();}});}else{Roo.log("enabling buttons");if(this.editorcore.initialized){this.tb.items.each(function(C){C.enable(); diff --git a/roojs-debug.js b/roojs-debug.js index 237ac4084a..c60ac8583d 100644 --- a/roojs-debug.js +++ b/roojs-debug.js @@ -52218,16 +52218,42 @@ Roo.form.HtmlEditor.ToolbarStandard.prototype = { createLink : function(){ //Roo.log("create link?"); var ec = this.editorcore; - (function() { - Roo.MessageBox.prompt("Add Link URL",this.createLinkText, function(btn, url) { - if (btn != 'ok') { - return; - } - if(url && url != 'http:/'+'/'){ - ec.relayCmd('createlink', url); - } + var ar = ec.getAllAncestors(); + var n = false; + for(var i = 0;i< ar.length;i++) { + if (ar[i] && ar[i].nodeName == 'A') { + n = ar[i]; + break; + } + } + + (function() { + + Roo.MessageBox.show({ + title : "Add / Edit Link URL", + msg : "Enter the url for the link", + buttons: Roo.MessageBox.OKCANCEL, + fn: function(btn, url){ + if (btn != 'ok') { + return; + } + if(url && url != 'http:/'+'/'){ + if (n) { + n.setAttribute('href', url); + } else { + ec.relayCmd('createlink', url); + } + } + }, + minWidth:250, + prompt:true, + //multiline: multiline, + modal : true, + value : n ? n.getAttribute('href') : '' }); - }).defer(100, this); // we have to defer this , otherwise the mouse click gives focus to the main window. + + + }).defer(100, this); // we have to defer this , otherwise the mouse click gives focus to the main window. }, diff --git a/roojs-ui-debug.js b/roojs-ui-debug.js index eccdb83658..f1c5c749ef 100644 --- a/roojs-ui-debug.js +++ b/roojs-ui-debug.js @@ -27749,16 +27749,42 @@ Roo.form.HtmlEditor.ToolbarStandard.prototype = { createLink : function(){ //Roo.log("create link?"); var ec = this.editorcore; - (function() { - Roo.MessageBox.prompt("Add Link URL",this.createLinkText, function(btn, url) { - if (btn != 'ok') { - return; - } - if(url && url != 'http:/'+'/'){ - ec.relayCmd('createlink', url); - } + var ar = ec.getAllAncestors(); + var n = false; + for(var i = 0;i< ar.length;i++) { + if (ar[i] && ar[i].nodeName == 'A') { + n = ar[i]; + break; + } + } + + (function() { + + Roo.MessageBox.show({ + title : "Add / Edit Link URL", + msg : "Enter the url for the link", + buttons: Roo.MessageBox.OKCANCEL, + fn: function(btn, url){ + if (btn != 'ok') { + return; + } + if(url && url != 'http:/'+'/'){ + if (n) { + n.setAttribute('href', url); + } else { + ec.relayCmd('createlink', url); + } + } + }, + minWidth:250, + prompt:true, + //multiline: multiline, + modal : true, + value : n ? n.getAttribute('href') : '' }); - }).defer(100, this); // we have to defer this , otherwise the mouse click gives focus to the main window. + + + }).defer(100, this); // we have to defer this , otherwise the mouse click gives focus to the main window. }, diff --git a/roojs-ui.js b/roojs-ui.js index 00c3638556..6a5f14027a 100644 --- a/roojs-ui.js +++ b/roojs-ui.js @@ -1208,11 +1208,12 @@ F.menu.items.push({actiontype:'word',html:'Remove MS Word Formating',handler:fun );F.menu.items.push({actiontype:'tidy',html:'Tidy HTML Source',handler:function(a,b){new Roo.htmleditor.Tidy(B.doc.body);B.syncValue();},tabIndex:-1});tb.add(F);}if(!this.disable.specialElements){var G={text:"Other;",cls:'x-edit-none',menu:{items:[]}};for(var i=0; i':'>'),ff,''); }return A.join('');},toggleSourceEdit:function(A){Roo.log("toolbar toogle");if(A===undefined){A=!this.sourceEditMode;}this.sourceEditMode=A===true;var B=this.tb.items.get(this.editorcore.frameId+'-sourceedit');if(B.pressed!==this.sourceEditMode){B.toggle(this.sourceEditMode); return;}if(A){Roo.log("disabling buttons");this.tb.items.each(function(C){if(C.cmd!='sourceedit'&&(typeof(C.cls)!='undefined'&&C.cls.indexOf('x-init-enable')===-1)){C.disable();}});}else{Roo.log("enabling buttons");if(this.editorcore.initialized){this.tb.items.each(function(C){C.enable(); -- 2.39.2