Skip to content

Commit

Permalink
fix(client): correct checklist rendering in markdown, fixes #165
Browse files Browse the repository at this point in the history
- show correct state (checked, unchecked)
- show indentation levels
  • Loading branch information
neopostmodern committed Aug 19, 2022
1 parent a8a6402 commit 5ab4775
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions client/src/renderer/components/RenderedMarkdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,17 @@ const MarkdownContainer = styled(ReactMarkdown)`
ol {
padding-left: ${listIndent};
ul,
ol {
padding-left: 0.9em;
&.contains-task-list {
padding-left: 1.1em;
}
}
li {
&.task-list-item {
list-style: none;
margin-left: -${listIndent};
}
> p {
Expand Down Expand Up @@ -71,6 +78,20 @@ const EmptyTextarea = styled.div`
padding-bottom: 1.3rem;
`;

const CheckboxWrapper = styled.div`
position: relative;
width: 0;
`;
const CheckboxContainer = styled.div`
position: absolute;
right: 0.2em;
`;
const ReadonlyCheckbox = ({ checked }) => (
<CheckboxWrapper>
<CheckboxContainer>{checked ? '☑' : '☐'}</CheckboxContainer>
</CheckboxWrapper>
);

const RenderedMarkdown = ({
markdown,
showEmpty = true,
Expand All @@ -95,9 +116,7 @@ const RenderedMarkdown = ({
</a>
);
},
input({ checked }) {
return checked ? '☐ ' : '☑ ';
},
input: ReadonlyCheckbox,
}}
>
{markdown}
Expand Down

0 comments on commit 5ab4775

Please sign in to comment.