@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.
- package/dist/{DropdownMenu-c57acb78.js → DropdownMenu-cae60146.js} +782 -723
- package/dist/rich-text/Editor.d.ts +2 -2
- package/dist/rich-text/Toolbar/BlockTypeSelector.d.ts +2 -0
- package/dist/rich-text/Toolbar/TextFormatToggleGroup.d.ts +2 -0
- package/dist/rich-text/Toolbar/Toolbar.d.ts +6 -0
- package/dist/rich-text.es.js +445 -133
- package/dist/ui/components/Alert.d.ts +1 -1
- package/dist/ui/components/Badge.d.ts +1 -1
- package/dist/ui/components/Button.d.ts +1 -1
- package/dist/ui/components/Toolbar.d.ts +1 -1
- package/dist/ui.es.js +14 -14
- package/package.json +1 -1
package/dist/rich-text.es.js
CHANGED
|
@@ -1,126 +1,438 @@
|
|
|
1
|
-
import { createHeadlessEditor as
|
|
2
|
-
import { $generateHtmlFromNodes as
|
|
3
|
-
import { $getRoot as
|
|
4
|
-
import { trimTextContentFromAnchor as
|
|
5
|
-
import { AutoLinkNode as
|
|
6
|
-
import { ListNode as
|
|
7
|
-
import { HeadingNode as
|
|
8
|
-
import { TableNode as
|
|
9
|
-
import { jsx as
|
|
10
|
-
import { createContext as
|
|
11
|
-
import { c as
|
|
12
|
-
import { LexicalComposer as
|
|
13
|
-
import { RichTextPlugin as
|
|
14
|
-
import
|
|
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
|
|
20
|
-
text:
|
|
21
|
-
maxChars:
|
|
22
|
-
maxLines:
|
|
21
|
+
const jt = ({
|
|
22
|
+
text: t,
|
|
23
|
+
maxChars: a,
|
|
24
|
+
maxLines: r
|
|
23
25
|
}) => {
|
|
24
|
-
if (
|
|
26
|
+
if (t.length === 0)
|
|
25
27
|
return 0;
|
|
26
|
-
const
|
|
27
|
-
if (!
|
|
28
|
-
return
|
|
29
|
-
let
|
|
30
|
-
for (;
|
|
31
|
-
|
|
32
|
-
` &&
|
|
33
|
-
return
|
|
34
|
-
},
|
|
35
|
-
editor:
|
|
36
|
-
maxChars:
|
|
37
|
-
maxLines:
|
|
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
|
|
40
|
-
|
|
41
|
-
const
|
|
42
|
-
return
|
|
43
|
-
},
|
|
44
|
-
let
|
|
45
|
-
const
|
|
46
|
-
nodes:
|
|
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 (
|
|
51
|
+
if (t)
|
|
50
52
|
try {
|
|
51
|
-
if (typeof
|
|
52
|
-
|
|
53
|
-
const
|
|
54
|
-
|
|
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
|
|
58
|
-
|
|
59
|
-
editor:
|
|
60
|
-
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
|
-
|
|
65
|
+
s.isEmpty() || i.setEditorState(s);
|
|
64
66
|
}
|
|
65
|
-
} catch (
|
|
66
|
-
console.error(
|
|
67
|
+
} catch (s) {
|
|
68
|
+
console.error(s);
|
|
67
69
|
}
|
|
68
|
-
let
|
|
69
|
-
return
|
|
70
|
-
|
|
71
|
-
}), { html:
|
|
72
|
-
},
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
],
|
|
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
|
-
}),
|
|
86
|
+
}), Pt = w({
|
|
85
87
|
fontStyle: "italic"
|
|
86
|
-
}),
|
|
88
|
+
}), Ut = w({
|
|
87
89
|
textDecoration: "underline"
|
|
88
|
-
}),
|
|
90
|
+
}), qt = w({
|
|
89
91
|
listStyleType: "none"
|
|
90
|
-
}),
|
|
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
|
-
}),
|
|
97
|
-
quote:
|
|
98
|
+
}), Gt = {
|
|
99
|
+
quote: Kt().className,
|
|
98
100
|
text: {
|
|
99
|
-
bold:
|
|
100
|
-
italic:
|
|
101
|
-
underline:
|
|
101
|
+
bold: At().className,
|
|
102
|
+
italic: Pt().className,
|
|
103
|
+
underline: Ut().className
|
|
102
104
|
},
|
|
103
105
|
list: {
|
|
104
106
|
nested: {
|
|
105
|
-
listitem:
|
|
107
|
+
listitem: qt().className
|
|
106
108
|
}
|
|
107
109
|
}
|
|
108
|
-
},
|
|
109
|
-
const [
|
|
110
|
-
|
|
111
|
-
}, []),
|
|
112
|
-
|
|
113
|
-
|
|
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
|
-
}, [
|
|
117
|
+
}, [t]);
|
|
116
118
|
return {
|
|
117
|
-
hasFocus:
|
|
119
|
+
hasFocus: a,
|
|
118
120
|
attributes: {
|
|
119
|
-
onFocus:
|
|
120
|
-
onBlur:
|
|
121
|
+
onFocus: i,
|
|
122
|
+
onBlur: l
|
|
121
123
|
}
|
|
122
124
|
};
|
|
123
|
-
},
|
|
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
|
-
}),
|
|
154
|
-
isLoading:
|
|
155
|
-
}) => /* @__PURE__ */
|
|
156
|
-
|
|
465
|
+
}), ve = ({
|
|
466
|
+
isLoading: t
|
|
467
|
+
}) => /* @__PURE__ */ e(
|
|
468
|
+
S,
|
|
157
469
|
{
|
|
158
470
|
css: {
|
|
159
|
-
visibility:
|
|
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__ */
|
|
477
|
+
children: /* @__PURE__ */ e(Bt, {})
|
|
166
478
|
}
|
|
167
|
-
),
|
|
168
|
-
isLoading:
|
|
169
|
-
children:
|
|
170
|
-
placeholderText:
|
|
171
|
-
nodes:
|
|
172
|
-
plugins:
|
|
173
|
-
|
|
174
|
-
content:
|
|
175
|
-
hideBorder:
|
|
176
|
-
onBlur:
|
|
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:
|
|
179
|
-
return /* @__PURE__ */
|
|
180
|
-
|
|
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:
|
|
188
|
-
nodes:
|
|
499
|
+
theme: Gt,
|
|
500
|
+
nodes: o,
|
|
189
501
|
editable: !0
|
|
190
502
|
},
|
|
191
503
|
children: [
|
|
192
|
-
/* @__PURE__ */
|
|
193
|
-
|
|
504
|
+
/* @__PURE__ */ C(
|
|
505
|
+
Me,
|
|
194
506
|
{
|
|
195
|
-
ref:
|
|
196
|
-
hasFocus:
|
|
197
|
-
hideBorder:
|
|
198
|
-
...
|
|
507
|
+
ref: c,
|
|
508
|
+
hasFocus: n,
|
|
509
|
+
hideBorder: p,
|
|
510
|
+
...u,
|
|
199
511
|
children: [
|
|
200
|
-
/* @__PURE__ */
|
|
201
|
-
|
|
512
|
+
/* @__PURE__ */ e(
|
|
513
|
+
Rt,
|
|
202
514
|
{
|
|
203
|
-
contentEditable:
|
|
204
|
-
placeholder:
|
|
205
|
-
|
|
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:
|
|
527
|
+
children: r
|
|
216
528
|
}
|
|
217
529
|
) : null,
|
|
218
|
-
ErrorBoundary:
|
|
530
|
+
ErrorBoundary: $t
|
|
219
531
|
}
|
|
220
532
|
),
|
|
221
|
-
|
|
222
|
-
/* @__PURE__ */
|
|
223
|
-
|
|
533
|
+
i,
|
|
534
|
+
/* @__PURE__ */ e(ve, { isLoading: t }),
|
|
535
|
+
/* @__PURE__ */ e(ke, { children: l })
|
|
224
536
|
]
|
|
225
537
|
}
|
|
226
538
|
),
|
|
227
|
-
/* @__PURE__ */
|
|
539
|
+
/* @__PURE__ */ e(D, { children: a })
|
|
228
540
|
]
|
|
229
541
|
}
|
|
230
542
|
) });
|
|
231
543
|
};
|
|
232
544
|
export {
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
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
|
};
|