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

MultiRootEditor Non Existent Root Error on getData() #549

Open
amankapur opened this issue Oct 28, 2024 · 0 comments
Open

MultiRootEditor Non Existent Root Error on getData() #549

amankapur opened this issue Oct 28, 2024 · 0 comments

Comments

@amankapur
Copy link

Trying to follow the official guide https://ckeditor.com/docs/ckeditor5/latest/getting-started/installation/react/react-multiroot.html with two way binding disabled to have a controlled component.

However, on trying to access the data via getData() function on the editor instance, I get datacontroller-get-non-existent-root error.

import { useMultiRootEditor } from '@ckeditor/ckeditor5-react';
import 'ckeditor5/ckeditor5.css';

import {
	MultiRootEditor,
	AccessibilityHelp,
	Alignment,
	Autosave,
	Bold,
	Essentials,
	FindAndReplace,
	FontFamily,
	FontSize,
	GeneralHtmlSupport,
	HorizontalLine,
	ImageBlock,
	ImageInline,
	ImageResize,
	ImageStyle,
	ImageToolbar,
	ImageUpload,
	Indent,
	IndentBlock,
	Italic,
	List,
	ListProperties,
	Paragraph,
	PasteFromOffice,
	SelectAll,
	SourceEditing,
	SpecialCharacters,
	SpecialCharactersArrows,
	SpecialCharactersCurrency,
	SpecialCharactersEssentials,
	SpecialCharactersLatin,
	SpecialCharactersMathematical,
	SpecialCharactersText,
	Strikethrough,
	Subscript,
	Superscript,
	Table,
	TableCaption,
	TableCellProperties,
	TableColumnResize,
	TableProperties,
	TableToolbar,
	Underline,
	Undo
} from 'ckeditor5';

export default function EditorBox({data, onChange}) {

	const editorConfig = {
		toolbar: {
			items: [
				'undo',
				'redo',
				'|',
				'sourceEditing',
				'findAndReplace',
				'|',
				'fontSize',
				'fontFamily',
				'|',
				'bold',
				'italic',
				'underline',
				'strikethrough',
				'subscript',
				'superscript',
				'|',
				'specialCharacters',
				'horizontalLine',
				'insertTable',
				'|',
				'alignment',
				'|',
				'bulletedList',
				'numberedList',
				'outdent',
				'indent',
			],
			shouldNotGroupWhenFull: true
		},
		plugins: [
			AccessibilityHelp,
			Alignment,
			Autosave,
			Bold,
			Essentials,
			FindAndReplace,
			FontFamily,
			FontSize,
			GeneralHtmlSupport,
			HorizontalLine,
			ImageBlock,
			ImageInline,
			ImageResize,
			ImageStyle,
			ImageToolbar,
			ImageUpload,
			Indent,
			IndentBlock,
			Italic,
			List,
			ListProperties,
			Paragraph,
			PasteFromOffice,
			SelectAll,
			SourceEditing,
			SpecialCharacters,
			SpecialCharactersArrows,
			SpecialCharactersCurrency,
			SpecialCharactersEssentials,
			SpecialCharactersLatin,
			SpecialCharactersMathematical,
			SpecialCharactersText,
			Strikethrough,
			Subscript,
			Superscript,
			Table,
			TableCaption,
			TableCellProperties,
			TableColumnResize,
			TableProperties,
			TableToolbar,
			Underline,
			Undo
		],
		fontFamily: {
			supportAllValues: true
		},
		fontSize: {
			options: [10, 12, 14, 'default', 18, 20, 22],
			supportAllValues: true
		},
		htmlSupport: {
			allow: [
				{
					name: /^.*$/,
					styles: true,
					attributes: true,
					classes: true
				}
			]
		},
		image: {
			toolbar: ['imageTextAlternative', '|', 'imageStyle:inline', 'imageStyle:wrapText', 'imageStyle:breakText', '|', 'resizeImage']
		},
		list: {
			properties: {
				styles: true,
				startIndex: true,
				reversed: true
			}
		},
		// placeholder: 'Type or paste your content here!',
		table: {
			contentToolbar: ['tableColumn', 'tableRow', 'mergeTableCells', 'tableProperties', 'tableCellProperties']
		}
	};

	const editorProps = {
		editor: MultiRootEditor,
		data,
		config: editorConfig,
		disableTwoWayDataBinding: true,
		onChange: (event, editor) =>  {onChange(editor.getData())},
	}
	const {
		toolbarElement,
		editableElements
	} = useMultiRootEditor(editorProps);



	return (
		<div>
			{toolbarElement }
			{editableElements}
		</div>
	);
}


Error as follows:

CKEditorError: datacontroller-get-non-existent-root
Read more: https://ckeditor.com/docs/ckeditor5/latest/support/error-codes.html#error-datacontroller-get-non-existent-root
    at DataController.get (ckeditor5.js?v=656b2241:33234:13)
    at DataController.<anonymous> (ckeditor5.js?v=656b2241:10111:37)
    at DataController.fire (ckeditor5.js?v=656b2241:9769:35)
    at <computed> [as get] (ckeditor5.js?v=656b2241:10114:21)
    at MultiRootEditor.getData (ckeditor5.js?v=656b2241:46639:22)
    at Object.onChange (EditorBox.jsx?t=1730107742558:186:23)
...

Versions:

├── @ckeditor/[email protected]
├── [email protected]
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

No branches or pull requests

1 participant