@soul-refiner/design-system 1.4.2 → 1.6.1-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/actions/button/button.d.ts +1 -1
- package/dist/components/actions/dropdown/dropdown.stories.d.ts +5 -0
- package/dist/components/actions/rate/rate.js +4 -3
- package/dist/components/atoms/hide/hide.js +1 -1
- package/dist/components/card/feature/feature.js +1 -1
- package/dist/components/custom/courses_selection/courses_selection.js +5 -7
- package/dist/components/custom/courses_selection/courses_selection.stories.d.ts +5 -0
- package/dist/components/custom/users_selection/users_selection.stories.d.ts +5 -0
- package/dist/components/editor/constants.d.ts +9 -11
- package/dist/components/editor/constants.js +11 -7
- package/dist/components/editor/context.d.ts +1 -0
- package/dist/components/editor/context.js +1 -0
- package/dist/components/editor/editor.d.ts +3 -4
- package/dist/components/editor/editor.js +27 -5
- package/dist/components/editor/editor.stories.d.ts +6 -0
- package/dist/components/editor/icons/border-all.d.ts +3 -0
- package/dist/components/editor/icons/border-all.js +3 -0
- package/dist/components/editor/icons/border-bottom.d.ts +3 -0
- package/dist/components/editor/icons/border-bottom.js +3 -0
- package/dist/components/editor/icons/border-left.d.ts +3 -0
- package/dist/components/editor/icons/border-left.js +3 -0
- package/dist/components/editor/icons/border-none.d.ts +3 -0
- package/dist/components/editor/icons/border-none.js +3 -0
- package/dist/components/editor/icons/border-right.d.ts +3 -0
- package/dist/components/editor/icons/border-right.js +3 -0
- package/dist/components/editor/icons/border-top.d.ts +3 -0
- package/dist/components/editor/icons/border-top.js +3 -0
- package/dist/components/editor/icons/index.d.ts +6 -0
- package/dist/components/editor/icons/index.js +6 -0
- package/dist/components/editor/navbar/index.d.ts +0 -1
- package/dist/components/editor/navbar/navbar.d.ts +1 -4
- package/dist/components/editor/navbar/navbar.js +10 -14
- package/dist/components/editor/plugins/{blockquote.js → blocks/blockquote.js} +1 -1
- package/dist/components/editor/plugins/blocks/blocks.d.ts +1 -0
- package/dist/components/editor/plugins/blocks/blocks.js +50 -0
- package/dist/components/editor/plugins/{buttons.js → blocks/buttons.js} +2 -2
- package/dist/components/editor/plugins/blocks/dropdown-menu.d.ts +29 -0
- package/dist/components/editor/plugins/blocks/dropdown-menu.js +62 -0
- package/dist/components/editor/plugins/blocks/image.d.ts +9 -0
- package/dist/components/editor/plugins/blocks/image.js +36 -0
- package/dist/components/editor/plugins/blocks/index.d.ts +1 -0
- package/dist/components/editor/plugins/blocks/index.js +1 -0
- package/dist/components/editor/plugins/blocks/media-popover.d.ts +6 -0
- package/dist/components/editor/plugins/blocks/media-popover.js +32 -0
- package/dist/components/editor/plugins/blocks/plate-button.d.ts +14 -0
- package/dist/components/editor/plugins/blocks/plate-button.js +37 -0
- package/dist/components/editor/plugins/blocks/popover.d.ts +7 -0
- package/dist/components/editor/plugins/blocks/popover.js +11 -0
- package/dist/components/editor/plugins/{qa.js → blocks/qa.js} +8 -8
- package/dist/components/editor/plugins/blocks/resizable.d.ts +39 -0
- package/dist/components/editor/plugins/blocks/resizable.js +37 -0
- package/dist/components/editor/plugins/blocks/separator.d.ts +5 -0
- package/dist/components/editor/plugins/blocks/separator.js +19 -0
- package/dist/components/editor/plugins/blocks/table-cell.d.ts +23 -0
- package/dist/components/editor/plugins/blocks/table-cell.js +38 -0
- package/dist/components/editor/plugins/blocks/table-row.d.ts +11 -0
- package/dist/components/editor/plugins/blocks/table-row.js +7 -0
- package/dist/components/editor/plugins/blocks/table.d.ts +12 -0
- package/dist/components/editor/plugins/blocks/table.js +82 -0
- package/dist/components/editor/plugins/{text.js → blocks/text.js} +3 -3
- package/dist/components/editor/plugins/{video.js → blocks/video.js} +2 -2
- package/dist/components/editor/plugins/index.d.ts +4 -7
- package/dist/components/editor/plugins/index.js +4 -112
- package/dist/components/editor/plugins/leafs/index.d.ts +1 -0
- package/dist/components/editor/plugins/leafs/index.js +1 -0
- package/dist/components/editor/plugins/leafs/leafs.d.ts +1 -0
- package/dist/components/editor/plugins/leafs/leafs.js +33 -0
- package/dist/components/editor/plugins/{link.js → leafs/link.js} +2 -2
- package/dist/components/editor/plugins/marks/index.d.ts +1 -0
- package/dist/components/editor/plugins/marks/index.js +1 -0
- package/dist/components/editor/plugins/marks/marks.d.ts +1 -0
- package/dist/components/editor/plugins/marks/marks.js +12 -0
- package/dist/components/editor/plugins/plate.d.ts +99 -0
- package/dist/components/editor/plugins/plate.js +37 -0
- package/dist/components/editor/plugins/{exitBreak.js → utils/exitBreak.js} +1 -1
- package/dist/components/editor/plugins/utils/index.d.ts +1 -0
- package/dist/components/editor/plugins/utils/index.js +1 -0
- package/dist/components/editor/plugins/{resetBlockType.js → utils/resetBlockType.js} +1 -1
- package/dist/components/editor/plugins/{selectOnBackspace.js → utils/selectOnBackspace.js} +1 -1
- package/dist/components/editor/plugins/utils/utils.d.ts +1 -0
- package/dist/components/editor/plugins/utils/utils.js +12 -0
- package/dist/components/editor/simple_editor/plugins.js +7 -7
- package/dist/components/iconography/avatar/avatar.d.ts +2 -1
- package/dist/components/iconography/avatar/avatar.js +3 -2
- package/dist/components/iconography/avatar/avatar.stories.d.ts +7 -0
- package/dist/components/iconography/avatar/icons/default.js +2 -3
- package/dist/components/input/text_input/text_input.d.ts +1 -0
- package/dist/components/media/video-player/playlist-item.d.ts +2 -2
- package/dist/components/media/video-player/playlist-item.js +6 -6
- package/dist/components/media/video-player/video.d.ts +13 -3
- package/dist/components/media/video-player/video.js +28 -9
- package/dist/components/media/video-player/video.stories.d.ts +6 -0
- package/dist/components/surfaces/carousel/card/card.js +1 -1
- package/dist/main.js +2 -0
- package/dist/main.js.LICENSE.txt +129 -0
- package/dist/styles/output.css +1771 -0
- package/package.json +20 -5
- package/dist/components/editor/plate.d.ts +0 -34
- package/dist/components/editor/plate.js +0 -27
- package/dist/components/editor/plugins/image.d.ts +0 -3
- package/dist/components/editor/plugins/image.js +0 -33
- /package/dist/components/editor/plugins/{blockquote.d.ts → blocks/blockquote.d.ts} +0 -0
- /package/dist/components/editor/plugins/{buttons.d.ts → blocks/buttons.d.ts} +0 -0
- /package/dist/components/editor/plugins/{list.d.ts → blocks/list.d.ts} +0 -0
- /package/dist/components/editor/plugins/{list.js → blocks/list.js} +0 -0
- /package/dist/components/editor/plugins/{qa.d.ts → blocks/qa.d.ts} +0 -0
- /package/dist/components/editor/plugins/{text.d.ts → blocks/text.d.ts} +0 -0
- /package/dist/components/editor/plugins/{video.d.ts → blocks/video.d.ts} +0 -0
- /package/dist/components/editor/plugins/{link.d.ts → leafs/link.d.ts} +0 -0
- /package/dist/components/editor/plugins/{exitBreak.d.ts → utils/exitBreak.d.ts} +0 -0
- /package/dist/components/editor/plugins/{resetBlockType.d.ts → utils/resetBlockType.d.ts} +0 -0
- /package/dist/components/editor/plugins/{selectOnBackspace.d.ts → utils/selectOnBackspace.d.ts} +0 -0
- /package/dist/components/editor/plugins/{softBreak.d.ts → utils/softBreak.d.ts} +0 -0
- /package/dist/components/editor/plugins/{softBreak.js → utils/softBreak.js} +0 -0
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { useCallback, useState } from 'react';
|
|
4
|
+
import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';
|
|
5
|
+
import { cn, createPrimitiveElement, withCn, withProps, withRef, withVariants, } from '@udecode/cn';
|
|
6
|
+
import { cva } from 'class-variance-authority';
|
|
7
|
+
import { ChevronRight } from '../../../../icons/arrow/chevron_right';
|
|
8
|
+
import { Checkmark } from '../../../../icons/basic/checkmark';
|
|
9
|
+
export const DropdownMenu = DropdownMenuPrimitive.Root;
|
|
10
|
+
export const DropdownMenuTrigger = DropdownMenuPrimitive.Trigger;
|
|
11
|
+
export const DropdownMenuGroup = DropdownMenuPrimitive.Group;
|
|
12
|
+
export const DropdownMenuPortal = DropdownMenuPrimitive.Portal;
|
|
13
|
+
export const DropdownMenuSub = DropdownMenuPrimitive.Sub;
|
|
14
|
+
export const DropdownMenuRadioGroup = DropdownMenuPrimitive.RadioGroup;
|
|
15
|
+
export const DropdownMenuSubTrigger = withRef(({ className, inset, children, ...props }, ref) => (React.createElement(DropdownMenuPrimitive.SubTrigger, { ref: ref, className: cn('flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent', 'data-[disabled]:pointer-events-none data-[disabled]:opacity-50', inset && 'pl-8', className), ...props },
|
|
16
|
+
children,
|
|
17
|
+
React.createElement(ChevronRight, { className: "ml-auto h-4 w-4" }))));
|
|
18
|
+
export const DropdownMenuSubContent = withCn(DropdownMenuPrimitive.SubContent, 'z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2');
|
|
19
|
+
const DropdownMenuContentVariants = withProps(DropdownMenuPrimitive.Content, {
|
|
20
|
+
sideOffset: 4,
|
|
21
|
+
className: cn('z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2'),
|
|
22
|
+
});
|
|
23
|
+
export const DropdownMenuContent = withRef(({ ...props }, ref) => (React.createElement(DropdownMenuPrimitive.Portal, null,
|
|
24
|
+
React.createElement(DropdownMenuContentVariants, { ref: ref, ...props }))));
|
|
25
|
+
const menuItemVariants = cva(cn('relative flex h-9 cursor-pointer select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors', 'focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50'), {
|
|
26
|
+
variants: {
|
|
27
|
+
inset: {
|
|
28
|
+
true: 'pl-8',
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
export const DropdownMenuItem = withVariants(DropdownMenuPrimitive.Item, menuItemVariants, ['inset']);
|
|
33
|
+
export const DropdownMenuCheckboxItem = withRef(({ className, children, ...props }, ref) => (React.createElement(DropdownMenuPrimitive.CheckboxItem, { ref: ref, className: cn('relative flex select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50', 'cursor-pointer', className), ...props },
|
|
34
|
+
React.createElement("span", { className: "absolute left-2 flex h-3.5 w-3.5 items-center justify-center" },
|
|
35
|
+
React.createElement(DropdownMenuPrimitive.ItemIndicator, null,
|
|
36
|
+
React.createElement(Checkmark, { className: "h-4 w-4" }))),
|
|
37
|
+
children)));
|
|
38
|
+
export const DropdownMenuRadioItem = withRef(({ className, children, hideIcon, ...props }, ref) => (React.createElement(DropdownMenuPrimitive.RadioItem, { ref: ref, className: cn('relative flex select-none items-center rounded-sm pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50', 'h-9 cursor-pointer px-2 data-[state=checked]:bg-accent data-[state=checked]:text-accent-foreground', className), ...props },
|
|
39
|
+
!hideIcon && (React.createElement("span", { className: "absolute right-2 flex h-3.5 w-3.5 items-center justify-center" },
|
|
40
|
+
React.createElement(DropdownMenuPrimitive.ItemIndicator, null,
|
|
41
|
+
React.createElement(Checkmark, { className: "h-4 w-4" })))),
|
|
42
|
+
children)));
|
|
43
|
+
const dropdownMenuLabelVariants = cva(cn('select-none px-2 py-1.5 text-sm font-semibold'), {
|
|
44
|
+
variants: {
|
|
45
|
+
inset: {
|
|
46
|
+
true: 'pl-8',
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
export const DropdownMenuLabel = withVariants(DropdownMenuPrimitive.Label, dropdownMenuLabelVariants, ['inset']);
|
|
51
|
+
export const DropdownMenuSeparator = withCn(DropdownMenuPrimitive.Separator, '-mx-1 my-1 h-px bg-muted');
|
|
52
|
+
export const DropdownMenuShortcut = withCn(createPrimitiveElement('span'), 'ml-auto text-xs tracking-widest opacity-60');
|
|
53
|
+
export const useOpenState = () => {
|
|
54
|
+
const [open, setOpen] = useState(false);
|
|
55
|
+
const onOpenChange = useCallback((_value = !open) => {
|
|
56
|
+
setOpen(_value);
|
|
57
|
+
}, [open]);
|
|
58
|
+
return {
|
|
59
|
+
open,
|
|
60
|
+
onOpenChange,
|
|
61
|
+
};
|
|
62
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export declare const ImageElement: React.ForwardRefExoticComponent<Omit<Omit<import("@udecode/plate-core").PlateRenderNodeProps<import("@udecode/slate").Value, import("@udecode/plate-core").PlateEditor<import("@udecode/slate").Value>> & Omit<import("slate-react").RenderElementProps, "element"> & {
|
|
3
|
+
element: import("@udecode/slate").TElement;
|
|
4
|
+
} & Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
5
|
+
as?: React.ElementType<any> | undefined;
|
|
6
|
+
asChild?: boolean | undefined;
|
|
7
|
+
} & React.RefAttributes<any> & {
|
|
8
|
+
elementToAttributes?: ((element: import("@udecode/slate").TElement) => any) | undefined;
|
|
9
|
+
} & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<any>, "ref"> & React.RefAttributes<unknown>>;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { cn, withRef } from '@udecode/cn';
|
|
3
|
+
import { PlateElement, withHOC } from '@udecode/plate-common';
|
|
4
|
+
import { ELEMENT_IMAGE, Image, useMediaState } from '@udecode/plate-media';
|
|
5
|
+
import { ResizableProvider } from '@udecode/plate-resizable';
|
|
6
|
+
import { MediaPopover } from './media-popover';
|
|
7
|
+
import { mediaResizeHandleVariants, Resizable, ResizeHandle, } from './resizable';
|
|
8
|
+
import { EditorContext } from '../../context';
|
|
9
|
+
export const ImageElement = withHOC(ResizableProvider, withRef(({ className, children, element, nodeProps, ...props }, ref) => {
|
|
10
|
+
const { imageSrcLoader } = React.useContext(EditorContext);
|
|
11
|
+
const { readOnly, focused, selected, align = 'center' } = useMediaState();
|
|
12
|
+
const { id, url, ...restElement } = element;
|
|
13
|
+
const [src, setSrc] = React.useState(null);
|
|
14
|
+
React.useEffect(() => {
|
|
15
|
+
(async () => {
|
|
16
|
+
if (!id || !imageSrcLoader)
|
|
17
|
+
return;
|
|
18
|
+
const source = await imageSrcLoader(id);
|
|
19
|
+
if (source)
|
|
20
|
+
setSrc(source);
|
|
21
|
+
})();
|
|
22
|
+
}, [id, imageSrcLoader]);
|
|
23
|
+
return (React.createElement(MediaPopover, { pluginKey: ELEMENT_IMAGE },
|
|
24
|
+
React.createElement(PlateElement, { ref: ref, className: cn('py-2.5', className), element: restElement, ...props },
|
|
25
|
+
!src ? null : (React.createElement("figure", { className: "group relative m-0", contentEditable: false },
|
|
26
|
+
React.createElement(Resizable, { align: align, options: {
|
|
27
|
+
align,
|
|
28
|
+
readOnly,
|
|
29
|
+
} },
|
|
30
|
+
React.createElement(ResizeHandle, { options: { direction: 'left' }, className: mediaResizeHandleVariants({ direction: 'left' }) }),
|
|
31
|
+
React.createElement(Image, { className: cn('block w-full max-w-full cursor-pointer object-cover px-0', 'rounded-sm', focused && selected && 'ring-2 ring-ring ring-offset-2'), alt: "", ...nodeProps, src: src }),
|
|
32
|
+
React.createElement(ResizeHandle, { options: { direction: 'right' }, className: mediaResizeHandleVariants({
|
|
33
|
+
direction: 'right',
|
|
34
|
+
}) })))),
|
|
35
|
+
children)));
|
|
36
|
+
}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { blocks } from './blocks';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { blocks } from './blocks';
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import React, { useEffect } from 'react';
|
|
2
|
+
import { isSelectionExpanded, useEditorSelector, useElement, useRemoveNodeButton, } from '@udecode/plate-common';
|
|
3
|
+
import { floatingMediaActions, useFloatingMediaSelectors, } from '@udecode/plate-media';
|
|
4
|
+
import { useReadOnly, useSelected } from 'slate-react';
|
|
5
|
+
import { Button } from './plate-button';
|
|
6
|
+
import { Popover, PopoverAnchor, PopoverContent } from './popover';
|
|
7
|
+
import { Link, Trash } from 'lucide-react';
|
|
8
|
+
export function MediaPopover({ children }) {
|
|
9
|
+
const readOnly = useReadOnly();
|
|
10
|
+
const selected = useSelected();
|
|
11
|
+
const selectionCollapsed = useEditorSelector((editor) => !isSelectionExpanded(editor), []);
|
|
12
|
+
const isOpen = !readOnly && selected && selectionCollapsed;
|
|
13
|
+
const isEditing = useFloatingMediaSelectors().isEditing();
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
if (!isOpen && isEditing) {
|
|
16
|
+
floatingMediaActions.isEditing(false);
|
|
17
|
+
}
|
|
18
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
19
|
+
}, [isOpen]);
|
|
20
|
+
const element = useElement();
|
|
21
|
+
const { props: buttonProps } = useRemoveNodeButton({ element });
|
|
22
|
+
if (readOnly)
|
|
23
|
+
return React.createElement(React.Fragment, null, children);
|
|
24
|
+
return (React.createElement(Popover, { open: isOpen, modal: false },
|
|
25
|
+
React.createElement(PopoverAnchor, null, children),
|
|
26
|
+
React.createElement(PopoverContent, { className: "w-auto p-1", onOpenAutoFocus: (e) => e.preventDefault() }, isEditing ? (React.createElement("div", { className: "flex w-[330px] flex-col" },
|
|
27
|
+
React.createElement("div", { className: "flex items-center" },
|
|
28
|
+
React.createElement("div", { className: "flex items-center pl-3 text-muted-foreground" },
|
|
29
|
+
React.createElement(Link, { className: "h-4 w-4" }))))) : (React.createElement("div", { className: "box-content flex h-9 items-center gap-1" },
|
|
30
|
+
React.createElement(Button, { variant: "ghost", size: "sms", ...buttonProps },
|
|
31
|
+
React.createElement(Trash, { className: "h-4 w-4" })))))));
|
|
32
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { VariantProps } from 'class-variance-authority';
|
|
3
|
+
export declare const buttonVariants: (props?: ({
|
|
4
|
+
variant?: "link" | "default" | "secondary" | "destructive" | "outline" | "ghost" | "inlineLink" | null | undefined;
|
|
5
|
+
size?: "none" | "icon" | "default" | "sm" | "xs" | "sms" | "lg" | null | undefined;
|
|
6
|
+
isMenu?: boolean | null | undefined;
|
|
7
|
+
} & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
|
|
8
|
+
export declare const Button: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & VariantProps<(props?: ({
|
|
9
|
+
variant?: "link" | "default" | "secondary" | "destructive" | "outline" | "ghost" | "inlineLink" | null | undefined;
|
|
10
|
+
size?: "none" | "icon" | "default" | "sm" | "xs" | "sms" | "lg" | null | undefined;
|
|
11
|
+
isMenu?: boolean | null | undefined;
|
|
12
|
+
} & import("class-variance-authority/dist/types").ClassProp) | undefined) => string> & {
|
|
13
|
+
asChild?: boolean | undefined;
|
|
14
|
+
} & React.RefAttributes<HTMLButtonElement>>;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { Slot } from '@radix-ui/react-slot';
|
|
3
|
+
import { cn, withRef } from '@udecode/cn';
|
|
4
|
+
import { cva } from 'class-variance-authority';
|
|
5
|
+
export const buttonVariants = cva('inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50', {
|
|
6
|
+
variants: {
|
|
7
|
+
variant: {
|
|
8
|
+
default: 'bg-primary text-primary-foreground hover:bg-primary/90',
|
|
9
|
+
destructive: 'bg-destructive text-destructive-foreground hover:bg-destructive/90',
|
|
10
|
+
outline: 'border border-input bg-background hover:bg-accent hover:text-accent-foreground',
|
|
11
|
+
secondary: 'bg-secondary text-secondary-foreground hover:bg-secondary/80',
|
|
12
|
+
ghost: 'hover:bg-accent hover:text-accent-foreground',
|
|
13
|
+
link: 'text-primary underline-offset-4 hover:underline',
|
|
14
|
+
inlineLink: 'text-base text-primary underline underline-offset-4',
|
|
15
|
+
},
|
|
16
|
+
size: {
|
|
17
|
+
default: 'h-10 px-4 py-2',
|
|
18
|
+
xs: 'h-8 rounded-md px-3',
|
|
19
|
+
sm: 'h-9 rounded-md px-3',
|
|
20
|
+
sms: 'h-9 w-9 rounded-md px-0',
|
|
21
|
+
lg: 'h-11 rounded-md px-8',
|
|
22
|
+
icon: 'h-10 w-10',
|
|
23
|
+
none: '',
|
|
24
|
+
},
|
|
25
|
+
isMenu: {
|
|
26
|
+
true: 'h-auto w-full cursor-pointer justify-start',
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
defaultVariants: {
|
|
30
|
+
variant: 'default',
|
|
31
|
+
size: 'default',
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
export const Button = withRef(({ className, isMenu, variant, size, asChild = false, ...props }, ref) => {
|
|
35
|
+
const Comp = asChild ? Slot : 'button';
|
|
36
|
+
return (React.createElement(Comp, { className: cn(buttonVariants({ isMenu, variant, size, className })), ref: ref, ...props }));
|
|
37
|
+
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import * as PopoverPrimitive from '@radix-ui/react-popover';
|
|
3
|
+
export declare const Popover: React.FC<PopoverPrimitive.PopoverProps>;
|
|
4
|
+
export declare const PopoverTrigger: React.ForwardRefExoticComponent<PopoverPrimitive.PopoverTriggerProps & React.RefAttributes<HTMLButtonElement>>;
|
|
5
|
+
export declare const PopoverAnchor: React.ForwardRefExoticComponent<PopoverPrimitive.PopoverAnchorProps & React.RefAttributes<HTMLDivElement>>;
|
|
6
|
+
export declare const popoverVariants: (props?: import("class-variance-authority/dist/types").ClassProp | undefined) => string;
|
|
7
|
+
export declare const PopoverContent: React.ForwardRefExoticComponent<Omit<PopoverPrimitive.PopoverContentProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import * as PopoverPrimitive from '@radix-ui/react-popover';
|
|
4
|
+
import { cn, withRef } from '@udecode/cn';
|
|
5
|
+
import { cva } from 'class-variance-authority';
|
|
6
|
+
export const Popover = PopoverPrimitive.Root;
|
|
7
|
+
export const PopoverTrigger = PopoverPrimitive.Trigger;
|
|
8
|
+
export const PopoverAnchor = PopoverPrimitive.Anchor;
|
|
9
|
+
export const popoverVariants = cva('w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 print:hidden');
|
|
10
|
+
export const PopoverContent = withRef(({ className, style, align = 'center', sideOffset = 4, ...props }, ref) => (React.createElement(PopoverPrimitive.Portal, null,
|
|
11
|
+
React.createElement(PopoverPrimitive.Content, { ref: ref, align: align, sideOffset: sideOffset, className: cn(popoverVariants(), className), style: { zIndex: 1000, ...style }, ...props }))));
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { createPluginFactory, PlateElement, } from '@udecode/plate';
|
|
3
3
|
import styled from 'styled-components';
|
|
4
|
-
import { ELEMENT_QA } from '
|
|
5
|
-
import { EditorContext } from '
|
|
6
|
-
import { Button } from '
|
|
7
|
-
import { Box } from '
|
|
8
|
-
import { HideButRender } from '
|
|
9
|
-
import { H } from '
|
|
10
|
-
import { ChevronDown } from '
|
|
11
|
-
import { ChevronUp } from '
|
|
4
|
+
import { ELEMENT_QA } from '../../constants';
|
|
5
|
+
import { EditorContext } from '../../context';
|
|
6
|
+
import { Button } from '../../../actions';
|
|
7
|
+
import { Box } from '../../../atoms/box';
|
|
8
|
+
import { HideButRender } from '../../../atoms/hide';
|
|
9
|
+
import { H } from '../../../atoms/typography';
|
|
10
|
+
import { ChevronDown } from '../../../../icons/arrow/chevron_down';
|
|
11
|
+
import { ChevronUp } from '../../../../icons/arrow/chevron_up';
|
|
12
12
|
export const QuestionAnswerElement = React.forwardRef(({ children, element, ...props }, ref) => {
|
|
13
13
|
const { questionAnswerId } = element;
|
|
14
14
|
const { commentInputLoader: CommentInput, commentLoader: Comments } = React.useContext(EditorContext);
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export declare const mediaResizeHandleVariants: (props?: ({
|
|
3
|
+
direction?: "right" | "left" | null | undefined;
|
|
4
|
+
} & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
|
|
5
|
+
export declare const ResizeHandle: React.ForwardRefExoticComponent<Omit<{
|
|
6
|
+
as?: React.ElementType<any> | undefined;
|
|
7
|
+
asChild?: boolean | undefined;
|
|
8
|
+
className?: string | undefined;
|
|
9
|
+
style?: React.CSSProperties | undefined;
|
|
10
|
+
options?: import("@udecode/plate-resizable").ResizeHandleOptions | undefined;
|
|
11
|
+
state?: {
|
|
12
|
+
isResizing: boolean;
|
|
13
|
+
setIsResizing: React.Dispatch<React.SetStateAction<boolean>>;
|
|
14
|
+
initialPosition: number;
|
|
15
|
+
setInitialPosition: React.Dispatch<React.SetStateAction<number>>;
|
|
16
|
+
initialSize: number;
|
|
17
|
+
setInitialSize: React.Dispatch<React.SetStateAction<number>>;
|
|
18
|
+
isHorizontal: boolean;
|
|
19
|
+
direction: import("@udecode/plate-resizable").ResizeDirection;
|
|
20
|
+
onResize: (event: import("@udecode/plate-resizable").ResizeEvent) => void;
|
|
21
|
+
onMouseDown: React.MouseEventHandler<Element> | undefined;
|
|
22
|
+
onTouchStart: React.TouchEventHandler<Element> | undefined;
|
|
23
|
+
onHover: (() => void) | undefined;
|
|
24
|
+
onHoverEnd: (() => void) | undefined;
|
|
25
|
+
} | undefined;
|
|
26
|
+
setProps?: ((hookProps: {
|
|
27
|
+
onMouseDown: React.MouseEventHandler<Element>;
|
|
28
|
+
onTouchStart: React.TouchEventHandler<Element>;
|
|
29
|
+
onMouseOver: () => void;
|
|
30
|
+
onMouseOut: () => void;
|
|
31
|
+
onTouchMove: () => void;
|
|
32
|
+
onTouchEnd: () => void;
|
|
33
|
+
}) => Omit<React.HTMLAttributes<HTMLDivElement>, "onResize">) | undefined;
|
|
34
|
+
} & Omit<React.HTMLAttributes<HTMLDivElement>, "onResize"> & React.RefAttributes<any>, "ref"> & React.RefAttributes<any>>;
|
|
35
|
+
export declare const Resizable: React.ForwardRefExoticComponent<Omit<React.HTMLAttributes<HTMLDivElement> & {
|
|
36
|
+
options: import("@udecode/plate-resizable").ResizableOptions;
|
|
37
|
+
} & React.RefAttributes<HTMLDivElement>, "ref"> & import("class-variance-authority").VariantProps<(props?: ({
|
|
38
|
+
align?: "center" | "right" | "left" | null | undefined;
|
|
39
|
+
} & import("class-variance-authority/dist/types").ClassProp) | undefined) => string> & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { cn, withRef, withVariants } from '@udecode/cn';
|
|
4
|
+
import { Resizable as ResizablePrimitive, ResizeHandle as ResizeHandlePrimitive, } from '@udecode/plate-resizable';
|
|
5
|
+
import { cva } from 'class-variance-authority';
|
|
6
|
+
export const mediaResizeHandleVariants = cva(cn('top-0 flex w-6 select-none flex-col justify-center', "after:flex after:h-16 after:w-[3px] after:rounded-[6px] after:bg-ring after:opacity-0 after:content-['_'] group-hover:after:opacity-100"), {
|
|
7
|
+
variants: {
|
|
8
|
+
direction: {
|
|
9
|
+
left: '-left-3 -ml-3 pl-3',
|
|
10
|
+
right: '-right-3 -mr-3 items-end pr-3',
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
});
|
|
14
|
+
const resizeHandleVariants = cva(cn('absolute z-40'), {
|
|
15
|
+
variants: {
|
|
16
|
+
direction: {
|
|
17
|
+
left: 'h-full cursor-col-resize',
|
|
18
|
+
right: 'h-full cursor-col-resize',
|
|
19
|
+
top: 'w-full cursor-row-resize',
|
|
20
|
+
bottom: 'w-full cursor-row-resize',
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
const ResizeHandleVariants = withVariants(ResizeHandlePrimitive, resizeHandleVariants, ['direction']);
|
|
25
|
+
export const ResizeHandle = withRef((props, ref) => (React.createElement(ResizeHandleVariants, { ref: ref, direction: props.options?.direction, ...props })));
|
|
26
|
+
const resizableVariants = cva('', {
|
|
27
|
+
variants: {
|
|
28
|
+
align: {
|
|
29
|
+
left: 'mr-auto',
|
|
30
|
+
center: 'mx-auto',
|
|
31
|
+
right: 'ml-auto',
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
export const Resizable = withVariants(ResizablePrimitive, resizableVariants, [
|
|
36
|
+
'align',
|
|
37
|
+
]);
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import * as SeparatorPrimitive from '@radix-ui/react-separator';
|
|
3
|
+
export declare const Separator: import("react").ForwardRefExoticComponent<Omit<Omit<SeparatorPrimitive.SeparatorProps & import("react").RefAttributes<HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>, "ref"> & import("class-variance-authority").VariantProps<(props?: ({
|
|
4
|
+
orientation?: "vertical" | "horizontal" | null | undefined;
|
|
5
|
+
} & import("class-variance-authority/dist/types").ClassProp) | undefined) => string> & import("react").RefAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import * as SeparatorPrimitive from '@radix-ui/react-separator';
|
|
3
|
+
import { withProps, withVariants } from '@udecode/cn';
|
|
4
|
+
import { cva } from 'class-variance-authority';
|
|
5
|
+
const separatorVariants = cva('shrink-0 bg-border', {
|
|
6
|
+
variants: {
|
|
7
|
+
orientation: {
|
|
8
|
+
horizontal: 'h-[1px] w-full',
|
|
9
|
+
vertical: 'h-full w-[1px]',
|
|
10
|
+
},
|
|
11
|
+
},
|
|
12
|
+
defaultVariants: {
|
|
13
|
+
orientation: 'horizontal',
|
|
14
|
+
},
|
|
15
|
+
});
|
|
16
|
+
export const Separator = withVariants(withProps(SeparatorPrimitive.Root, {
|
|
17
|
+
orientation: 'horizontal',
|
|
18
|
+
decorative: true,
|
|
19
|
+
}), separatorVariants);
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export declare const TableCellElement: React.ForwardRefExoticComponent<Omit<import("@udecode/plate-core").PlateRenderNodeProps<import("@udecode/slate").Value, import("@udecode/plate-core").PlateEditor<import("@udecode/slate").Value>> & Omit<import("slate-react").RenderElementProps, "element"> & {
|
|
3
|
+
element: import("@udecode/slate").TElement;
|
|
4
|
+
} & Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
5
|
+
as?: React.ElementType<any> | undefined;
|
|
6
|
+
asChild?: boolean | undefined;
|
|
7
|
+
} & React.RefAttributes<any> & {
|
|
8
|
+
elementToAttributes?: ((element: import("@udecode/slate").TElement) => any) | undefined;
|
|
9
|
+
} & React.RefAttributes<HTMLDivElement>, "ref"> & {
|
|
10
|
+
hideBorder?: boolean | undefined;
|
|
11
|
+
isHeader?: boolean | undefined;
|
|
12
|
+
} & React.RefAttributes<any>>;
|
|
13
|
+
export declare const TableCellHeaderElement: React.ForwardRefExoticComponent<Omit<Omit<import("@udecode/plate-core").PlateRenderNodeProps<import("@udecode/slate").Value, import("@udecode/plate-core").PlateEditor<import("@udecode/slate").Value>> & Omit<import("slate-react").RenderElementProps, "element"> & {
|
|
14
|
+
element: import("@udecode/slate").TElement;
|
|
15
|
+
} & Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
16
|
+
as?: React.ElementType<any> | undefined;
|
|
17
|
+
asChild?: boolean | undefined;
|
|
18
|
+
} & React.RefAttributes<any> & {
|
|
19
|
+
elementToAttributes?: ((element: import("@udecode/slate").TElement) => any) | undefined;
|
|
20
|
+
} & React.RefAttributes<HTMLDivElement>, "ref"> & {
|
|
21
|
+
hideBorder?: boolean | undefined;
|
|
22
|
+
isHeader?: boolean | undefined;
|
|
23
|
+
} & React.RefAttributes<any>, "ref"> & React.RefAttributes<any>>;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { cn, withProps, withRef } from '@udecode/cn';
|
|
3
|
+
import { PlateElement } from '@udecode/plate-common';
|
|
4
|
+
import { useTableCellElement, useTableCellElementResizable, useTableCellElementResizableState, useTableCellElementState, } from '@udecode/plate-table';
|
|
5
|
+
import { ResizeHandle } from './resizable';
|
|
6
|
+
export const TableCellElement = withRef(({ children, className, style, hideBorder, isHeader, ...props }, ref) => {
|
|
7
|
+
const { element } = props;
|
|
8
|
+
const { colIndex, rowIndex, readOnly, selected, hovered, hoveredLeft, rowSize, borders, isSelectingCell, colSpan, } = useTableCellElementState();
|
|
9
|
+
const { props: cellProps } = useTableCellElement({ element: props.element });
|
|
10
|
+
const resizableState = useTableCellElementResizableState({
|
|
11
|
+
colIndex,
|
|
12
|
+
rowIndex,
|
|
13
|
+
colSpan,
|
|
14
|
+
});
|
|
15
|
+
const { rightProps, bottomProps, leftProps, hiddenLeft } = useTableCellElementResizable(resizableState);
|
|
16
|
+
const Cell = isHeader ? 'th' : 'td';
|
|
17
|
+
return (React.createElement(PlateElement, { ref: ref, asChild: true, className: cn('relative h-full overflow-visible border-none bg-background p-0', hideBorder && 'before:border-none', element.background ? 'bg-[--cellBackground]' : 'bg-background', !hideBorder &&
|
|
18
|
+
cn(isHeader && 'text-left [&_>_*]:m-0', 'before:h-full before:w-full', selected && 'before:z-10 before:bg-muted', "before:absolute before:box-border before:select-none before:content-['']", borders &&
|
|
19
|
+
cn(borders.bottom?.size &&
|
|
20
|
+
`before:border-b before:border-b-border`, borders.right?.size && `before:border-r before:border-r-border`, borders.left?.size && `before:border-l before:border-l-border`, borders.top?.size && `before:border-t before:border-t-border`)), className), ...cellProps, ...props, style: {
|
|
21
|
+
'--cellBackground': element.background,
|
|
22
|
+
...style,
|
|
23
|
+
} },
|
|
24
|
+
React.createElement(Cell, null,
|
|
25
|
+
React.createElement("div", { className: "relative z-20 box-border h-full px-3 py-2", style: {
|
|
26
|
+
minHeight: rowSize,
|
|
27
|
+
} }, children),
|
|
28
|
+
!isSelectingCell && (React.createElement("div", { className: "group absolute top-0 h-full w-full select-none", contentEditable: false, suppressContentEditableWarning: true }, !readOnly && (React.createElement(React.Fragment, null,
|
|
29
|
+
React.createElement(ResizeHandle, { ...rightProps, className: "-top-3 right-[-5px] w-[10px]" }),
|
|
30
|
+
React.createElement(ResizeHandle, { ...bottomProps, className: "bottom-[-5px] h-[10px]" }),
|
|
31
|
+
!hiddenLeft && (React.createElement(ResizeHandle, { ...leftProps, className: "-top-3 left-[-5px] w-[10px]" })),
|
|
32
|
+
hovered && (React.createElement("div", { className: cn('absolute -top-3 z-30 h-[calc(100%_+_12px)] w-1 bg-ring', 'right-[-1.5px]') })),
|
|
33
|
+
hoveredLeft && (React.createElement("div", { className: cn('absolute -top-3 z-30 h-[calc(100%_+_12px)] w-1 bg-ring', 'left-[-1.5px]') })))))))));
|
|
34
|
+
});
|
|
35
|
+
TableCellElement.displayName = 'TableCellElement';
|
|
36
|
+
export const TableCellHeaderElement = withProps(TableCellElement, {
|
|
37
|
+
isHeader: true,
|
|
38
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export declare const TableRowElement: React.ForwardRefExoticComponent<Omit<import("@udecode/plate-core").PlateRenderNodeProps<import("@udecode/slate").Value, import("@udecode/plate-core").PlateEditor<import("@udecode/slate").Value>> & Omit<import("slate-react").RenderElementProps, "element"> & {
|
|
3
|
+
element: import("@udecode/slate").TElement;
|
|
4
|
+
} & Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
5
|
+
as?: React.ElementType<any> | undefined;
|
|
6
|
+
asChild?: boolean | undefined;
|
|
7
|
+
} & React.RefAttributes<any> & {
|
|
8
|
+
elementToAttributes?: ((element: import("@udecode/slate").TElement) => any) | undefined;
|
|
9
|
+
} & React.RefAttributes<HTMLDivElement>, "ref"> & {
|
|
10
|
+
hideBorder?: boolean | undefined;
|
|
11
|
+
} & React.RefAttributes<any>>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { cn, withRef } from '@udecode/cn';
|
|
3
|
+
import { PlateElement } from '@udecode/plate-common';
|
|
4
|
+
export const TableRowElement = withRef(({ hideBorder, children, ...props }, ref) => {
|
|
5
|
+
return (React.createElement(PlateElement, { asChild: true, ref: ref, className: cn('h-full', hideBorder && 'border-none'), ...props },
|
|
6
|
+
React.createElement("tr", null, children)));
|
|
7
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';
|
|
3
|
+
export declare const TableBordersDropdownMenuContent: React.ForwardRefExoticComponent<Omit<DropdownMenuPrimitive.DropdownMenuContentProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
4
|
+
export declare const TableFloatingToolbar: React.ForwardRefExoticComponent<Omit<Omit<import("@radix-ui/react-popover").PopoverContentProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
5
|
+
export declare const TableElement: React.ForwardRefExoticComponent<Omit<Omit<import("@udecode/plate-core").PlateRenderNodeProps<import("@udecode/slate").Value, import("@udecode/plate-core").PlateEditor<import("@udecode/slate").Value>> & Omit<import("slate-react").RenderElementProps, "element"> & {
|
|
6
|
+
element: import("@udecode/slate").TElement;
|
|
7
|
+
} & Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
8
|
+
as?: React.ElementType<any> | undefined;
|
|
9
|
+
asChild?: boolean | undefined;
|
|
10
|
+
} & React.RefAttributes<any> & {
|
|
11
|
+
elementToAttributes?: ((element: import("@udecode/slate").TElement) => any) | undefined;
|
|
12
|
+
} & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<any>, "ref"> & React.RefAttributes<unknown>>;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { cn, withRef } from '@udecode/cn';
|
|
3
|
+
import { isSelectionExpanded, PlateElement, useEditorRef, useEditorSelector, useElement, useRemoveNodeButton, withHOC, } from '@udecode/plate-common';
|
|
4
|
+
import { mergeTableCells, TableProvider, unmergeTableCells, useTableBordersDropdownMenuContentState, useTableElement, useTableElementState, useTableMergeState, } from '@udecode/plate-table';
|
|
5
|
+
import { useReadOnly, useSelected } from 'slate-react';
|
|
6
|
+
import { PopoverAnchor } from '@radix-ui/react-popover';
|
|
7
|
+
import { Combine, Trash, Ungroup } from 'lucide-react';
|
|
8
|
+
import { Button } from './plate-button';
|
|
9
|
+
import { DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuPortal, DropdownMenuTrigger, } from './dropdown-menu';
|
|
10
|
+
import { Popover, PopoverContent, popoverVariants } from './popover';
|
|
11
|
+
import { Separator } from './separator';
|
|
12
|
+
import { BorderAll, BorderBottom, BorderLeft, BorderNone, BorderRight, BorderTop, } from '../../icons';
|
|
13
|
+
export const TableBordersDropdownMenuContent = withRef((props, ref) => {
|
|
14
|
+
const { getOnSelectTableBorder, hasOuterBorders, hasBottomBorder, hasLeftBorder, hasNoBorders, hasRightBorder, hasTopBorder, } = useTableBordersDropdownMenuContentState();
|
|
15
|
+
return (React.createElement(DropdownMenuContent, { ref: ref, className: cn('min-w-[220px]'), side: "right", align: "start", sideOffset: 0, ...props },
|
|
16
|
+
React.createElement(DropdownMenuCheckboxItem, { checked: hasBottomBorder, onCheckedChange: getOnSelectTableBorder('bottom') },
|
|
17
|
+
React.createElement(BorderBottom, { className: "mr-2 h-4 w-4" }),
|
|
18
|
+
React.createElement("div", null, "Bottom Border")),
|
|
19
|
+
React.createElement(DropdownMenuCheckboxItem, { checked: hasTopBorder, onCheckedChange: getOnSelectTableBorder('top') },
|
|
20
|
+
React.createElement(BorderTop, { className: "mr-2 h-4 w-4" }),
|
|
21
|
+
React.createElement("div", null, "Top Border")),
|
|
22
|
+
React.createElement(DropdownMenuCheckboxItem, { checked: hasLeftBorder, onCheckedChange: getOnSelectTableBorder('left') },
|
|
23
|
+
React.createElement(BorderLeft, { className: "mr-2 h-4 w-4" }),
|
|
24
|
+
React.createElement("div", null, "Left Border")),
|
|
25
|
+
React.createElement(DropdownMenuCheckboxItem, { checked: hasRightBorder, onCheckedChange: getOnSelectTableBorder('right') },
|
|
26
|
+
React.createElement(BorderRight, { className: "mr-2 h-4 w-4" }),
|
|
27
|
+
React.createElement("div", null, "Right Border")),
|
|
28
|
+
React.createElement(Separator, null),
|
|
29
|
+
React.createElement(DropdownMenuCheckboxItem, { checked: hasNoBorders, onCheckedChange: getOnSelectTableBorder('none') },
|
|
30
|
+
React.createElement(BorderNone, { className: "mr-2 h-4 w-4" }),
|
|
31
|
+
React.createElement("div", null, "No Border")),
|
|
32
|
+
React.createElement(DropdownMenuCheckboxItem, { checked: hasOuterBorders, onCheckedChange: getOnSelectTableBorder('outer') },
|
|
33
|
+
React.createElement(BorderAll, { className: "mr-2 h-4 w-4" }),
|
|
34
|
+
React.createElement("div", null, "Outside Borders"))));
|
|
35
|
+
});
|
|
36
|
+
export const TableFloatingToolbar = withRef(({ children, ...props }, ref) => {
|
|
37
|
+
const element = useElement();
|
|
38
|
+
const { props: buttonProps } = useRemoveNodeButton({ element });
|
|
39
|
+
const selectionCollapsed = useEditorSelector((editor) => !isSelectionExpanded(editor), []);
|
|
40
|
+
const readOnly = useReadOnly();
|
|
41
|
+
const selected = useSelected();
|
|
42
|
+
const editor = useEditorRef();
|
|
43
|
+
const collapsed = !readOnly && selected && selectionCollapsed;
|
|
44
|
+
const open = !readOnly && selected;
|
|
45
|
+
const { canMerge, canUnmerge } = useTableMergeState();
|
|
46
|
+
const mergeContent = canMerge && (React.createElement(Button, { contentEditable: false, variant: "ghost", isMenu: true, onClick: () => mergeTableCells(editor) },
|
|
47
|
+
React.createElement(Combine, { className: "mr-2 h-4 w-4" }),
|
|
48
|
+
"Merge"));
|
|
49
|
+
const unmergeButton = canUnmerge && (React.createElement(Button, { contentEditable: false, variant: "ghost", isMenu: true, onClick: () => unmergeTableCells(editor) },
|
|
50
|
+
React.createElement(Ungroup, { className: "mr-2 h-4 w-4" }),
|
|
51
|
+
"Unmerge"));
|
|
52
|
+
const bordersContent = collapsed && (React.createElement(React.Fragment, null,
|
|
53
|
+
React.createElement(DropdownMenu, { modal: false },
|
|
54
|
+
React.createElement(DropdownMenuTrigger, { asChild: true },
|
|
55
|
+
React.createElement(Button, { variant: "ghost", isMenu: true },
|
|
56
|
+
React.createElement(BorderAll, { className: "mr-2 h-4 w-4" }),
|
|
57
|
+
"Borders")),
|
|
58
|
+
React.createElement(DropdownMenuPortal, null,
|
|
59
|
+
React.createElement(TableBordersDropdownMenuContent, null))),
|
|
60
|
+
React.createElement(Button, { contentEditable: false, variant: "ghost", isMenu: true, ...buttonProps },
|
|
61
|
+
React.createElement(Trash, { className: "mr-2 h-4 w-4" }),
|
|
62
|
+
"Delete")));
|
|
63
|
+
return (React.createElement(Popover, { open: open, modal: false },
|
|
64
|
+
React.createElement(PopoverAnchor, { asChild: true }, children),
|
|
65
|
+
(canMerge || canUnmerge || collapsed) && (React.createElement(PopoverContent, { ref: ref, className: cn(popoverVariants(), 'flex w-[220px] flex-col gap-1 p-1'), onOpenAutoFocus: (e) => e.preventDefault(), ...props },
|
|
66
|
+
unmergeButton,
|
|
67
|
+
mergeContent,
|
|
68
|
+
bordersContent))));
|
|
69
|
+
});
|
|
70
|
+
export const TableElement = withHOC(TableProvider, withRef(({ className, children, ...props }, ref) => {
|
|
71
|
+
const { colSizes, isSelectingCell, minColumnWidth, marginLeft } = useTableElementState();
|
|
72
|
+
const { props: tableProps, colGroupProps } = useTableElement();
|
|
73
|
+
return (React.createElement(TableFloatingToolbar, null,
|
|
74
|
+
React.createElement("div", { style: { paddingLeft: marginLeft } },
|
|
75
|
+
React.createElement(PlateElement, { ref: ref, asChild: true, className: cn('my-4 ml-px mr-0 table h-px w-full table-fixed border-collapse', isSelectingCell && '[&_*::selection]:bg-none', className), ...tableProps, ...props },
|
|
76
|
+
React.createElement("table", null,
|
|
77
|
+
React.createElement("colgroup", { ...colGroupProps }, colSizes.map((width, index) => (React.createElement("col", { key: index, style: {
|
|
78
|
+
minWidth: minColumnWidth,
|
|
79
|
+
width: width || undefined,
|
|
80
|
+
} })))),
|
|
81
|
+
React.createElement("tbody", { className: "min-w-full" }, children))))));
|
|
82
|
+
}));
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { createPluginFactory, PlateElement, } from '@udecode/plate';
|
|
3
|
-
import { P } from '
|
|
4
|
-
import { H } from '
|
|
5
|
-
import * as Elements from '
|
|
3
|
+
import { P } from '../../../atoms/typography/paragraph';
|
|
4
|
+
import { H } from '../../../atoms/typography/heading';
|
|
5
|
+
import * as Elements from '../../constants';
|
|
6
6
|
export const ParagraphElement = React.forwardRef(({ children, ...props }, ref) => {
|
|
7
7
|
const textAlign = props?.style?.textAlign;
|
|
8
8
|
return (React.createElement(PlateElement, { asChild: true, ref: ref, ...props },
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { createPluginFactory, isEditorReadOnly, PlateElement, } from '@udecode/plate';
|
|
3
|
-
import { ELEMENT_H2, ELEMENT_VIDEO } from '
|
|
4
|
-
import { EditorContext } from '
|
|
3
|
+
import { ELEMENT_H2, ELEMENT_VIDEO } from '../../constants';
|
|
4
|
+
import { EditorContext } from '../../context';
|
|
5
5
|
export const VideoTitleElement = React.forwardRef(function VideoTitle({ editor, element, ...props }, ref) {
|
|
6
6
|
const editable = !isEditorReadOnly(editor);
|
|
7
7
|
const { id } = element;
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export
|
|
5
|
-
export declare const marks: (import("@udecode/plate-core").PlatePlugin<import("@udecode/utils").AnyObject, import("@udecode/slate").Value, import("@udecode/plate-core").PlateEditor<import("@udecode/slate").Value>> | import("@udecode/plate-core").PlatePlugin<import("@udecode/plate-core").ToggleMarkPlugin, import("@udecode/slate").Value, import("@udecode/plate-core").PlateEditor<import("@udecode/slate").Value>>)[];
|
|
6
|
-
export declare const inline: (import("@udecode/plate-core").PlatePlugin<import("@udecode/utils").AnyObject, import("@udecode/slate").Value, import("@udecode/plate-core").PlateEditor<import("@udecode/slate").Value>> | import("@udecode/plate-core").PlatePlugin<import("@udecode/plate-indent").IndentPlugin, import("@udecode/slate").Value, import("@udecode/plate-core").PlateEditor<import("@udecode/slate").Value>> | import("@udecode/plate-core").PlatePlugin<import("@udecode/plate-link").LinkPlugin, import("@udecode/slate").Value, import("@udecode/plate-core").PlateEditor<import("@udecode/slate").Value>>)[];
|
|
7
|
-
export declare const utils: (import("@udecode/plate-core").PlatePlugin<import("@udecode/utils").AnyObject, import("@udecode/slate").Value, import("@udecode/plate-core").PlateEditor<import("@udecode/slate").Value>> | import("@udecode/plate-core").PlatePlugin<import("@udecode/plate-reset-node").ResetNodePlugin<import("@udecode/slate").Value, import("@udecode/plate-core").PlateEditor<import("@udecode/slate").Value>>, import("@udecode/slate").Value, import("@udecode/plate-core").PlateEditor<import("@udecode/slate").Value>> | import("@udecode/plate-core").PlatePlugin<import("@udecode/plate-break").ExitBreakPlugin, import("@udecode/slate").Value, import("@udecode/plate-core").PlateEditor<import("@udecode/slate").Value>> | import("@udecode/plate-core").PlatePlugin<import("@udecode/plate-select").SelectOnBackspacePlugin, import("@udecode/slate").Value, import("@udecode/plate-core").PlateEditor<import("@udecode/slate").Value>> | import("@udecode/plate-core").PlatePlugin<import("@udecode/plate-break").SoftBreakPlugin, import("@udecode/slate").Value, import("@udecode/plate-core").PlateEditor<import("@udecode/slate").Value>>)[];
|
|
1
|
+
export { blocks } from './blocks';
|
|
2
|
+
export { leafs } from './leafs';
|
|
3
|
+
export { marks } from './marks';
|
|
4
|
+
export { utils } from './utils';
|