1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-01-11 18:24:43 +02:00
This commit is contained in:
Laurent Cozic 2023-05-08 14:59:27 +01:00
parent 4e7087b350
commit 4f5e52c363
16 changed files with 171 additions and 92 deletions

View File

@ -551,6 +551,7 @@ packages/lib/models/SmartFilter.js
packages/lib/models/Tag.js
packages/lib/models/dateTimeFormats.test.js
packages/lib/models/settings/FileHandler.js
packages/lib/models/settings/types.js
packages/lib/models/utils/itemCanBeEncrypted.js
packages/lib/models/utils/paginatedFeed.js
packages/lib/models/utils/paginationToSql.js
@ -685,8 +686,6 @@ packages/lib/services/plugins/utils/validatePluginVersion.test.js
packages/lib/services/profileConfig/index.js
packages/lib/services/profileConfig/index.test.js
packages/lib/services/profileConfig/initProfile.js
packages/lib/services/profileConfig/mergeGlobalAndLocalSettings.js
packages/lib/services/profileConfig/splitGlobalAndLocalSettings.js
packages/lib/services/profileConfig/types.js
packages/lib/services/rest/Api.js
packages/lib/services/rest/Api.test.js

3
.gitignore vendored
View File

@ -537,6 +537,7 @@ packages/lib/models/SmartFilter.js
packages/lib/models/Tag.js
packages/lib/models/dateTimeFormats.test.js
packages/lib/models/settings/FileHandler.js
packages/lib/models/settings/types.js
packages/lib/models/utils/itemCanBeEncrypted.js
packages/lib/models/utils/paginatedFeed.js
packages/lib/models/utils/paginationToSql.js
@ -671,8 +672,6 @@ packages/lib/services/plugins/utils/validatePluginVersion.test.js
packages/lib/services/profileConfig/index.js
packages/lib/services/profileConfig/index.test.js
packages/lib/services/profileConfig/initProfile.js
packages/lib/services/profileConfig/mergeGlobalAndLocalSettings.js
packages/lib/services/profileConfig/splitGlobalAndLocalSettings.js
packages/lib/services/profileConfig/types.js
packages/lib/services/rest/Api.js
packages/lib/services/rest/Api.test.js

View File

