@capytale/meta-player 0.9.11 → 0.10.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.
Files changed (110) hide show
  1. package/.prettierrc.json +4 -4
  2. package/LICENSE +674 -674
  3. package/README.md +12 -12
  4. package/eslint.config.js +28 -28
  5. package/index.html +15 -15
  6. package/package.json +60 -60
  7. package/public/themes/lara-dark-blue/theme.css +7015 -7015
  8. package/public/themes/lara-light-blue/theme.css +7005 -7005
  9. package/src/App.tsx +145 -140
  10. package/src/AppRedux.css +39 -39
  11. package/src/MetaPlayer.tsx +168 -168
  12. package/src/activityJs.ts +7 -7
  13. package/src/app/createAppSlice.ts +6 -6
  14. package/src/app/hooks.ts +12 -12
  15. package/src/app/store.ts +52 -52
  16. package/src/app.module.scss +80 -80
  17. package/src/demo.tsx +87 -87
  18. package/src/external/prime.ts +5 -5
  19. package/src/features/activityData/ExitWarning.ts +28 -28
  20. package/src/features/activityData/IsAntiCheatExitDetectionDisabledSetter.tsx +19 -19
  21. package/src/features/activityData/IsDirtySetter.tsx +17 -17
  22. package/src/features/activityData/MetaPlayerOptionsSetter.tsx +41 -41
  23. package/src/features/activityData/activityDataSlice.ts +255 -255
  24. package/src/features/activityData/activityJsData.ts +90 -90
  25. package/src/features/activityData/hooks.ts +39 -39
  26. package/src/features/activityData/metaPlayerOptions.ts +23 -23
  27. package/src/features/activityData/uiState.ts +20 -20
  28. package/src/features/activityJS/ActivityJSProvider.tsx +362 -350
  29. package/src/features/activityJS/AfterResetAction.tsx +23 -23
  30. package/src/features/activityJS/AfterSaveAction.tsx +23 -23
  31. package/src/features/activityJS/BeforeResetAction.tsx +23 -23
  32. package/src/features/activityJS/BeforeSaveAction.tsx +23 -23
  33. package/src/features/activityJS/Saver.tsx +167 -167
  34. package/src/features/activityJS/hooks.ts +85 -85
  35. package/src/features/activityJS/internal-hooks.ts +96 -96
  36. package/src/features/activityJS/saverSlice.ts +96 -96
  37. package/src/features/activitySettings/ActivitySettingsSetter.tsx +21 -21
  38. package/src/features/activitySettings/hooks.ts +12 -12
  39. package/src/features/activitySettings/index.tsx +43 -43
  40. package/src/features/activitySettings/store.ts +108 -108
  41. package/src/features/activitySettings/style.module.scss +8 -8
  42. package/src/features/activitySettings/types.ts +140 -140
  43. package/src/features/activitySettings/ui.tsx +299 -299
  44. package/src/features/functionalities/AttachedFilesFunctionality.ts +23 -23
  45. package/src/features/functionalities/PreviewDialog.tsx +83 -83
  46. package/src/features/functionalities/functionalitiesSlice.ts +98 -98
  47. package/src/features/functionalities/hooks.ts +70 -70
  48. package/src/features/layout/hooks.ts +7 -7
  49. package/src/features/layout/layoutSlice.ts +93 -93
  50. package/src/features/navbar/activity-info/index.tsx +54 -54
  51. package/src/features/navbar/activity-info/style.module.scss +38 -38
  52. package/src/features/navbar/activity-menu/ActivityQuickActions.tsx +89 -57
  53. package/src/features/navbar/activity-menu/index.tsx +154 -154
  54. package/src/features/navbar/activity-menu/style.module.scss +7 -7
  55. package/src/features/navbar/capytale-menu/CloneDialog.tsx +75 -75
  56. package/src/features/navbar/capytale-menu/Countdown.tsx +313 -313
  57. package/src/features/navbar/capytale-menu/CountdownAndSaveButton.tsx +129 -125
  58. package/src/features/navbar/capytale-menu/index.tsx +260 -260
  59. package/src/features/navbar/capytale-menu/style.module.scss +8 -8
  60. package/src/features/navbar/capytale-menu/useRemainingTimeMs.tsx +32 -32
  61. package/src/features/navbar/index.tsx +39 -39
  62. package/src/features/navbar/navbarSlice.ts +79 -79
  63. package/src/features/navbar/preview-navbar/index.tsx +18 -0
  64. package/src/features/navbar/preview-navbar/style.module.scss +17 -0
  65. package/src/features/navbar/review-navbar/GradingNav.tsx +128 -128
  66. package/src/features/navbar/review-navbar/index.tsx +18 -18
  67. package/src/features/navbar/review-navbar/style.module.scss +22 -22
  68. package/src/features/navbar/sidebars/ActivitySidebarActions.tsx +57 -57
  69. package/src/features/navbar/sidebars/AttachedFilesSidebarContent.module.scss +43 -43
  70. package/src/features/navbar/sidebars/AttachedFilesSidebarContent.tsx +181 -181
  71. package/src/features/navbar/sidebars/SettingsSidebarContent.tsx +192 -192
  72. package/src/features/navbar/sidebars/style.module.scss +15 -15
  73. package/src/features/navbar/student-utils.ts +11 -11
  74. package/src/features/navbar/style.module.scss +65 -65
  75. package/src/features/pedago/InstructionsEditor.tsx +104 -102
  76. package/src/features/pedago/PdfEditor.tsx +91 -91
  77. package/src/features/pedago/PedagoCommands.tsx +378 -378
  78. package/src/features/pedago/SharedNotesEditor.tsx +144 -144
  79. package/src/features/pedago/hooks.ts +108 -108
  80. package/src/features/pedago/index.tsx +205 -205
  81. package/src/features/pedago/style.module.scss +233 -233
  82. package/src/features/theming/ThemeSwitcher.tsx +51 -51
  83. package/src/features/theming/hooks.ts +6 -6
  84. package/src/features/theming/themingSlice.ts +93 -93
  85. package/src/features/toast.tsx +38 -38
  86. package/src/hooks/index.ts +55 -16
  87. package/src/index.css +132 -132
  88. package/src/index.ts +93 -92
  89. package/src/logo.svg +1 -1
  90. package/src/my_json_data.js +4146 -4146
  91. package/src/settings.ts +6 -6
  92. package/src/types.ts +8 -8
  93. package/src/utils/ButtonDoubleIcon.tsx +35 -35
  94. package/src/utils/CardSelector.tsx +41 -41
  95. package/src/utils/ErrorBoundary.tsx +41 -41
  96. package/src/utils/PopupButton.tsx +134 -134
  97. package/src/utils/activity.ts +8 -8
  98. package/src/utils/breakpoints.ts +4 -4
  99. package/src/utils/capytale.ts +10 -10
  100. package/src/utils/clipboard.ts +11 -11
  101. package/src/utils/download.ts +7 -7
  102. package/src/utils/equality.ts +32 -32
  103. package/src/utils/server-clock.ts +42 -42
  104. package/src/utils/style.module.scss +45 -45
  105. package/src/utils/useFullscreen.ts +65 -65
  106. package/src/vite-env.d.ts +1 -1
  107. package/src/zustandStore.ts +66 -0
  108. package/tsconfig.json +28 -28
  109. package/tsconfig.node.json +9 -9
  110. package/vite.config.ts +11 -11
