Add artboard name to the export when exporting a single artboard (#3613)

* add artboard name to the export

* change file name to {docname}-{artboard} for more than 1 arboard

* add switch statement instead of if else
This commit is contained in:
Ayush Amawate 2026-01-11 17:58:19 +05:30 committed by GitHub
parent 1b91198b28
commit d98f19bf4a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 30 additions and 8 deletions

View File

@ -43,13 +43,21 @@ impl MessageHandler<ExportDialogMessage, ExportDialogMessageContext<'_>> for Exp
ExportDialogMessage::TransparentBackground { transparent } => self.transparent_background = transparent,
ExportDialogMessage::ExportBounds { bounds } => self.bounds = bounds,
ExportDialogMessage::Submit => responses.add_front(PortfolioMessage::SubmitDocumentExport {
name: portfolio.active_document().map(|document| document.name.clone()).unwrap_or_default(),
file_type: self.file_type,
scale_factor: self.scale_factor,
bounds: self.bounds,
transparent_background: self.file_type != FileType::Jpg && self.transparent_background,
}),
ExportDialogMessage::Submit => {
let artboard_name = match self.bounds {
ExportBounds::Artboard(layer) => self.artboards.get(&layer).cloned(),
_ => None,
};
responses.add_front(PortfolioMessage::SubmitDocumentExport {
name: portfolio.active_document().map(|document| document.name.clone()).unwrap_or_default(),
file_type: self.file_type,
scale_factor: self.scale_factor,
bounds: self.bounds,
transparent_background: self.file_type != FileType::Jpg && self.transparent_background,
artboard_name,
artboard_count: self.artboards.len(),
})
}
}
self.send_dialog_to_frontend(responses);

View File

@ -124,6 +124,8 @@ pub enum PortfolioMessage {
scale_factor: f64,
bounds: ExportBounds,
transparent_background: bool,
artboard_name: Option<String>,
artboard_count: usize,
},
SubmitActiveGraphRender,
SubmitGraphRender {

View File

@ -1036,6 +1036,8 @@ impl MessageHandler<PortfolioMessage, PortfolioMessageContext<'_>> for Portfolio
scale_factor,
bounds,
transparent_background,
artboard_name,
artboard_count,
} => {
let document = self.active_document_id.and_then(|id| self.documents.get_mut(&id)).expect("Tried to render non-existent document");
let export_config = ExportConfig {
@ -1044,6 +1046,8 @@ impl MessageHandler<PortfolioMessage, PortfolioMessageContext<'_>> for Portfolio
scale_factor,
bounds,
transparent_background,
artboard_name,
artboard_count,
..Default::default()
};
let result = self.executor.submit_document_export(document, self.active_document_id.unwrap(), export_config);

View File

@ -242,6 +242,8 @@ impl NodeGraphExecutor {
scale_factor,
#[cfg(feature = "gpu")]
transparent_background,
artboard_name,
artboard_count,
..
} = export_config;
@ -250,7 +252,11 @@ impl NodeGraphExecutor {
FileType::Png => "png",
FileType::Jpg => "jpg",
};
let name = format!("{name}.{file_extension}");
let base_name = match (artboard_name, artboard_count) {
(Some(artboard_name), count) if count > 1 => format!("{name} - {artboard_name}"),
_ => name,
};
let name = format!("{base_name}.{file_extension}");
match node_graph_output {
TaggedValue::RenderOutput(RenderOutput {

View File

@ -85,6 +85,8 @@ pub struct ExportConfig {
pub bounds: ExportBounds,
pub transparent_background: bool,
pub size: DVec2,
pub artboard_name: Option<String>,
pub artboard_count: usize,
}
#[derive(Clone)]