terrastruct / d2-obsidian

The official D2 plugin for Obsidian. D2 is a modern diagram scripting language thats turns text to diagrams.
https://d2lang.com
Mozilla Public License 2.0
204 stars 12 forks source link

Fix PDF exports and Debouncer #31

Closed berniexie closed 1 year ago

berniexie commented 1 year ago

Removing the debounced initial load fixes the PDF exports. I also added some css to remove the Recompile button for PDF exports.

While working on this task, I realized that the debouncer/abort function was not functioning correctly for files opened in split views or those containing multiple D2 diagrams. I initially believed that the docId was an identifier generated by the plugin API to recognize individual code blocks within the callback. However, this was not the case. Consequently, I needed to find an alternative location to store the debouncer key. The sole location within the callback where I could store page-related information was ctx.containerEl, which is the entire page container element. By putting an id there, we will now have a debouncer for each separate page view (which is enough).

Test pdf generated with multiple diagrams: test.pdf