diff --git a/apps/scandic-web/components/JsonToHtml/renderOptions.tsx b/apps/scandic-web/components/JsonToHtml/renderOptions.tsx
index a5c7f10f0..ab36570f6 100644
--- a/apps/scandic-web/components/JsonToHtml/renderOptions.tsx
+++ b/apps/scandic-web/components/JsonToHtml/renderOptions.tsx
@@ -336,6 +336,28 @@ export const renderOptions: RenderOptions = {
{next(node.children, embeds, fullRenderOptions)}
)
},
+ [RTETypeEnum.div]: (
+ node: RTEDefaultNode,
+ embeds: EmbedByUid,
+ next: RTENext,
+ fullRenderOptions: RenderOptions
+ ) => {
+ let props = extractPossibleAttributes(node.attrs)
+ const className = props.className
+
+ if (className) {
+ if (hasAvailableULFormat(className)) {
+ // @ts-ignore: We want to set css modules classNames even if it does not correspond
+ // to an existing class in the module style sheet. Due to our css modules plugin for
+ // typescript, we cannot do this without the ts-ignore
+ props.className = styles[className]
+ }
+ }
+
+ return (
+
{next(node.children, embeds, fullRenderOptions)}
+ )
+ },
[RTETypeEnum.reference]: (
node: RTENode,
diff --git a/apps/scandic-web/components/JsonToHtml/utils.tsx b/apps/scandic-web/components/JsonToHtml/utils.tsx
index c3748a2fb..c7786c37e 100644
--- a/apps/scandic-web/components/JsonToHtml/utils.tsx
+++ b/apps/scandic-web/components/JsonToHtml/utils.tsx
@@ -122,16 +122,13 @@ export function nodeToHtml(
if ("type" in node === false) {
return textNodeToHtml(node, fullRenderOptions)
} else {
- if (fullRenderOptions[node.type] !== undefined) {
+ const renderer = fullRenderOptions[node.type] as RTERenderOptionComponent
+ if (renderer) {
if (node.type === RTETypeEnum.doc) {
return null
}
- return (fullRenderOptions[node.type] as RTERenderOptionComponent)(
- node,
- embeds,
- next,
- fullRenderOptions
- )
+
+ return renderer(node, embeds, next, fullRenderOptions)
} else {
return next(node.children, embeds, fullRenderOptions)
}
@@ -152,11 +149,16 @@ export function nodesToHtml(
) {
const embeds = groupEmbedsByUid(embedsArray)
const fullRenderOptions = { ...renderOptions, ...overrideRenderOptions }
- return nodes.map((node, index) => (
-
- {nodeToHtml(node, embeds, fullRenderOptions)}
-
- ))
+
+ return nodes.map((node, index) => {
+ const nodeHtml = nodeToHtml(node, embeds, fullRenderOptions)
+
+ return (
+
+ {nodeHtml}
+
+ )
+ })
}
export function makeCssModuleCompatibleClassName(
diff --git a/apps/scandic-web/types/transitionTypes/rte/enums.ts b/apps/scandic-web/types/transitionTypes/rte/enums.ts
index 29a76bf0d..11af3edb8 100644
--- a/apps/scandic-web/types/transitionTypes/rte/enums.ts
+++ b/apps/scandic-web/types/transitionTypes/rte/enums.ts
@@ -28,6 +28,10 @@ export enum RTETypeEnum {
p = "p",
reference = "reference",
span = "span",
+ /**
+ * Included for compatibility when copying RTE from other sources e.g. epi
+ */
+ div = "div",
table = "table",
tbody = "tbody",
td = "td",
diff --git a/apps/scandic-web/utils/safeTry.ts b/apps/scandic-web/utils/safeTry.ts
index d3bb81596..9b986a17f 100644
--- a/apps/scandic-web/utils/safeTry.ts
+++ b/apps/scandic-web/utils/safeTry.ts
@@ -9,3 +9,11 @@ export async function safeTry(func: Promise): SafeTryResult {
return [undefined, err]
}
}
+
+export function safeTrySync(func: () => T): Awaited> {
+ try {
+ return [func(), undefined]
+ } catch (err) {
+ return [undefined, err]
+ }
+}