Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes are made for typescript issue in angular #527

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -619,6 +619,49 @@ export class AppComponent implements OnInit{
}
```

### Using type definition

If you want to use the type definitions the following code changes needs to be done in app.component.ts file.
```typescript
import { DefineIcon,RegisterCommand } from 'froala-editor';

// We will make usage of the Init hook and make the implementation there.
import { Component, OnInit } from '@angular/core';

@Component({
selector: 'app-demo',
template: `<div class="sample">
<h2>Sample 11: Add Custom Button</h2>
<div [froalaEditor]="options" [(froalaModel)]="content" ></div>
</div>`,


export class AppComponent implements OnInit{

ngOnInit () {
DefineIcon('alert', {NAME: 'info'});
RegisterCommand('alert', {
title: 'Hello',
focus: false,
undo: false,
refreshAfterCallback: false,

callback: () => {
alert('Hello!', this);
}
});
}

public options: Object = {
charCounterCount: true,
toolbarButtons: ['bold', 'italic', 'underline', 'paragraphFormat','alert'],
toolbarButtonsXS: ['bold', 'italic', 'underline', 'paragraphFormat','alert'],
toolbarButtonsSM: ['bold', 'italic', 'underline', 'paragraphFormat','alert'],
toolbarButtonsMD: ['bold', 'italic', 'underline', 'paragraphFormat','alert'],
};
}
```


### Special tags
Note: In order to use special tags in `app.module.ts` add
Expand Down
6 changes: 3 additions & 3 deletions projects/demo/src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Component, OnInit } from '@angular/core';
import {FormControl, FormGroup, Validators} from '@angular/forms';

import FroalaEditor from 'froala-editor';

import { DefineIcon,RegisterCommand } from 'froala-editor';
@Component({
selector: 'app-demo',
template: `
Expand Down Expand Up @@ -99,8 +99,8 @@ import FroalaEditor from 'froala-editor';
export class AppComponent implements OnInit {

ngOnInit () {
FroalaEditor.DefineIcon('alert', { SVG_KEY: 'help' });
FroalaEditor.RegisterCommand('alert', {
DefineIcon('alert', { SVG_KEY: 'help' });
RegisterCommand('alert', {
title: 'Hello',
focus: false,
undo: false,
Expand Down