-
Notifications
You must be signed in to change notification settings - Fork 98
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
Support for read-only mode #56
Conversation
tests/ckeditor.jsx
Outdated
@@ -372,6 +372,64 @@ describe( 'CKEditor Component', () => { | |||
} ); | |||
} ); | |||
} ); | |||
|
|||
describe.only( '#disabled', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❤️
Because ckeditor/ckeditor5#1364 is still open, I added the new property in mentioned PR. |
src/ckeditor.jsx
Outdated
@@ -103,11 +127,13 @@ CKEditor.propTypes = { | |||
onChange: PropTypes.func, | |||
onInit: PropTypes.func, | |||
onFocus: PropTypes.func, | |||
onBlur: PropTypes.func | |||
onBlur: PropTypes.func, | |||
disabled: PropTypes.oneOfType( [ PropTypes.bool, PropTypes.string ] ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't agree here. Why we should support multiple types here? Can't we just support only boolean
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not? You can do disabled="true"
(as I did before I discovered disabled={true}
) and it still will work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But disabled="true"
isn't the preferred way to pass a boolean option to react component as you find out yourself... IMO we should support more than one type if there're a concept and more logic behind the other types (like string and array of strings).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now the component will accept boolean value only.
sample/index.html
Outdated
@@ -51,6 +56,16 @@ <h2>Sample</h2> | |||
} ), | |||
document.getElementById( 'root' ) | |||
); | |||
|
|||
document.getElementById( 'readOnly' ).addEventListener( 'click', function() { | |||
window.editor.isReadOnly = !window.editor.isReadOnly; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if the editor isn't available here? 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I moved this code to onInit
component's callback.
Suggested merge commit message (convention)
Feature: Introduced the
[disabled]
property which allows switching the editor to read-only mode. Closes #53.