jaredreich / jaredreich/pell

Control pell text with one-way data binding

Open
#143 0 comments 3 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
12k
Forks
546
PR merge metrics
No merged PRs in 30d

Description

Hi, this is a doubt not a real issue.

I'm using pell with Angular and Redux, I have some actions that may modify peel's text from outside of it (mainly clear all). But since I'm using redux I added the pell html output inside my store and sync it onChange with a one way databing. No problems so far.

I use the following line to sync my store html with peel: `editorContent.innerHTML = this.htmlText`. This works normally with the exception that I loose the caret position every time. This makes the editor unusable, since I sync on every change.

I tried a lot of approaches to setting the caret position, but almost all of them work only for a single element with text. Finally I found Liam response in [this stackoverflow](https://stackoverflow.com/questions/6249095/how-to-set-caretcursor-position-in-contenteditable-element-div) thread (it is the second response). This almost works, it has a problem that it does not recognize the enters, so when I press enter a new line is added but my caret stays at the end of the current line.

Does someone have a way to keep the caret position after settings the innerHtml of the editor? I tried to debug Liam's code, but couldn't understand why it doesn't work.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reproducing the issue through pell's onChange flow and the reported editorContent.innerHTML assignment while using Angular and Redux. Investigate caret behavior in the contenteditable editor, especially after pressing Enter, and define done as preserving the caret position when external HTML updates are synchronized.

Written by the indexing model from the issue text.

Assessment

Tech stack
angular, javascript
Domain
frontend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.