mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
feat(ui): add fracturedjsonjs
to pretty-serialize objects
In use on the metadata viewer - makes it sooo much easier on the eyes.
This commit is contained in:
committed by
Kent Keirsey
parent
e537de2f6d
commit
b43b2714cc
@ -65,6 +65,7 @@
|
|||||||
"chakra-react-select": "^4.7.6",
|
"chakra-react-select": "^4.7.6",
|
||||||
"compare-versions": "^6.1.0",
|
"compare-versions": "^6.1.0",
|
||||||
"dateformat": "^5.0.3",
|
"dateformat": "^5.0.3",
|
||||||
|
"fracturedjsonjs": "^4.0.1",
|
||||||
"framer-motion": "^11.1.8",
|
"framer-motion": "^11.1.8",
|
||||||
"i18next": "^23.11.3",
|
"i18next": "^23.11.3",
|
||||||
"i18next-http-backend": "^2.5.1",
|
"i18next-http-backend": "^2.5.1",
|
||||||
|
7
invokeai/frontend/web/pnpm-lock.yaml
generated
7
invokeai/frontend/web/pnpm-lock.yaml
generated
@ -50,6 +50,9 @@ dependencies:
|
|||||||
dateformat:
|
dateformat:
|
||||||
specifier: ^5.0.3
|
specifier: ^5.0.3
|
||||||
version: 5.0.3
|
version: 5.0.3
|
||||||
|
fracturedjsonjs:
|
||||||
|
specifier: ^4.0.1
|
||||||
|
version: 4.0.1
|
||||||
framer-motion:
|
framer-motion:
|
||||||
specifier: ^11.1.8
|
specifier: ^11.1.8
|
||||||
version: 11.1.8(react-dom@18.3.1)(react@18.3.1)
|
version: 11.1.8(react-dom@18.3.1)(react@18.3.1)
|
||||||
@ -8691,6 +8694,10 @@ packages:
|
|||||||
engines: {node: '>= 0.6'}
|
engines: {node: '>= 0.6'}
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
|
/fracturedjsonjs@4.0.1:
|
||||||
|
resolution: {integrity: sha512-KMhSx7o45aPVj4w27dwdQyKJkNU8oBqw8UiK/s3VzsQB3+pKQ/3AqG/YOEQblV2BDuYE5dKp0OMf8RDsshrjTA==}
|
||||||
|
dev: false
|
||||||
|
|
||||||
/framer-motion@10.18.0(react-dom@18.3.1)(react@18.3.1):
|
/framer-motion@10.18.0(react-dom@18.3.1)(react@18.3.1):
|
||||||
resolution: {integrity: sha512-oGlDh1Q1XqYPksuTD/usb0I70hq95OUzmL9+6Zd+Hs4XV0oaISBa/UUMSjYiq6m8EUF32132mOJ8xVZS+I0S6w==}
|
resolution: {integrity: sha512-oGlDh1Q1XqYPksuTD/usb0I70hq95OUzmL9+6Zd+Hs4XV0oaISBa/UUMSjYiq6m8EUF32132mOJ8xVZS+I0S6w==}
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import { Box, Flex, IconButton, Tooltip, useShiftModifier } from '@invoke-ai/ui-library';
|
import { Box, Flex, IconButton, Tooltip, useShiftModifier } from '@invoke-ai/ui-library';
|
||||||
import { getOverlayScrollbarsParams } from 'common/components/OverlayScrollbars/constants';
|
import { getOverlayScrollbarsParams } from 'common/components/OverlayScrollbars/constants';
|
||||||
|
import { Formatter } from 'fracturedjsonjs';
|
||||||
import { isString } from 'lodash-es';
|
import { isString } from 'lodash-es';
|
||||||
import { OverlayScrollbarsComponent } from 'overlayscrollbars-react';
|
import { OverlayScrollbarsComponent } from 'overlayscrollbars-react';
|
||||||
import type { CSSProperties } from 'react';
|
import type { CSSProperties } from 'react';
|
||||||
@ -7,6 +8,8 @@ import { memo, useCallback, useMemo } from 'react';
|
|||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { PiCopyBold, PiDownloadSimpleBold } from 'react-icons/pi';
|
import { PiCopyBold, PiDownloadSimpleBold } from 'react-icons/pi';
|
||||||
|
|
||||||
|
const formatter = new Formatter();
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
label: string;
|
label: string;
|
||||||
data: unknown;
|
data: unknown;
|
||||||
@ -20,7 +23,7 @@ const overlayscrollbarsOptions = getOverlayScrollbarsParams('scroll', 'scroll').
|
|||||||
|
|
||||||
const DataViewer = (props: Props) => {
|
const DataViewer = (props: Props) => {
|
||||||
const { label, data, fileName, withDownload = true, withCopy = true, extraCopyActions } = props;
|
const { label, data, fileName, withDownload = true, withCopy = true, extraCopyActions } = props;
|
||||||
const dataString = useMemo(() => (isString(data) ? data : JSON.stringify(data, null, 2)), [data]);
|
const dataString = useMemo(() => (isString(data) ? data : formatter.Serialize(data)) ?? '', [data]);
|
||||||
const shift = useShiftModifier();
|
const shift = useShiftModifier();
|
||||||
const handleCopy = useCallback(() => {
|
const handleCopy = useCallback(() => {
|
||||||
navigator.clipboard.writeText(dataString);
|
navigator.clipboard.writeText(dataString);
|
||||||
|
Reference in New Issue
Block a user