set cursor after the insert elem possible ?
flozero opened this issue · comments
florent giraud commented
hello i am using angularjs 1.6 with components.
All is working fine but on my insert invent i would like to set the cursor after the span inserted. Because if i'm adding a class it will be add to all after because all will be in the span elem
` var article = document.getElementById('editor');
var container = article.parentNode;
var medium;
this.$onInit = function() {
setTimeout(function(){
medium = new Medium({
element: article,
mode: Medium.richMode,
placeholder: 'Your Article',
tags: null,
attributes: null
});
container.querySelector('.insert').onmousedown = function(evt) {
var child = document.createElement('span');
child.innerHTML = evt.target.attributes.data.value;
child.addEventListener("click", function(evt){
console.log(this);
this.remove();
});
medium.focus();
medium.insertHtml(child)
medium.cursor.set(this.html.text(el).length, el);
return false;
};
}, 0);`