From a5cffc11e3426c4feb5bedcf43cf04b96fe929f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=96=9F=E9=85=8C=20=E9=B5=AC=E5=85=84?= Date: Tue, 23 Feb 2016 12:33:51 +0800 Subject: [PATCH] Destruct bug fix --- .../SmartInput/CandidateAction/Heading.js | 4 ++-- .../Astro/Blog/AstroEdit/SmartInput/_this.js | 18 +++++++++++++----- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/botanjs/src/Astro/Blog/AstroEdit/SmartInput/CandidateAction/Heading.js b/botanjs/src/Astro/Blog/AstroEdit/SmartInput/CandidateAction/Heading.js index 854bb1b..22620ab 100644 --- a/botanjs/src/Astro/Blog/AstroEdit/SmartInput/CandidateAction/Heading.js +++ b/botanjs/src/Astro/Blog/AstroEdit/SmartInput/CandidateAction/Heading.js @@ -23,9 +23,9 @@ return null; }; - Heading.prototype.Process = function( key ) + Heading.prototype.Process = function( content ) { - this.visualizer.insertSnippet( "heading", { "value": key } ); + this.visualizer.insertSnippet( "heading", { "size": this.key, "value": content } ); }; Heading.prototype.Retreat = function( sender, e ) diff --git a/botanjs/src/Astro/Blog/AstroEdit/SmartInput/_this.js b/botanjs/src/Astro/Blog/AstroEdit/SmartInput/_this.js index 6c9fcc3..284810e 100644 --- a/botanjs/src/Astro/Blog/AstroEdit/SmartInput/_this.js +++ b/botanjs/src/Astro/Blog/AstroEdit/SmartInput/_this.js @@ -229,10 +229,14 @@ // Hitting ` twice escapes the ` character itself var v = sender.value.substr( 1 ); - if( v == "" ) insert = function() { return Dand.textNode( "`" ); }; - - sender.BindingBox.close( true ); + if( v == "" ) + { + insert = function() { return Dand.textNode( "`" ); }; + sender.BindingBox.close( true ); + break; + } + sender.BindingBox.close(); // Insert the code snippet with inline flag visualizer.insertSnippet( "code", { "inline": "on", "lang": "plain", "value": v } ); break; @@ -245,6 +249,7 @@ if( ModLevels.Cands().Empty && 1 < ModLevels.length ) { ModLevels.Action()( sender.value ); + sender.BindingBox.close(); break; } @@ -355,13 +360,16 @@ var ClosePanel = function( confirmed ) { - Cycle.next( function() { _self.Present = false; } ); visualizer.restoreSelection(); if( confirmed && insert != undefined ) visualizer.insertAtCaret( insert() ); - destructor.Destruct(); + // Posponing this prevents the BackQuoteBinding firing + Cycle.next( function() { + _self.Present = false; + destructor.Destruct(); + } ); }; // Advance the input level by CandidateAction