Skip to content

Commit a7879ab

Browse files
committed
refactor: icon pack manager
1 parent 3fee512 commit a7879ab

File tree

24 files changed

+1060
-914
lines changed

24 files changed

+1060
-914
lines changed

src/editor/icons-suggestion.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import {
66
EditorSuggestContext,
77
EditorSuggestTriggerInfo,
88
} from 'obsidian';
9-
import { getAllLoadedIconNames } from '@app/icon-pack-manager';
109
import icon from '@app/lib/icon';
1110
import emoji from '@app/emoji';
1211
import { saveIconToIconPack } from '@app/util';
@@ -69,8 +68,9 @@ export default class SuggestionIcon extends EditorSuggest<string> {
6968
.toLowerCase();
7069

7170
// Store all icons corresponding to the current query.
72-
const iconsNameArray = getAllLoadedIconNames()
73-
.filter((iconObject) => {
71+
const iconsNameArray = this.plugin
72+
.getIconPackManager()
73+
.allLoadedIconNames.filter((iconObject) => {
7474
const name =
7575
iconObject.prefix.toLowerCase() + iconObject.name.toLowerCase();
7676
return name.toLowerCase().includes(queryLowerCase);
@@ -87,7 +87,7 @@ export default class SuggestionIcon extends EditorSuggest<string> {
8787
}
8888

8989
renderSuggestion(value: string, el: HTMLElement): void {
90-
const iconObject = icon.getIconByName(value);
90+
const iconObject = icon.getIconByName(this.plugin, value);
9191
el.style.display = 'flex';
9292
el.style.alignItems = 'center';
9393
el.style.gap = '0.25rem';

src/editor/live-preview/state.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ export const buildPositionField = (plugin: IconizePlugin) => {
8484
identifier.length,
8585
rawCode.length - identifier.length,
8686
);
87-
if (!icon.getIconByName(iconName)) {
87+
if (!icon.getIconByName(plugin, iconName)) {
8888
continue;
8989
}
9090

src/editor/live-preview/widgets/icon-in-text.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export class IconInTextWidget extends WidgetType {
6161
},
6262
});
6363

64-
const foundIcon = icon.getIconByName(this.id);
64+
const foundIcon = icon.getIconByName(this.plugin, this.id);
6565
const fontSize = this.getSize(view);
6666

6767
if (foundIcon) {

src/editor/markdown-processors/icon-in-link.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ export const processIconInLinkMarkdown = (
7878
rootSpan.style.transform = 'translateY(0)';
7979
rootSpan.innerHTML = parsedEmoji;
8080
} else {
81-
let svgEl = icon.getIconByName(iconName).svgElement;
81+
let svgEl = icon.getIconByName(plugin, iconName).svgElement;
8282
svgEl = svg.setFontSize(svgEl, fontSize);
8383
if (svgEl) {
8484
rootSpan.style.transform = 'translateY(20%)';

src/editor/markdown-processors/icon-in-text.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ export const processIconInTextMarkdown = (
9898
shortcode.length - iconIdentifierLength,
9999
);
100100

101-
const iconObject = icon.getIconByName(iconName);
101+
const iconObject = icon.getIconByName(plugin, iconName);
102102
if (iconObject) {
103103
const toReplace = text.splitText(code.index);
104104
const rootSpan = createSpan({

0 commit comments

Comments
 (0)