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
|
// Set up the built-in items
|
||||||
var items = [];
|
var items = [];
|
||||||
var i, onUpdate, defaultValue, dataSet;
|
var i, onUpdate, onCursorActivity, defaultValue, dataSet;
|
||||||
|
|
||||||
for (i = 0; i < status.length; i++) {
|
for (i = 0; i < status.length; i++) {
|
||||||
// Reset some values
|
// Reset some values
|
||||||
onUpdate = undefined;
|
onUpdate = undefined;
|
||||||
|
onCursorActivity = undefined;
|
||||||
defaultValue = undefined;
|
defaultValue = undefined;
|
||||||
dataSet = undefined;
|
dataSet = undefined;
|
||||||
|
|
||||||
@ -2394,6 +2395,7 @@ EasyMDE.prototype.createStatusbar = function (status) {
|
|||||||
dataSet: status[i].dataSet,
|
dataSet: status[i].dataSet,
|
||||||
defaultValue: status[i].defaultValue,
|
defaultValue: status[i].defaultValue,
|
||||||
onUpdate: status[i].onUpdate,
|
onUpdate: status[i].onUpdate,
|
||||||
|
onCursorActivity: status[i].onCursorActivity,
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
var name = status[i];
|
var name = status[i];
|
||||||
@ -2424,6 +2426,11 @@ EasyMDE.prototype.createStatusbar = function (status) {
|
|||||||
var pos = cm.getCursor();
|
var pos = cm.getCursor();
|
||||||
el.innerHTML = pos.line + ':' + pos.ch;
|
el.innerHTML = pos.line + ':' + pos.ch;
|
||||||
};
|
};
|
||||||
|
onCursorActivity = function (el) {
|
||||||
|
var pos = cm.getCursor();
|
||||||
|
|
||||||
|
el.innerHTML = pos.line + ':' + pos.ch;
|
||||||
|
};
|
||||||
} else if (name === 'autosave') {
|
} else if (name === 'autosave') {
|
||||||
defaultValue = function (el) {
|
defaultValue = function (el) {
|
||||||
if (options.autosave != undefined && options.autosave.enabled === true) {
|
if (options.autosave != undefined && options.autosave.enabled === true) {
|
||||||
@ -2482,6 +2489,16 @@ EasyMDE.prototype.createStatusbar = function (status) {
|
|||||||
}(el, item)));
|
}(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
|
// Append the item to the status bar
|
||||||
bar.appendChild(el);
|
bar.appendChild(el);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user