| 1 |
import { ReactNode } from "react"; |
| 2 |
import textBlockIcon from "@tableberg/shared/icons/text"; |
| 3 |
import buttonBlockIcon from "@tableberg/shared/icons/button"; |
| 4 |
import imageBlockIcon from "@tableberg/shared/icons/image"; |
| 5 |
import StyledListIcon from "@tableberg/shared/icons/styled-list"; |
| 6 |
import HtmlIcon from "@tableberg/shared/icons/html"; |
| 7 |
import IconIcon from "@tableberg/shared/icons/icon"; |
| 8 |
import StarRatingIcon from "@tableberg/shared/icons/star-rating"; |
| 9 |
import { ElementTypes } from "../../attributes"; |
| 10 |
import { getExtendedElementDefinitions } from "../../extensions"; |
| 11 |
import { isProAvailable } from "../../pro-status"; |
| 12 |
|
| 13 |
export interface InserterItem { |
| 14 |
name: ElementTypes; |
| 15 |
title: string; |
| 16 |
icon: ReactNode; |
| 17 |
disabled?: boolean; |
| 18 |
isLocked?: boolean; |
| 19 |
upsellSelected?: string; |
| 20 |
} |
| 21 |
|
| 22 |
const baseCellInserterItems: InserterItem[] = [ |
| 23 |
{ name: "text", title: "Text", icon: textBlockIcon }, |
| 24 |
{ name: "button", title: "Button", icon: buttonBlockIcon }, |
| 25 |
{ name: "image", title: "Image", icon: imageBlockIcon }, |
| 26 |
{ name: "list", title: "List", icon: StyledListIcon }, |
| 27 |
]; |
| 28 |
|
| 29 |
export function getCellInserterItems(): InserterItem[] { |
| 30 |
const lockedProItems: InserterItem[] = isProAvailable() |
| 31 |
? [] |
| 32 |
: [ |
| 33 |
{ |
| 34 |
name: "styled-list" as ElementTypes, |
| 35 |
title: "Styled List", |
| 36 |
icon: StyledListIcon, |
| 37 |
isLocked: true, |
| 38 |
upsellSelected: "tableberg/styled-list", |
| 39 |
}, |
| 40 |
{ |
| 41 |
name: "icon" as ElementTypes, |
| 42 |
title: "Icon", |
| 43 |
icon: IconIcon, |
| 44 |
isLocked: true, |
| 45 |
upsellSelected: "tableberg/icon", |
| 46 |
}, |
| 47 |
{ |
| 48 |
name: "star-rating" as ElementTypes, |
| 49 |
title: "Star Rating", |
| 50 |
icon: StarRatingIcon, |
| 51 |
isLocked: true, |
| 52 |
upsellSelected: "tableberg/star-rating", |
| 53 |
}, |
| 54 |
{ |
| 55 |
name: "custom-html" as ElementTypes, |
| 56 |
title: "Custom HTML", |
| 57 |
icon: HtmlIcon, |
| 58 |
isLocked: true, |
| 59 |
upsellSelected: "tableberg/html", |
| 60 |
}, |
| 61 |
]; |
| 62 |
|
| 63 |
return [ |
| 64 |
...baseCellInserterItems, |
| 65 |
...lockedProItems, |
| 66 |
...getExtendedElementDefinitions().map(definition => ({ |
| 67 |
name: definition.name as ElementTypes, |
| 68 |
title: definition.title, |
| 69 |
icon: definition.icon, |
| 70 |
})), |
| 71 |
]; |
| 72 |
} |
| 73 |
|
| 74 |
export const cellInserterItems = getCellInserterItems(); |
| 75 |
|