Skip to content

Commit

Permalink
Extract the CKEditor 5 styles into a static stylesheet
Browse files Browse the repository at this point in the history
  • Loading branch information
dtdesign committed Aug 4, 2023
1 parent 33c9fc4 commit 5300596
Show file tree
Hide file tree
Showing 4 changed files with 110 additions and 1 deletion.
17 changes: 17 additions & 0 deletions ts/WoltLabSuite/Core/Component/Ckeditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,21 @@ function initializeConfiguration(
return configuration;
}

const stylesheetId = "ckeditor5-stylesheet";
function injectCss(): void {
if (document.getElementById(stylesheetId) !== null) {
return;
}

const stylesheet = document.createElement("link");
stylesheet.rel = "stylesheet";
stylesheet.type = "text/css";
stylesheet.href = `${window.WSC_API_URL}style/ckeditor5.css`;
stylesheet.id = stylesheetId;

document.head.append(stylesheet);
}

export async function setupCkeditor(
element: HTMLElement,
features: Features,
Expand All @@ -220,6 +235,8 @@ export async function setupCkeditor(
throw new TypeError(`Cannot initialize the editor for '${element.id}' twice.`);
}

injectCss();

await import("ckeditor5-bundle");

await new Promise((resolve) => {
Expand Down

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions wcfsetup/install/files/js/WoltLabSuite/Core/Component/Ckeditor.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 5300596

Please sign in to comment.