@redocly/marketing-pages 0.1.21 → 0.1.23
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/pages/editor/components/PreviewPanel/IframeContainer.js +3 -3
- package/dist/pages/editor/hooks/useEditorCommunication.js +2 -2
- package/dist/pages/editor/utils/operationScrolling.js +3 -3
- package/dist/pages/editor-preview/hooks/useCommunicationManager.js +1 -1
- package/dist/pages/learning-center/components/CardsBlock.d.ts +1 -1
- package/dist/pages/learning-center/components/CardsBlock.js +8 -8
- package/package.json +1 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import n,{useRef as c,useEffect as a}from"react";import i from"styled-components";const d=({definition:r,onIframeReady:s,onMessage:g})=>{const l=c(null),t=c(null),[m,p]=n.useState(0);return a(()=>{const o=e=>{console.log("[IframeContainer] Iframe ready, setting up communication"),t.current=e,e.updateDefinition(r),s(e)};return window.onReady=o,console.log("[IframeContainer] onReady callback registered"),()=>{delete window.onReady}},[r,s]),a(()=>{const o=e=>{if(e.data?.type==="scroll-to-operation"){if(!t.current){console.warn("[IframeContainer] Received scroll message but iframe not ready");return}console.log("[IframeContainer] Forwarding scroll-to-operation to iframe:",e.data.operationPath),t.current.postMessage(e.data,"*")}};return window.addEventListener("message",o),()=>window.removeEventListener("message",o)},[]),a(()=>{t.current&&r&&t.current.updateDefinition(r)},[r]),n.createElement(u,null,n.createElement(f,{key:m,ref:l,title:"API Documentation Preview",src:"/preview",onLoad:()=>{}}))};var I=d;const u=i.div`
|
|
2
2
|
height: 100%;
|
|
3
3
|
overflow: hidden;
|
|
4
|
-
`,
|
|
4
|
+
`,f=i.iframe`
|
|
5
5
|
width: 100%;
|
|
6
6
|
height: 100%;
|
|
7
7
|
border: none;
|
|
8
|
-
`;export{
|
|
8
|
+
`;export{I as default};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{useEffect as
|
|
2
|
-
`);let s=-1,
|
|
1
|
+
import{useEffect as P,useRef as f}from"react";import{findOperationAtLine as h,findOperationLineInEditor as w,sendScrollToPreview as E,isPositionInOperationBlock as L}from"../utils/operationScrolling";const T=({value:o,isFullPreview:c,editorRef:r})=>{const u=f(0),m=f(0);P(()=>{const e=t=>{if(t.data?.type!=="scroll-to-operation"||t.data?.source!=="preview"||!r.current||c)return;const a=Date.now();if(a-u.current<1e3)return;m.current=a;const l=t.data.operationPath;p(l)};return window.addEventListener("message",e),()=>window.removeEventListener("message",e)},[c,r]);const g=e=>{if(!o||c)return;const t=h(o,e);t?(console.log("[Editor] Sending scroll-to-operation:",t.pointer),u.current=Date.now(),E(t.pointer)):console.log("[Editor] No operation found at line",e)},p=e=>{if(!r.current||!o)return;const t=w(o,e);if(!t)return;const l=r.current.getPosition()?.lineNumber||1,i=o.split(`
|
|
2
|
+
`);let s=-1,d=i.length;for(let n=0;n<i.length;n++)if(i[n].includes(e.replace("#/paths/","").replace(/~1/g,"/"))){s=n;break}if(s!==-1){for(let n=s+1;n<i.length;n++)if(/^\s*\/[^:]+:\s*$/.test(i[n])){d=n;break}if(L(l,s,d))return}r.current.revealPositionInCenter({lineNumber:t,column:1}),r.current.setPosition({lineNumber:t,column:1})};return{scrollPreviewToOperation:g,scrollToOperationInEditor:p}};export{T as useEditorCommunication};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
const
|
|
2
|
-
`),s=o-1,l=t[s];let r=-1,a="";for(let n=s;n>=0;n--){const p=t[n];if(/^\s*\/[^:]+:\s*$/.test(p)){r=n,a=p.trim().replace(/:\s*$/,"");break}if(/^\s*components:\s*$/.test(p)||/^\s*schemas:\s*$/.test(p))break}if(r===-1)return null;let c=t.length;for(let n=r+1;n<t.length;n++){if(/^\s*\/[^:]+:\s*$/.test(t[n])){c=n;break}if(/^\s*components:\s*$/.test(t[n])||/^\s*schemas:\s*$/.test(t[n])){c=n;break}}if(!(s>r&&s<c))return null;let d=-1,e="";for(let n=s;n>r;n--){const u=t[n].match(/^\s*(get|post|put|delete|patch):\s*$/i);if(u){e=(u[1]||"").toLowerCase(),d=n;break}}if(d===-1)return null;const f=`#/paths/${a.replace(/\//g,"~1")}/${e}`;return{path:a,verb:e,pointer:f}},
|
|
3
|
-
`);let s="",l="";if(o.startsWith("#/")){const e=o.slice(2).split("/");l=(e[2]||"").toLowerCase(),s=(e[1]||"").replaceAll("~1","/")}else o.startsWith("/")?s=o:s=`/${o}`;let r=-1;for(let e=0;e<t.length;e++)if(t[e].trim()===`${s}:`){r=e;break}if(r===-1){for(let e=0;e<t.length;e++)if(t[e].includes(s)){r=e;break}}if(r===-1)return null;let a=t.length;for(let e=r+1;e<t.length;e++)if(/^\s*\/[^:]+:\s*$/.test(t[e])){a=e;break}let c=-1;for(let e=r+1;e<a;e++){const h=t[e].match(/^\s*(get|post|put|delete|patch):\s*$/i);if(h){const f=(h[1]||"").toLowerCase();if(!l||l===f){c=e,l=f;break}}}return(c!==-1?c:r)+1}
|
|
1
|
+
const g=(i,o)=>{const t=i.split(`
|
|
2
|
+
`),s=o-1,l=t[s];let r=-1,a="";for(let n=s;n>=0;n--){const p=t[n];if(/^\s*\/[^:]+:\s*$/.test(p)){r=n,a=p.trim().replace(/:\s*$/,"");break}if(/^\s*components:\s*$/.test(p)||/^\s*schemas:\s*$/.test(p))break}if(r===-1)return null;let c=t.length;for(let n=r+1;n<t.length;n++){if(/^\s*\/[^:]+:\s*$/.test(t[n])){c=n;break}if(/^\s*components:\s*$/.test(t[n])||/^\s*schemas:\s*$/.test(t[n])){c=n;break}}if(!(s>r&&s<c))return null;let d=-1,e="";for(let n=s;n>r;n--){const u=t[n].match(/^\s*(get|post|put|delete|patch):\s*$/i);if(u){e=(u[1]||"").toLowerCase(),d=n;break}}if(d===-1)return null;const f=`#/paths/${a.replace(/\//g,"~1")}/${e}`;return{path:a,verb:e,pointer:f}},b=(i,o)=>{const t=i.split(`
|
|
3
|
+
`);let s="",l="";if(o.startsWith("#/")){const e=o.slice(2).split("/");l=(e[2]||"").toLowerCase(),s=(e[1]||"").replaceAll("~1","/")}else o.startsWith("/")?s=o:s=`/${o}`;let r=-1;for(let e=0;e<t.length;e++)if(t[e].trim()===`${s}:`){r=e;break}if(r===-1){for(let e=0;e<t.length;e++)if(t[e].includes(s)){r=e;break}}if(r===-1)return null;let a=t.length;for(let e=r+1;e<t.length;e++)if(/^\s*\/[^:]+:\s*$/.test(t[e])){a=e;break}let c=-1;for(let e=r+1;e<a;e++){const h=t[e].match(/^\s*(get|post|put|delete|patch):\s*$/i);if(h){const f=(h[1]||"").toLowerCase();if(!l||l===f){c=e,l=f;break}}}return(c!==-1?c:r)+1},m=i=>{const o={type:"scroll-to-operation",operationPath:i,source:"editor"};window.postMessage(o,"*"),document.querySelectorAll("iframe").forEach(s=>{try{s.contentWindow?.postMessage(o,"*")}catch{}})},$=(i,o,t)=>{const s=o+1,l=t;return i>s&&i<=l};export{g as findOperationAtLine,b as findOperationLineInEditor,$ as isPositionInOperationBlock,m as sendScrollToPreview};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useEffect as
|
|
1
|
+
import{useEffect as l}from"react";import{extractOperationFromButton as y}from"../utils/html";const k=({definition:f,lastGoodDefinition:h,safeSlugify:d})=>{const s=e=>{const o=f||h;if(!o?.paths){console.warn("[EditorPreview] No definition or paths available");return}let r="",t="";if(e.startsWith("#/")){const i=e.slice(2).split("/");t=i[2]||"",r=(i[1]||"").replaceAll("~1","/")}else{const i=e.split("/"),w=i[1]||"";t=i[2]||"",r=w.replace(/^paths/,"").replaceAll("~1","/")}if(!r||!t){console.warn("[EditorPreview] Invalid pointer format:",e);return}const n=o.paths[r]?.[t];if(!n){console.warn("[EditorPreview] No operation found for",{path:r,verb:t,pointer:e});return}const g=n.tags?.[0],v=g?d(g)+"/":"";let a="";if(n?.operationId?a="/preview/"+v+d(n.operationId):a="/preview/"+v+"paths/"+d(r)+"/"+t.toLowerCase(),a&&a!==window.location.pathname){window.history.replaceState({},"",a);const i=t.toLowerCase(),w=r,E=()=>{const P=document.querySelectorAll('button[data-component-name="Button/Button"]');for(const c of P){const u=y(c);if(u&&u.path===w&&u.method.toLowerCase()===i)return c.click(),!0}return!1};let p=E();p||[0,100,300,800].forEach(c=>{setTimeout(()=>{p||(p=E())},c)})}else a||console.warn("[EditorPreview] could not compute url for pointer:",e)},m=e=>{window.parent.postMessage({type:"scroll-to-operation",operationPath:e,source:"preview"},"*")};return l(()=>{try{window.parent&&typeof window.parent.onReady=="function"?(window.parent.onReady(window),console.log("[EditorPreview] Successfully registered with parent window")):(console.warn("[EditorPreview] Parent onReady not available, retrying..."),setTimeout(()=>{window.parent&&typeof window.parent.onReady=="function"?(window.parent.onReady(window),console.log("[EditorPreview] Successfully registered with parent window (retry)")):console.error("[EditorPreview] Failed to register with parent window")},100))}catch(e){console.error("[EditorPreview] Error registering with parent:",e)}},[]),l(()=>(window.scrollToPointer=s,()=>{delete window.scrollToPointer}),[f,h]),l(()=>{const e=o=>{o.data?.type==="scroll-to-operation"&&o.data?.source==="editor"&&(console.log("[EditorPreview] Received scroll-to-operation message:",o.data.operationPath),s(o.data.operationPath))};return window.addEventListener("message",e),()=>{window.removeEventListener("message",e)}},[s]),l(()=>{const e=o=>{const t=o.target.closest("button");if(t){const n=y(t);n&&m(n.path)}};return document.addEventListener("click",e),()=>{document.removeEventListener("click",e)}},[]),{scrollToPointer:s,scrollToOperationInEditor:m}};export{k as useCommunicationManager};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import*as e from"react";import r from"styled-components";import{Link as d}from"@redocly/theme";import{Card as
|
|
1
|
+
import*as e from"react";import r from"styled-components";import{Link as d}from"@redocly/theme";import{Card as s}from"@redocly/theme/markdoc/components/Cards/Card";import{Cards as p}from"@redocly/theme/markdoc/components/Cards/Cards";const L=({cards:l})=>{const[a,c]=e.useState(!1);return e.useEffect(()=>{c(!0)},[]),e.useEffect(()=>{const t=document?.getElementsByTagName("h3");for(let i=0;i<t.length;i++)t[i].getElementsByTagName("path")[0]?.setAttribute("d","M8.53906 2.625L7.91344 3.23444L11.2297 6.5625H2.41406V7.4375H11.2297L7.91344 10.7507L8.53906 11.375L12.9141 7L8.53906 2.625Z")},[]),a?e.createElement(u,{columns:3,children:l.map((t,i)=>e.createElement(m,{key:i,title:`Learn ${t.title}`,image:t.thumbnail,to:t.landingPage,children:e.createElement(g,null,e.createElement(x,null,t.description),e.createElement(y,{onClick:o=>o.stopPropagation()},t.items.map((o,n)=>e.createElement("div",{key:n,style:{width:"100%"}},e.createElement(h,{key:n,to:o.link},e.createElement("div",null,e.createElement("img",{src:require("../images/ellipse.svg")}),e.createElement("p",null,o.title)),e.createElement("svg",{width:"22",height:"23",viewBox:"0 0 23 22",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e.createElement("rect",{x:"0.664062",width:"22",height:"22",rx:"11",fill:"inherit"}),e.createElement("path",{d:"M12.5391 6.625L11.9134 7.23444L15.2297 10.5625H6.41406V11.4375H15.2297L11.9134 14.7507L12.5391 15.375L16.9141 11L12.5391 6.625Z",fill:"inherit"}))),e.createElement(f,null))),t.moreItems&&e.createElement(v,null,"and ",t.moreItems)))}))}):null},m=r(s)`
|
|
2
2
|
max-width: 405px;
|
|
3
|
-
`,
|
|
3
|
+
`,x=r.p`
|
|
4
4
|
color: var(--text-color-primary);
|
|
5
5
|
font-family: Inter;
|
|
6
6
|
font-size: 16px;
|
|
@@ -14,11 +14,11 @@ import*as e from"react";import r from"styled-components";import{Link as d}from"@
|
|
|
14
14
|
padding: 0 16px;
|
|
15
15
|
|
|
16
16
|
margin: 0;
|
|
17
|
-
`,
|
|
17
|
+
`,g=r.div`
|
|
18
18
|
display: flex;
|
|
19
19
|
flex-direction: column;
|
|
20
20
|
gap: 12px;
|
|
21
|
-
`,
|
|
21
|
+
`,f=r.div`
|
|
22
22
|
margin: 2px 8px;
|
|
23
23
|
height: 1px;
|
|
24
24
|
background: var(--border-color-secondary);
|
|
@@ -73,7 +73,7 @@ import*as e from"react";import r from"styled-components";import{Link as d}from"@
|
|
|
73
73
|
transition: transform 0.3s ease-in-out;
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
|
-
`,
|
|
76
|
+
`,v=r.div`
|
|
77
77
|
display: flex;
|
|
78
78
|
padding: 8px;
|
|
79
79
|
align-items: center;
|
|
@@ -86,11 +86,11 @@ import*as e from"react";import r from"styled-components";import{Link as d}from"@
|
|
|
86
86
|
font-size: 14px;
|
|
87
87
|
font-weight: 400;
|
|
88
88
|
line-height: 22px;
|
|
89
|
-
`,
|
|
89
|
+
`,y=r.div`
|
|
90
90
|
display: flex;
|
|
91
91
|
flex-direction: column;
|
|
92
92
|
padding: 0 8px 16px 8px;
|
|
93
|
-
`,
|
|
93
|
+
`,u=r(p)`
|
|
94
94
|
--cards-gap: 24px;
|
|
95
95
|
--card-content-gap: 8px;
|
|
96
96
|
--card-padding: 16px 0 0 0;
|
|
@@ -129,4 +129,4 @@ import*as e from"react";import r from"styled-components";import{Link as d}from"@
|
|
|
129
129
|
height: unset;
|
|
130
130
|
}
|
|
131
131
|
}
|
|
132
|
-
`;export{
|
|
132
|
+
`;export{L as CardsBlock};
|