Skip to content

Commit

Permalink
🚧 biome: plugin and reveal
Browse files Browse the repository at this point in the history
  • Loading branch information
ebullient committed Dec 20, 2024
1 parent 71f1cb7 commit 80d3564
Show file tree
Hide file tree
Showing 8 changed files with 234 additions and 234 deletions.
2 changes: 1 addition & 1 deletion src/plugin/reveal.js-elapsed-time-bar/LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
SOFTWARE.
10 changes: 3 additions & 7 deletions src/plugin/reveal.js-elapsed-time-bar/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Keeping to time in presentations!

[Check out the live demo](https://tkrkt.github.com/reveal.js-elapsed-time-bar/)

## Installation
## Installation

Copy the folder ``plugin/elapsed-time-bar`` into plugin folder of your reveal.js project.

Expand All @@ -28,7 +28,6 @@ Reveal.initialize({
});
```


## Configurations

```js
Expand All @@ -49,7 +48,6 @@ Reveal.initialize({
});
```


## API

You can use APIs from global ``ElapsedTimeBar`` object.
Expand All @@ -63,7 +61,6 @@ You can use APIs from global ``ElapsedTimeBar`` object.
|pause()|pause timer|
|resume()|resume timer|


## Keyboard binding example

```js
Expand All @@ -83,7 +80,6 @@ Reveal.initialize({
});
```

## License

# License

MIT
MIT
43 changes: 24 additions & 19 deletions src/plugin/reveal.js-elapsed-time-bar/elapsed-time-bar.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,19 @@

window.ElapsedTimeBar = window.ElapsedTimeBar || {
id: 'ElapsedTimeBar',
start: function(allottedTime, elapsedTime) {
start: (allottedTime, elapsedTime) => {
ElapsedTimeBar.start(allottedTime, elapsedTime);
},
reset: function() {
reset: () => {
ElapsedTimeBar.reset();
},
pause: function() {
pause: () => {
ElapsedTimeBar.pause();
},
resume: function() {
resume: () => {
ElapsedTimeBar.resume();
}
};
if (Reveal.isReady()) {
ElapsedTimeBar.handleReady();
} else {
Reveal.addEventListener('ready', () => ElapsedTimeBar.handleReady());
}

const ElapsedTimeBar = {
id: 'ElapsedTimeBar',
Expand Down Expand Up @@ -56,13 +51,15 @@ const ElapsedTimeBar = {
let barHeight;
const pageProgressContainer = document.querySelector('.progress');
if (config.progressBarHeight) {
barHeight = parseInt(config.progressBarHeight, 10) + 'px';
barHeight = `${Number.parseInt(config.progressBarHeight, 10)}px`;

// override height of page-progress container
pageProgressContainer && (pageProgressContainer.style.height = barHeight);
if (pageProgressContainer) {
pageProgressContainer.style.height = barHeight;
}
} else if (config.progress && pageProgressContainer) {
// get height from page-progress container
barHeight = pageProgressContainer.getBoundingClientRect().height + 'px';
barHeight = `${pageProgressContainer.getBoundingClientRect().height}px`;
} else {
// default
barHeight = '3px';
Expand All @@ -71,25 +68,27 @@ const ElapsedTimeBar = {
// create container of time-progress
const timeProgressContainer = document.createElement('div');
timeProgressContainer.classList.add('progress');
Object.entries({
for (const [k, v] of Object.entries({
display: 'block',
position: 'fixed',
bottom: config.progress ? barHeight : 0,
width: '100%',
height: barHeight
}).forEach(([k, v]) => {
})) {
timeProgressContainer.style[k] = v;
});
}

document.querySelector('.reveal').appendChild(timeProgressContainer);

// create content of time-progress
this.timeProgressBar = document.createElement('div');
Object.entries({
for (const [k, v] of Object.entries({
height: '100%',
willChange: 'width'
}).forEach(([k, v]) => {
})) {
this.timeProgressBar.style[k] = v;
});
}

timeProgressContainer.appendChild(this.timeProgressBar);

// start timer
Expand All @@ -107,7 +106,7 @@ const ElapsedTimeBar = {
this.timeProgressBar.style.width = '100%';
this.isFinished = true;
} else {
this.timeProgressBar.style.width = elapsedTime / this.allottedTime * 100 + '%';
this.timeProgressBar.style.width = `${elapsedTime / this.allottedTime * 100}%`;
requestAnimationFrame(this.loop.bind(this));
}
},
Expand Down Expand Up @@ -160,3 +159,9 @@ const ElapsedTimeBar = {
this.loop();
}
};

if (Reveal.isReady()) {
ElapsedTimeBar.handleReady();
} else {
Reveal.addEventListener('ready', () => ElapsedTimeBar.handleReady());
}
2 changes: 1 addition & 1 deletion src/reveal/markdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ export const md = (() => {
// Hack required since https://github.com/hakimel/reveal.js/commit/d780352b7f78e16635ce9fabf2dbb53639610f18
// eslint-disable-next-line no-undef
global.Reveal = {
registerPlugin: () => {}
registerPlugin: () => { }
};
// eslint-disable-next-line no-undef
return require('reveal.js/plugin/markdown/markdown')();
Expand Down
44 changes: 22 additions & 22 deletions src/reveal/revealExporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import {
writeFile,
existsSync,
outputFileSync,
} from 'fs-extra';
import path from 'path';
import { ObsidianUtils } from '../obsidian/obsidianUtils';
import { Platform } from 'obsidian';
} from "fs-extra";
import path from "node:path";
import type { ObsidianUtils } from "../obsidian/obsidianUtils";
import { Platform } from "obsidian";

export class RevealExporter {
private pluginDirectory: string;
Expand All @@ -22,42 +22,42 @@ export class RevealExporter {

public async export(filePath: string, html: string, imgList: string[]) {
const ext = path.extname(filePath);
const folderName = path.basename(filePath).replaceAll(ext, '');
const folderName = path.basename(filePath).replaceAll(ext, "");
const folderDir = path.join(this.exportDirectory, folderName);
const sourceDir = path.dirname(filePath);
const vaultDir = this.vaultDirectory.replace(/\/$/, '');
const vaultDir = this.vaultDirectory.replace(/\/$/, "");

console.debug('export', sourceDir, vaultDir, folderDir);
console.debug("export", sourceDir, vaultDir, folderDir);

await emptyDir(folderDir);
await writeFile(path.join(folderDir, 'index.html'), html);
await writeFile(path.join(folderDir, "index.html"), html);

// TODO: let's track what css, scripts, and plugins are actually used
// rather than copying everything.
await copy(
path.join(this.pluginDirectory, 'css'),
path.join(folderDir, 'css'),
path.join(this.pluginDirectory, "css"),
path.join(folderDir, "css"),
);
await copy(
path.join(this.pluginDirectory, 'dist'),
path.join(folderDir, 'dist'),
path.join(this.pluginDirectory, "dist"),
path.join(folderDir, "dist"),
);
await copy(
path.join(this.pluginDirectory, 'plugin'),
path.join(folderDir, 'plugin'),
path.join(this.pluginDirectory, "plugin"),
path.join(folderDir, "plugin"),
);

for (const img of imgList) {
console.log('export', img);
if (img.startsWith('http')) {
console.log("export", img);
if (img.startsWith("http")) {
continue;
}
if (img.startsWith('/local-file-url')) {
if (img.startsWith("/local-file-url")) {
const urlpath = img.replace(
'/local-file-url',
"/local-file-url",
Platform.resourcePathPrefix,
);
const result = await fetch(urlpath).catch(error => {
const result = await fetch(urlpath).catch((error) => {
return new Response(null, {
status: 404,
statusText: error.messge,
Expand All @@ -73,7 +73,7 @@ export class RevealExporter {
);
} else {
console.info(
'open a bug to handle this kind of response. Include this message',
"open a bug to handle this kind of response. Include this message",
result,
);
}
Expand All @@ -89,10 +89,10 @@ export class RevealExporter {
imgPath = relative;
}
}
console.debug('img', img, imgPath, sourceDir != vaultDir);
console.debug("img", img, imgPath, sourceDir !== vaultDir);
await copy(imgPath, path.join(folderDir, img));
}

window.open('file://' + folderDir);
window.open(`file://${folderDir}`);
}
}
Loading

0 comments on commit 80d3564

Please sign in to comment.