create-nextblock 0.2.30 → 0.2.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/scripts/sync-template.js +70 -52
- package/templates/nextblock-template/app/[slug]/page.tsx +55 -55
- package/templates/nextblock-template/app/cms/blocks/actions.ts +15 -15
- package/templates/nextblock-template/app/cms/blocks/components/BackgroundSelector.tsx +14 -12
- package/templates/nextblock-template/app/cms/blocks/components/BlockEditorArea.tsx +24 -21
- package/templates/nextblock-template/app/cms/blocks/components/BlockEditorModal.tsx +1 -1
- package/templates/nextblock-template/app/cms/blocks/components/ColumnEditor.tsx +42 -24
- package/templates/nextblock-template/app/cms/blocks/components/EditableBlock.tsx +16 -16
- package/templates/nextblock-template/app/cms/blocks/editors/SectionBlockEditor.tsx +56 -35
- package/templates/nextblock-template/app/cms/blocks/editors/TextBlockEditor.tsx +1 -1
- package/templates/nextblock-template/app/cms/media/actions.ts +47 -47
- package/templates/nextblock-template/app/cms/media/components/MediaGridClient.tsx +3 -3
- package/templates/nextblock-template/app/cms/media/components/MediaUploadForm.tsx +1 -1
- package/templates/nextblock-template/app/cms/media/page.tsx +3 -3
- package/templates/nextblock-template/app/cms/revisions/JsonDiffView.tsx +8 -7
- package/templates/nextblock-template/app/cms/revisions/RevisionHistoryButton.tsx +16 -10
- package/templates/nextblock-template/app/cms/revisions/service.ts +9 -9
- package/templates/nextblock-template/app/cms/settings/extra-translations/actions.ts +1 -1
- package/templates/nextblock-template/app/cms/settings/logos/[id]/edit/page.tsx +1 -0
- package/templates/nextblock-template/eslint.config.mjs +14 -10
- package/templates/nextblock-template/lib/blocks/blockRegistry.ts +29 -29
- package/templates/nextblock-template/package.json +5 -3
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
import { createClient } from "@nextblock-cms/db/server";
|
|
5
5
|
import type { Json } from "@nextblock-cms/db";
|
|
6
|
-
import { compare, applyPatch } from 'fast-json-patch';
|
|
6
|
+
import { compare, applyPatch, type Operation } from 'fast-json-patch';
|
|
7
7
|
import type { FullPageContent, FullPostContent } from './utils';
|
|
8
8
|
|
|
9
9
|
|
|
@@ -120,8 +120,8 @@ export async function restorePageToVersion(pageId: number, targetVersion: number
|
|
|
120
120
|
|
|
121
121
|
for (const r of diffs || []) {
|
|
122
122
|
if (r.revision_type === 'diff') {
|
|
123
|
-
const ops = r.content as
|
|
124
|
-
const result = applyPatch(content as
|
|
123
|
+
const ops = r.content as unknown as Operation[];
|
|
124
|
+
const result = applyPatch(content as unknown as Record<string, unknown>, ops, /*validate*/ false, /*mutateDocument*/ true);
|
|
125
125
|
content = result.newDocument as unknown as FullPageContent;
|
|
126
126
|
} else {
|
|
127
127
|
content = r.content as unknown as FullPageContent;
|
|
@@ -208,8 +208,8 @@ export async function restorePostToVersion(postId: number, targetVersion: number
|
|
|
208
208
|
|
|
209
209
|
for (const r of diffs || []) {
|
|
210
210
|
if (r.revision_type === 'diff') {
|
|
211
|
-
const ops = r.content as
|
|
212
|
-
const result = applyPatch(content as
|
|
211
|
+
const ops = r.content as unknown as Operation[];
|
|
212
|
+
const result = applyPatch(content as unknown as Record<string, unknown>, ops, /*validate*/ false, /*mutateDocument*/ true);
|
|
213
213
|
content = result.newDocument as unknown as FullPostContent;
|
|
214
214
|
} else {
|
|
215
215
|
content = r.content as unknown as FullPostContent;
|
|
@@ -296,8 +296,8 @@ export async function reconstructPageVersionContent(pageId: number, targetVersio
|
|
|
296
296
|
|
|
297
297
|
for (const r of diffs || []) {
|
|
298
298
|
if (r.revision_type === 'diff') {
|
|
299
|
-
const ops = r.content as
|
|
300
|
-
const result = applyPatch(content as
|
|
299
|
+
const ops = r.content as unknown as Operation[];
|
|
300
|
+
const result = applyPatch(content as unknown as Record<string, unknown>, ops, false, true);
|
|
301
301
|
content = result.newDocument as unknown as FullPageContent;
|
|
302
302
|
} else {
|
|
303
303
|
content = r.content as unknown as FullPageContent;
|
|
@@ -333,8 +333,8 @@ export async function reconstructPostVersionContent(postId: number, targetVersio
|
|
|
333
333
|
|
|
334
334
|
for (const r of diffs || []) {
|
|
335
335
|
if (r.revision_type === 'diff') {
|
|
336
|
-
const ops = r.content as
|
|
337
|
-
const result = applyPatch(content as
|
|
336
|
+
const ops = r.content as unknown as Operation[];
|
|
337
|
+
const result = applyPatch(content as unknown as Record<string, unknown>, ops, false, true);
|
|
338
338
|
content = result.newDocument as unknown as FullPostContent;
|
|
339
339
|
} else {
|
|
340
340
|
content = r.content as unknown as FullPostContent;
|
|
@@ -59,7 +59,7 @@ export async function getTranslations() {
|
|
|
59
59
|
|
|
60
60
|
export async function updateTranslation(prevState: unknown, formData: FormData) {
|
|
61
61
|
const supabase = createClient();
|
|
62
|
-
const data = Object.fromEntries(formData
|
|
62
|
+
const data = Object.fromEntries(formData.entries());
|
|
63
63
|
const key = data.key as string;
|
|
64
64
|
|
|
65
65
|
if (!key) {
|
|
@@ -13,6 +13,7 @@ export default async function EditLogoPage(props: { params: Promise<{ id: string
|
|
|
13
13
|
return (
|
|
14
14
|
<div>
|
|
15
15
|
<h1 className="text-2xl font-semibold mb-6">Edit Logo</h1>
|
|
16
|
+
{/* eslint-disable-next-line @typescript-eslint/no-explicit-any */}
|
|
16
17
|
<LogoForm logo={logo} action={updateLogo as any} />
|
|
17
18
|
</div>
|
|
18
19
|
)
|
|
@@ -1,16 +1,11 @@
|
|
|
1
|
-
import nx from '@nx/eslint-plugin';
|
|
2
1
|
import nextPlugin from '@next/eslint-plugin-next';
|
|
3
|
-
|
|
4
|
-
const nextRules = {
|
|
5
|
-
...nextPlugin.configs.recommended.rules,
|
|
6
|
-
...nextPlugin.configs['core-web-vitals'].rules,
|
|
7
|
-
};
|
|
2
|
+
import tseslint from 'typescript-eslint';
|
|
8
3
|
|
|
9
4
|
const config = [
|
|
10
|
-
...nx.configs['flat/react-typescript'],
|
|
11
5
|
{
|
|
12
|
-
ignores: ['.next/**/*', '**/next-env.d.ts', '
|
|
6
|
+
ignores: ['.next/**/*', '**/next-env.d.ts', 'next-env.d.ts'],
|
|
13
7
|
},
|
|
8
|
+
...tseslint.configs.recommended,
|
|
14
9
|
{
|
|
15
10
|
files: [
|
|
16
11
|
'**/*.ts',
|
|
@@ -20,12 +15,21 @@ const config = [
|
|
|
20
15
|
'**/*.mjs',
|
|
21
16
|
'**/*.cjs',
|
|
22
17
|
],
|
|
18
|
+
languageOptions: {
|
|
19
|
+
parserOptions: {
|
|
20
|
+
project: true,
|
|
21
|
+
tsconfigRootDir: import.meta.dirname,
|
|
22
|
+
},
|
|
23
|
+
},
|
|
23
24
|
plugins: {
|
|
24
25
|
'@next/next': nextPlugin,
|
|
25
26
|
},
|
|
26
27
|
rules: {
|
|
27
|
-
...
|
|
28
|
-
'
|
|
28
|
+
...nextPlugin.configs.recommended.rules,
|
|
29
|
+
...nextPlugin.configs['core-web-vitals'].rules,
|
|
30
|
+
'@next/next/no-html-link-for-pages': 'off',
|
|
31
|
+
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
|
|
32
|
+
'@typescript-eslint/no-explicit-any': 'warn',
|
|
29
33
|
},
|
|
30
34
|
},
|
|
31
35
|
];
|
|
@@ -117,21 +117,21 @@ export interface SectionBlockContent {
|
|
|
117
117
|
solid_color?: string;
|
|
118
118
|
min_height?: string;
|
|
119
119
|
gradient?: Gradient;
|
|
120
|
-
image?: {
|
|
121
|
-
media_id: string;
|
|
122
|
-
object_key: string;
|
|
123
|
-
alt_text?: string;
|
|
124
|
-
width?: number;
|
|
125
|
-
height?: number;
|
|
126
|
-
blur_data_url?: string;
|
|
127
|
-
size: 'cover' | 'contain';
|
|
128
|
-
position: 'center' | 'top' | 'bottom' | 'left' | 'right';
|
|
129
|
-
quality?: number | null;
|
|
130
|
-
overlay?: {
|
|
131
|
-
type: 'gradient';
|
|
132
|
-
gradient: Gradient;
|
|
133
|
-
};
|
|
134
|
-
};
|
|
120
|
+
image?: {
|
|
121
|
+
media_id: string;
|
|
122
|
+
object_key: string;
|
|
123
|
+
alt_text?: string;
|
|
124
|
+
width?: number;
|
|
125
|
+
height?: number;
|
|
126
|
+
blur_data_url?: string;
|
|
127
|
+
size: 'cover' | 'contain';
|
|
128
|
+
position: 'center' | 'top' | 'bottom' | 'left' | 'right';
|
|
129
|
+
quality?: number | null;
|
|
130
|
+
overlay?: {
|
|
131
|
+
type: 'gradient';
|
|
132
|
+
gradient: Gradient;
|
|
133
|
+
};
|
|
134
|
+
};
|
|
135
135
|
};
|
|
136
136
|
/** Responsive column configuration */
|
|
137
137
|
responsive_columns: {
|
|
@@ -149,7 +149,7 @@ export interface SectionBlockContent {
|
|
|
149
149
|
/** Array of blocks within columns - 2D array where each index represents a column */
|
|
150
150
|
column_blocks: Array<Array<{
|
|
151
151
|
block_type: BlockType;
|
|
152
|
-
content: Record<string,
|
|
152
|
+
content: Record<string, unknown>;
|
|
153
153
|
temp_id?: string; // For client-side management before save
|
|
154
154
|
}>>;
|
|
155
155
|
}
|
|
@@ -211,7 +211,7 @@ export interface ContentPropertyDefinition {
|
|
|
211
211
|
/** Human-readable description of the property */
|
|
212
212
|
description?: string;
|
|
213
213
|
/** Default value for the property */
|
|
214
|
-
default?:
|
|
214
|
+
default?: unknown;
|
|
215
215
|
/** For union types, the possible values */
|
|
216
216
|
unionValues?: readonly string[];
|
|
217
217
|
/** For array types, the type of array elements */
|
|
@@ -221,7 +221,7 @@ export interface ContentPropertyDefinition {
|
|
|
221
221
|
min?: number;
|
|
222
222
|
max?: number;
|
|
223
223
|
pattern?: string;
|
|
224
|
-
enum?: readonly
|
|
224
|
+
enum?: readonly unknown[];
|
|
225
225
|
};
|
|
226
226
|
}
|
|
227
227
|
|
|
@@ -229,7 +229,7 @@ export interface ContentPropertyDefinition {
|
|
|
229
229
|
* Enhanced block definition interface with generic type parameter
|
|
230
230
|
* Links the TypeScript interface to the block definition for better type safety
|
|
231
231
|
*/
|
|
232
|
-
export interface BlockDefinition<T =
|
|
232
|
+
export interface BlockDefinition<T = unknown> {
|
|
233
233
|
/** The unique identifier for the block type */
|
|
234
234
|
type: BlockType;
|
|
235
235
|
/** User-friendly display name for the block */
|
|
@@ -799,7 +799,7 @@ export function getBlockDefinition(blockType: BlockType): BlockDefinition | unde
|
|
|
799
799
|
* @param blockType - The type of block to get initial content for
|
|
800
800
|
* @returns The initial content object or undefined if block type not found
|
|
801
801
|
*/
|
|
802
|
-
export function getInitialContent(blockType: BlockType):
|
|
802
|
+
export function getInitialContent(blockType: BlockType): unknown {
|
|
803
803
|
return blockRegistry[blockType]?.initialContent;
|
|
804
804
|
}
|
|
805
805
|
|
|
@@ -870,7 +870,7 @@ export type AllBlockContent =
|
|
|
870
870
|
*/
|
|
871
871
|
export function validateBlockContent(
|
|
872
872
|
blockType: BlockType,
|
|
873
|
-
content: Record<string,
|
|
873
|
+
content: Record<string, unknown>
|
|
874
874
|
): {
|
|
875
875
|
isValid: boolean;
|
|
876
876
|
errors: string[];
|
|
@@ -972,9 +972,9 @@ export function getRequiredProperties(blockType: BlockType): string[] {
|
|
|
972
972
|
const schema = getContentSchema(blockType);
|
|
973
973
|
if (!schema) return [];
|
|
974
974
|
|
|
975
|
-
return Object.entries(schema)
|
|
976
|
-
.filter(([, def]) => def.required)
|
|
977
|
-
.map(([name]) => name);
|
|
975
|
+
return Object.entries(schema)
|
|
976
|
+
.filter(([, def]) => def.required)
|
|
977
|
+
.map(([name]) => name);
|
|
978
978
|
}
|
|
979
979
|
|
|
980
980
|
/**
|
|
@@ -984,13 +984,13 @@ export function getRequiredProperties(blockType: BlockType): string[] {
|
|
|
984
984
|
* @param blockType - The type of block
|
|
985
985
|
* @returns Complete default content object
|
|
986
986
|
*/
|
|
987
|
-
export function generateDefaultContent(blockType: BlockType): Record<string,
|
|
987
|
+
export function generateDefaultContent(blockType: BlockType): Record<string, unknown> {
|
|
988
988
|
const schema = getContentSchema(blockType);
|
|
989
|
-
const initialContent = getInitialContent(blockType) || {};
|
|
989
|
+
const initialContent = getInitialContent(blockType) || ({} as Record<string, unknown>);
|
|
990
990
|
|
|
991
|
-
if (!schema) return initialContent
|
|
991
|
+
if (!schema) return initialContent as Record<string, unknown>;
|
|
992
992
|
|
|
993
|
-
const defaultContent: Record<string,
|
|
993
|
+
const defaultContent: Record<string, unknown> = { ...(initialContent as Record<string, unknown>) };
|
|
994
994
|
|
|
995
995
|
for (const [propertyName, propertyDef] of Object.entries(schema)) {
|
|
996
996
|
if (defaultContent[propertyName] === undefined && propertyDef.default !== undefined) {
|
|
@@ -999,4 +999,4 @@ export function generateDefaultContent(blockType: BlockType): Record<string, any
|
|
|
999
999
|
}
|
|
1000
1000
|
|
|
1001
1001
|
return defaultContent;
|
|
1002
|
-
}
|
|
1002
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nextblock-cms/template",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.11",
|
|
4
4
|
"private": true,
|
|
5
5
|
"scripts": {
|
|
6
6
|
"dev": "next dev",
|
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
"lint": "next lint"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@aws-sdk/client-s3": "^3.
|
|
12
|
+
"@aws-sdk/client-s3": "^3.920.0",
|
|
13
|
+
"@aws-sdk/s3-request-presigner": "^3.920.0",
|
|
13
14
|
"@dnd-kit/core": "^6.3.1",
|
|
14
15
|
"@dnd-kit/sortable": "^10.0.0",
|
|
15
16
|
"@dnd-kit/utilities": "^3.2.2",
|
|
@@ -47,6 +48,7 @@
|
|
|
47
48
|
"eslint-config-next": "^15.5.4",
|
|
48
49
|
"postcss": "^8.4.38",
|
|
49
50
|
"tailwindcss": "^3.4.3",
|
|
50
|
-
"typescript": "~5.8.2"
|
|
51
|
+
"typescript": "~5.8.2",
|
|
52
|
+
"typescript-eslint": "^8.0.0"
|
|
51
53
|
}
|
|
52
54
|
}
|