@grapesjs/studio-sdk-plugins 1.0.38 → 1.0.39-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (158) hide show
  1. package/dist/accordionComponent/index.cjs.js +5 -5
  2. package/dist/accordionComponent/index.es.js +70 -67
  3. package/dist/accordionComponent/index.js +39 -0
  4. package/dist/accordionComponent/index.umd.js +4 -4
  5. package/dist/aiChat/components/AiChatHeader.d.ts +4 -5
  6. package/dist/aiChat/components/AiChatInput/index.d.ts +4 -5
  7. package/dist/aiChat/components/AiChatMessage.d.ts +7 -8
  8. package/dist/aiChat/components/index.d.ts +1 -1
  9. package/dist/aiChat/components/utils.d.ts +1 -1
  10. package/dist/aiChat/index.cjs.js +10 -376
  11. package/dist/aiChat/index.es.js +4569 -28851
  12. package/dist/aiChat/index.js +10 -376
  13. package/dist/aiChat/index.umd.js +11 -377
  14. package/dist/aiChat/server/index.cjs.d.ts +0 -1
  15. package/dist/aiChat/server/index.cjs.js +45 -45
  16. package/dist/aiChat/server/index.d.ts +0 -1
  17. package/dist/aiChat/server/index.es.d.ts +0 -1
  18. package/dist/aiChat/server/index.es.js +371 -427
  19. package/dist/aiChat/server/index.js +45 -45
  20. package/dist/aiChat/server/index.umd.js +41 -41
  21. package/dist/aiChat/server/stream.test.d.ts +1 -0
  22. package/dist/aiChat/types.d.ts +18 -4
  23. package/dist/aiChat/typesSchema.d.ts +13 -0
  24. package/dist/animationComponent/index.cjs.js +3 -3
  25. package/dist/animationComponent/index.es.js +49 -46
  26. package/dist/animationComponent/index.js +519 -0
  27. package/dist/animationComponent/index.umd.js +3 -3
  28. package/dist/canvasAbsoluteMode/index.cjs.js +1 -1
  29. package/dist/canvasAbsoluteMode/index.es.js +115 -112
  30. package/dist/canvasAbsoluteMode/index.js +1 -0
  31. package/dist/canvasAbsoluteMode/index.umd.js +1 -1
  32. package/dist/canvasEmptyState/index.cjs.js +1 -1
  33. package/dist/canvasEmptyState/index.es.js +71 -68
  34. package/dist/canvasEmptyState/index.js +1 -0
  35. package/dist/canvasEmptyState/index.umd.js +1 -1
  36. package/dist/canvasFullSize/index.cjs.js +3 -3
  37. package/dist/canvasFullSize/index.es.js +69 -66
  38. package/dist/canvasFullSize/index.js +10 -0
  39. package/dist/canvasFullSize/index.umd.js +4 -4
  40. package/dist/canvasGridMode/index.cjs.js +7 -7
  41. package/dist/canvasGridMode/index.es.js +142 -139
  42. package/dist/canvasGridMode/index.js +26 -0
  43. package/dist/canvasGridMode/index.umd.js +7 -7
  44. package/dist/canvasScreenshot/index.cjs.js +1 -1
  45. package/dist/canvasScreenshot/index.es.js +78 -75
  46. package/dist/canvasScreenshot/index.js +1 -0
  47. package/dist/canvasScreenshot/index.umd.js +1 -1
  48. package/dist/dataSourceEjs/EjsExporter.d.ts +1 -1
  49. package/dist/dataSourceEjs/index.cjs.js +3 -3
  50. package/dist/dataSourceEjs/index.es.js +40 -37
  51. package/dist/dataSourceEjs/index.js +21 -0
  52. package/dist/dataSourceEjs/index.umd.js +3 -3
  53. package/dist/dataSourceHandlebars/HandlebarsExporter.d.ts +2 -2
  54. package/dist/dataSourceHandlebars/constants.d.ts +1 -1
  55. package/dist/dataSourceHandlebars/index.cjs.js +4 -4
  56. package/dist/dataSourceHandlebars/index.es.js +58 -55
  57. package/dist/dataSourceHandlebars/index.js +10 -0
  58. package/dist/dataSourceHandlebars/index.umd.js +2 -2
  59. package/dist/dialogComponent/index.cjs.js +11 -11
  60. package/dist/dialogComponent/index.es.js +72 -69
  61. package/dist/dialogComponent/index.js +59 -0
  62. package/dist/dialogComponent/index.umd.js +11 -11
  63. package/dist/flexComponent/index.cjs.js +6 -6
  64. package/dist/flexComponent/index.es.js +151 -142
  65. package/dist/flexComponent/index.js +33 -0
  66. package/dist/flexComponent/index.umd.js +8 -8
  67. package/dist/flexComponent/typesSchema.d.ts +1 -1
  68. package/dist/fsLightboxComponent/index.cjs.js +3 -3
  69. package/dist/fsLightboxComponent/index.es.js +93 -90
  70. package/dist/fsLightboxComponent/index.js +6 -0
  71. package/dist/fsLightboxComponent/index.umd.js +3 -3
  72. package/dist/googleFontsAssetProvider/index.cjs.js +1 -1
  73. package/dist/googleFontsAssetProvider/index.es.js +112 -109
  74. package/dist/googleFontsAssetProvider/index.js +1 -0
  75. package/dist/googleFontsAssetProvider/index.umd.js +1 -1
  76. package/dist/googleFontsAssetProvider/utils.d.ts +1 -1
  77. package/dist/iconifyComponent/index.cjs.js +2 -2
  78. package/dist/iconifyComponent/index.es.js +80 -77
  79. package/dist/iconifyComponent/index.js +3 -0
  80. package/dist/iconifyComponent/index.umd.js +2 -2
  81. package/dist/index.cjs.d.ts +1 -0
  82. package/dist/index.cjs.js +970 -82
  83. package/dist/index.d.ts +1 -0
  84. package/dist/index.es.d.ts +1 -0
  85. package/dist/index.es.js +7422 -6145
  86. package/dist/index.umd.js +975 -87
  87. package/dist/layoutSidebarButtons/index.cjs.js +1 -1
  88. package/dist/layoutSidebarButtons/index.es.js +95 -92
  89. package/dist/layoutSidebarButtons/index.js +1 -0
  90. package/dist/layoutSidebarButtons/index.umd.js +1 -1
  91. package/dist/lightGalleryComponent/index.cjs.js +1 -1
  92. package/dist/lightGalleryComponent/index.es.js +164 -161
  93. package/dist/lightGalleryComponent/index.js +1 -0
  94. package/dist/lightGalleryComponent/index.umd.js +1 -1
  95. package/dist/lightGalleryComponent/utils.d.ts +1 -1
  96. package/dist/linkImageComponent/index.cjs.js +2 -2
  97. package/dist/linkImageComponent/index.es.js +60 -57
  98. package/dist/linkImageComponent/index.js +12 -0
  99. package/dist/linkImageComponent/index.umd.js +2 -2
  100. package/dist/listPagesComponent/index.cjs.js +4 -4
  101. package/dist/listPagesComponent/index.es.js +57 -54
  102. package/dist/listPagesComponent/index.js +11 -0
  103. package/dist/listPagesComponent/index.umd.js +4 -4
  104. package/dist/listPagesComponent/utils.d.ts +1 -1
  105. package/dist/presetBlockLibrary/blocks.d.ts +6 -0
  106. package/dist/presetBlockLibrary/blocks.test.d.ts +2 -0
  107. package/dist/presetBlockLibrary/emailBlocks.d.ts +53 -0
  108. package/dist/presetBlockLibrary/index.cjs.d.ts +3 -0
  109. package/dist/presetBlockLibrary/index.cjs.js +889 -0
  110. package/dist/presetBlockLibrary/index.d.ts +3 -0
  111. package/dist/presetBlockLibrary/index.es.d.ts +3 -0
  112. package/dist/presetBlockLibrary/index.es.js +1408 -0
  113. package/dist/presetBlockLibrary/index.js +889 -0
  114. package/dist/presetBlockLibrary/index.test.d.ts +1 -0
  115. package/dist/presetBlockLibrary/index.umd.js +889 -0
  116. package/dist/presetBlockLibrary/shared.d.ts +3 -0
  117. package/dist/presetBlockLibrary/types.d.ts +24 -0
  118. package/dist/presetBlockLibrary/typesSchema.d.ts +47 -0
  119. package/dist/presetPrintable/index.cjs.js +3 -3
  120. package/dist/presetPrintable/index.es.js +133 -130
  121. package/dist/presetPrintable/index.js +32 -0
  122. package/dist/presetPrintable/index.umd.js +4 -4
  123. package/dist/prosemirror/index.cjs.js +8 -8
  124. package/dist/prosemirror/index.es.js +552 -549
  125. package/dist/prosemirror/index.js +10 -0
  126. package/dist/prosemirror/index.umd.js +9 -9
  127. package/dist/prosemirror/toolbar.d.ts +2 -2
  128. package/dist/prosemirror/types.d.ts +5 -5
  129. package/dist/rendererReact/index.cjs.js +1 -1
  130. package/dist/rendererReact/index.es.js +137 -134
  131. package/dist/rendererReact/index.js +1 -1
  132. package/dist/rendererReact/index.umd.js +1 -1
  133. package/dist/rteTinyMce/index.cjs.js +2 -2
  134. package/dist/rteTinyMce/index.es.js +74 -71
  135. package/dist/rteTinyMce/index.js +104 -0
  136. package/dist/rteTinyMce/index.umd.js +2 -2
  137. package/dist/shapeDividerComponent/index.cjs.js +4 -4
  138. package/dist/shapeDividerComponent/index.es.js +91 -88
  139. package/dist/shapeDividerComponent/index.js +97 -0
  140. package/dist/shapeDividerComponent/index.umd.js +4 -4
  141. package/dist/swiperComponent/index.cjs.js +7 -7
  142. package/dist/swiperComponent/index.es.js +95 -92
  143. package/dist/swiperComponent/index.js +45 -0
  144. package/dist/swiperComponent/index.umd.js +5 -5
  145. package/dist/tableComponent/index.cjs.js +1 -1
  146. package/dist/tableComponent/index.es.js +181 -178
  147. package/dist/tableComponent/index.js +1 -0
  148. package/dist/tableComponent/index.umd.js +1 -1
  149. package/dist/tableComponent/types.d.ts +3 -3
  150. package/dist/types.d.ts +14 -14
  151. package/dist/utils.d.ts +3 -2
  152. package/dist/utilsDataSources.d.ts +1 -1
  153. package/dist/youtubeAssetProvider/index.cjs.js +1 -1
  154. package/dist/youtubeAssetProvider/index.es.js +90 -87
  155. package/dist/youtubeAssetProvider/index.js +1 -0
  156. package/dist/youtubeAssetProvider/index.umd.js +1 -1
  157. package/package.json +182 -34
  158. package/dist/aiChat/server/models.d.ts +0 -15
