@arkitektbedriftene/fe-lib 0.3.17 → 0.3.19

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,130 +1,655 @@
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 dt } from "@lexical/headless";
2
+ import { $generateHtmlFromNodes as ct } from "@lexical/html";
3
+ import { $getRoot as _, ParagraphNode as ht, $createParagraphNode as R, $createTextNode as $, $setSelection as G, SELECTION_CHANGE_COMMAND as Q, $getSelection as L, COMMAND_PRIORITY_CRITICAL as X, $isRangeSelection as N, $isRootOrShadowRoot as ut, DEPRECATED_$isGridSelection as H, FORMAT_TEXT_COMMAND as E, COMMAND_PRIORITY_LOW as T, KEY_ARROW_DOWN_COMMAND as pt, KEY_ARROW_UP_COMMAND as gt, KEY_ESCAPE_COMMAND as ft, KEY_SPACE_COMMAND as mt, $getNearestNodeFromDOMNode as A, KEY_ARROW_LEFT_COMMAND as kt, $isElementNode as Mt } from "lexical";
4
+ import { trimTextContentFromAnchor as vt, $setBlocksType as F } from "@lexical/selection";
5
+ import { AutoLinkNode as Ct, LinkNode as bt } from "@lexical/link";
6
+ import { ListNode as V, ListItemNode as Tt, $isListNode as W, INSERT_UNORDERED_LIST_COMMAND as Lt, INSERT_ORDERED_LIST_COMMAND as Nt, INSERT_CHECK_LIST_COMMAND as J, insertList as yt, $isListItemNode as y } from "@lexical/list";
7
+ import { HeadingNode as xt, QuoteNode as Et, $isHeadingNode as St, $createHeadingNode as wt, $createQuoteNode as It } from "@lexical/rich-text";
8
+ import { TableNode as Ot, TableRowNode as _t, TableCellNode as Rt } from "@lexical/table";
9
+ import { jsx as o, jsxs as C, Fragment as j } from "react/jsx-runtime";
10
+ import { createContext as zt, useState as v, useRef as Z, useCallback as M, useContext as Bt, useEffect as z, useMemo as tt, useLayoutEffect as Dt } from "react";
11
+ import { c as w, s as et, D as Ht, T as Ft, a as m, B as O, b as Pt, d as S, u as $t, e as At, f as Wt, g as jt, o as Kt, h as Ut, i as Yt, j as qt, F as Gt, O as Qt, k as Xt, l as Vt, S as Jt } from "./DropdownMenu-1eb444b3.js";
12
+ import { LexicalComposer as Zt } from "@lexical/react/LexicalComposer.js";
13
+ import { RichTextPlugin as te } from "@lexical/react/LexicalRichTextPlugin.js";
14
+ import ee from "@lexical/react/LexicalErrorBoundary.js";
15
+ import { useLexicalComposerContext as B } from "@lexical/react/LexicalComposerContext.js";
16
+ import { $getNearestNodeOfType as re, $findMatchingParent as rt, mergeRegister as ot, isHTMLElement as K } from "@lexical/utils";
17
+ import { G as h } from "./index.esm-d078f232.js";
18
+ import { ListPlugin as oe } from "@lexical/react/LexicalListPlugin.js";
19
+ import { HistoryPlugin as ne } from "@lexical/react/LexicalHistoryPlugin.js";
20
+ import { TablePlugin as ae } from "@lexical/react/LexicalTablePlugin.js";
21
+ import { TabIndentationPlugin as ie } from "@lexical/react/LexicalTabIndentationPlugin.js";
15
22
  import "react-dom";
16
23
  import "@radix-ui/react-toolbar";
17
- import "./index.esm-d078f232.js";
18
24
  import "@radix-ui/react-dropdown-menu";
