Skip to content

Commit 63edd74

Browse files
authored
Merge pull request #4479 from tmackness/main
2 parents 1ff95a5 + 2f94fd8 commit 63edd74

File tree

8 files changed

+152
-2
lines changed

8 files changed

+152
-2
lines changed

apps/www/src/registry/components/editor/plate-types.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,18 @@ export interface MyH3Element extends MyTextBlockElement {
6666
type: typeof KEYS.h3;
6767
}
6868

69+
export interface MyH4Element extends MyTextBlockElement {
70+
type: typeof KEYS.h4;
71+
}
72+
73+
export interface MyH5Element extends MyTextBlockElement {
74+
type: typeof KEYS.h5;
75+
}
76+
77+
export interface MyH6Element extends MyTextBlockElement {
78+
type: typeof KEYS.h6;
79+
}
80+
6981
export interface MyHrElement extends MyBlockElement {
7082
children: [EmptyText];
7183
type: typeof KEYS.hr;
@@ -139,6 +151,9 @@ export type MyValue = (
139151
| MyH1Element
140152
| MyH2Element
141153
| MyH3Element
154+
| MyH4Element
155+
| MyH5Element
156+
| MyH6Element
142157
| MyHrElement
143158
| MyImageElement
144159
| MyMediaEmbedElement

apps/www/src/registry/components/editor/plugins/basic-blocks-base-kit.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ import {
33
BaseH1Plugin,
44
BaseH2Plugin,
55
BaseH3Plugin,
6+
BaseH4Plugin,
7+
BaseH5Plugin,
8+
BaseH6Plugin,
69
BaseHorizontalRulePlugin,
710
} from '@platejs/basic-nodes';
811
import { BaseParagraphPlugin } from 'platejs';
@@ -12,6 +15,9 @@ import {
1215
H1ElementStatic,
1316
H2ElementStatic,
1417
H3ElementStatic,
18+
H4ElementStatic,
19+
H5ElementStatic,
20+
H6ElementStatic,
1521
} from '@/registry/ui/heading-node-static';
1622
import { HrElementStatic } from '@/registry/ui/hr-node-static';
1723
import { ParagraphElementStatic } from '@/registry/ui/paragraph-node-static';
@@ -21,6 +27,9 @@ export const BaseBasicBlocksKit = [
2127
BaseH1Plugin.withComponent(H1ElementStatic),
2228
BaseH2Plugin.withComponent(H2ElementStatic),
2329
BaseH3Plugin.withComponent(H3ElementStatic),
30+
BaseH4Plugin.withComponent(H4ElementStatic),
31+
BaseH5Plugin.withComponent(H5ElementStatic),
32+
BaseH6Plugin.withComponent(H6ElementStatic),
2433
BaseBlockquotePlugin.withComponent(BlockquoteElementStatic),
2534
BaseHorizontalRulePlugin.withComponent(HrElementStatic),
2635
];

apps/www/src/registry/components/editor/plugins/basic-blocks-kit.tsx

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,15 @@ import {
55
H1Plugin,
66
H2Plugin,
77
H3Plugin,
8+
H4Plugin,
9+
H5Plugin,
10+
H6Plugin,
811
HorizontalRulePlugin,
912
} from '@platejs/basic-nodes/react';
1013
import { ParagraphPlugin } from 'platejs/react';
1114

1215
import { BlockquoteElement } from '@/registry/ui/blockquote-node';
13-
import { H1Element, H2Element, H3Element } from '@/registry/ui/heading-node';
16+
import { H1Element, H2Element, H3Element, H4Element, H5Element, H6Element } from '@/registry/ui/heading-node';
1417
import { HrElement } from '@/registry/ui/hr-node';
1518
import { ParagraphElement } from '@/registry/ui/paragraph-node';
1619

@@ -43,6 +46,33 @@ export const BasicBlocksKit = [
4346
},
4447
shortcuts: { toggle: { keys: 'mod+alt+3' } },
4548
}),
49+
H4Plugin.configure({
50+
node: {
51+
component: H4Element,
52+
},
53+
rules: {
54+
break: { empty: 'reset' },
55+
},
56+
shortcuts: { toggle: { keys: 'mod+alt+4' } },
57+
}),
58+
H5Plugin.configure({
59+
node: {
60+
component: H5Element,
61+
},
62+
rules: {
63+
break: { empty: 'reset' },
64+
},
65+
shortcuts: { toggle: { keys: 'mod+alt+5' } },
66+
}),
67+
H6Plugin.configure({
68+
node: {
69+
component: H6Element,
70+
},
71+
rules: {
72+
break: { empty: 'reset' },
73+
},
74+
shortcuts: { toggle: { keys: 'mod+alt+6' } },
75+
}),
4676
BlockquotePlugin.configure({
4777
node: { component: BlockquoteElement },
4878
shortcuts: { toggle: { keys: 'mod+shift+period' } },

apps/www/src/registry/ui/turn-into-toolbar-button.tsx

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ import {
1414
Heading1Icon,
1515
Heading2Icon,
1616
Heading3Icon,
17+
Heading4Icon,
18+
Heading5Icon,
19+
Heading6Icon,
1720
ListIcon,
1821
ListOrderedIcon,
1922
PilcrowIcon,
@@ -61,6 +64,24 @@ export const turnIntoItems = [
6164
label: 'Heading 3',
6265
value: 'h3',
6366
},
67+
{
68+
icon: <Heading4Icon />,
69+
keywords: ["subtitle", "h4"],
70+
label: "Heading 4",
71+
value: "h4",
72+
},
73+
{
74+
icon: <Heading5Icon />,
75+
keywords: ["subtitle", "h5"],
76+
label: "Heading 5",
77+
value: "h5",
78+
},
79+
{
80+
icon: <Heading6Icon />,
81+
keywords: ["subtitle", "h6"],
82+
label: "Heading 6",
83+
value: "h6",
84+
},
6485
{
6586
icon: <ListIcon />,
6687
keywords: ['unordered', 'ul', '-'],

templates/plate-playground-template/src/components/editor/plate-types.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,18 @@ export interface MyH3Element extends MyTextBlockElement {
6666
type: typeof KEYS.h3;
6767
}
6868

69+
export interface MyH4Element extends MyTextBlockElement {
70+
type: typeof KEYS.h4;
71+
}
72+
73+
export interface MyH5Element extends MyTextBlockElement {
74+
type: typeof KEYS.h5;
75+
}
76+
77+
export interface MyH6Element extends MyTextBlockElement {
78+
type: typeof KEYS.h6;
79+
}
80+
6981
export interface MyHrElement extends MyBlockElement {
7082
children: [EmptyText];
7183
type: typeof KEYS.hr;
@@ -139,6 +151,9 @@ export type MyValue = (
139151
| MyH1Element
140152
| MyH2Element
141153
| MyH3Element
154+
| MyH4Element
155+
| MyH5Element
156+
| MyH6Element
142157
| MyHrElement
143158
| MyImageElement
144159
| MyMediaEmbedElement

templates/plate-playground-template/src/components/editor/plugins/basic-blocks-base-kit.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ import {
33
BaseH1Plugin,
44
BaseH2Plugin,
55
BaseH3Plugin,
6+
BaseH4Plugin,
7+
BaseH5Plugin,
8+
BaseH6Plugin,
69
BaseHorizontalRulePlugin,
710
} from '@platejs/basic-nodes';
811
import { BaseParagraphPlugin } from 'platejs';
@@ -12,6 +15,9 @@ import {
1215
H1ElementStatic,
1316
H2ElementStatic,
1417
H3ElementStatic,
18+
H4ElementStatic,
19+
H5ElementStatic,
20+
H6ElementStatic,
1521
} from '@/components/ui/heading-node-static';
1622
import { HrElementStatic } from '@/components/ui/hr-node-static';
1723
import { ParagraphElementStatic } from '@/components/ui/paragraph-node-static';
@@ -21,6 +27,9 @@ export const BaseBasicBlocksKit = [
2127
BaseH1Plugin.withComponent(H1ElementStatic),
2228
BaseH2Plugin.withComponent(H2ElementStatic),
2329
BaseH3Plugin.withComponent(H3ElementStatic),
30+
BaseH4Plugin.withComponent(H4ElementStatic),
31+
BaseH5Plugin.withComponent(H5ElementStatic),
32+
BaseH6Plugin.withComponent(H6ElementStatic),
2433
BaseBlockquotePlugin.withComponent(BlockquoteElementStatic),
2534
BaseHorizontalRulePlugin.withComponent(HrElementStatic),
2635
];

templates/plate-playground-template/src/components/editor/plugins/basic-blocks-kit.tsx

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,15 @@ import {
55
H1Plugin,
66
H2Plugin,
77
H3Plugin,
8+
H4Plugin,
9+
H5Plugin,
10+
H6Plugin,
811
HorizontalRulePlugin,
912
} from '@platejs/basic-nodes/react';
1013
import { ParagraphPlugin } from 'platejs/react';
1114

1215
import { BlockquoteElement } from '@/components/ui/blockquote-node';
13-
import { H1Element, H2Element, H3Element } from '@/components/ui/heading-node';
16+
import { H1Element, H2Element, H3Element, H4Element, H5Element, H6Element } from '@/components/ui/heading-node';
1417
import { HrElement } from '@/components/ui/hr-node';
1518
import { ParagraphElement } from '@/components/ui/paragraph-node';
1619

@@ -43,6 +46,33 @@ export const BasicBlocksKit = [
4346
},
4447
shortcuts: { toggle: { keys: 'mod+alt+3' } },
4548
}),
49+
H4Plugin.configure({
50+
node: {
51+
component: H4Element,
52+
},
53+
rules: {
54+
break: { empty: "reset" },
55+
},
56+
shortcuts: { toggle: { keys: 'mod+alt+4' } },
57+
}),
58+
H5Plugin.configure({
59+
node: {
60+
component: H5Element,
61+
},
62+
rules: {
63+
break: { empty: "reset" },
64+
},
65+
shortcuts: { toggle: { keys: 'mod+alt+5' } },
66+
}),
67+
H6Plugin.configure({
68+
node: {
69+
component: H6Element,
70+
},
71+
rules: {
72+
break: { empty: "reset" },
73+
},
74+
shortcuts: { toggle: { keys: 'mod+alt+6' } },
75+
}),
4676
BlockquotePlugin.configure({
4777
node: { component: BlockquoteElement },
4878
shortcuts: { toggle: { keys: 'mod+shift+period' } },

templates/plate-playground-template/src/components/ui/turn-into-toolbar-button.tsx

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ import {
1414
Heading1Icon,
1515
Heading2Icon,
1616
Heading3Icon,
17+
Heading4Icon,
18+
Heading5Icon,
19+
Heading6Icon,
1720
ListIcon,
1821
ListOrderedIcon,
1922
PilcrowIcon,
@@ -61,6 +64,24 @@ const turnIntoItems = [
6164
label: 'Heading 3',
6265
value: 'h3',
6366
},
67+
{
68+
icon: <Heading4Icon />,
69+
keywords: ["subtitle", "h4"],
70+
label: "Heading 4",
71+
value: "h4",
72+
},
73+
{
74+
icon: <Heading5Icon />,
75+
keywords: ["subtitle", "h5"],
76+
label: "Heading 5",
77+
value: "h5",
78+
},
79+
{
80+
icon: <Heading6Icon />,
81+
keywords: ["subtitle", "h6"],
82+
label: "Heading 6",
83+
value: "h6",
84+
},
6485
{
6586
icon: <ListIcon />,
6687
keywords: ['unordered', 'ul', '-'],

0 commit comments

Comments
 (0)