mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-30 10:36:35 +02:00
Desktop: Multi-profiles: Share custom CSS between profiles
This commit is contained in:
parent
a111531810
commit
0cdef66816
@ -354,8 +354,7 @@ class Application extends BaseApplication {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Loads app-wide styles. (Markdown preview-specific styles loaded in app.js)
|
// Loads app-wide styles. (Markdown preview-specific styles loaded in app.js)
|
||||||
const filename = Setting.custom_css_files.JOPLIN_APP;
|
await injectCustomStyles('appStyles', Setting.customCssFilePath(Setting.customCssFilenames.JOPLIN_APP));
|
||||||
await injectCustomStyles('appStyles', `${dir}/${filename}`);
|
|
||||||
|
|
||||||
AlarmService.setDriver(new AlarmServiceDriverNode({ appName: packageInfo.build.appId }));
|
AlarmService.setDriver(new AlarmServiceDriverNode({ appName: packageInfo.build.appId }));
|
||||||
AlarmService.setLogger(reg.logger());
|
AlarmService.setLogger(reg.logger());
|
||||||
@ -433,7 +432,7 @@ class Application extends BaseApplication {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Loads custom Markdown preview styles
|
// 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({
|
this.store().dispatch({
|
||||||
type: 'CUSTOM_CSS_APPEND',
|
type: 'CUSTOM_CSS_APPEND',
|
||||||
css: cssString,
|
css: cssString,
|
||||||
|
@ -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_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 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',
|
JOPLIN_APP: 'userchrome.css',
|
||||||
RENDERED_MARKDOWN: 'userstyle.css',
|
RENDERED_MARKDOWN: 'userstyle.css',
|
||||||
};
|
};
|
||||||
@ -1187,12 +1187,10 @@ class Setting extends BaseModel {
|
|||||||
'style.customCss.renderedMarkdown': {
|
'style.customCss.renderedMarkdown': {
|
||||||
value: null,
|
value: null,
|
||||||
onClick: () => {
|
onClick: () => {
|
||||||
const dir = Setting.value('profileDir');
|
shim.openOrCreateFile(
|
||||||
const filename = Setting.custom_css_files.RENDERED_MARKDOWN;
|
this.customCssFilePath(Setting.customCssFilenames.RENDERED_MARKDOWN),
|
||||||
const filepath = `${dir}/${filename}`;
|
'/* For styling the rendered Markdown */'
|
||||||
const defaultContents = '/* For styling the rendered Markdown */';
|
);
|
||||||
|
|
||||||
shim.openOrCreateFile(filepath, defaultContents);
|
|
||||||
},
|
},
|
||||||
type: SettingItemType.Button,
|
type: SettingItemType.Button,
|
||||||
public: true,
|
public: true,
|
||||||
@ -1206,12 +1204,10 @@ class Setting extends BaseModel {
|
|||||||
'style.customCss.joplinApp': {
|
'style.customCss.joplinApp': {
|
||||||
value: null,
|
value: null,
|
||||||
onClick: () => {
|
onClick: () => {
|
||||||
const dir = Setting.value('profileDir');
|
shim.openOrCreateFile(
|
||||||
const filename = Setting.custom_css_files.JOPLIN_APP;
|
this.customCssFilePath(Setting.customCssFilenames.JOPLIN_APP),
|
||||||
const filepath = `${dir}/${filename}`;
|
`/* For styling the entire Joplin app (except the rendered Markdown, which is defined in \`${Setting.customCssFilenames.RENDERED_MARKDOWN}\`) */`
|
||||||
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);
|
|
||||||
},
|
},
|
||||||
type: SettingItemType.Button,
|
type: SettingItemType.Button,
|
||||||
public: true,
|
public: true,
|
||||||
@ -1527,6 +1523,10 @@ class Setting extends BaseModel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static customCssFilePath(filename: string): string {
|
||||||
|
return `${this.value('rootProfileDir')}/${filename}`;
|
||||||
|
}
|
||||||
|
|
||||||
public static skipDefaultMigrations() {
|
public static skipDefaultMigrations() {
|
||||||
logger.info('Skipping all default migrations...');
|
logger.info('Skipping all default migrations...');
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user