fix: Fixed issue when importing plaintext file
This commit is contained in:
@@ -27,8 +27,6 @@ export class PlaintextConverter {
|
|||||||
const createdAtDate = file.lastModified ? new Date(file.lastModified) : new Date()
|
const createdAtDate = file.lastModified ? new Date(file.lastModified) : new Date()
|
||||||
const updatedAtDate = 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 {
|
return {
|
||||||
created_at: createdAtDate,
|
created_at: createdAtDate,
|
||||||
created_at_timestamp: createdAtDate.getTime(),
|
created_at_timestamp: createdAtDate.getTime(),
|
||||||
@@ -38,9 +36,7 @@ export class PlaintextConverter {
|
|||||||
content_type: ContentType.TYPES.Note,
|
content_type: ContentType.TYPES.Note,
|
||||||
content: {
|
content: {
|
||||||
title: name,
|
title: name,
|
||||||
text: shouldConvertToSuper
|
text: isEntitledToSuper ? this.superConverterService.convertOtherFormatToSuperString(content, 'md') : content,
|
||||||
? this.superConverterService.convertOtherFormatToSuperString(content, 'md')
|
|
||||||
: content,
|
|
||||||
references: [],
|
references: [],
|
||||||
...(isEntitledToSuper
|
...(isEntitledToSuper
|
||||||
? {
|
? {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { createHeadlessEditor } from '@lexical/headless'
|
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 { FileItem, GenerateUuid, PrefKey, PrefValue, SuperConverterServiceInterface } from '@standardnotes/snjs'
|
||||||
import {
|
import {
|
||||||
$createParagraphNode,
|
$createParagraphNode,
|
||||||
@@ -19,6 +19,7 @@ import { $createFileExportNode } from '../Lexical/Nodes/FileExportNode'
|
|||||||
import { $createInlineFileNode, $isInlineFileNode, InlineFileNode } from '../Plugins/InlineFilePlugin/InlineFileNode'
|
import { $createInlineFileNode, $isInlineFileNode, InlineFileNode } from '../Plugins/InlineFilePlugin/InlineFileNode'
|
||||||
import { $createFileNode } from '../Plugins/EncryptedFilePlugin/Nodes/FileUtils'
|
import { $createFileNode } from '../Plugins/EncryptedFilePlugin/Nodes/FileUtils'
|
||||||
import { RemoteImageNode } from '../Plugins/RemoteImagePlugin/RemoteImageNode'
|
import { RemoteImageNode } from '../Plugins/RemoteImagePlugin/RemoteImageNode'
|
||||||
|
import { $convertFromMarkdownString } from '../Lexical/Utils/MarkdownImport'
|
||||||
export class HeadlessSuperConverter implements SuperConverterServiceInterface {
|
export class HeadlessSuperConverter implements SuperConverterServiceInterface {
|
||||||
private importEditor: LexicalEditor
|
private importEditor: LexicalEditor
|
||||||
private exportEditor: LexicalEditor
|
private exportEditor: LexicalEditor
|
||||||
@@ -218,7 +219,7 @@ export class HeadlessSuperConverter implements SuperConverterServiceInterface {
|
|||||||
this.importEditor.update(
|
this.importEditor.update(
|
||||||
() => {
|
() => {
|
||||||
try {
|
try {
|
||||||
$convertFromMarkdownString(otherFormatString, MarkdownTransformers)
|
$convertFromMarkdownString(otherFormatString, MarkdownTransformers, undefined, true)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error)
|
console.error(error)
|
||||||
didThrow = true
|
didThrow = true
|
||||||
|
|||||||
Reference in New Issue
Block a user