Skip to content

Commit

Permalink
update to the mindmap nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
Gerrit Riessen committed Nov 18, 2024
1 parent 81923f4 commit 96bda5e
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 51 deletions.
56 changes: 28 additions & 28 deletions nodes/nodes.json
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@
"name": "base",
"types": [],
"user": false,
"version": "0.6.3-b1"
"version": "0.6.5-b1"
},
{
"enabled": true,
Expand All @@ -536,7 +536,7 @@
"Topic"
],
"user": false,
"version": "0.6.3-b1"
"version": "0.6.5-b1"
},
{
"enabled": true,
Expand All @@ -548,7 +548,7 @@
"Observation"
],
"user": false,
"version": "0.6.3-b1"
"version": "0.6.5-b1"
},
{
"enabled": true,
Expand All @@ -560,7 +560,7 @@
"Question"
],
"user": false,
"version": "0.6.3-b1"
"version": "0.6.5-b1"
},
{
"enabled": true,
Expand All @@ -572,7 +572,7 @@
"Thought"
],
"user": false,
"version": "0.6.3-b1"
"version": "0.6.5-b1"
},
{
"enabled": true,
Expand All @@ -584,7 +584,7 @@
"Idea"
],
"user": false,
"version": "0.6.3-b1"
"version": "0.6.5-b1"
},
{
"enabled": true,
Expand All @@ -596,7 +596,7 @@
"Dream"
],
"user": false,
"version": "0.6.3-b1"
"version": "0.6.5-b1"
},
{
"enabled": true,
Expand All @@ -608,7 +608,7 @@
"Metaphor"
],
"user": false,
"version": "0.6.3-b1"
"version": "0.6.5-b1"
},
{
"enabled": true,
Expand All @@ -620,7 +620,7 @@
"Aphorism"
],
"user": false,
"version": "0.6.3-b1"
"version": "0.6.5-b1"
},
{
"enabled": true,
Expand All @@ -632,7 +632,7 @@
"Poesie"
],
"user": false,
"version": "0.6.3-b1"
"version": "0.6.5-b1"
},
{
"enabled": true,
Expand All @@ -644,7 +644,7 @@
"Humour"
],
"user": false,
"version": "0.6.3-b1"
"version": "0.6.5-b1"
},
{
"enabled": true,
Expand All @@ -656,7 +656,7 @@
"Treasure"
],
"user": false,
"version": "0.6.3-b1"
"version": "0.6.5-b1"
},
{
"enabled": true,
Expand All @@ -668,7 +668,7 @@
"Consequence"
],
"user": false,
"version": "0.6.3-b1"
"version": "0.6.5-b1"
},
{
"enabled": true,
Expand All @@ -680,7 +680,7 @@
"Advantage"
],
"user": false,
"version": "0.6.3-b1"
"version": "0.6.5-b1"
},
{
"enabled": true,
Expand All @@ -692,7 +692,7 @@
"Disadvantage"
],
"user": false,
"version": "0.6.3-b1"
"version": "0.6.5-b1"
},
{
"enabled": true,
Expand All @@ -704,7 +704,7 @@
"Text"
],
"user": false,
"version": "0.6.3-b1"
"version": "0.6.5-b1"
},
{
"enabled": true,
Expand All @@ -716,7 +716,7 @@
"Blog-Post"
],
"user": false,
"version": "0.6.3-b1"
"version": "0.6.5-b1"
},
{
"enabled": true,
Expand All @@ -728,7 +728,7 @@
"Image"
],
"user": false,
"version": "0.6.3-b1"
"version": "0.6.5-b1"
},
{
"enabled": true,
Expand All @@ -740,7 +740,7 @@
"Comment"
],
"user": false,
"version": "0.6.3-b1"
"version": "0.6.5-b1"
},
{
"enabled": true,
Expand All @@ -752,7 +752,7 @@
"Code-Base"
],
"user": false,
"version": "0.6.3-b1"
"version": "0.6.5-b1"
},
{
"enabled": true,
Expand All @@ -764,7 +764,7 @@
"Art"
],
"user": false,
"version": "0.6.3-b1"
"version": "0.6.5-b1"
},
{
"enabled": true,
Expand All @@ -776,7 +776,7 @@
"Learning"
],
"user": false,
"version": "0.6.3-b1"
"version": "0.6.5-b1"
},
{
"enabled": true,
Expand All @@ -788,7 +788,7 @@
"Inspiration"
],
"user": false,
"version": "0.6.3-b1"
"version": "0.6.5-b1"
},
{
"enabled": true,
Expand All @@ -800,7 +800,7 @@
"Quote"
],
"user": false,
"version": "0.6.3-b1"
"version": "0.6.5-b1"
},
{
"enabled": true,
Expand All @@ -812,7 +812,7 @@
"Definition"
],
"user": false,
"version": "0.6.3-b1"
"version": "0.6.5-b1"
},
{
"enabled": true,
Expand All @@ -824,7 +824,7 @@
"Bookmark"
],
"user": false,
"version": "0.6.3-b1"
"version": "0.6.5-b1"
},
{
"enabled": true,
Expand All @@ -836,7 +836,7 @@
"Book"
],
"user": false,
"version": "0.6.3-b1"
"version": "0.6.5-b1"
},
{
"enabled": true,
Expand All @@ -848,6 +848,6 @@
"Author"
],
"user": false,
"version": "0.6.3-b1"
"version": "0.6.5-b1"
}
]
51 changes: 30 additions & 21 deletions plugins/plugins.html
Original file line number Diff line number Diff line change
Expand Up @@ -1340,22 +1340,26 @@
</script>
<!-- --- [red-plugin:@gorenje/node-red-mindmap/customdraganddrop] --- -->
<script type="text/javascript">
(()=>{var a=()=>{RED.events.off("runtime-state",a);let e=async t=>{var a=(window.ddEvent=t).originalEvent.dataTransfer.items,n=a.length;let o=e=>`<div class="audio-container">
<audio controls preload=none>
<source src="${e.relative_url}" type="${e.mimetype}" />
</audio>
<p>Download <a href="${e.relative_url}" download="${e.filename}">file</a></p>
</div>`.replace(/\n\s+/g,"\n"),i=e=>`<div class="video-container">
<video width="640" height="360" controls="controls" preload="none" poster="${e.poster_url}">
<source src="${e.relative_url}" type="${e.mimetype}">
Your browser doesn't support HTML5 video.
</video>
<p>Download <a href="${e.relative_url}" download="${e.filename}">file</a></p>
</div>`.replace(/\n\s+/g,"\n"),s=e=>`![img](${e.relative_url})`,r=(e,t)=>{var a=new FileReader;a.onload=function(e){t(e.target.result)},a.readAsDataURL(e)},p=e=>({id:RED.nodes.id(),sumPass:!1,sumPassPrio:0,sumPassNodeId:"",createdAt:(new Date).toISOString(),updatedAt:(new Date).toISOString(),x:0,y:e,wires:[[]]}),d=e=>RED.view.importNodes(Array.isArray(e)?e:[e]),l=(e,t)=>{0==e.keywords.length?RED.notify("Text classification no keywords found",{type:"warning"}):RED.notify("Text classification found: "+e.keywords.join(","),{type:"success"});let n=[],a=RED.workspaces.active(),r=(RED.nodes.eachNode(e=>{"Topic"==e.type&&e.z==a&&n.push(e)}),{...p(0),type:"Text",name:t.lines[0].substr(0,30)+(30<t.lines[0].length?"...":""),info:t.content}),o=[];t=[...new Set(e.keywords)].map(e=>e.trim()).filter(e=>!!e).map((t,e)=>{var a=n.filter(e=>e.name==t)[0];if(!a)return{...p(0),type:"Topic",name:t,info:"",y:40*e,x:100};o.push(a)}).filter(e=>!!e);if(0<o.length){let e=t=>{t.id==r.id&&(RED.events.off("nodes:add",e),o.forEach(e=>{RED.nodes.addLink({source:RED.nodes.node(e.id),sourcePort:0,target:t})}),RED.view.redraw(!0))};RED.events.on("nodes:add",e)}r.wires=[[...t].map(e=>e.id)],d([r,...t])},m=e=>{let a=e.content.trim().split(/\s+/).filter(e=>3<e.length).map(e=>e.replace(/[.,+=@!]/g,"")),t=[...new Set(a)].map(t=>[t,a.filter(e=>e==t).length]).sort((e,t)=>e[1]>t[1]?-1:1);3<t.length&&(t.length=parseInt((t.length-1)*Math.random())+1),setTimeout(()=>{l({keywords:t.map(e=>e[0])},e)},parseInt(1759*Math.random()+542))};let c={},y=!1,f=["text/x-moz-place","text/x-moz-url","text/uri-list"];for(let e=0;e<n;e++){var u=a[e];"file"==u.kind?((t,a)=>{var e;t.type.startsWith("image/")?((e=new FormData).append("file",a,a.name),$.ajax({url:"/writermap/content",type:"POST",data:e,contentType:!1,processData:!1,enctype:"multipart/form-data",success:e=>{d({...p(0),type:"Image",name:a.name,info:s(e)+`
`})},error:e=>{r(a,e=>{e={relative_url:e,mimetype:t.type,filename:a.name};d({...p(0),type:"Image",name:a.name,info:s(e)+`
`})})}})):t.type.startsWith("audio/")?((e=new FormData).append("file",a,a.name),$.ajax({url:"/writermap/content",type:"POST",data:e,contentType:!1,processData:!1,enctype:"multipart/form-data",success:e=>{d({...p(0),type:"Inspiration",name:a.name,info:o(e)})},error:e=>{r(a,e=>{e={relative_url:e,mimetype:t.type,filename:a.name};d({...p(0),type:"Inspiration",name:a.name,info:o(e)+`
`})})}})):t.type.startsWith("video/")?((e=new FormData).append("file",a,a.name),$.ajax({url:"/writermap/content",type:"POST",data:e,contentType:!1,processData:!1,enctype:"multipart/form-data",success:e=>{d({...p(0),type:"Image",name:a.name,info:i(e)})},error:e=>{r(a,e=>{e={relative_url:e,mimetype:t.type,filename:a.name,poster_url:""};d({...p(0),type:"Image",name:a.name,info:i(e)+`
`})})}})):"text/markdown"!=t.type&&"text/plain"!=t.type||a.arrayBuffer().then(e=>{d({...p(0),type:"Text",name:a.name,info:(new TextDecoder).decode(e)})}).catch(e=>{console.log(e)})})(u,t.originalEvent.dataTransfer.files[e]):"string"==u.kind?await(async a=>new Promise((t,e)=>{a.getAsString(e=>{y=y||-1<f.indexOf(a.type);e={type:a.type,content:e,lines:(e||"").split("\n").filter(e=>!!e)};(c[e.type]||=[]).push(e),c[e.type].sort((e,t)=>e.lines.length>t.lines.length?-1:1),t()})}))(u):RED.notify(`Unsupported drag&drop kind: '${u.kind}'`,{type:"error"})}let g=e=>{if(-1<f.indexOf(e.type)){let a=e.lines;$.ajax({url:"/writermap/content",type:"POST",data:JSON.stringify({bookmark_url:a[0]}),contentType:"application/json",processData:!1,success:e=>{var t={...p(0),type:"Bookmark",name:a[1]||"Bookmark",info:a[0]+"\n\n"};"image"==e.type&&(t.info=""+a[0]+`
(function () {
var initialiseConfigNodeOnce = () => {
RED.events.off('runtime-state', initialiseConfigNodeOnce);

let customDropHandler=async t=>{var a=(window.ddEvent=t).originalEvent.dataTransfer.items,n=a.length;let o=e=>`<div class="audio-container">
<audio controls preload=none>
<source src="${e.relative_url}" type="${e.mimetype}" />
</audio>
<p>Download <a href="${e.relative_url}" download="${e.filename}">file</a></p>
</div>`.replace(/\n\s+/g,"\n"),i=e=>`<div class="video-container">
<video width="640" height="360" controls="controls" preload="none" poster="${e.poster_url}">
<source src="${e.relative_url}" type="${e.mimetype}">
Your browser doesn't support HTML5 video.
</video>
<p>Download <a href="${e.relative_url}" download="${e.filename}">file</a></p>
</div>`.replace(/\n\s+/g,"\n"),s=e=>`![img](${e.relative_url})`,r=(e,t)=>{var a=new FileReader;a.onload=function(e){t(e.target.result)},a.readAsDataURL(e)},p=e=>({id:RED.nodes.id(),sumPass:!1,sumPassPrio:0,sumPassNodeId:"",createdAt:(new Date).toISOString(),updatedAt:(new Date).toISOString(),x:0,y:e,wires:[[]]}),l=e=>RED.view.importNodes(Array.isArray(e)?e:[e]),d=(e,t)=>{0==e.keywords.length?RED.notify("Text classification no keywords found",{type:"warning"}):RED.notify("Text classification found: "+e.keywords.join(","),{type:"success"});let a=[],n=RED.workspaces.active(),r=(RED.nodes.eachNode(e=>{"Topic"==e.type&&e.z==n&&a.push(e)}),{...p(0),type:"Text",name:t.lines[0].substr(0,30)+(30<t.lines[0].length?"...":""),info:t.content}),o=[],i=0;t=[...new Set(e.keywords)].map(e=>e.trim()).filter(e=>!!e).sort((e,t)=>e<t?-1:1).map(t=>{var e=a.filter(e=>e.name==t)[0];if(!e)return i+=1,{...p(0),type:"Topic",name:t,info:"",y:40*(i-1),x:100};o.push(e)}).filter(e=>!!e);if(0<o.length){let e=t=>{t.id==r.id&&(RED.events.off("nodes:add",e),o.forEach(e=>{RED.nodes.addLink({source:RED.nodes.node(e.id),sourcePort:0,target:t})}),RED.view.redraw(!0))};RED.events.on("nodes:add",e)}r.wires=[[...t].map(e=>e.id)],l([r,...t])},m=e=>{let a=e.content.trim().split(/\s+/).map(e=>e.replace(/[.,+=@!]/g,"").replace(/['"]$/,"").replace(/^['"]/,"")).filter(e=>4<e.length).map(e=>e.toLowerCase()),t=[...new Set(a)].map(t=>[t,a.filter(e=>e==t).length]).sort((e,t)=>e[1]<t[1]?-1:1).filter(e=>1<e[1]);var n;3<t.length&&(n=[t.pop(),t.pop(),t.pop()],t.sort((e,t)=>.5<Math.random()?-1:1),t.length=parseInt((t.length-1)*Math.random())+1,t.length=Math.min(t.length,6),t=[...n,...t]),setTimeout(()=>{d({keywords:t.map(e=>e[0])},e)},parseInt(1759*Math.random()+542))};let c={},y=!1,u=["text/x-moz-place","text/x-moz-url","text/uri-list"];for(let e=0;e<n;e++){var f=a[e];"file"==f.kind?((t,a)=>{var e;t.type.startsWith("image/")?((e=new FormData).append("file",a,a.name),$.ajax({url:"/writermap/content",type:"POST",data:e,contentType:!1,processData:!1,enctype:"multipart/form-data",success:e=>{l({...p(0),type:"Image",name:a.name,info:s(e)+`
`})},error:e=>{r(a,e=>{e={relative_url:e,mimetype:t.type,filename:a.name};l({...p(0),type:"Image",name:a.name,info:s(e)+`
`})})}})):t.type.startsWith("audio/")?((e=new FormData).append("file",a,a.name),$.ajax({url:"/writermap/content",type:"POST",data:e,contentType:!1,processData:!1,enctype:"multipart/form-data",success:e=>{l({...p(0),type:"Inspiration",name:a.name,info:o(e)})},error:e=>{r(a,e=>{e={relative_url:e,mimetype:t.type,filename:a.name};l({...p(0),type:"Inspiration",name:a.name,info:o(e)+`
`})})}})):t.type.startsWith("video/")?((e=new FormData).append("file",a,a.name),$.ajax({url:"/writermap/content",type:"POST",data:e,contentType:!1,processData:!1,enctype:"multipart/form-data",success:e=>{l({...p(0),type:"Image",name:a.name,info:i(e)})},error:e=>{r(a,e=>{e={relative_url:e,mimetype:t.type,filename:a.name,poster_url:""};l({...p(0),type:"Image",name:a.name,info:i(e)+`
`})})}})):"text/markdown"!=t.type&&"text/plain"!=t.type||a.arrayBuffer().then(e=>{l({...p(0),type:"Text",name:a.name,info:(new TextDecoder).decode(e)})}).catch(e=>{console.log(e)})})(f,t.originalEvent.dataTransfer.files[e]):"string"==f.kind?await(async a=>new Promise((t,e)=>{a.getAsString(e=>{y=y||-1<u.indexOf(a.type);e={type:a.type,content:e,lines:(e||"").split("\n").filter(e=>!!e)};(c[e.type]||=[]).push(e),c[e.type].sort((e,t)=>e.lines.length>t.lines.length?-1:1),t()})}))(f):console.log(`Ignoring unsupported drag&drop kind: '${f.kind}'`)}let g=e=>{if(-1<u.indexOf(e.type)){let a=e.lines;$.ajax({url:"/writermap/content",type:"POST",data:JSON.stringify({bookmark_url:a[0]}),contentType:"application/json",processData:!1,success:e=>{var t={...p(0),type:"Bookmark",name:a[1]||"Bookmark",info:a[0]+"\n\n"};"image"==e.type&&(t.info=""+a[0]+`
${s(e)}
`,t.type="Image"),"audio"==e.type&&(t.info=""+a[0]+`
Expand All @@ -1364,18 +1368,23 @@
`,t.type="Inspiration"),"video"==e.type&&(t.info=""+a[0]+`
${i(e)}
`,t.type="Image"),d(t)},error:e=>{var t={...p(0),type:"Bookmark",name:a[1]||"Bookmark",info:a[0]+"\n\n"};d(t)}})}else"text/html"!=e.type||y?"text/markdown"!=e.type&&"text/plain"!=e.type||y||$.ajax({url:"/writermap/classification",type:"GET",processData:!1,success:()=>{(t=>{RED.notify("Preparing to classify text content, this might take a moment.",{type:"success"});$.ajax({url:"/writermap/classification",type:"POST",data:JSON.stringify({data:t.content}),contentType:"application/json",processData:!1,success:e=>{l(e,t)},error:e=>{m(t)}})})(e)},error:()=>{m(e)}}):d({...p(0),type:"Code-Base",name:"HTML Content",info:e.content})};window.stringKindsStoredForLater=c,y?"text/x-moz-place"in c?(a=>{let n=a.uri,r=a.title||"Bookmark";$.ajax({url:"/writermap/content",type:"POST",data:JSON.stringify({bookmark_url:n}),contentType:"application/json",processData:!1,success:e=>{var t={...p(0),type:"Bookmark",name:r,info:n+"\n\n",createdAt:new Date(a.dateAdded/1e3).toISOString(),updatedAt:new Date(a.lastModified/1e3).toISOString()};"image"==e.type&&(t.info=""+urlAndTitle[0]+`
`,t.type="Image"),l(t)},error:e=>{var t={...p(0),type:"Bookmark",name:a[1]||"Bookmark",info:a[0]+"\n\n"};l(t)}})}else"text/html"!=e.type||y?"text/markdown"!=e.type&&"text/plain"!=e.type||y||$.ajax({url:"/writermap/classification",type:"GET",processData:!1,success:()=>{(t=>{RED.notify("Preparing to classify text content, this might take a moment.",{type:"success"});$.ajax({url:"/writermap/classification",type:"POST",data:JSON.stringify({data:t.content}),contentType:"application/json",processData:!1,success:e=>{d(e,t)},error:e=>{m(t)}})})(e)},error:()=>{m(e)}}):l({...p(0),type:"Code-Base",name:"HTML Content",info:e.content})};window.stringKindsStoredForLater=c,y?"text/x-moz-place"in c?(a=>{let n=a.uri,r=a.title||"Bookmark";$.ajax({url:"/writermap/content",type:"POST",data:JSON.stringify({bookmark_url:n}),contentType:"application/json",processData:!1,success:e=>{var t={...p(0),type:"Bookmark",name:r,info:n+"\n\n",createdAt:new Date(a.dateAdded/1e3).toISOString(),updatedAt:new Date(a.lastModified/1e3).toISOString()};"image"==e.type&&(t.info=""+n+`
${s(e)}
`,t.type="Image"),"audio"==e.type&&(t.info=""+urlAndTitle[0]+`
`,t.type="Image"),"audio"==e.type&&(t.info=""+n+`
${o(e)}
`,t.type="Inspiration"),"video"==e.type&&(t.info=""+urlAndTitle[0]+`
`,t.type="Inspiration"),"video"==e.type&&(t.info=""+n+`
${i(e)}
`,t.type="Image"),d(t)},error:e=>{var t={...p(0),type:"Bookmark",name:r,info:n+"\n\n",createdAt:new Date(a.dateAdded/1e3).toISOString(),updatedAt:new Date(a.lastModified/1e3).toISOString()};d(t)}})})(JSON.parse(c["text/x-moz-place"][0].content)):"text/x-moz-url"in c?g(c["text/x-moz-url"][0]):"text/uri-list"in c&&g(c["text/uri-list"][0]):Object.keys(c).forEach(e=>{g(c[e][0])})},t=()=>{0<$("#red-ui-drop-target").length?$("#red-ui-drop-target").on("drop",e):setTimeout(t,300)};setTimeout(t,300),$(window).on("paste",e=>{try{if((window.pasteEvent=e).target&&("red-ui-header"==e.target.id||"red-ui-workspace-chart"==e.target.id)){var t=e.originalEvent.clipboardData.getData("text"),a=JSON.parse(t);if(Array.isArray(a))try{RED.view.importNodes(a,{generateIds:!1,addFlow:!1,touchImport:!1,generateDefaultNames:!1})}catch(e){RED.notify("Error: "+e.message,{type:"warning"})}}}catch(e){RED.notify("Error: "+e.message,{type:"warning"})}})};RED.events.on("runtime-state",a)})();
</script>
`,t.type="Image"),l(t)},error:e=>{var t={...p(0),type:"Bookmark",name:r,info:n+"\n\n",createdAt:new Date(a.dateAdded/1e3).toISOString(),updatedAt:new Date(a.lastModified/1e3).toISOString()};l(t)}})})(JSON.parse(c["text/x-moz-place"][0].content)):"text/x-moz-url"in c?g(c["text/x-moz-url"][0]):"text/uri-list"in c&&g(c["text/uri-list"][0]):Object.keys(c).forEach(e=>{g(c[e][0])})},defineCustomDropHandler=()=>{0<$("#red-ui-drop-target").length?$("#red-ui-drop-target").on("drop",customDropHandler):setTimeout(defineCustomDropHandler,300)};setTimeout(defineCustomDropHandler,300);

$(window).on("paste",e=>{try{window.pasteEvent=e;var a=RED.settings.version.split(".")[0];if(e.target&&(("3"!=a||"red-ui-header"==e.target.id||"red-ui-workspace-chart"==e.target.id)&&("4"!=a||"span"==e.target.tagName.toLowerCase()||$(e.target).hasClass("red-ui-header-logo")))){var t=e.originalEvent.clipboardData.getData("text"),r=JSON.parse(t);if(Array.isArray(r))try{RED.view.importNodes(r,{generateIds:!1,addFlow:!1,touchImport:!1,generateDefaultNames:!1})}catch(e){RED.notify("Error: "+e.message,{type:"warning"})}}}catch(e){RED.notify("Error: "+e.message,{type:"warning"})}});
};

RED.events.on('runtime-state', initialiseConfigNodeOnce);
})();
</script>
<!-- --- [red-plugin:@gorenje/node-red-mindmap/mindmap-sidebar] --- -->
<script type="text/javascript">

Expand Down
4 changes: 2 additions & 2 deletions plugins/plugins.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"plugins": [],
"runtime": false,
"user": false,
"version": "0.6.3-b1"
"version": "0.6.5-b1"
},
{
"editor": true,
Expand All @@ -45,6 +45,6 @@
"plugins": [],
"runtime": false,
"user": false,
"version": "0.6.3-b1"
"version": "0.6.5-b1"
}
]

0 comments on commit 96bda5e

Please sign in to comment.