-
-
Notifications
You must be signed in to change notification settings - Fork 392
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: note editor relationships (#1821)
- Loading branch information
Showing
28 changed files
with
357 additions
and
299 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,15 @@ | ||
import { FeatureIdentifier, NoteType } from '@standardnotes/features' | ||
import { ItemContent } from '../../Abstract/Content/ItemContent' | ||
|
||
export interface NoteContentSpecialized { | ||
title: string | ||
text: string | ||
mobilePrefersPlainEditor?: boolean | ||
hidePreview?: boolean | ||
preview_plain?: string | ||
preview_html?: string | ||
spellcheck?: boolean | ||
noteType?: NoteType | ||
editorIdentifier?: FeatureIdentifier | string | ||
} | ||
|
||
export type NoteContent = NoteContentSpecialized & ItemContent |
24 changes: 24 additions & 0 deletions
24
packages/models/src/Domain/Syncable/Note/NoteMutator.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { NoteMutator } from './NoteMutator' | ||
import { createNote } from './../../Utilities/Test/SpecUtils' | ||
import { MutationType } from '../../Abstract/Item' | ||
import { FeatureIdentifier, NoteType } from '@standardnotes/features' | ||
|
||
describe('note mutator', () => { | ||
it('sets noteType', () => { | ||
const note = createNote({}) | ||
const mutator = new NoteMutator(note, MutationType.NoUpdateUserTimestamps) | ||
mutator.noteType = NoteType.Authentication | ||
const result = mutator.getResult() | ||
|
||
expect(result.content.noteType).toEqual(NoteType.Authentication) | ||
}) | ||
|
||
it('sets editorIdentifier', () => { | ||
const note = createNote({}) | ||
const mutator = new NoteMutator(note, MutationType.NoUpdateUserTimestamps) | ||
mutator.editorIdentifier = FeatureIdentifier.MarkdownProEditor | ||
const result = mutator.getResult() | ||
|
||
expect(result.content.editorIdentifier).toEqual(FeatureIdentifier.MarkdownProEditor) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 0 additions & 55 deletions
55
packages/models/src/Domain/Utilities/Payload/AffectorFunction.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { SNApplication } from './../Application/Application' | ||
import { ContentType } from '@standardnotes/common' | ||
import { MutatorService } from './../Services/Mutator/MutatorService' | ||
import { SNComponentManager } from './../Services/ComponentManager/ComponentManager' | ||
import { NoteType } from '@standardnotes/features' | ||
import { NoteViewController } from './NoteViewController' | ||
|
||
describe('note view controller', () => { | ||
let application: SNApplication | ||
|
||
beforeEach(() => { | ||
application = {} as jest.Mocked<SNApplication> | ||
application.streamItems = jest.fn() | ||
|
||
const componentManager = {} as jest.Mocked<SNComponentManager> | ||
componentManager.getDefaultEditor = jest.fn() | ||
Object.defineProperty(application, 'componentManager', { value: componentManager }) | ||
|
||
const mutator = {} as jest.Mocked<MutatorService> | ||
mutator.createTemplateItem = jest.fn() | ||
Object.defineProperty(application, 'mutator', { value: mutator }) | ||
}) | ||
|
||
it('should create notes with plaintext note type', async () => { | ||
const controller = new NoteViewController(application) | ||
await controller.initialize(false) | ||
|
||
expect(application.mutator.createTemplateItem).toHaveBeenCalledWith( | ||
ContentType.Note, | ||
expect.objectContaining({ noteType: NoteType.Plain }), | ||
) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.