mirror of
https://github.com/Ionaru/easy-markdown-editor
synced 2025-07-02 23:54:28 -06:00
fix #183 : refresh cursor position on activity
This commit is contained in:
parent
228fe91a72
commit
24d4cc87af
@ -2372,11 +2372,12 @@ EasyMDE.prototype.createStatusbar = function (status) {
|
|||||||
|
|
||||||
// Set up the built-in items
|
// Set up the built-in items
|
||||||
var items = [];
|
var items = [];
|
||||||
var i, onUpdate, defaultValue;
|
var i, onUpdate, onActivity, defaultValue;
|
||||||
|
|
||||||
for (i = 0; i < status.length; i++) {
|
for (i = 0; i < status.length; i++) {
|
||||||
// Reset some values
|
// Reset some values
|
||||||
onUpdate = undefined;
|
onUpdate = undefined;
|
||||||
|
onActivity = undefined;
|
||||||
defaultValue = undefined;
|
defaultValue = undefined;
|
||||||
|
|
||||||
|
|
||||||
@ -2386,6 +2387,7 @@ EasyMDE.prototype.createStatusbar = function (status) {
|
|||||||
className: status[i].className,
|
className: status[i].className,
|
||||||
defaultValue: status[i].defaultValue,
|
defaultValue: status[i].defaultValue,
|
||||||
onUpdate: status[i].onUpdate,
|
onUpdate: status[i].onUpdate,
|
||||||
|
onActivity: status[i].onActivity,
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
var name = status[i];
|
var name = status[i];
|
||||||
@ -2408,7 +2410,7 @@ EasyMDE.prototype.createStatusbar = function (status) {
|
|||||||
defaultValue = function (el) {
|
defaultValue = function (el) {
|
||||||
el.innerHTML = '0:0';
|
el.innerHTML = '0:0';
|
||||||
};
|
};
|
||||||
onUpdate = function (el) {
|
onActivity = function (el) {
|
||||||
var pos = cm.getCursor();
|
var pos = cm.getCursor();
|
||||||
el.innerHTML = pos.line + ':' + pos.ch;
|
el.innerHTML = pos.line + ':' + pos.ch;
|
||||||
};
|
};
|
||||||
@ -2428,6 +2430,7 @@ EasyMDE.prototype.createStatusbar = function (status) {
|
|||||||
className: name,
|
className: name,
|
||||||
defaultValue: defaultValue,
|
defaultValue: defaultValue,
|
||||||
onUpdate: onUpdate,
|
onUpdate: onUpdate,
|
||||||
|
onActivity: onActivity,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2464,6 +2467,14 @@ EasyMDE.prototype.createStatusbar = function (status) {
|
|||||||
};
|
};
|
||||||
}(el, item)));
|
}(el, item)));
|
||||||
}
|
}
|
||||||
|
if (typeof item.onActivity === 'function') {
|
||||||
|
// Create a closure around the span of the current action, then execute the onActivity handler
|
||||||
|
this.codemirror.on('cursorActivity', (function (el, item) {
|
||||||
|
return function () {
|
||||||
|
item.onActivity(el);
|
||||||
|
};
|
||||||
|
}(el, item)));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Append the item to the status bar
|
// Append the item to the status bar
|
||||||
|
Loading…
x
Reference in New Issue
Block a user