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/silk.js CHANGED
@@ -1,227 +1,227 @@
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, forwardRef as Me, useImperativeHandle as Ee } from "react";
3
- import { LexicalComposer as Le } from "@lexical/react/LexicalComposer";
4
- import { useLexicalComposerContext as _ } from "@lexical/react/LexicalComposerContext";
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";
25
- function Mt() {
26
- return /* @__PURE__ */ t(ht, {});
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 Et() {
28
+ function Tt() {
29
29
  return /* @__PURE__ */ t("div", { style: { position: "relative" }, children: /* @__PURE__ */ t(
30
- dt,
30
+ ft,
31
31
  {
32
- contentEditable: /* @__PURE__ */ t(ut, { className: "silk-content-editable" }),
32
+ contentEditable: /* @__PURE__ */ t(ht, { className: "silk-content-editable" }),
33
33
  placeholder: /* @__PURE__ */ t("div", { className: "silk-placeholder", children: "Start writing…" }),
34
- ErrorBoundary: ft
34
+ ErrorBoundary: mt
35
35
  }
36
36
  ) });
37
37
  }
38
- function Lt() {
39
- const [e] = _();
40
- return x(() => pt(e), [e]), null;
38
+ function Dt() {
39
+ const [e] = E();
40
+ return _(() => gt(e), [e]), null;
41
41
  }
42
- const ke = Se({
42
+ const be = we({
43
43
  current: null
44
44
  });
45
- function oe() {
46
- return we(ke);
45
+ function se() {
46
+ return Me(be);
47
47
  }
48
- function Tt() {
49
- return kt().map(([e, n]) => ({ value: e, label: n }));
48
+ function It() {
49
+ return bt().map(([e, n]) => ({ value: e, label: n }));
50
50
  }
51
- const Dt = 32;
52
- function It({
51
+ const Ot = 32;
52
+ function Rt({
53
53
  language: e,
54
54
  codeNodeKey: n,
55
- codeElem: i
55
+ codeElem: o
56
56
  }) {
57
- var p;
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]);
60
- const m = w(() => {
61
- const d = s.current;
62
- if (!d) return;
63
- const k = i.getBoundingClientRect(), g = d.getBoundingClientRect();
64
- b({
65
- top: k.top - g.top - Dt,
66
- left: k.left - g.left,
67
- width: k.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
- }, [i, s]);
70
- he(() => {
71
- m();
72
- const d = new ResizeObserver(m);
73
- return d.observe(i), () => d.disconnect();
74
- }, [i, m]), x(() => o.registerUpdateListener(() => {
75
- m();
76
- }), [o, m]);
77
- const S = Tt(), f = ((p = S.find((d) => d.value === e)) == null ? void 0 : p.label) ?? e ?? "Plain Text", v = w(
78
- (d) => {
79
- o.update(() => {
80
- const k = H(n);
81
- ne(k) && k.setLanguage(d);
82
- }), h(!1);
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
- [o, n]
84
+ [i, n]
85
85
  );
86
- return x(() => {
87
- if (!r) return;
88
- const d = (k) => {
89
- c.current && !c.current.contains(k.target) && h(!1);
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", d), () => document.removeEventListener("mousedown", d);
92
- }, [r]), /* @__PURE__ */ y(
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: u.top,
100
- left: u.left,
101
- width: u.width,
99
+ top: d.top,
100
+ left: d.left,
101
+ width: d.width,
102
102
  pointerEvents: "auto"
103
103
  },
104
104
  children: [
105
- /* @__PURE__ */ y(
105
+ /* @__PURE__ */ k(
106
106
  "button",
107
107
  {
108
108
  className: "silk-code-language-select",
109
- onClick: () => l && h(!r),
109
+ onClick: () => l && f(!s),
110
110
  style: { cursor: l ? "pointer" : "default" },
111
- onMouseDown: (d) => d.preventDefault(),
111
+ onMouseDown: (m) => m.preventDefault(),
112
112
  type: "button",
113
113
  children: [
114
- f,
114
+ u,
115
115
  l && /* @__PURE__ */ t("span", { className: "silk-code-language-chevron", "aria-hidden": !0, children: "▾" })
116
116
  ]
117
117
  }
118
118
  ),
119
- r && l && /* @__PURE__ */ t("div", { className: "silk-code-language-dropdown", children: S.map((d) => /* @__PURE__ */ t(
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 === d.value ? " silk-code-language-option--active" : ""}`,
123
- onClick: () => v(d.value),
124
- onMouseDown: (k) => k.preventDefault(),
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: d.label
126
+ children: m.label
127
127
  },
128
- d.value
128
+ m.value
129
129
  )) })
130
130
  ]
131
131
  }
132
132
  );
133
133
  }
134
- function Ot() {
135
- const [e] = _(), [n, i] = C(
134
+ function At() {
135
+ const [e] = E(), [n, o] = C(
136
136
  /* @__PURE__ */ new Map()
137
137
  );
138
- return x(() => mt(e, {
139
- ...gt,
138
+ return _(() => kt(e, {
139
+ ...yt,
140
140
  defaultTheme: "dark-plus"
141
- }), [e]), x(() => {
142
- const o = /* @__PURE__ */ new Set(), s = () => {
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 o) {
146
- const c = H(a);
147
- if (ne(c)) {
148
- const u = e.getElementByKey(a);
149
- u && l.set(a, {
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: u
151
+ elem: d
152
152
  });
153
153
  }
154
154
  }
155
- i(l);
155
+ o(l);
156
156
  });
157
- }, r = e.registerMutationListener(
158
- pe,
157
+ }, s = e.registerMutationListener(
158
+ ge,
159
159
  (l) => {
160
160
  for (const [a, c] of l)
161
- c === "destroyed" ? o.delete(a) : o.add(a);
162
- s();
161
+ c === "destroyed" ? i.delete(a) : i.add(a);
162
+ r();
163
163
  },
164
164
  { skipInitialization: !1 }
165
- ), h = e.registerUpdateListener(({ dirtyElements: l }) => {
165
+ ), f = e.registerUpdateListener(({ dirtyElements: l }) => {
166
166
  let a = !1;
167
- for (const c of o)
167
+ for (const c of i)
168
168
  if (l.has(c)) {
169
169
  a = !0;
170
170
  break;
171
171
  }
172
- a && s();
172
+ a && r();
173
173
  });
174
174
  return () => {
175
- r(), h();
175
+ s(), f();
176
176
  };
177
- }, [e]), /* @__PURE__ */ t(te, { children: Array.from(n.entries()).map(([o, { language: s, elem: r }]) => /* @__PURE__ */ t(
178
- It,
177
+ }, [e]), /* @__PURE__ */ t(ie, { children: Array.from(n.entries()).map(([i, { language: r, elem: s }]) => /* @__PURE__ */ t(
178
+ Rt,
179
179
  {
180
- language: s,
181
- codeNodeKey: o,
182
- codeElem: r
180
+ language: r,
181
+ codeNodeKey: i,
182
+ codeElem: s
183
183
  },
184
- o
184
+ i
185
185
  )) });
186
186
  }
187
- class W extends Ye {
187
+ class G extends Je {
188
188
  static getType() {
189
189
  return "note";
190
190
  }
191
191
  static clone(n) {
192
- return new W(n.__noteType, n.__key);
192
+ return new G(n.__noteType, n.__key);
193
193
  }
194
- constructor(n = "info", i) {
195
- super(i), this.__noteType = n;
194
+ constructor(n = "info", o) {
195
+ super(o), this.__noteType = n;
196
196
  }
197
197
  createDOM(n) {
198
- const i = document.createElement("div");
199
- return i.className = `silk-note silk-note--${this.__noteType}`, i;
198
+ const o = document.createElement("div");
199
+ return o.className = `silk-note silk-note--${this.__noteType}`, o;
200
200
  }
201
- updateDOM(n, i) {
202
- return n.__noteType !== this.__noteType && (i.className = `silk-note silk-note--${this.__noteType}`), !1;
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 i = this.getWritable();
206
- return i.__noteType = n, i;
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, i) {
212
- const o = n.anchor.getNode(), s = this.getLastDescendant();
213
- if (s === null || o === s || o === this && n.anchor.offset === this.getChildrenSize()) {
214
- const r = G();
215
- return this.insertAfter(r, i), r;
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, i);
217
+ return super.insertNewAfter(n, o);
218
218
  }
219
219
  collapseAtStart() {
220
- const n = G(), i = this.getChildren();
221
- return i.length > 0 && i.forEach((o) => n.append(o)), this.replace(n), !0;
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 be(n.noteType);
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 be(e = "info") {
234
- return new W(e);
233
+ function ve(e = "info") {
234
+ return new G(e);
235
235
  }
236
- function ye(e) {
237
- return e instanceof W;
236
+ function Ne(e) {
237
+ return e instanceof G;
238
238
  }
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);
242
- x(() => {
243
- const f = e.registerCommand(
244
- Ke,
245
- (p) => (ae(p, {
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
- ), v = e.registerCommand(
251
- ie,
252
- (p) => {
253
- const d = E();
254
- if (L(d)) {
255
- u.current = d.clone();
256
- const k = d.isCollapsed();
257
- a(!k), k || h(d.getTextContent());
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 (p == null ? void 0 : p.text) !== void 0 && h(p.text), i(!0), !0;
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
- f(), v();
264
+ u(), x();
265
265
  };
266
- }, [e]), x(() => {
266
+ }, [e]), _(() => {
267
267
  n && setTimeout(() => {
268
- var f;
269
- return (f = c.current) == null ? void 0 : f.focus();
268
+ var u;
269
+ return (u = c.current) == null ? void 0 : u.focus();
270
270
  }, 0);
271
271
  }, [n]);
272
- const b = w(() => {
273
- i(!1), s(""), h(""), a(!1), u.current = null, e.focus();
274
- }, [e]), m = w(() => {
275
- o && (e.update(() => {
276
- if (u.current && je(u.current.clone()), l)
277
- ae(o, {
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 f = Ge(o, {
282
+ const u = Ye(i, {
283
283
  target: "_blank",
284
284
  rel: "noopener noreferrer"
285
- }), v = Je(r || o);
286
- f.append(v);
287
- const p = E();
288
- L(p) && p.insertNodes([f]);
285
+ }), x = Xe(s || i);
286
+ u.append(x);
287
+ const w = L();
288
+ T(w) && w.insertNodes([u]);
289
289
  }
290
- }), b());
291
- }, [e, o, r, l, b]), S = w(
292
- (f) => {
293
- f.key === "Enter" && (f.preventDefault(), m()), f.key === "Escape" && b();
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
- [m, b]
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: (f) => {
302
- f.target === f.currentTarget && b();
301
+ onMouseDown: (u) => {
302
+ u.target === u.currentTarget && p();
303
303
  },
304
- children: /* @__PURE__ */ y("div", { className: "silk-link-dialog", onKeyDown: S, children: [
305
- /* @__PURE__ */ y("div", { className: "silk-link-dialog-field", children: [
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: o,
314
- onChange: (f) => s(f.target.value),
313
+ value: i,
314
+ onChange: (u) => r(u.target.value),
315
315
  placeholder: "https://example.com"
316
316
  }
317
317
  )
318
318
  ] }),
319
- /* @__PURE__ */ y("div", { className: "silk-link-dialog-field", children: [
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: r,
327
- onChange: (f) => h(f.target.value),
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__ */ y("div", { className: "silk-link-dialog-actions", children: [
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: b,
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: m,
348
- disabled: !o,
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 Ft = 18;
359
- function O({
358
+ const $t = 18;
359
+ function A({
360
360
  children: e,
361
- size: n = Ft,
362
- className: i
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: i,
375
+ className: o,
376
376
  children: e
377
377
  }
378
378
  );
379
379
  }
380
- function At(e) {
381
- return /* @__PURE__ */ y(O, { ...e, children: [
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 $t(e) {
389
- return /* @__PURE__ */ y(O, { ...e, children: [
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 Pt(e) {
397
- return /* @__PURE__ */ y(O, { ...e, children: [
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 ve(e) {
403
- return /* @__PURE__ */ y(O, { ...e, children: [
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 zt(e) {
410
- return /* @__PURE__ */ y(O, { ...e, children: [
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 Bt(e) {
429
- return /* @__PURE__ */ y(O, { ...e, children: [
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 Ht(e) {
436
- return /* @__PURE__ */ y(O, { ...e, children: [
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 Ut(e) {
442
- return /* @__PURE__ */ y(O, { ...e, children: [
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 Wt(e) {
452
- return /* @__PURE__ */ y(O, { ...e, children: [
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 Kt(e) {
462
- return /* @__PURE__ */ t(O, { ...e, children: /* @__PURE__ */ t("line", { x1: "2", y1: "12", x2: "22", y2: "12" }) });
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 J(e) {
465
- const n = E();
466
- if (!L(n)) return;
467
- const o = n.anchor.getNode().getTopLevelElementOrThrow(), s = e(), r = G();
468
- return o.insertAfter(s), s.insertAfter(r), me(o) && o.getTextContentSize() === 0 && o.remove(), { node: s, trailing: r };
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 Gt = [
470
+ const Yt = [
471
471
  {
472
472
  name: "Heading 1",
473
- icon: /* @__PURE__ */ t(At, {}),
473
+ icon: /* @__PURE__ */ t(Pt, {}),
474
474
  description: "Large section heading",
475
475
  execute: () => {
476
- const e = J(() => le("h1"));
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($t, {}),
482
+ icon: /* @__PURE__ */ t(Bt, {}),
483
483
  description: "Medium section heading",
484
484
  execute: () => {
485
- const e = J(() => le("h2"));
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(Pt, {}),
491
+ icon: /* @__PURE__ */ t(zt, {}),
492
492
  description: "Code with syntax highlighting",
493
493
  execute: () => {
494
- const e = J(() => Fe("typescript"));
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(ve, {}),
500
+ icon: /* @__PURE__ */ t(Ce, {}),
501
501
  description: "Info, warning, or error callout",
502
502
  execute: () => {
503
- const e = E();
504
- if (!L(e)) return;
505
- const i = e.anchor.getNode().getTopLevelElementOrThrow(), o = be("info"), s = G();
506
- o.append(s);
507
- const r = G();
508
- i.insertAfter(o), o.insertAfter(r), me(i) && i.getTextContentSize() === 0 && i.remove(), s.selectStart();
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(Wt, {}),
513
+ icon: /* @__PURE__ */ t(Gt, {}),
514
514
  description: "Unordered bulleted list",
515
515
  execute: (e) => {
516
- e.dispatchCommand($e, void 0);
516
+ e.dispatchCommand(Be, void 0);
517
517
  }
518
518
  },
519
519
  {
520
520
  name: "Numbered List",
521
- icon: /* @__PURE__ */ t(Ut, {}),
521
+ icon: /* @__PURE__ */ t(Kt, {}),
522
522
  description: "Ordered numbered list",
523
523
  execute: (e) => {
524
- e.dispatchCommand(Pe, void 0);
524
+ e.dispatchCommand(ze, void 0);
525
525
  }
526
526
  },
527
527
  {
528
528
  name: "Divider",
529
- icon: /* @__PURE__ */ t(Kt, {}),
529
+ icon: /* @__PURE__ */ t(Vt, {}),
530
530
  description: "Horizontal line separator",
531
531
  execute: () => {
532
- const e = J(() => Ue());
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(Ht, {}),
538
+ icon: /* @__PURE__ */ t(Ut, {}),
539
539
  description: "Insert a masked link",
540
540
  execute: (e) => {
541
- e.dispatchCommand(ie, void 0);
541
+ e.dispatchCommand(re, void 0);
542
542
  }
543
543
  }
544
544
  ];
545
- class Vt extends _t {
545
+ class jt extends Et {
546
546
  constructor(n) {
547
547
  super(n.name), this.entry = n;
548
548
  }
549
549
  }
550
- function Yt({
550
+ function Jt({
551
551
  option: e,
552
552
  isSelected: n,
553
- onClick: i,
554
- onMouseEnter: o
553
+ onClick: o,
554
+ onMouseEnter: i
555
555
  }) {
556
- return /* @__PURE__ */ y(
556
+ return /* @__PURE__ */ k(
557
557
  "button",
558
558
  {
559
559
  className: `silk-slash-menu-item${n ? " silk-slash-menu-item--active" : ""}`,
560
- ref: (s) => e.setRefElement(s),
561
- onMouseDown: (s) => {
562
- s.preventDefault(), i();
560
+ ref: (r) => e.setRefElement(r),
561
+ onMouseDown: (r) => {
562
+ r.preventDefault(), o();
563
563
  },
564
- onMouseEnter: o,
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__ */ y("div", { className: "silk-slash-menu-text", children: [
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 jt() {
577
- const [e] = _(), [n, i] = C(() => e.isEditable()), [o, s] = C(null);
578
- x(() => e.registerEditableListener(i), [e]);
579
- const r = St("/", {
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
- }), h = _e(() => {
583
- if (o === null) return [];
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();
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 = 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,
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: m,
599
- isSelected: u.selectedIndex === S,
600
- onClick: () => u.selectOptionAndCleanUp(m),
601
- onMouseEnter: () => u.setHighlightedIndex(S)
598
+ option: g,
599
+ isSelected: d.selectedIndex === S,
600
+ onClick: () => d.selectOptionAndCleanUp(g),
601
+ onMouseEnter: () => d.setHighlightedIndex(S)
602
602
  },
603
- m.key
603
+ g.key
604
604
  )) }),
605
605
  c.current
606
606
  ),
607
607
  []
608
608
  );
609
609
  return n ? /* @__PURE__ */ t(
610
- wt,
610
+ Mt,
611
611
  {
612
- options: h,
613
- onQueryChange: s,
612
+ options: f,
613
+ onQueryChange: r,
614
614
  onSelectOption: l,
615
- triggerFn: r,
615
+ triggerFn: s,
616
616
  menuRenderFn: a,
617
617
  anchorClassName: "silk-slash-anchor"
618
618
  }
619
619
  ) : null;
620
620
  }
621
- const Jt = [
622
- { value: "info", label: "Info", Icon: ve },
623
- { value: "warning", label: "Question", Icon: zt },
624
- { value: "error", label: "Error", Icon: Bt }
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 Qt({
626
+ function qt({
627
627
  noteType: e,
628
628
  nodeKey: n,
629
- elem: i
629
+ elem: o
630
630
  }) {
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]);
633
- const m = w(() => {
634
- const f = s.current;
635
- if (!f) return;
636
- const v = i.getBoundingClientRect(), p = f.getBoundingClientRect();
637
- b({
638
- top: v.top - p.top + 13,
639
- left: v.left - p.left + 17
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
- }, [i, s]);
642
- he(() => {
643
- m();
644
- const f = new ResizeObserver(m);
645
- return f.observe(i), () => f.disconnect();
646
- }, [i, m]), x(() => o.registerUpdateListener(() => m()), [o, m]);
647
- const S = w(
648
- (f) => {
649
- o.update(() => {
650
- const v = H(n);
651
- ye(v) && v.setNoteType(f);
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
- [o, n]
654
+ [i, n]
655
655
  );
656
- return x(() => {
656
+ return _(() => {
657
657
  if (!l) return;
658
- const f = (v) => {
659
- c.current && !c.current.contains(v.target) && a(!1);
658
+ const u = (x) => {
659
+ c.current && !c.current.contains(x.target) && a(!1);
660
660
  };
661
- return document.addEventListener("mousedown", f), () => document.removeEventListener("mousedown", f);
662
- }, [l]), r ? /* @__PURE__ */ y(
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: u.top,
669
- left: u.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: (f) => f.preventDefault(),
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: Jt.map((f) => /* @__PURE__ */ y(
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--${f.value}${e === f.value ? " silk-note-type-option--active" : ""}`,
687
- onClick: () => S(f.value),
688
- onMouseDown: (v) => v.preventDefault(),
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(f.Icon, { size: 14 }),
692
- f.label
691
+ /* @__PURE__ */ t(u.Icon, { size: 14 }),
692
+ u.label
693
693
  ]
694
694
  },
695
- f.value
695
+ u.value
696
696
  )) })
697
697
  ]
698
698
  }
699
699
  ) : null;
700
700
  }
701
- function Xt() {
702
- const [e] = _(), [n, i] = C(
701
+ function Zt() {
702
+ const [e] = E(), [n, o] = C(
703
703
  /* @__PURE__ */ new Map()
704
704
  );
705
- return x(() => {
706
- const o = /* @__PURE__ */ new Set(), s = () => {
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 o) {
710
- const c = H(a);
711
- if (ye(c)) {
712
- const u = e.getElementByKey(a);
713
- u && l.set(a, {
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: u
715
+ elem: d
716
716
  });
717
717
  }
718
718
  }
719
- i(l);
719
+ o(l);
720
720
  });
721
- }, r = e.registerMutationListener(
722
- W,
721
+ }, s = e.registerMutationListener(
722
+ G,
723
723
  (l) => {
724
724
  for (const [a, c] of l)
725
- c === "destroyed" ? o.delete(a) : o.add(a);
726
- s();
725
+ c === "destroyed" ? i.delete(a) : i.add(a);
726
+ r();
727
727
  },
728
728
  { skipInitialization: !1 }
729
- ), h = e.registerUpdateListener(({ dirtyElements: l }) => {
729
+ ), f = e.registerUpdateListener(({ dirtyElements: l }) => {
730
730
  let a = !1;
731
- for (const c of o)
731
+ for (const c of i)
732
732
  if (l.has(c)) {
733
733
  a = !0;
734
734
  break;
735
735
  }
736
- a && s();
736
+ a && r();
737
737
  });
738
738
  return () => {
739
- r(), h();
739
+ s(), f();
740
740
  };
741
- }, [e]), /* @__PURE__ */ t(te, { children: Array.from(n.entries()).map(([o, { noteType: s, elem: r }]) => /* @__PURE__ */ t(
742
- Qt,
741
+ }, [e]), /* @__PURE__ */ t(ie, { children: Array.from(n.entries()).map(([i, { noteType: r, elem: s }]) => /* @__PURE__ */ t(
742
+ qt,
743
743
  {
744
- noteType: s,
745
- nodeKey: o,
746
- elem: r
744
+ noteType: r,
745
+ nodeKey: i,
746
+ elem: s
747
747
  },
748
- o
748
+ i
749
749
  )) });
750
750
  }
751
- const qt = [
752
- ...vt,
753
- Nt,
754
- Ct
751
+ const en = [
752
+ ...Ct,
753
+ xt,
754
+ _t
755
755
  ];
756
- function Zt() {
757
- const [e] = _();
758
- return x(() => yt(e, qt), [e]), null;
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
- const Ne = [
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
- ], U = [
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 en(e) {
781
- return e ? e.includes("SF Mono") || e.includes("Fira Code") ? U[1].value : e.includes("Space Grotesk") ? U[2].value : null : null;
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 re = 10, se = 36, ue = 16;
784
- function Ce() {
785
- const [e] = _(), [n, i] = C(/* @__PURE__ */ new Set()), [o, s] = C(ue), [r, h] = C(null), [l, a] = C(
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 = w(() => {
985
+ ), [c, d] = C(""), p = M(() => {
788
986
  e.getEditorState().read(() => {
789
- const p = E();
790
- if (!L(p)) return;
791
- const d = /* @__PURE__ */ new Set();
792
- p.hasFormat("bold") && d.add("bold"), p.hasFormat("italic") && d.add("italic"), p.hasFormat("underline") && d.add("underline"), p.hasFormat("code") && d.add("code"), i(d);
793
- const k = q(
794
- p,
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
- s(k ? parseInt(k, 10) : ue);
799
- const g = q(
800
- p,
1004
+ r(y ? parseInt(y, 10) : he);
1005
+ const b = q(
1006
+ h,
801
1007
  "color",
802
1008
  ""
803
1009
  );
804
- h(g || null);
805
- const M = q(
806
- p,
1010
+ f(b || null);
1011
+ const I = q(
1012
+ h,
807
1013
  "font-family",
808
1014
  ""
809
1015
  );
810
- a(en(M || null));
1016
+ a(sn(I || null));
1017
+ const W = h.anchor.getNode().getTopLevelElement();
1018
+ W && d(W.getFormatType() || "");
811
1019
  });
812
1020
  }, [e]);
813
- x(() => e.registerCommand(
814
- ge,
815
- () => (c(), !1),
816
- $
817
- ), [e, c]), x(() => e.registerUpdateListener(() => c()), [e, c]);
818
- const u = w(
819
- (p) => {
820
- e.dispatchCommand(Xe, p);
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
- ), b = w(
824
- (p) => {
825
- const d = Math.max(
826
- re,
827
- Math.min(se, o + p)
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 k = E();
831
- L(k) && Z(k, { "font-size": `${d}px` });
1038
+ const y = L();
1039
+ T(y) && Z(y, { "font-size": `${N}px` });
832
1040
  });
833
1041
  },
834
- [e, o]
835
- ), m = w(
836
- (p) => {
1042
+ [e, i]
1043
+ ), u = M(
1044
+ (h) => {
837
1045
  e.update(() => {
838
- const d = E();
839
- L(d) && Z(d, { color: p });
1046
+ const N = L();
1047
+ T(N) && Z(N, { color: h });
840
1048
  });
841
1049
  },
842
1050
  [e]
843
- ), S = w(
844
- (p) => {
1051
+ ), x = M(
1052
+ (h) => {
845
1053
  e.update(() => {
846
- const d = E();
847
- L(d) && Z(d, { "font-family": p });
1054
+ const N = L();
1055
+ T(N) && Z(N, { "font-family": h });
848
1056
  });
849
1057
  },
850
1058
  [e]
851
- ), f = w(() => {
1059
+ ), w = M(() => {
852
1060
  e.getEditorState().read(() => {
853
- const p = E();
854
- if (L(p)) {
855
- const d = p.getTextContent();
856
- e.dispatchCommand(ie, { text: d });
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]), v = w(() => {
1067
+ }, [e]), m = M(() => {
860
1068
  e.update(() => {
861
- const p = E();
862
- L(p) && ct(p, () => Ie());
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: o,
868
- currentColor: r,
1087
+ fontSize: i,
1088
+ currentColor: s,
869
1089
  currentFontFamily: l,
870
- toggleFormat: u,
871
- changeFontSize: b,
872
- applyColor: m,
873
- applyFontFamily: S,
874
- openLinkDialog: f,
875
- insertQuote: v
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 tn = 8;
879
- function nn() {
880
- var Y;
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), {
882
- formats: b,
883
- fontSize: m,
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: f,
886
- toggleFormat: v,
887
- changeFontSize: p,
888
- applyColor: d,
889
- applyFontFamily: k,
890
- openLinkDialog: g
891
- } = Ce(), M = w(() => {
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
- s(!1);
1115
+ r(!1);
894
1116
  return;
895
1117
  }
896
- let A = !1;
1118
+ let I = !1;
897
1119
  if (e.getEditorState().read(() => {
898
- const K = E();
899
- !L(K) || K.isCollapsed() || K.getNodes().some((xe) => {
900
- let j = xe.getParent();
901
- for (; j; ) {
902
- if (ne(j)) return !0;
903
- j = j.getParent();
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
- }) || (A = !0);
907
- }), !A) {
908
- s(!1);
1128
+ }) || (I = !0);
1129
+ }), !I) {
1130
+ r(!1);
909
1131
  return;
910
1132
  }
911
- const P = window.getSelection();
912
- if (!P || P.rangeCount === 0) {
913
- s(!1);
1133
+ const z = window.getSelection();
1134
+ if (!z || z.rangeCount === 0) {
1135
+ r(!1);
914
1136
  return;
915
1137
  }
916
- const z = P.getRangeAt(0).getBoundingClientRect(), B = n.current;
917
- if (!B) {
918
- s(!1);
1138
+ const F = z.getRangeAt(0).getBoundingClientRect(), $ = n.current;
1139
+ if (!$) {
1140
+ r(!1);
919
1141
  return;
920
1142
  }
921
- const D = B.getBoundingClientRect(), R = i.current, T = (R == null ? void 0 : R.offsetWidth) ?? 300;
922
- let I = z.left - D.left + z.width / 2;
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,
925
- left: I
926
- }), s(!0);
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 x(() => e.registerCommand(
929
- ge,
930
- () => (M(), !1),
931
- $
932
- ), [e, M]), x(() => e.registerUpdateListener(() => M()), [e, M]), x(() => {
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 N = (A) => {
935
- i.current && !i.current.contains(A.target) && (a(!1), u(!1));
1156
+ const b = (I) => {
1157
+ o.current && !o.current.contains(I.target) && (a(!1), d(!1));
936
1158
  };
937
- return document.addEventListener("mousedown", N), () => document.removeEventListener("mousedown", N);
938
- }, [l, c]), o ? /* @__PURE__ */ y(
1159
+ return document.addEventListener("mousedown", b), () => document.removeEventListener("mousedown", b);
1160
+ }, [l, c]), i ? /* @__PURE__ */ k(
939
1161
  "div",
940
1162
  {
941
- ref: i,
1163
+ ref: o,
942
1164
  className: "silk-floating-toolbar",
943
1165
  style: {
944
- top: r.top,
945
- left: r.left,
1166
+ top: s.top,
1167
+ left: s.left,
946
1168
  transform: "translate(-50%, -100%)"
947
1169
  },
948
- onMouseDown: (N) => N.preventDefault(),
1170
+ onMouseDown: (b) => b.preventDefault(),
949
1171
  children: [
950
1172
  /* @__PURE__ */ t(
951
1173
  "button",
952
1174
  {
953
- className: `silk-ft-btn${b.has("bold") ? " silk-ft-btn--active" : ""}`,
954
- onClick: () => v("bold"),
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${b.has("italic") ? " silk-ft-btn--active" : ""}`,
964
- onClick: () => v("italic"),
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${b.has("underline") ? " silk-ft-btn--active" : ""}`,
974
- onClick: () => v("underline"),
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${b.has("code") ? " silk-ft-btn--active" : ""}`,
984
- onClick: () => v("code"),
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: g,
1217
+ onClick: h,
996
1218
  type: "button",
997
1219
  title: "Insert link",
998
- children: /* @__PURE__ */ y(
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__ */ y("div", { className: "silk-ft-font-size", children: [
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: () => p(-1),
1024
- disabled: m <= re,
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: m }),
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: () => p(1),
1036
- disabled: m >= se,
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__ */ y("div", { className: "silk-ft-color-wrap", children: [
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), u(!1);
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: Ne.map((N) => /* @__PURE__ */ t(
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 === N.value || !S && N.value === null ? " silk-ft-color-swatch--active" : ""}`,
1289
+ className: `silk-ft-color-swatch${S === b.value || !S && b.value === null ? " silk-ft-color-swatch--active" : ""}`,
1068
1290
  onClick: () => {
1069
- d(N.value), a(!1);
1291
+ m(b.value), a(!1);
1070
1292
  },
1071
1293
  type: "button",
1072
- title: N.label,
1073
- style: N.value ? { backgroundColor: N.value } : void 0,
1074
- children: N.value === null && /* @__PURE__ */ y(
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
- N.value ?? "default"
1312
+ b.value ?? "default"
1091
1313
  )) })
1092
1314
  ] }),
1093
1315
  /* @__PURE__ */ t("div", { className: "silk-ft-sep" }),
1094
- /* @__PURE__ */ y("div", { className: "silk-ft-font-wrap", children: [
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
- u(!c), a(!1);
1322
+ d(!c), a(!1);
1101
1323
  },
1102
1324
  type: "button",
1103
1325
  title: "Font family",
1104
1326
  style: {
1105
- fontFamily: ((Y = U.find((N) => N.value === f)) == null ? void 0 : Y.css) ?? '"Inter", sans-serif',
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: U.map((N) => /* @__PURE__ */ t(
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${f === N.value ? " silk-ft-font-option--active" : ""}`,
1337
+ className: `silk-ft-font-option${u === b.value ? " silk-ft-font-option--active" : ""}`,
1116
1338
  onClick: () => {
1117
- k(N.value), u(!1);
1339
+ v(b.value), d(!1);
1118
1340
  },
1119
- onMouseDown: (A) => A.preventDefault(),
1341
+ onMouseDown: (I) => I.preventDefault(),
1120
1342
  type: "button",
1121
- style: { fontFamily: N.css },
1122
- children: N.label
1343
+ style: { fontFamily: b.css },
1344
+ children: b.label
1123
1345
  },
1124
- N.label
1346
+ b.label
1125
1347
  )) })
1126
1348
  ] })
1127
1349
  ]
1128
1350
  }
1129
1351
  ) : null;
1130
1352
  }
1131
- function on() {
1132
- var k;
1133
- const [e] = _(), [n, i] = C(() => e.isEditable()), o = F(null), [s, r] = C(!1), [h, l] = C(!1), {
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: u,
1137
- currentFontFamily: b,
1138
- toggleFormat: m,
1139
- changeFontSize: S,
1140
- applyColor: f,
1141
- applyFontFamily: v,
1142
- openLinkDialog: p,
1143
- insertQuote: d
1144
- } = Ce();
1145
- return x(() => e.registerEditableListener(i), [e]), x(() => {
1146
- if (!s && !h) return;
1147
- const g = (M) => {
1148
- o.current && !o.current.contains(M.target) && (r(!1), l(!1));
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", g), () => document.removeEventListener("mousedown", g);
1151
- }, [s, h]), /* @__PURE__ */ y(
1374
+ return document.addEventListener("mousedown", y), () => document.removeEventListener("mousedown", y);
1375
+ }, [r, f]), /* @__PURE__ */ k(
1152
1376
  "div",
1153
1377
  {
1154
- ref: o,
1378
+ ref: i,
1155
1379
  className: "silk-toolbar",
1156
1380
  style: n ? void 0 : { display: "none" },
1157
- onMouseDown: (g) => g.preventDefault(),
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: () => m("bold"),
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: () => m("italic"),
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: () => m("underline"),
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: () => m("code"),
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: p,
1428
+ onClick: m,
1205
1429
  type: "button",
1206
1430
  title: "Insert link",
1207
- children: /* @__PURE__ */ y(
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: d,
1454
+ onClick: v,
1231
1455
  type: "button",
1232
1456
  title: "Block quote",
1233
- children: /* @__PURE__ */ y(
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__ */ y("div", { className: "silk-ft-font-size", children: [
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: () => S(-1),
1260
- disabled: c <= re,
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: () => S(1),
1272
- disabled: c >= se,
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__ */ y("div", { className: "silk-ft-color-wrap", children: [
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${s ? " silk-ft-btn--active" : ""}`,
1561
+ className: `silk-ft-btn silk-ft-btn--color${r ? " silk-ft-btn--active" : ""}`,
1285
1562
  onClick: () => {
1286
- r(!s), l(!1);
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: u || "#1a1a1a" },
1571
+ style: { borderBottomColor: d || "#1a1a1a" },
1295
1572
  children: "A"
1296
1573
  }
1297
1574
  )
1298
1575
  }
1299
1576
  ),
1300
- s && /* @__PURE__ */ t("div", { className: "silk-ft-color-grid", children: Ne.map((g) => /* @__PURE__ */ t(
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${u === g.value || !u && g.value === null ? " silk-ft-color-swatch--active" : ""}`,
1580
+ className: `silk-ft-color-swatch${d === y.value || !d && y.value === null ? " silk-ft-color-swatch--active" : ""}`,
1304
1581
  onClick: () => {
1305
- f(g.value), r(!1);
1582
+ x(y.value), s(!1);
1306
1583
  },
1307
1584
  type: "button",
1308
- title: g.label,
1309
- style: g.value ? { backgroundColor: g.value } : void 0,
1310
- children: g.value === null && /* @__PURE__ */ y(
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
- g.value ?? "default"
1603
+ y.value ?? "default"
1327
1604
  )) })
1328
1605
  ] }),
1329
1606
  /* @__PURE__ */ t("div", { className: "silk-ft-sep" }),
1330
- /* @__PURE__ */ y("div", { className: "silk-ft-font-wrap", children: [
1607
+ /* @__PURE__ */ k("div", { className: "silk-ft-font-wrap", children: [
1331
1608
  /* @__PURE__ */ t(
1332
1609
  "button",
1333
1610
  {
1334
- className: `silk-ft-btn${h ? " silk-ft-btn--active" : ""}`,
1611
+ className: `silk-ft-btn${f ? " silk-ft-btn--active" : ""}`,
1335
1612
  onClick: () => {
1336
- l(!h), r(!1);
1613
+ l(!f), s(!1);
1337
1614
  },
1338
1615
  type: "button",
1339
1616
  title: "Font family",
1340
1617
  style: {
1341
- fontFamily: ((k = U.find((g) => g.value === b)) == null ? void 0 : k.css) ?? '"Inter", sans-serif',
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
- h && /* @__PURE__ */ t("div", { className: "silk-ft-font-dropdown", children: U.map((g) => /* @__PURE__ */ t(
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${b === g.value ? " silk-ft-font-option--active" : ""}`,
1628
+ className: `silk-ft-font-option${p === y.value ? " silk-ft-font-option--active" : ""}`,
1352
1629
  onClick: () => {
1353
- v(g.value), l(!1);
1630
+ w(y.value), l(!1);
1354
1631
  },
1355
- onMouseDown: (M) => M.preventDefault(),
1632
+ onMouseDown: (b) => b.preventDefault(),
1356
1633
  type: "button",
1357
- style: { fontFamily: g.css },
1358
- children: g.label
1634
+ style: { fontFamily: y.css },
1635
+ children: y.label
1359
1636
  },
1360
- g.label
1637
+ y.label
1361
1638
  )) })
1362
1639
  ] })
1363
1640
  ]
1364
1641
  }
1365
1642
  );
1366
1643
  }
1367
- function rn() {
1368
- const [e] = _();
1369
- return x(() => {
1644
+ function cn() {
1645
+ const [e] = E();
1646
+ return _(() => {
1370
1647
  const n = e.getRootElement();
1371
1648
  if (!n) return;
1372
- const i = (o) => {
1373
- if (e.isEditable() && !(o.metaKey || o.ctrlKey)) return;
1374
- const h = o.target.closest("a");
1375
- !h || !n.contains(h) || e.getEditorState().read(() => {
1376
- const l = qe(h);
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 = ce(l) ? l : ce(a) ? a : null;
1655
+ const a = l.getParent(), c = ue(l) ? l : ue(a) ? a : null;
1379
1656
  if (c) {
1380
- const u = c.getURL();
1381
- u && (o.preventDefault(), window.open(u, "_blank", "noopener,noreferrer"));
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", i), () => n.removeEventListener("click", i);
1662
+ return n.addEventListener("click", o), () => n.removeEventListener("click", o);
1386
1663
  }, [e]), null;
1387
1664
  }
1388
- function sn() {
1389
- const [e] = _();
1390
- return x(() => ze(e), [e]), /* @__PURE__ */ t(bt, {});
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 cn(e) {
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 dn(e) {
1582
- return new Promise((n, i) => {
1583
- const o = new FileReader();
1584
- o.onload = () => n(o.result), o.onerror = () => i(o.error), o.readAsDataURL(e);
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 un() {
1588
- const [e] = _();
1589
- return x(() => {
1590
- const n = (r) => {
1591
- for (const h of r)
1592
- dn(h).then((l) => {
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 = ee(l, h.name), c = E();
1595
- if (L(c))
1685
+ const a = te(l, f.name), c = L();
1686
+ if (T(c))
1596
1687
  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);
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
- de().append(a);
1692
+ fe().append(a);
1602
1693
  });
1603
1694
  });
1604
- }, i = e.registerCommand(
1605
- it,
1606
- (r) => {
1695
+ }, o = e.registerCommand(
1696
+ lt,
1697
+ (s) => {
1607
1698
  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);
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
- ), o = e.registerCommand(
1615
- rt,
1616
- (r) => {
1705
+ ), i = e.registerCommand(
1706
+ at,
1707
+ (s) => {
1617
1708
  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);
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
- ), s = e.registerCommand(
1625
- st,
1626
- (r) => {
1715
+ ), r = e.registerCommand(
1716
+ ct,
1717
+ (s) => {
1627
1718
  var l;
1628
- const h = (l = r.dataTransfer) == null ? void 0 : l.types;
1629
- return h && h.includes("Files") ? (r.preventDefault(), !0) : !1;
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
- i(), o(), s();
1725
+ o(), i(), r();
1635
1726
  };
1636
1727
  }, [e]), null;
1637
1728
  }
1638
- const fn = {
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
- }, hn = {
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 mn(...e) {
1762
+ function gn(...e) {
1672
1763
  const n = {};
1673
- for (const i of e)
1674
- for (const [o, s] of Object.entries(i)) {
1675
- const r = n[o];
1676
- r && typeof r == "object" && typeof s == "object" && !Array.isArray(r) && !Array.isArray(s) ? n[o] = { ...r, ...s } : n[o] = s;
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 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);
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 kn(e) {
1775
+ function yn(e) {
1685
1776
  const n = [];
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;
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 x(() => {
1780
+ const [n] = E();
1781
+ return _(() => {
1691
1782
  n.setEditable(e);
1692
1783
  }, [n, e]), null;
1693
1784
  }
1694
- function yn({
1785
+ function vn({
1695
1786
  handleRef: e
1696
1787
  }) {
1697
- const [n] = _();
1698
- return Ee(
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 vn = {
1797
+ const Nn = {
1707
1798
  history: !0,
1708
1799
  richText: !0,
1709
1800
  dragon: !0,
1710
1801
  code: !0,
1711
1802
  lists: !0
1712
- }, Yn = Me(
1803
+ }, jn = Le(
1713
1804
  function({
1714
1805
  features: n,
1715
- namespace: i = "silk-editor",
1716
- className: o,
1717
- theme: s,
1718
- editable: r = !0,
1719
- onError: h,
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 = F(null), u = {
1723
- ...vn,
1813
+ const c = B(null), d = {
1814
+ ...Nn,
1724
1815
  ...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,
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: h ?? ((f) => console.error(f))
1733
- }, children: /* @__PURE__ */ t(ke.Provider, { value: c, children: /* @__PURE__ */ y(
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${o ? ` ${o}` : ""}`,
1828
+ className: `silk-editor-container${i ? ` ${i}` : ""}`,
1738
1829
  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, {}),
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(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, {})
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
- ee as $createImageNode,
1763
- be as $createNoteNode,
1764
- cn as $isImageNode,
1765
- ye as $isNoteNode,
1766
- V as ImageNode,
1767
- W as NoteNode,
1768
- Yn as SilkEditor,
1769
- Yn as default
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
  };