angular-editor icon indicating copy to clipboard operation
angular-editor copied to clipboard

how to use angular-editor with mat-form-field ? faccing issue with mat-form-field must contain a MatFormFieldControl

Open cpratiksha opened this issue 7 years ago • 13 comments

cpratiksha avatar May 14 '19 13:05 cpratiksha

code :

<mat-form-field <angular-editor matInput matTextareaAutosize formControlName="description" [config]="editorConfig"> <mat-error *ngIf="courseAssignmentManagementForm.get('description').hasError('required')" Please enter the assignment's description mat-form-field>

cpratiksha avatar May 14 '19 13:05 cpratiksha

I use angular-editor as separate component in this case:

<mat-form-field class="full-width-input">
      <input matInput placeholder="Заголовок (без точки в конце)" formControlName="title" (blur)="updatePath()">
      <mat-error *ngIf="isFieldInvalid('title')">
        Введите заголовок статьи (без точки в конце)
      </mat-error>
    </mat-form-field>

    <div class="editor">
      <angular-editor id="e1" #angularEditor (blur)="onBlur()" formControlName="body" [config]="editorConfig"></angular-editor>
    </div>

    <mat-form-field class="full-width-input">
      <textarea class="textarea" matInput placeholder="Введение в статью (без точки в конце)" formControlName="introduction"></textarea>
      <mat-error *ngIf="isFieldInvalid('introduction')">
        Введите введение в статью (без точки в конце)
      </mat-error>
    </mat-form-field>

kolkov avatar May 14 '19 13:05 kolkov

Thank you Kolkov, I am trying with your solution

cpratiksha avatar May 14 '19 14:05 cpratiksha

do I need to implement ControlValueAccessor and MatFormFieldControl.

cpratiksha avatar May 14 '19 14:05 cpratiksha

worked for me <angular-editor formControlName="description" > </angular-editor>

cpratiksha avatar May 14 '19 15:05 cpratiksha

I use angular-editor as separate component in this case:

<mat-form-field class="full-width-input">
      <input matInput placeholder="Заголовок (без точки в конце)" formControlName="title" (blur)="updatePath()">
      <mat-error *ngIf="isFieldInvalid('title')">
        Введите заголовок статьи (без точки в конце)
      </mat-error>
    </mat-form-field>

    <div class="editor">
      <angular-editor id="e1" #angularEditor (blur)="onBlur()" formControlName="body" [config]="editorConfig"></angular-editor>
    </div>

    <mat-form-field class="full-width-input">
      <textarea class="textarea" matInput placeholder="Введение в статью (без точки в конце)" formControlName="introduction"></textarea>
      <mat-error *ngIf="isFieldInvalid('introduction')">
        Введите введение в статью (без точки в конце)
      </mat-error>
    </mat-form-field>

thank you its worked for me , is there any option to set min-length or max-length limit

cpratiksha avatar May 14 '19 15:05 cpratiksha

Look at the config please https://github.com/kolkov/angular-editor/blob/master/projects/angular-editor/src/lib/config.ts#L17

kolkov avatar May 14 '19 19:05 kolkov

Thank you very much for your quick response and support. Yes, I follow this config file but where do I change the min length define and I want to remove the image tab from the toolbar .

cpratiksha avatar May 15 '19 06:05 cpratiksha

Hello @kolkov I want to remove the image and code tab from my toolbar how do I remove it from my toolbar. not working for me : :host /deep/ angular-editor#myEditor .angular-editor-button[title="Insert Image"]{ display: none !important; }

cpratiksha avatar May 15 '19 08:05 cpratiksha

Hello @kolkov I want to remove the image and code tab from my toolbar how do I remove it from my toolbar. not working for me : :host /deep/ angular-editor#myEditor .angular-editor-button[title="Insert Image"]{ display: none !important; } worked for me .angular-editor-toolbar-set .angular-editor-button[title="Insert Image"]:nth-last-child(2) { display: none !important; } .angular-editor-toolbar-set .angular-editor-button[title="HTML Code"]:nth-last-child(1) { display: none !important; }

cpratiksha avatar May 15 '19 12:05 cpratiksha

https://github.com/kolkov/angular-editor/issues/11 this may help... then we need ability to customize toolbar by config.

kolkov avatar May 15 '19 13:05 kolkov

Reopen please if problem persists.

kolkov avatar Jul 30 '19 16:07 kolkov

Hi @kolkov , Is there anyway to get formControlName="description" from angular-editor. Below control value doesn't get if i use HTML code functionality. Client side mat-error shows.

It would be great if you suggested. Thank you. <angular-editor [config]="config" formControlName="description">

config: AngularEditorConfig = { editable: true, spellcheck: true, height: '15rem', minHeight: '5rem', placeholder: 'Enter embed code here...', translate: 'no', defaultParagraphSeparator: 'p', defaultFontName: 'Arial', toolbarHiddenButtons: [ ['bold'] ], customClasses: [ { name: "quote", class: "quote", }, { name: 'redText', class: 'redText' }, { name: "titleText", class: "titleText", tag: "h1", }, ] };

contentFormInit() { this.contentForm = this.fb.group({ name: ['', Validators.required], description: ['', Validators.required], content: [''], status: ['Active', Validators.required], skippable: [false], contentPosition: [Validators.required] });

} angular-editor

Deepak200981 avatar Oct 14 '20 05:10 Deepak200981