From 5532b7c8bd7bdcc681d491b40c3a852c39b3866b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bernd=20Ble=C3=9Fmann?= Date: Wed, 16 Feb 2022 12:13:33 +0100 Subject: [PATCH] =?utf8?q?CKEditor=20inline=5Fresize:=20Hack=20f=C3=BCr=20?= =?utf8?q?Editor=20im=20Dialog?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- js/ckeditor/plugins/inline_resize/plugin.js | 33 ++++++++++++++++++--- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/js/ckeditor/plugins/inline_resize/plugin.js b/js/ckeditor/plugins/inline_resize/plugin.js index c4481f679..eefac2e37 100644 --- a/js/ckeditor/plugins/inline_resize/plugin.js +++ b/js/ckeditor/plugins/inline_resize/plugin.js @@ -23,9 +23,23 @@ }); }; + function parentDialog(e) { + return e.getParents().filter( function(parent) { + return parent.$.classList.contains("ui-dialog-content") + })[0]; + }; + function attach( editor ) { var config = editor.config, - parent = parentScroll(editor.element); + parent = parentScroll(editor.element), + divelt = editor.element.getNext(function(elt){return elt.getAttribute("class") === "cke_textarea_inline"}), + inline = editor.element.$.classList.contains("texteditor-in-dialog"); + + var dialog; + + if (inline) { + dialog = parentDialog(divelt); + } var resize = function (width, height) { var editable; @@ -51,12 +65,22 @@ var viewRect = win.getViewPaneSize(); float_space.setStyle( 'position', 'absolute' ); - float_space.setStyle( 'top', pixelate( editorPos.y + editorRect.height - floatRect.height + 1) ); - float_space.setStyle( 'right', pixelate( viewRect.width - editorRect.right ) ); + if (inline) { + var dialogPos = dialog.getDocumentPosition(); + float_space.setStyle( 'top', pixelate( editorPos.y - dialogPos.y + editorRect.height - floatRect.height + 1 ) ); + + //float_space.setStyle( 'left', pixelate( editorPos.x - dialogPos.x + editorRect.width - floatRect.width ) ); + // floatRect.width seems to be far to high on first dialog popup + float_space.setStyle( 'left', pixelate( editorPos.x - dialogPos.x + editorRect.width - 11 ) ); + } else { + float_space.setStyle( 'top', pixelate( editorPos.y + editorRect.height - floatRect.height + 1) ); + float_space.setStyle( 'right', pixelate( viewRect.width - editorRect.right ) ); + } }; var float_html = '
\u25E2
'; // class so that csss can overrise content and style - var float_space = CKEDITOR.document.getBody().append( CKEDITOR.dom.element.createFromHtml( float_html )); + var float_space = inline ? divelt.getParent().append( CKEDITOR.dom.element.createFromHtml( float_html )) + : CKEDITOR.document.getBody().append( CKEDITOR.dom.element.createFromHtml( float_html )); var drag_handler = function( evt ) { var width = startSize.width + evt.data.$.screenX - origin.x, @@ -137,4 +161,5 @@ * ltr support * textarea/div mode safe, currently simply assumes that textarea inline is used * positioning of resize handle is not browser zomm safe + * positioning of resize handle in dialog with scroll bars is broken */ -- 2.20.1