sibiraj-s / ngx-editor

🖋️ Rich Text Editor for angular using ProseMirror
https://sibiraj-s.github.io/ngx-editor/
MIT License
458 stars 191 forks source link

How to set editor as readonly? #361

Closed chengB12 closed 3 years ago

chengB12 commented 3 years ago

I'm submitting a

Description

I upgrade ngx from 4.x to 10.x, ng build complain that [config] is not property of app-ngx-editor

I used to have [config]="editorConfig", while editorConfig = { editable: false }

Now I didn't found any documentation to bring back editable flag.

I tried [disabled]="true", it seems has no effect at all: https://stackblitz.com/edit/ngx-editor-suinw7?file=src/app/app.component.html

Version Information

ngx-editor: 10.1.0
angular: 12.2.2

Browser


sibiraj-s commented 3 years ago

You should be able use disabled property like you do for input components. Let me know if it is not working. I can check.

chengB12 commented 3 years ago

you can click the stackbliz link, it has [disabled]="true" yet the toolbar is disabled, however, not main editor body

sibiraj-s commented 3 years ago

Oh. Something might have been broken. I will check, but it was the method.

sibiraj-s commented 3 years ago

@chengB12 . Something is changed how angular handles this I think.

form = new FormGroup({
  editorContent: new FormControl(
    { value: jsonDoc, disabled: true },
    Validators.required()
  ),
});

this works and to programatically update the form, you can use.

this.form.get("editorContent").disable();
this.form.get("editorContent").enable();
sibiraj-s commented 3 years ago

Okay. ☝️ that how you do it for reactive forms. the disabled attribute will work as usual for the rest. Pardon me, I am slightly outdated.

Screenshot 2021-08-20 at 7 55 25 PM

Let me know if there is something else. Feel free to continue the discussion if required. Thanks.

github-actions[bot] commented 2 years ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in the thread.