@react-email/editor 0.0.0-experimental.20 → 0.0.0-experimental.21
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 +39 -113
- package/dist/index.d.cts +55 -87
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +55 -87
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +37 -115
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -1
package/dist/index.mjs
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import * as ReactEmailComponents from "@react-email/components";
|
|
2
2
|
import { Body as Body$1, Button as Button$1, CodeBlock, Column, Head, Heading as Heading$1, Hr, Html, Link as Link$1, Preview, Row, Section as Section$1, pretty, render, toPlainText } from "@react-email/components";
|
|
3
3
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
-
import { Extension, InputRule, Mark, Node as Node$1, findChildren,
|
|
4
|
+
import { Extension, InputRule, Mark, Node as Node$1, findChildren, mergeAttributes } from "@tiptap/core";
|
|
5
5
|
import { UndoRedo } from "@tiptap/extensions";
|
|
6
6
|
import { NodeViewContent, NodeViewWrapper, ReactNodeViewRenderer, ReactRenderer, useCurrentEditor, useEditor as useEditor$1, useEditorState } from "@tiptap/react";
|
|
7
7
|
import * as React from "react";
|
|
8
8
|
import { useCallback, useEffect, useImperativeHandle, useLayoutEffect, useRef, useState } from "react";
|
|
9
9
|
import TipTapStarterKit from "@tiptap/starter-kit";
|
|
10
10
|
import BlockquoteBase from "@tiptap/extension-blockquote";
|
|
11
|
+
import BoldBase from "@tiptap/extension-bold";
|
|
11
12
|
import BulletListBase from "@tiptap/extension-bullet-list";
|
|
12
13
|
import CodeBase from "@tiptap/extension-code";
|
|
13
14
|
import CodeBlock$1 from "@tiptap/extension-code-block";
|
|
@@ -25,6 +26,8 @@ import OrderedListBase from "@tiptap/extension-ordered-list";
|
|
|
25
26
|
import ParagraphBase from "@tiptap/extension-paragraph";
|
|
26
27
|
import TipTapPlaceholder from "@tiptap/extension-placeholder";
|
|
27
28
|
import StrikeBase from "@tiptap/extension-strike";
|
|
29
|
+
import SuperscriptBase from "@tiptap/extension-superscript";
|
|
30
|
+
import UnderlineBase from "@tiptap/extension-underline";
|
|
28
31
|
import { generateJSON } from "@tiptap/html";
|
|
29
32
|
import { AlignCenterIcon, AlignLeftIcon, AlignRightIcon, BoldIcon, CaseUpperIcon, Check, ChevronDown, Code as Code$1, CodeIcon, Columns2, Columns3, Columns4, ExternalLinkIcon, Heading1, Heading2, Heading3, ItalicIcon, LinkIcon, List, ListOrdered, MousePointer, PencilIcon, Rows2, SplitSquareVertical, SquareCode, StrikethroughIcon, Text, TextIcon, TextQuote, UnderlineIcon, UnlinkIcon } from "lucide-react";
|
|
30
33
|
import * as Popover from "@radix-ui/react-popover";
|
|
@@ -645,95 +648,23 @@ const Body = EmailNode.create({
|
|
|
645
648
|
|
|
646
649
|
//#endregion
|
|
647
650
|
//#region src/extensions/bold.tsx
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
* This extension allows you to mark text as bold.
|
|
666
|
-
* @see https://tiptap.dev/api/marks/bold
|
|
667
|
-
*/
|
|
668
|
-
const Bold = EmailMark.create({
|
|
669
|
-
name: "bold",
|
|
670
|
-
addOptions() {
|
|
671
|
-
return { HTMLAttributes: {} };
|
|
672
|
-
},
|
|
673
|
-
parseHTML() {
|
|
674
|
-
return [
|
|
675
|
-
{ tag: "strong" },
|
|
676
|
-
{
|
|
677
|
-
tag: "b",
|
|
678
|
-
getAttrs: (node) => node.style.fontWeight !== "normal" && null
|
|
679
|
-
},
|
|
680
|
-
{
|
|
681
|
-
style: "font-weight=400",
|
|
682
|
-
clearMark: (mark) => mark.type.name === this.name
|
|
683
|
-
}
|
|
684
|
-
];
|
|
685
|
-
},
|
|
686
|
-
renderHTML({ HTMLAttributes }) {
|
|
687
|
-
return [
|
|
688
|
-
"strong",
|
|
689
|
-
mergeAttributes(this.options.HTMLAttributes, HTMLAttributes),
|
|
690
|
-
0
|
|
691
|
-
];
|
|
692
|
-
},
|
|
693
|
-
renderToReactEmail({ children, style }) {
|
|
694
|
-
return /* @__PURE__ */ jsx("strong", {
|
|
695
|
-
style,
|
|
696
|
-
children
|
|
697
|
-
});
|
|
698
|
-
},
|
|
699
|
-
addCommands() {
|
|
700
|
-
return {
|
|
701
|
-
setBold: () => ({ commands }) => {
|
|
702
|
-
return commands.setMark(this.name);
|
|
703
|
-
},
|
|
704
|
-
toggleBold: () => ({ commands }) => {
|
|
705
|
-
return commands.toggleMark(this.name);
|
|
706
|
-
},
|
|
707
|
-
unsetBold: () => ({ commands }) => {
|
|
708
|
-
return commands.unsetMark(this.name);
|
|
709
|
-
}
|
|
710
|
-
};
|
|
711
|
-
},
|
|
712
|
-
addKeyboardShortcuts() {
|
|
713
|
-
return {
|
|
714
|
-
"Mod-b": () => this.editor.commands.toggleBold(),
|
|
715
|
-
"Mod-B": () => this.editor.commands.toggleBold()
|
|
716
|
-
};
|
|
717
|
-
},
|
|
718
|
-
addInputRules() {
|
|
719
|
-
return [markInputRule({
|
|
720
|
-
find: starInputRegex,
|
|
721
|
-
type: this.type
|
|
722
|
-
}), markInputRule({
|
|
723
|
-
find: underscoreInputRegex,
|
|
724
|
-
type: this.type
|
|
725
|
-
})];
|
|
726
|
-
},
|
|
727
|
-
addPasteRules() {
|
|
728
|
-
return [markPasteRule({
|
|
729
|
-
find: starPasteRegex,
|
|
730
|
-
type: this.type
|
|
731
|
-
}), markPasteRule({
|
|
732
|
-
find: underscorePasteRegex,
|
|
733
|
-
type: this.type
|
|
734
|
-
})];
|
|
735
|
-
}
|
|
736
|
-
});
|
|
651
|
+
const BoldWithoutFontWeightInference = BoldBase.extend({ parseHTML() {
|
|
652
|
+
return [
|
|
653
|
+
{ tag: "strong" },
|
|
654
|
+
{
|
|
655
|
+
tag: "b",
|
|
656
|
+
getAttrs: (node) => node.style.fontWeight !== "normal" && null
|
|
657
|
+
},
|
|
658
|
+
{
|
|
659
|
+
style: "font-weight=400",
|
|
660
|
+
clearMark: (mark) => mark.type.name === this.name
|
|
661
|
+
}
|
|
662
|
+
];
|
|
663
|
+
} });
|
|
664
|
+
const Bold = EmailMark.from(BoldWithoutFontWeightInference, ({ children, style }) => /* @__PURE__ */ jsx("strong", {
|
|
665
|
+
style,
|
|
666
|
+
children
|
|
667
|
+
}));
|
|
737
668
|
|
|
738
669
|
//#endregion
|
|
739
670
|
//#region src/extensions/bullet-list.tsx
|
|
@@ -1733,33 +1664,11 @@ const StyleAttribute = Extension.create({
|
|
|
1733
1664
|
|
|
1734
1665
|
//#endregion
|
|
1735
1666
|
//#region src/extensions/sup.tsx
|
|
1736
|
-
|
|
1737
|
-
* This extension allows you to mark text as superscript.
|
|
1738
|
-
* @see https://tiptap.dev/api/marks/superscript
|
|
1739
|
-
*/
|
|
1740
|
-
const Sup = EmailMark.create({
|
|
1667
|
+
const SupBase = SuperscriptBase.extend({
|
|
1741
1668
|
name: "sup",
|
|
1742
|
-
addOptions() {
|
|
1743
|
-
return { HTMLAttributes: {} };
|
|
1744
|
-
},
|
|
1745
|
-
parseHTML() {
|
|
1746
|
-
return [{ tag: "sup" }];
|
|
1747
|
-
},
|
|
1748
|
-
renderHTML({ HTMLAttributes }) {
|
|
1749
|
-
return [
|
|
1750
|
-
"sup",
|
|
1751
|
-
mergeAttributes(this.options.HTMLAttributes, HTMLAttributes),
|
|
1752
|
-
0
|
|
1753
|
-
];
|
|
1754
|
-
},
|
|
1755
|
-
renderToReactEmail({ children, style }) {
|
|
1756
|
-
return /* @__PURE__ */ jsx("sup", {
|
|
1757
|
-
style,
|
|
1758
|
-
children
|
|
1759
|
-
});
|
|
1760
|
-
},
|
|
1761
1669
|
addCommands() {
|
|
1762
1670
|
return {
|
|
1671
|
+
...this.parent?.(),
|
|
1763
1672
|
setSup: () => ({ commands }) => {
|
|
1764
1673
|
return commands.setMark(this.name);
|
|
1765
1674
|
},
|
|
@@ -1772,6 +1681,10 @@ const Sup = EmailMark.create({
|
|
|
1772
1681
|
};
|
|
1773
1682
|
}
|
|
1774
1683
|
});
|
|
1684
|
+
const Sup = EmailMark.from(SupBase, ({ children, style }) => /* @__PURE__ */ jsx("sup", {
|
|
1685
|
+
style,
|
|
1686
|
+
children
|
|
1687
|
+
}));
|
|
1775
1688
|
|
|
1776
1689
|
//#endregion
|
|
1777
1690
|
//#region src/extensions/table.tsx
|
|
@@ -1959,6 +1872,13 @@ const TableHeader = Node$1.create({
|
|
|
1959
1872
|
}
|
|
1960
1873
|
});
|
|
1961
1874
|
|
|
1875
|
+
//#endregion
|
|
1876
|
+
//#region src/extensions/underline.tsx
|
|
1877
|
+
const Underline = EmailMark.from(UnderlineBase, ({ children, style }) => /* @__PURE__ */ jsx("u", {
|
|
1878
|
+
style,
|
|
1879
|
+
children
|
|
1880
|
+
}));
|
|
1881
|
+
|
|
1962
1882
|
//#endregion
|
|
1963
1883
|
//#region src/extensions/uppercase.tsx
|
|
1964
1884
|
const Uppercase = EmailMark.create({
|
|
@@ -2196,6 +2116,7 @@ const starterKitExtensions = {
|
|
|
2196
2116
|
Divider,
|
|
2197
2117
|
Link,
|
|
2198
2118
|
Sup,
|
|
2119
|
+
Underline,
|
|
2199
2120
|
Uppercase,
|
|
2200
2121
|
PreservedStyle,
|
|
2201
2122
|
Table,
|
|
@@ -2240,6 +2161,7 @@ const StarterKit = Extension.create({
|
|
|
2240
2161
|
Divider: {},
|
|
2241
2162
|
Link: {},
|
|
2242
2163
|
Sup: {},
|
|
2164
|
+
Underline: {},
|
|
2243
2165
|
Uppercase: {},
|
|
2244
2166
|
PreservedStyle: {},
|
|
2245
2167
|
Table: {},
|
|
@@ -4121,5 +4043,5 @@ function createSlashCommand(options) {
|
|
|
4121
4043
|
const SlashCommand = createSlashCommand();
|
|
4122
4044
|
|
|
4123
4045
|
//#endregion
|
|
4124
|
-
export { AlignmentAttribute, BULLET_LIST, BUTTON, Blockquote, Body, Bold, BubbleMenu, BubbleMenuAlignCenter, BubbleMenuAlignLeft, BubbleMenuAlignRight, BubbleMenuBold, BubbleMenuCode, BubbleMenuDefault, BubbleMenuItalic, BubbleMenuItem, BubbleMenuItemGroup, BubbleMenuLinkSelector, BubbleMenuNodeSelector, BubbleMenuRoot, BubbleMenuSeparator, BubbleMenuStrike, BubbleMenuUnderline, BubbleMenuUppercase, BulletList, Button, ButtonBubbleMenu, ButtonBubbleMenuDefault, ButtonBubbleMenuEditLink, ButtonBubbleMenuRoot, ButtonBubbleMenuToolbar, CODE, COLUMN_PARENT_TYPES, ClassAttribute, Code, CodeBlockPrism, ColumnsColumn, CommandList, DIVIDER, Div, Divider, EmailNode, FOUR_COLUMNS, FourColumns, GlobalContent, H1, H2, H3, HardBreak, Heading, ImageBubbleMenu, ImageBubbleMenuDefault, ImageBubbleMenuEditLink, ImageBubbleMenuRoot, ImageBubbleMenuToolbar, Italic, Link, LinkBubbleMenu, LinkBubbleMenuDefault, LinkBubbleMenuEditLink, LinkBubbleMenuForm, LinkBubbleMenuOpenLink, LinkBubbleMenuRoot, LinkBubbleMenuToolbar, LinkBubbleMenuUnlink, ListItem, MAX_COLUMNS_DEPTH, MaxNesting, NUMBERED_LIST, NodeSelectorContent, NodeSelectorRoot, NodeSelectorTrigger, OrderedList, Paragraph, Placeholder, PreservedStyle, PreviewText, QUOTE, SECTION, Section, SlashCommand, StarterKit, Strike, StyleAttribute, Sup, TEXT, THREE_COLUMNS, TWO_COLUMNS, Table, TableCell, TableHeader, TableRow, ThreeColumns, TwoColumns, Uppercase, composeReactEmail, createSlashCommand, defaultSlashCommands, editorEventBus, filterAndRankItems, getColumnsDepth, getGlobalContent, isAtMaxColumnsDepth, isDocumentVisuallyEmpty, isInsideNode, processStylesForUnlink, scoreItem, setTextAlignment, useButtonBubbleMenuContext, useEditor, useImageBubbleMenuContext, useLinkBubbleMenuContext };
|
|
4046
|
+
export { AlignmentAttribute, BULLET_LIST, BUTTON, Blockquote, Body, Bold, BubbleMenu, BubbleMenuAlignCenter, BubbleMenuAlignLeft, BubbleMenuAlignRight, BubbleMenuBold, BubbleMenuCode, BubbleMenuDefault, BubbleMenuItalic, BubbleMenuItem, BubbleMenuItemGroup, BubbleMenuLinkSelector, BubbleMenuNodeSelector, BubbleMenuRoot, BubbleMenuSeparator, BubbleMenuStrike, BubbleMenuUnderline, BubbleMenuUppercase, BulletList, Button, ButtonBubbleMenu, ButtonBubbleMenuDefault, ButtonBubbleMenuEditLink, ButtonBubbleMenuRoot, ButtonBubbleMenuToolbar, CODE, COLUMN_PARENT_TYPES, ClassAttribute, Code, CodeBlockPrism, ColumnsColumn, CommandList, DIVIDER, Div, Divider, EmailNode, FOUR_COLUMNS, FourColumns, GlobalContent, H1, H2, H3, HardBreak, Heading, ImageBubbleMenu, ImageBubbleMenuDefault, ImageBubbleMenuEditLink, ImageBubbleMenuRoot, ImageBubbleMenuToolbar, Italic, Link, LinkBubbleMenu, LinkBubbleMenuDefault, LinkBubbleMenuEditLink, LinkBubbleMenuForm, LinkBubbleMenuOpenLink, LinkBubbleMenuRoot, LinkBubbleMenuToolbar, LinkBubbleMenuUnlink, ListItem, MAX_COLUMNS_DEPTH, MaxNesting, NUMBERED_LIST, NodeSelectorContent, NodeSelectorRoot, NodeSelectorTrigger, OrderedList, Paragraph, Placeholder, PreservedStyle, PreviewText, QUOTE, SECTION, Section, SlashCommand, StarterKit, Strike, StyleAttribute, Sup, TEXT, THREE_COLUMNS, TWO_COLUMNS, Table, TableCell, TableHeader, TableRow, ThreeColumns, TwoColumns, Underline, Uppercase, composeReactEmail, createSlashCommand, defaultSlashCommands, editorEventBus, filterAndRankItems, getColumnsDepth, getGlobalContent, isAtMaxColumnsDepth, isDocumentVisuallyEmpty, isInsideNode, processStylesForUnlink, scoreItem, setTextAlignment, useButtonBubbleMenuContext, useEditor, useImageBubbleMenuContext, useLinkBubbleMenuContext };
|
|
4125
4047
|
//# sourceMappingURL=index.mjs.map
|