@maily-to/core 0.2.1 → 0.2.3
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} +637 -304
- package/dist/extensions/index.cjs.map +1 -0
- package/dist/extensions/{index.d.mts → index.d.cts} +32 -1
- package/dist/extensions/index.d.ts +32 -1
- package/dist/extensions/index.mjs +616 -282
- package/dist/extensions/index.mjs.map +1 -1
- package/dist/{index.js → index.cjs} +649 -425
- package/dist/index.cjs.map +1 -0
- package/dist/index.css +2351 -0
- package/dist/index.css.map +1 -0
- package/dist/index.mjs +600 -376
- package/dist/index.mjs.map +1 -1
- package/package.json +8 -6
- package/readme.md +2 -0
- 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/{index.d.mts → index.d.cts} +0 -0
|
@@ -116,6 +116,7 @@ __export(extensions_exports, {
|
|
|
116
116
|
DEFAULT_VARIABLE_SUGGESTION_POPOVER: () => DEFAULT_VARIABLE_SUGGESTION_POPOVER,
|
|
117
117
|
DEFAULT_VARIABLE_TRIGGER_CHAR: () => DEFAULT_VARIABLE_TRIGGER_CHAR,
|
|
118
118
|
Footer: () => Footer,
|
|
119
|
+
HTMLCodeBlockExtension: () => HTMLCodeBlockExtension,
|
|
119
120
|
HorizontalRule: () => HorizontalRule,
|
|
120
121
|
ImageExtension: () => ImageExtension,
|
|
121
122
|
ImageUploadExtension: () => ImageUploadExtension,
|
|
@@ -143,7 +144,7 @@ __export(extensions_exports, {
|
|
|
143
144
|
module.exports = __toCommonJS(extensions_exports);
|
|
144
145
|
|
|
145
146
|
// src/editor/extensions/color.ts
|
|
146
|
-
var import_extension_color = __toESM(require("@tiptap/extension-color"));
|
|
147
|
+
var import_extension_color = __toESM(require("@tiptap/extension-color"), 1);
|
|
147
148
|
var Color = import_extension_color.default.extend({
|
|
148
149
|
addStorage() {
|
|
149
150
|
return {
|
|
@@ -319,16 +320,16 @@ function useImageUploadOptions(editor) {
|
|
|
319
320
|
|
|
320
321
|
// src/editor/extensions/maily-kit.tsx
|
|
321
322
|
var import_core14 = require("@tiptap/core");
|
|
322
|
-
var import_starter_kit = __toESM(require("@tiptap/starter-kit"));
|
|
323
|
-
var import_extension_list_item = __toESM(require("@tiptap/extension-list-item"));
|
|
324
|
-
var import_extension_paragraph2 = __toESM(require("@tiptap/extension-paragraph"));
|
|
325
|
-
var import_extension_text_align = __toESM(require("@tiptap/extension-text-align"));
|
|
326
|
-
var import_extension_text_style = __toESM(require("@tiptap/extension-text-style"));
|
|
327
|
-
var import_extension_heading2 = __toESM(require("@tiptap/extension-heading"));
|
|
328
|
-
var import_extension_underline = __toESM(require("@tiptap/extension-underline"));
|
|
329
|
-
var import_extension_document = __toESM(require("@tiptap/extension-document"));
|
|
330
|
-
var import_extension_focus = __toESM(require("@tiptap/extension-focus"));
|
|
331
|
-
var import_extension_dropcursor = __toESM(require("@tiptap/extension-dropcursor"));
|
|
323
|
+
var import_starter_kit = __toESM(require("@tiptap/starter-kit"), 1);
|
|
324
|
+
var import_extension_list_item = __toESM(require("@tiptap/extension-list-item"), 1);
|
|
325
|
+
var import_extension_paragraph2 = __toESM(require("@tiptap/extension-paragraph"), 1);
|
|
326
|
+
var import_extension_text_align = __toESM(require("@tiptap/extension-text-align"), 1);
|
|
327
|
+
var import_extension_text_style = __toESM(require("@tiptap/extension-text-style"), 1);
|
|
328
|
+
var import_extension_heading2 = __toESM(require("@tiptap/extension-heading"), 1);
|
|
329
|
+
var import_extension_underline = __toESM(require("@tiptap/extension-underline"), 1);
|
|
330
|
+
var import_extension_document = __toESM(require("@tiptap/extension-document"), 1);
|
|
331
|
+
var import_extension_focus = __toESM(require("@tiptap/extension-focus"), 1);
|
|
332
|
+
var import_extension_dropcursor = __toESM(require("@tiptap/extension-dropcursor"), 1);
|
|
332
333
|
|
|
333
334
|
// src/editor/nodes/footer.ts
|
|
334
335
|
var import_core3 = require("@tiptap/core");
|
|
@@ -792,7 +793,7 @@ var import_react3 = require("@tiptap/react");
|
|
|
792
793
|
var import_react2 = require("@tiptap/react");
|
|
793
794
|
|
|
794
795
|
// src/editor/components/input.tsx
|
|
795
|
-
var React = __toESM(require("react"));
|
|
796
|
+
var React = __toESM(require("react"), 1);
|
|
796
797
|
|
|
797
798
|
// src/editor/utils/classname.ts
|
|
798
799
|
var import_clsx = require("clsx");
|
|
@@ -833,8 +834,8 @@ var Input = React.forwardRef(
|
|
|
833
834
|
Input.displayName = "Input";
|
|
834
835
|
|
|
835
836
|
// src/editor/components/popover.tsx
|
|
836
|
-
var React2 = __toESM(require("react"));
|
|
837
|
-
var PopoverPrimitive = __toESM(require("@radix-ui/react-popover"));
|
|
837
|
+
var React2 = __toESM(require("react"), 1);
|
|
838
|
+
var PopoverPrimitive = __toESM(require("@radix-ui/react-popover"), 1);
|
|
838
839
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
839
840
|
var Popover = PopoverPrimitive.Root;
|
|
840
841
|
var PopoverTrigger = PopoverPrimitive.Trigger;
|
|
@@ -857,7 +858,7 @@ var PopoverContent = React2.forwardRef((_a, ref) => {
|
|
|
857
858
|
PopoverContent.displayName = PopoverPrimitive.Content.displayName;
|
|
858
859
|
|
|
859
860
|
// src/editor/components/textarea.tsx
|
|
860
|
-
var React3 = __toESM(require("react"));
|
|
861
|
+
var React3 = __toESM(require("react"), 1);
|
|
861
862
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
862
863
|
var Textarea = React3.forwardRef(
|
|
863
864
|
(_a, ref) => {
|
|
@@ -1365,7 +1366,7 @@ var import_react20 = require("@tiptap/react");
|
|
|
1365
1366
|
var import_lucide_react = require("lucide-react");
|
|
1366
1367
|
|
|
1367
1368
|
// src/editor/components/base-button.tsx
|
|
1368
|
-
var React4 = __toESM(require("react"));
|
|
1369
|
+
var React4 = __toESM(require("react"), 1);
|
|
1369
1370
|
var import_react_slot = require("@radix-ui/react-slot");
|
|
1370
1371
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
1371
1372
|
var BaseButton = React4.forwardRef(
|
|
@@ -1410,8 +1411,8 @@ var BaseButton = React4.forwardRef(
|
|
|
1410
1411
|
BaseButton.displayName = "BaseButton";
|
|
1411
1412
|
|
|
1412
1413
|
// src/editor/components/ui/tooltip.tsx
|
|
1413
|
-
var React5 = __toESM(require("react"));
|
|
1414
|
-
var TooltipPrimitive = __toESM(require("@radix-ui/react-tooltip"));
|
|
1414
|
+
var React5 = __toESM(require("react"), 1);
|
|
1415
|
+
var TooltipPrimitive = __toESM(require("@radix-ui/react-tooltip"), 1);
|
|
1415
1416
|
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
1416
1417
|
var TooltipProvider = TooltipPrimitive.Provider;
|
|
1417
1418
|
var Tooltip = TooltipPrimitive.Root;
|
|
@@ -2048,7 +2049,7 @@ var inlineImage = {
|
|
|
2048
2049
|
icon: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_lucide_react6.ImageIcon, { className: "mly-h-4 mly-w-4" }),
|
|
2049
2050
|
command: ({ editor, range }) => {
|
|
2050
2051
|
editor.chain().focus().deleteRange(range).setInlineImage({
|
|
2051
|
-
src: ""
|
|
2052
|
+
src: "https://maily.to/brand/logo.png"
|
|
2052
2053
|
}).command((props) => {
|
|
2053
2054
|
const { tr, state, view, editor: editor2 } = props;
|
|
2054
2055
|
const { from } = range;
|
|
@@ -2876,7 +2877,7 @@ var DEFAULT_SLASH_COMMANDS = [
|
|
|
2876
2877
|
|
|
2877
2878
|
// src/editor/provider.tsx
|
|
2878
2879
|
var import_jsx_runtime25 = require("react/jsx-runtime");
|
|
2879
|
-
var DEFAULT_PLACEHOLDER_URL = "maily.to/";
|
|
2880
|
+
var DEFAULT_PLACEHOLDER_URL = "https://maily.to/";
|
|
2880
2881
|
var MailyContext = (0, import_react9.createContext)({
|
|
2881
2882
|
placeholderUrl: DEFAULT_PLACEHOLDER_URL,
|
|
2882
2883
|
blocks: DEFAULT_SLASH_COMMANDS
|
|
@@ -2896,7 +2897,7 @@ var import_react15 = require("react");
|
|
|
2896
2897
|
var import_core11 = require("@tiptap/core");
|
|
2897
2898
|
var import_state4 = require("@tiptap/pm/state");
|
|
2898
2899
|
var import_react13 = require("@tiptap/react");
|
|
2899
|
-
var import_suggestion = __toESM(require("@tiptap/suggestion"));
|
|
2900
|
+
var import_suggestion = __toESM(require("@tiptap/suggestion"), 1);
|
|
2900
2901
|
|
|
2901
2902
|
// src/editor/nodes/variable/variable-suggestions-popover.tsx
|
|
2902
2903
|
var import_lucide_react12 = require("lucide-react");
|
|
@@ -3293,9 +3294,8 @@ var VariableExtension = import_core11.Node.create({
|
|
|
3293
3294
|
|
|
3294
3295
|
// src/editor/components/ui/link-input-popover.tsx
|
|
3295
3296
|
var import_jsx_runtime28 = require("react/jsx-runtime");
|
|
3296
|
-
var LINK_PROTOCOL_REGEX = /https?:\/\//;
|
|
3297
3297
|
function LinkInputPopover(props) {
|
|
3298
|
-
var _a, _b
|
|
3298
|
+
var _a, _b;
|
|
3299
3299
|
const {
|
|
3300
3300
|
defaultValue = "",
|
|
3301
3301
|
onValueChange,
|
|
@@ -3304,22 +3304,16 @@ function LinkInputPopover(props) {
|
|
|
3304
3304
|
editor,
|
|
3305
3305
|
isVariable
|
|
3306
3306
|
} = props;
|
|
3307
|
-
const defaultProtocol = (_a = defaultValue.match(LINK_PROTOCOL_REGEX)) == null ? void 0 : _a[0];
|
|
3308
|
-
const defaultUrlWithoutProtocol = defaultValue.replace(
|
|
3309
|
-
LINK_PROTOCOL_REGEX,
|
|
3310
|
-
""
|
|
3311
|
-
);
|
|
3312
3307
|
const [isOpen, setIsOpen] = (0, import_react14.useState)(false);
|
|
3313
|
-
const [protocol, setProtocol] = (0, import_react14.useState)(defaultProtocol || "https://");
|
|
3314
3308
|
const [isEditing, setIsEditing] = (0, import_react14.useState)(!isVariable);
|
|
3315
3309
|
const linkInputRef = (0, import_react14.useRef)(null);
|
|
3316
3310
|
const { placeholderUrl = DEFAULT_PLACEHOLDER_URL } = useMailyContext();
|
|
3317
3311
|
const options = useVariableOptions(editor);
|
|
3318
3312
|
const renderVariable = options == null ? void 0 : options.renderVariable;
|
|
3319
3313
|
const variables = options == null ? void 0 : options.variables;
|
|
3320
|
-
const variableTriggerCharacter = (
|
|
3314
|
+
const variableTriggerCharacter = (_b = (_a = options == null ? void 0 : options.suggestion) == null ? void 0 : _a.char) != null ? _b : DEFAULT_VARIABLE_TRIGGER_CHAR;
|
|
3321
3315
|
const autoCompleteOptions = (0, import_react15.useMemo)(() => {
|
|
3322
|
-
const withoutTrigger =
|
|
3316
|
+
const withoutTrigger = defaultValue.replace(
|
|
3323
3317
|
new RegExp(variableTriggerCharacter, "g"),
|
|
3324
3318
|
""
|
|
3325
3319
|
);
|
|
@@ -3328,7 +3322,7 @@ function LinkInputPopover(props) {
|
|
|
3328
3322
|
from: "bubble-variable",
|
|
3329
3323
|
editor
|
|
3330
3324
|
}).map((variable) => variable.name);
|
|
3331
|
-
}, [variables, variableTriggerCharacter,
|
|
3325
|
+
}, [variables, variableTriggerCharacter, defaultValue, editor]);
|
|
3332
3326
|
const popoverButton = /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
3333
3327
|
BaseButton,
|
|
3334
3328
|
{
|
|
@@ -3336,130 +3330,105 @@ function LinkInputPopover(props) {
|
|
|
3336
3330
|
size: "sm",
|
|
3337
3331
|
type: "button",
|
|
3338
3332
|
className: "mly-size-7",
|
|
3339
|
-
"data-state": !!
|
|
3333
|
+
"data-state": !!defaultValue,
|
|
3340
3334
|
children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(Icon, { className: "mly-h-3 mly-w-3 mly-shrink-0 mly-stroke-[2.5] mly-text-midnight-gray" })
|
|
3341
3335
|
}
|
|
3342
3336
|
) });
|
|
3343
|
-
|
|
3344
|
-
|
|
3345
|
-
|
|
3346
|
-
|
|
3347
|
-
|
|
3348
|
-
|
|
3349
|
-
|
|
3350
|
-
|
|
3351
|
-
|
|
3352
|
-
|
|
3353
|
-
|
|
3354
|
-
|
|
3355
|
-
|
|
3356
|
-
|
|
3357
|
-
|
|
3358
|
-
|
|
3359
|
-
|
|
3360
|
-
|
|
3361
|
-
|
|
3337
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(
|
|
3338
|
+
Popover,
|
|
3339
|
+
{
|
|
3340
|
+
open: isOpen,
|
|
3341
|
+
onOpenChange: (open) => {
|
|
3342
|
+
setIsOpen(open);
|
|
3343
|
+
if (open) {
|
|
3344
|
+
setTimeout(() => {
|
|
3345
|
+
var _a2;
|
|
3346
|
+
(_a2 = linkInputRef.current) == null ? void 0 : _a2.focus();
|
|
3347
|
+
}, 0);
|
|
3348
|
+
}
|
|
3349
|
+
},
|
|
3350
|
+
children: [
|
|
3351
|
+
tooltip ? /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(Tooltip, { children: [
|
|
3352
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)(TooltipTrigger, { asChild: true, children: popoverButton }),
|
|
3353
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)(TooltipContent, { sideOffset: 8, children: tooltip })
|
|
3354
|
+
] }) : popoverButton,
|
|
3355
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
3356
|
+
PopoverContent,
|
|
3362
3357
|
{
|
|
3363
|
-
|
|
3364
|
-
|
|
3365
|
-
|
|
3366
|
-
|
|
3367
|
-
|
|
3368
|
-
|
|
3369
|
-
|
|
3370
|
-
|
|
3371
|
-
|
|
3372
|
-
|
|
3373
|
-
|
|
3374
|
-
|
|
3375
|
-
|
|
3376
|
-
|
|
3377
|
-
|
|
3378
|
-
|
|
3379
|
-
|
|
3380
|
-
|
|
3381
|
-
|
|
3382
|
-
|
|
3383
|
-
},
|
|
3384
|
-
children: renderVariable({
|
|
3385
|
-
variable: {
|
|
3386
|
-
name: defaultUrlWithoutProtocol,
|
|
3387
|
-
valid: true
|
|
3388
|
-
},
|
|
3389
|
-
fallback: "",
|
|
3390
|
-
from: "bubble-variable",
|
|
3391
|
-
editor
|
|
3392
|
-
})
|
|
3393
|
-
}
|
|
3394
|
-
) }),
|
|
3395
|
-
isEditing && /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(import_jsx_runtime28.Fragment, { children: [
|
|
3396
|
-
/* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: "mly-relative", children: [
|
|
3397
|
-
/* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(
|
|
3398
|
-
"select",
|
|
3358
|
+
align: "end",
|
|
3359
|
+
side: "top",
|
|
3360
|
+
className: "mly-w-max mly-rounded-none mly-border-none mly-bg-transparent !mly-p-0 mly-shadow-none",
|
|
3361
|
+
sideOffset: 8,
|
|
3362
|
+
onCloseAutoFocus: (e) => e.preventDefault(),
|
|
3363
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
3364
|
+
"form",
|
|
3365
|
+
{
|
|
3366
|
+
onSubmit: (e) => {
|
|
3367
|
+
e.preventDefault();
|
|
3368
|
+
const input = linkInputRef.current;
|
|
3369
|
+
if (!input) {
|
|
3370
|
+
return;
|
|
3371
|
+
}
|
|
3372
|
+
onValueChange == null ? void 0 : onValueChange(input.value);
|
|
3373
|
+
setIsOpen(false);
|
|
3374
|
+
},
|
|
3375
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: "mly-isolate mly-flex mly-rounded-lg", children: [
|
|
3376
|
+
!isEditing && /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("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__ */ (0, import_jsx_runtime28.jsx)(
|
|
3377
|
+
"button",
|
|
3399
3378
|
{
|
|
3400
|
-
|
|
3401
|
-
|
|
3402
|
-
|
|
3403
|
-
|
|
3404
|
-
|
|
3405
|
-
|
|
3406
|
-
setProtocol(protocol2);
|
|
3407
|
-
const newValue = normalizeProtocol(
|
|
3408
|
-
((_a2 = linkInputRef.current) == null ? void 0 : _a2.value) || "",
|
|
3409
|
-
protocol2
|
|
3410
|
-
);
|
|
3411
|
-
onValueChange == null ? void 0 : onValueChange(newValue);
|
|
3379
|
+
onClick: () => {
|
|
3380
|
+
setIsEditing(true);
|
|
3381
|
+
setTimeout(() => {
|
|
3382
|
+
var _a2;
|
|
3383
|
+
(_a2 = linkInputRef.current) == null ? void 0 : _a2.focus();
|
|
3384
|
+
}, 0);
|
|
3412
3385
|
},
|
|
3413
|
-
children:
|
|
3414
|
-
|
|
3415
|
-
|
|
3416
|
-
|
|
3417
|
-
|
|
3418
|
-
|
|
3419
|
-
|
|
3420
|
-
|
|
3421
|
-
|
|
3422
|
-
size: 16,
|
|
3423
|
-
strokeWidth: 2,
|
|
3424
|
-
"aria-hidden": "true",
|
|
3425
|
-
role: "img"
|
|
3386
|
+
children: renderVariable({
|
|
3387
|
+
variable: {
|
|
3388
|
+
name: defaultValue,
|
|
3389
|
+
valid: true
|
|
3390
|
+
},
|
|
3391
|
+
fallback: "",
|
|
3392
|
+
from: "bubble-variable",
|
|
3393
|
+
editor
|
|
3394
|
+
})
|
|
3426
3395
|
}
|
|
3427
|
-
) })
|
|
3428
|
-
|
|
3429
|
-
|
|
3430
|
-
|
|
3431
|
-
|
|
3432
|
-
|
|
3433
|
-
|
|
3434
|
-
|
|
3435
|
-
|
|
3436
|
-
|
|
3437
|
-
|
|
3438
|
-
|
|
3439
|
-
|
|
3440
|
-
|
|
3441
|
-
|
|
3442
|
-
|
|
3443
|
-
|
|
3444
|
-
|
|
3445
|
-
|
|
3446
|
-
|
|
3447
|
-
|
|
3448
|
-
|
|
3449
|
-
|
|
3396
|
+
) }),
|
|
3397
|
+
isEditing && /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: "mly-relative", children: [
|
|
3398
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: "mly-absolute mly-inset-y-0 mly-left-1.5 mly-z-10 mly-flex mly-items-center", children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_lucide_react14.LinkIcon, { className: "mly-h-3 mly-w-3 mly-stroke-[2.5] mly-text-midnight-gray" }) }),
|
|
3399
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
3400
|
+
InputAutocomplete,
|
|
3401
|
+
{
|
|
3402
|
+
editor,
|
|
3403
|
+
value: defaultValue,
|
|
3404
|
+
onValueChange: (value) => {
|
|
3405
|
+
onValueChange == null ? void 0 : onValueChange(value);
|
|
3406
|
+
},
|
|
3407
|
+
autoCompleteOptions,
|
|
3408
|
+
ref: linkInputRef,
|
|
3409
|
+
placeholder: placeholderUrl,
|
|
3410
|
+
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",
|
|
3411
|
+
triggerChar: variableTriggerCharacter,
|
|
3412
|
+
onSelectOption: (value) => {
|
|
3413
|
+
var _a2;
|
|
3414
|
+
const isVariable2 = (_a2 = autoCompleteOptions.includes(value)) != null ? _a2 : false;
|
|
3415
|
+
if (isVariable2) {
|
|
3416
|
+
setIsEditing(false);
|
|
3417
|
+
}
|
|
3418
|
+
onValueChange == null ? void 0 : onValueChange(value, isVariable2);
|
|
3419
|
+
setIsOpen(false);
|
|
3420
|
+
}
|
|
3450
3421
|
}
|
|
3451
|
-
|
|
3452
|
-
|
|
3453
|
-
|
|
3454
|
-
|
|
3455
|
-
|
|
3456
|
-
] })
|
|
3457
|
-
] })
|
|
3422
|
+
)
|
|
3423
|
+
] })
|
|
3424
|
+
] })
|
|
3425
|
+
}
|
|
3426
|
+
)
|
|
3458
3427
|
}
|
|
3459
3428
|
)
|
|
3460
|
-
|
|
3461
|
-
|
|
3462
|
-
|
|
3429
|
+
]
|
|
3430
|
+
}
|
|
3431
|
+
);
|
|
3463
3432
|
}
|
|
3464
3433
|
|
|
3465
3434
|
// src/editor/components/ui/select.tsx
|
|
@@ -4138,7 +4107,7 @@ var ButtonExtension = import_core12.Node.create({
|
|
|
4138
4107
|
});
|
|
4139
4108
|
|
|
4140
4109
|
// src/editor/nodes/logo/logo.ts
|
|
4141
|
-
var import_extension_image = __toESM(require("@tiptap/extension-image"));
|
|
4110
|
+
var import_extension_image = __toESM(require("@tiptap/extension-image"), 1);
|
|
4142
4111
|
var import_react27 = require("@tiptap/react");
|
|
4143
4112
|
|
|
4144
4113
|
// src/editor/nodes/logo/logo-view.tsx
|
|
@@ -4166,10 +4135,21 @@ var useEvent = (handler) => {
|
|
|
4166
4135
|
}, []);
|
|
4167
4136
|
};
|
|
4168
4137
|
|
|
4138
|
+
// src/editor/utils/aspect-ratio.ts
|
|
4139
|
+
function getAspectRatio(width, height) {
|
|
4140
|
+
return width / height;
|
|
4141
|
+
}
|
|
4142
|
+
function getNewHeight(width, aspectRatio) {
|
|
4143
|
+
if (width <= 0 || aspectRatio <= 0) {
|
|
4144
|
+
return 0;
|
|
4145
|
+
}
|
|
4146
|
+
return width / aspectRatio;
|
|
4147
|
+
}
|
|
4148
|
+
|
|
4169
4149
|
// src/editor/nodes/image/image-view.tsx
|
|
4170
4150
|
var import_jsx_runtime32 = require("react/jsx-runtime");
|
|
4171
4151
|
var MIN_WIDTH = 20;
|
|
4172
|
-
var
|
|
4152
|
+
var IMAGE_MAX_WIDTH = 600;
|
|
4173
4153
|
function ImageView(props) {
|
|
4174
4154
|
const { node, updateAttributes: updateAttributes2, selected, editor } = props;
|
|
4175
4155
|
const [status, setStatus] = (0, import_react22.useState)("idle");
|
|
@@ -4187,7 +4167,10 @@ function ImageView(props) {
|
|
|
4187
4167
|
if (!imgRef.current || !imageParent || !selected) {
|
|
4188
4168
|
return;
|
|
4189
4169
|
}
|
|
4190
|
-
const imageParentWidth = Math.max(
|
|
4170
|
+
const imageParentWidth = Math.max(
|
|
4171
|
+
imageParent.offsetWidth,
|
|
4172
|
+
IMAGE_MAX_WIDTH
|
|
4173
|
+
);
|
|
4191
4174
|
event.preventDefault();
|
|
4192
4175
|
const direction = event.currentTarget.dataset.direction || "--";
|
|
4193
4176
|
const initialXPosition = event.clientX;
|
|
@@ -4199,7 +4182,8 @@ function ImageView(props) {
|
|
|
4199
4182
|
const removeListeners = () => {
|
|
4200
4183
|
window.removeEventListener("mousemove", mouseMoveHandler);
|
|
4201
4184
|
window.removeEventListener("mouseup", removeListeners);
|
|
4202
|
-
|
|
4185
|
+
const aspectRatio = getAspectRatio(newWidth, newHeight);
|
|
4186
|
+
updateAttributes2({ width: newWidth, height: newHeight, aspectRatio });
|
|
4203
4187
|
setResizingStyle(void 0);
|
|
4204
4188
|
};
|
|
4205
4189
|
const mouseMoveHandler = (event2) => {
|
|
@@ -4245,17 +4229,29 @@ function ImageView(props) {
|
|
|
4245
4229
|
},
|
|
4246
4230
|
[handleMouseDown, isPlaceholderImage]
|
|
4247
4231
|
);
|
|
4248
|
-
let {
|
|
4232
|
+
let {
|
|
4233
|
+
alignment = "center",
|
|
4234
|
+
width,
|
|
4235
|
+
height,
|
|
4236
|
+
src,
|
|
4237
|
+
borderRadius
|
|
4238
|
+
} = node.attrs || {};
|
|
4249
4239
|
const _a = node.attrs || {}, {
|
|
4250
4240
|
externalLink,
|
|
4251
4241
|
isExternalLinkVariable,
|
|
4252
4242
|
isSrcVariable,
|
|
4253
|
-
showIfKey
|
|
4243
|
+
showIfKey,
|
|
4244
|
+
aspectRatio: defaultAspectRatio,
|
|
4245
|
+
borderRadius: _,
|
|
4246
|
+
lockAspectRatio
|
|
4254
4247
|
} = _a, attrs = __objRest(_a, [
|
|
4255
4248
|
"externalLink",
|
|
4256
4249
|
"isExternalLinkVariable",
|
|
4257
4250
|
"isSrcVariable",
|
|
4258
|
-
"showIfKey"
|
|
4251
|
+
"showIfKey",
|
|
4252
|
+
"aspectRatio",
|
|
4253
|
+
"borderRadius",
|
|
4254
|
+
"lockAspectRatio"
|
|
4259
4255
|
]);
|
|
4260
4256
|
const hasImageSrc = !!attrs.src;
|
|
4261
4257
|
const isDroppable = !!onImageUpload && editor.isEditable && !hasImageSrc && !isSrcVariable && status === "idle";
|
|
@@ -4302,14 +4298,15 @@ function ImageView(props) {
|
|
|
4302
4298
|
return;
|
|
4303
4299
|
}
|
|
4304
4300
|
const wrapperWidth = wrapper.offsetWidth;
|
|
4305
|
-
const aspectRatio = naturalWidth
|
|
4301
|
+
const aspectRatio = getAspectRatio(naturalWidth, naturalHeight);
|
|
4306
4302
|
const calculatedHeight = Math.min(
|
|
4307
|
-
wrapperWidth
|
|
4303
|
+
getNewHeight(wrapperWidth, aspectRatio),
|
|
4308
4304
|
naturalHeight
|
|
4309
4305
|
);
|
|
4310
4306
|
updateAttributes2({
|
|
4311
4307
|
width: Math.min(wrapperWidth, naturalWidth),
|
|
4312
|
-
height: Math.min(calculatedHeight, naturalHeight)
|
|
4308
|
+
height: Math.min(calculatedHeight, naturalHeight),
|
|
4309
|
+
aspectRatio
|
|
4313
4310
|
});
|
|
4314
4311
|
};
|
|
4315
4312
|
img.onerror = () => {
|
|
@@ -4379,7 +4376,8 @@ function ImageView(props) {
|
|
|
4379
4376
|
position: "relative",
|
|
4380
4377
|
// Weird! Basically tiptap/prose wraps this in a span and the line height causes an annoying buffer.
|
|
4381
4378
|
lineHeight: "0px",
|
|
4382
|
-
display: "block"
|
|
4379
|
+
display: "block",
|
|
4380
|
+
maxWidth: "100%"
|
|
4383
4381
|
}), {
|
|
4384
4382
|
center: { marginLeft: "auto", marginRight: "auto" },
|
|
4385
4383
|
left: { marginRight: "auto" },
|
|
@@ -4421,7 +4419,8 @@ function ImageView(props) {
|
|
|
4421
4419
|
ref: imgRef,
|
|
4422
4420
|
style: __spreadProps(__spreadValues({}, resizingStyle), {
|
|
4423
4421
|
cursor: "default",
|
|
4424
|
-
marginBottom: 0
|
|
4422
|
+
marginBottom: 0,
|
|
4423
|
+
borderRadius
|
|
4425
4424
|
}),
|
|
4426
4425
|
draggable: editor.isEditable,
|
|
4427
4426
|
className: cn(
|
|
@@ -4773,8 +4772,9 @@ var LogoExtension = import_extension_image.default.extend({
|
|
|
4773
4772
|
});
|
|
4774
4773
|
|
|
4775
4774
|
// src/editor/nodes/image/image.ts
|
|
4776
|
-
var import_extension_image2 = __toESM(require("@tiptap/extension-image"));
|
|
4775
|
+
var import_extension_image2 = __toESM(require("@tiptap/extension-image"), 1);
|
|
4777
4776
|
var import_react28 = require("@tiptap/react");
|
|
4777
|
+
var DEFAULT_IMAGE_BORDER_RADIUS = 0;
|
|
4778
4778
|
var ImageExtension = import_extension_image2.default.extend({
|
|
4779
4779
|
addAttributes() {
|
|
4780
4780
|
var _a;
|
|
@@ -4838,6 +4838,17 @@ var ImageExtension = import_extension_image2.default.extend({
|
|
|
4838
4838
|
};
|
|
4839
4839
|
}
|
|
4840
4840
|
},
|
|
4841
|
+
borderRadius: {
|
|
4842
|
+
default: DEFAULT_IMAGE_BORDER_RADIUS,
|
|
4843
|
+
parseHTML: (element) => {
|
|
4844
|
+
return Number(element.getAttribute("data-border-radius"));
|
|
4845
|
+
},
|
|
4846
|
+
renderHTML: (attributes) => {
|
|
4847
|
+
return {
|
|
4848
|
+
"data-border-radius": attributes.borderRadius
|
|
4849
|
+
};
|
|
4850
|
+
}
|
|
4851
|
+
},
|
|
4841
4852
|
// Later we will remove this attribute
|
|
4842
4853
|
// and use the `src` attribute instead when implement
|
|
4843
4854
|
// the URL variable feature
|
|
@@ -4855,6 +4866,34 @@ var ImageExtension = import_extension_image2.default.extend({
|
|
|
4855
4866
|
};
|
|
4856
4867
|
}
|
|
4857
4868
|
},
|
|
4869
|
+
aspectRatio: {
|
|
4870
|
+
default: null,
|
|
4871
|
+
parseHTML: (element) => {
|
|
4872
|
+
return element.getAttribute("data-aspect-ratio") || null;
|
|
4873
|
+
},
|
|
4874
|
+
renderHTML: (attributes) => {
|
|
4875
|
+
if (!(attributes == null ? void 0 : attributes.aspectRatio)) {
|
|
4876
|
+
return {};
|
|
4877
|
+
}
|
|
4878
|
+
return {
|
|
4879
|
+
"data-aspect-ratio": attributes == null ? void 0 : attributes.aspectRatio
|
|
4880
|
+
};
|
|
4881
|
+
}
|
|
4882
|
+
},
|
|
4883
|
+
lockAspectRatio: {
|
|
4884
|
+
default: true,
|
|
4885
|
+
parseHTML: (element) => {
|
|
4886
|
+
return element.getAttribute("data-lock-aspect-ratio") === "true";
|
|
4887
|
+
},
|
|
4888
|
+
renderHTML: (attributes) => {
|
|
4889
|
+
if (!attributes.lockAspectRatio) {
|
|
4890
|
+
return {};
|
|
4891
|
+
}
|
|
4892
|
+
return {
|
|
4893
|
+
"data-lock-aspect-ratio": "true"
|
|
4894
|
+
};
|
|
4895
|
+
}
|
|
4896
|
+
},
|
|
4858
4897
|
showIfKey: {
|
|
4859
4898
|
default: DEFAULT_SECTION_SHOW_IF_KEY,
|
|
4860
4899
|
parseHTML: (element) => {
|
|
@@ -4879,7 +4918,7 @@ var ImageExtension = import_extension_image2.default.extend({
|
|
|
4879
4918
|
});
|
|
4880
4919
|
|
|
4881
4920
|
// src/editor/nodes/link.ts
|
|
4882
|
-
var import_extension_link = __toESM(require("@tiptap/extension-link"));
|
|
4921
|
+
var import_extension_link = __toESM(require("@tiptap/extension-link"), 1);
|
|
4883
4922
|
var LinkExtension = import_extension_link.default.extend({
|
|
4884
4923
|
addAttributes() {
|
|
4885
4924
|
var _a;
|
|
@@ -4900,7 +4939,7 @@ var LinkExtension = import_extension_link.default.extend({
|
|
|
4900
4939
|
});
|
|
4901
4940
|
|
|
4902
4941
|
// src/editor/nodes/heading/heading.ts
|
|
4903
|
-
var import_extension_heading = __toESM(require("@tiptap/extension-heading"));
|
|
4942
|
+
var import_extension_heading = __toESM(require("@tiptap/extension-heading"), 1);
|
|
4904
4943
|
var HeadingExtension = import_extension_heading.default.extend({
|
|
4905
4944
|
addAttributes() {
|
|
4906
4945
|
var _a;
|
|
@@ -4924,7 +4963,7 @@ var HeadingExtension = import_extension_heading.default.extend({
|
|
|
4924
4963
|
});
|
|
4925
4964
|
|
|
4926
4965
|
// src/editor/nodes/paragraph/paragraph.ts
|
|
4927
|
-
var import_extension_paragraph = __toESM(require("@tiptap/extension-paragraph"));
|
|
4966
|
+
var import_extension_paragraph = __toESM(require("@tiptap/extension-paragraph"), 1);
|
|
4928
4967
|
var ParagraphExtension = import_extension_paragraph.default.extend({
|
|
4929
4968
|
addAttributes() {
|
|
4930
4969
|
var _a;
|
|
@@ -5177,7 +5216,7 @@ var MailyKit = import_core14.Extension.create({
|
|
|
5177
5216
|
});
|
|
5178
5217
|
|
|
5179
5218
|
// src/editor/extensions/placeholder.ts
|
|
5180
|
-
var import_extension_placeholder = __toESM(require("@tiptap/extension-placeholder"));
|
|
5219
|
+
var import_extension_placeholder = __toESM(require("@tiptap/extension-placeholder"), 1);
|
|
5181
5220
|
var PlaceholderExtension = import_extension_placeholder.default.configure({
|
|
5182
5221
|
placeholder: ({ node }) => {
|
|
5183
5222
|
if (node.type.name === "heading") {
|
|
@@ -5196,7 +5235,7 @@ var PlaceholderExtension = import_extension_placeholder.default.configure({
|
|
|
5196
5235
|
|
|
5197
5236
|
// src/editor/extensions/slash-command/slash-command.ts
|
|
5198
5237
|
var import_core15 = require("@tiptap/core");
|
|
5199
|
-
var import_suggestion2 = __toESM(require("@tiptap/suggestion"));
|
|
5238
|
+
var import_suggestion2 = __toESM(require("@tiptap/suggestion"), 1);
|
|
5200
5239
|
var SlashCommandExtension = import_core15.Extension.create({
|
|
5201
5240
|
name: "slash-command",
|
|
5202
5241
|
addOptions() {
|
|
@@ -5219,16 +5258,118 @@ var SlashCommandExtension = import_core15.Extension.create({
|
|
|
5219
5258
|
});
|
|
5220
5259
|
|
|
5221
5260
|
// src/editor/extensions/slash-command/slash-command-view.tsx
|
|
5222
|
-
var
|
|
5223
|
-
var
|
|
5224
|
-
var import_tippy = __toESM(require("tippy.js"));
|
|
5261
|
+
var import_react32 = require("@tiptap/react");
|
|
5262
|
+
var import_react33 = require("react");
|
|
5263
|
+
var import_tippy = __toESM(require("tippy.js"), 1);
|
|
5264
|
+
|
|
5265
|
+
// src/editor/extensions/slash-command/slash-command-item.tsx
|
|
5225
5266
|
var import_lucide_react18 = require("lucide-react");
|
|
5267
|
+
var import_react31 = require("react");
|
|
5226
5268
|
var import_jsx_runtime35 = require("react/jsx-runtime");
|
|
5227
|
-
|
|
5228
|
-
|
|
5229
|
-
const
|
|
5230
|
-
|
|
5231
|
-
|
|
5269
|
+
function SlashCommandItem(props) {
|
|
5270
|
+
var _a;
|
|
5271
|
+
const {
|
|
5272
|
+
item,
|
|
5273
|
+
groupIndex,
|
|
5274
|
+
commandIndex,
|
|
5275
|
+
selectedGroupIndex,
|
|
5276
|
+
selectedCommandIndex,
|
|
5277
|
+
editor,
|
|
5278
|
+
activeCommandRef,
|
|
5279
|
+
selectItem
|
|
5280
|
+
} = props;
|
|
5281
|
+
const [open, setOpen] = (0, import_react31.useState)(false);
|
|
5282
|
+
const [isHovered, setIsHovered] = (0, import_react31.useState)(false);
|
|
5283
|
+
const isActive = groupIndex === selectedGroupIndex && commandIndex === selectedCommandIndex;
|
|
5284
|
+
const isSubCommand = item && "commands" in item;
|
|
5285
|
+
const shouldOpenTooltip = !!(item == null ? void 0 : item.preview) && (isActive || isHovered);
|
|
5286
|
+
const hasRenderFunction = typeof item.render === "function";
|
|
5287
|
+
const renderFunctionValue = hasRenderFunction ? (_a = item.render) == null ? void 0 : _a.call(item, editor) : null;
|
|
5288
|
+
let value = /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(import_jsx_runtime35.Fragment, { children: [
|
|
5289
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: "mly-flex mly-h-6 mly-w-6 mly-shrink-0 mly-items-center mly-justify-center", children: item.icon }),
|
|
5290
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: "mly-grow", children: [
|
|
5291
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)("p", { className: "mly-font-medium", children: item.title }),
|
|
5292
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)("p", { className: "mly-text-xs mly-text-gray-400", children: item.description })
|
|
5293
|
+
] }),
|
|
5294
|
+
isSubCommand && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("span", { className: "mly-block mly-px-1 mly-text-gray-400", children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_lucide_react18.ChevronRightIcon, { className: "mly-size-3.5 mly-stroke-[2.5]" }) })
|
|
5295
|
+
] });
|
|
5296
|
+
if (renderFunctionValue !== null && renderFunctionValue !== true) {
|
|
5297
|
+
value = renderFunctionValue;
|
|
5298
|
+
}
|
|
5299
|
+
const openTimerRef = (0, import_react31.useRef)(0);
|
|
5300
|
+
const handleDelayedOpen = (0, import_react31.useCallback)(() => {
|
|
5301
|
+
window.clearTimeout(openTimerRef.current);
|
|
5302
|
+
const delay = 200;
|
|
5303
|
+
openTimerRef.current = window.setTimeout(() => {
|
|
5304
|
+
setOpen(true);
|
|
5305
|
+
openTimerRef.current = 0;
|
|
5306
|
+
}, delay);
|
|
5307
|
+
}, [setOpen]);
|
|
5308
|
+
(0, import_react31.useEffect)(() => {
|
|
5309
|
+
if (shouldOpenTooltip) {
|
|
5310
|
+
handleDelayedOpen();
|
|
5311
|
+
} else {
|
|
5312
|
+
window.clearTimeout(openTimerRef.current);
|
|
5313
|
+
openTimerRef.current = 0;
|
|
5314
|
+
setOpen(false);
|
|
5315
|
+
}
|
|
5316
|
+
}, [shouldOpenTooltip]);
|
|
5317
|
+
(0, import_react31.useEffect)(() => {
|
|
5318
|
+
return () => {
|
|
5319
|
+
if (openTimerRef.current) {
|
|
5320
|
+
window.clearTimeout(openTimerRef.current);
|
|
5321
|
+
openTimerRef.current = 0;
|
|
5322
|
+
}
|
|
5323
|
+
};
|
|
5324
|
+
}, []);
|
|
5325
|
+
return /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(Tooltip, { open, children: [
|
|
5326
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
|
5327
|
+
"button",
|
|
5328
|
+
{
|
|
5329
|
+
className: cn(
|
|
5330
|
+
"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",
|
|
5331
|
+
isActive ? "mly-bg-gray-100 mly-text-gray-900" : "mly-bg-transparent"
|
|
5332
|
+
),
|
|
5333
|
+
onClick: () => selectItem(groupIndex, commandIndex),
|
|
5334
|
+
onMouseEnter: () => setIsHovered(true),
|
|
5335
|
+
onMouseLeave: () => setIsHovered(false),
|
|
5336
|
+
type: "button",
|
|
5337
|
+
ref: isActive ? activeCommandRef : null,
|
|
5338
|
+
children: value
|
|
5339
|
+
}
|
|
5340
|
+
) }),
|
|
5341
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
|
5342
|
+
TooltipContent,
|
|
5343
|
+
{
|
|
5344
|
+
side: "right",
|
|
5345
|
+
sideOffset: 10,
|
|
5346
|
+
className: "mly-w-52 mly-rounded-lg mly-border-none mly-p-1 mly-shadow",
|
|
5347
|
+
children: typeof item.preview === "function" ? item == null ? void 0 : item.preview(editor) : /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(import_jsx_runtime35.Fragment, { children: [
|
|
5348
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)("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__ */ (0, import_jsx_runtime35.jsx)(
|
|
5349
|
+
"img",
|
|
5350
|
+
{
|
|
5351
|
+
src: item == null ? void 0 : item.preview,
|
|
5352
|
+
alt: item == null ? void 0 : item.title,
|
|
5353
|
+
className: "mly-absolute mly-inset-0 mly-h-full mly-w-full mly-object-cover"
|
|
5354
|
+
}
|
|
5355
|
+
) }),
|
|
5356
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)("p", { className: "mly-mt-2 mly-px-0.5 mly-text-gray-500", children: item.description })
|
|
5357
|
+
] })
|
|
5358
|
+
}
|
|
5359
|
+
)
|
|
5360
|
+
] }, `${groupIndex}-${commandIndex}`);
|
|
5361
|
+
}
|
|
5362
|
+
|
|
5363
|
+
// src/editor/extensions/slash-command/slash-command-view.tsx
|
|
5364
|
+
var import_jsx_runtime36 = require("react/jsx-runtime");
|
|
5365
|
+
var CommandList = (0, import_react33.forwardRef)(function CommandList2(props, ref) {
|
|
5366
|
+
const { items: groups, command, editor, range, query } = props;
|
|
5367
|
+
const [selectedGroupIndex, setSelectedGroupIndex] = (0, import_react33.useState)(0);
|
|
5368
|
+
const [selectedCommandIndex, setSelectedCommandIndex] = (0, import_react33.useState)(0);
|
|
5369
|
+
const prevQuery = (0, import_react33.useRef)("");
|
|
5370
|
+
const prevSelectedGroupIndex = (0, import_react33.useRef)(0);
|
|
5371
|
+
const prevSelectedCommandIndex = (0, import_react33.useRef)(0);
|
|
5372
|
+
const selectItem = (0, import_react33.useCallback)(
|
|
5232
5373
|
(groupIndex, commandIndex) => {
|
|
5233
5374
|
const item = groups[groupIndex].commands[commandIndex];
|
|
5234
5375
|
if (!item) {
|
|
@@ -5238,71 +5379,104 @@ var CommandList = (0, import_react32.forwardRef)(function CommandList2(props, re
|
|
|
5238
5379
|
},
|
|
5239
5380
|
[command]
|
|
5240
5381
|
);
|
|
5241
|
-
(0,
|
|
5382
|
+
(0, import_react33.useImperativeHandle)(ref, () => ({
|
|
5242
5383
|
onKeyDown: ({ event }) => {
|
|
5243
|
-
var _a, _b;
|
|
5244
|
-
const navigationKeys = [
|
|
5384
|
+
var _a, _b, _c, _d;
|
|
5385
|
+
const navigationKeys = [
|
|
5386
|
+
"ArrowUp",
|
|
5387
|
+
"ArrowDown",
|
|
5388
|
+
"Enter",
|
|
5389
|
+
"ArrowLeft",
|
|
5390
|
+
"ArrowRight"
|
|
5391
|
+
];
|
|
5245
5392
|
if (navigationKeys.includes(event.key)) {
|
|
5246
|
-
|
|
5247
|
-
|
|
5248
|
-
|
|
5249
|
-
|
|
5250
|
-
|
|
5251
|
-
|
|
5252
|
-
|
|
5253
|
-
|
|
5254
|
-
|
|
5255
|
-
|
|
5256
|
-
|
|
5257
|
-
|
|
5258
|
-
|
|
5259
|
-
|
|
5260
|
-
|
|
5261
|
-
|
|
5262
|
-
|
|
5263
|
-
|
|
5264
|
-
|
|
5265
|
-
|
|
5266
|
-
|
|
5267
|
-
|
|
5268
|
-
|
|
5269
|
-
|
|
5270
|
-
|
|
5271
|
-
|
|
5272
|
-
|
|
5273
|
-
|
|
5274
|
-
|
|
5275
|
-
|
|
5276
|
-
|
|
5277
|
-
|
|
5278
|
-
|
|
5279
|
-
|
|
5280
|
-
|
|
5281
|
-
|
|
5282
|
-
|
|
5283
|
-
|
|
5393
|
+
let newCommandIndex = selectedCommandIndex;
|
|
5394
|
+
let newGroupIndex = selectedGroupIndex;
|
|
5395
|
+
switch (event.key) {
|
|
5396
|
+
case "ArrowLeft":
|
|
5397
|
+
event.preventDefault();
|
|
5398
|
+
const group = groups == null ? void 0 : groups[selectedGroupIndex];
|
|
5399
|
+
const isInsideSubCommand = group && "id" in group;
|
|
5400
|
+
if (!isInsideSubCommand) {
|
|
5401
|
+
return false;
|
|
5402
|
+
}
|
|
5403
|
+
editor.chain().focus().insertContentAt(range, `/${prevQuery.current}`).run();
|
|
5404
|
+
setTimeout(() => {
|
|
5405
|
+
setSelectedGroupIndex(prevSelectedGroupIndex.current);
|
|
5406
|
+
setSelectedCommandIndex(prevSelectedCommandIndex.current);
|
|
5407
|
+
}, 0);
|
|
5408
|
+
return true;
|
|
5409
|
+
case "ArrowRight":
|
|
5410
|
+
event.preventDefault();
|
|
5411
|
+
const command2 = (_b = (_a = groups == null ? void 0 : groups[selectedGroupIndex]) == null ? void 0 : _a.commands) == null ? void 0 : _b[selectedCommandIndex];
|
|
5412
|
+
const isSelectingSubCommand = command2 && "commands" in command2;
|
|
5413
|
+
if (!isSelectingSubCommand) {
|
|
5414
|
+
return false;
|
|
5415
|
+
}
|
|
5416
|
+
selectItem(selectedGroupIndex, selectedCommandIndex);
|
|
5417
|
+
prevQuery.current = query;
|
|
5418
|
+
prevSelectedGroupIndex.current = selectedGroupIndex;
|
|
5419
|
+
prevSelectedCommandIndex.current = selectedCommandIndex;
|
|
5420
|
+
return true;
|
|
5421
|
+
case "Enter":
|
|
5422
|
+
if (!groups.length) {
|
|
5423
|
+
return false;
|
|
5424
|
+
}
|
|
5425
|
+
selectItem(selectedGroupIndex, selectedCommandIndex);
|
|
5426
|
+
prevQuery.current = query;
|
|
5427
|
+
prevSelectedGroupIndex.current = selectedGroupIndex;
|
|
5428
|
+
prevSelectedCommandIndex.current = selectedCommandIndex;
|
|
5429
|
+
return true;
|
|
5430
|
+
case "ArrowUp":
|
|
5431
|
+
if (!groups.length) {
|
|
5432
|
+
return false;
|
|
5433
|
+
}
|
|
5434
|
+
newCommandIndex = selectedCommandIndex - 1;
|
|
5435
|
+
newGroupIndex = selectedGroupIndex;
|
|
5436
|
+
if (newCommandIndex < 0) {
|
|
5437
|
+
newGroupIndex = selectedGroupIndex - 1;
|
|
5438
|
+
newCommandIndex = ((_c = groups[newGroupIndex]) == null ? void 0 : _c.commands.length) - 1 || 0;
|
|
5439
|
+
}
|
|
5440
|
+
if (newGroupIndex < 0) {
|
|
5441
|
+
newGroupIndex = groups.length - 1;
|
|
5442
|
+
newCommandIndex = ((_d = groups[newGroupIndex]) == null ? void 0 : _d.commands.length) - 1 || 0;
|
|
5443
|
+
}
|
|
5444
|
+
setSelectedGroupIndex(newGroupIndex);
|
|
5445
|
+
setSelectedCommandIndex(newCommandIndex);
|
|
5446
|
+
return true;
|
|
5447
|
+
case "ArrowDown":
|
|
5448
|
+
if (!groups.length) {
|
|
5449
|
+
return false;
|
|
5450
|
+
}
|
|
5451
|
+
const commands = groups[selectedGroupIndex].commands;
|
|
5452
|
+
newCommandIndex = selectedCommandIndex + 1;
|
|
5453
|
+
newGroupIndex = selectedGroupIndex;
|
|
5454
|
+
if (commands.length - 1 < newCommandIndex) {
|
|
5455
|
+
newCommandIndex = 0;
|
|
5456
|
+
newGroupIndex = selectedGroupIndex + 1;
|
|
5457
|
+
}
|
|
5458
|
+
if (groups.length - 1 < newGroupIndex) {
|
|
5459
|
+
newGroupIndex = 0;
|
|
5460
|
+
}
|
|
5461
|
+
setSelectedGroupIndex(newGroupIndex);
|
|
5462
|
+
setSelectedCommandIndex(newCommandIndex);
|
|
5463
|
+
return true;
|
|
5464
|
+
default:
|
|
5284
5465
|
return false;
|
|
5285
|
-
}
|
|
5286
|
-
selectItem(selectedGroupIndex, selectedCommandIndex);
|
|
5287
|
-
return true;
|
|
5288
5466
|
}
|
|
5289
|
-
return false;
|
|
5290
5467
|
}
|
|
5291
5468
|
}
|
|
5292
5469
|
}));
|
|
5293
|
-
(0,
|
|
5294
|
-
|
|
5295
|
-
|
|
5296
|
-
}, [groups]);
|
|
5297
|
-
const commandListContainer = (0, import_react32.useRef)(null);
|
|
5298
|
-
const activeCommandRef = (0, import_react32.useRef)(null);
|
|
5299
|
-
(0, import_react32.useLayoutEffect)(() => {
|
|
5470
|
+
const commandListContainer = (0, import_react33.useRef)(null);
|
|
5471
|
+
const activeCommandRef = (0, import_react33.useRef)(null);
|
|
5472
|
+
(0, import_react33.useLayoutEffect)(() => {
|
|
5300
5473
|
const container = commandListContainer == null ? void 0 : commandListContainer.current;
|
|
5301
5474
|
const activeCommandContainer = activeCommandRef == null ? void 0 : activeCommandRef.current;
|
|
5302
5475
|
if (!container || !activeCommandContainer) {
|
|
5303
5476
|
return;
|
|
5304
5477
|
}
|
|
5305
5478
|
const { offsetTop, offsetHeight } = activeCommandContainer;
|
|
5479
|
+
container.style.transition = "none";
|
|
5306
5480
|
container.scrollTop = offsetTop - offsetHeight;
|
|
5307
5481
|
}, [
|
|
5308
5482
|
selectedGroupIndex,
|
|
@@ -5310,15 +5484,26 @@ var CommandList = (0, import_react32.forwardRef)(function CommandList2(props, re
|
|
|
5310
5484
|
commandListContainer,
|
|
5311
5485
|
activeCommandRef
|
|
5312
5486
|
]);
|
|
5313
|
-
|
|
5314
|
-
|
|
5487
|
+
(0, import_react33.useEffect)(() => {
|
|
5488
|
+
setSelectedGroupIndex(0);
|
|
5489
|
+
setSelectedCommandIndex(0);
|
|
5490
|
+
}, [groups]);
|
|
5491
|
+
(0, import_react33.useEffect)(() => {
|
|
5492
|
+
return () => {
|
|
5493
|
+
prevQuery.current = "";
|
|
5494
|
+
prevSelectedGroupIndex.current = 0;
|
|
5495
|
+
prevSelectedCommandIndex.current = 0;
|
|
5496
|
+
};
|
|
5497
|
+
}, []);
|
|
5498
|
+
return groups.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(TooltipProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("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: [
|
|
5499
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
5315
5500
|
"div",
|
|
5316
5501
|
{
|
|
5317
5502
|
id: "slash-command",
|
|
5318
5503
|
ref: commandListContainer,
|
|
5319
|
-
className: "mly-no-scrollbar mly-h-auto mly-max-h-[330px] mly-overflow-y-auto
|
|
5320
|
-
children: groups.map((group, groupIndex) => /* @__PURE__ */ (0,
|
|
5321
|
-
/* @__PURE__ */ (0,
|
|
5504
|
+
className: "mly-no-scrollbar mly-h-auto mly-max-h-[330px] mly-overflow-y-auto",
|
|
5505
|
+
children: groups.map((group, groupIndex) => /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(import_react33.Fragment, { children: [
|
|
5506
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
5322
5507
|
"span",
|
|
5323
5508
|
{
|
|
5324
5509
|
className: cn(
|
|
@@ -5328,72 +5513,35 @@ var CommandList = (0, import_react32.forwardRef)(function CommandList2(props, re
|
|
|
5328
5513
|
children: group.title
|
|
5329
5514
|
}
|
|
5330
5515
|
),
|
|
5331
|
-
/* @__PURE__ */ (0,
|
|
5332
|
-
|
|
5333
|
-
|
|
5334
|
-
|
|
5335
|
-
|
|
5336
|
-
|
|
5337
|
-
|
|
5338
|
-
|
|
5339
|
-
|
|
5340
|
-
|
|
5341
|
-
|
|
5342
|
-
|
|
5343
|
-
|
|
5344
|
-
|
|
5345
|
-
|
|
5346
|
-
value = renderFunctionValue;
|
|
5347
|
-
}
|
|
5348
|
-
const shouldOpenTooltip = !!(item == null ? void 0 : item.preview) && isActive;
|
|
5349
|
-
return /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(Tooltip, { open: shouldOpenTooltip, children: [
|
|
5350
|
-
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
|
5351
|
-
"button",
|
|
5352
|
-
{
|
|
5353
|
-
className: cn(
|
|
5354
|
-
"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",
|
|
5355
|
-
isActive ? "mly-bg-gray-100 mly-text-gray-900" : "mly-bg-transparent"
|
|
5356
|
-
),
|
|
5357
|
-
onClick: () => selectItem(groupIndex, commandIndex),
|
|
5358
|
-
type: "button",
|
|
5359
|
-
ref: isActive ? activeCommandRef : null,
|
|
5360
|
-
children: value
|
|
5361
|
-
}
|
|
5362
|
-
) }),
|
|
5363
|
-
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
|
5364
|
-
TooltipContent,
|
|
5365
|
-
{
|
|
5366
|
-
side: "right",
|
|
5367
|
-
sideOffset: 10,
|
|
5368
|
-
className: "mly-w-52 mly-rounded-lg mly-border-none mly-p-1 mly-shadow",
|
|
5369
|
-
children: typeof item.preview === "function" ? item == null ? void 0 : item.preview(editor) : /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(import_jsx_runtime35.Fragment, { children: [
|
|
5370
|
-
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)("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__ */ (0, import_jsx_runtime35.jsx)(
|
|
5371
|
-
"img",
|
|
5372
|
-
{
|
|
5373
|
-
src: item == null ? void 0 : item.preview,
|
|
5374
|
-
alt: item == null ? void 0 : item.title,
|
|
5375
|
-
className: "mly-absolute mly-inset-0 mly-h-full mly-w-full mly-object-cover"
|
|
5376
|
-
}
|
|
5377
|
-
) }),
|
|
5378
|
-
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)("p", { className: "mly-mt-2 mly-px-0.5 mly-text-gray-500", children: item.description })
|
|
5379
|
-
] })
|
|
5380
|
-
}
|
|
5381
|
-
)
|
|
5382
|
-
] }, commandIndex);
|
|
5516
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: "mly-space-y-0.5 mly-p-1", children: group.commands.map((item, commandIndex) => {
|
|
5517
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
5518
|
+
SlashCommandItem,
|
|
5519
|
+
{
|
|
5520
|
+
item,
|
|
5521
|
+
groupIndex,
|
|
5522
|
+
commandIndex,
|
|
5523
|
+
selectedGroupIndex,
|
|
5524
|
+
selectedCommandIndex,
|
|
5525
|
+
selectItem: () => selectItem(groupIndex, commandIndex),
|
|
5526
|
+
editor,
|
|
5527
|
+
activeCommandRef
|
|
5528
|
+
},
|
|
5529
|
+
commandIndex
|
|
5530
|
+
);
|
|
5383
5531
|
}) })
|
|
5384
5532
|
] }, groupIndex))
|
|
5385
5533
|
}
|
|
5386
5534
|
),
|
|
5387
|
-
/* @__PURE__ */ (0,
|
|
5388
|
-
/* @__PURE__ */ (0,
|
|
5389
|
-
/* @__PURE__ */ (0,
|
|
5390
|
-
/* @__PURE__ */ (0,
|
|
5535
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: "mly-border-t mly-border-gray-200 mly-px-1 mly-py-3 mly-pl-4", children: /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: "mly-flex mly-items-center", children: [
|
|
5536
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("p", { className: "mly-text-center mly-text-xs mly-text-gray-400", children: [
|
|
5537
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("kbd", { className: "mly-rounded mly-border mly-border-gray-200 mly-p-1 mly-px-2 mly-font-medium", children: "\u2191" }),
|
|
5538
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("kbd", { className: "mly-ml-1 mly-rounded mly-border mly-border-gray-200 mly-p-1 mly-px-2 mly-font-medium", children: "\u2193" }),
|
|
5391
5539
|
" ",
|
|
5392
5540
|
"to navigate"
|
|
5393
5541
|
] }),
|
|
5394
|
-
/* @__PURE__ */ (0,
|
|
5395
|
-
/* @__PURE__ */ (0,
|
|
5396
|
-
/* @__PURE__ */ (0,
|
|
5542
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("span", { "aria-hidden": "true", className: "mly-select-none mly-px-1", children: "\xB7" }),
|
|
5543
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("p", { className: "mly-text-center mly-text-xs mly-text-gray-400", children: [
|
|
5544
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("kbd", { className: "mly-rounded mly-border mly-border-gray-200 mly-p-1 mly-px-1.5 mly-font-medium", children: "Enter" }),
|
|
5397
5545
|
" ",
|
|
5398
5546
|
"to select"
|
|
5399
5547
|
] })
|
|
@@ -5482,7 +5630,7 @@ function getSlashCommandSuggestions(groups = DEFAULT_SLASH_COMMANDS) {
|
|
|
5482
5630
|
let popup = null;
|
|
5483
5631
|
return {
|
|
5484
5632
|
onStart: (props) => {
|
|
5485
|
-
component = new
|
|
5633
|
+
component = new import_react32.ReactRenderer(CommandList, {
|
|
5486
5634
|
props,
|
|
5487
5635
|
editor: props.editor
|
|
5488
5636
|
});
|
|
@@ -5496,24 +5644,36 @@ function getSlashCommandSuggestions(groups = DEFAULT_SLASH_COMMANDS) {
|
|
|
5496
5644
|
});
|
|
5497
5645
|
},
|
|
5498
5646
|
onUpdate: (props) => {
|
|
5647
|
+
var _a;
|
|
5648
|
+
const currentPopup = popup == null ? void 0 : popup[0];
|
|
5649
|
+
if (!currentPopup || ((_a = currentPopup == null ? void 0 : currentPopup.state) == null ? void 0 : _a.isDestroyed)) {
|
|
5650
|
+
return;
|
|
5651
|
+
}
|
|
5499
5652
|
component == null ? void 0 : component.updateProps(props);
|
|
5500
|
-
|
|
5653
|
+
currentPopup.setProps({
|
|
5501
5654
|
getReferenceClientRect: props.clientRect
|
|
5502
5655
|
});
|
|
5503
5656
|
},
|
|
5504
5657
|
onKeyDown: (props) => {
|
|
5505
|
-
var _a;
|
|
5658
|
+
var _a, _b;
|
|
5506
5659
|
if (props.event.key === "Escape") {
|
|
5507
|
-
popup == null ? void 0 : popup[0]
|
|
5660
|
+
const currentPopup = popup == null ? void 0 : popup[0];
|
|
5661
|
+
if (!((_a = currentPopup == null ? void 0 : currentPopup.state) == null ? void 0 : _a.isDestroyed)) {
|
|
5662
|
+
currentPopup == null ? void 0 : currentPopup.destroy();
|
|
5663
|
+
}
|
|
5664
|
+
component == null ? void 0 : component.destroy();
|
|
5508
5665
|
return true;
|
|
5509
5666
|
}
|
|
5510
|
-
return (
|
|
5667
|
+
return (_b = component == null ? void 0 : component.ref) == null ? void 0 : _b.onKeyDown(props);
|
|
5511
5668
|
},
|
|
5512
5669
|
onExit: () => {
|
|
5513
5670
|
if (!popup || !(popup == null ? void 0 : popup[0]) || !component) {
|
|
5514
5671
|
return;
|
|
5515
5672
|
}
|
|
5516
|
-
popup == null ? void 0 : popup[0]
|
|
5673
|
+
const currentPopup = popup == null ? void 0 : popup[0];
|
|
5674
|
+
if (!currentPopup.state.isDestroyed) {
|
|
5675
|
+
currentPopup.destroy();
|
|
5676
|
+
}
|
|
5517
5677
|
component == null ? void 0 : component.destroy();
|
|
5518
5678
|
}
|
|
5519
5679
|
};
|
|
@@ -5522,16 +5682,16 @@ function getSlashCommandSuggestions(groups = DEFAULT_SLASH_COMMANDS) {
|
|
|
5522
5682
|
}
|
|
5523
5683
|
|
|
5524
5684
|
// src/editor/nodes/variable/variable-suggestions.tsx
|
|
5525
|
-
var
|
|
5526
|
-
var
|
|
5527
|
-
var import_tippy2 = __toESM(require("tippy.js"));
|
|
5528
|
-
var
|
|
5529
|
-
var VariableList = (0,
|
|
5685
|
+
var import_react34 = require("@tiptap/react");
|
|
5686
|
+
var import_react35 = require("react");
|
|
5687
|
+
var import_tippy2 = __toESM(require("tippy.js"), 1);
|
|
5688
|
+
var import_jsx_runtime37 = require("react/jsx-runtime");
|
|
5689
|
+
var VariableList = (0, import_react35.forwardRef)((props, ref) => {
|
|
5530
5690
|
var _a;
|
|
5531
5691
|
const { items = [], editor } = props;
|
|
5532
|
-
const popoverRef = (0,
|
|
5692
|
+
const popoverRef = (0, import_react35.useRef)(null);
|
|
5533
5693
|
const VariableSuggestionPopoverComponent = (_a = useVariableOptions(editor)) == null ? void 0 : _a.variableSuggestionsPopover;
|
|
5534
|
-
(0,
|
|
5694
|
+
(0, import_react35.useImperativeHandle)(ref, () => ({
|
|
5535
5695
|
onKeyDown: ({ event }) => {
|
|
5536
5696
|
if (!popoverRef.current) {
|
|
5537
5697
|
return false;
|
|
@@ -5554,7 +5714,7 @@ var VariableList = (0, import_react34.forwardRef)((props, ref) => {
|
|
|
5554
5714
|
return false;
|
|
5555
5715
|
}
|
|
5556
5716
|
}));
|
|
5557
|
-
return /* @__PURE__ */ (0,
|
|
5717
|
+
return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
|
|
5558
5718
|
VariableSuggestionPopoverComponent,
|
|
5559
5719
|
{
|
|
5560
5720
|
items,
|
|
@@ -5587,7 +5747,7 @@ function getVariableSuggestions(char = DEFAULT_VARIABLE_TRIGGER_CHAR) {
|
|
|
5587
5747
|
let popup = null;
|
|
5588
5748
|
return {
|
|
5589
5749
|
onStart: (props) => {
|
|
5590
|
-
component = new
|
|
5750
|
+
component = new import_react34.ReactRenderer(VariableList, {
|
|
5591
5751
|
props,
|
|
5592
5752
|
editor: props.editor
|
|
5593
5753
|
});
|
|
@@ -5633,6 +5793,178 @@ function getVariableSuggestions(char = DEFAULT_VARIABLE_TRIGGER_CHAR) {
|
|
|
5633
5793
|
}
|
|
5634
5794
|
};
|
|
5635
5795
|
}
|
|
5796
|
+
|
|
5797
|
+
// src/editor/nodes/html/html.tsx
|
|
5798
|
+
var import_extension_code_block_lowlight = __toESM(require("@tiptap/extension-code-block-lowlight"), 1);
|
|
5799
|
+
var import_state5 = require("@tiptap/pm/state");
|
|
5800
|
+
var import_react38 = require("@tiptap/react");
|
|
5801
|
+
var import_xml = __toESM(require("highlight.js/lib/languages/xml"), 1);
|
|
5802
|
+
var import_lowlight = require("lowlight");
|
|
5803
|
+
|
|
5804
|
+
// src/editor/nodes/html/html-view.tsx
|
|
5805
|
+
var import_react36 = require("@tiptap/react");
|
|
5806
|
+
var import_react37 = require("react");
|
|
5807
|
+
var import_jsx_runtime38 = require("react/jsx-runtime");
|
|
5808
|
+
function HTMLCodeBlockView(props) {
|
|
5809
|
+
const { node, updateAttributes: updateAttributes2 } = props;
|
|
5810
|
+
let { language, activeTab = "code" } = node.attrs;
|
|
5811
|
+
activeTab || (activeTab = "code");
|
|
5812
|
+
const languageClass = language ? `language-${language}` : "";
|
|
5813
|
+
const html2 = (0, import_react37.useMemo)(() => {
|
|
5814
|
+
const text2 = node.content.content.reduce((acc, cur) => {
|
|
5815
|
+
if (cur.type.name === "text") {
|
|
5816
|
+
return acc + cur.text;
|
|
5817
|
+
} else if (cur.type.name === "variable") {
|
|
5818
|
+
const { id: variable, fallback } = (cur == null ? void 0 : cur.attrs) || {};
|
|
5819
|
+
const formattedVariable = fallback ? `{{${variable},fallback=${fallback}}}` : `{{${variable}}}`;
|
|
5820
|
+
return acc + formattedVariable;
|
|
5821
|
+
}
|
|
5822
|
+
return acc;
|
|
5823
|
+
}, "");
|
|
5824
|
+
const htmlParser = new DOMParser();
|
|
5825
|
+
const htmlDoc = htmlParser.parseFromString(text2, "text/html");
|
|
5826
|
+
const body = htmlDoc.body;
|
|
5827
|
+
return body.innerHTML;
|
|
5828
|
+
}, [activeTab]);
|
|
5829
|
+
const isEmpty = html2 === "";
|
|
5830
|
+
return /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)(
|
|
5831
|
+
import_react36.NodeViewWrapper,
|
|
5832
|
+
{
|
|
5833
|
+
draggable: false,
|
|
5834
|
+
"data-drag-handle": false,
|
|
5835
|
+
"data-type": "htmlCodeBlock",
|
|
5836
|
+
children: [
|
|
5837
|
+
activeTab === "code" && /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("pre", { className: "mly-my-0 mly-rounded-lg mly-border mly-border-gray-200 mly-bg-white mly-p-2 mly-text-black", children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
|
|
5838
|
+
import_react36.NodeViewContent,
|
|
5839
|
+
{
|
|
5840
|
+
as: "code",
|
|
5841
|
+
className: cn("is-editable", languageClass)
|
|
5842
|
+
}
|
|
5843
|
+
) }),
|
|
5844
|
+
activeTab === "preview" && /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
|
|
5845
|
+
"div",
|
|
5846
|
+
{
|
|
5847
|
+
className: cn(
|
|
5848
|
+
"mly-not-prose mly-rounded-lg mly-border mly-border-gray-200 mly-p-2",
|
|
5849
|
+
isEmpty && "mly-min-h-[42px]"
|
|
5850
|
+
),
|
|
5851
|
+
ref: (node2) => {
|
|
5852
|
+
if (!node2 || (node2 == null ? void 0 : node2.shadowRoot)) {
|
|
5853
|
+
return;
|
|
5854
|
+
}
|
|
5855
|
+
const shadow = node2.attachShadow({ mode: "open" });
|
|
5856
|
+
const sheet = new CSSStyleSheet();
|
|
5857
|
+
sheet.replaceSync(`
|
|
5858
|
+
* { font-family: 'Inter', sans-serif; }
|
|
5859
|
+
blockquote, h1, h2, h3, img, li, ol, p, ul {
|
|
5860
|
+
margin-top: 0;
|
|
5861
|
+
margin-bottom: 0;
|
|
5862
|
+
}
|
|
5863
|
+
`);
|
|
5864
|
+
shadow.adoptedStyleSheets = [sheet];
|
|
5865
|
+
const container = document.createElement("div");
|
|
5866
|
+
container.innerHTML = html2;
|
|
5867
|
+
shadow.appendChild(container);
|
|
5868
|
+
},
|
|
5869
|
+
contentEditable: false,
|
|
5870
|
+
onClick: () => {
|
|
5871
|
+
if (!isEmpty) {
|
|
5872
|
+
return;
|
|
5873
|
+
}
|
|
5874
|
+
updateAttributes2({
|
|
5875
|
+
activeTab: "code"
|
|
5876
|
+
});
|
|
5877
|
+
}
|
|
5878
|
+
}
|
|
5879
|
+
)
|
|
5880
|
+
]
|
|
5881
|
+
}
|
|
5882
|
+
);
|
|
5883
|
+
}
|
|
5884
|
+
|
|
5885
|
+
// src/editor/nodes/html/html.tsx
|
|
5886
|
+
var lowlight = (0, import_lowlight.createLowlight)(import_lowlight.common);
|
|
5887
|
+
lowlight.register("html", import_xml.default);
|
|
5888
|
+
var HTMLCodeBlockExtension = import_extension_code_block_lowlight.default.extend({
|
|
5889
|
+
name: "htmlCodeBlock",
|
|
5890
|
+
content: "(text|variable)*",
|
|
5891
|
+
addAttributes() {
|
|
5892
|
+
var _a;
|
|
5893
|
+
return __spreadProps(__spreadValues({}, (_a = this.parent) == null ? void 0 : _a.call(this)), {
|
|
5894
|
+
activeTab: "code",
|
|
5895
|
+
showIfKey: {
|
|
5896
|
+
default: DEFAULT_SECTION_SHOW_IF_KEY,
|
|
5897
|
+
parseHTML: (element) => {
|
|
5898
|
+
return element.getAttribute("data-show-if-key") || DEFAULT_SECTION_SHOW_IF_KEY;
|
|
5899
|
+
},
|
|
5900
|
+
renderHTML(attributes) {
|
|
5901
|
+
if (!attributes.showIfKey) {
|
|
5902
|
+
return {};
|
|
5903
|
+
}
|
|
5904
|
+
return {
|
|
5905
|
+
"data-show-if-key": attributes.showIfKey
|
|
5906
|
+
};
|
|
5907
|
+
}
|
|
5908
|
+
}
|
|
5909
|
+
});
|
|
5910
|
+
},
|
|
5911
|
+
addNodeView() {
|
|
5912
|
+
return (0, import_react38.ReactNodeViewRenderer)(HTMLCodeBlockView, {
|
|
5913
|
+
className: "mly-relative",
|
|
5914
|
+
attrs: ({ node }) => {
|
|
5915
|
+
var _a;
|
|
5916
|
+
return {
|
|
5917
|
+
"data-active-tab": ((_a = node == null ? void 0 : node.attrs) == null ? void 0 : _a.activeTab) || "code"
|
|
5918
|
+
};
|
|
5919
|
+
}
|
|
5920
|
+
});
|
|
5921
|
+
},
|
|
5922
|
+
addCommands() {
|
|
5923
|
+
return {
|
|
5924
|
+
setHtmlCodeBlock: (attributes) => ({ commands }) => {
|
|
5925
|
+
return commands.setNode(this.name, attributes);
|
|
5926
|
+
},
|
|
5927
|
+
toggleHtmlCodeBlock: (attributes) => ({ commands }) => {
|
|
5928
|
+
return commands.toggleNode(this.name, "paragraph", attributes);
|
|
5929
|
+
},
|
|
5930
|
+
updateHtmlCodeBlock: (attrs) => updateAttributes(this.name, attrs)
|
|
5931
|
+
};
|
|
5932
|
+
},
|
|
5933
|
+
addKeyboardShortcuts() {
|
|
5934
|
+
var _a;
|
|
5935
|
+
return __spreadProps(__spreadValues({}, (_a = this.parent) == null ? void 0 : _a.call(this)), {
|
|
5936
|
+
"Mod-a": ({ editor }) => {
|
|
5937
|
+
const { selection } = editor.state;
|
|
5938
|
+
const $pos = selection.$anchor;
|
|
5939
|
+
const node = $pos.node($pos.depth);
|
|
5940
|
+
if (node.type.name !== this.name) {
|
|
5941
|
+
return false;
|
|
5942
|
+
}
|
|
5943
|
+
let depth = $pos.depth;
|
|
5944
|
+
for (let d = depth; d > 0; d--) {
|
|
5945
|
+
if ($pos.node(d).type.name === this.name) {
|
|
5946
|
+
depth = d;
|
|
5947
|
+
break;
|
|
5948
|
+
}
|
|
5949
|
+
}
|
|
5950
|
+
const start = $pos.before(depth) + 1;
|
|
5951
|
+
const end = $pos.after(depth) - 1;
|
|
5952
|
+
const from = editor.state.doc.resolve(start);
|
|
5953
|
+
const to = editor.state.doc.resolve(end);
|
|
5954
|
+
if (from && to) {
|
|
5955
|
+
const transaction = editor.state.tr.setSelection(
|
|
5956
|
+
import_state5.TextSelection.between(from, to)
|
|
5957
|
+
);
|
|
5958
|
+
editor.view.dispatch(transaction);
|
|
5959
|
+
return true;
|
|
5960
|
+
}
|
|
5961
|
+
return false;
|
|
5962
|
+
}
|
|
5963
|
+
});
|
|
5964
|
+
}
|
|
5965
|
+
}).configure({
|
|
5966
|
+
lowlight
|
|
5967
|
+
});
|
|
5636
5968
|
// Annotate the CommonJS export names for ESM import in node:
|
|
5637
5969
|
0 && (module.exports = {
|
|
5638
5970
|
ButtonExtension,
|
|
@@ -5672,6 +6004,7 @@ function getVariableSuggestions(char = DEFAULT_VARIABLE_TRIGGER_CHAR) {
|
|
|
5672
6004
|
DEFAULT_VARIABLE_SUGGESTION_POPOVER,
|
|
5673
6005
|
DEFAULT_VARIABLE_TRIGGER_CHAR,
|
|
5674
6006
|
Footer,
|
|
6007
|
+
HTMLCodeBlockExtension,
|
|
5675
6008
|
HorizontalRule,
|
|
5676
6009
|
ImageExtension,
|
|
5677
6010
|
ImageUploadExtension,
|
|
@@ -5696,4 +6029,4 @@ function getVariableSuggestions(char = DEFAULT_VARIABLE_TRIGGER_CHAR) {
|
|
|
5696
6029
|
logoSizes,
|
|
5697
6030
|
useImageUploadOptions
|
|
5698
6031
|
});
|
|
5699
|
-
//# sourceMappingURL=index.
|
|
6032
|
+
//# sourceMappingURL=index.cjs.map
|