Skip to content

Commit

Permalink
Rename property
Browse files Browse the repository at this point in the history
  • Loading branch information
Mati365 committed Aug 12, 2024
1 parent 610c901 commit 63eeb53
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 13 deletions.
8 changes: 4 additions & 4 deletions src/ckeditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -301,10 +301,10 @@ export default class CKEditor<TEditor extends Editor> extends React.Component<Pr
* @param config CKEditor 5 editor configuration.
*/
private _createEditor( element: HTMLElement | string | Record<string, string>, config: EditorConfig ): Promise<TEditor> {
const { context } = this.props;
const { contextItemMetadata } = this.props;

if ( context ) {
config = withCKEditorReactContextMetadata( context, config );
if ( contextItemMetadata ) {
config = withCKEditorReactContextMetadata( contextItemMetadata, config );
}

return this.props.editor.create( element as HTMLElement, config )
Expand Down Expand Up @@ -452,7 +452,7 @@ export interface Props<TEditor extends Editor> extends InferProps<typeof CKEdito
EditorWatchdog: typeof EditorWatchdog;
ContextWatchdog: typeof ContextWatchdog;
};
context?: CKEditorConfigContextMetadata;
contextItemMetadata?: CKEditorConfigContextMetadata;
config?: EditorConfig;
watchdogConfig?: WatchdogConfig;
disableWatchdog?: boolean;
Expand Down
2 changes: 1 addition & 1 deletion src/context/setCKEditorReactContextMetadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export type CKEditorConfigContextMetadata = {
* The name of the editor in the React context. It'll be later used in the `useInitializedCKEditorsMap` hook
* to track the editor initialization and destruction events.
*/
editorName: string;
name: string;

/**
* Any additional metadata that can be stored in the context.
Expand Down
2 changes: 1 addition & 1 deletion src/context/useInitializedCKEditorsMap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export const useInitializedCKEditorsMap = <TContext extends Context>(
}

const metadata = tryExtractCKEditorReactContextMetadata( editor.config );
const nameOrId = metadata?.editorName ?? editor.id;
const nameOrId = metadata?.name ?? editor.id;

map[ nameOrId ] = {
instance: editor,
Expand Down
16 changes: 9 additions & 7 deletions tests/context/ckeditorcontext.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ describe( '<CKEditorContext> Component', () => {
>
<CKEditor
editor={ ClassicEditor }
context={ { editorName: 'my-editor' } }
contextItemMetadata={ { name: 'my-editor' } }
/>
</CKEditorContext>
);
Expand All @@ -462,11 +462,11 @@ describe( '<CKEditorContext> Component', () => {
>
<CKEditor
editor={ ClassicEditor }
context={ { editorName: 'editor1' } }
contextItemMetadata={ { name: 'editor1' } }
/>
<CKEditor
editor={ ClassicEditor }
context={ { editorName: 'editor2' } }
contextItemMetadata={ { name: 'editor2' } }
/>
</CKEditorContext>
);
Expand All @@ -493,8 +493,8 @@ describe( '<CKEditorContext> Component', () => {
>
<CKEditor
editor={ ClassicEditor }
context={ {
editorName: 'editor1',
contextItemMetadata={ {
name: 'editor1',
stuff: 2
} }
/>
Expand All @@ -508,7 +508,7 @@ describe( '<CKEditorContext> Component', () => {
const editorId = 'editor1';

expect( editors[ editorId ].metadata ).to.deep.equal( {
editorName: 'editor1',
name: 'editor1',
stuff: 2
} );
} );
Expand All @@ -527,7 +527,9 @@ describe( '<CKEditorContext> Component', () => {
>
<CKEditor
editor={ ClassicEditor }
context={ { editorName: 'editor1' } }
contextItemMetadata={ {
name: 'editor1'
} }
/>
</CKEditorContext>
);
Expand Down

0 comments on commit 63eeb53

Please sign in to comment.