I'll create a custom canvas application for you that combines the features you're looking for. This will be a single HTML file that you can save and run locally in your browser.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Interactive Canvas - Text Node Editor</title>
<style>
body {
margin: 0;
padding: 0;
font-family: Arial, sans-serif;
overflow: hidden;
background-color: #f0f0f0;
}
#toolbar {
position: fixed;
top: 0;
left: 0;
right: 0;
background: #333;
color: white;
padding: 10px;
z-index: 1000;
display: flex;
gap: 10px;
align-items: center;
flex-wrap: wrap;
}
#toolbar button {
padding: 8px 15px;
background: #555;
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
font-size: 14px;
}
#toolbar button:hover {
background: #666;
}
#toolbar button.active {
background: #4CAF50;
}
#canvas-container {
position: absolute;
top: 60px;
left: 0;
right: 0;
bottom: 0;
overflow: hidden;
cursor: grab;
}
#canvas-container.grabbing {
cursor: grabbing;
}
#canvas {
position: absolute;
width: 5000px;
height: 5000px;
transform-origin: 0 0;
}
.node {
position: absolute;
background: white;
border: 2px solid #333;
border-radius: 8px;
padding: 15px;
min-width: 150px;
box-shadow: 0 2px 5px rgba(0,0,0,0.2);
cursor: move;
user-select: none;
}
.node.selected {
border-color: #4CAF50;
box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.3);
}
.node-content {
outline: none;
min-height: 20px;
cursor: text;
}
.node-delete {
position: absolute;
top: -10px;
right: -10px;
width: 20px;
height: 20px;
background: #f44336;
color: white;
border: none;
border-radius: 50%;
cursor: pointer;
display: none;
font-size: 12px;
line-height: 20px;
text-align: center;
}
.node:hover .node-delete {
display: block;
}
.connection {
position: absolute;
pointer-events: none;
z-index: -1;
}
.connection-line {
stroke: #333;
stroke-width: 2;
fill: none;
}
#output-panel {
position: fixed;
bottom: 20px;
right: 20px;
background: white;
border: 2px solid #333;
border-radius: 8px;
padding: 15px;
max-width: 300px;
box-shadow: 0 2px 10px rgba(0,0,0,0.2);
}
#output-panel h3 {
margin-top: 0;
}
#output-text {
background: #f5f5f5;
padding: 10px;
border-radius: 4px;
min-height: 50px;
word-wrap: break-word;
}
.toggle-button {
display: inline-block;
padding: 8px 15px;
margin: 5px;
background: #e0e0e0;
border: 2px solid #999;
border-radius: 4px;
cursor: pointer;
user-select: none;
}
.toggle-button.active {
background: #4CAF50;
color: white;
border-color: #45a049;
}
#toggle-panel {
position: fixed;
top: 80px;
left: 20px;
background: white;
border: 2px solid #333;
border-radius: 8px;
padding: 15px;
box-shadow: 0 2px 10px rgba(0,0,0,0.2);
}
#zoom-info {
position: fixed;
bottom: 20px;
left: 20px;
background: rgba(0,0,0,0.7);
color: white;
padding: 5px 10px;
border-radius: 4px;
font-size: 12px;
}
</style>
</head>
<body>
<div id="toolbar">
<button onclick="addNode()">Add Node</button>
<button onclick="toggleConnectionMode()" id="connectBtn">Connect Nodes</button>
<button onclick="clearCanvas()">Clear Canvas</button>
<button onclick="saveCanvas()">Save</button>
<button onclick="loadCanvas()">Load</button>
<input type="file" id="fileInput" style="display: none;" accept=".json">
<button onclick="exportText()">Export Text</button>
<button onclick="zoomIn()">Zoom In</button>
<button onclick="zoomOut()">Zoom Out</button>
<button onclick="resetZoom()">Reset Zoom</button>
</div>
<div id="toggle-panel">
<h3>Toggle Options</h3>
<div class="toggle-button" onclick="toggleOption(this, 'big')">Big</div>
<div class="toggle-button" onclick="toggleOption(this, 'small')">Small</div>
<div class="toggle-button" onclick="toggleOption(this, 'chair')">Chair</div>
<div class="toggle-button" onclick="toggleOption(this, 'table')">Table</div>
<div class="toggle-button" onclick="toggleOption(this, 'red')">Red</div>
<div class="toggle-button" onclick="toggleOption(this, 'blue')">Blue</div>
</div>
<div id="canvas-container">
<div id="canvas">
<svg id="connections" style="position: absolute; width: 100%; height: 100%; z-index: -1;"></svg>
</div>
</div>
<div id="output-panel">
<h3>Combined Output</h3>
<div id="output-text"></div>
</div>
<div id="zoom-info">Zoom: 100%</div>
<script>
let nodes = [];
let connections = [];
let selectedNode = null;
let connectionMode = false;
let connectionStart = null;
let isDragging = false;
let isPanning = false;
let currentX = 0;
let currentY = 0;
let initialX = 0;
let initialY = 0;
let xOffset = 0;
let yOffset = 0;
let scale = 1;
let panX = 0;
let panY = 0;
let activeOptions = new Set();
const canvas = document.getElementById('canvas');
const canvasContainer = document.getElementById('canvas-container');
const connectionsEl = document.getElementById('connections');
// Initialize canvas position
updateCanvasTransform();
function updateCanvasTransform() {
canvas.style.transform = `translate(${panX}px, ${panY}px) scale(${scale})`;
document.getElementById('zoom-info').textContent = `Zoom: ${Math.round(scale * 100)}%`;
}
function addNode(x = 100, y = 100, text = 'New Node') {
const node = document.createElement('div');
node.className = 'node';
node.style.left = x + 'px';
node.style.top = y + 'px';
const nodeId = 'node-' + Date.now() + '-' + Math.random().toString(36).substr(2, 9);
node.id = nodeId;
const content = document.createElement('div');
content.className = 'node-content';
content.contentEditable = true;
content.textContent = text;
const deleteBtn = document.createElement('button');
deleteBtn.className = 'node-delete';
deleteBtn.textContent = '×';
deleteBtn.onclick = (e) => {
e.stopPropagation();
deleteNode(nodeId);
};
node.appendChild(content);
node.appendChild(deleteBtn);
node.addEventListener('mousedown', startDrag);
node.addEventListener('click', (e) => {
if (connectionMode) {
e.stopPropagation();
handleConnectionClick(nodeId);
}
});
canvas.appendChild(node);
nodes.push({id: nodeId, element: node});
return nodeId;
}
function deleteNode(nodeId) {
const nodeIndex = nodes.findIndex(n => n.id === nodeId);
if (nodeIndex !== -1) {
const node = nodes[nodeIndex];
node.element.remove();
nodes.splice(nodeIndex, 1);
// Remove connections
connections = connections.filter(conn => {
if (conn.from === nodeId || conn.to === nodeId) {
document.getElementById(conn.id)?.remove();
return false;
}
return true;
});
}
}
function startDrag(e) {
if (e.target.classList.contains('node-content')) return;
selectedNode = e.currentTarget;
selectedNode.classList.add('selected');
initialX = e.clientX - xOffset;
initialY = e.clientY - yOffset;
const rect = selectedNode.getBoundingClientRect();
const canvasRect = canvas.getBoundingClientRect();
xOffset = e.clientX - (rect.left - canvasRect.left) / scale;
yOffset = e.clientY - (rect.top - canvasRect.top) / scale;
isDragging = true;
}
function drag(e) {
if (isDragging && selectedNode) {
e.preventDefault();
currentX = (e.clientX - xOffset - panX) / scale;
currentY = (e.clientY - yOffset - panY) / scale;
selectedNode.style.left = currentX + 'px';
selectedNode.style.top = currentY + 'px';
updateConnections();
}
}
function stopDrag() {
if (selectedNode) {
selectedNode.classList.remove('selected');
}
isDragging = false;
selectedNode = null;
}
// Canvas panning
canvasContainer.addEventListener('mousedown', (e) => {
if (e.target === canvasContainer || e.target === canvas) {
isPanning = true;
canvasContainer.classList.add('grabbing');
initialX = e.clientX - panX;
initialY = e.clientY - panY;
}
});
canvasContainer.addEventListener('mousemove', (e) => {
if (isPanning) {
panX = e.clientX - initialX;
panY = e.clientY - initialY;
updateCanvasTransform();
}
});
canvasContainer.addEventListener('mouseup', () => {
isPanning = false;
canvasContainer.classList.remove('grabbing');
});
// Zoom functionality
canvasContainer.addEventListener('wheel', (e) => {
e.preventDefault();
const delta = e.deltaY > 0 ? 0.9 : 1.1;
const newScale = scale * delta;
if (newScale >= 0.1 && newScale <= 3) {
scale = newScale;
updateCanvasTransform();
}
});
function zoomIn() {
if (scale < 3) {
scale *= 1.2;
updateCanvasTransform();
}
}
function zoomOut() {
if (scale > 0.1) {
scale /= 1.2;
updateCanvasTransform();
}
}
function resetZoom() {
scale = 1;
panX = 0;
panY = 0;
updateCanvasTransform();
}
// Connection handling
function toggleConnectionMode() {
connectionMode = !connectionMode;
document.getElementById('connectBtn').classList.toggle('active', connectionMode);
connectionStart = null;
}
function handleConnectionClick(nodeId) {
if (!connectionStart) {
connectionStart = nodeId;
} else if (connectionStart !== nodeId) {
createConnection(connectionStart, nodeId);
connectionStart = null;
}
}
function createConnection(fromId, toId) {
const existingConnection = connections.find(
conn => (conn.from === fromId && conn.to === toId) ||
(conn.from === toId && conn.to === fromId)
);
if (existingConnection) {
// Remove existing connection
document.getElementById(existingConnection.id)?.remove();
connections = connections.filter(conn => conn.id !== existingConnection.id);
} else {
// Create new connection
const connectionId = 'conn-' + Date.now();
const line = document.createElementNS('http://www.w3.org/2000/svg', 'line');
line.id = connectionId;
line.classList.add('connection-line');
connectionsEl.appendChild(line);
connections.push({id: connectionId, from: fromId, to: toId, element: line});
updateConnections();
}
}
function updateConnections() {
connections.forEach(conn => {
const fromNode = document.getElementById(conn.from);
const toNode = document.getElementById(conn.to);
if (fromNode && toNode) {
const fromRect = fromNode.getBoundingClientRect();
const toRect = toNode.getBoundingClientRect();
const canvasRect = canvas.getBoundingClientRect();
const x1 = (fromRect.left + fromRect.width / 2 - canvasRect.left) / scale;
const y1 = (fromRect.top + fromRect.height / 2 - canvasRect.top) / scale;
const x2 = (toRect.left + toRect.width / 2 - canvasRect.left) / scale;
const y2 = (toRect.top + toRect.height / 2 - canvasRect.top) / scale;
conn.element.setAttribute('x1', x1);
conn.