@arkitektbedriftene/fe-lib 0.3.17 → 0.3.18

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,126 +1,438 @@
1
- import { createHeadlessEditor as y } from "@lexical/headless";
2
- import { $generateHtmlFromNodes as S } from "@lexical/html";
3
- import { $getRoot as f, ParagraphNode as E, $createParagraphNode as $, $createTextNode as F } from "lexical";
4
- import { trimTextContentFromAnchor as L } from "@lexical/selection";
5
- import { AutoLinkNode as w, LinkNode as v } from "@lexical/link";
6
- import { ListNode as R, ListItemNode as H } from "@lexical/list";
7
- import { HeadingNode as k, QuoteNode as P } from "@lexical/rich-text";
8
- import { TableNode as I, TableRowNode as M, TableCellNode as B } from "@lexical/table";
9
- import { jsx as a, jsxs as h, Fragment as j } from "react/jsx-runtime";
10
- import { createContext as q, useState as z, useRef as b, useCallback as p, useContext as A, useMemo as D } from "react";
11
- import { c as d, s as V, B as x, S as W } from "./DropdownMenu-c57acb78.js";
12
- import { LexicalComposer as J } from "@lexical/react/LexicalComposer.js";
13
- import { RichTextPlugin as O } from "@lexical/react/LexicalRichTextPlugin.js";
14
- import Q from "@lexical/react/LexicalErrorBoundary.js";
1
+ import { createHeadlessEditor as G } from "@lexical/headless";
2
+ import { $generateHtmlFromNodes as Q } from "@lexical/html";
3
+ import { $getRoot as I, ParagraphNode as V, $createParagraphNode as R, $createTextNode as J, SELECTION_CHANGE_COMMAND as $, $getSelection as y, COMMAND_PRIORITY_CRITICAL as F, $isRangeSelection as N, $isRootOrShadowRoot as X, DEPRECATED_$isGridSelection as E, FORMAT_TEXT_COMMAND as L } from "lexical";
4
+ import { trimTextContentFromAnchor as Y, $setBlocksType as H } from "@lexical/selection";
5
+ import { AutoLinkNode as Z, LinkNode as tt } from "@lexical/link";
6
+ import { ListNode as O, ListItemNode as et, $isListNode as rt, INSERT_UNORDERED_LIST_COMMAND as ot, INSERT_ORDERED_LIST_COMMAND as at, INSERT_CHECK_LIST_COMMAND as nt } from "@lexical/list";
7
+ import { HeadingNode as it, QuoteNode as st, $isHeadingNode as lt, $createHeadingNode as dt, $createQuoteNode as ct } from "@lexical/rich-text";
8
+ import { TableNode as ht, TableRowNode as pt, TableCellNode as ut } from "@lexical/table";
9
+ import { jsx as e, jsxs as C, Fragment as D } from "react/jsx-runtime";
10
+ import { createContext as gt, useState as M, useRef as j, useCallback as k, useContext as mt, useEffect as W, useMemo as _, useLayoutEffect as ft } from "react";
11
+ import { c as w, s as A, D as kt, T as Mt, a as m, B as S, b as vt, d as x, u as Ct, e as bt, f as Tt, g as Lt, o as xt, h as yt, i as Nt, j as wt, F as St, O as zt, k as Et, l as Ht, S as Bt } from "./DropdownMenu-cae60146.js";
12
+ import { LexicalComposer as It } from "@lexical/react/LexicalComposer.js";
13
+ import { RichTextPlugin as Rt } from "@lexical/react/LexicalRichTextPlugin.js";
14
+ import $t from "@lexical/react/LexicalErrorBoundary.js";
15
+ import { useLexicalComposerContext as P } from "@lexical/react/LexicalComposerContext";
16
+ import { $getNearestNodeOfType as Ft, $findMatchingParent as Ot, mergeRegister as Dt } from "@lexical/utils";
17
+ import { G as d } from "./index.esm-d078f232.js";
15
18
  import "react-dom";
16
19
  import "@radix-ui/react-toolbar";
17
- import "./index.esm-d078f232.js";
18
20
  import "@radix-ui/react-dropdown-menu";
