@arkitektbedriftene/fe-lib 0.3.18 → 0.3.20

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,180 +1,208 @@
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";
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-7a3b57bd.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";
18
22
  import "react-dom";
19
23
  import "@radix-ui/react-toolbar";
20
24
  import "@radix-ui/react-dropdown-menu";
21
- const jt = ({
25
+ const se = ({
22
26
  text: t,
23
- maxChars: a,
24
- maxLines: r
27
+ maxChars: r,
28
+ maxLines: e
25
29
  }) => {
26
30
  if (t.length === 0)
27
31
  return 0;
28
- const o = typeof r == "number", i = typeof a == "number";
29
- if (!o && !i)
32
+ const n = typeof e == "number", a = typeof r == "number";
33
+ if (!n && !a)
30
34
  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 = ({
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 = ({
37
41
  editor: t,
38
- maxChars: a,
39
- maxLines: r
42
+ maxChars: r,
43
+ maxLines: e
40
44
  }) => {
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,
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,
49
77
  editable: !1
50
78
  });
51
79
  if (t)
52
80
  try {
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);
81
+ if (typeof t == "string" && !nt(t))
82
+ a.update(() => {
83
+ const i = _(), d = R();
84
+ d.append($(t.trim())), i.append(d);
57
85
  });
58
86
  else {
59
- const s = i.parseEditorState(t, () => {
60
- o = Wt({
61
- editor: i,
62
- maxLines: r == null ? void 0 : r.maxLines
87
+ const i = a.parseEditorState(t, () => {
88
+ n = le({
89
+ editor: a,
90
+ maxLines: e == null ? void 0 : e.maxLines
63
91
  });
64
92
  });
65
- s.isEmpty() || i.setEditorState(s);
93
+ i.isEmpty() || a.setEditorState(i);
66
94
  }
67
- } catch (s) {
68
- console.error(s);
95
+ } catch (i) {
96
+ console.error(i);
69
97
  }
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({
98
+ let s = "";
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({
85
113
  fontWeight: "bold"
86
- }), Pt = w({
114
+ }), pe = w({
87
115
  fontStyle: "italic"
88
- }), Ut = w({
116
+ }), ge = w({
89
117
  textDecoration: "underline"
90
- }), qt = w({
118
+ }), fe = w({
91
119
  listStyleType: "none"
92
- }), Kt = w({
120
+ }), me = w({
93
121
  borderLeft: "4px solid #ccc",
94
122
  color: "#666",
95
123
  fontStyle: "italic",
96
124
  margin: "1.5em 10px",
97
125
  padding: "0.5em 10px"
98
- }), Gt = {
99
- quote: Kt().className,
126
+ }), ke = {
127
+ quote: me().className,
100
128
  text: {
101
- bold: At().className,
102
- italic: Pt().className,
103
- underline: Ut().className
129
+ bold: ue().className,
130
+ italic: pe().className,
131
+ underline: ge().className
104
132
  },
105
133
  list: {
106
134
  nested: {
107
- listitem: qt().className
135
+ listitem: fe().className
108
136
  }
109
137
  }
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();
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();
116
144
  }, 0);
117
145
  }, [t]);
118
146
  return {
119
- hasFocus: a,
147
+ hasFocus: r,
120
148
  attributes: {
121
- onFocus: i,
122
- onBlur: l
149
+ onFocus: a,
150
+ onBlur: s
123
151
  }
124
152
  };
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);
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);
128
156
  }
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);
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);
131
159
  }
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);
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);
134
162
  }
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);
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);
137
165
  }
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);
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);
140
168
  }
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);
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);
143
171
  }
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);
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);
146
174
  }
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);
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);
149
177
  }
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);
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);
152
180
  }
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);
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);
155
183
  }
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);
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);
158
186
  }
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);
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);
161
189
  }
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);
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);
164
192
  }
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);
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);
167
195
  }
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);
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);
170
198
  }
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);
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);
173
201
  }
