From 2ac464c53e39af1cde31973e939b07e930cb725c Mon Sep 17 00:00:00 2001 From: Eric Rosenbaum Date: Fri, 3 Nov 2017 11:35:42 -0400 Subject: [PATCH] Prepend icon to each extension block --- src/engine/runtime.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/engine/runtime.js b/src/engine/runtime.js index b97387135..eef031ac0 100644 --- a/src/engine/runtime.js +++ b/src/engine/runtime.js @@ -421,6 +421,7 @@ class Runtime extends EventEmitter { const categoryInfo = { id: extensionInfo.id, name: extensionInfo.name, + iconURI: extensionInfo.iconURI, color1: '#FF6680', color2: '#FF4D6A', color3: '#FF3355', @@ -524,8 +525,21 @@ class Runtime extends EventEmitter { // but each `[ARG]` will need to be replaced with the number in this map instead of `args0.length`. const argsMap = {}; - blockJSON.message0 = blockInfo.text.replace(/\[(.+?)]/g, (match, placeholder) => { + blockJSON.message0 = ''; + // If an icon for the extension exists, prepend it to each block + if (categoryInfo.iconURI) { + blockJSON.message0 = '%1'; + const iconJSON = { + type: 'field_image', + src: categoryInfo.iconURI, + width: 40, + height: 40 + }; + blockJSON.args0.push(iconJSON); + } + + blockJSON.message0 += blockInfo.text.replace(/\[(.+?)]/g, (match, placeholder) => { // Sanitize the placeholder to ensure valid XML placeholder = placeholder.replace(/[<"&]/, '_');