@carlonicora/nextjs-jsonapi 1.94.0 → 1.96.0

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.
@@ -8587,6 +8587,7 @@ function EditorSheet({
8587
8587
  onSuccess,
8588
8588
  onRevalidate,
8589
8589
  onNavigate,
8590
+ onSaved,
8590
8591
  size = "xl",
8591
8592
  disabled,
8592
8593
  hideSubmit,
@@ -8620,6 +8621,9 @@ function EditorSheet({
8620
8621
  try {
8621
8622
  const result = await onSubmit(values);
8622
8623
  setOpen(false);
8624
+ if (isEdit && result && onSaved) {
8625
+ onSaved(result, entityType);
8626
+ }
8623
8627
  if (onSuccess) {
8624
8628
  await onSuccess();
8625
8629
  } else if (result) {
@@ -8637,7 +8641,7 @@ function EditorSheet({
8637
8641
  });
8638
8642
  }
8639
8643
  },
8640
- [onSubmit, setOpen, onSuccess, onRevalidate, onNavigate, generateUrl, module, isEdit, propagateChanges, t]
8644
+ [onSubmit, setOpen, onSuccess, onSaved, onRevalidate, onNavigate, generateUrl, module, isEdit, propagateChanges, t]
8641
8645
  );
8642
8646
  return /* @__PURE__ */ jsxs39(Fragment9, { children: [
8643
8647
  /* @__PURE__ */ jsxs39(Sheet, { open, onOpenChange: handleOpenChange, children: [
@@ -9222,7 +9226,7 @@ import { useRef as useRef15 } from "react";
9222
9226
  import dynamic from "next/dynamic";
9223
9227
  import React14 from "react";
9224
9228
  import { jsx as jsx73 } from "react/jsx-runtime";
9225
- var BlockNoteEditor = dynamic(() => import("./BlockNoteEditor-S62X5HSE.mjs"), {
9229
+ var BlockNoteEditor = dynamic(() => import("./BlockNoteEditor-VPTC7JY3.mjs"), {
9226
9230
  ssr: false
9227
9231
  });
9228
9232
  var BlockNoteEditorContainer = React14.memo(/* @__PURE__ */ __name(function EditorContainer(props) {
@@ -9249,7 +9253,9 @@ function FormBlockNote({
9249
9253
  mentionSearchFn,
9250
9254
  mentionSearchParams,
9251
9255
  mentionResolveFn,
9252
- suggestionMenuComponent
9256
+ suggestionMenuComponent,
9257
+ mentionNameResolver,
9258
+ onWarmMentions
9253
9259
  }) {
9254
9260
  const initialContentRef = useRef15(null);
9255
9261
  const lastEditorContentRef = useRef15(void 0);
@@ -9295,6 +9301,8 @@ function FormBlockNote({
9295
9301
  mentionSearchParams,
9296
9302
  mentionResolveFn,
9297
9303
  suggestionMenuComponent,
9304
+ mentionNameResolver,
9305
+ onWarmMentions,
9298
9306
  className: cn(stretch && "min-h-0 flex-1")
9299
9307
  }
9300
9308
  );
@@ -13722,26 +13730,36 @@ var mentionDataAttrs = /* @__PURE__ */ __name((p) => ({
13722
13730
  "data-mention-type": p.entityType,
13723
13731
  "data-mention-alias": p.alias
13724
13732
  }), "mentionDataAttrs");
13725
- var createMentionInlineContentSpec = /* @__PURE__ */ __name((resolveFn, disableMention) => {
13733
+ var createMentionInlineContentSpec = /* @__PURE__ */ __name((resolveFn, disableMention, nameResolver) => {
13726
13734
  const Mention = React21.memo(/* @__PURE__ */ __name(function Mention2(props) {
13735
+ const displayName = nameResolver?.(props.id, props.entityType, props.alias) ?? props.alias;
13727
13736
  if (disableMention) {
13728
- const resolved2 = resolveFn?.(props.id, props.entityType, props.alias);
13737
+ const resolved2 = resolveFn?.(props.id, props.entityType, displayName);
13729
13738
  return /* @__PURE__ */ jsxs90(Link3, { href: resolved2?.url ?? "#", className: "text-primary", children: [
13730
13739
  "@",
13731
- props.alias
13740
+ displayName
13732
13741
  ] });
13733
13742
  }
13734
- const resolved = resolveFn?.(props.id, props.entityType, props.alias);
13743
+ const resolved = resolveFn?.(props.id, props.entityType, displayName);
13735
13744
  if (resolved?.Inline) {
13736
13745
  const Custom = resolved.Inline;
13737
- return /* @__PURE__ */ jsx151(Custom, { ...props });
13746
+ return /* @__PURE__ */ jsx151(Custom, { ...props, alias: displayName });
13738
13747
  }
13739
13748
  const href = resolved?.url ?? "#";
13740
13749
  const handleClick = resolved?.onActivate ? (e) => resolved.onActivate(e, props) : void 0;
13741
- return /* @__PURE__ */ jsxs90(Link3, { href, className: "text-primary", onClick: handleClick, ...mentionDataAttrs(props), children: [
13742
- "@",
13743
- props.alias
13744
- ] });
13750
+ return /* @__PURE__ */ jsxs90(
13751
+ Link3,
13752
+ {
13753
+ href,
13754
+ className: "text-primary",
13755
+ onClick: handleClick,
13756
+ ...mentionDataAttrs({ ...props, alias: displayName }),
13757
+ children: [
13758
+ "@",
13759
+ displayName
13760
+ ]
13761
+ }
13762
+ );
13745
13763
  }, "Mention"));
13746
13764
  return createReactInlineContentSpec(
13747
13765
  {
@@ -13769,14 +13787,28 @@ var createMentionInlineContentSpec = /* @__PURE__ */ __name((resolveFn, disableM
13769
13787
  // src/components/editors/BlockNoteEditorSuggestionMenuController.tsx
13770
13788
  import { SuggestionMenuController } from "@blocknote/react";
13771
13789
  import { autoUpdate, flip, shift } from "@floating-ui/react";
13772
- import { useCallback as useCallback28 } from "react";
13790
+ import React22, { useCallback as useCallback28 } from "react";
13773
13791
  import { jsx as jsx152 } from "react/jsx-runtime";
13792
+ var MentionInsertContext = React22.createContext(null);
13793
+ var useMentionInsert = /* @__PURE__ */ __name(() => React22.useContext(MentionInsertContext), "useMentionInsert");
13774
13794
  function BlockNoteEditorMentionSuggestionMenu({
13775
13795
  editor,
13776
13796
  mentionSearchFn,
13777
13797
  mentionSearchParams,
13778
13798
  suggestionMenuComponent
13779
13799
  }) {
13800
+ const onMentionInsert = useCallback28(
13801
+ (id, name, entityType) => {
13802
+ editor.insertInlineContent([
13803
+ {
13804
+ type: "mention",
13805
+ props: { alias: name, id, entityType }
13806
+ },
13807
+ " "
13808
+ ]);
13809
+ },
13810
+ [editor]
13811
+ );
13780
13812
  const getItems = useCallback28(
13781
13813
  async (query) => {
13782
13814
  const results = await mentionSearchFn(query, mentionSearchParams);
@@ -13801,7 +13833,7 @@ function BlockNoteEditorMentionSuggestionMenu({
13801
13833
  },
13802
13834
  [editor, mentionSearchFn, mentionSearchParams]
13803
13835
  );
13804
- return /* @__PURE__ */ jsx152("div", { className: "blocknote-suggestion-container", style: { position: "static" }, children: /* @__PURE__ */ jsx152(
13836
+ return /* @__PURE__ */ jsx152(MentionInsertContext.Provider, { value: onMentionInsert, children: /* @__PURE__ */ jsx152("div", { className: "blocknote-suggestion-container", style: { position: "static" }, children: /* @__PURE__ */ jsx152(
13805
13837
  SuggestionMenuController,
13806
13838
  {
13807
13839
  triggerCharacter: "@",
@@ -13816,7 +13848,7 @@ function BlockNoteEditorMentionSuggestionMenu({
13816
13848
  }
13817
13849
  }
13818
13850
  }
13819
- ) });
13851
+ ) }) });
13820
13852
  }
13821
13853
  __name(BlockNoteEditorMentionSuggestionMenu, "BlockNoteEditorMentionSuggestionMenu");
13822
13854
 
@@ -21809,6 +21841,7 @@ export {
21809
21841
  BlockNoteEditorMentionHoverCard,
21810
21842
  mentionDataAttrs,
21811
21843
  createMentionInlineContentSpec,
21844
+ useMentionInsert,
21812
21845
  BlockNoteEditorMentionSuggestionMenu,
21813
21846
  BlockNoteEditorContainer,
21814
21847
  CommonAssociationTrigger,
@@ -21985,4 +22018,4 @@ export {
21985
22018
  useOAuthClients,
21986
22019
  useOAuthClient
21987
22020
  };
21988
- //# sourceMappingURL=chunk-PNQDUCEN.mjs.map
22021
+ //# sourceMappingURL=chunk-QH4QZLBS.mjs.map