Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#12518 closed Bug (invalid)

[IE8 bug] getSelectedText returning empty string when selecting text within an ordered list in a table

Reported by: ckeditorTest Owned by:
Priority: Normal Milestone:
Component: General Version: 4.4.1
Keywords: Cc:

Description

I'm trying to put an anchor tag on a list item embedded in a table. As noted in the summary this bug is happening only in IE8 for me. Works in FF & Chrome. I'm using a custom plugin to get the selected text and set the anchor.

HTML:

<table>
	<tbody>
		<tr>
			<td>
			<ul>
				<li>test1 test</li>
				<li>test2 test</li>
			</ul>
			</td>
		</tr>
	</tbody>
</table>

JS:

		var CKEDITOR = parent.window.opener.CKEDITOR;
		var editor1 = CKEDITOR.instances.editor1;
		var selection = editor1.getSelection();
		var selectedText = selection.getSelectedText();
 
 
		if (selection.getType() == CKEDITOR.SELECTION_ELEMENT) {
		  var selectedContent = selection.getSelectedElement().$.outerHTML;
		} else if (selection.getType() == CKEDITOR.SELECTION_TEXT) {
		  if (CKEDITOR.env.ie) {
		    selection.unlock(true);
		    selectedContent = selection.getNative().createRange().htmlText;
		  } else {
		    selectedContent = selection.getNative();
		  }
		}

Attachments (4)

ckEditorBug.zip (5.1 KB) - added by ckeditorTest 9 years ago.
ckEditor_tableBug_with_plugin.zip (5.2 KB) - added by ckeditorTest 9 years ago.
ckEditor_tableBug_without_plugin.zip (2.5 KB) - added by ckeditorTest 9 years ago.
ckeditor.zip (4.7 KB) - added by Jakub Ś 9 years ago.

Download all attachments as: .zip

Change History (13)

Changed 9 years ago by ckeditorTest

Attachment: ckEditorBug.zip added

comment:1 Changed 9 years ago by ckeditorTest

replaced attachment so that files are html instead of asp. I'm only able to reproduce this issue if I use the plugin.

comment:2 Changed 9 years ago by Jakub Ś

Keywords: IE8 table unordered list getSelectedText removed
Resolution: invalid
Status: newclosed

I got same results as in #12476. Please see comment:9 for more details.

For me this issue is also invalid.

comment:3 Changed 9 years ago by ckeditorTest

I am able to reproduce this bug in IE9 & IE11 on Windows7 so I think it's a separate issue.

comment:4 Changed 9 years ago by Jakub Ś

I have tested both issues and got same results. What is more the code for both bugs is the same (this one has extra plugin but it doesn't change much ).

There is one thing I can recommend: focus editor befiore getting the selection. Use editor.focus().

In standard dialogs we:

  • declare variable in init
  • set it in {{onShow}}}
  • do stuff
  • on onOk we use selection saved in variable and apply styles to it.

Since you are using custom dialog, please try focusing editor after opening it and then getting the selection.

Changed 9 years ago by ckeditorTest

Changed 9 years ago by ckeditorTest

comment:5 Changed 9 years ago by ckeditorTest

Can I reopen this issue? I think the issue is within the plugin code. I do not see the bug if I insert the link from a regular popup window. Also, the same code works if the html is NOT within a table.

I've provide 2 sets of files - one with the plugin and one without. To reproduce the issue:

  1. Open the plugin version
  2. Select the 'test' text within the table html tags
  3. Click the file manager plugin button
  4. Click 'Insert Link' button
  5. No link created

Repeat steps above, but this time select the 'test' text outside of the table tags. Link should get created. Repeat steps above with the other sample files that don't use the plugin. Link should get created in all cases.

Last edited 9 years ago by Jakub Ś (previous) (diff)

comment:6 Changed 9 years ago by ckeditorTest

I get the same results testing IE8 and IE11 on Win7.

comment:7 Changed 9 years ago by Jakub Ś

I have looked at your code but haven't checked it because you haven't tried anything I have proposed. You haven't tried to focus editor or using styles to insert links. Instead you stay with the same code and keep writing that there is an error in editor.

comment:8 Changed 9 years ago by ckeditorTest

I have tried to set the focus, but this doesn't seem to be the problem. I've also tried to get styles to insert links, but am not able to get an instance. Not sure how this would even work. I'm trying to replace selected text within a <td>. eg. replace "<td>text</td>" with "<td><a href="http://test.doc">text</a></td>" I keep getting the error "Invalid procedure call or argument" when I attempt to create an instance of the style object. Here's my code:

var CKEDITOR = parent.window.opener.CKEDITOR;
var editor1 = CKEDITOR.instances.editor1;
var selection = editor1.getSelection();
var range = selection.getRanges()[0];
var style = new CKEDITOR.style( { element: 'td', attributes: { 'class': 'foo' } } );

style.type = CKEDITOR.STYLE_INLINE;
style.applyToRange( range, editor1 );
range.select();

I go back to the question as to why this seems to be only an issue within tables for IE?

comment:9 Changed 9 years ago by Jakub Ś

I have checked your code and made some modifications but for some weird reason it was throwing JavaScript error in IE8.

One thing is for sure - I remember this problem from IE and CKEditor 3.x and the best way to fix it was focusing editor and using styles.
Taking all the above into account please see attached code with solution and a little bit different dialog.

NOTE: I have checked this with CKEditor 4.4.5

Last edited 9 years ago by Jakub Ś (previous) (diff)

Changed 9 years ago by Jakub Ś

Attachment: ckeditor.zip added
Note: See TracTickets for help on using tickets.
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy