@starlightcms/react-sdk 1.1.0 → 2.0.0

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.
Files changed (121) hide show
  1. package/dist/cjs/VisualContent/blocks/{HTML.d.ts → HTML/index.d.ts} +2 -2
  2. package/dist/cjs/VisualContent/blocks/HTML/index.d.ts.map +1 -0
  3. package/dist/cjs/VisualContent/blocks/{HTML.js → HTML/index.js} +5 -2
  4. package/dist/cjs/VisualContent/blocks/HTML/index.js.map +1 -0
  5. package/dist/cjs/VisualContent/blocks/HTML/styles.d.ts +6 -0
  6. package/dist/cjs/VisualContent/blocks/HTML/styles.d.ts.map +1 -0
  7. package/dist/cjs/VisualContent/blocks/HTML/styles.js +13 -0
  8. package/dist/cjs/VisualContent/blocks/HTML/styles.js.map +1 -0
  9. package/dist/cjs/VisualContent/blocks/Header.d.ts.map +1 -1
  10. package/dist/cjs/VisualContent/blocks/Header.js +3 -1
  11. package/dist/cjs/VisualContent/blocks/Header.js.map +1 -1
  12. package/dist/{esm/VisualContent/blocks/Image.d.ts → cjs/VisualContent/blocks/Image/index.d.ts} +2 -2
  13. package/dist/cjs/VisualContent/blocks/Image/index.d.ts.map +1 -0
  14. package/dist/cjs/VisualContent/blocks/{Image.js → Image/index.js} +14 -11
  15. package/dist/cjs/VisualContent/blocks/Image/index.js.map +1 -0
  16. package/dist/cjs/VisualContent/blocks/Image/styles.d.ts +18 -0
  17. package/dist/cjs/VisualContent/blocks/Image/styles.d.ts.map +1 -0
  18. package/dist/cjs/VisualContent/blocks/Image/styles.js +31 -0
  19. package/dist/cjs/VisualContent/blocks/Image/styles.js.map +1 -0
  20. package/dist/{esm/VisualContent/blocks/List.d.ts → cjs/VisualContent/blocks/List/index.d.ts} +2 -2
  21. package/dist/cjs/VisualContent/blocks/List/index.d.ts.map +1 -0
  22. package/dist/cjs/VisualContent/blocks/{List.js → List/index.js} +6 -3
  23. package/dist/cjs/VisualContent/blocks/List/index.js.map +1 -0
  24. package/dist/cjs/VisualContent/blocks/List/styles.d.ts +6 -0
  25. package/dist/cjs/VisualContent/blocks/List/styles.d.ts.map +1 -0
  26. package/dist/cjs/VisualContent/blocks/List/styles.js +21 -0
  27. package/dist/cjs/VisualContent/blocks/List/styles.js.map +1 -0
  28. package/dist/cjs/VisualContent/blocks/Paragraph.d.ts +1 -1
  29. package/dist/cjs/VisualContent/blocks/Paragraph.d.ts.map +1 -1
  30. package/dist/cjs/VisualContent/blocks/Paragraph.js +6 -3
  31. package/dist/cjs/VisualContent/blocks/Paragraph.js.map +1 -1
  32. package/dist/cjs/VisualContent/blocks/Quote.d.ts +1 -1
  33. package/dist/cjs/VisualContent/blocks/Quote.d.ts.map +1 -1
  34. package/dist/cjs/VisualContent/blocks/Quote.js +3 -1
  35. package/dist/cjs/VisualContent/blocks/Quote.js.map +1 -1
  36. package/dist/cjs/VisualContent/blocks/Video/index.d.ts +16 -0
  37. package/dist/cjs/VisualContent/blocks/Video/index.d.ts.map +1 -0
  38. package/dist/cjs/VisualContent/blocks/Video/index.js +29 -0
  39. package/dist/cjs/VisualContent/blocks/Video/index.js.map +1 -0
  40. package/dist/cjs/VisualContent/blocks/Video/styles.d.ts +14 -0
  41. package/dist/cjs/VisualContent/blocks/Video/styles.d.ts.map +1 -0
  42. package/dist/cjs/VisualContent/blocks/Video/styles.js +41 -0
  43. package/dist/cjs/VisualContent/blocks/Video/styles.js.map +1 -0
  44. package/dist/cjs/VisualContent/index.d.ts +3 -3
  45. package/dist/cjs/VisualContent/index.d.ts.map +1 -1
  46. package/dist/cjs/VisualContent/index.js +9 -7
  47. package/dist/cjs/VisualContent/index.js.map +1 -1
  48. package/dist/cjs/VisualContent/styles.d.ts +12 -12
  49. package/dist/cjs/VisualContent/styles.d.ts.map +1 -1
  50. package/dist/cjs/VisualContent/styles.js +81 -42
  51. package/dist/cjs/VisualContent/styles.js.map +1 -1
  52. package/dist/cjs/VisualContent/types.d.ts +2 -1
  53. package/dist/cjs/VisualContent/types.d.ts.map +1 -1
  54. package/dist/cjs/VisualContent/types.js.map +1 -1
  55. package/dist/esm/VisualContent/blocks/{HTML.d.ts → HTML/index.d.ts} +2 -2
  56. package/dist/esm/VisualContent/blocks/HTML/index.d.ts.map +1 -0
  57. package/dist/esm/VisualContent/blocks/{HTML.js → HTML/index.js} +5 -2
  58. package/dist/esm/VisualContent/blocks/HTML/index.js.map +1 -0
  59. package/dist/esm/VisualContent/blocks/HTML/styles.d.ts +6 -0
  60. package/dist/esm/VisualContent/blocks/HTML/styles.d.ts.map +1 -0
  61. package/dist/esm/VisualContent/blocks/HTML/styles.js +7 -0
  62. package/dist/esm/VisualContent/blocks/HTML/styles.js.map +1 -0
  63. package/dist/esm/VisualContent/blocks/Header.d.ts.map +1 -1
  64. package/dist/esm/VisualContent/blocks/Header.js +3 -1
  65. package/dist/esm/VisualContent/blocks/Header.js.map +1 -1
  66. package/dist/{cjs/VisualContent/blocks/Image.d.ts → esm/VisualContent/blocks/Image/index.d.ts} +2 -2
  67. package/dist/esm/VisualContent/blocks/Image/index.d.ts.map +1 -0
  68. package/dist/esm/VisualContent/blocks/{Image.js → Image/index.js} +14 -11
  69. package/dist/esm/VisualContent/blocks/Image/index.js.map +1 -0
  70. package/dist/esm/VisualContent/blocks/Image/styles.d.ts +18 -0
  71. package/dist/esm/VisualContent/blocks/Image/styles.d.ts.map +1 -0
  72. package/dist/esm/VisualContent/blocks/Image/styles.js +25 -0
  73. package/dist/esm/VisualContent/blocks/Image/styles.js.map +1 -0
  74. package/dist/{cjs/VisualContent/blocks/List.d.ts → esm/VisualContent/blocks/List/index.d.ts} +2 -2
  75. package/dist/esm/VisualContent/blocks/List/index.d.ts.map +1 -0
  76. package/dist/esm/VisualContent/blocks/{List.js → List/index.js} +6 -3
  77. package/dist/esm/VisualContent/blocks/List/index.js.map +1 -0
  78. package/dist/esm/VisualContent/blocks/List/styles.d.ts +6 -0
  79. package/dist/esm/VisualContent/blocks/List/styles.d.ts.map +1 -0
  80. package/dist/esm/VisualContent/blocks/List/styles.js +15 -0
  81. package/dist/esm/VisualContent/blocks/List/styles.js.map +1 -0
  82. package/dist/esm/VisualContent/blocks/Paragraph.d.ts +1 -1
  83. package/dist/esm/VisualContent/blocks/Paragraph.d.ts.map +1 -1
  84. package/dist/esm/VisualContent/blocks/Paragraph.js +6 -3
  85. package/dist/esm/VisualContent/blocks/Paragraph.js.map +1 -1
  86. package/dist/esm/VisualContent/blocks/Quote.d.ts +1 -1
  87. package/dist/esm/VisualContent/blocks/Quote.d.ts.map +1 -1
  88. package/dist/esm/VisualContent/blocks/Quote.js +3 -1
  89. package/dist/esm/VisualContent/blocks/Quote.js.map +1 -1
  90. package/dist/esm/VisualContent/blocks/Video/index.d.ts +16 -0
  91. package/dist/esm/VisualContent/blocks/Video/index.d.ts.map +1 -0
  92. package/dist/esm/VisualContent/blocks/Video/index.js +24 -0
  93. package/dist/esm/VisualContent/blocks/Video/index.js.map +1 -0
  94. package/dist/esm/VisualContent/blocks/Video/styles.d.ts +14 -0
  95. package/dist/esm/VisualContent/blocks/Video/styles.d.ts.map +1 -0
  96. package/dist/esm/VisualContent/blocks/Video/styles.js +35 -0
  97. package/dist/esm/VisualContent/blocks/Video/styles.js.map +1 -0
  98. package/dist/esm/VisualContent/index.d.ts +3 -3
  99. package/dist/esm/VisualContent/index.d.ts.map +1 -1
  100. package/dist/esm/VisualContent/index.js +7 -5
  101. package/dist/esm/VisualContent/index.js.map +1 -1
  102. package/dist/esm/VisualContent/styles.d.ts +12 -12
  103. package/dist/esm/VisualContent/styles.d.ts.map +1 -1
  104. package/dist/esm/VisualContent/styles.js +80 -40
  105. package/dist/esm/VisualContent/styles.js.map +1 -1
  106. package/dist/esm/VisualContent/types.d.ts +2 -1
  107. package/dist/esm/VisualContent/types.d.ts.map +1 -1
  108. package/dist/esm/VisualContent/types.js.map +1 -1
  109. package/package.json +4 -2
  110. package/dist/cjs/VisualContent/blocks/HTML.d.ts.map +0 -1
  111. package/dist/cjs/VisualContent/blocks/HTML.js.map +0 -1
  112. package/dist/cjs/VisualContent/blocks/Image.d.ts.map +0 -1
  113. package/dist/cjs/VisualContent/blocks/Image.js.map +0 -1
  114. package/dist/cjs/VisualContent/blocks/List.d.ts.map +0 -1
  115. package/dist/cjs/VisualContent/blocks/List.js.map +0 -1
  116. package/dist/esm/VisualContent/blocks/HTML.d.ts.map +0 -1
  117. package/dist/esm/VisualContent/blocks/HTML.js.map +0 -1
  118. package/dist/esm/VisualContent/blocks/Image.d.ts.map +0 -1
  119. package/dist/esm/VisualContent/blocks/Image.js.map +0 -1
  120. package/dist/esm/VisualContent/blocks/List.d.ts.map +0 -1
  121. package/dist/esm/VisualContent/blocks/List.js.map +0 -1
