@activecollab/components 2.0.414 → 2.0.416
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.
- package/dist/cjs/components/Media/Media.js.map +1 -1
- package/dist/cjs/components/PortableText/Styles.js +20 -2
- package/dist/cjs/components/PortableText/Styles.js.map +1 -1
- package/dist/cjs/components/PortableText/renderers.js +20 -4
- package/dist/cjs/components/PortableText/renderers.js.map +1 -1
- package/dist/cjs/components/PortableText/types.js +39 -3
- package/dist/cjs/components/PortableText/types.js.map +1 -1
- package/dist/cjs/components/PortableText/types.test.js +137 -0
- package/dist/cjs/components/PortableText/types.test.js.map +1 -1
- package/dist/cjs/presentation/shared/FeatureAvailability.js +217 -0
- package/dist/cjs/presentation/shared/FeatureAvailability.js.map +1 -0
- package/dist/cjs/presentation/shared/MessageDialog.js.map +1 -1
- package/dist/cjs/presentation/shared/index.js +16 -1
- package/dist/cjs/presentation/shared/index.js.map +1 -1
- package/dist/esm/components/Media/Media.d.ts +3 -2
- package/dist/esm/components/Media/Media.d.ts.map +1 -1
- package/dist/esm/components/Media/Media.js.map +1 -1
- package/dist/esm/components/PortableText/Styles.d.ts +19 -1
- package/dist/esm/components/PortableText/Styles.d.ts.map +1 -1
- package/dist/esm/components/PortableText/Styles.js +20 -2
- package/dist/esm/components/PortableText/Styles.js.map +1 -1
- package/dist/esm/components/PortableText/renderers.d.ts.map +1 -1
- package/dist/esm/components/PortableText/renderers.js +20 -4
- package/dist/esm/components/PortableText/renderers.js.map +1 -1
- package/dist/esm/components/PortableText/types.d.ts +16 -2
- package/dist/esm/components/PortableText/types.d.ts.map +1 -1
- package/dist/esm/components/PortableText/types.js +32 -2
- package/dist/esm/components/PortableText/types.js.map +1 -1
- package/dist/esm/components/PortableText/types.test.js +138 -1
- package/dist/esm/components/PortableText/types.test.js.map +1 -1
- package/dist/esm/presentation/shared/FeatureAvailability.d.ts +52 -0
- package/dist/esm/presentation/shared/FeatureAvailability.d.ts.map +1 -0
- package/dist/esm/presentation/shared/FeatureAvailability.js +203 -0
- package/dist/esm/presentation/shared/FeatureAvailability.js.map +1 -0
- package/dist/esm/presentation/shared/MessageDialog.d.ts.map +1 -1
- package/dist/esm/presentation/shared/MessageDialog.js.map +1 -1
- package/dist/esm/presentation/shared/index.d.ts +2 -0
- package/dist/esm/presentation/shared/index.d.ts.map +1 -1
- package/dist/esm/presentation/shared/index.js +1 -0
- package/dist/esm/presentation/shared/index.js.map +1 -1
- package/dist/index.js +210 -140
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Media.js","names":["_react","_interopRequireWildcard","require","_Styles","_Typography","_excluded","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","_t","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","_extends","assign","bind","arguments","length","apply","_objectWithoutProperties","_objectWithoutPropertiesLoose","getOwnPropertySymbols","indexOf","propertyIsEnumerable","Media","exports","forwardRef","_ref","ref","src","alt","_ref$variant","variant","caption","rest","createElement","StyledMedia","$bordered","className","Caption1","color","displayName"],"sources":["../../../../src/components/Media/Media.tsx"],"sourcesContent":["import React, { forwardRef } from \"react\";\n\nimport { StyledMedia } from \"./Styles\";\nimport {
|
|
1
|
+
{"version":3,"file":"Media.js","names":["_react","_interopRequireWildcard","require","_Styles","_Typography","_excluded","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","_t","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","_extends","assign","bind","arguments","length","apply","_objectWithoutProperties","_objectWithoutPropertiesLoose","getOwnPropertySymbols","indexOf","propertyIsEnumerable","Media","exports","forwardRef","_ref","ref","src","alt","_ref$variant","variant","caption","rest","createElement","StyledMedia","$bordered","className","Caption1","color","displayName"],"sources":["../../../../src/components/Media/Media.tsx"],"sourcesContent":["import React, { forwardRef } from \"react\";\n\nimport { StyledMedia } from \"./Styles\";\nimport {\n PortableTextMediaBlock,\n PortableTextMediaImageVariant,\n} from \"../PortableText/types\";\nimport { Caption1 } from \"../Typography\";\n\nexport interface IMediaProps\n extends Omit<PortableTextMediaBlock, \"type\" | \"variant\">,\n React.ComponentPropsWithoutRef<\"div\"> {\n variant?: PortableTextMediaImageVariant;\n}\n\n/**\n * An image block: a screenshot renders framed (border, no shadow), a flat\n * illustration renders without a frame. The caption sits below the frame.\n */\nexport const Media = forwardRef<HTMLDivElement, IMediaProps>(\n ({ src, alt, variant = \"illustration\", caption, ...rest }, ref) => (\n <StyledMedia ref={ref} $bordered={variant === \"screenshot\"} {...rest}>\n <div className=\"c-media-frame\">\n <img src={src} alt={alt ?? \"\"} />\n </div>\n {caption ? <Caption1 color=\"secondary\">{caption}</Caption1> : null}\n </StyledMedia>\n )\n);\n\nMedia.displayName = \"Media\";\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAEA,IAAAC,OAAA,GAAAD,OAAA;AAKA,IAAAE,WAAA,GAAAF,OAAA;AAAyC,IAAAG,SAAA;AAAA,SAAAJ,wBAAAK,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAP,uBAAA,YAAAA,wBAAAK,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAAA,GAAAM,CAAA,CAAAO,GAAA,CA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A,CAAAgD,QAAQ;IAACC,KAAK,EAAC;EAAW,GAAEP,OAAkB,CAAC,GAAG,IACnD,CAAC;AAAA,CAElB,CAAC;AAEDT,KAAK,CAACiB,WAAW,GAAG,OAAO","ignoreList":[]}
|
|
@@ -50,11 +50,29 @@ var StyledDivider = exports.StyledDivider = _styledComponents.default.hr.withCon
|
|
|
50
50
|
})(["margin:0;border:none;border-top:1px solid var(--border-primary);"]);
|
|
51
51
|
StyledDivider.displayName = "StyledDivider";
|
|
52
52
|
|
|
53
|
-
/**
|
|
53
|
+
/**
|
|
54
|
+
* The default `list` block; rendered as ul or ol through the `as` prop, and
|
|
55
|
+
* tagged `data-portable-list` so the depth rules below scope to design-system
|
|
56
|
+
* lists — a stray `<ul>`/`<ol>` from an injected renderer is left untouched.
|
|
57
|
+
*
|
|
58
|
+
* Nesting works structurally: each level is its own StyledList inside a parent
|
|
59
|
+
* `<li>`, so it re-applies its own `padding-left` (indentation compounds) and,
|
|
60
|
+
* for ordered levels, restarts numbering. A nested list carries no vertical
|
|
61
|
+
* margin, so it hugs the item it belongs to.
|
|
62
|
+
*
|
|
63
|
+
* Both bullet and numbered levels change their marker by nesting depth, so
|
|
64
|
+
* levels stay distinct even where the two interleave:
|
|
65
|
+
* bullets disc → circle → square → (disc)
|
|
66
|
+
* numbers decimal → lower-alpha → lower-roman → (upper-alpha)
|
|
67
|
+
* Depth is counted from the list ancestors themselves (not per-tag), so an
|
|
68
|
+
* intervening `<ol>` never throws off a `<ul>`'s depth and vice-versa. The
|
|
69
|
+
* rules are ordered shallow-to-deep; a deeper rule is more specific, so it
|
|
70
|
+
* wins the cascade for the levels it applies to.
|
|
71
|
+
*/
|
|
54
72
|
var StyledList = exports.StyledList = _styledComponents.default.ul.withConfig({
|
|
55
73
|
displayName: "Styles__StyledList",
|
|
56
74
|
componentId: "sc-1fss4z4-5"
|
|
57
|
-
})(["margin:0;padding-left:", ";list-style:", " outside;li + li{margin-top:", ";}"], "1.25rem", function (_ref) {
|
|
75
|
+
})(["margin:0;padding-left:", ";list-style:", " outside;li + li{margin-top:", ";}& ul[data-portable-list]{list-style-type:circle;}& ol[data-portable-list]{list-style-type:lower-alpha;}& [data-portable-list] ul[data-portable-list]{list-style-type:square;}& [data-portable-list] ol[data-portable-list]{list-style-type:lower-roman;}& [data-portable-list] [data-portable-list] ul[data-portable-list]{list-style-type:disc;}& [data-portable-list] [data-portable-list] ol[data-portable-list]{list-style-type:upper-alpha;}"], "1.25rem", function (_ref) {
|
|
58
76
|
var $ordered = _ref.$ordered;
|
|
59
77
|
return $ordered ? "decimal" : "disc";
|
|
60
78
|
}, _LayoutTokens.SPACE.xs);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Styles.js","names":["_styledComponents","_interopRequireDefault","require","_LayoutTokens","e","__esModule","default","StyledCode","exports","styled","code","withConfig","displayName","componentId","StyledLink","a","StyledCodeBlock","pre","SPACE","md","StyledTableBlock","div","StyledDivider","hr","StyledList","ul","_ref","$ordered","xs"],"sources":["../../../../src/components/PortableText/Styles.ts"],"sourcesContent":["import styled from \"styled-components\";\nimport { theme } from \"twin.macro\";\n\nimport { SPACE } from \"../LayoutTokens\";\n\n/** The default `code` mark: a quiet inline chip that keeps the line intact. */\nexport const StyledCode = styled.code`\n padding: 0 ${theme(\"spacing.1\")};\n border-radius: ${theme(\"borderRadius.DEFAULT\")};\n background-color: var(--color-theme-300);\n font-family: \"SFMono-Regular\", Menlo, Consolas, \"Liberation Mono\", monospace;\n font-size: 0.85em;\n`;\n\nStyledCode.displayName = \"StyledCode\";\n\n/** The default `link` mark: an inline text link inside flowing content. */\nexport const StyledLink = styled.a`\n color: var(--color-primary);\n text-decoration: underline var(--color-primary);\n text-underline-offset: 3px;\n\n &:hover {\n text-decoration: none;\n }\n`;\n\nStyledLink.displayName = \"StyledLink\";\n\n/**\n * The default `code-block`: quiet preformatted content. It stays a bare\n * `<pre><code>` on purpose — article surfaces inject a Copy button onto\n * every `<pre>` they render.\n */\nexport const StyledCodeBlock = styled.pre`\n margin: 0;\n padding: ${SPACE.md};\n border-radius: ${theme(\"borderRadius.lg\")};\n background-color: var(--color-theme-200);\n overflow-x: auto;\n\n code {\n font-family: \"SFMono-Regular\", Menlo, Consolas, \"Liberation Mono\", monospace;\n font-size: ${theme(\"fontSize.body-2\")};\n color: var(--color-theme-900);\n }\n`;\n\nStyledCodeBlock.displayName = \"StyledCodeBlock\";\n\n/**\n * The default `table` block wrapper: Table ships page-level chrome (outer\n * margins) that flowing content does not want — the PortableText Stack owns\n * the vertical rhythm here.\n */\nexport const StyledTableBlock = styled.div`\n .c-table__wrap {\n margin: 0;\n }\n`;\n\nStyledTableBlock.displayName = \"StyledTableBlock\";\n\n/** The default `divider` block: a themed horizontal rule. */\nexport const StyledDivider = styled.hr`\n margin: 0;\n border: none;\n border-top: 1px solid var(--border-primary);\n`;\n\nStyledDivider.displayName = \"StyledDivider\";\n\n
|
|
1
|
+
{"version":3,"file":"Styles.js","names":["_styledComponents","_interopRequireDefault","require","_LayoutTokens","e","__esModule","default","StyledCode","exports","styled","code","withConfig","displayName","componentId","StyledLink","a","StyledCodeBlock","pre","SPACE","md","StyledTableBlock","div","StyledDivider","hr","StyledList","ul","_ref","$ordered","xs"],"sources":["../../../../src/components/PortableText/Styles.ts"],"sourcesContent":["import styled from \"styled-components\";\nimport { theme } from \"twin.macro\";\n\nimport { SPACE } from \"../LayoutTokens\";\n\n/** The default `code` mark: a quiet inline chip that keeps the line intact. */\nexport const StyledCode = styled.code`\n padding: 0 ${theme(\"spacing.1\")};\n border-radius: ${theme(\"borderRadius.DEFAULT\")};\n background-color: var(--color-theme-300);\n font-family: \"SFMono-Regular\", Menlo, Consolas, \"Liberation Mono\", monospace;\n font-size: 0.85em;\n`;\n\nStyledCode.displayName = \"StyledCode\";\n\n/** The default `link` mark: an inline text link inside flowing content. */\nexport const StyledLink = styled.a`\n color: var(--color-primary);\n text-decoration: underline var(--color-primary);\n text-underline-offset: 3px;\n\n &:hover {\n text-decoration: none;\n }\n`;\n\nStyledLink.displayName = \"StyledLink\";\n\n/**\n * The default `code-block`: quiet preformatted content. It stays a bare\n * `<pre><code>` on purpose — article surfaces inject a Copy button onto\n * every `<pre>` they render.\n */\nexport const StyledCodeBlock = styled.pre`\n margin: 0;\n padding: ${SPACE.md};\n border-radius: ${theme(\"borderRadius.lg\")};\n background-color: var(--color-theme-200);\n overflow-x: auto;\n\n code {\n font-family: \"SFMono-Regular\", Menlo, Consolas, \"Liberation Mono\", monospace;\n font-size: ${theme(\"fontSize.body-2\")};\n color: var(--color-theme-900);\n }\n`;\n\nStyledCodeBlock.displayName = \"StyledCodeBlock\";\n\n/**\n * The default `table` block wrapper: Table ships page-level chrome (outer\n * margins) that flowing content does not want — the PortableText Stack owns\n * the vertical rhythm here.\n */\nexport const StyledTableBlock = styled.div`\n .c-table__wrap {\n margin: 0;\n }\n`;\n\nStyledTableBlock.displayName = \"StyledTableBlock\";\n\n/** The default `divider` block: a themed horizontal rule. */\nexport const StyledDivider = styled.hr`\n margin: 0;\n border: none;\n border-top: 1px solid var(--border-primary);\n`;\n\nStyledDivider.displayName = \"StyledDivider\";\n\n/**\n * The default `list` block; rendered as ul or ol through the `as` prop, and\n * tagged `data-portable-list` so the depth rules below scope to design-system\n * lists — a stray `<ul>`/`<ol>` from an injected renderer is left untouched.\n *\n * Nesting works structurally: each level is its own StyledList inside a parent\n * `<li>`, so it re-applies its own `padding-left` (indentation compounds) and,\n * for ordered levels, restarts numbering. A nested list carries no vertical\n * margin, so it hugs the item it belongs to.\n *\n * Both bullet and numbered levels change their marker by nesting depth, so\n * levels stay distinct even where the two interleave:\n * bullets disc → circle → square → (disc)\n * numbers decimal → lower-alpha → lower-roman → (upper-alpha)\n * Depth is counted from the list ancestors themselves (not per-tag), so an\n * intervening `<ol>` never throws off a `<ul>`'s depth and vice-versa. The\n * rules are ordered shallow-to-deep; a deeper rule is more specific, so it\n * wins the cascade for the levels it applies to.\n */\nexport const StyledList = styled.ul<{ $ordered: boolean }>`\n margin: 0;\n padding-left: ${theme(\"spacing.5\")};\n list-style: ${({ $ordered }) => ($ordered ? \"decimal\" : \"disc\")} outside;\n\n li + li {\n margin-top: ${SPACE.xs};\n }\n\n /* Depth 2 */\n & ul[data-portable-list] {\n list-style-type: circle;\n }\n & ol[data-portable-list] {\n list-style-type: lower-alpha;\n }\n\n /* Depth 3 */\n & [data-portable-list] ul[data-portable-list] {\n list-style-type: square;\n }\n & [data-portable-list] ol[data-portable-list] {\n list-style-type: lower-roman;\n }\n\n /* Depth 4 (the producer's cap; deeper content clamps into it) */\n & [data-portable-list] [data-portable-list] ul[data-portable-list] {\n list-style-type: disc;\n }\n & [data-portable-list] [data-portable-list] ol[data-portable-list] {\n list-style-type: upper-alpha;\n }\n`;\n\nStyledList.displayName = \"StyledList\";\n"],"mappings":";;;;;;AAAA,IAAAA,iBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAGA,IAAAC,aAAA,GAAAD,OAAA;AAAwC,SAAAD,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAExC;AACO,IAAMG,UAAU,GAAAC,OAAA,CAAAD,UAAA,GAAGE,yBAAM,CAACC,IAAI,CAAAC,UAAA;EAAAC,WAAA;EAAAC,WAAA;AAAA,gLACtB,SAAkB,EACd,SAA6B,CAI/C;AAEDN,UAAU,CAACK,WAAW,GAAG,YAAY;;AAErC;AACO,IAAME,UAAU,GAAAN,OAAA,CAAAM,UAAA,GAAGL,yBAAM,CAACM,CAAC,CAAAJ,UAAA;EAAAC,WAAA;EAAAC,WAAA;AAAA,0IAQjC;AAEDC,UAAU,CAACF,WAAW,GAAG,YAAY;;AAErC;AACA;AACA;AACA;AACA;AACO,IAAMI,eAAe,GAAAR,OAAA,CAAAQ,eAAA,GAAGP,yBAAM,CAACQ,GAAG,CAAAN,UAAA;EAAAC,WAAA;EAAAC,WAAA;AAAA,wOAE5BK,mBAAK,CAACC,EAAE,EACF,QAAwB,EAM1B,UAAwB,CAGxC;AAEDH,eAAe,CAACJ,WAAW,GAAG,iBAAiB;;AAE/C;AACA;AACA;AACA;AACA;AACO,IAAMQ,gBAAgB,GAAAZ,OAAA,CAAAY,gBAAA,GAAGX,yBAAM,CAACY,GAAG,CAAAV,UAAA;EAAAC,WAAA;EAAAC,WAAA;AAAA,iCAIzC;AAEDO,gBAAgB,CAACR,WAAW,GAAG,kBAAkB;;AAEjD;AACO,IAAMU,aAAa,GAAAd,OAAA,CAAAc,aAAA,GAAGb,yBAAM,CAACc,EAAE,CAAAZ,UAAA;EAAAC,WAAA;EAAAC,WAAA;AAAA,wEAIrC;AAEDS,aAAa,CAACV,WAAW,GAAG,eAAe;;AAE3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,IAAMY,UAAU,GAAAhB,OAAA,CAAAgB,UAAA,GAAGf,yBAAM,CAACgB,EAAE,CAAAd,UAAA;EAAAC,WAAA;EAAAC,WAAA;AAAA,sgBAEjB,SAAkB,EACpB,UAAAa,IAAA;EAAA,IAAGC,QAAQ,GAAAD,IAAA,CAARC,QAAQ;EAAA,OAAQA,QAAQ,GAAG,SAAS,GAAG,MAAM;AAAA,CAAC,EAG/CT,mBAAK,CAACU,EAAE,CA0BzB;AAEDJ,UAAU,CAACZ,WAAW,GAAG,YAAY","ignoreList":[]}
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.portableTextDefaultMarkRenderers = exports.portableTextDefaultBlockRenderers = void 0;
|
|
7
7
|
var _react = _interopRequireWildcard(require("react"));
|
|
8
8
|
var _Styles = require("./Styles");
|
|
9
|
+
var _types = require("./types");
|
|
9
10
|
var _Media = require("../Media");
|
|
10
11
|
var _Tables = require("../Tables");
|
|
11
12
|
var _TitledText = require("../TitledText");
|
|
@@ -96,10 +97,16 @@ var portableTextDefaultBlockRenderers = exports.portableTextDefaultBlockRenderer
|
|
|
96
97
|
var block = _ref8.block,
|
|
97
98
|
children = _ref8.children;
|
|
98
99
|
var ordered = block.style === "number";
|
|
99
|
-
return
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
100
|
+
return (
|
|
101
|
+
/*#__PURE__*/
|
|
102
|
+
// `data-portable-list` scopes the depth-marker rules in Styles.ts to
|
|
103
|
+
// design-system lists, and marks the ancestors those rules count.
|
|
104
|
+
_react.default.createElement(_Styles.StyledList, {
|
|
105
|
+
as: ordered ? "ol" : "ul",
|
|
106
|
+
$ordered: ordered,
|
|
107
|
+
"data-portable-list": ""
|
|
108
|
+
}, children)
|
|
109
|
+
);
|
|
103
110
|
},
|
|
104
111
|
"list-item": function listItem(_ref9) {
|
|
105
112
|
var children = _ref9.children;
|
|
@@ -115,6 +122,15 @@ var portableTextDefaultBlockRenderers = exports.portableTextDefaultBlockRenderer
|
|
|
115
122
|
alt = _ref1.alt,
|
|
116
123
|
variant = _ref1.variant,
|
|
117
124
|
caption = _ref1.caption;
|
|
125
|
+
|
|
126
|
+
// Video (and future) variants carry service semantics, so their renderer
|
|
127
|
+
// is application-catalog territory — an injected `media` override. The
|
|
128
|
+
// universal set covers images only; anything else degrades and warns, per
|
|
129
|
+
// the contract's degradation rule.
|
|
130
|
+
if (variant !== undefined && !(0, _types.isPortableTextMediaImageVariant)(variant)) {
|
|
131
|
+
console.warn("PortableText: no default renderer for media variant \"".concat(variant, "\"."));
|
|
132
|
+
return null;
|
|
133
|
+
}
|
|
118
134
|
return /*#__PURE__*/_react.default.createElement(_Media.Media, {
|
|
119
135
|
src: src,
|
|
120
136
|
alt: alt,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderers.js","names":["_react","_interopRequireWildcard","require","_Styles","_Media","_Tables","_TitledText","_Typography","_Typography2","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","_t","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","portableTextDefaultMarkRenderers","exports","strong","_ref","children","createElement","em","_ref2","code","_ref3","StyledCode","link","_ref4","mark","href","Fragment","StyledLink","target","rel","HEADING_LEVEL_VARIANTS","DEFAULT_HEADING_LEVEL","headingVariantForLevel","level","undefined","variant","console","warn","concat","HeadingBlock","_ref5","block","_ref6","Heading","titledTextHeadings","portableTextDefaultBlockRenderers","paragraph","_ref7","Body1","heading","list","_ref8","ordered","style","StyledList","as","$ordered","listItem","_ref9","Typography","media","_ref0","_ref1","src","alt","caption","Media","titledText","_ref10","_ref11","title","TitledText","codeBlock","_ref12","_ref13","language","StyledCodeBlock","table","_ref14","renderSpans","_ref15","header","rows","cell","spans","map","span","index","key","text","StyledTableBlock","Table","Thead","Tbody","row","rowIndex","cellIndex","divider","StyledDivider"],"sources":["../../../../src/components/PortableText/renderers.tsx"],"sourcesContent":["import React, { Fragment, ReactNode } from \"react\";\n\nimport {\n StyledCode,\n StyledCodeBlock,\n StyledDivider,\n StyledLink,\n StyledList,\n StyledTableBlock,\n} from \"./Styles\";\nimport {\n PortableTextBlockRenderer,\n PortableTextCodeBlock,\n PortableTextDefaultBlockType,\n PortableTextDefaultMark,\n PortableTextHeadingBlock,\n PortableTextHeadingLevel,\n PortableTextLinkMark,\n PortableTextListBlock,\n PortableTextMarkRenderer,\n PortableTextMediaBlock,\n PortableTextSpan,\n PortableTextTableBlock,\n PortableTextTitledTextBlock,\n} from \"./types\";\nimport { Media } from \"../Media\";\nimport { Table, Tbody, Thead } from \"../Tables\";\nimport {\n TitledText,\n TitledTextVariant,\n titledTextHeadings,\n} from \"../TitledText\";\nimport { Body1 } from \"../Typography\";\nimport { Typography } from \"../Typography/Typography\";\n\n/**\n * The default renderers for the universal set — everything a client renders\n * without injection, and nothing more: no product element ever lands here.\n * Injected {@link PortableTextComponents} maps take precedence entry by entry.\n */\n\nexport const portableTextDefaultMarkRenderers: Record<\n PortableTextDefaultMark,\n PortableTextMarkRenderer\n> = {\n strong: ({ children }) => <strong>{children}</strong>,\n em: ({ children }) => <em>{children}</em>,\n code: ({ children }) => <StyledCode>{children}</StyledCode>,\n link: ({ mark, children }) => {\n const href = (mark as PortableTextLinkMark | undefined)?.href;\n\n // A link mark without an href (authored as a plain string) has nowhere\n // to go — keep the text, skip the anchor.\n if (!href) {\n return <>{children}</>;\n }\n\n return (\n <StyledLink href={href} target=\"_blank\" rel=\"noopener noreferrer\">\n {children}\n </StyledLink>\n );\n },\n};\n\n/** The semantic wire levels resolve to typography only here, in the renderer. */\nconst HEADING_LEVEL_VARIANTS: Record<\n PortableTextHeadingLevel,\n TitledTextVariant\n> = {\n 1: \"title1\",\n 2: \"title2\",\n 3: \"header2\",\n};\n\n/** The level `heading` and `titled-text` fall back to. */\nconst DEFAULT_HEADING_LEVEL: PortableTextHeadingLevel = 3;\n\n/**\n * Resolve a semantic wire level to its typography variant. An absent level is\n * the documented default; any other unrecognised level is a serializer bug on\n * a fixed 1–3 scale, so it falls back to the default and is logged, per the\n * contract's degradation rule.\n */\nconst headingVariantForLevel = (\n level: PortableTextHeadingLevel | undefined\n): TitledTextVariant => {\n if (level === undefined) {\n return HEADING_LEVEL_VARIANTS[DEFAULT_HEADING_LEVEL];\n }\n\n const variant = HEADING_LEVEL_VARIANTS[level];\n if (!variant) {\n console.warn(\n `PortableText: unknown heading level ${level}, falling back to ${DEFAULT_HEADING_LEVEL}.`\n );\n return HEADING_LEVEL_VARIANTS[DEFAULT_HEADING_LEVEL];\n }\n\n return variant;\n};\n\n/** Heading levels map to the same typography TitledText uses. */\nconst HeadingBlock: PortableTextBlockRenderer = ({ block, children }) => {\n const { level } = block as PortableTextHeadingBlock;\n const Heading = titledTextHeadings[headingVariantForLevel(level)];\n return <Heading>{children}</Heading>;\n};\n\nexport const portableTextDefaultBlockRenderers: Record<\n PortableTextDefaultBlockType,\n PortableTextBlockRenderer\n> = {\n paragraph: ({ children }) => <Body1>{children}</Body1>,\n heading: HeadingBlock,\n list: ({ block, children }) => {\n const ordered = (block as PortableTextListBlock).style === \"number\";\n return (\n <StyledList as={ordered ? \"ol\" : \"ul\"} $ordered={ordered}>\n {children}\n </StyledList>\n );\n },\n \"list-item\": ({ children }) => (\n <Typography variant=\"Body 1\" as=\"li\">\n {children}\n </Typography>\n ),\n media: ({ block }) => {\n const { src, alt, variant, caption } = block as PortableTextMediaBlock;\n return <Media src={src} alt={alt} variant={variant} caption={caption} />;\n },\n \"titled-text\": ({ block, children }) => {\n const { title, level } = block as PortableTextTitledTextBlock;\n return (\n <TitledText title={title} variant={headingVariantForLevel(level)}>\n {children}\n </TitledText>\n );\n },\n // No highlighter ships with the default set, so every language — known,\n // unknown or absent — is plain preformatted text; the hint travels on\n // data-language for surfaces that highlight.\n \"code-block\": ({ block }) => {\n const { code, language } = block as PortableTextCodeBlock;\n return (\n <StyledCodeBlock data-language={language || undefined}>\n <code>{code}</code>\n </StyledCodeBlock>\n );\n },\n table: ({ block, renderSpans }) => {\n const { header, rows } = block as PortableTextTableBlock;\n // Standalone (engine-less) use has no span renderer — keep the raw text.\n const cell = (spans: PortableTextSpan[]): ReactNode =>\n renderSpans\n ? renderSpans(spans)\n : spans.map((span, index) => (\n <Fragment key={index}>{span.text}</Fragment>\n ));\n\n return (\n <StyledTableBlock>\n <Table>\n <Thead>\n <tr>\n {header.map((spans, index) => (\n <th key={index}>{cell(spans)}</th>\n ))}\n </tr>\n </Thead>\n <Tbody>\n {rows.map((row, rowIndex) => (\n <tr key={rowIndex}>\n {row.map((spans, cellIndex) => (\n <td key={cellIndex}>{cell(spans)}</td>\n ))}\n </tr>\n ))}\n </Tbody>\n </Table>\n </StyledTableBlock>\n );\n },\n divider: () => <StyledDivider />,\n};\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAEA,IAAAC,OAAA,GAAAD,OAAA;AAuBA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,WAAA,GAAAJ,OAAA;AAKA,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OAAA,CAAAyG,gBAAgB,qBACf5G,MAAA,CAAAmB,OAAA,CAAAe,aAAA,CAAC7B,OAAA,CAAAwG,KAAK,qBACJ7G,MAAA,CAAAmB,OAAA,CAAAe,aAAA,CAAC7B,OAAA,CAAAyG,KAAK,qBACJ9G,MAAA,CAAAmB,OAAA,CAAAe,aAAA,aACGiE,MAAM,CAACI,GAAG,CAAC,UAACD,KAAK,EAAEG,KAAK;MAAA,oBACvBzG,MAAA,CAAAmB,OAAA,CAAAe,aAAA;QAAIwE,GAAG,EAAED;MAAM,GAAEJ,IAAI,CAACC,KAAK,CAAM,CAAC;IAAA,CACnC,CACC,CACC,CAAC,eACRtG,MAAA,CAAAmB,OAAA,CAAAe,aAAA,CAAC7B,OAAA,CAAA0G,KAAK,QACHX,IAAI,CAACG,GAAG,CAAC,UAACS,GAAG,EAAEC,QAAQ;MAAA,oBACtBjH,MAAA,CAAAmB,OAAA,CAAAe,aAAA;QAAIwE,GAAG,EAAEO;MAAS,GACfD,GAAG,CAACT,GAAG,CAAC,UAACD,KAAK,EAAEY,SAAS;QAAA,oBACxBlH,MAAA,CAAAmB,OAAA,CAAAe,aAAA;UAAIwE,GAAG,EAAEQ;QAAU,GAAEb,IAAI,CAACC,KAAK,CAAM,CAAC;MAAA,CACvC,CACC,CAAC;IAAA,CACN,CACI,CACF,CACS,CAAC;EAEvB,CAAC;EACDa,OAAO,EAAE,SAATA,OAAOA,CAAA;IAAA,oBAAQnH,MAAA,CAAAmB,OAAA,CAAAe,aAAA,CAAC/B,OAAA,CAAAiH,aAAa,MAAE,CAAC;EAAA;AAClC,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"renderers.js","names":["_react","_interopRequireWildcard","require","_Styles","_types","_Media","_Tables","_TitledText","_Typography","_Typography2","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","_t","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","portableTextDefaultMarkRenderers","exports","strong","_ref","children","createElement","em","_ref2","code","_ref3","StyledCode","link","_ref4","mark","href","Fragment","StyledLink","target","rel","HEADING_LEVEL_VARIANTS","DEFAULT_HEADING_LEVEL","headingVariantForLevel","level","undefined","variant","console","warn","concat","HeadingBlock","_ref5","block","_ref6","Heading","titledTextHeadings","portableTextDefaultBlockRenderers","paragraph","_ref7","Body1","heading","list","_ref8","ordered","style","StyledList","as","$ordered","listItem","_ref9","Typography","media","_ref0","_ref1","src","alt","caption","isPortableTextMediaImageVariant","Media","titledText","_ref10","_ref11","title","TitledText","codeBlock","_ref12","_ref13","language","StyledCodeBlock","table","_ref14","renderSpans","_ref15","header","rows","cell","spans","map","span","index","key","text","StyledTableBlock","Table","Thead","Tbody","row","rowIndex","cellIndex","divider","StyledDivider"],"sources":["../../../../src/components/PortableText/renderers.tsx"],"sourcesContent":["import React, { Fragment, ReactNode } from \"react\";\n\nimport {\n StyledCode,\n StyledCodeBlock,\n StyledDivider,\n StyledLink,\n StyledList,\n StyledTableBlock,\n} from \"./Styles\";\nimport {\n isPortableTextMediaImageVariant,\n PortableTextBlockRenderer,\n PortableTextCodeBlock,\n PortableTextDefaultBlockType,\n PortableTextDefaultMark,\n PortableTextHeadingBlock,\n PortableTextHeadingLevel,\n PortableTextLinkMark,\n PortableTextListBlock,\n PortableTextMarkRenderer,\n PortableTextMediaBlock,\n PortableTextSpan,\n PortableTextTableBlock,\n PortableTextTitledTextBlock,\n} from \"./types\";\nimport { Media } from \"../Media\";\nimport { Table, Tbody, Thead } from \"../Tables\";\nimport {\n TitledText,\n TitledTextVariant,\n titledTextHeadings,\n} from \"../TitledText\";\nimport { Body1 } from \"../Typography\";\nimport { Typography } from \"../Typography/Typography\";\n\n/**\n * The default renderers for the universal set — everything a client renders\n * without injection, and nothing more: no product element ever lands here.\n * Injected {@link PortableTextComponents} maps take precedence entry by entry.\n */\n\nexport const portableTextDefaultMarkRenderers: Record<\n PortableTextDefaultMark,\n PortableTextMarkRenderer\n> = {\n strong: ({ children }) => <strong>{children}</strong>,\n em: ({ children }) => <em>{children}</em>,\n code: ({ children }) => <StyledCode>{children}</StyledCode>,\n link: ({ mark, children }) => {\n const href = (mark as PortableTextLinkMark | undefined)?.href;\n\n // A link mark without an href (authored as a plain string) has nowhere\n // to go — keep the text, skip the anchor.\n if (!href) {\n return <>{children}</>;\n }\n\n return (\n <StyledLink href={href} target=\"_blank\" rel=\"noopener noreferrer\">\n {children}\n </StyledLink>\n );\n },\n};\n\n/** The semantic wire levels resolve to typography only here, in the renderer. */\nconst HEADING_LEVEL_VARIANTS: Record<\n PortableTextHeadingLevel,\n TitledTextVariant\n> = {\n 1: \"title1\",\n 2: \"title2\",\n 3: \"header2\",\n};\n\n/** The level `heading` and `titled-text` fall back to. */\nconst DEFAULT_HEADING_LEVEL: PortableTextHeadingLevel = 3;\n\n/**\n * Resolve a semantic wire level to its typography variant. An absent level is\n * the documented default; any other unrecognised level is a serializer bug on\n * a fixed 1–3 scale, so it falls back to the default and is logged, per the\n * contract's degradation rule.\n */\nconst headingVariantForLevel = (\n level: PortableTextHeadingLevel | undefined\n): TitledTextVariant => {\n if (level === undefined) {\n return HEADING_LEVEL_VARIANTS[DEFAULT_HEADING_LEVEL];\n }\n\n const variant = HEADING_LEVEL_VARIANTS[level];\n if (!variant) {\n console.warn(\n `PortableText: unknown heading level ${level}, falling back to ${DEFAULT_HEADING_LEVEL}.`\n );\n return HEADING_LEVEL_VARIANTS[DEFAULT_HEADING_LEVEL];\n }\n\n return variant;\n};\n\n/** Heading levels map to the same typography TitledText uses. */\nconst HeadingBlock: PortableTextBlockRenderer = ({ block, children }) => {\n const { level } = block as PortableTextHeadingBlock;\n const Heading = titledTextHeadings[headingVariantForLevel(level)];\n return <Heading>{children}</Heading>;\n};\n\nexport const portableTextDefaultBlockRenderers: Record<\n PortableTextDefaultBlockType,\n PortableTextBlockRenderer\n> = {\n paragraph: ({ children }) => <Body1>{children}</Body1>,\n heading: HeadingBlock,\n list: ({ block, children }) => {\n const ordered = (block as PortableTextListBlock).style === \"number\";\n return (\n // `data-portable-list` scopes the depth-marker rules in Styles.ts to\n // design-system lists, and marks the ancestors those rules count.\n <StyledList\n as={ordered ? \"ol\" : \"ul\"}\n $ordered={ordered}\n data-portable-list=\"\"\n >\n {children}\n </StyledList>\n );\n },\n \"list-item\": ({ children }) => (\n <Typography variant=\"Body 1\" as=\"li\">\n {children}\n </Typography>\n ),\n media: ({ block }) => {\n const { src, alt, variant, caption } = block as PortableTextMediaBlock;\n\n // Video (and future) variants carry service semantics, so their renderer\n // is application-catalog territory — an injected `media` override. The\n // universal set covers images only; anything else degrades and warns, per\n // the contract's degradation rule.\n if (variant !== undefined && !isPortableTextMediaImageVariant(variant)) {\n console.warn(\n `PortableText: no default renderer for media variant \"${variant}\".`\n );\n return null;\n }\n\n return <Media src={src} alt={alt} variant={variant} caption={caption} />;\n },\n \"titled-text\": ({ block, children }) => {\n const { title, level } = block as PortableTextTitledTextBlock;\n return (\n <TitledText title={title} variant={headingVariantForLevel(level)}>\n {children}\n </TitledText>\n );\n },\n // No highlighter ships with the default set, so every language — known,\n // unknown or absent — is plain preformatted text; the hint travels on\n // data-language for surfaces that highlight.\n \"code-block\": ({ block }) => {\n const { code, language } = block as PortableTextCodeBlock;\n return (\n <StyledCodeBlock data-language={language || undefined}>\n <code>{code}</code>\n </StyledCodeBlock>\n );\n },\n table: ({ block, renderSpans }) => {\n const { header, rows } = block as PortableTextTableBlock;\n // Standalone (engine-less) use has no span renderer — keep the raw text.\n const cell = (spans: PortableTextSpan[]): ReactNode =>\n renderSpans\n ? renderSpans(spans)\n : spans.map((span, index) => (\n <Fragment key={index}>{span.text}</Fragment>\n ));\n\n return (\n <StyledTableBlock>\n <Table>\n <Thead>\n <tr>\n {header.map((spans, index) => (\n <th key={index}>{cell(spans)}</th>\n ))}\n </tr>\n </Thead>\n <Tbody>\n {rows.map((row, rowIndex) => (\n <tr key={rowIndex}>\n {row.map((spans, cellIndex) => (\n <td key={cellIndex}>{cell(spans)}</td>\n ))}\n </t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CAAAe,aAAA;UAAIyE,GAAG,EAAEQ;QAAU,GAAEb,IAAI,CAACC,KAAK,CAAM,CAAC;MAAA,CACvC,CACC,CAAC;IAAA,CACN,CACI,CACF,CACS,CAAC;EAEvB,CAAC;EACDa,OAAO,EAAE,SAATA,OAAOA,CAAA;IAAA,oBAAQrH,MAAA,CAAAoB,OAAA,CAAAe,aAAA,CAAChC,OAAA,CAAAmH,aAAa,MAAE,CAAC;EAAA;AAClC,CAAC","ignoreList":[]}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.isPortableTextTableRow = exports.isPortableTextSpan = exports.isPortableTextObjectNode = exports.isPortableTextContent = exports.isPortableTextBlock = exports.PORTABLE_TEXT_DEFAULT_MARKS = exports.PORTABLE_TEXT_DEFAULT_BLOCKS = void 0;
|
|
6
|
+
exports.isPortableTextTableRow = exports.isPortableTextSpan = exports.isPortableTextObjectNode = exports.isPortableTextMediaImageVariant = exports.isPortableTextContent = exports.isPortableTextBlock = exports.PORTABLE_TEXT_DEFAULT_MARKS = exports.PORTABLE_TEXT_DEFAULT_BLOCKS = void 0;
|
|
7
7
|
/**
|
|
8
8
|
* Portable Text envelope — the general content contract for structured,
|
|
9
9
|
* renderer-independent content (in-app messages, help, changelogs).
|
|
@@ -33,8 +33,31 @@ var PORTABLE_TEXT_DEFAULT_MARKS = exports.PORTABLE_TEXT_DEFAULT_MARKS = ["strong
|
|
|
33
33
|
|
|
34
34
|
/** 1 maps to Title1, 2 to Title2, 3 to Header2 typography. */
|
|
35
35
|
|
|
36
|
+
/**
|
|
37
|
+
* A list item's children are its own spans first, then any nested `list`
|
|
38
|
+
* block(s) — the shape that carries multi-level lists. A spans-only item (no
|
|
39
|
+
* nested list) is the common, flat case and stays valid unchanged.
|
|
40
|
+
*/
|
|
41
|
+
|
|
36
42
|
/** Screenshots render framed (border, no shadow); illustrations render flat. */
|
|
37
43
|
|
|
44
|
+
/**
|
|
45
|
+
* Video variants name the hosting service; `src` is the canonical video URL.
|
|
46
|
+
* Their rendering carries service semantics (URL parsing, embed derivation),
|
|
47
|
+
* so it belongs to the application catalog — injected as a `media` block
|
|
48
|
+
* override — never to the default set. The default renderer degrades them.
|
|
49
|
+
*/
|
|
50
|
+
|
|
51
|
+
// A Record so the compiler checks the list against the union in both
|
|
52
|
+
// directions: a missing and a stray key each fail to build.
|
|
53
|
+
var MEDIA_IMAGE_VARIANTS = {
|
|
54
|
+
screenshot: true,
|
|
55
|
+
illustration: true
|
|
56
|
+
};
|
|
57
|
+
var isPortableTextMediaImageVariant = exports.isPortableTextMediaImageVariant = function isPortableTextMediaImageVariant(value) {
|
|
58
|
+
return typeof value === "string" && value in MEDIA_IMAGE_VARIANTS;
|
|
59
|
+
};
|
|
60
|
+
|
|
38
61
|
/** A table cell is a span array, so inline marks work inside cells. */
|
|
39
62
|
|
|
40
63
|
/** A themed horizontal rule between sections. Carries no data. */
|
|
@@ -114,10 +137,23 @@ var _isPortableTextBlock = exports.isPortableTextBlock = function isPortableText
|
|
|
114
137
|
switch (value.type) {
|
|
115
138
|
case "paragraph":
|
|
116
139
|
case "heading":
|
|
117
|
-
case "list-item":
|
|
118
140
|
return Array.isArray(value.children) && value.children.every(isPortableTextSpan);
|
|
141
|
+
case "list-item":
|
|
142
|
+
// The item's spans, plus optional nested `list` block(s). Widened only
|
|
143
|
+
// for nested lists: any other block child (a stray paragraph, an object)
|
|
144
|
+
// still fails, so a serializer bug is caught here, not at render.
|
|
145
|
+
return Array.isArray(value.children) && value.children.every(function (child) {
|
|
146
|
+
return isPortableTextSpan(child) || _isPortableTextBlock(child) && child.type === "list";
|
|
147
|
+
});
|
|
119
148
|
case "list":
|
|
120
|
-
|
|
149
|
+
// A list holds `list-item`s only. A sublist emitted as a sibling of the
|
|
150
|
+
// items (the classic half-implemented-nesting bug) renders invalid HTML
|
|
151
|
+
// — <ul> with a direct <ul> child — so it fails here, not at render.
|
|
152
|
+
// `list-item` is validated but sits outside the PortableTextBlock union,
|
|
153
|
+
// so the discriminator is checked before isPortableTextBlock narrows it.
|
|
154
|
+
return Array.isArray(value.children) && value.children.every(function (child) {
|
|
155
|
+
return isRecord(child) && child.type === "list-item" && _isPortableTextBlock(child);
|
|
156
|
+
});
|
|
121
157
|
case "media":
|
|
122
158
|
return typeof value.src === "string";
|
|
123
159
|
case "titled-text":
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":["PORTABLE_TEXT_DEFAULT_MARKS","exports","DEFAULT_BLOCK_TYPES","paragraph","heading","list","media","table","divider","PORTABLE_TEXT_DEFAULT_BLOCKS","Object","keys","isRecord","value","isPortableTextSpan","text","isPortableTextTableRow","Array","isArray","every","cell","isPortableTextObjectNode","type","_type","isPortableTextBlock","children","src","title","content","undefined","isPortableTextContent","code","language","header","rows","node"],"sources":["../../../../src/components/PortableText/types.ts"],"sourcesContent":["import { ComponentType, ReactNode } from \"react\";\n\n/**\n * Portable Text envelope — the general content contract for structured,\n * renderer-independent content (in-app messages, help, changelogs).\n *\n * The design system owns this envelope and the universal default set below.\n * It never hardcodes a product element: concrete elements (callout,\n * button-reference, doc-link, …) are defined in the application catalog and\n * injected into the Portable Text engine through {@link PortableTextComponents}.\n * See README.md next to this file for the full contract.\n */\n\n/* ---- Spans and marks ------------------------------------------------- */\n\n/**\n * A mark with data. Parameterless marks travel as plain strings (\"strong\");\n * marks that need data travel as objects discriminated by `type`.\n */\nexport interface PortableTextMarkObject {\n type: string;\n [data: string]: unknown;\n}\n\n/** The one default mark that carries data. */\nexport interface PortableTextLinkMark extends PortableTextMarkObject {\n type: \"link\";\n href: string;\n}\n\nexport type PortableTextMark = string | PortableTextMarkObject;\n\n/** The leaf of every text run: a piece of text plus the marks wrapping it. */\nexport interface PortableTextSpan {\n text: string;\n marks?: PortableTextMark[];\n}\n\n/** Marks every client understands without injection. */\nexport const PORTABLE_TEXT_DEFAULT_MARKS = [\n \"strong\",\n \"em\",\n \"code\",\n \"link\",\n] as const;\n\nexport type PortableTextDefaultMark =\n (typeof PORTABLE_TEXT_DEFAULT_MARKS)[number];\n\n/* ---- Blocks ----------------------------------------------------------- */\n\nexport interface PortableTextParagraphBlock {\n type: \"paragraph\";\n children: PortableTextSpan[];\n}\n\n/** 1 maps to Title1, 2 to Title2, 3 to Header2 typography. */\nexport type PortableTextHeadingLevel = 1 | 2 | 3;\n\nexport interface PortableTextHeadingBlock {\n type: \"heading\";\n level: PortableTextHeadingLevel;\n children: PortableTextSpan[];\n}\n\nexport type PortableTextListStyle = \"bullet\" | \"number\";\n\nexport interface PortableTextListItemBlock {\n type: \"list-item\";\n children: PortableTextSpan[];\n}\n\nexport interface PortableTextListBlock {\n type: \"list\";\n style?: PortableTextListStyle;\n children: PortableTextListItemBlock[];\n}\n\n/** Screenshots render framed (border, no shadow); illustrations render flat. */\nexport type PortableTextMediaVariant = \"screenshot\" | \"illustration\";\n\nexport interface PortableTextMediaBlock {\n type: \"media\";\n src: string;\n alt?: string;\n variant?: PortableTextMediaVariant;\n caption?: string;\n}\n\nexport interface PortableTextTitledTextBlock {\n type: \"titled-text\";\n /**\n * Same semantic scale as `heading` — 1, 2 or 3 (the default) — so the wire\n * format never encodes a typography name. How a level looks is the\n * renderer's business.\n */\n level?: PortableTextHeadingLevel;\n title: string;\n content?: PortableTextNode[];\n}\n\nexport interface PortableTextCodeBlock {\n type: \"code-block\";\n /**\n * A language hint (e.g. \"php\", \"json\"). The default renderer does no\n * highlighting, so any value — known, unknown or absent — renders as plain\n * preformatted text; it travels as data for surfaces that highlight.\n */\n language?: string;\n code: string;\n}\n\n/** A table cell is a span array, so inline marks work inside cells. */\nexport type PortableTextTableCell = PortableTextSpan[];\nexport type PortableTextTableRow = PortableTextTableCell[];\n\nexport interface PortableTextTableBlock {\n type: \"table\";\n header: PortableTextTableRow;\n rows: PortableTextTableRow[];\n}\n\n/** A themed horizontal rule between sections. Carries no data. */\nexport interface PortableTextDividerBlock {\n type: \"divider\";\n}\n\nexport type PortableTextBlock =\n | PortableTextParagraphBlock\n | PortableTextHeadingBlock\n | PortableTextListBlock\n | PortableTextMediaBlock\n | PortableTextTitledTextBlock\n | PortableTextCodeBlock\n | PortableTextTableBlock\n | PortableTextDividerBlock;\n\n/**\n * Derived from the union's discriminators, so adding a block to the union\n * without a renderer entry is a compile error, never silent drift.\n */\nexport type PortableTextDefaultBlockType = (\n | PortableTextBlock\n | PortableTextListItemBlock\n)[\"type\"];\n\n// A Record so the compiler checks the list against the union in both\n// directions: a missing and a stray key each fail to build.\nconst DEFAULT_BLOCK_TYPES: Record<PortableTextDefaultBlockType, true> = {\n paragraph: true,\n heading: true,\n list: true,\n \"list-item\": true,\n media: true,\n \"titled-text\": true,\n \"code-block\": true,\n table: true,\n divider: true,\n};\n\n/** Blocks every client understands without injection. */\nexport const PORTABLE_TEXT_DEFAULT_BLOCKS = Object.keys(\n DEFAULT_BLOCK_TYPES\n) as readonly PortableTextDefaultBlockType[];\n\n/* ---- Objects ----------------------------------------------------------- */\n\n/**\n * An embedded component the envelope does not interpret: `_type` names an\n * application-catalog element, everything else is that element's data. An\n * object whose `_type` has no injected renderer renders nothing and is logged.\n */\nexport interface PortableTextObjectNode {\n type: \"object\";\n _type: string;\n [data: string]: unknown;\n}\n\nexport type PortableTextNode = PortableTextBlock | PortableTextObjectNode;\n\n/** The root of a message body: what an API returns under `content`. */\nexport type PortableTextContent = PortableTextNode[];\n\n/* ---- Injection contract ------------------------------------------------ */\n\nexport interface PortableTextMarkRendererProps<\n TMark extends PortableTextMarkObject = PortableTextMarkObject\n> {\n /** Present for object marks; absent when the mark is a plain string. */\n mark?: TMark;\n children: ReactNode;\n}\n\nexport type PortableTextMarkRenderer<\n TMark extends PortableTextMarkObject = PortableTextMarkObject\n> = ComponentType<PortableTextMarkRendererProps<TMark>>;\n\nexport interface PortableTextObjectRendererProps<\n TNode extends PortableTextObjectNode = PortableTextObjectNode\n> {\n node: TNode;\n /** The object's nested `content`, already rendered by the engine. */\n children?: ReactNode;\n}\n\nexport type PortableTextObjectRenderer<\n TNode extends PortableTextObjectNode = PortableTextObjectNode\n> = ComponentType<PortableTextObjectRendererProps<TNode>>;\n\nexport interface PortableTextBlockRendererProps<\n TBlock extends PortableTextBlock = PortableTextBlock\n> {\n block: TBlock;\n /** The block's rendered children/content, when it has any. */\n children?: ReactNode;\n /**\n * Engine-bound span renderer for blocks that carry spans outside `children`\n * (table cells). Resolves marks with the same precedence — injected first,\n * then defaults — as flowing text. Absent when a renderer is used without\n * the engine.\n */\n renderSpans?: (spans: PortableTextSpan[]) => ReactNode;\n}\n\nexport type PortableTextBlockRenderer<\n TBlock extends PortableTextBlock = PortableTextBlock\n> = ComponentType<PortableTextBlockRendererProps<TBlock>>;\n\nexport type PortableTextUnknownKind = \"block\" | \"mark\" | \"object\";\n\n/**\n * Called once per unknown type instead of rendering it, so content written\n * for newer clients degrades silently on older ones.\n */\nexport type PortableTextUnknownTypeHandler = (\n kind: PortableTextUnknownKind,\n type: string\n) => void;\n\n/**\n * What an application injects into the Portable Text engine: renderers for\n * its catalog marks and objects, optional overrides for the default blocks,\n * and the unknown-type hook.\n */\nexport interface PortableTextComponents {\n marks?: Record<string, PortableTextMarkRenderer>;\n objects?: Record<string, PortableTextObjectRenderer>;\n blocks?: Partial<\n Record<PortableTextDefaultBlockType, PortableTextBlockRenderer>\n >;\n onUnknownType?: PortableTextUnknownTypeHandler;\n}\n\n/* ---- Runtime guards ----------------------------------------------------- */\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === \"object\" && value !== null;\n\nexport const isPortableTextSpan = (value: unknown): value is PortableTextSpan =>\n isRecord(value) && typeof value.text === \"string\";\n\nexport const isPortableTextTableRow = (\n value: unknown\n): value is PortableTextTableRow =>\n Array.isArray(value) &&\n value.every((cell) => Array.isArray(cell) && cell.every(isPortableTextSpan));\n\nexport const isPortableTextObjectNode = (\n value: unknown\n): value is PortableTextObjectNode =>\n isRecord(value) && value.type === \"object\" && typeof value._type === \"string\";\n\n/**\n * A block is any non-object node with a string `type`. Unknown block types\n * stay valid on purpose — they render nothing on clients that predate them.\n * Known types are held to their shape, so a serializer bug (a paragraph\n * without `children`, a list of non-nodes) fails here instead of at render.\n */\nexport const isPortableTextBlock = (\n value: unknown\n): value is PortableTextBlock => {\n if (\n !isRecord(value) ||\n typeof value.type !== \"string\" ||\n value.type === \"object\"\n ) {\n return false;\n }\n\n switch (value.type) {\n case \"paragraph\":\n case \"heading\":\n case \"list-item\":\n return (\n Array.isArray(value.children) &&\n value.children.every(isPortableTextSpan)\n );\n case \"list\":\n return (\n Array.isArray(value.children) &&\n value.children.every(isPortableTextBlock)\n );\n case \"media\":\n return typeof value.src === \"string\";\n case \"titled-text\":\n return (\n typeof value.title === \"string\" &&\n (value.content === undefined || isPortableTextContent(value.content))\n );\n case \"code-block\":\n return (\n typeof value.code === \"string\" &&\n (value.language === undefined || typeof value.language === \"string\")\n );\n case \"table\":\n return (\n isPortableTextTableRow(value.header) &&\n Array.isArray(value.rows) &&\n value.rows.every(isPortableTextTableRow)\n );\n case \"divider\":\n return true;\n default:\n return true;\n }\n};\n\nexport const isPortableTextContent = (\n value: unknown\n): value is PortableTextContent =>\n Array.isArray(value) &&\n value.every(\n (node) => isPortableTextBlock(node) || isPortableTextObjectNode(node)\n );\n"],"mappings":";;;;;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAMA;;AAQA;;AAMA;AACO,IAAMA,2BAA2B,GAAAC,OAAA,CAAAD,2BAAA,GAAG,CACzC,QAAQ,EACR,IAAI,EACJ,MAAM,EACN,MAAM,CACE;;AAKV;;AAOA;;AAsBA;;AAkCA;;AAUA;;AAeA;AACA;AACA;AACA;;AAMA;AACA;AACA,IAAME,mBAA+D,GAAG;EACtEC,SAAS,EAAE,IAAI;EACfC,OAAO,EAAE,IAAI;EACbC,IAAI,EAAE,IAAI;EACV,WAAW,EA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AA7B,OAAA,CAAA6B,qBAAA,GAAG,SAAxBA,qBAAqBA,CAChCjB,KAAc;EAAA,OAEdI,KAAK,CAACC,OAAO,CAACL,KAAK,CAAC,IACpBA,KAAK,CAACM,KAAK,CACT,UAACgB,IAAI;IAAA,OAAKX,oBAAmB,CAACW,IAAI,CAAC,IAAId,wBAAwB,CAACc,IAAI,CAAC;EAAA,CACvE,CAAC;AAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"types.js","names":["PORTABLE_TEXT_DEFAULT_MARKS","exports","MEDIA_IMAGE_VARIANTS","screenshot","illustration","isPortableTextMediaImageVariant","value","DEFAULT_BLOCK_TYPES","paragraph","heading","list","media","table","divider","PORTABLE_TEXT_DEFAULT_BLOCKS","Object","keys","isRecord","isPortableTextSpan","text","isPortableTextTableRow","Array","isArray","every","cell","isPortableTextObjectNode","type","_type","isPortableTextBlock","children","child","src","title","content","undefined","isPortableTextContent","code","language","header","rows","node"],"sources":["../../../../src/components/PortableText/types.ts"],"sourcesContent":["import { ComponentType, ReactNode } from \"react\";\n\n/**\n * Portable Text envelope — the general content contract for structured,\n * renderer-independent content (in-app messages, help, changelogs).\n *\n * The design system owns this envelope and the universal default set below.\n * It never hardcodes a product element: concrete elements (callout,\n * button-reference, doc-link, …) are defined in the application catalog and\n * injected into the Portable Text engine through {@link PortableTextComponents}.\n * See README.md next to this file for the full contract.\n */\n\n/* ---- Spans and marks ------------------------------------------------- */\n\n/**\n * A mark with data. Parameterless marks travel as plain strings (\"strong\");\n * marks that need data travel as objects discriminated by `type`.\n */\nexport interface PortableTextMarkObject {\n type: string;\n [data: string]: unknown;\n}\n\n/** The one default mark that carries data. */\nexport interface PortableTextLinkMark extends PortableTextMarkObject {\n type: \"link\";\n href: string;\n}\n\nexport type PortableTextMark = string | PortableTextMarkObject;\n\n/** The leaf of every text run: a piece of text plus the marks wrapping it. */\nexport interface PortableTextSpan {\n text: string;\n marks?: PortableTextMark[];\n}\n\n/** Marks every client understands without injection. */\nexport const PORTABLE_TEXT_DEFAULT_MARKS = [\n \"strong\",\n \"em\",\n \"code\",\n \"link\",\n] as const;\n\nexport type PortableTextDefaultMark =\n (typeof PORTABLE_TEXT_DEFAULT_MARKS)[number];\n\n/* ---- Blocks ----------------------------------------------------------- */\n\nexport interface PortableTextParagraphBlock {\n type: \"paragraph\";\n children: PortableTextSpan[];\n}\n\n/** 1 maps to Title1, 2 to Title2, 3 to Header2 typography. */\nexport type PortableTextHeadingLevel = 1 | 2 | 3;\n\nexport interface PortableTextHeadingBlock {\n type: \"heading\";\n level: PortableTextHeadingLevel;\n children: PortableTextSpan[];\n}\n\nexport type PortableTextListStyle = \"bullet\" | \"number\";\n\n/**\n * A list item's children are its own spans first, then any nested `list`\n * block(s) — the shape that carries multi-level lists. A spans-only item (no\n * nested list) is the common, flat case and stays valid unchanged.\n */\nexport interface PortableTextListItemBlock {\n type: \"list-item\";\n children: (PortableTextSpan | PortableTextListBlock)[];\n}\n\nexport interface PortableTextListBlock {\n type: \"list\";\n style?: PortableTextListStyle;\n children: PortableTextListItemBlock[];\n}\n\n/** Screenshots render framed (border, no shadow); illustrations render flat. */\nexport type PortableTextMediaImageVariant = \"screenshot\" | \"illustration\";\n\n/**\n * Video variants name the hosting service; `src` is the canonical video URL.\n * Their rendering carries service semantics (URL parsing, embed derivation),\n * so it belongs to the application catalog — injected as a `media` block\n * override — never to the default set. The default renderer degrades them.\n */\nexport type PortableTextMediaVideoVariant = \"vimeo\" | \"youtube\";\n\nexport type PortableTextMediaVariant =\n | PortableTextMediaImageVariant\n | PortableTextMediaVideoVariant;\n\n// A Record so the compiler checks the list against the union in both\n// directions: a missing and a stray key each fail to build.\nconst MEDIA_IMAGE_VARIANTS: Record<PortableTextMediaImageVariant, true> = {\n screenshot: true,\n illustration: true,\n};\n\nexport const isPortableTextMediaImageVariant = (\n value: unknown\n): value is PortableTextMediaImageVariant =>\n typeof value === \"string\" && value in MEDIA_IMAGE_VARIANTS;\n\nexport interface PortableTextMediaBlock {\n type: \"media\";\n src: string;\n alt?: string;\n variant?: PortableTextMediaVariant;\n caption?: string;\n}\n\nexport interface PortableTextTitledTextBlock {\n type: \"titled-text\";\n /**\n * Same semantic scale as `heading` — 1, 2 or 3 (the default) — so the wire\n * format never encodes a typography name. How a level looks is the\n * renderer's business.\n */\n level?: PortableTextHeadingLevel;\n title: string;\n content?: PortableTextNode[];\n}\n\nexport interface PortableTextCodeBlock {\n type: \"code-block\";\n /**\n * A language hint (e.g. \"php\", \"json\"). The default renderer does no\n * highlighting, so any value — known, unknown or absent — renders as plain\n * preformatted text; it travels as data for surfaces that highlight.\n */\n language?: string;\n code: string;\n}\n\n/** A table cell is a span array, so inline marks work inside cells. */\nexport type PortableTextTableCell = PortableTextSpan[];\nexport type PortableTextTableRow = PortableTextTableCell[];\n\nexport interface PortableTextTableBlock {\n type: \"table\";\n header: PortableTextTableRow;\n rows: PortableTextTableRow[];\n}\n\n/** A themed horizontal rule between sections. Carries no data. */\nexport interface PortableTextDividerBlock {\n type: \"divider\";\n}\n\nexport type PortableTextBlock =\n | PortableTextParagraphBlock\n | PortableTextHeadingBlock\n | PortableTextListBlock\n | PortableTextMediaBlock\n | PortableTextTitledTextBlock\n | PortableTextCodeBlock\n | PortableTextTableBlock\n | PortableTextDividerBlock;\n\n/**\n * Derived from the union's discriminators, so adding a block to the union\n * without a renderer entry is a compile error, never silent drift.\n */\nexport type PortableTextDefaultBlockType = (\n | PortableTextBlock\n | PortableTextListItemBlock\n)[\"type\"];\n\n// A Record so the compiler checks the list against the union in both\n// directions: a missing and a stray key each fail to build.\nconst DEFAULT_BLOCK_TYPES: Record<PortableTextDefaultBlockType, true> = {\n paragraph: true,\n heading: true,\n list: true,\n \"list-item\": true,\n media: true,\n \"titled-text\": true,\n \"code-block\": true,\n table: true,\n divider: true,\n};\n\n/** Blocks every client understands without injection. */\nexport const PORTABLE_TEXT_DEFAULT_BLOCKS = Object.keys(\n DEFAULT_BLOCK_TYPES\n) as readonly PortableTextDefaultBlockType[];\n\n/* ---- Objects ----------------------------------------------------------- */\n\n/**\n * An embedded component the envelope does not interpret: `_type` names an\n * application-catalog element, everything else is that element's data. An\n * object whose `_type` has no injected renderer renders nothing and is logged.\n */\nexport interface PortableTextObjectNode {\n type: \"object\";\n _type: string;\n [data: string]: unknown;\n}\n\nexport type PortableTextNode = PortableTextBlock | PortableTextObjectNode;\n\n/** The root of a message body: what an API returns under `content`. */\nexport type PortableTextContent = PortableTextNode[];\n\n/* ---- Injection contract ------------------------------------------------ */\n\nexport interface PortableTextMarkRendererProps<\n TMark extends PortableTextMarkObject = PortableTextMarkObject\n> {\n /** Present for object marks; absent when the mark is a plain string. */\n mark?: TMark;\n children: ReactNode;\n}\n\nexport type PortableTextMarkRenderer<\n TMark extends PortableTextMarkObject = PortableTextMarkObject\n> = ComponentType<PortableTextMarkRendererProps<TMark>>;\n\nexport interface PortableTextObjectRendererProps<\n TNode extends PortableTextObjectNode = PortableTextObjectNode\n> {\n node: TNode;\n /** The object's nested `content`, already rendered by the engine. */\n children?: ReactNode;\n}\n\nexport type PortableTextObjectRenderer<\n TNode extends PortableTextObjectNode = PortableTextObjectNode\n> = ComponentType<PortableTextObjectRendererProps<TNode>>;\n\nexport interface PortableTextBlockRendererProps<\n TBlock extends PortableTextBlock = PortableTextBlock\n> {\n block: TBlock;\n /** The block's rendered children/content, when it has any. */\n children?: ReactNode;\n /**\n * Engine-bound span renderer for blocks that carry spans outside `children`\n * (table cells). Resolves marks with the same precedence — injected first,\n * then defaults — as flowing text. Absent when a renderer is used without\n * the engine.\n */\n renderSpans?: (spans: PortableTextSpan[]) => ReactNode;\n}\n\nexport type PortableTextBlockRenderer<\n TBlock extends PortableTextBlock = PortableTextBlock\n> = ComponentType<PortableTextBlockRendererProps<TBlock>>;\n\nexport type PortableTextUnknownKind = \"block\" | \"mark\" | \"object\";\n\n/**\n * Called once per unknown type instead of rendering it, so content written\n * for newer clients degrades silently on older ones.\n */\nexport type PortableTextUnknownTypeHandler = (\n kind: PortableTextUnknownKind,\n type: string\n) => void;\n\n/**\n * What an application injects into the Portable Text engine: renderers for\n * its catalog marks and objects, optional overrides for the default blocks,\n * and the unknown-type hook.\n */\nexport interface PortableTextComponents {\n marks?: Record<string, PortableTextMarkRenderer>;\n objects?: Record<string, PortableTextObjectRenderer>;\n blocks?: Partial<\n Record<PortableTextDefaultBlockType, PortableTextBlockRenderer>\n >;\n onUnknownType?: PortableTextUnknownTypeHandler;\n}\n\n/* ---- Runtime guards ----------------------------------------------------- */\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === \"object\" && value !== null;\n\nexport const isPortableTextSpan = (value: unknown): value is PortableTextSpan =>\n isRecord(value) && typeof value.text === \"string\";\n\nexport const isPortableTextTableRow = (\n value: unknown\n): value is PortableTextTableRow =>\n Array.isArray(value) &&\n value.every((cell) => Array.isArray(cell) && cell.every(isPortableTextSpan));\n\nexport const isPortableTextObjectNode = (\n value: unknown\n): value is PortableTextObjectNode =>\n isRecord(value) && value.type === \"object\" && typeof value._type === \"string\";\n\n/**\n * A block is any non-object node with a string `type`. Unknown block types\n * stay valid on purpose — they render nothing on clients that predate them.\n * Known types are held to their shape, so a serializer bug (a paragraph\n * without `children`, a list of non-nodes) fails here instead of at render.\n */\nexport const isPortableTextBlock = (\n value: unknown\n): value is PortableTextBlock => {\n if (\n !isRecord(value) ||\n typeof value.type !== \"string\" ||\n value.type === \"object\"\n ) {\n return false;\n }\n\n switch (value.type) {\n case \"paragraph\":\n case \"heading\":\n return (\n Array.isArray(value.children) &&\n value.children.every(isPortableTextSpan)\n );\n case \"list-item\":\n // The item's spans, plus optional nested `list` block(s). Widened only\n // for nested lists: any other block child (a stray paragraph, an object)\n // still fails, so a serializer bug is caught here, not at render.\n return (\n Array.isArray(value.children) &&\n value.children.every(\n (child) =>\n isPortableTextSpan(child) ||\n (isPortableTextBlock(child) && child.type === \"list\")\n )\n );\n case \"list\":\n // A list holds `list-item`s only. A sublist emitted as a sibling of the\n // items (the classic half-implemented-nesting bug) renders invalid HTML\n // — <ul> with a direct <ul> child — so it fails here, not at render.\n // `list-item` is validated but sits outside the PortableTextBlock union,\n // so the discriminator is checked before isPortableTextBlock narrows it.\n return (\n Array.isArray(value.children) &&\n value.children.every(\n (child) =>\n isRecord(child) &&\n child.type === \"list-item\" &&\n isPortableTextBlock(child)\n )\n );\n case \"media\":\n return typeof value.src === \"string\";\n case \"titled-text\":\n return (\n typeof value.title === \"string\" &&\n (value.content === undefined || isPortableTextContent(value.content))\n );\n case \"code-block\":\n return (\n typeof value.code === \"string\" &&\n (value.language === undefined || typeof value.language === \"string\")\n );\n case \"table\":\n return (\n isPortableTextTableRow(value.header) &&\n Array.isArray(value.rows) &&\n value.rows.every(isPortableTextTableRow)\n );\n case \"divider\":\n return true;\n default:\n return true;\n }\n};\n\nexport const isPortableTextContent = (\n value: unknown\n): value is PortableTextContent =>\n Array.isArray(value) &&\n value.every(\n (node) => isPortableTextBlock(node) || isPortableTextObjectNode(node)\n );\n"],"mappings":";;;;;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAMA;;AAQA;;AAMA;AACO,IAAMA,2BAA2B,GAAAC,OAAA,CAAAD,2BAAA,GAAG,CACzC,QAAQ,EACR,IAAI,EACJ,MAAM,EACN,MAAM,CACE;;AAKV;;AAOA;;AAWA;AACA;AACA;AACA;AACA;;AAYA;;AAGA;AACA;AACA;AACA;AACA;AACA;;AAOA;AACA;AACA,IAAME,oBAAiE,GAAG;EACxEC,UAAU,EAAE,IAAI;EAChBC,YAAY,EAAE;AAChB,CAAC;AAEM,IAAMC,+BAA+B,GAAAJ,OAAA,CAAAI,+BAAA,GAAG,SAAlCA,+BAA+BA,CAC1CC,KAAc;EAAA,OAEd,OAAOA,KAAK,KAAK,QAAQ,IAAIA,KAAK,IAAIJ,oBAAoB;AAAA;;AAiC5D;;AAUA;;AAeA;AACA;AACA;AACA;;AAMA;AACA;AACA,IAAMK,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,QAAQ,KAC9B1B,KAAK,CAAC2B,OAAO,KAAKC,SAAS,IAAIC,qBAAqB,CAAC7B,KAAK,CAAC2B,OAAO,CAAC,CAAC;IAEzE,KAAK,YAAY;MACf,OACE,OAAO3B,KAAK,CAAC8B,IAAI,KAAK,QAAQ,KAC7B9B,KAAK,CAAC+B,QAAQ,KAAKH,SAAS,IAAI,OAAO5B,KAAK,CAAC+B,QAAQ,KAAK,QAAQ,CAAC;IAExE,KAAK,OAAO;MACV,OACEjB,sBAAsB,CAACd,KAAK,CAACgC,MAAM,CAAC,IACpCjB,KAAK,CAACC,OAAO,CAAChB,KAAK,CAACiC,IAAI,CAAC,IACzBjC,KAAK,CAACiC,IAAI,CAAChB,KAAK,CAACH,sBAAsB,CAAC;IAE5C,KAAK,SAAS;MACZ,OAAO,IAAI;IACb;MACE,OAAO,IAAI;EACf;AACF,CAAC;AAEM,IAAMe,qBAAqB,GAAAlC,OAAA,CAAAkC,qBAAA,GAAG,SAAxBA,qBAAqBA,CAChC7B,KAAc;EAAA,OAEde,KAAK,CAACC,OAAO,CAAChB,KAAK,CAAC,IACpBA,KAAK,CAACiB,KAAK,CACT,UAACiB,IAAI;IAAA,OAAKZ,oBAAmB,CAACY,IAAI,CAAC,IAAIf,wBAAwB,CAACe,IAAI,CAAC;EAAA,CACvE,CAAC;AAAA","ignoreList":[]}
|
|
@@ -199,6 +199,126 @@ describe("PortableText envelope", function () {
|
|
|
199
199
|
rows: []
|
|
200
200
|
}])).toBe(false);
|
|
201
201
|
});
|
|
202
|
+
it("accepts a list-item whose children nest a list block after its spans", function () {
|
|
203
|
+
expect((0, _types.isPortableTextContent)([{
|
|
204
|
+
type: "list",
|
|
205
|
+
style: "bullet",
|
|
206
|
+
children: [{
|
|
207
|
+
type: "list-item",
|
|
208
|
+
children: [{
|
|
209
|
+
text: "Step 3:",
|
|
210
|
+
marks: ["strong"]
|
|
211
|
+
}, {
|
|
212
|
+
text: " Choose one of the following options:"
|
|
213
|
+
}, {
|
|
214
|
+
type: "list",
|
|
215
|
+
style: "bullet",
|
|
216
|
+
children: [{
|
|
217
|
+
type: "list-item",
|
|
218
|
+
children: [{
|
|
219
|
+
text: "Sign in via Email"
|
|
220
|
+
}]
|
|
221
|
+
}, {
|
|
222
|
+
type: "list-item",
|
|
223
|
+
children: [{
|
|
224
|
+
text: "Sign in via your Google account"
|
|
225
|
+
}]
|
|
226
|
+
}]
|
|
227
|
+
}]
|
|
228
|
+
}]
|
|
229
|
+
}])).toBe(true);
|
|
230
|
+
});
|
|
231
|
+
it("validates a list nested four levels deep with mixed styles per level", function () {
|
|
232
|
+
expect((0, _types.isPortableTextContent)([{
|
|
233
|
+
type: "list",
|
|
234
|
+
style: "number",
|
|
235
|
+
children: [{
|
|
236
|
+
type: "list-item",
|
|
237
|
+
children: [{
|
|
238
|
+
text: "Top level, ordered"
|
|
239
|
+
}, {
|
|
240
|
+
type: "list",
|
|
241
|
+
style: "bullet",
|
|
242
|
+
children: [{
|
|
243
|
+
type: "list-item",
|
|
244
|
+
children: [{
|
|
245
|
+
text: "Level 2, bullet"
|
|
246
|
+
}, {
|
|
247
|
+
type: "list",
|
|
248
|
+
style: "number",
|
|
249
|
+
children: [{
|
|
250
|
+
type: "list-item",
|
|
251
|
+
children: [{
|
|
252
|
+
text: "Level 3, ordered"
|
|
253
|
+
}, {
|
|
254
|
+
type: "list",
|
|
255
|
+
style: "bullet",
|
|
256
|
+
children: [{
|
|
257
|
+
type: "list-item",
|
|
258
|
+
children: [{
|
|
259
|
+
text: "Level 4, bullet"
|
|
260
|
+
}]
|
|
261
|
+
}]
|
|
262
|
+
}]
|
|
263
|
+
}]
|
|
264
|
+
}]
|
|
265
|
+
}]
|
|
266
|
+
}]
|
|
267
|
+
}]
|
|
268
|
+
}])).toBe(true);
|
|
269
|
+
});
|
|
270
|
+
it("rejects a list whose child is a sublist instead of a list-item", function () {
|
|
271
|
+
// The classic half-implemented-nesting bug: the sublist is emitted as a
|
|
272
|
+
// sibling of the items rather than inside one. It renders invalid HTML
|
|
273
|
+
// (<ul> with a direct <ul> child), so the guard must reject it.
|
|
274
|
+
expect((0, _types.isPortableTextContent)([{
|
|
275
|
+
type: "list",
|
|
276
|
+
style: "bullet",
|
|
277
|
+
children: [{
|
|
278
|
+
type: "list-item",
|
|
279
|
+
children: [{
|
|
280
|
+
text: "Parent"
|
|
281
|
+
}]
|
|
282
|
+
}, {
|
|
283
|
+
type: "list",
|
|
284
|
+
style: "bullet",
|
|
285
|
+
children: [{
|
|
286
|
+
type: "list-item",
|
|
287
|
+
children: [{
|
|
288
|
+
text: "Orphan sub"
|
|
289
|
+
}]
|
|
290
|
+
}]
|
|
291
|
+
}]
|
|
292
|
+
}])).toBe(false);
|
|
293
|
+
});
|
|
294
|
+
it("rejects a list-item child that is neither a span nor a nested list", function () {
|
|
295
|
+
// A stray paragraph child — the guard is widened for nested lists only.
|
|
296
|
+
expect((0, _types.isPortableTextContent)([{
|
|
297
|
+
type: "list",
|
|
298
|
+
children: [{
|
|
299
|
+
type: "list-item",
|
|
300
|
+
children: [{
|
|
301
|
+
text: "An item"
|
|
302
|
+
}, {
|
|
303
|
+
type: "paragraph",
|
|
304
|
+
children: [{
|
|
305
|
+
text: "not allowed here"
|
|
306
|
+
}]
|
|
307
|
+
}]
|
|
308
|
+
}]
|
|
309
|
+
}])).toBe(false);
|
|
310
|
+
// An embedded object child is rejected too.
|
|
311
|
+
expect((0, _types.isPortableTextContent)([{
|
|
312
|
+
type: "list",
|
|
313
|
+
children: [{
|
|
314
|
+
type: "list-item",
|
|
315
|
+
children: [{
|
|
316
|
+
type: "object",
|
|
317
|
+
_type: "callout"
|
|
318
|
+
}]
|
|
319
|
+
}]
|
|
320
|
+
}])).toBe(false);
|
|
321
|
+
});
|
|
202
322
|
it("accepts a code-block without a language and a table without rows", function () {
|
|
203
323
|
expect((0, _types.isPortableTextContent)([{
|
|
204
324
|
type: "code-block",
|
|
@@ -243,6 +363,23 @@ describe("PortableText envelope", function () {
|
|
|
243
363
|
expect(_types.PORTABLE_TEXT_DEFAULT_BLOCKS).toEqual(["paragraph", "heading", "list", "list-item", "media", "titled-text", "code-block", "table", "divider"]);
|
|
244
364
|
expect(_types.PORTABLE_TEXT_DEFAULT_MARKS).toEqual(["strong", "em", "code", "link"]);
|
|
245
365
|
});
|
|
366
|
+
it("keeps video media variants in the envelope but out of the image variant set", function () {
|
|
367
|
+
expect((0, _types.isPortableTextContent)([{
|
|
368
|
+
type: "media",
|
|
369
|
+
variant: "vimeo",
|
|
370
|
+
src: "https://vimeo.com/1131696931",
|
|
371
|
+
caption: "Duplicating a project"
|
|
372
|
+
}, {
|
|
373
|
+
type: "media",
|
|
374
|
+
variant: "youtube",
|
|
375
|
+
src: "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
|
|
376
|
+
}])).toBe(true);
|
|
377
|
+
expect((0, _types.isPortableTextMediaImageVariant)("screenshot")).toBe(true);
|
|
378
|
+
expect((0, _types.isPortableTextMediaImageVariant)("illustration")).toBe(true);
|
|
379
|
+
expect((0, _types.isPortableTextMediaImageVariant)("vimeo")).toBe(false);
|
|
380
|
+
expect((0, _types.isPortableTextMediaImageVariant)("youtube")).toBe(false);
|
|
381
|
+
expect((0, _types.isPortableTextMediaImageVariant)(undefined)).toBe(false);
|
|
382
|
+
});
|
|
246
383
|
it("accepts an application components map through the injection contract", function () {
|
|
247
384
|
var _components$onUnknown, _components$marks;
|
|
248
385
|
var seen = [];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.test.js","names":["_react","require","_types","describe","sampleMessageContent","type","level","children","text","marks","article","style","src","variant","caption","title","content","_type","tone","label","language","code","header","rows","it","expect","isPortableTextContent","toBe","payload","data","heading","paragraph","callout","isPortableTextBlock","isPortableTextObjectNode","isPortableTextSpan","PORTABLE_TEXT_DEFAULT_BLOCKS","toEqual","PORTABLE_TEXT_DEFAULT_MARKS","_components$onUnknown","_components$marks","seen","components","interfaceName","_ref","createElement","Fragment","objects","_ref2","onUnknownType","kind","push","concat","call","Object","keys"],"sources":["../../../../src/components/PortableText/types.test.ts"],"sourcesContent":["import { createElement, Fragment } from \"react\";\n\nimport {\n isPortableTextBlock,\n isPortableTextContent,\n isPortableTextObjectNode,\n isPortableTextSpan,\n PORTABLE_TEXT_DEFAULT_BLOCKS,\n PORTABLE_TEXT_DEFAULT_MARKS,\n PortableTextComponents,\n PortableTextContent,\n} from \"./types\";\n\ndescribe(\"PortableText envelope\", () => {\n const sampleMessageContent: PortableTextContent = [\n { type: \"heading\", level: 2, children: [{ text: \"IP Firewall\" }] },\n {\n type: \"paragraph\",\n children: [\n { text: \"Open the \" },\n { text: \"Security page\", marks: [\"interface-name\"] },\n { text: \" and press \" },\n { text: \"Enter\", marks: [\"keyboard-key\"] },\n { text: \". Read more in \" },\n {\n text: \"the help article\",\n marks: [{ type: \"doc-link\", article: \"ip-firewall\" }],\n },\n { text: \".\" },\n ],\n },\n {\n type: \"list\",\n style: \"bullet\",\n children: [\n {\n type: \"list-item\",\n children: [{ text: \"Allowlist the IPs you trust\" }],\n },\n {\n type: \"list-item\",\n children: [{ text: \"immediately\", marks: [\"strong\"] }],\n },\n ],\n },\n {\n type: \"media\",\n src: \"/screenshots/firewall.png\",\n variant: \"screenshot\",\n caption: \"The firewall settings\",\n },\n {\n type: \"titled-text\",\n title: \"Allowlist the IPs you trust\",\n level: 3,\n content: [\n { type: \"paragraph\", children: [{ text: \"Add one range per line.\" }] },\n ],\n },\n {\n type: \"object\",\n _type: \"callout\",\n tone: \"note\",\n content: [\n {\n type: \"paragraph\",\n children: [{ text: \"Takes effect immediately.\" }],\n },\n ],\n },\n {\n type: \"object\",\n _type: \"button-reference\",\n label: \"Save Changes\",\n variant: \"primary\",\n },\n { type: \"divider\" },\n {\n type: \"code-block\",\n language: \"json\",\n code: '{ \"allowlist\": [\"203.0.113.0/24\"] }',\n },\n {\n type: \"table\",\n header: [[{ text: \"Range\" }], [{ text: \"Purpose\" }]],\n rows: [\n [\n [{ text: \"203.0.113.0/24\", marks: [\"code\"] }],\n [{ text: \"Office\", marks: [\"strong\"] }],\n ],\n [[{ text: \"198.51.100.0/24\", marks: [\"code\"] }], [{ text: \"VPN\" }]],\n ],\n },\n ];\n\n it(\"validates a sample message that mixes default blocks and catalog objects\", () => {\n expect(isPortableTextContent(sampleMessageContent)).toBe(true);\n });\n\n it(\"keeps unknown block and object types valid so older clients degrade instead of break\", () => {\n expect(\n isPortableTextContent([\n { type: \"some-future-block\", payload: 1 },\n { type: \"object\", _type: \"some-future-element\", data: true },\n ])\n ).toBe(true);\n });\n\n it(\"rejects nodes without a type discriminator and objects without _type\", () => {\n expect(isPortableTextContent([{ children: [] }])).toBe(false);\n expect(isPortableTextContent([{ type: \"object\" }])).toBe(false);\n expect(isPortableTextContent([\"paragraph\"])).toBe(false);\n expect(isPortableTextContent({ content: [] })).toBe(false);\n });\n\n it(\"rejects known blocks whose shape a serializer bug has broken\", () => {\n expect(isPortableTextContent([{ type: \"paragraph\" }])).toBe(false);\n expect(\n isPortableTextContent([{ type: \"heading\", level: 2, children: \"oops\" }])\n ).toBe(false);\n expect(\n isPortableTextContent([\n { type: \"paragraph\", children: [{ marks: [\"strong\"] }] },\n ])\n ).toBe(false);\n expect(isPortableTextContent([{ type: \"list\" }])).toBe(false);\n expect(\n isPortableTextContent([{ type: \"list\", children: [\"not a node\"] }])\n ).toBe(false);\n expect(isPortableTextContent([{ type: \"media\" }])).toBe(false);\n expect(isPortableTextContent([{ type: \"titled-text\", content: [] }])).toBe(\n false\n );\n expect(\n isPortableTextContent([\n { type: \"titled-text\", title: \"Ranges\", content: \"oops\" },\n ])\n ).toBe(false);\n });\n\n it(\"rejects malformed code-block, table and divider-adjacent shapes\", () => {\n expect(isPortableTextContent([{ type: \"code-block\" }])).toBe(false);\n expect(isPortableTextContent([{ type: \"code-block\", code: 42 }])).toBe(\n false\n );\n expect(\n isPortableTextContent([{ type: \"code-block\", code: \"x\", language: 1 }])\n ).toBe(false);\n expect(isPortableTextContent([{ type: \"table\" }])).toBe(false);\n expect(\n isPortableTextContent([{ type: \"table\", header: [], rows: \"oops\" }])\n ).toBe(false);\n expect(\n isPortableTextContent([\n { type: \"table\", header: [[{ text: \"A\" }]], rows: [[\"not a cell\"]] },\n ])\n ).toBe(false);\n expect(\n isPortableTextContent([\n { type: \"table\", header: [{ text: \"not a cell\" }], rows: [] },\n ])\n ).toBe(false);\n });\n\n it(\"accepts a code-block without a language and a table without rows\", () => {\n expect(\n isPortableTextContent([{ type: \"code-block\", code: \"npm install\" }])\n ).toBe(true);\n expect(\n isPortableTextContent([\n { type: \"table\", header: [[{ text: \"A\" }]], rows: [] },\n ])\n ).toBe(true);\n expect(isPortableTextContent([{ type: \"divider\" }])).toBe(true);\n });\n\n it(\"accepts a titled-text with only a title, with or without content\", () => {\n expect(\n isPortableTextContent([{ type: \"titled-text\", title: \"Ranges\" }])\n ).toBe(true);\n expect(\n isPortableTextContent([\n { type: \"titled-text\", title: \"Ranges\", content: [] },\n ])\n ).toBe(true);\n });\n\n it(\"tells blocks, objects and spans apart\", () => {\n const [heading, paragraph] = sampleMessageContent;\n const callout = sampleMessageContent[5];\n\n expect(isPortableTextBlock(heading)).toBe(true);\n expect(isPortableTextBlock(callout)).toBe(false);\n expect(isPortableTextObjectNode(callout)).toBe(true);\n expect(isPortableTextObjectNode(heading)).toBe(false);\n expect(isPortableTextSpan({ text: \"plain\" })).toBe(true);\n expect(isPortableTextSpan(paragraph)).toBe(false);\n });\n\n it(\"ships a universal default set free of product elements\", () => {\n expect(PORTABLE_TEXT_DEFAULT_BLOCKS).toEqual([\n \"paragraph\",\n \"heading\",\n \"list\",\n \"list-item\",\n \"media\",\n \"titled-text\",\n \"code-block\",\n \"table\",\n \"divider\",\n ]);\n expect(PORTABLE_TEXT_DEFAULT_MARKS).toEqual([\n \"strong\",\n \"em\",\n \"code\",\n \"link\",\n ]);\n });\n\n it(\"accepts an application components map through the injection contract\", () => {\n const seen: string[] = [];\n const components: PortableTextComponents = {\n marks: {\n \"interface-name\": ({ children }) =>\n createElement(Fragment, null, children),\n },\n objects: {\n callout: ({ children }) => createElement(Fragment, null, children),\n },\n onUnknownType: (kind, type) => {\n seen.push(`${kind}:${type}`);\n },\n };\n\n components.onUnknownType?.(\"object\", \"some-future-element\");\n\n expect(Object.keys(components.marks ?? {})).toEqual([\"interface-name\"]);\n expect(seen).toEqual([\"object:some-future-element\"]);\n });\n});\n"],"mappings":";;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAEA,IAAAC,MAAA,GAAAD,OAAA;AAWAE,QAAQ,CAAC,uBAAuB,EAAE,YAAM;EACtC,IAAMC,oBAAyC,GAAG,CAChD;IAAEC,IAAI,EAAE,SAAS;IAAEC,KAAK,EAAE,CAAC;IAAEC,QAAQ,EAAE,CAAC;MAAEC,IAAI,EAAE;IAAc,CAAC;EAAE,CAAC,EAClE;IACEH,IAAI,EAAE,WAAW;IACjBE,QAAQ,EAAE,CACR;MAAEC,IAAI,EAAE;IAAY,CAAC,EACrB;MAAEA,IAAI,EAAE,eAAe;MAAEC,KAAK,EAAE,CAAC,gBAAgB;IAAE,CAAC,EACpD;MAAED,IAAI,EAAE;IAAc,CAAC,EACvB;MAAEA,IAAI,EAAE,OAAO;MAAEC,KAAK,EAAE,CAAC,cAAc;IAAE,CAAC,EAC1C;MAAED,IAAI,EAAE;IAAkB,CAAC,EAC3B;MACEA,IAAI,EAAE,kBAAkB;MACxBC,KAAK,EAAE,CAAC;QAAEJ,IAAI,EAAE,UAAU;QAAEK,OAAO,EAAE;MAAc,CAAC;IACtD,CAAC,EACD;MAAEF,IAAI,EAAE;IAAI,CAAC;EAEjB,CAAC,EACD;IACEH,IAAI,EAAE,MAAM;IACZM,KAAK,EAAE,QAAQ;IACfJ,QAAQ,EAAE,CACR;MACEF,IAAI,EAAE,WAAW;MACjBE,QAAQ,EAAE,CAAC;QAAEC,IAAI,EAAE;MAA8B,CAAC;IACpD,CAAC,EACD;MACEH,IAAI,EAAE,WAAW;MACjBE,QAAQ,EAA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AE;QACPf,OAAO,EAAE,SAATA,OAAOA,CAAAgB,KAAA;UAAA,IAAKzC,QAAQ,GAAAyC,KAAA,CAARzC,QAAQ;UAAA,oBAAO,IAAAsC,oBAAa,EAACC,eAAQ,EAAE,IAAI,EAAEvC,QAAQ,CAAC;QAAA;MACpE,CAAC;MACD0C,aAAa,EAAE,SAAfA,aAAaA,CAAGC,IAAI,EAAE7C,IAAI,EAAK;QAC7BoC,IAAI,CAACU,IAAI,IAAAC,MAAA,CAAIF,IAAI,OAAAE,MAAA,CAAI/C,IAAI,CAAE,CAAC;MAC9B;IACF,CAAC;IAED,CAAAkC,qBAAA,GAAAG,UAAU,CAACO,aAAa,cAAAV,qBAAA,eAAxBA,qBAAA,CAAAc,IAAA,CAAAX,UAAU,EAAiB,QAAQ,EAAE,qBAAqB,CAAC;IAE3DjB,MAAM,CAAC6B,MAAM,CAACC,IAAI,EAAAf,iBAAA,GAACE,UAAU,CAACjC,KAAK,cAAA+B,iBAAA,cAAAA,iBAAA,GAAI,CAAC,CAAC,CAAC,CAAC,CAACH,OAAO,CAAC,CAAC,gBAAgB,CAAC,CAAC;IACvEZ,MAAM,CAACgB,IAAI,CAAC,CAACJ,OAAO,CAAC,CAAC,4BAA4B,CAAC,CAAC;EACtD,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"types.test.js","names":["_react","require","_types","describe","sampleMessageContent","type","level","children","text","marks","article","style","src","variant","caption","title","content","_type","tone","label","language","code","header","rows","it","expect","isPortableTextContent","toBe","payload","data","heading","paragraph","callout","isPortableTextBlock","isPortableTextObjectNode","isPortableTextSpan","PORTABLE_TEXT_DEFAULT_BLOCKS","toEqual","PORTABLE_TEXT_DEFAULT_MARKS","isPortableTextMediaImageVariant","undefined","_components$onUnknown","_components$marks","seen","components","interfaceName","_ref","createElement","Fragment","objects","_ref2","onUnknownType","kind","push","concat","call","Object","keys"],"sources":["../../../../src/components/PortableText/types.test.ts"],"sourcesContent":["import { createElement, Fragment } from \"react\";\n\nimport {\n isPortableTextBlock,\n isPortableTextContent,\n isPortableTextMediaImageVariant,\n isPortableTextObjectNode,\n isPortableTextSpan,\n PORTABLE_TEXT_DEFAULT_BLOCKS,\n PORTABLE_TEXT_DEFAULT_MARKS,\n PortableTextComponents,\n PortableTextContent,\n} from \"./types\";\n\ndescribe(\"PortableText envelope\", () => {\n const sampleMessageContent: PortableTextContent = [\n { type: \"heading\", level: 2, children: [{ text: \"IP Firewall\" }] },\n {\n type: \"paragraph\",\n children: [\n { text: \"Open the \" },\n { text: \"Security page\", marks: [\"interface-name\"] },\n { text: \" and press \" },\n { text: \"Enter\", marks: [\"keyboard-key\"] },\n { text: \". Read more in \" },\n {\n text: \"the help article\",\n marks: [{ type: \"doc-link\", article: \"ip-firewall\" }],\n },\n { text: \".\" },\n ],\n },\n {\n type: \"list\",\n style: \"bullet\",\n children: [\n {\n type: \"list-item\",\n children: [{ text: \"Allowlist the IPs you trust\" }],\n },\n {\n type: \"list-item\",\n children: [{ text: \"immediately\", marks: [\"strong\"] }],\n },\n ],\n },\n {\n type: \"media\",\n src: \"/screenshots/firewall.png\",\n variant: \"screenshot\",\n caption: \"The firewall settings\",\n },\n {\n type: \"titled-text\",\n title: \"Allowlist the IPs you trust\",\n level: 3,\n content: [\n { type: \"paragraph\", children: [{ text: \"Add one range per line.\" }] },\n ],\n },\n {\n type: \"object\",\n _type: \"callout\",\n tone: \"note\",\n content: [\n {\n type: \"paragraph\",\n children: [{ text: \"Takes effect immediately.\" }],\n },\n ],\n },\n {\n type: \"object\",\n _type: \"button-reference\",\n label: \"Save Changes\",\n variant: \"primary\",\n },\n { type: \"divider\" },\n {\n type: \"code-block\",\n language: \"json\",\n code: '{ \"allowlist\": [\"203.0.113.0/24\"] }',\n },\n {\n type: \"table\",\n header: [[{ text: \"Range\" }], [{ text: \"Purpose\" }]],\n rows: [\n [\n [{ text: \"203.0.113.0/24\", marks: [\"code\"] }],\n [{ text: \"Office\", marks: [\"strong\"] }],\n ],\n [[{ text: \"198.51.100.0/24\", marks: [\"code\"] }], [{ text: \"VPN\" }]],\n ],\n },\n ];\n\n it(\"validates a sample message that mixes default blocks and catalog objects\", () => {\n expect(isPortableTextContent(sampleMessageContent)).toBe(true);\n });\n\n it(\"keeps unknown block and object types valid so older clients degrade instead of break\", () => {\n expect(\n isPortableTextContent([\n { type: \"some-future-block\", payload: 1 },\n { type: \"object\", _type: \"some-future-element\", data: true },\n ])\n ).toBe(true);\n });\n\n it(\"rejects nodes without a type discriminator and objects without _type\", () => {\n expect(isPortableTextContent([{ children: [] }])).toBe(false);\n expect(isPortableTextContent([{ type: \"object\" }])).toBe(false);\n expect(isPortableTextContent([\"paragraph\"])).toBe(false);\n expect(isPortableTextContent({ content: [] })).toBe(false);\n });\n\n it(\"rejects known blocks whose shape a serializer bug has broken\", () => {\n expect(isPortableTextContent([{ type: \"paragraph\" }])).toBe(false);\n expect(\n isPortableTextContent([{ type: \"heading\", level: 2, children: \"oops\" }])\n ).toBe(false);\n expect(\n isPortableTextContent([\n { type: \"paragraph\", children: [{ marks: [\"strong\"] }] },\n ])\n ).toBe(false);\n expect(isPortableTextContent([{ type: \"list\" }])).toBe(false);\n expect(\n isPortableTextContent([{ type: \"list\", children: [\"not a node\"] }])\n ).toBe(false);\n expect(isPortableTextContent([{ type: \"media\" }])).toBe(false);\n expect(isPortableTextContent([{ type: \"titled-text\", content: [] }])).toBe(\n false\n );\n expect(\n isPortableTextContent([\n { type: \"titled-text\", title: \"Ranges\", content: \"oops\" },\n ])\n ).toBe(false);\n });\n\n it(\"rejects malformed code-block, table and divider-adjacent shapes\", () => {\n expect(isPortableTextContent([{ type: \"code-block\" }])).toBe(false);\n expect(isPortableTextContent([{ type: \"code-block\", code: 42 }])).toBe(\n false\n );\n expect(\n isPortableTextContent([{ type: \"code-block\", code: \"x\", language: 1 }])\n ).toBe(false);\n expect(isPortableTextContent([{ type: \"table\" }])).toBe(false);\n expect(\n isPortableTextContent([{ type: \"table\", header: [], rows: \"oops\" }])\n ).toBe(false);\n expect(\n isPortableTextContent([\n { type: \"table\", header: [[{ text: \"A\" }]], rows: [[\"not a cell\"]] },\n ])\n ).toBe(false);\n expect(\n isPortableTextContent([\n { type: \"table\", header: [{ text: \"not a cell\" }], rows: [] },\n ])\n ).toBe(false);\n });\n\n it(\"accepts a list-item whose children nest a list block after its spans\", () => {\n expect(\n isPortableTextContent([\n {\n type: \"list\",\n style: \"bullet\",\n children: [\n {\n type: \"list-item\",\n children: [\n { text: \"Step 3:\", marks: [\"strong\"] },\n { text: \" Choose one of the following options:\" },\n {\n type: \"list\",\n style: \"bullet\",\n children: [\n {\n type: \"list-item\",\n children: [{ text: \"Sign in via Email\" }],\n },\n {\n type: \"list-item\",\n children: [{ text: \"Sign in via your Google account\" }],\n },\n ],\n },\n ],\n },\n ],\n },\n ])\n ).toBe(true);\n });\n\n it(\"validates a list nested four levels deep with mixed styles per level\", () => {\n expect(\n isPortableTextContent([\n {\n type: \"list\",\n style: \"number\",\n children: [\n {\n type: \"list-item\",\n children: [\n { text: \"Top level, ordered\" },\n {\n type: \"list\",\n style: \"bullet\",\n children: [\n {\n type: \"list-item\",\n children: [\n { text: \"Level 2, bullet\" },\n {\n type: \"list\",\n style: \"number\",\n children: [\n {\n type: \"list-item\",\n children: [\n { text: \"Level 3, ordered\" },\n {\n type: \"list\",\n style: \"bullet\",\n children: [\n {\n type: \"list-item\",\n children: [{ text: \"Level 4, bullet\" }],\n },\n ],\n },\n ],\n },\n ],\n },\n ],\n },\n ],\n },\n ],\n },\n ],\n },\n ])\n ).toBe(true);\n });\n\n it(\"rejects a list whose child is a sublist instead of a list-item\", () => {\n // The classic half-implemented-nesting bug: the sublist is emitted as a\n // sibling of the items rather than inside one. It renders invalid HTML\n // (<ul> with a direct <ul> child), so the guard must reject it.\n expect(\n isPortableTextContent([\n {\n type: \"list\",\n style: \"bullet\",\n children: [\n { type: \"list-item\", children: [{ text: \"Parent\" }] },\n {\n type: \"list\",\n style: \"bullet\",\n children: [\n { type: \"list-item\", children: [{ text: \"Orphan sub\" }] },\n ],\n },\n ],\n },\n ])\n ).toBe(false);\n });\n\n it(\"rejects a list-item child that is neither a span nor a nested list\", () => {\n // A stray paragraph child — the guard is widened for nested lists only.\n expect(\n isPortableTextContent([\n {\n type: \"list\",\n children: [\n {\n type: \"list-item\",\n children: [\n { text: \"An item\" },\n { type: \"paragraph\", children: [{ text: \"not allowed here\" }] },\n ],\n },\n ],\n },\n ])\n ).toBe(false);\n // An embedded object child is rejected too.\n expect(\n isPortableTextContent([\n {\n type: \"list\",\n children: [\n {\n type: \"list-item\",\n children: [{ type: \"object\", _type: \"callout\" }],\n },\n ],\n },\n ])\n ).toBe(false);\n });\n\n it(\"accepts a code-block without a language and a table without rows\", () => {\n expect(\n isPortableTextContent([{ type: \"code-block\", code: \"npm install\" }])\n ).toBe(true);\n expect(\n isPortableTextContent([\n { type: \"table\", header: [[{ text: \"A\" }]], rows: [] },\n ])\n ).toBe(true);\n expect(isPortableTextContent([{ type: \"divider\" }])).toBe(true);\n });\n\n it(\"accepts a titled-text with only a title, with or without content\", () => {\n expect(\n isPortableTextContent([{ type: \"titled-text\", title: \"Ranges\" }])\n ).toBe(true);\n expect(\n isPortableTextContent([\n { type: \"titled-text\", title: \"Ranges\", content: [] },\n ])\n ).toBe(true);\n });\n\n it(\"tells blocks, objects and spans apart\", () => {\n const [heading, paragraph] = sampleMessageContent;\n const callout = sampleMessageContent[5];\n\n expect(isPortableTextBlock(heading)).toBe(true);\n expect(isPortableTextBlock(callout)).toBe(false);\n expect(isPortableTextObjectNode(callout)).toBe(true);\n expect(isPortableTextObjectNode(heading)).toBe(false);\n expect(isPortableTextSpan({ text: \"plain\" })).toBe(true);\n expect(isPortableTextSpan(paragraph)).toBe(false);\n });\n\n it(\"ships a universal default set free of product elements\", () => {\n expect(PORTABLE_TEXT_DEFAULT_BLOCKS).toEqual([\n \"paragraph\",\n \"heading\",\n \"list\",\n \"list-item\",\n \"media\",\n \"titled-text\",\n \"code-block\",\n \"table\",\n \"divider\",\n ]);\n expect(PORTABLE_TEXT_DEFAULT_MARKS).toEqual([\n \"strong\",\n \"em\",\n \"code\",\n \"link\",\n ]);\n });\n\n it(\"keeps video media variants in the envelope but out of the image variant set\", () => {\n expect(\n isPortableTextContent([\n {\n type: \"media\",\n variant: \"vimeo\",\n src: \"https://vimeo.com/1131696931\",\n caption: \"Duplicating a project\",\n },\n {\n type: \"media\",\n variant: \"youtube\",\n src: \"https://www.youtube.com/watch?v=dQw4w9WgXcQ\",\n },\n ])\n ).toBe(true);\n\n expect(isPortableTextMediaImageVariant(\"screenshot\")).toBe(true);\n expect(isPortableTextMediaImageVariant(\"illustration\")).toBe(true);\n expect(isPortableTextMediaImageVariant(\"vimeo\")).toBe(false);\n expect(isPortableTextMediaImageVariant(\"youtube\")).toBe(false);\n expect(isPortableTextMediaImageVariant(undefined)).toBe(false);\n });\n\n it(\"accepts an application components map through the injection contract\", () => {\n const seen: string[] = [];\n const components: PortableTextComponents = {\n marks: {\n \"interface-name\": ({ children }) =>\n createElement(Fragment, null, children),\n },\n objects: {\n callout: ({ children }) => createElement(Fragment, null, children),\n },\n onUnknownType: (kind, type) => {\n seen.push(`${kind}:${type}`);\n },\n };\n\n components.onUnknownType?.(\"object\", \"some-future-element\");\n\n expect(Object.keys(components.marks ?? {})).toEqual([\"interface-name\"]);\n expect(seen).toEqual([\"object:some-future-element\"]);\n });\n});\n"],"mappings":";;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAEA,IAAAC,MAAA,GAAAD,OAAA;AAYAE,QAAQ,CAAC,uBAAuB,EAAE,YAAM;EACtC,IAAMC,oBAAyC,GAAG,CAChD;IAAEC,IAAI,EAAE,SAAS;IAAEC,KAAK,EAAE,CAAC;IAAEC,QAAQ,EAAE,CAAC;MAAEC,IAAI,EAAE;IAAc,CAAC;EAAE,CAAC,EAClE;IACEH,IAAI,EAAE,WAAW;IACjBE,QAAQ,EAAE,CACR;MAAEC,IAA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