fix: Fixed issue when importing plaintext file

This commit is contained in:
Aman Harwara
2023-11-24 19:53:33 +05:30
parent 6a5cbc8006
commit 1f81cadcfc
2 changed files with 4 additions and 7 deletions

View File

@@ -27,8 +27,6 @@ export class PlaintextConverter {
const createdAtDate = file.lastModified ? new Date(file.lastModified) : new Date()
const updatedAtDate = file.lastModified ? new Date(file.lastModified) : new Date()
const shouldConvertToSuper = file.type === 'text/markdown' && isEntitledToSuper
return {
created_at: createdAtDate,
created_at_timestamp: createdAtDate.getTime(),
@@ -38,9 +36,7 @@ export class PlaintextConverter {
content_type: ContentType.TYPES.Note,
content: {
title: name,
text: shouldConvertToSuper
? this.superConverterService.convertOtherFormatToSuperString(content, 'md')
: content,
text: isEntitledToSuper ? this.superConverterService.convertOtherFormatToSuperString(content, 'md') : content,
references: [],
...(isEntitledToSuper
? {

View File

@@ -1,5 +1,5 @@
import { createHeadlessEditor } from '@lexical/headless'
import { $convertToMarkdownString, $convertFromMarkdownString } from '@lexical/markdown'
import { $convertToMarkdownString } from '@lexical/markdown'
import { FileItem, GenerateUuid, PrefKey, PrefValue, SuperConverterServiceInterface } from '@standardnotes/snjs'
import {
$createParagraphNode,
@@ -19,6 +19,7 @@ import { $createFileExportNode } from '../Lexical/Nodes/FileExportNode'
import { $createInlineFileNode, $isInlineFileNode, InlineFileNode } from '../Plugins/InlineFilePlugin/InlineFileNode'
import { $createFileNode } from '../Plugins/EncryptedFilePlugin/Nodes/FileUtils'
import { RemoteImageNode } from '../Plugins/RemoteImagePlugin/RemoteImageNode'
import { $convertFromMarkdownString } from '../Lexical/Utils/MarkdownImport'
export class HeadlessSuperConverter implements SuperConverterServiceInterface {
private importEditor: LexicalEditor
private exportEditor: LexicalEditor
@@ -218,7 +219,7 @@ export class HeadlessSuperConverter implements SuperConverterServiceInterface {
this.importEditor.update(
() => {
try {
$convertFromMarkdownString(otherFormatString, MarkdownTransformers)
$convertFromMarkdownString(otherFormatString, MarkdownTransformers, undefined, true)
} catch (error) {
console.error(error)
didThrow = true