Skip to content

Commit 5719699

Browse files
committed
add directive to set width to 100% for images in notes
1 parent 34bcb03 commit 5719699

File tree

4 files changed

+25
-3
lines changed

4 files changed

+25
-3
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { AfterViewChecked, Directive, ElementRef } from '@angular/core';
2+
import { MatDialog } from '@angular/material/dialog';
3+
4+
@Directive({
5+
selector: '[appMarkedImageWidth]'
6+
})
7+
export class MarkedImageWidthDirective implements AfterViewChecked {
8+
9+
public images: any[] = [];
10+
11+
constructor(private el: ElementRef, public dialog: MatDialog) {
12+
}
13+
14+
ngAfterViewChecked() {
15+
const imgElements = this.el.nativeElement.querySelectorAll('img');
16+
imgElements.forEach(img => {
17+
img.style.width = '100%';
18+
});
19+
}
20+
}

frontend/src/app/shared/note-details/note-card-body/note-content.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<div #noteContentDiv>
1+
<div #noteContentDiv appMarkedImageWidth>
22
<div *ngIf="inList && viewHeight > 180 else wholeText">
33
<div [ngClass]="{more_text: showMoreText, less_text: !showMoreText}">
44
<p [innerHtml]="note.content | md2html"></p>

frontend/src/app/shared/shared.module.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ import { PageNavigationBarComponent } from './page-navigation-bar/page-navigatio
4545
import { NoteDetailsComponent } from './note-details/note-details.component';
4646
import { NoteContentComponent } from './note-details/note-card-body/note-content.component';
4747
import { AsyncNoteListComponent } from './async-note-list/async-note-list.component';
48+
import { MarkedImageWidthDirective } from './directive/marked-image-width.directive';
4849

4950

5051
/**
@@ -65,7 +66,7 @@ import { AsyncNoteListComponent } from './async-note-list/async-note-list.compon
6566
HighlightModule,
6667
MatFormFieldModule,
6768
MatChipsModule,
68-
MatIconModule
69+
MatIconModule,
6970
],
7071
declarations: [
7172
HighLightPipe,
@@ -78,6 +79,7 @@ import { AsyncNoteListComponent } from './async-note-list/async-note-list.compon
7879
AsyncSearchResultListComponent,
7980
BookmarkTextComponent,
8081
TagsValidatorDirective,
82+
MarkedImageWidthDirective,
8183
DeleteResourceDialogComponent,
8284
SocialShareDialogComponent,
8385
LoginRequiredDialogComponent,

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "Codever",
3-
"version": "7.0.1",
3+
"version": "7.0.2",
44
"description": "Codever - bookmarks and snippets manager for developers & co",
55
"scripts": {
66
"test": "echo \"Error: no test specified\" && exit 1",

0 commit comments

Comments
 (0)