@styleflow.app/flowpress-astro-core 1.0.0-beta.3 → 1.0.0-beta.30

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 (243) hide show
  1. package/CHANGELOG.md +190 -1
  2. package/README.md +111 -3
  3. package/dist/accessibility-panel.d.ts +2 -0
  4. package/dist/accessibility-panel.d.ts.map +1 -0
  5. package/dist/accessibility-panel.js +81 -0
  6. package/dist/accessibility-panel.js.map +1 -0
  7. package/dist/astro/BaseLayout.astro +34 -17
  8. package/dist/astro/CompositionRenderer.astro +157 -0
  9. package/dist/astro/DefaultBlockAdapter.astro +35 -0
  10. package/dist/astro/DefaultTemplate.astro +12 -7
  11. package/dist/astro/GutenbergRenderer.astro +240 -80
  12. package/dist/astro/StyleflowElement.astro +23 -0
  13. package/dist/astro/ThemeRuntime.astro +26 -0
  14. package/dist/astro/blocks/CarouselBlock.astro +8 -10
  15. package/dist/astro/blocks/CarouselItemBlock.astro +4 -4
  16. package/dist/astro/blocks/ColumnBlock.astro +4 -5
  17. package/dist/astro/blocks/CoverBlock.astro +155 -0
  18. package/dist/astro/blocks/FormBlock.astro +23 -20
  19. package/dist/astro/blocks/GridBlock.astro +4 -4
  20. package/dist/astro/blocks/HeroBlock.astro +4 -5
  21. package/dist/astro/blocks/ImageBlock.astro +4 -5
  22. package/dist/astro/blocks/ListItemFallback.astro +10 -7
  23. package/dist/astro/blocks/NumberSpinnerBlock.astro +29 -22
  24. package/dist/astro/blocks/SemanticElement.astro +35 -0
  25. package/dist/astro/blocks/SiteLogoBlock.astro +53 -0
  26. package/dist/astro/blocks/TextBlock.astro +33 -28
  27. package/dist/astro/blocks/ThemeToggleBlock.astro +13 -0
  28. package/dist/astro/blocks/cover.d.ts +13 -0
  29. package/dist/astro/blocks/cover.d.ts.map +1 -0
  30. package/dist/astro/blocks/cover.js +105 -0
  31. package/dist/astro/blocks/cover.js.map +1 -0
  32. package/dist/astro/blocks/cover.ts +119 -0
  33. package/dist/astro/blocks/helpers.d.ts +7 -0
  34. package/dist/astro/blocks/helpers.d.ts.map +1 -1
  35. package/dist/astro/blocks/helpers.js +52 -41
  36. package/dist/astro/blocks/helpers.js.map +1 -1
  37. package/dist/astro/blocks/helpers.ts +64 -45
  38. package/dist/astro/native/Blob.astro +113 -0
  39. package/dist/astro/native/BlobBlock.astro +52 -0
  40. package/dist/astro/native/CustomFieldValue.astro +87 -0
  41. package/dist/astro/native/LevelTag.astro +20 -0
  42. package/dist/astro/native/MapBlock.astro +41 -0
  43. package/dist/astro/native/NativeHtmlBlock.astro +12 -0
  44. package/dist/astro/native/NativeIconBlock.astro +42 -0
  45. package/dist/astro/native/ProjectTimelineBlock.astro +34 -0
  46. package/dist/astro/native/ResolvedBlocks.astro +89 -0
  47. package/dist/astro/native/SyncedPatternContent.astro +92 -0
  48. package/dist/astro/native/TermFieldValue.astro +38 -0
  49. package/dist/astro/native/Timeline.astro +21 -0
  50. package/dist/astro/native/TimelineCardBlock.astro +7 -0
  51. package/dist/astro/native/blob/blob-shapes.generated.d.ts +2 -0
  52. package/dist/astro/native/blob/blob-shapes.generated.d.ts.map +1 -0
  53. package/dist/astro/native/blob/blob-shapes.generated.js +2 -0
  54. package/dist/astro/native/blob/blob-shapes.generated.js.map +1 -0
  55. package/dist/astro/native/blob/blob-shapes.generated.ts +1 -0
  56. package/dist/astro/native/blob/config.d.ts +49 -0
  57. package/dist/astro/native/blob/config.d.ts.map +1 -0
  58. package/dist/astro/native/blob/config.js +86 -0
  59. package/dist/astro/native/blob/config.js.map +1 -0
  60. package/dist/astro/native/blob/config.ts +132 -0
  61. package/dist/astro/native/blob/controller.d.ts +11 -0
  62. package/dist/astro/native/blob/controller.d.ts.map +1 -0
  63. package/dist/astro/native/blob/controller.js +240 -0
  64. package/dist/astro/native/blob/controller.js.map +1 -0
  65. package/dist/astro/native/blob/controller.ts +248 -0
  66. package/dist/astro/native/blob/geometry.d.ts +2 -0
  67. package/dist/astro/native/blob/geometry.d.ts.map +1 -0
  68. package/dist/astro/native/blob/geometry.js +2 -0
  69. package/dist/astro/native/blob/geometry.js.map +1 -0
  70. package/dist/astro/native/blob/geometry.ts +1 -0
  71. package/dist/astro/native/blob/ids.d.ts +7 -0
  72. package/dist/astro/native/blob/ids.d.ts.map +1 -0
  73. package/dist/astro/native/blob/ids.js +11 -0
  74. package/dist/astro/native/blob/ids.js.map +1 -0
  75. package/dist/astro/native/blob/ids.ts +11 -0
  76. package/dist/astro/native/blob.css +83 -0
  77. package/dist/astro/native/button.d.ts +13 -0
  78. package/dist/astro/native/button.d.ts.map +1 -0
  79. package/dist/astro/native/button.js +26 -0
  80. package/dist/astro/native/button.js.map +1 -0
  81. package/dist/astro/native/button.ts +26 -0
  82. package/dist/astro/native/core-block.astro +18 -0
  83. package/dist/astro/native/core-button.astro +43 -0
  84. package/dist/astro/native/core-buttons.astro +14 -0
  85. package/dist/astro/native/core-group.astro +23 -0
  86. package/dist/astro/native/core-home-link.astro +12 -0
  87. package/dist/astro/native/core-html.astro +8 -0
  88. package/dist/astro/native/core-icon.astro +7 -0
  89. package/dist/astro/native/core-image.astro +124 -0
  90. package/dist/astro/native/core-navigation-link.astro +71 -0
  91. package/dist/astro/native/core-navigation-submenu.astro +33 -0
  92. package/dist/astro/native/core-navigation.astro +94 -0
  93. package/dist/astro/native/core-page-list-data-item.astro +19 -0
  94. package/dist/astro/native/core-page-list-item.astro +8 -0
  95. package/dist/astro/native/core-page-list.astro +40 -0
  96. package/dist/astro/native/core-post-date.astro +21 -0
  97. package/dist/astro/native/core-post-excerpt.astro +26 -0
  98. package/dist/astro/native/core-post-featured-image.astro +37 -0
  99. package/dist/astro/native/core-post-template.astro +30 -0
  100. package/dist/astro/native/core-post-terms.astro +47 -0
  101. package/dist/astro/native/core-post-title.astro +23 -0
  102. package/dist/astro/native/core-query-no-results.astro +12 -0
  103. package/dist/astro/native/core-query.astro +22 -0
  104. package/dist/astro/native/core-separator.astro +20 -0
  105. package/dist/astro/native/core-site-title.astro +16 -0
  106. package/dist/astro/native/core-term-description.astro +12 -0
  107. package/dist/astro/native/core-term-name.astro +21 -0
  108. package/dist/astro/native/core-term-template.astro +30 -0
  109. package/dist/astro/native/core-terms-query.astro +19 -0
  110. package/dist/astro/native/core-transparent.astro +11 -0
  111. package/dist/astro/native/flowpress-navigation-controller.d.ts +2 -0
  112. package/dist/astro/native/flowpress-navigation-controller.d.ts.map +1 -0
  113. package/dist/astro/native/flowpress-navigation-controller.js +217 -0
  114. package/dist/astro/native/flowpress-navigation-controller.js.map +1 -0
  115. package/dist/astro/native/flowpress-navigation-controller.ts +215 -0
  116. package/dist/astro/native/flowpress-navigation.css +17 -0
  117. package/dist/astro/native/grid-bleed.js +106 -0
  118. package/dist/astro/native/grid.css +180 -0
  119. package/dist/astro/native/grid.d.ts +17 -0
  120. package/dist/astro/native/grid.d.ts.map +1 -0
  121. package/dist/astro/native/grid.js +103 -0
  122. package/dist/astro/native/grid.js.map +1 -0
  123. package/dist/astro/native/grid.ts +118 -0
  124. package/dist/astro/native/html.d.ts +6 -0
  125. package/dist/astro/native/html.d.ts.map +1 -0
  126. package/dist/astro/native/html.js +10 -0
  127. package/dist/astro/native/html.js.map +1 -0
  128. package/dist/astro/native/html.ts +9 -0
  129. package/dist/astro/native/icon.d.ts +3 -0
  130. package/dist/astro/native/icon.d.ts.map +1 -0
  131. package/dist/astro/native/icon.js +23 -0
  132. package/dist/astro/native/icon.js.map +1 -0
  133. package/dist/astro/native/icon.ts +21 -0
  134. package/dist/astro/native/map.d.ts +14 -0
  135. package/dist/astro/native/map.d.ts.map +1 -0
  136. package/dist/astro/native/map.js +60 -0
  137. package/dist/astro/native/map.js.map +1 -0
  138. package/dist/astro/native/map.ts +70 -0
  139. package/dist/astro/native/motion-preference.d.ts +50 -0
  140. package/dist/astro/native/motion-preference.d.ts.map +1 -0
  141. package/dist/astro/native/motion-preference.js +132 -0
  142. package/dist/astro/native/motion-preference.js.map +1 -0
  143. package/dist/astro/native/motion-preference.ts +158 -0
  144. package/dist/astro/native/motion.d.ts +101 -0
  145. package/dist/astro/native/motion.d.ts.map +1 -0
  146. package/dist/astro/native/motion.js +168 -0
  147. package/dist/astro/native/motion.js.map +1 -0
  148. package/dist/astro/native/motion.ts +312 -0
  149. package/dist/astro/native/query-loop.d.ts +38 -0
  150. package/dist/astro/native/query-loop.d.ts.map +1 -0
  151. package/dist/astro/native/query-loop.js +20 -0
  152. package/dist/astro/native/query-loop.js.map +1 -0
  153. package/dist/astro/native/query-loop.ts +67 -0
  154. package/dist/astro/native/registry.d.ts +3 -0
  155. package/dist/astro/native/registry.d.ts.map +1 -0
  156. package/dist/astro/native/registry.js +81 -0
  157. package/dist/astro/native/registry.js.map +1 -0
  158. package/dist/astro/native/registry.ts +81 -0
  159. package/dist/astro/native/sf-block-binding.astro +20 -0
  160. package/dist/astro/native/sf-post-field.astro +9 -0
  161. package/dist/astro/native/sf-term-field.astro +9 -0
  162. package/dist/astro/native/timeline.css +4 -0
  163. package/dist/astro/native/timeline.d.ts +28 -0
  164. package/dist/astro/native/timeline.d.ts.map +1 -0
  165. package/dist/astro/native/timeline.js +43 -0
  166. package/dist/astro/native/timeline.js.map +1 -0
  167. package/dist/astro/native/timeline.ts +79 -0
  168. package/dist/astro/preferences/AccessibilityPanel.astro +118 -0
  169. package/dist/astro/preferences/ColorModeToggle.astro +26 -0
  170. package/dist/astro/preferences/MotionToggle.astro +27 -0
  171. package/dist/astro/preferences/PreferencesRuntime.astro +9 -0
  172. package/dist/astro/preferences/ThemeToggle.astro +30 -0
  173. package/dist/astro/preferences/Toggle.astro +50 -0
  174. package/dist/astro/preferences/preferences.css +125 -0
  175. package/dist/block-renderers.d.ts +20 -3
  176. package/dist/block-renderers.d.ts.map +1 -1
  177. package/dist/block-renderers.js.map +1 -1
  178. package/dist/client.d.ts +17 -1
  179. package/dist/client.d.ts.map +1 -1
  180. package/dist/client.js +63 -9
  181. package/dist/client.js.map +1 -1
  182. package/dist/composition.d.ts +14 -0
  183. package/dist/composition.d.ts.map +1 -0
  184. package/dist/composition.js +124 -0
  185. package/dist/composition.js.map +1 -0
  186. package/dist/default-blocks.d.ts +9 -0
  187. package/dist/default-blocks.d.ts.map +1 -0
  188. package/dist/default-blocks.js +118 -0
  189. package/dist/default-blocks.js.map +1 -0
  190. package/dist/env.d.ts +9 -0
  191. package/dist/env.d.ts.map +1 -1
  192. package/dist/env.js +20 -0
  193. package/dist/env.js.map +1 -1
  194. package/dist/index.d.ts +8 -0
  195. package/dist/index.d.ts.map +1 -1
  196. package/dist/index.js +7 -0
  197. package/dist/index.js.map +1 -1
  198. package/dist/links.d.ts +5 -0
  199. package/dist/links.d.ts.map +1 -0
  200. package/dist/links.js +32 -0
  201. package/dist/links.js.map +1 -0
  202. package/dist/media.d.ts +28 -0
  203. package/dist/media.d.ts.map +1 -0
  204. package/dist/media.js +212 -0
  205. package/dist/media.js.map +1 -0
  206. package/dist/motion-preference.d.ts +50 -0
  207. package/dist/motion-preference.d.ts.map +1 -0
  208. package/dist/motion-preference.js +132 -0
  209. package/dist/motion-preference.js.map +1 -0
  210. package/dist/preferences-runtime.d.ts +3 -0
  211. package/dist/preferences-runtime.d.ts.map +1 -0
  212. package/dist/preferences-runtime.js +23 -0
  213. package/dist/preferences-runtime.js.map +1 -0
  214. package/dist/preferences-styleflow.d.ts +3 -0
  215. package/dist/preferences-styleflow.d.ts.map +1 -0
  216. package/dist/preferences-styleflow.js +14 -0
  217. package/dist/preferences-styleflow.js.map +1 -0
  218. package/dist/preferences.d.ts +4 -0
  219. package/dist/preferences.d.ts.map +1 -0
  220. package/dist/preferences.js +4 -0
  221. package/dist/preferences.js.map +1 -0
  222. package/dist/styleflow.d.ts +16 -1
  223. package/dist/styleflow.d.ts.map +1 -1
  224. package/dist/styleflow.js +76 -7
  225. package/dist/styleflow.js.map +1 -1
  226. package/dist/templates.d.ts +16 -16
  227. package/dist/text.d.ts +3 -0
  228. package/dist/text.d.ts.map +1 -0
  229. package/dist/text.js +6 -0
  230. package/dist/text.js.map +1 -0
  231. package/dist/theme-runtime.d.ts +16 -0
  232. package/dist/theme-runtime.d.ts.map +1 -0
  233. package/dist/theme-runtime.js +100 -0
  234. package/dist/theme-runtime.js.map +1 -0
  235. package/dist/tsconfig.tsbuildinfo +1 -1
  236. package/dist/types.d.ts +84 -1
  237. package/dist/types.d.ts.map +1 -1
  238. package/dist/types.js.map +1 -1
  239. package/dist/vivid-colors-preference.d.ts +31 -0
  240. package/dist/vivid-colors-preference.d.ts.map +1 -0
  241. package/dist/vivid-colors-preference.js +102 -0
  242. package/dist/vivid-colors-preference.js.map +1 -0
  243. package/package.json +26 -4
