Skip to content

Commit

Permalink
Insert smiley in a widget
Browse files Browse the repository at this point in the history
  • Loading branch information
Cyperghost committed Oct 9, 2024
1 parent 980b6a0 commit 876ce8e
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions plugins/ckeditor5-woltlab-smiley/src/woltlabsmiley.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import type { DowncastInsertEvent } from "@ckeditor/ckeditor5-engine";
import { Image } from "@ckeditor/ckeditor5-image";

import "../theme/woltlabsmiley.css";
import { toWidget } from "@ckeditor/ckeditor5-widget";

export class WoltlabSmiley extends Plugin {
static get pluginName() {
Expand Down Expand Up @@ -69,13 +70,20 @@ export class WoltlabSmiley extends Plugin {
consumable.consume(item, "insert");

const image = writer.createEmptyElement("img");
const container = writer.createContainerElement(
"span",
{ class: "image-inline" },
image,
);
writer.setAttribute("translate", "no", image);
const position = mapper.toViewPosition(
this.editor.model.createPositionBefore(item),
);
writer.insert(position, image);
toWidget(container, writer);

writer.insert(position, container);

mapper.bindElements(item, image);
mapper.bindElements(item, container);
},
{ priority: "high" },
);
Expand Down

0 comments on commit 876ce8e

Please sign in to comment.