Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

set cursor after the insert elem possible ? #206

Open
flozero opened this issue May 23, 2017 · 0 comments
Open

set cursor after the insert elem possible ? #206

flozero opened this issue May 23, 2017 · 0 comments

Comments

@flozero
Copy link

flozero commented May 23, 2017

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);`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant