mirror of
https://github.com/wanderer-industries/wanderer
synced 2025-12-12 10:45:54 +00:00
feat: Add support markdown for system description
This commit is contained in:
@@ -1,4 +1,3 @@
|
|||||||
import classes from './MarkdownComment.module.scss';
|
|
||||||
import clsx from 'clsx';
|
import clsx from 'clsx';
|
||||||
import {
|
import {
|
||||||
InfoDrawer,
|
InfoDrawer,
|
||||||
@@ -49,7 +48,11 @@ export const MarkdownComment = ({ text, time, characterEveId, id }: MarkdownComm
|
|||||||
<>
|
<>
|
||||||
<InfoDrawer
|
<InfoDrawer
|
||||||
labelClassName="mb-[3px]"
|
labelClassName="mb-[3px]"
|
||||||
className={clsx(classes.MarkdownCommentRoot, 'p-1 bg-stone-700/20 ')}
|
className={clsx(
|
||||||
|
'p-1 bg-stone-700/20',
|
||||||
|
'text-[12px] leading-[1.2] text-stone-300 break-words',
|
||||||
|
'bg-gradient-to-r from-stone-600/40 via-stone-600/10 to-stone-600/0',
|
||||||
|
)}
|
||||||
onMouseEnter={handleMouseEnter}
|
onMouseEnter={handleMouseEnter}
|
||||||
onMouseLeave={handleMouseLeave}
|
onMouseLeave={handleMouseLeave}
|
||||||
title={
|
title={
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
.CERoot {
|
||||||
|
@apply border border-stone-400/30 rounded-[2px];
|
||||||
|
|
||||||
|
:global {
|
||||||
|
.cm-content {
|
||||||
|
@apply bg-stone-600/40;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,6 +6,7 @@ import { useHotkey } from '@/hooks/Mapper/hooks';
|
|||||||
import { useCallback, useRef, useState } from 'react';
|
import { useCallback, useRef, useState } from 'react';
|
||||||
import { OutCommand } from '@/hooks/Mapper/types';
|
import { OutCommand } from '@/hooks/Mapper/types';
|
||||||
import { useMapRootState } from '@/hooks/Mapper/mapRootProvider';
|
import { useMapRootState } from '@/hooks/Mapper/mapRootProvider';
|
||||||
|
import classes from './CommentsEditor.module.scss';
|
||||||
|
|
||||||
export interface CommentsEditorProps {}
|
export interface CommentsEditorProps {}
|
||||||
|
|
||||||
@@ -48,6 +49,7 @@ export const CommentsEditor = ({}: CommentsEditorProps) => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<MarkdownEditor
|
<MarkdownEditor
|
||||||
|
className={classes.CERoot}
|
||||||
value={textVal}
|
value={textVal}
|
||||||
onChange={setTextVal}
|
onChange={setTextVal}
|
||||||
overlayContent={
|
overlayContent={
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
.CERoot {
|
.CERoot {
|
||||||
@apply border border-stone-400/30 rounded-[2px];
|
@apply border border-stone-500/30 rounded-[2px];
|
||||||
|
|
||||||
:global {
|
:global {
|
||||||
.cm-content {
|
.cm-content {
|
||||||
@apply bg-stone-600/40;
|
@apply bg-stone-950/70;
|
||||||
}
|
}
|
||||||
|
|
||||||
.cm-scroller {
|
.cm-scroller {
|
||||||
|
|||||||
@@ -44,9 +44,17 @@ export interface MarkdownEditorProps {
|
|||||||
overlayContent?: ReactNode;
|
overlayContent?: ReactNode;
|
||||||
value: string;
|
value: string;
|
||||||
onChange: (value: string) => void;
|
onChange: (value: string) => void;
|
||||||
|
height?: string;
|
||||||
|
className?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const MarkdownEditor = ({ value, onChange, overlayContent }: MarkdownEditorProps) => {
|
export const MarkdownEditor = ({
|
||||||
|
value,
|
||||||
|
onChange,
|
||||||
|
overlayContent,
|
||||||
|
height = '70px',
|
||||||
|
className,
|
||||||
|
}: MarkdownEditorProps) => {
|
||||||
const [hasShift, setHasShift] = useState(false);
|
const [hasShift, setHasShift] = useState(false);
|
||||||
|
|
||||||
const refData = useRef({ onChange });
|
const refData = useRef({ onChange });
|
||||||
@@ -66,9 +74,9 @@ export const MarkdownEditor = ({ value, onChange, overlayContent }: MarkdownEdit
|
|||||||
<div className={clsx(classes.MarkdownEditor, 'relative')}>
|
<div className={clsx(classes.MarkdownEditor, 'relative')}>
|
||||||
<CodeMirror
|
<CodeMirror
|
||||||
value={value}
|
value={value}
|
||||||
height="70px"
|
height={height}
|
||||||
extensions={CODE_MIRROR_EXTENSIONS}
|
extensions={CODE_MIRROR_EXTENSIONS}
|
||||||
className={classes.CERoot}
|
className={clsx(classes.CERoot, className)}
|
||||||
theme={oneDark}
|
theme={oneDark}
|
||||||
onChange={handleOnChange}
|
onChange={handleOnChange}
|
||||||
placeholder="Start typing..."
|
placeholder="Start typing..."
|
||||||
|
|||||||
@@ -8,8 +8,8 @@ import { LabelsManager } from '@/hooks/Mapper/utils/labelsManager.ts';
|
|||||||
import { Dialog } from 'primereact/dialog';
|
import { Dialog } from 'primereact/dialog';
|
||||||
import { IconField } from 'primereact/iconfield';
|
import { IconField } from 'primereact/iconfield';
|
||||||
import { InputText } from 'primereact/inputtext';
|
import { InputText } from 'primereact/inputtext';
|
||||||
import { InputTextarea } from 'primereact/inputtextarea';
|
|
||||||
import { useCallback, useEffect, useRef, useState } from 'react';
|
import { useCallback, useEffect, useRef, useState } from 'react';
|
||||||
|
import { MarkdownEditor } from '@/hooks/Mapper/components/mapInterface/components/MarkdownEditor';
|
||||||
|
|
||||||
interface SystemSettingsDialog {
|
interface SystemSettingsDialog {
|
||||||
systemId: string;
|
systemId: string;
|
||||||
@@ -214,13 +214,9 @@ export const SystemSettingsDialog = ({ systemId, visible, setVisible }: SystemSe
|
|||||||
|
|
||||||
<div className="flex flex-col gap-1">
|
<div className="flex flex-col gap-1">
|
||||||
<label htmlFor="username">Description</label>
|
<label htmlFor="username">Description</label>
|
||||||
<InputTextarea
|
<div className="h-[200px]">
|
||||||
autoResize
|
<MarkdownEditor value={description} onChange={e => setDescription(e)} height="180px" />
|
||||||
rows={5}
|
</div>
|
||||||
cols={30}
|
|
||||||
value={description}
|
|
||||||
onChange={e => setDescription(e.target.value)}
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { useMapRootState } from '@/hooks/Mapper/mapRootProvider';
|
|||||||
import { isWormholeSpace } from '@/hooks/Mapper/components/map/helpers/isWormholeSpace.ts';
|
import { isWormholeSpace } from '@/hooks/Mapper/components/map/helpers/isWormholeSpace.ts';
|
||||||
import { useMemo } from 'react';
|
import { useMemo } from 'react';
|
||||||
import { getSystemById, sortWHClasses } from '@/hooks/Mapper/helpers';
|
import { getSystemById, sortWHClasses } from '@/hooks/Mapper/helpers';
|
||||||
import { InfoDrawer, WHClassView, WHEffectView } from '@/hooks/Mapper/components/ui-kit';
|
import { InfoDrawer, MarkdownTextViewer, WHClassView, WHEffectView } from '@/hooks/Mapper/components/ui-kit';
|
||||||
import { getSystemStaticInfo } from '@/hooks/Mapper/mapRootProvider/hooks/useLoadSystemStatic';
|
import { getSystemStaticInfo } from '@/hooks/Mapper/mapRootProvider/hooks/useLoadSystemStatic';
|
||||||
|
|
||||||
interface SystemInfoContentProps {
|
interface SystemInfoContentProps {
|
||||||
@@ -51,7 +51,7 @@ export const SystemInfoContent = ({ systemId }: SystemInfoContentProps) => {
|
|||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<div className="break-words">{description}</div>
|
<MarkdownTextViewer>{description}</MarkdownTextViewer>
|
||||||
</InfoDrawer>
|
</InfoDrawer>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,8 +1,5 @@
|
|||||||
.MarkdownCommentRoot {
|
.MarkdownTextViewer {
|
||||||
border-left-width: 3px;
|
|
||||||
|
|
||||||
@apply text-[12px] leading-[1.2] text-stone-300 break-words;
|
@apply text-[12px] leading-[1.2] text-stone-300 break-words;
|
||||||
@apply bg-gradient-to-r from-stone-600/40 via-stone-600/10 to-stone-600/0;
|
|
||||||
|
|
||||||
.h1 {
|
.h1 {
|
||||||
@apply text-[12px] font-normal m-0 p-0 border-none break-words whitespace-normal;
|
@apply text-[12px] font-normal m-0 p-0 border-none break-words whitespace-normal;
|
||||||
@@ -56,6 +53,10 @@
|
|||||||
@apply font-bold text-green-400 break-words whitespace-normal;
|
@apply font-bold text-green-400 break-words whitespace-normal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
strong {
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
i, em {
|
i, em {
|
||||||
@apply italic text-pink-400 break-words whitespace-normal;
|
@apply italic text-pink-400 break-words whitespace-normal;
|
||||||
}
|
}
|
||||||
@@ -2,10 +2,16 @@ import Markdown from 'react-markdown';
|
|||||||
import remarkGfm from 'remark-gfm';
|
import remarkGfm from 'remark-gfm';
|
||||||
import remarkBreaks from 'remark-breaks';
|
import remarkBreaks from 'remark-breaks';
|
||||||
|
|
||||||
|
import classes from './MarkdownTextViewer.module.scss';
|
||||||
|
|
||||||
const REMARK_PLUGINS = [remarkGfm, remarkBreaks];
|
const REMARK_PLUGINS = [remarkGfm, remarkBreaks];
|
||||||
|
|
||||||
type MarkdownTextViewerProps = { children: string };
|
type MarkdownTextViewerProps = { children: string };
|
||||||
|
|
||||||
export const MarkdownTextViewer = ({ children }: MarkdownTextViewerProps) => {
|
export const MarkdownTextViewer = ({ children }: MarkdownTextViewerProps) => {
|
||||||
return <Markdown remarkPlugins={REMARK_PLUGINS}>{children}</Markdown>;
|
return (
|
||||||
|
<div className={classes.MarkdownTextViewer}>
|
||||||
|
<Markdown remarkPlugins={REMARK_PLUGINS}>{children}</Markdown>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user