@maily-to/core 0.0.25 → 0.0.27
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/blocks/index.d.mts +2 -2
- package/dist/blocks/index.d.ts +2 -2
- package/dist/blocks/index.js +7 -7
- package/dist/blocks/index.js.map +1 -1
- package/dist/blocks/index.mjs +6 -6
- package/dist/blocks/index.mjs.map +1 -1
- package/dist/extensions/index.d.mts +10 -9
- package/dist/extensions/index.d.ts +10 -9
- package/dist/extensions/index.js +432 -433
- package/dist/extensions/index.js.map +1 -1
- package/dist/extensions/index.mjs +356 -357
- package/dist/extensions/index.mjs.map +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +100 -81
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +89 -70
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/readme.md +5 -4
package/dist/index.mjs
CHANGED
|
@@ -54,7 +54,7 @@ function styleInject(css, { insertAt } = {}) {
|
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
// src/styles/index.css
|
|
57
|
-
styleInject(':root {\n --placeholder-color: #adb5bd;\n --bg-color: #ffffff;\n --variable-icon-size: 12px;\n --variable-icon-gap: 4px;\n}\n.mly-editor .mly-prose p:where([class~=text-sm]) {\n font-size: 16px;\n}\n.mly-editor .mly-prose h1,\n.mly-editor .mly-prose h2,\n.mly-editor .mly-prose h3 {\n margin-top: 0;\n margin-bottom: 12px;\n}\n.mly-editor .mly-prose h1 {\n font-size: 36px;\n}\n.mly-editor .mly-prose h2 {\n font-size: 30px;\n}\n.mly-editor .mly-prose h3 {\n font-size: 24px;\n}\n.mly-editor .mly-prose p {\n font-size: 15px;\n margin-bottom: 20px;\n}\n.mly-editor .mly-prose h1 + p,\n.mly-editor .mly-prose h2 + p,\n.mly-editor .mly-prose h3 + p,\n.mly-editor .mly-prose hr + p,\n.mly-editor .mly-prose table + p {\n margin-top: 0;\n}\n.mly-editor .mly-prose ol,\n.mly-editor .mly-prose ul {\n margin-top: 0;\n margin-bottom: 20px;\n}\n.mly-editor .mly-prose li:not(:last-child) {\n margin-bottom: 8px;\n}\n.mly-editor .mly-prose li > p {\n margin: 0;\n}\n.mly-editor .mly-prose img,\n.mly-editor .mly-prose .node-logo {\n margin-top: 0;\n margin-bottom: 32px;\n}\n.mly-editor .mly-prose hr {\n margin-block: 32px;\n}\n.mly-editor .mly-prose .footer {\n display: block;\n font-size: 13px;\n margin-bottom: 20px;\n color: rgb(100, 116, 139);\n}\n.mly-editor .mly-prose .spacer + * {\n margin-top: 0;\n}\n.mly-editor .mly-prose p + .spacer {\n margin-top: -20px;\n}\n.mly-editor .mly-prose blockquote + .spacer {\n margin-top: -16px;\n}\n.mly-editor .mly-prose h1 + .spacer,\n.mly-editor .mly-prose h2 + .spacer,\n.mly-editor .mly-prose h3 + .spacer {\n margin-top: -12px;\n}\n.mly-editor .mly-prose ol + .spacer,\n.mly-editor .mly-prose ul + .spacer {\n margin-top: -20px;\n}\n.mly-editor .mly-prose img + .spacer,\n.mly-editor .mly-prose .node-logo + .spacer {\n margin-top: -32px;\n}\n.mly-editor .mly-prose .node-button + .spacer,\n.mly-editor .mly-prose .node-linkCard + .spacer,\n.mly-editor .mly-prose footer + .spacer {\n margin-top: -20px;\n}\n.mly-editor .mly-prose .node-button,\n.mly-editor .mly-prose .node-linkCard {\n margin-top: 0;\n margin-bottom: 20px;\n}\n.mly-editor .mly-prose .node-image {\n line-height: 0;\n margin-top: 0;\n margin-bottom: 32px;\n outline: none;\n}\n.mly-editor .mly-prose .node-image + .spacer {\n margin-top: -32px;\n}\n.mly-editor .mly-prose code::before,\n.mly-editor .mly-prose code::after {\n content: none;\n}\n.mly-no-scrollbar::-webkit-scrollbar {\n display: none;\n}\n.mly-no-scrollbar {\n -ms-overflow-style: none;\n scrollbar-width: none;\n}\n.mly-editor .react-colorful__alpha {\n border-radius: 0;\n}\n.mly-editor .react-colorful__saturation,\n.mly-editor .react-colorful__hue,\n.mly-editor .react-colorful__alpha {\n border-radius: 8px;\n}\n.mly-editor .react-colorful__hue,\n.mly-editor .react-colorful__alpha {\n height: 16px;\n}\n.mly-editor .react-colorful__pointer {\n width: 16px;\n height: 16px;\n}\n.mly-editable .ProseMirror-selectednode::after {\n content: "";\n position: absolute;\n inset: -2px;\n pointer-events: none;\n border-radius: 6px;\n background: rgba(35, 131, 226, 0.14);\n}\n.mly-prose {\n strong {\n color: currentColor;\n }\n}\n.ProseMirror {\n position: relative;\n word-wrap: break-word;\n white-space: pre-wrap;\n white-space: break-spaces;\n font-variant-ligatures: none;\n font-feature-settings: "liga" 0;\n &:focus {\n outline: none;\n }\n p {\n margin-top: 0;\n }\n h1 {\n --variable-icon-size: 28px;\n }\n h2 {\n --variable-icon-size: 24px;\n }\n h3 {\n --variable-icon-size: 20px;\n }\n h1,\n h2,\n h3 {\n --variable-icon-gap: 8px;\n }\n .is-editor-empty:first-child:not([data-type=columns], [data-type=section], ul, li, ol)::before {\n content: attr(data-placeholder);\n float: left;\n color: var(--placeholder-color);\n pointer-events: none;\n height: 0;\n }\n .is-empty:not([data-type=columns], [data-type=section], ol, ul, li)::before {\n content: attr(data-placeholder);\n float: left;\n color: var(--placeholder-color);\n pointer-events: none;\n height: 0;\n }\n [data-type=columns] .is-empty::before,\n [data-type=section] .is-empty::before {\n --l-threshold: 0.66;\n --diff: calc(var(--l-threshold) - l);\n color: oklch(from var(--bg-color) clamp(0.05, max(min(var(--diff) * infinity, 1), 0), 0.95) c h) !important;\n opacity: 0.6;\n }\n [data-type=columns] {\n display: flex;\n margin: 0;\n padding: 0;\n &.has-focus [data-type=column],\n &:hover [data-type=column] {\n outline: 1.5px solid #e9ecef;\n outline-style: dashed;\n }\n [data-type=column].has-focus {\n outline-style: solid;\n }\n }\n [data-type=column] {\n display: table-cell;\n flex-basis: 0;\n flex-grow: 1;\n overflow: auto;\n & > *:first-child {\n margin-top: 0;\n }\n & > *:last-child {\n margin-bottom: 0;\n }\n }\n [data-type=section] {\n margin: 0;\n padding: 0;\n [data-type=section-cell] {\n padding: 0;\n & > *:first-child {\n margin-top: 0;\n }\n & > *:last-child {\n margin-bottom: 0;\n }\n }\n }\n [data-type=
|
|
57
|
+
styleInject(':root {\n --placeholder-color: #adb5bd;\n --bg-color: #ffffff;\n --variable-icon-size: 12px;\n --variable-icon-gap: 4px;\n}\n.mly-editor .mly-prose p:where([class~=text-sm]) {\n font-size: 16px;\n}\n.mly-editor .mly-prose h1,\n.mly-editor .mly-prose h2,\n.mly-editor .mly-prose h3 {\n margin-top: 0;\n margin-bottom: 12px;\n}\n.mly-editor .mly-prose h1 {\n font-size: 36px;\n}\n.mly-editor .mly-prose h2 {\n font-size: 30px;\n}\n.mly-editor .mly-prose h3 {\n font-size: 24px;\n}\n.mly-editor .mly-prose p {\n font-size: 15px;\n margin-bottom: 20px;\n}\n.mly-editor .mly-prose h1 + p,\n.mly-editor .mly-prose h2 + p,\n.mly-editor .mly-prose h3 + p,\n.mly-editor .mly-prose hr + p,\n.mly-editor .mly-prose table + p {\n margin-top: 0;\n}\n.mly-editor .mly-prose ol,\n.mly-editor .mly-prose ul {\n margin-top: 0;\n margin-bottom: 20px;\n}\n.mly-editor .mly-prose li:not(:last-child) {\n margin-bottom: 8px;\n}\n.mly-editor .mly-prose li > p {\n margin: 0;\n}\n.mly-editor .mly-prose img,\n.mly-editor .mly-prose .node-logo {\n margin-top: 0;\n margin-bottom: 32px;\n}\n.mly-editor .mly-prose hr {\n margin-block: 32px;\n}\n.mly-editor .mly-prose .footer {\n display: block;\n font-size: 13px;\n margin-bottom: 20px;\n color: rgb(100, 116, 139);\n}\n.mly-editor .mly-prose .spacer + * {\n margin-top: 0;\n}\n.mly-editor .mly-prose p + .spacer {\n margin-top: -20px;\n}\n.mly-editor .mly-prose blockquote + .spacer {\n margin-top: -16px;\n}\n.mly-editor .mly-prose h1 + .spacer,\n.mly-editor .mly-prose h2 + .spacer,\n.mly-editor .mly-prose h3 + .spacer {\n margin-top: -12px;\n}\n.mly-editor .mly-prose ol + .spacer,\n.mly-editor .mly-prose ul + .spacer {\n margin-top: -20px;\n}\n.mly-editor .mly-prose img + .spacer,\n.mly-editor .mly-prose .node-logo + .spacer {\n margin-top: -32px;\n}\n.mly-editor .mly-prose .node-button + .spacer,\n.mly-editor .mly-prose .node-linkCard + .spacer,\n.mly-editor .mly-prose footer + .spacer {\n margin-top: -20px;\n}\n.mly-editor .mly-prose .node-button,\n.mly-editor .mly-prose .node-linkCard {\n margin-top: 0;\n margin-bottom: 20px;\n}\n.mly-editor .mly-prose .node-image {\n line-height: 0;\n margin-top: 0;\n margin-bottom: 32px;\n outline: none;\n}\n.mly-editor .mly-prose .node-image + .spacer {\n margin-top: -32px;\n}\n.mly-editor .mly-prose code::before,\n.mly-editor .mly-prose code::after {\n content: none;\n}\n.mly-no-scrollbar::-webkit-scrollbar {\n display: none;\n}\n.mly-no-scrollbar {\n -ms-overflow-style: none;\n scrollbar-width: none;\n}\n.mly-editor .react-colorful__alpha {\n border-radius: 0;\n}\n.mly-editor .react-colorful__saturation,\n.mly-editor .react-colorful__hue,\n.mly-editor .react-colorful__alpha {\n border-radius: 8px;\n}\n.mly-editor .react-colorful__hue,\n.mly-editor .react-colorful__alpha {\n height: 16px;\n}\n.mly-editor .react-colorful__pointer {\n width: 16px;\n height: 16px;\n}\n.mly-editable .ProseMirror-selectednode::after {\n content: "";\n position: absolute;\n inset: -2px;\n pointer-events: none;\n border-radius: 6px;\n background: rgba(35, 131, 226, 0.14);\n}\n.mly-prose {\n strong {\n color: currentColor;\n }\n}\n.ProseMirror {\n position: relative;\n word-wrap: break-word;\n white-space: pre-wrap;\n white-space: break-spaces;\n font-variant-ligatures: none;\n font-feature-settings: "liga" 0;\n &:focus {\n outline: none;\n }\n p {\n margin-top: 0;\n }\n h1 {\n --variable-icon-size: 28px;\n }\n h2 {\n --variable-icon-size: 24px;\n }\n h3 {\n --variable-icon-size: 20px;\n }\n h1,\n h2,\n h3 {\n --variable-icon-gap: 8px;\n }\n .is-editor-empty:first-child:not([data-type=columns], [data-type=section], ul, li, ol)::before {\n content: attr(data-placeholder);\n float: left;\n color: var(--placeholder-color);\n pointer-events: none;\n height: 0;\n }\n .is-empty:not([data-type=columns], [data-type=section], ol, ul, li)::before {\n content: attr(data-placeholder);\n float: left;\n color: var(--placeholder-color);\n pointer-events: none;\n height: 0;\n }\n [data-type=columns] .is-empty::before,\n [data-type=section] .is-empty::before {\n --l-threshold: 0.66;\n --diff: calc(var(--l-threshold) - l);\n color: oklch(from var(--bg-color) clamp(0.05, max(min(var(--diff) * infinity, 1), 0), 0.95) c h) !important;\n opacity: 0.6;\n }\n [data-type=columns] {\n display: flex;\n margin: 0;\n padding: 0;\n &.has-focus [data-type=column],\n &:hover [data-type=column] {\n outline: 1.5px solid #e9ecef;\n outline-style: dashed;\n }\n [data-type=column].has-focus {\n outline-style: solid;\n }\n }\n [data-type=column] {\n display: table-cell;\n flex-basis: 0;\n flex-grow: 1;\n overflow: auto;\n & > *:first-child {\n margin-top: 0;\n }\n & > *:last-child {\n margin-bottom: 0;\n }\n }\n [data-type=section] {\n margin: 0;\n padding: 0;\n [data-type=section-cell] {\n padding: 0;\n & > *:first-child {\n margin-top: 0;\n }\n & > *:last-child {\n margin-bottom: 0;\n }\n }\n }\n [data-type=repeat] {\n [data-node-view-content] > div {\n & > *:first-child {\n margin-top: 0;\n }\n & > *:last-child {\n margin-bottom: 0;\n }\n }\n }\n .node-repeat.has-focus [data-repeat-indicator] {\n opacity: 1;\n }\n [data-type=show] {\n [data-node-view-content] > div {\n & > *:first-child {\n margin-top: 0;\n }\n & > *:last-child {\n margin-bottom: 0;\n }\n }\n }\n *:has(+ .ProseMirror-gapcursor) {\n margin-bottom: 0 !important;\n }\n .ProseMirror-gapcursor {\n &::after {\n border: 1.5px solid gray;\n width: 24px;\n }\n & + * {\n margin-top: 0 !important;\n }\n }\n}\n.hide-number-controls {\n &::-webkit-outer-spin-button,\n &::-webkit-inner-spin-button {\n -webkit-appearance: none;\n margin: 0;\n }\n &[type=number] {\n -moz-appearance: textfield;\n }\n}\n.hide-scrollbars {\n scrollbar-width: none;\n -ms-overflow-style: none;\n &::-webkit-scrollbar {\n display: none;\n }\n}\n');
|
|
58
58
|
|
|
59
59
|
// src/styles/preflight.css
|
|
60
60
|
styleInject(':where(.mly-editor),\n:where(.mly-editor) ::before,\n:where(.mly-editor) ::after {\n box-sizing: border-box;\n border-width: 0;\n border-style: solid;\n border-color: #e5e7eb;\n}\n:where(.mly-editor) ::before,\n:where(.mly-editor) ::after {\n --tw-content: "";\n}\n:where(.mly-editor) html {\n line-height: 1.5;\n -webkit-text-size-adjust: 100%;\n -moz-tab-size: 4;\n -o-tab-size: 4;\n tab-size: 4;\n font-family:\n ui-sans-serif,\n system-ui,\n sans-serif,\n "Apple Color Emoji",\n "Segoe UI Emoji",\n "Segoe UI Symbol",\n "Noto Color Emoji";\n font-feature-settings: normal;\n font-variation-settings: normal;\n}\n:where(.mly-editor) body {\n margin: 0;\n line-height: inherit;\n}\n:where(.mly-editor) hr {\n height: 0;\n color: inherit;\n border-top-width: 1px;\n}\n:where(.mly-editor) abbr:where([title]) {\n -webkit-text-decoration: underline dotted;\n text-decoration: underline dotted;\n}\n:where(.mly-editor) h1,\n:where(.mly-editor) h2,\n:where(.mly-editor) h3,\n:where(.mly-editor) h4,\n:where(.mly-editor) h5,\n:where(.mly-editor) h6 {\n font-size: inherit;\n font-weight: inherit;\n}\n:where(.mly-editor) a {\n color: inherit;\n text-decoration: inherit;\n}\n:where(.mly-editor) b,\n:where(.mly-editor) strong {\n font-weight: bolder;\n}\n:where(.mly-editor) code,\n:where(.mly-editor) kbd,\n:where(.mly-editor) samp,\n:where(.mly-editor) pre {\n font-family:\n ui-monospace,\n SFMono-Regular,\n Menlo,\n Monaco,\n Consolas,\n "Liberation Mono",\n "Courier New",\n monospace;\n font-size: 1em;\n}\n:where(.mly-editor) small {\n font-size: 80%;\n}\n:where(.mly-editor) sub,\n:where(.mly-editor) sup {\n font-size: 75%;\n line-height: 0;\n position: relative;\n vertical-align: baseline;\n}\n:where(.mly-editor) sub {\n bottom: -0.25em;\n}\n:where(.mly-editor) sup {\n top: -0.5em;\n}\n:where(.mly-editor) table {\n text-indent: 0;\n border-color: inherit;\n border-collapse: collapse;\n}\n:where(.mly-editor) button,\n:where(.mly-editor) input,\n:where(.mly-editor) optgroup,\n:where(.mly-editor) select,\n:where(.mly-editor) textarea {\n font-family: inherit;\n font-feature-settings: inherit;\n font-variation-settings: inherit;\n font-size: 100%;\n font-weight: inherit;\n line-height: inherit;\n color: inherit;\n margin: 0;\n padding: 0;\n}\n:where(.mly-editor) button,\n:where(.mly-editor) select {\n text-transform: none;\n}\n:where(.mly-editor) button,\n:where(.mly-editor) [type=button],\n:where(.mly-editor) [type=reset],\n:where(.mly-editor) [type=submit] {\n -webkit-appearance: button;\n background-image: none;\n}\n:where(.mly-editor) :-moz-focusring {\n outline: auto;\n}\n:where(.mly-editor) :-moz-ui-invalid {\n box-shadow: none;\n}\n:where(.mly-editor) progress {\n vertical-align: baseline;\n}\n:where(.mly-editor) ::-webkit-inner-spin-button,\n:where(.mly-editor) ::-webkit-outer-spin-button {\n height: auto;\n}\n:where(.mly-editor) [type=search] {\n -webkit-appearance: textfield;\n outline-offset: -2px;\n}\n:where(.mly-editor) ::-webkit-search-decoration {\n -webkit-appearance: none;\n}\n:where(.mly-editor) ::-webkit-file-upload-button {\n -webkit-appearance: button;\n font: inherit;\n}\n:where(.mly-editor) summary {\n display: list-item;\n}\n:where(.mly-editor) blockquote,\n:where(.mly-editor) dl,\n:where(.mly-editor) dd,\n:where(.mly-editor) h1,\n:where(.mly-editor) h2,\n:where(.mly-editor) h3,\n:where(.mly-editor) h4,\n:where(.mly-editor) h5,\n:where(.mly-editor) h6,\n:where(.mly-editor) hr,\n:where(.mly-editor) figure,\n:where(.mly-editor) p,\n:where(.mly-editor) pre {\n margin: 0;\n}\n:where(.mly-editor) fieldset {\n margin: 0;\n padding: 0;\n}\n:where(.mly-editor) legend {\n padding: 0;\n}\n:where(.mly-editor) ol,\n:where(.mly-editor) ul,\n:where(.mly-editor) menu {\n list-style: none;\n margin: 0;\n padding: 0;\n}\n:where(.mly-editor) dialog {\n padding: 0;\n}\n:where(.mly-editor) textarea {\n resize: vertical;\n}\n:where(.mly-editor) input::-moz-placeholder,\n:where(.mly-editor) textarea::-moz-placeholder {\n opacity: 1;\n color: #9ca3af;\n}\n:where(.mly-editor) input::placeholder,\n:where(.mly-editor) textarea::placeholder {\n opacity: 1;\n color: #9ca3af;\n}\n:where(.mly-editor) button,\n:where(.mly-editor) [role=button] {\n cursor: pointer;\n}\n:where(.mly-editor) :disabled {\n cursor: default;\n}\n:where(.mly-editor) img,\n:where(.mly-editor) svg,\n:where(.mly-editor) video,\n:where(.mly-editor) canvas,\n:where(.mly-editor) audio,\n:where(.mly-editor) iframe,\n:where(.mly-editor) embed,\n:where(.mly-editor) object {\n display: block;\n vertical-align: middle;\n}\n:where(.mly-editor) img,\n:where(.mly-editor) video {\n max-width: 100%;\n height: auto;\n}\n:where(.mly-editor) [hidden] {\n display: none;\n}\n');
|
|
@@ -64,7 +64,7 @@ styleInject('*,\n::before,\n::after {\n --tw-border-spacing-x: 0;\n --tw-borde
|
|
|
64
64
|
|
|
65
65
|
// src/editor/index.tsx
|
|
66
66
|
import { EditorContent, useEditor } from "@tiptap/react";
|
|
67
|
-
import { useRef as useRef12 } from "react";
|
|
67
|
+
import { useMemo as useMemo9, useRef as useRef12 } from "react";
|
|
68
68
|
|
|
69
69
|
// src/editor/components/column-menu/columns-bubble-menu.tsx
|
|
70
70
|
import { BubbleMenu } from "@tiptap/react";
|
|
@@ -936,16 +936,16 @@ var section = {
|
|
|
936
936
|
editor.chain().focus().deleteRange(range).setSection().run();
|
|
937
937
|
}
|
|
938
938
|
};
|
|
939
|
-
var
|
|
940
|
-
title: "
|
|
939
|
+
var repeat = {
|
|
940
|
+
title: "Repeat",
|
|
941
941
|
description: "Loop over an array of items.",
|
|
942
|
-
searchTerms: ["for", "loop"],
|
|
942
|
+
searchTerms: ["repeat", "for", "loop"],
|
|
943
943
|
icon: /* @__PURE__ */ jsx11(Repeat2, { className: "mly-h-4 mly-w-4" }),
|
|
944
944
|
shouldBeHidden: (editor) => {
|
|
945
|
-
return editor.isActive("
|
|
945
|
+
return editor.isActive("repeat");
|
|
946
946
|
},
|
|
947
947
|
command: ({ editor, range }) => {
|
|
948
|
-
editor.chain().focus().deleteRange(range).
|
|
948
|
+
editor.chain().focus().deleteRange(range).setRepeat().run();
|
|
949
949
|
}
|
|
950
950
|
};
|
|
951
951
|
var spacer = {
|
|
@@ -1086,7 +1086,7 @@ var DEFAULT_SLASH_COMMANDS = [
|
|
|
1086
1086
|
logo,
|
|
1087
1087
|
columns,
|
|
1088
1088
|
section,
|
|
1089
|
-
|
|
1089
|
+
repeat,
|
|
1090
1090
|
divider,
|
|
1091
1091
|
spacer,
|
|
1092
1092
|
button,
|
|
@@ -1665,7 +1665,7 @@ function ColumnsBubbleMenu(props) {
|
|
|
1665
1665
|
}, [editor]);
|
|
1666
1666
|
const bubbleMenuProps = __spreadProps(__spreadValues(__spreadValues({}, props), appendTo ? { appendTo: appendTo.current } : {}), {
|
|
1667
1667
|
shouldShow: ({ editor: editor2 }) => {
|
|
1668
|
-
if (isTextSelected(editor2) || editor2.isActive("section") || editor2.isActive("
|
|
1668
|
+
if (isTextSelected(editor2) || editor2.isActive("section") || editor2.isActive("repeat") || !editor2.isEditable) {
|
|
1669
1669
|
return false;
|
|
1670
1670
|
}
|
|
1671
1671
|
return editor2.isActive("columns");
|
|
@@ -2406,7 +2406,7 @@ var EditorMenuBar = (props) => {
|
|
|
2406
2406
|
);
|
|
2407
2407
|
};
|
|
2408
2408
|
|
|
2409
|
-
// src/editor/components/
|
|
2409
|
+
// src/editor/components/repeat-menu/repeat-bubble-menu.tsx
|
|
2410
2410
|
import { BubbleMenu as BubbleMenu2, findChildren } from "@tiptap/react";
|
|
2411
2411
|
import {
|
|
2412
2412
|
InfoIcon
|
|
@@ -2414,17 +2414,17 @@ import {
|
|
|
2414
2414
|
import { useCallback as useCallback4, useMemo as useMemo4, useRef as useRef5, useState as useState6 } from "react";
|
|
2415
2415
|
import { sticky as sticky2 } from "tippy.js";
|
|
2416
2416
|
|
|
2417
|
-
// src/editor/components/
|
|
2417
|
+
// src/editor/components/repeat-menu/use-repeat-state.ts
|
|
2418
2418
|
import { useEditorState as useEditorState2 } from "@tiptap/react";
|
|
2419
2419
|
import deepEql2 from "fast-deep-equal";
|
|
2420
|
-
var
|
|
2420
|
+
var useRepeatState = (editor) => {
|
|
2421
2421
|
const states = useEditorState2({
|
|
2422
2422
|
editor,
|
|
2423
2423
|
selector: (ctx) => {
|
|
2424
2424
|
var _a, _b;
|
|
2425
2425
|
return {
|
|
2426
|
-
each: (_a = ctx.editor.getAttributes("
|
|
2427
|
-
currentShowIfKey: ((_b = ctx.editor.getAttributes("
|
|
2426
|
+
each: (_a = ctx.editor.getAttributes("repeat")) == null ? void 0 : _a.each,
|
|
2427
|
+
currentShowIfKey: ((_b = ctx.editor.getAttributes("repeat")) == null ? void 0 : _b.showIfKey) || "",
|
|
2428
2428
|
isSectionActive: ctx.editor.isActive("section")
|
|
2429
2429
|
};
|
|
2430
2430
|
},
|
|
@@ -2433,23 +2433,23 @@ var useForState = (editor) => {
|
|
|
2433
2433
|
return states;
|
|
2434
2434
|
};
|
|
2435
2435
|
|
|
2436
|
-
// src/editor/components/
|
|
2436
|
+
// src/editor/components/repeat-menu/repeat-bubble-menu.tsx
|
|
2437
2437
|
import { jsx as jsx24, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
2438
|
-
function
|
|
2438
|
+
function RepeatBubbleMenu(props) {
|
|
2439
2439
|
const { appendTo, editor } = props;
|
|
2440
2440
|
if (!editor) {
|
|
2441
2441
|
return null;
|
|
2442
2442
|
}
|
|
2443
|
-
const state =
|
|
2443
|
+
const state = useRepeatState(editor);
|
|
2444
2444
|
const getReferenceClientRect = useCallback4(() => {
|
|
2445
|
-
const renderContainer = getRenderContainer(editor, "
|
|
2445
|
+
const renderContainer = getRenderContainer(editor, "repeat");
|
|
2446
2446
|
const rect = (renderContainer == null ? void 0 : renderContainer.getBoundingClientRect()) || new DOMRect(-1e3, -1e3, 0, 0);
|
|
2447
2447
|
return rect;
|
|
2448
2448
|
}, [editor]);
|
|
2449
2449
|
const bubbleMenuProps = __spreadProps(__spreadValues(__spreadValues({}, props), appendTo ? { appendTo: appendTo.current } : {}), {
|
|
2450
2450
|
shouldShow: ({ editor: editor2 }) => {
|
|
2451
2451
|
var _a;
|
|
2452
|
-
const activeForNode = getClosestNodeByName(editor2, "
|
|
2452
|
+
const activeForNode = getClosestNodeByName(editor2, "repeat");
|
|
2453
2453
|
const sectionNodeChildren = activeForNode ? (_a = findChildren(activeForNode == null ? void 0 : activeForNode.node, (node) => {
|
|
2454
2454
|
return node.type.name === "section";
|
|
2455
2455
|
})) == null ? void 0 : _a[0] : null;
|
|
@@ -2457,7 +2457,7 @@ function ForBubbleMenu(props) {
|
|
|
2457
2457
|
if (isTextSelected(editor2) || hasActiveSectionNodeChildren || !editor2.isEditable) {
|
|
2458
2458
|
return false;
|
|
2459
2459
|
}
|
|
2460
|
-
return editor2.isActive("
|
|
2460
|
+
return editor2.isActive("repeat");
|
|
2461
2461
|
},
|
|
2462
2462
|
tippyOptions: {
|
|
2463
2463
|
offset: [0, 8],
|
|
@@ -2470,7 +2470,7 @@ function ForBubbleMenu(props) {
|
|
|
2470
2470
|
sticky: "popper",
|
|
2471
2471
|
maxWidth: "auto"
|
|
2472
2472
|
},
|
|
2473
|
-
pluginKey: "
|
|
2473
|
+
pluginKey: "repeatBubbleMenu"
|
|
2474
2474
|
});
|
|
2475
2475
|
const { variables = [], renderVariable = DEFAULT_RENDER_VARIABLE_FUNCTION } = useMailyContext();
|
|
2476
2476
|
const inputRef = useRef5(null);
|
|
@@ -2480,7 +2480,7 @@ function ForBubbleMenu(props) {
|
|
|
2480
2480
|
return processVariables(variables, {
|
|
2481
2481
|
query: eachKey || "",
|
|
2482
2482
|
editor,
|
|
2483
|
-
from: "
|
|
2483
|
+
from: "repeat-variable"
|
|
2484
2484
|
}).map((variable) => variable.name);
|
|
2485
2485
|
}, [variables, eachKey, editor]);
|
|
2486
2486
|
const isValidEachKey = eachKey;
|
|
@@ -2490,7 +2490,7 @@ function ForBubbleMenu(props) {
|
|
|
2490
2490
|
className: "mly-flex mly-items-stretch mly-rounded-lg mly-border mly-border-slate-200 mly-bg-white mly-p-0.5 mly-shadow-md",
|
|
2491
2491
|
children: /* @__PURE__ */ jsxs10(TooltipProvider, { children: [
|
|
2492
2492
|
/* @__PURE__ */ jsxs10("div", { className: "mly-flex mly-items-center mly-gap-1.5 mly-px-1.5 mly-text-sm mly-leading-none", children: [
|
|
2493
|
-
"
|
|
2493
|
+
"Repeat",
|
|
2494
2494
|
/* @__PURE__ */ jsxs10(Tooltip, { children: [
|
|
2495
2495
|
/* @__PURE__ */ jsx24(TooltipTrigger, { children: /* @__PURE__ */ jsx24(
|
|
2496
2496
|
InfoIcon,
|
|
@@ -2548,7 +2548,7 @@ function ForBubbleMenu(props) {
|
|
|
2548
2548
|
placeholder: "ie. payload.items",
|
|
2549
2549
|
value: (state == null ? void 0 : state.each) || "",
|
|
2550
2550
|
onValueChange: (value) => {
|
|
2551
|
-
editor.commands.
|
|
2551
|
+
editor.commands.updateRepeat({
|
|
2552
2552
|
each: value
|
|
2553
2553
|
});
|
|
2554
2554
|
},
|
|
@@ -2556,7 +2556,7 @@ function ForBubbleMenu(props) {
|
|
|
2556
2556
|
setIsUpdatingKey(false);
|
|
2557
2557
|
},
|
|
2558
2558
|
onSelectOption: (value) => {
|
|
2559
|
-
editor.commands.
|
|
2559
|
+
editor.commands.updateRepeat({
|
|
2560
2560
|
each: value
|
|
2561
2561
|
});
|
|
2562
2562
|
setIsUpdatingKey(false);
|
|
@@ -2573,7 +2573,7 @@ function ForBubbleMenu(props) {
|
|
|
2573
2573
|
{
|
|
2574
2574
|
showIfKey: state.currentShowIfKey,
|
|
2575
2575
|
onShowIfKeyValueChange: (value) => {
|
|
2576
|
-
editor.commands.
|
|
2576
|
+
editor.commands.updateRepeat({
|
|
2577
2577
|
showIfKey: value
|
|
2578
2578
|
});
|
|
2579
2579
|
},
|
|
@@ -3952,11 +3952,11 @@ function SectionBubbleMenu(props) {
|
|
|
3952
3952
|
shouldShow: ({ editor: editor2 }) => {
|
|
3953
3953
|
var _a;
|
|
3954
3954
|
const activeSectionNode = getClosestNodeByName(editor2, "section");
|
|
3955
|
-
const
|
|
3956
|
-
return node.type.name === "
|
|
3955
|
+
const repeatNodeChildren = activeSectionNode ? (_a = findChildren2(activeSectionNode == null ? void 0 : activeSectionNode.node, (node) => {
|
|
3956
|
+
return node.type.name === "repeat";
|
|
3957
3957
|
})) == null ? void 0 : _a[0] : null;
|
|
3958
|
-
const
|
|
3959
|
-
if (isTextSelected(editor2) ||
|
|
3958
|
+
const hasActiveRepeatNodeChildren = repeatNodeChildren && editor2.isActive("repeat");
|
|
3959
|
+
if (isTextSelected(editor2) || hasActiveRepeatNodeChildren || !editor2.isEditable) {
|
|
3960
3960
|
return false;
|
|
3961
3961
|
}
|
|
3962
3962
|
return editor2.isActive("section");
|
|
@@ -5739,22 +5739,22 @@ var ColumnsExtension = Node8.create({
|
|
|
5739
5739
|
}
|
|
5740
5740
|
});
|
|
5741
5741
|
|
|
5742
|
-
// src/editor/nodes/
|
|
5742
|
+
// src/editor/nodes/repeat/repeat.ts
|
|
5743
5743
|
import { mergeAttributes as mergeAttributes8, Node as Node9 } from "@tiptap/core";
|
|
5744
5744
|
import { ReactNodeViewRenderer as ReactNodeViewRenderer6 } from "@tiptap/react";
|
|
5745
5745
|
|
|
5746
|
-
// src/editor/nodes/
|
|
5746
|
+
// src/editor/nodes/repeat/repeat-view.tsx
|
|
5747
5747
|
import { NodeViewWrapper as NodeViewWrapper6, NodeViewContent } from "@tiptap/react";
|
|
5748
5748
|
import { Repeat2 as Repeat22 } from "lucide-react";
|
|
5749
5749
|
import { jsx as jsx42, jsxs as jsxs23 } from "react/jsx-runtime";
|
|
5750
|
-
function
|
|
5750
|
+
function RepeatView(props) {
|
|
5751
5751
|
const { editor, getPos } = props;
|
|
5752
5752
|
return /* @__PURE__ */ jsxs23(
|
|
5753
5753
|
NodeViewWrapper6,
|
|
5754
5754
|
{
|
|
5755
|
+
"data-type": "repeat",
|
|
5755
5756
|
draggable: editor.isEditable,
|
|
5756
5757
|
"data-drag-handle": editor.isEditable,
|
|
5757
|
-
"data-type": "for",
|
|
5758
5758
|
className: "mly-relative",
|
|
5759
5759
|
children: [
|
|
5760
5760
|
/* @__PURE__ */ jsx42(NodeViewContent, { className: "is-editable" }),
|
|
@@ -5779,9 +5779,9 @@ function ForView(props) {
|
|
|
5779
5779
|
);
|
|
5780
5780
|
}
|
|
5781
5781
|
|
|
5782
|
-
// src/editor/nodes/
|
|
5783
|
-
var
|
|
5784
|
-
name: "
|
|
5782
|
+
// src/editor/nodes/repeat/repeat.ts
|
|
5783
|
+
var RepeatExtension = Node9.create({
|
|
5784
|
+
name: "repeat",
|
|
5785
5785
|
group: "block",
|
|
5786
5786
|
content: "(block|columns)+",
|
|
5787
5787
|
draggable: true,
|
|
@@ -5839,7 +5839,7 @@ var ForExtension = Node9.create({
|
|
|
5839
5839
|
},
|
|
5840
5840
|
addCommands() {
|
|
5841
5841
|
return {
|
|
5842
|
-
|
|
5842
|
+
setRepeat: () => ({ commands }) => {
|
|
5843
5843
|
return commands.insertContent({
|
|
5844
5844
|
type: this.name,
|
|
5845
5845
|
attrs: {},
|
|
@@ -5850,11 +5850,11 @@ var ForExtension = Node9.create({
|
|
|
5850
5850
|
]
|
|
5851
5851
|
});
|
|
5852
5852
|
},
|
|
5853
|
-
|
|
5853
|
+
updateRepeat: (attrs) => updateAttributes(this.name, attrs)
|
|
5854
5854
|
};
|
|
5855
5855
|
},
|
|
5856
5856
|
addNodeView() {
|
|
5857
|
-
return ReactNodeViewRenderer6(
|
|
5857
|
+
return ReactNodeViewRenderer6(RepeatView, {
|
|
5858
5858
|
contentDOMElementTag: "div",
|
|
5859
5859
|
className: "mly-relative"
|
|
5860
5860
|
});
|
|
@@ -6084,7 +6084,7 @@ function TextBubbleMenu(props) {
|
|
|
6084
6084
|
return false;
|
|
6085
6085
|
}
|
|
6086
6086
|
const nestedNodes = [
|
|
6087
|
-
|
|
6087
|
+
RepeatExtension.name,
|
|
6088
6088
|
SectionExtension.name,
|
|
6089
6089
|
ColumnsExtension.name,
|
|
6090
6090
|
ColumnExtension.name
|
|
@@ -6233,9 +6233,8 @@ function TextBubbleMenu(props) {
|
|
|
6233
6233
|
|
|
6234
6234
|
// src/editor/nodes/variable/variable-suggestions.tsx
|
|
6235
6235
|
import { ReactRenderer } from "@tiptap/react";
|
|
6236
|
-
import { forwardRef as forwardRef8, useImperativeHandle as useImperativeHandle2 } from "react";
|
|
6236
|
+
import { useRef as useRef10, forwardRef as forwardRef8, useImperativeHandle as useImperativeHandle2 } from "react";
|
|
6237
6237
|
import tippy2 from "tippy.js";
|
|
6238
|
-
import { useRef as useRef10 } from "react";
|
|
6239
6238
|
import { jsx as jsx45 } from "react/jsx-runtime";
|
|
6240
6239
|
var VariableList = forwardRef8((props, ref) => {
|
|
6241
6240
|
const { items = [] } = props;
|
|
@@ -6279,7 +6278,7 @@ var VariableList = forwardRef8((props, ref) => {
|
|
|
6279
6278
|
);
|
|
6280
6279
|
});
|
|
6281
6280
|
VariableList.displayName = "VariableList";
|
|
6282
|
-
function getVariableSuggestions(variables = DEFAULT_VARIABLES, char = DEFAULT_VARIABLE_TRIGGER_CHAR) {
|
|
6281
|
+
function getVariableSuggestions(variables = DEFAULT_VARIABLES, char = DEFAULT_VARIABLE_TRIGGER_CHAR, variableListComponent = VariableList) {
|
|
6283
6282
|
return {
|
|
6284
6283
|
char,
|
|
6285
6284
|
items: ({ query, editor }) => {
|
|
@@ -6294,7 +6293,7 @@ function getVariableSuggestions(variables = DEFAULT_VARIABLES, char = DEFAULT_VA
|
|
|
6294
6293
|
let popup = null;
|
|
6295
6294
|
return {
|
|
6296
6295
|
onStart: (props) => {
|
|
6297
|
-
component = new ReactRenderer(
|
|
6296
|
+
component = new ReactRenderer(variableListComponent, {
|
|
6298
6297
|
props,
|
|
6299
6298
|
editor: props.editor
|
|
6300
6299
|
});
|
|
@@ -6536,7 +6535,7 @@ var MailyKit = Extension.create({
|
|
|
6536
6535
|
"columns",
|
|
6537
6536
|
"column",
|
|
6538
6537
|
"section",
|
|
6539
|
-
"
|
|
6538
|
+
"repeat",
|
|
6540
6539
|
"show",
|
|
6541
6540
|
"blockquote"
|
|
6542
6541
|
].includes(node.type.name)) {
|
|
@@ -6568,8 +6567,8 @@ var MailyKit = Extension.create({
|
|
|
6568
6567
|
if (this.options.linkCard !== false) {
|
|
6569
6568
|
extensions2.push(LinkCardExtension.configure(this.options.linkCard));
|
|
6570
6569
|
}
|
|
6571
|
-
if (this.options.
|
|
6572
|
-
extensions2.push(
|
|
6570
|
+
if (this.options.repeat !== false) {
|
|
6571
|
+
extensions2.push(RepeatExtension);
|
|
6573
6572
|
}
|
|
6574
6573
|
if (this.options.section !== false) {
|
|
6575
6574
|
extensions2.push(SectionExtension);
|
|
@@ -6643,13 +6642,13 @@ import {
|
|
|
6643
6642
|
useEffect as useEffect7,
|
|
6644
6643
|
useLayoutEffect as useLayoutEffect2,
|
|
6645
6644
|
useRef as useRef11,
|
|
6646
|
-
useState as
|
|
6645
|
+
useState as useState11
|
|
6647
6646
|
} from "react";
|
|
6648
6647
|
import tippy3 from "tippy.js";
|
|
6649
6648
|
import { jsx as jsx46, jsxs as jsxs26 } from "react/jsx-runtime";
|
|
6650
6649
|
function CommandList(props) {
|
|
6651
6650
|
const { items, command, editor } = props;
|
|
6652
|
-
const [selectedIndex, setSelectedIndex] =
|
|
6651
|
+
const [selectedIndex, setSelectedIndex] = useState11(0);
|
|
6653
6652
|
const selectItem = useCallback7(
|
|
6654
6653
|
(index) => {
|
|
6655
6654
|
const item = items[index];
|
|
@@ -6823,6 +6822,24 @@ function extensions(props) {
|
|
|
6823
6822
|
return [...defaultExtensions, ...extensions2];
|
|
6824
6823
|
}
|
|
6825
6824
|
|
|
6825
|
+
// src/editor/utils/replace-deprecated.ts
|
|
6826
|
+
function replaceDeprecatedNode(json) {
|
|
6827
|
+
const stack = [json];
|
|
6828
|
+
while (stack.length) {
|
|
6829
|
+
const node = stack.pop();
|
|
6830
|
+
if (!node) {
|
|
6831
|
+
continue;
|
|
6832
|
+
}
|
|
6833
|
+
if (node.type === "for") {
|
|
6834
|
+
node.type = "repeat";
|
|
6835
|
+
}
|
|
6836
|
+
if (node.content) {
|
|
6837
|
+
stack.push(...node.content);
|
|
6838
|
+
}
|
|
6839
|
+
}
|
|
6840
|
+
return json;
|
|
6841
|
+
}
|
|
6842
|
+
|
|
6826
6843
|
// src/editor/index.tsx
|
|
6827
6844
|
import { jsx as jsx47, jsxs as jsxs27 } from "react/jsx-runtime";
|
|
6828
6845
|
function Editor9(props) {
|
|
@@ -6848,25 +6865,27 @@ function Editor9(props) {
|
|
|
6848
6865
|
editable = true,
|
|
6849
6866
|
placeholderUrl = DEFAULT_PLACEHOLDER_URL
|
|
6850
6867
|
} = props;
|
|
6851
|
-
|
|
6852
|
-
|
|
6853
|
-
|
|
6854
|
-
|
|
6855
|
-
|
|
6856
|
-
|
|
6857
|
-
|
|
6858
|
-
|
|
6859
|
-
|
|
6860
|
-
|
|
6861
|
-
|
|
6862
|
-
|
|
6863
|
-
|
|
6864
|
-
|
|
6865
|
-
|
|
6866
|
-
|
|
6867
|
-
|
|
6868
|
-
|
|
6869
|
-
|
|
6868
|
+
const formattedContent = useMemo9(() => {
|
|
6869
|
+
if (contentJson) {
|
|
6870
|
+
const json = (contentJson == null ? void 0 : contentJson.type) === "doc" ? contentJson : {
|
|
6871
|
+
type: "doc",
|
|
6872
|
+
content: contentJson
|
|
6873
|
+
};
|
|
6874
|
+
return replaceDeprecatedNode(json);
|
|
6875
|
+
} else if (contentHtml) {
|
|
6876
|
+
return contentHtml;
|
|
6877
|
+
} else {
|
|
6878
|
+
return {
|
|
6879
|
+
type: "doc",
|
|
6880
|
+
content: [
|
|
6881
|
+
{
|
|
6882
|
+
type: "paragraph",
|
|
6883
|
+
content: []
|
|
6884
|
+
}
|
|
6885
|
+
]
|
|
6886
|
+
};
|
|
6887
|
+
}
|
|
6888
|
+
}, [contentHtml, contentJson]);
|
|
6870
6889
|
const menuContainerRef = useRef12(null);
|
|
6871
6890
|
const editor = useEditor({
|
|
6872
6891
|
editorProps: {
|
|
@@ -6938,7 +6957,7 @@ function Editor9(props) {
|
|
|
6938
6957
|
/* @__PURE__ */ jsx47(SectionBubbleMenu, { editor, appendTo: menuContainerRef }),
|
|
6939
6958
|
/* @__PURE__ */ jsx47(ColumnsBubbleMenu, { editor, appendTo: menuContainerRef }),
|
|
6940
6959
|
/* @__PURE__ */ jsx47(ContentMenu, { editor }),
|
|
6941
|
-
/* @__PURE__ */ jsx47(
|
|
6960
|
+
/* @__PURE__ */ jsx47(RepeatBubbleMenu, { editor, appendTo: menuContainerRef })
|
|
6942
6961
|
]
|
|
6943
6962
|
}
|
|
6944
6963
|
)
|