jodit / jodit/jodit-react

Selection no longer available

Open
#58 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
406
Forks
131
Avg merge
2h 32m
Merged PRs (30d)
2

Description

Hi,

I'm using React and this seemed to work on the previous version. I'm grabbing a reference using the following...

<JoditEditor
   ref={ refObj => { this.jodit = refObj; } }
   value={this.state.content}
   config={this.config}
   onChange={this.onJoditEditorChange}
/>

Then elsewhere trying to add some HTML to the curser position or replace the selected text...

this.jodit.selection.insertHTML( "<p>some HTML</p>" );

The "this.jodit" is defined, but "selection" is NOT defined (ie crashes with an undefined error)!

Is there a different way I should be doing this? I've tried using the SelectStart and SelectEnd values. But they don't change, are always the length of the present value, therefore my HTML gets inserted at the end of the value.

Thanks
Dave

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the issue with the shown JoditEditor ref and the calls to selection.insertHTML, SelectStart, and SelectEnd. Trace how the React wrapper exposes the editor reference and selection state; done means inserting HTML at the cursor or replacing selected text works without an undefined selection error.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.