diff --git a/admin/src/components/MediaLib.tsx b/admin/src/components/MediaLib.tsx index 4f6cfcf..c6e300a 100644 --- a/admin/src/components/MediaLib.tsx +++ b/admin/src/components/MediaLib.tsx @@ -1,36 +1,62 @@ import React from 'react'; -import PropTypes from 'prop-types'; -import { useStrapiApp } from '@strapi/strapi/admin'; import prefixFileUrlWithBackendUrl from '../utils/prefixFileUrlWithBackendUrl'; +import { useStrapiApp } from '@strapi/strapi/admin'; - -const MediaLib = ( { isOpen = false, onChange = () => {}, onToggle = () => {} } ) => { - const { components } = useStrapiApp( 'library', app => app ); - const MediaLibraryDialog = components[ 'media-library' ]; - - const handleSelectAssets = files => { - const formattedFiles = files.map(f => ( { +interface IMediaLibComponent { + isOpen: boolean; + onChange: (files: FormattedMediaFile[]) => void; + onToggle: (idx: any) => void; + allowedTypes: string[]; +} + +interface FormattedMediaFile { + alternativeText?: string; + name?: string; + alt: string; + url: string; + width: number | undefined; + height: number | undefined; + size: number | undefined; + mime: string | undefined; + formats: Record | undefined; +} + + +const MediaLibComponent: React.FC = ({ + isOpen = false, + onChange, + onToggle, + allowedTypes +}) => { + + const { components } = useStrapiApp('library', (app) => app); + const MediaLibraryDialog = components['media-library'] as React.ComponentType; + + + const handleSelectAssets = (files: FormattedMediaFile[]) => { + const formattedFiles: any = files.map((f) => ({ alt: f.alternativeText || f.name, - url: prefixFileUrlWithBackendUrl( f.url ), + url: prefixFileUrlWithBackendUrl(f.url), + width: f.width, + height: f.height, + size: f.size, mime: f.mime, - } ) ); - - onChange( formattedFiles ); + formats: f.formats, + })); + onChange(formattedFiles); }; - if ( !isOpen ) { - return null - }; + if (!isOpen) { + return null; + } - return( - + return ( + ); }; -MediaLib.propTypes = { - isOpen: PropTypes.bool, - onChange: PropTypes.func, - onToggle: PropTypes.func, -}; - -export default MediaLib; +export default MediaLibComponent; diff --git a/admin/src/components/ReactMdEditor.tsx b/admin/src/components/ReactMdEditor.tsx index 1b41838..4663932 100644 --- a/admin/src/components/ReactMdEditor.tsx +++ b/admin/src/components/ReactMdEditor.tsx @@ -1,6 +1,6 @@ import { FC as FunctionComponent, useState, useEffect, useMemo } from "react"; -import { Box, Flex, Typography } from "@strapi/design-system"; +import { Flex, Field } from "@strapi/design-system"; import type { Schema } from "@strapi/types"; import MDEditor, { commands, ICommand } from "@uiw/react-md-editor"; import { useIntl } from "react-intl"; @@ -9,7 +9,7 @@ import { styled } from "styled-components"; import "@uiw/react-markdown-preview/markdown.css"; import {PLUGIN_ID} from '../utils/pluginId'; -import { MediaLib } from "./MediaLib"; +import MediaLib from "./MediaLib"; import { useField } from "@strapi/strapi/admin"; const Wrapper = styled.div` @@ -34,6 +34,9 @@ const Wrapper = styled.div` img { max-width: 100%; } + ul,ol{ + list-style:inherit; + } .w-md-editor-preview { display: block; strong { @@ -73,15 +76,19 @@ interface EditorProps { defaultMessage: string; }; required?: boolean; + attribute?: any; // TO FIX + labelAction?: React.ReactNode; //TO FIX TO CHECK } const Editor: FunctionComponent = ({ + attribute, name, - intlLabel, disabled, - error, - description, + labelAction, required, + description, + error, + intlLabel, }) => { // const { formatMessage } = useIntl(); const { onChange, value }: any = useField(name); @@ -187,42 +194,36 @@ const Editor: FunctionComponent = ({ }, []); return ( - - - - {formatMessage(intlLabel)} - - {required && ( - - * - - )} - - -