Skip to content

Commit

Permalink
fix: checklist not working anymore inside markdown #2988
Browse files Browse the repository at this point in the history
  • Loading branch information
johannesjo committed Jan 29, 2024
1 parent c74c989 commit bbfa937
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 11 deletions.
29 changes: 22 additions & 7 deletions src/app/ui/inline-markdown/inline-markdown.component.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@import "../../../_variables";
@import '../../../_variables';

:host {
display: block;
Expand All @@ -21,7 +21,7 @@

.resize-to-fit {
position: absolute;
right: $s*2;
right: $s * 2;
top: 0;
cursor: pointer;
}
Expand All @@ -35,7 +35,7 @@
.markdown-parsed {
//transition: height 1.3s;
border: 0;
padding: $s $s*2;
padding: $s $s * 2;
margin: 0;
width: 100%;
box-sizing: border-box;
Expand All @@ -53,14 +53,13 @@
padding-top: 0;
}


h1,
h2,
h3 {
&,
.mat-typography & {
margin-bottom: $s;
margin-top: $s*2;
margin-top: $s * 2;

&:first-child {
margin-top: 0;
Expand All @@ -71,16 +70,32 @@

ul {
margin: 0 $s;
padding-left: $s*2;
padding-left: $s * 2;
}

> ul {
padding-left: $s*2;
padding-left: $s * 2;
}

ul ul {
padding-top: 0;
}

.checkbox {
display: inline-block;
font-size: 20px;
width: 20px;
line-height: 1;
text-align: center;
margin-left: -28px;
vertical-align: middle;
margin-right: $s;
}

.checkbox-wrapper {
list-style: none;
margin-bottom: $s;
}
}

textarea {
Expand Down
8 changes: 7 additions & 1 deletion src/app/ui/inline-markdown/inline-markdown.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,13 @@ export class InlineMarkdownComponent implements OnInit, OnDestroy {

toggleShowEdit($event?: MouseEvent): void {
// check if anchor link was clicked
if (!$event || ($event.target as HTMLElement).tagName !== 'A') {
console.log(($event?.target as any).className);

if (
!$event ||
(($event.target as HTMLElement).tagName !== 'A' &&
!($event.target as HTMLElement).className.includes('marked-checkbox'))
) {
this.isShowEdit = true;
this.modelCopy = this.model || '';

Expand Down
13 changes: 10 additions & 3 deletions src/app/ui/ui.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,10 +189,17 @@ const OTHER_3RD_PARTY_MODS_WITHOUT_CFG = [
provide: MarkedOptions,
useFactory: (): MarkedOptions => {
const renderer = new MarkedRenderer();
renderer.listitem = (text: string) =>
/<input.+type="checkbox"/.test(text)
? '<li style="list-style: none;">' + text + '</li>'
renderer.checkbox = (isChecked: boolean) => {
return `<span class="checkbox material-icons">${
isChecked ? 'check_box ' : 'check_box_outline_blank '
}</span>`;
};
renderer.listitem = (text: string) => {
console.log(text, text.includes('checkbox'));
return text.includes('checkbox')
? '<li class="checkbox-wrapper">' + text + '</li>'
: '<li>' + text + '</li>';
};
return {
renderer: renderer,
gfm: true,
Expand Down

0 comments on commit bbfa937

Please sign in to comment.