You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-06-18 23:07:45 +02:00
Add support for editable resources
This commit is contained in:
@ -144,7 +144,7 @@ function shimInit() {
|
||||
|
||||
shim.createResourceFromPath = async function(filePath, defaultProps = null, options = null) {
|
||||
options = Object.assign({
|
||||
resizeLargeImages: 'always', // 'always' or 'ask'
|
||||
resizeLargeImages: 'always', // 'always', 'ask' or 'never'
|
||||
}, options);
|
||||
|
||||
const readChunk = require('read-chunk');
|
||||
@ -182,7 +182,7 @@ function shimInit() {
|
||||
|
||||
const targetPath = Resource.fullPath(resource);
|
||||
|
||||
if (['image/jpeg', 'image/jpg', 'image/png'].includes(resource.mime)) {
|
||||
if (options.resizeLargeImages !== 'never' && ['image/jpeg', 'image/jpg', 'image/png'].includes(resource.mime)) {
|
||||
const ok = await handleResizeImage_(filePath, targetPath, resource.mime, options.resizeLargeImages);
|
||||
if (!ok) return null;
|
||||
} else {
|
||||
@ -205,6 +205,17 @@ function shimInit() {
|
||||
return Resource.save(resource, { isNew: true });
|
||||
};
|
||||
|
||||
shim.updateResourceBlob = async function(resourceId, newBlobFilePath) {
|
||||
const resource = await Resource.load(resourceId);
|
||||
const fileStat = await shim.fsDriver().stat(newBlobFilePath);
|
||||
await shim.fsDriver().copy(newBlobFilePath, Resource.fullPath(resource));
|
||||
|
||||
await Resource.save({
|
||||
id: resource.id,
|
||||
size: fileStat.size,
|
||||
});
|
||||
};
|
||||
|
||||
shim.attachFileToNoteBody = async function(noteBody, filePath, position = null, options = null) {
|
||||
options = Object.assign({}, {
|
||||
createFileURL: false,
|
||||
|
Reference in New Issue
Block a user