-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
10155 lines (8816 loc) Β· 440 KB
/
script.js
File metadata and controls
10155 lines (8816 loc) Β· 440 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
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// MiniWord Main Application - Page Switching Version
class MiniWord {
constructor() {
this.editor = document.getElementById('editor');
this.sidebar = document.getElementById('sidebar');
this.sidebarTitle = document.getElementById('sidebar-title');
this.sidebarContent = document.getElementById('sidebar-content');
this.sidebarClose = document.getElementById('sidebar-close');
this.currentPage = 'home';
this.currentDocument = {
content: '',
title: 'Untitled Document',
modified: false
};
// Internal MiniWord clipboard (safer, does not depend on browser permissions)
this.internalClipboard = {
plainText: '',
html: '',
hasContent: false,
type: null // 'plain' | 'formatted'
};
this.paginationMode = true; // Default to paginated mode
this.tempContent = null;
// Initialize zoom level
this.currentZoom = 100;
// Comments properties
this.documentComments = [];
this.commentId = 0;
this.selectedText = '';
this.commentAuthor = 'Reviewer';
this.init();
}
init() {
this.setupEventListeners();
this.showPage('home');
this.updateStatus();
// Initialize comments
this.initializeComments();
// Load saved settings
this.loadSettings();
// Default show file toolbar
this.switchToolbar('file');
// Hide sidebar initially
this.sidebar.classList.add('hidden');
// Initialize with paginated layout
this.createPaginatedLayout();
// Initialize zoom level
this.initializeZoom();
// Initialize page orientation
this.initializePageOrientation();
// Check for shared document
this.checkForSharedDocument();
}
setupEventListeners() {
// Menu bar events - dynamic toolbar switching
document.querySelectorAll('.menu-item').forEach(item => {
item.addEventListener('click', (e) => {
const menuType = e.target.dataset.page;
this.switchToolbar(menuType);
// Hide sidebar when clicking menu items
this.sidebar.classList.add('hidden');
});
});
// Toolbar button events
document.querySelectorAll('.toolbar-btn').forEach(btn => {
btn.addEventListener('click', (e) => {
e.preventDefault();
const button = e.target.closest('.toolbar-btn');
const page = button.dataset.page;
const submenu = button.dataset.submenu;
if (submenu) {
this.toggleSubmenu(submenu, button);
} else {
// Show page for all toolbar buttons (including bulleted_list and numbered_list)
this.showPage(page);
}
});
});
// Submenu item events
document.querySelectorAll('.submenu-item').forEach(item => {
item.addEventListener('click', (e) => {
e.preventDefault();
const page = e.target.dataset.page;
this.showPage(page);
this.hideSubmenu();
});
});
// Click elsewhere to hide submenu
document.addEventListener('click', (e) => {
if (!e.target.closest('.toolbar-btn[data-submenu]') && !e.target.closest('.submenu-container')) {
this.hideSubmenu();
}
});
// Sidebar close button
this.sidebarClose.addEventListener('click', () => {
this.sidebar.classList.add('hidden');
});
// Editor events
this.editor.addEventListener('input', () => {
this.currentDocument.modified = true;
this.updateStatus();
});
this.editor.addEventListener('keydown', (e) => {
this.handleKeyboardShortcuts(e);
});
// Add click event listener to ensure cursor positioning works
this.editor.addEventListener('click', (e) => {
// Allow links to work normally - don't interfere with link clicks
if (e.target.tagName === 'A' || e.target.closest('a')) {
// Let the link handle its own click event
return;
}
// Ensure the editor maintains focus for cursor positioning
this.editor.focus();
});
// Add click event listeners to page-content elements for cursor positioning
document.addEventListener('click', (e) => {
// Allow links to work normally - don't interfere with link clicks
if (e.target.tagName === 'A' || e.target.closest('a')) {
// Let the link handle its own click event
return;
}
const pageContent = e.target.closest('.page-content');
if (pageContent && pageContent.contentEditable) {
// Ensure the page content element can receive focus
pageContent.focus();
}
});
// File input events
document.addEventListener('change', (e) => {
if (e.target.id === 'file-input') {
const fileStatus = document.getElementById('file-status');
if (e.target.files.length > 0) {
const file = e.target.files[0];
fileStatus.textContent = `Selected: ${file.name} (${(file.size / 1024).toFixed(1)} KB)`;
} else {
fileStatus.textContent = 'No file selected';
}
}
});
}
switchToolbar(menuType) {
// Hide all toolbar content
document.querySelectorAll('.toolbar-content').forEach(content => {
content.style.display = 'none';
});
// Remove active state from all menu items
document.querySelectorAll('.menu-item').forEach(item => {
item.classList.remove('active');
});
// Show corresponding toolbar
const targetToolbar = document.getElementById(`${menuType}-toolbar`);
if (targetToolbar) {
targetToolbar.style.display = 'flex';
}
// Activate corresponding menu item
const activeMenuItem = document.querySelector(`[data-page="${menuType}"]`);
if (activeMenuItem) {
activeMenuItem.classList.add('active');
}
}
handleKeyboardShortcuts(e) {
const isCtrl = e.ctrlKey || e.metaKey;
if (isCtrl) {
switch (e.key) {
case 'n':
e.preventDefault();
this.showPage('file_new');
break;
case 'o':
e.preventDefault();
this.showPage('file_open');
break;
case 's':
e.preventDefault();
this.showPage('file_save');
break;
case 'p':
e.preventDefault();
this.showPage('file_print');
break;
case 'z':
e.preventDefault();
this.showPage('edit_undo');
break;
case 'y':
e.preventDefault();
this.showPage('edit_redo');
break;
case 'x':
e.preventDefault();
this.showPage('edit_cut');
break;
case 'c':
e.preventDefault();
// Open formatted copy page for Ctrl+C within MiniWord's help/sidebar system
this.showPage('copy_formatted');
break;
case 'v':
e.preventDefault();
this.showPage('edit_paste');
break;
case 'f':
e.preventDefault();
this.showPage('find');
break;
case 'h':
e.preventDefault();
this.showPage('replace');
break;
case 'k':
e.preventDefault();
this.clearAllFormatting();
break;
case 'j':
e.preventDefault();
this.activateFormatPainter();
break;
case '=':
case '+':
e.preventDefault();
this.zoomIn();
break;
case '-':
e.preventDefault();
this.zoomOut();
break;
case '0':
e.preventDefault();
this.resetZoom();
break;
case 'b':
e.preventDefault();
this.showPage('bold');
break;
case 'i':
e.preventDefault();
this.showPage('italic');
break;
case 'u':
e.preventDefault();
this.showPage('underline');
break;
case 'r':
e.preventDefault();
this.refreshWebPage();
break;
case 'w':
e.preventDefault();
this.closeWebPage();
break;
}
}
// Handle F5 for refresh
if (e.key === 'F5') {
e.preventDefault();
this.refreshWebPage();
}
// Handle Ctrl+T for new tab
if (isCtrl && e.key === 't') {
e.preventDefault();
this.openNewTab();
}
}
showPage(pageId) {
this.currentPage = pageId;
// Special handling for chart insert - show sidebar AND modal
if (pageId === 'insert_chart') {
// Show sidebar with function description
this.sidebar.classList.remove('hidden');
this.renderPage(pageId);
// Also show the modal
this.showChartInsertModal();
return;
}
// Only show sidebar for specific function pages, not for menu categories
const menuCategories = ['file', 'edit', 'view', 'insert', 'format', 'tools', 'help'];
// Special case: table_insert should show in sidebar
if (!menuCategories.includes(pageId) || pageId === 'table_insert') {
this.sidebar.classList.remove('hidden');
} else {
this.sidebar.classList.add('hidden');
}
// Update button status
document.querySelectorAll('.toolbar-btn').forEach(btn => {
btn.classList.remove('active');
});
const activeBtn = document.querySelector(`[data-page="${pageId}"]`);
if (activeBtn) {
activeBtn.classList.add('active');
}
// Show corresponding page content
this.renderPage(pageId);
// Special handling for specific pages
}
renderPage(pageId) {
console.log('renderPage called with pageId:', pageId); // Debug log
const pageContent = this.getPageContent(pageId);
console.log('Page content:', pageContent); // Debug log
this.sidebarTitle.textContent = pageContent.title;
this.sidebarContent.innerHTML = pageContent.content;
// Load current settings when Application Settings page is loaded
if (pageId === 'app_settings') {
this.loadCurrentSettings();
}
// Check if buttons are rendered
if (pageId === 'insert_chart') {
const refreshBtn = document.querySelector('button[onclick*="detectTablesInDocument"]');
const testBtn = document.querySelector('button[onclick*="testTableDetection"]');
console.log('Refresh button found:', !!refreshBtn); // Debug log
console.log('Test button found:', !!testBtn); // Debug log
}
// Bind page-specific events
this.bindPageEvents(pageId);
}
getPageContent(pageId) {
const pages = {
'home': {
title: 'Welcome to MiniWord',
content: `
<div class="page-content">
<h2>Welcome to MiniWord</h2>
<p>This is a simulated Word environment that provides complete document editing functionality.</p>
<div class="feature-grid">
<div class="feature-card">
<img src="miniword_buttons_png/file_new.png" alt="New">
<h4>New Document</h4>
<p>Create blank document</p>
</div>
<div class="feature-card">
<img src="miniword_buttons_png/file_open.png" alt="Open">
<h4>Open Document</h4>
<p>Open existing document</p>
</div>
<div class="feature-card">
<img src="miniword_buttons_png/file_save.png" alt="Save">
<h4>Save Document</h4>
<p>Save current document</p>
</div>
</div>
<p>Click toolbar buttons or use keyboard shortcuts to start editing documents.</p>
</div>
`
},
'file': {
title: 'File Operations',
content: `
<div class="page-content">
<h2>File Operations</h2>
<p>Manage your document files</p>
<div class="feature-grid">
<div class="feature-card" onclick="miniWord.showPage('file_new')">
<img src="miniword_buttons_png/file_new.png" alt="New">
<h4>New Document</h4>
<p>Create blank document</p>
</div>
<div class="feature-card" onclick="miniWord.showPage('file_open')">
<img src="miniword_buttons_png/file_open.png" alt="Open">
<h4>Open Document</h4>
<p>Open existing document</p>
</div>
<div class="feature-card" onclick="miniWord.showPage('file_save')">
<img src="miniword_buttons_png/file_save.png" alt="Save">
<h4>Save Document</h4>
<p>Save current document</p>
</div>
<div class="feature-card" onclick="miniWord.showPage('file_print')">
<img src="miniword_buttons_png/file_print.png" alt="Print">
<h4>Print Document</h4>
<p>Print current document</p>
</div>
</div>
</div>
`
},
'file_new': {
title: 'New Document',
content: `
<div class="page-content">
<h2>New Document</h2>
<p>Create a new document with custom settings</p>
<div class="form-group">
<label>Document Title:</label>
<input type="text" id="new-doc-title" placeholder="Enter document title" value="Untitled Document">
</div>
<div class="form-group">
<label>Document Type:</label>
<select id="new-doc-type">
<option value="blank">Blank Document</option>
<option value="letter">Business Letter</option>
<option value="report">Project Report</option>
<option value="memo">Internal Memo</option>
<option value="resume">Personal Resume</option>
<option value="newsletter">Newsletter</option>
<option value="invoice">Invoice</option>
</select>
</div>
<div class="warning-box">
<strong>Note:</strong> Creating a new document will replace the current document. Save your work first if needed.
</div>
<div class="button-group">
<button class="btn btn-primary" onclick="miniWord.createNewDocument()">Create Document</button>
<button class="btn" onclick="miniWord.showPage('file')">Cancel</button>
</div>
</div>
`
},
'file_open': {
title: 'Open Document',
content: `
<div class="page-content">
<h2>Open Document</h2>
<p>Open existing document files</p>
<div class="form-group">
<label>Select File:</label>
<div class="file-input-wrapper">
<input type="file" id="file-input" accept=".txt,.html,.htm,.md" style="display: none;">
<button type="button" class="file-select-btn" onclick="document.getElementById('file-input').click()">
Choose File
</button>
<span id="file-status" class="file-status-text">No file selected</span>
</div>
</div>
<div class="form-group">
<label>Or enter document content:</label>
<textarea id="content-input" rows="6" placeholder="Paste document content..."></textarea>
</div>
<div class="button-group">
<button class="btn btn-primary" onclick="miniWord.openDocument()">Open Document</button>
<button class="btn" onclick="miniWord.showPage('home')">Cancel</button>
</div>
</div>
`
},
'file_save': {
title: 'Save Document',
content: `
<div class="page-content">
<h2>Save Document</h2>
<p>Save current document to file</p>
<div class="form-group">
<label>Filename:</label>
<input type="text" id="save-filename" placeholder="Enter filename" value="${this.currentDocument.title || 'Untitled Document'}">
</div>
<div class="form-group">
<label>Save Fo rmat:</label>
<select id="save-format">
<option value="html">HTML Document</option>
<option value="txt">Plain Text</option>
<option value="md">Markdown</option>
</select>
</div>
<div class="button-group">
<button class="btn btn-primary" onclick="miniWord.saveDocument()">Save Document</button>
<button class="btn" onclick="miniWord.showPage('home')">Cancel</button>
</div>
</div>
`
},
'file_print': {
title: 'Print Document',
content: `
<div class="page-content">
<h2>Print Document</h2>
<p>Print current document</p>
<div class="form-group">
<label>Printer:</label>
<select id="printer-select">
<option value="default">Default Printer</option>
<option value="pdf">Save as PDF</option>
</select>
</div>
<div class="form-group">
<label>Page Range:</label>
<select id="page-range">
<option value="all">All Pages</option>
<option value="current">Current Page</option>
<option value="custom">Custom Range</option>
</select>
</div>
<div class="button-group">
<button class="btn btn-primary" onclick="miniWord.printDocument()">Print</button>
<button class="btn" onclick="miniWord.showPage('view_preview')">Preview</button>
<button class="btn" onclick="miniWord.showPage('home')">Cancel</button>
</div>
</div>
`
},
'web_refresh': {
title: 'Refresh Page',
content: `
<div class="page-content">
<h2>Refresh Page</h2>
<p>Reload the current web page</p>
<div class="warning-box">
<strong>Warning:</strong> This will reload the entire page. Any unsaved changes will be lost.
</div>
<div class="button-group">
<button class="btn btn-primary" onclick="miniWord.refreshWebPage()">Refresh Page</button>
<button class="btn" onclick="miniWord.showPage('home')">Cancel</button>
</div>
</div>
`
},
'web_close': {
title: 'Close Page',
content: `
<div class="page-content">
<h2>Close Page</h2>
<p>Close the current browser tab/window</p>
<div class="warning-box">
<strong>Note:</strong> This will attempt to close the current tab. If the tab cannot be closed programmatically, you'll need to close it manually.
</div>
<div class="button-group">
<button class="btn btn-primary" onclick="miniWord.closeWebPage()">Close Page</button>
<button class="btn" onclick="miniWord.showPage('home')">Cancel</button>
</div>
</div>
`
},
'new_tab': {
title: 'Open New Tab',
content: `
<div class="page-content">
<h2>Open New Tab</h2>
<p>Open a new browser tab with a fresh MiniWord instance</p>
<div class="info-box">
<strong>Info:</strong> This will open a new tab with MiniWord. You can work on multiple documents simultaneously.
</div>
<div class="button-group">
<button class="btn btn-primary" onclick="miniWord.openNewTab()">Open New Tab</button>
<button class="btn" onclick="miniWord.showPage('home')">Cancel</button>
</div>
</div>
`
},
'toggle_pagination': {
title: 'Toggle Pagination',
content: `
<div class="page-content">
<h2>Toggle Pagination</h2>
<p>Switch between paginated view (like Microsoft Word) and continuous text view</p>
<div class="info-box">
<strong>Current Mode:</strong> <span id="current-mode">Pagination</span>
</div>
<div class="warning-box">
<strong>Note:</strong> Switching modes will reformat your document content.
</div>
<div class="button-group">
<button class="btn btn-primary" onclick="miniWord.togglePagination()">Toggle Mode</button>
<button class="btn" onclick="miniWord.showPage('home')">Cancel</button>
</div>
</div>
`
},
'edit': {
title: 'Edit Operations',
content: `
<div class="page-content">
<h2>Edit Operations</h2>
<p>Basic editing functions</p>
<div class="feature-grid">
<div class="feature-card" onclick="miniWord.showPage('edit_undo')">
<img src="miniword_buttons_png/edit_undo.png" alt="Undo">
<h4>Undo</h4>
<p>Undo the last operation</p>
</div>
<div class="feature-card" onclick="miniWord.showPage('edit_redo')">
<img src="miniword_buttons_png/edit_redo.png" alt="Redo">
<h4>Redo</h4>
<p>Redo the undone operation</p>
</div>
<div class="feature-card" onclick="miniWord.showPage('edit_cut')">
<img src="miniword_buttons_png/edit_cut.png" alt="Cut">
<h4>Cut</h4>
<p>Cut selected content</p>
</div>
<div class="feature-card" onclick="miniWord.showPage('copy_plain')">
<img src="miniword_buttons_png/edit_copy.png" alt="Direct Copy">
<h4>Direct Copy</h4>
<p>Copy selected text without formatting</p>
</div>
<div class="feature-card" onclick="miniWord.showPage('copy_formatted')">
<img src="miniword_icons_set2/mw2_styles.png" alt="Formatted Copy">
<h4>Formatted Copy</h4>
<p>Copy selected text with all formatting</p>
</div>
<div class="feature-card" onclick="miniWord.showPage('edit_paste')">
<img src="miniword_buttons_png/edit_paste.png" alt="Paste">
<h4>Paste</h4>
<p>Paste clipboard content</p>
</div>
</div>
</div>
`
},
'edit_undo': {
title: 'Undo Operation',
content: `
<div class="page-content">
<h2>Undo Operation</h2>
<p>Undo the last operation</p>
<div class="button-group">
<button class="btn btn-primary" onclick="miniWord.undo()">Undo (Ctrl+Z)</button>
<button class="btn" onclick="miniWord.showPage('edit')">Back to Edit</button>
</div>
</div>
`
},
'edit_redo': {
title: 'Redo Operation',
content: `
<div class="page-content">
<h2>Redo Operation</h2>
<p>Redo the undone operation</p>
<div class="button-group">
<button class="btn btn-primary" onclick="miniWord.redo()">Redo (Ctrl+Y)</button>
<button class="btn" onclick="miniWord.showPage('edit')">Back to Edit</button>
</div>
</div>
`
},
'edit_cut': {
title: 'Cut Content',
content: `
<div class="page-content">
<h2>Cut Content</h2>
<p>Cut selected content to clipboard</p>
<div class="button-group">
<button class="btn btn-primary" onclick="miniWord.cut()">Cut (Ctrl+X)</button>
<button class="btn" onclick="miniWord.showPage('edit')">Back to Edit</button>
</div>
</div>
`
},
'edit_paste': {
title: 'Paste Content',
content: `
<div class="page-content">
<h2>Paste Content</h2>
<p>Paste content from clipboard with different options</p>
<div class="feature-info">
<h3>Paste Options:</h3>
<ul>
<li><strong>Smart Paste:</strong> Automatically detects and pastes formatted or plain text</li>
<li><strong>Plain Text:</strong> Paste as plain text only (removes formatting)</li>
<li><strong>Formatted:</strong> Paste with all formatting preserved</li>
</ul>
</div>
<div class="button-group">
<button class="btn btn-primary" onclick="miniWord.paste()">Smart Paste (Ctrl+V)</button>
<button class="btn btn-secondary" onclick="miniWord.pastePlainText()">Paste Plain Text</button>
<button class="btn btn-secondary" onclick="miniWord.pasteFormatted()">Paste Formatted</button>
<button class="btn" onclick="miniWord.showPage('edit')">Back to Edit</button>
</div>
</div>
`
},
'find': {
title: 'Find Text',
content: `
<div class="page-content">
<h2>Find Text</h2>
<p>Find specified text in document</p>
<div class="form-group">
<label>Find Content:</label>
<input type="text" id="find-text" placeholder="Enter text to find">
</div>
<div class="form-group">
<label>
<input type="checkbox" id="case-sensitive"> Case sensitive
</label>
</div>
<div class="button-group">
<button class="btn btn-primary" onclick="miniWord.findText()">Find</button>
<button class="btn" onclick="miniWord.showPage('home')">Cancel</button>
</div>
</div>
`
},
'replace': {
title: 'Find and Replace',
content: `
<div class="page-content">
<h2>Find and Replace</h2>
<p>Find and replace text in document</p>
<div class="form-group">
<label>Find Content:</label>
<input type="text" id="replace-find" placeholder="Enter text to find">
</div>
<div class="form-group">
<label>Replace With:</label>
<input type="text" id="replace-with" placeholder="Enter replacement text">
</div>
<div class="form-group">
<label>
<input type="checkbox" id="replace-case-sensitive"> Case sensitive
</label>
</div>
<div class="button-group">
<button class="btn btn-primary" onclick="miniWord.replaceText()">Replace All</button>
<button class="btn" onclick="miniWord.showPage('home')">Cancel</button>
</div>
</div>
`
},
'bold': {
title: 'Bold Format',
content: `
<div class="page-content">
<h2>Bold Format</h2>
<p>Set selected text to bold</p>
<div class="button-group">
<button class="btn btn-primary" onclick="miniWord.toggleBold()">Apply Bold (Ctrl+B)</button>
<button class="btn" onclick="miniWord.showPage('format')">Back to Format</button>
</div>
</div>
`
},
'italic': {
title: 'Italic Format',
content: `
<div class="page-content">
<h2>Italic Format</h2>
<p>Set selected text to italic</p>
<div class="button-group">
<button class="btn btn-primary" onclick="miniWord.toggleItalic()">Apply Italic (Ctrl+I)</button>
<button class="btn" onclick="miniWord.showPage('format')">Back to Format</button>
</div>
</div>
`
},
'underline': {
title: 'Underline Format',
content: `
<div class="page-content">
<h2>Underline Format</h2>
<p>Add underline to selected text</p>
<div class="button-group">
<button class="btn btn-primary" onclick="miniWord.toggleUnderline()">Apply Underline (Ctrl+U)</button>
<button class="btn" onclick="miniWord.showPage('format')">Back to Format</button>
</div>
</div>
`
},
'text_color': {
title: 'Text Color',
content: `
<div class="page-content">
<h2>Text Color</h2>
<p>Change color of selected text</p>
<div class="form-group">
<label>Select Color:</label>
<input type="color" id="font-color" value="#000000" style="width: 60px; height: 40px; border: 2px solid #ccc; border-radius: 4px;">
</div>
<div class="color-palette" style="display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 20px 0;">
<div class="color-option" style="background-color: #000000; width: 40px; height: 40px; border: 2px solid #ccc; border-radius: 4px; cursor: pointer;" data-color="#000000" onclick="document.getElementById('font-color').value='#000000'; miniWord.applyColorDirect('#000000');"></div>
<div class="color-option" style="background-color: #ff0000; width: 40px; height: 40px; border: 2px solid #ccc; border-radius: 4px; cursor: pointer;" data-color="#ff0000" onclick="document.getElementById('font-color').value='#ff0000'; miniWord.applyColorDirect('#ff0000');"></div>
<div class="color-option" style="background-color: #00ff00; width: 40px; height: 40px; border: 2px solid #ccc; border-radius: 4px; cursor: pointer;" data-color="#00ff00" onclick="document.getElementById('font-color').value='#00ff00'; miniWord.applyColorDirect('#00ff00');"></div>
<div class="color-option" style="background-color: #0000ff; width: 40px; height: 40px; border: 2px solid #ccc; border-radius: 4px; cursor: pointer;" data-color="#0000ff" onclick="document.getElementById('font-color').value='#0000ff'; miniWord.applyColorDirect('#0000ff');"></div>
<div class="color-option" style="background-color: #ffff00; width: 40px; height: 40px; border: 2px solid #ccc; border-radius: 4px; cursor: pointer;" data-color="#ffff00" onclick="document.getElementById('font-color').value='#ffff00'; miniWord.applyColorDirect('#ffff00');"></div>
<div class="color-option" style="background-color: #ff00ff; width: 40px; height: 40px; border: 2px solid #ccc; border-radius: 4px; cursor: pointer;" data-color="#ff00ff" onclick="document.getElementById('font-color').value='#ff00ff'; miniWord.applyColorDirect('#ff00ff');"></div>
<div class="color-option" style="background-color: #00ffff; width: 40px; height: 40px; border: 2px solid #ccc; border-radius: 4px; cursor: pointer;" data-color="#00ffff" onclick="document.getElementById('font-color').value='#00ffff'; miniWord.applyColorDirect('#00ffff');"></div>
<div class="color-option" style="background-color: #808080; width: 40px; height: 40px; border: 2px solid #ccc; border-radius: 4px; cursor: pointer;" data-color="#808080" onclick="document.getElementById('font-color').value='#808080'; miniWord.applyColorDirect('#808080');"></div>
</div>
<div class="button-group" style="margin-top: 20px;">
<button class="btn btn-primary" onclick="miniWord.fontColor()" style="background-color: #007bff; color: white; padding: 12px 24px; border: none; border-radius: 4px; font-size: 16px; cursor: pointer; margin-right: 10px;">π¨ Apply Color</button>
<button class="btn" onclick="miniWord.showPage('format')" style="background-color: #6c757d; color: white; padding: 12px 24px; border: none; border-radius: 4px; font-size: 16px; cursor: pointer;">Back to Format</button>
</div>
<div style="margin-top: 15px; padding: 10px; background-color: #f8f9fa; border-radius: 4px; font-size: 14px; color: #666;">
<strong>Instructions:</strong><br>
1. First select the text in the editor to set color<br>
2. Choose color (click color square or use color picker)<br>
3. Click "Apply Color" button
</div>
</div>
`
},
'insert_table': {
title: 'Insert Table',
content: `
<div class="page-content">
<h2>Insert Table</h2>
<p>Insert a table into your document with customizable rows and columns.</p>
<div class="input-group">
<label>Select Table Size:</label>
<div class="table-preview" id="table-size-preview"></div>
</div>
<div class="button-group">
<button class="btn btn-primary" onclick="miniWord.insertSelectedTable()">Insert Table</button>
<button class="btn" onclick="miniWord.showPage('insert')">Back to Insert</button>
</div>
</div>
`
},
'insert_chart': {
title: 'Insert Chart',
content: `
<div class="page-content">
<h2>Insert Chart</h2>
<p>Insert various types of charts in document based on table data.</p>
<div class="feature-info">
<h3>Features:</h3>
<ul>
<li>π Bar Chart - Display data as vertical bars</li>
<li>π₯§ Pie Chart - Show data as proportional slices</li>
<li>π Auto-detect tables in document</li>
<li>βοΈ Manual data input option</li>
</ul>
<h3>How to use:</h3>
<ol>
<li>Insert a table in your document</li>
<li>Click "Insert Chart" button</li>
<li>Select chart type and options</li>
<li>Choose data source (auto-detect or manual)</li>
<li>Click "Insert Chart" to add to document</li>
</ol>
</div>
</div>
`
},
'help': {
title: 'Help and Instructions',
content: `
<div class="page-content">
<h2>Help and Instructions</h2>
<p>MiniWord User Guide and Interactive Help</p>
<!-- Quick Actions -->
<div class="help-actions">
<h3>Quick Actions</h3>
<div class="button-group">
<button class="btn btn-primary" onclick="miniWord.showKeyboardShortcuts()">Show Keyboard Shortcuts</button>
<button class="btn btn-info" onclick="miniWord.showTutorial()">Start Tutorial</button>
<button class="btn btn-warning" onclick="miniWord.resetToDefaults()">Reset to Defaults</button>
<button class="btn btn-success" onclick="miniWord.exportHelp()">Export Help Guide</button>
</div>
</div>
<!-- Interactive Help -->
<div class="interactive-help">
<h3>Interactive Help</h3>
<div class="form-group">
<label>Search Help:</label>
<input type="text" id="help-search" placeholder="Type your question here..." onkeyup="miniWord.searchHelp(this.value)">
<button class="btn btn-sm" onclick="miniWord.clearHelpSearch()">Clear</button>
</div>
<div id="help-results" class="help-results"></div>
</div>
<!-- Quick Tips -->
<div class="quick-tips">
<h3>Quick Tips</h3>
<div class="tip-card" onclick="miniWord.showTip('formatting')">
<h4>π‘ Formatting Tips</h4>
<p>Learn about text formatting options</p>
</div>
<div class="tip-card" onclick="miniWord.showTip('tables')">
<h4>π Table Management</h4>
<p>How to create and manage tables</p>
</div>
<div class="tip-card" onclick="miniWord.showTip('lists')">
<h4>π Lists and Bullets</h4>
<p>Creating bulleted and numbered lists</p>
</div>
<div class="tip-card" onclick="miniWord.showTip('comments')">
<h4>π¬ Comments and Reviews</h4>
<p>Adding and managing comments</p>
</div>
</div>
<!-- System Information -->
<div class="system-info">
<h3>System Information</h3>
<div class="info-grid">
<div class="info-item">
<strong>Version:</strong> <span id="app-version">MiniWord 1.0</span>
</div>
<div class="info-item">
<strong>Last Updated:</strong> <span id="last-updated">Today</span>
</div>
<div class="info-item">
<strong>Document Status:</strong> <span id="doc-status">Ready</span>
</div>
</div>
</div>
<!-- Keyboard Shortcuts (Collapsible) -->
<div class="keyboard-shortcuts">
<h3>Keyboard Shortcuts</h3>
<button class="btn btn-sm" onclick="miniWord.toggleShortcuts()">Toggle Shortcuts</button>
<div id="shortcuts-list" class="shortcuts-list" style="display: none;">
<div class="shortcut-category">
<h4>File Operations</h4>
<ul>
<li><kbd>Ctrl+N</kbd> New Document</li>
<li><kbd>Ctrl+O</kbd> Open Document</li>
<li><kbd>Ctrl+S</kbd> Save Document</li>
<li><kbd>Ctrl+P</kbd> Print Document</li>
</ul>
</div>
<div class="shortcut-category">
<h4>Edit Operations</h4>
<ul>
<li><kbd>Ctrl+Z</kbd> Undo</li>
<li><kbd>Ctrl+Y</kbd> Redo</li>
<li><kbd>Ctrl+X</kbd> Cut</li>
<li><kbd>Ctrl+C</kbd> Copy</li>
<li><kbd>Ctrl+V</kbd> Paste</li>
<li><kbd>Ctrl+F</kbd> Find</li>
<li><kbd>Ctrl+H</kbd> Replace</li>
</ul>
</div>
<div class="shortcut-category">
<h4>Formatting</h4>
<ul>
<li><kbd>Ctrl+B</kbd> Bold</li>
<li><kbd>Ctrl+I</kbd> Italic</li>
<li><kbd>Ctrl+U</kbd> Underline</li>
<li><kbd>Ctrl+K</kbd> Clear Formatting</li>
<li><kbd>Ctrl+J</kbd> Format Painter</li>
</ul>
</div>