19
- const G = ({
20
- text: e,
21
- maxChars: i,
22
- maxLines: n
21
+ const jt = ({
22
+ text: t,
23
+ maxChars: a,
24
+ maxLines: r
23
25
  }) => {
24
- if (e.length === 0)
26
+ if (t.length === 0)
25
27
  return 0;
26
- const r = typeof n == "number", o = typeof i == "number";
27
- if (!r && !o)
28
- return e.length;
29
- let s = 0, t = 0;
30
- for (; t < e.length && (!r || s < n) && (!o || t < i); )
31
- e[t] === `
32
- ` && s++, t++;
33
- return e.slice(0, t).length;
34
- }, K = ({
35
- editor: e,
36
- maxChars: i,
37
- maxLines: n
28
+ const o = typeof r == "number", i = typeof a == "number";
29
+ if (!o && !i)
30
+ return t.length;
31
+ let l = 0, s = 0;
32
+ for (; s < t.length && (!o || l < r) && (!i || s < a); )
33
+ t[s] === `
34
+ ` && l++, s++;
35
+ return t.slice(0, s).length;
36
+ }, Wt = ({
37
+ editor: t,
38
+ maxChars: a,
39
+ maxLines: r
38
40
  }) => {
39
- const r = f(), o = r.getTextContent(), s = G({ text: o, maxChars: i, maxLines: n }), t = o.length - s, m = r.select().anchor;
40
- L(e, m, t);
41
- const c = r.getLastChild();
42
- return c instanceof E && c.getChildrenSize() === 0 && c.remove(), t;
43
- }, U = (e) => e[0] === "{", Se = (e, i, n) => {
44
- let r = 0;
45
- const o = y({
46
- nodes: i,
41
+ const o = I(), i = o.getTextContent(), l = jt({ text: i, maxChars: a, maxLines: r }), s = i.length - l, f = o.select().anchor;
42
+ Y(t, f, s);
43
+ const n = o.getLastChild();
44
+ return n instanceof V && n.getChildrenSize() === 0 && n.remove(), s;
45
+ }, _t = (t) => t[0] === "{", We = (t, a, r) => {
46
+ let o = 0;
47
+ const i = G({
48
+ nodes: a,
47
49
  editable: !1
48
50
  });
49
- if (e)
51
+ if (t)
50
52
  try {
51
- if (typeof e == "string" && !U(e))
52
- o.update(() => {
53
- const t = f(), l = $();
54
- l.append(F(e.trim())), t.append(l);
53
+ if (typeof t == "string" && !_t(t))
54
+ i.update(() => {
55
+ const s = I(), p = R();
56
+ p.append(J(t.trim())), s.append(p);
55
57
  });
56
58
  else {
57
- const t = o.parseEditorState(e, () => {
58
- r = K({
59
- editor: o,
60
- maxLines: n == null ? void 0 : n.maxLines
59
+ const s = i.parseEditorState(t, () => {
60
+ o = Wt({
61
+ editor: i,
62
+ maxLines: r == null ? void 0 : r.maxLines
61
63
  });
62
64
  });
63
- t.isEmpty() || o.setEditorState(t);
65
+ s.isEmpty() || i.setEditorState(s);
64
66
  }
65
- } catch (t) {
66
- console.error(t);
67
+ } catch (s) {
68
+ console.error(s);
67
69
  }
68
- let s = "";
69
- return o.update(() => {
70
- s = S(o);
71
- }), { html: s, trimCount: r };
72
- }, Ee = [
73
- k,
74
- P,
75
- R,
76
- H,
77
- w,
78
- v,
79
- I,
80
- M,
81
- B
82
- ], X = d({
70
+ let l = "";
71
+ return i.update(() => {
72
+ l = Q(i);
73
+ }), { html: l, trimCount: o };
74
+ }, _e = [
75
+ it,
76
+ st,
77
+ O,
78
+ et,
79
+ Z,
80
+ tt,
81
+ ht,
82
+ pt,
83
+ ut
84
+ ], At = w({
83
85
  fontWeight: "bold"
84
- }), Y = d({
86
+ }), Pt = w({
85
87
  fontStyle: "italic"
86
- }), Z = d({
88
+ }), Ut = w({
87
89
  textDecoration: "underline"
88
- }), _ = d({
90
+ }), qt = w({
89
91
  listStyleType: "none"
90
- }), ee = d({
92
+ }), Kt = w({
91
93
  borderLeft: "4px solid #ccc",
92
94
  color: "#666",
93
95
  fontStyle: "italic",
94
96
  margin: "1.5em 10px",
95
97
  padding: "0.5em 10px"
96
- }), te = {
97
- quote: ee().className,
98
+ }), Gt = {
99
+ quote: Kt().className,
98
100
  text: {
99
- bold: X().className,
100
- italic: Y().className,
101
- underline: Z().className
101
+ bold: At().className,
102
+ italic: Pt().className,
103
+ underline: Ut().className
102
104
  },
103
105
  list: {
104
106
  nested: {
105
- listitem: _().className
107
+ listitem: qt().className
106
108
  }
107
109
  }
108
- }, g = q({ hasFocus: !1, editorRef: { current: null } }), oe = ({ onBlur: e }) => {
109
- const [i, n] = z(!1), r = b(null), o = p(() => {
110
- n(!0), r.current && window.clearTimeout(r.current);
111
- }, []), s = p(() => {
112
- r.current = window.setTimeout(() => {
113
- n(!1), e == null || e();
110
+ }, U = gt({ hasFocus: !1, editorRef: { current: null } }), Qt = ({ onBlur: t }) => {
111
+ const [a, r] = M(!1), o = j(null), i = k(() => {
112
+ r(!0), o.current && window.clearTimeout(o.current);
113
+ }, []), l = k(() => {
114
+ o.current = window.setTimeout(() => {
115
+ r(!1), t == null || t();
114
116
  }, 0);
115
- }, [e]);
117
+ }, [t]);
116
118
  return {
117
- hasFocus: i,
119
+ hasFocus: a,
118
120
  attributes: {
119
- onFocus: o,
120
- onBlur: s
121
+ onFocus: i,
122
+ onBlur: l
121
123
  }
122
124
  };
123
- }, $e = () => A(g), re = V("div", {
125
+ }, Vt = () => mt(U);
126
+ function Jt(t) {
127
+ return d({ tag: "svg", attr: { viewBox: "0 0 24 24", strokeWidth: "2", stroke: "currentColor", fill: "none", strokeLinecap: "round", strokeLinejoin: "round" }, child: [{ tag: "path", attr: { stroke: "none", d: "M0 0h24v24H0z", fill: "none" } }, { tag: "path", attr: { d: "M7 5h6a3.5 3.5 0 0 1 0 7h-6z" } }, { tag: "path", attr: { d: "M13 12h1a3.5 3.5 0 0 1 0 7h-7v-7" } }] })(t);
128
+ }
129
+ function Xt(t) {
130
+ return d({ tag: "svg", attr: { viewBox: "0 0 24 24", strokeWidth: "2", stroke: "currentColor", fill: "none", strokeLinecap: "round", strokeLinejoin: "round" }, child: [{ tag: "path", attr: { stroke: "none", d: "M0 0h24v24H0z", fill: "none" } }, { tag: "path", attr: { d: "M7 8l-4 4l4 4" } }, { tag: "path", attr: { d: "M17 8l4 4l-4 4" } }, { tag: "path", attr: { d: "M14 4l-4 16" } }] })(t);
131
+ }
132
+ function Yt(t) {
133
+ return d({ tag: "svg", attr: { viewBox: "0 0 24 24", strokeWidth: "2", stroke: "currentColor", fill: "none", strokeLinecap: "round", strokeLinejoin: "round" }, child: [{ tag: "path", attr: { stroke: "none", d: "M0 0h24v24H0z", fill: "none" } }, { tag: "path", attr: { d: "M19 18v-8l-2 2" } }, { tag: "path", attr: { d: "M4 6v12" } }, { tag: "path", attr: { d: "M12 6v12" } }, { tag: "path", attr: { d: "M11 18h2" } }, { tag: "path", attr: { d: "M3 18h2" } }, { tag: "path", attr: { d: "M4 12h8" } }, { tag: "path", attr: { d: "M3 6h2" } }, { tag: "path", attr: { d: "M11 6h2" } }] })(t);
134
+ }
135
+ function Zt(t) {
136
+ return d({ tag: "svg", attr: { viewBox: "0 0 24 24", strokeWidth: "2", stroke: "currentColor", fill: "none", strokeLinecap: "round", strokeLinejoin: "round" }, child: [{ tag: "path", attr: { stroke: "none", d: "M0 0h24v24H0z", fill: "none" } }, { tag: "path", attr: { d: "M17 12a2 2 0 1 1 4 0c0 .591 -.417 1.318 -.816 1.858l-3.184 4.143l4 0" } }, { tag: "path", attr: { d: "M4 6v12" } }, { tag: "path", attr: { d: "M12 6v12" } }, { tag: "path", attr: { d: "M11 18h2" } }, { tag: "path", attr: { d: "M3 18h2" } }, { tag: "path", attr: { d: "M4 12h8" } }, { tag: "path", attr: { d: "M3 6h2" } }, { tag: "path", attr: { d: "M11 6h2" } }] })(t);
137
+ }
138
+ function te(t) {
139
+ return d({ tag: "svg", attr: { viewBox: "0 0 24 24", strokeWidth: "2", stroke: "currentColor", fill: "none", strokeLinecap: "round", strokeLinejoin: "round" }, child: [{ tag: "path", attr: { stroke: "none", d: "M0 0h24v24H0z", fill: "none" } }, { tag: "path", attr: { d: "M19 14a2 2 0 1 0 -2 -2" } }, { tag: "path", attr: { d: "M17 16a2 2 0 1 0 2 -2" } }, { tag: "path", attr: { d: "M4 6v12" } }, { tag: "path", attr: { d: "M12 6v12" } }, { tag: "path", attr: { d: "M11 18h2" } }, { tag: "path", attr: { d: "M3 18h2" } }, { tag: "path", attr: { d: "M4 12h8" } }, { tag: "path", attr: { d: "M3 6h2" } }, { tag: "path", attr: { d: "M11 6h2" } }] })(t);
140
+ }
141
+ function ee(t) {
142
+ return d({ tag: "svg", attr: { viewBox: "0 0 24 24", strokeWidth: "2", stroke: "currentColor", fill: "none", strokeLinecap: "round", strokeLinejoin: "round" }, child: [{ tag: "path", attr: { stroke: "none", d: "M0 0h24v24H0z", fill: "none" } }, { tag: "path", attr: { d: "M20 18v-8l-4 6h5" } }, { tag: "path", attr: { d: "M4 6v12" } }, { tag: "path", attr: { d: "M12 6v12" } }, { tag: "path", attr: { d: "M11 18h2" } }, { tag: "path", attr: { d: "M3 18h2" } }, { tag: "path", attr: { d: "M4 12h8" } }, { tag: "path", attr: { d: "M3 6h2" } }, { tag: "path", attr: { d: "M11 6h2" } }] })(t);
143
+ }
144
+ function re(t) {
145
+ return d({ tag: "svg", attr: { viewBox: "0 0 24 24", strokeWidth: "2", stroke: "currentColor", fill: "none", strokeLinecap: "round", strokeLinejoin: "round" }, child: [{ tag: "path", attr: { stroke: "none", d: "M0 0h24v24H0z", fill: "none" } }, { tag: "path", attr: { d: "M17 18h2a2 2 0 1 0 0 -4h-2v-4h4" } }, { tag: "path", attr: { d: "M4 6v12" } }, { tag: "path", attr: { d: "M12 6v12" } }, { tag: "path", attr: { d: "M11 18h2" } }, { tag: "path", attr: { d: "M3 18h2" } }, { tag: "path", attr: { d: "M4 12h8" } }, { tag: "path", attr: { d: "M3 6h2" } }, { tag: "path", attr: { d: "M11 6h2" } }] })(t);
146
+ }
147
+ function oe(t) {
148
+ return d({ tag: "svg", attr: { viewBox: "0 0 24 24", strokeWidth: "2", stroke: "currentColor", fill: "none", strokeLinecap: "round", strokeLinejoin: "round" }, child: [{ tag: "path", attr: { stroke: "none", d: "M0 0h24v24H0z", fill: "none" } }, { tag: "path", attr: { d: "M19 14a2 2 0 1 0 0 4a2 2 0 0 0 0 -4z" } }, { tag: "path", attr: { d: "M21 12a2 2 0 1 0 -4 0v4" } }, { tag: "path", attr: { d: "M4 6v12" } }, { tag: "path", attr: { d: "M12 6v12" } }, { tag: "path", attr: { d: "M11 18h2" } }, { tag: "path", attr: { d: "M3 18h2" } }, { tag: "path", attr: { d: "M4 12h8" } }, { tag: "path", attr: { d: "M3 6h2" } }, { tag: "path", attr: { d: "M11 6h2" } }] })(t);
149
+ }
150
+ function ae(t) {
151
+ return d({ tag: "svg", attr: { viewBox: "0 0 24 24", strokeWidth: "2", stroke: "currentColor", fill: "none", strokeLinecap: "round", strokeLinejoin: "round" }, child: [{ tag: "path", attr: { stroke: "none", d: "M0 0h24v24H0z", fill: "none" } }, { tag: "path", attr: { d: "M11 5l6 0" } }, { tag: "path", attr: { d: "M7 19l6 0" } }, { tag: "path", attr: { d: "M14 5l-4 14" } }] })(t);
152
+ }
153
+ function ne(t) {
154
+ return d({ tag: "svg", attr: { viewBox: "0 0 24 24", strokeWidth: "2", stroke: "currentColor", fill: "none", strokeLinecap: "round", strokeLinejoin: "round" }, child: [{ tag: "path", attr: { stroke: "none", d: "M0 0h24v24H0z", fill: "none" } }, { tag: "path", attr: { d: "M17.5 15.5m-3.5 0a3.5 3.5 0 1 0 7 0a3.5 3.5 0 1 0 -7 0" } }, { tag: "path", attr: { d: "M3 19v-10.5a3.5 3.5 0 0 1 7 0v10.5" } }, { tag: "path", attr: { d: "M3 13h7" } }, { tag: "path", attr: { d: "M21 12v7" } }] })(t);
155
+ }
156
+ function ie(t) {
157
+ return d({ tag: "svg", attr: { viewBox: "0 0 24 24", strokeWidth: "2", stroke: "currentColor", fill: "none", strokeLinecap: "round", strokeLinejoin: "round" }, child: [{ tag: "path", attr: { stroke: "none", d: "M0 0h24v24H0z", fill: "none" } }, { tag: "path", attr: { d: "M3.5 5.5l1.5 1.5l2.5 -2.5" } }, { tag: "path", attr: { d: "M3.5 11.5l1.5 1.5l2.5 -2.5" } }, { tag: "path", attr: { d: "M3.5 17.5l1.5 1.5l2.5 -2.5" } }, { tag: "path", attr: { d: "M11 6l9 0" } }, { tag: "path", attr: { d: "M11 12l9 0" } }, { tag: "path", attr: { d: "M11 18l9 0" } }] })(t);
158
+ }
159
+ function se(t) {
160
+ return d({ tag: "svg", attr: { viewBox: "0 0 24 24", strokeWidth: "2", stroke: "currentColor", fill: "none", strokeLinecap: "round", strokeLinejoin: "round" }, child: [{ tag: "path", attr: { stroke: "none", d: "M0 0h24v24H0z", fill: "none" } }, { tag: "path", attr: { d: "M11 6h9" } }, { tag: "path", attr: { d: "M11 12h9" } }, { tag: "path", attr: { d: "M12 18h8" } }, { tag: "path", attr: { d: "M4 16a2 2 0 1 1 4 0c0 .591 -.5 1 -1 1.5l-3 2.5h4" } }, { tag: "path", attr: { d: "M6 10v-6l-2 2" } }] })(t);
161
+ }
162
+ function le(t) {
163
+ return d({ tag: "svg", attr: { viewBox: "0 0 24 24", strokeWidth: "2", stroke: "currentColor", fill: "none", strokeLinecap: "round", strokeLinejoin: "round" }, child: [{ tag: "path", attr: { stroke: "none", d: "M0 0h24v24H0z", fill: "none" } }, { tag: "path", attr: { d: "M9 6l11 0" } }, { tag: "path", attr: { d: "M9 12l11 0" } }, { tag: "path", attr: { d: "M9 18l11 0" } }, { tag: "path", attr: { d: "M5 6l0 .01" } }, { tag: "path", attr: { d: "M5 12l0 .01" } }, { tag: "path", attr: { d: "M5 18l0 .01" } }] })(t);
164
+ }
165
+ function de(t) {
166
+ return d({ tag: "svg", attr: { viewBox: "0 0 24 24", strokeWidth: "2", stroke: "currentColor", fill: "none", strokeLinecap: "round", strokeLinejoin: "round" }, child: [{ tag: "path", attr: { stroke: "none", d: "M0 0h24v24H0z", fill: "none" } }, { tag: "path", attr: { d: "M10 11h-4a1 1 0 0 1 -1 -1v-3a1 1 0 0 1 1 -1h3a1 1 0 0 1 1 1v6c0 2.667 -1.333 4.333 -4 5" } }, { tag: "path", attr: { d: "M19 11h-4a1 1 0 0 1 -1 -1v-3a1 1 0 0 1 1 -1h3a1 1 0 0 1 1 1v6c0 2.667 -1.333 4.333 -4 5" } }] })(t);
167
+ }
168
+ function ce(t) {
169
+ return d({ tag: "svg", attr: { viewBox: "0 0 24 24", strokeWidth: "2", stroke: "currentColor", fill: "none", strokeLinecap: "round", strokeLinejoin: "round" }, child: [{ tag: "path", attr: { stroke: "none", d: "M0 0h24v24H0z", fill: "none" } }, { tag: "path", attr: { d: "M5 7l8 10m-8 0l8 -10" } }, { tag: "path", attr: { d: "M21 11h-4l3.5 -4a1.73 1.73 0 0 0 -3.5 -2" } }] })(t);
170
+ }
171
+ function he(t) {
172
+ return d({ tag: "svg", attr: { viewBox: "0 0 24 24", strokeWidth: "2", stroke: "currentColor", fill: "none", strokeLinecap: "round", strokeLinejoin: "round" }, child: [{ tag: "path", attr: { stroke: "none", d: "M0 0h24v24H0z", fill: "none" } }, { tag: "path", attr: { d: "M7 5v5a5 5 0 0 0 10 0v-5" } }, { tag: "path", attr: { d: "M5 19h14" } }] })(t);
173
+ }
174
+ const pe = A("div", {
175
+ width: "10rem",
176
+ display: "flex"
177
+ }), q = {
178
+ bullet: "Punktliste",
179
+ h1: "Overskrift 1",
180
+ h2: "Overskrift 2",
181
+ h3: "Overskrift 3",
182
+ h4: "Overskrift 4",
183
+ h5: "Overskrift 5",
184
+ h6: "Overskrift 6",
185
+ number: "Nummerert liste",
186
+ paragraph: "Normal",
187
+ quote: "Sitat",
188
+ check: "Avkrysningsliste"
189
+ }, ue = {
190
+ bullet: /* @__PURE__ */ e(le, { size: "1.25rem" }),
191
+ h1: /* @__PURE__ */ e(Yt, { size: "1.25rem" }),
192
+ h2: /* @__PURE__ */ e(Zt, { size: "1.25rem" }),
193
+ h3: /* @__PURE__ */ e(te, { size: "1.25rem" }),
194
+ h4: /* @__PURE__ */ e(ee, { size: "1.25rem" }),
195
+ h5: /* @__PURE__ */ e(re, { size: "1.25rem" }),
196
+ h6: /* @__PURE__ */ e(oe, { size: "1.25rem" }),
197
+ number: /* @__PURE__ */ e(se, { size: "1.25rem" }),
198
+ check: /* @__PURE__ */ e(ie, { size: "1.25rem" }),
199
+ paragraph: /* @__PURE__ */ e(ne, { size: "1.25rem" }),
200
+ quote: /* @__PURE__ */ e(de, { size: "1.25rem" })
201
+ }, g = ({
202
+ blockType: t
203
+ }) => /* @__PURE__ */ C(D, { children: [
204
+ /* @__PURE__ */ e(S, { css: { display: "flex" }, children: ue[t] }),
205
+ /* @__PURE__ */ e(S, { children: q[t] })
206
+ ] }), ge = (t) => {
207
+ if (!N(t))
208
+ return null;
209
+ const a = t.anchor.getNode();
210
+ let r = a.getKey() === "root" ? a : Ot(a, (o) => {
211
+ const i = o.getParent();
212
+ return i !== null && X(i);
213
+ });
214
+ return r === null && (r = a.getTopLevelElementOrThrow()), {
215
+ anchorNode: a,
216
+ element: r
217
+ };
218
+ }, me = () => {
219
+ const [t] = P(), [a, r] = M("paragraph");
220
+ W(() => t.registerCommand(
221
+ $,
222
+ () => {
223
+ const n = y(), u = ge(n);
224
+ if (!u)
225
+ return !1;
226
+ const { element: c, anchorNode: b } = u, T = c.getKey();
227
+ if (t.getElementByKey(T) !== null)
228
+ if (rt(c)) {
229
+ const v = Ft(
230
+ b,
231
+ O
232
+ ), z = v ? v.getListType() : c.getListType();
233
+ r(z);
234
+ } else {
235
+ const v = lt(c) ? c.getTag() : c.getType();
236
+ v in q && r(v);
237
+ }
238
+ return !1;
239
+ },
240
+ F
241
+ ), [t]);
242
+ const o = (n) => {
243
+ a !== n && t.update(() => {
244
+ const u = y();
245
+ (N(u) || E(u)) && (H(u, () => dt(n)), r(n));
246
+ });
247
+ };
248
+ return /* @__PURE__ */ e(pe, { children: /* @__PURE__ */ C(
249
+ kt,
250
+ {
251
+ trigger: /* @__PURE__ */ e(
252
+ Mt,
253
+ {
254
+ dropdown: !0,
255
+ css: { display: "flex", width: "100%", overflow: "hidden" },
256
+ children: /* @__PURE__ */ e(g, { blockType: a })
257
+ }
258
+ ),
259
+ side: "bottom",
260
+ align: "start",
261
+ children: [
262
+ /* @__PURE__ */ e(m, { onClick: () => {
263
+ a !== "paragraph" && t.update(() => {
264
+ const n = y();
265
+ (N(n) || E(n)) && (H(n, () => R()), r("paragraph"));
266
+ });
267
+ }, children: /* @__PURE__ */ e(g, { blockType: "paragraph" }) }),
268
+ /* @__PURE__ */ e(m, { onClick: () => o("h1"), children: /* @__PURE__ */ e(g, { blockType: "h1" }) }),
269
+ /* @__PURE__ */ e(m, { onClick: () => o("h2"), children: /* @__PURE__ */ e(g, { blockType: "h2" }) }),
270
+ /* @__PURE__ */ e(m, { onClick: () => o("h3"), children: /* @__PURE__ */ e(g, { blockType: "h3" }) }),
271
+ /* @__PURE__ */ e(m, { onClick: () => o("h4"), children: /* @__PURE__ */ e(g, { blockType: "h4" }) }),
272
+ /* @__PURE__ */ e(m, { onClick: () => o("h5"), children: /* @__PURE__ */ e(g, { blockType: "h5" }) }),
273
+ /* @__PURE__ */ e(m, { onClick: () => o("h6"), children: /* @__PURE__ */ e(g, { blockType: "h6" }) }),
274
+ /* @__PURE__ */ e(m, { onClick: () => {
275
+ a !== "bullet" && (t.dispatchCommand(ot, void 0), r("bullet"));
276
+ }, children: /* @__PURE__ */ e(g, { blockType: "bullet" }) }),
277
+ /* @__PURE__ */ e(m, { onClick: () => {
278
+ a !== "number" && (t.dispatchCommand(at, void 0), r("number"));
279
+ }, children: /* @__PURE__ */ e(g, { blockType: "number" }) }),
280
+ /* @__PURE__ */ e(m, { onClick: () => {
281
+ a !== "check" && (t.dispatchCommand(nt, void 0), r("check"));
282
+ }, children: /* @__PURE__ */ e(g, { blockType: "check" }) }),
283
+ /* @__PURE__ */ e(m, { onClick: () => {
284
+ a !== "quote" && t.update(() => {
285
+ const n = y();
286
+ (N(n) || E(n)) && (H(n, () => ct()), r("quote"));
287
+ });
288
+ }, children: /* @__PURE__ */ e(g, { blockType: "quote" }) })
289
+ ]
290
+ }
291
+ ) });
292
+ }, fe = () => {
293
+ const [t] = P(), [a, r] = M(!1), [o, i] = M(!1), [l, s] = M(!1), [p, f] = M(!1), [n, u] = M(!1), c = k(() => {
294
+ const h = y();
295
+ N(h) && (r(h.hasFormat("bold")), i(h.hasFormat("italic")), s(h.hasFormat("underline")), f(h.hasFormat("code")), u(h.hasFormat("superscript")));
296
+ }, []);
297
+ W(() => Dt(
298
+ t.registerCommand(
299
+ $,
300
+ () => (c(), !1),
301
+ F
302
+ ),
303
+ t.registerUpdateListener(({ editorState: h }) => {
304
+ h.read(() => {
305
+ c();
306
+ });
307
+ })
308
+ ), [t, c]);
309
+ const b = k(
310
+ () => t.dispatchCommand(L, "bold"),
311
+ [t]
312
+ ), T = k(
313
+ () => t.dispatchCommand(L, "italic"),
314
+ [t]
315
+ ), B = k(
316
+ () => t.dispatchCommand(L, "underline"),
317
+ [t]
318
+ ), v = k(
319
+ () => t.dispatchCommand(L, "code"),
320
+ [t]
321
+ ), z = k(
322
+ () => t.dispatchCommand(L, "superscript"),
323
+ [t]
324
+ ), K = _(() => {
325
+ const h = [];
326
+ return a && h.push("bold"), o && h.push("italic"), l && h.push("underline"), p && h.push("code"), n && h.push("superscript"), h;
327
+ }, [a, o, l, p, n]);
328
+ return /* @__PURE__ */ C(
329
+ vt,
330
+ {
331
+ type: "multiple",
332
+ "aria-label": "Tekstformattering",
333
+ value: K,
334
+ children: [
335
+ /* @__PURE__ */ e(
336
+ x,
337
+ {
338
+ onClick: b,
339
+ title: "Fet tekst",
340
+ value: "bold",
341
+ children: /* @__PURE__ */ e(Jt, { size: "1.25rem" })
342
+ }
343
+ ),
344
+ /* @__PURE__ */ e(
345
+ x,
346
+ {
347
+ onClick: T,
348
+ title: "Kursiv tekst",
349
+ value: "italic",
350
+ children: /* @__PURE__ */ e(ae, { size: "1.25rem" })
351
+ }
352
+ ),
353
+ /* @__PURE__ */ e(
354
+ x,
355
+ {
356
+ onClick: B,
357
+ title: "Understreket tekst",
358
+ value: "underline",
359
+ children: /* @__PURE__ */ e(he, { size: "1.25rem" })
360
+ }
361
+ ),
362
+ /* @__PURE__ */ e(
363
+ x,
364
+ {
365
+ onClick: v,
366
+ title: "Kode",
367
+ value: "code",
368
+ children: /* @__PURE__ */ e(Xt, { size: "1.25rem" })
369
+ }
370
+ ),
371
+ /* @__PURE__ */ e(
372
+ x,
373
+ {
374
+ onClick: z,
375
+ title: "Superscript",
376
+ value: "superscript",
377
+ children: /* @__PURE__ */ e(ce, { size: "1.25rem" })
378
+ }
379
+ )
380
+ ]
381
+ }
382
+ );
383
+ }, ke = ({ children: t }) => {
384
+ const { hasFocus: a, editorRef: r } = Vt(), o = a, [i, l] = M(o);
385
+ ft(() => {
386
+ l(o);
387
+ }, [o]);
388
+ const { context: s, refs: p, floatingStyles: f } = Ct({
389
+ placement: "top",
390
+ whileElementsMounted: bt,
391
+ middleware: [
392
+ Tt({
393
+ apply: ({ rects: u, elements: c }) => {
394
+ c.floating.style.minWidth = `${u.reference.width}px`;
395
+ }
396
+ }),
397
+ Lt(),
398
+ xt({
399
+ mainAxis: 8
400
+ }),
401
+ yt({
402
+ padding: 8
403
+ })
404
+ ],
405
+ open: i,
406
+ onOpenChange: l,
407
+ elements: {
408
+ reference: r.current
409
+ }
410
+ }), { getFloatingProps: n } = Nt([
411
+ wt(s, {
412
+ role: "dialog"
413
+ })
414
+ ]);
415
+ return i ? /* @__PURE__ */ e(St, { children: /* @__PURE__ */ e(
416
+ zt,
417
+ {
418
+ ref: p.setFloating,
419
+ style: f,
420
+ ...n,
421
+ css: {
422
+ border: "1px solid $border",
423
+ borderRadius: "$md",
424
+ overflow: "hidden",
425
+ boxShadow: "$md"
426
+ },
427
+ children: /* @__PURE__ */ C(Et, { "aria-label": "Formattering", children: [
428
+ /* @__PURE__ */ e(me, {}),
429
+ /* @__PURE__ */ e(Ht, {}),
430
+ /* @__PURE__ */ e(fe, {}),
431
+ t
432
+ ] })
433
+ }
434
+ ) }) : null;
435
+ }, Me = A("div", {
124
436
  border: "1px solid $borderDarker",
125
437
  borderRadius: "$md",
126
438
  position: "relative",
@@ -150,59 +462,59 @@ const G = ({
150
462
  }
151
463
  }
152
464
  ]
153
- }), ne = ({
154
- isLoading: e
155
- }) => /* @__PURE__ */ a(
156
- x,
465
+ }), ve = ({
466
+ isLoading: t
467
+ }) => /* @__PURE__ */ e(
468
+ S,
157
469
  {
158
470
  css: {
159
- visibility: e ? "visible" : "hidden",
471
+ visibility: t ? "visible" : "hidden",
160
472
  position: "absolute",
161
473
  bottom: "1rem",
162
474
  right: "1rem",
163
475
  display: "flex"
164
476
  },
165
- children: /* @__PURE__ */ a(W, {})
477
+ children: /* @__PURE__ */ e(Bt, {})
166
478
  }
167
- ), Fe = ({
168
- isLoading: e,
169
- children: i,
170
- placeholderText: n,
171
- nodes: r,
172
- plugins: o,
173
- toolbar: s,
174
- content: t,
175
- hideBorder: l,
176
- onBlur: m
479
+ ), Ae = ({
480
+ isLoading: t,
481
+ children: a,
482
+ placeholderText: r,
483
+ nodes: o,
484
+ plugins: i,
485
+ toolbarContent: l,
486
+ content: s,
487
+ hideBorder: p,
488
+ onBlur: f
177
489
  }) => {
178
- const { hasFocus: c, attributes: C } = oe({ onBlur: m }), u = b(null), N = D(() => ({ hasFocus: c, editorRef: u }), [c]);
179
- return /* @__PURE__ */ a(g.Provider, { value: N, children: /* @__PURE__ */ h(
180
- J,
490
+ const { hasFocus: n, attributes: u } = Qt({ onBlur: f }), c = j(null), b = _(() => ({ hasFocus: n, editorRef: c }), [n]);
491
+ return /* @__PURE__ */ e(U.Provider, { value: b, children: /* @__PURE__ */ C(
492
+ It,
181
493
  {
182
494
  initialConfig: {
183
495
  namespace: "CommentEditor",
184
496
  onError: (T) => {
185
497
  console.error(T);
186
498
  },
187
- theme: te,
188
- nodes: r,
499
+ theme: Gt,
500
+ nodes: o,
189
501
  editable: !0
190
502
  },
191
503
  children: [
192
- /* @__PURE__ */ h(
193
- re,
504
+ /* @__PURE__ */ C(
505
+ Me,
194
506
  {
195
- ref: u,
196
- hasFocus: c,
197
- hideBorder: l,
198
- ...C,
507
+ ref: c,
508
+ hasFocus: n,
509
+ hideBorder: p,
510
+ ...u,
199
511
  children: [
200
- /* @__PURE__ */ a(
201
- O,
512
+ /* @__PURE__ */ e(
513
+ Rt,
202
514
  {
203
- contentEditable: t,
204
- placeholder: n ? /* @__PURE__ */ a(
205
- x,
515
+ contentEditable: s,
516
+ placeholder: r ? /* @__PURE__ */ e(
517
+ S,
206
518
  {
207
519
  css: {
208
520
  position: "absolute",
@@ -212,29 +524,29 @@ const G = ({
212
524
  pointerEvents: "none",
213
525
  fontSize: "$sm"
214
526
  },
215
- children: n
527
+ children: r
216
528
  }
217
529
  ) : null,
218
- ErrorBoundary: Q
530
+ ErrorBoundary: $t
219
531
  }
220
532
  ),
221
- o,
222
- /* @__PURE__ */ a(ne, { isLoading: e }),
223
- s
533
+ i,
534
+ /* @__PURE__ */ e(ve, { isLoading: t }),
535
+ /* @__PURE__ */ e(ke, { children: l })
224
536
  ]
225
537
  }
226
538
  ),
227
- /* @__PURE__ */ a(j, { children: i })
539
+ /* @__PURE__ */ e(D, { children: a })
228
540
  ]
229
541
  }
230
542
  ) });
231
543
  };
232
544
  export {
233
- Fe as RichTextEditor,
234
- Ee as defaultNodes,
235
- U as isJSON,
236
- g as richTextContext,
237
- Se as stateToHTML,
238
- oe as useHasFocusWithin,
239
- $e as useRichTextContext
545
+ Ae as RichTextEditor,
546
+ _e as defaultNodes,
547
+ _t as isJSON,
548
+ U as richTextContext,
549
+ We as stateToHTML,
550
+ Qt as useHasFocusWithin,
551
+ Vt as useRichTextContext
240
552
  };