1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-27 10:32:58 +02:00

Desktop: Multi-profiles: Share custom CSS between profiles

This commit is contained in:
Laurent Cozic 2022-04-16 13:51:17 +01:00
parent a111531810
commit 0cdef66816
2 changed files with 15 additions and 16 deletions

View File

@ -354,8 +354,7 @@ class Application extends BaseApplication {
}
// Loads app-wide styles. (Markdown preview-specific styles loaded in app.js)
const filename = Setting.custom_css_files.JOPLIN_APP;
await injectCustomStyles('appStyles', `${dir}/${filename}`);
await injectCustomStyles('appStyles', Setting.customCssFilePath(Setting.customCssFilenames.JOPLIN_APP));
AlarmService.setDriver(new AlarmServiceDriverNode({ appName: packageInfo.build.appId }));
AlarmService.setLogger(reg.logger());
@ -433,7 +432,7 @@ class Application extends BaseApplication {
});
// Loads custom Markdown preview styles
const cssString = await loadCustomCss(`${Setting.value('profileDir')}/userstyle.css`);
const cssString = await loadCustomCss(Setting.customCssFilePath(Setting.customCssFilenames.RENDERED_MARKDOWN));
this.store().dispatch({
type: 'CUSTOM_CSS_APPEND',
css: cssString,

View File

@ -243,7 +243,7 @@ class Setting extends BaseModel {
public static SYNC_UPGRADE_STATE_SHOULD_DO = 1; // Should be upgraded, but waiting for user to confirm
public static SYNC_UPGRADE_STATE_MUST_DO = 2; // Must be upgraded - on next restart, the upgrade will start
public static custom_css_files = {
public static customCssFilenames = {
JOPLIN_APP: 'userchrome.css',
RENDERED_MARKDOWN: 'userstyle.css',
};
@ -1187,12 +1187,10 @@ class Setting extends BaseModel {
'style.customCss.renderedMarkdown': {
value: null,
onClick: () => {
const dir = Setting.value('profileDir');
const filename = Setting.custom_css_files.RENDERED_MARKDOWN;
const filepath = `${dir}/${filename}`;
const defaultContents = '/* For styling the rendered Markdown */';
shim.openOrCreateFile(filepath, defaultContents);
shim.openOrCreateFile(
this.customCssFilePath(Setting.customCssFilenames.RENDERED_MARKDOWN),
'/* For styling the rendered Markdown */'
);
},
type: SettingItemType.Button,
public: true,
@ -1206,12 +1204,10 @@ class Setting extends BaseModel {
'style.customCss.joplinApp': {
value: null,
onClick: () => {
const dir = Setting.value('profileDir');
const filename = Setting.custom_css_files.JOPLIN_APP;
const filepath = `${dir}/${filename}`;
const defaultContents = `/* For styling the entire Joplin app (except the rendered Markdown, which is defined in \`${Setting.custom_css_files.RENDERED_MARKDOWN}\`) */`;
shim.openOrCreateFile(filepath, defaultContents);
shim.openOrCreateFile(
this.customCssFilePath(Setting.customCssFilenames.JOPLIN_APP),
`/* For styling the entire Joplin app (except the rendered Markdown, which is defined in \`${Setting.customCssFilenames.RENDERED_MARKDOWN}\`) */`
);
},
type: SettingItemType.Button,
public: true,
@ -1527,6 +1523,10 @@ class Setting extends BaseModel {
}
}
public static customCssFilePath(filename: string): string {
return `${this.value('rootProfileDir')}/${filename}`;
}
public static skipDefaultMigrations() {
logger.info('Skipping all default migrations...');