@tailor-cms/tce-preview-runtime 0.0.21 → 0.0.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tailor-cms/tce-preview-runtime",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.27",
|
|
4
4
|
"dependencies": {
|
|
5
5
|
"@mdi/font": "^7.0.96",
|
|
6
6
|
"@vitejs/plugin-vue": "4.3.4",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"access": "public"
|
|
23
23
|
},
|
|
24
24
|
"scripts": {
|
|
25
|
-
"dev": "vite",
|
|
25
|
+
"dev": "vite --open",
|
|
26
26
|
"build": "vue-tsc --noEmit && vite build",
|
|
27
27
|
"serve": "vite preview",
|
|
28
28
|
"lint": "eslint --ext .js,.ts,.vue .",
|
|
@@ -7,23 +7,28 @@ const { isDark, toggleDark, showEdit, showDisplay, showBothComponents } =
|
|
|
7
7
|
</script>
|
|
8
8
|
|
|
9
9
|
<template>
|
|
10
|
-
<v-app-bar :color="isDark ? '
|
|
10
|
+
<v-app-bar :color="isDark ? 'grey-darken-4' : 'grey-lighten-4'" elevation="1">
|
|
11
11
|
<template #prepend>
|
|
12
|
-
<v-app-bar-nav-icon class="ml-
|
|
13
|
-
<
|
|
14
|
-
<img :src="logoUrl" alt="Tailor logo" width="30" />
|
|
15
|
-
</v-avatar>
|
|
12
|
+
<v-app-bar-nav-icon class="ml-2">
|
|
13
|
+
<img :src="logoUrl" alt="Tailor logo" width="24" />
|
|
16
14
|
</v-app-bar-nav-icon>
|
|
17
15
|
</template>
|
|
18
|
-
<v-app-bar-title class="ml-
|
|
16
|
+
<v-app-bar-title class="ml-1 font-weight-bold">
|
|
17
|
+
Content Element Kit
|
|
18
|
+
<span class="pl-1 text-body-2 font-weight-bold">0.0.1</span>
|
|
19
|
+
</v-app-bar-title>
|
|
19
20
|
<v-spacer />
|
|
20
|
-
<v-btn-toggle
|
|
21
|
+
<v-btn-toggle
|
|
22
|
+
:variant="isDark ? 'flat' : 'tonal'"
|
|
23
|
+
class="mr-4"
|
|
24
|
+
density="compact"
|
|
25
|
+
>
|
|
21
26
|
<v-btn @click="showEdit">
|
|
22
27
|
<span>Edit</span>
|
|
23
28
|
<v-icon end>mdi-pencil</v-icon>
|
|
24
29
|
</v-btn>
|
|
25
30
|
<v-btn @click="showDisplay">
|
|
26
|
-
<span>
|
|
31
|
+
<span>Display</span>
|
|
27
32
|
<v-icon end>mdi-fullscreen</v-icon>
|
|
28
33
|
</v-btn>
|
|
29
34
|
<v-btn @click="showBothComponents">
|
|
@@ -31,7 +36,7 @@ const { isDark, toggleDark, showEdit, showDisplay, showBothComponents } =
|
|
|
31
36
|
<v-icon end>mdi-math-norm-box</v-icon>
|
|
32
37
|
</v-btn>
|
|
33
38
|
</v-btn-toggle>
|
|
34
|
-
<v-btn href="https://github.com/tailor-cms/
|
|
39
|
+
<v-btn href="https://github.com/tailor-cms/tce-template" icon>
|
|
35
40
|
<v-icon>mdi-github</v-icon>
|
|
36
41
|
</v-btn>
|
|
37
42
|
<v-btn icon @click.prevent="toggleDark()">
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div v-show="isLoaded">
|
|
3
|
+
<v-tabs density="compact" hide-slider>
|
|
4
|
+
<v-tab>Server state</v-tab>
|
|
5
|
+
</v-tabs>
|
|
6
|
+
<div class="pa-6">
|
|
7
|
+
<JsonEditor
|
|
8
|
+
v-if="isLoaded"
|
|
9
|
+
:main-menu-bar="false"
|
|
10
|
+
:status-bar="false"
|
|
11
|
+
:value="orderKeys(props.element)"
|
|
12
|
+
mode="text"
|
|
13
|
+
/>
|
|
14
|
+
</div>
|
|
15
|
+
</div>
|
|
16
|
+
</template>
|
|
17
|
+
|
|
18
|
+
<script setup lang="ts">
|
|
19
|
+
import JsonEditor from 'vue3-ts-jsoneditor';
|
|
20
|
+
|
|
21
|
+
const props = defineProps<{ element: any; isLoaded: Boolean }>();
|
|
22
|
+
|
|
23
|
+
const orderKeys = (val: any) => {
|
|
24
|
+
return [
|
|
25
|
+
'id',
|
|
26
|
+
'uid',
|
|
27
|
+
'type',
|
|
28
|
+
'position',
|
|
29
|
+
'data',
|
|
30
|
+
'meta',
|
|
31
|
+
'refs',
|
|
32
|
+
'contentId',
|
|
33
|
+
'contentSignature',
|
|
34
|
+
'linked',
|
|
35
|
+
'detached',
|
|
36
|
+
'createdAt',
|
|
37
|
+
'updatedAt',
|
|
38
|
+
'deletedAt',
|
|
39
|
+
].reduce((acc: any, key: string) => {
|
|
40
|
+
acc[key] = val[key];
|
|
41
|
+
return acc;
|
|
42
|
+
}, {});
|
|
43
|
+
};
|
|
44
|
+
</script>
|
|
@@ -1,79 +1,37 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import { onMounted } from 'vue';
|
|
3
|
-
import JsonEditor from 'vue3-ts-jsoneditor';
|
|
2
|
+
import { onMounted, ref } from 'vue';
|
|
4
3
|
import Split from 'split.js';
|
|
5
4
|
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
// 'id',
|
|
11
|
-
// 'uid',
|
|
12
|
-
// 'type',
|
|
13
|
-
// 'position',
|
|
14
|
-
// 'data',
|
|
15
|
-
// 'meta',
|
|
16
|
-
// 'refs',
|
|
17
|
-
// 'contentId',
|
|
18
|
-
// 'contentSignature',
|
|
19
|
-
// 'linked',
|
|
20
|
-
// 'detached',
|
|
21
|
-
// 'createdAt',
|
|
22
|
-
// 'updatedAt',
|
|
23
|
-
// 'deletedAt',
|
|
24
|
-
// ];
|
|
5
|
+
import BottomPanel from './BottomPanel.vue';
|
|
6
|
+
import PreviewPanel from './PreviewPanel.vue';
|
|
7
|
+
import SplashLoader from './SplashLoader.vue';
|
|
8
|
+
import { useGlobalState } from '../state';
|
|
25
9
|
|
|
26
10
|
const props = defineProps<{ element: any }>();
|
|
27
|
-
|
|
11
|
+
|
|
12
|
+
const { isDark } = useGlobalState();
|
|
13
|
+
const isLoaded = ref(false);
|
|
28
14
|
|
|
29
15
|
onMounted(() => {
|
|
30
|
-
// Component preview split
|
|
31
|
-
splitJs.value = Split([`#${PANELS.EDIT}`, `#${PANELS.DISPLAY}`], {
|
|
32
|
-
minSize: [0, 0],
|
|
33
|
-
});
|
|
34
16
|
// Client/server vertical split
|
|
35
17
|
Split([`#panelTop`, `#panelBottom`], {
|
|
36
18
|
direction: 'vertical',
|
|
37
19
|
sizes: [70, 30],
|
|
38
20
|
});
|
|
21
|
+
setTimeout(() => (isLoaded.value = true), 5000);
|
|
39
22
|
});
|
|
40
23
|
</script>
|
|
41
24
|
|
|
42
25
|
<template>
|
|
43
26
|
<main :class="{ 'dark-theme': isDark }">
|
|
44
|
-
<
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
>
|
|
53
|
-
</iframe>
|
|
54
|
-
<iframe
|
|
55
|
-
:id="PANELS.DISPLAY"
|
|
56
|
-
frameBorder="0"
|
|
57
|
-
sandbox="allow-scripts"
|
|
58
|
-
src="http://localhost:8020"
|
|
59
|
-
title="Display component container"
|
|
60
|
-
>
|
|
61
|
-
</iframe>
|
|
62
|
-
</div>
|
|
63
|
-
</div>
|
|
64
|
-
<div id="panelBottom" class="panel">
|
|
65
|
-
<v-tabs density="compact" hide-slider>
|
|
66
|
-
<v-tab>Server state</v-tab>
|
|
67
|
-
</v-tabs>
|
|
68
|
-
<div class="pa-5">
|
|
69
|
-
<JsonEditor
|
|
70
|
-
:main-menu-bar="false"
|
|
71
|
-
:status-bar="false"
|
|
72
|
-
:value="props.element"
|
|
73
|
-
mode="text"
|
|
74
|
-
/>
|
|
75
|
-
</div>
|
|
76
|
-
</div>
|
|
27
|
+
<SplashLoader v-show="!isLoaded" />
|
|
28
|
+
<PreviewPanel id="panelTop" :is-loaded="isLoaded" />
|
|
29
|
+
<BottomPanel
|
|
30
|
+
id="panelBottom"
|
|
31
|
+
:element="props.element"
|
|
32
|
+
:is-loaded="isLoaded"
|
|
33
|
+
class="preview-panel"
|
|
34
|
+
/>
|
|
77
35
|
</main>
|
|
78
36
|
</template>
|
|
79
37
|
|
|
@@ -81,8 +39,9 @@ onMounted(() => {
|
|
|
81
39
|
main {
|
|
82
40
|
height: calc(100vh - var(--nav-height));
|
|
83
41
|
|
|
84
|
-
.panel {
|
|
42
|
+
.preview-panel {
|
|
85
43
|
background-color: #eceff1;
|
|
44
|
+
overflow-y: auto;
|
|
86
45
|
}
|
|
87
46
|
}
|
|
88
47
|
|
|
@@ -97,9 +56,9 @@ main {
|
|
|
97
56
|
}
|
|
98
57
|
|
|
99
58
|
.gutter.gutter-vertical {
|
|
100
|
-
cursor: row-resize
|
|
59
|
+
cursor: row-resize;
|
|
101
60
|
background-color: #fff;
|
|
102
|
-
background-image: url('data:image/png;base64,
|
|
61
|
+
background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB4AAAAFAQMAAABo7865AAAABlBMVEVHcEzMzMzyAv2sAAAAAXRSTlMAQObYZgAAABBJREFUeF5jOAMEEAIEEFwAn3kMwcB6I2AAAAAASUVORK5CYII=');
|
|
103
62
|
}
|
|
104
63
|
|
|
105
64
|
.dark-theme {
|
|
@@ -107,10 +66,5 @@ main {
|
|
|
107
66
|
.gutter.gutter-vertical {
|
|
108
67
|
background-color: #333;
|
|
109
68
|
}
|
|
110
|
-
|
|
111
|
-
.jse-theme-dark .cm-content,
|
|
112
|
-
.jse-theme-dark .cm-gutters {
|
|
113
|
-
background-color: #29292f !important;
|
|
114
|
-
}
|
|
115
69
|
}
|
|
116
70
|
</style>
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div v-show="isLoaded" class="d-flex flex-grow-1 preview-panel">
|
|
3
|
+
<iframe
|
|
4
|
+
:id="PANELS.EDIT"
|
|
5
|
+
ref="editPanel"
|
|
6
|
+
frameBorder="0"
|
|
7
|
+
sandbox="allow-scripts"
|
|
8
|
+
src="http://localhost:8010"
|
|
9
|
+
title="Edit component container"
|
|
10
|
+
>
|
|
11
|
+
</iframe>
|
|
12
|
+
<iframe
|
|
13
|
+
:id="PANELS.DISPLAY"
|
|
14
|
+
ref="displayPanel"
|
|
15
|
+
frameBorder="0"
|
|
16
|
+
sandbox="allow-scripts"
|
|
17
|
+
src="http://localhost:8020"
|
|
18
|
+
title="Display component container"
|
|
19
|
+
>
|
|
20
|
+
</iframe>
|
|
21
|
+
</div>
|
|
22
|
+
</template>
|
|
23
|
+
|
|
24
|
+
<script setup lang="ts">
|
|
25
|
+
import { onMounted, ref, watch } from 'vue';
|
|
26
|
+
import Split from 'split.js';
|
|
27
|
+
|
|
28
|
+
import { PANELS, useGlobalState } from '../state';
|
|
29
|
+
|
|
30
|
+
const props = defineProps<{ isLoaded: Boolean }>();
|
|
31
|
+
|
|
32
|
+
const editPanel = ref(null);
|
|
33
|
+
const displayPanel = ref(null);
|
|
34
|
+
const { previewPanelSplit } = useGlobalState();
|
|
35
|
+
|
|
36
|
+
onMounted(() => {
|
|
37
|
+
previewPanelSplit.value = Split([`#${PANELS.EDIT}`, `#${PANELS.DISPLAY}`], {
|
|
38
|
+
minSize: [0, 0],
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
watch(props.isLoaded, (isLoaded) => {
|
|
43
|
+
if (!isLoaded) return;
|
|
44
|
+
reloadPreview();
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
const reloadPreview = () => {
|
|
48
|
+
/* eslint-disable */
|
|
49
|
+
// @ts-ignore
|
|
50
|
+
editPanel.value.src = editPanel.value.src;
|
|
51
|
+
// @ts-ignore
|
|
52
|
+
displayPanel.value.src = displayPanel.value.src;
|
|
53
|
+
/* eslint-enable */
|
|
54
|
+
};
|
|
55
|
+
</script>
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<transition name="fade">
|
|
3
|
+
<div :style="{ backgroundColor }" class="splash-loader">
|
|
4
|
+
<div>
|
|
5
|
+
<div class="splash-loader__anim">
|
|
6
|
+
<img :src="logo" alt="Logo" width="88" />
|
|
7
|
+
</div>
|
|
8
|
+
<div class="splash-loader__text text-body-1">
|
|
9
|
+
<div>Booting Teaching Element Kit....</div>
|
|
10
|
+
<div class="font-weight-bold">Alpha preview v0.0.1</div>
|
|
11
|
+
</div>
|
|
12
|
+
</div>
|
|
13
|
+
</div>
|
|
14
|
+
</transition>
|
|
15
|
+
</template>
|
|
16
|
+
|
|
17
|
+
<script lang="ts">
|
|
18
|
+
import logoUrl from '../assets/logo.png';
|
|
19
|
+
|
|
20
|
+
export default {
|
|
21
|
+
props: {
|
|
22
|
+
logo: {
|
|
23
|
+
type: String,
|
|
24
|
+
default: logoUrl,
|
|
25
|
+
},
|
|
26
|
+
color: {
|
|
27
|
+
type: String,
|
|
28
|
+
default: '#00bfa5',
|
|
29
|
+
},
|
|
30
|
+
backgroundColor: {
|
|
31
|
+
type: String,
|
|
32
|
+
default: '#fff',
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
created() {
|
|
36
|
+
this.setColor();
|
|
37
|
+
},
|
|
38
|
+
methods: {
|
|
39
|
+
setColor() {
|
|
40
|
+
document.documentElement.style.setProperty('--splash-color', this.color);
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
</script>
|
|
45
|
+
|
|
46
|
+
<style lang="scss" scoped>
|
|
47
|
+
$splash-color: var(--splash-color);
|
|
48
|
+
|
|
49
|
+
.splash-loader {
|
|
50
|
+
flex: 1;
|
|
51
|
+
width: 100%;
|
|
52
|
+
height: 100%;
|
|
53
|
+
display: flex;
|
|
54
|
+
align-items: center;
|
|
55
|
+
justify-content: center;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.splash-loader__anim {
|
|
59
|
+
text-align: center;
|
|
60
|
+
animation: splashAnimation 1.3s infinite;
|
|
61
|
+
|
|
62
|
+
img {
|
|
63
|
+
margin: auto;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.splash-loader__text {
|
|
68
|
+
margin-top: 50px;
|
|
69
|
+
font-size: 1rem;
|
|
70
|
+
text-align: center;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
@keyframes splashAnimation {
|
|
74
|
+
0% {
|
|
75
|
+
filter: drop-shadow(0px 0px 0px $splash-color);
|
|
76
|
+
}
|
|
77
|
+
100% {
|
|
78
|
+
filter: drop-shadow(0px 0px 200px $splash-color);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.fade-enter-active,
|
|
83
|
+
.fade-leave-active {
|
|
84
|
+
transition: opacity 0.3s;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.fade-enter,
|
|
88
|
+
.fade-leave-to {
|
|
89
|
+
opacity: 0;
|
|
90
|
+
}
|
|
91
|
+
</style>
|
package/src/state/preview.ts
CHANGED
|
@@ -14,25 +14,25 @@ export const useGlobalState = createGlobalState(() => {
|
|
|
14
14
|
|
|
15
15
|
// Control panels
|
|
16
16
|
const visiblePanels = ref(['EDIT', 'DISPLAY', 'STATE']);
|
|
17
|
-
const
|
|
17
|
+
const previewPanelSplit = ref();
|
|
18
18
|
const showEdit = () => {
|
|
19
19
|
visiblePanels.value = [PANELS.EDIT];
|
|
20
|
-
if (
|
|
20
|
+
if (previewPanelSplit.value) previewPanelSplit.value?.setSizes([100, 0]);
|
|
21
21
|
};
|
|
22
22
|
const showDisplay = () => {
|
|
23
23
|
visiblePanels.value = [PANELS.DISPLAY];
|
|
24
|
-
if (
|
|
24
|
+
if (previewPanelSplit.value) previewPanelSplit.value?.setSizes([0, 100]);
|
|
25
25
|
};
|
|
26
26
|
const showBothComponents = () => {
|
|
27
27
|
visiblePanels.value = [PANELS.EDIT, PANELS.DISPLAY];
|
|
28
|
-
if (
|
|
28
|
+
if (previewPanelSplit.value) previewPanelSplit.value?.setSizes([50, 50]);
|
|
29
29
|
};
|
|
30
30
|
|
|
31
31
|
return {
|
|
32
32
|
isDark,
|
|
33
33
|
toggleDark,
|
|
34
34
|
visiblePanels,
|
|
35
|
-
|
|
35
|
+
previewPanelSplit,
|
|
36
36
|
showEdit,
|
|
37
37
|
showDisplay,
|
|
38
38
|
showBothComponents,
|