@blockly/field-multilineinput 6.0.8 → 13.1.0

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.
package/README.md CHANGED
@@ -41,11 +41,39 @@ always a valid string, while its text could be any string entered into its
41
41
  editor. Unlike a text input field, this field also supports newline characters
42
42
  entered in the editor.
43
43
 
44
+ #### Editor keyboard shortcuts
45
+
46
+ The default keyboard mapping is:
47
+
48
+ | Key | Action |
49
+ | ----------- | ------------------------------------------------- |
50
+ | Enter | Commit the value and close the editor |
51
+ | Shift+Enter | Insert a newline at the cursor |
52
+ | Escape | Revert to the original value and close the editor |
53
+
54
+ With `FieldMultilineInput.enterCommits = false` the mapping is swapped:
55
+
56
+ | Key | Action |
57
+ | ----------- | ------------------------------------------------- |
58
+ | Enter | Insert a newline at the cursor |
59
+ | Shift+Enter | Commit the value and close the editor |
60
+ | Escape | Revert to the original value and close the editor |
61
+
62
+ `enterCommits` and `showHint` are global (static) settings that apply to all
63
+ fields. Set them once before creating your blocks:
64
+
65
+ ```js
66
+ import {FieldMultilineInput} from '@blockly/field-multilineinput';
67
+
68
+ FieldMultilineInput.enterCommits = false; // default: true
69
+ FieldMultilineInput.showHint = false; // default: true
70
+ ```
71
+
44
72
  The constructor for this field accepts three optional parameters:
45
73
 
46
74
  - `value`: The default text. Defaults to `""`.
47
75
  - `validator`: A function that is called to validate what the user entered.
48
- - `config`: An object with three optional properties:
76
+ - `config`: An object with optional properties:
49
77
  - `maxLines`: The maximum number of lines displayed before scrolling
50
78
  functionality is enabled. Defaults to `Infinity`.
51
79
  - `spellcheck`: Whether spell checking is enabled. Defaults to `true`.
