@edifice.io/react 2.6.8 → 2.6.9-chore-tiptap-v3.20261013175230

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.
Files changed (37) hide show
  1. package/dist/editor.js +2 -0
  2. package/dist/homepage.js +2 -1
  3. package/dist/modules/editor/components/BubbleMenuEditImage/BubbleMenuEditImage.js +97 -90
  4. package/dist/modules/editor/components/BubbleMenuEditInformationPane/BubbleMenuEditInformationPane.js +111 -95
  5. package/dist/modules/editor/components/EditorToolbar/EditorToolbar.Typography.js +3 -3
  6. package/dist/modules/editor/components/EditorToolbar/EditorToolbar.js +6 -4
  7. package/dist/modules/editor/components/Toolbar/LinkToolbar.FloatingOptions.js +12 -0
  8. package/dist/modules/editor/components/Toolbar/LinkToolbar.js +5 -4
  9. package/dist/modules/editor/components/Toolbar/TableToolbar.js +11 -5
  10. package/dist/modules/editor/hooks/index.d.ts +1 -0
  11. package/dist/modules/editor/hooks/useCommentEditor.d.ts +1 -1
  12. package/dist/modules/editor/hooks/useCommentEditor.js +12 -4
  13. package/dist/modules/editor/hooks/useEditorState.d.ts +20 -0
  14. package/dist/modules/editor/hooks/useEditorState.js +16 -0
  15. package/dist/modules/editor/hooks/useTipTapEditor.d.ts +1 -1
  16. package/dist/modules/editor/hooks/useTipTapEditor.js +64 -24
  17. package/dist/modules/homepage/components/Communities/Communities.d.ts +2 -1
  18. package/dist/modules/homepage/components/Communities/Communities.js +14 -13
  19. package/dist/modules/homepage/components/Communities/CommunitiesContainer.d.ts +1 -1
  20. package/dist/modules/homepage/components/Communities/CommunitiesContainer.js +9 -5
  21. package/dist/modules/homepage/components/Communities/CommunitiesSkeleton.js +4 -7
  22. package/dist/modules/homepage/components/Communities/useCommunities.d.ts +4 -1
  23. package/dist/modules/homepage/components/Communities/useCommunities.js +8 -3
  24. package/dist/modules/homepage/components/HomeCard/HomeCardHeader.js +2 -2
  25. package/dist/modules/multimedia/MediaLibrary/MediaLibrary.d.ts +2 -0
  26. package/dist/modules/multimedia/MediaLibrary/MediaLibrary.js +2 -0
  27. package/dist/modules/multimedia/MediaLibrary/MediaLibraryContext.d.ts +4 -0
  28. package/dist/modules/multimedia/MediaLibrary/innertabs/Upload.js +2 -1
  29. package/dist/modules/multimedia/MediaLibrary/innertabs/Workspace.js +3 -0
  30. package/dist/node_modules/.pnpm/@tiptap_extension-floating-menu@3.32.0_@floating-ui_dom@1.6.0_@tiptap_core@3.32.0_@tiptap_pm@3.32.0__@tiptap_pm@3.32.0/node_modules/@tiptap/extension-floating-menu/dist/index.js +159 -0
  31. package/dist/node_modules/.pnpm/@tiptap_react@3.32.0_@floating-ui_dom@1.6.0_@tiptap_core@3.32.0_@tiptap_pm@3.32.0__@tiptap_pm_6inmb43gajy4fnlwtngbwkv7um/node_modules/@tiptap/react/dist/menus/index.js +341 -0
  32. package/dist/node_modules/.pnpm/prosemirror-model@1.25.12/node_modules/prosemirror-model/dist/index.js +419 -0
  33. package/dist/node_modules/.pnpm/prosemirror-state@1.4.4/node_modules/prosemirror-state/dist/index.js +489 -0
  34. package/dist/node_modules/.pnpm/prosemirror-transform@1.12.2/node_modules/prosemirror-transform/dist/index.js +607 -0
  35. package/package.json +35 -43
  36. package/dist/modules/editor/components/Toolbar/LinkToolbar.TippyOptions.d.ts +0 -2
  37. package/dist/modules/editor/components/Toolbar/LinkToolbar.TippyOptions.js +0 -8
@@ -1,6 +1,7 @@
1
1
  export * from './useActionOptions';
2
2
  export * from './useCommentEditor';
3
3
  export * from './useEditorContext';
