+
+
+
+
+
+
+
+
+
+
+
-
-
-
+
+
+
-
+
-
-
+
+
-
-
- >
+
+
+ >
+ }
+ />
)
}),
headingsPlugin(),
+ diffSourcePlugin({
+ viewMode: 'rich-text',
+ diffMarkdown: markdown
+ }),
quotePlugin(),
imagePlugin({
ImageDialog: ImageDialog
@@ -118,6 +128,7 @@ export const Editor = React.memo(
codeBlockEditorDescriptors: [PlainTextCodeEditorDescriptor]
})
],
+ // eslint-disable-next-line react-hooks/exhaustive-deps
[]
)
diff --git a/src/components/ModForm.tsx b/src/components/ModForm.tsx
index afeccd5..a4a86cd 100644
--- a/src/components/ModForm.tsx
+++ b/src/components/ModForm.tsx
@@ -22,7 +22,12 @@ import {
ModPageLoaderResult,
SubmitModActionResult
} from '../types'
-import { initializeFormState, MOD_DRAFT_CACHE_KEY } from '../utils'
+import {
+ initializeFormState,
+ log,
+ LogType,
+ MOD_DRAFT_CACHE_KEY
+} from '../utils'
import { CheckboxField, InputField, InputFieldWithImageUpload } from './Inputs'
import { OriginalAuthor } from './OriginalAuthor'
import { CategoryAutocomplete } from './CategoryAutocomplete'
@@ -32,6 +37,7 @@ import { MEDIA_OPTIONS } from 'controllers'
import { InputError } from './Inputs/Error'
import { ImageUpload } from './Inputs/ImageUpload'
import { useLocalCache } from 'hooks/useLocalCache'
+import { toast } from 'react-toastify'
interface GameOption {
value: string
@@ -59,6 +65,13 @@ export const ModForm = () => {
isEditing ? initializeFormState(mod) : cache ? cache : initializeFormState()
)
+ // Enable backwards compatibility with the mods that used html
+ const body = useMemo(() => {
+ // Replace the most problematic HTML tags (
)
+ const fixed = formState.body.replaceAll(/
/g, '\r\n')
+ return fixed
+ }, [formState.body])
+
useEffect(() => {
if (!isEditing) {
const newCache = _.cloneDeep(formState)
@@ -253,11 +266,15 @@ export const ModForm = () => {
{
handleInputChange('body', md)
}}
+ onError={(payload) => {
+ toast.error('Markdown error. Fix manually in the source mode.')
+ log(true, LogType.Error, payload.error)
+ }}
/>
{typeof formErrors?.body !== 'undefined' && (