Skip to content

Commit

Permalink
enrich lexical features and improve visibility
Browse files Browse the repository at this point in the history
  • Loading branch information
rccsousa committed Oct 21, 2024
1 parent 6de2a24 commit 098c5ad
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 34 deletions.
66 changes: 34 additions & 32 deletions src/app/(payload)/admin/importMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,23 @@ import { MetaImageComponent as MetaImageComponent_12 } from '@payloadcms/plugin-
import { MetaDescriptionComponent as MetaDescriptionComponent_13 } from '@payloadcms/plugin-seo/client'
import { PreviewComponent as PreviewComponent_14 } from '@payloadcms/plugin-seo/client'
import { HorizontalRuleFeatureClient as HorizontalRuleFeatureClient_15 } from '@payloadcms/richtext-lexical/client'
import { UploadFeatureClient as UploadFeatureClient_16 } from '@payloadcms/richtext-lexical/client'
import { BlockquoteFeatureClient as BlockquoteFeatureClient_17 } from '@payloadcms/richtext-lexical/client'
import { RelationshipFeatureClient as RelationshipFeatureClient_18 } from '@payloadcms/richtext-lexical/client'
import { ChecklistFeatureClient as ChecklistFeatureClient_19 } from '@payloadcms/richtext-lexical/client'
import { OrderedListFeatureClient as OrderedListFeatureClient_20 } from '@payloadcms/richtext-lexical/client'
import { UnorderedListFeatureClient as UnorderedListFeatureClient_21 } from '@payloadcms/richtext-lexical/client'
import { IndentFeatureClient as IndentFeatureClient_22 } from '@payloadcms/richtext-lexical/client'
import { AlignFeatureClient as AlignFeatureClient_23 } from '@payloadcms/richtext-lexical/client'
import { HeadingFeatureClient as HeadingFeatureClient_24 } from '@payloadcms/richtext-lexical/client'
import { ParagraphFeatureClient as ParagraphFeatureClient_25 } from '@payloadcms/richtext-lexical/client'
import { InlineCodeFeatureClient as InlineCodeFeatureClient_26 } from '@payloadcms/richtext-lexical/client'
import { SuperscriptFeatureClient as SuperscriptFeatureClient_27 } from '@payloadcms/richtext-lexical/client'
import { SubscriptFeatureClient as SubscriptFeatureClient_28 } from '@payloadcms/richtext-lexical/client'
import { StrikethroughFeatureClient as StrikethroughFeatureClient_29 } from '@payloadcms/richtext-lexical/client'
import { default as default_30 } from '@/components/BeforeDashboard'
import { default as default_31 } from '@/components/BeforeLogin'
import { BlocksFeatureClient as BlocksFeatureClient_16 } from '@payloadcms/richtext-lexical/client'
import { HeadingFeatureClient as HeadingFeatureClient_17 } from '@payloadcms/richtext-lexical/client'
import { UploadFeatureClient as UploadFeatureClient_18 } from '@payloadcms/richtext-lexical/client'
import { BlockquoteFeatureClient as BlockquoteFeatureClient_19 } from '@payloadcms/richtext-lexical/client'
import { RelationshipFeatureClient as RelationshipFeatureClient_20 } from '@payloadcms/richtext-lexical/client'
import { ChecklistFeatureClient as ChecklistFeatureClient_21 } from '@payloadcms/richtext-lexical/client'
import { OrderedListFeatureClient as OrderedListFeatureClient_22 } from '@payloadcms/richtext-lexical/client'
import { UnorderedListFeatureClient as UnorderedListFeatureClient_23 } from '@payloadcms/richtext-lexical/client'
import { IndentFeatureClient as IndentFeatureClient_24 } from '@payloadcms/richtext-lexical/client'
import { AlignFeatureClient as AlignFeatureClient_25 } from '@payloadcms/richtext-lexical/client'
import { ParagraphFeatureClient as ParagraphFeatureClient_26 } from '@payloadcms/richtext-lexical/client'
import { InlineCodeFeatureClient as InlineCodeFeatureClient_27 } from '@payloadcms/richtext-lexical/client'
import { SuperscriptFeatureClient as SuperscriptFeatureClient_28 } from '@payloadcms/richtext-lexical/client'
import { SubscriptFeatureClient as SubscriptFeatureClient_29 } from '@payloadcms/richtext-lexical/client'
import { StrikethroughFeatureClient as StrikethroughFeatureClient_30 } from '@payloadcms/richtext-lexical/client'
import { default as default_31 } from '@/components/BeforeDashboard'
import { default as default_32 } from '@/components/BeforeLogin'

export const importMap = {
"@payloadcms/richtext-lexical/client#RichTextCell": RichTextCell_0,
Expand All @@ -48,20 +49,21 @@ export const importMap = {
"@payloadcms/plugin-seo/client#MetaDescriptionComponent": MetaDescriptionComponent_13,
"@payloadcms/plugin-seo/client#PreviewComponent": PreviewComponent_14,
"@payloadcms/richtext-lexical/client#HorizontalRuleFeatureClient": HorizontalRuleFeatureClient_15,
"@payloadcms/richtext-lexical/client#UploadFeatureClient": UploadFeatureClient_16,
"@payloadcms/richtext-lexical/client#BlockquoteFeatureClient": BlockquoteFeatureClient_17,
"@payloadcms/richtext-lexical/client#RelationshipFeatureClient": RelationshipFeatureClient_18,
"@payloadcms/richtext-lexical/client#ChecklistFeatureClient": ChecklistFeatureClient_19,
"@payloadcms/richtext-lexical/client#OrderedListFeatureClient": OrderedListFeatureClient_20,
"@payloadcms/richtext-lexical/client#UnorderedListFeatureClient": UnorderedListFeatureClient_21,
"@payloadcms/richtext-lexical/client#IndentFeatureClient": IndentFeatureClient_22,
"@payloadcms/richtext-lexical/client#AlignFeatureClient": AlignFeatureClient_23,
"@payloadcms/richtext-lexical/client#HeadingFeatureClient": HeadingFeatureClient_24,
"@payloadcms/richtext-lexical/client#ParagraphFeatureClient": ParagraphFeatureClient_25,
"@payloadcms/richtext-lexical/client#InlineCodeFeatureClient": InlineCodeFeatureClient_26,
"@payloadcms/richtext-lexical/client#SuperscriptFeatureClient": SuperscriptFeatureClient_27,
"@payloadcms/richtext-lexical/client#SubscriptFeatureClient": SubscriptFeatureClient_28,
"@payloadcms/richtext-lexical/client#StrikethroughFeatureClient": StrikethroughFeatureClient_29,
"@/components/BeforeDashboard#default": default_30,
"@/components/BeforeLogin#default": default_31
"@payloadcms/richtext-lexical/client#BlocksFeatureClient": BlocksFeatureClient_16,
"@payloadcms/richtext-lexical/client#HeadingFeatureClient": HeadingFeatureClient_17,
"@payloadcms/richtext-lexical/client#UploadFeatureClient": UploadFeatureClient_18,
"@payloadcms/richtext-lexical/client#BlockquoteFeatureClient": BlockquoteFeatureClient_19,
"@payloadcms/richtext-lexical/client#RelationshipFeatureClient": RelationshipFeatureClient_20,
"@payloadcms/richtext-lexical/client#ChecklistFeatureClient": ChecklistFeatureClient_21,
"@payloadcms/richtext-lexical/client#OrderedListFeatureClient": OrderedListFeatureClient_22,
"@payloadcms/richtext-lexical/client#UnorderedListFeatureClient": UnorderedListFeatureClient_23,
"@payloadcms/richtext-lexical/client#IndentFeatureClient": IndentFeatureClient_24,
"@payloadcms/richtext-lexical/client#AlignFeatureClient": AlignFeatureClient_25,
"@payloadcms/richtext-lexical/client#ParagraphFeatureClient": ParagraphFeatureClient_26,
"@payloadcms/richtext-lexical/client#InlineCodeFeatureClient": InlineCodeFeatureClient_27,
"@payloadcms/richtext-lexical/client#SuperscriptFeatureClient": SuperscriptFeatureClient_28,
"@payloadcms/richtext-lexical/client#SubscriptFeatureClient": SubscriptFeatureClient_29,
"@payloadcms/richtext-lexical/client#StrikethroughFeatureClient": StrikethroughFeatureClient_30,
"@/components/BeforeDashboard#default": default_31,
"@/components/BeforeLogin#default": default_32
}
6 changes: 6 additions & 0 deletions src/app/(payload)/custom.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.rich-text-lexical * {
max-width: 600px;
margin: 0 auto;
line-height: 2em;
}

13 changes: 11 additions & 2 deletions src/collections/Blogposts/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { HTMLConverterFeature, lexicalEditor, lexicalHTML } from "@payloadcms/richtext-lexical";
import { BlocksFeature, FixedToolbarFeature, HeadingFeature, HorizontalRuleFeature, HTMLConverterFeature, InlineToolbarFeature, lexicalEditor, lexicalHTML } from "@payloadcms/richtext-lexical";
import type { CollectionConfig } from "payload";

import { slugField } from "@/fields/slug";
Expand All @@ -14,6 +14,8 @@ import {
PreviewField,
} from "@payloadcms/plugin-seo/fields";
import { generatePreviewPath } from "@/utilities/generatePreviewPath";
import { Banner } from "@payloadcms/ui/elements/Banner";
import { Code } from "@/blocks/Code/config";

export const Blogposts: CollectionConfig = {
slug: "blogposts",
Expand Down Expand Up @@ -73,7 +75,14 @@ export const Blogposts: CollectionConfig = {
type: "richText",
required: true,
editor: lexicalEditor({
features: ({ defaultFeatures }) => [...defaultFeatures, HTMLConverterFeature({})],
features: ({ defaultFeatures }) => [
...defaultFeatures,
HeadingFeature({ enabledHeadingSizes: ["h1", "h2", "h3", "h4"] }),
BlocksFeature({ blocks: [Code] }),
FixedToolbarFeature(),
InlineToolbarFeature(),
HorizontalRuleFeature(),
HTMLConverterFeature({})],
}),
},
lexicalHTML("content", { name: "content_html" }),
Expand Down
11 changes: 11 additions & 0 deletions src/payload-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,17 @@ export interface HomepageSetting {
updatedAt?: string | null;
createdAt?: string | null;
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "CodeBlock".
*/
export interface CodeBlock {
language?: ('typescript' | 'javascript' | 'css') | null;
code: string;
id?: string | null;
blockName?: string | null;
blockType: 'code';
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "auth".
Expand Down

0 comments on commit 098c5ad

Please sign in to comment.