@tn-pulse-suivi/notion-ui-comps 1.0.3 → 1.0.5

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/index.cjs CHANGED
@@ -2508,7 +2508,7 @@ function addEmojiTrigger(editor, trigger = ":", node, nodePos) {
2508
2508
  }
2509
2509
 
2510
2510
  // src/components/tiptap-ui/slash-dropdown-menu/use-slash-dropdown-menu.tsx
2511
- var getSlashMenuItemsTexts = (tNL, tCommon, tBook) => ({
2511
+ var getSlashMenuItemsTexts = (tNL) => ({
2512
2512
  // Style
2513
2513
  text: {
2514
2514
  title: tNL("Text"),
@@ -2698,7 +2698,7 @@ var getItemImplementations = (commonFns) => {
2698
2698
  const statusNodeDomNode = commonFns.findDomRefAtPos(pos, domAtPos.bind(view));
2699
2699
  if (statusNodeDomNode.tagName === "STATUS-NODE") {
2700
2700
  const statusNodeDomNodeText = statusNodeDomNode.getAttribute("text");
2701
- const emptyStatusPopupInputPlaceholder = commonFns.getI18next().t("emptyStatusPopupInputPlaceholder");
2701
+ const emptyStatusPopupInputPlaceholder = t("emptyStatusPopupInputPlaceholder");
2702
2702
  const nodeAtPos = doc.nodeAt(pos);
2703
2703
  if (commonFns.equalNodeType(nodes.statusNode, nodeAtPos)) {
2704
2704
  if (statusNodeDomNodeText === emptyStatusPopupInputPlaceholder) {
@@ -2810,12 +2810,10 @@ function organizeItemsByGroups(items, showGroups) {
2810
2810
  }
2811
2811
  function useSlashDropdownMenu(config) {
2812
2812
  const { t: tNotionLike } = (0, import_react_i18next.useTranslation)("notionLike" /* notionLike */);
2813
- const { t: tCommon } = (0, import_react_i18next.useTranslation)("common" /* common */);
2814
- const { t: tBook } = (0, import_react_i18next.useTranslation)("book" /* book */);
2815
2813
  const getSlashMenuItems = (0, import_react38.useCallback)(
2816
2814
  (editor, commonFns) => {
2817
2815
  const items = [];
2818
- const texts = getSlashMenuItemsTexts(tNotionLike, tCommon, tBook);
2816
+ const texts = getSlashMenuItemsTexts(tNotionLike);
2819
2817
  const enabledItems = config?.enabledItems || Object.keys(texts);
2820
2818
  const showGroups = config?.showGroups !== false;
2821
2819
  const itemImplementations = getItemImplementations(commonFns);
@@ -10994,7 +10992,8 @@ var TurnIntoDropdown = (0, import_react138.forwardRef)(
10994
10992
  hideWhenUnavailable,
10995
10993
  blockTypes,
10996
10994
  onOpenChange,
10997
- tNotionLike
10995
+ tNotionLike,
10996
+ commonFns
10998
10997
  });
10999
10998
  if (!isVisible) {
11000
10999
  return null;
@@ -11123,7 +11122,7 @@ function shouldShowTurnInto(params) {
11123
11122
  return true;
11124
11123
  }
11125
11124
  function useTurnIntoDropdown(config) {
11126
- const { editor: providedEditor, hideWhenUnavailable = false, blockTypes, onOpenChange, tNotionLike } = config || {};
11125
+ const { editor: providedEditor, hideWhenUnavailable = false, blockTypes, onOpenChange, tNotionLike, commonFns } = config || {};
11127
11126
  const { editor } = useTiptapEditor(providedEditor);
11128
11127
  const [isOpen, setIsOpen] = (0, import_react139.useState)(false);
11129
11128
  const [isVisible, setIsVisible] = (0, import_react139.useState)(true);
@@ -11162,7 +11161,7 @@ function useTurnIntoDropdown(config) {
11162
11161
  activeBlockType,
11163
11162
  handleOpenChange,
11164
11163
  filteredOptions: getFilteredBlockTypeOptions(tNotionLike, blockTypes),
11165
- label: capitalizeFirstLetter(tNotionLike("TurnInto").toLowerCase()) + ` (current: ${activeBlockType?.label || tNotionLike("Text")})`,
11164
+ label: commonFns.capitalizeFirstLetter(tNotionLike("TurnInto").toLowerCase()) + ` (current: ${activeBlockType?.label || tNotionLike("Text")})`,
11166
11165
  Icon: ChevronDownIcon
11167
11166
  };
11168
11167
  }
@@ -12226,7 +12225,6 @@ RefreshCcwIcon.displayName = "RefreshCcwIcon";
12226
12225
  var import_jsx_runtime108 = require("react/jsx-runtime");
12227
12226
  function ImageNodeFloating({
12228
12227
  editor: providedEditor,
12229
- ExpandImgIconClickHAndler,
12230
12228
  tNotionLike,
12231
12229
  commonFns,
12232
12230
  customIcons
@@ -12237,7 +12235,7 @@ function ImageNodeFloating({
12237
12235
  return null;
12238
12236
  }
12239
12237
  return /* @__PURE__ */ (0, import_jsx_runtime108.jsxs)(import_jsx_runtime108.Fragment, { children: [
12240
- /* @__PURE__ */ (0, import_jsx_runtime108.jsx)(image_expand_button_default, { ExpandImgIconClickHAndler, commonFns, customIcons }),
12238
+ /* @__PURE__ */ (0, import_jsx_runtime108.jsx)(image_expand_button_default, { commonFns, customIcons }),
12241
12239
  /* @__PURE__ */ (0, import_jsx_runtime108.jsx)(ImageAlignButton, { align: "left" }),
12242
12240
  /* @__PURE__ */ (0, import_jsx_runtime108.jsx)(ImageAlignButton, { align: "center" }),
12243
12241
  /* @__PURE__ */ (0, import_jsx_runtime108.jsx)(ImageAlignButton, { align: "right" }),
@@ -12495,7 +12493,6 @@ function MainToolbarContent({
12495
12493
  isMobile,
12496
12494
  toolbarViews,
12497
12495
  onViewChange,
12498
- ExpandImgIconClickHAndler,
12499
12496
  tNotionLike,
12500
12497
  commonFns,
12501
12498
  customIcons
@@ -12519,7 +12516,7 @@ function MainToolbarContent({
12519
12516
  editor
12520
12517
  }
12521
12518
  ),
12522
- /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(ImageNodeFloating, { ExpandImgIconClickHAndler, tNotionLike, commonFns, customIcons }),
12519
+ /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(ImageNodeFloating, { tNotionLike, commonFns, customIcons }),
12523
12520
  /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(ScriptGroup, { tNotionLike }),
12524
12521
  /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(AlignmentGroup, { tNotionLike }),
12525
12522
  /* @__PURE__ */ (0, import_jsx_runtime109.jsxs)(ToolbarGroup, { children: [
@@ -12543,7 +12540,7 @@ function SpecializedToolbarContent({ view, onBack }) {
12543
12540
  view.content
12544
12541
  ] });
12545
12542
  }
12546
- function MobileToolbar({ editor: providedEditor, ExpandImgIconClickHAndler, tNotionLike, commonFns, customIcons }) {
12543
+ function MobileToolbar({ editor: providedEditor, tNotionLike, commonFns, customIcons }) {
12547
12544
  const { editor } = useTiptapEditor(providedEditor);
12548
12545
  const isMobile = useIsBreakpoint("max", 480);
12549
12546
  const toolbarRef = (0, import_react155.useRef)(null);
@@ -12575,7 +12572,6 @@ function MobileToolbar({ editor: providedEditor, ExpandImgIconClickHAndler, tNot
12575
12572
  isMobile,
12576
12573
  toolbarViews,
12577
12574
  onViewChange: toolbarState.showView,
12578
- ExpandImgIconClickHAndler,
12579
12575
  tNotionLike,
12580
12576
  commonFns,
12581
12577
  customIcons
@@ -12836,7 +12832,7 @@ var isElementWithinEditor = (editor, element) => {
12836
12832
 
12837
12833
  // src/components/tiptap-templates/notion-like/notion-like-editor-toolbar-floating.tsx
12838
12834
  var import_jsx_runtime112 = require("react/jsx-runtime");
12839
- function NotionToolbarFloating({ ExpandImgIconClickHAndler, tNotionLike, commonFns, customIcons }) {
12835
+ function NotionToolbarFloating({ tNotionLike, commonFns, customIcons }) {
12840
12836
  const { editor } = useTiptapEditor();
12841
12837
  const isMobile = useIsBreakpoint("max", 480);
12842
12838
  const { lockDragHandle, commentInputVisible } = useUiEditorState(editor);
@@ -12857,7 +12853,7 @@ function NotionToolbarFloating({ ExpandImgIconClickHAndler, tNotionLike, commonF
12857
12853
  /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(MarkButton, { type: "code", hideWhenUnavailable: true, tNotionLike })
12858
12854
  ] }),
12859
12855
  /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(ToolbarSeparator, {}),
12860
- /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(ToolbarGroup, { children: /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(ImageNodeFloating, { ExpandImgIconClickHAndler, tNotionLike, commonFns, customIcons }) }),
12856
+ /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(ToolbarGroup, { children: /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(ImageNodeFloating, { tNotionLike, commonFns, customIcons }) }),
12861
12857
  /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(ToolbarGroup, { children: /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(VideoNodeFloating, { tNotionLike }) }),
12862
12858
  /* @__PURE__ */ (0, import_jsx_runtime112.jsxs)(ToolbarGroup, { children: [
12863
12859
  /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(LinkPopover, { autoOpenOnLinkActive: false, hideWhenUnavailable: true, tNotionLike }),
@@ -19545,10 +19541,11 @@ function ImageNodeView(props) {
19545
19541
  const { editor, node, updateAttributes, getPos } = props;
19546
19542
  const hasContent = node.content.size > 0;
19547
19543
  const { commonFns } = (0, import_react198.useContext)(import_react199.EditorContext);
19544
+ console.log("\u{1F680} ~ ImageNodeView ~ commonFns:", commonFns);
19548
19545
  if (!commonFns) {
19549
19546
  console.error("ImageNodeView :: commonFns NOT PROVIDED !!!!");
19550
19547
  }
19551
- const { getFileUrl, ExpandImgIconClickHAndler } = commonFns || {};
19548
+ const { getFileUrl } = commonFns || {};
19552
19549
  return /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(
19553
19550
  ResizableImage,
19554
19551
  {
@@ -19574,7 +19571,6 @@ function ImageNodeView(props) {
19574
19571
  },
19575
19572
  onUpdateAttributes: updateAttributes,
19576
19573
  getPos,
19577
- ExpandImgIconClickHAndler,
19578
19574
  commonFns
19579
19575
  }
19580
19576
  );
@@ -19595,7 +19591,6 @@ var ResizableImage = ({
19595
19591
  onImageResize,
19596
19592
  onUpdateAttributes,
19597
19593
  getPos,
19598
- ExpandImgIconClickHAndler,
19599
19594
  commonFns
19600
19595
  }) => {
19601
19596
  const [width, setWidth] = (0, import_react198.useState)(initialWidth);
@@ -20173,7 +20168,7 @@ CloseIcon.displayName = "CloseIcon";
20173
20168
 
20174
20169
  // src/components/tiptap-node/image-upload-node/image-upload-node.tsx
20175
20170
  var import_jsx_runtime136 = require("react/jsx-runtime");
20176
- function useFileUpload(options, commonFns) {
20171
+ function useFileUpload(options) {
20177
20172
  const [fileItems, setFileItems] = (0, import_react202.useState)([]);
20178
20173
  const fileItemsRef = (0, import_react202.useRef)(fileItems);
20179
20174
  fileItemsRef.current = fileItems;
@@ -20240,8 +20235,7 @@ function useFileUpload(options, commonFns) {
20240
20235
  } else {
20241
20236
  console.error("abortController.signal.aborted !!");
20242
20237
  }
20243
- },
20244
- commonFns
20238
+ }
20245
20239
  );
20246
20240
  return null;
20247
20241
  } catch (error) {
@@ -20265,7 +20259,7 @@ function useFileUpload(options, commonFns) {
20265
20259
  options.onError?.(new Error(`Maximum ${options.limit} file${options.limit === 1 ? "" : "s"} allowed`));
20266
20260
  return [];
20267
20261
  }
20268
- const uploadPromises = files.map((file) => uploadFile(file, commonFns));
20262
+ const uploadPromises = files.map((file) => uploadFile(file));
20269
20263
  const results = await Promise.all(uploadPromises);
20270
20264
  return results.filter((imgInfos) => imgInfos !== null);
20271
20265
  };
@@ -20482,7 +20476,8 @@ var ImageUploadNode = (props) => {
20482
20476
  onError: extension.options.onError
20483
20477
  };
20484
20478
  const { commonFns } = (0, import_react202.useContext)(import_react203.EditorContext);
20485
- const { fileItems, uploadFiles, removeFileItem, clearAllFiles } = useFileUpload(uploadOptions, commonFns);
20479
+ console.log("\u{1F680} ~ ImageUploadNode ~ commonFns:", commonFns);
20480
+ const { fileItems, uploadFiles, removeFileItem, clearAllFiles } = useFileUpload(uploadOptions);
20486
20481
  const handleUpload = async (files) => {
20487
20482
  const imgsInfos = await uploadFiles(files);
20488
20483
  if (imgsInfos.length > 0) {
@@ -20863,11 +20858,12 @@ var useNotionLikeExtensions = (args) => {
20863
20858
  withVideo = true,
20864
20859
  setTocContent,
20865
20860
  ignore,
20866
- customExtensions = []
20861
+ customExtensions = [],
20862
+ commonFns
20867
20863
  } = args;
20868
20864
  const editable = Boolean(isEditable);
20869
20865
  const localHandleImageUpload = (0, import_react206.useCallback)(
20870
- async (file, fileId, onProgress, abortSignal, onDoneCb, commonFns) => {
20866
+ async (file, fileId, onProgress, abortSignal, onDoneCb) => {
20871
20867
  if (!file) {
20872
20868
  throw new Error("No file provided");
20873
20869
  }
@@ -21115,8 +21111,6 @@ function EditorProvider(props) {
21115
21111
  width,
21116
21112
  height,
21117
21113
  extraStyle,
21118
- // setMenuBarGetter,
21119
- // mentionList,
21120
21114
  isEditable = true,
21121
21115
  withImages = true,
21122
21116
  initialContent = "",
@@ -21135,7 +21129,6 @@ function EditorProvider(props) {
21135
21129
  showToCInBookPages,
21136
21130
  customExtensions,
21137
21131
  customIcons
21138
- // withStatus,
21139
21132
  } = props;
21140
21133
  const { setTocContent } = useToc();
21141
21134
  const { t: tBook } = (0, import_react_i18next8.useTranslation)("book" /* book */);
@@ -21153,9 +21146,6 @@ function EditorProvider(props) {
21153
21146
  onDestroyTimerLockRef,
21154
21147
  isLinkRemovalRef,
21155
21148
  fileReUploadIsOnRef,
21156
- // svgs,
21157
- // t,
21158
- // setVideoUrlDialogData,
21159
21149
  getFileUrl,
21160
21150
  setGetEditorContent,
21161
21151
  getEditorRef,
@@ -21163,8 +21153,8 @@ function EditorProvider(props) {
21163
21153
  ExpandImgIconClickHAndler,
21164
21154
  tNotionLike,
21165
21155
  commonFns
21166
- // isPasteEventRef
21167
21156
  } = getInchangeableProps();
21157
+ const { getUpdatedProseMirrorViewVars, urlToFile, ...restCommonFns } = commonFns;
21168
21158
  const extensions = useNotionLikeExtensions_default({
21169
21159
  isEditable,
21170
21160
  withImages,
@@ -21173,7 +21163,8 @@ function EditorProvider(props) {
21173
21163
  withTables,
21174
21164
  withVideo,
21175
21165
  setTocContent,
21176
- customExtensions
21166
+ customExtensions,
21167
+ commonFns: restCommonFns
21177
21168
  });
21178
21169
  const imageIndexRef = (0, import_react208.useRef)(0);
21179
21170
  const transformNode = (args) => {
@@ -21240,7 +21231,7 @@ function EditorProvider(props) {
21240
21231
  const selection = bookmark.resolve(view.state.doc);
21241
21232
  setTimeout(
21242
21233
  ({ sel, frag, v }) => {
21243
- let { newDispatch, newTr } = commonFns.getUpdatedProseMirrorViewVars(v);
21234
+ let { newDispatch, newTr } = getUpdatedProseMirrorViewVars(v);
21244
21235
  const { from, to } = sel;
21245
21236
  newDispatch(newTr.replaceRange(from, to, frag).scrollIntoView());
21246
21237
  },
@@ -21298,7 +21289,7 @@ function EditorProvider(props) {
21298
21289
  if (slice.content.size === 0 && fileImages.length) {
21299
21290
  setTimeout(
21300
21291
  (blobs) => {
21301
- let { newDispatch, newTr } = commonFns.getUpdatedProseMirrorViewVars(view);
21292
+ let { newDispatch, newTr } = getUpdatedProseMirrorViewVars(view);
21302
21293
  const { schema: schema2 } = editorRef.current;
21303
21294
  let tr;
21304
21295
  if (blobs.length === 1) {
@@ -21338,7 +21329,7 @@ function EditorProvider(props) {
21338
21329
  const isFile = htmImg instanceof File;
21339
21330
  if (!isFile) {
21340
21331
  const { src } = htmImg;
21341
- commonFns.urlToFile(src, `pasted-${hiIndex}.png`, (err, imf) => {
21332
+ urlToFile(src, `pasted-${hiIndex}.png`, (err, imf) => {
21342
21333
  if (err) {
21343
21334
  console.error("handlePaste.urlToFile.cb ~ err : ", err);
21344
21335
  } else {
@@ -21576,18 +21567,17 @@ function EditorProvider(props) {
21576
21567
  ...extraStyle
21577
21568
  },
21578
21569
  children: [
21579
- /* @__PURE__ */ (0, import_jsx_runtime138.jsxs)(import_react209.EditorContext.Provider, { value: { editor, commonFns: { getFileUrl } }, children: [
21570
+ /* @__PURE__ */ (0, import_jsx_runtime138.jsxs)(import_react209.EditorContext.Provider, { value: { editor, commonFns: { ...restCommonFns, getFileUrl, ExpandImgIconClickHAndler } }, children: [
21580
21571
  /* @__PURE__ */ (0, import_jsx_runtime138.jsx)(
21581
21572
  EditorContentArea,
21582
21573
  {
21583
21574
  mentionListRef,
21584
- ExpandImgIconClickHAndler,
21585
21575
  tNotionLike,
21586
- commonFns,
21576
+ commonFns: restCommonFns,
21587
21577
  customIcons
21588
21578
  }
21589
21579
  ),
21590
- withToc && showToCInBookPages ? /* @__PURE__ */ (0, import_jsx_runtime138.jsx)(TocSidebar, { topOffset: 48, commonFns }) : "",
21580
+ withToc && showToCInBookPages ? /* @__PURE__ */ (0, import_jsx_runtime138.jsx)(TocSidebar, { topOffset: 48, commonFns: restCommonFns }) : "",
21591
21581
  /* @__PURE__ */ (0, import_jsx_runtime138.jsx)(TableExtendRowColumnButtons, {}),
21592
21582
  /* @__PURE__ */ (0, import_jsx_runtime138.jsx)(TableHandle, { tNotionLike }),
21593
21583
  /* @__PURE__ */ (0, import_jsx_runtime138.jsx)(
@@ -21632,7 +21622,7 @@ function LoadingSpinner({ text = "Connecting..." }) {
21632
21622
  /* @__PURE__ */ (0, import_jsx_runtime139.jsx)("div", { className: "spinner-loading-text", children: text })
21633
21623
  ] }) });
21634
21624
  }
21635
- function EditorContentArea({ mentionListRef, ExpandImgIconClickHAndler, tNotionLike, commonFns, customIcons }) {
21625
+ function EditorContentArea({ mentionListRef, tNotionLike, commonFns, customIcons }) {
21636
21626
  const { editor } = (0, import_react210.useContext)(import_react211.EditorContext);
21637
21627
  const { isDragging } = useUiEditorState(editor);
21638
21628
  useScrollToHash();
@@ -21653,9 +21643,9 @@ function EditorContentArea({ mentionListRef, ExpandImgIconClickHAndler, tNotionL
21653
21643
  /* @__PURE__ */ (0, import_jsx_runtime139.jsx)(EmojiDropdownMenu, {}),
21654
21644
  /* @__PURE__ */ (0, import_jsx_runtime139.jsx)(MentionDropdownMenu, { mentionListRef }),
21655
21645
  /* @__PURE__ */ (0, import_jsx_runtime139.jsx)(SlashDropdownMenu, { commonFns }),
21656
- /* @__PURE__ */ (0, import_jsx_runtime139.jsx)(NotionToolbarFloating, { ExpandImgIconClickHAndler, tNotionLike, commonFns, customIcons }),
21646
+ /* @__PURE__ */ (0, import_jsx_runtime139.jsx)(NotionToolbarFloating, { tNotionLike, commonFns, customIcons }),
21657
21647
  (0, import_react_dom.createPortal)(
21658
- /* @__PURE__ */ (0, import_jsx_runtime139.jsx)(MobileToolbar, { ExpandImgIconClickHAndler, tNotionLike, commonFns, customIcons }),
21648
+ /* @__PURE__ */ (0, import_jsx_runtime139.jsx)(MobileToolbar, { tNotionLike, commonFns, customIcons }),
21659
21649
  document.body
21660
21650
  )
21661
21651
  ]