Skip to content

Commit

Permalink
feat:新增dnd-panel拖拽面板示例
Browse files Browse the repository at this point in the history
  • Loading branch information
wuchenguang1998 committed Mar 29, 2024
1 parent cbc82f1 commit 1ffc821
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 0 deletions.
37 changes: 37 additions & 0 deletions packages/extension/examples/components/dnd-panel/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="format-detection" content="telephone=no, email=no">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>LOGIC FLOW</title>
<link rel="stylesheet" href="/core/dist/style/index.css">
<!-- <link rel="stylesheet" href="http://0.0.0.0:9099/src/style/index.css"> -->
<link rel="stylesheet" href="/extension/src/style/index.css">
<style>
html,body {
padding: 0;
margin: 0;
}
body {
background-color: #FFF;
}
#app {
width: 1400px;
margin: 0 auto;
}
</style>
</head>
<body>
<button id="setDisabled">禁用面板circle</button>
<button id="setUsable">启用面板circle</button>
<div class="rules-graph">
<div id="app"></div>
</div>
<!-- <script src="/core/dist/logic-flow.js"></script> -->
<script src="http://localhost:9093/logic-flow.js"></script>
<script src="/DndPanel.js"></script>
<script type="module" src="./index.mjs"></script>

</body>
</html>
48 changes: 48 additions & 0 deletions packages/extension/examples/components/dnd-panel/index.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
const lf = new LogicFlow({
container: document.querySelector('#app'),
grid: true,
width: 1400,
multipleSelectKey: 'alt',
autoExpand: false,
plugins: [DndPanel],
height: 800
})
lf.setTheme({
baseNode: {
stroke: '#51a1ff',
strokeWidth: 8,
},
});

