diff --git a/dist/entry.js b/dist/entry.js index 30fa439dc2..e459c11271 100644 --- a/dist/entry.js +++ b/dist/entry.js @@ -21858,19 +21858,26 @@ Entry.ExtGuide = function(b, a, d) { }; (function(b) { b.render = function() { - var a = this.blockView.getBoard(); - this.svgGroup = this.blockView.svgGroup.elem("g", {class:"extension guideGroup"}); - this.blockView.guideSvgGroup = this.svgGroup; - $(this.svgGroup).bind("mousedown touchstart", function(a) { - a.stopPropagation && a.stopPropagation(); - a.preventDefault && a.preventDefault(); - }); - var b = this.block.getCode().createThread(this.model); - !b.view && b.createView(a); - this.svgGroup.appendChild(b.getFirstBlock().view.clone()); - this.updatePos(); - this.block.getThread().view.setHasGuide(!0); - b.destroy(!1); + if (this.model) { + var a = this.blockView.getBoard(); + this.svgGroup = this.blockView.svgGroup.elem("g", {class:"extension guideGroup"}); + this.blockView.guideSvgGroup = this.svgGroup; + $(this.svgGroup).bind("mousedown touchstart", function(a) { + a.stopPropagation && a.stopPropagation(); + a.preventDefault && a.preventDefault(); + }); + var b = this.block.getCode(); + this.model[0].x = -99999; + this.model[0].y = -99999; + b = b.createThread(this.model); + !b.view && b.createView(a); + a = b.getFirstBlock().view.clone(); + a.removeAttribute("transform"); + this.svgGroup.appendChild(a); + this.updatePos(); + this.block.getThread().view.setHasGuide(!0); + b.destroy(!1); + } }; b.updatePos = function() { this.svgGroup.attr("transform", this._getTransform()); diff --git a/dist/entry.min.js b/dist/entry.min.js index a10f26cf08..b44646f32e 100644 --- a/dist/entry.min.js +++ b/dist/entry.min.js @@ -2487,8 +2487,8 @@ null===this.scope.block)if(this._callStack.length){if(a=this.scope,this.scope=th (function(b){b.callReturn=function(){};b.getParam=function(a){a=this.block.params[a];var b=new Entry.Scope(a,this.executor);return Entry.block[a.type].func.call(b,this.entity,b)};b.getParams=function(){var a=this;return this.block.params.map(function(b){if(b instanceof Entry.Block){var c=new Entry.Scope(b,a.executor);return Entry.block[b.type].func.call(c,a.entity,c)}return b})};b.getValue=function(a,b){var c=this.block.params[this._getParamIndex(a,b)],e=new Entry.Scope(c,this.executor);return Entry.block[c.type].func.call(e, this.entity,e)};b.getStringValue=function(a,b){return String(this.getValue(a,b))};b.getNumberValue=function(a,b){return Number(this.getValue(a))};b.getBooleanValue=function(a,b){return Number(this.getValue(a,b))?!0:!1};b.getField=function(a,b){return this.block.params[this._getParamIndex(a)]};b.getStringField=function(a,b){return String(this.getField(a))};b.getNumberField=function(a){return Number(this.getField(a))};b.getStatement=function(a,b){return this.executor.stepInto(this.block.statements[this._getStatementIndex(a, b)])};b._getParamIndex=function(a){this._schema||(this._schema=Entry.block[this.type]);return this._schema.paramsKeyMap[a]};b._getStatementIndex=function(a){this._schema||(this._schema=Entry.block[this.type]);return this._schema.statementsKeyMap[a]};b.die=function(){this.block=null;return Entry.STATIC.BREAK}})(Entry.Scope.prototype);Entry.BlockExtension=function(b,a){};(function(b){})(Entry.BlockExtension.prototype);Entry.ExtGuide=function(b,a,d){this.blockView=a;this.block=a.block;this.model=b.model?b.model:[];this.render()}; -(function(b){b.render=function(){var a=this.blockView.getBoard();this.svgGroup=this.blockView.svgGroup.elem("g",{class:"extension guideGroup"});this.blockView.guideSvgGroup=this.svgGroup;$(this.svgGroup).bind("mousedown touchstart",function(a){a.stopPropagation&&a.stopPropagation();a.preventDefault&&a.preventDefault()});var b=this.block.getCode().createThread(this.model);!b.view&&b.createView(a);this.svgGroup.appendChild(b.getFirstBlock().view.clone());this.updatePos();this.block.getThread().view.setHasGuide(!0); -b.destroy(!1)};b.updatePos=function(){this.svgGroup.attr("transform",this._getTransform())};b._getTransform=function(){return"translate(0,%y)".replace("%y",this.blockView.magnet.next.y)}})(Entry.ExtGuide.prototype);Entry.ExtSideTag=function(b,a,d){this.blockView=a;this.color=b.color?b.color:"#EBC576";this.text=b.text?b.text:"";this.height=b.height?Number(b.height):31*Number(b.count);this.render();this.updatePos()}; +(function(b){b.render=function(){if(this.model){var a=this.blockView.getBoard();this.svgGroup=this.blockView.svgGroup.elem("g",{class:"extension guideGroup"});this.blockView.guideSvgGroup=this.svgGroup;$(this.svgGroup).bind("mousedown touchstart",function(a){a.stopPropagation&&a.stopPropagation();a.preventDefault&&a.preventDefault()});var b=this.block.getCode();this.model[0].x=-99999;this.model[0].y=-99999;b=b.createThread(this.model);!b.view&&b.createView(a);a=b.getFirstBlock().view.clone();a.removeAttribute("transform"); +this.svgGroup.appendChild(a);this.updatePos();this.block.getThread().view.setHasGuide(!0);b.destroy(!1)}};b.updatePos=function(){this.svgGroup.attr("transform",this._getTransform())};b._getTransform=function(){return"translate(0,%y)".replace("%y",this.blockView.magnet.next.y)}})(Entry.ExtGuide.prototype);Entry.ExtSideTag=function(b,a,d){this.blockView=a;this.color=b.color?b.color:"#EBC576";this.text=b.text?b.text:"";this.height=b.height?Number(b.height):31*Number(b.count);this.render();this.updatePos()}; (function(b){b.render=function(){this.svgGroup=this.blockView.svgGroup.elem("g");$(this.svgGroup).bind("mousedown touchstart",function(a){a.stopPropagation&&a.stopPropagation();a.preventDefault&&a.preventDefault()});this.path=this.svgGroup.elem("path").attr({d:"m0,2 h-9 v"+(this.height-4)+" h9",stroke:this.color,fill:"transparent","stroke-width":"3"});this.textElement=this.svgGroup.elem("text").attr({style:"white-space: pre;","font-size":"10px","font-family":"nanumBarunRegular","class":"dragNone", fill:"#000000"});this.tspans=this.text.split("\n").map(function(a){var b=this.textElement.elem("tspan").attr({dy:"1.2em",x:"0","class":"extension sideTagTspan"});b.textContent=a;return b}.bind(this))};b.updatePos=function(){this.positionX=8*-(this.blockView.block.pointer().length-2);this.svgGroup.attr("transform","translate("+this.positionX+",0)");this.textElement.attr({y:this.height/2-12*(this.tspans.length-1)-2});var a=this.textElement.getBoundingClientRect();this.tspans.map(function(b){b.attr({x:-a.width- 14})})}})(Entry.ExtSideTag.prototype);Entry.Field=function(){}; diff --git a/src/workspace/extension/guide.js b/src/workspace/extension/guide.js index 9a77309ad9..3f975e4300 100644 --- a/src/workspace/extension/guide.js +++ b/src/workspace/extension/guide.js @@ -11,7 +11,10 @@ Entry.ExtGuide = function(content, blockView, mode) { }; (function(p) { + var TRANSFORM = "transform"; p.render = function() { + if (!this.model) return; + var board = this.blockView.getBoard(); this.svgGroup = this.blockView.svgGroup.elem("g", { class: 'extension guideGroup' @@ -27,16 +30,24 @@ Entry.ExtGuide = function(content, blockView, mode) { var block = this.block; var code = block.getCode(); + + //move blocks off the screen + //in order to prevent magneting for some reasons + this.model[0].x = -99999; + this.model[0].y = -99999; + var thread = code.createThread(this.model); !thread.view && thread.createView(board); - this.svgGroup.appendChild(thread.getFirstBlock().view.clone()); + var cloned = thread.getFirstBlock().view.clone(); + cloned.removeAttribute(TRANSFORM); + this.svgGroup.appendChild(cloned); this.updatePos(); this.block.getThread().view.setHasGuide(true); thread.destroy(false); }; p.updatePos = function() { - this.svgGroup.attr('transform', this._getTransform()); + this.svgGroup.attr(TRANSFORM, this._getTransform()); }; p._getTransform = function() {