@@ -0,0 +1,53 @@
1
+ ---
2
+ import StyleflowElement from "../StyleflowElement.astro";
3
+ import type { FlowpressBlockRendererProps } from "../../block-renderers.js";
4
+
5
+ type LogoImage = { url?: string | undefined; width?: number | undefined; height?: number | undefined; alt?: string } | undefined;
6
+ type LogoData = {
7
+ images?: { positive?: LogoImage | undefined; negative?: LogoImage } | undefined;
8
+ homeUrl?: string | undefined;
9
+ override?: "auto" | "positive" | "negative" | undefined;
10
+ };
11
+
12
+ const { block, styleflowProps, htmlProps } = Astro.props as FlowpressBlockRendererProps;
13
+ const data = (block.resolvedData ?? {}) as LogoData;
14
+ const positive = data.images?.positive ?? {};
15
+ const negative = data.images?.negative ?? {};
16
+ const homeUrl = typeof data.homeUrl === "string" && data.homeUrl ? data.homeUrl : "/";
17
+ const override = data.override === "positive" || data.override === "negative"
18
+ ? data.override
19
+ : "auto";
20
+ const rootHtmlProps = {
21
+ ...htmlProps,
22
+ class: ["flowpress-site-logo", htmlProps.class].filter(Boolean).join(" ")
23
+ };
24
+ ---
25
+
26
+ {positive.url || negative.url ? (
27
+ <StyleflowElement as="a"
28
+ {...rootHtmlProps}
29
+ {...styleflowProps}
30
+ href={homeUrl}
31
+ data-flowpress-logo-override={override === "auto" ? undefined : override}
32
+ aria-label="Home"
33
+ >
34
+ {positive.url ? (
35
+ <img
36
+ class="flowpress-site-logo__image flowpress-site-logo__image--positive"
37
+ src={positive.url}
38
+ width={positive.width || undefined}
39
+ height={positive.height || undefined}
40
+ alt={positive.alt ?? ""}
41
+ />
42
+ ) : null}
43
+ {negative.url ? (
44
+ <img
45
+ class="flowpress-site-logo__image flowpress-site-logo__image--negative"
46
+ src={negative.url}
47
+ width={negative.width || undefined}
48
+ height={negative.height || undefined}
49
+ alt={negative.alt ?? ""}
50
+ />
51
+ ) : null}
52
+ </StyleflowElement>
53
+ ) : null}
@@ -1,5 +1,6 @@
1
1
  ---
