Skip to content

DesignCraft: An open-source page and layout design editor written by scratch in pure Rust

Integration: .indd and .indt files open through the converter

aiongg0209b6781b43
diff --git a/crates/engine/src/cmd/file.rs b/crates/engine/src/cmd/file.rs
index 377c46a5e..26ae6dcff 100644
--- a/crates/engine/src/cmd/file.rs
+++ b/crates/engine/src/cmd/file.rs
@@ -448,19 +448,6 @@ fn file_open_recent(s: &mut Session, p: &Value) -> Result<Value> {
file_open(s, &json!({"path": path}))
}
-/// An InDesign file that DesignCraft can't open yet, with how to bring it over. Decoding one as a
-/// DesignCraft document only reported "not a DesignCraft document: expected value at line 1
-/// column 1" (#21).
-fn foreign_document(name: &str) -> Option<&'static str> {
- let ext = std::path::Path::new(name).extension().and_then(|e| e.to_str())?.to_ascii_lowercase();
- match ext.as_str() {
- "indd" | "indt" => Some(
- "InDesign documents (.indd) and templates (.indt) can't be opened yet. In InDesign, choose File ▸ Export… ▸ InDesign Markup (IDML) and open the .idml in DesignCraft.",
- ),
- _ => None,
- }
-}
-
/// `file.open`: the document opens and moves to the front of File › Open Recent.
fn file_open(s: &mut Session, p: &Value) -> Result<Value> {
let r = open_path(s, p)?;
@@ -472,9 +459,6 @@ fn file_open(s: &mut Session, p: &Value) -> Result<Value> {
fn open_path(s: &mut Session, p: &Value) -> Result<Value> {
let path = str_param(p, "path").ok_or_else(|| bad("file.open", "missing `path`"))?;
- if let Some(hint) = foreign_document(path) {
- return Err(EngineError::Other(format!("{path}: {hint}")));
- }
#[cfg(not(target_arch = "wasm32"))]
{
let bytes = crate::io::read_file(path).map_err(EngineError::Other)?;
@@ -547,11 +531,6 @@ fn document_fonts_folder(dir: &std::path::Path) -> std::path::PathBuf {
}
fn file_open_bytes(s: &mut Session, p: &Value) -> Result<Value> {
- if let Some(name) = str_param(p, "name")
- && let Some(hint) = foreign_document(name)
- {
- return Err(EngineError::Other(format!("{name}: {hint}")));
- }
let b = base64_decode(str_param(p, "base64").unwrap_or(""));
// IDML packages are recognised by their stored `mimetype` first entry, INDD files by their
// signature (or their name).
diff --git a/crates/engine/src/cmd/interchange.rs b/crates/engine/src/cmd/interchange.rs
index d53905b54..6d482c959 100644
--- a/crates/engine/src/cmd/interchange.rs
+++ b/crates/engine/src/cmd/interchange.rs
@@ -251,7 +251,12 @@ pub(crate) fn open_idml(s: &mut Session, p: &Value) -> Result<Value> {
// share its buffer.
let mut previews = std::collections::HashMap::new();
let bytes = if is_indd(&file, &bytes) {
- let conversion = indd::convert(&bytes, &file).map_err(|e| EngineError::Other(format!("can't convert the InDesign file: {e}")))?;
+ // What the converter can't read still comes over as IDML (#21).
+ let conversion = indd::convert(&bytes, &file).map_err(|e| {
+ EngineError::Other(format!(
+ "can't convert the InDesign file: {e}. In InDesign, choose File ▸ Export… ▸ InDesign Markup (IDML) and open the .idml in DesignCraft."
+ ))
+ })?;
warnings.extend(conversion.warnings.iter().map(|w| w.message().to_string()));
for p in conversion.previews {
let data = std::sync::Arc::new(p.data);