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

Read-only mode #492

Closed
pjasiun opened this issue Jul 3, 2017 · 10 comments · Fixed by ckeditor/ckeditor5-core#97
Closed

Read-only mode #492

pjasiun opened this issue Jul 3, 2017 · 10 comments · Fixed by ckeditor/ckeditor5-core#97
Assignees
Labels
package:core package:ui type:feature This issue reports a feature request (an idea for a new functionality or a missing option).
Milestone

Comments

@pjasiun
Copy link

pjasiun commented Jul 3, 2017

While refactoring commands API (https://github.com/ckeditor/ckeditor5-core/issues/88) we talked about the read-only mode.

Recently, we also talked about it more, F2F with @Reinmar and @oskarwrobel.

We decided that:

  • there should be an observable property in the editor: editor.readonly, so all features can observe it,
  • the command base class should have a default listener which disable all commands if the editor is in the read-only mode,
  • UI should be disabled manually: for instance, the contextual toolbar should not be displayed if all buttons there are disabled, on the other hand, it should be possible to open link balloon on a link to copy that link URL (however in can be implemented later),
  • the engine will not block anything in the read-only mode, in case somebody wants to implement a feature which applies some changes anyway,
  • selection should be enabled in the read-only mode, it should be possible to select and copy text.
@pjasiun pjasiun added package:core package:ui type:feature This issue reports a feature request (an idea for a new functionality or a missing option). labels Jul 3, 2017
@oskarwrobel oskarwrobel self-assigned this Jul 3, 2017
@Reinmar
Copy link
Member

Reinmar commented Jul 3, 2017

there should be an observable property in the editor: editor.readonly, so all features can observe it,

readOnly or readonly? The word is "read-only" so these are two separate words, hence readOnly. CKE4 uses readOnly as well.

Besides, we wanted to resign from having a negated "readOnly" and instead have "isEditable". I think we already have it somewhere in the code. So, we should make the final decision and clean this up.

the command base class should have a default listener which disable all commands if the editor is in the read-only mode,

See https://github.com/ckeditor/ckeditor5-core/blob/77e52176e0885d37d8c05e8d2f7851b58c033fe6/tests/command.js#L115-L134

selection should be enabled in the read-only mode, it should be possible to select and copy text.

This we need to see live. Our first step is to disable features, so disable ability to change the content. But then we need to figure out what to do with the selection. Do we want to turn of contentEditable or do we want to leave ability to put a caret in the content or do we want something in between. Let's make the decision later as we'll be able to better understand the needs.

@oskarwrobel
Copy link
Contributor

oskarwrobel commented Jul 3, 2017

readOnly or readonly? The word is "read-only" so these are two separate words, hence readOnly. CKE4 uses readOnly as well.

readonly is consistent with HTML input#readonly attribute.

@Reinmar
Copy link
Member

Reinmar commented Jul 3, 2017

readolny

I love the typo :D Makes this word so cool :D

@oskarwrobel
Copy link
Contributor

Fixed :D

@Reinmar
Copy link
Member

Reinmar commented Jul 3, 2017

readolny is consistent with HTML input#readolny attribute.

Aren't attributes case-insensitive?

image

But:

image

@pjasiun
Copy link
Author

pjasiun commented Jul 3, 2017

I would keep readonly/readOnly. Editable as already overused (isEditable could be also a method to check if the type of the element is "Editable", also editable.isEditable = false looks very strange for me). I'm fine with both readonly and readOnly, but to keep backward compatibility and because its 2 words I prefer readOnly.

@scofalik
Copy link
Contributor

scofalik commented Jul 4, 2017

In this case I am also for readOnly. I know we had discussion about parameter names but this one I think is fine and natural. We are all used to think about editor as "read only" and "not read only". As @pjasiun stated, isEditable has connotation with other parts of code.

@Reinmar
Copy link
Member

Reinmar commented Jul 5, 2017

Back to the naming... shouldn't it be isReadOnly?

Boolean properties and variables are always prefixed by an auxiliary verb:

https://github.com/ckeditor/ckeditor5-design/wiki/Code-Style-Naming-Guidelines

@pjasiun
Copy link
Author

pjasiun commented Jul 5, 2017

isReadOnly is great.

@oskarwrobel
Copy link
Contributor

One of the requirements is:

UI should be disabled manually: for instance, the contextual toolbar should not be displayed if all buttons there are disabled, on the other hand, it should be possible to open link balloon on a link to copy that link URL (however in can be implemented later),

From @fredck.

I'm for not showing contextual toolbars at all, if the editor is readonly.

https://github.com/ckeditor/ckeditor5-image/issues/123#issuecomment-313639614

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package:core package:ui type:feature This issue reports a feature request (an idea for a new functionality or a missing option).
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants