@parathantl/react-email-editor 0.1.7 → 0.1.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.
- package/dist/index.cjs +113 -65
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +74 -9
- package/dist/index.css.map +1 -1
- package/dist/index.d.mts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +113 -65
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2998,9 +2998,8 @@ var editor_default = {
|
|
|
2998
2998
|
|
|
2999
2999
|
// src/components/Toolbar/Toolbar.tsx
|
|
3000
3000
|
import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
3001
|
-
var Toolbar = React3.memo(function Toolbar2({ sidebarOpen, propertiesOpen, onToggleSidebar, onToggleProperties }) {
|
|
3001
|
+
var Toolbar = React3.memo(function Toolbar2({ sidebarOpen, propertiesOpen, onToggleSidebar, onToggleProperties, toolbarActions }) {
|
|
3002
3002
|
const { template, activeTab } = useTemplateContext();
|
|
3003
|
-
const { canUndo, canRedo } = useHistoryContext();
|
|
3004
3003
|
const dispatch = useEditorDispatch();
|
|
3005
3004
|
const fileInputRef = useRef6(null);
|
|
3006
3005
|
const [exportOpen, setExportOpen] = useState3(false);
|
|
@@ -3018,12 +3017,6 @@ var Toolbar = React3.memo(function Toolbar2({ sidebarOpen, propertiesOpen, onTog
|
|
|
3018
3017
|
},
|
|
3019
3018
|
[dispatch]
|
|
3020
3019
|
);
|
|
3021
|
-
const handleUndo = useCallback6(() => {
|
|
3022
|
-
dispatch({ type: "UNDO" });
|
|
3023
|
-
}, [dispatch]);
|
|
3024
|
-
const handleRedo = useCallback6(() => {
|
|
3025
|
-
dispatch({ type: "REDO" });
|
|
3026
|
-
}, [dispatch]);
|
|
3027
3020
|
const handleExportMJML = useCallback6(() => {
|
|
3028
3021
|
const mjml = generateMJML(templateRef.current);
|
|
3029
3022
|
const blob = new Blob([mjml], { type: "text/xml" });
|
|
@@ -3091,30 +3084,6 @@ var Toolbar = React3.memo(function Toolbar2({ sidebarOpen, propertiesOpen, onTog
|
|
|
3091
3084
|
[dispatch]
|
|
3092
3085
|
);
|
|
3093
3086
|
return /* @__PURE__ */ jsxs3("div", { className: `ee-toolbar ${toolbar_default.toolbar}`, role: "toolbar", "aria-label": "Editor toolbar", children: [
|
|
3094
|
-
/* @__PURE__ */ jsxs3("div", { className: `ee-toolbar-history ${toolbar_default.toolbarGroup}`, role: "group", "aria-label": "History", children: [
|
|
3095
|
-
/* @__PURE__ */ jsx4(
|
|
3096
|
-
"button",
|
|
3097
|
-
{
|
|
3098
|
-
className: `ee-toolbar-undo ${toolbar_default.toolbarBtn}`,
|
|
3099
|
-
onClick: handleUndo,
|
|
3100
|
-
disabled: !canUndo,
|
|
3101
|
-
title: "Undo (Ctrl+Z)",
|
|
3102
|
-
"aria-label": "Undo",
|
|
3103
|
-
children: "Undo"
|
|
3104
|
-
}
|
|
3105
|
-
),
|
|
3106
|
-
/* @__PURE__ */ jsx4(
|
|
3107
|
-
"button",
|
|
3108
|
-
{
|
|
3109
|
-
className: `ee-toolbar-redo ${toolbar_default.toolbarBtn}`,
|
|
3110
|
-
onClick: handleRedo,
|
|
3111
|
-
disabled: !canRedo,
|
|
3112
|
-
title: "Redo (Ctrl+Shift+Z)",
|
|
3113
|
-
"aria-label": "Redo",
|
|
3114
|
-
children: "Redo"
|
|
3115
|
-
}
|
|
3116
|
-
)
|
|
3117
|
-
] }),
|
|
3118
3087
|
/* @__PURE__ */ jsxs3("div", { className: editor_default.panelToggle, children: [
|
|
3119
3088
|
/* @__PURE__ */ jsx4(
|
|
3120
3089
|
"button",
|
|
@@ -3184,6 +3153,7 @@ var Toolbar = React3.memo(function Toolbar2({ sidebarOpen, propertiesOpen, onTog
|
|
|
3184
3153
|
] })
|
|
3185
3154
|
] })
|
|
3186
3155
|
] }),
|
|
3156
|
+
toolbarActions && /* @__PURE__ */ jsx4("div", { className: `ee-toolbar-actions ${toolbar_default.toolbarGroup}`, children: toolbarActions }),
|
|
3187
3157
|
/* @__PURE__ */ jsx4(
|
|
3188
3158
|
"input",
|
|
3189
3159
|
{
|
|
@@ -25096,12 +25066,12 @@ function preventBlur(e) {
|
|
|
25096
25066
|
}
|
|
25097
25067
|
e.preventDefault();
|
|
25098
25068
|
}
|
|
25099
|
-
function RichTextToolbar({ editor }) {
|
|
25069
|
+
function RichTextToolbar({ editor, defaultFontFamily, defaultFontSize }) {
|
|
25100
25070
|
if (!editor) return null;
|
|
25101
25071
|
return /* @__PURE__ */ jsxs11("div", { className: `ee-richtext-toolbar ${toolbar_default.richTextToolbar}`, onMouseDown: preventBlur, children: [
|
|
25102
25072
|
/* @__PURE__ */ jsxs11("div", { className: `ee-richtext-group ${toolbar_default.richTextGroup}`, children: [
|
|
25103
|
-
/* @__PURE__ */ jsx13(FontFamilySelect, { editor }),
|
|
25104
|
-
/* @__PURE__ */ jsx13(FontSizeSelect, { editor })
|
|
25073
|
+
/* @__PURE__ */ jsx13(FontFamilySelect, { editor, defaultFontFamily }),
|
|
25074
|
+
/* @__PURE__ */ jsx13(FontSizeSelect, { editor, defaultFontSize })
|
|
25105
25075
|
] }),
|
|
25106
25076
|
/* @__PURE__ */ jsxs11("div", { className: `ee-richtext-group ${toolbar_default.richTextGroup}`, children: [
|
|
25107
25077
|
/* @__PURE__ */ jsx13(Tooltip, { label: "Bold", shortcut: "Ctrl+B", children: /* @__PURE__ */ jsx13(
|
|
@@ -25284,9 +25254,10 @@ function RichTextToolbar({ editor }) {
|
|
|
25284
25254
|
] })
|
|
25285
25255
|
] });
|
|
25286
25256
|
}
|
|
25287
|
-
function FontFamilySelect({ editor }) {
|
|
25257
|
+
function FontFamilySelect({ editor, defaultFontFamily }) {
|
|
25288
25258
|
const { fontFamilies } = useEditorFonts();
|
|
25289
|
-
const
|
|
25259
|
+
const inlineFont = editor.getAttributes("textStyle").fontFamily || "";
|
|
25260
|
+
const currentFont = inlineFont || defaultFontFamily || "";
|
|
25290
25261
|
const fonts = fontFamilies.slice();
|
|
25291
25262
|
if (currentFont && !fonts.some((f) => f.toLowerCase() === currentFont.toLowerCase())) {
|
|
25292
25263
|
fonts.push(currentFont);
|
|
@@ -25312,9 +25283,10 @@ function FontFamilySelect({ editor }) {
|
|
|
25312
25283
|
}
|
|
25313
25284
|
);
|
|
25314
25285
|
}
|
|
25315
|
-
function FontSizeSelect({ editor }) {
|
|
25286
|
+
function FontSizeSelect({ editor, defaultFontSize }) {
|
|
25316
25287
|
const { fontSizes } = useEditorFonts();
|
|
25317
|
-
const
|
|
25288
|
+
const inlineSize = editor.getAttributes("textStyle").fontSize || "";
|
|
25289
|
+
const currentSize = inlineSize || defaultFontSize || "";
|
|
25318
25290
|
const sizes = fontSizes.slice();
|
|
25319
25291
|
if (currentSize && !sizes.includes(currentSize)) {
|
|
25320
25292
|
sizes.push(currentSize);
|
|
@@ -25743,7 +25715,14 @@ var TextBlockInner = function TextBlock({ block }) {
|
|
|
25743
25715
|
backgroundColor: p.backgroundColor && p.backgroundColor !== "transparent" ? p.backgroundColor : void 0
|
|
25744
25716
|
}), [p.fontFamily, p.fontSize, p.color, p.lineHeight, p.padding, p.fontWeight, p.textTransform, p.letterSpacing, p.backgroundColor]);
|
|
25745
25717
|
return /* @__PURE__ */ jsxs12("div", { className: `ee-block-text ${blocks_default.textBlock}`, ref: wrapperRef, children: [
|
|
25746
|
-
isFocused && editorInstance && /* @__PURE__ */ jsx14("div", { className: blocks_default.textBlockToolbar, children: /* @__PURE__ */ jsx14(
|
|
25718
|
+
isFocused && editorInstance && /* @__PURE__ */ jsx14("div", { className: blocks_default.textBlockToolbar, children: /* @__PURE__ */ jsx14(
|
|
25719
|
+
RichTextToolbar,
|
|
25720
|
+
{
|
|
25721
|
+
editor: editorInstance,
|
|
25722
|
+
defaultFontFamily: p.fontFamily,
|
|
25723
|
+
defaultFontSize: p.fontSize
|
|
25724
|
+
}
|
|
25725
|
+
) }),
|
|
25747
25726
|
/* @__PURE__ */ jsx14("div", { style: wrapperStyle, children: /* @__PURE__ */ jsx14(
|
|
25748
25727
|
TipTapEditor,
|
|
25749
25728
|
{
|
|
@@ -27457,6 +27436,12 @@ import React26, { useState as useState14, useCallback as useCallback18, useRef a
|
|
|
27457
27436
|
|
|
27458
27437
|
// src/styles/canvas.module.css
|
|
27459
27438
|
var canvas_default = {
|
|
27439
|
+
"canvasArea": "canvasArea",
|
|
27440
|
+
"canvasHeader": "canvasHeader",
|
|
27441
|
+
"canvasHeaderCenter": "canvasHeaderCenter",
|
|
27442
|
+
"canvasHeaderGroup": "canvasHeaderGroup",
|
|
27443
|
+
"canvasHeaderBtn": "canvasHeaderBtn",
|
|
27444
|
+
"canvasHeaderBtnActive": "canvasHeaderBtnActive",
|
|
27460
27445
|
"canvasWrapper": "canvasWrapper",
|
|
27461
27446
|
"canvasBody": "canvasBody",
|
|
27462
27447
|
"canvasBodyDragOver": "canvasBodyDragOver",
|
|
@@ -27998,10 +27983,13 @@ var SectionDropZone = React29.memo(function SectionDropZone2({ index }) {
|
|
|
27998
27983
|
|
|
27999
27984
|
// src/components/Canvas/Canvas.tsx
|
|
28000
27985
|
import { jsx as jsx32, jsxs as jsxs22 } from "react/jsx-runtime";
|
|
27986
|
+
var MOBILE_WIDTH = 375;
|
|
28001
27987
|
var Canvas = React30.memo(function Canvas2() {
|
|
28002
27988
|
const { template } = useTemplateContext();
|
|
27989
|
+
const { canUndo, canRedo } = useHistoryContext();
|
|
28003
27990
|
const dispatch = useEditorDispatch();
|
|
28004
27991
|
const [isDragOver, setIsDragOver] = useState18(false);
|
|
27992
|
+
const [previewMode, setPreviewMode] = useState18("desktop");
|
|
28005
27993
|
const handleAddSection = useCallback22(() => {
|
|
28006
27994
|
dispatch({ type: "ADD_SECTION", payload: { section: createSection() } });
|
|
28007
27995
|
}, [dispatch]);
|
|
@@ -28039,30 +28027,89 @@ var Canvas = React30.memo(function Canvas2() {
|
|
|
28039
28027
|
},
|
|
28040
28028
|
[dispatch]
|
|
28041
28029
|
);
|
|
28042
|
-
|
|
28043
|
-
"
|
|
28044
|
-
|
|
28045
|
-
|
|
28046
|
-
|
|
28047
|
-
|
|
28048
|
-
|
|
28049
|
-
|
|
28050
|
-
|
|
28051
|
-
|
|
28052
|
-
|
|
28053
|
-
|
|
28054
|
-
|
|
28055
|
-
|
|
28056
|
-
|
|
28057
|
-
|
|
28058
|
-
|
|
28059
|
-
|
|
28060
|
-
|
|
28061
|
-
|
|
28062
|
-
|
|
28063
|
-
|
|
28064
|
-
|
|
28065
|
-
|
|
28030
|
+
const handleUndo = useCallback22(() => {
|
|
28031
|
+
dispatch({ type: "UNDO" });
|
|
28032
|
+
}, [dispatch]);
|
|
28033
|
+
const handleRedo = useCallback22(() => {
|
|
28034
|
+
dispatch({ type: "REDO" });
|
|
28035
|
+
}, [dispatch]);
|
|
28036
|
+
const canvasWidth = previewMode === "mobile" ? MOBILE_WIDTH : template.globalStyles.width;
|
|
28037
|
+
return /* @__PURE__ */ jsxs22("div", { className: `ee-canvas-area ${canvas_default.canvasArea}`, children: [
|
|
28038
|
+
/* @__PURE__ */ jsxs22("div", { className: `ee-canvas-header ${canvas_default.canvasHeader}`, children: [
|
|
28039
|
+
/* @__PURE__ */ jsx32("div", { className: `ee-canvas-header-center ${canvas_default.canvasHeaderCenter}`, children: /* @__PURE__ */ jsxs22("div", { className: `ee-canvas-view-toggle ${canvas_default.canvasHeaderGroup}`, role: "group", "aria-label": "Preview size", children: [
|
|
28040
|
+
/* @__PURE__ */ jsx32(
|
|
28041
|
+
"button",
|
|
28042
|
+
{
|
|
28043
|
+
className: `ee-canvas-view-desktop ${canvas_default.canvasHeaderBtn} ${previewMode === "desktop" ? `ee-canvas-view--active ${canvas_default.canvasHeaderBtnActive}` : ""}`,
|
|
28044
|
+
onClick: () => setPreviewMode("desktop"),
|
|
28045
|
+
"aria-pressed": previewMode === "desktop",
|
|
28046
|
+
"aria-label": "Desktop view",
|
|
28047
|
+
title: `Desktop (${template.globalStyles.width}px)`,
|
|
28048
|
+
children: "\u{1F5A5}"
|
|
28049
|
+
}
|
|
28050
|
+
),
|
|
28051
|
+
/* @__PURE__ */ jsx32(
|
|
28052
|
+
"button",
|
|
28053
|
+
{
|
|
28054
|
+
className: `ee-canvas-view-mobile ${canvas_default.canvasHeaderBtn} ${previewMode === "mobile" ? `ee-canvas-view--active ${canvas_default.canvasHeaderBtnActive}` : ""}`,
|
|
28055
|
+
onClick: () => setPreviewMode("mobile"),
|
|
28056
|
+
"aria-pressed": previewMode === "mobile",
|
|
28057
|
+
"aria-label": "Mobile view",
|
|
28058
|
+
title: "Mobile (375px)",
|
|
28059
|
+
children: "\u{1F4F1}"
|
|
28060
|
+
}
|
|
28061
|
+
)
|
|
28062
|
+
] }) }),
|
|
28063
|
+
/* @__PURE__ */ jsxs22("div", { className: `ee-canvas-history ${canvas_default.canvasHeaderGroup}`, role: "group", "aria-label": "History", children: [
|
|
28064
|
+
/* @__PURE__ */ jsx32(
|
|
28065
|
+
"button",
|
|
28066
|
+
{
|
|
28067
|
+
className: `ee-canvas-undo ${canvas_default.canvasHeaderBtn}`,
|
|
28068
|
+
onClick: handleUndo,
|
|
28069
|
+
disabled: !canUndo,
|
|
28070
|
+
title: "Undo (Ctrl+Z)",
|
|
28071
|
+
"aria-label": "Undo",
|
|
28072
|
+
children: "\u21A9"
|
|
28073
|
+
}
|
|
28074
|
+
),
|
|
28075
|
+
/* @__PURE__ */ jsx32(
|
|
28076
|
+
"button",
|
|
28077
|
+
{
|
|
28078
|
+
className: `ee-canvas-redo ${canvas_default.canvasHeaderBtn}`,
|
|
28079
|
+
onClick: handleRedo,
|
|
28080
|
+
disabled: !canRedo,
|
|
28081
|
+
title: "Redo (Ctrl+Shift+Z)",
|
|
28082
|
+
"aria-label": "Redo",
|
|
28083
|
+
children: "\u21AA"
|
|
28084
|
+
}
|
|
28085
|
+
)
|
|
28086
|
+
] })
|
|
28087
|
+
] }),
|
|
28088
|
+
/* @__PURE__ */ jsx32("div", { className: `ee-canvas-wrapper ${canvas_default.canvasWrapper}`, onClick: handleCanvasClick, role: "main", "aria-label": "Email canvas", children: /* @__PURE__ */ jsxs22(
|
|
28089
|
+
"div",
|
|
28090
|
+
{
|
|
28091
|
+
className: `ee-canvas-body ${canvas_default.canvasBody} ${isDragOver ? canvas_default.canvasBodyDragOver : ""}`,
|
|
28092
|
+
style: {
|
|
28093
|
+
width: canvasWidth,
|
|
28094
|
+
backgroundColor: template.globalStyles.backgroundColor,
|
|
28095
|
+
fontFamily: template.globalStyles.fontFamily
|
|
28096
|
+
},
|
|
28097
|
+
onClick: (e) => e.stopPropagation(),
|
|
28098
|
+
onDragOver: handleBodyDragOver,
|
|
28099
|
+
onDragLeave: handleBodyDragLeave,
|
|
28100
|
+
onDrop: handleBodyDrop,
|
|
28101
|
+
"aria-label": "Email content area",
|
|
28102
|
+
children: [
|
|
28103
|
+
template.sections.map((section, index) => /* @__PURE__ */ jsxs22(React30.Fragment, { children: [
|
|
28104
|
+
/* @__PURE__ */ jsx32(SectionDropZone, { index }),
|
|
28105
|
+
/* @__PURE__ */ jsx32(Section, { section })
|
|
28106
|
+
] }, section.id)),
|
|
28107
|
+
template.sections.length > 0 && /* @__PURE__ */ jsx32(SectionDropZone, { index: template.sections.length }),
|
|
28108
|
+
/* @__PURE__ */ jsx32("button", { className: `ee-add-section ${canvas_default.addSectionBtn}`, onClick: handleAddSection, "aria-label": "Add new section", children: "+ Add Section" })
|
|
28109
|
+
]
|
|
28110
|
+
}
|
|
28111
|
+
) })
|
|
28112
|
+
] });
|
|
28066
28113
|
});
|
|
28067
28114
|
|
|
28068
28115
|
// src/components/Properties/SectionProperties.tsx
|
|
@@ -29746,7 +29793,8 @@ var EditorInner = forwardRef2(function EditorInner2(props, ref) {
|
|
|
29746
29793
|
sidebarOpen,
|
|
29747
29794
|
propertiesOpen,
|
|
29748
29795
|
onToggleSidebar: toggleSidebar,
|
|
29749
|
-
onToggleProperties: toggleProperties
|
|
29796
|
+
onToggleProperties: toggleProperties,
|
|
29797
|
+
toolbarActions: props.toolbarActions
|
|
29750
29798
|
}
|
|
29751
29799
|
),
|
|
29752
29800
|
/* @__PURE__ */ jsxs47("div", { className: editor_default.editorBody, children: [
|