Skip to content
Browse files

Fixed bug that caused previewers not to update while typing

  • Loading branch information...
1 parent 9d7e341 commit 34b9a958935be5996d7667274ac2ae6b98241817 @LeaVerou committed
Showing with 25 additions and 25 deletions.
  1. +25 −25 code/editor.js
View
50 code/editor.js
@@ -289,6 +289,31 @@ var _ = window.Editor = function(pre) {
return;
}
+ // Show a previewer, if needed
+ if(self.Previewer) {
+ var selection = getSelection();
+
+ if(selection.rangeCount) {
+ var range = selection.getRangeAt(0),
+ element = range.startContainer;
+
+ if(element.nodeType == 3) {
+ element = element.parentNode;
+ }
+
+ var type = Previewer.get(element);
+
+ if(type) {
+ Previewer.active = element;
+ Previewer.s[type].token = element;
+ }
+ else {
+ Previewer.hideAll();
+ Previewer.active = null;
+ }
+ }
+ }
+
if(keyCode !== 37 && keyCode !== 39) {
var ss = this.selectionStart,
se = this.selectionEnd;
@@ -409,31 +434,6 @@ var _ = window.Editor = function(pre) {
highlighter.setAttribute('data-line', line + 1);
highlighter.style.height = lineHeight + 'px';
highlighter.style.top = line * lineHeight + 'px';
-
- // Show a previewer, if needed
- if(self.Previewer) {
- var selection = getSelection();
-
- if(selection.rangeCount) {
- var range = selection.getRangeAt(0),
- element = range.startContainer;
-
- if(element.nodeType == 3) {
- element = element.parentNode;
- }
-
- var type = Previewer.get(element);
-
- if(type) {
- Previewer.active = element;
- Previewer.s[type].token = element;
- }
- else {
- Previewer.hideAll();
- Previewer.active = null;
- }
- }
- }
});
$u.event.fire(this.pre, 'caretmove');

0 comments on commit 34b9a95

Please sign in to comment.
Something went wrong with that request. Please try again.