Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: icon pack manager #631

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/editor/icons-suggestion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
EditorSuggestContext,
EditorSuggestTriggerInfo,
} from 'obsidian';
import { getAllLoadedIconNames } from '@app/icon-pack-manager';
import icon from '@app/lib/icon';
import emoji from '@app/emoji';
import { saveIconToIconPack } from '@app/util';
Expand Down Expand Up @@ -69,8 +68,9 @@ export default class SuggestionIcon extends EditorSuggest<string> {
.toLowerCase();

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

renderSuggestion(value: string, el: HTMLElement): void {
const iconObject = icon.getIconByName(value);
const iconObject = icon.getIconByName(this.plugin, value);
el.style.display = 'flex';
el.style.alignItems = 'center';
el.style.gap = '0.25rem';
Expand Down
2 changes: 1 addition & 1 deletion src/editor/live-preview/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export const buildPositionField = (plugin: IconizePlugin) => {
identifier.length,
rawCode.length - identifier.length,
);
if (!icon.getIconByName(iconName)) {
if (!icon.getIconByName(plugin, iconName)) {
continue;
}

Expand Down
2 changes: 1 addition & 1 deletion src/editor/live-preview/widgets/icon-in-text.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export class IconInTextWidget extends WidgetType {
},
});

const foundIcon = icon.getIconByName(this.id);
const foundIcon = icon.getIconByName(this.plugin, this.id);
const fontSize = this.getSize(view);

if (foundIcon) {
Expand Down
2 changes: 1 addition & 1 deletion src/editor/markdown-processors/icon-in-link.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export const processIconInLinkMarkdown = (
rootSpan.style.transform = 'translateY(0)';
rootSpan.innerHTML = parsedEmoji;
} else {
let svgEl = icon.getIconByName(iconName).svgElement;
let svgEl = icon.getIconByName(plugin, iconName).svgElement;
svgEl = svg.setFontSize(svgEl, fontSize);
if (svgEl) {
rootSpan.style.transform = 'translateY(20%)';
Expand Down
2 changes: 1 addition & 1 deletion src/editor/markdown-processors/icon-in-text.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export const processIconInTextMarkdown = (
shortcode.length - iconIdentifierLength,
);

const iconObject = icon.getIconByName(iconName);
const iconObject = icon.getIconByName(plugin, iconName);
if (iconObject) {
const toReplace = text.splitText(code.index);
const rootSpan = createSpan({
Expand Down
Loading
Loading