@arpproject/recrate 0.1.17 → 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
|
] }),
|
|
@@ -110840,7 +110854,8 @@ const RenderEntity = forwardRef((props, ref) => {
|
|
|
110840
110854
|
const addProfileTabItem = {
|
|
110841
110855
|
key: "add-schema-button",
|
|
110842
110856
|
label: addProfileTabLabel,
|
|
110843
|
-
className: "ant-tabs-tab-add-button"
|
|
110857
|
+
className: "ant-tabs-tab-add-button",
|
|
110858
|
+
disabled: true
|
|
110844
110859
|
};
|
|
110845
110860
|
const toggleViewTabItem = {
|
|
110846
110861
|
key: "toggle-view",
|
|
@@ -119520,7 +119535,7 @@ var EmotionCacheContext = /* @__PURE__ */ React.createContext(
|
|
|
119520
119535
|
}) : null
|
|
119521
119536
|
);
|
|
119522
119537
|
var CacheProvider = EmotionCacheContext.Provider;
|
|
119523
|
-
const version = "0.1.
|
|
119538
|
+
const version = "0.1.19";
|
|
119524
119539
|
const pkg = {
|
|
119525
119540
|
version
|
|
119526
119541
|
};
|
|
@@ -119567,6 +119582,7 @@ function DescriboCrateBuilder(props) {
|
|
|
119567
119582
|
const state = useStateStore();
|
|
119568
119583
|
const renderEntityRef = useRef(null);
|
|
119569
119584
|
const keys2 = useRef({ cm: 0, pm: 0, lookups: 0 });
|
|
119585
|
+
const lastHandledEntityIdRef = useRef(void 0);
|
|
119570
119586
|
const configuration = useMemo$1(() => {
|
|
119571
119587
|
const config2 = {
|
|
119572
119588
|
enableContextEditor,
|
|
@@ -119611,6 +119627,7 @@ function DescriboCrateBuilder(props) {
|
|
|
119611
119627
|
lookup
|
|
119612
119628
|
]);
|
|
119613
119629
|
const init2 = useCallback(async () => {
|
|
119630
|
+
var _a2, _b;
|
|
119614
119631
|
instance.changeLanguage(language2);
|
|
119615
119632
|
if (!crate || isEmpty(crate)) {
|
|
119616
119633
|
setReady(false);
|
|
@@ -119648,21 +119665,37 @@ function DescriboCrateBuilder(props) {
|
|
|
119648
119665
|
setError(false);
|
|
119649
119666
|
state.configuration = configuration;
|
|
119650
119667
|
try {
|
|
119651
|
-
const
|
|
119652
|
-
|
|
119653
|
-
|
|
119654
|
-
|
|
119655
|
-
|
|
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) {
|
|
119656
119685
|
setError(true);
|
|
119657
119686
|
return;
|
|
119658
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
|
+
}
|
|
119659
119692
|
setReady(true);
|
|
119660
119693
|
onReady == null ? void 0 : onReady();
|
|
119661
119694
|
} catch (error22) {
|
|
119662
119695
|
setError(true);
|
|
119663
119696
|
onError == null ? void 0 : onError({ error: "Failed to initialize entity" });
|
|
119664
119697
|
}
|
|
119665
|
-
}, [crate, profile, lookup, configuration, enableEntityTimestamps, language2, onError, onReady, state.editorState]);
|
|
119698
|
+
}, [crate, profile, entityId, lookup, configuration, enableEntityTimestamps, language2, onError, onReady, state.editorState]);
|
|
119666
119699
|
const handleSetCurrentEntity = useCallback((params) => {
|
|
119667
119700
|
const { id: id2, updateState = true } = params;
|
|
119668
119701
|
if (!id2 || !cm) return;
|
|
@@ -119713,14 +119746,23 @@ function DescriboCrateBuilder(props) {
|
|
|
119713
119746
|
onError == null ? void 0 : onError({});
|
|
119714
119747
|
};
|
|
119715
119748
|
useEffect(() => {
|
|
119716
|
-
state.editorState.reset();
|
|
119717
119749
|
init2();
|
|
119718
119750
|
}, [crate, profile, init2]);
|
|
119719
119751
|
useEffect(() => {
|
|
119720
|
-
|
|
119721
|
-
|
|
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 });
|
|
119722
119764
|
}
|
|
119723
|
-
}, [entityId, contextEntity, handleSetCurrentEntity]);
|
|
119765
|
+
}, [entityId, contextEntity, handleSetCurrentEntity, state.editorState]);
|
|
119724
119766
|
const saveCrate = () => {
|
|
119725
119767
|
if (!cm) return;
|
|
119726
119768
|
if (purgeUnlinkedEntities) {
|