2
0
mirror of https://github.com/Ionaru/easy-markdown-editor synced 2025-07-18 15:34:28 -06:00

Merge pull request #184 from firm1/fix_183

Fix refresh display cursor position
This commit is contained in:
Jeroen Akkerman 2020-04-20 15:12:49 +02:00 committed by GitHub
commit b1d29c491f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 3 deletions

View File

@ -4,7 +4,10 @@ All notable changes to easymde will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
<!--## [Unreleased]-->
## [Unreleased]
### Fixed
- Fix cursor displayed position on activity ([#183]).
## [2.10.1] - 2020-04-06
### Fixed
- Typescript error when entering certain strings for toolbar buttons ([#178]).

View File

@ -2372,11 +2372,12 @@ EasyMDE.prototype.createStatusbar = function (status) {
// Set up the built-in items
var items = [];
var i, onUpdate, defaultValue;
var i, onUpdate, onActivity, defaultValue;
for (i = 0; i < status.length; i++) {
// Reset some values
onUpdate = undefined;
onActivity = undefined;
defaultValue = undefined;
@ -2386,6 +2387,7 @@ EasyMDE.prototype.createStatusbar = function (status) {
className: status[i].className,
defaultValue: status[i].defaultValue,
onUpdate: status[i].onUpdate,
onActivity: status[i].onActivity,
});
} else {
var name = status[i];
@ -2408,7 +2410,7 @@ EasyMDE.prototype.createStatusbar = function (status) {
defaultValue = function (el) {
el.innerHTML = '0:0';
};
onUpdate = function (el) {
onActivity = function (el) {
var pos = cm.getCursor();
el.innerHTML = pos.line + ':' + pos.ch;
};
@ -2428,6 +2430,7 @@ EasyMDE.prototype.createStatusbar = function (status) {
className: name,
defaultValue: defaultValue,
onUpdate: onUpdate,
onActivity: onActivity,
});
}
}
@ -2464,6 +2467,14 @@ EasyMDE.prototype.createStatusbar = function (status) {
};
}(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