@grapesjs/studio-sdk-plugins 1.0.8 → 1.0.9

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 (35) hide show
  1. package/dist/dialogComponent/index.cjs.js +4 -4
  2. package/dist/dialogComponent/index.es.js +27 -28
  3. package/dist/dialogComponent/index.umd.js +4 -4
  4. package/dist/fsLightboxComponent/index.cjs.js +2 -2
  5. package/dist/fsLightboxComponent/index.es.js +51 -52
  6. package/dist/fsLightboxComponent/index.umd.js +2 -2
  7. package/dist/index.cjs.d.ts +1 -0
  8. package/dist/index.cjs.js +22 -22
  9. package/dist/index.d.ts +1 -0
  10. package/dist/index.es.d.ts +1 -0
  11. package/dist/index.es.js +5265 -4605
  12. package/dist/index.umd.js +22 -22
  13. package/dist/lightGalleryComponent/index.cjs.d.ts +3 -0
  14. package/dist/lightGalleryComponent/index.cjs.js +1 -0
  15. package/dist/lightGalleryComponent/index.d.ts +3 -0
  16. package/dist/lightGalleryComponent/index.es.d.ts +3 -0
  17. package/dist/lightGalleryComponent/index.es.js +718 -0
  18. package/dist/lightGalleryComponent/index.umd.js +1 -0
  19. package/dist/lightGalleryComponent/types.d.ts +57 -0
  20. package/dist/lightGalleryComponent/typesSchema.d.ts +3 -0
  21. package/dist/lightGalleryComponent/utils.d.ts +47 -0
  22. package/dist/listPagesComponent/index.cjs.js +3 -3
  23. package/dist/listPagesComponent/index.es.js +32 -33
  24. package/dist/listPagesComponent/index.umd.js +3 -3
  25. package/dist/prosemirror/index.cjs.js +8 -8
  26. package/dist/prosemirror/index.es.js +806 -786
  27. package/dist/prosemirror/index.umd.js +9 -9
  28. package/dist/prosemirror/schema.d.ts +1 -1
  29. package/dist/prosemirror/types.d.ts +5 -0
  30. package/dist/prosemirror/utils.d.ts +3 -1
  31. package/dist/tableComponent/index.cjs.js +1 -1
  32. package/dist/tableComponent/index.es.js +35 -36
  33. package/dist/tableComponent/index.umd.js +1 -1
  34. package/dist/utils.d.ts +1 -0
  35. package/package.json +1 -1
@@ -220,6 +220,6 @@ export declare const marks: {
220
220
  toDOM(mark: Mark): [string, any, number];
221
221
  };
222
222
  };
223
- export declare const schema: Schema<"div" | "table" | "image" | "text" | "heading" | "doc" | "inlineFragment" | "paragraph" | "orderedList" | "bulletList" | "listItem" | "codeBlock" | "inlineBreak" | "hardBreak" | "table_row" | "table_cell" | "table_header" | "nonTextNode", "link" | "em" | "strong" | "underline" | "strikethrough" | "font_size">;
223
+ export declare const schema: Schema<"div" | "table" | "image" | "text" | "heading" | "doc" | "inlineFragment" | "paragraph" | "orderedList" | "bulletList" | "listItem" | "codeBlock" | "inlineBreak" | "hardBreak" | "table_row" | "table_cell" | "table_header" | "nonTextNode", "em" | "link" | "strong" | "underline" | "strikethrough" | "font_size">;
224
224
  export type DefaultSchema = typeof schema;
225
225
  export default schema;
@@ -36,6 +36,11 @@ export interface RteProseMirrorToolbarProps extends RteCustomToolbarProps {
36
36
  };
37
37
  }
