2023-06-30 10:55:56 +02:00
|
|
|
/* eslint-disable multiline-comment-style */
|
|
|
|
|
2024-03-09 13:03:57 +02:00
|
|
|
import shim from '../../../shim';
|
2021-07-23 12:05:21 +02:00
|
|
|
import Plugin from '../Plugin';
|
|
|
|
|
|
|
|
export default class JoplinWindow {
|
|
|
|
|
2024-04-05 13:16:49 +02:00
|
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Old code before rule was applied
|
2021-07-23 12:05:21 +02:00
|
|
|
private store_: any;
|
|
|
|
|
2024-04-05 13:16:49 +02:00
|
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Old code before rule was applied
|
2024-11-08 17:32:05 +02:00
|
|
|
public constructor(_plugin: Plugin, store: any) {
|
2021-07-23 12:05:21 +02:00
|
|
|
this.store_ = store;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Loads a chrome CSS file. It will apply to the window UI elements, except
|
|
|
|
* for the note viewer. It is the same as the "Custom stylesheet for
|
|
|
|
* Joplin-wide app styles" setting. See the [Load CSS Demo](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/load_css)
|
|
|
|
* for an example.
|
2024-03-26 13:36:15 +02:00
|
|
|
*
|
|
|
|
* <span class="platform-desktop">desktop</span>
|
2021-07-23 12:05:21 +02:00
|
|
|
*/
|
|
|
|
public async loadChromeCssFile(filePath: string) {
|
2024-11-08 17:32:05 +02:00
|
|
|
this.store_.dispatch({
|
|
|
|
type: 'CUSTOM_CHROME_CSS_ADD',
|
|
|
|
filePath,
|
|
|
|
});
|
2021-07-23 12:05:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Loads a note CSS file. It will apply to the note viewer, as well as any
|
|
|
|
* exported or printed note. It is the same as the "Custom stylesheet for
|
|
|
|
* rendered Markdown" setting. See the [Load CSS Demo](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/load_css)
|
|
|
|
* for an example.
|
2024-03-26 13:36:15 +02:00
|
|
|
*
|
|
|
|
* <span class="platform-desktop">desktop</span>
|
2021-07-23 12:05:21 +02:00
|
|
|
*/
|
|
|
|
public async loadNoteCssFile(filePath: string) {
|
2024-03-09 13:03:57 +02:00
|
|
|
const cssString = await shim.fsDriver().readFile(filePath, 'utf8');
|
2021-07-23 12:05:21 +02:00
|
|
|
|
|
|
|
this.store_.dispatch({
|
2024-11-08 17:32:05 +02:00
|
|
|
type: 'CUSTOM_VIEWER_CSS_APPEND',
|
2021-07-23 12:05:21 +02:00
|
|
|
css: cssString,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|