Simplify your stack and build anything. Or everything.
Build tomorrow’s web with a modern solution you truly own.
Code-based nature means you can build on top of it to power anything.
It’s time to take back your content infrastructure.

Lexical features not working

default discord avatar
catfive6644last year
6

I'm trying to modify the features available in Lexical and not seeing expected results:


- As expected, removing

defaultFeatures

correctly removes all features


- Including a simple additional one, like

FixedToolbarFeature

, does

not

render the fixed toolbar


- Including

BlocksFeature

also has no effect



There is very little going on in this new, proof-of-concept Payload installation... what might be wrong?



export const Pages: CollectionConfig = {
  slug: 'pages',
  admin: {
    useAsTitle: 'name',
    group: 'Site',
  },
  fields: [
    {
      name: 'name',
      type: 'text',
    },
    {
      name: 'test',
      type: 'richText',
      editor: lexicalEditor({
        features: ({ defaultFeatures }) => [
          ...defaultFeatures,
          BlocksFeature({
             blocks: [TextBlurbBlock],
           }),
          FixedToolbarFeature(),
        ],
      }),
    },
    ...
  • discord user avatar
    alessiogr
    last year

    what Payload version are you using? Could you share the repo?

  • default discord avatar
    catfive6644last year
    @360823574644129795

    i'm on 3.19. i haven't published this repo yet as I'm only evaluating payload



    the payload config is totally stock aside from my collections

  • discord user avatar
    alessiogr
    last year

    I would test this on 3.27.0 - it definitely works fine for me there

  • default discord avatar
    catfive6644last year

    I solved this. The issue was that my types and/or import map were out of date.



    These had started to drift because I:


    - Configured a field to use a custom component, which I later relocated without updating the config


    - Installed postcss and started sprinkling css module imports throughout the code, which upset the type generator



    I still need to figure out how to make the generator play well with postcss, but I at least have my lexical features now.



    I'm a little unclear as to whether payload sometimes/always/never runs the generators automatically. When I first started out it all seemed to work automatically and silently. At some point it started to

    fail

    silently...

  • discord user avatar
    alessiogr
    last year

    Yea I don't think we throw any errors if it fails during runtime. You might only see them if you manually run

    pnpm payload generate:importmap

    .



    Installed postcss and started sprinkling css module imports throughout the code, which upset the type generator

    The reason you're seeing it fail is due to you importing client-only modules (=> css files) into your Payload Config. The payload config is expected to be node-safe, and importing client-only modules is not.



    In order for this to work correctly, you will have to make sure to only import client modules, like css files, from other client files. Those client files can then be imported safely into your Payload Config using string import paths.

  • default discord avatar
    catfive6644last year

    Thanks

    @360823574644129795
Star on GitHub

Star

Chat on Discord

Discord

online

Can't find what you're looking for?

Get dedicated engineering support directly from the Payload team.