@nuasite/cms 0.20.1 → 0.20.2
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/dist/editor.js +11246 -11441
- package/package.json +1 -1
- package/src/dev-middleware.ts +14 -4
- package/src/editor/api.ts +0 -251
- package/src/editor/components/markdown-editor-overlay.tsx +7 -26
- package/src/editor/components/toolbar.tsx +0 -75
- package/src/editor/constants.ts +0 -4
- package/src/editor/editor.ts +2 -192
- package/src/editor/hooks/index.ts +0 -3
- package/src/editor/hooks/useBlockEditorHandlers.ts +1 -8
- package/src/editor/hooks/useTooltipState.ts +1 -2
- package/src/editor/index.tsx +2 -18
- package/src/editor/post-message.ts +0 -6
- package/src/editor/signals.ts +0 -166
- package/src/editor/styles.css +0 -108
- package/src/editor/types.ts +0 -66
- package/src/types.ts +0 -4
- package/src/editor/ai.ts +0 -185
- package/src/editor/components/ai-chat.tsx +0 -631
- package/src/editor/components/ai-tooltip.tsx +0 -180
- package/src/editor/hooks/useAIHandlers.ts +0 -345
package/src/editor/editor.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { fetchManifest,
|
|
1
|
+
import { fetchManifest, getMarkdownContent, saveBatchChanges } from './api'
|
|
2
2
|
import { CSS, TIMING } from './constants'
|
|
3
3
|
import {
|
|
4
4
|
cleanupHighlightSystem,
|
|
@@ -33,7 +33,7 @@ import {
|
|
|
33
33
|
saveImageEditsToStorage,
|
|
34
34
|
} from './storage'
|
|
35
35
|
import type { Attribute } from './types'
|
|
36
|
-
import type { AttributeChangePayload, ChangePayload, CmsConfig,
|
|
36
|
+
import type { AttributeChangePayload, ChangePayload, CmsConfig, ManifestEntry, SavedAttributeEdit } from './types'
|
|
37
37
|
|
|
38
38
|
// CSS attribute for markdown content elements
|
|
39
39
|
const MARKDOWN_ATTRIBUTE = 'data-cms-markdown'
|
|
@@ -261,10 +261,6 @@ export async function startEditMode(
|
|
|
261
261
|
const targetId = innermostCms.getAttribute('data-cms-id')
|
|
262
262
|
innermostCms.focus()
|
|
263
263
|
signals.setCurrentEditingId(targetId)
|
|
264
|
-
// Update chat context if chat is open
|
|
265
|
-
if (signals.isChatOpen.value && targetId) {
|
|
266
|
-
signals.setChatContextElement(targetId)
|
|
267
|
-
}
|
|
268
264
|
logDebug(config.debug, 'Click - focusing innermost CMS element:', targetId)
|
|
269
265
|
onStateChange?.()
|
|
270
266
|
}
|
|
@@ -277,10 +273,6 @@ export async function startEditMode(
|
|
|
277
273
|
(e) => {
|
|
278
274
|
if (e.target === el) {
|
|
279
275
|
signals.setCurrentEditingId(cmsId)
|
|
280
|
-
// Update chat context if chat is open
|
|
281
|
-
if (signals.isChatOpen.value && cmsId) {
|
|
282
|
-
signals.setChatContextElement(cmsId)
|
|
283
|
-
}
|
|
284
276
|
logDebug(config.debug, 'Focus on', cmsId)
|
|
285
277
|
onStateChange?.()
|
|
286
278
|
}
|
|
@@ -884,9 +876,6 @@ export async function saveAllChanges(
|
|
|
884
876
|
return { success: false, updated: result.updated, errors: result.errors }
|
|
885
877
|
}
|
|
886
878
|
|
|
887
|
-
// Start polling for deployment status after successful save
|
|
888
|
-
startDeploymentPolling(config)
|
|
889
|
-
|
|
890
879
|
onStateChange?.()
|
|
891
880
|
return { success: true, updated: result.updated }
|
|
892
881
|
} catch (err) {
|
|
@@ -1383,185 +1372,6 @@ export function handleColorChange(
|
|
|
1383
1372
|
onStateChange?.()
|
|
1384
1373
|
}
|
|
1385
1374
|
|
|
1386
|
-
// ============================================================================
|
|
1387
|
-
// Deployment Status Polling
|
|
1388
|
-
// ============================================================================
|
|
1389
|
-
|
|
1390
|
-
const DEPLOYMENT_POLL_INTERVAL_MS = 3000
|
|
1391
|
-
const DEPLOYMENT_SUCCESS_HIDE_DELAY_MS = 5000
|
|
1392
|
-
const DEPLOYMENT_INITIAL_DELAY_MS = 2000
|
|
1393
|
-
const DEPLOYMENT_MAX_WAIT_ATTEMPTS = 10 // Keep polling for up to 30 seconds waiting for deployment to start
|
|
1394
|
-
|
|
1395
|
-
let deploymentPollTimer: ReturnType<typeof setInterval> | null = null
|
|
1396
|
-
let deploymentHideTimer: ReturnType<typeof setTimeout> | null = null
|
|
1397
|
-
let deploymentWaitAttempts = 0
|
|
1398
|
-
let deploymentStartTimestamp: string | null = null
|
|
1399
|
-
let deploymentCallback: ((status: 'completed' | 'failed' | 'timeout') => void) | null = null
|
|
1400
|
-
|
|
1401
|
-
export interface DeploymentPollingOptions {
|
|
1402
|
-
/** Called when deployment completes, fails, or times out */
|
|
1403
|
-
onComplete?: (status: 'completed' | 'failed' | 'timeout') => void
|
|
1404
|
-
}
|
|
1405
|
-
|
|
1406
|
-
/**
|
|
1407
|
-
* Start polling for deployment status after a save operation.
|
|
1408
|
-
* Polls the API every 3 seconds until deployment completes or fails.
|
|
1409
|
-
* Waits for deployment to appear for up to 30 seconds before giving up.
|
|
1410
|
-
* Skips polling entirely when deployment is not available (e.g. local dev).
|
|
1411
|
-
*/
|
|
1412
|
-
export async function startDeploymentPolling(config: CmsConfig, options?: DeploymentPollingOptions): Promise<void> {
|
|
1413
|
-
// Clear any existing timers
|
|
1414
|
-
stopDeploymentPolling()
|
|
1415
|
-
|
|
1416
|
-
// Do a preflight check to see if deployment is available
|
|
1417
|
-
try {
|
|
1418
|
-
const preflight = await getDeploymentStatus(config.apiBase)
|
|
1419
|
-
if (preflight.deploymentEnabled === false) {
|
|
1420
|
-
// Deployment not available (e.g. local dev) — skip polling entirely
|
|
1421
|
-
return
|
|
1422
|
-
}
|
|
1423
|
-
} catch {
|
|
1424
|
-
// If we can't even reach the endpoint, skip polling
|
|
1425
|
-
return
|
|
1426
|
-
}
|
|
1427
|
-
|
|
1428
|
-
// Reset wait attempts counter and store the timestamp when we started
|
|
1429
|
-
deploymentWaitAttempts = 0
|
|
1430
|
-
deploymentStartTimestamp = new Date().toISOString()
|
|
1431
|
-
deploymentCallback = options?.onComplete ?? null
|
|
1432
|
-
|
|
1433
|
-
// Set initial status to indicate deployment started
|
|
1434
|
-
signals.updateDeploymentState({
|
|
1435
|
-
status: 'pending',
|
|
1436
|
-
isPolling: true,
|
|
1437
|
-
error: null,
|
|
1438
|
-
})
|
|
1439
|
-
|
|
1440
|
-
const poll = async () => {
|
|
1441
|
-
try {
|
|
1442
|
-
const status: DeploymentStatusResponse = await getDeploymentStatus(config.apiBase)
|
|
1443
|
-
|
|
1444
|
-
if (status.currentDeployment) {
|
|
1445
|
-
// Found an active deployment - reset wait counter
|
|
1446
|
-
deploymentWaitAttempts = 0
|
|
1447
|
-
|
|
1448
|
-
signals.updateDeploymentState({
|
|
1449
|
-
status: status.currentDeployment.status,
|
|
1450
|
-
})
|
|
1451
|
-
|
|
1452
|
-
// Check if deployment is still active
|
|
1453
|
-
const isActive = ['pending', 'queued', 'running'].includes(status.currentDeployment.status)
|
|
1454
|
-
|
|
1455
|
-
if (!isActive) {
|
|
1456
|
-
// Deployment finished
|
|
1457
|
-
const cb = deploymentCallback
|
|
1458
|
-
stopDeploymentPolling()
|
|
1459
|
-
|
|
1460
|
-
if (status.currentDeployment.status === 'completed') {
|
|
1461
|
-
// Update last deployed timestamp
|
|
1462
|
-
if (status.lastSuccessfulDeployment) {
|
|
1463
|
-
signals.setLastDeployedAt(status.lastSuccessfulDeployment.completedAt)
|
|
1464
|
-
}
|
|
1465
|
-
|
|
1466
|
-
// Auto-hide after 5 seconds for successful deployments
|
|
1467
|
-
deploymentHideTimer = setTimeout(() => {
|
|
1468
|
-
signals.resetDeploymentState()
|
|
1469
|
-
}, DEPLOYMENT_SUCCESS_HIDE_DELAY_MS)
|
|
1470
|
-
|
|
1471
|
-
cb?.('completed')
|
|
1472
|
-
} else {
|
|
1473
|
-
// For failed deployments, keep showing until user dismisses
|
|
1474
|
-
cb?.('failed')
|
|
1475
|
-
}
|
|
1476
|
-
}
|
|
1477
|
-
} else {
|
|
1478
|
-
// No active deployment found
|
|
1479
|
-
deploymentWaitAttempts++
|
|
1480
|
-
|
|
1481
|
-
// Check if we have a recent successful deployment (completed after we started polling)
|
|
1482
|
-
if (status.lastSuccessfulDeployment && deploymentStartTimestamp) {
|
|
1483
|
-
const lastDeployTime = new Date(status.lastSuccessfulDeployment.completedAt).getTime()
|
|
1484
|
-
const startTime = new Date(deploymentStartTimestamp).getTime()
|
|
1485
|
-
|
|
1486
|
-
if (lastDeployTime > startTime) {
|
|
1487
|
-
// Deployment completed after we started - show success
|
|
1488
|
-
signals.updateDeploymentState({
|
|
1489
|
-
status: 'completed',
|
|
1490
|
-
lastDeployedAt: status.lastSuccessfulDeployment.completedAt,
|
|
1491
|
-
isPolling: false,
|
|
1492
|
-
})
|
|
1493
|
-
|
|
1494
|
-
// Auto-hide after 5 seconds
|
|
1495
|
-
deploymentHideTimer = setTimeout(() => {
|
|
1496
|
-
signals.resetDeploymentState()
|
|
1497
|
-
}, DEPLOYMENT_SUCCESS_HIDE_DELAY_MS)
|
|
1498
|
-
|
|
1499
|
-
const cb = deploymentCallback
|
|
1500
|
-
stopDeploymentPolling()
|
|
1501
|
-
cb?.('completed')
|
|
1502
|
-
return
|
|
1503
|
-
}
|
|
1504
|
-
}
|
|
1505
|
-
|
|
1506
|
-
// Keep waiting if we haven't exceeded max attempts
|
|
1507
|
-
if (deploymentWaitAttempts >= DEPLOYMENT_MAX_WAIT_ATTEMPTS) {
|
|
1508
|
-
// Give up waiting - deployment may have failed to start
|
|
1509
|
-
console.warn('[CMS] No deployment found after waiting, giving up')
|
|
1510
|
-
const cb = deploymentCallback
|
|
1511
|
-
signals.resetDeploymentState()
|
|
1512
|
-
stopDeploymentPolling()
|
|
1513
|
-
cb?.('timeout')
|
|
1514
|
-
}
|
|
1515
|
-
// Otherwise keep polling with "pending" status
|
|
1516
|
-
}
|
|
1517
|
-
} catch (error) {
|
|
1518
|
-
console.error('[CMS] Failed to fetch deployment status:', error)
|
|
1519
|
-
signals.updateDeploymentState({
|
|
1520
|
-
status: 'failed',
|
|
1521
|
-
error: error instanceof Error ? error.message : 'Unknown error',
|
|
1522
|
-
isPolling: false,
|
|
1523
|
-
})
|
|
1524
|
-
const cb = deploymentCallback
|
|
1525
|
-
stopDeploymentPolling()
|
|
1526
|
-
cb?.('failed')
|
|
1527
|
-
}
|
|
1528
|
-
}
|
|
1529
|
-
|
|
1530
|
-
// Delay initial poll to allow deployment to be registered
|
|
1531
|
-
setTimeout(() => {
|
|
1532
|
-
poll()
|
|
1533
|
-
// Then poll every 3 seconds
|
|
1534
|
-
deploymentPollTimer = setInterval(poll, DEPLOYMENT_POLL_INTERVAL_MS)
|
|
1535
|
-
}, DEPLOYMENT_INITIAL_DELAY_MS)
|
|
1536
|
-
}
|
|
1537
|
-
|
|
1538
|
-
/**
|
|
1539
|
-
* Stop polling for deployment status.
|
|
1540
|
-
*/
|
|
1541
|
-
export function stopDeploymentPolling(): void {
|
|
1542
|
-
if (deploymentPollTimer) {
|
|
1543
|
-
clearInterval(deploymentPollTimer)
|
|
1544
|
-
deploymentPollTimer = null
|
|
1545
|
-
}
|
|
1546
|
-
deploymentWaitAttempts = 0
|
|
1547
|
-
deploymentStartTimestamp = null
|
|
1548
|
-
deploymentCallback = null
|
|
1549
|
-
signals.setDeploymentPolling(false)
|
|
1550
|
-
}
|
|
1551
|
-
|
|
1552
|
-
/**
|
|
1553
|
-
* Dismiss the deployment status indicator.
|
|
1554
|
-
* Used when user clicks on a failed deployment status.
|
|
1555
|
-
*/
|
|
1556
|
-
export function dismissDeploymentStatus(): void {
|
|
1557
|
-
if (deploymentHideTimer) {
|
|
1558
|
-
clearTimeout(deploymentHideTimer)
|
|
1559
|
-
deploymentHideTimer = null
|
|
1560
|
-
}
|
|
1561
|
-
stopDeploymentPolling()
|
|
1562
|
-
signals.resetDeploymentState()
|
|
1563
|
-
}
|
|
1564
|
-
|
|
1565
1375
|
// ============================================================================
|
|
1566
1376
|
// Attribute Tracking
|
|
1567
1377
|
// ============================================================================
|
|
@@ -6,9 +6,6 @@ export { isElementInCmsUI, usePositionTracking } from './utils'
|
|
|
6
6
|
export { useTooltipState } from './useTooltipState'
|
|
7
7
|
export type { TooltipState, UseTooltipStateOptions } from './useTooltipState'
|
|
8
8
|
|
|
9
|
-
export { useAIHandlers } from './useAIHandlers'
|
|
10
|
-
export type { AIHandlersOptions } from './useAIHandlers'
|
|
11
|
-
|
|
12
9
|
export { useBlockEditorHandlers } from './useBlockEditorHandlers'
|
|
13
10
|
export type { BlockEditorHandlersOptions } from './useBlockEditorHandlers'
|
|
14
11
|
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { useCallback, useState } from 'preact/hooks'
|
|
2
2
|
import { logDebug } from '../dom'
|
|
3
|
-
import { startDeploymentPolling } from '../editor'
|
|
4
3
|
import { getComponentInstances } from '../manifest'
|
|
5
4
|
import * as signals from '../signals'
|
|
6
5
|
import type { CmsConfig, CmsManifest, ComponentInstance, InsertPosition } from '../types'
|
|
@@ -178,9 +177,6 @@ export function useBlockEditorHandlers({
|
|
|
178
177
|
|
|
179
178
|
showToast(`${componentName} inserted ${position} component`, 'success')
|
|
180
179
|
}
|
|
181
|
-
|
|
182
|
-
// Trigger deployment polling after successful insert
|
|
183
|
-
startDeploymentPolling(config)
|
|
184
180
|
} catch (error) {
|
|
185
181
|
console.error('[CMS] Failed to insert component:', error)
|
|
186
182
|
|
|
@@ -238,10 +234,7 @@ export function useBlockEditorHandlers({
|
|
|
238
234
|
|
|
239
235
|
showToast(arrayMode ? 'Item removed' : 'Component removed', 'success')
|
|
240
236
|
|
|
241
|
-
//
|
|
242
|
-
startDeploymentPolling(config)
|
|
243
|
-
|
|
244
|
-
// Visually collapse and hide the component until page refreshes after deploy
|
|
237
|
+
// Visually collapse and hide the component until HMR refreshes the page
|
|
245
238
|
if (componentEl) {
|
|
246
239
|
collapseElement(componentEl)
|
|
247
240
|
}
|
|
@@ -29,9 +29,8 @@ export function useTooltipState(_options?: UseTooltipStateOptions) {
|
|
|
29
29
|
*/
|
|
30
30
|
const showTooltipForElement = useCallback(() => {
|
|
31
31
|
const currentEditingId = signals.currentEditingId.value
|
|
32
|
-
const isProcessing = signals.isAIProcessing.value
|
|
33
32
|
|
|
34
|
-
if (!currentEditingId
|
|
33
|
+
if (!currentEditingId) {
|
|
35
34
|
setTooltipState({ elementId: null, rect: null, element: null })
|
|
36
35
|
return
|
|
37
36
|
}
|
package/src/editor/index.tsx
CHANGED
|
@@ -27,15 +27,7 @@ import { Toolbar } from './components/toolbar'
|
|
|
27
27
|
import { getConfig } from './config'
|
|
28
28
|
import { Z_INDEX } from './constants'
|
|
29
29
|
import { disableAllInteractiveElements, enableAllInteractiveElements, logDebug } from './dom'
|
|
30
|
-
import {
|
|
31
|
-
discardAllChanges,
|
|
32
|
-
dismissDeploymentStatus,
|
|
33
|
-
handleColorChange,
|
|
34
|
-
saveAllChanges,
|
|
35
|
-
startEditMode,
|
|
36
|
-
stopEditMode,
|
|
37
|
-
toggleShowOriginal,
|
|
38
|
-
} from './editor'
|
|
30
|
+
import { discardAllChanges, handleColorChange, saveAllChanges, startEditMode, stopEditMode, toggleShowOriginal } from './editor'
|
|
39
31
|
import { canRedo, canUndo, performRedo, performUndo } from './history'
|
|
40
32
|
import {
|
|
41
33
|
useBgImageHoverDetection,
|
|
@@ -244,8 +236,6 @@ const CmsUI = () => {
|
|
|
244
236
|
seo: signals.dirtySeoChangesCount.value,
|
|
245
237
|
total: signals.totalDirtyCount.value,
|
|
246
238
|
},
|
|
247
|
-
deploymentStatus: signals.deploymentStatus.value,
|
|
248
|
-
lastDeployedAt: signals.lastDeployedAt.value,
|
|
249
239
|
canUndo: canUndo.value,
|
|
250
240
|
canRedo: canRedo.value,
|
|
251
241
|
})
|
|
@@ -337,10 +327,6 @@ const CmsUI = () => {
|
|
|
337
327
|
setMediaLibraryOpen(true)
|
|
338
328
|
}, [])
|
|
339
329
|
|
|
340
|
-
const handleDismissDeployment = useCallback(() => {
|
|
341
|
-
dismissDeploymentStatus()
|
|
342
|
-
}, [])
|
|
343
|
-
|
|
344
330
|
const handleEditContent = useCallback(async () => {
|
|
345
331
|
if (!await openMarkdownEditorForCurrentPage()) {
|
|
346
332
|
signals.showToast('No collection content found on this page', 'error')
|
|
@@ -474,7 +460,6 @@ const CmsUI = () => {
|
|
|
474
460
|
|
|
475
461
|
// Get reactive values from signals
|
|
476
462
|
const isEditing = signals.isEditing.value
|
|
477
|
-
const isAIProcessing = signals.isAIProcessing.value
|
|
478
463
|
const blockEditorState = signals.blockEditorState.value
|
|
479
464
|
const colorEditorState = signals.colorEditorState.value
|
|
480
465
|
const manifest = signals.manifest.value
|
|
@@ -556,7 +541,6 @@ const CmsUI = () => {
|
|
|
556
541
|
onDiscard: handleDiscard,
|
|
557
542
|
onSelectElement: handleSelectElementToggle,
|
|
558
543
|
onMediaLibrary: handleMediaLibrary,
|
|
559
|
-
onDismissDeployment: handleDismissDeployment,
|
|
560
544
|
onNavigateChange: () => {
|
|
561
545
|
signals.navigateToNextChange()
|
|
562
546
|
},
|
|
@@ -572,7 +556,7 @@ const CmsUI = () => {
|
|
|
572
556
|
|
|
573
557
|
<ErrorBoundary componentName="Text Style Toolbar">
|
|
574
558
|
<TextStyleToolbar
|
|
575
|
-
visible={textSelectionState.hasSelection && isEditing &&
|
|
559
|
+
visible={textSelectionState.hasSelection && isEditing && isTextStylingAllowed}
|
|
576
560
|
rect={textSelectionState.rect}
|
|
577
561
|
element={textSelectionState.element}
|
|
578
562
|
onStyleChange={updateUI}
|
|
@@ -109,8 +109,6 @@ export function buildPageNavigatedMessage(manifest: CmsManifest, pathname: strin
|
|
|
109
109
|
export function buildEditorState(opts: {
|
|
110
110
|
isEditing: boolean
|
|
111
111
|
dirtyCount: CmsEditorState['dirtyCount']
|
|
112
|
-
deploymentStatus: CmsEditorState['deployment']['status']
|
|
113
|
-
lastDeployedAt: string | null
|
|
114
112
|
canUndo: boolean
|
|
115
113
|
canRedo: boolean
|
|
116
114
|
}): CmsEditorState {
|
|
@@ -118,10 +116,6 @@ export function buildEditorState(opts: {
|
|
|
118
116
|
isEditing: opts.isEditing,
|
|
119
117
|
hasChanges: opts.dirtyCount.total > 0,
|
|
120
118
|
dirtyCount: opts.dirtyCount,
|
|
121
|
-
deployment: {
|
|
122
|
-
status: opts.deploymentStatus,
|
|
123
|
-
lastDeployedAt: opts.lastDeployedAt,
|
|
124
|
-
},
|
|
125
119
|
canUndo: opts.canUndo,
|
|
126
120
|
canRedo: opts.canRedo,
|
|
127
121
|
}
|
package/src/editor/signals.ts
CHANGED
|
@@ -4,11 +4,8 @@ import { fetchManifest, getMarkdownContent } from './api'
|
|
|
4
4
|
import type { ToastMessage, ToastType } from './components/toast/types'
|
|
5
5
|
import { getConfig } from './config'
|
|
6
6
|
import type {
|
|
7
|
-
AIState,
|
|
8
|
-
AIStatusType,
|
|
9
7
|
AttributeEditorState,
|
|
10
8
|
BlockEditorState,
|
|
11
|
-
ChatMessage,
|
|
12
9
|
CmsConfig,
|
|
13
10
|
CmsManifest,
|
|
14
11
|
CmsSettings,
|
|
@@ -20,8 +17,6 @@ import type {
|
|
|
20
17
|
ConfirmDialogState,
|
|
21
18
|
CreatePageState,
|
|
22
19
|
DeletePageState,
|
|
23
|
-
DeploymentState,
|
|
24
|
-
DeploymentStatusType,
|
|
25
20
|
EditorState,
|
|
26
21
|
FieldDefinition,
|
|
27
22
|
MarkdownEditorState,
|
|
@@ -103,21 +98,6 @@ function createDirtyTracking<T extends { isDirty: boolean }>(
|
|
|
103
98
|
}
|
|
104
99
|
|
|
105
100
|
// Initial state factories
|
|
106
|
-
function createInitialAIState(): AIState {
|
|
107
|
-
return {
|
|
108
|
-
isPromptVisible: false,
|
|
109
|
-
isProcessing: false,
|
|
110
|
-
targetElementId: null,
|
|
111
|
-
streamingContent: null,
|
|
112
|
-
error: null,
|
|
113
|
-
isChatOpen: false,
|
|
114
|
-
chatMessages: [],
|
|
115
|
-
chatContextElementId: null,
|
|
116
|
-
currentStatus: null,
|
|
117
|
-
statusMessage: null,
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
|
|
121
101
|
function createInitialBlockEditorState(): BlockEditorState {
|
|
122
102
|
return {
|
|
123
103
|
isOpen: false,
|
|
@@ -180,15 +160,6 @@ function createInitialCollectionsBrowserState(): CollectionsBrowserState {
|
|
|
180
160
|
}
|
|
181
161
|
}
|
|
182
162
|
|
|
183
|
-
function createInitialDeploymentState(): DeploymentState {
|
|
184
|
-
return {
|
|
185
|
-
status: null,
|
|
186
|
-
lastDeployedAt: null,
|
|
187
|
-
isPolling: false,
|
|
188
|
-
error: null,
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
|
|
192
163
|
function createInitialColorEditorState(): ColorEditorState {
|
|
193
164
|
return {
|
|
194
165
|
isOpen: false,
|
|
@@ -296,22 +267,6 @@ const _pendingImageChangesHelpers = createMapHelpers(pendingImageChanges)
|
|
|
296
267
|
const _pendingColorChangesHelpers = createMapHelpers(pendingColorChanges)
|
|
297
268
|
const _pendingBgImageChangesHelpers = createMapHelpers(pendingBgImageChanges)
|
|
298
269
|
|
|
299
|
-
// ============================================================================
|
|
300
|
-
// AI State Signals
|
|
301
|
-
// ============================================================================
|
|
302
|
-
|
|
303
|
-
export const aiState = signal<AIState>(createInitialAIState())
|
|
304
|
-
|
|
305
|
-
// Convenience computed signals for AI state
|
|
306
|
-
export const isAIProcessing = computed(() => aiState.value.isProcessing)
|
|
307
|
-
export const isChatOpen = computed(() => aiState.value.isChatOpen)
|
|
308
|
-
export const chatMessages = computed(() => aiState.value.chatMessages)
|
|
309
|
-
export const chatContextElementId = computed(
|
|
310
|
-
() => aiState.value.chatContextElementId,
|
|
311
|
-
)
|
|
312
|
-
export const currentStatus = computed(() => aiState.value.currentStatus)
|
|
313
|
-
export const statusMessage = computed(() => aiState.value.statusMessage)
|
|
314
|
-
|
|
315
270
|
// ============================================================================
|
|
316
271
|
// Block Editor State Signals
|
|
317
272
|
// ============================================================================
|
|
@@ -450,19 +405,6 @@ export const collectionsBrowserState = signal<CollectionsBrowserState>(
|
|
|
450
405
|
export const isCollectionsBrowserOpen = computed(() => collectionsBrowserState.value.isOpen)
|
|
451
406
|
export const selectedBrowserCollection = computed(() => collectionsBrowserState.value.selectedCollection)
|
|
452
407
|
|
|
453
|
-
// ============================================================================
|
|
454
|
-
// Deployment State Signals
|
|
455
|
-
// ============================================================================
|
|
456
|
-
|
|
457
|
-
export const deploymentState = signal<DeploymentState>(
|
|
458
|
-
createInitialDeploymentState(),
|
|
459
|
-
)
|
|
460
|
-
|
|
461
|
-
// Convenience computed signals for deployment
|
|
462
|
-
export const deploymentStatus = computed(() => deploymentState.value.status)
|
|
463
|
-
export const isDeploymentPolling = computed(() => deploymentState.value.isPolling)
|
|
464
|
-
export const lastDeployedAt = computed(() => deploymentState.value.lastDeployedAt)
|
|
465
|
-
|
|
466
408
|
// ============================================================================
|
|
467
409
|
// Redirect Countdown State
|
|
468
410
|
// ============================================================================
|
|
@@ -771,83 +713,6 @@ export const deletePendingAttributeChange = _pendingAttributeChangesHelpers.dele
|
|
|
771
713
|
export const clearPendingAttributeChanges = _pendingAttributeChangesHelpers.clear
|
|
772
714
|
export const getPendingAttributeChange = _pendingAttributeChangesHelpers.get
|
|
773
715
|
|
|
774
|
-
// ============================================================================
|
|
775
|
-
// AI State Mutations
|
|
776
|
-
// ============================================================================
|
|
777
|
-
|
|
778
|
-
export function setAIPromptVisible(visible: boolean): void {
|
|
779
|
-
aiState.value = { ...aiState.value, isPromptVisible: visible }
|
|
780
|
-
}
|
|
781
|
-
|
|
782
|
-
export function setAIProcessing(processing: boolean): void {
|
|
783
|
-
aiState.value = { ...aiState.value, isProcessing: processing }
|
|
784
|
-
}
|
|
785
|
-
|
|
786
|
-
export function setAIStatus(status: AIStatusType, message?: string): void {
|
|
787
|
-
aiState.value = {
|
|
788
|
-
...aiState.value,
|
|
789
|
-
currentStatus: status,
|
|
790
|
-
statusMessage: message ?? null,
|
|
791
|
-
}
|
|
792
|
-
}
|
|
793
|
-
|
|
794
|
-
export function clearAIStatus(): void {
|
|
795
|
-
aiState.value = {
|
|
796
|
-
...aiState.value,
|
|
797
|
-
currentStatus: null,
|
|
798
|
-
statusMessage: null,
|
|
799
|
-
}
|
|
800
|
-
}
|
|
801
|
-
|
|
802
|
-
export function setAITargetElement(elementId: string | null): void {
|
|
803
|
-
aiState.value = { ...aiState.value, targetElementId: elementId }
|
|
804
|
-
}
|
|
805
|
-
|
|
806
|
-
export function setAIStreamingContent(content: string | null): void {
|
|
807
|
-
aiState.value = { ...aiState.value, streamingContent: content }
|
|
808
|
-
}
|
|
809
|
-
|
|
810
|
-
export function setAIError(error: string | null): void {
|
|
811
|
-
aiState.value = { ...aiState.value, error }
|
|
812
|
-
}
|
|
813
|
-
|
|
814
|
-
export function resetAIState(): void {
|
|
815
|
-
aiState.value = createInitialAIState()
|
|
816
|
-
}
|
|
817
|
-
|
|
818
|
-
export function setAIChatOpen(open: boolean): void {
|
|
819
|
-
aiState.value = { ...aiState.value, isChatOpen: open }
|
|
820
|
-
}
|
|
821
|
-
|
|
822
|
-
export function addChatMessage(message: ChatMessage): void {
|
|
823
|
-
aiState.value = {
|
|
824
|
-
...aiState.value,
|
|
825
|
-
chatMessages: [...aiState.value.chatMessages, message],
|
|
826
|
-
}
|
|
827
|
-
}
|
|
828
|
-
|
|
829
|
-
export function setChatMessages(messages: ChatMessage[]): void {
|
|
830
|
-
aiState.value = {
|
|
831
|
-
...aiState.value,
|
|
832
|
-
chatMessages: messages,
|
|
833
|
-
}
|
|
834
|
-
}
|
|
835
|
-
|
|
836
|
-
export function updateChatMessage(messageId: string, content: string): void {
|
|
837
|
-
aiState.value = {
|
|
838
|
-
...aiState.value,
|
|
839
|
-
chatMessages: aiState.value.chatMessages.map((msg) => msg.id === messageId ? { ...msg, content } : msg),
|
|
840
|
-
}
|
|
841
|
-
}
|
|
842
|
-
|
|
843
|
-
export function setChatContextElement(elementId: string | null): void {
|
|
844
|
-
aiState.value = { ...aiState.value, chatContextElementId: elementId }
|
|
845
|
-
}
|
|
846
|
-
|
|
847
|
-
export function clearChatMessages(): void {
|
|
848
|
-
aiState.value = { ...aiState.value, chatMessages: [] }
|
|
849
|
-
}
|
|
850
|
-
|
|
851
716
|
// ============================================================================
|
|
852
717
|
// Block Editor State Mutations
|
|
853
718
|
// ============================================================================
|
|
@@ -1249,34 +1114,6 @@ export async function openMarkdownEditorForEntry(
|
|
|
1249
1114
|
}
|
|
1250
1115
|
}
|
|
1251
1116
|
|
|
1252
|
-
// ============================================================================
|
|
1253
|
-
// Deployment State Mutations
|
|
1254
|
-
// ============================================================================
|
|
1255
|
-
|
|
1256
|
-
export function setDeploymentStatus(status: DeploymentStatusType | null): void {
|
|
1257
|
-
deploymentState.value = { ...deploymentState.value, status }
|
|
1258
|
-
}
|
|
1259
|
-
|
|
1260
|
-
export function setDeploymentPolling(isPolling: boolean): void {
|
|
1261
|
-
deploymentState.value = { ...deploymentState.value, isPolling }
|
|
1262
|
-
}
|
|
1263
|
-
|
|
1264
|
-
export function setLastDeployedAt(timestamp: string | null): void {
|
|
1265
|
-
deploymentState.value = { ...deploymentState.value, lastDeployedAt: timestamp }
|
|
1266
|
-
}
|
|
1267
|
-
|
|
1268
|
-
export function setDeploymentError(error: string | null): void {
|
|
1269
|
-
deploymentState.value = { ...deploymentState.value, error }
|
|
1270
|
-
}
|
|
1271
|
-
|
|
1272
|
-
export function updateDeploymentState(update: Partial<DeploymentState>): void {
|
|
1273
|
-
deploymentState.value = { ...deploymentState.value, ...update }
|
|
1274
|
-
}
|
|
1275
|
-
|
|
1276
|
-
export function resetDeploymentState(): void {
|
|
1277
|
-
deploymentState.value = createInitialDeploymentState()
|
|
1278
|
-
}
|
|
1279
|
-
|
|
1280
1117
|
// ============================================================================
|
|
1281
1118
|
// Color Editor State Mutations
|
|
1282
1119
|
// ============================================================================
|
|
@@ -1530,7 +1367,6 @@ export function getStateSnapshot(): EditorState {
|
|
|
1530
1367
|
pendingComponentChanges: pendingComponentChanges.value,
|
|
1531
1368
|
pendingInserts: pendingInserts.value,
|
|
1532
1369
|
manifest: manifest.value,
|
|
1533
|
-
ai: aiState.value,
|
|
1534
1370
|
blockEditor: blockEditorState.value,
|
|
1535
1371
|
}
|
|
1536
1372
|
}
|
|
@@ -1558,7 +1394,6 @@ export function resetAllState(): void {
|
|
|
1558
1394
|
pendingComponentChanges.value = new Map()
|
|
1559
1395
|
pendingInserts.value = new Map()
|
|
1560
1396
|
manifest.value = { entries: {}, components: {}, componentDefinitions: {} }
|
|
1561
|
-
aiState.value = createInitialAIState()
|
|
1562
1397
|
blockEditorState.value = createInitialBlockEditorState()
|
|
1563
1398
|
markdownEditorState.value = createInitialMarkdownEditorState()
|
|
1564
1399
|
mediaLibraryState.value = createInitialMediaLibraryState()
|
|
@@ -1566,7 +1401,6 @@ export function resetAllState(): void {
|
|
|
1566
1401
|
deletePageState.value = createInitialDeletePageState()
|
|
1567
1402
|
redirectsManagerState.value = createInitialRedirectsManagerState()
|
|
1568
1403
|
collectionsBrowserState.value = createInitialCollectionsBrowserState()
|
|
1569
|
-
deploymentState.value = createInitialDeploymentState()
|
|
1570
1404
|
colorEditorState.value = createInitialColorEditorState()
|
|
1571
1405
|
confirmDialogState.value = createInitialConfirmDialogState()
|
|
1572
1406
|
seoEditorState.value = createInitialSeoEditorState()
|