@@ -0,0 +1 @@
1
+ "use strict";function ie(e,t,o){let l,n,s,r,a;const c=t;function h(){const d=Date.now()-r;d<c&&d>=0?l=setTimeout(h,c-d):(l=null,a=e.apply(s,n),s=n=null)}const v=function(){return s=this,n=arguments,r=Date.now(),l||(l=setTimeout(h,c)),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 F="app.grapesjs.com",U="app-stage.grapesjs.com",he="app2.grapesjs.com",de="app-stage2.grapesjs.com",E=[F,he,U,de,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io",".claudemcpcontent.com",".web-sandbox.oaiusercontent.com"],ve="license:check:end",ue=()=>typeof window<"u",ge=({isDev:e,isStage:t,isPlatform:o})=>`${e?"":`https://${t?U:F}`}/${o?"platform-api":"api"}`,pe=()=>{if(!ue())return"";const{hostname:e}=window.location;if(e)return e;try{return window.parent.location.hostname||""}catch{return""}},be=()=>{const e=pe();return!!e&&(E.includes(e)||E.some(t=>e.endsWith(t)))};function $(e){return typeof e=="function"}async function fe({path:e,baseApiUrl:t,method:o="GET",headers:l={},params:n,body:s}){const a=`${t||ge({isDev:!1,isStage:!1})}${e}`,c={method:o,headers:{"Content-Type":"application/json",...l}};s&&(c.body=JSON.stringify(s));const h=n?new URLSearchParams(n).toString():"",v=h?`?${h}`:"",d=await fetch(`${a}${v}`,c);if(!d.ok)throw new Error(`HTTP error! status: ${d.status}`);return d.json()}var C=(e=>(e.free="free",e.startup="startup",e.business="business",e.enterprise="enterprise",e))(C||{}),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.openEditCode="studio:openEditCode",e.openBlocks="studio:openBlocks",e.appendComponent="studio:appendComponent",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 S={[C.free]:0,[C.startup]:10,[C.business]:20,[C.enterprise]:30};function me(e,t){const o=e;return o.init=l=>{const n=s=>e(s,l);return n.__gjsPluginId=t,n},o}const we=(e,t)=>me(e,t);async function ye({editor:e,plan:t,pluginName:o,licenseKey:l,onLicenseCheckResponse:n,cleanup:s}){let r="",a;const c=d=>{console.warn("Cleanup plugin:",o,"Reason:",d),s(e,o)},h=(d={})=>{var y;const{error:b,sdkLicense:V}=d,m=(y=d.plan)==null?void 0:y.category;if(!(V||d.license)||b)c(b||"Invalid license");else if(m){const z=S[t],A=S[m];z>A&&c({pluginRequiredPlan:t,licensePlan:m})}};e.Commands.has(B.settings)&&(a=e.runCommand(B.settings),r=(a==null?void 0:a.baseUrl)||"");const v=d=>{n==null||n(d),d&&h(d)};if(!a){e.onReady(async()=>{if(!be())if(l){const d=await He({licenseKey:l,pluginName:o,baseApiUrl:r});v(d)}else c("The `licenseKey` option not provided")});return}if(a.licensePlan||a.licenseError){const d=Ce(a);v(d);return}e.on(ve,d=>v(d))}const Ce=e=>({sdkLicense:e.license,license:e.license,error:e.licenseError,plan:e.licensePlan});async function He(e){const{licenseKey:t,pluginName:o,baseApiUrl:l}=e;try{return(await fe({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 _="tableComponent",Re=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>'},f="table",W="thead",j="tfoot",M="tbody",p="row",g="cell",D="clipboardTable",Pe=[f,W,j,M,p,g],x=e=>e.em.get(D)||[],Ve=e=>e.every(t=>t.is(g)),T=(e,t)=>{const{editor:o,event:l,opts:n}=e,s=l.currentTarget||l.target,{x:r,y:a,width:c,height:h}=s.getBoundingClientRect(),v={style:{width:240,height:300},placer:{type:"popover",closeOnClickAway:!0,x:r,y:a,w:c,h},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.openSettings)?n.openSettings({...e,layoutProps:v}):o.runCommand(B.layoutToggle,v)},ze=(e,{rows:t=1,cells:o=5,text:l}={})=>({type:e,components:Array.from(Array(t).keys()).map(n=>({type:p,components:Array.from(Array(o).keys()).map(s=>({type:g,components:l?{type:"text",content:$(l)?l({y:n,x:s}):l}:void 0}))}))}),K="Table settings",q=e=>{const{component:t}=e;return t.is(f)?t:t.closestType(f)},Ae=e=>{var t;(t=q(e))==null||t.remove(e.opts)},Be=e=>{const t=q(e);t&&(e.editor.select(t),T(e,{id:"tableSettings",header:{label:K}}))},X=e=>[{id:i.table,icon:u[i.table],label:"Table",items:[{id:i.tableSettings,label:K,icon:u[i.tableSettings],onClick:({event:o})=>Be({...e,event:o})},{id:i.tableDelete,label:"Delete table",icon:u[i.tableDelete],onClick:()=>Ae(e)}]}],Y=({editor:e})=>{const t=x(e);return t.length&&Ve(t)},G=({component:e,editor:t,after:o})=>{if(!e.is(g))return;const l=e.closestType(f),n=e.closestType(p),s=e.index()+(o?1:0);l==null||l.findType(p).forEach(a=>a.append({type:g},{at:s}));const r=n==null?void 0:n.components().at(s);r&&t.select(r)},J=({component:e,opts:t})=>{if(!e.is(g))return;const o=e.closestType(f),l=e.index();o==null||o.findType(p).forEach(n=>{var s;return(s=n.components().at(l))==null?void 0:s.remove(t)})},Q=({component:e,editor:t})=>{if(!e.is(g))return;const o=e.closestType(f),l=e.index(),n=(o==null?void 0:o.findType(p).map(s=>s.components().at(l)))||[];n.length&&t.em.set(D,n)},Z=e=>{const{component:t,editor:o,after:l}=e;if(!t.is(g)||!Y(e))return;const n=x(o),s=t.closestType(f),r=t.index()+(l?1:0);s==null||s.findType(p).forEach((a,c)=>{const h=n[c],v=(h==null?void 0:h.clone())||{type:g};a.append(v,{at:r})})},xe=e=>{const{component:t}=e;t.is(g)&&(Q(e),J({...e,opts:{temporary:!0}}))},Ie=e=>{const t=Y(e);return[{id:i.tableColumnItems,icon:u[i.tableColumn],label:"Column",items:[{id:i.tableColumnInsertBefore,label:"Insert column before",icon:u[i.tableColumnInsertBefore],onClick:()=>G(e)},{id:i.tableColumnInsertAfter,label:"Insert column after",icon:u[i.tableColumnInsertAfter],onClick:()=>G({...e,after:!0})},{id:i.tableColumnDelete,label:"Delete column",icon:u[i.tableColumnDelete],onClick:()=>J(e)},{id:i.tableColumnCut,label:"Cut column",icon:u[i.tableColumnCut],onClick:()=>xe(e)},{id:i.tableColumnCopy,label:"Copy column",icon:u[i.tableColumnCopy],onClick:()=>Q(e)},{id:i.tableColumnPasteBefore,label:"Paste column before",icon:u[i.tableColumnPasteBefore],disabled:!t,onClick:()=>Z(e)},{id:i.tableColumnPasteAfter,label:"Paste column after",icon:u[i.tableColumnPasteAfter],disabled:!t,onClick:()=>Z({...e,after:!0})}]}]},ee="Row settings",Me=e=>e.every(t=>t.is(p)),P=e=>{const{component:t}=e,o=t.is(g),l=t.is(p);if(!(!o&&!l))return l?t:t.closestType(p)},N=e=>{const{component:t,editor:o,after:l}=e,n=P(e);if(!n)return;const s=n.index()+(l?1:0),r=n.components().length,a=Array.from(Array(r).keys()).map(()=>({type:g})),c=n.parent();if(c){const h=c.append({type:p,components:a},{at:s})[0];if(t.is(g)&&h){const v=t.index(),d=h.components().at(v);d&&o.select(d)}}},te=e=>{var t;(t=P(e))==null||t.remove(e.opts)},le=e=>{const t=P(e);t&&e.editor.em.set(D,[t])},O=e=>{var a;const{editor:t,after:o}=e,l=P(e);if(!l||!oe(e))return;const s=x(t)[0],r=l.index()+(o?1:0);s&&((a=l.parent())==null||a.append(s.clone(),{at:r}))},ke=e=>{P(e)&&(le(e),te({...e,opts:{temporary:!0}}))},oe=({editor:e})=>{const t=x(e);return t.length&&Me(t)},De=e=>{const t=P(e);t&&(e.editor.select(t),T(e,{id:"tableRowSettings",header:{label:ee}}))},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:()=>N(e)},{id:i.tableRowInsertAfter,label:"Insert row after",icon:u[i.tableRowInsertAfter],onClick:()=>N({...e,after:!0})},{id:i.tableRowDelete,label:"Delete row",icon:u[i.tableRowDelete],onClick:()=>te(e)},{id:i.tableRowProperties,label:ee,icon:u[i.tableRowProperties],onClick:({event:l})=>De({...e,event:l})},{id:i.tableRowCut,label:"Cut row",icon:u[i.tableRowCut],onClick:()=>ke(e)},{id:i.tableRowCopy,label:"Copy row",icon:u[i.tableRowCopy],onClick:()=>le(e)},{id:i.tableRowPasteBefore,label:"Paste row before",icon:u[i.tableRowPasteBefore],disabled:!t,onClick:()=>O(e)},{id:i.tableRowPasteAfter,label:"Paste row after",icon:u[i.tableRowPasteAfter],disabled:!t,onClick:()=>O({...e,after:!0})}]},...X(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:r,colspan:a}=L(n);if(t[l])for(;t[l][s];)s++;for(let c=l;c<l+r;c++){t[c]||(t[c]=[]);for(let h=s;h<s+a;h++)t[c][h]={real:c===l&&h===s,cell:n,rowspan:r,colspan:a}}})}),t}function H(e,t,o){var l;return(l=e[o])==null?void 0:l[t]}const k=e=>e.closestType(p);function Te(e,{x:t,y:o,rows:l,cols:n}){var a;let s=k(e[o][t].cell),r;for(let c=1;c<=l;c++)if(s=(a=s==null?void 0:s.parent())==null?void 0:a.components().at(s.index()+1),s){for(r=t;r>=0;r--){const{cell:h}=e[o+c][r],v=k(h);if(v===s){for(let d=1;d<=n;d++){const b=h.index();v.append({type:g},{at:b+1})}break}}if(r===-1){const v=s.components().at(0).index();for(let d=1;d<=n;d++)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:r}=L(n);if(r>1||s>1){n.addAttributes({colspan:1,rowspan:1});for(let a=0;a<r-1;a++){const c=n.index();k(n).append({type:g},{at:c+1})}Te(e,{x:o,y:t,rows:s-1,cols:r})}}}}function Le(e){const t=[];e.components().forEach(o=>{o.components().length||t.push(o)}),t.forEach(o=>o.remove())}const I=(e,t={})=>{var r;const o=se(e),{em:l}=e;let n,s;for(let a=0;a<o.length;a++)for(let c=0;c<o[a].length;c++){const h=o[a][c];if((r=t.selected)!=null&&r.includes(h.cell)||l.selected.hasComponent(h.cell)){const v={x:c,y:a};n||(n=v),s=v}}return{grid:o,startPos:n,endPos:s}};function Ee(e,t={}){const o=I(e),{startPos:l,endPos:n}=o;let{grid:s}=o;const{em:r}=e;if(!l||!n)return;const a=l.x,c=l.y,h=n.x,v=n.y,d=H(s,a,c),b=H(s,h,v);if(d&&b){ae(s),s=se(e);const V=[],m=H(s,a,c).cell;m.addAttributes({colspan:h-a+1,rowspan:v-c+1});for(let w=c;w<=v;w++)for(let y=a;y<=h;y++){const z=H(s,y,w);if(!z)continue;const{cell:A}=z;A!==m&&V.push(A)}V.forEach(w=>{t.mergeContent&&m.append(w.components().models),w.remove()}),r.setSelected(m),Le(e)}}const ce="Cell settings",Se="Merge cells",Ge="Split cell",Ze=e=>e.closestType(p),R=e=>{var t;return(t=Ze(e))==null?void 0:t.parent()},Ne=e=>{const t=e.editor.getSelectedAll(),o=R(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)},Oe=e=>{const o=e.editor.getSelectedAll()[0],l=R(o),{grid:n}=I(l);ae(n)},re=e=>{const t=e.editor.getSelectedAll(),o=R(t[0]);if(!o||t.length<2||t.some(a=>!a.is(g)||R(a)!==o))return!1;const{grid:l,startPos:n,endPos:s}=I(o),{em:r}=o;if(!n||!s)return!1;for(let a=n.y;a<=s.y;a++)for(let c=n.x;c<=s.x;c++){const h=H(l,c,a);if(!h||!r.selected.hasComponent(h.cell))return!1}return!0},Fe=e=>{const{editor:t}=e;if(!re(e))return;const o=t.getSelectedAll(),l=R(o[0]);Ee(l,{mergeContent:!0})},Ue=e=>{T(e,{id:"tableCellSettings",header:{label:ce}})},$e=e=>[{id:i.tableCellItems,icon:u[i.tableCellProperties],label:"Cell",items:[{id:i.tableCellProperties,label:ce,icon:u[i.tableCellProperties],onClick:({event:o})=>Ue({...e,event:o})},{id:i.tableCellMerge,label:Se,icon:u[i.tableCellMerge],onClick:()=>Fe(e),disabled:!re(e)},{id:i.tableCellSplit,label:Ge,icon:u[i.tableCellSplit],onClick:()=>Oe(e),disabled:!Ne(e)}]},...Ie(e),...ne(e)],_e=e=>{const t=e[0]&&R(e[0]);if(!t)return;const{grid:o,startPos:l,endPos:n}=I(t,{selected:e});if(!l||!n)return;const s=[];for(let r=l.y;r<=n.y;r++)for(let a=l.x;a<=n.x;a++){const c=H(o,a,r);c&&s.push(c.cell)}s.length&&t.em.setSelected(s,{fromCell:!0})},We=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(f,{block:o.block&&{label:"Table",media:u.table,category:"Extra",content:{type:f,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:r,value:a,emitUpdate:c}){const h=r.find("caption")[0];a?!h&&r.append({type:"text",tagName:"caption",components:{type:"textnode",content:"Caption"}}):h==null||h.remove(),c(),e.refresh({tools:!0})},getValue(r){return!!r.component.find("caption")[0]}}],components:ze(M,{rows:5}),contextMenu:({items:r,editor:a,component:c})=>[...X({editor:a,component:c,opts:o}),...r]}}}),l.addType(W,{model:{defaults:{icon:u.tableHead,...n}}}),l.addType(j,{model:{defaults:{icon:u.tableFoot,...n}}}),l.addType(M,{model:{defaults:{icon:u.tableRowProperties,...n}}}),l.addType(p,{model:{defaults:{icon:u.tableRowProperties,emptyState:!0,highlightable:!1,stylable:["height","text-align","border-width","border-style","border-color"],traits:[],contextMenu:({items:r,editor:a,component:c})=>[...ne({editor:a,component:c,opts:o}),...r]}}}),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:r,editor:a,component:c})=>[...$e({editor:a,component:c,opts:o}),...r]}}});const s=ie((r,a)=>{var d;const c=e.getSelectedAll(),h=!!((d=a==null?void 0:a.event)!=null&&d.shiftKey);if(c.length<2||!h||a.fromCell)return;const v=c.map(b=>b.is(g)?b:b.closestType(g)).filter(Boolean);v.length===c.length&&_e(v)},0);e.on("component:select",s),ye({editor:e,plan:Re,pluginName:_,licenseKey:o.licenseKey,cleanup:()=>{e.off("component:select",s),e.Blocks.remove(f),Pe.forEach(r=>l.removeType(r))}})},je=we(We,_);module.exports=je;
@@ -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 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",".claudemcpcontent.com",".web-sandbox.oaiusercontent.com"],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=()=>{if(!de())return"";const{hostname:e}=window.location;if(e)return e;try{return window.parent.location.hostname||""}catch{return""}},ve=()=>{const e=ue();return!!e&&(N.includes(e)||N.some(t=>e.endsWith(t)))};function O(e){return typeof e=="function"}async function ge({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.openEditCode="studio:openEditCode",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 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;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(!ve())if(l){const h=await we({licenseKey:l,pluginName:o,baseApiUrl:c});v(h)}else r("The `licenseKey` option not provided")});return}if(a.licensePlan||a.licenseError){const h=me(a);v(h);return}e.on(ie,h=>v(h))}const me=e=>({sdkLicense:e.license,license:e.license,error:e.licenseError,plan:e.licensePlan});async function we(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 ye="tableComponent",Ce=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",He=[p,F,U,D,b,g],x=e=>e.em.get(T)||[],Re=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)},Pe=(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)},Ve=e=>{var t;(t=_(e))==null||t.remove(e.opts)},ze=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})=>ze({...e,event:o})},{id:i.tableDelete,label:"Delete table",icon:u[i.tableDelete],onClick:()=>Ve(e)}]}],j=({editor:e})=>{const t=x(e);return t.length&&Re(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})})},Ae=e=>{const{component:t}=e;t.is(g)&&(X(e),q({...e,opts:{temporary:!0}}))},xe=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:()=>Ae(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",Be=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}))},Ie=e=>{H(e)&&(te(e),ee({...e,opts:{temporary:!0}}))},oe=({editor:e})=>{const t=x(e);return t.length&&Be(t)},Me=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})=>Me({...e,event:l})},{id:i.tableRowCut,label:"Cut row",icon:u[i.tableRowCut],onClick:()=>Ie(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)]},E=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}=E(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 L=e=>e.closestType(b);function ke(e,{x:t,y:o,rows:l,cols:n}){var a;let s=L(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=L(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}=E(n);if(c>1||s>1){n.addAttributes({colspan:1,rowspan:1});for(let a=0;a<c-1;a++){const r=n.index();L(n).append({type:g},{at:r+1})}ke(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 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 Te(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),De(e)}}const re="Cell settings",Se="Merge cells",Ee="Split cell",Le=e=>e.closestType(b),P=e=>{var t;return(t=Le(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}=E(l);return!(s<2&&n<2)},Ne=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},Oe=e=>{const{editor:t}=e;if(!ce(e))return;const o=t.getSelectedAll(),l=P(o[0]);Te(l,{mergeContent:!0})},Ze=e=>{S(e,{id:"tableCellSettings",header:{label:re}})},Fe=e=>[{id:i.tableCellItems,icon:u[i.tableCellProperties],label:"Cell",items:[{id:i.tableCellProperties,label:re,icon:u[i.tableCellProperties],onClick:({event:o})=>Ze({...e,event:o})},{id:i.tableCellMerge,label:Se,icon:u[i.tableCellMerge],onClick:()=>Oe(e),disabled:!ce(e)},{id:i.tableCellSplit,label:Ee,icon:u[i.tableCellSplit],onClick:()=>Ne(e),disabled:!Ge(e)}]},...xe(e),...ne(e)],Ue=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 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: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:Pe(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})=>[...Fe({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&&Ue(v)},0);e.on("component:select",s),fe({editor:e,plan:Ce,pluginName:ye,licenseKey:o.licenseKey,cleanup:()=>{e.off("component:select",s),e.Blocks.remove(p),He.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,r,a;const c=t;function d(){const h=Date.now()-r;h<c&&h>=0?l=setTimeout(d,c-h):(l=null,a=e.apply(s,n),s=n=null)}const v=function(){return s=this,n=arguments,r=Date.now(),l||(l=setTimeout(d,c)),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",O=[y,"app2.grapesjs.com",G,"app-stage2.grapesjs.com","localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io",".claudemcpcontent.com",".web-sandbox.oaiusercontent.com"],de="license:check:end",he=()=>typeof window<"u",ue=({isDev:e,isStage:t,isPlatform:o})=>`${e?"":`https://${t?G:y}`}/${o?"platform-api":"api"}`,ve=()=>{if(!he())return"";const{hostname:e}=window.location;if(e)return e;try{return window.parent.location.hostname||""}catch{return""}},pe=()=>{const e=ve();return!!e&&(O.includes(e)||O.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||ue({isDev:!1,isStage:!1})}${e}`,c={method:o,headers:{"Content-Type":"application/json",...l}};s&&(c.body=JSON.stringify(s));const d=n?new URLSearchParams(n).toString():"",v=d?`?${d}`:"",h=await fetch(`${a}${v}`,c);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.openEditCode="studio:openEditCode",e.openBlocks="studio:openBlocks",e.appendComponent="studio:appendComponent",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 be(e,t){const o=e;return o.init=l=>{const n=s=>e(s,l);return n.__gjsPluginId=t,n},o}const fe=(e,t)=>be(e,t);async function me({editor:e,plan:t,pluginName:o,licenseKey:l,onLicenseCheckResponse:n,cleanup:s}){let r="",a;const c=h=>{console.warn("Cleanup plugin:",o,"Reason:",h),s(e,o)},d=(h={})=>{var V;const{error:f,sdkLicense:I}=h,m=(V=h.plan)==null?void 0:V.category;if(!(I||h.license)||f)c(f||"Invalid license");else if(m){const M=Z[t],k=Z[m];M>k&&c({pluginRequiredPlan:t,licensePlan:m})}};e.Commands.has(A.settings)&&(a=e.runCommand(A.settings),r=(a==null?void 0:a.baseUrl)||"");const v=h=>{n==null||n(h),h&&d(h)};if(!a){e.onReady(async()=>{if(!pe())if(l){const h=await ye({licenseKey:l,pluginName:o,baseApiUrl:r});v(h)}else c("The `licenseKey` option not provided")});return}if(a.licensePlan||a.licenseError){const h=we(a);v(h);return}e.on(de,h=>v(h))}const we=e=>({sdkLicense:e.license,license:e.license,error:e.licenseError,plan:e.licensePlan});async function ye(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 F="tableComponent",Ce=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>'},b="table",_="thead",U="tfoot",D="tbody",g="row",p="cell",T="clipboardTable",He=[b,_,U,D,g,p],x=e=>e.em.get(T)||[],Re=e=>e.every(t=>t.is(p)),E=(e,t)=>{const{editor:o,event:l,opts:n}=e,s=l.currentTarget||l.target,{x:r,y:a,width:c,height:d}=s.getBoundingClientRect(),v={style:{width:240,height:300},placer:{type:"popover",closeOnClickAway:!0,x:r,y:a,w:c,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:v}):o.runCommand(A.layoutToggle,v)},Pe=(e,{rows:t=1,cells:o=5,text:l}={})=>({type:e,components:Array.from(Array(t).keys()).map(n=>({type:g,components:Array.from(Array(o).keys()).map(s=>({type:p,components:l?{type:"text",content:N(l)?l({y:n,x:s}):l}:void 0}))}))}),$="Table settings",j=e=>{const{component:t}=e;return t.is(b)?t:t.closestType(b)},Ve=e=>{var t;(t=j(e))==null||t.remove(e.opts)},ze=e=>{const t=j(e);t&&(e.editor.select(t),E(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})=>ze({...e,event:o})},{id:i.tableDelete,label:"Delete table",icon:u[i.tableDelete],onClick:()=>Ve(e)}]}],K=({editor:e})=>{const t=x(e);return t.length&&Re(t)},q=({component:e,editor:t,after:o})=>{if(!e.is(p))return;const l=e.closestType(b),n=e.closestType(g),s=e.index()+(o?1:0);l==null||l.findType(g).forEach(a=>a.append({type:p},{at:s}));const r=n==null?void 0:n.components().at(s);r&&t.select(r)},X=({component:e,opts:t})=>{if(!e.is(p))return;const o=e.closestType(b),l=e.index();o==null||o.findType(g).forEach(n=>{var s;return(s=n.components().at(l))==null?void 0:s.remove(t)})},Y=({component:e,editor:t})=>{if(!e.is(p))return;const o=e.closestType(b),l=e.index(),n=(o==null?void 0:o.findType(g).map(s=>s.components().at(l)))||[];n.length&&t.em.set(T,n)},J=e=>{const{component:t,editor:o,after:l}=e;if(!t.is(p)||!K(e))return;const n=x(o),s=t.closestType(b),r=t.index()+(l?1:0);s==null||s.findType(g).forEach((a,c)=>{const d=n[c],v=(d==null?void 0:d.clone())||{type:p};a.append(v,{at:r})})},Ae=e=>{const{component:t}=e;t.is(p)&&(Y(e),X({...e,opts:{temporary:!0}}))},xe=e=>{const t=K(e);return[{id:i.tableColumnItems,icon:u[i.tableColumn],label:"Column",items:[{id:i.tableColumnInsertBefore,label:"Insert column before",icon:u[i.tableColumnInsertBefore],onClick:()=>q(e)},{id:i.tableColumnInsertAfter,label:"Insert column after",icon:u[i.tableColumnInsertAfter],onClick:()=>q({...e,after:!0})},{id:i.tableColumnDelete,label:"Delete column",icon:u[i.tableColumnDelete],onClick:()=>X(e)},{id:i.tableColumnCut,label:"Cut column",icon:u[i.tableColumnCut],onClick:()=>Ae(e)},{id:i.tableColumnCopy,label:"Copy column",icon:u[i.tableColumnCopy],onClick:()=>Y(e)},{id:i.tableColumnPasteBefore,label:"Paste column before",icon:u[i.tableColumnPasteBefore],disabled:!t,onClick:()=>J(e)},{id:i.tableColumnPasteAfter,label:"Paste column after",icon:u[i.tableColumnPasteAfter],disabled:!t,onClick:()=>J({...e,after:!0})}]}]},Q="Row settings",Be=e=>e.every(t=>t.is(g)),H=e=>{const{component:t}=e,o=t.is(p),l=t.is(g);if(!(!o&&!l))return l?t:t.closestType(g)},ee=e=>{const{component:t,editor:o,after:l}=e,n=H(e);if(!n)return;const s=n.index()+(l?1:0),r=n.components().length,a=Array.from(Array(r).keys()).map(()=>({type:p})),c=n.parent();if(c){const d=c.append({type:g,components:a},{at:s})[0];if(t.is(p)&&d){const v=t.index(),h=d.components().at(v);h&&o.select(h)}}},te=e=>{var t;(t=H(e))==null||t.remove(e.opts)},le=e=>{const t=H(e);t&&e.editor.em.set(T,[t])},oe=e=>{var a;const{editor:t,after:o}=e,l=H(e);if(!l||!ne(e))return;const s=x(t)[0],r=l.index()+(o?1:0);s&&((a=l.parent())==null||a.append(s.clone(),{at:r}))},Ie=e=>{H(e)&&(le(e),te({...e,opts:{temporary:!0}}))},ne=({editor:e})=>{const t=x(e);return t.length&&Be(t)},Me=e=>{const t=H(e);t&&(e.editor.select(t),E(e,{id:"tableRowSettings",header:{label:Q}}))},se=e=>{const t=ne(e);return[{id:i.tableRowItems,icon:u[i.tableRowProperties],label:"Row",items:[{id:i.tableRowInsertBefore,label:"Insert row before",icon:u[i.tableRowInsertBefore],onClick:()=>ee(e)},{id:i.tableRowInsertAfter,label:"Insert row after",icon:u[i.tableRowInsertAfter],onClick:()=>ee({...e,after:!0})},{id:i.tableRowDelete,label:"Delete row",icon:u[i.tableRowDelete],onClick:()=>te(e)},{id:i.tableRowProperties,label:Q,icon:u[i.tableRowProperties],onClick:({event:l})=>Me({...e,event:l})},{id:i.tableRowCut,label:"Cut row",icon:u[i.tableRowCut],onClick:()=>Ie(e)},{id:i.tableRowCopy,label:"Copy row",icon:u[i.tableRowCopy],onClick:()=>le(e)},{id:i.tableRowPasteBefore,label:"Paste row before",icon:u[i.tableRowPasteBefore],disabled:!t,onClick:()=>oe(e)},{id:i.tableRowPasteAfter,label:"Paste row after",icon:u[i.tableRowPasteAfter],disabled:!t,onClick:()=>oe({...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 ae(e){const t=[];return e.components().forEach((o,l)=>{o.components().each((n,s)=>{const{rowspan:r,colspan:a}=L(n);if(t[l])for(;t[l][s];)s++;for(let c=l;c<l+r;c++){t[c]||(t[c]=[]);for(let d=s;d<s+a;d++)t[c][d]={real:c===l&&d===s,cell:n,rowspan:r,colspan:a}}})}),t}function R(e,t,o){var l;return(l=e[o])==null?void 0:l[t]}const S=e=>e.closestType(g);function ke(e,{x:t,y:o,rows:l,cols:n}){var a;let s=S(e[o][t].cell),r;for(let c=1;c<=l;c++)if(s=(a=s==null?void 0:s.parent())==null?void 0:a.components().at(s.index()+1),s){for(r=t;r>=0;r--){const{cell:d}=e[o+c][r],v=S(d);if(v===s){for(let h=1;h<=n;h++){const f=d.index();v.append({type:p},{at:f+1})}break}}if(r===-1){const v=s.components().at(0).index();for(let h=1;h<=n;h++)s.append({type:p},{at:v})}}}function ce(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:r}=L(n);if(r>1||s>1){n.addAttributes({colspan:1,rowspan:1});for(let a=0;a<r-1;a++){const c=n.index();S(n).append({type:p},{at:c+1})}ke(e,{x:o,y:t,rows:s-1,cols:r})}}}}function De(e){const t=[];e.components().forEach(o=>{o.components().length||t.push(o)}),t.forEach(o=>o.remove())}const B=(e,t={})=>{var r;const o=ae(e),{em:l}=e;let n,s;for(let a=0;a<o.length;a++)for(let c=0;c<o[a].length;c++){const d=o[a][c];if((r=t.selected)!=null&&r.includes(d.cell)||l.selected.hasComponent(d.cell)){const v={x:c,y:a};n||(n=v),s=v}}return{grid:o,startPos:n,endPos:s}};function Te(e,t={}){const o=B(e),{startPos:l,endPos:n}=o;let{grid:s}=o;const{em:r}=e;if(!l||!n)return;const a=l.x,c=l.y,d=n.x,v=n.y,h=R(s,a,c),f=R(s,d,v);if(h&&f){ce(s),s=ae(e);const I=[],m=R(s,a,c).cell;m.addAttributes({colspan:d-a+1,rowspan:v-c+1});for(let w=c;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()}),r.setSelected(m),De(e)}}const re="Cell settings",Ee="Merge cells",Le="Split cell",Se=e=>e.closestType(g),P=e=>{var t;return(t=Se(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(p))||t.length>1)return!1;const{rowspan:n,colspan:s}=L(l);return!(s<2&&n<2)},Oe=e=>{const o=e.editor.getSelectedAll()[0],l=P(o),{grid:n}=B(l);ce(n)},ie=e=>{const t=e.editor.getSelectedAll(),o=P(t[0]);if(!o||t.length<2||t.some(a=>!a.is(p)||P(a)!==o))return!1;const{grid:l,startPos:n,endPos:s}=B(o),{em:r}=o;if(!n||!s)return!1;for(let a=n.y;a<=s.y;a++)for(let c=n.x;c<=s.x;c++){const d=R(l,c,a);if(!d||!r.selected.hasComponent(d.cell))return!1}return!0},Ne=e=>{const{editor:t}=e;if(!ie(e))return;const o=t.getSelectedAll(),l=P(o[0]);Te(l,{mergeContent:!0})},Ze=e=>{E(e,{id:"tableCellSettings",header:{label:re}})},Fe=e=>[{id:i.tableCellItems,icon:u[i.tableCellProperties],label:"Cell",items:[{id:i.tableCellProperties,label:re,icon:u[i.tableCellProperties],onClick:({event:o})=>Ze({...e,event:o})},{id:i.tableCellMerge,label:Ee,icon:u[i.tableCellMerge],onClick:()=>Ne(e),disabled:!ie(e)},{id:i.tableCellSplit,label:Le,icon:u[i.tableCellSplit],onClick:()=>Oe(e),disabled:!Ge(e)}]},...xe(e),...se(e)],_e=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 r=l.y;r<=n.y;r++)for(let a=l.x;a<=n.x;a++){const c=R(o,a,r);c&&s.push(c.cell)}s.length&&t.em.setSelected(s,{fromCell:!0})};return fe(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(b,{block:o.block&&{label:"Table",media:u.table,category:"Extra",content:{type:b,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:r,value:a,emitUpdate:c}){const d=r.find("caption")[0];a?!d&&r.append({type:"text",tagName:"caption",components:{type:"textnode",content:"Caption"}}):d==null||d.remove(),c(),e.refresh({tools:!0})},getValue(r){return!!r.component.find("caption")[0]}}],components:Pe(D,{rows:5}),contextMenu:({items:r,editor:a,component:c})=>[...W({editor:a,component:c,opts:o}),...r]}}}),l.addType(_,{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(g,{model:{defaults:{icon:u.tableRowProperties,emptyState:!0,highlightable:!1,stylable:["height","text-align","border-width","border-style","border-color"],traits:[],contextMenu:({items:r,editor:a,component:c})=>[...se({editor:a,component:c,opts:o}),...r]}}}),l.addType(p,{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:r,editor:a,component:c})=>[...Fe({editor:a,component:c,opts:o}),...r]}}});const s=z((r,a)=>{var h;const c=e.getSelectedAll(),d=!!((h=a==null?void 0:a.event)!=null&&h.shiftKey);if(c.length<2||!d||a.fromCell)return;const v=c.map(f=>f.is(p)?f:f.closestType(p)).filter(Boolean);v.length===c.length&&_e(v)},0);e.on("component:select",s),me({editor:e,plan:Ce,pluginName:F,licenseKey:o.licenseKey,cleanup:()=>{e.off("component:select",s),e.Blocks.remove(b),He.forEach(r=>l.removeType(r))}})},F)});
@@ -1,8 +1,8 @@
1
1
  import { Component, Editor, ObjectAny } from 'grapesjs';
2
2
  import { SDKPluginOptions } from '../utils';
3
- import { LayoutCommandProps } from '@studio/editor/src/types';
4
- export { StudioCommands } from '@studio/editor/src/plugins/global/types';
5
- export type { LayoutCommandProps, ContextMenuItem, ContextMenuFn } from '@studio/editor/src/types';
3
+ import { LayoutCommandProps } from '@grapesjs/studio-sdk/dist/types';
4
+ export { StudioCommands } from '@grapesjs/studio-sdk/dist/plugins/global/types';
5
+ export type { LayoutCommandProps, ContextMenuItem, ContextMenuFn } from '@grapesjs/studio-sdk/dist/types';
6
6
  export interface GetTableContextItems {
7
7
  editor: Editor;
8
8
  component: Component;
package/dist/types.d.ts CHANGED
@@ -1,16 +1,16 @@
1
1
  export { SdkPlanCategories } from '@studio/app/src/app/types';
2
- export { ToastVariant } from '@studio/editor/src/components/Toast/types';
3
- export type { IToast } from '@studio/editor/src/components/Toast/types';
4
- export type { CustomLayoutComponentsRegistry, StudioLayoutComponentsConfigProps, StudioLayoutComponentsConfig } from '@studio/editor/src/components/public/types';
5
- export { StudioCommands, StudioEvents } from '@studio/editor/src/plugins/global/types';
6
- export type { StudioCommandProjectFileOptions, StudioSdkSettings } from '@studio/editor/src/plugins/global/types';
7
- export type { AssetProvider, InputAssetProps } from '@studio/editor/src/typeConfigs/assets';
8
- export type { ProjectFile } from '@studio/editor/src/typeConfigs/project';
9
- export type { FontAssetProps } from '@studio/editor/src/typeConfigs/fonts';
10
- export type { Font, FontFaceArgs } from '@studio/editor/src/typeConfigs/shared';
11
- export type { LayoutCommandProps, LayoutConfig, RootLayoutConfig } from '@studio/editor/src/typeConfigs/layout';
12
- export type { StudioLayoutButtonConfigProps, StudioLayoutSidebarLeftConfigProps, StudioLayoutCanvasSidebarTopConfigProps } from '@studio/editor/src/typeConfigs/layoutComponents';
13
- export { ThemeValue } from '@studio/editor/src/typeConfigs/shared';
14
- export type { RteCustomToolbarProps } from '@studio/editor/src/typeConfigs/shared';
15
- export { ProjectType } from '@studio/editor/src/utils/types';
2
+ export { ToastVariant } from '@grapesjs/studio-sdk/dist/components/Toast/types';
3
+ export type { IToast } from '@grapesjs/studio-sdk/dist/components/Toast/types';
4
+ export type { CustomLayoutComponentsRegistry, StudioLayoutComponentsConfigProps, StudioLayoutComponentsConfig } from '@grapesjs/studio-sdk/dist/components/public/types';
5
+ export { StudioCommands, StudioEvents } from '@grapesjs/studio-sdk/dist/plugins/global/types';
6
+ export type { StudioCommandProjectFileOptions, StudioSdkSettings } from '@grapesjs/studio-sdk/dist/plugins/global/types';
7
+ export type { AssetProvider, InputAssetProps } from '@grapesjs/studio-sdk/dist/typeConfigs/assets';
8
+ export type { ProjectFile } from '@grapesjs/studio-sdk/dist/typeConfigs/project';
9
+ export type { FontAssetProps } from '@grapesjs/studio-sdk/dist/typeConfigs/fonts';
10
+ export type { Font, FontFaceArgs } from '@grapesjs/studio-sdk/dist/typeConfigs/shared';
11
+ export type { LayoutCommandProps, LayoutConfig, RootLayoutConfig } from '@grapesjs/studio-sdk/dist/typeConfigs/layout';
12
+ export type { StudioLayoutButtonConfigProps, StudioLayoutSidebarLeftConfigProps, StudioLayoutCanvasSidebarTopConfigProps } from '@grapesjs/studio-sdk/dist/typeConfigs/layoutComponents';
13
+ export { ThemeValue } from '@grapesjs/studio-sdk/dist/typeConfigs/shared';
14
+ export type { RteCustomToolbarProps } from '@grapesjs/studio-sdk/dist/typeConfigs/shared';
15
+ export { ProjectType } from '@grapesjs/studio-sdk/dist/utils/types';
16
16
  export type { BlockProperties, CanvasSpot, Component, ComponentView, Editor, Plugin, ToolbarButtonProps, Trait, TraitProperties } from 'grapesjs';
package/dist/utils.d.ts CHANGED
@@ -37,20 +37,21 @@ export interface SDKPlugin<T extends SDKPluginOptions = SDKPluginOptions> extend
37
37
  export interface PluginWithInit<T extends SDKPluginOptions = SDKPluginOptions> extends Plugin<T> {
38
38
  init: (opts: T) => (editor: Editor) => void;
39
39
  }
40
- export declare const pluginWithInit: <T extends SDKPluginOptions>(plugin: SDKPlugin<T>) => PluginWithInit<T>;
40
+ export declare const pluginWithInit: <T extends SDKPluginOptions>(plugin: SDKPlugin<T>, id: string) => PluginWithInit<T>;
41
41
  export declare function subscribeToLicenseCheck({ editor, plan, pluginName, licenseKey, onLicenseCheckResponse, cleanup }: {
42
42
  editor: Editor;
43
43
  pluginName: string;
44
44
  plan: SdkPlanCategories;
45
45
  licenseKey?: string;
46
46
  onLicenseCheckResponse?: (res: LicenseCheckResult | false) => void;
47
- cleanup: () => void;
47
+ cleanup: (editor: Editor, pluginId: string) => void;
48
48
  }): Promise<void>;
49
49
  export declare const elHasAttribute: (el: HTMLElement, attrName: string) => boolean;
50
50
  export declare const elHasClassName: (el: HTMLElement, className: string) => boolean;
51
51
  export declare const isComponentByTypeKey: (type: string) => (el: Element) => boolean;
52
52
  export declare const isComponentTypeSource: (...types: string[]) => (source: Component) => boolean;
53
53
  export declare const isComponentTypeTarget: (...types: string[]) => (_: Component, target: Component) => boolean;
54
+ export declare const cleanupPlugin: (editor: Editor, pluginId: string) => void;
54
55
  /**
55
56
  * A helper function to get props, value and trait defintion from StudioPluginTraits.
56
57
  */
@@ -1,4 +1,4 @@
1
- import { ConditionType, IDataSourceExporter, IDataSourceImporter } from '@studio/editor/src/typeConfigs/dataSources';
1
+ import { ConditionType, IDataSourceExporter, IDataSourceImporter } from '@grapesjs/studio-sdk/dist/typeConfigs/dataSources';
2
2
  import { Editor, LogicGroupProps } from 'grapesjs';
3
3
  export declare const isLogicCondition: (condition: ConditionType) => condition is LogicGroupProps;
4
4
  export declare const setupExporter: (editor: Editor, exporter: IDataSourceExporter) => () => void;
@@ -1 +1 @@
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.openEditCode="studio:openEditCode",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",".claudemcpcontent.com",".web-sandbox.oaiusercontent.com"],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=()=>{if(!D())return"";const{hostname:e}=window.location;if(e)return e;try{return window.parent.location.hostname||""}catch{return""}},E=()=>{const e=O();return!!e&&(P.includes(e)||P.some(o=>e.endsWith(o)))};async function $({path:e,baseApiUrl:o,method:a="GET",headers:n={},params:l,body:u}){const t=`${o||k({isDev:!1,isStage:!1})}${e}`,r={method:a,headers:{"Content-Type":"application/json",...n}};u&&(r.body=JSON.stringify(u));const c=l?new URLSearchParams(l).toString():"",i=c?`?${c}`:"",s=await fetch(`${t}${i}`,r);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 M(e){const o=e;return o.init=a=>n=>e(n,a),o}const j=e=>M(e);async function B({editor:e,plan:o,pluginName:a,licenseKey:n,onLicenseCheckResponse:l,cleanup:u}){let p="",t;const r=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)r(h||"Invalid license");else if(y){const I=T[o],L=T[y];I>L&&r({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(!E())if(n){const s=await Y({licenseKey:n,pluginName:a,baseApiUrl:p});i(s)}else r("The `licenseKey` option not provided")});return}if(t.licensePlan||t.licenseError){const s=N(t);i(s);return}e.on(U,s=>i(s))}const N=e=>({sdkLicense:e.license,license:e.license,error:e.licenseError,plan:e.licensePlan});async function Y(e){const{licenseKey:o,pluginName:a,baseApiUrl:n}=e;try{return(await $({baseApiUrl:n,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 W=e=>{const o={};for(const a of Object.keys(e)){let n=e[a];n&&(Array.isArray(n)?n=n.map(l=>l.toString()).join(","):n=n.toString(),o[a]=n)}return new URLSearchParams(o)},A="youtube-video",_=e=>{const{apiKey:o,searchParams:a,thumbnailQuality:n="high"}=e,l=(t={})=>{const c="https://www.googleapis.com/youtube/v3/search",i=W(t);return`${c}?${i}`},u=t=>{var r,c,i;return((r=t[n])==null?void 0:r.url)||((c=t.high)==null?void 0:c.url)||((i=t.medium)==null?void 0:i.url)||t.default.url},p=t=>{const r=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:r,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:r}){var f;const c={maxResults:25,q:t,pageToken:r==null?void 0:r.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:r})=>({type:"column",onClick:()=>r(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}}]})}},F={youtubeAssetProvider:{searchBtn:"Search on YouTube",modalTitle:"Select YouTube Video",providerLabel:"YouTube Videos"}},K="youtubeAssetProvider",q=g.startup,H=function(e,o){var c;const{skipVideoComponent:a,i18n:n={}}=o,l=_(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,r=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:()=>r(this)},...s]}},view:{events:()=>({dblclick:"onActive"}),onActive(){const{model:i}=this,s=i.get("provider")||"";s!=null&&s.startsWith("yt")&&r(i)}}}),e.I18n.addMessages({en:F,...n}),B({editor:e,licenseKey:o.licenseKey,plan:q,pluginName:K,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=j(H);module.exports=V;
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.openEditCode="studio:openEditCode",e.openBlocks="studio:openBlocks",e.appendComponent="studio:appendComponent",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",k="app2.grapesjs.com",G="app-stage2.grapesjs.com",P=[w,k,R,G,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io",".claudemcpcontent.com",".web-sandbox.oaiusercontent.com"],U="license:check:end",D=()=>typeof window<"u",O=({isDev:e,isStage:o,isPlatform:n})=>`${e?"":`https://${o?R:w}`}/${n?"platform-api":"api"}`,E=()=>{if(!D())return"";const{hostname:e}=window.location;if(e)return e;try{return window.parent.location.hostname||""}catch{return""}},$=()=>{const e=E();return!!e&&(P.includes(e)||P.some(o=>e.endsWith(o)))};async function M({path:e,baseApiUrl:o,method:n="GET",headers:i={},params:r,body:u}){const t=`${o||O({isDev:!1,isStage:!1})}${e}`,a={method:n,headers:{"Content-Type":"application/json",...i}};u&&(a.body=JSON.stringify(u));const c=r?new URLSearchParams(r).toString():"",l=c?`?${c}`:"",s=await fetch(`${t}${l}`,a);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 B(e,o){const n=e;return n.init=i=>{const r=u=>e(u,i);return r.__gjsPluginId=o,r},n}const j=(e,o)=>B(e,o);async function N({editor:e,plan:o,pluginName:n,licenseKey:i,onLicenseCheckResponse:r,cleanup:u}){let p="",t;const a=s=>{console.warn("Cleanup plugin:",n,"Reason:",s),u(e,n)},c=(s={})=>{var v;const{error:h,sdkLicense:d}=s,y=(v=s.plan)==null?void 0:v.category;if(!(d||s.license)||h)a(h||"Invalid license");else if(y){const L=T[o],x=T[y];L>x&&a({pluginRequiredPlan:o,licensePlan:y})}};e.Commands.has(b.settings)&&(t=e.runCommand(b.settings),p=(t==null?void 0:t.baseUrl)||"");const l=s=>{r==null||r(s),s&&c(s)};if(!t){e.onReady(async()=>{if(!$())if(i){const s=await _({licenseKey:i,pluginName:n,baseApiUrl:p});l(s)}else a("The `licenseKey` option not provided")});return}if(t.licensePlan||t.licenseError){const s=Y(t);l(s);return}e.on(U,s=>l(s))}const Y=e=>({sdkLicense:e.license,license:e.license,error:e.licenseError,plan:e.licensePlan});async function _(e){const{licenseKey:o,pluginName:n,baseApiUrl:i}=e;try{return(await M({baseApiUrl:i,path:`/sdk/${o||"na"}`,method:"POST",params:{d:window.location.hostname,pn:n}})).result||{}}catch(r){return console.error("Error during SDK license check:",r),!1}}const W=e=>{const o={};for(const n of Object.keys(e)){let i=e[n];i&&(Array.isArray(i)?i=i.map(r=>r.toString()).join(","):i=i.toString(),o[n]=i)}return new URLSearchParams(o)},A="youtube-video",F=e=>{const{apiKey:o,searchParams:n,thumbnailQuality:i="high"}=e,r=(t={})=>{const c="https://www.googleapis.com/youtube/v3/search",l=W(t);return`${c}?${l}`},u=t=>{var a,c,l;return((a=t[i])==null?void 0:a.url)||((c=t.high)==null?void 0:c.url)||((l=t.medium)==null?void 0:l.url)||t.default.url},p=t=>{const a=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:a,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:a}){var f;const c={maxResults:25,q:t,pageToken:a==null?void 0:a.token,type:["video"],key:o},l=n==null?void 0:n({searchValue:t}),s={...c,...l};s.part?s.part.includes("snippet")||s.part.push("snippet"):s.part=["snippet"];const d=await(await fetch(r(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:a})=>({type:"column",onClick:()=>a(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}}]})}},K={youtubeAssetProvider:{searchBtn:"Search on YouTube",modalTitle:"Select YouTube Video",providerLabel:"YouTube Videos"}},I="youtubeAssetProvider",q=g.startup,H=function(e,o){var c;const{skipVideoComponent:n,i18n:i={}}=o,r=F(o);e.runCommand(b.assetProviderAdd,{provider:r});const u="search-on-youtube",p="video",t=(c=e.Components.getType(p))==null?void 0:c.model.prototype,a=l=>{e.Assets.open({modalTitle:e.I18n.t("youtubeAssetProvider.modalTitle"),providerId:r.id,typeId:r.types[0],providers:[],types:[],select:s=>{e.Assets.close(),l.set({videoId:s.attributes.id})},content:{header:{addUrl:!1,upload:!1}}})};!n&&t&&e.Components.addType(p,{model:{getYoutubeTraits(){const[l,...s]=t.getYoutubeTraits.apply(this);return[l,{id:u,type:"button",label:e.I18n.t("youtubeAssetProvider.searchBtn"),command:()=>a(this)},...s]}},view:{events:()=>({dblclick:"onActive"}),onActive(){const{model:l}=this,s=l.get("provider")||"";s!=null&&s.startsWith("yt")&&a(l)}}}),e.I18n.addMessages({en:K,...i}),N({editor:e,licenseKey:o.licenseKey,plan:q,pluginName:I,cleanup:()=>{e.runCommand(b.assetProviderRemove,{id:r.id}),!n&&t&&e.Components.addType(p,{model:{getYoutubeTraits(){return t.getYoutubeTraits.apply(this).filter(l=>l.id!==u)}}})}})},V=j(H,I);module.exports=V;