@ -1,4 +1,5 @@
import Setting, { SettingStorage } from '@joplin/lib/models/Setting';
import { schemaUrl } from '@joplin/lib/models/settings/types';
import { SettingItemType } from '@joplin/lib/services/plugins/api/types';
import shim from '@joplin/lib/shim';
@ -38,7 +39,7 @@ class Command extends BaseCommand {
public async action(args: any) {
const schema: Record<string, any> = {
title: 'JSON schema for Joplin setting files',
'$id': Setting.schemaUrl,
'$id': schemaUrl,
'$schema': 'https://json-schema.org/draft-07/schema#',
type: 'object',
properties: {},

View File

@ -14,4 +14,5 @@ style.min.css
build/lib/
vendor/*
!vendor/loadEmojiLib.js
main-html.bundle.js
main-html.bundle.js
main.js

View File

@ -84,35 +84,35 @@ export class Bridge {
// Perhaps the easiest would be to patch electron-context-menu to
// support the renderer process again. Or possibly revert to an old
// version of electron-context-menu.
public setupContextMenu(_spellCheckerMenuItemsHandler: Function) {
require('electron-context-menu')({
allWindows: [this.window()],
// public setupContextMenu(_spellCheckerMenuItemsHandler: Function) {
// require('electron-context-menu')({
// allWindows: [this.window()],
electronApp: this.electronApp(),
// electronApp: this.electronApp(),
shouldShowMenu: (_event: any, params: any) => {
// params.inputFieldType === 'none' when right-clicking the text
// editor. This is a bit of a hack to detect it because in this
// case we don't want to use the built-in context menu but a
// custom one.
return params.isEditable && params.inputFieldType !== 'none';
},
// shouldShowMenu: (_event: any, params: any) => {
// // params.inputFieldType === 'none' when right-clicking the text
// // editor. This is a bit of a hack to detect it because in this
// // case we don't want to use the built-in context menu but a
// // custom one.
// return params.isEditable && params.inputFieldType !== 'none';
// },
// menu: (actions: any, props: any) => {
// const items = spellCheckerMenuItemsHandler(props.misspelledWord, props.dictionarySuggestions);
// const spellCheckerMenuItems = items.map((item: any) => new MenuItem(item)); //SpellCheckerService.instance().contextMenuItems(props.misspelledWord, props.dictionarySuggestions).map((item: any) => new MenuItem(item));
// // menu: (actions: any, props: any) => {
// // const items = spellCheckerMenuItemsHandler(props.misspelledWord, props.dictionarySuggestions);
// // const spellCheckerMenuItems = items.map((item: any) => new MenuItem(item)); //SpellCheckerService.instance().contextMenuItems(props.misspelledWord, props.dictionarySuggestions).map((item: any) => new MenuItem(item));
// const output = [
// actions.cut(),
// actions.copy(),
// actions.paste(),
// ...spellCheckerMenuItems,
// ];
// // const output = [
// // actions.cut(),
// // actions.copy(),
// // actions.paste(),
// // ...spellCheckerMenuItems,
// // ];
// return output;
// },
});
}
// // return output;
// // },
// });
// }
public window() {
return this.electronWrapper_.window();

View File

@ -6,6 +6,8 @@
"private": true,
"scripts": {
"dist": "yarn run electronRebuild && npx electron-builder",
"pack-html": "rollup --config rollup-main-html.config.js",
"pack-main": "rollup --config rollup-main.config.js",
"build": "gulp build",
"postinstall": "yarn run build",
"electronBuilder": "gulp electronBuilder",
@ -36,6 +38,9 @@
"build/images/**",
"build/defaultPlugins/**"
],
"files": [
"!node_modules/**/*"
],
"afterAllArtifactBuild": "./generateSha512.js",
"asar": true,
"asarUnpack": "./node_modules/node-notifier/vendor/**",
@ -110,6 +115,8 @@
"devDependencies": {
"@joplin/tools": "~2.11",
"@rollup/plugin-commonjs": "24.1.0",
"@rollup/plugin-json": "6.0.0",
"@rollup/plugin-node-resolve": "15.0.2",
"@testing-library/react-hooks": "8.0.1",
"@types/jest": "29.2.6",
"@types/node": "18.11.18",

View File

@ -0,0 +1,24 @@
const commonjs = require('@rollup/plugin-commonjs');
const nodeResolve = require('@rollup/plugin-node-resolve');
const pluginJson = require('@rollup/plugin-json');
module.exports = {
input: 'main-html.js',
output: {
file: 'main-html.bundle.js',
format: 'cjs',
},
plugins: [
nodeResolve(),
pluginJson(),
commonjs({
dynamicRequireTargets: [
'codemirror/mode/python/python',
],
}),
],
external: [
'keytar',
'fsevents',
],
};

View File

@ -0,0 +1,16 @@
const commonjs = require('@rollup/plugin-commonjs');
const nodeResolve = require('@rollup/plugin-node-resolve');
const pluginJson = require('@rollup/plugin-json');
module.exports = {
input: 'main.source.js',
output: {
file: 'main.js',
format: 'cjs',
},
plugins: [
nodeResolve(),
pluginJson(),
commonjs(),
],
};

View File

@ -1,14 +0,0 @@
const commonjs = require('@rollup/plugin-commonjs');
module.exports = {
input: 'main-html.js',
output: {
file: 'main-html.bundle.js',
format: 'cjs',
},
plugins: [commonjs({
dynamicRequireTargets: [
'codemirror/mode/python/python',
],
})],
};

View File

@ -7,8 +7,6 @@ import SyncTargetRegistry from '../SyncTargetRegistry';
import time from '../time';
import FileHandler, { SettingValues } from './settings/FileHandler';
import Logger from '../Logger';
import mergeGlobalAndLocalSettings from '../services/profileConfig/mergeGlobalAndLocalSettings';
import splitGlobalAndLocalSettings from '../services/profileConfig/splitGlobalAndLocalSettings';
const { sprintf } = require('sprintf-js');
const ObjectUtils = require('../ObjectUtils');
const { toTitleCase } = require('../string-utils.js');
@ -16,6 +14,44 @@ const { rtrimSlashes, toSystemSlashes } = require('../path-utils');
const logger = Logger.create('models/Setting');
const mergeGlobalAndLocalSettings = (rootSettings: Record<string, any>, subProfileSettings: Record<string, any>) => {
const output: Record<string, any> = { ...subProfileSettings };
for (const k of Object.keys(output)) {
const md = Setting.settingMetadata(k);
if (md.isGlobal) {
delete output[k];
if (k in rootSettings) output[k] = rootSettings[k];
}
}
for (const k of Object.keys(rootSettings)) {
const md = Setting.settingMetadata(k);
if (md.isGlobal) {
output[k] = rootSettings[k];
}
}
return output;
};
const splitGlobalAndLocalSettings = (settings: SettingValues) => {
const globalSettings: SettingValues = {};
const localSettings: SettingValues = {};
for (const [k, v] of Object.entries(settings)) {
const md = Setting.settingMetadata(k);
if (md.isGlobal) {
globalSettings[k] = v;
} else {
localSettings[k] = v;
}
}
return { globalSettings, localSettings };
};
export enum SettingItemType {
Int = 1,
String = 2,
@ -219,8 +255,6 @@ const userSettingMigration: UserSettingMigration[] = [
class Setting extends BaseModel {
public static schemaUrl = 'https://joplinapp.org/schema/settings.json';
// For backward compatibility
public static TYPE_INT = SettingItemType.Int;
public static TYPE_STRING = SettingItemType.String;

View File

@ -1,6 +1,6 @@
import Logger from '../../Logger';
import shim from '../../shim';
import Setting from '../Setting';
import { schemaUrl } from './types';
const logger = Logger.create('Settings');
@ -41,7 +41,7 @@ export default class FileHandler {
public async save(values: SettingValues) {
const json = `${JSON.stringify({
'$schema': Setting.schemaUrl,
'$schema': schemaUrl,
...values,
}, null, '\t')}\n`;

View File

@ -0,0 +1,2 @@
// eslint-disable-next-line import/prefer-default-export
export const schemaUrl = 'https://joplinapp.org/schema/settings.json';

View File

@ -1,22 +0,0 @@
import Setting from '../../models/Setting';
export default (rootSettings: Record<string, any>, subProfileSettings: Record<string, any>) => {
const output: Record<string, any> = { ...subProfileSettings };
for (const k of Object.keys(output)) {
const md = Setting.settingMetadata(k);
if (md.isGlobal) {
delete output[k];
if (k in rootSettings) output[k] = rootSettings[k];
}
}
for (const k of Object.keys(rootSettings)) {
const md = Setting.settingMetadata(k);
if (md.isGlobal) {
output[k] = rootSettings[k];
}
}
return output;
};

View File

@ -1,19 +0,0 @@
import Setting from '../../models/Setting';
import { SettingValues } from '../../models/settings/FileHandler';
export default (settings: SettingValues) => {
const globalSettings: SettingValues = {};
const localSettings: SettingValues = {};
for (const [k, v] of Object.entries(settings)) {
const md = Setting.settingMetadata(k);
if (md.isGlobal) {
globalSettings[k] = v;
} else {
localSettings[k] = v;
}
}
return { globalSettings, localSettings };
};

View File

@ -6254,6 +6254,8 @@ __metadata:
"@joplin/renderer": ~2.11
"@joplin/tools": ~2.11
"@rollup/plugin-commonjs": 24.1.0
"@rollup/plugin-json": 6.0.0
"@rollup/plugin-node-resolve": 15.0.2
"@testing-library/react-hooks": 8.0.1
"@types/jest": 29.2.6
"@types/node": 18.11.18
@ -8827,6 +8829,39 @@ __metadata:
languageName: node
linkType: hard
"@rollup/plugin-json@npm:6.0.0":
version: 6.0.0
resolution: "@rollup/plugin-json@npm:6.0.0"
dependencies:
"@rollup/pluginutils": ^5.0.1
peerDependencies:
rollup: ^1.20.0||^2.0.0||^3.0.0
peerDependenciesMeta:
rollup:
optional: true
checksum: 77cfc941edaf77a5307977704ffaba706d83bea66f265b2b68f14be2a0af6d08b0fb1b04fdd773146c84cc70938ff64b00ae946808fd6ac057058af824d78128
languageName: node
linkType: hard
"@rollup/plugin-node-resolve@npm:15.0.2":
version: 15.0.2
resolution: "@rollup/plugin-node-resolve@npm:15.0.2"
dependencies:
"@rollup/pluginutils": ^5.0.1
"@types/resolve": 1.20.2
deepmerge: ^4.2.2
is-builtin-module: ^3.2.1
is-module: ^1.0.0
resolve: ^1.22.1
peerDependencies:
rollup: ^2.78.0||^3.0.0
peerDependenciesMeta:
rollup:
optional: true
checksum: 328eafee06ff967a36441b55e77fbd0d4f599d256e5d1977800ee71915846c46bc1b6185df35c7b512ad2b4023b05b65a332be77b8b00b9d8a20f87d056b8166
languageName: node
linkType: hard
"@rollup/pluginutils@npm:^5.0.1":
version: 5.0.2
resolution: "@rollup/pluginutils@npm:5.0.2"
@ -9931,6 +9966,13 @@ __metadata:
languageName: node
linkType: hard
"@types/resolve@npm:1.20.2":
version: 1.20.2
resolution: "@types/resolve@npm:1.20.2"
checksum: 61c2cad2499ffc8eab36e3b773945d337d848d3ac6b7b0a87c805ba814bc838ef2f262fc0f109bfd8d2e0898ff8bd80ad1025f9ff64f1f71d3d4294c9f14e5f6
languageName: node
linkType: hard
"@types/responselike@npm:*, @types/responselike@npm:^1.0.0":
version: 1.0.0
resolution: "@types/responselike@npm:1.0.0"
@ -12949,7 +12991,7 @@ __metadata:
languageName: node
linkType: hard
"builtin-modules@npm:3.3.0":
"builtin-modules@npm:3.3.0, builtin-modules@npm:^3.3.0":
version: 3.3.0
resolution: "builtin-modules@npm:3.3.0"
checksum: db021755d7ed8be048f25668fe2117620861ef6703ea2c65ed2779c9e3636d5c3b82325bd912244293959ff3ae303afa3471f6a15bf5060c103e4cc3a839749d
@ -22222,6 +22264,15 @@ __metadata:
languageName: node
linkType: hard
"is-builtin-module@npm:^3.2.1":
version: 3.2.1
resolution: "is-builtin-module@npm:3.2.1"
dependencies:
builtin-modules: ^3.3.0
checksum: e8f0ffc19a98240bda9c7ada84d846486365af88d14616e737d280d378695c8c448a621dcafc8332dbf0fcd0a17b0763b845400709963fa9151ddffece90ae88
languageName: node
linkType: hard
"is-callable@npm:^1.1.3, is-callable@npm:^1.1.4, is-callable@npm:^1.2.4":
version: 1.2.4
resolution: "is-callable@npm:1.2.4"