diff --git a/crates/doc/src/lib.rs b/crates/doc/src/lib.rs index cb481734a..c4180f490 100644 --- a/crates/doc/src/lib.rs +++ b/crates/doc/src/lib.rs @@ -100,7 +100,7 @@ pub use metadata::{CopyrightStatus, DocMetadata}; pub use node::Knockout; pub use node::Scaling; pub use node::{Extras, ExtrasMut, ImageObject, LAYER_COLORS, LayerColor, LiveShape, Node, NodeExtras, NodeId, NodeKind, OpacityMask}; -pub use node::{ImageMap, ObjectAttributes}; +pub use node::{ImageMap, MAX_SVG_SCRIPTS, ObjectAttributes, SVG_EVENTS}; pub use orient::OrientedBox; pub use pattern::{Overlap, PatternDef, PatternEdit, RepeatKind, RepeatSpec, TileType}; pub use perspective::PerspectiveAttachment; @@ -731,6 +731,10 @@ pub struct Document { /// export settings are Export for Screens' ([`Document::export_settings`]). #[serde(default, skip_serializing_if = "Vec::is_empty")] pub assets: Vec, + /// Window › SVG Interactivity › Link JavaScript Files: the JavaScript files (paths or URLs, as + /// given) SVG export links with ` + + "#); + let (doc, warnings) = import_with(&text, &ImportOptions { folder: Some("/tmp"), read: Some(&read) }).unwrap(); + let asked = asked.lock().unwrap().clone(); + assert!(asked.iter().any(|p| p.contains("photo.png")) && !asked.iter().any(|p| p.contains("evil")), "read {asked:?}"); + assert_eq!(doc.svg_scripts, ["evil.js"], "each link once, the inline script left out"); + assert!(warnings.iter().any(|w| w.contains("inline scripts were left out")), "{warnings:?}"); + assert_eq!(events(&doc, "shape"), [pair("onclick", "fetch('https://example.com')")]); + assert_eq!(doc.title, "Untitled-1", "the inline script didn't run"); +} +/// Import keeps the first 64 different `