diff --git a/shared/js/text/bbcode/renderer.ts b/shared/js/text/bbcode/renderer.ts index afb73346..9dc1cc98 100644 --- a/shared/js/text/bbcode/renderer.ts +++ b/shared/js/text/bbcode/renderer.ts @@ -1,16 +1,29 @@ +import * as loader from "tc-loader"; +import {Stage} from "tc-loader"; + +import * as React from "react"; +import {Context} from "react"; + import TextRenderer from "vendor/xbbcode/renderer/text"; import ReactRenderer from "vendor/xbbcode/renderer/react"; import HTMLRenderer from "vendor/xbbcode/renderer/html"; -export const BBCodeHandlerContext = React.createContext(undefined); - -export const rendererText = new TextRenderer(); -export const rendererReact = new ReactRenderer(); -export const rendererHTML = new HTMLRenderer(rendererReact); - import "./emoji"; import "./highlight"; import "./youtube"; import "./url"; import "./image"; -import * as React from "react"; \ No newline at end of file + +export let BBCodeHandlerContext: Context; + +export const rendererText = new TextRenderer(); +export const rendererReact = new ReactRenderer(); +export const rendererHTML = new HTMLRenderer(rendererReact); + +loader.register_task(Stage.JAVASCRIPT_INITIALIZING, { + name: "BBCode handler context", + function: async () => { + BBCodeHandlerContext = React.createContext(undefined); + }, + priority: 80 +}) \ No newline at end of file