-
Notifications
You must be signed in to change notification settings - Fork 85
feat: add files via file tree #314
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Nemikolh
merged 16 commits into
stackblitz:main
from
AriPerkkio:feat/add-files-via-filetree
Sep 13, 2024
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
fa23143
feat(runtime): reactive source for editor files
AriPerkkio 35b666c
feat(runtime): store to support file and folder creation
AriPerkkio 0d1d3e4
feat(runtime): new metadata option `editor.fileTree.allowEdits`
AriPerkkio 1b512d0
feat(react): `<FileTree>` to support file and folder editing
AriPerkkio 2fe5950
docs: `editor.fileTree.allowEdits` and FileTree's `onFileChange`
AriPerkkio 5aa480d
Merge branch 'main' into feat/add-files-via-filetree
AriPerkkio 3eab68f
fix: code review
AriPerkkio c96ed68
feat!: change `FileTree.files` format to identify file/folder type
AriPerkkio 95394df
fix: sort files and folders
AriPerkkio c8d1e84
docs: filetree examples
AriPerkkio 0410f40
chore: enforce type
AriPerkkio 5aba530
fix: code review
AriPerkkio a38731e
fix: code review
AriPerkkio 28f8da2
docs: lowercase methods
AriPerkkio b180631
fix: move file sorting to file tree only
AriPerkkio b2b2239
docs: no need to sort anymore
AriPerkkio File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
26 changes: 16 additions & 10 deletions
26
docs/tutorialkit.dev/src/components/react-examples/ExampleFileTree.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,32 @@ | ||
import { useState } from 'react'; | ||
import { useState, type ComponentProps } from 'react'; | ||
import FileTree from '@tutorialkit/react/core/FileTree'; | ||
|
||
export default function ExampleFileTree() { | ||
const [selectedFile, setSelectedFile] = useState(FILES[0]); | ||
const [files, setFiles] = useState(INITIAL_FILES); | ||
const [selectedFile, setSelectedFile] = useState(INITIAL_FILES[0].path); | ||
|
||
return ( | ||
<FileTree | ||
files={FILES} | ||
files={files} | ||
hideRoot | ||
className="my-file-tree" | ||
hiddenFiles={['package-lock.json']} | ||
selectedFile={selectedFile} | ||
onFileSelect={setSelectedFile} | ||
onFileChange={(event) => { | ||
if (event.method === 'add') { | ||
setFiles([...files, { path: event.value, type: event.type }]); | ||
} | ||
}} | ||
/> | ||
); | ||
} | ||
|
||
const FILES = [ | ||
'/src/index.js', | ||
'/src/index.html', | ||
'/src/assets/logo.svg', | ||
'/package-lock.json', | ||
'/package.json', | ||
'/vite.config.js', | ||
const INITIAL_FILES: ComponentProps<typeof FileTree>['files'] = [ | ||
{ path: '/package-lock.json', type: 'file' }, | ||
{ path: '/package.json', type: 'file' }, | ||
{ path: '/src/assets/logo.svg', type: 'file' }, | ||
{ path: '/src/index.html', type: 'file' }, | ||
{ path: '/src/index.js', type: 'file' }, | ||
{ path: '/vite.config.js', type: 'file' }, | ||
]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
e2e/src/content/tutorial/tests/file-tree/allow-edits-disabled/_files/first-level/file.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export default 'File in first level'; |
1 change: 1 addition & 0 deletions
1
...ent/tutorial/tests/file-tree/allow-edits-disabled/_files/first-level/second-level/file.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export default 'File in second level'; |
11 changes: 11 additions & 0 deletions
11
e2e/src/content/tutorial/tests/file-tree/allow-edits-disabled/content.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
type: lesson | ||
title: Allow Edits Disabled | ||
previews: false | ||
terminal: | ||
panels: terminal | ||
--- | ||
|
||
# File Tree test - Allow Edits Disabled | ||
|
||
Option `editor.fileTree.allowEdits` has default `false` value. |
1 change: 1 addition & 0 deletions
1
e2e/src/content/tutorial/tests/file-tree/allow-edits-enabled/_files/first-level/file.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export default 'File in first level'; |
1 change: 1 addition & 0 deletions
1
...tent/tutorial/tests/file-tree/allow-edits-enabled/_files/first-level/second-level/file.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export default 'File in second level'; |
12 changes: 12 additions & 0 deletions
12
e2e/src/content/tutorial/tests/file-tree/allow-edits-enabled/content.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--- | ||
type: lesson | ||
title: Allow Edits Enabled | ||
previews: false | ||
editor: | ||
fileTree: | ||
allowEdits: true | ||
terminal: | ||
panels: terminal | ||
--- | ||
|
||
# File Tree test - Allow Edits Enabled |
1 change: 1 addition & 0 deletions
1
e2e/src/content/tutorial/tests/file-tree/hidden/_files/example.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export default 'Lesson file example.js content'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
type: lesson | ||
title: Hidden | ||
editor: | ||
fileTree: false | ||
focus: /example.js | ||
--- | ||
|
||
# File Tree test - Hidden |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.