node-red-contrib-markdown-note 1.1.1 → 1.1.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.
Files changed (2) hide show
  1. package/note.html +44 -59
  2. package/package.json +40 -40
package/note.html CHANGED
@@ -17,19 +17,15 @@
17
17
  return "note";
18
18
  },
19
19
 
20
- oneditprepare: function () {
21
- var content = this.content || "";
22
-
23
- // Capture top-left anchor position before editing
24
- // This ensures the node stays in place after edits
25
- if (
26
- this._noteTopY === undefined &&
27
- this.y !== undefined &&
28
- this.h !== undefined
29
- ) {
30
- this._noteTopY = this.y - this.h / 2;
31
- this._noteLastY = this.y;
32
- }
20
+ oneditprepare: function () {
21
+ var content = this.content || "";
22
+
23
+ // Capture the current top edge before editing so content-driven
24
+ // height changes can keep the note visually anchored.
25
+ if (this.y !== undefined && this.h !== undefined) {
26
+ this._noteTopY = this.y - this.h / 2;
27
+ this._notePreserveTopOnNextRender = true;
28
+ }
33
29
 
34
30
  // Create the ACE editor with markdown mode
35
31
  this.editor = RED.editor.createEditor({
@@ -48,28 +44,25 @@
48
44
  delete this.editor;
49
45
  }
50
46
 
51
- // Reposition node after Node-RED finishes its layout
52
- var node = this;
53
- if (node._noteTopY !== undefined) {
54
- setTimeout(function () {
55
- // Re-render to get correct height
56
- renderNoteNode(node);
57
-
58
- // Anchor top edge
59
- if (node.h !== undefined) {
60
- node.y = node._noteTopY + node.h / 2;
61
- node._noteLastY = node.y;
62
- RED.view.redraw(true);
63
- }
64
- }, 0);
65
- }
66
- },
67
- oneditcancel: function () {
68
- if (this.editor) {
69
- this.editor.destroy();
70
- delete this.editor;
71
- }
47
+ // Re-render after Node-RED finishes its layout so the content height is
48
+ // measured from the updated markdown.
49
+ var node = this;
50
+ if (
51
+ node._noteTopY !== undefined &&
52
+ node._notePreserveTopOnNextRender === true
53
+ ) {
54
+ setTimeout(function () {
55
+ renderNoteNode(node);
56
+ }, 0);
57
+ }
72
58
  },
59
+ oneditcancel: function () {
60
+ if (this.editor) {
61
+ this.editor.destroy();
62
+ delete this.editor;
63
+ }
64
+ this._notePreserveTopOnNextRender = false;
65
+ },
73
66
  oneditresize: function (size) {
74
67
  var rows = $("#dialog-form>div:not(.node-text-editor-row)");
75
68
  var height = $("#dialog-form").height();
@@ -249,31 +242,23 @@
249
242
  // We use snappedHeight directly to allow expansion beyond initial 'h'
250
243
  var finalHeight = Math.max(snappedHeight, Math.ceil(minHeight / 40) * 40);
251
244
 
252
- // Track top edge position to anchor the node
253
- // If this is first render OR user has moved the node, recalculate anchor
254
- var currentTopY = node.y - h / 2;
255
- if (node._noteTopY === undefined || node._noteLastY === undefined) {
256
- // First time: store current top edge as anchor
257
- node._noteTopY = currentTopY;
258
- } else if (Math.abs(node.y - node._noteLastY) > 1) {
259
- // User moved the node - update anchor
260
- node._noteTopY = currentTopY;
261
- }
262
-
263
- // Set y so top edge stays at _noteTopY
264
- var newY = node._noteTopY + finalHeight / 2;
265
- node.y = newY;
266
- node._noteLastY = newY;
267
-
268
- rect.attr("height", finalHeight);
269
- fo.attr("height", finalHeight - inset * 2);
270
- contentDiv.style("height", finalHeight - inset * 2 + "px");
271
-
272
- // Update Node-RED's internal dimensions
273
- node.h = finalHeight;
274
- }
275
- }
276
- </script>
245
+ rect.attr("height", finalHeight);
246
+ fo.attr("height", finalHeight - inset * 2);
247
+ contentDiv.style("height", finalHeight - inset * 2 + "px");
248
+
249
+ if (
250
+ node._notePreserveTopOnNextRender === true &&
251
+ typeof node._noteTopY === "number"
252
+ ) {
253
+ node.y = node._noteTopY + finalHeight / 2;
254
+ node._notePreserveTopOnNextRender = false;
255
+ }
256
+
257
+ // Update Node-RED's internal dimensions
258
+ node.h = finalHeight;
259
+ }
260
+ }
261
+ </script>
277
262
 
278
263
  <script type="text/html" data-template-name="note">
279
264
  <div class="form-row node-text-editor-row">
package/package.json CHANGED
@@ -1,41 +1,41 @@
1
- {
2
- "name": "node-red-contrib-markdown-note",
3
- "version": "1.1.1",
4
- "description": "A Node-RED node for adding rich Markdown notes and annotations to your flows.",
5
- "keywords": [
6
- "node-red",
7
- "node-red-contrib",
8
- "node-red-node",
9
- "note",
10
- "markdown",
11
- "annotation",
12
- "comment",
13
- "documentation"
14
- ],
15
- "author": "Ted Lanham <Backroads4me@gmail.com>",
16
- "license": "MIT",
17
- "homepage": "https://github.com/Backroads4Me/node-red-contrib-markdown-note",
18
- "bugs": {
19
- "url": "https://github.com/Backroads4Me/node-red-contrib-markdown-note/issues"
20
- },
21
- "files": [
22
- "note.js",
23
- "note.html",
24
- "README.md",
25
- "LICENSE",
26
- "examples"
27
- ],
28
- "node-red": {
29
- "version": ">=3.0.0",
30
- "nodes": {
31
- "note": "note.js"
32
- }
33
- },
34
- "repository": {
35
- "type": "git",
36
- "url": "git+https://github.com/Backroads4Me/node-red-contrib-markdown-note.git"
37
- },
38
- "engines": {
39
- "node": ">=14.0.0"
40
- }
1
+ {
2
+ "name": "node-red-contrib-markdown-note",
3
+ "version": "1.1.2",
4
+ "description": "A Node-RED node for adding rich Markdown notes and annotations to your flows.",
5
+ "keywords": [
6
+ "node-red",
7
+ "node-red-contrib",
8
+ "node-red-node",
9
+ "note",
10
+ "markdown",
11
+ "annotation",
12
+ "comment",
13
+ "documentation"
14
+ ],
15
+ "author": "Ted Lanham <Backroads4me@gmail.com>",
16
+ "license": "MIT",
17
+ "homepage": "https://github.com/Backroads4Me/node-red-contrib-markdown-note",
18
+ "bugs": {
19
+ "url": "https://github.com/Backroads4Me/node-red-contrib-markdown-note/issues"
20
+ },
21
+ "files": [
22
+ "note.js",
23
+ "note.html",
24
+ "README.md",
25
+ "LICENSE",
26
+ "examples"
27
+ ],
28
+ "node-red": {
29
+ "version": ">=3.0.0",
30
+ "nodes": {
31
+ "note": "note.js"
32
+ }
33
+ },
34
+ "repository": {
35
+ "type": "git",
36
+ "url": "git+https://github.com/Backroads4Me/node-red-contrib-markdown-note.git"
37
+ },
38
+ "engines": {
39
+ "node": ">=14.0.0"
40
+ }
41
41
  }