4
+ export * from './useEditorState';
4
5
  export * from './useImageModal';
5
6
  export * from './useImageSelection';
6
7
  export * from './useLinkToolbar';
@@ -6,7 +6,7 @@ import { Content, HTMLContent } from '@tiptap/react';
6
6
  * @param content default rich content
7
7
  */
8
8
  export declare const useCommentEditor: (editable: boolean, content: Content, maxLength?: number) => {
9
- editor: import('@tiptap/core').Editor | null;
9
+ editor: import('@tiptap/core').Editor;
10
10
  commentLength: number;
11
11
  getComment: () => HTMLContent;
12
12
  resetComment: () => void;
@@ -1,14 +1,22 @@
1
1
  import { useState, useEffect } from "react";
2
2
  import { Hyperlink } from "@edifice.io/tiptap-extensions/hyperlink";
3
- import CharacterCount from "@tiptap/extension-character-count";
3
+ import { CharacterCount } from "@tiptap/extensions";
4
4
  import { useEditor } from "@tiptap/react";
5
5
  import StarterKit from "@tiptap/starter-kit";
6
6
  const useCommentEditor = (editable, content, maxLength = 800) => {
7
7
  const [commentLength, setCommentLength] = useState(0), editor = useEditor({
8
8
  editable,
9
- extensions: [StarterKit, Hyperlink, CharacterCount.configure({
10
- limit: maxLength
11
- })],
9
+ extensions: [
10
+ // v3's StarterKit bundles its own 'link' mark, which would compete with
11
+ // Hyperlink below for the same <a> tags. Disabled.
12
+ StarterKit.configure({
13
+ link: !1
14
+ }),
15
+ Hyperlink,
16
+ CharacterCount.configure({
17
+ limit: maxLength
18
+ })
19
+ ],
12
20
  content
13
21
  });
14
22
  return useEffect(() => {
@@ -0,0 +1,20 @@
1
+ import { Editor } from '@tiptap/react';
2
+ /**
3
+ * Hook to track editor state changes in Tiptap v3.
4
+ * Replaces the pattern of using `editor?.state` in useEffect dependencies.
5
+ *
6
+ * @param editor - The Tiptap editor instance
7
+ * @returns A counter that increments on each editor update
8
+ *
9
+ * @example
10
+ * ```tsx
11
+ * const { editor } = useEditorContext();
12
+ * const editorState = useEditorState(editor);
13
+ *
14
+ * useEffect(() => {
15
+ * const attrs = editor?.getAttributes('textStyle');
16
+ * // ... do something with attrs
17
+ * }, [editor, editorState]);
18
+ * ```
19
+ */
20
+ export declare const useEditorState: (editor: Editor | null | undefined) => number;
@@ -0,0 +1,16 @@
1
+ import { useState, useEffect } from "react";
2
+ const useEditorState = (editor) => {
3
+ const [updateCount, setUpdateCount] = useState(0);
4
+ return useEffect(() => {
5
+ if (!editor) return;
6
+ const handleUpdate = () => {
7
+ setUpdateCount((prev) => prev + 1);
8
+ };
9
+ return editor.on("transaction", handleUpdate), () => {
10
+ editor.off("transaction", handleUpdate);
11
+ };
12
+ }, [editor]), updateCount;
13
+ };
14
+ export {
15
+ useEditorState
16
+ };
@@ -15,6 +15,6 @@ import { WorkspaceVisibility } from '@edifice.io/client';
15
15
  export declare const useTipTapEditor: (editable: boolean, content: Content, focus?: FocusPosition, placeholder?: string, onContentChange?: ({ editor }: {
16
16
  editor: any;
17
17
  }) => void, visibility?: WorkspaceVisibility, extensions?: Extensions) => {
18
- editor: import('@tiptap/core').Editor | null;
18
+ editor: import('@tiptap/core').Editor;
19
19
  editable: boolean;
20
20
  };
@@ -9,18 +9,14 @@ import { SpeechSynthesis } from "@edifice.io/tiptap-extensions/speech-synthesis"
9
9
  import { TableCell } from "@edifice.io/tiptap-extensions/table-cell";
10
10
  import { Mathematics } from "@tiptap/extension-mathematics";
11
11
  import Color from "@tiptap/extension-color";
12
- import Focus from "@tiptap/extension-focus";
13
12
  import FontFamily from "@tiptap/extension-font-family";
14
- import Placeholder from "@tiptap/extension-placeholder";
13
+ import { TextStyleKit } from "@tiptap/extension-text-style";
14
+ import { Focus, Placeholder } from "@tiptap/extensions";
15
15
  import Subscript from "@tiptap/extension-subscript";
16
16
  import Superscript from "@tiptap/extension-superscript";
17
- import Table from "@tiptap/extension-table";
18
- import TableHeader from "@tiptap/extension-table-header";
19
- import TableRow from "@tiptap/extension-table-row";
17
+ import { TableRow, TableHeader, Table } from "@tiptap/extension-table";
20
18
  import TextAlign from "@tiptap/extension-text-align";
21
- import TextStyle from "@tiptap/extension-text-style";
22
19
  import Typography from "@tiptap/extension-typography";
23
- import Underline from "@tiptap/extension-underline";
24
20
  import { useEditor } from "@tiptap/react";
25
21
  import StarterKit from "@tiptap/starter-kit";
26
22
  import { useTranslation } from "react-i18next";
@@ -50,22 +46,64 @@ const useTipTapEditor = (editable, content, focus, placeholder, onContentChange,
50
46
  // TipTap editor must be instantiated in editable mode for table columns to be resizable.
51
47
  // It will then be set in the correct editable mode, by a useEffect below.
52
48
  editable: !0,
53
- extensions: [StarterKit, Focus.configure({
54
- className: "has-focus",
55
- mode: "all"
56
- }), Placeholder.configure({
57
- placeholder: t(placeholder || "tiptap.placeholder")
58
- }), CustomHighlight.configure({
59
- multicolor: !0
60
- }), Underline, TextStyle, Color, Subscript, Superscript, Table.configure({
61
- resizable: !0
62
- }), TableRow, TableHeader, TableCell, TextAlign.configure({
63
- types: ["heading", "paragraph", "video", "audio", "iframe"]
64
- }), CustomHeading.configure({
65
- levels: [1, 2]
66
- }), Typography, FontSize, SpeechRecognition, SpeechSynthesis.configure({
67
- lang: (currentLanguage == null ? void 0 : currentLanguage.length) === 2 ? `${currentLanguage}-${currentLanguage.toUpperCase()}` : "fr-FR"
68
- }), Hyperlink, FontFamily, Mathematics, Alert, IframeNodeView(MediaRenderer), VideoNodeView(MediaRenderer), AudioNodeView(AudioRenderer), LinkerNodeView(LinkerRenderer), ImageNodeView(MediaRenderer, uploadFile), AttachmentNodeView(AttachmentRenderer), InformationPaneNodeView(InformationPaneRenderer), ...extensions || []],
49
+ extensions: [
50
+ // v3's StarterKit bundles its own heading/link nodes, which would compete with
51
+ // CustomHeading/Hyperlink below for the same HTML tags. Disabled.
52
+ StarterKit.configure({
53
+ heading: !1,
54
+ link: !1
55
+ }),
56
+ Focus.configure({
57
+ className: "has-focus",
58
+ mode: "all"
59
+ }),
60
+ Placeholder.configure({
61
+ placeholder: t(placeholder || "tiptap.placeholder")
62
+ }),
63
+ CustomHighlight.configure({
64
+ multicolor: !0
65
+ }),
66
+ // v3's TextStyleKit bundles its own color/fontFamily/fontSize, which would
67
+ // duplicate the Color/FontFamily/FontSize added below. Disabled.
68
+ TextStyleKit.configure({
69
+ color: !1,
70
+ fontFamily: !1,
71
+ fontSize: !1
72
+ }),
73
+ Color,
74
+ Subscript,
75
+ Superscript,
76
+ Table.configure({
77
+ resizable: !0
78
+ }),
79
+ TableRow,
80
+ TableHeader,
81
+ TableCell,
82
+ TextAlign.configure({
83
+ types: ["heading", "paragraph", "video", "audio", "iframe"]
84
+ }),
85
+ CustomHeading.configure({
86
+ levels: [1, 2]
87
+ }),
88
+ Typography,
89
+ FontSize,
90
+ SpeechRecognition,
91
+ SpeechSynthesis.configure({
92
+ lang: (currentLanguage == null ? void 0 : currentLanguage.length) === 2 ? `${currentLanguage}-${currentLanguage.toUpperCase()}` : "fr-FR"
93
+ }),
94
+ Hyperlink,
95
+ FontFamily,
96
+ Mathematics,
97
+ Alert,
98
+ IframeNodeView(MediaRenderer),
99
+ VideoNodeView(MediaRenderer),
100
+ AudioNodeView(AudioRenderer),
101
+ LinkerNodeView(LinkerRenderer),
102
+ ImageNodeView(MediaRenderer, uploadFile),
103
+ AttachmentNodeView(AttachmentRenderer),
104
+ InformationPaneNodeView(InformationPaneRenderer),
105
+ ...extensions || []
106
+ ],
69
107
  content,
70
108
  // If the onContentChange callback is provided, we call it on every content change.
71
109
  ...onContentChange ? {
@@ -75,7 +113,9 @@ const useTipTapEditor = (editable, content, focus, placeholder, onContentChange,
75
113
  return useEffect(() => {
76
114
  editor == null || editor.setEditable(editable, !1);
77
115
  }, [editor, editable]), useEffect(() => {
78
- editor == null || editor.commands.setContent(content);
116
+ editor == null || editor.commands.setContent(content, {
117
+ emitUpdate: !1
118
+ });
79
119
  }, [content]), useEffect(() => {
80
120
  focus && (editor == null || editor.commands.focus(focus));
81
121
  }, [editor, focus, editable]), {
@@ -2,9 +2,10 @@ import { CommunityItemProps } from './CommunityItem';
2
2
  export interface CommunitiesProps {
3
3
  communitiesList?: CommunityItemProps[];
4
4
  handleActionClick: () => void;
5
+ canCreateCommunity?: boolean;
5
6
  }
6
7
  declare const Communities: {
7
- ({ communitiesList, handleActionClick, }: CommunitiesProps): import("react/jsx-runtime").JSX.Element;
8
+ ({ communitiesList, handleActionClick, canCreateCommunity, }: CommunitiesProps): import("react/jsx-runtime").JSX.Element;
8
9
  displayName: string;
9
10
  };
10
11
  export default Communities;
@@ -1,32 +1,33 @@
1
- import { jsxs, jsx } from "react/jsx-runtime";
1
+ import { jsxs, jsx, Fragment } from "react/jsx-runtime";
2
2
  import illuCommunities from "@edifice.io/bootstrap/dist/images/homepage/illu-communities.svg";
3
- import { useMeasure } from "@uidotdev/usehooks";
4
3
  import { useTranslation } from "react-i18next";
5
4
  import SvgIconArrowRight from "../../../icons/components/IconArrowRight.js";
6
5
  import CommunityItem from "./CommunityItem.js";
7
6
  import HomeCard from "../HomeCard/HomeCard.js";
8
7
  import Flex from "../../../../components/Flex/Flex.js";
9
8
  import Image from "../../../../components/Image/Image.js";
10
- const NARROW_CONTAINER_WIDTH = 800, MAX_ITEMS = 4, MAX_ITEMS_NARROW = 3, Communities = ({
9
+ const Communities = ({
11
10
  communitiesList = [],
12
- handleActionClick
11
+ handleActionClick,
12
+ canCreateCommunity = !1
13
13
  }) => {
14
14
  const {
15
15
  t
16
- } = useTranslation(), [containerRef, {
17
- width
18
- }] = useMeasure(), maxItems = width !== null && width < NARROW_CONTAINER_WIDTH ? MAX_ITEMS_NARROW : MAX_ITEMS, visibleCommunities = communitiesList.slice(0, maxItems), itemWidth = `${100 / maxItems}%`;
16
+ } = useTranslation();
19
17
  return /* @__PURE__ */ jsxs(HomeCard, { variant: "primary", children: [
20
- /* @__PURE__ */ jsx(HomeCard.Header, { actionLabel: communitiesList.length > 0 ? t("homepage.communities.actionLabel.seeMore") : t("homepage.communities.actionLabel.create"), actionRightIcon: /* @__PURE__ */ jsx(SvgIconArrowRight, {}), onActionClick: handleActionClick, title: t("homepage.communities.title") }),
21
- /* @__PURE__ */ jsx(HomeCard.Content, { children: /* @__PURE__ */ jsx(Flex, { ref: containerRef, gap: "16", children: visibleCommunities.length > 0 ? visibleCommunities.map((community, index) => /* @__PURE__ */ jsx(CommunityItem, { title: community.title, communityImage: community.communityImage, onActionClick: community.onActionClick, nbNotifications: community.nbNotifications, width: itemWidth }, index)) : /* @__PURE__ */ jsxs("div", { className: "communities-empty", children: [
18
+ /* @__PURE__ */ jsx(HomeCard.Header, { actionLabel: communitiesList.length > 0 || !canCreateCommunity ? t("homepage.communities.actionLabel.seeMore", "Voir plus") : t("homepage.communities.actionLabel.create", "Créer une communauté"), actionRightIcon: /* @__PURE__ */ jsx(SvgIconArrowRight, {}), onActionClick: handleActionClick, title: t("homepage.communities.title", "Mes communautés") }),
19
+ /* @__PURE__ */ jsx(HomeCard.Content, { className: "communities-content", children: /* @__PURE__ */ jsx(Flex, { gap: "16", children: communitiesList.length > 0 ? /* @__PURE__ */ jsx("div", { className: "communities-list", children: communitiesList.map((community, index) => /* @__PURE__ */ jsx(CommunityItem, { title: community.title, communityImage: community.communityImage, onActionClick: community.onActionClick, nbNotifications: community.nbNotifications, width: "auto" }, index)) }) : /* @__PURE__ */ jsxs("div", { className: "communities-empty", children: [
22
20
  /* @__PURE__ */ jsx(Image, { src: illuCommunities, alt: "", "aria-hidden": "true", style: {
23
21
  width: 80,
24
22
  height: 80
25
23
  } }),
26
- /* @__PURE__ */ jsxs("div", { className: "communities-empty-content", children: [
27
- /* @__PURE__ */ jsx("p", { className: "communities-empty-title", children: t("homepage.communities.subtitle", "Créez votre première communauté pour animer votre classe !") }),
28
- /* @__PURE__ */ jsx("p", { className: "communities-empty-description", children: t("homepage.communities.description", "Vous pouvez centraliser et organiser les documents et les ressources pour vos élèves.") })
29
- ] })
24
+ /* @__PURE__ */ jsx("div", { className: "communities-empty-content", children: canCreateCommunity ? /* @__PURE__ */ jsxs(Fragment, { children: [
25
+ /* @__PURE__ */ jsx("p", { className: "communities-empty-title", children: t("homepage.communities.subtitle.teacher", "Réunissez vos élèves avec Communautés !") }),
26
+ /* @__PURE__ */ jsx("p", { className: "communities-empty-description", children: t("homepage.communities.description.teacher", "Centralisez et organisez les documents et les ressources pour vos groupes d'élèves.") })
27
+ ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
28
+ /* @__PURE__ */ jsx("p", { className: "communities-empty-title", children: t("homepage.communities.subtitle.student", "Retrouvez toutes vos communautés ici ! ") }),
29
+ /* @__PURE__ */ jsx("p", { className: "communities-empty-description", children: t("homepage.communities.description.student", `Consultez l'onglet "Nouveaux partages" pour découvrir si vous avez été ajouté à une nouvelle communauté.`) })
30
+ ] }) })
30
31
  ] }) }) })
31
32
  ] });
32
33
  };
@@ -5,7 +5,7 @@ export type CommunitiesContainerProps = {
5
5
  /** Handle a click on the header action button. If undefined, communities (or the community creation flow) will be opened. */
6
6
  onHeaderActionClick?: () => void;
7
7
  };
8
- export declare function CommunitiesContainer({ onCommunityClick: handleCommunityClick, onHeaderActionClick: handleHeaderActionClick, }: CommunitiesContainerProps): import("react/jsx-runtime").JSX.Element | "An error occurred while loading communities.";
8
+ export declare function CommunitiesContainer({ onCommunityClick: handleCommunityClick, onHeaderActionClick: handleHeaderActionClick, }: CommunitiesContainerProps): import("react/jsx-runtime").JSX.Element | "An error occurred while loading communities." | null;
9
9
  export declare namespace CommunitiesContainer {
10
10
  var displayName: string;
11
11
  }
@@ -3,28 +3,32 @@ import { useCallback, useMemo } from "react";
3
3
  import Communities from "./Communities.js";
4
4
  import CommunitiesSkeleton from "./CommunitiesSkeleton.js";
5
5
  import { useCommunities } from "./useCommunities.js";
6
+ import useHasWorkflow from "../../../../hooks/useHasWorkflow/useHasWorkflow.js";
7
+ const COMMUNITY_ACCESS_WORKFLOW = "community.access", COMMUNITY_CREATE_WORKFLOW = "community.create", COMMUNITY_WORKFLOWS = [COMMUNITY_ACCESS_WORKFLOW, COMMUNITY_CREATE_WORKFLOW];
6
8
  function CommunitiesContainer({
7
9
  onCommunityClick: handleCommunityClick = (community) => {
8
10
  window.open(`/communities/id/${community.id}/home`, "_self");
9
11
  },
10
12
  onHeaderActionClick: handleHeaderActionClick
11
13
  }) {
12
- const {
14
+ const rights = useHasWorkflow(COMMUNITY_WORKFLOWS), canCreateCommunity = (rights == null ? void 0 : rights[COMMUNITY_CREATE_WORKFLOW]) === !0, hasCommunitiesRight = canCreateCommunity || (rights == null ? void 0 : rights[COMMUNITY_ACCESS_WORKFLOW]) === !0, {
13
15
  communities,
14
16
  isLoading,
15
17
  error
16
- } = useCommunities(), handleActionClick = useCallback(() => {
18
+ } = useCommunities({
19
+ enabled: hasCommunitiesRight
20
+ }), handleActionClick = useCallback(() => {
17
21
  if (handleHeaderActionClick) {
18
22
  handleHeaderActionClick();
19
23
  return;
20
24
  }
21
- window.open(communities.length > 0 ? "/communities" : "/communities/create/step-type", "_self");
22
- }, [handleHeaderActionClick, communities.length]), mappedCommunities = useMemo(() => communities.map((community) => ({
25
+ window.open(communities.length === 0 && canCreateCommunity ? "/communities/create/step-type" : "/communities", "_self");
26
+ }, [handleHeaderActionClick, communities.length, canCreateCommunity]), mappedCommunities = useMemo(() => communities.map((community) => ({
23
27
  title: community.title,
24
28
  communityImage: community.image ?? "",
25
29
  onActionClick: () => handleCommunityClick(community)
26
30
  })), [communities, handleCommunityClick]);
27
- return isLoading ? /* @__PURE__ */ jsx(CommunitiesSkeleton, {}) : error ? "An error occurred while loading communities." : /* @__PURE__ */ jsx(Communities, { communitiesList: mappedCommunities, handleActionClick });
31
+ return rights === void 0 || isLoading ? /* @__PURE__ */ jsx(CommunitiesSkeleton, {}) : hasCommunitiesRight ? error ? "An error occurred while loading communities." : /* @__PURE__ */ jsx(Communities, { communitiesList: mappedCommunities, handleActionClick, canCreateCommunity }) : null;
28
32
  }
29
33
  export {
30
34
  CommunitiesContainer
@@ -3,17 +3,14 @@ import HomeCard from "../HomeCard/HomeCard.js";
3
3
  import Flex from "../../../../components/Flex/Flex.js";
4
4
  import TextSkeleton from "../../../../components/Skeleton/TextSkeleton.js";
5
5
  import ButtonSkeleton from "../../../../components/Skeleton/ButtonSkeleton.js";
6
- const primaryTitleWidths = ["80%", "64%", "88%", "72%"], secondaryTitleWidths = ["56%", "44%", "60%", "48%"], CommunitiesSkeleton = () => /* @__PURE__ */ jsxs(HomeCard, { variant: "primary", "data-testid": "communities-skeleton", children: [
6
+ const primaryTitleWidths = ["80%", "64%", "88%", "72%", "76%", "68%"], secondaryTitleWidths = ["56%", "44%", "60%", "48%", "52%", "40%"], CommunitiesSkeleton = () => /* @__PURE__ */ jsxs(HomeCard, { variant: "primary", "data-testid": "communities-skeleton", children: [
7
7
  /* @__PURE__ */ jsxs(Flex, { align: "center", justify: "between", gap: "8", className: "home-card-header", children: [
8
8
  /* @__PURE__ */ jsx(TextSkeleton, { size: "lg", className: "col-5" }),
9
9
  /* @__PURE__ */ jsx(ButtonSkeleton, { "aria-hidden": "true", size: "sm", className: "px-24", color: "tertiary" })
10
10
  ] }),
11
- /* @__PURE__ */ jsx(HomeCard.Content, { children: /* @__PURE__ */ jsx(Flex, { gap: "16", children: primaryTitleWidths.map((primaryWidth, index) => /* @__PURE__ */ jsxs("div", { className: "communities-item", style: {
12
- width: "25%"
13
- }, "aria-hidden": "true", children: [
11
+ /* @__PURE__ */ jsx(HomeCard.Content, { className: "communities-content", children: /* @__PURE__ */ jsx(Flex, { gap: "16", children: /* @__PURE__ */ jsx("div", { className: "communities-list", children: primaryTitleWidths.map((primaryWidth, index) => /* @__PURE__ */ jsxs("div", { className: "communities-item", "aria-hidden": "true", children: [
14
12
  /* @__PURE__ */ jsx("div", { className: "communities-item-image placeholder rounded", style: {
15
- display: "block",
16
- aspectRatio: "1 / 1"
13
+ display: "block"
17
14
  } }),
18
15
  /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: "4", className: "mt-8", children: [
19
16
  /* @__PURE__ */ jsx("div", { style: {
@@ -25,7 +22,7 @@ const primaryTitleWidths = ["80%", "64%", "88%", "72%"], secondaryTitleWidths =
25
22
  alignSelf: "center"
26
23
  }, children: /* @__PURE__ */ jsx(TextSkeleton, { className: "col-12", size: "sm" }) })
27
24
  ] })
28
- ] }, primaryWidth)) }) })
25
+ ] }, primaryWidth)) }) }) })
29
26
  ] });
30
27
  export {
31
28
  CommunitiesSkeleton as default
@@ -3,7 +3,10 @@ export interface CommunitiesModel {
3
3
  title: string;
4
4
  image?: string;
5
5
  }
6
- export declare function useCommunities(): {
6
+ export declare const COMMUNITIES_PREVIEW_SIZE = 6;
7
+ export declare function useCommunities({ enabled }?: {
8
+ enabled?: boolean;
9
+ }): {
7
10
  communities: CommunitiesModel[];
8
11
  isLoading: boolean;
9
12
  error: Error | null;
@@ -1,6 +1,9 @@
1
1
  import { odeServices } from "@edifice.io/client";
2
2
  import { useQuery, queryOptions } from "@tanstack/react-query";
3
- function useCommunities() {
3
+ const COMMUNITIES_PREVIEW_SIZE = 6;
4
+ function useCommunities({
5
+ enabled = !0
6
+ } = {}) {
4
7
  const {
5
8
  data,
6
9
  isLoading,
@@ -8,11 +11,12 @@ function useCommunities() {
8
11
  } = useQuery(queryOptions({
9
12
  queryKey: ["communities", "preview"],
10
13
  queryFn: async () => {
11
- const http = odeServices.http(), response = await http.get("/communities/api/communities?page=1&size=4");
14
+ const http = odeServices.http(), response = await http.get(`/communities/api/communities?page=1&size=${COMMUNITIES_PREVIEW_SIZE}`);
12
15
  if (http.isResponseError())
13
16
  throw new Error(http.latestResponse.statusText);
14
17
  return response.items;
15
- }
18
+ },
19
+ enabled
16
20
  }));
17
21
  return {
18
22
  communities: data ?? [],
@@ -21,5 +25,6 @@ function useCommunities() {
21
25
  };
22
26
  }
23
27
  export {
28
+ COMMUNITIES_PREVIEW_SIZE,
24
29
  useCommunities
25
30
  };
@@ -13,9 +13,9 @@ const HomeCardHeader = ({
13
13
  ...rest
14
14
  }) => {
15
15
  const hasAction = !!actionLabel && !!onActionClick;
16
- return /* @__PURE__ */ jsxs(Flex, { align: "center", justify: "between", gap: "8", className: clsx("home-card-header", className), ...rest, children: [
16
+ return /* @__PURE__ */ jsxs(Flex, { align: "center", justify: "between", gap: "8", wrap: "wrap", className: clsx("home-card-header", className), ...rest, children: [
17
17
  /* @__PURE__ */ jsx("h3", { className: "home-card-header-title", children: title }),
18
- hasAction && /* @__PURE__ */ jsx(ButtonBeta, { color: "tertiary", size: "sm", variant: "ghost", onClick: onActionClick, leftIcon: actionLeftIcon, rightIcon: actionRightIcon, "data-testid": "home-card-header-action", ...actionProps, children: actionLabel })
18
+ hasAction && /* @__PURE__ */ jsx(ButtonBeta, { color: "tertiary", size: "sm", variant: "ghost", onClick: onActionClick, className: "home-card-header-action", leftIcon: actionLeftIcon, rightIcon: actionRightIcon, "data-testid": "home-card-header-action", ...actionProps, children: actionLabel })
19
19
  ] });
20
20
  };
21
21
  export {
@@ -65,6 +65,8 @@ export interface MediaLibraryProps {
65
65
  visibility: WorkspaceVisibility;
66
66
  /** Allow selecting / uploading multiple files at once ? */
67
67
  multiple?: boolean;
68
+ /** Restrict attachments to PDF files in Workspace and Upload. */
69
+ pdfOnly?: boolean;
68
70
  /**
69
71
  * Called when the user validates the modal (Add button).
70
72
  * @param result depends on which InnerTab is visible
@@ -66,6 +66,7 @@ const orderedTabs = [
66
66
  appCode,
67
67
  visibility,
68
68
  multiple,
69
+ pdfOnly,
69
70
  onSuccess,
70
71
  onCancel,
71
72
  onTabChange
@@ -199,6 +200,7 @@ const orderedTabs = [
199
200
  appCode,
200
201
  visibility,
201
202
  multiple,
203
+ pdfOnly,
202
204
  type,
203
205
  setResultCounter,
204
206
  setResult,
@@ -7,6 +7,8 @@ export declare const MediaLibraryContext: import('react').Context<{
7
7
  visibility?: WorkspaceVisibility;
8
8
  /** Allow selecting / uploading multiple files at once ? */
9
9
  multiple?: boolean;
10
+ /** Restrict attachments to PDF files in Workspace and Upload. */
11
+ pdfOnly?: boolean;
10
12
  /** Type of resource to search for. */
11
13
  type: MediaLibraryType | null;
12
14
  /** Set the counter in the success button label. */
@@ -36,6 +38,8 @@ export declare function useMediaLibraryContext(): {
36
38
  visibility?: WorkspaceVisibility;
37
39
  /** Allow selecting / uploading multiple files at once ? */
38
40
  multiple?: boolean;
41
+ /** Restrict attachments to PDF files in Workspace and Upload. */
42
+ pdfOnly?: boolean;
39
43
  /** Type of resource to search for. */
40
44
  type: MediaLibraryType | null;
41
45
  /** Set the counter in the success button label. */
@@ -36,6 +36,7 @@ const acceptedTypes = (type) => {
36
36
  t
37
37
  } = useTranslation(), {
38
38
  type,
39
+ pdfOnly,
39
40
  visibility,
40
41
  multiple,
41
42
  setResult,
@@ -60,7 +61,7 @@ const acceptedTypes = (type) => {
60
61
  /* @__PURE__ */ jsx(Radio, { label: t("bbm.upload.sort.alpha"), name: "media-library-upload-sort", value: "alpha", model: sortByAlpha ? "alpha" : "date", checked: sortByAlpha, onChange: () => setSortByAlpha(!0), "data-testid": "media-library-upload-sort-alpha" }),
61
62
  /* @__PURE__ */ jsx(Radio, { label: t("bbm.upload.sort.date"), name: "media-library-upload-sort", value: "date", model: sortByAlpha ? "alpha" : "date", checked: !sortByAlpha, onChange: () => setSortByAlpha(!1), "data-testid": "media-library-upload-sort-date" })
62
63
  ] }),
63
- /* @__PURE__ */ jsx(Dropzone, { multiple, accept: acceptedTypes(type ?? "embedder"), children: /* @__PURE__ */ jsx(UploadFiles, { onFilesChange: handleOnFilesChange, visibility }) })
64
+ /* @__PURE__ */ jsx(Dropzone, { multiple, accept: type === "attachment" && pdfOnly ? ["application/pdf"] : acceptedTypes(type ?? "embedder"), children: /* @__PURE__ */ jsx(UploadFiles, { onFilesChange: handleOnFilesChange, visibility }) })
64
65
  ] });
65
66
  };
66
67
  export {
@@ -4,6 +4,7 @@ import Workspace$1 from "../../Workspace/Workspace.js";
4
4
  const Workspace = () => {
5
5
  const {
6
6
  type,
7
+ pdfOnly,
7
8
  setResultCounter,
8
9
  setResult,
9
10
  multiple,
@@ -17,6 +18,8 @@ const Workspace = () => {
17
18
  return "audio";
18
19
  case "video":
19
20
  return "video";
21
+ case "attachment":
22
+ return pdfOnly ? "pdf" : null;
20
23
  default:
21
24
  return null;
22
25
  }