@arbidocs/blocks 0.3.114 → 0.3.115
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/index.cjs +32 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +14 -1
- package/dist/index.d.ts +14 -1
- package/dist/index.js +32 -3
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -2376,7 +2376,8 @@ function StudioEditor({
|
|
|
2376
2376
|
live,
|
|
2377
2377
|
initialSlug,
|
|
2378
2378
|
testIdPrefix = "studio",
|
|
2379
|
-
publishAsset
|
|
2379
|
+
publishAsset,
|
|
2380
|
+
resetSeam = false
|
|
2380
2381
|
}) {
|
|
2381
2382
|
const arbi = react.useArbi();
|
|
2382
2383
|
const materialize = react$1.useMemo(
|
|
@@ -2407,6 +2408,14 @@ function StudioEditor({
|
|
|
2407
2408
|
cancelled = true;
|
|
2408
2409
|
};
|
|
2409
2410
|
}, [slug, live]);
|
|
2411
|
+
react$1.useEffect(() => {
|
|
2412
|
+
if (!resetSeam) return;
|
|
2413
|
+
const w = window;
|
|
2414
|
+
w.__studioResetSlug = (s) => persistence.deletePage(arbi, live, s);
|
|
2415
|
+
return () => {
|
|
2416
|
+
delete w.__studioResetSlug;
|
|
2417
|
+
};
|
|
2418
|
+
}, [resetSeam, arbi, live, persistence]);
|
|
2410
2419
|
const persist4 = react$1.useCallback(
|
|
2411
2420
|
async (toSave) => {
|
|
2412
2421
|
setSaving(true);
|
|
@@ -2692,6 +2701,26 @@ function createStudioPersistence(cfg) {
|
|
|
2692
2701
|
function loadPublished(arbi, live, slug) {
|
|
2693
2702
|
return readPage(arbi, live, publishedKey(slug), publishedFile(slug));
|
|
2694
2703
|
}
|
|
2704
|
+
async function deletePage(arbi, live, slug) {
|
|
2705
|
+
try {
|
|
2706
|
+
localStorage.removeItem(pageKey(slug));
|
|
2707
|
+
localStorage.removeItem(publishedKey(slug));
|
|
2708
|
+
} catch {
|
|
2709
|
+
}
|
|
2710
|
+
if (!canUseArbi(arbi, live)) return;
|
|
2711
|
+
try {
|
|
2712
|
+
await arbi.selectWorkspace(WORKSPACE_ID);
|
|
2713
|
+
const docs = await arbi.documents.list();
|
|
2714
|
+
const names = [pageFile(slug), publishedFile(slug)];
|
|
2715
|
+
const ids = docs.filter(
|
|
2716
|
+
(d) => (d.folder ?? "").includes(FOLDER) && names.some((n) => (d.file_name ?? "").endsWith(n))
|
|
2717
|
+
).map((d) => d.external_id);
|
|
2718
|
+
if (ids.length) await arbi.documents.delete(ids);
|
|
2719
|
+
console.info(`[studio] deleted ${ids.length} doc(s) for "${slug}" from ARBI`);
|
|
2720
|
+
} catch (e) {
|
|
2721
|
+
console.warn(`[studio] ARBI delete failed for "${slug}"`, e);
|
|
2722
|
+
}
|
|
2723
|
+
}
|
|
2695
2724
|
async function saveTheme(arbi, live, theme) {
|
|
2696
2725
|
try {
|
|
2697
2726
|
localStorage.setItem(THEME_KEY, JSON.stringify(theme));
|
|
@@ -2728,7 +2757,7 @@ function createStudioPersistence(cfg) {
|
|
|
2728
2757
|
return null;
|
|
2729
2758
|
}
|
|
2730
2759
|
}
|
|
2731
|
-
return { savePage, loadPage, savePublished, loadPublished, saveTheme, loadTheme };
|
|
2760
|
+
return { savePage, loadPage, savePublished, loadPublished, deletePage, saveTheme, loadTheme };
|
|
2732
2761
|
}
|
|
2733
2762
|
function AiTextField({
|
|
2734
2763
|
value,
|
|
@@ -2968,7 +2997,7 @@ function ImageFieldControl({
|
|
|
2968
2997
|
{
|
|
2969
2998
|
src: thumb,
|
|
2970
2999
|
alt: d.file_name ?? "",
|
|
2971
|
-
className: "aspect-square w-full object-
|
|
3000
|
+
className: "aspect-square w-full bg-muted object-contain"
|
|
2972
3001
|
}
|
|
2973
3002
|
) : /* @__PURE__ */ jsxRuntime.jsx("span", { className: "flex aspect-square w-full items-center justify-center bg-muted text-muted-foreground", children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ImagePlus, { className: "size-4" }) })
|
|
2974
3003
|
},
|