fix: super note improvements (#1991)
* fix: super note previews * fix; checkmark size * fix: top padding * fix: prevent delete shortcut * fix: spellcheck control * fix: only embed file if uploaded to current note * fix: ability to create new tag from editor autocomplete * feat: protected file embed handling * fix: event payload
This commit is contained in:
@@ -179,7 +179,7 @@ describe('NoteView', () => {
|
||||
application,
|
||||
})
|
||||
|
||||
await noteView.dismissProtectedWarning()
|
||||
await noteView.authorizeAndDismissProtectedWarning()
|
||||
|
||||
expect(notesController.setShowProtectedWarning).toHaveBeenCalledWith(false)
|
||||
})
|
||||
@@ -192,7 +192,7 @@ describe('NoteView', () => {
|
||||
application,
|
||||
})
|
||||
|
||||
await noteView.dismissProtectedWarning()
|
||||
await noteView.authorizeAndDismissProtectedWarning()
|
||||
|
||||
expect(notesController.setShowProtectedWarning).not.toHaveBeenCalled()
|
||||
})
|
||||
@@ -207,7 +207,7 @@ describe('NoteView', () => {
|
||||
application,
|
||||
})
|
||||
|
||||
await noteView.dismissProtectedWarning()
|
||||
await noteView.authorizeAndDismissProtectedWarning()
|
||||
|
||||
expect(notesController.setShowProtectedWarning).toHaveBeenCalledWith(false)
|
||||
})
|
||||
|
||||
@@ -47,6 +47,7 @@ import {
|
||||
transactionForAssociateComponentWithCurrentNote,
|
||||
transactionForDisassociateComponentWithCurrentNote,
|
||||
} from './TransactionFunctions'
|
||||
import { SuperEditorContentId } from '@standardnotes/blocks-editor'
|
||||
|
||||
const MinimumStatusDuration = 400
|
||||
const TextareaDebounce = 100
|
||||
@@ -202,7 +203,7 @@ class NoteView extends AbstractComponent<NoteViewProps, State> {
|
||||
|
||||
this.statusTimeout = undefined
|
||||
;(this.onPanelResizeFinish as unknown) = undefined
|
||||
;(this.dismissProtectedWarning as unknown) = undefined
|
||||
;(this.authorizeAndDismissProtectedWarning as unknown) = undefined
|
||||
;(this.editorComponentViewerRequestsReload as unknown) = undefined
|
||||
;(this.onTextAreaChange as unknown) = undefined
|
||||
;(this.onTitleEnter as unknown) = undefined
|
||||
@@ -452,7 +453,7 @@ class NoteView extends AbstractComponent<NoteViewProps, State> {
|
||||
}
|
||||
}
|
||||
|
||||
dismissProtectedWarning = async () => {
|
||||
authorizeAndDismissProtectedWarning = async () => {
|
||||
let showNoteContents = true
|
||||
|
||||
if (this.application.hasProtectionSources()) {
|
||||
@@ -893,6 +894,7 @@ class NoteView extends AbstractComponent<NoteViewProps, State> {
|
||||
this.removeTrashKeyObserver = this.application.io.addKeyObserver({
|
||||
key: KeyboardKey.Backspace,
|
||||
notTags: ['INPUT', 'TEXTAREA'],
|
||||
notElementIds: [SuperEditorContentId],
|
||||
modifiers: [KeyboardModifier.Meta],
|
||||
onKeyDown: () => {
|
||||
this.deleteNote(false).catch(console.error)
|
||||
@@ -984,9 +986,9 @@ class NoteView extends AbstractComponent<NoteViewProps, State> {
|
||||
if (this.state.showProtectedWarning || !this.application.isAuthorizedToRenderItem(this.note)) {
|
||||
return (
|
||||
<ProtectedItemOverlay
|
||||
viewControllerManager={this.viewControllerManager}
|
||||
showAccountMenu={() => this.application.showAccountMenu()}
|
||||
hasProtectionSources={this.application.hasProtectionSources()}
|
||||
onViewItem={this.dismissProtectedWarning}
|
||||
onViewItem={this.authorizeAndDismissProtectedWarning}
|
||||
itemType={'note'}
|
||||
/>
|
||||
)
|
||||
@@ -1009,6 +1011,7 @@ class NoteView extends AbstractComponent<NoteViewProps, State> {
|
||||
<NoteViewFileDropTarget
|
||||
note={this.note}
|
||||
linkingController={this.viewControllerManager.linkingController}
|
||||
filesController={this.viewControllerManager.filesController}
|
||||
noteViewElement={this.noteViewElementRef.current}
|
||||
/>
|
||||
)}
|
||||
@@ -1155,6 +1158,7 @@ class NoteView extends AbstractComponent<NoteViewProps, State> {
|
||||
note={this.note}
|
||||
linkingController={this.viewControllerManager.linkingController}
|
||||
filesController={this.viewControllerManager.filesController}
|
||||
spellcheck={this.state.spellcheck}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { FilesController } from '@/Controllers/FilesController'
|
||||
import { LinkingController } from '@/Controllers/LinkingController'
|
||||
import { SNNote } from '@standardnotes/snjs'
|
||||
import { useEffect } from 'react'
|
||||
@@ -6,10 +7,11 @@ import { useFileDragNDrop } from '../FileDragNDropProvider/FileDragNDropProvider
|
||||
type Props = {
|
||||
note: SNNote
|
||||
linkingController: LinkingController
|
||||
filesController: FilesController
|
||||
noteViewElement: HTMLElement | null
|
||||
}
|
||||
|
||||
const NoteViewFileDropTarget = ({ note, linkingController, noteViewElement }: Props) => {
|
||||
const NoteViewFileDropTarget = ({ note, linkingController, noteViewElement, filesController }: Props) => {
|
||||
const { isDraggingFiles, addDragTarget, removeDragTarget } = useFileDragNDrop()
|
||||
|
||||
useEffect(() => {
|
||||
@@ -21,6 +23,7 @@ const NoteViewFileDropTarget = ({ note, linkingController, noteViewElement }: Pr
|
||||
callback: (files) => {
|
||||
files.forEach(async (uploadedFile) => {
|
||||
await linkingController.linkItems(note, uploadedFile)
|
||||
filesController.notifyObserversOfUploadedFileLinkingToCurrentNote(uploadedFile.uuid)
|
||||
})
|
||||
},
|
||||
})
|
||||
@@ -31,7 +34,7 @@ const NoteViewFileDropTarget = ({ note, linkingController, noteViewElement }: Pr
|
||||
removeDragTarget(target)
|
||||
}
|
||||
}
|
||||
}, [addDragTarget, linkingController, note, noteViewElement, removeDragTarget])
|
||||
}, [addDragTarget, linkingController, note, noteViewElement, removeDragTarget, filesController])
|
||||
|
||||
return isDraggingFiles ? (
|
||||
// Required to block drag events to editor iframe
|
||||
|
||||
Reference in New Issue
Block a user