From 3b82288112eee29de3002c3721caec8b1c70cc0b Mon Sep 17 00:00:00 2001 From: Borghild Selle <104756130+BorghildSelle@users.noreply.github.com> Date: Mon, 19 Aug 2024 12:39:29 +0200 Subject: [PATCH] :bug: portabletext didnt recognize block (#2466) --- web/core/Typography/Heading.tsx | 64 ++++++++++++++--------------- web/package.json | 6 +-- web/pnpm-lock.yaml | 52 +++++++++-------------- web/sections/Grid/GridTextBlock.tsx | 2 +- 4 files changed, 56 insertions(+), 68 deletions(-) diff --git a/web/core/Typography/Heading.tsx b/web/core/Typography/Heading.tsx index 9be267474..1bc11572f 100644 --- a/web/core/Typography/Heading.tsx +++ b/web/core/Typography/Heading.tsx @@ -51,7 +51,6 @@ const defaultComponents = ({ ) }, h2: ({ children }: PortableTextBlock) => { - console.log('is h2', id) return ( <>{children} @@ -132,6 +131,19 @@ export const Heading = ({ id, ...props }: HeadingProps) => { + let serializers = { + // eslint-disable-next-line + // @ts-ignore + block: { + ...defaultComponents({ variant, group, as, serializerClassnames, className, id }).block, + }, + // eslint-disable-next-line + // @ts-ignore + marks: { + ...defaultComponents({ variant, group, as }).marks, + }, + } + let div: PortableTextBlock[] = [] return ( <> @@ -149,6 +161,20 @@ export const Heading = ({ const WrapperTextTag = as ?? (`h2` as React.ElementType) const PortableTextTag = `span` as React.ElementType + serializers = { + // eslint-disable-next-line + // @ts-ignore + block: { + ...defaultComponents({ variant, group, as: PortableTextTag, serializerClassnames, className }).block, + ...blocksComponents, + }, + // eslint-disable-next-line + // @ts-ignore + marks: { + ...defaultComponents({ variant, group, as: PortableTextTag }).marks, + }, + } + return ( - + {/*@ts-ignore */} + ) } }) ) : ( )} diff --git a/web/package.json b/web/package.json index 9398458fa..987e48cdc 100644 --- a/web/package.json +++ b/web/package.json @@ -31,9 +31,9 @@ "@equinor/eds-utils": "^0.8.4", "@floating-ui/react": "^0.26.9", "@next/bundle-analyzer": "^12.1.0", - "@portabletext/react": "^3.0.0", - "@portabletext/to-html": "^2.0.5", - "@portabletext/types": "^2.0.2", + "@portabletext/react": "^3.1.0", + "@portabletext/to-html": "^2.0.13", + "@portabletext/types": "^2.0.13", "@react-spring/web": "^9.4.5", "@sanity/asset-utils": "^1.3.0", "@sanity/client": "^5.4.2", diff --git a/web/pnpm-lock.yaml b/web/pnpm-lock.yaml index 33fd08a88..7d876949e 100644 --- a/web/pnpm-lock.yaml +++ b/web/pnpm-lock.yaml @@ -41,14 +41,14 @@ dependencies: specifier: ^12.1.0 version: 12.1.0 '@portabletext/react': - specifier: ^3.0.0 - version: 3.0.0(react@18.2.0) + specifier: ^3.1.0 + version: 3.1.0(react@18.2.0) '@portabletext/to-html': - specifier: ^2.0.5 - version: 2.0.5 + specifier: ^2.0.13 + version: 2.0.13 '@portabletext/types': - specifier: ^2.0.2 - version: 2.0.2 + specifier: ^2.0.13 + version: 2.0.13 '@react-spring/web': specifier: ^9.4.5 version: 9.4.5(react-dom@18.2.0)(react@18.2.0) @@ -2816,46 +2816,34 @@ packages: resolution: {integrity: sha512-P1st0aksCrn9sGZhp8GMYwBnQsbvAWsZAX44oXNNvLHGqAOcoVxmjZiohstwQ7SqKnbR47akdNi+uleWD8+g6A==} dev: false - /@portabletext/react@3.0.0(react@18.2.0): - resolution: {integrity: sha512-bvh9Ls3ZOa7rPOtJ2fTrTFAC6nXAwHlyt1ukFqFSgTehtsgl91WB2kaBa3XdXCBiobzED3OPcLZ3Y3fsb9ZFiQ==} + /@portabletext/react@3.1.0(react@18.2.0): + resolution: {integrity: sha512-ZGHlvS+NvId9RSqnflN8xF2KVZgAgD399dK1GaycurnGNZGZYTd5nZmc8by1yL76Ar8n/dbVtouUDJIkO4Tupw==} engines: {node: ^14.13.1 || >=16.0.0} peerDependencies: - react: ^17 || ^18 + react: ^17 || ^18 || >=19.0.0-rc dependencies: - '@portabletext/toolkit': 2.0.1 - '@portabletext/types': 2.0.2 + '@portabletext/toolkit': 2.0.15 + '@portabletext/types': 2.0.13 react: 18.2.0 dev: false - /@portabletext/to-html@2.0.5: - resolution: {integrity: sha512-KkUI6iBuKSzclyKYnwGLiE0asxvW1ZcFmZ7wBslW+nulw78qwpTl3wuK47zf+y0XX7g52d5gw5WlYBAhuSEjSg==} - engines: {node: ^14.13.1 || >=16.0.0} - dependencies: - '@portabletext/toolkit': 2.0.10 - '@portabletext/types': 2.0.8 - dev: false - - /@portabletext/toolkit@2.0.1: - resolution: {integrity: sha512-vr2SeDFUFV+VmRIyYsHBMimZLiiN0S7qIridt/YLJs3Wm1dI4jsfUam82AQwheSMjvWdBiBZ+Wsjq5HZBG4htw==} + /@portabletext/to-html@2.0.13: + resolution: {integrity: sha512-T3zL+2RcPCPGCp7rRrGrNJnGAqkdlpiOZnb/wh4tjDYJevteGY+5hmA0/5idLXzLiPv6vT8Gld852Sc0aFXwUA==} engines: {node: ^14.13.1 || >=16.0.0} dependencies: - '@portabletext/types': 2.0.8 + '@portabletext/toolkit': 2.0.15 + '@portabletext/types': 2.0.13 dev: false - /@portabletext/toolkit@2.0.10: - resolution: {integrity: sha512-d+F9JvpnMEx7kd6saZ9OWA4U1Iwuokh6TOht7iqkfWU+0ivh9yM4v+b0Kpu+iiPcElicoabhtXol+yTvWJ1jDw==} + /@portabletext/toolkit@2.0.15: + resolution: {integrity: sha512-KRNEUAd6eOxE9y591qC0sE24ZG2q27OHXe0dsPclj4IoEzf8aEuDcHR64wfFtB0aHq9Wdx3pIinmhZZcl35/vg==} engines: {node: ^14.13.1 || >=16.0.0} dependencies: - '@portabletext/types': 2.0.8 - dev: false - - /@portabletext/types@2.0.2: - resolution: {integrity: sha512-3xTbSa80G1nODyACY0ilrmPo1PmU1xuoPvfcpzpqSEL0kX01fSW+21PKgS9BcG+GqdG9HK/VxciKWa+nFA7mqg==} - engines: {node: ^14.13.1 || >=16.0.0 || >=18.0.0} + '@portabletext/types': 2.0.13 dev: false - /@portabletext/types@2.0.8: - resolution: {integrity: sha512-eiq9/kMX2bYezS4/kLFk3xNnruCFjCDdw6aYEv5ECHVKkYROiuLd3/AsP5d7tWF3+kPPy6tB0Wq8aqDG/URHGA==} + /@portabletext/types@2.0.13: + resolution: {integrity: sha512-5xk5MSyQU9CrDho3Rsguj38jhijhD36Mk8S6mZo3huv6PM+t4M/5kJN2KFIxgvt4ONpvOEs1pVIZAV0cL0Vi+Q==} engines: {node: ^14.13.1 || >=16.0.0 || >=18.0.0} dev: false diff --git a/web/sections/Grid/GridTextBlock.tsx b/web/sections/Grid/GridTextBlock.tsx index 9d8176946..335c743b1 100644 --- a/web/sections/Grid/GridTextBlock.tsx +++ b/web/sections/Grid/GridTextBlock.tsx @@ -145,7 +145,7 @@ const GridTextBlock = forwardRef(function Gr const serializerClassnames = { largeText: `leading-tight text-balance ${titleTextColor}`, - normal: `text-lg leading-snug text-balance ${titleTextColor}`, + normal: `text-2xl leading-snug text-balance ${titleTextColor}`, } const mainContent = (