{event name='wysiwyg'}
+<script data-eager="true">
+{
+ let stylesheet = document.getElementById("ckeditor5-stylesheet");
+ if (stylesheet === null) {
+ stylesheet = document.createElement("link");
+ stylesheet.rel = "stylesheet";
+ stylesheet.type = "text/css";
+ stylesheet.href = "{$__wcf->getPath()}style/ckeditor5.css";
+ stylesheet.id = "ckeditor5-stylesheet";
+
+ document.head.append(stylesheet);
+ }
+}
+</script>
<script data-relocate="true">
require([
"WoltLabSuite/Core/Component/Ckeditor",
return configuration;
}
-const stylesheetId = "ckeditor5-stylesheet";
-function injectCss(): HTMLLinkElement | null {
- let stylesheet = document.getElementById(stylesheetId) as HTMLLinkElement | null;
- if (stylesheet !== null) {
- return null;
- }
-
- 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);
-
- return stylesheet;
-}
-
export async function setupCkeditor(
element: HTMLElement,
features: Features,
setupLayer();
- const injectedStylesheet = injectCss();
-
- await Promise.all([
- new Promise<void>((resolve) => {
- if (injectedStylesheet === null) {
- resolve();
- } else {
- injectedStylesheet.addEventListener("load", () => {
- resolve();
- });
- }
- }),
- import("ckeditor5-bundle"),
- ]);
+ await import("ckeditor5-bundle");
await new Promise((resolve) => {
window.requestAnimationFrame(resolve);
{event name='wysiwyg'}
+<script data-eager="true">
+{
+ let stylesheet = document.getElementById("ckeditor5-stylesheet");
+ if (stylesheet === null) {
+ stylesheet = document.createElement("link");
+ stylesheet.rel = "stylesheet";
+ stylesheet.type = "text/css";
+ stylesheet.href = "{$__wcf->getPath()}style/ckeditor5.css";
+ stylesheet.id = "ckeditor5-stylesheet";
+
+ document.head.append(stylesheet);
+ }
+}
+</script>
<script data-relocate="true">
require([
"WoltLabSuite/Core/Component/Ckeditor",
}
return configuration;
}
- const stylesheetId = "ckeditor5-stylesheet";
- function injectCss() {
- let stylesheet = document.getElementById(stylesheetId);
- if (stylesheet !== null) {
- return null;
- }
- 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);
- return stylesheet;
- }
async function setupCkeditor(element, features, bbcodes, codeBlockLanguages) {
if (instances.has(element)) {
throw new TypeError(`Cannot initialize the editor for '${element.id}' twice.`);
}
(0, Layer_1.setup)();
- const injectedStylesheet = injectCss();
- await Promise.all([
- new Promise((resolve) => {
- if (injectedStylesheet === null) {
- resolve();
- }
- else {
- injectedStylesheet.addEventListener("load", () => {
- resolve();
- });
- }
- }),
- new Promise((resolve_1, reject_1) => { require(["ckeditor5-bundle"], resolve_1, reject_1); }).then(tslib_1.__importStar),
- ]);
+ await new Promise((resolve_1, reject_1) => { require(["ckeditor5-bundle"], resolve_1, reject_1); }).then(tslib_1.__importStar);
await new Promise((resolve) => {
window.requestAnimationFrame(resolve);
});