sykpcomposer 1.1.1 → 1.19.2
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 +12 -0
- package/dist/ImageComponent-855cf80f.js +921 -0
- package/dist/ImageComponent-855cf80f.js.map +1 -0
- package/dist/InlineImageComponent-87d221c5.js +529 -0
- package/dist/InlineImageComponent-87d221c5.js.map +1 -0
- package/dist/LexicalNestedComposer.esm-6b21e728.js +109 -0
- package/dist/LexicalNestedComposer.esm-6b21e728.js.map +1 -0
- package/dist/PollComponent-b28294b0.js +169 -0
- package/dist/PollComponent-b28294b0.js.map +1 -0
- package/dist/assets/icons/3-columns.svg +3 -0
- package/dist/assets/icons/LICENSE.md +5 -0
- package/dist/assets/icons/add-sign.svg +3 -0
- package/dist/assets/icons/arrow-clockwise.svg +1 -0
- package/dist/assets/icons/arrow-counterclockwise.svg +1 -0
- package/dist/assets/icons/bg-color.svg +1 -0
- package/dist/assets/icons/camera.svg +1 -0
- package/dist/assets/icons/card-checklist.svg +1 -0
- package/dist/assets/icons/caret-right-fill.svg +1 -0
- package/dist/assets/icons/chat-left-text.svg +1 -0
- package/dist/assets/icons/chat-right-dots.svg +1 -0
- package/dist/assets/icons/chat-right-text.svg +1 -0
- package/dist/assets/icons/chat-right.svg +1 -0
- package/dist/assets/icons/chat-square-quote.svg +1 -0
- package/dist/assets/icons/chevron-down.svg +1 -0
- package/dist/assets/icons/clipboard.svg +1 -0
- package/dist/assets/icons/close.svg +1 -0
- package/dist/assets/icons/code.svg +1 -0
- package/dist/assets/icons/comments.svg +1 -0
- package/dist/assets/icons/copy.svg +1 -0
- package/dist/assets/icons/diagram-2.svg +1 -0
- package/dist/assets/icons/download.svg +1 -0
- package/dist/assets/icons/draggable-block-menu.svg +1 -0
- package/dist/assets/icons/dropdown-more.svg +1 -0
- package/dist/assets/icons/figma.svg +1 -0
- package/dist/assets/icons/file-earmark-text.svg +4 -0
- package/dist/assets/icons/file-image.svg +1 -0
- package/dist/assets/icons/filetype-gif.svg +1 -0
- package/dist/assets/icons/font-color.svg +1 -0
- package/dist/assets/icons/font-family.svg +1 -0
- package/dist/assets/icons/gear.svg +1 -0
- package/dist/assets/icons/horizontal-rule.svg +1 -0
- package/dist/assets/icons/indent.svg +1 -0
- package/dist/assets/icons/journal-code.svg +1 -0
- package/dist/assets/icons/journal-text.svg +1 -0
- package/dist/assets/icons/justify.svg +1 -0
- package/dist/assets/icons/link.svg +1 -0
- package/dist/assets/icons/list-ol.svg +1 -0
- package/dist/assets/icons/list-ul.svg +1 -0
- package/dist/assets/icons/lock-fill.svg +1 -0
- package/dist/assets/icons/lock.svg +1 -0
- package/dist/assets/icons/markdown.svg +1 -0
- package/dist/assets/icons/mic.svg +1 -0
- package/dist/assets/icons/minus-sign.svg +3 -0
- package/dist/assets/icons/outdent.svg +1 -0
- package/dist/assets/icons/paint-bucket.svg +1 -0
- package/dist/assets/icons/palette.svg +1 -0
- package/dist/assets/icons/pdf-svgrepo-com.svg +45 -0
- package/dist/assets/icons/pencil-fill.svg +1 -0
- package/dist/assets/icons/plug-fill.svg +1 -0
- package/dist/assets/icons/plug.svg +1 -0
- package/dist/assets/icons/plus-slash-minus.svg +1 -0
- package/dist/assets/icons/plus.svg +1 -0
- package/dist/assets/icons/prettier-error.svg +1 -0
- package/dist/assets/icons/prettier.svg +1 -0
- package/dist/assets/icons/scissors.svg +3 -0
- package/dist/assets/icons/send.svg +1 -0
- package/dist/assets/icons/square-check.svg +1 -0
- package/dist/assets/icons/sticky.svg +1 -0
- package/dist/assets/icons/success-alt.svg +1 -0
- package/dist/assets/icons/success.svg +1 -0
- package/dist/assets/icons/table.svg +1 -0
- package/dist/assets/icons/text-center.svg +1 -0
- package/dist/assets/icons/text-left.svg +1 -0
- package/dist/assets/icons/text-paragraph.svg +1 -0
- package/dist/assets/icons/text-right.svg +1 -0
- package/dist/assets/icons/trash.svg +1 -0
- package/dist/assets/icons/trash3.svg +1 -0
- package/dist/assets/icons/tweet.svg +1 -0
- package/dist/assets/icons/type-bold.svg +1 -0
- package/dist/assets/icons/type-h1.svg +1 -0
- package/dist/assets/icons/type-h2.svg +1 -0
- package/dist/assets/icons/type-h3.svg +1 -0
- package/dist/assets/icons/type-h4.svg +1 -0
- package/dist/assets/icons/type-h5.svg +1 -0
- package/dist/assets/icons/type-h6.svg +1 -0
- package/dist/assets/icons/type-italic.svg +1 -0
- package/dist/assets/icons/type-strikethrough.svg +1 -0
- package/dist/assets/icons/type-subscript.svg +1 -0
- package/dist/assets/icons/type-superscript.svg +1 -0
- package/dist/assets/icons/type-underline.svg +1 -0
- package/dist/assets/icons/upload.svg +1 -0
- package/dist/assets/icons/user.svg +1 -0
- package/dist/assets/icons/youtube.svg +1 -0
- package/dist/emoji-list-48028e71.js +16606 -0
- package/dist/emoji-list-48028e71.js.map +1 -0
- package/dist/favicon.ico +0 -0
- package/dist/index-5594e4c0.js +80776 -0
- package/dist/index-5594e4c0.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.es.js +4 -18782
- package/dist/index.es.js.map +1 -1
- package/dist/index.html +43 -0
- package/dist/index.umd.js +1554 -80
- package/dist/index.umd.js.map +1 -1
- package/dist/logo192.png +0 -0
- package/dist/logo512.png +0 -0
- package/dist/manifest.json +25 -0
- package/dist/robots.txt +3 -0
- package/dist/src/declarations.d.ts +4 -0
- package/dist/src/lexical/Editor.d.ts +7 -0
- package/dist/src/lexical/ExampleTheme.d.ts +3 -0
- package/dist/src/lexical/HeadingStyles.d.ts +3 -0
- package/dist/src/lexical/commenting/index.d.ts +61 -0
- package/dist/src/lexical/context/SharedAutocompleteContext.d.ts +16 -0
- package/dist/src/lexical/context/SharedHistoryContext.d.ts +17 -0
- package/dist/src/lexical/hooks/useModal.d.ts +12 -0
- package/dist/src/lexical/http.d.ts +13 -0
- package/dist/src/lexical/nodes/AutocompleteNode.d.ts +32 -0
- package/dist/src/lexical/nodes/EmojiNode.d.ts +25 -0
- package/dist/src/lexical/nodes/FigmaNode.d.ts +27 -0
- package/dist/src/lexical/nodes/ImageComponent.d.ts +22 -0
- package/dist/src/lexical/nodes/ImageNode.d.ts +50 -0
- package/dist/src/lexical/nodes/InlineImageComponent.d.ts +25 -0
- package/dist/src/lexical/nodes/InlineImageNode.d.ts +65 -0
- package/dist/src/lexical/nodes/KeywordNode.d.ts +22 -0
- package/dist/src/lexical/nodes/LayoutContainerNode.d.ts +30 -0
- package/dist/src/lexical/nodes/LayoutItemNode.d.ts +22 -0
- package/dist/src/lexical/nodes/MentionNode.d.ts +28 -0
- package/dist/src/lexical/nodes/PageBreakNode/index.d.ts +24 -0
- package/dist/src/lexical/nodes/PlaygroundNodes.d.ts +10 -0
- package/dist/src/lexical/nodes/PollComponent.d.ts +15 -0
- package/dist/src/lexical/nodes/PollNode.d.ts +40 -0
- package/dist/src/lexical/nodes/ReferenceNode.d.ts +21 -0
- package/dist/src/lexical/nodes/TweetNode.d.ts +28 -0
- package/dist/src/lexical/nodes/YouTubeNode.d.ts +29 -0
- package/dist/src/lexical/plugins/AutoEmbedPlugin/index.d.ts +26 -0
- package/dist/src/lexical/plugins/AutoLinkPlugin/index.d.ts +9 -0
- package/dist/src/lexical/plugins/AutocompletePlugin/index.d.ts +10 -0
- package/dist/src/lexical/plugins/CollapsiblePlugin/CollapsibleContainerNode.d.ts +30 -0
- package/dist/src/lexical/plugins/CollapsiblePlugin/CollapsibleContentNode.d.ts +24 -0
- package/dist/src/lexical/plugins/CollapsiblePlugin/CollapsibleTitleNode.d.ts +25 -0
- package/dist/src/lexical/plugins/CollapsiblePlugin/index.d.ts +10 -0
- package/dist/src/lexical/plugins/CommentPlugin/AddCommentBox.d.ts +8 -0
- package/dist/src/lexical/plugins/CommentPlugin/CommentInputBox.d.ts +11 -0
- package/dist/src/lexical/plugins/CommentPlugin/CommentPanelListCB.d.ts +21 -0
- package/dist/src/lexical/plugins/CommentPlugin/CommentsComposer.d.ts +11 -0
- package/dist/src/lexical/plugins/CommentPlugin/CommentsPanel.d.ts +18 -0
- package/dist/src/lexical/plugins/CommentPlugin/CommentsPanelList.d.ts +17 -0
- package/dist/src/lexical/plugins/CommentPlugin/CommentsPanelListComment.d.ts +10 -0
- package/dist/src/lexical/plugins/CommentPlugin/EscapeHandlerPlugin.d.ts +3 -0
- package/dist/src/lexical/plugins/CommentPlugin/PlainTextEditor.d.ts +13 -0
- package/dist/src/lexical/plugins/CommentPlugin/ShowDeleteCommentOrThreadDialog.d.ts +8 -0
- package/dist/src/lexical/plugins/CommentPlugin/UseOnChange.d.ts +2 -0
- package/dist/src/lexical/plugins/CommentPlugin/index.d.ts +21 -0
- package/dist/src/lexical/plugins/CrossReferencePlugin/HashToolbarOpenerPlugin.d.ts +1 -0
- package/dist/src/lexical/plugins/CrossReferencePlugin/ReferenceToolbar.d.ts +22 -0
- package/dist/src/lexical/plugins/CrossReferencePlugin/index.d.ts +2 -0
- package/dist/src/lexical/plugins/DragDropPastePlugin/index.d.ts +8 -0
- package/dist/src/lexical/plugins/DraggableBlockPlugin/index.d.ts +11 -0
- package/dist/src/lexical/plugins/EmojiPickerPlugin/index.d.ts +9 -0
- package/dist/src/lexical/plugins/EmojisPlugin/index.d.ts +9 -0
- package/dist/src/lexical/plugins/FigmaPlugin/index.d.ts +11 -0
- package/dist/src/lexical/plugins/FloatingLinkEditorPlugin/index.d.ts +13 -0
- package/dist/src/lexical/plugins/FloatingTextFormatToolbarPlugin/index.d.ts +11 -0
- package/dist/src/lexical/plugins/ImagesPlugin/index.d.ts +24 -0
- package/dist/src/lexical/plugins/InlineImagePlugin/index.d.ts +16 -0
- package/dist/src/lexical/plugins/KeywordsPlugin/index.d.ts +9 -0
- package/dist/src/lexical/plugins/LayoutPlugin/InsertLayoutDialog.d.ts +13 -0
- package/dist/src/lexical/plugins/LayoutPlugin/LayoutPlugin.d.ts +14 -0
- package/dist/src/{components/plugins/TreeViewPlugin.d.ts → lexical/plugins/LinkPlugin/index.d.ts} +1 -1
- package/dist/src/lexical/plugins/ListMaxIndentLevelPlugin/index.d.ts +12 -0
- package/dist/src/lexical/plugins/MentionsPlugin/index.d.ts +11 -0
- package/dist/src/lexical/plugins/PageBreakPlugin/index.d.ts +4 -0
- package/dist/src/lexical/plugins/PollPlugin/index.d.ts +15 -0
- package/dist/src/lexical/plugins/TabFocusPlugin/index.d.ts +8 -0
- package/dist/src/lexical/plugins/TableActionMenuPlugin/index.d.ts +12 -0
- package/dist/src/lexical/plugins/TableCellResizer/index.d.ts +2 -0
- package/dist/src/lexical/plugins/TablePlugin.d.ts +39 -0
- package/dist/src/lexical/plugins/ToolbarPlugin/fontSize.d.ts +21 -0
- package/dist/src/lexical/plugins/ToolbarPlugin/index.d.ts +15 -0
- package/dist/src/lexical/plugins/TwitterPlugin/index.d.ts +11 -0
- package/dist/src/lexical/plugins/YouTubePlugin/index.d.ts +11 -0
- package/dist/src/lexical/themes/PlaygroundEditorTheme.d.ts +10 -0
- package/dist/src/lexical/ui/Button.d.ts +17 -0
- package/dist/src/lexical/ui/ColorPicker.d.ts +19 -0
- package/dist/src/lexical/ui/ContentEditable.d.ts +11 -0
- package/dist/src/lexical/ui/Dialog.d.ts +15 -0
- package/dist/src/lexical/ui/DropDown.d.ts +24 -0
- package/dist/src/lexical/ui/DropdownColorPicker.d.ts +21 -0
- package/dist/src/lexical/ui/FileInput.d.ts +16 -0
- package/dist/src/lexical/ui/ImageResizer.d.ts +24 -0
- package/dist/src/lexical/ui/Modal.d.ts +14 -0
- package/dist/src/lexical/ui/Placeholder.d.ts +12 -0
- package/dist/src/lexical/ui/Select.d.ts +14 -0
- package/dist/src/lexical/ui/TextInput.d.ts +18 -0
- package/dist/src/lexical/utils/canUseDOM.d.ts +8 -0
- package/dist/src/lexical/utils/emoji-list.d.ts +27 -0
- package/dist/src/lexical/utils/environment.d.ts +24 -0
- package/dist/src/lexical/utils/getDOMRangeRect.d.ts +8 -0
- package/dist/src/lexical/utils/getSelectedNode.d.ts +2 -0
- package/dist/src/lexical/utils/guard.d.ts +8 -0
- package/dist/src/lexical/utils/invariant.d.ts +8 -0
- package/dist/src/lexical/utils/joinClasses.d.ts +8 -0
- package/dist/src/lexical/utils/point.d.ts +21 -0
- package/dist/src/lexical/utils/rect.d.ts +45 -0
- package/dist/src/lexical/utils/setFloatingElemPosition.d.ts +1 -0
- package/dist/src/lexical/utils/setFloatingElemPositionForLinkEditor.d.ts +1 -0
- package/dist/src/lexical/utils/swipe.d.ts +11 -0
- package/dist/src/lexical/utils/url.d.ts +9 -0
- package/dist/style.css +1 -1
- package/package.json +76 -45
- package/dist/src/components/Editor.d.ts +0 -2
- package/dist/src/components/ExampleTheme.d.ts +0 -43
- package/dist/src/components/plugins/ToolbarPlugin.d.ts +0 -2
- package/dist/src/vite-env.d.ts +0 -1
- package/readme.md +0 -24
|
@@ -0,0 +1,921 @@
|
|
|
1
|
+
import { j as v, u as ce, a as ae, $ as G, b as q, c as J, d as Q, e as ne, f as de, m as le, S as ge, C as z, g as ue, D as pe, K as we, h as me, i as xe, k as Ce, R as fe, L as ye, P as De, l as ve, n as be } from "./index-5594e4c0.js";
|
|
2
|
+
import { L as Re } from "./LexicalNestedComposer.esm-6b21e728.js";
|
|
3
|
+
import C, { useRef as Y, PureComponent as Ee, createRef as re, useState as U, useCallback as V, useEffect as te, Suspense as Me } from "react";
|
|
4
|
+
import "react-dom";
|
|
5
|
+
function ee(l, t, e) {
|
|
6
|
+
return Math.min(Math.max(l, t), e);
|
|
7
|
+
}
|
|
8
|
+
const f = {
|
|
9
|
+
east: 1 << 0,
|
|
10
|
+
north: 1 << 3,
|
|
11
|
+
south: 1 << 1,
|
|
12
|
+
west: 1 << 2
|
|
13
|
+
};
|
|
14
|
+
function Ne({
|
|
15
|
+
onResizeStart: l,
|
|
16
|
+
onResizeEnd: t,
|
|
17
|
+
buttonRef: e,
|
|
18
|
+
imageRef: o,
|
|
19
|
+
maxWidth: n,
|
|
20
|
+
editor: r,
|
|
21
|
+
showCaption: h,
|
|
22
|
+
setShowCaption: p,
|
|
23
|
+
captionsEnabled: s
|
|
24
|
+
}) {
|
|
25
|
+
const i = Y(null), d = Y({
|
|
26
|
+
priority: "",
|
|
27
|
+
value: "default"
|
|
28
|
+
}), a = Y({
|
|
29
|
+
currentHeight: 0,
|
|
30
|
+
currentWidth: 0,
|
|
31
|
+
direction: 0,
|
|
32
|
+
isResizing: !1,
|
|
33
|
+
ratio: 0,
|
|
34
|
+
startHeight: 0,
|
|
35
|
+
startWidth: 0,
|
|
36
|
+
startX: 0,
|
|
37
|
+
startY: 0
|
|
38
|
+
}), g = r.getRootElement(), c = g !== null ? g.getBoundingClientRect().width - 20 : 100, y = g !== null ? g.getBoundingClientRect().height - 20 : 100, N = 100, x = 100, P = (w) => {
|
|
39
|
+
const u = w === f.east || w === f.west, m = w === f.north || w === f.south, _ = w & f.north && w & f.west || w & f.south && w & f.east, M = u ? "ew" : m ? "ns" : _ ? "nwse" : "nesw";
|
|
40
|
+
g !== null && g.style.setProperty(
|
|
41
|
+
"cursor",
|
|
42
|
+
`${M}-resize`,
|
|
43
|
+
"important"
|
|
44
|
+
), document.body !== null && (document.body.style.setProperty(
|
|
45
|
+
"cursor",
|
|
46
|
+
`${M}-resize`,
|
|
47
|
+
"important"
|
|
48
|
+
), d.current.value = document.body.style.getPropertyValue(
|
|
49
|
+
"-webkit-user-select"
|
|
50
|
+
), d.current.priority = document.body.style.getPropertyPriority(
|
|
51
|
+
"-webkit-user-select"
|
|
52
|
+
), document.body.style.setProperty(
|
|
53
|
+
"-webkit-user-select",
|
|
54
|
+
"none",
|
|
55
|
+
"important"
|
|
56
|
+
));
|
|
57
|
+
}, T = () => {
|
|
58
|
+
g !== null && g.style.setProperty("cursor", "text"), document.body !== null && (document.body.style.setProperty("cursor", "default"), document.body.style.setProperty(
|
|
59
|
+
"-webkit-user-select",
|
|
60
|
+
d.current.value,
|
|
61
|
+
d.current.priority
|
|
62
|
+
));
|
|
63
|
+
}, S = (w, u) => {
|
|
64
|
+
if (!r.isEditable())
|
|
65
|
+
return;
|
|
66
|
+
const m = o.current, _ = i.current;
|
|
67
|
+
if (m !== null && _ !== null) {
|
|
68
|
+
w.preventDefault();
|
|
69
|
+
const { width: M, height: b } = m.getBoundingClientRect(), D = a.current;
|
|
70
|
+
D.startWidth = M, D.startHeight = b, D.ratio = M / b, D.currentWidth = M, D.currentHeight = b, D.startX = w.clientX, D.startY = w.clientY, D.isResizing = !0, D.direction = u, P(u), l(), _.classList.add("image-control-wrapper--resizing"), m.style.height = `${b}px`, m.style.width = `${M}px`, document.addEventListener("pointermove", k), document.addEventListener("pointerup", I);
|
|
71
|
+
}
|
|
72
|
+
}, k = (w) => {
|
|
73
|
+
const u = o.current, m = a.current, _ = m.direction & (f.east | f.west), M = m.direction & (f.south | f.north);
|
|
74
|
+
if (u !== null && m.isResizing) {
|
|
75
|
+
if (_ && M) {
|
|
76
|
+
let b = Math.floor(m.startX - w.clientX);
|
|
77
|
+
b = m.direction & f.east ? -b : b;
|
|
78
|
+
const D = ee(
|
|
79
|
+
m.startWidth + b,
|
|
80
|
+
N,
|
|
81
|
+
c
|
|
82
|
+
), X = D / m.ratio;
|
|
83
|
+
u.style.width = `${D}px`, u.style.height = `${X}px`, m.currentHeight = X, m.currentWidth = D;
|
|
84
|
+
} else if (M) {
|
|
85
|
+
let b = Math.floor(m.startY - w.clientY);
|
|
86
|
+
b = m.direction & f.south ? -b : b;
|
|
87
|
+
const D = ee(
|
|
88
|
+
m.startHeight + b,
|
|
89
|
+
x,
|
|
90
|
+
y
|
|
91
|
+
);
|
|
92
|
+
u.style.height = `${D}px`, u.style.maxHeight = `${D}px`, m.currentHeight = D;
|
|
93
|
+
} else {
|
|
94
|
+
let b = Math.floor(m.startX - w.clientX);
|
|
95
|
+
b = m.direction & f.east ? -b : b;
|
|
96
|
+
const D = ee(
|
|
97
|
+
m.startWidth + b,
|
|
98
|
+
N,
|
|
99
|
+
c
|
|
100
|
+
);
|
|
101
|
+
u.style.width = `${D}px`, u.style.maxWidth = `${D}px`, m.currentWidth = D;
|
|
102
|
+
}
|
|
103
|
+
u && (u.setAttribute("width", `${m.currentWidth}`), u.setAttribute("height", `${m.currentHeight}`));
|
|
104
|
+
}
|
|
105
|
+
}, I = () => {
|
|
106
|
+
const w = o.current, u = a.current, m = i.current;
|
|
107
|
+
if (w !== null && m !== null && u.isResizing) {
|
|
108
|
+
const _ = u.currentWidth, M = u.currentHeight;
|
|
109
|
+
u.startWidth = 0, u.startHeight = 0, u.ratio = 0, u.startX = 0, u.startY = 0, u.currentWidth = 0, u.currentHeight = 0, u.isResizing = !1, m.classList.remove("image-control-wrapper--resizing"), T(), t(_, M), document.removeEventListener("pointermove", k), document.removeEventListener("pointerup", I);
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
return /* @__PURE__ */ v.exports.jsxs("div", { ref: i, children: [
|
|
113
|
+
/* @__PURE__ */ v.exports.jsx(
|
|
114
|
+
"div",
|
|
115
|
+
{
|
|
116
|
+
className: "image-resizer image-resizer-n",
|
|
117
|
+
onPointerDown: (w) => {
|
|
118
|
+
S(w, f.north);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
),
|
|
122
|
+
/* @__PURE__ */ v.exports.jsx(
|
|
123
|
+
"div",
|
|
124
|
+
{
|
|
125
|
+
className: "image-resizer image-resizer-ne",
|
|
126
|
+
onPointerDown: (w) => {
|
|
127
|
+
S(w, f.north | f.east);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
),
|
|
131
|
+
/* @__PURE__ */ v.exports.jsx(
|
|
132
|
+
"div",
|
|
133
|
+
{
|
|
134
|
+
className: "image-resizer image-resizer-e",
|
|
135
|
+
onPointerDown: (w) => {
|
|
136
|
+
S(w, f.east);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
),
|
|
140
|
+
/* @__PURE__ */ v.exports.jsx(
|
|
141
|
+
"div",
|
|
142
|
+
{
|
|
143
|
+
className: "image-resizer image-resizer-se",
|
|
144
|
+
onPointerDown: (w) => {
|
|
145
|
+
S(w, f.south | f.east);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
),
|
|
149
|
+
/* @__PURE__ */ v.exports.jsx(
|
|
150
|
+
"div",
|
|
151
|
+
{
|
|
152
|
+
className: "image-resizer image-resizer-s",
|
|
153
|
+
onPointerDown: (w) => {
|
|
154
|
+
S(w, f.south);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
),
|
|
158
|
+
/* @__PURE__ */ v.exports.jsx(
|
|
159
|
+
"div",
|
|
160
|
+
{
|
|
161
|
+
className: "image-resizer image-resizer-sw",
|
|
162
|
+
onPointerDown: (w) => {
|
|
163
|
+
S(w, f.south | f.west);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
),
|
|
167
|
+
/* @__PURE__ */ v.exports.jsx(
|
|
168
|
+
"div",
|
|
169
|
+
{
|
|
170
|
+
className: "image-resizer image-resizer-w",
|
|
171
|
+
onPointerDown: (w) => {
|
|
172
|
+
S(w, f.west);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
),
|
|
176
|
+
/* @__PURE__ */ v.exports.jsx(
|
|
177
|
+
"div",
|
|
178
|
+
{
|
|
179
|
+
className: "image-resizer image-resizer-nw",
|
|
180
|
+
onPointerDown: (w) => {
|
|
181
|
+
S(w, f.north | f.west);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
)
|
|
185
|
+
] });
|
|
186
|
+
}
|
|
187
|
+
const Z = {
|
|
188
|
+
x: 0,
|
|
189
|
+
y: 0,
|
|
190
|
+
width: 0,
|
|
191
|
+
height: 0,
|
|
192
|
+
unit: "px"
|
|
193
|
+
}, j = (l, t, e) => Math.min(Math.max(l, t), e), _e = (...l) => l.filter((t) => t && typeof t == "string").join(" "), ie = (l, t) => l === t || l.width === t.width && l.height === t.height && l.x === t.x && l.y === t.y && l.unit === t.unit;
|
|
194
|
+
function B(l, t, e) {
|
|
195
|
+
return l.unit === "%" ? { ...Z, ...l, unit: "%" } : {
|
|
196
|
+
unit: "%",
|
|
197
|
+
x: l.x ? l.x / t * 100 : 0,
|
|
198
|
+
y: l.y ? l.y / e * 100 : 0,
|
|
199
|
+
width: l.width ? l.width / t * 100 : 0,
|
|
200
|
+
height: l.height ? l.height / e * 100 : 0
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
function A(l, t, e) {
|
|
204
|
+
return l.unit ? l.unit === "px" ? { ...Z, ...l, unit: "px" } : {
|
|
205
|
+
unit: "px",
|
|
206
|
+
x: l.x ? l.x * t / 100 : 0,
|
|
207
|
+
y: l.y ? l.y * e / 100 : 0,
|
|
208
|
+
width: l.width ? l.width * t / 100 : 0,
|
|
209
|
+
height: l.height ? l.height * e / 100 : 0
|
|
210
|
+
} : { ...Z, ...l, unit: "px" };
|
|
211
|
+
}
|
|
212
|
+
function oe(l, t, e, o, n, r = 0, h = 0, p = o, s = n) {
|
|
213
|
+
const i = { ...l };
|
|
214
|
+
let d = Math.min(r, o), a = Math.min(h, n), g = Math.min(p, o), c = Math.min(s, n);
|
|
215
|
+
t && (t > 1 ? (d = h ? h * t : d, a = d / t, g = p * t) : (a = r ? r / t : a, d = a * t, c = s / t)), i.y < 0 && (i.height = Math.max(i.height + i.y, a), i.y = 0), i.x < 0 && (i.width = Math.max(i.width + i.x, d), i.x = 0);
|
|
216
|
+
const y = o - (i.x + i.width);
|
|
217
|
+
y < 0 && (i.x = Math.min(i.x, o - d), i.width += y);
|
|
218
|
+
const N = n - (i.y + i.height);
|
|
219
|
+
if (N < 0 && (i.y = Math.min(i.y, n - a), i.height += N), i.width < d && ((e === "sw" || e == "nw") && (i.x -= d - i.width), i.width = d), i.height < a && ((e === "nw" || e == "ne") && (i.y -= a - i.height), i.height = a), i.width > g && ((e === "sw" || e == "nw") && (i.x -= g - i.width), i.width = g), i.height > c && ((e === "nw" || e == "ne") && (i.y -= c - i.height), i.height = c), t) {
|
|
220
|
+
const x = i.width / i.height;
|
|
221
|
+
if (x < t) {
|
|
222
|
+
const P = Math.max(i.width / t, a);
|
|
223
|
+
(e === "nw" || e == "ne") && (i.y -= P - i.height), i.height = P;
|
|
224
|
+
} else if (x > t) {
|
|
225
|
+
const P = Math.max(i.height * t, d);
|
|
226
|
+
(e === "sw" || e == "nw") && (i.x -= P - i.width), i.width = P;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
return i;
|
|
230
|
+
}
|
|
231
|
+
function Pe(l, t, e, o) {
|
|
232
|
+
const n = { ...l };
|
|
233
|
+
return t === "ArrowLeft" ? o === "nw" ? (n.x -= e, n.y -= e, n.width += e, n.height += e) : o === "w" ? (n.x -= e, n.width += e) : o === "sw" ? (n.x -= e, n.width += e, n.height += e) : o === "ne" ? (n.y += e, n.width -= e, n.height -= e) : o === "e" ? n.width -= e : o === "se" && (n.width -= e, n.height -= e) : t === "ArrowRight" && (o === "nw" ? (n.x += e, n.y += e, n.width -= e, n.height -= e) : o === "w" ? (n.x += e, n.width -= e) : o === "sw" ? (n.x += e, n.width -= e, n.height -= e) : o === "ne" ? (n.y -= e, n.width += e, n.height += e) : o === "e" ? n.width += e : o === "se" && (n.width += e, n.height += e)), t === "ArrowUp" ? o === "nw" ? (n.x -= e, n.y -= e, n.width += e, n.height += e) : o === "n" ? (n.y -= e, n.height += e) : o === "ne" ? (n.y -= e, n.width += e, n.height += e) : o === "sw" ? (n.x += e, n.width -= e, n.height -= e) : o === "s" ? n.height -= e : o === "se" && (n.width -= e, n.height -= e) : t === "ArrowDown" && (o === "nw" ? (n.x += e, n.y += e, n.width -= e, n.height -= e) : o === "n" ? (n.y += e, n.height -= e) : o === "ne" ? (n.y += e, n.width -= e, n.height -= e) : o === "sw" ? (n.x -= e, n.width += e, n.height += e) : o === "s" ? n.height += e : o === "se" && (n.width += e, n.height += e)), n;
|
|
234
|
+
}
|
|
235
|
+
const W = { capture: !0, passive: !1 };
|
|
236
|
+
let Se = 0;
|
|
237
|
+
const L = class $ extends Ee {
|
|
238
|
+
constructor() {
|
|
239
|
+
super(...arguments), this.docMoveBound = !1, this.mouseDownOnCrop = !1, this.dragStarted = !1, this.evData = {
|
|
240
|
+
startClientX: 0,
|
|
241
|
+
startClientY: 0,
|
|
242
|
+
startCropX: 0,
|
|
243
|
+
startCropY: 0,
|
|
244
|
+
clientX: 0,
|
|
245
|
+
clientY: 0,
|
|
246
|
+
isResize: !0
|
|
247
|
+
}, this.componentRef = re(), this.mediaRef = re(), this.initChangeCalled = !1, this.instanceId = `rc-${Se++}`, this.state = {
|
|
248
|
+
cropIsActive: !1,
|
|
249
|
+
newCropIsBeingDrawn: !1
|
|
250
|
+
}, this.onCropPointerDown = (t) => {
|
|
251
|
+
const { crop: e, disabled: o } = this.props, n = this.getBox();
|
|
252
|
+
if (!e)
|
|
253
|
+
return;
|
|
254
|
+
const r = A(e, n.width, n.height);
|
|
255
|
+
if (o)
|
|
256
|
+
return;
|
|
257
|
+
t.cancelable && t.preventDefault(), this.bindDocMove(), this.componentRef.current.focus({ preventScroll: !0 });
|
|
258
|
+
const h = t.target.dataset.ord, p = !!h;
|
|
259
|
+
let s = t.clientX, i = t.clientY, d = r.x, a = r.y;
|
|
260
|
+
if (h) {
|
|
261
|
+
const g = t.clientX - n.x, c = t.clientY - n.y;
|
|
262
|
+
let y = 0, N = 0;
|
|
263
|
+
h === "ne" || h == "e" ? (y = g - (r.x + r.width), N = c - r.y, d = r.x, a = r.y + r.height) : h === "se" || h === "s" ? (y = g - (r.x + r.width), N = c - (r.y + r.height), d = r.x, a = r.y) : h === "sw" || h == "w" ? (y = g - r.x, N = c - (r.y + r.height), d = r.x + r.width, a = r.y) : (h === "nw" || h == "n") && (y = g - r.x, N = c - r.y, d = r.x + r.width, a = r.y + r.height), s = d + n.x + y, i = a + n.y + N;
|
|
264
|
+
}
|
|
265
|
+
this.evData = {
|
|
266
|
+
startClientX: s,
|
|
267
|
+
startClientY: i,
|
|
268
|
+
startCropX: d,
|
|
269
|
+
startCropY: a,
|
|
270
|
+
clientX: t.clientX,
|
|
271
|
+
clientY: t.clientY,
|
|
272
|
+
isResize: p,
|
|
273
|
+
ord: h
|
|
274
|
+
}, this.mouseDownOnCrop = !0, this.setState({ cropIsActive: !0 });
|
|
275
|
+
}, this.onComponentPointerDown = (t) => {
|
|
276
|
+
const { crop: e, disabled: o, locked: n, keepSelection: r, onChange: h } = this.props, p = this.getBox();
|
|
277
|
+
if (o || n || r && e)
|
|
278
|
+
return;
|
|
279
|
+
t.cancelable && t.preventDefault(), this.bindDocMove(), this.componentRef.current.focus({ preventScroll: !0 });
|
|
280
|
+
const s = t.clientX - p.x, i = t.clientY - p.y, d = {
|
|
281
|
+
unit: "px",
|
|
282
|
+
x: s,
|
|
283
|
+
y: i,
|
|
284
|
+
width: 0,
|
|
285
|
+
height: 0
|
|
286
|
+
};
|
|
287
|
+
this.evData = {
|
|
288
|
+
startClientX: t.clientX,
|
|
289
|
+
startClientY: t.clientY,
|
|
290
|
+
startCropX: s,
|
|
291
|
+
startCropY: i,
|
|
292
|
+
clientX: t.clientX,
|
|
293
|
+
clientY: t.clientY,
|
|
294
|
+
isResize: !0
|
|
295
|
+
}, this.mouseDownOnCrop = !0, h(A(d, p.width, p.height), B(d, p.width, p.height)), this.setState({ cropIsActive: !0, newCropIsBeingDrawn: !0 });
|
|
296
|
+
}, this.onDocPointerMove = (t) => {
|
|
297
|
+
const { crop: e, disabled: o, onChange: n, onDragStart: r } = this.props, h = this.getBox();
|
|
298
|
+
if (o || !e || !this.mouseDownOnCrop)
|
|
299
|
+
return;
|
|
300
|
+
t.cancelable && t.preventDefault(), this.dragStarted || (this.dragStarted = !0, r && r(t));
|
|
301
|
+
const { evData: p } = this;
|
|
302
|
+
p.clientX = t.clientX, p.clientY = t.clientY;
|
|
303
|
+
let s;
|
|
304
|
+
p.isResize ? s = this.resizeCrop() : s = this.dragCrop(), ie(e, s) || n(
|
|
305
|
+
A(s, h.width, h.height),
|
|
306
|
+
B(s, h.width, h.height)
|
|
307
|
+
);
|
|
308
|
+
}, this.onComponentKeyDown = (t) => {
|
|
309
|
+
const { crop: e, disabled: o, onChange: n, onComplete: r } = this.props;
|
|
310
|
+
if (o)
|
|
311
|
+
return;
|
|
312
|
+
const h = t.key;
|
|
313
|
+
let p = !1;
|
|
314
|
+
if (!e)
|
|
315
|
+
return;
|
|
316
|
+
const s = this.getBox(), i = this.makePixelCrop(s), d = (navigator.platform.match("Mac") ? t.metaKey : t.ctrlKey) ? $.nudgeStepLarge : t.shiftKey ? $.nudgeStepMedium : $.nudgeStep;
|
|
317
|
+
if (h === "ArrowLeft" ? (i.x -= d, p = !0) : h === "ArrowRight" ? (i.x += d, p = !0) : h === "ArrowUp" ? (i.y -= d, p = !0) : h === "ArrowDown" && (i.y += d, p = !0), p) {
|
|
318
|
+
t.cancelable && t.preventDefault(), i.x = j(i.x, 0, s.width - i.width), i.y = j(i.y, 0, s.height - i.height);
|
|
319
|
+
const a = A(i, s.width, s.height), g = B(i, s.width, s.height);
|
|
320
|
+
n(a, g), r && r(a, g);
|
|
321
|
+
}
|
|
322
|
+
}, this.onHandlerKeyDown = (t, e) => {
|
|
323
|
+
const {
|
|
324
|
+
aspect: o = 0,
|
|
325
|
+
crop: n,
|
|
326
|
+
disabled: r,
|
|
327
|
+
minWidth: h = 0,
|
|
328
|
+
minHeight: p = 0,
|
|
329
|
+
maxWidth: s,
|
|
330
|
+
maxHeight: i,
|
|
331
|
+
onChange: d,
|
|
332
|
+
onComplete: a
|
|
333
|
+
} = this.props, g = this.getBox();
|
|
334
|
+
if (r || !n)
|
|
335
|
+
return;
|
|
336
|
+
if (t.key === "ArrowUp" || t.key === "ArrowDown" || t.key === "ArrowLeft" || t.key === "ArrowRight")
|
|
337
|
+
t.stopPropagation(), t.preventDefault();
|
|
338
|
+
else
|
|
339
|
+
return;
|
|
340
|
+
const c = (navigator.platform.match("Mac") ? t.metaKey : t.ctrlKey) ? $.nudgeStepLarge : t.shiftKey ? $.nudgeStepMedium : $.nudgeStep, y = A(n, g.width, g.height), N = Pe(y, t.key, c, e), x = oe(
|
|
341
|
+
N,
|
|
342
|
+
o,
|
|
343
|
+
e,
|
|
344
|
+
g.width,
|
|
345
|
+
g.height,
|
|
346
|
+
h,
|
|
347
|
+
p,
|
|
348
|
+
s,
|
|
349
|
+
i
|
|
350
|
+
);
|
|
351
|
+
if (!ie(n, x)) {
|
|
352
|
+
const P = B(x, g.width, g.height);
|
|
353
|
+
d(x, P), a && a(x, P);
|
|
354
|
+
}
|
|
355
|
+
}, this.onDocPointerDone = (t) => {
|
|
356
|
+
const { crop: e, disabled: o, onComplete: n, onDragEnd: r } = this.props, h = this.getBox();
|
|
357
|
+
this.unbindDocMove(), !(o || !e) && this.mouseDownOnCrop && (this.mouseDownOnCrop = !1, this.dragStarted = !1, r && r(t), n && n(A(e, h.width, h.height), B(e, h.width, h.height)), this.setState({ cropIsActive: !1, newCropIsBeingDrawn: !1 }));
|
|
358
|
+
}, this.onDragFocus = () => {
|
|
359
|
+
var t;
|
|
360
|
+
(t = this.componentRef.current) == null || t.scrollTo(0, 0);
|
|
361
|
+
};
|
|
362
|
+
}
|
|
363
|
+
get document() {
|
|
364
|
+
return document;
|
|
365
|
+
}
|
|
366
|
+
// We unfortunately get the bounding box every time as x+y changes
|
|
367
|
+
// due to scrolling.
|
|
368
|
+
getBox() {
|
|
369
|
+
const t = this.mediaRef.current;
|
|
370
|
+
if (!t)
|
|
371
|
+
return { x: 0, y: 0, width: 0, height: 0 };
|
|
372
|
+
const { x: e, y: o, width: n, height: r } = t.getBoundingClientRect();
|
|
373
|
+
return { x: e, y: o, width: n, height: r };
|
|
374
|
+
}
|
|
375
|
+
componentDidUpdate(t) {
|
|
376
|
+
const { crop: e, onComplete: o } = this.props;
|
|
377
|
+
if (o && !t.crop && e) {
|
|
378
|
+
const { width: n, height: r } = this.getBox();
|
|
379
|
+
n && r && o(A(e, n, r), B(e, n, r));
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
componentWillUnmount() {
|
|
383
|
+
this.resizeObserver && this.resizeObserver.disconnect(), this.unbindDocMove();
|
|
384
|
+
}
|
|
385
|
+
bindDocMove() {
|
|
386
|
+
this.docMoveBound || (this.document.addEventListener("pointermove", this.onDocPointerMove, W), this.document.addEventListener("pointerup", this.onDocPointerDone, W), this.document.addEventListener("pointercancel", this.onDocPointerDone, W), this.docMoveBound = !0);
|
|
387
|
+
}
|
|
388
|
+
unbindDocMove() {
|
|
389
|
+
this.docMoveBound && (this.document.removeEventListener("pointermove", this.onDocPointerMove, W), this.document.removeEventListener("pointerup", this.onDocPointerDone, W), this.document.removeEventListener("pointercancel", this.onDocPointerDone, W), this.docMoveBound = !1);
|
|
390
|
+
}
|
|
391
|
+
getCropStyle() {
|
|
392
|
+
const { crop: t } = this.props;
|
|
393
|
+
if (t)
|
|
394
|
+
return {
|
|
395
|
+
top: `${t.y}${t.unit}`,
|
|
396
|
+
left: `${t.x}${t.unit}`,
|
|
397
|
+
width: `${t.width}${t.unit}`,
|
|
398
|
+
height: `${t.height}${t.unit}`
|
|
399
|
+
};
|
|
400
|
+
}
|
|
401
|
+
dragCrop() {
|
|
402
|
+
const { evData: t } = this, e = this.getBox(), o = this.makePixelCrop(e), n = t.clientX - t.startClientX, r = t.clientY - t.startClientY;
|
|
403
|
+
return o.x = j(t.startCropX + n, 0, e.width - o.width), o.y = j(t.startCropY + r, 0, e.height - o.height), o;
|
|
404
|
+
}
|
|
405
|
+
getPointRegion(t, e, o, n) {
|
|
406
|
+
const { evData: r } = this, h = r.clientX - t.x, p = r.clientY - t.y;
|
|
407
|
+
let s;
|
|
408
|
+
n && e ? s = e === "nw" || e === "n" || e === "ne" : s = p < r.startCropY;
|
|
409
|
+
let i;
|
|
410
|
+
return o && e ? i = e === "nw" || e === "w" || e === "sw" : i = h < r.startCropX, i ? s ? "nw" : "sw" : s ? "ne" : "se";
|
|
411
|
+
}
|
|
412
|
+
resolveMinDimensions(t, e, o = 0, n = 0) {
|
|
413
|
+
const r = Math.min(o, t.width), h = Math.min(n, t.height);
|
|
414
|
+
return !e || !r && !h ? [r, h] : e > 1 ? r ? [r, r / e] : [h * e, h] : h ? [h * e, h] : [r, r / e];
|
|
415
|
+
}
|
|
416
|
+
resizeCrop() {
|
|
417
|
+
const { evData: t } = this, { aspect: e = 0, maxWidth: o, maxHeight: n } = this.props, r = this.getBox(), [h, p] = this.resolveMinDimensions(r, e, this.props.minWidth, this.props.minHeight);
|
|
418
|
+
let s = this.makePixelCrop(r);
|
|
419
|
+
const i = this.getPointRegion(r, t.ord, h, p), d = t.ord || i;
|
|
420
|
+
let a = t.clientX - t.startClientX, g = t.clientY - t.startClientY;
|
|
421
|
+
(h && d === "nw" || d === "w" || d === "sw") && (a = Math.min(a, -h)), (p && d === "nw" || d === "n" || d === "ne") && (g = Math.min(g, -p));
|
|
422
|
+
const c = {
|
|
423
|
+
unit: "px",
|
|
424
|
+
x: 0,
|
|
425
|
+
y: 0,
|
|
426
|
+
width: 0,
|
|
427
|
+
height: 0
|
|
428
|
+
};
|
|
429
|
+
i === "ne" ? (c.x = t.startCropX, c.width = a, e ? (c.height = c.width / e, c.y = t.startCropY - c.height) : (c.height = Math.abs(g), c.y = t.startCropY - c.height)) : i === "se" ? (c.x = t.startCropX, c.y = t.startCropY, c.width = a, e ? c.height = c.width / e : c.height = g) : i === "sw" ? (c.x = t.startCropX + a, c.y = t.startCropY, c.width = Math.abs(a), e ? c.height = c.width / e : c.height = g) : i === "nw" && (c.x = t.startCropX + a, c.width = Math.abs(a), e ? (c.height = c.width / e, c.y = t.startCropY - c.height) : (c.height = Math.abs(g), c.y = t.startCropY + g));
|
|
430
|
+
const y = oe(
|
|
431
|
+
c,
|
|
432
|
+
e,
|
|
433
|
+
i,
|
|
434
|
+
r.width,
|
|
435
|
+
r.height,
|
|
436
|
+
h,
|
|
437
|
+
p,
|
|
438
|
+
o,
|
|
439
|
+
n
|
|
440
|
+
);
|
|
441
|
+
return e || $.xyOrds.indexOf(d) > -1 ? s = y : $.xOrds.indexOf(d) > -1 ? (s.x = y.x, s.width = y.width) : $.yOrds.indexOf(d) > -1 && (s.y = y.y, s.height = y.height), s.x = j(s.x, 0, r.width - s.width), s.y = j(s.y, 0, r.height - s.height), s;
|
|
442
|
+
}
|
|
443
|
+
renderCropSelection() {
|
|
444
|
+
const {
|
|
445
|
+
ariaLabels: t = $.defaultProps.ariaLabels,
|
|
446
|
+
disabled: e,
|
|
447
|
+
locked: o,
|
|
448
|
+
renderSelectionAddon: n,
|
|
449
|
+
ruleOfThirds: r,
|
|
450
|
+
crop: h
|
|
451
|
+
} = this.props, p = this.getCropStyle();
|
|
452
|
+
if (h)
|
|
453
|
+
return /* @__PURE__ */ C.createElement(
|
|
454
|
+
"div",
|
|
455
|
+
{
|
|
456
|
+
style: p,
|
|
457
|
+
className: "ReactCrop__crop-selection",
|
|
458
|
+
onPointerDown: this.onCropPointerDown,
|
|
459
|
+
"aria-label": t.cropArea,
|
|
460
|
+
tabIndex: 0,
|
|
461
|
+
onKeyDown: this.onComponentKeyDown,
|
|
462
|
+
role: "group"
|
|
463
|
+
},
|
|
464
|
+
!e && !o && /* @__PURE__ */ C.createElement("div", { className: "ReactCrop__drag-elements", onFocus: this.onDragFocus }, /* @__PURE__ */ C.createElement("div", { className: "ReactCrop__drag-bar ord-n", "data-ord": "n" }), /* @__PURE__ */ C.createElement("div", { className: "ReactCrop__drag-bar ord-e", "data-ord": "e" }), /* @__PURE__ */ C.createElement("div", { className: "ReactCrop__drag-bar ord-s", "data-ord": "s" }), /* @__PURE__ */ C.createElement("div", { className: "ReactCrop__drag-bar ord-w", "data-ord": "w" }), /* @__PURE__ */ C.createElement(
|
|
465
|
+
"div",
|
|
466
|
+
{
|
|
467
|
+
className: "ReactCrop__drag-handle ord-nw",
|
|
468
|
+
"data-ord": "nw",
|
|
469
|
+
tabIndex: 0,
|
|
470
|
+
"aria-label": t.nwDragHandle,
|
|
471
|
+
onKeyDown: (s) => this.onHandlerKeyDown(s, "nw"),
|
|
472
|
+
role: "button"
|
|
473
|
+
}
|
|
474
|
+
), /* @__PURE__ */ C.createElement(
|
|
475
|
+
"div",
|
|
476
|
+
{
|
|
477
|
+
className: "ReactCrop__drag-handle ord-n",
|
|
478
|
+
"data-ord": "n",
|
|
479
|
+
tabIndex: 0,
|
|
480
|
+
"aria-label": t.nDragHandle,
|
|
481
|
+
onKeyDown: (s) => this.onHandlerKeyDown(s, "n"),
|
|
482
|
+
role: "button"
|
|
483
|
+
}
|
|
484
|
+
), /* @__PURE__ */ C.createElement(
|
|
485
|
+
"div",
|
|
486
|
+
{
|
|
487
|
+
className: "ReactCrop__drag-handle ord-ne",
|
|
488
|
+
"data-ord": "ne",
|
|
489
|
+
tabIndex: 0,
|
|
490
|
+
"aria-label": t.neDragHandle,
|
|
491
|
+
onKeyDown: (s) => this.onHandlerKeyDown(s, "ne"),
|
|
492
|
+
role: "button"
|
|
493
|
+
}
|
|
494
|
+
), /* @__PURE__ */ C.createElement(
|
|
495
|
+
"div",
|
|
496
|
+
{
|
|
497
|
+
className: "ReactCrop__drag-handle ord-e",
|
|
498
|
+
"data-ord": "e",
|
|
499
|
+
tabIndex: 0,
|
|
500
|
+
"aria-label": t.eDragHandle,
|
|
501
|
+
onKeyDown: (s) => this.onHandlerKeyDown(s, "e"),
|
|
502
|
+
role: "button"
|
|
503
|
+
}
|
|
504
|
+
), /* @__PURE__ */ C.createElement(
|
|
505
|
+
"div",
|
|
506
|
+
{
|
|
507
|
+
className: "ReactCrop__drag-handle ord-se",
|
|
508
|
+
"data-ord": "se",
|
|
509
|
+
tabIndex: 0,
|
|
510
|
+
"aria-label": t.seDragHandle,
|
|
511
|
+
onKeyDown: (s) => this.onHandlerKeyDown(s, "se"),
|
|
512
|
+
role: "button"
|
|
513
|
+
}
|
|
514
|
+
), /* @__PURE__ */ C.createElement(
|
|
515
|
+
"div",
|
|
516
|
+
{
|
|
517
|
+
className: "ReactCrop__drag-handle ord-s",
|
|
518
|
+
"data-ord": "s",
|
|
519
|
+
tabIndex: 0,
|
|
520
|
+
"aria-label": t.sDragHandle,
|
|
521
|
+
onKeyDown: (s) => this.onHandlerKeyDown(s, "s"),
|
|
522
|
+
role: "button"
|
|
523
|
+
}
|
|
524
|
+
), /* @__PURE__ */ C.createElement(
|
|
525
|
+
"div",
|
|
526
|
+
{
|
|
527
|
+
className: "ReactCrop__drag-handle ord-sw",
|
|
528
|
+
"data-ord": "sw",
|
|
529
|
+
tabIndex: 0,
|
|
530
|
+
"aria-label": t.swDragHandle,
|
|
531
|
+
onKeyDown: (s) => this.onHandlerKeyDown(s, "sw"),
|
|
532
|
+
role: "button"
|
|
533
|
+
}
|
|
534
|
+
), /* @__PURE__ */ C.createElement(
|
|
535
|
+
"div",
|
|
536
|
+
{
|
|
537
|
+
className: "ReactCrop__drag-handle ord-w",
|
|
538
|
+
"data-ord": "w",
|
|
539
|
+
tabIndex: 0,
|
|
540
|
+
"aria-label": t.wDragHandle,
|
|
541
|
+
onKeyDown: (s) => this.onHandlerKeyDown(s, "w"),
|
|
542
|
+
role: "button"
|
|
543
|
+
}
|
|
544
|
+
)),
|
|
545
|
+
n && /* @__PURE__ */ C.createElement("div", { className: "ReactCrop__selection-addon", onPointerDown: (s) => s.stopPropagation() }, n(this.state)),
|
|
546
|
+
r && /* @__PURE__ */ C.createElement(C.Fragment, null, /* @__PURE__ */ C.createElement("div", { className: "ReactCrop__rule-of-thirds-hz" }), /* @__PURE__ */ C.createElement("div", { className: "ReactCrop__rule-of-thirds-vt" }))
|
|
547
|
+
);
|
|
548
|
+
}
|
|
549
|
+
makePixelCrop(t) {
|
|
550
|
+
const e = { ...Z, ...this.props.crop || {} };
|
|
551
|
+
return A(e, t.width, t.height);
|
|
552
|
+
}
|
|
553
|
+
render() {
|
|
554
|
+
const { aspect: t, children: e, circularCrop: o, className: n, crop: r, disabled: h, locked: p, style: s, ruleOfThirds: i } = this.props, { cropIsActive: d, newCropIsBeingDrawn: a } = this.state, g = r ? this.renderCropSelection() : null, c = _e(
|
|
555
|
+
"ReactCrop",
|
|
556
|
+
n,
|
|
557
|
+
d && "ReactCrop--active",
|
|
558
|
+
h && "ReactCrop--disabled",
|
|
559
|
+
p && "ReactCrop--locked",
|
|
560
|
+
a && "ReactCrop--new-crop",
|
|
561
|
+
r && t && "ReactCrop--fixed-aspect",
|
|
562
|
+
r && o && "ReactCrop--circular-crop",
|
|
563
|
+
r && i && "ReactCrop--rule-of-thirds",
|
|
564
|
+
!this.dragStarted && r && !r.width && !r.height && "ReactCrop--invisible-crop",
|
|
565
|
+
o && "ReactCrop--no-animate"
|
|
566
|
+
);
|
|
567
|
+
return /* @__PURE__ */ C.createElement("div", { ref: this.componentRef, className: c, style: s }, /* @__PURE__ */ C.createElement("div", { ref: this.mediaRef, className: "ReactCrop__child-wrapper", onPointerDown: this.onComponentPointerDown }, e), r ? /* @__PURE__ */ C.createElement("svg", { className: "ReactCrop__crop-mask", width: "100%", height: "100%" }, /* @__PURE__ */ C.createElement("defs", null, /* @__PURE__ */ C.createElement("mask", { id: `hole-${this.instanceId}` }, /* @__PURE__ */ C.createElement("rect", { width: "100%", height: "100%", fill: "white" }), o ? /* @__PURE__ */ C.createElement(
|
|
568
|
+
"ellipse",
|
|
569
|
+
{
|
|
570
|
+
cx: `${r.x + r.width / 2}${r.unit}`,
|
|
571
|
+
cy: `${r.y + r.height / 2}${r.unit}`,
|
|
572
|
+
rx: `${r.width / 2}${r.unit}`,
|
|
573
|
+
ry: `${r.height / 2}${r.unit}`,
|
|
574
|
+
fill: "black"
|
|
575
|
+
}
|
|
576
|
+
) : /* @__PURE__ */ C.createElement(
|
|
577
|
+
"rect",
|
|
578
|
+
{
|
|
579
|
+
x: `${r.x}${r.unit}`,
|
|
580
|
+
y: `${r.y}${r.unit}`,
|
|
581
|
+
width: `${r.width}${r.unit}`,
|
|
582
|
+
height: `${r.height}${r.unit}`,
|
|
583
|
+
fill: "black"
|
|
584
|
+
}
|
|
585
|
+
))), /* @__PURE__ */ C.createElement("rect", { fill: "black", fillOpacity: 0.5, width: "100%", height: "100%", mask: `url(#hole-${this.instanceId})` })) : void 0, g);
|
|
586
|
+
}
|
|
587
|
+
};
|
|
588
|
+
L.xOrds = ["e", "w"], L.yOrds = ["n", "s"], L.xyOrds = ["nw", "ne", "se", "sw"], L.nudgeStep = 1, L.nudgeStepMedium = 10, L.nudgeStepLarge = 100, L.defaultProps = {
|
|
589
|
+
ariaLabels: {
|
|
590
|
+
cropArea: "Use the arrow keys to move the crop selection area",
|
|
591
|
+
nwDragHandle: "Use the arrow keys to move the north west drag handle to change the crop selection area",
|
|
592
|
+
nDragHandle: "Use the up and down arrow keys to move the north drag handle to change the crop selection area",
|
|
593
|
+
neDragHandle: "Use the arrow keys to move the north east drag handle to change the crop selection area",
|
|
594
|
+
eDragHandle: "Use the up and down arrow keys to move the east drag handle to change the crop selection area",
|
|
595
|
+
seDragHandle: "Use the arrow keys to move the south east drag handle to change the crop selection area",
|
|
596
|
+
sDragHandle: "Use the up and down arrow keys to move the south drag handle to change the crop selection area",
|
|
597
|
+
swDragHandle: "Use the arrow keys to move the south west drag handle to change the crop selection area",
|
|
598
|
+
wDragHandle: "Use the up and down arrow keys to move the west drag handle to change the crop selection area"
|
|
599
|
+
}
|
|
600
|
+
};
|
|
601
|
+
let He = L;
|
|
602
|
+
const se = be("RIGHT_CLICK_IMAGE_COMMAND");
|
|
603
|
+
function $e({
|
|
604
|
+
altText: l,
|
|
605
|
+
className: t,
|
|
606
|
+
src: e,
|
|
607
|
+
width: o,
|
|
608
|
+
height: n,
|
|
609
|
+
maxWidth: r,
|
|
610
|
+
imageRef: h,
|
|
611
|
+
startCrop: p,
|
|
612
|
+
setStartCrop: s,
|
|
613
|
+
isFocused: i,
|
|
614
|
+
nodeKey: d
|
|
615
|
+
}) {
|
|
616
|
+
const [a, g] = U(null), [c, y] = U(null), [N, x] = U({
|
|
617
|
+
//@ts-ignore
|
|
618
|
+
unit: "px",
|
|
619
|
+
// Can be 'px' or '%'
|
|
620
|
+
x: 25,
|
|
621
|
+
y: 25,
|
|
622
|
+
width: 50,
|
|
623
|
+
height: 50
|
|
624
|
+
}), [P] = ae(), T = () => {
|
|
625
|
+
if (a) {
|
|
626
|
+
const u = h.current;
|
|
627
|
+
if (!u || !a)
|
|
628
|
+
return;
|
|
629
|
+
const m = u.naturalWidth / u.width, _ = u.naturalHeight / u.height, M = new OffscreenCanvas(
|
|
630
|
+
a.width * m,
|
|
631
|
+
a.height * _
|
|
632
|
+
), b = M.getContext("2d");
|
|
633
|
+
if (!b)
|
|
634
|
+
throw new Error("No 2D context available");
|
|
635
|
+
b.drawImage(
|
|
636
|
+
u,
|
|
637
|
+
a.x * m,
|
|
638
|
+
a.y * _,
|
|
639
|
+
a.width * m,
|
|
640
|
+
a.height * _,
|
|
641
|
+
0,
|
|
642
|
+
0,
|
|
643
|
+
a.width * m,
|
|
644
|
+
a.height * _
|
|
645
|
+
), M.convertToBlob({ type: "image/png" }).then((D) => {
|
|
646
|
+
const X = URL.createObjectURL(D);
|
|
647
|
+
y(X), s(!1);
|
|
648
|
+
const O = new FileReader();
|
|
649
|
+
O.onload = () => {
|
|
650
|
+
const K = O.result;
|
|
651
|
+
P.update(() => {
|
|
652
|
+
const R = J(d);
|
|
653
|
+
Q(R) && K && R.setSrc(K);
|
|
654
|
+
});
|
|
655
|
+
}, O.onerror = () => {
|
|
656
|
+
console.log("error");
|
|
657
|
+
}, O.readAsDataURL(D);
|
|
658
|
+
});
|
|
659
|
+
}
|
|
660
|
+
}, S = () => {
|
|
661
|
+
p || s((u) => {
|
|
662
|
+
if (u === !1) {
|
|
663
|
+
const m = h.current;
|
|
664
|
+
x({
|
|
665
|
+
unit: "px",
|
|
666
|
+
// Can be 'px' or '%'
|
|
667
|
+
x: 0,
|
|
668
|
+
y: 0,
|
|
669
|
+
width: m.width,
|
|
670
|
+
height: m.height
|
|
671
|
+
});
|
|
672
|
+
}
|
|
673
|
+
return !u;
|
|
674
|
+
});
|
|
675
|
+
}, k = Y(null), I = Y(null);
|
|
676
|
+
te(() => {
|
|
677
|
+
a && (k.current = a);
|
|
678
|
+
}, [a]);
|
|
679
|
+
const w = (u) => {
|
|
680
|
+
I.current && !I.current.contains(u.target) && s(!1);
|
|
681
|
+
};
|
|
682
|
+
return te(() => (document.addEventListener("mousedown", w), () => {
|
|
683
|
+
document.removeEventListener("mousedown", w);
|
|
684
|
+
}), []), /* @__PURE__ */ v.exports.jsxs("div", { ref: I, children: [
|
|
685
|
+
i && /* @__PURE__ */ v.exports.jsx(
|
|
686
|
+
"button",
|
|
687
|
+
{
|
|
688
|
+
style: { zIndex: 999 },
|
|
689
|
+
className: "image-caption-button",
|
|
690
|
+
onClick: () => S(),
|
|
691
|
+
children: "Crop"
|
|
692
|
+
}
|
|
693
|
+
),
|
|
694
|
+
p && /* @__PURE__ */ v.exports.jsx(
|
|
695
|
+
"button",
|
|
696
|
+
{
|
|
697
|
+
style: { zIndex: 999 },
|
|
698
|
+
className: "image-caption-button",
|
|
699
|
+
onClick: () => T(),
|
|
700
|
+
children: "Apply Crop"
|
|
701
|
+
}
|
|
702
|
+
),
|
|
703
|
+
p ? /* @__PURE__ */ v.exports.jsx(
|
|
704
|
+
He,
|
|
705
|
+
{
|
|
706
|
+
crop: N,
|
|
707
|
+
onChange: (u) => x(u),
|
|
708
|
+
onComplete: (u) => g(u),
|
|
709
|
+
children: /* @__PURE__ */ v.exports.jsx(
|
|
710
|
+
"img",
|
|
711
|
+
{
|
|
712
|
+
className: t || void 0,
|
|
713
|
+
src: c || e,
|
|
714
|
+
alt: l,
|
|
715
|
+
ref: h,
|
|
716
|
+
style: {
|
|
717
|
+
height: n,
|
|
718
|
+
maxWidth: r,
|
|
719
|
+
width: o
|
|
720
|
+
},
|
|
721
|
+
draggable: "false"
|
|
722
|
+
}
|
|
723
|
+
)
|
|
724
|
+
}
|
|
725
|
+
) : (
|
|
726
|
+
// When startCrop is false, show the cropped image or original image
|
|
727
|
+
/* @__PURE__ */ v.exports.jsx(
|
|
728
|
+
"img",
|
|
729
|
+
{
|
|
730
|
+
className: t || void 0,
|
|
731
|
+
src: c || e,
|
|
732
|
+
alt: l,
|
|
733
|
+
ref: h,
|
|
734
|
+
style: {
|
|
735
|
+
height: n,
|
|
736
|
+
maxWidth: r,
|
|
737
|
+
width: o
|
|
738
|
+
},
|
|
739
|
+
draggable: "false"
|
|
740
|
+
}
|
|
741
|
+
)
|
|
742
|
+
)
|
|
743
|
+
] });
|
|
744
|
+
}
|
|
745
|
+
function Ye({
|
|
746
|
+
src: l,
|
|
747
|
+
altText: t,
|
|
748
|
+
nodeKey: e,
|
|
749
|
+
width: o,
|
|
750
|
+
height: n,
|
|
751
|
+
maxWidth: r,
|
|
752
|
+
resizable: h,
|
|
753
|
+
showCaption: p,
|
|
754
|
+
caption: s
|
|
755
|
+
}) {
|
|
756
|
+
const i = Y(null), d = Y(null), [a, g, c] = ce(e), [y, N] = U(!1), [x] = ae(), [P, T] = U(null), [S, k] = U(!1), I = Y(null), w = V(
|
|
757
|
+
(R) => {
|
|
758
|
+
if (a && G(q())) {
|
|
759
|
+
R.preventDefault();
|
|
760
|
+
const H = J(e);
|
|
761
|
+
if (Q(H))
|
|
762
|
+
return H.remove(), !0;
|
|
763
|
+
}
|
|
764
|
+
return !1;
|
|
765
|
+
},
|
|
766
|
+
[a, e]
|
|
767
|
+
), u = V(
|
|
768
|
+
(R) => {
|
|
769
|
+
const E = q(), H = d.current;
|
|
770
|
+
if (a && G(E) && E.getNodes().length === 1) {
|
|
771
|
+
if (p)
|
|
772
|
+
return ne(null), R.preventDefault(), s.focus(), !0;
|
|
773
|
+
if (H !== null && H !== document.activeElement)
|
|
774
|
+
return R.preventDefault(), H.focus(), !0;
|
|
775
|
+
}
|
|
776
|
+
return !1;
|
|
777
|
+
},
|
|
778
|
+
[s, a, p]
|
|
779
|
+
), m = V(
|
|
780
|
+
(R) => I.current === s || d.current === R.target ? (ne(null), x.update(() => {
|
|
781
|
+
g(!0);
|
|
782
|
+
const E = x.getRootElement();
|
|
783
|
+
E !== null && E.focus();
|
|
784
|
+
}), !0) : !1,
|
|
785
|
+
[s, x, g]
|
|
786
|
+
), _ = V(
|
|
787
|
+
(R) => {
|
|
788
|
+
const E = R;
|
|
789
|
+
return y ? !0 : E.target === i.current ? (E.shiftKey ? g(!a) : (c(), g(!0)), !0) : !1;
|
|
790
|
+
},
|
|
791
|
+
[y, a, g, c]
|
|
792
|
+
), M = V(
|
|
793
|
+
(R) => {
|
|
794
|
+
x.getEditorState().read(() => {
|
|
795
|
+
const E = q();
|
|
796
|
+
R.target.tagName === "IMG" && de(E) && E.getNodes().length === 1 && x.dispatchCommand(
|
|
797
|
+
se,
|
|
798
|
+
R
|
|
799
|
+
);
|
|
800
|
+
});
|
|
801
|
+
},
|
|
802
|
+
[x]
|
|
803
|
+
);
|
|
804
|
+
te(() => {
|
|
805
|
+
let R = !0;
|
|
806
|
+
const E = x.getRootElement(), H = le(
|
|
807
|
+
x.registerUpdateListener(({ editorState: F }) => {
|
|
808
|
+
R && T(F.read(() => q()));
|
|
809
|
+
}),
|
|
810
|
+
x.registerCommand(
|
|
811
|
+
ge,
|
|
812
|
+
(F, he) => (I.current = he, !1),
|
|
813
|
+
z
|
|
814
|
+
),
|
|
815
|
+
x.registerCommand(
|
|
816
|
+
ue,
|
|
817
|
+
_,
|
|
818
|
+
z
|
|
819
|
+
),
|
|
820
|
+
x.registerCommand(
|
|
821
|
+
se,
|
|
822
|
+
_,
|
|
823
|
+
z
|
|
824
|
+
),
|
|
825
|
+
x.registerCommand(
|
|
826
|
+
pe,
|
|
827
|
+
(F) => F.target === i.current ? (F.preventDefault(), !0) : !1,
|
|
828
|
+
z
|
|
829
|
+
),
|
|
830
|
+
x.registerCommand(
|
|
831
|
+
we,
|
|
832
|
+
w,
|
|
833
|
+
z
|
|
834
|
+
),
|
|
835
|
+
x.registerCommand(
|
|
836
|
+
me,
|
|
837
|
+
w,
|
|
838
|
+
z
|
|
839
|
+
),
|
|
840
|
+
x.registerCommand(xe, u, z),
|
|
841
|
+
x.registerCommand(Ce, m, z)
|
|
842
|
+
);
|
|
843
|
+
return E == null || E.addEventListener("contextmenu", M), () => {
|
|
844
|
+
R = !1, H(), E == null || E.removeEventListener("contextmenu", M);
|
|
845
|
+
};
|
|
846
|
+
}, [
|
|
847
|
+
c,
|
|
848
|
+
x,
|
|
849
|
+
y,
|
|
850
|
+
a,
|
|
851
|
+
e,
|
|
852
|
+
w,
|
|
853
|
+
u,
|
|
854
|
+
m,
|
|
855
|
+
_,
|
|
856
|
+
M,
|
|
857
|
+
g
|
|
858
|
+
]);
|
|
859
|
+
const b = () => {
|
|
860
|
+
x.update(() => {
|
|
861
|
+
const R = J(e);
|
|
862
|
+
Q(R) && R.setShowCaption(!0);
|
|
863
|
+
});
|
|
864
|
+
}, D = (R, E) => {
|
|
865
|
+
setTimeout(() => {
|
|
866
|
+
N(!1);
|
|
867
|
+
}, 200), x.update(() => {
|
|
868
|
+
const H = J(e);
|
|
869
|
+
console.log(H, "node"), Q(H) && H.setWidthAndHeight(R, E);
|
|
870
|
+
});
|
|
871
|
+
}, X = () => {
|
|
872
|
+
S || N(!0);
|
|
873
|
+
}, O = a && G(P) && !y, K = a || y;
|
|
874
|
+
return /* @__PURE__ */ v.exports.jsx(Me, { fallback: null, children: /* @__PURE__ */ v.exports.jsxs(v.exports.Fragment, { children: [
|
|
875
|
+
/* @__PURE__ */ v.exports.jsx("div", { draggable: O, children: /* @__PURE__ */ v.exports.jsx(
|
|
876
|
+
$e,
|
|
877
|
+
{
|
|
878
|
+
className: K ? `focused ${G(P) ? "draggable" : ""}` : null,
|
|
879
|
+
src: l,
|
|
880
|
+
altText: t,
|
|
881
|
+
width: o,
|
|
882
|
+
height: n,
|
|
883
|
+
maxWidth: r,
|
|
884
|
+
imageRef: i,
|
|
885
|
+
startCrop: S,
|
|
886
|
+
setStartCrop: k,
|
|
887
|
+
isFocused: K,
|
|
888
|
+
nodeKey: e
|
|
889
|
+
}
|
|
890
|
+
) }),
|
|
891
|
+
p && /* @__PURE__ */ v.exports.jsx("div", { className: "image-caption-container", children: /* @__PURE__ */ v.exports.jsx(Re, { initialEditor: s, children: /* @__PURE__ */ v.exports.jsx(
|
|
892
|
+
fe,
|
|
893
|
+
{
|
|
894
|
+
contentEditable: /* @__PURE__ */ v.exports.jsx(ye, { className: "ImageNode__contentEditable" }),
|
|
895
|
+
placeholder: /* @__PURE__ */ v.exports.jsx(De, { className: "ImageNode__placeholder", children: "Enter a caption..." }),
|
|
896
|
+
ErrorBoundary: ve
|
|
897
|
+
}
|
|
898
|
+
) }) }),
|
|
899
|
+
!S && h && G(P) && K && /* @__PURE__ */ v.exports.jsx(
|
|
900
|
+
Ne,
|
|
901
|
+
{
|
|
902
|
+
showCaption: p,
|
|
903
|
+
setShowCaption: b,
|
|
904
|
+
editor: x,
|
|
905
|
+
buttonRef: d,
|
|
906
|
+
maxWidth: r,
|
|
907
|
+
onResizeStart: S ? () => {
|
|
908
|
+
} : X,
|
|
909
|
+
onResizeEnd: S ? () => {
|
|
910
|
+
} : D,
|
|
911
|
+
captionsEnabled: !1,
|
|
912
|
+
imageRef: i
|
|
913
|
+
}
|
|
914
|
+
)
|
|
915
|
+
] }) });
|
|
916
|
+
}
|
|
917
|
+
export {
|
|
918
|
+
se as RIGHT_CLICK_IMAGE_COMMAND,
|
|
919
|
+
Ye as default
|
|
920
|
+
};
|
|
921
|
+
//# sourceMappingURL=ImageComponent-855cf80f.js.map
|