froala / angular-froala

Angular.js bindings for Froala WYSIWYG HTML Rich Text Editor.
https://froala.com/wysiwyg-editor
MIT License
306 stars 123 forks source link

Disable text edit and allow text style changes #209

Closed AlmogCohen closed 5 years ago

AlmogCohen commented 5 years ago

This is not an issue, but rather a question - If I missed some community guidelines and it should be asked somewhere else please let me know and feel free to close this issue.

Assuming the text inside the editor is pre-populdated, I want to disable or refuse any edits to the text itself BUT allow one toolbar action - applying different inline styles to highlight text selections. Would that be possible? If so, how would you recommend doing that? What would be a good approach to do that?

I've been playing around with some custom capabilities of froala, but the moment I disable the editor, the whole toolbar actions are disabled as well (which generally makes complete sense).

Update:

  1. Best thing would be: All keyboard operations are disabled but selection and inlineToolbar actions enabled so the user can highlight the existing text. That would be awesome.
  2. If this is too much, I can live with something that refuse keyboard edits with some message, while keeping the text intact and allowing style changes through the toolbar + text selection
AlmogCohen commented 5 years ago

Not sure yet, maybe it is possible to use the events system to cancel changes upon input/keyboard operations (and paste/cut and the rest)...?

stefanneculai commented 5 years ago

@AlmogCohen what you could do is to listen to the keydown event and stop it's propagation: https://jsfiddle.net/froala/Lnw7zfd1/