(null)
-
- const editor = useEditor({
- immediatelyRender: false,
- shouldRerenderOnTransaction: false,
- content: value || {
- type: "doc",
- content: [{ type: "paragraph", content: [] }],
- },
- editable: !readOnly,
- onUpdate: ({ editor }) => {
- if (!readOnly) {
- const json = editor.getJSON()
- onChange?.(json)
- }
- },
- editorProps: {
- attributes: {
- autocomplete: "off",
- autocorrect: "off",
- autocapitalize: "off",
- "aria-label": "Main content area, start typing to enter text.",
- class: "simple-editor",
- },
- },
- extensions: [
- StarterKit.configure({
- horizontalRule: false,
- link: {
- openOnClick: false,
- enableClickSelection: true,
- },
- }),
- HorizontalRule,
- TextAlign.configure({ types: ["heading", "paragraph"] }),
- TaskList,
- TaskItem.configure({ nested: true }),
- Highlight.configure({ multicolor: true }),
- Typography,
- Superscript,
- Subscript,
- Selection,
- Image,
- ImageUploadNode.configure({
- accept: "image/*",
- maxSize: MAX_FILE_SIZE,
- limit: 3,
- upload: handleImageUpload,
- onError: (error) => console.error("Upload failed:", error),
- }),
- ],
- })
-
- // 👇 Important: update content when fetched JSON changes
- useEffect(() => {
- if (editor && value) {
- editor.commands.setContent(value)
- }
- // eslint-disable-next-line react-hooks/exhaustive-deps
- }, [editor])
-
- return (
-
-
- {!readOnly && (
-
-
-
- )}
-
- {!readOnly && (
-
- )}
-
-
-
-
- )
-}
diff --git a/frontends/ol-components/src/components/TiptapEditor/TiptapEditor.tsx b/frontends/ol-components/src/components/TiptapEditor/TiptapEditor.tsx
index 9b0220ea83..e1451bdc60 100644
--- a/frontends/ol-components/src/components/TiptapEditor/TiptapEditor.tsx
+++ b/frontends/ol-components/src/components/TiptapEditor/TiptapEditor.tsx
@@ -3,8 +3,9 @@
// Based on ./components/tiptap-templates/simple/simple-editor.tsx
import React from "react"
+import styled from "@emotion/styled"
import { EditorContent } from "@tiptap/react"
-
+import type { Editor } from "@tiptap/core"
import { ImageUploadButton } from "./components/tiptap-ui/image-upload-button"
// --- UI Primitives ---
@@ -39,6 +40,25 @@ import "./styles/_keyframe-animations.scss"
import "./styles/_variables.scss"
import "./components/tiptap-templates/simple/simple-editor.scss"
+const StyledEditorContent = styled(EditorContent)<{ readOnly: boolean }>(
+ ({ theme, readOnly }) => ({
+ maxWidth: "1000px",
+ minHeight: "calc(100vh - 350px)",
+ backgroundColor: theme.custom.colors.white,
+ borderRadius: "10px",
+ margin: "20px auto",
+ ...(readOnly
+ ? {
+ maxWidth: "100%",
+ backgroundColor: "transparent",
+ ".tiptap.ProseMirror.simple-editor": {
+ padding: "0",
+ },
+ }
+ : {}),
+ }),
+)
+
export const MainToolbarContent = () => {
return (
<>
@@ -94,19 +114,23 @@ export const MainToolbarContent = () => {
)
}
-interface SimpleEditorProps {
- value?: object
- onChange?: (json: object) => void
+interface TiptapEditorProps {
+ editor: Editor
readOnly?: boolean
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- editor?: any
+ className?: string
}
-export default function SimpleEditor({ readOnly, editor }: SimpleEditorProps) {
+
+export default function TiptapEditor({
+ editor,
+ readOnly,
+ className,
+}: TiptapEditorProps) {
return (
-
)
}
diff --git a/frontends/ol-components/src/components/TiptapEditor/index.ts b/frontends/ol-components/src/components/TiptapEditor/index.ts
new file mode 100644
index 0000000000..60304b2ea2
--- /dev/null
+++ b/frontends/ol-components/src/components/TiptapEditor/index.ts
@@ -0,0 +1 @@
+export { ArticleEditor } from "./ArticleEditor"
diff --git a/frontends/ol-components/src/index.ts b/frontends/ol-components/src/index.ts
index 8528e62f4c..ef27b4aa64 100644
--- a/frontends/ol-components/src/index.ts
+++ b/frontends/ol-components/src/index.ts
@@ -171,9 +171,7 @@ export * from "./components/ThemeProvider/MITLearnGlobalStyles"
export { AppRouterCacheProvider as NextJsAppRouterCacheProvider } from "@mui/material-nextjs/v15-appRouter"
-export { default as TiptapEditor } from "./components/TiptapEditor/TiptapEditor"
-export { default as TiptapEditorContainer } from "./components/TiptapEditor/EditorContainer"
-export type { JSONContent } from "@tiptap/core"
+export * from "./components/TiptapEditor"
// /**
// * @deprecated Please use component from @mitodl/smoot-design instead