refactor: native feature management (#2350)
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
import { useMemo, FunctionComponent } from 'react'
|
||||
import { SNApplication, SNNote, classNames } from '@standardnotes/snjs'
|
||||
import { SNNote, classNames } from '@standardnotes/snjs'
|
||||
import { formatDateForContextMenu } from '@/Utils/DateUtils'
|
||||
import { calculateReadTime } from './Utils/calculateReadTime'
|
||||
import { countNoteAttributes } from './Utils/countNoteAttributes'
|
||||
import { WebApplicationInterface } from '@standardnotes/ui-services'
|
||||
|
||||
export const useNoteAttributes = (application: SNApplication, note: SNNote) => {
|
||||
export const useNoteAttributes = (application: WebApplicationInterface, note: SNNote) => {
|
||||
const { words, characters, paragraphs } = useMemo(() => countNoteAttributes(note.text), [note.text])
|
||||
|
||||
const readTime = useMemo(() => (typeof words === 'number' ? calculateReadTime(words) : 'N/A'), [words])
|
||||
@@ -14,7 +15,7 @@ export const useNoteAttributes = (application: SNApplication, note: SNNote) => {
|
||||
const dateCreated = useMemo(() => formatDateForContextMenu(note.created_at), [note.created_at])
|
||||
|
||||
const editor = application.componentManager.editorForNote(note)
|
||||
const format = editor?.package_info?.file_type || 'txt'
|
||||
const format = editor.fileType
|
||||
|
||||
return {
|
||||
words,
|
||||
@@ -28,7 +29,7 @@ export const useNoteAttributes = (application: SNApplication, note: SNNote) => {
|
||||
}
|
||||
|
||||
export const NoteAttributes: FunctionComponent<{
|
||||
application: SNApplication
|
||||
application: WebApplicationInterface
|
||||
note: SNNote
|
||||
className?: string
|
||||
}> = ({ application, note, className }) => {
|
||||
|
||||
Reference in New Issue
Block a user