@tnd028/strapi-plugin-tiptap-editor 0.0.1
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/README.md +3 -0
- package/dist/_chunks/Alignment-B0f2-LO0.js +135 -0
- package/dist/_chunks/Alignment-qMOzO-n2.mjs +133 -0
- package/dist/_chunks/Blockquote-9wBGDz3L.mjs +34 -0
- package/dist/_chunks/Blockquote-DeGUfK27.js +36 -0
- package/dist/_chunks/Bold-C-0g6Ayd.mjs +46 -0
- package/dist/_chunks/Bold-ClnPsPHt.js +48 -0
- package/dist/_chunks/ColorAndHighlight-BMmtoSpj.js +217 -0
- package/dist/_chunks/ColorAndHighlight-t1Ui5tcL.mjs +215 -0
- package/dist/_chunks/Emoji-Bm1_vSh5.mjs +263 -0
- package/dist/_chunks/Emoji-C-LQZ4Z3.js +265 -0
- package/dist/_chunks/Heading-BDJqd1Qw.js +125 -0
- package/dist/_chunks/Heading-BycRob5M.mjs +123 -0
- package/dist/_chunks/HorizontalRule-CJlDmdma.js +34 -0
- package/dist/_chunks/HorizontalRule-CzQCeC3b.mjs +32 -0
- package/dist/_chunks/Iframe-DCBWSb0v.mjs +165 -0
- package/dist/_chunks/Iframe-Dyn_2cMB.js +167 -0
- package/dist/_chunks/ImagePlaceholder-C14kojd5.js +71 -0
- package/dist/_chunks/ImagePlaceholder-DtrSuhf_.mjs +69 -0
- package/dist/_chunks/Italic-BfpKX0KX.mjs +34 -0
- package/dist/_chunks/Italic-DdhVL78v.js +36 -0
- package/dist/_chunks/Link-BuYDqSqo.js +61 -0
- package/dist/_chunks/Link-DUV5Ybep.mjs +59 -0
- package/dist/_chunks/Lists-BKopoFR6.js +107 -0
- package/dist/_chunks/Lists-DsKxj3MD.mjs +105 -0
- package/dist/_chunks/Redo-1mEX1yOd.js +35 -0
- package/dist/_chunks/Redo-Ca3VQxSe.mjs +33 -0
- package/dist/_chunks/SearchAndReplace-DmU5DlWv.mjs +347 -0
- package/dist/_chunks/SearchAndReplace-DzNdbTWJ.js +349 -0
- package/dist/_chunks/Strikethrough-BygxCHak.mjs +121 -0
- package/dist/_chunks/Strikethrough-DQfR4OFk.js +123 -0
- package/dist/_chunks/Table-BhbZ2Blv.mjs +123 -0
- package/dist/_chunks/Table-DLaqBAbz.js +125 -0
- package/dist/_chunks/TiptapEditorInput-BDE09h5-.mjs +6802 -0
- package/dist/_chunks/TiptapEditorInput-vfLsCt1p.js +6854 -0
- package/dist/_chunks/Undo-BuT4OkoE.js +32 -0
- package/dist/_chunks/Undo-PL5n4axf.mjs +30 -0
- package/dist/_chunks/en-B4KWt_jN.js +4 -0
- package/dist/_chunks/en-Byx4XI2L.mjs +4 -0
- package/dist/_chunks/index-ku90UbIF.mjs +1397 -0
- package/dist/_chunks/index-wYDv8vsJ.js +1398 -0
- package/dist/admin/index.js +6 -0
- package/dist/admin/index.mjs +6 -0
- package/dist/admin/src/components/ContentEditorInput.d.ts +10 -0
- package/dist/admin/src/components/GlobalStyling.d.ts +4 -0
- package/dist/admin/src/components/Initializer.d.ts +5 -0
- package/dist/admin/src/components/MediaLibraryModal.d.ts +27 -0
- package/dist/admin/src/components/PluginIcon.d.ts +2 -0
- package/dist/admin/src/components/TextEditorInput.d.ts +10 -0
- package/dist/admin/src/components/TiptapEditorInput.d.ts +6 -0
- package/dist/admin/src/components/editor/BaseEditor.d.ts +22 -0
- package/dist/admin/src/components/editor/ContentEditor.d.ts +10 -0
- package/dist/admin/src/components/editor/TextEditor.d.ts +10 -0
- package/dist/admin/src/components/editor/extensions/Heading.d.ts +2 -0
- package/dist/admin/src/components/editor/extensions/Iframe.d.ts +24 -0
- package/dist/admin/src/components/editor/extensions/Image.d.ts +3 -0
- package/dist/admin/src/components/editor/extensions/ImagePlaceholder.d.ts +15 -0
- package/dist/admin/src/components/editor/extensions/custom-component/CustomComponentEditPopover.d.ts +1 -0
- package/dist/admin/src/components/editor/extensions/custom-component/CustomComponentExtension.d.ts +3 -0
- package/dist/admin/src/components/editor/extensions/custom-component/CustomComponentInsertPopover.d.ts +13 -0
- package/dist/admin/src/components/editor/extensions/custom-component/CustomComponentRenderer.d.ts +1 -0
- package/dist/admin/src/components/editor/extensions/custom-component/Store.d.ts +20 -0
- package/dist/admin/src/components/editor/extensions/custom-component/types.d.ts +33 -0
- package/dist/admin/src/components/editor/extensions/fileHandler.d.ts +12 -0
- package/dist/admin/src/components/editor/extensions/link.d.ts +1 -0
- package/dist/admin/src/components/editor/extensions/noNewLine.d.ts +2 -0
- package/dist/admin/src/components/editor/extensions/resetMarksOnEnter.d.ts +2 -0
- package/dist/admin/src/components/editor/extensions/searchAndReplace.d.ts +53 -0
- package/dist/admin/src/components/editor/partials/EditorProvider.d.ts +13 -0
- package/dist/admin/src/components/editor/partials/LinkBubbleMenu.d.ts +5 -0
- package/dist/admin/src/components/editor/partials/LinkEditBlock.d.ts +9 -0
- package/dist/admin/src/components/editor/partials/LinkPopoverBlock.d.ts +8 -0
- package/dist/admin/src/components/editor/partials/ToolbarButton.d.ts +11 -0
- package/dist/admin/src/components/editor/partials/ToolbarButtons.d.ts +25 -0
- package/dist/admin/src/components/editor/toolbars/Alignment.d.ts +1 -0
- package/dist/admin/src/components/editor/toolbars/Blockquote.d.ts +4 -0
- package/dist/admin/src/components/editor/toolbars/Bold.d.ts +4 -0
- package/dist/admin/src/components/editor/toolbars/BulletList.d.ts +4 -0
- package/dist/admin/src/components/editor/toolbars/ColorAndHighlight.d.ts +5 -0
- package/dist/admin/src/components/editor/toolbars/Emoji.d.ts +4 -0
- package/dist/admin/src/components/editor/toolbars/Heading.d.ts +1 -0
- package/dist/admin/src/components/editor/toolbars/HorizontalRule.d.ts +4 -0
- package/dist/admin/src/components/editor/toolbars/Iframe.d.ts +3 -0
- package/dist/admin/src/components/editor/toolbars/ImagePlaceholder.d.ts +4 -0
- package/dist/admin/src/components/editor/toolbars/Italic.d.ts +4 -0
- package/dist/admin/src/components/editor/toolbars/Link.d.ts +4 -0
- package/dist/admin/src/components/editor/toolbars/Lists.d.ts +1 -0
- package/dist/admin/src/components/editor/toolbars/OrderedList.d.ts +4 -0
- package/dist/admin/src/components/editor/toolbars/Redo.d.ts +4 -0
- package/dist/admin/src/components/editor/toolbars/SearchAndReplace.d.ts +1 -0
- package/dist/admin/src/components/editor/toolbars/Strikethrough.d.ts +4 -0
- package/dist/admin/src/components/editor/toolbars/Table.d.ts +1 -0
- package/dist/admin/src/components/editor/toolbars/Undo.d.ts +4 -0
- package/dist/admin/src/components/editor/useEditor.d.ts +18 -0
- package/dist/admin/src/components/editor/utils.d.ts +28 -0
- package/dist/admin/src/components/ui/button.d.ts +9 -0
- package/dist/admin/src/components/ui/dropdown-menu.d.ts +27 -0
- package/dist/admin/src/components/ui/input.d.ts +6 -0
- package/dist/admin/src/components/ui/label.d.ts +7 -0
- package/dist/admin/src/components/ui/separator.d.ts +7 -0
- package/dist/admin/src/components/ui/toggle.d.ts +17 -0
- package/dist/admin/src/components/ui/tooltip.d.ts +7 -0
- package/dist/admin/src/config/index.d.ts +2 -0
- package/dist/admin/src/config/pluginConfig.d.ts +20 -0
- package/dist/admin/src/config/types.d.ts +109 -0
- package/dist/admin/src/errorSlicer.d.ts +4 -0
- package/dist/admin/src/exports.d.ts +4 -0
- package/dist/admin/src/hooks/useDebounceCallback.d.ts +9 -0
- package/dist/admin/src/index.d.ts +25 -0
- package/dist/admin/src/pluginId.d.ts +5 -0
- package/dist/admin/src/theme/additional.d.ts +1 -0
- package/dist/admin/src/theme/colorScheme.d.ts +2 -0
- package/dist/admin/src/theme/colors.d.ts +1 -0
- package/dist/admin/src/theme/common.d.ts +1 -0
- package/dist/admin/src/theme/index.d.ts +2 -0
- package/dist/admin/src/types.d.ts +15 -0
- package/dist/admin/src/utils/dom.d.ts +7 -0
- package/dist/admin/src/utils/getTranslation.d.ts +7 -0
- package/dist/admin/src/utils/isImageResponsive.d.ts +8 -0
- package/dist/admin/src/utils/localStorage.d.ts +21 -0
- package/dist/admin/src/utils/prefixWithBackendUrl.d.ts +6 -0
- package/dist/admin/src/utils/utils.d.ts +7 -0
- package/dist/server/index.js +15 -0
- package/dist/server/index.mjs +16 -0
- package/dist/server/src/index.d.ts +7 -0
- package/package.json +116 -0
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Popover, Typography, Grid } from "@strapi/design-system";
|
|
3
|
+
import { Youtube } from "lucide-react";
|
|
4
|
+
import { forwardRef, useState, useCallback } from "react";
|
|
5
|
+
import styled from "styled-components";
|
|
6
|
+
import { u as useEditorContext, T as ToolbarButton } from "./TiptapEditorInput-BDE09h5-.mjs";
|
|
7
|
+
const IframeIcon = styled(Youtube)`
|
|
8
|
+
width: 20px;
|
|
9
|
+
height: 20px;
|
|
10
|
+
`;
|
|
11
|
+
const PopoverContent = styled(Popover.Content)`
|
|
12
|
+
width: 100%;
|
|
13
|
+
min-width: 360px;
|
|
14
|
+
padding: 12px;
|
|
15
|
+
`;
|
|
16
|
+
const FormGroup = styled.div`
|
|
17
|
+
display: flex;
|
|
18
|
+
flex-direction: column;
|
|
19
|
+
gap: 10px;
|
|
20
|
+
margin-bottom: 6px;
|
|
21
|
+
`;
|
|
22
|
+
const Label = styled.label`
|
|
23
|
+
font-size: 13px;
|
|
24
|
+
font-weight: 500;
|
|
25
|
+
color: ${(props) => props.theme.colors.neutral700};
|
|
26
|
+
`;
|
|
27
|
+
const Input = styled.input`
|
|
28
|
+
border: 1px solid ${(props) => props.theme.colors.neutral200};
|
|
29
|
+
border-radius: 4px;
|
|
30
|
+
padding: 6px 8px;
|
|
31
|
+
font-size: 14px;
|
|
32
|
+
width: 100%;
|
|
33
|
+
&:focus {
|
|
34
|
+
outline: none;
|
|
35
|
+
border-color: ${(props) => props.theme.colors.primary500};
|
|
36
|
+
}
|
|
37
|
+
`;
|
|
38
|
+
const ButtonRow = styled.div`
|
|
39
|
+
display: flex;
|
|
40
|
+
justify-content: flex-end;
|
|
41
|
+
margin-top: 8px;
|
|
42
|
+
gap: 8px;
|
|
43
|
+
`;
|
|
44
|
+
const SmallButton = styled.button`
|
|
45
|
+
padding: 6px 12px;
|
|
46
|
+
border-radius: 4px;
|
|
47
|
+
font-size: 13px;
|
|
48
|
+
cursor: pointer;
|
|
49
|
+
border: none;
|
|
50
|
+
background-color: ${({ variant, theme }) => variant === "primary" ? theme.colors.primary600 : theme.colors.neutral100};
|
|
51
|
+
color: ${({ variant, theme }) => variant === "primary" ? theme.colors.neutral0 : theme.colors.neutral700};
|
|
52
|
+
|
|
53
|
+
&:hover {
|
|
54
|
+
opacity: 0.9;
|
|
55
|
+
}
|
|
56
|
+
`;
|
|
57
|
+
const IframeToolbar = forwardRef(
|
|
58
|
+
({ className, onClick, children, ...props }, ref) => {
|
|
59
|
+
const { editor } = useEditorContext();
|
|
60
|
+
const [open, setOpen] = useState(false);
|
|
61
|
+
const [src, setSrc] = useState("");
|
|
62
|
+
const [width, setWidth] = useState("560");
|
|
63
|
+
const [height, setHeight] = useState("315");
|
|
64
|
+
const [allowFullscreen, setAllowFullscreen] = useState(true);
|
|
65
|
+
const [error, setError] = useState("");
|
|
66
|
+
const onInsertIframe = useCallback(() => {
|
|
67
|
+
if (!src) {
|
|
68
|
+
setError("Please enter a URL");
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
try {
|
|
72
|
+
new URL(src);
|
|
73
|
+
} catch (e) {
|
|
74
|
+
setError("Invalid URL format.");
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
editor?.chain().focus().setIframe({
|
|
78
|
+
src,
|
|
79
|
+
width,
|
|
80
|
+
height,
|
|
81
|
+
allowfullscreen: allowFullscreen,
|
|
82
|
+
frameborder: 0
|
|
83
|
+
}).run();
|
|
84
|
+
setOpen(false);
|
|
85
|
+
setSrc("");
|
|
86
|
+
setError("");
|
|
87
|
+
}, [editor, src, width, height, allowFullscreen]);
|
|
88
|
+
return /* @__PURE__ */ jsxs(Popover.Root, { open, onOpenChange: setOpen, children: [
|
|
89
|
+
/* @__PURE__ */ jsx(Popover.Trigger, { children: /* @__PURE__ */ jsx(
|
|
90
|
+
ToolbarButton,
|
|
91
|
+
{
|
|
92
|
+
tooltip: "Insert Iframe",
|
|
93
|
+
"aria-label": "Insert Iframe",
|
|
94
|
+
isActive: editor?.isActive("iframe"),
|
|
95
|
+
...props,
|
|
96
|
+
ref,
|
|
97
|
+
children: /* @__PURE__ */ jsx(IframeIcon, {})
|
|
98
|
+
}
|
|
99
|
+
) }),
|
|
100
|
+
/* @__PURE__ */ jsxs(PopoverContent, { align: "start", side: "bottom", children: [
|
|
101
|
+
/* @__PURE__ */ jsxs(FormGroup, { children: [
|
|
102
|
+
/* @__PURE__ */ jsx(Label, { children: "Iframe Source (URL)" }),
|
|
103
|
+
/* @__PURE__ */ jsx(
|
|
104
|
+
Input,
|
|
105
|
+
{
|
|
106
|
+
type: "url",
|
|
107
|
+
placeholder: "https://www.youtube.com/embed/xxxx",
|
|
108
|
+
value: src,
|
|
109
|
+
onChange: (e) => {
|
|
110
|
+
setSrc(e.target.value);
|
|
111
|
+
if (error) setError("");
|
|
112
|
+
},
|
|
113
|
+
style: { borderColor: error ? "#d02b20" : void 0 }
|
|
114
|
+
}
|
|
115
|
+
),
|
|
116
|
+
error && /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "danger600", children: error })
|
|
117
|
+
] }),
|
|
118
|
+
/* @__PURE__ */ jsxs(Grid.Root, { gap: 6, children: [
|
|
119
|
+
/* @__PURE__ */ jsx(Grid.Item, { xs: 6, children: /* @__PURE__ */ jsxs(FormGroup, { children: [
|
|
120
|
+
/* @__PURE__ */ jsx(Label, { children: "Width (px)" }),
|
|
121
|
+
/* @__PURE__ */ jsx(
|
|
122
|
+
Input,
|
|
123
|
+
{
|
|
124
|
+
type: "number",
|
|
125
|
+
value: width,
|
|
126
|
+
onChange: (e) => setWidth(e.target.value)
|
|
127
|
+
}
|
|
128
|
+
)
|
|
129
|
+
] }) }),
|
|
130
|
+
/* @__PURE__ */ jsx(Grid.Item, { xs: 6, children: /* @__PURE__ */ jsxs(FormGroup, { children: [
|
|
131
|
+
/* @__PURE__ */ jsx(Label, { children: "Height (px)" }),
|
|
132
|
+
/* @__PURE__ */ jsx(
|
|
133
|
+
Input,
|
|
134
|
+
{
|
|
135
|
+
type: "number",
|
|
136
|
+
value: height,
|
|
137
|
+
onChange: (e) => setHeight(e.target.value)
|
|
138
|
+
}
|
|
139
|
+
)
|
|
140
|
+
] }) })
|
|
141
|
+
] }),
|
|
142
|
+
/* @__PURE__ */ jsx(FormGroup, { children: /* @__PURE__ */ jsxs("label", { style: { fontSize: "13px", display: "flex", alignItems: "center" }, children: [
|
|
143
|
+
/* @__PURE__ */ jsx(
|
|
144
|
+
"input",
|
|
145
|
+
{
|
|
146
|
+
type: "checkbox",
|
|
147
|
+
checked: allowFullscreen,
|
|
148
|
+
onChange: (e) => setAllowFullscreen(e.target.checked),
|
|
149
|
+
style: { marginRight: "6px" }
|
|
150
|
+
}
|
|
151
|
+
),
|
|
152
|
+
"Allow Fullscreen"
|
|
153
|
+
] }) }),
|
|
154
|
+
/* @__PURE__ */ jsxs(ButtonRow, { children: [
|
|
155
|
+
/* @__PURE__ */ jsx(SmallButton, { onClick: () => setOpen(false), children: "Cancel" }),
|
|
156
|
+
/* @__PURE__ */ jsx(SmallButton, { variant: "primary", onClick: onInsertIframe, children: "Insert" })
|
|
157
|
+
] })
|
|
158
|
+
] })
|
|
159
|
+
] });
|
|
160
|
+
}
|
|
161
|
+
);
|
|
162
|
+
IframeToolbar.displayName = "IframeToolbar";
|
|
163
|
+
export {
|
|
164
|
+
IframeToolbar
|
|
165
|
+
};
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const jsxRuntime = require("react/jsx-runtime");
|
|
4
|
+
const designSystem = require("@strapi/design-system");
|
|
5
|
+
const lucideReact = require("lucide-react");
|
|
6
|
+
const React = require("react");
|
|
7
|
+
const styled = require("styled-components");
|
|
8
|
+
const TiptapEditorInput = require("./TiptapEditorInput-vfLsCt1p.js");
|
|
9
|
+
const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
|
|
10
|
+
const styled__default = /* @__PURE__ */ _interopDefault(styled);
|
|
11
|
+
const IframeIcon = styled__default.default(lucideReact.Youtube)`
|
|
12
|
+
width: 20px;
|
|
13
|
+
height: 20px;
|
|
14
|
+
`;
|
|
15
|
+
const PopoverContent = styled__default.default(designSystem.Popover.Content)`
|
|
16
|
+
width: 100%;
|
|
17
|
+
min-width: 360px;
|
|
18
|
+
padding: 12px;
|
|
19
|
+
`;
|
|
20
|
+
const FormGroup = styled__default.default.div`
|
|
21
|
+
display: flex;
|
|
22
|
+
flex-direction: column;
|
|
23
|
+
gap: 10px;
|
|
24
|
+
margin-bottom: 6px;
|
|
25
|
+
`;
|
|
26
|
+
const Label = styled__default.default.label`
|
|
27
|
+
font-size: 13px;
|
|
28
|
+
font-weight: 500;
|
|
29
|
+
color: ${(props) => props.theme.colors.neutral700};
|
|
30
|
+
`;
|
|
31
|
+
const Input = styled__default.default.input`
|
|
32
|
+
border: 1px solid ${(props) => props.theme.colors.neutral200};
|
|
33
|
+
border-radius: 4px;
|
|
34
|
+
padding: 6px 8px;
|
|
35
|
+
font-size: 14px;
|
|
36
|
+
width: 100%;
|
|
37
|
+
&:focus {
|
|
38
|
+
outline: none;
|
|
39
|
+
border-color: ${(props) => props.theme.colors.primary500};
|
|
40
|
+
}
|
|
41
|
+
`;
|
|
42
|
+
const ButtonRow = styled__default.default.div`
|
|
43
|
+
display: flex;
|
|
44
|
+
justify-content: flex-end;
|
|
45
|
+
margin-top: 8px;
|
|
46
|
+
gap: 8px;
|
|
47
|
+
`;
|
|
48
|
+
const SmallButton = styled__default.default.button`
|
|
49
|
+
padding: 6px 12px;
|
|
50
|
+
border-radius: 4px;
|
|
51
|
+
font-size: 13px;
|
|
52
|
+
cursor: pointer;
|
|
53
|
+
border: none;
|
|
54
|
+
background-color: ${({ variant, theme }) => variant === "primary" ? theme.colors.primary600 : theme.colors.neutral100};
|
|
55
|
+
color: ${({ variant, theme }) => variant === "primary" ? theme.colors.neutral0 : theme.colors.neutral700};
|
|
56
|
+
|
|
57
|
+
&:hover {
|
|
58
|
+
opacity: 0.9;
|
|
59
|
+
}
|
|
60
|
+
`;
|
|
61
|
+
const IframeToolbar = React.forwardRef(
|
|
62
|
+
({ className, onClick, children, ...props }, ref) => {
|
|
63
|
+
const { editor } = TiptapEditorInput.useEditorContext();
|
|
64
|
+
const [open, setOpen] = React.useState(false);
|
|
65
|
+
const [src, setSrc] = React.useState("");
|
|
66
|
+
const [width, setWidth] = React.useState("560");
|
|
67
|
+
const [height, setHeight] = React.useState("315");
|
|
68
|
+
const [allowFullscreen, setAllowFullscreen] = React.useState(true);
|
|
69
|
+
const [error, setError] = React.useState("");
|
|
70
|
+
const onInsertIframe = React.useCallback(() => {
|
|
71
|
+
if (!src) {
|
|
72
|
+
setError("Please enter a URL");
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
try {
|
|
76
|
+
new URL(src);
|
|
77
|
+
} catch (e) {
|
|
78
|
+
setError("Invalid URL format.");
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
editor?.chain().focus().setIframe({
|
|
82
|
+
src,
|
|
83
|
+
width,
|
|
84
|
+
height,
|
|
85
|
+
allowfullscreen: allowFullscreen,
|
|
86
|
+
frameborder: 0
|
|
87
|
+
}).run();
|
|
88
|
+
setOpen(false);
|
|
89
|
+
setSrc("");
|
|
90
|
+
setError("");
|
|
91
|
+
}, [editor, src, width, height, allowFullscreen]);
|
|
92
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Popover.Root, { open, onOpenChange: setOpen, children: [
|
|
93
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Popover.Trigger, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
94
|
+
TiptapEditorInput.ToolbarButton,
|
|
95
|
+
{
|
|
96
|
+
tooltip: "Insert Iframe",
|
|
97
|
+
"aria-label": "Insert Iframe",
|
|
98
|
+
isActive: editor?.isActive("iframe"),
|
|
99
|
+
...props,
|
|
100
|
+
ref,
|
|
101
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(IframeIcon, {})
|
|
102
|
+
}
|
|
103
|
+
) }),
|
|
104
|
+
/* @__PURE__ */ jsxRuntime.jsxs(PopoverContent, { align: "start", side: "bottom", children: [
|
|
105
|
+
/* @__PURE__ */ jsxRuntime.jsxs(FormGroup, { children: [
|
|
106
|
+
/* @__PURE__ */ jsxRuntime.jsx(Label, { children: "Iframe Source (URL)" }),
|
|
107
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
108
|
+
Input,
|
|
109
|
+
{
|
|
110
|
+
type: "url",
|
|
111
|
+
placeholder: "https://www.youtube.com/embed/xxxx",
|
|
112
|
+
value: src,
|
|
113
|
+
onChange: (e) => {
|
|
114
|
+
setSrc(e.target.value);
|
|
115
|
+
if (error) setError("");
|
|
116
|
+
},
|
|
117
|
+
style: { borderColor: error ? "#d02b20" : void 0 }
|
|
118
|
+
}
|
|
119
|
+
),
|
|
120
|
+
error && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "danger600", children: error })
|
|
121
|
+
] }),
|
|
122
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Grid.Root, { gap: 6, children: [
|
|
123
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { xs: 6, children: /* @__PURE__ */ jsxRuntime.jsxs(FormGroup, { children: [
|
|
124
|
+
/* @__PURE__ */ jsxRuntime.jsx(Label, { children: "Width (px)" }),
|
|
125
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
126
|
+
Input,
|
|
127
|
+
{
|
|
128
|
+
type: "number",
|
|
129
|
+
value: width,
|
|
130
|
+
onChange: (e) => setWidth(e.target.value)
|
|
131
|
+
}
|
|
132
|
+
)
|
|
133
|
+
] }) }),
|
|
134
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { xs: 6, children: /* @__PURE__ */ jsxRuntime.jsxs(FormGroup, { children: [
|
|
135
|
+
/* @__PURE__ */ jsxRuntime.jsx(Label, { children: "Height (px)" }),
|
|
136
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
137
|
+
Input,
|
|
138
|
+
{
|
|
139
|
+
type: "number",
|
|
140
|
+
value: height,
|
|
141
|
+
onChange: (e) => setHeight(e.target.value)
|
|
142
|
+
}
|
|
143
|
+
)
|
|
144
|
+
] }) })
|
|
145
|
+
] }),
|
|
146
|
+
/* @__PURE__ */ jsxRuntime.jsx(FormGroup, { children: /* @__PURE__ */ jsxRuntime.jsxs("label", { style: { fontSize: "13px", display: "flex", alignItems: "center" }, children: [
|
|
147
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
148
|
+
"input",
|
|
149
|
+
{
|
|
150
|
+
type: "checkbox",
|
|
151
|
+
checked: allowFullscreen,
|
|
152
|
+
onChange: (e) => setAllowFullscreen(e.target.checked),
|
|
153
|
+
style: { marginRight: "6px" }
|
|
154
|
+
}
|
|
155
|
+
),
|
|
156
|
+
"Allow Fullscreen"
|
|
157
|
+
] }) }),
|
|
158
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ButtonRow, { children: [
|
|
159
|
+
/* @__PURE__ */ jsxRuntime.jsx(SmallButton, { onClick: () => setOpen(false), children: "Cancel" }),
|
|
160
|
+
/* @__PURE__ */ jsxRuntime.jsx(SmallButton, { variant: "primary", onClick: onInsertIframe, children: "Insert" })
|
|
161
|
+
] })
|
|
162
|
+
] })
|
|
163
|
+
] });
|
|
164
|
+
}
|
|
165
|
+
);
|
|
166
|
+
IframeToolbar.displayName = "IframeToolbar";
|
|
167
|
+
exports.IframeToolbar = IframeToolbar;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const jsxRuntime = require("react/jsx-runtime");
|
|
4
|
+
const React = require("react");
|
|
5
|
+
const lucideReact = require("lucide-react");
|
|
6
|
+
const TiptapEditorInput = require("./TiptapEditorInput-vfLsCt1p.js");
|
|
7
|
+
const styled = require("styled-components");
|
|
8
|
+
const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
|
|
9
|
+
const styled__default = /* @__PURE__ */ _interopDefault(styled);
|
|
10
|
+
const ImageIcon = styled__default.default(lucideReact.LucideImage)`
|
|
11
|
+
width: 16px;
|
|
12
|
+
height: 16px;
|
|
13
|
+
`;
|
|
14
|
+
const ImagePlaceholderToolbar = React.forwardRef(({ className, onClick, children, ...props }, ref) => {
|
|
15
|
+
const { editor } = TiptapEditorInput.useEditorContext();
|
|
16
|
+
const [mediaLibOpen, setMediaLibOpen] = React.useState(false);
|
|
17
|
+
const handleMediaSelect = React.useCallback((file) => {
|
|
18
|
+
if (!file) return;
|
|
19
|
+
let srcset = void 0;
|
|
20
|
+
if (file.formats) {
|
|
21
|
+
const sets = Object.keys(file.formats).sort((a, b) => file.formats[a].width - file.formats[b].width).map((k) => {
|
|
22
|
+
const f = file.formats[k];
|
|
23
|
+
const url = f.url.startsWith("http") ? f.url : `${window.strapi?.backendURL}${f.url}`;
|
|
24
|
+
return `${url} ${f.width}w`;
|
|
25
|
+
});
|
|
26
|
+
srcset = sets.join(", ");
|
|
27
|
+
}
|
|
28
|
+
editor.chain().focus().setImage({
|
|
29
|
+
src: file.url,
|
|
30
|
+
alt: file.alt,
|
|
31
|
+
caption: file.caption,
|
|
32
|
+
title: file.name,
|
|
33
|
+
pixelWidth: file.width,
|
|
34
|
+
pixelHeight: file.height,
|
|
35
|
+
originalWidth: file.width,
|
|
36
|
+
originalHeight: file.height,
|
|
37
|
+
media_id: file.id,
|
|
38
|
+
width: "auto",
|
|
39
|
+
aspectRatio: file.width && file.height ? `${file.width}/${file.height}` : null,
|
|
40
|
+
srcset
|
|
41
|
+
}).run();
|
|
42
|
+
setMediaLibOpen(false);
|
|
43
|
+
}, [editor]);
|
|
44
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
45
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
46
|
+
TiptapEditorInput.ToolbarButton,
|
|
47
|
+
{
|
|
48
|
+
tooltip: "Image",
|
|
49
|
+
"aria-label": "Insert image",
|
|
50
|
+
isActive: editor?.isActive("image"),
|
|
51
|
+
onClick: (e) => {
|
|
52
|
+
setMediaLibOpen(true);
|
|
53
|
+
onClick?.(e);
|
|
54
|
+
},
|
|
55
|
+
ref,
|
|
56
|
+
...props,
|
|
57
|
+
children: children || /* @__PURE__ */ jsxRuntime.jsx(ImageIcon, {})
|
|
58
|
+
}
|
|
59
|
+
),
|
|
60
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
61
|
+
TiptapEditorInput.MediaLibraryModal,
|
|
62
|
+
{
|
|
63
|
+
isOpen: mediaLibOpen,
|
|
64
|
+
onClose: () => setMediaLibOpen(false),
|
|
65
|
+
onSelect: handleMediaSelect
|
|
66
|
+
}
|
|
67
|
+
)
|
|
68
|
+
] });
|
|
69
|
+
});
|
|
70
|
+
ImagePlaceholderToolbar.displayName = "ImagePlaceholderToolbar";
|
|
71
|
+
exports.ImagePlaceholderToolbar = ImagePlaceholderToolbar;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { jsxs, Fragment, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef, useState, useCallback } from "react";
|
|
3
|
+
import { LucideImage } from "lucide-react";
|
|
4
|
+
import { u as useEditorContext, T as ToolbarButton, M as MediaLibraryModal } from "./TiptapEditorInput-BDE09h5-.mjs";
|
|
5
|
+
import styled from "styled-components";
|
|
6
|
+
const ImageIcon = styled(LucideImage)`
|
|
7
|
+
width: 16px;
|
|
8
|
+
height: 16px;
|
|
9
|
+
`;
|
|
10
|
+
const ImagePlaceholderToolbar = forwardRef(({ className, onClick, children, ...props }, ref) => {
|
|
11
|
+
const { editor } = useEditorContext();
|
|
12
|
+
const [mediaLibOpen, setMediaLibOpen] = useState(false);
|
|
13
|
+
const handleMediaSelect = useCallback((file) => {
|
|
14
|
+
if (!file) return;
|
|
15
|
+
let srcset = void 0;
|
|
16
|
+
if (file.formats) {
|
|
17
|
+
const sets = Object.keys(file.formats).sort((a, b) => file.formats[a].width - file.formats[b].width).map((k) => {
|
|
18
|
+
const f = file.formats[k];
|
|
19
|
+
const url = f.url.startsWith("http") ? f.url : `${window.strapi?.backendURL}${f.url}`;
|
|
20
|
+
return `${url} ${f.width}w`;
|
|
21
|
+
});
|
|
22
|
+
srcset = sets.join(", ");
|
|
23
|
+
}
|
|
24
|
+
editor.chain().focus().setImage({
|
|
25
|
+
src: file.url,
|
|
26
|
+
alt: file.alt,
|
|
27
|
+
caption: file.caption,
|
|
28
|
+
title: file.name,
|
|
29
|
+
pixelWidth: file.width,
|
|
30
|
+
pixelHeight: file.height,
|
|
31
|
+
originalWidth: file.width,
|
|
32
|
+
originalHeight: file.height,
|
|
33
|
+
media_id: file.id,
|
|
34
|
+
width: "auto",
|
|
35
|
+
aspectRatio: file.width && file.height ? `${file.width}/${file.height}` : null,
|
|
36
|
+
srcset
|
|
37
|
+
}).run();
|
|
38
|
+
setMediaLibOpen(false);
|
|
39
|
+
}, [editor]);
|
|
40
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
41
|
+
/* @__PURE__ */ jsx(
|
|
42
|
+
ToolbarButton,
|
|
43
|
+
{
|
|
44
|
+
tooltip: "Image",
|
|
45
|
+
"aria-label": "Insert image",
|
|
46
|
+
isActive: editor?.isActive("image"),
|
|
47
|
+
onClick: (e) => {
|
|
48
|
+
setMediaLibOpen(true);
|
|
49
|
+
onClick?.(e);
|
|
50
|
+
},
|
|
51
|
+
ref,
|
|
52
|
+
...props,
|
|
53
|
+
children: children || /* @__PURE__ */ jsx(ImageIcon, {})
|
|
54
|
+
}
|
|
55
|
+
),
|
|
56
|
+
/* @__PURE__ */ jsx(
|
|
57
|
+
MediaLibraryModal,
|
|
58
|
+
{
|
|
59
|
+
isOpen: mediaLibOpen,
|
|
60
|
+
onClose: () => setMediaLibOpen(false),
|
|
61
|
+
onSelect: handleMediaSelect
|
|
62
|
+
}
|
|
63
|
+
)
|
|
64
|
+
] });
|
|
65
|
+
});
|
|
66
|
+
ImagePlaceholderToolbar.displayName = "ImagePlaceholderToolbar";
|
|
67
|
+
export {
|
|
68
|
+
ImagePlaceholderToolbar
|
|
69
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
import { ItalicIcon } from "lucide-react";
|
|
4
|
+
import { u as useEditorContext, T as ToolbarButton } from "./TiptapEditorInput-BDE09h5-.mjs";
|
|
5
|
+
import styled from "styled-components";
|
|
6
|
+
const ItalicIconStyled = styled(ItalicIcon)`
|
|
7
|
+
width: 16px;
|
|
8
|
+
height: 16px;
|
|
9
|
+
`;
|
|
10
|
+
const ItalicToolbar = forwardRef(
|
|
11
|
+
({ className, onClick, children, ...props }, ref) => {
|
|
12
|
+
const { editor } = useEditorContext();
|
|
13
|
+
return /* @__PURE__ */ jsx(
|
|
14
|
+
ToolbarButton,
|
|
15
|
+
{
|
|
16
|
+
tooltip: "Italic",
|
|
17
|
+
"aria-label": "Set italic",
|
|
18
|
+
isActive: editor?.isActive("italic"),
|
|
19
|
+
onClick: (e) => {
|
|
20
|
+
editor?.chain().focus().toggleItalic().run();
|
|
21
|
+
onClick?.(e);
|
|
22
|
+
},
|
|
23
|
+
disabled: !editor?.can().chain().focus().toggleItalic().run(),
|
|
24
|
+
ref,
|
|
25
|
+
...props,
|
|
26
|
+
children: children || /* @__PURE__ */ jsx(ItalicIconStyled, {})
|
|
27
|
+
}
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
);
|
|
31
|
+
ItalicToolbar.displayName = "ItalicToolbar";
|
|
32
|
+
export {
|
|
33
|
+
ItalicToolbar
|
|
34
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const jsxRuntime = require("react/jsx-runtime");
|
|
4
|
+
const React = require("react");
|
|
5
|
+
const lucideReact = require("lucide-react");
|
|
6
|
+
const TiptapEditorInput = require("./TiptapEditorInput-vfLsCt1p.js");
|
|
7
|
+
const styled = require("styled-components");
|
|
8
|
+
const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
|
|
9
|
+
const styled__default = /* @__PURE__ */ _interopDefault(styled);
|
|
10
|
+
const ItalicIconStyled = styled__default.default(lucideReact.ItalicIcon)`
|
|
11
|
+
width: 16px;
|
|
12
|
+
height: 16px;
|
|
13
|
+
`;
|
|
14
|
+
const ItalicToolbar = React.forwardRef(
|
|
15
|
+
({ className, onClick, children, ...props }, ref) => {
|
|
16
|
+
const { editor } = TiptapEditorInput.useEditorContext();
|
|
17
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
18
|
+
TiptapEditorInput.ToolbarButton,
|
|
19
|
+
{
|
|
20
|
+
tooltip: "Italic",
|
|
21
|
+
"aria-label": "Set italic",
|
|
22
|
+
isActive: editor?.isActive("italic"),
|
|
23
|
+
onClick: (e) => {
|
|
24
|
+
editor?.chain().focus().toggleItalic().run();
|
|
25
|
+
onClick?.(e);
|
|
26
|
+
},
|
|
27
|
+
disabled: !editor?.can().chain().focus().toggleItalic().run(),
|
|
28
|
+
ref,
|
|
29
|
+
...props,
|
|
30
|
+
children: children || /* @__PURE__ */ jsxRuntime.jsx(ItalicIconStyled, {})
|
|
31
|
+
}
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
);
|
|
35
|
+
ItalicToolbar.displayName = "ItalicToolbar";
|
|
36
|
+
exports.ItalicToolbar = ItalicToolbar;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const jsxRuntime = require("react/jsx-runtime");
|
|
4
|
+
const React = require("react");
|
|
5
|
+
const lucideReact = require("lucide-react");
|
|
6
|
+
const TiptapEditorInput = require("./TiptapEditorInput-vfLsCt1p.js");
|
|
7
|
+
const designSystem = require("@strapi/design-system");
|
|
8
|
+
const styled = require("styled-components");
|
|
9
|
+
const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
|
|
10
|
+
const styled__default = /* @__PURE__ */ _interopDefault(styled);
|
|
11
|
+
const LinkIcon = styled__default.default(lucideReact.Link2)`
|
|
12
|
+
width: 20px;
|
|
13
|
+
height: 20px;
|
|
14
|
+
`;
|
|
15
|
+
const PopoverContent = styled__default.default(designSystem.Popover.Content)`
|
|
16
|
+
width: 100%;
|
|
17
|
+
min-width: 320px;
|
|
18
|
+
padding: 12px;
|
|
19
|
+
`;
|
|
20
|
+
const LinkToolbar = React.forwardRef(
|
|
21
|
+
({ className, onClick, children, ...props }, ref) => {
|
|
22
|
+
const { editor } = TiptapEditorInput.useEditorContext();
|
|
23
|
+
const [open, setOpen] = React.useState(false);
|
|
24
|
+
const { from, to } = editor.state.selection;
|
|
25
|
+
const text = editor.state.doc.textBetween(from, to, " ");
|
|
26
|
+
const onSetLink = React.useCallback(
|
|
27
|
+
(url, text2, openInNewTab) => {
|
|
28
|
+
editor.chain().focus().extendMarkRange("link").insertContent({
|
|
29
|
+
type: "text",
|
|
30
|
+
text: text2 || url,
|
|
31
|
+
marks: [
|
|
32
|
+
{
|
|
33
|
+
type: "link",
|
|
34
|
+
attrs: {
|
|
35
|
+
href: url,
|
|
36
|
+
target: openInNewTab ? "_blank" : ""
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
]
|
|
40
|
+
}).setLink({ href: url }).run();
|
|
41
|
+
editor.commands.enter();
|
|
42
|
+
},
|
|
43
|
+
[editor]
|
|
44
|
+
);
|
|
45
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Popover.Root, { open, onOpenChange: setOpen, children: [
|
|
46
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Popover.Trigger, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
47
|
+
TiptapEditorInput.ToolbarButton,
|
|
48
|
+
{
|
|
49
|
+
isActive: editor.isActive("link"),
|
|
50
|
+
tooltip: "Link",
|
|
51
|
+
"aria-label": "Insert link",
|
|
52
|
+
disabled: editor.isActive("codeBlock"),
|
|
53
|
+
...props,
|
|
54
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(LinkIcon, {})
|
|
55
|
+
}
|
|
56
|
+
) }),
|
|
57
|
+
/* @__PURE__ */ jsxRuntime.jsx(PopoverContent, { align: "start", side: "bottom", children: /* @__PURE__ */ jsxRuntime.jsx(TiptapEditorInput.LinkEditBlock, { onSave: onSetLink, defaultText: text }) })
|
|
58
|
+
] });
|
|
59
|
+
}
|
|
60
|
+
);
|
|
61
|
+
exports.LinkToolbar = LinkToolbar;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef, useState, useCallback } from "react";
|
|
3
|
+
import { Link2 } from "lucide-react";
|
|
4
|
+
import { u as useEditorContext, T as ToolbarButton, L as LinkEditBlock } from "./TiptapEditorInput-BDE09h5-.mjs";
|
|
5
|
+
import { Popover } from "@strapi/design-system";
|
|
6
|
+
import styled from "styled-components";
|
|
7
|
+
const LinkIcon = styled(Link2)`
|
|
8
|
+
width: 20px;
|
|
9
|
+
height: 20px;
|
|
10
|
+
`;
|
|
11
|
+
const PopoverContent = styled(Popover.Content)`
|
|
12
|
+
width: 100%;
|
|
13
|
+
min-width: 320px;
|
|
14
|
+
padding: 12px;
|
|
15
|
+
`;
|
|
16
|
+
const LinkToolbar = forwardRef(
|
|
17
|
+
({ className, onClick, children, ...props }, ref) => {
|
|
18
|
+
const { editor } = useEditorContext();
|
|
19
|
+
const [open, setOpen] = useState(false);
|
|
20
|
+
const { from, to } = editor.state.selection;
|
|
21
|
+
const text = editor.state.doc.textBetween(from, to, " ");
|
|
22
|
+
const onSetLink = useCallback(
|
|
23
|
+
(url, text2, openInNewTab) => {
|
|
24
|
+
editor.chain().focus().extendMarkRange("link").insertContent({
|
|
25
|
+
type: "text",
|
|
26
|
+
text: text2 || url,
|
|
27
|
+
marks: [
|
|
28
|
+
{
|
|
29
|
+
type: "link",
|
|
30
|
+
attrs: {
|
|
31
|
+
href: url,
|
|
32
|
+
target: openInNewTab ? "_blank" : ""
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
]
|
|
36
|
+
}).setLink({ href: url }).run();
|
|
37
|
+
editor.commands.enter();
|
|
38
|
+
},
|
|
39
|
+
[editor]
|
|
40
|
+
);
|
|
41
|
+
return /* @__PURE__ */ jsxs(Popover.Root, { open, onOpenChange: setOpen, children: [
|
|
42
|
+
/* @__PURE__ */ jsx(Popover.Trigger, { children: /* @__PURE__ */ jsx(
|
|
43
|
+
ToolbarButton,
|
|
44
|
+
{
|
|
45
|
+
isActive: editor.isActive("link"),
|
|
46
|
+
tooltip: "Link",
|
|
47
|
+
"aria-label": "Insert link",
|
|
48
|
+
disabled: editor.isActive("codeBlock"),
|
|
49
|
+
...props,
|
|
50
|
+
children: /* @__PURE__ */ jsx(LinkIcon, {})
|
|
51
|
+
}
|
|
52
|
+
) }),
|
|
53
|
+
/* @__PURE__ */ jsx(PopoverContent, { align: "start", side: "bottom", children: /* @__PURE__ */ jsx(LinkEditBlock, { onSave: onSetLink, defaultText: text }) })
|
|
54
|
+
] });
|
|
55
|
+
}
|
|
56
|
+
);
|
|
57
|
+
export {
|
|
58
|
+
LinkToolbar
|
|
59
|
+
};
|