print task tree as text using system print dialog

Hunter
Tuesday, June 17th, 2025 at 8:17 AM

index.html+50 

index.html
 287  			background-color: var(--accent);
 288  			transform: translateY(-50%);
 289  		}
 290 +
 291 +		/* print styles */
 292 +		@media print {
 293 +			body * {
 294 +				visibility: hidden;
 295 +			}
 296 +			#print-content, #print-content * {
 297 +				visibility: visible;
 298 +			}
 299 +			#print-content {
 300 +				position: absolute;
 301 +				left: 0;
 302 +				top: 0;
 303 +				font-family: monospace;
 304 +				font-size: 12pt;
 305 +				line-height: 1.4;
 306 +				white-space: pre-wrap;
 307 +				color: black;
 308 +				background: white;
 309 +			}
 310 +			#app-container {
 311 +				display: none;
 312 +			}
 313 +		}
 314  	</style>
 315  	<script>
 316  		document.addEventListener('click', function(e) {

1189  			
1190  			// Add scroll handler to block default scroll behavior
1191  			window.addEventListener('wheel', handleScroll, { passive: false });
1192 +
1193 +			// Add print handler
1194 +			window.addEventListener('beforeprint', handleBeforePrint);
1195 +			window.addEventListener('afterprint', handleAfterPrint);
1196  			
1197 +			function handleBeforePrint() {
1198 +				// Create print content div if it doesn't exist
1199 +				let printContent = document.getElementById('print-content');
1200 +				if (!printContent) {
1201 +					printContent = document.createElement('div');
1202 +					printContent.id = 'print-content';
1203 +					document.body.appendChild(printContent);
1204 +				}
1205 +				
1206 +				// Generate the serialized task tree for current parent task and its descendants
1207 +				const serializedTasks = serializeTaskTree(currentTask);
1208 +				printContent.textContent = serializedTasks;
1209 +			}
1210 +
1211 +			function handleAfterPrint() {
1212 +				// Clean up print content
1213 +				const printContent = document.getElementById('print-content');
1214 +				if (printContent) {
1215 +					printContent.remove();
1216 +				}
1217 +			}
1218 +
1219  			function handleScroll(e) {
1220  				// Prevent the default scroll behavior
1221  				e.preventDefault();