@ivanholiak/easy-email-extensions 4.16.23 → 4.16.25

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.
@@ -1,4 +1,5 @@
1
1
  import React from 'react';
2
+ import './FontFamily.scss';
2
3
  export declare function FontFamily({ name }: {
3
4
  name?: string;
4
5
  }): React.JSX.Element;
@@ -0,0 +1,2 @@
1
+ import React from 'react';
2
+ export declare function Code(): React.JSX.Element;
@@ -18,6 +18,7 @@ import { Hero } from './Hero';
18
18
  import { Navbar } from './Navbar';
19
19
  import { Social } from './Social';
20
20
  import { Table } from './Table';
21
+ import { Code } from './Code';
21
22
  import { AdvancedTable } from './AdvancedTable';
22
23
  export declare const blocks: {
23
24
  page: typeof Page;
@@ -40,6 +41,7 @@ export declare const blocks: {
40
41
  navbar: typeof Navbar;
41
42
  social: typeof Social;
42
43
  table: typeof Table;
44
+ code: typeof Code;
43
45
  advanced_text: typeof Text;
44
46
  advanced_image: typeof Image;
45
47
  advanced_button: typeof Button;
@@ -50,6 +52,7 @@ export declare const blocks: {
50
52
  advanced_navbar: typeof Navbar;
51
53
  advanced_social: typeof Social;
52
54
  advanced_table: typeof AdvancedTable;
55
+ advanced_code: typeof Code;
53
56
  advanced_hero: typeof Hero;
54
57
  advanced_wrapper: typeof Wrapper;
55
58
  advanced_section: typeof Section;
@@ -0,0 +1,2 @@
1
+ import React from 'react';
2
+ export declare function CodeBlockItem(): React.JSX.Element;
package/lib/index2.js CHANGED
@@ -38394,7 +38394,7 @@ function useFontFamily() {
38394
38394
  };
38395
38395
  }
38396
38396
  var styleText$2 = ".easy-email-extensions-Tools-Popover .ee-popover-content{padding:0}.easy-email-extensions-Tools-Popover .ee-popover-content-inner *::-webkit-scrollbar{-webkit-appearance:none;width:5px}.easy-email-extensions-Tools-Popover .ee-popover-content-inner *::-webkit-scrollbar-thumb{border-radius:5px;background-color:#00000080;box-shadow:0 0 1px #ffffff80;-webkit-box-shadow:0 0 1px rgba(255,255,255,.5)}\n";
38397
- function FontFamily$1(props) {
38397
+ function FontFamily$2(props) {
38398
38398
  const { fontList: fontList2 } = useFontFamily();
38399
38399
  const { execCommand } = props;
38400
38400
  const [visible, setVisible] = React__default.useState(false);
@@ -38696,11 +38696,13 @@ function EyeIcon() {
38696
38696
  onClick: onToggleVisible
38697
38697
  });
38698
38698
  }
38699
+ var FontFamily$1 = "";
38699
38700
  function FontFamily({ name: name2 }) {
38700
38701
  const { focusIdx: focusIdx2 } = useFocusIdx();
38701
38702
  const { fontList: defaultFontList } = useEditorProps();
38702
38703
  const { pageData: pageData2 } = useEditorContext();
38703
38704
  const [searchValue, setSearchValue] = useState("");
38705
+ const loadedRef = useRef(/* @__PURE__ */ new Set());
38704
38706
  const addFonts = pageData2.data.value.fonts;
38705
38707
  const allOptions = useMemo(() => {
38706
38708
  const options2 = [];
@@ -38729,21 +38731,38 @@ function FontFamily({ name: name2 }) {
38729
38731
  }
38730
38732
  return options2;
38731
38733
  }, [addFonts, defaultFontList]);
38732
- useEffect(() => {
38734
+ const filteredOptions = useMemo(() => {
38735
+ if (!searchValue)
38736
+ return allOptions;
38733
38737
  const search = searchValue.toLowerCase();
38734
- const visible = search ? allOptions.filter((opt2) => opt2.value.toLowerCase().includes(search)) : allOptions;
38735
- const fontsToLoad = visible.slice(0, 15).map((opt2) => opt2.value).filter((f2) => GOOGLE_FONTS.includes(f2));
38736
- if (fontsToLoad.length > 0) {
38737
- loadGoogleFontsPreview(fontsToLoad);
38738
- }
38738
+ return allOptions.filter((opt2) => opt2.value.toLowerCase().includes(search));
38739
38739
  }, [searchValue, allOptions]);
38740
+ const loadFontsBatch = useCallback((fonts) => {
38741
+ const toLoad = fonts.map((f2) => f2.value).filter((f2) => GOOGLE_FONTS.includes(f2) && !loadedRef.current.has(f2));
38742
+ if (toLoad.length > 0) {
38743
+ toLoad.forEach((f2) => loadedRef.current.add(f2));
38744
+ loadGoogleFontsPreview(toLoad);
38745
+ }
38746
+ }, []);
38747
+ useEffect(() => {
38748
+ loadFontsBatch(filteredOptions.slice(0, 20));
38749
+ }, [filteredOptions, loadFontsBatch]);
38740
38750
  const handleSearch = useCallback((val) => {
38741
38751
  setSearchValue(val);
38742
38752
  }, []);
38753
+ const handlePopupScroll = useCallback((e2) => {
38754
+ const target2 = e2.target;
38755
+ const scrollRatio = (target2.scrollTop + target2.clientHeight) / target2.scrollHeight;
38756
+ if (scrollRatio > 0.7) {
38757
+ const approxIndex = Math.floor(target2.scrollTop / target2.scrollHeight * filteredOptions.length);
38758
+ loadFontsBatch(filteredOptions.slice(approxIndex, approxIndex + 20));
38759
+ }
38760
+ }, [filteredOptions, loadFontsBatch]);
38743
38761
  const fieldName = name2 || `${focusIdx2}.attributes.font-family`;
38744
38762
  return /* @__PURE__ */ React__default.createElement(Field, {
38745
38763
  name: fieldName
38746
38764
  }, ({ input: { onChange, onBlur: onBlur3, value } }) => /* @__PURE__ */ React__default.createElement(Form.Item, {
38765
+ className: "easy-email-font-family-field",
38747
38766
  label: t("Font family"),
38748
38767
  labelCol: { span: 24, style: { paddingRight: 0 } },
38749
38768
  wrapperCol: { span: 24 },
@@ -38761,12 +38780,20 @@ function FontFamily({ name: name2 }) {
38761
38780
  onBlur3();
38762
38781
  setSearchValue("");
38763
38782
  },
38783
+ onVisibleChange: (visible) => {
38784
+ if (visible) {
38785
+ loadFontsBatch(filteredOptions.slice(0, 20));
38786
+ }
38787
+ },
38764
38788
  filterOption: (inputValue, option) => {
38765
38789
  var _a2;
38766
38790
  const optValue = (((_a2 = option.props) == null ? void 0 : _a2.value) || "").toLowerCase();
38767
38791
  return optValue.includes(inputValue.toLowerCase());
38768
38792
  },
38769
- virtualListProps: { height: 256 },
38793
+ virtualListProps: {
38794
+ height: 256,
38795
+ onScroll: handlePopupScroll
38796
+ },
38770
38797
  style: { width: "100%" },
38771
38798
  dropdownMenuClassName: "easy-email-overlay",
38772
38799
  allowClear: true
@@ -40185,8 +40212,8 @@ const ShadowDom = (props) => {
40185
40212
  ref: setRef
40186
40213
  }), root2 && ReactDOM$1.createPortal(props.children, root2)));
40187
40214
  };
40188
- const CodeMirrorEditorPromise = import("./index3.js");
40189
- const CodeMirrorEditor = React__default.lazy(() => CodeMirrorEditorPromise);
40215
+ const CodeMirrorEditorPromise$1 = import("./index3.js");
40216
+ const CodeMirrorEditor$1 = React__default.lazy(() => CodeMirrorEditorPromise$1);
40190
40217
  const HtmlEditor = (props) => {
40191
40218
  const { visible, setVisible } = props;
40192
40219
  const { focusBlock: focusBlock2, setValueByIdx: setValueByIdx2 } = useBlock();
@@ -40255,7 +40282,7 @@ const HtmlEditor = (props) => {
40255
40282
  color: "#fff"
40256
40283
  }
40257
40284
  }, t("Editor Loading..."))
40258
- }, /* @__PURE__ */ React__default.createElement(CodeMirrorEditor, {
40285
+ }, /* @__PURE__ */ React__default.createElement(CodeMirrorEditor$1, {
40259
40286
  value: content,
40260
40287
  onChange: setContent
40261
40288
  }))), /* @__PURE__ */ React__default.createElement("div", {
@@ -41370,6 +41397,47 @@ function Table() {
41370
41397
  setVisible
41371
41398
  }));
41372
41399
  }
41400
+ const CodeMirrorEditorPromise = import("./index3.js");
41401
+ const CodeMirrorEditor = React__default.lazy(() => CodeMirrorEditorPromise);
41402
+ function Code() {
41403
+ const { focusBlock: focusBlock2, setValueByIdx: setValueByIdx2 } = useBlock();
41404
+ const { focusIdx: focusIdx2 } = useFocusIdx();
41405
+ const content = (focusBlock2 == null ? void 0 : focusBlock2.data.value.content) || "";
41406
+ const onChangeContent = (val) => {
41407
+ if (!focusBlock2)
41408
+ return;
41409
+ focusBlock2.data.value.content = val;
41410
+ setValueByIdx2(focusIdx2, __spreadValues({}, focusBlock2));
41411
+ };
41412
+ return /* @__PURE__ */ React__default.createElement(AttributesPanelWrapper, null, /* @__PURE__ */ React__default.createElement(CollapseWrapper, {
41413
+ defaultActiveKey: ["0", "1", "2"]
41414
+ }, /* @__PURE__ */ React__default.createElement(Collapse$1.Item, {
41415
+ name: "0",
41416
+ header: t("Code content")
41417
+ }, /* @__PURE__ */ React__default.createElement(Suspense, {
41418
+ fallback: /* @__PURE__ */ React__default.createElement("div", null, t("Loading..."))
41419
+ }, /* @__PURE__ */ React__default.createElement(CodeMirrorEditor, {
41420
+ value: content,
41421
+ onChange: onChangeContent
41422
+ }))), /* @__PURE__ */ React__default.createElement(Collapse$1.Item, {
41423
+ name: "1",
41424
+ header: t("Dimension")
41425
+ }, /* @__PURE__ */ React__default.createElement(Space$1, {
41426
+ direction: "vertical"
41427
+ }, /* @__PURE__ */ React__default.createElement(Padding, {
41428
+ showResetAll: true
41429
+ }))), /* @__PURE__ */ React__default.createElement(Collapse$1.Item, {
41430
+ name: "2",
41431
+ header: t("Color")
41432
+ }, /* @__PURE__ */ React__default.createElement(Grid$1.Row, null, /* @__PURE__ */ React__default.createElement(Grid$1.Col, {
41433
+ span: 11
41434
+ }, /* @__PURE__ */ React__default.createElement(Color, null)), /* @__PURE__ */ React__default.createElement(Grid$1.Col, {
41435
+ offset: 1,
41436
+ span: 11
41437
+ }, /* @__PURE__ */ React__default.createElement(ContainerBackgroundColor, {
41438
+ title: t("Background color")
41439
+ }))))));
41440
+ }
41373
41441
  function AdvancedTable() {
41374
41442
  const { focusIdx: focusIdx2 } = useFocusIdx();
41375
41443
  return /* @__PURE__ */ React__default.createElement(AttributesPanelWrapper, null, /* @__PURE__ */ React__default.createElement(CollapseWrapper, {
@@ -41425,6 +41493,7 @@ const blocks = {
41425
41493
  [BasicType.NAVBAR]: Navbar,
41426
41494
  [BasicType.SOCIAL]: Social,
41427
41495
  [BasicType.TABLE]: Table,
41496
+ [BasicType.CODE]: Code,
41428
41497
  [AdvancedType.TEXT]: Text,
41429
41498
  [AdvancedType.IMAGE]: Image$1,
41430
41499
  [AdvancedType.BUTTON]: Button,
@@ -41435,6 +41504,7 @@ const blocks = {
41435
41504
  [AdvancedType.NAVBAR]: Navbar,
41436
41505
  [AdvancedType.SOCIAL]: Social,
41437
41506
  [AdvancedType.TABLE]: AdvancedTable,
41507
+ [AdvancedType.CODE]: Code,
41438
41508
  [AdvancedType.HERO]: Hero,
41439
41509
  [AdvancedType.WRAPPER]: Wrapper,
41440
41510
  [AdvancedType.SECTION]: Section,
@@ -55046,7 +55116,7 @@ function Tools(props) {
55046
55116
  ];
55047
55117
  case AvailableTools.FontFamily:
55048
55118
  return [
55049
- /* @__PURE__ */ React__default.createElement(FontFamily$1, {
55119
+ /* @__PURE__ */ React__default.createElement(FontFamily$2, {
55050
55120
  key: tool,
55051
55121
  execCommand,
55052
55122
  getPopupContainer: getPopoverMountNode
@@ -57158,6 +57228,36 @@ function SocialBlockItem() {
57158
57228
  })));
57159
57229
  })));
57160
57230
  }
57231
+ function CodeBlockItem() {
57232
+ return /* @__PURE__ */ React__default.createElement(Stack$4.Item, {
57233
+ fill: true
57234
+ }, /* @__PURE__ */ React__default.createElement(Stack$4, {
57235
+ vertical: true
57236
+ }, /* @__PURE__ */ React__default.createElement(Stack$4.Item, {
57237
+ fill: true
57238
+ }, /* @__PURE__ */ React__default.createElement(BlockMaskWrapper, {
57239
+ type: AdvancedType.CODE,
57240
+ payload: {
57241
+ data: {
57242
+ value: {
57243
+ content: "const greet = (name) => {\n console.log(`Hello, ${name}!`);\n};\ngreet('World');"
57244
+ }
57245
+ }
57246
+ }
57247
+ }, /* @__PURE__ */ React__default.createElement("div", {
57248
+ style: {
57249
+ backgroundColor: "#f4f4f4",
57250
+ borderRadius: 4,
57251
+ padding: "12px 16px",
57252
+ fontFamily: "'Courier New', Courier, monospace",
57253
+ fontSize: 12,
57254
+ lineHeight: 1.5,
57255
+ whiteSpace: "pre-wrap",
57256
+ wordWrap: "break-word",
57257
+ color: "#333"
57258
+ }
57259
+ }, "const greet = (name) => {\n console.log(`Hello, ${name}!`);\n};")))));
57260
+ }
57161
57261
  function WrapperBlockItem() {
57162
57262
  return /* @__PURE__ */ React__default.createElement(Stack$4.Item, {
57163
57263
  fill: true
@@ -58050,6 +58150,16 @@ const defaultCategories$1 = [
58050
58150
  );
58051
58151
  },
58052
58152
  component: SocialBlockItem
58153
+ },
58154
+ {
58155
+ type: AdvancedType.CODE,
58156
+ get title() {
58157
+ return t("Code");
58158
+ },
58159
+ get description() {
58160
+ return t("Displays a formatted code snippet in your email.");
58161
+ },
58162
+ component: CodeBlockItem
58053
58163
  }
58054
58164
  ]
58055
58165
  },