2
- import S from "@styleflow.app/astro/S.astro";
2
+ import { decodeFlowpressText } from "../../text.js";
3
+ import StyleflowElement from "../StyleflowElement.astro";
3
4
  import type { FlowpressBlock } from "../../types.js";
4
5
  import type { StyleflowContract } from "../../styleflow.js";
5
6
  import {
@@ -7,15 +8,17 @@ import {
7
8
  preserveEmptyTextBlock,
8
9
  preserveRichTextSpacing,
9
10
  semanticProps,
11
+ textBlockSemanticDefaults,
10
12
  textAlignmentStyle,
11
13
  textValue,
12
14
  unwrapCoreHtml
13
15
  } from "./helpers.js";
16
+ import SemanticElement from "./SemanticElement.astro";
14
17
 
15
18
  interface Props {
16
19
  block: FlowpressBlock;
17
- contract?: StyleflowContract;
18
- hasChildren?: boolean;
20
+ contract?: StyleflowContract | undefined;
21
+ hasChildren?: boolean | undefined;
19
22
  }
20
23
 
21
24
  const { block, contract, hasChildren = false } = Astro.props;
@@ -24,21 +27,9 @@ const attributes = block.attributes;
24
27
  const heading = name === "heading" || name === "core/heading";
25
28
  const level = Math.min(6, Math.max(1, Number(attributes.level ?? 2)));
26
29
  const headingTag = `h${level}` as "h1" | "h2" | "h3" | "h4" | "h5" | "h6";
27
- const defaults = heading
28
- ? {
29
- ty: "heading",
30
- v: String(attributes.v ?? attributes.variant ?? level),
31
- w: String(attributes.w ?? attributes.weight ?? "strong"),
32
- foreground: "primary"
33
- }
34
- : {
35
- ty: "body",
36
- v: String(attributes.v ?? (name.includes("quote") ? "lg" : "md")),
37
- w: String(attributes.w ?? "default"),
38
- foreground: "primary"
39
- };
30
+ const defaults = textBlockSemanticDefaults(name, attributes, contract);
40
31
  const semantic = semanticProps(attributes, contract, defaults);
41
- const htmlAttributes = blockHtmlAttributes(attributes);
32
+ const htmlAttributes = blockHtmlAttributes(attributes, name === "core/list" ? "wp-block-list" : "");
42
33
  const alignmentStyle = textAlignmentStyle(attributes);
43
34
  const coreHtml = String(
44
35
  attributes.content
@@ -60,24 +51,38 @@ const listTag = Boolean(attributes.ordered) ? "ol" : "ul";
60
51
  ---
61
52
 
62
53
  {heading ? (
63
- <S as={headingTag} {...semantic} {...htmlAttributes} style={alignmentStyle} set:html={html} />
54
+ <SemanticElement
55
+ tag={headingTag}
56
+ attributes={{ ...semantic, ...htmlAttributes, style: alignmentStyle }}
57
+ html={html}
58
+ />
64
59
  ) : name === "core/list" ? (
65
- <S as={listTag} {...semantic} {...htmlAttributes} style={alignmentStyle}>
66
- {hasChildren ? <slot /> : <Fragment set:html={html} />}
67
- </S>
60
+ <SemanticElement
61
+ tag={listTag}
62
+ attributes={{ ...semantic, ...htmlAttributes, style: alignmentStyle }}
63
+ html={hasChildren ? undefined : html}
64
+ >
65
+ {hasChildren ? <slot /> : null}
66
+ </SemanticElement>
68
67
  ) : name === "core/list-item" ? (
69
- <S as="li" {...semantic} {...htmlAttributes} style={alignmentStyle}>
68
+ <StyleflowElement as="li" {...semantic} {...htmlAttributes} style={alignmentStyle}>
70
69
  <span set:html={html}></span>
71
70
  {hasChildren ? <slot /> : null}
72
- </S>
71
+ </StyleflowElement>
73
72
  ) : name === "quote" || name === "core/quote" ? (
74
- <S as="blockquote" {...semantic} {...htmlAttributes} style={alignmentStyle}>
73
+ <StyleflowElement as="blockquote" {...semantic} {...htmlAttributes} style={alignmentStyle}>
75
74
  {hasChildren ? <slot /> : <div set:html={html}></div>}
76
- {attributes.citation ? <cite>{String(attributes.citation)}</cite> : null}
77
- </S>
75
+ {attributes.citation ? <cite>{decodeFlowpressText(attributes.citation)}</cite> : null}
76
+ </StyleflowElement>
77
+ ) : name === "core/paragraph" ? (
78
+ <StyleflowElement as="p"
79
+ {...semantic}
80
+ {...htmlAttributes}
81
+ style={alignmentStyle}
82
+ set:html={html}
83
+ />
78
84
  ) : (
79
- <S
80
- as={name === "core/paragraph" ? "p" : "div"}
85
+ <StyleflowElement as="div"
81
86
  {...semantic}
82
87
  {...htmlAttributes}
83
88
  style={alignmentStyle}
@@ -0,0 +1,13 @@
1
+ ---
2
+ import StyleflowElement from "../StyleflowElement.astro";
3
+ import ThemeToggle from "../preferences/ThemeToggle.astro";
4
+ import type { FlowpressBlockRendererProps } from "../../block-renderers.js";
5
+ const { block, styleflowProps, htmlProps } = Astro.props as FlowpressBlockRendererProps;
6
+ const label = typeof block.attributes.label === "string" && block.attributes.label.trim()
7
+ ? block.attributes.label.trim() : "Change color theme";
8
+ const showThemeName = block.attributes.showThemeName !== false;
9
+ ---
10
+ <StyleflowElement as="span" {...styleflowProps} class="flowpress-theme-control">
11
+ <ThemeToggle {...htmlProps} label={label} />
12
+ {showThemeName && <StyleflowElement as="span" data-styleflow-theme-label aria-hidden="true" />}
13
+ </StyleflowElement>
@@ -0,0 +1,13 @@
1
+ import type { FlowpressBlock } from "../../types.js";
2
+ export type CoverBackgroundType = "color" | "image" | "video";
3
+ export type CoverTagName = "article" | "aside" | "div" | "footer" | "header" | "main" | "section";
4
+ export declare function coverTagName(value: unknown): CoverTagName;
5
+ export declare function coverMediaSource(block: FlowpressBlock): string;
6
+ export declare function coverPosterSource(block: FlowpressBlock): string | undefined;
7
+ export declare function coverBackgroundType(block: FlowpressBlock): CoverBackgroundType;
8
+ export declare function coverObjectPosition(value: unknown): string;
9
+ export declare function coverMinimumHeight(value: unknown, unitValue: unknown): string | undefined;
10
+ export declare function coverContentPosition(value: unknown): [string, string];
11
+ export declare function coverScrimEnabled(attributes: Record<string, unknown>): boolean;
12
+ export declare function coverScrimOpacity(attributes: Record<string, unknown>): number;
13
+ //# sourceMappingURL=cover.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cover.d.ts","sourceRoot":"","sources":["../../../src/astro/blocks/cover.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAErD,MAAM,MAAM,mBAAmB,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,CAAC;AAwC9D,MAAM,MAAM,YAAY,GAAG,SAAS,GAAG,OAAO,GAAG,KAAK,GAAG,QAAQ,GAAG,QAAQ,GAAG,MAAM,GAAG,SAAS,CAAC;AAClG,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,YAAY,CAGzD;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,cAAc,GAAG,MAAM,CAE9D;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,cAAc,GAAG,MAAM,GAAG,SAAS,CAI3E;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,cAAc,GAAG,mBAAmB,CAK9E;AAUD,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAQ1D;AAED,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,OAAO,EACd,SAAS,EAAE,OAAO,GACjB,MAAM,GAAG,SAAS,CAMpB;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAGrE;AAED,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAM9E;AAQD,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAK7E"}
@@ -0,0 +1,105 @@
1
+ const COVER_TAGS = new Set([
2
+ "article",
3
+ "aside",
4
+ "div",
5
+ "footer",
6
+ "header",
7
+ "main",
8
+ "section"
9
+ ]);
10
+ const HEIGHT_UNITS = new Set([
11
+ "px",
12
+ "%",
13
+ "em",
14
+ "rem",
15
+ "vh",
16
+ "svh",
17
+ "lvh",
18
+ "dvh",
19
+ "vw"
20
+ ]);
21
+ const CONTENT_POSITIONS = {
22
+ "top left": ["start", "start"],
23
+ "top center": ["start", "center"],
24
+ "top right": ["start", "end"],
25
+ "center left": ["center", "start"],
26
+ "center center": ["center", "center"],
27
+ "center right": ["center", "end"],
28
+ "bottom left": ["end", "start"],
29
+ "bottom center": ["end", "center"],
30
+ "bottom right": ["end", "end"]
31
+ };
32
+ function text(value) {
33
+ return typeof value === "string" ? value.trim() : "";
34
+ }
35
+ export function coverTagName(value) {
36
+ const candidate = text(value).toLowerCase();
37
+ return COVER_TAGS.has(candidate) ? candidate : "div";
38
+ }
39
+ export function coverMediaSource(block) {
40
+ return text(block.attributes.url) || text(block.resolvedData?.url);
41
+ }
42
+ export function coverPosterSource(block) {
43
+ return text(block.attributes.poster)
44
+ || text(block.resolvedData?.poster)
45
+ || undefined;
46
+ }
47
+ export function coverBackgroundType(block) {
48
+ const requested = text(block.attributes.backgroundType).toLowerCase();
49
+ if (requested === "video")
50
+ return "video";
51
+ if (requested === "color")
52
+ return "color";
53
+ return coverMediaSource(block) ? "image" : "color";
54
+ }
55
+ function percentage(value) {
56
+ const numeric = typeof value === "number" ? value : Number(value);
57
+ if (!Number.isFinite(numeric))
58
+ return undefined;
59
+ if (numeric >= 0 && numeric <= 1)
60
+ return numeric * 100;
61
+ if (numeric >= 0 && numeric <= 100)
62
+ return numeric;
63
+ return undefined;
64
+ }
65
+ export function coverObjectPosition(value) {
66
+ if (!value || typeof value !== "object" || Array.isArray(value)) {
67
+ return "50% 50%";
68
+ }
69
+ const focalPoint = value;
70
+ const x = percentage(focalPoint.x);
71
+ const y = percentage(focalPoint.y);
72
+ return x === undefined || y === undefined ? "50% 50%" : `${x}% ${y}%`;
73
+ }
74
+ export function coverMinimumHeight(value, unitValue) {
75
+ const numeric = typeof value === "number" ? value : Number(value);
76
+ if (!Number.isFinite(numeric) || numeric < 0)
77
+ return undefined;
78
+ const requestedUnit = text(unitValue).toLowerCase();
79
+ const unit = HEIGHT_UNITS.has(requestedUnit) ? requestedUnit : "px";
80
+ return `${numeric}${unit}`;
81
+ }
82
+ export function coverContentPosition(value) {
83
+ return CONTENT_POSITIONS[text(value).toLowerCase()]
84
+ ?? ["center", "center"];
85
+ }
86
+ export function coverScrimEnabled(attributes) {
87
+ if (typeof attributes.scrimEnabled === "boolean") {
88
+ return attributes.scrimEnabled;
89
+ }
90
+ const nativeDimRatio = Number(attributes.dimRatio);
91
+ return Number.isFinite(nativeDimRatio) && nativeDimRatio > 0;
92
+ }
93
+ function clampedPercentage(value) {
94
+ const numeric = typeof value === "number" ? value : Number(value);
95
+ if (!Number.isFinite(numeric))
96
+ return undefined;
97
+ return Math.min(100, Math.max(0, numeric));
98
+ }
99
+ export function coverScrimOpacity(attributes) {
100
+ const explicitOpacity = clampedPercentage(attributes.scrimOpacity);
101
+ if (explicitOpacity !== undefined)
102
+ return explicitOpacity;
103
+ return clampedPercentage(attributes.dimRatio) ?? 100;
104
+ }
105
+ //# sourceMappingURL=cover.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cover.js","sourceRoot":"","sources":["../../../src/astro/blocks/cover.ts"],"names":[],"mappings":"AAIA,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC;IACzB,SAAS;IACT,OAAO;IACP,KAAK;IACL,QAAQ;IACR,QAAQ;IACR,MAAM;IACN,SAAS;CACV,CAAC,CAAC;AAEH,MAAM,YAAY,GAAG,IAAI,GAAG,CAAC;IAC3B,IAAI;IACJ,GAAG;IACH,IAAI;IACJ,KAAK;IACL,IAAI;IACJ,KAAK;IACL,KAAK;IACL,KAAK;IACL,IAAI;CACL,CAAC,CAAC;AAEH,MAAM,iBAAiB,GAAqC;IAC1D,UAAU,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC;IAC9B,YAAY,EAAE,CAAC,OAAO,EAAE,QAAQ,CAAC;IACjC,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AC,CAAC;AAC7C,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,UAAmC;IACnE,MAAM,eAAe,GAAG,iBAAiB,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC;IACnE,IAAI,eAAe,KAAK,SAAS;QAAE,OAAO,eAAe,CAAC;IAE1D,OAAO,iBAAiB,CAAC,UAAU,CAAC,QAAQ,CAAC,IAAI,GAAG,CAAC;AACvD,CAAC","sourcesContent":["import type { FlowpressBlock } from \"../../types.js\";\n\nexport type CoverBackgroundType = \"color\" | \"image\" | \"video\";\n\nconst COVER_TAGS = new Set([\n \"article\",\n \"aside\",\n \"div\",\n \"footer\",\n \"header\",\n \"main\",\n \"section\"\n]);\n\nconst HEIGHT_UNITS = new Set([\n \"px\",\n \"%\",\n \"em\",\n \"rem\",\n \"vh\",\n \"svh\",\n \"lvh\",\n \"dvh\",\n \"vw\"\n]);\n\nconst CONTENT_POSITIONS: Record<string, [string, string]> = {\n \"top left\": [\"start\", \"start\"],\n \"top center\": [\"start\", \"center\"],\n \"top right\": [\"start\", \"end\"],\n \"center left\": [\"center\", \"start\"],\n \"center center\": [\"center\", \"center\"],\n \"center right\": [\"center\", \"end\"],\n \"bottom left\": [\"end\", \"start\"],\n \"bottom center\": [\"end\", \"center\"],\n \"bottom right\": [\"end\", \"end\"]\n};\n\nfunction text(value: unknown): string {\n return typeof value === \"string\" ? value.trim() : \"\";\n}\n\nexport type CoverTagName = \"article\" | \"aside\" | \"div\" | \"footer\" | \"header\" | \"main\" | \"section\";\nexport function coverTagName(value: unknown): CoverTagName {\n const candidate = text(value).toLowerCase();\n return COVER_TAGS.has(candidate) ? candidate as CoverTagName : \"div\";\n}\n\nexport function coverMediaSource(block: FlowpressBlock): string {\n return text(block.attributes.url) || text(block.resolvedData?.url);\n}\n\nexport function coverPosterSource(block: FlowpressBlock): string | undefined {\n return text(block.attributes.poster)\n || text(block.resolvedData?.poster)\n || undefined;\n}\n\nexport function coverBackgroundType(block: FlowpressBlock): CoverBackgroundType {\n const requested = text(block.attributes.backgroundType).toLowerCase();\n if (requested === \"video\") return \"video\";\n if (requested === \"color\") return \"color\";\n return coverMediaSource(block) ? \"image\" : \"color\";\n}\n\nfunction percentage(value: unknown): number | undefined {\n const numeric = typeof value === \"number\" ? value : Number(value);\n if (!Number.isFinite(numeric)) return undefined;\n if (numeric >= 0 && numeric <= 1) return numeric * 100;\n if (numeric >= 0 && numeric <= 100) return numeric;\n return undefined;\n}\n\nexport function coverObjectPosition(value: unknown): string {\n if (!value || typeof value !== \"object\" || Array.isArray(value)) {\n return \"50% 50%\";\n }\n const focalPoint = value as Record<string, unknown>;\n const x = percentage(focalPoint.x);\n const y = percentage(focalPoint.y);\n return x === undefined || y === undefined ? \"50% 50%\" : `${x}% ${y}%`;\n}\n\nexport function coverMinimumHeight(\n value: unknown,\n unitValue: unknown\n): string | undefined {\n const numeric = typeof value === \"number\" ? value : Number(value);\n if (!Number.isFinite(numeric) || numeric < 0) return undefined;\n const requestedUnit = text(unitValue).toLowerCase();\n const unit = HEIGHT_UNITS.has(requestedUnit) ? requestedUnit : \"px\";\n return `${numeric}${unit}`;\n}\n\nexport function coverContentPosition(value: unknown): [string, string] {\n return CONTENT_POSITIONS[text(value).toLowerCase()]\n ?? [\"center\", \"center\"];\n}\n\nexport function coverScrimEnabled(attributes: Record<string, unknown>): boolean {\n if (typeof attributes.scrimEnabled === \"boolean\") {\n return attributes.scrimEnabled;\n }\n const nativeDimRatio = Number(attributes.dimRatio);\n return Number.isFinite(nativeDimRatio) && nativeDimRatio > 0;\n}\n\nfunction clampedPercentage(value: unknown): number | undefined {\n const numeric = typeof value === \"number\" ? value : Number(value);\n if (!Number.isFinite(numeric)) return undefined;\n return Math.min(100, Math.max(0, numeric));\n}\n\nexport function coverScrimOpacity(attributes: Record<string, unknown>): number {\n const explicitOpacity = clampedPercentage(attributes.scrimOpacity);\n if (explicitOpacity !== undefined) return explicitOpacity;\n\n return clampedPercentage(attributes.dimRatio) ?? 100;\n}\n"]}
@@ -0,0 +1,119 @@
1
+ import type { FlowpressBlock } from "../../types.js";
2
+
3
+ export type CoverBackgroundType = "color" | "image" | "video";
4
+
5
+ const COVER_TAGS = new Set([
6
+ "article",
7
+ "aside",
8
+ "div",
9
+ "footer",
10
+ "header",
11
+ "main",
12
+ "section"
13
+ ]);
14
+
15
+ const HEIGHT_UNITS = new Set([
16
+ "px",
17
+ "%",
18
+ "em",
19
+ "rem",
20
+ "vh",
21
+ "svh",
22
+ "lvh",
23
+ "dvh",
24
+ "vw"
25
+ ]);
26
+
27
+ const CONTENT_POSITIONS: Record<string, [string, string]> = {
28
+ "top left": ["start", "start"],
29
+ "top center": ["start", "center"],
30
+ "top right": ["start", "end"],
31
+ "center left": ["center", "start"],
32
+ "center center": ["center", "center"],
33
+ "center right": ["center", "end"],
34
+ "bottom left": ["end", "start"],
35
+ "bottom center": ["end", "center"],
36
+ "bottom right": ["end", "end"]
37
+ };
38
+
39
+ function text(value: unknown): string {
40
+ return typeof value === "string" ? value.trim() : "";
41
+ }
42
+
43
+ export type CoverTagName = "article" | "aside" | "div" | "footer" | "header" | "main" | "section";
44
+ export function coverTagName(value: unknown): CoverTagName {
45
+ const candidate = text(value).toLowerCase();
46
+ return COVER_TAGS.has(candidate) ? candidate as CoverTagName : "div";
47
+ }
48
+
49
+ export function coverMediaSource(block: FlowpressBlock): string {
50
+ return text(block.attributes.url) || text(block.resolvedData?.url);
51
+ }
52
+
53
+ export function coverPosterSource(block: FlowpressBlock): string | undefined {
54
+ return text(block.attributes.poster)
55
+ || text(block.resolvedData?.poster)
56
+ || undefined;
57
+ }
58
+
59
+ export function coverBackgroundType(block: FlowpressBlock): CoverBackgroundType {
60
+ const requested = text(block.attributes.backgroundType).toLowerCase();
61
+ if (requested === "video") return "video";
62
+ if (requested === "color") return "color";
63
+ return coverMediaSource(block) ? "image" : "color";
64
+ }
65
+
66
+ function percentage(value: unknown): number | undefined {
67
+ const numeric = typeof value === "number" ? value : Number(value);
68
+ if (!Number.isFinite(numeric)) return undefined;
69
+ if (numeric >= 0 && numeric <= 1) return numeric * 100;
70
+ if (numeric >= 0 && numeric <= 100) return numeric;
71
+ return undefined;
72
+ }
73
+
74
+ export function coverObjectPosition(value: unknown): string {
75
+ if (!value || typeof value !== "object" || Array.isArray(value)) {
76
+ return "50% 50%";
77
+ }
78
+ const focalPoint = value as Record<string, unknown>;
79
+ const x = percentage(focalPoint.x);
80
+ const y = percentage(focalPoint.y);
81
+ return x === undefined || y === undefined ? "50% 50%" : `${x}% ${y}%`;
82
+ }
83
+
84
+ export function coverMinimumHeight(
85
+ value: unknown,
86
+ unitValue: unknown
87
+ ): string | undefined {
88
+ const numeric = typeof value === "number" ? value : Number(value);
89
+ if (!Number.isFinite(numeric) || numeric < 0) return undefined;
90
+ const requestedUnit = text(unitValue).toLowerCase();
91
+ const unit = HEIGHT_UNITS.has(requestedUnit) ? requestedUnit : "px";
92
+ return `${numeric}${unit}`;
93
+ }
94
+
95
+ export function coverContentPosition(value: unknown): [string, string] {
96
+ return CONTENT_POSITIONS[text(value).toLowerCase()]
97
+ ?? ["center", "center"];
98
+ }
99
+
100
+ export function coverScrimEnabled(attributes: Record<string, unknown>): boolean {
101
+ if (typeof attributes.scrimEnabled === "boolean") {
102
+ return attributes.scrimEnabled;
103
+ }
104
+ const nativeDimRatio = Number(attributes.dimRatio);
105
+ return Number.isFinite(nativeDimRatio) && nativeDimRatio > 0;
106
+ }
107
+
108
+ function clampedPercentage(value: unknown): number | undefined {
109
+ const numeric = typeof value === "number" ? value : Number(value);
110
+ if (!Number.isFinite(numeric)) return undefined;
111
+ return Math.min(100, Math.max(0, numeric));
112
+ }
113
+
114
+ export function coverScrimOpacity(attributes: Record<string, unknown>): number {
115
+ const explicitOpacity = clampedPercentage(attributes.scrimOpacity);
116
+ if (explicitOpacity !== undefined) return explicitOpacity;
117
+
118
+ return clampedPercentage(attributes.dimRatio) ?? 100;
119
+ }
@@ -13,6 +13,13 @@ export declare function blockHtmlAttributes(attributes: Record<string, unknown>,
13
13
  };
14
14
  export declare const TEXT_HTML_TAGS: readonly ["span", "p", "h1", "h2", "h3", "h4", "h5", "h6", "strong", "em", "small", "mark"];
15
15
  export type TextHtmlTag = (typeof TEXT_HTML_TAGS)[number];
16
+ /**
17
+ * Derive a variant only when Gutenberg omitted it. The selected typography
18
+ * type can differ from the block's native type, so a paragraph styled as a
19
+ * heading must not inherit the paragraph-only `md` variant.
20
+ */
21
+ export declare function compatibleTypographyVariant(type: string, preferred: string, contract?: StyleflowContract): string;
22
+ export declare function textBlockSemanticDefaults(blockName: string, attributes: Record<string, unknown>, contract?: StyleflowContract): Record<string, unknown>;
16
23
  export declare function textHtmlTag(value: unknown): TextHtmlTag;
17
24
  export declare function semanticProps(attributes: Record<string, unknown>, contract?: StyleflowContract, defaults?: Record<string, unknown>): Record<string, unknown>;
18
25
  /** Resolve only Gutenberg's supported text-alignment values to inline CSS. */
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../src/astro/blocks/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,iBAAiB,EACvB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAErD,eAAO,MAAM,sBAAsB;;;;CAIlC,CAAC;AAEF,eAAO,MAAM,4BAA4B,YAAY,CAAC;AAEtD,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAmBzD;AAED,wBAAgB,mBAAmB,CACjC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACnC,SAAS,SAAK,GACb;IAAE,EAAE,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAgBjC;AAsBD,eAAO,MAAM,cAAc,6FAajB,CAAC;AAEX,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,CAAC,CAAC;AAE1D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Ac,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAKnD"}
@@ -1,4 +1,5 @@
1
- import { resolveDynamicStyleflowProps } from "../../styleflow.js";
1
+ import { resolveFlowpressBlockStyleflowProps } from "../../styleflow.js";
2
+ import { flowpressLinkHref } from "../../links.js";
2
3
  export const DEFAULT_SEMANTIC_PROPS = {
3
4
  surface: "default",
4
5
  layoutRole: "stack",
@@ -35,25 +36,6 @@ export function blockHtmlAttributes(attributes, baseClass = "") {
35
36
  ...(className ? { class: className } : {})
36
37
  };
37
38
  }
38
- const SEMANTIC_KEYS = [
39
- "theme",
40
- "tone",
41
- "intensity",
42
- "surface",
43
- "layoutRole",
44
- "density",
45
- "ty",
46
- "v",
47
- "w",
48
- "foreground",
49
- "interactivePriority",
50
- "noBackground",
51
- "noBorder",
52
- "noPadding",
53
- "noGap",
54
- "noRadius",
55
- "noForeground"
56
- ];
57
39
  export const TEXT_HTML_TAGS = [
58
40
  "span",
59
41
  "p",
@@ -68,6 +50,51 @@ export const TEXT_HTML_TAGS = [
68
50
  "small",
69
51
  "mark"
70
52
  ];
53
+ function preferredTypographyVariant(type) {
54
+ if (type === "heading")
55
+ return "2";
56
+ if (type === "body" || type === "label" || type === "code")
57
+ return "md";
58
+ return undefined;
59
+ }
60
+ /**
61
+ * Derive a variant only when Gutenberg omitted it. The selected typography
62
+ * type can differ from the block's native type, so a paragraph styled as a
63
+ * heading must not inherit the paragraph-only `md` variant.
64
+ */
65
+ export function compatibleTypographyVariant(type, preferred, contract) {
66
+ const variants = contract?.semantic.axes.typography.variantsByType[type];
67
+ if (!variants?.length)
68
+ return preferred;
69
+ return [
70
+ preferredTypographyVariant(type),
71
+ preferred,
72
+ contract?.semantic.agentPolicy.defaults.typography.ty === type
73
+ ? contract.semantic.agentPolicy.defaults.typography.v
74
+ : undefined,
75
+ variants[0]
76
+ ].find((candidate) => (typeof candidate === "string" && variants.includes(candidate))) ?? preferred;
77
+ }
78
+ export function textBlockSemanticDefaults(blockName, attributes, contract) {
79
+ const name = blockName.replace(/^sf\//, "");
80
+ const heading = name === "heading" || name === "core/heading";
81
+ const level = Math.min(6, Math.max(1, Number(attributes.level ?? 2)));
82
+ const defaultType = heading ? "heading" : "body";
83
+ const authored = (...values) => values.find((value) => value !== undefined && value !== null && value !== "");
84
+ const activeType = String(authored(attributes.ty) ?? defaultType);
85
+ const nativeVariant = heading
86
+ ? String(level)
87
+ : name.includes("quote") ? "lg" : "md";
88
+ const authoredVariant = authored(attributes.v, attributes.variant);
89
+ return {
90
+ ty: defaultType,
91
+ v: authoredVariant === undefined
92
+ ? compatibleTypographyVariant(activeType, nativeVariant, contract)
93
+ : String(authoredVariant),
94
+ w: String(authored(attributes.w, attributes.weight) ?? (heading ? "strong" : "default")),
95
+ foreground: "primary"
96
+ };
97
+ }
71
98
  export function textHtmlTag(value) {
72
99
  const candidate = String(value ?? "span");
73
100
  return TEXT_HTML_TAGS.includes(candidate)
@@ -75,22 +102,10 @@ export function textHtmlTag(value) {
75
102
  : "span";
76
103
  }
77
104
  export function semanticProps(attributes, contract, defaults = DEFAULT_SEMANTIC_PROPS) {
78
- const input = Object.fromEntries(SEMANTIC_KEYS
79
- .filter((key) => attributes[key] !== undefined)
80
- .map((key) => [key, attributes[key]]));
81
- if (contract) {
82
- return resolveDynamicStyleflowProps(input, defaults, contract, {
83
- strict: process.env.NODE_ENV === "production" || process.env.STYLEFLOW_STRICT === "1",
84
- onDiagnostic: (diagnostic) => console.warn(`[${diagnostic.code}] ${diagnostic.message}`)
85
- });
86
- }
87
- const resolved = { ...defaults, ...input };
88
- for (const key of ["tone", "intensity", "foreground"]) {
89
- if (input[key] === "inherit") {
90
- delete resolved[key];
91
- }
92
- }
93
- return resolved;
105
+ return resolveFlowpressBlockStyleflowProps(attributes, contract, defaults, {
106
+ strict: process.env.NODE_ENV === "production" || process.env.STYLEFLOW_STRICT === "1",
107
+ onDiagnostic: (diagnostic) => console.warn(`[${diagnostic.code}] ${diagnostic.message}`)
108
+ });
94
109
  }
95
110
  const TEXT_ALIGNMENTS = new Set([
96
111
  "left",
@@ -156,11 +171,7 @@ export function preserveEmptyTextBlock(html) {
156
171
  return html.trim() === "" ? "&nbsp;" : html;
157
172
  }
158
173
  export function linkValue(block, key = "link") {
159
- const value = block.attributes[key];
160
- const href = typeof value === "string"
161
- ? value
162
- : String(objectValue(block, key).url ?? "");
163
- return /^(?:\/(?!\/)|#|https?:\/\/|mailto:|tel:)/i.test(href) ? href : "";
174
+ return flowpressLinkHref(block.attributes[key]);
164
175
  }
165
176
  export function responsiveValues(attributes, prefix, fallback) {
166
177
  const keys = ["base", "sm", "md", "lg", "xl", "2xl"];