package/src/settings.ts CHANGED
@@ -1,6 +1,6 @@
1
- const settings = {
2
- STATEMENT_MAX_SIZE: 2000000, // 2 MB
3
- TOOLTIP_SHOW_DELAY: 500,
4
- };
5
-
6
- export default settings;
1
+ const settings = {
2
+ STATEMENT_MAX_SIZE: 2000000, // 2 MB
3
+ TOOLTIP_SHOW_DELAY: 500,
4
+ };
5
+
6
+ export default settings;
package/src/types.ts CHANGED
@@ -1,9 +1,9 @@
1
- export type AntiCheatOptions = {
2
- preserveDom: boolean;
3
- hasIframes: boolean;
4
- };
5
-
6
- export type UIOptions = {
7
- noWorkflow: boolean;
8
- noSaveForStudents: boolean;
1
+ export type AntiCheatOptions = {
2
+ preserveDom: boolean;
3
+ hasIframes: boolean;
4
+ };
5
+
6
+ export type UIOptions = {
7
+ noWorkflow: boolean;
8
+ noSaveForStudents: boolean;
9
9
  };
@@ -1,35 +1,35 @@
1
- import { Button, ButtonProps } from "primereact/button";
2
- import React from "react";
3
-
4
- type ButtonDoubleIconProps = Exclude<
5
- ButtonProps,
6
- "icon" | "children" | "iconPos"
7
- > & {
8
- leftIcon: string;
9
- rightIcon: string;
10
- };
11
-
12
- const ButtonDoubleIcon: React.FC<ButtonDoubleIconProps> = function ({
13
- label,
14
- leftIcon,
15
- rightIcon,
16
- ...props
17
- }) {
18
- return (
19
- <Button {...props}>
20
- <span
21
- className={"p-button-icon p-c p-button-icon-left " + leftIcon}
22
- data-pc-section="icon"
23
- ></span>
24
- <span className="p-button-label p-c" data-pc-section="label">
25
- {label}
26
- </span>
27
- <span
28
- className={"p-button-icon p-c p-button-icon-right " + rightIcon}
29
- data-pc-section="icon"
30
- ></span>
31
- </Button>
32
- );
33
- };
34
-
35
- export default ButtonDoubleIcon;
1
+ import { Button, ButtonProps } from "primereact/button";
2
+ import React from "react";
3
+
4
+ type ButtonDoubleIconProps = Exclude<
5
+ ButtonProps,
6
+ "icon" | "children" | "iconPos"
7
+ > & {
8
+ leftIcon: string;
9
+ rightIcon: string;
10
+ };
11
+
12
+ const ButtonDoubleIcon: React.FC<ButtonDoubleIconProps> = function ({
13
+ label,
14
+ leftIcon,
15
+ rightIcon,
16
+ ...props
17
+ }) {
18
+ return (
19
+ <Button {...props}>
20
+ <span
21
+ className={"p-button-icon p-c p-button-icon-left " + leftIcon}
22
+ data-pc-section="icon"
23
+ ></span>
24
+ <span className="p-button-label p-c" data-pc-section="label">
25
+ {label}
26
+ </span>
27
+ <span
28
+ className={"p-button-icon p-c p-button-icon-right " + rightIcon}
29
+ data-pc-section="icon"
30
+ ></span>
31
+ </Button>
32
+ );
33
+ };
34
+
35
+ export default ButtonDoubleIcon;
@@ -1,41 +1,41 @@
1
- import { RadioButton } from "primereact/radiobutton";
2
- import styles from "./style.module.scss";
3
-
4
- type CardSelectorProps<ValueType> = {
5
- options: { title: string; description: string; value: ValueType }[];
6
- selected?: ValueType | null;
7
- onChange: (value: ValueType) => void | Promise<void>;
8
- };
9
- const CardSelector = function <ValueType>(props: CardSelectorProps<ValueType>) {
10
- return (
11
- <>
12
- <div className={styles.cardSelector}>
13
- {props.options.map((option) => (
14
- <div
15
- className={styles.cardSelectorOption}
16
- data-selected={props.selected === option.value}
17
- role="button"
18
- aria-label={`Sélectionner l'option ${option.title}`}
19
- onClick={() => {
20
- props.onChange(option.value);
21
- }}
22
- >
23
- <div className={styles.cardSelectorOptionRadio}>
24
- <RadioButton checked={props.selected === option.value} />
25
- </div>
26
- <div className={styles.cardSelectorOptionContent}>
27
- <div className={styles.cardSelectorOptionTitle}>
28
- {option.title}
29
- </div>
30
- <div className={styles.cardSelectorOptionDescription}>
31
- {option.description}
32
- </div>
33
- </div>
34
- </div>
35
- ))}
36
- </div>
37
- </>
38
- );
39
- };
40
-
41
- export default CardSelector;
1
+ import { RadioButton } from "primereact/radiobutton";
2
+ import styles from "./style.module.scss";
3
+
4
+ type CardSelectorProps<ValueType> = {
5
+ options: { title: string; description: string; value: ValueType }[];
6
+ selected?: ValueType | null;
7
+ onChange: (value: ValueType) => void | Promise<void>;
8
+ };
9
+ const CardSelector = function <ValueType>(props: CardSelectorProps<ValueType>) {
10
+ return (
11
+ <>
12
+ <div className={styles.cardSelector}>
13
+ {props.options.map((option) => (
14
+ <div
15
+ className={styles.cardSelectorOption}
16
+ data-selected={props.selected === option.value}
17
+ role="button"
18
+ aria-label={`Sélectionner l'option ${option.title}`}
19
+ onClick={() => {
20
+ props.onChange(option.value);
21
+ }}
22
+ >
23
+ <div className={styles.cardSelectorOptionRadio}>
24
+ <RadioButton checked={props.selected === option.value} />
25
+ </div>
26
+ <div className={styles.cardSelectorOptionContent}>
27
+ <div className={styles.cardSelectorOptionTitle}>
28
+ {option.title}
29
+ </div>
30
+ <div className={styles.cardSelectorOptionDescription}>
31
+ {option.description}
32
+ </div>
33
+ </div>
34
+ </div>
35
+ ))}
36
+ </div>
37
+ </>
38
+ );
39
+ };
40
+
41
+ export default CardSelector;
@@ -1,41 +1,41 @@
1
- import { Component, ErrorInfo, PropsWithChildren, ReactNode } from "react";
2
-
3
- type ErrorBoundaryProps = PropsWithChildren<{
4
- fallback: ReactNode;
5
- }>;
6
- type ErrorBoundaryState = {
7
- hasError: boolean;
8
- };
9
-
10
- export class ErrorBoundary extends Component<
11
- ErrorBoundaryProps,
12
- ErrorBoundaryState
13
- > {
14
- constructor(props: ErrorBoundaryProps) {
15
- super(props);
16
- this.state = { hasError: false };
17
- }
18
-
19
- static getDerivedStateFromError(_error: Error) {
20
- // Update state so the next render will show the fallback UI.
21
- return { hasError: true };
22
- }
23
-
24
- componentDidCatch(error: Error, info: ErrorInfo) {
25
- // Example "componentStack":
26
- // in ComponentThatThrows (created by App)
27
- // in ErrorBoundary (created by App)
28
- // in div (created by App)
29
- // in App
30
- console.error(error, info.componentStack);
31
- }
32
-
33
- render() {
34
- if (this.state.hasError) {
35
- // You can render any custom fallback UI
36
- return this.props.fallback;
37
- }
38
-
39
- return this.props.children;
40
- }
41
- }
1
+ import { Component, ErrorInfo, PropsWithChildren, ReactNode } from "react";
2
+
3
+ type ErrorBoundaryProps = PropsWithChildren<{
4
+ fallback: ReactNode;
5
+ }>;
6
+ type ErrorBoundaryState = {
7
+ hasError: boolean;
8
+ };
9
+
10
+ export class ErrorBoundary extends Component<
11
+ ErrorBoundaryProps,
12
+ ErrorBoundaryState
13
+ > {
14
+ constructor(props: ErrorBoundaryProps) {
15
+ super(props);
16
+ this.state = { hasError: false };
17
+ }
18
+
19
+ static getDerivedStateFromError(_error: Error) {
20
+ // Update state so the next render will show the fallback UI.
21
+ return { hasError: true };
22
+ }
23
+
24
+ componentDidCatch(error: Error, info: ErrorInfo) {
25
+ // Example "componentStack":
26
+ // in ComponentThatThrows (created by App)
27
+ // in ErrorBoundary (created by App)
28
+ // in div (created by App)
29
+ // in App
30
+ console.error(error, info.componentStack);
31
+ }
32
+
33
+ render() {
34
+ if (this.state.hasError) {
35
+ // You can render any custom fallback UI
36
+ return this.props.fallback;
37
+ }
38
+
39
+ return this.props.children;
40
+ }
41
+ }
@@ -1,135 +1,135 @@
1
- import { Button, ButtonProps } from "primereact/button";
2
- import { MenuItem } from "primereact/menuitem";
3
- import { TieredMenu } from "primereact/tieredmenu";
4
- import { useMountEffect } from "primereact/hooks";
5
- import {
6
- IconType,
7
- ObjectUtils,
8
- UniqueComponentId,
9
- classNames,
10
- } from "primereact/utils";
11
- import {
12
- CSSProperties,
13
- KeyboardEventHandler,
14
- MouseEventHandler,
15
- ReactNode,
16
- useRef,
17
- useState,
18
- } from "react";
19
- import { Tooltip } from "primereact/tooltip";
20
- import { TooltipOptions } from "primereact/tooltip/tooltipoptions";
21
-
22
- type PopupButtonProps = {
23
- id?: string;
24
- icon?: IconType<ButtonProps>;
25
- buttonClassName?: string;
26
- disabled?: boolean;
27
- buttonProps?: ButtonProps;
28
- size?: "small" | "large";
29
- severity?: "secondary" | "success" | "info" | "warning" | "danger" | "help";
30
- outlined?: boolean;
31
- text?: boolean;
32
- raised?: boolean;
33
- unstyled?: boolean;
34
- onButtonKeydown?: KeyboardEventHandler<HTMLButtonElement>;
35
- model?: MenuItem[];
36
- appendTo?: HTMLElement | "self" | (() => HTMLElement) | null;
37
- tooltip?: ReactNode;
38
- menuStyle?: CSSProperties;
39
- autoZIndex?: boolean;
40
- baseZIndex?: number;
41
- menuClassName?: string;
42
- tooltipOptions?: TooltipOptions;
43
- };
44
-
45
- const PopupButton: React.FC<PopupButtonProps> = ({
46
- id,
47
- icon,
48
- buttonClassName,
49
- disabled,
50
- buttonProps,
51
- size,
52
- severity,
53
- outlined,
54
- text,
55
- raised,
56
- unstyled,
57
- onButtonKeydown,
58
- model,
59
- appendTo,
60
- tooltip,
61
- menuStyle,
62
- autoZIndex,
63
- baseZIndex,
64
- menuClassName,
65
- tooltipOptions,
66
- ...props
67
- }: PopupButtonProps) => {
68
- const [idState, setIdState] = useState(id);
69
- useMountEffect(() => {
70
- if (!idState) {
71
- setIdState(UniqueComponentId());
72
- }
73
- });
74
-
75
- const [overlayVisibleState, _setOverlayVisibleState] =
76
- useState<boolean>(false);
77
- const menuRef = useRef(null);
78
- const elementRef = useRef(null);
79
-
80
- const hasTooltip = ObjectUtils.isNotEmpty(tooltip);
81
-
82
- const onDropdownButtonClick: MouseEventHandler<HTMLButtonElement> = (
83
- event,
84
- ) => {
85
- menuRef && (menuRef.current as any)?.toggle(event);
86
- };
87
-
88
- const menuId = idState + "_overlay";
89
-
90
- return (
91
- <>
92
- <div {...props}>
93
- <Button
94
- type="button"
95
- className={classNames(buttonClassName)}
96
- icon={icon}
97
- onClick={onDropdownButtonClick}
98
- disabled={disabled}
99
- aria-expanded={overlayVisibleState}
100
- aria-haspopup="true"
101
- aria-controls={menuId}
102
- {...buttonProps}
103
- size={size}
104
- severity={severity}
105
- outlined={outlined}
106
- text={text}
107
- raised={raised}
108
- onKeyDown={onButtonKeydown}
109
- unstyled={unstyled}
110
- />
111
- <TieredMenu
112
- ref={menuRef}
113
- popup={true}
114
- unstyled={unstyled}
115
- model={model}
116
- appendTo={appendTo}
117
- id={menuId}
118
- style={menuStyle}
119
- autoZIndex={autoZIndex}
120
- baseZIndex={baseZIndex}
121
- className={menuClassName}
122
- />
123
- </div>
124
- {hasTooltip && (
125
- <Tooltip
126
- target={elementRef}
127
- content={tooltip}
128
- {...tooltipOptions}
129
- />
130
- )}
131
- </>
132
- );
133
- };
134
-
1
+ import { Button, ButtonProps } from "primereact/button";
2
+ import { MenuItem } from "primereact/menuitem";
3
+ import { TieredMenu } from "primereact/tieredmenu";
4
+ import { useMountEffect } from "primereact/hooks";
5
+ import {
6
+ IconType,
7
+ ObjectUtils,
8
+ UniqueComponentId,
9
+ classNames,
10
+ } from "primereact/utils";
11
+ import {
12
+ CSSProperties,
13
+ KeyboardEventHandler,
14
+ MouseEventHandler,
15
+ ReactNode,
16
+ useRef,
17
+ useState,
18
+ } from "react";
19
+ import { Tooltip } from "primereact/tooltip";
20
+ import { TooltipOptions } from "primereact/tooltip/tooltipoptions";
21
+
22
+ type PopupButtonProps = {
23
+ id?: string;
24
+ icon?: IconType<ButtonProps>;
25
+ buttonClassName?: string;
26
+ disabled?: boolean;
27
+ buttonProps?: ButtonProps;
28
+ size?: "small" | "large";
29
+ severity?: "secondary" | "success" | "info" | "warning" | "danger" | "help";
30
+ outlined?: boolean;
31
+ text?: boolean;
32
+ raised?: boolean;
33
+ unstyled?: boolean;
34
+ onButtonKeydown?: KeyboardEventHandler<HTMLButtonElement>;
35
+ model?: MenuItem[];
36
+ appendTo?: HTMLElement | "self" | (() => HTMLElement) | null;
37
+ tooltip?: ReactNode;
38
+ menuStyle?: CSSProperties;
39
+ autoZIndex?: boolean;
40
+ baseZIndex?: number;
41
+ menuClassName?: string;
42
+ tooltipOptions?: TooltipOptions;
43
+ };
44
+
45
+ const PopupButton: React.FC<PopupButtonProps> = ({
46
+ id,
47
+ icon,
48
+ buttonClassName,
49
+ disabled,
50
+ buttonProps,
51
+ size,
52
+ severity,
53
+ outlined,
54
+ text,
55
+ raised,
56
+ unstyled,
57
+ onButtonKeydown,
58
+ model,
59
+ appendTo,
60
+ tooltip,
61
+ menuStyle,
62
+ autoZIndex,
63
+ baseZIndex,
64
+ menuClassName,
65
+ tooltipOptions,
66
+ ...props
67
+ }: PopupButtonProps) => {
68
+ const [idState, setIdState] = useState(id);
69
+ useMountEffect(() => {
70
+ if (!idState) {
71
+ setIdState(UniqueComponentId());
72
+ }
73
+ });
74
+
75
+ const [overlayVisibleState, _setOverlayVisibleState] =
76
+ useState<boolean>(false);
77
+ const menuRef = useRef(null);
78
+ const elementRef = useRef(null);
79
+
80
+ const hasTooltip = ObjectUtils.isNotEmpty(tooltip);
81
+
82
+ const onDropdownButtonClick: MouseEventHandler<HTMLButtonElement> = (
83
+ event,
84
+ ) => {
85
+ menuRef && (menuRef.current as any)?.toggle(event);
86
+ };
87
+
88
+ const menuId = idState + "_overlay";
89
+
90
+ return (
91
+ <>
92
+ <div {...props}>
93
+ <Button
94
+ type="button"
95
+ className={classNames(buttonClassName)}
96
+ icon={icon}
97
+ onClick={onDropdownButtonClick}
98
+ disabled={disabled}
99
+ aria-expanded={overlayVisibleState}
100
+ aria-haspopup="true"
101
+ aria-controls={menuId}
102
+ {...buttonProps}
103
+ size={size}
104
+ severity={severity}
105
+ outlined={outlined}
106
+ text={text}
107
+ raised={raised}
108
+ onKeyDown={onButtonKeydown}
109
+ unstyled={unstyled}
110
+ />
111
+ <TieredMenu
112
+ ref={menuRef}
113
+ popup={true}
114
+ unstyled={unstyled}
115
+ model={model}
116
+ appendTo={appendTo}
117
+ id={menuId}
118
+ style={menuStyle}
119
+ autoZIndex={autoZIndex}
120
+ baseZIndex={baseZIndex}
121
+ className={menuClassName}
122
+ />
123
+ </div>
124
+ {hasTooltip && (
125
+ <Tooltip
126
+ target={elementRef}
127
+ content={tooltip}
128
+ {...tooltipOptions}
129
+ />
130
+ )}
131
+ </>
132
+ );
133
+ };
134
+
135
135
  export default PopupButton;
@@ -1,8 +1,8 @@
1
- export function getIdFromUrl() {
2
- const params = new URLSearchParams(window.location.search);
3
- const id = params.get("id");
4
- if (id !== null) {
5
- return parseInt(id, 10);
6
- }
7
- return null;
8
- }
1
+ export function getIdFromUrl() {
2
+ const params = new URLSearchParams(window.location.search);
3
+ const id = params.get("id");
4
+ if (id !== null) {
5
+ return parseInt(id, 10);
6
+ }
7
+ return null;
8
+ }
@@ -1,5 +1,5 @@
1
- export const SM = 576;
2
- export const MD = 768;
3
- export const ML = 850;
4
- export const LG = 992;
1
+ export const SM = 576;
2
+ export const MD = 768;
3
+ export const ML = 850;
4
+ export const LG = 992;
5
5
  export const XL = 1200;
@@ -1,11 +1,11 @@
1
- import httpClient from '@capytale/activity.js/backend/capytale/http';
2
-
3
- // Definit le endpoint de l'API
4
- const myActivitiesApiEp = '/web/c-hdls/api/my-activities';
5
-
6
- export async function apiCloneActivity(nid: number | string, title?: string) {
7
- return httpClient.postGetJsonAsync<any>(
8
- myActivitiesApiEp,
9
- { action: 'clone', nid, title },
10
- )
1
+ import httpClient from '@capytale/activity.js/backend/capytale/http';
2
+
3
+ // Definit le endpoint de l'API
4
+ const myActivitiesApiEp = '/web/c-hdls/api/my-activities';
5
+
6
+ export async function apiCloneActivity(nid: number | string, title?: string) {
7
+ return httpClient.postGetJsonAsync<any>(
8
+ myActivitiesApiEp,
9
+ { action: 'clone', nid, title },
10
+ )
11
11
  }
@@ -1,11 +1,11 @@
1
- export async function copyToClipboard(
2
- text: string,
3
- callback?: (success: boolean, error?: any) => any,
4
- ) {
5
- try {
6
- await navigator.clipboard.writeText(text);
7
- callback?.(true);
8
- } catch (err) {
9
- callback?.(false, err);
10
- }
11
- }
1
+ export async function copyToClipboard(
2
+ text: string,
3
+ callback?: (success: boolean, error?: any) => any,
4
+ ) {
5
+ try {
6
+ await navigator.clipboard.writeText(text);
7
+ callback?.(true);
8
+ } catch (err) {
9
+ callback?.(false, err);
10
+ }
11
+ }
@@ -1,8 +1,8 @@
1
- export function downloadFile(url: string, name?: string) {
2
- const a = document.createElement("a");
3
- a.href = url;
4
- a.download = name || url.split("/").pop() || "download";
5
- document.body.appendChild(a);
6
- a.click();
7
- document.body.removeChild(a);
1
+ export function downloadFile(url: string, name?: string) {
2
+ const a = document.createElement("a");
3
+ a.href = url;
4
+ a.download = name || url.split("/").pop() || "download";
5
+ document.body.appendChild(a);
6
+ a.click();
7
+ document.body.removeChild(a);
8
8
  }