efficient-web-builder 74.7.0 → 74.9.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.
Files changed (55) hide show
  1. package/CHANGELOG.md +46 -0
  2. package/dist/editor/components/CustomHtmlCodeWindow.js +3 -3
  3. package/dist/editor/components/DuplicateToPageMenu.js +1 -1
  4. package/dist/editor/components/PagesPanel.js +1 -1
  5. package/dist/editor/components/PartSettingsPanel.js +1 -1
  6. package/dist/editor/components/PreviewPartAnchors.d.ts +2 -2
  7. package/dist/editor/components/PreviewPartAnchors.js +1 -1
  8. package/dist/editor/components/SectionTextPartBridge.js +1 -1
  9. package/dist/editor/components/SiteAccentField.js +1 -1
  10. package/dist/editor/components/SiteTextStylesField.d.ts +2 -0
  11. package/dist/editor/components/SiteTextStylesField.js +1 -1
  12. package/dist/editor/components/StandaloneSectionEditor.js +1 -1
  13. package/dist/editor/components/StorefrontEditor.js +1 -1
  14. package/dist/editor/components/storefront-editor.css +5 -5
  15. package/dist/editor/components/useSocialSettings.d.ts +2 -2
  16. package/dist/editor/lib/content/section-one-padding.d.ts +31 -0
  17. package/dist/editor/lib/content/section-one-padding.js +1 -0
  18. package/dist/editor/lib/document/blocks/general/index.d.ts +2 -2
  19. package/dist/editor/lib/document/box-fields.d.ts +1 -1
  20. package/dist/editor/lib/document/page-root.js +2 -2
  21. package/dist/format/lib/content/box-shape.d.ts +1 -1
  22. package/dist/format/lib/document/blocks/block-types.d.ts +2 -0
  23. package/dist/format/lib/document/passes/types.d.ts +2 -0
  24. package/dist/format/lib/document/style-text.d.ts +2 -0
  25. package/dist/format/lib/document/style-text.js +1 -1
  26. package/dist/format/lib/fonts.d.ts +43 -7
  27. package/dist/format/lib/fonts.js +1 -1
  28. package/dist/format/lib/site-font-faces.d.ts +9 -0
  29. package/dist/format/lib/site-font-faces.js +2 -0
  30. package/dist/format/lib/site-theme-row.d.ts +29 -1
  31. package/dist/format/lib/site-theme-row.js +1 -0
  32. package/dist/format/lib/sized-image.js +1 -1
  33. package/dist/format/lib/source-rules/one-dropdown.js +3 -3
  34. package/dist/format/lib/source-rules/page-picture-place.js +3 -3
  35. package/dist/format/lib/source-rules/published-mounts.js +38 -38
  36. package/dist/format/lib/source-rules/shape-rows-use-the-picker.js +2 -2
  37. package/dist/format/lib/source-rules/support/element-call.d.ts +5 -0
  38. package/dist/format/lib/source-rules/support/element-call.js +1 -0
  39. package/dist/format/lib/word-styles.d.ts +7 -6
  40. package/dist/format/lib/word-styles.js +1 -1
  41. package/dist/render/components/HeroPictures.d.ts +2 -2
  42. package/dist/render/components/PublishedPartStylesContext.js +1 -1
  43. package/dist/render/components/SiteFontsContext.d.ts +11 -0
  44. package/dist/render/components/SiteFontsContext.js +2 -0
  45. package/dist/render/lib/content/section-own-pads.d.ts +11 -3
  46. package/dist/render/lib/content/section-own-pads.js +1 -1
  47. package/dist/render/lib/document/part-styles.d.ts +7 -5
  48. package/dist/render/lib/document/part-styles.js +2 -2
  49. package/dist/render/lib/document/passes/section-padding.d.ts +2 -1
  50. package/dist/render/lib/document/passes/section-padding.js +1 -1
  51. package/dist/render/lib/text-styles/site-text-styles.d.ts +3 -3
  52. package/dist/render/lib/text-styles/site-text-styles.js +2 -2
  53. package/dist/routine-index.json +1 -1
  54. package/dist/value-index.json +1 -1
  55. package/package.json +1 -1
@@ -1,5 +1,5 @@
1
1
  import { type OwnFrame } from "../../content/section-padding.js";