const rect = {
type: 'rect',
label: 'rect',
icon: 'data:image/png;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQH/2wBDAQEBAQEBAQEBAQEBAQEB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9Thd/lTuGL0azPpSO/Y84Fpt+6JxGdI1SW718ScThYuqtl1ZyXYI9CNejJsYa05ZcUkEHr8h23gs2yAiorFMZUFiCmAJgY7je5of1VG/AtfxZajGRrdQqzePYoKk59RVFogkoXrFEpuqciZTF6xTGKPIQ5lEQH/AARDKg7315RC6D+OYC/Bs7vMX2aYYfuYbIcWK9r5QJSHBNyoazuhSRJGxoTD26q3u3sjmzLx+2tyKb5vZUxYFVf0168UPJSgzkSU5sRkcCFO0RSQpKsasc/8EvXt26O46rm4YYYL+KXn/9k=',
}
const circle = {
type: 'circle',
label: 'circle',
icon: 'data:image/png;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQH/2wBDAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQH/wAARCAAiACIDASIAAhEBAxEB/8QAGwABAQEAAgMAAAAAAAAAAAAAAAkIAgMEBwr/xAAkEAABBQACAgIDAQEAAAAAAAADAQIEBQYABwgSERMJFCIWMf/EABcBAQEBAQAAAAAAAAAAAAAAAAcABAX/xAAfEQADAAMBAAMBAQAAAAAAAAADBAUBAgYABxEUExX/2gAMAwEAAhEDEQA/APv45Pfsfz+zsHYTeuOhOtdZ5E7atKYFl/jkOzMQSBcgzOHc19ZfSrMUQiESVLi1gqX4H8Cu3IpHh838hnZepynVGb62wcksPad6bGB13AkgM6NIFTzPRlyyPIYjyCJZGl1NEdzGeza+4nPG8Z2BVdI9CdFYnx86+qsLjoAGEECOfR3zgsbaam++pEmXFpI+PtIryqRsCK57gVkL6oMRrAi/pXhx+W5rk0e17GYbpGegdoJcpy2j7EtE68jcIady4+lnV/8AINs+qKM9Iqpmjha3KzoEePs5rVOhu9G3ynMPihgjKJNdF0O6YaDYT0tSF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WUj8UaUumt9Bz1Hqto1iTy3N85ZS6AoHrc5iQe1celEamIpT0HmTLJ7N7uvtbBxqMIR7lzhq0W/kXZCDJjW0uexUmUuhu3JbcUZVJLwKYpclSjou+2264oAR2sL6Kpr4LnJCk31HjWvHHHAry75xxxy9eccccvXnHHHL17/2Q==',
};
const disabledCircle = {
type: 'circle',
label: 'circle',
disabled: true,
icon: 'data:image/png;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQH/2wBDAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQH/wAARCAAhACIDASIAAhEBAxEB/8QAGgABAQEAAwEAAAAAAAAAAAAAAAgHBAUGCv/EACQQAAICAgICAgMBAQAAAAAAAAIDAQQFBgAHEhMIERQhIhUy/8QAFgEBAQEAAAAAAAAAAAAAAAAAAAIB/8QAIREAAgMAAgICAwAAAAAAAAAAAREAITFBUWFxAiKBsfH/2gAMAwEAAhEDEQA/APv1YxaVm1pgpSgJjGMIQWtYDJGZmUwIAAxJERTAiMTMzERyOs58nNj2rP3NV+PvX7uxbeOMlX9oyBsqashwslcepnvoKdUZMT6b13MYldjwMqardeRsz3Xy/wBqy2H62x+qYBpJy/Y+x0dRgxOVz/m2Qa2+qGRBEMXGDTxz4gZ86d20MzH6gt3660LB9aahh9QwCFrq4yssbNqFAuxlMiYD+dlbpAMS23ddEsIimYUqFVleFdCVhoQDTLQeUt73JLJJApJn3wPxzcl+x2f8udPWWY27p3V9hwKIl19GpXSnLV0h/bfUNXYNgsfQrgylg4a6sPHyYwY/6oHqbuPT+4cI3KazYcm7QlSs3gcgIKyuHsNEpAXrAjB1V0g2Kt5BEh8LYE+qwp9dOrchntHFp6b+Q/WHY+tD/nYrs3KnqO742rAqpWrFuzQrFkWoCBHzdN6tlWQv6kshhZtH5Ntv9uhfKkjwsPjnh2x5iwrJFC1yQHn7lzccccmVJH+YuAylnr7A7phklYu9cbdjNlcoRk/rHfc13ukR+zka92cc55QMwqoFlx+K1EQ0dpO44TftXw+269aXaxmYprsB4GJsqv8AqBtULUD+1XKFiGVbSiiJByij68ZGZ9JZrV7lexTtoTaqWktrWq1hYORYrvAlOQ9LIJbUuWRLasxIDAiEokZmORfe+PnZ3WGcyWe+Ou6U8Xhso+bl/r7Z5Y/E+6Y8ZGi9yLyGxAyC0HZHH5CvXUKTzNoYEI0IhNFsPLW9ZsmwSRb0c11362WtyHu6sgntDv7p/qzX2BejSc1O5bq+uUMVjV1H4+5+C9sfyiyqjQJbInziLObxyJ+nwxXOVYx3zV3Fc4e9kdB68pOj1W81iGCzIyif0wqhIdnrKrBRE+sq84xkFMeNqvH9jt3TfSOt9O4y4NGxYzuz5o/fsW25IIjI5RsmTZUoJY8qdGHGbvx/yLDXPOX3LVpoqJej62wSqAvezldRZVEBgl+Eav8AnubTxxxyZUccccRHHHHERxxxxE//2Q==',
callback: () => alert('面板的circle拖拽已被禁用了!'),
};

const buildItems = (isCircleDisabled = false) => {
return isCircleDisabled ? [rect, disabledCircle] : [rect, circle];
}

lf.extension.dndPanel.setPatternItems(buildItems());

lf.render();

document.querySelector('#setDisabled').addEventListener('click', () => {
lf.extension.dndPanel.setPatternItems(buildItems(true));
})
document.querySelector('#setUsable').addEventListener('click', () => {
lf.extension.dndPanel.setPatternItems(buildItems(false));
})

0 comments on commit 1ffc821

Please sign in to comment.