mirror of
				https://github.com/node-red/node-red.git
				synced 2025-03-01 10:36:34 +00:00 
			
		
		
		
	Merge pull request #3674 from node-red-hitachi/fix-cursor-position-function-node
Fix initial cursor position of init/finalize tab of function node
This commit is contained in:
		@@ -460,7 +460,7 @@
 | 
				
			|||||||
                }
 | 
					                }
 | 
				
			||||||
            });
 | 
					            });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            var buildEditor = function(id, stateId, focus, value, defaultValue, extraLibs) {
 | 
					            var buildEditor = function(id, stateId, focus, value, defaultValue, extraLibs, offset) {
 | 
				
			||||||
                var editor = RED.editor.createEditor({
 | 
					                var editor = RED.editor.createEditor({
 | 
				
			||||||
                    id: id,
 | 
					                    id: id,
 | 
				
			||||||
                    mode: 'ace/mode/nrjavascript',
 | 
					                    mode: 'ace/mode/nrjavascript',
 | 
				
			||||||
@@ -484,14 +484,14 @@
 | 
				
			|||||||
                    extraLibs: extraLibs
 | 
					                    extraLibs: extraLibs
 | 
				
			||||||
                });
 | 
					                });
 | 
				
			||||||
                if (defaultValue && value === "") {
 | 
					                if (defaultValue && value === "") {
 | 
				
			||||||
                    editor.moveCursorTo(defaultValue.split("\n").length - 1, 0);
 | 
					                    editor.moveCursorTo(defaultValue.split("\n").length +offset, 0);
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                editor.__stateId = stateId;
 | 
					                editor.__stateId = stateId;
 | 
				
			||||||
                return editor;
 | 
					                return editor;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            this.initEditor = buildEditor('node-input-init-editor', this.id + "/" + "initEditor", false, $("#node-input-initialize").val(), RED._("node-red:function.text.initialize"))
 | 
					            this.initEditor = buildEditor('node-input-init-editor', this.id + "/" + "initEditor", false, $("#node-input-initialize").val(), RED._("node-red:function.text.initialize"), undefined, 0);
 | 
				
			||||||
            this.editor = buildEditor('node-input-func-editor', this.id + "/" + "editor", true, $("#node-input-func").val(), undefined, that.libs || [])
 | 
					            this.editor = buildEditor('node-input-func-editor', this.id + "/" + "editor", true, $("#node-input-func").val(), undefined, that.libs || [], undefined, -1);
 | 
				
			||||||
            this.finalizeEditor = buildEditor('node-input-finalize-editor', this.id + "/" + "finalizeEditor", false, $("#node-input-finalize").val(), RED._("node-red:function.text.finalize"))
 | 
					            this.finalizeEditor = buildEditor('node-input-finalize-editor', this.id + "/" + "finalizeEditor", false, $("#node-input-finalize").val(), RED._("node-red:function.text.finalize"), undefined, 0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            RED.library.create({
 | 
					            RED.library.create({
 | 
				
			||||||
                url:"functions", // where to get the data from
 | 
					                url:"functions", // where to get the data from
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user