@gregoriusrippenstein/node-red-contrib-nodedev 0.6.1 → 0.6.2

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.
@@ -12,7 +12,7 @@ module.exports = function (RED) {
12
12
  }
13
13
  }
14
14
 
15
- RED.plugins.registerPlugin("msg-tracer-plugin", {
15
+ RED.plugins.registerPlugin("{{ node.name }}-plugin", {
16
16
  onadd: () => {
17
17
  RED.hooks.add(OnReceiveHookName, {{ node.name }}OnReceiveHook)
18
18
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name" : "@gregoriusrippenstein/node-red-contrib-nodedev",
3
- "version": "0.6.1",
3
+ "version": "0.6.2",
4
4
  "dependencies": {
5
5
  "pako": "^2.1.0",
6
6
  "tar-stream": "^3.1.6",
@@ -1,5 +1,5 @@
1
1
  <script type="text/javascript">
2
- (function() {
2
+ (function() {
3
3
  var globalYourConfigNode = null;
4
4
 
5
5
  function doGenerateOTP(cfgnode, cb) {
@@ -343,6 +343,99 @@
343
343
  $('#node-input-nodedev-sidebar-otp-counter').val(globalYourConfigNode.counter || globalYourConfigNode._def.defaults.counter.value)
344
344
 
345
345
  $("#node-input-nodefactorysidebar-package-version").val(globalYourConfigNode.pkgversion);
346
+
347
+
348
+ function addTargetToExternalLinks(el) {
349
+ $(el).find("a").each(function (el) {
350
+ const href = $(this).attr('href');
351
+ if (/^https?:/.test(href)) {
352
+ $(this).attr('target', '_blank');
353
+ }
354
+ });
355
+ return el;
356
+ }
357
+
358
+ // Adds `text` to `target` with the following additions:
359
+ // - wraps text in a div with class `red-ui-help`
360
+ // - wraps text in a span with class `red-ui-text-bidi-aware` and sets the `dir` attribute to the base text direction of the text
361
+ // - wraps any text nodes in a span
362
+ // - wraps any H3 elements in an anchor with class `red-ui-help-info-header` and adds a click handler to toggle the visibility of the following elements until the next H3
363
+ // - ensures any <a> links to external sites open in a new tab
364
+ function renderInfoText(text, target, options) {
365
+ const info = addTargetToExternalLinks($('<div class="red-ui-help"><span class="red-ui-text-bidi-aware" dir=\"' + RED.text.bidi.resolveBaseTextDir(text) + '">' + text + '</span></div>')).appendTo(target);
366
+ info.find(".red-ui-text-bidi-aware").contents().filter(function () { return this.nodeType === 3 && this.textContent.trim() !== "" }).wrap("<span></span>");
367
+ if (options?.collapseSections !== false) {
368
+ const foldingHeader = "H3";
369
+ const breakHeader = ["H1", "H2", "H3"];
370
+ info.find(foldingHeader).wrapInner('<a class="red-ui-help-info-header expanded" href="#"></a>')
371
+ .find("a").prepend('<i class="fa fa-angle-right">').on("click", function (e) {
372
+ e.preventDefault();
373
+ const isExpanded = $(this).hasClass('expanded');
374
+ let el = $(this).parent().next();
375
+ while (el.length === 1 && breakHeader.indexOf(el[0].nodeName) === -1) {
376
+ el.toggle(!isExpanded);
377
+ el = el.next();
378
+ }
379
+ $(this).toggleClass('expanded', !isExpanded);
380
+ });
381
+ }
382
+ }
383
+
384
+ // this adds the badge to the top of the PkgFile node.
385
+ RED.view.annotations.register("pkgfile-node-info-docs", {
386
+ type: "badge",
387
+ class: "red-ui-flow-node-docs",
388
+ element: function (node) {
389
+ const docsBadge = document.createElementNS("http://www.w3.org/2000/svg", "g")
390
+
391
+ const pageOutline = document.createElementNS("http://www.w3.org/2000/svg", "rect");
392
+ pageOutline.setAttribute("x", 0);
393
+ pageOutline.setAttribute("y", 0);
394
+ pageOutline.setAttribute("rx", 2);
395
+ pageOutline.setAttribute("width", 7);
396
+ pageOutline.setAttribute("height", 10);
397
+ docsBadge.appendChild(pageOutline)
398
+
399
+ const pageLines = document.createElementNS("http://www.w3.org/2000/svg", "path");
400
+ pageLines.setAttribute("d", "M 7 3 h -3 v -3 M 2 8 h 3 M 2 6 h 3 M 2 4 h 2")
401
+ docsBadge.appendChild(pageLines)
402
+ return docsBadge;
403
+ },
404
+ show: function (n) { return n.type == "PkgFile" },
405
+ popover: {
406
+ content: function (n, popoverInstance) {
407
+ const section = $('<div class="red-ui-sidebar-section red-ui-flow-annotation-popover-section"></div>')
408
+ const banner = $('<div class="red-ui-sidebar-banner"></div>').appendTo(section)
409
+ $('<div class="red-ui-sidebar-banner-icon"><i class="fa fa-info"></i></div>').appendTo(banner)
410
+ $('<div class="red-ui-sidebar-banner-label" data-i18n="sidebar.info.name"></div>').appendTo(banner)
411
+ const tools = $('<div class="red-ui-sidebar-banner-tools"></div>').appendTo(banner)
412
+ const canEdit = RED.user.hasPermission('flows.write') && !RED.workspaces.isLocked()
413
+ if (canEdit) {
414
+ const editButton = $('<button type="button" data-i18n="[title]common.label.edit"><i class="fa fa-pencil"></i></button>').appendTo(tools)
415
+ editButton.on('click', function (evt) {
416
+ evt.preventDefault()
417
+ evt.stopPropagation()
418
+ if (popoverInstance) { popoverInstance.close() }
419
+ RED.editor.edit(n)
420
+ })
421
+ }
422
+ const body = $('<div class="red-ui-flow-annotation-popover-body contact-node-popover-content"></div>').appendTo(section)
423
+ renderInfoText(RED.utils.renderMarkdown(n._def.info.call(n)), body, { collapseSections: false });
424
+
425
+ // Resolve data-i18n attributes on content
426
+ section.i18n()
427
+
428
+ // On the next tick, render any unrendered mermaid diagrams
429
+ // (Already-rendered diagrams will be skipped via the `mermaid-processed` attribute)
430
+ setTimeout(function () {
431
+ RED.editor.mermaid.render()
432
+ }, 0)
433
+
434
+ return section
435
+ },
436
+ width: 400
437
+ }
438
+ })
346
439
  }
347
440
  RED.events.on('flows:loaded', fillInSiderBarForm);
348
441
  };
@@ -353,7 +446,7 @@
353
446
 
354
447
  <!-- The html for the right sidebar plugin screen -->
355
448
  <script type="text/x-red" data-template-name="NodeFactorySidebar">
356
- <div style="position: relative; height: 100%; overflow-y: auto;">
449
+ <div style="position: relative; height: 100%; overflow-y: auto;">
357
450
  <div class="form-row func-nodedev-pkgimporter-tabs-row">
358
451
  <ul style="min-width: 600px; margin-bottom: 20px;" id="func-nodedev-pkgimporter-tabs"></ul>
359
452
  </div>
@@ -484,4 +577,4 @@
484
577
  </div>
485
578
  </div>
486
579
  </div>
487
- </script>
580
+ </script>