Skip to content

Commit

Permalink
fix copying and pasting into markdown input
Browse files Browse the repository at this point in the history
  • Loading branch information
Skalakid committed Feb 6, 2024
1 parent 58e1899 commit c698ea7
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/MarkdownTextInput.web.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,14 @@ const MarkdownTextInput = React.forwardRef<TextInput, MarkdownTextInputProps>(
if (history.current && shouldAddToHistory) {
history.current.debouncedAdd(parsedText.text, parsedText.cursorPosition);
}

if (parsedText.cursorPosition !== null) {
contentSelection.current = {
start: parsedText.cursorPosition,
end: parsedText.cursorPosition,
};
}

return parsedText;
},
[multiline],
Expand Down Expand Up @@ -418,13 +426,13 @@ const MarkdownTextInput = React.forwardRef<TextInput, MarkdownTextInputProps>(
}

const text = processedValue !== undefined ? processedValue : '';
parseText(divRef.current, text, processedMarkdownStyle);
if ((divRef.current as unknown as TextInput).isFocused()) {
contentSelection.current = {
start: text.length,
end: text.length,
};
}
parseText(divRef.current, text, processedMarkdownStyle);
updateTextColor(divRef.current, value);
}, [multiline, processedMarkdownStyle, processedValue]);

Expand Down

0 comments on commit c698ea7

Please sign in to comment.