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

Placeholder error with viewWriter #5

Closed
martonflori opened this issue Oct 6, 2020 · 1 comment
Closed

Placeholder error with viewWriter #5

martonflori opened this issue Oct 6, 2020 · 1 comment

Comments

@martonflori
Copy link

martonflori commented Oct 6, 2020

Hi there,

I have ran into an issue implementing the placeholder for ckeditor, I'd appreciate a little help.
It's built with webpack, some of the imports I've dotted out for readability, the code is below:

import ClassicEditor from '@ckeditor/ckeditor5-editor-classic/src/classiceditor.js';
import Placeholder from 'ckeditor5-placeholder';
...

export const createEditor = async (selector) => {
	let ckEditor;
	await ClassicEditor
		.create(document.querySelector(selector), {
			plugins: [
				... ,
				Placeholder
			],
			toolbar: [
                                ... ,
				'placeholder'
			],
			extraPlugins: [customUploadAdapterPlugin]
		})
		.then(editor => {
			console.log('Editor initialized');
			ckEditor = editor;
		})
		.catch(error => {
			console.error(error.stack);
		});
	return ckEditor;
}

Then later I'm using it like this:

        const ckEditor = await import('../../../lib/ckeditor/ckeditor-webpack.js');
        const editor = await ckEditor.createEditor('#content');

And the error I'm getting when clicking on the placeholder prop: Uncaught TypeError: viewWriter.createContainerElement is not a function

error
Does anyone have an idea what could cause this?

Thanks in advance!

@martonx
Copy link
Contributor

martonx commented Oct 6, 2020

Hey, there is a bug in the code, at least with latest version of CkEditor 5.

In placeholderediting.js, you should add .writer to viewWriter. This is the fixed version

#6 here you are, my PR with fixed code.

martonx added a commit to martonx/ckeditor5-placeholder that referenced this issue Oct 6, 2020
PavolC added a commit to PavolC/ckeditor5-placeholder that referenced this issue Jan 13, 2021
Updated to bring in line with ckeditor docs
PavolC added a commit to PavolC/ckeditor5-placeholder that referenced this issue Jan 14, 2021
Fix for issue kiruh#5 since it was still happening.
@kiruh kiruh closed this as completed Mar 15, 2021
@kiruh kiruh reopened this Mar 15, 2021
@kiruh kiruh closed this as completed Mar 16, 2021
kiruh added a commit that referenced this issue Jul 2, 2021
Fix for issue #5 since it was still happening.
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

3 participants