@@ -54,6 +54,8 @@ <h5 class="modal-title" id="mediaSelectModalLabel">Select Media</h5>
54
54
</ div >
55
55
< div class ="modal-body ">
56
56
< select id ="mediaFileSelect " class ="form-select mb-3 "> </ select >
57
+ < input type ="file " webkitRelativePath id ="fileMediaSelect-select " class ="form-control mb-3 " placeholder ="Select a file from the media folder ">
58
+ < p id ="fileMediaSelect-feedback "> </ p >
57
59
< input type ="text " id ="newFileName " class ="form-control mb-3 " placeholder ="New file name (without extension) ">
58
60
< input type ="text " id ="altText " class ="form-control " placeholder ="Alt text for image ">
59
61
</ div >
@@ -65,6 +67,33 @@ <h5 class="modal-title" id="mediaSelectModalLabel">Select Media</h5>
65
67
</ div >
66
68
</ div >
67
69
70
+ < div class ="modal fade " id ="blockquoteModal " tabindex ="-1 " aria-labelledby ="blockquoteModalLabel " aria-hidden ="true ">
71
+ < div class ="modal-dialog ">
72
+ < div class ="modal-content ">
73
+ < div class ="modal-header ">
74
+ < h5 class ="modal-title " id ="blockquoteModalLabel "> Insert Blockqoute Code</ h5 >
75
+ < button type ="button " class ="btn-close " data-bs-dismiss ="modal " aria-label ="Close "> </ button >
76
+ </ div >
77
+ < div class ="modal-body ">
78
+ < select id ="blockquoteSelect " class ="form-select mb-3 ">
79
+ < option value ="> [!NOTE] "> NOTE</ option >
80
+ < option value ="> [!TIP] "> TIP</ option >
81
+ < option value ="> [!IMPORTANT] "> IMPORTANT</ option >
82
+ < option value ="> [!WARNING] "> WARNING</ option >
83
+ < option value ="> [!CAUTION] "> CAUTION</ option >
84
+ < option value ="> "> Only Quote</ option >
85
+ </ select >
86
+ < textarea title ="blockquoteEditor " id ="blockquoteContent " class ="form-control " rows ="10 "> </ textarea >
87
+ </ div >
88
+ < div class ="modal-footer ">
89
+ < button type ="button " class ="btn btn-secondary " data-bs-dismiss ="modal "> Cancel</ button >
90
+ < button type ="button " class ="btn btn-primary " onclick ="insertBlockquoteCode() "> Enter</ button >
91
+ </ div >
92
+ </ div >
93
+ </ div >
94
+ </ div >
95
+
96
+
68
97
<!-- Colored Code Dialog -->
69
98
< div class ="modal fade " id ="coloredCodeModal " tabindex ="-1 " aria-labelledby ="coloredCodeModalLabel " aria-hidden ="true ">
70
99
< div class ="modal-dialog ">
@@ -244,6 +273,9 @@ <h5 class="modal-title" id="internalLinksModalLabel">Insert Internal Link</h5>
244
273
case 'internalLink' :
245
274
showInternalLinksDialog ( ) ;
246
275
break ;
276
+ case 'blockquoteSelect' :
277
+ showModal ( 'blockquoteModal' ) ;
278
+ break ;
247
279
default :
248
280
doc . replaceRange ( value , cursor ) ;
249
281
}
@@ -262,6 +294,22 @@ <h5 class="modal-title" id="internalLinksModalLabel">Insert Internal Link</h5>
262
294
hideModal ( 'coloredCodeModal' ) ;
263
295
}
264
296
297
+ function insertBlockquoteCode ( ) {
298
+ const blockquote = document . getElementById ( 'blockquoteSelect' ) . value ;
299
+ const text = document . getElementById ( 'blockquoteContent' ) . value ;
300
+ const formattedText = blockquote + "\n" + addPrefixToLines ( text ) ;
301
+ editor . getDoc ( ) . replaceSelection ( formattedText ) ;
302
+ hideModal ( 'blockquoteModal' ) ;
303
+ }
304
+
305
+ function addPrefixToLines ( text ) {
306
+ var lines = text . split ( '\n' ) ;
307
+ for ( var i = 0 ; i < lines . length ; i ++ ) {
308
+ lines [ i ] = "> " + lines [ i ] ;
309
+ }
310
+ return lines . join ( '\n' ) ;
311
+ }
312
+
265
313
function showInternalLinksDialog ( ) {
266
314
const select = document . getElementById ( 'internalLinkSelect' ) ;
267
315
select . innerHTML = '' ;
@@ -332,6 +380,9 @@ <h5 class="modal-title" id="internalLinksModalLabel">Insert Internal Link</h5>
332
380
case 'mediaSelect' :
333
381
showMediaSelectDialog ( ) ;
334
382
break ;
383
+ case 'blockquoteSelect' :
384
+ showModal ( 'blockquoteModal' ) ;
385
+ break ;
335
386
default :
336
387
doc . replaceRange ( value , cursor ) ;
337
388
}
@@ -350,12 +401,23 @@ <h5 class="modal-title" id="internalLinksModalLabel">Insert Internal Link</h5>
350
401
option . textContent = file ;
351
402
select . appendChild ( option ) ;
352
403
} ) ;
404
+ // TODO change, only for testing now -> create this as example for testing purposes:
405
+ var fileName = document . getElementById ( "file-select" ) . value ;
406
+ var newFileName = fileName . replace ( / \. m d $ / , '_1' ) ; // Replace .md with 1
407
+ document . getElementById ( "newFileName" ) . defaultValue = newFileName ;
408
+ document . getElementById ( "altText" ) . defaultValue = newFileName ;
353
409
showModal ( 'mediaSelectModal' ) ;
354
410
} ) ;
355
411
}
356
412
357
413
function insertMediaFile ( ) {
358
- const file = document . getElementById ( 'mediaFileSelect' ) . value ;
414
+ var file = document . getElementById ( 'mediaFileSelect' ) . value ;
415
+ console . log ( file )
416
+ const fileMediaSelect = document . getElementById ( 'fileMediaSelect-select' ) . files [ 0 ] . name ;
417
+ if ( fileMediaSelect != null && fileMediaSelect ) {
418
+ file = fileMediaSelect ;
419
+ console . log ( file )
420
+ }
359
421
const newName = document . getElementById ( 'newFileName' ) . value ;
360
422
const altText = document . getElementById ( 'altText' ) . value ;
361
423
@@ -374,6 +436,24 @@ <h5 class="modal-title" id="internalLinksModalLabel">Insert Internal Link</h5>
374
436
} ) ;
375
437
}
376
438
439
+ document . getElementById ( "fileMediaSelect-select" ) . addEventListener ( "change" , function ( ) {
440
+ var fileInput = document . getElementById ( "fileMediaSelect-select" ) ;
441
+ var filePath = fileInput . value ;
442
+
443
+ var feedback = document . getElementById ( "fileMediaSelect-feedback" ) ;
444
+
445
+ // Check if the selected file is in the ./mediaSet folder
446
+ // TODO check against the media file list /api/media-list
447
+ if ( true ) {
448
+ feedback . textContent = "File selected: " + fileInput . files [ 0 ] . name ;
449
+ feedback . style . color = "green" ;
450
+ } else {
451
+ feedback . textContent = "Please select a file from the media folder." ;
452
+ feedback . style . color = "red" ;
453
+ fileInput . value = "" ; // Clear the input
454
+ }
455
+ } ) ;
456
+
377
457
function toggleFullscreen ( ) {
378
458
const editorWrapper = editor . getWrapperElement ( ) ;
379
459
if ( ! document . fullscreenElement ) {
@@ -486,6 +566,8 @@ <h5 class="modal-title" id="internalLinksModalLabel">Insert Internal Link</h5>
486
566
} ) ;
487
567
}
488
568
569
+
570
+
489
571
function pasteFromClipboard ( ) {
490
572
navigator . clipboard . readText ( )
491
573
. then ( text => {
0 commit comments