@blinkk/root-cms 2.4.2 → 2.4.4

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.
@@ -23,10 +23,13 @@ interface RichTextProps {
23
23
  declare function RichText(props: RichTextProps): preact.JSX.Element;
24
24
  declare namespace RichText {
25
25
  var ParagraphBlock: (props: RichTextParagraphBlockProps) => preact.JSX.Element | null;
26
+ var DelimiterBlock: () => preact.JSX.Element;
26
27
  var HeadingBlock: (props: RichTextHeadingBlockProps) => preact.JSX.Element | null;
28
+ var QuoteBlock: (props: RichTextQuoteBlockProps) => preact.JSX.Element | null;
27
29
  var ListBlock: (props: RichTextListBlockProps) => preact.JSX.Element | null;
28
30
  var ImageBlock: (props: RichTextImageBlockProps) => preact.JSX.Element | null;
29
31
  var HtmlBlock: (props: RichTextHtmlBlockProps) => preact.JSX.Element | null;
32
+ var TableBlock: (props: RichTextTableBlockProps) => preact.JSX.Element | null;
30
33
  }
31
34
  interface RichTextParagraphBlockProps {
32
35
  type: 'paragraph';
@@ -34,6 +37,10 @@ interface RichTextParagraphBlockProps {
34
37
  text?: string;
35
38
  };
36
39
  }
40
+ interface RichTextDelimiterBlockProps {
41
+ type: 'delimiter';
42
+ data?: {};
43
+ }
37
44
  interface RichTextHeadingBlockProps {
38
45
  type: 'heading';
39
46
  data?: {
@@ -41,6 +48,12 @@ interface RichTextHeadingBlockProps {
41
48
  text?: string;
42
49
  };
43
50
  }
51
+ interface RichTextQuoteBlockProps {
52
+ type: 'quote';
53
+ data?: {
54
+ text?: string;
55
+ };
56
+ }
44
57
  interface ListItem {
45
58
  content?: string;
46
59
  items?: ListItem[];
@@ -69,5 +82,16 @@ interface RichTextHtmlBlockProps {
69
82
  html?: string;
70
83
  };
71
84
  }
85
+ interface RichTextTableBlockProps {
86
+ type: 'table';
87
+ data?: {
88
+ rows?: Array<{
89
+ cells: Array<{
90
+ blocks: RichTextBlock[];
91
+ type: 'header' | 'data';
92
+ }>;
93
+ }>;
94
+ };
95
+ }
72
96
 
73
- export { RichText, type RichTextBlock, type RichTextBlockComponent, RichTextContext, type RichTextContextProps, type RichTextData, type RichTextHeadingBlockProps, type RichTextHtmlBlockProps, type RichTextImageBlockProps, type RichTextListBlockProps, type RichTextParagraphBlockProps, type RichTextProps, useRichTextContext };
97
+ export { RichText, type RichTextBlock, type RichTextBlockComponent, RichTextContext, type RichTextContextProps, type RichTextData, type RichTextDelimiterBlockProps, type RichTextHeadingBlockProps, type RichTextHtmlBlockProps, type RichTextImageBlockProps, type RichTextListBlockProps, type RichTextParagraphBlockProps, type RichTextProps, type RichTextQuoteBlockProps, type RichTextTableBlockProps, useRichTextContext };
package/dist/richtext.js CHANGED
@@ -10,11 +10,14 @@ function useRichTextContext() {
10
10
  function RichText(props) {
11
11
  const richTextContext = useRichTextContext();
12
12
  const components = {
13
+ delimiter: RichText.DelimiterBlock,
13
14
  heading: RichText.HeadingBlock,
14
15
  html: RichText.HtmlBlock,
15
16
  image: RichText.ImageBlock,
16
17
  orderedList: RichText.ListBlock,
17
18
  paragraph: RichText.ParagraphBlock,
19
+ quote: RichText.QuoteBlock,
20
+ table: RichText.TableBlock,
18
21
  unorderedList: RichText.ListBlock,
19
22
  ...richTextContext.components,
20
23
  ...props.components
@@ -42,6 +45,9 @@ RichText.ParagraphBlock = (props) => {
42
45
  const t = useTranslations();
43
46
  return /* @__PURE__ */ jsx("p", { dangerouslySetInnerHTML: { __html: t(props.data.text) } });
44
47
  };
48
+ RichText.DelimiterBlock = () => {
49
+ return /* @__PURE__ */ jsx("hr", {});
50
+ };
45
51
  RichText.HeadingBlock = (props) => {
46
52
  if (!props.data?.text) {
47
53
  return null;
@@ -51,6 +57,13 @@ RichText.HeadingBlock = (props) => {
51
57
  const Component = `h${level}`;
52
58
  return /* @__PURE__ */ jsx(Component, { dangerouslySetInnerHTML: { __html: t(props.data.text) } });
53
59
  };
60
+ RichText.QuoteBlock = (props) => {
61
+ if (!props.data?.text) {
62
+ return null;
63
+ }
64
+ const t = useTranslations();
65
+ return /* @__PURE__ */ jsx("blockquote", { dangerouslySetInnerHTML: { __html: t(props.data.text) } });
66
+ };
54
67
  RichText.ListBlock = (props) => {
55
68
  if (!props.data?.items?.length) {
56
69
  return null;
@@ -100,6 +113,24 @@ RichText.HtmlBlock = (props) => {
100
113
  }
101
114
  return /* @__PURE__ */ jsx("div", { dangerouslySetInnerHTML: { __html: html } });
102
115
  };
116
+ RichText.TableBlock = (props) => {
117
+ const rows = props.data?.rows || [];
118
+ const richTextContext = useRichTextContext();
119
+ if (rows.length === 0) {
120
+ return null;
121
+ }
122
+ return /* @__PURE__ */ jsx("table", { children: /* @__PURE__ */ jsx("tbody", { children: rows.map((row, rowIndex) => /* @__PURE__ */ jsx("tr", { children: row.cells.map((cell, cellIndex) => {
123
+ const isHeader = cell.type === "header";
124
+ const Cell = isHeader ? "th" : "td";
125
+ return /* @__PURE__ */ jsx(Cell, { children: /* @__PURE__ */ jsx(
126
+ RichText,
127
+ {
128
+ data: { blocks: cell.blocks, time: 0, version: "" },
129
+ components: richTextContext.components
130
+ }
131
+ ) }, cellIndex);
132
+ }) }, rowIndex)) }) });
133
+ };
103
134
  function toNumber(input) {
104
135
  if (input === void 0) {
105
136
  return 0;
@@ -24,6 +24,11 @@ type StringField = CommonFieldProps & {
24
24
  variant?: 'input' | 'textarea';
25
25
  /** For textarea variant, the maximum number of rows of text to show. */
26
26
  maxRows?: number;
27
+ /**
28
+ * For textarea variant, set to `true` to allow the textarea to automatically
29
+ * resize its height based on its content.
30
+ */
31
+ autosize?: boolean;
27
32
  };
28
33
  declare function string(field: Omit<StringField, 'type'>): StringField;
29
34
  type NumberField = CommonFieldProps & {
@@ -230,6 +235,10 @@ type Collection = SchemaWithTypes & {
230
235
  * `<id>.schema.ts`.
231
236
  */
232
237
  id: string;
238
+ /**
239
+ * Group name for organizing collections together into a hierarchy.
240
+ */
241
+ group?: string;
233
242
  /**
234
243
  * Domain where the collection serves from. Used for multi-domain sites,
235
244
  * defaults to the "domain" value `from root.config.ts`.