You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-12-05 22:57:29 +02:00
* Add support for editable resources * Fixed handling of resource paths * Add delay before saving resource * Delete temp files and stop watching when switching notes * Handle sync when resource has been edited * Handle resource conflicts * Refactoring and handle conflicts from edit watcher * Added test unit for conflict handling when deleting resource * Trying to fix Travis-ci test units * Fixed typo * Update TinyMCE.tsx * Update AsyncActionQueue.ts
This commit is contained in:
@@ -149,7 +149,7 @@ class Note extends BaseItem {
|
||||
const id = resourceIds[i];
|
||||
const resource = await Resource.load(id);
|
||||
if (!resource) continue;
|
||||
const resourcePath = options.useAbsolutePaths ? `file://${Resource.fullPath(resource)}` : Resource.relativePath(resource);
|
||||
const resourcePath = options.useAbsolutePaths ? `${`file://${Resource.fullPath(resource)}` + '?t='}${resource.updated_time}` : Resource.relativePath(resource);
|
||||
body = body.replace(new RegExp(`:/${id}`, 'gi'), markdownUtils.escapeLinkUrl(resourcePath));
|
||||
}
|
||||
|
||||
@@ -174,12 +174,19 @@ class Note extends BaseItem {
|
||||
this.logger().info('replaceResourceExternalToInternalLinks', 'options:', options, 'pathsToTry:', pathsToTry, 'body:', body);
|
||||
|
||||
for (const basePath of pathsToTry) {
|
||||
const reString = `${pregQuote(`${basePath}/`)}[a-zA-Z0-9.]+`;
|
||||
const re = new RegExp(reString, 'gi');
|
||||
body = body.replace(re, match => {
|
||||
const id = Resource.pathToId(match);
|
||||
return `:/${id}`;
|
||||
});
|
||||
const reStrings = [
|
||||
// Handles file://path/to/abcdefg.jpg?t=12345678
|
||||
`${pregQuote(`${basePath}/`)}[a-zA-Z0-9.]+\\?t=[0-9]+`,
|
||||
// Handles file://path/to/abcdefg.jpg
|
||||
`${pregQuote(`${basePath}/`)}[a-zA-Z0-9.]+`,
|
||||
];
|
||||
for (const reString of reStrings) {
|
||||
const re = new RegExp(reString, 'gi');
|
||||
body = body.replace(re, match => {
|
||||
const id = Resource.pathToId(match);
|
||||
return `:/${id}`;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
this.logger().info('replaceResourceExternalToInternalLinks result', body);
|
||||
|
||||
Reference in New Issue
Block a user