feat: add custom Typst icon to ribbon

- Import addIcon from Obsidian API
- Register custom SVG icon with 'typst-pdf-export' identifier
- Replace default 'type' icon with custom Typst logo icon
- Update SVG to include proper styling and fill color

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Jarvis committed 2025-09-03 10:59:31 +02:00
1 parent 305df30c85
commit ec4dc1d77c
2 files changed
+10 -5

No files matched your search

+9 -2
View File
@@ -5,6 +5,7 @@
import {
App,
addIcon,
Plugin,
PluginSettingTab,
Setting,
@@ -39,8 +40,14 @@ export class obsidianTypstPDFExport extends Plugin {
this.converter = new PandocTypstConverter(this);
this.templateManager = new TemplateManager(this);
// Add ribbon icon
this.addRibbonIcon('type', 'Export to PDF with Typst', (event: MouseEvent) => {
// Register custom icon
addIcon('typst-pdf-export', `<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" xml:space="preserve" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2">
<path d="m9.002 4.175 4.343-2.13V6l4.033-.304V8.13h-4.033c-.017.223-.001 8.368 0 9.432.001.65.889 1.217 1.551 1.217.775 0 3.102-1.217 3.102-1.217l.931 1.522s-2.741 1.774-4.033 2.129c-1.195.329-2.017.761-3.723 0-1.073-.478-2.144-1.582-2.171-2.738-.052-2.231 0-10.649 0-10.649L7.14 8.13l-.31-1.825L9.002 6z" style="fill:#828282"/>
</svg>
`);
// Add ribbon icon using custom icon
this.addRibbonIcon('typst-pdf-export', 'Export to PDF with Typst', (event: MouseEvent) => {
this.handleRibbonClick(event);
});
+1 -3
View File
@@ -1,3 +1 @@
<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" xml:space="preserve" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2">
<path d="m9.002 4.175 4.343-2.13V6l4.033-.304V8.13h-4.033c-.017.223-.001 8.368 0 9.432.001.65.889 1.217 1.551 1.217.775 0 3.102-1.217 3.102-1.217l.931 1.522s-2.741 1.774-4.033 2.129c-1.195.329-2.017.761-3.723 0-1.073-.478-2.144-1.582-2.171-2.738-.052-2.231 0-10.649 0-10.649L7.14 8.13l-.31-1.825L9.002 6z"/>
</svg>
<?xml version="1.0" encoding="UTF-8" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg width="100%" height="100%" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;"><path d="M9.002,4.175l4.343,-2.13l-0,3.955l4.033,-0.304l-0,2.434l-4.033,0c-0.017,0.223 -0.001,8.368 -0,9.432c0.001,0.65 0.889,1.217 1.551,1.217c0.775,0 3.102,-1.217 3.102,-1.217l0.931,1.522c-0,-0 -2.741,1.774 -4.033,2.129c-1.195,0.329 -2.017,0.761 -3.723,0c-1.073,-0.478 -2.144,-1.582 -2.171,-2.738c-0.052,-2.231 -0,-10.649 -0,-10.649l-1.862,0.304l-0.31,-1.825l2.172,-0.305l-0,-1.825Z" style="fill:#828282;"/></svg>

Before

Width:  |  Height:  |  Size: 485 B

After

Width:  |  Height:  |  Size: 855 B