174
- const pe = A("div", {
202
+ const De = et("div", {
175
203
  width: "10rem",
176
204
  display: "flex"
177
- }), q = {
205
+ }), it = {
178
206
  bullet: "Punktliste",
179
207
  h1: "Overskrift 1",
180
208
  h2: "Overskrift 2",
@@ -186,257 +214,442 @@ const pe = A("div", {
186
214
  paragraph: "Normal",
187
215
  quote: "Sitat",
188
216
  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 = ({
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 = ({
202
230
  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) => {
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) => {
207
246
  if (!N(t))
208
247
  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);
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);
213
252
  });
214
- return r === null && (r = a.getTopLevelElementOrThrow()), {
215
- anchorNode: a,
216
- element: r
253
+ return e === null && (e = r.getTopLevelElementOrThrow()), {
254
+ anchorNode: r,
255
+ element: e
217
256
  };
218
- }, me = () => {
219
- const [t] = P(), [a, r] = M("paragraph");
220
- W(() => t.registerCommand(
221
- $,
257
+ }, Pe = () => {
258
+ const [t] = B(), [r, e] = v("paragraph");
259
+ z(() => t.registerCommand(
260
+ Q,
222
261
  () => {
223
- const n = y(), u = ge(n);
224
- if (!u)
262
+ const l = L(), g = Fe(l);
263
+ if (!g)
225
264
  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);
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);
234
273
  } else {
235
- const v = lt(c) ? c.getTag() : c.getType();
236
- v in q && r(v);
274
+ const k = St(c) ? c.getTag() : c.getType();
275
+ k in it && e(k);
237
276
  }
238
277
  return !1;
239
278
  },
240
- F
279
+ X
241
280
  ), [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));
281
+ const n = (l) => {
282
+ r !== l && t.update(() => {
283
+ const g = L();
284
+ (N(g) || H(g)) && (F(g, () => wt(l)), e(l));
246
285
  });
247
286
  };
248
- return /* @__PURE__ */ e(pe, { children: /* @__PURE__ */ C(
249
- kt,
287
+ return /* @__PURE__ */ o(De, { children: /* @__PURE__ */ C(
288
+ Ht,
250
289
  {
251
- trigger: /* @__PURE__ */ e(
252
- Mt,
290
+ trigger: /* @__PURE__ */ o(
291
+ Ft,
253
292
  {
254
293
  dropdown: !0,
255
294
  css: { display: "flex", width: "100%", overflow: "hidden" },
256
- children: /* @__PURE__ */ e(g, { blockType: a })
295
+ children: /* @__PURE__ */ o(f, { blockType: r })
257
296
  }
258
297
  ),
259
298
  side: "bottom",
260
299
  align: "start",
261
300
  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"));
301
+ /* @__PURE__ */ o(m, { onClick: () => {
302
+ r !== "paragraph" && t.update(() => {
303
+ const l = L();
304
+ (N(l) || H(l)) && (F(l, () => R()), e("paragraph"));
266
305
  });
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"));
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"));
287
326
  });
288
- }, children: /* @__PURE__ */ e(g, { blockType: "quote" }) })
327
+ }, children: /* @__PURE__ */ o(f, { blockType: "quote" }) })
289
328
  ]
290
329
  }
291
330
  ) });
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")));
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")));
296
335
  }, []);
