@bagelink/blox 1.15.110 → 1.15.114
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/dist/CmsPageView.vue.d.ts.map +1 -1
- package/dist/{PreviewApp-B-0N8xJy.cjs → PreviewApp-0YmiHBi5.cjs} +1 -1
- package/dist/{PreviewApp-eIzHiJ-a.js → PreviewApp-T3i0jOkB.js} +1 -1
- package/dist/{PreviewApp.vue_vue_type_style_index_0_lang-CbtS5GCv.js → PreviewApp.vue_vue_type_style_index_0_lang-C0i8ucHq.js} +1 -1
- package/dist/{PreviewApp.vue_vue_type_style_index_0_lang-bIPmNO4K.cjs → PreviewApp.vue_vue_type_style_index_0_lang-CwX30h--.cjs} +1 -1
- package/dist/admin/AdminEditBar.vue.d.ts +7 -0
- package/dist/admin/AdminEditBar.vue.d.ts.map +1 -0
- package/dist/admin/useBloxEdit.d.ts +12 -0
- package/dist/admin/useBloxEdit.d.ts.map +1 -0
- package/dist/api/index.d.ts +3 -0
- package/dist/api/index.d.ts.map +1 -1
- package/dist/{core-inrQh-VF.cjs → core-DmxEiWAR.cjs} +137 -8
- package/dist/{core-Cz6zN6jB.js → core-VQR6lrvO.js} +144 -15
- package/dist/core.d.ts +4 -0
- package/dist/core.d.ts.map +1 -1
- package/dist/index.cjs +8 -3
- package/dist/index.d.ts +5 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +15 -10
- package/dist/ssg/index.cjs +1 -1
- package/dist/ssg/index.mjs +1 -1
- package/dist/style.css +30 -0
- package/dist/symbols.d.ts +16 -0
- package/dist/symbols.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -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":";AAubA,wBAMG"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
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-
|
|
3
|
+
const PreviewApp_vue_vue_type_style_index_0_lang = require("./PreviewApp.vue_vue_type_style_index_0_lang-CwX30h--.cjs");
|
|
4
4
|
exports.default = PreviewApp_vue_vue_type_style_index_0_lang._sfc_main;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defineComponent, inject, ref, h, provide, onMounted, onUnmounted, openBlock, createElementBlock, createVNode, unref, nextTick } from "vue";
|
|
2
|
-
import { B as BLOX_REGISTRY_KEY, g as globalRefOf, G as GlobalBlockHost, u as useLocale } from "./core-
|
|
2
|
+
import { B as BLOX_REGISTRY_KEY, g as globalRefOf, G as GlobalBlockHost, u as useLocale } from "./core-VQR6lrvO.js";
|
|
3
3
|
function sendToEditor(msg) {
|
|
4
4
|
window.parent.postMessage(msg, "*");
|
|
5
5
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
type __VLS_Props = {
|
|
2
|
+
websiteId?: string | null;
|
|
3
|
+
pageId?: string | null;
|
|
4
|
+
};
|
|
5
|
+
declare const _default: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
6
|
+
export default _default;
|
|
7
|
+
//# sourceMappingURL=AdminEditBar.vue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AdminEditBar.vue.d.ts","sourceRoot":"","sources":["../../src/admin/AdminEditBar.vue"],"names":[],"mappings":"AAwEA,KAAK,WAAW,GAAG;IAClB,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACzB,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CACtB,CAAC;;AAsFF,wBAMG"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { BloxAdminConfig } from '../symbols';
|
|
2
|
+
export declare function useBloxEdit(configOverride?: BloxAdminConfig): {
|
|
3
|
+
config: BloxAdminConfig | null;
|
|
4
|
+
enabled: import('vue').ComputedRef<boolean>;
|
|
5
|
+
showEdit: import('vue').ComputedRef<boolean>;
|
|
6
|
+
studioBaseUrl: import('vue').ComputedRef<string>;
|
|
7
|
+
editUrl: (websiteId: string, pageId: string) => string;
|
|
8
|
+
enable: () => void;
|
|
9
|
+
dismiss: () => void;
|
|
10
|
+
init: () => void;
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=useBloxEdit.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useBloxEdit.d.ts","sourceRoot":"","sources":["../../src/admin/useBloxEdit.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAuCjD,wBAAgB,WAAW,CAAC,cAAc,CAAC,EAAE,eAAe;;;;;yBAuB/B,MAAM,UAAU,MAAM,KAAG,MAAM;;;;EAiB3D"}
|
package/dist/api/index.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { CollectionItemsPage, PageResolveRead } from './types';
|
|
2
2
|
export declare function configureApi(websiteName: string, store: string): void;
|
|
3
|
+
/** Synchronously read the resolved website id if already known (SSG-embedded or cached). */
|
|
4
|
+
export declare function getWebsiteIdSync(): string | null;
|
|
5
|
+
export declare function getWebsiteId(): Promise<string>;
|
|
3
6
|
export declare function resolvePath(path: string, locale: string): Promise<PageResolveRead>;
|
|
4
7
|
export interface ListItemsOptions {
|
|
5
8
|
locale?: string;
|
package/dist/api/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,eAAe,EAAe,MAAM,SAAS,CAAA;AAUhF,wBAAgB,YAAY,CAAC,WAAW,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAIrE;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,eAAe,EAAe,MAAM,SAAS,CAAA;AAUhF,wBAAgB,YAAY,CAAC,WAAW,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAIrE;AAsBD,4FAA4F;AAC5F,wBAAgB,gBAAgB,IAAI,MAAM,GAAG,IAAI,CAOhD;AAED,wBAAsB,YAAY,IAAI,OAAO,CAAC,MAAM,CAAC,CAiBpD;AAED,wBAAsB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CAMxF;AAED,MAAM,WAAW,gBAAgB;IAChC,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,CAAC,CAAC,EAAE,MAAM,CAAA;IACV,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,KAAK,CAAC,EAAE,MAAM,CAAA;CACd;AAED,wBAAsB,SAAS,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC1D,UAAU,EAAE,MAAM,EAClB,EAAE,MAAM,EAAE,CAAC,EAAE,MAAU,EAAE,KAAW,EAAE,GAAE,gBAAqB,GAC3D,OAAO,CAAC,mBAAmB,GAAG;IAAE,KAAK,EAAE,CAAC,EAAE,CAAA;CAAE,CAAC,CAK/C"}
|
|
@@ -26,6 +26,14 @@ async function request(path, { locale: locale2, params, ...opts } = {}) {
|
|
|
26
26
|
if (res.status === 204) return null;
|
|
27
27
|
return res.json();
|
|
28
28
|
}
|
|
29
|
+
function getWebsiteIdSync() {
|
|
30
|
+
if (_websiteId) return _websiteId;
|
|
31
|
+
if (typeof window !== "undefined") {
|
|
32
|
+
const embedded = window[ssg_client.BLOX_WEBSITE_ID_WINDOW_KEY];
|
|
33
|
+
if (typeof embedded === "string" && embedded !== "") return embedded;
|
|
34
|
+
}
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
29
37
|
async function getWebsiteId() {
|
|
30
38
|
if (_websiteId) return _websiteId;
|
|
31
39
|
if (typeof window !== "undefined") {
|
|
@@ -54,6 +62,104 @@ async function listItems(collection, { locale: locale2, q, offset = 0, limit = 1
|
|
|
54
62
|
params: { ...q ? { q } : {}, offset, limit }
|
|
55
63
|
});
|
|
56
64
|
}
|
|
65
|
+
const BLOX_REGISTRY_KEY = Symbol("blox:registry");
|
|
66
|
+
const BLOX_CONFIG_KEY = Symbol("blox:config");
|
|
67
|
+
const BLOX_LOCALE_STRATEGY_KEY = Symbol("blox:locale-strategy");
|
|
68
|
+
const BLOX_GLOBAL_RESOLVER_KEY = Symbol("blox:global-resolver");
|
|
69
|
+
const BLOX_ADMIN_CONFIG_KEY = Symbol("blox:admin-config");
|
|
70
|
+
const STORAGE_KEY = "blox:edit";
|
|
71
|
+
const active = vue.ref(readStored());
|
|
72
|
+
let initialized = false;
|
|
73
|
+
function readStored() {
|
|
74
|
+
if (typeof localStorage === "undefined") return false;
|
|
75
|
+
try {
|
|
76
|
+
return localStorage.getItem(STORAGE_KEY) === "1";
|
|
77
|
+
} catch {
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
function writeStored(value) {
|
|
82
|
+
if (typeof localStorage === "undefined") return;
|
|
83
|
+
try {
|
|
84
|
+
if (value) localStorage.setItem(STORAGE_KEY, "1");
|
|
85
|
+
else localStorage.removeItem(STORAGE_KEY);
|
|
86
|
+
} catch {
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
function useBloxEdit(configOverride) {
|
|
90
|
+
const injected = vue.inject(BLOX_ADMIN_CONFIG_KEY, null);
|
|
91
|
+
const config = configOverride ?? injected;
|
|
92
|
+
const enabled = vue.computed(() => config != null);
|
|
93
|
+
const showEdit = vue.computed(() => active.value);
|
|
94
|
+
const studioBaseUrl = vue.computed(() => {
|
|
95
|
+
if (!config) return "";
|
|
96
|
+
return (config.studioBaseUrl ?? `https://${config.projectId}.bagelstudio.co`).replace(/\/$/, "");
|
|
97
|
+
});
|
|
98
|
+
function enable() {
|
|
99
|
+
active.value = true;
|
|
100
|
+
writeStored(true);
|
|
101
|
+
}
|
|
102
|
+
function dismiss() {
|
|
103
|
+
active.value = false;
|
|
104
|
+
writeStored(false);
|
|
105
|
+
}
|
|
106
|
+
function editUrl(websiteId, pageId) {
|
|
107
|
+
return `${studioBaseUrl.value}/blox/${websiteId}/${pageId}`;
|
|
108
|
+
}
|
|
109
|
+
function init() {
|
|
110
|
+
if (initialized || !enabled.value || typeof window === "undefined") return;
|
|
111
|
+
initialized = true;
|
|
112
|
+
const trigger = (config == null ? void 0 : config.trigger) ?? "edit";
|
|
113
|
+
const params = new URLSearchParams(window.location.search);
|
|
114
|
+
if (params.has(trigger)) enable();
|
|
115
|
+
window.__bloxEdit = { enable, dismiss };
|
|
116
|
+
}
|
|
117
|
+
return { config, enabled, showEdit, studioBaseUrl, editUrl, enable, dismiss, init };
|
|
118
|
+
}
|
|
119
|
+
const _hoisted_1$1 = {
|
|
120
|
+
key: 0,
|
|
121
|
+
class: "blox-admin-bar"
|
|
122
|
+
};
|
|
123
|
+
const _sfc_main$2 = /* @__PURE__ */ vue.defineComponent({
|
|
124
|
+
__name: "AdminEditBar",
|
|
125
|
+
props: {
|
|
126
|
+
websiteId: {},
|
|
127
|
+
pageId: {}
|
|
128
|
+
},
|
|
129
|
+
setup(__props) {
|
|
130
|
+
const props = __props;
|
|
131
|
+
const { enabled, showEdit, editUrl, dismiss, init } = useBloxEdit();
|
|
132
|
+
vue.onMounted(init);
|
|
133
|
+
function openEditor() {
|
|
134
|
+
if (!props.websiteId || !props.pageId) return;
|
|
135
|
+
window.location.href = editUrl(props.websiteId, props.pageId);
|
|
136
|
+
}
|
|
137
|
+
return (_ctx, _cache) => {
|
|
138
|
+
return vue.unref(enabled) ? (vue.openBlock(), vue.createBlock(vue.Teleport, {
|
|
139
|
+
key: 0,
|
|
140
|
+
to: "body"
|
|
141
|
+
}, [
|
|
142
|
+
vue.unref(showEdit) && __props.websiteId && __props.pageId ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_1$1, [
|
|
143
|
+
vue.createElementVNode("button", {
|
|
144
|
+
type: "button",
|
|
145
|
+
class: "blox-admin-btn",
|
|
146
|
+
onClick: openEditor
|
|
147
|
+
}, [..._cache[1] || (_cache[1] = [
|
|
148
|
+
vue.createElementVNode("span", { "aria-hidden": "true" }, "✏️", -1),
|
|
149
|
+
vue.createElementVNode("span", null, "Edit this page", -1)
|
|
150
|
+
])]),
|
|
151
|
+
vue.createElementVNode("button", {
|
|
152
|
+
type: "button",
|
|
153
|
+
class: "blox-admin-btn blox-admin-btn--ghost",
|
|
154
|
+
title: "Hide",
|
|
155
|
+
onClick: _cache[0] || (_cache[0] = //@ts-ignore
|
|
156
|
+
(...args) => vue.unref(dismiss) && vue.unref(dismiss)(...args))
|
|
157
|
+
}, " ✕ ")
|
|
158
|
+
])) : vue.createCommentVNode("", true)
|
|
159
|
+
])) : vue.createCommentVNode("", true);
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
});
|
|
57
163
|
const locale = vue.ref(localStorage.getItem("blox:locale") || "en");
|
|
58
164
|
const currentAlternates = vue.ref({});
|
|
59
165
|
function useLocale() {
|
|
@@ -74,10 +180,6 @@ function useLocale() {
|
|
|
74
180
|
}
|
|
75
181
|
return { locale, dir, setLocale, currentAlternates, setAlternates };
|
|
76
182
|
}
|
|
77
|
-
const BLOX_REGISTRY_KEY = Symbol("blox:registry");
|
|
78
|
-
const BLOX_CONFIG_KEY = Symbol("blox:config");
|
|
79
|
-
const BLOX_LOCALE_STRATEGY_KEY = Symbol("blox:locale-strategy");
|
|
80
|
-
const BLOX_GLOBAL_RESOLVER_KEY = Symbol("blox:global-resolver");
|
|
81
183
|
const GlobalBlockHost = vue.defineComponent({
|
|
82
184
|
name: "GlobalBlockHost",
|
|
83
185
|
props: {
|
|
@@ -208,12 +310,15 @@ const _sfc_main$1 = /* @__PURE__ */ vue.defineComponent({
|
|
|
208
310
|
const blocks = vue.ref([]);
|
|
209
311
|
const contexts = vue.ref({});
|
|
210
312
|
vue.provide("contexts", contexts);
|
|
313
|
+
const adminConfig = vue.inject(BLOX_ADMIN_CONFIG_KEY, null);
|
|
314
|
+
const currentPageId = vue.ref(null);
|
|
315
|
+
const websiteId = vue.ref(getWebsiteIdSync());
|
|
211
316
|
const notFound = vue.ref(false);
|
|
212
317
|
const error = vue.ref(null);
|
|
213
318
|
const initialLoading = vue.ref(true);
|
|
214
319
|
const navigating = vue.ref(false);
|
|
215
320
|
function tryHydrateFromState(path) {
|
|
216
|
-
var _a, _b;
|
|
321
|
+
var _a, _b, _c;
|
|
217
322
|
const win = typeof window !== "undefined" ? window : typeof globalThis !== "undefined" ? globalThis : void 0;
|
|
218
323
|
if (!win) return false;
|
|
219
324
|
const state = win[ssg_client.BLOX_STATE_WINDOW_KEY];
|
|
@@ -222,6 +327,7 @@ const _sfc_main$1 = /* @__PURE__ */ vue.defineComponent({
|
|
|
222
327
|
if (!entry) return false;
|
|
223
328
|
blocks.value = ((_b = (_a = entry.page) == null ? void 0 : _a.content) == null ? void 0 : _b.blocks) ?? [];
|
|
224
329
|
contexts.value = entry.contexts ?? {};
|
|
330
|
+
currentPageId.value = ((_c = entry.page) == null ? void 0 : _c.id) ?? null;
|
|
225
331
|
setAlternates(entry.alternates ?? {});
|
|
226
332
|
return true;
|
|
227
333
|
}
|
|
@@ -258,6 +364,7 @@ const _sfc_main$1 = /* @__PURE__ */ vue.defineComponent({
|
|
|
258
364
|
const resolved = await resolvePath(slug, urlLocale);
|
|
259
365
|
blocks.value = ((_a = resolved.page.content) == null ? void 0 : _a.blocks) ?? [];
|
|
260
366
|
contexts.value = resolved.contexts ?? {};
|
|
367
|
+
currentPageId.value = resolved.page.id ?? null;
|
|
261
368
|
setAlternates(resolved.alternates ?? {});
|
|
262
369
|
updateDocumentTitle(resolved);
|
|
263
370
|
} catch (e) {
|
|
@@ -277,6 +384,14 @@ const _sfc_main$1 = /* @__PURE__ */ vue.defineComponent({
|
|
|
277
384
|
load();
|
|
278
385
|
}
|
|
279
386
|
vue.watch(() => route.path, load);
|
|
387
|
+
vue.onMounted(() => {
|
|
388
|
+
if (adminConfig && !websiteId.value) {
|
|
389
|
+
getWebsiteId().then((id) => {
|
|
390
|
+
websiteId.value = id;
|
|
391
|
+
}).catch(() => {
|
|
392
|
+
});
|
|
393
|
+
}
|
|
394
|
+
});
|
|
280
395
|
return (_ctx, _cache) => {
|
|
281
396
|
const _component_RouterLink = vue.resolveComponent("RouterLink");
|
|
282
397
|
return vue.openBlock(), vue.createElementBlock("div", null, [
|
|
@@ -294,7 +409,12 @@ const _sfc_main$1 = /* @__PURE__ */ vue.defineComponent({
|
|
|
294
409
|
])) : error.value ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_3, vue.toDisplayString(error.value), 1)) : (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 3 }, [
|
|
295
410
|
navigating.value ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_4)) : vue.createCommentVNode("", true),
|
|
296
411
|
vue.createVNode(vue.unref(PageRenderer), { blocks: blocks.value }, null, 8, ["blocks"])
|
|
297
|
-
], 64))
|
|
412
|
+
], 64)),
|
|
413
|
+
vue.unref(adminConfig) ? (vue.openBlock(), vue.createBlock(_sfc_main$2, {
|
|
414
|
+
key: 4,
|
|
415
|
+
"website-id": websiteId.value,
|
|
416
|
+
"page-id": currentPageId.value
|
|
417
|
+
}, null, 8, ["website-id", "page-id"])) : vue.createCommentVNode("", true)
|
|
298
418
|
]);
|
|
299
419
|
};
|
|
300
420
|
}
|
|
@@ -415,11 +535,13 @@ class BloxInstance {
|
|
|
415
535
|
__publicField(this, "_routeRegistered", false);
|
|
416
536
|
__publicField(this, "_config");
|
|
417
537
|
__publicField(this, "_strategy");
|
|
538
|
+
__publicField(this, "_adminEdit");
|
|
418
539
|
this._config = {
|
|
419
540
|
defaultLocale: (options == null ? void 0 : options.defaultLocale) ?? "en",
|
|
420
541
|
supportedLocales: (options == null ? void 0 : options.supportedLocales) ?? []
|
|
421
542
|
};
|
|
422
543
|
this._strategy = createLocaleStrategy(options ?? {});
|
|
544
|
+
this._adminEdit = options == null ? void 0 : options.adminEdit;
|
|
423
545
|
}
|
|
424
546
|
registerModules(modules) {
|
|
425
547
|
const list = Array.isArray(modules) ? modules : Object.values(modules);
|
|
@@ -488,7 +610,7 @@ class BloxInstance {
|
|
|
488
610
|
}
|
|
489
611
|
router.addRoute({
|
|
490
612
|
path: "/_blox_preview",
|
|
491
|
-
component: () => Promise.resolve().then(() => require("./PreviewApp-
|
|
613
|
+
component: () => Promise.resolve().then(() => require("./PreviewApp-0YmiHBi5.cjs")),
|
|
492
614
|
beforeEnter: () => window.parent !== window ? true : "/"
|
|
493
615
|
});
|
|
494
616
|
router.addRoute({ path: "/:pathMatch(.*)*", component: _sfc_main$1 });
|
|
@@ -510,6 +632,7 @@ class BloxInstance {
|
|
|
510
632
|
if (options == null ? void 0 : options.modules) this.registerModules(options.modules);
|
|
511
633
|
if (options == null ? void 0 : options.components) this.registerComponents(options.components);
|
|
512
634
|
if (options == null ? void 0 : options.router) this.registerRoutes(options.router);
|
|
635
|
+
if (options == null ? void 0 : options.adminEdit) this._adminEdit = options.adminEdit;
|
|
513
636
|
if ((options == null ? void 0 : options.websiteName) || (options == null ? void 0 : options.store)) {
|
|
514
637
|
configureApi(options.websiteName ?? "", options.store ?? "");
|
|
515
638
|
}
|
|
@@ -520,6 +643,7 @@ class BloxInstance {
|
|
|
520
643
|
app.provide(BLOX_REGISTRY_KEY, this._registry);
|
|
521
644
|
app.provide(BLOX_CONFIG_KEY, this._config);
|
|
522
645
|
app.provide(BLOX_LOCALE_STRATEGY_KEY, this._strategy);
|
|
646
|
+
if (this._adminEdit) app.provide(BLOX_ADMIN_CONFIG_KEY, this._adminEdit);
|
|
523
647
|
app.component("RouterLink", _sfc_main);
|
|
524
648
|
}
|
|
525
649
|
}
|
|
@@ -536,6 +660,7 @@ function createBlox(options) {
|
|
|
536
660
|
if (options == null ? void 0 : options.router) instance.registerRoutes(options.router);
|
|
537
661
|
return instance;
|
|
538
662
|
}
|
|
663
|
+
exports.BLOX_ADMIN_CONFIG_KEY = BLOX_ADMIN_CONFIG_KEY;
|
|
539
664
|
exports.BLOX_CONFIG_KEY = BLOX_CONFIG_KEY;
|
|
540
665
|
exports.BLOX_GLOBAL_RESOLVER_KEY = BLOX_GLOBAL_RESOLVER_KEY;
|
|
541
666
|
exports.BLOX_LOCALE_STRATEGY_KEY = BLOX_LOCALE_STRATEGY_KEY;
|
|
@@ -544,10 +669,14 @@ exports.BloxInstance = BloxInstance;
|
|
|
544
669
|
exports.GLOBAL_REF_KEY = GLOBAL_REF_KEY;
|
|
545
670
|
exports.GlobalBlockHost = GlobalBlockHost;
|
|
546
671
|
exports.PageRenderer = PageRenderer;
|
|
547
|
-
exports._sfc_main = _sfc_main$
|
|
672
|
+
exports._sfc_main = _sfc_main$2;
|
|
673
|
+
exports._sfc_main$1 = _sfc_main$1;
|
|
548
674
|
exports.configureApi = configureApi;
|
|
549
675
|
exports.createBlox = createBlox;
|
|
676
|
+
exports.getWebsiteId = getWebsiteId;
|
|
677
|
+
exports.getWebsiteIdSync = getWebsiteIdSync;
|
|
550
678
|
exports.globalRefOf = globalRefOf;
|
|
551
679
|
exports.listItems = listItems;
|
|
552
680
|
exports.resolvePath = resolvePath;
|
|
681
|
+
exports.useBloxEdit = useBloxEdit;
|
|
553
682
|
exports.useLocale = useLocale;
|
|
@@ -2,7 +2,7 @@ var __defProp = Object.defineProperty;
|
|
|
2
2
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
3
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
4
|
import { BLOX_WEBSITE_ID_WINDOW_KEY, BLOX_STATE_WINDOW_KEY } from "./ssg/client.mjs";
|
|
5
|
-
import { computed, ref, defineComponent,
|
|
5
|
+
import { inject, computed, ref, defineComponent, onMounted, unref, openBlock, createBlock, Teleport, createElementBlock, createElementVNode, createCommentVNode, onUnmounted, watch, h, provide, resolveComponent, createVNode, toDisplayString, withCtx, createTextVNode, Fragment, normalizeProps, guardReactiveProps, renderSlot } from "vue";
|
|
6
6
|
import { useRoute, useRouter, RouterLink } from "vue-router";
|
|
7
7
|
import { getI18n, Loading } from "@bagelink/vue";
|
|
8
8
|
const BASE = "/api";
|
|
@@ -25,6 +25,14 @@ async function request(path, { locale: locale2, params, ...opts } = {}) {
|
|
|
25
25
|
if (res.status === 204) return null;
|
|
26
26
|
return res.json();
|
|
27
27
|
}
|
|
28
|
+
function getWebsiteIdSync() {
|
|
29
|
+
if (_websiteId) return _websiteId;
|
|
30
|
+
if (typeof window !== "undefined") {
|
|
31
|
+
const embedded = window[BLOX_WEBSITE_ID_WINDOW_KEY];
|
|
32
|
+
if (typeof embedded === "string" && embedded !== "") return embedded;
|
|
33
|
+
}
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
28
36
|
async function getWebsiteId() {
|
|
29
37
|
if (_websiteId) return _websiteId;
|
|
30
38
|
if (typeof window !== "undefined") {
|
|
@@ -53,6 +61,104 @@ async function listItems(collection, { locale: locale2, q, offset = 0, limit = 1
|
|
|
53
61
|
params: { ...q ? { q } : {}, offset, limit }
|
|
54
62
|
});
|
|
55
63
|
}
|
|
64
|
+
const BLOX_REGISTRY_KEY = Symbol("blox:registry");
|
|
65
|
+
const BLOX_CONFIG_KEY = Symbol("blox:config");
|
|
66
|
+
const BLOX_LOCALE_STRATEGY_KEY = Symbol("blox:locale-strategy");
|
|
67
|
+
const BLOX_GLOBAL_RESOLVER_KEY = Symbol("blox:global-resolver");
|
|
68
|
+
const BLOX_ADMIN_CONFIG_KEY = Symbol("blox:admin-config");
|
|
69
|
+
const STORAGE_KEY = "blox:edit";
|
|
70
|
+
const active = ref(readStored());
|
|
71
|
+
let initialized = false;
|
|
72
|
+
function readStored() {
|
|
73
|
+
if (typeof localStorage === "undefined") return false;
|
|
74
|
+
try {
|
|
75
|
+
return localStorage.getItem(STORAGE_KEY) === "1";
|
|
76
|
+
} catch {
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
function writeStored(value) {
|
|
81
|
+
if (typeof localStorage === "undefined") return;
|
|
82
|
+
try {
|
|
83
|
+
if (value) localStorage.setItem(STORAGE_KEY, "1");
|
|
84
|
+
else localStorage.removeItem(STORAGE_KEY);
|
|
85
|
+
} catch {
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
function useBloxEdit(configOverride) {
|
|
89
|
+
const injected = inject(BLOX_ADMIN_CONFIG_KEY, null);
|
|
90
|
+
const config = configOverride ?? injected;
|
|
91
|
+
const enabled = computed(() => config != null);
|
|
92
|
+
const showEdit = computed(() => active.value);
|
|
93
|
+
const studioBaseUrl = computed(() => {
|
|
94
|
+
if (!config) return "";
|
|
95
|
+
return (config.studioBaseUrl ?? `https://${config.projectId}.bagelstudio.co`).replace(/\/$/, "");
|
|
96
|
+
});
|
|
97
|
+
function enable() {
|
|
98
|
+
active.value = true;
|
|
99
|
+
writeStored(true);
|
|
100
|
+
}
|
|
101
|
+
function dismiss() {
|
|
102
|
+
active.value = false;
|
|
103
|
+
writeStored(false);
|
|
104
|
+
}
|
|
105
|
+
function editUrl(websiteId, pageId) {
|
|
106
|
+
return `${studioBaseUrl.value}/blox/${websiteId}/${pageId}`;
|
|
107
|
+
}
|
|
108
|
+
function init() {
|
|
109
|
+
if (initialized || !enabled.value || typeof window === "undefined") return;
|
|
110
|
+
initialized = true;
|
|
111
|
+
const trigger = (config == null ? void 0 : config.trigger) ?? "edit";
|
|
112
|
+
const params = new URLSearchParams(window.location.search);
|
|
113
|
+
if (params.has(trigger)) enable();
|
|
114
|
+
window.__bloxEdit = { enable, dismiss };
|
|
115
|
+
}
|
|
116
|
+
return { config, enabled, showEdit, studioBaseUrl, editUrl, enable, dismiss, init };
|
|
117
|
+
}
|
|
118
|
+
const _hoisted_1$1 = {
|
|
119
|
+
key: 0,
|
|
120
|
+
class: "blox-admin-bar"
|
|
121
|
+
};
|
|
122
|
+
const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
123
|
+
__name: "AdminEditBar",
|
|
124
|
+
props: {
|
|
125
|
+
websiteId: {},
|
|
126
|
+
pageId: {}
|
|
127
|
+
},
|
|
128
|
+
setup(__props) {
|
|
129
|
+
const props = __props;
|
|
130
|
+
const { enabled, showEdit, editUrl, dismiss, init } = useBloxEdit();
|
|
131
|
+
onMounted(init);
|
|
132
|
+
function openEditor() {
|
|
133
|
+
if (!props.websiteId || !props.pageId) return;
|
|
134
|
+
window.location.href = editUrl(props.websiteId, props.pageId);
|
|
135
|
+
}
|
|
136
|
+
return (_ctx, _cache) => {
|
|
137
|
+
return unref(enabled) ? (openBlock(), createBlock(Teleport, {
|
|
138
|
+
key: 0,
|
|
139
|
+
to: "body"
|
|
140
|
+
}, [
|
|
141
|
+
unref(showEdit) && __props.websiteId && __props.pageId ? (openBlock(), createElementBlock("div", _hoisted_1$1, [
|
|
142
|
+
createElementVNode("button", {
|
|
143
|
+
type: "button",
|
|
144
|
+
class: "blox-admin-btn",
|
|
145
|
+
onClick: openEditor
|
|
146
|
+
}, [..._cache[1] || (_cache[1] = [
|
|
147
|
+
createElementVNode("span", { "aria-hidden": "true" }, "✏️", -1),
|
|
148
|
+
createElementVNode("span", null, "Edit this page", -1)
|
|
149
|
+
])]),
|
|
150
|
+
createElementVNode("button", {
|
|
151
|
+
type: "button",
|
|
152
|
+
class: "blox-admin-btn blox-admin-btn--ghost",
|
|
153
|
+
title: "Hide",
|
|
154
|
+
onClick: _cache[0] || (_cache[0] = //@ts-ignore
|
|
155
|
+
(...args) => unref(dismiss) && unref(dismiss)(...args))
|
|
156
|
+
}, " ✕ ")
|
|
157
|
+
])) : createCommentVNode("", true)
|
|
158
|
+
])) : createCommentVNode("", true);
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
});
|
|
56
162
|
const locale = ref(localStorage.getItem("blox:locale") || "en");
|
|
57
163
|
const currentAlternates = ref({});
|
|
58
164
|
function useLocale() {
|
|
@@ -73,10 +179,6 @@ function useLocale() {
|
|
|
73
179
|
}
|
|
74
180
|
return { locale, dir, setLocale, currentAlternates, setAlternates };
|
|
75
181
|
}
|
|
76
|
-
const BLOX_REGISTRY_KEY = Symbol("blox:registry");
|
|
77
|
-
const BLOX_CONFIG_KEY = Symbol("blox:config");
|
|
78
|
-
const BLOX_LOCALE_STRATEGY_KEY = Symbol("blox:locale-strategy");
|
|
79
|
-
const BLOX_GLOBAL_RESOLVER_KEY = Symbol("blox:global-resolver");
|
|
80
182
|
const GlobalBlockHost = defineComponent({
|
|
81
183
|
name: "GlobalBlockHost",
|
|
82
184
|
props: {
|
|
@@ -207,12 +309,15 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
207
309
|
const blocks = ref([]);
|
|
208
310
|
const contexts = ref({});
|
|
209
311
|
provide("contexts", contexts);
|
|
312
|
+
const adminConfig = inject(BLOX_ADMIN_CONFIG_KEY, null);
|
|
313
|
+
const currentPageId = ref(null);
|
|
314
|
+
const websiteId = ref(getWebsiteIdSync());
|
|
210
315
|
const notFound = ref(false);
|
|
211
316
|
const error = ref(null);
|
|
212
317
|
const initialLoading = ref(true);
|
|
213
318
|
const navigating = ref(false);
|
|
214
319
|
function tryHydrateFromState(path) {
|
|
215
|
-
var _a, _b;
|
|
320
|
+
var _a, _b, _c;
|
|
216
321
|
const win = typeof window !== "undefined" ? window : typeof globalThis !== "undefined" ? globalThis : void 0;
|
|
217
322
|
if (!win) return false;
|
|
218
323
|
const state = win[BLOX_STATE_WINDOW_KEY];
|
|
@@ -221,6 +326,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
221
326
|
if (!entry) return false;
|
|
222
327
|
blocks.value = ((_b = (_a = entry.page) == null ? void 0 : _a.content) == null ? void 0 : _b.blocks) ?? [];
|
|
223
328
|
contexts.value = entry.contexts ?? {};
|
|
329
|
+
currentPageId.value = ((_c = entry.page) == null ? void 0 : _c.id) ?? null;
|
|
224
330
|
setAlternates(entry.alternates ?? {});
|
|
225
331
|
return true;
|
|
226
332
|
}
|
|
@@ -257,6 +363,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
257
363
|
const resolved = await resolvePath(slug, urlLocale);
|
|
258
364
|
blocks.value = ((_a = resolved.page.content) == null ? void 0 : _a.blocks) ?? [];
|
|
259
365
|
contexts.value = resolved.contexts ?? {};
|
|
366
|
+
currentPageId.value = resolved.page.id ?? null;
|
|
260
367
|
setAlternates(resolved.alternates ?? {});
|
|
261
368
|
updateDocumentTitle(resolved);
|
|
262
369
|
} catch (e) {
|
|
@@ -276,6 +383,14 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
276
383
|
load();
|
|
277
384
|
}
|
|
278
385
|
watch(() => route.path, load);
|
|
386
|
+
onMounted(() => {
|
|
387
|
+
if (adminConfig && !websiteId.value) {
|
|
388
|
+
getWebsiteId().then((id) => {
|
|
389
|
+
websiteId.value = id;
|
|
390
|
+
}).catch(() => {
|
|
391
|
+
});
|
|
392
|
+
}
|
|
393
|
+
});
|
|
279
394
|
return (_ctx, _cache) => {
|
|
280
395
|
const _component_RouterLink = resolveComponent("RouterLink");
|
|
281
396
|
return openBlock(), createElementBlock("div", null, [
|
|
@@ -293,7 +408,12 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
293
408
|
])) : error.value ? (openBlock(), createElementBlock("div", _hoisted_3, toDisplayString(error.value), 1)) : (openBlock(), createElementBlock(Fragment, { key: 3 }, [
|
|
294
409
|
navigating.value ? (openBlock(), createElementBlock("div", _hoisted_4)) : createCommentVNode("", true),
|
|
295
410
|
createVNode(unref(PageRenderer), { blocks: blocks.value }, null, 8, ["blocks"])
|
|
296
|
-
], 64))
|
|
411
|
+
], 64)),
|
|
412
|
+
unref(adminConfig) ? (openBlock(), createBlock(_sfc_main$2, {
|
|
413
|
+
key: 4,
|
|
414
|
+
"website-id": websiteId.value,
|
|
415
|
+
"page-id": currentPageId.value
|
|
416
|
+
}, null, 8, ["website-id", "page-id"])) : createCommentVNode("", true)
|
|
297
417
|
]);
|
|
298
418
|
};
|
|
299
419
|
}
|
|
@@ -414,11 +534,13 @@ class BloxInstance {
|
|
|
414
534
|
__publicField(this, "_routeRegistered", false);
|
|
415
535
|
__publicField(this, "_config");
|
|
416
536
|
__publicField(this, "_strategy");
|
|
537
|
+
__publicField(this, "_adminEdit");
|
|
417
538
|
this._config = {
|
|
418
539
|
defaultLocale: (options == null ? void 0 : options.defaultLocale) ?? "en",
|
|
419
540
|
supportedLocales: (options == null ? void 0 : options.supportedLocales) ?? []
|
|
420
541
|
};
|
|
421
542
|
this._strategy = createLocaleStrategy(options ?? {});
|
|
543
|
+
this._adminEdit = options == null ? void 0 : options.adminEdit;
|
|
422
544
|
}
|
|
423
545
|
registerModules(modules) {
|
|
424
546
|
const list = Array.isArray(modules) ? modules : Object.values(modules);
|
|
@@ -487,7 +609,7 @@ class BloxInstance {
|
|
|
487
609
|
}
|
|
488
610
|
router.addRoute({
|
|
489
611
|
path: "/_blox_preview",
|
|
490
|
-
component: () => import("./PreviewApp-
|
|
612
|
+
component: () => import("./PreviewApp-T3i0jOkB.js"),
|
|
491
613
|
beforeEnter: () => window.parent !== window ? true : "/"
|
|
492
614
|
});
|
|
493
615
|
router.addRoute({ path: "/:pathMatch(.*)*", component: _sfc_main$1 });
|
|
@@ -509,6 +631,7 @@ class BloxInstance {
|
|
|
509
631
|
if (options == null ? void 0 : options.modules) this.registerModules(options.modules);
|
|
510
632
|
if (options == null ? void 0 : options.components) this.registerComponents(options.components);
|
|
511
633
|
if (options == null ? void 0 : options.router) this.registerRoutes(options.router);
|
|
634
|
+
if (options == null ? void 0 : options.adminEdit) this._adminEdit = options.adminEdit;
|
|
512
635
|
if ((options == null ? void 0 : options.websiteName) || (options == null ? void 0 : options.store)) {
|
|
513
636
|
configureApi(options.websiteName ?? "", options.store ?? "");
|
|
514
637
|
}
|
|
@@ -519,6 +642,7 @@ class BloxInstance {
|
|
|
519
642
|
app.provide(BLOX_REGISTRY_KEY, this._registry);
|
|
520
643
|
app.provide(BLOX_CONFIG_KEY, this._config);
|
|
521
644
|
app.provide(BLOX_LOCALE_STRATEGY_KEY, this._strategy);
|
|
645
|
+
if (this._adminEdit) app.provide(BLOX_ADMIN_CONFIG_KEY, this._adminEdit);
|
|
522
646
|
app.component("RouterLink", _sfc_main);
|
|
523
647
|
}
|
|
524
648
|
}
|
|
@@ -539,16 +663,21 @@ export {
|
|
|
539
663
|
BLOX_REGISTRY_KEY as B,
|
|
540
664
|
GlobalBlockHost as G,
|
|
541
665
|
PageRenderer as P,
|
|
542
|
-
_sfc_main$
|
|
666
|
+
_sfc_main$2 as _,
|
|
543
667
|
BLOX_LOCALE_STRATEGY_KEY as a,
|
|
544
|
-
|
|
668
|
+
BLOX_ADMIN_CONFIG_KEY as b,
|
|
545
669
|
createBlox as c,
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
670
|
+
BLOX_CONFIG_KEY as d,
|
|
671
|
+
BLOX_GLOBAL_RESOLVER_KEY as e,
|
|
672
|
+
BloxInstance as f,
|
|
549
673
|
globalRefOf as g,
|
|
550
|
-
|
|
551
|
-
|
|
674
|
+
_sfc_main$1 as h,
|
|
675
|
+
GLOBAL_REF_KEY as i,
|
|
676
|
+
configureApi as j,
|
|
677
|
+
getWebsiteId as k,
|
|
678
|
+
getWebsiteIdSync as l,
|
|
679
|
+
listItems as m,
|
|
680
|
+
useBloxEdit as n,
|
|
552
681
|
resolvePath as r,
|
|
553
682
|
useLocale as u
|
|
554
683
|
};
|
package/dist/core.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { Router } from 'vue-router';
|
|
|
3
3
|
import { BlockModule } from './defineBlock';
|
|
4
4
|
import { StrategyOptions } from './localeStrategy';
|
|
5
5
|
import { BlockComponent, BlockDefinition } from './schema';
|
|
6
|
+
import { BloxAdminConfig } from './symbols';
|
|
6
7
|
/** Either a full `{ component, schema }` definition or a self-defining component (used `defineBlock()`). */
|
|
7
8
|
export type BloxComponent = BlockDefinition | BlockComponent;
|
|
8
9
|
export interface BloxOptions extends StrategyOptions {
|
|
@@ -27,12 +28,15 @@ export interface BloxOptions extends StrategyOptions {
|
|
|
27
28
|
websiteName?: string;
|
|
28
29
|
/** Datastore store identifier. */
|
|
29
30
|
store?: string;
|
|
31
|
+
/** Opt-in admin "edit this page" button (deep-links to the studio designer). */
|
|
32
|
+
adminEdit?: BloxAdminConfig;
|
|
30
33
|
}
|
|
31
34
|
export declare class BloxInstance {
|
|
32
35
|
private readonly _registry;
|
|
33
36
|
private _routeRegistered;
|
|
34
37
|
private _config;
|
|
35
38
|
private _strategy;
|
|
39
|
+
private _adminEdit?;
|
|
36
40
|
constructor(options?: BloxOptions);
|
|
37
41
|
registerModules(modules: BlockModule[] | Record<string, BlockModule>): this;
|
|
38
42
|
registerComponents(components: Record<string, BloxComponent>): this;
|
package/dist/core.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../src/core.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,GAAG,EAAa,MAAM,KAAK,CAAA;AACzC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AACxC,OAAO,KAAK,EAAa,WAAW,EAAE,MAAM,eAAe,CAAA;AAC3D,OAAO,KAAK,EAAk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,CAAC,EAAE,WAAW;IASjC,eAAe,CAAC,OAAO,EAAE,WAAW,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,GAAG,IAAI;IA8B3E,kBAAkB,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,GAAG,IAAI;IA2BnE,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAyBpC,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,IAAI;CAkC9C;AAMD,wBAAgB,UAAU,CAAC,OAAO,CAAC,EAAE,WAAW,GAAG,YAAY,CAS9D"}
|
package/dist/index.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const core = require("./core-
|
|
4
|
-
const PreviewApp_vue_vue_type_style_index_0_lang = require("./PreviewApp.vue_vue_type_style_index_0_lang-
|
|
3
|
+
const core = require("./core-DmxEiWAR.cjs");
|
|
4
|
+
const PreviewApp_vue_vue_type_style_index_0_lang = require("./PreviewApp.vue_vue_type_style_index_0_lang-CwX30h--.cjs");
|
|
5
5
|
const vue = require("vue");
|
|
6
6
|
const vueRouter = require("vue-router");
|
|
7
7
|
const pinia = require("pinia");
|
|
@@ -133,19 +133,24 @@ function defineBlock(meta) {
|
|
|
133
133
|
}
|
|
134
134
|
return meta;
|
|
135
135
|
}
|
|
136
|
+
exports.AdminEditBar = core._sfc_main;
|
|
137
|
+
exports.BLOX_ADMIN_CONFIG_KEY = core.BLOX_ADMIN_CONFIG_KEY;
|
|
136
138
|
exports.BLOX_CONFIG_KEY = core.BLOX_CONFIG_KEY;
|
|
137
139
|
exports.BLOX_GLOBAL_RESOLVER_KEY = core.BLOX_GLOBAL_RESOLVER_KEY;
|
|
138
140
|
exports.BLOX_LOCALE_STRATEGY_KEY = core.BLOX_LOCALE_STRATEGY_KEY;
|
|
139
141
|
exports.BloxInstance = core.BloxInstance;
|
|
140
|
-
exports.CmsPageView = core._sfc_main;
|
|
142
|
+
exports.CmsPageView = core._sfc_main$1;
|
|
141
143
|
exports.GLOBAL_REF_KEY = core.GLOBAL_REF_KEY;
|
|
142
144
|
exports.GlobalBlockHost = core.GlobalBlockHost;
|
|
143
145
|
exports.PageRenderer = core.PageRenderer;
|
|
144
146
|
exports.configureApi = core.configureApi;
|
|
145
147
|
exports.createBlox = core.createBlox;
|
|
148
|
+
exports.getWebsiteId = core.getWebsiteId;
|
|
149
|
+
exports.getWebsiteIdSync = core.getWebsiteIdSync;
|
|
146
150
|
exports.globalRefOf = core.globalRefOf;
|
|
147
151
|
exports.listItems = core.listItems;
|
|
148
152
|
exports.resolvePath = core.resolvePath;
|
|
153
|
+
exports.useBloxEdit = core.useBloxEdit;
|
|
149
154
|
exports.useLocale = core.useLocale;
|
|
150
155
|
exports.PreviewApp = PreviewApp_vue_vue_type_style_index_0_lang._sfc_main;
|
|
151
156
|
exports.PreviewRenderer = PreviewApp_vue_vue_type_style_index_0_lang.PreviewRenderer;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
export { configureApi, listItems, resolvePath } from './api/index';
|
|
1
|
+
export { configureApi, getWebsiteId, getWebsiteIdSync, listItems, resolvePath } from './api/index';
|
|
2
2
|
export type { ListItemsOptions } from './api/index';
|
|
3
3
|
export type { BindingWarning, Block, BloxPageApiAdapter, CollectionItem, CollectionItemsPage, ContentStatus, PageContent, PageCreateData, PageRead, PageResolveRead, PageUpdateData, WebsiteRead, } from './api/types';
|
|
4
4
|
export { sendToEditor, sendToPreview } from './bridge';
|
|
5
5
|
export type { BlockSchemaInfo, EditorMessage, PreviewMessage } from './bridge';
|
|
6
6
|
export { default as CmsPageView } from './CmsPageView.vue';
|
|
7
|
+
export { default as AdminEditBar } from './admin/AdminEditBar.vue';
|
|
8
|
+
export { useBloxEdit } from './admin/useBloxEdit';
|
|
7
9
|
export { useGlobalBlock } from './composables/useGlobalBlock';
|
|
8
10
|
export type { GlobalBlockLoader, UseGlobalBlockResult } from './composables/useGlobalBlock';
|
|
9
11
|
export { useLocale } from './composables/useLocale';
|
|
@@ -21,8 +23,8 @@ export { default as PageRenderer } from './PageRenderer';
|
|
|
21
23
|
export { default as PreviewApp } from './PreviewApp.vue';
|
|
22
24
|
export { default as PreviewRenderer } from './PreviewRenderer';
|
|
23
25
|
export type { BlockComponent, BlockDefinition, BlockSchema } from './schema';
|
|
24
|
-
export { BLOX_CONFIG_KEY, BLOX_GLOBAL_RESOLVER_KEY, BLOX_LOCALE_STRATEGY_KEY } from './symbols';
|
|
25
|
-
export type { BloxConfig, GlobalBlockResolver } from './symbols';
|
|
26
|
+
export { BLOX_ADMIN_CONFIG_KEY, BLOX_CONFIG_KEY, BLOX_GLOBAL_RESOLVER_KEY, BLOX_LOCALE_STRATEGY_KEY } from './symbols';
|
|
27
|
+
export type { BloxAdminConfig, BloxConfig, GlobalBlockResolver } from './symbols';
|
|
26
28
|
export { GLOBAL_REF_KEY, globalRefOf } from './globalRef';
|
|
27
29
|
export { default as GlobalBlockHost } from './GlobalBlockHost';
|
|
28
30
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,gBAAgB,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAClG,YAAY,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAKnD,YAAY,EACX,cAAc,EACd,KAAK,EAEL,kBAAkB,EAClB,c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O,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,kBAAkB,CAAA;AACxD,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAK9D,YAAY,EAAE,cAAc,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAI5E,OAAO,EAAE,qBAAqB,EAAE,eAAe,EAAE,wBAAwB,EAAE,wBAAwB,EAAE,MAAM,WAAW,CAAA;AAEtH,YAAY,EAAE,eAAe,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAA;AAEjF,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AACzD,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,mBAAmB,CAAA"}
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { a as BLOX_LOCALE_STRATEGY_KEY, u as useLocale, c as createBlox } from "./core-
|
|
2
|
-
import { b, d, e,
|
|
3
|
-
import { _ as _2, P as P2, s, a } from "./PreviewApp.vue_vue_type_style_index_0_lang-
|
|
1
|
+
import { a as BLOX_LOCALE_STRATEGY_KEY, u as useLocale, c as createBlox } from "./core-VQR6lrvO.js";
|
|
2
|
+
import { _, b, d, e, f, h, i, G, P, j, k, l, g, m, r, n } from "./core-VQR6lrvO.js";
|
|
3
|
+
import { _ as _2, P as P2, s, a } from "./PreviewApp.vue_vue_type_style_index_0_lang-C0i8ucHq.js";
|
|
4
4
|
import { ref, onMounted, onUnmounted, inject, computed, createApp, markRaw } from "vue";
|
|
5
5
|
import { useRouter } from "vue-router";
|
|
6
6
|
import { createPinia } from "pinia";
|
|
@@ -133,25 +133,30 @@ function defineBlock(meta) {
|
|
|
133
133
|
return meta;
|
|
134
134
|
}
|
|
135
135
|
export {
|
|
136
|
-
|
|
137
|
-
|
|
136
|
+
_ as AdminEditBar,
|
|
137
|
+
b as BLOX_ADMIN_CONFIG_KEY,
|
|
138
|
+
d as BLOX_CONFIG_KEY,
|
|
139
|
+
e as BLOX_GLOBAL_RESOLVER_KEY,
|
|
138
140
|
BLOX_LOCALE_STRATEGY_KEY,
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
141
|
+
f as BloxInstance,
|
|
142
|
+
h as CmsPageView,
|
|
143
|
+
i as GLOBAL_REF_KEY,
|
|
142
144
|
G as GlobalBlockHost,
|
|
143
145
|
P as PageRenderer,
|
|
144
146
|
_2 as PreviewApp,
|
|
145
147
|
P2 as PreviewRenderer,
|
|
146
|
-
|
|
148
|
+
j as configureApi,
|
|
147
149
|
createBlox,
|
|
148
150
|
createBloxApp,
|
|
149
151
|
defineBlock,
|
|
152
|
+
k as getWebsiteId,
|
|
153
|
+
l as getWebsiteIdSync,
|
|
150
154
|
g as globalRefOf,
|
|
151
|
-
|
|
155
|
+
m as listItems,
|
|
152
156
|
r as resolvePath,
|
|
153
157
|
s as sendToEditor,
|
|
154
158
|
a as sendToPreview,
|
|
159
|
+
n as useBloxEdit,
|
|
155
160
|
useGlobalBlock,
|
|
156
161
|
useLocale,
|
|
157
162
|
useLocaleNav,
|
package/dist/ssg/index.cjs
CHANGED
|
@@ -26,7 +26,7 @@ const prerender = require("../prerender-DH6Arhpk.cjs");
|
|
|
26
26
|
const ssg_client = require("./client.cjs");
|
|
27
27
|
const pinia = require("pinia");
|
|
28
28
|
const vue = require("vue");
|
|
29
|
-
const core = require("../core-
|
|
29
|
+
const core = require("../core-DmxEiWAR.cjs");
|
|
30
30
|
async function renderBloxSsgPage(options) {
|
|
31
31
|
const {
|
|
32
32
|
url,
|
package/dist/ssg/index.mjs
CHANGED
|
@@ -4,7 +4,7 @@ import { BLOX_STATE_WINDOW_KEY, BLOX_COLLECTIONS_WINDOW_KEY, BLOX_WEBSITE_ID_WIN
|
|
|
4
4
|
import { getCollectionCache, getEmbeddedWebsiteId, installBloxStateCache, installCollectionCache } from "./client.mjs";
|
|
5
5
|
import { createPinia } from "pinia";
|
|
6
6
|
import { createSSRApp, markRaw } from "vue";
|
|
7
|
-
import { c as createBlox } from "../core-
|
|
7
|
+
import { c as createBlox } from "../core-VQR6lrvO.js";
|
|
8
8
|
async function renderBloxSsgPage(options) {
|
|
9
9
|
const {
|
|
10
10
|
url,
|
package/dist/style.css
CHANGED
|
@@ -1,4 +1,34 @@
|
|
|
1
1
|
|
|
2
|
+
.blox-admin-bar {
|
|
3
|
+
position: fixed;
|
|
4
|
+
bottom: 20px;
|
|
5
|
+
right: 20px;
|
|
6
|
+
z-index: 2147483000;
|
|
7
|
+
display: flex;
|
|
8
|
+
gap: 8px;
|
|
9
|
+
}
|
|
10
|
+
.blox-admin-btn {
|
|
11
|
+
display: inline-flex;
|
|
12
|
+
align-items: center;
|
|
13
|
+
justify-content: center;
|
|
14
|
+
gap: 8px;
|
|
15
|
+
padding: 10px 16px;
|
|
16
|
+
border: none;
|
|
17
|
+
border-radius: 999px;
|
|
18
|
+
background: #111827;
|
|
19
|
+
color: #fff;
|
|
20
|
+
font: 500 14px/1 system-ui, sans-serif;
|
|
21
|
+
cursor: pointer;
|
|
22
|
+
box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
|
|
23
|
+
}
|
|
24
|
+
.blox-admin-btn:hover {
|
|
25
|
+
background: #1f2937;
|
|
26
|
+
}
|
|
27
|
+
.blox-admin-btn--ghost {
|
|
28
|
+
background: #374151;
|
|
29
|
+
padding: 10px 12px;
|
|
30
|
+
}
|
|
31
|
+
|
|
2
32
|
.blox-nav-progress {
|
|
3
33
|
position: fixed;
|
|
4
34
|
top: 0;
|
package/dist/symbols.d.ts
CHANGED
|
@@ -19,4 +19,20 @@ export declare const BLOX_LOCALE_STRATEGY_KEY: InjectionKey<LocaleStrategy>;
|
|
|
19
19
|
*/
|
|
20
20
|
export type GlobalBlockResolver = (ref: string) => Promise<Record<string, unknown> | null>;
|
|
21
21
|
export declare const BLOX_GLOBAL_RESOLVER_KEY: InjectionKey<GlobalBlockResolver>;
|
|
22
|
+
/**
|
|
23
|
+
* Opt-in "edit this page" feature for marketing sites.
|
|
24
|
+
*
|
|
25
|
+
* No auth is performed here: when opted in (via the `?edit` trigger) a floating
|
|
26
|
+
* button deep-links to the studio page designer
|
|
27
|
+
* (`{studioBaseUrl}/blox/{websiteId}/{pageId}`), which enforces real auth.
|
|
28
|
+
*/
|
|
29
|
+
export interface BloxAdminConfig {
|
|
30
|
+
/** Project id, e.g. 'hamikra'. Used to build `https://{projectId}.bagelstudio.co`. */
|
|
31
|
+
projectId: string;
|
|
32
|
+
/** Override the studio base URL. Defaults to `https://{projectId}.bagelstudio.co`. */
|
|
33
|
+
studioBaseUrl?: string;
|
|
34
|
+
/** Query param that reveals the edit button. Defaults to `edit`. */
|
|
35
|
+
trigger?: string;
|
|
36
|
+
}
|
|
37
|
+
export declare const BLOX_ADMIN_CONFIG_KEY: InjectionKey<BloxAdminConfig>;
|
|
22
38
|
//# sourceMappingURL=symbols.d.ts.map
|
package/dist/symbols.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"symbols.d.ts","sourceRoot":"","sources":["../src/symbols.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,KAAK,CAAA;AACvC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AACtD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAE/C,eAAO,MAAM,iBAAiB,EAAE,YAAY,CAAC,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAClD,CAAA;AAE1B,MAAM,WAAW,UAAU;IAC1B,aAAa,EAAE,MAAM,CAAA;IACrB,gBAAgB,EAAE,MAAM,EAAE,CAAA;CAC1B;AAED,eAAO,MAAM,eAAe,EAAE,YAAY,CAAC,UAAU,CAAyB,CAAA;AAE9E,eAAO,MAAM,wBAAwB,EAAE,YAAY,CAAC,cAAc,CAAkC,CAAA;AAEpG;;;;;;;;GAQG;AACH,MAAM,MAAM,mBAA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