@@ -1,5 +1,5 @@
1
- import { FC } from 'react';
2
1
  import { ParagraphBlock, VisualDataBlock } from '@starlightcms/js-sdk';
2
+ import { FC } from 'react';
3
3
  /**
4
4
  * VisualContent renderer component that renders `paragraph` type blocks
5
5
  * as `<p>` elements. Empty paragraph blocks (generally used to break
@@ -1 +1 @@
1
- {"version":3,"file":"Paragraph.d.ts","sourceRoot":"","sources":["../../../../src/VisualContent/blocks/Paragraph.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAE,EAAE,EAAE,MAAM,OAAO,CAAA;AACjC,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAEtE;;;;;;;;;;;GAWG;AACH,QAAA,MAAM,SAAS,EAAE,EAAE,CAAC,eAAe,CAAC,cAAc,CAAC,CAclD,CAAA;AAED,eAAe,SAAS,CAAA"}
1
+ {"version":3,"file":"Paragraph.d.ts","sourceRoot":"","sources":["../../../../src/VisualContent/blocks/Paragraph.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAEtE,OAAc,EAAE,EAAE,EAAE,MAAM,OAAO,CAAA;AAEjC;;;;;;;;;;;GAWG;AACH,QAAA,MAAM,SAAS,EAAE,EAAE,CAAC,eAAe,CAAC,cAAc,CAAC,CAelD,CAAA;AAED,eAAe,SAAS,CAAA"}
@@ -1,3 +1,4 @@
1
+ import { BlockWrapper } from '../styles';
1
2
  import React from 'react';
2
3
  /**
3
4
  * VisualContent renderer component that renders `paragraph` type blocks
@@ -13,9 +14,11 @@ import React from 'react';
13
14
  */
14
15
  const Paragraph = ({ data }) => {
15
16
  if (!data.text)
16
- return (React.createElement("p", { className: "sl-content-block sl-paragraph empty", "aria-hidden": true },
17
- React.createElement("br", null)));
18
- return (React.createElement("p", { className: "sl-content-block sl-paragraph", dangerouslySetInnerHTML: { __html: data.text } }));
17
+ return (React.createElement(BlockWrapper, { className: "sl-content-block sl-paragraph empty", "aria-hidden": true },
18
+ React.createElement("p", null,
19
+ React.createElement("br", null))));
20
+ return (React.createElement(BlockWrapper, { className: "sl-content-block sl-paragraph" },
21
+ React.createElement("p", { dangerouslySetInnerHTML: { __html: data.text } })));
19
22
  };
20
23
  export default Paragraph;
21
24
  //# sourceMappingURL=Paragraph.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Paragraph.js","sourceRoot":"","sources":["../../../../src/VisualContent/blocks/Paragraph.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAa,MAAM,OAAO,CAAA;AAGjC;;;;;;;;;;;GAWG;AACH,MAAM,SAAS,GAAwC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE;IAClE,IAAI,CAAC,IAAI,CAAC,IAAI;QACZ,OAAO,CACL,2BAAG,SAAS,EAAC,qCAAqC;YAChD,+BAAM,CACJ,CACL,CAAA;IAEH,OAAO,CACL,2BACE,SAAS,EAAC,+BAA+B,EACzC,uBAAuB,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,IAAI,EAAE,GAC9C,CACH,CAAA;AACH,CAAC,CAAA;AAED,eAAe,SAAS,CAAA","sourcesContent":["import React, { FC } from 'react'\nimport { ParagraphBlock, VisualDataBlock } from '@starlightcms/js-sdk'\n\n/**\n * VisualContent renderer component that renders `paragraph` type blocks\n * as `<p>` elements. Empty paragraph blocks (generally used to break\n * lines) will have an `empty` class added to them.\n *\n * See {@doclink components/VisualContent/#customizing-components | the guide page on the VisualContent component}\n * to learn how to customize block renderer components like this one.\n *\n * @param props VisualDataBlock object. See {@link ParagraphBlock} to learn the\n * type of data this component receives.\n * @group VisualContent Renderers\n */\nconst Paragraph: FC<VisualDataBlock<ParagraphBlock>> = ({ data }) => {\n if (!data.text)\n return (\n <p className=\"sl-content-block sl-paragraph empty\" aria-hidden>\n <br />\n </p>\n )\n\n return (\n <p\n className=\"sl-content-block sl-paragraph\"\n dangerouslySetInnerHTML={{ __html: data.text }}\n />\n )\n}\n\nexport default Paragraph\n"]}
