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

feat(Ghost Node): Add support for lexical format #7488

Merged
merged 5 commits into from
Oct 23, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
17 changes: 17 additions & 0 deletions packages/nodes-base/nodes/Ghost/Ghost.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,14 @@ export class Ghost implements INodeType {
if (contentFormat === 'html') {
post.html = content;
qs.source = 'html';
} else if (contentFormat === 'lexical') {
const lexical = validateJSON(content);
if (lexical === undefined) {
throw new NodeOperationError(this.getNode(), 'Content must be a valid JSON', {
itemIndex: i,
});
}
post.lexical = content;
} else {
const mobileDoc = validateJSON(content);
if (mobileDoc === undefined) {
Expand Down Expand Up @@ -293,6 +301,15 @@ export class Ghost implements INodeType {
post.html = updateFields.content || '';
qs.source = 'html';
delete updateFields.content;
} else if (contentFormat === 'lexical') {
const lexical = validateJSON((updateFields.contentJson as string) || undefined);
if (lexical === undefined) {
throw new NodeOperationError(this.getNode(), 'Content must be a valid JSON', {
itemIndex: i,
});
}
post.lexical = updateFields.contentJson;
delete updateFields.contentJson;
} else {
const mobileDoc = validateJSON((updateFields.contentJson as string) || undefined);
if (mobileDoc === undefined) {
Expand Down
48 changes: 48 additions & 0 deletions packages/nodes-base/nodes/Ghost/PostDescription.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ export const postFields: INodeProperties[] = [
name: 'Mobile Doc',
value: 'mobileDoc',
},
{
name: 'Lexical',
value: 'lexical',
},
],
default: 'html',
description: 'The format of the post',
Expand Down Expand Up @@ -150,6 +154,22 @@ export const postFields: INodeProperties[] = [
description:
'Mobiledoc is the raw JSON format that Ghost uses to store post contents. <a href="https://ghost.org/docs/concepts/posts/#document-storage">Info</a>.',
},
{
displayName: 'Content (JSON)',
name: 'content',
type: 'json',
displayOptions: {
show: {
source: ['adminApi'],
resource: ['post'],
operation: ['create'],
contentFormat: ['lexical'],
},
},

default: '',
description: 'Lexical is the JSON format returned by the Ghost Default editor',
},
{
displayName: 'Additional Fields',
name: 'additionalFields',
Expand Down Expand Up @@ -395,6 +415,10 @@ export const postFields: INodeProperties[] = [
name: 'Mobile Doc',
value: 'mobiledoc',
},
{
name: 'Lexical',
value: 'lexical',
},
],
default: ['mobiledoc'],
},
Expand Down Expand Up @@ -532,6 +556,10 @@ export const postFields: INodeProperties[] = [
name: 'Plaintext',
value: 'plaintext',
},
{
name: 'Lexical',
value: 'lexical',
},
],
default: ['html'],
description:
Expand Down Expand Up @@ -593,6 +621,10 @@ export const postFields: INodeProperties[] = [
name: 'Mobile Doc',
value: 'mobiledoc',
},
{
name: 'Lexical',
value: 'lexical',
},
],
default: ['mobiledoc'],
},
Expand Down Expand Up @@ -636,6 +668,10 @@ export const postFields: INodeProperties[] = [
name: 'Mobile Doc',
value: 'mobileDoc',
},
{
name: 'Lexical',
value: 'lexical',
},
],
default: 'html',
description: 'The format of the post',
Expand Down Expand Up @@ -707,6 +743,18 @@ export const postFields: INodeProperties[] = [
description:
'Mobiledoc is the raw JSON format that Ghost uses to store post contents. <a href="https://ghost.org/docs/concepts/posts/#document-storage">Info.</a>.',
},
{
displayName: 'Content (JSON)',
name: 'contentJson',
type: 'json',
displayOptions: {
show: {
'/contentFormat': ['lexical'],
},
},
default: '',
description: 'Lexical is the JSON format returned by the Ghost Default editor',
},
{
displayName: 'Featured',
name: 'featured',
Expand Down