Vlad Kurkin (b_vladi) wrote in changelog,
Vlad Kurkin
b_vladi
changelog

[livejournal] r20476: LJSUP-10299: Disappeared text after clic...

Committer: vkurkin
LJSUP-10299: Disappeared text after click button lj-cut
U   trunk/htdocs/js/ck/plugins/livejournal/plugin.js
Modified: trunk/htdocs/js/ck/plugins/livejournal/plugin.js
===================================================================
--- trunk/htdocs/js/ck/plugins/livejournal/plugin.js	2011-11-03 13:20:28 UTC (rev 20475)
+++ trunk/htdocs/js/ck/plugins/livejournal/plugin.js	2011-11-03 13:27:24 UTC (rev 20476)
@@ -623,26 +623,28 @@
 						}
 					} else {
 						if(text = prompt(top.CKLang.CutPrompt, top.CKLang.ReadMore)){
-							var selection = new CKEDITOR.dom.selection(editor.document),
-								ranges = selection.getRanges();
+							var selection = new CKEDITOR.dom.selection(editor.document);
 
-							var ljCutNode = new CKEDITOR.dom.element.get(editor.document.$.createElement('lj:cut'));
-							ljCutNode.setAttribute('lj-cmd', 'LJCut');
+							ljTagsData.LJCut.node = new CKEDITOR.dom.element.get(document.createElement('lj:cut'));
+							ljTagsData.LJCut.node.setAttribute('lj-cmd', 'LJCut');
 
 							if(text != top.CKLang.ReadMore){
-								ljCutNode.setAttribute('text', text);
+								ljTagsData.LJCut.node.setAttribute('text', text);
 							}
 
+							var ranges = selection.getRanges();
+							selection.lock();
 							for(var i = 0, l = ranges.length; i < l; i++){
 								var range = ranges[i];
-								ljCutNode.append(range.extractContents());
+								range.cloneContents().appendTo(ljTagsData.LJCut.node);
 							}
-
-							editor.insertElement(ljCutNode);
+							selection.unlock();
+							editor.insertElement(ljTagsData.LJCut.node);
+							selection.selectElement(ljTagsData.LJCut.node);
 						}
+					}
 
-						CKEDITOR.note && CKEDITOR.note.hide(true);
-					}
+					CKEDITOR.note && CKEDITOR.note.hide(true);
 				},
 				editorFocus: false
 			});

Tags: b_vladi, js, livejournal, vkurkin
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments