Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes 349 #1292

Merged
merged 7 commits into from
Jul 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions services/cms/src/components/editors/GutenbergEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ const GutenbergEditor: React.FC<React.PropsWithChildren<GutenbergEditorProps>> =
>({
disableCustomColors: false,
disableCustomEditorFontSizes: false,
styles: [],
})

const sideBarStartingYCoordinate = useSidebarStartingYCoodrinate()
Expand Down
4 changes: 4 additions & 0 deletions services/cms/src/styles/Gutenberg/editor-styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -129,3 +129,7 @@
.wp-block-embed .components-placeholder__learn-more {
display: none;
}

.block-editor-plain-text {
width: 100%;
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,17 @@ const SyntaxHighlightedContainer: React.FC<SyntaxHighlightedContainerProps> = ({
// The content coming from gutenberg contains <br> tags which do not work when we higlight the code with hljs
// So we'll replace the br tags with newlines
const replacedContent = useMemo(() => {
return content?.replace(/<br\s*\\?>/g, "\n") ?? ""
let res = content ?? ""
res = res.replace(/<br\s*\\?>/g, "\n")
return res
}, [content])

return (
<code
className={css`
background-color: #1a2333;
border-radius: 4px;
font-variant-ligatures: none;
`}
ref={ref}
dangerouslySetInnerHTML={{ __html: sanitizeCourseMaterialHtml(replacedContent) }}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { css } from "@emotion/css"
import dynamic from "next/dynamic"
import { useMemo } from "react"

import { BlockRendererProps } from "../../.."
import { CodeAttributes } from "../../../../../../types/GutenbergBlockAttributes"
import { fontSizeMapper } from "../../../../../styles/fontSizeMapper"

import BreakFromCentered from "@/shared-module/common/components/Centering/BreakFromCentered"
import Spinner from "@/shared-module/common/components/Spinner"
Expand All @@ -19,15 +19,36 @@ const SyntaxHighlightedContainer = dynamic(() => import("./SyntaxHighlightedCont

const CodeBlock: React.FC<React.PropsWithChildren<BlockRendererProps<CodeAttributes>>> = ({
data,
dontAllowBlockToBeWiderThanContainerWidth,
}) => {
const { anchor, content, fontSize } = data.attributes
const { anchor, content } = data.attributes
const fontSizePx = useMemo(() => {
const longestLine = (content ?? "")
.split("\n")
.reduce((acc, line) => (line.length > acc ? line.length : acc), 0)

let fontSizePx = 20
if (longestLine > 70) {
fontSizePx = 16
}
if (longestLine > 100) {
fontSizePx = 14
}
return fontSizePx
}, [content])

return (
<BreakFromCentered sidebar={false}>
<BreakFromCentered sidebar={false} disabled={dontAllowBlockToBeWiderThanContainerWidth}>
<pre
className={css`
max-width: 1000px;
margin: 0 auto;
${fontSize && `font-size: ${fontSizeMapper(fontSize)};`}
${dontAllowBlockToBeWiderThanContainerWidth &&
// If this is inside a container, large margins don't look good.
`margin-top: -1.5rem;
margin-bottom: -1.5rem;
`}
font-size: ${fontSizePx}px;
font-family: ${monospaceFont} !important;
line-height: 1.75rem;
white-space: pre-wrap;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,7 @@ const parseText = (
terms: Term[],
options: { glossary: boolean } = { glossary: true },
) => {
const sanitizedHTML = sanitizeCourseMaterialHtml(content)
const { count, converted: parsedLatex } = convertToLatex(sanitizedHTML)
const { count, converted: parsedLatex } = convertToLatex(content ?? "")
const parsedCitation = parseCitation(parsedLatex)

let parsedText = parsedCitation
Expand Down
113 changes: 46 additions & 67 deletions services/headless-lms/Cargo.lock

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

6 changes: 3 additions & 3 deletions services/headless-lms/certificates/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ headless-lms-utils = { path = "../utils" }
headless-lms-models = { path = "../models" }

# An SVG rendering library.
resvg = "0.38.0"
resvg = "0.42.0"
# An SVG simplification library.
usvg = "0.38.0"
usvg = "0.42.0"
# A simple, streaming XML writer.
xmlwriter = "0.1.0"
# High performance xml reader and writer
quick-xml = "0.31.0"
quick-xml = "0.35.0"
# International Components for Unicode
icu = { version = "1.3.2", features = ["std", "serde"] }
# Trait and struct definitions for the ICU data provider
Expand Down
Loading
Loading