-
Notifications
You must be signed in to change notification settings - Fork 78
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
Add quick code option to settings and shortcode parameters #126
Conversation
It allows to toggle the feature that allows the user to enter in edit mode when double clicking.
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 looks good and works well!
One inconsistency is that we do not have this option for the Block in the Block Editor. We can turn it on/off globally, and within individual shortcodes. Perhaps we can add a Block setting as well? (Can be in a new PR)
syntaxhighlighter.php
Outdated
@@ -1392,6 +1399,7 @@ function settings_page() { ?> | |||
<label for="syntaxhighlighter-light"><input name="syntaxhighlighter_settings[light]" type="checkbox" id="syntaxhighlighter-light" value="1" <?php checked( $this->settings['light'], 1 ); ?> /> <?php _e( 'Use the light display mode, best for single lines of code', 'syntaxhighlighter' ); ?></label><br /> | |||
<label for="syntaxhighlighter-smarttabs"><input name="syntaxhighlighter_settings[smarttabs]" type="checkbox" id="syntaxhighlighter-smarttabs" value="1" <?php checked( $this->settings['smarttabs'], 1 ); ?> /> <?php _e( 'Use smart tabs allowing tabs being used for alignment', 'syntaxhighlighter' ); ?></label><br /> | |||
<label for="syntaxhighlighter-wraplines"><input name="syntaxhighlighter_settings[wraplines]" type="checkbox" id="syntaxhighlighter-wraplines" value="1" <?php checked( $this->settings['wraplines'], 1 ); ?> /> <?php _e( 'Wrap long lines (v2.x only, disabling this will make a scrollbar show instead)', 'syntaxhighlighter' ); ?></label><br /> | |||
<label for="syntaxhighlighter-quickcode"><input name="syntaxhighlighter_settings[quickcode]" type="checkbox" id="syntaxhighlighter-quickcode" value="1" <?php checked( $this->settings['quickcode'], 1 ); ?> /> <?php _e( 'Enable edit mode on double click', 'syntaxhighlighter' ); ?></label><br /> |
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 should use esc_html_e( ... )
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.
Good catch! I took the opportunity to fix all occurrences.
Maybe I could do it in another PR, but as I was changing some of these texts, I think it also makes sense to be in this PR. Makes sense to you? If you think not, I can split ;)
syntaxhighlighter.php
Outdated
@@ -1516,6 +1524,7 @@ function settings_page() { ?> | |||
<li><?php printf( _x( '%1$s (v3 only) — Sets some text to show up before the code. Very useful when combined with the %2$s parameter.', 'title parameter', 'syntaxhighlighter' ), '<code>title</code>', '<code>collapse</code>' ); ?></li> | |||
<li><?php printf( _x( '%s — Toggle the toolbar (buttons in v2, the about question mark in v3)', 'toolbar parameter', 'syntaxhighlighter' ), '<code>toolbar</code>' ); ?></li> | |||
<li><?php printf( _x( '%s (v2 only) — Toggle line wrapping.', 'wraplines parameter', 'syntaxhighlighter'), '<code>wraplines</code>' ); ?></li> | |||
<li><?php printf( _x( '%s — Enable edit mode on double click.', 'quickcode parameter', 'syntaxhighlighter' ), '<code>quickcode</code>' ); ?></li> |
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 should use esc_html_x( ... )
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.
Good catch! I took the opportunity to fix all occurrences.
Maybe I could do it in another PR, but as I was changing some of these texts, I think it also makes sense to be in this PR. Makes sense to you? If you think not, I can split ;)
c3debae
to
0afc0e6
Compare
@alexsanford Makes sense! I added it here 53143c6 Thank you for your code review so far. =) |
@renatho The feature on the block works well! I wonder, though, if we should give a better explanation. The Setting, for example, says "Enable edit mode on double click (v3.x only)", whereas the block setting says "Quick code". I don't think that will be clear to people. So two things:
|
Hey @alexsanford ! Thank you for your re-review! 😅
Makes totally sense! I updated the block editor to match the same setting label: 9e736a0
Actually, it should be working like that because of these lines:
I tested and it seems to be working. Could you please confirm if it is not working? The test that I did:
|
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.
Actually, it should be working like that because of these lines
Ah, yes it is! Sorry about that. I noticed the text in the setting, and didn't even test to see if it was already working. Whoops! 😅
This looks great, and works well! 🎉
Description
This PR introduces a new setting option and shortcode to toggle the
quickcode
(currently always enabled).The
quickcode
is responsible for the feature that allows the user to enter in edit mode when double-clicking on the code. This PR keeps it turned on by default, but allowing to disable, what can be useful for some websites.Screenshots
The behaviour after the double click (current behaviour): Remove the formatting and allow the user to edit the code.