You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-06-27 23:28:38 +02:00
This commit is contained in:
@ -61,7 +61,7 @@ const markdownUtils = {
|
||||
},
|
||||
|
||||
// Returns the **encoded** URLs, so to be useful they should be decoded again before use.
|
||||
extractImageUrls(md: string) {
|
||||
extractFileUrls(md: string, onlyImage: boolean = false): Array<string> {
|
||||
const markdownIt = new MarkdownIt();
|
||||
markdownIt.validateLink = validateLinks; // Necessary to support file:/// links
|
||||
|
||||
@ -72,11 +72,10 @@ const markdownUtils = {
|
||||
const searchUrls = (tokens: any[]) => {
|
||||
for (let i = 0; i < tokens.length; i++) {
|
||||
const token = tokens[i];
|
||||
|
||||
if (token.type === 'image') {
|
||||
if ((onlyImage === true && token.type === 'image') || (onlyImage === false && (token.type === 'image' || token.type === 'link_open'))) {
|
||||
for (let j = 0; j < token.attrs.length; j++) {
|
||||
const a = token.attrs[j];
|
||||
if (a[0] === 'src' && a.length >= 2 && a[1]) {
|
||||
if ((a[0] === 'src' || a[0] === 'href') && a.length >= 2 && a[1]) {
|
||||
output.push(a[1]);
|
||||
}
|
||||
}
|
||||
@ -93,6 +92,10 @@ const markdownUtils = {
|
||||
return output;
|
||||
},
|
||||
|
||||
extractImageUrls(md: string) {
|
||||
return markdownUtils.extractFileUrls(md,true);
|
||||
},
|
||||
|
||||
// The match results has 5 items
|
||||
// Full match array is
|
||||
// [Full match, whitespace, list token, ol line number, whitespace following token]
|
||||
|
Reference in New Issue
Block a user