@cgi-learning-hub/ui 1.15.0-dev.1788362942 → 1.15.0-dev.1788514003
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.js +1 -1
- package/dist/index.es.js +1 -1
- package/dist/{src-jE7nLe9k.js → src-2xPjYvOK.js} +2 -2
- package/dist/tiptap/index.cjs.js +233 -2
- package/dist/tiptap/index.es.js +233 -2
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_src = require("./src-
|
|
2
|
+
const require_src = require("./src-DldG1AFs.cjs");
|
|
3
3
|
let _mui_material_Accordion = require("@mui/material/Accordion");
|
|
4
4
|
let _mui_material_AccordionActions = require("@mui/material/AccordionActions");
|
|
5
5
|
let _mui_material_AccordionDetails = require("@mui/material/AccordionDetails");
|
package/dist/index.es.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as ListSubheader, $t as FolderCard, A as DialogTitle, At as TableSortLabel, B as Grid, Bt as ZoomControl, C as CircularProgress, Ct as TableBody, D as DialogActions, Dt as TableHead, E as Container, Et as TableFooter, F as FormControlLabel, Ft as Toolbar, G as InputLabel, Gt as ResourceCard, H as IconButton, Ht as ICON_TYPE, I as FormGroup, It as Tooltip, J as List, Jt as LoaderBackdrop, K as LinearProgress, Kt as QueryError, L as FormHelperText, Lt as Typography, M as Drawer, Mt as TextField, N as Fade, Nt as ToggleButton, O as DialogContent, Ot as TablePagination, P as FormControl, Pt as ToggleButtonGroup, Q as ListItemText, Qt as Heading, R as FormLabel, Rt as Zoom, S as Chip, St as Table, T as Collapse, Tt as TableContainer, U as Input, Ut as TimePicker, V as Grow, Vt as TreeView, W as InputBase, Wt as SearchInput, X as ListItemButton, Xt as ImagePicker, Y as ListItem, Yt as Loader, Z as ListItemIcon, _ as CardActions, _n as
|
|
1
|
+
import { $ as ListSubheader, $t as FolderCard, A as DialogTitle, At as TableSortLabel, B as Grid, Bt as ZoomControl, C as CircularProgress, Ct as TableBody, D as DialogActions, Dt as TableHead, E as Container, Et as TableFooter, F as FormControlLabel, Ft as Toolbar, G as InputLabel, Gt as ResourceCard, H as IconButton, Ht as ICON_TYPE, I as FormGroup, It as Tooltip, J as List, Jt as LoaderBackdrop, K as LinearProgress, Kt as QueryError, L as FormHelperText, Lt as Typography, M as Drawer, Mt as TextField, N as Fade, Nt as ToggleButton, O as DialogContent, Ot as TablePagination, P as FormControl, Pt as ToggleButtonGroup, Q as ListItemText, Qt as Heading, R as FormLabel, Rt as Zoom, S as Chip, St as Table, T as Collapse, Tt as TableContainer, U as Input, Ut as TimePicker, V as Grow, Vt as TreeView, W as InputBase, Wt as SearchInput, X as ListItemButton, Xt as ImagePicker, Y as ListItem, Yt as Loader, Z as ListItemIcon, _ as CardActions, _n as TabList, _t as StepLabel, a as AlertTitle, an as Dialog, at as Paper, b as CardMedia, bn as getTabId, bt as Switch, c as Avatar, cn as DEFAULT_COLOR_OPTIONS, ct as RadioGroup, d as Box, dn as Alert, dt as Slide, en as FileList, et as Menu, f as Breadcrumbs, fn as ActionBar, ft as Slider, g as CardActionArea, gt as StepButton, h as Card, hn as tabPanelClasses, ht as Step, i as AccordionSummary, in as Dropzone, it as Pagination, j as Divider, jt as Tabs, k as DialogContentText, kt as TableRow, l as Backdrop, lt as Select, m as ButtonGroup, mn as getTabPanelUtilityClass, mt as Stack, n as AccordionActions, nn as EmptyState, nt as MobileStepper, o as AppBar, on as DatePicker, ot as Popover, p as Button, pn as TabPanel, pt as Snackbar, q as Link, qt as PasswordInput, r as AccordionDetails, rn as EllipsisWithTooltip, rt as Modal, s as Autocomplete, sn as ColorPicker, st as Radio, t as Accordion, tn as FileListItem, tt as MenuItem, u as Badge, ut as Skeleton, v as CardContent, vn as TabContext, vt as Stepper, w as ClickAwayListener, wt as TableCell, x as Checkbox, xn as useTabContext, xt as Tab, y as CardHeader, yn as getPanelId, yt as SvgIcon, z as GlobalStyles, zt as useMediaQuery } from "./src-2xPjYvOK.js";
|
|
2
2
|
export * from "@mui/material/Tabs";
|
|
3
3
|
export * from "@mui/material/styles";
|
|
4
4
|
export * from "@mui/material/Accordion";
|
|
@@ -29560,6 +29560,6 @@ var ZoomControl = ({ step = 10, value = 50, onChange, max = 100, min = 0, label
|
|
|
29560
29560
|
});
|
|
29561
29561
|
};
|
|
29562
29562
|
//#endregion
|
|
29563
|
-
export { ListSubheader as $, FolderCard as $t, DialogTitle as A, TableSortLabel as At, Grid as B, ZoomControl as Bt, CircularProgress$1 as C, TableBody as Ct, DialogActions$1 as D, TableHead as Dt, Container as E, TableFooter as Et, FormControlLabel as F, Toolbar as Ft, InputLabel$1 as G, ResourceCard as Gt, IconButton as H, ICON_TYPE as Ht, FormGroup as I, Tooltip$1 as It, List$1 as J, LoaderBackdrop as Jt, LinearProgress as K, QueryError as Kt, FormHelperText$1 as L, Typography$1 as Lt, Drawer as M, TextField$1 as Mt, Fade$1 as N, ToggleButton as Nt, DialogContent$1 as O, TablePagination as Ot, FormControl$1 as P, ToggleButtonGroup as Pt, ListItemText$1 as Q, Heading as Qt, FormLabel as R, Zoom as Rt, Chip$1 as S, Table as St, Collapse$1 as T, TableContainer as Tt, Input as U, TimePicker as Ut, Grow$1 as V, TreeView as Vt, InputBase$1 as W, SearchInput as Wt, ListItemButton$1 as X, ImagePicker as Xt, ListItem$1 as Y, Loader as Yt, ListItemIcon$1 as Z, DeleteRounded_default as Zt, CardActions as _,
|
|
29563
|
+
export { ListSubheader as $, FolderCard as $t, DialogTitle as A, TableSortLabel as At, Grid as B, ZoomControl as Bt, CircularProgress$1 as C, TableBody as Ct, DialogActions$1 as D, TableHead as Dt, Container as E, TableFooter as Et, FormControlLabel as F, Toolbar as Ft, InputLabel$1 as G, ResourceCard as Gt, IconButton as H, ICON_TYPE as Ht, FormGroup as I, Tooltip$1 as It, List$1 as J, LoaderBackdrop as Jt, LinearProgress as K, QueryError as Kt, FormHelperText$1 as L, Typography$1 as Lt, Drawer as M, TextField$1 as Mt, Fade$1 as N, ToggleButton as Nt, DialogContent$1 as O, TablePagination as Ot, FormControl$1 as P, ToggleButtonGroup as Pt, ListItemText$1 as Q, Heading as Qt, FormLabel as R, Zoom as Rt, Chip$1 as S, Table as St, Collapse$1 as T, TableContainer as Tt, Input as U, TimePicker as Ut, Grow$1 as V, TreeView as Vt, InputBase$1 as W, SearchInput as Wt, ListItemButton$1 as X, ImagePicker as Xt, ListItem$1 as Y, Loader as Yt, ListItemIcon$1 as Z, DeleteRounded_default as Zt, CardActions as _, TabList as _n, StepLabel as _t, AlertTitle$1 as a, Dialog as an, Paper as at, CardMedia$1 as b, getTabId as bn, Switch as bt, Avatar as c, DEFAULT_COLOR_OPTIONS as cn, RadioGroup as ct, Box$1 as d, Alert as dn, Slide as dt, FileList as en, Menu as et, Breadcrumbs as f, ActionBar as fn, Slider as ft, CardActionArea as g, clsx as gn, StepButton as gt, Card$1 as h, tabPanelClasses as hn, Step as ht, AccordionSummary as i, Dropzone as in, Pagination as it, Divider$1 as j, Tabs$1 as jt, DialogContentText as k, TableRow as kt, Backdrop$1 as l, SvgIcon_default as ln, Select as lt, ButtonGroup as m, getTabPanelUtilityClass as mn, Stack$1 as mt, AccordionActions as n, EmptyState as nn, MobileStepper as nt, AppBar as o, DatePicker as on, Popover as ot, Button$1 as p, TabPanel as pn, Snackbar as pt, Link as q, PasswordInput as qt, AccordionDetails as r, EllipsisWithTooltip as rn, Modal as rt, Autocomplete as s, ColorPicker as sn, Radio as st, Accordion as t, FileListItem as tn, MenuItem$1 as tt, Badge as u, Circle as un, Skeleton as ut, CardContent$1 as v, TabContext as vn, Stepper as vt, ClickAwayListener$1 as w, TableCell as wt, Checkbox as x, useTabContext as xn, Tab as xt, CardHeader as y, getPanelId as yn, SvgIcon as yt, GlobalStyles as z, useMediaQuery$1 as zt };
|
|
29564
29564
|
|
|
29565
|
-
//# sourceMappingURL=src-
|
|
29565
|
+
//# sourceMappingURL=src-2xPjYvOK.js.map
|
package/dist/tiptap/index.cjs.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_src = require("../src-
|
|
2
|
+
const require_src = require("../src-DldG1AFs.cjs");
|
|
3
3
|
let react = require("react");
|
|
4
4
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
5
5
|
let _mui_material_styles = require("@mui/material/styles");
|
|
@@ -2373,6 +2373,234 @@ var TextAlignButton = (0, react.forwardRef)(({ editor: providedEditor, align, te
|
|
|
2373
2373
|
});
|
|
2374
2374
|
TextAlignButton.displayName = "TextAlignButton";
|
|
2375
2375
|
//#endregion
|
|
2376
|
+
//#region src/tiptap/components/ui/text-color-popover/const.ts
|
|
2377
|
+
var COLORS = [
|
|
2378
|
+
"#F44336",
|
|
2379
|
+
"#E91E63",
|
|
2380
|
+
"#9C27B0",
|
|
2381
|
+
"#673AB7",
|
|
2382
|
+
"#3F51B5",
|
|
2383
|
+
"#2196F3",
|
|
2384
|
+
"#03A9F4",
|
|
2385
|
+
"#00BCD4",
|
|
2386
|
+
"#009688",
|
|
2387
|
+
"#4CAF50",
|
|
2388
|
+
"#8BC34a",
|
|
2389
|
+
"#CDDC39",
|
|
2390
|
+
"#FFEB3B",
|
|
2391
|
+
"#FFC107",
|
|
2392
|
+
"#FF9800",
|
|
2393
|
+
"#FF5722",
|
|
2394
|
+
"#795548",
|
|
2395
|
+
"#607D8B"
|
|
2396
|
+
];
|
|
2397
|
+
//#endregion
|
|
2398
|
+
//#region ../../node_modules/.pnpm/@mui+icons-material@9.4.0_@mui+material@9.4.0_@emotion+react@11.14.0_@types+react@19.2._02cb1dd638d2ccdea7d16c50ea4ea174/node_modules/@mui/icons-material/FormatColorTextRounded.mjs
|
|
2399
|
+
var FormatColorTextRounded_default = (0, _mui_material_SvgIcon.createSvgIcon)(/*#__PURE__*/ (0, react_jsx_runtime.jsx)("path", { d: "M20 20H4c-1.1 0-2 .9-2 2s.9 2 2 2h16c1.1 0 2-.9 2-2s-.9-2-2-2M7.11 17c.48 0 .91-.3 1.06-.75l1.01-2.83h5.65l.99 2.82c.16.46.59.76 1.07.76.79 0 1.33-.79 1.05-1.52L13.69 4.17C13.43 3.47 12.75 3 12 3s-1.43.47-1.69 1.17L6.06 15.48c-.28.73.27 1.52 1.05 1.52m4.83-11.4h.12l2.03 5.79H9.91z" }), "FormatColorTextRounded");
|
|
2400
|
+
//#endregion
|
|
2401
|
+
//#region src/tiptap/components/ui/text-color-popover/use-text-color-popover.ts
|
|
2402
|
+
/**
|
|
2403
|
+
* Checks if a text color can be set in the current editor state
|
|
2404
|
+
*/
|
|
2405
|
+
function canSetTextColor(editor) {
|
|
2406
|
+
if (!editor || !editor.isEditable) return false;
|
|
2407
|
+
if (isNodeTypeSelected(editor, ["image"], true)) return false;
|
|
2408
|
+
try {
|
|
2409
|
+
return editor.can().setColor("red");
|
|
2410
|
+
} catch {
|
|
2411
|
+
return false;
|
|
2412
|
+
}
|
|
2413
|
+
}
|
|
2414
|
+
/**
|
|
2415
|
+
* Gets the currently active text color from the editor selection
|
|
2416
|
+
*/
|
|
2417
|
+
function getActiveTextColor(editor) {
|
|
2418
|
+
if (!editor || !editor.isEditable || !editor.isActive("textStyle")) return null;
|
|
2419
|
+
return editor.getAttributes("textStyle").color;
|
|
2420
|
+
}
|
|
2421
|
+
/**
|
|
2422
|
+
* Determines if the text color button should be shown
|
|
2423
|
+
*/
|
|
2424
|
+
function shouldShowTextColorButton(props) {
|
|
2425
|
+
const { editor, hideWhenUnavailable } = props;
|
|
2426
|
+
if (!editor || !editor.isEditable) return false;
|
|
2427
|
+
const textStyleInSchema = isMarkInSchema("textStyle", editor);
|
|
2428
|
+
if (!hideWhenUnavailable) return true;
|
|
2429
|
+
if (!textStyleInSchema) return false;
|
|
2430
|
+
if (!editor.isActive("code")) return canSetTextColor(editor);
|
|
2431
|
+
return true;
|
|
2432
|
+
}
|
|
2433
|
+
/**
|
|
2434
|
+
* Custom hook for handling text style operations in a Tiptap editor
|
|
2435
|
+
*/
|
|
2436
|
+
function useTextStyleHandler(props) {
|
|
2437
|
+
const { editor, onSetTextStyle } = props;
|
|
2438
|
+
return {
|
|
2439
|
+
setTextColor: (0, react.useCallback)((color) => {
|
|
2440
|
+
if (!editor) return;
|
|
2441
|
+
editor.chain().focus().extendMarkRange("textStyle").setColor(color).run();
|
|
2442
|
+
onSetTextStyle?.();
|
|
2443
|
+
}, [editor, onSetTextStyle]),
|
|
2444
|
+
removeTextColor: (0, react.useCallback)(() => {
|
|
2445
|
+
if (!editor) return;
|
|
2446
|
+
editor.chain().focus().unsetColor().removeEmptyTextStyle().run();
|
|
2447
|
+
}, [editor])
|
|
2448
|
+
};
|
|
2449
|
+
}
|
|
2450
|
+
/**
|
|
2451
|
+
* Main hook that provides text color popover functionality for Tiptap editor
|
|
2452
|
+
*/
|
|
2453
|
+
function useTextColorPopover(config) {
|
|
2454
|
+
const { editor: providedEditor, hideWhenUnavailable = false, onSetTextColor } = config || {};
|
|
2455
|
+
const { editor } = useTiptapEditor(providedEditor);
|
|
2456
|
+
const [isVisible, setIsVisible] = (0, react.useState)(true);
|
|
2457
|
+
const activeColor = getActiveTextColor(editor);
|
|
2458
|
+
const isActive = activeColor !== null;
|
|
2459
|
+
const canSet = canSetTextColor(editor);
|
|
2460
|
+
const textColorHandler = useTextStyleHandler({
|
|
2461
|
+
editor,
|
|
2462
|
+
onSetTextStyle: onSetTextColor
|
|
2463
|
+
});
|
|
2464
|
+
(0, react.useEffect)(() => {
|
|
2465
|
+
if (!editor) return;
|
|
2466
|
+
const handleSelectionUpdate = () => {
|
|
2467
|
+
setIsVisible(shouldShowTextColorButton({
|
|
2468
|
+
editor,
|
|
2469
|
+
hideWhenUnavailable
|
|
2470
|
+
}));
|
|
2471
|
+
};
|
|
2472
|
+
handleSelectionUpdate();
|
|
2473
|
+
editor.on("selectionUpdate", handleSelectionUpdate);
|
|
2474
|
+
return () => {
|
|
2475
|
+
editor.off("selectionUpdate", handleSelectionUpdate);
|
|
2476
|
+
};
|
|
2477
|
+
}, [editor, hideWhenUnavailable]);
|
|
2478
|
+
return {
|
|
2479
|
+
isVisible,
|
|
2480
|
+
canSet,
|
|
2481
|
+
activeColor,
|
|
2482
|
+
isActive,
|
|
2483
|
+
label: "Couleur",
|
|
2484
|
+
Icon: FormatColorTextRounded_default,
|
|
2485
|
+
...textColorHandler
|
|
2486
|
+
};
|
|
2487
|
+
}
|
|
2488
|
+
//#endregion
|
|
2489
|
+
//#region src/tiptap/components/ui/text-color-popover/text-color-popover.tsx
|
|
2490
|
+
/**
|
|
2491
|
+
* Text color button component for triggering the text color popover
|
|
2492
|
+
*/
|
|
2493
|
+
var TextColorButton = (0, react.forwardRef)(({ className, children, ...props }, ref) => {
|
|
2494
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
|
|
2495
|
+
type: "button",
|
|
2496
|
+
className,
|
|
2497
|
+
role: "button",
|
|
2498
|
+
tabIndex: -1,
|
|
2499
|
+
ref,
|
|
2500
|
+
...props,
|
|
2501
|
+
children: children || /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FormatColorTextRounded_default, { fontSize: "small" })
|
|
2502
|
+
});
|
|
2503
|
+
});
|
|
2504
|
+
TextColorButton.displayName = "TextColorButton";
|
|
2505
|
+
/**
|
|
2506
|
+
* Main content component for the text color popover
|
|
2507
|
+
*/
|
|
2508
|
+
var TextColorMain = ({ setTextColor, removeTextColor, onChange, activeColor }) => {
|
|
2509
|
+
const handleChange = (color) => {
|
|
2510
|
+
if (color.hex === activeColor) removeTextColor();
|
|
2511
|
+
else setTextColor(color.hex);
|
|
2512
|
+
onChange?.();
|
|
2513
|
+
};
|
|
2514
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_src.Circle, {
|
|
2515
|
+
colors: COLORS,
|
|
2516
|
+
color: activeColor ?? void 0,
|
|
2517
|
+
onChange: handleChange,
|
|
2518
|
+
style: {
|
|
2519
|
+
gap: 5,
|
|
2520
|
+
width: "15rem",
|
|
2521
|
+
padding: 10
|
|
2522
|
+
},
|
|
2523
|
+
pointProps: { style: {
|
|
2524
|
+
width: 20,
|
|
2525
|
+
height: 20
|
|
2526
|
+
} }
|
|
2527
|
+
});
|
|
2528
|
+
};
|
|
2529
|
+
/**
|
|
2530
|
+
* text color popover component for Tiptap editors.
|
|
2531
|
+
*
|
|
2532
|
+
* For custom popover implementations, use the `useTextColorPopover` hook instead.
|
|
2533
|
+
*/
|
|
2534
|
+
var TextColorPopover = (0, react.forwardRef)(({ editor: providedEditor, hideWhenUnavailable = false, onSetTextColor, onOpenChange, onClick, children, ...buttonProps }, ref) => {
|
|
2535
|
+
const { editor } = useTiptapEditor(providedEditor);
|
|
2536
|
+
const [anchorEl, setAnchorEl] = (0, react.useState)(null);
|
|
2537
|
+
const internalRef = (0, react.useRef)(null);
|
|
2538
|
+
const justSubmittedRef = (0, react.useRef)(false);
|
|
2539
|
+
const { isVisible, canSet, activeColor, isActive, setTextColor, removeTextColor, label, Icon } = useTextColorPopover({
|
|
2540
|
+
editor,
|
|
2541
|
+
hideWhenUnavailable,
|
|
2542
|
+
onSetTextColor
|
|
2543
|
+
});
|
|
2544
|
+
const setRefs = (0, react.useCallback)((node) => {
|
|
2545
|
+
internalRef.current = node;
|
|
2546
|
+
if (typeof ref === "function") ref(node);
|
|
2547
|
+
else if (ref) ref.current = node;
|
|
2548
|
+
}, [ref]);
|
|
2549
|
+
const handleClose = (0, react.useCallback)(() => {
|
|
2550
|
+
setAnchorEl(null);
|
|
2551
|
+
onOpenChange?.(false);
|
|
2552
|
+
}, [onOpenChange]);
|
|
2553
|
+
const handleSetTextColor = (0, react.useCallback)((color) => {
|
|
2554
|
+
justSubmittedRef.current = true;
|
|
2555
|
+
setTextColor(color);
|
|
2556
|
+
setAnchorEl(null);
|
|
2557
|
+
queueMicrotask(() => {
|
|
2558
|
+
justSubmittedRef.current = false;
|
|
2559
|
+
});
|
|
2560
|
+
}, [setTextColor]);
|
|
2561
|
+
const handleClick = (0, react.useCallback)((event) => {
|
|
2562
|
+
onClick?.(event, !isActive);
|
|
2563
|
+
if (event.defaultPrevented) return;
|
|
2564
|
+
setAnchorEl(event.currentTarget);
|
|
2565
|
+
}, [onClick, anchorEl]);
|
|
2566
|
+
if (!isVisible) return null;
|
|
2567
|
+
const open = Boolean(anchorEl);
|
|
2568
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(TextColorButton, {
|
|
2569
|
+
value: "textStyle",
|
|
2570
|
+
disabled: !canSet,
|
|
2571
|
+
selected: isActive || open,
|
|
2572
|
+
"data-disabled": !canSet,
|
|
2573
|
+
"aria-label": label,
|
|
2574
|
+
tooltip: label,
|
|
2575
|
+
onClick: handleClick,
|
|
2576
|
+
...buttonProps,
|
|
2577
|
+
ref: setRefs,
|
|
2578
|
+
children: children ?? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Icon, {
|
|
2579
|
+
fontSize: "small",
|
|
2580
|
+
sx: { color: activeColor ?? "inherit" }
|
|
2581
|
+
})
|
|
2582
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_mui_material_Popover.default, {
|
|
2583
|
+
open,
|
|
2584
|
+
anchorEl,
|
|
2585
|
+
onClose: handleClose,
|
|
2586
|
+
anchorOrigin: {
|
|
2587
|
+
vertical: "bottom",
|
|
2588
|
+
horizontal: "center"
|
|
2589
|
+
},
|
|
2590
|
+
transformOrigin: {
|
|
2591
|
+
vertical: -4,
|
|
2592
|
+
horizontal: "center"
|
|
2593
|
+
},
|
|
2594
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TextColorMain, {
|
|
2595
|
+
setTextColor: handleSetTextColor,
|
|
2596
|
+
removeTextColor,
|
|
2597
|
+
onChange: handleClose,
|
|
2598
|
+
activeColor
|
|
2599
|
+
})
|
|
2600
|
+
})] });
|
|
2601
|
+
});
|
|
2602
|
+
TextColorPopover.displayName = "TextColorPopover";
|
|
2603
|
+
//#endregion
|
|
2376
2604
|
//#region ../../node_modules/.pnpm/@mui+icons-material@9.4.0_@mui+material@9.4.0_@emotion+react@11.14.0_@types+react@19.2._02cb1dd638d2ccdea7d16c50ea4ea174/node_modules/@mui/icons-material/RedoRounded.mjs
|
|
2377
2605
|
var RedoRounded_default = (0, _mui_material_SvgIcon.createSvgIcon)(/*#__PURE__*/ (0, react_jsx_runtime.jsx)("path", { d: "M18.4 10.6C16.55 8.99 14.15 8 11.5 8c-4.16 0-7.74 2.42-9.44 5.93-.32.67.04 1.47.75 1.71.59.2 1.23-.08 1.5-.64 1.3-2.66 4.03-4.5 7.19-4.5 1.95 0 3.73.72 5.12 1.88l-1.91 1.91c-.63.63-.19 1.71.7 1.71H21c.55 0 1-.45 1-1V9.41c0-.89-1.08-1.34-1.71-.71z" }), "RedoRounded");
|
|
2378
2606
|
//#endregion
|
|
@@ -2806,7 +3034,9 @@ ToolbarSeparator.displayName = "ToolbarSeparator";
|
|
|
2806
3034
|
//#endregion
|
|
2807
3035
|
//#region src/tiptap/components/ui-primitive/formatting-controls/formatting-controls.tsx
|
|
2808
3036
|
var FormattingControls = ({ editor }) => {
|
|
2809
|
-
const
|
|
3037
|
+
const extensionNames = editor.extensionManager.extensions.map((e) => e.name);
|
|
3038
|
+
const hasSuperscriptSubscript = extensionNames.some((name) => name === "subscript" || name === "superscript");
|
|
3039
|
+
const hasTextStyle = extensionNames.some((name) => name === "textStyle");
|
|
2810
3040
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
2811
3041
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(ToolbarGroup, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(UndoRedoButton, { action: "undo" }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(UndoRedoButton, { action: "redo" })] }),
|
|
2812
3042
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolbarSeparator, {}),
|
|
@@ -2827,6 +3057,7 @@ var FormattingControls = ({ editor }) => {
|
|
|
2827
3057
|
] }),
|
|
2828
3058
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolbarSeparator, {}),
|
|
2829
3059
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(ToolbarGroup, { children: [
|
|
3060
|
+
hasTextStyle ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TextColorPopover, {}) : null,
|
|
2830
3061
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(MarkButton, { type: "bold" }),
|
|
2831
3062
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(MarkButton, { type: "italic" }),
|
|
2832
3063
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(MarkButton, { type: "strike" }),
|
package/dist/tiptap/index.es.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { H as IconButton, It as Tooltip, Lt as Typography, Nt as ToggleButton, W as InputBase, Zt as DeleteRounded_default, et as Menu,
|
|
1
|
+
import { H as IconButton, It as Tooltip, Lt as Typography, Nt as ToggleButton, W as InputBase, Zt as DeleteRounded_default, et as Menu, gn as clsx, j as Divider, ln as SvgIcon_default, mt as Stack, ot as Popover, tt as MenuItem, u as Badge, un as Circle } from "../src-2xPjYvOK.js";
|
|
2
2
|
import { Fragment, forwardRef, useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
3
3
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
4
4
|
import { styled } from "@mui/material/styles";
|
|
@@ -2349,6 +2349,234 @@ var TextAlignButton = forwardRef(({ editor: providedEditor, align, text, hideWhe
|
|
|
2349
2349
|
});
|
|
2350
2350
|
TextAlignButton.displayName = "TextAlignButton";
|
|
2351
2351
|
//#endregion
|
|
2352
|
+
//#region src/tiptap/components/ui/text-color-popover/const.ts
|
|
2353
|
+
var COLORS = [
|
|
2354
|
+
"#F44336",
|
|
2355
|
+
"#E91E63",
|
|
2356
|
+
"#9C27B0",
|
|
2357
|
+
"#673AB7",
|
|
2358
|
+
"#3F51B5",
|
|
2359
|
+
"#2196F3",
|
|
2360
|
+
"#03A9F4",
|
|
2361
|
+
"#00BCD4",
|
|
2362
|
+
"#009688",
|
|
2363
|
+
"#4CAF50",
|
|
2364
|
+
"#8BC34a",
|
|
2365
|
+
"#CDDC39",
|
|
2366
|
+
"#FFEB3B",
|
|
2367
|
+
"#FFC107",
|
|
2368
|
+
"#FF9800",
|
|
2369
|
+
"#FF5722",
|
|
2370
|
+
"#795548",
|
|
2371
|
+
"#607D8B"
|
|
2372
|
+
];
|
|
2373
|
+
//#endregion
|
|
2374
|
+
//#region ../../node_modules/.pnpm/@mui+icons-material@9.4.0_@mui+material@9.4.0_@emotion+react@11.14.0_@types+react@19.2._02cb1dd638d2ccdea7d16c50ea4ea174/node_modules/@mui/icons-material/FormatColorTextRounded.mjs
|
|
2375
|
+
var FormatColorTextRounded_default = SvgIcon_default(/*#__PURE__*/ jsx("path", { d: "M20 20H4c-1.1 0-2 .9-2 2s.9 2 2 2h16c1.1 0 2-.9 2-2s-.9-2-2-2M7.11 17c.48 0 .91-.3 1.06-.75l1.01-2.83h5.65l.99 2.82c.16.46.59.76 1.07.76.79 0 1.33-.79 1.05-1.52L13.69 4.17C13.43 3.47 12.75 3 12 3s-1.43.47-1.69 1.17L6.06 15.48c-.28.73.27 1.52 1.05 1.52m4.83-11.4h.12l2.03 5.79H9.91z" }), "FormatColorTextRounded");
|
|
2376
|
+
//#endregion
|
|
2377
|
+
//#region src/tiptap/components/ui/text-color-popover/use-text-color-popover.ts
|
|
2378
|
+
/**
|
|
2379
|
+
* Checks if a text color can be set in the current editor state
|
|
2380
|
+
*/
|
|
2381
|
+
function canSetTextColor(editor) {
|
|
2382
|
+
if (!editor || !editor.isEditable) return false;
|
|
2383
|
+
if (isNodeTypeSelected(editor, ["image"], true)) return false;
|
|
2384
|
+
try {
|
|
2385
|
+
return editor.can().setColor("red");
|
|
2386
|
+
} catch {
|
|
2387
|
+
return false;
|
|
2388
|
+
}
|
|
2389
|
+
}
|
|
2390
|
+
/**
|
|
2391
|
+
* Gets the currently active text color from the editor selection
|
|
2392
|
+
*/
|
|
2393
|
+
function getActiveTextColor(editor) {
|
|
2394
|
+
if (!editor || !editor.isEditable || !editor.isActive("textStyle")) return null;
|
|
2395
|
+
return editor.getAttributes("textStyle").color;
|
|
2396
|
+
}
|
|
2397
|
+
/**
|
|
2398
|
+
* Determines if the text color button should be shown
|
|
2399
|
+
*/
|
|
2400
|
+
function shouldShowTextColorButton(props) {
|
|
2401
|
+
const { editor, hideWhenUnavailable } = props;
|
|
2402
|
+
if (!editor || !editor.isEditable) return false;
|
|
2403
|
+
const textStyleInSchema = isMarkInSchema("textStyle", editor);
|
|
2404
|
+
if (!hideWhenUnavailable) return true;
|
|
2405
|
+
if (!textStyleInSchema) return false;
|
|
2406
|
+
if (!editor.isActive("code")) return canSetTextColor(editor);
|
|
2407
|
+
return true;
|
|
2408
|
+
}
|
|
2409
|
+
/**
|
|
2410
|
+
* Custom hook for handling text style operations in a Tiptap editor
|
|
2411
|
+
*/
|
|
2412
|
+
function useTextStyleHandler(props) {
|
|
2413
|
+
const { editor, onSetTextStyle } = props;
|
|
2414
|
+
return {
|
|
2415
|
+
setTextColor: useCallback((color) => {
|
|
2416
|
+
if (!editor) return;
|
|
2417
|
+
editor.chain().focus().extendMarkRange("textStyle").setColor(color).run();
|
|
2418
|
+
onSetTextStyle?.();
|
|
2419
|
+
}, [editor, onSetTextStyle]),
|
|
2420
|
+
removeTextColor: useCallback(() => {
|
|
2421
|
+
if (!editor) return;
|
|
2422
|
+
editor.chain().focus().unsetColor().removeEmptyTextStyle().run();
|
|
2423
|
+
}, [editor])
|
|
2424
|
+
};
|
|
2425
|
+
}
|
|
2426
|
+
/**
|
|
2427
|
+
* Main hook that provides text color popover functionality for Tiptap editor
|
|
2428
|
+
*/
|
|
2429
|
+
function useTextColorPopover(config) {
|
|
2430
|
+
const { editor: providedEditor, hideWhenUnavailable = false, onSetTextColor } = config || {};
|
|
2431
|
+
const { editor } = useTiptapEditor(providedEditor);
|
|
2432
|
+
const [isVisible, setIsVisible] = useState(true);
|
|
2433
|
+
const activeColor = getActiveTextColor(editor);
|
|
2434
|
+
const isActive = activeColor !== null;
|
|
2435
|
+
const canSet = canSetTextColor(editor);
|
|
2436
|
+
const textColorHandler = useTextStyleHandler({
|
|
2437
|
+
editor,
|
|
2438
|
+
onSetTextStyle: onSetTextColor
|
|
2439
|
+
});
|
|
2440
|
+
useEffect(() => {
|
|
2441
|
+
if (!editor) return;
|
|
2442
|
+
const handleSelectionUpdate = () => {
|
|
2443
|
+
setIsVisible(shouldShowTextColorButton({
|
|
2444
|
+
editor,
|
|
2445
|
+
hideWhenUnavailable
|
|
2446
|
+
}));
|
|
2447
|
+
};
|
|
2448
|
+
handleSelectionUpdate();
|
|
2449
|
+
editor.on("selectionUpdate", handleSelectionUpdate);
|
|
2450
|
+
return () => {
|
|
2451
|
+
editor.off("selectionUpdate", handleSelectionUpdate);
|
|
2452
|
+
};
|
|
2453
|
+
}, [editor, hideWhenUnavailable]);
|
|
2454
|
+
return {
|
|
2455
|
+
isVisible,
|
|
2456
|
+
canSet,
|
|
2457
|
+
activeColor,
|
|
2458
|
+
isActive,
|
|
2459
|
+
label: "Couleur",
|
|
2460
|
+
Icon: FormatColorTextRounded_default,
|
|
2461
|
+
...textColorHandler
|
|
2462
|
+
};
|
|
2463
|
+
}
|
|
2464
|
+
//#endregion
|
|
2465
|
+
//#region src/tiptap/components/ui/text-color-popover/text-color-popover.tsx
|
|
2466
|
+
/**
|
|
2467
|
+
* Text color button component for triggering the text color popover
|
|
2468
|
+
*/
|
|
2469
|
+
var TextColorButton = forwardRef(({ className, children, ...props }, ref) => {
|
|
2470
|
+
return /* @__PURE__ */ jsx(Button, {
|
|
2471
|
+
type: "button",
|
|
2472
|
+
className,
|
|
2473
|
+
role: "button",
|
|
2474
|
+
tabIndex: -1,
|
|
2475
|
+
ref,
|
|
2476
|
+
...props,
|
|
2477
|
+
children: children || /* @__PURE__ */ jsx(FormatColorTextRounded_default, { fontSize: "small" })
|
|
2478
|
+
});
|
|
2479
|
+
});
|
|
2480
|
+
TextColorButton.displayName = "TextColorButton";
|
|
2481
|
+
/**
|
|
2482
|
+
* Main content component for the text color popover
|
|
2483
|
+
*/
|
|
2484
|
+
var TextColorMain = ({ setTextColor, removeTextColor, onChange, activeColor }) => {
|
|
2485
|
+
const handleChange = (color) => {
|
|
2486
|
+
if (color.hex === activeColor) removeTextColor();
|
|
2487
|
+
else setTextColor(color.hex);
|
|
2488
|
+
onChange?.();
|
|
2489
|
+
};
|
|
2490
|
+
return /* @__PURE__ */ jsx(Circle, {
|
|
2491
|
+
colors: COLORS,
|
|
2492
|
+
color: activeColor ?? void 0,
|
|
2493
|
+
onChange: handleChange,
|
|
2494
|
+
style: {
|
|
2495
|
+
gap: 5,
|
|
2496
|
+
width: "15rem",
|
|
2497
|
+
padding: 10
|
|
2498
|
+
},
|
|
2499
|
+
pointProps: { style: {
|
|
2500
|
+
width: 20,
|
|
2501
|
+
height: 20
|
|
2502
|
+
} }
|
|
2503
|
+
});
|
|
2504
|
+
};
|
|
2505
|
+
/**
|
|
2506
|
+
* text color popover component for Tiptap editors.
|
|
2507
|
+
*
|
|
2508
|
+
* For custom popover implementations, use the `useTextColorPopover` hook instead.
|
|
2509
|
+
*/
|
|
2510
|
+
var TextColorPopover = forwardRef(({ editor: providedEditor, hideWhenUnavailable = false, onSetTextColor, onOpenChange, onClick, children, ...buttonProps }, ref) => {
|
|
2511
|
+
const { editor } = useTiptapEditor(providedEditor);
|
|
2512
|
+
const [anchorEl, setAnchorEl] = useState(null);
|
|
2513
|
+
const internalRef = useRef(null);
|
|
2514
|
+
const justSubmittedRef = useRef(false);
|
|
2515
|
+
const { isVisible, canSet, activeColor, isActive, setTextColor, removeTextColor, label, Icon } = useTextColorPopover({
|
|
2516
|
+
editor,
|
|
2517
|
+
hideWhenUnavailable,
|
|
2518
|
+
onSetTextColor
|
|
2519
|
+
});
|
|
2520
|
+
const setRefs = useCallback((node) => {
|
|
2521
|
+
internalRef.current = node;
|
|
2522
|
+
if (typeof ref === "function") ref(node);
|
|
2523
|
+
else if (ref) ref.current = node;
|
|
2524
|
+
}, [ref]);
|
|
2525
|
+
const handleClose = useCallback(() => {
|
|
2526
|
+
setAnchorEl(null);
|
|
2527
|
+
onOpenChange?.(false);
|
|
2528
|
+
}, [onOpenChange]);
|
|
2529
|
+
const handleSetTextColor = useCallback((color) => {
|
|
2530
|
+
justSubmittedRef.current = true;
|
|
2531
|
+
setTextColor(color);
|
|
2532
|
+
setAnchorEl(null);
|
|
2533
|
+
queueMicrotask(() => {
|
|
2534
|
+
justSubmittedRef.current = false;
|
|
2535
|
+
});
|
|
2536
|
+
}, [setTextColor]);
|
|
2537
|
+
const handleClick = useCallback((event) => {
|
|
2538
|
+
onClick?.(event, !isActive);
|
|
2539
|
+
if (event.defaultPrevented) return;
|
|
2540
|
+
setAnchorEl(event.currentTarget);
|
|
2541
|
+
}, [onClick, anchorEl]);
|
|
2542
|
+
if (!isVisible) return null;
|
|
2543
|
+
const open = Boolean(anchorEl);
|
|
2544
|
+
return /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx(TextColorButton, {
|
|
2545
|
+
value: "textStyle",
|
|
2546
|
+
disabled: !canSet,
|
|
2547
|
+
selected: isActive || open,
|
|
2548
|
+
"data-disabled": !canSet,
|
|
2549
|
+
"aria-label": label,
|
|
2550
|
+
tooltip: label,
|
|
2551
|
+
onClick: handleClick,
|
|
2552
|
+
...buttonProps,
|
|
2553
|
+
ref: setRefs,
|
|
2554
|
+
children: children ?? /* @__PURE__ */ jsx(Icon, {
|
|
2555
|
+
fontSize: "small",
|
|
2556
|
+
sx: { color: activeColor ?? "inherit" }
|
|
2557
|
+
})
|
|
2558
|
+
}), /* @__PURE__ */ jsx(Popover, {
|
|
2559
|
+
open,
|
|
2560
|
+
anchorEl,
|
|
2561
|
+
onClose: handleClose,
|
|
2562
|
+
anchorOrigin: {
|
|
2563
|
+
vertical: "bottom",
|
|
2564
|
+
horizontal: "center"
|
|
2565
|
+
},
|
|
2566
|
+
transformOrigin: {
|
|
2567
|
+
vertical: -4,
|
|
2568
|
+
horizontal: "center"
|
|
2569
|
+
},
|
|
2570
|
+
children: /* @__PURE__ */ jsx(TextColorMain, {
|
|
2571
|
+
setTextColor: handleSetTextColor,
|
|
2572
|
+
removeTextColor,
|
|
2573
|
+
onChange: handleClose,
|
|
2574
|
+
activeColor
|
|
2575
|
+
})
|
|
2576
|
+
})] });
|
|
2577
|
+
});
|
|
2578
|
+
TextColorPopover.displayName = "TextColorPopover";
|
|
2579
|
+
//#endregion
|
|
2352
2580
|
//#region ../../node_modules/.pnpm/@mui+icons-material@9.4.0_@mui+material@9.4.0_@emotion+react@11.14.0_@types+react@19.2._02cb1dd638d2ccdea7d16c50ea4ea174/node_modules/@mui/icons-material/RedoRounded.mjs
|
|
2353
2581
|
var RedoRounded_default = SvgIcon_default(/*#__PURE__*/ jsx("path", { d: "M18.4 10.6C16.55 8.99 14.15 8 11.5 8c-4.16 0-7.74 2.42-9.44 5.93-.32.67.04 1.47.75 1.71.59.2 1.23-.08 1.5-.64 1.3-2.66 4.03-4.5 7.19-4.5 1.95 0 3.73.72 5.12 1.88l-1.91 1.91c-.63.63-.19 1.71.7 1.71H21c.55 0 1-.45 1-1V9.41c0-.89-1.08-1.34-1.71-.71z" }), "RedoRounded");
|
|
2354
2582
|
//#endregion
|
|
@@ -2782,7 +3010,9 @@ ToolbarSeparator.displayName = "ToolbarSeparator";
|
|
|
2782
3010
|
//#endregion
|
|
2783
3011
|
//#region src/tiptap/components/ui-primitive/formatting-controls/formatting-controls.tsx
|
|
2784
3012
|
var FormattingControls = ({ editor }) => {
|
|
2785
|
-
const
|
|
3013
|
+
const extensionNames = editor.extensionManager.extensions.map((e) => e.name);
|
|
3014
|
+
const hasSuperscriptSubscript = extensionNames.some((name) => name === "subscript" || name === "superscript");
|
|
3015
|
+
const hasTextStyle = extensionNames.some((name) => name === "textStyle");
|
|
2786
3016
|
return /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
2787
3017
|
/* @__PURE__ */ jsxs(ToolbarGroup, { children: [/* @__PURE__ */ jsx(UndoRedoButton, { action: "undo" }), /* @__PURE__ */ jsx(UndoRedoButton, { action: "redo" })] }),
|
|
2788
3018
|
/* @__PURE__ */ jsx(ToolbarSeparator, {}),
|
|
@@ -2803,6 +3033,7 @@ var FormattingControls = ({ editor }) => {
|
|
|
2803
3033
|
] }),
|
|
2804
3034
|
/* @__PURE__ */ jsx(ToolbarSeparator, {}),
|
|
2805
3035
|
/* @__PURE__ */ jsxs(ToolbarGroup, { children: [
|
|
3036
|
+
hasTextStyle ? /* @__PURE__ */ jsx(TextColorPopover, {}) : null,
|
|
2806
3037
|
/* @__PURE__ */ jsx(MarkButton, { type: "bold" }),
|
|
2807
3038
|
/* @__PURE__ */ jsx(MarkButton, { type: "italic" }),
|
|
2808
3039
|
/* @__PURE__ */ jsx(MarkButton, { type: "strike" }),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cgi-learning-hub/ui",
|
|
3
|
-
"version": "1.15.0-dev.
|
|
3
|
+
"version": "1.15.0-dev.1788514003",
|
|
4
4
|
"description": "React component library for Hub's design system, built on Material UI with custom and extended components.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cgi-learning-hub",
|