PluginProbe
Code Block Pro – Beautiful Syntax Highlighting / 1.27.6
Code Block Pro – Beautiful Syntax Highlighting v1.27.6
1.27.1 1.27.2 1.27.3 1.27.4 1.27.5 1.27.6 1.27.7 1.28.0 1.3.0 1.4.0 1.5.0 1.5.1 1.5.2 1.6.0 1.7.0 1.8.0 1.9.0 1.9.1 1.9.2 1.9.3 trunk 1.1.0 1.10.0 1.11.0 1.11.1 All 63 releases
code-block-pro / src / editor / components / SlotFactory.tsx

SlotFactory.tsx in Code Block Pro – Beautiful Syntax Highlighting 1.27.6, at src/editor/components/SlotFactory.tsx

30 lines 878 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import { createSlotFill } from '@wordpress/components';
2 import { useMemo } from '@wordpress/element';
3 import { AttributesPropsAndSetter } from '../../types';
4 import { decode, encode } from '../../util/code';
5 import { languages } from '../../util/languages';
6
7 export const SlotFactory = ({
8 name,
9 attributes,
10 setAttributes,
11 }: AttributesPropsAndSetter & { name: string }) => {
12 const { Slot } = useMemo(() => {
13 return createSlotFill(name);
14 }, [name]);
15 return (
16 <Slot
17 fillProps={{
18 attributes,
19 setAttributes,
20 languages,
21 getCode: () => decode(attributes.code, attributes),
22 setCode: (code: string) =>
23 setAttributes({
24 code: encode(code, attributes),
25 }),
26 }}
27 />
28 );
29 };
30