feat(SW-3173): Added support for one or two columns for the list inside the RTE

Approved-by: Matilda Landström
This commit is contained in:
Erik Tiekstra
2025-09-01 07:52:32 +00:00
parent c7f00aca4d
commit ec66a5647a
5 changed files with 64 additions and 111 deletions

View File

@@ -4,13 +4,11 @@ import { renderOptions } from './renderOptions'
import styles from './jsontohtml.module.css'
import type { Node, Embeds } from './JsonToHtml'
import type { Embeds, Node } from './JsonToHtml'
import {
AvailableParagraphFormatEnum,
AvailableULFormatEnum,
RTETypeEnum,
} from './types/rte/enums'
import { EmbedByUid } from './JsonToHtml'
import { AVAILABLE_LIST_FORMATS } from './types/rte/constants'
import { AvailableParagraphFormatEnum, RTETypeEnum } from './types/rte/enums'
import {
RTEMarkType,
type RTENode,
@@ -19,7 +17,6 @@ import {
type RTETextNode,
} from './types/rte/node'
import type { RenderOptions } from './types/rte/option'
import { EmbedByUid } from './JsonToHtml'
export function groupEmbedsByUid(embedsArray: Node<Embeds>[]) {
const embedsByUid = embedsArray.reduce<EmbedByUid>((acc, embed) => {
@@ -109,11 +106,14 @@ export function hasAvailableParagraphFormat(className?: string) {
return Object.keys(AvailableParagraphFormatEnum).includes(className)
}
export function hasAvailableULFormat(className?: string) {
export function extractAvailableListClassNames(className?: string) {
if (!className) {
return false
return []
}
return Object.keys(AvailableULFormatEnum).includes(className)
const classNames = className.split(' ')
return classNames
.filter((name) => AVAILABLE_LIST_FORMATS.includes(name))
.map((item) => styles[item] || item)
}
export function nodeToHtml(
@@ -165,20 +165,3 @@ export function nodesToHtml(
)
})
}
export function makeCssModuleCompatibleClassName(
className: string | undefined,
formatType: 'ul'
): string {
if (!className) return ''
if (formatType === 'ul' && hasAvailableULFormat(className)) {
// TODO: REMOVE
// @ats-expect-error: 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
return styles[className] || className
}
return className
}