@grapesjs/studio-sdk-plugins 1.0.38 → 1.0.39-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/accordionComponent/index.cjs.js +5 -5
- package/dist/accordionComponent/index.es.js +70 -67
- package/dist/accordionComponent/index.js +39 -0
- package/dist/accordionComponent/index.umd.js +4 -4
- package/dist/aiChat/components/AiChatHeader.d.ts +4 -5
- package/dist/aiChat/components/AiChatInput/index.d.ts +4 -5
- package/dist/aiChat/components/AiChatMessage.d.ts +7 -8
- package/dist/aiChat/components/index.d.ts +1 -1
- package/dist/aiChat/components/utils.d.ts +1 -1
- package/dist/aiChat/index.cjs.js +10 -376
- package/dist/aiChat/index.es.js +4569 -28851
- package/dist/aiChat/index.js +10 -376
- package/dist/aiChat/index.umd.js +11 -377
- package/dist/aiChat/server/index.cjs.d.ts +0 -1
- package/dist/aiChat/server/index.cjs.js +45 -45
- package/dist/aiChat/server/index.d.ts +0 -1
- package/dist/aiChat/server/index.es.d.ts +0 -1
- package/dist/aiChat/server/index.es.js +371 -427
- package/dist/aiChat/server/index.js +45 -45
- package/dist/aiChat/server/index.umd.js +41 -41
- package/dist/aiChat/server/stream.test.d.ts +1 -0
- package/dist/aiChat/types.d.ts +18 -4
- package/dist/aiChat/typesSchema.d.ts +13 -0
- package/dist/animationComponent/index.cjs.js +3 -3
- package/dist/animationComponent/index.es.js +49 -46
- package/dist/animationComponent/index.js +519 -0
- package/dist/animationComponent/index.umd.js +3 -3
- package/dist/canvasAbsoluteMode/index.cjs.js +1 -1
- package/dist/canvasAbsoluteMode/index.es.js +115 -112
- package/dist/canvasAbsoluteMode/index.js +1 -0
- package/dist/canvasAbsoluteMode/index.umd.js +1 -1
- package/dist/canvasEmptyState/index.cjs.js +1 -1
- package/dist/canvasEmptyState/index.es.js +71 -68
- package/dist/canvasEmptyState/index.js +1 -0
- package/dist/canvasEmptyState/index.umd.js +1 -1
- package/dist/canvasFullSize/index.cjs.js +3 -3
- package/dist/canvasFullSize/index.es.js +69 -66
- package/dist/canvasFullSize/index.js +10 -0
- package/dist/canvasFullSize/index.umd.js +4 -4
- package/dist/canvasGridMode/index.cjs.js +7 -7
- package/dist/canvasGridMode/index.es.js +142 -139
- package/dist/canvasGridMode/index.js +26 -0
- package/dist/canvasGridMode/index.umd.js +7 -7
- package/dist/canvasScreenshot/index.cjs.js +1 -1
- package/dist/canvasScreenshot/index.es.js +78 -75
- package/dist/canvasScreenshot/index.js +1 -0
- package/dist/canvasScreenshot/index.umd.js +1 -1
- package/dist/dataSourceEjs/EjsExporter.d.ts +1 -1
- package/dist/dataSourceEjs/index.cjs.js +3 -3
- package/dist/dataSourceEjs/index.es.js +40 -37
- package/dist/dataSourceEjs/index.js +21 -0
- package/dist/dataSourceEjs/index.umd.js +3 -3
- package/dist/dataSourceHandlebars/HandlebarsExporter.d.ts +2 -2
- package/dist/dataSourceHandlebars/constants.d.ts +1 -1
- package/dist/dataSourceHandlebars/index.cjs.js +4 -4
- package/dist/dataSourceHandlebars/index.es.js +58 -55
- package/dist/dataSourceHandlebars/index.js +10 -0
- package/dist/dataSourceHandlebars/index.umd.js +2 -2
- package/dist/dialogComponent/index.cjs.js +11 -11
- package/dist/dialogComponent/index.es.js +72 -69
- package/dist/dialogComponent/index.js +59 -0
- package/dist/dialogComponent/index.umd.js +11 -11
- package/dist/flexComponent/index.cjs.js +6 -6
- package/dist/flexComponent/index.es.js +151 -142
- package/dist/flexComponent/index.js +33 -0
- package/dist/flexComponent/index.umd.js +8 -8
- package/dist/flexComponent/typesSchema.d.ts +1 -1
- package/dist/fsLightboxComponent/index.cjs.js +3 -3
- package/dist/fsLightboxComponent/index.es.js +93 -90
- package/dist/fsLightboxComponent/index.js +6 -0
- package/dist/fsLightboxComponent/index.umd.js +3 -3
- package/dist/googleFontsAssetProvider/index.cjs.js +1 -1
- package/dist/googleFontsAssetProvider/index.es.js +112 -109
- package/dist/googleFontsAssetProvider/index.js +1 -0
- package/dist/googleFontsAssetProvider/index.umd.js +1 -1
- package/dist/googleFontsAssetProvider/utils.d.ts +1 -1
- package/dist/iconifyComponent/index.cjs.js +2 -2
- package/dist/iconifyComponent/index.es.js +80 -77
- package/dist/iconifyComponent/index.js +3 -0
- package/dist/iconifyComponent/index.umd.js +2 -2
- package/dist/index.cjs.d.ts +1 -0
- package/dist/index.cjs.js +970 -82
- package/dist/index.d.ts +1 -0
- package/dist/index.es.d.ts +1 -0
- package/dist/index.es.js +7422 -6145
- package/dist/index.umd.js +975 -87
- package/dist/layoutSidebarButtons/index.cjs.js +1 -1
- package/dist/layoutSidebarButtons/index.es.js +95 -92
- package/dist/layoutSidebarButtons/index.js +1 -0
- package/dist/layoutSidebarButtons/index.umd.js +1 -1
- package/dist/lightGalleryComponent/index.cjs.js +1 -1
- package/dist/lightGalleryComponent/index.es.js +164 -161
- package/dist/lightGalleryComponent/index.js +1 -0
- package/dist/lightGalleryComponent/index.umd.js +1 -1
- package/dist/lightGalleryComponent/utils.d.ts +1 -1
- package/dist/linkImageComponent/index.cjs.js +2 -2
- package/dist/linkImageComponent/index.es.js +60 -57
- package/dist/linkImageComponent/index.js +12 -0
- package/dist/linkImageComponent/index.umd.js +2 -2
- package/dist/listPagesComponent/index.cjs.js +4 -4
- package/dist/listPagesComponent/index.es.js +57 -54
- package/dist/listPagesComponent/index.js +11 -0
- package/dist/listPagesComponent/index.umd.js +4 -4
- package/dist/listPagesComponent/utils.d.ts +1 -1
- package/dist/presetBlockLibrary/blocks.d.ts +6 -0
- package/dist/presetBlockLibrary/blocks.test.d.ts +2 -0
- package/dist/presetBlockLibrary/emailBlocks.d.ts +53 -0
- package/dist/presetBlockLibrary/index.cjs.d.ts +3 -0
- package/dist/presetBlockLibrary/index.cjs.js +889 -0
- package/dist/presetBlockLibrary/index.d.ts +3 -0
- package/dist/presetBlockLibrary/index.es.d.ts +3 -0
- package/dist/presetBlockLibrary/index.es.js +1408 -0
- package/dist/presetBlockLibrary/index.js +889 -0
- package/dist/presetBlockLibrary/index.test.d.ts +1 -0
- package/dist/presetBlockLibrary/index.umd.js +889 -0
- package/dist/presetBlockLibrary/shared.d.ts +3 -0
- package/dist/presetBlockLibrary/types.d.ts +24 -0
- package/dist/presetBlockLibrary/typesSchema.d.ts +47 -0
- package/dist/presetPrintable/index.cjs.js +3 -3
- package/dist/presetPrintable/index.es.js +133 -130
- package/dist/presetPrintable/index.js +32 -0
- package/dist/presetPrintable/index.umd.js +4 -4
- package/dist/prosemirror/index.cjs.js +8 -8
- package/dist/prosemirror/index.es.js +552 -549
- package/dist/prosemirror/index.js +10 -0
- package/dist/prosemirror/index.umd.js +9 -9
- package/dist/prosemirror/toolbar.d.ts +2 -2
- package/dist/prosemirror/types.d.ts +5 -5
- package/dist/rendererReact/index.cjs.js +1 -1
- package/dist/rendererReact/index.es.js +137 -134
- package/dist/rendererReact/index.js +1 -1
- package/dist/rendererReact/index.umd.js +1 -1
- package/dist/rteTinyMce/index.cjs.js +2 -2
- package/dist/rteTinyMce/index.es.js +74 -71
- package/dist/rteTinyMce/index.js +104 -0
- package/dist/rteTinyMce/index.umd.js +2 -2
- package/dist/shapeDividerComponent/index.cjs.js +4 -4
- package/dist/shapeDividerComponent/index.es.js +91 -88
- package/dist/shapeDividerComponent/index.js +97 -0
- package/dist/shapeDividerComponent/index.umd.js +4 -4
- package/dist/swiperComponent/index.cjs.js +7 -7
- package/dist/swiperComponent/index.es.js +95 -92
- package/dist/swiperComponent/index.js +45 -0
- package/dist/swiperComponent/index.umd.js +5 -5
- package/dist/tableComponent/index.cjs.js +1 -1
- package/dist/tableComponent/index.es.js +181 -178
- package/dist/tableComponent/index.js +1 -0
- package/dist/tableComponent/index.umd.js +1 -1
- package/dist/tableComponent/types.d.ts +3 -3
- package/dist/types.d.ts +14 -14
- package/dist/utils.d.ts +3 -2
- package/dist/utilsDataSources.d.ts +1 -1
- package/dist/youtubeAssetProvider/index.cjs.js +1 -1
- package/dist/youtubeAssetProvider/index.es.js +90 -87
- package/dist/youtubeAssetProvider/index.js +1 -0
- package/dist/youtubeAssetProvider/index.umd.js +1 -1
- package/package.json +182 -34
- package/dist/aiChat/server/models.d.ts +0 -15
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { BlockCategoryProperties, LibraryProperties } from 'grapesjs';
|
|
2
|
+
import { BlockProperties } from '../types';
|
|
3
|
+
import { PresetBlockLibraryOptions as PresetBlockLibraryOptionsSchema } from './typesSchema';
|
|
4
|
+
export type BlockWithoutContent = Omit<BlockProperties, 'content'>;
|
|
5
|
+
export interface PresetBlockDefinition {
|
|
6
|
+
label: string;
|
|
7
|
+
category: BlockCategoryProperties;
|
|
8
|
+
getContent: (props: {
|
|
9
|
+
getImageUrl: (fallbackUrl: string) => string;
|
|
10
|
+
}) => string;
|
|
11
|
+
}
|
|
12
|
+
export interface PresetBlockLibraryOptions extends Omit<PresetBlockLibraryOptionsSchema, 'category' | 'block' | 'defaultLibrary' | 'getImageUrl'> {
|
|
13
|
+
category?: (props: BlockCategoryProperties) => BlockCategoryProperties | false | void;
|
|
14
|
+
block?: (props: BlockProperties) => BlockProperties | false | void;
|
|
15
|
+
defaultLibrary?: (props: LibraryProperties) => LibraryProperties | false | void;
|
|
16
|
+
getImageUrl?: (props: {
|
|
17
|
+
block: BlockWithoutContent;
|
|
18
|
+
}) => string | void;
|
|
19
|
+
/**
|
|
20
|
+
* WIP: Avoid applying custom visual styles and rely on styles defined in the project.
|
|
21
|
+
* @default false
|
|
22
|
+
*/
|
|
23
|
+
withGlobalStyles?: boolean;
|
|
24
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { SDKPluginOptions } from '../utils';
|
|
2
|
+
export interface PresetBlockLibraryOptions extends SDKPluginOptions {
|
|
3
|
+
/**
|
|
4
|
+
* Include only specific built-in category ids.
|
|
5
|
+
* @examples
|
|
6
|
+
* ['preset-block-library-header', 'preset-block-library-footer']
|
|
7
|
+
*/
|
|
8
|
+
categories?: string[];
|
|
9
|
+
/**
|
|
10
|
+
* Filter or customize built-in categories.
|
|
11
|
+
* @examples
|
|
12
|
+
* props => {
|
|
13
|
+
* if (props.id === 'preset-block-library-footer') return false;
|
|
14
|
+
* return { ...props, icon: '<svg viewBox="0 0 24 24"></svg>' };
|
|
15
|
+
* }
|
|
16
|
+
*/
|
|
17
|
+
category?: '__fn__';
|
|
18
|
+
/**
|
|
19
|
+
* Filter or customize built-in blocks.
|
|
20
|
+
* @examples
|
|
21
|
+
* props => {
|
|
22
|
+
* if (props.id === 'preset-email-footer-simple') return false;
|
|
23
|
+
* return { ...props, label: 'Simple Footer Block' };
|
|
24
|
+
* }
|
|
25
|
+
*/
|
|
26
|
+
block?: '__fn__';
|
|
27
|
+
/**
|
|
28
|
+
* Customize default placeholder image URLs used by built-in blocks.
|
|
29
|
+
* @examples
|
|
30
|
+
* ({ block }) => `https://placehold.co/100x100/0f172a/f8fafc.png?text=${block.label}`
|
|
31
|
+
*/
|
|
32
|
+
getImageUrl?: '__fn__';
|
|
33
|
+
/**
|
|
34
|
+
* Customize the default library properties
|
|
35
|
+
* @examples
|
|
36
|
+
* // customize library properties
|
|
37
|
+
* props => ({ ...props, icon: '<svg viewBox="0 0 24 24"></svg>', label: 'Custom Library' })
|
|
38
|
+
* // or disable the default library
|
|
39
|
+
* () => false,
|
|
40
|
+
*/
|
|
41
|
+
defaultLibrary?: '__fn__';
|
|
42
|
+
/**
|
|
43
|
+
* Preselect the built-in library in the blocks panel when available.
|
|
44
|
+
* @default false
|
|
45
|
+
*/
|
|
46
|
+
selectLibrary?: boolean;
|
|
47
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";const C="app.grapesjs.com",z="app-stage.grapesjs.com",
|
|
1
|
+
"use strict";const C="app.grapesjs.com",z="app-stage.grapesjs.com",Z="app2.grapesjs.com",Q="app-stage2.grapesjs.com",I=[C,Z,z,Q,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io",".claudemcpcontent.com",".web-sandbox.oaiusercontent.com"],ee="license:check:end",te=()=>typeof window<"u",O=(e,n={})=>{const t=ae(e)?{id:e,src:e}:e;return new Promise((o,s)=>{var d,u;const{loadedScripts:a}=n,{id:c,src:i}=t,l=document.querySelector(`script[src="${i}"]`);if(l){if((d=n.onScript)==null||d.call(n,l),a&&!a.get(i)){l.addEventListener("load",()=>o(c)),l.addEventListener("error",()=>s(c));return}return o(c)}const g=window.define;window.define=void 0;const f=()=>{a==null||a.set(i,!0),window.define=g},r=document.createElement("script");r.src=i,r.onload=()=>{o(c),f()},r.onerror=()=>{s(c),f()},document.head.appendChild(r),(u=n.onScript)==null||u.call(n,r)})},oe=({isDev:e,isStage:n,isPlatform:t})=>`${e?"":`https://${n?z:C}`}/${t?"platform-api":"api"}`,ne=()=>{if(!te())return"";const{hostname:e}=window.location;if(e)return e;try{return window.parent.location.hostname||""}catch{return""}},se=()=>{const e=ne();return!!e&&(I.includes(e)||I.some(n=>e.endsWith(n)))},ae=e=>typeof e=="string";async function re({path:e,baseApiUrl:n,method:t="GET",headers:o={},params:s,body:a}){const i=`${n||oe({isDev:!1,isStage:!1})}${e}`,l={method:t,headers:{"Content-Type":"application/json",...o}};a&&(l.body=JSON.stringify(a));const g=s?new URLSearchParams(s).toString():"",f=g?`?${g}`:"",r=await fetch(`${i}${f}`,l);if(!r.ok)throw new Error(`HTTP error! status: ${r.status}`);return r.json()}var k=(e=>(e.free="free",e.startup="startup",e.business="business",e.enterprise="enterprise",e))(k||{}),j=(e=>(e.toastAdd="studio:toastAdd",e.toastRemove="studio:toastRemove",e.dialogOpen="studio:dialogOpen",e.dialogClose="studio:dialogClose",e.dialogExportCode="studio:dialogExportCode",e.dialogImportCode="studio:dialogImportCode",e.openEditCode="studio:openEditCode",e.openBlocks="studio:openBlocks",e.appendComponent="studio:appendComponent",e.sidebarLeftSet="studio:sidebarLeft:set",e.sidebarLeftGet="studio:sidebarLeft:get",e.sidebarLeftToggle="studio:sidebarLeft:toggle",e.sidebarRightSet="studio:sidebarRight:set",e.sidebarRightGet="studio:sidebarRight:get",e.sidebarRightToggle="studio:sidebarRight:toggle",e.sidebarTopSet="studio:sidebarTop:set",e.sidebarTopGet="studio:sidebarTop:get",e.sidebarTopToggle="studio:sidebarTop:toggle",e.sidebarBottomSet="studio:sidebarBottom:set",e.sidebarBottomGet="studio:sidebarBottom:get",e.sidebarBottomToggle="studio:sidebarBottom:toggle",e.symbolAdd="studio:symbolAdd",e.symbolDetach="studio:symbolDetach",e.symbolOverride="studio:symbolOverride",e.symbolPropagateStyles="studio:propagateStyles",e.getPagesConfig="studio:getPagesConfig",e.setPagesConfig="studio:setPagesConfig",e.getPageSettings="studio:getPageSettings",e.setPageSettings="studio:setPageSettings",e.clearPage="studio:clearPage",e.projectFiles="studio:projectFiles",e.validateCode="studio:validateCode",e.canvasReload="studio:canvasReload",e.getBlocksPanel="studio:getBlocksPanel",e.setBlocksPanel="studio:setBlocksPanel",e.getStateContextMenu="studio:getStateContextMenu",e.setStateContextMenu="studio:setStateContextMenu",e.contextMenuComponent="studio:contextMenuComponent",e.layoutAdd="studio:layoutAdd",e.layoutRemove="studio:layoutRemove",e.layoutToggle="studio:layoutToggle",e.layoutUpdate="studio:layoutUpdate",e.layoutGet="studio:layoutGet",e.layoutConfigGet="studio:layoutConfigGet",e.layoutConfigSet="studio:layoutConfigSet",e.layoutComponentAdd="studio:layoutComponentAdd",e.layoutComponentGet="studio:layoutComponentGet",e.layoutComponentRemove="studio:layoutComponentRemove",e.layoutComponentRender="studio:layoutComponentRender",e.getStateTheme="studio:getStateTheme",e.setStateTheme="studio:setStateTheme",e.settings="studio:settings",e.assetProviderGet="studio:assetProviderGet",e.assetProviderAdd="studio:assetProviderAdd",e.assetProviderRemove="studio:assetProviderRemove",e.fontGet="studio:fontGet",e.fontAdd="studio:fontAdd",e.fontRemove="studio:fontRemove",e.fontManagerOpen="studio:fontManagerOpen",e.menuFontLoad="studio:menuFontLoad",e.toggleStateDataSource="studio:toggleStateDataSource",e.getStateDataSource="studio:getStateDataSource",e.dataSourceSetGlobalData="studio:dataSourceSetGlobalData",e.dataSourceSetImporter="studio:dataSourceSetImporter",e.dataSourceSetExporter="studio:dataSourceSetExporter",e.setDragAbsolute="studio:setDragAbsolute",e))(j||{});const F={[k.free]:0,[k.startup]:10,[k.business]:20,[k.enterprise]:30};function ie(e,n){const t=e;return t.init=o=>{const s=a=>e(a,o);return s.__gjsPluginId=n,s},t}const ce=(e,n)=>ie(e,n);async function le({editor:e,plan:n,pluginName:t,licenseKey:o,onLicenseCheckResponse:s,cleanup:a}){let c="",i;const l=r=>{console.warn("Cleanup plugin:",t,"Reason:",r),a(e,t)},g=(r={})=>{var p;const{error:d,sdkLicense:u}=r,m=(p=r.plan)==null?void 0:p.category;if(!(u||r.license)||d)l(d||"Invalid license");else if(m){const h=F[n],L=F[m];h>L&&l({pluginRequiredPlan:n,licensePlan:m})}};e.Commands.has(j.settings)&&(i=e.runCommand(j.settings),c=(i==null?void 0:i.baseUrl)||"");const f=r=>{s==null||s(r),r&&g(r)};if(!i){e.onReady(async()=>{if(!se())if(o){const r=await de({licenseKey:o,pluginName:t,baseApiUrl:c});f(r)}else l("The `licenseKey` option not provided")});return}if(i.licensePlan||i.licenseError){const r=pe(i);f(r);return}e.on(ee,r=>f(r))}const pe=e=>({sdkLicense:e.license,license:e.license,error:e.licenseError,plan:e.licensePlan});async function de(e){const{licenseKey:n,pluginName:t,baseApiUrl:o}=e;try{return(await re({baseApiUrl:o,path:`/sdk/${n||"na"}`,method:"POST",params:{d:window.location.hostname,pn:t}})).result||{}}catch(s){return console.error("Error during SDK license check:",s),!1}}const ge=e=>n=>{var t;return((t=n.getAttribute)==null?void 0:t.call(n,V))===e},ue=(...e)=>(n,t)=>e.some(o=>t.is(o)),K=(e,n,t)=>{const{doc:o=document}=t,s=t.target||o.head,a=s.querySelector(`style[${e}]`)||o.createElement("style");a.setAttribute(e,"true"),a.innerHTML=n,!s.contains(a)&&s.appendChild(a)},he="gjs-plg-",q="data-gs-plg-",V="data-type-role";function N(e,n,t){let o,s,a,c,i;const l=n===void 0?100:n;function g(){const r=Date.now()-c;r<l&&r>=0?o=setTimeout(g,l-r):(o=null,i=e.apply(a,s),a=s=null)}const f=function(){return a=this,s=arguments,c=Date.now(),o||(o=setTimeout(g,l)),i};return f.clear=function(){o&&(clearTimeout(o),o=null)},f.flush=function(){o&&(i=e.apply(a,s),a=s=null,clearTimeout(o),o=null)},f}const A="page-break";var y=(e=>(e.A5="a5",e.A5Portrait="a5-portrait",e.A4="a4",e.A3="a3",e.B5="b5",e.B4="b4",e.letter="letter",e.legal="legal",e.ledger="ledger",e))(y||{});function H(e,n){const o={mm:3.7795275590551185,cm:37.79527559055118,in:96,pt:1.3333333333333333,pc:16};return o[n]?e*o[n]:null}const fe=(e,n)=>{const{name:t,id:o,width:s,height:a,unit:c}=e,{fixedHeight:i}=n,l=`${s}${c}`,g=`${a}${c}`;return{id:o||t.toLowerCase().replace(/\s/g,"-"),name:`${t} (${l} x ${g})`,sizeH:a,sizeW:s,sizeUnit:c,widthMedia:"",width:l,minHeight:i?"0":`${H(a,c)}px`,height:i?g:void 0}},M="page-breaks",D="gjs-page-breaks-spot",G=e=>e.type===M;function ve(e){const{Devices:n}=e,{height:t,minHeight:o}=n.getSelected().attributes,a=parseFloat(`${t&&t!=="auto"?t:o}`),c=e.getWrapper(),i=c==null?void 0:c.getEl(),l=[];if(!c||!i)return l;const g=i.getBoundingClientRect().height,r=c.findType(A).map(u=>u.getEl()).filter(Boolean).map(u=>({top:u.offsetTop,height:u.offsetHeight}));let d=0;for(;d<g;){const u=r.find(m=>m.top>d&&m.top<d+a);u?(d=u.top+u.height,l.push(u.top)):(d+=a,d<g&&l.push(d))}return l}function be(e,n){const{Canvas:t}=e,o=t.events,s=e.events;let a;const c=()=>{K(`${q}preset-printable-spots`,`.${D} {
|
|
2
2
|
position: absolute;
|
|
3
3
|
left: 0;
|
|
4
4
|
width: 100%;
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
right: 0;
|
|
17
17
|
transform: translate(100%, -50%);
|
|
18
18
|
}
|
|
19
|
-
`,{target:window.document.head})},i=()=>{if(n.enablePageBreaksSpot===!1)return;const p={id:M,type:M,component:e.getWrapper()};return t.getSpots(p).pop()||t.addSpot(p)},l=({spot:p})=>{const{spotEl:h}=p.attributes;!
|
|
19
|
+
`,{target:window.document.head})},i=()=>{if(n.enablePageBreaksSpot===!1)return;const p={id:M,type:M,component:e.getWrapper()};return t.getSpots(p).pop()||t.addSpot(p)},l=({spot:p})=>{const{spotEl:h}=p.attributes;!G(p)||!h||!a||a.removeChild(h)},g=({spot:p})=>{if(!G(p)||!a)return;let{spotEl:h}=p.attributes;h||(h=document.createElement("div"),h.className=`${D}__items`,p.set({spotEl:h})),a.appendChild(h)},f=({spot:p})=>{const{spotEl:h,pageBreaks:L=[]}=p.attributes;!G(p)||!h||!a||(Object.entries(p.getStyle()).forEach(([$,x])=>h.style.setProperty($,x)),h.innerHTML="",L.forEach(($,x)=>{const T=document.createElement("div");T.setAttribute("data-page-number",`${x+2}`),T.className=D,T.style.top=`${$}px`,h.appendChild(T)}))},r=N(()=>{if(e.em.destroyed)return;const p=i();p&&p.set({pageBreaks:ve(e),up:(p.attributes.up||0)+1})},150),d=N(r,200),u=()=>{a=t.getSpotsEl(),i()},m=()=>{const p=i();p&&p.set({up:(p.attributes.up||0)+1})},w=[["component:input",r],["frame:scroll",m],[s.update,r],[o.spotAdd,g],[o.spotUpdate,f],[o.spotRemove,l],[o.frameLoadBody,u]];return w.forEach(([p,h])=>e.on(p,h)),e.onReady(()=>{c(),new ResizeObserver(m).observe(t.getElement().parentElement)}),()=>{w.forEach(([p,h])=>e.off(p,h)),r.clear(),d.clear()}}var U=(e=>(e.print="presetPrintable:print",e))(U||{});const W=e=>new Promise(n=>{const t=document.createElement("iframe");t.style.cssText="position: absolute; width: 0; height: 0; border: 0; opacity: 0; pointer-events: none;",t.srcdoc=e.content,t.onload=()=>n(t),document.body.appendChild(t)});function me(e,n){const{Commands:t,Pages:o}=e;return t.add(U.print,async(s,a,c={})=>{const i={page:c.allPages?void 0:o.getSelected(),styles:"inline",optionsHtml:{exporter:null}},g=(await t.run(j.projectFiles,i)).filter(d=>d.filename.endsWith(".html")),f=g.map(d=>d.content).join('<div style="break-before: page;"></div>'),r=[];if(c.separatePrints)for(const d of g)r.push(await W(d));else r.push(await W({content:f,filename:"",mimeType:""}));for(const d of r){const u=d.contentWindow;u.focus(),u.print()}setTimeout(()=>r.forEach(d=>d.remove()),1e3)}),t.add("presetPrintable:exp",async s=>{await O("https://cdn.jsdelivr.net/npm/html2canvas@1.4.1/dist/html2canvas.min.js"),await O("https://cdn.jsdelivr.net/npm/jspdf@3.0.0/dist/jspdf.umd.min.js");const{Devices:a,Canvas:c}=s,{sizeW:i,sizeH:l,sizeUnit:g}=a.getSelected().attributes,f=c.getFrameEl().contentDocument,r="px",d=[H(i,g),H(l,g)],u=new window.jspdf.jsPDF({unit:r,format:d}),m=f.body;u.html(m,{callback:w=>w.save()})}),()=>{delete e.Commands.commands[U.print]}}function ye(e,n){const{blockPageBreak:t={}}=n,{Components:o,Blocks:s}=e,a="Page Break",c=`${he}${A}`;return o.addType(A,{block:t&&{label:a,media:'<svg viewBox="0 0 24 24"><path d="M18 20H6v-2H4v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2h-2v2M14 2H6a2 2 0 0 0-2 2v8h2V4h8v4h4v4h2V8l-6-6m-3 14H8v-2h3v2m5 0h-3v-2h3v2M3 14h3v2H3v-2m18 2h-3v-2h3v2Z"/></svg>',category:"Extra",select:!0,...t},isComponent:ge(A),model:{defaults:{name:a,classes:c,attributes:{[V]:A},emptyState:!0,stylable:!1,droppable:!1,draggable:ue("wrapper"),styles:`.${c} { break-before: page; }`,traits:[]}}}),()=>{o.removeType(A),s.remove(A)}}const Y="presetPrintable",we=k.free,Pe=function(e,n={}){var S;const t={selectedDevice:y.A4,...n},{Canvas:o,Devices:s,Blocks:a}=e,c=o.events,i=e.events,l=t.selectedDevice||s.getConfig().default,g=[{id:y.A5,name:"A5",width:148,height:210,unit:"mm"},{id:y.A5Portrait,name:"A5 Portrait",width:210,height:148,unit:"mm"},{id:y.A4,name:"A4",width:210,height:297,unit:"mm"},{id:y.A3,name:"A3",width:297,height:420,unit:"mm"},{id:y.B5,name:"B5",width:176,height:250,unit:"mm"},{id:y.B4,name:"B4",width:250,height:353,unit:"mm"},{id:y.letter,name:"Letter",width:8.5,height:11,unit:"in"},{id:y.legal,name:"Legal",width:8.5,height:14,unit:"in"},{id:y.ledger,name:"Ledger",width:11,height:17,unit:"in"}],r=(((S=t.devices)==null?void 0:S.call(t,{items:g}))||g).map(v=>fe(v,t));s.devices.reset(r);const d=l&&s.get(l)||s.getAll().at(0);s.select(d),["map","video"].forEach(v=>a.remove(v));const m=(v={})=>{const b="page-rule",{rules:P}=e.Css,{width:E,height:B,minHeight:R}=s.getSelected().attributes,J=B&&B!=="auto"?B:R,_=P.where({id:b}).pop(),X=_||P.add({id:b,selectors:[],selectorsAdd:"@page"},{at:0});(v.fromDeviceChange||!_)&&X.addStyle({size:`${E} ${J}`,...!_&&{margin:"0"}})},w=(v,b={})=>{const P=v.document,{minHeight:E}=s.getSelected().attributes,R=`
|
|
20
20
|
${!!parseFloat(`${E}`)?`
|
|
21
21
|
[data-gjs-type="wrapper"] { min-height: ${E}; }
|
|
22
22
|
`:`
|
|
@@ -29,4 +29,4 @@
|
|
|
29
29
|
height: 100dvh;
|
|
30
30
|
}
|
|
31
31
|
`}
|
|
32
|
-
`;K(`${q}preset-printable`,R,{doc:P,target:P.head}),m(b)};e.on(c.frameLoadBody,v=>{const b=v.window;if(w(b),t.fixedHeight){const E=v.model.getComponent().getEl();E==null||E.addEventListener("scroll",B=>{const R=B.target;R.scrollTop>0&&R.scrollTo(0,0)})}}),e.on(
|
|
32
|
+
`;K(`${q}preset-printable`,R,{doc:P,target:P.head}),m(b)};e.on(c.frameLoadBody,v=>{const b=v.window;if(w(b),t.fixedHeight){const E=v.model.getComponent().getEl();E==null||E.addEventListener("scroll",B=>{const R=B.target;R.scrollTop>0&&R.scrollTo(0,0)})}}),e.on(s.events.select,()=>{var b;const v=(b=o.getFrameEl().contentDocument)==null?void 0:b.defaultView;v&&w(v,{fromDeviceChange:!0})});const p=()=>{const b=e.Css.getRules().filter(P=>P.selectorsToString()==="body").pop();b==null||b.addStyle({"margin-top":"","margin-right":"","margin-bottom":"","margin-left":"",margin:"0"})},h=[[i.projectLoad,p]];h.forEach(([v,b])=>e.on(v,b));const L=be(e,t),$=me(e),x=ye(e,t);e.onReady(()=>{e.UndoManager.clear()});const T=()=>{h.forEach(([v,b])=>e.off(v,b)),L(),$(),x()};e.on(i.destroy,T),le({editor:e,licenseKey:t.licenseKey,plan:we,pluginName:Y,cleanup:T})},Ee=ce(Pe,Y);module.exports=Ee;
|