silk-compose 0.0.1 → 0.0.2
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/README.md +27 -17
- package/dist/index.d.ts +12 -8
- package/dist/silk.js +398 -392
- package/package.json +5 -14
package/dist/silk.js
CHANGED
|
@@ -1,44 +1,43 @@
|
|
|
1
1
|
import { jsx as t, Fragment as te, jsxs as y } from "react/jsx-runtime";
|
|
2
|
-
import { useEffect as x, createContext as Se, useContext as we, useState as C, useRef as F, useCallback as w, useLayoutEffect as he, useMemo as _e } from "react";
|
|
3
|
-
import { LexicalComposer as
|
|
2
|
+
import { useEffect as x, createContext as Se, useContext as we, useState as C, useRef as F, useCallback as w, useLayoutEffect as he, useMemo as _e, forwardRef as Me, useImperativeHandle as Ee } from "react";
|
|
3
|
+
import { LexicalComposer as Le } from "@lexical/react/LexicalComposer";
|
|
4
4
|
import { useLexicalComposerContext as _ } from "@lexical/react/LexicalComposerContext";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import { $
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import { useBasicTypeaheadTriggerMatch as xt, LexicalTypeaheadMenuPlugin as St, MenuOption as wt } from "@lexical/react/LexicalTypeaheadMenuPlugin";
|
|
26
|
-
function _t() {
|
|
27
|
-
return /* @__PURE__ */ t(ft, {});
|
|
28
|
-
}
|
|
5
|
+
import { HorizontalRulePlugin as Te } from "@lexical/react/LexicalHorizontalRulePlugin";
|
|
6
|
+
import { TabIndentationPlugin as De } from "@lexical/react/LexicalTabIndentationPlugin";
|
|
7
|
+
import { $createHeadingNode as le, $createQuoteNode as Ie, HeadingNode as Oe, QuoteNode as Re } from "@lexical/rich-text";
|
|
8
|
+
import { CodeNode as pe, $isCodeNode as ne, $createCodeNode as Fe, CodeHighlightNode as Ae } from "@lexical/code";
|
|
9
|
+
import { INSERT_UNORDERED_LIST_COMMAND as $e, INSERT_ORDERED_LIST_COMMAND as Pe, registerList as ze, ListNode as Be, ListItemNode as He } from "@lexical/list";
|
|
10
|
+
import { $createHorizontalRuleNode as Ue, HorizontalRuleNode as We } from "@lexical/react/LexicalHorizontalRuleNode";
|
|
11
|
+
import { TOGGLE_LINK_COMMAND as Ke, $toggleLink as ae, $createLinkNode as Ge, $isLinkNode as ce, LinkNode as Ve } from "@lexical/link";
|
|
12
|
+
import { $getNodeByKey as H, ElementNode as Ye, $createParagraphNode as G, COMMAND_PRIORITY_LOW as $, $getSelection as E, $isRangeSelection as L, $setSelection as je, $createTextNode as Je, createCommand as Qe, $isParagraphNode as me, SELECTION_CHANGE_COMMAND as ge, FORMAT_TEXT_COMMAND as Xe, $getNearestNodeFromDOMNode as qe, $applyNodeReplacement as Ze, DecoratorNode as et, CLICK_COMMAND as tt, KEY_BACKSPACE_COMMAND as nt, KEY_DELETE_COMMAND as ot, PASTE_COMMAND as it, COMMAND_PRIORITY_HIGH as X, DROP_COMMAND as rt, DRAGOVER_COMMAND as st, $isNodeSelection as lt, $getRoot as de } from "lexical";
|
|
13
|
+
import { useLexicalNodeSelection as at } from "@lexical/react/useLexicalNodeSelection";
|
|
14
|
+
import { $getSelectionStyleValueForProperty as q, $patchStyleText as Z, $setBlocksType as ct } from "@lexical/selection";
|
|
15
|
+
import { RichTextPlugin as dt } from "@lexical/react/LexicalRichTextPlugin";
|
|
16
|
+
import { ContentEditable as ut } from "@lexical/react/LexicalContentEditable";
|
|
17
|
+
import { LexicalErrorBoundary as ft } from "@lexical/react/LexicalErrorBoundary";
|
|
18
|
+
import { HistoryPlugin as ht } from "@lexical/react/LexicalHistoryPlugin";
|
|
19
|
+
import { registerDragonSupport as pt } from "@lexical/dragon";
|
|
20
|
+
import { registerCodeHighlighting as mt, ShikiTokenizer as gt, getCodeLanguageOptions as kt } from "@lexical/code-shiki";
|
|
21
|
+
import { ListPlugin as bt } from "@lexical/react/LexicalListPlugin";
|
|
22
|
+
import { registerMarkdownShortcuts as yt, TEXT_FORMAT_TRANSFORMERS as vt, UNORDERED_LIST as Nt, ORDERED_LIST as Ct } from "@lexical/markdown";
|
|
23
|
+
import { createPortal as xt } from "react-dom";
|
|
24
|
+
import { useBasicTypeaheadTriggerMatch as St, LexicalTypeaheadMenuPlugin as wt, MenuOption as _t } from "@lexical/react/LexicalTypeaheadMenuPlugin";
|
|
29
25
|
function Mt() {
|
|
26
|
+
return /* @__PURE__ */ t(ht, {});
|
|
27
|
+
}
|
|
28
|
+
function Et() {
|
|
30
29
|
return /* @__PURE__ */ t("div", { style: { position: "relative" }, children: /* @__PURE__ */ t(
|
|
31
|
-
|
|
30
|
+
dt,
|
|
32
31
|
{
|
|
33
|
-
contentEditable: /* @__PURE__ */ t(
|
|
32
|
+
contentEditable: /* @__PURE__ */ t(ut, { className: "silk-content-editable" }),
|
|
34
33
|
placeholder: /* @__PURE__ */ t("div", { className: "silk-placeholder", children: "Start writing…" }),
|
|
35
|
-
ErrorBoundary:
|
|
34
|
+
ErrorBoundary: ft
|
|
36
35
|
}
|
|
37
36
|
) });
|
|
38
37
|
}
|
|
39
|
-
function
|
|
38
|
+
function Lt() {
|
|
40
39
|
const [e] = _();
|
|
41
|
-
return x(() =>
|
|
40
|
+
return x(() => pt(e), [e]), null;
|
|
42
41
|
}
|
|
43
42
|
const ke = Se({
|
|
44
43
|
current: null
|
|
@@ -46,24 +45,24 @@ const ke = Se({
|
|
|
46
45
|
function oe() {
|
|
47
46
|
return we(ke);
|
|
48
47
|
}
|
|
49
|
-
function
|
|
50
|
-
return
|
|
48
|
+
function Tt() {
|
|
49
|
+
return kt().map(([e, n]) => ({ value: e, label: n }));
|
|
51
50
|
}
|
|
52
|
-
const
|
|
53
|
-
function
|
|
51
|
+
const Dt = 32;
|
|
52
|
+
function It({
|
|
54
53
|
language: e,
|
|
55
54
|
codeNodeKey: n,
|
|
56
55
|
codeElem: i
|
|
57
56
|
}) {
|
|
58
57
|
var p;
|
|
59
|
-
const [o] = _(), s = oe(), [r,
|
|
60
|
-
x(() => o.registerEditableListener(
|
|
58
|
+
const [o] = _(), s = oe(), [r, h] = C(!1), [l, a] = C(() => o.isEditable()), c = F(null), [u, b] = C({ top: 0, left: 0, width: 0 });
|
|
59
|
+
x(() => o.registerEditableListener(a), [o]);
|
|
61
60
|
const m = w(() => {
|
|
62
61
|
const d = s.current;
|
|
63
62
|
if (!d) return;
|
|
64
63
|
const k = i.getBoundingClientRect(), g = d.getBoundingClientRect();
|
|
65
64
|
b({
|
|
66
|
-
top: k.top - g.top -
|
|
65
|
+
top: k.top - g.top - Dt,
|
|
67
66
|
left: k.left - g.left,
|
|
68
67
|
width: k.width
|
|
69
68
|
});
|
|
@@ -75,31 +74,31 @@ function Dt({
|
|
|
75
74
|
}, [i, m]), x(() => o.registerUpdateListener(() => {
|
|
76
75
|
m();
|
|
77
76
|
}), [o, m]);
|
|
78
|
-
const S =
|
|
77
|
+
const S = Tt(), f = ((p = S.find((d) => d.value === e)) == null ? void 0 : p.label) ?? e ?? "Plain Text", v = w(
|
|
79
78
|
(d) => {
|
|
80
79
|
o.update(() => {
|
|
81
80
|
const k = H(n);
|
|
82
81
|
ne(k) && k.setLanguage(d);
|
|
83
|
-
}),
|
|
82
|
+
}), h(!1);
|
|
84
83
|
},
|
|
85
84
|
[o, n]
|
|
86
85
|
);
|
|
87
86
|
return x(() => {
|
|
88
87
|
if (!r) return;
|
|
89
88
|
const d = (k) => {
|
|
90
|
-
|
|
89
|
+
c.current && !c.current.contains(k.target) && h(!1);
|
|
91
90
|
};
|
|
92
91
|
return document.addEventListener("mousedown", d), () => document.removeEventListener("mousedown", d);
|
|
93
92
|
}, [r]), /* @__PURE__ */ y(
|
|
94
93
|
"div",
|
|
95
94
|
{
|
|
96
|
-
ref:
|
|
95
|
+
ref: c,
|
|
97
96
|
className: "silk-code-header",
|
|
98
97
|
style: {
|
|
99
98
|
position: "absolute",
|
|
100
|
-
top:
|
|
101
|
-
left:
|
|
102
|
-
width:
|
|
99
|
+
top: u.top,
|
|
100
|
+
left: u.left,
|
|
101
|
+
width: u.width,
|
|
103
102
|
pointerEvents: "auto"
|
|
104
103
|
},
|
|
105
104
|
children: [
|
|
@@ -107,17 +106,17 @@ function Dt({
|
|
|
107
106
|
"button",
|
|
108
107
|
{
|
|
109
108
|
className: "silk-code-language-select",
|
|
110
|
-
onClick: () =>
|
|
111
|
-
style: { cursor:
|
|
109
|
+
onClick: () => l && h(!r),
|
|
110
|
+
style: { cursor: l ? "pointer" : "default" },
|
|
112
111
|
onMouseDown: (d) => d.preventDefault(),
|
|
113
112
|
type: "button",
|
|
114
113
|
children: [
|
|
115
|
-
|
|
116
|
-
|
|
114
|
+
f,
|
|
115
|
+
l && /* @__PURE__ */ t("span", { className: "silk-code-language-chevron", "aria-hidden": !0, children: "▾" })
|
|
117
116
|
]
|
|
118
117
|
}
|
|
119
118
|
),
|
|
120
|
-
r &&
|
|
119
|
+
r && l && /* @__PURE__ */ t("div", { className: "silk-code-language-dropdown", children: S.map((d) => /* @__PURE__ */ t(
|
|
121
120
|
"button",
|
|
122
121
|
{
|
|
123
122
|
className: `silk-code-language-option${e === d.value ? " silk-code-language-option--active" : ""}`,
|
|
@@ -132,51 +131,51 @@ function Dt({
|
|
|
132
131
|
}
|
|
133
132
|
);
|
|
134
133
|
}
|
|
135
|
-
function
|
|
134
|
+
function Ot() {
|
|
136
135
|
const [e] = _(), [n, i] = C(
|
|
137
136
|
/* @__PURE__ */ new Map()
|
|
138
137
|
);
|
|
139
|
-
return x(() =>
|
|
140
|
-
...
|
|
138
|
+
return x(() => mt(e, {
|
|
139
|
+
...gt,
|
|
141
140
|
defaultTheme: "dark-plus"
|
|
142
141
|
}), [e]), x(() => {
|
|
143
142
|
const o = /* @__PURE__ */ new Set(), s = () => {
|
|
144
143
|
e.getEditorState().read(() => {
|
|
145
|
-
const
|
|
146
|
-
for (const
|
|
147
|
-
const
|
|
148
|
-
if (ne(
|
|
149
|
-
const
|
|
150
|
-
|
|
151
|
-
language:
|
|
152
|
-
elem:
|
|
144
|
+
const l = /* @__PURE__ */ new Map();
|
|
145
|
+
for (const a of o) {
|
|
146
|
+
const c = H(a);
|
|
147
|
+
if (ne(c)) {
|
|
148
|
+
const u = e.getElementByKey(a);
|
|
149
|
+
u && l.set(a, {
|
|
150
|
+
language: c.getLanguage() ?? "typescript",
|
|
151
|
+
elem: u
|
|
153
152
|
});
|
|
154
153
|
}
|
|
155
154
|
}
|
|
156
|
-
i(
|
|
155
|
+
i(l);
|
|
157
156
|
});
|
|
158
157
|
}, r = e.registerMutationListener(
|
|
159
158
|
pe,
|
|
160
|
-
(
|
|
161
|
-
for (const [
|
|
162
|
-
|
|
159
|
+
(l) => {
|
|
160
|
+
for (const [a, c] of l)
|
|
161
|
+
c === "destroyed" ? o.delete(a) : o.add(a);
|
|
163
162
|
s();
|
|
164
163
|
},
|
|
165
164
|
{ skipInitialization: !1 }
|
|
166
|
-
),
|
|
167
|
-
let
|
|
168
|
-
for (const
|
|
169
|
-
if (
|
|
170
|
-
|
|
165
|
+
), h = e.registerUpdateListener(({ dirtyElements: l }) => {
|
|
166
|
+
let a = !1;
|
|
167
|
+
for (const c of o)
|
|
168
|
+
if (l.has(c)) {
|
|
169
|
+
a = !0;
|
|
171
170
|
break;
|
|
172
171
|
}
|
|
173
|
-
|
|
172
|
+
a && s();
|
|
174
173
|
});
|
|
175
174
|
return () => {
|
|
176
|
-
r(),
|
|
175
|
+
r(), h();
|
|
177
176
|
};
|
|
178
177
|
}, [e]), /* @__PURE__ */ t(te, { children: Array.from(n.entries()).map(([o, { language: s, elem: r }]) => /* @__PURE__ */ t(
|
|
179
|
-
|
|
178
|
+
It,
|
|
180
179
|
{
|
|
181
180
|
language: s,
|
|
182
181
|
codeNodeKey: o,
|
|
@@ -185,7 +184,7 @@ function It() {
|
|
|
185
184
|
o
|
|
186
185
|
)) });
|
|
187
186
|
}
|
|
188
|
-
class W extends
|
|
187
|
+
class W extends Ye {
|
|
189
188
|
static getType() {
|
|
190
189
|
return "note";
|
|
191
190
|
}
|
|
@@ -237,12 +236,12 @@ function be(e = "info") {
|
|
|
237
236
|
function ye(e) {
|
|
238
237
|
return e instanceof W;
|
|
239
238
|
}
|
|
240
|
-
const ie =
|
|
241
|
-
function
|
|
242
|
-
const [e] = _(), [n, i] = C(!1), [o, s] = C(""), [r,
|
|
239
|
+
const ie = Qe("SHOW_LINK_DIALOG");
|
|
240
|
+
function Rt() {
|
|
241
|
+
const [e] = _(), [n, i] = C(!1), [o, s] = C(""), [r, h] = C(""), [l, a] = C(!1), c = F(null), u = F(null);
|
|
243
242
|
x(() => {
|
|
244
|
-
const
|
|
245
|
-
|
|
243
|
+
const f = e.registerCommand(
|
|
244
|
+
Ke,
|
|
246
245
|
(p) => (ae(p, {
|
|
247
246
|
target: "_blank",
|
|
248
247
|
rel: "noopener noreferrer"
|
|
@@ -253,45 +252,45 @@ function Ot() {
|
|
|
253
252
|
(p) => {
|
|
254
253
|
const d = E();
|
|
255
254
|
if (L(d)) {
|
|
256
|
-
|
|
255
|
+
u.current = d.clone();
|
|
257
256
|
const k = d.isCollapsed();
|
|
258
|
-
|
|
257
|
+
a(!k), k || h(d.getTextContent());
|
|
259
258
|
}
|
|
260
|
-
return (p == null ? void 0 : p.text) !== void 0 &&
|
|
259
|
+
return (p == null ? void 0 : p.text) !== void 0 && h(p.text), i(!0), !0;
|
|
261
260
|
},
|
|
262
261
|
$
|
|
263
262
|
);
|
|
264
263
|
return () => {
|
|
265
|
-
|
|
264
|
+
f(), v();
|
|
266
265
|
};
|
|
267
266
|
}, [e]), x(() => {
|
|
268
267
|
n && setTimeout(() => {
|
|
269
|
-
var
|
|
270
|
-
return (
|
|
268
|
+
var f;
|
|
269
|
+
return (f = c.current) == null ? void 0 : f.focus();
|
|
271
270
|
}, 0);
|
|
272
271
|
}, [n]);
|
|
273
272
|
const b = w(() => {
|
|
274
|
-
i(!1), s(""),
|
|
273
|
+
i(!1), s(""), h(""), a(!1), u.current = null, e.focus();
|
|
275
274
|
}, [e]), m = w(() => {
|
|
276
275
|
o && (e.update(() => {
|
|
277
|
-
if (
|
|
276
|
+
if (u.current && je(u.current.clone()), l)
|
|
278
277
|
ae(o, {
|
|
279
278
|
target: "_blank",
|
|
280
279
|
rel: "noopener noreferrer"
|
|
281
280
|
});
|
|
282
281
|
else {
|
|
283
|
-
const
|
|
282
|
+
const f = Ge(o, {
|
|
284
283
|
target: "_blank",
|
|
285
284
|
rel: "noopener noreferrer"
|
|
286
|
-
}), v =
|
|
287
|
-
|
|
285
|
+
}), v = Je(r || o);
|
|
286
|
+
f.append(v);
|
|
288
287
|
const p = E();
|
|
289
|
-
L(p) && p.insertNodes([
|
|
288
|
+
L(p) && p.insertNodes([f]);
|
|
290
289
|
}
|
|
291
290
|
}), b());
|
|
292
|
-
}, [e, o, r,
|
|
293
|
-
(
|
|
294
|
-
|
|
291
|
+
}, [e, o, r, l, b]), S = w(
|
|
292
|
+
(f) => {
|
|
293
|
+
f.key === "Enter" && (f.preventDefault(), m()), f.key === "Escape" && b();
|
|
295
294
|
},
|
|
296
295
|
[m, b]
|
|
297
296
|
);
|
|
@@ -299,8 +298,8 @@ function Ot() {
|
|
|
299
298
|
"div",
|
|
300
299
|
{
|
|
301
300
|
className: "silk-link-dialog-backdrop",
|
|
302
|
-
onMouseDown: (
|
|
303
|
-
|
|
301
|
+
onMouseDown: (f) => {
|
|
302
|
+
f.target === f.currentTarget && b();
|
|
304
303
|
},
|
|
305
304
|
children: /* @__PURE__ */ y("div", { className: "silk-link-dialog", onKeyDown: S, children: [
|
|
306
305
|
/* @__PURE__ */ y("div", { className: "silk-link-dialog-field", children: [
|
|
@@ -308,11 +307,11 @@ function Ot() {
|
|
|
308
307
|
/* @__PURE__ */ t(
|
|
309
308
|
"input",
|
|
310
309
|
{
|
|
311
|
-
ref:
|
|
310
|
+
ref: c,
|
|
312
311
|
className: "silk-link-dialog-input",
|
|
313
312
|
type: "text",
|
|
314
313
|
value: o,
|
|
315
|
-
onChange: (
|
|
314
|
+
onChange: (f) => s(f.target.value),
|
|
316
315
|
placeholder: "https://example.com"
|
|
317
316
|
}
|
|
318
317
|
)
|
|
@@ -322,12 +321,12 @@ function Ot() {
|
|
|
322
321
|
/* @__PURE__ */ t(
|
|
323
322
|
"input",
|
|
324
323
|
{
|
|
325
|
-
className: `silk-link-dialog-input${
|
|
324
|
+
className: `silk-link-dialog-input${l ? " silk-link-dialog-input--readonly" : ""}`,
|
|
326
325
|
type: "text",
|
|
327
326
|
value: r,
|
|
328
|
-
onChange: (
|
|
327
|
+
onChange: (f) => h(f.target.value),
|
|
329
328
|
placeholder: "Link text",
|
|
330
|
-
readOnly:
|
|
329
|
+
readOnly: l
|
|
331
330
|
}
|
|
332
331
|
)
|
|
333
332
|
] }),
|
|
@@ -356,10 +355,10 @@ function Ot() {
|
|
|
356
355
|
}
|
|
357
356
|
) : null;
|
|
358
357
|
}
|
|
359
|
-
const
|
|
358
|
+
const Ft = 18;
|
|
360
359
|
function O({
|
|
361
360
|
children: e,
|
|
362
|
-
size: n =
|
|
361
|
+
size: n = Ft,
|
|
363
362
|
className: i
|
|
364
363
|
}) {
|
|
365
364
|
return /* @__PURE__ */ t(
|
|
@@ -378,7 +377,7 @@ function O({
|
|
|
378
377
|
}
|
|
379
378
|
);
|
|
380
379
|
}
|
|
381
|
-
function
|
|
380
|
+
function At(e) {
|
|
382
381
|
return /* @__PURE__ */ y(O, { ...e, children: [
|
|
383
382
|
/* @__PURE__ */ t("path", { d: "M4 12h8" }),
|
|
384
383
|
/* @__PURE__ */ t("path", { d: "M4 18V6" }),
|
|
@@ -386,7 +385,7 @@ function Ft(e) {
|
|
|
386
385
|
/* @__PURE__ */ t("path", { d: "M17 12l3-2v8" })
|
|
387
386
|
] });
|
|
388
387
|
}
|
|
389
|
-
function
|
|
388
|
+
function $t(e) {
|
|
390
389
|
return /* @__PURE__ */ y(O, { ...e, children: [
|
|
391
390
|
/* @__PURE__ */ t("path", { d: "M4 12h8" }),
|
|
392
391
|
/* @__PURE__ */ t("path", { d: "M4 18V6" }),
|
|
@@ -394,7 +393,7 @@ function At(e) {
|
|
|
394
393
|
/* @__PURE__ */ t("path", { d: "M21 18h-4c0-4 4-3 4-6 0-1.5-2-2.5-4-1" })
|
|
395
394
|
] });
|
|
396
395
|
}
|
|
397
|
-
function
|
|
396
|
+
function Pt(e) {
|
|
398
397
|
return /* @__PURE__ */ y(O, { ...e, children: [
|
|
399
398
|
/* @__PURE__ */ t("polyline", { points: "16 18 22 12 16 6" }),
|
|
400
399
|
/* @__PURE__ */ t("polyline", { points: "8 6 2 12 8 18" })
|
|
@@ -407,7 +406,7 @@ function ve(e) {
|
|
|
407
406
|
/* @__PURE__ */ t("line", { x1: "12", y1: "8", x2: "12.01", y2: "8" })
|
|
408
407
|
] });
|
|
409
408
|
}
|
|
410
|
-
function
|
|
409
|
+
function zt(e) {
|
|
411
410
|
return /* @__PURE__ */ y(O, { ...e, children: [
|
|
412
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" }),
|
|
413
412
|
/* @__PURE__ */ t(
|
|
@@ -426,20 +425,20 @@ function Pt(e) {
|
|
|
426
425
|
)
|
|
427
426
|
] });
|
|
428
427
|
}
|
|
429
|
-
function
|
|
428
|
+
function Bt(e) {
|
|
430
429
|
return /* @__PURE__ */ y(O, { ...e, children: [
|
|
431
430
|
/* @__PURE__ */ t("circle", { cx: "12", cy: "12", r: "10" }),
|
|
432
431
|
/* @__PURE__ */ t("line", { x1: "12", y1: "8", x2: "12", y2: "12" }),
|
|
433
432
|
/* @__PURE__ */ t("line", { x1: "12", y1: "16", x2: "12.01", y2: "16" })
|
|
434
433
|
] });
|
|
435
434
|
}
|
|
436
|
-
function
|
|
435
|
+
function Ht(e) {
|
|
437
436
|
return /* @__PURE__ */ y(O, { ...e, children: [
|
|
438
437
|
/* @__PURE__ */ t("path", { d: "M10 13a5 5 0 007.54.54l3-3a5 5 0 00-7.07-7.07l-1.72 1.71" }),
|
|
439
438
|
/* @__PURE__ */ t("path", { d: "M14 11a5 5 0 00-7.54-.54l-3 3a5 5 0 007.07 7.07l1.71-1.71" })
|
|
440
439
|
] });
|
|
441
440
|
}
|
|
442
|
-
function
|
|
441
|
+
function Ut(e) {
|
|
443
442
|
return /* @__PURE__ */ y(O, { ...e, children: [
|
|
444
443
|
/* @__PURE__ */ t("line", { x1: "10", y1: "6", x2: "21", y2: "6" }),
|
|
445
444
|
/* @__PURE__ */ t("line", { x1: "10", y1: "12", x2: "21", y2: "12" }),
|
|
@@ -449,7 +448,7 @@ function Ht(e) {
|
|
|
449
448
|
/* @__PURE__ */ t("path", { d: "M6 18H4c0-1 2-2 2-3s-1-1.5-2-1" })
|
|
450
449
|
] });
|
|
451
450
|
}
|
|
452
|
-
function
|
|
451
|
+
function Wt(e) {
|
|
453
452
|
return /* @__PURE__ */ y(O, { ...e, children: [
|
|
454
453
|
/* @__PURE__ */ t("line", { x1: "8", y1: "6", x2: "21", y2: "6" }),
|
|
455
454
|
/* @__PURE__ */ t("line", { x1: "8", y1: "12", x2: "21", y2: "12" }),
|
|
@@ -459,7 +458,7 @@ function Ut(e) {
|
|
|
459
458
|
/* @__PURE__ */ t("line", { x1: "3", y1: "18", x2: "3.01", y2: "18" })
|
|
460
459
|
] });
|
|
461
460
|
}
|
|
462
|
-
function
|
|
461
|
+
function Kt(e) {
|
|
463
462
|
return /* @__PURE__ */ t(O, { ...e, children: /* @__PURE__ */ t("line", { x1: "2", y1: "12", x2: "22", y2: "12" }) });
|
|
464
463
|
}
|
|
465
464
|
function J(e) {
|
|
@@ -468,10 +467,10 @@ function J(e) {
|
|
|
468
467
|
const o = n.anchor.getNode().getTopLevelElementOrThrow(), s = e(), r = G();
|
|
469
468
|
return o.insertAfter(s), s.insertAfter(r), me(o) && o.getTextContentSize() === 0 && o.remove(), { node: s, trailing: r };
|
|
470
469
|
}
|
|
471
|
-
const
|
|
470
|
+
const Gt = [
|
|
472
471
|
{
|
|
473
472
|
name: "Heading 1",
|
|
474
|
-
icon: /* @__PURE__ */ t(
|
|
473
|
+
icon: /* @__PURE__ */ t(At, {}),
|
|
475
474
|
description: "Large section heading",
|
|
476
475
|
execute: () => {
|
|
477
476
|
const e = J(() => le("h1"));
|
|
@@ -480,7 +479,7 @@ const Kt = [
|
|
|
480
479
|
},
|
|
481
480
|
{
|
|
482
481
|
name: "Heading 2",
|
|
483
|
-
icon: /* @__PURE__ */ t(
|
|
482
|
+
icon: /* @__PURE__ */ t($t, {}),
|
|
484
483
|
description: "Medium section heading",
|
|
485
484
|
execute: () => {
|
|
486
485
|
const e = J(() => le("h2"));
|
|
@@ -489,10 +488,10 @@ const Kt = [
|
|
|
489
488
|
},
|
|
490
489
|
{
|
|
491
490
|
name: "Code Block",
|
|
492
|
-
icon: /* @__PURE__ */ t(
|
|
491
|
+
icon: /* @__PURE__ */ t(Pt, {}),
|
|
493
492
|
description: "Code with syntax highlighting",
|
|
494
493
|
execute: () => {
|
|
495
|
-
const e = J(() =>
|
|
494
|
+
const e = J(() => Fe("typescript"));
|
|
496
495
|
e == null || e.node.selectStart();
|
|
497
496
|
}
|
|
498
497
|
},
|
|
@@ -511,44 +510,44 @@ const Kt = [
|
|
|
511
510
|
},
|
|
512
511
|
{
|
|
513
512
|
name: "Bulleted List",
|
|
514
|
-
icon: /* @__PURE__ */ t(
|
|
513
|
+
icon: /* @__PURE__ */ t(Wt, {}),
|
|
515
514
|
description: "Unordered bulleted list",
|
|
516
515
|
execute: (e) => {
|
|
517
|
-
e.dispatchCommand(
|
|
516
|
+
e.dispatchCommand($e, void 0);
|
|
518
517
|
}
|
|
519
518
|
},
|
|
520
519
|
{
|
|
521
520
|
name: "Numbered List",
|
|
522
|
-
icon: /* @__PURE__ */ t(
|
|
521
|
+
icon: /* @__PURE__ */ t(Ut, {}),
|
|
523
522
|
description: "Ordered numbered list",
|
|
524
523
|
execute: (e) => {
|
|
525
|
-
e.dispatchCommand(
|
|
524
|
+
e.dispatchCommand(Pe, void 0);
|
|
526
525
|
}
|
|
527
526
|
},
|
|
528
527
|
{
|
|
529
528
|
name: "Divider",
|
|
530
|
-
icon: /* @__PURE__ */ t(
|
|
529
|
+
icon: /* @__PURE__ */ t(Kt, {}),
|
|
531
530
|
description: "Horizontal line separator",
|
|
532
531
|
execute: () => {
|
|
533
|
-
const e = J(() =>
|
|
532
|
+
const e = J(() => Ue());
|
|
534
533
|
e == null || e.trailing.selectStart();
|
|
535
534
|
}
|
|
536
535
|
},
|
|
537
536
|
{
|
|
538
537
|
name: "Link",
|
|
539
|
-
icon: /* @__PURE__ */ t(
|
|
538
|
+
icon: /* @__PURE__ */ t(Ht, {}),
|
|
540
539
|
description: "Insert a masked link",
|
|
541
540
|
execute: (e) => {
|
|
542
541
|
e.dispatchCommand(ie, void 0);
|
|
543
542
|
}
|
|
544
543
|
}
|
|
545
544
|
];
|
|
546
|
-
class
|
|
545
|
+
class Vt extends _t {
|
|
547
546
|
constructor(n) {
|
|
548
547
|
super(n.name), this.entry = n;
|
|
549
548
|
}
|
|
550
549
|
}
|
|
551
|
-
function
|
|
550
|
+
function Yt({
|
|
552
551
|
option: e,
|
|
553
552
|
isSelected: n,
|
|
554
553
|
onClick: i,
|
|
@@ -574,67 +573,67 @@ function Vt({
|
|
|
574
573
|
}
|
|
575
574
|
);
|
|
576
575
|
}
|
|
577
|
-
function
|
|
576
|
+
function jt() {
|
|
578
577
|
const [e] = _(), [n, i] = C(() => e.isEditable()), [o, s] = C(null);
|
|
579
578
|
x(() => e.registerEditableListener(i), [e]);
|
|
580
|
-
const r =
|
|
579
|
+
const r = St("/", {
|
|
581
580
|
minLength: 0,
|
|
582
581
|
allowWhitespace: !0
|
|
583
|
-
}),
|
|
582
|
+
}), h = _e(() => {
|
|
584
583
|
if (o === null) return [];
|
|
585
|
-
const
|
|
586
|
-
return
|
|
587
|
-
(b) => b.name.toLowerCase().includes(
|
|
588
|
-
).map((b) => new
|
|
589
|
-
}, [o]),
|
|
590
|
-
(
|
|
591
|
-
|
|
584
|
+
const c = o.toLowerCase();
|
|
585
|
+
return Gt.filter(
|
|
586
|
+
(b) => b.name.toLowerCase().includes(c) || b.description.toLowerCase().includes(c)
|
|
587
|
+
).map((b) => new Vt(b));
|
|
588
|
+
}, [o]), l = w(
|
|
589
|
+
(c, u, b) => {
|
|
590
|
+
u && u.remove(), c.entry.execute(e), b();
|
|
592
591
|
},
|
|
593
592
|
[e]
|
|
594
|
-
),
|
|
595
|
-
(
|
|
596
|
-
/* @__PURE__ */ t("div", { className: "silk-slash-menu", children:
|
|
597
|
-
|
|
593
|
+
), a = w(
|
|
594
|
+
(c, u, b) => c.current == null || u.options.length === 0 ? null : xt(
|
|
595
|
+
/* @__PURE__ */ t("div", { className: "silk-slash-menu", children: u.options.map((m, S) => /* @__PURE__ */ t(
|
|
596
|
+
Yt,
|
|
598
597
|
{
|
|
599
598
|
option: m,
|
|
600
|
-
isSelected:
|
|
601
|
-
onClick: () =>
|
|
602
|
-
onMouseEnter: () =>
|
|
599
|
+
isSelected: u.selectedIndex === S,
|
|
600
|
+
onClick: () => u.selectOptionAndCleanUp(m),
|
|
601
|
+
onMouseEnter: () => u.setHighlightedIndex(S)
|
|
603
602
|
},
|
|
604
603
|
m.key
|
|
605
604
|
)) }),
|
|
606
|
-
|
|
605
|
+
c.current
|
|
607
606
|
),
|
|
608
607
|
[]
|
|
609
608
|
);
|
|
610
609
|
return n ? /* @__PURE__ */ t(
|
|
611
|
-
|
|
610
|
+
wt,
|
|
612
611
|
{
|
|
613
|
-
options:
|
|
612
|
+
options: h,
|
|
614
613
|
onQueryChange: s,
|
|
615
|
-
onSelectOption:
|
|
614
|
+
onSelectOption: l,
|
|
616
615
|
triggerFn: r,
|
|
617
|
-
menuRenderFn:
|
|
616
|
+
menuRenderFn: a,
|
|
618
617
|
anchorClassName: "silk-slash-anchor"
|
|
619
618
|
}
|
|
620
619
|
) : null;
|
|
621
620
|
}
|
|
622
|
-
const
|
|
621
|
+
const Jt = [
|
|
623
622
|
{ value: "info", label: "Info", Icon: ve },
|
|
624
|
-
{ value: "warning", label: "Question", Icon:
|
|
625
|
-
{ value: "error", label: "Error", Icon:
|
|
623
|
+
{ value: "warning", label: "Question", Icon: zt },
|
|
624
|
+
{ value: "error", label: "Error", Icon: Bt }
|
|
626
625
|
];
|
|
627
|
-
function
|
|
626
|
+
function Qt({
|
|
628
627
|
noteType: e,
|
|
629
628
|
nodeKey: n,
|
|
630
629
|
elem: i
|
|
631
630
|
}) {
|
|
632
|
-
const [o] = _(), s = oe(), [r,
|
|
633
|
-
x(() => o.registerEditableListener(
|
|
631
|
+
const [o] = _(), s = oe(), [r, h] = C(() => o.isEditable()), [l, a] = C(!1), c = F(null), [u, b] = C({ top: 0, left: 0 });
|
|
632
|
+
x(() => o.registerEditableListener(h), [o]);
|
|
634
633
|
const m = w(() => {
|
|
635
|
-
const
|
|
636
|
-
if (!
|
|
637
|
-
const v = i.getBoundingClientRect(), p =
|
|
634
|
+
const f = s.current;
|
|
635
|
+
if (!f) return;
|
|
636
|
+
const v = i.getBoundingClientRect(), p = f.getBoundingClientRect();
|
|
638
637
|
b({
|
|
639
638
|
top: v.top - p.top + 13,
|
|
640
639
|
left: v.left - p.left + 17
|
|
@@ -642,32 +641,32 @@ function Jt({
|
|
|
642
641
|
}, [i, s]);
|
|
643
642
|
he(() => {
|
|
644
643
|
m();
|
|
645
|
-
const
|
|
646
|
-
return
|
|
644
|
+
const f = new ResizeObserver(m);
|
|
645
|
+
return f.observe(i), () => f.disconnect();
|
|
647
646
|
}, [i, m]), x(() => o.registerUpdateListener(() => m()), [o, m]);
|
|
648
647
|
const S = w(
|
|
649
|
-
(
|
|
648
|
+
(f) => {
|
|
650
649
|
o.update(() => {
|
|
651
650
|
const v = H(n);
|
|
652
|
-
ye(v) && v.setNoteType(
|
|
653
|
-
}),
|
|
651
|
+
ye(v) && v.setNoteType(f);
|
|
652
|
+
}), a(!1);
|
|
654
653
|
},
|
|
655
654
|
[o, n]
|
|
656
655
|
);
|
|
657
656
|
return x(() => {
|
|
658
|
-
if (!
|
|
659
|
-
const
|
|
660
|
-
|
|
657
|
+
if (!l) return;
|
|
658
|
+
const f = (v) => {
|
|
659
|
+
c.current && !c.current.contains(v.target) && a(!1);
|
|
661
660
|
};
|
|
662
|
-
return document.addEventListener("mousedown",
|
|
663
|
-
}, [
|
|
661
|
+
return document.addEventListener("mousedown", f), () => document.removeEventListener("mousedown", f);
|
|
662
|
+
}, [l]), r ? /* @__PURE__ */ y(
|
|
664
663
|
"div",
|
|
665
664
|
{
|
|
666
|
-
ref:
|
|
665
|
+
ref: c,
|
|
667
666
|
style: {
|
|
668
667
|
position: "absolute",
|
|
669
|
-
top:
|
|
670
|
-
left:
|
|
668
|
+
top: u.top,
|
|
669
|
+
left: u.left,
|
|
671
670
|
zIndex: 1
|
|
672
671
|
},
|
|
673
672
|
children: [
|
|
@@ -675,72 +674,72 @@ function Jt({
|
|
|
675
674
|
"button",
|
|
676
675
|
{
|
|
677
676
|
className: `silk-note-icon-trigger silk-note-icon-trigger--${e}`,
|
|
678
|
-
onClick: () =>
|
|
679
|
-
onMouseDown: (
|
|
677
|
+
onClick: () => a(!l),
|
|
678
|
+
onMouseDown: (f) => f.preventDefault(),
|
|
680
679
|
type: "button",
|
|
681
680
|
"aria-label": "Change note type"
|
|
682
681
|
}
|
|
683
682
|
),
|
|
684
|
-
|
|
683
|
+
l && /* @__PURE__ */ t("div", { className: "silk-note-icon-dropdown", children: Jt.map((f) => /* @__PURE__ */ y(
|
|
685
684
|
"button",
|
|
686
685
|
{
|
|
687
|
-
className: `silk-note-type-option silk-note-type-option--${
|
|
688
|
-
onClick: () => S(
|
|
686
|
+
className: `silk-note-type-option silk-note-type-option--${f.value}${e === f.value ? " silk-note-type-option--active" : ""}`,
|
|
687
|
+
onClick: () => S(f.value),
|
|
689
688
|
onMouseDown: (v) => v.preventDefault(),
|
|
690
689
|
type: "button",
|
|
691
690
|
children: [
|
|
692
|
-
/* @__PURE__ */ t(
|
|
693
|
-
|
|
691
|
+
/* @__PURE__ */ t(f.Icon, { size: 14 }),
|
|
692
|
+
f.label
|
|
694
693
|
]
|
|
695
694
|
},
|
|
696
|
-
|
|
695
|
+
f.value
|
|
697
696
|
)) })
|
|
698
697
|
]
|
|
699
698
|
}
|
|
700
699
|
) : null;
|
|
701
700
|
}
|
|
702
|
-
function
|
|
701
|
+
function Xt() {
|
|
703
702
|
const [e] = _(), [n, i] = C(
|
|
704
703
|
/* @__PURE__ */ new Map()
|
|
705
704
|
);
|
|
706
705
|
return x(() => {
|
|
707
706
|
const o = /* @__PURE__ */ new Set(), s = () => {
|
|
708
707
|
e.getEditorState().read(() => {
|
|
709
|
-
const
|
|
710
|
-
for (const
|
|
711
|
-
const
|
|
712
|
-
if (ye(
|
|
713
|
-
const
|
|
714
|
-
|
|
715
|
-
noteType:
|
|
716
|
-
elem:
|
|
708
|
+
const l = /* @__PURE__ */ new Map();
|
|
709
|
+
for (const a of o) {
|
|
710
|
+
const c = H(a);
|
|
711
|
+
if (ye(c)) {
|
|
712
|
+
const u = e.getElementByKey(a);
|
|
713
|
+
u && l.set(a, {
|
|
714
|
+
noteType: c.getNoteType(),
|
|
715
|
+
elem: u
|
|
717
716
|
});
|
|
718
717
|
}
|
|
719
718
|
}
|
|
720
|
-
i(
|
|
719
|
+
i(l);
|
|
721
720
|
});
|
|
722
721
|
}, r = e.registerMutationListener(
|
|
723
722
|
W,
|
|
724
|
-
(
|
|
725
|
-
for (const [
|
|
726
|
-
|
|
723
|
+
(l) => {
|
|
724
|
+
for (const [a, c] of l)
|
|
725
|
+
c === "destroyed" ? o.delete(a) : o.add(a);
|
|
727
726
|
s();
|
|
728
727
|
},
|
|
729
728
|
{ skipInitialization: !1 }
|
|
730
|
-
),
|
|
731
|
-
let
|
|
732
|
-
for (const
|
|
733
|
-
if (
|
|
734
|
-
|
|
729
|
+
), h = e.registerUpdateListener(({ dirtyElements: l }) => {
|
|
730
|
+
let a = !1;
|
|
731
|
+
for (const c of o)
|
|
732
|
+
if (l.has(c)) {
|
|
733
|
+
a = !0;
|
|
735
734
|
break;
|
|
736
735
|
}
|
|
737
|
-
|
|
736
|
+
a && s();
|
|
738
737
|
});
|
|
739
738
|
return () => {
|
|
740
|
-
r(),
|
|
739
|
+
r(), h();
|
|
741
740
|
};
|
|
742
741
|
}, [e]), /* @__PURE__ */ t(te, { children: Array.from(n.entries()).map(([o, { noteType: s, elem: r }]) => /* @__PURE__ */ t(
|
|
743
|
-
|
|
742
|
+
Qt,
|
|
744
743
|
{
|
|
745
744
|
noteType: s,
|
|
746
745
|
nodeKey: o,
|
|
@@ -749,14 +748,14 @@ function Qt() {
|
|
|
749
748
|
o
|
|
750
749
|
)) });
|
|
751
750
|
}
|
|
752
|
-
const
|
|
753
|
-
...
|
|
754
|
-
|
|
755
|
-
|
|
751
|
+
const qt = [
|
|
752
|
+
...vt,
|
|
753
|
+
Nt,
|
|
754
|
+
Ct
|
|
756
755
|
];
|
|
757
|
-
function
|
|
756
|
+
function Zt() {
|
|
758
757
|
const [e] = _();
|
|
759
|
-
return x(() =>
|
|
758
|
+
return x(() => yt(e, qt), [e]), null;
|
|
760
759
|
}
|
|
761
760
|
const Ne = [
|
|
762
761
|
{ value: null, label: "Default" },
|
|
@@ -778,14 +777,14 @@ const Ne = [
|
|
|
778
777
|
css: '"Space Grotesk", sans-serif'
|
|
779
778
|
}
|
|
780
779
|
];
|
|
781
|
-
function
|
|
780
|
+
function en(e) {
|
|
782
781
|
return e ? e.includes("SF Mono") || e.includes("Fira Code") ? U[1].value : e.includes("Space Grotesk") ? U[2].value : null : null;
|
|
783
782
|
}
|
|
784
783
|
const re = 10, se = 36, ue = 16;
|
|
785
784
|
function Ce() {
|
|
786
|
-
const [e] = _(), [n, i] = C(/* @__PURE__ */ new Set()), [o, s] = C(ue), [r,
|
|
785
|
+
const [e] = _(), [n, i] = C(/* @__PURE__ */ new Set()), [o, s] = C(ue), [r, h] = C(null), [l, a] = C(
|
|
787
786
|
null
|
|
788
|
-
),
|
|
787
|
+
), c = w(() => {
|
|
789
788
|
e.getEditorState().read(() => {
|
|
790
789
|
const p = E();
|
|
791
790
|
if (!L(p)) return;
|
|
@@ -802,23 +801,23 @@ function Ce() {
|
|
|
802
801
|
"color",
|
|
803
802
|
""
|
|
804
803
|
);
|
|
805
|
-
|
|
804
|
+
h(g || null);
|
|
806
805
|
const M = q(
|
|
807
806
|
p,
|
|
808
807
|
"font-family",
|
|
809
808
|
""
|
|
810
809
|
);
|
|
811
|
-
|
|
810
|
+
a(en(M || null));
|
|
812
811
|
});
|
|
813
812
|
}, [e]);
|
|
814
813
|
x(() => e.registerCommand(
|
|
815
814
|
ge,
|
|
816
|
-
() => (
|
|
815
|
+
() => (c(), !1),
|
|
817
816
|
$
|
|
818
|
-
), [e,
|
|
819
|
-
const
|
|
817
|
+
), [e, c]), x(() => e.registerUpdateListener(() => c()), [e, c]);
|
|
818
|
+
const u = w(
|
|
820
819
|
(p) => {
|
|
821
|
-
e.dispatchCommand(
|
|
820
|
+
e.dispatchCommand(Xe, p);
|
|
822
821
|
},
|
|
823
822
|
[e]
|
|
824
823
|
), b = w(
|
|
@@ -849,7 +848,7 @@ function Ce() {
|
|
|
849
848
|
});
|
|
850
849
|
},
|
|
851
850
|
[e]
|
|
852
|
-
),
|
|
851
|
+
), f = w(() => {
|
|
853
852
|
e.getEditorState().read(() => {
|
|
854
853
|
const p = E();
|
|
855
854
|
if (L(p)) {
|
|
@@ -860,30 +859,30 @@ function Ce() {
|
|
|
860
859
|
}, [e]), v = w(() => {
|
|
861
860
|
e.update(() => {
|
|
862
861
|
const p = E();
|
|
863
|
-
L(p) &&
|
|
862
|
+
L(p) && ct(p, () => Ie());
|
|
864
863
|
});
|
|
865
864
|
}, [e]);
|
|
866
865
|
return {
|
|
867
866
|
formats: n,
|
|
868
867
|
fontSize: o,
|
|
869
868
|
currentColor: r,
|
|
870
|
-
currentFontFamily:
|
|
871
|
-
toggleFormat:
|
|
869
|
+
currentFontFamily: l,
|
|
870
|
+
toggleFormat: u,
|
|
872
871
|
changeFontSize: b,
|
|
873
872
|
applyColor: m,
|
|
874
873
|
applyFontFamily: S,
|
|
875
|
-
openLinkDialog:
|
|
874
|
+
openLinkDialog: f,
|
|
876
875
|
insertQuote: v
|
|
877
876
|
};
|
|
878
877
|
}
|
|
879
|
-
const
|
|
880
|
-
function
|
|
878
|
+
const tn = 8;
|
|
879
|
+
function nn() {
|
|
881
880
|
var Y;
|
|
882
|
-
const [e] = _(), n = oe(), i = F(null), [o, s] = C(!1), [r,
|
|
881
|
+
const [e] = _(), n = oe(), i = F(null), [o, s] = C(!1), [r, h] = C({ top: 0, left: 0 }), [l, a] = C(!1), [c, u] = C(!1), {
|
|
883
882
|
formats: b,
|
|
884
883
|
fontSize: m,
|
|
885
884
|
currentColor: S,
|
|
886
|
-
currentFontFamily:
|
|
885
|
+
currentFontFamily: f,
|
|
887
886
|
toggleFormat: v,
|
|
888
887
|
changeFontSize: p,
|
|
889
888
|
applyColor: d,
|
|
@@ -921,8 +920,8 @@ function tn() {
|
|
|
921
920
|
}
|
|
922
921
|
const D = B.getBoundingClientRect(), R = i.current, T = (R == null ? void 0 : R.offsetWidth) ?? 300;
|
|
923
922
|
let I = z.left - D.left + z.width / 2;
|
|
924
|
-
I = Math.max(T / 2 + 4, I), I = Math.min(D.width - T / 2 - 4, I),
|
|
925
|
-
top: z.top - D.top -
|
|
923
|
+
I = Math.max(T / 2 + 4, I), I = Math.min(D.width - T / 2 - 4, I), h({
|
|
924
|
+
top: z.top - D.top - tn,
|
|
926
925
|
left: I
|
|
927
926
|
}), s(!0);
|
|
928
927
|
}, [e, n]);
|
|
@@ -931,12 +930,12 @@ function tn() {
|
|
|
931
930
|
() => (M(), !1),
|
|
932
931
|
$
|
|
933
932
|
), [e, M]), x(() => e.registerUpdateListener(() => M()), [e, M]), x(() => {
|
|
934
|
-
if (!
|
|
933
|
+
if (!l && !c) return;
|
|
935
934
|
const N = (A) => {
|
|
936
|
-
i.current && !i.current.contains(A.target) && (
|
|
935
|
+
i.current && !i.current.contains(A.target) && (a(!1), u(!1));
|
|
937
936
|
};
|
|
938
937
|
return document.addEventListener("mousedown", N), () => document.removeEventListener("mousedown", N);
|
|
939
|
-
}, [
|
|
938
|
+
}, [l, c]), o ? /* @__PURE__ */ y(
|
|
940
939
|
"div",
|
|
941
940
|
{
|
|
942
941
|
ref: i,
|
|
@@ -1046,9 +1045,9 @@ function tn() {
|
|
|
1046
1045
|
/* @__PURE__ */ t(
|
|
1047
1046
|
"button",
|
|
1048
1047
|
{
|
|
1049
|
-
className: `silk-ft-btn silk-ft-btn--color${
|
|
1048
|
+
className: `silk-ft-btn silk-ft-btn--color${l ? " silk-ft-btn--active" : ""}`,
|
|
1050
1049
|
onClick: () => {
|
|
1051
|
-
|
|
1050
|
+
a(!l), u(!1);
|
|
1052
1051
|
},
|
|
1053
1052
|
type: "button",
|
|
1054
1053
|
title: "Text color",
|
|
@@ -1062,12 +1061,12 @@ function tn() {
|
|
|
1062
1061
|
)
|
|
1063
1062
|
}
|
|
1064
1063
|
),
|
|
1065
|
-
|
|
1064
|
+
l && /* @__PURE__ */ t("div", { className: "silk-ft-color-grid", children: Ne.map((N) => /* @__PURE__ */ t(
|
|
1066
1065
|
"button",
|
|
1067
1066
|
{
|
|
1068
1067
|
className: `silk-ft-color-swatch${S === N.value || !S && N.value === null ? " silk-ft-color-swatch--active" : ""}`,
|
|
1069
1068
|
onClick: () => {
|
|
1070
|
-
d(N.value),
|
|
1069
|
+
d(N.value), a(!1);
|
|
1071
1070
|
},
|
|
1072
1071
|
type: "button",
|
|
1073
1072
|
title: N.label,
|
|
@@ -1096,26 +1095,26 @@ function tn() {
|
|
|
1096
1095
|
/* @__PURE__ */ t(
|
|
1097
1096
|
"button",
|
|
1098
1097
|
{
|
|
1099
|
-
className: `silk-ft-btn${
|
|
1098
|
+
className: `silk-ft-btn${c ? " silk-ft-btn--active" : ""}`,
|
|
1100
1099
|
onClick: () => {
|
|
1101
|
-
|
|
1100
|
+
u(!c), a(!1);
|
|
1102
1101
|
},
|
|
1103
1102
|
type: "button",
|
|
1104
1103
|
title: "Font family",
|
|
1105
1104
|
style: {
|
|
1106
|
-
fontFamily: ((Y = U.find((N) => N.value ===
|
|
1105
|
+
fontFamily: ((Y = U.find((N) => N.value === f)) == null ? void 0 : Y.css) ?? '"Inter", sans-serif',
|
|
1107
1106
|
fontSize: 12,
|
|
1108
1107
|
fontWeight: 500
|
|
1109
1108
|
},
|
|
1110
1109
|
children: "Aa"
|
|
1111
1110
|
}
|
|
1112
1111
|
),
|
|
1113
|
-
|
|
1112
|
+
c && /* @__PURE__ */ t("div", { className: "silk-ft-font-dropdown", children: U.map((N) => /* @__PURE__ */ t(
|
|
1114
1113
|
"button",
|
|
1115
1114
|
{
|
|
1116
|
-
className: `silk-ft-font-option${
|
|
1115
|
+
className: `silk-ft-font-option${f === N.value ? " silk-ft-font-option--active" : ""}`,
|
|
1117
1116
|
onClick: () => {
|
|
1118
|
-
k(N.value),
|
|
1117
|
+
k(N.value), u(!1);
|
|
1119
1118
|
},
|
|
1120
1119
|
onMouseDown: (A) => A.preventDefault(),
|
|
1121
1120
|
type: "button",
|
|
@@ -1129,27 +1128,27 @@ function tn() {
|
|
|
1129
1128
|
}
|
|
1130
1129
|
) : null;
|
|
1131
1130
|
}
|
|
1132
|
-
function
|
|
1131
|
+
function on() {
|
|
1133
1132
|
var k;
|
|
1134
|
-
const [e] = _(), [n, i] = C(() => e.isEditable()), o = F(null), [s, r] = C(!1), [
|
|
1135
|
-
formats:
|
|
1136
|
-
fontSize:
|
|
1137
|
-
currentColor:
|
|
1133
|
+
const [e] = _(), [n, i] = C(() => e.isEditable()), o = F(null), [s, r] = C(!1), [h, l] = C(!1), {
|
|
1134
|
+
formats: a,
|
|
1135
|
+
fontSize: c,
|
|
1136
|
+
currentColor: u,
|
|
1138
1137
|
currentFontFamily: b,
|
|
1139
1138
|
toggleFormat: m,
|
|
1140
1139
|
changeFontSize: S,
|
|
1141
|
-
applyColor:
|
|
1140
|
+
applyColor: f,
|
|
1142
1141
|
applyFontFamily: v,
|
|
1143
1142
|
openLinkDialog: p,
|
|
1144
1143
|
insertQuote: d
|
|
1145
1144
|
} = Ce();
|
|
1146
1145
|
return x(() => e.registerEditableListener(i), [e]), x(() => {
|
|
1147
|
-
if (!s && !
|
|
1146
|
+
if (!s && !h) return;
|
|
1148
1147
|
const g = (M) => {
|
|
1149
|
-
o.current && !o.current.contains(M.target) && (r(!1),
|
|
1148
|
+
o.current && !o.current.contains(M.target) && (r(!1), l(!1));
|
|
1150
1149
|
};
|
|
1151
1150
|
return document.addEventListener("mousedown", g), () => document.removeEventListener("mousedown", g);
|
|
1152
|
-
}, [s,
|
|
1151
|
+
}, [s, h]), /* @__PURE__ */ y(
|
|
1153
1152
|
"div",
|
|
1154
1153
|
{
|
|
1155
1154
|
ref: o,
|
|
@@ -1160,7 +1159,7 @@ function nn() {
|
|
|
1160
1159
|
/* @__PURE__ */ t(
|
|
1161
1160
|
"button",
|
|
1162
1161
|
{
|
|
1163
|
-
className: `silk-ft-btn${
|
|
1162
|
+
className: `silk-ft-btn${a.has("bold") ? " silk-ft-btn--active" : ""}`,
|
|
1164
1163
|
onClick: () => m("bold"),
|
|
1165
1164
|
type: "button",
|
|
1166
1165
|
title: "Bold",
|
|
@@ -1170,7 +1169,7 @@ function nn() {
|
|
|
1170
1169
|
/* @__PURE__ */ t(
|
|
1171
1170
|
"button",
|
|
1172
1171
|
{
|
|
1173
|
-
className: `silk-ft-btn${
|
|
1172
|
+
className: `silk-ft-btn${a.has("italic") ? " silk-ft-btn--active" : ""}`,
|
|
1174
1173
|
onClick: () => m("italic"),
|
|
1175
1174
|
type: "button",
|
|
1176
1175
|
title: "Italic",
|
|
@@ -1180,7 +1179,7 @@ function nn() {
|
|
|
1180
1179
|
/* @__PURE__ */ t(
|
|
1181
1180
|
"button",
|
|
1182
1181
|
{
|
|
1183
|
-
className: `silk-ft-btn${
|
|
1182
|
+
className: `silk-ft-btn${a.has("underline") ? " silk-ft-btn--active" : ""}`,
|
|
1184
1183
|
onClick: () => m("underline"),
|
|
1185
1184
|
type: "button",
|
|
1186
1185
|
title: "Underline",
|
|
@@ -1190,7 +1189,7 @@ function nn() {
|
|
|
1190
1189
|
/* @__PURE__ */ t(
|
|
1191
1190
|
"button",
|
|
1192
1191
|
{
|
|
1193
|
-
className: `silk-ft-btn silk-ft-btn--mono${
|
|
1192
|
+
className: `silk-ft-btn silk-ft-btn--mono${a.has("code") ? " silk-ft-btn--active" : ""}`,
|
|
1194
1193
|
onClick: () => m("code"),
|
|
1195
1194
|
type: "button",
|
|
1196
1195
|
title: "Inline code",
|
|
@@ -1258,19 +1257,19 @@ function nn() {
|
|
|
1258
1257
|
{
|
|
1259
1258
|
className: "silk-ft-btn silk-ft-btn--sm",
|
|
1260
1259
|
onClick: () => S(-1),
|
|
1261
|
-
disabled:
|
|
1260
|
+
disabled: c <= re,
|
|
1262
1261
|
type: "button",
|
|
1263
1262
|
title: "Decrease font size",
|
|
1264
1263
|
children: "−"
|
|
1265
1264
|
}
|
|
1266
1265
|
),
|
|
1267
|
-
/* @__PURE__ */ t("span", { className: "silk-ft-font-size-value", children:
|
|
1266
|
+
/* @__PURE__ */ t("span", { className: "silk-ft-font-size-value", children: c }),
|
|
1268
1267
|
/* @__PURE__ */ t(
|
|
1269
1268
|
"button",
|
|
1270
1269
|
{
|
|
1271
1270
|
className: "silk-ft-btn silk-ft-btn--sm",
|
|
1272
1271
|
onClick: () => S(1),
|
|
1273
|
-
disabled:
|
|
1272
|
+
disabled: c >= se,
|
|
1274
1273
|
type: "button",
|
|
1275
1274
|
title: "Increase font size",
|
|
1276
1275
|
children: "+"
|
|
@@ -1284,7 +1283,7 @@ function nn() {
|
|
|
1284
1283
|
{
|
|
1285
1284
|
className: `silk-ft-btn silk-ft-btn--color${s ? " silk-ft-btn--active" : ""}`,
|
|
1286
1285
|
onClick: () => {
|
|
1287
|
-
r(!s),
|
|
1286
|
+
r(!s), l(!1);
|
|
1288
1287
|
},
|
|
1289
1288
|
type: "button",
|
|
1290
1289
|
title: "Text color",
|
|
@@ -1292,7 +1291,7 @@ function nn() {
|
|
|
1292
1291
|
"span",
|
|
1293
1292
|
{
|
|
1294
1293
|
className: "silk-ft-color-indicator",
|
|
1295
|
-
style: { borderBottomColor:
|
|
1294
|
+
style: { borderBottomColor: u || "#1a1a1a" },
|
|
1296
1295
|
children: "A"
|
|
1297
1296
|
}
|
|
1298
1297
|
)
|
|
@@ -1301,9 +1300,9 @@ function nn() {
|
|
|
1301
1300
|
s && /* @__PURE__ */ t("div", { className: "silk-ft-color-grid", children: Ne.map((g) => /* @__PURE__ */ t(
|
|
1302
1301
|
"button",
|
|
1303
1302
|
{
|
|
1304
|
-
className: `silk-ft-color-swatch${
|
|
1303
|
+
className: `silk-ft-color-swatch${u === g.value || !u && g.value === null ? " silk-ft-color-swatch--active" : ""}`,
|
|
1305
1304
|
onClick: () => {
|
|
1306
|
-
|
|
1305
|
+
f(g.value), r(!1);
|
|
1307
1306
|
},
|
|
1308
1307
|
type: "button",
|
|
1309
1308
|
title: g.label,
|
|
@@ -1332,9 +1331,9 @@ function nn() {
|
|
|
1332
1331
|
/* @__PURE__ */ t(
|
|
1333
1332
|
"button",
|
|
1334
1333
|
{
|
|
1335
|
-
className: `silk-ft-btn${
|
|
1334
|
+
className: `silk-ft-btn${h ? " silk-ft-btn--active" : ""}`,
|
|
1336
1335
|
onClick: () => {
|
|
1337
|
-
|
|
1336
|
+
l(!h), r(!1);
|
|
1338
1337
|
},
|
|
1339
1338
|
type: "button",
|
|
1340
1339
|
title: "Font family",
|
|
@@ -1346,12 +1345,12 @@ function nn() {
|
|
|
1346
1345
|
children: "Aa"
|
|
1347
1346
|
}
|
|
1348
1347
|
),
|
|
1349
|
-
|
|
1348
|
+
h && /* @__PURE__ */ t("div", { className: "silk-ft-font-dropdown", children: U.map((g) => /* @__PURE__ */ t(
|
|
1350
1349
|
"button",
|
|
1351
1350
|
{
|
|
1352
1351
|
className: `silk-ft-font-option${b === g.value ? " silk-ft-font-option--active" : ""}`,
|
|
1353
1352
|
onClick: () => {
|
|
1354
|
-
v(g.value),
|
|
1353
|
+
v(g.value), l(!1);
|
|
1355
1354
|
},
|
|
1356
1355
|
onMouseDown: (M) => M.preventDefault(),
|
|
1357
1356
|
type: "button",
|
|
@@ -1365,71 +1364,71 @@ function nn() {
|
|
|
1365
1364
|
}
|
|
1366
1365
|
);
|
|
1367
1366
|
}
|
|
1368
|
-
function
|
|
1367
|
+
function rn() {
|
|
1369
1368
|
const [e] = _();
|
|
1370
1369
|
return x(() => {
|
|
1371
1370
|
const n = e.getRootElement();
|
|
1372
1371
|
if (!n) return;
|
|
1373
1372
|
const i = (o) => {
|
|
1374
1373
|
if (e.isEditable() && !(o.metaKey || o.ctrlKey)) return;
|
|
1375
|
-
const
|
|
1376
|
-
!
|
|
1377
|
-
const
|
|
1378
|
-
if (!
|
|
1379
|
-
const
|
|
1380
|
-
if (
|
|
1381
|
-
const
|
|
1382
|
-
|
|
1374
|
+
const h = o.target.closest("a");
|
|
1375
|
+
!h || !n.contains(h) || e.getEditorState().read(() => {
|
|
1376
|
+
const l = qe(h);
|
|
1377
|
+
if (!l) return;
|
|
1378
|
+
const a = l.getParent(), c = ce(l) ? l : ce(a) ? a : null;
|
|
1379
|
+
if (c) {
|
|
1380
|
+
const u = c.getURL();
|
|
1381
|
+
u && (o.preventDefault(), window.open(u, "_blank", "noopener,noreferrer"));
|
|
1383
1382
|
}
|
|
1384
1383
|
});
|
|
1385
1384
|
};
|
|
1386
1385
|
return n.addEventListener("click", i), () => n.removeEventListener("click", i);
|
|
1387
1386
|
}, [e]), null;
|
|
1388
1387
|
}
|
|
1389
|
-
function
|
|
1388
|
+
function sn() {
|
|
1390
1389
|
const [e] = _();
|
|
1391
|
-
return x(() =>
|
|
1390
|
+
return x(() => ze(e), [e]), /* @__PURE__ */ t(bt, {});
|
|
1392
1391
|
}
|
|
1393
|
-
const
|
|
1394
|
-
function
|
|
1392
|
+
const ln = ["nw", "ne", "sw", "se"];
|
|
1393
|
+
function an({
|
|
1395
1394
|
src: e,
|
|
1396
1395
|
altText: n,
|
|
1397
1396
|
width: i,
|
|
1398
1397
|
height: o,
|
|
1399
1398
|
nodeKey: s
|
|
1400
1399
|
}) {
|
|
1401
|
-
const [r] = _(),
|
|
1402
|
-
(d) =>
|
|
1403
|
-
[
|
|
1404
|
-
),
|
|
1405
|
-
(d) =>
|
|
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(() => {
|
|
1406
1405
|
const k = H(s);
|
|
1407
1406
|
k && k.remove();
|
|
1408
1407
|
}), !0) : !1,
|
|
1409
|
-
[r,
|
|
1408
|
+
[r, a, b, s]
|
|
1410
1409
|
);
|
|
1411
1410
|
x(() => {
|
|
1412
1411
|
const d = r.registerCommand(
|
|
1413
|
-
|
|
1412
|
+
tt,
|
|
1414
1413
|
S,
|
|
1415
1414
|
$
|
|
1416
1415
|
), k = r.registerCommand(
|
|
1417
|
-
|
|
1418
|
-
|
|
1416
|
+
nt,
|
|
1417
|
+
f,
|
|
1419
1418
|
$
|
|
1420
1419
|
), g = r.registerCommand(
|
|
1421
|
-
|
|
1422
|
-
|
|
1420
|
+
ot,
|
|
1421
|
+
f,
|
|
1423
1422
|
$
|
|
1424
1423
|
);
|
|
1425
1424
|
return () => {
|
|
1426
1425
|
d(), k(), g();
|
|
1427
1426
|
};
|
|
1428
|
-
}, [r, S,
|
|
1427
|
+
}, [r, S, f]);
|
|
1429
1428
|
const v = w(
|
|
1430
1429
|
(d, k) => {
|
|
1431
1430
|
k.preventDefault(), k.stopPropagation(), m(!0);
|
|
1432
|
-
const g =
|
|
1431
|
+
const g = l.current;
|
|
1433
1432
|
if (!g) return;
|
|
1434
1433
|
const M = k.clientX, Y = k.clientY, N = g.offsetWidth, A = g.offsetHeight, P = N / A, Q = (B) => {
|
|
1435
1434
|
let D = B.clientX - M;
|
|
@@ -1449,7 +1448,7 @@ function ln({
|
|
|
1449
1448
|
const D = g.offsetWidth, R = g.offsetHeight;
|
|
1450
1449
|
r.update(() => {
|
|
1451
1450
|
const T = H(s);
|
|
1452
|
-
if (T &&
|
|
1451
|
+
if (T && cn(T)) {
|
|
1453
1452
|
const I = T.getWritable();
|
|
1454
1453
|
I.__width = D, I.__height = R;
|
|
1455
1454
|
}
|
|
@@ -1462,13 +1461,13 @@ function ln({
|
|
|
1462
1461
|
return /* @__PURE__ */ y(
|
|
1463
1462
|
"div",
|
|
1464
1463
|
{
|
|
1465
|
-
ref:
|
|
1466
|
-
className: `silk-image-container${
|
|
1464
|
+
ref: h,
|
|
1465
|
+
className: `silk-image-container${a ? " silk-image-container--selected" : ""}`,
|
|
1467
1466
|
children: [
|
|
1468
1467
|
/* @__PURE__ */ t(
|
|
1469
1468
|
"img",
|
|
1470
1469
|
{
|
|
1471
|
-
ref:
|
|
1470
|
+
ref: l,
|
|
1472
1471
|
src: e,
|
|
1473
1472
|
alt: n,
|
|
1474
1473
|
width: i,
|
|
@@ -1477,7 +1476,7 @@ function ln({
|
|
|
1477
1476
|
draggable: !1
|
|
1478
1477
|
}
|
|
1479
1478
|
),
|
|
1480
|
-
|
|
1479
|
+
a && p && /* @__PURE__ */ t(te, { children: ln.map((d) => /* @__PURE__ */ t(
|
|
1481
1480
|
"div",
|
|
1482
1481
|
{
|
|
1483
1482
|
className: `silk-image-handle silk-image-handle--${d}`,
|
|
@@ -1489,7 +1488,7 @@ function ln({
|
|
|
1489
1488
|
}
|
|
1490
1489
|
);
|
|
1491
1490
|
}
|
|
1492
|
-
class V extends
|
|
1491
|
+
class V extends et {
|
|
1493
1492
|
static getType() {
|
|
1494
1493
|
return "image";
|
|
1495
1494
|
}
|
|
@@ -1559,7 +1558,7 @@ class V extends Ze {
|
|
|
1559
1558
|
}
|
|
1560
1559
|
decorate(n) {
|
|
1561
1560
|
return /* @__PURE__ */ t(
|
|
1562
|
-
|
|
1561
|
+
an,
|
|
1563
1562
|
{
|
|
1564
1563
|
src: this.__src,
|
|
1565
1564
|
altText: this.__altText,
|
|
@@ -1571,63 +1570,63 @@ class V extends Ze {
|
|
|
1571
1570
|
}
|
|
1572
1571
|
}
|
|
1573
1572
|
function ee(e, n = "", i, o) {
|
|
1574
|
-
return
|
|
1573
|
+
return Ze(new V(e, n, i, o));
|
|
1575
1574
|
}
|
|
1576
|
-
function
|
|
1575
|
+
function cn(e) {
|
|
1577
1576
|
return e instanceof V;
|
|
1578
1577
|
}
|
|
1579
1578
|
function fe(e) {
|
|
1580
1579
|
return e.type.startsWith("image/");
|
|
1581
1580
|
}
|
|
1582
|
-
function
|
|
1581
|
+
function dn(e) {
|
|
1583
1582
|
return new Promise((n, i) => {
|
|
1584
1583
|
const o = new FileReader();
|
|
1585
1584
|
o.onload = () => n(o.result), o.onerror = () => i(o.error), o.readAsDataURL(e);
|
|
1586
1585
|
});
|
|
1587
1586
|
}
|
|
1588
|
-
function
|
|
1587
|
+
function un() {
|
|
1589
1588
|
const [e] = _();
|
|
1590
1589
|
return x(() => {
|
|
1591
1590
|
const n = (r) => {
|
|
1592
|
-
for (const
|
|
1593
|
-
|
|
1591
|
+
for (const h of r)
|
|
1592
|
+
dn(h).then((l) => {
|
|
1594
1593
|
e.update(() => {
|
|
1595
|
-
const
|
|
1596
|
-
if (L(
|
|
1597
|
-
|
|
1598
|
-
else if (
|
|
1599
|
-
const
|
|
1600
|
-
m ? m.insertAfter(
|
|
1594
|
+
const a = ee(l, h.name), c = E();
|
|
1595
|
+
if (L(c))
|
|
1596
|
+
c.focus.getNode().getTopLevelElementOrThrow().insertAfter(a);
|
|
1597
|
+
else if (lt(c)) {
|
|
1598
|
+
const u = c.getNodes(), m = u[u.length - 1].getTopLevelElement();
|
|
1599
|
+
m ? m.insertAfter(a) : de().append(a);
|
|
1601
1600
|
} else
|
|
1602
|
-
de().append(
|
|
1601
|
+
de().append(a);
|
|
1603
1602
|
});
|
|
1604
1603
|
});
|
|
1605
1604
|
}, i = e.registerCommand(
|
|
1606
|
-
|
|
1605
|
+
it,
|
|
1607
1606
|
(r) => {
|
|
1608
|
-
var
|
|
1609
|
-
const
|
|
1610
|
-
if (!
|
|
1611
|
-
const
|
|
1612
|
-
return
|
|
1607
|
+
var a;
|
|
1608
|
+
const h = (a = r.clipboardData) == null ? void 0 : a.files;
|
|
1609
|
+
if (!h || h.length === 0) return !1;
|
|
1610
|
+
const l = Array.from(h).filter(fe);
|
|
1611
|
+
return l.length === 0 ? !1 : (r.preventDefault(), n(l), !0);
|
|
1613
1612
|
},
|
|
1614
1613
|
X
|
|
1615
1614
|
), o = e.registerCommand(
|
|
1616
|
-
|
|
1615
|
+
rt,
|
|
1617
1616
|
(r) => {
|
|
1618
|
-
var
|
|
1619
|
-
const
|
|
1620
|
-
if (!
|
|
1621
|
-
const
|
|
1622
|
-
return
|
|
1617
|
+
var a;
|
|
1618
|
+
const h = (a = r.dataTransfer) == null ? void 0 : a.files;
|
|
1619
|
+
if (!h || h.length === 0) return !1;
|
|
1620
|
+
const l = Array.from(h).filter(fe);
|
|
1621
|
+
return l.length === 0 ? !1 : (r.preventDefault(), n(l), !0);
|
|
1623
1622
|
},
|
|
1624
1623
|
X
|
|
1625
1624
|
), s = e.registerCommand(
|
|
1626
|
-
|
|
1625
|
+
st,
|
|
1627
1626
|
(r) => {
|
|
1628
|
-
var
|
|
1629
|
-
const
|
|
1630
|
-
return
|
|
1627
|
+
var l;
|
|
1628
|
+
const h = (l = r.dataTransfer) == null ? void 0 : l.types;
|
|
1629
|
+
return h && h.includes("Files") ? (r.preventDefault(), !0) : !1;
|
|
1631
1630
|
},
|
|
1632
1631
|
X
|
|
1633
1632
|
);
|
|
@@ -1636,7 +1635,7 @@ function dn() {
|
|
|
1636
1635
|
};
|
|
1637
1636
|
}, [e]), null;
|
|
1638
1637
|
}
|
|
1639
|
-
const
|
|
1638
|
+
const fn = {
|
|
1640
1639
|
root: "silk-root",
|
|
1641
1640
|
paragraph: "silk-paragraph",
|
|
1642
1641
|
link: "silk-link",
|
|
@@ -1659,17 +1658,17 @@ const un = {
|
|
|
1659
1658
|
strikethrough: "silk-text-strikethrough",
|
|
1660
1659
|
code: "silk-text-code"
|
|
1661
1660
|
}
|
|
1662
|
-
},
|
|
1661
|
+
}, hn = {
|
|
1663
1662
|
heading: {
|
|
1664
1663
|
h1: "silk-heading-h1",
|
|
1665
1664
|
h2: "silk-heading-h2",
|
|
1666
1665
|
h3: "silk-heading-h3"
|
|
1667
1666
|
},
|
|
1668
1667
|
quote: "silk-quote"
|
|
1669
|
-
},
|
|
1668
|
+
}, pn = {
|
|
1670
1669
|
code: "silk-code-block"
|
|
1671
1670
|
};
|
|
1672
|
-
function
|
|
1671
|
+
function mn(...e) {
|
|
1673
1672
|
const n = {};
|
|
1674
1673
|
for (const i of e)
|
|
1675
1674
|
for (const [o, s] of Object.entries(i)) {
|
|
@@ -1678,87 +1677,94 @@ function pn(...e) {
|
|
|
1678
1677
|
}
|
|
1679
1678
|
return n;
|
|
1680
1679
|
}
|
|
1681
|
-
function
|
|
1682
|
-
const i = [
|
|
1683
|
-
return e.richText !== !1 && i.push(
|
|
1680
|
+
function gn(e, n) {
|
|
1681
|
+
const i = [fn];
|
|
1682
|
+
return e.richText !== !1 && i.push(hn), e.code !== !1 && i.push(pn), n && i.push(n), mn(...i);
|
|
1684
1683
|
}
|
|
1685
|
-
function
|
|
1684
|
+
function kn(e) {
|
|
1686
1685
|
const n = [];
|
|
1687
|
-
return e.richText !== !1 && n.push(
|
|
1686
|
+
return e.richText !== !1 && n.push(Oe, Re), e.code !== !1 && n.push(pe, Ae), e.lists !== !1 && n.push(Be, He), n.push(W, We, Ve, V), n;
|
|
1688
1687
|
}
|
|
1689
|
-
function
|
|
1688
|
+
function bn({ editable: e }) {
|
|
1690
1689
|
const [n] = _();
|
|
1691
1690
|
return x(() => {
|
|
1692
1691
|
n.setEditable(e);
|
|
1693
1692
|
}, [n, e]), null;
|
|
1694
1693
|
}
|
|
1695
|
-
|
|
1694
|
+
function yn({
|
|
1695
|
+
handleRef: e
|
|
1696
|
+
}) {
|
|
1697
|
+
const [n] = _();
|
|
1698
|
+
return Ee(
|
|
1699
|
+
e,
|
|
1700
|
+
() => ({
|
|
1701
|
+
getState: () => JSON.stringify(n.getEditorState().toJSON())
|
|
1702
|
+
}),
|
|
1703
|
+
[n]
|
|
1704
|
+
), null;
|
|
1705
|
+
}
|
|
1706
|
+
const vn = {
|
|
1696
1707
|
history: !0,
|
|
1697
1708
|
richText: !0,
|
|
1698
1709
|
dragon: !0,
|
|
1699
1710
|
code: !0,
|
|
1700
1711
|
lists: !0
|
|
1701
|
-
}
|
|
1702
|
-
function
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
/* @__PURE__ */ t(tn, {})
|
|
1751
|
-
]
|
|
1752
|
-
}
|
|
1753
|
-
) }) });
|
|
1754
|
-
}
|
|
1712
|
+
}, Yn = Me(
|
|
1713
|
+
function({
|
|
1714
|
+
features: n,
|
|
1715
|
+
namespace: i = "silk-editor",
|
|
1716
|
+
className: o,
|
|
1717
|
+
theme: s,
|
|
1718
|
+
editable: r = !0,
|
|
1719
|
+
onError: h,
|
|
1720
|
+
initialEditorState: l
|
|
1721
|
+
}, a) {
|
|
1722
|
+
const c = F(null), u = {
|
|
1723
|
+
...vn,
|
|
1724
|
+
...n
|
|
1725
|
+
}, b = gn(u, s), m = kn(u);
|
|
1726
|
+
return /* @__PURE__ */ t(Le, { initialConfig: {
|
|
1727
|
+
namespace: i,
|
|
1728
|
+
theme: b,
|
|
1729
|
+
nodes: m,
|
|
1730
|
+
editable: r,
|
|
1731
|
+
editorState: l ?? void 0,
|
|
1732
|
+
onError: h ?? ((f) => console.error(f))
|
|
1733
|
+
}, children: /* @__PURE__ */ t(ke.Provider, { value: c, children: /* @__PURE__ */ y(
|
|
1734
|
+
"div",
|
|
1735
|
+
{
|
|
1736
|
+
ref: c,
|
|
1737
|
+
className: `silk-editor-container${o ? ` ${o}` : ""}`,
|
|
1738
|
+
children: [
|
|
1739
|
+
/* @__PURE__ */ t(on, {}),
|
|
1740
|
+
u.richText && /* @__PURE__ */ t(Et, {}),
|
|
1741
|
+
u.history && /* @__PURE__ */ t(Mt, {}),
|
|
1742
|
+
u.dragon && /* @__PURE__ */ t(Lt, {}),
|
|
1743
|
+
u.code && /* @__PURE__ */ t(Ot, {}),
|
|
1744
|
+
u.lists && /* @__PURE__ */ t(sn, {}),
|
|
1745
|
+
/* @__PURE__ */ t(De, {}),
|
|
1746
|
+
/* @__PURE__ */ t(Te, {}),
|
|
1747
|
+
/* @__PURE__ */ t(Xt, {}),
|
|
1748
|
+
/* @__PURE__ */ t(Rt, {}),
|
|
1749
|
+
/* @__PURE__ */ t(Zt, {}),
|
|
1750
|
+
/* @__PURE__ */ t(rn, {}),
|
|
1751
|
+
/* @__PURE__ */ t(un, {}),
|
|
1752
|
+
/* @__PURE__ */ t(bn, { editable: r }),
|
|
1753
|
+
/* @__PURE__ */ t(yn, { handleRef: a }),
|
|
1754
|
+
/* @__PURE__ */ t(jt, {}),
|
|
1755
|
+
/* @__PURE__ */ t(nn, {})
|
|
1756
|
+
]
|
|
1757
|
+
}
|
|
1758
|
+
) }) });
|
|
1759
|
+
}
|
|
1760
|
+
);
|
|
1755
1761
|
export {
|
|
1756
1762
|
ee as $createImageNode,
|
|
1757
1763
|
be as $createNoteNode,
|
|
1758
|
-
|
|
1764
|
+
cn as $isImageNode,
|
|
1759
1765
|
ye as $isNoteNode,
|
|
1760
1766
|
V as ImageNode,
|
|
1761
1767
|
W as NoteNode,
|
|
1762
|
-
|
|
1763
|
-
|
|
1768
|
+
Yn as SilkEditor,
|
|
1769
|
+
Yn as default
|
|
1764
1770
|
};
|