Skip to content

Commit

Permalink
fix: issue with icon color in icon in link live preview (#411)
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorianWoelki committed Mar 30, 2024
1 parent 2679926 commit 650da87
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const buildLinkDecorations = (

if (possibleIcon) {
const iconDecoration = Decoration.widget({
widget: new IconInLinkWidget(plugin, possibleIcon),
widget: new IconInLinkWidget(plugin, possibleIcon, file.path),
});

builder.add(node.from, node.from, iconDecoration);
Expand Down
4 changes: 4 additions & 0 deletions src/editor/live-preview/widgets/icon-in-link.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export class IconInLinkWidget extends WidgetType {
constructor(
public plugin: IconFolderPlugin,
public iconData: Icon | string,
public path: string,
) {
super();
}
Expand All @@ -16,6 +17,9 @@ export class IconInLinkWidget extends WidgetType {
typeof this.iconData === 'string'
? this.iconData
: this.iconData.prefix + this.iconData.name;
iconNode.style.color =
this.plugin.getIconColor(this.path) ??
this.plugin.getSettings().iconColor;
iconNode.setAttribute('title', iconName);
iconNode.classList.add('iconize-icon-in-link');

Expand Down
4 changes: 4 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -715,6 +715,10 @@ export default class IconFolderPlugin extends Plugin {
getIconColor(path: string): string | undefined {
const pathData = this.getData()[path];

if (!pathData) {
return undefined;
}

if (typeof pathData === 'string') {
return undefined;
}
Expand Down

0 comments on commit 650da87

Please sign in to comment.