Skip to content

Commit

Permalink
feat: add possibility to write the filename per editor
Browse files Browse the repository at this point in the history
  • Loading branch information
dimaslz committed Nov 24, 2021
1 parent 2fba93d commit 2653e21
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 2 deletions.
15 changes: 13 additions & 2 deletions components/Editor.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<div>
<div ref="toolbar" class="flex items-center justify-between h-10 p-1 bg-white border-b">
<div>
<div ref="toolbar" class="flex items-center justify-between h-10 p-1 bg-white">
<div class="flex flex-row">
<select
name="language"
:value="language"
Expand Down Expand Up @@ -98,6 +98,16 @@
</div>
</div>

<div class="flex w-full px-1 pb-1 border-b">
<input
type="text"
:value="filename"
@input="(event) => $emit('filename-change', event.target.value)"
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"
placeholder="filename"
/>
</div>

<div
ref="monaco"
class="min-w-full"
Expand Down Expand Up @@ -129,6 +139,7 @@ export default {
value: String,
theme: String,
tabSize: [String, Number],
filename: String,
language: String,
height: Number,
availbleHeight: Number,
Expand Down
7 changes: 7 additions & 0 deletions components/Page.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
:key="editor.id"
:tab-size="editor.tabSize"
:language="editor.language"
:filename="editor.filename"
:width="isLandscape ? editorWidth : editorWidth / editors.length"
:height="isPortrait ? editorHeight : editorHeight / editors.length"
:landscape="isLandscape"
Expand All @@ -36,11 +37,13 @@
@update:layout="toggleLayout"
@update:tab-size="(size) => (editors[index].tabSize = size)"
@update:language="(lang) => (editors[index].language = lang)"
@filename-change="(filename) => (editors[index].filename = filename)"
/>
</div>

<Preview
:tab="tab"
:filenames="filenames"
:code="code"
:languages="languages"
class="flex flex-col justify-between w-full h-full overflow-scroll"
Expand Down Expand Up @@ -136,6 +139,10 @@ export default {
}));
},
filenames() {
return this.editors.map(({ filename }) => filename);
},
canRemoveEditor() {
return this.editors.length > 1;
},
Expand Down
2 changes: 2 additions & 0 deletions components/Preview.vue
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
ref="preview"
class="z-10"
:blocks="blocks"
:filenames="filenames"
:font-size="settings.fontSize"
:line-height="settings.lineHeight"
:background="settings.background"
Expand Down Expand Up @@ -290,6 +291,7 @@ const DEFAULT_WIDTH = 450;
export default {
props: {
filenames: Array,
tab: Object,
code: Array,
languages: Array,
Expand Down
2 changes: 2 additions & 0 deletions components/Window.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
</div>

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

0 comments on commit 2653e21

Please sign in to comment.