Skip to content

Commit

Permalink
INT-3308_2: Put back support for any unknown key to be assigned as an…
Browse files Browse the repository at this point in the history
… init prop (#532)

* INT-3308_2: Any other string key is typed as any again and don't export EditorOptions

* INT-3308_2: Added a test for unknown other `init` props
  • Loading branch information
danoaky-tiny authored May 28, 2024
1 parent d822088 commit f35497d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/main/ts/components/Editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ interface DoNotUse<T extends string> {

type OmittedInitProps = 'selector' | 'target' | 'readonly' | 'license_key';

export type EditorOptions = Parameters<TinyMCE['init']>[0];
type EditorOptions = Parameters<TinyMCE['init']>[0];

export type InitOptions = Omit<OmitStringIndexSignature<EditorOptions>, OmittedInitProps> & {
selector?: DoNotUse<'selector prop is handled internally by the component'>;
target?: DoNotUse<'target prop is handled internally by the component'>;
readonly?: DoNotUse<'readonly prop is overridden by the component, use the `disabled` prop instead'>;
license_key?: DoNotUse<'license_key prop is overridden by the integration, use the `licenseKey` prop instead'>;
};
} & { [key: string]: unknown };

export type Version = `${'4' | '5' | '6' | '7'}${'' | '-dev' | '-testing' | `.${number}` | `.${number}.${number}`}`;

Expand Down
22 changes: 22 additions & 0 deletions src/test/ts/browser/EditorInitTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,28 @@ describe('EditorInitTest', () => {
}
});
});

it('Assigning other unknown props to the editor is allowed', async () => {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
using _ = await render({
init: {
mergetags_list: [{
title: 'Client',
menu: [
{
value: 'Client.LastCallDate',
title: 'Call date'
},
{
value: 'Client.Name',
title: 'Client name'
}
]
}],
something_else: 'value'
}
});
});
})
);
});

0 comments on commit f35497d

Please sign in to comment.