Skip to content

Commit

Permalink
fix: Fixed issue when importing plaintext file
Browse files Browse the repository at this point in the history
  • Loading branch information
amanharwara committed Nov 24, 2023
1 parent 6a5cbc8 commit 1f81cad
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand All @@ -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
? {
Expand Down
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 1f81cad

Please sign in to comment.