@xynolog/react-ui 0.8.0 → 0.8.1
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/README.md +26 -46
- package/package.json +12 -9
- package/src/components/Button/Button.tsx +0 -188
- package/src/components/Button/__tests__/Button.test.tsx +0 -449
- package/src/components/CodeMirrorRenderer.tsx +0 -536
- package/src/components/DelegateProgress.tsx +0 -308
- package/src/components/ErrorBoundary.tsx +0 -174
- package/src/components/ItemFoundLog.tsx +0 -42
- package/src/components/LiveRegion.tsx +0 -261
- package/src/components/ProtectedErrorBoundary.tsx +0 -114
- package/src/components/ResizeHandle.tsx +0 -167
- package/src/components/ResourceTagsInline.tsx +0 -120
- package/src/components/SessionExpiryBanner.tsx +0 -74
- package/src/components/SessionTimer.tsx +0 -17
- package/src/components/StatusDisplay.tsx +0 -131
- package/src/components/Toast.tsx +0 -217
- package/src/components/Toolbar.tsx +0 -194
- package/src/components/UserMenuSkeleton.tsx +0 -13
- package/src/components/__tests__/DelegateProgress.denominator.test.tsx +0 -102
- package/src/components/__tests__/DelegateProgress.test.tsx +0 -649
- package/src/components/__tests__/ErrorBoundary.test.tsx +0 -565
- package/src/components/__tests__/LiveRegion.a11y.test.tsx +0 -258
- package/src/components/__tests__/LiveRegion.hooks.test.tsx +0 -140
- package/src/components/__tests__/ProtectedErrorBoundary.test.tsx +0 -225
- package/src/components/__tests__/ResizeHandle.test.tsx +0 -159
- package/src/components/__tests__/ResourceTagsInline.test.tsx +0 -325
- package/src/components/__tests__/SessionExpiryBanner.test.tsx +0 -124
- package/src/components/__tests__/SessionTimer.test.tsx +0 -199
- package/src/components/__tests__/StatusDisplay.test.tsx +0 -179
- package/src/components/__tests__/Toast.test.tsx +0 -96
- package/src/components/__tests__/Toolbar.test.tsx +0 -111
- package/src/components/__tests__/UserMenuSkeleton.test.tsx +0 -182
- package/src/components/annotation/AnchoredTextNotice.tsx +0 -36
- package/src/components/annotation/AnnotateToolbar.tsx +0 -531
- package/src/components/annotation/__tests__/AnnotateToolbar.display.test.tsx +0 -127
- package/src/components/annotation/__tests__/AnnotateToolbar.test.tsx +0 -304
- package/src/components/annotation-popups/JsonLdView.tsx +0 -127
- package/src/components/annotation-popups/SharedPopupElements.tsx +0 -131
- package/src/components/annotation-popups/__tests__/JsonLdView.test.tsx +0 -432
- package/src/components/annotation-popups/__tests__/SharedPopupElements.test.tsx +0 -297
- package/src/components/branding/XynologBranding.tsx +0 -41
- package/src/components/branding/__tests__/XynologBranding.test.tsx +0 -383
- package/src/components/error-states/ResourceErrorState.tsx +0 -30
- package/src/components/error-states/__tests__/ResourceErrorState.test.tsx +0 -102
- package/src/components/image-annotation/AnnotationOverlay.tsx +0 -307
- package/src/components/image-annotation/SvgDrawingCanvas.tsx +0 -514
- package/src/components/image-annotation/__tests__/AnnotationOverlay.click.test.tsx +0 -169
- package/src/components/image-annotation/__tests__/AnnotationOverlay.hover.test.tsx +0 -83
- package/src/components/image-annotation/__tests__/SvgDrawingCanvas.annotate-gate.test.tsx +0 -228
- package/src/components/image-annotation/__tests__/SvgDrawingCanvas.click.test.tsx +0 -204
- package/src/components/layout/LeftSidebar.tsx +0 -150
- package/src/components/layout/PageLayout.tsx +0 -49
- package/src/components/layout/SkipLinks.tsx +0 -36
- package/src/components/layout/UnifiedHeader.tsx +0 -151
- package/src/components/layout/__tests__/LeftSidebar.test.tsx +0 -426
- package/src/components/layout/__tests__/PageLayout.test.tsx +0 -311
- package/src/components/layout/__tests__/SkipLinks.a11y.test.tsx +0 -218
- package/src/components/layout/__tests__/UnifiedHeader.test.tsx +0 -555
- package/src/components/loading-states/ComposeLoadingState.tsx +0 -19
- package/src/components/loading-states/ResourceLoadingState.tsx +0 -13
- package/src/components/loading-states/__tests__/ComposeLoadingState.test.tsx +0 -37
- package/src/components/loading-states/__tests__/ResourceLoadingState.test.tsx +0 -31
- package/src/components/modals/ComposeStep.tsx +0 -245
- package/src/components/modals/ConfigureGatherStep.tsx +0 -110
- package/src/components/modals/ConfigureGenerationStep.tsx +0 -458
- package/src/components/modals/ConfigureSearchStep.tsx +0 -124
- package/src/components/modals/ContextSummary.tsx +0 -317
- package/src/components/modals/CorpusPane.tsx +0 -96
- package/src/components/modals/DiscardPrompt.tsx +0 -44
- package/src/components/modals/GatherContextStep.tsx +0 -480
- package/src/components/modals/KbIdentityConflictModal.tsx +0 -122
- package/src/components/modals/KeyboardShortcutsHelpModal.tsx +0 -238
- package/src/components/modals/PermissionDeniedModal.tsx +0 -207
- package/src/components/modals/ReferenceWizardModal.tsx +0 -656
- package/src/components/modals/ResourceGenerateModal.tsx +0 -457
- package/src/components/modals/SearchModal.tsx +0 -334
- package/src/components/modals/SearchResultsStep.tsx +0 -117
- package/src/components/modals/SessionEndedModal.tsx +0 -148
- package/src/components/modals/WizardFooter.tsx +0 -72
- package/src/components/modals/__tests__/ComposeStep.test.tsx +0 -187
- package/src/components/modals/__tests__/ConfigureGatherStep.test.tsx +0 -92
- package/src/components/modals/__tests__/ConfigureGenerationStep.test.tsx +0 -574
- package/src/components/modals/__tests__/ConfigureSearchStep.test.tsx +0 -124
- package/src/components/modals/__tests__/GatherContextStep.resource.test.tsx +0 -702
- package/src/components/modals/__tests__/KbIdentityConflictModal.test.tsx +0 -102
- package/src/components/modals/__tests__/KeyboardShortcutsHelpModal.test.tsx +0 -115
- package/src/components/modals/__tests__/PermissionDeniedModal.test.tsx +0 -218
- package/src/components/modals/__tests__/ReferenceWizardModal.test.tsx +0 -936
- package/src/components/modals/__tests__/ResourceGenerateModal.test.tsx +0 -532
- package/src/components/modals/__tests__/SearchModal.accessibility.test.tsx +0 -95
- package/src/components/modals/__tests__/SearchModal.basic.test.tsx +0 -84
- package/src/components/modals/__tests__/SearchModal.keyboard.test.tsx +0 -162
- package/src/components/modals/__tests__/SearchModal.search-wiring.test.tsx +0 -237
- package/src/components/modals/__tests__/SearchModal.translations.test.tsx +0 -91
- package/src/components/modals/__tests__/SearchResultsStep.test.tsx +0 -95
- package/src/components/modals/__tests__/SessionEndedModal.test.tsx +0 -171
- package/src/components/modals/__tests__/WizardFooter.test.tsx +0 -446
- package/src/components/modals/__tests__/search-modal-harness.ts +0 -82
- package/src/components/navigation/CollapsibleResourceNavigation.tsx +0 -364
- package/src/components/navigation/NavigationMenu.tsx +0 -66
- package/src/components/navigation/ObservableLink.tsx +0 -90
- package/src/components/navigation/SimpleNavigation.tsx +0 -169
- package/src/components/navigation/SortableResourceTab.tsx +0 -122
- package/src/components/navigation/__tests__/NavigationMenu.a11y.test.tsx +0 -302
- package/src/components/navigation/__tests__/NavigationMenu.test.tsx +0 -399
- package/src/components/navigation/__tests__/ObservableLink.test.tsx +0 -85
- package/src/components/navigation/__tests__/SimpleNavigation.test.tsx +0 -193
- package/src/components/navigation/__tests__/SortableResourceTab.test.tsx +0 -421
- package/src/components/pdf-annotation/PdfAnnotationCanvas.client.tsx +0 -10
- package/src/components/pdf-annotation/PdfAnnotationCanvas.tsx +0 -632
- package/src/components/pdf-annotation/PdfPageView.tsx +0 -527
- package/src/components/pdf-annotation/__tests__/PdfAnnotationCanvas.annotate-gate.test.tsx +0 -295
- package/src/components/pdf-annotation/__tests__/PdfAnnotationCanvas.pixels-before-anchoring.test.tsx +0 -166
- package/src/components/pdf-annotation/__tests__/PdfAnnotationCanvas.test.tsx +0 -1719
- package/src/components/pdf-annotation/__tests__/estimate-slot-height.test.ts +0 -61
- package/src/components/pdf-annotation/__tests__/rects-for-page.test.ts +0 -110
- package/src/components/pdf-annotation/estimate-slot-height.ts +0 -31
- package/src/components/pdf-annotation/rects-for-page.ts +0 -50
- package/src/components/resource/AnnotateView.tsx +0 -373
- package/src/components/resource/AnnotationHistory.tsx +0 -169
- package/src/components/resource/BrowseView.tsx +0 -440
- package/src/components/resource/DownloadFileLink.tsx +0 -53
- package/src/components/resource/HistoryEvent.tsx +0 -186
- package/src/components/resource/ResourceViewer.tsx +0 -617
- package/src/components/resource/__tests__/AnnotateView.code-point-offsets.test.tsx +0 -482
- package/src/components/resource/__tests__/AnnotateView.embeddable.test.tsx +0 -78
- package/src/components/resource/__tests__/AnnotateView.focus.test.tsx +0 -147
- package/src/components/resource/__tests__/AnnotateView.registry.test.tsx +0 -143
- package/src/components/resource/__tests__/AnnotationHistory.test.tsx +0 -257
- package/src/components/resource/__tests__/BrowseView.code-point-offsets.test.tsx +0 -123
- package/src/components/resource/__tests__/BrowseView.embeddable.test.tsx +0 -76
- package/src/components/resource/__tests__/BrowseView.links.test.tsx +0 -84
- package/src/components/resource/__tests__/BrowseView.overlay-async.test.tsx +0 -165
- package/src/components/resource/__tests__/BrowseView.reference-hover.test.tsx +0 -200
- package/src/components/resource/__tests__/BrowseView.registry.test.tsx +0 -57
- package/src/components/resource/__tests__/BrowseView.test.tsx +0 -915
- package/src/components/resource/__tests__/HistoryEvent.test.tsx +0 -571
- package/src/components/resource/__tests__/ResourceViewer.delete-failure.test.tsx +0 -103
- package/src/components/resource/__tests__/ResourceViewer.embeddable.test.tsx +0 -250
- package/src/components/resource/__tests__/ResourceViewer.mode-switch.test.tsx +0 -262
- package/src/components/resource/__tests__/ResourceViewer.multi-mount-invalidation.test.tsx +0 -166
- package/src/components/resource/__tests__/ResourceViewer.registry.test.tsx +0 -112
- package/src/components/resource/__tests__/ResourceViewer.toolbar-opt-out.test.tsx +0 -207
- package/src/components/resource/__tests__/ResourceViewer.toolbar-prefs.test.tsx +0 -274
- package/src/components/resource/__tests__/annotation-interactions.test.tsx +0 -116
- package/src/components/resource/__tests__/browse-renderers.dispatch.test.tsx +0 -183
- package/src/components/resource/__tests__/browse-renderers.test.tsx +0 -47
- package/src/components/resource/__tests__/download-link.test.tsx +0 -171
- package/src/components/resource/__tests__/event-formatting.test.ts +0 -379
- package/src/components/resource/__tests__/inline-embedding.test.tsx +0 -133
- package/src/components/resource/__tests__/media-completeness.test.tsx +0 -144
- package/src/components/resource/annotate-renderers.tsx +0 -186
- package/src/components/resource/browse-renderers.tsx +0 -133
- package/src/components/resource/event-formatting.ts +0 -393
- package/src/components/resource/panels/AssessmentEntry.tsx +0 -127
- package/src/components/resource/panels/AssessmentPanel.tsx +0 -309
- package/src/components/resource/panels/CollaborationPanel.tsx +0 -228
- package/src/components/resource/panels/CommentEntry.tsx +0 -242
- package/src/components/resource/panels/CommentsPanel.tsx +0 -320
- package/src/components/resource/panels/DelegateSection.tsx +0 -282
- package/src/components/resource/panels/DelegateShell.tsx +0 -134
- package/src/components/resource/panels/HighlightEntry.tsx +0 -83
- package/src/components/resource/panels/HighlightPanel.tsx +0 -212
- package/src/components/resource/panels/JsonLdPanel.tsx +0 -119
- package/src/components/resource/panels/PanelHeader.tsx +0 -22
- package/src/components/resource/panels/ReferenceEntry.tsx +0 -232
- package/src/components/resource/panels/ReferencesPanel.tsx +0 -626
- package/src/components/resource/panels/ResourceInfoPanel.tsx +0 -433
- package/src/components/resource/panels/StatisticsPanel.tsx +0 -145
- package/src/components/resource/panels/TagEntry.tsx +0 -87
- package/src/components/resource/panels/TaggingPanel.tsx +0 -554
- package/src/components/resource/panels/UnifiedAnnotationsPanel.tsx +0 -384
- package/src/components/resource/panels/__tests__/AssessmentEntry.test.tsx +0 -292
- package/src/components/resource/panels/__tests__/AssessmentPanel.test.tsx +0 -685
- package/src/components/resource/panels/__tests__/CollaborationPanel.test.tsx +0 -685
- package/src/components/resource/panels/__tests__/CommentEntry.test.tsx +0 -750
- package/src/components/resource/panels/__tests__/CommentsPanel.test.tsx +0 -877
- package/src/components/resource/panels/__tests__/DelegateSection.test.tsx +0 -623
- package/src/components/resource/panels/__tests__/DelegateShell.test.tsx +0 -212
- package/src/components/resource/panels/__tests__/HighlightEntry.test.tsx +0 -236
- package/src/components/resource/panels/__tests__/HighlightPanel.annotationProgress.test.tsx +0 -506
- package/src/components/resource/panels/__tests__/HighlightPanel.out-of-order.test.tsx +0 -132
- package/src/components/resource/panels/__tests__/JsonLdPanel.test.tsx +0 -230
- package/src/components/resource/panels/__tests__/PanelHeader.test.tsx +0 -54
- package/src/components/resource/panels/__tests__/ReferenceEntry.test.tsx +0 -578
- package/src/components/resource/panels/__tests__/ReferencesPanel.headless.test.tsx +0 -193
- package/src/components/resource/panels/__tests__/ReferencesPanel.observable-flow.test.tsx +0 -193
- package/src/components/resource/panels/__tests__/ReferencesPanel.test.tsx +0 -1080
- package/src/components/resource/panels/__tests__/ResourceInfoPanel.test.tsx +0 -812
- package/src/components/resource/panels/__tests__/ResourceInfoPanel.text-layer.test.tsx +0 -106
- package/src/components/resource/panels/__tests__/StatisticsPanel.test.tsx +0 -329
- package/src/components/resource/panels/__tests__/TagEntry.test.tsx +0 -250
- package/src/components/resource/panels/__tests__/TaggingPanel.test.tsx +0 -772
- package/src/components/resource/panels/__tests__/UnifiedAnnotationsPanel.delegated-job.test.tsx +0 -207
- package/src/components/resource/panels/__tests__/UnifiedAnnotationsPanel.failure.test.tsx +0 -89
- package/src/components/resource/panels/__tests__/agent-label.test.ts +0 -136
- package/src/components/resource/panels/agent-label.ts +0 -35
- package/src/components/settings/SettingsPanel.tsx +0 -251
- package/src/components/settings/__tests__/SettingsPanel.test.tsx +0 -260
- package/src/components/viewers/ImageViewer.tsx +0 -18
- package/src/components/viewers/__tests__/ImageViewer.test.tsx +0 -57
- package/src/components/viewers/index.ts +0 -1
- package/src/features/auth/__tests__/AuthErrorDisplay.test.tsx +0 -181
- package/src/features/auth/components/AuthErrorDisplay.tsx +0 -89
- package/src/features/moderate-entity-tags/__tests__/EntityTagsPage.test.tsx +0 -387
- package/src/features/moderate-entity-tags/components/EntityTagsPage.tsx +0 -161
- package/src/features/moderate-entity-tags/state/__tests__/entity-tags-state-unit.test.ts +0 -183
- package/src/features/moderate-entity-tags/state/entity-tags-state-unit.ts +0 -73
- package/src/features/moderate-recent/__tests__/RecentDocumentsPage.test.tsx +0 -422
- package/src/features/moderate-recent/components/RecentDocumentsPage.tsx +0 -117
- package/src/features/moderate-tag-schemas/__tests__/TagSchemasPage.test.tsx +0 -481
- package/src/features/moderate-tag-schemas/components/TagSchemasPage.tsx +0 -161
- package/src/features/resource-compose/__tests__/ResourceComposePage.test.tsx +0 -600
- package/src/features/resource-compose/__tests__/UploadProgressBar.test.tsx +0 -256
- package/src/features/resource-compose/components/ResourceComposePage.tsx +0 -809
- package/src/features/resource-compose/components/UploadProgressBar.tsx +0 -125
- package/src/features/resource-compose/state/__tests__/compose-page-state-unit.test.ts +0 -195
- package/src/features/resource-compose/state/compose-page-state-unit.ts +0 -187
- package/src/features/resource-discovery/__tests__/ResourceCard.test.tsx +0 -338
- package/src/features/resource-discovery/__tests__/ResourceDiscoveryPage.test.tsx +0 -449
- package/src/features/resource-discovery/components/ResourceCard.tsx +0 -80
- package/src/features/resource-discovery/components/ResourceDiscoveryPage.tsx +0 -330
- package/src/features/resource-discovery/state/__tests__/discover-state-unit.test.ts +0 -477
- package/src/features/resource-discovery/state/discover-state-unit.ts +0 -162
- package/src/features/resource-viewer/__tests__/ResourceViewerPage.content-loading.test.tsx +0 -260
- package/src/features/resource-viewer/__tests__/ResourceViewerPage.test.tsx +0 -570
- package/src/features/resource-viewer/__tests__/generation-params.test.ts +0 -49
- package/src/features/resource-viewer/components/ResourceViewerPage.tsx +0 -1058
- package/src/features/resource-viewer/generation-params.ts +0 -23
- package/src/features/resource-viewer/hooks/__tests__/useResourceViewedReport.test.tsx +0 -77
- package/src/features/resource-viewer/hooks/useResourceViewedReport.ts +0 -38
- package/src/features/resource-viewer/state/__tests__/resource-loader-state-unit.test.ts +0 -178
- package/src/features/resource-viewer/state/__tests__/resource-viewer-page-state-unit.test.ts +0 -505
- package/src/features/resource-viewer/state/resource-loader-state-unit.ts +0 -93
- package/src/features/resource-viewer/state/resource-viewer-page-state-unit.ts +0 -156
|
@@ -1,809 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ResourceComposePage Component
|
|
3
|
-
*
|
|
4
|
-
* Pure React component for creating and editing resources.
|
|
5
|
-
* Supports two modes: new resource and clone. (Reference completion moved
|
|
6
|
-
* into the resolve wizard, as its in-modal compose step.)
|
|
7
|
-
* All dependencies passed as props - no Next.js hooks!
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
import React, { useState, useEffect } from 'react';
|
|
11
|
-
import {
|
|
12
|
-
capabilitiesOf,
|
|
13
|
-
AUTHORABLE_MEDIA_TYPES,
|
|
14
|
-
MEDIA_TYPES,
|
|
15
|
-
mediaTypeForExtension,
|
|
16
|
-
isSupportedMediaType,
|
|
17
|
-
LOCALES,
|
|
18
|
-
folderOf,
|
|
19
|
-
proposeStoragePath,
|
|
20
|
-
getStorageUri,
|
|
21
|
-
} from '@xynolog/core';
|
|
22
|
-
import type { SupportedMediaType } from '@xynolog/core';
|
|
23
|
-
import type { UploadProgress } from '@xynolog/sdk';
|
|
24
|
-
import { type CloneData } from '../state/compose-page-state-unit';
|
|
25
|
-
import {
|
|
26
|
-
COMMON_PANELS,
|
|
27
|
-
type ToolbarPanelType,
|
|
28
|
-
} from '../../../state/shell-state-unit';
|
|
29
|
-
import {
|
|
30
|
-
type ToolbarPanelsProps,
|
|
31
|
-
type ToolbarProps,
|
|
32
|
-
} from '../../../components/Toolbar';
|
|
33
|
-
import { buttonStyles } from '../../../lib/button-styles';
|
|
34
|
-
import { CodeMirrorRenderer } from '../../../components/CodeMirrorRenderer';
|
|
35
|
-
import { useFormAnnouncements } from '../../../components/LiveRegion';
|
|
36
|
-
import { useLineNumbers } from '../../../contexts/LineNumbersContext';
|
|
37
|
-
import { UploadProgressBar } from './UploadProgressBar';
|
|
38
|
-
import type { ResolvedTheme } from '../../../contexts/ThemeContext';
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Big tent: every registry type is uploadable. The `accept` hint lists all
|
|
42
|
-
* known extensions — it's only a hint; `handleFileUpload` never rejects.
|
|
43
|
-
*/
|
|
44
|
-
const UPLOAD_ACCEPT = Object.values(MEDIA_TYPES)
|
|
45
|
-
.map((c) => c.extension)
|
|
46
|
-
.join(',');
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Detection chain for uploaded files (same spirit as the CLI):
|
|
50
|
-
* 1. the browser's `file.type`, if it names a registry member;
|
|
51
|
-
* 2. otherwise the filename extension (`file.type` is routinely empty for
|
|
52
|
-
* `.md` and friends);
|
|
53
|
-
* 3. otherwise `application/octet-stream` — itself a registry member, so
|
|
54
|
-
* under the big tent every file is uploadable.
|
|
55
|
-
*/
|
|
56
|
-
function detectUploadMediaType(file: File): string {
|
|
57
|
-
if (file.type && isSupportedMediaType(file.type)) return file.type;
|
|
58
|
-
if (file.name.includes('.')) {
|
|
59
|
-
const byExt = mediaTypeForExtension(
|
|
60
|
-
file.name.slice(file.name.lastIndexOf('.')),
|
|
61
|
-
);
|
|
62
|
-
if (byExt) return byExt;
|
|
63
|
-
}
|
|
64
|
-
return 'application/octet-stream';
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
export interface ResourceComposePageProps {
|
|
68
|
-
mode: 'new' | 'clone';
|
|
69
|
-
cloneData?: CloneData | null;
|
|
70
|
-
|
|
71
|
-
// Available options
|
|
72
|
-
availableEntityTypes: string[];
|
|
73
|
-
|
|
74
|
-
// Initial values
|
|
75
|
-
initialLocale: string;
|
|
76
|
-
|
|
77
|
-
// UI state
|
|
78
|
-
theme: ResolvedTheme;
|
|
79
|
-
hoverDelayMs: number;
|
|
80
|
-
activePanel: ToolbarPanelType | null;
|
|
81
|
-
|
|
82
|
-
// Actions
|
|
83
|
-
onSaveResource: (params: SaveResourceParams) => Promise<void>;
|
|
84
|
-
onCancel: () => void;
|
|
85
|
-
/** Choose a destination directory and return its path relative to the KB root. */
|
|
86
|
-
onChooseStorageDirectory?: (
|
|
87
|
-
suggestedDirectory: string,
|
|
88
|
-
) => Promise<string | null>;
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* Live upload-progress for the in-flight save. Resolved by the route
|
|
92
|
-
* shell from `composeVM.uploadProgress$`. `null` between saves and
|
|
93
|
-
* after completion. When non-null, the form disables Save and the
|
|
94
|
-
* inline `<UploadProgressBar />` below the action buttons renders.
|
|
95
|
-
*/
|
|
96
|
-
uploadProgress?: UploadProgress | null;
|
|
97
|
-
|
|
98
|
-
// Translations
|
|
99
|
-
translations: {
|
|
100
|
-
title: string;
|
|
101
|
-
titleEditClone: string;
|
|
102
|
-
subtitleClone: string;
|
|
103
|
-
resourceName: string;
|
|
104
|
-
resourceNamePlaceholder: string;
|
|
105
|
-
entityTypes: string;
|
|
106
|
-
language: string;
|
|
107
|
-
contentSource: string;
|
|
108
|
-
uploadFile: string;
|
|
109
|
-
uploadFileDescription: string;
|
|
110
|
-
writeContent: string;
|
|
111
|
-
writeContentDescription: string;
|
|
112
|
-
dropFileOrClick: string;
|
|
113
|
-
supportedFormats: string;
|
|
114
|
-
mediaType: string;
|
|
115
|
-
autoDetected: string;
|
|
116
|
-
format: string;
|
|
117
|
-
content: string;
|
|
118
|
-
resourceContent: string;
|
|
119
|
-
encoding: string;
|
|
120
|
-
archiveOriginal: string;
|
|
121
|
-
cancel: string;
|
|
122
|
-
saving: string;
|
|
123
|
-
creating: string;
|
|
124
|
-
saveClonedResource: string;
|
|
125
|
-
createResource: string;
|
|
126
|
-
chooseFolder?: string;
|
|
127
|
-
locationHint?: string;
|
|
128
|
-
};
|
|
129
|
-
|
|
130
|
-
// Component dependencies
|
|
131
|
-
ToolbarPanels: React.ComponentType<ToolbarPanelsProps>;
|
|
132
|
-
Toolbar: React.ComponentType<ToolbarProps<ToolbarPanelType>>;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
export interface SaveResourceParams {
|
|
136
|
-
mode: 'new' | 'clone';
|
|
137
|
-
name: string;
|
|
138
|
-
storageUri: string;
|
|
139
|
-
content?: string;
|
|
140
|
-
file?: File;
|
|
141
|
-
format?: string;
|
|
142
|
-
charset?: string;
|
|
143
|
-
entityTypes?: string[];
|
|
144
|
-
language: string;
|
|
145
|
-
archiveOriginal?: boolean;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
export function ResourceComposePage({
|
|
149
|
-
mode,
|
|
150
|
-
cloneData,
|
|
151
|
-
availableEntityTypes,
|
|
152
|
-
initialLocale,
|
|
153
|
-
theme,
|
|
154
|
-
hoverDelayMs,
|
|
155
|
-
activePanel,
|
|
156
|
-
onSaveResource,
|
|
157
|
-
onCancel,
|
|
158
|
-
onChooseStorageDirectory,
|
|
159
|
-
uploadProgress = null,
|
|
160
|
-
translations: t,
|
|
161
|
-
ToolbarPanels,
|
|
162
|
-
Toolbar,
|
|
163
|
-
}: ResourceComposePageProps) {
|
|
164
|
-
// Form announcements
|
|
165
|
-
const { announceFormSubmitting, announceFormSuccess, announceFormError } =
|
|
166
|
-
useFormAnnouncements();
|
|
167
|
-
|
|
168
|
-
// Shared display setting (LineNumbersContext) — was a prop threaded from
|
|
169
|
-
// the route, which desynced it from the Settings toggle.
|
|
170
|
-
const { showLineNumbers } = useLineNumbers();
|
|
171
|
-
|
|
172
|
-
// Form state
|
|
173
|
-
const [newResourceName, setNewResourceName] = useState('');
|
|
174
|
-
const [newResourceContent, setNewResourceContent] = useState('');
|
|
175
|
-
const [selectedEntityTypes, setSelectedEntityTypes] = useState<string[]>([]);
|
|
176
|
-
const [isCreating, setIsCreating] = useState(false);
|
|
177
|
-
|
|
178
|
-
// Content input method selection
|
|
179
|
-
const [inputMethod, setInputMethod] = useState<'upload' | 'write'>('write');
|
|
180
|
-
|
|
181
|
-
// File upload state
|
|
182
|
-
const [uploadedFile, setUploadedFile] = useState<File | null>(null);
|
|
183
|
-
const [fileMimeType, setFileMimeType] = useState<string>('text/markdown');
|
|
184
|
-
const [filePreviewUrl, setFilePreviewUrl] = useState<string | null>(null);
|
|
185
|
-
const [isDragOver, setIsDragOver] = useState(false);
|
|
186
|
-
|
|
187
|
-
// Format selection for manual content entry
|
|
188
|
-
const [selectedFormat, setSelectedFormat] = useState<string>('text/markdown');
|
|
189
|
-
|
|
190
|
-
// Language selection - default to current user locale
|
|
191
|
-
const [selectedLanguage, setSelectedLanguage] =
|
|
192
|
-
useState<string>(initialLocale);
|
|
193
|
-
|
|
194
|
-
// Character encoding selection - default to UTF-8 (empty string means use default)
|
|
195
|
-
const [selectedCharset, setSelectedCharset] = useState<string>('');
|
|
196
|
-
|
|
197
|
-
// Working-tree path (bare, no protocol prefix) — converted to file:// URI on submit
|
|
198
|
-
const [storagePath, setStoragePath] = useState('');
|
|
199
|
-
const [storageDirectory, setStorageDirectory] = useState<string | null>(null);
|
|
200
|
-
const [choosingStorageDirectory, setChoosingStorageDirectory] =
|
|
201
|
-
useState(false);
|
|
202
|
-
const [storageLocationError, setStorageLocationError] = useState<
|
|
203
|
-
string | null
|
|
204
|
-
>(null);
|
|
205
|
-
|
|
206
|
-
// Archive original checkbox (for clones only)
|
|
207
|
-
const [archiveOriginal, setArchiveOriginal] = useState(true);
|
|
208
|
-
|
|
209
|
-
// The Save location starts filled and follows the title until the user
|
|
210
|
-
// takes it over; `pathTouched` is derived, so clearing restores the proposal.
|
|
211
|
-
// A clone proposes beside its source; a new resource proposes at the root.
|
|
212
|
-
const composeFormat: SupportedMediaType = isSupportedMediaType(selectedFormat)
|
|
213
|
-
? selectedFormat
|
|
214
|
-
: 'text/markdown';
|
|
215
|
-
const pathTouched = storagePath !== '';
|
|
216
|
-
const proposedPath = pathTouched
|
|
217
|
-
? storagePath
|
|
218
|
-
: proposeStoragePath(
|
|
219
|
-
mode === 'clone' && cloneData
|
|
220
|
-
? folderOf(getStorageUri(cloneData.sourceResource))
|
|
221
|
-
: '',
|
|
222
|
-
newResourceName,
|
|
223
|
-
composeFormat,
|
|
224
|
-
);
|
|
225
|
-
const proposedFilename = proposedPath.split('/').filter(Boolean).at(-1) ?? '';
|
|
226
|
-
const effectivePath =
|
|
227
|
-
onChooseStorageDirectory && storageDirectory !== null
|
|
228
|
-
? [storageDirectory, proposedFilename].filter(Boolean).join('/')
|
|
229
|
-
: proposedPath;
|
|
230
|
-
|
|
231
|
-
// Initialize form data based on mode
|
|
232
|
-
useEffect(() => {
|
|
233
|
-
if (mode === 'clone' && cloneData) {
|
|
234
|
-
setNewResourceName(cloneData.sourceResource.name);
|
|
235
|
-
setNewResourceContent(cloneData.sourceContent);
|
|
236
|
-
}
|
|
237
|
-
}, [mode, cloneData]);
|
|
238
|
-
|
|
239
|
-
// Handle file upload
|
|
240
|
-
const handleFileUpload = (e: React.ChangeEvent<HTMLInputElement>) => {
|
|
241
|
-
const file = e.target.files?.[0];
|
|
242
|
-
if (!file) return;
|
|
243
|
-
applyUploadedFile(file);
|
|
244
|
-
};
|
|
245
|
-
|
|
246
|
-
// One application path for both entries into the dropzone: the file-input
|
|
247
|
-
// change (click) and a real drag-and-drop (the input is display:none, so
|
|
248
|
-
// native input drops can never land — the label owns the drop).
|
|
249
|
-
const applyUploadedFile = (file: File) => {
|
|
250
|
-
const detectedMediaType = detectUploadMediaType(file);
|
|
251
|
-
setUploadedFile(file);
|
|
252
|
-
setFileMimeType(detectedMediaType);
|
|
253
|
-
setInputMethod('upload');
|
|
254
|
-
|
|
255
|
-
// Set file name as default resource name if empty
|
|
256
|
-
if (!newResourceName) {
|
|
257
|
-
const nameWithoutExt = file.name.replace(/\.[^/.]+$/, '');
|
|
258
|
-
setNewResourceName(nameWithoutExt);
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
// Images and PDFs get an object-URL preview; everything else reads as text.
|
|
262
|
-
const detectedRender = capabilitiesOf(detectedMediaType)?.render;
|
|
263
|
-
if (detectedRender === 'image' || detectedRender === 'pdf') {
|
|
264
|
-
const previewUrl = URL.createObjectURL(file);
|
|
265
|
-
setFilePreviewUrl(previewUrl);
|
|
266
|
-
} else {
|
|
267
|
-
// For text files, read content
|
|
268
|
-
const reader = new FileReader();
|
|
269
|
-
reader.onload = (event) => {
|
|
270
|
-
const content = event.target?.result as string;
|
|
271
|
-
setNewResourceContent(content);
|
|
272
|
-
};
|
|
273
|
-
reader.readAsText(file);
|
|
274
|
-
}
|
|
275
|
-
};
|
|
276
|
-
|
|
277
|
-
// Cleanup preview URL on unmount
|
|
278
|
-
useEffect(() => {
|
|
279
|
-
return () => {
|
|
280
|
-
if (filePreviewUrl) {
|
|
281
|
-
URL.revokeObjectURL(filePreviewUrl);
|
|
282
|
-
}
|
|
283
|
-
};
|
|
284
|
-
}, [filePreviewUrl]);
|
|
285
|
-
|
|
286
|
-
const handleSaveResource = async (e: React.FormEvent) => {
|
|
287
|
-
e.preventDefault();
|
|
288
|
-
if (!newResourceName.trim()) return;
|
|
289
|
-
|
|
290
|
-
setIsCreating(true);
|
|
291
|
-
announceFormSubmitting();
|
|
292
|
-
|
|
293
|
-
try {
|
|
294
|
-
const params: SaveResourceParams = {
|
|
295
|
-
mode,
|
|
296
|
-
name: newResourceName,
|
|
297
|
-
storageUri: `file://${effectivePath}`,
|
|
298
|
-
content: newResourceContent,
|
|
299
|
-
format: uploadedFile ? fileMimeType : selectedFormat,
|
|
300
|
-
entityTypes: selectedEntityTypes,
|
|
301
|
-
language: selectedLanguage,
|
|
302
|
-
};
|
|
303
|
-
|
|
304
|
-
if (uploadedFile) {
|
|
305
|
-
params.file = uploadedFile;
|
|
306
|
-
}
|
|
307
|
-
if (selectedCharset) {
|
|
308
|
-
params.charset = selectedCharset;
|
|
309
|
-
}
|
|
310
|
-
if (mode === 'clone') {
|
|
311
|
-
params.archiveOriginal = archiveOriginal;
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
await onSaveResource(params);
|
|
315
|
-
|
|
316
|
-
// Announce success based on mode
|
|
317
|
-
const successMessage =
|
|
318
|
-
mode === 'clone'
|
|
319
|
-
? 'Resource cloned successfully'
|
|
320
|
-
: 'Resource created successfully';
|
|
321
|
-
announceFormSuccess(successMessage);
|
|
322
|
-
} catch (error) {
|
|
323
|
-
announceFormError('Failed to save resource. Please try again.');
|
|
324
|
-
throw error;
|
|
325
|
-
} finally {
|
|
326
|
-
setIsCreating(false);
|
|
327
|
-
}
|
|
328
|
-
};
|
|
329
|
-
|
|
330
|
-
const chooseStorageDirectory = async () => {
|
|
331
|
-
if (!onChooseStorageDirectory) return;
|
|
332
|
-
setChoosingStorageDirectory(true);
|
|
333
|
-
setStorageLocationError(null);
|
|
334
|
-
try {
|
|
335
|
-
const pathParts = effectivePath.split('/');
|
|
336
|
-
pathParts.pop();
|
|
337
|
-
const chosen = await onChooseStorageDirectory(pathParts.join('/'));
|
|
338
|
-
if (chosen !== null) setStorageDirectory(chosen);
|
|
339
|
-
} catch (error) {
|
|
340
|
-
setStorageLocationError(
|
|
341
|
-
error instanceof Error ? error.message : String(error),
|
|
342
|
-
);
|
|
343
|
-
} finally {
|
|
344
|
-
setChoosingStorageDirectory(false);
|
|
345
|
-
}
|
|
346
|
-
};
|
|
347
|
-
|
|
348
|
-
const isClone = mode === 'clone';
|
|
349
|
-
|
|
350
|
-
return (
|
|
351
|
-
<div
|
|
352
|
-
className={`xynolog-page${activePanel && COMMON_PANELS.includes(activePanel) ? ' xynolog-page--panel-open' : ''}`}
|
|
353
|
-
>
|
|
354
|
-
{/* Main Content Area */}
|
|
355
|
-
<div className="xynolog-page__content xynolog-page__compose">
|
|
356
|
-
{/* Page Title */}
|
|
357
|
-
<div className="xynolog-page__header">
|
|
358
|
-
<h1 className="xynolog-page__title">
|
|
359
|
-
{isClone ? t.titleEditClone : t.title}
|
|
360
|
-
</h1>
|
|
361
|
-
{isClone && (
|
|
362
|
-
<p className="xynolog-page__subtitle">{t.subtitleClone}</p>
|
|
363
|
-
)}
|
|
364
|
-
</div>
|
|
365
|
-
|
|
366
|
-
{/* Create Form */}
|
|
367
|
-
<div className="xynolog-form">
|
|
368
|
-
<form
|
|
369
|
-
onSubmit={handleSaveResource}
|
|
370
|
-
className="xynolog-form__fields xynolog-compose-grid"
|
|
371
|
-
>
|
|
372
|
-
{/* Left column: metadata */}
|
|
373
|
-
<div className="xynolog-compose-grid__meta">
|
|
374
|
-
{/* Name */}
|
|
375
|
-
<div className="xynolog-form__field">
|
|
376
|
-
<label htmlFor="docName" className="xynolog-form__label">
|
|
377
|
-
{t.resourceName}
|
|
378
|
-
</label>
|
|
379
|
-
<input
|
|
380
|
-
id="docName"
|
|
381
|
-
type="text"
|
|
382
|
-
value={newResourceName}
|
|
383
|
-
onChange={(e) => setNewResourceName(e.target.value)}
|
|
384
|
-
placeholder={t.resourceNamePlaceholder}
|
|
385
|
-
className="xynolog-input"
|
|
386
|
-
required
|
|
387
|
-
disabled={isCreating}
|
|
388
|
-
/>
|
|
389
|
-
</div>
|
|
390
|
-
|
|
391
|
-
{/* Storage URI */}
|
|
392
|
-
<div className="xynolog-form__field">
|
|
393
|
-
{onChooseStorageDirectory ? (
|
|
394
|
-
<div className="xynolog-form__label">
|
|
395
|
-
Location in Knowledge Base
|
|
396
|
-
</div>
|
|
397
|
-
) : (
|
|
398
|
-
<label htmlFor="storagePath" className="xynolog-form__label">
|
|
399
|
-
Save location
|
|
400
|
-
</label>
|
|
401
|
-
)}
|
|
402
|
-
{onChooseStorageDirectory ? (
|
|
403
|
-
<div className="xynolog-form__location-picker">
|
|
404
|
-
<code id="storagePath" title={effectivePath}>
|
|
405
|
-
file://{effectivePath}
|
|
406
|
-
</code>
|
|
407
|
-
<button
|
|
408
|
-
type="button"
|
|
409
|
-
className="xynolog-form__location-button"
|
|
410
|
-
onClick={() => void chooseStorageDirectory()}
|
|
411
|
-
disabled={isCreating || choosingStorageDirectory}
|
|
412
|
-
>
|
|
413
|
-
{choosingStorageDirectory
|
|
414
|
-
? 'Choosing…'
|
|
415
|
-
: (t.chooseFolder ?? 'Choose folder…')}
|
|
416
|
-
</button>
|
|
417
|
-
</div>
|
|
418
|
-
) : (
|
|
419
|
-
<div className="xynolog-input-addon">
|
|
420
|
-
<span className="xynolog-input-addon__prefix">file://</span>
|
|
421
|
-
<input
|
|
422
|
-
id="storagePath"
|
|
423
|
-
type="text"
|
|
424
|
-
value={effectivePath}
|
|
425
|
-
onChange={(e) => setStoragePath(e.target.value)}
|
|
426
|
-
placeholder="docs/my-resource.md"
|
|
427
|
-
required
|
|
428
|
-
className="xynolog-input xynolog-input--addon"
|
|
429
|
-
disabled={isCreating}
|
|
430
|
-
/>
|
|
431
|
-
</div>
|
|
432
|
-
)}
|
|
433
|
-
{onChooseStorageDirectory && (
|
|
434
|
-
<p className="xynolog-form__location-hint">
|
|
435
|
-
{t.locationHint ??
|
|
436
|
-
'The resource name determines the filename. Choose a folder within this Knowledge Base.'}
|
|
437
|
-
</p>
|
|
438
|
-
)}
|
|
439
|
-
{storageLocationError && (
|
|
440
|
-
<p className="xynolog-form__location-error" role="alert">
|
|
441
|
-
{storageLocationError}
|
|
442
|
-
</p>
|
|
443
|
-
)}
|
|
444
|
-
</div>
|
|
445
|
-
|
|
446
|
-
{/* Entity Types Selection */}
|
|
447
|
-
{
|
|
448
|
-
<div className="xynolog-form__field xynolog-form__entity-types">
|
|
449
|
-
<div className="xynolog-form__label">{t.entityTypes}</div>
|
|
450
|
-
<div
|
|
451
|
-
className="xynolog-form__entity-type-buttons"
|
|
452
|
-
role="group"
|
|
453
|
-
aria-describedby="entity-types-description"
|
|
454
|
-
>
|
|
455
|
-
{availableEntityTypes.map((type: string) => {
|
|
456
|
-
const isSelected = selectedEntityTypes.includes(type);
|
|
457
|
-
return (
|
|
458
|
-
<button
|
|
459
|
-
key={type}
|
|
460
|
-
type="button"
|
|
461
|
-
onClick={() => {
|
|
462
|
-
setSelectedEntityTypes((prev) =>
|
|
463
|
-
prev.includes(type)
|
|
464
|
-
? prev.filter((t) => t !== type)
|
|
465
|
-
: [...prev, type],
|
|
466
|
-
);
|
|
467
|
-
}}
|
|
468
|
-
className="xynolog-form__entity-type-button"
|
|
469
|
-
data-selected={isSelected}
|
|
470
|
-
disabled={isCreating}
|
|
471
|
-
aria-pressed={isSelected}
|
|
472
|
-
aria-label={`${type} entity type, ${isSelected ? 'selected' : 'not selected'}`}
|
|
473
|
-
>
|
|
474
|
-
{type}
|
|
475
|
-
</button>
|
|
476
|
-
);
|
|
477
|
-
})}
|
|
478
|
-
</div>
|
|
479
|
-
{selectedEntityTypes.length > 0 && (
|
|
480
|
-
<div
|
|
481
|
-
className="sr-only"
|
|
482
|
-
aria-live="polite"
|
|
483
|
-
aria-atomic="true"
|
|
484
|
-
>
|
|
485
|
-
{selectedEntityTypes.length} entity type
|
|
486
|
-
{selectedEntityTypes.length !== 1
|
|
487
|
-
? 's'
|
|
488
|
-
: ''} selected: {selectedEntityTypes.join(', ')}
|
|
489
|
-
</div>
|
|
490
|
-
)}
|
|
491
|
-
</div>
|
|
492
|
-
}
|
|
493
|
-
|
|
494
|
-
{/* Language Selector */}
|
|
495
|
-
<div className="xynolog-form__field">
|
|
496
|
-
<label
|
|
497
|
-
htmlFor="language-select"
|
|
498
|
-
className="xynolog-form__label"
|
|
499
|
-
>
|
|
500
|
-
{t.language}
|
|
501
|
-
</label>
|
|
502
|
-
<select
|
|
503
|
-
id="language-select"
|
|
504
|
-
value={selectedLanguage}
|
|
505
|
-
onChange={(e) => setSelectedLanguage(e.target.value)}
|
|
506
|
-
disabled={isCreating}
|
|
507
|
-
className="xynolog-select"
|
|
508
|
-
>
|
|
509
|
-
{LOCALES.map((lang) => (
|
|
510
|
-
<option key={lang.code} value={lang.code}>
|
|
511
|
-
{lang.nativeName}
|
|
512
|
-
</option>
|
|
513
|
-
))}
|
|
514
|
-
</select>
|
|
515
|
-
</div>
|
|
516
|
-
</div>
|
|
517
|
-
{/* end xynolog-compose-grid__meta */}
|
|
518
|
-
|
|
519
|
-
{/* Right column: content */}
|
|
520
|
-
<div className="xynolog-compose-grid__content">
|
|
521
|
-
{/* Content Source Toggle - only show for new resources */}
|
|
522
|
-
{!isClone && (
|
|
523
|
-
<div className="xynolog-form__field">
|
|
524
|
-
<label className="xynolog-form__label">
|
|
525
|
-
{t.contentSource}
|
|
526
|
-
</label>
|
|
527
|
-
<div className="xynolog-form__content-source-toggle">
|
|
528
|
-
<button
|
|
529
|
-
type="button"
|
|
530
|
-
onClick={() => setInputMethod('upload')}
|
|
531
|
-
disabled={isCreating}
|
|
532
|
-
className="xynolog-form__content-source-button"
|
|
533
|
-
data-active={inputMethod === 'upload'}
|
|
534
|
-
>
|
|
535
|
-
<div className="xynolog-form__content-source-icon-wrapper">
|
|
536
|
-
<span className="xynolog-form__content-source-icon">
|
|
537
|
-
📎
|
|
538
|
-
</span>
|
|
539
|
-
<span className="xynolog-form__content-source-label">
|
|
540
|
-
{t.uploadFile}
|
|
541
|
-
</span>
|
|
542
|
-
</div>
|
|
543
|
-
<div className="xynolog-form__content-source-description">
|
|
544
|
-
{t.uploadFileDescription}
|
|
545
|
-
</div>
|
|
546
|
-
</button>
|
|
547
|
-
|
|
548
|
-
<button
|
|
549
|
-
type="button"
|
|
550
|
-
onClick={() => setInputMethod('write')}
|
|
551
|
-
disabled={isCreating}
|
|
552
|
-
className="xynolog-form__content-source-button"
|
|
553
|
-
data-active={inputMethod === 'write'}
|
|
554
|
-
>
|
|
555
|
-
<div className="xynolog-form__content-source-icon-wrapper">
|
|
556
|
-
<span className="xynolog-form__content-source-icon">
|
|
557
|
-
✍️
|
|
558
|
-
</span>
|
|
559
|
-
<span className="xynolog-form__content-source-label">
|
|
560
|
-
{t.writeContent}
|
|
561
|
-
</span>
|
|
562
|
-
</div>
|
|
563
|
-
<div className="xynolog-form__content-source-description">
|
|
564
|
-
{t.writeContentDescription}
|
|
565
|
-
</div>
|
|
566
|
-
</button>
|
|
567
|
-
</div>
|
|
568
|
-
</div>
|
|
569
|
-
)}
|
|
570
|
-
|
|
571
|
-
{/* Upload File Section */}
|
|
572
|
-
{!isClone && inputMethod === 'upload' && (
|
|
573
|
-
<div className="xynolog-form__upload-section">
|
|
574
|
-
<div>
|
|
575
|
-
<div className="xynolog-form__upload-container">
|
|
576
|
-
<label
|
|
577
|
-
className="xynolog-form__upload-dropzone"
|
|
578
|
-
data-drag-over={isDragOver ? 'true' : 'false'}
|
|
579
|
-
onDragOver={(e) => {
|
|
580
|
-
e.preventDefault();
|
|
581
|
-
setIsDragOver(true);
|
|
582
|
-
}}
|
|
583
|
-
onDragLeave={() => setIsDragOver(false)}
|
|
584
|
-
onDrop={(e) => {
|
|
585
|
-
e.preventDefault();
|
|
586
|
-
setIsDragOver(false);
|
|
587
|
-
const file = e.dataTransfer.files?.[0];
|
|
588
|
-
if (file && !isCreating) applyUploadedFile(file);
|
|
589
|
-
}}
|
|
590
|
-
>
|
|
591
|
-
<div className="xynolog-form__upload-area">
|
|
592
|
-
<input
|
|
593
|
-
type="file"
|
|
594
|
-
accept={UPLOAD_ACCEPT}
|
|
595
|
-
onChange={handleFileUpload}
|
|
596
|
-
className="xynolog-form__upload-input"
|
|
597
|
-
disabled={isCreating}
|
|
598
|
-
/>
|
|
599
|
-
<p className="xynolog-form__upload-text">
|
|
600
|
-
{uploadedFile
|
|
601
|
-
? uploadedFile.name
|
|
602
|
-
: t.dropFileOrClick}
|
|
603
|
-
</p>
|
|
604
|
-
<p className="xynolog-form__upload-hint">
|
|
605
|
-
{t.supportedFormats}
|
|
606
|
-
</p>
|
|
607
|
-
</div>
|
|
608
|
-
</label>
|
|
609
|
-
{uploadedFile && (
|
|
610
|
-
<button
|
|
611
|
-
type="button"
|
|
612
|
-
onClick={() => {
|
|
613
|
-
setUploadedFile(null);
|
|
614
|
-
setFilePreviewUrl(null);
|
|
615
|
-
setFileMimeType('text/markdown');
|
|
616
|
-
}}
|
|
617
|
-
className="xynolog-button xynolog-button--danger xynolog-button--small"
|
|
618
|
-
disabled={isCreating}
|
|
619
|
-
>
|
|
620
|
-
Clear
|
|
621
|
-
</button>
|
|
622
|
-
)}
|
|
623
|
-
</div>
|
|
624
|
-
</div>
|
|
625
|
-
|
|
626
|
-
{/* Media Type Display - Auto-detected */}
|
|
627
|
-
{uploadedFile && (
|
|
628
|
-
<div className="xynolog-form__media-type">
|
|
629
|
-
<span className="xynolog-form__media-type-label">
|
|
630
|
-
{t.mediaType}:
|
|
631
|
-
</span>
|
|
632
|
-
<code className="xynolog-form__media-type-value">
|
|
633
|
-
{fileMimeType}
|
|
634
|
-
</code>
|
|
635
|
-
<span
|
|
636
|
-
className="xynolog-form__media-type-lock"
|
|
637
|
-
title={t.autoDetected}
|
|
638
|
-
>
|
|
639
|
-
🔒
|
|
640
|
-
</span>
|
|
641
|
-
</div>
|
|
642
|
-
)}
|
|
643
|
-
|
|
644
|
-
{/* Image Preview */}
|
|
645
|
-
{uploadedFile &&
|
|
646
|
-
filePreviewUrl &&
|
|
647
|
-
capabilitiesOf(fileMimeType)?.render === 'image' && (
|
|
648
|
-
<div className="xynolog-form__image-preview">
|
|
649
|
-
<p className="xynolog-form__image-preview-label">
|
|
650
|
-
Preview:
|
|
651
|
-
</p>
|
|
652
|
-
<div className="xynolog-form__image-preview-container">
|
|
653
|
-
<img
|
|
654
|
-
src={filePreviewUrl}
|
|
655
|
-
alt="Upload preview"
|
|
656
|
-
className="xynolog-form__image-preview-img"
|
|
657
|
-
/>
|
|
658
|
-
</div>
|
|
659
|
-
</div>
|
|
660
|
-
)}
|
|
661
|
-
</div>
|
|
662
|
-
)}
|
|
663
|
-
|
|
664
|
-
{/* Write Content Section */}
|
|
665
|
-
{(isClone || inputMethod === 'write') && (
|
|
666
|
-
<div className="xynolog-form__write-section">
|
|
667
|
-
{/* Format Selector - only for manual entry, not clones */}
|
|
668
|
-
{!isClone && (
|
|
669
|
-
<div className="xynolog-form__field">
|
|
670
|
-
<label
|
|
671
|
-
htmlFor="format-select"
|
|
672
|
-
className="xynolog-form__label"
|
|
673
|
-
>
|
|
674
|
-
{t.format}
|
|
675
|
-
</label>
|
|
676
|
-
<select
|
|
677
|
-
id="format-select"
|
|
678
|
-
value={selectedFormat}
|
|
679
|
-
onChange={(e) => setSelectedFormat(e.target.value)}
|
|
680
|
-
disabled={isCreating}
|
|
681
|
-
className="xynolog-select"
|
|
682
|
-
>
|
|
683
|
-
{AUTHORABLE_MEDIA_TYPES.map((mt) => (
|
|
684
|
-
<option key={mt} value={mt}>
|
|
685
|
-
{capabilitiesOf(mt)?.label ?? mt} ({mt})
|
|
686
|
-
</option>
|
|
687
|
-
))}
|
|
688
|
-
</select>
|
|
689
|
-
</div>
|
|
690
|
-
)}
|
|
691
|
-
|
|
692
|
-
{/* Content Editor */}
|
|
693
|
-
<div className="xynolog-form__field xynolog-form__editor">
|
|
694
|
-
<label className="xynolog-form__label">
|
|
695
|
-
{isClone ? t.resourceContent : t.content}
|
|
696
|
-
</label>
|
|
697
|
-
<div
|
|
698
|
-
className="xynolog-form__editor-wrapper"
|
|
699
|
-
lang={selectedLanguage}
|
|
700
|
-
>
|
|
701
|
-
<CodeMirrorRenderer
|
|
702
|
-
content={newResourceContent}
|
|
703
|
-
editable={!isCreating}
|
|
704
|
-
sourceView={true}
|
|
705
|
-
showLineNumbers={showLineNumbers}
|
|
706
|
-
hoverDelayMs={hoverDelayMs}
|
|
707
|
-
onChange={(newContent) =>
|
|
708
|
-
setNewResourceContent(newContent)
|
|
709
|
-
}
|
|
710
|
-
/>
|
|
711
|
-
</div>
|
|
712
|
-
</div>
|
|
713
|
-
|
|
714
|
-
{/* Encoding Selector - only for manual text entry */}
|
|
715
|
-
{!isClone && (
|
|
716
|
-
<div className="xynolog-form__field">
|
|
717
|
-
<label
|
|
718
|
-
htmlFor="charset-select"
|
|
719
|
-
className="xynolog-form__label"
|
|
720
|
-
>
|
|
721
|
-
{t.encoding}
|
|
722
|
-
</label>
|
|
723
|
-
<select
|
|
724
|
-
id="charset-select"
|
|
725
|
-
value={selectedCharset}
|
|
726
|
-
onChange={(e) => setSelectedCharset(e.target.value)}
|
|
727
|
-
disabled={isCreating}
|
|
728
|
-
className="xynolog-select"
|
|
729
|
-
>
|
|
730
|
-
<option value="">UTF-8 (default)</option>
|
|
731
|
-
<option value="iso-8859-1">ISO-8859-1 (Latin-1)</option>
|
|
732
|
-
<option value="windows-1252">Windows-1252</option>
|
|
733
|
-
<option value="ascii">ASCII</option>
|
|
734
|
-
<option value="utf-16le">UTF-16LE</option>
|
|
735
|
-
</select>
|
|
736
|
-
</div>
|
|
737
|
-
)}
|
|
738
|
-
</div>
|
|
739
|
-
)}
|
|
740
|
-
|
|
741
|
-
{/* Archive Original Checkbox (for clones only) */}
|
|
742
|
-
{isClone && (
|
|
743
|
-
<div className="xynolog-form__checkbox-field">
|
|
744
|
-
<input
|
|
745
|
-
id="archiveOriginal"
|
|
746
|
-
type="checkbox"
|
|
747
|
-
checked={archiveOriginal}
|
|
748
|
-
onChange={(e) => setArchiveOriginal(e.target.checked)}
|
|
749
|
-
className="xynolog-checkbox"
|
|
750
|
-
disabled={isCreating}
|
|
751
|
-
/>
|
|
752
|
-
<label
|
|
753
|
-
htmlFor="archiveOriginal"
|
|
754
|
-
className="xynolog-form__checkbox-label"
|
|
755
|
-
>
|
|
756
|
-
{t.archiveOriginal}
|
|
757
|
-
</label>
|
|
758
|
-
</div>
|
|
759
|
-
)}
|
|
760
|
-
</div>
|
|
761
|
-
{/* end xynolog-compose-grid__content */}
|
|
762
|
-
|
|
763
|
-
{/* Action Buttons */}
|
|
764
|
-
<div className="xynolog-form__actions">
|
|
765
|
-
<button
|
|
766
|
-
type="button"
|
|
767
|
-
onClick={onCancel}
|
|
768
|
-
disabled={isCreating || uploadProgress !== null}
|
|
769
|
-
className={buttonStyles.tertiary.base}
|
|
770
|
-
>
|
|
771
|
-
{t.cancel}
|
|
772
|
-
</button>
|
|
773
|
-
<button
|
|
774
|
-
type="submit"
|
|
775
|
-
disabled={
|
|
776
|
-
isCreating ||
|
|
777
|
-
uploadProgress !== null ||
|
|
778
|
-
!newResourceName.trim()
|
|
779
|
-
}
|
|
780
|
-
className={buttonStyles.primary.base}
|
|
781
|
-
>
|
|
782
|
-
{isCreating
|
|
783
|
-
? isClone
|
|
784
|
-
? t.saving
|
|
785
|
-
: t.creating
|
|
786
|
-
: isClone
|
|
787
|
-
? t.saveClonedResource
|
|
788
|
-
: t.createResource}
|
|
789
|
-
</button>
|
|
790
|
-
</div>
|
|
791
|
-
|
|
792
|
-
{/* Inline upload progress — renders below the action buttons while
|
|
793
|
-
an upload is in flight. `null` between saves and after completion. */}
|
|
794
|
-
<UploadProgressBar progress={uploadProgress} label={t.uploadFile} />
|
|
795
|
-
</form>
|
|
796
|
-
</div>
|
|
797
|
-
</div>
|
|
798
|
-
|
|
799
|
-
{/* Right Sidebar - Panels and Toolbar */}
|
|
800
|
-
<div className="xynolog-page__sidebar">
|
|
801
|
-
{/* Panels Container */}
|
|
802
|
-
<ToolbarPanels activePanel={activePanel} theme={theme} />
|
|
803
|
-
|
|
804
|
-
{/* Toolbar - Always visible on the right */}
|
|
805
|
-
<Toolbar context="simple" activePanel={activePanel} />
|
|
806
|
-
</div>
|
|
807
|
-
</div>
|
|
808
|
-
);
|
|
809
|
-
}
|