Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CSS classes to ngx-contentful-richtext component and to renderers #9

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { ChangeDetectionStrategy, Component } from '@angular/core';
import { ChangeDetectionStrategy, Component, HostBinding } from '@angular/core';
import { MARKS } from '@contentful/rich-text-types';

import { MarkRenderer } from '../classes/mark-renderer.class';

export const TEXT = `<ng-container ngxMarkRendererHost [node]="node"></ng-container>`;
Expand All @@ -17,5 +16,7 @@ export const TEXT = `<ng-container ngxMarkRendererHost [node]="node"></ng-contai
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class DefaultMarkRendererComponent extends MarkRenderer {
@HostBinding('class') class = 'default-mark-renderer';

MARKS: typeof MARKS = MARKS;
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { ChangeDetectionStrategy, Component } from '@angular/core';
import { ChangeDetectionStrategy, Component, HostBinding } from '@angular/core';
import { BLOCKS, INLINES } from '@contentful/rich-text-types';

import { NodeRenderer } from '../classes/node-renderer.class';

export const CHILDREN =
Expand Down Expand Up @@ -47,6 +46,8 @@ const DEFAULT_INLINE =
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class DefaultNodeRendererComponent extends NodeRenderer {
@HostBinding('class') class = 'default-node-renderer';

BLOCKS: typeof BLOCKS = BLOCKS;
INLINES: typeof INLINES = INLINES;
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
import { ChangeDetectionStrategy, Component, Input } from '@angular/core';
import {
ChangeDetectionStrategy,
Component,
HostBinding,
Input,
} from '@angular/core';
import { Text } from '@contentful/rich-text-types';

@Component({
template: '{{ node.value }}',
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class TextValueComponent {
@HostBinding('class') class = 'text-value';

@Input() node: Text;
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import {
ChangeDetectionStrategy,
Component,
HostBinding,
Input,
OnChanges,
OnInit,
SimpleChanges,
} from '@angular/core';
import { Block, Document, Inline } from '@contentful/rich-text-types';

import {
MarkRendererResolver,
NodeRendererResolver,
Expand All @@ -34,6 +34,8 @@ import {
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class NgxContentfulRichTextComponent implements OnInit, OnChanges {
@HostBinding('class') class = 'ngx-contentful-rich-text';

/** Document to render */
@Input() document: Document;

Expand Down