2
- import type { BlockPass } from "../../../../format/lib/document/passes/types.js";
2
+ import type { BlockPass, PassBlock } from "../../../../format/lib/document/passes/types.js";
3
3
  type InnerPadding = {
4
4
  top: number;
5
5
  bottom: number;
@@ -15,6 +15,7 @@ export declare const PAD_ON_ROOT: ReadonlySet<string>;
15
15
  export declare const PADS_ITS_OWN_SPACE: ReadonlySet<string>;
16
16
  export declare const sectionPadding: BlockPass;
17
17
  export declare const OWN_PAD_FRAME: Readonly<Record<string, (props: Record<string, unknown>) => OwnFrame>>;
18
+ export declare function ownFrameOf(key: string, comp: Pick<PassBlock, "ownPad"> | undefined): ((props: Record<string, unknown>) => OwnFrame) | undefined;
18
19
  export declare const OWN_PAD_LABEL: Readonly<Record<string, string>>;
19
20
  export declare function withPadTotals(props: Record<string, unknown>, changed: Readonly<Record<string, unknown>> | undefined): Record<string, unknown>;
20
21
  export declare function olderPadNote(props: Record<string, unknown>, frame: number, side?: "top" | "bottom"): string | null;
@@ -1 +1 @@
1
- import{jsx as g}from"react/jsx-runtime";import{SideOnceClass as I}from"../../../components/SideSpaceOnce.js";import{HideTaker as C}from"../../../components/ViewHideRoot.js";import{LineChoice as F}from"../../../components/InBoxContext.js";import{isBackgroundBox as L}from"../../../../format/lib/content/box-background.js";import{boxSideSpaceOf as R}from"../../../../format/lib/content/box-side-space.js";import{SECTION_OWN_PADS as W}from"../../content/section-own-pads.js";import{BAND_PAD_KEYS as m,BAND_PAD_UNIT_KEY as y,BLOCK_PAD_FRAME as P,PAD_TOTAL_KEY as c,SECTION_PAD_KEYS as h,framePadAttrs as K,padTotalKeys as S,padValuesOf as H,sectionPadAttrs as j,tierFramesOf as D}from"../../content/section-padding.js";import{readPartStyle as v}from"../part-styles.js";import{CRUMB_PAD as Y,SPEC_PAD as M}from"../../../../format/lib/sections/strip-shape.js";import{say as U}from"../../../../format/lib/editor-words.js";import{sectionFillPassClass as E}from"../../../../format/lib/content/section-min-height.js";import{COPIES_IN_THE_BOX as $,drawsCopiesInTheBox as k}from"../../../../format/lib/content/copies-in-box.js";import{ownEntry as f}from"../../../../format/lib/own-entry.js";const B={ParagraphsA:{top:60,bottom:80},StatsParagraph:{top:120,bottom:120},Timeline:{top:120,bottom:120},Footprint:{top:120,bottom:120},TimelineTrack:{top:120,bottom:120},TitleWithButtons:{top:140,bottom:140},ProcessSteps:{top:120,bottom:120}},Pt=new Set(Object.keys(B));function A(t,e){return e?.innerPadding??f(B,t)}const _t=t=>A(t)??{},gt=t=>f({DetailRows:{top:100,bottom:100}},t),T=new Set(["Flex","Text","Heading","ImageBlock","ButtonBlock"]),V=new Set(["Divider"]),X=new Set(["Hero","HeroSingle","IntroBleed","CategoryBar","DocTabs"]),N=new Set(["ProductGrid"]);function b(t,e,n=!1,o){const a=t.render;t.render=r=>{if(e?.(r))return a(r);const s={...H(r,h,n),sideSpace:R(r.sideSpace)},d=o?K({values:s,frame:o(r)},!0).outer:j(s),i=a(r);if(!d)return i;const l=u=>g(I,{className:u?`${d.className} ${u}`:d.className,children:w=>g(C,{className:w,style:d.style,children:i})}),_=E(r,{atSectionLine:!0}),x=E(r);return _===x?l(_):g(F,{line:"by-box",draw:u=>l(u?x:_)})}}const mt={name:"sectionPadding",applies:(t,e,n)=>e.isSection(t)&&!X.has(t)&&!!n&&typeof n.render=="function",panel(t,e,n){const o=A(e,t);if(o){t.fields={...t.fields,...n.sidesPaddingFields({keys:m,unitKey:y,fallback:o,tablet:!0,siteSide:!0})};return}if(N.has(e))return;const a=[m.top,m.bottom].filter(s=>t.fields!=null&&s in t.fields);if(a.length)throw new Error(`section-padding: ${e} declares its own ${a.join(" / ")} row; declare \`innerPadding: { top, bottom }\` in its meta and the one Padding row draws on its band`);const r=f(O,e);if(r){p(t,e,n,r);return}t.fields={...t.fields,...n.sidesPaddingFields({tablet:!0,siteSide:!0})}},draw(t,e){if(!A(e,t)){if(N.has(e)){b(t);return}T.has(e)||V.has(e)||b(t,e==="Flex"?n=>L(n.bgImage):$.has(e)?n=>k(e,n):void 0,!0,f(O,e))}}},G=["Heading","Text","ImageBlock","ButtonBlock"],q=["LogoBlock"],O={Text:t=>v(t,"text").textStyle?.startsWith("heading-")?P.heading:P.text,Heading:()=>P.heading,ButtonBlock:()=>P.text,Breadcrumb:()=>D(Y),SpecStrip:()=>D(M),...Object.fromEntries(Object.entries(W).map(([t,e])=>[t,e.frame]))},z={ButtonBlock:"Outer padding"};function J(t,e){const n=t[c],o=Array.isArray(n)?n.filter(i=>typeof i=="string"):[],a=S().filter(i=>e?.[i]);if(!a.length)return t;const r=[...o.filter(i=>!a.includes(i)),...a.filter(i=>typeof t[i]=="number")];if(r.length===o.length&&r.every((i,l)=>i===o[l]))return t;const{[c]:s,...d}=t;return r.length?{...d,[c]:r}:d}function Q(t,e,n){if(e<=0)return null;const o=Array.isArray(t[c])?t[c]:[];return(n?S().filter(s=>s.startsWith(h[n])):S()).some(s=>typeof t[s]=="number"&&!o.includes(s))?U("plus {n} px (older setting)",{n:e}):null}function p(t,e,n,o){t.fields={...t.fields,...n.ownPaddingFields?.(o,Q,f(z,e))??n.sidesPaddingFields({tablet:!0,siteSide:!0})};const a=t.resolveData;t.resolveData=(r,s)=>{const d=r.props??{},i=s?.trigger==="replace"?J(d,s.changed):d,l=i===d?r:{...r,props:i};return a?a(l,s):l}}const St={name:"blockPadding",applies:(t,e,n)=>(G.includes(t)||q.includes(t))&&!!n&&typeof n.render=="function",panel(t,e,n){const o=f(O,e);if(!o){t.fields={...t.fields,...n.sidesPaddingFields({tablet:!0,siteSide:!0})};return}p(t,e,n,o)},draw(t,e){T.has(e)||b(t,void 0,!0)}};export{O as OWN_PAD_FRAME,z as OWN_PAD_LABEL,V as PADS_ITS_OWN_SPACE,T as PAD_ON_ROOT,Pt as SECTION_PAD_INNER,B as SECTION_PAD_INNER_DEFAULTS,St as blockPadding,_t as innerPaddingFallback,Q as olderPadNote,gt as ownPairDefault,mt as sectionPadding,J as withPadTotals};
1
+ import{jsx as g}from"react/jsx-runtime";import{SideOnceClass as C}from"../../../components/SideSpaceOnce.js";import{HideTaker as F}from"../../../components/ViewHideRoot.js";import{LineChoice as L}from"../../../components/InBoxContext.js";import{isBackgroundBox as R}from"../../../../format/lib/content/box-background.js";import{boxSideSpaceOf as W}from"../../../../format/lib/content/box-side-space.js";import{SECTION_OWN_PADS as y}from"../../content/section-own-pads.js";import{BAND_PAD_KEYS as m,BAND_PAD_UNIT_KEY as K,BLOCK_PAD_FRAME as P,PAD_TOTAL_KEY as f,SECTION_PAD_KEYS as x,framePadAttrs as H,padTotalKeys as S,padValuesOf as j,sectionPadAttrs as v,tierFramesOf as h}from"../../content/section-padding.js";import{readPartStyle as Y}from"../part-styles.js";import{CRUMB_PAD as M,SPEC_PAD as U}from"../../../../format/lib/sections/strip-shape.js";import{say as $}from"../../../../format/lib/editor-words.js";import{sectionFillPassClass as D}from"../../../../format/lib/content/section-min-height.js";import{COPIES_IN_THE_BOX as k,drawsCopiesInTheBox as V}from"../../../../format/lib/content/copies-in-box.js";import{ownEntry as c}from"../../../../format/lib/own-entry.js";const E={ParagraphsA:{top:60,bottom:80},StatsParagraph:{top:120,bottom:120},Timeline:{top:120,bottom:120},Footprint:{top:120,bottom:120},TimelineTrack:{top:120,bottom:120},TitleWithButtons:{top:140,bottom:140},ProcessSteps:{top:120,bottom:120}},_t=new Set(Object.keys(E));function A(t,e){return e?.innerPadding??c(E,t)}const gt=t=>A(t)??{},mt=t=>c({DetailRows:{top:100,bottom:100}},t),B=new Set(["Flex","Text","Heading","ImageBlock","ButtonBlock"]),X=new Set(["Divider"]),G=new Set(["Hero","HeroSingle","IntroBleed","CategoryBar","DocTabs"]),T=new Set(["ProductGrid"]);function O(t,e,n=!1,o){const a=t.render;t.render=r=>{if(e?.(r))return a(r);const s={...j(r,x,n),sideSpace:W(r.sideSpace)},d=o?H({values:s,frame:o(r)},!0).outer:v(s),i=a(r);if(!d)return i;const l=u=>g(C,{className:u?`${d.className} ${u}`:d.className,children:I=>g(F,{className:I,style:d.style,children:i})}),_=D(r,{atSectionLine:!0}),b=D(r);return _===b?l(_):g(L,{line:"by-box",draw:u=>l(u?b:_)})}}const St={name:"sectionPadding",applies:(t,e,n)=>e.isSection(t)&&!G.has(t)&&!!n&&typeof n.render=="function",panel(t,e,n){const o=A(e,t);if(o){t.fields={...t.fields,...n.sidesPaddingFields({keys:m,unitKey:K,fallback:o,tablet:!0,siteSide:!0})};return}if(T.has(e))return;const a=[m.top,m.bottom].filter(s=>t.fields!=null&&s in t.fields);if(a.length)throw new Error(`section-padding: ${e} declares its own ${a.join(" / ")} row; declare \`innerPadding: { top, bottom }\` in its meta and the one Padding row draws on its band`);const r=N(e,t);if(r){p(t,e,n,r);return}t.fields={...t.fields,...n.sidesPaddingFields({tablet:!0,siteSide:!0})}},draw(t,e){if(!A(e,t)){if(T.has(e)){O(t);return}B.has(e)||X.has(e)||O(t,e==="Flex"?n=>R(n.bgImage):k.has(e)?n=>V(e,n):void 0,!0,N(e,t))}}},q=["Heading","Text","ImageBlock","ButtonBlock"],z=["LogoBlock"],w={Text:t=>Y(t,"text").textStyle?.startsWith("heading-")?P.heading:P.text,Heading:()=>P.heading,ButtonBlock:()=>P.text,Breadcrumb:()=>h(M),SpecStrip:()=>h(U),...Object.fromEntries(Object.entries(y).map(([t,e])=>[t,e.frame]))};function N(t,e){return c(w,t)??e?.ownPad?.frame}const J={ButtonBlock:"Outer padding"};function Q(t,e){const n=t[f],o=Array.isArray(n)?n.filter(i=>typeof i=="string"):[],a=S().filter(i=>e?.[i]);if(!a.length)return t;const r=[...o.filter(i=>!a.includes(i)),...a.filter(i=>typeof t[i]=="number")];if(r.length===o.length&&r.every((i,l)=>i===o[l]))return t;const{[f]:s,...d}=t;return r.length?{...d,[f]:r}:d}function Z(t,e,n){if(e<=0)return null;const o=Array.isArray(t[f])?t[f]:[];return(n?S().filter(s=>s.startsWith(x[n])):S()).some(s=>typeof t[s]=="number"&&!o.includes(s))?$("plus {n} px (older setting)",{n:e}):null}function p(t,e,n,o){t.fields={...t.fields,...n.ownPaddingFields?.(o,Z,c(J,e))??n.sidesPaddingFields({tablet:!0,siteSide:!0})};const a=t.resolveData;t.resolveData=(r,s)=>{const d=r.props??{},i=s?.trigger==="replace"?Q(d,s.changed):d,l=i===d?r:{...r,props:i};return a?a(l,s):l}}const At={name:"blockPadding",applies:(t,e,n)=>(q.includes(t)||z.includes(t))&&!!n&&typeof n.render=="function",panel(t,e,n){const o=c(w,e);if(!o){t.fields={...t.fields,...n.sidesPaddingFields({tablet:!0,siteSide:!0})};return}p(t,e,n,o)},draw(t,e){B.has(e)||O(t,void 0,!0)}};export{w as OWN_PAD_FRAME,J as OWN_PAD_LABEL,X as PADS_ITS_OWN_SPACE,B as PAD_ON_ROOT,_t as SECTION_PAD_INNER,E as SECTION_PAD_INNER_DEFAULTS,At as blockPadding,gt as innerPaddingFallback,Z as olderPadNote,N as ownFrameOf,mt as ownPairDefault,St as sectionPadding,Q as withPadTotals};
@@ -1,5 +1,5 @@
1
1
  import { type TextStyle, type TextStyleCase, type TextStyleDevice } from "efficient-easel/text-styles/model";
2
- import { type FontRole, type FontsValue } from "../../../format/lib/fonts.js";
2
+ import { type FontRegistry, type FontRole, type FontsValue } from "../../../format/lib/fonts.js";
3
3
  import { viewRules } from "../content/view-values.js";
4
4
  import { type PartStyle } from "../document/part-styles.js";
5
5
  import { faceClassOf } from "../../../format/lib/text-style-face.js";
@@ -70,7 +70,7 @@ export type SiteTextSeed = {
70
70
  typography: ResolvedHeadingTypography;
71
71
  textStyles: unknown;
72
72
  };
73
- export declare function siteTextFromRow(row: Partial<SiteThemeRow>): SiteTextSeed;
73
+ export declare function siteTextFromRow(row: Partial<SiteThemeRow>, registry?: FontRegistry): SiteTextSeed;
74
74
  export declare function textStylesToOld(list: readonly StoredTextStyle[], prev: OldSiteText): OldSiteText;
75
75
  export declare function themeWithTextStyles<T extends {
76
76
  fonts?: unknown;
@@ -79,7 +79,7 @@ export declare function themeWithTextStyles<T extends {
79
79
  headingTypography?: unknown;
80
80
  textStyles?: unknown;
81
81
  }>(theme: T): T;
82
- export declare function textStylesCss(list: readonly StoredTextStyle[]): string;
82
+ export declare function textStylesCss(list: readonly StoredTextStyle[], registry?: FontRegistry): string;
83
83
  export declare function accentItalicCss(italic: boolean | null | undefined): string;
84
84
  export declare function styleIdOfRole(role: FontRole | null | undefined): string | undefined;
85
85
  export declare function partStyleToTextStyleValues(style: PartStyle): StoredTextStyleValues;
@@ -1,2 +1,2 @@
1
- import{defaultTextStyles as Y,textStyleCaseCss as le}from"efficient-easel/text-styles/model";import{resolveViewValue as Z}from"efficient-easel/draw";import{viewKey as w}from"../../../format/lib/animation/views.js";import{FONT_OPTIONS as ce,normalizeFonts as B}from"../../../format/lib/fonts.js";import{PHONE_MEDIA as de,TABLET_MEDIA as pe,viewOverrides as H,viewRules as U}from"../content/view-values.js";import{STYLE_ID_OF_ROLE as fe,TEXT_STYLE_ATTR as ue,paragraphRules as X,partSpacingOf as ge}from"../document/part-styles.js";import{FACE_SIZE as he,faceClassOf as q}from"../../../format/lib/text-style-face.js";import{partColourName as Q,partInkCss as me}from"../../../format/lib/document/part-inks.js";import{compressionMetrics as Se,headingTypographyFromRow as ye,normalizeHeadingCompression as I,normalizeSizes as ee}from"../../../format/lib/theme.js";import{finiteNumber as v}from"../../../format/lib/finite-number.js";import{nonEmptyString as P}from"../../../format/lib/non-empty-string.js";const j=e=>e==="sentence"?"none":void 0,ne=["font","color","size","sizeTablet","sizePhone","weight","italic","lineHeight","lineHeightTablet","lineHeightPhone","letterSpacing","letterSpacingTablet","letterSpacingPhone","paragraphSpacing","paragraphSpacingTablet","paragraphSpacingPhone","letterCase","largestSize","largestSizeTablet","largestSizePhone"],O=["desktop","tablet","phone"],k=(e,i)=>w(e,i);function L(e,i,t,n=U()){return Z("textSize",i,e.sizeTablet,e.sizePhone,n)[t]}const xe=[["lineSpacing","lineHeight","line"],["letterSpacing","letterSpacing","letter"]];function R(e){for(const[i,t,n]of xe)for(const s of O)if(e===k(i,s))return{key:w(t,s),view:s,spacing:n};return{key:e,view:"desktop",spacing:null}}function x(e){const i={};for(const t of ne)e[t]!==void 0&&(i[t]=e[t]);return i}function F(e,i){const{auto:t,...n}=e,s=new Set(i??[]),r=ne.filter(o=>s.has(o)&&e.values[o]===void 0);return r.length?{...n,auto:r}:n}function te(e){const i=e.fonts,t=e.sizes,n=e.typography,s=Se(e.compression),r={"heading-1":{font:P(i.heading),size:v(t.headingLarge),weight:v(n.weight),lineHeight:s.lineHeight,letterSpacing:s.letterSpacing,letterCase:j(n.case),largestSize:v(n.maxPx)},"heading-2":{font:P(i.heading2),size:v(t.headingMedium),weight:v(n.weight2),lineHeight:s.lineHeight,letterSpacing:s.letterSpacing,letterCase:j(n.case2)},"heading-3":{font:P(i.heading3),size:v(t.headingSmall),weight:v(n.weight3),lineHeight:s.lineHeight,letterSpacing:s.letterSpacing,letterCase:j(n.case3)},"body-1":{font:P(i.body),size:v(t.body)},"body-5":{font:P(i.label),size:v(t.label)}};return Y().map(({id:o,kind:l,name:d})=>({id:o,kind:l,name:d,values:x(r[o]??{})}))}function N(e){return Array.isArray(e)&&e.every(t=>t&&typeof t=="object"&&typeof t.id=="string"&&(t.kind==="heading"||t.kind==="body")&&typeof t.name=="string")?e.map(t=>F({...t,values:x(t.values??{})},Array.isArray(t.auto)?t.auto:void 0)):null}function je(e){return N(e)??[]}function ie(e){return N(e)??Y().map(({id:i,kind:t,name:n})=>({id:i,kind:t,name:n,values:{}}))}function M(e,i){const t=te(i),n=N(e);return n?n.map(s=>{const r={...V(t,s.id)};for(const o of s.auto??[])delete r[o];return{...s,values:x({...r,...s.values})}}):t}const V=(e,i)=>e.find(t=>t.id===i)?.values??{},se=["heading-1","heading-2","heading-3"];function Le({saved:e,old:i,cur:t,next:n,sizeOf:s,panelView:r="desktop"}){const o=te(i),l=ie(e),d=M(l,i),c=[],f=n.map(a=>{const S=t.find(g=>g.id===a.id),h=l.find(g=>g.id===a.id);if(!S||!h){const g=be([a],s,r)[0],T=g.values.color;return T===void 0?g:{...g,values:{...g.values,color:Q(T)}}}const p={...h.values},b=new Set(h.auto??[]),y=a.values,_=S.values,z=[...new Set([...Object.keys(y),...Object.keys(_)])].filter(g=>JSON.stringify(y[g])!==JSON.stringify(_[g])),D=g=>R(g).spacing==="letter";z.sort((g,T)=>Number(D(g))-Number(D(T)));for(const g of z){const{key:T,view:re,spacing:K}=R(g),$=T,E=y[g];if(E===void 0){delete p[$],V(o,a.id)[$]!==void 0&&(c.push([a.id,$]),b.add($));continue}if(b.delete($),K==="line")p[$]=C(E/100,3);else if(K==="letter"){const W={...d.find(A=>A.id===a.id)?.values??{}};for(const A of z)y[A]===void 0&&delete W[R(A).key];const G=x({...W,...p}),J=L(G,s({...a,values:G}),re);p[$]=J?C(E/J,4):0}else p[$]=E}return F({id:a.id,kind:a.kind,name:a.name,values:x(p)},b)});let u=i.compression;if(c.some(([a,S])=>(S==="lineHeight"||S==="letterSpacing")&&se.includes(a))&&I(u)!=="normal"){for(const a of se){const S=f.find(p=>p.id===a);if(!S)continue;const h={...S.values};for(const p of["lineHeight","letterSpacing"])c.some(([b,y])=>b===a&&y===p)||h[p]===void 0&&!(S.auto??[]).includes(p)&&(h[p]=V(o,a)[p]);S.values=x(h)}u="normal"}return{saved:f,old:{...i,compression:u}}}function Re(e,i){const t={text_styles:e.saved};return e.old.compression!==i.compression&&(t.heading_compression=I(e.old.compression)),t}const C=(e,i)=>Number(e.toFixed(i)),oe=(e,i)=>O.indexOf(e)<O.indexOf(i)?i:e;function Fe(e,i,t="desktop"){return e.map(n=>{const s={...n.values},r=i(n);for(const o of O){const l=w("lineHeight",o),d=n.values[l],c=n.values[w("letterSpacing",o)];delete s[l],d!==void 0&&(s[k("lineSpacing",o)]=C(d*100,1));const f=oe(o,t);c!==void 0&&(s[k("letterSpacing",o)]=C(c*L(n.values,r,f),f===o?2:4))}return{id:n.id,kind:n.kind,name:n.name,values:s}})}function be(e,i,t="desktop"){return e.map(n=>{const s=n.values,r={...s};for(const c of O)delete r[k("lineSpacing",c)],delete r[k("letterSpacing",c)];const o={id:n.id,kind:n.kind,name:n.name,values:x(r)},l={...o.values},d=i({...o,values:{...o.values}});for(const c of O){const f=s[k("lineSpacing",c)],u=s[k("letterSpacing",c)];if(typeof f=="number"&&(l[w("lineHeight",c)]=C(f/100,3)),typeof u=="number"){const m=L(o.values,d,oe(c,t));l[w("letterSpacing",c)]=m?C(u/m,4):0}}return{...o,values:x(l)}})}function Me(e){const i={fonts:B({heading:e.heading_font??void 0,heading2:e.heading_2_font??void 0,heading3:e.heading_3_font??void 0,body:e.body_font??void 0,accent:e.accent_font??void 0,label:e.label_font??void 0}),sizes:ee({headingLarge:e.heading_size_large_px,headingMedium:e.heading_size_medium_px,headingSmall:e.heading_size_small_px,accent:e.accent_size_px,body:e.body_size_px,label:e.label_size_px}),compression:I(e.heading_compression),typography:ye(e)},t=e.text_styles??null,n=Array.isArray(t)?ae(M(t,i),i):i;return{fonts:B(n.fonts),sizes:ee(n.sizes),compression:I(n.compression),typography:n.typography,textStyles:t}}function ae(e,i){const t=m=>e.find(a=>a.id===m)?.values??{},n=t("heading-1"),s=t("heading-2"),r=t("heading-3"),o=t("body-1"),l=t("body-5"),d=i.fonts,c=i.sizes,f=i.typography,u=m=>m==="none"?"sentence":"authored";return{fonts:{...d,heading:n.font??d.heading,heading2:s.font??n.font??d.heading2,heading3:r.font??n.font??d.heading3,body:o.font??d.body,label:l.font??d.label},sizes:{...c,headingLarge:n.size??null,headingMedium:s.size??null,headingSmall:r.size??null,body:o.size??null,label:l.size??null},compression:i.compression,typography:{...f,case:u(n.letterCase),weight:n.weight??null,maxPx:n.largestSize??null,weight2:s.weight??null,weight3:r.weight??null,case2:u(s.letterCase),case3:u(r.letterCase)}}}function Ve(e){const i=N(e.textStyles);if(!i||i.every(s=>Object.keys(s.values).length===0&&!s.auto))return e;const t={fonts:e.fonts??{},sizes:e.sizes??{},compression:String(e.headingCompression??"normal"),typography:e.headingTypography??{}},n=ae(M(i,t),t);return{...e,fonts:n.fonts,sizes:n.sizes,headingCompression:n.compression,headingTypography:n.typography}}function De(e){const i=[];for(const t of e){const n=t.values,s=`.${q(t)}`,r=`[${ue}="${t.id}"]`,o=`${s}, ${r}`,l=[],d=n.font!==void 0?ce.find(m=>m.key===n.font)?.cssVar:void 0;if(d&&l.push(`font-family: var(${d})`),n.size!==void 0){const m=n.largestSize!==void 0?Math.min(n.size,n.largestSize):n.size;l.push(`font-size: ${m}px`)}const c=me(n.color);c&&l.push(`color: ${c}`),n.italic===!0&&l.push("font-style: italic"),n.weight!==void 0&&l.push(`font-weight: ${n.weight}`);const f=[];n.lineHeight!==void 0&&f.push(`line-height: ${n.lineHeight}`),n.letterSpacing!==void 0&&f.push(`letter-spacing: ${n.letterSpacing}em`),t.kind==="body"&&l.push(...f);const u=le(n.letterCase);u&&t.kind==="body"&&l.push(`text-transform: ${u}`),n.paragraphSpacing&&l.push(`--sf-part-para: ${n.paragraphSpacing}px`),l.length&&i.push(`${o} { ${l.join("; ")} }`),t.kind==="heading"&&f.length&&i.push(`${o}, ${s}:is(h1, h2, h3, h4), ${r}:is(h1, h2, h3, h4) { ${f.join("; ")} }`),t.kind==="heading"&&u&&i.push(`${r}, ${s}:is(h1, h2, h3, h4) { text-transform: ${u} }`),n.paragraphSpacing&&(i.push(`*:has(> ${r}) { --sf-part-para: ${n.paragraphSpacing}px }`),i.push(...X(`:is(${o})`,`*:has(> ${r})`))),i.push(...ze(t,o,s,r))}return i.join(`
2
- `)}function ze(e,i,t,n){const s=e.values,r=H("textSize",s.size,s.sizeTablet,s.sizePhone),o=H("textSize",s.largestSize,s.largestSizeTablet,s.largestSizePhone),l=H("same",s.lineHeight,s.lineHeightTablet,s.lineHeightPhone),d=H("same",s.letterSpacing,s.letterSpacingTablet,s.letterSpacingPhone),c=H("spacing",s.paragraphSpacing,s.paragraphSpacingTablet,s.paragraphSpacingPhone),f=Z("textSize",s.size,s.sizeTablet,s.sizePhone,U()),u=ve[e.id],m=[];for(const[a,S]of[["tablet",pe],["phone",de]]){const h=[],p=[],b=f[a],y=o[a],_=r[a]===void 0&&y===void 0||b===void 0?void 0:y===void 0?b:Math.min(b,y);_!==void 0&&p.push(`font-size: ${_}px`);const z=[];l[a]!==void 0&&z.push(`line-height: ${l[a]}`),d[a]!==void 0&&z.push(`letter-spacing: ${d[a]}em`),e.kind==="body"&&p.push(...z),c[a]!==void 0&&p.push(`--sf-part-para: ${c[a]}px`),p.length&&h.push(`${i} { ${p.join("; ")} }`),e.kind==="heading"&&z.length&&h.push(`${i}, ${t}:is(h1, h2, h3, h4), ${n}:is(h1, h2, h3, h4) { ${z.join("; ")} }`),c[a]!==void 0&&h.push(`*:has(> ${n}) { --sf-part-para: ${c[a]}px }`),c[a]!==void 0&&!s.paragraphSpacing&&h.push(...X(`:is(${i})`,`*:has(> ${n})`)),_!==void 0&&u&&h.push(`.sf-themed-content { --size-${u}: ${_}px !important }`),h.length&&m.push(`@media ${S} { ${h.join(" ")} }`)}return m}const ve=Object.fromEntries(Object.entries(he).map(([e,{step:i}])=>[e,i]));function Ke(e){return e!==!0&&e!==!1?"":`em.text-accent { font-style: ${e?"italic":"normal"} }`}function We(e){return e?fe[e]:void 0}function $e(e){const i=ge(e);return x({font:e.font,color:e.color===void 0?void 0:Q(e.color),size:e.size,weight:e.weight,italic:e.italic,lineHeight:i.lineHeight,letterSpacing:i.letterSpacingEm,paragraphSpacing:e.paragraphSpacing,letterCase:e.case})}function Ge(e){return Object.keys($e(e)).length>0}function Je({saved:e,old:i,styleId:t,values:n}){const s=ie(e);return{saved:_e(s,t,n),old:i}}function _e(e,i,t){return e.map(n=>n.id===i?F({...n,values:x({...n.values,...t})},n.auto):n)}function Ye(e){const i=e.filter(t=>t.kind==="body").map(t=>Number(/^body-(\d+)$/.exec(t.id)?.[1])).filter(t=>Number.isInteger(t)&&t>0);return i.length?`body-${Math.max(...i)}`:"body-1"}export{Ke as accentItalicCss,Le as applyListChange,Ye as eyebrowStyleId,q as faceClassOf,be as fromPanelStyles,Ge as hasStyleChange,Re as listChangePatch,ie as listToWrite,$e as partStyleToTextStyleValues,Je as pushIntoStyle,M as resolveTextStyles,_e as setStyleValues,Me as siteTextFromRow,je as storedTextStyles,We as styleIdOfRole,De as textStylesCss,te as textStylesFromOld,ae as textStylesToOld,Ve as themeWithTextStyles,Fe as toPanelStyles,L as viewSizeOf};
1
+ import{defaultTextStyles as J,textStyleCaseCss as ce}from"efficient-easel/text-styles/model";import{resolveViewValue as Z}from"efficient-easel/draw";import{viewKey as w}from"../../../format/lib/animation/views.js";import{POOL_FONT_REGISTRY as B,normalizeFonts as U}from"../../../format/lib/fonts.js";import{PHONE_MEDIA as de,TABLET_MEDIA as pe,viewOverrides as H,viewRules as X}from"../content/view-values.js";import{STYLE_ID_OF_ROLE as fe,TEXT_STYLE_ATTR as ue,paragraphRules as q,partSpacingOf as ge}from"../document/part-styles.js";import{FACE_SIZE as he,faceClassOf as Q}from"../../../format/lib/text-style-face.js";import{partColourName as ee,partInkCss as me}from"../../../format/lib/document/part-inks.js";import{compressionMetrics as Se,headingTypographyFromRow as ye,normalizeHeadingCompression as I,normalizeSizes as ne}from"../../../format/lib/theme.js";import{finiteNumber as v}from"../../../format/lib/finite-number.js";import{nonEmptyString as P}from"../../../format/lib/non-empty-string.js";const N=e=>e==="sentence"?"none":void 0,te=["font","color","size","sizeTablet","sizePhone","weight","italic","lineHeight","lineHeightTablet","lineHeightPhone","letterSpacing","letterSpacingTablet","letterSpacingPhone","paragraphSpacing","paragraphSpacingTablet","paragraphSpacingPhone","letterCase","largestSize","largestSizeTablet","largestSizePhone"],O=["desktop","tablet","phone"],k=(e,o)=>w(e,o);function L(e,o,t,i=X()){return Z("textSize",o,e.sizeTablet,e.sizePhone,i)[t]}const be=[["lineSpacing","lineHeight","line"],["letterSpacing","letterSpacing","letter"]];function R(e){for(const[o,t,i]of be)for(const n of O)if(e===k(o,n))return{key:w(t,n),view:n,spacing:i};return{key:e,view:"desktop",spacing:null}}function b(e){const o={};for(const t of te)e[t]!==void 0&&(o[t]=e[t]);return o}function F(e,o){const{auto:t,...i}=e,n=new Set(o??[]),l=te.filter(s=>n.has(s)&&e.values[s]===void 0);return l.length?{...i,auto:l}:i}function ie(e){const o=e.fonts,t=e.sizes,i=e.typography,n=Se(e.compression),l={"heading-1":{font:P(o.heading),size:v(t.headingLarge),weight:v(i.weight),lineHeight:n.lineHeight,letterSpacing:n.letterSpacing,letterCase:N(i.case),largestSize:v(i.maxPx)},"heading-2":{font:P(o.heading2),size:v(t.headingMedium),weight:v(i.weight2),lineHeight:n.lineHeight,letterSpacing:n.letterSpacing,letterCase:N(i.case2)},"heading-3":{font:P(o.heading3),size:v(t.headingSmall),weight:v(i.weight3),lineHeight:n.lineHeight,letterSpacing:n.letterSpacing,letterCase:N(i.case3)},"body-1":{font:P(o.body),size:v(t.body)},"body-5":{font:P(o.label),size:v(t.label)}};return J().map(({id:s,kind:d,name:r})=>({id:s,kind:d,name:r,values:b(l[s]??{})}))}function j(e){return Array.isArray(e)&&e.every(t=>t&&typeof t=="object"&&typeof t.id=="string"&&(t.kind==="heading"||t.kind==="body")&&typeof t.name=="string")?e.map(t=>F({...t,values:b(t.values??{})},Array.isArray(t.auto)?t.auto:void 0)):null}function Ne(e){return j(e)??[]}function oe(e){return j(e)??J().map(({id:o,kind:t,name:i})=>({id:o,kind:t,name:i,values:{}}))}function M(e,o){const t=ie(o),i=j(e);return i?i.map(n=>{const l={...V(t,n.id)};for(const s of n.auto??[])delete l[s];return{...n,values:b({...l,...n.values})}}):t}const V=(e,o)=>e.find(t=>t.id===o)?.values??{},se=["heading-1","heading-2","heading-3"];function Le({saved:e,old:o,cur:t,next:i,sizeOf:n,panelView:l="desktop"}){const s=ie(o),d=oe(e),r=M(d,o),c=[],g=i.map(a=>{const S=t.find(u=>u.id===a.id),m=d.find(u=>u.id===a.id);if(!S||!m){const u=xe([a],n,l)[0],T=u.values.color;return T===void 0?u:{...u,values:{...u.values,color:ee(T)}}}const p={...m.values},x=new Set(m.auto??[]),y=a.values,_=S.values,z=[...new Set([...Object.keys(y),...Object.keys(_)])].filter(u=>JSON.stringify(y[u])!==JSON.stringify(_[u])),D=u=>R(u).spacing==="letter";z.sort((u,T)=>Number(D(u))-Number(D(T)));for(const u of z){const{key:T,view:le,spacing:K}=R(u),$=T,E=y[u];if(E===void 0){delete p[$],V(s,a.id)[$]!==void 0&&(c.push([a.id,$]),x.add($));continue}if(x.delete($),K==="line")p[$]=C(E/100,3);else if(K==="letter"){const G={...r.find(A=>A.id===a.id)?.values??{}};for(const A of z)y[A]===void 0&&delete G[R(A).key];const W=b({...G,...p}),Y=L(W,n({...a,values:W}),le);p[$]=Y?C(E/Y,4):0}else p[$]=E}return F({id:a.id,kind:a.kind,name:a.name,values:b(p)},x)});let f=o.compression;if(c.some(([a,S])=>(S==="lineHeight"||S==="letterSpacing")&&se.includes(a))&&I(f)!=="normal"){for(const a of se){const S=g.find(p=>p.id===a);if(!S)continue;const m={...S.values};for(const p of["lineHeight","letterSpacing"])c.some(([x,y])=>x===a&&y===p)||m[p]===void 0&&!(S.auto??[]).includes(p)&&(m[p]=V(s,a)[p]);S.values=b(m)}f="normal"}return{saved:g,old:{...o,compression:f}}}function Re(e,o){const t={text_styles:e.saved};return e.old.compression!==o.compression&&(t.heading_compression=I(e.old.compression)),t}const C=(e,o)=>Number(e.toFixed(o)),ae=(e,o)=>O.indexOf(e)<O.indexOf(o)?o:e;function Fe(e,o,t="desktop"){return e.map(i=>{const n={...i.values},l=o(i);for(const s of O){const d=w("lineHeight",s),r=i.values[d],c=i.values[w("letterSpacing",s)];delete n[d],r!==void 0&&(n[k("lineSpacing",s)]=C(r*100,1));const g=ae(s,t);c!==void 0&&(n[k("letterSpacing",s)]=C(c*L(i.values,l,g),g===s?2:4))}return{id:i.id,kind:i.kind,name:i.name,values:n}})}function xe(e,o,t="desktop"){return e.map(i=>{const n=i.values,l={...n};for(const c of O)delete l[k("lineSpacing",c)],delete l[k("letterSpacing",c)];const s={id:i.id,kind:i.kind,name:i.name,values:b(l)},d={...s.values},r=o({...s,values:{...s.values}});for(const c of O){const g=n[k("lineSpacing",c)],f=n[k("letterSpacing",c)];if(typeof g=="number"&&(d[w("lineHeight",c)]=C(g/100,3)),typeof f=="number"){const h=L(s.values,r,ae(c,t));d[w("letterSpacing",c)]=h?C(f/h,4):0}}return{...s,values:b(d)}})}function Me(e,o=B){const t={fonts:U({heading:e.heading_font??void 0,heading2:e.heading_2_font??void 0,heading3:e.heading_3_font??void 0,body:e.body_font??void 0,accent:e.accent_font??void 0,label:e.label_font??void 0},o),sizes:ne({headingLarge:e.heading_size_large_px,headingMedium:e.heading_size_medium_px,headingSmall:e.heading_size_small_px,accent:e.accent_size_px,body:e.body_size_px,label:e.label_size_px}),compression:I(e.heading_compression),typography:ye(e)},i=e.text_styles??null,n=Array.isArray(i)?re(M(i,t),t):t;return{fonts:U(n.fonts,o),sizes:ne(n.sizes),compression:I(n.compression),typography:n.typography,textStyles:i}}function re(e,o){const t=h=>e.find(a=>a.id===h)?.values??{},i=t("heading-1"),n=t("heading-2"),l=t("heading-3"),s=t("body-1"),d=t("body-5"),r=o.fonts,c=o.sizes,g=o.typography,f=h=>h==="none"?"sentence":"authored";return{fonts:{...r,heading:i.font??r.heading,heading2:n.font??i.font??r.heading2,heading3:l.font??i.font??r.heading3,body:s.font??r.body,label:d.font??r.label},sizes:{...c,headingLarge:i.size??null,headingMedium:n.size??null,headingSmall:l.size??null,body:s.size??null,label:d.size??null},compression:o.compression,typography:{...g,case:f(i.letterCase),weight:i.weight??null,maxPx:i.largestSize??null,weight2:n.weight??null,weight3:l.weight??null,case2:f(n.letterCase),case3:f(l.letterCase)}}}function Ve(e){const o=j(e.textStyles);if(!o||o.every(n=>Object.keys(n.values).length===0&&!n.auto))return e;const t={fonts:e.fonts??{},sizes:e.sizes??{},compression:String(e.headingCompression??"normal"),typography:e.headingTypography??{}},i=re(M(o,t),t);return{...e,fonts:i.fonts,sizes:i.sizes,headingCompression:i.compression,headingTypography:i.typography}}function De(e,o=B){const t=[];for(const i of e){const n=i.values,l=`.${Q(i)}`,s=`[${ue}="${i.id}"]`,d=`${l}, ${s}`,r=[],c=n.font!==void 0?o.byKey.get(n.font)?.cssVar:void 0;if(c&&r.push(`font-family: var(${c})`),n.size!==void 0){const a=n.largestSize!==void 0?Math.min(n.size,n.largestSize):n.size;r.push(`font-size: ${a}px`)}const g=me(n.color);g&&r.push(`color: ${g}`),n.italic===!0&&r.push("font-style: italic"),n.weight!==void 0&&r.push(`font-weight: ${n.weight}`);const f=[];n.lineHeight!==void 0&&f.push(`line-height: ${n.lineHeight}`),n.letterSpacing!==void 0&&f.push(`letter-spacing: ${n.letterSpacing}em`),i.kind==="body"&&r.push(...f);const h=ce(n.letterCase);h&&i.kind==="body"&&r.push(`text-transform: ${h}`),n.paragraphSpacing&&r.push(`--sf-part-para: ${n.paragraphSpacing}px`),r.length&&t.push(`${d} { ${r.join("; ")} }`),i.kind==="heading"&&f.length&&t.push(`${d}, ${l}:is(h1, h2, h3, h4), ${s}:is(h1, h2, h3, h4) { ${f.join("; ")} }`),i.kind==="heading"&&h&&t.push(`${s}, ${l}:is(h1, h2, h3, h4) { text-transform: ${h} }`),n.paragraphSpacing&&(t.push(`*:has(> ${s}) { --sf-part-para: ${n.paragraphSpacing}px }`),t.push(...q(`:is(${d})`,`*:has(> ${s})`))),t.push(...ze(i,d,l,s))}return t.join(`
2
+ `)}function ze(e,o,t,i){const n=e.values,l=H("textSize",n.size,n.sizeTablet,n.sizePhone),s=H("textSize",n.largestSize,n.largestSizeTablet,n.largestSizePhone),d=H("same",n.lineHeight,n.lineHeightTablet,n.lineHeightPhone),r=H("same",n.letterSpacing,n.letterSpacingTablet,n.letterSpacingPhone),c=H("spacing",n.paragraphSpacing,n.paragraphSpacingTablet,n.paragraphSpacingPhone),g=Z("textSize",n.size,n.sizeTablet,n.sizePhone,X()),f=ve[e.id],h=[];for(const[a,S]of[["tablet",pe],["phone",de]]){const m=[],p=[],x=g[a],y=s[a],_=l[a]===void 0&&y===void 0||x===void 0?void 0:y===void 0?x:Math.min(x,y);_!==void 0&&p.push(`font-size: ${_}px`);const z=[];d[a]!==void 0&&z.push(`line-height: ${d[a]}`),r[a]!==void 0&&z.push(`letter-spacing: ${r[a]}em`),e.kind==="body"&&p.push(...z),c[a]!==void 0&&p.push(`--sf-part-para: ${c[a]}px`),p.length&&m.push(`${o} { ${p.join("; ")} }`),e.kind==="heading"&&z.length&&m.push(`${o}, ${t}:is(h1, h2, h3, h4), ${i}:is(h1, h2, h3, h4) { ${z.join("; ")} }`),c[a]!==void 0&&m.push(`*:has(> ${i}) { --sf-part-para: ${c[a]}px }`),c[a]!==void 0&&!n.paragraphSpacing&&m.push(...q(`:is(${o})`,`*:has(> ${i})`)),_!==void 0&&f&&m.push(`.sf-themed-content { --size-${f}: ${_}px !important }`),m.length&&h.push(`@media ${S} { ${m.join(" ")} }`)}return h}const ve=Object.fromEntries(Object.entries(he).map(([e,{step:o}])=>[e,o]));function Ke(e){return e!==!0&&e!==!1?"":`em.text-accent { font-style: ${e?"italic":"normal"} }`}function Ge(e){return e?fe[e]:void 0}function $e(e){const o=ge(e);return b({font:e.font,color:e.color===void 0?void 0:ee(e.color),size:e.size,weight:e.weight,italic:e.italic,lineHeight:o.lineHeight,letterSpacing:o.letterSpacingEm,paragraphSpacing:e.paragraphSpacing,letterCase:e.case})}function We(e){return Object.keys($e(e)).length>0}function Ye({saved:e,old:o,styleId:t,values:i}){const n=oe(e);return{saved:_e(n,t,i),old:o}}function _e(e,o,t){return e.map(i=>i.id===o?F({...i,values:b({...i.values,...t})},i.auto):i)}function Je(e){const o=e.filter(t=>t.kind==="body").map(t=>Number(/^body-(\d+)$/.exec(t.id)?.[1])).filter(t=>Number.isInteger(t)&&t>0);return o.length?`body-${Math.max(...o)}`:"body-1"}export{Ke as accentItalicCss,Le as applyListChange,Je as eyebrowStyleId,Q as faceClassOf,xe as fromPanelStyles,We as hasStyleChange,Re as listChangePatch,oe as listToWrite,$e as partStyleToTextStyleValues,Ye as pushIntoStyle,M as resolveTextStyles,_e as setStyleValues,Me as siteTextFromRow,Ne as storedTextStyles,Ge as styleIdOfRole,De as textStylesCss,ie as textStylesFromOld,re as textStylesToOld,Ve as themeWithTextStyles,Fe as toPanelStyles,L as viewSizeOf};