Skip to content

Commit

Permalink
feat(UI): resizable textarea in new/edito note, closes #747
Browse files Browse the repository at this point in the history
  • Loading branch information
Fabio286 committed Feb 4, 2024
1 parent bb36e98 commit 1a0c5da
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 10 deletions.
Empty file removed src/common/interfaces/parser.ts
Empty file.
12 changes: 10 additions & 2 deletions src/renderer/components/BaseConfirmModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ const { t } = useI18n();
const props = defineProps({
size: {
type: String as PropType<'small' | 'medium' | '400' | 'large'>,
validator: (prop: string) => ['small', 'medium', '400', 'large'].includes(prop),
type: String as PropType<'small' | 'medium' | '400' | 'large' | 'resize'>,
validator: (prop: string) => ['small', 'medium', '400', 'large', 'resize'].includes(prop),
default: 'small'
},
hideFooter: {
Expand Down Expand Up @@ -88,6 +88,8 @@ const modalSizeClass = computed(() => {
return 'modal-sm';
if (props.size === '400')
return 'modal-400';
if (props.size === 'resize')
return 'modal-resize';
else if (props.size === 'large')
return 'modal-lg';
else return '';
Expand Down Expand Up @@ -120,6 +122,12 @@ onBeforeUnmount(() => {
max-width: 400px;
}
.modal-resize .modal-container {
max-width: 95vw;
max-height: 95vh;
width: auto;
}
.modal.modal-sm .modal-container {
padding: 0;
}
Expand Down
20 changes: 14 additions & 6 deletions src/renderer/components/BaseTextEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@
:id="`editor-${id}`"
class="editor"
:class="editorClass"
:style="{height: `${height}px`}"
:style="{
height: `${height}px`,
width: width ? `${width}px` : null,
resize: resizable ? 'both' : 'none'
}"
/>
</div>
</template>
Expand All @@ -17,18 +21,20 @@ import 'ace-builds/webpack-resolver';
import { uidGen } from 'common/libs/uidGen';
import { storeToRefs } from 'pinia';
import { onMounted, watch } from 'vue';
import { PropType, onMounted, watch } from 'vue';
import { useSettingsStore } from '@/stores/settings';
const props = defineProps({
modelValue: String,
mode: { type: String, default: 'text' },
editorClass: { type: String, default: '' },
resizable: { type: Boolean, default: false },
autoFocus: { type: Boolean, default: false },
readOnly: { type: Boolean, default: false },
showLineNumbers: { type: Boolean, default: true },
height: { type: Number, default: 200 }
height: { type: Number, default: 200 },
width: { type: [Number, Boolean] as PropType<number|false>, default: false }
});
const emit = defineEmits(['update:modelValue']);
const settingsStore = useSettingsStore();
Expand Down Expand Up @@ -132,8 +138,10 @@ onMounted(() => {

<style lang="scss" scoped>
.editor-wrapper {
.editor {
width: 100%;
}
.editor {
width: 100%;
height: 100%;
max-width: 90vw;
}
}
</style>
6 changes: 5 additions & 1 deletion src/renderer/components/ModalNoteEdit.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<ConfirmModal
size="medium"
size="resize"
:disable-autofocus="true"
:close-on-confirm="!!localNote.note.length"
:confirm-text="t('general.save')"
Expand Down Expand Up @@ -52,6 +52,10 @@
v-model="localNote.note"
:mode="editorMode"
:show-line-numbers="false"
:auto-focus="true"
:height="400"
:width="640"
:resizable="true"
/>
</div>
</form>
Expand Down
6 changes: 5 additions & 1 deletion src/renderer/components/ModalNoteNew.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<ConfirmModal
size="medium"
size="resize"
:disable-autofocus="true"
:close-on-confirm="!!newNote.note.length"
:confirm-text="t('general.save')"
Expand Down Expand Up @@ -52,6 +52,10 @@
v-model="newNote.note"
:mode="editorMode"
:show-line-numbers="false"
:auto-focus="true"
:height="400"
:width="640"
:resizable="true"
/>
</div>
</form>
Expand Down

0 comments on commit 1a0c5da

Please sign in to comment.