fix: Fixed issue with Keep HTML imports not working
This commit is contained in:
@@ -3,6 +3,8 @@ import { DecryptedItemInterface, FileItem, ItemContent, NoteContent, SNNote, SNT
|
|||||||
import { ConversionResult } from './ConversionResult'
|
import { ConversionResult } from './ConversionResult'
|
||||||
import { SuperConverterHTMLOptions } from '@standardnotes/snjs'
|
import { SuperConverterHTMLOptions } from '@standardnotes/snjs'
|
||||||
|
|
||||||
|
export type HTMLToSuperConverterFunction = (html: string, options?: SuperConverterHTMLOptions) => string
|
||||||
|
|
||||||
export interface Converter {
|
export interface Converter {
|
||||||
getImportType(): string
|
getImportType(): string
|
||||||
|
|
||||||
@@ -19,7 +21,7 @@ export interface Converter {
|
|||||||
canUploadFiles: boolean
|
canUploadFiles: boolean
|
||||||
uploadFile: UploadFileFn
|
uploadFile: UploadFileFn
|
||||||
canUseSuper: boolean
|
canUseSuper: boolean
|
||||||
convertHTMLToSuper: (html: string, options?: SuperConverterHTMLOptions) => string
|
convertHTMLToSuper: HTMLToSuperConverterFunction
|
||||||
convertMarkdownToSuper: (markdown: string) => string
|
convertMarkdownToSuper: (markdown: string) => string
|
||||||
readFileAsText: (file: File) => Promise<string>
|
readFileAsText: (file: File) => Promise<string>
|
||||||
linkItems(
|
linkItems(
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { SNNote } from '@standardnotes/models'
|
import { SNNote } from '@standardnotes/models'
|
||||||
import { Converter, InsertNoteFn } from '../Converter'
|
import { Converter, HTMLToSuperConverterFunction, InsertNoteFn } from '../Converter'
|
||||||
|
|
||||||
type Content =
|
type Content =
|
||||||
| {
|
| {
|
||||||
@@ -40,6 +40,10 @@ export class GoogleKeepConverter implements Converter {
|
|||||||
console.error(error)
|
console.error(error)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (content.length > 0 && content.includes('class="content"')) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,7 +71,7 @@ export class GoogleKeepConverter implements Converter {
|
|||||||
data: string,
|
data: string,
|
||||||
file: { name: string },
|
file: { name: string },
|
||||||
insertNote: InsertNoteFn,
|
insertNote: InsertNoteFn,
|
||||||
convertHTMLToSuper: (html: string) => string,
|
convertHTMLToSuper: HTMLToSuperConverterFunction,
|
||||||
canUseSuper: boolean,
|
canUseSuper: boolean,
|
||||||
): Promise<SNNote> {
|
): Promise<SNNote> {
|
||||||
const rootElement = document.createElement('html')
|
const rootElement = document.createElement('html')
|
||||||
@@ -109,7 +113,9 @@ export class GoogleKeepConverter implements Converter {
|
|||||||
contentElement.innerHTML = contentElement.innerHTML.replace(/<br>/g, '\n')
|
contentElement.innerHTML = contentElement.innerHTML.replace(/<br>/g, '\n')
|
||||||
content = contentElement.textContent
|
content = contentElement.textContent
|
||||||
} else {
|
} else {
|
||||||
content = convertHTMLToSuper(rootElement.innerHTML)
|
content = convertHTMLToSuper(rootElement.innerHTML, {
|
||||||
|
addLineBreaks: false,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!content) {
|
if (!content) {
|
||||||
|
|||||||
Reference in New Issue
Block a user