@mixd-id/web-scaffold 0.1.230406104 → 0.1.230406107
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 +2 -1
- package/src/components/Article.vue +85 -3
- package/src/components/ListView.vue +1 -1
- package/src/components/Modal.vue +6 -5
- package/src/components/Modal2.vue +6 -2
- package/src/components/Slider.vue +2 -2
- package/src/widgets/ArticleSetting.vue +192 -0
- package/src/widgets/ComponentSetting.vue +0 -13
- package/src/widgets/WebPageBuilder.vue +28 -7
- package/src/widgets/WebPageSelector.vue +3 -1
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mixd-id/web-scaffold",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.230406107",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"dev": "vite serve",
|
|
7
7
|
"build": "vite build",
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
"exports": {
|
|
12
12
|
".": "./src/index.js",
|
|
13
13
|
"./themes/default": "./src/themes/default/index.js",
|
|
14
|
+
"./components/Modal.vue": "./src/components/Modal.vue",
|
|
14
15
|
"./components/Modal2.vue": "./src/components/Modal2.vue",
|
|
15
16
|
"./components/Textbox.vue": "./src/components/Textbox.vue",
|
|
16
17
|
"./mixin/component": "./src/mixin/component.js",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
<script>
|
|
11
11
|
|
|
12
12
|
import { componentMixin } from '../mixin/component';
|
|
13
|
-
import {
|
|
13
|
+
import {getSelection, restoreSelection, saveSelection} from "../utils/selection";
|
|
14
14
|
|
|
15
15
|
export default{
|
|
16
16
|
|
|
@@ -24,6 +24,27 @@ export default{
|
|
|
24
24
|
|
|
25
25
|
methods: {
|
|
26
26
|
|
|
27
|
+
getSelection(){
|
|
28
|
+
const { text = '', href = '', target = '' } = saveSelection(this.$el)
|
|
29
|
+
return {
|
|
30
|
+
text,
|
|
31
|
+
href,
|
|
32
|
+
target
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
|
|
36
|
+
addLink(link){
|
|
37
|
+
|
|
38
|
+
restoreSelection()
|
|
39
|
+
|
|
40
|
+
document.execCommand("insertHTML", false,
|
|
41
|
+
"<a style='font-size:inherit;font-family:inherit;background-color:inherit' " +
|
|
42
|
+
"href=\"" + link.href + "\" " +
|
|
43
|
+
"target=\"" + link.target + "\">" +
|
|
44
|
+
link.text +
|
|
45
|
+
"</a>");
|
|
46
|
+
},
|
|
47
|
+
|
|
27
48
|
onInput(){
|
|
28
49
|
if(this.editable){
|
|
29
50
|
this.triggerUpdate()
|
|
@@ -198,13 +219,72 @@ export default{
|
|
|
198
219
|
|
|
199
220
|
mounted() {
|
|
200
221
|
if('edit-mode' in this.$route.query){
|
|
201
|
-
window.addEventListener('message', (
|
|
222
|
+
window.addEventListener('message', (e) => {
|
|
223
|
+
|
|
224
|
+
const { data, source } = e
|
|
225
|
+
|
|
202
226
|
if(data.uid === this.uid){
|
|
203
227
|
|
|
204
|
-
const { action, type, value } = data.data
|
|
228
|
+
const { action, type, value } = data.data ?? {}
|
|
229
|
+
|
|
230
|
+
let result
|
|
205
231
|
|
|
206
232
|
switch(action){
|
|
207
233
|
|
|
234
|
+
case 'saveSelection':
|
|
235
|
+
case 'getSelection':
|
|
236
|
+
const sel = saveSelection(this.$el)
|
|
237
|
+
const { text, target, href } = sel
|
|
238
|
+
result = {
|
|
239
|
+
text,
|
|
240
|
+
target,
|
|
241
|
+
href
|
|
242
|
+
}
|
|
243
|
+
break
|
|
244
|
+
|
|
245
|
+
case 'restoreSelection':
|
|
246
|
+
restoreSelection()
|
|
247
|
+
break
|
|
248
|
+
|
|
249
|
+
case 'insertLink':
|
|
250
|
+
restoreSelection()
|
|
251
|
+
|
|
252
|
+
document.execCommand("insertHTML", false,
|
|
253
|
+
"<a style='font-size:inherit;font-family:inherit;background-color:inherit' " +
|
|
254
|
+
"href=\"" + value.href + "\" " +
|
|
255
|
+
"target=\"" + value.target + "\">" +
|
|
256
|
+
value.text +
|
|
257
|
+
"</a>");
|
|
258
|
+
break
|
|
259
|
+
|
|
260
|
+
case 'removeLink':
|
|
261
|
+
const { element } = getSelection(this.$el)
|
|
262
|
+
|
|
263
|
+
let a = element
|
|
264
|
+
while(a && a.tagName !== 'A'){
|
|
265
|
+
a = a.parentNode
|
|
266
|
+
}
|
|
267
|
+
if(a){
|
|
268
|
+
a.parentNode.replaceChild(element, a)
|
|
269
|
+
}
|
|
270
|
+
break
|
|
271
|
+
|
|
272
|
+
case 'insertImage':
|
|
273
|
+
const props = {}
|
|
274
|
+
if(value.width)
|
|
275
|
+
props.width = parseInt(value.width) + 'px'
|
|
276
|
+
if(value.height)
|
|
277
|
+
props.height = parseInt(value.height) + 'px'
|
|
278
|
+
|
|
279
|
+
let propHtml = []
|
|
280
|
+
for(let key in props){
|
|
281
|
+
propHtml.push(`${key}='${props[key]}'`)
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
document.execCommand("insertHTML", false,
|
|
285
|
+
"<img src=\"" + value.url + "\" " + propHtml.join(' ') + "/>");
|
|
286
|
+
break
|
|
287
|
+
|
|
208
288
|
case 'insertTable':
|
|
209
289
|
this.insertTable()
|
|
210
290
|
break
|
|
@@ -241,7 +321,9 @@ export default{
|
|
|
241
321
|
|
|
242
322
|
}
|
|
243
323
|
|
|
324
|
+
source.postMessage(result, '*')
|
|
244
325
|
}
|
|
326
|
+
|
|
245
327
|
})
|
|
246
328
|
this.editable = true
|
|
247
329
|
}
|
|
@@ -359,7 +359,7 @@ export default{
|
|
|
359
359
|
|
|
360
360
|
case 'create':
|
|
361
361
|
case 'update':
|
|
362
|
-
if(Object.keys(items[0]).length <= 1 && Object.keys(items[0])[0] === 'uid'){
|
|
362
|
+
if(items[0] && Object.keys(items[0]).length <= 1 && Object.keys(items[0])[0] === 'uid'){
|
|
363
363
|
this.socketEmit2(this.src, {
|
|
364
364
|
columns:this.config.columns,
|
|
365
365
|
preset:{
|
package/src/components/Modal.vue
CHANGED
|
@@ -42,6 +42,7 @@
|
|
|
42
42
|
let modals = []
|
|
43
43
|
|
|
44
44
|
const registerModal = (modal) => {
|
|
45
|
+
if(modals.includes(modal)) return
|
|
45
46
|
|
|
46
47
|
modals.forEach((_) => {
|
|
47
48
|
_.isDisabled = 1
|
|
@@ -51,7 +52,6 @@ const registerModal = (modal) => {
|
|
|
51
52
|
}
|
|
52
53
|
|
|
53
54
|
const unRegisterModal = (modal) => {
|
|
54
|
-
|
|
55
55
|
modals = modals.filter((_) => _ !== modal)
|
|
56
56
|
|
|
57
57
|
if(modals.length > 0)
|
|
@@ -134,9 +134,11 @@ export default{
|
|
|
134
134
|
document.querySelector('.bW9k').addEventListener('click', this.onDismiss)
|
|
135
135
|
window.addEventListener('keydown', this.onKeyDown)
|
|
136
136
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
137
|
+
this.$nextTick(() => {
|
|
138
|
+
if(this.computedState){
|
|
139
|
+
this.setState(this.computedState)
|
|
140
|
+
}
|
|
141
|
+
})
|
|
140
142
|
},
|
|
141
143
|
|
|
142
144
|
methods: {
|
|
@@ -220,7 +222,6 @@ export default{
|
|
|
220
222
|
@apply bg-base-400;
|
|
221
223
|
@apply border-[1px] border-text-50 z-20 flex max-h-[90vh];
|
|
222
224
|
@apply rounded-xl overflow-hidden;
|
|
223
|
-
transition: all 300ms cubic-bezier(0.25, 1, 0.5, 1);
|
|
224
225
|
}
|
|
225
226
|
|
|
226
227
|
.modal form{
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
<div>
|
|
3
3
|
<Teleport to=".bW9k">
|
|
4
4
|
<div :class="computedClass" ref="modal" :style="computedStyle"
|
|
5
|
-
:data-state="computedState ? 1 : 0">
|
|
5
|
+
:data-state="!!computedState ? 1 : 0">
|
|
6
6
|
<form v-if="useForm" @submit.prevent="$emit('submit')">
|
|
7
7
|
<div class="modal-head">
|
|
8
8
|
<slot name="head" :context="context"></slot>
|
|
@@ -37,6 +37,7 @@
|
|
|
37
37
|
let modals = []
|
|
38
38
|
|
|
39
39
|
const registerModal = (modal) => {
|
|
40
|
+
if(modals.includes(modal)) return
|
|
40
41
|
|
|
41
42
|
modals.forEach((_) => {
|
|
42
43
|
_.isDisabled = 1
|
|
@@ -66,7 +67,10 @@ export default{
|
|
|
66
67
|
type: String,
|
|
67
68
|
default: 'bottom'
|
|
68
69
|
},
|
|
69
|
-
state:
|
|
70
|
+
state: {
|
|
71
|
+
type: [ Number, Boolean, String ],
|
|
72
|
+
default: true
|
|
73
|
+
},
|
|
70
74
|
transition: { type: String, default: 'slideup' },
|
|
71
75
|
width: String,
|
|
72
76
|
useForm: {
|
|
@@ -259,7 +259,7 @@ export default{
|
|
|
259
259
|
}
|
|
260
260
|
|
|
261
261
|
.slider>div:nth-child(1){
|
|
262
|
-
@apply absolute bg-
|
|
262
|
+
@apply absolute bg-text-50 rounded-lg;
|
|
263
263
|
height: .5rem;
|
|
264
264
|
top: 50%;
|
|
265
265
|
left: .75rem;
|
|
@@ -282,4 +282,4 @@ export default{
|
|
|
282
282
|
touch-action: none;
|
|
283
283
|
}
|
|
284
284
|
|
|
285
|
-
</style>
|
|
285
|
+
</style>
|
|
@@ -22,6 +22,12 @@
|
|
|
22
22
|
<button class="p-3" type="button" ref="listBtn" @click="$refs.listContext.open($refs.listBtn)">
|
|
23
23
|
<svg width="14" height="14" class="fill-text-400 hover:fill-primary" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path d="M64 144c26.5 0 48-21.5 48-48s-21.5-48-48-48S16 69.5 16 96s21.5 48 48 48zM192 64c-17.7 0-32 14.3-32 32s14.3 32 32 32H480c17.7 0 32-14.3 32-32s-14.3-32-32-32H192zm0 160c-17.7 0-32 14.3-32 32s14.3 32 32 32H480c17.7 0 32-14.3 32-32s-14.3-32-32-32H192zm0 160c-17.7 0-32 14.3-32 32s14.3 32 32 32H480c17.7 0 32-14.3 32-32s-14.3-32-32-32H192zM64 464c26.5 0 48-21.5 48-48s-21.5-48-48-48s-48 21.5-48 48s21.5 48 48 48zm48-208c0-26.5-21.5-48-48-48s-48 21.5-48 48s21.5 48 48 48s48-21.5 48-48z"/></svg>
|
|
24
24
|
</button>
|
|
25
|
+
<button class="p-3" type="button" @click="createImage">
|
|
26
|
+
<svg width="14" height="14" class="fill-text-400 hover:fill-primary" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path d="M152 120c-26.51 0-48 21.49-48 48s21.49 48 48 48s48-21.49 48-48S178.5 120 152 120zM447.1 32h-384C28.65 32-.0091 60.65-.0091 96v320c0 35.35 28.65 64 63.1 64h384c35.35 0 64-28.65 64-64V96C511.1 60.65 483.3 32 447.1 32zM463.1 409.3l-136.8-185.9C323.8 218.8 318.1 216 312 216c-6.113 0-11.82 2.768-15.21 7.379l-106.6 144.1l-37.09-46.1c-3.441-4.279-8.934-6.809-14.77-6.809c-5.842 0-11.33 2.529-14.78 6.809l-75.52 93.81c0-.0293 0 .0293 0 0L47.99 96c0-8.822 7.178-16 16-16h384c8.822 0 16 7.178 16 16V409.3z"/></svg>
|
|
27
|
+
</button>
|
|
28
|
+
<button class="p-3" type="button" @click="insertLink">
|
|
29
|
+
<svg width="14" height="14" class="fill-text-400 hover:fill-primary" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path d="M314.222 197.78c51.091 51.091 54.377 132.287 9.75 187.16-6.242 7.73-2.784 3.865-84.94 86.02-54.696 54.696-143.266 54.745-197.99 0-54.711-54.69-54.734-143.255 0-197.99 32.773-32.773 51.835-51.899 63.409-63.457 7.463-7.452 20.331-2.354 20.486 8.192a173.31 173.31 0 0 0 4.746 37.828c.966 4.029-.272 8.269-3.202 11.198L80.632 312.57c-32.755 32.775-32.887 85.892 0 118.8 32.775 32.755 85.892 32.887 118.8 0l75.19-75.2c32.718-32.725 32.777-86.013 0-118.79a83.722 83.722 0 0 0-22.814-16.229c-4.623-2.233-7.182-7.25-6.561-12.346 1.356-11.122 6.296-21.885 14.815-30.405l4.375-4.375c3.625-3.626 9.177-4.594 13.76-2.294 12.999 6.524 25.187 15.211 36.025 26.049zM470.958 41.04c-54.724-54.745-143.294-54.696-197.99 0-82.156 82.156-78.698 78.29-84.94 86.02-44.627 54.873-41.341 136.069 9.75 187.16 10.838 10.838 23.026 19.525 36.025 26.049 4.582 2.3 10.134 1.331 13.76-2.294l4.375-4.375c8.52-8.519 13.459-19.283 14.815-30.405.621-5.096-1.938-10.113-6.561-12.346a83.706 83.706 0 0 1-22.814-16.229c-32.777-32.777-32.718-86.065 0-118.79l75.19-75.2c32.908-32.887 86.025-32.755 118.8 0 32.887 32.908 32.755 86.025 0 118.8l-45.848 45.84c-2.93 2.929-4.168 7.169-3.202 11.198a173.31 173.31 0 0 1 4.746 37.828c.155 10.546 13.023 15.644 20.486 8.192 11.574-11.558 30.636-30.684 63.409-63.457 54.733-54.735 54.71-143.3-.001-197.991z"/></svg>
|
|
30
|
+
</button>
|
|
25
31
|
<button class="p-3" type="button" @click="insertTable">
|
|
26
32
|
<svg width="14" height="14" class="fill-text-400 hover:fill-primary" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path d="M464 32H48C21.49 32 0 53.49 0 80v352c0 26.51 21.49 48 48 48h416c26.51 0 48-21.49 48-48V80c0-26.51-21.49-48-48-48zM224 416H64v-96h160v96zm0-160H64v-96h160v96zm224 160H288v-96h160v96zm0-160H288v-96h160v96z"/></svg>
|
|
27
33
|
</button>
|
|
@@ -216,6 +222,94 @@
|
|
|
216
222
|
</div>
|
|
217
223
|
</ContextMenu>
|
|
218
224
|
|
|
225
|
+
<Modal ref="linkModal" width="360" height="400" dismissable="true">
|
|
226
|
+
<template v-slot:head>
|
|
227
|
+
<div class="relative p-5">
|
|
228
|
+
<h3>Add Link</h3>
|
|
229
|
+
<div class="absolute top-0 right-0 p-2">
|
|
230
|
+
<button type="button" class="p-2" @click="$refs.linkModal.close()">
|
|
231
|
+
<svg width="24" height="24" viewBox="0 0 24 24" class="fill-text-300 hover:fill-red-500" xmlns="http://www.w3.org/2000/svg">
|
|
232
|
+
<path d="M6.53034 5.46965C6.23745 5.17676 5.76257 5.17676 5.46968 5.46965C5.17679 5.76255 5.17679 6.23742 5.46968 6.53031L10.9393 12L5.46967 17.4697C5.17678 17.7626 5.17678 18.2374 5.46967 18.5303C5.76256 18.8232 6.23744 18.8232 6.53033 18.5303L12 13.0606L17.4697 18.5303C17.7626 18.8232 18.2375 18.8232 18.5303 18.5303C18.8232 18.2374 18.8232 17.7626 18.5303 17.4697L13.0607 12L18.5303 6.53032C18.8232 6.23743 18.8232 5.76256 18.5303 5.46966C18.2374 5.17677 17.7626 5.17677 17.4697 5.46966L12 10.9393L6.53034 5.46965Z"/>
|
|
233
|
+
</svg>
|
|
234
|
+
</button>
|
|
235
|
+
</div>
|
|
236
|
+
</div>
|
|
237
|
+
</template>
|
|
238
|
+
<template v-slot:foot="{ context }">
|
|
239
|
+
<div class="p-5 flex flex-row gap-3">
|
|
240
|
+
<Button variant="secondary" class="w-[100px]" @click="removeLink">Remove</Button>
|
|
241
|
+
<Button class="flex-1" @click="addLink(context)">Add Link</Button>
|
|
242
|
+
</div>
|
|
243
|
+
</template>
|
|
244
|
+
<template #default="{ context }">
|
|
245
|
+
<div class="flex-1 flex flex-col gap-5 p-5">
|
|
246
|
+
<div>
|
|
247
|
+
<label>Text</label>
|
|
248
|
+
<Textbox class="w-full mt-1" v-model="context.text" />
|
|
249
|
+
</div>
|
|
250
|
+
<div>
|
|
251
|
+
<label>Href</label>
|
|
252
|
+
<Textbox class="w-full mt-1" v-model="context.href" />
|
|
253
|
+
</div>
|
|
254
|
+
<div>
|
|
255
|
+
<label>Target</label>
|
|
256
|
+
<Dropdown class="w-[150px] mt-1" v-model="context.target">
|
|
257
|
+
<option value="">_self</option>
|
|
258
|
+
<option value="_blank">_blank</option>
|
|
259
|
+
<option value="_parent">_parent</option>
|
|
260
|
+
<option value="_top">_top</option>
|
|
261
|
+
</Dropdown>
|
|
262
|
+
</div>
|
|
263
|
+
</div>
|
|
264
|
+
</template>
|
|
265
|
+
</Modal>
|
|
266
|
+
|
|
267
|
+
<Modal ref="imageModal" width="360" height="420" dismissable="true">
|
|
268
|
+
<template v-slot:head>
|
|
269
|
+
<div class="relative p-5">
|
|
270
|
+
<h3>Add Image</h3>
|
|
271
|
+
<div class="absolute top-0 right-0 p-2">
|
|
272
|
+
<button type="button" class="p-2" @click="$refs.imageModal.close()">
|
|
273
|
+
<svg width="24" height="24" viewBox="0 0 24 24" class="fill-text-300 hover:fill-red-500" xmlns="http://www.w3.org/2000/svg">
|
|
274
|
+
<path d="M6.53034 5.46965C6.23745 5.17676 5.76257 5.17676 5.46968 5.46965C5.17679 5.76255 5.17679 6.23742 5.46968 6.53031L10.9393 12L5.46967 17.4697C5.17678 17.7626 5.17678 18.2374 5.46967 18.5303C5.76256 18.8232 6.23744 18.8232 6.53033 18.5303L12 13.0606L17.4697 18.5303C17.7626 18.8232 18.2375 18.8232 18.5303 18.5303C18.8232 18.2374 18.8232 17.7626 18.5303 17.4697L13.0607 12L18.5303 6.53032C18.8232 6.23743 18.8232 5.76256 18.5303 5.46966C18.2374 5.17677 17.7626 5.17677 17.4697 5.46966L12 10.9393L6.53034 5.46965Z"/>
|
|
275
|
+
</svg>
|
|
276
|
+
</button>
|
|
277
|
+
</div>
|
|
278
|
+
</div>
|
|
279
|
+
</template>
|
|
280
|
+
<template #foot="{ context }">
|
|
281
|
+
<div class="p-5">
|
|
282
|
+
<Button class="w-full" @click="addImage(context)" :state="!context.src ? -1 : 1">Add Image</Button>
|
|
283
|
+
</div>
|
|
284
|
+
</template>
|
|
285
|
+
<template #default="{ context }">
|
|
286
|
+
<div class="flex-1 flex flex-col gap-5 p-5">
|
|
287
|
+
<div>
|
|
288
|
+
<Image class="min-h-[100px] bg-base-300 rounded-xl" ref="image" :src="context.src" editable="true"
|
|
289
|
+
@click="$refs.image.edit()" @change="(_, file) => context.src = file">
|
|
290
|
+
<template #empty="{ instance }">
|
|
291
|
+
<div class="absolute right-0 top-0 bottom-0 left-0 flex items-center justify-center">
|
|
292
|
+
Click to Add Image...
|
|
293
|
+
</div>
|
|
294
|
+
</template>
|
|
295
|
+
</Image>
|
|
296
|
+
</div>
|
|
297
|
+
<div class="grid grid-cols-2 gap-5">
|
|
298
|
+
<div>
|
|
299
|
+
<label>Width</label>
|
|
300
|
+
<Textbox class="mt-1" v-model="context.width" maxlength="3" />
|
|
301
|
+
</div>
|
|
302
|
+
<div>
|
|
303
|
+
<label>Height</label>
|
|
304
|
+
<Textbox class="mt-1" v-model="context.height" maxlength="3" />
|
|
305
|
+
</div>
|
|
306
|
+
</div>
|
|
307
|
+
<br />
|
|
308
|
+
<br />
|
|
309
|
+
</div>
|
|
310
|
+
</template>
|
|
311
|
+
</Modal>
|
|
312
|
+
|
|
219
313
|
<ComponentSetting :item="item"
|
|
220
314
|
:view-type="viewType"
|
|
221
315
|
:view-types="viewTypes"
|
|
@@ -227,10 +321,16 @@
|
|
|
227
321
|
|
|
228
322
|
<script>
|
|
229
323
|
|
|
324
|
+
import {restoreSelection} from "../utils/selection";
|
|
325
|
+
import {downsizeImage} from "../utils/helpers.mjs";
|
|
326
|
+
import axios from "axios";
|
|
327
|
+
|
|
230
328
|
export default{
|
|
231
329
|
|
|
232
330
|
emits: [ 'change', 'postMessageToIframe' ],
|
|
233
331
|
|
|
332
|
+
inject: [ 'alert', 'postIframe' ],
|
|
333
|
+
|
|
234
334
|
props: {
|
|
235
335
|
|
|
236
336
|
item: {
|
|
@@ -246,6 +346,64 @@ export default{
|
|
|
246
346
|
|
|
247
347
|
methods: {
|
|
248
348
|
|
|
349
|
+
createImage(){
|
|
350
|
+
this.postIframe({ uid:this.item.uid, data: { action: 'saveSelection' } })
|
|
351
|
+
.then(_ => {
|
|
352
|
+
this.$refs.imageModal.open()
|
|
353
|
+
})
|
|
354
|
+
},
|
|
355
|
+
|
|
356
|
+
async addImage(image){
|
|
357
|
+
|
|
358
|
+
this.postIframe({ uid:this.item.uid, data: { action: 'restoreSelection' }})
|
|
359
|
+
.then(_ => {
|
|
360
|
+
|
|
361
|
+
downsizeImage(image.src, image.width ?? 300)
|
|
362
|
+
.then(async (blob) => {
|
|
363
|
+
|
|
364
|
+
const data = new FormData()
|
|
365
|
+
data.append('image', blob)
|
|
366
|
+
|
|
367
|
+
try{
|
|
368
|
+
const res = await axios.post(import.meta.env.VITE_API_HOST + '/import/image',
|
|
369
|
+
data,
|
|
370
|
+
{
|
|
371
|
+
headers: {
|
|
372
|
+
"Content-Type": "multipart/form-data",
|
|
373
|
+
},
|
|
374
|
+
}
|
|
375
|
+
)
|
|
376
|
+
image.url = res.data.url
|
|
377
|
+
|
|
378
|
+
const value = JSON.parse(JSON.stringify(image))
|
|
379
|
+
await this.postIframe({ uid:this.item.uid, data:{ action: 'insertImage', value }})
|
|
380
|
+
}
|
|
381
|
+
catch(e){
|
|
382
|
+
this.alert(e)
|
|
383
|
+
}
|
|
384
|
+
})
|
|
385
|
+
.finally(_ => {
|
|
386
|
+
this.$refs.imageModal.close()
|
|
387
|
+
})
|
|
388
|
+
|
|
389
|
+
|
|
390
|
+
/*const props = {}
|
|
391
|
+
if(this.newImage.width)
|
|
392
|
+
props.width = this.newImage.width
|
|
393
|
+
if(this.newImage.height)
|
|
394
|
+
props.height = this.newImage.height
|
|
395
|
+
|
|
396
|
+
let propHtml = []
|
|
397
|
+
for(let key in props){
|
|
398
|
+
propHtml.push(`${key}='${props[key]}'`)
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
document.execCommand("insertHTML", false,
|
|
402
|
+
"<img src=\"" + this.newImage.base64 + "\" " + propHtml.join(' ') + "/>");*/
|
|
403
|
+
|
|
404
|
+
})
|
|
405
|
+
},
|
|
406
|
+
|
|
249
407
|
format(type, value){
|
|
250
408
|
|
|
251
409
|
switch(type){
|
|
@@ -259,6 +417,40 @@ export default{
|
|
|
259
417
|
}
|
|
260
418
|
},
|
|
261
419
|
|
|
420
|
+
insertLink(){
|
|
421
|
+
this.postIframe({
|
|
422
|
+
uid:this.item.uid,
|
|
423
|
+
data: {
|
|
424
|
+
action: 'getSelection'
|
|
425
|
+
}
|
|
426
|
+
})
|
|
427
|
+
.then(res => {
|
|
428
|
+
this.$refs.linkModal.open(res)
|
|
429
|
+
})
|
|
430
|
+
},
|
|
431
|
+
|
|
432
|
+
addLink(link){
|
|
433
|
+
link = JSON.parse(JSON.stringify(link))
|
|
434
|
+
this.postIframe({
|
|
435
|
+
uid:this.item.uid,
|
|
436
|
+
data: {
|
|
437
|
+
action: 'insertLink',
|
|
438
|
+
value: link
|
|
439
|
+
}
|
|
440
|
+
})
|
|
441
|
+
this.$refs.linkModal.close()
|
|
442
|
+
},
|
|
443
|
+
|
|
444
|
+
removeLink(){
|
|
445
|
+
this.postIframe({
|
|
446
|
+
uid:this.item.uid,
|
|
447
|
+
data: {
|
|
448
|
+
action: 'removeLink'
|
|
449
|
+
}
|
|
450
|
+
})
|
|
451
|
+
this.$refs.linkModal.close()
|
|
452
|
+
},
|
|
453
|
+
|
|
262
454
|
insertTable(){
|
|
263
455
|
this.$emit('postMessageToIframe', this.item.uid, { action:'insertTable' })
|
|
264
456
|
},
|
|
@@ -444,19 +444,6 @@
|
|
|
444
444
|
|
|
445
445
|
</div>
|
|
446
446
|
|
|
447
|
-
<div class="h-[1px] bg-text-50"></div>
|
|
448
|
-
|
|
449
|
-
<div class="flex flex-row items-center gap-4">
|
|
450
|
-
<label class="flex-1 text-text-400">ID</label>
|
|
451
|
-
<Textbox v-model="item.props.id" :maxlength="10" @keyup.enter="apply" class="w-[120px]"/>
|
|
452
|
-
</div>
|
|
453
|
-
|
|
454
|
-
<div v-if="item.uid" class="h-[1px] bg-text-50"></div>
|
|
455
|
-
|
|
456
|
-
<div v-if="item.uid" class="py-6 text-center">
|
|
457
|
-
<small class="text-text-400">uid: {{ item.uid }}</small>
|
|
458
|
-
</div>
|
|
459
|
-
|
|
460
447
|
<br />
|
|
461
448
|
<br />
|
|
462
449
|
|
|
@@ -242,6 +242,7 @@
|
|
|
242
242
|
<option value="75%">75%</option>
|
|
243
243
|
<option value="50%">50%</option>
|
|
244
244
|
</Dropdown>
|
|
245
|
+
|
|
245
246
|
<Textbox :readonly="1" :value="iframeSrc" class="w-full">
|
|
246
247
|
<template #start>
|
|
247
248
|
<button @click="reloadIframe" class="p-3">
|
|
@@ -511,6 +512,7 @@ export default{
|
|
|
511
512
|
|
|
512
513
|
this.page = page
|
|
513
514
|
this.layouts = layouts
|
|
515
|
+
this.iframeSrc = import.meta.env.VITE_WEB_HOST + '/' + (this.page.path ?? '')
|
|
514
516
|
this.$nextTick(() => this.resize())
|
|
515
517
|
})
|
|
516
518
|
.catch((err) => {
|
|
@@ -532,6 +534,19 @@ export default{
|
|
|
532
534
|
}
|
|
533
535
|
},
|
|
534
536
|
|
|
537
|
+
postIframe(data){
|
|
538
|
+
return new Promise((resolve, reject) => {
|
|
539
|
+
const handleResponse = (e) => {
|
|
540
|
+
window.removeEventListener('message', handleResponse)
|
|
541
|
+
resolve(e.data)
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
window.addEventListener('message', handleResponse)
|
|
545
|
+
|
|
546
|
+
this.$refs.iframe.contentWindow.postMessage(data, '*')
|
|
547
|
+
})
|
|
548
|
+
},
|
|
549
|
+
|
|
535
550
|
resize(){
|
|
536
551
|
|
|
537
552
|
const transformOrigin = this.store.viewType === '' ? 'center top' : '0 0'
|
|
@@ -640,11 +655,13 @@ export default{
|
|
|
640
655
|
if(!component.instance)
|
|
641
656
|
component.instance = {}
|
|
642
657
|
|
|
658
|
+
const compUid = '_' + component.uid.substring(0, 4) + ' '
|
|
659
|
+
|
|
643
660
|
Object.assign(component.instance, {
|
|
644
661
|
type: component.type,
|
|
645
662
|
uid: component.uid,
|
|
646
663
|
|
|
647
|
-
class: this.compClasses.map(key => {
|
|
664
|
+
class: compUid + this.compClasses.map(key => {
|
|
648
665
|
return Array.isArray(component.props[key]) ? component.props[key].join(' ') : ''
|
|
649
666
|
})
|
|
650
667
|
.filter(_ => _)
|
|
@@ -686,6 +703,7 @@ export default{
|
|
|
686
703
|
this.socketEmit2('page.save', this.page)
|
|
687
704
|
.then(() => {
|
|
688
705
|
if(reload){
|
|
706
|
+
this.iframeSrc = import.meta.env.VITE_WEB_HOST + '/' + (this.page.path ?? '')
|
|
689
707
|
this.reloadIframe()
|
|
690
708
|
}
|
|
691
709
|
})
|
|
@@ -765,6 +783,10 @@ export default{
|
|
|
765
783
|
}
|
|
766
784
|
}
|
|
767
785
|
}
|
|
786
|
+
},
|
|
787
|
+
|
|
788
|
+
getPage(){
|
|
789
|
+
return this.page
|
|
768
790
|
}
|
|
769
791
|
|
|
770
792
|
},
|
|
@@ -848,10 +870,6 @@ export default{
|
|
|
848
870
|
|
|
849
871
|
},
|
|
850
872
|
|
|
851
|
-
iframeSrc(){
|
|
852
|
-
return import.meta.env.VITE_WEB_HOST + '/' + (this.page.path ?? '')
|
|
853
|
-
},
|
|
854
|
-
|
|
855
873
|
layout(){
|
|
856
874
|
if(this.page){
|
|
857
875
|
return this.layouts.find((_) => _.id === parseInt(this.page.layoutId))
|
|
@@ -889,6 +907,7 @@ export default{
|
|
|
889
907
|
data(){
|
|
890
908
|
return {
|
|
891
909
|
iframeStyle: {},
|
|
910
|
+
iframeSrc: '',
|
|
892
911
|
page: null,
|
|
893
912
|
layouts: [],
|
|
894
913
|
tabItems: [
|
|
@@ -1019,7 +1038,7 @@ export default{
|
|
|
1019
1038
|
|
|
1020
1039
|
window.addEventListener('message', (event) => {
|
|
1021
1040
|
|
|
1022
|
-
const { uid, type, value } = event.data
|
|
1041
|
+
const { uid, type, value } = event.data ?? {}
|
|
1023
1042
|
|
|
1024
1043
|
let comp
|
|
1025
1044
|
let compType
|
|
@@ -1074,7 +1093,9 @@ export default{
|
|
|
1074
1093
|
return {
|
|
1075
1094
|
imageUrl: this.imageUrl,
|
|
1076
1095
|
imageSrc: this.imageSrc,
|
|
1077
|
-
store: this.store
|
|
1096
|
+
store: this.store,
|
|
1097
|
+
postIframe: this.postIframe,
|
|
1098
|
+
getPage: this.getPage
|
|
1078
1099
|
}
|
|
1079
1100
|
},
|
|
1080
1101
|
|
|
@@ -52,6 +52,8 @@ import groupBy from "lodash/groupBy";
|
|
|
52
52
|
|
|
53
53
|
export default{
|
|
54
54
|
|
|
55
|
+
emits: [ 'save' ],
|
|
56
|
+
|
|
55
57
|
inject: [ 'alert', 'socketEmit2' ],
|
|
56
58
|
|
|
57
59
|
props: {
|
|
@@ -96,7 +98,7 @@ export default{
|
|
|
96
98
|
async create(){
|
|
97
99
|
try{
|
|
98
100
|
const res = await this.socketEmit2('page.create', this.selectedTemplate.page)
|
|
99
|
-
this.$
|
|
101
|
+
this.$emit('save', res)
|
|
100
102
|
this.close()
|
|
101
103
|
}
|
|
102
104
|
catch(err){
|