@tumaet/prompt-ui-components 0.0.10 → 0.0.12
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/components/index.js +10 -0
- package/dist/components/index.js.map +1 -1
- package/dist/components/minimal-tiptap/components/bubble-menu/link-bubble-menu.js +65 -0
- package/dist/components/minimal-tiptap/components/bubble-menu/link-bubble-menu.js.map +1 -0
- package/dist/components/minimal-tiptap/components/image/image-edit-block.js +38 -0
- package/dist/components/minimal-tiptap/components/image/image-edit-block.js.map +1 -0
- package/dist/components/minimal-tiptap/components/image/image-edit-dialog.js +12 -0
- package/dist/components/minimal-tiptap/components/image/image-edit-dialog.js.map +1 -0
- package/dist/components/minimal-tiptap/components/link/link-edit-block.js +34 -0
- package/dist/components/minimal-tiptap/components/link/link-edit-block.js.map +1 -0
- package/dist/components/minimal-tiptap/components/link/link-edit-popover.js +38 -0
- package/dist/components/minimal-tiptap/components/link/link-edit-popover.js.map +1 -0
- package/dist/components/minimal-tiptap/components/link/link-popover-block.js +28 -0
- package/dist/components/minimal-tiptap/components/link/link-popover-block.js.map +1 -0
- package/dist/components/minimal-tiptap/components/measured-container.js +16 -0
- package/dist/components/minimal-tiptap/components/measured-container.js.map +1 -0
- package/dist/components/minimal-tiptap/components/section/five.js +39 -0
- package/dist/components/minimal-tiptap/components/section/five.js.map +1 -0
- package/dist/components/minimal-tiptap/components/section/four.js +29 -0
- package/dist/components/minimal-tiptap/components/section/four.js.map +1 -0
- package/dist/components/minimal-tiptap/components/section/mailingPlaceholders.js +23 -0
- package/dist/components/minimal-tiptap/components/section/mailingPlaceholders.js.map +1 -0
- package/dist/components/minimal-tiptap/components/section/one.js +77 -0
- package/dist/components/minimal-tiptap/components/section/one.js.map +1 -0
- package/dist/components/minimal-tiptap/components/section/three.js +79 -0
- package/dist/components/minimal-tiptap/components/section/three.js.map +1 -0
- package/dist/components/minimal-tiptap/components/section/two.js +65 -0
- package/dist/components/minimal-tiptap/components/section/two.js.map +1 -0
- package/dist/components/minimal-tiptap/components/shortcut-key.js +11 -0
- package/dist/components/minimal-tiptap/components/shortcut-key.js.map +1 -0
- package/dist/components/minimal-tiptap/components/spinner.js +9 -0
- package/dist/components/minimal-tiptap/components/spinner.js.map +1 -0
- package/dist/components/minimal-tiptap/components/toolbar-button.js +15 -0
- package/dist/components/minimal-tiptap/components/toolbar-button.js.map +1 -0
- package/dist/components/minimal-tiptap/components/toolbar-section.js +27 -0
- package/dist/components/minimal-tiptap/components/toolbar-section.js.map +1 -0
- package/dist/components/minimal-tiptap/extensions/code-block-lowlight/code-block-lowlight.js +16 -0
- package/dist/components/minimal-tiptap/extensions/code-block-lowlight/code-block-lowlight.js.map +1 -0
- package/dist/components/minimal-tiptap/extensions/code-block-lowlight/index.js +2 -0
- package/dist/components/minimal-tiptap/extensions/code-block-lowlight/index.js.map +1 -0
- package/dist/components/minimal-tiptap/extensions/color/color.js +20 -0
- package/dist/components/minimal-tiptap/extensions/color/color.js.map +1 -0
- package/dist/components/minimal-tiptap/extensions/color/index.js +2 -0
- package/dist/components/minimal-tiptap/extensions/color/index.js.map +1 -0
- package/dist/components/minimal-tiptap/extensions/file-handler/index.js +74 -0
- package/dist/components/minimal-tiptap/extensions/file-handler/index.js.map +1 -0
- package/dist/components/minimal-tiptap/extensions/horizontal-rule/horizontal-rule.js +16 -0
- package/dist/components/minimal-tiptap/extensions/horizontal-rule/horizontal-rule.js.map +1 -0
- package/dist/components/minimal-tiptap/extensions/horizontal-rule/index.js +2 -0
- package/dist/components/minimal-tiptap/extensions/horizontal-rule/index.js.map +1 -0
- package/dist/components/minimal-tiptap/extensions/image/components/image-actions.js +39 -0
- package/dist/components/minimal-tiptap/extensions/image/components/image-actions.js.map +1 -0
- package/dist/components/minimal-tiptap/extensions/image/components/image-overlay.js +9 -0
- package/dist/components/minimal-tiptap/extensions/image/components/image-overlay.js.map +1 -0
- package/dist/components/minimal-tiptap/extensions/image/components/image-view-block.js +167 -0
- package/dist/components/minimal-tiptap/extensions/image/components/image-view-block.js.map +1 -0
- package/dist/components/minimal-tiptap/extensions/image/components/resize-handle.js +11 -0
- package/dist/components/minimal-tiptap/extensions/image/components/resize-handle.js.map +1 -0
- package/dist/components/minimal-tiptap/extensions/image/hooks/use-drag-resize.js +88 -0
- package/dist/components/minimal-tiptap/extensions/image/hooks/use-drag-resize.js.map +1 -0
- package/dist/components/minimal-tiptap/extensions/image/hooks/use-image-actions.js +32 -0
- package/dist/components/minimal-tiptap/extensions/image/hooks/use-image-actions.js.map +1 -0
- package/dist/components/minimal-tiptap/extensions/image/image.js +225 -0
- package/dist/components/minimal-tiptap/extensions/image/image.js.map +1 -0
- package/dist/components/minimal-tiptap/extensions/image/index.js +2 -0
- package/dist/components/minimal-tiptap/extensions/image/index.js.map +1 -0
- package/dist/components/minimal-tiptap/extensions/index.js +10 -0
- package/dist/components/minimal-tiptap/extensions/index.js.map +1 -0
- package/dist/components/minimal-tiptap/extensions/link/index.js +2 -0
- package/dist/components/minimal-tiptap/extensions/link/index.js.map +1 -0
- package/dist/components/minimal-tiptap/extensions/link/link.js +74 -0
- package/dist/components/minimal-tiptap/extensions/link/link.js.map +1 -0
- package/dist/components/minimal-tiptap/extensions/reset-marks-on-enter/index.js +2 -0
- package/dist/components/minimal-tiptap/extensions/reset-marks-on-enter/index.js.map +1 -0
- package/dist/components/minimal-tiptap/extensions/reset-marks-on-enter/reset-marks-on-enter.js +20 -0
- package/dist/components/minimal-tiptap/extensions/reset-marks-on-enter/reset-marks-on-enter.js.map +1 -0
- package/dist/components/minimal-tiptap/extensions/selection/index.js +2 -0
- package/dist/components/minimal-tiptap/extensions/selection/index.js.map +1 -0
- package/dist/components/minimal-tiptap/extensions/selection/selection.js +31 -0
- package/dist/components/minimal-tiptap/extensions/selection/selection.js.map +1 -0
- package/dist/components/minimal-tiptap/extensions/unset-all-marks/index.js +2 -0
- package/dist/components/minimal-tiptap/extensions/unset-all-marks/index.js.map +1 -0
- package/dist/components/minimal-tiptap/extensions/unset-all-marks/unset-all-marks.js +9 -0
- package/dist/components/minimal-tiptap/extensions/unset-all-marks/unset-all-marks.js.map +1 -0
- package/dist/components/minimal-tiptap/form-description-tiptap.js +26 -0
- package/dist/components/minimal-tiptap/form-description-tiptap.js.map +1 -0
- package/dist/components/minimal-tiptap/hooks/use-container-size.js +44 -0
- package/dist/components/minimal-tiptap/hooks/use-container-size.js.map +1 -0
- package/dist/components/minimal-tiptap/hooks/use-minimal-tiptap.js +160 -0
- package/dist/components/minimal-tiptap/hooks/use-minimal-tiptap.js.map +1 -0
- package/dist/components/minimal-tiptap/hooks/use-theme.js +19 -0
- package/dist/components/minimal-tiptap/hooks/use-theme.js.map +1 -0
- package/dist/components/minimal-tiptap/hooks/use-throttle.js +24 -0
- package/dist/components/minimal-tiptap/hooks/use-throttle.js.map +1 -0
- package/dist/components/minimal-tiptap/index.js +2 -0
- package/dist/components/minimal-tiptap/index.js.map +1 -0
- package/dist/components/minimal-tiptap/mailing-tiptap.js +30 -0
- package/dist/components/minimal-tiptap/mailing-tiptap.js.map +1 -0
- package/dist/components/minimal-tiptap/minimal-tiptap.js +29 -0
- package/dist/components/minimal-tiptap/minimal-tiptap.js.map +1 -0
- package/dist/components/minimal-tiptap/styles/index.css +444 -0
- package/dist/components/minimal-tiptap/types.js +2 -0
- package/dist/components/minimal-tiptap/types.js.map +1 -0
- package/dist/components/minimal-tiptap/utils.js +156 -0
- package/dist/components/minimal-tiptap/utils.js.map +1 -0
- package/dist/types/components/index.d.ts +10 -0
- package/dist/types/components/minimal-tiptap/components/bubble-menu/link-bubble-menu.d.ts +7 -0
- package/dist/types/components/minimal-tiptap/components/image/image-edit-block.d.ts +8 -0
- package/dist/types/components/minimal-tiptap/components/image/image-edit-dialog.d.ts +8 -0
- package/dist/types/components/minimal-tiptap/components/link/link-edit-block.d.ts +9 -0
- package/dist/types/components/minimal-tiptap/components/link/link-edit-popover.d.ts +8 -0
- package/dist/types/components/minimal-tiptap/components/link/link-popover-block.d.ts +8 -0
- package/dist/types/components/minimal-tiptap/components/measured-container.d.ts +2 -0
- package/dist/types/components/minimal-tiptap/components/section/five.d.ts +12 -0
- package/dist/types/components/minimal-tiptap/components/section/four.d.ts +12 -0
- package/dist/types/components/minimal-tiptap/components/section/mailingPlaceholders.d.ts +10 -0
- package/dist/types/components/minimal-tiptap/components/section/one.d.ts +11 -0
- package/dist/types/components/minimal-tiptap/components/section/three.d.ts +9 -0
- package/dist/types/components/minimal-tiptap/components/section/two.d.ts +12 -0
- package/dist/types/components/minimal-tiptap/components/shortcut-key.d.ts +5 -0
- package/dist/types/components/minimal-tiptap/components/spinner.d.ts +5 -0
- package/dist/types/components/minimal-tiptap/components/toolbar-button.d.ts +10 -0
- package/dist/types/components/minimal-tiptap/components/toolbar-section.d.ts +16 -0
- package/dist/types/components/minimal-tiptap/extensions/code-block-lowlight/code-block-lowlight.d.ts +2 -0
- package/dist/types/components/minimal-tiptap/extensions/code-block-lowlight/index.d.ts +1 -0
- package/dist/types/components/minimal-tiptap/extensions/color/color.d.ts +1 -0
- package/dist/types/components/minimal-tiptap/extensions/color/index.d.ts +1 -0
- package/dist/types/components/minimal-tiptap/extensions/file-handler/index.d.ts +12 -0
- package/dist/types/components/minimal-tiptap/extensions/horizontal-rule/horizontal-rule.d.ts +2 -0
- package/dist/types/components/minimal-tiptap/extensions/horizontal-rule/index.d.ts +1 -0
- package/dist/types/components/minimal-tiptap/extensions/image/components/image-actions.d.ts +17 -0
- package/dist/types/components/minimal-tiptap/extensions/image/components/image-overlay.d.ts +2 -0
- package/dist/types/components/minimal-tiptap/extensions/image/components/image-view-block.d.ts +3 -0
- package/dist/types/components/minimal-tiptap/extensions/image/components/resize-handle.d.ts +6 -0
- package/dist/types/components/minimal-tiptap/extensions/image/hooks/use-drag-resize.d.ts +24 -0
- package/dist/types/components/minimal-tiptap/extensions/image/hooks/use-image-actions.d.ts +24 -0
- package/dist/types/components/minimal-tiptap/extensions/image/image.d.ts +52 -0
- package/dist/types/components/minimal-tiptap/extensions/image/index.d.ts +1 -0
- package/dist/types/components/minimal-tiptap/extensions/index.d.ts +9 -0
- package/dist/types/components/minimal-tiptap/extensions/link/index.d.ts +1 -0
- package/dist/types/components/minimal-tiptap/extensions/link/link.d.ts +2 -0
- package/dist/types/components/minimal-tiptap/extensions/reset-marks-on-enter/index.d.ts +1 -0
- package/dist/types/components/minimal-tiptap/extensions/reset-marks-on-enter/reset-marks-on-enter.d.ts +2 -0
- package/dist/types/components/minimal-tiptap/extensions/selection/index.d.ts +1 -0
- package/dist/types/components/minimal-tiptap/extensions/selection/selection.d.ts +3 -0
- package/dist/types/components/minimal-tiptap/extensions/unset-all-marks/index.d.ts +1 -0
- package/dist/types/components/minimal-tiptap/extensions/unset-all-marks/unset-all-marks.d.ts +2 -0
- package/dist/types/components/minimal-tiptap/form-description-tiptap.d.ts +4 -0
- package/dist/types/components/minimal-tiptap/hooks/use-container-size.d.ts +1 -0
- package/dist/types/components/minimal-tiptap/hooks/use-minimal-tiptap.d.ts +13 -0
- package/dist/types/components/minimal-tiptap/hooks/use-theme.d.ts +2 -0
- package/dist/types/components/minimal-tiptap/hooks/use-throttle.d.ts +1 -0
- package/dist/types/components/minimal-tiptap/index.d.ts +1 -0
- package/dist/types/components/minimal-tiptap/mailing-tiptap.d.ts +13 -0
- package/dist/types/components/minimal-tiptap/minimal-tiptap.d.ts +12 -0
- package/dist/types/components/minimal-tiptap/types.d.ts +25 -0
- package/dist/types/components/minimal-tiptap/utils.d.ts +38 -0
- package/package.json +26 -4
- package/src/components/minimal-tiptap/styles/index.css +444 -0
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { useState, useEffect, useCallback } from 'react';
|
|
2
|
+
const DEFAULT_RECT = {
|
|
3
|
+
top: 0,
|
|
4
|
+
left: 0,
|
|
5
|
+
bottom: 0,
|
|
6
|
+
right: 0,
|
|
7
|
+
x: 0,
|
|
8
|
+
y: 0,
|
|
9
|
+
width: 0,
|
|
10
|
+
height: 0,
|
|
11
|
+
toJSON: () => '{}',
|
|
12
|
+
};
|
|
13
|
+
export function useContainerSize(element) {
|
|
14
|
+
const [size, setSize] = useState(() => element?.getBoundingClientRect() ?? DEFAULT_RECT);
|
|
15
|
+
const handleResize = useCallback(() => {
|
|
16
|
+
if (!element)
|
|
17
|
+
return;
|
|
18
|
+
const newRect = element.getBoundingClientRect();
|
|
19
|
+
setSize((prevRect) => {
|
|
20
|
+
if (Math.round(prevRect.width) === Math.round(newRect.width) &&
|
|
21
|
+
Math.round(prevRect.height) === Math.round(newRect.height) &&
|
|
22
|
+
Math.round(prevRect.x) === Math.round(newRect.x) &&
|
|
23
|
+
Math.round(prevRect.y) === Math.round(newRect.y)) {
|
|
24
|
+
return prevRect;
|
|
25
|
+
}
|
|
26
|
+
return newRect;
|
|
27
|
+
});
|
|
28
|
+
}, [element]);
|
|
29
|
+
useEffect(() => {
|
|
30
|
+
if (!element)
|
|
31
|
+
return;
|
|
32
|
+
const resizeObserver = new ResizeObserver(handleResize);
|
|
33
|
+
resizeObserver.observe(element);
|
|
34
|
+
window.addEventListener('click', handleResize);
|
|
35
|
+
window.addEventListener('resize', handleResize);
|
|
36
|
+
return () => {
|
|
37
|
+
resizeObserver.disconnect();
|
|
38
|
+
window.removeEventListener('click', handleResize);
|
|
39
|
+
window.removeEventListener('resize', handleResize);
|
|
40
|
+
};
|
|
41
|
+
}, [element, handleResize]);
|
|
42
|
+
return size;
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=use-container-size.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-container-size.js","sourceRoot":"","sources":["../../../../src/components/minimal-tiptap/hooks/use-container-size.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,OAAO,CAAA;AAExD,MAAM,YAAY,GAAY;IAC5B,GAAG,EAAE,CAAC;IACN,IAAI,EAAE,CAAC;IACP,MAAM,EAAE,CAAC;IACT,KAAK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AA;QACvD,cAAc,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;QAE/B,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,YAAY,CAAC,CAAA;QAC9C,MAAM,CAAC,gBAAgB,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAA;QAE/C,OAAO,GAAG,EAAE;YACV,cAAc,CAAC,UAAU,EAAE,CAAA;YAC3B,MAAM,CAAC,mBAAmB,CAAC,OAAO,EAAE,YAAY,CAAC,CAAA;YACjD,MAAM,CAAC,mBAAmB,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAA;QACpD,CAAC,CAAA;IACH,CAAC,EAAE,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC,CAAA;IAE3B,OAAO,IAAI,CAAA;AACb,CAAC"}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-shadow */
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { StarterKit } from '@tiptap/starter-kit';
|
|
4
|
+
import { useEditor } from '@tiptap/react';
|
|
5
|
+
import { Typography } from '@tiptap/extension-typography';
|
|
6
|
+
import { Placeholder } from '@tiptap/extension-placeholder';
|
|
7
|
+
import { Underline } from '@tiptap/extension-underline';
|
|
8
|
+
import { TextStyle } from '@tiptap/extension-text-style';
|
|
9
|
+
import { Link, Image, HorizontalRule, CodeBlockLowlight, Selection, Color, UnsetAllMarks, ResetMarksOnEnter, FileHandler, } from '../extensions';
|
|
10
|
+
import { cn } from '../../../lib/utils';
|
|
11
|
+
import { fileToBase64, getOutput, randomId } from '../utils';
|
|
12
|
+
import { useThrottle } from '../hooks/use-throttle';
|
|
13
|
+
import { toast } from 'sonner';
|
|
14
|
+
const createExtensions = (placeholder) => [
|
|
15
|
+
StarterKit.configure({
|
|
16
|
+
horizontalRule: false,
|
|
17
|
+
codeBlock: false,
|
|
18
|
+
paragraph: { HTMLAttributes: { class: 'text-node' } },
|
|
19
|
+
heading: { HTMLAttributes: { class: 'heading-node' } },
|
|
20
|
+
blockquote: { HTMLAttributes: { class: 'block-node' } },
|
|
21
|
+
bulletList: { HTMLAttributes: { class: 'list-node' } },
|
|
22
|
+
orderedList: { HTMLAttributes: { class: 'list-node' } },
|
|
23
|
+
code: { HTMLAttributes: { class: 'inline', spellcheck: 'false' } },
|
|
24
|
+
dropcursor: { width: 2, class: 'ProseMirror-dropcursor border' },
|
|
25
|
+
}),
|
|
26
|
+
Link,
|
|
27
|
+
Underline,
|
|
28
|
+
Image.configure({
|
|
29
|
+
allowedMimeTypes: ['image/*'],
|
|
30
|
+
maxFileSize: 5 * 1024 * 1024,
|
|
31
|
+
allowBase64: true,
|
|
32
|
+
uploadFn: async (file) => {
|
|
33
|
+
// NOTE: This is a fake upload function. Replace this with your own upload logic.
|
|
34
|
+
// This function should return the uploaded image URL.
|
|
35
|
+
// wait 3s to simulate upload
|
|
36
|
+
await new Promise((resolve) => setTimeout(resolve, 3000));
|
|
37
|
+
const src = await fileToBase64(file);
|
|
38
|
+
// either return { id: string | number, src: string } or just src
|
|
39
|
+
// return src;
|
|
40
|
+
return { id: randomId(), src };
|
|
41
|
+
},
|
|
42
|
+
onToggle(editor, files, pos) {
|
|
43
|
+
editor.commands.insertContentAt(pos, files.map((image) => {
|
|
44
|
+
const blobUrl = URL.createObjectURL(image);
|
|
45
|
+
const id = randomId();
|
|
46
|
+
return {
|
|
47
|
+
type: 'image',
|
|
48
|
+
attrs: {
|
|
49
|
+
id,
|
|
50
|
+
src: blobUrl,
|
|
51
|
+
alt: image.name,
|
|
52
|
+
title: image.name,
|
|
53
|
+
fileName: image.name,
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
}));
|
|
57
|
+
},
|
|
58
|
+
onImageRemoved({ id, src }) {
|
|
59
|
+
console.log('Image removed', { id, src });
|
|
60
|
+
},
|
|
61
|
+
onValidationError(errors) {
|
|
62
|
+
errors.forEach((error) => {
|
|
63
|
+
toast.error('Image validation error', {
|
|
64
|
+
position: 'bottom-right',
|
|
65
|
+
description: error.reason,
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
},
|
|
69
|
+
onActionSuccess({ action }) {
|
|
70
|
+
const mapping = {
|
|
71
|
+
copyImage: 'Copy Image',
|
|
72
|
+
copyLink: 'Copy Link',
|
|
73
|
+
download: 'Download',
|
|
74
|
+
};
|
|
75
|
+
toast.success(mapping[action], {
|
|
76
|
+
position: 'bottom-right',
|
|
77
|
+
description: 'Image action success',
|
|
78
|
+
});
|
|
79
|
+
},
|
|
80
|
+
onActionError(error, { action }) {
|
|
81
|
+
const mapping = {
|
|
82
|
+
copyImage: 'Copy Image',
|
|
83
|
+
copyLink: 'Copy Link',
|
|
84
|
+
download: 'Download',
|
|
85
|
+
};
|
|
86
|
+
toast.error(`Failed to ${mapping[action]}`, {
|
|
87
|
+
position: 'bottom-right',
|
|
88
|
+
description: error.message,
|
|
89
|
+
});
|
|
90
|
+
},
|
|
91
|
+
}),
|
|
92
|
+
FileHandler.configure({
|
|
93
|
+
allowBase64: true,
|
|
94
|
+
allowedMimeTypes: ['image/*'],
|
|
95
|
+
maxFileSize: 5 * 1024 * 1024,
|
|
96
|
+
onDrop: (editor, files, pos) => {
|
|
97
|
+
files.forEach(async (file) => {
|
|
98
|
+
const src = await fileToBase64(file);
|
|
99
|
+
editor.commands.insertContentAt(pos, {
|
|
100
|
+
type: 'image',
|
|
101
|
+
attrs: { src },
|
|
102
|
+
});
|
|
103
|
+
});
|
|
104
|
+
},
|
|
105
|
+
onPaste: (editor, files) => {
|
|
106
|
+
files.forEach(async (file) => {
|
|
107
|
+
const src = await fileToBase64(file);
|
|
108
|
+
editor.commands.insertContent({
|
|
109
|
+
type: 'image',
|
|
110
|
+
attrs: { src },
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
},
|
|
114
|
+
onValidationError: (errors) => {
|
|
115
|
+
errors.forEach((error) => {
|
|
116
|
+
toast.error('Image validation error', {
|
|
117
|
+
position: 'bottom-right',
|
|
118
|
+
description: error.reason,
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
},
|
|
122
|
+
}),
|
|
123
|
+
Color,
|
|
124
|
+
TextStyle,
|
|
125
|
+
Selection,
|
|
126
|
+
Typography,
|
|
127
|
+
UnsetAllMarks,
|
|
128
|
+
HorizontalRule,
|
|
129
|
+
ResetMarksOnEnter,
|
|
130
|
+
CodeBlockLowlight,
|
|
131
|
+
Placeholder.configure({ placeholder: () => placeholder }),
|
|
132
|
+
];
|
|
133
|
+
export const useMinimalTiptapEditor = ({ value, output = 'html', placeholder = '', editorClassName, throttleDelay = 0, onUpdate, onBlur, ...props }) => {
|
|
134
|
+
const throttledSetValue = useThrottle((value) => onUpdate?.(value), throttleDelay);
|
|
135
|
+
const handleUpdate = React.useCallback((editor) => throttledSetValue(getOutput(editor, output)), [output, throttledSetValue]);
|
|
136
|
+
const handleCreate = React.useCallback((editor) => {
|
|
137
|
+
if (value && editor.isEmpty) {
|
|
138
|
+
editor.commands.setContent(value);
|
|
139
|
+
}
|
|
140
|
+
}, [value]);
|
|
141
|
+
const handleBlur = React.useCallback((editor) => onBlur?.(getOutput(editor, output)), [output, onBlur]);
|
|
142
|
+
const editor = useEditor({
|
|
143
|
+
extensions: createExtensions(placeholder),
|
|
144
|
+
editorProps: {
|
|
145
|
+
attributes: {
|
|
146
|
+
autocomplete: 'off',
|
|
147
|
+
autocorrect: 'off',
|
|
148
|
+
autocapitalize: 'off',
|
|
149
|
+
class: cn('focus:outline-none', editorClassName),
|
|
150
|
+
},
|
|
151
|
+
},
|
|
152
|
+
onUpdate: ({ editor }) => handleUpdate(editor),
|
|
153
|
+
onCreate: ({ editor }) => handleCreate(editor),
|
|
154
|
+
onBlur: ({ editor }) => handleBlur(editor),
|
|
155
|
+
...props,
|
|
156
|
+
});
|
|
157
|
+
return editor;
|
|
158
|
+
};
|
|
159
|
+
export default useMinimalTiptapEditor;
|
|
160
|
+
//# sourceMappingURL=use-minimal-tiptap.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-minimal-tiptap.js","sourceRoot":"","sources":["../../../../src/components/minimal-tiptap/hooks/use-minimal-tiptap.ts"],"names":[],"mappings":"AAAA,iDAAiD;AACjD,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAG9B,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAA;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAA;AAC3D,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAA;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAA;AACxD,OAAO,EACL,IAAI,EACJ,KAAK,EACL,cAAc,EACd,iBAAiB,EACjB,SAAS,EACT,KAAK,EACL,aAAa,EACb,iBAAiB,EACjB,WAAW,GACZ,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAA;AAChC,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AACnD,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAA;AAY9B,MAAM,gBAAgB,GAAG,CAAC,WAAmB,EAAE,EAAE,CAAC;IAChD,UAAU,CAAC,SAAS,CAAC;QACnB,cAAc,EAAE,KAAK;QACrB,SAAS,EAAE,KAAK;QAChB,SAAS,EAAE,EAAE,cAAc,EAAE,EAAE,KAAK,EAAE,WAAW,EAAE,EAAE;QACrD,OAAO,EAAE,EAAE,cAAc,EAAE,EAAE,KAAK,EAAE,cAAc,EAAE,EAAE;QACtD,UAAU,EAAE,EAAE,cAAc,EAAE,EAAE,KAAK,EAAE,YAAY,EAAE,EAAE;QACvD,UAAU,EAAE,EAAE,cAAc,EAAE,EAAE,K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AAY,CAAC,MAAM,CAAC;QAC9C,QAAQ,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,YAAY,CAAC,MAAM,CAAC;QAC9C,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC;QAC1C,GAAG,KAAK;KACT,CAAC,CAAA;IAEF,OAAO,MAAM,CAAA;AACf,CAAC,CAAA;AAED,eAAe,sBAAsB,CAAA"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
export const useTheme = () => {
|
|
3
|
+
const [isDarkMode, setIsDarkMode] = React.useState(false);
|
|
4
|
+
React.useEffect(() => {
|
|
5
|
+
const darkModeMediaQuery = window.matchMedia('(prefers-color-scheme: dark)');
|
|
6
|
+
setIsDarkMode(darkModeMediaQuery.matches);
|
|
7
|
+
const handleChange = (e) => {
|
|
8
|
+
const newDarkMode = e.matches;
|
|
9
|
+
setIsDarkMode(newDarkMode);
|
|
10
|
+
};
|
|
11
|
+
darkModeMediaQuery.addEventListener('change', handleChange);
|
|
12
|
+
return () => {
|
|
13
|
+
darkModeMediaQuery.removeEventListener('change', handleChange);
|
|
14
|
+
};
|
|
15
|
+
}, []);
|
|
16
|
+
return isDarkMode;
|
|
17
|
+
};
|
|
18
|
+
export default useTheme;
|
|
19
|
+
//# sourceMappingURL=use-theme.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-theme.js","sourceRoot":"","sources":["../../../../src/components/minimal-tiptap/hooks/use-theme.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B,MAAM,CAAC,MAAM,QAAQ,GAAG,GAAG,EAAE;IAC3B,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAA;IAEzD,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,MAAM,kBAAkB,GAAG,MAAM,CAAC,UAAU,CAAC,8BAA8B,CAAC,CAAA;QAC5E,aAAa,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAA;QAEzC,MAAM,YAAY,GAAG,CAAC,CAAsB,EAAE,EAAE;YAC9C,MAAM,WAAW,GAAG,CAAC,CAAC,OAAO,CAAA;YAC7B,aAAa,CAAC,WAAW,CAAC,CAAA;QAC5B,CAAC,CAAA;QAED,kBAAkB,CAAC,gBAAgB,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAA;QAE3D,OAAO,GAAG,EAAE;YACV,kBAAkB,CAAC,mBAAmB,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAA;QAChE,CAAC,CAAA;IACH,CAAC,EAAE,EAAE,CAAC,CAAA;IAEN,OAAO,UAAU,CAAA;AACnB,CAAC,CAAA;AAED,eAAe,QAAQ,CAAA"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { useRef, useCallback } from 'react';
|
|
2
|
+
export function useThrottle(callback, delay) {
|
|
3
|
+
const lastRan = useRef(Date.now());
|
|
4
|
+
const timeoutRef = useRef(null);
|
|
5
|
+
return useCallback((...args) => {
|
|
6
|
+
const handler = () => {
|
|
7
|
+
if (Date.now() - lastRan.current >= delay) {
|
|
8
|
+
callback(...args);
|
|
9
|
+
lastRan.current = Date.now();
|
|
10
|
+
}
|
|
11
|
+
else {
|
|
12
|
+
if (timeoutRef.current) {
|
|
13
|
+
clearTimeout(timeoutRef.current);
|
|
14
|
+
}
|
|
15
|
+
timeoutRef.current = setTimeout(() => {
|
|
16
|
+
callback(...args);
|
|
17
|
+
lastRan.current = Date.now();
|
|
18
|
+
}, delay - (Date.now() - lastRan.current));
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
handler();
|
|
22
|
+
}, [callback, delay]);
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=use-throttle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-throttle.js","sourceRoot":"","sources":["../../../../src/components/minimal-tiptap/hooks/use-throttle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,OAAO,CAAA;AAE3C,MAAM,UAAU,WAAW,CACzB,QAAW,EACX,KAAa;IAEb,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAA;IAClC,MAAM,UAAU,GAAG,MAAM,CAAuC,IAAI,CAAC,CAAA;IAErE,OAAO,WAAW,CAChB,CAAC,GAAG,IAAmB,EAAE,EAAE;QACzB,MAAM,OAAO,GAAG,GAAG,EAAE;YACnB,IAAI,IAAI,CAAC,GAAG,EAAE,GAAG,OAAO,CAAC,OAAO,IAAI,KAAK,EAAE,CAAC;gBAC1C,QAAQ,CAAC,GAAG,IAAI,CAAC,CAAA;gBACjB,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,GAAG,EAAE,CAAA;YAC9B,CAAC;iBAAM,CAAC;gBACN,IAAI,UAAU,CAAC,OAAO,EAAE,CAAC;oBACvB,YAAY,CAAC,UAAU,CAAC,OAAO,CAAC,CAAA;gBAClC,CAAC;gBACD,UAAU,CAAC,OAAO,GAAG,UAAU,CAC7B,GAAG,EAAE;oBACH,QAAQ,CAAC,GAAG,IAAI,CAAC,CAAA;oBACjB,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,GAAG,EAAE,CAAA;gBAC9B,CAAC,EACD,KAAK,GAAG,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC,CACvC,CAAA;YACH,CAAC;QACH,CAAC,CAAA;QAED,OAAO,EAAE,CAAA;IACX,CAAC,EACD,CAAC,QAAQ,EAAE,KAAK,CAAC,CAClB,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/minimal-tiptap/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAA"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import './styles/index.css';
|
|
4
|
+
import { EditorContent } from '@tiptap/react';
|
|
5
|
+
import { Separator } from '../../components/ui/separator';
|
|
6
|
+
import { cn } from '../../lib/utils';
|
|
7
|
+
import { SectionOne } from './components/section/one';
|
|
8
|
+
import { SectionTwo } from './components/section/two';
|
|
9
|
+
import { SectionThree } from './components/section/three';
|
|
10
|
+
import { SectionFour } from './components/section/four';
|
|
11
|
+
import { SectionFive } from './components/section/five';
|
|
12
|
+
import { LinkBubbleMenu } from './components/bubble-menu/link-bubble-menu';
|
|
13
|
+
import { useMinimalTiptapEditor } from './hooks/use-minimal-tiptap';
|
|
14
|
+
import { MeasuredContainer } from './components/measured-container';
|
|
15
|
+
import SectionMailingPlaceholders from './components/section/mailingPlaceholders';
|
|
16
|
+
const MailingToolbar = ({ editor, placeholders }) => (_jsx("div", { className: 'shrink-0 overflow-x-auto border-b border-border p-2', children: _jsxs("div", { className: 'flex w-max items-center gap-px', children: [_jsx(SectionOne, { editor: editor, activeLevels: [1, 2, 3, 4, 5, 6] }), _jsx(Separator, { orientation: 'vertical', className: 'mx-2 h-7' }), _jsx(SectionTwo, { editor: editor, activeActions: ['bold', 'italic', 'underline', 'strikethrough', 'code', 'clearFormatting'], mainActionCount: 3 }), _jsx(Separator, { orientation: 'vertical', className: 'mx-2 h-7' }), _jsx(SectionThree, { editor: editor }), _jsx(Separator, { orientation: 'vertical', className: 'mx-2 h-7' }), _jsx(SectionFour, { editor: editor, activeActions: ['orderedList', 'bulletList'], mainActionCount: 0 }), _jsx(Separator, { orientation: 'vertical', className: 'mx-2 h-7' }), _jsx(SectionFive, { editor: editor, activeActions: ['codeBlock', 'blockquote', 'horizontalRule'], mainActionCount: 0 }), _jsx(Separator, { orientation: 'vertical', className: 'mx-2 h-7' }), _jsx(SectionMailingPlaceholders, { editor: editor, placeholders: placeholders })] }) }));
|
|
17
|
+
export const MailingTiptapEditor = React.forwardRef(({ value, onChange, className, editorContentClassName, placeholders, ...props }, ref) => {
|
|
18
|
+
const editor = useMinimalTiptapEditor({
|
|
19
|
+
value,
|
|
20
|
+
onUpdate: onChange,
|
|
21
|
+
...props,
|
|
22
|
+
});
|
|
23
|
+
if (!editor) {
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
return (_jsxs(MeasuredContainer, { as: 'div', name: 'editor', ref: ref, className: cn('flex h-auto min-h-72 w-full flex-col rounded-md border border-input shadow-sm focus-within:border-primary', className), children: [_jsx(MailingToolbar, { editor: editor, placeholders: placeholders }), _jsx(EditorContent, { editor: editor, className: cn('minimal-tiptap-editor', editorContentClassName) }), _jsx(LinkBubbleMenu, { editor: editor })] }));
|
|
27
|
+
});
|
|
28
|
+
MailingTiptapEditor.displayName = 'MailingTiptapEditor';
|
|
29
|
+
export default MailingTiptapEditor;
|
|
30
|
+
//# sourceMappingURL=mailing-tiptap.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mailing-tiptap.js","sourceRoot":"","sources":["../../../src/components/minimal-tiptap/mailing-tiptap.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,oBAAoB,CAAA;AAI3B,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAA;AACrD,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAA;AAChC,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAA;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAA;AACvD,OAAO,EAAE,WAAW,EAAE,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,gBAAgB,CAAC,EAC5D,eAAe,EAAE,CAAC,GAClB,EACF,KAAC,SAAS,IAAC,WAAW,EAAC,UAAU,EAAC,SAAS,EAAC,UAAU,GAAG,EAEzD,KAAC,0BAA0B,IAAC,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,YAAY,GAAI,IACtE,GACF,CACP,CAAA;AAED,MAAM,CAAC,MAAM,mBAAmB,GAAG,KAAK,CAAC,UAAU,CACjD,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,sBAAsB,EAAE,YAAY,EAAE,GAAG,KAAK,EAAE,EAAE,GAAG,EAAE,EAAE;IACtF,MAAM,MAAM,GAAG,sBAAsB,CAAC;QACpC,KAAK;QACL,QAAQ,EAAE,QAAQ;QAClB,GAAG,KAAK;KACT,CAAC,CAAA;IAEF,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,OAAO,IAAI,CAAA;IACb,CAAC;IAED,OAAO,CACL,MAAC,iBAAiB,IAChB,EAAE,EAAC,KAAK,EACR,IAAI,EAAC,QAAQ,EACb,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,EAAE,CACX,2GAA2G,EAC3G,SAAS,CACV,aAED,KAAC,cAAc,IAAC,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,YAAY,GAAI,EAC9D,KAAC,aAAa,IACZ,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,EAAE,CAAC,uBAAuB,EAAE,sBAAsB,CAAC,GAC9D,EACF,KAAC,cAAc,IAAC,MAAM,EAAE,MAAM,GAAI,IAChB,CACrB,CAAA;AACH,CAAC,CACF,CAAA;AAED,mBAAmB,CAAC,WAAW,GAAG,qBAAqB,CAAA;AAEvD,eAAe,mBAAmB,CAAA"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import './styles/index.css';
|
|
4
|
+
import { EditorContent } from '@tiptap/react';
|
|
5
|
+
import { Separator } from '../../components/ui/separator';
|
|
6
|
+
import { cn } from '../../lib/utils';
|
|
7
|
+
import { SectionOne } from './components/section/one';
|
|
8
|
+
import { SectionTwo } from './components/section/two';
|
|
9
|
+
import { SectionThree } from './components/section/three';
|
|
10
|
+
import { SectionFour } from './components/section/four';
|
|
11
|
+
import { SectionFive } from './components/section/five';
|
|
12
|
+
import { LinkBubbleMenu } from './components/bubble-menu/link-bubble-menu';
|
|
13
|
+
import { useMinimalTiptapEditor } from './hooks/use-minimal-tiptap';
|
|
14
|
+
import { MeasuredContainer } from './components/measured-container';
|
|
15
|
+
const Toolbar = ({ editor }) => (_jsx("div", { className: 'shrink-0 overflow-x-auto border-b border-border p-2', children: _jsxs("div", { className: 'flex w-max items-center gap-px', children: [_jsx(SectionOne, { editor: editor, activeLevels: [1, 2, 3, 4, 5, 6] }), _jsx(Separator, { orientation: 'vertical', className: 'mx-2 h-7' }), _jsx(SectionTwo, { editor: editor, activeActions: ['bold', 'italic', 'underline', 'strikethrough', 'code', 'clearFormatting'], mainActionCount: 3 }), _jsx(Separator, { orientation: 'vertical', className: 'mx-2 h-7' }), _jsx(SectionThree, { editor: editor }), _jsx(Separator, { orientation: 'vertical', className: 'mx-2 h-7' }), _jsx(SectionFour, { editor: editor, activeActions: ['orderedList', 'bulletList'], mainActionCount: 0 }), _jsx(Separator, { orientation: 'vertical', className: 'mx-2 h-7' }), _jsx(SectionFive, { editor: editor, activeActions: ['codeBlock', 'blockquote', 'horizontalRule'], mainActionCount: 0 })] }) }));
|
|
16
|
+
export const MinimalTiptapEditor = React.forwardRef(({ value, onChange, className, editorContentClassName, ...props }, ref) => {
|
|
17
|
+
const editor = useMinimalTiptapEditor({
|
|
18
|
+
value,
|
|
19
|
+
onUpdate: onChange,
|
|
20
|
+
...props,
|
|
21
|
+
});
|
|
22
|
+
if (!editor) {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
return (_jsxs(MeasuredContainer, { as: 'div', name: 'editor', ref: ref, className: cn('flex h-auto min-h-32 w-full flex-col rounded-md border border-input shadow-sm focus-within:border-primary', className), children: [_jsx(Toolbar, { editor: editor }), _jsx(EditorContent, { editor: editor, className: cn('minimal-tiptap-editor', editorContentClassName) }), _jsx(LinkBubbleMenu, { editor: editor })] }));
|
|
26
|
+
});
|
|
27
|
+
MinimalTiptapEditor.displayName = 'MinimalTiptapEditor';
|
|
28
|
+
export default MinimalTiptapEditor;
|
|
29
|
+
//# sourceMappingURL=minimal-tiptap.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"minimal-tiptap.js","sourceRoot":"","sources":["../../../src/components/minimal-tiptap/minimal-tiptap.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,oBAAoB,CAAA;AAI3B,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAA;AACrD,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAA;AAChC,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAA;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAA;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAA;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,2CAA2C,CAAA;AAC1E,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAA;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAA;AASnE,MAAM,OAAO,GAAG,CAAC,EAAE,MAAM,EAAsB,EAAE,EAAE,CAAC,CAClD,cAAK,SAAS,EAAC,qDAAqD,YAClE,eAAK,SAAS,EAAC,gCAAgC,aAC7C,KAAC,UAAU,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