mirror of
https://github.com/Ionaru/easy-markdown-editor
synced 2025-09-24 16:40:55 -06:00
Added function cursorActivity fot cursor.
Signed-off-by: Dmitry Mazurov <dimabzz@gmail.com>
This commit is contained in:
parent
126794c2c4
commit
e467bdf8f6
@ -2378,11 +2378,12 @@ EasyMDE.prototype.createStatusbar = function (status) {
|
||||
|
||||
// Set up the built-in items
|
||||
var items = [];
|
||||
var i, onUpdate, defaultValue, dataSet;
|
||||
var i, onUpdate, onCursorActivity, defaultValue, dataSet;
|
||||
|
||||
for (i = 0; i < status.length; i++) {
|
||||
// Reset some values
|
||||
onUpdate = undefined;
|
||||
onCursorActivity = undefined;
|
||||
defaultValue = undefined;
|
||||
dataSet = undefined;
|
||||
|
||||
@ -2394,6 +2395,7 @@ EasyMDE.prototype.createStatusbar = function (status) {
|
||||
dataSet: status[i].dataSet,
|
||||
defaultValue: status[i].defaultValue,
|
||||
onUpdate: status[i].onUpdate,
|
||||
onCursorActivity: status[i].onCursorActivity,
|
||||
});
|
||||
} else {
|
||||
var name = status[i];
|
||||
@ -2424,6 +2426,11 @@ EasyMDE.prototype.createStatusbar = function (status) {
|
||||
var pos = cm.getCursor();
|
||||
el.innerHTML = pos.line + ':' + pos.ch;
|
||||
};
|
||||
onCursorActivity = function (el) {
|
||||
var pos = cm.getCursor();
|
||||
|
||||
el.innerHTML = pos.line + ':' + pos.ch;
|
||||
};
|
||||
} else if (name === 'autosave') {
|
||||
defaultValue = function (el) {
|
||||
if (options.autosave != undefined && options.autosave.enabled === true) {
|
||||
@ -2482,6 +2489,16 @@ EasyMDE.prototype.createStatusbar = function (status) {
|
||||
}(el, item)));
|
||||
}
|
||||
|
||||
// Ensure the onCursorActivity is a function
|
||||
if (typeof item.onCursorActivity === 'function') {
|
||||
// Create a closure around the span of the current action, then execute the onCursorActivity handler
|
||||
this.codemirror.on('cursorActivity', (function (el, item) {
|
||||
return function () {
|
||||
item.onCursorActivity(el);
|
||||
};
|
||||
}(el, item)));
|
||||
}
|
||||
|
||||
|
||||
// Append the item to the status bar
|
||||
bar.appendChild(el);
|
||||
|
Loading…
x
Reference in New Issue
Block a user