From fc8c4063f22fa4dae450665eb9b8eb3677e55835 Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Tue, 16 Oct 2018 11:36:24 +0100 Subject: [PATCH] Add markdown toolbar to flow description editor --- .../src/js/ui/editors/markdown.js | 3 ++ .../editor-client/src/js/ui/workspaces.js | 28 ++++++++++++++++--- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/packages/node_modules/@node-red/editor-client/src/js/ui/editors/markdown.js b/packages/node_modules/@node-red/editor-client/src/js/ui/editors/markdown.js index dd020e780..e75e1b617 100644 --- a/packages/node_modules/@node-red/editor-client/src/js/ui/editors/markdown.js +++ b/packages/node_modules/@node-red/editor-client/src/js/ui/editors/markdown.js @@ -199,6 +199,9 @@ RED.editor.types._markdown = (function() { } } else { editor.session.replace(editor.selection.getRange(), (style.before||"")+current+(style.after||"")); + if (current === "") { + editor.gotoLine(range.start.row+1,range.start.column+(style.before||"").length,false); + } } editor.focus(); }); diff --git a/packages/node_modules/@node-red/editor-client/src/js/ui/workspaces.js b/packages/node_modules/@node-red/editor-client/src/js/ui/workspaces.js index 284bd6243..bb8fac23b 100644 --- a/packages/node_modules/@node-red/editor-client/src/js/ui/workspaces.js +++ b/packages/node_modules/@node-red/editor-client/src/js/ui/workspaces.js @@ -150,13 +150,14 @@ RED.workspaces = (function() { $('
'+ ''+ - ' '+ + ' '+ ''+ '
').appendTo(dialogForm); - $('
'+ + var row = $('
'+ ''+ - '
'+ + '
'+ + '
'+ '
').appendTo(dialogForm); tabflowEditor = RED.editor.createEditor({ id: 'node-input-info', @@ -164,7 +165,26 @@ RED.workspaces = (function() { value: "" }); - $('
').appendTo(dialogForm); + var toolbar = RED.editor.types._markdown.buildToolbar(row.find(".node-text-editor-toolbar"),tabflowEditor); + + $('').appendTo(toolbar); + + $('#node-info-input-info-expand').click(function(e) { + e.preventDefault(); + var value = tabflowEditor.getValue(); + RED.editor.editMarkdown({ + value: value, + width: "Infinity", + cursor: tabflowEditor.getCursorPosition(), + complete: function(v,cursor) { + tabflowEditor.setValue(v, -1); + tabflowEditor.gotoLine(cursor.row+1,cursor.column,false); + setTimeout(function() { + tabflowEditor.focus(); + },300); + } + }) + }); dialogForm.find('#node-input-disabled-btn').on("click",function(e) { var i = $(this).find("i");