File tree 3 files changed +16
-14
lines changed
src/routes/tutorial/[slug]
3 files changed +16
-14
lines changed Original file line number Diff line number Diff line change 84
84
},
85
85
86
86
add: async (stubs ) => {
87
- const illegal_create = editing_constraints . create .some (
88
- (c ) => ! stubs . some ((s ) => ( s . type === ' directory ' && c . startsWith ( s . name )) || s .name === c)
87
+ const illegal_create = stubs .some (
88
+ (s ) => ! editing_constraints . create . some ((c ) => s .name === c)
89
89
);
90
+
90
91
if (illegal_create) {
91
92
modal_text =
92
93
' Only the following files and folders are allowed to be created in this tutorial chapter:\n ' +
104
105
},
105
106
106
107
edit: async (to_rename , new_name ) => {
107
- const illegal_rename = editing_constraints .remove .some (
108
- (r ) =>
109
- (to_rename .type === ' directory' && r .startsWith (to_rename .name )) || to_rename .name === r
110
- );
108
+ const illegal_rename =
109
+ ! editing_constraints .remove .some ((r ) => to_rename .name === r) ||
110
+ ! editing_constraints .create .some ((c ) => new_name === c);
111
111
if (illegal_rename) {
112
112
modal_text =
113
113
' 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\n They can only be renamed to the following:\n ' +
116
+ editing_constraints .create .join (' \n ' );
115
117
return ;
116
118
}
117
119
141
143
},
142
144
143
145
remove: async (stub ) => {
144
- const illegal_delete = editing_constraints .remove .some (
145
- (r ) => (stub .type === ' directory' && r .startsWith (stub .name )) || stub .name === r
146
- );
146
+ const illegal_delete = ! editing_constraints .remove .some ((r ) => stub .name === r);
147
147
if (illegal_delete) {
148
148
modal_text =
149
149
' Only the following files and folders are allowed to be deleted in this tutorial chapter:\n ' +
Original file line number Diff line number Diff line change 24
24
</script >
25
25
26
26
{#if $menu_items }
27
- <nav style ="position: fixed; z-index: 1 ; top: {$menu_items .y }px; left: {$menu_items .x }px" >
27
+ <nav style ="position: fixed; z-index: 5 ; top: {$menu_items .y }px; left: {$menu_items .x }px" >
28
28
<div class =" navbar" id =" navbar" >
29
29
<ul >
30
30
{#each $menu_items .items as item }
Original file line number Diff line number Diff line change 114
114
for (let i = 1 ; i <= parts .length ; i++ ) {
115
115
const part = parts .slice (0 , i).join (' /' );
116
116
const basename = /** @type {string} */ (part .split (' /' ).pop ());
117
- const name = prefix + part + ' / ' ;
117
+ const name = prefix + part;
118
118
if (! files .some ((file ) => file .name === name)) {
119
119
if (i < parts .length || state === ' add_folder' ) {
120
120
stubs .push ({ type: ' directory' , name, depth: depth + i, basename });
121
121
} else if (i === parts .length && state === ' add_file' ) {
122
122
stubs .push ({
123
123
type: ' file' ,
124
- name: name . slice ( 0 , - 1 ) ,
124
+ name,
125
125
depth: depth + i,
126
126
basename,
127
127
text: true ,
131
131
}
132
132
}
133
133
134
- add (stubs);
134
+ if (stubs .length ) {
135
+ add (stubs);
136
+ }
135
137
}
136
138
}
137
139
You can’t perform that action at this time.
0 commit comments