Skip to content
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/polite-schools-unite.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"nextjs-website": minor
---

Add parsing for ckeditorhtml parts
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,8 @@ export const ckEditorPart: StrapiPart = {
__component: 'parts.ck-editor',
content: '<p>CKEditor content</p>',
};

export const ckEditorHtmlPart: StrapiPart = {
__component: 'parts.ck-editor-html',
content: '<p>CKEditor HTML content</p>',
};
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
embedHtmlPart,
quotePart,
ckEditorPart,
ckEditorHtmlPart,
} from '@/lib/strapi/__tests__/fixtures/parts';
import {
minimalAlertPart,
Expand Down Expand Up @@ -107,6 +108,13 @@ describe('makePartProps', () => {
expect(result).toHaveProperty('menuItems');
});

it('should transform ck-editor-html part', () => {
const result = makePartProps(ckEditorHtmlPart);
expect(result).toHaveProperty('component', 'ckEditor');
expect(result).toHaveProperty('content');
expect(result).toHaveProperty('menuItems');
});

it('should return null for unknown part type', () => {
const result = makePartProps({ __component: 'parts.unknown' } as any);
expect(result).toBeNull();
Expand Down
9 changes: 9 additions & 0 deletions apps/nextjs-website/src/lib/strapi/makeProps/makePart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,15 @@ export function makePartProps(strapiPart: StrapiPart): Part | null {
content: parsedContent,
menuItems: [...menuItems],
};
case 'parts.ck-editor-html':
// eslint-disable-next-line no-case-declarations
// eslint-disable-next-line no-case-declarations
const parsedHtmlContent = parseCkEditorContent(strapiPart.content);
return {
component: 'ckEditor',
content: parsedHtmlContent.parsedContent,
menuItems: [...parsedHtmlContent.menuItems],
};
default:
return null;
}
Expand Down
8 changes: 7 additions & 1 deletion apps/nextjs-website/src/lib/strapi/types/part.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ type CkEditorPart = {
readonly __component: 'parts.ck-editor';
};

type CkEditorHtmlPart = {
readonly content: string;
readonly __component: 'parts.ck-editor-html';
};

type CodeBlockPart = {
readonly code: string;
readonly language?: string;
Expand Down Expand Up @@ -59,4 +64,5 @@ export type StrapiPart =
| CodeBlockPart
| EmbedHtmlPart
| HtmlPart
| QuotePart;
| QuotePart
| CkEditorHtmlPart;
Loading