@blockly/field-multilineinput 3.0.12 → 3.0.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"field_multilineinput.d.ts","sourceRoot":"","sources":["../src/field_multilineinput.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;GAEG;AAEH,OAAO,KAAK,OAAO,MAAM,cAAc,CAAC;AAExC;;GAEG;AACH,qBAAa,mBAAoB,SAAQ,OAAO,CAAC,cAAc;IAC7D;;;OAGG;IACH,SAAS,EAAE,WAAW,GAAG,IAAI,CAAQ;IAErC;;;OAGG;IAEH,SAAS,CAAC,SAAS,SAAY;IAE/B,iDAAiD;IAEjD,SAAS,CAAC,cAAc,UAAS;IAEjC;;;;;;;;;;;;;;OAcG;gBAED,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,OAAO,CAAC,KAAK,CAAC,UAAU,EAChD,SAAS,CAAC,EAAE,4BAA4B,EACxC,MAAM,CAAC,EAAE,yBAAyB;IAcpC;;;;OAIG;cAEgB,UAAU,CAAC,MAAM,EAAE,yBAAyB;IAK/D;;;;;;;OAOG;IACM,KAAK,CAAC,YAAY,EAAE,OAAO,GAAG,OAAO;IAY9C;;;;;OAKG;IACM,OAAO,CAAC,YAAY,EAAE,OAAO;IAItC;;;;;;OAMG;IACM,SAAS;IAQlB;;;;;;OAMG;IACM,SAAS,CAAC,KAAK,EAAE,OAAO;IAOjC;;OAEG;IACM,QAAQ;IAWjB;;;;;OAKG;cAEgB,eAAe,IAAI,MAAM;IA0C5C;;;;;;;;OAQG;cAEgB,cAAc,CAAC,QAAQ,EAAE,MAAM;IAOlD,2CAA2C;cAExB,OAAO;IAmF1B,uDAAuD;cAEpC,WAAW;IAwE9B;;;;;;;;;OASG;IAEM,WAAW,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,UAAU,CAAC,EAAE,OAAO;IAKpD;;;;OAIG;cAEgB,aAAa,IAAI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AItC;;;;;;OAMG;IACM,SAAS;IAQlB;;;;;;OAMG;IACM,SAAS,CAAC,KAAK,EAAE,OAAO;IAOjC;;OAEG;IACM,QAAQ;IAWjB;;;;;OAKG;cAEgB,eAAe,IAAI,MAAM;IA0C5C;;;;;;;;OAQG;cAEgB,cAAc,CAAC,QAAQ,EAAE,MAAM;IAOlD,2CAA2C;cAExB,OAAO;IAmF1B,uDAAuD;cAEpC,WAAW;IA2E9B;;;;;;;;;OASG;IAEM,WAAW,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,UAAU,CAAC,EAAE,OAAO;IAKpD;;;;OAIG;cAEgB,aAAa,IAAI,mBAAmB;IAwCvD;;;;;OAKG;IACH,WAAW,CAAC,QAAQ,EAAE,MAAM;IAW5B;;;;OAIG;IACH,WAAW,IAAI,MAAM;IAIrB;;;;;OAKG;cAEgB,mBAAmB,CAAC,CAAC,EAAE,aAAa;IAMvD;;;;;;;OAOG;WACa,QAAQ,CACtB,OAAO,EAAE,iCAAiC,GACzC,mBAAmB;CAMvB;AA2BD;;GAEG;AACH,MAAM,WAAW,yBACf,SAAQ,OAAO,CAAC,oBAAoB;IACpC,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,iCACf,SAAQ,yBAAyB;IACjC,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,MAAM,4BAA4B,GAAG,OAAO,CAAC,uBAAuB,CAAC"}
package/dist/index.js CHANGED
@@ -1,3 +1,3 @@
1
1
  /*! For license information please see index.js.LICENSE.txt */