19
- const G = ({
20
- text: e,
21
- maxChars: i,
22
- maxLines: n
25
+ const se = ({
26
+ text: t,
27
+ maxChars: r,
28
+ maxLines: e
23
29
  }) => {
24
- if (e.length === 0)
30
+ if (t.length === 0)
25
31
  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
32
+ const n = typeof e == "number", a = typeof r == "number";
33
+ if (!n && !a)
34
+ return t.length;
35
+ let s = 0, i = 0;
36
+ for (; i < t.length && (!n || s < e) && (!a || i < r); )
37
+ t[i] === `
38
+ ` && s++, i++;
39
+ return t.slice(0, i).length;
40
+ }, le = ({
41
+ editor: t,
42
+ maxChars: r,
43
+ maxLines: e
38
44
  }) => {
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,
45
+ const n = _(), a = n.getTextContent(), s = se({ text: a, maxChars: r, maxLines: e }), i = a.length - s, p = n.select().anchor;
46
+ vt(t, p, i);
47
+ const l = n.getLastChild();
48
+ return l instanceof ht && l.getChildrenSize() === 0 && l.remove(), i;
49
+ }, nt = (t) => t[0] === "{", de = (t) => t !== null && typeof t == "object" && "isEmpty" in t, ce = (t, r) => {
50
+ t.update(
51
+ () => {
52
+ const e = _();
53
+ e.clear();
54
+ const n = R();
55
+ n.append($("")), e.append(n), G(null);
56
+ },
57
+ {
58
+ tag: r
59
+ }
60
+ );
61
+ }, he = (t, r, e) => {
62
+ r.update(
63
+ () => {
64
+ const n = _();
65
+ n.clear();
66
+ const a = R();
67
+ a.append($(t.trim())), n.append(a), G(null);
68
+ },
69
+ {
70
+ tag: e
71
+ }
72
+ ), r.blur();
73
+ }, vr = (t, r, e) => {
74
+ let n = 0;
75
+ const a = dt({
76
+ nodes: r,
47
77
  editable: !1
48
78
  });
49
- if (e)
79
+ if (t)
50
80
  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);
81
+ if (typeof t == "string" && !nt(t))
82
+ a.update(() => {
83
+ const i = _(), d = R();
84
+ d.append($(t.trim())), i.append(d);
55
85
  });
56
86
  else {
57
- const t = o.parseEditorState(e, () => {
58
- r = K({
59
- editor: o,
60
- maxLines: n == null ? void 0 : n.maxLines
87
+ const i = a.parseEditorState(t, () => {
88
+ n = le({
89
+ editor: a,
90
+ maxLines: e == null ? void 0 : e.maxLines
61
91
  });
62
92
  });
63
- t.isEmpty() || o.setEditorState(t);
93
+ i.isEmpty() || a.setEditorState(i);
64
94
  }
65
- } catch (t) {
66
- console.error(t);
95
+ } catch (i) {
96
+ console.error(i);
67
97
  }
68
98
  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({
99
+ return a.update(() => {
100
+ s = ct(a);
101
+ }), { html: s, trimCount: n };
102
+ }, Cr = [
103
+ xt,
104
+ Et,
105
+ V,
106
+ Tt,
107
+ Ct,
108
+ bt,
109
+ Ot,
110
+ _t,
111
+ Rt
112
+ ], ue = w({
83
113
  fontWeight: "bold"
84
- }), Y = d({
114
+ }), pe = w({
85
115
  fontStyle: "italic"
86
- }), Z = d({
116
+ }), ge = w({
87
117
  textDecoration: "underline"
88
- }), _ = d({
118
+ }), fe = w({
89
119
  listStyleType: "none"
90
- }), ee = d({
120
+ }), me = w({
91
121
  borderLeft: "4px solid #ccc",
92
122
  color: "#666",
93
123
  fontStyle: "italic",
94
124
  margin: "1.5em 10px",
95
125
  padding: "0.5em 10px"
96
- }), te = {
97
- quote: ee().className,
126
+ }), ke = {
127
+ quote: me().className,
98
128
  text: {
99
- bold: X().className,
100
- italic: Y().className,
101
- underline: Z().className
129
+ bold: ue().className,
130
+ italic: pe().className,
131
+ underline: ge().className
102
132
  },
103
133
  list: {
104
134
  nested: {
105
- listitem: _().className
135
+ listitem: fe().className
106
136
  }
107
137
  }
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();
138
+ }, at = zt({ hasFocus: !1, editorRef: { current: null } }), Me = ({ onBlur: t }) => {
139
+ const [r, e] = v(!1), n = Z(null), a = M(() => {
140
+ e(!0), n.current && window.clearTimeout(n.current);
141
+ }, []), s = M(() => {
142
+ n.current = window.setTimeout(() => {
143
+ e(!1), t == null || t();
114
144
  }, 0);
115
- }, [e]);
145
+ }, [t]);
116
146
  return {
117
- hasFocus: i,
147
+ hasFocus: r,
118
148
  attributes: {
119
- onFocus: o,
149
+ onFocus: a,
120
150
  onBlur: s
121
151
  }
122
152
  };
123
- }, $e = () => A(g), re = V("div", {
153
+ }, ve = () => Bt(at);
154
+ function Ce(t) {
155
+ return h({ 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);
156
+ }
157
+ function be(t) {
158
+ return h({ 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);
159
+ }
160
+ function Te(t) {
161
+ return h({ 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);
162
+ }
163
+ function Le(t) {
164
+ return h({ 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);
165
+ }
166
+ function Ne(t) {
167
+ return h({ 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);
168
+ }
169
+ function ye(t) {
170
+ return h({ 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);
171
+ }
172
+ function xe(t) {
173
+ return h({ 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);
174
+ }
175
+ function Ee(t) {
176
+ return h({ 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);
177
+ }
178
+ function Se(t) {
179
+ return h({ 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);
180
+ }
181
+ function we(t) {
182
+ return h({ 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);
183
+ }
184
+ function Ie(t) {
185
+ return h({ 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);
186
+ }
187
+ function Oe(t) {
188
+ return h({ 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);
189
+ }
190
+ function _e(t) {
191
+ return h({ 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);
192
+ }
193
+ function Re(t) {
194
+ return h({ 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);
195
+ }
196
+ function ze(t) {
197
+ return h({ 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);
198
+ }
199
+ function Be(t) {
200
+ return h({ 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);
201
+ }
202
+ const De = et("div", {
203
+ width: "10rem",
204
+ display: "flex"
205
+ }), it = {
206
+ bullet: "Punktliste",
207
+ h1: "Overskrift 1",
208
+ h2: "Overskrift 2",
209
+ h3: "Overskrift 3",
210
+ h4: "Overskrift 4",
211
+ h5: "Overskrift 5",
212
+ h6: "Overskrift 6",
213
+ number: "Nummerert liste",
214
+ paragraph: "Normal",
215
+ quote: "Sitat",
216
+ check: "Avkrysningsliste"
217
+ }, He = {
218
+ bullet: /* @__PURE__ */ o(_e, { size: "1.25rem" }),
219
+ h1: /* @__PURE__ */ o(Te, { size: "1.25rem" }),
220
+ h2: /* @__PURE__ */ o(Le, { size: "1.25rem" }),
221
+ h3: /* @__PURE__ */ o(Ne, { size: "1.25rem" }),
222
+ h4: /* @__PURE__ */ o(ye, { size: "1.25rem" }),
223
+ h5: /* @__PURE__ */ o(xe, { size: "1.25rem" }),
224
+ h6: /* @__PURE__ */ o(Ee, { size: "1.25rem" }),
225
+ number: /* @__PURE__ */ o(Oe, { size: "1.25rem" }),
226
+ check: /* @__PURE__ */ o(Ie, { size: "1.25rem" }),
227
+ paragraph: /* @__PURE__ */ o(we, { size: "1.25rem" }),
228
+ quote: /* @__PURE__ */ o(Re, { size: "1.25rem" })
229
+ }, f = ({
230
+ blockType: t
231
+ }) => /* @__PURE__ */ C(j, { children: [
232
+ /* @__PURE__ */ o(O, { css: { display: "flex", flex: "0 0 auto" }, children: He[t] }),
233
+ /* @__PURE__ */ o(
234
+ O,
235
+ {
236
+ css: {
237
+ flex: "1 1 auto",
238
+ overflow: "hidden",
239
+ textOverflow: "ellipsis",
240
+ whiteSpace: "nowrap"
241
+ },
242
+ children: it[t]
243
+ }
244
+ )
245
+ ] }), Fe = (t) => {
246
+ if (!N(t))
247
+ return null;
248
+ const r = t.anchor.getNode();
249
+ let e = r.getKey() === "root" ? r : rt(r, (n) => {
250
+ const a = n.getParent();
251
+ return a !== null && ut(a);
252
+ });
253
+ return e === null && (e = r.getTopLevelElementOrThrow()), {
254
+ anchorNode: r,
255
+ element: e
256
+ };
257
+ }, Pe = () => {
258
+ const [t] = B(), [r, e] = v("paragraph");
259
+ z(() => t.registerCommand(
260
+ Q,
261
+ () => {
262
+ const l = L(), g = Fe(l);
263
+ if (!g)
264
+ return !1;
265
+ const { element: c, anchorNode: x } = g, b = c.getKey();
266
+ if (t.getElementByKey(b) !== null)
267
+ if (W(c)) {
268
+ const k = re(
269
+ x,
270
+ V
271
+ ), D = k ? k.getListType() : c.getListType();
272
+ e(D);
273
+ } else {
274
+ const k = St(c) ? c.getTag() : c.getType();
275
+ k in it && e(k);
276
+ }
277
+ return !1;
278
+ },
279
+ X
280
+ ), [t]);
281
+ const n = (l) => {
282
+ r !== l && t.update(() => {
283
+ const g = L();
284
+ (N(g) || H(g)) && (F(g, () => wt(l)), e(l));
285
+ });
286
+ };
287
+ return /* @__PURE__ */ o(De, { children: /* @__PURE__ */ C(
288
+ Ht,
289
+ {
290
+ trigger: /* @__PURE__ */ o(
291
+ Ft,
292
+ {
293
+ dropdown: !0,
294
+ css: { display: "flex", width: "100%", overflow: "hidden" },
295
+ children: /* @__PURE__ */ o(f, { blockType: r })
296
+ }
297
+ ),
298
+ side: "bottom",
299
+ align: "start",
300
+ children: [
301
+ /* @__PURE__ */ o(m, { onClick: () => {
302
+ r !== "paragraph" && t.update(() => {
303
+ const l = L();
304
+ (N(l) || H(l)) && (F(l, () => R()), e("paragraph"));
305
+ });
306
+ }, children: /* @__PURE__ */ o(f, { blockType: "paragraph" }) }),
307
+ /* @__PURE__ */ o(m, { onClick: () => n("h1"), children: /* @__PURE__ */ o(f, { blockType: "h1" }) }),
308
+ /* @__PURE__ */ o(m, { onClick: () => n("h2"), children: /* @__PURE__ */ o(f, { blockType: "h2" }) }),
309
+ /* @__PURE__ */ o(m, { onClick: () => n("h3"), children: /* @__PURE__ */ o(f, { blockType: "h3" }) }),
310
+ /* @__PURE__ */ o(m, { onClick: () => n("h4"), children: /* @__PURE__ */ o(f, { blockType: "h4" }) }),
311
+ /* @__PURE__ */ o(m, { onClick: () => n("h5"), children: /* @__PURE__ */ o(f, { blockType: "h5" }) }),
312
+ /* @__PURE__ */ o(m, { onClick: () => n("h6"), children: /* @__PURE__ */ o(f, { blockType: "h6" }) }),
313
+ /* @__PURE__ */ o(m, { onClick: () => {
314
+ r !== "bullet" && (t.dispatchCommand(Lt, void 0), e("bullet"));
315
+ }, children: /* @__PURE__ */ o(f, { blockType: "bullet" }) }),
316
+ /* @__PURE__ */ o(m, { onClick: () => {
317
+ r !== "number" && (t.dispatchCommand(Nt, void 0), e("number"));
318
+ }, children: /* @__PURE__ */ o(f, { blockType: "number" }) }),
319
+ /* @__PURE__ */ o(m, { onClick: () => {
320
+ r !== "check" && (t.dispatchCommand(J, void 0), e("check"));
321
+ }, children: /* @__PURE__ */ o(f, { blockType: "check" }) }),
322
+ /* @__PURE__ */ o(m, { onClick: () => {
323
+ r !== "quote" && t.update(() => {
324
+ const l = L();
325
+ (N(l) || H(l)) && (F(l, () => It()), e("quote"));
326
+ });
327
+ }, children: /* @__PURE__ */ o(f, { blockType: "quote" }) })
328
+ ]
329
+ }
330
+ ) });
331
+ }, $e = () => {
332
+ const [t] = B(), [r, e] = v(!1), [n, a] = v(!1), [s, i] = v(!1), [d, p] = v(!1), [l, g] = v(!1), c = M(() => {
333
+ const u = L();
334
+ N(u) && (e(u.hasFormat("bold")), a(u.hasFormat("italic")), i(u.hasFormat("underline")), p(u.hasFormat("code")), g(u.hasFormat("superscript")));
335
+ }, []);
336
+ z(() => ot(
337
+ t.registerCommand(
338
+ Q,
339
+ () => (c(), !1),
340
+ X
341
+ ),
342
+ t.registerUpdateListener(({ editorState: u }) => {
343
+ u.read(() => {
344
+ c();
345
+ });
346
+ })
347
+ ), [t, c]);
348
+ const x = M(
349
+ () => t.dispatchCommand(E, "bold"),
350
+ [t]
351
+ ), b = M(
352
+ () => t.dispatchCommand(E, "italic"),
353
+ [t]
354
+ ), I = M(
355
+ () => t.dispatchCommand(E, "underline"),
356
+ [t]
357
+ ), k = M(
358
+ () => t.dispatchCommand(E, "code"),
359
+ [t]
360
+ ), D = M(
361
+ () => t.dispatchCommand(E, "superscript"),
362
+ [t]
363
+ ), lt = tt(() => {
364
+ const u = [];
365
+ return r && u.push("bold"), n && u.push("italic"), s && u.push("underline"), d && u.push("code"), l && u.push("superscript"), u;
366
+ }, [r, n, s, d, l]);
367
+ return /* @__PURE__ */ C(
368
+ Pt,
369
+ {
370
+ type: "multiple",
371
+ "aria-label": "Tekstformattering",
372
+ value: lt,
373
+ children: [
374
+ /* @__PURE__ */ o(
375
+ S,
376
+ {
377
+ onClick: x,
378
+ title: "Fet tekst",
379
+ value: "bold",
380
+ children: /* @__PURE__ */ o(Ce, { size: "1.25rem" })
381
+ }
382
+ ),
383
+ /* @__PURE__ */ o(
384
+ S,
385
+ {
386
+ onClick: b,
387
+ title: "Kursiv tekst",
388
+ value: "italic",
389
+ children: /* @__PURE__ */ o(Se, { size: "1.25rem" })
390
+ }
391
+ ),
392
+ /* @__PURE__ */ o(
393
+ S,
394
+ {
395
+ onClick: I,
396
+ title: "Understreket tekst",
397
+ value: "underline",
398
+ children: /* @__PURE__ */ o(Be, { size: "1.25rem" })
399
+ }
400
+ ),
401
+ /* @__PURE__ */ o(
402
+ S,
403
+ {
404
+ onClick: k,
405
+ title: "Kode",
406
+ value: "code",
407
+ children: /* @__PURE__ */ o(be, { size: "1.25rem" })
408
+ }
409
+ ),
410
+ /* @__PURE__ */ o(
411
+ S,
412
+ {
413
+ onClick: D,
414
+ title: "Superscript",
415
+ value: "superscript",
416
+ children: /* @__PURE__ */ o(ze, { size: "1.25rem" })
417
+ }
418
+ )
419
+ ]
420
+ }
421
+ );
422
+ }, Ae = ({ children: t }) => {
423
+ const { hasFocus: r, editorRef: e } = ve(), n = r, [a, s] = v(n);
424
+ Dt(() => {
425
+ s(n);
426
+ }, [n]);
427
+ const { context: i, refs: d, floatingStyles: p } = $t({
428
+ placement: "top",
429
+ whileElementsMounted: At,
430
+ middleware: [
431
+ Wt({
432
+ apply: ({ rects: g, elements: c }) => {
433
+ c.floating.style.minWidth = `${g.reference.width}px`;
434
+ }
435
+ }),
436
+ jt(),
437
+ Kt({
438
+ mainAxis: 8
439
+ }),
440
+ Ut({
441
+ padding: 8
442
+ })
443
+ ],
444
+ open: a,
445
+ onOpenChange: s,
446
+ elements: {
447
+ reference: e.current
448
+ }
449
+ }), { getFloatingProps: l } = Yt([
450
+ qt(i, {
451
+ role: "dialog"
452
+ })
453
+ ]);
454
+ return a ? /* @__PURE__ */ o(Gt, { children: /* @__PURE__ */ o(
455
+ Qt,
456
+ {
457
+ ref: d.setFloating,
458
+ style: p,
459
+ ...l,
460
+ css: {
461
+ border: "1px solid $border",
462
+ borderRadius: "$md",
463
+ overflow: "hidden",
464
+ boxShadow: "$md"
465
+ },
466
+ children: /* @__PURE__ */ C(Xt, { "aria-label": "Formattering", children: [
467
+ /* @__PURE__ */ o(Pe, {}),
468
+ /* @__PURE__ */ o(Vt, {}),
469
+ /* @__PURE__ */ o($e, {}),
470
+ t
471
+ ] })
472
+ }
473
+ ) }) : null;
474
+ };
475
+ function We() {
476
+ const [t] = B();
477
+ return z(() => ot(
478
+ t.registerCommand(
479
+ J,
480
+ () => (yt(t, "check"), !0),
481
+ T
482
+ ),
483
+ t.registerCommand(
484
+ pt,
485
+ (r) => q(r, t, !1),
486
+ T
487
+ ),
488
+ t.registerCommand(
489
+ gt,
490
+ (r) => q(r, t, !0),
491
+ T
492
+ ),
493
+ t.registerCommand(
494
+ ft,
495
+ (r) => {
496
+ if (P() != null) {
497
+ const n = t.getRootElement();
498
+ return n != null && n.focus(), !0;
499
+ }
500
+ return !1;
501
+ },
502
+ T
503
+ ),
504
+ t.registerCommand(
505
+ mt,
506
+ (r) => {
507
+ const e = P();
508
+ return e != null && t.isEditable() ? (t.update(() => {
509
+ const n = A(e);
510
+ y(n) && (r.preventDefault(), n.toggleChecked());
511
+ }), !0) : !1;
512
+ },
513
+ T
514
+ ),
515
+ t.registerCommand(
516
+ kt,
517
+ (r) => t.getEditorState().read(() => {
518
+ const e = L();
519
+ if (N(e) && e.isCollapsed()) {
520
+ const { anchor: n } = e, a = n.type === "element";
521
+ if (a || n.offset === 0) {
522
+ const s = n.getNode(), i = rt(
523
+ s,
524
+ (d) => Mt(d) && !d.isInline()
525
+ );
526
+ if (y(i)) {
527
+ const d = i.getParent();
528
+ if (W(d) && d.getListType() === "check" && (a || i.getFirstDescendant() === s)) {
529
+ const p = t.getElementByKey(i.__key);
530
+ if (p != null && document.activeElement !== p)
531
+ return p.focus(), r.preventDefault(), !0;
532
+ }
533
+ }
534
+ }
535
+ }
536
+ return !1;
537
+ }),
538
+ T
539
+ ),
540
+ t.registerRootListener((r, e) => {
541
+ r !== null && (r.addEventListener("click", U), r.addEventListener("pointerdown", Y)), e !== null && (e.removeEventListener("click", U), e.removeEventListener("pointerdown", Y));
542
+ })
543
+ ), [t]), null;
544
+ }
545
+ function st(t, r) {
546
+ const e = t.target;
547
+ if (e === null || !K(e))
548
+ return;
549
+ const n = e.firstChild;
550
+ if (n != null && K(n) && (n.tagName === "UL" || n.tagName === "OL"))
551
+ return;
552
+ const a = e.parentNode;
553
+ if (!a || a.__lexicalListType !== "check")
554
+ return;
555
+ const s = t.pageX, i = e.getBoundingClientRect();
556
+ (e.dir === "rtl" ? s < i.right && s > i.right - 20 : s > i.left && s < i.left + 20) && r();
557
+ }
558
+ function U(t) {
559
+ st(t, () => {
560
+ const r = t.target, e = je(r);
561
+ e != null && e.isEditable() && e.update(() => {
562
+ if (t.target) {
563
+ const n = A(r);
564
+ y(n) && (r.focus(), n.toggleChecked());
565
+ }
566
+ });
567
+ });
568
+ }
569
+ function Y(t) {
570
+ st(t, () => {
571
+ t.preventDefault();
572
+ });
573
+ }
574
+ function je(t) {
575
+ let r = t;
576
+ for (; r; ) {
577
+ if (r.__lexicalEditor)
578
+ return r.__lexicalEditor;
579
+ r = r.parentNode;
580
+ }
581
+ return null;
582
+ }
583
+ function P() {
584
+ const t = document.activeElement;
585
+ return t != null && t.tagName === "LI" && t.parentNode != null && // @ts-ignore internal field
586
+ t.parentNode.__lexicalListType === "check" ? t : null;
587
+ }
588
+ function Ke(t, r) {
589
+ let e = r ? t.getPreviousSibling() : t.getNextSibling(), n = t;
590
+ for (; e == null && y(n); )
591
+ n = n.getParentOrThrow().getParent(), n != null && (e = r ? n.getPreviousSibling() : n.getNextSibling());
592
+ for (; y(e); ) {
593
+ const a = r ? e.getLastChild() : e.getFirstChild();
594
+ if (!W(a))
595
+ return e;
596
+ e = r ? a.getLastChild() : a.getFirstChild();
597
+ }
598
+ return null;
599
+ }
600
+ function q(t, r, e) {
601
+ const n = P();
602
+ return n != null && r.update(() => {
603
+ const a = A(n);
604
+ if (!y(a))
605
+ return;
606
+ const s = Ke(a, e);
607
+ if (s != null) {
608
+ s.selectStart();
609
+ const i = r.getElementByKey(s.__key);
610
+ i != null && (t.preventDefault(), setTimeout(() => {
611
+ i.focus();
612
+ }, 0));
613
+ }
614
+ }), !1;
615
+ }
616
+ const Ue = () => /* @__PURE__ */ C(j, { children: [
617
+ /* @__PURE__ */ o(oe, {}),
618
+ /* @__PURE__ */ o(ae, {}),
619
+ /* @__PURE__ */ o(ne, {}),
620
+ /* @__PURE__ */ o(We, {}),
621
+ /* @__PURE__ */ o(ie, {})
622
+ ] }), Ye = ({
623
+ state: t
624
+ }) => {
625
+ const [r] = B();
626
+ return z(() => {
627
+ if (t)
628
+ try {
629
+ if (de(t)) {
630
+ t.isEmpty() ? ce(r) : r.setEditorState(t);
631
+ return;
632
+ }
633
+ if (typeof t == "string" && !nt(t)) {
634
+ he(t, r);
635
+ return;
636
+ }
637
+ const e = r.parseEditorState(t);
638
+ e.isEmpty() || r.setEditorState(e);
639
+ } catch (e) {
640
+ console.error("Could not parse"), console.error(e);
641
+ }
642
+ }, []), null;
643
+ }, qe = et("div", {
124
644
  border: "1px solid $borderDarker",
125
645
  borderRadius: "$md",
126
646
  position: "relative",
127
647
  backgroundColor: "white",
648
+ padding: "$4",
649
+ overflowY: "auto",
650
+ "&>div:focus-visible": {
651
+ outline: "none"
652
+ },
128
653
  "&:hover": {
129
654
  borderColor: "$gray200"
130
655
  },
@@ -150,59 +675,62 @@ const G = ({
150
675
  }
151
676
  }
152
677
  ]
153
- }), ne = ({
154
- isLoading: e
155
- }) => /* @__PURE__ */ a(
156
- x,
678
+ }), Ge = ({
679
+ isLoading: t
680
+ }) => /* @__PURE__ */ o(
681
+ O,
157
682
  {
158
683
  css: {
159
- visibility: e ? "visible" : "hidden",
684
+ visibility: t ? "visible" : "hidden",
160
685
  position: "absolute",
161
686
  bottom: "1rem",
162
687
  right: "1rem",
163
688
  display: "flex"
164
689
  },
165
- children: /* @__PURE__ */ a(W, {})
690
+ children: /* @__PURE__ */ o(Jt, {})
166
691
  }
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
692
+ ), br = ({
693
+ isLoading: t,
694
+ children: r,
695
+ placeholderText: e,
696
+ nodes: n,
697
+ plugins: a,
698
+ toolbarContent: s,
699
+ content: i,
700
+ hideBorder: d,
701
+ onBlur: p,
702
+ defaultState: l,
703
+ css: g
177
704
  }) => {
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,
705
+ const { hasFocus: c, attributes: x } = Me({ onBlur: p }), b = Z(null), I = tt(() => ({ hasFocus: c, editorRef: b }), [c]);
706
+ return /* @__PURE__ */ o(at.Provider, { value: I, children: /* @__PURE__ */ C(
707
+ Zt,
181
708
  {
182
709
  initialConfig: {
183
710
  namespace: "CommentEditor",
184
- onError: (T) => {
185
- console.error(T);
711
+ onError: (k) => {
712
+ console.error(k);
186
713
  },
187
- theme: te,
188
- nodes: r,
714
+ theme: ke,
715
+ nodes: n,
189
716
  editable: !0
190
717
  },
191
718
  children: [
192
- /* @__PURE__ */ h(
193
- re,
719
+ /* @__PURE__ */ C(
720
+ qe,
194
721
  {
195
- ref: u,
722
+ ref: b,
196
723
  hasFocus: c,
197
- hideBorder: l,
198
- ...C,
724
+ hideBorder: d,
725
+ css: g,
726
+ ...x,
199
727
  children: [
200
- /* @__PURE__ */ a(
201
- O,
728
+ /* @__PURE__ */ o(
729
+ te,
202
730
  {
203
- contentEditable: t,
204
- placeholder: n ? /* @__PURE__ */ a(
205
- x,
731
+ contentEditable: i,
732
+ placeholder: e ? /* @__PURE__ */ o(
733
+ O,
206
734
  {
207
735
  css: {
208
736
  position: "absolute",
@@ -212,29 +740,34 @@ const G = ({
212
740
  pointerEvents: "none",
213
741
  fontSize: "$sm"
214
742
  },
215
- children: n
743
+ children: e
216
744
  }
217
745
  ) : null,
218
- ErrorBoundary: Q
746
+ ErrorBoundary: ee
219
747
  }
220
748
  ),
221
- o,
222
- /* @__PURE__ */ a(ne, { isLoading: e }),
223
- s
749
+ /* @__PURE__ */ o(Ue, {}),
750
+ a,
751
+ /* @__PURE__ */ o(Ge, { isLoading: t }),
752
+ /* @__PURE__ */ o(Ae, { children: s })
224
753
  ]
225
754
  }
226
755
  ),
227
- /* @__PURE__ */ a(j, { children: i })
756
+ /* @__PURE__ */ o(Ye, { state: l }),
757
+ /* @__PURE__ */ o(j, { children: r })
228
758
  ]
229
759
  }
230
760
  ) });
231
761
  };
232
762
  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
763
+ br as RichTextEditor,
764
+ ce as clearEditorState,
765
+ Cr as defaultNodes,
766
+ de as isEditorState,
767
+ nt as isJSON,
768
+ at as richTextContext,
769
+ he as setStateFromPlainText,
770
+ vr as stateToHTML,
771
+ Me as useHasFocusWithin,
772
+ ve as useRichTextContext
240
773
  };