@@ -16,7 +16,7 @@ rtoqmd_addin <- function() {
1616 input_path <- context $ path
1717
1818 # Check if the document has been saved
19- if (is.null( input_path ) || length( input_path ) == 0 || input_path == " " ) {
19+ if (input_path == " " ) {
2020 rstudioapi :: showDialog(
2121 title = " Unsaved Document" ,
2222 message = " Please save your R script before converting it to Quarto markdown."
@@ -80,10 +80,6 @@ rtoqmd_addin <- function() {
8080 ui <- miniUI :: miniPage(
8181 shiny :: tags $ head(
8282 shiny :: tags $ style(shiny :: HTML("
83- .gadget-title {
84- background-color: #0073e6 !important;
85- color: white !important;
86- }
8783 .loader {
8884 position: fixed;
8985 top: 0;
@@ -125,6 +121,7 @@ rtoqmd_addin <- function() {
125121 ),
126122 miniUI :: gadgetTitleBar(
127123 " Convert R Script to Quarto" ,
124+ left = miniUI :: miniTitleBarCancelButton(" cancel" , " \u 21a9" ),
128125 right = shiny :: div(
129126 style = " display: flex; align-items: center; gap: 10px;" ,
130127 shiny :: actionButton(
@@ -138,23 +135,22 @@ rtoqmd_addin <- function() {
138135 french_flag_html ,
139136 style = " padding: 5px 10px; font-size: 12px;" ,
140137 class = " btn-sm"
141- )
138+ ),
139+ miniUI :: miniTitleBarButton(" done" , shiny :: HTML(" <span style='font-size: 16px; font-weight: bold;'>GENERATE \u 25b6</span>" ), primary = TRUE )
142140 )
143141 ),
144142 shiny :: div(id = " loader" , class = " loader" , shiny :: div(class = " spinner" )),
145143 miniUI :: miniContentPanel(
146144 shiny :: fillCol(
147145 flex = c(NA , 1 ),
148- # Generate button
149- shiny :: div(
150- style = " text-align: center; margin: 0; padding: 15px 0; background-color: #f8f9fa; border-bottom: 1px solid #dee2e6;" ,
151- logo_html ,
152- shiny :: br(),
153- shiny :: actionButton(" done" , " GENERATE" , class = " btn-primary btn-lg" , style = " font-size: 16px; font-weight: bold; padding: 10px 40px; margin-top: 10px;" )
154- ),
155146 shiny :: fillRow(
156147 shiny :: div(
157148 style = " padding: 20px; overflow-y: auto;" ,
149+ # Logo centered
150+ shiny :: div(
151+ style = " text-align: center; margin-bottom: 20px;" ,
152+ logo_html
153+ ),
158154 # Mode selection
159155 shiny :: fluidRow(
160156 shiny :: column(12 ,
@@ -342,49 +338,11 @@ rtoqmd_addin <- function() {
342338 ),
343339 shiny :: hr(),
344340 # Checkboxes in 2 columns
345- shiny :: fluidRow(
346- shiny :: column(6 ,
347- shiny :: checkboxInput(
348- " render" ,
349- shiny :: textOutput(" label_render" ),
350- value = TRUE
351- ),
352- shiny :: conditionalPanel(
353- condition = " input.conversion_mode == 'single'" ,
354- shiny :: checkboxInput(
355- " open_qmd" ,
356- shiny :: textOutput(" label_open_qmd" ),
357- value = TRUE
358- )
359- ),
360- shiny :: checkboxInput(
361- " number_sections" ,
362- shiny :: textOutput(" label_number_sections" ),
363- value = TRUE
364- )
365- ),
366- shiny :: column(6 ,
367- shiny :: checkboxInput(
368- " code_fold" ,
369- shiny :: textOutput(" label_code_fold" ),
370- value = FALSE
371- ),
372- shiny :: conditionalPanel(
373- condition = " input.conversion_mode == 'single'" ,
374- shiny :: checkboxInput(
375- " open_html" ,
376- shiny :: textOutput(" label_open_html" ),
377- value = FALSE
378- )
379- ),
380- shiny :: checkboxInput(
381- " show_source_lines" ,
382- shiny :: textOutput(" label_show_source_lines" ),
383- value = TRUE
384- ),
385- shiny :: uiOutput(" ui_code_quality" )
386- )
387- )
341+ shiny :: uiOutput(" ui_checkboxes" ),
342+
343+ # Code quality checkboxes
344+ shiny :: hr(),
345+ shiny :: uiOutput(" ui_code_quality" )
388346 )
389347 )
390348 )
@@ -559,8 +517,8 @@ rtoqmd_addin <- function() {
559517 number_sections = " Number sections automatically (not needed if sections already numbered)" ,
560518 show_source_lines = " Show original line numbers in code chunks" ,
561519 code_quality = " Code Quality Checks:" ,
562- use_styler = " Use styler formatting (show differences in tabsets )" ,
563- use_lintr = " Use lintr quality checks (show issues in tabsets )" ,
520+ use_styler = " Use styler formatting (shows styled version in tabs )" ,
521+ use_lintr = " Use lintr quality checks (shows issues in tabs )" ,
564522 apply_styler = " Apply styler to source file (modifies original R file)"
565523 ),
566524 fr = list (
@@ -577,14 +535,14 @@ rtoqmd_addin <- function() {
577535 author = " Nom de l'auteur :" ,
578536 theme = " Theme HTML :" ,
579537 render = " Generer Html apres conversion" ,
580- open_html = " Ouvrir le fichier Html apr \\ u00e8s rendu" ,
538+ open_html = " Ouvrir le fichier Html apres rendu" ,
581539 open_qmd = " Ouvrir le fichier .qmd dans l'editeur apres conversion" ,
582- code_fold = " Replier les blocs de code par d \\ u00e9faut " ,
583- number_sections = " Numeroter les sections automatiquement (pas utile si vos sections sont deja numerotees)" ,
540+ code_fold = " Replier les blocs de code par defaut " ,
541+ number_sections = " Numeroter les sections automatiquement (pas utile si vos sections sont dej \u 00e0 numerotees)" ,
584542 show_source_lines = " Afficher les numeros de ligne originaux dans les chunks" ,
585543 code_quality = " Verifications de la qualite du code :" ,
586- use_styler = " Utiliser styler (afficher les differences dans les tabsets )" ,
587- use_lintr = " Utiliser lintr (afficher les problemes dans les tabsets )" ,
544+ use_styler = " Utiliser styler pour le formatage (affiche la version stylisee dans des onglets )" ,
545+ use_lintr = " Utiliser lintr pour la qualite du code (affiche les problemes dans des onglets )" ,
588546 apply_styler = " Appliquer styler au fichier source (modifie le fichier R original)"
589547 )
590548 )
@@ -618,9 +576,30 @@ rtoqmd_addin <- function() {
618576 output $ label_html_file_optional <- shiny :: renderText({ translations [[lang()]]$ html_file_optional })
619577 output $ label_title <- shiny :: renderText({ translations [[lang()]]$ title })
620578 output $ label_author <- shiny :: renderText({ translations [[lang()]]$ author })
621- output $ label_code_fold <- shiny :: renderText({ translations [[lang()]]$ code_fold })
622- output $ label_number_sections <- shiny :: renderText({ translations [[lang()]]$ number_sections })
623- output $ label_show_source_lines <- shiny :: renderText({ translations [[lang()]]$ show_source_lines })
579+ output $ label_theme <- shiny :: renderText({ translations [[lang()]]$ theme })
580+
581+ # Render main checkboxes with dynamic labels
582+ output $ ui_checkboxes <- shiny :: renderUI({
583+ trans <- translations [[lang()]]
584+ shiny :: fluidRow(
585+ shiny :: column(6 ,
586+ shiny :: checkboxInput(" render" , trans $ render , value = TRUE ),
587+ shiny :: conditionalPanel(
588+ condition = " input.conversion_mode == 'single'" ,
589+ shiny :: checkboxInput(" open_qmd" , trans $ open_qmd , value = TRUE )
590+ ),
591+ shiny :: checkboxInput(" number_sections" , trans $ number_sections , value = TRUE )
592+ ),
593+ shiny :: column(6 ,
594+ shiny :: checkboxInput(" code_fold" , trans $ code_fold , value = FALSE ),
595+ shiny :: conditionalPanel(
596+ condition = " input.conversion_mode == 'single'" ,
597+ shiny :: checkboxInput(" open_html" , trans $ open_html , value = FALSE )
598+ ),
599+ shiny :: checkboxInput(" show_source_lines" , trans $ show_source_lines , value = TRUE )
600+ )
601+ )
602+ })
624603
625604 # Render code quality checkboxes with dynamic labels
626605 output $ ui_code_quality <- shiny :: renderUI({
@@ -633,10 +612,6 @@ rtoqmd_addin <- function() {
633612 )
634613 })
635614
636- # When done button is pressedny::renderText({ translations[[lang()]]$code_fold })
637- output $ label_number_sections <- shiny :: renderText({ translations [[lang()]]$ number_sections })
638- output $ label_show_source_lines <- shiny :: renderText({ translations [[lang()]]$ show_source_lines })
639-
640615 # When done button is pressed
641616 shiny :: observeEvent(input $ done , {
642617
@@ -657,6 +632,9 @@ rtoqmd_addin <- function() {
657632 code_fold <- input $ code_fold
658633 number_sections <- input $ number_sections
659634 show_source_lines <- input $ show_source_lines
635+ use_styler <- input $ use_styler
636+ use_lintr <- input $ use_lintr
637+ apply_styler <- input $ apply_styler
660638
661639 # Convert based on mode
662640 tryCatch({
@@ -672,15 +650,12 @@ rtoqmd_addin <- function() {
672650 author = author ,
673651 format = " html" ,
674652 theme = theme ,
675- render_html = render ,
653+ render = render ,
676654 output_dir = output_dir ,
677655 create_book = create_book_val ,
678656 code_fold = code_fold ,
679657 number_sections = number_sections ,
680- language = lang(),
681- use_styler = input $ use_styler ,
682- use_lintr = input $ use_lintr ,
683- apply_styler = input $ apply_styler
658+ language = lang()
684659 )
685660
686661 # If rendering, wait for index.html to be created
@@ -715,16 +690,16 @@ rtoqmd_addin <- function() {
715690 author = author ,
716691 format = " html" ,
717692 theme = theme ,
718- render_html = render ,
693+ render = render ,
719694 output_html_file = html_file_final ,
720695 open_html = open_html && render ,
721696 code_fold = code_fold ,
722697 number_sections = number_sections ,
723698 lang = lang(),
724699 show_source_lines = show_source_lines ,
725- use_styler = input $ use_styler ,
726- use_lintr = input $ use_lintr ,
727- apply_styler = input $ apply_styler
700+ use_styler = use_styler ,
701+ use_lintr = use_lintr ,
702+ apply_styler = apply_styler
728703 )
729704 }
730705
@@ -738,9 +713,9 @@ rtoqmd_addin <- function() {
738713
739714 # Show success message based on language
740715 success_msg <- if (lang() == " fr" ) {
741- " [OK] Conversion terminee avec succes !"
716+ " \u 2705 Conversion terminee avec succes !"
742717 } else {
743- " [OK] Conversion completed successfully!"
718+ " \u 2705 Conversion completed successfully!"
744719 }
745720
746721 shiny :: showNotification(
@@ -761,6 +736,10 @@ rtoqmd_addin <- function() {
761736 })
762737 })
763738
739+ # When cancel button is pressed
740+ shiny :: observeEvent(input $ cancel , {
741+ shiny :: stopApp()
742+ })
764743 }
765744
766745 # Run the gadget
@@ -769,3 +748,29 @@ rtoqmd_addin <- function() {
769748
770749 invisible ()
771750}
751+
752+ # ' Launch Quartify Shiny Interface
753+ # '
754+ # ' Opens the Quartify conversion interface in your default web browser.
755+ # ' This function provides the same interface as the RStudio add-in but works
756+ # ' in any R environment including Positron, VS Code, RStudio, or command line.
757+ # ' Unlike the add-in, this function requires you to manually select input files
758+ # ' using the file browser in the interface.
759+ # '
760+ # ' @param launch.browser Logical, whether to open in browser (default: TRUE).
761+ # ' Set to FALSE to run in RStudio Viewer pane if available.
762+ # ' @param port The port to run the app on (default: random available port)
763+ # ' @return Invisibly returns NULL when the app is closed
764+ # ' @importFrom shiny runApp fluidPage titlePanel sidebarLayout sidebarPanel mainPanel
765+ # ' @export
766+ # ' @examples
767+ # ' \dontrun{
768+ # ' # Launch the Shiny app in browser (works in any IDE)
769+ # ' quartify_app()
770+ # '
771+ # ' # Use in Positron or VS Code
772+ # ' library(quartify)
773+ # ' quartify_app()
774+ # '
775+ # ' # Specify a port
776+ # ' quartify_app(port = 3838)
0 commit comments