0

Problem

I'm using Toast UI Editor with the color syntax plugin. When I apply a color to selected text:

  1. Issue 1: The cursor jumps to the beginning of the line/paragraph (only on first color change)
  2. Issue 2: When changing text to the same color or partially changing color, the highlight still displays

Environment

  • Toast UI Editor: [version]
  • @toast-ui/editor-plugin-color-syntax: [version]
  • Browser: [browser + version]

Expected Behavior

  • Selection/cursor should remain at the end of selected text after color is applied
  • Changing to same color should remove the color (not display highlight)

Actual Behavior

  • Cursor jumps to beginning of line after applying color (first time only)
  • Highlight background still appears even after changing to same color

Attempts Made

  1. Tried setting tr.setSelection() before and after dispatch
  2. Tried saving/restoring selection using editorNode.getSelection()/setSelection()
  3. Tried wrapping dispatch with setTimeout
  4. Tried calling original command instead of custom implementation

None of these approaches solved the cursor jumping issue.

Question

  • How can I prevent the selection from being reset after the color command?
  • Is there a proper way to handle selection preservation in Toast UI Editor plugins?
  • Should I use a different approach (hooks, events, etc.) instead of overriding the command?

Any insights would be appreciated!

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.