@cgi-learning-hub/ui 1.15.0-dev.1788516152 → 1.15.0-dev.1788870644
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-2xPjYvOK.js → src-CUvREoVb.js} +10 -10
- package/dist/tiptap/index.cjs.js +338 -58
- package/dist/tiptap/index.d.ts +13 -1
- package/dist/tiptap/index.es.js +338 -59
- 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-DLUPogQT.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 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-
|
|
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-CUvREoVb.js";
|
|
2
2
|
export * from "@mui/material/Tabs";
|
|
3
3
|
export * from "@mui/material/styles";
|
|
4
4
|
export * from "@mui/material/Accordion";
|
|
@@ -2023,7 +2023,7 @@ var ColorPicker = ({ disabled = false, options, value, onChange, slotProps, useC
|
|
|
2023
2023
|
});
|
|
2024
2024
|
};
|
|
2025
2025
|
//#endregion
|
|
2026
|
-
//#region ../../node_modules/.pnpm/@mui+x-internals@9.
|
|
2026
|
+
//#region ../../node_modules/.pnpm/@mui+x-internals@9.13.0_@types+react@19.2.18_react-dom@19.2.8_react@19.2.8__react@19.2.8/node_modules/@mui/x-internals/formatErrorMessage/formatErrorMessage.mjs
|
|
2027
2027
|
/**
|
|
2028
2028
|
* WARNING: Don't import this directly. It's imported by the code generated by
|
|
2029
2029
|
* `@mui/internal-babel-plugin-minify-errors`. Make sure to always use string literals in `Error`
|
|
@@ -2610,7 +2610,7 @@ var require_advancedFormat = /* @__PURE__ */ __commonJSMin(((exports, module) =>
|
|
|
2610
2610
|
}));
|
|
2611
2611
|
}));
|
|
2612
2612
|
//#endregion
|
|
2613
|
-
//#region ../../node_modules/.pnpm/@mui+x-internals@9.
|
|
2613
|
+
//#region ../../node_modules/.pnpm/@mui+x-internals@9.13.0_@types+react@19.2.18_react-dom@19.2.8_react@19.2.8__react@19.2.8/node_modules/@mui/x-internals/warning/warning.mjs
|
|
2614
2614
|
var warnedOnceCache = /* @__PURE__ */ new Set();
|
|
2615
2615
|
/**
|
|
2616
2616
|
* Logs a message to the console on development mode. The warning will only be logged once.
|
|
@@ -25546,7 +25546,7 @@ function lruMemoize(func, equalityCheckOrOptions) {
|
|
|
25546
25546
|
return memoized;
|
|
25547
25547
|
}
|
|
25548
25548
|
//#endregion
|
|
25549
|
-
//#region ../../node_modules/.pnpm/@mui+x-internals@9.
|
|
25549
|
+
//#region ../../node_modules/.pnpm/@mui+x-internals@9.13.0_@types+react@19.2.18_react-dom@19.2.8_react@19.2.8__react@19.2.8/node_modules/@mui/x-internals/store/createSelector.mjs
|
|
25550
25550
|
var reselectCreateSelector = createSelectorCreator({
|
|
25551
25551
|
memoize: lruMemoize,
|
|
25552
25552
|
memoizeOptions: {
|
|
@@ -25704,7 +25704,7 @@ var createSelectorMemoizedWithOptions = (options) => (...inputs) => {
|
|
|
25704
25704
|
*/
|
|
25705
25705
|
var createSelectorMemoized = createSelectorMemoizedWithOptions();
|
|
25706
25706
|
//#endregion
|
|
25707
|
-
//#region ../../node_modules/.pnpm/@mui+x-internals@9.
|
|
25707
|
+
//#region ../../node_modules/.pnpm/@mui+x-internals@9.13.0_@types+react@19.2.18_react-dom@19.2.8_react@19.2.8__react@19.2.8/node_modules/@mui/x-internals/store/useStore.mjs
|
|
25708
25708
|
var useStoreImplementation = parseInt(React$1.version, 10) >= 19 ? useStoreR19 : useStoreLegacy;
|
|
25709
25709
|
function useStore(store, selector, a1, a2, a3) {
|
|
25710
25710
|
return useStoreImplementation(store, selector, a1, a2, a3);
|
|
@@ -25723,7 +25723,7 @@ function useStoreLegacy(store, selector, a1, a2, a3) {
|
|
|
25723
25723
|
return useSyncExternalStoreWithSelector(store.subscribe, store.getSnapshot, store.getSnapshot, (state) => selector(state, a1, a2, a3));
|
|
25724
25724
|
}
|
|
25725
25725
|
//#endregion
|
|
25726
|
-
//#region ../../node_modules/.pnpm/@mui+x-internals@9.
|
|
25726
|
+
//#region ../../node_modules/.pnpm/@mui+x-internals@9.13.0_@types+react@19.2.18_react-dom@19.2.8_react@19.2.8__react@19.2.8/node_modules/@mui/x-internals/store/Store.mjs
|
|
25727
25727
|
var Store = class Store {
|
|
25728
25728
|
static create(state) {
|
|
25729
25729
|
return new Store(state);
|
|
@@ -25937,7 +25937,7 @@ function TreeViewProvider(props) {
|
|
|
25937
25937
|
});
|
|
25938
25938
|
}
|
|
25939
25939
|
//#endregion
|
|
25940
|
-
//#region ../../node_modules/.pnpm/@mui+x-internals@9.
|
|
25940
|
+
//#region ../../node_modules/.pnpm/@mui+x-internals@9.13.0_@types+react@19.2.18_react-dom@19.2.8_react@19.2.8__react@19.2.8/node_modules/@mui/x-internals/fastObjectShallowCompare/fastObjectShallowCompare.mjs
|
|
25941
25941
|
var is = Object.is;
|
|
25942
25942
|
/**
|
|
25943
25943
|
* Fast shallow compare for objects.
|
|
@@ -28180,7 +28180,7 @@ function useOnMount(fn) {
|
|
|
28180
28180
|
*/
|
|
28181
28181
|
var SafeReact = { ...React$1 };
|
|
28182
28182
|
//#endregion
|
|
28183
|
-
//#region ../../node_modules/.pnpm/@mui+x-internals@9.
|
|
28183
|
+
//#region ../../node_modules/.pnpm/@mui+x-internals@9.13.0_@types+react@19.2.18_react-dom@19.2.8_react@19.2.8__react@19.2.8/node_modules/@mui/x-internals/disposable/index.mjs
|
|
28184
28184
|
/**
|
|
28185
28185
|
* Well-known `Symbol.dispose`. Resolves to the native well-known symbol when
|
|
28186
28186
|
* the runtime ships the explicit resource management proposal; otherwise falls
|
|
@@ -28297,7 +28297,7 @@ function unwrapSuppressedErrors(error) {
|
|
|
28297
28297
|
return failures;
|
|
28298
28298
|
}
|
|
28299
28299
|
//#endregion
|
|
28300
|
-
//#region ../../node_modules/.pnpm/@mui+x-internals@9.
|
|
28300
|
+
//#region ../../node_modules/.pnpm/@mui+x-internals@9.13.0_@types+react@19.2.18_react-dom@19.2.8_react@19.2.8__react@19.2.8/node_modules/@mui/x-internals/useDisposable/useDisposable.mjs
|
|
28301
28301
|
var STRICT_MODE_BITS = 16;
|
|
28302
28302
|
var SafeReactInternals = SafeReact;
|
|
28303
28303
|
var ReactInternals = SafeReactInternals.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE ?? SafeReactInternals.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
|
|
@@ -28400,7 +28400,7 @@ function useTreeViewStore(StoreClass, parameters) {
|
|
|
28400
28400
|
return store;
|
|
28401
28401
|
}
|
|
28402
28402
|
//#endregion
|
|
28403
|
-
//#region ../../node_modules/.pnpm/@mui+x-internals@9.
|
|
28403
|
+
//#region ../../node_modules/.pnpm/@mui+x-internals@9.13.0_@types+react@19.2.18_react-dom@19.2.8_react@19.2.8__react@19.2.8/node_modules/@mui/x-internals/EventManager/EventManager.mjs
|
|
28404
28404
|
var EventManager = class {
|
|
28405
28405
|
maxListeners = 20;
|
|
28406
28406
|
warnOnce = false;
|
|
@@ -29562,4 +29562,4 @@ var ZoomControl = ({ step = 10, value = 50, onChange, max = 100, min = 0, label
|
|
|
29562
29562
|
//#endregion
|
|
29563
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-CUvREoVb.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-DLUPogQT.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");
|
|
@@ -609,7 +609,7 @@ var CODE_BLOCK_SHORTCUT_KEY = "mod+alt+c";
|
|
|
609
609
|
/**
|
|
610
610
|
* Checks if code block can be toggled in the current editor state
|
|
611
611
|
*/
|
|
612
|
-
function canToggle$
|
|
612
|
+
function canToggle$2(editor, turnInto = true) {
|
|
613
613
|
if (!editor || !editor.isEditable) return false;
|
|
614
614
|
if (!isNodeInSchema("codeBlock", editor) || isNodeTypeSelected(editor, ["image"])) return false;
|
|
615
615
|
if (!turnInto) return editor.can().toggleNode("codeBlock", "paragraph");
|
|
@@ -629,7 +629,7 @@ function canToggle$1(editor, turnInto = true) {
|
|
|
629
629
|
*/
|
|
630
630
|
function toggleCodeBlock(editor) {
|
|
631
631
|
if (!editor || !editor.isEditable) return false;
|
|
632
|
-
if (!canToggle$
|
|
632
|
+
if (!canToggle$2(editor)) return false;
|
|
633
633
|
try {
|
|
634
634
|
const view = editor.view;
|
|
635
635
|
let state = view.state;
|
|
@@ -681,7 +681,7 @@ function shouldShowButton$4(props) {
|
|
|
681
681
|
if (!hideWhenUnavailable) return true;
|
|
682
682
|
if (!editor.isEditable) return false;
|
|
683
683
|
if (!isNodeInSchema("codeBlock", editor)) return false;
|
|
684
|
-
if (!editor.isActive("code")) return canToggle$
|
|
684
|
+
if (!editor.isActive("code")) return canToggle$2(editor);
|
|
685
685
|
return true;
|
|
686
686
|
}
|
|
687
687
|
/**
|
|
@@ -731,7 +731,7 @@ function useCodeBlock(config) {
|
|
|
731
731
|
const { editor: providedEditor, hideWhenUnavailable = false, onToggled } = config || {};
|
|
732
732
|
const { editor } = useTiptapEditor(providedEditor);
|
|
733
733
|
const [isVisible, setIsVisible] = (0, react.useState)(true);
|
|
734
|
-
const canToggleState = canToggle$
|
|
734
|
+
const canToggleState = canToggle$2(editor);
|
|
735
735
|
const isActive = editor?.isActive("codeBlock") || false;
|
|
736
736
|
(0, react.useEffect)(() => {
|
|
737
737
|
if (!editor) return;
|
|
@@ -897,7 +897,7 @@ var HEADING_SHORTCUT_KEYS = {
|
|
|
897
897
|
/**
|
|
898
898
|
* Checks if heading can be toggled in the current editor state
|
|
899
899
|
*/
|
|
900
|
-
function canToggle(editor, level, turnInto = true) {
|
|
900
|
+
function canToggle$1(editor, level, turnInto = true) {
|
|
901
901
|
if (!editor || !editor.isEditable) return false;
|
|
902
902
|
if (!isNodeInSchema("heading", editor) || isNodeTypeSelected(editor, ["image"])) return false;
|
|
903
903
|
if (!turnInto) return level ? editor.can().setNode("heading", { level }) : editor.can().setNode("heading");
|
|
@@ -926,7 +926,7 @@ function isHeadingActive(editor, level) {
|
|
|
926
926
|
function toggleHeading(editor, level) {
|
|
927
927
|
if (!editor || !editor.isEditable) return false;
|
|
928
928
|
const levels = Array.isArray(level) ? level : [level];
|
|
929
|
-
const toggleLevel = levels.find((l) => canToggle(editor, l));
|
|
929
|
+
const toggleLevel = levels.find((l) => canToggle$1(editor, l));
|
|
930
930
|
if (!toggleLevel) return false;
|
|
931
931
|
try {
|
|
932
932
|
const view = editor.view;
|
|
@@ -973,15 +973,15 @@ function toggleHeading(editor, level) {
|
|
|
973
973
|
/**
|
|
974
974
|
* Determines if the heading menu item should be shown
|
|
975
975
|
*/
|
|
976
|
-
function shouldShowItem(props) {
|
|
976
|
+
function shouldShowItem$1(props) {
|
|
977
977
|
const { editor, level, hideWhenUnavailable } = props;
|
|
978
978
|
if (!editor) return false;
|
|
979
979
|
if (!hideWhenUnavailable) return true;
|
|
980
980
|
if (!editor.isEditable) return false;
|
|
981
981
|
if (!isNodeInSchema("heading", editor)) return false;
|
|
982
982
|
if (!editor.isActive("code")) {
|
|
983
|
-
if (Array.isArray(level)) return level.some((l) => canToggle(editor, l));
|
|
984
|
-
return canToggle(editor, level);
|
|
983
|
+
if (Array.isArray(level)) return level.some((l) => canToggle$1(editor, l));
|
|
984
|
+
return canToggle$1(editor, level);
|
|
985
985
|
}
|
|
986
986
|
return true;
|
|
987
987
|
}
|
|
@@ -1035,12 +1035,12 @@ function useHeading(config) {
|
|
|
1035
1035
|
const { editor: providedEditor, level, hideWhenUnavailable = false, onToggled } = config;
|
|
1036
1036
|
const { editor } = useTiptapEditor(providedEditor);
|
|
1037
1037
|
const [isVisible, setIsVisible] = (0, react.useState)(true);
|
|
1038
|
-
const canToggleState = canToggle(editor, level);
|
|
1038
|
+
const canToggleState = canToggle$1(editor, level);
|
|
1039
1039
|
const isActive = isHeadingActive(editor, level);
|
|
1040
1040
|
(0, react.useEffect)(() => {
|
|
1041
1041
|
if (!editor) return;
|
|
1042
1042
|
const handleSelectionUpdate = () => {
|
|
1043
|
-
setIsVisible(shouldShowItem({
|
|
1043
|
+
setIsVisible(shouldShowItem$1({
|
|
1044
1044
|
editor,
|
|
1045
1045
|
level,
|
|
1046
1046
|
hideWhenUnavailable
|
|
@@ -1129,6 +1129,169 @@ var HeadingMenuItem = (0, react.forwardRef)(({ editor: providedEditor, level, te
|
|
|
1129
1129
|
});
|
|
1130
1130
|
HeadingMenuItem.displayName = "HeadingMenuItem";
|
|
1131
1131
|
//#endregion
|
|
1132
|
+
//#region src/tiptap/components/ui/paragraph-menu-item/use-paragraph.ts
|
|
1133
|
+
/**
|
|
1134
|
+
* Checks if paragraph can be toggled in the current editor state
|
|
1135
|
+
*/
|
|
1136
|
+
function canToggle(editor, turnInto = true) {
|
|
1137
|
+
if (!editor || !editor.isEditable) return false;
|
|
1138
|
+
if (!isNodeInSchema("paragraph", editor) || isNodeTypeSelected(editor, ["image"])) return false;
|
|
1139
|
+
if (!turnInto) return editor.can().setNode("paragraph");
|
|
1140
|
+
if (!selectionWithinConvertibleTypes(editor, [
|
|
1141
|
+
"paragraph",
|
|
1142
|
+
"heading",
|
|
1143
|
+
"bulletList",
|
|
1144
|
+
"orderedList",
|
|
1145
|
+
"taskList",
|
|
1146
|
+
"blockquote",
|
|
1147
|
+
"codeBlock"
|
|
1148
|
+
])) return false;
|
|
1149
|
+
return editor.can().setNode("paragraph") || editor.can().clearNodes();
|
|
1150
|
+
}
|
|
1151
|
+
/**
|
|
1152
|
+
* Checks if paragraph is currently active
|
|
1153
|
+
*/
|
|
1154
|
+
function isParagraphActive(editor) {
|
|
1155
|
+
if (!editor || !editor.isEditable) return false;
|
|
1156
|
+
return editor.isActive("paragraph");
|
|
1157
|
+
}
|
|
1158
|
+
/**
|
|
1159
|
+
* Toggles paragraph in the editor
|
|
1160
|
+
*/
|
|
1161
|
+
function toggleParagraph(editor) {
|
|
1162
|
+
if (!editor || !editor.isEditable || !canToggle(editor)) return false;
|
|
1163
|
+
try {
|
|
1164
|
+
const view = editor.view;
|
|
1165
|
+
let state = view.state;
|
|
1166
|
+
let tr = state.tr;
|
|
1167
|
+
const blocks = getSelectedBlockNodes(editor);
|
|
1168
|
+
const isPossibleToTurnInto = selectionWithinConvertibleTypes(editor, [
|
|
1169
|
+
"paragraph",
|
|
1170
|
+
"heading",
|
|
1171
|
+
"bulletList",
|
|
1172
|
+
"orderedList",
|
|
1173
|
+
"taskList",
|
|
1174
|
+
"blockquote",
|
|
1175
|
+
"codeBlock"
|
|
1176
|
+
]) && blocks.length === 1;
|
|
1177
|
+
if ((state.selection.empty || state.selection instanceof _tiptap_pm_state.TextSelection) && isPossibleToTurnInto) {
|
|
1178
|
+
const pos = findNodePosition({
|
|
1179
|
+
editor,
|
|
1180
|
+
node: state.selection.$anchor.node(1)
|
|
1181
|
+
})?.pos;
|
|
1182
|
+
if (!isValidPosition(pos)) return false;
|
|
1183
|
+
tr = tr.setSelection(_tiptap_pm_state.NodeSelection.create(state.doc, pos));
|
|
1184
|
+
view.dispatch(tr);
|
|
1185
|
+
state = view.state;
|
|
1186
|
+
}
|
|
1187
|
+
const selection = state.selection;
|
|
1188
|
+
let chain = editor.chain().focus();
|
|
1189
|
+
if (selection instanceof _tiptap_pm_state.NodeSelection) {
|
|
1190
|
+
const firstChild = selection.node.firstChild?.firstChild;
|
|
1191
|
+
const lastChild = selection.node.lastChild?.lastChild;
|
|
1192
|
+
const from = firstChild ? selection.from + firstChild.nodeSize : selection.from + 1;
|
|
1193
|
+
const to = lastChild ? selection.to - lastChild.nodeSize : selection.to - 1;
|
|
1194
|
+
const resolvedFrom = state.doc.resolve(from);
|
|
1195
|
+
const resolvedTo = state.doc.resolve(to);
|
|
1196
|
+
chain = chain.setTextSelection(_tiptap_pm_state.TextSelection.between(resolvedFrom, resolvedTo)).clearNodes();
|
|
1197
|
+
}
|
|
1198
|
+
chain.setNode("paragraph").run();
|
|
1199
|
+
editor.chain().focus().selectTextblockEnd().run();
|
|
1200
|
+
return true;
|
|
1201
|
+
} catch {
|
|
1202
|
+
return false;
|
|
1203
|
+
}
|
|
1204
|
+
}
|
|
1205
|
+
/**
|
|
1206
|
+
* Determines if the paragraph menu item should be shown
|
|
1207
|
+
*/
|
|
1208
|
+
function shouldShowItem(props) {
|
|
1209
|
+
const { editor, hideWhenUnavailable } = props;
|
|
1210
|
+
if (!editor) return false;
|
|
1211
|
+
if (!hideWhenUnavailable) return true;
|
|
1212
|
+
if (!editor.isEditable) return false;
|
|
1213
|
+
if (!isNodeInSchema("paragraph", editor)) return false;
|
|
1214
|
+
if (!editor.isActive("code")) return canToggle(editor);
|
|
1215
|
+
return true;
|
|
1216
|
+
}
|
|
1217
|
+
/**
|
|
1218
|
+
* Custom hook that provides paragraph functionality for Tiptap editor
|
|
1219
|
+
*/
|
|
1220
|
+
function useParagraph(config) {
|
|
1221
|
+
const { editor: providedEditor, hideWhenUnavailable = false, onToggled } = config;
|
|
1222
|
+
const { editor } = useTiptapEditor(providedEditor);
|
|
1223
|
+
const [isVisible, setIsVisible] = (0, react.useState)(true);
|
|
1224
|
+
const canToggleState = canToggle(editor);
|
|
1225
|
+
const isActive = isParagraphActive(editor);
|
|
1226
|
+
(0, react.useEffect)(() => {
|
|
1227
|
+
if (!editor) return;
|
|
1228
|
+
const handleSelectionUpdate = () => {
|
|
1229
|
+
setIsVisible(shouldShowItem({
|
|
1230
|
+
editor,
|
|
1231
|
+
hideWhenUnavailable
|
|
1232
|
+
}));
|
|
1233
|
+
};
|
|
1234
|
+
handleSelectionUpdate();
|
|
1235
|
+
editor.on("selectionUpdate", handleSelectionUpdate);
|
|
1236
|
+
return () => {
|
|
1237
|
+
editor.off("selectionUpdate", handleSelectionUpdate);
|
|
1238
|
+
};
|
|
1239
|
+
}, [editor, hideWhenUnavailable]);
|
|
1240
|
+
return {
|
|
1241
|
+
isVisible,
|
|
1242
|
+
isActive,
|
|
1243
|
+
handleToggle: (0, react.useCallback)(() => {
|
|
1244
|
+
if (!editor) return false;
|
|
1245
|
+
const success = toggleParagraph(editor);
|
|
1246
|
+
if (success) onToggled?.();
|
|
1247
|
+
return success;
|
|
1248
|
+
}, [editor, onToggled]),
|
|
1249
|
+
canToggle: canToggleState,
|
|
1250
|
+
label: "Paragraphe"
|
|
1251
|
+
};
|
|
1252
|
+
}
|
|
1253
|
+
//#endregion
|
|
1254
|
+
//#region src/tiptap/components/ui/paragraph-menu-item/paragraph-menu-item.tsx
|
|
1255
|
+
/**
|
|
1256
|
+
* Menu item component for toggling paragraph in a Tiptap editor.
|
|
1257
|
+
*
|
|
1258
|
+
* For custom menu item implementations, use the `useParagraph` hook instead.
|
|
1259
|
+
*/
|
|
1260
|
+
var ParagraphMenuItem = (0, react.forwardRef)(({ editor: providedEditor, text, hideWhenUnavailable = false, onToggled, showShortcut = false, onClick, children, ...menuItemProps }, ref) => {
|
|
1261
|
+
const { editor } = useTiptapEditor(providedEditor);
|
|
1262
|
+
const { isVisible, canToggle, isActive, handleToggle, label } = useParagraph({
|
|
1263
|
+
editor,
|
|
1264
|
+
hideWhenUnavailable,
|
|
1265
|
+
onToggled
|
|
1266
|
+
});
|
|
1267
|
+
const handleClick = (0, react.useCallback)((event) => {
|
|
1268
|
+
onClick?.(event);
|
|
1269
|
+
if (event.defaultPrevented) return;
|
|
1270
|
+
handleToggle();
|
|
1271
|
+
}, [handleToggle, onClick]);
|
|
1272
|
+
if (!isVisible) return null;
|
|
1273
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_mui_material_MenuItem.default, {
|
|
1274
|
+
component: "li",
|
|
1275
|
+
role: "button",
|
|
1276
|
+
tabIndex: -1,
|
|
1277
|
+
disabled: !canToggle,
|
|
1278
|
+
"data-disabled": !canToggle,
|
|
1279
|
+
"aria-label": label,
|
|
1280
|
+
"aria-pressed": isActive,
|
|
1281
|
+
tooltip: label,
|
|
1282
|
+
selected: isActive,
|
|
1283
|
+
onClick: handleClick,
|
|
1284
|
+
...menuItemProps,
|
|
1285
|
+
ref,
|
|
1286
|
+
children: children ?? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [label && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_mui_material_Typography.default, {
|
|
1287
|
+
component: "span",
|
|
1288
|
+
variant: "body2",
|
|
1289
|
+
children: label
|
|
1290
|
+
}), showShortcut && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_mui_material_Badge.default, { children: parseShortcutKeys({ shortcutKeys: "ctrl+alt+p" }) })] })
|
|
1291
|
+
});
|
|
1292
|
+
});
|
|
1293
|
+
ParagraphMenuItem.displayName = "ParagraphMenuItem";
|
|
1294
|
+
//#endregion
|
|
1132
1295
|
//#region src/tiptap/components/icons/heading-icon.tsx
|
|
1133
1296
|
var HeadingIcon = (0, _mui_material_utils.createSvgIcon)(/* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
|
|
1134
1297
|
d: "M6 3C6.55228 3 7 3.44772 7 4V11H17V4C17 3.44772 17.4477 3 18 3C18.5523 3 19 3.44772 19 4V20C19 20.5523 18.5523 21 18 21C17.4477 21 17 20.5523 17 20V13H7V20C7 20.5523 6.55228 21 6 21C5.44772 21 5 20.5523 5 20V4C5 3.44772 5.44772 3 6 3Z",
|
|
@@ -1202,11 +1365,11 @@ function useHeadingMenu(config) {
|
|
|
1202
1365
|
const [isVisible, setIsVisible] = (0, react.useState)(true);
|
|
1203
1366
|
const activeLevel = getActiveHeadingLevel(editor, levels);
|
|
1204
1367
|
const isActive = isHeadingActive(editor);
|
|
1205
|
-
const canToggleState = canToggle(editor);
|
|
1368
|
+
const canToggleState = canToggle$1(editor);
|
|
1206
1369
|
(0, react.useEffect)(() => {
|
|
1207
1370
|
if (!editor) return;
|
|
1208
1371
|
const handleSelectionUpdate = () => {
|
|
1209
|
-
setIsVisible(shouldShowItem({
|
|
1372
|
+
setIsVisible(shouldShowItem$1({
|
|
1210
1373
|
editor,
|
|
1211
1374
|
hideWhenUnavailable,
|
|
1212
1375
|
level: levels
|
|
@@ -1286,7 +1449,7 @@ var HeadingMenu = (0, react.forwardRef)(({ editor: providedEditor, levels = [
|
|
|
1286
1449
|
...buttonProps,
|
|
1287
1450
|
ref,
|
|
1288
1451
|
children: children ? children : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Icon, { fontSize: "small" }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ExpandMoreRounded_default, { sx: { fontSize: "0.75rem" } })] })
|
|
1289
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.
|
|
1452
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_mui_material_Menu.default, {
|
|
1290
1453
|
id: "heading-menu",
|
|
1291
1454
|
anchorEl,
|
|
1292
1455
|
open,
|
|
@@ -1295,12 +1458,15 @@ var HeadingMenu = (0, react.forwardRef)(({ editor: providedEditor, levels = [
|
|
|
1295
1458
|
"aria-labelledby": "heading-button",
|
|
1296
1459
|
role: "listbox"
|
|
1297
1460
|
} },
|
|
1298
|
-
children:
|
|
1461
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(ParagraphMenuItem, {
|
|
1462
|
+
editor,
|
|
1463
|
+
onClick: handleClose
|
|
1464
|
+
}), levels.map((level) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(HeadingMenuItem, {
|
|
1299
1465
|
editor,
|
|
1300
1466
|
level,
|
|
1301
1467
|
text: `Heading ${level}`,
|
|
1302
1468
|
onClick: handleClose
|
|
1303
|
-
}, `heading-${level}`))
|
|
1469
|
+
}, `heading-${level}`))]
|
|
1304
1470
|
})] });
|
|
1305
1471
|
});
|
|
1306
1472
|
HeadingMenu.displayName = "HeadingMenu";
|
|
@@ -2785,6 +2951,139 @@ var UndoRedoButton = (0, react.forwardRef)(({ editor: providedEditor, action, te
|
|
|
2785
2951
|
});
|
|
2786
2952
|
UndoRedoButton.displayName = "UndoRedoButton";
|
|
2787
2953
|
//#endregion
|
|
2954
|
+
//#region src/tiptap/components/ui-primitive/formatting-controls/const.tsx
|
|
2955
|
+
var BUTTON_DEFS = [
|
|
2956
|
+
{
|
|
2957
|
+
id: "undo",
|
|
2958
|
+
extensionName: "undoRedo",
|
|
2959
|
+
group: "history",
|
|
2960
|
+
Component: () => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(UndoRedoButton, { action: "undo" })
|
|
2961
|
+
},
|
|
2962
|
+
{
|
|
2963
|
+
id: "redo",
|
|
2964
|
+
extensionName: "undoRedo",
|
|
2965
|
+
group: "history",
|
|
2966
|
+
Component: () => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(UndoRedoButton, { action: "redo" })
|
|
2967
|
+
},
|
|
2968
|
+
{
|
|
2969
|
+
id: "heading",
|
|
2970
|
+
extensionName: "heading",
|
|
2971
|
+
group: "blocks",
|
|
2972
|
+
Component: () => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(HeadingMenu, {
|
|
2973
|
+
modal: false,
|
|
2974
|
+
levels: [
|
|
2975
|
+
1,
|
|
2976
|
+
2,
|
|
2977
|
+
3,
|
|
2978
|
+
4
|
|
2979
|
+
]
|
|
2980
|
+
})
|
|
2981
|
+
},
|
|
2982
|
+
{
|
|
2983
|
+
id: "bulletList",
|
|
2984
|
+
extensionName: "bulletList",
|
|
2985
|
+
group: "blocks",
|
|
2986
|
+
Component: () => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ListButton, { type: "bulletList" })
|
|
2987
|
+
},
|
|
2988
|
+
{
|
|
2989
|
+
id: "orderedList",
|
|
2990
|
+
extensionName: "orderedList",
|
|
2991
|
+
group: "blocks",
|
|
2992
|
+
Component: () => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ListButton, { type: "orderedList" })
|
|
2993
|
+
},
|
|
2994
|
+
{
|
|
2995
|
+
id: "blockquote",
|
|
2996
|
+
extensionName: "blockquote",
|
|
2997
|
+
group: "blocks",
|
|
2998
|
+
Component: BlockquoteButton
|
|
2999
|
+
},
|
|
3000
|
+
{
|
|
3001
|
+
id: "codeBlock",
|
|
3002
|
+
extensionName: "codeBlock",
|
|
3003
|
+
group: "blocks",
|
|
3004
|
+
Component: CodeBlockButton
|
|
3005
|
+
},
|
|
3006
|
+
{
|
|
3007
|
+
id: "textColor",
|
|
3008
|
+
extensionName: "textStyle",
|
|
3009
|
+
group: "marks",
|
|
3010
|
+
Component: TextColorPopover
|
|
3011
|
+
},
|
|
3012
|
+
{
|
|
3013
|
+
id: "bold",
|
|
3014
|
+
extensionName: "bold",
|
|
3015
|
+
group: "marks",
|
|
3016
|
+
Component: () => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MarkButton, { type: "bold" })
|
|
3017
|
+
},
|
|
3018
|
+
{
|
|
3019
|
+
id: "italic",
|
|
3020
|
+
extensionName: "italic",
|
|
3021
|
+
group: "marks",
|
|
3022
|
+
Component: () => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MarkButton, { type: "italic" })
|
|
3023
|
+
},
|
|
3024
|
+
{
|
|
3025
|
+
id: "strike",
|
|
3026
|
+
extensionName: "strike",
|
|
3027
|
+
group: "marks",
|
|
3028
|
+
Component: () => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MarkButton, { type: "strike" })
|
|
3029
|
+
},
|
|
3030
|
+
{
|
|
3031
|
+
id: "code",
|
|
3032
|
+
extensionName: "code",
|
|
3033
|
+
group: "marks",
|
|
3034
|
+
Component: () => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MarkButton, { type: "code" })
|
|
3035
|
+
},
|
|
3036
|
+
{
|
|
3037
|
+
id: "underline",
|
|
3038
|
+
extensionName: "underline",
|
|
3039
|
+
group: "marks",
|
|
3040
|
+
Component: () => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MarkButton, { type: "underline" })
|
|
3041
|
+
},
|
|
3042
|
+
{
|
|
3043
|
+
id: "link",
|
|
3044
|
+
extensionName: "link",
|
|
3045
|
+
group: "marks",
|
|
3046
|
+
Component: LinkPopover
|
|
3047
|
+
},
|
|
3048
|
+
{
|
|
3049
|
+
id: "superscript",
|
|
3050
|
+
extensionName: "superscript",
|
|
3051
|
+
group: "scripts",
|
|
3052
|
+
Component: () => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MarkButton, { type: "superscript" })
|
|
3053
|
+
},
|
|
3054
|
+
{
|
|
3055
|
+
id: "subscript",
|
|
3056
|
+
extensionName: "subscript",
|
|
3057
|
+
group: "scripts",
|
|
3058
|
+
Component: () => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MarkButton, { type: "subscript" })
|
|
3059
|
+
},
|
|
3060
|
+
{
|
|
3061
|
+
id: "alignLeft",
|
|
3062
|
+
extensionName: "textAlign",
|
|
3063
|
+
group: "textAlign",
|
|
3064
|
+
Component: () => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TextAlignButton, { align: "left" })
|
|
3065
|
+
},
|
|
3066
|
+
{
|
|
3067
|
+
id: "alignCenter",
|
|
3068
|
+
extensionName: "textAlign",
|
|
3069
|
+
group: "textAlign",
|
|
3070
|
+
Component: () => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TextAlignButton, { align: "center" })
|
|
3071
|
+
},
|
|
3072
|
+
{
|
|
3073
|
+
id: "alignRight",
|
|
3074
|
+
extensionName: "textAlign",
|
|
3075
|
+
group: "textAlign",
|
|
3076
|
+
Component: () => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TextAlignButton, { align: "right" })
|
|
3077
|
+
},
|
|
3078
|
+
{
|
|
3079
|
+
id: "alignJustify",
|
|
3080
|
+
extensionName: "textAlign",
|
|
3081
|
+
group: "textAlign",
|
|
3082
|
+
Component: () => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TextAlignButton, { align: "justify" })
|
|
3083
|
+
}
|
|
3084
|
+
];
|
|
3085
|
+
var BUTTON_IDS = BUTTON_DEFS.map((def) => def.id);
|
|
3086
|
+
//#endregion
|
|
2788
3087
|
//#region src/tiptap/hooks/use-composed-ref.ts
|
|
2789
3088
|
var updateRef = (ref, value) => {
|
|
2790
3089
|
if (typeof ref === "function") ref(value);
|
|
@@ -3030,48 +3329,28 @@ var ToolbarSeparator = () => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_mui_mat
|
|
|
3030
3329
|
});
|
|
3031
3330
|
ToolbarSeparator.displayName = "ToolbarSeparator";
|
|
3032
3331
|
//#endregion
|
|
3332
|
+
//#region src/tiptap/components/ui-primitive/formatting-controls/hooks.ts
|
|
3333
|
+
var useFormattingItems = (editor) => {
|
|
3334
|
+
return (0, react.useMemo)(() => {
|
|
3335
|
+
if (!editor) return [];
|
|
3336
|
+
return BUTTON_DEFS.filter((def) => def.extensionName ? editor.extensionManager.extensions.some((e) => e.name === def.extensionName) : true);
|
|
3337
|
+
}, [editor]);
|
|
3338
|
+
};
|
|
3339
|
+
//#endregion
|
|
3340
|
+
//#region src/tiptap/components/ui-primitive/formatting-controls/utils.ts
|
|
3341
|
+
function groupBy(items, getKey) {
|
|
3342
|
+
return items.reduce((acc, item) => {
|
|
3343
|
+
const key = getKey(item);
|
|
3344
|
+
(acc[key] ??= []).push(item);
|
|
3345
|
+
return acc;
|
|
3346
|
+
}, {});
|
|
3347
|
+
}
|
|
3348
|
+
//#endregion
|
|
3033
3349
|
//#region src/tiptap/components/ui-primitive/formatting-controls/formatting-controls.tsx
|
|
3034
|
-
var FormattingControls = ({ editor }) => {
|
|
3035
|
-
const
|
|
3036
|
-
const
|
|
3037
|
-
|
|
3038
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
3039
|
-
/* @__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" })] }),
|
|
3040
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolbarSeparator, {}),
|
|
3041
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(ToolbarGroup, { children: [
|
|
3042
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(HeadingMenu, {
|
|
3043
|
-
modal: false,
|
|
3044
|
-
levels: [
|
|
3045
|
-
1,
|
|
3046
|
-
2,
|
|
3047
|
-
3,
|
|
3048
|
-
4
|
|
3049
|
-
]
|
|
3050
|
-
}),
|
|
3051
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(ListButton, { type: "bulletList" }),
|
|
3052
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(ListButton, { type: "orderedList" }),
|
|
3053
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(BlockquoteButton, {}),
|
|
3054
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(CodeBlockButton, {})
|
|
3055
|
-
] }),
|
|
3056
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolbarSeparator, {}),
|
|
3057
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(ToolbarGroup, { children: [
|
|
3058
|
-
hasTextStyle ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TextColorPopover, {}) : null,
|
|
3059
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(MarkButton, { type: "bold" }),
|
|
3060
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(MarkButton, { type: "italic" }),
|
|
3061
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(MarkButton, { type: "strike" }),
|
|
3062
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(MarkButton, { type: "code" }),
|
|
3063
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(MarkButton, { type: "underline" }),
|
|
3064
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(LinkPopover, {})
|
|
3065
|
-
] }),
|
|
3066
|
-
hasSuperscriptSubscript ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolbarSeparator, {}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(ToolbarGroup, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(MarkButton, { type: "superscript" }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MarkButton, { type: "subscript" })] })] }) : null,
|
|
3067
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolbarSeparator, {}),
|
|
3068
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(ToolbarGroup, { children: [
|
|
3069
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(TextAlignButton, { align: "left" }),
|
|
3070
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(TextAlignButton, { align: "center" }),
|
|
3071
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(TextAlignButton, { align: "right" }),
|
|
3072
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(TextAlignButton, { align: "justify" })
|
|
3073
|
-
] })
|
|
3074
|
-
] });
|
|
3350
|
+
var FormattingControls = ({ editor, include }) => {
|
|
3351
|
+
const items = useFormattingItems(editor);
|
|
3352
|
+
const groups = groupBy(include ? items.filter((button) => include.includes(button.id)) : items, (button) => button.group);
|
|
3353
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, { children: Object.entries(groups).map(([groupId, groupItems], index) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react.Fragment, { children: [index > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolbarSeparator, {}) : null, /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolbarGroup, { children: groupItems.map((item) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(item.Component, {}, item.id)) })] }, groupId)) });
|
|
3075
3354
|
};
|
|
3076
3355
|
FormattingControls.displayName = "FormattingControls";
|
|
3077
3356
|
//#endregion
|
|
@@ -3091,6 +3370,7 @@ function Spacer({ orientation = "horizontal", size, style = {}, ...props }) {
|
|
|
3091
3370
|
});
|
|
3092
3371
|
}
|
|
3093
3372
|
//#endregion
|
|
3373
|
+
exports.BUTTON_IDS = BUTTON_IDS;
|
|
3094
3374
|
exports.FormattingControls = FormattingControls;
|
|
3095
3375
|
exports.Spacer = Spacer;
|
|
3096
3376
|
exports.Toolbar = Toolbar;
|
package/dist/tiptap/index.d.ts
CHANGED
|
@@ -7,13 +7,25 @@ declare type BaseProps = React.HTMLAttributes<HTMLDivElement>;
|
|
|
7
7
|
|
|
8
8
|
declare type BaseProps_2 = React.HTMLAttributes<HTMLDivElement>;
|
|
9
9
|
|
|
10
|
+
export declare const BUTTON_IDS: string[];
|
|
11
|
+
|
|
12
|
+
declare type ButtonDef = {
|
|
13
|
+
Component: React.FC;
|
|
14
|
+
extensionName: string;
|
|
15
|
+
group: ButtonGroup;
|
|
16
|
+
id: string;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
declare type ButtonGroup = "history" | "blocks" | "marks" | "scripts" | "textAlign";
|
|
20
|
+
|
|
10
21
|
export declare const FormattingControls: {
|
|
11
|
-
({ editor }: FormattingControlsProps): JSX.Element;
|
|
22
|
+
({ editor, include, }: FormattingControlsProps): JSX.Element;
|
|
12
23
|
displayName: string;
|
|
13
24
|
};
|
|
14
25
|
|
|
15
26
|
declare interface FormattingControlsProps extends BaseProps {
|
|
16
27
|
editor: Editor;
|
|
28
|
+
include?: ButtonDef["id"][];
|
|
17
29
|
}
|
|
18
30
|
|
|
19
31
|
export declare function Spacer({ orientation, size, style, ...props }: React.ComponentProps<"div"> & {
|
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, 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-
|
|
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-CUvREoVb.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";
|
|
@@ -585,7 +585,7 @@ var CODE_BLOCK_SHORTCUT_KEY = "mod+alt+c";
|
|
|
585
585
|
/**
|
|
586
586
|
* Checks if code block can be toggled in the current editor state
|
|
587
587
|
*/
|
|
588
|
-
function canToggle$
|
|
588
|
+
function canToggle$2(editor, turnInto = true) {
|
|
589
589
|
if (!editor || !editor.isEditable) return false;
|
|
590
590
|
if (!isNodeInSchema("codeBlock", editor) || isNodeTypeSelected(editor, ["image"])) return false;
|
|
591
591
|
if (!turnInto) return editor.can().toggleNode("codeBlock", "paragraph");
|
|
@@ -605,7 +605,7 @@ function canToggle$1(editor, turnInto = true) {
|
|
|
605
605
|
*/
|
|
606
606
|
function toggleCodeBlock(editor) {
|
|
607
607
|
if (!editor || !editor.isEditable) return false;
|
|
608
|
-
if (!canToggle$
|
|
608
|
+
if (!canToggle$2(editor)) return false;
|
|
609
609
|
try {
|
|
610
610
|
const view = editor.view;
|
|
611
611
|
let state = view.state;
|
|
@@ -657,7 +657,7 @@ function shouldShowButton$4(props) {
|
|
|
657
657
|
if (!hideWhenUnavailable) return true;
|
|
658
658
|
if (!editor.isEditable) return false;
|
|
659
659
|
if (!isNodeInSchema("codeBlock", editor)) return false;
|
|
660
|
-
if (!editor.isActive("code")) return canToggle$
|
|
660
|
+
if (!editor.isActive("code")) return canToggle$2(editor);
|
|
661
661
|
return true;
|
|
662
662
|
}
|
|
663
663
|
/**
|
|
@@ -707,7 +707,7 @@ function useCodeBlock(config) {
|
|
|
707
707
|
const { editor: providedEditor, hideWhenUnavailable = false, onToggled } = config || {};
|
|
708
708
|
const { editor } = useTiptapEditor(providedEditor);
|
|
709
709
|
const [isVisible, setIsVisible] = useState(true);
|
|
710
|
-
const canToggleState = canToggle$
|
|
710
|
+
const canToggleState = canToggle$2(editor);
|
|
711
711
|
const isActive = editor?.isActive("codeBlock") || false;
|
|
712
712
|
useEffect(() => {
|
|
713
713
|
if (!editor) return;
|
|
@@ -873,7 +873,7 @@ var HEADING_SHORTCUT_KEYS = {
|
|
|
873
873
|
/**
|
|
874
874
|
* Checks if heading can be toggled in the current editor state
|
|
875
875
|
*/
|
|
876
|
-
function canToggle(editor, level, turnInto = true) {
|
|
876
|
+
function canToggle$1(editor, level, turnInto = true) {
|
|
877
877
|
if (!editor || !editor.isEditable) return false;
|
|
878
878
|
if (!isNodeInSchema("heading", editor) || isNodeTypeSelected(editor, ["image"])) return false;
|
|
879
879
|
if (!turnInto) return level ? editor.can().setNode("heading", { level }) : editor.can().setNode("heading");
|
|
@@ -902,7 +902,7 @@ function isHeadingActive(editor, level) {
|
|
|
902
902
|
function toggleHeading(editor, level) {
|
|
903
903
|
if (!editor || !editor.isEditable) return false;
|
|
904
904
|
const levels = Array.isArray(level) ? level : [level];
|
|
905
|
-
const toggleLevel = levels.find((l) => canToggle(editor, l));
|
|
905
|
+
const toggleLevel = levels.find((l) => canToggle$1(editor, l));
|
|
906
906
|
if (!toggleLevel) return false;
|
|
907
907
|
try {
|
|
908
908
|
const view = editor.view;
|
|
@@ -949,15 +949,15 @@ function toggleHeading(editor, level) {
|
|
|
949
949
|
/**
|
|
950
950
|
* Determines if the heading menu item should be shown
|
|
951
951
|
*/
|
|
952
|
-
function shouldShowItem(props) {
|
|
952
|
+
function shouldShowItem$1(props) {
|
|
953
953
|
const { editor, level, hideWhenUnavailable } = props;
|
|
954
954
|
if (!editor) return false;
|
|
955
955
|
if (!hideWhenUnavailable) return true;
|
|
956
956
|
if (!editor.isEditable) return false;
|
|
957
957
|
if (!isNodeInSchema("heading", editor)) return false;
|
|
958
958
|
if (!editor.isActive("code")) {
|
|
959
|
-
if (Array.isArray(level)) return level.some((l) => canToggle(editor, l));
|
|
960
|
-
return canToggle(editor, level);
|
|
959
|
+
if (Array.isArray(level)) return level.some((l) => canToggle$1(editor, l));
|
|
960
|
+
return canToggle$1(editor, level);
|
|
961
961
|
}
|
|
962
962
|
return true;
|
|
963
963
|
}
|
|
@@ -1011,12 +1011,12 @@ function useHeading(config) {
|
|
|
1011
1011
|
const { editor: providedEditor, level, hideWhenUnavailable = false, onToggled } = config;
|
|
1012
1012
|
const { editor } = useTiptapEditor(providedEditor);
|
|
1013
1013
|
const [isVisible, setIsVisible] = useState(true);
|
|
1014
|
-
const canToggleState = canToggle(editor, level);
|
|
1014
|
+
const canToggleState = canToggle$1(editor, level);
|
|
1015
1015
|
const isActive = isHeadingActive(editor, level);
|
|
1016
1016
|
useEffect(() => {
|
|
1017
1017
|
if (!editor) return;
|
|
1018
1018
|
const handleSelectionUpdate = () => {
|
|
1019
|
-
setIsVisible(shouldShowItem({
|
|
1019
|
+
setIsVisible(shouldShowItem$1({
|
|
1020
1020
|
editor,
|
|
1021
1021
|
level,
|
|
1022
1022
|
hideWhenUnavailable
|
|
@@ -1105,6 +1105,169 @@ var HeadingMenuItem = forwardRef(({ editor: providedEditor, level, text, hideWhe
|
|
|
1105
1105
|
});
|
|
1106
1106
|
HeadingMenuItem.displayName = "HeadingMenuItem";
|
|
1107
1107
|
//#endregion
|
|
1108
|
+
//#region src/tiptap/components/ui/paragraph-menu-item/use-paragraph.ts
|
|
1109
|
+
/**
|
|
1110
|
+
* Checks if paragraph can be toggled in the current editor state
|
|
1111
|
+
*/
|
|
1112
|
+
function canToggle(editor, turnInto = true) {
|
|
1113
|
+
if (!editor || !editor.isEditable) return false;
|
|
1114
|
+
if (!isNodeInSchema("paragraph", editor) || isNodeTypeSelected(editor, ["image"])) return false;
|
|
1115
|
+
if (!turnInto) return editor.can().setNode("paragraph");
|
|
1116
|
+
if (!selectionWithinConvertibleTypes(editor, [
|
|
1117
|
+
"paragraph",
|
|
1118
|
+
"heading",
|
|
1119
|
+
"bulletList",
|
|
1120
|
+
"orderedList",
|
|
1121
|
+
"taskList",
|
|
1122
|
+
"blockquote",
|
|
1123
|
+
"codeBlock"
|
|
1124
|
+
])) return false;
|
|
1125
|
+
return editor.can().setNode("paragraph") || editor.can().clearNodes();
|
|
1126
|
+
}
|
|
1127
|
+
/**
|
|
1128
|
+
* Checks if paragraph is currently active
|
|
1129
|
+
*/
|
|
1130
|
+
function isParagraphActive(editor) {
|
|
1131
|
+
if (!editor || !editor.isEditable) return false;
|
|
1132
|
+
return editor.isActive("paragraph");
|
|
1133
|
+
}
|
|
1134
|
+
/**
|
|
1135
|
+
* Toggles paragraph in the editor
|
|
1136
|
+
*/
|
|
1137
|
+
function toggleParagraph(editor) {
|
|
1138
|
+
if (!editor || !editor.isEditable || !canToggle(editor)) return false;
|
|
1139
|
+
try {
|
|
1140
|
+
const view = editor.view;
|
|
1141
|
+
let state = view.state;
|
|
1142
|
+
let tr = state.tr;
|
|
1143
|
+
const blocks = getSelectedBlockNodes(editor);
|
|
1144
|
+
const isPossibleToTurnInto = selectionWithinConvertibleTypes(editor, [
|
|
1145
|
+
"paragraph",
|
|
1146
|
+
"heading",
|
|
1147
|
+
"bulletList",
|
|
1148
|
+
"orderedList",
|
|
1149
|
+
"taskList",
|
|
1150
|
+
"blockquote",
|
|
1151
|
+
"codeBlock"
|
|
1152
|
+
]) && blocks.length === 1;
|
|
1153
|
+
if ((state.selection.empty || state.selection instanceof TextSelection) && isPossibleToTurnInto) {
|
|
1154
|
+
const pos = findNodePosition({
|
|
1155
|
+
editor,
|
|
1156
|
+
node: state.selection.$anchor.node(1)
|
|
1157
|
+
})?.pos;
|
|
1158
|
+
if (!isValidPosition(pos)) return false;
|
|
1159
|
+
tr = tr.setSelection(NodeSelection.create(state.doc, pos));
|
|
1160
|
+
view.dispatch(tr);
|
|
1161
|
+
state = view.state;
|
|
1162
|
+
}
|
|
1163
|
+
const selection = state.selection;
|
|
1164
|
+
let chain = editor.chain().focus();
|
|
1165
|
+
if (selection instanceof NodeSelection) {
|
|
1166
|
+
const firstChild = selection.node.firstChild?.firstChild;
|
|
1167
|
+
const lastChild = selection.node.lastChild?.lastChild;
|
|
1168
|
+
const from = firstChild ? selection.from + firstChild.nodeSize : selection.from + 1;
|
|
1169
|
+
const to = lastChild ? selection.to - lastChild.nodeSize : selection.to - 1;
|
|
1170
|
+
const resolvedFrom = state.doc.resolve(from);
|
|
1171
|
+
const resolvedTo = state.doc.resolve(to);
|
|
1172
|
+
chain = chain.setTextSelection(TextSelection.between(resolvedFrom, resolvedTo)).clearNodes();
|
|
1173
|
+
}
|
|
1174
|
+
chain.setNode("paragraph").run();
|
|
1175
|
+
editor.chain().focus().selectTextblockEnd().run();
|
|
1176
|
+
return true;
|
|
1177
|
+
} catch {
|
|
1178
|
+
return false;
|
|
1179
|
+
}
|
|
1180
|
+
}
|
|
1181
|
+
/**
|
|
1182
|
+
* Determines if the paragraph menu item should be shown
|
|
1183
|
+
*/
|
|
1184
|
+
function shouldShowItem(props) {
|
|
1185
|
+
const { editor, hideWhenUnavailable } = props;
|
|
1186
|
+
if (!editor) return false;
|
|
1187
|
+
if (!hideWhenUnavailable) return true;
|
|
1188
|
+
if (!editor.isEditable) return false;
|
|
1189
|
+
if (!isNodeInSchema("paragraph", editor)) return false;
|
|
1190
|
+
if (!editor.isActive("code")) return canToggle(editor);
|
|
1191
|
+
return true;
|
|
1192
|
+
}
|
|
1193
|
+
/**
|
|
1194
|
+
* Custom hook that provides paragraph functionality for Tiptap editor
|
|
1195
|
+
*/
|
|
1196
|
+
function useParagraph(config) {
|
|
1197
|
+
const { editor: providedEditor, hideWhenUnavailable = false, onToggled } = config;
|
|
1198
|
+
const { editor } = useTiptapEditor(providedEditor);
|
|
1199
|
+
const [isVisible, setIsVisible] = useState(true);
|
|
1200
|
+
const canToggleState = canToggle(editor);
|
|
1201
|
+
const isActive = isParagraphActive(editor);
|
|
1202
|
+
useEffect(() => {
|
|
1203
|
+
if (!editor) return;
|
|
1204
|
+
const handleSelectionUpdate = () => {
|
|
1205
|
+
setIsVisible(shouldShowItem({
|
|
1206
|
+
editor,
|
|
1207
|
+
hideWhenUnavailable
|
|
1208
|
+
}));
|
|
1209
|
+
};
|
|
1210
|
+
handleSelectionUpdate();
|
|
1211
|
+
editor.on("selectionUpdate", handleSelectionUpdate);
|
|
1212
|
+
return () => {
|
|
1213
|
+
editor.off("selectionUpdate", handleSelectionUpdate);
|
|
1214
|
+
};
|
|
1215
|
+
}, [editor, hideWhenUnavailable]);
|
|
1216
|
+
return {
|
|
1217
|
+
isVisible,
|
|
1218
|
+
isActive,
|
|
1219
|
+
handleToggle: useCallback(() => {
|
|
1220
|
+
if (!editor) return false;
|
|
1221
|
+
const success = toggleParagraph(editor);
|
|
1222
|
+
if (success) onToggled?.();
|
|
1223
|
+
return success;
|
|
1224
|
+
}, [editor, onToggled]),
|
|
1225
|
+
canToggle: canToggleState,
|
|
1226
|
+
label: "Paragraphe"
|
|
1227
|
+
};
|
|
1228
|
+
}
|
|
1229
|
+
//#endregion
|
|
1230
|
+
//#region src/tiptap/components/ui/paragraph-menu-item/paragraph-menu-item.tsx
|
|
1231
|
+
/**
|
|
1232
|
+
* Menu item component for toggling paragraph in a Tiptap editor.
|
|
1233
|
+
*
|
|
1234
|
+
* For custom menu item implementations, use the `useParagraph` hook instead.
|
|
1235
|
+
*/
|
|
1236
|
+
var ParagraphMenuItem = forwardRef(({ editor: providedEditor, text, hideWhenUnavailable = false, onToggled, showShortcut = false, onClick, children, ...menuItemProps }, ref) => {
|
|
1237
|
+
const { editor } = useTiptapEditor(providedEditor);
|
|
1238
|
+
const { isVisible, canToggle, isActive, handleToggle, label } = useParagraph({
|
|
1239
|
+
editor,
|
|
1240
|
+
hideWhenUnavailable,
|
|
1241
|
+
onToggled
|
|
1242
|
+
});
|
|
1243
|
+
const handleClick = useCallback((event) => {
|
|
1244
|
+
onClick?.(event);
|
|
1245
|
+
if (event.defaultPrevented) return;
|
|
1246
|
+
handleToggle();
|
|
1247
|
+
}, [handleToggle, onClick]);
|
|
1248
|
+
if (!isVisible) return null;
|
|
1249
|
+
return /* @__PURE__ */ jsx(MenuItem, {
|
|
1250
|
+
component: "li",
|
|
1251
|
+
role: "button",
|
|
1252
|
+
tabIndex: -1,
|
|
1253
|
+
disabled: !canToggle,
|
|
1254
|
+
"data-disabled": !canToggle,
|
|
1255
|
+
"aria-label": label,
|
|
1256
|
+
"aria-pressed": isActive,
|
|
1257
|
+
tooltip: label,
|
|
1258
|
+
selected: isActive,
|
|
1259
|
+
onClick: handleClick,
|
|
1260
|
+
...menuItemProps,
|
|
1261
|
+
ref,
|
|
1262
|
+
children: children ?? /* @__PURE__ */ jsxs(Fragment$1, { children: [label && /* @__PURE__ */ jsx(Typography, {
|
|
1263
|
+
component: "span",
|
|
1264
|
+
variant: "body2",
|
|
1265
|
+
children: label
|
|
1266
|
+
}), showShortcut && /* @__PURE__ */ jsx(Badge, { children: parseShortcutKeys({ shortcutKeys: "ctrl+alt+p" }) })] })
|
|
1267
|
+
});
|
|
1268
|
+
});
|
|
1269
|
+
ParagraphMenuItem.displayName = "ParagraphMenuItem";
|
|
1270
|
+
//#endregion
|
|
1108
1271
|
//#region src/tiptap/components/icons/heading-icon.tsx
|
|
1109
1272
|
var HeadingIcon = createSvgIcon(/* @__PURE__ */ jsx("path", {
|
|
1110
1273
|
d: "M6 3C6.55228 3 7 3.44772 7 4V11H17V4C17 3.44772 17.4477 3 18 3C18.5523 3 19 3.44772 19 4V20C19 20.5523 18.5523 21 18 21C17.4477 21 17 20.5523 17 20V13H7V20C7 20.5523 6.55228 21 6 21C5.44772 21 5 20.5523 5 20V4C5 3.44772 5.44772 3 6 3Z",
|
|
@@ -1178,11 +1341,11 @@ function useHeadingMenu(config) {
|
|
|
1178
1341
|
const [isVisible, setIsVisible] = useState(true);
|
|
1179
1342
|
const activeLevel = getActiveHeadingLevel(editor, levels);
|
|
1180
1343
|
const isActive = isHeadingActive(editor);
|
|
1181
|
-
const canToggleState = canToggle(editor);
|
|
1344
|
+
const canToggleState = canToggle$1(editor);
|
|
1182
1345
|
useEffect(() => {
|
|
1183
1346
|
if (!editor) return;
|
|
1184
1347
|
const handleSelectionUpdate = () => {
|
|
1185
|
-
setIsVisible(shouldShowItem({
|
|
1348
|
+
setIsVisible(shouldShowItem$1({
|
|
1186
1349
|
editor,
|
|
1187
1350
|
hideWhenUnavailable,
|
|
1188
1351
|
level: levels
|
|
@@ -1262,7 +1425,7 @@ var HeadingMenu = forwardRef(({ editor: providedEditor, levels = [
|
|
|
1262
1425
|
...buttonProps,
|
|
1263
1426
|
ref,
|
|
1264
1427
|
children: children ? children : /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(Icon, { fontSize: "small" }), /* @__PURE__ */ jsx(ExpandMoreRounded_default, { sx: { fontSize: "0.75rem" } })] })
|
|
1265
|
-
}), /* @__PURE__ */
|
|
1428
|
+
}), /* @__PURE__ */ jsxs(Menu, {
|
|
1266
1429
|
id: "heading-menu",
|
|
1267
1430
|
anchorEl,
|
|
1268
1431
|
open,
|
|
@@ -1271,12 +1434,15 @@ var HeadingMenu = forwardRef(({ editor: providedEditor, levels = [
|
|
|
1271
1434
|
"aria-labelledby": "heading-button",
|
|
1272
1435
|
role: "listbox"
|
|
1273
1436
|
} },
|
|
1274
|
-
children:
|
|
1437
|
+
children: [/* @__PURE__ */ jsx(ParagraphMenuItem, {
|
|
1438
|
+
editor,
|
|
1439
|
+
onClick: handleClose
|
|
1440
|
+
}), levels.map((level) => /* @__PURE__ */ jsx(HeadingMenuItem, {
|
|
1275
1441
|
editor,
|
|
1276
1442
|
level,
|
|
1277
1443
|
text: `Heading ${level}`,
|
|
1278
1444
|
onClick: handleClose
|
|
1279
|
-
}, `heading-${level}`))
|
|
1445
|
+
}, `heading-${level}`))]
|
|
1280
1446
|
})] });
|
|
1281
1447
|
});
|
|
1282
1448
|
HeadingMenu.displayName = "HeadingMenu";
|
|
@@ -2761,6 +2927,139 @@ var UndoRedoButton = forwardRef(({ editor: providedEditor, action, text, hideWhe
|
|
|
2761
2927
|
});
|
|
2762
2928
|
UndoRedoButton.displayName = "UndoRedoButton";
|
|
2763
2929
|
//#endregion
|
|
2930
|
+
//#region src/tiptap/components/ui-primitive/formatting-controls/const.tsx
|
|
2931
|
+
var BUTTON_DEFS = [
|
|
2932
|
+
{
|
|
2933
|
+
id: "undo",
|
|
2934
|
+
extensionName: "undoRedo",
|
|
2935
|
+
group: "history",
|
|
2936
|
+
Component: () => /* @__PURE__ */ jsx(UndoRedoButton, { action: "undo" })
|
|
2937
|
+
},
|
|
2938
|
+
{
|
|
2939
|
+
id: "redo",
|
|
2940
|
+
extensionName: "undoRedo",
|
|
2941
|
+
group: "history",
|
|
2942
|
+
Component: () => /* @__PURE__ */ jsx(UndoRedoButton, { action: "redo" })
|
|
2943
|
+
},
|
|
2944
|
+
{
|
|
2945
|
+
id: "heading",
|
|
2946
|
+
extensionName: "heading",
|
|
2947
|
+
group: "blocks",
|
|
2948
|
+
Component: () => /* @__PURE__ */ jsx(HeadingMenu, {
|
|
2949
|
+
modal: false,
|
|
2950
|
+
levels: [
|
|
2951
|
+
1,
|
|
2952
|
+
2,
|
|
2953
|
+
3,
|
|
2954
|
+
4
|
|
2955
|
+
]
|
|
2956
|
+
})
|
|
2957
|
+
},
|
|
2958
|
+
{
|
|
2959
|
+
id: "bulletList",
|
|
2960
|
+
extensionName: "bulletList",
|
|
2961
|
+
group: "blocks",
|
|
2962
|
+
Component: () => /* @__PURE__ */ jsx(ListButton, { type: "bulletList" })
|
|
2963
|
+
},
|
|
2964
|
+
{
|
|
2965
|
+
id: "orderedList",
|
|
2966
|
+
extensionName: "orderedList",
|
|
2967
|
+
group: "blocks",
|
|
2968
|
+
Component: () => /* @__PURE__ */ jsx(ListButton, { type: "orderedList" })
|
|
2969
|
+
},
|
|
2970
|
+
{
|
|
2971
|
+
id: "blockquote",
|
|
2972
|
+
extensionName: "blockquote",
|
|
2973
|
+
group: "blocks",
|
|
2974
|
+
Component: BlockquoteButton
|
|
2975
|
+
},
|
|
2976
|
+
{
|
|
2977
|
+
id: "codeBlock",
|
|
2978
|
+
extensionName: "codeBlock",
|
|
2979
|
+
group: "blocks",
|
|
2980
|
+
Component: CodeBlockButton
|
|
2981
|
+
},
|
|
2982
|
+
{
|
|
2983
|
+
id: "textColor",
|
|
2984
|
+
extensionName: "textStyle",
|
|
2985
|
+
group: "marks",
|
|
2986
|
+
Component: TextColorPopover
|
|
2987
|
+
},
|
|
2988
|
+
{
|
|
2989
|
+
id: "bold",
|
|
2990
|
+
extensionName: "bold",
|
|
2991
|
+
group: "marks",
|
|
2992
|
+
Component: () => /* @__PURE__ */ jsx(MarkButton, { type: "bold" })
|
|
2993
|
+
},
|
|
2994
|
+
{
|
|
2995
|
+
id: "italic",
|
|
2996
|
+
extensionName: "italic",
|
|
2997
|
+
group: "marks",
|
|
2998
|
+
Component: () => /* @__PURE__ */ jsx(MarkButton, { type: "italic" })
|
|
2999
|
+
},
|
|
3000
|
+
{
|
|
3001
|
+
id: "strike",
|
|
3002
|
+
extensionName: "strike",
|
|
3003
|
+
group: "marks",
|
|
3004
|
+
Component: () => /* @__PURE__ */ jsx(MarkButton, { type: "strike" })
|
|
3005
|
+
},
|
|
3006
|
+
{
|
|
3007
|
+
id: "code",
|
|
3008
|
+
extensionName: "code",
|
|
3009
|
+
group: "marks",
|
|
3010
|
+
Component: () => /* @__PURE__ */ jsx(MarkButton, { type: "code" })
|
|
3011
|
+
},
|
|
3012
|
+
{
|
|
3013
|
+
id: "underline",
|
|
3014
|
+
extensionName: "underline",
|
|
3015
|
+
group: "marks",
|
|
3016
|
+
Component: () => /* @__PURE__ */ jsx(MarkButton, { type: "underline" })
|
|
3017
|
+
},
|
|
3018
|
+
{
|
|
3019
|
+
id: "link",
|
|
3020
|
+
extensionName: "link",
|
|
3021
|
+
group: "marks",
|
|
3022
|
+
Component: LinkPopover
|
|
3023
|
+
},
|
|
3024
|
+
{
|
|
3025
|
+
id: "superscript",
|
|
3026
|
+
extensionName: "superscript",
|
|
3027
|
+
group: "scripts",
|
|
3028
|
+
Component: () => /* @__PURE__ */ jsx(MarkButton, { type: "superscript" })
|
|
3029
|
+
},
|
|
3030
|
+
{
|
|
3031
|
+
id: "subscript",
|
|
3032
|
+
extensionName: "subscript",
|
|
3033
|
+
group: "scripts",
|
|
3034
|
+
Component: () => /* @__PURE__ */ jsx(MarkButton, { type: "subscript" })
|
|
3035
|
+
},
|
|
3036
|
+
{
|
|
3037
|
+
id: "alignLeft",
|
|
3038
|
+
extensionName: "textAlign",
|
|
3039
|
+
group: "textAlign",
|
|
3040
|
+
Component: () => /* @__PURE__ */ jsx(TextAlignButton, { align: "left" })
|
|
3041
|
+
},
|
|
3042
|
+
{
|
|
3043
|
+
id: "alignCenter",
|
|
3044
|
+
extensionName: "textAlign",
|
|
3045
|
+
group: "textAlign",
|
|
3046
|
+
Component: () => /* @__PURE__ */ jsx(TextAlignButton, { align: "center" })
|
|
3047
|
+
},
|
|
3048
|
+
{
|
|
3049
|
+
id: "alignRight",
|
|
3050
|
+
extensionName: "textAlign",
|
|
3051
|
+
group: "textAlign",
|
|
3052
|
+
Component: () => /* @__PURE__ */ jsx(TextAlignButton, { align: "right" })
|
|
3053
|
+
},
|
|
3054
|
+
{
|
|
3055
|
+
id: "alignJustify",
|
|
3056
|
+
extensionName: "textAlign",
|
|
3057
|
+
group: "textAlign",
|
|
3058
|
+
Component: () => /* @__PURE__ */ jsx(TextAlignButton, { align: "justify" })
|
|
3059
|
+
}
|
|
3060
|
+
];
|
|
3061
|
+
var BUTTON_IDS = BUTTON_DEFS.map((def) => def.id);
|
|
3062
|
+
//#endregion
|
|
2764
3063
|
//#region src/tiptap/hooks/use-composed-ref.ts
|
|
2765
3064
|
var updateRef = (ref, value) => {
|
|
2766
3065
|
if (typeof ref === "function") ref(value);
|
|
@@ -3006,48 +3305,28 @@ var ToolbarSeparator = () => /* @__PURE__ */ jsx(Divider, {
|
|
|
3006
3305
|
});
|
|
3007
3306
|
ToolbarSeparator.displayName = "ToolbarSeparator";
|
|
3008
3307
|
//#endregion
|
|
3308
|
+
//#region src/tiptap/components/ui-primitive/formatting-controls/hooks.ts
|
|
3309
|
+
var useFormattingItems = (editor) => {
|
|
3310
|
+
return useMemo(() => {
|
|
3311
|
+
if (!editor) return [];
|
|
3312
|
+
return BUTTON_DEFS.filter((def) => def.extensionName ? editor.extensionManager.extensions.some((e) => e.name === def.extensionName) : true);
|
|
3313
|
+
}, [editor]);
|
|
3314
|
+
};
|
|
3315
|
+
//#endregion
|
|
3316
|
+
//#region src/tiptap/components/ui-primitive/formatting-controls/utils.ts
|
|
3317
|
+
function groupBy(items, getKey) {
|
|
3318
|
+
return items.reduce((acc, item) => {
|
|
3319
|
+
const key = getKey(item);
|
|
3320
|
+
(acc[key] ??= []).push(item);
|
|
3321
|
+
return acc;
|
|
3322
|
+
}, {});
|
|
3323
|
+
}
|
|
3324
|
+
//#endregion
|
|
3009
3325
|
//#region src/tiptap/components/ui-primitive/formatting-controls/formatting-controls.tsx
|
|
3010
|
-
var FormattingControls = ({ editor }) => {
|
|
3011
|
-
const
|
|
3012
|
-
const
|
|
3013
|
-
|
|
3014
|
-
return /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
3015
|
-
/* @__PURE__ */ jsxs(ToolbarGroup, { children: [/* @__PURE__ */ jsx(UndoRedoButton, { action: "undo" }), /* @__PURE__ */ jsx(UndoRedoButton, { action: "redo" })] }),
|
|
3016
|
-
/* @__PURE__ */ jsx(ToolbarSeparator, {}),
|
|
3017
|
-
/* @__PURE__ */ jsxs(ToolbarGroup, { children: [
|
|
3018
|
-
/* @__PURE__ */ jsx(HeadingMenu, {
|
|
3019
|
-
modal: false,
|
|
3020
|
-
levels: [
|
|
3021
|
-
1,
|
|
3022
|
-
2,
|
|
3023
|
-
3,
|
|
3024
|
-
4
|
|
3025
|
-
]
|
|
3026
|
-
}),
|
|
3027
|
-
/* @__PURE__ */ jsx(ListButton, { type: "bulletList" }),
|
|
3028
|
-
/* @__PURE__ */ jsx(ListButton, { type: "orderedList" }),
|
|
3029
|
-
/* @__PURE__ */ jsx(BlockquoteButton, {}),
|
|
3030
|
-
/* @__PURE__ */ jsx(CodeBlockButton, {})
|
|
3031
|
-
] }),
|
|
3032
|
-
/* @__PURE__ */ jsx(ToolbarSeparator, {}),
|
|
3033
|
-
/* @__PURE__ */ jsxs(ToolbarGroup, { children: [
|
|
3034
|
-
hasTextStyle ? /* @__PURE__ */ jsx(TextColorPopover, {}) : null,
|
|
3035
|
-
/* @__PURE__ */ jsx(MarkButton, { type: "bold" }),
|
|
3036
|
-
/* @__PURE__ */ jsx(MarkButton, { type: "italic" }),
|
|
3037
|
-
/* @__PURE__ */ jsx(MarkButton, { type: "strike" }),
|
|
3038
|
-
/* @__PURE__ */ jsx(MarkButton, { type: "code" }),
|
|
3039
|
-
/* @__PURE__ */ jsx(MarkButton, { type: "underline" }),
|
|
3040
|
-
/* @__PURE__ */ jsx(LinkPopover, {})
|
|
3041
|
-
] }),
|
|
3042
|
-
hasSuperscriptSubscript ? /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(ToolbarSeparator, {}), /* @__PURE__ */ jsxs(ToolbarGroup, { children: [/* @__PURE__ */ jsx(MarkButton, { type: "superscript" }), /* @__PURE__ */ jsx(MarkButton, { type: "subscript" })] })] }) : null,
|
|
3043
|
-
/* @__PURE__ */ jsx(ToolbarSeparator, {}),
|
|
3044
|
-
/* @__PURE__ */ jsxs(ToolbarGroup, { children: [
|
|
3045
|
-
/* @__PURE__ */ jsx(TextAlignButton, { align: "left" }),
|
|
3046
|
-
/* @__PURE__ */ jsx(TextAlignButton, { align: "center" }),
|
|
3047
|
-
/* @__PURE__ */ jsx(TextAlignButton, { align: "right" }),
|
|
3048
|
-
/* @__PURE__ */ jsx(TextAlignButton, { align: "justify" })
|
|
3049
|
-
] })
|
|
3050
|
-
] });
|
|
3326
|
+
var FormattingControls = ({ editor, include }) => {
|
|
3327
|
+
const items = useFormattingItems(editor);
|
|
3328
|
+
const groups = groupBy(include ? items.filter((button) => include.includes(button.id)) : items, (button) => button.group);
|
|
3329
|
+
return /* @__PURE__ */ jsx(Fragment$1, { children: Object.entries(groups).map(([groupId, groupItems], index) => /* @__PURE__ */ jsxs(Fragment, { children: [index > 0 ? /* @__PURE__ */ jsx(ToolbarSeparator, {}) : null, /* @__PURE__ */ jsx(ToolbarGroup, { children: groupItems.map((item) => /* @__PURE__ */ jsx(item.Component, {}, item.id)) })] }, groupId)) });
|
|
3051
3330
|
};
|
|
3052
3331
|
FormattingControls.displayName = "FormattingControls";
|
|
3053
3332
|
//#endregion
|
|
@@ -3067,6 +3346,6 @@ function Spacer({ orientation = "horizontal", size, style = {}, ...props }) {
|
|
|
3067
3346
|
});
|
|
3068
3347
|
}
|
|
3069
3348
|
//#endregion
|
|
3070
|
-
export { FormattingControls, Spacer, Toolbar, ToolbarGroup, ToolbarSeparator };
|
|
3349
|
+
export { BUTTON_IDS, FormattingControls, Spacer, Toolbar, ToolbarGroup, ToolbarSeparator };
|
|
3071
3350
|
|
|
3072
3351
|
//# sourceMappingURL=index.es.js.map
|
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.1788870644",
|
|
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",
|