|
1 | 1 | import IconizePlugin from '@app/main'; |
| 2 | +import dom from '@lib/util/dom'; |
| 3 | +import svg from '@lib/util/svg'; |
| 4 | +import icon from '@lib/icon'; |
| 5 | +import { EventEmitter } from './event/event'; |
| 6 | +import { removeIconFromIconPack, saveIconToIconPack } from '@app/util'; |
| 7 | +import { getAllIconPacks, getIconsFromIconPack } from '@app/icon-pack-manager'; |
2 | 8 |
|
3 | 9 | export { AllIconsLoadedEvent } from '@lib/event/events'; |
4 | 10 |
|
5 | 11 | export default interface IconizeAPI { |
| 12 | + getEventEmitter(): EventEmitter; |
| 13 | + getIconByName: typeof icon.getIconByName; |
| 14 | + /** |
| 15 | + * Sets an icon or emoji for an HTMLElement based on the specified icon name and color. |
| 16 | + * The function manipulates the specified node inline. |
| 17 | + * @param iconName Name of the icon or emoji to add. |
| 18 | + * @param node HTMLElement to which the icon or emoji will be added. |
| 19 | + * @param color Optional color of the icon to add. |
| 20 | + */ |
| 21 | + setIconForNode(iconName: string, node: HTMLElement, color?: string): void; |
| 22 | + doesElementHasIconNode: typeof dom.doesElementHasIconNode; |
| 23 | + getIconFromElement: typeof dom.getIconFromElement; |
| 24 | + removeIconInNode: typeof dom.removeIconInNode; |
| 25 | + removeIconInPath: typeof dom.removeIconInPath; |
| 26 | + /** |
| 27 | + * Will add the icon to the icon pack and then extract the icon to the icon pack. |
| 28 | + * @param iconNameWithPrefix String that will be used to add the icon to the icon pack. |
| 29 | + */ |
| 30 | + saveIconToIconPack(iconNameWithPrefix: string): void; |
| 31 | + /** |
| 32 | + * Will remove the icon from the icon pack by removing the icon file from the icon pack directory. |
| 33 | + * @param iconNameWithPrefix String that will be used to remove the icon from the icon pack. |
| 34 | + */ |
| 35 | + removeIconFromIconPack(iconNameWithPrefix: string): void; |
| 36 | + getAllIconPacks: typeof getAllIconPacks; |
| 37 | + getIconsFromIconPack: typeof getIconsFromIconPack; |
| 38 | + util: { |
| 39 | + dom: typeof dom; |
| 40 | + svg: typeof svg; |
| 41 | + }; |
6 | 42 | version: { |
7 | 43 | current: string; |
8 | 44 | }; |
9 | 45 | } |
10 | 46 |
|
11 | 47 | export function getApi(plugin: IconizePlugin): IconizeAPI { |
12 | 48 | return { |
| 49 | + getEventEmitter: () => plugin.getEventEmitter(), |
| 50 | + getIconByName: (iconNameWithPrefix: string) => |
| 51 | + icon.getIconByName(iconNameWithPrefix), |
| 52 | + setIconForNode: (iconName: string, node: HTMLElement, color?: string) => |
| 53 | + dom.setIconForNode(plugin, iconName, node, color), |
| 54 | + saveIconToIconPack: (iconNameWithPrefix) => |
| 55 | + saveIconToIconPack(plugin, iconNameWithPrefix), |
| 56 | + removeIconFromIconPack: (iconNameWithPrefix) => |
| 57 | + removeIconFromIconPack(plugin, iconNameWithPrefix), |
| 58 | + getIconsFromIconPack: getIconsFromIconPack, |
| 59 | + getAllIconPacks: getAllIconPacks, |
| 60 | + doesElementHasIconNode: dom.doesElementHasIconNode, |
| 61 | + getIconFromElement: dom.getIconFromElement, |
| 62 | + removeIconInNode: dom.removeIconInNode, |
| 63 | + removeIconInPath: dom.removeIconInPath, |
| 64 | + util: { |
| 65 | + dom, |
| 66 | + svg, |
| 67 | + }, |
13 | 68 | version: { |
14 | 69 | get current() { |
15 | 70 | return plugin.manifest.version; |
|
0 commit comments