Auto Resize Snippet Height Shortcode Title Attribute
-
Hi Hugh,
Thanks so much for releasing this plugin. ??
I was wondering if you knew how to get the snippet box to auto resize it’s height to fit the content and get rid of the vertical scroll bar. I tried via CSS but it didn’t appear to have any effect.
I also modified the plugin code for class-code-snippet-library (shame on me since it will break when you update) to allow a title attribute to be used in the shortcode. If anyone else wants to do the same below are the changes I made.
On line 261 I added:
'title' => ''
On line 270 I modified:
$html = $this->display_snippet( $id , $execute );
to be
$html = $this->display_snippet( $id , $execute, $title );
On line 276 I modified:
private function display_snippet( $id = 0 , $execute = false ) {
to be
private function display_snippet( $id = 0 , $execute = false, $title ) {
On Line 299 I added (before <pre id=”code_snippet_’):
<div class="csl-tw"><span class="csl-dt">snippet?:?</span><span class="csl-ct">'.$title.'</span></div>
I then styled my “csl-tw” and ‘csl-title’ in my stylesheet. The styles I chose look like this (modify as needed):
.csl-tw { background:#CCCCCC; border-bottom:1px solid #B3B3B3; padding:7px 12px 4px; } .csl-dt { color:#9c9c9c; }
Additionally, to remove the top margin (white gap) so my title box and snippet box touch, in my CSS I added:
.entry-content pre.ace_editor{ margin-top:0; }
Then end result looks something like this:
CSL – With Title ImgFuture Feature Suggestions
– Add title attribute to snippet shortcode.
– It would be really neat when we create the snippet if we could have a “description field” which could be used as the shortcode title
– Some kind of snippet categories (for organization); if this is possible maybe use the category instead of a description for the titlehttps://www.ads-software.com/extend/plugins/code-snippet-library/
- The topic ‘Auto Resize Snippet Height Shortcode Title Attribute’ is closed to new replies.