@tumaet/prompt-ui-components 0.0.6 → 0.0.7
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/index.css +1044 -1
- package/package.json +2 -2
- package/dist/components/minimal-tiptap/components/bubble-menu/link-bubble-menu.js +0 -65
- package/dist/components/minimal-tiptap/components/bubble-menu/link-bubble-menu.js.map +0 -1
- package/dist/components/minimal-tiptap/components/image/image-edit-block.js +0 -38
- package/dist/components/minimal-tiptap/components/image/image-edit-block.js.map +0 -1
- package/dist/components/minimal-tiptap/components/image/image-edit-dialog.js +0 -12
- package/dist/components/minimal-tiptap/components/image/image-edit-dialog.js.map +0 -1
- package/dist/components/minimal-tiptap/components/link/link-edit-block.js +0 -34
- package/dist/components/minimal-tiptap/components/link/link-edit-block.js.map +0 -1
- package/dist/components/minimal-tiptap/components/link/link-edit-popover.js +0 -38
- package/dist/components/minimal-tiptap/components/link/link-edit-popover.js.map +0 -1
- package/dist/components/minimal-tiptap/components/link/link-popover-block.js +0 -28
- package/dist/components/minimal-tiptap/components/link/link-popover-block.js.map +0 -1
- package/dist/components/minimal-tiptap/components/measured-container.js +0 -16
- package/dist/components/minimal-tiptap/components/measured-container.js.map +0 -1
- package/dist/components/minimal-tiptap/components/section/five.js +0 -39
- package/dist/components/minimal-tiptap/components/section/five.js.map +0 -1
- package/dist/components/minimal-tiptap/components/section/four.js +0 -29
- package/dist/components/minimal-tiptap/components/section/four.js.map +0 -1
- package/dist/components/minimal-tiptap/components/section/mailingPlaceholders.js +0 -23
- package/dist/components/minimal-tiptap/components/section/mailingPlaceholders.js.map +0 -1
- package/dist/components/minimal-tiptap/components/section/one.js +0 -77
- package/dist/components/minimal-tiptap/components/section/one.js.map +0 -1
- package/dist/components/minimal-tiptap/components/section/three.js +0 -79
- package/dist/components/minimal-tiptap/components/section/three.js.map +0 -1
- package/dist/components/minimal-tiptap/components/section/two.js +0 -65
- package/dist/components/minimal-tiptap/components/section/two.js.map +0 -1
- package/dist/components/minimal-tiptap/components/shortcut-key.js +0 -11
- package/dist/components/minimal-tiptap/components/shortcut-key.js.map +0 -1
- package/dist/components/minimal-tiptap/components/spinner.js +0 -9
- package/dist/components/minimal-tiptap/components/spinner.js.map +0 -1
- package/dist/components/minimal-tiptap/components/toolbar-button.js +0 -15
- package/dist/components/minimal-tiptap/components/toolbar-button.js.map +0 -1
- package/dist/components/minimal-tiptap/components/toolbar-section.js +0 -27
- package/dist/components/minimal-tiptap/components/toolbar-section.js.map +0 -1
- package/dist/components/minimal-tiptap/extensions/code-block-lowlight/code-block-lowlight.js +0 -16
- package/dist/components/minimal-tiptap/extensions/code-block-lowlight/code-block-lowlight.js.map +0 -1
- package/dist/components/minimal-tiptap/extensions/code-block-lowlight/index.js +0 -2
- package/dist/components/minimal-tiptap/extensions/code-block-lowlight/index.js.map +0 -1
- package/dist/components/minimal-tiptap/extensions/color/color.js +0 -20
- package/dist/components/minimal-tiptap/extensions/color/color.js.map +0 -1
- package/dist/components/minimal-tiptap/extensions/color/index.js +0 -2
- package/dist/components/minimal-tiptap/extensions/color/index.js.map +0 -1
- package/dist/components/minimal-tiptap/extensions/file-handler/index.js +0 -74
- package/dist/components/minimal-tiptap/extensions/file-handler/index.js.map +0 -1
- package/dist/components/minimal-tiptap/extensions/horizontal-rule/horizontal-rule.js +0 -16
- package/dist/components/minimal-tiptap/extensions/horizontal-rule/horizontal-rule.js.map +0 -1
- package/dist/components/minimal-tiptap/extensions/horizontal-rule/index.js +0 -2
- package/dist/components/minimal-tiptap/extensions/horizontal-rule/index.js.map +0 -1
- package/dist/components/minimal-tiptap/extensions/image/components/image-actions.js +0 -39
- package/dist/components/minimal-tiptap/extensions/image/components/image-actions.js.map +0 -1
- package/dist/components/minimal-tiptap/extensions/image/components/image-overlay.js +0 -9
- package/dist/components/minimal-tiptap/extensions/image/components/image-overlay.js.map +0 -1
- package/dist/components/minimal-tiptap/extensions/image/components/image-view-block.js +0 -167
- package/dist/components/minimal-tiptap/extensions/image/components/image-view-block.js.map +0 -1
- package/dist/components/minimal-tiptap/extensions/image/components/resize-handle.js +0 -11
- package/dist/components/minimal-tiptap/extensions/image/components/resize-handle.js.map +0 -1
- package/dist/components/minimal-tiptap/extensions/image/hooks/use-drag-resize.js +0 -88
- package/dist/components/minimal-tiptap/extensions/image/hooks/use-drag-resize.js.map +0 -1
- package/dist/components/minimal-tiptap/extensions/image/hooks/use-image-actions.js +0 -32
- package/dist/components/minimal-tiptap/extensions/image/hooks/use-image-actions.js.map +0 -1
- package/dist/components/minimal-tiptap/extensions/image/image.js +0 -225
- package/dist/components/minimal-tiptap/extensions/image/image.js.map +0 -1
- package/dist/components/minimal-tiptap/extensions/image/index.js +0 -2
- package/dist/components/minimal-tiptap/extensions/image/index.js.map +0 -1
- package/dist/components/minimal-tiptap/extensions/index.js +0 -10
- package/dist/components/minimal-tiptap/extensions/index.js.map +0 -1
- package/dist/components/minimal-tiptap/extensions/link/index.js +0 -2
- package/dist/components/minimal-tiptap/extensions/link/index.js.map +0 -1
- package/dist/components/minimal-tiptap/extensions/link/link.js +0 -74
- package/dist/components/minimal-tiptap/extensions/link/link.js.map +0 -1
- package/dist/components/minimal-tiptap/extensions/reset-marks-on-enter/index.js +0 -2
- package/dist/components/minimal-tiptap/extensions/reset-marks-on-enter/index.js.map +0 -1
- package/dist/components/minimal-tiptap/extensions/reset-marks-on-enter/reset-marks-on-enter.js +0 -20
- package/dist/components/minimal-tiptap/extensions/reset-marks-on-enter/reset-marks-on-enter.js.map +0 -1
- package/dist/components/minimal-tiptap/extensions/selection/index.js +0 -2
- package/dist/components/minimal-tiptap/extensions/selection/index.js.map +0 -1
- package/dist/components/minimal-tiptap/extensions/selection/selection.js +0 -31
- package/dist/components/minimal-tiptap/extensions/selection/selection.js.map +0 -1
- package/dist/components/minimal-tiptap/extensions/unset-all-marks/index.js +0 -2
- package/dist/components/minimal-tiptap/extensions/unset-all-marks/index.js.map +0 -1
- package/dist/components/minimal-tiptap/extensions/unset-all-marks/unset-all-marks.js +0 -9
- package/dist/components/minimal-tiptap/extensions/unset-all-marks/unset-all-marks.js.map +0 -1
- package/dist/components/minimal-tiptap/form-description-tiptap.js +0 -26
- package/dist/components/minimal-tiptap/form-description-tiptap.js.map +0 -1
- package/dist/components/minimal-tiptap/hooks/use-container-size.js +0 -44
- package/dist/components/minimal-tiptap/hooks/use-container-size.js.map +0 -1
- package/dist/components/minimal-tiptap/hooks/use-minimal-tiptap.js +0 -160
- package/dist/components/minimal-tiptap/hooks/use-minimal-tiptap.js.map +0 -1
- package/dist/components/minimal-tiptap/hooks/use-theme.js +0 -19
- package/dist/components/minimal-tiptap/hooks/use-theme.js.map +0 -1
- package/dist/components/minimal-tiptap/hooks/use-throttle.js +0 -24
- package/dist/components/minimal-tiptap/hooks/use-throttle.js.map +0 -1
- package/dist/components/minimal-tiptap/index.js +0 -2
- package/dist/components/minimal-tiptap/index.js.map +0 -1
- package/dist/components/minimal-tiptap/mailing-tiptap.js +0 -30
- package/dist/components/minimal-tiptap/mailing-tiptap.js.map +0 -1
- package/dist/components/minimal-tiptap/minimal-tiptap.js +0 -29
- package/dist/components/minimal-tiptap/minimal-tiptap.js.map +0 -1
- package/dist/components/minimal-tiptap/types.js +0 -2
- package/dist/components/minimal-tiptap/types.js.map +0 -1
- package/dist/components/minimal-tiptap/utils.js +0 -156
- package/dist/components/minimal-tiptap/utils.js.map +0 -1
- package/dist/types/components/minimal-tiptap/components/bubble-menu/link-bubble-menu.d.ts +0 -7
- package/dist/types/components/minimal-tiptap/components/image/image-edit-block.d.ts +0 -8
- package/dist/types/components/minimal-tiptap/components/image/image-edit-dialog.d.ts +0 -8
- package/dist/types/components/minimal-tiptap/components/link/link-edit-block.d.ts +0 -9
- package/dist/types/components/minimal-tiptap/components/link/link-edit-popover.d.ts +0 -8
- package/dist/types/components/minimal-tiptap/components/link/link-popover-block.d.ts +0 -8
- package/dist/types/components/minimal-tiptap/components/measured-container.d.ts +0 -2
- package/dist/types/components/minimal-tiptap/components/section/five.d.ts +0 -12
- package/dist/types/components/minimal-tiptap/components/section/four.d.ts +0 -12
- package/dist/types/components/minimal-tiptap/components/section/mailingPlaceholders.d.ts +0 -10
- package/dist/types/components/minimal-tiptap/components/section/one.d.ts +0 -11
- package/dist/types/components/minimal-tiptap/components/section/three.d.ts +0 -9
- package/dist/types/components/minimal-tiptap/components/section/two.d.ts +0 -12
- package/dist/types/components/minimal-tiptap/components/shortcut-key.d.ts +0 -5
- package/dist/types/components/minimal-tiptap/components/spinner.d.ts +0 -5
- package/dist/types/components/minimal-tiptap/components/toolbar-button.d.ts +0 -10
- package/dist/types/components/minimal-tiptap/components/toolbar-section.d.ts +0 -16
- package/dist/types/components/minimal-tiptap/extensions/code-block-lowlight/code-block-lowlight.d.ts +0 -2
- package/dist/types/components/minimal-tiptap/extensions/code-block-lowlight/index.d.ts +0 -1
- package/dist/types/components/minimal-tiptap/extensions/color/color.d.ts +0 -1
- package/dist/types/components/minimal-tiptap/extensions/color/index.d.ts +0 -1
- package/dist/types/components/minimal-tiptap/extensions/file-handler/index.d.ts +0 -12
- package/dist/types/components/minimal-tiptap/extensions/horizontal-rule/horizontal-rule.d.ts +0 -2
- package/dist/types/components/minimal-tiptap/extensions/horizontal-rule/index.d.ts +0 -1
- package/dist/types/components/minimal-tiptap/extensions/image/components/image-actions.d.ts +0 -17
- package/dist/types/components/minimal-tiptap/extensions/image/components/image-overlay.d.ts +0 -2
- package/dist/types/components/minimal-tiptap/extensions/image/components/image-view-block.d.ts +0 -3
- package/dist/types/components/minimal-tiptap/extensions/image/components/resize-handle.d.ts +0 -6
- package/dist/types/components/minimal-tiptap/extensions/image/hooks/use-drag-resize.d.ts +0 -24
- package/dist/types/components/minimal-tiptap/extensions/image/hooks/use-image-actions.d.ts +0 -24
- package/dist/types/components/minimal-tiptap/extensions/image/image.d.ts +0 -52
- package/dist/types/components/minimal-tiptap/extensions/image/index.d.ts +0 -1
- package/dist/types/components/minimal-tiptap/extensions/index.d.ts +0 -9
- package/dist/types/components/minimal-tiptap/extensions/link/index.d.ts +0 -1
- package/dist/types/components/minimal-tiptap/extensions/link/link.d.ts +0 -2
- package/dist/types/components/minimal-tiptap/extensions/reset-marks-on-enter/index.d.ts +0 -1
- package/dist/types/components/minimal-tiptap/extensions/reset-marks-on-enter/reset-marks-on-enter.d.ts +0 -2
- package/dist/types/components/minimal-tiptap/extensions/selection/index.d.ts +0 -1
- package/dist/types/components/minimal-tiptap/extensions/selection/selection.d.ts +0 -3
- package/dist/types/components/minimal-tiptap/extensions/unset-all-marks/index.d.ts +0 -1
- package/dist/types/components/minimal-tiptap/extensions/unset-all-marks/unset-all-marks.d.ts +0 -2
- package/dist/types/components/minimal-tiptap/form-description-tiptap.d.ts +0 -4
- package/dist/types/components/minimal-tiptap/hooks/use-container-size.d.ts +0 -1
- package/dist/types/components/minimal-tiptap/hooks/use-minimal-tiptap.d.ts +0 -13
- package/dist/types/components/minimal-tiptap/hooks/use-theme.d.ts +0 -2
- package/dist/types/components/minimal-tiptap/hooks/use-throttle.d.ts +0 -1
- package/dist/types/components/minimal-tiptap/index.d.ts +0 -1
- package/dist/types/components/minimal-tiptap/mailing-tiptap.d.ts +0 -13
- package/dist/types/components/minimal-tiptap/minimal-tiptap.d.ts +0 -12
- package/dist/types/components/minimal-tiptap/types.d.ts +0 -25
- package/dist/types/components/minimal-tiptap/utils.d.ts +0 -38
|
@@ -1,44 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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,EAAE,CAAC;IACR,CAAC,EAAE,CAAC;IACJ,CAAC,EAAE,CAAC;IACJ,KAAK,EAAE,CAAC;IACR,MAAM,EAAE,CAAC;IACT,MAAM,E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9C,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"}
|
|
@@ -1,160 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"use-minimal-tiptap.js","sourceRoot":"","sources":["../../../../src/components/minimal-tiptap/hooks/use-minimal-tiptap.ts"],"names":[],"mappings":"AAAA,iD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AM,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"}
|
|
@@ -1,19 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,24 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/minimal-tiptap/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAA"}
|
|
@@ -1,30 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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,MAAM,2BAA2B,CAAA;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,2CAA2C,CAAA;AAC1E,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,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AEzD,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"}
|
|
@@ -1,29 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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,IAAC,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC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,EAAE,GAAG,EACR,SAAS,EAAE,EAAE,CACX,2GAA2G,EAC3G,SAAS,CACV,aAED,KAAC,OAAO,IAAC,MAAM,EAAE,MAAM,GAAI,EAC3B,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"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/components/minimal-tiptap/types.ts"],"names":[],"mappings":""}
|
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
export const isClient = () => typeof window !== 'undefined';
|
|
2
|
-
export const isServer = () => !isClient();
|
|
3
|
-
export const isMacOS = () => isClient() && window.navigator.platform === 'MacIntel';
|
|
4
|
-
const shortcutKeyMap = {
|
|
5
|
-
mod: isMacOS() ? { symbol: '⌘', readable: 'Command' } : { symbol: 'Ctrl', readable: 'Control' },
|
|
6
|
-
alt: isMacOS() ? { symbol: '⌥', readable: 'Option' } : { symbol: 'Alt', readable: 'Alt' },
|
|
7
|
-
shift: { symbol: '⇧', readable: 'Shift' }
|
|
8
|
-
};
|
|
9
|
-
export const getShortcutKey = (key) => shortcutKeyMap[key.toLowerCase()] || { symbol: key, readable: key };
|
|
10
|
-
export const getShortcutKeys = (keys) => keys.map(getShortcutKey);
|
|
11
|
-
export const getOutput = (editor, format) => {
|
|
12
|
-
switch (format) {
|
|
13
|
-
case 'json':
|
|
14
|
-
return editor.getJSON();
|
|
15
|
-
case 'html':
|
|
16
|
-
return editor.isEmpty ? '' : editor.getHTML();
|
|
17
|
-
default:
|
|
18
|
-
return editor.getText();
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
export const isUrl = (text, options = { requireHostname: false }) => {
|
|
22
|
-
if (text.includes('\n'))
|
|
23
|
-
return false;
|
|
24
|
-
try {
|
|
25
|
-
const url = new URL(text);
|
|
26
|
-
const blockedProtocols = ['javascript:', 'file:', 'vbscript:', ...(options.allowBase64 ? [] : ['data:'])];
|
|
27
|
-
if (blockedProtocols.includes(url.protocol))
|
|
28
|
-
return false;
|
|
29
|
-
if (options.allowBase64 && url.protocol === 'data:')
|
|
30
|
-
return /^data:image\/[a-z]+;base64,/.test(text);
|
|
31
|
-
if (url.hostname)
|
|
32
|
-
return true;
|
|
33
|
-
return (url.protocol !== '' &&
|
|
34
|
-
(url.pathname.startsWith('//') || url.pathname.startsWith('http')) &&
|
|
35
|
-
!options.requireHostname);
|
|
36
|
-
}
|
|
37
|
-
catch {
|
|
38
|
-
return false;
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
export const sanitizeUrl = (url, options = {}) => {
|
|
42
|
-
if (!url)
|
|
43
|
-
return undefined;
|
|
44
|
-
if (options.allowBase64 && url.startsWith('data:image')) {
|
|
45
|
-
return isUrl(url, { requireHostname: false, allowBase64: true }) ? url : undefined;
|
|
46
|
-
}
|
|
47
|
-
return isUrl(url, { requireHostname: false, allowBase64: options.allowBase64 }) ||
|
|
48
|
-
/^(\/|#|mailto:|sms:|fax:|tel:)/.test(url)
|
|
49
|
-
? url
|
|
50
|
-
: `https://${url}`;
|
|
51
|
-
};
|
|
52
|
-
export const blobUrlToBase64 = async (blobUrl) => {
|
|
53
|
-
const response = await fetch(blobUrl);
|
|
54
|
-
const blob = await response.blob();
|
|
55
|
-
return new Promise((resolve, reject) => {
|
|
56
|
-
const reader = new FileReader();
|
|
57
|
-
reader.onloadend = () => {
|
|
58
|
-
if (typeof reader.result === 'string') {
|
|
59
|
-
resolve(reader.result);
|
|
60
|
-
}
|
|
61
|
-
else {
|
|
62
|
-
reject(new Error('Failed to convert Blob to base64'));
|
|
63
|
-
}
|
|
64
|
-
};
|
|
65
|
-
reader.onerror = reject;
|
|
66
|
-
reader.readAsDataURL(blob);
|
|
67
|
-
});
|
|
68
|
-
};
|
|
69
|
-
export const randomId = () => Math.random().toString(36).slice(2, 11);
|
|
70
|
-
export const fileToBase64 = (file) => {
|
|
71
|
-
return new Promise((resolve, reject) => {
|
|
72
|
-
const reader = new FileReader();
|
|
73
|
-
reader.onloadend = () => {
|
|
74
|
-
if (typeof reader.result === 'string') {
|
|
75
|
-
resolve(reader.result);
|
|
76
|
-
}
|
|
77
|
-
else {
|
|
78
|
-
reject(new Error('Failed to convert File to base64'));
|
|
79
|
-
}
|
|
80
|
-
};
|
|
81
|
-
reader.onerror = reject;
|
|
82
|
-
reader.readAsDataURL(file);
|
|
83
|
-
});
|
|
84
|
-
};
|
|
85
|
-
const validateFileOrBase64 = (input, options, originalFile, validFiles, errors) => {
|
|
86
|
-
const { isValidType, isValidSize } = checkTypeAndSize(input, options);
|
|
87
|
-
if (isValidType && isValidSize) {
|
|
88
|
-
validFiles.push(originalFile);
|
|
89
|
-
}
|
|
90
|
-
else {
|
|
91
|
-
if (!isValidType)
|
|
92
|
-
errors.push({ file: input, reason: 'type' });
|
|
93
|
-
if (!isValidSize)
|
|
94
|
-
errors.push({ file: input, reason: 'size' });
|
|
95
|
-
}
|
|
96
|
-
};
|
|
97
|
-
const checkTypeAndSize = (input, { allowedMimeTypes, maxFileSize }) => {
|
|
98
|
-
const mimeType = input instanceof File ? input.type : base64MimeType(input);
|
|
99
|
-
const size = input instanceof File ? input.size : atob(input.split(',')[1]).length;
|
|
100
|
-
const isValidType = allowedMimeTypes.length === 0 ||
|
|
101
|
-
allowedMimeTypes.includes(mimeType) ||
|
|
102
|
-
allowedMimeTypes.includes(`${mimeType.split('/')[0]}/*`);
|
|
103
|
-
const isValidSize = !maxFileSize || size <= maxFileSize;
|
|
104
|
-
return { isValidType, isValidSize };
|
|
105
|
-
};
|
|
106
|
-
const base64MimeType = (encoded) => {
|
|
107
|
-
const result = encoded.match(/data:([a-zA-Z0-9]+\/[a-zA-Z0-9-.+]+).*,.*/);
|
|
108
|
-
return result && result.length > 1 ? result[1] : 'unknown';
|
|
109
|
-
};
|
|
110
|
-
const isBase64 = (str) => {
|
|
111
|
-
if (str.startsWith('data:')) {
|
|
112
|
-
const matches = str.match(/^data:[^;]+;base64,(.+)$/);
|
|
113
|
-
if (matches && matches[1]) {
|
|
114
|
-
str = matches[1];
|
|
115
|
-
}
|
|
116
|
-
else {
|
|
117
|
-
return false;
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
try {
|
|
121
|
-
return btoa(atob(str)) === str;
|
|
122
|
-
}
|
|
123
|
-
catch {
|
|
124
|
-
return false;
|
|
125
|
-
}
|
|
126
|
-
};
|
|
127
|
-
export const filterFiles = (files, options) => {
|
|
128
|
-
const validFiles = [];
|
|
129
|
-
const errors = [];
|
|
130
|
-
files.forEach(file => {
|
|
131
|
-
const actualFile = 'src' in file ? file.src : file;
|
|
132
|
-
if (actualFile instanceof File) {
|
|
133
|
-
validateFileOrBase64(actualFile, options, file, validFiles, errors);
|
|
134
|
-
}
|
|
135
|
-
else if (typeof actualFile === 'string') {
|
|
136
|
-
if (isBase64(actualFile)) {
|
|
137
|
-
if (options.allowBase64) {
|
|
138
|
-
validateFileOrBase64(actualFile, options, file, validFiles, errors);
|
|
139
|
-
}
|
|
140
|
-
else {
|
|
141
|
-
errors.push({ file: actualFile, reason: 'base64NotAllowed' });
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
else {
|
|
145
|
-
if (!sanitizeUrl(actualFile, { allowBase64: options.allowBase64 })) {
|
|
146
|
-
errors.push({ file: actualFile, reason: 'invalidBase64' });
|
|
147
|
-
}
|
|
148
|
-
else {
|
|
149
|
-
validFiles.push(file);
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
});
|
|
154
|
-
return [validFiles, errors];
|
|
155
|
-
};
|
|
156
|
-
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +0,0 @@
|
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I,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,kBAAkB,EAAE,CAAC,CAAA;gBAC/D,CAAC;YACH,CAAC;iBAAM,CAAC;gBACN,IAAI,CAAC,WAAW,CAAC,UAAU,EAAE,EAAE,WAAW,EAAE,OAAO,CAAC,WAAW,EAAE,CAAC,EAAE,CAAC;oBACnE,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,eAAe,EAAE,CAAC,CAAA;gBAC5D,CAAC;qBAAM,CAAC;oBACN,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;gBACvB,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC,CAAC,CAAA;IAEF,OAAO,CAAC,UAAU,EAAE,MAAM,CAAC,CAAA;AAC7B,CAAC,CAAA"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { Editor } from '@tiptap/react';
|
|
2
|
-
import type { VariantProps } from 'class-variance-authority';
|
|
3
|
-
import type { toggleVariants } from '../../../../../components/ui/toggle';
|
|
4
|
-
interface ImageEditDialogProps extends VariantProps<typeof toggleVariants> {
|
|
5
|
-
editor: Editor;
|
|
6
|
-
}
|
|
7
|
-
declare const ImageEditDialog: ({ editor, size, variant }: ImageEditDialogProps) => import("react/jsx-runtime").JSX.Element;
|
|
8
|
-
export { ImageEditDialog };
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
export interface LinkEditorProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
3
|
-
defaultUrl?: string;
|
|
4
|
-
defaultText?: string;
|
|
5
|
-
defaultIsNewTab?: boolean;
|
|
6
|
-
onSave: (url: string, text?: string, isNewTab?: boolean) => void;
|
|
7
|
-
}
|
|
8
|
-
export declare const LinkEditBlock: React.ForwardRefExoticComponent<LinkEditorProps & React.RefAttributes<HTMLDivElement>>;
|
|
9
|
-
export default LinkEditBlock;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { Editor } from '@tiptap/react';
|
|
2
|
-
import type { VariantProps } from 'class-variance-authority';
|
|
3
|
-
import type { toggleVariants } from '../../../../../components/ui/toggle';
|
|
4
|
-
interface LinkEditPopoverProps extends VariantProps<typeof toggleVariants> {
|
|
5
|
-
editor: Editor;
|
|
6
|
-
}
|
|
7
|
-
declare const LinkEditPopover: ({ editor, size, variant }: LinkEditPopoverProps) => import("react/jsx-runtime").JSX.Element;
|
|
8
|
-
export { LinkEditPopover };
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import type { Editor } from '@tiptap/react';
|
|
3
|
-
import type { toggleVariants } from '../../../../../components/ui/toggle';
|
|
4
|
-
import type { VariantProps } from 'class-variance-authority';
|
|
5
|
-
type InsertElementAction = 'codeBlock' | 'blockquote' | 'horizontalRule';
|
|
6
|
-
interface SectionFiveProps extends VariantProps<typeof toggleVariants> {
|
|
7
|
-
editor: Editor;
|
|
8
|
-
activeActions?: InsertElementAction[];
|
|
9
|
-
mainActionCount?: number;
|
|
10
|
-
}
|
|
11
|
-
export declare const SectionFive: React.FC<SectionFiveProps>;
|
|
12
|
-
export default SectionFive;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import type { Editor } from '@tiptap/react';
|
|
3
|
-
import type { toggleVariants } from '../../../../../components/ui/toggle';
|
|
4
|
-
import type { VariantProps } from 'class-variance-authority';
|
|
5
|
-
type ListItemAction = 'orderedList' | 'bulletList';
|
|
6
|
-
interface SectionFourProps extends VariantProps<typeof toggleVariants> {
|
|
7
|
-
editor: Editor;
|
|
8
|
-
activeActions?: ListItemAction[];
|
|
9
|
-
mainActionCount?: number;
|
|
10
|
-
}
|
|
11
|
-
export declare const SectionFour: React.FC<SectionFourProps>;
|
|
12
|
-
export default SectionFour;
|