Recently, I added a text editor called Jodit to my angular application and faced some challenges in integrating it smoothly.
The steps I followed were:
npm install --save jodit
- Inserted
in angular.json's build-options-scripts"node_modules/jodit/build/jodit.min.js"
- Included
in angular.json's build-options-styles"node_modules/jodit/build/jodit.min.css"
Below is a snippet of my component:
import * as jodit from 'jodit';
@Component({
selector: 'app-test',
styleUrls: ['./test.component.scss'],
template: `
<textarea id="test" name="editor"></textarea>
`
})
export class TestComponent implements OnInit {
public editor: any;
constructor() {}
ngOnInit() {//
const elem: HTMLElement = document.getElementById('test');
this.editor = new jodit.Jodit(elem, {});
}
The errors I encountered are showcased below:
src/app/test.component.ts(21,28): error TS2339: Property 'Jodit' does not exist on type 'typeof import("C:/Users/test/Desktop/test/node_modules/jodit/src/types/index")'.
src/app/test.component.ts(41,27): error TS2339: Property 'Jodit' does not exist on type 'typeof import("C:/Users/test/Desktop/test/node_modules/jodit/src/types/index")'.
Despite the compilation issues, the text editor functions properly when I use npm start
(although the errors persist). Could this be due to a type linkage error? Any insights would be appreciated.