@gem-sdk/components 17.0.0-dev.131 → 17.0.0-dev.132
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.
|
@@ -1,11 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@gem-sdk/core"),t=require("react");const
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@gem-sdk/core"),t=require("react");const r=/<(embed|img|input|picture|video)/i;exports.default=(i,o)=>{let l=e.useEditorMode(),{editorData:n}=i||{},{customLabel:s}=o||{},p=`
|
|
2
2
|
<p class="gp-text-center gp-text-sm gp-py-4 gp-leading-6 gp-text-light-500 gp-flex gp-flex-col gp-gap-[4px]">
|
|
3
|
-
<span>${
|
|
4
|
-
|
|
5
|
-
</p>`,[o]),c=(e,t)=>{let p=document.createElement("div");p.innerHTML=e;let n=p.childNodes,a=!1,i=!0;if(n.length>0){n.forEach(e=>{s.includes(e?.tagName)&&(a=!0,e?.remove())});let e=p.childNodes;e.forEach(e=>{if(l.includes(e?.tagName))i=!1;else if(e?.nodeName!=="#comment"){let t=e?.textContent?.trim();t&&(i=!1)}})}return i&&(i=!p?.textContent?.trim()),t&&(a=!0),{empty:i,hasScript:a}},g=t.useMemo(()=>{if("edit"===a){let{empty:e,hasScript:t}=c(i?.html||"",i?.javascript||"");if(t)return`
|
|
6
|
-
<div class="gp-py-4 gp-font-[sans-serif] gp-flex gp-flex-col gp-gap-[4px]" >
|
|
7
|
-
<p class="gp-text-center gp-text-sm gp-leading-[21px] gp-text-[#676767] ">
|
|
8
|
-
Publish the page to see the content.
|
|
9
|
-
</p>
|
|
10
|
-
</div>
|
|
11
|
-
`;if(e)return r(i?.css||"",i?.javascript||"",i?.html||"")}return i?.html?.trim()},[a,i?.html,i?.javascript,i?.css,r]);return{mode:a,htmlPlainText:g,handleDoubleClickCustomCode:e=>{if(2===e.detail){let e=new CustomEvent("editor:toolbar:open-custom-code",{bubbles:!0});window.dispatchEvent(e)}}}};
|
|
3
|
+
<span>${s||"Custom Code"}</span>
|
|
4
|
+
</p>`,u=e=>r.test(e),d=e=>{let t=u(e);if(t)return!1;let r=document.createElement("div");return r.innerHTML=e,!r?.textContent?.trim()},c=t.useMemo(()=>{if("edit"===l){let e=d(n?.html||"");if(e)return p}return n?.html?.trim()},[l,n?.html,n?.javascript,n?.css]);return{mode:l,htmlPlainText:c,handleDoubleClickCustomCode:e=>{if(2===e.detail){let e=new CustomEvent("editor:toolbar:open-custom-code",{bubbles:!0});window.dispatchEvent(e)}}}};
|
|
@@ -1,11 +1,4 @@
|
|
|
1
|
-
import{useEditorMode as e}from"@gem-sdk/core";import{
|
|
1
|
+
import{useEditorMode as e}from"@gem-sdk/core";import{useMemo as t}from"react";let r=/<(embed|img|input|picture|video)/i,i=(i,o)=>{let l=e(),{editorData:p}=i||{},{customLabel:n}=o||{},m=`
|
|
2
2
|
<p class="gp-text-center gp-text-sm gp-py-4 gp-leading-6 gp-text-light-500 gp-flex gp-flex-col gp-gap-[4px]">
|
|
3
|
-
<span>${
|
|
4
|
-
|
|
5
|
-
</p>`,[r]),c=(e,t)=>{let p=document.createElement("div");p.innerHTML=e;let n=p.childNodes,a=!1,o=!0;if(n.length>0){n.forEach(e=>{l.includes(e?.tagName)&&(a=!0,e?.remove())});let e=p.childNodes;e.forEach(e=>{if(s.includes(e?.tagName))o=!1;else if(e?.nodeName!=="#comment"){let t=e?.textContent?.trim();t&&(o=!1)}})}return o&&(o=!p?.textContent?.trim()),t&&(a=!0),{empty:o,hasScript:a}},d=p(()=>{if("edit"===o){let{empty:e,hasScript:t}=c(i?.html||"",i?.javascript||"");if(t)return`
|
|
6
|
-
<div class="gp-py-4 gp-font-[sans-serif] gp-flex gp-flex-col gp-gap-[4px]" >
|
|
7
|
-
<p class="gp-text-center gp-text-sm gp-leading-[21px] gp-text-[#676767] ">
|
|
8
|
-
Publish the page to see the content.
|
|
9
|
-
</p>
|
|
10
|
-
</div>
|
|
11
|
-
`;if(e)return g(i?.css||"",i?.javascript||"",i?.html||"")}return i?.html?.trim()},[o,i?.html,i?.javascript,i?.css,g]);return{mode:o,htmlPlainText:d,handleDoubleClickCustomCode:e=>{if(2===e.detail){let e=new CustomEvent("editor:toolbar:open-custom-code",{bubbles:!0});window.dispatchEvent(e)}}}};export{n as default};
|
|
3
|
+
<span>${n||"Custom Code"}</span>
|
|
4
|
+
</p>`,s=e=>r.test(e),d=e=>{let t=s(e);if(t)return!1;let r=document.createElement("div");return r.innerHTML=e,!r?.textContent?.trim()},u=t(()=>{if("edit"===l){let e=d(p?.html||"");if(e)return m}return p?.html?.trim()},[l,p?.html,p?.javascript,p?.css]);return{mode:l,htmlPlainText:u,handleDoubleClickCustomCode:e=>{if(2===e.detail){let e=new CustomEvent("editor:toolbar:open-custom-code",{bubbles:!0});window.dispatchEvent(e)}}}};export{i as default};
|