fix strange behavior after inserting a substitution, #38803, fallout from #24331
authorMark Wells <mark@freeside.biz>
Thu, 10 Dec 2015 01:23:46 +0000 (17:23 -0800)
committerMark Wells <mark@freeside.biz>
Thu, 10 Dec 2015 01:24:03 +0000 (17:24 -0800)
httemplate/elements/ckeditor/plugins/blockprotect/plugin.js
httemplate/elements/htmlarea.html

index e4ef391..96c0f42 100644 (file)
                             } // span function
                           } // elements
                         });
-                }
+
+                        editor.on( 'afterInsertHtml', function( evt ) {
+                          // if this leaves an open SPAN, move the cursor
+                          // to after it
+                          var range = editor.getSelection().getRanges()[0];
+                          var ec = range.endContainer;
+                          if ( ec.hasClass('cke_blockprotect') ) {
+                            range.setEndAfter(ec);
+                            range.collapse();
+                            editor.getSelection().selectRanges([ range ]);
+                          }
+                        });
+
+                } // afterInit
         }); // plugins.add
 }) ();
 
index c98993d..0ba4177 100644 (file)
@@ -20,7 +20,8 @@ Example:
 
 <SCRIPT TYPE="text/javascript">
 
-  CKEDITOR.replace('<% $opt{'field'} %>',
+  var <% $opt{'field'} %>_editor =
+    CKEDITOR.replace('<% $opt{'field'} %>',
                    <% encode_json($config) %>
   );