Improve markdown widget css processing
This commit is contained in:
parent
2f79239167
commit
c04747cdd8
@ -15,4 +15,4 @@
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
|
|
||||||
-->
|
-->
|
||||||
<markdown [data]="markdownText" class="tb-markdown-view" (click)="markdownClick($event)"></markdown>
|
<markdown [data]="markdownText" class="tb-markdown-view {{markdownClass}}" (click)="markdownClick($event)"></markdown>
|
||||||
|
|||||||
@ -14,7 +14,7 @@
|
|||||||
/// limitations under the License.
|
/// limitations under the License.
|
||||||
///
|
///
|
||||||
|
|
||||||
import { ChangeDetectorRef, Component, ElementRef, Input, OnInit } from '@angular/core';
|
import { ChangeDetectorRef, Component, Input, OnInit } from '@angular/core';
|
||||||
import { PageComponent } from '@shared/components/page.component';
|
import { PageComponent } from '@shared/components/page.component';
|
||||||
import { WidgetContext } from '@home/models/widget-component.models';
|
import { WidgetContext } from '@home/models/widget-component.models';
|
||||||
import { Store } from '@ngrx/store';
|
import { Store } from '@ngrx/store';
|
||||||
@ -56,8 +56,9 @@ export class MarkdownWidgetComponent extends PageComponent implements OnInit {
|
|||||||
|
|
||||||
markdownText: string;
|
markdownText: string;
|
||||||
|
|
||||||
|
markdownClass: string;
|
||||||
|
|
||||||
constructor(protected store: Store<AppState>,
|
constructor(protected store: Store<AppState>,
|
||||||
private elementRef: ElementRef,
|
|
||||||
private cd: ChangeDetectorRef) {
|
private cd: ChangeDetectorRef) {
|
||||||
super(store);
|
super(store);
|
||||||
}
|
}
|
||||||
@ -66,15 +67,14 @@ export class MarkdownWidgetComponent extends PageComponent implements OnInit {
|
|||||||
this.ctx.$scope.markdownWidget = this;
|
this.ctx.$scope.markdownWidget = this;
|
||||||
this.settings = this.ctx.settings;
|
this.settings = this.ctx.settings;
|
||||||
this.markdownTextFunction = this.settings.useMarkdownTextFunction ? parseFunction(this.settings.markdownTextFunction, ['data']) : null;
|
this.markdownTextFunction = this.settings.useMarkdownTextFunction ? parseFunction(this.settings.markdownTextFunction, ['data']) : null;
|
||||||
|
this.markdownClass = 'markdown-widget';
|
||||||
const cssString = this.settings.markdownCss;
|
const cssString = this.settings.markdownCss;
|
||||||
if (isNotEmptyStr(cssString)) {
|
if (isNotEmptyStr(cssString)) {
|
||||||
const cssParser = new cssjs();
|
const cssParser = new cssjs();
|
||||||
cssParser.testMode = false;
|
cssParser.testMode = false;
|
||||||
const namespace = 'entities-hierarchy-' + hashCode(cssString);
|
this.markdownClass += '-' + hashCode(cssString);
|
||||||
cssParser.cssPreviewNamespace = namespace;
|
cssParser.cssPreviewNamespace = 'tb-markdown-view.' + this.markdownClass;
|
||||||
cssParser.createStyleElement(namespace, cssString);
|
cssParser.createStyleElement(this.markdownClass, cssString);
|
||||||
$(this.elementRef.nativeElement).addClass(namespace);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user