Skip to content

Commit 2653e21

Browse files
committed
feat: add possibility to write the filename per editor
1 parent 2fba93d commit 2653e21

File tree

4 files changed

+24
-2
lines changed

4 files changed

+24
-2
lines changed

components/Editor.vue

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<template>
22
<div>
3-
<div ref="toolbar" class="flex items-center justify-between h-10 p-1 bg-white border-b">
4-
<div>
3+
<div ref="toolbar" class="flex items-center justify-between h-10 p-1 bg-white">
4+
<div class="flex flex-row">
55
<select
66
name="language"
77
:value="language"
@@ -98,6 +98,16 @@
9898
</div>
9999
</div>
100100

101+
<div class="flex w-full px-1 pb-1 border-b">
102+
<input
103+
type="text"
104+
:value="filename"
105+
@input="(event) => $emit('filename-change', event.target.value)"
106+
class="block w-full py-1 pl-3 pr-10 text-base border-gray-300 focus:outline-none rounded-lg focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm"
107+
placeholder="filename"
108+
/>
109+
</div>
110+
101111
<div
102112
ref="monaco"
103113
class="min-w-full"
@@ -129,6 +139,7 @@ export default {
129139
value: String,
130140
theme: String,
131141
tabSize: [String, Number],
142+
filename: String,
132143
language: String,
133144
height: Number,
134145
availbleHeight: Number,

components/Page.vue

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
:key="editor.id"
2323
:tab-size="editor.tabSize"
2424
:language="editor.language"
25+
:filename="editor.filename"
2526
:width="isLandscape ? editorWidth : editorWidth / editors.length"
2627
:height="isPortrait ? editorHeight : editorHeight / editors.length"
2728
:landscape="isLandscape"
@@ -36,11 +37,13 @@
3637
@update:layout="toggleLayout"
3738
@update:tab-size="(size) => (editors[index].tabSize = size)"
3839
@update:language="(lang) => (editors[index].language = lang)"
40+
@filename-change="(filename) => (editors[index].filename = filename)"
3941
/>
4042
</div>
4143

4244
<Preview
4345
:tab="tab"
46+
:filenames="filenames"
4447
:code="code"
4548
:languages="languages"
4649
class="flex flex-col justify-between w-full h-full overflow-scroll"
@@ -136,6 +139,10 @@ export default {
136139
}));
137140
},
138141
142+
filenames() {
143+
return this.editors.map(({ filename }) => filename);
144+
},
145+
139146
canRemoveEditor() {
140147
return this.editors.length > 1;
141148
},

components/Preview.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@
8383
ref="preview"
8484
class="z-10"
8585
:blocks="blocks"
86+
:filenames="filenames"
8687
:font-size="settings.fontSize"
8788
:line-height="settings.lineHeight"
8889
:background="settings.background"
@@ -290,6 +291,7 @@ const DEFAULT_WIDTH = 450;
290291
291292
export default {
292293
props: {
294+
filenames: Array,
293295
tab: Object,
294296
code: Array,
295297
languages: Array,

components/Window.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
</div>
3838

3939
<div v-for="(lines, index) in blocks" :key="index" :style="{ padding: `${padding}px` }">
40+
<div class="text-sm mb-2 text-gray-400 w-full text-right">{{ filenames[index] }}</div>
4041
<Code
4142
class="relative"
4243
:lines="lines"
@@ -54,6 +55,7 @@ import FauxMenu from './FauxMenu';
5455
export default {
5556
props: {
5657
blocks: Array,
58+
filenames: Array,
5759
fontSize: [String, Number],
5860
lineHeight: [String, Number],
5961
background: String,

0 commit comments

Comments
 (0)