2
- !function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e(require("blockly/core"));else if("function"==typeof define&&define.amd)define(["blockly/core"],e);else{var i="object"==typeof exports?e(require("blockly/core")):e(t.Blockly);for(var s in i)("object"==typeof exports?exports:t)[s]=i[s]}}(this,(t=>(()=>{"use strict";var e={573:e=>{e.exports=t}},i={};function s(t){var l=i[t];if(void 0!==l)return l.exports;var n=i[t]={exports:{}};return e[t](n,n.exports,s),n.exports}s.d=(t,e)=>{for(var i in e)s.o(e,i)&&!s.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},s.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),s.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var l={};return(()=>{s.r(l),s.d(l,{FieldMultilineInput:()=>e});var t=s(573);class e extends t.FieldTextInput{constructor(e,i,s){super(t.Field.SKIP_SETUP),this.textGroup=null,this.maxLines_=1/0,this.isOverflowedY_=!1,e!==t.Field.SKIP_SETUP&&(s&&this.configure_(s),this.setValue(e),i&&this.setValidator(i))}configure_(t){super.configure_(t),t.maxLines&&this.setMaxLines(t.maxLines)}toXml(t){return t.textContent=this.getValue().replace(/\n/g,"&#10;"),t}fromXml(t){this.setValue(t.textContent.replace(/&#10;/g,"\n"))}saveState(){const t=this.saveLegacyState(e);return null!==t?t:this.getValue()}loadState(e){this.loadLegacyState(t.Field,e)||this.setValue(e)}initView(){this.createBorderRect_(),this.textGroup=t.utils.dom.createSvgElement(t.utils.Svg.G,{class:"blocklyEditableText"},this.fieldGroup_)}getDisplayText_(){const e=this.getSourceBlock();if(!e)throw new Error("The field has not yet been attached to its input. Call appendField to attach it.");let i=this.getText();if(!i)return t.Field.NBSP;const s=i.split("\n");i="";const l=this.isOverflowedY_?this.maxLines_:s.length;for(let e=0;e<l;e++){let n=s[e];n.length>this.maxDisplayLength?n=n.substring(0,this.maxDisplayLength-4)+"...":this.isOverflowedY_&&e===l-1&&(n=n.substring(0,n.length-3)+"..."),n=n.replace(/\s/g,t.Field.NBSP),i+=n,e!==l-1&&(i+="\n")}return e.RTL&&(i+="‏"),i}doValueUpdate_(t){super.doValueUpdate_(t),null!==this.value_&&(this.isOverflowedY_=this.value_.split("\n").length>this.maxLines_)}render_(){const e=this.getSourceBlock();if(!e)throw new Error("The field has not yet been attached to its input. Call appendField to attach it.");let i;const s=this.textGroup;for(;i=s.firstChild;)s.removeChild(i);const l=this.getConstants();if(!l)throw Error("Constants not found");const n=this.getDisplayText_().split("\n");let o=0;for(let e=0;e<n.length;e++){const i=l.FIELD_TEXT_HEIGHT+l.FIELD_BORDER_RECT_Y_PADDING;t.utils.dom.createSvgElement(t.utils.Svg.TEXT,{class:"blocklyText blocklyMultilineText",x:l.FIELD_BORDER_RECT_X_PADDING,y:o+l.FIELD_BORDER_RECT_Y_PADDING,dy:l.FIELD_TEXT_BASELINE},s).appendChild(document.createTextNode(n[e])),o+=i}if(this.isBeingEdited_){const e=this.htmlInput_;this.isOverflowedY_?t.utils.dom.addClass(e,"blocklyHtmlTextAreaInputOverflowedY"):t.utils.dom.removeClass(e,"blocklyHtmlTextAreaInputOverflowedY")}if(this.updateSize_(),this.isBeingEdited_){e.RTL?setTimeout(this.resizeEditor_.bind(this),0):this.resizeEditor_();const i=this.htmlInput_;this.isTextValid_?(t.utils.dom.removeClass(i,"blocklyInvalidInput"),t.utils.aria.setState(i,t.utils.aria.State.INVALID,!1)):(t.utils.dom.addClass(i,"blocklyInvalidInput"),t.utils.aria.setState(i,t.utils.aria.State.INVALID,!0))}}updateSize_(){const e=this.getConstants();if(!e)throw Error("Constants not found");const i=this.textGroup.childNodes,s=e.FIELD_TEXT_FONTSIZE,l=e.FIELD_TEXT_FONTWEIGHT,n=e.FIELD_TEXT_FONTFAMILY;let o=0,r=0;for(let a=0;a<i.length;a++){const d=i[a],u=t.utils.dom.getFastTextWidth(d,s,l,n);u>o&&(o=u),r+=e.FIELD_TEXT_HEIGHT+(a>0?e.FIELD_BORDER_RECT_Y_PADDING:0)}if(this.isBeingEdited_){const e=String(this.value_).split("\n"),i=t.utils.dom.createSvgElement(t.utils.Svg.TEXT,{class:"blocklyText blocklyMultilineText"});for(let r=0;r<e.length;r++){e[r].length>this.maxDisplayLength&&(e[r]=e[r].substring(0,this.maxDisplayLength)),i.textContent=e[r];const a=t.utils.dom.getFastTextWidth(i,s,l,n);a>o&&(o=a)}const r=this.htmlInput_;o+=r.offsetWidth-r.clientWidth}this.borderRect_&&(r+=2*e.FIELD_BORDER_RECT_Y_PADDING,o+=2*e.FIELD_BORDER_RECT_X_PADDING,this.borderRect_.setAttribute("width",`${o}`),this.borderRect_.setAttribute("height",`${r}`)),this.size_.width=o,this.size_.height=r,this.positionBorderRect_()}showEditor_(t,e){super.showEditor_(t,e),this.forceRerender()}widgetCreate_(){const e=t.WidgetDiv.getDiv(),i=this.workspace_.getScale(),s=this.getConstants();if(!s)throw Error("Constants not found");const l=document.createElement("textarea");l.className="blocklyHtmlInput blocklyHtmlTextAreaInput",l.setAttribute("spellcheck",String(this.spellcheck_));const n=s.FIELD_TEXT_FONTSIZE*i+"pt";e.style.fontSize=n,l.style.fontSize=n;const o=t.FieldTextInput.BORDERRADIUS*i+"px";l.style.borderRadius=o;const r=s.FIELD_BORDER_RECT_X_PADDING*i,a=s.FIELD_BORDER_RECT_Y_PADDING*i/2;l.style.padding=a+"px "+r+"px "+a+"px "+r+"px";const d=s.FIELD_TEXT_HEIGHT+s.FIELD_BORDER_RECT_Y_PADDING;return l.style.lineHeight=d*i+"px",e.appendChild(l),l.value=l.defaultValue=this.getEditorText_(this.value_),l.setAttribute("data-untyped-default-value",String(this.value_)),l.setAttribute("data-old-value",""),t.utils.userAgent.GECKO?setTimeout(this.resizeEditor_.bind(this),0):this.resizeEditor_(),this.bindInputEvents_(l),l}setMaxLines(t){"number"==typeof t&&t>0&&t!==this.maxLines_&&(this.maxLines_=t,this.forceRerender())}getMaxLines(){return this.maxLines_}onHtmlInputKeyDown_(t){"Enter"!==t.key&&super.onHtmlInputKeyDown_(t)}static fromJson(e){return new this(t.utils.parsing.replaceMessageReferences(e.text),void 0,e)}}t.fieldRegistry.unregister("field_multilinetext"),t.fieldRegistry.register("field_multilinetext",e),t.Css.register("\n.blocklyHtmlTextAreaInput {\n font-family: monospace;\n resize: none;\n overflow: hidden;\n height: 100%;\n text-align: left;\n}\n\n.blocklyHtmlTextAreaInputOverflowedY {\n overflow-y: scroll;\n}\n")})(),l})()));
2
+ !function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e(require("blockly/core"));else if("function"==typeof define&&define.amd)define(["blockly/core"],e);else{var i="object"==typeof exports?e(require("blockly/core")):e(t.Blockly);for(var s in i)("object"==typeof exports?exports:t)[s]=i[s]}}(this,(t=>(()=>{"use strict";var e={573:e=>{e.exports=t}},i={};function s(t){var l=i[t];if(void 0!==l)return l.exports;var n=i[t]={exports:{}};return e[t](n,n.exports,s),n.exports}s.d=(t,e)=>{for(var i in e)s.o(e,i)&&!s.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},s.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),s.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var l={};return(()=>{s.r(l),s.d(l,{FieldMultilineInput:()=>e});var t=s(573);class e extends t.FieldTextInput{constructor(e,i,s){super(t.Field.SKIP_SETUP),this.textGroup=null,this.maxLines_=1/0,this.isOverflowedY_=!1,e!==t.Field.SKIP_SETUP&&(s&&this.configure_(s),this.setValue(e),i&&this.setValidator(i))}configure_(t){super.configure_(t),t.maxLines&&this.setMaxLines(t.maxLines)}toXml(t){return t.textContent=this.getValue().replace(/\n/g,"&#10;"),t}fromXml(t){this.setValue(t.textContent.replace(/&#10;/g,"\n"))}saveState(){const t=this.saveLegacyState(e);return null!==t?t:this.getValue()}loadState(e){this.loadLegacyState(t.Field,e)||this.setValue(e)}initView(){this.createBorderRect_(),this.textGroup=t.utils.dom.createSvgElement(t.utils.Svg.G,{class:"blocklyEditableText"},this.fieldGroup_)}getDisplayText_(){const e=this.getSourceBlock();if(!e)throw new Error("The field has not yet been attached to its input. Call appendField to attach it.");let i=this.getText();if(!i)return t.Field.NBSP;const s=i.split("\n");i="";const l=this.isOverflowedY_?this.maxLines_:s.length;for(let e=0;e<l;e++){let n=s[e];n.length>this.maxDisplayLength?n=n.substring(0,this.maxDisplayLength-4)+"...":this.isOverflowedY_&&e===l-1&&(n=n.substring(0,n.length-3)+"..."),n=n.replace(/\s/g,t.Field.NBSP),i+=n,e!==l-1&&(i+="\n")}return e.RTL&&(i+="‏"),i}doValueUpdate_(t){super.doValueUpdate_(t),null!==this.value_&&(this.isOverflowedY_=this.value_.split("\n").length>this.maxLines_)}render_(){const e=this.getSourceBlock();if(!e)throw new Error("The field has not yet been attached to its input. Call appendField to attach it.");let i;const s=this.textGroup;for(;i=s.firstChild;)s.removeChild(i);const l=this.getConstants();if(!l)throw Error("Constants not found");const n=this.getDisplayText_().split("\n");let o=0;for(let e=0;e<n.length;e++){const i=l.FIELD_TEXT_HEIGHT+l.FIELD_BORDER_RECT_Y_PADDING;t.utils.dom.createSvgElement(t.utils.Svg.TEXT,{class:"blocklyText blocklyMultilineText",x:l.FIELD_BORDER_RECT_X_PADDING,y:o+l.FIELD_BORDER_RECT_Y_PADDING,dy:l.FIELD_TEXT_BASELINE},s).appendChild(document.createTextNode(n[e])),o+=i}if(this.isBeingEdited_){const e=this.htmlInput_;this.isOverflowedY_?t.utils.dom.addClass(e,"blocklyHtmlTextAreaInputOverflowedY"):t.utils.dom.removeClass(e,"blocklyHtmlTextAreaInputOverflowedY")}if(this.updateSize_(),this.isBeingEdited_){e.RTL?setTimeout(this.resizeEditor_.bind(this),0):this.resizeEditor_();const i=this.htmlInput_;this.isTextValid_?(t.utils.dom.removeClass(i,"blocklyInvalidInput"),t.utils.aria.setState(i,t.utils.aria.State.INVALID,!1)):(t.utils.dom.addClass(i,"blocklyInvalidInput"),t.utils.aria.setState(i,t.utils.aria.State.INVALID,!0))}}updateSize_(){const e=this.getConstants();if(!e)throw Error("Constants not found");const i=this.textGroup.childNodes,s=e.FIELD_TEXT_FONTSIZE,l=e.FIELD_TEXT_FONTWEIGHT,n=e.FIELD_TEXT_FONTFAMILY;let o=0,r=0;for(let a=0;a<i.length;a++){const d=i[a],u=t.utils.dom.getFastTextWidth(d,s,l,n);u>o&&(o=u),r+=e.FIELD_TEXT_HEIGHT+(a>0?e.FIELD_BORDER_RECT_Y_PADDING:0)}if(this.isBeingEdited_){const e=String(this.value_).split("\n"),i=t.utils.dom.createSvgElement(t.utils.Svg.TEXT,{class:"blocklyText blocklyMultilineText"});for(let r=0;r<e.length;r++){e[r].length>this.maxDisplayLength&&(e[r]=e[r].substring(0,this.maxDisplayLength)),i.textContent=e[r];const a=t.utils.dom.getFastTextWidth(i,s,l,n);a>o&&(o=a)}const r=this.htmlInput_;o+=r.offsetWidth-r.clientWidth}this.borderRect_&&(r+=2*e.FIELD_BORDER_RECT_Y_PADDING,o+=2*e.FIELD_BORDER_RECT_X_PADDING+1,this.borderRect_.setAttribute("width",`${o}`),this.borderRect_.setAttribute("height",`${r}`)),this.size_.width=o,this.size_.height=r,this.positionBorderRect_()}showEditor_(t,e){super.showEditor_(t,e),this.forceRerender()}widgetCreate_(){const e=t.WidgetDiv.getDiv(),i=this.workspace_.getScale(),s=this.getConstants();if(!s)throw Error("Constants not found");const l=document.createElement("textarea");l.className="blocklyHtmlInput blocklyHtmlTextAreaInput",l.setAttribute("spellcheck",String(this.spellcheck_));const n=s.FIELD_TEXT_FONTSIZE*i+"pt";e.style.fontSize=n,l.style.fontSize=n;const o=t.FieldTextInput.BORDERRADIUS*i+"px";l.style.borderRadius=o;const r=s.FIELD_BORDER_RECT_X_PADDING*i,a=s.FIELD_BORDER_RECT_Y_PADDING*i/2;l.style.padding=a+"px "+r+"px "+a+"px "+r+"px";const d=s.FIELD_TEXT_HEIGHT+s.FIELD_BORDER_RECT_Y_PADDING;return l.style.lineHeight=d*i+"px",e.appendChild(l),l.value=l.defaultValue=this.getEditorText_(this.value_),l.setAttribute("data-untyped-default-value",String(this.value_)),l.setAttribute("data-old-value",""),t.utils.userAgent.GECKO?setTimeout(this.resizeEditor_.bind(this),0):this.resizeEditor_(),this.bindInputEvents_(l),l}setMaxLines(t){"number"==typeof t&&t>0&&t!==this.maxLines_&&(this.maxLines_=t,this.forceRerender())}getMaxLines(){return this.maxLines_}onHtmlInputKeyDown_(t){"Enter"!==t.key&&super.onHtmlInputKeyDown_(t)}static fromJson(e){return new this(t.utils.parsing.replaceMessageReferences(e.text),void 0,e)}}t.fieldRegistry.unregister("field_multilinetext"),t.fieldRegistry.register("field_multilinetext",e),t.Css.register("\n.blocklyHtmlTextAreaInput {\n font-family: monospace;\n resize: none;\n overflow: hidden;\n height: 100%;\n text-align: left;\n}\n\n.blocklyHtmlTextAreaInputOverflowedY {\n overflow-y: scroll;\n}\n")})(),l})()));
3
3
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","mappings":";CAAA,SAA2CA,EAAMC,GAChD,GAAsB,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,EAAQG,QAAQ,sBAC7B,GAAqB,mBAAXC,QAAyBA,OAAOC,IAC9CD,OAAO,CAAC,gBAAiBJ,OACrB,CACJ,IAAIM,EAAuB,iBAAZL,QAAuBD,EAAQG,QAAQ,iBAAmBH,EAAQD,EAAc,SAC/F,IAAI,IAAIQ,KAAKD,GAAuB,iBAAZL,QAAuBA,QAAUF,GAAMQ,GAAKD,EAAEC,EACvE,CACA,CATD,CASGC,MAAOC,qCCTVP,EAAOD,QAAUQ,ICCbC,EAA2B,CAAC,EAGhC,SAASC,EAAoBC,GAE5B,IAAIC,EAAeH,EAAyBE,GAC5C,QAAqBE,IAAjBD,EACH,OAAOA,EAAaZ,QAGrB,IAAIC,EAASQ,EAAyBE,GAAY,CAGjDX,QAAS,CAAC,GAOX,OAHAc,EAAoBH,GAAUV,EAAQA,EAAOD,QAASU,GAG/CT,EAAOD,OACf,CCrBAU,EAAoBK,EAAI,CAACf,EAASgB,KACjC,IAAI,IAAIC,KAAOD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I,eAAe3I,KAAKuE,QACpEmB,EAAU0B,aAAa,6BAA8BN,OAAO9G,KAAKuE,SACjEmB,EAAU0B,aAAa,iBAAkB,IACrC,wBAEFvB,WAAW7F,KAAK8F,cAAcC,KAAK/F,MAAO,GAE1CA,KAAK8F,gBAGP9F,KAAK4I,iBAAiBlD,GAEfA,CACT,CAQApD,YAAYD,GAEY,iBAAbA,GACPA,EAAW,GACXA,IAAarC,KAAK+B,YAElB/B,KAAK+B,UAAYM,EACjBrC,KAAK4H,gBAET,CAOAiB,cACE,OAAO7I,KAAK+B,SACd,CASmB+G,oBAAoBpB,GACvB,UAAVA,EAAEhH,KACJmB,MAAMiH,oBAAoBpB,EAE9B,CAUAqB,gBACEC,GAKA,OAAO,IAAIhJ,KAHE,yCAA+CgJ,EAAQ/E,WAG9C3D,EAAW0I,EACnC,EAOF,2BAAiC,uBAEjC,yBAA+B,sBAAuBvH,GAKtD,eAAqB","sources":["webpack://@blockly/field-multilineinput/webpack/universalModuleDefinition","webpack://@blockly/field-multilineinput/external umd {\"root\":\"Blockly\",\"commonjs\":\"blockly/core\",\"commonjs2\":\"blockly/core\",\"amd\":\"blockly/core\"}","webpack://@blockly/field-multilineinput/webpack/bootstrap","webpack://@blockly/field-multilineinput/webpack/runtime/define property getters","webpack://@blockly/field-multilineinput/webpack/runtime/hasOwnProperty shorthand","webpack://@blockly/field-multilineinput/webpack/runtime/make namespace object","webpack://@blockly/field-multilineinput/./src/field_multilineinput.ts"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory(require(\"blockly/core\"));\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([\"blockly/core\"], factory);\n\telse {\n\t\tvar a = typeof exports === 'object' ? factory(require(\"blockly/core\")) : factory(root[\"Blockly\"]);\n\t\tfor(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];\n\t}\n})(this, (__WEBPACK_EXTERNAL_MODULE__573__) => {\nreturn ","module.exports = __WEBPACK_EXTERNAL_MODULE__573__;","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","/**\n * @license\n * Copyright 2023 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\n/**\n * @fileoverview Multiline text input field.\n */\n\nimport * as Blockly from 'blockly/core';\n\n/**\n * Class for an editable text area input field.\n */\nexport class FieldMultilineInput extends Blockly.FieldTextInput {\n /**\n * The SVG group element that will contain a text element for each text row\n * when initialized.\n */\n textGroup: SVGGElement | null = null;\n\n /**\n * Defines the maximum number of lines of field.\n * If exceeded, scrolling functionality is enabled.\n */\n // eslint-disable-next-line @typescript-eslint/naming-convention\n protected maxLines_ = Infinity;\n\n /** Whether Y overflow is currently occurring. */\n // eslint-disable-next-line @typescript-eslint/naming-convention\n protected isOverflowedY_ = false;\n\n /**\n * @param value The initial content of the field. Should cast to a string.\n * Defaults to an empty string if null or undefined. Also accepts\n * Field.SKIP_SETUP if you wish to skip setup (only used by subclasses\n * that want to handle configuration and setting the field value after\n * their own constructors have run).\n * @param validator An optional function that is called to validate any\n * constraints on what the user entered. Takes the new text as an\n * argument and returns either the accepted text, a replacement text, or\n * null to abort the change.\n * @param config A map of options used to configure the field.\n * See the [field creation documentation]{@link\n * https://developers.google.com/blockly/guides/create-custom-blocks/fields/built-in-fields/multiline-text-input#creation}\n * for a list of properties this parameter supports.\n */\n constructor(\n value?: string | typeof Blockly.Field.SKIP_SETUP,\n validator?: FieldMultilineInputValidator,\n config?: FieldMultilineInputConfig,\n ) {\n super(Blockly.Field.SKIP_SETUP);\n\n if (value === Blockly.Field.SKIP_SETUP) return;\n if (config) {\n this.configure_(config);\n }\n this.setValue(value);\n if (validator) {\n this.setValidator(validator);\n }\n }\n\n /**\n * Configure the field based on the given map of options.\n *\n * @param config A map of options to configure the field based on.\n */\n // eslint-disable-next-line @typescript-eslint/naming-convention\n protected override configure_(config: FieldMultilineInputConfig) {\n super.configure_(config);\n if (config.maxLines) this.setMaxLines(config.maxLines);\n }\n\n /**\n * Serializes this field's value to XML.\n * Should only be called by Blockly.Xml.\n *\n * @param fieldElement The element to populate with info about the field's\n * state.\n * @returns The element containing info about the field's state.\n */\n override toXml(fieldElement: Element): Element {\n // Replace '\\n' characters with HTML-escaped equivalent '&#10'. This is\n // needed so the plain-text representation of the XML produced by\n // `Blockly.Xml.domToText` will appear on a single line (this is a\n // limitation of the plain-text format).\n fieldElement.textContent = (this.getValue() as string).replace(\n /\\n/g,\n '&#10;',\n );\n return fieldElement;\n }\n\n /**\n * Sets the field's value based on the given XML element. Should only be\n * called by Blockly.Xml.\n *\n * @param fieldElement The element containing info about the field's state.\n */\n override fromXml(fieldElement: Element) {\n this.setValue((fieldElement.textContent as string).replace(/&#10;/g, '\\n'));\n }\n\n /**\n * Saves this field's value.\n * This function only exists for subclasses of FieldMultilineInput which\n * predate the load/saveState API and only define to/fromXml.\n *\n * @returns The state of this field.\n */\n override saveState() {\n const legacyState = this.saveLegacyState(FieldMultilineInput);\n if (legacyState !== null) {\n return legacyState;\n }\n return this.getValue();\n }\n\n /**\n * Sets the field's value based on the given state.\n * This function only exists for subclasses of FieldMultilineInput which\n * predate the load/saveState API and only define to/fromXml.\n *\n * @param state The state of the variable to assign to this variable field.\n */\n override loadState(state: unknown) {\n if (this.loadLegacyState(Blockly.Field, state)) {\n return;\n }\n this.setValue(state);\n }\n\n /**\n * Create the block UI for this field.\n */\n override initView() {\n this.createBorderRect_();\n this.textGroup = Blockly.utils.dom.createSvgElement(\n Blockly.utils.Svg.G,\n {\n class: 'blocklyEditableText',\n },\n this.fieldGroup_,\n );\n }\n\n /**\n * Get the text from this field as displayed on screen. May differ from\n * getText due to ellipsis, and other formatting.\n *\n * @returns Currently displayed text.\n */\n // eslint-disable-next-line @typescript-eslint/naming-convention\n protected override getDisplayText_(): string {\n const block = this.getSourceBlock();\n if (!block) {\n throw new Error(\n 'The field has not yet been attached to its input. ' +\n 'Call appendField to attach it.',\n );\n }\n let textLines = this.getText();\n if (!textLines) {\n // Prevent the field from disappearing if empty.\n return Blockly.Field.NBSP;\n }\n const lines = textLines.split('\\n');\n textLines = '';\n const displayLinesNumber = this.isOverflowedY_\n ? this.maxLines_\n : lines.length;\n for (let i = 0; i < displayLinesNumber; i++) {\n let text = lines[i];\n if (text.length > this.maxDisplayLength) {\n // Truncate displayed string and add an ellipsis ('...').\n text = text.substring(0, this.maxDisplayLength - 4) + '...';\n } else if (this.isOverflowedY_ && i === displayLinesNumber - 1) {\n text = text.substring(0, text.length - 3) + '...';\n }\n // Replace whitespace with non-breaking spaces so the text doesn't\n // collapse.\n text = text.replace(/\\s/g, Blockly.Field.NBSP);\n\n textLines += text;\n if (i !== displayLinesNumber - 1) {\n textLines += '\\n';\n }\n }\n if (block.RTL) {\n // The SVG is LTR, force value to be RTL.\n textLines += '\\u200F';\n }\n return textLines;\n }\n\n /**\n * Called by setValue if the text input is valid. Updates the value of the\n * field, and updates the text of the field if it is not currently being\n * edited (i.e. handled by the htmlInput_). Is being redefined here to update\n * overflow state of the field.\n *\n * @param newValue The value to be saved. The default validator guarantees\n * that this is a string.\n */\n // eslint-disable-next-line @typescript-eslint/naming-convention\n protected override doValueUpdate_(newValue: string) {\n super.doValueUpdate_(newValue);\n if (this.value_ !== null) {\n this.isOverflowedY_ = this.value_.split('\\n').length > this.maxLines_;\n }\n }\n\n /** Updates the text of the textElement. */\n // eslint-disable-next-line @typescript-eslint/naming-convention\n protected override render_() {\n const block = this.getSourceBlock();\n if (!block) {\n throw new Error(\n 'The field has not yet been attached to its input. ' +\n 'Call appendField to attach it.',\n );\n }\n // Remove all text group children.\n let currentChild;\n const textGroup = this.textGroup as SVGElement;\n while ((currentChild = textGroup.firstChild)) {\n textGroup.removeChild(currentChild);\n }\n\n const constants = this.getConstants();\n // This can't happen, but TypeScript thinks it can and lint forbids `!.`.\n if (!constants) throw Error('Constants not found');\n // Add in text elements into the group.\n const lines = this.getDisplayText_().split('\\n');\n let y = 0;\n for (let i = 0; i < lines.length; i++) {\n const lineHeight =\n constants.FIELD_TEXT_HEIGHT + constants.FIELD_BORDER_RECT_Y_PADDING;\n const span = Blockly.utils.dom.createSvgElement(\n Blockly.utils.Svg.TEXT,\n {\n class: 'blocklyText blocklyMultilineText',\n x: constants.FIELD_BORDER_RECT_X_PADDING,\n y: y + constants.FIELD_BORDER_RECT_Y_PADDING,\n dy: constants.FIELD_TEXT_BASELINE,\n },\n textGroup,\n );\n span.appendChild(document.createTextNode(lines[i]));\n y += lineHeight;\n }\n\n if (this.isBeingEdited_) {\n const htmlInput = this.htmlInput_ as HTMLElement;\n if (this.isOverflowedY_) {\n Blockly.utils.dom.addClass(\n htmlInput,\n 'blocklyHtmlTextAreaInputOverflowedY',\n );\n } else {\n Blockly.utils.dom.removeClass(\n htmlInput,\n 'blocklyHtmlTextAreaInputOverflowedY',\n );\n }\n }\n\n this.updateSize_();\n\n if (this.isBeingEdited_) {\n if (block.RTL) {\n // in RTL, we need to let the browser reflow before resizing\n // in order to get the correct bounding box of the borderRect\n // avoiding issue #2777.\n setTimeout(this.resizeEditor_.bind(this), 0);\n } else {\n this.resizeEditor_();\n }\n const htmlInput = this.htmlInput_ as HTMLElement;\n if (!this.isTextValid_) {\n Blockly.utils.dom.addClass(htmlInput, 'blocklyInvalidInput');\n Blockly.utils.aria.setState(\n htmlInput,\n Blockly.utils.aria.State.INVALID,\n true,\n );\n } else {\n Blockly.utils.dom.removeClass(htmlInput, 'blocklyInvalidInput');\n Blockly.utils.aria.setState(\n htmlInput,\n Blockly.utils.aria.State.INVALID,\n false,\n );\n }\n }\n }\n\n /** Updates the size of the field based on the text. */\n // eslint-disable-next-line @typescript-eslint/naming-convention\n protected override updateSize_() {\n const constants = this.getConstants();\n // This can't happen, but TypeScript thinks it can and lint forbids `!.`.\n if (!constants) throw Error('Constants not found');\n const nodes = (this.textGroup as SVGElement).childNodes;\n const fontSize = constants.FIELD_TEXT_FONTSIZE;\n const fontWeight = constants.FIELD_TEXT_FONTWEIGHT;\n const fontFamily = constants.FIELD_TEXT_FONTFAMILY;\n let totalWidth = 0;\n let totalHeight = 0;\n for (let i = 0; i < nodes.length; i++) {\n const tspan = nodes[i] as SVGTextElement;\n const textWidth = Blockly.utils.dom.getFastTextWidth(\n tspan,\n fontSize,\n fontWeight,\n fontFamily,\n );\n if (textWidth > totalWidth) {\n totalWidth = textWidth;\n }\n totalHeight +=\n constants.FIELD_TEXT_HEIGHT +\n (i > 0 ? constants.FIELD_BORDER_RECT_Y_PADDING : 0);\n }\n if (this.isBeingEdited_) {\n // The default width is based on the longest line in the display text,\n // but when it's being edited, width should be calculated based on the\n // absolute longest line, even if it would be truncated after editing.\n // Otherwise we would get wrong editor width when there are more\n // lines than this.maxLines_.\n const actualEditorLines = String(this.value_).split('\\n');\n const dummyTextElement = Blockly.utils.dom.createSvgElement(\n Blockly.utils.Svg.TEXT,\n {class: 'blocklyText blocklyMultilineText'},\n );\n\n for (let i = 0; i < actualEditorLines.length; i++) {\n if (actualEditorLines[i].length > this.maxDisplayLength) {\n actualEditorLines[i] = actualEditorLines[i].substring(\n 0,\n this.maxDisplayLength,\n );\n }\n dummyTextElement.textContent = actualEditorLines[i];\n const lineWidth = Blockly.utils.dom.getFastTextWidth(\n dummyTextElement,\n fontSize,\n fontWeight,\n fontFamily,\n );\n if (lineWidth > totalWidth) {\n totalWidth = lineWidth;\n }\n }\n\n const htmlInput = this.htmlInput_ as HTMLElement;\n const scrollbarWidth = htmlInput.offsetWidth - htmlInput.clientWidth;\n totalWidth += scrollbarWidth;\n }\n if (this.borderRect_) {\n totalHeight += constants.FIELD_BORDER_RECT_Y_PADDING * 2;\n totalWidth += constants.FIELD_BORDER_RECT_X_PADDING * 2;\n this.borderRect_.setAttribute('width', `${totalWidth}`);\n this.borderRect_.setAttribute('height', `${totalHeight}`);\n }\n this.size_.width = totalWidth;\n this.size_.height = totalHeight;\n\n this.positionBorderRect_();\n }\n\n /**\n * Show the inline free-text editor on top of the text.\n * Overrides the default behaviour to force rerender in order to\n * correct block size, based on editor text.\n *\n * @param e Optional mouse event that triggered the field to open, or\n * undefined if triggered programmatically.\n * @param quietInput True if editor should be created without focus.\n * Defaults to false.\n */\n // eslint-disable-next-line @typescript-eslint/naming-convention\n override showEditor_(e?: Event, quietInput?: boolean) {\n super.showEditor_(e, quietInput);\n this.forceRerender();\n }\n\n /**\n * Create the text input editor widget.\n *\n * @returns The newly created text input editor.\n */\n // eslint-disable-next-line @typescript-eslint/naming-convention\n protected override widgetCreate_(): HTMLTextAreaElement {\n const div = Blockly.WidgetDiv.getDiv() as HTMLDivElement;\n const scale = (this.workspace_ as Blockly.WorkspaceSvg).getScale();\n const constants = this.getConstants();\n // This can't happen, but TypeScript thinks it can and lint forbids `!.`.\n if (!constants) throw Error('Constants not found');\n\n const htmlInput = document.createElement('textarea');\n htmlInput.className = 'blocklyHtmlInput blocklyHtmlTextAreaInput';\n htmlInput.setAttribute('spellcheck', String(this.spellcheck_));\n const fontSize = constants.FIELD_TEXT_FONTSIZE * scale + 'pt';\n div.style.fontSize = fontSize;\n htmlInput.style.fontSize = fontSize;\n const borderRadius = Blockly.FieldTextInput.BORDERRADIUS * scale + 'px';\n htmlInput.style.borderRadius = borderRadius;\n const paddingX = constants.FIELD_BORDER_RECT_X_PADDING * scale;\n const paddingY = (constants.FIELD_BORDER_RECT_Y_PADDING * scale) / 2;\n htmlInput.style.padding =\n paddingY + 'px ' + paddingX + 'px ' + paddingY + 'px ' + paddingX + 'px';\n const lineHeight =\n constants.FIELD_TEXT_HEIGHT + constants.FIELD_BORDER_RECT_Y_PADDING;\n htmlInput.style.lineHeight = lineHeight * scale + 'px';\n\n div.appendChild(htmlInput);\n\n htmlInput.value = htmlInput.defaultValue = this.getEditorText_(this.value_);\n htmlInput.setAttribute('data-untyped-default-value', String(this.value_));\n htmlInput.setAttribute('data-old-value', '');\n if (Blockly.utils.userAgent.GECKO) {\n // In FF, ensure the browser reflows before resizing to avoid issue #2777.\n setTimeout(this.resizeEditor_.bind(this), 0);\n } else {\n this.resizeEditor_();\n }\n\n this.bindInputEvents_(htmlInput);\n\n return htmlInput;\n }\n\n /**\n * Sets the maxLines config for this field.\n *\n * @param maxLines Defines the maximum number of lines allowed, before\n * scrolling functionality is enabled.\n */\n setMaxLines(maxLines: number) {\n if (\n typeof maxLines === 'number' &&\n maxLines > 0 &&\n maxLines !== this.maxLines_\n ) {\n this.maxLines_ = maxLines;\n this.forceRerender();\n }\n }\n\n /**\n * Returns the maxLines config of this field.\n *\n * @returns The maxLines config value.\n */\n getMaxLines(): number {\n return this.maxLines_;\n }\n\n /**\n * Handle key down to the editor. Override the text input definition of this\n * so as to not close the editor when enter is typed in.\n *\n * @param e Keyboard event.\n */\n // eslint-disable-next-line @typescript-eslint/naming-convention\n protected override onHtmlInputKeyDown_(e: KeyboardEvent) {\n if (e.key !== 'Enter') {\n super.onHtmlInputKeyDown_(e);\n }\n }\n\n /**\n * Construct a FieldMultilineInput from a JSON arg object,\n * dereferencing any string table references.\n *\n * @param options A JSON object with options (text, and spellcheck).\n * @returns The new field instance.\n * @nocollapse\n */\n static override fromJson(\n options: FieldMultilineInputFromJsonConfig,\n ): FieldMultilineInput {\n const text = Blockly.utils.parsing.replaceMessageReferences(options.text);\n // `this` might be a subclass of FieldMultilineInput if that class doesn't\n // override the static fromJson method.\n return new this(text, undefined, options);\n }\n}\n\n// Unregister legacy field_multilinetext that was in core. Delete this once\n// core Blockly no longer defines field_multilinetext.\n// If field_multilinetext is not defined in core,\n// this generates a console warning.\nBlockly.fieldRegistry.unregister('field_multilinetext');\n\nBlockly.fieldRegistry.register('field_multilinetext', FieldMultilineInput);\n\n/**\n * CSS for multiline field.\n */\nBlockly.Css.register(`\n.blocklyHtmlTextAreaInput {\n font-family: monospace;\n resize: none;\n overflow: hidden;\n height: 100%;\n text-align: left;\n}\n\n.blocklyHtmlTextAreaInputOverflowedY {\n overflow-y: scroll;\n}\n`);\n\n/**\n * Config options for the multiline input field.\n */\nexport interface FieldMultilineInputConfig\n extends Blockly.FieldTextInputConfig {\n maxLines?: number;\n}\n\n/**\n * fromJson config options for the multiline input field.\n */\nexport interface FieldMultilineInputFromJsonConfig\n extends FieldMultilineInputConfig {\n text?: string;\n}\n\n/**\n * A function that is called to validate changes to the field's value before\n * they are set.\n *\n * @see {@link https://developers.google.com/blockly/guides/create-custom-blocks/fields/validators#return_values}\n * @param newValue The value to be validated.\n * @returns One of three instructions for setting the new value: `T`, `null`,\n * or `undefined`.\n *\n * - `T` to set this function's returned value instead of `newValue`.\n *\n * - `null` to invoke `doValueInvalid_` and not set a value.\n *\n * - `undefined` to set `newValue` as is.\n */\nexport type FieldMultilineInputValidator = Blockly.FieldTextInputValidator;\n"],"names":["root","factory","exports","module","require","define","amd","a","i","this","__WEBPACK_EXTERNAL_MODULE__573__","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","undefined","__webpack_modules__","d","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","r","Symbol","toStringTag","value","FieldMultilineInput","constructor","validator","config","super","textGroup","maxLines_","Infinity","isOverflowedY_","configure_","setValue","setValidator","maxLines","setMaxLines","toXml","fieldElement","textContent","getValue","replace","fromXml","saveState","legacyState","saveLegacyState","loadState","state","loadLegacyState","initView","createBorderRect_","class","fieldGroup_","getDisplayText_","block","getSourceBlock","Error","textLines","getText","lines","split","displayLinesNumber","length","text","maxDisplayLength","substring","RTL","doValueUpdate_","newValue","value_","render_","currentChild","firstChild","removeChild","constants","getConstants","y","lineHeight","FIELD_TEXT_HEIGHT","FIELD_BORDER_RECT_Y_PADDING","x","FIELD_BORDER_RECT_X_PADDING","dy","FIELD_TEXT_BASELINE","appendChild","document","createTextNode","isBeingEdited_","htmlInput","htmlInput_","updateSize_","setTimeout","resizeEditor_","bind","isTextValid_","nodes","childNodes","fontSize","FIELD_TEXT_FONTSIZE","fontWeight","FIELD_TEXT_FONTWEIGHT","fontFamily","FIELD_TEXT_FONTFAMILY","totalWidth","totalHeight","tspan","textWidth","actualEditorLines","String","dummyTextElement","lineWidth","offsetWidth","clientWidth","borderRect_","setAttribute","size_","width","height","positionBorderRect_","showEditor_","e","quietInput","forceRerender","widgetCreate_","div","scale","workspace_","getScale","createElement","className","spellcheck_","style","borderRadius","paddingX","paddingY","padding","defaultValue","getEditorText_","bindInputEvents_","getMaxLines","onHtmlInputKeyDown_","static","options"],"sourceRoot":""}
1
+ {"version":3,"file":"index.js","mappings":";CAAA,SAA2CA,EAAMC,GAChD,GAAsB,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,EAAQG,QAAQ,sBAC7B,GAAqB,mBAAXC,QAAyBA,OAAOC,IAC9CD,OAAO,CAAC,gBAAiBJ,OACrB,CACJ,IAAIM,EAAuB,iBAAZL,QAAuBD,EAAQG,QAAQ,iBAAmBH,EAAQD,EAAc,SAC/F,IAAI,IAAIQ,KAAK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T,EAAU2C,MAAMlC,SAAWA,EAC3B,MAAMmC,EAAe,8BAAsCP,EAAQ,KACnErC,EAAU2C,MAAMC,aAAeA,EAC/B,MAAMC,EAAW3D,EAAUO,4BAA8B4C,EACnDS,EAAY5D,EAAUK,4BAA8B8C,EAAS,EACnErC,EAAU2C,MAAMI,QACdD,EAAW,MAAQD,EAAW,MAAQC,EAAW,MAAQD,EAAW,KACtE,MAAMxD,EACJH,EAAUI,kBAAoBJ,EAAUK,4BAiB1C,OAhBAS,EAAU2C,MAAMtD,WAAaA,EAAagD,EAAQ,KAElDD,EAAIxC,YAAYI,GAEhBA,EAAUlE,MAAQkE,EAAUgD,aAAe1I,KAAK2I,eAAe3I,KAAKuE,QACpEmB,EAAU0B,aAAa,6BAA8BN,OAAO9G,KAAKuE,SACjEmB,EAAU0B,aAAa,iBAAkB,IACrC,wBAEFvB,WAAW7F,KAAK8F,cAAcC,KAAK/F,MAAO,GAE1CA,KAAK8F,gBAGP9F,KAAK4I,iBAAiBlD,GAEfA,CACT,CAQApD,YAAYD,GAEY,iBAAbA,GACPA,EAAW,GACXA,IAAarC,KAAK+B,YAElB/B,KAAK+B,UAAYM,EACjBrC,KAAK4H,gBAET,CAOAiB,cACE,OAAO7I,KAAK+B,SACd,CASmB+G,oBAAoBpB,GACvB,UAAVA,EAAEhH,KACJmB,MAAMiH,oBAAoBpB,EAE9B,CAUAqB,gBACEC,GAKA,OAAO,IAAIhJ,KAHE,yCAA+CgJ,EAAQ/E,WAG9C3D,EAAW0I,EACnC,EAOF,2BAAiC,uBAEjC,yBAA+B,sBAAuBvH,GAKtD,eAAqB","sources":["webpack://@blockly/field-multilineinput/webpack/universalModuleDefinition","webpack://@blockly/field-multilineinput/external umd {\"root\":\"Blockly\",\"commonjs\":\"blockly/core\",\"commonjs2\":\"blockly/core\",\"amd\":\"blockly/core\"}","webpack://@blockly/field-multilineinput/webpack/bootstrap","webpack://@blockly/field-multilineinput/webpack/runtime/define property getters","webpack://@blockly/field-multilineinput/webpack/runtime/hasOwnProperty shorthand","webpack://@blockly/field-multilineinput/webpack/runtime/make namespace object","webpack://@blockly/field-multilineinput/./src/field_multilineinput.ts"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory(require(\"blockly/core\"));\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([\"blockly/core\"], factory);\n\telse {\n\t\tvar a = typeof exports === 'object' ? factory(require(\"blockly/core\")) : factory(root[\"Blockly\"]);\n\t\tfor(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];\n\t}\n})(this, (__WEBPACK_EXTERNAL_MODULE__573__) => {\nreturn ","module.exports = __WEBPACK_EXTERNAL_MODULE__573__;","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","/**\n * @license\n * Copyright 2023 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\n/**\n * @fileoverview Multiline text input field.\n */\n\nimport * as Blockly from 'blockly/core';\n\n/**\n * Class for an editable text area input field.\n */\nexport class FieldMultilineInput extends Blockly.FieldTextInput {\n /**\n * The SVG group element that will contain a text element for each text row\n * when initialized.\n */\n textGroup: SVGGElement | null = null;\n\n /**\n * Defines the maximum number of lines of field.\n * If exceeded, scrolling functionality is enabled.\n */\n // eslint-disable-next-line @typescript-eslint/naming-convention\n protected maxLines_ = Infinity;\n\n /** Whether Y overflow is currently occurring. */\n // eslint-disable-next-line @typescript-eslint/naming-convention\n protected isOverflowedY_ = false;\n\n /**\n * @param value The initial content of the field. Should cast to a string.\n * Defaults to an empty string if null or undefined. Also accepts\n * Field.SKIP_SETUP if you wish to skip setup (only used by subclasses\n * that want to handle configuration and setting the field value after\n * their own constructors have run).\n * @param validator An optional function that is called to validate any\n * constraints on what the user entered. Takes the new text as an\n * argument and returns either the accepted text, a replacement text, or\n * null to abort the change.\n * @param config A map of options used to configure the field.\n * See the [field creation documentation]{@link\n * https://developers.google.com/blockly/guides/create-custom-blocks/fields/built-in-fields/multiline-text-input#creation}\n * for a list of properties this parameter supports.\n */\n constructor(\n value?: string | typeof Blockly.Field.SKIP_SETUP,\n validator?: FieldMultilineInputValidator,\n config?: FieldMultilineInputConfig,\n ) {\n super(Blockly.Field.SKIP_SETUP);\n\n if (value === Blockly.Field.SKIP_SETUP) return;\n if (config) {\n this.configure_(config);\n }\n this.setValue(value);\n if (validator) {\n this.setValidator(validator);\n }\n }\n\n /**\n * Configure the field based on the given map of options.\n *\n * @param config A map of options to configure the field based on.\n */\n // eslint-disable-next-line @typescript-eslint/naming-convention\n protected override configure_(config: FieldMultilineInputConfig) {\n super.configure_(config);\n if (config.maxLines) this.setMaxLines(config.maxLines);\n }\n\n /**\n * Serializes this field's value to XML.\n * Should only be called by Blockly.Xml.\n *\n * @param fieldElement The element to populate with info about the field's\n * state.\n * @returns The element containing info about the field's state.\n */\n override toXml(fieldElement: Element): Element {\n // Replace '\\n' characters with HTML-escaped equivalent '&#10'. This is\n // needed so the plain-text representation of the XML produced by\n // `Blockly.Xml.domToText` will appear on a single line (this is a\n // limitation of the plain-text format).\n fieldElement.textContent = (this.getValue() as string).replace(\n /\\n/g,\n '&#10;',\n );\n return fieldElement;\n }\n\n /**\n * Sets the field's value based on the given XML element. Should only be\n * called by Blockly.Xml.\n *\n * @param fieldElement The element containing info about the field's state.\n */\n override fromXml(fieldElement: Element) {\n this.setValue((fieldElement.textContent as string).replace(/&#10;/g, '\\n'));\n }\n\n /**\n * Saves this field's value.\n * This function only exists for subclasses of FieldMultilineInput which\n * predate the load/saveState API and only define to/fromXml.\n *\n * @returns The state of this field.\n */\n override saveState() {\n const legacyState = this.saveLegacyState(FieldMultilineInput);\n if (legacyState !== null) {\n return legacyState;\n }\n return this.getValue();\n }\n\n /**\n * Sets the field's value based on the given state.\n * This function only exists for subclasses of FieldMultilineInput which\n * predate the load/saveState API and only define to/fromXml.\n *\n * @param state The state of the variable to assign to this variable field.\n */\n override loadState(state: unknown) {\n if (this.loadLegacyState(Blockly.Field, state)) {\n return;\n }\n this.setValue(state);\n }\n\n /**\n * Create the block UI for this field.\n */\n override initView() {\n this.createBorderRect_();\n this.textGroup = Blockly.utils.dom.createSvgElement(\n Blockly.utils.Svg.G,\n {\n class: 'blocklyEditableText',\n },\n this.fieldGroup_,\n );\n }\n\n /**\n * Get the text from this field as displayed on screen. May differ from\n * getText due to ellipsis, and other formatting.\n *\n * @returns Currently displayed text.\n */\n // eslint-disable-next-line @typescript-eslint/naming-convention\n protected override getDisplayText_(): string {\n const block = this.getSourceBlock();\n if (!block) {\n throw new Error(\n 'The field has not yet been attached to its input. ' +\n 'Call appendField to attach it.',\n );\n }\n let textLines = this.getText();\n if (!textLines) {\n // Prevent the field from disappearing if empty.\n return Blockly.Field.NBSP;\n }\n const lines = textLines.split('\\n');\n textLines = '';\n const displayLinesNumber = this.isOverflowedY_\n ? this.maxLines_\n : lines.length;\n for (let i = 0; i < displayLinesNumber; i++) {\n let text = lines[i];\n if (text.length > this.maxDisplayLength) {\n // Truncate displayed string and add an ellipsis ('...').\n text = text.substring(0, this.maxDisplayLength - 4) + '...';\n } else if (this.isOverflowedY_ && i === displayLinesNumber - 1) {\n text = text.substring(0, text.length - 3) + '...';\n }\n // Replace whitespace with non-breaking spaces so the text doesn't\n // collapse.\n text = text.replace(/\\s/g, Blockly.Field.NBSP);\n\n textLines += text;\n if (i !== displayLinesNumber - 1) {\n textLines += '\\n';\n }\n }\n if (block.RTL) {\n // The SVG is LTR, force value to be RTL.\n textLines += '\\u200F';\n }\n return textLines;\n }\n\n /**\n * Called by setValue if the text input is valid. Updates the value of the\n * field, and updates the text of the field if it is not currently being\n * edited (i.e. handled by the htmlInput_). Is being redefined here to update\n * overflow state of the field.\n *\n * @param newValue The value to be saved. The default validator guarantees\n * that this is a string.\n */\n // eslint-disable-next-line @typescript-eslint/naming-convention\n protected override doValueUpdate_(newValue: string) {\n super.doValueUpdate_(newValue);\n if (this.value_ !== null) {\n this.isOverflowedY_ = this.value_.split('\\n').length > this.maxLines_;\n }\n }\n\n /** Updates the text of the textElement. */\n // eslint-disable-next-line @typescript-eslint/naming-convention\n protected override render_() {\n const block = this.getSourceBlock();\n if (!block) {\n throw new Error(\n 'The field has not yet been attached to its input. ' +\n 'Call appendField to attach it.',\n );\n }\n // Remove all text group children.\n let currentChild;\n const textGroup = this.textGroup as SVGElement;\n while ((currentChild = textGroup.firstChild)) {\n textGroup.removeChild(currentChild);\n }\n\n const constants = this.getConstants();\n // This can't happen, but TypeScript thinks it can and lint forbids `!.`.\n if (!constants) throw Error('Constants not found');\n // Add in text elements into the group.\n const lines = this.getDisplayText_().split('\\n');\n let y = 0;\n for (let i = 0; i < lines.length; i++) {\n const lineHeight =\n constants.FIELD_TEXT_HEIGHT + constants.FIELD_BORDER_RECT_Y_PADDING;\n const span = Blockly.utils.dom.createSvgElement(\n Blockly.utils.Svg.TEXT,\n {\n class: 'blocklyText blocklyMultilineText',\n x: constants.FIELD_BORDER_RECT_X_PADDING,\n y: y + constants.FIELD_BORDER_RECT_Y_PADDING,\n dy: constants.FIELD_TEXT_BASELINE,\n },\n textGroup,\n );\n span.appendChild(document.createTextNode(lines[i]));\n y += lineHeight;\n }\n\n if (this.isBeingEdited_) {\n const htmlInput = this.htmlInput_ as HTMLElement;\n if (this.isOverflowedY_) {\n Blockly.utils.dom.addClass(\n htmlInput,\n 'blocklyHtmlTextAreaInputOverflowedY',\n );\n } else {\n Blockly.utils.dom.removeClass(\n htmlInput,\n 'blocklyHtmlTextAreaInputOverflowedY',\n );\n }\n }\n\n this.updateSize_();\n\n if (this.isBeingEdited_) {\n if (block.RTL) {\n // in RTL, we need to let the browser reflow before resizing\n // in order to get the correct bounding box of the borderRect\n // avoiding issue #2777.\n setTimeout(this.resizeEditor_.bind(this), 0);\n } else {\n this.resizeEditor_();\n }\n const htmlInput = this.htmlInput_ as HTMLElement;\n if (!this.isTextValid_) {\n Blockly.utils.dom.addClass(htmlInput, 'blocklyInvalidInput');\n Blockly.utils.aria.setState(\n htmlInput,\n Blockly.utils.aria.State.INVALID,\n true,\n );\n } else {\n Blockly.utils.dom.removeClass(htmlInput, 'blocklyInvalidInput');\n Blockly.utils.aria.setState(\n htmlInput,\n Blockly.utils.aria.State.INVALID,\n false,\n );\n }\n }\n }\n\n /** Updates the size of the field based on the text. */\n // eslint-disable-next-line @typescript-eslint/naming-convention\n protected override updateSize_() {\n const constants = this.getConstants();\n // This can't happen, but TypeScript thinks it can and lint forbids `!.`.\n if (!constants) throw Error('Constants not found');\n const nodes = (this.textGroup as SVGElement).childNodes;\n const fontSize = constants.FIELD_TEXT_FONTSIZE;\n const fontWeight = constants.FIELD_TEXT_FONTWEIGHT;\n const fontFamily = constants.FIELD_TEXT_FONTFAMILY;\n let totalWidth = 0;\n let totalHeight = 0;\n for (let i = 0; i < nodes.length; i++) {\n const tspan = nodes[i] as SVGTextElement;\n const textWidth = Blockly.utils.dom.getFastTextWidth(\n tspan,\n fontSize,\n fontWeight,\n fontFamily,\n );\n if (textWidth > totalWidth) {\n totalWidth = textWidth;\n }\n totalHeight +=\n constants.FIELD_TEXT_HEIGHT +\n (i > 0 ? constants.FIELD_BORDER_RECT_Y_PADDING : 0);\n }\n if (this.isBeingEdited_) {\n // The default width is based on the longest line in the display text,\n // but when it's being edited, width should be calculated based on the\n // absolute longest line, even if it would be truncated after editing.\n // Otherwise we would get wrong editor width when there are more\n // lines than this.maxLines_.\n const actualEditorLines = String(this.value_).split('\\n');\n const dummyTextElement = Blockly.utils.dom.createSvgElement(\n Blockly.utils.Svg.TEXT,\n {class: 'blocklyText blocklyMultilineText'},\n );\n\n for (let i = 0; i < actualEditorLines.length; i++) {\n if (actualEditorLines[i].length > this.maxDisplayLength) {\n actualEditorLines[i] = actualEditorLines[i].substring(\n 0,\n this.maxDisplayLength,\n );\n }\n dummyTextElement.textContent = actualEditorLines[i];\n const lineWidth = Blockly.utils.dom.getFastTextWidth(\n dummyTextElement,\n fontSize,\n fontWeight,\n fontFamily,\n );\n if (lineWidth > totalWidth) {\n totalWidth = lineWidth;\n }\n }\n\n const htmlInput = this.htmlInput_ as HTMLElement;\n const scrollbarWidth = htmlInput.offsetWidth - htmlInput.clientWidth;\n totalWidth += scrollbarWidth;\n }\n if (this.borderRect_) {\n totalHeight += constants.FIELD_BORDER_RECT_Y_PADDING * 2;\n // NOTE: Adding 1 extra px to prevent wrapping. Based on browser zoom,\n // the rounding of the calculated value can result in the line wrapping\n // unintentionally.\n totalWidth += constants.FIELD_BORDER_RECT_X_PADDING * 2 + 1;\n this.borderRect_.setAttribute('width', `${totalWidth}`);\n this.borderRect_.setAttribute('height', `${totalHeight}`);\n }\n this.size_.width = totalWidth;\n this.size_.height = totalHeight;\n\n this.positionBorderRect_();\n }\n\n /**\n * Show the inline free-text editor on top of the text.\n * Overrides the default behaviour to force rerender in order to\n * correct block size, based on editor text.\n *\n * @param e Optional mouse event that triggered the field to open, or\n * undefined if triggered programmatically.\n * @param quietInput True if editor should be created without focus.\n * Defaults to false.\n */\n // eslint-disable-next-line @typescript-eslint/naming-convention\n override showEditor_(e?: Event, quietInput?: boolean) {\n super.showEditor_(e, quietInput);\n this.forceRerender();\n }\n\n /**\n * Create the text input editor widget.\n *\n * @returns The newly created text input editor.\n */\n // eslint-disable-next-line @typescript-eslint/naming-convention\n protected override widgetCreate_(): HTMLTextAreaElement {\n const div = Blockly.WidgetDiv.getDiv() as HTMLDivElement;\n const scale = (this.workspace_ as Blockly.WorkspaceSvg).getScale();\n const constants = this.getConstants();\n // This can't happen, but TypeScript thinks it can and lint forbids `!.`.\n if (!constants) throw Error('Constants not found');\n\n const htmlInput = document.createElement('textarea');\n htmlInput.className = 'blocklyHtmlInput blocklyHtmlTextAreaInput';\n htmlInput.setAttribute('spellcheck', String(this.spellcheck_));\n const fontSize = constants.FIELD_TEXT_FONTSIZE * scale + 'pt';\n div.style.fontSize = fontSize;\n htmlInput.style.fontSize = fontSize;\n const borderRadius = Blockly.FieldTextInput.BORDERRADIUS * scale + 'px';\n htmlInput.style.borderRadius = borderRadius;\n const paddingX = constants.FIELD_BORDER_RECT_X_PADDING * scale;\n const paddingY = (constants.FIELD_BORDER_RECT_Y_PADDING * scale) / 2;\n htmlInput.style.padding =\n paddingY + 'px ' + paddingX + 'px ' + paddingY + 'px ' + paddingX + 'px';\n const lineHeight =\n constants.FIELD_TEXT_HEIGHT + constants.FIELD_BORDER_RECT_Y_PADDING;\n htmlInput.style.lineHeight = lineHeight * scale + 'px';\n\n div.appendChild(htmlInput);\n\n htmlInput.value = htmlInput.defaultValue = this.getEditorText_(this.value_);\n htmlInput.setAttribute('data-untyped-default-value', String(this.value_));\n htmlInput.setAttribute('data-old-value', '');\n if (Blockly.utils.userAgent.GECKO) {\n // In FF, ensure the browser reflows before resizing to avoid issue #2777.\n setTimeout(this.resizeEditor_.bind(this), 0);\n } else {\n this.resizeEditor_();\n }\n\n this.bindInputEvents_(htmlInput);\n\n return htmlInput;\n }\n\n /**\n * Sets the maxLines config for this field.\n *\n * @param maxLines Defines the maximum number of lines allowed, before\n * scrolling functionality is enabled.\n */\n setMaxLines(maxLines: number) {\n if (\n typeof maxLines === 'number' &&\n maxLines > 0 &&\n maxLines !== this.maxLines_\n ) {\n this.maxLines_ = maxLines;\n this.forceRerender();\n }\n }\n\n /**\n * Returns the maxLines config of this field.\n *\n * @returns The maxLines config value.\n */\n getMaxLines(): number {\n return this.maxLines_;\n }\n\n /**\n * Handle key down to the editor. Override the text input definition of this\n * so as to not close the editor when enter is typed in.\n *\n * @param e Keyboard event.\n */\n // eslint-disable-next-line @typescript-eslint/naming-convention\n protected override onHtmlInputKeyDown_(e: KeyboardEvent) {\n if (e.key !== 'Enter') {\n super.onHtmlInputKeyDown_(e);\n }\n }\n\n /**\n * Construct a FieldMultilineInput from a JSON arg object,\n * dereferencing any string table references.\n *\n * @param options A JSON object with options (text, and spellcheck).\n * @returns The new field instance.\n * @nocollapse\n */\n static override fromJson(\n options: FieldMultilineInputFromJsonConfig,\n ): FieldMultilineInput {\n const text = Blockly.utils.parsing.replaceMessageReferences(options.text);\n // `this` might be a subclass of FieldMultilineInput if that class doesn't\n // override the static fromJson method.\n return new this(text, undefined, options);\n }\n}\n\n// Unregister legacy field_multilinetext that was in core. Delete this once\n// core Blockly no longer defines field_multilinetext.\n// If field_multilinetext is not defined in core,\n// this generates a console warning.\nBlockly.fieldRegistry.unregister('field_multilinetext');\n\nBlockly.fieldRegistry.register('field_multilinetext', FieldMultilineInput);\n\n/**\n * CSS for multiline field.\n */\nBlockly.Css.register(`\n.blocklyHtmlTextAreaInput {\n font-family: monospace;\n resize: none;\n overflow: hidden;\n height: 100%;\n text-align: left;\n}\n\n.blocklyHtmlTextAreaInputOverflowedY {\n overflow-y: scroll;\n}\n`);\n\n/**\n * Config options for the multiline input field.\n */\nexport interface FieldMultilineInputConfig\n extends Blockly.FieldTextInputConfig {\n maxLines?: number;\n}\n\n/**\n * fromJson config options for the multiline input field.\n */\nexport interface FieldMultilineInputFromJsonConfig\n extends FieldMultilineInputConfig {\n text?: string;\n}\n\n/**\n * A function that is called to validate changes to the field's value before\n * they are set.\n *\n * @see {@link https://developers.google.com/blockly/guides/create-custom-blocks/fields/validators#return_values}\n * @param newValue The value to be validated.\n * @returns One of three instructions for setting the new value: `T`, `null`,\n * or `undefined`.\n *\n * - `T` to set this function's returned value instead of `newValue`.\n *\n * - `null` to invoke `doValueInvalid_` and not set a value.\n *\n * - `undefined` to set `newValue` as is.\n */\nexport type FieldMultilineInputValidator = Blockly.FieldTextInputValidator;\n"],"names":["root","factory","exports","module","require","define","amd","a","i","this","__WEBPACK_EXTERNAL_MODULE__573__","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","undefined","__webpack_modules__","d","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","r","Symbol","toStringTag","value","FieldMultilineInput","constructor","validator","config","super","textGroup","maxLines_","Infinity","isOverflowedY_","configure_","setValue","setValidator","maxLines","setMaxLines","toXml","fieldElement","textContent","getValue","replace","fromXml","saveState","legacyState","saveLegacyState","loadState","state","loadLegacyState","initView","createBorderRect_","class","fieldGroup_","getDisplayText_","block","getSourceBlock","Error","textLines","getText","lines","split","displayLinesNumber","length","text","maxDisplayLength","substring","RTL","doValueUpdate_","newValue","value_","render_","currentChild","firstChild","removeChild","constants","getConstants","y","lineHeight","FIELD_TEXT_HEIGHT","FIELD_BORDER_RECT_Y_PADDING","x","FIELD_BORDER_RECT_X_PADDING","dy","FIELD_TEXT_BASELINE","appendChild","document","createTextNode","isBeingEdited_","htmlInput","htmlInput_","updateSize_","setTimeout","resizeEditor_","bind","isTextValid_","nodes","childNodes","fontSize","FIELD_TEXT_FONTSIZE","fontWeight","FIELD_TEXT_FONTWEIGHT","fontFamily","FIELD_TEXT_FONTFAMILY","totalWidth","totalHeight","tspan","textWidth","actualEditorLines","String","dummyTextElement","lineWidth","offsetWidth","clientWidth","borderRect_","setAttribute","size_","width","height","positionBorderRect_","showEditor_","e","quietInput","forceRerender","widgetCreate_","div","scale","workspace_","getScale","createElement","className","spellcheck_","style","borderRadius","paddingX","paddingY","padding","defaultValue","getEditorText_","bindInputEvents_","getMaxLines","onHtmlInputKeyDown_","static","options"],"sourceRoot":""}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blockly/field-multilineinput",
3
- "version": "3.0.12",
3
+ "version": "3.0.13",
4
4
  "description": "A Blockly multilineinput field.",
5
5
  "scripts": {
6
6
  "audit:fix": "blockly-scripts auditFix",
@@ -57,5 +57,5 @@
57
57
  "engines": {
58
58
  "node": ">=8.0.0"
59
59
  },
60
- "gitHead": "7954a8fff50e41fa7c0f891e957bf9ed616361d6"
60
+ "gitHead": "0d09c5d2dfd31d370ada8393cb002a39ef3d028e"
61
61
  }
@@ -362,7 +362,10 @@ export class FieldMultilineInput extends Blockly.FieldTextInput {
362
362
  }
363
363
  if (this.borderRect_) {
364
364
  totalHeight += constants.FIELD_BORDER_RECT_Y_PADDING * 2;
365
- totalWidth += constants.FIELD_BORDER_RECT_X_PADDING * 2;
365
+ // NOTE: Adding 1 extra px to prevent wrapping. Based on browser zoom,
366
+ // the rounding of the calculated value can result in the line wrapping
367
+ // unintentionally.
368
+ totalWidth += constants.FIELD_BORDER_RECT_X_PADDING * 2 + 1;
366
369
  this.borderRect_.setAttribute('width', `${totalWidth}`);
367
370
  this.borderRect_.setAttribute('height', `${totalHeight}`);
368
371
  }