38
38
  export interface RteProseMirrorOptions extends SDKPluginOptions {
39
+ /**
40
+ * Enable RTE on click of the text component, instead of the default double-click.
41
+ * @default false
42
+ */
43
+ enableOnClick?: boolean;
39
44
  /**
40
45
  * Extend the default ProseMirror schema.
41
46
  * @example
@@ -1,7 +1,8 @@
1
1
  import { MarkType, NodeType } from 'prosemirror-model';
2
2
  import { EditorState, Transaction } from 'prosemirror-state';
3
3
  import { EditorView } from 'prosemirror-view';
4
- import { Component } from 'grapesjs';
4
+ import { Component, Editor } from 'grapesjs';
5
+ import { RteProseMirrorOptions } from './types';
5
6
  export declare const mapElToView: WeakMap<HTMLElement, EditorView>;
6
7
  export declare const mapViewToEl: WeakMap<EditorView, HTMLElement>;
7
8
  export declare const setElToViewMapping: (el: HTMLElement, view: EditorView) => void;
@@ -22,3 +23,4 @@ export declare function handleNodeSplitting(tr: Transaction, from: number): {
22
23
  splittedInlineFragmentPos: number;
23
24
  };
24
25
  export declare function removeInlineFragmentMarks(tr: Transaction, pos: number, textLength: number): void;
26
+ export declare function enableRteOnClick(editor: Editor, options?: RteProseMirrorOptions): () => void;
@@ -1 +1 @@
1
- "use strict";require("react");function ce(e,t,o){let l,s,n,c,a;const r=t;function h(){const g=Date.now()-c;g<r&&g>=0?l=setTimeout(h,r-g):(l=null,a=e.apply(n,s),n=s=null)}const v=function(){return n=this,s=arguments,c=Date.now(),l||(l=setTimeout(h,r)),a};return v.clear=function(){l&&(clearTimeout(l),l=null)},v.flush=function(){l&&(a=e.apply(n,s),n=s=null,clearTimeout(l),l=null)},v}const B="app.grapesjs.com",O="app-stage.grapesjs.com",T=[B,O,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],re="license:check:start",ie="license:check:end",Z=()=>typeof window<"u",he=({isDev:e,isStage:t})=>`${e?"":`https://${t?O:B}`}/api`,de=()=>{const e=Z()&&window.location.hostname;return!!e&&(T.includes(e)||T.some(t=>e.endsWith(t)))},ve=()=>(Z()&&window.location.hostname)===B;function F(e){return typeof e=="function"}var be={NODE_ENV:"production",NPM_PACKAGE_VERSION:"1.0.8",STUDIO_NPM_PACKAGE_VERSION:"1.0.25"};const ge=be.NODE_ENV!=="production";async function ue({path:e,method:t="GET",headers:o={},body:l}){const n=`${he({isDev:ge,isStage:!ve()})}${e}`,c={method:t,headers:{"Content-Type":"application/json",...o}};l&&(c.body=JSON.stringify(l));const a=await fetch(n,c);if(!a.ok)throw new Error(`HTTP error! status: ${a.status}`);return a.json()}function pe(e){const t=e;return t.init=o=>l=>e(l,o),t}const fe=e=>pe(e);async function me({editor:e,pluginName:t,licenseKey:o,cleanup:l}){let s=!1;const n=de();e.on(re,()=>{s=!0}),e.on(ie,({sdkLicense:c})=>{c||l()}),setTimeout(async()=>{if(!s){if(n)return;o&&await we({licenseKey:o,pluginName:t})||l()}},2e3)}async function we({licenseKey:e,pluginName:t}){try{const o=await ue({path:`/sdk/${e}`,method:"POST",body:JSON.stringify({d:window.location.hostname,pn:t})}),{license:l}=o.result||{};return!!l}catch(o){return console.error("Error during SDK license check:",o),!1}}var G=(e=>(e.toastAdd="studio:toastAdd",e.dialogOpen="studio:dialogOpen",e.dialogClose="studio:dialogClose",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.projectFiles="studio:projectFiles",e.canvasReload="studio:canvasReload",e.getBlocksPanel="studio:getBlocksPanel",e.setBlocksPanel="studio:setBlocksPanel",e.contextMenuComponent="studio:contextMenuComponent",e.layoutAdd="studio:layoutAdd",e.layoutRemove="studio:layoutRemove",e.layoutToggle="studio:layoutToggle",e))(G||{}),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 d={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",W="thead",$="tfoot",P="tbody",u="row",b="cell",k="clipboardTable",ye=[p,W,$,P,u,b],V=e=>e.em.get(k)||[],Ce=e=>e.every(t=>t.is(b)),I=(e,t)=>{const{editor:o,event:l,opts:s}=e,n=l.currentTarget||l.target,{x:c,y:a,width:r,height:h}=n.getBoundingClientRect(),v={style:{width:240,height:300},placer:{type:"popover",closeOnClickAway:!0,x:c,y:a,w:r,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};F(s.openSettings)?s.openSettings({...e,layoutProps:v}):o.runCommand(G.layoutToggle,v)},He=(e,{rows:t=1,cells:o=5,text:l}={})=>({type:e,components:Array.from(Array(t).keys()).map(s=>({type:u,components:Array.from(Array(o).keys()).map(n=>({type:b,components:l?{type:"text",content:F(l)?l({y:s,x:n}):l}:void 0}))}))}),K="Table settings",U=e=>{const{component:t}=e;return t.is(p)?t:t.closestType(p)},Ve=e=>{var t;(t=U(e))==null||t.remove(e.opts)},Re=e=>{const t=U(e);t&&(e.editor.select(t),I(e,{id:"tableSettings",header:{label:K}}))},j=e=>[{id:i.table,icon:d[i.table],label:"Table",items:[{id:i.tableSettings,label:K,icon:d[i.tableSettings],onClick:({event:o})=>Re({...e,event:o})},{id:i.tableDelete,label:"Delete table",icon:d[i.tableDelete],onClick:()=>Ve(e)}]}],J=({editor:e})=>{const t=V(e);return t.length&&Ce(t)},E=({component:e,editor:t,after:o})=>{if(!e.is(b))return;const l=e.closestType(p),s=e.closestType(u),n=e.index()+(o?1:0);l==null||l.findType(u).forEach(a=>a.append({type:b},{at:n}));const c=s==null?void 0:s.components().at(n);c&&t.select(c)},X=({component:e,opts:t})=>{if(!e.is(b))return;const o=e.closestType(p),l=e.index();o==null||o.findType(u).forEach(s=>{var n;return(n=s.components().at(l))==null?void 0:n.remove(t)})},Y=({component:e,editor:t})=>{if(!e.is(b))return;const o=e.closestType(p),l=e.index(),s=(o==null?void 0:o.findType(u).map(n=>n.components().at(l)))||[];s.length&&t.em.set(k,s)},L=e=>{const{component:t,editor:o,after:l}=e;if(!t.is(b)||!J(e))return;const s=V(o),n=t.closestType(p),c=t.index()+(l?1:0);n==null||n.findType(u).forEach((a,r)=>{const h=s[r],v=(h==null?void 0:h.clone())||{type:b};a.append(v,{at:c})})},ze=e=>{const{component:t}=e;t.is(b)&&(Y(e),X({...e,opts:{temporary:!0}}))},Pe=e=>{const t=J(e);return[{id:i.tableColumnItems,icon:d[i.tableColumn],label:"Column",items:[{id:i.tableColumnInsertBefore,label:"Insert column before",icon:d[i.tableColumnInsertBefore],onClick:()=>E(e)},{id:i.tableColumnInsertAfter,label:"Insert column after",icon:d[i.tableColumnInsertAfter],onClick:()=>E({...e,after:!0})},{id:i.tableColumnDelete,label:"Delete column",icon:d[i.tableColumnDelete],onClick:()=>X(e)},{id:i.tableColumnCut,label:"Cut column",icon:d[i.tableColumnCut],onClick:()=>ze(e)},{id:i.tableColumnCopy,label:"Copy column",icon:d[i.tableColumnCopy],onClick:()=>Y(e)},{id:i.tableColumnPasteBefore,label:"Paste column before",icon:d[i.tableColumnPasteBefore],disabled:!t,onClick:()=>L(e)},{id:i.tableColumnPasteAfter,label:"Paste column after",icon:d[i.tableColumnPasteAfter],disabled:!t,onClick:()=>L({...e,after:!0})}]}]},q="Row settings",Ae=e=>e.every(t=>t.is(u)),C=e=>{const{component:t}=e,o=t.is(b),l=t.is(u);if(!(!o&&!l))return l?t:t.closestType(u)},N=e=>{const{component:t,editor:o,after:l}=e,s=C(e);if(!s)return;const n=s.index()+(l?1:0),c=s.components().length,a=Array.from(Array(c).keys()).map(()=>({type:b})),r=s.parent();if(r){const h=r.append({type:u,components:a},{at:n})[0];if(t.is(b)&&h){const v=t.index(),g=h.components().at(v);g&&o.select(g)}}},Q=e=>{var t;(t=C(e))==null||t.remove(e.opts)},ee=e=>{const t=C(e);t&&e.editor.em.set(k,[t])},_=e=>{var a;const{editor:t,after:o}=e,l=C(e);if(!l||!te(e))return;const n=V(t)[0],c=l.index()+(o?1:0);n&&((a=l.parent())==null||a.append(n.clone(),{at:c}))},Be=e=>{C(e)&&(ee(e),Q({...e,opts:{temporary:!0}}))},te=({editor:e})=>{const t=V(e);return t.length&&Ae(t)},ke=e=>{const t=C(e);t&&(e.editor.select(t),I(e,{id:"tableRowSettings",header:{label:q}}))},le=e=>{const t=te(e);return[{id:i.tableRowItems,icon:d[i.tableRowProperties],label:"Row",items:[{id:i.tableRowInsertBefore,label:"Insert row before",icon:d[i.tableRowInsertBefore],onClick:()=>N(e)},{id:i.tableRowInsertAfter,label:"Insert row after",icon:d[i.tableRowInsertAfter],onClick:()=>N({...e,after:!0})},{id:i.tableRowDelete,label:"Delete row",icon:d[i.tableRowDelete],onClick:()=>Q(e)},{id:i.tableRowProperties,label:q,icon:d[i.tableRowProperties],onClick:({event:l})=>ke({...e,event:l})},{id:i.tableRowCut,label:"Cut row",icon:d[i.tableRowCut],onClick:()=>Be(e)},{id:i.tableRowCopy,label:"Copy row",icon:d[i.tableRowCopy],onClick:()=>ee(e)},{id:i.tableRowPasteBefore,label:"Paste row before",icon:d[i.tableRowPasteBefore],disabled:!t,onClick:()=>_(e)},{id:i.tableRowPasteAfter,label:"Paste row after",icon:d[i.tableRowPasteAfter],disabled:!t,onClick:()=>_({...e,after:!0})}]},...j(e)]},x=e=>{const t=e.attributes.attributes||{},o=parseInt(`${t.rowspan||1}`,10),l=parseInt(`${t.colspan||1}`,10);return{rowspan:o,colspan:l}};function oe(e){const t=[];return e.components().forEach((o,l)=>{o.components().each((s,n)=>{const{rowspan:c,colspan:a}=x(s);if(t[l])for(;t[l][n];)n++;for(let r=l;r<l+c;r++){t[r]||(t[r]=[]);for(let h=n;h<n+a;h++)t[r][h]={real:r===l&&h===n,cell:s,rowspan:c,colspan:a}}})}),t}function w(e,t,o){var l;return(l=e[o])==null?void 0:l[t]}const A=e=>e.closestType(u);function Ie(e,{x:t,y:o,rows:l,cols:s}){var a;let n=A(e[o][t].cell),c;for(let r=1;r<=l;r++)if(n=(a=n==null?void 0:n.parent())==null?void 0:a.components().at(n.index()+1),n){for(c=t;c>=0;c--){const{cell:h}=e[o+r][c],v=A(h);if(v===n){for(let g=1;g<=s;g++){const f=h.index();v.append({type:b},{at:f+1})}break}}if(c===-1){const v=n.components().at(0).index();for(let g=1;g<=s;g++)n.append({type:b},{at:v})}}}function ne(e){for(let t=0;t<e.length;t++)for(let o=0;o<e[t].length;o++){const s=e[t][o].cell;if(s.em.selected.hasComponent(s)){const{rowspan:n,colspan:c}=x(s);if(c>1||n>1){s.addAttributes({colspan:1,rowspan:1});for(let a=0;a<c-1;a++){const r=s.index();A(s).append({type:b},{at:r+1})}Ie(e,{x:o,y:t,rows:n-1,cols:c})}}}}function xe(e){const t=[];e.components().forEach(o=>{o.components().length||t.push(o)}),t.forEach(o=>o.remove())}const R=(e,t={})=>{var c;const o=oe(e),{em:l}=e;let s,n;for(let a=0;a<o.length;a++)for(let r=0;r<o[a].length;r++){const h=o[a][r];if((c=t.selected)!=null&&c.includes(h.cell)||l.selected.hasComponent(h.cell)){const v={x:r,y:a};s||(s=v),n=v}}return{grid:o,startPos:s,endPos:n}};function Me(e,t={}){const o=R(e),{startPos:l,endPos:s}=o;let{grid:n}=o;const{em:c}=e;if(!l||!s)return;const a=l.x,r=l.y,h=s.x,v=s.y,g=w(n,a,r),f=w(n,h,v);if(g&&f){ne(n),n=oe(e);const M=[],H=w(n,a,r).cell;H.addAttributes({colspan:h-a+1,rowspan:v-r+1});for(let m=r;m<=v;m++)for(let z=a;z<=h;z++){const S=w(n,z,m);if(!S)continue;const{cell:D}=S;D!==H&&M.push(D)}M.forEach(m=>{t.mergeContent&&H.append(m.components().models),m.remove()}),c.setSelected(H),xe(e)}}const se="Cell settings",Se="Merge cells",De="Split cell",Te=e=>e.closestType(u),y=e=>{var t;return(t=Te(e))==null?void 0:t.parent()},Ee=e=>{const t=e.editor.getSelectedAll(),o=y(t[0]),l=t[0];if(!o||!(l!=null&&l.is(b))||t.length>1)return!1;const{rowspan:s,colspan:n}=x(l);return!(n<2&&s<2)},Le=e=>{const o=e.editor.getSelectedAll()[0],l=y(o),{grid:s}=R(l);ne(s)},ae=e=>{const t=e.editor.getSelectedAll(),o=y(t[0]);if(!o||t.length<2||t.some(a=>!a.is(b)||y(a)!==o))return!1;const{grid:l,startPos:s,endPos:n}=R(o),{em:c}=o;if(!s||!n)return!1;for(let a=s.y;a<=n.y;a++)for(let r=s.x;r<=n.x;r++){const h=w(l,r,a);if(!h||!c.selected.hasComponent(h.cell))return!1}return!0},Ne=e=>{const{editor:t}=e;if(!ae(e))return;const o=t.getSelectedAll(),l=y(o[0]);Me(l,{mergeContent:!0})},_e=e=>{I(e,{id:"tableCellSettings",header:{label:se}})},Oe=e=>[{id:i.tableCellItems,icon:d[i.tableCellProperties],label:"Cell",items:[{id:i.tableCellProperties,label:se,icon:d[i.tableCellProperties],onClick:({event:o})=>_e({...e,event:o})},{id:i.tableCellMerge,label:Se,icon:d[i.tableCellMerge],onClick:()=>Ne(e),disabled:!ae(e)},{id:i.tableCellSplit,label:De,icon:d[i.tableCellSplit],onClick:()=>Le(e),disabled:!Ee(e)}]},...Pe(e),...le(e)],Ze=e=>{const t=e[0]&&y(e[0]);if(!t)return;const{grid:o,startPos:l,endPos:s}=R(t,{selected:e});if(!l||!s)return;const n=[];for(let c=l.y;c<=s.y;c++)for(let a=l.x;a<=s.x;a++){const r=w(o,a,c);r&&n.push(r.cell)}n.length&&t.em.setSelected(n,{fromCell:!0})},Fe="tableComponent",Ge=function(e,t={}){const o={block:{},...t},{Components:l}=e,s={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:d.table,category:"Extra",content:{type:p,style:{width:"100%"}},select:!0,...o.block},model:{defaults:{emptyState:!0,highlightable:!1,icon:d.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 h=c.find("caption")[0];a?!h&&c.append({type:"text",tagName:"caption",components:{type:"textnode",content:"Caption"}}):h==null||h.remove(),r(),e.refresh({tools:!0})},getValue(c){return!!c.component.find("caption")[0]}}],components:He(P,{rows:5}),contextMenu:({items:c,editor:a,component:r})=>[...j({editor:a,component:r,opts:o}),...c]}}}),l.addType(W,{model:{defaults:{icon:d.tableHead,...s}}}),l.addType($,{model:{defaults:{icon:d.tableFoot,...s}}}),l.addType(P,{model:{defaults:{icon:d.tableRowProperties,...s}}}),l.addType(u,{model:{defaults:{icon:d.tableRowProperties,emptyState:!0,highlightable:!1,stylable:["height","text-align","border-width","border-style","border-color"],traits:[],contextMenu:({items:c,editor:a,component:r})=>[...le({editor:a,component:r,opts:o}),...c]}}}),l.addType(b,{model:{defaults:{icon:d.tableCellProperties,emptyState:{styleOut:"height: 1px"},stylable:["width","height","padding","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})=>[...Oe({editor:a,component:r,opts:o}),...c]}}});const n=ce((c,a)=>{var g;const r=e.getSelectedAll(),h=!!((g=a==null?void 0:a.event)!=null&&g.shiftKey);if(r.length<2||!h||a.fromCell)return;const v=r.map(f=>f.is(b)?f:f.closestType(b)).filter(Boolean);v.length===r.length&&Ze(v)},0);e.on("component:select",n),me({editor:e,licenseKey:o.licenseKey,pluginName:Fe,cleanup:()=>{e.off("component:select",n),e.Blocks.remove(p),ye.forEach(c=>l.removeType(c))}})},We=fe(Ge);module.exports=We;
1
+ "use strict";function ce(e,t,o){let l,n,s,c,a;const r=t;function h(){const g=Date.now()-c;g<r&&g>=0?l=setTimeout(h,r-g):(l=null,a=e.apply(s,n),s=n=null)}const v=function(){return s=this,n=arguments,c=Date.now(),l||(l=setTimeout(h,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 B="app.grapesjs.com",O="app-stage.grapesjs.com",T=[B,O,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],re="license:check:start",ie="license:check:end",_=()=>typeof window<"u",he=({isDev:e,isStage:t})=>`${e?"":`https://${t?O:B}`}/api`,de=()=>{const e=_()&&window.location.hostname;return!!e&&(T.includes(e)||T.some(t=>e.endsWith(t)))},ve=()=>(_()&&window.location.hostname)===B;function F(e){return typeof e=="function"}var be={};const ge=be.NODE_ENV!=="production";async function ue({path:e,method:t="GET",headers:o={},body:l}){const s=`${he({isDev:ge,isStage:!ve()})}${e}`,c={method:t,headers:{"Content-Type":"application/json",...o}};l&&(c.body=JSON.stringify(l));const a=await fetch(s,c);if(!a.ok)throw new Error(`HTTP error! status: ${a.status}`);return a.json()}function pe(e){const t=e;return t.init=o=>l=>e(l,o),t}const fe=e=>pe(e);async function me({editor:e,pluginName:t,licenseKey:o,cleanup:l}){let n=!1;const s=de();e.on(re,()=>{n=!0}),e.on(ie,({sdkLicense:c})=>{c||l()}),setTimeout(async()=>{if(!n){if(s)return;o&&await we({licenseKey:o,pluginName:t})||l()}},2e3)}async function we({licenseKey:e,pluginName:t}){try{const o=await ue({path:`/sdk/${e}`,method:"POST",body:JSON.stringify({d:window.location.hostname,pn:t})}),{license:l}=o.result||{};return!!l}catch(o){return console.error("Error during SDK license check:",o),!1}}var W=(e=>(e.toastAdd="studio:toastAdd",e.dialogOpen="studio:dialogOpen",e.dialogClose="studio:dialogClose",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.projectFiles="studio:projectFiles",e.canvasReload="studio:canvasReload",e.getBlocksPanel="studio:getBlocksPanel",e.setBlocksPanel="studio:setBlocksPanel",e.contextMenuComponent="studio:contextMenuComponent",e.layoutAdd="studio:layoutAdd",e.layoutRemove="studio:layoutRemove",e.layoutToggle="studio:layoutToggle",e))(W||{}),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 d={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",G="thead",$="tfoot",P="tbody",u="row",b="cell",k="clipboardTable",ye=[p,G,$,P,u,b],V=e=>e.em.get(k)||[],Ce=e=>e.every(t=>t.is(b)),x=(e,t)=>{const{editor:o,event:l,opts:n}=e,s=l.currentTarget||l.target,{x:c,y:a,width:r,height:h}=s.getBoundingClientRect(),v={style:{width:240,height:300},placer:{type:"popover",closeOnClickAway:!0,x:c,y:a,w:r,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};F(n.openSettings)?n.openSettings({...e,layoutProps:v}):o.runCommand(W.layoutToggle,v)},He=(e,{rows:t=1,cells:o=5,text:l}={})=>({type:e,components:Array.from(Array(t).keys()).map(n=>({type:u,components:Array.from(Array(o).keys()).map(s=>({type:b,components:l?{type:"text",content:F(l)?l({y:n,x:s}):l}:void 0}))}))}),j="Table settings",U=e=>{const{component:t}=e;return t.is(p)?t:t.closestType(p)},Ve=e=>{var t;(t=U(e))==null||t.remove(e.opts)},Re=e=>{const t=U(e);t&&(e.editor.select(t),x(e,{id:"tableSettings",header:{label:j}}))},K=e=>[{id:i.table,icon:d[i.table],label:"Table",items:[{id:i.tableSettings,label:j,icon:d[i.tableSettings],onClick:({event:o})=>Re({...e,event:o})},{id:i.tableDelete,label:"Delete table",icon:d[i.tableDelete],onClick:()=>Ve(e)}]}],J=({editor:e})=>{const t=V(e);return t.length&&Ce(t)},E=({component:e,editor:t,after:o})=>{if(!e.is(b))return;const l=e.closestType(p),n=e.closestType(u),s=e.index()+(o?1:0);l==null||l.findType(u).forEach(a=>a.append({type:b},{at:s}));const c=n==null?void 0:n.components().at(s);c&&t.select(c)},X=({component:e,opts:t})=>{if(!e.is(b))return;const o=e.closestType(p),l=e.index();o==null||o.findType(u).forEach(n=>{var s;return(s=n.components().at(l))==null?void 0:s.remove(t)})},Y=({component:e,editor:t})=>{if(!e.is(b))return;const o=e.closestType(p),l=e.index(),n=(o==null?void 0:o.findType(u).map(s=>s.components().at(l)))||[];n.length&&t.em.set(k,n)},L=e=>{const{component:t,editor:o,after:l}=e;if(!t.is(b)||!J(e))return;const n=V(o),s=t.closestType(p),c=t.index()+(l?1:0);s==null||s.findType(u).forEach((a,r)=>{const h=n[r],v=(h==null?void 0:h.clone())||{type:b};a.append(v,{at:c})})},ze=e=>{const{component:t}=e;t.is(b)&&(Y(e),X({...e,opts:{temporary:!0}}))},Pe=e=>{const t=J(e);return[{id:i.tableColumnItems,icon:d[i.tableColumn],label:"Column",items:[{id:i.tableColumnInsertBefore,label:"Insert column before",icon:d[i.tableColumnInsertBefore],onClick:()=>E(e)},{id:i.tableColumnInsertAfter,label:"Insert column after",icon:d[i.tableColumnInsertAfter],onClick:()=>E({...e,after:!0})},{id:i.tableColumnDelete,label:"Delete column",icon:d[i.tableColumnDelete],onClick:()=>X(e)},{id:i.tableColumnCut,label:"Cut column",icon:d[i.tableColumnCut],onClick:()=>ze(e)},{id:i.tableColumnCopy,label:"Copy column",icon:d[i.tableColumnCopy],onClick:()=>Y(e)},{id:i.tableColumnPasteBefore,label:"Paste column before",icon:d[i.tableColumnPasteBefore],disabled:!t,onClick:()=>L(e)},{id:i.tableColumnPasteAfter,label:"Paste column after",icon:d[i.tableColumnPasteAfter],disabled:!t,onClick:()=>L({...e,after:!0})}]}]},q="Row settings",Ae=e=>e.every(t=>t.is(u)),C=e=>{const{component:t}=e,o=t.is(b),l=t.is(u);if(!(!o&&!l))return l?t:t.closestType(u)},N=e=>{const{component:t,editor:o,after:l}=e,n=C(e);if(!n)return;const s=n.index()+(l?1:0),c=n.components().length,a=Array.from(Array(c).keys()).map(()=>({type:b})),r=n.parent();if(r){const h=r.append({type:u,components:a},{at:s})[0];if(t.is(b)&&h){const v=t.index(),g=h.components().at(v);g&&o.select(g)}}},Q=e=>{var t;(t=C(e))==null||t.remove(e.opts)},ee=e=>{const t=C(e);t&&e.editor.em.set(k,[t])},Z=e=>{var a;const{editor:t,after:o}=e,l=C(e);if(!l||!te(e))return;const s=V(t)[0],c=l.index()+(o?1:0);s&&((a=l.parent())==null||a.append(s.clone(),{at:c}))},Be=e=>{C(e)&&(ee(e),Q({...e,opts:{temporary:!0}}))},te=({editor:e})=>{const t=V(e);return t.length&&Ae(t)},ke=e=>{const t=C(e);t&&(e.editor.select(t),x(e,{id:"tableRowSettings",header:{label:q}}))},le=e=>{const t=te(e);return[{id:i.tableRowItems,icon:d[i.tableRowProperties],label:"Row",items:[{id:i.tableRowInsertBefore,label:"Insert row before",icon:d[i.tableRowInsertBefore],onClick:()=>N(e)},{id:i.tableRowInsertAfter,label:"Insert row after",icon:d[i.tableRowInsertAfter],onClick:()=>N({...e,after:!0})},{id:i.tableRowDelete,label:"Delete row",icon:d[i.tableRowDelete],onClick:()=>Q(e)},{id:i.tableRowProperties,label:q,icon:d[i.tableRowProperties],onClick:({event:l})=>ke({...e,event:l})},{id:i.tableRowCut,label:"Cut row",icon:d[i.tableRowCut],onClick:()=>Be(e)},{id:i.tableRowCopy,label:"Copy row",icon:d[i.tableRowCopy],onClick:()=>ee(e)},{id:i.tableRowPasteBefore,label:"Paste row before",icon:d[i.tableRowPasteBefore],disabled:!t,onClick:()=>Z(e)},{id:i.tableRowPasteAfter,label:"Paste row after",icon:d[i.tableRowPasteAfter],disabled:!t,onClick:()=>Z({...e,after:!0})}]},...K(e)]},I=e=>{const t=e.attributes.attributes||{},o=parseInt(`${t.rowspan||1}`,10),l=parseInt(`${t.colspan||1}`,10);return{rowspan:o,colspan:l}};function oe(e){const t=[];return e.components().forEach((o,l)=>{o.components().each((n,s)=>{const{rowspan:c,colspan:a}=I(n);if(t[l])for(;t[l][s];)s++;for(let r=l;r<l+c;r++){t[r]||(t[r]=[]);for(let h=s;h<s+a;h++)t[r][h]={real:r===l&&h===s,cell:n,rowspan:c,colspan:a}}})}),t}function w(e,t,o){var l;return(l=e[o])==null?void 0:l[t]}const A=e=>e.closestType(u);function xe(e,{x:t,y:o,rows:l,cols:n}){var a;let s=A(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:h}=e[o+r][c],v=A(h);if(v===s){for(let g=1;g<=n;g++){const f=h.index();v.append({type:b},{at:f+1})}break}}if(c===-1){const v=s.components().at(0).index();for(let g=1;g<=n;g++)s.append({type:b},{at:v})}}}function se(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}=I(n);if(c>1||s>1){n.addAttributes({colspan:1,rowspan:1});for(let a=0;a<c-1;a++){const r=n.index();A(n).append({type:b},{at:r+1})}xe(e,{x:o,y:t,rows:s-1,cols:c})}}}}function Ie(e){const t=[];e.components().forEach(o=>{o.components().length||t.push(o)}),t.forEach(o=>o.remove())}const R=(e,t={})=>{var c;const o=oe(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 h=o[a][r];if((c=t.selected)!=null&&c.includes(h.cell)||l.selected.hasComponent(h.cell)){const v={x:r,y:a};n||(n=v),s=v}}return{grid:o,startPos:n,endPos:s}};function Me(e,t={}){const o=R(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,h=n.x,v=n.y,g=w(s,a,r),f=w(s,h,v);if(g&&f){se(s),s=oe(e);const M=[],H=w(s,a,r).cell;H.addAttributes({colspan:h-a+1,rowspan:v-r+1});for(let m=r;m<=v;m++)for(let z=a;z<=h;z++){const S=w(s,z,m);if(!S)continue;const{cell:D}=S;D!==H&&M.push(D)}M.forEach(m=>{t.mergeContent&&H.append(m.components().models),m.remove()}),c.setSelected(H),Ie(e)}}const ne="Cell settings",Se="Merge cells",De="Split cell",Te=e=>e.closestType(u),y=e=>{var t;return(t=Te(e))==null?void 0:t.parent()},Ee=e=>{const t=e.editor.getSelectedAll(),o=y(t[0]),l=t[0];if(!o||!(l!=null&&l.is(b))||t.length>1)return!1;const{rowspan:n,colspan:s}=I(l);return!(s<2&&n<2)},Le=e=>{const o=e.editor.getSelectedAll()[0],l=y(o),{grid:n}=R(l);se(n)},ae=e=>{const t=e.editor.getSelectedAll(),o=y(t[0]);if(!o||t.length<2||t.some(a=>!a.is(b)||y(a)!==o))return!1;const{grid:l,startPos:n,endPos:s}=R(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 h=w(l,r,a);if(!h||!c.selected.hasComponent(h.cell))return!1}return!0},Ne=e=>{const{editor:t}=e;if(!ae(e))return;const o=t.getSelectedAll(),l=y(o[0]);Me(l,{mergeContent:!0})},Ze=e=>{x(e,{id:"tableCellSettings",header:{label:ne}})},Oe=e=>[{id:i.tableCellItems,icon:d[i.tableCellProperties],label:"Cell",items:[{id:i.tableCellProperties,label:ne,icon:d[i.tableCellProperties],onClick:({event:o})=>Ze({...e,event:o})},{id:i.tableCellMerge,label:Se,icon:d[i.tableCellMerge],onClick:()=>Ne(e),disabled:!ae(e)},{id:i.tableCellSplit,label:De,icon:d[i.tableCellSplit],onClick:()=>Le(e),disabled:!Ee(e)}]},...Pe(e),...le(e)],_e=e=>{const t=e[0]&&y(e[0]);if(!t)return;const{grid:o,startPos:l,endPos:n}=R(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=w(o,a,c);r&&s.push(r.cell)}s.length&&t.em.setSelected(s,{fromCell:!0})},Fe="tableComponent",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(p,{block:o.block&&{label:"Table",media:d.table,category:"Extra",content:{type:p,style:{width:"100%"}},select:!0,...o.block},model:{defaults:{emptyState:!0,highlightable:!1,icon:d.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 h=c.find("caption")[0];a?!h&&c.append({type:"text",tagName:"caption",components:{type:"textnode",content:"Caption"}}):h==null||h.remove(),r(),e.refresh({tools:!0})},getValue(c){return!!c.component.find("caption")[0]}}],components:He(P,{rows:5}),contextMenu:({items:c,editor:a,component:r})=>[...K({editor:a,component:r,opts:o}),...c]}}}),l.addType(G,{model:{defaults:{icon:d.tableHead,...n}}}),l.addType($,{model:{defaults:{icon:d.tableFoot,...n}}}),l.addType(P,{model:{defaults:{icon:d.tableRowProperties,...n}}}),l.addType(u,{model:{defaults:{icon:d.tableRowProperties,emptyState:!0,highlightable:!1,stylable:["height","text-align","border-width","border-style","border-color"],traits:[],contextMenu:({items:c,editor:a,component:r})=>[...le({editor:a,component:r,opts:o}),...c]}}}),l.addType(b,{model:{defaults:{icon:d.tableCellProperties,emptyState:{styleOut:"height: 1px"},stylable:["width","height","padding","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})=>[...Oe({editor:a,component:r,opts:o}),...c]}}});const s=ce((c,a)=>{var g;const r=e.getSelectedAll(),h=!!((g=a==null?void 0:a.event)!=null&&g.shiftKey);if(r.length<2||!h||a.fromCell)return;const v=r.map(f=>f.is(b)?f:f.closestType(b)).filter(Boolean);v.length===r.length&&_e(v)},0);e.on("component:select",s),me({editor:e,licenseKey:o.licenseKey,pluginName:Fe,cleanup:()=>{e.off("component:select",s),e.Blocks.remove(p),ye.forEach(c=>l.removeType(c))}})},Ge=fe(We);module.exports=Ge;
@@ -1,4 +1,3 @@
1
- import "react";
2
1
  function ce(e, t, o) {
3
2
  let l, s, n, c, a;
4
3
  const r = t;
@@ -26,14 +25,14 @@ const B = "app.grapesjs.com", O = "app-stage.grapesjs.com", T = [
26
25
  // For stackblitz.com demos
27
26
  "-sandpack.codesandbox.io"
28
27
  // For Sandpack demos
29
- ], re = "license:check:start", ie = "license:check:end", Z = () => typeof window < "u", he = ({ isDev: e, isStage: t }) => `${e ? "" : `https://${t ? O : B}`}/api`, de = () => {
30
- const e = Z() && window.location.hostname;
28
+ ], re = "license:check:start", ie = "license:check:end", _ = () => typeof window < "u", he = ({ isDev: e, isStage: t }) => `${e ? "" : `https://${t ? O : B}`}/api`, de = () => {
29
+ const e = _() && window.location.hostname;
31
30
  return !!e && (T.includes(e) || T.some((t) => e.endsWith(t)));
32
- }, ve = () => (Z() && window.location.hostname) === B;
31
+ }, ve = () => (_() && window.location.hostname) === B;
33
32
  function F(e) {
34
33
  return typeof e == "function";
35
34
  }
36
- var be = { NODE_ENV: "production", NPM_PACKAGE_VERSION: "1.0.8", STUDIO_NPM_PACKAGE_VERSION: "1.0.25" };
35
+ var be = {};
37
36
  const ge = be.NODE_ENV !== "production";
38
37
  async function ue({
39
38
  path: e,
@@ -93,7 +92,7 @@ async function we({ licenseKey: e, pluginName: t }) {
93
92
  return console.error("Error during SDK license check:", o), !1;
94
93
  }
95
94
  }
96
- var G = /* @__PURE__ */ ((e) => (e.toastAdd = "studio:toastAdd", e.dialogOpen = "studio:dialogOpen", e.dialogClose = "studio:dialogClose", 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.projectFiles = "studio:projectFiles", e.canvasReload = "studio:canvasReload", e.getBlocksPanel = "studio:getBlocksPanel", e.setBlocksPanel = "studio:setBlocksPanel", e.contextMenuComponent = "studio:contextMenuComponent", e.layoutAdd = "studio:layoutAdd", e.layoutRemove = "studio:layoutRemove", e.layoutToggle = "studio:layoutToggle", e))(G || {}), i = /* @__PURE__ */ ((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 || {});
95
+ var W = /* @__PURE__ */ ((e) => (e.toastAdd = "studio:toastAdd", e.dialogOpen = "studio:dialogOpen", e.dialogClose = "studio:dialogClose", 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.projectFiles = "studio:projectFiles", e.canvasReload = "studio:canvasReload", e.getBlocksPanel = "studio:getBlocksPanel", e.setBlocksPanel = "studio:setBlocksPanel", e.contextMenuComponent = "studio:contextMenuComponent", e.layoutAdd = "studio:layoutAdd", e.layoutRemove = "studio:layoutRemove", e.layoutToggle = "studio:layoutToggle", e))(W || {}), i = /* @__PURE__ */ ((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 || {});
97
96
  const d = {
98
97
  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>',
99
98
  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>',
@@ -122,7 +121,7 @@ const d = {
122
121
  tableColumnCopy: '<svg viewBox="0 0 24 24"><path d="M17 6v16h-7V6h7zm-2 2h-3v12h3V8zm-2-6v2H8v15H6V2h7z"/></svg>',
123
122
  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>',
124
123
  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>'
125
- }, p = "table", W = "thead", $ = "tfoot", P = "tbody", u = "row", b = "cell", k = "clipboardTable", ye = [p, W, $, P, u, b], V = (e) => e.em.get(k) || [], Ce = (e) => e.every((t) => t.is(b)), I = (e, t) => {
124
+ }, p = "table", G = "thead", $ = "tfoot", P = "tbody", u = "row", b = "cell", k = "clipboardTable", ye = [p, G, $, P, u, b], V = (e) => e.em.get(k) || [], Ce = (e) => e.every((t) => t.is(b)), x = (e, t) => {
126
125
  const { editor: o, event: l, opts: s } = e, n = l.currentTarget || l.target, { x: c, y: a, width: r, height: h } = n.getBoundingClientRect(), v = {
127
126
  style: { width: 240, height: 300 },
128
127
  placer: { type: "popover", closeOnClickAway: !0, x: c, y: a, w: r, h },
@@ -144,7 +143,7 @@ const d = {
144
143
  },
145
144
  ...t
146
145
  };
147
- F(s.openSettings) ? s.openSettings({ ...e, layoutProps: v }) : o.runCommand(G.layoutToggle, v);
146
+ F(s.openSettings) ? s.openSettings({ ...e, layoutProps: v }) : o.runCommand(W.layoutToggle, v);
148
147
  }, He = (e, {
149
148
  rows: t = 1,
150
149
  cells: o = 5,
@@ -158,7 +157,7 @@ const d = {
158
157
  components: l ? { type: "text", content: F(l) ? l({ y: s, x: n }) : l } : void 0
159
158
  }))
160
159
  }))
161
- }), K = "Table settings", U = (e) => {
160
+ }), j = "Table settings", U = (e) => {
162
161
  const { component: t } = e;
163
162
  return t.is(p) ? t : t.closestType(p);
164
163
  }, Ve = (e) => {
@@ -166,18 +165,18 @@ const d = {
166
165
  (t = U(e)) == null || t.remove(e.opts);
167
166
  }, Re = (e) => {
168
167
  const t = U(e);
169
- t && (e.editor.select(t), I(e, {
168
+ t && (e.editor.select(t), x(e, {
170
169
  id: "tableSettings",
171
- header: { label: K }
170
+ header: { label: j }
172
171
  }));
173
- }, j = (e) => [{
172
+ }, K = (e) => [{
174
173
  id: i.table,
175
174
  icon: d[i.table],
176
175
  label: "Table",
177
176
  items: [
178
177
  {
179
178
  id: i.tableSettings,
180
- label: K,
179
+ label: j,
181
180
  icon: d[i.tableSettings],
182
181
  onClick: ({ event: o }) => Re({
183
182
  ...e,
@@ -297,7 +296,7 @@ const d = {
297
296
  }, ee = (e) => {
298
297
  const t = C(e);
299
298
  t && e.editor.em.set(k, [t]);
300
- }, _ = (e) => {
299
+ }, Z = (e) => {
301
300
  var a;
302
301
  const { editor: t, after: o } = e, l = C(e);
303
302
  if (!l || !te(e)) return;
@@ -310,7 +309,7 @@ const d = {
310
309
  return t.length && Ae(t);
311
310
  }, ke = (e) => {
312
311
  const t = C(e);
313
- t && (e.editor.select(t), I(e, {
312
+ t && (e.editor.select(t), x(e, {
314
313
  id: "tableRowSettings",
315
314
  header: { label: q }
316
315
  }));
@@ -366,18 +365,18 @@ const d = {
366
365
  label: "Paste row before",
367
366
  icon: d[i.tableRowPasteBefore],
368
367
  disabled: !t,
369
- onClick: () => _(e)
368
+ onClick: () => Z(e)
370
369
  },
371
370
  {
372
371
  id: i.tableRowPasteAfter,
373
372
  label: "Paste row after",
374
373
  icon: d[i.tableRowPasteAfter],
375
374
  disabled: !t,
376
- onClick: () => _({ ...e, after: !0 })
375
+ onClick: () => Z({ ...e, after: !0 })
377
376
  }
378
377
  ]
379
- }, ...j(e)];
380
- }, x = (e) => {
378
+ }, ...K(e)];
379
+ }, I = (e) => {
381
380
  const t = e.attributes.attributes || {}, o = parseInt(`${t.rowspan || 1}`, 10), l = parseInt(`${t.colspan || 1}`, 10);
382
381
  return { rowspan: o, colspan: l };
383
382
  };
@@ -385,7 +384,7 @@ function oe(e) {
385
384
  const t = [];
386
385
  return e.components().forEach((o, l) => {
387
386
  o.components().each((s, n) => {
388
- const { rowspan: c, colspan: a } = x(s);
387
+ const { rowspan: c, colspan: a } = I(s);
389
388
  if (t[l])
390
389
  for (; t[l][n]; )
391
390
  n++;
@@ -407,7 +406,7 @@ function w(e, t, o) {
407
406
  return (l = e[o]) == null ? void 0 : l[t];
408
407
  }
409
408
  const A = (e) => e.closestType(u);
410
- function Ie(e, { x: t, y: o, rows: l, cols: s }) {
409
+ function xe(e, { x: t, y: o, rows: l, cols: s }) {
411
410
  var a;
412
411
  let n = A(e[o][t].cell), c;
413
412
  for (let r = 1; r <= l; r++)
@@ -434,19 +433,19 @@ function ne(e) {
434
433
  for (let o = 0; o < e[t].length; o++) {
435
434
  const s = e[t][o].cell;
436
435
  if (s.em.selected.hasComponent(s)) {
437
- const { rowspan: n, colspan: c } = x(s);
436
+ const { rowspan: n, colspan: c } = I(s);
438
437
  if (c > 1 || n > 1) {
439
438
  s.addAttributes({ colspan: 1, rowspan: 1 });
440
439
  for (let a = 0; a < c - 1; a++) {
441
440
  const r = s.index();
442
441
  A(s).append({ type: b }, { at: r + 1 });
443
442
  }
444
- Ie(e, { x: o, y: t, rows: n - 1, cols: c });
443
+ xe(e, { x: o, y: t, rows: n - 1, cols: c });
445
444
  }
446
445
  }
447
446
  }
448
447
  }
449
- function xe(e) {
448
+ function Ie(e) {
450
449
  const t = [];
451
450
  e.components().forEach((o) => {
452
451
  o.components().length || t.push(o);
@@ -493,7 +492,7 @@ function Me(e, t = {}) {
493
492
  }
494
493
  M.forEach((m) => {
495
494
  t.mergeContent && H.append(m.components().models), m.remove();
496
- }), c.setSelected(H), xe(e);
495
+ }), c.setSelected(H), Ie(e);
497
496
  }
498
497
  }
499
498
  const se = "Cell settings", Se = "Merge cells", De = "Split cell", Te = (e) => e.closestType(u), y = (e) => {
@@ -503,7 +502,7 @@ const se = "Cell settings", Se = "Merge cells", De = "Split cell", Te = (e) => e
503
502
  const t = e.editor.getSelectedAll(), o = y(t[0]), l = t[0];
504
503
  if (!o || !(l != null && l.is(b)) || t.length > 1)
505
504
  return !1;
506
- const { rowspan: s, colspan: n } = x(l);
505
+ const { rowspan: s, colspan: n } = I(l);
507
506
  return !(n < 2 && s < 2);
508
507
  }, Le = (e) => {
509
508
  const o = e.editor.getSelectedAll()[0], l = y(o), { grid: s } = R(l);
@@ -526,8 +525,8 @@ const se = "Cell settings", Se = "Merge cells", De = "Split cell", Te = (e) => e
526
525
  if (!ae(e)) return;
527
526
  const o = t.getSelectedAll(), l = y(o[0]);
528
527
  Me(l, { mergeContent: !0 });
529
- }, _e = (e) => {
530
- I(e, {
528
+ }, Ze = (e) => {
529
+ x(e, {
531
530
  id: "tableCellSettings",
532
531
  header: { label: se }
533
532
  });
@@ -540,7 +539,7 @@ const se = "Cell settings", Se = "Merge cells", De = "Split cell", Te = (e) => e
540
539
  id: i.tableCellProperties,
541
540
  label: se,
542
541
  icon: d[i.tableCellProperties],
543
- onClick: ({ event: o }) => _e({
542
+ onClick: ({ event: o }) => Ze({
544
543
  ...e,
545
544
  // @ts-expect-error workaround for the build
546
545
  event: o
@@ -561,7 +560,7 @@ const se = "Cell settings", Se = "Merge cells", De = "Split cell", Te = (e) => e
561
560
  disabled: !Ee(e)
562
561
  }
563
562
  ]
564
- }, ...Pe(e), ...le(e)], Ze = (e) => {
563
+ }, ...Pe(e), ...le(e)], _e = (e) => {
565
564
  const t = e[0] && y(e[0]);
566
565
  if (!t) return;
567
566
  const { grid: o, startPos: l, endPos: s } = R(t, { selected: e });
@@ -573,7 +572,7 @@ const se = "Cell settings", Se = "Merge cells", De = "Split cell", Te = (e) => e
573
572
  r && n.push(r.cell);
574
573
  }
575
574
  n.length && t.em.setSelected(n, { fromCell: !0 });
576
- }, Fe = "tableComponent", Ge = function(e, t = {}) {
575
+ }, Fe = "tableComponent", We = function(e, t = {}) {
577
576
  const o = {
578
577
  block: {},
579
578
  ...t
@@ -660,12 +659,12 @@ const se = "Cell settings", Se = "Merge cells", De = "Split cell", Te = (e) => e
660
659
  ],
661
660
  components: He(P, { rows: 5 }),
662
661
  contextMenu: ({ items: c, editor: a, component: r }) => [
663
- ...j({ editor: a, component: r, opts: o }),
662
+ ...K({ editor: a, component: r, opts: o }),
664
663
  ...c
665
664
  ]
666
665
  }
667
666
  }
668
- }), l.addType(W, {
667
+ }), l.addType(G, {
669
668
  model: {
670
669
  defaults: {
671
670
  icon: d.tableHead,
@@ -756,7 +755,7 @@ const se = "Cell settings", Se = "Merge cells", De = "Split cell", Te = (e) => e
756
755
  const r = e.getSelectedAll(), h = !!((g = a == null ? void 0 : a.event) != null && g.shiftKey);
757
756
  if (r.length < 2 || !h || a.fromCell) return;
758
757
  const v = r.map((f) => f.is(b) ? f : f.closestType(b)).filter(Boolean);
759
- v.length === r.length && Ze(v);
758
+ v.length === r.length && _e(v);
760
759
  }, 0);
761
760
  e.on("component:select", n), me({
762
761
  editor: e,
@@ -766,7 +765,7 @@ const se = "Cell settings", Se = "Merge cells", De = "Split cell", Te = (e) => e
766
765
  e.off("component:select", n), e.Blocks.remove(p), ye.forEach((c) => l.removeType(c));
767
766
  }
768
767
  });
769
- }, $e = fe(Ge);
768
+ }, Ge = fe(We);
770
769
  export {
771
- $e as default
770
+ Ge as default
772
771
  };
@@ -1 +1 @@
1
- (function(V,p){typeof exports=="object"&&typeof module<"u"?module.exports=p(require("react")):typeof define=="function"&&define.amd?define(["react"],p):(V=typeof globalThis<"u"?globalThis:V||self,V.StudioSdkPlugins_tableComponent=p())})(this,function(){"use strict";function V(e,t,o){let l,s,n,c,a;const i=t;function d(){const u=Date.now()-c;u<i&&u>=0?l=setTimeout(d,i-u):(l=null,a=e.apply(n,s),n=s=null)}const v=function(){return n=this,s=arguments,c=Date.now(),l||(l=setTimeout(d,i)),a};return v.clear=function(){l&&(clearTimeout(l),l=null)},v.flush=function(){l&&(a=e.apply(n,s),n=s=null,clearTimeout(l),l=null)},v}const p="app.grapesjs.com",S="app-stage.grapesjs.com",T=[p,S,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],ie="license:check:start",re="license:check:end",D=()=>typeof window<"u",de=({isDev:e,isStage:t})=>`${e?"":`https://${t?S:p}`}/api`,he=()=>{const e=D()&&window.location.hostname;return!!e&&(T.includes(e)||T.some(t=>e.endsWith(t)))},ve=()=>(D()&&window.location.hostname)===p;function E(e){return typeof e=="function"}var be={NODE_ENV:"production",NPM_PACKAGE_VERSION:"1.0.8",STUDIO_NPM_PACKAGE_VERSION:"1.0.25"};const ue=be.NODE_ENV!=="production";async function ge({path:e,method:t="GET",headers:o={},body:l}){const n=`${de({isDev:ue,isStage:!ve()})}${e}`,c={method:t,headers:{"Content-Type":"application/json",...o}};l&&(c.body=JSON.stringify(l));const a=await fetch(n,c);if(!a.ok)throw new Error(`HTTP error! status: ${a.status}`);return a.json()}function fe(e){const t=e;return t.init=o=>l=>e(l,o),t}const pe=e=>fe(e);async function me({editor:e,pluginName:t,licenseKey:o,cleanup:l}){let s=!1;const n=he();e.on(ie,()=>{s=!0}),e.on(re,({sdkLicense:c})=>{c||l()}),setTimeout(async()=>{if(!s){if(n)return;o&&await we({licenseKey:o,pluginName:t})||l()}},2e3)}async function we({licenseKey:e,pluginName:t}){try{const o=await ge({path:`/sdk/${e}`,method:"POST",body:JSON.stringify({d:window.location.hostname,pn:t})}),{license:l}=o.result||{};return!!l}catch(o){return console.error("Error during SDK license check:",o),!1}}var L=(e=>(e.toastAdd="studio:toastAdd",e.dialogOpen="studio:dialogOpen",e.dialogClose="studio:dialogClose",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.projectFiles="studio:projectFiles",e.canvasReload="studio:canvasReload",e.getBlocksPanel="studio:getBlocksPanel",e.setBlocksPanel="studio:setBlocksPanel",e.contextMenuComponent="studio:contextMenuComponent",e.layoutAdd="studio:layoutAdd",e.layoutRemove="studio:layoutRemove",e.layoutToggle="studio:layoutToggle",e))(L||{}),r=(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))(r||{});const h={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",N="thead",_="tfoot",A="tbody",g="row",b="cell",B="clipboardTable",ye=[f,N,_,A,g,b],R=e=>e.em.get(B)||[],Ce=e=>e.every(t=>t.is(b)),k=(e,t)=>{const{editor:o,event:l,opts:s}=e,n=l.currentTarget||l.target,{x:c,y:a,width:i,height:d}=n.getBoundingClientRect(),v={style:{width:240,height:300},placer:{type:"popover",closeOnClickAway:!0,x:c,y:a,w:i,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};E(s.openSettings)?s.openSettings({...e,layoutProps:v}):o.runCommand(L.layoutToggle,v)},He=(e,{rows:t=1,cells:o=5,text:l}={})=>({type:e,components:Array.from(Array(t).keys()).map(s=>({type:g,components:Array.from(Array(o).keys()).map(n=>({type:b,components:l?{type:"text",content:E(l)?l({y:s,x:n}):l}:void 0}))}))}),O="Table settings",Z=e=>{const{component:t}=e;return t.is(f)?t:t.closestType(f)},Ve=e=>{var t;(t=Z(e))==null||t.remove(e.opts)},Re=e=>{const t=Z(e);t&&(e.editor.select(t),k(e,{id:"tableSettings",header:{label:O}}))},F=e=>[{id:r.table,icon:h[r.table],label:"Table",items:[{id:r.tableSettings,label:O,icon:h[r.tableSettings],onClick:({event:o})=>Re({...e,event:o})},{id:r.tableDelete,label:"Delete table",icon:h[r.tableDelete],onClick:()=>Ve(e)}]}],G=({editor:e})=>{const t=R(e);return t.length&&Ce(t)},W=({component:e,editor:t,after:o})=>{if(!e.is(b))return;const l=e.closestType(f),s=e.closestType(g),n=e.index()+(o?1:0);l==null||l.findType(g).forEach(a=>a.append({type:b},{at:n}));const c=s==null?void 0:s.components().at(n);c&&t.select(c)},$=({component:e,opts:t})=>{if(!e.is(b))return;const o=e.closestType(f),l=e.index();o==null||o.findType(g).forEach(s=>{var n;return(n=s.components().at(l))==null?void 0:n.remove(t)})},j=({component:e,editor:t})=>{if(!e.is(b))return;const o=e.closestType(f),l=e.index(),s=(o==null?void 0:o.findType(g).map(n=>n.components().at(l)))||[];s.length&&t.em.set(B,s)},K=e=>{const{component:t,editor:o,after:l}=e;if(!t.is(b)||!G(e))return;const s=R(o),n=t.closestType(f),c=t.index()+(l?1:0);n==null||n.findType(g).forEach((a,i)=>{const d=s[i],v=(d==null?void 0:d.clone())||{type:b};a.append(v,{at:c})})},ze=e=>{const{component:t}=e;t.is(b)&&(j(e),$({...e,opts:{temporary:!0}}))},Pe=e=>{const t=G(e);return[{id:r.tableColumnItems,icon:h[r.tableColumn],label:"Column",items:[{id:r.tableColumnInsertBefore,label:"Insert column before",icon:h[r.tableColumnInsertBefore],onClick:()=>W(e)},{id:r.tableColumnInsertAfter,label:"Insert column after",icon:h[r.tableColumnInsertAfter],onClick:()=>W({...e,after:!0})},{id:r.tableColumnDelete,label:"Delete column",icon:h[r.tableColumnDelete],onClick:()=>$(e)},{id:r.tableColumnCut,label:"Cut column",icon:h[r.tableColumnCut],onClick:()=>ze(e)},{id:r.tableColumnCopy,label:"Copy column",icon:h[r.tableColumnCopy],onClick:()=>j(e)},{id:r.tableColumnPasteBefore,label:"Paste column before",icon:h[r.tableColumnPasteBefore],disabled:!t,onClick:()=>K(e)},{id:r.tableColumnPasteAfter,label:"Paste column after",icon:h[r.tableColumnPasteAfter],disabled:!t,onClick:()=>K({...e,after:!0})}]}]},U="Row settings",Ae=e=>e.every(t=>t.is(g)),w=e=>{const{component:t}=e,o=t.is(b),l=t.is(g);if(!(!o&&!l))return l?t:t.closestType(g)},J=e=>{const{component:t,editor:o,after:l}=e,s=w(e);if(!s)return;const n=s.index()+(l?1:0),c=s.components().length,a=Array.from(Array(c).keys()).map(()=>({type:b})),i=s.parent();if(i){const d=i.append({type:g,components:a},{at:n})[0];if(t.is(b)&&d){const v=t.index(),u=d.components().at(v);u&&o.select(u)}}},X=e=>{var t;(t=w(e))==null||t.remove(e.opts)},Y=e=>{const t=w(e);t&&e.editor.em.set(B,[t])},q=e=>{var a;const{editor:t,after:o}=e,l=w(e);if(!l||!Q(e))return;const n=R(t)[0],c=l.index()+(o?1:0);n&&((a=l.parent())==null||a.append(n.clone(),{at:c}))},Be=e=>{w(e)&&(Y(e),X({...e,opts:{temporary:!0}}))},Q=({editor:e})=>{const t=R(e);return t.length&&Ae(t)},ke=e=>{const t=w(e);t&&(e.editor.select(t),k(e,{id:"tableRowSettings",header:{label:U}}))},ee=e=>{const t=Q(e);return[{id:r.tableRowItems,icon:h[r.tableRowProperties],label:"Row",items:[{id:r.tableRowInsertBefore,label:"Insert row before",icon:h[r.tableRowInsertBefore],onClick:()=>J(e)},{id:r.tableRowInsertAfter,label:"Insert row after",icon:h[r.tableRowInsertAfter],onClick:()=>J({...e,after:!0})},{id:r.tableRowDelete,label:"Delete row",icon:h[r.tableRowDelete],onClick:()=>X(e)},{id:r.tableRowProperties,label:U,icon:h[r.tableRowProperties],onClick:({event:l})=>ke({...e,event:l})},{id:r.tableRowCut,label:"Cut row",icon:h[r.tableRowCut],onClick:()=>Be(e)},{id:r.tableRowCopy,label:"Copy row",icon:h[r.tableRowCopy],onClick:()=>Y(e)},{id:r.tableRowPasteBefore,label:"Paste row before",icon:h[r.tableRowPasteBefore],disabled:!t,onClick:()=>q(e)},{id:r.tableRowPasteAfter,label:"Paste row after",icon:h[r.tableRowPasteAfter],disabled:!t,onClick:()=>q({...e,after:!0})}]},...F(e)]},x=e=>{const t=e.attributes.attributes||{},o=parseInt(`${t.rowspan||1}`,10),l=parseInt(`${t.colspan||1}`,10);return{rowspan:o,colspan:l}};function te(e){const t=[];return e.components().forEach((o,l)=>{o.components().each((s,n)=>{const{rowspan:c,colspan:a}=x(s);if(t[l])for(;t[l][n];)n++;for(let i=l;i<l+c;i++){t[i]||(t[i]=[]);for(let d=n;d<n+a;d++)t[i][d]={real:i===l&&d===n,cell:s,rowspan:c,colspan:a}}})}),t}function y(e,t,o){var l;return(l=e[o])==null?void 0:l[t]}const I=e=>e.closestType(g);function xe(e,{x:t,y:o,rows:l,cols:s}){var a;let n=I(e[o][t].cell),c;for(let i=1;i<=l;i++)if(n=(a=n==null?void 0:n.parent())==null?void 0:a.components().at(n.index()+1),n){for(c=t;c>=0;c--){const{cell:d}=e[o+i][c],v=I(d);if(v===n){for(let u=1;u<=s;u++){const m=d.index();v.append({type:b},{at:m+1})}break}}if(c===-1){const v=n.components().at(0).index();for(let u=1;u<=s;u++)n.append({type:b},{at:v})}}}function le(e){for(let t=0;t<e.length;t++)for(let o=0;o<e[t].length;o++){const s=e[t][o].cell;if(s.em.selected.hasComponent(s)){const{rowspan:n,colspan:c}=x(s);if(c>1||n>1){s.addAttributes({colspan:1,rowspan:1});for(let a=0;a<c-1;a++){const i=s.index();I(s).append({type:b},{at:i+1})}xe(e,{x:o,y:t,rows:n-1,cols:c})}}}}function Ie(e){const t=[];e.components().forEach(o=>{o.components().length||t.push(o)}),t.forEach(o=>o.remove())}const z=(e,t={})=>{var c;const o=te(e),{em:l}=e;let s,n;for(let a=0;a<o.length;a++)for(let i=0;i<o[a].length;i++){const d=o[a][i];if((c=t.selected)!=null&&c.includes(d.cell)||l.selected.hasComponent(d.cell)){const v={x:i,y:a};s||(s=v),n=v}}return{grid:o,startPos:s,endPos:n}};function Me(e,t={}){const o=z(e),{startPos:l,endPos:s}=o;let{grid:n}=o;const{em:c}=e;if(!l||!s)return;const a=l.x,i=l.y,d=s.x,v=s.y,u=y(n,a,i),m=y(n,d,v);if(u&&m){le(n),n=te(e);const se=[],P=y(n,a,i).cell;P.addAttributes({colspan:d-a+1,rowspan:v-i+1});for(let H=i;H<=v;H++)for(let M=a;M<=d;M++){const ae=y(n,M,H);if(!ae)continue;const{cell:ce}=ae;ce!==P&&se.push(ce)}se.forEach(H=>{t.mergeContent&&P.append(H.components().models),H.remove()}),c.setSelected(P),Ie(e)}}const oe="Cell settings",Se="Merge cells",Te="Split cell",De=e=>e.closestType(g),C=e=>{var t;return(t=De(e))==null?void 0:t.parent()},Ee=e=>{const t=e.editor.getSelectedAll(),o=C(t[0]),l=t[0];if(!o||!(l!=null&&l.is(b))||t.length>1)return!1;const{rowspan:s,colspan:n}=x(l);return!(n<2&&s<2)},Le=e=>{const o=e.editor.getSelectedAll()[0],l=C(o),{grid:s}=z(l);le(s)},ne=e=>{const t=e.editor.getSelectedAll(),o=C(t[0]);if(!o||t.length<2||t.some(a=>!a.is(b)||C(a)!==o))return!1;const{grid:l,startPos:s,endPos:n}=z(o),{em:c}=o;if(!s||!n)return!1;for(let a=s.y;a<=n.y;a++)for(let i=s.x;i<=n.x;i++){const d=y(l,i,a);if(!d||!c.selected.hasComponent(d.cell))return!1}return!0},Ne=e=>{const{editor:t}=e;if(!ne(e))return;const o=t.getSelectedAll(),l=C(o[0]);Me(l,{mergeContent:!0})},_e=e=>{k(e,{id:"tableCellSettings",header:{label:oe}})},Oe=e=>[{id:r.tableCellItems,icon:h[r.tableCellProperties],label:"Cell",items:[{id:r.tableCellProperties,label:oe,icon:h[r.tableCellProperties],onClick:({event:o})=>_e({...e,event:o})},{id:r.tableCellMerge,label:Se,icon:h[r.tableCellMerge],onClick:()=>Ne(e),disabled:!ne(e)},{id:r.tableCellSplit,label:Te,icon:h[r.tableCellSplit],onClick:()=>Le(e),disabled:!Ee(e)}]},...Pe(e),...ee(e)],Ze=e=>{const t=e[0]&&C(e[0]);if(!t)return;const{grid:o,startPos:l,endPos:s}=z(t,{selected:e});if(!l||!s)return;const n=[];for(let c=l.y;c<=s.y;c++)for(let a=l.x;a<=s.x;a++){const i=y(o,a,c);i&&n.push(i.cell)}n.length&&t.em.setSelected(n,{fromCell:!0})},Fe="tableComponent";return pe(function(e,t={}){const o={block:{},...t},{Components:l}=e,s={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:h.table,category:"Extra",content:{type:f,style:{width:"100%"}},select:!0,...o.block},model:{defaults:{emptyState:!0,highlightable:!1,icon:h.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:i}){const d=c.find("caption")[0];a?!d&&c.append({type:"text",tagName:"caption",components:{type:"textnode",content:"Caption"}}):d==null||d.remove(),i(),e.refresh({tools:!0})},getValue(c){return!!c.component.find("caption")[0]}}],components:He(A,{rows:5}),contextMenu:({items:c,editor:a,component:i})=>[...F({editor:a,component:i,opts:o}),...c]}}}),l.addType(N,{model:{defaults:{icon:h.tableHead,...s}}}),l.addType(_,{model:{defaults:{icon:h.tableFoot,...s}}}),l.addType(A,{model:{defaults:{icon:h.tableRowProperties,...s}}}),l.addType(g,{model:{defaults:{icon:h.tableRowProperties,emptyState:!0,highlightable:!1,stylable:["height","text-align","border-width","border-style","border-color"],traits:[],contextMenu:({items:c,editor:a,component:i})=>[...ee({editor:a,component:i,opts:o}),...c]}}}),l.addType(b,{model:{defaults:{icon:h.tableCellProperties,emptyState:{styleOut:"height: 1px"},stylable:["width","height","padding","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:i})=>[...Oe({editor:a,component:i,opts:o}),...c]}}});const n=V((c,a)=>{var u;const i=e.getSelectedAll(),d=!!((u=a==null?void 0:a.event)!=null&&u.shiftKey);if(i.length<2||!d||a.fromCell)return;const v=i.map(m=>m.is(b)?m:m.closestType(b)).filter(Boolean);v.length===i.length&&Ze(v)},0);e.on("component:select",n),me({editor:e,licenseKey:o.licenseKey,pluginName:Fe,cleanup:()=>{e.off("component:select",n),e.Blocks.remove(f),ye.forEach(c=>l.removeType(c))}})})});
1
+ (function(V,p){typeof exports=="object"&&typeof module<"u"?module.exports=p():typeof define=="function"&&define.amd?define(p):(V=typeof globalThis<"u"?globalThis:V||self,V.StudioSdkPlugins_tableComponent=p())})(this,function(){"use strict";function V(e,t,o){let l,s,n,c,a;const i=t;function h(){const u=Date.now()-c;u<i&&u>=0?l=setTimeout(h,i-u):(l=null,a=e.apply(n,s),n=s=null)}const v=function(){return n=this,s=arguments,c=Date.now(),l||(l=setTimeout(h,i)),a};return v.clear=function(){l&&(clearTimeout(l),l=null)},v.flush=function(){l&&(a=e.apply(n,s),n=s=null,clearTimeout(l),l=null)},v}const p="app.grapesjs.com",S="app-stage.grapesjs.com",T=[p,S,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],ie="license:check:start",re="license:check:end",D=()=>typeof window<"u",he=({isDev:e,isStage:t})=>`${e?"":`https://${t?S:p}`}/api`,de=()=>{const e=D()&&window.location.hostname;return!!e&&(T.includes(e)||T.some(t=>e.endsWith(t)))},ve=()=>(D()&&window.location.hostname)===p;function E(e){return typeof e=="function"}var be={};const ue=be.NODE_ENV!=="production";async function ge({path:e,method:t="GET",headers:o={},body:l}){const n=`${he({isDev:ue,isStage:!ve()})}${e}`,c={method:t,headers:{"Content-Type":"application/json",...o}};l&&(c.body=JSON.stringify(l));const a=await fetch(n,c);if(!a.ok)throw new Error(`HTTP error! status: ${a.status}`);return a.json()}function fe(e){const t=e;return t.init=o=>l=>e(l,o),t}const pe=e=>fe(e);async function me({editor:e,pluginName:t,licenseKey:o,cleanup:l}){let s=!1;const n=de();e.on(ie,()=>{s=!0}),e.on(re,({sdkLicense:c})=>{c||l()}),setTimeout(async()=>{if(!s){if(n)return;o&&await we({licenseKey:o,pluginName:t})||l()}},2e3)}async function we({licenseKey:e,pluginName:t}){try{const o=await ge({path:`/sdk/${e}`,method:"POST",body:JSON.stringify({d:window.location.hostname,pn:t})}),{license:l}=o.result||{};return!!l}catch(o){return console.error("Error during SDK license check:",o),!1}}var L=(e=>(e.toastAdd="studio:toastAdd",e.dialogOpen="studio:dialogOpen",e.dialogClose="studio:dialogClose",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.projectFiles="studio:projectFiles",e.canvasReload="studio:canvasReload",e.getBlocksPanel="studio:getBlocksPanel",e.setBlocksPanel="studio:setBlocksPanel",e.contextMenuComponent="studio:contextMenuComponent",e.layoutAdd="studio:layoutAdd",e.layoutRemove="studio:layoutRemove",e.layoutToggle="studio:layoutToggle",e))(L||{}),r=(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))(r||{});const d={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",N="thead",Z="tfoot",A="tbody",g="row",b="cell",B="clipboardTable",ye=[f,N,Z,A,g,b],R=e=>e.em.get(B)||[],Ce=e=>e.every(t=>t.is(b)),k=(e,t)=>{const{editor:o,event:l,opts:s}=e,n=l.currentTarget||l.target,{x:c,y:a,width:i,height:h}=n.getBoundingClientRect(),v={style:{width:240,height:300},placer:{type:"popover",closeOnClickAway:!0,x:c,y:a,w:i,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};E(s.openSettings)?s.openSettings({...e,layoutProps:v}):o.runCommand(L.layoutToggle,v)},He=(e,{rows:t=1,cells:o=5,text:l}={})=>({type:e,components:Array.from(Array(t).keys()).map(s=>({type:g,components:Array.from(Array(o).keys()).map(n=>({type:b,components:l?{type:"text",content:E(l)?l({y:s,x:n}):l}:void 0}))}))}),O="Table settings",_=e=>{const{component:t}=e;return t.is(f)?t:t.closestType(f)},Ve=e=>{var t;(t=_(e))==null||t.remove(e.opts)},Re=e=>{const t=_(e);t&&(e.editor.select(t),k(e,{id:"tableSettings",header:{label:O}}))},F=e=>[{id:r.table,icon:d[r.table],label:"Table",items:[{id:r.tableSettings,label:O,icon:d[r.tableSettings],onClick:({event:o})=>Re({...e,event:o})},{id:r.tableDelete,label:"Delete table",icon:d[r.tableDelete],onClick:()=>Ve(e)}]}],W=({editor:e})=>{const t=R(e);return t.length&&Ce(t)},G=({component:e,editor:t,after:o})=>{if(!e.is(b))return;const l=e.closestType(f),s=e.closestType(g),n=e.index()+(o?1:0);l==null||l.findType(g).forEach(a=>a.append({type:b},{at:n}));const c=s==null?void 0:s.components().at(n);c&&t.select(c)},$=({component:e,opts:t})=>{if(!e.is(b))return;const o=e.closestType(f),l=e.index();o==null||o.findType(g).forEach(s=>{var n;return(n=s.components().at(l))==null?void 0:n.remove(t)})},j=({component:e,editor:t})=>{if(!e.is(b))return;const o=e.closestType(f),l=e.index(),s=(o==null?void 0:o.findType(g).map(n=>n.components().at(l)))||[];s.length&&t.em.set(B,s)},U=e=>{const{component:t,editor:o,after:l}=e;if(!t.is(b)||!W(e))return;const s=R(o),n=t.closestType(f),c=t.index()+(l?1:0);n==null||n.findType(g).forEach((a,i)=>{const h=s[i],v=(h==null?void 0:h.clone())||{type:b};a.append(v,{at:c})})},ze=e=>{const{component:t}=e;t.is(b)&&(j(e),$({...e,opts:{temporary:!0}}))},Pe=e=>{const t=W(e);return[{id:r.tableColumnItems,icon:d[r.tableColumn],label:"Column",items:[{id:r.tableColumnInsertBefore,label:"Insert column before",icon:d[r.tableColumnInsertBefore],onClick:()=>G(e)},{id:r.tableColumnInsertAfter,label:"Insert column after",icon:d[r.tableColumnInsertAfter],onClick:()=>G({...e,after:!0})},{id:r.tableColumnDelete,label:"Delete column",icon:d[r.tableColumnDelete],onClick:()=>$(e)},{id:r.tableColumnCut,label:"Cut column",icon:d[r.tableColumnCut],onClick:()=>ze(e)},{id:r.tableColumnCopy,label:"Copy column",icon:d[r.tableColumnCopy],onClick:()=>j(e)},{id:r.tableColumnPasteBefore,label:"Paste column before",icon:d[r.tableColumnPasteBefore],disabled:!t,onClick:()=>U(e)},{id:r.tableColumnPasteAfter,label:"Paste column after",icon:d[r.tableColumnPasteAfter],disabled:!t,onClick:()=>U({...e,after:!0})}]}]},K="Row settings",Ae=e=>e.every(t=>t.is(g)),w=e=>{const{component:t}=e,o=t.is(b),l=t.is(g);if(!(!o&&!l))return l?t:t.closestType(g)},J=e=>{const{component:t,editor:o,after:l}=e,s=w(e);if(!s)return;const n=s.index()+(l?1:0),c=s.components().length,a=Array.from(Array(c).keys()).map(()=>({type:b})),i=s.parent();if(i){const h=i.append({type:g,components:a},{at:n})[0];if(t.is(b)&&h){const v=t.index(),u=h.components().at(v);u&&o.select(u)}}},X=e=>{var t;(t=w(e))==null||t.remove(e.opts)},Y=e=>{const t=w(e);t&&e.editor.em.set(B,[t])},q=e=>{var a;const{editor:t,after:o}=e,l=w(e);if(!l||!Q(e))return;const n=R(t)[0],c=l.index()+(o?1:0);n&&((a=l.parent())==null||a.append(n.clone(),{at:c}))},Be=e=>{w(e)&&(Y(e),X({...e,opts:{temporary:!0}}))},Q=({editor:e})=>{const t=R(e);return t.length&&Ae(t)},ke=e=>{const t=w(e);t&&(e.editor.select(t),k(e,{id:"tableRowSettings",header:{label:K}}))},ee=e=>{const t=Q(e);return[{id:r.tableRowItems,icon:d[r.tableRowProperties],label:"Row",items:[{id:r.tableRowInsertBefore,label:"Insert row before",icon:d[r.tableRowInsertBefore],onClick:()=>J(e)},{id:r.tableRowInsertAfter,label:"Insert row after",icon:d[r.tableRowInsertAfter],onClick:()=>J({...e,after:!0})},{id:r.tableRowDelete,label:"Delete row",icon:d[r.tableRowDelete],onClick:()=>X(e)},{id:r.tableRowProperties,label:K,icon:d[r.tableRowProperties],onClick:({event:l})=>ke({...e,event:l})},{id:r.tableRowCut,label:"Cut row",icon:d[r.tableRowCut],onClick:()=>Be(e)},{id:r.tableRowCopy,label:"Copy row",icon:d[r.tableRowCopy],onClick:()=>Y(e)},{id:r.tableRowPasteBefore,label:"Paste row before",icon:d[r.tableRowPasteBefore],disabled:!t,onClick:()=>q(e)},{id:r.tableRowPasteAfter,label:"Paste row after",icon:d[r.tableRowPasteAfter],disabled:!t,onClick:()=>q({...e,after:!0})}]},...F(e)]},x=e=>{const t=e.attributes.attributes||{},o=parseInt(`${t.rowspan||1}`,10),l=parseInt(`${t.colspan||1}`,10);return{rowspan:o,colspan:l}};function te(e){const t=[];return e.components().forEach((o,l)=>{o.components().each((s,n)=>{const{rowspan:c,colspan:a}=x(s);if(t[l])for(;t[l][n];)n++;for(let i=l;i<l+c;i++){t[i]||(t[i]=[]);for(let h=n;h<n+a;h++)t[i][h]={real:i===l&&h===n,cell:s,rowspan:c,colspan:a}}})}),t}function y(e,t,o){var l;return(l=e[o])==null?void 0:l[t]}const I=e=>e.closestType(g);function xe(e,{x:t,y:o,rows:l,cols:s}){var a;let n=I(e[o][t].cell),c;for(let i=1;i<=l;i++)if(n=(a=n==null?void 0:n.parent())==null?void 0:a.components().at(n.index()+1),n){for(c=t;c>=0;c--){const{cell:h}=e[o+i][c],v=I(h);if(v===n){for(let u=1;u<=s;u++){const m=h.index();v.append({type:b},{at:m+1})}break}}if(c===-1){const v=n.components().at(0).index();for(let u=1;u<=s;u++)n.append({type:b},{at:v})}}}function le(e){for(let t=0;t<e.length;t++)for(let o=0;o<e[t].length;o++){const s=e[t][o].cell;if(s.em.selected.hasComponent(s)){const{rowspan:n,colspan:c}=x(s);if(c>1||n>1){s.addAttributes({colspan:1,rowspan:1});for(let a=0;a<c-1;a++){const i=s.index();I(s).append({type:b},{at:i+1})}xe(e,{x:o,y:t,rows:n-1,cols:c})}}}}function Ie(e){const t=[];e.components().forEach(o=>{o.components().length||t.push(o)}),t.forEach(o=>o.remove())}const z=(e,t={})=>{var c;const o=te(e),{em:l}=e;let s,n;for(let a=0;a<o.length;a++)for(let i=0;i<o[a].length;i++){const h=o[a][i];if((c=t.selected)!=null&&c.includes(h.cell)||l.selected.hasComponent(h.cell)){const v={x:i,y:a};s||(s=v),n=v}}return{grid:o,startPos:s,endPos:n}};function Me(e,t={}){const o=z(e),{startPos:l,endPos:s}=o;let{grid:n}=o;const{em:c}=e;if(!l||!s)return;const a=l.x,i=l.y,h=s.x,v=s.y,u=y(n,a,i),m=y(n,h,v);if(u&&m){le(n),n=te(e);const se=[],P=y(n,a,i).cell;P.addAttributes({colspan:h-a+1,rowspan:v-i+1});for(let H=i;H<=v;H++)for(let M=a;M<=h;M++){const ae=y(n,M,H);if(!ae)continue;const{cell:ce}=ae;ce!==P&&se.push(ce)}se.forEach(H=>{t.mergeContent&&P.append(H.components().models),H.remove()}),c.setSelected(P),Ie(e)}}const oe="Cell settings",Se="Merge cells",Te="Split cell",De=e=>e.closestType(g),C=e=>{var t;return(t=De(e))==null?void 0:t.parent()},Ee=e=>{const t=e.editor.getSelectedAll(),o=C(t[0]),l=t[0];if(!o||!(l!=null&&l.is(b))||t.length>1)return!1;const{rowspan:s,colspan:n}=x(l);return!(n<2&&s<2)},Le=e=>{const o=e.editor.getSelectedAll()[0],l=C(o),{grid:s}=z(l);le(s)},ne=e=>{const t=e.editor.getSelectedAll(),o=C(t[0]);if(!o||t.length<2||t.some(a=>!a.is(b)||C(a)!==o))return!1;const{grid:l,startPos:s,endPos:n}=z(o),{em:c}=o;if(!s||!n)return!1;for(let a=s.y;a<=n.y;a++)for(let i=s.x;i<=n.x;i++){const h=y(l,i,a);if(!h||!c.selected.hasComponent(h.cell))return!1}return!0},Ne=e=>{const{editor:t}=e;if(!ne(e))return;const o=t.getSelectedAll(),l=C(o[0]);Me(l,{mergeContent:!0})},Ze=e=>{k(e,{id:"tableCellSettings",header:{label:oe}})},Oe=e=>[{id:r.tableCellItems,icon:d[r.tableCellProperties],label:"Cell",items:[{id:r.tableCellProperties,label:oe,icon:d[r.tableCellProperties],onClick:({event:o})=>Ze({...e,event:o})},{id:r.tableCellMerge,label:Se,icon:d[r.tableCellMerge],onClick:()=>Ne(e),disabled:!ne(e)},{id:r.tableCellSplit,label:Te,icon:d[r.tableCellSplit],onClick:()=>Le(e),disabled:!Ee(e)}]},...Pe(e),...ee(e)],_e=e=>{const t=e[0]&&C(e[0]);if(!t)return;const{grid:o,startPos:l,endPos:s}=z(t,{selected:e});if(!l||!s)return;const n=[];for(let c=l.y;c<=s.y;c++)for(let a=l.x;a<=s.x;a++){const i=y(o,a,c);i&&n.push(i.cell)}n.length&&t.em.setSelected(n,{fromCell:!0})},Fe="tableComponent";return pe(function(e,t={}){const o={block:{},...t},{Components:l}=e,s={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:d.table,category:"Extra",content:{type:f,style:{width:"100%"}},select:!0,...o.block},model:{defaults:{emptyState:!0,highlightable:!1,icon:d.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:i}){const h=c.find("caption")[0];a?!h&&c.append({type:"text",tagName:"caption",components:{type:"textnode",content:"Caption"}}):h==null||h.remove(),i(),e.refresh({tools:!0})},getValue(c){return!!c.component.find("caption")[0]}}],components:He(A,{rows:5}),contextMenu:({items:c,editor:a,component:i})=>[...F({editor:a,component:i,opts:o}),...c]}}}),l.addType(N,{model:{defaults:{icon:d.tableHead,...s}}}),l.addType(Z,{model:{defaults:{icon:d.tableFoot,...s}}}),l.addType(A,{model:{defaults:{icon:d.tableRowProperties,...s}}}),l.addType(g,{model:{defaults:{icon:d.tableRowProperties,emptyState:!0,highlightable:!1,stylable:["height","text-align","border-width","border-style","border-color"],traits:[],contextMenu:({items:c,editor:a,component:i})=>[...ee({editor:a,component:i,opts:o}),...c]}}}),l.addType(b,{model:{defaults:{icon:d.tableCellProperties,emptyState:{styleOut:"height: 1px"},stylable:["width","height","padding","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:i})=>[...Oe({editor:a,component:i,opts:o}),...c]}}});const n=V((c,a)=>{var u;const i=e.getSelectedAll(),h=!!((u=a==null?void 0:a.event)!=null&&u.shiftKey);if(i.length<2||!h||a.fromCell)return;const v=i.map(m=>m.is(b)?m:m.closestType(b)).filter(Boolean);v.length===i.length&&_e(v)},0);e.on("component:select",n),me({editor:e,licenseKey:o.licenseKey,pluginName:Fe,cleanup:()=>{e.off("component:select",n),e.Blocks.remove(f),ye.forEach(c=>l.removeType(c))}})})});
package/dist/utils.d.ts CHANGED
@@ -23,4 +23,5 @@ export declare function subscribeToLicenseCheck({ editor, pluginName, licenseKey
23
23
  licenseKey?: string;
24
24
  cleanup: () => void;
25
25
  }): Promise<void>;
26
+ export declare const elHasAttribute: (el: HTMLElement, attrName: string) => boolean;
26
27
  export declare const CLS_PREFIX = "gjs-plg-";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@grapesjs/studio-sdk-plugins",
3
- "version": "1.0.8",
3
+ "version": "1.0.9",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org"
6
6
  },