mirror of
https://github.com/leanote/desktop-app.git
synced 2025-10-19 01:54:02 +00:00
导入导出leanote的图片附件前缀为leanote://file/getX 去掉api
This commit is contained in:
@@ -10,7 +10,7 @@
|
|||||||
notes: [
|
notes: [
|
||||||
{
|
{
|
||||||
title: 'life',
|
title: 'life',
|
||||||
content: 'laldfadf', // 图片, 附件链接为 leanote://api/file/getImage?fileId=xxxx, leanote://api/file/getAttach?fileId=3232323
|
content: 'laldfadf', // 图片, 附件链接为 leanote://file/getImage?fileId=xxxx, leanote://file/getAttach?fileId=3232323
|
||||||
tags: [1,2,3],
|
tags: [1,2,3],
|
||||||
isMarkdown: true,
|
isMarkdown: true,
|
||||||
author: 'leanote', // 作者, 没用
|
author: 'leanote', // 作者, 没用
|
||||||
@@ -298,21 +298,21 @@ define(function() {
|
|||||||
if (note.IsMarkdown) {
|
if (note.IsMarkdown) {
|
||||||
var href;
|
var href;
|
||||||
if (!eachMatch.isAttach) {
|
if (!eachMatch.isAttach) {
|
||||||
href = 'leanote://api/file/getImage?fileId=' + eachMatch.fileId;
|
href = 'leanote://file/getImage?fileId=' + eachMatch.fileId;
|
||||||
link = '';
|
link = '';
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
href = 'leanote://api/file/getAttach?fileId=' + eachMatch.fileId;
|
href = 'leanote://file/getAttach?fileId=' + eachMatch.fileId;
|
||||||
link = '[' + eachMatch.title + '](' + href + ')';
|
link = '[' + eachMatch.title + '](' + href + ')';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (!eachMatch.isAttach) {
|
if (!eachMatch.isAttach) {
|
||||||
var href = 'leanote://api/file/getImage?fileId=' + eachMatch.fileId;
|
var href = 'leanote://file/getImage?fileId=' + eachMatch.fileId;
|
||||||
link = '<img ' + eachMatch.pre + 'src="' + href + '"' + eachMatch.back + '>';
|
link = '<img ' + eachMatch.pre + 'src="' + href + '"' + eachMatch.back + '>';
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
var href = 'leanote://api/file/getAttach?fileId=' + eachMatch.fileId;
|
var href = 'leanote://file/getAttach?fileId=' + eachMatch.fileId;
|
||||||
link = '<a ' + eachMatch.pre + 'href="' + href + '"' + eachMatch.back + '>' + eachMatch.title + '</a>';
|
link = '<a ' + eachMatch.pre + 'href="' + href + '"' + eachMatch.back + '>' + eachMatch.title + '</a>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -18,7 +18,7 @@ var Import = {
|
|||||||
notes: [
|
notes: [
|
||||||
{
|
{
|
||||||
title: 'life',
|
title: 'life',
|
||||||
content: 'laldfadf', // 图片, 附件链接为 leanote://api/file/getImage?fileId=xxxx, leanote://api/file/getAttach?fileId=3232323
|
content: 'laldfadf', // 图片, 附件链接为 leanote://file/getImage?fileId=xxxx, leanote://file/getAttach?fileId=3232323
|
||||||
tags: [1,2,3],
|
tags: [1,2,3],
|
||||||
isMarkdown: true,
|
isMarkdown: true,
|
||||||
author: 'leanote', // 作者, 没用
|
author: 'leanote', // 作者, 没用
|
||||||
@@ -92,7 +92,7 @@ var Import = {
|
|||||||
if (note.isMarkdown) {
|
if (note.isMarkdown) {
|
||||||
|
|
||||||
// image
|
// image
|
||||||
var reg = new RegExp('!\\[([^\\]]*?)\\]\\(leanote://api/file/getImage\\?fileId=([0-9a-zA-Z]{24})\\)', 'g');
|
var reg = new RegExp('!\\[([^\\]]*?)\\]\\(leanote://file/getImage\\?fileId=([0-9a-zA-Z]{24})\\)', 'g');
|
||||||
var matches = reg.exec(content);
|
var matches = reg.exec(content);
|
||||||
// 先找到所有的
|
// 先找到所有的
|
||||||
while(matches) {
|
while(matches) {
|
||||||
@@ -110,7 +110,7 @@ var Import = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// attach
|
// attach
|
||||||
var reg = new RegExp('\\[([^\\]]*?)\\]\\(leanote://api/file/getAttach\\?fileId=([0-9a-zA-Z]{24})\\)', 'g');
|
var reg = new RegExp('\\[([^\\]]*?)\\]\\(leanote://file/getAttach\\?fileId=([0-9a-zA-Z]{24})\\)', 'g');
|
||||||
var matches = reg.exec(content);
|
var matches = reg.exec(content);
|
||||||
// 先找到所有的
|
// 先找到所有的
|
||||||
while(matches) {
|
while(matches) {
|
||||||
@@ -130,8 +130,8 @@ var Import = {
|
|||||||
else {
|
else {
|
||||||
|
|
||||||
// 图片处理后, 可以替换内容中的链接了
|
// 图片处理后, 可以替换内容中的链接了
|
||||||
// leanote://api/file/getImage?fileId=xxxx,
|
// leanote://file/getImage?fileId=xxxx,
|
||||||
var reg = new RegExp('<img([^>]*?)src=["\']?leanote://api/file/getImage\\?fileId=([0-9a-zA-Z]{24})["\']?(.*?)>', 'g');
|
var reg = new RegExp('<img([^>]*?)src=["\']?leanote://file/getImage\\?fileId=([0-9a-zA-Z]{24})["\']?(.*?)>', 'g');
|
||||||
var matches = reg.exec(content);
|
var matches = reg.exec(content);
|
||||||
while(matches) {
|
while(matches) {
|
||||||
var all = matches[0];
|
var all = matches[0];
|
||||||
@@ -149,7 +149,7 @@ var Import = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 处理附件
|
// 处理附件
|
||||||
var reg = new RegExp('<a([^>]*?)href=["\']?leanote://api/file/getAttach\\?fileId=([0-9a-zA-Z]{24})["\']?(.*?)>([^<]*)</a>', 'g');
|
var reg = new RegExp('<a([^>]*?)href=["\']?leanote://file/getAttach\\?fileId=([0-9a-zA-Z]{24})["\']?(.*?)>([^<]*)</a>', 'g');
|
||||||
var matches = reg.exec(content);
|
var matches = reg.exec(content);
|
||||||
// 先找到所有的
|
// 先找到所有的
|
||||||
while(matches) {
|
while(matches) {
|
||||||
@@ -204,7 +204,6 @@ var Import = {
|
|||||||
link = '<a ' + eachMatch.pre + 'href="' + href + '"' + eachMatch.back + '>' + eachMatch.title + '</a>';
|
link = '<a ' + eachMatch.pre + 'href="' + href + '"' + eachMatch.back + '>' + eachMatch.title + '</a>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
content = content.replace(eachMatch.all, link);
|
content = content.replace(eachMatch.all, link);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user