@aprovan/patchwork-editor 0.1.2-dev.03aaf5b → 0.1.2-dev.ba8f277
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/.turbo/turbo-build.log +2 -2
- package/dist/components/CodePreview.d.ts +10 -1
- package/dist/components/MarkdownPreview.d.ts +8 -0
- package/dist/components/SaveStatusButton.d.ts +9 -0
- package/dist/components/ServicesInspector.d.ts +3 -4
- package/dist/components/WidgetPreview.d.ts +8 -0
- package/dist/components/edit/EditModal.d.ts +2 -1
- package/dist/components/edit/FileTree.d.ts +22 -3
- package/dist/components/edit/fileTypes.d.ts +2 -0
- package/dist/components/edit/useEditSession.d.ts +1 -0
- package/dist/components/index.d.ts +7 -5
- package/dist/index.d.ts +3 -3
- package/dist/index.js +904 -176
- package/package.json +3 -3
- package/src/components/CodePreview.tsx +118 -160
- package/src/components/MarkdownPreview.tsx +147 -0
- package/src/components/SaveStatusButton.tsx +55 -0
- package/src/components/ServicesInspector.tsx +101 -37
- package/src/components/WidgetPreview.tsx +102 -0
- package/src/components/edit/EditModal.tsx +83 -26
- package/src/components/edit/FileTree.tsx +523 -28
- package/src/components/edit/api.ts +6 -1
- package/src/components/edit/fileTypes.ts +8 -0
- package/src/components/edit/useEditSession.ts +13 -3
- package/src/components/index.ts +7 -5
- package/src/index.ts +10 -6
|
@@ -12,6 +12,7 @@ import type {
|
|
|
12
12
|
export interface UseEditSessionOptions {
|
|
13
13
|
originalCode?: string;
|
|
14
14
|
originalProject?: VirtualProject;
|
|
15
|
+
initialActiveFile?: string;
|
|
15
16
|
compile?: CompileFn;
|
|
16
17
|
apiEndpoint?: string;
|
|
17
18
|
}
|
|
@@ -29,6 +30,7 @@ export function useEditSession(
|
|
|
29
30
|
const {
|
|
30
31
|
originalCode,
|
|
31
32
|
originalProject: providedProject,
|
|
33
|
+
initialActiveFile,
|
|
32
34
|
compile,
|
|
33
35
|
apiEndpoint,
|
|
34
36
|
} = options;
|
|
@@ -49,7 +51,11 @@ export function useEditSession(
|
|
|
49
51
|
const lastSyncedProjectRef = useRef<VirtualProject>(originalProject);
|
|
50
52
|
|
|
51
53
|
const [project, setProject] = useState<VirtualProject>(originalProject);
|
|
52
|
-
const [activeFile, setActiveFile] = useState(
|
|
54
|
+
const [activeFile, setActiveFile] = useState(
|
|
55
|
+
initialActiveFile && originalProject.files.has(initialActiveFile)
|
|
56
|
+
? initialActiveFile
|
|
57
|
+
: originalProject.entry,
|
|
58
|
+
);
|
|
53
59
|
const [history, setHistory] = useState<EditHistoryEntry[]>([]);
|
|
54
60
|
const [isApplying, setIsApplying] = useState(false);
|
|
55
61
|
const [error, setError] = useState<string | null>(null);
|
|
@@ -61,12 +67,16 @@ export function useEditSession(
|
|
|
61
67
|
if (originalProject !== lastSyncedProjectRef.current) {
|
|
62
68
|
lastSyncedProjectRef.current = originalProject;
|
|
63
69
|
setProject(originalProject);
|
|
64
|
-
setActiveFile(
|
|
70
|
+
setActiveFile(
|
|
71
|
+
initialActiveFile && originalProject.files.has(initialActiveFile)
|
|
72
|
+
? initialActiveFile
|
|
73
|
+
: originalProject.entry,
|
|
74
|
+
);
|
|
65
75
|
setHistory([]);
|
|
66
76
|
setError(null);
|
|
67
77
|
setStreamingNotes([]);
|
|
68
78
|
}
|
|
69
|
-
}, [originalProject]);
|
|
79
|
+
}, [originalProject, initialActiveFile]);
|
|
70
80
|
|
|
71
81
|
const performEdit = useCallback(
|
|
72
82
|
async (
|
package/src/components/index.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
export { CodeBlockExtension } from
|
|
2
|
-
export { CodePreview } from
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
5
|
-
export
|
|
1
|
+
export { CodeBlockExtension } from "./CodeBlockExtension";
|
|
2
|
+
export { CodePreview } from "./CodePreview";
|
|
3
|
+
export { WidgetPreview } from "./WidgetPreview";
|
|
4
|
+
export { MarkdownEditor } from "./MarkdownEditor";
|
|
5
|
+
export { MarkdownPreview } from "./MarkdownPreview";
|
|
6
|
+
export { ServicesInspector, type ServiceInfo } from "./ServicesInspector";
|
|
7
|
+
export * from "./edit";
|
package/src/index.ts
CHANGED
|
@@ -2,10 +2,12 @@
|
|
|
2
2
|
export {
|
|
3
3
|
CodeBlockExtension,
|
|
4
4
|
CodePreview,
|
|
5
|
+
WidgetPreview,
|
|
5
6
|
MarkdownEditor,
|
|
7
|
+
MarkdownPreview,
|
|
6
8
|
ServicesInspector,
|
|
7
9
|
type ServiceInfo,
|
|
8
|
-
} from
|
|
10
|
+
} from "./components";
|
|
9
11
|
|
|
10
12
|
// Edit components
|
|
11
13
|
export {
|
|
@@ -40,11 +42,13 @@ export {
|
|
|
40
42
|
isCompilable,
|
|
41
43
|
isMediaFile,
|
|
42
44
|
isTextFile,
|
|
45
|
+
isMarkdownFile,
|
|
46
|
+
isPreviewable,
|
|
43
47
|
isImageFile,
|
|
44
48
|
isVideoFile,
|
|
45
49
|
getLanguageFromExt,
|
|
46
50
|
getMimeType,
|
|
47
|
-
} from
|
|
51
|
+
} from "./components/edit";
|
|
48
52
|
|
|
49
53
|
// Lib utilities
|
|
50
54
|
export {
|
|
@@ -58,7 +62,7 @@ export {
|
|
|
58
62
|
type CodePart,
|
|
59
63
|
type ParsedPart,
|
|
60
64
|
type ExtractOptions,
|
|
61
|
-
|
|
65
|
+
|
|
62
66
|
// Diff utilities
|
|
63
67
|
parseCodeBlockAttributes,
|
|
64
68
|
parseCodeBlocks,
|
|
@@ -74,7 +78,7 @@ export {
|
|
|
74
78
|
type CodeBlock,
|
|
75
79
|
type DiffBlock,
|
|
76
80
|
type ParsedEditResponse,
|
|
77
|
-
|
|
81
|
+
|
|
78
82
|
// VFS utilities
|
|
79
83
|
getVFSConfig,
|
|
80
84
|
getVFSStore,
|
|
@@ -83,7 +87,7 @@ export {
|
|
|
83
87
|
listProjects,
|
|
84
88
|
saveFile,
|
|
85
89
|
isVFSAvailable,
|
|
86
|
-
|
|
90
|
+
|
|
87
91
|
// General utilities
|
|
88
92
|
cn,
|
|
89
|
-
} from
|
|
93
|
+
} from "./lib";
|