-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest-copy-comprehensive.html
More file actions
508 lines (438 loc) · 14.6 KB
/
Copy pathtest-copy-comprehensive.html
File metadata and controls
508 lines (438 loc) · 14.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Comprehensive Copy Test - QuikDown</title>
<link rel="icon" href="../favicon.svg" type="image/svg+xml">
<link rel="stylesheet" href="../dist/quikdown.light.min.css">
<style>
body {
font-family: system-ui, -apple-system, sans-serif;
max-width: 1400px;
margin: 40px auto;
padding: 20px;
background: #f5f5f5;
}
h1 {
color: #333;
border-bottom: 2px solid #007bff;
padding-bottom: 10px;
}
.test-container {
display: grid;
grid-template-columns: 1fr 1fr 1fr;
gap: 20px;
margin-top: 20px;
}
.panel {
background: white;
border: 1px solid #ddd;
padding: 20px;
border-radius: 8px;
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.panel h3 {
margin-top: 0;
color: #007bff;
border-bottom: 1px solid #eee;
padding-bottom: 10px;
}
textarea {
width: 100%;
height: 400px;
font-family: 'Monaco', 'Menlo', monospace;
font-size: 12px;
border: 1px solid #ddd;
padding: 10px;
border-radius: 4px;
}
#preview {
background: #fff;
padding: 15px;
min-height: 400px;
border: 1px solid #ddd;
border-radius: 4px;
overflow-y: auto;
}
#extracted {
background: #f8f9fa;
padding: 10px;
min-height: 400px;
white-space: pre-wrap;
font-family: monospace;
font-size: 12px;
border: 1px solid #ddd;
border-radius: 4px;
overflow-y: auto;
}
.controls {
display: flex;
gap: 10px;
margin: 20px 0;
flex-wrap: wrap;
}
button {
padding: 10px 20px;
cursor: pointer;
background: #007bff;
color: white;
border: none;
border-radius: 4px;
font-size: 14px;
transition: background 0.2s;
}
button:hover {
background: #0056b3;
}
button.secondary {
background: #6c757d;
}
button.secondary:hover {
background: #5a6268;
}
.status {
margin-top: 10px;
padding: 10px 15px;
background: #d1ecf1;
border: 1px solid #bee5eb;
border-radius: 4px;
color: #0c5460;
display: none;
}
.status.show {
display: block;
}
.status.success {
background: #d4edda;
border-color: #c3e6cb;
color: #155724;
}
.status.error {
background: #f8d7da;
border-color: #f5c6cb;
color: #721c24;
}
.info-box {
background: #e7f3ff;
border: 1px solid #b3d9ff;
border-radius: 4px;
padding: 15px;
margin-bottom: 20px;
}
.info-box h4 {
margin-top: 0;
color: #004085;
}
.info-box ul {
margin: 10px 0;
padding-left: 20px;
}
</style>
</head>
<body>
<h1>🧪 Comprehensive Copy to Clipboard Test</h1>
<div class="info-box">
<h4>Testing Copy Functionality</h4>
<ul>
<li><strong>Copy Text</strong> - Extracts plain text with proper structure for pasting into Google Docs, Word, etc.</li>
<li><strong>Copy Markdown</strong> - Copies the raw markdown source</li>
<li><strong>Copy HTML</strong> - Copies the rendered HTML markup</li>
</ul>
<p>Try copying the text and pasting into Google Docs to test table formatting and structure preservation.</p>
</div>
<div class="controls">
<button onclick="copyText()">📋 Copy Text (for Google Docs)</button>
<button onclick="copyMarkdown()" class="secondary">📝 Copy Markdown</button>
<button onclick="copyHTML()" class="secondary">🔧 Copy HTML</button>
<button onclick="loadSample1()">Load Sample 1</button>
<button onclick="loadSample2()">Load Sample 2</button>
<button onclick="loadSample3()">Load Complex</button>
</div>
<div class="status" id="status"></div>
<div class="test-container">
<div class="panel">
<h3>📝 Markdown Source</h3>
<textarea id="markdown"># QuikDown Test Document
## Text Formatting
This paragraph has **bold text**, *italic text*, and ~~strikethrough~~. We can also use `inline code` snippets.
## Lists
### Unordered List
- First item
- Second item with **bold**
- Third item with *italic*
- Nested item 1
- Nested item 2
### Ordered List
1. Step one
2. Step two
3. Step three
### Task List
- [x] Completed task
- [ ] Pending task
- [x] Another completed task
## Tables
| Feature | Status | Priority | Notes |
|---------|--------|----------|--------|
| Markdown Parser | ✅ Complete | High | Fast and secure |
| Bidirectional | ✅ Complete | High | Edit either view |
| Copy to Clipboard | 🔄 Testing | Medium | Google Docs compatible |
| Plugins | ✅ Complete | Low | Extensible system |
## Code Blocks
```javascript
// JavaScript example
function greet(name) {
console.log(`Hello, ${name}!`);
return {
message: `Welcome`,
timestamp: Date.now()
};
}
greet('World');
```
```python
# Python example
def fibonacci(n):
if n <= 1:
return n
return fibonacci(n-1) + fibonacci(n-2)
print([fibonacci(i) for i in range(10)])
```
## Links and Images
Check out [QuikDown on GitHub](https://github.com/deftio/quikdown) for more info.

## Blockquotes
> This is a blockquote with multiple lines.
> It can contain **formatting** and even [links](https://example.com).
## Horizontal Rule
---
## Complex Nested Structure
### Project Overview
1. **Phase 1**: Planning
- Define requirements
- Create mockups
- Get approval
2. **Phase 2**: Implementation
- Set up environment
- Write code
- Test features
3. **Phase 3**: Deployment
- Build production
- Deploy to server
- Monitor performance</textarea>
</div>
<div class="panel">
<h3>👁️ Rendered Preview</h3>
<div id="preview"></div>
</div>
<div class="panel">
<h3>📄 Extracted Plain Text</h3>
<div id="extracted"></div>
</div>
</div>
<script type="module">
import QuikdownEditor from '../dist/quikdown_edit.esm.js';
// Create editor instance for access to getText method
let editorInstance = null;
// Initialize editor in hidden div just for getText functionality
const hiddenDiv = document.createElement('div');
hiddenDiv.style.display = 'none';
document.body.appendChild(hiddenDiv);
editorInstance = new QuikdownEditor(hiddenDiv, {
showToolbar: false,
mode: 'source'
});
function updatePreview() {
const markdown = document.getElementById('markdown').value;
// Update editor and get rendered content
editorInstance.setMarkdown(markdown);
const html = editorInstance.getHTML();
const text = editorInstance.getText();
// Update preview
document.getElementById('preview').innerHTML = html;
// Show extracted text
document.getElementById('extracted').textContent = text;
}
window.copyText = async function() {
const text = editorInstance.getText();
try {
await navigator.clipboard.writeText(text);
showStatus('✓ Plain text copied! Try pasting into Google Docs', 'success');
} catch (err) {
// Fallback
const textarea = document.createElement('textarea');
textarea.value = text;
textarea.style.position = 'fixed';
textarea.style.left = '-999999px';
document.body.appendChild(textarea);
textarea.select();
const result = document.execCommand('copy');
textarea.remove();
if (result) {
showStatus('✓ Plain text copied (fallback)! Try pasting into Google Docs', 'success');
} else {
showStatus('✗ Failed to copy text', 'error');
}
}
};
window.copyMarkdown = async function() {
const markdown = document.getElementById('markdown').value;
try {
await navigator.clipboard.writeText(markdown);
showStatus('✓ Markdown source copied!', 'success');
} catch (err) {
showStatus('✗ Failed to copy markdown', 'error');
}
};
window.copyHTML = async function() {
const html = editorInstance.getHTML();
try {
await navigator.clipboard.writeText(html);
showStatus('✓ HTML markup copied!', 'success');
} catch (err) {
showStatus('✗ Failed to copy HTML', 'error');
}
};
function showStatus(message, type = 'info') {
const status = document.getElementById('status');
status.textContent = message;
status.className = `status show ${type}`;
setTimeout(() => {
status.className = 'status';
}, 4000);
}
// Sample content loaders
window.loadSample1 = function() {
document.getElementById('markdown').value = `# Simple Document
## Paragraph
This is a simple paragraph with **bold** and *italic* text.
## List
- Item 1
- Item 2
- Item 3
## Table
| Name | Age | City |
|------|-----|------|
| Alice | 30 | NYC |
| Bob | 25 | LA |
| Charlie | 35 | Chicago |`;
updatePreview();
};
window.loadSample2 = function() {
document.getElementById('markdown').value = `# Mermaid Diagram Test
## Flow Chart
\`\`\`mermaid
graph TD
A[Start] --> B{Decision}
B -->|Yes| C[Do this]
B -->|No| D[Do that]
C --> E[End]
D --> E
\`\`\`
## Sequence Diagram
\`\`\`mermaid
sequenceDiagram
participant User
participant System
participant Database
User->>System: Request data
System->>Database: Query
Database-->>System: Results
System-->>User: Response
\`\`\`
## Data Table
| Component | Version | Status |
|-----------|---------|--------|
| Frontend | 2.1.0 | 🟢 Active |
| Backend | 1.8.3 | 🟢 Active |
| Database | 5.7 | 🟡 Update needed |`;
updatePreview();
};
window.loadSample3 = function() {
document.getElementById('markdown').value = `# Complete Feature Showcase
## Advanced Tables
### Performance Metrics
| Metric | Q1 2024 | Q2 2024 | Q3 2024 | Change | Status |
|--------|---------|---------|---------|--------|--------|
| Response Time | 245ms | 198ms | 156ms | -36.3% | ✅ |
| Throughput | 1.2K req/s | 1.8K req/s | 2.4K req/s | +100% | ✅ |
| Error Rate | 0.15% | 0.08% | 0.03% | -80% | ✅ |
| Uptime | 99.9% | 99.95% | 99.99% | +0.09% | ✅ |
### Feature Comparison
| Feature | Basic | Pro | Enterprise |
|---------|-------|-----|------------|
| Users | 1 | 5 | Unlimited |
| Storage | 10GB | 100GB | 1TB |
| Support | Email | Priority | Dedicated |
| API Access | ❌ | ✅ | ✅ |
| Custom Domain | ❌ | ✅ | ✅ |
| SSO | ❌ | ❌ | ✅ |
## Complex Code Examples
### React Component
\`\`\`jsx
import React, { useState, useEffect } from 'react';
const DataTable = ({ data, onSort }) => {
const [sortField, setSortField] = useState(null);
const [sortOrder, setSortOrder] = useState('asc');
const handleSort = (field) => {
const order = sortField === field && sortOrder === 'asc' ? 'desc' : 'asc';
setSortField(field);
setSortOrder(order);
onSort(field, order);
};
return (
<table className="data-table">
<thead>
<tr>
{Object.keys(data[0]).map(key => (
<th key={key} onClick={() => handleSort(key)}>
{key} {sortField === key ? (sortOrder === 'asc' ? '↑' : '↓') : ''}
</th>
))}
</tr>
</thead>
<tbody>
{data.map((row, idx) => (
<tr key={idx}>
{Object.values(row).map((val, i) => (
<td key={i}>{val}</td>
))}
</tr>
))}
</tbody>
</table>
);
};
\`\`\`
## Mixed Content with Images
The QuikDown parser handles various content types seamlessly:
1. **Text formatting**: Bold, italic, code
2. **Lists**: Ordered, unordered, nested
3. **Tables**: With alignment and complex data
4. **Code blocks**: With syntax highlighting
5. **Images**: External and data URLs

---
> **Note**: This document tests all major markdown features to ensure proper text extraction for clipboard operations.`;
updatePreview();
};
// Initial render
updatePreview();
// Update on input
document.getElementById('markdown').addEventListener('input', updatePreview);
// Load mermaid if needed
if (window.mermaid) {
mermaid.initialize({ startOnLoad: false });
// Re-render mermaid on updates
const originalUpdate = updatePreview;
window.updatePreview = function() {
originalUpdate();
setTimeout(() => {
mermaid.run();
}, 100);
};
}
</script>
<!-- Optional: Load mermaid for diagram support -->
<script src="https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js"></script>
</body>
</html>