@maily-to/core 0.2.2 → 0.2.4
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.js → index.cjs} +2 -2
- package/dist/blocks/index.cjs.map +1 -0
- package/dist/blocks/index.mjs +1 -1
- package/dist/blocks/index.mjs.map +1 -1
- package/dist/extensions/{index.js → index.cjs} +496 -319
- package/dist/extensions/index.cjs.map +1 -0
- package/dist/extensions/index.mjs +467 -290
- package/dist/extensions/index.mjs.map +1 -1
- package/dist/{index.js → index.cjs} +651 -395
- package/dist/index.cjs.map +1 -0
- package/dist/index.css +6 -36
- package/dist/index.css.map +1 -1
- package/dist/index.mjs +602 -346
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -5
- package/dist/blocks/index.js.map +0 -1
- package/dist/extensions/index.js.map +0 -1
- package/dist/index.js.map +0 -1
- /package/dist/blocks/{index.d.mts → index.d.cts} +0 -0
- /package/dist/extensions/{index.d.mts → index.d.cts} +0 -0
- /package/dist/{index.d.mts → index.d.cts} +0 -0
package/dist/index.mjs
CHANGED
|
@@ -53,7 +53,7 @@ var __async = (__this, __arguments, generator) => {
|
|
|
53
53
|
|
|
54
54
|
// src/editor/index.tsx
|
|
55
55
|
import { EditorContent, useEditor } from "@tiptap/react";
|
|
56
|
-
import { useMemo as
|
|
56
|
+
import { useMemo as useMemo14, useRef as useRef13 } from "react";
|
|
57
57
|
|
|
58
58
|
// src/editor/components/column-menu/columns-bubble-menu.tsx
|
|
59
59
|
import { BubbleMenu } from "@tiptap/react";
|
|
@@ -2559,10 +2559,24 @@ var useEvent = (handler) => {
|
|
|
2559
2559
|
}, []);
|
|
2560
2560
|
};
|
|
2561
2561
|
|
|
2562
|
+
// src/editor/utils/aspect-ratio.ts
|
|
2563
|
+
function getAspectRatio(width, height) {
|
|
2564
|
+
return width / height;
|
|
2565
|
+
}
|
|
2566
|
+
function getNewHeight(width, aspectRatio) {
|
|
2567
|
+
if (width <= 0 || aspectRatio <= 0) {
|
|
2568
|
+
return 0;
|
|
2569
|
+
}
|
|
2570
|
+
return width / aspectRatio;
|
|
2571
|
+
}
|
|
2572
|
+
function getNewWidth(height, aspectRatio) {
|
|
2573
|
+
return height * aspectRatio;
|
|
2574
|
+
}
|
|
2575
|
+
|
|
2562
2576
|
// src/editor/nodes/image/image-view.tsx
|
|
2563
2577
|
import { Fragment as Fragment3, jsx as jsx17, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
2564
2578
|
var MIN_WIDTH = 20;
|
|
2565
|
-
var
|
|
2579
|
+
var IMAGE_MAX_WIDTH = 600;
|
|
2566
2580
|
function ImageView(props) {
|
|
2567
2581
|
const { node, updateAttributes: updateAttributes2, selected, editor } = props;
|
|
2568
2582
|
const [status, setStatus] = useState4("idle");
|
|
@@ -2580,7 +2594,10 @@ function ImageView(props) {
|
|
|
2580
2594
|
if (!imgRef.current || !imageParent || !selected) {
|
|
2581
2595
|
return;
|
|
2582
2596
|
}
|
|
2583
|
-
const imageParentWidth = Math.max(
|
|
2597
|
+
const imageParentWidth = Math.max(
|
|
2598
|
+
imageParent.offsetWidth,
|
|
2599
|
+
IMAGE_MAX_WIDTH
|
|
2600
|
+
);
|
|
2584
2601
|
event.preventDefault();
|
|
2585
2602
|
const direction = event.currentTarget.dataset.direction || "--";
|
|
2586
2603
|
const initialXPosition = event.clientX;
|
|
@@ -2592,7 +2609,8 @@ function ImageView(props) {
|
|
|
2592
2609
|
const removeListeners = () => {
|
|
2593
2610
|
window.removeEventListener("mousemove", mouseMoveHandler);
|
|
2594
2611
|
window.removeEventListener("mouseup", removeListeners);
|
|
2595
|
-
|
|
2612
|
+
const aspectRatio = getAspectRatio(newWidth, newHeight);
|
|
2613
|
+
updateAttributes2({ width: newWidth, height: newHeight, aspectRatio });
|
|
2596
2614
|
setResizingStyle(void 0);
|
|
2597
2615
|
};
|
|
2598
2616
|
const mouseMoveHandler = (event2) => {
|
|
@@ -2638,17 +2656,29 @@ function ImageView(props) {
|
|
|
2638
2656
|
},
|
|
2639
2657
|
[handleMouseDown, isPlaceholderImage]
|
|
2640
2658
|
);
|
|
2641
|
-
let {
|
|
2659
|
+
let {
|
|
2660
|
+
alignment = "center",
|
|
2661
|
+
width,
|
|
2662
|
+
height,
|
|
2663
|
+
src,
|
|
2664
|
+
borderRadius: borderRadius2
|
|
2665
|
+
} = node.attrs || {};
|
|
2642
2666
|
const _a = node.attrs || {}, {
|
|
2643
2667
|
externalLink,
|
|
2644
2668
|
isExternalLinkVariable,
|
|
2645
2669
|
isSrcVariable,
|
|
2646
|
-
showIfKey
|
|
2670
|
+
showIfKey,
|
|
2671
|
+
aspectRatio: defaultAspectRatio,
|
|
2672
|
+
borderRadius: _,
|
|
2673
|
+
lockAspectRatio
|
|
2647
2674
|
} = _a, attrs = __objRest(_a, [
|
|
2648
2675
|
"externalLink",
|
|
2649
2676
|
"isExternalLinkVariable",
|
|
2650
2677
|
"isSrcVariable",
|
|
2651
|
-
"showIfKey"
|
|
2678
|
+
"showIfKey",
|
|
2679
|
+
"aspectRatio",
|
|
2680
|
+
"borderRadius",
|
|
2681
|
+
"lockAspectRatio"
|
|
2652
2682
|
]);
|
|
2653
2683
|
const hasImageSrc = !!attrs.src;
|
|
2654
2684
|
const isDroppable = !!onImageUpload && editor.isEditable && !hasImageSrc && !isSrcVariable && status === "idle";
|
|
@@ -2695,14 +2725,15 @@ function ImageView(props) {
|
|
|
2695
2725
|
return;
|
|
2696
2726
|
}
|
|
2697
2727
|
const wrapperWidth = wrapper.offsetWidth;
|
|
2698
|
-
const aspectRatio = naturalWidth
|
|
2728
|
+
const aspectRatio = getAspectRatio(naturalWidth, naturalHeight);
|
|
2699
2729
|
const calculatedHeight = Math.min(
|
|
2700
|
-
wrapperWidth
|
|
2730
|
+
getNewHeight(wrapperWidth, aspectRatio),
|
|
2701
2731
|
naturalHeight
|
|
2702
2732
|
);
|
|
2703
2733
|
updateAttributes2({
|
|
2704
2734
|
width: Math.min(wrapperWidth, naturalWidth),
|
|
2705
|
-
height: Math.min(calculatedHeight, naturalHeight)
|
|
2735
|
+
height: Math.min(calculatedHeight, naturalHeight),
|
|
2736
|
+
aspectRatio
|
|
2706
2737
|
});
|
|
2707
2738
|
};
|
|
2708
2739
|
img.onerror = () => {
|
|
@@ -2772,7 +2803,8 @@ function ImageView(props) {
|
|
|
2772
2803
|
position: "relative",
|
|
2773
2804
|
// Weird! Basically tiptap/prose wraps this in a span and the line height causes an annoying buffer.
|
|
2774
2805
|
lineHeight: "0px",
|
|
2775
|
-
display: "block"
|
|
2806
|
+
display: "block",
|
|
2807
|
+
maxWidth: "100%"
|
|
2776
2808
|
}), {
|
|
2777
2809
|
center: { marginLeft: "auto", marginRight: "auto" },
|
|
2778
2810
|
left: { marginRight: "auto" },
|
|
@@ -2814,7 +2846,8 @@ function ImageView(props) {
|
|
|
2814
2846
|
ref: imgRef,
|
|
2815
2847
|
style: __spreadProps(__spreadValues({}, resizingStyle), {
|
|
2816
2848
|
cursor: "default",
|
|
2817
|
-
marginBottom: 0
|
|
2849
|
+
marginBottom: 0,
|
|
2850
|
+
borderRadius: borderRadius2
|
|
2818
2851
|
}),
|
|
2819
2852
|
draggable: editor.isEditable,
|
|
2820
2853
|
className: cn(
|
|
@@ -3164,9 +3197,33 @@ var LogoExtension = TiptapImage.extend({
|
|
|
3164
3197
|
}
|
|
3165
3198
|
});
|
|
3166
3199
|
|
|
3200
|
+
// src/editor/utils/border-radius.ts
|
|
3201
|
+
var borderRadius = [
|
|
3202
|
+
{
|
|
3203
|
+
name: "Sharp",
|
|
3204
|
+
value: 0
|
|
3205
|
+
},
|
|
3206
|
+
{
|
|
3207
|
+
name: "Smooth",
|
|
3208
|
+
value: 8
|
|
3209
|
+
},
|
|
3210
|
+
{
|
|
3211
|
+
name: "Smoother",
|
|
3212
|
+
value: 16
|
|
3213
|
+
},
|
|
3214
|
+
{
|
|
3215
|
+
name: "Rounded",
|
|
3216
|
+
value: 24
|
|
3217
|
+
},
|
|
3218
|
+
{
|
|
3219
|
+
name: "Circle",
|
|
3220
|
+
value: 9999
|
|
3221
|
+
}
|
|
3222
|
+
];
|
|
3223
|
+
|
|
3167
3224
|
// src/editor/components/image-menu/image-bubble-menu.tsx
|
|
3168
3225
|
import { BubbleMenu as BubbleMenu3 } from "@tiptap/react";
|
|
3169
|
-
import { ImageDown } from "lucide-react";
|
|
3226
|
+
import { ImageDown, LockIcon, LockOpenIcon } from "lucide-react";
|
|
3170
3227
|
import { sticky as sticky3 } from "tippy.js";
|
|
3171
3228
|
|
|
3172
3229
|
// src/editor/components/alignment-switch.tsx
|
|
@@ -3242,7 +3299,7 @@ function AlignmentSwitch(props) {
|
|
|
3242
3299
|
}
|
|
3243
3300
|
|
|
3244
3301
|
// src/editor/components/ui/link-input-popover.tsx
|
|
3245
|
-
import {
|
|
3302
|
+
import { Link, LinkIcon as LinkIcon2 } from "lucide-react";
|
|
3246
3303
|
import { useRef as useRef7, useState as useState7 } from "react";
|
|
3247
3304
|
|
|
3248
3305
|
// src/editor/provider.tsx
|
|
@@ -3320,7 +3377,7 @@ var inlineImage = {
|
|
|
3320
3377
|
icon: /* @__PURE__ */ jsx22(ImageIcon, { className: "mly-h-4 mly-w-4" }),
|
|
3321
3378
|
command: ({ editor, range }) => {
|
|
3322
3379
|
editor.chain().focus().deleteRange(range).setInlineImage({
|
|
3323
|
-
src: ""
|
|
3380
|
+
src: "https://maily.to/brand/logo.png"
|
|
3324
3381
|
}).command((props) => {
|
|
3325
3382
|
const { tr, state, view, editor: editor2 } = props;
|
|
3326
3383
|
const { from } = range;
|
|
@@ -4167,7 +4224,7 @@ var DEFAULT_SLASH_COMMANDS = [
|
|
|
4167
4224
|
|
|
4168
4225
|
// src/editor/provider.tsx
|
|
4169
4226
|
import { jsx as jsx32 } from "react/jsx-runtime";
|
|
4170
|
-
var DEFAULT_PLACEHOLDER_URL = "maily.to/";
|
|
4227
|
+
var DEFAULT_PLACEHOLDER_URL = "https://maily.to/";
|
|
4171
4228
|
var MailyContext = createContext({
|
|
4172
4229
|
placeholderUrl: DEFAULT_PLACEHOLDER_URL,
|
|
4173
4230
|
blocks: DEFAULT_SLASH_COMMANDS
|
|
@@ -4598,10 +4655,9 @@ var VariableExtension = Node4.create({
|
|
|
4598
4655
|
});
|
|
4599
4656
|
|
|
4600
4657
|
// src/editor/components/ui/link-input-popover.tsx
|
|
4601
|
-
import {
|
|
4602
|
-
var LINK_PROTOCOL_REGEX = /https?:\/\//;
|
|
4658
|
+
import { jsx as jsx35, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
4603
4659
|
function LinkInputPopover(props) {
|
|
4604
|
-
var _a, _b
|
|
4660
|
+
var _a, _b;
|
|
4605
4661
|
const {
|
|
4606
4662
|
defaultValue = "",
|
|
4607
4663
|
onValueChange,
|
|
@@ -4610,22 +4666,16 @@ function LinkInputPopover(props) {
|
|
|
4610
4666
|
editor,
|
|
4611
4667
|
isVariable
|
|
4612
4668
|
} = props;
|
|
4613
|
-
const defaultProtocol = (_a = defaultValue.match(LINK_PROTOCOL_REGEX)) == null ? void 0 : _a[0];
|
|
4614
|
-
const defaultUrlWithoutProtocol = defaultValue.replace(
|
|
4615
|
-
LINK_PROTOCOL_REGEX,
|
|
4616
|
-
""
|
|
4617
|
-
);
|
|
4618
4669
|
const [isOpen, setIsOpen] = useState7(false);
|
|
4619
|
-
const [protocol, setProtocol] = useState7(defaultProtocol || "https://");
|
|
4620
4670
|
const [isEditing, setIsEditing] = useState7(!isVariable);
|
|
4621
4671
|
const linkInputRef = useRef7(null);
|
|
4622
4672
|
const { placeholderUrl = DEFAULT_PLACEHOLDER_URL } = useMailyContext();
|
|
4623
4673
|
const options = useVariableOptions(editor);
|
|
4624
4674
|
const renderVariable = options == null ? void 0 : options.renderVariable;
|
|
4625
4675
|
const variables = options == null ? void 0 : options.variables;
|
|
4626
|
-
const variableTriggerCharacter = (
|
|
4676
|
+
const variableTriggerCharacter = (_b = (_a = options == null ? void 0 : options.suggestion) == null ? void 0 : _a.char) != null ? _b : DEFAULT_VARIABLE_TRIGGER_CHAR;
|
|
4627
4677
|
const autoCompleteOptions = useMemo6(() => {
|
|
4628
|
-
const withoutTrigger =
|
|
4678
|
+
const withoutTrigger = defaultValue.replace(
|
|
4629
4679
|
new RegExp(variableTriggerCharacter, "g"),
|
|
4630
4680
|
""
|
|
4631
4681
|
);
|
|
@@ -4634,7 +4684,7 @@ function LinkInputPopover(props) {
|
|
|
4634
4684
|
from: "bubble-variable",
|
|
4635
4685
|
editor
|
|
4636
4686
|
}).map((variable) => variable.name);
|
|
4637
|
-
}, [variables, variableTriggerCharacter,
|
|
4687
|
+
}, [variables, variableTriggerCharacter, defaultValue, editor]);
|
|
4638
4688
|
const popoverButton = /* @__PURE__ */ jsx35(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsx35(
|
|
4639
4689
|
BaseButton,
|
|
4640
4690
|
{
|
|
@@ -4642,130 +4692,105 @@ function LinkInputPopover(props) {
|
|
|
4642
4692
|
size: "sm",
|
|
4643
4693
|
type: "button",
|
|
4644
4694
|
className: "mly-size-7",
|
|
4645
|
-
"data-state": !!
|
|
4695
|
+
"data-state": !!defaultValue,
|
|
4646
4696
|
children: /* @__PURE__ */ jsx35(Icon, { className: "mly-h-3 mly-w-3 mly-shrink-0 mly-stroke-[2.5] mly-text-midnight-gray" })
|
|
4647
4697
|
}
|
|
4648
4698
|
) });
|
|
4649
|
-
|
|
4650
|
-
|
|
4651
|
-
|
|
4652
|
-
|
|
4653
|
-
|
|
4654
|
-
|
|
4655
|
-
|
|
4656
|
-
|
|
4657
|
-
|
|
4658
|
-
|
|
4659
|
-
|
|
4660
|
-
|
|
4661
|
-
|
|
4662
|
-
|
|
4663
|
-
|
|
4664
|
-
|
|
4665
|
-
|
|
4666
|
-
|
|
4667
|
-
|
|
4699
|
+
return /* @__PURE__ */ jsxs17(
|
|
4700
|
+
Popover,
|
|
4701
|
+
{
|
|
4702
|
+
open: isOpen,
|
|
4703
|
+
onOpenChange: (open) => {
|
|
4704
|
+
setIsOpen(open);
|
|
4705
|
+
if (open) {
|
|
4706
|
+
setTimeout(() => {
|
|
4707
|
+
var _a2;
|
|
4708
|
+
(_a2 = linkInputRef.current) == null ? void 0 : _a2.focus();
|
|
4709
|
+
}, 0);
|
|
4710
|
+
}
|
|
4711
|
+
},
|
|
4712
|
+
children: [
|
|
4713
|
+
tooltip ? /* @__PURE__ */ jsxs17(Tooltip, { children: [
|
|
4714
|
+
/* @__PURE__ */ jsx35(TooltipTrigger, { asChild: true, children: popoverButton }),
|
|
4715
|
+
/* @__PURE__ */ jsx35(TooltipContent, { sideOffset: 8, children: tooltip })
|
|
4716
|
+
] }) : popoverButton,
|
|
4717
|
+
/* @__PURE__ */ jsx35(
|
|
4718
|
+
PopoverContent,
|
|
4668
4719
|
{
|
|
4669
|
-
|
|
4670
|
-
|
|
4671
|
-
|
|
4672
|
-
|
|
4673
|
-
|
|
4674
|
-
|
|
4675
|
-
|
|
4676
|
-
|
|
4677
|
-
|
|
4678
|
-
|
|
4679
|
-
|
|
4680
|
-
|
|
4681
|
-
|
|
4682
|
-
|
|
4683
|
-
|
|
4684
|
-
|
|
4685
|
-
|
|
4686
|
-
|
|
4687
|
-
|
|
4688
|
-
|
|
4689
|
-
},
|
|
4690
|
-
children: renderVariable({
|
|
4691
|
-
variable: {
|
|
4692
|
-
name: defaultUrlWithoutProtocol,
|
|
4693
|
-
valid: true
|
|
4694
|
-
},
|
|
4695
|
-
fallback: "",
|
|
4696
|
-
from: "bubble-variable",
|
|
4697
|
-
editor
|
|
4698
|
-
})
|
|
4699
|
-
}
|
|
4700
|
-
) }),
|
|
4701
|
-
isEditing && /* @__PURE__ */ jsxs17(Fragment4, { children: [
|
|
4702
|
-
/* @__PURE__ */ jsxs17("div", { className: "mly-relative", children: [
|
|
4703
|
-
/* @__PURE__ */ jsxs17(
|
|
4704
|
-
"select",
|
|
4720
|
+
align: "end",
|
|
4721
|
+
side: "top",
|
|
4722
|
+
className: "mly-w-max mly-rounded-none mly-border-none mly-bg-transparent !mly-p-0 mly-shadow-none",
|
|
4723
|
+
sideOffset: 8,
|
|
4724
|
+
onCloseAutoFocus: (e) => e.preventDefault(),
|
|
4725
|
+
children: /* @__PURE__ */ jsx35(
|
|
4726
|
+
"form",
|
|
4727
|
+
{
|
|
4728
|
+
onSubmit: (e) => {
|
|
4729
|
+
e.preventDefault();
|
|
4730
|
+
const input = linkInputRef.current;
|
|
4731
|
+
if (!input) {
|
|
4732
|
+
return;
|
|
4733
|
+
}
|
|
4734
|
+
onValueChange == null ? void 0 : onValueChange(input.value);
|
|
4735
|
+
setIsOpen(false);
|
|
4736
|
+
},
|
|
4737
|
+
children: /* @__PURE__ */ jsxs17("div", { className: "mly-isolate mly-flex mly-rounded-lg", children: [
|
|
4738
|
+
!isEditing && /* @__PURE__ */ jsx35("div", { className: "mly-flex mly-h-8 mly-items-center mly-rounded-lg mly-border mly-border-gray-300 mly-bg-white mly-px-0.5", children: /* @__PURE__ */ jsx35(
|
|
4739
|
+
"button",
|
|
4705
4740
|
{
|
|
4706
|
-
|
|
4707
|
-
|
|
4708
|
-
|
|
4709
|
-
|
|
4710
|
-
|
|
4711
|
-
|
|
4712
|
-
setProtocol(protocol2);
|
|
4713
|
-
const newValue = normalizeProtocol(
|
|
4714
|
-
((_a2 = linkInputRef.current) == null ? void 0 : _a2.value) || "",
|
|
4715
|
-
protocol2
|
|
4716
|
-
);
|
|
4717
|
-
onValueChange == null ? void 0 : onValueChange(newValue);
|
|
4741
|
+
onClick: () => {
|
|
4742
|
+
setIsEditing(true);
|
|
4743
|
+
setTimeout(() => {
|
|
4744
|
+
var _a2;
|
|
4745
|
+
(_a2 = linkInputRef.current) == null ? void 0 : _a2.focus();
|
|
4746
|
+
}, 0);
|
|
4718
4747
|
},
|
|
4719
|
-
children:
|
|
4720
|
-
|
|
4721
|
-
|
|
4722
|
-
|
|
4723
|
-
|
|
4724
|
-
|
|
4725
|
-
|
|
4726
|
-
|
|
4727
|
-
|
|
4728
|
-
size: 16,
|
|
4729
|
-
strokeWidth: 2,
|
|
4730
|
-
"aria-hidden": "true",
|
|
4731
|
-
role: "img"
|
|
4748
|
+
children: renderVariable({
|
|
4749
|
+
variable: {
|
|
4750
|
+
name: defaultValue,
|
|
4751
|
+
valid: true
|
|
4752
|
+
},
|
|
4753
|
+
fallback: "",
|
|
4754
|
+
from: "bubble-variable",
|
|
4755
|
+
editor
|
|
4756
|
+
})
|
|
4732
4757
|
}
|
|
4733
|
-
) })
|
|
4734
|
-
|
|
4735
|
-
|
|
4736
|
-
|
|
4737
|
-
|
|
4738
|
-
|
|
4739
|
-
|
|
4740
|
-
|
|
4741
|
-
|
|
4742
|
-
|
|
4743
|
-
|
|
4744
|
-
|
|
4745
|
-
|
|
4746
|
-
|
|
4747
|
-
|
|
4748
|
-
|
|
4749
|
-
|
|
4750
|
-
|
|
4751
|
-
|
|
4752
|
-
|
|
4753
|
-
|
|
4754
|
-
|
|
4755
|
-
|
|
4758
|
+
) }),
|
|
4759
|
+
isEditing && /* @__PURE__ */ jsxs17("div", { className: "mly-relative", children: [
|
|
4760
|
+
/* @__PURE__ */ jsx35("div", { className: "mly-absolute mly-inset-y-0 mly-left-1.5 mly-z-10 mly-flex mly-items-center", children: /* @__PURE__ */ jsx35(LinkIcon2, { className: "mly-h-3 mly-w-3 mly-stroke-[2.5] mly-text-midnight-gray" }) }),
|
|
4761
|
+
/* @__PURE__ */ jsx35(
|
|
4762
|
+
InputAutocomplete,
|
|
4763
|
+
{
|
|
4764
|
+
editor,
|
|
4765
|
+
value: defaultValue,
|
|
4766
|
+
onValueChange: (value) => {
|
|
4767
|
+
onValueChange == null ? void 0 : onValueChange(value);
|
|
4768
|
+
},
|
|
4769
|
+
autoCompleteOptions,
|
|
4770
|
+
ref: linkInputRef,
|
|
4771
|
+
placeholder: placeholderUrl,
|
|
4772
|
+
className: "-mly-ms-px mly-block mly-h-8 mly-w-56 mly-rounded-lg mly-border mly-border-gray-300 mly-px-2 mly-py-1.5 mly-pl-6 mly-pr-6 mly-text-sm mly-shadow-sm mly-outline-none placeholder:mly-text-gray-400",
|
|
4773
|
+
triggerChar: variableTriggerCharacter,
|
|
4774
|
+
onSelectOption: (value) => {
|
|
4775
|
+
var _a2;
|
|
4776
|
+
const isVariable2 = (_a2 = autoCompleteOptions.includes(value)) != null ? _a2 : false;
|
|
4777
|
+
if (isVariable2) {
|
|
4778
|
+
setIsEditing(false);
|
|
4779
|
+
}
|
|
4780
|
+
onValueChange == null ? void 0 : onValueChange(value, isVariable2);
|
|
4781
|
+
setIsOpen(false);
|
|
4782
|
+
}
|
|
4756
4783
|
}
|
|
4757
|
-
|
|
4758
|
-
|
|
4759
|
-
|
|
4760
|
-
|
|
4761
|
-
|
|
4762
|
-
] })
|
|
4763
|
-
] })
|
|
4784
|
+
)
|
|
4785
|
+
] })
|
|
4786
|
+
] })
|
|
4787
|
+
}
|
|
4788
|
+
)
|
|
4764
4789
|
}
|
|
4765
4790
|
)
|
|
4766
|
-
|
|
4767
|
-
|
|
4768
|
-
|
|
4791
|
+
]
|
|
4792
|
+
}
|
|
4793
|
+
);
|
|
4769
4794
|
}
|
|
4770
4795
|
|
|
4771
4796
|
// src/editor/components/image-menu/image-size.tsx
|
|
@@ -4794,19 +4819,22 @@ var useImageState = (editor) => {
|
|
|
4794
4819
|
const states = useEditorState3({
|
|
4795
4820
|
editor,
|
|
4796
4821
|
selector: ({ editor: editor2 }) => {
|
|
4797
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
|
|
4822
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
|
|
4798
4823
|
return {
|
|
4799
4824
|
width: String(editor2.getAttributes("image").width),
|
|
4800
4825
|
height: String(editor2.getAttributes("image").height),
|
|
4801
4826
|
isImageActive: editor2.isActive("image"),
|
|
4802
4827
|
isLogoActive: editor2.isActive("logo"),
|
|
4803
4828
|
alignment: ((_a = editor2.getAttributes("image")) == null ? void 0 : _a.alignment) || ((_b = editor2.getAttributes("logo")) == null ? void 0 : _b.alignment),
|
|
4804
|
-
|
|
4805
|
-
|
|
4806
|
-
|
|
4807
|
-
|
|
4808
|
-
|
|
4809
|
-
|
|
4829
|
+
borderRadius: (_c = editor2.getAttributes("image")) == null ? void 0 : _c.borderRadius,
|
|
4830
|
+
logoSize: ((_d = editor2.getAttributes("logo")) == null ? void 0 : _d.size) || DEFAULT_LOGO_SIZE,
|
|
4831
|
+
imageSrc: ((_e = editor2.getAttributes("image")) == null ? void 0 : _e.src) || ((_f = editor2.getAttributes("logo")) == null ? void 0 : _f.src) || "",
|
|
4832
|
+
isSrcVariable: (_j = (_i = (_g = editor2.getAttributes("image")) == null ? void 0 : _g.isSrcVariable) != null ? _i : (_h = editor2.getAttributes("logo")) == null ? void 0 : _h.isSrcVariable) != null ? _j : false,
|
|
4833
|
+
imageExternalLink: ((_k = editor2.getAttributes("image")) == null ? void 0 : _k.externalLink) || "",
|
|
4834
|
+
isExternalLinkVariable: (_l = editor2.getAttributes("image")) == null ? void 0 : _l.isExternalLinkVariable,
|
|
4835
|
+
lockAspectRatio: (_m = editor2.getAttributes("image")) == null ? void 0 : _m.lockAspectRatio,
|
|
4836
|
+
aspectRatio: (_n = editor2.getAttributes("image")) == null ? void 0 : _n.aspectRatio,
|
|
4837
|
+
currentShowIfKey: ((_o = editor2.getAttributes("image")) == null ? void 0 : _o.showIfKey) || ((_p = editor2.getAttributes("logo")) == null ? void 0 : _p.showIfKey) || ""
|
|
4810
4838
|
};
|
|
4811
4839
|
},
|
|
4812
4840
|
equalityFn: deepEql3
|
|
@@ -4815,7 +4843,7 @@ var useImageState = (editor) => {
|
|
|
4815
4843
|
};
|
|
4816
4844
|
|
|
4817
4845
|
// src/editor/components/image-menu/image-bubble-menu.tsx
|
|
4818
|
-
import { Fragment as
|
|
4846
|
+
import { Fragment as Fragment4, jsx as jsx37, jsxs as jsxs19 } from "react/jsx-runtime";
|
|
4819
4847
|
function ImageBubbleMenu(props) {
|
|
4820
4848
|
var _a, _b, _c, _d;
|
|
4821
4849
|
const { editor, appendTo } = props;
|
|
@@ -4839,12 +4867,13 @@ function ImageBubbleMenu(props) {
|
|
|
4839
4867
|
maxWidth: "100%"
|
|
4840
4868
|
}
|
|
4841
4869
|
});
|
|
4870
|
+
const { lockAspectRatio } = state;
|
|
4842
4871
|
return /* @__PURE__ */ jsx37(
|
|
4843
4872
|
BubbleMenu3,
|
|
4844
4873
|
__spreadProps(__spreadValues({}, bubbleMenuProps), {
|
|
4845
4874
|
className: "mly-flex mly-rounded-lg mly-border mly-border-gray-200 mly-bg-white mly-p-0.5 mly-shadow-md",
|
|
4846
4875
|
children: /* @__PURE__ */ jsxs19(TooltipProvider, { children: [
|
|
4847
|
-
state.isLogoActive && state.imageSrc && /* @__PURE__ */ jsxs19(
|
|
4876
|
+
state.isLogoActive && state.imageSrc && /* @__PURE__ */ jsxs19(Fragment4, { children: [
|
|
4848
4877
|
/* @__PURE__ */ jsx37(
|
|
4849
4878
|
Select,
|
|
4850
4879
|
{
|
|
@@ -4916,8 +4945,26 @@ function ImageBubbleMenu(props) {
|
|
|
4916
4945
|
}
|
|
4917
4946
|
)
|
|
4918
4947
|
] }),
|
|
4919
|
-
state.isImageActive && state.imageSrc && /* @__PURE__ */ jsxs19(
|
|
4948
|
+
state.isImageActive && state.imageSrc && /* @__PURE__ */ jsxs19(Fragment4, { children: [
|
|
4920
4949
|
/* @__PURE__ */ jsx37(Divider, {}),
|
|
4950
|
+
/* @__PURE__ */ jsx37(
|
|
4951
|
+
Select,
|
|
4952
|
+
{
|
|
4953
|
+
label: "Border Radius",
|
|
4954
|
+
value: state == null ? void 0 : state.borderRadius,
|
|
4955
|
+
options: borderRadius.map((value) => ({
|
|
4956
|
+
value: String(value.value),
|
|
4957
|
+
label: value.name
|
|
4958
|
+
})),
|
|
4959
|
+
onValueChange: (value) => {
|
|
4960
|
+
editor == null ? void 0 : editor.chain().updateAttributes("image", {
|
|
4961
|
+
borderRadius: Number(value)
|
|
4962
|
+
}).run();
|
|
4963
|
+
},
|
|
4964
|
+
tooltip: "Border Radius",
|
|
4965
|
+
className: "mly-capitalize"
|
|
4966
|
+
}
|
|
4967
|
+
),
|
|
4921
4968
|
/* @__PURE__ */ jsxs19("div", { className: "mly-flex mly-space-x-0.5", children: [
|
|
4922
4969
|
/* @__PURE__ */ jsx37(
|
|
4923
4970
|
ImageSize,
|
|
@@ -4925,7 +4972,14 @@ function ImageBubbleMenu(props) {
|
|
|
4925
4972
|
dimension: "width",
|
|
4926
4973
|
value: (_c = state == null ? void 0 : state.width) != null ? _c : "",
|
|
4927
4974
|
onValueChange: (value) => {
|
|
4928
|
-
|
|
4975
|
+
const width = Math.min(Number(value) || 0, IMAGE_MAX_WIDTH);
|
|
4976
|
+
editor == null ? void 0 : editor.chain().updateAttributes("image", __spreadValues({
|
|
4977
|
+
width: String(width)
|
|
4978
|
+
}, lockAspectRatio && value ? {
|
|
4979
|
+
height: String(
|
|
4980
|
+
getNewHeight(width, state.aspectRatio)
|
|
4981
|
+
)
|
|
4982
|
+
} : {})).run();
|
|
4929
4983
|
}
|
|
4930
4984
|
}
|
|
4931
4985
|
),
|
|
@@ -4935,9 +4989,33 @@ function ImageBubbleMenu(props) {
|
|
|
4935
4989
|
dimension: "height",
|
|
4936
4990
|
value: (_d = state == null ? void 0 : state.height) != null ? _d : "",
|
|
4937
4991
|
onValueChange: (value) => {
|
|
4938
|
-
|
|
4992
|
+
const height = Number(value) || 0;
|
|
4993
|
+
editor == null ? void 0 : editor.chain().updateAttributes("image", __spreadValues({
|
|
4994
|
+
height: String(height)
|
|
4995
|
+
}, lockAspectRatio && value ? {
|
|
4996
|
+
width: String(
|
|
4997
|
+
getNewWidth(height, state.aspectRatio)
|
|
4998
|
+
)
|
|
4999
|
+
} : {})).run();
|
|
4939
5000
|
}
|
|
4940
5001
|
}
|
|
5002
|
+
),
|
|
5003
|
+
/* @__PURE__ */ jsx37(
|
|
5004
|
+
BubbleMenuButton,
|
|
5005
|
+
{
|
|
5006
|
+
isActive: () => lockAspectRatio,
|
|
5007
|
+
command: () => {
|
|
5008
|
+
const width = Number(state.width) || 0;
|
|
5009
|
+
const height = Number(state.height) || 0;
|
|
5010
|
+
const aspectRatio = width / height;
|
|
5011
|
+
editor == null ? void 0 : editor.chain().updateAttributes("image", {
|
|
5012
|
+
lockAspectRatio: !lockAspectRatio,
|
|
5013
|
+
aspectRatio
|
|
5014
|
+
}).run();
|
|
5015
|
+
},
|
|
5016
|
+
icon: lockAspectRatio ? LockIcon : LockOpenIcon,
|
|
5017
|
+
tooltip: "Lock Aspect Ratio"
|
|
5018
|
+
}
|
|
4941
5019
|
)
|
|
4942
5020
|
] })
|
|
4943
5021
|
] }),
|
|
@@ -5585,7 +5663,7 @@ var useSectionState = (editor) => {
|
|
|
5585
5663
|
};
|
|
5586
5664
|
|
|
5587
5665
|
// src/editor/components/section-menu/section-bubble-menu.tsx
|
|
5588
|
-
import { Fragment as
|
|
5666
|
+
import { Fragment as Fragment5, jsx as jsx44, jsxs as jsxs24 } from "react/jsx-runtime";
|
|
5589
5667
|
function SectionBubbleMenu(props) {
|
|
5590
5668
|
const { appendTo, editor } = props;
|
|
5591
5669
|
if (!editor) {
|
|
@@ -5821,7 +5899,7 @@ function SectionBubbleMenu(props) {
|
|
|
5821
5899
|
editor
|
|
5822
5900
|
}
|
|
5823
5901
|
),
|
|
5824
|
-
state.isColumnsActive && /* @__PURE__ */ jsxs24(
|
|
5902
|
+
state.isColumnsActive && /* @__PURE__ */ jsxs24(Fragment5, { children: [
|
|
5825
5903
|
/* @__PURE__ */ jsx44(Divider, {}),
|
|
5826
5904
|
/* @__PURE__ */ jsxs24(Popover, { children: [
|
|
5827
5905
|
/* @__PURE__ */ jsxs24(PopoverTrigger, { className: "mly-flex mly-items-center mly-gap-1 mly-rounded-md mly-px-1.5 mly-text-sm data-[state=open]:mly-bg-soft-gray hover:mly-bg-soft-gray", children: [
|
|
@@ -7079,6 +7157,7 @@ var ButtonExtension = Node9.create({
|
|
|
7079
7157
|
// src/editor/nodes/image/image.ts
|
|
7080
7158
|
import TiptapImage2 from "@tiptap/extension-image";
|
|
7081
7159
|
import { ReactNodeViewRenderer as ReactNodeViewRenderer5 } from "@tiptap/react";
|
|
7160
|
+
var DEFAULT_IMAGE_BORDER_RADIUS = 0;
|
|
7082
7161
|
var ImageExtension = TiptapImage2.extend({
|
|
7083
7162
|
addAttributes() {
|
|
7084
7163
|
var _a;
|
|
@@ -7142,6 +7221,17 @@ var ImageExtension = TiptapImage2.extend({
|
|
|
7142
7221
|
};
|
|
7143
7222
|
}
|
|
7144
7223
|
},
|
|
7224
|
+
borderRadius: {
|
|
7225
|
+
default: DEFAULT_IMAGE_BORDER_RADIUS,
|
|
7226
|
+
parseHTML: (element) => {
|
|
7227
|
+
return Number(element.getAttribute("data-border-radius"));
|
|
7228
|
+
},
|
|
7229
|
+
renderHTML: (attributes) => {
|
|
7230
|
+
return {
|
|
7231
|
+
"data-border-radius": attributes.borderRadius
|
|
7232
|
+
};
|
|
7233
|
+
}
|
|
7234
|
+
},
|
|
7145
7235
|
// Later we will remove this attribute
|
|
7146
7236
|
// and use the `src` attribute instead when implement
|
|
7147
7237
|
// the URL variable feature
|
|
@@ -7159,6 +7249,34 @@ var ImageExtension = TiptapImage2.extend({
|
|
|
7159
7249
|
};
|
|
7160
7250
|
}
|
|
7161
7251
|
},
|
|
7252
|
+
aspectRatio: {
|
|
7253
|
+
default: null,
|
|
7254
|
+
parseHTML: (element) => {
|
|
7255
|
+
return element.getAttribute("data-aspect-ratio") || null;
|
|
7256
|
+
},
|
|
7257
|
+
renderHTML: (attributes) => {
|
|
7258
|
+
if (!(attributes == null ? void 0 : attributes.aspectRatio)) {
|
|
7259
|
+
return {};
|
|
7260
|
+
}
|
|
7261
|
+
return {
|
|
7262
|
+
"data-aspect-ratio": attributes == null ? void 0 : attributes.aspectRatio
|
|
7263
|
+
};
|
|
7264
|
+
}
|
|
7265
|
+
},
|
|
7266
|
+
lockAspectRatio: {
|
|
7267
|
+
default: true,
|
|
7268
|
+
parseHTML: (element) => {
|
|
7269
|
+
return element.getAttribute("data-lock-aspect-ratio") === "true";
|
|
7270
|
+
},
|
|
7271
|
+
renderHTML: (attributes) => {
|
|
7272
|
+
if (!attributes.lockAspectRatio) {
|
|
7273
|
+
return {};
|
|
7274
|
+
}
|
|
7275
|
+
return {
|
|
7276
|
+
"data-lock-aspect-ratio": "true"
|
|
7277
|
+
};
|
|
7278
|
+
}
|
|
7279
|
+
},
|
|
7162
7280
|
showIfKey: {
|
|
7163
7281
|
default: DEFAULT_SECTION_SHOW_IF_KEY,
|
|
7164
7282
|
parseHTML: (element) => {
|
|
@@ -7238,7 +7356,24 @@ function HTMLCodeBlockView(props) {
|
|
|
7238
7356
|
"mly-not-prose mly-rounded-lg mly-border mly-border-gray-200 mly-p-2",
|
|
7239
7357
|
isEmpty && "mly-min-h-[42px]"
|
|
7240
7358
|
),
|
|
7241
|
-
|
|
7359
|
+
ref: (node2) => {
|
|
7360
|
+
if (!node2 || (node2 == null ? void 0 : node2.shadowRoot)) {
|
|
7361
|
+
return;
|
|
7362
|
+
}
|
|
7363
|
+
const shadow = node2.attachShadow({ mode: "open" });
|
|
7364
|
+
const sheet = new CSSStyleSheet();
|
|
7365
|
+
sheet.replaceSync(`
|
|
7366
|
+
* { font-family: 'Inter', sans-serif; }
|
|
7367
|
+
blockquote, h1, h2, h3, img, li, ol, p, ul {
|
|
7368
|
+
margin-top: 0;
|
|
7369
|
+
margin-bottom: 0;
|
|
7370
|
+
}
|
|
7371
|
+
`);
|
|
7372
|
+
shadow.adoptedStyleSheets = [sheet];
|
|
7373
|
+
const container = document.createElement("div");
|
|
7374
|
+
container.innerHTML = html2;
|
|
7375
|
+
shadow.appendChild(container);
|
|
7376
|
+
},
|
|
7242
7377
|
contentEditable: false,
|
|
7243
7378
|
onClick: () => {
|
|
7244
7379
|
if (!isEmpty) {
|
|
@@ -7663,21 +7798,123 @@ import { ReactRenderer } from "@tiptap/react";
|
|
|
7663
7798
|
import {
|
|
7664
7799
|
forwardRef as forwardRef8,
|
|
7665
7800
|
Fragment as Fragment7,
|
|
7666
|
-
useCallback as
|
|
7667
|
-
useEffect as
|
|
7801
|
+
useCallback as useCallback11,
|
|
7802
|
+
useEffect as useEffect8,
|
|
7668
7803
|
useImperativeHandle as useImperativeHandle2,
|
|
7669
7804
|
useLayoutEffect as useLayoutEffect2,
|
|
7670
|
-
useRef as
|
|
7671
|
-
useState as
|
|
7805
|
+
useRef as useRef11,
|
|
7806
|
+
useState as useState11
|
|
7672
7807
|
} from "react";
|
|
7673
7808
|
import tippy2 from "tippy.js";
|
|
7809
|
+
|
|
7810
|
+
// src/editor/extensions/slash-command/slash-command-item.tsx
|
|
7674
7811
|
import { ChevronRightIcon } from "lucide-react";
|
|
7675
|
-
import {
|
|
7812
|
+
import { useCallback as useCallback10, useState as useState10, useRef as useRef10, useEffect as useEffect7 } from "react";
|
|
7813
|
+
import { Fragment as Fragment6, jsx as jsx53, jsxs as jsxs31 } from "react/jsx-runtime";
|
|
7814
|
+
function SlashCommandItem(props) {
|
|
7815
|
+
var _a;
|
|
7816
|
+
const {
|
|
7817
|
+
item,
|
|
7818
|
+
groupIndex,
|
|
7819
|
+
commandIndex,
|
|
7820
|
+
selectedGroupIndex,
|
|
7821
|
+
selectedCommandIndex,
|
|
7822
|
+
editor,
|
|
7823
|
+
activeCommandRef,
|
|
7824
|
+
selectItem
|
|
7825
|
+
} = props;
|
|
7826
|
+
const [open, setOpen] = useState10(false);
|
|
7827
|
+
const [isHovered, setIsHovered] = useState10(false);
|
|
7828
|
+
const isActive = groupIndex === selectedGroupIndex && commandIndex === selectedCommandIndex;
|
|
7829
|
+
const isSubCommand = item && "commands" in item;
|
|
7830
|
+
const shouldOpenTooltip = !!(item == null ? void 0 : item.preview) && (isActive || isHovered);
|
|
7831
|
+
const hasRenderFunction = typeof item.render === "function";
|
|
7832
|
+
const renderFunctionValue = hasRenderFunction ? (_a = item.render) == null ? void 0 : _a.call(item, editor) : null;
|
|
7833
|
+
let value = /* @__PURE__ */ jsxs31(Fragment6, { children: [
|
|
7834
|
+
/* @__PURE__ */ jsx53("div", { className: "mly-flex mly-h-6 mly-w-6 mly-shrink-0 mly-items-center mly-justify-center", children: item.icon }),
|
|
7835
|
+
/* @__PURE__ */ jsxs31("div", { className: "mly-grow", children: [
|
|
7836
|
+
/* @__PURE__ */ jsx53("p", { className: "mly-font-medium", children: item.title }),
|
|
7837
|
+
/* @__PURE__ */ jsx53("p", { className: "mly-text-xs mly-text-gray-400", children: item.description })
|
|
7838
|
+
] }),
|
|
7839
|
+
isSubCommand && /* @__PURE__ */ jsx53("span", { className: "mly-block mly-px-1 mly-text-gray-400", children: /* @__PURE__ */ jsx53(ChevronRightIcon, { className: "mly-size-3.5 mly-stroke-[2.5]" }) })
|
|
7840
|
+
] });
|
|
7841
|
+
if (renderFunctionValue !== null && renderFunctionValue !== true) {
|
|
7842
|
+
value = renderFunctionValue;
|
|
7843
|
+
}
|
|
7844
|
+
const openTimerRef = useRef10(0);
|
|
7845
|
+
const handleDelayedOpen = useCallback10(() => {
|
|
7846
|
+
window.clearTimeout(openTimerRef.current);
|
|
7847
|
+
const delay = 200;
|
|
7848
|
+
openTimerRef.current = window.setTimeout(() => {
|
|
7849
|
+
setOpen(true);
|
|
7850
|
+
openTimerRef.current = 0;
|
|
7851
|
+
}, delay);
|
|
7852
|
+
}, [setOpen]);
|
|
7853
|
+
useEffect7(() => {
|
|
7854
|
+
if (shouldOpenTooltip) {
|
|
7855
|
+
handleDelayedOpen();
|
|
7856
|
+
} else {
|
|
7857
|
+
window.clearTimeout(openTimerRef.current);
|
|
7858
|
+
openTimerRef.current = 0;
|
|
7859
|
+
setOpen(false);
|
|
7860
|
+
}
|
|
7861
|
+
}, [shouldOpenTooltip]);
|
|
7862
|
+
useEffect7(() => {
|
|
7863
|
+
return () => {
|
|
7864
|
+
if (openTimerRef.current) {
|
|
7865
|
+
window.clearTimeout(openTimerRef.current);
|
|
7866
|
+
openTimerRef.current = 0;
|
|
7867
|
+
}
|
|
7868
|
+
};
|
|
7869
|
+
}, []);
|
|
7870
|
+
return /* @__PURE__ */ jsxs31(Tooltip, { open, children: [
|
|
7871
|
+
/* @__PURE__ */ jsx53(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx53(
|
|
7872
|
+
"button",
|
|
7873
|
+
{
|
|
7874
|
+
className: cn(
|
|
7875
|
+
"mly-flex mly-w-full mly-items-center mly-gap-2 mly-rounded-md mly-px-2 mly-py-1 mly-text-left mly-text-sm mly-text-gray-900 hover:mly-bg-gray-100 hover:mly-text-gray-900",
|
|
7876
|
+
isActive ? "mly-bg-gray-100 mly-text-gray-900" : "mly-bg-transparent"
|
|
7877
|
+
),
|
|
7878
|
+
onClick: () => selectItem(groupIndex, commandIndex),
|
|
7879
|
+
onMouseEnter: () => setIsHovered(true),
|
|
7880
|
+
onMouseLeave: () => setIsHovered(false),
|
|
7881
|
+
type: "button",
|
|
7882
|
+
ref: isActive ? activeCommandRef : null,
|
|
7883
|
+
children: value
|
|
7884
|
+
}
|
|
7885
|
+
) }),
|
|
7886
|
+
/* @__PURE__ */ jsx53(
|
|
7887
|
+
TooltipContent,
|
|
7888
|
+
{
|
|
7889
|
+
side: "right",
|
|
7890
|
+
sideOffset: 10,
|
|
7891
|
+
className: "mly-w-52 mly-rounded-lg mly-border-none mly-p-1 mly-shadow",
|
|
7892
|
+
children: typeof item.preview === "function" ? item == null ? void 0 : item.preview(editor) : /* @__PURE__ */ jsxs31(Fragment6, { children: [
|
|
7893
|
+
/* @__PURE__ */ jsx53("figure", { className: "mly-relative mly-aspect-[2.5] mly-w-full mly-overflow-hidden mly-rounded-md mly-border mly-border-gray-200", children: /* @__PURE__ */ jsx53(
|
|
7894
|
+
"img",
|
|
7895
|
+
{
|
|
7896
|
+
src: item == null ? void 0 : item.preview,
|
|
7897
|
+
alt: item == null ? void 0 : item.title,
|
|
7898
|
+
className: "mly-absolute mly-inset-0 mly-h-full mly-w-full mly-object-cover"
|
|
7899
|
+
}
|
|
7900
|
+
) }),
|
|
7901
|
+
/* @__PURE__ */ jsx53("p", { className: "mly-mt-2 mly-px-0.5 mly-text-gray-500", children: item.description })
|
|
7902
|
+
] })
|
|
7903
|
+
}
|
|
7904
|
+
)
|
|
7905
|
+
] }, `${groupIndex}-${commandIndex}`);
|
|
7906
|
+
}
|
|
7907
|
+
|
|
7908
|
+
// src/editor/extensions/slash-command/slash-command-view.tsx
|
|
7909
|
+
import { jsx as jsx54, jsxs as jsxs32 } from "react/jsx-runtime";
|
|
7676
7910
|
var CommandList = forwardRef8(function CommandList2(props, ref) {
|
|
7677
|
-
const { items: groups, command, editor } = props;
|
|
7678
|
-
const [selectedGroupIndex, setSelectedGroupIndex] =
|
|
7679
|
-
const [selectedCommandIndex, setSelectedCommandIndex] =
|
|
7680
|
-
const
|
|
7911
|
+
const { items: groups, command, editor, range, query } = props;
|
|
7912
|
+
const [selectedGroupIndex, setSelectedGroupIndex] = useState11(0);
|
|
7913
|
+
const [selectedCommandIndex, setSelectedCommandIndex] = useState11(0);
|
|
7914
|
+
const prevQuery = useRef11("");
|
|
7915
|
+
const prevSelectedGroupIndex = useRef11(0);
|
|
7916
|
+
const prevSelectedCommandIndex = useRef11(0);
|
|
7917
|
+
const selectItem = useCallback11(
|
|
7681
7918
|
(groupIndex, commandIndex) => {
|
|
7682
7919
|
const item = groups[groupIndex].commands[commandIndex];
|
|
7683
7920
|
if (!item) {
|
|
@@ -7689,62 +7926,94 @@ var CommandList = forwardRef8(function CommandList2(props, ref) {
|
|
|
7689
7926
|
);
|
|
7690
7927
|
useImperativeHandle2(ref, () => ({
|
|
7691
7928
|
onKeyDown: ({ event }) => {
|
|
7692
|
-
var _a, _b;
|
|
7693
|
-
const navigationKeys = [
|
|
7929
|
+
var _a, _b, _c, _d;
|
|
7930
|
+
const navigationKeys = [
|
|
7931
|
+
"ArrowUp",
|
|
7932
|
+
"ArrowDown",
|
|
7933
|
+
"Enter",
|
|
7934
|
+
"ArrowLeft",
|
|
7935
|
+
"ArrowRight"
|
|
7936
|
+
];
|
|
7694
7937
|
if (navigationKeys.includes(event.key)) {
|
|
7695
|
-
|
|
7696
|
-
|
|
7697
|
-
|
|
7698
|
-
|
|
7699
|
-
|
|
7700
|
-
|
|
7701
|
-
|
|
7702
|
-
|
|
7703
|
-
|
|
7704
|
-
|
|
7705
|
-
|
|
7706
|
-
|
|
7707
|
-
|
|
7708
|
-
|
|
7709
|
-
|
|
7710
|
-
|
|
7711
|
-
|
|
7712
|
-
|
|
7713
|
-
|
|
7714
|
-
|
|
7715
|
-
|
|
7716
|
-
|
|
7717
|
-
|
|
7718
|
-
|
|
7719
|
-
|
|
7720
|
-
|
|
7721
|
-
|
|
7722
|
-
|
|
7723
|
-
|
|
7724
|
-
|
|
7725
|
-
|
|
7726
|
-
|
|
7727
|
-
|
|
7728
|
-
|
|
7729
|
-
|
|
7730
|
-
|
|
7731
|
-
|
|
7732
|
-
|
|
7938
|
+
let newCommandIndex = selectedCommandIndex;
|
|
7939
|
+
let newGroupIndex = selectedGroupIndex;
|
|
7940
|
+
switch (event.key) {
|
|
7941
|
+
case "ArrowLeft":
|
|
7942
|
+
event.preventDefault();
|
|
7943
|
+
const group = groups == null ? void 0 : groups[selectedGroupIndex];
|
|
7944
|
+
const isInsideSubCommand = group && "id" in group;
|
|
7945
|
+
if (!isInsideSubCommand) {
|
|
7946
|
+
return false;
|
|
7947
|
+
}
|
|
7948
|
+
editor.chain().focus().insertContentAt(range, `/${prevQuery.current}`).run();
|
|
7949
|
+
setTimeout(() => {
|
|
7950
|
+
setSelectedGroupIndex(prevSelectedGroupIndex.current);
|
|
7951
|
+
setSelectedCommandIndex(prevSelectedCommandIndex.current);
|
|
7952
|
+
}, 0);
|
|
7953
|
+
return true;
|
|
7954
|
+
case "ArrowRight":
|
|
7955
|
+
event.preventDefault();
|
|
7956
|
+
const command2 = (_b = (_a = groups == null ? void 0 : groups[selectedGroupIndex]) == null ? void 0 : _a.commands) == null ? void 0 : _b[selectedCommandIndex];
|
|
7957
|
+
const isSelectingSubCommand = command2 && "commands" in command2;
|
|
7958
|
+
if (!isSelectingSubCommand) {
|
|
7959
|
+
return false;
|
|
7960
|
+
}
|
|
7961
|
+
selectItem(selectedGroupIndex, selectedCommandIndex);
|
|
7962
|
+
prevQuery.current = query;
|
|
7963
|
+
prevSelectedGroupIndex.current = selectedGroupIndex;
|
|
7964
|
+
prevSelectedCommandIndex.current = selectedCommandIndex;
|
|
7965
|
+
return true;
|
|
7966
|
+
case "Enter":
|
|
7967
|
+
if (!groups.length) {
|
|
7968
|
+
return false;
|
|
7969
|
+
}
|
|
7970
|
+
selectItem(selectedGroupIndex, selectedCommandIndex);
|
|
7971
|
+
prevQuery.current = query;
|
|
7972
|
+
prevSelectedGroupIndex.current = selectedGroupIndex;
|
|
7973
|
+
prevSelectedCommandIndex.current = selectedCommandIndex;
|
|
7974
|
+
return true;
|
|
7975
|
+
case "ArrowUp":
|
|
7976
|
+
if (!groups.length) {
|
|
7977
|
+
return false;
|
|
7978
|
+
}
|
|
7979
|
+
newCommandIndex = selectedCommandIndex - 1;
|
|
7980
|
+
newGroupIndex = selectedGroupIndex;
|
|
7981
|
+
if (newCommandIndex < 0) {
|
|
7982
|
+
newGroupIndex = selectedGroupIndex - 1;
|
|
7983
|
+
newCommandIndex = ((_c = groups[newGroupIndex]) == null ? void 0 : _c.commands.length) - 1 || 0;
|
|
7984
|
+
}
|
|
7985
|
+
if (newGroupIndex < 0) {
|
|
7986
|
+
newGroupIndex = groups.length - 1;
|
|
7987
|
+
newCommandIndex = ((_d = groups[newGroupIndex]) == null ? void 0 : _d.commands.length) - 1 || 0;
|
|
7988
|
+
}
|
|
7989
|
+
setSelectedGroupIndex(newGroupIndex);
|
|
7990
|
+
setSelectedCommandIndex(newCommandIndex);
|
|
7991
|
+
return true;
|
|
7992
|
+
case "ArrowDown":
|
|
7993
|
+
if (!groups.length) {
|
|
7994
|
+
return false;
|
|
7995
|
+
}
|
|
7996
|
+
const commands = groups[selectedGroupIndex].commands;
|
|
7997
|
+
newCommandIndex = selectedCommandIndex + 1;
|
|
7998
|
+
newGroupIndex = selectedGroupIndex;
|
|
7999
|
+
if (commands.length - 1 < newCommandIndex) {
|
|
8000
|
+
newCommandIndex = 0;
|
|
8001
|
+
newGroupIndex = selectedGroupIndex + 1;
|
|
8002
|
+
}
|
|
8003
|
+
if (groups.length - 1 < newGroupIndex) {
|
|
8004
|
+
newGroupIndex = 0;
|
|
8005
|
+
}
|
|
8006
|
+
setSelectedGroupIndex(newGroupIndex);
|
|
8007
|
+
setSelectedCommandIndex(newCommandIndex);
|
|
8008
|
+
return true;
|
|
8009
|
+
default:
|
|
7733
8010
|
return false;
|
|
7734
|
-
}
|
|
7735
|
-
selectItem(selectedGroupIndex, selectedCommandIndex);
|
|
7736
|
-
return true;
|
|
7737
8011
|
}
|
|
7738
|
-
return false;
|
|
7739
8012
|
}
|
|
7740
8013
|
}
|
|
7741
8014
|
}));
|
|
7742
|
-
|
|
7743
|
-
|
|
7744
|
-
setSelectedCommandIndex(0);
|
|
7745
|
-
}, [groups]);
|
|
7746
|
-
const commandListContainer = useRef10(null);
|
|
7747
|
-
const activeCommandRef = useRef10(null);
|
|
8015
|
+
const commandListContainer = useRef11(null);
|
|
8016
|
+
const activeCommandRef = useRef11(null);
|
|
7748
8017
|
useLayoutEffect2(() => {
|
|
7749
8018
|
const container = commandListContainer == null ? void 0 : commandListContainer.current;
|
|
7750
8019
|
const activeCommandContainer = activeCommandRef == null ? void 0 : activeCommandRef.current;
|
|
@@ -7752,6 +8021,7 @@ var CommandList = forwardRef8(function CommandList2(props, ref) {
|
|
|
7752
8021
|
return;
|
|
7753
8022
|
}
|
|
7754
8023
|
const { offsetTop, offsetHeight } = activeCommandContainer;
|
|
8024
|
+
container.style.transition = "none";
|
|
7755
8025
|
container.scrollTop = offsetTop - offsetHeight;
|
|
7756
8026
|
}, [
|
|
7757
8027
|
selectedGroupIndex,
|
|
@@ -7759,15 +8029,26 @@ var CommandList = forwardRef8(function CommandList2(props, ref) {
|
|
|
7759
8029
|
commandListContainer,
|
|
7760
8030
|
activeCommandRef
|
|
7761
8031
|
]);
|
|
7762
|
-
|
|
7763
|
-
|
|
8032
|
+
useEffect8(() => {
|
|
8033
|
+
setSelectedGroupIndex(0);
|
|
8034
|
+
setSelectedCommandIndex(0);
|
|
8035
|
+
}, [groups]);
|
|
8036
|
+
useEffect8(() => {
|
|
8037
|
+
return () => {
|
|
8038
|
+
prevQuery.current = "";
|
|
8039
|
+
prevSelectedGroupIndex.current = 0;
|
|
8040
|
+
prevSelectedCommandIndex.current = 0;
|
|
8041
|
+
};
|
|
8042
|
+
}, []);
|
|
8043
|
+
return groups.length > 0 ? /* @__PURE__ */ jsx54(TooltipProvider, { children: /* @__PURE__ */ jsxs32("div", { className: "mly-z-50 mly-w-72 mly-overflow-hidden mly-rounded-md mly-border mly-border-gray-200 mly-bg-white mly-shadow-md mly-transition-all", children: [
|
|
8044
|
+
/* @__PURE__ */ jsx54(
|
|
7764
8045
|
"div",
|
|
7765
8046
|
{
|
|
7766
8047
|
id: "slash-command",
|
|
7767
8048
|
ref: commandListContainer,
|
|
7768
|
-
className: "mly-no-scrollbar mly-h-auto mly-max-h-[330px] mly-overflow-y-auto
|
|
7769
|
-
children: groups.map((group, groupIndex) => /* @__PURE__ */
|
|
7770
|
-
/* @__PURE__ */
|
|
8049
|
+
className: "mly-no-scrollbar mly-h-auto mly-max-h-[330px] mly-overflow-y-auto",
|
|
8050
|
+
children: groups.map((group, groupIndex) => /* @__PURE__ */ jsxs32(Fragment7, { children: [
|
|
8051
|
+
/* @__PURE__ */ jsx54(
|
|
7771
8052
|
"span",
|
|
7772
8053
|
{
|
|
7773
8054
|
className: cn(
|
|
@@ -7777,72 +8058,35 @@ var CommandList = forwardRef8(function CommandList2(props, ref) {
|
|
|
7777
8058
|
children: group.title
|
|
7778
8059
|
}
|
|
7779
8060
|
),
|
|
7780
|
-
/* @__PURE__ */
|
|
7781
|
-
|
|
7782
|
-
|
|
7783
|
-
|
|
7784
|
-
|
|
7785
|
-
|
|
7786
|
-
|
|
7787
|
-
|
|
7788
|
-
|
|
7789
|
-
|
|
7790
|
-
|
|
7791
|
-
|
|
7792
|
-
|
|
7793
|
-
|
|
7794
|
-
|
|
7795
|
-
value = renderFunctionValue;
|
|
7796
|
-
}
|
|
7797
|
-
const shouldOpenTooltip = !!(item == null ? void 0 : item.preview) && isActive;
|
|
7798
|
-
return /* @__PURE__ */ jsxs31(Tooltip, { open: shouldOpenTooltip, children: [
|
|
7799
|
-
/* @__PURE__ */ jsx53(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx53(
|
|
7800
|
-
"button",
|
|
7801
|
-
{
|
|
7802
|
-
className: cn(
|
|
7803
|
-
"mly-flex mly-w-full mly-items-center mly-gap-2 mly-rounded-md mly-px-2 mly-py-1 mly-text-left mly-text-sm mly-text-gray-900 hover:mly-bg-gray-100 hover:mly-text-gray-900",
|
|
7804
|
-
isActive ? "mly-bg-gray-100 mly-text-gray-900" : "mly-bg-transparent"
|
|
7805
|
-
),
|
|
7806
|
-
onClick: () => selectItem(groupIndex, commandIndex),
|
|
7807
|
-
type: "button",
|
|
7808
|
-
ref: isActive ? activeCommandRef : null,
|
|
7809
|
-
children: value
|
|
7810
|
-
}
|
|
7811
|
-
) }),
|
|
7812
|
-
/* @__PURE__ */ jsx53(
|
|
7813
|
-
TooltipContent,
|
|
7814
|
-
{
|
|
7815
|
-
side: "right",
|
|
7816
|
-
sideOffset: 10,
|
|
7817
|
-
className: "mly-w-52 mly-rounded-lg mly-border-none mly-p-1 mly-shadow",
|
|
7818
|
-
children: typeof item.preview === "function" ? item == null ? void 0 : item.preview(editor) : /* @__PURE__ */ jsxs31(Fragment8, { children: [
|
|
7819
|
-
/* @__PURE__ */ jsx53("figure", { className: "mly-relative mly-aspect-[2.5] mly-w-full mly-overflow-hidden mly-rounded-md mly-border mly-border-gray-200", children: /* @__PURE__ */ jsx53(
|
|
7820
|
-
"img",
|
|
7821
|
-
{
|
|
7822
|
-
src: item == null ? void 0 : item.preview,
|
|
7823
|
-
alt: item == null ? void 0 : item.title,
|
|
7824
|
-
className: "mly-absolute mly-inset-0 mly-h-full mly-w-full mly-object-cover"
|
|
7825
|
-
}
|
|
7826
|
-
) }),
|
|
7827
|
-
/* @__PURE__ */ jsx53("p", { className: "mly-mt-2 mly-px-0.5 mly-text-gray-500", children: item.description })
|
|
7828
|
-
] })
|
|
7829
|
-
}
|
|
7830
|
-
)
|
|
7831
|
-
] }, commandIndex);
|
|
8061
|
+
/* @__PURE__ */ jsx54("div", { className: "mly-space-y-0.5 mly-p-1", children: group.commands.map((item, commandIndex) => {
|
|
8062
|
+
return /* @__PURE__ */ jsx54(
|
|
8063
|
+
SlashCommandItem,
|
|
8064
|
+
{
|
|
8065
|
+
item,
|
|
8066
|
+
groupIndex,
|
|
8067
|
+
commandIndex,
|
|
8068
|
+
selectedGroupIndex,
|
|
8069
|
+
selectedCommandIndex,
|
|
8070
|
+
selectItem: () => selectItem(groupIndex, commandIndex),
|
|
8071
|
+
editor,
|
|
8072
|
+
activeCommandRef
|
|
8073
|
+
},
|
|
8074
|
+
commandIndex
|
|
8075
|
+
);
|
|
7832
8076
|
}) })
|
|
7833
8077
|
] }, groupIndex))
|
|
7834
8078
|
}
|
|
7835
8079
|
),
|
|
7836
|
-
/* @__PURE__ */
|
|
7837
|
-
/* @__PURE__ */
|
|
7838
|
-
/* @__PURE__ */
|
|
7839
|
-
/* @__PURE__ */
|
|
8080
|
+
/* @__PURE__ */ jsx54("div", { className: "mly-border-t mly-border-gray-200 mly-px-1 mly-py-3 mly-pl-4", children: /* @__PURE__ */ jsxs32("div", { className: "mly-flex mly-items-center", children: [
|
|
8081
|
+
/* @__PURE__ */ jsxs32("p", { className: "mly-text-center mly-text-xs mly-text-gray-400", children: [
|
|
8082
|
+
/* @__PURE__ */ jsx54("kbd", { className: "mly-rounded mly-border mly-border-gray-200 mly-p-1 mly-px-2 mly-font-medium", children: "\u2191" }),
|
|
8083
|
+
/* @__PURE__ */ jsx54("kbd", { className: "mly-ml-1 mly-rounded mly-border mly-border-gray-200 mly-p-1 mly-px-2 mly-font-medium", children: "\u2193" }),
|
|
7840
8084
|
" ",
|
|
7841
8085
|
"to navigate"
|
|
7842
8086
|
] }),
|
|
7843
|
-
/* @__PURE__ */
|
|
7844
|
-
/* @__PURE__ */
|
|
7845
|
-
/* @__PURE__ */
|
|
8087
|
+
/* @__PURE__ */ jsx54("span", { "aria-hidden": "true", className: "mly-select-none mly-px-1", children: "\xB7" }),
|
|
8088
|
+
/* @__PURE__ */ jsxs32("p", { className: "mly-text-center mly-text-xs mly-text-gray-400", children: [
|
|
8089
|
+
/* @__PURE__ */ jsx54("kbd", { className: "mly-rounded mly-border mly-border-gray-200 mly-p-1 mly-px-1.5 mly-font-medium", children: "Enter" }),
|
|
7846
8090
|
" ",
|
|
7847
8091
|
"to select"
|
|
7848
8092
|
] })
|
|
@@ -7941,28 +8185,41 @@ function getSlashCommandSuggestions(groups = DEFAULT_SLASH_COMMANDS) {
|
|
|
7941
8185
|
content: component.element,
|
|
7942
8186
|
showOnCreate: true,
|
|
7943
8187
|
interactive: true,
|
|
7944
|
-
trigger: "manual"
|
|
8188
|
+
trigger: "manual",
|
|
8189
|
+
placement: "top-start"
|
|
7945
8190
|
});
|
|
7946
8191
|
},
|
|
7947
8192
|
onUpdate: (props) => {
|
|
8193
|
+
var _a;
|
|
8194
|
+
const currentPopup = popup == null ? void 0 : popup[0];
|
|
8195
|
+
if (!currentPopup || ((_a = currentPopup == null ? void 0 : currentPopup.state) == null ? void 0 : _a.isDestroyed)) {
|
|
8196
|
+
return;
|
|
8197
|
+
}
|
|
7948
8198
|
component == null ? void 0 : component.updateProps(props);
|
|
7949
|
-
|
|
8199
|
+
currentPopup.setProps({
|
|
7950
8200
|
getReferenceClientRect: props.clientRect
|
|
7951
8201
|
});
|
|
7952
8202
|
},
|
|
7953
8203
|
onKeyDown: (props) => {
|
|
7954
|
-
var _a;
|
|
8204
|
+
var _a, _b;
|
|
7955
8205
|
if (props.event.key === "Escape") {
|
|
7956
|
-
popup == null ? void 0 : popup[0]
|
|
8206
|
+
const currentPopup = popup == null ? void 0 : popup[0];
|
|
8207
|
+
if (!((_a = currentPopup == null ? void 0 : currentPopup.state) == null ? void 0 : _a.isDestroyed)) {
|
|
8208
|
+
currentPopup == null ? void 0 : currentPopup.destroy();
|
|
8209
|
+
}
|
|
8210
|
+
component == null ? void 0 : component.destroy();
|
|
7957
8211
|
return true;
|
|
7958
8212
|
}
|
|
7959
|
-
return (
|
|
8213
|
+
return (_b = component == null ? void 0 : component.ref) == null ? void 0 : _b.onKeyDown(props);
|
|
7960
8214
|
},
|
|
7961
8215
|
onExit: () => {
|
|
7962
8216
|
if (!popup || !(popup == null ? void 0 : popup[0]) || !component) {
|
|
7963
8217
|
return;
|
|
7964
8218
|
}
|
|
7965
|
-
popup == null ? void 0 : popup[0]
|
|
8219
|
+
const currentPopup = popup == null ? void 0 : popup[0];
|
|
8220
|
+
if (!currentPopup.state.isDestroyed) {
|
|
8221
|
+
currentPopup.destroy();
|
|
8222
|
+
}
|
|
7966
8223
|
component == null ? void 0 : component.destroy();
|
|
7967
8224
|
}
|
|
7968
8225
|
};
|
|
@@ -7972,13 +8229,13 @@ function getSlashCommandSuggestions(groups = DEFAULT_SLASH_COMMANDS) {
|
|
|
7972
8229
|
|
|
7973
8230
|
// src/editor/nodes/variable/variable-suggestions.tsx
|
|
7974
8231
|
import { ReactRenderer as ReactRenderer2 } from "@tiptap/react";
|
|
7975
|
-
import { forwardRef as forwardRef9, useImperativeHandle as useImperativeHandle3, useRef as
|
|
8232
|
+
import { forwardRef as forwardRef9, useImperativeHandle as useImperativeHandle3, useRef as useRef12 } from "react";
|
|
7976
8233
|
import tippy3 from "tippy.js";
|
|
7977
|
-
import { jsx as
|
|
8234
|
+
import { jsx as jsx55 } from "react/jsx-runtime";
|
|
7978
8235
|
var VariableList = forwardRef9((props, ref) => {
|
|
7979
8236
|
var _a;
|
|
7980
8237
|
const { items = [], editor } = props;
|
|
7981
|
-
const popoverRef =
|
|
8238
|
+
const popoverRef = useRef12(null);
|
|
7982
8239
|
const VariableSuggestionPopoverComponent = (_a = useVariableOptions(editor)) == null ? void 0 : _a.variableSuggestionsPopover;
|
|
7983
8240
|
useImperativeHandle3(ref, () => ({
|
|
7984
8241
|
onKeyDown: ({ event }) => {
|
|
@@ -8003,7 +8260,7 @@ var VariableList = forwardRef9((props, ref) => {
|
|
|
8003
8260
|
return false;
|
|
8004
8261
|
}
|
|
8005
8262
|
}));
|
|
8006
|
-
return /* @__PURE__ */
|
|
8263
|
+
return /* @__PURE__ */ jsx55(
|
|
8007
8264
|
VariableSuggestionPopoverComponent,
|
|
8008
8265
|
{
|
|
8009
8266
|
items,
|
|
@@ -8225,7 +8482,7 @@ var useTextMenuState = (editor) => {
|
|
|
8225
8482
|
};
|
|
8226
8483
|
|
|
8227
8484
|
// src/editor/components/text-menu/text-bubble-content.tsx
|
|
8228
|
-
import { Fragment as
|
|
8485
|
+
import { Fragment as Fragment8, jsx as jsx56, jsxs as jsxs33 } from "react/jsx-runtime";
|
|
8229
8486
|
function TextBubbleContent(props) {
|
|
8230
8487
|
var _a, _b, _c, _d;
|
|
8231
8488
|
const { editor, showListMenu = true } = props;
|
|
@@ -8269,9 +8526,9 @@ function TextBubbleContent(props) {
|
|
|
8269
8526
|
tooltip: "Code"
|
|
8270
8527
|
}
|
|
8271
8528
|
];
|
|
8272
|
-
return /* @__PURE__ */
|
|
8273
|
-
items.map((item, index) => /* @__PURE__ */
|
|
8274
|
-
/* @__PURE__ */
|
|
8529
|
+
return /* @__PURE__ */ jsxs33(Fragment8, { children: [
|
|
8530
|
+
items.map((item, index) => /* @__PURE__ */ jsx56(BubbleMenuButton, __spreadValues({}, item), index)),
|
|
8531
|
+
/* @__PURE__ */ jsx56(
|
|
8275
8532
|
AlignmentSwitch,
|
|
8276
8533
|
{
|
|
8277
8534
|
alignment: state.textAlign,
|
|
@@ -8280,8 +8537,8 @@ function TextBubbleContent(props) {
|
|
|
8280
8537
|
}
|
|
8281
8538
|
}
|
|
8282
8539
|
),
|
|
8283
|
-
!state.isListActive && showListMenu && /* @__PURE__ */
|
|
8284
|
-
/* @__PURE__ */
|
|
8540
|
+
!state.isListActive && showListMenu && /* @__PURE__ */ jsxs33(Fragment8, { children: [
|
|
8541
|
+
/* @__PURE__ */ jsx56(
|
|
8285
8542
|
BubbleMenuButton,
|
|
8286
8543
|
{
|
|
8287
8544
|
icon: List2,
|
|
@@ -8291,7 +8548,7 @@ function TextBubbleContent(props) {
|
|
|
8291
8548
|
tooltip: "Bullet List"
|
|
8292
8549
|
}
|
|
8293
8550
|
),
|
|
8294
|
-
/* @__PURE__ */
|
|
8551
|
+
/* @__PURE__ */ jsx56(
|
|
8295
8552
|
BubbleMenuButton,
|
|
8296
8553
|
{
|
|
8297
8554
|
icon: ListOrdered2,
|
|
@@ -8302,13 +8559,12 @@ function TextBubbleContent(props) {
|
|
|
8302
8559
|
}
|
|
8303
8560
|
)
|
|
8304
8561
|
] }),
|
|
8305
|
-
/* @__PURE__ */
|
|
8562
|
+
/* @__PURE__ */ jsx56(
|
|
8306
8563
|
LinkInputPopover,
|
|
8307
8564
|
{
|
|
8308
8565
|
defaultValue: (_d = state == null ? void 0 : state.linkUrl) != null ? _d : "",
|
|
8309
8566
|
onValueChange: (value, isVariable) => {
|
|
8310
|
-
|
|
8311
|
-
if (!defaultValueWithoutProtocol) {
|
|
8567
|
+
if (!value) {
|
|
8312
8568
|
editor == null ? void 0 : editor.chain().focus().extendMarkRange("link").unsetLink().unsetUnderline().run();
|
|
8313
8569
|
return;
|
|
8314
8570
|
}
|
|
@@ -8319,8 +8575,8 @@ function TextBubbleContent(props) {
|
|
|
8319
8575
|
isVariable: state.isUrlVariable
|
|
8320
8576
|
}
|
|
8321
8577
|
),
|
|
8322
|
-
/* @__PURE__ */
|
|
8323
|
-
/* @__PURE__ */
|
|
8578
|
+
/* @__PURE__ */ jsx56(Divider, {}),
|
|
8579
|
+
/* @__PURE__ */ jsx56(
|
|
8324
8580
|
ColorPicker,
|
|
8325
8581
|
{
|
|
8326
8582
|
color: state.currentTextColor,
|
|
@@ -8329,16 +8585,16 @@ function TextBubbleContent(props) {
|
|
|
8329
8585
|
},
|
|
8330
8586
|
tooltip: "Text Color",
|
|
8331
8587
|
suggestedColors,
|
|
8332
|
-
children: /* @__PURE__ */
|
|
8588
|
+
children: /* @__PURE__ */ jsx56(
|
|
8333
8589
|
BaseButton,
|
|
8334
8590
|
{
|
|
8335
8591
|
variant: "ghost",
|
|
8336
8592
|
size: "sm",
|
|
8337
8593
|
type: "button",
|
|
8338
8594
|
className: "!mly-h-7 mly-w-7 mly-shrink-0 mly-p-0",
|
|
8339
|
-
children: /* @__PURE__ */
|
|
8340
|
-
/* @__PURE__ */
|
|
8341
|
-
/* @__PURE__ */
|
|
8595
|
+
children: /* @__PURE__ */ jsxs33("div", { className: "mly-flex mly-flex-col mly-items-center mly-justify-center mly-gap-[1px]", children: [
|
|
8596
|
+
/* @__PURE__ */ jsx56("span", { className: "mly-font-bolder mly-font-mono mly-text-xs mly-text-slate-700", children: "A" }),
|
|
8597
|
+
/* @__PURE__ */ jsx56(
|
|
8342
8598
|
"div",
|
|
8343
8599
|
{
|
|
8344
8600
|
className: "mly-h-[2px] mly-w-3",
|
|
@@ -8354,35 +8610,35 @@ function TextBubbleContent(props) {
|
|
|
8354
8610
|
}
|
|
8355
8611
|
|
|
8356
8612
|
// src/editor/components/text-menu/turn-into-block.tsx
|
|
8357
|
-
import { ChevronDownIcon as
|
|
8358
|
-
import { useMemo as
|
|
8359
|
-
import { jsx as
|
|
8613
|
+
import { ChevronDownIcon as ChevronDownIcon2, PilcrowIcon } from "lucide-react";
|
|
8614
|
+
import { useMemo as useMemo13 } from "react";
|
|
8615
|
+
import { jsx as jsx57, jsxs as jsxs34 } from "react/jsx-runtime";
|
|
8360
8616
|
var isOption = (option) => option.type === "option";
|
|
8361
8617
|
var isCategory = (option) => option.type === "category";
|
|
8362
8618
|
function TurnIntoBlock(props) {
|
|
8363
8619
|
const { options } = props;
|
|
8364
|
-
const activeItem =
|
|
8620
|
+
const activeItem = useMemo13(
|
|
8365
8621
|
() => options.find((option) => option.type === "option" && option.isActive()),
|
|
8366
8622
|
[options]
|
|
8367
8623
|
);
|
|
8368
8624
|
const { icon: ActiveIcon = PilcrowIcon } = activeItem || {};
|
|
8369
|
-
return /* @__PURE__ */
|
|
8370
|
-
/* @__PURE__ */
|
|
8371
|
-
/* @__PURE__ */
|
|
8625
|
+
return /* @__PURE__ */ jsxs34(Popover, { children: [
|
|
8626
|
+
/* @__PURE__ */ jsxs34(Tooltip, { children: [
|
|
8627
|
+
/* @__PURE__ */ jsx57(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsxs34(
|
|
8372
8628
|
PopoverTrigger,
|
|
8373
8629
|
{
|
|
8374
8630
|
className: cn(
|
|
8375
8631
|
"mly-flex mly-aspect-square mly-h-7 mly-items-center mly-justify-center mly-gap-1 mly-rounded-md mly-px-1.5 mly-text-sm data-[state=open]:mly-bg-soft-gray hover:mly-bg-soft-gray focus-visible:mly-relative focus-visible:mly-z-10 focus-visible:mly-outline-none focus-visible:mly-ring-2 focus-visible:mly-ring-gray-400 focus-visible:mly-ring-offset-2"
|
|
8376
8632
|
),
|
|
8377
8633
|
children: [
|
|
8378
|
-
/* @__PURE__ */
|
|
8379
|
-
/* @__PURE__ */
|
|
8634
|
+
/* @__PURE__ */ jsx57(ActiveIcon, { className: "mly-h-3 mly-w-3 mly-shrink-0 mly-stroke-[2.5]" }),
|
|
8635
|
+
/* @__PURE__ */ jsx57(ChevronDownIcon2, { className: "mly-h-3 mly-w-3 mly-shrink-0 mly-stroke-[2.5]" })
|
|
8380
8636
|
]
|
|
8381
8637
|
}
|
|
8382
8638
|
) }),
|
|
8383
|
-
/* @__PURE__ */
|
|
8639
|
+
/* @__PURE__ */ jsx57(TooltipContent, { sideOffset: 8, children: "Turn into" })
|
|
8384
8640
|
] }),
|
|
8385
|
-
/* @__PURE__ */
|
|
8641
|
+
/* @__PURE__ */ jsx57(
|
|
8386
8642
|
PopoverContent,
|
|
8387
8643
|
{
|
|
8388
8644
|
align: "start",
|
|
@@ -8391,21 +8647,21 @@ function TurnIntoBlock(props) {
|
|
|
8391
8647
|
className: "mly-flex mly-w-[160px] mly-flex-col mly-rounded-md mly-p-1",
|
|
8392
8648
|
children: options.map((option, index) => {
|
|
8393
8649
|
if (isOption(option)) {
|
|
8394
|
-
return /* @__PURE__ */
|
|
8650
|
+
return /* @__PURE__ */ jsxs34(
|
|
8395
8651
|
BaseButton,
|
|
8396
8652
|
{
|
|
8397
8653
|
onClick: option.onClick,
|
|
8398
8654
|
variant: "ghost",
|
|
8399
8655
|
className: "mly-h-auto mly-justify-start mly-gap-2 !mly-rounded mly-px-2 mly-py-1 mly-text-sm mly-font-normal mly-text-midnight-gray",
|
|
8400
8656
|
children: [
|
|
8401
|
-
/* @__PURE__ */
|
|
8657
|
+
/* @__PURE__ */ jsx57(option.icon, { className: "mly-size-[15px] mly-shrink-0" }),
|
|
8402
8658
|
option.label
|
|
8403
8659
|
]
|
|
8404
8660
|
},
|
|
8405
8661
|
option.id
|
|
8406
8662
|
);
|
|
8407
8663
|
} else if (isCategory(option)) {
|
|
8408
|
-
return /* @__PURE__ */
|
|
8664
|
+
return /* @__PURE__ */ jsx57(
|
|
8409
8665
|
"label",
|
|
8410
8666
|
{
|
|
8411
8667
|
className: cn(
|
|
@@ -8518,7 +8774,7 @@ function useTurnIntoBlockOptions(editor) {
|
|
|
8518
8774
|
}
|
|
8519
8775
|
|
|
8520
8776
|
// src/editor/components/text-menu/text-bubble-menu.tsx
|
|
8521
|
-
import { jsx as
|
|
8777
|
+
import { jsx as jsx58, jsxs as jsxs35 } from "react/jsx-runtime";
|
|
8522
8778
|
function TextBubbleMenu(props) {
|
|
8523
8779
|
const { editor, appendTo } = props;
|
|
8524
8780
|
if (!editor) {
|
|
@@ -8569,14 +8825,14 @@ function TextBubbleMenu(props) {
|
|
|
8569
8825
|
}
|
|
8570
8826
|
});
|
|
8571
8827
|
const turnIntoBlockOptions = useTurnIntoBlockOptions(editor);
|
|
8572
|
-
return /* @__PURE__ */
|
|
8828
|
+
return /* @__PURE__ */ jsx58(
|
|
8573
8829
|
BubbleMenu8,
|
|
8574
8830
|
__spreadProps(__spreadValues({}, bubbleMenuProps), {
|
|
8575
8831
|
className: "mly-flex mly-gap-0.5 mly-rounded-lg mly-border mly-border-gray-200 mly-bg-white mly-p-0.5 mly-shadow-md",
|
|
8576
|
-
children: /* @__PURE__ */
|
|
8577
|
-
/* @__PURE__ */
|
|
8578
|
-
/* @__PURE__ */
|
|
8579
|
-
/* @__PURE__ */
|
|
8832
|
+
children: /* @__PURE__ */ jsxs35(TooltipProvider, { children: [
|
|
8833
|
+
/* @__PURE__ */ jsx58(TurnIntoBlock, { options: turnIntoBlockOptions }),
|
|
8834
|
+
/* @__PURE__ */ jsx58(Divider, { className: "mly-mx-0" }),
|
|
8835
|
+
/* @__PURE__ */ jsx58(TextBubbleContent, { editor })
|
|
8580
8836
|
] })
|
|
8581
8837
|
})
|
|
8582
8838
|
);
|
|
@@ -8585,7 +8841,7 @@ function TextBubbleMenu(props) {
|
|
|
8585
8841
|
// src/editor/components/variable-menu/variable-bubble-menu.tsx
|
|
8586
8842
|
import { BubbleMenu as BubbleMenu9 } from "@tiptap/react";
|
|
8587
8843
|
import { sticky as sticky7 } from "tippy.js";
|
|
8588
|
-
import { jsx as
|
|
8844
|
+
import { jsx as jsx59 } from "react/jsx-runtime";
|
|
8589
8845
|
function VariableBubbleMenu(props) {
|
|
8590
8846
|
const { editor, appendTo } = props;
|
|
8591
8847
|
if (!editor) {
|
|
@@ -8608,11 +8864,11 @@ function VariableBubbleMenu(props) {
|
|
|
8608
8864
|
placement: "top-start"
|
|
8609
8865
|
}
|
|
8610
8866
|
});
|
|
8611
|
-
return /* @__PURE__ */
|
|
8867
|
+
return /* @__PURE__ */ jsx59(
|
|
8612
8868
|
BubbleMenu9,
|
|
8613
8869
|
__spreadProps(__spreadValues({}, bubbleMenuProps), {
|
|
8614
8870
|
className: "mly-flex mly-gap-0.5 mly-rounded-lg mly-border mly-border-slate-200 mly-bg-white mly-p-0.5 mly-shadow-md",
|
|
8615
|
-
children: /* @__PURE__ */
|
|
8871
|
+
children: /* @__PURE__ */ jsx59(TooltipProvider, { children: /* @__PURE__ */ jsx59(TextBubbleContent, { showListMenu: false, editor }) })
|
|
8616
8872
|
})
|
|
8617
8873
|
);
|
|
8618
8874
|
}
|
|
@@ -8666,7 +8922,7 @@ function replaceDeprecatedNode(json) {
|
|
|
8666
8922
|
}
|
|
8667
8923
|
|
|
8668
8924
|
// src/editor/index.tsx
|
|
8669
|
-
import { jsx as
|
|
8925
|
+
import { jsx as jsx60, jsxs as jsxs36 } from "react/jsx-runtime";
|
|
8670
8926
|
function Editor13(props) {
|
|
8671
8927
|
const {
|
|
8672
8928
|
config: {
|
|
@@ -8687,7 +8943,7 @@ function Editor13(props) {
|
|
|
8687
8943
|
editable = true,
|
|
8688
8944
|
placeholderUrl = DEFAULT_PLACEHOLDER_URL
|
|
8689
8945
|
} = props;
|
|
8690
|
-
const formattedContent =
|
|
8946
|
+
const formattedContent = useMemo14(() => {
|
|
8691
8947
|
if (contentJson) {
|
|
8692
8948
|
const json = (contentJson == null ? void 0 : contentJson.type) === "doc" ? contentJson : {
|
|
8693
8949
|
type: "doc",
|
|
@@ -8708,7 +8964,7 @@ function Editor13(props) {
|
|
|
8708
8964
|
};
|
|
8709
8965
|
}
|
|
8710
8966
|
}, [contentHtml, contentJson, replaceDeprecatedNode]);
|
|
8711
|
-
const menuContainerRef =
|
|
8967
|
+
const menuContainerRef = useRef13(null);
|
|
8712
8968
|
const editor = useEditor({
|
|
8713
8969
|
editorProps: {
|
|
8714
8970
|
attributes: {
|
|
@@ -8734,7 +8990,7 @@ function Editor13(props) {
|
|
|
8734
8990
|
if (!editor) {
|
|
8735
8991
|
return null;
|
|
8736
8992
|
}
|
|
8737
|
-
return /* @__PURE__ */
|
|
8993
|
+
return /* @__PURE__ */ jsx60(MailyProvider, { placeholderUrl, children: /* @__PURE__ */ jsxs36(
|
|
8738
8994
|
"div",
|
|
8739
8995
|
{
|
|
8740
8996
|
className: cn(
|
|
@@ -8744,8 +9000,8 @@ function Editor13(props) {
|
|
|
8744
9000
|
),
|
|
8745
9001
|
ref: menuContainerRef,
|
|
8746
9002
|
children: [
|
|
8747
|
-
hasMenuBar && /* @__PURE__ */
|
|
8748
|
-
/* @__PURE__ */
|
|
9003
|
+
hasMenuBar && /* @__PURE__ */ jsx60(EditorMenuBar, { config: props.config, editor }),
|
|
9004
|
+
/* @__PURE__ */ jsxs36(
|
|
8749
9005
|
"div",
|
|
8750
9006
|
{
|
|
8751
9007
|
className: cn(
|
|
@@ -8753,17 +9009,17 @@ function Editor13(props) {
|
|
|
8753
9009
|
bodyClassName
|
|
8754
9010
|
),
|
|
8755
9011
|
children: [
|
|
8756
|
-
/* @__PURE__ */
|
|
8757
|
-
/* @__PURE__ */
|
|
8758
|
-
/* @__PURE__ */
|
|
8759
|
-
/* @__PURE__ */
|
|
8760
|
-
/* @__PURE__ */
|
|
8761
|
-
/* @__PURE__ */
|
|
8762
|
-
/* @__PURE__ */
|
|
8763
|
-
/* @__PURE__ */
|
|
8764
|
-
/* @__PURE__ */
|
|
8765
|
-
/* @__PURE__ */
|
|
8766
|
-
/* @__PURE__ */
|
|
9012
|
+
/* @__PURE__ */ jsx60(TextBubbleMenu, { editor, appendTo: menuContainerRef }),
|
|
9013
|
+
/* @__PURE__ */ jsx60(ImageBubbleMenu, { editor, appendTo: menuContainerRef }),
|
|
9014
|
+
/* @__PURE__ */ jsx60(SpacerBubbleMenu, { editor, appendTo: menuContainerRef }),
|
|
9015
|
+
/* @__PURE__ */ jsx60(EditorContent, { editor }),
|
|
9016
|
+
/* @__PURE__ */ jsx60(SectionBubbleMenu, { editor, appendTo: menuContainerRef }),
|
|
9017
|
+
/* @__PURE__ */ jsx60(ColumnsBubbleMenu, { editor, appendTo: menuContainerRef }),
|
|
9018
|
+
/* @__PURE__ */ jsx60(ContentMenu, { editor }),
|
|
9019
|
+
/* @__PURE__ */ jsx60(VariableBubbleMenu, { editor, appendTo: menuContainerRef }),
|
|
9020
|
+
/* @__PURE__ */ jsx60(RepeatBubbleMenu, { editor, appendTo: menuContainerRef }),
|
|
9021
|
+
/* @__PURE__ */ jsx60(HTMLBubbleMenu, { editor, appendTo: menuContainerRef }),
|
|
9022
|
+
/* @__PURE__ */ jsx60(InlineImageBubbleMenu, { editor, appendTo: menuContainerRef })
|
|
8767
9023
|
]
|
|
8768
9024
|
}
|
|
8769
9025
|
)
|