-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Code Editor basic support for: undo, redo, find, replace #3129
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
base: develop
Are you sure you want to change the base?
Code Editor basic support for: undo, redo, find, replace #3129
Conversation
e17f0c9 to
417d185
Compare
| } | ||
| .CodeMirror-search-label{ |
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 remove this empty CSS key/body.
|
|
||
| } | ||
| .CodeMirror-dialog { |
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.
Could you please check the styling with dark themes, it's a bit odd. Also, OneDark has dark font color on dark background.
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.
Yes the control was essentially un-themed. Would you prefer legibility is working for both, or to actually flip the theme based on marktext?
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.
Flipping the theme would be great. I think we use two different themes based whether MarkTexts theme is light or darkish. Maybe we can use CSS selectors to differentiate colors.
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.
Yeah I assumed CSS light/dark overall would be the way to go. Will update.
| import 'codemirror/addon/search/searchcursor' | ||
| import 'codemirror/addon/dialog/dialog' | ||
| import 'codemirror/addon/search/search' | ||
| import 'codemirror/addon/search/jump-to-line' |
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.
Is this needed for search or only for the Alt+G shortcut? Please remove the dependency if it's not necessary for seach as it may conflict with other functions (later).
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.
Only jump-to-line is for alt+g, the rest is required for search. I expect in the long term that the code editor will get more 'native' search removing the dialog need. As far as I know the addons should not cause any code conflict as they are siloed into their own class.
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.
Core problem that the feature is undocumented and it doesn't for for preview mode.
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.
Sure, that was largely why I was leaving it undocumented too, was it only worked in the code editor. To confirm you just want jump-to-line removed correct?
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.
Yes, please.
| @@ -993,13 +993,13 @@ export default { | |||
| }, | |||
|
|
|||
| handleUndo () { | |||
| if (this.editor) { | |||
| if (this.editor && this.sourceCode === 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.
You can simplify this.sourceCode === false to !this.sourceCode
| this.editor.undo() | ||
| } | ||
| }, | ||
|
|
||
| handleRedo () { | ||
| if (this.editor) { | ||
| if (this.editor && this.sourceCode === 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.
You can simplify this.sourceCode === false to !this.sourceCode
| @@ -1077,6 +1077,7 @@ export default { | |||
| }, | |||
|
|
|||
| handleFindAction (action) { | |||
| if (this.sourceCode) { return } | |||
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 add a new line to the body (preferred) or remove brackets around return.
| }, | ||
|
|
||
| docClick () { | ||
| if (this.editor && this.sourceCode) { this.editor.execCommand('clearSearch') } |
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 add the body in a new line.
| @@ -245,6 +261,49 @@ export default { | |||
| this.tabId = null // invalidate tab id | |||
| } | |||
| }, | |||
| handleUndo () { | |||
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 keep spacing (new lines) between methods. You could group e.g. undo/redo etc if you like.
Description
Adds some of the features requested from #2188
This is a bit of a quick hack together so not properly implemented to use the marktext search box, instead use the codeMirror one with some styling. This also adds an undocumented, keybind of alt+g to go to jump to line number. Note if you bind something to alt+g in marktext then this will not fire.