mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-10-01 00:10:45 +00:00
Evernote plugin: fix crash with missing fields
This commit is contained in:
parent
b3e0e134ab
commit
5238b4d503
@ -35,10 +35,10 @@ exports["application/enex+xml"] = function(text,fields) {
|
|||||||
var noteNodes = doc.querySelectorAll("note");
|
var noteNodes = doc.querySelectorAll("note");
|
||||||
$tw.utils.each(noteNodes,function(noteNode) {
|
$tw.utils.each(noteNodes,function(noteNode) {
|
||||||
var result = {
|
var result = {
|
||||||
title: noteNode.querySelector("title").textContent,
|
title: getTextContent(noteNode,"title"),
|
||||||
type: "text/html",
|
type: "text/html",
|
||||||
tags: [],
|
tags: [],
|
||||||
text: noteNode.querySelector("content").textContent
|
text: getTextContent(noteNode,"content")
|
||||||
};
|
};
|
||||||
$tw.utils.each(noteNode.querySelectorAll("tag"),function(tagNode) {
|
$tw.utils.each(noteNode.querySelectorAll("tag"),function(tagNode) {
|
||||||
result.tags.push(tagNode.textContent);
|
result.tags.push(tagNode.textContent);
|
||||||
@ -49,11 +49,11 @@ exports["application/enex+xml"] = function(text,fields) {
|
|||||||
results.push(result);
|
results.push(result);
|
||||||
$tw.utils.each(noteNode.querySelectorAll("resources"),function(resourceNode) {
|
$tw.utils.each(noteNode.querySelectorAll("resources"),function(resourceNode) {
|
||||||
results.push({
|
results.push({
|
||||||
title: resourceNode.querySelector("resource-attributes>file-name").textContent,
|
title: getTextContent(resourceNode,"resource-attributes>file-name"),
|
||||||
type: resourceNode.querySelector("mime").textContent,
|
type: getTextContent(resourceNode,"mime"),
|
||||||
width: resourceNode.querySelector("width").textContent,
|
width: getTextContent(resourceNode,"width"),
|
||||||
height: resourceNode.querySelector("height").textContent,
|
height: getTextContent(resourceNode,"height"),
|
||||||
text: resourceNode.querySelector("data").textContent
|
text: getTextContent(resourceNode,"data")
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -61,4 +61,8 @@ exports["application/enex+xml"] = function(text,fields) {
|
|||||||
return results;
|
return results;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function getTextContent(node,selector) {
|
||||||
|
return (node.querySelector(selector) || {}).textContent;
|
||||||
|
}
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
Loading…
Reference in New Issue
Block a user