File tree Expand file tree Collapse file tree 2 files changed +6
-1
lines changed
Expand file tree Collapse file tree 2 files changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -34,6 +34,11 @@ const App: Component = () => {
3434 < div contentEditable >
3535 t< b > e</ b >
3636 < i > s</ i > t
37+ < ul >
38+ < li > first item</ li >
39+ < li > second item</ li >
40+ < li > third item</ li >
41+ </ ul >
3742 </ div >
3843 </ div >
3944 < div >
Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ export const getTextNodes = (startNode: Node) => {
1717const addNodeLength = ( length : number , node : Node ) => length + ( node as Text ) . data . length ;
1818
1919const getRangePos = ( container : Node , offset : number , texts : Node [ ] ) => {
20- const index = texts . indexOf ( container ) ;
20+ const index = texts . findIndex ( ( text ) => text === container || text . parentElement === container ) ;
2121 return index === - 1 ? NaN : texts . slice ( 0 , index ) . reduce ( addNodeLength , 0 ) + offset ;
2222} ;
2323
You can’t perform that action at this time.
0 commit comments