690503:1340 Update workflow #05
This commit is contained in:
@@ -17,6 +17,9 @@
|
|||||||
# production
|
# production
|
||||||
/build
|
/build
|
||||||
|
|
||||||
|
# Generated Monaco Editor self-hosted assets (สร้างใหม่อัตโนมัติจาก npm postinstall)
|
||||||
|
/public/monaco-vs
|
||||||
|
|
||||||
# misc
|
# misc
|
||||||
.DS_Store
|
.DS_Store
|
||||||
*.pem
|
*.pem
|
||||||
|
|||||||
@@ -15,6 +15,10 @@ vi.mock('@monaco-editor/react', () => ({
|
|||||||
onChange={(e) => onChange?.(e.target.value)}
|
onChange={(e) => onChange?.(e.target.value)}
|
||||||
/>
|
/>
|
||||||
),
|
),
|
||||||
|
// เพิ่ม loader mock เพื่อรองรับ loader.config() call ใน dsl-editor.tsx
|
||||||
|
loader: {
|
||||||
|
config: vi.fn(),
|
||||||
|
},
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// Mock next-themes
|
// Mock next-themes
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
// File: components/workflows/dsl-editor.tsx
|
||||||
|
// Change Log: 2026-05-03 — แก้ CSP violation โดยเปลี่ยนจาก CDN เป็น self-hosted Monaco assets
|
||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
import { useState, useRef, useEffect } from 'react';
|
import { useState, useRef, useEffect } from 'react';
|
||||||
@@ -5,11 +7,16 @@ import { Button } from '@/components/ui/button';
|
|||||||
import { Card } from '@/components/ui/card';
|
import { Card } from '@/components/ui/card';
|
||||||
import { Alert, AlertDescription } from '@/components/ui/alert';
|
import { Alert, AlertDescription } from '@/components/ui/alert';
|
||||||
import { CheckCircle, AlertCircle, Play, Loader2 } from 'lucide-react';
|
import { CheckCircle, AlertCircle, Play, Loader2 } from 'lucide-react';
|
||||||
import Editor, { OnMount } from '@monaco-editor/react';
|
import Editor, { OnMount, loader } from '@monaco-editor/react';
|
||||||
import { workflowApi } from '@/lib/api/workflows';
|
import { workflowApi } from '@/lib/api/workflows';
|
||||||
import { ValidationResult } from '@/types/workflow';
|
import { ValidationResult } from '@/types/workflow';
|
||||||
import { useTheme } from 'next-themes';
|
import { useTheme } from 'next-themes';
|
||||||
|
|
||||||
|
// กำหนดให้ Monaco โหลด assets จาก self-hosted path แทน cdn.jsdelivr.net
|
||||||
|
// เพื่อผ่าน CSP directive: style-src 'self' 'unsafe-inline'
|
||||||
|
loader.config({ paths: { vs: '/monaco-vs' } });
|
||||||
|
|
||||||
|
|
||||||
interface DSLEditorProps {
|
interface DSLEditorProps {
|
||||||
initialValue?: string;
|
initialValue?: string;
|
||||||
onChange?: (value: string) => void;
|
onChange?: (value: string) => void;
|
||||||
|
|||||||
@@ -12,7 +12,9 @@
|
|||||||
"test": "vitest",
|
"test": "vitest",
|
||||||
"test:watch": "vitest --watch",
|
"test:watch": "vitest --watch",
|
||||||
"test:coverage": "vitest run --coverage",
|
"test:coverage": "vitest run --coverage",
|
||||||
"test:debug": "vitest --inspect-brk --no-file-parallelism"
|
"test:debug": "vitest --inspect-brk --no-file-parallelism",
|
||||||
|
"copy-monaco-assets": "node -e \"const fs=require('fs');const src='node_modules/monaco-editor/min/vs';const dst='public/monaco-vs';if(!fs.existsSync(dst)){fs.cpSync(src,dst,{recursive:true});console.log('Monaco assets copied')}else{console.log('Monaco assets already exist')}\"",
|
||||||
|
"postinstall": "npm run copy-monaco-assets"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@hookform/resolvers": "3.9.0",
|
"@hookform/resolvers": "3.9.0",
|
||||||
|
|||||||
@@ -98,6 +98,8 @@ export default auth((req) => {
|
|||||||
"img-src 'self' blob: data: https:",
|
"img-src 'self' blob: data: https:",
|
||||||
"font-src 'self' data:",
|
"font-src 'self' data:",
|
||||||
`connect-src 'self' ws: wss: ${connectSrcApi}`,
|
`connect-src 'self' ws: wss: ${connectSrcApi}`,
|
||||||
|
// Monaco Editor Web Workers ต้องการ blob: URL สำหรับ inline workers
|
||||||
|
"worker-src 'self' blob:",
|
||||||
"object-src 'none'",
|
"object-src 'none'",
|
||||||
"base-uri 'self'",
|
"base-uri 'self'",
|
||||||
"form-action 'self'",
|
"form-action 'self'",
|
||||||
|
|||||||
Reference in New Issue
Block a user