Skip to content
This repository has been archived by the owner on Dec 16, 2022. It is now read-only.

Commit

Permalink
Merge pull request #655 from avelow/master
Browse files Browse the repository at this point in the history
add types/katex, import options from katex and optimize import
  • Loading branch information
garciparedes committed Dec 7, 2020
2 parents ad71c3a + b498acb commit c028f5c
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 24 deletions.
6 changes: 6 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Expand Up @@ -63,6 +63,7 @@
"@angular/platform-browser": "8.2.14",
"@angular/platform-browser-dynamic": "8.2.14",
"@angular/router": "8.2.14",
"@types/katex": "^0.11.0",
"clean-css": "4.2.2",
"ng-packagr": "9.1.5",
"node-sass": "4.14.1",
Expand Down
2 changes: 1 addition & 1 deletion projects/demo/src/app/app.component.ts
@@ -1,5 +1,5 @@
import { Component } from '@angular/core';
import { KatexOptions } from 'ng-katex';
import { KatexOptions } from 'katex';

@Component({
selector: 'app-root',
Expand Down
5 changes: 2 additions & 3 deletions projects/ng-katex/src/lib/ng-katex.component.ts
Expand Up @@ -3,9 +3,8 @@ import {
EventEmitter,
Input,
Output,
ViewEncapsulation,
} from '@angular/core';
import * as ko from './ng-katex.options';
import { KatexOptions } from 'katex';

@Component({
selector: 'ng-katex',
Expand All @@ -19,7 +18,7 @@ import * as ko from './ng-katex.options';
export class KatexComponent {

@Input() equation: string;
@Input() options?: ko.KatexOptions;
@Input() options?: KatexOptions;
@Output() onError = new EventEmitter<any>();

hasError(error) {
Expand Down
4 changes: 2 additions & 2 deletions projects/ng-katex/src/lib/ng-katex.directive.ts
Expand Up @@ -6,15 +6,15 @@ import {
Output,
} from '@angular/core';
import { KatexService } from './ng-katex.service';
import * as ko from './ng-katex.options';
import { KatexOptions } from 'katex';

@Directive({
selector: '[katex]',
})
export class KatexDirective {

@Input('katex') equation: string;
@Input('katex-options') options: ko.KatexOptions;
@Input('katex-options') options: KatexOptions;

@Output() onError = new EventEmitter<any>();

Expand Down
9 changes: 0 additions & 9 deletions projects/ng-katex/src/lib/ng-katex.options.ts

This file was deleted.

12 changes: 5 additions & 7 deletions projects/ng-katex/src/lib/ng-katex.service.ts
@@ -1,16 +1,14 @@
import { ElementRef, Injectable } from '@angular/core';
import * as ko from './ng-katex.options';

import * as katex from 'katex';
import { render, renderToString, KatexOptions } from 'katex';

@Injectable()
export class KatexService {

render(equation: string, element: ElementRef, options?: ko.KatexOptions) {
return katex.render(equation, element.nativeElement, options);
render(equation: string, element: ElementRef, options?: KatexOptions) {
return render(equation, element.nativeElement, options);
}

renderToString(equation: string, options?: ko.KatexOptions): string {
return katex.renderToString(equation, options);
renderToString(equation: string, options?: KatexOptions): string {
return renderToString(equation, options);
}
}
1 change: 0 additions & 1 deletion projects/ng-katex/src/lib/ng-katex.ts
@@ -1,4 +1,3 @@
export * from './ng-katex.options';
export * from './ng-katex.component';
export * from './ng-katex-paragraph.component';
export * from './ng-katex.module';
1 change: 0 additions & 1 deletion projects/ng-katex/src/public-api.ts
@@ -1,7 +1,6 @@
/*
* Public API Surface of ng-katex
*/
export * from './lib/ng-katex.options';
export * from './lib/ng-katex.component';
export * from './lib/ng-katex-paragraph.component';
export * from './lib/ng-katex.module';

0 comments on commit c028f5c

Please sign in to comment.