Skip to content

Commit

Permalink
fix(text-editor): remove easymde as commonjs dep
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions committed May 17, 2022
1 parent 7e1b03f commit 5c57c0e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
3 changes: 2 additions & 1 deletion apps/docs-app/project.json
Expand Up @@ -48,7 +48,8 @@
"scripts": [
"node_modules/echarts/dist/echarts.js",
"node_modules/echarts-wordcloud/dist/echarts-wordcloud.min.js",
"node_modules/shepherd.js/dist/js/shepherd.min.js"
"node_modules/shepherd.js/dist/js/shepherd.min.js",
"node_modules/easymde/dist/easymde.min.js"
]
},
"configurations": {
Expand Down
12 changes: 6 additions & 6 deletions libs/angular-text-editor/src/lib/text-editor.component.ts
Expand Up @@ -9,14 +9,14 @@ import {
OnDestroy,
} from '@angular/core';
import { NG_VALUE_ACCESSOR, ControlValueAccessor } from '@angular/forms';
import * as EasyMDE from 'easymde';
// get access to the marked class under easymde
import * as marked from 'marked';
import { marked } from 'marked';

const noop: any = () => {
// empty method
};

const EasyMDE = (window as any).EasyMDE;

@Component({
selector: 'td-text-editor',
templateUrl: './text-editor.component.html',
Expand All @@ -33,7 +33,7 @@ export class TdTextEditorComponent
implements AfterViewInit, OnDestroy, ControlValueAccessor
{
private _value = '';
private _easyMDE!: EasyMDE;
private _easyMDE!: typeof EasyMDE;
private _fromEditor = false;

@ViewChild('easymde', { static: true }) textarea!: ElementRef;
Expand Down Expand Up @@ -66,7 +66,7 @@ export class TdTextEditorComponent
return this._value;
}

get easyMDE(): EasyMDE {
get easyMDE(): typeof EasyMDE {
return this._easyMDE;
}

Expand All @@ -87,7 +87,7 @@ export class TdTextEditorComponent
this.options.element = this.textarea.nativeElement;

// If content entered is html then don't evaluate it, prevent xss vulnerabilities
marked.marked.setOptions({ sanitize: true });
marked.setOptions({ sanitize: true });
this._easyMDE = new EasyMDE(this.options);
this._easyMDE.value(this.value);
this._easyMDE.codemirror.on('change', this._onChange);
Expand Down

0 comments on commit 5c57c0e

Please sign in to comment.