fix: Fixes issue where selecting a third-party editor/note-type as default for a tag would not correctly apply editor
This commit is contained in:
@@ -31,6 +31,7 @@ export interface ComponentManagerInterface {
|
|||||||
|
|
||||||
setPermissionDialogUIHandler(handler: (dialog: PermissionDialog) => void): void
|
setPermissionDialogUIHandler(handler: (dialog: PermissionDialog) => void): void
|
||||||
|
|
||||||
|
findComponentWithPackageIdentifier(identifier: string): ComponentInterface | undefined
|
||||||
editorForNote(note: SNNote): UIFeature<EditorFeatureDescription | IframeComponentFeatureDescription>
|
editorForNote(note: SNNote): UIFeature<EditorFeatureDescription | IframeComponentFeatureDescription>
|
||||||
getDefaultEditorIdentifier(currentTag?: SNTag): string
|
getDefaultEditorIdentifier(currentTag?: SNTag): string
|
||||||
|
|
||||||
|
|||||||
@@ -358,6 +358,12 @@ export class SNComponentManager
|
|||||||
return this.viewers.find((viewer) => viewer.identifier === identifier)
|
return this.viewers.find((viewer) => viewer.identifier === identifier)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public findComponentWithPackageIdentifier(identifier: string): ComponentInterface | undefined {
|
||||||
|
return this.items.getDisplayableComponents().find((component) => {
|
||||||
|
return component.identifier === identifier
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
private componentViewerForSessionKey(key: string): ComponentViewerInterface | undefined {
|
private componentViewerForSessionKey(key: string): ComponentViewerInterface | undefined {
|
||||||
return this.viewers.find((viewer) => viewer.sessionKey === key)
|
return this.viewers.find((viewer) => viewer.sessionKey === key)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -119,12 +119,23 @@ const NewNotePreferences: FunctionComponent<Props> = ({
|
|||||||
|
|
||||||
const selectEditorForNewNoteDefault = useCallback(
|
const selectEditorForNewNoteDefault = useCallback(
|
||||||
(value: EditorOption['value']) => {
|
(value: EditorOption['value']) => {
|
||||||
const uuid = Uuid.create(value)
|
let identifier: NativeFeatureIdentifier | Uuid | undefined = undefined
|
||||||
|
|
||||||
const feature = NativeFeatureIdentifier.create(value)
|
const feature = NativeFeatureIdentifier.create(value)
|
||||||
if (
|
if (!feature.isFailed()) {
|
||||||
application.features.getFeatureStatus(!uuid.isFailed() ? uuid.getValue() : feature.getValue()) !==
|
identifier = feature.getValue()
|
||||||
FeatureStatus.Entitled
|
} else {
|
||||||
) {
|
const thirdPartyEditor = application.componentManager.findComponentWithPackageIdentifier(value)
|
||||||
|
if (thirdPartyEditor) {
|
||||||
|
identifier = Uuid.create(thirdPartyEditor.uuid).getValue()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!identifier) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (application.features.getFeatureStatus(identifier) !== FeatureStatus.Entitled) {
|
||||||
const editorItem = editorItems.find((item) => item.value === value)
|
const editorItem = editorItems.find((item) => item.value === value)
|
||||||
if (editorItem) {
|
if (editorItem) {
|
||||||
premiumModal.activate(editorItem.label)
|
premiumModal.activate(editorItem.label)
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ export function getDropdownItemsForAllEditors(application: WebApplicationInterfa
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
label: editor.displayName,
|
label: editor.displayName,
|
||||||
value: editor.uuid,
|
value: editor.identifier,
|
||||||
...(iconType ? { icon: iconType } : null),
|
...(iconType ? { icon: iconType } : null),
|
||||||
...(tint ? { iconClassName: `text-accessory-tint-${tint}` } : null),
|
...(tint ? { iconClassName: `text-accessory-tint-${tint}` } : null),
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user