Some foundation for preload options

Switching computers
This commit is contained in:
GnoxNahte 2024-08-25 21:13:21 +08:00
parent 04a21a21b3
commit e0cae5611b
4 changed files with 48 additions and 0 deletions

View file

@ -82,6 +82,7 @@ A brief overview with some steps on how the plugin works. *Not required to use t
- [ ] Google Maps
- [ ] Google Calendar
- [ ] Other websites. [Iframely](https://iframely.com/domains) has a list of websites that can be embedded.
- [ ] Add preview websites when hovering a link and holding `Ctrl` for websites that aren't embedded using the syntax.
- [ ] Add tests
- [ ] Updated README.md
- [ ] Improve readability. Open to suggestions, especially if something isn't clear.

22
SettingsExplanation.md Normal file
View file

@ -0,0 +1,22 @@
# Settings
This is an explanation of all the settings that the plugin has.
## General
### Preview Embed
Opens this for you to test your embeds
![Preview embed](/readme-assets/settings/Preview-Settings.png)
### Dark Mode
Sets dark mode for supported websites:
- Reddit
- Twitter/X
## Show thumbnail
### Thumbnail supported websites list
- YouTube
- CodePen
- TikTok
##

Binary file not shown.

After

Width:  |  Height:  |  Size: 182 KiB

View file

@ -14,6 +14,13 @@ export enum GoogleDocsViewOptions {
EditDefault,
}
export enum PreloadOptions {
None,
Placeholder,
Placeholder_ClickToLoad,
Thumbnail,
Thumbnail_ClickToLoad,
}
// export type SupportedWebsites = "CodePen" | "Google Docs" | "Imgur" | "Reddit" | "SoundCloud" | "Spotify" | "Steam" | "TikTok" | "Twitter/X" | "YouTube";
@ -26,6 +33,7 @@ export type SupportedWebsitesMap = {
export interface PluginSettings {
// General
darkMode: boolean;
preloadOption: PreloadOptions;
enabledWebsites: SupportedWebsitesMap;
@ -152,6 +160,23 @@ export class AutoEmbedSettingTab extends PluginSettingTab {
await this.plugin.saveSettings();
})
);
const preloadOptions = EnumToRecord(PreloadOptions);
Object.entries(preloadOptions).forEach(([key, value]) => {
preloadOptions[key] = value.replace("_", " + ");
});
new Setting(containerEl)
.setName("Preload options")
.setDesc("Choose how the embed behaves before loading")
.addDropdown(dropdown => dropdown
.addOptions(preloadOptions)
.setValue(PreloadOptions[settings.preloadOption])
.onChange(async (value) => {
settings.preloadOption = PreloadOptions[value as keyof typeof PreloadOptions];
await this.plugin.saveSettings();
})
)
new Setting(containerEl)
.setName("Supported website")