Injecting custom CSS files in each WebView #72
-
We have created a custom CSS file for the comics book. What would be a good approach of injecting that CSS file into the each WebView? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
We plan to work soonish on an Injectable API to inject custom JavaScript and CSS but there's nothing available yet. However, you can implement a custom transformer for the HTML resources to use with the You can wrap the publication fetcher from the func injectCSS(_ resource: Resource) -> Resource {
...
}
streamer.open(
...,
onCreatePublication: { _, _, fetcher, _ in
fetcher = TransformingFetcher(fetcher: fetcher, transformers: [injectCSS]),
}
) Take a look at the
|
Beta Was this translation helpful? Give feedback.
We plan to work soonish on an Injectable API to inject custom JavaScript and CSS but there's nothing available yet.
However, you can implement a custom transformer for the HTML resources to use with the
TransformingFetcher
and inject the CSS yourself.You can wrap the publication fetcher from the
Streamer.open(onCreatePublication:)
closure:Take a look at the
EPUBHTMLInjector
for an example:swift-toolkit/Sources/Streamer/Parser/EPUB/Resource Transformers/EPUBHTML…