@maily-to/core 0.0.25 → 0.0.26
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 +8 -8
- package/dist/extensions/index.d.ts +8 -8
- package/dist/extensions/index.js +429 -429
- package/dist/extensions/index.js.map +1 -1
- package/dist/extensions/index.mjs +353 -353
- 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 +83 -63
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +84 -64
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/readme.md +3 -3
package/dist/index.d.mts
CHANGED
|
@@ -22,7 +22,7 @@ type Variable = {
|
|
|
22
22
|
};
|
|
23
23
|
type VariableFunctionOptions = {
|
|
24
24
|
query: string;
|
|
25
|
-
from: 'content-variable' | 'bubble-variable' | '
|
|
25
|
+
from: 'content-variable' | 'bubble-variable' | 'repeat-variable';
|
|
26
26
|
editor: Editor$1;
|
|
27
27
|
};
|
|
28
28
|
type VariablesFunction = (opts: VariableFunctionOptions) => Array<Variable>;
|
package/dist/index.d.ts
CHANGED
|
@@ -22,7 +22,7 @@ type Variable = {
|
|
|
22
22
|
};
|
|
23
23
|
type VariableFunctionOptions = {
|
|
24
24
|
query: string;
|
|
25
|
-
from: 'content-variable' | 'bubble-variable' | '
|
|
25
|
+
from: 'content-variable' | 'bubble-variable' | 'repeat-variable';
|
|
26
26
|
editor: Editor$1;
|
|
27
27
|
};
|
|
28
28
|
type VariablesFunction = (opts: VariableFunctionOptions) => Array<Variable>;
|
package/dist/index.js
CHANGED
|
@@ -87,7 +87,7 @@ function styleInject(css, { insertAt } = {}) {
|
|
|
87
87
|
}
|
|
88
88
|
|
|
89
89
|
// src/styles/index.css
|
|
90
|
-
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=
|
|
90
|
+
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');
|
|
91
91
|
|
|
92
92
|
// src/styles/preflight.css
|
|
93
93
|
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');
|
|
@@ -948,16 +948,16 @@ var section = {
|
|
|
948
948
|
editor.chain().focus().deleteRange(range).setSection().run();
|
|
949
949
|
}
|
|
950
950
|
};
|
|
951
|
-
var
|
|
952
|
-
title: "
|
|
951
|
+
var repeat = {
|
|
952
|
+
title: "Repeat",
|
|
953
953
|
description: "Loop over an array of items.",
|
|
954
|
-
searchTerms: ["for", "loop"],
|
|
954
|
+
searchTerms: ["repeat", "for", "loop"],
|
|
955
955
|
icon: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_lucide_react6.Repeat2, { className: "mly-h-4 mly-w-4" }),
|
|
956
956
|
shouldBeHidden: (editor) => {
|
|
957
|
-
return editor.isActive("
|
|
957
|
+
return editor.isActive("repeat");
|
|
958
958
|
},
|
|
959
959
|
command: ({ editor, range }) => {
|
|
960
|
-
editor.chain().focus().deleteRange(range).
|
|
960
|
+
editor.chain().focus().deleteRange(range).setRepeat().run();
|
|
961
961
|
}
|
|
962
962
|
};
|
|
963
963
|
var spacer = {
|
|
@@ -1089,7 +1089,7 @@ var DEFAULT_SLASH_COMMANDS = [
|
|
|
1089
1089
|
logo,
|
|
1090
1090
|
columns,
|
|
1091
1091
|
section,
|
|
1092
|
-
|
|
1092
|
+
repeat,
|
|
1093
1093
|
divider,
|
|
1094
1094
|
spacer,
|
|
1095
1095
|
button,
|
|
@@ -1668,7 +1668,7 @@ function ColumnsBubbleMenu(props) {
|
|
|
1668
1668
|
}, [editor]);
|
|
1669
1669
|
const bubbleMenuProps = __spreadProps(__spreadValues(__spreadValues({}, props), appendTo ? { appendTo: appendTo.current } : {}), {
|
|
1670
1670
|
shouldShow: ({ editor: editor2 }) => {
|
|
1671
|
-
if (isTextSelected(editor2) || editor2.isActive("section") || editor2.isActive("
|
|
1671
|
+
if (isTextSelected(editor2) || editor2.isActive("section") || editor2.isActive("repeat") || !editor2.isEditable) {
|
|
1672
1672
|
return false;
|
|
1673
1673
|
}
|
|
1674
1674
|
return editor2.isActive("columns");
|
|
@@ -2390,23 +2390,23 @@ var EditorMenuBar = (props) => {
|
|
|
2390
2390
|
);
|
|
2391
2391
|
};
|
|
2392
2392
|
|
|
2393
|
-
// src/editor/components/
|
|
2393
|
+
// src/editor/components/repeat-menu/repeat-bubble-menu.tsx
|
|
2394
2394
|
var import_react18 = require("@tiptap/react");
|
|
2395
2395
|
var import_lucide_react16 = require("lucide-react");
|
|
2396
2396
|
var import_react19 = require("react");
|
|
2397
2397
|
var import_tippy3 = require("tippy.js");
|
|
2398
2398
|
|
|
2399
|
-
// src/editor/components/
|
|
2399
|
+
// src/editor/components/repeat-menu/use-repeat-state.ts
|
|
2400
2400
|
var import_react17 = require("@tiptap/react");
|
|
2401
2401
|
var import_fast_deep_equal2 = __toESM(require("fast-deep-equal"));
|
|
2402
|
-
var
|
|
2402
|
+
var useRepeatState = (editor) => {
|
|
2403
2403
|
const states = (0, import_react17.useEditorState)({
|
|
2404
2404
|
editor,
|
|
2405
2405
|
selector: (ctx) => {
|
|
2406
2406
|
var _a, _b;
|
|
2407
2407
|
return {
|
|
2408
|
-
each: (_a = ctx.editor.getAttributes("
|
|
2409
|
-
currentShowIfKey: ((_b = ctx.editor.getAttributes("
|
|
2408
|
+
each: (_a = ctx.editor.getAttributes("repeat")) == null ? void 0 : _a.each,
|
|
2409
|
+
currentShowIfKey: ((_b = ctx.editor.getAttributes("repeat")) == null ? void 0 : _b.showIfKey) || "",
|
|
2410
2410
|
isSectionActive: ctx.editor.isActive("section")
|
|
2411
2411
|
};
|
|
2412
2412
|
},
|
|
@@ -2415,23 +2415,23 @@ var useForState = (editor) => {
|
|
|
2415
2415
|
return states;
|
|
2416
2416
|
};
|
|
2417
2417
|
|
|
2418
|
-
// src/editor/components/
|
|
2418
|
+
// src/editor/components/repeat-menu/repeat-bubble-menu.tsx
|
|
2419
2419
|
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
2420
|
-
function
|
|
2420
|
+
function RepeatBubbleMenu(props) {
|
|
2421
2421
|
const { appendTo, editor } = props;
|
|
2422
2422
|
if (!editor) {
|
|
2423
2423
|
return null;
|
|
2424
2424
|
}
|
|
2425
|
-
const state =
|
|
2425
|
+
const state = useRepeatState(editor);
|
|
2426
2426
|
const getReferenceClientRect = (0, import_react19.useCallback)(() => {
|
|
2427
|
-
const renderContainer = getRenderContainer(editor, "
|
|
2427
|
+
const renderContainer = getRenderContainer(editor, "repeat");
|
|
2428
2428
|
const rect = (renderContainer == null ? void 0 : renderContainer.getBoundingClientRect()) || new DOMRect(-1e3, -1e3, 0, 0);
|
|
2429
2429
|
return rect;
|
|
2430
2430
|
}, [editor]);
|
|
2431
2431
|
const bubbleMenuProps = __spreadProps(__spreadValues(__spreadValues({}, props), appendTo ? { appendTo: appendTo.current } : {}), {
|
|
2432
2432
|
shouldShow: ({ editor: editor2 }) => {
|
|
2433
2433
|
var _a;
|
|
2434
|
-
const activeForNode = getClosestNodeByName(editor2, "
|
|
2434
|
+
const activeForNode = getClosestNodeByName(editor2, "repeat");
|
|
2435
2435
|
const sectionNodeChildren = activeForNode ? (_a = (0, import_react18.findChildren)(activeForNode == null ? void 0 : activeForNode.node, (node) => {
|
|
2436
2436
|
return node.type.name === "section";
|
|
2437
2437
|
})) == null ? void 0 : _a[0] : null;
|
|
@@ -2439,7 +2439,7 @@ function ForBubbleMenu(props) {
|
|
|
2439
2439
|
if (isTextSelected(editor2) || hasActiveSectionNodeChildren || !editor2.isEditable) {
|
|
2440
2440
|
return false;
|
|
2441
2441
|
}
|
|
2442
|
-
return editor2.isActive("
|
|
2442
|
+
return editor2.isActive("repeat");
|
|
2443
2443
|
},
|
|
2444
2444
|
tippyOptions: {
|
|
2445
2445
|
offset: [0, 8],
|
|
@@ -2452,7 +2452,7 @@ function ForBubbleMenu(props) {
|
|
|
2452
2452
|
sticky: "popper",
|
|
2453
2453
|
maxWidth: "auto"
|
|
2454
2454
|
},
|
|
2455
|
-
pluginKey: "
|
|
2455
|
+
pluginKey: "repeatBubbleMenu"
|
|
2456
2456
|
});
|
|
2457
2457
|
const { variables = [], renderVariable = DEFAULT_RENDER_VARIABLE_FUNCTION } = useMailyContext();
|
|
2458
2458
|
const inputRef = (0, import_react19.useRef)(null);
|
|
@@ -2462,7 +2462,7 @@ function ForBubbleMenu(props) {
|
|
|
2462
2462
|
return processVariables(variables, {
|
|
2463
2463
|
query: eachKey || "",
|
|
2464
2464
|
editor,
|
|
2465
|
-
from: "
|
|
2465
|
+
from: "repeat-variable"
|
|
2466
2466
|
}).map((variable) => variable.name);
|
|
2467
2467
|
}, [variables, eachKey, editor]);
|
|
2468
2468
|
const isValidEachKey = eachKey;
|
|
@@ -2472,7 +2472,7 @@ function ForBubbleMenu(props) {
|
|
|
2472
2472
|
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",
|
|
2473
2473
|
children: /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(TooltipProvider, { children: [
|
|
2474
2474
|
/* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { className: "mly-flex mly-items-center mly-gap-1.5 mly-px-1.5 mly-text-sm mly-leading-none", children: [
|
|
2475
|
-
"
|
|
2475
|
+
"Repeat",
|
|
2476
2476
|
/* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(Tooltip, { children: [
|
|
2477
2477
|
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(TooltipTrigger, { children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
2478
2478
|
import_lucide_react16.InfoIcon,
|
|
@@ -2530,7 +2530,7 @@ function ForBubbleMenu(props) {
|
|
|
2530
2530
|
placeholder: "ie. payload.items",
|
|
2531
2531
|
value: (state == null ? void 0 : state.each) || "",
|
|
2532
2532
|
onValueChange: (value) => {
|
|
2533
|
-
editor.commands.
|
|
2533
|
+
editor.commands.updateRepeat({
|
|
2534
2534
|
each: value
|
|
2535
2535
|
});
|
|
2536
2536
|
},
|
|
@@ -2538,7 +2538,7 @@ function ForBubbleMenu(props) {
|
|
|
2538
2538
|
setIsUpdatingKey(false);
|
|
2539
2539
|
},
|
|
2540
2540
|
onSelectOption: (value) => {
|
|
2541
|
-
editor.commands.
|
|
2541
|
+
editor.commands.updateRepeat({
|
|
2542
2542
|
each: value
|
|
2543
2543
|
});
|
|
2544
2544
|
setIsUpdatingKey(false);
|
|
@@ -2555,7 +2555,7 @@ function ForBubbleMenu(props) {
|
|
|
2555
2555
|
{
|
|
2556
2556
|
showIfKey: state.currentShowIfKey,
|
|
2557
2557
|
onShowIfKeyValueChange: (value) => {
|
|
2558
|
-
editor.commands.
|
|
2558
|
+
editor.commands.updateRepeat({
|
|
2559
2559
|
showIfKey: value
|
|
2560
2560
|
});
|
|
2561
2561
|
},
|
|
@@ -3931,11 +3931,11 @@ function SectionBubbleMenu(props) {
|
|
|
3931
3931
|
shouldShow: ({ editor: editor2 }) => {
|
|
3932
3932
|
var _a;
|
|
3933
3933
|
const activeSectionNode = getClosestNodeByName(editor2, "section");
|
|
3934
|
-
const
|
|
3935
|
-
return node.type.name === "
|
|
3934
|
+
const repeatNodeChildren = activeSectionNode ? (_a = (0, import_react32.findChildren)(activeSectionNode == null ? void 0 : activeSectionNode.node, (node) => {
|
|
3935
|
+
return node.type.name === "repeat";
|
|
3936
3936
|
})) == null ? void 0 : _a[0] : null;
|
|
3937
|
-
const
|
|
3938
|
-
if (isTextSelected(editor2) ||
|
|
3937
|
+
const hasActiveRepeatNodeChildren = repeatNodeChildren && editor2.isActive("repeat");
|
|
3938
|
+
if (isTextSelected(editor2) || hasActiveRepeatNodeChildren || !editor2.isEditable) {
|
|
3939
3939
|
return false;
|
|
3940
3940
|
}
|
|
3941
3941
|
return editor2.isActive("section");
|
|
@@ -5710,22 +5710,22 @@ var ColumnsExtension = import_core12.Node.create({
|
|
|
5710
5710
|
}
|
|
5711
5711
|
});
|
|
5712
5712
|
|
|
5713
|
-
// src/editor/nodes/
|
|
5713
|
+
// src/editor/nodes/repeat/repeat.ts
|
|
5714
5714
|
var import_core13 = require("@tiptap/core");
|
|
5715
5715
|
var import_react48 = require("@tiptap/react");
|
|
5716
5716
|
|
|
5717
|
-
// src/editor/nodes/
|
|
5717
|
+
// src/editor/nodes/repeat/repeat-view.tsx
|
|
5718
5718
|
var import_react47 = require("@tiptap/react");
|
|
5719
5719
|
var import_lucide_react22 = require("lucide-react");
|
|
5720
5720
|
var import_jsx_runtime42 = require("react/jsx-runtime");
|
|
5721
|
-
function
|
|
5721
|
+
function RepeatView(props) {
|
|
5722
5722
|
const { editor, getPos } = props;
|
|
5723
5723
|
return /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(
|
|
5724
5724
|
import_react47.NodeViewWrapper,
|
|
5725
5725
|
{
|
|
5726
|
+
"data-type": "repeat",
|
|
5726
5727
|
draggable: editor.isEditable,
|
|
5727
5728
|
"data-drag-handle": editor.isEditable,
|
|
5728
|
-
"data-type": "for",
|
|
5729
5729
|
className: "mly-relative",
|
|
5730
5730
|
children: [
|
|
5731
5731
|
/* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_react47.NodeViewContent, { className: "is-editable" }),
|
|
@@ -5750,9 +5750,9 @@ function ForView(props) {
|
|
|
5750
5750
|
);
|
|
5751
5751
|
}
|
|
5752
5752
|
|
|
5753
|
-
// src/editor/nodes/
|
|
5754
|
-
var
|
|
5755
|
-
name: "
|
|
5753
|
+
// src/editor/nodes/repeat/repeat.ts
|
|
5754
|
+
var RepeatExtension = import_core13.Node.create({
|
|
5755
|
+
name: "repeat",
|
|
5756
5756
|
group: "block",
|
|
5757
5757
|
content: "(block|columns)+",
|
|
5758
5758
|
draggable: true,
|
|
@@ -5810,7 +5810,7 @@ var ForExtension = import_core13.Node.create({
|
|
|
5810
5810
|
},
|
|
5811
5811
|
addCommands() {
|
|
5812
5812
|
return {
|
|
5813
|
-
|
|
5813
|
+
setRepeat: () => ({ commands }) => {
|
|
5814
5814
|
return commands.insertContent({
|
|
5815
5815
|
type: this.name,
|
|
5816
5816
|
attrs: {},
|
|
@@ -5821,11 +5821,11 @@ var ForExtension = import_core13.Node.create({
|
|
|
5821
5821
|
]
|
|
5822
5822
|
});
|
|
5823
5823
|
},
|
|
5824
|
-
|
|
5824
|
+
updateRepeat: (attrs) => updateAttributes(this.name, attrs)
|
|
5825
5825
|
};
|
|
5826
5826
|
},
|
|
5827
5827
|
addNodeView() {
|
|
5828
|
-
return (0, import_react48.ReactNodeViewRenderer)(
|
|
5828
|
+
return (0, import_react48.ReactNodeViewRenderer)(RepeatView, {
|
|
5829
5829
|
contentDOMElementTag: "div",
|
|
5830
5830
|
className: "mly-relative"
|
|
5831
5831
|
});
|
|
@@ -6047,7 +6047,7 @@ function TextBubbleMenu(props) {
|
|
|
6047
6047
|
return false;
|
|
6048
6048
|
}
|
|
6049
6049
|
const nestedNodes = [
|
|
6050
|
-
|
|
6050
|
+
RepeatExtension.name,
|
|
6051
6051
|
SectionExtension.name,
|
|
6052
6052
|
ColumnsExtension.name,
|
|
6053
6053
|
ColumnExtension.name
|
|
@@ -6499,7 +6499,7 @@ var MailyKit = import_core15.Extension.create({
|
|
|
6499
6499
|
"columns",
|
|
6500
6500
|
"column",
|
|
6501
6501
|
"section",
|
|
6502
|
-
"
|
|
6502
|
+
"repeat",
|
|
6503
6503
|
"show",
|
|
6504
6504
|
"blockquote"
|
|
6505
6505
|
].includes(node.type.name)) {
|
|
@@ -6531,8 +6531,8 @@ var MailyKit = import_core15.Extension.create({
|
|
|
6531
6531
|
if (this.options.linkCard !== false) {
|
|
6532
6532
|
extensions2.push(LinkCardExtension.configure(this.options.linkCard));
|
|
6533
6533
|
}
|
|
6534
|
-
if (this.options.
|
|
6535
|
-
extensions2.push(
|
|
6534
|
+
if (this.options.repeat !== false) {
|
|
6535
|
+
extensions2.push(RepeatExtension);
|
|
6536
6536
|
}
|
|
6537
6537
|
if (this.options.section !== false) {
|
|
6538
6538
|
extensions2.push(SectionExtension);
|
|
@@ -6780,6 +6780,24 @@ function extensions(props) {
|
|
|
6780
6780
|
return [...defaultExtensions, ...extensions2];
|
|
6781
6781
|
}
|
|
6782
6782
|
|
|
6783
|
+
// src/editor/utils/replace-deprecated.ts
|
|
6784
|
+
function replaceDeprecatedNode(json) {
|
|
6785
|
+
const stack = [json];
|
|
6786
|
+
while (stack.length) {
|
|
6787
|
+
const node = stack.pop();
|
|
6788
|
+
if (!node) {
|
|
6789
|
+
continue;
|
|
6790
|
+
}
|
|
6791
|
+
if (node.type === "for") {
|
|
6792
|
+
node.type = "repeat";
|
|
6793
|
+
}
|
|
6794
|
+
if (node.content) {
|
|
6795
|
+
stack.push(...node.content);
|
|
6796
|
+
}
|
|
6797
|
+
}
|
|
6798
|
+
return json;
|
|
6799
|
+
}
|
|
6800
|
+
|
|
6783
6801
|
// src/editor/index.tsx
|
|
6784
6802
|
var import_jsx_runtime47 = require("react/jsx-runtime");
|
|
6785
6803
|
function Editor9(props) {
|
|
@@ -6805,25 +6823,27 @@ function Editor9(props) {
|
|
|
6805
6823
|
editable = true,
|
|
6806
6824
|
placeholderUrl = DEFAULT_PLACEHOLDER_URL
|
|
6807
6825
|
} = props;
|
|
6808
|
-
|
|
6809
|
-
|
|
6810
|
-
|
|
6811
|
-
|
|
6812
|
-
|
|
6813
|
-
|
|
6814
|
-
|
|
6815
|
-
|
|
6816
|
-
|
|
6817
|
-
|
|
6818
|
-
|
|
6819
|
-
|
|
6820
|
-
|
|
6821
|
-
|
|
6822
|
-
|
|
6823
|
-
|
|
6824
|
-
|
|
6825
|
-
|
|
6826
|
-
|
|
6826
|
+
const formattedContent = (0, import_react58.useMemo)(() => {
|
|
6827
|
+
if (contentJson) {
|
|
6828
|
+
const json = (contentJson == null ? void 0 : contentJson.type) === "doc" ? contentJson : {
|
|
6829
|
+
type: "doc",
|
|
6830
|
+
content: contentJson
|
|
6831
|
+
};
|
|
6832
|
+
return replaceDeprecatedNode(json);
|
|
6833
|
+
} else if (contentHtml) {
|
|
6834
|
+
return contentHtml;
|
|
6835
|
+
} else {
|
|
6836
|
+
return {
|
|
6837
|
+
type: "doc",
|
|
6838
|
+
content: [
|
|
6839
|
+
{
|
|
6840
|
+
type: "paragraph",
|
|
6841
|
+
content: []
|
|
6842
|
+
}
|
|
6843
|
+
]
|
|
6844
|
+
};
|
|
6845
|
+
}
|
|
6846
|
+
}, [contentHtml, contentJson]);
|
|
6827
6847
|
const menuContainerRef = (0, import_react58.useRef)(null);
|
|
6828
6848
|
const editor = (0, import_react57.useEditor)({
|
|
6829
6849
|
editorProps: {
|
|
@@ -6895,7 +6915,7 @@ function Editor9(props) {
|
|
|
6895
6915
|
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(SectionBubbleMenu, { editor, appendTo: menuContainerRef }),
|
|
6896
6916
|
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(ColumnsBubbleMenu, { editor, appendTo: menuContainerRef }),
|
|
6897
6917
|
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(ContentMenu, { editor }),
|
|
6898
|
-
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
6918
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(RepeatBubbleMenu, { editor, appendTo: menuContainerRef })
|
|
6899
6919
|
]
|
|
6900
6920
|
}
|
|
6901
6921
|
)
|