@grapesjs/studio-sdk-plugins 1.0.35 → 1.0.36
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/accordionComponent/index.cjs.js +7 -7
- package/dist/accordionComponent/index.es.js +175 -162
- package/dist/accordionComponent/index.umd.js +7 -7
- package/dist/aiChat/index.cjs.js +64 -64
- package/dist/aiChat/index.es.js +5785 -5757
- package/dist/aiChat/index.js +64 -64
- package/dist/aiChat/index.umd.js +63 -63
- package/dist/animationComponent/index.cjs.js +3 -3
- package/dist/animationComponent/index.es.js +204 -191
- package/dist/animationComponent/index.umd.js +3 -3
- package/dist/canvasAbsoluteMode/index.cjs.js +1 -1
- package/dist/canvasAbsoluteMode/index.es.js +183 -170
- package/dist/canvasAbsoluteMode/index.umd.js +1 -1
- package/dist/canvasEmptyState/index.cjs.js +1 -1
- package/dist/canvasEmptyState/index.es.js +134 -121
- package/dist/canvasEmptyState/index.umd.js +1 -1
- package/dist/canvasFullSize/index.cjs.js +9 -9
- package/dist/canvasFullSize/index.es.js +165 -152
- package/dist/canvasFullSize/index.umd.js +9 -9
- package/dist/canvasGridMode/index.cjs.js +5 -5
- package/dist/canvasGridMode/index.es.js +245 -232
- package/dist/canvasGridMode/index.umd.js +4 -4
- package/dist/canvasScreenshot/index.cjs.js +1 -1
- package/dist/canvasScreenshot/index.es.js +155 -142
- package/dist/canvasScreenshot/index.umd.js +1 -1
- package/dist/dataSourceEjs/index.cjs.js +9 -9
- package/dist/dataSourceEjs/index.es.js +257 -244
- package/dist/dataSourceEjs/index.umd.js +9 -9
- package/dist/dataSourceHandlebars/index.cjs.js +8 -8
- package/dist/dataSourceHandlebars/index.es.js +216 -203
- package/dist/dataSourceHandlebars/index.umd.js +7 -7
- package/dist/dialogComponent/index.cjs.js +14 -14
- package/dist/dialogComponent/index.es.js +141 -128
- package/dist/dialogComponent/index.umd.js +14 -14
- package/dist/flexComponent/index.cjs.js +13 -13
- package/dist/flexComponent/index.es.js +484 -471
- package/dist/flexComponent/index.umd.js +13 -13
- package/dist/fsLightboxComponent/index.cjs.js +3 -3
- package/dist/fsLightboxComponent/index.es.js +173 -160
- package/dist/fsLightboxComponent/index.umd.js +3 -3
- package/dist/googleFontsAssetProvider/index.cjs.js +1 -1
- package/dist/googleFontsAssetProvider/index.es.js +160 -147
- package/dist/googleFontsAssetProvider/index.umd.js +1 -1
- package/dist/iconifyComponent/index.cjs.js +2 -2
- package/dist/iconifyComponent/index.es.js +196 -183
- package/dist/iconifyComponent/index.umd.js +2 -2
- package/dist/index.cjs.js +25 -25
- package/dist/index.es.js +121 -108
- package/dist/index.umd.js +18 -18
- package/dist/layoutSidebarButtons/index.cjs.js +1 -1
- package/dist/layoutSidebarButtons/index.es.js +157 -144
- package/dist/layoutSidebarButtons/index.umd.js +1 -1
- package/dist/lightGalleryComponent/index.cjs.js +1 -1
- package/dist/lightGalleryComponent/index.es.js +245 -232
- package/dist/lightGalleryComponent/index.umd.js +1 -1
- package/dist/linkImageComponent/index.cjs.js +2 -2
- package/dist/linkImageComponent/index.es.js +106 -93
- package/dist/linkImageComponent/index.umd.js +2 -2
- package/dist/listPagesComponent/index.cjs.js +5 -5
- package/dist/listPagesComponent/index.es.js +157 -144
- package/dist/listPagesComponent/index.umd.js +5 -5
- package/dist/presetPrintable/index.cjs.js +3 -3
- package/dist/presetPrintable/index.es.js +181 -168
- package/dist/presetPrintable/index.umd.js +3 -3
- package/dist/prosemirror/index.cjs.js +7 -7
- package/dist/prosemirror/index.es.js +385 -372
- package/dist/prosemirror/index.umd.js +8 -8
- package/dist/rendererReact/index.cjs.js +1 -1
- package/dist/rendererReact/index.es.js +200 -187
- package/dist/rendererReact/index.js +1 -1
- package/dist/rendererReact/index.umd.js +1 -1
- package/dist/rteTinyMce/index.cjs.js +2 -2
- package/dist/rteTinyMce/index.es.js +118 -105
- package/dist/rteTinyMce/index.umd.js +2 -2
- package/dist/shapeDividerComponent/index.cjs.js +4 -4
- package/dist/shapeDividerComponent/index.es.js +129 -116
- package/dist/shapeDividerComponent/index.umd.js +4 -4
- package/dist/swiperComponent/index.cjs.js +9 -9
- package/dist/swiperComponent/index.es.js +203 -190
- package/dist/swiperComponent/index.umd.js +7 -7
- package/dist/tableComponent/index.cjs.js +1 -1
- package/dist/tableComponent/index.es.js +257 -244
- package/dist/tableComponent/index.umd.js +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/youtubeAssetProvider/index.cjs.js +1 -1
- package/dist/youtubeAssetProvider/index.es.js +121 -108
- package/dist/youtubeAssetProvider/index.umd.js +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(z,y){typeof exports=="object"&&typeof module<"u"?module.exports=y():typeof define=="function"&&define.amd?define(y):(z=typeof globalThis<"u"?globalThis:z||self,z.StudioSdkPlugins_tableComponent=y())})(this,function(){"use strict";function z(e,t,o){let l,n,s,c,a;const r=t;function d(){const h=Date.now()-c;h<r&&h>=0?l=setTimeout(d,r-h):(l=null,a=e.apply(s,n),s=n=null)}const u=function(){return s=this,n=arguments,c=Date.now(),l||(l=setTimeout(d,r)),a};return u.clear=function(){l&&(clearTimeout(l),l=null)},u.flush=function(){l&&(a=e.apply(s,n),s=n=null,clearTimeout(l),l=null)},u}const y="app.grapesjs.com",G="app-stage.grapesjs.com",L=[y,"app2.grapesjs.com",G,"app-stage2.grapesjs.com","localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],ie="license:check:start",de="license:check:end",he=()=>typeof window<"u",ve=({isDev:e,isStage:t,isPlatform:o})=>`${e?"":`https://${t?G:y}`}/${o?"platform-api":"api"}`,ue=()=>{const e=he()&&window.location.hostname;return!!e&&(L.includes(e)||L.some(t=>e.endsWith(t)))};function N(e){return typeof e=="function"}async function ge({path:e,baseApiUrl:t,method:o="GET",headers:l={},params:n,body:s}){const a=`${t||ve({isDev:!1,isStage:!1})}${e}`,r={method:o,headers:{"Content-Type":"application/json",...l}};s&&(r.body=JSON.stringify(s));const d=n?new URLSearchParams(n).toString():"",u=d?`?${d}`:"",h=await fetch(`${a}${u}`,r);if(!h.ok)throw new Error(`HTTP error! status: ${h.status}`);return h.json()}var C=(e=>(e.free="free",e.startup="startup",e.business="business",e.enterprise="enterprise",e))(C||{}),O=(e=>(e.toastAdd="studio:toastAdd",e.toastRemove="studio:toastRemove",e.dialogOpen="studio:dialogOpen",e.dialogClose="studio:dialogClose",e.dialogExportCode="studio:dialogExportCode",e.dialogImportCode="studio:dialogImportCode",e.sidebarLeftSet="studio:sidebarLeft:set",e.sidebarLeftGet="studio:sidebarLeft:get",e.sidebarLeftToggle="studio:sidebarLeft:toggle",e.sidebarRightSet="studio:sidebarRight:set",e.sidebarRightGet="studio:sidebarRight:get",e.sidebarRightToggle="studio:sidebarRight:toggle",e.sidebarTopSet="studio:sidebarTop:set",e.sidebarTopGet="studio:sidebarTop:get",e.sidebarTopToggle="studio:sidebarTop:toggle",e.sidebarBottomSet="studio:sidebarBottom:set",e.sidebarBottomGet="studio:sidebarBottom:get",e.sidebarBottomToggle="studio:sidebarBottom:toggle",e.symbolAdd="studio:symbolAdd",e.symbolDetach="studio:symbolDetach",e.symbolOverride="studio:symbolOverride",e.symbolPropagateStyles="studio:propagateStyles",e.getPagesConfig="studio:getPagesConfig",e.setPagesConfig="studio:setPagesConfig",e.getPageSettings="studio:getPageSettings",e.setPageSettings="studio:setPageSettings",e.clearPage="studio:clearPage",e.projectFiles="studio:projectFiles",e.validateCode="studio:validateCode",e.canvasReload="studio:canvasReload",e.getBlocksPanel="studio:getBlocksPanel",e.setBlocksPanel="studio:setBlocksPanel",e.getStateContextMenu="studio:getStateContextMenu",e.setStateContextMenu="studio:setStateContextMenu",e.contextMenuComponent="studio:contextMenuComponent",e.layoutAdd="studio:layoutAdd",e.layoutRemove="studio:layoutRemove",e.layoutToggle="studio:layoutToggle",e.layoutUpdate="studio:layoutUpdate",e.layoutGet="studio:layoutGet",e.layoutConfigGet="studio:layoutConfigGet",e.layoutConfigSet="studio:layoutConfigSet",e.layoutComponentAdd="studio:layoutComponentAdd",e.layoutComponentGet="studio:layoutComponentGet",e.layoutComponentRemove="studio:layoutComponentRemove",e.layoutComponentRender="studio:layoutComponentRender",e.getStateTheme="studio:getStateTheme",e.setStateTheme="studio:setStateTheme",e.assetProviderGet="studio:assetProviderGet",e.assetProviderAdd="studio:assetProviderAdd",e.assetProviderRemove="studio:assetProviderRemove",e.fontGet="studio:fontGet",e.fontAdd="studio:fontAdd",e.fontRemove="studio:fontRemove",e.fontManagerOpen="studio:fontManagerOpen",e.menuFontLoad="studio:menuFontLoad",e.toggleStateDataSource="studio:toggleStateDataSource",e.getStateDataSource="studio:getStateDataSource",e.dataSourceSetGlobalData="studio:dataSourceSetGlobalData",e.dataSourceSetImporter="studio:dataSourceSetImporter",e.dataSourceSetExporter="studio:dataSourceSetExporter",e.setDragAbsolute="studio:setDragAbsolute",e))(O||{});const Z={[C.free]:0,[C.startup]:10,[C.business]:20,[C.enterprise]:30};function be(e){const t=e;return t.init=o=>l=>e(l,o),t}const pe=e=>be(e);async function fe({editor:e,plan:t,pluginName:o,licenseKey:l,onLicenseCheckResponse:n,cleanup:s}){let c="",a=!1;const r=ue(),d=h=>{console.warn("Cleanup plugin:",o,"Reason:",h),s()},u=(h={})=>{var V;const{error:f,sdkLicense:B}=h,m=(V=h.plan)==null?void 0:V.category;if(!(B||h.license)||f)d(f||"Invalid license");else if(m){const I=Z[t],M=Z[m];I>M&&d({pluginRequiredPlan:t,licensePlan:m})}};e.on(ie,h=>{c=h==null?void 0:h.baseApiUrl,a=!0}),e.on(de,h=>{n==null||n(h),u(h)}),setTimeout(async()=>{if(!a){if(r)return;if(l){const h=await me({licenseKey:l,pluginName:o,baseApiUrl:c});n==null||n(h),h&&u(h)}else d("The `licenseKey` option not provided")}},2e3)}async function me(e){const{licenseKey:t,pluginName:o,baseApiUrl:l}=e;try{return(await ge({baseApiUrl:l,path:`/sdk/${t||"na"}`,method:"POST",params:{d:window.location.hostname,pn:o}})).result||{}}catch(n){return console.error("Error during SDK license check:",n),!1}}const we="tableComponent",ye=C.startup;var i=(e=>(e.table="table",e.tableSettings="tableSettings",e.tableDelete="tableDelete",e.tableHead="tableHead",e.tableFoot="tableFoot",e.tableCellItems="tableCellItems",e.tableCellProperties="tableCellProperties",e.tableCellMerge="tableCellMerge",e.tableCellSplit="tableCellSplit",e.tableRowItems="tableRowItems",e.tableRowInsertBefore="tableRowInsertBefore",e.tableRowInsertAfter="tableRowInsertAfter",e.tableRowDelete="tableRowDelete",e.tableRowProperties="tableRowProperties",e.tableRowCut="tableRowCut",e.tableRowCopy="tableRowCopy",e.tableRowPasteBefore="tableRowPasteBefore",e.tableRowPasteAfter="tableRowPasteAfter",e.tableColumn="tableColumn",e.tableColumnItems="tableColumnItems",e.tableColumnInsertBefore="tableColumnInsertBefore",e.tableColumnInsertAfter="tableColumnInsertAfter",e.tableColumnDelete="tableColumnDelete",e.tableColumnCut="tableColumnCut",e.tableColumnCopy="tableColumnCopy",e.tableColumnPasteBefore="tableColumnPasteBefore",e.tableColumnPasteAfter="tableColumnPasteAfter",e))(i||{});const v={table:'<svg viewBox="0 0 24 24"><path d="M5 4h14a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2m0 4v4h6V8H5m8 0v4h6V8h-6m-8 6v4h6v-4H5m8 0v4h6v-4h-6Z"/></svg>',tableSettings:'<svg viewBox="0 0 24 24"><path d="M5 4h14a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2m0 4v4h6V8H5m8 0v4h6V8h-6m-8 6v4h6v-4H5m8 0v4h6v-4h-6Z"/></svg>',tableDelete:'<svg viewBox="0 0 24 24"><path d="M19 4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h14zM5 6v12h14V6H5z"/><path d="m14.4 8.6 1 1-2.3 2.4 2.3 2.4-1 1-2.4-2.3-2.4 2.3-1-1 2.3-2.4-2.3-2.4 1-1 2.4 2.3z"/></svg>',tableHead:'<svg viewBox="0 0 24 24"><path d="M19 4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h14Zm-8 11H5v3h6v-3Zm8 0h-6v3h6v-3Zm0-5h-6v3h6v-3ZM5 13h6v-3H5v3Z"/></svg>',tableFoot:'<svg viewBox="0 0 24 24" data-test="1" style="transform: rotate(180deg);"><path d="M19 4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h14Zm-8 11H5v3h6v-3Zm8 0h-6v3h6v-3Zm0-5h-6v3h6v-3ZM5 13h6v-3H5v3Z"/></svg>',tableColumn:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M19 4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h14Zm0 9h-4v5h4v-5Zm-6 0H9v5h4v-5Zm0-7H9v5h4V6Zm6 0h-4v5h4V6Z"/></svg>',tableCellItems:"",tableCellProperties:'<svg viewBox="0 0 24 24"><path d="M19 4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6l2-2h14zm-8 9H5v5h6v-5zm8 0h-6v5h6v-5zm-8-7H5v5h6V6z"/></svg>',tableCellMerge:'<svg viewBox="0 0 24 24"><path d="M19 4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6l2-2h14zM5 16v2h3v-2H5zm14-5h-9v7h9v-7zm0-5h-4v3h4V6zM8 6H5v3h3V6zm5 0h-3v3h3V6zm-8 8h3v-3H5v3z"/></svg>',tableCellSplit:'<svg viewBox="0 0 24 24"><path d="M19 4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h14zM8 15.5H5V18h3v-2.5zm11-5h-9V18h9v-7.5zm-2.5 1 1 1-2 2 2 2-1 1-2-2-2 2-1-1 2-2-2-2 1-1 2 2 2-2zm-8.5-1H5v3h3v-3zM19 6h-4v2.5h4V6zM8 6H5v2.5h3V6zm5 0h-3v2.5h3V6z"/></svg>',tableRowItems:"",tableRowInsertBefore:'<svg viewBox="0 0 24 24"><path d="M6 4a1 1 0 1 1 0 2H5v6h14V6h-1a1 1 0 0 1 0-2h2c.6 0 1 .4 1 1v13a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5c0-.6.4-1 1-1h2zm5 10H5v4h6v-4zm8 0h-6v4h6v-4zM12 3c.5 0 1 .4 1 .9V6h2a1 1 0 0 1 0 2h-2v2a1 1 0 0 1-2 .1V8H9a1 1 0 0 1 0-2h2V4c0-.6.4-1 1-1z"/></svg>',tableRowInsertAfter:'<svg viewBox="0 0 24 24"><path d="M12 13c.5 0 1 .4 1 .9V16h2a1 1 0 0 1 .1 2H13v2a1 1 0 0 1-2 .1V18H9a1 1 0 0 1-.1-2H11v-2c0-.6.4-1 1-1zm6 7a1 1 0 0 1 0-2h1v-6H5v6h1a1 1 0 0 1 0 2H4a1 1 0 0 1-1-1V6c0-1.1.9-2 2-2h14a2 2 0 0 1 2 2v13c0 .5-.4 1-.9 1H18zM11 6H5v4h6V6zm8 0h-6v4h6V6z"/></svg>',tableRowDelete:'<svg viewBox="0 0 24 24"><path d="M19 4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h14zm0 2H5v3h2.5v2H5v2h2.5v2H5v3h14v-3h-2.5v-2H19v-2h-2.5V9H19V6zm-4.7 1.8 1.2 1L13 12l2.6 3.3-1.2 1-2.3-3-2.3 3-1.2-1L11 12 8.5 8.7l1.2-1 2.3 3 2.3-3z"/></svg>',tableRowProperties:'<svg viewBox="0 0 24 24"><path d="M19 4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h14zM5 15v3h6v-3H5zm14 0h-6v3h6v-3zm0-9h-6v3h6V6zM5 9h6V6H5v3z"/></svg>',tableRowCut:'<svg viewBox="0 0 24 24"><path fill-rule="evenodd" d="M22 3v5H9l3 3 2-2h4l-4 4 1 1h.5c.4 0 .8 0 1.2.3.5.2.9.4 1.2.8.7.6 1 1.3 1 2.2.2.8 0 1.5-.6 2l-.8.5-1 .2c-.4 0-.8 0-1.2-.3a3.9 3.9 0 0 1-2.1-2.2c-.2-.5-.3-1-.2-1.5l-1-1-1 1c0 .5 0 1-.2 1.5-.1.5-.4 1-.9 1.4-.3.4-.7.6-1.2.8l-1.2.3c-.4 0-.7 0-1-.2-.3 0-.6-.3-.8-.5-.5-.5-.8-1.2-.7-2a3 3 0 0 1 1-2.2A3.7 3.7 0 0 1 8.6 14H9l1-1-4-4-.5-1a3.3 3.3 0 0 1 0-2c0-.4.3-.7.5-1l2 2V3h14zM8.5 15.3h-.3a2.6 2.6 0 0 0-.8.4 2.5 2.5 0 0 0-.9 1.1l-.1.4v.7l.2.5.5.2h.7a2.5 2.5 0 0 0 .8-.3L9 18l.4-.4.2-.4.1-.4v-.7a1 1 0 0 0-.2-.5 1 1 0 0 0-.4-.2h-.5zm7 0H15a1 1 0 0 0-.4.3 1 1 0 0 0-.2.5 1.5 1.5 0 0 0 0 .7v.4a2.8 2.8 0 0 0 .5.7h.1a2.8 2.8 0 0 0 .8.6l.4.1h.7l.5-.2.2-.5v-.7a2.6 2.6 0 0 0-.3-.8 2.4 2.4 0 0 0-.7-.7 2.5 2.5 0 0 0-.8-.3h-.3zM12 11.6c-.4 0-.7.1-1 .4-.3.3-.4.6-.4 1s.1.7.4 1c.3.3.6.4 1 .4s.7-.1 1-.4c.3-.3.4-.6.4-1s-.1-.7-.4-1c-.3-.3-.6-.4-1-.4zm8.5-7.1h-11v2h11v-2z"/></svg>',tableRowCopy:'<svg viewBox="0 0 24 24"><path d="M22 11v7H6v-7h16zm-2 2H8v3h12v-3zm-1-6v2H4v5H2V7h17z"/></svg>',tableRowPasteBefore:'<svg viewBox="0 0 24 24"><path fill-rule="evenodd" d="M12 1a3 3 0 0 1 2.8 2H18c1 0 2 .8 2 1.9V7h-2V5h-2v1c0 .6-.4 1-1 1H9a1 1 0 0 1-1-1V5H6v13h12v-4h2v4c0 1-.8 2-1.9 2H6c-1 0-2-.8-2-1.9V5c0-1 .8-2 1.9-2h3.3A3 3 0 0 1 12 1zm10 7v5H8V8h14zm-1.5 1.5h-11v2h11v-2zM12 3a1 1 0 1 0 0 2 1 1 0 0 0 0-2z"/></svg>',tableRowPasteAfter:'<svg viewBox="0 0 24 24"><path fill-rule="evenodd" d="M12 1a3 3 0 0 1 2.8 2H18c1 0 2 .8 2 1.9V11h-2V5h-2v1c0 .6-.4 1-1 1H9a1 1 0 0 1-1-1V5H6v13h14c0 1-.8 2-1.9 2H6c-1 0-2-.8-2-1.9V5c0-1 .8-2 1.9-2h3.3A3 3 0 0 1 12 1zm10 11v5H8v-5h14zm-1.5 1.5h-11v2h11v-2zM12 3a1 1 0 1 0 0 2 1 1 0 0 0 0-2z"/></svg>',tableColumnItems:"",tableColumnInsertBefore:'<svg viewBox="0 0 24 24"><path d="M19 4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H4a1 1 0 0 1-1-1v-2a1 1 0 0 1 2 0v1h8V6H5v1a1 1 0 1 1-2 0V5c0-.6.4-1 1-1h15zm0 9h-4v5h4v-5zM8 8c.5 0 1 .4 1 .9V11h2a1 1 0 0 1 .1 2H9v2a1 1 0 0 1-2 .1V13H5a1 1 0 0 1-.1-2H7V9c0-.6.4-1 1-1zm11-2h-4v5h4V6z"/></svg>',tableColumnInsertAfter:'<svg viewBox="0 0 24 24"><path d="M20 4c.6 0 1 .4 1 1v2a1 1 0 0 1-2 0V6h-8v12h8v-1a1 1 0 0 1 2 0v2c0 .5-.4 1-.9 1H5a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h15zM9 13H5v5h4v-5zm7-5c.5 0 1 .4 1 .9V11h2a1 1 0 0 1 .1 2H17v2a1 1 0 0 1-2 .1V13h-2a1 1 0 0 1-.1-2H15V9c0-.6.4-1 1-1zM9 6H5v5h4V6z"/></svg>',tableColumnDelete:'<svg viewBox="0 0 24 24"><path d="M19 4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h14zm-4 4h-2V6h-2v2H9V6H5v12h4v-2h2v2h2v-2h2v2h4V6h-4v2zm.3.5 1 1.2-3 2.3 3 2.3-1 1.2L12 13l-3.3 2.6-1-1.2 3-2.3-3-2.3 1-1.2L12 11l3.3-2.5z"/></svg>',tableColumnCut:'<svg viewBox="0 0 24 24"><path fill-rule="evenodd" d="M7.2 4.5a3 3 0 0 1 2.2 1A3.7 3.7 0 0 1 10.5 8v.5l1 1 4-4 1-.5a3.3 3.3 0 0 1 2 0c.4 0 .7.3 1 .5L17 8h4v13h-6V10l-1.5 1.5.5.5v4l-2.5-2.5-1 1v.5c0 .4 0 .8-.3 1.2-.2.5-.4.9-.8 1.2-.6.7-1.3 1-2.2 1-.8.2-1.5 0-2-.6l-.5-.8-.2-1c0-.4 0-.8.3-1.2A3.9 3.9 0 0 1 7 12.7c.5-.2 1-.3 1.5-.2l1-1-1-1c-.5 0-1 0-1.5-.2-.5-.1-1-.4-1.4-.9-.4-.3-.6-.7-.8-1.2L4.5 7c0-.4 0-.7.2-1 0-.3.3-.6.5-.8.5-.5 1.2-.8 2-.7zm12.3 5h-3v10h3v-10zM8 13.8h-.3l-.4.2a2.8 2.8 0 0 0-.7.4v.1a2.8 2.8 0 0 0-.6.8l-.1.4v.7l.2.5.5.2h.7a2.6 2.6 0 0 0 .8-.3 2.4 2.4 0 0 0 .7-.7 2.5 2.5 0 0 0 .3-.8 1.5 1.5 0 0 0 0-.8 1 1 0 0 0-.2-.4 1 1 0 0 0-.5-.2H8zm3.5-3.7c-.4 0-.7.1-1 .4-.3.3-.4.6-.4 1s.1.7.4 1c.3.3.6.4 1 .4s.7-.1 1-.4c.3-.3.4-.6.4-1s-.1-.7-.4-1c-.3-.3-.6-.4-1-.4zM7 5.8h-.4a1 1 0 0 0-.5.3 1 1 0 0 0-.2.5v.7a2.5 2.5 0 0 0 .3.8l.2.3h.1l.4.4.4.2.4.1h.7L9 9l.2-.4a1.6 1.6 0 0 0 0-.8 2.6 2.6 0 0 0-.3-.8 2.5 2.5 0 0 0-1.2-1l-.4-.1H7z"/></svg>',tableColumnCopy:'<svg viewBox="0 0 24 24"><path d="M17 6v16h-7V6h7zm-2 2h-3v12h3V8zm-2-6v2H8v15H6V2h7z"/></svg>',tableColumnPasteBefore:'<svg viewBox="0 0 24 24"><path fill-rule="evenodd" d="M12 1a3 3 0 0 1 2.8 2H18c1 0 2 .8 2 1.9V18c0 1-.8 2-1.9 2H11v-2h7V5h-2v1c0 .6-.4 1-1 1H9a1 1 0 0 1-1-1V5H6v2H4V5c0-1 .8-2 1.9-2h3.3A3 3 0 0 1 12 1zm-2 7v12H4V8h6zM8.5 9.5h-3v9h3v-9zM12 3a1 1 0 1 0 0 2 1 1 0 0 0 0-2z"/></svg>',tableColumnPasteAfter:'<svg viewBox="0 0 24 24"><path fill-rule="evenodd" d="M12 1a3 3 0 0 1 2.8 2H18c1 0 2 .8 2 1.9V7h-2V5h-2v1c0 .6-.4 1-1 1H9a1 1 0 0 1-1-1V5H6v13h7v2H6c-1 0-2-.8-2-1.9V5c0-1 .8-2 1.9-2h3.3A3 3 0 0 1 12 1zm8 7v12h-6V8h6zm-1.5 1.5h-3v9h3v-9zM12 3a1 1 0 1 0 0 2 1 1 0 0 0 0-2z"/></svg>'},p="table",F="thead",_="tfoot",D="tbody",b="row",g="cell",k="clipboardTable",Ce=[p,F,_,D,b,g],A=e=>e.em.get(k)||[],He=e=>e.every(t=>t.is(g)),T=(e,t)=>{const{editor:o,event:l,opts:n}=e,s=l.currentTarget||l.target,{x:c,y:a,width:r,height:d}=s.getBoundingClientRect(),u={style:{width:240,height:300},placer:{type:"popover",closeOnClickAway:!0,x:c,y:a,w:r,h:d},layout:{type:"tabs",value:"props",tabs:[{id:"styles",label:"Styles",children:{type:"panelStyles"}},{id:"props",label:"Properties",children:{type:"panelProperties",style:{padding:"14px 7px"}}}]},...t};N(n.openSettings)?n.openSettings({...e,layoutProps:u}):o.runCommand(O.layoutToggle,u)},Re=(e,{rows:t=1,cells:o=5,text:l}={})=>({type:e,components:Array.from(Array(t).keys()).map(n=>({type:b,components:Array.from(Array(o).keys()).map(s=>({type:g,components:l?{type:"text",content:N(l)?l({y:n,x:s}):l}:void 0}))}))}),U="Table settings",$=e=>{const{component:t}=e;return t.is(p)?t:t.closestType(p)},Pe=e=>{var t;(t=$(e))==null||t.remove(e.opts)},Ve=e=>{const t=$(e);t&&(e.editor.select(t),T(e,{id:"tableSettings",header:{label:U}}))},W=e=>[{id:i.table,icon:v[i.table],label:"Table",items:[{id:i.tableSettings,label:U,icon:v[i.tableSettings],onClick:({event:o})=>Ve({...e,event:o})},{id:i.tableDelete,label:"Delete table",icon:v[i.tableDelete],onClick:()=>Pe(e)}]}],j=({editor:e})=>{const t=A(e);return t.length&&He(t)},K=({component:e,editor:t,after:o})=>{if(!e.is(g))return;const l=e.closestType(p),n=e.closestType(b),s=e.index()+(o?1:0);l==null||l.findType(b).forEach(a=>a.append({type:g},{at:s}));const c=n==null?void 0:n.components().at(s);c&&t.select(c)},q=({component:e,opts:t})=>{if(!e.is(g))return;const o=e.closestType(p),l=e.index();o==null||o.findType(b).forEach(n=>{var s;return(s=n.components().at(l))==null?void 0:s.remove(t)})},X=({component:e,editor:t})=>{if(!e.is(g))return;const o=e.closestType(p),l=e.index(),n=(o==null?void 0:o.findType(b).map(s=>s.components().at(l)))||[];n.length&&t.em.set(k,n)},Y=e=>{const{component:t,editor:o,after:l}=e;if(!t.is(g)||!j(e))return;const n=A(o),s=t.closestType(p),c=t.index()+(l?1:0);s==null||s.findType(b).forEach((a,r)=>{const d=n[r],u=(d==null?void 0:d.clone())||{type:g};a.append(u,{at:c})})},ze=e=>{const{component:t}=e;t.is(g)&&(X(e),q({...e,opts:{temporary:!0}}))},Ae=e=>{const t=j(e);return[{id:i.tableColumnItems,icon:v[i.tableColumn],label:"Column",items:[{id:i.tableColumnInsertBefore,label:"Insert column before",icon:v[i.tableColumnInsertBefore],onClick:()=>K(e)},{id:i.tableColumnInsertAfter,label:"Insert column after",icon:v[i.tableColumnInsertAfter],onClick:()=>K({...e,after:!0})},{id:i.tableColumnDelete,label:"Delete column",icon:v[i.tableColumnDelete],onClick:()=>q(e)},{id:i.tableColumnCut,label:"Cut column",icon:v[i.tableColumnCut],onClick:()=>ze(e)},{id:i.tableColumnCopy,label:"Copy column",icon:v[i.tableColumnCopy],onClick:()=>X(e)},{id:i.tableColumnPasteBefore,label:"Paste column before",icon:v[i.tableColumnPasteBefore],disabled:!t,onClick:()=>Y(e)},{id:i.tableColumnPasteAfter,label:"Paste column after",icon:v[i.tableColumnPasteAfter],disabled:!t,onClick:()=>Y({...e,after:!0})}]}]},J="Row settings",xe=e=>e.every(t=>t.is(b)),H=e=>{const{component:t}=e,o=t.is(g),l=t.is(b);if(!(!o&&!l))return l?t:t.closestType(b)},Q=e=>{const{component:t,editor:o,after:l}=e,n=H(e);if(!n)return;const s=n.index()+(l?1:0),c=n.components().length,a=Array.from(Array(c).keys()).map(()=>({type:g})),r=n.parent();if(r){const d=r.append({type:b,components:a},{at:s})[0];if(t.is(g)&&d){const u=t.index(),h=d.components().at(u);h&&o.select(h)}}},ee=e=>{var t;(t=H(e))==null||t.remove(e.opts)},te=e=>{const t=H(e);t&&e.editor.em.set(k,[t])},le=e=>{var a;const{editor:t,after:o}=e,l=H(e);if(!l||!oe(e))return;const s=A(t)[0],c=l.index()+(o?1:0);s&&((a=l.parent())==null||a.append(s.clone(),{at:c}))},Be=e=>{H(e)&&(te(e),ee({...e,opts:{temporary:!0}}))},oe=({editor:e})=>{const t=A(e);return t.length&&xe(t)},Ie=e=>{const t=H(e);t&&(e.editor.select(t),T(e,{id:"tableRowSettings",header:{label:J}}))},ne=e=>{const t=oe(e);return[{id:i.tableRowItems,icon:v[i.tableRowProperties],label:"Row",items:[{id:i.tableRowInsertBefore,label:"Insert row before",icon:v[i.tableRowInsertBefore],onClick:()=>Q(e)},{id:i.tableRowInsertAfter,label:"Insert row after",icon:v[i.tableRowInsertAfter],onClick:()=>Q({...e,after:!0})},{id:i.tableRowDelete,label:"Delete row",icon:v[i.tableRowDelete],onClick:()=>ee(e)},{id:i.tableRowProperties,label:J,icon:v[i.tableRowProperties],onClick:({event:l})=>Ie({...e,event:l})},{id:i.tableRowCut,label:"Cut row",icon:v[i.tableRowCut],onClick:()=>Be(e)},{id:i.tableRowCopy,label:"Copy row",icon:v[i.tableRowCopy],onClick:()=>te(e)},{id:i.tableRowPasteBefore,label:"Paste row before",icon:v[i.tableRowPasteBefore],disabled:!t,onClick:()=>le(e)},{id:i.tableRowPasteAfter,label:"Paste row after",icon:v[i.tableRowPasteAfter],disabled:!t,onClick:()=>le({...e,after:!0})}]},...W(e)]},S=e=>{const t=e.attributes.attributes||{},o=parseInt(`${t.rowspan||1}`,10),l=parseInt(`${t.colspan||1}`,10);return{rowspan:o,colspan:l}};function se(e){const t=[];return e.components().forEach((o,l)=>{o.components().each((n,s)=>{const{rowspan:c,colspan:a}=S(n);if(t[l])for(;t[l][s];)s++;for(let r=l;r<l+c;r++){t[r]||(t[r]=[]);for(let d=s;d<s+a;d++)t[r][d]={real:r===l&&d===s,cell:n,rowspan:c,colspan:a}}})}),t}function R(e,t,o){var l;return(l=e[o])==null?void 0:l[t]}const E=e=>e.closestType(b);function Me(e,{x:t,y:o,rows:l,cols:n}){var a;let s=E(e[o][t].cell),c;for(let r=1;r<=l;r++)if(s=(a=s==null?void 0:s.parent())==null?void 0:a.components().at(s.index()+1),s){for(c=t;c>=0;c--){const{cell:d}=e[o+r][c],u=E(d);if(u===s){for(let h=1;h<=n;h++){const f=d.index();u.append({type:g},{at:f+1})}break}}if(c===-1){const u=s.components().at(0).index();for(let h=1;h<=n;h++)s.append({type:g},{at:u})}}}function ae(e){for(let t=0;t<e.length;t++)for(let o=0;o<e[t].length;o++){const n=e[t][o].cell;if(n.em.selected.hasComponent(n)){const{rowspan:s,colspan:c}=S(n);if(c>1||s>1){n.addAttributes({colspan:1,rowspan:1});for(let a=0;a<c-1;a++){const r=n.index();E(n).append({type:g},{at:r+1})}Me(e,{x:o,y:t,rows:s-1,cols:c})}}}}function De(e){const t=[];e.components().forEach(o=>{o.components().length||t.push(o)}),t.forEach(o=>o.remove())}const x=(e,t={})=>{var c;const o=se(e),{em:l}=e;let n,s;for(let a=0;a<o.length;a++)for(let r=0;r<o[a].length;r++){const d=o[a][r];if((c=t.selected)!=null&&c.includes(d.cell)||l.selected.hasComponent(d.cell)){const u={x:r,y:a};n||(n=u),s=u}}return{grid:o,startPos:n,endPos:s}};function ke(e,t={}){const o=x(e),{startPos:l,endPos:n}=o;let{grid:s}=o;const{em:c}=e;if(!l||!n)return;const a=l.x,r=l.y,d=n.x,u=n.y,h=R(s,a,r),f=R(s,d,u);if(h&&f){ae(s),s=se(e);const B=[],m=R(s,a,r).cell;m.addAttributes({colspan:d-a+1,rowspan:u-r+1});for(let w=r;w<=u;w++)for(let V=a;V<=d;V++){const I=R(s,V,w);if(!I)continue;const{cell:M}=I;M!==m&&B.push(M)}B.forEach(w=>{t.mergeContent&&m.append(w.components().models),w.remove()}),c.setSelected(m),De(e)}}const re="Cell settings",Te="Merge cells",Se="Split cell",Ee=e=>e.closestType(b),P=e=>{var t;return(t=Ee(e))==null?void 0:t.parent()},Ge=e=>{const t=e.editor.getSelectedAll(),o=P(t[0]),l=t[0];if(!o||!(l!=null&&l.is(g))||t.length>1)return!1;const{rowspan:n,colspan:s}=S(l);return!(s<2&&n<2)},Le=e=>{const o=e.editor.getSelectedAll()[0],l=P(o),{grid:n}=x(l);ae(n)},ce=e=>{const t=e.editor.getSelectedAll(),o=P(t[0]);if(!o||t.length<2||t.some(a=>!a.is(g)||P(a)!==o))return!1;const{grid:l,startPos:n,endPos:s}=x(o),{em:c}=o;if(!n||!s)return!1;for(let a=n.y;a<=s.y;a++)for(let r=n.x;r<=s.x;r++){const d=R(l,r,a);if(!d||!c.selected.hasComponent(d.cell))return!1}return!0},Ne=e=>{const{editor:t}=e;if(!ce(e))return;const o=t.getSelectedAll(),l=P(o[0]);ke(l,{mergeContent:!0})},Oe=e=>{T(e,{id:"tableCellSettings",header:{label:re}})},Ze=e=>[{id:i.tableCellItems,icon:v[i.tableCellProperties],label:"Cell",items:[{id:i.tableCellProperties,label:re,icon:v[i.tableCellProperties],onClick:({event:o})=>Oe({...e,event:o})},{id:i.tableCellMerge,label:Te,icon:v[i.tableCellMerge],onClick:()=>Ne(e),disabled:!ce(e)},{id:i.tableCellSplit,label:Se,icon:v[i.tableCellSplit],onClick:()=>Le(e),disabled:!Ge(e)}]},...Ae(e),...ne(e)],Fe=e=>{const t=e[0]&&P(e[0]);if(!t)return;const{grid:o,startPos:l,endPos:n}=x(t,{selected:e});if(!l||!n)return;const s=[];for(let c=l.y;c<=n.y;c++)for(let a=l.x;a<=n.x;a++){const r=R(o,a,c);r&&s.push(r.cell)}s.length&&t.em.setSelected(s,{fromCell:!0})};return pe(function(e,t={}){const o={block:{},...t},{Components:l}=e,n={copyable:!1,emptyState:!0,highlightable:!1,stylable:["color","font-family","font-size","font-weight","line-height","text-align","vertical-align","background-color","border-width","border-style","border-color"]};l.addType(p,{block:o.block&&{label:"Table",media:v.table,category:"Extra",content:{type:p,style:{width:"100%"}},select:!0,...o.block},model:{defaults:{emptyState:!0,highlightable:!1,icon:v.table,stylable:["width","height","margin","font-family","font-size","font-weight","line-height","text-align","background","background-color","border-width","border-style","border-color"],traits:[{type:"number",min:0,name:"cellspacing",label:"Cell spacing"},{type:"number",min:0,name:"cellpadding",label:"Cell padding"},{id:"tableCaption",type:"checkbox",label:"Caption",setValue({component:c,value:a,emitUpdate:r}){const d=c.find("caption")[0];a?!d&&c.append({type:"text",tagName:"caption",components:{type:"textnode",content:"Caption"}}):d==null||d.remove(),r(),e.refresh({tools:!0})},getValue(c){return!!c.component.find("caption")[0]}}],components:Re(D,{rows:5}),contextMenu:({items:c,editor:a,component:r})=>[...W({editor:a,component:r,opts:o}),...c]}}}),l.addType(F,{model:{defaults:{icon:v.tableHead,...n}}}),l.addType(_,{model:{defaults:{icon:v.tableFoot,...n}}}),l.addType(D,{model:{defaults:{icon:v.tableRowProperties,...n}}}),l.addType(b,{model:{defaults:{icon:v.tableRowProperties,emptyState:!0,highlightable:!1,stylable:["height","text-align","border-width","border-style","border-color"],traits:[],contextMenu:({items:c,editor:a,component:r})=>[...ne({editor:a,component:r,opts:o}),...c]}}}),l.addType(g,{model:{defaults:{icon:v.tableCellProperties,emptyState:{styleOut:"height: 1px"},stylable:["width","height","padding","background","background-color","text-align","vertical-align","border-width","border-style","border-color"],traits:[{id:"tableCellType",type:"select",options:[{value:"td",name:"Cell"},{value:"th",name:"Header Cell"}],label:"Cell type",name:"tagName",changeProp:!0},{id:"tableCellScope",type:"select",options:[{value:!1,name:"None"},{value:"row",name:"Row"},{value:"col",name:"Column"},{value:"rowgroup",name:"Row group"},{value:"colgroup",name:"Column group"}],label:"Scope",name:"scope"}],contextMenu:({items:c,editor:a,component:r})=>[...Ze({editor:a,component:r,opts:o}),...c]}}});const s=z((c,a)=>{var h;const r=e.getSelectedAll(),d=!!((h=a==null?void 0:a.event)!=null&&h.shiftKey);if(r.length<2||!d||a.fromCell)return;const u=r.map(f=>f.is(g)?f:f.closestType(g)).filter(Boolean);u.length===r.length&&Fe(u)},0);e.on("component:select",s),fe({editor:e,plan:ye,pluginName:we,licenseKey:o.licenseKey,cleanup:()=>{e.off("component:select",s),e.Blocks.remove(p),Ce.forEach(c=>l.removeType(c))}})})});
|
|
1
|
+
(function(z,y){typeof exports=="object"&&typeof module<"u"?module.exports=y():typeof define=="function"&&define.amd?define(y):(z=typeof globalThis<"u"?globalThis:z||self,z.StudioSdkPlugins_tableComponent=y())})(this,function(){"use strict";function z(e,t,o){let l,n,s,c,a;const r=t;function d(){const h=Date.now()-c;h<r&&h>=0?l=setTimeout(d,r-h):(l=null,a=e.apply(s,n),s=n=null)}const v=function(){return s=this,n=arguments,c=Date.now(),l||(l=setTimeout(d,r)),a};return v.clear=function(){l&&(clearTimeout(l),l=null)},v.flush=function(){l&&(a=e.apply(s,n),s=n=null,clearTimeout(l),l=null)},v}const y="app.grapesjs.com",G="app-stage.grapesjs.com",N=[y,"app2.grapesjs.com",G,"app-stage2.grapesjs.com","localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],ie="license:check:end",de=()=>typeof window<"u",he=({isDev:e,isStage:t,isPlatform:o})=>`${e?"":`https://${t?G:y}`}/${o?"platform-api":"api"}`,ue=()=>{const e=de()&&window.location.hostname;return!!e&&(N.includes(e)||N.some(t=>e.endsWith(t)))};function O(e){return typeof e=="function"}async function ve({path:e,baseApiUrl:t,method:o="GET",headers:l={},params:n,body:s}){const a=`${t||he({isDev:!1,isStage:!1})}${e}`,r={method:o,headers:{"Content-Type":"application/json",...l}};s&&(r.body=JSON.stringify(s));const d=n?new URLSearchParams(n).toString():"",v=d?`?${d}`:"",h=await fetch(`${a}${v}`,r);if(!h.ok)throw new Error(`HTTP error! status: ${h.status}`);return h.json()}var C=(e=>(e.free="free",e.startup="startup",e.business="business",e.enterprise="enterprise",e))(C||{}),A=(e=>(e.toastAdd="studio:toastAdd",e.toastRemove="studio:toastRemove",e.dialogOpen="studio:dialogOpen",e.dialogClose="studio:dialogClose",e.dialogExportCode="studio:dialogExportCode",e.dialogImportCode="studio:dialogImportCode",e.sidebarLeftSet="studio:sidebarLeft:set",e.sidebarLeftGet="studio:sidebarLeft:get",e.sidebarLeftToggle="studio:sidebarLeft:toggle",e.sidebarRightSet="studio:sidebarRight:set",e.sidebarRightGet="studio:sidebarRight:get",e.sidebarRightToggle="studio:sidebarRight:toggle",e.sidebarTopSet="studio:sidebarTop:set",e.sidebarTopGet="studio:sidebarTop:get",e.sidebarTopToggle="studio:sidebarTop:toggle",e.sidebarBottomSet="studio:sidebarBottom:set",e.sidebarBottomGet="studio:sidebarBottom:get",e.sidebarBottomToggle="studio:sidebarBottom:toggle",e.symbolAdd="studio:symbolAdd",e.symbolDetach="studio:symbolDetach",e.symbolOverride="studio:symbolOverride",e.symbolPropagateStyles="studio:propagateStyles",e.getPagesConfig="studio:getPagesConfig",e.setPagesConfig="studio:setPagesConfig",e.getPageSettings="studio:getPageSettings",e.setPageSettings="studio:setPageSettings",e.clearPage="studio:clearPage",e.projectFiles="studio:projectFiles",e.validateCode="studio:validateCode",e.canvasReload="studio:canvasReload",e.getBlocksPanel="studio:getBlocksPanel",e.setBlocksPanel="studio:setBlocksPanel",e.getStateContextMenu="studio:getStateContextMenu",e.setStateContextMenu="studio:setStateContextMenu",e.contextMenuComponent="studio:contextMenuComponent",e.layoutAdd="studio:layoutAdd",e.layoutRemove="studio:layoutRemove",e.layoutToggle="studio:layoutToggle",e.layoutUpdate="studio:layoutUpdate",e.layoutGet="studio:layoutGet",e.layoutConfigGet="studio:layoutConfigGet",e.layoutConfigSet="studio:layoutConfigSet",e.layoutComponentAdd="studio:layoutComponentAdd",e.layoutComponentGet="studio:layoutComponentGet",e.layoutComponentRemove="studio:layoutComponentRemove",e.layoutComponentRender="studio:layoutComponentRender",e.getStateTheme="studio:getStateTheme",e.setStateTheme="studio:setStateTheme",e.settings="studio:settings",e.assetProviderGet="studio:assetProviderGet",e.assetProviderAdd="studio:assetProviderAdd",e.assetProviderRemove="studio:assetProviderRemove",e.fontGet="studio:fontGet",e.fontAdd="studio:fontAdd",e.fontRemove="studio:fontRemove",e.fontManagerOpen="studio:fontManagerOpen",e.menuFontLoad="studio:menuFontLoad",e.toggleStateDataSource="studio:toggleStateDataSource",e.getStateDataSource="studio:getStateDataSource",e.dataSourceSetGlobalData="studio:dataSourceSetGlobalData",e.dataSourceSetImporter="studio:dataSourceSetImporter",e.dataSourceSetExporter="studio:dataSourceSetExporter",e.setDragAbsolute="studio:setDragAbsolute",e))(A||{});const Z={[C.free]:0,[C.startup]:10,[C.business]:20,[C.enterprise]:30};function ge(e){const t=e;return t.init=o=>l=>e(l,o),t}const be=e=>ge(e);async function pe({editor:e,plan:t,pluginName:o,licenseKey:l,onLicenseCheckResponse:n,cleanup:s}){let c="",a;const r=h=>{console.warn("Cleanup plugin:",o,"Reason:",h),s()},d=(h={})=>{var V;const{error:f,sdkLicense:I}=h,m=(V=h.plan)==null?void 0:V.category;if(!(I||h.license)||f)r(f||"Invalid license");else if(m){const M=Z[t],k=Z[m];M>k&&r({pluginRequiredPlan:t,licensePlan:m})}};e.Commands.has(A.settings)&&(a=e.runCommand(A.settings),c=(a==null?void 0:a.baseUrl)||"");const v=h=>{n==null||n(h),h&&d(h)};if(!a){e.onReady(async()=>{if(!ue())if(l){const h=await me({licenseKey:l,pluginName:o,baseApiUrl:c});v(h)}else r("The `licenseKey` option not provided")});return}if(a.licensePlan||a.licenseError){const h=fe(a);v(h);return}e.on(ie,h=>v(h))}const fe=e=>({sdkLicense:e.license,license:e.license,error:e.licenseError,plan:e.licensePlan});async function me(e){const{licenseKey:t,pluginName:o,baseApiUrl:l}=e;try{return(await ve({baseApiUrl:l,path:`/sdk/${t||"na"}`,method:"POST",params:{d:window.location.hostname,pn:o}})).result||{}}catch(n){return console.error("Error during SDK license check:",n),!1}}const we="tableComponent",ye=C.startup;var i=(e=>(e.table="table",e.tableSettings="tableSettings",e.tableDelete="tableDelete",e.tableHead="tableHead",e.tableFoot="tableFoot",e.tableCellItems="tableCellItems",e.tableCellProperties="tableCellProperties",e.tableCellMerge="tableCellMerge",e.tableCellSplit="tableCellSplit",e.tableRowItems="tableRowItems",e.tableRowInsertBefore="tableRowInsertBefore",e.tableRowInsertAfter="tableRowInsertAfter",e.tableRowDelete="tableRowDelete",e.tableRowProperties="tableRowProperties",e.tableRowCut="tableRowCut",e.tableRowCopy="tableRowCopy",e.tableRowPasteBefore="tableRowPasteBefore",e.tableRowPasteAfter="tableRowPasteAfter",e.tableColumn="tableColumn",e.tableColumnItems="tableColumnItems",e.tableColumnInsertBefore="tableColumnInsertBefore",e.tableColumnInsertAfter="tableColumnInsertAfter",e.tableColumnDelete="tableColumnDelete",e.tableColumnCut="tableColumnCut",e.tableColumnCopy="tableColumnCopy",e.tableColumnPasteBefore="tableColumnPasteBefore",e.tableColumnPasteAfter="tableColumnPasteAfter",e))(i||{});const u={table:'<svg viewBox="0 0 24 24"><path d="M5 4h14a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2m0 4v4h6V8H5m8 0v4h6V8h-6m-8 6v4h6v-4H5m8 0v4h6v-4h-6Z"/></svg>',tableSettings:'<svg viewBox="0 0 24 24"><path d="M5 4h14a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2m0 4v4h6V8H5m8 0v4h6V8h-6m-8 6v4h6v-4H5m8 0v4h6v-4h-6Z"/></svg>',tableDelete:'<svg viewBox="0 0 24 24"><path d="M19 4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h14zM5 6v12h14V6H5z"/><path d="m14.4 8.6 1 1-2.3 2.4 2.3 2.4-1 1-2.4-2.3-2.4 2.3-1-1 2.3-2.4-2.3-2.4 1-1 2.4 2.3z"/></svg>',tableHead:'<svg viewBox="0 0 24 24"><path d="M19 4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h14Zm-8 11H5v3h6v-3Zm8 0h-6v3h6v-3Zm0-5h-6v3h6v-3ZM5 13h6v-3H5v3Z"/></svg>',tableFoot:'<svg viewBox="0 0 24 24" data-test="1" style="transform: rotate(180deg);"><path d="M19 4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h14Zm-8 11H5v3h6v-3Zm8 0h-6v3h6v-3Zm0-5h-6v3h6v-3ZM5 13h6v-3H5v3Z"/></svg>',tableColumn:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M19 4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h14Zm0 9h-4v5h4v-5Zm-6 0H9v5h4v-5Zm0-7H9v5h4V6Zm6 0h-4v5h4V6Z"/></svg>',tableCellItems:"",tableCellProperties:'<svg viewBox="0 0 24 24"><path d="M19 4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6l2-2h14zm-8 9H5v5h6v-5zm8 0h-6v5h6v-5zm-8-7H5v5h6V6z"/></svg>',tableCellMerge:'<svg viewBox="0 0 24 24"><path d="M19 4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6l2-2h14zM5 16v2h3v-2H5zm14-5h-9v7h9v-7zm0-5h-4v3h4V6zM8 6H5v3h3V6zm5 0h-3v3h3V6zm-8 8h3v-3H5v3z"/></svg>',tableCellSplit:'<svg viewBox="0 0 24 24"><path d="M19 4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h14zM8 15.5H5V18h3v-2.5zm11-5h-9V18h9v-7.5zm-2.5 1 1 1-2 2 2 2-1 1-2-2-2 2-1-1 2-2-2-2 1-1 2 2 2-2zm-8.5-1H5v3h3v-3zM19 6h-4v2.5h4V6zM8 6H5v2.5h3V6zm5 0h-3v2.5h3V6z"/></svg>',tableRowItems:"",tableRowInsertBefore:'<svg viewBox="0 0 24 24"><path d="M6 4a1 1 0 1 1 0 2H5v6h14V6h-1a1 1 0 0 1 0-2h2c.6 0 1 .4 1 1v13a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5c0-.6.4-1 1-1h2zm5 10H5v4h6v-4zm8 0h-6v4h6v-4zM12 3c.5 0 1 .4 1 .9V6h2a1 1 0 0 1 0 2h-2v2a1 1 0 0 1-2 .1V8H9a1 1 0 0 1 0-2h2V4c0-.6.4-1 1-1z"/></svg>',tableRowInsertAfter:'<svg viewBox="0 0 24 24"><path d="M12 13c.5 0 1 .4 1 .9V16h2a1 1 0 0 1 .1 2H13v2a1 1 0 0 1-2 .1V18H9a1 1 0 0 1-.1-2H11v-2c0-.6.4-1 1-1zm6 7a1 1 0 0 1 0-2h1v-6H5v6h1a1 1 0 0 1 0 2H4a1 1 0 0 1-1-1V6c0-1.1.9-2 2-2h14a2 2 0 0 1 2 2v13c0 .5-.4 1-.9 1H18zM11 6H5v4h6V6zm8 0h-6v4h6V6z"/></svg>',tableRowDelete:'<svg viewBox="0 0 24 24"><path d="M19 4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h14zm0 2H5v3h2.5v2H5v2h2.5v2H5v3h14v-3h-2.5v-2H19v-2h-2.5V9H19V6zm-4.7 1.8 1.2 1L13 12l2.6 3.3-1.2 1-2.3-3-2.3 3-1.2-1L11 12 8.5 8.7l1.2-1 2.3 3 2.3-3z"/></svg>',tableRowProperties:'<svg viewBox="0 0 24 24"><path d="M19 4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h14zM5 15v3h6v-3H5zm14 0h-6v3h6v-3zm0-9h-6v3h6V6zM5 9h6V6H5v3z"/></svg>',tableRowCut:'<svg viewBox="0 0 24 24"><path fill-rule="evenodd" d="M22 3v5H9l3 3 2-2h4l-4 4 1 1h.5c.4 0 .8 0 1.2.3.5.2.9.4 1.2.8.7.6 1 1.3 1 2.2.2.8 0 1.5-.6 2l-.8.5-1 .2c-.4 0-.8 0-1.2-.3a3.9 3.9 0 0 1-2.1-2.2c-.2-.5-.3-1-.2-1.5l-1-1-1 1c0 .5 0 1-.2 1.5-.1.5-.4 1-.9 1.4-.3.4-.7.6-1.2.8l-1.2.3c-.4 0-.7 0-1-.2-.3 0-.6-.3-.8-.5-.5-.5-.8-1.2-.7-2a3 3 0 0 1 1-2.2A3.7 3.7 0 0 1 8.6 14H9l1-1-4-4-.5-1a3.3 3.3 0 0 1 0-2c0-.4.3-.7.5-1l2 2V3h14zM8.5 15.3h-.3a2.6 2.6 0 0 0-.8.4 2.5 2.5 0 0 0-.9 1.1l-.1.4v.7l.2.5.5.2h.7a2.5 2.5 0 0 0 .8-.3L9 18l.4-.4.2-.4.1-.4v-.7a1 1 0 0 0-.2-.5 1 1 0 0 0-.4-.2h-.5zm7 0H15a1 1 0 0 0-.4.3 1 1 0 0 0-.2.5 1.5 1.5 0 0 0 0 .7v.4a2.8 2.8 0 0 0 .5.7h.1a2.8 2.8 0 0 0 .8.6l.4.1h.7l.5-.2.2-.5v-.7a2.6 2.6 0 0 0-.3-.8 2.4 2.4 0 0 0-.7-.7 2.5 2.5 0 0 0-.8-.3h-.3zM12 11.6c-.4 0-.7.1-1 .4-.3.3-.4.6-.4 1s.1.7.4 1c.3.3.6.4 1 .4s.7-.1 1-.4c.3-.3.4-.6.4-1s-.1-.7-.4-1c-.3-.3-.6-.4-1-.4zm8.5-7.1h-11v2h11v-2z"/></svg>',tableRowCopy:'<svg viewBox="0 0 24 24"><path d="M22 11v7H6v-7h16zm-2 2H8v3h12v-3zm-1-6v2H4v5H2V7h17z"/></svg>',tableRowPasteBefore:'<svg viewBox="0 0 24 24"><path fill-rule="evenodd" d="M12 1a3 3 0 0 1 2.8 2H18c1 0 2 .8 2 1.9V7h-2V5h-2v1c0 .6-.4 1-1 1H9a1 1 0 0 1-1-1V5H6v13h12v-4h2v4c0 1-.8 2-1.9 2H6c-1 0-2-.8-2-1.9V5c0-1 .8-2 1.9-2h3.3A3 3 0 0 1 12 1zm10 7v5H8V8h14zm-1.5 1.5h-11v2h11v-2zM12 3a1 1 0 1 0 0 2 1 1 0 0 0 0-2z"/></svg>',tableRowPasteAfter:'<svg viewBox="0 0 24 24"><path fill-rule="evenodd" d="M12 1a3 3 0 0 1 2.8 2H18c1 0 2 .8 2 1.9V11h-2V5h-2v1c0 .6-.4 1-1 1H9a1 1 0 0 1-1-1V5H6v13h14c0 1-.8 2-1.9 2H6c-1 0-2-.8-2-1.9V5c0-1 .8-2 1.9-2h3.3A3 3 0 0 1 12 1zm10 11v5H8v-5h14zm-1.5 1.5h-11v2h11v-2zM12 3a1 1 0 1 0 0 2 1 1 0 0 0 0-2z"/></svg>',tableColumnItems:"",tableColumnInsertBefore:'<svg viewBox="0 0 24 24"><path d="M19 4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H4a1 1 0 0 1-1-1v-2a1 1 0 0 1 2 0v1h8V6H5v1a1 1 0 1 1-2 0V5c0-.6.4-1 1-1h15zm0 9h-4v5h4v-5zM8 8c.5 0 1 .4 1 .9V11h2a1 1 0 0 1 .1 2H9v2a1 1 0 0 1-2 .1V13H5a1 1 0 0 1-.1-2H7V9c0-.6.4-1 1-1zm11-2h-4v5h4V6z"/></svg>',tableColumnInsertAfter:'<svg viewBox="0 0 24 24"><path d="M20 4c.6 0 1 .4 1 1v2a1 1 0 0 1-2 0V6h-8v12h8v-1a1 1 0 0 1 2 0v2c0 .5-.4 1-.9 1H5a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h15zM9 13H5v5h4v-5zm7-5c.5 0 1 .4 1 .9V11h2a1 1 0 0 1 .1 2H17v2a1 1 0 0 1-2 .1V13h-2a1 1 0 0 1-.1-2H15V9c0-.6.4-1 1-1zM9 6H5v5h4V6z"/></svg>',tableColumnDelete:'<svg viewBox="0 0 24 24"><path d="M19 4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h14zm-4 4h-2V6h-2v2H9V6H5v12h4v-2h2v2h2v-2h2v2h4V6h-4v2zm.3.5 1 1.2-3 2.3 3 2.3-1 1.2L12 13l-3.3 2.6-1-1.2 3-2.3-3-2.3 1-1.2L12 11l3.3-2.5z"/></svg>',tableColumnCut:'<svg viewBox="0 0 24 24"><path fill-rule="evenodd" d="M7.2 4.5a3 3 0 0 1 2.2 1A3.7 3.7 0 0 1 10.5 8v.5l1 1 4-4 1-.5a3.3 3.3 0 0 1 2 0c.4 0 .7.3 1 .5L17 8h4v13h-6V10l-1.5 1.5.5.5v4l-2.5-2.5-1 1v.5c0 .4 0 .8-.3 1.2-.2.5-.4.9-.8 1.2-.6.7-1.3 1-2.2 1-.8.2-1.5 0-2-.6l-.5-.8-.2-1c0-.4 0-.8.3-1.2A3.9 3.9 0 0 1 7 12.7c.5-.2 1-.3 1.5-.2l1-1-1-1c-.5 0-1 0-1.5-.2-.5-.1-1-.4-1.4-.9-.4-.3-.6-.7-.8-1.2L4.5 7c0-.4 0-.7.2-1 0-.3.3-.6.5-.8.5-.5 1.2-.8 2-.7zm12.3 5h-3v10h3v-10zM8 13.8h-.3l-.4.2a2.8 2.8 0 0 0-.7.4v.1a2.8 2.8 0 0 0-.6.8l-.1.4v.7l.2.5.5.2h.7a2.6 2.6 0 0 0 .8-.3 2.4 2.4 0 0 0 .7-.7 2.5 2.5 0 0 0 .3-.8 1.5 1.5 0 0 0 0-.8 1 1 0 0 0-.2-.4 1 1 0 0 0-.5-.2H8zm3.5-3.7c-.4 0-.7.1-1 .4-.3.3-.4.6-.4 1s.1.7.4 1c.3.3.6.4 1 .4s.7-.1 1-.4c.3-.3.4-.6.4-1s-.1-.7-.4-1c-.3-.3-.6-.4-1-.4zM7 5.8h-.4a1 1 0 0 0-.5.3 1 1 0 0 0-.2.5v.7a2.5 2.5 0 0 0 .3.8l.2.3h.1l.4.4.4.2.4.1h.7L9 9l.2-.4a1.6 1.6 0 0 0 0-.8 2.6 2.6 0 0 0-.3-.8 2.5 2.5 0 0 0-1.2-1l-.4-.1H7z"/></svg>',tableColumnCopy:'<svg viewBox="0 0 24 24"><path d="M17 6v16h-7V6h7zm-2 2h-3v12h3V8zm-2-6v2H8v15H6V2h7z"/></svg>',tableColumnPasteBefore:'<svg viewBox="0 0 24 24"><path fill-rule="evenodd" d="M12 1a3 3 0 0 1 2.8 2H18c1 0 2 .8 2 1.9V18c0 1-.8 2-1.9 2H11v-2h7V5h-2v1c0 .6-.4 1-1 1H9a1 1 0 0 1-1-1V5H6v2H4V5c0-1 .8-2 1.9-2h3.3A3 3 0 0 1 12 1zm-2 7v12H4V8h6zM8.5 9.5h-3v9h3v-9zM12 3a1 1 0 1 0 0 2 1 1 0 0 0 0-2z"/></svg>',tableColumnPasteAfter:'<svg viewBox="0 0 24 24"><path fill-rule="evenodd" d="M12 1a3 3 0 0 1 2.8 2H18c1 0 2 .8 2 1.9V7h-2V5h-2v1c0 .6-.4 1-1 1H9a1 1 0 0 1-1-1V5H6v13h7v2H6c-1 0-2-.8-2-1.9V5c0-1 .8-2 1.9-2h3.3A3 3 0 0 1 12 1zm8 7v12h-6V8h6zm-1.5 1.5h-3v9h3v-9zM12 3a1 1 0 1 0 0 2 1 1 0 0 0 0-2z"/></svg>'},p="table",F="thead",U="tfoot",D="tbody",b="row",g="cell",T="clipboardTable",Ce=[p,F,U,D,b,g],x=e=>e.em.get(T)||[],He=e=>e.every(t=>t.is(g)),S=(e,t)=>{const{editor:o,event:l,opts:n}=e,s=l.currentTarget||l.target,{x:c,y:a,width:r,height:d}=s.getBoundingClientRect(),v={style:{width:240,height:300},placer:{type:"popover",closeOnClickAway:!0,x:c,y:a,w:r,h:d},layout:{type:"tabs",value:"props",tabs:[{id:"styles",label:"Styles",children:{type:"panelStyles"}},{id:"props",label:"Properties",children:{type:"panelProperties",style:{padding:"14px 7px"}}}]},...t};O(n.openSettings)?n.openSettings({...e,layoutProps:v}):o.runCommand(A.layoutToggle,v)},Re=(e,{rows:t=1,cells:o=5,text:l}={})=>({type:e,components:Array.from(Array(t).keys()).map(n=>({type:b,components:Array.from(Array(o).keys()).map(s=>({type:g,components:l?{type:"text",content:O(l)?l({y:n,x:s}):l}:void 0}))}))}),$="Table settings",_=e=>{const{component:t}=e;return t.is(p)?t:t.closestType(p)},Pe=e=>{var t;(t=_(e))==null||t.remove(e.opts)},Ve=e=>{const t=_(e);t&&(e.editor.select(t),S(e,{id:"tableSettings",header:{label:$}}))},W=e=>[{id:i.table,icon:u[i.table],label:"Table",items:[{id:i.tableSettings,label:$,icon:u[i.tableSettings],onClick:({event:o})=>Ve({...e,event:o})},{id:i.tableDelete,label:"Delete table",icon:u[i.tableDelete],onClick:()=>Pe(e)}]}],j=({editor:e})=>{const t=x(e);return t.length&&He(t)},K=({component:e,editor:t,after:o})=>{if(!e.is(g))return;const l=e.closestType(p),n=e.closestType(b),s=e.index()+(o?1:0);l==null||l.findType(b).forEach(a=>a.append({type:g},{at:s}));const c=n==null?void 0:n.components().at(s);c&&t.select(c)},q=({component:e,opts:t})=>{if(!e.is(g))return;const o=e.closestType(p),l=e.index();o==null||o.findType(b).forEach(n=>{var s;return(s=n.components().at(l))==null?void 0:s.remove(t)})},X=({component:e,editor:t})=>{if(!e.is(g))return;const o=e.closestType(p),l=e.index(),n=(o==null?void 0:o.findType(b).map(s=>s.components().at(l)))||[];n.length&&t.em.set(T,n)},Y=e=>{const{component:t,editor:o,after:l}=e;if(!t.is(g)||!j(e))return;const n=x(o),s=t.closestType(p),c=t.index()+(l?1:0);s==null||s.findType(b).forEach((a,r)=>{const d=n[r],v=(d==null?void 0:d.clone())||{type:g};a.append(v,{at:c})})},ze=e=>{const{component:t}=e;t.is(g)&&(X(e),q({...e,opts:{temporary:!0}}))},Ae=e=>{const t=j(e);return[{id:i.tableColumnItems,icon:u[i.tableColumn],label:"Column",items:[{id:i.tableColumnInsertBefore,label:"Insert column before",icon:u[i.tableColumnInsertBefore],onClick:()=>K(e)},{id:i.tableColumnInsertAfter,label:"Insert column after",icon:u[i.tableColumnInsertAfter],onClick:()=>K({...e,after:!0})},{id:i.tableColumnDelete,label:"Delete column",icon:u[i.tableColumnDelete],onClick:()=>q(e)},{id:i.tableColumnCut,label:"Cut column",icon:u[i.tableColumnCut],onClick:()=>ze(e)},{id:i.tableColumnCopy,label:"Copy column",icon:u[i.tableColumnCopy],onClick:()=>X(e)},{id:i.tableColumnPasteBefore,label:"Paste column before",icon:u[i.tableColumnPasteBefore],disabled:!t,onClick:()=>Y(e)},{id:i.tableColumnPasteAfter,label:"Paste column after",icon:u[i.tableColumnPasteAfter],disabled:!t,onClick:()=>Y({...e,after:!0})}]}]},J="Row settings",xe=e=>e.every(t=>t.is(b)),H=e=>{const{component:t}=e,o=t.is(g),l=t.is(b);if(!(!o&&!l))return l?t:t.closestType(b)},Q=e=>{const{component:t,editor:o,after:l}=e,n=H(e);if(!n)return;const s=n.index()+(l?1:0),c=n.components().length,a=Array.from(Array(c).keys()).map(()=>({type:g})),r=n.parent();if(r){const d=r.append({type:b,components:a},{at:s})[0];if(t.is(g)&&d){const v=t.index(),h=d.components().at(v);h&&o.select(h)}}},ee=e=>{var t;(t=H(e))==null||t.remove(e.opts)},te=e=>{const t=H(e);t&&e.editor.em.set(T,[t])},le=e=>{var a;const{editor:t,after:o}=e,l=H(e);if(!l||!oe(e))return;const s=x(t)[0],c=l.index()+(o?1:0);s&&((a=l.parent())==null||a.append(s.clone(),{at:c}))},Be=e=>{H(e)&&(te(e),ee({...e,opts:{temporary:!0}}))},oe=({editor:e})=>{const t=x(e);return t.length&&xe(t)},Ie=e=>{const t=H(e);t&&(e.editor.select(t),S(e,{id:"tableRowSettings",header:{label:J}}))},ne=e=>{const t=oe(e);return[{id:i.tableRowItems,icon:u[i.tableRowProperties],label:"Row",items:[{id:i.tableRowInsertBefore,label:"Insert row before",icon:u[i.tableRowInsertBefore],onClick:()=>Q(e)},{id:i.tableRowInsertAfter,label:"Insert row after",icon:u[i.tableRowInsertAfter],onClick:()=>Q({...e,after:!0})},{id:i.tableRowDelete,label:"Delete row",icon:u[i.tableRowDelete],onClick:()=>ee(e)},{id:i.tableRowProperties,label:J,icon:u[i.tableRowProperties],onClick:({event:l})=>Ie({...e,event:l})},{id:i.tableRowCut,label:"Cut row",icon:u[i.tableRowCut],onClick:()=>Be(e)},{id:i.tableRowCopy,label:"Copy row",icon:u[i.tableRowCopy],onClick:()=>te(e)},{id:i.tableRowPasteBefore,label:"Paste row before",icon:u[i.tableRowPasteBefore],disabled:!t,onClick:()=>le(e)},{id:i.tableRowPasteAfter,label:"Paste row after",icon:u[i.tableRowPasteAfter],disabled:!t,onClick:()=>le({...e,after:!0})}]},...W(e)]},L=e=>{const t=e.attributes.attributes||{},o=parseInt(`${t.rowspan||1}`,10),l=parseInt(`${t.colspan||1}`,10);return{rowspan:o,colspan:l}};function se(e){const t=[];return e.components().forEach((o,l)=>{o.components().each((n,s)=>{const{rowspan:c,colspan:a}=L(n);if(t[l])for(;t[l][s];)s++;for(let r=l;r<l+c;r++){t[r]||(t[r]=[]);for(let d=s;d<s+a;d++)t[r][d]={real:r===l&&d===s,cell:n,rowspan:c,colspan:a}}})}),t}function R(e,t,o){var l;return(l=e[o])==null?void 0:l[t]}const E=e=>e.closestType(b);function Me(e,{x:t,y:o,rows:l,cols:n}){var a;let s=E(e[o][t].cell),c;for(let r=1;r<=l;r++)if(s=(a=s==null?void 0:s.parent())==null?void 0:a.components().at(s.index()+1),s){for(c=t;c>=0;c--){const{cell:d}=e[o+r][c],v=E(d);if(v===s){for(let h=1;h<=n;h++){const f=d.index();v.append({type:g},{at:f+1})}break}}if(c===-1){const v=s.components().at(0).index();for(let h=1;h<=n;h++)s.append({type:g},{at:v})}}}function ae(e){for(let t=0;t<e.length;t++)for(let o=0;o<e[t].length;o++){const n=e[t][o].cell;if(n.em.selected.hasComponent(n)){const{rowspan:s,colspan:c}=L(n);if(c>1||s>1){n.addAttributes({colspan:1,rowspan:1});for(let a=0;a<c-1;a++){const r=n.index();E(n).append({type:g},{at:r+1})}Me(e,{x:o,y:t,rows:s-1,cols:c})}}}}function ke(e){const t=[];e.components().forEach(o=>{o.components().length||t.push(o)}),t.forEach(o=>o.remove())}const B=(e,t={})=>{var c;const o=se(e),{em:l}=e;let n,s;for(let a=0;a<o.length;a++)for(let r=0;r<o[a].length;r++){const d=o[a][r];if((c=t.selected)!=null&&c.includes(d.cell)||l.selected.hasComponent(d.cell)){const v={x:r,y:a};n||(n=v),s=v}}return{grid:o,startPos:n,endPos:s}};function De(e,t={}){const o=B(e),{startPos:l,endPos:n}=o;let{grid:s}=o;const{em:c}=e;if(!l||!n)return;const a=l.x,r=l.y,d=n.x,v=n.y,h=R(s,a,r),f=R(s,d,v);if(h&&f){ae(s),s=se(e);const I=[],m=R(s,a,r).cell;m.addAttributes({colspan:d-a+1,rowspan:v-r+1});for(let w=r;w<=v;w++)for(let V=a;V<=d;V++){const M=R(s,V,w);if(!M)continue;const{cell:k}=M;k!==m&&I.push(k)}I.forEach(w=>{t.mergeContent&&m.append(w.components().models),w.remove()}),c.setSelected(m),ke(e)}}const re="Cell settings",Te="Merge cells",Se="Split cell",Le=e=>e.closestType(b),P=e=>{var t;return(t=Le(e))==null?void 0:t.parent()},Ee=e=>{const t=e.editor.getSelectedAll(),o=P(t[0]),l=t[0];if(!o||!(l!=null&&l.is(g))||t.length>1)return!1;const{rowspan:n,colspan:s}=L(l);return!(s<2&&n<2)},Ge=e=>{const o=e.editor.getSelectedAll()[0],l=P(o),{grid:n}=B(l);ae(n)},ce=e=>{const t=e.editor.getSelectedAll(),o=P(t[0]);if(!o||t.length<2||t.some(a=>!a.is(g)||P(a)!==o))return!1;const{grid:l,startPos:n,endPos:s}=B(o),{em:c}=o;if(!n||!s)return!1;for(let a=n.y;a<=s.y;a++)for(let r=n.x;r<=s.x;r++){const d=R(l,r,a);if(!d||!c.selected.hasComponent(d.cell))return!1}return!0},Ne=e=>{const{editor:t}=e;if(!ce(e))return;const o=t.getSelectedAll(),l=P(o[0]);De(l,{mergeContent:!0})},Oe=e=>{S(e,{id:"tableCellSettings",header:{label:re}})},Ze=e=>[{id:i.tableCellItems,icon:u[i.tableCellProperties],label:"Cell",items:[{id:i.tableCellProperties,label:re,icon:u[i.tableCellProperties],onClick:({event:o})=>Oe({...e,event:o})},{id:i.tableCellMerge,label:Te,icon:u[i.tableCellMerge],onClick:()=>Ne(e),disabled:!ce(e)},{id:i.tableCellSplit,label:Se,icon:u[i.tableCellSplit],onClick:()=>Ge(e),disabled:!Ee(e)}]},...Ae(e),...ne(e)],Fe=e=>{const t=e[0]&&P(e[0]);if(!t)return;const{grid:o,startPos:l,endPos:n}=B(t,{selected:e});if(!l||!n)return;const s=[];for(let c=l.y;c<=n.y;c++)for(let a=l.x;a<=n.x;a++){const r=R(o,a,c);r&&s.push(r.cell)}s.length&&t.em.setSelected(s,{fromCell:!0})};return be(function(e,t={}){const o={block:{},...t},{Components:l}=e,n={copyable:!1,emptyState:!0,highlightable:!1,stylable:["color","font-family","font-size","font-weight","line-height","text-align","vertical-align","background-color","border-width","border-style","border-color"]};l.addType(p,{block:o.block&&{label:"Table",media:u.table,category:"Extra",content:{type:p,style:{width:"100%"}},select:!0,...o.block},model:{defaults:{emptyState:!0,highlightable:!1,icon:u.table,stylable:["width","height","margin","font-family","font-size","font-weight","line-height","text-align","background","background-color","border-width","border-style","border-color"],traits:[{type:"number",min:0,name:"cellspacing",label:"Cell spacing"},{type:"number",min:0,name:"cellpadding",label:"Cell padding"},{id:"tableCaption",type:"checkbox",label:"Caption",setValue({component:c,value:a,emitUpdate:r}){const d=c.find("caption")[0];a?!d&&c.append({type:"text",tagName:"caption",components:{type:"textnode",content:"Caption"}}):d==null||d.remove(),r(),e.refresh({tools:!0})},getValue(c){return!!c.component.find("caption")[0]}}],components:Re(D,{rows:5}),contextMenu:({items:c,editor:a,component:r})=>[...W({editor:a,component:r,opts:o}),...c]}}}),l.addType(F,{model:{defaults:{icon:u.tableHead,...n}}}),l.addType(U,{model:{defaults:{icon:u.tableFoot,...n}}}),l.addType(D,{model:{defaults:{icon:u.tableRowProperties,...n}}}),l.addType(b,{model:{defaults:{icon:u.tableRowProperties,emptyState:!0,highlightable:!1,stylable:["height","text-align","border-width","border-style","border-color"],traits:[],contextMenu:({items:c,editor:a,component:r})=>[...ne({editor:a,component:r,opts:o}),...c]}}}),l.addType(g,{model:{defaults:{icon:u.tableCellProperties,emptyState:{styleOut:"height: 1px"},stylable:["width","height","padding","background","background-color","text-align","vertical-align","border-width","border-style","border-color"],traits:[{id:"tableCellType",type:"select",options:[{value:"td",name:"Cell"},{value:"th",name:"Header Cell"}],label:"Cell type",name:"tagName",changeProp:!0},{id:"tableCellScope",type:"select",options:[{value:!1,name:"None"},{value:"row",name:"Row"},{value:"col",name:"Column"},{value:"rowgroup",name:"Row group"},{value:"colgroup",name:"Column group"}],label:"Scope",name:"scope"}],contextMenu:({items:c,editor:a,component:r})=>[...Ze({editor:a,component:r,opts:o}),...c]}}});const s=z((c,a)=>{var h;const r=e.getSelectedAll(),d=!!((h=a==null?void 0:a.event)!=null&&h.shiftKey);if(r.length<2||!d||a.fromCell)return;const v=r.map(f=>f.is(g)?f:f.closestType(g)).filter(Boolean);v.length===r.length&&Fe(v)},0);e.on("component:select",s),pe({editor:e,plan:ye,pluginName:we,licenseKey:o.licenseKey,cleanup:()=>{e.off("component:select",s),e.Blocks.remove(p),Ce.forEach(c=>l.removeType(c))}})})});
|
package/dist/types.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ export { ToastVariant } from '@studio/editor/src/components/Toast/types';
|
|
|
3
3
|
export type { IToast } from '@studio/editor/src/components/Toast/types';
|
|
4
4
|
export type { CustomLayoutComponentsRegistry, StudioLayoutComponentsConfigProps, StudioLayoutComponentsConfig } from '@studio/editor/src/components/public/types';
|
|
5
5
|
export { StudioCommands, StudioEvents } from '@studio/editor/src/plugins/global/types';
|
|
6
|
-
export type { StudioCommandProjectFileOptions } from '@studio/editor/src/plugins/global/types';
|
|
6
|
+
export type { StudioCommandProjectFileOptions, StudioSdkSettings } from '@studio/editor/src/plugins/global/types';
|
|
7
7
|
export type { AssetProvider, InputAssetProps } from '@studio/editor/src/typeConfigs/assets';
|
|
8
8
|
export type { ProjectFile } from '@studio/editor/src/typeConfigs/project';
|
|
9
9
|
export type { FontAssetProps } from '@studio/editor/src/typeConfigs/fonts';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var g=(e=>(e.free="free",e.startup="startup",e.business="business",e.enterprise="enterprise",e))(g||{}),
|
|
1
|
+
"use strict";var g=(e=>(e.free="free",e.startup="startup",e.business="business",e.enterprise="enterprise",e))(g||{}),b=(e=>(e.toastAdd="studio:toastAdd",e.toastRemove="studio:toastRemove",e.dialogOpen="studio:dialogOpen",e.dialogClose="studio:dialogClose",e.dialogExportCode="studio:dialogExportCode",e.dialogImportCode="studio:dialogImportCode",e.sidebarLeftSet="studio:sidebarLeft:set",e.sidebarLeftGet="studio:sidebarLeft:get",e.sidebarLeftToggle="studio:sidebarLeft:toggle",e.sidebarRightSet="studio:sidebarRight:set",e.sidebarRightGet="studio:sidebarRight:get",e.sidebarRightToggle="studio:sidebarRight:toggle",e.sidebarTopSet="studio:sidebarTop:set",e.sidebarTopGet="studio:sidebarTop:get",e.sidebarTopToggle="studio:sidebarTop:toggle",e.sidebarBottomSet="studio:sidebarBottom:set",e.sidebarBottomGet="studio:sidebarBottom:get",e.sidebarBottomToggle="studio:sidebarBottom:toggle",e.symbolAdd="studio:symbolAdd",e.symbolDetach="studio:symbolDetach",e.symbolOverride="studio:symbolOverride",e.symbolPropagateStyles="studio:propagateStyles",e.getPagesConfig="studio:getPagesConfig",e.setPagesConfig="studio:setPagesConfig",e.getPageSettings="studio:getPageSettings",e.setPageSettings="studio:setPageSettings",e.clearPage="studio:clearPage",e.projectFiles="studio:projectFiles",e.validateCode="studio:validateCode",e.canvasReload="studio:canvasReload",e.getBlocksPanel="studio:getBlocksPanel",e.setBlocksPanel="studio:setBlocksPanel",e.getStateContextMenu="studio:getStateContextMenu",e.setStateContextMenu="studio:setStateContextMenu",e.contextMenuComponent="studio:contextMenuComponent",e.layoutAdd="studio:layoutAdd",e.layoutRemove="studio:layoutRemove",e.layoutToggle="studio:layoutToggle",e.layoutUpdate="studio:layoutUpdate",e.layoutGet="studio:layoutGet",e.layoutConfigGet="studio:layoutConfigGet",e.layoutConfigSet="studio:layoutConfigSet",e.layoutComponentAdd="studio:layoutComponentAdd",e.layoutComponentGet="studio:layoutComponentGet",e.layoutComponentRemove="studio:layoutComponentRemove",e.layoutComponentRender="studio:layoutComponentRender",e.getStateTheme="studio:getStateTheme",e.setStateTheme="studio:setStateTheme",e.settings="studio:settings",e.assetProviderGet="studio:assetProviderGet",e.assetProviderAdd="studio:assetProviderAdd",e.assetProviderRemove="studio:assetProviderRemove",e.fontGet="studio:fontGet",e.fontAdd="studio:fontAdd",e.fontRemove="studio:fontRemove",e.fontManagerOpen="studio:fontManagerOpen",e.menuFontLoad="studio:menuFontLoad",e.toggleStateDataSource="studio:toggleStateDataSource",e.getStateDataSource="studio:getStateDataSource",e.dataSourceSetGlobalData="studio:dataSourceSetGlobalData",e.dataSourceSetImporter="studio:dataSourceSetImporter",e.dataSourceSetExporter="studio:dataSourceSetExporter",e.setDragAbsolute="studio:setDragAbsolute",e))(b||{});const w="app.grapesjs.com",R="app-stage.grapesjs.com",x="app2.grapesjs.com",G="app-stage2.grapesjs.com",P=[w,x,R,G,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],U="license:check:end",D=()=>typeof window<"u",k=({isDev:e,isStage:o,isPlatform:a})=>`${e?"":`https://${o?R:w}`}/${a?"platform-api":"api"}`,O=()=>{const e=D()&&window.location.hostname;return!!e&&(P.includes(e)||P.some(o=>e.endsWith(o)))};async function $({path:e,baseApiUrl:o,method:a="GET",headers:r={},params:l,body:u}){const t=`${o||k({isDev:!1,isStage:!1})}${e}`,n={method:a,headers:{"Content-Type":"application/json",...r}};u&&(n.body=JSON.stringify(u));const c=l?new URLSearchParams(l).toString():"",i=c?`?${c}`:"",s=await fetch(`${t}${i}`,n);if(!s.ok)throw new Error(`HTTP error! status: ${s.status}`);return s.json()}const T={[g.free]:0,[g.startup]:10,[g.business]:20,[g.enterprise]:30};function E(e){const o=e;return o.init=a=>r=>e(r,a),o}const M=e=>E(e);async function j({editor:e,plan:o,pluginName:a,licenseKey:r,onLicenseCheckResponse:l,cleanup:u}){let p="",t;const n=s=>{console.warn("Cleanup plugin:",a,"Reason:",s),u()},c=(s={})=>{var v;const{error:h,sdkLicense:d}=s,y=(v=s.plan)==null?void 0:v.category;if(!(d||s.license)||h)n(h||"Invalid license");else if(y){const I=T[o],L=T[y];I>L&&n({pluginRequiredPlan:o,licensePlan:y})}};e.Commands.has(b.settings)&&(t=e.runCommand(b.settings),p=(t==null?void 0:t.baseUrl)||"");const i=s=>{l==null||l(s),s&&c(s)};if(!t){e.onReady(async()=>{if(!O())if(r){const s=await N({licenseKey:r,pluginName:a,baseApiUrl:p});i(s)}else n("The `licenseKey` option not provided")});return}if(t.licensePlan||t.licenseError){const s=B(t);i(s);return}e.on(U,s=>i(s))}const B=e=>({sdkLicense:e.license,license:e.license,error:e.licenseError,plan:e.licensePlan});async function N(e){const{licenseKey:o,pluginName:a,baseApiUrl:r}=e;try{return(await $({baseApiUrl:r,path:`/sdk/${o||"na"}`,method:"POST",params:{d:window.location.hostname,pn:a}})).result||{}}catch(l){return console.error("Error during SDK license check:",l),!1}}const Y=e=>{const o={};for(const a of Object.keys(e)){let r=e[a];r&&(Array.isArray(r)?r=r.map(l=>l.toString()).join(","):r=r.toString(),o[a]=r)}return new URLSearchParams(o)},A="youtube-video",W=e=>{const{apiKey:o,searchParams:a,thumbnailQuality:r="high"}=e,l=(t={})=>{const c="https://www.googleapis.com/youtube/v3/search",i=Y(t);return`${c}?${i}`},u=t=>{var n,c,i;return((n=t[r])==null?void 0:n.url)||((c=t.high)==null?void 0:c.url)||((i=t.medium)==null?void 0:i.url)||t.default.url},p=t=>{const n=u(t.snippet.thumbnails);return{id:t.id.videoId,src:`https://www.youtube.com/watch?v=${t.id.videoId}`,name:t.snippet.title,type:A,customData:{thumbnailUrl:n,videoItem:t}}};return{id:"youtube",types:[A],label:({editor:t})=>t.I18n.t("youtubeAssetProvider.providerLabel"),search:{reloadOnInput:!0,debounceMs:1e3},async onLoad({searchValue:t,pageCustomData:n}){var f;const c={maxResults:25,q:t,pageToken:n==null?void 0:n.token,type:["video"],key:o},i=a==null?void 0:a({searchValue:t}),s={...c,...i};s.part?s.part.includes("snippet")||s.part.push("snippet"):s.part=["snippet"];const d=await(await fetch(l(s))).json();return(f=d.items)!=null&&f.length?{items:d.items.map(p),nextPageCustomData:{token:d.nextPageToken},isLastPage:!d.nextPageToken}:{items:[],isLastPage:!0}},itemLayout:({assetProps:t,onSelect:n})=>({type:"column",onClick:()=>n(t),htmlAttrs:{title:t.name},style:{borderWidth:"1px",borderRadius:8,overflow:"hidden",cursor:"pointer"},children:[{type:"custom",render:()=>{var c;return`<img src="${(c=t.customData)==null?void 0:c.thumbnailUrl}" alt="${t.name}" style="width: 100%; height: 100px; object-fit: cover">`}},{type:"text",content:t.name,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",paddingLeft:8,paddingRight:8}}]})}},_={youtubeAssetProvider:{searchBtn:"Search on YouTube",modalTitle:"Select YouTube Video",providerLabel:"YouTube Videos"}},F="youtubeAssetProvider",K=g.startup,q=function(e,o){var c;const{skipVideoComponent:a,i18n:r={}}=o,l=W(o);e.runCommand(b.assetProviderAdd,{provider:l});const u="search-on-youtube",p="video",t=(c=e.Components.getType(p))==null?void 0:c.model.prototype,n=i=>{e.Assets.open({modalTitle:e.I18n.t("youtubeAssetProvider.modalTitle"),providerId:l.id,typeId:l.types[0],providers:[],types:[],select:s=>{e.Assets.close(),i.set({videoId:s.attributes.id})},content:{header:{addUrl:!1,upload:!1}}})};!a&&t&&e.Components.addType(p,{model:{getYoutubeTraits(){const[i,...s]=t.getYoutubeTraits.apply(this);return[i,{id:u,type:"button",label:e.I18n.t("youtubeAssetProvider.searchBtn"),command:()=>n(this)},...s]}},view:{events:()=>({dblclick:"onActive"}),onActive(){const{model:i}=this,s=i.get("provider")||"";s!=null&&s.startsWith("yt")&&n(i)}}}),e.I18n.addMessages({en:_,...r}),j({editor:e,licenseKey:o.licenseKey,plan:K,pluginName:F,cleanup:()=>{e.runCommand(b.assetProviderRemove,{id:l.id}),!a&&t&&e.Components.addType(p,{model:{getYoutubeTraits(){return t.getYoutubeTraits.apply(this).filter(i=>i.id!==u)}}})}})},V=M(q);module.exports=V;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
var g = /* @__PURE__ */ ((e) => (e.free = "free", e.startup = "startup", e.business = "business", e.enterprise = "enterprise", e))(g || {}),
|
|
2
|
-
const w = "app.grapesjs.com",
|
|
1
|
+
var g = /* @__PURE__ */ ((e) => (e.free = "free", e.startup = "startup", e.business = "business", e.enterprise = "enterprise", e))(g || {}), b = /* @__PURE__ */ ((e) => (e.toastAdd = "studio:toastAdd", e.toastRemove = "studio:toastRemove", e.dialogOpen = "studio:dialogOpen", e.dialogClose = "studio:dialogClose", e.dialogExportCode = "studio:dialogExportCode", e.dialogImportCode = "studio:dialogImportCode", e.sidebarLeftSet = "studio:sidebarLeft:set", e.sidebarLeftGet = "studio:sidebarLeft:get", e.sidebarLeftToggle = "studio:sidebarLeft:toggle", e.sidebarRightSet = "studio:sidebarRight:set", e.sidebarRightGet = "studio:sidebarRight:get", e.sidebarRightToggle = "studio:sidebarRight:toggle", e.sidebarTopSet = "studio:sidebarTop:set", e.sidebarTopGet = "studio:sidebarTop:get", e.sidebarTopToggle = "studio:sidebarTop:toggle", e.sidebarBottomSet = "studio:sidebarBottom:set", e.sidebarBottomGet = "studio:sidebarBottom:get", e.sidebarBottomToggle = "studio:sidebarBottom:toggle", e.symbolAdd = "studio:symbolAdd", e.symbolDetach = "studio:symbolDetach", e.symbolOverride = "studio:symbolOverride", e.symbolPropagateStyles = "studio:propagateStyles", e.getPagesConfig = "studio:getPagesConfig", e.setPagesConfig = "studio:setPagesConfig", e.getPageSettings = "studio:getPageSettings", e.setPageSettings = "studio:setPageSettings", e.clearPage = "studio:clearPage", e.projectFiles = "studio:projectFiles", e.validateCode = "studio:validateCode", e.canvasReload = "studio:canvasReload", e.getBlocksPanel = "studio:getBlocksPanel", e.setBlocksPanel = "studio:setBlocksPanel", e.getStateContextMenu = "studio:getStateContextMenu", e.setStateContextMenu = "studio:setStateContextMenu", e.contextMenuComponent = "studio:contextMenuComponent", e.layoutAdd = "studio:layoutAdd", e.layoutRemove = "studio:layoutRemove", e.layoutToggle = "studio:layoutToggle", e.layoutUpdate = "studio:layoutUpdate", e.layoutGet = "studio:layoutGet", e.layoutConfigGet = "studio:layoutConfigGet", e.layoutConfigSet = "studio:layoutConfigSet", e.layoutComponentAdd = "studio:layoutComponentAdd", e.layoutComponentGet = "studio:layoutComponentGet", e.layoutComponentRemove = "studio:layoutComponentRemove", e.layoutComponentRender = "studio:layoutComponentRender", e.getStateTheme = "studio:getStateTheme", e.setStateTheme = "studio:setStateTheme", e.settings = "studio:settings", e.assetProviderGet = "studio:assetProviderGet", e.assetProviderAdd = "studio:assetProviderAdd", e.assetProviderRemove = "studio:assetProviderRemove", e.fontGet = "studio:fontGet", e.fontAdd = "studio:fontAdd", e.fontRemove = "studio:fontRemove", e.fontManagerOpen = "studio:fontManagerOpen", e.menuFontLoad = "studio:menuFontLoad", e.toggleStateDataSource = "studio:toggleStateDataSource", e.getStateDataSource = "studio:getStateDataSource", e.dataSourceSetGlobalData = "studio:dataSourceSetGlobalData", e.dataSourceSetImporter = "studio:dataSourceSetImporter", e.dataSourceSetExporter = "studio:dataSourceSetExporter", e.setDragAbsolute = "studio:setDragAbsolute", e))(b || {});
|
|
2
|
+
const w = "app.grapesjs.com", R = "app-stage.grapesjs.com", x = "app2.grapesjs.com", G = "app-stage2.grapesjs.com", P = [
|
|
3
3
|
w,
|
|
4
|
+
x,
|
|
5
|
+
R,
|
|
4
6
|
G,
|
|
5
|
-
I,
|
|
6
|
-
L,
|
|
7
7
|
"localhost",
|
|
8
8
|
"127.0.0.1",
|
|
9
9
|
".local-credentialless.webcontainer.io",
|
|
@@ -12,34 +12,34 @@ const w = "app.grapesjs.com", I = "app-stage.grapesjs.com", G = "app2.grapesjs.c
|
|
|
12
12
|
// For stackblitz.com demos
|
|
13
13
|
"-sandpack.codesandbox.io"
|
|
14
14
|
// For Sandpack demos
|
|
15
|
-
], U = "license:check:
|
|
15
|
+
], U = "license:check:end", D = () => typeof window < "u", k = ({
|
|
16
16
|
isDev: e,
|
|
17
17
|
isStage: o,
|
|
18
18
|
isPlatform: i
|
|
19
|
-
}) => `${e ? "" : `https://${o ?
|
|
20
|
-
const e =
|
|
19
|
+
}) => `${e ? "" : `https://${o ? R : w}`}/${i ? "platform-api" : "api"}`, O = () => {
|
|
20
|
+
const e = D() && window.location.hostname;
|
|
21
21
|
return !!e && (P.includes(e) || P.some((o) => e.endsWith(o)));
|
|
22
22
|
};
|
|
23
|
-
async function
|
|
23
|
+
async function $({
|
|
24
24
|
path: e,
|
|
25
25
|
baseApiUrl: o,
|
|
26
26
|
method: i = "GET",
|
|
27
|
-
headers:
|
|
28
|
-
params:
|
|
27
|
+
headers: n = {},
|
|
28
|
+
params: l,
|
|
29
29
|
body: u
|
|
30
30
|
}) {
|
|
31
|
-
const
|
|
31
|
+
const t = `${o || k({ isDev: !1, isStage: !1 })}${e}`, r = {
|
|
32
32
|
method: i,
|
|
33
33
|
headers: {
|
|
34
34
|
"Content-Type": "application/json",
|
|
35
|
-
...
|
|
35
|
+
...n
|
|
36
36
|
}
|
|
37
37
|
};
|
|
38
|
-
u && (
|
|
39
|
-
const c =
|
|
40
|
-
if (!
|
|
41
|
-
throw new Error(`HTTP error! status: ${
|
|
42
|
-
return
|
|
38
|
+
u && (r.body = JSON.stringify(u));
|
|
39
|
+
const c = l ? new URLSearchParams(l).toString() : "", a = c ? `?${c}` : "", s = await fetch(`${t}${a}`, r);
|
|
40
|
+
if (!s.ok)
|
|
41
|
+
throw new Error(`HTTP error! status: ${s.status}`);
|
|
42
|
+
return s.json();
|
|
43
43
|
}
|
|
44
44
|
const T = {
|
|
45
45
|
[g.free]: 0,
|
|
@@ -47,52 +47,65 @@ const T = {
|
|
|
47
47
|
[g.business]: 20,
|
|
48
48
|
[g.enterprise]: 30
|
|
49
49
|
};
|
|
50
|
-
function
|
|
50
|
+
function E(e) {
|
|
51
51
|
const o = e;
|
|
52
|
-
return o.init = (i) => (
|
|
52
|
+
return o.init = (i) => (n) => e(n, i), o;
|
|
53
53
|
}
|
|
54
|
-
const
|
|
55
|
-
async function
|
|
54
|
+
const M = (e) => /* @__PURE__ */ E(e);
|
|
55
|
+
async function j({
|
|
56
56
|
editor: e,
|
|
57
57
|
plan: o,
|
|
58
58
|
pluginName: i,
|
|
59
|
-
licenseKey:
|
|
60
|
-
onLicenseCheckResponse:
|
|
59
|
+
licenseKey: n,
|
|
60
|
+
onLicenseCheckResponse: l,
|
|
61
61
|
cleanup: u
|
|
62
62
|
}) {
|
|
63
|
-
let
|
|
64
|
-
const
|
|
65
|
-
console.warn("Cleanup plugin:", i, "Reason:",
|
|
66
|
-
},
|
|
63
|
+
let p = "", t;
|
|
64
|
+
const r = (s) => {
|
|
65
|
+
console.warn("Cleanup plugin:", i, "Reason:", s), u();
|
|
66
|
+
}, c = (s = {}) => {
|
|
67
67
|
var v;
|
|
68
|
-
const { error:
|
|
69
|
-
if (!(
|
|
70
|
-
|
|
71
|
-
else if (
|
|
72
|
-
const
|
|
73
|
-
|
|
68
|
+
const { error: h, sdkLicense: d } = s, y = (v = s.plan) == null ? void 0 : v.category;
|
|
69
|
+
if (!(d || s.license) || h)
|
|
70
|
+
r(h || "Invalid license");
|
|
71
|
+
else if (y) {
|
|
72
|
+
const I = T[o], L = T[y];
|
|
73
|
+
I > L && r({ pluginRequiredPlan: o, licensePlan: y });
|
|
74
74
|
}
|
|
75
75
|
};
|
|
76
|
-
e.
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
if (
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
}
|
|
89
|
-
|
|
76
|
+
e.Commands.has(b.settings) && (t = e.runCommand(b.settings), p = (t == null ? void 0 : t.baseUrl) || "");
|
|
77
|
+
const a = (s) => {
|
|
78
|
+
l == null || l(s), s && c(s);
|
|
79
|
+
};
|
|
80
|
+
if (!t) {
|
|
81
|
+
e.onReady(async () => {
|
|
82
|
+
if (!O())
|
|
83
|
+
if (n) {
|
|
84
|
+
const s = await N({ licenseKey: n, pluginName: i, baseApiUrl: p });
|
|
85
|
+
a(s);
|
|
86
|
+
} else
|
|
87
|
+
r("The `licenseKey` option not provided");
|
|
88
|
+
});
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
if (t.licensePlan || t.licenseError) {
|
|
92
|
+
const s = B(t);
|
|
93
|
+
a(s);
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
e.on(U, (s) => a(s));
|
|
90
97
|
}
|
|
98
|
+
const B = (e) => ({
|
|
99
|
+
sdkLicense: e.license,
|
|
100
|
+
license: e.license,
|
|
101
|
+
error: e.licenseError,
|
|
102
|
+
plan: e.licensePlan
|
|
103
|
+
});
|
|
91
104
|
async function N(e) {
|
|
92
|
-
const { licenseKey: o, pluginName: i, baseApiUrl:
|
|
105
|
+
const { licenseKey: o, pluginName: i, baseApiUrl: n } = e;
|
|
93
106
|
try {
|
|
94
|
-
return (await
|
|
95
|
-
baseApiUrl:
|
|
107
|
+
return (await $({
|
|
108
|
+
baseApiUrl: n,
|
|
96
109
|
path: `/sdk/${o || "na"}`,
|
|
97
110
|
method: "POST",
|
|
98
111
|
params: {
|
|
@@ -100,64 +113,64 @@ async function N(e) {
|
|
|
100
113
|
pn: i
|
|
101
114
|
}
|
|
102
115
|
})).result || {};
|
|
103
|
-
} catch (
|
|
104
|
-
return console.error("Error during SDK license check:",
|
|
116
|
+
} catch (l) {
|
|
117
|
+
return console.error("Error during SDK license check:", l), !1;
|
|
105
118
|
}
|
|
106
119
|
}
|
|
107
|
-
const
|
|
120
|
+
const Y = (e) => {
|
|
108
121
|
const o = {};
|
|
109
122
|
for (const i of Object.keys(e)) {
|
|
110
|
-
let
|
|
111
|
-
|
|
123
|
+
let n = e[i];
|
|
124
|
+
n && (Array.isArray(n) ? n = n.map((l) => l.toString()).join(",") : n = n.toString(), o[i] = n);
|
|
112
125
|
}
|
|
113
126
|
return new URLSearchParams(o);
|
|
114
|
-
}, A = "youtube-video",
|
|
115
|
-
const { apiKey: o, searchParams: i, thumbnailQuality:
|
|
116
|
-
const c = "https://www.googleapis.com/youtube/v3/search",
|
|
117
|
-
return `${c}?${
|
|
118
|
-
}, u = (
|
|
119
|
-
var
|
|
120
|
-
return ((
|
|
121
|
-
},
|
|
122
|
-
const
|
|
127
|
+
}, A = "youtube-video", W = (e) => {
|
|
128
|
+
const { apiKey: o, searchParams: i, thumbnailQuality: n = "high" } = e, l = (t = {}) => {
|
|
129
|
+
const c = "https://www.googleapis.com/youtube/v3/search", a = Y(t);
|
|
130
|
+
return `${c}?${a}`;
|
|
131
|
+
}, u = (t) => {
|
|
132
|
+
var r, c, a;
|
|
133
|
+
return ((r = t[n]) == null ? void 0 : r.url) || ((c = t.high) == null ? void 0 : c.url) || ((a = t.medium) == null ? void 0 : a.url) || t.default.url;
|
|
134
|
+
}, p = (t) => {
|
|
135
|
+
const r = u(t.snippet.thumbnails);
|
|
123
136
|
return {
|
|
124
|
-
id:
|
|
125
|
-
src: `https://www.youtube.com/watch?v=${
|
|
126
|
-
name:
|
|
137
|
+
id: t.id.videoId,
|
|
138
|
+
src: `https://www.youtube.com/watch?v=${t.id.videoId}`,
|
|
139
|
+
name: t.snippet.title,
|
|
127
140
|
type: A,
|
|
128
|
-
customData: { thumbnailUrl:
|
|
141
|
+
customData: { thumbnailUrl: r, videoItem: t }
|
|
129
142
|
};
|
|
130
143
|
};
|
|
131
144
|
return {
|
|
132
145
|
id: "youtube",
|
|
133
146
|
types: [A],
|
|
134
|
-
label: ({ editor:
|
|
147
|
+
label: ({ editor: t }) => t.I18n.t("youtubeAssetProvider.providerLabel"),
|
|
135
148
|
search: { reloadOnInput: !0, debounceMs: 1e3 },
|
|
136
|
-
async onLoad({ searchValue:
|
|
149
|
+
async onLoad({ searchValue: t, pageCustomData: r }) {
|
|
137
150
|
var f;
|
|
138
151
|
const c = {
|
|
139
152
|
maxResults: 25,
|
|
140
|
-
q:
|
|
141
|
-
pageToken:
|
|
153
|
+
q: t,
|
|
154
|
+
pageToken: r == null ? void 0 : r.token,
|
|
142
155
|
type: ["video"],
|
|
143
156
|
key: o
|
|
144
|
-
},
|
|
157
|
+
}, a = i == null ? void 0 : i({ searchValue: t }), s = {
|
|
145
158
|
...c,
|
|
146
|
-
...
|
|
159
|
+
...a
|
|
147
160
|
};
|
|
148
|
-
|
|
149
|
-
const
|
|
150
|
-
return (f =
|
|
151
|
-
items:
|
|
152
|
-
nextPageCustomData: { token:
|
|
153
|
-
isLastPage: !
|
|
161
|
+
s.part ? s.part.includes("snippet") || s.part.push("snippet") : s.part = ["snippet"];
|
|
162
|
+
const d = await (await fetch(l(s))).json();
|
|
163
|
+
return (f = d.items) != null && f.length ? {
|
|
164
|
+
items: d.items.map(p),
|
|
165
|
+
nextPageCustomData: { token: d.nextPageToken },
|
|
166
|
+
isLastPage: !d.nextPageToken
|
|
154
167
|
} : { items: [], isLastPage: !0 };
|
|
155
168
|
},
|
|
156
|
-
itemLayout: ({ assetProps:
|
|
169
|
+
itemLayout: ({ assetProps: t, onSelect: r }) => ({
|
|
157
170
|
type: "column",
|
|
158
|
-
onClick: () =>
|
|
171
|
+
onClick: () => r(t),
|
|
159
172
|
htmlAttrs: {
|
|
160
|
-
title:
|
|
173
|
+
title: t.name
|
|
161
174
|
},
|
|
162
175
|
style: {
|
|
163
176
|
borderWidth: "1px",
|
|
@@ -170,12 +183,12 @@ const W = (e) => {
|
|
|
170
183
|
type: "custom",
|
|
171
184
|
render: () => {
|
|
172
185
|
var c;
|
|
173
|
-
return `<img src="${(c =
|
|
186
|
+
return `<img src="${(c = t.customData) == null ? void 0 : c.thumbnailUrl}" alt="${t.name}" style="width: 100%; height: 100px; object-fit: cover">`;
|
|
174
187
|
}
|
|
175
188
|
},
|
|
176
189
|
{
|
|
177
190
|
type: "text",
|
|
178
|
-
content:
|
|
191
|
+
content: t.name,
|
|
179
192
|
style: {
|
|
180
193
|
overflow: "hidden",
|
|
181
194
|
textOverflow: "ellipsis",
|
|
@@ -193,19 +206,19 @@ const W = (e) => {
|
|
|
193
206
|
modalTitle: "Select YouTube Video",
|
|
194
207
|
providerLabel: "YouTube Videos"
|
|
195
208
|
}
|
|
196
|
-
},
|
|
209
|
+
}, F = "youtubeAssetProvider", K = g.startup, q = function(e, o) {
|
|
197
210
|
var c;
|
|
198
|
-
const { skipVideoComponent: i, i18n:
|
|
199
|
-
e.runCommand(
|
|
200
|
-
const u = "search-on-youtube",
|
|
211
|
+
const { skipVideoComponent: i, i18n: n = {} } = o, l = W(o);
|
|
212
|
+
e.runCommand(b.assetProviderAdd, { provider: l });
|
|
213
|
+
const u = "search-on-youtube", p = "video", t = (c = e.Components.getType(p)) == null ? void 0 : c.model.prototype, r = (a) => {
|
|
201
214
|
e.Assets.open({
|
|
202
215
|
modalTitle: e.I18n.t("youtubeAssetProvider.modalTitle"),
|
|
203
|
-
providerId:
|
|
204
|
-
typeId:
|
|
216
|
+
providerId: l.id,
|
|
217
|
+
typeId: l.types[0],
|
|
205
218
|
providers: [],
|
|
206
219
|
types: [],
|
|
207
|
-
select: (
|
|
208
|
-
e.Assets.close(),
|
|
220
|
+
select: (s) => {
|
|
221
|
+
e.Assets.close(), a.set({ videoId: s.attributes.id });
|
|
209
222
|
},
|
|
210
223
|
content: {
|
|
211
224
|
header: {
|
|
@@ -215,19 +228,19 @@ const W = (e) => {
|
|
|
215
228
|
}
|
|
216
229
|
});
|
|
217
230
|
};
|
|
218
|
-
!i &&
|
|
231
|
+
!i && t && e.Components.addType(p, {
|
|
219
232
|
model: {
|
|
220
233
|
getYoutubeTraits() {
|
|
221
|
-
const [
|
|
234
|
+
const [a, ...s] = t.getYoutubeTraits.apply(this);
|
|
222
235
|
return [
|
|
223
|
-
|
|
236
|
+
a,
|
|
224
237
|
{
|
|
225
238
|
id: u,
|
|
226
239
|
type: "button",
|
|
227
240
|
label: e.I18n.t("youtubeAssetProvider.searchBtn"),
|
|
228
|
-
command: () =>
|
|
241
|
+
command: () => r(this)
|
|
229
242
|
},
|
|
230
|
-
...
|
|
243
|
+
...s
|
|
231
244
|
];
|
|
232
245
|
}
|
|
233
246
|
},
|
|
@@ -236,29 +249,29 @@ const W = (e) => {
|
|
|
236
249
|
dblclick: "onActive"
|
|
237
250
|
}),
|
|
238
251
|
onActive() {
|
|
239
|
-
const { model:
|
|
240
|
-
|
|
252
|
+
const { model: a } = this, s = a.get("provider") || "";
|
|
253
|
+
s != null && s.startsWith("yt") && r(a);
|
|
241
254
|
}
|
|
242
255
|
}
|
|
243
256
|
}), e.I18n.addMessages({
|
|
244
257
|
en: _,
|
|
245
|
-
...
|
|
246
|
-
}),
|
|
258
|
+
...n
|
|
259
|
+
}), j({
|
|
247
260
|
editor: e,
|
|
248
261
|
licenseKey: o.licenseKey,
|
|
249
|
-
plan:
|
|
250
|
-
pluginName:
|
|
262
|
+
plan: K,
|
|
263
|
+
pluginName: F,
|
|
251
264
|
cleanup: () => {
|
|
252
|
-
e.runCommand(
|
|
265
|
+
e.runCommand(b.assetProviderRemove, { id: l.id }), !i && t && e.Components.addType(p, {
|
|
253
266
|
model: {
|
|
254
267
|
getYoutubeTraits() {
|
|
255
|
-
return
|
|
268
|
+
return t.getYoutubeTraits.apply(this).filter((a) => a.id !== u);
|
|
256
269
|
}
|
|
257
270
|
}
|
|
258
271
|
});
|
|
259
272
|
}
|
|
260
273
|
});
|
|
261
|
-
},
|
|
274
|
+
}, V = M(q);
|
|
262
275
|
export {
|
|
263
|
-
|
|
276
|
+
V as default
|
|
264
277
|
};
|