@layers-app/editor 0.0.10 → 0.0.11

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.
@@ -1,4 +1,4 @@
1
- import { a6 as p, a7 as k, n as E } from "./DSD.CLhKx58f.js";
1
+ import { ae as p, af as k, l as E } from "./layers.BngHKUYL.js";
2
2
  import { useRef as O, useContext as P, useMemo as D, useEffect as h } from "react";
3
3
  import { jsx as _ } from "react/jsx-runtime";
4
4
  function K(e) {
@@ -19,18 +19,18 @@ function S({ initialEditor: e, children: t, initialNodes: o, initialTheme: g, sk
19
19
  i == null && C(9);
20
20
  const [l, { getTheme: w }] = i, x = D(() => {
21
21
  const a = g || w() || void 0, y = k(i, a);
22
- if (a !== void 0 && (e._config.theme = a), e._parentEditor = l, o) for (let n of o) {
23
- let s = null, r = null;
24
- if (typeof n != "function") {
25
- const d = n;
26
- n = d.replace, s = d.with, r = d.withKlass || null;
22
+ if (a !== void 0 && (e._config.theme = a), e._parentEditor = l, o) for (let r of o) {
23
+ let s = null, n = null;
24
+ if (typeof r != "function") {
25
+ const d = r;
26
+ r = d.replace, s = d.with, n = d.withKlass || null;
27
27
  }
28
- const u = e._nodes.get(n.getType());
29
- e._nodes.set(n.getType(), { exportDOM: u ? u.exportDOM : void 0, klass: n, replace: s, replaceWithKlass: r, transforms: m(n) });
28
+ const u = e._nodes.get(r.getType());
29
+ e._nodes.set(r.getType(), { exportDOM: u ? u.exportDOM : void 0, klass: r, replace: s, replaceWithKlass: n, transforms: m(r) });
30
30
  }
31
31
  else {
32
- const n = e._nodes = new Map(l._nodes);
33
- for (const [s, r] of n) e._nodes.set(s, { exportDOM: r.exportDOM, klass: r.klass, replace: r.replace, replaceWithKlass: r.replaceWithKlass, transforms: m(r.klass) });
32
+ const r = e._nodes = new Map(l._nodes);
33
+ for (const [s, n] of r) e._nodes.set(s, { exportDOM: n.exportDOM, klass: n.klass, replace: n.replace, replaceWithKlass: n.replaceWithKlass, transforms: m(n.klass) });
34
34
  }
35
35
  return e._config.namespace = l._config.namespace, e._editable = l._editable, [e, y];
36
36
  }, []), { isCollabActive: M, yjsDocMap: b } = E(), c = v || f.current || b.has(e.getKey());
@@ -1,111 +1,111 @@
1
1
  import { jsx as g, jsxs as $, Fragment as F } from "react/jsx-runtime";
2
- import { useState as U, useMemo as V, useLayoutEffect as Y, useEffect as b, Suspense as q, 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 re, y as M, e as oe, 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 fe, U as me, V as ge, b as B, W as pe, X as Ce, Y as he, Z as ye, _ as ve, a0 as Ee, a1 as we, n 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.CLhKx58f.js";
4
- import { d as xe, P as Pe } from "./DSD.AwtUbg5v.js";
2
+ import { useState as Y, useMemo as V, useLayoutEffect as I, useEffect as b, Suspense as q, useRef as A } from "react";
3
+ import { N as T, D as G, g as i, z as c, A as u, G as J, H as Q, J as W, M as Z, O as ee, P as te, Q as ne, j as re, S as z, m as oe, T as S, k as se, U as ae, V as M, W as O, X as ie, Y as ce, Z as le, _ as ue, a0 as de, a1 as fe, a2 as me, a3 as ge, u as B, a4 as pe, a5 as Ce, a6 as he, a7 as ye, a8 as ve, a9 as Ee, aa as we, l as ke, a as De, ab as be, ac as Le, q as Re, s as Se, c as x, ad as P } from "./layers.BngHKUYL.js";
4
+ import { d as xe, P as Pe } from "./layers.DKx4HQvO.js";
5
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) {
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), X = E && /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream, Ae = E && /^(?=.*Chrome).*/i.test(navigator.userAgent), We = E && /AppleWebKit\/[\d.]+/.test(navigator.userAgent) && !Ae;
7
+ function K(n, t) {
8
8
  t.update(() => {
9
9
  if (n !== null) {
10
- const e = me(n, KeyboardEvent) ? null : n.clipboardData, s = a();
10
+ const e = me(n, KeyboardEvent) ? null : n.clipboardData, s = i();
11
11
  if (s !== null && e != null) {
12
12
  n.preventDefault();
13
- const i = ge(t);
14
- i !== null && e.setData("text/html", i), e.setData("text/plain", s.getTextContent());
13
+ const a = ge(t);
14
+ a !== null && e.setData("text/html", a), e.setData("text/plain", s.getTextContent());
15
15
  }
16
16
  }
17
17
  });
18
18
  }
19
- function Me(n) {
19
+ function ze(n) {
20
20
  return T(n.registerCommand(S, (t) => {
21
- const e = a();
21
+ const e = i();
22
22
  return !!c(e) && (e.deleteCharacter(t), !0);
23
23
  }, u), n.registerCommand(fe, (t) => {
24
- const e = a();
24
+ const e = i();
25
25
  return !!c(e) && (e.deleteWord(t), !0);
26
26
  }, u), n.registerCommand(de, (t) => {
27
- const e = a();
27
+ const e = i();
28
28
  return !!c(e) && (e.deleteLine(t), !0);
29
29
  }, u), n.registerCommand(ue, (t) => {
30
- const e = a();
30
+ const e = i();
31
31
  if (!c(e)) return !1;
32
32
  if (typeof t == "string") e.insertText(t);
33
33
  else {
34
34
  const s = t.dataTransfer;
35
- if (s != null) A(s, e);
35
+ if (s != null) W(s, e);
36
36
  else {
37
- const i = t.data;
38
- i && e.insertText(i);
37
+ const a = t.data;
38
+ a && e.insertText(a);
39
39
  }
40
40
  }
41
41
  return !0;
42
42
  }, u), n.registerCommand(le, () => {
43
- const t = a();
43
+ const t = i();
44
44
  return !!c(t) && (t.removeText(), !0);
45
- }, u), n.registerCommand(M, (t) => {
46
- const e = a();
45
+ }, u), n.registerCommand(z, (t) => {
46
+ const e = i();
47
47
  return !!c(e) && (e.insertLineBreak(t), !0);
48
48
  }, u), n.registerCommand(ce, () => {
49
- const t = a();
49
+ const t = i();
50
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
51
  }, u), n.registerCommand(ie, (t) => {
57
- const e = a();
52
+ const e = i();
53
+ if (!c(e)) return !1;
54
+ const s = t, a = s.shiftKey;
55
+ return !!M(e, !0) && (s.preventDefault(), O(e, a, !0), !0);
56
+ }, u), n.registerCommand(ae, (t) => {
57
+ const e = i();
58
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);
59
+ const s = t, a = s.shiftKey;
60
+ return !!M(e, !1) && (s.preventDefault(), O(e, a, !1), !0);
61
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));
62
+ const e = i();
63
+ return !!c(e) && (!X || navigator.language !== "ko-KR") && (t.preventDefault(), n.dispatchCommand(S, !0));
64
64
  }, u), n.registerCommand(oe, (t) => {
65
- const e = a();
65
+ const e = i();
66
66
  return !!c(e) && (t.preventDefault(), n.dispatchCommand(S, !1));
67
67
  }, u), n.registerCommand(re, (t) => {
68
- const e = a();
68
+ const e = i();
69
69
  if (!c(e)) return !1;
70
70
  if (t !== null) {
71
- if ((z || _e || Ae) && Be) return !1;
71
+ if ((X || _e || We) && Be) return !1;
72
72
  t.preventDefault();
73
73
  }
74
- return n.dispatchCommand(M, !1);
74
+ return n.dispatchCommand(z, !1);
75
75
  }, u), n.registerCommand(te, () => (ne(), !0), u), n.registerCommand(ee, (t) => {
76
- const e = a();
77
- return !!c(e) && (I(t, n), !0);
76
+ const e = i();
77
+ return !!c(e) && (K(t, n), !0);
78
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 o = a();
79
+ const e = i();
80
+ return !!c(e) && (function(s, a) {
81
+ K(s, a), a.update(() => {
82
+ const o = i();
83
83
  c(o) && o.removeText();
84
84
  });
85
85
  }(t, n), !0);
86
86
  }, u), n.registerCommand(Q, (t) => {
87
- const e = a();
88
- return !!c(e) && (function(s, i) {
89
- s.preventDefault(), i.update(() => {
90
- const o = a(), { clipboardData: d } = s;
91
- d != null && c(o) && A(d, o);
87
+ const e = i();
88
+ return !!c(e) && (function(s, a) {
89
+ s.preventDefault(), a.update(() => {
90
+ const o = i(), { clipboardData: d } = s;
91
+ d != null && c(o) && W(d, o);
92
92
  }, { tag: "paste" });
93
93
  }(t, n), !0);
94
94
  }, u), n.registerCommand(J, (t) => {
95
- const e = a();
95
+ const e = i();
96
96
  return !!c(e) && (t.preventDefault(), !0);
97
97
  }, u), n.registerCommand(G, (t) => {
98
- const e = a();
98
+ const e = i();
99
99
  return !!c(e) && (t.preventDefault(), !0);
100
100
  }, u));
101
101
  }
102
- const N = typeof window < "u" && window.document !== void 0 && window.document.createElement !== void 0 ? Y : b;
103
- function K(n) {
102
+ const N = typeof window < "u" && window.document !== void 0 && window.document.createElement !== void 0 ? I : b;
103
+ function U(n) {
104
104
  return n.getEditorState().read(he(n.isComposing()));
105
105
  }
106
- function Oe({ contentEditable: n, placeholder: t = null, ErrorBoundary: e }) {
107
- const [s] = B(), i = function(o, d) {
108
- const [m, v] = U(() => o.getDecorators());
106
+ function Me({ contentEditable: n, placeholder: t = null, ErrorBoundary: e }) {
107
+ const [s] = B(), a = function(o, d) {
108
+ const [m, v] = Y(() => o.getDecorators());
109
109
  return N(() => o.registerDecoratorListener((y) => {
110
110
  $e(() => {
111
111
  v(y);
@@ -122,51 +122,51 @@ function Oe({ contentEditable: n, placeholder: t = null, ErrorBoundary: e }) {
122
122
  }, [d, m, o]);
123
123
  }(s, e);
124
124
  return function(o) {
125
- N(() => T(Me(o), pe(o)), [o]);
126
- }(s), $(F, { children: [n, g(Xe, { content: t }), i] });
125
+ N(() => T(ze(o), pe(o)), [o]);
126
+ }(s), $(F, { children: [n, g(Oe, { content: t }), a] });
127
127
  }
128
- function Xe({ content: n }) {
129
- const [t] = B(), e = function(i) {
130
- const [o, d] = U(() => K(i));
128
+ function Oe({ content: n }) {
129
+ const [t] = B(), e = function(a) {
130
+ const [o, d] = Y(() => U(a));
131
131
  return N(() => {
132
132
  function m() {
133
- const v = K(i);
133
+ const v = U(a);
134
134
  d(v);
135
135
  }
136
- return m(), T(i.registerUpdateListener(() => {
136
+ return m(), T(a.registerUpdateListener(() => {
137
137
  m();
138
- }), i.registerEditableListener(() => {
138
+ }), a.registerEditableListener(() => {
139
139
  m();
140
140
  }));
141
- }, [i]), o;
141
+ }, [a]), o;
142
142
  }(t), s = Ce();
143
143
  return e ? typeof n == "function" ? n(s) : n : null;
144
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) {
145
+ const Xe = new URL(window.location.href);
146
+ new URLSearchParams(Xe.search);
147
+ const Ke = "https://wss.dudoc.io";
148
+ function Ue(n, t) {
149
149
  let e = t.get(n);
150
- return e === void 0 ? (e = new ye(), t.set(n, e)) : e.load(), new ve(Ie, "/" + n, e, {
150
+ return e === void 0 ? (e = new ye(), t.set(n, e)) : e.load(), new ve(Ke, "/" + n, e, {
151
151
  connect: !1
152
152
  });
153
153
  }
154
- const Ue = Ee ? Y : b, Ye = {
154
+ const Ye = Ee ? I : b, Ie = {
155
155
  ...we,
156
156
  paragraph: "StickyEditorTheme__paragraph"
157
157
  };
158
158
  function L(n, t) {
159
- const e = n.style, s = t.rootElementRect, i = s !== null ? s.left : 0, o = s !== null ? s.top : 0;
160
- e.top = o + t.y + "px", e.left = i + t.x + "px";
159
+ const e = n.style, s = t.rootElementRect, a = s !== null ? s.left : 0, o = s !== null ? s.top : 0;
160
+ e.top = o + t.y + "px", e.left = a + t.x + "px";
161
161
  }
162
162
  function Ge({
163
163
  x: n,
164
164
  y: t,
165
165
  nodeKey: e,
166
166
  color: s,
167
- caption: i
167
+ caption: a
168
168
  }) {
169
- const [o] = B(), d = W(null), m = W({
169
+ const [o] = B(), d = A(null), m = A({
170
170
  isDragging: !1,
171
171
  offsetX: 0,
172
172
  offsetY: 0,
@@ -179,7 +179,7 @@ function Ge({
179
179
  r.x = n, r.y = t;
180
180
  const l = d.current;
181
181
  l !== null && L(l, r);
182
- }, [n, t]), Ue(() => {
182
+ }, [n, t]), Ye(() => {
183
183
  const r = m.current, l = new ResizeObserver((h) => {
184
184
  for (let p = 0; p < h.length; p++) {
185
185
  const H = h[p], { target: j } = H;
@@ -262,17 +262,17 @@ function Ge({
262
262
  children: /* @__PURE__ */ g("i", { className: "bucket" })
263
263
  }
264
264
  ),
265
- /* @__PURE__ */ $(xe, { initialEditor: i, initialTheme: Ye, children: [
265
+ /* @__PURE__ */ $(xe, { initialEditor: a, initialTheme: Ie, children: [
266
266
  v ? /* @__PURE__ */ g(
267
267
  be,
268
268
  {
269
- id: i.getKey(),
270
- providerFactory: Ke,
269
+ id: a.getKey(),
270
+ providerFactory: Ue,
271
271
  shouldBootstrap: !0
272
272
  }
273
273
  ) : /* @__PURE__ */ g(Le, { externalHistoryState: R }),
274
274
  /* @__PURE__ */ g(
275
- Oe,
275
+ Me,
276
276
  {
277
277
  contentEditable: /* @__PURE__ */ g(Se, { className: "StickyNode__contentEditable" }),
278
278
  placeholder: /* @__PURE__ */ g(Pe, { className: "StickyNode__placeholder", children: "What's up?" }),
@@ -1,6 +1,6 @@
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.CLhKx58f.js";
1
+ import { jsx as o, jsxs as g } from "react/jsx-runtime";
2
+ import { useMemo as I, useState as D, useRef as S, useCallback as $, useEffect as V } from "react";
3
+ import { u as j, f as E, w as P, g as x, c as k, x as b, N as R, k as w, K as v, m as y, r as B, B as A, y as T, l as W } from "./layers.BngHKUYL.js";
4
4
  function O(...t) {
5
5
  return t.filter(Boolean).join(" ");
6
6
  }
@@ -14,19 +14,19 @@ function L({
14
14
  totalVotes: a,
15
15
  withPollNode: p
16
16
  }) {
17
- const { clientID: r } = W(), _ = 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: [
17
+ const { clientID: r } = W(), h = S(null), m = t.votes, _ = m.indexOf(r) !== -1, i = m.length, f = t.text;
18
+ return /* @__PURE__ */ g("div", { className: "PollNode__optionContainer", children: [
19
19
  /* @__PURE__ */ o(
20
20
  "div",
21
21
  {
22
22
  className: O(
23
23
  "PollNode__optionCheckboxWrapper",
24
- f && "PollNode__optionCheckboxChecked"
24
+ _ && "PollNode__optionCheckboxChecked"
25
25
  ),
26
26
  children: /* @__PURE__ */ o(
27
27
  "input",
28
28
  {
29
- ref: _,
29
+ ref: h,
30
30
  className: "PollNode__optionCheckbox",
31
31
  type: "checkbox",
32
32
  onChange: () => {
@@ -34,12 +34,12 @@ function L({
34
34
  d.toggleVote(t, r);
35
35
  });
36
36
  },
37
- checked: f
37
+ checked: _
38
38
  }
39
39
  )
40
40
  }
41
41
  ),
42
- /* @__PURE__ */ C("div", { className: "PollNode__optionInputWrapper", children: [
42
+ /* @__PURE__ */ g("div", { className: "PollNode__optionInputWrapper", children: [
43
43
  /* @__PURE__ */ o(
44
44
  "div",
45
45
  {
@@ -53,7 +53,7 @@ function L({
53
53
  {
54
54
  className: "PollNode__optionInput",
55
55
  type: "text",
56
- value: h,
56
+ value: f,
57
57
  onChange: (d) => {
58
58
  const u = d.target, N = u.value, e = u.selectionStart, l = u.selectionEnd;
59
59
  p(
@@ -92,7 +92,7 @@ function z({
92
92
  options: c,
93
93
  nodeKey: n
94
94
  }) {
95
- const [a] = V(), p = I(() => F(c), [c]), [r, _, m] = j(n), [g, f] = D(null), i = S(null), h = $(
95
+ const [a] = j(), p = I(() => F(c), [c]), [r, h, m] = E(n), [C, _] = D(null), i = S(null), f = $(
96
96
  (e) => {
97
97
  if (r && P(x())) {
98
98
  e.preventDefault();
@@ -103,29 +103,29 @@ function z({
103
103
  },
104
104
  [r, n]
105
105
  );
106
- R(() => E(
106
+ V(() => R(
107
107
  a.registerUpdateListener(({ editorState: e }) => {
108
- f(e.read(() => x()));
108
+ _(e.read(() => x()));
109
109
  }),
110
110
  a.registerCommand(
111
- y,
111
+ B,
112
112
  (e) => {
113
113
  const l = e;
114
- return l.target === i.current ? (l.shiftKey || m(), _(!r), !0) : !1;
114
+ return l.target === i.current ? (l.shiftKey || m(), h(!r), !0) : !1;
115
115
  },
116
116
  v
117
117
  ),
118
118
  a.registerCommand(
119
- B,
120
- h,
119
+ y,
120
+ f,
121
121
  v
122
122
  ),
123
123
  a.registerCommand(
124
124
  w,
125
- h,
125
+ f,
126
126
  v
127
127
  )
128
- ), [m, a, r, n, h, _]);
128
+ ), [m, a, r, n, f, h]);
129
129
  const d = (e, l) => {
130
130
  a.update(
131
131
  () => {
@@ -138,13 +138,13 @@ function z({
138
138
  d((e) => {
139
139
  e.addOption(T());
140
140
  });
141
- }, N = P(g) && r;
141
+ }, N = P(C) && r;
142
142
  return /* @__PURE__ */ o(
143
143
  "div",
144
144
  {
145
145
  className: `PollNode__container ${N ? "focused" : ""}`,
146
146
  ref: i,
147
- children: /* @__PURE__ */ C("div", { className: "PollNode__inner", children: [
147
+ children: /* @__PURE__ */ g("div", { className: "PollNode__inner", children: [
148
148
  /* @__PURE__ */ o("h2", { className: "PollNode__heading", children: t }),
149
149
  c.map((e, l) => {
150
150
  const s = e.uid;