You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-12-05 22:57:29 +02:00
Desktop: Fix import interop service (#1887)
* Revert "Revert "Desktop: Add ENEX to HTML export (#1795)"" This reverts commit50b66cceca. * Revert "Revert "Desktop, Cli: Fixed interop service so that it still allow auto-detecting importer based on format (required for Cli and for test units)"" This reverts commitc7c57ab2a5. * Fix the .md importer * Add comment re future refactor * Rm importerClass for .md importer * Fix EnexToMd module name
This commit is contained in:
committed by
Laurent Cozic
parent
8a8ecaade3
commit
172d925f0f
@@ -5,6 +5,7 @@ const Note = require('lib/models/Note.js');
|
||||
const Tag = require('lib/models/Tag.js');
|
||||
const Resource = require('lib/models/Resource.js');
|
||||
const { enexXmlToMd } = require('./import-enex-md-gen.js');
|
||||
const { enexXmlToHtml } = require('./import-enex-html-gen.js');
|
||||
const { time } = require('lib/time-utils.js');
|
||||
const Levenshtein = require('levenshtein');
|
||||
const md5 = require('md5');
|
||||
@@ -164,6 +165,7 @@ async function saveNoteToStorage(note, fuzzyMatching = false) {
|
||||
|
||||
function importEnex(parentFolderId, filePath, importOptions = null) {
|
||||
if (!importOptions) importOptions = {};
|
||||
// console.info(JSON.stringify({importOptions}, null, 2));
|
||||
if (!('fuzzyMatching' in importOptions)) importOptions.fuzzyMatching = false;
|
||||
if (!('onProgress' in importOptions)) importOptions.onProgress = function() {};
|
||||
if (!('onError' in importOptions)) importOptions.onError = function() {};
|
||||
@@ -216,9 +218,15 @@ function importEnex(parentFolderId, filePath, importOptions = null) {
|
||||
|
||||
while (notes.length) {
|
||||
let note = notes.shift();
|
||||
const body = await enexXmlToMd(note.bodyXml, note.resources);
|
||||
const body = importOptions.outputFormat === 'html' ?
|
||||
await enexXmlToHtml(note.bodyXml, note.resources) :
|
||||
await enexXmlToMd(note.bodyXml, note.resources);
|
||||
delete note.bodyXml;
|
||||
|
||||
note.markup_language = importOptions.outputFormat === 'html' ?
|
||||
Note.MARKUP_LANGUAGE_HTML :
|
||||
Note.MARKUP_LANGUAGE_MARKDOWN;
|
||||
|
||||
// console.info('*************************************************************************');
|
||||
// console.info(body);
|
||||
// console.info('*************************************************************************');
|
||||
|
||||
Reference in New Issue
Block a user