Commit c04747cdd8149330bfd526d018d4cfe5621bb5f0

Authored by Igor Kulikov
1 parent 2f792391

Improve markdown widget css processing

... ... @@ -15,4 +15,4 @@
15 15 limitations under the License.
16 16
17 17 -->
18   -<markdown [data]="markdownText" class="tb-markdown-view" (click)="markdownClick($event)"></markdown>
  18 +<markdown [data]="markdownText" class="tb-markdown-view {{markdownClass}}" (click)="markdownClick($event)"></markdown>
... ...
... ... @@ -14,7 +14,7 @@
14 14 /// limitations under the License.
15 15 ///
16 16
17   -import { ChangeDetectorRef, Component, ElementRef, Input, OnInit } from '@angular/core';
  17 +import { ChangeDetectorRef, Component, Input, OnInit } from '@angular/core';
18 18 import { PageComponent } from '@shared/components/page.component';
19 19 import { WidgetContext } from '@home/models/widget-component.models';
20 20 import { Store } from '@ngrx/store';
... ... @@ -56,8 +56,9 @@ export class MarkdownWidgetComponent extends PageComponent implements OnInit {
56 56
57 57 markdownText: string;
58 58
  59 + markdownClass: string;
  60 +
59 61 constructor(protected store: Store<AppState>,
60   - private elementRef: ElementRef,
61 62 private cd: ChangeDetectorRef) {
62 63 super(store);
63 64 }
... ... @@ -66,15 +67,14 @@ export class MarkdownWidgetComponent extends PageComponent implements OnInit {
66 67 this.ctx.$scope.markdownWidget = this;
67 68 this.settings = this.ctx.settings;
68 69 this.markdownTextFunction = this.settings.useMarkdownTextFunction ? parseFunction(this.settings.markdownTextFunction, ['data']) : null;
69   -
  70 + this.markdownClass = 'markdown-widget';
70 71 const cssString = this.settings.markdownCss;
71 72 if (isNotEmptyStr(cssString)) {
72 73 const cssParser = new cssjs();
73 74 cssParser.testMode = false;
74   - const namespace = 'entities-hierarchy-' + hashCode(cssString);
75   - cssParser.cssPreviewNamespace = namespace;
76   - cssParser.createStyleElement(namespace, cssString);
77   - $(this.elementRef.nativeElement).addClass(namespace);
  75 + this.markdownClass += '-' + hashCode(cssString);
  76 + cssParser.cssPreviewNamespace = 'tb-markdown-view.' + this.markdownClass;
  77 + cssParser.createStyleElement(this.markdownClass, cssString);
78 78 }
79 79 }
80 80
... ...