Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fixed issue with third party editors not loading #2174

Merged
merged 4 commits into from Jan 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion packages/features/src/Domain/Component/NoteType.spec.ts
Expand Up @@ -5,7 +5,6 @@ describe('note type', () => {
it('should return the correct note type for editor identifier', () => {
expect(noteTypeForEditorIdentifier(FeatureIdentifier.PlainEditor)).toEqual(NoteType.Plain)
expect(noteTypeForEditorIdentifier(FeatureIdentifier.SuperEditor)).toEqual(NoteType.Super)
expect(noteTypeForEditorIdentifier(FeatureIdentifier.MarkdownVisualEditor)).toEqual(NoteType.Markdown)
expect(noteTypeForEditorIdentifier(FeatureIdentifier.MarkdownProEditor)).toEqual(NoteType.Markdown)
expect(noteTypeForEditorIdentifier(FeatureIdentifier.PlusEditor)).toEqual(NoteType.RichText)
expect(noteTypeForEditorIdentifier(FeatureIdentifier.CodeEditor)).toEqual(NoteType.Code)
Expand Down
2 changes: 1 addition & 1 deletion packages/features/src/Domain/Feature/FeatureIdentifier.ts
Expand Up @@ -30,12 +30,12 @@ export enum FeatureIdentifier {

CodeEditor = 'org.standardnotes.code-editor',
MarkdownProEditor = 'org.standardnotes.advanced-markdown-editor',
MarkdownVisualEditor = 'org.standardnotes.markdown-visual-editor',
PlusEditor = 'org.standardnotes.plus-editor',
SheetsEditor = 'org.standardnotes.standard-sheets',
TaskEditor = 'org.standardnotes.simple-task-editor',
TokenVaultEditor = 'org.standardnotes.token-vault',

DeprecatedMarkdownVisualEditor = 'org.standardnotes.markdown-visual-editor',
DeprecatedBoldEditor = 'org.standardnotes.bold-editor',
DeprecatedMarkdownBasicEditor = 'org.standardnotes.simple-markdown-editor',
DeprecatedMarkdownMathEditor = 'org.standardnotes.fancy-markdown-editor',
Expand Down
17 changes: 16 additions & 1 deletion packages/features/src/Domain/Lists/DeprecatedFeatures.ts
Expand Up @@ -55,6 +55,21 @@ export function GetDeprecatedFeatures(): FeatureDescription[] {
availableInRoles: [RoleName.NAMES.PlusUser, RoleName.NAMES.ProUser],
})

const markdownAlt: EditorFeatureDescription = FillEditorComponentDefaults({
availableInSubscriptions: [SubscriptionName.PlusPlan, SubscriptionName.ProPlan],
name: 'Markdown Alternative',
identifier: FeatureIdentifier.DeprecatedMarkdownVisualEditor,
note_type: NoteType.Markdown,
file_type: 'md',
deprecated: true,
permission_name: PermissionName.MarkdownVisualEditor,
spellcheckControl: true,
description:
'A WYSIWYG-style Markdown editor that renders Markdown in preview-mode while you type without displaying any syntax.',
index_path: 'build/index.html',
availableInRoles: [RoleName.NAMES.PlusUser, RoleName.NAMES.ProUser],
})

const markdownMinimist: EditorFeatureDescription = FillEditorComponentDefaults({
availableInSubscriptions: [SubscriptionName.PlusPlan, SubscriptionName.ProPlan],
name: 'Minimal Markdown',
Expand Down Expand Up @@ -112,5 +127,5 @@ export function GetDeprecatedFeatures(): FeatureDescription[] {
availableInRoles: [RoleName.NAMES.PlusUser, RoleName.NAMES.ProUser],
})

return [bold, markdownBasic, markdownMinimist, markdownMath, filesafe]
return [bold, markdownBasic, markdownMinimist, markdownMath, markdownAlt, filesafe]
}
16 changes: 1 addition & 15 deletions packages/features/src/Domain/Lists/Editors.ts
Expand Up @@ -52,20 +52,6 @@ export function editors(): EditorFeatureDescription[] {
availableInRoles: [RoleName.NAMES.PlusUser, RoleName.NAMES.ProUser],
})

const markdownAlt: EditorFeatureDescription = FillEditorComponentDefaults({
availableInSubscriptions: [SubscriptionName.PlusPlan, SubscriptionName.ProPlan],
name: 'Markdown Alternative',
identifier: FeatureIdentifier.MarkdownVisualEditor,
note_type: NoteType.Markdown,
file_type: 'md',
permission_name: PermissionName.MarkdownVisualEditor,
spellcheckControl: true,
description:
'A WYSIWYG-style Markdown editor that renders Markdown in preview-mode while you type without displaying any syntax.',
index_path: 'build/index.html',
availableInRoles: [RoleName.NAMES.PlusUser, RoleName.NAMES.ProUser],
})

const task: EditorFeatureDescription = FillEditorComponentDefaults({
availableInSubscriptions: [SubscriptionName.PlusPlan, SubscriptionName.ProPlan],
name: 'Checklist',
Expand Down Expand Up @@ -109,5 +95,5 @@ export function editors(): EditorFeatureDescription[] {
availableInRoles: [RoleName.NAMES.PlusUser, RoleName.NAMES.ProUser],
})

return [code, plus, markdown, markdownAlt, task, tokenvault, spreadsheets]
return [code, plus, markdown, task, tokenvault, spreadsheets]
}
Expand Up @@ -68,7 +68,7 @@ describe('component model', () => {
expect(component.noteType).toEqual(NoteType.Authentication)
})

it('should return plain as noteType if no note type defined in package_info', () => {
it('should return unknown as noteType if no note type defined in package_info', () => {
const component = new SNComponent(
new DecryptedPayload(
{
Expand All @@ -83,6 +83,6 @@ describe('component model', () => {
),
)

expect(component.noteType).toEqual(NoteType.Plain)
expect(component.noteType).toEqual(NoteType.Unknown)
})
})
2 changes: 1 addition & 1 deletion packages/models/src/Domain/Syncable/Component/Component.ts
Expand Up @@ -180,7 +180,7 @@ export class SNComponent extends DecryptedItem<ComponentContent> implements Comp
}

public get noteType(): NoteType {
return this.package_info.note_type || NoteType.Plain
return this.package_info.note_type || NoteType.Unknown
}

public get isDeprecated(): boolean {
Expand Down
Expand Up @@ -147,7 +147,7 @@ describe('featuresService', () => {

const manager = createManager(Environment.Desktop, Platform.MacDesktop)
expect(
manager.areRequestedPermissionsValid(nativeComponent(FeatureIdentifier.MarkdownVisualEditor), permissions),
manager.areRequestedPermissionsValid(nativeComponent(FeatureIdentifier.MarkdownProEditor), permissions),
).toEqual(true)
})

Expand Down
Expand Up @@ -4,6 +4,9 @@ import { IconType } from '@standardnotes/models'

export function getIconAndTintForNoteType(noteType?: NoteType, subtle?: boolean): [IconType, number] {
switch (noteType) {
case undefined:
case NoteType.Plain:
return [PlainEditorMetadata.icon, PlainEditorMetadata.iconTintNumber]
case NoteType.RichText:
return ['rich-text', 1]
case NoteType.Markdown:
Expand All @@ -21,7 +24,8 @@ export function getIconAndTintForNoteType(noteType?: NoteType, subtle?: boolean)
subtle ? (SuperEditorMetadata.subtleIcon as IconType) : SuperEditorMetadata.icon,
SuperEditorMetadata.iconTintNumber,
]
case NoteType.Unknown:
default:
return [PlainEditorMetadata.icon, PlainEditorMetadata.iconTintNumber]
return ['editor', PlainEditorMetadata.iconTintNumber]
}
}