2016-05-12 11:44:29 +02:00
|
|
|
import QtQml 2.0
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This script will make the paths of inserted media files absolute in the markdown link (tested on Linux)
|
|
|
|
*/
|
|
|
|
QtObject {
|
|
|
|
/**
|
|
|
|
* This function is called when media file is inserted into the note
|
|
|
|
*
|
|
|
|
* @param fileName string the file path of the source media file before it was copied to the media folder
|
|
|
|
* @param mediaMarkdownText string the markdown text of the media file, e.g. 
|
|
|
|
* @return string the new markdown text of the media file
|
|
|
|
*/
|
2016-05-12 18:50:18 +02:00
|
|
|
function callInsertMediaHook(fileName, mediaMarkdownText) {
|
2016-05-12 11:44:29 +02:00
|
|
|
// get the path of the current note folder
|
|
|
|
var path = script.currentNoteFolderPath();
|
2016-05-12 12:44:51 +02:00
|
|
|
|
|
|
|
// Windows users might want to add an additional slash in front of the path
|
|
|
|
//path = "/" + path;
|
|
|
|
|
2016-05-12 11:44:29 +02:00
|
|
|
// make the path of inserted media files absolute
|
2016-05-12 12:39:10 +02:00
|
|
|
return mediaMarkdownText.replace(new RegExp("media", "g"), path + "/media");
|
2016-05-12 11:44:29 +02:00
|
|
|
}
|
|
|
|
}
|