@layers-app/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.
@@ -0,0 +1,155 @@
1
+ import { jsx as o, jsxs as C } from "react/jsx-runtime";
2
+ import { useMemo as I, useState as D, useRef as S, useCallback as $, useEffect as R } from "react";
3
+ import { b as V, a as j, w as P, R as x, C as k, l as b, N as E, k as w, K as v, e as B, r as y, B as A, m as T, n as W } from "./DSD.BSMoqlgJ.js";
4
+ function O(...t) {
5
+ return t.filter(Boolean).join(" ");
6
+ }
7
+ function F(t) {
8
+ return t.reduce((c, n) => c + n.votes.length, 0);
9
+ }
10
+ function L({
11
+ option: t,
12
+ index: c,
13
+ options: n,
14
+ totalVotes: a,
15
+ withPollNode: p
16
+ }) {
17
+ const { clientID: r } = T(), _ = S(null), m = t.votes, f = m.indexOf(r) !== -1, i = m.length, h = t.text;
18
+ return /* @__PURE__ */ C("div", { className: "PollNode__optionContainer", children: [
19
+ /* @__PURE__ */ o(
20
+ "div",
21
+ {
22
+ className: O(
23
+ "PollNode__optionCheckboxWrapper",
24
+ f && "PollNode__optionCheckboxChecked"
25
+ ),
26
+ children: /* @__PURE__ */ o(
27
+ "input",
28
+ {
29
+ ref: _,
30
+ className: "PollNode__optionCheckbox",
31
+ type: "checkbox",
32
+ onChange: () => {
33
+ p((d) => {
34
+ d.toggleVote(t, r);
35
+ });
36
+ },
37
+ checked: f
38
+ }
39
+ )
40
+ }
41
+ ),
42
+ /* @__PURE__ */ C("div", { className: "PollNode__optionInputWrapper", children: [
43
+ /* @__PURE__ */ o(
44
+ "div",
45
+ {
46
+ className: "PollNode__optionInputVotes",
47
+ style: { width: `${i === 0 ? 0 : i / a * 100}%` }
48
+ }
49
+ ),
50
+ /* @__PURE__ */ o("span", { className: "PollNode__optionInputVotesCount", children: i > 0 && (i === 1 ? "1 vote" : `${i} votes`) }),
51
+ /* @__PURE__ */ o(
52
+ "input",
53
+ {
54
+ className: "PollNode__optionInput",
55
+ type: "text",
56
+ value: h,
57
+ onChange: (d) => {
58
+ const u = d.target, N = u.value, e = u.selectionStart, l = u.selectionEnd;
59
+ p(
60
+ (s) => {
61
+ s.setOptionText(t, N);
62
+ },
63
+ () => {
64
+ u.selectionStart = e, u.selectionEnd = l;
65
+ }
66
+ );
67
+ },
68
+ placeholder: `Option ${c + 1}`
69
+ }
70
+ )
71
+ ] }),
72
+ /* @__PURE__ */ o(
73
+ "button",
74
+ {
75
+ disabled: n.length < 3,
76
+ className: O(
77
+ "PollNode__optionDelete",
78
+ n.length < 3 && "PollNode__optionDeleteDisabled"
79
+ ),
80
+ "aria-label": "Remove",
81
+ onClick: () => {
82
+ p((d) => {
83
+ d.deleteOption(t);
84
+ });
85
+ }
86
+ }
87
+ )
88
+ ] });
89
+ }
90
+ function z({
91
+ question: t,
92
+ options: c,
93
+ nodeKey: n
94
+ }) {
95
+ const [a] = V(), p = I(() => F(c), [c]), [r, _, m] = j(n), [g, f] = D(null), i = S(null), h = $(
96
+ (e) => {
97
+ if (r && P(x())) {
98
+ e.preventDefault();
99
+ const s = k(n);
100
+ b(s) && s.remove();
101
+ }
102
+ return !1;
103
+ },
104
+ [r, n]
105
+ );
106
+ R(() => E(
107
+ a.registerUpdateListener(({ editorState: e }) => {
108
+ f(e.read(() => x()));
109
+ }),
110
+ a.registerCommand(
111
+ y,
112
+ (e) => {
113
+ const l = e;
114
+ return l.target === i.current ? (l.shiftKey || m(), _(!r), !0) : !1;
115
+ },
116
+ v
117
+ ),
118
+ a.registerCommand(B, h, v),
119
+ a.registerCommand(w, h, v)
120
+ ), [m, a, r, n, h, _]);
121
+ const d = (e, l) => {
122
+ a.update(
123
+ () => {
124
+ const s = k(n);
125
+ b(s) && e(s);
126
+ },
127
+ { onUpdate: l }
128
+ );
129
+ }, u = () => {
130
+ d((e) => {
131
+ e.addOption(W());
132
+ });
133
+ }, N = P(g) && r;
134
+ return /* @__PURE__ */ o("div", { className: `PollNode__container ${N ? "focused" : ""}`, ref: i, children: /* @__PURE__ */ C("div", { className: "PollNode__inner", children: [
135
+ /* @__PURE__ */ o("h2", { className: "PollNode__heading", children: t }),
136
+ c.map((e, l) => {
137
+ const s = e.uid;
138
+ return /* @__PURE__ */ o(
139
+ L,
140
+ {
141
+ withPollNode: d,
142
+ option: e,
143
+ index: l,
144
+ options: c,
145
+ totalVotes: p
146
+ },
147
+ s
148
+ );
149
+ }),
150
+ /* @__PURE__ */ o("div", { className: "PollNode__footer", children: /* @__PURE__ */ o(A, { onClick: u, small: !0, children: "Add Option" }) })
151
+ ] }) });
152
+ }
153
+ export {
154
+ z as default
155
+ };
@@ -0,0 +1,253 @@
1
+ import { jsx as e, jsxs as f, Fragment as L } from "react/jsx-runtime";
2
+ import { u as j, a as M, b as U, w, R as _, C as B, $ as z, F as D, N as O, c as W, K as h, d as q, k as G, e as H, D as J, r as Q, t as V, L as X, f as Y, h as Z, g as K, i as ee, j as te, B as ne } from "./DSD.BSMoqlgJ.js";
3
+ import { d as ae, P as le } from "./DSD.wx0g6wlB.js";
4
+ import { useRef as k, useState as E, useCallback as F, useEffect as oe, Suspense as ie } from "react";
5
+ import { TextInput as re } from "@mantine/core";
6
+ function se({
7
+ label: n,
8
+ value: o,
9
+ onChange: t,
10
+ placeholder: u = "",
11
+ "data-test-id": i,
12
+ type: c = "text"
13
+ }) {
14
+ return /* @__PURE__ */ e(
15
+ re,
16
+ {
17
+ type: c,
18
+ placeholder: u,
19
+ value: o,
20
+ onChange: (r) => {
21
+ t(r.target.value);
22
+ },
23
+ label: n,
24
+ "data-test-id": i,
25
+ mb: 10
26
+ }
27
+ );
28
+ }
29
+ function ce({ children: n, label: o, className: t, ...u }) {
30
+ return /* @__PURE__ */ f("div", { className: "Input__wrapper", children: [
31
+ /* @__PURE__ */ e("label", { style: { marginTop: "-1em" }, className: "Input__label", children: o }),
32
+ /* @__PURE__ */ e("select", { ...u, className: t || "select", children: n })
33
+ ] });
34
+ }
35
+ const y = /* @__PURE__ */ new Set();
36
+ function ue(n) {
37
+ if (!y.has(n))
38
+ throw new Promise((o) => {
39
+ const t = new Image();
40
+ t.src = n, t.onload = () => {
41
+ y.add(n), o(null);
42
+ };
43
+ });
44
+ }
45
+ function de({
46
+ altText: n,
47
+ className: o,
48
+ imageRef: t,
49
+ src: u,
50
+ width: i,
51
+ height: c,
52
+ position: r
53
+ }) {
54
+ return ue(u), /* @__PURE__ */ e(
55
+ "img",
56
+ {
57
+ className: o || void 0,
58
+ src: u,
59
+ alt: n,
60
+ ref: t,
61
+ "data-position": r,
62
+ style: {
63
+ display: "block",
64
+ height: c,
65
+ width: i
66
+ },
67
+ draggable: "false"
68
+ }
69
+ );
70
+ }
71
+ function me({
72
+ activeEditor: n,
73
+ nodeKey: o,
74
+ onClose: t
75
+ }) {
76
+ const i = n.getEditorState().read(() => B(o)), [c, r] = E(i.getAltText()), [v, x] = E(i.getShowCaption()), [I, C] = E(i.getPosition()), b = (m) => {
77
+ x(m.target.checked);
78
+ }, d = (m) => {
79
+ C(m.target.value);
80
+ }, p = () => {
81
+ const m = { altText: c, position: I, showCaption: v };
82
+ i && n.update(() => {
83
+ i.update(m);
84
+ }), t();
85
+ };
86
+ return /* @__PURE__ */ f(L, { children: [
87
+ /* @__PURE__ */ e("div", { style: { marginBottom: "1em" }, children: /* @__PURE__ */ e(
88
+ se,
89
+ {
90
+ label: "Alt-текст",
91
+ placeholder: "Альтернативный текст",
92
+ onChange: r,
93
+ value: c,
94
+ "data-test-id": "image-modal-alt-text-input"
95
+ }
96
+ ) }),
97
+ /* @__PURE__ */ f(
98
+ ce,
99
+ {
100
+ style: { marginBottom: "1em", width: "208px" },
101
+ value: I,
102
+ label: "Position",
103
+ name: "position",
104
+ id: "position-select",
105
+ onChange: d,
106
+ children: [
107
+ /* @__PURE__ */ e("option", { value: "left", children: "Left" }),
108
+ /* @__PURE__ */ e("option", { value: "right", children: "Right" }),
109
+ /* @__PURE__ */ e("option", { value: "full", children: "Full Width" })
110
+ ]
111
+ }
112
+ ),
113
+ /* @__PURE__ */ f("div", { className: "Input__wrapper", children: [
114
+ /* @__PURE__ */ e(
115
+ "input",
116
+ {
117
+ id: "caption",
118
+ type: "checkbox",
119
+ checked: v,
120
+ onChange: b
121
+ }
122
+ ),
123
+ /* @__PURE__ */ e("label", { htmlFor: "caption", children: "Show Caption" })
124
+ ] }),
125
+ /* @__PURE__ */ e(te, { children: /* @__PURE__ */ e(ne, { "data-test-id": "image-modal-file-upload-btn", onClick: () => p(), children: "Применить" }) })
126
+ ] });
127
+ }
128
+ function ve({
129
+ src: n,
130
+ altText: o,
131
+ nodeKey: t,
132
+ width: u,
133
+ height: i,
134
+ showCaption: c,
135
+ caption: r,
136
+ position: v
137
+ }) {
138
+ const [x, I] = j(), C = k(null), b = k(null), [d, p, m] = M(t), [l] = U(), [$, A] = E(null), P = k(null), N = F(
139
+ (s) => {
140
+ if (d && w(_())) {
141
+ s.preventDefault();
142
+ const a = B(t);
143
+ z(a) && a.remove();
144
+ }
145
+ return !1;
146
+ },
147
+ [d, t]
148
+ ), R = F(
149
+ (s) => {
150
+ const g = _(), a = b.current;
151
+ if (d && w(g) && g.getNodes().length === 1) {
152
+ if (c)
153
+ return D(null), s.preventDefault(), r.focus(), !0;
154
+ if (a !== null && a !== document.activeElement)
155
+ return s.preventDefault(), a.focus(), !0;
156
+ }
157
+ return !1;
158
+ },
159
+ [r, d, c]
160
+ ), T = F(
161
+ (s) => P.current === r || b.current === s.target ? (D(null), l.update(() => {
162
+ p(!0);
163
+ const g = l.getRootElement();
164
+ g !== null && g.focus();
165
+ }), !0) : !1,
166
+ [r, l, p]
167
+ );
168
+ return oe(() => {
169
+ let s = !0;
170
+ const g = O(
171
+ l.registerUpdateListener(({ editorState: a }) => {
172
+ s && A(a.read(() => _()));
173
+ }),
174
+ l.registerCommand(
175
+ V,
176
+ (a, S) => (P.current = S, !1),
177
+ h
178
+ ),
179
+ l.registerCommand(
180
+ Q,
181
+ (a) => {
182
+ const S = a;
183
+ return S.target === C.current ? (S.shiftKey ? p(!d) : (m(), p(!0)), !0) : !1;
184
+ },
185
+ h
186
+ ),
187
+ l.registerCommand(
188
+ J,
189
+ (a) => a.target === C.current ? (a.preventDefault(), !0) : !1,
190
+ h
191
+ ),
192
+ l.registerCommand(H, N, h),
193
+ l.registerCommand(G, N, h),
194
+ l.registerCommand(q, R, h),
195
+ l.registerCommand(W, T, h)
196
+ );
197
+ return () => {
198
+ s = !1, g();
199
+ };
200
+ }, [m, l, d, t, N, R, T, p]), /* @__PURE__ */ f(ie, { fallback: null, children: [
201
+ /* @__PURE__ */ f(L, { children: [
202
+ /* @__PURE__ */ f("div", { draggable: !1, children: [
203
+ /* @__PURE__ */ e(
204
+ "button",
205
+ {
206
+ className: "image-edit-button",
207
+ ref: b,
208
+ onClick: () => {
209
+ I("Update Inline Image", (s) => /* @__PURE__ */ e(
210
+ me,
211
+ {
212
+ activeEditor: l,
213
+ nodeKey: t,
214
+ onClose: s
215
+ }
216
+ ));
217
+ },
218
+ children: "Edit"
219
+ }
220
+ ),
221
+ /* @__PURE__ */ e(
222
+ de,
223
+ {
224
+ className: d ? `focused ${w($) ? "draggable" : ""}` : null,
225
+ src: n,
226
+ altText: o,
227
+ imageRef: C,
228
+ width: u,
229
+ height: i,
230
+ position: v
231
+ }
232
+ )
233
+ ] }),
234
+ c && /* @__PURE__ */ e("div", { className: "image-caption-container", children: /* @__PURE__ */ f(ae, { initialEditor: r, children: [
235
+ /* @__PURE__ */ e(X, {}),
236
+ /* @__PURE__ */ e(Y, {}),
237
+ /* @__PURE__ */ e(
238
+ Z,
239
+ {
240
+ contentEditable: /* @__PURE__ */ e(K, { className: "InlineImageNode__contentEditable" }),
241
+ placeholder: /* @__PURE__ */ e(le, { className: "InlineImageNode__placeholder", children: "Enter a caption..." }),
242
+ ErrorBoundary: ee
243
+ }
244
+ )
245
+ ] }) })
246
+ ] }),
247
+ x
248
+ ] });
249
+ }
250
+ export {
251
+ me as UpdateInlineImageDialog,
252
+ ve as default
253
+ };
@@ -0,0 +1,284 @@
1
+ import { jsx as g, jsxs as $, Fragment as F } from "react/jsx-runtime";
2
+ import { useState as U, useEffect as b, useMemo as V, Suspense as q, useLayoutEffect as Y, useRef as W } from "react";
3
+ import { N as T, D as G, R as a, o as c, p as u, q as J, s as Q, v as A, x as Z, A as ee, z as te, H as ne, d as oe, y as M, e as re, E as S, k as se, G as ie, I as O, J as X, M as ae, O as ce, P as le, Q as ue, S as de, T as me, U as fe, V as ge, b as B, W as pe, X as Ce, Y as he, Z as ve, _ as ye, a0 as Ee, a1 as we, m as ke, a2 as De, a3 as be, a4 as Le, g as Re, i as Se, C as x, a5 as P } from "./DSD.BSMoqlgJ.js";
4
+ import { d as xe, P as Pe } from "./DSD.wx0g6wlB.js";
5
+ import { flushSync as $e, createPortal as Ne } from "react-dom";
6
+ const E = typeof window < "u" && window.document !== void 0 && window.document.createElement !== void 0, Te = E && "documentMode" in document ? document.documentMode : null, Be = !(!E || !("InputEvent" in window) || Te) && "getTargetRanges" in new window.InputEvent("input"), _e = E && /Version\/[\d.]+.*Safari/.test(navigator.userAgent), z = E && /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream, We = E && /^(?=.*Chrome).*/i.test(navigator.userAgent), Ae = E && /AppleWebKit\/[\d.]+/.test(navigator.userAgent) && !We;
7
+ function I(n, t) {
8
+ t.update(() => {
9
+ if (n !== null) {
10
+ const e = fe(n, KeyboardEvent) ? null : n.clipboardData, s = a();
11
+ if (s !== null && e != null) {
12
+ n.preventDefault();
13
+ const i = ge(t);
14
+ i !== null && e.setData("text/html", i), e.setData("text/plain", s.getTextContent());
15
+ }
16
+ }
17
+ });
18
+ }
19
+ function Me(n) {
20
+ return T(n.registerCommand(S, (t) => {
21
+ const e = a();
22
+ return !!c(e) && (e.deleteCharacter(t), !0);
23
+ }, u), n.registerCommand(me, (t) => {
24
+ const e = a();
25
+ return !!c(e) && (e.deleteWord(t), !0);
26
+ }, u), n.registerCommand(de, (t) => {
27
+ const e = a();
28
+ return !!c(e) && (e.deleteLine(t), !0);
29
+ }, u), n.registerCommand(ue, (t) => {
30
+ const e = a();
31
+ if (!c(e)) return !1;
32
+ if (typeof t == "string") e.insertText(t);
33
+ else {
34
+ const s = t.dataTransfer;
35
+ if (s != null) A(s, e);
36
+ else {
37
+ const i = t.data;
38
+ i && e.insertText(i);
39
+ }
40
+ }
41
+ return !0;
42
+ }, u), n.registerCommand(le, () => {
43
+ const t = a();
44
+ return !!c(t) && (t.removeText(), !0);
45
+ }, u), n.registerCommand(M, (t) => {
46
+ const e = a();
47
+ return !!c(e) && (e.insertLineBreak(t), !0);
48
+ }, u), n.registerCommand(ce, () => {
49
+ const t = a();
50
+ return !!c(t) && (t.insertLineBreak(), !0);
51
+ }, u), n.registerCommand(ae, (t) => {
52
+ const e = a();
53
+ if (!c(e)) return !1;
54
+ const s = t, i = s.shiftKey;
55
+ return !!O(e, !0) && (s.preventDefault(), X(e, i, !0), !0);
56
+ }, u), n.registerCommand(ie, (t) => {
57
+ const e = a();
58
+ if (!c(e)) return !1;
59
+ const s = t, i = s.shiftKey;
60
+ return !!O(e, !1) && (s.preventDefault(), X(e, i, !1), !0);
61
+ }, u), n.registerCommand(se, (t) => {
62
+ const e = a();
63
+ return !!c(e) && (!z || navigator.language !== "ko-KR") && (t.preventDefault(), n.dispatchCommand(S, !0));
64
+ }, u), n.registerCommand(re, (t) => {
65
+ const e = a();
66
+ return !!c(e) && (t.preventDefault(), n.dispatchCommand(S, !1));
67
+ }, u), n.registerCommand(oe, (t) => {
68
+ const e = a();
69
+ if (!c(e)) return !1;
70
+ if (t !== null) {
71
+ if ((z || _e || Ae) && Be) return !1;
72
+ t.preventDefault();
73
+ }
74
+ return n.dispatchCommand(M, !1);
75
+ }, u), n.registerCommand(te, () => (ne(), !0), u), n.registerCommand(ee, (t) => {
76
+ const e = a();
77
+ return !!c(e) && (I(t, n), !0);
78
+ }, u), n.registerCommand(Z, (t) => {
79
+ const e = a();
80
+ return !!c(e) && (function(s, i) {
81
+ I(s, i), i.update(() => {
82
+ const r = a();
83
+ c(r) && r.removeText();
84
+ });
85
+ }(t, n), !0);
86
+ }, u), n.registerCommand(Q, (t) => {
87
+ const e = a();
88
+ return !!c(e) && (function(s, i) {
89
+ s.preventDefault(), i.update(() => {
90
+ const r = a(), { clipboardData: d } = s;
91
+ d != null && c(r) && A(d, r);
92
+ }, { tag: "paste" });
93
+ }(t, n), !0);
94
+ }, u), n.registerCommand(J, (t) => {
95
+ const e = a();
96
+ return !!c(e) && (t.preventDefault(), !0);
97
+ }, u), n.registerCommand(G, (t) => {
98
+ const e = a();
99
+ return !!c(e) && (t.preventDefault(), !0);
100
+ }, u));
101
+ }
102
+ const N = typeof window < "u" && window.document !== void 0 && window.document.createElement !== void 0 ? Y : b;
103
+ function K(n) {
104
+ return n.getEditorState().read(he(n.isComposing()));
105
+ }
106
+ function Oe({ contentEditable: n, placeholder: t = null, ErrorBoundary: e }) {
107
+ const [s] = B(), i = function(r, d) {
108
+ const [f, y] = U(() => r.getDecorators());
109
+ return N(() => r.registerDecoratorListener((v) => {
110
+ $e(() => {
111
+ y(v);
112
+ });
113
+ }), [r]), b(() => {
114
+ y(r.getDecorators());
115
+ }, [r]), V(() => {
116
+ const v = [], w = Object.keys(f);
117
+ for (let k = 0; k < w.length; k++) {
118
+ const D = w[k], R = g(d, { onError: (l) => r._onError(l), children: g(q, { fallback: null, children: f[D] }) }), o = r.getElementByKey(D);
119
+ o !== null && v.push(Ne(R, o, D));
120
+ }
121
+ return v;
122
+ }, [d, f, r]);
123
+ }(s, e);
124
+ return function(r) {
125
+ N(() => T(Me(r), pe(r)), [r]);
126
+ }(s), $(F, { children: [n, g(Xe, { content: t }), i] });
127
+ }
128
+ function Xe({ content: n }) {
129
+ const [t] = B(), e = function(i) {
130
+ const [r, d] = U(() => K(i));
131
+ return N(() => {
132
+ function f() {
133
+ const y = K(i);
134
+ d(y);
135
+ }
136
+ return f(), T(i.registerUpdateListener(() => {
137
+ f();
138
+ }), i.registerEditableListener(() => {
139
+ f();
140
+ }));
141
+ }, [i]), r;
142
+ }(t), s = Ce();
143
+ return e ? typeof n == "function" ? n(s) : n : null;
144
+ }
145
+ const ze = new URL(window.location.href);
146
+ new URLSearchParams(ze.search);
147
+ const Ie = "https://wss.dudoc.io";
148
+ function Ke(n, t) {
149
+ let e = t.get(n);
150
+ return e === void 0 ? (e = new ve(), t.set(n, e)) : e.load(), new ye(Ie, "/" + n, e, {
151
+ connect: !1
152
+ });
153
+ }
154
+ const Ue = Ee ? Y : b, Ye = {
155
+ ...we,
156
+ paragraph: "StickyEditorTheme__paragraph"
157
+ };
158
+ function L(n, t) {
159
+ const e = n.style, s = t.rootElementRect, i = s !== null ? s.left : 0, r = s !== null ? s.top : 0;
160
+ e.top = r + t.y + "px", e.left = i + t.x + "px";
161
+ }
162
+ function Ge({
163
+ x: n,
164
+ y: t,
165
+ nodeKey: e,
166
+ color: s,
167
+ caption: i
168
+ }) {
169
+ const [r] = B(), d = W(null), f = W({
170
+ isDragging: !1,
171
+ offsetX: 0,
172
+ offsetY: 0,
173
+ rootElementRect: null,
174
+ x: 0,
175
+ y: 0
176
+ }), { isCollabActive: y } = ke();
177
+ b(() => {
178
+ const o = f.current;
179
+ o.x = n, o.y = t;
180
+ const l = d.current;
181
+ l !== null && L(l, o);
182
+ }, [n, t]), Ue(() => {
183
+ const o = f.current, l = new ResizeObserver((h) => {
184
+ for (let p = 0; p < h.length; p++) {
185
+ const H = h[p], { target: j } = H;
186
+ o.rootElementRect = j.getBoundingClientRect();
187
+ const _ = d.current;
188
+ _ !== null && L(_, o);
189
+ }
190
+ }), m = r.registerRootListener((h, p) => {
191
+ p !== null && l.unobserve(p), h !== null && l.observe(h);
192
+ }), C = () => {
193
+ const h = r.getRootElement(), p = d.current;
194
+ h !== null && p !== null && (o.rootElementRect = h.getBoundingClientRect(), L(p, o));
195
+ };
196
+ return window.addEventListener("resize", C), () => {
197
+ window.removeEventListener("resize", C), m();
198
+ };
199
+ }, [r]), b(() => {
200
+ const o = d.current;
201
+ o !== null && setTimeout(() => {
202
+ o.style.setProperty("transition", "top 0.3s ease 0s, left 0.3s ease 0s");
203
+ }, 500);
204
+ }, []);
205
+ const v = (o) => {
206
+ const l = d.current, m = f.current, C = m.rootElementRect;
207
+ l !== null && m.isDragging && C !== null && (m.x = o.pageX - m.offsetX - C.left, m.y = o.pageY - m.offsetY - C.top, L(l, m));
208
+ }, w = () => {
209
+ const o = d.current, l = f.current;
210
+ o !== null && (l.isDragging = !1, o.classList.remove("dragging"), r.update(() => {
211
+ const m = x(e);
212
+ P(m) && m.setPosition(l.x, l.y);
213
+ })), document.removeEventListener("pointermove", v), document.removeEventListener("pointerup", w);
214
+ }, k = () => {
215
+ r.update(() => {
216
+ const o = x(e);
217
+ P(o) && o.remove();
218
+ });
219
+ }, D = () => {
220
+ r.update(() => {
221
+ const o = x(e);
222
+ P(o) && o.toggleColor();
223
+ });
224
+ }, { historyState: R } = De();
225
+ return /* @__PURE__ */ g("div", { ref: d, className: "sticky-note-container", children: /* @__PURE__ */ $(
226
+ "div",
227
+ {
228
+ className: `sticky-note ${s}`,
229
+ onPointerDown: (o) => {
230
+ const l = d.current;
231
+ if (l == null || o.button === 2 || o.target !== l.firstChild)
232
+ return;
233
+ const m = l, C = f.current;
234
+ if (m !== null) {
235
+ const { top: h, left: p } = m.getBoundingClientRect();
236
+ C.offsetX = o.clientX - p, C.offsetY = o.clientY - h, C.isDragging = !0, m.classList.add("dragging"), document.addEventListener("pointermove", v), document.addEventListener("pointerup", w), o.preventDefault();
237
+ }
238
+ },
239
+ children: [
240
+ /* @__PURE__ */ g(
241
+ "button",
242
+ {
243
+ onClick: k,
244
+ className: "delete",
245
+ "aria-label": "Delete sticky note",
246
+ title: "Delete",
247
+ children: "X"
248
+ }
249
+ ),
250
+ /* @__PURE__ */ g(
251
+ "button",
252
+ {
253
+ onClick: D,
254
+ className: "color",
255
+ "aria-label": "Change sticky note color",
256
+ title: "Color",
257
+ children: /* @__PURE__ */ g("i", { className: "bucket" })
258
+ }
259
+ ),
260
+ /* @__PURE__ */ $(xe, { initialEditor: i, initialTheme: Ye, children: [
261
+ y ? /* @__PURE__ */ g(
262
+ be,
263
+ {
264
+ id: i.getKey(),
265
+ providerFactory: Ke,
266
+ shouldBootstrap: !0
267
+ }
268
+ ) : /* @__PURE__ */ g(Le, { externalHistoryState: R }),
269
+ /* @__PURE__ */ g(
270
+ Oe,
271
+ {
272
+ contentEditable: /* @__PURE__ */ g(Re, { className: "StickyNode__contentEditable" }),
273
+ placeholder: /* @__PURE__ */ g(Pe, { className: "StickyNode__placeholder", children: "What's up?" }),
274
+ ErrorBoundary: Se
275
+ }
276
+ )
277
+ ] })
278
+ ]
279
+ }
280
+ ) });
281
+ }
282
+ export {
283
+ Ge as default
284
+ };