question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Question: how to move the cursor to be the end of newly inserted tag?

See original GitHub issue

I’ve made some function to insert a special tag, but the cursor after inserting is before the tag. How to move it to the end of the new tag?

Kapture 2020-03-04 at 16 52 18

  pickup: function(e: any) {
    e.preventDefault();
    e.stopPropagation();

    const [variableKey, target] = extractAttrValue(
      e.target,
      "data-variable-key",
      (target: any) => /UL/i.test(target.tagName)
    );

    if (variableKey) {
      const variablePlaceholder = target.textContent;

      // @ts-ignore
      const node = this.util.createElement("var");
      node.setAttribute("data-node-type", "variable");
      node.setAttribute("data-variable-key", variableKey);
      node.setAttribute("contenteditable", false);
      node.textContent = variablePlaceholder;

      // @ts-ignore
      this.insertNode(node);
      // todo move cursor to the end ?

      // @ts-ignore
      this.history.push(false);
    }

    // @ts-ignore
    this.submenuOff();

    // @ts-ignore
    this.focus();
  }
};

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
zhaoyao91commented, Mar 4, 2020

😃 BTW, I found the user functions are useful, such as uploadImage and insertHTML. but we can’t use them in core when writing plugin 😦

0reactions
JiHong88commented, Mar 11, 2020

The 2.26.0 version has been updated. If there is an issue, please register as a new issue. Thank you.

Read more comments on GitHub >

github_iconTop Results From Across the Web

how to move the cursor to be the end of newly inserted tag ...
I've made some function to insert a special tag, but the cursor after inserting is before the tag. How to move it to...
Read more >
vim - move cursor after inserted text - Stack Overflow
After a put command ("p" or "P") the cursor is sometimes placed at the first inserted line and sometimes on the last inserted...
Read more >
How to place cursor position at end of text in text input field ...
In this article, we are going to learn about how to place the cursor at end of the text in a text input...
Read more >
Moving cursor beyond shapes and text boxes I've just inserted
After your last paragraph before the shapes, create a space big enough for the shapes to go into and then start typing a...
Read more >
Keyboard shortcuts for Google Docs - Android
Keyboard shortcuts for Google Docs ; Move to the end of the table, hold Ctrl + Alt + Shift, press t then d...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found