@arpproject/recrate 0.1.18 → 0.1.19
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/recrate.es.js
CHANGED
|
@@ -67378,6 +67378,8 @@ let EditorState$1 = class EditorState {
|
|
|
67378
67378
|
*/
|
|
67379
67379
|
push({ id: id2 }) {
|
|
67380
67380
|
if (!id2) return;
|
|
67381
|
+
const latest = this.latest();
|
|
67382
|
+
if ((latest == null ? void 0 : latest.id) === id2) return;
|
|
67381
67383
|
if (this.history.length - 1 > this.current) {
|
|
67382
67384
|
this.history = this.history.slice(0, this.current + 1);
|
|
67383
67385
|
}
|
|
@@ -67404,6 +67406,12 @@ let EditorState$1 = class EditorState {
|
|
|
67404
67406
|
latest() {
|
|
67405
67407
|
return this.history[this.current];
|
|
67406
67408
|
}
|
|
67409
|
+
canBack() {
|
|
67410
|
+
return this.current > 0;
|
|
67411
|
+
}
|
|
67412
|
+
canForward() {
|
|
67413
|
+
return this.current < this.history.length - 1;
|
|
67414
|
+
}
|
|
67407
67415
|
/**
|
|
67408
67416
|
* Update the current entry
|
|
67409
67417
|
*
|
|
@@ -106644,15 +106652,19 @@ const RenderControls = ({
|
|
|
106644
106652
|
const loadRootDataset = () => {
|
|
106645
106653
|
onLoadEntity({ id: "./" });
|
|
106646
106654
|
};
|
|
106655
|
+
const canGoBack = state.editorState.canBack();
|
|
106656
|
+
const canGoForward = state.editorState.canForward();
|
|
106647
106657
|
const handleBack = () => {
|
|
106648
|
-
|
|
106658
|
+
if (!canGoBack) return;
|
|
106659
|
+
onBack();
|
|
106649
106660
|
const latest = state.editorState.latest();
|
|
106650
106661
|
if (latest == null ? void 0 : latest.id) {
|
|
106651
106662
|
onLoadEntity({ id: latest.id, updateState: false });
|
|
106652
106663
|
}
|
|
106653
106664
|
};
|
|
106654
106665
|
const handleForward = () => {
|
|
106655
|
-
|
|
106666
|
+
if (!canGoForward) return;
|
|
106667
|
+
onForward();
|
|
106656
106668
|
const latest = state.editorState.latest();
|
|
106657
106669
|
if (latest == null ? void 0 : latest.id) {
|
|
106658
106670
|
onLoadEntity({ id: latest.id, updateState: false });
|
|
@@ -106676,7 +106688,8 @@ const RenderControls = ({
|
|
|
106676
106688
|
{
|
|
106677
106689
|
onClick: handleBack,
|
|
106678
106690
|
type: "primary",
|
|
106679
|
-
icon: /* @__PURE__ */ jsxRuntimeExports.jsx(RefIcon$8, {})
|
|
106691
|
+
icon: /* @__PURE__ */ jsxRuntimeExports.jsx(RefIcon$8, {}),
|
|
106692
|
+
disabled: !canGoBack
|
|
106680
106693
|
}
|
|
106681
106694
|
),
|
|
106682
106695
|
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
@@ -106693,7 +106706,8 @@ const RenderControls = ({
|
|
|
106693
106706
|
{
|
|
106694
106707
|
onClick: handleForward,
|
|
106695
106708
|
type: "primary",
|
|
106696
|
-
icon: /* @__PURE__ */ jsxRuntimeExports.jsx(RefIcon$7, {})
|
|
106709
|
+
icon: /* @__PURE__ */ jsxRuntimeExports.jsx(RefIcon$7, {}),
|
|
106710
|
+
disabled: !canGoForward
|
|
106697
106711
|
}
|
|
106698
106712
|
)
|
|
106699
106713
|
] }),
|
|
@@ -119521,7 +119535,7 @@ var EmotionCacheContext = /* @__PURE__ */ React.createContext(
|
|
|
119521
119535
|
}) : null
|
|
119522
119536
|
);
|
|
119523
119537
|
var CacheProvider = EmotionCacheContext.Provider;
|
|
119524
|
-
const version = "0.1.
|
|
119538
|
+
const version = "0.1.19";
|
|
119525
119539
|
const pkg = {
|
|
119526
119540
|
version
|
|
119527
119541
|
};
|
|
@@ -119568,6 +119582,7 @@ function DescriboCrateBuilder(props) {
|
|
|
119568
119582
|
const state = useStateStore();
|
|
119569
119583
|
const renderEntityRef = useRef(null);
|
|
119570
119584
|
const keys2 = useRef({ cm: 0, pm: 0, lookups: 0 });
|
|
119585
|
+
const lastHandledEntityIdRef = useRef(void 0);
|
|
119571
119586
|
const configuration = useMemo$1(() => {
|
|
119572
119587
|
const config2 = {
|
|
119573
119588
|
enableContextEditor,
|
|
@@ -119612,6 +119627,7 @@ function DescriboCrateBuilder(props) {
|
|
|
119612
119627
|
lookup
|
|
119613
119628
|
]);
|
|
119614
119629
|
const init2 = useCallback(async () => {
|
|
119630
|
+
var _a2, _b;
|
|
119615
119631
|
instance.changeLanguage(language2);
|
|
119616
119632
|
if (!crate || isEmpty(crate)) {
|
|
119617
119633
|
setReady(false);
|
|
@@ -119649,21 +119665,37 @@ function DescriboCrateBuilder(props) {
|
|
|
119649
119665
|
setError(false);
|
|
119650
119666
|
state.configuration = configuration;
|
|
119651
119667
|
try {
|
|
119652
|
-
const
|
|
119653
|
-
|
|
119654
|
-
|
|
119655
|
-
|
|
119656
|
-
|
|
119668
|
+
const graph = Array.isArray(crate == null ? void 0 : crate["@graph"]) ? crate["@graph"] : [];
|
|
119669
|
+
const validIds = new Set(
|
|
119670
|
+
graph.filter((entry) => entry && typeof entry === "object" && typeof entry["@id"] === "string").map((entry) => String(entry["@id"]))
|
|
119671
|
+
);
|
|
119672
|
+
state.editorState.history = state.editorState.history.filter((entry) => validIds.has(entry.id));
|
|
119673
|
+
state.editorState.current = state.editorState.history.length === 0 ? 0 : Math.min(state.editorState.current, state.editorState.history.length - 1);
|
|
119674
|
+
const candidateIds = [(_a2 = state.editorState.latest()) == null ? void 0 : _a2.id, entityId, "./"];
|
|
119675
|
+
let nextEntity = null;
|
|
119676
|
+
for (const candidateId of candidateIds) {
|
|
119677
|
+
if (!candidateId) continue;
|
|
119678
|
+
const maybeEntity = newCm.getEntity({ id: candidateId, link: false, materialise: false });
|
|
119679
|
+
if (!isEmpty(maybeEntity)) {
|
|
119680
|
+
nextEntity = maybeEntity;
|
|
119681
|
+
break;
|
|
119682
|
+
}
|
|
119683
|
+
}
|
|
119684
|
+
if (!nextEntity) {
|
|
119657
119685
|
setError(true);
|
|
119658
119686
|
return;
|
|
119659
119687
|
}
|
|
119688
|
+
setContextEntity(nextEntity);
|
|
119689
|
+
if (((_b = state.editorState.latest()) == null ? void 0 : _b.id) !== nextEntity["@id"]) {
|
|
119690
|
+
state.editorState.push({ id: nextEntity["@id"] });
|
|
119691
|
+
}
|
|
119660
119692
|
setReady(true);
|
|
119661
119693
|
onReady == null ? void 0 : onReady();
|
|
119662
119694
|
} catch (error22) {
|
|
119663
119695
|
setError(true);
|
|
119664
119696
|
onError == null ? void 0 : onError({ error: "Failed to initialize entity" });
|
|
119665
119697
|
}
|
|
119666
|
-
}, [crate, profile, lookup, configuration, enableEntityTimestamps, language2, onError, onReady, state.editorState]);
|
|
119698
|
+
}, [crate, profile, entityId, lookup, configuration, enableEntityTimestamps, language2, onError, onReady, state.editorState]);
|
|
119667
119699
|
const handleSetCurrentEntity = useCallback((params) => {
|
|
119668
119700
|
const { id: id2, updateState = true } = params;
|
|
119669
119701
|
if (!id2 || !cm) return;
|
|
@@ -119714,14 +119746,23 @@ function DescriboCrateBuilder(props) {
|
|
|
119714
119746
|
onError == null ? void 0 : onError({});
|
|
119715
119747
|
};
|
|
119716
119748
|
useEffect(() => {
|
|
119717
|
-
state.editorState.reset();
|
|
119718
119749
|
init2();
|
|
119719
119750
|
}, [crate, profile, init2]);
|
|
119720
119751
|
useEffect(() => {
|
|
119721
|
-
|
|
119722
|
-
|
|
119752
|
+
var _a2;
|
|
119753
|
+
if (!entityId) {
|
|
119754
|
+
lastHandledEntityIdRef.current = void 0;
|
|
119755
|
+
return;
|
|
119756
|
+
}
|
|
119757
|
+
if (lastHandledEntityIdRef.current === entityId) {
|
|
119758
|
+
return;
|
|
119759
|
+
}
|
|
119760
|
+
lastHandledEntityIdRef.current = entityId;
|
|
119761
|
+
if (entityId !== (contextEntity == null ? void 0 : contextEntity["@id"])) {
|
|
119762
|
+
const shouldPushToHistory = ((_a2 = state.editorState.latest()) == null ? void 0 : _a2.id) !== entityId;
|
|
119763
|
+
handleSetCurrentEntity({ id: entityId, updateState: shouldPushToHistory });
|
|
119723
119764
|
}
|
|
119724
|
-
}, [entityId, contextEntity, handleSetCurrentEntity]);
|
|
119765
|
+
}, [entityId, contextEntity, handleSetCurrentEntity, state.editorState]);
|
|
119725
119766
|
const saveCrate = () => {
|
|
119726
119767
|
if (!cm) return;
|
|
119727
119768
|
if (purgeUnlinkedEntities) {
|