Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Aug 5, 2025. It is now read-only.

Commit72b6fb8

Browse files
committed
[fix] file creation fixes
- fix names- fix checks for allowed actions- fix contextmenu appearance
1 parent53b8bee commit72b6fb8

File tree

3 files changed

+16
-14
lines changed

3 files changed

+16
-14
lines changed

‎src/routes/tutorial/[slug]/+page.svelte‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,10 @@
8484
},
8585
8686
add:async (stubs)=> {
87-
constillegal_create=editing_constraints.create.some(
88-
(c)=>!stubs.some((s)=> (s.type==='directory'&&c.startsWith(s.name))||s.name=== c)
87+
constillegal_create=stubs.some(
88+
(s)=>!editing_constraints.create.some((c)=>s.name=== c)
8989
);
90+
9091
if (illegal_create) {
9192
modal_text=
9293
'Only the following files and folders are allowed to be created in this tutorial chapter:\n'+
@@ -104,14 +105,15 @@
104105
},
105106
106107
edit:async (to_rename,new_name)=> {
107-
constillegal_rename=editing_constraints.remove.some(
108-
(r)=>
109-
(to_rename.type==='directory'&&r.startsWith(to_rename.name))||to_rename.name=== r
110-
);
108+
constillegal_rename=
109+
!editing_constraints.remove.some((r)=>to_rename.name=== r)||
110+
!editing_constraints.create.some((c)=> new_name=== c);
111111
if (illegal_rename) {
112112
modal_text=
113113
'Only the following files and folders are allowed to be renamed in this tutorial chapter:\n'+
114-
editing_constraints.remove.join('\n');
114+
editing_constraints.remove.join('\n')+
115+
'\n\nThey can only be renamed to the following:\n'+
116+
editing_constraints.create.join('\n');
115117
return;
116118
}
117119
@@ -141,9 +143,7 @@
141143
},
142144
143145
remove:async (stub)=> {
144-
constillegal_delete=editing_constraints.remove.some(
145-
(r)=> (stub.type==='directory'&&r.startsWith(stub.name))||stub.name=== r
146-
);
146+
constillegal_delete=!editing_constraints.remove.some((r)=>stub.name=== r);
147147
if (illegal_delete) {
148148
modal_text=
149149
'Only the following files and folders are allowed to be deleted in this tutorial chapter:\n'+

‎src/routes/tutorial/[slug]/ContextMenu.svelte‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
</script>
2525

2626
{#if$menu_items}
27-
<navstyle="position: fixed; z-index:1; top:{$menu_items.y}px; left:{$menu_items.x}px">
27+
<navstyle="position: fixed; z-index:5; top:{$menu_items.y}px; left:{$menu_items.x}px">
2828
<divclass="navbar"id="navbar">
2929
<ul>
3030
{#each$menu_items.itemsasitem}

‎src/routes/tutorial/[slug]/Folder.svelte‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,14 +114,14 @@
114114
for (let i=1; i<=parts.length; i++) {
115115
constpart=parts.slice(0, i).join('/');
116116
constbasename=/**@type{string}*/ (part.split('/').pop());
117-
constname= prefix+ part+'/';
117+
constname= prefix+ part;
118118
if (!files.some((file)=>file.name=== name)) {
119119
if (i<parts.length|| state==='add_folder') {
120120
stubs.push({ type:'directory', name, depth: depth+ i, basename });
121121
}elseif (i===parts.length&& state==='add_file') {
122122
stubs.push({
123123
type:'file',
124-
name:name.slice(0,-1),
124+
name,
125125
depth: depth+ i,
126126
basename,
127127
text:true,
@@ -131,7 +131,9 @@
131131
}
132132
}
133133
134-
add(stubs);
134+
if (stubs.length) {
135+
add(stubs);
136+
}
135137
}
136138
}
137139

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp