From bcc7834650e5145066d6cdf0c27687998b5675c2 Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Fri, 5 Oct 2018 17:56:54 +0100 Subject: [PATCH] Add markdown formatting toolbar --- .../editor-client/src/js/ui/common/panels.js | 40 ++++++--- .../src/js/ui/editors/markdown.js | 83 ++++++++++++++++++- 2 files changed, 110 insertions(+), 13 deletions(-) diff --git a/packages/node_modules/@node-red/editor-client/src/js/ui/common/panels.js b/packages/node_modules/@node-red/editor-client/src/js/ui/common/panels.js index 22e415099..3ccaa6b43 100644 --- a/packages/node_modules/@node-red/editor-client/src/js/ui/common/panels.js +++ b/packages/node_modules/@node-red/editor-client/src/js/ui/common/panels.js @@ -32,8 +32,7 @@ RED.panels = (function() { var startPosition; var panelSizes = []; var modifiedSizes = false; - var panelRatio; - + var panelRatio = 0.5; separator.draggable({ axis: vertical?"y":"x", containment: container, @@ -62,31 +61,47 @@ RED.panels = (function() { if (options.resize) { options.resize(newSizes[0],newSizes[1]); } - panelRatio = newSizes[0]/size; + panelRatio = newSizes[0]/(size-8); }, stop:function(event,ui) { modifiedSizes = true; } }); - return { - resize: function(size) { - var panelSizes = [$(children[0]).height(),$(children[1]).height()]; + var panel = { + ratio: function(ratio) { + panelRatio = ratio; + modifiedSizes = true; + if (ratio === 0 || ratio === 1) { + separator.hide(); + } else { + separator.show(); + } if (vertical) { + panel.resize(container.height()); + } else { + panel.resize(container.width()); + } + }, + resize: function(size) { + var panelSizes; + if (vertical) { + panelSizes = [$(children[0]).height(),$(children[1]).height()]; container.height(size); } else { + panelSizes = [$(children[0]).width(),$(children[1]).width()]; container.width(size); } if (modifiedSizes) { - var topPanelSize = panelRatio*size; - var bottomPanelSize = size - topPanelSize - 48; + var topPanelSize = panelRatio*(size-8); + var bottomPanelSize = size - topPanelSize - 8; panelSizes = [topPanelSize,bottomPanelSize]; if (vertical) { - $(children[0]).height(panelSizes[0]); - $(children[1]).height(panelSizes[1]); + $(children[0]).outerHeight(panelSizes[0]); + $(children[1]).outerHeight(panelSizes[1]); } else { - $(children[0]).width(panelSizes[0]); - $(children[1]).width(panelSizes[1]); + $(children[0]).outerWidth(panelSizes[0]); + $(children[1]).outerWidth(panelSizes[1]); } } if (options.resize) { @@ -94,6 +109,7 @@ RED.panels = (function() { } } } + return panel; } return { 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 161988150..3e34591c0 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 @@ -19,7 +19,29 @@ RED.editor.types._markdown = (function() { var template = '