@arpproject/recrate 0.1.22 → 0.1.23
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 +17 -3
- package/dist/recrate.es.js +277 -32
- package/package.json +1 -1
|
@@ -1,5 +1,17 @@
|
|
|
1
|
+
interface NavigationTabState {
|
|
2
|
+
scrollTop?: number;
|
|
3
|
+
expandedSections?: string[];
|
|
4
|
+
selectedItems?: string[];
|
|
5
|
+
}
|
|
6
|
+
interface NavigationState {
|
|
7
|
+
activeTab?: string;
|
|
8
|
+
tabStates?: Record<string, NavigationTabState>;
|
|
9
|
+
uiState?: Record<string, any>;
|
|
10
|
+
}
|
|
1
11
|
interface State {
|
|
2
12
|
id: string;
|
|
13
|
+
tab?: string;
|
|
14
|
+
navigationState?: NavigationState;
|
|
3
15
|
[key: string]: any;
|
|
4
16
|
}
|
|
5
17
|
/**
|
|
@@ -14,9 +26,8 @@ export declare class EditorState {
|
|
|
14
26
|
history: State[];
|
|
15
27
|
current: number;
|
|
16
28
|
constructor();
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
*/
|
|
29
|
+
private hydrate;
|
|
30
|
+
private persist;
|
|
20
31
|
reset(): void;
|
|
21
32
|
/**
|
|
22
33
|
* Push a new state onto the history stack
|
|
@@ -47,6 +58,9 @@ export declare class EditorState {
|
|
|
47
58
|
* @param {Object} an object to be merged into the current entry
|
|
48
59
|
*/
|
|
49
60
|
update(newState: State): void;
|
|
61
|
+
updateNavigationState(navigationState: NavigationState): void;
|
|
62
|
+
getNavigationState(id?: string): NavigationState | undefined;
|
|
63
|
+
prune(validIds: Set<string>): void;
|
|
50
64
|
/**
|
|
51
65
|
* Delete a property from the current entry
|
|
52
66
|
*
|
package/dist/recrate.es.js
CHANGED
|
@@ -67349,17 +67349,39 @@ function useStore(api2, selector = identity) {
|
|
|
67349
67349
|
React__default.useDebugValue(slice2);
|
|
67350
67350
|
return slice2;
|
|
67351
67351
|
}
|
|
67352
|
+
const STORAGE_KEY = "recrate.editor-state.v1";
|
|
67352
67353
|
let EditorState$1 = class EditorState {
|
|
67353
67354
|
constructor() {
|
|
67354
|
-
|
|
67355
|
-
this.
|
|
67355
|
+
const hydrated = this.hydrate();
|
|
67356
|
+
this.history = (hydrated == null ? void 0 : hydrated.history) ?? [];
|
|
67357
|
+
this.current = (hydrated == null ? void 0 : hydrated.current) ?? 0;
|
|
67358
|
+
}
|
|
67359
|
+
hydrate() {
|
|
67360
|
+
if (typeof window === "undefined") return null;
|
|
67361
|
+
try {
|
|
67362
|
+
const raw = window.sessionStorage.getItem(STORAGE_KEY);
|
|
67363
|
+
if (!raw) return null;
|
|
67364
|
+
const data = JSON.parse(raw);
|
|
67365
|
+
if (!Array.isArray(data == null ? void 0 : data.history)) return null;
|
|
67366
|
+
return {
|
|
67367
|
+
history: data.history,
|
|
67368
|
+
current: Math.max(0, Math.min(Number(data.current) || 0, data.history.length - 1))
|
|
67369
|
+
};
|
|
67370
|
+
} catch {
|
|
67371
|
+
return null;
|
|
67372
|
+
}
|
|
67373
|
+
}
|
|
67374
|
+
persist() {
|
|
67375
|
+
if (typeof window === "undefined") return;
|
|
67376
|
+
try {
|
|
67377
|
+
window.sessionStorage.setItem(STORAGE_KEY, JSON.stringify({ history: this.history, current: this.current }));
|
|
67378
|
+
} catch {
|
|
67379
|
+
}
|
|
67356
67380
|
}
|
|
67357
|
-
/**
|
|
67358
|
-
* Reset the internal state
|
|
67359
|
-
*/
|
|
67360
67381
|
reset() {
|
|
67361
67382
|
this.history = [];
|
|
67362
67383
|
this.current = 0;
|
|
67384
|
+
this.persist();
|
|
67363
67385
|
}
|
|
67364
67386
|
/**
|
|
67365
67387
|
* Push a new state onto the history stack
|
|
@@ -67378,6 +67400,7 @@ let EditorState$1 = class EditorState {
|
|
|
67378
67400
|
}
|
|
67379
67401
|
this.history = [...this.history, { id: id2 }];
|
|
67380
67402
|
this.current = this.history.length - 1;
|
|
67403
|
+
this.persist();
|
|
67381
67404
|
}
|
|
67382
67405
|
/**
|
|
67383
67406
|
* Go back through the state
|
|
@@ -67385,6 +67408,7 @@ let EditorState$1 = class EditorState {
|
|
|
67385
67408
|
back() {
|
|
67386
67409
|
if (this.current === 0) return;
|
|
67387
67410
|
this.current -= 1;
|
|
67411
|
+
this.persist();
|
|
67388
67412
|
}
|
|
67389
67413
|
/**
|
|
67390
67414
|
* Go forward through the state
|
|
@@ -67392,6 +67416,7 @@ let EditorState$1 = class EditorState {
|
|
|
67392
67416
|
forward() {
|
|
67393
67417
|
if (this.current === this.history.length - 1) return;
|
|
67394
67418
|
this.current += 1;
|
|
67419
|
+
this.persist();
|
|
67395
67420
|
}
|
|
67396
67421
|
/**
|
|
67397
67422
|
* Return the current entry
|
|
@@ -67412,6 +67437,44 @@ let EditorState$1 = class EditorState {
|
|
|
67412
67437
|
*/
|
|
67413
67438
|
update(newState) {
|
|
67414
67439
|
this.history[this.current] = { ...this.history[this.current], ...newState };
|
|
67440
|
+
this.persist();
|
|
67441
|
+
}
|
|
67442
|
+
updateNavigationState(navigationState) {
|
|
67443
|
+
var _a2, _b;
|
|
67444
|
+
const latest = this.latest();
|
|
67445
|
+
if (!latest) return;
|
|
67446
|
+
this.update({
|
|
67447
|
+
...latest,
|
|
67448
|
+
navigationState: {
|
|
67449
|
+
...latest.navigationState ?? {},
|
|
67450
|
+
...navigationState,
|
|
67451
|
+
tabStates: {
|
|
67452
|
+
...((_a2 = latest.navigationState) == null ? void 0 : _a2.tabStates) ?? {},
|
|
67453
|
+
...navigationState.tabStates ?? {}
|
|
67454
|
+
},
|
|
67455
|
+
uiState: {
|
|
67456
|
+
...((_b = latest.navigationState) == null ? void 0 : _b.uiState) ?? {},
|
|
67457
|
+
...navigationState.uiState ?? {}
|
|
67458
|
+
}
|
|
67459
|
+
}
|
|
67460
|
+
});
|
|
67461
|
+
}
|
|
67462
|
+
getNavigationState(id2) {
|
|
67463
|
+
var _a2;
|
|
67464
|
+
if (!id2) {
|
|
67465
|
+
return (_a2 = this.latest()) == null ? void 0 : _a2.navigationState;
|
|
67466
|
+
}
|
|
67467
|
+
for (let i = this.history.length - 1; i >= 0; i -= 1) {
|
|
67468
|
+
const entry = this.history[i];
|
|
67469
|
+
if ((entry == null ? void 0 : entry.id) !== id2) continue;
|
|
67470
|
+
if (entry.navigationState) return entry.navigationState;
|
|
67471
|
+
}
|
|
67472
|
+
return void 0;
|
|
67473
|
+
}
|
|
67474
|
+
prune(validIds) {
|
|
67475
|
+
this.history = this.history.filter((entry) => validIds.has(entry.id));
|
|
67476
|
+
this.current = this.history.length === 0 ? 0 : Math.min(this.current, this.history.length - 1);
|
|
67477
|
+
this.persist();
|
|
67415
67478
|
}
|
|
67416
67479
|
/**
|
|
67417
67480
|
* Delete a property from the current entry
|
|
@@ -67421,6 +67484,7 @@ let EditorState$1 = class EditorState {
|
|
|
67421
67484
|
*/
|
|
67422
67485
|
deleteFromState({ property }) {
|
|
67423
67486
|
delete this.history[this.current][property];
|
|
67487
|
+
this.persist();
|
|
67424
67488
|
}
|
|
67425
67489
|
/**
|
|
67426
67490
|
* Replace an id in the state
|
|
@@ -67435,13 +67499,8 @@ let EditorState$1 = class EditorState {
|
|
|
67435
67499
|
replaceId({ id: id2, newId }) {
|
|
67436
67500
|
this.history = this.history.slice(0, -1);
|
|
67437
67501
|
this.current = this.history.length - 1;
|
|
67438
|
-
this.history = this.history.map((e3
|
|
67439
|
-
|
|
67440
|
-
return { ...e3, id: newId };
|
|
67441
|
-
} else {
|
|
67442
|
-
return e3;
|
|
67443
|
-
}
|
|
67444
|
-
});
|
|
67502
|
+
this.history = this.history.map((e3) => e3.id === id2 ? { ...e3, id: newId } : e3);
|
|
67503
|
+
this.persist();
|
|
67445
67504
|
}
|
|
67446
67505
|
};
|
|
67447
67506
|
const createStateStore = () => createStore((set2) => ({
|
|
@@ -106637,6 +106696,7 @@ const RenderControls = ({
|
|
|
106637
106696
|
var _a2, _b, _c, _d, _e2, _f;
|
|
106638
106697
|
const { t: t2 } = useTranslation();
|
|
106639
106698
|
const state = useStateStore();
|
|
106699
|
+
const debugNav = (...args) => console.log("[recrate-nav-debug][controls]", ...args);
|
|
106640
106700
|
const [dialogs, setDialogs] = useState({
|
|
106641
106701
|
previewCrate: false,
|
|
106642
106702
|
editContext: false,
|
|
@@ -106666,17 +106726,25 @@ const RenderControls = ({
|
|
|
106666
106726
|
const canGoForward = state.editorState.canForward();
|
|
106667
106727
|
const handleBack = () => {
|
|
106668
106728
|
if (!canGoBack) return;
|
|
106729
|
+
const before = state.editorState.latest();
|
|
106730
|
+
debugNav("back.click", { currentEntity: entity["@id"], before });
|
|
106669
106731
|
onBack();
|
|
106670
106732
|
const latest = state.editorState.latest();
|
|
106733
|
+
debugNav("back.afterPointerMove", { latest });
|
|
106671
106734
|
if (latest == null ? void 0 : latest.id) {
|
|
106735
|
+
debugNav("back.loadEntity", { id: latest.id, updateState: false });
|
|
106672
106736
|
onLoadEntity({ id: latest.id, updateState: false });
|
|
106673
106737
|
}
|
|
106674
106738
|
};
|
|
106675
106739
|
const handleForward = () => {
|
|
106676
106740
|
if (!canGoForward) return;
|
|
106741
|
+
const before = state.editorState.latest();
|
|
106742
|
+
debugNav("forward.click", { currentEntity: entity["@id"], before });
|
|
106677
106743
|
onForward();
|
|
106678
106744
|
const latest = state.editorState.latest();
|
|
106745
|
+
debugNav("forward.afterPointerMove", { latest });
|
|
106679
106746
|
if (latest == null ? void 0 : latest.id) {
|
|
106747
|
+
debugNav("forward.loadEntity", { id: latest.id, updateState: false });
|
|
106680
106748
|
onLoadEntity({ id: latest.id, updateState: false });
|
|
106681
106749
|
}
|
|
106682
106750
|
};
|
|
@@ -110558,9 +110626,47 @@ const RenderEntity = forwardRef((props, ref) => {
|
|
|
110558
110626
|
localStorage.setItem("recrate.verticalTabWidth", String(clamped));
|
|
110559
110627
|
}, 200), [iconView]);
|
|
110560
110628
|
const [scrollViewportHeight, setScrollViewportHeight] = useState(0);
|
|
110629
|
+
const [scrollRestoreNonce, setScrollRestoreNonce] = useState(0);
|
|
110561
110630
|
const contentContainerRef = useRef(null);
|
|
110562
110631
|
const activeContentRef = useRef(null);
|
|
110563
110632
|
const editorPanelRef = useRef(null);
|
|
110633
|
+
const navigationRestoreReadyRef = useRef(false);
|
|
110634
|
+
const pendingRestoredTabRef = useRef(null);
|
|
110635
|
+
const debugNav = (...args) => console.log("[recrate-nav-debug][shell2]", ...args);
|
|
110636
|
+
const getVisibleContextMarkers = (selector, dataAttribute) => {
|
|
110637
|
+
const source = activeContentRef.current;
|
|
110638
|
+
if (!source) return [];
|
|
110639
|
+
return Array.from(source.querySelectorAll(selector)).map((node2) => node2.getAttribute(dataAttribute)).filter((value) => Boolean(value));
|
|
110640
|
+
};
|
|
110641
|
+
const captureViewContext = (tabName = activeTab, explicitScrollTop) => {
|
|
110642
|
+
var _a3, _b2, _c2, _d2, _e3;
|
|
110643
|
+
const entityId = contextEntity == null ? void 0 : contextEntity["@id"];
|
|
110644
|
+
if (!entityId || ((_a3 = state.editorState.latest()) == null ? void 0 : _a3.id) !== entityId) return;
|
|
110645
|
+
const previous = state.editorState.getNavigationState(entityId) ?? {};
|
|
110646
|
+
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;
|
|
110647
|
+
const nextTabState = {
|
|
110648
|
+
scrollTop,
|
|
110649
|
+
expandedSections: getVisibleContextMarkers('[aria-expanded="true"],[data-expanded="true"]', "data-section-id"),
|
|
110650
|
+
selectedItems: getVisibleContextMarkers('[aria-selected="true"],[data-selected="true"]', "data-item-id")
|
|
110651
|
+
};
|
|
110652
|
+
debugNav("captureViewContext", {
|
|
110653
|
+
entityId,
|
|
110654
|
+
tabName,
|
|
110655
|
+
scrollTop,
|
|
110656
|
+
latestId: (_e3 = state.editorState.latest()) == null ? void 0 : _e3.id
|
|
110657
|
+
});
|
|
110658
|
+
state.editorState.updateNavigationState({
|
|
110659
|
+
activeTab: tabName,
|
|
110660
|
+
tabStates: { [tabName]: nextTabState },
|
|
110661
|
+
uiState: {
|
|
110662
|
+
showAddPanel,
|
|
110663
|
+
reverseSidebarVisible,
|
|
110664
|
+
highlightRequiredProperties,
|
|
110665
|
+
iconView,
|
|
110666
|
+
tabPaneWidth
|
|
110667
|
+
}
|
|
110668
|
+
});
|
|
110669
|
+
};
|
|
110564
110670
|
const computeScrollViewportHeight = useMemo$1(() => debounce(() => {
|
|
110565
110671
|
var _a3, _b2;
|
|
110566
110672
|
const containerRect = (_a3 = contentContainerRef.current) == null ? void 0 : _a3.getBoundingClientRect();
|
|
@@ -110615,6 +110721,16 @@ const RenderEntity = forwardRef((props, ref) => {
|
|
|
110615
110721
|
}
|
|
110616
110722
|
}));
|
|
110617
110723
|
useEffect(() => {
|
|
110724
|
+
navigationRestoreReadyRef.current = false;
|
|
110725
|
+
debugNav("entity.effect.start", {
|
|
110726
|
+
incomingEntityId: entity == null ? void 0 : entity["@id"],
|
|
110727
|
+
previousContextEntityId: contextEntity == null ? void 0 : contextEntity["@id"],
|
|
110728
|
+
activeTab,
|
|
110729
|
+
latest: state.editorState.latest()
|
|
110730
|
+
});
|
|
110731
|
+
if ((contextEntity == null ? void 0 : contextEntity["@id"]) && (entity == null ? void 0 : entity["@id"]) && contextEntity["@id"] !== entity["@id"]) {
|
|
110732
|
+
captureViewContext(activeTab);
|
|
110733
|
+
}
|
|
110618
110734
|
setExtraProperties([]);
|
|
110619
110735
|
init2({ entity });
|
|
110620
110736
|
}, [entity]);
|
|
@@ -110625,10 +110741,10 @@ const RenderEntity = forwardRef((props, ref) => {
|
|
|
110625
110741
|
}
|
|
110626
110742
|
}, [profileManager == null ? void 0 : profileManager.$key]);
|
|
110627
110743
|
const init2 = ({ entity: entity2 }) => {
|
|
110744
|
+
var _a3, _b2, _c2, _d2, _e3;
|
|
110628
110745
|
if (!entity2["@id"]) return;
|
|
110629
|
-
|
|
110630
|
-
|
|
110631
|
-
}
|
|
110746
|
+
const latestEntry = state.editorState.latest();
|
|
110747
|
+
const isCurrentHistoryEntity = (latestEntry == null ? void 0 : latestEntry.id) === entity2["@id"];
|
|
110632
110748
|
const layout = applyLayout({
|
|
110633
110749
|
configuration: state.configuration,
|
|
110634
110750
|
profileManager,
|
|
@@ -110639,24 +110755,153 @@ const RenderEntity = forwardRef((props, ref) => {
|
|
|
110639
110755
|
setRenderTabs(layout.renderTabs);
|
|
110640
110756
|
setMissingRequiredData(layout.missingRequiredData);
|
|
110641
110757
|
setTabs(layout.tabs);
|
|
110642
|
-
|
|
110643
|
-
|
|
110644
|
-
|
|
110645
|
-
|
|
110758
|
+
const navState = isCurrentHistoryEntity ? latestEntry == null ? void 0 : latestEntry.navigationState : state.editorState.getNavigationState(entity2["@id"]);
|
|
110759
|
+
const tabNames = layout.tabs.map((tab) => tab.name);
|
|
110760
|
+
const fallbackTab = tabNames.includes("about") ? "about" : tabNames[0] ?? "about";
|
|
110761
|
+
const restoredTab = layout.renderTabs && (navState == null ? void 0 : navState.activeTab) && tabNames.includes(navState.activeTab) ? navState.activeTab : fallbackTab;
|
|
110762
|
+
debugNav("init.restoreDecision", {
|
|
110763
|
+
entityId: entity2["@id"],
|
|
110764
|
+
latestEntry,
|
|
110765
|
+
isCurrentHistoryEntity,
|
|
110766
|
+
navActiveTab: navState == null ? void 0 : navState.activeTab,
|
|
110767
|
+
tabNames,
|
|
110768
|
+
restoredTab,
|
|
110769
|
+
fallbackTab
|
|
110770
|
+
});
|
|
110771
|
+
pendingRestoredTabRef.current = restoredTab;
|
|
110772
|
+
setActiveTab(restoredTab);
|
|
110773
|
+
if (typeof ((_a3 = navState == null ? void 0 : navState.uiState) == null ? void 0 : _a3.showAddPanel) === "boolean") setShowAddPanel(navState.uiState.showAddPanel);
|
|
110774
|
+
if (typeof ((_b2 = navState == null ? void 0 : navState.uiState) == null ? void 0 : _b2.reverseSidebarVisible) === "boolean") setReverseSidebarVisible(navState.uiState.reverseSidebarVisible);
|
|
110775
|
+
if (typeof ((_c2 = navState == null ? void 0 : navState.uiState) == null ? void 0 : _c2.highlightRequiredProperties) === "boolean") setHighlightRequiredProperties(navState.uiState.highlightRequiredProperties);
|
|
110776
|
+
if (typeof ((_d2 = navState == null ? void 0 : navState.uiState) == null ? void 0 : _d2.iconView) === "boolean") setIconView(navState.uiState.iconView);
|
|
110777
|
+
if (typeof ((_e3 = navState == null ? void 0 : navState.uiState) == null ? void 0 : _e3.tabPaneWidth) === "number") setTabPaneWidth(navState.uiState.tabPaneWidth);
|
|
110778
|
+
if (isCurrentHistoryEntity) {
|
|
110779
|
+
if (layout.renderTabs) {
|
|
110780
|
+
state.editorState.update({ id: entity2["@id"], tab: restoredTab });
|
|
110781
|
+
} else {
|
|
110782
|
+
state.editorState.deleteFromState({ property: "tab" });
|
|
110783
|
+
}
|
|
110646
110784
|
}
|
|
110785
|
+
debugNav("init.deferReadyUntilTabCommit", {
|
|
110786
|
+
entityId: entity2["@id"],
|
|
110787
|
+
restoredTab
|
|
110788
|
+
});
|
|
110647
110789
|
};
|
|
110648
110790
|
const refresh = () => {
|
|
110649
110791
|
const entityObj = crateManager.getEntity({ id: entity["@id"], link: false, materialise: false });
|
|
110650
110792
|
init2({ entity: entityObj });
|
|
110651
110793
|
};
|
|
110794
|
+
const handleLoadEntityWithContext = (params) => {
|
|
110795
|
+
debugNav("handleLoadEntityWithContext", {
|
|
110796
|
+
fromEntityId: contextEntity == null ? void 0 : contextEntity["@id"],
|
|
110797
|
+
activeTab,
|
|
110798
|
+
params,
|
|
110799
|
+
latest: state.editorState.latest()
|
|
110800
|
+
});
|
|
110801
|
+
captureViewContext(activeTab);
|
|
110802
|
+
onLoadEntity(params);
|
|
110803
|
+
};
|
|
110652
110804
|
const saveTabToState = (tabName) => {
|
|
110653
|
-
|
|
110805
|
+
var _a3;
|
|
110806
|
+
const activeEntityId = contextEntity == null ? void 0 : contextEntity["@id"];
|
|
110807
|
+
const latestId = (_a3 = state.editorState.latest()) == null ? void 0 : _a3.id;
|
|
110808
|
+
if (!activeEntityId || latestId !== activeEntityId) {
|
|
110809
|
+
debugNav("saveTabToState.skip", { tabName, activeEntityId, latestId });
|
|
110810
|
+
return;
|
|
110811
|
+
}
|
|
110812
|
+
debugNav("saveTabToState.apply", { tabName, activeEntityId });
|
|
110813
|
+
state.editorState.update({ id: activeEntityId, tab: tabName });
|
|
110814
|
+
state.editorState.updateNavigationState({ activeTab: tabName });
|
|
110654
110815
|
};
|
|
110655
110816
|
useEffect(() => {
|
|
110656
110817
|
if (entity == null ? void 0 : entity["@id"]) {
|
|
110657
110818
|
refresh();
|
|
110658
110819
|
}
|
|
110659
110820
|
}, [extraProperties]);
|
|
110821
|
+
useEffect(() => {
|
|
110822
|
+
var _a3, _b2, _c2;
|
|
110823
|
+
if (!navigationRestoreReadyRef.current) return;
|
|
110824
|
+
if (!(contextEntity == null ? void 0 : contextEntity["@id"])) return;
|
|
110825
|
+
const viewport = activeContentRef.current;
|
|
110826
|
+
if (!viewport) return;
|
|
110827
|
+
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;
|
|
110828
|
+
debugNav("scroll.restore.start", {
|
|
110829
|
+
entityId: contextEntity["@id"],
|
|
110830
|
+
activeTab,
|
|
110831
|
+
restoreTarget,
|
|
110832
|
+
latest: state.editorState.latest()
|
|
110833
|
+
});
|
|
110834
|
+
let cancelled = false;
|
|
110835
|
+
let rafId = 0;
|
|
110836
|
+
let timerId = 0;
|
|
110837
|
+
let attempts = 0;
|
|
110838
|
+
const maxAttempts = 12;
|
|
110839
|
+
const attemptRestore = () => {
|
|
110840
|
+
if (cancelled) return;
|
|
110841
|
+
attempts += 1;
|
|
110842
|
+
const maxScrollable = Math.max(0, viewport.scrollHeight - viewport.clientHeight);
|
|
110843
|
+
const target = Math.min(restoreTarget, maxScrollable);
|
|
110844
|
+
viewport.scrollTop = target;
|
|
110845
|
+
debugNav("scroll.restore.attempt", {
|
|
110846
|
+
entityId: contextEntity["@id"],
|
|
110847
|
+
activeTab,
|
|
110848
|
+
attempt: attempts,
|
|
110849
|
+
restoreTarget,
|
|
110850
|
+
maxScrollable,
|
|
110851
|
+
appliedScrollTop: viewport.scrollTop
|
|
110852
|
+
});
|
|
110853
|
+
const done = Math.abs(viewport.scrollTop - target) <= 1;
|
|
110854
|
+
if (done || attempts >= maxAttempts) {
|
|
110855
|
+
debugNav("scroll.restore.applied", {
|
|
110856
|
+
entityId: contextEntity["@id"],
|
|
110857
|
+
activeTab,
|
|
110858
|
+
attempts,
|
|
110859
|
+
restoreTarget,
|
|
110860
|
+
appliedScrollTop: viewport.scrollTop
|
|
110861
|
+
});
|
|
110862
|
+
return;
|
|
110863
|
+
}
|
|
110864
|
+
timerId = window.setTimeout(() => {
|
|
110865
|
+
rafId = window.requestAnimationFrame(attemptRestore);
|
|
110866
|
+
}, 35);
|
|
110867
|
+
};
|
|
110868
|
+
rafId = window.requestAnimationFrame(attemptRestore);
|
|
110869
|
+
const handleScroll = () => captureViewContext(activeTab, viewport.scrollTop);
|
|
110870
|
+
viewport.addEventListener("scroll", handleScroll, { passive: true });
|
|
110871
|
+
return () => {
|
|
110872
|
+
cancelled = true;
|
|
110873
|
+
if (navigationRestoreReadyRef.current) {
|
|
110874
|
+
captureViewContext(activeTab, viewport.scrollTop);
|
|
110875
|
+
}
|
|
110876
|
+
viewport.removeEventListener("scroll", handleScroll);
|
|
110877
|
+
window.cancelAnimationFrame(rafId);
|
|
110878
|
+
window.clearTimeout(timerId);
|
|
110879
|
+
};
|
|
110880
|
+
}, [activeTab, contextEntity == null ? void 0 : contextEntity["@id"], renderTabs, tabs.length, scrollRestoreNonce]);
|
|
110881
|
+
useEffect(() => {
|
|
110882
|
+
const pendingTab = pendingRestoredTabRef.current;
|
|
110883
|
+
if (!(contextEntity == null ? void 0 : contextEntity["@id"])) return;
|
|
110884
|
+
if (pendingTab) {
|
|
110885
|
+
if (activeTab !== pendingTab) {
|
|
110886
|
+
debugNav("restore.waitingForCommittedTab", {
|
|
110887
|
+
entityId: contextEntity["@id"],
|
|
110888
|
+
pendingTab,
|
|
110889
|
+
activeTab
|
|
110890
|
+
});
|
|
110891
|
+
return;
|
|
110892
|
+
}
|
|
110893
|
+
navigationRestoreReadyRef.current = true;
|
|
110894
|
+
pendingRestoredTabRef.current = null;
|
|
110895
|
+
setScrollRestoreNonce((prev2) => prev2 + 1);
|
|
110896
|
+
debugNav("restore.tabCommitted", {
|
|
110897
|
+
entityId: contextEntity["@id"],
|
|
110898
|
+
activeTab
|
|
110899
|
+
});
|
|
110900
|
+
return;
|
|
110901
|
+
}
|
|
110902
|
+
if (!navigationRestoreReadyRef.current) return;
|
|
110903
|
+
captureViewContext(activeTab);
|
|
110904
|
+
}, [activeTab, showAddPanel, reverseSidebarVisible, highlightRequiredProperties, iconView, tabPaneWidth, contextEntity == null ? void 0 : contextEntity["@id"]]);
|
|
110660
110905
|
const handleAddPropertyPlaceholder = (property) => {
|
|
110661
110906
|
try {
|
|
110662
110907
|
const newExtraProperties = [...extraProperties, property];
|
|
@@ -110711,7 +110956,7 @@ const RenderEntity = forwardRef((props, ref) => {
|
|
|
110711
110956
|
...data
|
|
110712
110957
|
});
|
|
110713
110958
|
if (updatedEntity["@id"] !== entity["@id"]) {
|
|
110714
|
-
|
|
110959
|
+
handleLoadEntityWithContext({ id: updatedEntity["@id"] });
|
|
110715
110960
|
} else {
|
|
110716
110961
|
refresh();
|
|
110717
110962
|
}
|
|
@@ -110816,7 +111061,7 @@ const RenderEntity = forwardRef((props, ref) => {
|
|
|
110816
111061
|
const handleDeleteEntity = (data) => {
|
|
110817
111062
|
try {
|
|
110818
111063
|
crateManager.deleteEntity({ id: data.id });
|
|
110819
|
-
|
|
111064
|
+
handleLoadEntityWithContext({ id: "./" });
|
|
110820
111065
|
onSaveCrate();
|
|
110821
111066
|
} catch (error2) {
|
|
110822
111067
|
onError();
|
|
@@ -110929,7 +111174,7 @@ const RenderEntity = forwardRef((props, ref) => {
|
|
|
110929
111174
|
RenderControls,
|
|
110930
111175
|
{
|
|
110931
111176
|
entity: contextEntity,
|
|
110932
|
-
onLoadEntity,
|
|
111177
|
+
onLoadEntity: handleLoadEntityWithContext,
|
|
110933
111178
|
onBack: () => state.editorState.back(),
|
|
110934
111179
|
onForward: () => state.editorState.forward(),
|
|
110935
111180
|
onAddPropertyPlaceholder: handleAddPropertyPlaceholder,
|
|
@@ -110998,7 +111243,7 @@ const RenderEntity = forwardRef((props, ref) => {
|
|
|
110998
111243
|
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
110999
111244
|
"div",
|
|
111000
111245
|
{
|
|
111001
|
-
className: `my-2 p-2 describo-property describo-property-name-name ${savedProperty === "name" ? "bg-green-200 rounded
|
|
111246
|
+
className: `my-2 p-2 describo-property describo-property-name-name ${savedProperty === "name" ? "bg-green-200 rounded" : ""}`,
|
|
111002
111247
|
children: /* @__PURE__ */ jsxRuntimeExports.jsx(EntityName, { entity: contextEntity, onUpdate: handleUpdateEntity })
|
|
111003
111248
|
}
|
|
111004
111249
|
),
|
|
@@ -111016,7 +111261,7 @@ const RenderEntity = forwardRef((props, ref) => {
|
|
|
111016
111261
|
values: Array.isArray(contextEntity[property]) ? contextEntity[property] : [contextEntity[property]],
|
|
111017
111262
|
highlightRequired: highlightRequiredProperties,
|
|
111018
111263
|
savedProperty: savedProperty === property,
|
|
111019
|
-
onLoadEntity,
|
|
111264
|
+
onLoadEntity: handleLoadEntityWithContext,
|
|
111020
111265
|
onCreateEntity: handleCreateEntity,
|
|
111021
111266
|
onLinkEntity: handleLinkEntity,
|
|
111022
111267
|
onUnlinkEntity: handleUnlinkEntity,
|
|
@@ -111104,7 +111349,7 @@ const RenderEntity = forwardRef((props, ref) => {
|
|
|
111104
111349
|
values: Array.isArray(contextEntity[property]) ? contextEntity[property] : [contextEntity[property]],
|
|
111105
111350
|
highlightRequired: highlightRequiredProperties,
|
|
111106
111351
|
savedProperty: savedProperty === property,
|
|
111107
|
-
onLoadEntity,
|
|
111352
|
+
onLoadEntity: handleLoadEntityWithContext,
|
|
111108
111353
|
onCreateEntity: handleCreateEntity,
|
|
111109
111354
|
onLinkEntity: handleLinkEntity,
|
|
111110
111355
|
onUnlinkEntity: handleUnlinkEntity,
|
|
@@ -111134,6 +111379,7 @@ const RenderEntity = forwardRef((props, ref) => {
|
|
|
111134
111379
|
className: "describo-tabs-vertical-center-add",
|
|
111135
111380
|
activeKey: activeTab,
|
|
111136
111381
|
onChange: (key) => {
|
|
111382
|
+
captureViewContext(activeTab);
|
|
111137
111383
|
setActiveTab(key);
|
|
111138
111384
|
saveTabToState(key);
|
|
111139
111385
|
},
|
|
@@ -111180,7 +111426,7 @@ const RenderEntity = forwardRef((props, ref) => {
|
|
|
111180
111426
|
values: Array.isArray(contextEntity[input.name]) ? contextEntity[input.name] : [contextEntity[input.name]],
|
|
111181
111427
|
highlightRequired: highlightRequiredProperties,
|
|
111182
111428
|
savedProperty: savedProperty === input.name,
|
|
111183
|
-
onLoadEntity,
|
|
111429
|
+
onLoadEntity: handleLoadEntityWithContext,
|
|
111184
111430
|
onCreateEntity: handleCreateEntity,
|
|
111185
111431
|
onLinkEntity: handleLinkEntity,
|
|
111186
111432
|
onUnlinkEntity: handleUnlinkEntity,
|
|
@@ -111209,7 +111455,7 @@ const RenderEntity = forwardRef((props, ref) => {
|
|
|
111209
111455
|
values: Array.isArray(contextEntity[input.name]) ? contextEntity[input.name] : [contextEntity[input.name]],
|
|
111210
111456
|
highlightRequired: highlightRequiredProperties,
|
|
111211
111457
|
savedProperty: savedProperty === input.name,
|
|
111212
|
-
onLoadEntity,
|
|
111458
|
+
onLoadEntity: handleLoadEntityWithContext,
|
|
111213
111459
|
onCreateEntity: handleCreateEntity,
|
|
111214
111460
|
onLinkEntity: handleLinkEntity,
|
|
111215
111461
|
onUnlinkEntity: handleUnlinkEntity,
|
|
@@ -111242,7 +111488,7 @@ const RenderEntity = forwardRef((props, ref) => {
|
|
|
111242
111488
|
{
|
|
111243
111489
|
entity: contextEntity,
|
|
111244
111490
|
onLoadEntity: (data) => {
|
|
111245
|
-
|
|
111491
|
+
handleLoadEntityWithContext(data);
|
|
111246
111492
|
setReverseSidebarVisible(false);
|
|
111247
111493
|
}
|
|
111248
111494
|
},
|
|
@@ -119575,7 +119821,7 @@ var EmotionCacheContext = /* @__PURE__ */ React.createContext(
|
|
|
119575
119821
|
}) : null
|
|
119576
119822
|
);
|
|
119577
119823
|
var CacheProvider = EmotionCacheContext.Provider;
|
|
119578
|
-
const version = "0.1.
|
|
119824
|
+
const version = "0.1.23";
|
|
119579
119825
|
const pkg = {
|
|
119580
119826
|
version
|
|
119581
119827
|
};
|
|
@@ -119712,8 +119958,7 @@ function DescriboCrateBuilderInner(props) {
|
|
|
119712
119958
|
const validIds = new Set(
|
|
119713
119959
|
graph.filter((entry) => entry && typeof entry === "object" && typeof entry["@id"] === "string").map((entry) => String(entry["@id"]))
|
|
119714
119960
|
);
|
|
119715
|
-
state.editorState.
|
|
119716
|
-
state.editorState.current = state.editorState.history.length === 0 ? 0 : Math.min(state.editorState.current, state.editorState.history.length - 1);
|
|
119961
|
+
state.editorState.prune(validIds);
|
|
119717
119962
|
const candidateIds = [(_a2 = state.editorState.latest()) == null ? void 0 : _a2.id, entityId, "./"];
|
|
119718
119963
|
let nextEntity = null;
|
|
119719
119964
|
for (const candidateId of candidateIds) {
|