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

data prop is not available for ckeditor #567

Closed
MohannedAbuzant opened this issue Jan 6, 2025 · 5 comments · Fixed by #571
Closed

data prop is not available for ckeditor #567

MohannedAbuzant opened this issue Jan 6, 2025 · 5 comments · Fixed by #571
Milestone

Comments

@MohannedAbuzant
Copy link

Code:

import {ClassicEditor, EventInfo} from 'ckeditor5';
import React, {ReactNode} from 'react';
import {CKEditor} from '@ckeditor/ckeditor5-react';
import 'ckeditor5/ckeditor5.css';


function EditorComponent({
	value,
	schema,
	onChange
}: {
	value: string;
	schema: IEditor;
	onChange?: React.Dispatch<React.SetStateAction<{value: string}>>;
}): ReactNode {
	
	const handleOnChange = (_: EventInfo, editor: ClassicEditor) => {
		if (onChange) {
			onChange({value: editor.getData()});
		}
	};

	return (
		<>
			{schema.label && (
				<Text className={classes.label}>
					{schema.label}
					{isRequired && (
						<Text c="var(--mantine-color-error)" span ms="xs">
							*
						</Text>
					)}
				</Text>
			)}

			<CKEditor
				onChange={handleOnChange}
				editor={ClassicEditor}
				config={{
					licenseKey: 'GPL',
					// extraPlugins: [uploadPlugin], //Will import again when need Media
					toolbar: schema?.toolbar
						? schema?.toolbar
						: EditorDefaultSchema,
					plugins: EditorDefaultPluginsSchema,
					...(locale === LANGUAGES?.ar?.abbreviation && {
						translations: coreTranslations,
						language: {
							ui: 'ar'
						}
					})
				}}
				data={value}
			></CKEditor>
			<Text c={LAYOUT_COLORS.DANGER_COLOR}>{error}</Text>
		</>
	);
}

export default JbEditorComponent;

Problem:
data is not assignable to type
IntrinsicAttributes & IntrinsicClassAttributes<CKEditor> & Readonly<Props>
Property data does not exist on type
IntrinsicAttributes & IntrinsicClassAttributes<CKEditor> & Readonly<Props>

Versions:
"@types/react": "19.0.2",
"@types/react-dom": "19.0.2"
"next": "15.1.3",
"@ckeditor/ckeditor5-react": "^9.4.0",
"ckeditor5": "^44.1.0",

@jonaldinger
Copy link

I'm getting the same error after upgrading to React v19. Has anybody figured out a solution or workaround?

@Witoso
Copy link
Member

Witoso commented Feb 4, 2025

@Mati365 I think you tested that in the past. Any ideas?

@Mati365
Copy link
Member

Mati365 commented Feb 4, 2025

@Witoso I'll check that.

@Mati365
Copy link
Member

Mati365 commented Feb 4, 2025

Looks like Next.js struggles with resolving InferProps from prop-types within integration package. The problem is that it's already installed, and it works perfectly fine on Vite.

Mati365 added a commit that referenced this issue Feb 4, 2025
Fix: data prop is no longer unavailable in Next.js related integrations. Closes #567
Other: Remove prop-types from dependencies of package.
@CKEditorBot CKEditorBot added this to the iteration 83 milestone Feb 4, 2025
@jonaldinger
Copy link

Just wanted to follow up to confirm that the 9.5.0 release did solve my issue. Also note that I'm not using Next.js (just Vite + React 19), so the fix seems maybe even more broadly applicable than expected/intended 🙌. Thank you @Witoso and @Mati365!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants