mirror of https://github.com/laurent22/joplin.git
Desktop: Improved custom icon selection
parent
2933b7eb2a
commit
885f0e1557
|
@ -96,7 +96,14 @@ export default function(props: Props) {
|
|||
}, []);
|
||||
|
||||
const onBrowseClick = useCallback(async () => {
|
||||
const filePaths = await bridge().showOpenDialog();
|
||||
const filePaths = await bridge().showOpenDialog({
|
||||
filters: [
|
||||
{
|
||||
name: _('Images'),
|
||||
extensions: ['jpg', 'jpeg', 'png'],
|
||||
},
|
||||
],
|
||||
});
|
||||
if (filePaths.length !== 1) return;
|
||||
const filePath = filePaths[0];
|
||||
|
||||
|
|
|
@ -6,4 +6,8 @@
|
|||
|
||||
.icon-selector-row > .foldericon {
|
||||
margin-right: 5px;
|
||||
display: flex;
|
||||
border: 1px solid var(--joplin-divider-color);
|
||||
padding: 5px;
|
||||
background-color: var(--joplin-background-color);
|
||||
}
|
|
@ -17,6 +17,7 @@ const toRelative = require('relative');
|
|||
const timers = require('timers');
|
||||
const zlib = require('zlib');
|
||||
const dgram = require('dgram');
|
||||
const { basename, fileExtension, safeFileExtension } = require('./path-utils');
|
||||
|
||||
function fileExists(filePath) {
|
||||
try {
|
||||
|
@ -230,7 +231,6 @@ function shimInit(options = null) {
|
|||
const imageType = require('image-type');
|
||||
|
||||
const uuid = require('./uuid').default;
|
||||
const { basename, fileExtension, safeFileExtension } = require('./path-utils');
|
||||
|
||||
if (!(await fs.pathExists(filePath))) throw new Error(_('Cannot access %s', filePath));
|
||||
|
||||
|
@ -336,6 +336,9 @@ function shimInit(options = null) {
|
|||
const image = nativeImage.createFromPath(filePath);
|
||||
if (!image) throw new Error(`Could not load image: ${filePath}`);
|
||||
|
||||
const ext = fileExtension(filePath).toLowerCase();
|
||||
if (!['jpg', 'jpeg', 'png'].includes(ext)) throw new Error(`Unsupported file format: ${ext}`);
|
||||
|
||||
if (maxSize) {
|
||||
const size = image.getSize();
|
||||
if (size.width > maxSize || size.height > maxSize) throw new Error(`Image cannot be larger than ${maxSize}x${maxSize} pixels`);
|
||||
|
|
Loading…
Reference in New Issue