mirror of
https://github.com/Myriad-Dreamin/tinymist.git
synced 2025-07-24 13:13:43 +00:00
feat: execute export and query on the task model (#1214)
* feat: extract id and doc id from config * dev: merge `TaskWhen` and move `PathPattern` * g * dev: let it compile * dev: rename a bit * dev: finish cmd conversions * dev: configure server * dev: run export * dev: clean code * dev: parse gap on export * fix: when test
This commit is contained in:
parent
86d3b912d4
commit
1b80d8c31d
14 changed files with 608 additions and 592 deletions
|
@ -155,80 +155,18 @@ mod polymorphic {
|
|||
use completion::CompletionList;
|
||||
use lsp_types::TextEdit;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use tinymist_project::ProjectTask;
|
||||
use typst::foundations::Dict;
|
||||
|
||||
use super::prelude::*;
|
||||
use super::*;
|
||||
|
||||
#[derive(Default, Debug, Clone, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub enum PageSelection {
|
||||
#[default]
|
||||
First,
|
||||
Merged {
|
||||
gap: Option<String>,
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum ExportKind {
|
||||
Pdf {
|
||||
creation_timestamp: Option<chrono::DateTime<chrono::Utc>>,
|
||||
},
|
||||
Html {},
|
||||
Markdown {},
|
||||
Text {},
|
||||
Query {
|
||||
format: String,
|
||||
output_extension: Option<String>,
|
||||
strict: bool,
|
||||
selector: String,
|
||||
field: Option<String>,
|
||||
one: bool,
|
||||
pretty: bool,
|
||||
},
|
||||
Svg {
|
||||
page: PageSelection,
|
||||
},
|
||||
Png {
|
||||
ppi: Option<f64>,
|
||||
fill: Option<String>,
|
||||
page: PageSelection,
|
||||
},
|
||||
}
|
||||
|
||||
impl Default for ExportKind {
|
||||
fn default() -> Self {
|
||||
Self::Pdf {
|
||||
creation_timestamp: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl ExportKind {
|
||||
pub fn extension(&self) -> &str {
|
||||
match self {
|
||||
Self::Pdf { .. } => "pdf",
|
||||
Self::Html { .. } => "html",
|
||||
Self::Markdown { .. } => "md",
|
||||
Self::Text { .. } => "txt",
|
||||
Self::Svg { .. } => "svg",
|
||||
Self::Png { .. } => "png",
|
||||
Self::Query {
|
||||
format,
|
||||
output_extension,
|
||||
..
|
||||
} => output_extension.as_deref().unwrap_or(format),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct OnExportRequest {
|
||||
/// The path of the document to export.
|
||||
pub path: PathBuf,
|
||||
/// The kind of the export.
|
||||
pub kind: ExportKind,
|
||||
/// The export task to run.
|
||||
pub task: ProjectTask,
|
||||
/// Whether to open the exported file(s) after the export is done.
|
||||
pub open: bool,
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue