Skip to content

Commit

Permalink
♻️ AdvancedSlidesSettings -> SlidesExtendedSettings
Browse files Browse the repository at this point in the history
  • Loading branch information
ebullient committed May 5, 2024
1 parent 07f08e0 commit a00b6ad
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/@types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ interface QueryString {
embed: boolean;
export: boolean;
}
export interface AdvancedSlidesSettings {
export interface SlidesExtendedSettings {
port: string;
autoReload: boolean;
autoStart: boolean;
Expand Down
6 changes: 3 additions & 3 deletions src/advancedSlides-Plugin.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { addIcon, Plugin, TAbstractFile } from 'obsidian';
import { AdvancedSlidesSettings } from './@types';
import { SlidesExtendedSettings } from './@types';
import { RevealServer } from './reveal/revealServer';
import { ObsidianUtils } from './obsidian/obsidianUtils';
import { AutoCompleteSuggest } from './obsidian/suggesters/AutoCompleteSuggester';
Expand All @@ -18,7 +18,7 @@ import { EmbeddedSlideProcessor } from './obsidian/embeddedSlideProcessor';
import { AdvancedSlidesDistribution } from './advancedSlides-Distribution';

export class AdvancedSlidesPlugin extends Plugin {
settings: AdvancedSlidesSettings;
settings: SlidesExtendedSettings;
obsidianUtils: ObsidianUtils;

private revealServer: RevealServer;
Expand Down Expand Up @@ -273,7 +273,7 @@ export class AdvancedSlidesPlugin extends Plugin {
}
}

async update(newSettings: AdvancedSlidesSettings) {
async update(newSettings: SlidesExtendedSettings) {
this.settings = newSettings;
await this.saveSettings();
}
Expand Down
4 changes: 2 additions & 2 deletions src/advancedSlides-SettingTab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ import {
getThemeFiles,
} from './obsidian/suggesters/ThemeSuggester';
import { AdvancedSlidesPlugin } from './advancedSlides-Plugin';
import { AdvancedSlidesSettings } from './@types';
import { SlidesExtendedSettings } from './@types';

/** This is because TypeScript's filters are dumb. */
function isFolder(file: TAbstractFile): file is TFolder {
return file instanceof TFolder;
}
export class AdvancedSlidesSettingTab extends PluginSettingTab {
plugin: AdvancedSlidesPlugin;
newSettings: AdvancedSlidesSettings;
newSettings: SlidesExtendedSettings;

constructor(app: App, plugin: AdvancedSlidesPlugin) {
super(app, plugin);
Expand Down
4 changes: 2 additions & 2 deletions src/advancedSlides-constants.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { AdvancedSlidesSettings, ImageCollector, Options } from './@types';
import { SlidesExtendedSettings, ImageCollector, Options } from './@types';

export const ICON_DATA =
'<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100"><path fill="currentColor" stroke="currentColor" d="M100 74.242V1.516H0v72.726h45.453v15.153H31.816v9.09h36.368v-9.09H54.547V74.242Zm-90.91-9.09V10.605h81.82v54.547Zm0 0"/><path fill="currentColor" stroke="currentColor" d="M54.547 19.695h9.09V56.06h-9.09ZM72.727 25.758h9.09v30.305h-9.09ZM36.363 31.816h9.09V56.06h-9.09ZM18.184 22.727h9.09v33.335h-9.09Zm0 0"/></svg>';

export const REFRESH_ICON =
'<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100"><path fill="currentColor" stroke="currentColor" d="M70.691 87.988a38.342 38.342 0 0 1-3.414 1.125 1.885 1.885 0 1 0 1.012 3.633 41.67 41.67 0 0 0 3.75-1.234 1.886 1.886 0 1 0-1.348-3.524ZM80.14 82.82a41.04 41.04 0 0 1-2.984 2.008c-.89.54-1.176 1.7-.633 2.59a1.88 1.88 0 0 0 2.59.633 43.628 43.628 0 0 0 3.278-2.203 1.891 1.891 0 0 0 .39-2.637 1.884 1.884 0 0 0-2.64-.39ZM60.2 90.402c-1.184.11-2.395.164-3.595.164a1.883 1.883 0 0 0-1.886 1.887c0 1.043.84 1.887 1.886 1.887 1.313 0 2.637-.059 3.934-.176a1.89 1.89 0 0 0 1.711-2.05c-.094-1.04-1.027-1.821-2.05-1.712ZM95.73 64.96a1.884 1.884 0 0 0-2.46 1.032 38.605 38.605 0 0 1-1.52 3.262 1.893 1.893 0 0 0 .8 2.547c.278.144.579.21.872.21.68 0 1.34-.366 1.676-1.011a43.077 43.077 0 0 0 1.664-3.574 1.892 1.892 0 0 0-1.032-2.465ZM98.055 53.91c-1.016-.133-1.973.621-2.094 1.653a39.641 39.641 0 0 1-.578 3.554 1.886 1.886 0 1 0 3.691.774c.27-1.278.48-2.582.637-3.891a1.887 1.887 0 0 0-1.656-2.09ZM87.86 75.3a41.33 41.33 0 0 1-2.344 2.735 1.889 1.889 0 0 0 2.754 2.582 40.924 40.924 0 0 0 2.562-2.996 1.88 1.88 0 0 0-.328-2.644 1.88 1.88 0 0 0-2.645.324ZM98.113 50.945a1.886 1.886 0 0 0 1.887-1.89C100 25.125 80.535 5.66 56.605 5.66c-22.468 0-40.996 17.16-43.18 39.059L3.224 34.516a1.884 1.884 0 0 0-2.668 0 1.884 1.884 0 0 0 0 2.668L13.758 50.39c.176.172.383.312.617.406a1.836 1.836 0 0 0 1.441 0c.23-.094.442-.234.614-.406l13.207-13.207a1.884 1.884 0 0 0 0-2.668 1.884 1.884 0 0 0-2.668 0l-9.653 9.652c2.418-19.547 19.098-34.734 39.29-34.734 21.843 0 39.62 17.777 39.62 39.62 0 1.048.844 1.891 1.887 1.891Zm0 0"/></svg>';

export const DEFAULT_SETTINGS: AdvancedSlidesSettings = {
export const DEFAULT_SETTINGS: SlidesExtendedSettings = {
port: '3000',
autoReload: true,
autoStart: true,
Expand Down
11 changes: 7 additions & 4 deletions src/obsidian/obsidianUtils.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { readFileSync } from 'fs-extra';
import { App, FileSystemAdapter, resolveSubpath, TFile } from 'obsidian';
import path from 'path';
import { AdvancedSlidesSettings, ImageCollector } from '../@types';
import {
SlidesExtendedSettings as SlidesExtendedSettings,
ImageCollector,
} from '../@types';
import { DISABLED_IMAGE_COLLECTOR } from '../advancedSlides-constants';
import { MarkdownProcessor } from './markdownProcessor';

Expand All @@ -17,7 +20,7 @@ function setImageCollector(newInstance: ImageCollector) {
export class ObsidianUtils implements ImageCollector {
private app: App;
private fileSystem: FileSystemAdapter;
private settings: AdvancedSlidesSettings;
private settings: SlidesExtendedSettings;
private readonly processor: MarkdownProcessor;
private readonly vaultDir;
private readonly pluginDir;
Expand All @@ -32,7 +35,7 @@ export class ObsidianUtils implements ImageCollector {

private yamlRegex = /^---.*?---\n(.*?)($|---)/s;

constructor(app: App, settings: AdvancedSlidesSettings) {
constructor(app: App, settings: SlidesExtendedSettings) {
this.app = app;
if (!(this.app.vault.adapter instanceof FileSystemAdapter)) {
throw new Error('Slides Extended is only supported on the desktop');
Expand Down Expand Up @@ -112,7 +115,7 @@ export class ObsidianUtils implements ImageCollector {
return this.highlightSearchPath;
}

getSettings(): AdvancedSlidesSettings {
getSettings(): SlidesExtendedSettings {
return this.settings;
}

Expand Down
4 changes: 2 additions & 2 deletions src/reveal/revealPreviewView.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ItemView, MarkdownView, Menu, WorkspaceLeaf } from 'obsidian';
import { YamlParser } from '../yaml/yamlParser';
import { AdvancedSlidesSettings, Options } from '../@types';
import { SlidesExtendedSettings, Options } from '../@types';

export const REVEAL_PREVIEW_VIEW = 'reveal-preview-view';

Expand All @@ -15,7 +15,7 @@ export class RevealPreviewView extends ItemView {
constructor(
leaf: WorkspaceLeaf,
home: URL,
settings: AdvancedSlidesSettings,
settings: SlidesExtendedSettings,
onCloseListener: () => void,
) {
super(leaf);
Expand Down
6 changes: 3 additions & 3 deletions src/yaml/yamlParser.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { loadFront } from 'yaml-front-matter';

import { isEmpty, isNil, omit, omitBy, pick } from '../util';
import { AdvancedSlidesSettings, Options } from '../@types';
import { SlidesExtendedSettings, Options } from '../@types';
import { DEFAULTS } from '../advancedSlides-constants';

export class YamlParser {
private settings: AdvancedSlidesSettings;
private settings: SlidesExtendedSettings;

constructor(settings: AdvancedSlidesSettings) {
constructor(settings: SlidesExtendedSettings) {
this.settings = settings;
}

Expand Down

0 comments on commit a00b6ad

Please sign in to comment.