Skip to content

Commit 9268462

Browse files
Merge pull request #87 from JSON-ms/dev
Adjust editor height when hovering in desktop mode
2 parents 41eefdc + 91eb485 commit 9268462

3 files changed

Lines changed: 26 additions & 5 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "@json.ms/www",
33
"private": true,
44
"type": "module",
5-
"version": "1.2.15",
5+
"version": "1.2.16",
66
"scripts": {
77
"dev": "vite --host",
88
"build": "run-p type-check \"build-only {@}\" --",

src/components/SitePreview.vue

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<script setup lang="ts">
22
import {useGlobalStore} from '@/stores/global';
3-
import {defineExpose, nextTick, onMounted, onUnmounted, ref, watch} from 'vue';
3+
import {computed, defineExpose, nextTick, onMounted, onUnmounted, ref, watch} from 'vue';
44
import type {IStructure, IStructureData} from '@/interfaces';
55
import {useLayout} from '@/composables/layout';
66
import StructureEditor from '@/components/StructureEditor.vue';
@@ -24,11 +24,21 @@ const loaded = ref(false);
2424
const loading = ref(false);
2525
const killIframe = ref(false);
2626
const siteNotCompatibleSnack = ref(false);
27+
const hoveringEditor = ref(false);
2728
const { layoutSize, windowHeight, layoutPx } = useLayout();
2829
const { reloading, siteCompatible, sendMessageToIframe, getPathsFromSectionKey, listenIframeMessage, sendUserDataToIframe } = useIframe();
2930
const { userDataLoading } = useUserData();
3031
const iframeErrorMsg = ref('This site is not JSONms compatible');
3132
33+
const editorHeight = computed((): number => {
34+
const padding = (globalStore.userSettings.data.layoutSitePreviewPadding ? 96 : 63);
35+
const result = windowHeight.value - padding;
36+
if (hoveringEditor.value) {
37+
return result + 32;
38+
}
39+
return result - layoutSize.value.preview.height;
40+
})
41+
3242
const refresh = () => {
3343
if (siteCompatible.value) {
3444
reloading.value = true;
@@ -212,7 +222,15 @@ defineExpose({
212222
<template #append>
213223
<v-expand-transition>
214224
<div v-show="globalStore.admin.previewMode === 'desktop' && globalStore.admin.structure">
215-
<v-card :height="windowHeight - layoutSize.preview.height - (globalStore.userSettings.data.layoutSitePreviewPadding ? 96 : 63)" tile flat theme="dark">
225+
<v-card
226+
:height="editorHeight"
227+
tile
228+
flat
229+
class="editor-card"
230+
theme="dark"
231+
@mouseover="hoveringEditor = true"
232+
@mouseleave="hoveringEditor = false"
233+
>
216234
<StructureEditor
217235
ref="structureEditor"
218236
v-model="structure"
@@ -238,4 +256,7 @@ defineExpose({
238256
transition: all 200ms ease;
239257
}
240258
}
259+
.editor-card {
260+
transition: height 300ms ease;
261+
}
241262
</style>

src/components/StructureEditor.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,9 @@ const scrollToSection = (section: string) => {
161161
const annotations = [];
162162
const line = findNeedleInString(structure.value.content, ' ' + section + ':');
163163
if (line) {
164-
instance.renderer.scrollToLine(line, false, true);
164+
instance.renderer.scrollToLine(line - 1, false, true);
165165
annotations.push({
166-
row: line,
166+
row: line - 1,
167167
column: 0,
168168
text: "Current section",
169169
type: "info"

0 commit comments

Comments
 (0)