Skip to content

Commit

Permalink
Fix single line input structure
Browse files Browse the repository at this point in the history
  • Loading branch information
Skalakid committed Sep 11, 2024
1 parent 1701063 commit 5f6bdaa
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
5 changes: 2 additions & 3 deletions src/MarkdownTextInput.web.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ const MarkdownTextInput = React.forwardRef<TextInput, MarkdownTextInputProps>(
if (text === null) {
return {text: divRef.current.value, cursorPosition: null};
}
const parsedText = updateInputStructure(target, text, cursorPosition, customMarkdownStyles, !multiline, shouldForceDOMUpdate);
const parsedText = updateInputStructure(target, text, cursorPosition, customMarkdownStyles, false, shouldForceDOMUpdate);
divRef.current.value = parsedText.text;

if (history.current && shouldAddToHistory) {
Expand All @@ -158,7 +158,7 @@ const MarkdownTextInput = React.forwardRef<TextInput, MarkdownTextInputProps>(

return parsedText;
},
[multiline],
[],
);

const processedMarkdownStyle = useMemo(() => {
Expand Down Expand Up @@ -683,7 +683,6 @@ const styles = StyleSheet.create({
fontFamily: 'sans-serif',
// @ts-expect-error it works on web
boxSizing: 'border-box',
whiteSpace: 'pre-wrap',
overflowY: 'auto',
overflowX: 'auto',
overflowWrap: 'break-word',
Expand Down
8 changes: 8 additions & 0 deletions src/web/MarkdownTextInput.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
overflow: auto;
}

.react-native-live-markdown-input-singleline p {
display: inline-block;
}

.react-native-live-markdown-input-multiline p {
display: block;
}

.react-native-live-markdown-input-singleline::-webkit-scrollbar {
display: none;
}
Expand Down
1 change: 0 additions & 1 deletion src/web/utils/blockUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ function addStyleToBlock(targetElement: HTMLElement, type: NodeType, markdownSty
switch (type) {
case 'line':
Object.assign(node.style, {
display: 'block',
margin: '0',
padding: '0',
});
Expand Down

0 comments on commit 5f6bdaa

Please sign in to comment.