editor-storybook-fix
This commit is contained in:
parent
5eded9f143
commit
74725df0ff
|
@ -6,7 +6,7 @@ import { EditorContext, EditorContextType, ShoutForm } from '~/context/editor'
|
|||
import { LocalizeContext, LocalizeContextType } from '~/context/localize'
|
||||
import { SessionContext, SessionContextType } from '~/context/session'
|
||||
import { SnackbarContext, SnackbarContextType } from '~/context/ui'
|
||||
import { EditorComponent } from './Editor'
|
||||
import { EditorComponent, EditorComponentProps } from './Editor'
|
||||
|
||||
// Mock any necessary data
|
||||
const mockSession = {
|
||||
|
@ -125,8 +125,8 @@ export default meta
|
|||
type Story = StoryObj<typeof EditorComponent>
|
||||
|
||||
export const Default: Story = {
|
||||
render: (args) => {
|
||||
const [_content, setContent] = createSignal(args.initialContent || '')
|
||||
render: (props: EditorComponentProps) => {
|
||||
const [_content, setContent] = createSignal(props.initialContent || '')
|
||||
|
||||
return (
|
||||
<SessionContext.Provider value={mockSession as SessionContextType}>
|
||||
|
@ -134,9 +134,9 @@ export const Default: Story = {
|
|||
<SnackbarContext.Provider value={mockSnackbarContext as SnackbarContextType}>
|
||||
<EditorContext.Provider value={mockEditorContext as EditorContextType}>
|
||||
<EditorComponent
|
||||
{...args}
|
||||
{...props}
|
||||
onChange={(text: string) => {
|
||||
args.onChange(text)
|
||||
props.onChange(text)
|
||||
setContent(text)
|
||||
}}
|
||||
/>
|
||||
|
|
|
@ -51,7 +51,7 @@ import { renderUploadedImage } from './renderUploadedImage'
|
|||
|
||||
import './Prosemirror.scss'
|
||||
|
||||
type Props = {
|
||||
export type EditorComponentProps = {
|
||||
shoutId: number
|
||||
initialContent?: string
|
||||
onChange: (text: string) => void
|
||||
|
@ -72,7 +72,7 @@ const allowedImageTypes = new Set([
|
|||
const yDocs: Record<string, Doc> = {}
|
||||
const providers: Record<string, HocuspocusProvider> = {}
|
||||
|
||||
export const EditorComponent = (props: Props) => {
|
||||
export const EditorComponent = (props: EditorComponentProps) => {
|
||||
const { t } = useLocalize()
|
||||
const { session } = useSession()
|
||||
const author = createMemo<Author>(() => session()?.user?.app_data?.profile as Author)
|
||||
|
|
Loading…
Reference in New Issue
Block a user