297
- W(() => Dt(
336
+ z(() => ot(
298
337
  t.registerCommand(
299
- $,
338
+ Q,
300
339
  () => (c(), !1),
301
- F
340
+ X
302
341
  ),
303
- t.registerUpdateListener(({ editorState: h }) => {
304
- h.read(() => {
342
+ t.registerUpdateListener(({ editorState: u }) => {
343
+ u.read(() => {
305
344
  c();
306
345
  });
307
346
  })
308
347
  ), [t, c]);
309
- const b = k(
310
- () => t.dispatchCommand(L, "bold"),
348
+ const x = M(
349
+ () => t.dispatchCommand(E, "bold"),
311
350
  [t]
312
- ), T = k(
313
- () => t.dispatchCommand(L, "italic"),
351
+ ), b = M(
352
+ () => t.dispatchCommand(E, "italic"),
314
353
  [t]
315
- ), B = k(
316
- () => t.dispatchCommand(L, "underline"),
354
+ ), I = M(
355
+ () => t.dispatchCommand(E, "underline"),
317
356
  [t]
318
- ), v = k(
319
- () => t.dispatchCommand(L, "code"),
357
+ ), k = M(
358
+ () => t.dispatchCommand(E, "code"),
320
359
  [t]
321
- ), z = k(
322
- () => t.dispatchCommand(L, "superscript"),
360
+ ), D = M(
361
+ () => t.dispatchCommand(E, "superscript"),
323
362
  [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]);
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]);
328
367
  return /* @__PURE__ */ C(
329
- vt,
368
+ Pt,
330
369
  {
331
370
  type: "multiple",
332
371
  "aria-label": "Tekstformattering",
333
- value: K,
372
+ value: lt,
334
373
  children: [
335
- /* @__PURE__ */ e(
336
- x,
374
+ /* @__PURE__ */ o(
375
+ S,
337
376
  {
338
- onClick: b,
377
+ onClick: x,
339
378
  title: "Fet tekst",
340
379
  value: "bold",
341
- children: /* @__PURE__ */ e(Jt, { size: "1.25rem" })
380
+ children: /* @__PURE__ */ o(Ce, { size: "1.25rem" })
342
381
  }
343
382
  ),
344
- /* @__PURE__ */ e(
345
- x,
383
+ /* @__PURE__ */ o(
384
+ S,
346
385
  {
347
- onClick: T,
386
+ onClick: b,
348
387
  title: "Kursiv tekst",
349
388
  value: "italic",
350
- children: /* @__PURE__ */ e(ae, { size: "1.25rem" })
389
+ children: /* @__PURE__ */ o(Se, { size: "1.25rem" })
351
390
  }
352
391
  ),
353
- /* @__PURE__ */ e(
354
- x,
392
+ /* @__PURE__ */ o(
393
+ S,
355
394
  {
356
- onClick: B,
395
+ onClick: I,
357
396
  title: "Understreket tekst",
358
397
  value: "underline",
359
- children: /* @__PURE__ */ e(he, { size: "1.25rem" })
398
+ children: /* @__PURE__ */ o(Be, { size: "1.25rem" })
360
399
  }
361
400
  ),
362
- /* @__PURE__ */ e(
363
- x,
401
+ /* @__PURE__ */ o(
402
+ S,
364
403
  {
365
- onClick: v,
404
+ onClick: k,
366
405
  title: "Kode",
367
406
  value: "code",
368
- children: /* @__PURE__ */ e(Xt, { size: "1.25rem" })
407
+ children: /* @__PURE__ */ o(be, { size: "1.25rem" })
369
408
  }
370
409
  ),
371
- /* @__PURE__ */ e(
372
- x,
410
+ /* @__PURE__ */ o(
411
+ S,
373
412
  {
374
- onClick: z,
413
+ onClick: D,
375
414
  title: "Superscript",
376
415
  value: "superscript",
377
- children: /* @__PURE__ */ e(ce, { size: "1.25rem" })
416
+ children: /* @__PURE__ */ o(ze, { size: "1.25rem" })
378
417
  }
379
418
  )
380
419
  ]
381
420
  }
382
421
  );
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({
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({
389
428
  placement: "top",
390
- whileElementsMounted: bt,
429
+ whileElementsMounted: At,
391
430
  middleware: [
392
- Tt({
393
- apply: ({ rects: u, elements: c }) => {
394
- c.floating.style.minWidth = `${u.reference.width}px`;
431
+ Wt({
432
+ apply: ({ rects: g, elements: c }) => {
433
+ c.floating.style.minWidth = `${g.reference.width}px`;
395
434
  }
396
435
  }),
397
- Lt(),
398
- xt({
436
+ jt(),
437
+ Kt({
399
438
  mainAxis: 8
400
439
  }),
401
- yt({
440
+ Ut({
402
441
  padding: 8
403
442
  })
404
443
  ],
405
- open: i,
406
- onOpenChange: l,
444
+ open: a,
445
+ onOpenChange: s,
407
446
  elements: {
408
- reference: r.current
447
+ reference: e.current
409
448
  }
410
- }), { getFloatingProps: n } = Nt([
411
- wt(s, {
449
+ }), { getFloatingProps: l } = Yt([
450
+ qt(i, {
412
451
  role: "dialog"
413
452
  })
414
453
  ]);
415
- return i ? /* @__PURE__ */ e(St, { children: /* @__PURE__ */ e(
416
- zt,
454
+ return a ? /* @__PURE__ */ o(Gt, { children: /* @__PURE__ */ o(
455
+ Qt,
417
456
  {
418
- ref: p.setFloating,
419
- style: f,
420
- ...n,
457
+ ref: d.setFloating,
458
+ style: p,
459
+ ...l,
421
460
  css: {
422
461
  border: "1px solid $border",
423
462
  borderRadius: "$md",
424
463
  overflow: "hidden",
425
464
  boxShadow: "$md"
426
465
  },
427
- children: /* @__PURE__ */ C(Et, { "aria-label": "Formattering", children: [
428
- /* @__PURE__ */ e(me, {}),
429
- /* @__PURE__ */ e(Ht, {}),
430
- /* @__PURE__ */ e(fe, {}),
466
+ children: /* @__PURE__ */ C(Xt, { "aria-label": "Formattering", children: [
467
+ /* @__PURE__ */ o(Pe, {}),
468
+ /* @__PURE__ */ o(Vt, {}),
469
+ /* @__PURE__ */ o($e, {}),
431
470
  t
432
471
  ] })
433
472
  }
434
473
  ) }) : null;
435
- }, Me = A("div", {
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", {
436
644
  border: "1px solid $borderDarker",
437
645
  borderRadius: "$md",
438
646
  position: "relative",
439
647
  backgroundColor: "white",
648
+ padding: "$4",
649
+ overflowY: "auto",
650
+ "&>div:focus-visible": {
651
+ outline: "none"
652
+ },
440
653
  "&:hover": {
441
654
  borderColor: "$gray200"
442
655
  },
@@ -462,10 +675,10 @@ const pe = A("div", {
462
675
  }
463
676
  }
464
677
  ]
465
- }), ve = ({
678
+ }), Ge = ({
466
679
  isLoading: t
467
- }) => /* @__PURE__ */ e(
468
- S,
680
+ }) => /* @__PURE__ */ o(
681
+ O,
469
682
  {
470
683
  css: {
471
684
  visibility: t ? "visible" : "hidden",
@@ -474,47 +687,50 @@ const pe = A("div", {
474
687
  right: "1rem",
475
688
  display: "flex"
476
689
  },
477
- children: /* @__PURE__ */ e(Bt, {})
690
+ children: /* @__PURE__ */ o(Jt, {})
478
691
  }
479
- ), Ae = ({
692
+ ), br = ({
480
693
  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
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
489
704
  }) => {
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,
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,
493
708
  {
494
709
  initialConfig: {
495
710
  namespace: "CommentEditor",
496
- onError: (T) => {
497
- console.error(T);
711
+ onError: (k) => {
712
+ console.error(k);
498
713
  },
499
- theme: Gt,
500
- nodes: o,
714
+ theme: ke,
715
+ nodes: n,
501
716
  editable: !0
502
717
  },
503
718
  children: [
504
719
  /* @__PURE__ */ C(
505
- Me,
720
+ qe,
506
721
  {
507
- ref: c,
508
- hasFocus: n,
509
- hideBorder: p,
510
- ...u,
722
+ ref: b,
723
+ hasFocus: c,
724
+ hideBorder: d,
725
+ css: g,
726
+ ...x,
511
727
  children: [
512
- /* @__PURE__ */ e(
513
- Rt,
728
+ /* @__PURE__ */ o(
729
+ te,
514
730
  {
515
- contentEditable: s,
516
- placeholder: r ? /* @__PURE__ */ e(
517
- S,
731
+ contentEditable: i,
732
+ placeholder: e ? /* @__PURE__ */ o(
733
+ O,
518
734
  {
519
735
  css: {
520
736
  position: "absolute",
@@ -524,29 +740,34 @@ const pe = A("div", {
524
740
  pointerEvents: "none",
525
741
  fontSize: "$sm"
526
742
  },
527
- children: r
743
+ children: e
528
744
  }
529
745
  ) : null,
530
- ErrorBoundary: $t
746
+ ErrorBoundary: ee
531
747
  }
532
748
  ),
533
- i,
534
- /* @__PURE__ */ e(ve, { isLoading: t }),
535
- /* @__PURE__ */ e(ke, { children: l })
749
+ /* @__PURE__ */ o(Ue, {}),
750
+ a,
751
+ /* @__PURE__ */ o(Ge, { isLoading: t }),
752
+ /* @__PURE__ */ o(Ae, { children: s })
536
753
  ]
537
754
  }
538
755
  ),
539
- /* @__PURE__ */ e(D, { children: a })
756
+ /* @__PURE__ */ o(Ye, { state: l }),
757
+ /* @__PURE__ */ o(j, { children: r })
540
758
  ]
541
759
  }
542
760
  ) });
543
761
  };
544
762
  export {
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
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
552
773
  };