| 1 | "use client"; |
| 2 | |
| 3 | import { |
| 4 | BlockquotePlugin, |
| 5 | H1Plugin, |
| 6 | H2Plugin, |
| 7 | H3Plugin, |
| 8 | H4Plugin, |
| 9 | H5Plugin, |
| 10 | H6Plugin, |
| 11 | HorizontalRulePlugin, |
| 12 | } from "@platejs/basic-nodes/react"; |
| 13 | import { createPlatePlugin, ParagraphPlugin } from "platejs/react"; |
| 14 | |
| 15 | import { BlockquoteElement } from "@/components/plate/ui/blockquote-node"; |
| 16 | import { HrElement } from "@/components/plate/ui/hr-node"; |
| 17 | import ContributorElement from "../custom-elements/contributor"; |
| 18 | import LabelElement from "../custom-elements/label"; |
| 19 | import { |
| 20 | H1Element, |
| 21 | H2Element, |
| 22 | H3Element, |
| 23 | H4Element, |
| 24 | H5Element, |
| 25 | H6Element, |
| 26 | } from "../custom-elements/presentation-heading-element"; |
| 27 | import { PresentationParagraphElement } from "../custom-elements/presentation-paragraph-element"; |
| 28 | import PresentationTitleElement from "../custom-elements/presentation-title"; |
| 29 | import { |
| 30 | CONTRIBUTOR_ELEMENT, |
| 31 | LABEL_ELEMENT, |
| 32 | PRESENTATION_TITLE_ELEMENT, |
| 33 | } from "../lib"; |
| 34 | |
| 35 | const presentationTitleRules = { |
| 36 | break: { empty: "reset" as const }, |
| 37 | }; |
| 38 | |
| 39 | const PresentationTitlePlugin = createPlatePlugin({ |
| 40 | key: PRESENTATION_TITLE_ELEMENT, |
| 41 | node: { |
| 42 | isElement: true, |
| 43 | component: PresentationTitleElement, |
| 44 | }, |
| 45 | rules: { |
| 46 | break: presentationTitleRules.break, |
| 47 | }, |
| 48 | }); |
| 49 | |
| 50 | const LabelPlugin = createPlatePlugin({ |
| 51 | key: LABEL_ELEMENT, |
| 52 | node: { |
| 53 | isElement: true, |
| 54 | component: LabelElement, |
| 55 | }, |
| 56 | }); |
| 57 | |
| 58 | const ContributorPlugin = createPlatePlugin({ |
| 59 | key: CONTRIBUTOR_ELEMENT, |
| 60 | node: { |
| 61 | isElement: true, |
| 62 | isVoid: true, |
| 63 | component: ContributorElement, |
| 64 | }, |
| 65 | }); |
| 66 | |
| 67 | export const BasicBlocksKit = [ |
| 68 | ParagraphPlugin.withComponent(PresentationParagraphElement), |
| 69 | PresentationTitlePlugin, |
| 70 | LabelPlugin, |
| 71 | ContributorPlugin, |
| 72 | H1Plugin.configure({ |
| 73 | node: { |
| 74 | component: H1Element, |
| 75 | }, |
| 76 | rules: { |
| 77 | break: { empty: "reset" }, |
| 78 | }, |
| 79 | shortcuts: { toggle: { keys: "mod+alt+1" } }, |
| 80 | }), |
| 81 | H2Plugin.configure({ |
| 82 | node: { |
| 83 | component: H2Element, |
| 84 | }, |
| 85 | rules: { |
| 86 | break: { empty: "reset" }, |
| 87 | }, |
| 88 | shortcuts: { toggle: { keys: "mod+alt+2" } }, |
| 89 | }), |
| 90 | H3Plugin.configure({ |
| 91 | node: { |
| 92 | component: H3Element, |
| 93 | }, |
| 94 | rules: { |
| 95 | break: { empty: "reset" }, |
| 96 | }, |
| 97 | shortcuts: { toggle: { keys: "mod+alt+3" } }, |
| 98 | }), |
| 99 | H4Plugin.configure({ |
| 100 | node: { |
| 101 | component: H4Element, |
| 102 | }, |
| 103 | rules: { |
| 104 | break: { empty: "reset" }, |
| 105 | }, |
| 106 | shortcuts: { toggle: { keys: "mod+alt+4" } }, |
| 107 | }), |
| 108 | H5Plugin.configure({ |
| 109 | node: { |
| 110 | component: H5Element, |
| 111 | }, |
| 112 | rules: { |
| 113 | break: { empty: "reset" }, |
| 114 | }, |
| 115 | shortcuts: { toggle: { keys: "mod+alt+5" } }, |
| 116 | }), |
| 117 | H6Plugin.configure({ |
| 118 | node: { |
| 119 | component: H6Element, |
| 120 | }, |
| 121 | rules: { |
| 122 | break: { empty: "reset" }, |
| 123 | }, |
| 124 | shortcuts: { toggle: { keys: "mod+alt+6" } }, |
| 125 | }), |
| 126 | BlockquotePlugin.configure({ |
| 127 | node: { component: BlockquoteElement }, |
| 128 | shortcuts: { toggle: { keys: "mod+shift+period" } }, |
| 129 | }), |
| 130 | HorizontalRulePlugin.configure({ |
| 131 | node: { component: HrElement }, |
| 132 | }), |
| 133 | ]; |
| 134 |