#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)
Change History (13)
Changed 10 years ago by
Attachment: | ckEditorBug.zip added |
---|
comment:1 Changed 10 years ago by
comment:2 Changed 10 years ago by
Keywords: | IE8 table unordered list getSelectedText removed |
---|---|
Resolution: | → invalid |
Status: | new → closed |
I got same results as in #12476. Please see comment:9 for more details.
For me this issue is also invalid.
comment:3 Changed 10 years ago by
I am able to reproduce this bug in IE9 & IE11 on Windows7 so I think it's a separate issue.
comment:4 Changed 10 years ago by
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 10 years ago by
Attachment: | ckEditor_tableBug_with_plugin.zip added |
---|
Changed 10 years ago by
Attachment: | ckEditor_tableBug_without_plugin.zip added |
---|
comment:5 Changed 10 years ago by
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:
- Open the plugin version
- Select the 'test' text within the table html tags
- Click the file manager plugin button
- Click 'Insert Link' button
- 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.
comment:7 Changed 10 years ago by
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 10 years ago by
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 10 years ago by
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
Changed 10 years ago by
Attachment: | ckeditor.zip added |
---|
replaced attachment so that files are html instead of asp. I'm only able to reproduce this issue if I use the plugin.