1
+ {"version":3,"file":"Paragraph.js","sourceRoot":"","sources":["../../../../src/VisualContent/blocks/Paragraph.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AACxC,OAAO,KAAa,MAAM,OAAO,CAAA;AAEjC;;;;;;;;;;;GAWG;AACH,MAAM,SAAS,GAAwC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE;IAClE,IAAI,CAAC,IAAI,CAAC,IAAI;QACZ,OAAO,CACL,oBAAC,YAAY,IAAC,SAAS,EAAC,qCAAqC;YAC3D;gBACE,+BAAM,CACJ,CACS,CAChB,CAAA;IAEH,OAAO,CACL,oBAAC,YAAY,IAAC,SAAS,EAAC,+BAA+B;QACrD,2BAAG,uBAAuB,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,IAAI,EAAE,GAAI,CACxC,CAChB,CAAA;AACH,CAAC,CAAA;AAED,eAAe,SAAS,CAAA","sourcesContent":["import { ParagraphBlock, VisualDataBlock } from '@starlightcms/js-sdk'\nimport { BlockWrapper } from '../styles'\nimport React, { FC } from 'react'\n\n/**\n * VisualContent renderer component that renders `paragraph` type blocks\n * as `<p>` elements. Empty paragraph blocks (generally used to break\n * lines) will have an `empty` class added to them.\n *\n * See {@doclink components/VisualContent/#customizing-components | the guide page on the VisualContent component}\n * to learn how to customize block renderer components like this one.\n *\n * @param props VisualDataBlock object. See {@link ParagraphBlock} to learn the\n * type of data this component receives.\n * @group VisualContent Renderers\n */\nconst Paragraph: FC<VisualDataBlock<ParagraphBlock>> = ({ data }) => {\n if (!data.text)\n return (\n <BlockWrapper className=\"sl-content-block sl-paragraph empty\" aria-hidden>\n <p>\n <br />\n </p>\n </BlockWrapper>\n )\n\n return (\n <BlockWrapper className=\"sl-content-block sl-paragraph\">\n <p dangerouslySetInnerHTML={{ __html: data.text }} />\n </BlockWrapper>\n )\n}\n\nexport default Paragraph\n"]}
@@ -1,5 +1,5 @@
1
- import { FC } from 'react';
2
1
  import { QuoteBlock, VisualDataBlock } from '@starlightcms/js-sdk';
2
+ import { FC } from 'react';
3
3
  /**
4
4
  * VisualContent renderer component that renders `quote` type blocks
5
5
  * as `<blockquote>` elements.
@@ -1 +1 @@
1
- {"version":3,"file":"Quote.d.ts","sourceRoot":"","sources":["../../../../src/VisualContent/blocks/Quote.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAE,EAAE,EAAE,MAAM,OAAO,CAAA;AACjC,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAElE;;;;;;;;;;GAUG;AACH,QAAA,MAAM,KAAK,EAAE,EAAE,CAAC,eAAe,CAAC,UAAU,CAAC,CAI1C,CAAA;AAED,eAAe,KAAK,CAAA"}
1
+ {"version":3,"file":"Quote.d.ts","sourceRoot":"","sources":["../../../../src/VisualContent/blocks/Quote.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAElE,OAAc,EAAE,EAAE,EAAE,MAAM,OAAO,CAAA;AAEjC;;;;;;;;;;GAUG;AACH,QAAA,MAAM,KAAK,EAAE,EAAE,CAAC,eAAe,CAAC,UAAU,CAAC,CAM1C,CAAA;AAED,eAAe,KAAK,CAAA"}
@@ -1,3 +1,4 @@
1
+ import { BlockWrapper } from '../styles';
1
2
  import React from 'react';
2
3
  /**
3
4
  * VisualContent renderer component that renders `quote` type blocks
@@ -11,7 +12,8 @@ import React from 'react';
11
12
  * @group VisualContent Renderers
12
13
  */
13
14
  const Quote = ({ data }) => {
14
- return (React.createElement("blockquote", { className: "sl-content-block sl-quote" }, data.text));
15
+ return (React.createElement(BlockWrapper, { className: "sl-content-block sl-quote" },
16
+ React.createElement("blockquote", null, data.text)));
15
17
  };
16
18
  export default Quote;
17
19
  //# sourceMappingURL=Quote.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Quote.js","sourceRoot":"","sources":["../../../../src/VisualContent/blocks/Quote.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAa,MAAM,OAAO,CAAA;AAGjC;;;;;;;;;;GAUG;AACH,MAAM,KAAK,GAAoC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE;IAC1D,OAAO,CACL,oCAAY,SAAS,EAAC,2BAA2B,IAAE,IAAI,CAAC,IAAI,CAAc,CAC3E,CAAA;AACH,CAAC,CAAA;AAED,eAAe,KAAK,CAAA","sourcesContent":["import React, { FC } from 'react'\nimport { QuoteBlock, VisualDataBlock } from '@starlightcms/js-sdk'\n\n/**\n * VisualContent renderer component that renders `quote` type blocks\n * as `<blockquote>` elements.\n *\n * See {@doclink components/VisualContent/#customizing-components | the guide page on the VisualContent component}\n * to learn how to customize block renderer components like this one.\n *\n * @param props VisualDataBlock object. See {@link QuoteBlock} to learn the\n * type of data this component receives.\n * @group VisualContent Renderers\n */\nconst Quote: FC<VisualDataBlock<QuoteBlock>> = ({ data }) => {\n return (\n <blockquote className=\"sl-content-block sl-quote\">{data.text}</blockquote>\n )\n}\n\nexport default Quote\n"]}
1
+ {"version":3,"file":"Quote.js","sourceRoot":"","sources":["../../../../src/VisualContent/blocks/Quote.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AACxC,OAAO,KAAa,MAAM,OAAO,CAAA;AAEjC;;;;;;;;;;GAUG;AACH,MAAM,KAAK,GAAoC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE;IAC1D,OAAO,CACL,oBAAC,YAAY,IAAC,SAAS,EAAC,2BAA2B;QACjD,wCAAa,IAAI,CAAC,IAAI,CAAc,CACvB,CAChB,CAAA;AACH,CAAC,CAAA;AAED,eAAe,KAAK,CAAA","sourcesContent":["import { QuoteBlock, VisualDataBlock } from '@starlightcms/js-sdk'\nimport { BlockWrapper } from '../styles'\nimport React, { FC } from 'react'\n\n/**\n * VisualContent renderer component that renders `quote` type blocks\n * as `<blockquote>` elements.\n *\n * See {@doclink components/VisualContent/#customizing-components | the guide page on the VisualContent component}\n * to learn how to customize block renderer components like this one.\n *\n * @param props VisualDataBlock object. See {@link QuoteBlock} to learn the\n * type of data this component receives.\n * @group VisualContent Renderers\n */\nconst Quote: FC<VisualDataBlock<QuoteBlock>> = ({ data }) => {\n return (\n <BlockWrapper className=\"sl-content-block sl-quote\">\n <blockquote>{data.text}</blockquote>\n </BlockWrapper>\n )\n}\n\nexport default Quote\n"]}
@@ -0,0 +1,16 @@
1
+ import { VideoBlock, VisualDataBlock } from '@starlightcms/js-sdk';
2
+ import { FC } from 'react';
3
+ /**
4
+ * VisualContent renderer component that renders `video` type blocks
5
+ * as a responsive video along with its caption (if defined).
6
+ *
7
+ * See {@doclink components/VisualContent/#customizing-components | the guide page on the VisualContent component}
8
+ * to learn how to customize block renderer components like this one.
9
+ *
10
+ * @param props VisualDataBlock object. See {@link VideoBlock} to learn the
11
+ * type of data this component receives.
12
+ * @group VisualContent Renderers
13
+ */
14
+ declare const Video: FC<VisualDataBlock<VideoBlock>>;
15
+ export default Video;
16
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/VisualContent/blocks/Video/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAGlE,OAAc,EAAE,EAAE,EAAE,MAAM,OAAO,CAAA;AAEjC;;;;;;;;;;GAUG;AACH,QAAA,MAAM,KAAK,EAAE,EAAE,CAAC,eAAe,CAAC,UAAU,CAAC,CAgB1C,CAAA;AAED,eAAe,KAAK,CAAA"}
@@ -0,0 +1,24 @@
1
+ import { BlockWrapper } from '../../styles';
2
+ import { VideoWrapper } from './styles';
3
+ import React from 'react';
4
+ /**
5
+ * VisualContent renderer component that renders `video` type blocks
6
+ * as a responsive video along with its caption (if defined).
7
+ *
8
+ * See {@doclink components/VisualContent/#customizing-components | the guide page on the VisualContent component}
9
+ * to learn how to customize block renderer components like this one.
10
+ *
11
+ * @param props VisualDataBlock object. See {@link VideoBlock} to learn the
12
+ * type of data this component receives.
13
+ * @group VisualContent Renderers
14
+ */
15
+ const Video = ({ data }) => {
16
+ const { html, width, caption } = data;
17
+ const widthType = ['auto', 'justify', 'max'].includes(width) ? width : 'fixed';
18
+ return (React.createElement(BlockWrapper, { className: `sl-content-block sl-video sl-width-${widthType}` },
19
+ React.createElement(VideoWrapper, { width: width },
20
+ React.createElement("div", { dangerouslySetInnerHTML: { __html: html } }),
21
+ caption && (React.createElement("figcaption", { dangerouslySetInnerHTML: { __html: caption } })))));
22
+ };
23
+ export default Video;
24
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/VisualContent/blocks/Video/index.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AACvC,OAAO,KAAa,MAAM,OAAO,CAAA;AAEjC;;;;;;;;;;GAUG;AACH,MAAM,KAAK,GAAoC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE;IAC1D,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,IAAI,CAAA;IAErC,MAAM,SAAS,GAAG,CAAC,MAAM,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAA;IAE9E,OAAO,CACL,oBAAC,YAAY,IAAC,SAAS,EAAE,sCAAsC,SAAS,EAAE;QACxE,oBAAC,YAAY,IAAC,KAAK,EAAE,KAAK;YACxB,6BAAK,uBAAuB,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,GAAI;YAEjD,OAAO,IAAI,CACV,oCAAY,uBAAuB,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,GAAI,CAC7D,CACY,CACF,CAChB,CAAA;AACH,CAAC,CAAA;AAED,eAAe,KAAK,CAAA","sourcesContent":["import { VideoBlock, VisualDataBlock } from '@starlightcms/js-sdk'\nimport { BlockWrapper } from '../../styles'\nimport { VideoWrapper } from './styles'\nimport React, { FC } from 'react'\n\n/**\n * VisualContent renderer component that renders `video` type blocks\n * as a responsive video along with its caption (if defined).\n *\n * See {@doclink components/VisualContent/#customizing-components | the guide page on the VisualContent component}\n * to learn how to customize block renderer components like this one.\n *\n * @param props VisualDataBlock object. See {@link VideoBlock} to learn the\n * type of data this component receives.\n * @group VisualContent Renderers\n */\nconst Video: FC<VisualDataBlock<VideoBlock>> = ({ data }) => {\n const { html, width, caption } = data\n\n const widthType = ['auto', 'justify', 'max'].includes(width) ? width : 'fixed'\n\n return (\n <BlockWrapper className={`sl-content-block sl-video sl-width-${widthType}`}>\n <VideoWrapper width={width}>\n <div dangerouslySetInnerHTML={{ __html: html }} />\n\n {caption && (\n <figcaption dangerouslySetInnerHTML={{ __html: caption }} />\n )}\n </VideoWrapper>\n </BlockWrapper>\n )\n}\n\nexport default Video\n"]}
@@ -0,0 +1,14 @@
1
+ /// <reference types="react" />
2
+ declare type VideoWrapperProps = {
3
+ width: string | null;
4
+ };
5
+ export declare const VideoWrapper: import("@emotion/styled").StyledComponent<{
6
+ theme?: import("@emotion/react").Theme | undefined;
7
+ as?: import("react").ElementType<any> | undefined;
8
+ } & import("react").ClassAttributes<HTMLElement> & import("react").HTMLAttributes<HTMLElement> & {
9
+ children?: import("react").ReactNode;
10
+ } & {
11
+ theme?: import("@emotion/react").Theme | undefined;
12
+ } & VideoWrapperProps, {}, {}>;
13
+ export {};
14
+ //# sourceMappingURL=styles.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../../../src/VisualContent/blocks/Video/styles.ts"],"names":[],"mappings":";AAGA,aAAK,iBAAiB,GAAG;IACvB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;CACrB,CAAA;AAED,eAAO,MAAM,YAAY;;;;;;;8BA+BxB,CAAA"}
@@ -0,0 +1,35 @@
1
+ import { FigureWrapper } from '../../styles';
2
+ import styled from '@emotion/styled';
3
+ export const VideoWrapper = styled(FigureWrapper) `
4
+ margin: 0;
5
+
6
+ > div {
7
+ > * {
8
+ max-width: 100%;
9
+ }
10
+
11
+ > iframe {
12
+ display: block;
13
+ margin: auto;
14
+
15
+ aspect-ratio: 16/9;
16
+
17
+ border: none;
18
+
19
+ background-color: transparent;
20
+
21
+ width: ${({ width }) => {
22
+ switch (width) {
23
+ case 'auto':
24
+ return 'initial';
25
+ case 'justify':
26
+ case 'max':
27
+ return '100%';
28
+ default:
29
+ return width;
30
+ }
31
+ }};
32
+ }
33
+ }
34
+ `;
35
+ //# sourceMappingURL=styles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"styles.js","sourceRoot":"","sources":["../../../../../src/VisualContent/blocks/Video/styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAC5C,OAAO,MAAM,MAAM,iBAAiB,CAAA;AAMpC,MAAM,CAAC,MAAM,YAAY,GAAG,MAAM,CAAC,aAAa,CAAC,CAAmB;;;;;;;;;;;;;;;;;;eAkBrD,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE;IACrB,QAAQ,KAAK,EAAE;QACb,KAAK,MAAM;YACT,OAAO,SAAS,CAAA;QAClB,KAAK,SAAS,CAAC;QACf,KAAK,KAAK;YACR,OAAO,MAAM,CAAA;QACf;YACE,OAAO,KAAK,CAAA;KACf;AACH,CAAC;;;CAGN,CAAA","sourcesContent":["import { FigureWrapper } from '../../styles'\nimport styled from '@emotion/styled'\n\ntype VideoWrapperProps = {\n width: string | null\n}\n\nexport const VideoWrapper = styled(FigureWrapper)<VideoWrapperProps>`\n margin: 0;\n\n > div {\n > * {\n max-width: 100%;\n }\n\n > iframe {\n display: block;\n margin: auto;\n\n aspect-ratio: 16/9;\n\n border: none;\n\n background-color: transparent;\n\n width: ${({ width }) => {\n switch (width) {\n case 'auto':\n return 'initial'\n case 'justify':\n case 'max':\n return '100%'\n default:\n return width\n }\n }};\n }\n }\n`\n"]}
@@ -1,12 +1,12 @@
1
1
  /// <reference types="react" />
2
2
  import { VisualContentProps } from './types';
3
- import { VisualContentStyles } from './styles';
3
+ import Image, { ImageOptions } from './blocks/Image';
4
4
  import Paragraph from './blocks/Paragraph';
5
5
  import Header from './blocks/Header';
6
6
  import Quote from './blocks/Quote';
7
- import Image, { ImageOptions } from './blocks/Image';
8
7
  import HTML from './blocks/HTML';
9
8
  import List from './blocks/List';
9
+ import Video from './blocks/Video';
10
10
  /**
11
11
  * Renders HTML content from data returned by a Visual Editor field on Starlight.
12
12
  *
@@ -59,6 +59,6 @@ import List from './blocks/List';
59
59
  * @group VisualContent
60
60
  */
61
61
  export declare const VisualContent: ({ content, components, excerpt, excerptLength, }: VisualContentProps) => JSX.Element;
62
- export { VisualContentStyles, Paragraph as ParagraphComponent, Header as HeaderComponent, Quote as QuoteComponent, Image as ImageComponent, HTML as HTMLComponent, List as ListComponent, };
62
+ export { Paragraph as ParagraphComponent, Header as HeaderComponent, Quote as QuoteComponent, Image as ImageComponent, HTML as HTMLComponent, List as ListComponent, Video as VideoComponent, };
63
63
  export type { VisualContentProps, ImageOptions };
64
64
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/VisualContent/index.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAmB,kBAAkB,EAAE,MAAM,SAAS,CAAA;AAC7D,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAA;AAC9C,OAAO,SAAS,MAAM,oBAAoB,CAAA;AAC1C,OAAO,MAAM,MAAM,iBAAiB,CAAA;AACpC,OAAO,KAAK,MAAM,gBAAgB,CAAA;AAClC,OAAO,KAAK,EAAE,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AACpD,OAAO,IAAI,MAAM,eAAe,CAAA;AAChC,OAAO,IAAI,MAAM,eAAe,CAAA;AAWhC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDG;AACH,eAAO,MAAM,aAAa,qDAKvB,kBAAkB,KAAG,WAmDvB,CAAA;AAED,OAAO,EACL,mBAAmB,EACnB,SAAS,IAAI,kBAAkB,EAC/B,MAAM,IAAI,eAAe,EACzB,KAAK,IAAI,cAAc,EACvB,KAAK,IAAI,cAAc,EACvB,IAAI,IAAI,aAAa,EACrB,IAAI,IAAI,aAAa,GACtB,CAAA;AAED,YAAY,EAAE,kBAAkB,EAAE,YAAY,EAAE,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/VisualContent/index.tsx"],"names":[],"mappings":";AACA,OAAO,EAAmB,kBAAkB,EAAE,MAAM,SAAS,CAAA;AAC7D,OAAO,KAAK,EAAE,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AACpD,OAAO,SAAS,MAAM,oBAAoB,CAAA;AAG1C,OAAO,MAAM,MAAM,iBAAiB,CAAA;AACpC,OAAO,KAAK,MAAM,gBAAgB,CAAA;AAClC,OAAO,IAAI,MAAM,eAAe,CAAA;AAChC,OAAO,IAAI,MAAM,eAAe,CAAA;AAChC,OAAO,KAAK,MAAM,gBAAgB,CAAA;AAYlC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDG;AACH,eAAO,MAAM,aAAa,qDAKvB,kBAAkB,KAAG,WAmDvB,CAAA;AAED,OAAO,EACL,SAAS,IAAI,kBAAkB,EAC/B,MAAM,IAAI,eAAe,EACzB,KAAK,IAAI,cAAc,EACvB,KAAK,IAAI,cAAc,EACvB,IAAI,IAAI,aAAa,EACrB,IAAI,IAAI,aAAa,EACrB,KAAK,IAAI,cAAc,GACxB,CAAA;AAED,YAAY,EAAE,kBAAkB,EAAE,YAAY,EAAE,CAAA"}
@@ -1,11 +1,12 @@
1
- import React, { useMemo } from 'react';
2
- import { VisualContentStyles } from './styles';
1
+ import Image from './blocks/Image';
3
2
  import Paragraph from './blocks/Paragraph';
3
+ import { OuterWrapper } from './styles';
4
+ import React, { useMemo } from 'react';
4
5
  import Header from './blocks/Header';
5
6
  import Quote from './blocks/Quote';
6
- import Image from './blocks/Image';
7
7
  import HTML from './blocks/HTML';
8
8
  import List from './blocks/List';
9
+ import Video from './blocks/Video';
9
10
  const defaultComponents = {
10
11
  paragraph: Paragraph,
11
12
  header: Header,
@@ -13,6 +14,7 @@ const defaultComponents = {
13
14
  image: Image,
14
15
  raw: HTML,
15
16
  list: List,
17
+ video: Video,
16
18
  };
17
19
  /**
18
20
  * Renders HTML content from data returned by a Visual Editor field on Starlight.
@@ -81,12 +83,12 @@ export const VisualContent = ({ content, components = {}, excerpt = false, excer
81
83
  const Component = componentList.paragraph;
82
84
  return (React.createElement(Component, { key: block.id, id: block.id, type: block.type, data: { text: excerptText } }));
83
85
  }
84
- return (React.createElement("div", { className: "sl-visual-content" }, content.blocks.map((block) => {
86
+ return (React.createElement(OuterWrapper, { className: "sl-visual-content" }, content.blocks.map((block) => {
85
87
  const Component = componentList[block.type];
86
88
  if (!Component)
87
89
  return null;
88
90
  return (React.createElement(Component, { key: block.id, id: block.id, type: block.type, data: block.data }));
89
91
  })));
90
92
  };
91
- export { VisualContentStyles, Paragraph as ParagraphComponent, Header as HeaderComponent, Quote as QuoteComponent, Image as ImageComponent, HTML as HTMLComponent, List as ListComponent, };
93
+ export { Paragraph as ParagraphComponent, Header as HeaderComponent, Quote as QuoteComponent, Image as ImageComponent, HTML as HTMLComponent, List as ListComponent, Video as VideoComponent, };
92
94
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/VisualContent/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AAGtC,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAA;AAC9C,OAAO,SAAS,MAAM,oBAAoB,CAAA;AAC1C,OAAO,MAAM,MAAM,iBAAiB,CAAA;AACpC,OAAO,KAAK,MAAM,gBAAgB,CAAA;AAClC,OAAO,KAAuB,MAAM,gBAAgB,CAAA;AACpD,OAAO,IAAI,MAAM,eAAe,CAAA;AAChC,OAAO,IAAI,MAAM,eAAe,CAAA;AAEhC,MAAM,iBAAiB,GAAoB;IACzC,SAAS,EAAE,SAAS;IACpB,MAAM,EAAE,MAAM;IACd,KAAK,EAAE,KAAK;IACZ,KAAK,EAAE,KAAK;IACZ,GAAG,EAAE,IAAI;IACT,IAAI,EAAE,IAAI;CACX,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,EAC5B,OAAO,EACP,UAAU,GAAG,EAAE,EACf,OAAO,GAAG,KAAK,EACf,aAAa,GAAG,EAAE,GACC,EAAe,EAAE;IACpC,MAAM,aAAa,GAAG,OAAO,CAC3B,GAAG,EAAE,CAAC,iCAAM,iBAAiB,GAAK,UAAU,EAAG,EAC/C,CAAC,UAAU,CAAC,CACb,CAAA;IAED,IAAI,CAAC,OAAO,E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,KAAK,CAAC,IAAa,GACzB,CACH,CAAA;IACH,CAAC,CAAC,CACE,CACP,CAAA;AACH,CAAC,CAAA;AAED,OAAO,EACL,mBAAmB,EACnB,SAAS,IAAI,kBAAkB,EAC/B,MAAM,IAAI,eAAe,EACzB,KAAK,IAAI,cAAc,EACvB,KAAK,IAAI,cAAc,EACvB,IAAI,IAAI,aAAa,EACrB,IAAI,IAAI,aAAa,GACtB,CAAA","sourcesContent":["import React, { useMemo } from 'react'\nimport { VisualDataBlock, ParagraphBlock } from '@starlightcms/js-sdk'\nimport { BlockComponents, VisualContentProps } from './types'\nimport { VisualContentStyles } from './styles'\nimport Paragraph from './blocks/Paragraph'\nimport Header from './blocks/Header'\nimport Quote from './blocks/Quote'\nimport Image, { ImageOptions } from './blocks/Image'\nimport HTML from './blocks/HTML'\nimport List from './blocks/List'\n\nconst defaultComponents: BlockComponents = {\n paragraph: Paragraph,\n header: Header,\n quote: Quote,\n image: Image,\n raw: HTML,\n list: List,\n}\n\n/**\n * Renders HTML content from data returned by a Visual Editor field on Starlight.\n *\n * The only required prop is `content`, which is the data returned by a Visual\n * Editor field. Additionally, you can provide custom components to render each\n * data block type.\n *\n * You can also pass the `excerpt` boolean prop to only render a portion of the\n * content, which is useful to summarize the content in lists.\n *\n * To learn how to customize the rendered content, take a look at the\n * [Customizing the output](#) guide page.\n *\n * @example Requesting an entry and rendering its content.\n *\n * Assume we created a \"Posts\" model with a slug of `posts`, and placed a Visual\n * Editor field with a key of `post_content` on it.\n *\n * ```jsx\n * import Starlight, { VisualContent } from '@starlightcms/react-sdk'\n *\n * const EntryComponent = ({ slug }) => {\n * const [entry, setEntry] = useState(null)\n *\n * // This is just an example, you could fetch\n * // the entry any way you want.\n * useEffect(async () => {\n * const response = await Starlight.posts.entries.get(slug)\n *\n * setEntry(response.data)\n * }, [ slug ])\n *\n * // After fetching, content will be on the `entry.data.post_content` property.\n * return (\n * entry ? (\n * <article>\n * <h1>{entry.title}</h1>\n * <VisualContent content={entry.data.post_content} />\n * </article>\n * ) : (\n * <div>Loading...</div>\n * )\n * )\n * }\n *\n * ```\n *\n * @param props Component props. See {@link VisualContentProps} to see the\n * available options.\n * @group VisualContent\n */\nexport const VisualContent = ({\n content,\n components = {},\n excerpt = false,\n excerptLength = 40,\n}: VisualContentProps): JSX.Element => {\n const componentList = useMemo(\n () => ({ ...defaultComponents, ...components }),\n [components]\n )\n\n if (!content) {\n return null as unknown as JSX.Element\n }\n\n if (excerpt) {\n const block = content.blocks.find((block) => block.type === 'paragraph') as\n | VisualDataBlock<ParagraphBlock>\n | undefined\n\n if (!block || !block.data.text) return null as unknown as JSX.Element\n\n const text = block.data.text.split(' ')\n const excerptText =\n text.length > excerptLength\n ? text.splice(0, excerptLength).join(' ') + '...'\n : text.join(' ')\n const Component = componentList.paragraph\n\n return (\n <Component\n key={block.id}\n id={block.id}\n type={block.type}\n data={{ text: excerptText }}\n />\n )\n }\n return (\n <div className=\"sl-visual-content\">\n {content.blocks.map((block) => {\n const Component = componentList[block.type]\n\n if (!Component) return null\n\n return (\n <Component\n key={block.id}\n id={block.id}\n type={block.type}\n data={block.data as never}\n />\n )\n })}\n </div>\n )\n}\n\nexport {\n VisualContentStyles,\n Paragraph as ParagraphComponent,\n Header as HeaderComponent,\n Quote as QuoteComponent,\n Image as ImageComponent,\n HTML as HTMLComponent,\n List as ListComponent,\n}\n\nexport type { VisualContentProps, ImageOptions }\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/VisualContent/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAuB,MAAM,gBAAgB,CAAA;AACpD,OAAO,SAAS,MAAM,oBAAoB,CAAA;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AACvC,OAAO,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AACtC,OAAO,MAAM,MAAM,iBAAiB,CAAA;AACpC,OAAO,KAAK,MAAM,gBAAgB,CAAA;AAClC,OAAO,IAA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C,GAAG,CAAC,CAAA;QACpB,MAAM,SAAS,GAAG,aAAa,CAAC,SAAS,CAAA;QAEzC,OAAO,CACL,oBAAC,SAAS,IACR,GAAG,EAAE,KAAK,CAAC,EAAE,EACb,EAAE,EAAE,KAAK,CAAC,EAAE,EACZ,IAAI,EAAE,KAAK,CAAC,IAAI,EAChB,IAAI,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,GAC3B,CACH,CAAA;KACF;IACD,OAAO,CACL,oBAAC,YAAY,IAAC,SAAS,EAAC,mBAAmB,IACxC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;QAC5B,MAAM,SAAS,GAAG,aAAa,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;QAE3C,IAAI,CAAC,SAAS;YAAE,OAAO,IAAI,CAAA;QAE3B,OAAO,CACL,oBAAC,SAAS,IACR,GAAG,EAAE,KAAK,CAAC,EAAE,EACb,EAAE,EAAE,KAAK,CAAC,EAAE,EACZ,IAAI,EAAE,KAAK,CAAC,IAAI,EAChB,IAAI,EAAE,KAAK,CAAC,IAAa,GACzB,CACH,CAAA;IACH,CAAC,CAAC,CACW,CAChB,CAAA;AACH,CAAC,CAAA;AAED,OAAO,EACL,SAAS,IAAI,kBAAkB,EAC/B,MAAM,IAAI,eAAe,EACzB,KAAK,IAAI,cAAc,EACvB,KAAK,IAAI,cAAc,EACvB,IAAI,IAAI,aAAa,EACrB,IAAI,IAAI,aAAa,EACrB,KAAK,IAAI,cAAc,GACxB,CAAA","sourcesContent":["import { VisualDataBlock, ParagraphBlock } from '@starlightcms/js-sdk'\nimport { BlockComponents, VisualContentProps } from './types'\nimport Image, { ImageOptions } from './blocks/Image'\nimport Paragraph from './blocks/Paragraph'\nimport { OuterWrapper } from './styles'\nimport React, { useMemo } from 'react'\nimport Header from './blocks/Header'\nimport Quote from './blocks/Quote'\nimport HTML from './blocks/HTML'\nimport List from './blocks/List'\nimport Video from './blocks/Video'\n\nconst defaultComponents: BlockComponents = {\n paragraph: Paragraph,\n header: Header,\n quote: Quote,\n image: Image,\n raw: HTML,\n list: List,\n video: Video,\n}\n\n/**\n * Renders HTML content from data returned by a Visual Editor field on Starlight.\n *\n * The only required prop is `content`, which is the data returned by a Visual\n * Editor field. Additionally, you can provide custom components to render each\n * data block type.\n *\n * You can also pass the `excerpt` boolean prop to only render a portion of the\n * content, which is useful to summarize the content in lists.\n *\n * To learn how to customize the rendered content, take a look at the\n * [Customizing the output](#) guide page.\n *\n * @example Requesting an entry and rendering its content.\n *\n * Assume we created a \"Posts\" model with a slug of `posts`, and placed a Visual\n * Editor field with a key of `post_content` on it.\n *\n * ```jsx\n * import Starlight, { VisualContent } from '@starlightcms/react-sdk'\n *\n * const EntryComponent = ({ slug }) => {\n * const [entry, setEntry] = useState(null)\n *\n * // This is just an example, you could fetch\n * // the entry any way you want.\n * useEffect(async () => {\n * const response = await Starlight.posts.entries.get(slug)\n *\n * setEntry(response.data)\n * }, [ slug ])\n *\n * // After fetching, content will be on the `entry.data.post_content` property.\n * return (\n * entry ? (\n * <article>\n * <h1>{entry.title}</h1>\n * <VisualContent content={entry.data.post_content} />\n * </article>\n * ) : (\n * <div>Loading...</div>\n * )\n * )\n * }\n *\n * ```\n *\n * @param props Component props. See {@link VisualContentProps} to see the\n * available options.\n * @group VisualContent\n */\nexport const VisualContent = ({\n content,\n components = {},\n excerpt = false,\n excerptLength = 40,\n}: VisualContentProps): JSX.Element => {\n const componentList = useMemo(\n () => ({ ...defaultComponents, ...components }),\n [components]\n )\n\n if (!content) {\n return null as unknown as JSX.Element\n }\n\n if (excerpt) {\n const block = content.blocks.find((block) => block.type === 'paragraph') as\n | VisualDataBlock<ParagraphBlock>\n | undefined\n\n if (!block || !block.data.text) return null as unknown as JSX.Element\n\n const text = block.data.text.split(' ')\n const excerptText =\n text.length > excerptLength\n ? text.splice(0, excerptLength).join(' ') + '...'\n : text.join(' ')\n const Component = componentList.paragraph\n\n return (\n <Component\n key={block.id}\n id={block.id}\n type={block.type}\n data={{ text: excerptText }}\n />\n )\n }\n return (\n <OuterWrapper className=\"sl-visual-content\">\n {content.blocks.map((block) => {\n const Component = componentList[block.type]\n\n if (!Component) return null\n\n return (\n <Component\n key={block.id}\n id={block.id}\n type={block.type}\n data={block.data as never}\n />\n )\n })}\n </OuterWrapper>\n )\n}\n\nexport {\n Paragraph as ParagraphComponent,\n Header as HeaderComponent,\n Quote as QuoteComponent,\n Image as ImageComponent,\n HTML as HTMLComponent,\n List as ListComponent,\n Video as VideoComponent,\n}\n\nexport type { VisualContentProps, ImageOptions }\n"]}
@@ -1,14 +1,14 @@
1
1
  /// <reference types="react" />
2
- /**
3
- * Renders a `<style>` tag with rules that style the rendered
4
- * {@link VisualContent} HTML. While not required for VisualContent to work,
5
- * using these rules is a quick way to make the content look the same way as it
6
- * does on the Starlight content editor.
7
- *
8
- * You only need to render this component once in your application,
9
- * preferably in the `<head>` section.
10
- *
11
- * @group VisualContent
12
- */
13
- export declare const VisualContentStyles: () => JSX.Element;
2
+ export declare const OuterWrapper: import("@emotion/styled").StyledComponent<{
3
+ theme?: import("@emotion/react").Theme | undefined;
4
+ as?: import("react").ElementType<any> | undefined;
5
+ }, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
6
+ export declare const BlockWrapper: import("@emotion/styled").StyledComponent<{
7
+ theme?: import("@emotion/react").Theme | undefined;
8
+ as?: import("react").ElementType<any> | undefined;
9
+ }, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
10
+ export declare const FigureWrapper: import("@emotion/styled").StyledComponent<{
11
+ theme?: import("@emotion/react").Theme | undefined;
12
+ as?: import("react").ElementType<any> | undefined;
13
+ }, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLElement>, HTMLElement>, {}>;
14
14
  //# sourceMappingURL=styles.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../src/VisualContent/styles.tsx"],"names":[],"mappings":";AA6BA;;;;;;;;;;GAUG;AACH,eAAO,MAAM,mBAAmB,QAAO,WAEtC,CAAA"}
1
+ {"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../src/VisualContent/styles.ts"],"names":[],"mappings":";AAEA,eAAO,MAAM,YAAY;;;yGAiExB,CAAA;AAED,eAAO,MAAM,YAAY;;;yGAMxB,CAAA;AAED,eAAO,MAAM,aAAa;;;mGAMzB,CAAA"}
@@ -1,42 +1,82 @@
1
- import React from 'react';
2
- const styles = `
3
- .sl-visual-content *{max-width:100%}
4
- .sl-visual-content>figure{margin:1em 0}
5
- .sl-list{list-style:none;padding-left:1em}
6
- .sl-list>li{margin:.5em 0}
7
- .sl-list>li::before{content: "•";margin-right:.5em}
8
- .sl__color{padding:2px 0;border-radius:4px}
9
- .sl__color__bg--red{background-color:rgb(253,235,236)}
10
- .sl__color__bg--pink{background-color:rgb(253,235,236)}
11
- .sl__color__bg--purple{background-color:rgb(244,240,247)}
12
- .sl__color__bg--blue{background-color:rgb(231,243,248)}
13
- .sl__color__bg--green{background-color:rgb(237,243,236)}
14
- .sl__color__bg--yellow{background-color:rgb(251,243,219)}
15
- .sl__color__bg--orange{background-color:rgb(251,236,221)}
16
- .sl__color__bg--brown{background-color:rgb(244,238,238)}
17
- .sl__color__bg--gray{background-color:rgb(241,241,239)}
18
- .sl__color__text--red{color:rgb(212,76,71)}
19
- .sl__color__text--pink{color:rgb(193,76,138)}
20
- .sl__color__text--purple{color:rgb(144,101,176)}
21
- .sl__color__text--blue{color:rgb(51,126,169)}
22
- .sl__color__text--green{color:rgb(68,131,97)}
23
- .sl__color__text--yellow{color:rgb(203,145,47)}
24
- .sl__color__text--orange{color:rgb(217,115,13)}
25
- .sl__color__text--brown{color:rgb(159,107,83)}
26
- .sl__color__text--gray{color:rgb(120,119,116)}
1
+ import styled from '@emotion/styled';
2
+ export const OuterWrapper = styled.div `
3
+ .sl__color {
4
+ padding: 2px 0;
5
+ border-radius: 4px;
6
+
7
+ &__bg {
8
+ &--red {
9
+ background-color: rgb(253, 235, 236);
10
+ }
11
+ &--pink {
12
+ background-color: rgb(253, 235, 236);
13
+ }
14
+ &--purple {
15
+ background-color: rgb(244, 240, 247);
16
+ }
17
+ &--blue {
18
+ background-color: rgb(231, 243, 248);
19
+ }
20
+ &--green {
21
+ background-color: rgb(237, 243, 236);
22
+ }
23
+ &--yellow {
24
+ background-color: rgb(251, 243, 219);
25
+ }
26
+ &--orange {
27
+ background-color: rgb(251, 236, 221);
28
+ }
29
+ &--brown {
30
+ background-color: rgb(244, 238, 238);
31
+ }
32
+ &--gray {
33
+ background-color: rgb(241, 241, 239);
34
+ }
35
+ }
36
+
37
+ &__text {
38
+ &--red {
39
+ color: rgb(212, 76, 71);
40
+ }
41
+ &--pink {
42
+ color: rgb(193, 76, 138);
43
+ }
44
+ &--purple {
45
+ color: rgb(144, 101, 176);
46
+ }
47
+ &--blue {
48
+ color: rgb(51, 126, 169);
49
+ }
50
+ &--green {
51
+ color: rgb(68, 131, 97);
52
+ }
53
+ &--yellow {
54
+ color: rgb(203, 145, 47);
55
+ }
56
+ &--orange {
57
+ color: rgb(217, 115, 13);
58
+ }
59
+ &--brown {
60
+ color: rgb(159, 107, 83);
61
+ }
62
+ &--gray {
63
+ color: rgb(120, 119, 116);
64
+ }
65
+ }
66
+ }
67
+ `;
68
+ export const BlockWrapper = styled.div `
69
+ margin: auto;
70
+
71
+ &.sl-width-max {
72
+ max-width: 100%;
73
+ }
74
+ `;
75
+ export const FigureWrapper = styled.figure `
76
+ figcaption {
77
+ display: flex;
78
+ justify-content: center;
79
+ margin-top: 6px;
80
+ }
27
81
  `;
28
- /**
29
- * Renders a `<style>` tag with rules that style the rendered
30
- * {@link VisualContent} HTML. While not required for VisualContent to work,
31
- * using these rules is a quick way to make the content look the same way as it
32
- * does on the Starlight content editor.
33
- *
34
- * You only need to render this component once in your application,
35
- * preferably in the `<head>` section.
36
- *
37
- * @group VisualContent
38
- */
39
- export const VisualContentStyles = () => {
40
- return React.createElement("style", { dangerouslySetInnerHTML: { __html: styles } });
41
- };
42
82
  //# sourceMappingURL=styles.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"styles.js","sourceRoot":"","sources":["../../../src/VisualContent/styles.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;CAyBd,CAAA;AAED;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,GAAgB,EAAE;IACnD,OAAO,+BAAO,uBAAuB,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,GAAI,CAAA;AAC/D,CAAC,CAAA","sourcesContent":["import React from 'react'\n\nconst styles = `\n .sl-visual-content *{max-width:100%}\n .sl-visual-content>figure{margin:1em 0}\n .sl-list{list-style:none;padding-left:1em}\n .sl-list>li{margin:.5em 0}\n .sl-list>li::before{content: \"•\";margin-right:.5em}\n .sl__color{padding:2px 0;border-radius:4px}\n .sl__color__bg--red{background-color:rgb(253,235,236)}\n .sl__color__bg--pink{background-color:rgb(253,235,236)}\n .sl__color__bg--purple{background-color:rgb(244,240,247)}\n .sl__color__bg--blue{background-color:rgb(231,243,248)}\n .sl__color__bg--green{background-color:rgb(237,243,236)}\n .sl__color__bg--yellow{background-color:rgb(251,243,219)}\n .sl__color__bg--orange{background-color:rgb(251,236,221)}\n .sl__color__bg--brown{background-color:rgb(244,238,238)}\n .sl__color__bg--gray{background-color:rgb(241,241,239)}\n .sl__color__text--red{color:rgb(212,76,71)}\n .sl__color__text--pink{color:rgb(193,76,138)}\n .sl__color__text--purple{color:rgb(144,101,176)}\n .sl__color__text--blue{color:rgb(51,126,169)}\n .sl__color__text--green{color:rgb(68,131,97)}\n .sl__color__text--yellow{color:rgb(203,145,47)}\n .sl__color__text--orange{color:rgb(217,115,13)}\n .sl__color__text--brown{color:rgb(159,107,83)}\n .sl__color__text--gray{color:rgb(120,119,116)}\n`\n\n/**\n * Renders a `<style>` tag with rules that style the rendered\n * {@link VisualContent} HTML. While not required for VisualContent to work,\n * using these rules is a quick way to make the content look the same way as it\n * does on the Starlight content editor.\n *\n * You only need to render this component once in your application,\n * preferably in the `<head>` section.\n *\n * @group VisualContent\n */\nexport const VisualContentStyles = (): JSX.Element => {\n return <style dangerouslySetInnerHTML={{ __html: styles }} />\n}\n"]}
1
+ {"version":3,"file":"styles.js","sourceRoot":"","sources":["../../../src/VisualContent/styles.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,iBAAiB,CAAA;AAEpC,MAAM,CAAC,MAAM,YAAY,GAAG,MAAM,CAAC,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiErC,CAAA;AAED,MAAM,CAAC,MAAM,YAAY,GAAG,MAAM,CAAC,GAAG,CAAA;;;;;;CAMrC,CAAA;AAED,MAAM,CAAC,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,CAAA;;;;;;CAMzC,CAAA","sourcesContent":["import styled from '@emotion/styled'\n\nexport const OuterWrapper = styled.div`\n .sl__color {\n padding: 2px 0;\n border-radius: 4px;\n\n &__bg {\n &--red {\n background-color: rgb(253, 235, 236);\n }\n &--pink {\n background-color: rgb(253, 235, 236);\n }\n &--purple {\n background-color: rgb(244, 240, 247);\n }\n &--blue {\n background-color: rgb(231, 243, 248);\n }\n &--green {\n background-color: rgb(237, 243, 236);\n }\n &--yellow {\n background-color: rgb(251, 243, 219);\n }\n &--orange {\n background-color: rgb(251, 236, 221);\n }\n &--brown {\n background-color: rgb(244, 238, 238);\n }\n &--gray {\n background-color: rgb(241, 241, 239);\n }\n }\n\n &__text {\n &--red {\n color: rgb(212, 76, 71);\n }\n &--pink {\n color: rgb(193, 76, 138);\n }\n &--purple {\n color: rgb(144, 101, 176);\n }\n &--blue {\n color: rgb(51, 126, 169);\n }\n &--green {\n color: rgb(68, 131, 97);\n }\n &--yellow {\n color: rgb(203, 145, 47);\n }\n &--orange {\n color: rgb(217, 115, 13);\n }\n &--brown {\n color: rgb(159, 107, 83);\n }\n &--gray {\n color: rgb(120, 119, 116);\n }\n }\n }\n`\n\nexport const BlockWrapper = styled.div`\n margin: auto;\n\n &.sl-width-max {\n max-width: 100%;\n }\n`\n\nexport const FigureWrapper = styled.figure`\n figcaption {\n display: flex;\n justify-content: center;\n margin-top: 6px;\n }\n`\n"]}
@@ -1,5 +1,5 @@
1
1
  import { ComponentType } from 'react';
2
- import { HeaderBlock, ImageBlock, ParagraphBlock, QuoteBlock, VisualData, VisualDataBlock, BlockType, HTMLBlock, ListBlock } from '@starlightcms/js-sdk';
2
+ import { HeaderBlock, ImageBlock, ParagraphBlock, QuoteBlock, VisualData, VisualDataBlock, BlockType, HTMLBlock, ListBlock, VideoBlock } from '@starlightcms/js-sdk';
3
3
  declare type Implements<T, U extends T> = Record<string, unknown>;
4
4
  export interface BlockComponents extends Implements<Record<BlockType, unknown>, BlockComponents> {
5
5
  paragraph: ComponentType<VisualDataBlock<ParagraphBlock>>;
@@ -8,6 +8,7 @@ export interface BlockComponents extends Implements<Record<BlockType, unknown>,
8
8
  image: ComponentType<VisualDataBlock<ImageBlock>>;
9
9
  raw: ComponentType<VisualDataBlock<HTMLBlock>>;
10
10
  list: ComponentType<VisualDataBlock<ListBlock>>;
11
+ video: ComponentType<VisualDataBlock<VideoBlock>>;
11
12
  }
12
13
  /**
13
14
  * Props accepted by the {@link VisualContent} component.
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/VisualContent/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAA;AACrC,OAAO,EACL,WAAW,EACX,UAAU,EACV,cAAc,EACd,UAAU,EACV,UAAU,EACV,eAAe,EACf,SAAS,EACT,SAAS,EACT,SAAS,EACV,MAAM,sBAAsB,CAAA;AA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CAAA;AAEzD,MAAM,WAAW,eACf,SAAQ,UAAU,CAAC,MAAM,CAAC,SAAS,EAAE,OAAO,CAAC,EAAE,eAAe,CAAC;IAC/D,SAAS,EAAE,aAAa,CAAC,eAAe,CAAC,cAAc,CAAC,CAAC,CAAA;IACzD,MAAM,EAAE,aAAa,CAAC,eAAe,CAAC,WAAW,CAAC,CAAC,CAAA;IACnD,KAAK,EAAE,aAAa,CAAC,eAAe,CAAC,UAAU,CAAC,CAAC,CAAA;IACjD,KAAK,EAAE,aAAa,CAAC,eAAe,CAAC,UAAU,CAAC,CAAC,CAAA;IACjD,GAAG,EAAE,aAAa,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC,CAAA;IAC9C,IAAI,EAAE,aAAa,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC,CAAA;IAC/C,KAAK,EAAE,aAAa,CAAC,eAAe,CAAC,UAAU,CAAC,CAAC,CAAA;CAClD;AAED;;;GAGG;AACH,MAAM,WAAW,kBAAkB;IACjC;;;OAGG;IACH,OAAO,CAAC,EAAE,UAAU,CAAA;IACpB;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC,eAAe,CAAC,CAAA;IACrC;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAA;CACvB"}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/VisualContent/types.ts"],"names":[],"mappings":"","sourcesContent":["import { ComponentType } from 'react'\nimport {\n HeaderBlock,\n ImageBlock,\n ParagraphBlock,\n QuoteBlock,\n VisualData,\n VisualDataBlock,\n BlockType,\n HTMLBlock,\n ListBlock,\n} from '@starlightcms/js-sdk'\n\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\ntype Implements<T, U extends T> = Record<string, unknown>\n\nexport interface BlockComponents\n extends Implements<Record<BlockType, unknown>, BlockComponents> {\n paragraph: ComponentType<VisualDataBlock<ParagraphBlock>>\n header: ComponentType<VisualDataBlock<HeaderBlock>>\n quote: ComponentType<VisualDataBlock<QuoteBlock>>\n image: ComponentType<VisualDataBlock<ImageBlock>>\n raw: ComponentType<VisualDataBlock<HTMLBlock>>\n list: ComponentType<VisualDataBlock<ListBlock>>\n}\n\n/**\n * Props accepted by the {@link VisualContent} component.\n * @group VisualContent\n */\nexport interface VisualContentProps {\n /**\n * The content to render. It should be the object returned by\n * Starlight on a Visual Editor field. Required.\n */\n content?: VisualData\n /**\n * An optional object of React components. You can pass any\n * number of replacement components that will render blocks of a given type.\n */\n components?: Partial<BlockComponents>\n /**\n * If true, only a small portion of the content will be rendered,\n * and block types other than text paragraphs will be ignored. Defaults to false.\n */\n excerpt?: boolean\n /**\n * Defines the maximum number of words to render when\n * excerpt is true. Defaults to 40.\n */\n excerptLength?: number\n}\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/VisualContent/types.ts"],"names":[],"mappings":"","sourcesContent":["import { ComponentType } from 'react'\nimport {\n HeaderBlock,\n ImageBlock,\n ParagraphBlock,\n QuoteBlock,\n VisualData,\n VisualDataBlock,\n BlockType,\n HTMLBlock,\n ListBlock,\n VideoBlock,\n} from '@starlightcms/js-sdk'\n\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\ntype Implements<T, U extends T> = Record<string, unknown>\n\nexport interface BlockComponents\n extends Implements<Record<BlockType, unknown>, BlockComponents> {\n paragraph: ComponentType<VisualDataBlock<ParagraphBlock>>\n header: ComponentType<VisualDataBlock<HeaderBlock>>\n quote: ComponentType<VisualDataBlock<QuoteBlock>>\n image: ComponentType<VisualDataBlock<ImageBlock>>\n raw: ComponentType<VisualDataBlock<HTMLBlock>>\n list: ComponentType<VisualDataBlock<ListBlock>>\n video: ComponentType<VisualDataBlock<VideoBlock>>\n}\n\n/**\n * Props accepted by the {@link VisualContent} component.\n * @group VisualContent\n */\nexport interface VisualContentProps {\n /**\n * The content to render. It should be the object returned by\n * Starlight on a Visual Editor field. Required.\n */\n content?: VisualData\n /**\n * An optional object of React components. You can pass any\n * number of replacement components that will render blocks of a given type.\n */\n components?: Partial<BlockComponents>\n /**\n * If true, only a small portion of the content will be rendered,\n * and block types other than text paragraphs will be ignored. Defaults to false.\n */\n excerpt?: boolean\n /**\n * Defines the maximum number of words to render when\n * excerpt is true. Defaults to 40.\n */\n excerptLength?: number\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@starlightcms/react-sdk",
3
- "version": "1.1.0",
3
+ "version": "2.0.0",
4
4
  "description": "The Starlight SDK for React",
5
5
  "workspaces": [
6
6
  "website"
@@ -60,7 +60,9 @@
60
60
  ]
61
61
  },
62
62
  "dependencies": {
63
- "@starlightcms/js-sdk": "^1.1.0"
63
+ "@emotion/react": "^11.10.6",
64
+ "@emotion/styled": "^11.10.6",
65
+ "@starlightcms/js-sdk": "^2.0.1"
64
66
  },
65
67
  "peerDependencies": {
66
68
  "react": ">=16.0.0"
@@ -1 +0,0 @@
1
- {"version":3,"file":"HTML.d.ts","sourceRoot":"","sources":["../../../../src/VisualContent/blocks/HTML.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAE,EAAE,EAAE,MAAM,OAAO,CAAA;AACjC,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAEjE;;;;;;;;;;GAUG;AACH,QAAA,MAAM,IAAI,EAAE,EAAE,CAAC,eAAe,CAAC,SAAS,CAAC,CAOxC,CAAA;AAED,eAAe,IAAI,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"HTML.js","sourceRoot":"","sources":["../../../../src/VisualContent/blocks/HTML.tsx"],"names":[],"mappings":";;;;;AAAA,kDAAiC;AAGjC;;;;;;;;;;GAUG;AACH,MAAM,IAAI,GAAmC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE;IACxD,OAAO,CACL,uCACE,SAAS,EAAC,+BAA+B,EACzC,uBAAuB,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,IAAI,EAAE,GAC9C,CACH,CAAA;AACH,CAAC,CAAA;AAED,kBAAe,IAAI,CAAA","sourcesContent":["import React, { FC } from 'react'\nimport { HTMLBlock, VisualDataBlock } from '@starlightcms/js-sdk'\n\n/**\n * VisualContent renderer component that renders `raw` type blocks\n * as inline HTML inside a `div` element.\n *\n * See {@doclink components/VisualContent/#customizing-components | the guide page on the VisualContent component}\n * to learn how to customize block renderer components like this one.\n *\n * @param props VisualDataBlock object. See {@link HTMLBlock} to learn the\n * type of data this component receives.\n * @group VisualContent Renderers\n */\nconst HTML: FC<VisualDataBlock<HTMLBlock>> = ({ data }) => {\n return (\n <div\n className=\"sl-content-block sl-html test\"\n dangerouslySetInnerHTML={{ __html: data.html }}\n />\n )\n}\n\nexport default HTML\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"Image.d.ts","sourceRoot":"","sources":["../../../../src/VisualContent/blocks/Image.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAE,EAAE,EAAuB,MAAM,OAAO,CAAA;AACtD,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAElE;;GAEG;AACH,oBAAY,YAAY,GAAG;IACzB,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,QAAA,MAAM,KAAK,EAAE,EAAE,CAAC,eAAe,CAAC,UAAU,CAAC,GAAG,YAAY,CA8CzD,CAAA;AAED,eAAe,KAAK,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"Image.js","sourceRoot":"","sources":["../../../../src/VisualContent/blocks/Image.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAsD;AAUtD;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,KAAK,GAAmD,CAAC,EAC7D,IAAI,EACJ,KAAK,GAAG,+BAA+B,GACxC,EAAE,EAAE;IACH,MAAM,EAAE,GAAG,EAAE,KAAK,E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AG,EACR,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,GACjC,CACH;QACA,OAAO,IAAI,8CAAY,uBAAuB,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,GAAI,CACjE,CACV,CAAA;AACH,CAAC,CAAA;AAED,kBAAe,KAAK,CAAA","sourcesContent":["import React, { FC, useEffect, useState } from 'react'\nimport { ImageBlock, VisualDataBlock } from '@starlightcms/js-sdk'\n\n/**\n * Type used by {@link ImageComponent} to accept a `sizes` prop.\n */\nexport type ImageOptions = {\n sizes?: string\n}\n\n/**\n * VisualContent renderer component that renders `image` type blocks\n * as a responsive image along with its caption (if defined). Optionally\n * wraps the image in an anchor if a link is defined in the content.\n *\n * See {@doclink components/VisualContent/#customizing-components | the guide page on the VisualContent component}\n * to learn how to customize block renderer components like this one.\n *\n * This component also supports an optional `sizes` prop to provide better image\n * responsiveness, see {@doclink components/VisualContent/#responsive-images | the guide page on responsive images}\n * to learn more.\n *\n * @param props VisualDataBlock object. See {@link ImageBlock} to learn the\n * type of data this component receives. Also accepts\n * an optional `sizes` string prop.\n * @group VisualContent Renderers\n */\nconst Image: FC<VisualDataBlock<ImageBlock> & ImageOptions> = ({\n data,\n sizes = '(max-width: 480px) 90vw, 70vw',\n}) => {\n const { url, files, alt = '', caption, href } = data\n const [target, setTarget] = useState('_self')\n const [srcSet, setSrcSet] = useState('')\n\n useEffect(() => {\n if (!href) return\n\n setTarget(\n new URL(href).origin === window.location.origin ? '_self' : '_blank'\n )\n }, [href])\n\n useEffect(() => {\n if (!files || !files.length) return\n\n setSrcSet(files.map((file) => `${file.url} ${file.width}w`).join(', '))\n }, [files])\n\n return (\n <figure>\n {href ? (\n <a href={href} target={target}>\n <img\n className=\"sl-content-block sl-image\"\n src={url}\n alt={alt}\n srcSet={srcSet}\n sizes={srcSet ? sizes : undefined}\n />\n </a>\n ) : (\n <img\n className=\"sl-content-block sl-image\"\n src={url}\n alt={alt}\n srcSet={srcSet}\n sizes={srcSet ? sizes : undefined}\n />\n )}\n {caption && <figcaption dangerouslySetInnerHTML={{ __html: caption }} />}\n </figure>\n )\n}\n\nexport default Image\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"List.d.ts","sourceRoot":"","sources":["../../../../src/VisualContent/blocks/List.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAE,EAAE,EAAE,MAAM,OAAO,CAAA;AACjC,OAAO,EAAE,SAAS,EAAY,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAuB3E;;;;;;;;;;GAUG;AACH,QAAA,MAAM,IAAI,EAAE,EAAE,CAAC,eAAe,CAAC,SAAS,CAAC,CAUxC,CAAA;AAED,eAAe,IAAI,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"List.js","sourceRoot":"","sources":["../../../../src/VisualContent/blocks/List.tsx"],"names":[],"mappings":";;;;;AAAA,kDAAiC;AAQjC,MAAM,OAAO,GAAqB,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE;IACtD,OAAO,CACL;QACE,wCAAM,uBAAuB,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,OAAO,EAAE,GAAI;QAC1D,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CACjC,8BAAC,OAAO,QACL,IAAI,CAAC,KAAK;YACT,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,KAAK,EAAE,EAAE,CAAC,CACjC,8BAAC,OAAO,IAAC,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,GAAI,CACzD,CAAC,CACI,CACX,CAAC,CAAC,CAAC,IAAI,CACL,CACN,CAAA;AACH,CAAC,CAAA;AAED;;;;;;;;;;GAUG;AACH,MAAM,IAAI,GAAmC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE;IACxD,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAA;IAE1D,OAAO,CACL,8BAAC,WAAW,IAAC,SAAS,EAAC,wCAAwC,IAC5D,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,CAC/B,8BAAC,OAAO,IAAC,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,GAAI,CAC1D,CAAC,CACU,CACf,CAAA;AACH,CAAC,CAAA;AAED,kBAAe,IAAI,CAAA","sourcesContent":["import React, { FC } from 'react'\nimport { ListBlock, ListItem, VisualDataBlock } from '@starlightcms/js-sdk'\n\ntype SubListProps = {\n item: ListItem\n Wrapper: 'ul' | 'ol'\n}\n\nconst SubList: FC<SubListProps> = ({ item, Wrapper }) => {\n return (\n <li>\n <span dangerouslySetInnerHTML={{ __html: item.content }} />\n {item.items && item.items.length ? (\n <Wrapper>\n {item.items &&\n item.items.map((subItem, index) => (\n <SubList key={index} item={subItem} Wrapper={Wrapper} />\n ))}\n </Wrapper>\n ) : null}\n </li>\n )\n}\n\n/**\n * VisualContent renderer component that renders `list` type blocks\n * as `<ul>` or `<ol>` elements, depending on the list style.\n *\n * See {@doclink components/VisualContent/#customizing-components | the guide page on the VisualContent component}\n * to learn how to customize block renderer components like this one.\n *\n * @param props VisualDataBlock object. See {@link ListBlock} to learn the\n * type of data this component receives.\n * @group VisualContent Renderers\n */\nconst List: FC<VisualDataBlock<ListBlock>> = ({ data }) => {\n const ListWrapper = data.style === 'ordered' ? 'ol' : 'ul'\n\n return (\n <ListWrapper className=\"sl-content-block sl-list sl-list__root\">\n {data.items.map((item, index) => (\n <SubList key={index} item={item} Wrapper={ListWrapper} />\n ))}\n </ListWrapper>\n )\n}\n\nexport default List\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"HTML.d.ts","sourceRoot":"","sources":["../../../../src/VisualContent/blocks/HTML.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAE,EAAE,EAAE,MAAM,OAAO,CAAA;AACjC,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAEjE;;;;;;;;;;GAUG;AACH,QAAA,MAAM,IAAI,EAAE,EAAE,CAAC,eAAe,CAAC,SAAS,CAAC,CAOxC,CAAA;AAED,eAAe,IAAI,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"HTML.js","sourceRoot":"","sources":["../../../../src/VisualContent/blocks/HTML.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAa,MAAM,OAAO,CAAA;AAGjC;;;;;;;;;;GAUG;AACH,MAAM,IAAI,GAAmC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE;IACxD,OAAO,CACL,6BACE,SAAS,EAAC,+BAA+B,EACzC,uBAAuB,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,IAAI,EAAE,GAC9C,CACH,CAAA;AACH,CAAC,CAAA;AAED,eAAe,IAAI,CAAA","sourcesContent":["import React, { FC } from 'react'\nimport { HTMLBlock, VisualDataBlock } from '@starlightcms/js-sdk'\n\n/**\n * VisualContent renderer component that renders `raw` type blocks\n * as inline HTML inside a `div` element.\n *\n * See {@doclink components/VisualContent/#customizing-components | the guide page on the VisualContent component}\n * to learn how to customize block renderer components like this one.\n *\n * @param props VisualDataBlock object. See {@link HTMLBlock} to learn the\n * type of data this component receives.\n * @group VisualContent Renderers\n */\nconst HTML: FC<VisualDataBlock<HTMLBlock>> = ({ data }) => {\n return (\n <div\n className=\"sl-content-block sl-html test\"\n dangerouslySetInnerHTML={{ __html: data.html }}\n />\n )\n}\n\nexport default HTML\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"Image.d.ts","sourceRoot":"","sources":["../../../../src/VisualContent/blocks/Image.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAE,EAAE,EAAuB,MAAM,OAAO,CAAA;AACtD,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAElE;;GAEG;AACH,oBAAY,YAAY,GAAG;IACzB,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,QAAA,MAAM,KAAK,EAAE,EAAE,CAAC,eAAe,CAAC,UAAU,CAAC,GAAG,YAAY,CA8CzD,CAAA;AAED,eAAe,KAAK,CAAA"}