Skip to content

Commit

Permalink
Merge pull request #12 from JetBrains/select-task
Browse files Browse the repository at this point in the history
Select task placeholder on click
  • Loading branch information
kisenka authored Apr 17, 2018
2 parents 4244cc1 + 9f79624 commit 30f016a
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/executable-code/executable-fragment.js
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,24 @@ export default class ExecutableFragment extends ExecutableCodeTemplate {

this.codemirror.on("change", codemirror => {
this.removeStyles()
})
});

/**
* Select marker's placeholder on mouse click
*/
this.codemirror.on("mousedown", (codemirror, event) => {
let position = codemirror.coordsChar({left: event.pageX, top: event.pageY});
if (position.line !== 0 || position.ch !== 0) {
let markers = codemirror.findMarksAt(position);
let todoMarker = markers.find(marker => marker.className === "taskWindow");
if (todoMarker != null) {
let markerPosition = todoMarker.find();
codemirror.setSelection(markerPosition.from, markerPosition.to);
codemirror.focus();
event.preventDefault();
}
}
});
}

destroy() {
Expand Down

0 comments on commit 30f016a

Please sign in to comment.