mirror of
https://github.com/filebrowser/filebrowser.git
synced 2025-07-15 04:20:26 +00:00
feat: add font size botton to text editor (#5290)
This commit is contained in:
parent
9072cbce34
commit
035084d8e8
@ -4,6 +4,18 @@
|
|||||||
<action icon="close" :label="t('buttons.close')" @action="close()" />
|
<action icon="close" :label="t('buttons.close')" @action="close()" />
|
||||||
<title>{{ fileStore.req?.name ?? "" }}</title>
|
<title>{{ fileStore.req?.name ?? "" }}</title>
|
||||||
|
|
||||||
|
<action
|
||||||
|
icon="add"
|
||||||
|
@action="increaseFontSize"
|
||||||
|
:label="t('buttons.increaseFontSize')"
|
||||||
|
/>
|
||||||
|
<span class="editor-font-size">{{ fontSize }}px</span>
|
||||||
|
<action
|
||||||
|
icon="remove"
|
||||||
|
@action="decreaseFontSize"
|
||||||
|
:label="t('buttons.decreaseFontSize')"
|
||||||
|
/>
|
||||||
|
|
||||||
<action
|
<action
|
||||||
v-if="authStore.user?.perm.modify"
|
v-if="authStore.user?.perm.modify"
|
||||||
id="save-button"
|
id="save-button"
|
||||||
@ -67,6 +79,7 @@ const route = useRoute();
|
|||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|
||||||
const editor = ref<Ace.Editor | null>(null);
|
const editor = ref<Ace.Editor | null>(null);
|
||||||
|
const fontSize = ref(parseInt(localStorage.getItem("editorFontSize") || "14"));
|
||||||
|
|
||||||
const isPreview = ref(false);
|
const isPreview = ref(false);
|
||||||
const previewContent = ref("");
|
const previewContent = ref("");
|
||||||
@ -121,6 +134,7 @@ onMounted(() => {
|
|||||||
editor.value!.setTheme("ace/theme/twilight");
|
editor.value!.setTheme("ace/theme/twilight");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
editor.value.setFontSize(fontSize.value);
|
||||||
editor.value.focus();
|
editor.value.focus();
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -186,6 +200,21 @@ const save = async () => {
|
|||||||
$showError(e);
|
$showError(e);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const increaseFontSize = () => {
|
||||||
|
fontSize.value += 1;
|
||||||
|
editor.value?.setFontSize(fontSize.value);
|
||||||
|
localStorage.setItem("editorFontSize", fontSize.value.toString());
|
||||||
|
};
|
||||||
|
|
||||||
|
const decreaseFontSize = () => {
|
||||||
|
if (fontSize.value > 1) {
|
||||||
|
fontSize.value -= 1;
|
||||||
|
editor.value?.setFontSize(fontSize.value);
|
||||||
|
localStorage.setItem("editorFontSize", fontSize.value.toString());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const close = () => {
|
const close = () => {
|
||||||
if (!editor.value?.session.getUndoManager().isClean()) {
|
if (!editor.value?.session.getUndoManager().isClean()) {
|
||||||
layoutStore.showHover("discardEditorChanges");
|
layoutStore.showHover("discardEditorChanges");
|
||||||
@ -202,3 +231,10 @@ const preview = () => {
|
|||||||
isPreview.value = !isPreview.value;
|
isPreview.value = !isPreview.value;
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.editor-font-size {
|
||||||
|
margin: 0 0.5em;
|
||||||
|
color: var(--fg);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user