-
-
Notifications
You must be signed in to change notification settings - Fork 703
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to restore the html elements which is created dynamically #252
Comments
Html dynamically is not added in the export data. View to store new html in node: #40 (comment) |
This line conten all html on node. The "Home" is editor.module and the "5" is node ID. You just have to add the same information as you do in the node. |
You are copying the content of the node. You would have to search for the content within the child |
design came correctly but after reloading the page modal is popping up automatically |
I do not copy the contents of the DOM as the DF attribute values would not have to be copied. <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/gh/jerosoler/Drawflow/dist/drawflow.min.css"
/>
<script src="https://unpkg.com/drawflow/dist/drawflow.min.js"></script>
<style>
#drawflow {
position: relative;
width: 600px;
height: 600px;
border: 1px solid red;
}
</style>
</head>
<body>
<button onclick="exportDF()">Export</button>
<button onclick="importDF()">Import</button>
<div id="drawflow"></div>
<script>
var id = document.getElementById("drawflow");
const editor = new Drawflow(id);
editor.reroute = true;
editor.reroute_fix_curvature = true;
editor.start();
var html = `<div><p>Hii<p>
<button onclick="addimage(this)">addImage</button>
<div class="images"></div>
<div>`;
editor.addNode('github', 2, 2, 150, 100, 'github', {}, html);
editor.addNode('github', 2, 2, 300, 150, 'github', {}, html);
let dataExport = {};
function exportDF() {
dataExport = editor.export();
}
function importDF() {
editor.import(dataExport);
}
function addimage(el) {
const ele = el.closest(".drawflow-node");
const nodeId = ele.id.slice(5);
const nodeInfo = editor.getNodeFromId(nodeId);
const img = document.createElement("img");
img.src= 'https://avatars.githubusercontent.com/u/53616269?s=88&u=b7dc0eae565dfcc78bef7905766b55b06cf2d4a9&v=4'
img.width = '35';
// Add image to export
const transformToElement = new DOMParser().parseFromString(nodeInfo.html, 'text/html').body;
transformToElement.querySelector(".images").appendChild(img);
// Update Export
const module = editor.module;
editor.drawflow.drawflow[module].data[nodeId].html = transformToElement.innerHTML
// Add image to editor
const images = ele.querySelector(".images"); // Select target
images.appendChild(img);
// Update connections for resize node.
editor.updateConnectionNodes(`node-${nodeId}`);
}
</script>
</body>
</html> |
i did this and everything is working fine
|
i am storing Drawflow json object in localstorage after reloading the page all dynamically added rows are not loading back
The text was updated successfully, but these errors were encountered: