Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TextColorFeature not working #2

Open
jlole opened this issue Dec 29, 2024 · 13 comments
Open

TextColorFeature not working #2

jlole opened this issue Dec 29, 2024 · 13 comments

Comments

@jlole
Copy link

jlole commented Dec 29, 2024

Status

I have added TextColorFeature to the editor and imported the css
this is working fine except that if you don't give it an object { colors: [...] } it gives an error

Screenshot 2024-12-29 at 16 21 52

Screenshot 2024-12-29 at 16 15 54

Issue

on the frontend the colors are not showing, in the html I just see empty comments

Screenshot 2024-12-29 at 16 22 07

I appreciate the plugin! thanks for making it

@rubn-g
Copy link
Owner

rubn-g commented Dec 29, 2024

Hey, thanks for spotting the issue with colors property. i've fixed that, colors is now optional, as it should.

About the html rendering issue, how are you rendering the json to html?
It works with the convertLexicalToHTML function from @payloadcms/richtext-lexical package, let me know how are you doing it, maybe we can improve it to make it work with other methods too.

@jlole
Copy link
Author

jlole commented Dec 29, 2024

ah thanks for your answer, I was using <RichText data={...} />

@rubn-g
Copy link
Owner

rubn-g commented Dec 30, 2024

I've added converters to the plugin, you should edit the RichText component to add the JSXConverters as defined in usage step 4 of the README.

Let me know if it works for you

@jlole
Copy link
Author

jlole commented Dec 30, 2024

I got it to work, thank you so much!

It seems for me in the TextJSXConverter
import { NodeFormat } from '@payloadcms/richtext-lexical'
causes an Module not found: Can't resolve 'fs'
Copying it manually fixed it for me

Furthermore, in ParagraphJSXConverter I had to change
return <p style={style} dangerouslySetInnerHTML={{ __html: children }} />
into
return <p style={style}>{children}</p>
otherwise I would see this in my frontend:
Screenshot 2024-12-30 at 18 22 10

@jlole
Copy link
Author

jlole commented Dec 30, 2024

I also just noticed the regex to get the colors includes the semicolon ; so i get a Console Error
Style property values shouldn't contain a semicolon. Try "color: #FFF176" instead.

@rubn-g
Copy link
Owner

rubn-g commented Dec 30, 2024

Thanks for helping me testing the JSX Converters, i'm not using RichText component and it's being hard for me to properly test that part.

I've released the fixes for the issues you've found

@jlole
Copy link
Author

jlole commented Dec 31, 2024

I tried the new versions (0.3.1, 0.4.0, 0.4.1) but it seems it didn't include the latest changes?

@rubn-g
Copy link
Owner

rubn-g commented Dec 31, 2024

Seems like there were some issue while building the code, i've re-built and published a 0.5.0 version. It should be fine now.

Thank you!

@AdrianMaj
Copy link

Hey, I think it's still something wrong with the JSXConverter

import { JSXConvertersFunction, RichText as RichTextWithoutBlocks } from "@payloadcms/richtext-lexical/react";
import { JSXConverters } from "payloadcms-lexical-ext";

import { CodeBlock, CodeBlockProps } from "@/blocks/Code/Component";

import type { CallToActionBlock as CTABlockProps, MediaBlock as MediaBlockProps } from "@/payload-types";
// import { BannerBlock } from "@/blocks/Banner/Component";
import { CallToActionBlock } from "@/blocks/CallToAction/Component";
import { cn } from "@/utils/cn";

type NodeTypes = DefaultNodeTypes | SerializedBlockNode<CTABlockProps | MediaBlockProps | CodeBlockProps>;

const jsxConverters: JSXConvertersFunction<NodeTypes> = ({ defaultConverters }) => ({
  ...defaultConverters,
  ...JSXConverters,
  blocks: {
    // banner: ({ node }) => <BannerBlock className="col-start-2 mb-4" {...node.fields} />,
    mediaBlock: ({ node }) => (
      <MediaBlock
        className="col-span-3 col-start-1"
        imgClassName="m-0"
        {...node.fields}
        captionClassName="mx-auto max-w-[48rem]"
        enableGutter={false}
        disableInnerContainer={true}
      />
    ),
    code: ({ node }) => <CodeBlock className="col-start-2" {...node.fields} />,
    cta: ({ node }) => <CallToActionBlock {...node.fields} />,
  },
});

Got it like that, and like the person above, I got the "Can't resolve 'fs'" error.

@rubn-g
Copy link
Owner

rubn-g commented Jan 2, 2025

Hi @AdrianMaj i released version 0.5.1, this should be fixed

@AdrianMaj
Copy link

Thanks for fast update, but I still don't find it working. When I use source code and manually add the converters it works, but when using import { JSXConverters } from "payloadcms-lexical-ext"; it shows the "Can't resolve 'fs'" error. Ofc I updated to 0.5.1

@rubn-g
Copy link
Owner

rubn-g commented Jan 3, 2025

I released a beta version, you should be able to install it like npm i payloadcms-lexical-ext@next
Can you test if it helps with the issue?

@AdrianMaj
Copy link

Unfortunately no, here is the full error message, maybe it will help you out:

./node_modules/.pnpm/image-size@1.2.0/node_modules/image-size/dist/index.js:4:12
Module not found: Can't resolve 'fs'
  2 | Object.defineProperty(exports, "__esModule", { value: true });
  3 | exports.types = exports.setConcurrency = exports.disableTypes = exports.disableFS = exports.imageSize = void 0;
> 4 | const fs = require("fs");
    |            ^
  5 | const path = require("path");
  6 | const queue_1 = require("queue");
  7 | const index_1 = require("./types/index");

https://nextjs.org/docs/messages/module-not-found

Import trace for requested module:
./node_modules/.pnpm/payload@3.13.0_graphql@16.10.0_monaco-editor@0.52.2_react-dom@19.0.0_react@19.0.0__react@19.0.0_typescript@5.7.2/node_modules/payload/dist/uploads/getImageSize.js
./node_modules/.pnpm/payload@3.13.0_graphql@16.10.0_monaco-editor@0.52.2_react-dom@19.0.0_react@19.0.0__react@19.0.0_typescript@5.7.2/node_modules/payload/dist/uploads/generateFileData.js
./node_modules/.pnpm/payload@3.13.0_graphql@16.10.0_monaco-editor@0.52.2_react-dom@19.0.0_react@19.0.0__react@19.0.0_typescript@5.7.2/node_modules/payload/dist/collections/operations/create.js
./node_modules/.pnpm/payload@3.13.0_graphql@16.10.0_monaco-editor@0.52.2_react-dom@19.0.0_react@19.0.0__react@19.0.0_typescript@5.7.2/node_modules/payload/dist/index.js
./node_modules/.pnpm/@payloadcms+richtext-lexical@3.13.0_g2oe2h3l6niypvuubtbjxgztr4/node_modules/@payloadcms/richtext-lexical/dist/index.js
./node_modules/.pnpm/payloadcms-lexical-ext@0.5.2_@lexical+table@0.20.0_@payloadcms+richtext-lexical@3.13.0_g2oe2h_33jt6tmzf3a5t7yitaxgvj5vyq/node_modules/payloadcms-lexical-ext/build/index.js
./src/components/RichText/index.tsx
./src/blocks/Form/Component.tsx```

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants