@parathantl/react-email-editor 0.1.7 → 0.1.8
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 +21 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +21 -10
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -455,6 +455,8 @@ interface EmailEditorProps {
|
|
|
455
455
|
onTemplateLoad?: (template: EmailTemplate) => void;
|
|
456
456
|
/** Called when history state changes (undo/redo) */
|
|
457
457
|
onHistoryChange?: (canUndo: boolean, canRedo: boolean) => void;
|
|
458
|
+
/** React node rendered at the right end of the toolbar (e.g. a Save button). */
|
|
459
|
+
toolbarActions?: React.ReactNode;
|
|
458
460
|
}
|
|
459
461
|
interface EmailEditorRef {
|
|
460
462
|
getMJML: () => string;
|
package/dist/index.d.ts
CHANGED
|
@@ -455,6 +455,8 @@ interface EmailEditorProps {
|
|
|
455
455
|
onTemplateLoad?: (template: EmailTemplate) => void;
|
|
456
456
|
/** Called when history state changes (undo/redo) */
|
|
457
457
|
onHistoryChange?: (canUndo: boolean, canRedo: boolean) => void;
|
|
458
|
+
/** React node rendered at the right end of the toolbar (e.g. a Save button). */
|
|
459
|
+
toolbarActions?: React.ReactNode;
|
|
458
460
|
}
|
|
459
461
|
interface EmailEditorRef {
|
|
460
462
|
getMJML: () => string;
|
package/dist/index.js
CHANGED
|
@@ -2998,7 +2998,7 @@ 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
3003
|
const { canUndo, canRedo } = useHistoryContext();
|
|
3004
3004
|
const dispatch = useEditorDispatch();
|
|
@@ -3184,6 +3184,7 @@ var Toolbar = React3.memo(function Toolbar2({ sidebarOpen, propertiesOpen, onTog
|
|
|
3184
3184
|
] })
|
|
3185
3185
|
] })
|
|
3186
3186
|
] }),
|
|
3187
|
+
toolbarActions && /* @__PURE__ */ jsx4("div", { className: `ee-toolbar-actions ${toolbar_default.toolbarGroup}`, children: toolbarActions }),
|
|
3187
3188
|
/* @__PURE__ */ jsx4(
|
|
3188
3189
|
"input",
|
|
3189
3190
|
{
|
|
@@ -25096,12 +25097,12 @@ function preventBlur(e) {
|
|
|
25096
25097
|
}
|
|
25097
25098
|
e.preventDefault();
|
|
25098
25099
|
}
|
|
25099
|
-
function RichTextToolbar({ editor }) {
|
|
25100
|
+
function RichTextToolbar({ editor, defaultFontFamily, defaultFontSize }) {
|
|
25100
25101
|
if (!editor) return null;
|
|
25101
25102
|
return /* @__PURE__ */ jsxs11("div", { className: `ee-richtext-toolbar ${toolbar_default.richTextToolbar}`, onMouseDown: preventBlur, children: [
|
|
25102
25103
|
/* @__PURE__ */ jsxs11("div", { className: `ee-richtext-group ${toolbar_default.richTextGroup}`, children: [
|
|
25103
|
-
/* @__PURE__ */ jsx13(FontFamilySelect, { editor }),
|
|
25104
|
-
/* @__PURE__ */ jsx13(FontSizeSelect, { editor })
|
|
25104
|
+
/* @__PURE__ */ jsx13(FontFamilySelect, { editor, defaultFontFamily }),
|
|
25105
|
+
/* @__PURE__ */ jsx13(FontSizeSelect, { editor, defaultFontSize })
|
|
25105
25106
|
] }),
|
|
25106
25107
|
/* @__PURE__ */ jsxs11("div", { className: `ee-richtext-group ${toolbar_default.richTextGroup}`, children: [
|
|
25107
25108
|
/* @__PURE__ */ jsx13(Tooltip, { label: "Bold", shortcut: "Ctrl+B", children: /* @__PURE__ */ jsx13(
|
|
@@ -25284,9 +25285,10 @@ function RichTextToolbar({ editor }) {
|
|
|
25284
25285
|
] })
|
|
25285
25286
|
] });
|
|
25286
25287
|
}
|
|
25287
|
-
function FontFamilySelect({ editor }) {
|
|
25288
|
+
function FontFamilySelect({ editor, defaultFontFamily }) {
|
|
25288
25289
|
const { fontFamilies } = useEditorFonts();
|
|
25289
|
-
const
|
|
25290
|
+
const inlineFont = editor.getAttributes("textStyle").fontFamily || "";
|
|
25291
|
+
const currentFont = inlineFont || defaultFontFamily || "";
|
|
25290
25292
|
const fonts = fontFamilies.slice();
|
|
25291
25293
|
if (currentFont && !fonts.some((f) => f.toLowerCase() === currentFont.toLowerCase())) {
|
|
25292
25294
|
fonts.push(currentFont);
|
|
@@ -25312,9 +25314,10 @@ function FontFamilySelect({ editor }) {
|
|
|
25312
25314
|
}
|
|
25313
25315
|
);
|
|
25314
25316
|
}
|
|
25315
|
-
function FontSizeSelect({ editor }) {
|
|
25317
|
+
function FontSizeSelect({ editor, defaultFontSize }) {
|
|
25316
25318
|
const { fontSizes } = useEditorFonts();
|
|
25317
|
-
const
|
|
25319
|
+
const inlineSize = editor.getAttributes("textStyle").fontSize || "";
|
|
25320
|
+
const currentSize = inlineSize || defaultFontSize || "";
|
|
25318
25321
|
const sizes = fontSizes.slice();
|
|
25319
25322
|
if (currentSize && !sizes.includes(currentSize)) {
|
|
25320
25323
|
sizes.push(currentSize);
|
|
@@ -25743,7 +25746,14 @@ var TextBlockInner = function TextBlock({ block }) {
|
|
|
25743
25746
|
backgroundColor: p.backgroundColor && p.backgroundColor !== "transparent" ? p.backgroundColor : void 0
|
|
25744
25747
|
}), [p.fontFamily, p.fontSize, p.color, p.lineHeight, p.padding, p.fontWeight, p.textTransform, p.letterSpacing, p.backgroundColor]);
|
|
25745
25748
|
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(
|
|
25749
|
+
isFocused && editorInstance && /* @__PURE__ */ jsx14("div", { className: blocks_default.textBlockToolbar, children: /* @__PURE__ */ jsx14(
|
|
25750
|
+
RichTextToolbar,
|
|
25751
|
+
{
|
|
25752
|
+
editor: editorInstance,
|
|
25753
|
+
defaultFontFamily: p.fontFamily,
|
|
25754
|
+
defaultFontSize: p.fontSize
|
|
25755
|
+
}
|
|
25756
|
+
) }),
|
|
25747
25757
|
/* @__PURE__ */ jsx14("div", { style: wrapperStyle, children: /* @__PURE__ */ jsx14(
|
|
25748
25758
|
TipTapEditor,
|
|
25749
25759
|
{
|
|
@@ -29746,7 +29756,8 @@ var EditorInner = forwardRef2(function EditorInner2(props, ref) {
|
|
|
29746
29756
|
sidebarOpen,
|
|
29747
29757
|
propertiesOpen,
|
|
29748
29758
|
onToggleSidebar: toggleSidebar,
|
|
29749
|
-
onToggleProperties: toggleProperties
|
|
29759
|
+
onToggleProperties: toggleProperties,
|
|
29760
|
+
toolbarActions: props.toolbarActions
|
|
29750
29761
|
}
|
|
29751
29762
|
),
|
|
29752
29763
|
/* @__PURE__ */ jsxs47("div", { className: editor_default.editorBody, children: [
|