@@ -186,6 +214,8 @@ textMultiline.installBlock({
186
214
 
187
215
  ### API reference
188
216
 
217
+ Instance methods:
218
+
189
219
  - `setMaxLines`: Sets the maximum number of displayed lines before
190
220
  scrolling functionality is enabled.
191
221
  - `getMaxLines`: Returns the maximum number of displayed lines before
@@ -193,6 +223,15 @@ textMultiline.installBlock({
193
223
  - `setSpellcheck`: Sets whether spell checking is enabled.
194
224
  - `getSpellcheck`: Returns whether spell checking is enabled.
195
225
 
226
+ Static (global) properties:
227
+
228
+ - `FieldMultilineInput.enterCommits`: Whether pressing Enter commits the
229
+ value (`true`, default) or inserts a newline (`false`). Applies to all
230
+ fields.
231
+ - `FieldMultilineInput.showHint`: Whether the keyboard-shortcut hint bar is
232
+ shown in the editor. When `false`, no space is reserved for the hint bar.
233
+ Applies to all fields.
234
+
196
235
  ## License
197
236
 
198
237
  Apache 2.0
@@ -11,6 +11,11 @@ import * as Blockly from 'blockly/core';
11
11
  * Class for an editable text area input field.
12
12
  */
13
13
  export declare class FieldMultilineInput extends Blockly.FieldTextInput {
14
+ /**
15
+ * Minimum editor width (in SVG/workspace units) when the field is open.
16
+ * Prevents narrow editors when the initial text is very short.
17
+ */
18
+ static readonly EDITOR_MIN_WIDTH = 150;
14
19
  /**
15
20
  * The SVG group element that will contain a text element for each text row
16
21
  * when initialized.
@@ -23,6 +28,17 @@ export declare class FieldMultilineInput extends Blockly.FieldTextInput {
23
28
  protected maxLines_: number;
24
29
  /** Whether Y overflow is currently occurring. */
25
30
  protected isOverflowedY_: boolean;
31
+ /** Whether pressing Enter commits the value (default) or inserts a newline. */
32
+ static enterCommits: boolean;
33
+ /** Whether to show the keyboard-shortcut hint bar in the editor. */
34
+ static showHint: boolean;
35
+ /** The hint bar DOM element while the editor is open. */
36
+ private hintElement;
37
+ /**
38
+ * Cached natural width of the hint bar in px, keyed by scale.
39
+ * Invalidated when zoom changes to avoid stale measurements.
40
+ */
41
+ private cachedHintWidth;
26
42
  /**
27
43
  * @param value The initial content of the field. Should cast to a string.
28
44
  * Defaults to an empty string if null or undefined. Also accepts
@@ -119,6 +135,37 @@ export declare class FieldMultilineInput extends Blockly.FieldTextInput {
119
135
  * @returns The newly created text input editor.
120
136
  */
121
137
  protected widgetCreate_(): HTMLTextAreaElement;
138
+ /**
139
+ * Creates the keyboard hint bar shown at the bottom of the editor.
140
+ *
141
+ * Keys are rendered as keycaps (bordered boxes).
142
+ *
143
+ * @param heightPx The height of the hint bar in pixels.
144
+ * @returns The hint bar element.
145
+ */
146
+ private createHint;
147
+ /**
148
+ * Creates a colon separator element used between keycaps and the action icon.
149
+ *
150
+ * @returns The colon element.
151
+ */
152
+ private createHintColon;
153
+ /**
154
+ * Creates a keycap element displaying a single key label.
155
+ *
156
+ * @param label The key symbol to display.
157
+ * @returns The keycap element.
158
+ */
159
+ private createHintKeycap;
160
+ /**
161
+ * Creates a text label describing the result of a key action.
162
+ *
163
+ * Uses Blockly.Msg for i18n with hardcoded English fallbacks.
164
+ *
165
+ * @param type Either 'commit' or 'newline'.
166
+ * @returns The label element.
167
+ */
168
+ private createHintLabel;
122
169
  /**
123
170
  * Sets the maxLines config for this field.
124
171
  *
@@ -133,12 +180,25 @@ export declare class FieldMultilineInput extends Blockly.FieldTextInput {
133
180
  */
134
181
  getMaxLines(): number;
135
182
  /**
136
- * Handle key down to the editor. Override the text input definition of this
137
- * so as to not close the editor when enter is typed in.
183
+ * Handle key down to the editor.
184
+ *
185
+ * Enter commits the value and closes the editor (matching FieldTextInput).
186
+ * Shift+Enter inserts a newline at the cursor.
187
+ * All other keys are handled by the parent class (Escape reverts, Tab navigates).
138
188
  *
139
189
  * @param e Keyboard event.
140
190
  */
141
191
  protected onHtmlInputKeyDown_(e: KeyboardEvent): void;
192
+ /**
193
+ * Inserts a newline character at the current cursor position in the textarea.
194
+ *
195
+ * The browser's default Enter-key behavior inserts a newline, but
196
+ * Shift+Enter has no default character-insertion action, so we handle it
197
+ * manually here. After splicing the character we dispatch an `input` event
198
+ * to trigger Blockly's onHtmlInputChange handler (programmatic `.value`
199
+ * assignment doesn't fire `input` on its own).
200
+ */
201
+ private insertNewline;
142
202
  /**
143
203
  * Construct a FieldMultilineInput from a JSON arg object,
144
204
  * dereferencing any string table references.
@@ -1 +1 @@
1
- {"version":3,"file":"field_multilineinput.d.ts","sourceRoot":"","sources":["../src/field_multiline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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"),require("blockly/javascript"),require("blockly/dart"),require("blockly/lua"),require("blockly/php"),require("blockly/python"));else if("function"==typeof define&&define.amd)define(["blockly/core","blockly/javascript","blockly/dart","blockly/lua","blockly/php","blockly/python"],e);else{var i="object"==typeof exports?e(require("blockly/core"),require("blockly/javascript"),require("blockly/dart"),require("blockly/lua"),require("blockly/php"),require("blockly/python")):e(t.Blockly,t["Blockly.JavaScript"],t["Blockly.Dart"],t["Blockly.Lua"],t["Blockly.PHP"],t["Blockly.Python"]);for(var l in i)("object"==typeof exports?exports:t)[l]=i[l]}}(this,(t,e,i,l,o,s)=>(()=>{"use strict";var r={127:t=>{t.exports=e},157:t=>{t.exports=l},370:e=>{e.exports=t},379:t=>{t.exports=i},537:t=>{t.exports=o},557:t=>{t.exports=s}},n={};function a(t){var e=n[t];if(void 0!==e)return e.exports;var i=n[t]={exports:{}};return r[t](i,i.exports,a),i.exports}a.d=(t,e)=>{for(var i in e)a.o(e,i)&&!a.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},a.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),a.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var u={};a.r(u),a.d(u,{FieldMultilineInput:()=>f,installAllBlocks:()=>R,registerFieldMultilineInput:()=>y,textMultiline:()=>d});var d={};a.r(d),a.d(d,{BLOCK_NAME:()=>g,blockDefinition:()=>k,installBlock:()=>v,toDart:()=>I,toJavascript:()=>m,toLua:()=>x,toPhp:()=>D,toPython:()=>b});var c=a(370),h=a(127),p=a(379),_=a(157),T=a(537),E=a(557);class f extends c.FieldTextInput{constructor(t,e,i){super(c.Field.SKIP_SETUP),this.textGroup=null,this.maxLines_=1/0,this.isOverflowedY_=!1,t!==c.Field.SKIP_SETUP&&(i&&this.configure_(i),this.setValue(t),e&&this.setValidator(e))}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(f);return null!==t?t:this.getValue()}loadState(t){this.loadLegacyState(c.Field,t)||this.setValue(t)}initView(){this.createBorderRect_(),this.textGroup=c.utils.dom.createSvgElement(c.utils.Svg.G,{class:"blocklyEditableField"},this.fieldGroup_)}getDisplayText_(){const t=this.getSourceBlock();if(!t)throw new Error("The field has not yet been attached to its input. Call appendField to attach it.");let e=this.getText();if(!e)return c.Field.NBSP;const i=e.split("\n");e="";const l=this.isOverflowedY_?this.maxLines_:i.length;for(let t=0;t<l;t++){let o=i[t];o.length>this.maxDisplayLength?o=o.substring(0,this.maxDisplayLength-4)+"...":this.isOverflowedY_&&t===l-1&&(o=o.substring(0,o.length-3)+"..."),o=o.replace(/\s/g,c.Field.NBSP),e+=o,t!==l-1&&(e+="\n")}return t.RTL&&(e+="‏"),e}doValueUpdate_(t){super.doValueUpdate_(t),null!==this.value_&&(this.isOverflowedY_=this.value_.split("\n").length>this.maxLines_)}render_(){const t=this.getSourceBlock();if(!t)throw new Error("The field has not yet been attached to its input. Call appendField to attach it.");let e;const i=this.textGroup;for(;e=i.firstChild;)i.removeChild(e);const l=this.getConstants();if(!l)throw Error("Constants not found");const o=this.getDisplayText_().split("\n");let s=0;for(let t=0;t<o.length;t++){const e=l.FIELD_TEXT_HEIGHT+l.FIELD_BORDER_RECT_Y_PADDING;c.utils.dom.createSvgElement(c.utils.Svg.TEXT,{class:"blocklyText blocklyMultilineText",x:l.FIELD_BORDER_RECT_X_PADDING,y:s+l.FIELD_BORDER_RECT_Y_PADDING,dy:l.FIELD_TEXT_BASELINE},i).appendChild(document.createTextNode(o[t])),s+=e}if(this.isBeingEdited_){const t=this.htmlInput_;this.isOverflowedY_?c.utils.dom.addClass(t,"blocklyHtmlTextAreaInputOverflowedY"):c.utils.dom.removeClass(t,"blocklyHtmlTextAreaInputOverflowedY")}if(this.updateSize_(),this.isBeingEdited_){t.RTL?setTimeout(this.resizeEditor_.bind(this),0):this.resizeEditor_();const e=this.htmlInput_;this.isTextValid_?(c.utils.dom.removeClass(e,"blocklyInvalidInput"),c.utils.aria.setState(e,c.utils.aria.State.INVALID,!1)):(c.utils.dom.addClass(e,"blocklyInvalidInput"),c.utils.aria.setState(e,c.utils.aria.State.INVALID,!0))}}updateSize_(){const t=this.getConstants();if(!t)throw Error("Constants not found");const e=this.textGroup.childNodes;t.FIELD_TEXT_FONTSIZE,t.FIELD_TEXT_FONTWEIGHT,t.FIELD_TEXT_FONTFAMILY;let i=0,l=0;for(let o=0;o<e.length;o++){const s=e[o],r=c.utils.dom.getTextWidth(s);r>i&&(i=r),l+=t.FIELD_TEXT_HEIGHT+(o>0?t.FIELD_BORDER_RECT_Y_PADDING:0)}if(this.isBeingEdited_){const t=String(this.value_).split("\n"),e=c.utils.dom.createSvgElement(c.utils.Svg.TEXT,{class:"blocklyText blocklyMultilineText"});for(let l=0;l<t.length;l++){t[l].length>this.maxDisplayLength&&(t[l]=t[l].substring(0,this.maxDisplayLength)),e.textContent=t[l];const o=c.utils.dom.getTextWidth(e);o>i&&(i=o)}const l=this.htmlInput_;i+=l.offsetWidth-l.clientWidth}this.borderRect_&&(l+=2*t.FIELD_BORDER_RECT_Y_PADDING,i+=2*t.FIELD_BORDER_RECT_X_PADDING+1,this.borderRect_.setAttribute("width",`${i}`),this.borderRect_.setAttribute("height",`${l}`)),this.size_.width=i,this.size_.height=l,this.positionBorderRect_()}showEditor_(t,e){super.showEditor_(t,e),this.forceRerender()}widgetCreate_(){const t=c.WidgetDiv.getDiv(),e=this.workspace_.getScale(),i=this.getConstants();if(!i)throw Error("Constants not found");const l=document.createElement("textarea");l.className="blocklyHtmlInput blocklyHtmlTextAreaInput",l.setAttribute("spellcheck",String(this.spellcheck_));const o=i.FIELD_TEXT_FONTSIZE*e+"pt";t.style.fontSize=o,l.style.fontSize=o;const s=c.FieldTextInput.BORDERRADIUS*e+"px";l.style.borderRadius=s;const r=i.FIELD_BORDER_RECT_X_PADDING*e,n=i.FIELD_BORDER_RECT_Y_PADDING*e/2;l.style.padding=n+"px "+r+"px "+n+"px "+r+"px";const a=i.FIELD_TEXT_HEIGHT+i.FIELD_BORDER_RECT_Y_PADDING;return l.style.lineHeight=a*e+"px",t.appendChild(l),l.value=l.defaultValue=this.getEditorText_(this.value_),l.setAttribute("data-untyped-default-value",String(this.value_)),l.setAttribute("data-old-value",""),c.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(t){return new this(c.utils.parsing.replaceMessageReferences(t.text),void 0,t)}}function y(){c.fieldRegistry.register("field_multilinetext",f)}c.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");const g="text_multiline",A={type:g,message0:"%1 %2",args0:[{type:"field_image",src:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAARCAYAAADpPU2iAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAdhgAAHYYBXaITgQAAABh0RVh0U29mdHdhcmUAcGFpbnQubmV0IDQuMS42/U4J6AAAAP1JREFUOE+Vks0KQUEYhjmRIja4ABtZ2dm5A3t3Ia6AUm7CylYuQRaUhZSlLZJiQbFAyRnPN33y01HOW08z8873zpwzM4F3GWOCruvGIE4/rLaV+Nq1hVGMBqzhqlxgCys4wJA65xnogMHsQ5lujnYHTejBBCK2mE4abjCgMGhNxHgDFWjDSG07kdfVa2pZMf4ZyMAdWmpZMfYOsLiDMYMjlMB+K613QISRhTnITnsYg5yUd0DETmEoMlkFOeIT/A58iyK5E18BuTBfgYXfwNJv4P9/oEBerLylOnRhygmGdPpTTBZAPkde61lbQe4moWUvYUZYLfUNftIY4zwA5X2Z9AYnQrEAAAAASUVORK5CYII=",width:12,height:17,alt:"¶"},{type:"field_multilinetext",name:"TEXT",text:""}],output:"String",style:"text_blocks",helpUrl:"%{BKY_TEXT_TEXT_HELPURL}",tooltip:"%{BKY_TEXT_TEXT_TOOLTIP}",extensions:["parent_tooltip_when_inline"]};function m(t,e){const i=e.multiline_quote_(t.getFieldValue("TEXT")),l=-1!==i.indexOf("+")?h.Order.ADDITION:h.Order.ATOMIC;return[i,l]}function I(t,e){const i=e.multiline_quote_(t.getFieldValue("TEXT")),l=-1!==i.indexOf("+")?p.Order.ADDITIVE:p.Order.ATOMIC;return[i,l]}function x(t,e){const i=e.multiline_quote_(t.getFieldValue("TEXT")),l=-1!==i.indexOf("..")?_.Order.CONCATENATION:_.Order.ATOMIC;return[i,l]}function D(t,e){const i=e.multiline_quote_(t.getFieldValue("TEXT")),l=-1!==i.indexOf(".")?T.Order.STRING_CONCAT:T.Order.ATOMIC;return[i,l]}function b(t,e){const i=e.multiline_quote_(t.getFieldValue("TEXT")),l=-1!==i.indexOf("+")?E.Order.ADDITIVE:E.Order.ATOMIC;return[i,l]}const O=c.common.createBlockDefinitionsFromJsonArray([A]),k=O[g];function v(t={}){y(),c.common.defineBlocks(O),t.javascript&&(t.javascript.forBlock[g]=m),t.dart&&(t.dart.forBlock[g]=I),t.lua&&(t.lua.forBlock[g]=x),t.php&&(t.php.forBlock[g]=D),t.python&&(t.python.forBlock[g]=b)}const R=v;return u})());
2
+ !function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e(require("blockly/core"),require("blockly/javascript"),require("blockly/dart"),require("blockly/lua"),require("blockly/php"),require("blockly/python"));else if("function"==typeof define&&define.amd)define(["blockly/core","blockly/javascript","blockly/dart","blockly/lua","blockly/php","blockly/python"],e);else{var i="object"==typeof exports?e(require("blockly/core"),require("blockly/javascript"),require("blockly/dart"),require("blockly/lua"),require("blockly/php"),require("blockly/python")):e(t.Blockly,t["Blockly.JavaScript"],t["Blockly.Dart"],t["Blockly.Lua"],t["Blockly.PHP"],t["Blockly.Python"]);for(var n in i)("object"==typeof exports?exports:t)[n]=i[n]}}(this,(t,e,i,n,l,s)=>(()=>{"use strict";var o={370(e){e.exports=t},379(t){t.exports=i},127(t){t.exports=e},157(t){t.exports=n},537(t){t.exports=l},557(t){t.exports=s}},r={};function a(t){var e=r[t];if(void 0!==e)return e.exports;var i=r[t]={exports:{}};return o[t](i,i.exports,a),i.exports}a.d=(t,e)=>{for(var i in e)a.o(e,i)&&!a.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},a.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),a.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var c={};a.r(c),a.d(c,{FieldMultilineInput:()=>y,installAllBlocks:()=>L,registerFieldMultilineInput:()=>f,textMultiline:()=>d});var d={};a.r(d),a.d(d,{BLOCK_NAME:()=>g,blockDefinition:()=>v,installBlock:()=>k,toDart:()=>I,toJavascript:()=>b,toLua:()=>x,toPhp:()=>A,toPython:()=>D});var h=a(370),u=a(127),p=a(379),_=a(157),m=a(537),E=a(557);class y extends h.FieldTextInput{constructor(t,e,i){super(h.Field.SKIP_SETUP),this.textGroup=null,this.maxLines_=1/0,this.isOverflowedY_=!1,this.hintElement=null,this.cachedHintWidth=null,t!==h.Field.SKIP_SETUP&&(i&&this.configure_(i),this.setValue(t),e&&this.setValidator(e))}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(y);return null!==t?t:this.getValue()}loadState(t){this.loadLegacyState(h.Field,t)||this.setValue(t)}initView(){this.createBorderRect_(),this.textGroup=h.utils.dom.createSvgElement(h.utils.Svg.G,{class:"blocklyEditableField"},this.fieldGroup_),this.fieldGroup_&&h.utils.dom.addClass(this.fieldGroup_,"blocklyField")}getDisplayText_(){const t=this.getSourceBlock();if(!t)throw new Error("The field has not yet been attached to its input. Call appendField to attach it.");let e=this.getText();if(!e)return h.Field.NBSP;const i=e.split("\n");e="";const n=this.isOverflowedY_?this.maxLines_:i.length;for(let t=0;t<n;t++){let l=i[t];l.length>this.maxDisplayLength?l=l.substring(0,this.maxDisplayLength-4)+"...":this.isOverflowedY_&&t===n-1&&(l=l.substring(0,l.length-3)+"..."),l=l.replace(/\s/g,h.Field.NBSP),e+=l,t!==n-1&&(e+="\n")}return t.RTL&&(e+="‏"),e}doValueUpdate_(t){super.doValueUpdate_(t),null!==this.value_&&(this.isOverflowedY_=this.value_.split("\n").length>this.maxLines_)}render_(){const t=this.getSourceBlock();if(!t)throw new Error("The field has not yet been attached to its input. Call appendField to attach it.");let e;const i=this.textGroup;for(;e=i.firstChild;)i.removeChild(e);const n=this.getConstants();if(!n)throw Error("Constants not found");const l=this.getDisplayText_().split("\n");let s=0;for(let t=0;t<l.length;t++){const e=n.FIELD_TEXT_HEIGHT+n.FIELD_BORDER_RECT_Y_PADDING;h.utils.dom.createSvgElement(h.utils.Svg.TEXT,{class:"blocklyText blocklyMultilineText",x:n.FIELD_BORDER_RECT_X_PADDING,y:s+n.FIELD_BORDER_RECT_Y_PADDING,dy:n.FIELD_TEXT_BASELINE},i).appendChild(document.createTextNode(l[t])),s+=e}if(this.isBeingEdited_){const t=this.htmlInput_;this.isOverflowedY_?h.utils.dom.addClass(t,"blocklyHtmlTextAreaInputOverflowedY"):h.utils.dom.removeClass(t,"blocklyHtmlTextAreaInputOverflowedY")}if(this.updateSize_(),this.isBeingEdited_){t.RTL?setTimeout(this.resizeEditor_.bind(this),0):this.resizeEditor_();const e=this.htmlInput_;this.isTextValid_?(h.utils.dom.removeClass(e,"blocklyInvalidInput"),h.utils.aria.setState(e,h.utils.aria.State.INVALID,!1)):(h.utils.dom.addClass(e,"blocklyInvalidInput"),h.utils.aria.setState(e,h.utils.aria.State.INVALID,!0))}}updateSize_(){var t;const e=this.getConstants();if(!e)throw Error("Constants not found");const i=this.textGroup.childNodes;let n=0,l=0;for(let t=0;t<i.length;t++){const s=i[t],o=h.utils.dom.getTextWidth(s);o>n&&(n=o),l+=e.FIELD_TEXT_HEIGHT+(t>0?e.FIELD_BORDER_RECT_Y_PADDING:0)}if(this.isBeingEdited_){const t=String(this.value_).split("\n"),i=h.utils.dom.createSvgElement(h.utils.Svg.TEXT,{class:"blocklyText blocklyMultilineText"});for(let e=0;e<t.length;e++){t[e].length>this.maxDisplayLength&&(t[e]=t[e].substring(0,this.maxDisplayLength)),i.textContent=t[e];const l=h.utils.dom.getTextWidth(i);l>n&&(n=l)}const s=this.htmlInput_;n+=s.offsetWidth-s.clientWidth,y.showHint&&(l+=e.FIELD_TEXT_HEIGHT+e.FIELD_BORDER_RECT_Y_PADDING)}if(this.borderRect_&&(l+=2*e.FIELD_BORDER_RECT_Y_PADDING,n+=2*e.FIELD_BORDER_RECT_X_PADDING+1),this.isBeingEdited_&&(n=Math.max(n,y.EDITOR_MIN_WIDTH),y.showHint&&(null===(t=this.hintElement)||void 0===t?void 0:t.isConnected))){const t=this.workspace_.getScale();if(!this.cachedHintWidth||this.cachedHintWidth.scale!==t){this.hintElement.style.width="max-content";const e=this.hintElement.offsetWidth;this.hintElement.style.width="",e>0&&(this.cachedHintWidth={scale:t,widthPx:e})}this.cachedHintWidth&&(n=Math.max(n,this.cachedHintWidth.widthPx/t))}this.borderRect_&&(this.borderRect_.setAttribute("width",`${n}`),this.borderRect_.setAttribute("height",`${l}`)),this.size_.width=n,this.size_.height=l,this.positionBorderRect_()}showEditor_(t,e){super.showEditor_(t,e),this.forceRerender()}widgetCreate_(){const t=h.WidgetDiv.getDiv(),e=this.workspace_.getScale(),i=this.getConstants();if(!i)throw Error("Constants not found");const n=document.createElement("textarea");n.className="blocklyHtmlInput blocklyHtmlTextAreaInput",n.setAttribute("spellcheck",String(this.spellcheck_));const l=i.FIELD_TEXT_FONTSIZE*e+"pt";t.style.fontSize=l,n.style.fontSize=l;const s=h.FieldTextInput.BORDERRADIUS*e+"px";n.style.borderRadius=s;const o=i.FIELD_BORDER_RECT_X_PADDING*e,r=i.FIELD_BORDER_RECT_Y_PADDING*e/2,a=i.FIELD_TEXT_HEIGHT+i.FIELD_BORDER_RECT_Y_PADDING,c=Math.ceil(a*e),d=y.showHint?r+c:r;return n.style.padding=`${r}px ${o}px ${d}px ${o}px`,n.style.lineHeight=a*e+"px",t.appendChild(n),n.value=n.defaultValue=this.getEditorText_(this.value_),n.setAttribute("data-untyped-default-value",String(this.value_)),n.setAttribute("data-old-value",""),h.utils.userAgent.GECKO?setTimeout(this.resizeEditor_.bind(this),0):this.resizeEditor_(),this.bindInputEvents_(n),y.showHint&&(this.hintElement=this.createHint(c),this.hintElement.style.fontFamily=i.FIELD_TEXT_FONTFAMILY,t.appendChild(this.hintElement)),n}createHint(t){const e=document.createElement("div");e.className="blocklyMultilineHint",e.setAttribute("aria-hidden","true"),e.style.height=t+"px";const i=document.createElement("div");i.className="blocklyMultilineHintGroup",i.appendChild(this.createHintKeycap("⏎")),i.appendChild(this.createHintColon()),i.appendChild(this.createHintLabel(y.enterCommits?"commit":"newline")),e.appendChild(i);const n=document.createElement("div");return n.className="blocklyMultilineHintGroup",n.appendChild(this.createHintKeycap("⇧")),n.appendChild(this.createHintKeycap("⏎")),n.appendChild(this.createHintColon()),n.appendChild(this.createHintLabel(y.enterCommits?"newline":"commit")),e.appendChild(n),e}createHintColon(){const t=document.createElement("span");return t.className="blocklyMultilineHintColon",t.textContent=":",t}createHintKeycap(t){const e=document.createElement("span");return e.className="blocklyMultilineHintKey",e.textContent=t,e}createHintLabel(t){const e=document.createElement("span");return e.className="blocklyMultilineHintLabel",e.textContent="commit"===t?h.Msg.FIELD_MULTILINEINPUT_FINISH_EDITING||"Finish editing":h.Msg.FIELD_MULTILINEINPUT_NEW_LINE||"New line",e}setMaxLines(t){"number"==typeof t&&t>0&&t!==this.maxLines_&&(this.maxLines_=t,this.forceRerender())}getMaxLines(){return this.maxLines_}onHtmlInputKeyDown_(t){if("Enter"===t.key){if(t.isComposing)return;const e=t.shiftKey;(y.enterCommits?!e:e)?super.onHtmlInputKeyDown_(t):(this.insertNewline(),t.preventDefault(),t.stopPropagation())}else super.onHtmlInputKeyDown_(t)}insertNewline(){var t,e;const i=this.htmlInput_;if(!i)return;const n=null!==(t=i.selectionStart)&&void 0!==t?t:i.value.length,l=null!==(e=i.selectionEnd)&&void 0!==e?e:n;i.value=i.value.substring(0,n)+"\n"+i.value.substring(l),i.selectionStart=i.selectionEnd=n+1,i.dispatchEvent(new Event("input"))}static fromJson(t){return new this(h.utils.parsing.replaceMessageReferences(t.text),void 0,t)}}function f(){h.fieldRegistry.register("field_multilinetext",y)}y.EDITOR_MIN_WIDTH=150,y.enterCommits=!0,y.showHint=!0,h.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.blocklyMultilineHint {\n position: absolute;\n bottom: 0;\n left: 0;\n width: 100%;\n display: flex;\n justify-content: space-around;\n align-items: center;\n padding: 0 4px;\n box-sizing: border-box;\n font-size: 0.85em;\n color: rgba(0, 0, 0, 0.6);\n background-color: white;\n border-top: 1px solid rgba(0, 0, 0, 0.15);\n border-radius: 0 0 4px 4px;\n user-select: none;\n pointer-events: none;\n}\n\n.blocklyMultilineHintGroup {\n display: inline-flex;\n align-items: center;\n}\n\n.blocklyMultilineHintKey {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n min-width: 1.3em;\n height: 1.3em;\n padding: 0 0.25em;\n margin: 0 0.1em;\n border: 1px solid rgba(0, 0, 0, 0.35);\n border-radius: 3px;\n background-color: #f5f5f5;\n line-height: 1;\n box-sizing: border-box;\n}\n\n.blocklyMultilineHintColon {\n margin: 0 0.15em;\n}\n\n.blocklyMultilineHintLabel {\n white-space: nowrap;\n}\n");const g="text_multiline",T={type:g,message0:"%1 %2",args0:[{type:"field_image",src:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAARCAYAAADpPU2iAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAdhgAAHYYBXaITgQAAABh0RVh0U29mdHdhcmUAcGFpbnQubmV0IDQuMS42/U4J6AAAAP1JREFUOE+Vks0KQUEYhjmRIja4ABtZ2dm5A3t3Ia6AUm7CylYuQRaUhZSlLZJiQbFAyRnPN33y01HOW08z8873zpwzM4F3GWOCruvGIE4/rLaV+Nq1hVGMBqzhqlxgCys4wJA65xnogMHsQ5lujnYHTejBBCK2mE4abjCgMGhNxHgDFWjDSG07kdfVa2pZMf4ZyMAdWmpZMfYOsLiDMYMjlMB+K613QISRhTnITnsYg5yUd0DETmEoMlkFOeIT/A58iyK5E18BuTBfgYXfwNJv4P9/oEBerLylOnRhygmGdPpTTBZAPkde61lbQe4moWUvYUZYLfUNftIY4zwA5X2Z9AYnQrEAAAAASUVORK5CYII=",width:12,height:17,alt:"¶"},{type:"field_multilinetext",name:"TEXT",text:""}],output:"String",style:"text_blocks",helpUrl:"%{BKY_TEXT_TEXT_HELPURL}",tooltip:"%{BKY_TEXT_TEXT_TOOLTIP}",extensions:["parent_tooltip_when_inline"]};function b(t,e){const i=e.multiline_quote_(t.getFieldValue("TEXT")),n=-1!==i.indexOf("+")?u.Order.ADDITION:u.Order.ATOMIC;return[i,n]}function I(t,e){const i=e.multiline_quote_(t.getFieldValue("TEXT")),n=-1!==i.indexOf("+")?p.Order.ADDITIVE:p.Order.ATOMIC;return[i,n]}function x(t,e){const i=e.multiline_quote_(t.getFieldValue("TEXT")),n=-1!==i.indexOf("..")?_.Order.CONCATENATION:_.Order.ATOMIC;return[i,n]}function A(t,e){const i=e.multiline_quote_(t.getFieldValue("TEXT")),n=-1!==i.indexOf(".")?m.Order.STRING_CONCAT:m.Order.ATOMIC;return[i,n]}function D(t,e){const i=e.multiline_quote_(t.getFieldValue("TEXT")),n=-1!==i.indexOf("+")?E.Order.ADDITIVE:E.Order.ATOMIC;return[i,n]}const C=h.common.createBlockDefinitionsFromJsonArray([T]),v=C[g];function k(t={}){f(),h.common.defineBlocks(C),t.javascript&&(t.javascript.forBlock[g]=b),t.dart&&(t.dart.forBlock[g]=I),t.lua&&(t.lua.forBlock[g]=x),t.php&&(t.php.forBlock[g]=A),t.python&&(t.python.forBlock[g]=D)}const L=k;return c})());
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,gBAAiBA,QAAQ,sBAAuBA,QAAQ,gBAAiBA,QAAQ,eAAgBA,QAAQ,eAAgBA,QAAQ,wBAC9J,GAAqB,mBAAXC,QAAyBA,OAAOC,IAC9CD,OAAO,CAAC,eAAgB,qBAAsB,eAAgB,cAAe,cAAe,kBAAmBJ,OAC3G,CACJ,IAAIM,EAAuB,iBAAZL,QAAuBD,EAAQG,QAAQ,gBAAiBA,QAAQ,sBAAuBA,QAAQ,gBAAiBA,QAAQ,eAAgBA,QAAQ,eAAgBA,QAAQ,mBAAqBH,EAAQD,EAAc,QAAGA,EAAK,sBAAuBA,EAAK,gBAAiBA,EAAK,eAAgBA,EAAK,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djI,EACAqH,GAGA,MAAMC,EAAOD,EAAUE,iBAAiBvH,EAAMwH,cAAc,SACtDC,GACmB,IAAvBH,EAAKI,QAAQ,KAAc,QAASQ,cAAgB,QAASN,OAC/D,MAAO,CAACN,EAAMG,EAChB,CASO,SAASU,EACdnI,EACAqH,GAGA,MAAMC,EAAOD,EAAUE,iBAAiBvH,EAAMwH,cAAc,SACtDC,GACmB,IAAvBH,EAAKI,QAAQ,KAAc,QAAYI,SAAW,QAAYF,OAChE,MAAO,CAACN,EAAMG,EAChB,CAEA,MAAMW,EAAkB,SAAcC,oCAAoC,CACxE5B,IAIW6B,EAAkBF,EAAgB5B,GAQxC,SAAS+B,EAAaC,EAAmB,CAAC,GAC/ClC,IACA,SAAcmC,aAAaL,GACvBI,EAAKE,aAAYF,EAAKE,WAAWC,SAASnC,GAAcY,GACxDoB,EAAKI,OAAMJ,EAAKI,KAAKD,SAASnC,GAAcqB,GAC5CW,EAAKK,MAAKL,EAAKK,IAAIF,SAASnC,GAAcuB,GAC1CS,EAAKM,MAAKN,EAAKM,IAAIH,SAASnC,GAAcyB,GAC1CO,EAAKO,SAAQP,EAAKO,OAAOJ,SAASnC,GAAc2B,EACtD,CCzJO,MAAMa,EAAmB,E","sources":["webpack://@blockly/field-multilineinput/webpack/universalModuleDefinition","webpack://@blockly/field-multilineinput/external umd {\"root\":\"Blockly.JavaScript\",\"commonjs\":\"blockly/javascript\",\"commonjs2\":\"blockly/javascript\",\"amd\":\"blockly/javascript\"}","webpack://@blockly/field-multilineinput/external umd {\"root\":\"Blockly.Lua\",\"commonjs\":\"blockly/lua\",\"commonjs2\":\"blockly/lua\",\"amd\":\"blockly/lua\"}","webpack://@blockly/field-multilineinput/external umd {\"root\":\"Blockly\",\"commonjs\":\"blockly/core\",\"commonjs2\":\"blockly/core\",\"amd\":\"blockly/core\"}","webpack://@blockly/field-multilineinput/external umd {\"root\":\"Blockly.Dart\",\"commonjs\":\"blockly/dart\",\"commonjs2\":\"blockly/dart\",\"amd\":\"blockly/dart\"}","webpack://@blockly/field-multilineinput/external umd {\"root\":\"Blockly.PHP\",\"commonjs\":\"blockly/php\",\"commonjs2\":\"blockly/php\",\"amd\":\"blockly/php\"}","webpack://@blockly/field-multilineinput/external umd {\"root\":\"Blockly.Python\",\"commonjs\":\"blockly/python\",\"commonjs2\":\"blockly/python\",\"amd\":\"blockly/python\"}","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","webpack://@blockly/field-multilineinput/./src/blocks/textMultiline.ts","webpack://@blockly/field-multilineinput/./src/index.ts"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory(require(\"blockly/core\"), require(\"blockly/javascript\"), require(\"blockly/dart\"), require(\"blockly/lua\"), require(\"blockly/php\"), require(\"blockly/python\"));\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([\"blockly/core\", \"blockly/javascript\", \"blockly/dart\", \"blockly/lua\", \"blockly/php\", \"blockly/python\"], factory);\n\telse {\n\t\tvar a = typeof exports === 'object' ? factory(require(\"blockly/core\"), require(\"blockly/javascript\"), require(\"blockly/dart\"), require(\"blockly/lua\"), require(\"blockly/php\"), require(\"blockly/python\")) : factory(root[\"Blockly\"], root[\"Blockly.JavaScript\"], root[\"Blockly.Dart\"], root[\"Blockly.Lua\"], root[\"Blockly.PHP\"], root[\"Blockly.Python\"]);\n\t\tfor(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];\n\t}\n})(this, (__WEBPACK_EXTERNAL_MODULE__370__, __WEBPACK_EXTERNAL_MODULE__127__, __WEBPACK_EXTERNAL_MODULE__379__, __WEBPACK_EXTERNAL_MODULE__157__, __WEBPACK_EXTERNAL_MODULE__537__, __WEBPACK_EXTERNAL_MODULE__557__) => {\nreturn ","module.exports = __WEBPACK_EXTERNAL_MODULE__127__;","module.exports = __WEBPACK_EXTERNAL_MODULE__157__;","module.exports = __WEBPACK_EXTERNAL_MODULE__370__;","module.exports = __WEBPACK_EXTERNAL_MODULE__379__;","module.exports = __WEBPACK_EXTERNAL_MODULE__537__;","module.exports = __WEBPACK_EXTERNAL_MODULE__557__;","// 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: 'blocklyEditableField',\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.getTextWidth(tspan);\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.getTextWidth(dummyTextElement);\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/**\n * Register the field and any dependencies.\n */\nexport function registerFieldMultilineInput() {\n Blockly.fieldRegistry.register('field_multilinetext', FieldMultilineInput);\n}\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","/**\n * @license\n * Copyright 2024 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport {Block, common as BlocklyCommon} from 'blockly/core';\nimport {\n JavascriptGenerator,\n Order as JavascriptOrder,\n} from 'blockly/javascript';\nimport {DartGenerator, Order as DartOrder} from 'blockly/dart';\nimport {LuaGenerator, Order as LuaOrder} from 'blockly/lua';\nimport {PhpGenerator, Order as PhpOrder} from 'blockly/php';\nimport {PythonGenerator, Order as PythonOrder} from 'blockly/python';\nimport {registerFieldMultilineInput} from '../field_multilineinput';\nimport {Generators} from './generatorsType';\n\n/** The name this block is registered under. */\nexport const BLOCK_NAME = 'text_multiline';\n\n// Block for multiline text input.\nconst jsonDefinition = {\n type: BLOCK_NAME,\n message0: '%1 %2',\n args0: [\n {\n type: 'field_image',\n src:\n 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAARCAYAAADpP' +\n 'U2iAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAdhgAAHYYBXaITgQAAABh0RVh0' +\n 'U29mdHdhcmUAcGFpbnQubmV0IDQuMS42/U4J6AAAAP1JREFUOE+Vks0KQUEYhjm' +\n 'RIja4ABtZ2dm5A3t3Ia6AUm7CylYuQRaUhZSlLZJiQbFAyRnPN33y01HOW08z88' +\n '73zpwzM4F3GWOCruvGIE4/rLaV+Nq1hVGMBqzhqlxgCys4wJA65xnogMHsQ5luj' +\n 'nYHTejBBCK2mE4abjCgMGhNxHgDFWjDSG07kdfVa2pZMf4ZyMAdWmpZMfYOsLiD' +\n 'MYMjlMB+K613QISRhTnITnsYg5yUd0DETmEoMlkFOeIT/A58iyK5E18BuTBfgYX' +\n 'fwNJv4P9/oEBerLylOnRhygmGdPpTTBZAPkde61lbQe4moWUvYUZYLfUNftIY4z' +\n 'wA5X2Z9AYnQrEAAAAASUVORK5CYII=',\n width: 12,\n height: 17,\n alt: '\\u00B6',\n },\n {\n type: 'field_multilinetext',\n name: 'TEXT',\n text: '',\n },\n ],\n output: 'String',\n style: 'text_blocks',\n helpUrl: '%{BKY_TEXT_TEXT_HELPURL}',\n tooltip: '%{BKY_TEXT_TEXT_TOOLTIP}',\n extensions: ['parent_tooltip_when_inline'],\n};\n\n/**\n * Javascript block generator function.\n *\n * @param block The Block instance to generate code for.\n * @param generator The JavascriptGenerator calling the function.\n * @returns A tuple containing the code string and precedence.\n */\nexport function toJavascript(\n block: Block,\n generator: JavascriptGenerator,\n): [string, JavascriptOrder] {\n // Text value.\n const code = generator.multiline_quote_(block.getFieldValue('TEXT'));\n const order =\n code.indexOf('+') !== -1\n ? JavascriptOrder.ADDITION\n : JavascriptOrder.ATOMIC;\n return [code, order];\n}\n\n/**\n * Dart block generator function.\n *\n * @param block The Block instance to generate code for.\n * @param generator The DartGenerator calling the function.\n * @returns A tuple containing the code string and precedence.\n */\nexport function toDart(\n block: Block,\n generator: DartGenerator,\n): [string, DartOrder] {\n // Text value.\n const code = generator.multiline_quote_(block.getFieldValue('TEXT'));\n const order =\n code.indexOf('+') !== -1 ? DartOrder.ADDITIVE : DartOrder.ATOMIC;\n return [code, order];\n}\n\n/**\n * Lua block generator function.\n *\n * @param block The Block instance to generate code for.\n * @param generator The LuaGenerator calling the function.\n * @returns A tuple containing the code string and precedence.\n */\nexport function toLua(\n block: Block,\n generator: LuaGenerator,\n): [string, LuaOrder] {\n // Text value.\n const code = generator.multiline_quote_(block.getFieldValue('TEXT'));\n const order =\n code.indexOf('..') !== -1 ? LuaOrder.CONCATENATION : LuaOrder.ATOMIC;\n return [code, order];\n}\n\n/**\n * PHP block generator function.\n *\n * @param block The Block instance to generate code for.\n * @param generator The PhpGenerator calling the function.\n * @returns A tuple containing the code string and precedence.\n */\nexport function toPhp(\n block: Block,\n generator: PhpGenerator,\n): [string, PhpOrder] {\n // Text value.\n const code = generator.multiline_quote_(block.getFieldValue('TEXT'));\n const order =\n code.indexOf('.') !== -1 ? PhpOrder.STRING_CONCAT : PhpOrder.ATOMIC;\n return [code, order];\n}\n\n/**\n * Python block generator function.\n *\n * @param block The Block instance to generate code for.\n * @param generator The PythonGenerator calling the function.\n * @returns A tuple containing the code string and precedence.\n */\nexport function toPython(\n block: Block,\n generator: PythonGenerator,\n): [string, PythonOrder] {\n // Text value.\n const code = generator.multiline_quote_(block.getFieldValue('TEXT'));\n const order =\n code.indexOf('+') !== -1 ? PythonOrder.ADDITIVE : PythonOrder.ATOMIC;\n return [code, order];\n}\n\nconst definitionsDict = BlocklyCommon.createBlockDefinitionsFromJsonArray([\n jsonDefinition,\n]);\n\n/** The text_multiline BlockDefinition. */\nexport const blockDefinition = definitionsDict[BLOCK_NAME];\n\n/**\n * Install the `text_multiline` block and all of its dependencies.\n *\n * @param gens The CodeGenerators to install per-block\n * generators on.\n */\nexport function installBlock(gens: Generators = {}) {\n registerFieldMultilineInput();\n BlocklyCommon.defineBlocks(definitionsDict);\n if (gens.javascript) gens.javascript.forBlock[BLOCK_NAME] = toJavascript;\n if (gens.dart) gens.dart.forBlock[BLOCK_NAME] = toDart;\n if (gens.lua) gens.lua.forBlock[BLOCK_NAME] = toLua;\n if (gens.php) gens.php.forBlock[BLOCK_NAME] = toPhp;\n if (gens.python) gens.python.forBlock[BLOCK_NAME] = toPython;\n}\n","/**\n * @license\n * Copyright 2023 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport * as textMultiline from './blocks/textMultiline';\n\nexport * from './field_multilineinput';\n\n// Re-export all parts of the block definition.\nexport * as textMultiline from './blocks/textMultiline';\n\n// This package currently exports a single block. More may\n// be added later.\nexport const installAllBlocks = textMultiline.installBlock;\n"],"names":["root","factory","exports","module","require","define","amd","a","i","this","__WEBPACK_EXTERNAL_MODULE__370__","__WEBPACK_EXTERNAL_MODULE__127__","__WEBPACK_EXTERNAL_MODULE__379__","__WEBPACK_EXTERNAL_MODULE__157__","__WEBPACK_EXTERNAL_MODULE__537__","__WEBPACK_EXTERNAL_MODULE__557__","__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","SKIP_SETUP","textGroup","maxLines_","Infinity","isOverflowedY_","configure_","setValue","setValidator","maxLines","setMaxLines","toXml","fieldElement","textContent","getValue","replace","fromXml","saveState","legacyState","saveLegacyState","loadState","state","loadLegacyState","initView","createBorderRect_","dom","createSvgElement","Svg","G","class","fieldGroup_","getDisplayText_","block","getSourceBlock","Error","textLines","getText","NBSP","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","TEXT","x","FIELD_BORDER_RECT_X_PADDING","dy","FIELD_TEXT_BASELINE","appendChild","document","createTextNode","isBeingEdited_","htmlInput","htmlInput_","addClass","removeClass","updateSize_","setTimeout","resizeEditor_","bind","isTextValid_","aria","setState","State","INVALID","nodes","childNodes","FIELD_TEXT_FONTSIZE","FIELD_TEXT_FONTWEIGHT","FIELD_TEXT_FONTFAMILY","totalWidth","totalHeight","tspan","textWidth","getTextWidth","actualEditorLines","String","dummyTextElement","lineWidth","offsetWidth","clientWidth","borderRect_","setAttribute","size_","width","height","positionBorderRect_","showEditor_","e","quietInput","forceRerender","widgetCreate_","div","getDiv","scale","workspace_","getScale","createElement","className","spellcheck_","fontSize","style","borderRadius","BORDERRADIUS","paddingX","paddingY","padding","defaultValue","getEditorText_","userAgent","GECKO","bindInputEvents_","getMaxLines","onHtmlInputKeyDown_","fromJson","options","parsing","replaceMessageReferences","registerFieldMultilineInput","register","BLOCK_NAME","jsonDefinition","type","message0","args0","src","alt","name","output","helpUrl","tooltip","extensions","toJavascript","generator","code","multiline_quote_","getFieldValue","order","indexOf","ADDITION","ATOMIC","toDart","ADDITIVE","toLua","CONCATENATION","toPhp","STRING_CONCAT","toPython","definitionsDict","createBlockDefinitionsFromJsonArray","blockDefinition","installBlock","gens","defineBlocks","javascript","forBlock","dart","lua","php","python","installAllBlocks"],"sourceRoot":""}
1
+ {"version":3,"file":"index.js","mappings":";CAAA,SAAAA,EAAAC,GACA,oBAAAC,SAAA,iBAAAC,OACAA,OAAAD,QAAAD,EAAAG,QAAA,gBAAAA,QAAA,sBAAAA,QAAA,gBAAAA,QAAA,eAAAA,QAAA,eAAAA,QAAA,wBACA,sBAAAC,QAAAA,OAAAC,IACAD,OAAA,kGAAAJ,OACA,CACA,IAAAM,EAAA,iBAAAL,QAAAD,EAAAG,QAAA,gBAAAA,QAAA,sBAAAA,QAAA,gBAAAA,QAAA,eAAAA,QAAA,eAAAA,QAAA,mBAAAH,EAAAD,EAAA,QAAAA,EAAA,sBAAAA,EAAA,gBAAAA,EAAA,eAAAA,EAAA,eAAAA,EAAA,mBACA,QAAAQ,KAAAD,GAAA,iBAAAL,QAAAA,QAAAF,GAAAQ,GAAAD,EAAAC,EACA,CACC,CATD,CASCC,KAAA,CAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,qCCTDZ,EAAAD,QAAAQ,UCAAP,EAAAD,QAAAU,UCAAT,EAAAD,QAAAS,UCAAR,EAAAD,QAAAW,UCAAV,EAAAD,QAAAY,UCAAX,EAAAD,QAAAa,ICCAC,EAAA,GAGA,SAAAC,EAAAC,GAEA,IAAAC,EAAAH,EAAAE,GACA,QAAAE,IAAAD,EACA,OAAAA,EAAAjB,QAGA,IAAAC,EAAAa,EAAAE,GAAA,CAGAhB,QAAA,IAOA,OAHAmB,EAAAH,GAAAf,EAAAA,EAAAD,QAAAe,GAGAd,EAAAD,OACA,CCrBAe,EAAAK,EAAA,CAAApB,EAAAqB,KACA,QAAAC,KAAAD,EACAN,EAAAQ,EAAAF,EAAAC,KAAAP,EAAAQ,EAAAvB,EAAAsB,IACAE,OAAAC,eAAAzB,EAAAsB,EAAA,CAAyCI,YAAA,EAAAC,IAAA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,EACd7K,EACA0J,GAGA,MAAMC,EAAOD,EAAUE,iBAAiB5J,EAAM6J,cAAc,SACtDC,GACmB,IAAvBH,EAAKI,QAAQ,KAAce,EAAAb,MAAYK,SAAWQ,EAAAb,MAAYE,OAChE,MAAO,CAACR,EAAMG,EAChB,CAEA,MAAMiB,EAAkBzN,EAAA0N,OAAcC,oCAAoC,CACxElC,IAIWmC,EAAkBH,EAAgBjC,GAQxC,SAASqC,EAAaC,EAAmB,IAC9C1C,IACApL,EAAA0N,OAAcK,aAAaN,GACvBK,EAAKE,aAAYF,EAAKE,WAAWC,SAASzC,GAAcW,GACxD2B,EAAKI,OAAMJ,EAAKI,KAAKD,SAASzC,GAAcsB,GAC5CgB,EAAKK,MAAKL,EAAKK,IAAIF,SAASzC,GAAcyB,GAC1Ca,EAAKM,MAAKN,EAAKM,IAAIH,SAASzC,GAAc4B,GAC1CU,EAAKO,SAAQP,EAAKO,OAAOJ,SAASzC,GAAc+B,EACtD,CCzJO,MAAMe,EAAmBT","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/external umd {\"root\":\"Blockly.Dart\",\"commonjs\":\"blockly/dart\",\"commonjs2\":\"blockly/dart\",\"amd\":\"blockly/dart\"}","webpack://@blockly/field-multilineinput/external umd {\"root\":\"Blockly.JavaScript\",\"commonjs\":\"blockly/javascript\",\"commonjs2\":\"blockly/javascript\",\"amd\":\"blockly/javascript\"}","webpack://@blockly/field-multilineinput/external umd {\"root\":\"Blockly.Lua\",\"commonjs\":\"blockly/lua\",\"commonjs2\":\"blockly/lua\",\"amd\":\"blockly/lua\"}","webpack://@blockly/field-multilineinput/external umd {\"root\":\"Blockly.PHP\",\"commonjs\":\"blockly/php\",\"commonjs2\":\"blockly/php\",\"amd\":\"blockly/php\"}","webpack://@blockly/field-multilineinput/external umd {\"root\":\"Blockly.Python\",\"commonjs\":\"blockly/python\",\"commonjs2\":\"blockly/python\",\"amd\":\"blockly/python\"}","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","webpack://@blockly/field-multilineinput/./src/blocks/textMultiline.ts","webpack://@blockly/field-multilineinput/./src/index.ts"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory(require(\"blockly/core\"), require(\"blockly/javascript\"), require(\"blockly/dart\"), require(\"blockly/lua\"), require(\"blockly/php\"), require(\"blockly/python\"));\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([\"blockly/core\", \"blockly/javascript\", \"blockly/dart\", \"blockly/lua\", \"blockly/php\", \"blockly/python\"], factory);\n\telse {\n\t\tvar a = typeof exports === 'object' ? factory(require(\"blockly/core\"), require(\"blockly/javascript\"), require(\"blockly/dart\"), require(\"blockly/lua\"), require(\"blockly/php\"), require(\"blockly/python\")) : factory(root[\"Blockly\"], root[\"Blockly.JavaScript\"], root[\"Blockly.Dart\"], root[\"Blockly.Lua\"], root[\"Blockly.PHP\"], root[\"Blockly.Python\"]);\n\t\tfor(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];\n\t}\n})(this, (__WEBPACK_EXTERNAL_MODULE__370__, __WEBPACK_EXTERNAL_MODULE__127__, __WEBPACK_EXTERNAL_MODULE__379__, __WEBPACK_EXTERNAL_MODULE__157__, __WEBPACK_EXTERNAL_MODULE__537__, __WEBPACK_EXTERNAL_MODULE__557__) => {\nreturn ","module.exports = __WEBPACK_EXTERNAL_MODULE__370__;","module.exports = __WEBPACK_EXTERNAL_MODULE__379__;","module.exports = __WEBPACK_EXTERNAL_MODULE__127__;","module.exports = __WEBPACK_EXTERNAL_MODULE__157__;","module.exports = __WEBPACK_EXTERNAL_MODULE__537__;","module.exports = __WEBPACK_EXTERNAL_MODULE__557__;","// 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 * Minimum editor width (in SVG/workspace units) when the field is open.\n * Prevents narrow editors when the initial text is very short.\n */\n\n static readonly EDITOR_MIN_WIDTH = 150;\n\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 /** Whether pressing Enter commits the value (default) or inserts a newline. */\n static enterCommits = true;\n\n /** Whether to show the keyboard-shortcut hint bar in the editor. */\n static showHint = true;\n\n /** The hint bar DOM element while the editor is open. */\n private hintElement: HTMLDivElement | null = null;\n\n /**\n * Cached natural width of the hint bar in px, keyed by scale.\n * Invalidated when zoom changes to avoid stale measurements.\n */\n private cachedHintWidth: {scale: number; widthPx: number} | null = null;\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: 'blocklyEditableField',\n },\n this.fieldGroup_,\n );\n if (this.fieldGroup_) {\n Blockly.utils.dom.addClass(this.fieldGroup_, 'blocklyField');\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 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.getTextWidth(tspan);\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.getTextWidth(dummyTextElement);\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 (FieldMultilineInput.showHint) {\n // Reserve a row at the bottom of the editor for the keyboard hint bar.\n // The textarea's padding-bottom (set in widgetCreate_) keeps the text\n // and caret out of this reserved strip.\n totalHeight +=\n constants.FIELD_TEXT_HEIGHT + constants.FIELD_BORDER_RECT_Y_PADDING;\n }\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 }\n if (this.isBeingEdited_) {\n totalWidth = Math.max(totalWidth, FieldMultilineInput.EDITOR_MIN_WIDTH);\n\n // Measure the hint bar's natural width to make sure the editor is wide enough.\n if (FieldMultilineInput.showHint && this.hintElement?.isConnected) {\n const scale = (this.workspace_ as Blockly.WorkspaceSvg).getScale();\n if (!this.cachedHintWidth || this.cachedHintWidth.scale !== scale) {\n // Temporarily let the element size to its content to measure its\n // natural width, unaffected by the current WidgetDiv width.\n this.hintElement.style.width = 'max-content';\n const widthPx = this.hintElement.offsetWidth;\n this.hintElement.style.width = '';\n if (widthPx > 0) this.cachedHintWidth = {scale, widthPx};\n }\n if (this.cachedHintWidth) {\n totalWidth = Math.max(\n totalWidth,\n this.cachedHintWidth.widthPx / scale,\n );\n }\n }\n }\n if (this.borderRect_) {\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 const lineHeight =\n constants.FIELD_TEXT_HEIGHT + constants.FIELD_BORDER_RECT_Y_PADDING;\n const hintHeightPx = Math.ceil(lineHeight * scale);\n // When the hint bar is visible it occupies one text row at the bottom;\n // pad the textarea by that row so we don't edit text underneath it.\n const paddingBottomPx = FieldMultilineInput.showHint\n ? paddingY + hintHeightPx\n : paddingY;\n htmlInput.style.padding = `${paddingY}px ${paddingX}px ${paddingBottomPx}px ${paddingX}px`;\n htmlInput.style.lineHeight = lineHeight * scale + 'px';\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 if (FieldMultilineInput.showHint) {\n this.hintElement = this.createHint(hintHeightPx);\n this.hintElement.style.fontFamily = constants.FIELD_TEXT_FONTFAMILY;\n div.appendChild(this.hintElement);\n }\n\n return htmlInput;\n }\n\n /**\n * Creates the keyboard hint bar shown at the bottom of the editor.\n *\n * Keys are rendered as keycaps (bordered boxes).\n *\n * @param heightPx The height of the hint bar in pixels.\n * @returns The hint bar element.\n */\n private createHint(heightPx: number): HTMLDivElement {\n const shiftKey = '⇧';\n const enterKey = '⏎';\n const hint = document.createElement('div');\n hint.className = 'blocklyMultilineHint';\n hint.setAttribute('aria-hidden', 'true');\n hint.style.height = heightPx + 'px';\n\n // Plain Enter\n const enterGroup = document.createElement('div');\n enterGroup.className = 'blocklyMultilineHintGroup';\n enterGroup.appendChild(this.createHintKeycap(enterKey));\n enterGroup.appendChild(this.createHintColon());\n enterGroup.appendChild(\n this.createHintLabel(\n FieldMultilineInput.enterCommits ? 'commit' : 'newline',\n ),\n );\n hint.appendChild(enterGroup);\n\n // Modifier+Enter\n const modEnterGroup = document.createElement('div');\n modEnterGroup.className = 'blocklyMultilineHintGroup';\n modEnterGroup.appendChild(this.createHintKeycap(shiftKey));\n modEnterGroup.appendChild(this.createHintKeycap(enterKey));\n modEnterGroup.appendChild(this.createHintColon());\n modEnterGroup.appendChild(\n this.createHintLabel(\n FieldMultilineInput.enterCommits ? 'newline' : 'commit',\n ),\n );\n hint.appendChild(modEnterGroup);\n\n return hint;\n }\n\n /**\n * Creates a colon separator element used between keycaps and the action icon.\n *\n * @returns The colon element.\n */\n private createHintColon(): HTMLSpanElement {\n const colon = document.createElement('span');\n colon.className = 'blocklyMultilineHintColon';\n colon.textContent = ':';\n return colon;\n }\n\n /**\n * Creates a keycap element displaying a single key label.\n *\n * @param label The key symbol to display.\n * @returns The keycap element.\n */\n private createHintKeycap(label: string): HTMLSpanElement {\n const key = document.createElement('span');\n key.className = 'blocklyMultilineHintKey';\n key.textContent = label;\n return key;\n }\n\n /**\n * Creates a text label describing the result of a key action.\n *\n * Uses Blockly.Msg for i18n with hardcoded English fallbacks.\n *\n * @param type Either 'commit' or 'newline'.\n * @returns The label element.\n */\n private createHintLabel(type: 'commit' | 'newline'): HTMLSpanElement {\n const label = document.createElement('span');\n label.className = 'blocklyMultilineHintLabel';\n label.textContent =\n type === 'commit'\n ? Blockly.Msg['FIELD_MULTILINEINPUT_FINISH_EDITING'] || 'Finish editing'\n : Blockly.Msg['FIELD_MULTILINEINPUT_NEW_LINE'] || 'New line';\n return label;\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.\n *\n * Enter commits the value and closes the editor (matching FieldTextInput).\n * Shift+Enter inserts a newline at the cursor.\n * All other keys are handled by the parent class (Escape reverts, Tab navigates).\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 if (e.isComposing) {\n // Let the IME (input method editor) finalize its composition naturally;\n // don't commit or insert a newline ourselves.\n return;\n }\n const shiftPressed = e.shiftKey;\n const shouldCommit = FieldMultilineInput.enterCommits\n ? !shiftPressed\n : shiftPressed;\n if (shouldCommit) {\n super.onHtmlInputKeyDown_(e);\n } else {\n this.insertNewline();\n e.preventDefault();\n e.stopPropagation();\n }\n } else {\n super.onHtmlInputKeyDown_(e);\n }\n }\n\n /**\n * Inserts a newline character at the current cursor position in the textarea.\n *\n * The browser's default Enter-key behavior inserts a newline, but\n * Shift+Enter has no default character-insertion action, so we handle it\n * manually here. After splicing the character we dispatch an `input` event\n * to trigger Blockly's onHtmlInputChange handler (programmatic `.value`\n * assignment doesn't fire `input` on its own).\n */\n private insertNewline() {\n const htmlInput = this.htmlInput_;\n if (!htmlInput) return;\n const start = htmlInput.selectionStart ?? htmlInput.value.length;\n const end = htmlInput.selectionEnd ?? start;\n htmlInput.value =\n htmlInput.value.substring(0, start) +\n '\\n' +\n htmlInput.value.substring(end);\n htmlInput.selectionStart = htmlInput.selectionEnd = start + 1;\n htmlInput.dispatchEvent(new Event('input'));\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/**\n * Register the field and any dependencies.\n */\nexport function registerFieldMultilineInput() {\n Blockly.fieldRegistry.register('field_multilinetext', FieldMultilineInput);\n}\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.blocklyMultilineHint {\n position: absolute;\n bottom: 0;\n left: 0;\n width: 100%;\n display: flex;\n justify-content: space-around;\n align-items: center;\n padding: 0 4px;\n box-sizing: border-box;\n font-size: 0.85em;\n color: rgba(0, 0, 0, 0.6);\n background-color: white;\n border-top: 1px solid rgba(0, 0, 0, 0.15);\n border-radius: 0 0 4px 4px;\n user-select: none;\n pointer-events: none;\n}\n\n.blocklyMultilineHintGroup {\n display: inline-flex;\n align-items: center;\n}\n\n.blocklyMultilineHintKey {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n min-width: 1.3em;\n height: 1.3em;\n padding: 0 0.25em;\n margin: 0 0.1em;\n border: 1px solid rgba(0, 0, 0, 0.35);\n border-radius: 3px;\n background-color: #f5f5f5;\n line-height: 1;\n box-sizing: border-box;\n}\n\n.blocklyMultilineHintColon {\n margin: 0 0.15em;\n}\n\n.blocklyMultilineHintLabel {\n white-space: nowrap;\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 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","/**\n * @license\n * Copyright 2024 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport {Block, common as BlocklyCommon} from 'blockly/core';\nimport {\n JavascriptGenerator,\n Order as JavascriptOrder,\n} from 'blockly/javascript';\nimport {DartGenerator, Order as DartOrder} from 'blockly/dart';\nimport {LuaGenerator, Order as LuaOrder} from 'blockly/lua';\nimport {PhpGenerator, Order as PhpOrder} from 'blockly/php';\nimport {PythonGenerator, Order as PythonOrder} from 'blockly/python';\nimport {registerFieldMultilineInput} from '../field_multilineinput';\nimport {Generators} from './generatorsType';\n\n/** The name this block is registered under. */\nexport const BLOCK_NAME = 'text_multiline';\n\n// Block for multiline text input.\nconst jsonDefinition = {\n type: BLOCK_NAME,\n message0: '%1 %2',\n args0: [\n {\n type: 'field_image',\n src:\n 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAARCAYAAADpP' +\n 'U2iAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAdhgAAHYYBXaITgQAAABh0RVh0' +\n 'U29mdHdhcmUAcGFpbnQubmV0IDQuMS42/U4J6AAAAP1JREFUOE+Vks0KQUEYhjm' +\n 'RIja4ABtZ2dm5A3t3Ia6AUm7CylYuQRaUhZSlLZJiQbFAyRnPN33y01HOW08z88' +\n '73zpwzM4F3GWOCruvGIE4/rLaV+Nq1hVGMBqzhqlxgCys4wJA65xnogMHsQ5luj' +\n 'nYHTejBBCK2mE4abjCgMGhNxHgDFWjDSG07kdfVa2pZMf4ZyMAdWmpZMfYOsLiD' +\n 'MYMjlMB+K613QISRhTnITnsYg5yUd0DETmEoMlkFOeIT/A58iyK5E18BuTBfgYX' +\n 'fwNJv4P9/oEBerLylOnRhygmGdPpTTBZAPkde61lbQe4moWUvYUZYLfUNftIY4z' +\n 'wA5X2Z9AYnQrEAAAAASUVORK5CYII=',\n width: 12,\n height: 17,\n alt: '\\u00B6',\n },\n {\n type: 'field_multilinetext',\n name: 'TEXT',\n text: '',\n },\n ],\n output: 'String',\n style: 'text_blocks',\n helpUrl: '%{BKY_TEXT_TEXT_HELPURL}',\n tooltip: '%{BKY_TEXT_TEXT_TOOLTIP}',\n extensions: ['parent_tooltip_when_inline'],\n};\n\n/**\n * Javascript block generator function.\n *\n * @param block The Block instance to generate code for.\n * @param generator The JavascriptGenerator calling the function.\n * @returns A tuple containing the code string and precedence.\n */\nexport function toJavascript(\n block: Block,\n generator: JavascriptGenerator,\n): [string, JavascriptOrder] {\n // Text value.\n const code = generator.multiline_quote_(block.getFieldValue('TEXT'));\n const order =\n code.indexOf('+') !== -1\n ? JavascriptOrder.ADDITION\n : JavascriptOrder.ATOMIC;\n return [code, order];\n}\n\n/**\n * Dart block generator function.\n *\n * @param block The Block instance to generate code for.\n * @param generator The DartGenerator calling the function.\n * @returns A tuple containing the code string and precedence.\n */\nexport function toDart(\n block: Block,\n generator: DartGenerator,\n): [string, DartOrder] {\n // Text value.\n const code = generator.multiline_quote_(block.getFieldValue('TEXT'));\n const order =\n code.indexOf('+') !== -1 ? DartOrder.ADDITIVE : DartOrder.ATOMIC;\n return [code, order];\n}\n\n/**\n * Lua block generator function.\n *\n * @param block The Block instance to generate code for.\n * @param generator The LuaGenerator calling the function.\n * @returns A tuple containing the code string and precedence.\n */\nexport function toLua(\n block: Block,\n generator: LuaGenerator,\n): [string, LuaOrder] {\n // Text value.\n const code = generator.multiline_quote_(block.getFieldValue('TEXT'));\n const order =\n code.indexOf('..') !== -1 ? LuaOrder.CONCATENATION : LuaOrder.ATOMIC;\n return [code, order];\n}\n\n/**\n * PHP block generator function.\n *\n * @param block The Block instance to generate code for.\n * @param generator The PhpGenerator calling the function.\n * @returns A tuple containing the code string and precedence.\n */\nexport function toPhp(\n block: Block,\n generator: PhpGenerator,\n): [string, PhpOrder] {\n // Text value.\n const code = generator.multiline_quote_(block.getFieldValue('TEXT'));\n const order =\n code.indexOf('.') !== -1 ? PhpOrder.STRING_CONCAT : PhpOrder.ATOMIC;\n return [code, order];\n}\n\n/**\n * Python block generator function.\n *\n * @param block The Block instance to generate code for.\n * @param generator The PythonGenerator calling the function.\n * @returns A tuple containing the code string and precedence.\n */\nexport function toPython(\n block: Block,\n generator: PythonGenerator,\n): [string, PythonOrder] {\n // Text value.\n const code = generator.multiline_quote_(block.getFieldValue('TEXT'));\n const order =\n code.indexOf('+') !== -1 ? PythonOrder.ADDITIVE : PythonOrder.ATOMIC;\n return [code, order];\n}\n\nconst definitionsDict = BlocklyCommon.createBlockDefinitionsFromJsonArray([\n jsonDefinition,\n]);\n\n/** The text_multiline BlockDefinition. */\nexport const blockDefinition = definitionsDict[BLOCK_NAME];\n\n/**\n * Install the `text_multiline` block and all of its dependencies.\n *\n * @param gens The CodeGenerators to install per-block\n * generators on.\n */\nexport function installBlock(gens: Generators = {}) {\n registerFieldMultilineInput();\n BlocklyCommon.defineBlocks(definitionsDict);\n if (gens.javascript) gens.javascript.forBlock[BLOCK_NAME] = toJavascript;\n if (gens.dart) gens.dart.forBlock[BLOCK_NAME] = toDart;\n if (gens.lua) gens.lua.forBlock[BLOCK_NAME] = toLua;\n if (gens.php) gens.php.forBlock[BLOCK_NAME] = toPhp;\n if (gens.python) gens.python.forBlock[BLOCK_NAME] = toPython;\n}\n","/**\n * @license\n * Copyright 2023 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport * as textMultiline from './blocks/textMultiline';\n\nexport * from './field_multilineinput';\n\n// Re-export all parts of the block definition.\nexport * as textMultiline from './blocks/textMultiline';\n\n// This package currently exports a single block. More may\n// be added later.\nexport const installAllBlocks = textMultiline.installBlock;\n"],"names":["root","factory","exports","module","require","define","amd","a","i","this","__WEBPACK_EXTERNAL_MODULE__370__","__WEBPACK_EXTERNAL_MODULE__127__","__WEBPACK_EXTERNAL_MODULE__379__","__WEBPACK_EXTERNAL_MODULE__157__","__WEBPACK_EXTERNAL_MODULE__537__","__WEBPACK_EXTERNAL_MODULE__557__","__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","core_","FieldTextInput","constructor","validator","config","super","Field","SKIP_SETUP","textGroup","maxLines_","Infinity","isOverflowedY_","hintElement","cachedHintWidth","configure_","setValue","setValidator","maxLines","setMaxLines","toXml","fieldElement","textContent","getValue","replace","fromXml","saveState","legacyState","saveLegacyState","loadState","state","loadLegacyState","initView","createBorderRect_","utils","dom","createSvgElement","Svg","G","class","fieldGroup_","addClass","getDisplayText_","block","getSourceBlock","Error","textLines","getText","NBSP","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","TEXT","x","FIELD_BORDER_RECT_X_PADDING","dy","FIELD_TEXT_BASELINE","appendChild","document","createTextNode","isBeingEdited_","htmlInput","htmlInput_","removeClass","updateSize_","setTimeout","resizeEditor_","bind","isTextValid_","aria","setState","State","INVALID","nodes","childNodes","totalWidth","totalHeight","tspan","textWidth","getTextWidth","actualEditorLines","String","dummyTextElement","lineWidth","offsetWidth","clientWidth","showHint","borderRect_","Math","max","EDITOR_MIN_WIDTH","_a","isConnected","scale","workspace_","getScale","style","width","widthPx","setAttribute","size_","height","positionBorderRect_","showEditor_","e","quietInput","forceRerender","widgetCreate_","div","WidgetDiv","getDiv","createElement","className","spellcheck_","fontSize","FIELD_TEXT_FONTSIZE","borderRadius","BORDERRADIUS","paddingX","paddingY","hintHeightPx","ceil","paddingBottomPx","padding","defaultValue","getEditorText_","userAgent","GECKO","bindInputEvents_","createHint","fontFamily","FIELD_TEXT_FONTFAMILY","heightPx","hint","enterGroup","createHintKeycap","createHintColon","createHintLabel","enterCommits","modEnterGroup","colon","label","type","Msg","getMaxLines","onHtmlInputKeyDown_","isComposing","shiftPressed","shiftKey","insertNewline","preventDefault","stopPropagation","start","selectionStart","end","_b","selectionEnd","dispatchEvent","Event","fromJson","options","parsing","replaceMessageReferences","registerFieldMultilineInput","fieldRegistry","register","Css","BLOCK_NAME","jsonDefinition","message0","args0","src","alt","name","output","helpUrl","tooltip","extensions","toJavascript","generator","code","multiline_quote_","getFieldValue","order","indexOf","javascript_","Order","ADDITION","ATOMIC","toDart","dart_","ADDITIVE","toLua","lua_","CONCATENATION","toPhp","php_","STRING_CONCAT","toPython","python_","definitionsDict","common","createBlockDefinitionsFromJsonArray","blockDefinition","installBlock","gens","defineBlocks","javascript","forBlock","dart","lua","php","python","installAllBlocks"],"sourceRoot":""}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blockly/field-multilineinput",
3
- "version": "6.0.8",
3
+ "version": "13.1.0",
4
4
  "description": "A Blockly multilineinput field.",
5
5
  "scripts": {
6
6
  "audit:fix": "blockly-scripts auditFix",
@@ -40,20 +40,17 @@
40
40
  "src"
41
41
  ],
42
42
  "devDependencies": {
43
- "@blockly/dev-scripts": "^4.0.11",
44
- "@blockly/dev-tools": "^9.0.8",
45
- "chai": "^4.2.0",
46
- "sinon": "^9.0.1",
47
- "typescript": "^5.4.5"
43
+ "@blockly/dev-scripts": "^13.1.0",
44
+ "@blockly/dev-tools": "^13.1.0",
45
+ "chai": "^6.2.2",
46
+ "sinon": "^22.0.0",
47
+ "typescript": "^6.0.3"
48
48
  },
49
49
  "peerDependencies": {
50
- "blockly": "^12.0.0"
50
+ "blockly": "^13.1.0"
51
51
  },
52
52
  "publishConfig": {
53
53
  "access": "public"
54
54
  },
55
- "engines": {
56
- "node": ">=8.0.0"
57
- },
58
- "gitHead": "da7e9a67d4368cf54cd65e170e64f12cda415be6"
55
+ "gitHead": "7660d802b5dd60f9b650411c274872dd7f2ef0a9"
59
56
  }
@@ -14,6 +14,13 @@ import * as Blockly from 'blockly/core';
14
14
  * Class for an editable text area input field.
15
15
  */
16
16
  export class FieldMultilineInput extends Blockly.FieldTextInput {
17
+ /**
18
+ * Minimum editor width (in SVG/workspace units) when the field is open.
19
+ * Prevents narrow editors when the initial text is very short.
20
+ */
21
+
22
+ static readonly EDITOR_MIN_WIDTH = 150;
23
+
17
24
  /**
18
25
  * The SVG group element that will contain a text element for each text row
19
26
  * when initialized.
@@ -31,6 +38,21 @@ export class FieldMultilineInput extends Blockly.FieldTextInput {
31
38
  // eslint-disable-next-line @typescript-eslint/naming-convention
32
39
  protected isOverflowedY_ = false;
33
40
 
41
+ /** Whether pressing Enter commits the value (default) or inserts a newline. */
42
+ static enterCommits = true;
43
+
44
+ /** Whether to show the keyboard-shortcut hint bar in the editor. */
45
+ static showHint = true;
46
+
47
+ /** The hint bar DOM element while the editor is open. */
48
+ private hintElement: HTMLDivElement | null = null;
49
+
50
+ /**
51
+ * Cached natural width of the hint bar in px, keyed by scale.
52
+ * Invalidated when zoom changes to avoid stale measurements.
53
+ */
54
+ private cachedHintWidth: {scale: number; widthPx: number} | null = null;
55
+
34
56
  /**
35
57
  * @param value The initial content of the field. Should cast to a string.
36
58
  * Defaults to an empty string if null or undefined. Also accepts
@@ -145,6 +167,9 @@ export class FieldMultilineInput extends Blockly.FieldTextInput {
145
167
  },
146
168
  this.fieldGroup_,
147
169
  );
170
+ if (this.fieldGroup_) {
171
+ Blockly.utils.dom.addClass(this.fieldGroup_, 'blocklyField');
172
+ }
148
173
  }
149
174
 
150
175
  /**
@@ -305,9 +330,6 @@ export class FieldMultilineInput extends Blockly.FieldTextInput {
305
330
  // This can't happen, but TypeScript thinks it can and lint forbids `!.`.
306
331
  if (!constants) throw Error('Constants not found');
307
332
  const nodes = (this.textGroup as SVGElement).childNodes;
308
- const fontSize = constants.FIELD_TEXT_FONTSIZE;
309
- const fontWeight = constants.FIELD_TEXT_FONTWEIGHT;
310
- const fontFamily = constants.FIELD_TEXT_FONTFAMILY;
311
333
  let totalWidth = 0;
312
334
  let totalHeight = 0;
313
335
  for (let i = 0; i < nodes.length; i++) {
@@ -349,6 +371,14 @@ export class FieldMultilineInput extends Blockly.FieldTextInput {
349
371
  const htmlInput = this.htmlInput_ as HTMLElement;
350
372
  const scrollbarWidth = htmlInput.offsetWidth - htmlInput.clientWidth;
351
373
  totalWidth += scrollbarWidth;
374
+
375
+ if (FieldMultilineInput.showHint) {
376
+ // Reserve a row at the bottom of the editor for the keyboard hint bar.
377
+ // The textarea's padding-bottom (set in widgetCreate_) keeps the text
378
+ // and caret out of this reserved strip.
379
+ totalHeight +=
380
+ constants.FIELD_TEXT_HEIGHT + constants.FIELD_BORDER_RECT_Y_PADDING;
381
+ }
352
382
  }
353
383
  if (this.borderRect_) {
354
384
  totalHeight += constants.FIELD_BORDER_RECT_Y_PADDING * 2;
@@ -356,6 +386,30 @@ export class FieldMultilineInput extends Blockly.FieldTextInput {
356
386
  // the rounding of the calculated value can result in the line wrapping
357
387
  // unintentionally.
358
388
  totalWidth += constants.FIELD_BORDER_RECT_X_PADDING * 2 + 1;
389
+ }
390
+ if (this.isBeingEdited_) {
391
+ totalWidth = Math.max(totalWidth, FieldMultilineInput.EDITOR_MIN_WIDTH);
392
+
393
+ // Measure the hint bar's natural width to make sure the editor is wide enough.
394
+ if (FieldMultilineInput.showHint && this.hintElement?.isConnected) {
395
+ const scale = (this.workspace_ as Blockly.WorkspaceSvg).getScale();
396
+ if (!this.cachedHintWidth || this.cachedHintWidth.scale !== scale) {
397
+ // Temporarily let the element size to its content to measure its
398
+ // natural width, unaffected by the current WidgetDiv width.
399
+ this.hintElement.style.width = 'max-content';
400
+ const widthPx = this.hintElement.offsetWidth;
401
+ this.hintElement.style.width = '';
402
+ if (widthPx > 0) this.cachedHintWidth = {scale, widthPx};
403
+ }
404
+ if (this.cachedHintWidth) {
405
+ totalWidth = Math.max(
406
+ totalWidth,
407
+ this.cachedHintWidth.widthPx / scale,
408
+ );
409
+ }
410
+ }
411
+ }
412
+ if (this.borderRect_) {
359
413
  this.borderRect_.setAttribute('width', `${totalWidth}`);
360
414
  this.borderRect_.setAttribute('height', `${totalHeight}`);
361
415
  }
@@ -404,12 +458,16 @@ export class FieldMultilineInput extends Blockly.FieldTextInput {
404
458
  htmlInput.style.borderRadius = borderRadius;
405
459
  const paddingX = constants.FIELD_BORDER_RECT_X_PADDING * scale;
406
460
  const paddingY = (constants.FIELD_BORDER_RECT_Y_PADDING * scale) / 2;
407
- htmlInput.style.padding =
408
- paddingY + 'px ' + paddingX + 'px ' + paddingY + 'px ' + paddingX + 'px';
409
461
  const lineHeight =
410
462
  constants.FIELD_TEXT_HEIGHT + constants.FIELD_BORDER_RECT_Y_PADDING;
463
+ const hintHeightPx = Math.ceil(lineHeight * scale);
464
+ // When the hint bar is visible it occupies one text row at the bottom;
465
+ // pad the textarea by that row so we don't edit text underneath it.
466
+ const paddingBottomPx = FieldMultilineInput.showHint
467
+ ? paddingY + hintHeightPx
468
+ : paddingY;
469
+ htmlInput.style.padding = `${paddingY}px ${paddingX}px ${paddingBottomPx}px ${paddingX}px`;
411
470
  htmlInput.style.lineHeight = lineHeight * scale + 'px';
412
-
413
471
  div.appendChild(htmlInput);
414
472
 
415
473
  htmlInput.value = htmlInput.defaultValue = this.getEditorText_(this.value_);
@@ -424,9 +482,102 @@ export class FieldMultilineInput extends Blockly.FieldTextInput {
424
482
 
425
483
  this.bindInputEvents_(htmlInput);
426
484
 
485
+ if (FieldMultilineInput.showHint) {
486
+ this.hintElement = this.createHint(hintHeightPx);
487
+ this.hintElement.style.fontFamily = constants.FIELD_TEXT_FONTFAMILY;
488
+ div.appendChild(this.hintElement);
489
+ }
490
+
427
491
  return htmlInput;
428
492
  }
429
493
 
494
+ /**
495
+ * Creates the keyboard hint bar shown at the bottom of the editor.
496
+ *
497
+ * Keys are rendered as keycaps (bordered boxes).
498
+ *
499
+ * @param heightPx The height of the hint bar in pixels.
500
+ * @returns The hint bar element.
501
+ */
502
+ private createHint(heightPx: number): HTMLDivElement {
503
+ const shiftKey = '⇧';
504
+ const enterKey = '⏎';
505
+ const hint = document.createElement('div');
506
+ hint.className = 'blocklyMultilineHint';
507
+ hint.setAttribute('aria-hidden', 'true');
508
+ hint.style.height = heightPx + 'px';
509
+
510
+ // Plain Enter
511
+ const enterGroup = document.createElement('div');
512
+ enterGroup.className = 'blocklyMultilineHintGroup';
513
+ enterGroup.appendChild(this.createHintKeycap(enterKey));
514
+ enterGroup.appendChild(this.createHintColon());
515
+ enterGroup.appendChild(
516
+ this.createHintLabel(
517
+ FieldMultilineInput.enterCommits ? 'commit' : 'newline',
518
+ ),
519
+ );
520
+ hint.appendChild(enterGroup);
521
+
522
+ // Modifier+Enter
523
+ const modEnterGroup = document.createElement('div');
524
+ modEnterGroup.className = 'blocklyMultilineHintGroup';
525
+ modEnterGroup.appendChild(this.createHintKeycap(shiftKey));
526
+ modEnterGroup.appendChild(this.createHintKeycap(enterKey));
527
+ modEnterGroup.appendChild(this.createHintColon());
528
+ modEnterGroup.appendChild(
529
+ this.createHintLabel(
530
+ FieldMultilineInput.enterCommits ? 'newline' : 'commit',
531
+ ),
532
+ );
533
+ hint.appendChild(modEnterGroup);
534
+
535
+ return hint;
536
+ }
537
+
538
+ /**
539
+ * Creates a colon separator element used between keycaps and the action icon.
540
+ *
541
+ * @returns The colon element.
542
+ */
543
+ private createHintColon(): HTMLSpanElement {
544
+ const colon = document.createElement('span');
545
+ colon.className = 'blocklyMultilineHintColon';
546
+ colon.textContent = ':';
547
+ return colon;
548
+ }
549
+
550
+ /**
551
+ * Creates a keycap element displaying a single key label.
552
+ *
553
+ * @param label The key symbol to display.
554
+ * @returns The keycap element.
555
+ */
556
+ private createHintKeycap(label: string): HTMLSpanElement {
557
+ const key = document.createElement('span');
558
+ key.className = 'blocklyMultilineHintKey';
559
+ key.textContent = label;
560
+ return key;
561
+ }
562
+
563
+ /**
564
+ * Creates a text label describing the result of a key action.
565
+ *
566
+ * Uses Blockly.Msg for i18n with hardcoded English fallbacks.
567
+ *
568
+ * @param type Either 'commit' or 'newline'.
569
+ * @returns The label element.
570
+ */
571
+ private createHintLabel(type: 'commit' | 'newline'): HTMLSpanElement {
572
+ const label = document.createElement('span');
573
+ label.className = 'blocklyMultilineHintLabel';
574
+ label.textContent =
575
+ type === 'commit'
576
+ ? Blockly.Msg['FIELD_MULTILINEINPUT_FINISH_EDITING'] || 'Finish editing'
577
+ : Blockly.Msg['FIELD_MULTILINEINPUT_NEW_LINE'] || 'New line';
578
+ return label;
579
+ }
580
+
430
581
  /**
431
582
  * Sets the maxLines config for this field.
432
583
  *
@@ -454,18 +605,60 @@ export class FieldMultilineInput extends Blockly.FieldTextInput {
454
605
  }
455
606
 
456
607
  /**
457
- * Handle key down to the editor. Override the text input definition of this
458
- * so as to not close the editor when enter is typed in.
608
+ * Handle key down to the editor.
609
+ *
610
+ * Enter commits the value and closes the editor (matching FieldTextInput).
611
+ * Shift+Enter inserts a newline at the cursor.
612
+ * All other keys are handled by the parent class (Escape reverts, Tab navigates).
459
613
  *
460
614
  * @param e Keyboard event.
461
615
  */
462
616
  // eslint-disable-next-line @typescript-eslint/naming-convention
463
617
  protected override onHtmlInputKeyDown_(e: KeyboardEvent) {
464
- if (e.key !== 'Enter') {
618
+ if (e.key === 'Enter') {
619
+ if (e.isComposing) {
620
+ // Let the IME (input method editor) finalize its composition naturally;
621
+ // don't commit or insert a newline ourselves.
622
+ return;
623
+ }
624
+ const shiftPressed = e.shiftKey;
625
+ const shouldCommit = FieldMultilineInput.enterCommits
626
+ ? !shiftPressed
627
+ : shiftPressed;
628
+ if (shouldCommit) {
629
+ super.onHtmlInputKeyDown_(e);
630
+ } else {
631
+ this.insertNewline();
632
+ e.preventDefault();
633
+ e.stopPropagation();
634
+ }
635
+ } else {
465
636
  super.onHtmlInputKeyDown_(e);
466
637
  }
467
638
  }
468
639
 
640
+ /**
641
+ * Inserts a newline character at the current cursor position in the textarea.
642
+ *
643
+ * The browser's default Enter-key behavior inserts a newline, but
644
+ * Shift+Enter has no default character-insertion action, so we handle it
645
+ * manually here. After splicing the character we dispatch an `input` event
646
+ * to trigger Blockly's onHtmlInputChange handler (programmatic `.value`
647
+ * assignment doesn't fire `input` on its own).
648
+ */
649
+ private insertNewline() {
650
+ const htmlInput = this.htmlInput_;
651
+ if (!htmlInput) return;
652
+ const start = htmlInput.selectionStart ?? htmlInput.value.length;
653
+ const end = htmlInput.selectionEnd ?? start;
654
+ htmlInput.value =
655
+ htmlInput.value.substring(0, start) +
656
+ '\n' +
657
+ htmlInput.value.substring(end);
658
+ htmlInput.selectionStart = htmlInput.selectionEnd = start + 1;
659
+ htmlInput.dispatchEvent(new Event('input'));
660
+ }
661
+
469
662
  /**
470
663
  * Construct a FieldMultilineInput from a JSON arg object,
471
664
  * dereferencing any string table references.
@@ -506,6 +699,53 @@ Blockly.Css.register(`
506
699
  .blocklyHtmlTextAreaInputOverflowedY {
507
700
  overflow-y: scroll;
508
701
  }
702
+
703
+ .blocklyMultilineHint {
704
+ position: absolute;
705
+ bottom: 0;
706
+ left: 0;
707
+ width: 100%;
708
+ display: flex;
709
+ justify-content: space-around;
710
+ align-items: center;
711
+ padding: 0 4px;
712
+ box-sizing: border-box;
713
+ font-size: 0.85em;
714
+ color: rgba(0, 0, 0, 0.6);
715
+ background-color: white;
716
+ border-top: 1px solid rgba(0, 0, 0, 0.15);
717
+ border-radius: 0 0 4px 4px;
718
+ user-select: none;
719
+ pointer-events: none;
720
+ }
721
+
722
+ .blocklyMultilineHintGroup {
723
+ display: inline-flex;
724
+ align-items: center;
725
+ }
726
+
727
+ .blocklyMultilineHintKey {
728
+ display: inline-flex;
729
+ align-items: center;
730
+ justify-content: center;
731
+ min-width: 1.3em;
732
+ height: 1.3em;
733
+ padding: 0 0.25em;
734
+ margin: 0 0.1em;
735
+ border: 1px solid rgba(0, 0, 0, 0.35);
736
+ border-radius: 3px;
737
+ background-color: #f5f5f5;
738
+ line-height: 1;
739
+ box-sizing: border-box;
740
+ }
741
+
742
+ .blocklyMultilineHintColon {
743
+ margin: 0 0.15em;
744
+ }
745
+
746
+ .blocklyMultilineHintLabel {
747
+ white-space: nowrap;
748
+ }
509
749
  `);
510
750
 
511
751
  /**
@@ -519,8 +759,7 @@ export interface FieldMultilineInputConfig
519
759
  /**
520
760
  * fromJson config options for the multiline input field.
521
761
  */
522
- export interface FieldMultilineInputFromJsonConfig
523
- extends FieldMultilineInputConfig {
762
+ export interface FieldMultilineInputFromJsonConfig extends FieldMultilineInputConfig {
524
763
  text?: string;
525
764
  }
526
765