Skip to content

Commit

Permalink
simplify source tree; remove reveal content
Browse files Browse the repository at this point in the history
  • Loading branch information
ebullient committed Mar 10, 2024
1 parent 715a795 commit 840df5a
Show file tree
Hide file tree
Showing 49 changed files with 688 additions and 1,320 deletions.
507 changes: 507 additions & 0 deletions .gitignore

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions docs/extend-syntax/inlineStyling.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,6 @@ it is possible to add further css files beside theme and highlight theme to slid
css: [css/layout.css,css/customFonts.css]
---
```

These files will be found relative to either the configured custom Theme Directory or
the Advanced Slides plugin folder.
3 changes: 2 additions & 1 deletion docs/themes/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ Open the settings for Advanced Slides Plugin, and choose a folder to use as your

**Example:**

If you create a directory in your vault called `assets/themes`, and create a CSS file called **my-theme.css** in that directory:
If you create a directory in your vault called `assets/themes`, and create a
CSS file called **my-theme.css** in that directory:

1. Open settings for Advanced Slides Plugin, and choose `assets/themes` as the "Theme Directory"
2. You should be able to select `my-theme.css` as the default theme in slide settings (suggester)
Expand Down
15 changes: 10 additions & 5 deletions esbuild.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ const dir = process.env.OUTDIR ? process.env.OUTDIR : "./build";

const map = {
'src/main.ts': 'main',
'src/scss/layout/main.scss': 'css/layout',
'src/scss/layout/advanced-slides.scss': 'css/advanced-slides',
};

const themeDir = 'src/scss/theme/source/';
const themeDir = 'src/scss/theme/';
const files = readdirSync(themeDir);
files.forEach(function (file) {
if (file.endsWith('.scss')) {
Expand Down Expand Up @@ -83,7 +83,12 @@ const parameters = {
treeShaking: true,
outdir: dir,
plugins: [
sassPlugin({ filter: /.(s[ac]ss|css)$/ }),
sassPlugin({
filter: /.(s[ac]ss|css)$/,
loadPaths: [
'node_modules/reveal.js/css',
],
}),
copy({
assets: {
from: ['manifest.json'],
Expand Down Expand Up @@ -155,7 +160,7 @@ const parameters = {
}),
copy({
assets: {
from: ['node_modules/chart.js/dist/*'],
from: ['node_modules/chart.js/dist/chart.min.js'],
to: ['./plugin/chart/'],
}
}),
Expand All @@ -174,7 +179,7 @@ const parameters = {
}),
copy({
assets: {
from: ['node_modules/reveal.js-elapsed-time-bar/plugin/elapsed-time-bar/*'],
from: ['node_modules/reveal-elapsed-time-bar/src/elapsed-time-bar.js'],
to: ['./plugin/elapsed-time-bar/'],
}
}),
Expand Down
2 changes: 1 addition & 1 deletion src/@types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ export interface AdvancedSlidesSettings {
showGrid: boolean;
autoComplete: string;
paneMode: PaneType;
motm: string;
themeDirectory: string;
center: boolean;
}

export type Options = {
Expand Down
63 changes: 40 additions & 23 deletions src/advancedSlides-Plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,8 @@ export class AdvancedSlidesPlugin extends Plugin {
);

try {
this.revealServer = new RevealServer(
this.obsidianUtils,
this.settings.port,
);
this.configureServer();

this.registerView(
REVEAL_PREVIEW_VIEW,
leaf =>
Expand Down Expand Up @@ -122,16 +120,7 @@ export class AdvancedSlidesPlugin extends Plugin {
}
this.registerEditorSuggest(this.autoCompleteSuggester);

if (this.settings.autoStart) {
await this.revealServer.start();
}

const instance = this.getViewInstance();
if (instance) {
if (instance.url == 'about:blank') {
await this.showView();
}
}
await this.initServer();
};

getViewInstance(): RevealPreviewView {
Expand Down Expand Up @@ -198,6 +187,35 @@ export class AdvancedSlidesPlugin extends Plugin {
await this.openUrl(url);
}

configureServer = () => {
this.revealServer = new RevealServer(
this.obsidianUtils,
this.settings.port,
);
};

initServer = async () => {
if (this.settings.autoStart) {
await this.revealServer.start();
}

const instance = this.getViewInstance();
if (instance) {
if (instance.url == 'about:blank') {
await this.showView();
}
}
};

stopServer = async () => {
await this.revealServer.stop();

const instance = this.getViewInstance();
if (instance) {
await instance.onClose();
}
};

private async openUrl(url: URL) {
const instance = this.getViewInstance();
instance.setUrl(url.toString());
Expand All @@ -216,12 +234,11 @@ export class AdvancedSlidesPlugin extends Plugin {

async onunload() {
console.debug('unloading Advanced Slides');
await this.revealServer.stop();
const instance = this.getViewInstance();
if (instance) {
this.app.workspace.detachLeavesOfType(REVEAL_PREVIEW_VIEW);
await instance.onClose();
}
await this.stopServer();

this.app.workspace
.getLeavesOfType(REVEAL_PREVIEW_VIEW)
.forEach(leaf => leaf.detach());
}

async loadSettings() {
Expand All @@ -235,9 +252,9 @@ export class AdvancedSlidesPlugin extends Plugin {
async saveSettings() {
await this.saveData(this.settings);
console.debug('Advanced Slides: settings saved');
await this.onunload();
await this.onload();
await this.layoutReady();
await this.stopServer();
this.configureServer();
await this.initServer();
}

async update(newSettings: AdvancedSlidesSettings) {
Expand Down
Loading

0 comments on commit 840df5a

Please sign in to comment.