-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Enable lock in MarkdownEditor #283
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
Conversation
|
LGTM |
browser/components/MarkdownEditor.js
Outdated
| renderValue: props.value, | ||
| keyPressed: {} | ||
| keyPressed: {}, | ||
| locked: false |
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.
This is duplicated and not connected the state with https://github.com/asmsuechan/Boostnote/blob/74ee6ae6ce047ae7c349b35ae048ae14930c547e/browser/main/Detail/MarkdownNoteDetail.js#L29.
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.
However, I'm not sure how it connects each other.
| } | ||
|
|
||
| toggleLockButton () { | ||
| return this.state.locked ? 'fa-lock' : 'fa-unlock-alt' |
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.
This does not collaborate with the actual a state of MarkdownEditor.
| {(() => { | ||
| // TODO: get a state of MarkdownEditor somehow | ||
| const editorStatus='CODE' | ||
| let faClassName=`fa ${this.toggleLockButton()}` |
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 wanna get the current status PREVIEW/CODE of the MarkdownEditor.
|
Current status is WIP because the lock/unlock icon is shown even PREVIEW mode. |
| } | ||
| this.dispatchTimer = null | ||
|
|
||
| this.showLockButton = () => this.handleShowLockButton() |
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.
Please use Function.prototype.bind. It is more clearly which this is assigned.
this.showLockButton = this.showLockButton.bind(this);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.
We need to refactor other same style lines.
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 know, so we should try to refactor little by little...
| this.setState({ isLocked: !this.state.isLocked }) | ||
| } | ||
|
|
||
| toggleLockButton () { |
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 think getToggleLockButtonClassName is better.
| </div> | ||
| <div styleName='info-right'> | ||
| {(() => { | ||
| let faClassName=`fa ${this.toggleLockButton()}` |
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.
Can you use const?
| <i className={faClassName}/> | ||
| </button> | ||
| ) | ||
| } |
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.
Writing this function before return is more readable.
const lockButtonComponent =
<button styleName='info-right-button'
onFocus={(e) => this.handleFocus(e)}
onMouseDown={(e) => this.handleLockButtonMouseDown(e)}
>
<i className={`fa ${this.toggleLockButton()}`}/>
</button>;
/** */
return (
{this.state.editorStatus === 'CODE' ? lockButtonComponent : '' }
);|
I fixed them. |
|
I think Tooltip is needed when hover on lock icon. How about it? |
|
@kazup01 So do I. |

Hi, I added a function which keeps Editor mode even though I move to another window.
refs: #272