@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.
- package/dist/{DropdownMenu-cae60146.js → DropdownMenu-7a3b57bd.js} +155 -130
- package/dist/rich-text/Editor.d.ts +11 -1
- package/dist/rich-text/Plugins/CheckListPlugin.d.ts +10 -0
- package/dist/rich-text/Plugins/ParsePlugin.d.ts +4 -0
- package/dist/rich-text/Plugins/Plugins.d.ts +2 -0
- package/dist/rich-text/state.d.ts +4 -1
- package/dist/rich-text.es.js +530 -309
- package/dist/ui/components/Alert.d.ts +0 -1
- package/dist/ui/components/Badge.d.ts +0 -1
- package/dist/ui/components/Box.d.ts +0 -1
- package/dist/ui/components/Button.d.ts +0 -1
- package/dist/ui/components/Card.d.ts +118 -0
- package/dist/ui/components/Menu/DropdownMenu.d.ts +0 -3
- package/dist/ui/components/Menu/Menu.d.ts +0 -3
- package/dist/ui/components/OverlayCard.d.ts +0 -1
- package/dist/ui/components/Popover.d.ts +0 -1
- package/dist/ui/components/Spinner.d.ts +0 -1
- package/dist/ui/components/Toolbar.d.ts +0 -4
- package/dist/ui/stitches.config.d.ts +0 -6
- package/dist/ui/ui.d.ts +1 -0
- package/dist/ui.es.js +23 -22
- package/package.json +1 -1
package/dist/rich-text.es.js
CHANGED
|
@@ -1,180 +1,208 @@
|
|
|
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 w, s as
|
|
12
|
-
import { LexicalComposer as
|
|
13
|
-
import { RichTextPlugin as
|
|
14
|
-
import
|
|
15
|
-
import { useLexicalComposerContext as
|
|
16
|
-
import { $getNearestNodeOfType as
|
|
17
|
-
import { G as
|
|
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
|
|
25
|
+
const se = ({
|
|
22
26
|
text: t,
|
|
23
|
-
maxChars:
|
|
24
|
-
maxLines:
|
|
27
|
+
maxChars: r,
|
|
28
|
+
maxLines: e
|
|
25
29
|
}) => {
|
|
26
30
|
if (t.length === 0)
|
|
27
31
|
return 0;
|
|
28
|
-
const
|
|
29
|
-
if (!
|
|
32
|
+
const n = typeof e == "number", a = typeof r == "number";
|
|
33
|
+
if (!n && !a)
|
|
30
34
|
return t.length;
|
|
31
|
-
let
|
|
32
|
-
for (;
|
|
33
|
-
t[
|
|
34
|
-
` &&
|
|
35
|
-
return t.slice(0,
|
|
36
|
-
},
|
|
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:
|
|
39
|
-
maxLines:
|
|
42
|
+
maxChars: r,
|
|
43
|
+
maxLines: e
|
|
40
44
|
}) => {
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
const
|
|
44
|
-
return
|
|
45
|
-
},
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
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" && !
|
|
54
|
-
|
|
55
|
-
const
|
|
56
|
-
|
|
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
|
|
60
|
-
|
|
61
|
-
editor:
|
|
62
|
-
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
|
-
|
|
93
|
+
i.isEmpty() || a.setEditorState(i);
|
|
66
94
|
}
|
|
67
|
-
} catch (
|
|
68
|
-
console.error(
|
|
95
|
+
} catch (i) {
|
|
96
|
+
console.error(i);
|
|
69
97
|
}
|
|
70
|
-
let
|
|
71
|
-
return
|
|
72
|
-
|
|
73
|
-
}), { html:
|
|
74
|
-
},
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
],
|
|
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
|
-
}),
|
|
114
|
+
}), pe = w({
|
|
87
115
|
fontStyle: "italic"
|
|
88
|
-
}),
|
|
116
|
+
}), ge = w({
|
|
89
117
|
textDecoration: "underline"
|
|
90
|
-
}),
|
|
118
|
+
}), fe = w({
|
|
91
119
|
listStyleType: "none"
|
|
92
|
-
}),
|
|
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
|
-
}),
|
|
99
|
-
quote:
|
|
126
|
+
}), ke = {
|
|
127
|
+
quote: me().className,
|
|
100
128
|
text: {
|
|
101
|
-
bold:
|
|
102
|
-
italic:
|
|
103
|
-
underline:
|
|
129
|
+
bold: ue().className,
|
|
130
|
+
italic: pe().className,
|
|
131
|
+
underline: ge().className
|
|
104
132
|
},
|
|
105
133
|
list: {
|
|
106
134
|
nested: {
|
|
107
|
-
listitem:
|
|
135
|
+
listitem: fe().className
|
|
108
136
|
}
|
|
109
137
|
}
|
|
110
|
-
},
|
|
111
|
-
const [
|
|
112
|
-
|
|
113
|
-
}, []),
|
|
114
|
-
|
|
115
|
-
|
|
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:
|
|
147
|
+
hasFocus: r,
|
|
120
148
|
attributes: {
|
|
121
|
-
onFocus:
|
|
122
|
-
onBlur:
|
|
149
|
+
onFocus: a,
|
|
150
|
+
onBlur: s
|
|
123
151
|
}
|
|
124
152
|
};
|
|
125
|
-
},
|
|
126
|
-
function
|
|
127
|
-
return
|
|
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
|
|
130
|
-
return
|
|
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
|
|
133
|
-
return
|
|
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
|
|
136
|
-
return
|
|
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
|
|
139
|
-
return
|
|
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
|
|
142
|
-
return
|
|
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
|
|
145
|
-
return
|
|
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
|
|
148
|
-
return
|
|
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
|
|
151
|
-
return
|
|
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
|
|
154
|
-
return
|
|
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
|
|
157
|
-
return
|
|
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
|
|
160
|
-
return
|
|
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
|
|
163
|
-
return
|
|
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
|
|
166
|
-
return
|
|
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
|
|
169
|
-
return
|
|
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
|
|
172
|
-
return
|
|
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
|
|
202
|
+
const De = et("div", {
|
|
175
203
|
width: "10rem",
|
|
176
204
|
display: "flex"
|
|
177
|
-
}),
|
|
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
|
-
},
|
|
190
|
-
bullet: /* @__PURE__ */
|
|
191
|
-
h1: /* @__PURE__ */
|
|
192
|
-
h2: /* @__PURE__ */
|
|
193
|
-
h3: /* @__PURE__ */
|
|
194
|
-
h4: /* @__PURE__ */
|
|
195
|
-
h5: /* @__PURE__ */
|
|
196
|
-
h6: /* @__PURE__ */
|
|
197
|
-
number: /* @__PURE__ */
|
|
198
|
-
check: /* @__PURE__ */
|
|
199
|
-
paragraph: /* @__PURE__ */
|
|
200
|
-
quote: /* @__PURE__ */
|
|
201
|
-
},
|
|
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(
|
|
204
|
-
/* @__PURE__ */
|
|
205
|
-
/* @__PURE__ */
|
|
206
|
-
|
|
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
|
|
210
|
-
let
|
|
211
|
-
const
|
|
212
|
-
return
|
|
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
|
|
215
|
-
anchorNode:
|
|
216
|
-
element:
|
|
253
|
+
return e === null && (e = r.getTopLevelElementOrThrow()), {
|
|
254
|
+
anchorNode: r,
|
|
255
|
+
element: e
|
|
217
256
|
};
|
|
218
|
-
},
|
|
219
|
-
const [t] =
|
|
220
|
-
|
|
221
|
-
|
|
257
|
+
}, Pe = () => {
|
|
258
|
+
const [t] = B(), [r, e] = v("paragraph");
|
|
259
|
+
z(() => t.registerCommand(
|
|
260
|
+
Q,
|
|
222
261
|
() => {
|
|
223
|
-
const
|
|
224
|
-
if (!
|
|
262
|
+
const l = L(), g = Fe(l);
|
|
263
|
+
if (!g)
|
|
225
264
|
return !1;
|
|
226
|
-
const { element: c, anchorNode:
|
|
227
|
-
if (t.getElementByKey(
|
|
228
|
-
if (
|
|
229
|
-
const
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
),
|
|
233
|
-
|
|
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
|
|
236
|
-
|
|
274
|
+
const k = St(c) ? c.getTag() : c.getType();
|
|
275
|
+
k in it && e(k);
|
|
237
276
|
}
|
|
238
277
|
return !1;
|
|
239
278
|
},
|
|
240
|
-
|
|
279
|
+
X
|
|
241
280
|
), [t]);
|
|
242
|
-
const
|
|
243
|
-
|
|
244
|
-
const
|
|
245
|
-
(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__ */
|
|
249
|
-
|
|
287
|
+
return /* @__PURE__ */ o(De, { children: /* @__PURE__ */ C(
|
|
288
|
+
Ht,
|
|
250
289
|
{
|
|
251
|
-
trigger: /* @__PURE__ */
|
|
252
|
-
|
|
290
|
+
trigger: /* @__PURE__ */ o(
|
|
291
|
+
Ft,
|
|
253
292
|
{
|
|
254
293
|
dropdown: !0,
|
|
255
294
|
css: { display: "flex", width: "100%", overflow: "hidden" },
|
|
256
|
-
children: /* @__PURE__ */
|
|
295
|
+
children: /* @__PURE__ */ o(f, { blockType: r })
|
|
257
296
|
}
|
|
258
297
|
),
|
|
259
298
|
side: "bottom",
|
|
260
299
|
align: "start",
|
|
261
300
|
children: [
|
|
262
|
-
/* @__PURE__ */
|
|
263
|
-
|
|
264
|
-
const
|
|
265
|
-
(N(
|
|
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__ */
|
|
268
|
-
/* @__PURE__ */
|
|
269
|
-
/* @__PURE__ */
|
|
270
|
-
/* @__PURE__ */
|
|
271
|
-
/* @__PURE__ */
|
|
272
|
-
/* @__PURE__ */
|
|
273
|
-
/* @__PURE__ */
|
|
274
|
-
/* @__PURE__ */
|
|
275
|
-
|
|
276
|
-
}, children: /* @__PURE__ */
|
|
277
|
-
/* @__PURE__ */
|
|
278
|
-
|
|
279
|
-
}, children: /* @__PURE__ */
|
|
280
|
-
/* @__PURE__ */
|
|
281
|
-
|
|
282
|
-
}, children: /* @__PURE__ */
|
|
283
|
-
/* @__PURE__ */
|
|
284
|
-
|
|
285
|
-
const
|
|
286
|
-
(N(
|
|
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__ */
|
|
327
|
+
}, children: /* @__PURE__ */ o(f, { blockType: "quote" }) })
|
|
289
328
|
]
|
|
290
329
|
}
|
|
291
330
|
) });
|
|
292
|
-
},
|
|
293
|
-
const [t] =
|
|
294
|
-
const
|
|
295
|
-
N(
|
|
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
|
-
|
|
336
|
+
z(() => ot(
|
|
298
337
|
t.registerCommand(
|
|
299
|
-
|
|
338
|
+
Q,
|
|
300
339
|
() => (c(), !1),
|
|
301
|
-
|
|
340
|
+
X
|
|
302
341
|
),
|
|
303
|
-
t.registerUpdateListener(({ editorState:
|
|
304
|
-
|
|
342
|
+
t.registerUpdateListener(({ editorState: u }) => {
|
|
343
|
+
u.read(() => {
|
|
305
344
|
c();
|
|
306
345
|
});
|
|
307
346
|
})
|
|
308
347
|
), [t, c]);
|
|
309
|
-
const
|
|
310
|
-
() => t.dispatchCommand(
|
|
348
|
+
const x = M(
|
|
349
|
+
() => t.dispatchCommand(E, "bold"),
|
|
311
350
|
[t]
|
|
312
|
-
),
|
|
313
|
-
() => t.dispatchCommand(
|
|
351
|
+
), b = M(
|
|
352
|
+
() => t.dispatchCommand(E, "italic"),
|
|
314
353
|
[t]
|
|
315
|
-
),
|
|
316
|
-
() => t.dispatchCommand(
|
|
354
|
+
), I = M(
|
|
355
|
+
() => t.dispatchCommand(E, "underline"),
|
|
317
356
|
[t]
|
|
318
|
-
),
|
|
319
|
-
() => t.dispatchCommand(
|
|
357
|
+
), k = M(
|
|
358
|
+
() => t.dispatchCommand(E, "code"),
|
|
320
359
|
[t]
|
|
321
|
-
),
|
|
322
|
-
() => t.dispatchCommand(
|
|
360
|
+
), D = M(
|
|
361
|
+
() => t.dispatchCommand(E, "superscript"),
|
|
323
362
|
[t]
|
|
324
|
-
),
|
|
325
|
-
const
|
|
326
|
-
return
|
|
327
|
-
}, [
|
|
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
|
-
|
|
368
|
+
Pt,
|
|
330
369
|
{
|
|
331
370
|
type: "multiple",
|
|
332
371
|
"aria-label": "Tekstformattering",
|
|
333
|
-
value:
|
|
372
|
+
value: lt,
|
|
334
373
|
children: [
|
|
335
|
-
/* @__PURE__ */
|
|
336
|
-
|
|
374
|
+
/* @__PURE__ */ o(
|
|
375
|
+
S,
|
|
337
376
|
{
|
|
338
|
-
onClick:
|
|
377
|
+
onClick: x,
|
|
339
378
|
title: "Fet tekst",
|
|
340
379
|
value: "bold",
|
|
341
|
-
children: /* @__PURE__ */
|
|
380
|
+
children: /* @__PURE__ */ o(Ce, { size: "1.25rem" })
|
|
342
381
|
}
|
|
343
382
|
),
|
|
344
|
-
/* @__PURE__ */
|
|
345
|
-
|
|
383
|
+
/* @__PURE__ */ o(
|
|
384
|
+
S,
|
|
346
385
|
{
|
|
347
|
-
onClick:
|
|
386
|
+
onClick: b,
|
|
348
387
|
title: "Kursiv tekst",
|
|
349
388
|
value: "italic",
|
|
350
|
-
children: /* @__PURE__ */
|
|
389
|
+
children: /* @__PURE__ */ o(Se, { size: "1.25rem" })
|
|
351
390
|
}
|
|
352
391
|
),
|
|
353
|
-
/* @__PURE__ */
|
|
354
|
-
|
|
392
|
+
/* @__PURE__ */ o(
|
|
393
|
+
S,
|
|
355
394
|
{
|
|
356
|
-
onClick:
|
|
395
|
+
onClick: I,
|
|
357
396
|
title: "Understreket tekst",
|
|
358
397
|
value: "underline",
|
|
359
|
-
children: /* @__PURE__ */
|
|
398
|
+
children: /* @__PURE__ */ o(Be, { size: "1.25rem" })
|
|
360
399
|
}
|
|
361
400
|
),
|
|
362
|
-
/* @__PURE__ */
|
|
363
|
-
|
|
401
|
+
/* @__PURE__ */ o(
|
|
402
|
+
S,
|
|
364
403
|
{
|
|
365
|
-
onClick:
|
|
404
|
+
onClick: k,
|
|
366
405
|
title: "Kode",
|
|
367
406
|
value: "code",
|
|
368
|
-
children: /* @__PURE__ */
|
|
407
|
+
children: /* @__PURE__ */ o(be, { size: "1.25rem" })
|
|
369
408
|
}
|
|
370
409
|
),
|
|
371
|
-
/* @__PURE__ */
|
|
372
|
-
|
|
410
|
+
/* @__PURE__ */ o(
|
|
411
|
+
S,
|
|
373
412
|
{
|
|
374
|
-
onClick:
|
|
413
|
+
onClick: D,
|
|
375
414
|
title: "Superscript",
|
|
376
415
|
value: "superscript",
|
|
377
|
-
children: /* @__PURE__ */
|
|
416
|
+
children: /* @__PURE__ */ o(ze, { size: "1.25rem" })
|
|
378
417
|
}
|
|
379
418
|
)
|
|
380
419
|
]
|
|
381
420
|
}
|
|
382
421
|
);
|
|
383
|
-
},
|
|
384
|
-
const { hasFocus:
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
}, [
|
|
388
|
-
const { context:
|
|
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:
|
|
429
|
+
whileElementsMounted: At,
|
|
391
430
|
middleware: [
|
|
392
|
-
|
|
393
|
-
apply: ({ rects:
|
|
394
|
-
c.floating.style.minWidth = `${
|
|
431
|
+
Wt({
|
|
432
|
+
apply: ({ rects: g, elements: c }) => {
|
|
433
|
+
c.floating.style.minWidth = `${g.reference.width}px`;
|
|
395
434
|
}
|
|
396
435
|
}),
|
|
397
|
-
|
|
398
|
-
|
|
436
|
+
jt(),
|
|
437
|
+
Kt({
|
|
399
438
|
mainAxis: 8
|
|
400
439
|
}),
|
|
401
|
-
|
|
440
|
+
Ut({
|
|
402
441
|
padding: 8
|
|
403
442
|
})
|
|
404
443
|
],
|
|
405
|
-
open:
|
|
406
|
-
onOpenChange:
|
|
444
|
+
open: a,
|
|
445
|
+
onOpenChange: s,
|
|
407
446
|
elements: {
|
|
408
|
-
reference:
|
|
447
|
+
reference: e.current
|
|
409
448
|
}
|
|
410
|
-
}), { getFloatingProps:
|
|
411
|
-
|
|
449
|
+
}), { getFloatingProps: l } = Yt([
|
|
450
|
+
qt(i, {
|
|
412
451
|
role: "dialog"
|
|
413
452
|
})
|
|
414
453
|
]);
|
|
415
|
-
return
|
|
416
|
-
|
|
454
|
+
return a ? /* @__PURE__ */ o(Gt, { children: /* @__PURE__ */ o(
|
|
455
|
+
Qt,
|
|
417
456
|
{
|
|
418
|
-
ref:
|
|
419
|
-
style:
|
|
420
|
-
...
|
|
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(
|
|
428
|
-
/* @__PURE__ */
|
|
429
|
-
/* @__PURE__ */
|
|
430
|
-
/* @__PURE__ */ e
|
|
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
|
-
}
|
|
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
|
-
}),
|
|
678
|
+
}), Ge = ({
|
|
466
679
|
isLoading: t
|
|
467
|
-
}) => /* @__PURE__ */
|
|
468
|
-
|
|
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__ */
|
|
690
|
+
children: /* @__PURE__ */ o(Jt, {})
|
|
478
691
|
}
|
|
479
|
-
),
|
|
692
|
+
), br = ({
|
|
480
693
|
isLoading: t,
|
|
481
|
-
children:
|
|
482
|
-
placeholderText:
|
|
483
|
-
nodes:
|
|
484
|
-
plugins:
|
|
485
|
-
toolbarContent:
|
|
486
|
-
content:
|
|
487
|
-
hideBorder:
|
|
488
|
-
onBlur:
|
|
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:
|
|
491
|
-
return /* @__PURE__ */
|
|
492
|
-
|
|
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: (
|
|
497
|
-
console.error(
|
|
711
|
+
onError: (k) => {
|
|
712
|
+
console.error(k);
|
|
498
713
|
},
|
|
499
|
-
theme:
|
|
500
|
-
nodes:
|
|
714
|
+
theme: ke,
|
|
715
|
+
nodes: n,
|
|
501
716
|
editable: !0
|
|
502
717
|
},
|
|
503
718
|
children: [
|
|
504
719
|
/* @__PURE__ */ C(
|
|
505
|
-
|
|
720
|
+
qe,
|
|
506
721
|
{
|
|
507
|
-
ref:
|
|
508
|
-
hasFocus:
|
|
509
|
-
hideBorder:
|
|
510
|
-
|
|
722
|
+
ref: b,
|
|
723
|
+
hasFocus: c,
|
|
724
|
+
hideBorder: d,
|
|
725
|
+
css: g,
|
|
726
|
+
...x,
|
|
511
727
|
children: [
|
|
512
|
-
/* @__PURE__ */
|
|
513
|
-
|
|
728
|
+
/* @__PURE__ */ o(
|
|
729
|
+
te,
|
|
514
730
|
{
|
|
515
|
-
contentEditable:
|
|
516
|
-
placeholder:
|
|
517
|
-
|
|
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:
|
|
743
|
+
children: e
|
|
528
744
|
}
|
|
529
745
|
) : null,
|
|
530
|
-
ErrorBoundary:
|
|
746
|
+
ErrorBoundary: ee
|
|
531
747
|
}
|
|
532
748
|
),
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
/* @__PURE__ */
|
|
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__ */
|
|
756
|
+
/* @__PURE__ */ o(Ye, { state: l }),
|
|
757
|
+
/* @__PURE__ */ o(j, { children: r })
|
|
540
758
|
]
|
|
541
759
|
}
|
|
542
760
|
) });
|
|
543
761
|
};
|
|
544
762
|
export {
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
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
|
};
|