silk-compose 0.0.2 → 0.0.3
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/index.d.ts +7 -3
- package/dist/silk.css +1 -1
- package/dist/silk.js +938 -847
- package/package.json +1 -1
package/dist/silk.js
CHANGED
|
@@ -1,227 +1,227 @@
|
|
|
1
|
-
import { jsx as t, Fragment as
|
|
2
|
-
import { useEffect as
|
|
3
|
-
import { LexicalComposer as
|
|
4
|
-
import { useLexicalComposerContext as
|
|
5
|
-
import { HorizontalRulePlugin as
|
|
6
|
-
import { TabIndentationPlugin as
|
|
7
|
-
import { $createHeadingNode as
|
|
8
|
-
import { CodeNode as
|
|
9
|
-
import { INSERT_UNORDERED_LIST_COMMAND as
|
|
10
|
-
import { $createHorizontalRuleNode as
|
|
11
|
-
import { TOGGLE_LINK_COMMAND as
|
|
12
|
-
import { $getNodeByKey as
|
|
13
|
-
import { useLexicalNodeSelection as
|
|
14
|
-
import { $getSelectionStyleValueForProperty as q, $patchStyleText as Z, $setBlocksType as
|
|
15
|
-
import { RichTextPlugin as
|
|
16
|
-
import { ContentEditable as
|
|
17
|
-
import { LexicalErrorBoundary as
|
|
18
|
-
import { HistoryPlugin as
|
|
19
|
-
import { registerDragonSupport as
|
|
20
|
-
import { registerCodeHighlighting as
|
|
21
|
-
import { ListPlugin as
|
|
22
|
-
import { registerMarkdownShortcuts as
|
|
23
|
-
import { createPortal as
|
|
24
|
-
import { useBasicTypeaheadTriggerMatch as
|
|
25
|
-
function
|
|
26
|
-
return /* @__PURE__ */ t(
|
|
1
|
+
import { jsx as t, Fragment as ie, jsxs as k } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect as _, createContext as we, useContext as Me, useState as C, useRef as B, useCallback as M, useLayoutEffect as pe, useMemo as Ee, forwardRef as Le, useImperativeHandle as Te } from "react";
|
|
3
|
+
import { LexicalComposer as De } from "@lexical/react/LexicalComposer";
|
|
4
|
+
import { useLexicalComposerContext as E } from "@lexical/react/LexicalComposerContext";
|
|
5
|
+
import { HorizontalRulePlugin as Ie } from "@lexical/react/LexicalHorizontalRulePlugin";
|
|
6
|
+
import { TabIndentationPlugin as Oe } from "@lexical/react/LexicalTabIndentationPlugin";
|
|
7
|
+
import { $createHeadingNode as ce, $createQuoteNode as Re, HeadingNode as Ae, QuoteNode as Fe } from "@lexical/rich-text";
|
|
8
|
+
import { CodeNode as ge, $isCodeNode as oe, $createCodeNode as $e, CodeHighlightNode as Pe } from "@lexical/code";
|
|
9
|
+
import { INSERT_UNORDERED_LIST_COMMAND as Be, INSERT_ORDERED_LIST_COMMAND as ze, registerList as He, ListNode as We, ListItemNode as Ue } from "@lexical/list";
|
|
10
|
+
import { $createHorizontalRuleNode as Ke, HorizontalRuleNode as Ge } from "@lexical/react/LexicalHorizontalRuleNode";
|
|
11
|
+
import { TOGGLE_LINK_COMMAND as Ve, $toggleLink as de, $createLinkNode as Ye, $isLinkNode as ue, LinkNode as je } from "@lexical/link";
|
|
12
|
+
import { $getNodeByKey as U, ElementNode as Je, $createParagraphNode as Y, COMMAND_PRIORITY_LOW as H, $getSelection as L, $isRangeSelection as T, $setSelection as Qe, $createTextNode as Xe, createCommand as qe, $isParagraphNode as ke, $applyNodeReplacement as Ze, DecoratorNode as et, CLICK_COMMAND as tt, KEY_BACKSPACE_COMMAND as nt, KEY_DELETE_COMMAND as it, $isNodeSelection as ee, SELECTION_CHANGE_COMMAND as ye, FORMAT_TEXT_COMMAND as ot, FORMAT_ELEMENT_COMMAND as st, $getNearestNodeFromDOMNode as rt, PASTE_COMMAND as lt, COMMAND_PRIORITY_HIGH as X, DROP_COMMAND as at, DRAGOVER_COMMAND as ct, $getRoot as fe } from "lexical";
|
|
13
|
+
import { useLexicalNodeSelection as dt } from "@lexical/react/useLexicalNodeSelection";
|
|
14
|
+
import { $getSelectionStyleValueForProperty as q, $patchStyleText as Z, $setBlocksType as ut } from "@lexical/selection";
|
|
15
|
+
import { RichTextPlugin as ft } from "@lexical/react/LexicalRichTextPlugin";
|
|
16
|
+
import { ContentEditable as ht } from "@lexical/react/LexicalContentEditable";
|
|
17
|
+
import { LexicalErrorBoundary as mt } from "@lexical/react/LexicalErrorBoundary";
|
|
18
|
+
import { HistoryPlugin as pt } from "@lexical/react/LexicalHistoryPlugin";
|
|
19
|
+
import { registerDragonSupport as gt } from "@lexical/dragon";
|
|
20
|
+
import { registerCodeHighlighting as kt, ShikiTokenizer as yt, getCodeLanguageOptions as bt } from "@lexical/code-shiki";
|
|
21
|
+
import { ListPlugin as vt } from "@lexical/react/LexicalListPlugin";
|
|
22
|
+
import { registerMarkdownShortcuts as Nt, TEXT_FORMAT_TRANSFORMERS as Ct, UNORDERED_LIST as xt, ORDERED_LIST as _t } from "@lexical/markdown";
|
|
23
|
+
import { createPortal as St } from "react-dom";
|
|
24
|
+
import { useBasicTypeaheadTriggerMatch as wt, LexicalTypeaheadMenuPlugin as Mt, MenuOption as Et } from "@lexical/react/LexicalTypeaheadMenuPlugin";
|
|
25
|
+
function Lt() {
|
|
26
|
+
return /* @__PURE__ */ t(pt, {});
|
|
27
27
|
}
|
|
28
|
-
function
|
|
28
|
+
function Tt() {
|
|
29
29
|
return /* @__PURE__ */ t("div", { style: { position: "relative" }, children: /* @__PURE__ */ t(
|
|
30
|
-
|
|
30
|
+
ft,
|
|
31
31
|
{
|
|
32
|
-
contentEditable: /* @__PURE__ */ t(
|
|
32
|
+
contentEditable: /* @__PURE__ */ t(ht, { className: "silk-content-editable" }),
|
|
33
33
|
placeholder: /* @__PURE__ */ t("div", { className: "silk-placeholder", children: "Start writing…" }),
|
|
34
|
-
ErrorBoundary:
|
|
34
|
+
ErrorBoundary: mt
|
|
35
35
|
}
|
|
36
36
|
) });
|
|
37
37
|
}
|
|
38
|
-
function
|
|
39
|
-
const [e] =
|
|
40
|
-
return
|
|
38
|
+
function Dt() {
|
|
39
|
+
const [e] = E();
|
|
40
|
+
return _(() => gt(e), [e]), null;
|
|
41
41
|
}
|
|
42
|
-
const
|
|
42
|
+
const be = we({
|
|
43
43
|
current: null
|
|
44
44
|
});
|
|
45
|
-
function
|
|
46
|
-
return
|
|
45
|
+
function se() {
|
|
46
|
+
return Me(be);
|
|
47
47
|
}
|
|
48
|
-
function
|
|
49
|
-
return
|
|
48
|
+
function It() {
|
|
49
|
+
return bt().map(([e, n]) => ({ value: e, label: n }));
|
|
50
50
|
}
|
|
51
|
-
const
|
|
52
|
-
function
|
|
51
|
+
const Ot = 32;
|
|
52
|
+
function Rt({
|
|
53
53
|
language: e,
|
|
54
54
|
codeNodeKey: n,
|
|
55
|
-
codeElem:
|
|
55
|
+
codeElem: o
|
|
56
56
|
}) {
|
|
57
|
-
var
|
|
58
|
-
const [
|
|
59
|
-
|
|
60
|
-
const
|
|
61
|
-
const
|
|
62
|
-
if (!
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
top:
|
|
66
|
-
left:
|
|
67
|
-
width:
|
|
57
|
+
var w;
|
|
58
|
+
const [i] = E(), r = se(), [s, f] = C(!1), [l, a] = C(() => i.isEditable()), c = B(null), [d, p] = C({ top: 0, left: 0, width: 0 });
|
|
59
|
+
_(() => i.registerEditableListener(a), [i]);
|
|
60
|
+
const g = M(() => {
|
|
61
|
+
const m = r.current;
|
|
62
|
+
if (!m) return;
|
|
63
|
+
const v = o.getBoundingClientRect(), h = m.getBoundingClientRect();
|
|
64
|
+
p({
|
|
65
|
+
top: v.top - h.top - Ot,
|
|
66
|
+
left: v.left - h.left,
|
|
67
|
+
width: v.width
|
|
68
68
|
});
|
|
69
|
-
}, [
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
const
|
|
73
|
-
return
|
|
74
|
-
}, [
|
|
75
|
-
|
|
76
|
-
}), [
|
|
77
|
-
const S =
|
|
78
|
-
(
|
|
79
|
-
|
|
80
|
-
const
|
|
81
|
-
|
|
82
|
-
}),
|
|
69
|
+
}, [o, r]);
|
|
70
|
+
pe(() => {
|
|
71
|
+
g();
|
|
72
|
+
const m = new ResizeObserver(g);
|
|
73
|
+
return m.observe(o), () => m.disconnect();
|
|
74
|
+
}, [o, g]), _(() => i.registerUpdateListener(() => {
|
|
75
|
+
g();
|
|
76
|
+
}), [i, g]);
|
|
77
|
+
const S = It(), u = ((w = S.find((m) => m.value === e)) == null ? void 0 : w.label) ?? e ?? "Plain Text", x = M(
|
|
78
|
+
(m) => {
|
|
79
|
+
i.update(() => {
|
|
80
|
+
const v = U(n);
|
|
81
|
+
oe(v) && v.setLanguage(m);
|
|
82
|
+
}), f(!1);
|
|
83
83
|
},
|
|
84
|
-
[
|
|
84
|
+
[i, n]
|
|
85
85
|
);
|
|
86
|
-
return
|
|
87
|
-
if (!
|
|
88
|
-
const
|
|
89
|
-
c.current && !c.current.contains(
|
|
86
|
+
return _(() => {
|
|
87
|
+
if (!s) return;
|
|
88
|
+
const m = (v) => {
|
|
89
|
+
c.current && !c.current.contains(v.target) && f(!1);
|
|
90
90
|
};
|
|
91
|
-
return document.addEventListener("mousedown",
|
|
92
|
-
}, [
|
|
91
|
+
return document.addEventListener("mousedown", m), () => document.removeEventListener("mousedown", m);
|
|
92
|
+
}, [s]), /* @__PURE__ */ k(
|
|
93
93
|
"div",
|
|
94
94
|
{
|
|
95
95
|
ref: c,
|
|
96
96
|
className: "silk-code-header",
|
|
97
97
|
style: {
|
|
98
98
|
position: "absolute",
|
|
99
|
-
top:
|
|
100
|
-
left:
|
|
101
|
-
width:
|
|
99
|
+
top: d.top,
|
|
100
|
+
left: d.left,
|
|
101
|
+
width: d.width,
|
|
102
102
|
pointerEvents: "auto"
|
|
103
103
|
},
|
|
104
104
|
children: [
|
|
105
|
-
/* @__PURE__ */
|
|
105
|
+
/* @__PURE__ */ k(
|
|
106
106
|
"button",
|
|
107
107
|
{
|
|
108
108
|
className: "silk-code-language-select",
|
|
109
|
-
onClick: () => l &&
|
|
109
|
+
onClick: () => l && f(!s),
|
|
110
110
|
style: { cursor: l ? "pointer" : "default" },
|
|
111
|
-
onMouseDown: (
|
|
111
|
+
onMouseDown: (m) => m.preventDefault(),
|
|
112
112
|
type: "button",
|
|
113
113
|
children: [
|
|
114
|
-
|
|
114
|
+
u,
|
|
115
115
|
l && /* @__PURE__ */ t("span", { className: "silk-code-language-chevron", "aria-hidden": !0, children: "▾" })
|
|
116
116
|
]
|
|
117
117
|
}
|
|
118
118
|
),
|
|
119
|
-
|
|
119
|
+
s && l && /* @__PURE__ */ t("div", { className: "silk-code-language-dropdown", children: S.map((m) => /* @__PURE__ */ t(
|
|
120
120
|
"button",
|
|
121
121
|
{
|
|
122
|
-
className: `silk-code-language-option${e ===
|
|
123
|
-
onClick: () =>
|
|
124
|
-
onMouseDown: (
|
|
122
|
+
className: `silk-code-language-option${e === m.value ? " silk-code-language-option--active" : ""}`,
|
|
123
|
+
onClick: () => x(m.value),
|
|
124
|
+
onMouseDown: (v) => v.preventDefault(),
|
|
125
125
|
type: "button",
|
|
126
|
-
children:
|
|
126
|
+
children: m.label
|
|
127
127
|
},
|
|
128
|
-
|
|
128
|
+
m.value
|
|
129
129
|
)) })
|
|
130
130
|
]
|
|
131
131
|
}
|
|
132
132
|
);
|
|
133
133
|
}
|
|
134
|
-
function
|
|
135
|
-
const [e] =
|
|
134
|
+
function At() {
|
|
135
|
+
const [e] = E(), [n, o] = C(
|
|
136
136
|
/* @__PURE__ */ new Map()
|
|
137
137
|
);
|
|
138
|
-
return
|
|
139
|
-
...
|
|
138
|
+
return _(() => kt(e, {
|
|
139
|
+
...yt,
|
|
140
140
|
defaultTheme: "dark-plus"
|
|
141
|
-
}), [e]),
|
|
142
|
-
const
|
|
141
|
+
}), [e]), _(() => {
|
|
142
|
+
const i = /* @__PURE__ */ new Set(), r = () => {
|
|
143
143
|
e.getEditorState().read(() => {
|
|
144
144
|
const l = /* @__PURE__ */ new Map();
|
|
145
|
-
for (const a of
|
|
146
|
-
const c =
|
|
147
|
-
if (
|
|
148
|
-
const
|
|
149
|
-
|
|
145
|
+
for (const a of i) {
|
|
146
|
+
const c = U(a);
|
|
147
|
+
if (oe(c)) {
|
|
148
|
+
const d = e.getElementByKey(a);
|
|
149
|
+
d && l.set(a, {
|
|
150
150
|
language: c.getLanguage() ?? "typescript",
|
|
151
|
-
elem:
|
|
151
|
+
elem: d
|
|
152
152
|
});
|
|
153
153
|
}
|
|
154
154
|
}
|
|
155
|
-
|
|
155
|
+
o(l);
|
|
156
156
|
});
|
|
157
|
-
},
|
|
158
|
-
|
|
157
|
+
}, s = e.registerMutationListener(
|
|
158
|
+
ge,
|
|
159
159
|
(l) => {
|
|
160
160
|
for (const [a, c] of l)
|
|
161
|
-
c === "destroyed" ?
|
|
162
|
-
|
|
161
|
+
c === "destroyed" ? i.delete(a) : i.add(a);
|
|
162
|
+
r();
|
|
163
163
|
},
|
|
164
164
|
{ skipInitialization: !1 }
|
|
165
|
-
),
|
|
165
|
+
), f = e.registerUpdateListener(({ dirtyElements: l }) => {
|
|
166
166
|
let a = !1;
|
|
167
|
-
for (const c of
|
|
167
|
+
for (const c of i)
|
|
168
168
|
if (l.has(c)) {
|
|
169
169
|
a = !0;
|
|
170
170
|
break;
|
|
171
171
|
}
|
|
172
|
-
a &&
|
|
172
|
+
a && r();
|
|
173
173
|
});
|
|
174
174
|
return () => {
|
|
175
|
-
|
|
175
|
+
s(), f();
|
|
176
176
|
};
|
|
177
|
-
}, [e]), /* @__PURE__ */ t(
|
|
178
|
-
|
|
177
|
+
}, [e]), /* @__PURE__ */ t(ie, { children: Array.from(n.entries()).map(([i, { language: r, elem: s }]) => /* @__PURE__ */ t(
|
|
178
|
+
Rt,
|
|
179
179
|
{
|
|
180
|
-
language:
|
|
181
|
-
codeNodeKey:
|
|
182
|
-
codeElem:
|
|
180
|
+
language: r,
|
|
181
|
+
codeNodeKey: i,
|
|
182
|
+
codeElem: s
|
|
183
183
|
},
|
|
184
|
-
|
|
184
|
+
i
|
|
185
185
|
)) });
|
|
186
186
|
}
|
|
187
|
-
class
|
|
187
|
+
class G extends Je {
|
|
188
188
|
static getType() {
|
|
189
189
|
return "note";
|
|
190
190
|
}
|
|
191
191
|
static clone(n) {
|
|
192
|
-
return new
|
|
192
|
+
return new G(n.__noteType, n.__key);
|
|
193
193
|
}
|
|
194
|
-
constructor(n = "info",
|
|
195
|
-
super(
|
|
194
|
+
constructor(n = "info", o) {
|
|
195
|
+
super(o), this.__noteType = n;
|
|
196
196
|
}
|
|
197
197
|
createDOM(n) {
|
|
198
|
-
const
|
|
199
|
-
return
|
|
198
|
+
const o = document.createElement("div");
|
|
199
|
+
return o.className = `silk-note silk-note--${this.__noteType}`, o;
|
|
200
200
|
}
|
|
201
|
-
updateDOM(n,
|
|
202
|
-
return n.__noteType !== this.__noteType && (
|
|
201
|
+
updateDOM(n, o) {
|
|
202
|
+
return n.__noteType !== this.__noteType && (o.className = `silk-note silk-note--${this.__noteType}`), !1;
|
|
203
203
|
}
|
|
204
204
|
setNoteType(n) {
|
|
205
|
-
const
|
|
206
|
-
return
|
|
205
|
+
const o = this.getWritable();
|
|
206
|
+
return o.__noteType = n, o;
|
|
207
207
|
}
|
|
208
208
|
getNoteType() {
|
|
209
209
|
return this.getLatest().__noteType;
|
|
210
210
|
}
|
|
211
|
-
insertNewAfter(n,
|
|
212
|
-
const
|
|
213
|
-
if (
|
|
214
|
-
const
|
|
215
|
-
return this.insertAfter(
|
|
211
|
+
insertNewAfter(n, o) {
|
|
212
|
+
const i = n.anchor.getNode(), r = this.getLastDescendant();
|
|
213
|
+
if (r === null || i === r || i === this && n.anchor.offset === this.getChildrenSize()) {
|
|
214
|
+
const s = Y();
|
|
215
|
+
return this.insertAfter(s, o), s;
|
|
216
216
|
}
|
|
217
|
-
return super.insertNewAfter(n,
|
|
217
|
+
return super.insertNewAfter(n, o);
|
|
218
218
|
}
|
|
219
219
|
collapseAtStart() {
|
|
220
|
-
const n =
|
|
221
|
-
return
|
|
220
|
+
const n = Y(), o = this.getChildren();
|
|
221
|
+
return o.length > 0 && o.forEach((i) => n.append(i)), this.replace(n), !0;
|
|
222
222
|
}
|
|
223
223
|
static importJSON(n) {
|
|
224
|
-
return
|
|
224
|
+
return ve(n.noteType);
|
|
225
225
|
}
|
|
226
226
|
exportJSON() {
|
|
227
227
|
return {
|
|
@@ -230,79 +230,79 @@ class W extends Ye {
|
|
|
230
230
|
};
|
|
231
231
|
}
|
|
232
232
|
}
|
|
233
|
-
function
|
|
234
|
-
return new
|
|
233
|
+
function ve(e = "info") {
|
|
234
|
+
return new G(e);
|
|
235
235
|
}
|
|
236
|
-
function
|
|
237
|
-
return e instanceof
|
|
236
|
+
function Ne(e) {
|
|
237
|
+
return e instanceof G;
|
|
238
238
|
}
|
|
239
|
-
const
|
|
240
|
-
function
|
|
241
|
-
const [e] =
|
|
242
|
-
|
|
243
|
-
const
|
|
244
|
-
|
|
245
|
-
(
|
|
239
|
+
const re = qe("SHOW_LINK_DIALOG");
|
|
240
|
+
function Ft() {
|
|
241
|
+
const [e] = E(), [n, o] = C(!1), [i, r] = C(""), [s, f] = C(""), [l, a] = C(!1), c = B(null), d = B(null);
|
|
242
|
+
_(() => {
|
|
243
|
+
const u = e.registerCommand(
|
|
244
|
+
Ve,
|
|
245
|
+
(w) => (de(w, {
|
|
246
246
|
target: "_blank",
|
|
247
247
|
rel: "noopener noreferrer"
|
|
248
248
|
}), !0),
|
|
249
|
-
|
|
250
|
-
),
|
|
251
|
-
|
|
252
|
-
(
|
|
253
|
-
const
|
|
254
|
-
if (
|
|
255
|
-
|
|
256
|
-
const
|
|
257
|
-
a(!
|
|
249
|
+
H
|
|
250
|
+
), x = e.registerCommand(
|
|
251
|
+
re,
|
|
252
|
+
(w) => {
|
|
253
|
+
const m = L();
|
|
254
|
+
if (T(m)) {
|
|
255
|
+
d.current = m.clone();
|
|
256
|
+
const v = m.isCollapsed();
|
|
257
|
+
a(!v), v || f(m.getTextContent());
|
|
258
258
|
}
|
|
259
|
-
return (
|
|
259
|
+
return (w == null ? void 0 : w.text) !== void 0 && f(w.text), o(!0), !0;
|
|
260
260
|
},
|
|
261
|
-
|
|
261
|
+
H
|
|
262
262
|
);
|
|
263
263
|
return () => {
|
|
264
|
-
|
|
264
|
+
u(), x();
|
|
265
265
|
};
|
|
266
|
-
}, [e]),
|
|
266
|
+
}, [e]), _(() => {
|
|
267
267
|
n && setTimeout(() => {
|
|
268
|
-
var
|
|
269
|
-
return (
|
|
268
|
+
var u;
|
|
269
|
+
return (u = c.current) == null ? void 0 : u.focus();
|
|
270
270
|
}, 0);
|
|
271
271
|
}, [n]);
|
|
272
|
-
const
|
|
273
|
-
|
|
274
|
-
}, [e]),
|
|
275
|
-
|
|
276
|
-
if (
|
|
277
|
-
|
|
272
|
+
const p = M(() => {
|
|
273
|
+
o(!1), r(""), f(""), a(!1), d.current = null, e.focus();
|
|
274
|
+
}, [e]), g = M(() => {
|
|
275
|
+
i && (e.update(() => {
|
|
276
|
+
if (d.current && Qe(d.current.clone()), l)
|
|
277
|
+
de(i, {
|
|
278
278
|
target: "_blank",
|
|
279
279
|
rel: "noopener noreferrer"
|
|
280
280
|
});
|
|
281
281
|
else {
|
|
282
|
-
const
|
|
282
|
+
const u = Ye(i, {
|
|
283
283
|
target: "_blank",
|
|
284
284
|
rel: "noopener noreferrer"
|
|
285
|
-
}),
|
|
286
|
-
|
|
287
|
-
const
|
|
288
|
-
|
|
285
|
+
}), x = Xe(s || i);
|
|
286
|
+
u.append(x);
|
|
287
|
+
const w = L();
|
|
288
|
+
T(w) && w.insertNodes([u]);
|
|
289
289
|
}
|
|
290
|
-
}),
|
|
291
|
-
}, [e,
|
|
292
|
-
(
|
|
293
|
-
|
|
290
|
+
}), p());
|
|
291
|
+
}, [e, i, s, l, p]), S = M(
|
|
292
|
+
(u) => {
|
|
293
|
+
u.key === "Enter" && (u.preventDefault(), g()), u.key === "Escape" && p();
|
|
294
294
|
},
|
|
295
|
-
[
|
|
295
|
+
[g, p]
|
|
296
296
|
);
|
|
297
297
|
return n ? /* @__PURE__ */ t(
|
|
298
298
|
"div",
|
|
299
299
|
{
|
|
300
300
|
className: "silk-link-dialog-backdrop",
|
|
301
|
-
onMouseDown: (
|
|
302
|
-
|
|
301
|
+
onMouseDown: (u) => {
|
|
302
|
+
u.target === u.currentTarget && p();
|
|
303
303
|
},
|
|
304
|
-
children: /* @__PURE__ */
|
|
305
|
-
/* @__PURE__ */
|
|
304
|
+
children: /* @__PURE__ */ k("div", { className: "silk-link-dialog", onKeyDown: S, children: [
|
|
305
|
+
/* @__PURE__ */ k("div", { className: "silk-link-dialog-field", children: [
|
|
306
306
|
/* @__PURE__ */ t("label", { className: "silk-link-dialog-label", children: "URL" }),
|
|
307
307
|
/* @__PURE__ */ t(
|
|
308
308
|
"input",
|
|
@@ -310,32 +310,32 @@ function Rt() {
|
|
|
310
310
|
ref: c,
|
|
311
311
|
className: "silk-link-dialog-input",
|
|
312
312
|
type: "text",
|
|
313
|
-
value:
|
|
314
|
-
onChange: (
|
|
313
|
+
value: i,
|
|
314
|
+
onChange: (u) => r(u.target.value),
|
|
315
315
|
placeholder: "https://example.com"
|
|
316
316
|
}
|
|
317
317
|
)
|
|
318
318
|
] }),
|
|
319
|
-
/* @__PURE__ */
|
|
319
|
+
/* @__PURE__ */ k("div", { className: "silk-link-dialog-field", children: [
|
|
320
320
|
/* @__PURE__ */ t("label", { className: "silk-link-dialog-label", children: "Display text" }),
|
|
321
321
|
/* @__PURE__ */ t(
|
|
322
322
|
"input",
|
|
323
323
|
{
|
|
324
324
|
className: `silk-link-dialog-input${l ? " silk-link-dialog-input--readonly" : ""}`,
|
|
325
325
|
type: "text",
|
|
326
|
-
value:
|
|
327
|
-
onChange: (
|
|
326
|
+
value: s,
|
|
327
|
+
onChange: (u) => f(u.target.value),
|
|
328
328
|
placeholder: "Link text",
|
|
329
329
|
readOnly: l
|
|
330
330
|
}
|
|
331
331
|
)
|
|
332
332
|
] }),
|
|
333
|
-
/* @__PURE__ */
|
|
333
|
+
/* @__PURE__ */ k("div", { className: "silk-link-dialog-actions", children: [
|
|
334
334
|
/* @__PURE__ */ t(
|
|
335
335
|
"button",
|
|
336
336
|
{
|
|
337
337
|
className: "silk-link-dialog-cancel",
|
|
338
|
-
onClick:
|
|
338
|
+
onClick: p,
|
|
339
339
|
type: "button",
|
|
340
340
|
children: "Cancel"
|
|
341
341
|
}
|
|
@@ -344,8 +344,8 @@ function Rt() {
|
|
|
344
344
|
"button",
|
|
345
345
|
{
|
|
346
346
|
className: "silk-link-dialog-insert",
|
|
347
|
-
onClick:
|
|
348
|
-
disabled: !
|
|
347
|
+
onClick: g,
|
|
348
|
+
disabled: !i,
|
|
349
349
|
type: "button",
|
|
350
350
|
children: "Insert"
|
|
351
351
|
}
|
|
@@ -355,11 +355,11 @@ function Rt() {
|
|
|
355
355
|
}
|
|
356
356
|
) : null;
|
|
357
357
|
}
|
|
358
|
-
const
|
|
359
|
-
function
|
|
358
|
+
const $t = 18;
|
|
359
|
+
function A({
|
|
360
360
|
children: e,
|
|
361
|
-
size: n =
|
|
362
|
-
className:
|
|
361
|
+
size: n = $t,
|
|
362
|
+
className: o
|
|
363
363
|
}) {
|
|
364
364
|
return /* @__PURE__ */ t(
|
|
365
365
|
"svg",
|
|
@@ -372,42 +372,42 @@ function O({
|
|
|
372
372
|
strokeWidth: 2,
|
|
373
373
|
strokeLinecap: "round",
|
|
374
374
|
strokeLinejoin: "round",
|
|
375
|
-
className:
|
|
375
|
+
className: o,
|
|
376
376
|
children: e
|
|
377
377
|
}
|
|
378
378
|
);
|
|
379
379
|
}
|
|
380
|
-
function
|
|
381
|
-
return /* @__PURE__ */
|
|
380
|
+
function Pt(e) {
|
|
381
|
+
return /* @__PURE__ */ k(A, { ...e, children: [
|
|
382
382
|
/* @__PURE__ */ t("path", { d: "M4 12h8" }),
|
|
383
383
|
/* @__PURE__ */ t("path", { d: "M4 18V6" }),
|
|
384
384
|
/* @__PURE__ */ t("path", { d: "M12 18V6" }),
|
|
385
385
|
/* @__PURE__ */ t("path", { d: "M17 12l3-2v8" })
|
|
386
386
|
] });
|
|
387
387
|
}
|
|
388
|
-
function
|
|
389
|
-
return /* @__PURE__ */
|
|
388
|
+
function Bt(e) {
|
|
389
|
+
return /* @__PURE__ */ k(A, { ...e, children: [
|
|
390
390
|
/* @__PURE__ */ t("path", { d: "M4 12h8" }),
|
|
391
391
|
/* @__PURE__ */ t("path", { d: "M4 18V6" }),
|
|
392
392
|
/* @__PURE__ */ t("path", { d: "M12 18V6" }),
|
|
393
393
|
/* @__PURE__ */ t("path", { d: "M21 18h-4c0-4 4-3 4-6 0-1.5-2-2.5-4-1" })
|
|
394
394
|
] });
|
|
395
395
|
}
|
|
396
|
-
function
|
|
397
|
-
return /* @__PURE__ */
|
|
396
|
+
function zt(e) {
|
|
397
|
+
return /* @__PURE__ */ k(A, { ...e, children: [
|
|
398
398
|
/* @__PURE__ */ t("polyline", { points: "16 18 22 12 16 6" }),
|
|
399
399
|
/* @__PURE__ */ t("polyline", { points: "8 6 2 12 8 18" })
|
|
400
400
|
] });
|
|
401
401
|
}
|
|
402
|
-
function
|
|
403
|
-
return /* @__PURE__ */
|
|
402
|
+
function Ce(e) {
|
|
403
|
+
return /* @__PURE__ */ k(A, { ...e, children: [
|
|
404
404
|
/* @__PURE__ */ t("circle", { cx: "12", cy: "12", r: "10" }),
|
|
405
405
|
/* @__PURE__ */ t("line", { x1: "12", y1: "16", x2: "12", y2: "12" }),
|
|
406
406
|
/* @__PURE__ */ t("line", { x1: "12", y1: "8", x2: "12.01", y2: "8" })
|
|
407
407
|
] });
|
|
408
408
|
}
|
|
409
|
-
function
|
|
410
|
-
return /* @__PURE__ */
|
|
409
|
+
function Ht(e) {
|
|
410
|
+
return /* @__PURE__ */ k(A, { ...e, children: [
|
|
411
411
|
/* @__PURE__ */ t("path", { d: "M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z" }),
|
|
412
412
|
/* @__PURE__ */ t(
|
|
413
413
|
"text",
|
|
@@ -425,21 +425,21 @@ function zt(e) {
|
|
|
425
425
|
)
|
|
426
426
|
] });
|
|
427
427
|
}
|
|
428
|
-
function
|
|
429
|
-
return /* @__PURE__ */
|
|
428
|
+
function Wt(e) {
|
|
429
|
+
return /* @__PURE__ */ k(A, { ...e, children: [
|
|
430
430
|
/* @__PURE__ */ t("circle", { cx: "12", cy: "12", r: "10" }),
|
|
431
431
|
/* @__PURE__ */ t("line", { x1: "12", y1: "8", x2: "12", y2: "12" }),
|
|
432
432
|
/* @__PURE__ */ t("line", { x1: "12", y1: "16", x2: "12.01", y2: "16" })
|
|
433
433
|
] });
|
|
434
434
|
}
|
|
435
|
-
function
|
|
436
|
-
return /* @__PURE__ */
|
|
435
|
+
function Ut(e) {
|
|
436
|
+
return /* @__PURE__ */ k(A, { ...e, children: [
|
|
437
437
|
/* @__PURE__ */ t("path", { d: "M10 13a5 5 0 007.54.54l3-3a5 5 0 00-7.07-7.07l-1.72 1.71" }),
|
|
438
438
|
/* @__PURE__ */ t("path", { d: "M14 11a5 5 0 00-7.54-.54l-3 3a5 5 0 007.07 7.07l1.71-1.71" })
|
|
439
439
|
] });
|
|
440
440
|
}
|
|
441
|
-
function
|
|
442
|
-
return /* @__PURE__ */
|
|
441
|
+
function Kt(e) {
|
|
442
|
+
return /* @__PURE__ */ k(A, { ...e, children: [
|
|
443
443
|
/* @__PURE__ */ t("line", { x1: "10", y1: "6", x2: "21", y2: "6" }),
|
|
444
444
|
/* @__PURE__ */ t("line", { x1: "10", y1: "12", x2: "21", y2: "12" }),
|
|
445
445
|
/* @__PURE__ */ t("line", { x1: "10", y1: "18", x2: "21", y2: "18" }),
|
|
@@ -448,8 +448,8 @@ function Ut(e) {
|
|
|
448
448
|
/* @__PURE__ */ t("path", { d: "M6 18H4c0-1 2-2 2-3s-1-1.5-2-1" })
|
|
449
449
|
] });
|
|
450
450
|
}
|
|
451
|
-
function
|
|
452
|
-
return /* @__PURE__ */
|
|
451
|
+
function Gt(e) {
|
|
452
|
+
return /* @__PURE__ */ k(A, { ...e, children: [
|
|
453
453
|
/* @__PURE__ */ t("line", { x1: "8", y1: "6", x2: "21", y2: "6" }),
|
|
454
454
|
/* @__PURE__ */ t("line", { x1: "8", y1: "12", x2: "21", y2: "12" }),
|
|
455
455
|
/* @__PURE__ */ t("line", { x1: "8", y1: "18", x2: "21", y2: "18" }),
|
|
@@ -458,114 +458,114 @@ function Wt(e) {
|
|
|
458
458
|
/* @__PURE__ */ t("line", { x1: "3", y1: "18", x2: "3.01", y2: "18" })
|
|
459
459
|
] });
|
|
460
460
|
}
|
|
461
|
-
function
|
|
462
|
-
return /* @__PURE__ */ t(
|
|
461
|
+
function Vt(e) {
|
|
462
|
+
return /* @__PURE__ */ t(A, { ...e, children: /* @__PURE__ */ t("line", { x1: "2", y1: "12", x2: "22", y2: "12" }) });
|
|
463
463
|
}
|
|
464
|
-
function
|
|
465
|
-
const n =
|
|
466
|
-
if (!
|
|
467
|
-
const
|
|
468
|
-
return
|
|
464
|
+
function Q(e) {
|
|
465
|
+
const n = L();
|
|
466
|
+
if (!T(n)) return;
|
|
467
|
+
const i = n.anchor.getNode().getTopLevelElementOrThrow(), r = e(), s = Y();
|
|
468
|
+
return i.insertAfter(r), r.insertAfter(s), ke(i) && i.getTextContentSize() === 0 && i.remove(), { node: r, trailing: s };
|
|
469
469
|
}
|
|
470
|
-
const
|
|
470
|
+
const Yt = [
|
|
471
471
|
{
|
|
472
472
|
name: "Heading 1",
|
|
473
|
-
icon: /* @__PURE__ */ t(
|
|
473
|
+
icon: /* @__PURE__ */ t(Pt, {}),
|
|
474
474
|
description: "Large section heading",
|
|
475
475
|
execute: () => {
|
|
476
|
-
const e =
|
|
476
|
+
const e = Q(() => ce("h1"));
|
|
477
477
|
e == null || e.node.selectStart();
|
|
478
478
|
}
|
|
479
479
|
},
|
|
480
480
|
{
|
|
481
481
|
name: "Heading 2",
|
|
482
|
-
icon: /* @__PURE__ */ t(
|
|
482
|
+
icon: /* @__PURE__ */ t(Bt, {}),
|
|
483
483
|
description: "Medium section heading",
|
|
484
484
|
execute: () => {
|
|
485
|
-
const e =
|
|
485
|
+
const e = Q(() => ce("h2"));
|
|
486
486
|
e == null || e.node.selectStart();
|
|
487
487
|
}
|
|
488
488
|
},
|
|
489
489
|
{
|
|
490
490
|
name: "Code Block",
|
|
491
|
-
icon: /* @__PURE__ */ t(
|
|
491
|
+
icon: /* @__PURE__ */ t(zt, {}),
|
|
492
492
|
description: "Code with syntax highlighting",
|
|
493
493
|
execute: () => {
|
|
494
|
-
const e =
|
|
494
|
+
const e = Q(() => $e("typescript"));
|
|
495
495
|
e == null || e.node.selectStart();
|
|
496
496
|
}
|
|
497
497
|
},
|
|
498
498
|
{
|
|
499
499
|
name: "Note",
|
|
500
|
-
icon: /* @__PURE__ */ t(
|
|
500
|
+
icon: /* @__PURE__ */ t(Ce, {}),
|
|
501
501
|
description: "Info, warning, or error callout",
|
|
502
502
|
execute: () => {
|
|
503
|
-
const e =
|
|
504
|
-
if (!
|
|
505
|
-
const
|
|
506
|
-
|
|
507
|
-
const
|
|
508
|
-
|
|
503
|
+
const e = L();
|
|
504
|
+
if (!T(e)) return;
|
|
505
|
+
const o = e.anchor.getNode().getTopLevelElementOrThrow(), i = ve("info"), r = Y();
|
|
506
|
+
i.append(r);
|
|
507
|
+
const s = Y();
|
|
508
|
+
o.insertAfter(i), i.insertAfter(s), ke(o) && o.getTextContentSize() === 0 && o.remove(), r.selectStart();
|
|
509
509
|
}
|
|
510
510
|
},
|
|
511
511
|
{
|
|
512
512
|
name: "Bulleted List",
|
|
513
|
-
icon: /* @__PURE__ */ t(
|
|
513
|
+
icon: /* @__PURE__ */ t(Gt, {}),
|
|
514
514
|
description: "Unordered bulleted list",
|
|
515
515
|
execute: (e) => {
|
|
516
|
-
e.dispatchCommand(
|
|
516
|
+
e.dispatchCommand(Be, void 0);
|
|
517
517
|
}
|
|
518
518
|
},
|
|
519
519
|
{
|
|
520
520
|
name: "Numbered List",
|
|
521
|
-
icon: /* @__PURE__ */ t(
|
|
521
|
+
icon: /* @__PURE__ */ t(Kt, {}),
|
|
522
522
|
description: "Ordered numbered list",
|
|
523
523
|
execute: (e) => {
|
|
524
|
-
e.dispatchCommand(
|
|
524
|
+
e.dispatchCommand(ze, void 0);
|
|
525
525
|
}
|
|
526
526
|
},
|
|
527
527
|
{
|
|
528
528
|
name: "Divider",
|
|
529
|
-
icon: /* @__PURE__ */ t(
|
|
529
|
+
icon: /* @__PURE__ */ t(Vt, {}),
|
|
530
530
|
description: "Horizontal line separator",
|
|
531
531
|
execute: () => {
|
|
532
|
-
const e =
|
|
532
|
+
const e = Q(() => Ke());
|
|
533
533
|
e == null || e.trailing.selectStart();
|
|
534
534
|
}
|
|
535
535
|
},
|
|
536
536
|
{
|
|
537
537
|
name: "Link",
|
|
538
|
-
icon: /* @__PURE__ */ t(
|
|
538
|
+
icon: /* @__PURE__ */ t(Ut, {}),
|
|
539
539
|
description: "Insert a masked link",
|
|
540
540
|
execute: (e) => {
|
|
541
|
-
e.dispatchCommand(
|
|
541
|
+
e.dispatchCommand(re, void 0);
|
|
542
542
|
}
|
|
543
543
|
}
|
|
544
544
|
];
|
|
545
|
-
class
|
|
545
|
+
class jt extends Et {
|
|
546
546
|
constructor(n) {
|
|
547
547
|
super(n.name), this.entry = n;
|
|
548
548
|
}
|
|
549
549
|
}
|
|
550
|
-
function
|
|
550
|
+
function Jt({
|
|
551
551
|
option: e,
|
|
552
552
|
isSelected: n,
|
|
553
|
-
onClick:
|
|
554
|
-
onMouseEnter:
|
|
553
|
+
onClick: o,
|
|
554
|
+
onMouseEnter: i
|
|
555
555
|
}) {
|
|
556
|
-
return /* @__PURE__ */
|
|
556
|
+
return /* @__PURE__ */ k(
|
|
557
557
|
"button",
|
|
558
558
|
{
|
|
559
559
|
className: `silk-slash-menu-item${n ? " silk-slash-menu-item--active" : ""}`,
|
|
560
|
-
ref: (
|
|
561
|
-
onMouseDown: (
|
|
562
|
-
|
|
560
|
+
ref: (r) => e.setRefElement(r),
|
|
561
|
+
onMouseDown: (r) => {
|
|
562
|
+
r.preventDefault(), o();
|
|
563
563
|
},
|
|
564
|
-
onMouseEnter:
|
|
564
|
+
onMouseEnter: i,
|
|
565
565
|
type: "button",
|
|
566
566
|
children: [
|
|
567
567
|
/* @__PURE__ */ t("span", { className: "silk-slash-menu-icon", children: e.entry.icon }),
|
|
568
|
-
/* @__PURE__ */
|
|
568
|
+
/* @__PURE__ */ k("div", { className: "silk-slash-menu-text", children: [
|
|
569
569
|
/* @__PURE__ */ t("span", { className: "silk-slash-menu-name", children: e.entry.name }),
|
|
570
570
|
/* @__PURE__ */ t("span", { className: "silk-slash-menu-description", children: e.entry.description })
|
|
571
571
|
] })
|
|
@@ -573,100 +573,100 @@ function Yt({
|
|
|
573
573
|
}
|
|
574
574
|
);
|
|
575
575
|
}
|
|
576
|
-
function
|
|
577
|
-
const [e] =
|
|
578
|
-
|
|
579
|
-
const
|
|
576
|
+
function Qt() {
|
|
577
|
+
const [e] = E(), [n, o] = C(() => e.isEditable()), [i, r] = C(null);
|
|
578
|
+
_(() => e.registerEditableListener(o), [e]);
|
|
579
|
+
const s = wt("/", {
|
|
580
580
|
minLength: 0,
|
|
581
581
|
allowWhitespace: !0
|
|
582
|
-
}),
|
|
583
|
-
if (
|
|
584
|
-
const c =
|
|
585
|
-
return
|
|
586
|
-
(
|
|
587
|
-
).map((
|
|
588
|
-
}, [
|
|
589
|
-
(c,
|
|
590
|
-
|
|
582
|
+
}), f = Ee(() => {
|
|
583
|
+
if (i === null) return [];
|
|
584
|
+
const c = i.toLowerCase();
|
|
585
|
+
return Yt.filter(
|
|
586
|
+
(p) => p.name.toLowerCase().includes(c) || p.description.toLowerCase().includes(c)
|
|
587
|
+
).map((p) => new jt(p));
|
|
588
|
+
}, [i]), l = M(
|
|
589
|
+
(c, d, p) => {
|
|
590
|
+
d && d.remove(), c.entry.execute(e), p();
|
|
591
591
|
},
|
|
592
592
|
[e]
|
|
593
|
-
), a =
|
|
594
|
-
(c,
|
|
595
|
-
/* @__PURE__ */ t("div", { className: "silk-slash-menu", children:
|
|
596
|
-
|
|
593
|
+
), a = M(
|
|
594
|
+
(c, d, p) => c.current == null || d.options.length === 0 ? null : St(
|
|
595
|
+
/* @__PURE__ */ t("div", { className: "silk-slash-menu", children: d.options.map((g, S) => /* @__PURE__ */ t(
|
|
596
|
+
Jt,
|
|
597
597
|
{
|
|
598
|
-
option:
|
|
599
|
-
isSelected:
|
|
600
|
-
onClick: () =>
|
|
601
|
-
onMouseEnter: () =>
|
|
598
|
+
option: g,
|
|
599
|
+
isSelected: d.selectedIndex === S,
|
|
600
|
+
onClick: () => d.selectOptionAndCleanUp(g),
|
|
601
|
+
onMouseEnter: () => d.setHighlightedIndex(S)
|
|
602
602
|
},
|
|
603
|
-
|
|
603
|
+
g.key
|
|
604
604
|
)) }),
|
|
605
605
|
c.current
|
|
606
606
|
),
|
|
607
607
|
[]
|
|
608
608
|
);
|
|
609
609
|
return n ? /* @__PURE__ */ t(
|
|
610
|
-
|
|
610
|
+
Mt,
|
|
611
611
|
{
|
|
612
|
-
options:
|
|
613
|
-
onQueryChange:
|
|
612
|
+
options: f,
|
|
613
|
+
onQueryChange: r,
|
|
614
614
|
onSelectOption: l,
|
|
615
|
-
triggerFn:
|
|
615
|
+
triggerFn: s,
|
|
616
616
|
menuRenderFn: a,
|
|
617
617
|
anchorClassName: "silk-slash-anchor"
|
|
618
618
|
}
|
|
619
619
|
) : null;
|
|
620
620
|
}
|
|
621
|
-
const
|
|
622
|
-
{ value: "info", label: "Info", Icon:
|
|
623
|
-
{ value: "warning", label: "Question", Icon:
|
|
624
|
-
{ value: "error", label: "Error", Icon:
|
|
621
|
+
const Xt = [
|
|
622
|
+
{ value: "info", label: "Info", Icon: Ce },
|
|
623
|
+
{ value: "warning", label: "Question", Icon: Ht },
|
|
624
|
+
{ value: "error", label: "Error", Icon: Wt }
|
|
625
625
|
];
|
|
626
|
-
function
|
|
626
|
+
function qt({
|
|
627
627
|
noteType: e,
|
|
628
628
|
nodeKey: n,
|
|
629
|
-
elem:
|
|
629
|
+
elem: o
|
|
630
630
|
}) {
|
|
631
|
-
const [
|
|
632
|
-
|
|
633
|
-
const
|
|
634
|
-
const
|
|
635
|
-
if (!
|
|
636
|
-
const
|
|
637
|
-
|
|
638
|
-
top:
|
|
639
|
-
left:
|
|
631
|
+
const [i] = E(), r = se(), [s, f] = C(() => i.isEditable()), [l, a] = C(!1), c = B(null), [d, p] = C({ top: 0, left: 0 });
|
|
632
|
+
_(() => i.registerEditableListener(f), [i]);
|
|
633
|
+
const g = M(() => {
|
|
634
|
+
const u = r.current;
|
|
635
|
+
if (!u) return;
|
|
636
|
+
const x = o.getBoundingClientRect(), w = u.getBoundingClientRect();
|
|
637
|
+
p({
|
|
638
|
+
top: x.top - w.top + 13,
|
|
639
|
+
left: x.left - w.left + 17
|
|
640
640
|
});
|
|
641
|
-
}, [
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
const
|
|
645
|
-
return
|
|
646
|
-
}, [
|
|
647
|
-
const S =
|
|
648
|
-
(
|
|
649
|
-
|
|
650
|
-
const
|
|
651
|
-
|
|
641
|
+
}, [o, r]);
|
|
642
|
+
pe(() => {
|
|
643
|
+
g();
|
|
644
|
+
const u = new ResizeObserver(g);
|
|
645
|
+
return u.observe(o), () => u.disconnect();
|
|
646
|
+
}, [o, g]), _(() => i.registerUpdateListener(() => g()), [i, g]);
|
|
647
|
+
const S = M(
|
|
648
|
+
(u) => {
|
|
649
|
+
i.update(() => {
|
|
650
|
+
const x = U(n);
|
|
651
|
+
Ne(x) && x.setNoteType(u);
|
|
652
652
|
}), a(!1);
|
|
653
653
|
},
|
|
654
|
-
[
|
|
654
|
+
[i, n]
|
|
655
655
|
);
|
|
656
|
-
return
|
|
656
|
+
return _(() => {
|
|
657
657
|
if (!l) return;
|
|
658
|
-
const
|
|
659
|
-
c.current && !c.current.contains(
|
|
658
|
+
const u = (x) => {
|
|
659
|
+
c.current && !c.current.contains(x.target) && a(!1);
|
|
660
660
|
};
|
|
661
|
-
return document.addEventListener("mousedown",
|
|
662
|
-
}, [l]),
|
|
661
|
+
return document.addEventListener("mousedown", u), () => document.removeEventListener("mousedown", u);
|
|
662
|
+
}, [l]), s ? /* @__PURE__ */ k(
|
|
663
663
|
"div",
|
|
664
664
|
{
|
|
665
665
|
ref: c,
|
|
666
666
|
style: {
|
|
667
667
|
position: "absolute",
|
|
668
|
-
top:
|
|
669
|
-
left:
|
|
668
|
+
top: d.top,
|
|
669
|
+
left: d.left,
|
|
670
670
|
zIndex: 1
|
|
671
671
|
},
|
|
672
672
|
children: [
|
|
@@ -675,96 +675,294 @@ function Qt({
|
|
|
675
675
|
{
|
|
676
676
|
className: `silk-note-icon-trigger silk-note-icon-trigger--${e}`,
|
|
677
677
|
onClick: () => a(!l),
|
|
678
|
-
onMouseDown: (
|
|
678
|
+
onMouseDown: (u) => u.preventDefault(),
|
|
679
679
|
type: "button",
|
|
680
680
|
"aria-label": "Change note type"
|
|
681
681
|
}
|
|
682
682
|
),
|
|
683
|
-
l && /* @__PURE__ */ t("div", { className: "silk-note-icon-dropdown", children:
|
|
683
|
+
l && /* @__PURE__ */ t("div", { className: "silk-note-icon-dropdown", children: Xt.map((u) => /* @__PURE__ */ k(
|
|
684
684
|
"button",
|
|
685
685
|
{
|
|
686
|
-
className: `silk-note-type-option silk-note-type-option--${
|
|
687
|
-
onClick: () => S(
|
|
688
|
-
onMouseDown: (
|
|
686
|
+
className: `silk-note-type-option silk-note-type-option--${u.value}${e === u.value ? " silk-note-type-option--active" : ""}`,
|
|
687
|
+
onClick: () => S(u.value),
|
|
688
|
+
onMouseDown: (x) => x.preventDefault(),
|
|
689
689
|
type: "button",
|
|
690
690
|
children: [
|
|
691
|
-
/* @__PURE__ */ t(
|
|
692
|
-
|
|
691
|
+
/* @__PURE__ */ t(u.Icon, { size: 14 }),
|
|
692
|
+
u.label
|
|
693
693
|
]
|
|
694
694
|
},
|
|
695
|
-
|
|
695
|
+
u.value
|
|
696
696
|
)) })
|
|
697
697
|
]
|
|
698
698
|
}
|
|
699
699
|
) : null;
|
|
700
700
|
}
|
|
701
|
-
function
|
|
702
|
-
const [e] =
|
|
701
|
+
function Zt() {
|
|
702
|
+
const [e] = E(), [n, o] = C(
|
|
703
703
|
/* @__PURE__ */ new Map()
|
|
704
704
|
);
|
|
705
|
-
return
|
|
706
|
-
const
|
|
705
|
+
return _(() => {
|
|
706
|
+
const i = /* @__PURE__ */ new Set(), r = () => {
|
|
707
707
|
e.getEditorState().read(() => {
|
|
708
708
|
const l = /* @__PURE__ */ new Map();
|
|
709
|
-
for (const a of
|
|
710
|
-
const c =
|
|
711
|
-
if (
|
|
712
|
-
const
|
|
713
|
-
|
|
709
|
+
for (const a of i) {
|
|
710
|
+
const c = U(a);
|
|
711
|
+
if (Ne(c)) {
|
|
712
|
+
const d = e.getElementByKey(a);
|
|
713
|
+
d && l.set(a, {
|
|
714
714
|
noteType: c.getNoteType(),
|
|
715
|
-
elem:
|
|
715
|
+
elem: d
|
|
716
716
|
});
|
|
717
717
|
}
|
|
718
718
|
}
|
|
719
|
-
|
|
719
|
+
o(l);
|
|
720
720
|
});
|
|
721
|
-
},
|
|
722
|
-
|
|
721
|
+
}, s = e.registerMutationListener(
|
|
722
|
+
G,
|
|
723
723
|
(l) => {
|
|
724
724
|
for (const [a, c] of l)
|
|
725
|
-
c === "destroyed" ?
|
|
726
|
-
|
|
725
|
+
c === "destroyed" ? i.delete(a) : i.add(a);
|
|
726
|
+
r();
|
|
727
727
|
},
|
|
728
728
|
{ skipInitialization: !1 }
|
|
729
|
-
),
|
|
729
|
+
), f = e.registerUpdateListener(({ dirtyElements: l }) => {
|
|
730
730
|
let a = !1;
|
|
731
|
-
for (const c of
|
|
731
|
+
for (const c of i)
|
|
732
732
|
if (l.has(c)) {
|
|
733
733
|
a = !0;
|
|
734
734
|
break;
|
|
735
735
|
}
|
|
736
|
-
a &&
|
|
736
|
+
a && r();
|
|
737
737
|
});
|
|
738
738
|
return () => {
|
|
739
|
-
|
|
739
|
+
s(), f();
|
|
740
740
|
};
|
|
741
|
-
}, [e]), /* @__PURE__ */ t(
|
|
742
|
-
|
|
741
|
+
}, [e]), /* @__PURE__ */ t(ie, { children: Array.from(n.entries()).map(([i, { noteType: r, elem: s }]) => /* @__PURE__ */ t(
|
|
742
|
+
qt,
|
|
743
743
|
{
|
|
744
|
-
noteType:
|
|
745
|
-
nodeKey:
|
|
746
|
-
elem:
|
|
744
|
+
noteType: r,
|
|
745
|
+
nodeKey: i,
|
|
746
|
+
elem: s
|
|
747
747
|
},
|
|
748
|
-
|
|
748
|
+
i
|
|
749
749
|
)) });
|
|
750
750
|
}
|
|
751
|
-
const
|
|
752
|
-
...
|
|
753
|
-
|
|
754
|
-
|
|
751
|
+
const en = [
|
|
752
|
+
...Ct,
|
|
753
|
+
xt,
|
|
754
|
+
_t
|
|
755
755
|
];
|
|
756
|
-
function
|
|
757
|
-
const [e] =
|
|
758
|
-
return
|
|
756
|
+
function tn() {
|
|
757
|
+
const [e] = E();
|
|
758
|
+
return _(() => Nt(e, en), [e]), null;
|
|
759
|
+
}
|
|
760
|
+
const nn = ["nw", "ne", "sw", "se"];
|
|
761
|
+
function on({
|
|
762
|
+
src: e,
|
|
763
|
+
altText: n,
|
|
764
|
+
width: o,
|
|
765
|
+
height: i,
|
|
766
|
+
nodeKey: r
|
|
767
|
+
}) {
|
|
768
|
+
const [s] = E(), f = B(null), l = B(null), [a, c, d] = dt(r), [p, g] = C(!1), S = M(
|
|
769
|
+
(m) => f.current && f.current.contains(m.target) ? (d(), c(!0), !0) : !1,
|
|
770
|
+
[d, c]
|
|
771
|
+
), u = M(
|
|
772
|
+
(m) => a && !p ? (m.preventDefault(), s.update(() => {
|
|
773
|
+
const v = U(r);
|
|
774
|
+
v && v.remove();
|
|
775
|
+
}), !0) : !1,
|
|
776
|
+
[s, a, p, r]
|
|
777
|
+
);
|
|
778
|
+
_(() => {
|
|
779
|
+
const m = s.registerCommand(
|
|
780
|
+
tt,
|
|
781
|
+
S,
|
|
782
|
+
H
|
|
783
|
+
), v = s.registerCommand(
|
|
784
|
+
nt,
|
|
785
|
+
u,
|
|
786
|
+
H
|
|
787
|
+
), h = s.registerCommand(
|
|
788
|
+
it,
|
|
789
|
+
u,
|
|
790
|
+
H
|
|
791
|
+
);
|
|
792
|
+
return () => {
|
|
793
|
+
m(), v(), h();
|
|
794
|
+
};
|
|
795
|
+
}, [s, S, u]);
|
|
796
|
+
const x = M(
|
|
797
|
+
(m, v) => {
|
|
798
|
+
v.preventDefault(), v.stopPropagation(), g(!0);
|
|
799
|
+
const h = l.current;
|
|
800
|
+
if (!h) return;
|
|
801
|
+
const N = v.clientX, y = v.clientY, b = h.offsetWidth, I = h.offsetHeight, z = b / I, W = ($) => {
|
|
802
|
+
let O = $.clientX - N;
|
|
803
|
+
const P = $.clientY - y;
|
|
804
|
+
(m === "nw" || m === "sw") && (O = -O);
|
|
805
|
+
let D;
|
|
806
|
+
if (Math.abs(O) > Math.abs(P))
|
|
807
|
+
D = Math.max(100, b + O);
|
|
808
|
+
else {
|
|
809
|
+
const V = m === "nw" || m === "ne" ? -P : P;
|
|
810
|
+
D = Math.max(100, b + V * z);
|
|
811
|
+
}
|
|
812
|
+
const R = D / z;
|
|
813
|
+
h.style.width = `${Math.round(D)}px`, h.style.height = `${Math.round(R)}px`;
|
|
814
|
+
}, F = ($) => {
|
|
815
|
+
document.removeEventListener("mousemove", W), document.removeEventListener("mouseup", F), g(!1);
|
|
816
|
+
const O = h.offsetWidth, P = h.offsetHeight;
|
|
817
|
+
s.update(() => {
|
|
818
|
+
const D = U(r);
|
|
819
|
+
if (D && ne(D)) {
|
|
820
|
+
const R = D.getWritable();
|
|
821
|
+
R.__width = O, R.__height = P;
|
|
822
|
+
}
|
|
823
|
+
});
|
|
824
|
+
};
|
|
825
|
+
document.addEventListener("mousemove", W), document.addEventListener("mouseup", F);
|
|
826
|
+
},
|
|
827
|
+
[s, r]
|
|
828
|
+
), w = s.isEditable();
|
|
829
|
+
return /* @__PURE__ */ k(
|
|
830
|
+
"div",
|
|
831
|
+
{
|
|
832
|
+
ref: f,
|
|
833
|
+
className: `silk-image-container${a ? " silk-image-container--selected" : ""}`,
|
|
834
|
+
children: [
|
|
835
|
+
/* @__PURE__ */ t(
|
|
836
|
+
"img",
|
|
837
|
+
{
|
|
838
|
+
ref: l,
|
|
839
|
+
src: e,
|
|
840
|
+
alt: n,
|
|
841
|
+
width: o,
|
|
842
|
+
height: i,
|
|
843
|
+
className: "silk-image",
|
|
844
|
+
draggable: !1
|
|
845
|
+
}
|
|
846
|
+
),
|
|
847
|
+
a && w && /* @__PURE__ */ t(ie, { children: nn.map((m) => /* @__PURE__ */ t(
|
|
848
|
+
"div",
|
|
849
|
+
{
|
|
850
|
+
className: `silk-image-handle silk-image-handle--${m}`,
|
|
851
|
+
onMouseDown: (v) => x(m, v)
|
|
852
|
+
},
|
|
853
|
+
m
|
|
854
|
+
)) })
|
|
855
|
+
]
|
|
856
|
+
}
|
|
857
|
+
);
|
|
759
858
|
}
|
|
760
|
-
|
|
859
|
+
class j extends et {
|
|
860
|
+
static getType() {
|
|
861
|
+
return "image";
|
|
862
|
+
}
|
|
863
|
+
static clone(n) {
|
|
864
|
+
return new j(
|
|
865
|
+
n.__src,
|
|
866
|
+
n.__altText,
|
|
867
|
+
n.__width,
|
|
868
|
+
n.__height,
|
|
869
|
+
n.__alignment,
|
|
870
|
+
n.__key
|
|
871
|
+
);
|
|
872
|
+
}
|
|
873
|
+
constructor(n, o, i, r, s = "", f) {
|
|
874
|
+
super(f), this.__src = n, this.__altText = o, this.__width = i, this.__height = r, this.__alignment = s;
|
|
875
|
+
}
|
|
876
|
+
getAlignment() {
|
|
877
|
+
return this.getLatest().__alignment;
|
|
878
|
+
}
|
|
879
|
+
setAlignment(n) {
|
|
880
|
+
const o = this.getWritable();
|
|
881
|
+
o.__alignment = n;
|
|
882
|
+
}
|
|
883
|
+
createDOM() {
|
|
884
|
+
const n = document.createElement("div");
|
|
885
|
+
return n.className = "silk-image-wrapper", this.__alignment && this.__alignment !== "left" && (n.style.textAlign = this.__alignment), n;
|
|
886
|
+
}
|
|
887
|
+
updateDOM(n, o) {
|
|
888
|
+
return n.__alignment !== this.__alignment && (o.style.textAlign = this.__alignment && this.__alignment !== "left" ? this.__alignment : ""), !1;
|
|
889
|
+
}
|
|
890
|
+
isInline() {
|
|
891
|
+
return !1;
|
|
892
|
+
}
|
|
893
|
+
isKeyboardSelectable() {
|
|
894
|
+
return !0;
|
|
895
|
+
}
|
|
896
|
+
static importJSON(n) {
|
|
897
|
+
return te(
|
|
898
|
+
n.src,
|
|
899
|
+
n.altText,
|
|
900
|
+
n.width,
|
|
901
|
+
n.height,
|
|
902
|
+
n.alignment
|
|
903
|
+
);
|
|
904
|
+
}
|
|
905
|
+
exportJSON() {
|
|
906
|
+
return {
|
|
907
|
+
...super.exportJSON(),
|
|
908
|
+
src: this.__src,
|
|
909
|
+
altText: this.__altText,
|
|
910
|
+
width: this.__width,
|
|
911
|
+
height: this.__height,
|
|
912
|
+
alignment: this.__alignment || void 0
|
|
913
|
+
};
|
|
914
|
+
}
|
|
915
|
+
exportDOM() {
|
|
916
|
+
const n = document.createElement("img");
|
|
917
|
+
return n.src = this.__src, n.alt = this.__altText, this.__width && (n.width = this.__width), this.__height && (n.height = this.__height), { element: n };
|
|
918
|
+
}
|
|
919
|
+
static importDOM() {
|
|
920
|
+
return {
|
|
921
|
+
img: () => ({
|
|
922
|
+
conversion: (n) => {
|
|
923
|
+
const o = n;
|
|
924
|
+
return {
|
|
925
|
+
node: te(
|
|
926
|
+
o.src,
|
|
927
|
+
o.alt || "",
|
|
928
|
+
o.naturalWidth || void 0,
|
|
929
|
+
o.naturalHeight || void 0
|
|
930
|
+
)
|
|
931
|
+
};
|
|
932
|
+
},
|
|
933
|
+
priority: 0
|
|
934
|
+
})
|
|
935
|
+
};
|
|
936
|
+
}
|
|
937
|
+
decorate(n) {
|
|
938
|
+
return /* @__PURE__ */ t(
|
|
939
|
+
on,
|
|
940
|
+
{
|
|
941
|
+
src: this.__src,
|
|
942
|
+
altText: this.__altText,
|
|
943
|
+
width: this.__width,
|
|
944
|
+
height: this.__height,
|
|
945
|
+
nodeKey: this.__key
|
|
946
|
+
}
|
|
947
|
+
);
|
|
948
|
+
}
|
|
949
|
+
}
|
|
950
|
+
function te(e, n = "", o, i, r) {
|
|
951
|
+
return Ze(
|
|
952
|
+
new j(e, n, o, i, r)
|
|
953
|
+
);
|
|
954
|
+
}
|
|
955
|
+
function ne(e) {
|
|
956
|
+
return e instanceof j;
|
|
957
|
+
}
|
|
958
|
+
const xe = [
|
|
761
959
|
{ value: null, label: "Default" },
|
|
762
960
|
{ value: "#9c9a94", label: "Muted" },
|
|
763
961
|
{ value: "#ac3521", label: "Alert" },
|
|
764
962
|
{ value: "#5a6340", label: "Emphasis" },
|
|
765
963
|
{ value: "#7e572e", label: "Accent" },
|
|
766
964
|
{ value: "#4a5568", label: "Secondary" }
|
|
767
|
-
],
|
|
965
|
+
], K = [
|
|
768
966
|
{ value: null, label: "Inter", css: '"Inter", sans-serif' },
|
|
769
967
|
{
|
|
770
968
|
value: '"SF Mono", "Fira Code", "Fira Mono", Menlo, Consolas, monospace',
|
|
@@ -777,181 +975,205 @@ const Ne = [
|
|
|
777
975
|
css: '"Space Grotesk", sans-serif'
|
|
778
976
|
}
|
|
779
977
|
];
|
|
780
|
-
function
|
|
781
|
-
return e ? e.includes("SF Mono") || e.includes("Fira Code") ?
|
|
978
|
+
function sn(e) {
|
|
979
|
+
return e ? e.includes("SF Mono") || e.includes("Fira Code") ? K[1].value : e.includes("Space Grotesk") ? K[2].value : null : null;
|
|
782
980
|
}
|
|
783
|
-
const
|
|
784
|
-
function
|
|
785
|
-
const [e] =
|
|
981
|
+
const le = 10, ae = 36, he = 16;
|
|
982
|
+
function _e() {
|
|
983
|
+
const [e] = E(), [n, o] = C(/* @__PURE__ */ new Set()), [i, r] = C(he), [s, f] = C(null), [l, a] = C(
|
|
786
984
|
null
|
|
787
|
-
), c =
|
|
985
|
+
), [c, d] = C(""), p = M(() => {
|
|
788
986
|
e.getEditorState().read(() => {
|
|
789
|
-
const
|
|
790
|
-
if (
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
987
|
+
const h = L();
|
|
988
|
+
if (ee(h)) {
|
|
989
|
+
const F = h.getNodes();
|
|
990
|
+
if (F.length > 0) {
|
|
991
|
+
const $ = F[0];
|
|
992
|
+
ne($) && d($.getAlignment() || "");
|
|
993
|
+
}
|
|
994
|
+
return;
|
|
995
|
+
}
|
|
996
|
+
if (!T(h)) return;
|
|
997
|
+
const N = /* @__PURE__ */ new Set();
|
|
998
|
+
h.hasFormat("bold") && N.add("bold"), h.hasFormat("italic") && N.add("italic"), h.hasFormat("underline") && N.add("underline"), h.hasFormat("code") && N.add("code"), o(N);
|
|
999
|
+
const y = q(
|
|
1000
|
+
h,
|
|
795
1001
|
"font-size",
|
|
796
1002
|
""
|
|
797
1003
|
);
|
|
798
|
-
|
|
799
|
-
const
|
|
800
|
-
|
|
1004
|
+
r(y ? parseInt(y, 10) : he);
|
|
1005
|
+
const b = q(
|
|
1006
|
+
h,
|
|
801
1007
|
"color",
|
|
802
1008
|
""
|
|
803
1009
|
);
|
|
804
|
-
|
|
805
|
-
const
|
|
806
|
-
|
|
1010
|
+
f(b || null);
|
|
1011
|
+
const I = q(
|
|
1012
|
+
h,
|
|
807
1013
|
"font-family",
|
|
808
1014
|
""
|
|
809
1015
|
);
|
|
810
|
-
a(
|
|
1016
|
+
a(sn(I || null));
|
|
1017
|
+
const W = h.anchor.getNode().getTopLevelElement();
|
|
1018
|
+
W && d(W.getFormatType() || "");
|
|
811
1019
|
});
|
|
812
1020
|
}, [e]);
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
() => (
|
|
816
|
-
|
|
817
|
-
), [e,
|
|
818
|
-
const
|
|
819
|
-
(
|
|
820
|
-
e.dispatchCommand(
|
|
1021
|
+
_(() => e.registerCommand(
|
|
1022
|
+
ye,
|
|
1023
|
+
() => (p(), !1),
|
|
1024
|
+
H
|
|
1025
|
+
), [e, p]), _(() => e.registerUpdateListener(() => p()), [e, p]);
|
|
1026
|
+
const g = M(
|
|
1027
|
+
(h) => {
|
|
1028
|
+
e.dispatchCommand(ot, h);
|
|
821
1029
|
},
|
|
822
1030
|
[e]
|
|
823
|
-
),
|
|
824
|
-
(
|
|
825
|
-
const
|
|
826
|
-
|
|
827
|
-
Math.min(
|
|
1031
|
+
), S = M(
|
|
1032
|
+
(h) => {
|
|
1033
|
+
const N = Math.max(
|
|
1034
|
+
le,
|
|
1035
|
+
Math.min(ae, i + h)
|
|
828
1036
|
);
|
|
829
1037
|
e.update(() => {
|
|
830
|
-
const
|
|
831
|
-
|
|
1038
|
+
const y = L();
|
|
1039
|
+
T(y) && Z(y, { "font-size": `${N}px` });
|
|
832
1040
|
});
|
|
833
1041
|
},
|
|
834
|
-
[e,
|
|
835
|
-
),
|
|
836
|
-
(
|
|
1042
|
+
[e, i]
|
|
1043
|
+
), u = M(
|
|
1044
|
+
(h) => {
|
|
837
1045
|
e.update(() => {
|
|
838
|
-
const
|
|
839
|
-
|
|
1046
|
+
const N = L();
|
|
1047
|
+
T(N) && Z(N, { color: h });
|
|
840
1048
|
});
|
|
841
1049
|
},
|
|
842
1050
|
[e]
|
|
843
|
-
),
|
|
844
|
-
(
|
|
1051
|
+
), x = M(
|
|
1052
|
+
(h) => {
|
|
845
1053
|
e.update(() => {
|
|
846
|
-
const
|
|
847
|
-
|
|
1054
|
+
const N = L();
|
|
1055
|
+
T(N) && Z(N, { "font-family": h });
|
|
848
1056
|
});
|
|
849
1057
|
},
|
|
850
1058
|
[e]
|
|
851
|
-
),
|
|
1059
|
+
), w = M(() => {
|
|
852
1060
|
e.getEditorState().read(() => {
|
|
853
|
-
const
|
|
854
|
-
if (
|
|
855
|
-
const
|
|
856
|
-
e.dispatchCommand(
|
|
1061
|
+
const h = L();
|
|
1062
|
+
if (T(h)) {
|
|
1063
|
+
const N = h.getTextContent();
|
|
1064
|
+
e.dispatchCommand(re, { text: N });
|
|
857
1065
|
}
|
|
858
1066
|
});
|
|
859
|
-
}, [e]),
|
|
1067
|
+
}, [e]), m = M(() => {
|
|
860
1068
|
e.update(() => {
|
|
861
|
-
const
|
|
862
|
-
|
|
1069
|
+
const h = L();
|
|
1070
|
+
T(h) && ut(h, () => Re());
|
|
863
1071
|
});
|
|
864
|
-
}, [e])
|
|
1072
|
+
}, [e]), v = M(
|
|
1073
|
+
(h) => {
|
|
1074
|
+
e.update(() => {
|
|
1075
|
+
const N = L();
|
|
1076
|
+
if (ee(N)) {
|
|
1077
|
+
for (const y of N.getNodes())
|
|
1078
|
+
ne(y) && y.setAlignment(h);
|
|
1079
|
+
return;
|
|
1080
|
+
}
|
|
1081
|
+
}), e.dispatchCommand(st, h);
|
|
1082
|
+
},
|
|
1083
|
+
[e]
|
|
1084
|
+
);
|
|
865
1085
|
return {
|
|
866
1086
|
formats: n,
|
|
867
|
-
fontSize:
|
|
868
|
-
currentColor:
|
|
1087
|
+
fontSize: i,
|
|
1088
|
+
currentColor: s,
|
|
869
1089
|
currentFontFamily: l,
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
1090
|
+
alignment: c,
|
|
1091
|
+
toggleFormat: g,
|
|
1092
|
+
changeFontSize: S,
|
|
1093
|
+
applyColor: u,
|
|
1094
|
+
applyFontFamily: x,
|
|
1095
|
+
openLinkDialog: w,
|
|
1096
|
+
insertQuote: m,
|
|
1097
|
+
applyAlignment: v
|
|
876
1098
|
};
|
|
877
1099
|
}
|
|
878
|
-
const
|
|
879
|
-
function
|
|
880
|
-
var
|
|
881
|
-
const [e] =
|
|
882
|
-
formats:
|
|
883
|
-
fontSize:
|
|
1100
|
+
const rn = 8;
|
|
1101
|
+
function ln() {
|
|
1102
|
+
var y;
|
|
1103
|
+
const [e] = E(), n = se(), o = B(null), [i, r] = C(!1), [s, f] = C({ top: 0, left: 0 }), [l, a] = C(!1), [c, d] = C(!1), {
|
|
1104
|
+
formats: p,
|
|
1105
|
+
fontSize: g,
|
|
884
1106
|
currentColor: S,
|
|
885
|
-
currentFontFamily:
|
|
886
|
-
toggleFormat:
|
|
887
|
-
changeFontSize:
|
|
888
|
-
applyColor:
|
|
889
|
-
applyFontFamily:
|
|
890
|
-
openLinkDialog:
|
|
891
|
-
} =
|
|
1107
|
+
currentFontFamily: u,
|
|
1108
|
+
toggleFormat: x,
|
|
1109
|
+
changeFontSize: w,
|
|
1110
|
+
applyColor: m,
|
|
1111
|
+
applyFontFamily: v,
|
|
1112
|
+
openLinkDialog: h
|
|
1113
|
+
} = _e(), N = M(() => {
|
|
892
1114
|
if (!e.isEditable()) {
|
|
893
|
-
|
|
1115
|
+
r(!1);
|
|
894
1116
|
return;
|
|
895
1117
|
}
|
|
896
|
-
let
|
|
1118
|
+
let I = !1;
|
|
897
1119
|
if (e.getEditorState().read(() => {
|
|
898
|
-
const
|
|
899
|
-
!
|
|
900
|
-
let
|
|
901
|
-
for (;
|
|
902
|
-
if (
|
|
903
|
-
|
|
1120
|
+
const V = L();
|
|
1121
|
+
!T(V) || V.isCollapsed() || V.getNodes().some((Se) => {
|
|
1122
|
+
let J = Se.getParent();
|
|
1123
|
+
for (; J; ) {
|
|
1124
|
+
if (oe(J)) return !0;
|
|
1125
|
+
J = J.getParent();
|
|
904
1126
|
}
|
|
905
1127
|
return !1;
|
|
906
|
-
}) || (
|
|
907
|
-
}), !
|
|
908
|
-
|
|
1128
|
+
}) || (I = !0);
|
|
1129
|
+
}), !I) {
|
|
1130
|
+
r(!1);
|
|
909
1131
|
return;
|
|
910
1132
|
}
|
|
911
|
-
const
|
|
912
|
-
if (!
|
|
913
|
-
|
|
1133
|
+
const z = window.getSelection();
|
|
1134
|
+
if (!z || z.rangeCount === 0) {
|
|
1135
|
+
r(!1);
|
|
914
1136
|
return;
|
|
915
1137
|
}
|
|
916
|
-
const
|
|
917
|
-
if (
|
|
918
|
-
|
|
1138
|
+
const F = z.getRangeAt(0).getBoundingClientRect(), $ = n.current;
|
|
1139
|
+
if (!$) {
|
|
1140
|
+
r(!1);
|
|
919
1141
|
return;
|
|
920
1142
|
}
|
|
921
|
-
const
|
|
922
|
-
let
|
|
923
|
-
|
|
924
|
-
top:
|
|
925
|
-
left:
|
|
926
|
-
}),
|
|
1143
|
+
const O = $.getBoundingClientRect(), P = o.current, D = (P == null ? void 0 : P.offsetWidth) ?? 300;
|
|
1144
|
+
let R = F.left - O.left + F.width / 2;
|
|
1145
|
+
R = Math.max(D / 2 + 4, R), R = Math.min(O.width - D / 2 - 4, R), f({
|
|
1146
|
+
top: F.top - O.top - rn,
|
|
1147
|
+
left: R
|
|
1148
|
+
}), r(!0);
|
|
927
1149
|
}, [e, n]);
|
|
928
|
-
return
|
|
929
|
-
|
|
930
|
-
() => (
|
|
931
|
-
|
|
932
|
-
), [e,
|
|
1150
|
+
return _(() => e.registerCommand(
|
|
1151
|
+
ye,
|
|
1152
|
+
() => (N(), !1),
|
|
1153
|
+
H
|
|
1154
|
+
), [e, N]), _(() => e.registerUpdateListener(() => N()), [e, N]), _(() => {
|
|
933
1155
|
if (!l && !c) return;
|
|
934
|
-
const
|
|
935
|
-
|
|
1156
|
+
const b = (I) => {
|
|
1157
|
+
o.current && !o.current.contains(I.target) && (a(!1), d(!1));
|
|
936
1158
|
};
|
|
937
|
-
return document.addEventListener("mousedown",
|
|
938
|
-
}, [l, c]),
|
|
1159
|
+
return document.addEventListener("mousedown", b), () => document.removeEventListener("mousedown", b);
|
|
1160
|
+
}, [l, c]), i ? /* @__PURE__ */ k(
|
|
939
1161
|
"div",
|
|
940
1162
|
{
|
|
941
|
-
ref:
|
|
1163
|
+
ref: o,
|
|
942
1164
|
className: "silk-floating-toolbar",
|
|
943
1165
|
style: {
|
|
944
|
-
top:
|
|
945
|
-
left:
|
|
1166
|
+
top: s.top,
|
|
1167
|
+
left: s.left,
|
|
946
1168
|
transform: "translate(-50%, -100%)"
|
|
947
1169
|
},
|
|
948
|
-
onMouseDown: (
|
|
1170
|
+
onMouseDown: (b) => b.preventDefault(),
|
|
949
1171
|
children: [
|
|
950
1172
|
/* @__PURE__ */ t(
|
|
951
1173
|
"button",
|
|
952
1174
|
{
|
|
953
|
-
className: `silk-ft-btn${
|
|
954
|
-
onClick: () =>
|
|
1175
|
+
className: `silk-ft-btn${p.has("bold") ? " silk-ft-btn--active" : ""}`,
|
|
1176
|
+
onClick: () => x("bold"),
|
|
955
1177
|
type: "button",
|
|
956
1178
|
title: "Bold",
|
|
957
1179
|
children: /* @__PURE__ */ t("strong", { children: "B" })
|
|
@@ -960,8 +1182,8 @@ function nn() {
|
|
|
960
1182
|
/* @__PURE__ */ t(
|
|
961
1183
|
"button",
|
|
962
1184
|
{
|
|
963
|
-
className: `silk-ft-btn${
|
|
964
|
-
onClick: () =>
|
|
1185
|
+
className: `silk-ft-btn${p.has("italic") ? " silk-ft-btn--active" : ""}`,
|
|
1186
|
+
onClick: () => x("italic"),
|
|
965
1187
|
type: "button",
|
|
966
1188
|
title: "Italic",
|
|
967
1189
|
children: /* @__PURE__ */ t("em", { children: "I" })
|
|
@@ -970,8 +1192,8 @@ function nn() {
|
|
|
970
1192
|
/* @__PURE__ */ t(
|
|
971
1193
|
"button",
|
|
972
1194
|
{
|
|
973
|
-
className: `silk-ft-btn${
|
|
974
|
-
onClick: () =>
|
|
1195
|
+
className: `silk-ft-btn${p.has("underline") ? " silk-ft-btn--active" : ""}`,
|
|
1196
|
+
onClick: () => x("underline"),
|
|
975
1197
|
type: "button",
|
|
976
1198
|
title: "Underline",
|
|
977
1199
|
children: /* @__PURE__ */ t("span", { style: { textDecoration: "underline" }, children: "U" })
|
|
@@ -980,8 +1202,8 @@ function nn() {
|
|
|
980
1202
|
/* @__PURE__ */ t(
|
|
981
1203
|
"button",
|
|
982
1204
|
{
|
|
983
|
-
className: `silk-ft-btn silk-ft-btn--mono${
|
|
984
|
-
onClick: () =>
|
|
1205
|
+
className: `silk-ft-btn silk-ft-btn--mono${p.has("code") ? " silk-ft-btn--active" : ""}`,
|
|
1206
|
+
onClick: () => x("code"),
|
|
985
1207
|
type: "button",
|
|
986
1208
|
title: "Inline code",
|
|
987
1209
|
children: "</>"
|
|
@@ -992,10 +1214,10 @@ function nn() {
|
|
|
992
1214
|
"button",
|
|
993
1215
|
{
|
|
994
1216
|
className: "silk-ft-btn",
|
|
995
|
-
onClick:
|
|
1217
|
+
onClick: h,
|
|
996
1218
|
type: "button",
|
|
997
1219
|
title: "Insert link",
|
|
998
|
-
children: /* @__PURE__ */
|
|
1220
|
+
children: /* @__PURE__ */ k(
|
|
999
1221
|
"svg",
|
|
1000
1222
|
{
|
|
1001
1223
|
width: "15",
|
|
@@ -1015,25 +1237,25 @@ function nn() {
|
|
|
1015
1237
|
}
|
|
1016
1238
|
),
|
|
1017
1239
|
/* @__PURE__ */ t("div", { className: "silk-ft-sep" }),
|
|
1018
|
-
/* @__PURE__ */
|
|
1240
|
+
/* @__PURE__ */ k("div", { className: "silk-ft-font-size", children: [
|
|
1019
1241
|
/* @__PURE__ */ t(
|
|
1020
1242
|
"button",
|
|
1021
1243
|
{
|
|
1022
1244
|
className: "silk-ft-btn silk-ft-btn--sm",
|
|
1023
|
-
onClick: () =>
|
|
1024
|
-
disabled:
|
|
1245
|
+
onClick: () => w(-1),
|
|
1246
|
+
disabled: g <= le,
|
|
1025
1247
|
type: "button",
|
|
1026
1248
|
title: "Decrease font size",
|
|
1027
1249
|
children: "−"
|
|
1028
1250
|
}
|
|
1029
1251
|
),
|
|
1030
|
-
/* @__PURE__ */ t("span", { className: "silk-ft-font-size-value", children:
|
|
1252
|
+
/* @__PURE__ */ t("span", { className: "silk-ft-font-size-value", children: g }),
|
|
1031
1253
|
/* @__PURE__ */ t(
|
|
1032
1254
|
"button",
|
|
1033
1255
|
{
|
|
1034
1256
|
className: "silk-ft-btn silk-ft-btn--sm",
|
|
1035
|
-
onClick: () =>
|
|
1036
|
-
disabled:
|
|
1257
|
+
onClick: () => w(1),
|
|
1258
|
+
disabled: g >= ae,
|
|
1037
1259
|
type: "button",
|
|
1038
1260
|
title: "Increase font size",
|
|
1039
1261
|
children: "+"
|
|
@@ -1041,13 +1263,13 @@ function nn() {
|
|
|
1041
1263
|
)
|
|
1042
1264
|
] }),
|
|
1043
1265
|
/* @__PURE__ */ t("div", { className: "silk-ft-sep" }),
|
|
1044
|
-
/* @__PURE__ */
|
|
1266
|
+
/* @__PURE__ */ k("div", { className: "silk-ft-color-wrap", children: [
|
|
1045
1267
|
/* @__PURE__ */ t(
|
|
1046
1268
|
"button",
|
|
1047
1269
|
{
|
|
1048
1270
|
className: `silk-ft-btn silk-ft-btn--color${l ? " silk-ft-btn--active" : ""}`,
|
|
1049
1271
|
onClick: () => {
|
|
1050
|
-
a(!l),
|
|
1272
|
+
a(!l), d(!1);
|
|
1051
1273
|
},
|
|
1052
1274
|
type: "button",
|
|
1053
1275
|
title: "Text color",
|
|
@@ -1061,17 +1283,17 @@ function nn() {
|
|
|
1061
1283
|
)
|
|
1062
1284
|
}
|
|
1063
1285
|
),
|
|
1064
|
-
l && /* @__PURE__ */ t("div", { className: "silk-ft-color-grid", children:
|
|
1286
|
+
l && /* @__PURE__ */ t("div", { className: "silk-ft-color-grid", children: xe.map((b) => /* @__PURE__ */ t(
|
|
1065
1287
|
"button",
|
|
1066
1288
|
{
|
|
1067
|
-
className: `silk-ft-color-swatch${S ===
|
|
1289
|
+
className: `silk-ft-color-swatch${S === b.value || !S && b.value === null ? " silk-ft-color-swatch--active" : ""}`,
|
|
1068
1290
|
onClick: () => {
|
|
1069
|
-
|
|
1291
|
+
m(b.value), a(!1);
|
|
1070
1292
|
},
|
|
1071
1293
|
type: "button",
|
|
1072
|
-
title:
|
|
1073
|
-
style:
|
|
1074
|
-
children:
|
|
1294
|
+
title: b.label,
|
|
1295
|
+
style: b.value ? { backgroundColor: b.value } : void 0,
|
|
1296
|
+
children: b.value === null && /* @__PURE__ */ k(
|
|
1075
1297
|
"svg",
|
|
1076
1298
|
{
|
|
1077
1299
|
width: "14",
|
|
@@ -1087,80 +1309,82 @@ function nn() {
|
|
|
1087
1309
|
}
|
|
1088
1310
|
)
|
|
1089
1311
|
},
|
|
1090
|
-
|
|
1312
|
+
b.value ?? "default"
|
|
1091
1313
|
)) })
|
|
1092
1314
|
] }),
|
|
1093
1315
|
/* @__PURE__ */ t("div", { className: "silk-ft-sep" }),
|
|
1094
|
-
/* @__PURE__ */
|
|
1316
|
+
/* @__PURE__ */ k("div", { className: "silk-ft-font-wrap", children: [
|
|
1095
1317
|
/* @__PURE__ */ t(
|
|
1096
1318
|
"button",
|
|
1097
1319
|
{
|
|
1098
1320
|
className: `silk-ft-btn${c ? " silk-ft-btn--active" : ""}`,
|
|
1099
1321
|
onClick: () => {
|
|
1100
|
-
|
|
1322
|
+
d(!c), a(!1);
|
|
1101
1323
|
},
|
|
1102
1324
|
type: "button",
|
|
1103
1325
|
title: "Font family",
|
|
1104
1326
|
style: {
|
|
1105
|
-
fontFamily: ((
|
|
1327
|
+
fontFamily: ((y = K.find((b) => b.value === u)) == null ? void 0 : y.css) ?? '"Inter", sans-serif',
|
|
1106
1328
|
fontSize: 12,
|
|
1107
1329
|
fontWeight: 500
|
|
1108
1330
|
},
|
|
1109
1331
|
children: "Aa"
|
|
1110
1332
|
}
|
|
1111
1333
|
),
|
|
1112
|
-
c && /* @__PURE__ */ t("div", { className: "silk-ft-font-dropdown", children:
|
|
1334
|
+
c && /* @__PURE__ */ t("div", { className: "silk-ft-font-dropdown", children: K.map((b) => /* @__PURE__ */ t(
|
|
1113
1335
|
"button",
|
|
1114
1336
|
{
|
|
1115
|
-
className: `silk-ft-font-option${
|
|
1337
|
+
className: `silk-ft-font-option${u === b.value ? " silk-ft-font-option--active" : ""}`,
|
|
1116
1338
|
onClick: () => {
|
|
1117
|
-
|
|
1339
|
+
v(b.value), d(!1);
|
|
1118
1340
|
},
|
|
1119
|
-
onMouseDown: (
|
|
1341
|
+
onMouseDown: (I) => I.preventDefault(),
|
|
1120
1342
|
type: "button",
|
|
1121
|
-
style: { fontFamily:
|
|
1122
|
-
children:
|
|
1343
|
+
style: { fontFamily: b.css },
|
|
1344
|
+
children: b.label
|
|
1123
1345
|
},
|
|
1124
|
-
|
|
1346
|
+
b.label
|
|
1125
1347
|
)) })
|
|
1126
1348
|
] })
|
|
1127
1349
|
]
|
|
1128
1350
|
}
|
|
1129
1351
|
) : null;
|
|
1130
1352
|
}
|
|
1131
|
-
function
|
|
1132
|
-
var
|
|
1133
|
-
const [e] =
|
|
1353
|
+
function an() {
|
|
1354
|
+
var N;
|
|
1355
|
+
const [e] = E(), [n, o] = C(() => e.isEditable()), i = B(null), [r, s] = C(!1), [f, l] = C(!1), {
|
|
1134
1356
|
formats: a,
|
|
1135
1357
|
fontSize: c,
|
|
1136
|
-
currentColor:
|
|
1137
|
-
currentFontFamily:
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1358
|
+
currentColor: d,
|
|
1359
|
+
currentFontFamily: p,
|
|
1360
|
+
alignment: g,
|
|
1361
|
+
toggleFormat: S,
|
|
1362
|
+
changeFontSize: u,
|
|
1363
|
+
applyColor: x,
|
|
1364
|
+
applyFontFamily: w,
|
|
1365
|
+
openLinkDialog: m,
|
|
1366
|
+
insertQuote: v,
|
|
1367
|
+
applyAlignment: h
|
|
1368
|
+
} = _e();
|
|
1369
|
+
return _(() => e.registerEditableListener(o), [e]), _(() => {
|
|
1370
|
+
if (!r && !f) return;
|
|
1371
|
+
const y = (b) => {
|
|
1372
|
+
i.current && !i.current.contains(b.target) && (s(!1), l(!1));
|
|
1149
1373
|
};
|
|
1150
|
-
return document.addEventListener("mousedown",
|
|
1151
|
-
}, [
|
|
1374
|
+
return document.addEventListener("mousedown", y), () => document.removeEventListener("mousedown", y);
|
|
1375
|
+
}, [r, f]), /* @__PURE__ */ k(
|
|
1152
1376
|
"div",
|
|
1153
1377
|
{
|
|
1154
|
-
ref:
|
|
1378
|
+
ref: i,
|
|
1155
1379
|
className: "silk-toolbar",
|
|
1156
1380
|
style: n ? void 0 : { display: "none" },
|
|
1157
|
-
onMouseDown: (
|
|
1381
|
+
onMouseDown: (y) => y.preventDefault(),
|
|
1158
1382
|
children: [
|
|
1159
1383
|
/* @__PURE__ */ t(
|
|
1160
1384
|
"button",
|
|
1161
1385
|
{
|
|
1162
1386
|
className: `silk-ft-btn${a.has("bold") ? " silk-ft-btn--active" : ""}`,
|
|
1163
|
-
onClick: () =>
|
|
1387
|
+
onClick: () => S("bold"),
|
|
1164
1388
|
type: "button",
|
|
1165
1389
|
title: "Bold",
|
|
1166
1390
|
children: /* @__PURE__ */ t("strong", { children: "B" })
|
|
@@ -1170,7 +1394,7 @@ function on() {
|
|
|
1170
1394
|
"button",
|
|
1171
1395
|
{
|
|
1172
1396
|
className: `silk-ft-btn${a.has("italic") ? " silk-ft-btn--active" : ""}`,
|
|
1173
|
-
onClick: () =>
|
|
1397
|
+
onClick: () => S("italic"),
|
|
1174
1398
|
type: "button",
|
|
1175
1399
|
title: "Italic",
|
|
1176
1400
|
children: /* @__PURE__ */ t("em", { children: "I" })
|
|
@@ -1180,7 +1404,7 @@ function on() {
|
|
|
1180
1404
|
"button",
|
|
1181
1405
|
{
|
|
1182
1406
|
className: `silk-ft-btn${a.has("underline") ? " silk-ft-btn--active" : ""}`,
|
|
1183
|
-
onClick: () =>
|
|
1407
|
+
onClick: () => S("underline"),
|
|
1184
1408
|
type: "button",
|
|
1185
1409
|
title: "Underline",
|
|
1186
1410
|
children: /* @__PURE__ */ t("span", { style: { textDecoration: "underline" }, children: "U" })
|
|
@@ -1190,7 +1414,7 @@ function on() {
|
|
|
1190
1414
|
"button",
|
|
1191
1415
|
{
|
|
1192
1416
|
className: `silk-ft-btn silk-ft-btn--mono${a.has("code") ? " silk-ft-btn--active" : ""}`,
|
|
1193
|
-
onClick: () =>
|
|
1417
|
+
onClick: () => S("code"),
|
|
1194
1418
|
type: "button",
|
|
1195
1419
|
title: "Inline code",
|
|
1196
1420
|
children: "</>"
|
|
@@ -1201,10 +1425,10 @@ function on() {
|
|
|
1201
1425
|
"button",
|
|
1202
1426
|
{
|
|
1203
1427
|
className: "silk-ft-btn",
|
|
1204
|
-
onClick:
|
|
1428
|
+
onClick: m,
|
|
1205
1429
|
type: "button",
|
|
1206
1430
|
title: "Insert link",
|
|
1207
|
-
children: /* @__PURE__ */
|
|
1431
|
+
children: /* @__PURE__ */ k(
|
|
1208
1432
|
"svg",
|
|
1209
1433
|
{
|
|
1210
1434
|
width: "15",
|
|
@@ -1227,10 +1451,10 @@ function on() {
|
|
|
1227
1451
|
"button",
|
|
1228
1452
|
{
|
|
1229
1453
|
className: "silk-ft-btn",
|
|
1230
|
-
onClick:
|
|
1454
|
+
onClick: v,
|
|
1231
1455
|
type: "button",
|
|
1232
1456
|
title: "Block quote",
|
|
1233
|
-
children: /* @__PURE__ */
|
|
1457
|
+
children: /* @__PURE__ */ k(
|
|
1234
1458
|
"svg",
|
|
1235
1459
|
{
|
|
1236
1460
|
width: "15",
|
|
@@ -1251,13 +1475,66 @@ function on() {
|
|
|
1251
1475
|
}
|
|
1252
1476
|
),
|
|
1253
1477
|
/* @__PURE__ */ t("div", { className: "silk-ft-sep" }),
|
|
1254
|
-
/* @__PURE__ */
|
|
1478
|
+
/* @__PURE__ */ t(
|
|
1479
|
+
"button",
|
|
1480
|
+
{
|
|
1481
|
+
className: `silk-ft-btn${g === "" || g === "left" ? " silk-ft-btn--active" : ""}`,
|
|
1482
|
+
onClick: () => h("left"),
|
|
1483
|
+
type: "button",
|
|
1484
|
+
title: "Align left",
|
|
1485
|
+
children: /* @__PURE__ */ k(
|
|
1486
|
+
"svg",
|
|
1487
|
+
{
|
|
1488
|
+
width: "15",
|
|
1489
|
+
height: "15",
|
|
1490
|
+
viewBox: "0 0 24 24",
|
|
1491
|
+
fill: "none",
|
|
1492
|
+
stroke: "currentColor",
|
|
1493
|
+
strokeWidth: 2,
|
|
1494
|
+
strokeLinecap: "round",
|
|
1495
|
+
children: [
|
|
1496
|
+
/* @__PURE__ */ t("line", { x1: "3", y1: "6", x2: "21", y2: "6" }),
|
|
1497
|
+
/* @__PURE__ */ t("line", { x1: "3", y1: "12", x2: "15", y2: "12" }),
|
|
1498
|
+
/* @__PURE__ */ t("line", { x1: "3", y1: "18", x2: "18", y2: "18" })
|
|
1499
|
+
]
|
|
1500
|
+
}
|
|
1501
|
+
)
|
|
1502
|
+
}
|
|
1503
|
+
),
|
|
1504
|
+
/* @__PURE__ */ t(
|
|
1505
|
+
"button",
|
|
1506
|
+
{
|
|
1507
|
+
className: `silk-ft-btn${g === "center" ? " silk-ft-btn--active" : ""}`,
|
|
1508
|
+
onClick: () => h("center"),
|
|
1509
|
+
type: "button",
|
|
1510
|
+
title: "Align center",
|
|
1511
|
+
children: /* @__PURE__ */ k(
|
|
1512
|
+
"svg",
|
|
1513
|
+
{
|
|
1514
|
+
width: "15",
|
|
1515
|
+
height: "15",
|
|
1516
|
+
viewBox: "0 0 24 24",
|
|
1517
|
+
fill: "none",
|
|
1518
|
+
stroke: "currentColor",
|
|
1519
|
+
strokeWidth: 2,
|
|
1520
|
+
strokeLinecap: "round",
|
|
1521
|
+
children: [
|
|
1522
|
+
/* @__PURE__ */ t("line", { x1: "3", y1: "6", x2: "21", y2: "6" }),
|
|
1523
|
+
/* @__PURE__ */ t("line", { x1: "6", y1: "12", x2: "18", y2: "12" }),
|
|
1524
|
+
/* @__PURE__ */ t("line", { x1: "5", y1: "18", x2: "19", y2: "18" })
|
|
1525
|
+
]
|
|
1526
|
+
}
|
|
1527
|
+
)
|
|
1528
|
+
}
|
|
1529
|
+
),
|
|
1530
|
+
/* @__PURE__ */ t("div", { className: "silk-ft-sep" }),
|
|
1531
|
+
/* @__PURE__ */ k("div", { className: "silk-ft-font-size", children: [
|
|
1255
1532
|
/* @__PURE__ */ t(
|
|
1256
1533
|
"button",
|
|
1257
1534
|
{
|
|
1258
1535
|
className: "silk-ft-btn silk-ft-btn--sm",
|
|
1259
|
-
onClick: () =>
|
|
1260
|
-
disabled: c <=
|
|
1536
|
+
onClick: () => u(-1),
|
|
1537
|
+
disabled: c <= le,
|
|
1261
1538
|
type: "button",
|
|
1262
1539
|
title: "Decrease font size",
|
|
1263
1540
|
children: "−"
|
|
@@ -1268,8 +1545,8 @@ function on() {
|
|
|
1268
1545
|
"button",
|
|
1269
1546
|
{
|
|
1270
1547
|
className: "silk-ft-btn silk-ft-btn--sm",
|
|
1271
|
-
onClick: () =>
|
|
1272
|
-
disabled: c >=
|
|
1548
|
+
onClick: () => u(1),
|
|
1549
|
+
disabled: c >= ae,
|
|
1273
1550
|
type: "button",
|
|
1274
1551
|
title: "Increase font size",
|
|
1275
1552
|
children: "+"
|
|
@@ -1277,13 +1554,13 @@ function on() {
|
|
|
1277
1554
|
)
|
|
1278
1555
|
] }),
|
|
1279
1556
|
/* @__PURE__ */ t("div", { className: "silk-ft-sep" }),
|
|
1280
|
-
/* @__PURE__ */
|
|
1557
|
+
/* @__PURE__ */ k("div", { className: "silk-ft-color-wrap", children: [
|
|
1281
1558
|
/* @__PURE__ */ t(
|
|
1282
1559
|
"button",
|
|
1283
1560
|
{
|
|
1284
|
-
className: `silk-ft-btn silk-ft-btn--color${
|
|
1561
|
+
className: `silk-ft-btn silk-ft-btn--color${r ? " silk-ft-btn--active" : ""}`,
|
|
1285
1562
|
onClick: () => {
|
|
1286
|
-
|
|
1563
|
+
s(!r), l(!1);
|
|
1287
1564
|
},
|
|
1288
1565
|
type: "button",
|
|
1289
1566
|
title: "Text color",
|
|
@@ -1291,23 +1568,23 @@ function on() {
|
|
|
1291
1568
|
"span",
|
|
1292
1569
|
{
|
|
1293
1570
|
className: "silk-ft-color-indicator",
|
|
1294
|
-
style: { borderBottomColor:
|
|
1571
|
+
style: { borderBottomColor: d || "#1a1a1a" },
|
|
1295
1572
|
children: "A"
|
|
1296
1573
|
}
|
|
1297
1574
|
)
|
|
1298
1575
|
}
|
|
1299
1576
|
),
|
|
1300
|
-
|
|
1577
|
+
r && /* @__PURE__ */ t("div", { className: "silk-ft-color-grid", children: xe.map((y) => /* @__PURE__ */ t(
|
|
1301
1578
|
"button",
|
|
1302
1579
|
{
|
|
1303
|
-
className: `silk-ft-color-swatch${
|
|
1580
|
+
className: `silk-ft-color-swatch${d === y.value || !d && y.value === null ? " silk-ft-color-swatch--active" : ""}`,
|
|
1304
1581
|
onClick: () => {
|
|
1305
|
-
|
|
1582
|
+
x(y.value), s(!1);
|
|
1306
1583
|
},
|
|
1307
1584
|
type: "button",
|
|
1308
|
-
title:
|
|
1309
|
-
style:
|
|
1310
|
-
children:
|
|
1585
|
+
title: y.label,
|
|
1586
|
+
style: y.value ? { backgroundColor: y.value } : void 0,
|
|
1587
|
+
children: y.value === null && /* @__PURE__ */ k(
|
|
1311
1588
|
"svg",
|
|
1312
1589
|
{
|
|
1313
1590
|
width: "14",
|
|
@@ -1323,319 +1600,133 @@ function on() {
|
|
|
1323
1600
|
}
|
|
1324
1601
|
)
|
|
1325
1602
|
},
|
|
1326
|
-
|
|
1603
|
+
y.value ?? "default"
|
|
1327
1604
|
)) })
|
|
1328
1605
|
] }),
|
|
1329
1606
|
/* @__PURE__ */ t("div", { className: "silk-ft-sep" }),
|
|
1330
|
-
/* @__PURE__ */
|
|
1607
|
+
/* @__PURE__ */ k("div", { className: "silk-ft-font-wrap", children: [
|
|
1331
1608
|
/* @__PURE__ */ t(
|
|
1332
1609
|
"button",
|
|
1333
1610
|
{
|
|
1334
|
-
className: `silk-ft-btn${
|
|
1611
|
+
className: `silk-ft-btn${f ? " silk-ft-btn--active" : ""}`,
|
|
1335
1612
|
onClick: () => {
|
|
1336
|
-
l(!
|
|
1613
|
+
l(!f), s(!1);
|
|
1337
1614
|
},
|
|
1338
1615
|
type: "button",
|
|
1339
1616
|
title: "Font family",
|
|
1340
1617
|
style: {
|
|
1341
|
-
fontFamily: ((
|
|
1618
|
+
fontFamily: ((N = K.find((y) => y.value === p)) == null ? void 0 : N.css) ?? '"Inter", sans-serif',
|
|
1342
1619
|
fontSize: 12,
|
|
1343
1620
|
fontWeight: 500
|
|
1344
1621
|
},
|
|
1345
1622
|
children: "Aa"
|
|
1346
1623
|
}
|
|
1347
1624
|
),
|
|
1348
|
-
|
|
1625
|
+
f && /* @__PURE__ */ t("div", { className: "silk-ft-font-dropdown", children: K.map((y) => /* @__PURE__ */ t(
|
|
1349
1626
|
"button",
|
|
1350
1627
|
{
|
|
1351
|
-
className: `silk-ft-font-option${
|
|
1628
|
+
className: `silk-ft-font-option${p === y.value ? " silk-ft-font-option--active" : ""}`,
|
|
1352
1629
|
onClick: () => {
|
|
1353
|
-
|
|
1630
|
+
w(y.value), l(!1);
|
|
1354
1631
|
},
|
|
1355
|
-
onMouseDown: (
|
|
1632
|
+
onMouseDown: (b) => b.preventDefault(),
|
|
1356
1633
|
type: "button",
|
|
1357
|
-
style: { fontFamily:
|
|
1358
|
-
children:
|
|
1634
|
+
style: { fontFamily: y.css },
|
|
1635
|
+
children: y.label
|
|
1359
1636
|
},
|
|
1360
|
-
|
|
1637
|
+
y.label
|
|
1361
1638
|
)) })
|
|
1362
1639
|
] })
|
|
1363
1640
|
]
|
|
1364
1641
|
}
|
|
1365
1642
|
);
|
|
1366
1643
|
}
|
|
1367
|
-
function
|
|
1368
|
-
const [e] =
|
|
1369
|
-
return
|
|
1644
|
+
function cn() {
|
|
1645
|
+
const [e] = E();
|
|
1646
|
+
return _(() => {
|
|
1370
1647
|
const n = e.getRootElement();
|
|
1371
1648
|
if (!n) return;
|
|
1372
|
-
const
|
|
1373
|
-
if (e.isEditable() && !(
|
|
1374
|
-
const
|
|
1375
|
-
!
|
|
1376
|
-
const l =
|
|
1649
|
+
const o = (i) => {
|
|
1650
|
+
if (e.isEditable() && !(i.metaKey || i.ctrlKey)) return;
|
|
1651
|
+
const f = i.target.closest("a");
|
|
1652
|
+
!f || !n.contains(f) || e.getEditorState().read(() => {
|
|
1653
|
+
const l = rt(f);
|
|
1377
1654
|
if (!l) return;
|
|
1378
|
-
const a = l.getParent(), c =
|
|
1655
|
+
const a = l.getParent(), c = ue(l) ? l : ue(a) ? a : null;
|
|
1379
1656
|
if (c) {
|
|
1380
|
-
const
|
|
1381
|
-
|
|
1657
|
+
const d = c.getURL();
|
|
1658
|
+
d && (i.preventDefault(), window.open(d, "_blank", "noopener,noreferrer"));
|
|
1382
1659
|
}
|
|
1383
1660
|
});
|
|
1384
1661
|
};
|
|
1385
|
-
return n.addEventListener("click",
|
|
1662
|
+
return n.addEventListener("click", o), () => n.removeEventListener("click", o);
|
|
1386
1663
|
}, [e]), null;
|
|
1387
1664
|
}
|
|
1388
|
-
function
|
|
1389
|
-
const [e] =
|
|
1390
|
-
return
|
|
1391
|
-
}
|
|
1392
|
-
const ln = ["nw", "ne", "sw", "se"];
|
|
1393
|
-
function an({
|
|
1394
|
-
src: e,
|
|
1395
|
-
altText: n,
|
|
1396
|
-
width: i,
|
|
1397
|
-
height: o,
|
|
1398
|
-
nodeKey: s
|
|
1399
|
-
}) {
|
|
1400
|
-
const [r] = _(), h = F(null), l = F(null), [a, c, u] = at(s), [b, m] = C(!1), S = w(
|
|
1401
|
-
(d) => h.current && h.current.contains(d.target) ? (u(), c(!0), !0) : !1,
|
|
1402
|
-
[u, c]
|
|
1403
|
-
), f = w(
|
|
1404
|
-
(d) => a && !b ? (d.preventDefault(), r.update(() => {
|
|
1405
|
-
const k = H(s);
|
|
1406
|
-
k && k.remove();
|
|
1407
|
-
}), !0) : !1,
|
|
1408
|
-
[r, a, b, s]
|
|
1409
|
-
);
|
|
1410
|
-
x(() => {
|
|
1411
|
-
const d = r.registerCommand(
|
|
1412
|
-
tt,
|
|
1413
|
-
S,
|
|
1414
|
-
$
|
|
1415
|
-
), k = r.registerCommand(
|
|
1416
|
-
nt,
|
|
1417
|
-
f,
|
|
1418
|
-
$
|
|
1419
|
-
), g = r.registerCommand(
|
|
1420
|
-
ot,
|
|
1421
|
-
f,
|
|
1422
|
-
$
|
|
1423
|
-
);
|
|
1424
|
-
return () => {
|
|
1425
|
-
d(), k(), g();
|
|
1426
|
-
};
|
|
1427
|
-
}, [r, S, f]);
|
|
1428
|
-
const v = w(
|
|
1429
|
-
(d, k) => {
|
|
1430
|
-
k.preventDefault(), k.stopPropagation(), m(!0);
|
|
1431
|
-
const g = l.current;
|
|
1432
|
-
if (!g) return;
|
|
1433
|
-
const M = k.clientX, Y = k.clientY, N = g.offsetWidth, A = g.offsetHeight, P = N / A, Q = (B) => {
|
|
1434
|
-
let D = B.clientX - M;
|
|
1435
|
-
const R = B.clientY - Y;
|
|
1436
|
-
(d === "nw" || d === "sw") && (D = -D);
|
|
1437
|
-
let T;
|
|
1438
|
-
if (Math.abs(D) > Math.abs(R))
|
|
1439
|
-
T = Math.max(100, N + D);
|
|
1440
|
-
else {
|
|
1441
|
-
const K = d === "nw" || d === "ne" ? -R : R;
|
|
1442
|
-
T = Math.max(100, N + K * P);
|
|
1443
|
-
}
|
|
1444
|
-
const I = T / P;
|
|
1445
|
-
g.style.width = `${Math.round(T)}px`, g.style.height = `${Math.round(I)}px`;
|
|
1446
|
-
}, z = (B) => {
|
|
1447
|
-
document.removeEventListener("mousemove", Q), document.removeEventListener("mouseup", z), m(!1);
|
|
1448
|
-
const D = g.offsetWidth, R = g.offsetHeight;
|
|
1449
|
-
r.update(() => {
|
|
1450
|
-
const T = H(s);
|
|
1451
|
-
if (T && cn(T)) {
|
|
1452
|
-
const I = T.getWritable();
|
|
1453
|
-
I.__width = D, I.__height = R;
|
|
1454
|
-
}
|
|
1455
|
-
});
|
|
1456
|
-
};
|
|
1457
|
-
document.addEventListener("mousemove", Q), document.addEventListener("mouseup", z);
|
|
1458
|
-
},
|
|
1459
|
-
[r, s]
|
|
1460
|
-
), p = r.isEditable();
|
|
1461
|
-
return /* @__PURE__ */ y(
|
|
1462
|
-
"div",
|
|
1463
|
-
{
|
|
1464
|
-
ref: h,
|
|
1465
|
-
className: `silk-image-container${a ? " silk-image-container--selected" : ""}`,
|
|
1466
|
-
children: [
|
|
1467
|
-
/* @__PURE__ */ t(
|
|
1468
|
-
"img",
|
|
1469
|
-
{
|
|
1470
|
-
ref: l,
|
|
1471
|
-
src: e,
|
|
1472
|
-
alt: n,
|
|
1473
|
-
width: i,
|
|
1474
|
-
height: o,
|
|
1475
|
-
className: "silk-image",
|
|
1476
|
-
draggable: !1
|
|
1477
|
-
}
|
|
1478
|
-
),
|
|
1479
|
-
a && p && /* @__PURE__ */ t(te, { children: ln.map((d) => /* @__PURE__ */ t(
|
|
1480
|
-
"div",
|
|
1481
|
-
{
|
|
1482
|
-
className: `silk-image-handle silk-image-handle--${d}`,
|
|
1483
|
-
onMouseDown: (k) => v(d, k)
|
|
1484
|
-
},
|
|
1485
|
-
d
|
|
1486
|
-
)) })
|
|
1487
|
-
]
|
|
1488
|
-
}
|
|
1489
|
-
);
|
|
1490
|
-
}
|
|
1491
|
-
class V extends et {
|
|
1492
|
-
static getType() {
|
|
1493
|
-
return "image";
|
|
1494
|
-
}
|
|
1495
|
-
static clone(n) {
|
|
1496
|
-
return new V(
|
|
1497
|
-
n.__src,
|
|
1498
|
-
n.__altText,
|
|
1499
|
-
n.__width,
|
|
1500
|
-
n.__height,
|
|
1501
|
-
n.__key
|
|
1502
|
-
);
|
|
1503
|
-
}
|
|
1504
|
-
constructor(n, i, o, s, r) {
|
|
1505
|
-
super(r), this.__src = n, this.__altText = i, this.__width = o, this.__height = s;
|
|
1506
|
-
}
|
|
1507
|
-
createDOM() {
|
|
1508
|
-
const n = document.createElement("div");
|
|
1509
|
-
return n.className = "silk-image-wrapper", n;
|
|
1510
|
-
}
|
|
1511
|
-
updateDOM() {
|
|
1512
|
-
return !1;
|
|
1513
|
-
}
|
|
1514
|
-
isInline() {
|
|
1515
|
-
return !1;
|
|
1516
|
-
}
|
|
1517
|
-
isKeyboardSelectable() {
|
|
1518
|
-
return !0;
|
|
1519
|
-
}
|
|
1520
|
-
static importJSON(n) {
|
|
1521
|
-
return ee(
|
|
1522
|
-
n.src,
|
|
1523
|
-
n.altText,
|
|
1524
|
-
n.width,
|
|
1525
|
-
n.height
|
|
1526
|
-
);
|
|
1527
|
-
}
|
|
1528
|
-
exportJSON() {
|
|
1529
|
-
return {
|
|
1530
|
-
...super.exportJSON(),
|
|
1531
|
-
src: this.__src,
|
|
1532
|
-
altText: this.__altText,
|
|
1533
|
-
width: this.__width,
|
|
1534
|
-
height: this.__height
|
|
1535
|
-
};
|
|
1536
|
-
}
|
|
1537
|
-
exportDOM() {
|
|
1538
|
-
const n = document.createElement("img");
|
|
1539
|
-
return n.src = this.__src, n.alt = this.__altText, this.__width && (n.width = this.__width), this.__height && (n.height = this.__height), { element: n };
|
|
1540
|
-
}
|
|
1541
|
-
static importDOM() {
|
|
1542
|
-
return {
|
|
1543
|
-
img: () => ({
|
|
1544
|
-
conversion: (n) => {
|
|
1545
|
-
const i = n;
|
|
1546
|
-
return {
|
|
1547
|
-
node: ee(
|
|
1548
|
-
i.src,
|
|
1549
|
-
i.alt || "",
|
|
1550
|
-
i.naturalWidth || void 0,
|
|
1551
|
-
i.naturalHeight || void 0
|
|
1552
|
-
)
|
|
1553
|
-
};
|
|
1554
|
-
},
|
|
1555
|
-
priority: 0
|
|
1556
|
-
})
|
|
1557
|
-
};
|
|
1558
|
-
}
|
|
1559
|
-
decorate(n) {
|
|
1560
|
-
return /* @__PURE__ */ t(
|
|
1561
|
-
an,
|
|
1562
|
-
{
|
|
1563
|
-
src: this.__src,
|
|
1564
|
-
altText: this.__altText,
|
|
1565
|
-
width: this.__width,
|
|
1566
|
-
height: this.__height,
|
|
1567
|
-
nodeKey: this.__key
|
|
1568
|
-
}
|
|
1569
|
-
);
|
|
1570
|
-
}
|
|
1571
|
-
}
|
|
1572
|
-
function ee(e, n = "", i, o) {
|
|
1573
|
-
return Ze(new V(e, n, i, o));
|
|
1665
|
+
function dn() {
|
|
1666
|
+
const [e] = E();
|
|
1667
|
+
return _(() => He(e), [e]), /* @__PURE__ */ t(vt, {});
|
|
1574
1668
|
}
|
|
1575
|
-
function
|
|
1576
|
-
return e instanceof V;
|
|
1577
|
-
}
|
|
1578
|
-
function fe(e) {
|
|
1669
|
+
function me(e) {
|
|
1579
1670
|
return e.type.startsWith("image/");
|
|
1580
1671
|
}
|
|
1581
|
-
function
|
|
1582
|
-
return new Promise((n,
|
|
1583
|
-
const
|
|
1584
|
-
|
|
1672
|
+
function un(e) {
|
|
1673
|
+
return new Promise((n, o) => {
|
|
1674
|
+
const i = new FileReader();
|
|
1675
|
+
i.onload = () => n(i.result), i.onerror = () => o(i.error), i.readAsDataURL(e);
|
|
1585
1676
|
});
|
|
1586
1677
|
}
|
|
1587
|
-
function
|
|
1588
|
-
const [e] =
|
|
1589
|
-
return
|
|
1590
|
-
const n = (
|
|
1591
|
-
for (const
|
|
1592
|
-
|
|
1678
|
+
function fn() {
|
|
1679
|
+
const [e] = E();
|
|
1680
|
+
return _(() => {
|
|
1681
|
+
const n = (s) => {
|
|
1682
|
+
for (const f of s)
|
|
1683
|
+
un(f).then((l) => {
|
|
1593
1684
|
e.update(() => {
|
|
1594
|
-
const a =
|
|
1595
|
-
if (
|
|
1685
|
+
const a = te(l, f.name), c = L();
|
|
1686
|
+
if (T(c))
|
|
1596
1687
|
c.focus.getNode().getTopLevelElementOrThrow().insertAfter(a);
|
|
1597
|
-
else if (
|
|
1598
|
-
const
|
|
1599
|
-
|
|
1688
|
+
else if (ee(c)) {
|
|
1689
|
+
const d = c.getNodes(), g = d[d.length - 1].getTopLevelElement();
|
|
1690
|
+
g ? g.insertAfter(a) : fe().append(a);
|
|
1600
1691
|
} else
|
|
1601
|
-
|
|
1692
|
+
fe().append(a);
|
|
1602
1693
|
});
|
|
1603
1694
|
});
|
|
1604
|
-
},
|
|
1605
|
-
|
|
1606
|
-
(
|
|
1695
|
+
}, o = e.registerCommand(
|
|
1696
|
+
lt,
|
|
1697
|
+
(s) => {
|
|
1607
1698
|
var a;
|
|
1608
|
-
const
|
|
1609
|
-
if (!
|
|
1610
|
-
const l = Array.from(
|
|
1611
|
-
return l.length === 0 ? !1 : (
|
|
1699
|
+
const f = (a = s.clipboardData) == null ? void 0 : a.files;
|
|
1700
|
+
if (!f || f.length === 0) return !1;
|
|
1701
|
+
const l = Array.from(f).filter(me);
|
|
1702
|
+
return l.length === 0 ? !1 : (s.preventDefault(), n(l), !0);
|
|
1612
1703
|
},
|
|
1613
1704
|
X
|
|
1614
|
-
),
|
|
1615
|
-
|
|
1616
|
-
(
|
|
1705
|
+
), i = e.registerCommand(
|
|
1706
|
+
at,
|
|
1707
|
+
(s) => {
|
|
1617
1708
|
var a;
|
|
1618
|
-
const
|
|
1619
|
-
if (!
|
|
1620
|
-
const l = Array.from(
|
|
1621
|
-
return l.length === 0 ? !1 : (
|
|
1709
|
+
const f = (a = s.dataTransfer) == null ? void 0 : a.files;
|
|
1710
|
+
if (!f || f.length === 0) return !1;
|
|
1711
|
+
const l = Array.from(f).filter(me);
|
|
1712
|
+
return l.length === 0 ? !1 : (s.preventDefault(), n(l), !0);
|
|
1622
1713
|
},
|
|
1623
1714
|
X
|
|
1624
|
-
),
|
|
1625
|
-
|
|
1626
|
-
(
|
|
1715
|
+
), r = e.registerCommand(
|
|
1716
|
+
ct,
|
|
1717
|
+
(s) => {
|
|
1627
1718
|
var l;
|
|
1628
|
-
const
|
|
1629
|
-
return
|
|
1719
|
+
const f = (l = s.dataTransfer) == null ? void 0 : l.types;
|
|
1720
|
+
return f && f.includes("Files") ? (s.preventDefault(), !0) : !1;
|
|
1630
1721
|
},
|
|
1631
1722
|
X
|
|
1632
1723
|
);
|
|
1633
1724
|
return () => {
|
|
1634
|
-
|
|
1725
|
+
o(), i(), r();
|
|
1635
1726
|
};
|
|
1636
1727
|
}, [e]), null;
|
|
1637
1728
|
}
|
|
1638
|
-
const
|
|
1729
|
+
const hn = {
|
|
1639
1730
|
root: "silk-root",
|
|
1640
1731
|
paragraph: "silk-paragraph",
|
|
1641
1732
|
link: "silk-link",
|
|
@@ -1658,7 +1749,7 @@ const fn = {
|
|
|
1658
1749
|
strikethrough: "silk-text-strikethrough",
|
|
1659
1750
|
code: "silk-text-code"
|
|
1660
1751
|
}
|
|
1661
|
-
},
|
|
1752
|
+
}, mn = {
|
|
1662
1753
|
heading: {
|
|
1663
1754
|
h1: "silk-heading-h1",
|
|
1664
1755
|
h2: "silk-heading-h2",
|
|
@@ -1668,34 +1759,34 @@ const fn = {
|
|
|
1668
1759
|
}, pn = {
|
|
1669
1760
|
code: "silk-code-block"
|
|
1670
1761
|
};
|
|
1671
|
-
function
|
|
1762
|
+
function gn(...e) {
|
|
1672
1763
|
const n = {};
|
|
1673
|
-
for (const
|
|
1674
|
-
for (const [
|
|
1675
|
-
const
|
|
1676
|
-
|
|
1764
|
+
for (const o of e)
|
|
1765
|
+
for (const [i, r] of Object.entries(o)) {
|
|
1766
|
+
const s = n[i];
|
|
1767
|
+
s && typeof s == "object" && typeof r == "object" && !Array.isArray(s) && !Array.isArray(r) ? n[i] = { ...s, ...r } : n[i] = r;
|
|
1677
1768
|
}
|
|
1678
1769
|
return n;
|
|
1679
1770
|
}
|
|
1680
|
-
function
|
|
1681
|
-
const
|
|
1682
|
-
return e.richText !== !1 &&
|
|
1771
|
+
function kn(e, n) {
|
|
1772
|
+
const o = [hn];
|
|
1773
|
+
return e.richText !== !1 && o.push(mn), e.code !== !1 && o.push(pn), n && o.push(n), gn(...o);
|
|
1683
1774
|
}
|
|
1684
|
-
function
|
|
1775
|
+
function yn(e) {
|
|
1685
1776
|
const n = [];
|
|
1686
|
-
return e.richText !== !1 && n.push(
|
|
1777
|
+
return e.richText !== !1 && n.push(Ae, Fe), e.code !== !1 && n.push(ge, Pe), e.lists !== !1 && n.push(We, Ue), n.push(G, Ge, je, j), n;
|
|
1687
1778
|
}
|
|
1688
1779
|
function bn({ editable: e }) {
|
|
1689
|
-
const [n] =
|
|
1690
|
-
return
|
|
1780
|
+
const [n] = E();
|
|
1781
|
+
return _(() => {
|
|
1691
1782
|
n.setEditable(e);
|
|
1692
1783
|
}, [n, e]), null;
|
|
1693
1784
|
}
|
|
1694
|
-
function
|
|
1785
|
+
function vn({
|
|
1695
1786
|
handleRef: e
|
|
1696
1787
|
}) {
|
|
1697
|
-
const [n] =
|
|
1698
|
-
return
|
|
1788
|
+
const [n] = E();
|
|
1789
|
+
return Te(
|
|
1699
1790
|
e,
|
|
1700
1791
|
() => ({
|
|
1701
1792
|
getState: () => JSON.stringify(n.getEditorState().toJSON())
|
|
@@ -1703,68 +1794,68 @@ function yn({
|
|
|
1703
1794
|
[n]
|
|
1704
1795
|
), null;
|
|
1705
1796
|
}
|
|
1706
|
-
const
|
|
1797
|
+
const Nn = {
|
|
1707
1798
|
history: !0,
|
|
1708
1799
|
richText: !0,
|
|
1709
1800
|
dragon: !0,
|
|
1710
1801
|
code: !0,
|
|
1711
1802
|
lists: !0
|
|
1712
|
-
},
|
|
1803
|
+
}, jn = Le(
|
|
1713
1804
|
function({
|
|
1714
1805
|
features: n,
|
|
1715
|
-
namespace:
|
|
1716
|
-
className:
|
|
1717
|
-
theme:
|
|
1718
|
-
editable:
|
|
1719
|
-
onError:
|
|
1806
|
+
namespace: o = "silk-editor",
|
|
1807
|
+
className: i,
|
|
1808
|
+
theme: r,
|
|
1809
|
+
editable: s = !0,
|
|
1810
|
+
onError: f,
|
|
1720
1811
|
initialEditorState: l
|
|
1721
1812
|
}, a) {
|
|
1722
|
-
const c =
|
|
1723
|
-
...
|
|
1813
|
+
const c = B(null), d = {
|
|
1814
|
+
...Nn,
|
|
1724
1815
|
...n
|
|
1725
|
-
},
|
|
1726
|
-
return /* @__PURE__ */ t(
|
|
1727
|
-
namespace:
|
|
1728
|
-
theme:
|
|
1729
|
-
nodes:
|
|
1730
|
-
editable:
|
|
1816
|
+
}, p = kn(d, r), g = yn(d);
|
|
1817
|
+
return /* @__PURE__ */ t(De, { initialConfig: {
|
|
1818
|
+
namespace: o,
|
|
1819
|
+
theme: p,
|
|
1820
|
+
nodes: g,
|
|
1821
|
+
editable: s,
|
|
1731
1822
|
editorState: l ?? void 0,
|
|
1732
|
-
onError:
|
|
1733
|
-
}, children: /* @__PURE__ */ t(
|
|
1823
|
+
onError: f ?? ((u) => console.error(u))
|
|
1824
|
+
}, children: /* @__PURE__ */ t(be.Provider, { value: c, children: /* @__PURE__ */ k(
|
|
1734
1825
|
"div",
|
|
1735
1826
|
{
|
|
1736
1827
|
ref: c,
|
|
1737
|
-
className: `silk-editor-container${
|
|
1828
|
+
className: `silk-editor-container${i ? ` ${i}` : ""}`,
|
|
1738
1829
|
children: [
|
|
1739
|
-
/* @__PURE__ */ t(
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
/* @__PURE__ */ t(
|
|
1746
|
-
/* @__PURE__ */ t(
|
|
1747
|
-
/* @__PURE__ */ t(Xt, {}),
|
|
1748
|
-
/* @__PURE__ */ t(Rt, {}),
|
|
1830
|
+
/* @__PURE__ */ t(an, {}),
|
|
1831
|
+
d.richText && /* @__PURE__ */ t(Tt, {}),
|
|
1832
|
+
d.history && /* @__PURE__ */ t(Lt, {}),
|
|
1833
|
+
d.dragon && /* @__PURE__ */ t(Dt, {}),
|
|
1834
|
+
d.code && /* @__PURE__ */ t(At, {}),
|
|
1835
|
+
d.lists && /* @__PURE__ */ t(dn, {}),
|
|
1836
|
+
/* @__PURE__ */ t(Oe, {}),
|
|
1837
|
+
/* @__PURE__ */ t(Ie, {}),
|
|
1749
1838
|
/* @__PURE__ */ t(Zt, {}),
|
|
1750
|
-
/* @__PURE__ */ t(
|
|
1751
|
-
/* @__PURE__ */ t(
|
|
1752
|
-
/* @__PURE__ */ t(
|
|
1753
|
-
/* @__PURE__ */ t(
|
|
1754
|
-
/* @__PURE__ */ t(
|
|
1755
|
-
/* @__PURE__ */ t(
|
|
1839
|
+
/* @__PURE__ */ t(Ft, {}),
|
|
1840
|
+
/* @__PURE__ */ t(tn, {}),
|
|
1841
|
+
/* @__PURE__ */ t(cn, {}),
|
|
1842
|
+
/* @__PURE__ */ t(fn, {}),
|
|
1843
|
+
/* @__PURE__ */ t(bn, { editable: s }),
|
|
1844
|
+
/* @__PURE__ */ t(vn, { handleRef: a }),
|
|
1845
|
+
/* @__PURE__ */ t(Qt, {}),
|
|
1846
|
+
/* @__PURE__ */ t(ln, {})
|
|
1756
1847
|
]
|
|
1757
1848
|
}
|
|
1758
1849
|
) }) });
|
|
1759
1850
|
}
|
|
1760
1851
|
);
|
|
1761
1852
|
export {
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1853
|
+
te as $createImageNode,
|
|
1854
|
+
ve as $createNoteNode,
|
|
1855
|
+
ne as $isImageNode,
|
|
1856
|
+
Ne as $isNoteNode,
|
|
1857
|
+
j as ImageNode,
|
|
1858
|
+
G as NoteNode,
|
|
1859
|
+
jn as SilkEditor,
|
|
1860
|
+
jn as default
|
|
1770
1861
|
};
|