@bagelink/blox 1.13.5 → 1.14.7
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/LICENSE +21 -0
- package/dist/CmsPageView.vue.d.ts.map +1 -1
- package/dist/PreviewApp-BDMfuAiu.cjs +4 -0
- package/dist/PreviewApp-MdZQEVkN.js +4 -0
- package/dist/PreviewApp.vue.d.ts.map +1 -1
- package/dist/PreviewApp.vue_vue_type_style_index_0_lang-BG9Fvfdw.cjs +187 -0
- package/dist/PreviewApp.vue_vue_type_style_index_0_lang-Bc4Ac4WN.js +188 -0
- package/dist/PreviewRenderer.d.ts.map +1 -1
- package/dist/bridge.d.ts +5 -0
- package/dist/bridge.d.ts.map +1 -1
- package/dist/core-CgtYpQbn.js +466 -0
- package/dist/core-DhrL5TMI.cjs +465 -0
- package/dist/core.d.ts.map +1 -1
- package/dist/createBloxApp.d.ts +107 -0
- package/dist/createBloxApp.d.ts.map +1 -0
- package/dist/defineBlock.d.ts +23 -4
- package/dist/defineBlock.d.ts.map +1 -1
- package/dist/index.cjs +87 -604
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +86 -602
- package/dist/{prerender-oMLxrKGs.js → prerender-CJ22vZ1T.js} +12 -10
- package/dist/{prerender-CjJwDXkC.cjs → prerender-LqPEzho3.cjs} +8 -6
- package/dist/schema.d.ts +6 -0
- package/dist/schema.d.ts.map +1 -1
- package/dist/ssg/cli.cjs +2 -2
- package/dist/ssg/cli.mjs +2 -2
- package/dist/ssg/client.cjs +9 -7
- package/dist/ssg/client.d.ts +1 -1
- package/dist/ssg/client.d.ts.map +1 -1
- package/dist/ssg/client.mjs +3 -1
- package/dist/ssg/collection-cache.d.ts +1 -1
- package/dist/ssg/constants.d.ts +1 -1
- package/dist/ssg/constants.d.ts.map +1 -1
- package/dist/ssg/createSSREntry.d.ts +73 -0
- package/dist/ssg/createSSREntry.d.ts.map +1 -0
- package/dist/ssg/index.cjs +116 -8
- package/dist/ssg/index.d.ts +2 -0
- package/dist/ssg/index.d.ts.map +1 -1
- package/dist/ssg/index.mjs +94 -7
- package/dist/ssg/prerender.d.ts.map +1 -1
- package/dist/ssg/render-resolved-page.d.ts +1 -1
- package/dist/ssg/render-resolved-page.d.ts.map +1 -1
- package/dist/style.css +5 -46
- package/dist/vite-plugin.cjs +143 -3
- package/dist/vite-plugin.d.ts +22 -21
- package/dist/vite-plugin.d.ts.map +1 -1
- package/dist/vite-plugin.mjs +143 -3
- package/package.json +128 -126
- package/dist/PreviewApp-BZNzZkit.js +0 -4
- package/dist/PreviewApp-C1WvJWI4.cjs +0 -4
- package/dist/constants-BjitNk-W.js +0 -8
- package/dist/constants-CFB_pMvT.cjs +0 -7
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 Bagel Studio
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CmsPageView.vue.d.ts","sourceRoot":"","sources":["../src/CmsPageView.vue"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"CmsPageView.vue.d.ts","sourceRoot":"","sources":["../src/CmsPageView.vue"],"names":[],"mappings":";AAoYA,wBAMG"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const PreviewApp_vue_vue_type_style_index_0_lang = require("./PreviewApp.vue_vue_type_style_index_0_lang-BG9Fvfdw.cjs");
|
|
4
|
+
exports.default = PreviewApp_vue_vue_type_style_index_0_lang._sfc_main;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PreviewApp.vue.d.ts","sourceRoot":"","sources":["../src/PreviewApp.vue"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"PreviewApp.vue.d.ts","sourceRoot":"","sources":["../src/PreviewApp.vue"],"names":[],"mappings":";AA+NA,wBAMG"}
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const vue = require("vue");
|
|
3
|
+
const core = require("./core-DhrL5TMI.cjs");
|
|
4
|
+
function sendToEditor(msg) {
|
|
5
|
+
window.parent.postMessage(msg, "*");
|
|
6
|
+
}
|
|
7
|
+
function sendToPreview(iframe, msg) {
|
|
8
|
+
var _a;
|
|
9
|
+
(_a = iframe.contentWindow) == null ? void 0 : _a.postMessage(msg, "*");
|
|
10
|
+
}
|
|
11
|
+
const PreviewRenderer = vue.defineComponent({
|
|
12
|
+
name: "PreviewRenderer",
|
|
13
|
+
props: {
|
|
14
|
+
blocks: {
|
|
15
|
+
type: Array,
|
|
16
|
+
default: () => []
|
|
17
|
+
},
|
|
18
|
+
selectedIndex: {
|
|
19
|
+
type: Number,
|
|
20
|
+
default: null
|
|
21
|
+
},
|
|
22
|
+
hoveredIndex: {
|
|
23
|
+
type: Number,
|
|
24
|
+
default: null
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
setup(props) {
|
|
28
|
+
const registry = vue.inject(core.BLOX_REGISTRY_KEY, {});
|
|
29
|
+
const localHovered = vue.ref(null);
|
|
30
|
+
function onBlockClick(index) {
|
|
31
|
+
sendToEditor({ type: "BLOX_BLOCK_CLICK", index });
|
|
32
|
+
}
|
|
33
|
+
function onBlockEnter(index) {
|
|
34
|
+
localHovered.value = index;
|
|
35
|
+
sendToEditor({ type: "BLOX_BLOCK_HOVER", index });
|
|
36
|
+
}
|
|
37
|
+
function onBlockLeave() {
|
|
38
|
+
localHovered.value = null;
|
|
39
|
+
sendToEditor({ type: "BLOX_BLOCK_HOVER", index: null });
|
|
40
|
+
}
|
|
41
|
+
const wrapperStyle = { position: "relative", cursor: "pointer" };
|
|
42
|
+
const overlayBase = {
|
|
43
|
+
position: "absolute",
|
|
44
|
+
inset: "0",
|
|
45
|
+
zIndex: "10",
|
|
46
|
+
pointerEvents: "auto",
|
|
47
|
+
transition: "box-shadow 0.12s, background 0.12s"
|
|
48
|
+
};
|
|
49
|
+
const overlayHovered = {
|
|
50
|
+
...overlayBase,
|
|
51
|
+
boxShadow: "inset 0 0 0 2px rgba(99, 102, 241, 0.5)",
|
|
52
|
+
background: "rgba(99, 102, 241, 0.04)"
|
|
53
|
+
};
|
|
54
|
+
const overlaySelected = {
|
|
55
|
+
...overlayBase,
|
|
56
|
+
boxShadow: "inset 0 0 0 3px #6366f1",
|
|
57
|
+
background: "rgba(99, 102, 241, 0.06)"
|
|
58
|
+
};
|
|
59
|
+
const labelBase = {
|
|
60
|
+
position: "absolute",
|
|
61
|
+
top: "0",
|
|
62
|
+
left: "0",
|
|
63
|
+
zIndex: "20",
|
|
64
|
+
padding: "2px 8px",
|
|
65
|
+
fontSize: "11px",
|
|
66
|
+
fontFamily: "system-ui, sans-serif",
|
|
67
|
+
fontWeight: "600",
|
|
68
|
+
lineHeight: "20px",
|
|
69
|
+
letterSpacing: "0.02em",
|
|
70
|
+
textTransform: "uppercase",
|
|
71
|
+
pointerEvents: "none",
|
|
72
|
+
whiteSpace: "nowrap",
|
|
73
|
+
color: "#6366f1",
|
|
74
|
+
background: "rgba(99, 102, 241, 0.1)",
|
|
75
|
+
borderBottomRightRadius: "4px"
|
|
76
|
+
};
|
|
77
|
+
const labelSelected = { ...labelBase, color: "#fff", background: "#6366f1" };
|
|
78
|
+
return () => vue.h(
|
|
79
|
+
"div",
|
|
80
|
+
{ class: "blox-preview-canvas" },
|
|
81
|
+
props.blocks.flatMap((block, i) => {
|
|
82
|
+
const definition = registry[block.type];
|
|
83
|
+
if (!definition) return [];
|
|
84
|
+
const isSelected = props.selectedIndex === i;
|
|
85
|
+
const isHovered = (props.hoveredIndex === i || localHovered.value === i) && !isSelected;
|
|
86
|
+
const { label } = definition.schema;
|
|
87
|
+
const overlayStyle = isSelected ? overlaySelected : isHovered ? overlayHovered : overlayBase;
|
|
88
|
+
return [
|
|
89
|
+
vue.h(
|
|
90
|
+
"div",
|
|
91
|
+
{
|
|
92
|
+
"key": i,
|
|
93
|
+
"data-blox-index": i,
|
|
94
|
+
"style": wrapperStyle,
|
|
95
|
+
"onClick": () => {
|
|
96
|
+
onBlockClick(i);
|
|
97
|
+
},
|
|
98
|
+
"onMouseenter": () => {
|
|
99
|
+
onBlockEnter(i);
|
|
100
|
+
},
|
|
101
|
+
"onMouseleave": onBlockLeave
|
|
102
|
+
},
|
|
103
|
+
[
|
|
104
|
+
vue.h(definition.component, { ...definition.schema.defaults, ...block.props }),
|
|
105
|
+
vue.h("div", { style: overlayStyle }),
|
|
106
|
+
(isSelected || isHovered) && vue.h("div", { style: isSelected ? labelSelected : labelBase }, label)
|
|
107
|
+
]
|
|
108
|
+
)
|
|
109
|
+
];
|
|
110
|
+
})
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
const _hoisted_1 = { class: "blox-preview-root" };
|
|
115
|
+
const _sfc_main = /* @__PURE__ */ vue.defineComponent({
|
|
116
|
+
__name: "PreviewApp",
|
|
117
|
+
setup(__props) {
|
|
118
|
+
const registry = vue.inject(core.BLOX_REGISTRY_KEY, {});
|
|
119
|
+
const { setLocale } = core.useLocale();
|
|
120
|
+
const blocks = vue.ref([]);
|
|
121
|
+
const contexts = vue.ref({});
|
|
122
|
+
const selectedIndex = vue.ref(null);
|
|
123
|
+
const hoveredIndex = vue.ref(null);
|
|
124
|
+
vue.provide("contexts", contexts);
|
|
125
|
+
let heightObserver = null;
|
|
126
|
+
function onMessage(event) {
|
|
127
|
+
var _a;
|
|
128
|
+
const msg = event.data;
|
|
129
|
+
switch (msg.type) {
|
|
130
|
+
case "BLOX_INIT":
|
|
131
|
+
blocks.value = ((_a = msg.page.page.content) == null ? void 0 : _a.blocks) ?? [];
|
|
132
|
+
contexts.value = msg.page.contexts ?? {};
|
|
133
|
+
setLocale(msg.locale);
|
|
134
|
+
break;
|
|
135
|
+
case "BLOX_SET_LOCALE":
|
|
136
|
+
setLocale(msg.locale);
|
|
137
|
+
break;
|
|
138
|
+
case "BLOX_SET_BLOCKS":
|
|
139
|
+
blocks.value = msg.blocks;
|
|
140
|
+
break;
|
|
141
|
+
case "BLOX_SELECT_BLOCK":
|
|
142
|
+
selectedIndex.value = msg.index;
|
|
143
|
+
if (msg.index !== null) {
|
|
144
|
+
vue.nextTick(() => {
|
|
145
|
+
const el = document.querySelector(`[data-blox-index="${msg.index}"]`);
|
|
146
|
+
el == null ? void 0 : el.scrollIntoView({ behavior: "smooth", block: "center" });
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
break;
|
|
150
|
+
case "BLOX_HOVER_BLOCK":
|
|
151
|
+
hoveredIndex.value = msg.index;
|
|
152
|
+
break;
|
|
153
|
+
case "BLOX_SCROLL_TOP":
|
|
154
|
+
window.scrollTo(0, 0);
|
|
155
|
+
break;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
vue.onMounted(() => {
|
|
159
|
+
window.addEventListener("message", onMessage);
|
|
160
|
+
heightObserver = new ResizeObserver(() => {
|
|
161
|
+
sendToEditor({ type: "BLOX_HEIGHT", height: document.body.scrollHeight });
|
|
162
|
+
});
|
|
163
|
+
heightObserver.observe(document.body);
|
|
164
|
+
sendToEditor({
|
|
165
|
+
type: "BLOX_READY",
|
|
166
|
+
registry: Object.fromEntries(Object.entries(registry).map(([key, def]) => [key, def.schema]))
|
|
167
|
+
});
|
|
168
|
+
});
|
|
169
|
+
vue.onUnmounted(() => {
|
|
170
|
+
window.removeEventListener("message", onMessage);
|
|
171
|
+
heightObserver == null ? void 0 : heightObserver.disconnect();
|
|
172
|
+
});
|
|
173
|
+
return (_ctx, _cache) => {
|
|
174
|
+
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1, [
|
|
175
|
+
vue.createVNode(vue.unref(PreviewRenderer), {
|
|
176
|
+
blocks: blocks.value,
|
|
177
|
+
"selected-index": selectedIndex.value,
|
|
178
|
+
"hovered-index": hoveredIndex.value
|
|
179
|
+
}, null, 8, ["blocks", "selected-index", "hovered-index"])
|
|
180
|
+
]);
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
});
|
|
184
|
+
exports.PreviewRenderer = PreviewRenderer;
|
|
185
|
+
exports._sfc_main = _sfc_main;
|
|
186
|
+
exports.sendToEditor = sendToEditor;
|
|
187
|
+
exports.sendToPreview = sendToPreview;
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import { defineComponent, inject, ref, h, provide, onMounted, onUnmounted, openBlock, createElementBlock, createVNode, unref, nextTick } from "vue";
|
|
2
|
+
import { e as BLOX_REGISTRY_KEY, u as useLocale } from "./core-CgtYpQbn.js";
|
|
3
|
+
function sendToEditor(msg) {
|
|
4
|
+
window.parent.postMessage(msg, "*");
|
|
5
|
+
}
|
|
6
|
+
function sendToPreview(iframe, msg) {
|
|
7
|
+
var _a;
|
|
8
|
+
(_a = iframe.contentWindow) == null ? void 0 : _a.postMessage(msg, "*");
|
|
9
|
+
}
|
|
10
|
+
const PreviewRenderer = defineComponent({
|
|
11
|
+
name: "PreviewRenderer",
|
|
12
|
+
props: {
|
|
13
|
+
blocks: {
|
|
14
|
+
type: Array,
|
|
15
|
+
default: () => []
|
|
16
|
+
},
|
|
17
|
+
selectedIndex: {
|
|
18
|
+
type: Number,
|
|
19
|
+
default: null
|
|
20
|
+
},
|
|
21
|
+
hoveredIndex: {
|
|
22
|
+
type: Number,
|
|
23
|
+
default: null
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
setup(props) {
|
|
27
|
+
const registry = inject(BLOX_REGISTRY_KEY, {});
|
|
28
|
+
const localHovered = ref(null);
|
|
29
|
+
function onBlockClick(index) {
|
|
30
|
+
sendToEditor({ type: "BLOX_BLOCK_CLICK", index });
|
|
31
|
+
}
|
|
32
|
+
function onBlockEnter(index) {
|
|
33
|
+
localHovered.value = index;
|
|
34
|
+
sendToEditor({ type: "BLOX_BLOCK_HOVER", index });
|
|
35
|
+
}
|
|
36
|
+
function onBlockLeave() {
|
|
37
|
+
localHovered.value = null;
|
|
38
|
+
sendToEditor({ type: "BLOX_BLOCK_HOVER", index: null });
|
|
39
|
+
}
|
|
40
|
+
const wrapperStyle = { position: "relative", cursor: "pointer" };
|
|
41
|
+
const overlayBase = {
|
|
42
|
+
position: "absolute",
|
|
43
|
+
inset: "0",
|
|
44
|
+
zIndex: "10",
|
|
45
|
+
pointerEvents: "auto",
|
|
46
|
+
transition: "box-shadow 0.12s, background 0.12s"
|
|
47
|
+
};
|
|
48
|
+
const overlayHovered = {
|
|
49
|
+
...overlayBase,
|
|
50
|
+
boxShadow: "inset 0 0 0 2px rgba(99, 102, 241, 0.5)",
|
|
51
|
+
background: "rgba(99, 102, 241, 0.04)"
|
|
52
|
+
};
|
|
53
|
+
const overlaySelected = {
|
|
54
|
+
...overlayBase,
|
|
55
|
+
boxShadow: "inset 0 0 0 3px #6366f1",
|
|
56
|
+
background: "rgba(99, 102, 241, 0.06)"
|
|
57
|
+
};
|
|
58
|
+
const labelBase = {
|
|
59
|
+
position: "absolute",
|
|
60
|
+
top: "0",
|
|
61
|
+
left: "0",
|
|
62
|
+
zIndex: "20",
|
|
63
|
+
padding: "2px 8px",
|
|
64
|
+
fontSize: "11px",
|
|
65
|
+
fontFamily: "system-ui, sans-serif",
|
|
66
|
+
fontWeight: "600",
|
|
67
|
+
lineHeight: "20px",
|
|
68
|
+
letterSpacing: "0.02em",
|
|
69
|
+
textTransform: "uppercase",
|
|
70
|
+
pointerEvents: "none",
|
|
71
|
+
whiteSpace: "nowrap",
|
|
72
|
+
color: "#6366f1",
|
|
73
|
+
background: "rgba(99, 102, 241, 0.1)",
|
|
74
|
+
borderBottomRightRadius: "4px"
|
|
75
|
+
};
|
|
76
|
+
const labelSelected = { ...labelBase, color: "#fff", background: "#6366f1" };
|
|
77
|
+
return () => h(
|
|
78
|
+
"div",
|
|
79
|
+
{ class: "blox-preview-canvas" },
|
|
80
|
+
props.blocks.flatMap((block, i) => {
|
|
81
|
+
const definition = registry[block.type];
|
|
82
|
+
if (!definition) return [];
|
|
83
|
+
const isSelected = props.selectedIndex === i;
|
|
84
|
+
const isHovered = (props.hoveredIndex === i || localHovered.value === i) && !isSelected;
|
|
85
|
+
const { label } = definition.schema;
|
|
86
|
+
const overlayStyle = isSelected ? overlaySelected : isHovered ? overlayHovered : overlayBase;
|
|
87
|
+
return [
|
|
88
|
+
h(
|
|
89
|
+
"div",
|
|
90
|
+
{
|
|
91
|
+
"key": i,
|
|
92
|
+
"data-blox-index": i,
|
|
93
|
+
"style": wrapperStyle,
|
|
94
|
+
"onClick": () => {
|
|
95
|
+
onBlockClick(i);
|
|
96
|
+
},
|
|
97
|
+
"onMouseenter": () => {
|
|
98
|
+
onBlockEnter(i);
|
|
99
|
+
},
|
|
100
|
+
"onMouseleave": onBlockLeave
|
|
101
|
+
},
|
|
102
|
+
[
|
|
103
|
+
h(definition.component, { ...definition.schema.defaults, ...block.props }),
|
|
104
|
+
h("div", { style: overlayStyle }),
|
|
105
|
+
(isSelected || isHovered) && h("div", { style: isSelected ? labelSelected : labelBase }, label)
|
|
106
|
+
]
|
|
107
|
+
)
|
|
108
|
+
];
|
|
109
|
+
})
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
const _hoisted_1 = { class: "blox-preview-root" };
|
|
114
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
115
|
+
__name: "PreviewApp",
|
|
116
|
+
setup(__props) {
|
|
117
|
+
const registry = inject(BLOX_REGISTRY_KEY, {});
|
|
118
|
+
const { setLocale } = useLocale();
|
|
119
|
+
const blocks = ref([]);
|
|
120
|
+
const contexts = ref({});
|
|
121
|
+
const selectedIndex = ref(null);
|
|
122
|
+
const hoveredIndex = ref(null);
|
|
123
|
+
provide("contexts", contexts);
|
|
124
|
+
let heightObserver = null;
|
|
125
|
+
function onMessage(event) {
|
|
126
|
+
var _a;
|
|
127
|
+
const msg = event.data;
|
|
128
|
+
switch (msg.type) {
|
|
129
|
+
case "BLOX_INIT":
|
|
130
|
+
blocks.value = ((_a = msg.page.page.content) == null ? void 0 : _a.blocks) ?? [];
|
|
131
|
+
contexts.value = msg.page.contexts ?? {};
|
|
132
|
+
setLocale(msg.locale);
|
|
133
|
+
break;
|
|
134
|
+
case "BLOX_SET_LOCALE":
|
|
135
|
+
setLocale(msg.locale);
|
|
136
|
+
break;
|
|
137
|
+
case "BLOX_SET_BLOCKS":
|
|
138
|
+
blocks.value = msg.blocks;
|
|
139
|
+
break;
|
|
140
|
+
case "BLOX_SELECT_BLOCK":
|
|
141
|
+
selectedIndex.value = msg.index;
|
|
142
|
+
if (msg.index !== null) {
|
|
143
|
+
nextTick(() => {
|
|
144
|
+
const el = document.querySelector(`[data-blox-index="${msg.index}"]`);
|
|
145
|
+
el == null ? void 0 : el.scrollIntoView({ behavior: "smooth", block: "center" });
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
break;
|
|
149
|
+
case "BLOX_HOVER_BLOCK":
|
|
150
|
+
hoveredIndex.value = msg.index;
|
|
151
|
+
break;
|
|
152
|
+
case "BLOX_SCROLL_TOP":
|
|
153
|
+
window.scrollTo(0, 0);
|
|
154
|
+
break;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
onMounted(() => {
|
|
158
|
+
window.addEventListener("message", onMessage);
|
|
159
|
+
heightObserver = new ResizeObserver(() => {
|
|
160
|
+
sendToEditor({ type: "BLOX_HEIGHT", height: document.body.scrollHeight });
|
|
161
|
+
});
|
|
162
|
+
heightObserver.observe(document.body);
|
|
163
|
+
sendToEditor({
|
|
164
|
+
type: "BLOX_READY",
|
|
165
|
+
registry: Object.fromEntries(Object.entries(registry).map(([key, def]) => [key, def.schema]))
|
|
166
|
+
});
|
|
167
|
+
});
|
|
168
|
+
onUnmounted(() => {
|
|
169
|
+
window.removeEventListener("message", onMessage);
|
|
170
|
+
heightObserver == null ? void 0 : heightObserver.disconnect();
|
|
171
|
+
});
|
|
172
|
+
return (_ctx, _cache) => {
|
|
173
|
+
return openBlock(), createElementBlock("div", _hoisted_1, [
|
|
174
|
+
createVNode(unref(PreviewRenderer), {
|
|
175
|
+
blocks: blocks.value,
|
|
176
|
+
"selected-index": selectedIndex.value,
|
|
177
|
+
"hovered-index": hoveredIndex.value
|
|
178
|
+
}, null, 8, ["blocks", "selected-index", "hovered-index"])
|
|
179
|
+
]);
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
export {
|
|
184
|
+
PreviewRenderer as P,
|
|
185
|
+
_sfc_main as _,
|
|
186
|
+
sendToPreview as a,
|
|
187
|
+
sendToEditor as s
|
|
188
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PreviewRenderer.d.ts","sourceRoot":"","sources":["../src/PreviewRenderer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,KAAK,CAAA;AACnC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;;;cAatB,QAAQ,CAAC,KAAK,EAAE,CAAC;uBACnB,KAAK,EAAE;;;cAGJ,QAAQ,CAAC,MAAM,GAAG,IAAI,CAAC;;;;cAIvB,QAAQ,CAAC,MAAM,GAAG,IAAI,CAAC;;;;;;;cARxB,QAAQ,CAAC,KAAK,EAAE,CAAC;uBACnB,KAAK,EAAE;;;cAGJ,QAAQ,CAAC,MAAM,GAAG,IAAI,CAAC;;;;cAIvB,QAAQ,CAAC,MAAM,GAAG,IAAI,CAAC;;;;;;;;AAZ1C,
|
|
1
|
+
{"version":3,"file":"PreviewRenderer.d.ts","sourceRoot":"","sources":["../src/PreviewRenderer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,KAAK,CAAA;AACnC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;;;cAatB,QAAQ,CAAC,KAAK,EAAE,CAAC;uBACnB,KAAK,EAAE;;;cAGJ,QAAQ,CAAC,MAAM,GAAG,IAAI,CAAC;;;;cAIvB,QAAQ,CAAC,MAAM,GAAG,IAAI,CAAC;;;;;;;cARxB,QAAQ,CAAC,KAAK,EAAE,CAAC;uBACnB,KAAK,EAAE;;;cAGJ,QAAQ,CAAC,MAAM,GAAG,IAAI,CAAC;;;;cAIvB,QAAQ,CAAC,MAAM,GAAG,IAAI,CAAC;;;;;;;;AAZ1C,wBA8FE"}
|
package/dist/bridge.d.ts
CHANGED
|
@@ -6,6 +6,9 @@ export interface BlockSchemaInfo {
|
|
|
6
6
|
icon?: string;
|
|
7
7
|
fields: SchemaDefinition;
|
|
8
8
|
defaults?: Record<string, unknown>;
|
|
9
|
+
dataSource?: boolean;
|
|
10
|
+
thumbnail?: string;
|
|
11
|
+
order?: number;
|
|
9
12
|
}
|
|
10
13
|
export type EditorMessage = {
|
|
11
14
|
type: 'BLOX_INIT';
|
|
@@ -23,6 +26,8 @@ export type EditorMessage = {
|
|
|
23
26
|
} | {
|
|
24
27
|
type: 'BLOX_HOVER_BLOCK';
|
|
25
28
|
index: number | null;
|
|
29
|
+
} | {
|
|
30
|
+
type: 'BLOX_SCROLL_TOP';
|
|
26
31
|
};
|
|
27
32
|
export type PreviewMessage = {
|
|
28
33
|
type: 'BLOX_READY';
|
package/dist/bridge.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bridge.d.ts","sourceRoot":"","sources":["../src/bridge.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA;AACrD,OAAO,KAAK,EAAE,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAEzD,MAAM,WAAW,eAAe;IAC/B,KAAK,EAAE,MAAM,CAAA;IACb,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,gBAAgB,CAAA;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;
|
|
1
|
+
{"version":3,"file":"bridge.d.ts","sourceRoot":"","sources":["../src/bridge.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA;AACrD,OAAO,KAAK,EAAE,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAEzD,MAAM,WAAW,eAAe;IAC/B,KAAK,EAAE,MAAM,CAAA;IACb,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,gBAAgB,CAAA;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAClC,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,KAAK,CAAC,EAAE,MAAM,CAAA;CACd;AAMD,MAAM,MAAM,aAAa,GACpB;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,IAAI,EAAE,eAAe,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAC7D;IAAE,IAAI,EAAE,iBAAiB,CAAC;IAAC,MAAM,EAAE,KAAK,EAAE,CAAA;CAAE,GAC5C;IAAE,IAAI,EAAE,iBAAiB,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAC3C;IAAE,IAAI,EAAE,mBAAmB,CAAC;IAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,GACnD;IAAE,IAAI,EAAE,kBAAkB,CAAC;IAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,GAClD;IAAE,IAAI,EAAE,iBAAiB,CAAA;CAAE,CAAA;AAM/B,MAAM,MAAM,cAAc,GACrB;IAAE,IAAI,EAAE,YAAY,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAA;CAAE,GAClE;IAAE,IAAI,EAAE,kBAAkB,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAC3C;IAAE,IAAI,EAAE,kBAAkB,CAAC;IAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,GAClD;IAAE,IAAI,EAAE,aAAa,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GACvC;IAAE,IAAI,EAAE,YAAY,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAA;AAM3C,wBAAgB,YAAY,CAAC,GAAG,EAAE,cAAc,GAAG,IAAI,CAEtD;AAED,wBAAgB,aAAa,CAAC,MAAM,EAAE,iBAAiB,EAAE,GAAG,EAAE,aAAa,GAAG,IAAI,CAEjF"}
|