1

Until now I have used CKEditor 4 with their drag and drop solution of contacts. It works fine. Now I have added the CKEditor 5 to my Angular 2+ solution. The editor is up and running, but I cant't wrap my head around how to get the Widget/Hcard (drag and drop) thing to work with angular and ckeditor 5.

I have spent a lot of time trying to figure this out and really need some help getting this to work.

This is their example site with the drag and drop: https://ckeditor.com/docs/ckeditor5/latest/features/drag-drop.html

If anyone is able to recreate this example page as an Angular soulution in stackblitz, or similar, to show that it is actually possible to make their example of dragging and dropping contacts work, I would be forever grateful.

5
  • what is your angular version? Commented Nov 4, 2024 at 11:21
  • @NarenMurali I use angular version 16 and @ckeditor/ckeditor5-angular version 8
    – TommyF
    Commented Nov 4, 2024 at 16:04
  • 4
    You're welcome stackblitz.com/edit/stackblitz-starters-bv8xtw
    – yurzui
    Commented Nov 21, 2024 at 17:05
  • 1
    Omg. @yurzui. You are the man! Thank you so much!
    – TommyF
    Commented Nov 22, 2024 at 14:50
  • @yurzui If you add your comment as an answer I can grant you the bounty
    – TommyF
    Commented Nov 27, 2024 at 17:38

1 Answer 1

1
+50

In order to reuse this feature in Angular project you need to make sure to use import from ckeditor5 instead of @ckeditor/* imports.

Then you need to convert hcard.js from example to hcard.ts and assign this plugin to buildInPlugins

import {
  ClassicEditor as ClassicEditorBase,
} from 'ckeditor5';
import { HCardEditing } from './hcard';

...
export class ClassicEditor extends ClassicEditorBase {
  static override builtinPlugins = [...defaultPlugins, HCardEditing];

  static override defaultConfig = defaultConfig;
}

Finally, in editor component you need to use this extended ClassicEditor:

component.ts

export class AppComponent {
  public Editor = ClassicEditor;

template.html

<ckeditor [editor]="Editor" [data]="html"></ckeditor>

Stackblitz Example

1
  • Thanks again, man! Really appreciate it.
    – TommyF
    Commented Nov 27, 2024 at 22:14

Not the answer you're looking for? Browse other questions tagged or ask your own question.