@arpproject/recrate 0.1.24 → 0.1.25
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/crate-builder/editor-state.d.ts +1 -0
- package/dist/recrate.es.js +125 -11
- package/package.json +1 -1
|
@@ -70,6 +70,7 @@ export declare class EditorState {
|
|
|
70
70
|
*/
|
|
71
71
|
update(newState: State): void;
|
|
72
72
|
updateNavigationState(navigationState: NavigationState): void;
|
|
73
|
+
updateNavigationStateForId(id: string, navigationState: NavigationState): void;
|
|
73
74
|
getNavigationState(id?: string): NavigationState | undefined;
|
|
74
75
|
prune(validIds: Set<string>): void;
|
|
75
76
|
/**
|
package/dist/recrate.es.js
CHANGED
|
@@ -67477,6 +67477,31 @@ let EditorState$1 = class EditorState {
|
|
|
67477
67477
|
}
|
|
67478
67478
|
});
|
|
67479
67479
|
}
|
|
67480
|
+
updateNavigationStateForId(id2, navigationState) {
|
|
67481
|
+
var _a2, _b;
|
|
67482
|
+
if (!id2) return;
|
|
67483
|
+
for (let i = this.history.length - 1; i >= 0; i -= 1) {
|
|
67484
|
+
const entry = this.history[i];
|
|
67485
|
+
if ((entry == null ? void 0 : entry.id) !== id2) continue;
|
|
67486
|
+
this.history[i] = {
|
|
67487
|
+
...entry,
|
|
67488
|
+
navigationState: {
|
|
67489
|
+
...entry.navigationState ?? {},
|
|
67490
|
+
...navigationState,
|
|
67491
|
+
tabStates: {
|
|
67492
|
+
...((_a2 = entry.navigationState) == null ? void 0 : _a2.tabStates) ?? {},
|
|
67493
|
+
...navigationState.tabStates ?? {}
|
|
67494
|
+
},
|
|
67495
|
+
uiState: {
|
|
67496
|
+
...((_b = entry.navigationState) == null ? void 0 : _b.uiState) ?? {},
|
|
67497
|
+
...navigationState.uiState ?? {}
|
|
67498
|
+
}
|
|
67499
|
+
}
|
|
67500
|
+
};
|
|
67501
|
+
this.persist();
|
|
67502
|
+
return;
|
|
67503
|
+
}
|
|
67504
|
+
}
|
|
67480
67505
|
getNavigationState(id2) {
|
|
67481
67506
|
var _a2;
|
|
67482
67507
|
if (!id2) {
|
|
@@ -110655,15 +110680,25 @@ const RenderEntity = forwardRef((props, ref) => {
|
|
|
110655
110680
|
const editorPanelRef = useRef(null);
|
|
110656
110681
|
const navigationRestoreReadyRef = useRef(false);
|
|
110657
110682
|
const pendingRestoredTabRef = useRef(null);
|
|
110683
|
+
const restoreInProgressRef = useRef(false);
|
|
110684
|
+
const debugScroll = (...args) => console.log("[recrate-scroll-debug]", ...args);
|
|
110658
110685
|
const getVisibleContextMarkers = (selector, dataAttribute) => {
|
|
110659
110686
|
const source = activeContentRef.current;
|
|
110660
110687
|
if (!source) return [];
|
|
110661
110688
|
return Array.from(source.querySelectorAll(selector)).map((node2) => node2.getAttribute(dataAttribute)).filter((value) => Boolean(value));
|
|
110662
110689
|
};
|
|
110663
110690
|
const captureViewContext = (tabName = activeTab, explicitScrollTop) => {
|
|
110664
|
-
var _a3, _b2, _c2, _d2;
|
|
110691
|
+
var _a3, _b2, _c2, _d2, _e3, _f2, _g2, _h2;
|
|
110665
110692
|
const entityId = contextEntity == null ? void 0 : contextEntity["@id"];
|
|
110666
|
-
if (!entityId
|
|
110693
|
+
if (!entityId) return;
|
|
110694
|
+
if (restoreInProgressRef.current && typeof explicitScrollTop !== "number") {
|
|
110695
|
+
debugScroll("capture.skipped-during-restore", {
|
|
110696
|
+
entityId,
|
|
110697
|
+
tabName,
|
|
110698
|
+
latestId: (_a3 = state.editorState.latest()) == null ? void 0 : _a3.id
|
|
110699
|
+
});
|
|
110700
|
+
return;
|
|
110701
|
+
}
|
|
110667
110702
|
const previous = state.editorState.getNavigationState(entityId) ?? {};
|
|
110668
110703
|
const scrollTop = typeof explicitScrollTop === "number" ? explicitScrollTop : ((_b2 = activeContentRef.current) == null ? void 0 : _b2.scrollTop) ?? ((_d2 = (_c2 = previous.tabStates) == null ? void 0 : _c2[tabName]) == null ? void 0 : _d2.scrollTop) ?? 0;
|
|
110669
110704
|
const nextTabState = {
|
|
@@ -110671,7 +110706,20 @@ const RenderEntity = forwardRef((props, ref) => {
|
|
|
110671
110706
|
expandedSections: getVisibleContextMarkers('[aria-expanded="true"],[data-expanded="true"]', "data-section-id"),
|
|
110672
110707
|
selectedItems: getVisibleContextMarkers('[aria-selected="true"],[data-selected="true"]', "data-item-id")
|
|
110673
110708
|
};
|
|
110674
|
-
|
|
110709
|
+
debugScroll("capture", {
|
|
110710
|
+
entityId,
|
|
110711
|
+
tabName,
|
|
110712
|
+
latestId: (_e3 = state.editorState.latest()) == null ? void 0 : _e3.id,
|
|
110713
|
+
explicitScrollTop,
|
|
110714
|
+
scrollTop,
|
|
110715
|
+
previousScrollTop: ((_g2 = (_f2 = previous.tabStates) == null ? void 0 : _f2[tabName]) == null ? void 0 : _g2.scrollTop) ?? null,
|
|
110716
|
+
viewport: activeContentRef.current ? {
|
|
110717
|
+
clientHeight: activeContentRef.current.clientHeight,
|
|
110718
|
+
scrollHeight: activeContentRef.current.scrollHeight,
|
|
110719
|
+
currentScrollTop: activeContentRef.current.scrollTop
|
|
110720
|
+
} : null
|
|
110721
|
+
});
|
|
110722
|
+
const navigationState = {
|
|
110675
110723
|
activeTab: tabName,
|
|
110676
110724
|
tabStates: { [tabName]: nextTabState },
|
|
110677
110725
|
uiState: {
|
|
@@ -110681,7 +110729,12 @@ const RenderEntity = forwardRef((props, ref) => {
|
|
|
110681
110729
|
iconView,
|
|
110682
110730
|
tabPaneWidth
|
|
110683
110731
|
}
|
|
110684
|
-
}
|
|
110732
|
+
};
|
|
110733
|
+
if (((_h2 = state.editorState.latest()) == null ? void 0 : _h2.id) === entityId) {
|
|
110734
|
+
state.editorState.updateNavigationState(navigationState);
|
|
110735
|
+
} else {
|
|
110736
|
+
state.editorState.updateNavigationStateForId(entityId, navigationState);
|
|
110737
|
+
}
|
|
110685
110738
|
};
|
|
110686
110739
|
const computeScrollViewportHeight = useMemo$1(() => debounce(() => {
|
|
110687
110740
|
var _a3, _b2;
|
|
@@ -110769,6 +110822,15 @@ const RenderEntity = forwardRef((props, ref) => {
|
|
|
110769
110822
|
const tabNames = layout.tabs.map((tab) => tab.name);
|
|
110770
110823
|
const fallbackTab = tabNames.includes("about") ? "about" : tabNames[0] ?? "about";
|
|
110771
110824
|
const restoredTab = layout.renderTabs && (navState == null ? void 0 : navState.activeTab) && tabNames.includes(navState.activeTab) ? navState.activeTab : fallbackTab;
|
|
110825
|
+
debugScroll("init", {
|
|
110826
|
+
entityId: entity2["@id"],
|
|
110827
|
+
latestId: latestEntry == null ? void 0 : latestEntry.id,
|
|
110828
|
+
isCurrentHistoryEntity,
|
|
110829
|
+
renderTabs: layout.renderTabs,
|
|
110830
|
+
tabNames,
|
|
110831
|
+
restoredTab,
|
|
110832
|
+
navState
|
|
110833
|
+
});
|
|
110772
110834
|
pendingRestoredTabRef.current = restoredTab;
|
|
110773
110835
|
setActiveTab(restoredTab);
|
|
110774
110836
|
if (typeof ((_a3 = navState == null ? void 0 : navState.uiState) == null ? void 0 : _a3.showAddPanel) === "boolean") setShowAddPanel(navState.uiState.showAddPanel);
|
|
@@ -110789,6 +110851,11 @@ const RenderEntity = forwardRef((props, ref) => {
|
|
|
110789
110851
|
init2({ entity: entityObj });
|
|
110790
110852
|
};
|
|
110791
110853
|
const handleLoadEntityWithContext = (params) => {
|
|
110854
|
+
debugScroll("navigate", {
|
|
110855
|
+
fromEntityId: contextEntity == null ? void 0 : contextEntity["@id"],
|
|
110856
|
+
activeTab,
|
|
110857
|
+
params
|
|
110858
|
+
});
|
|
110792
110859
|
captureViewContext(activeTab);
|
|
110793
110860
|
onLoadEntity(params);
|
|
110794
110861
|
};
|
|
@@ -110814,19 +110881,58 @@ const RenderEntity = forwardRef((props, ref) => {
|
|
|
110814
110881
|
const viewport = activeContentRef.current;
|
|
110815
110882
|
if (!viewport) return;
|
|
110816
110883
|
const restoreTarget = ((_c2 = (_b2 = (_a3 = state.editorState.getNavigationState(contextEntity["@id"])) == null ? void 0 : _a3.tabStates) == null ? void 0 : _b2[activeTab]) == null ? void 0 : _c2.scrollTop) ?? 0;
|
|
110884
|
+
debugScroll("restore.start", {
|
|
110885
|
+
entityId: contextEntity["@id"],
|
|
110886
|
+
activeTab,
|
|
110887
|
+
restoreTarget,
|
|
110888
|
+
viewport: {
|
|
110889
|
+
clientHeight: viewport.clientHeight,
|
|
110890
|
+
scrollHeight: viewport.scrollHeight,
|
|
110891
|
+
scrollTop: viewport.scrollTop
|
|
110892
|
+
}
|
|
110893
|
+
});
|
|
110817
110894
|
let cancelled = false;
|
|
110818
110895
|
let rafId = 0;
|
|
110819
110896
|
let timerId = 0;
|
|
110820
110897
|
let attempts = 0;
|
|
110821
|
-
const maxAttempts =
|
|
110898
|
+
const maxAttempts = 40;
|
|
110899
|
+
const previousInlineScrollBehavior = viewport.style.scrollBehavior;
|
|
110900
|
+
restoreInProgressRef.current = true;
|
|
110901
|
+
viewport.style.scrollBehavior = "auto";
|
|
110822
110902
|
const attemptRestore = () => {
|
|
110823
110903
|
if (cancelled) return;
|
|
110824
110904
|
attempts += 1;
|
|
110825
110905
|
const maxScrollable = Math.max(0, viewport.scrollHeight - viewport.clientHeight);
|
|
110826
110906
|
const target = Math.min(restoreTarget, maxScrollable);
|
|
110827
|
-
viewport.
|
|
110828
|
-
const
|
|
110907
|
+
viewport.scrollTo({ top: target, behavior: "auto" });
|
|
110908
|
+
const contentReady = restoreTarget <= maxScrollable || restoreTarget === 0;
|
|
110909
|
+
const done = contentReady && Math.abs(viewport.scrollTop - target) <= 1;
|
|
110910
|
+
debugScroll("restore.attempt", {
|
|
110911
|
+
entityId: contextEntity["@id"],
|
|
110912
|
+
activeTab,
|
|
110913
|
+
attempts,
|
|
110914
|
+
restoreTarget,
|
|
110915
|
+
maxScrollable,
|
|
110916
|
+
target,
|
|
110917
|
+
actualScrollTop: viewport.scrollTop,
|
|
110918
|
+
clientHeight: viewport.clientHeight,
|
|
110919
|
+
scrollHeight: viewport.scrollHeight,
|
|
110920
|
+
contentReady,
|
|
110921
|
+
done
|
|
110922
|
+
});
|
|
110829
110923
|
if (done || attempts >= maxAttempts) {
|
|
110924
|
+
restoreInProgressRef.current = false;
|
|
110925
|
+
viewport.style.scrollBehavior = previousInlineScrollBehavior;
|
|
110926
|
+
debugScroll("restore.stop", {
|
|
110927
|
+
entityId: contextEntity["@id"],
|
|
110928
|
+
activeTab,
|
|
110929
|
+
attempts,
|
|
110930
|
+
restoreTarget,
|
|
110931
|
+
finalScrollTop: viewport.scrollTop,
|
|
110932
|
+
maxScrollable,
|
|
110933
|
+
contentReady,
|
|
110934
|
+
done
|
|
110935
|
+
});
|
|
110830
110936
|
return;
|
|
110831
110937
|
}
|
|
110832
110938
|
timerId = window.setTimeout(() => {
|
|
@@ -110838,6 +110944,8 @@ const RenderEntity = forwardRef((props, ref) => {
|
|
|
110838
110944
|
viewport.addEventListener("scroll", handleScroll, { passive: true });
|
|
110839
110945
|
return () => {
|
|
110840
110946
|
cancelled = true;
|
|
110947
|
+
restoreInProgressRef.current = false;
|
|
110948
|
+
viewport.style.scrollBehavior = previousInlineScrollBehavior;
|
|
110841
110949
|
if (navigationRestoreReadyRef.current) {
|
|
110842
110950
|
captureViewContext(activeTab, viewport.scrollTop);
|
|
110843
110951
|
}
|
|
@@ -110850,10 +110958,16 @@ const RenderEntity = forwardRef((props, ref) => {
|
|
|
110850
110958
|
const pendingTab = pendingRestoredTabRef.current;
|
|
110851
110959
|
if (!(contextEntity == null ? void 0 : contextEntity["@id"])) return;
|
|
110852
110960
|
if (pendingTab) {
|
|
110961
|
+
debugScroll("restore.pending-tab", {
|
|
110962
|
+
entityId: contextEntity["@id"],
|
|
110963
|
+
pendingTab,
|
|
110964
|
+
activeTab
|
|
110965
|
+
});
|
|
110853
110966
|
if (activeTab !== pendingTab) {
|
|
110854
110967
|
return;
|
|
110855
110968
|
}
|
|
110856
110969
|
navigationRestoreReadyRef.current = true;
|
|
110970
|
+
restoreInProgressRef.current = true;
|
|
110857
110971
|
pendingRestoredTabRef.current = null;
|
|
110858
110972
|
setScrollRestoreNonce((prev2) => prev2 + 1);
|
|
110859
110973
|
return;
|
|
@@ -111180,7 +111294,7 @@ const RenderEntity = forwardRef((props, ref) => {
|
|
|
111180
111294
|
),
|
|
111181
111295
|
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "absolute right-0 top-0 bottom-0 w-1 bg-slate-300 opacity-0 group-hover:opacity-100" })
|
|
111182
111296
|
] }) }),
|
|
111183
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(Ve.Pane, { children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { ref: activeContentRef, className: "flex-1 overflow-y-auto scroll-smooth min-h-0 p-3", children: [
|
|
111297
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(Ve.Pane, { children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { ref: activeContentRef, className: "describo-editor-scroll flex-1 overflow-y-auto scroll-smooth min-h-0 p-3", children: [
|
|
111184
111298
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-row space-x-2 my-2 p-2", children: [
|
|
111185
111299
|
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
111186
111300
|
"div",
|
|
@@ -111268,7 +111382,7 @@ const RenderEntity = forwardRef((props, ref) => {
|
|
|
111268
111382
|
tabBarStyle: { width: "100%" }
|
|
111269
111383
|
}
|
|
111270
111384
|
) }),
|
|
111271
|
-
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { ref: activeContentRef, className: "h-full overflow-y-auto scroll-smooth min-h-0 p-3", children: [
|
|
111385
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { ref: activeContentRef, className: "describo-editor-scroll h-full overflow-y-auto scroll-smooth min-h-0 p-3", children: [
|
|
111272
111386
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-row space-x-2 my-2 p-2", children: [
|
|
111273
111387
|
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
111274
111388
|
"div",
|
|
@@ -111350,7 +111464,7 @@ const RenderEntity = forwardRef((props, ref) => {
|
|
|
111350
111464
|
),
|
|
111351
111465
|
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "absolute right-0 top-0 bottom-0 w-1 bg-slate-300 opacity-0 group-hover:opacity-100" })
|
|
111352
111466
|
] }) }),
|
|
111353
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(Ve.Pane, { children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { ref: activeContentRef, className: "h-full overflow-y-auto scroll-smooth min-h-0 p-3", children: [
|
|
111467
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(Ve.Pane, { children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { ref: activeContentRef, className: "describo-editor-scroll h-full overflow-y-auto scroll-smooth min-h-0 p-3", children: [
|
|
111354
111468
|
!((_m = state.configuration) == null ? void 0 : _m.readonly) && ((_n = tabs.find((t22) => t22.name === activeTab)) == null ? void 0 : _n.missingRequiredData) && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-red-600 float-right mb-2", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
111355
111469
|
"button",
|
|
111356
111470
|
{
|
|
@@ -119780,7 +119894,7 @@ var EmotionCacheContext = /* @__PURE__ */ React.createContext(
|
|
|
119780
119894
|
}) : null
|
|
119781
119895
|
);
|
|
119782
119896
|
var CacheProvider = EmotionCacheContext.Provider;
|
|
119783
|
-
const version = "0.1.
|
|
119897
|
+
const version = "0.1.25";
|
|
119784
119898
|
const pkg = {
|
|
119785
119899
|
version
|
|
119786
119900
|
};
|