@glifox/gnosis 0.0.13 → 0.0.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/gnosis.mjs CHANGED
@@ -1,74 +1,74 @@
1
1
  var _ = Object.defineProperty;
2
- var O = (e, t, s) => t in e ? _(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s;
3
- var v = (e, t, s) => O(e, typeof t != "symbol" ? t + "" : t, s);
4
- import { languages as W } from "@codemirror/language-data";
5
- import { markdown as V } from "@codemirror/lang-markdown";
2
+ var O = (e, t, r) => t in e ? _(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
3
+ var S = (e, t, r) => O(e, typeof t != "symbol" ? t + "" : t, r);
4
+ import { languages as V } from "@codemirror/language-data";
5
+ import { markdown as W } from "@codemirror/lang-markdown";
6
6
  import { GFM as F } from "@lezer/markdown";
7
- import { Tag as U, styleTags as X, tags as B } from "@lezer/highlight";
8
- import { ViewPlugin as j, Decoration as l, WidgetType as x, EditorView as R } from "@codemirror/view";
9
- import { syntaxTree as E } from "@codemirror/language";
10
- import { EditorView as T } from "codemirror";
7
+ import { Tag as U, styleTags as X, tags as A } from "@lezer/highlight";
8
+ import { ViewPlugin as j, Decoration as l, WidgetType as $, EditorView as R } from "@codemirror/view";
9
+ import { syntaxTree as I } from "@codemirror/language";
10
+ import { EditorView as M } from "codemirror";
11
11
  import { StateEffect as G, StateField as K } from "@codemirror/state";
12
- const m = U.define("none"), Y = X({
13
- "Blockquote/...": m,
14
- HorizontalRule: m,
15
- "ATXHeading1/... SetextHeading1/...": m,
16
- "ATXHeading2/... SetextHeading2/...": m,
17
- "ATXHeading3/...": m,
18
- "ATXHeading4/...": m,
19
- "ATXHeading5/...": m,
20
- "ATXHeading6/...": m,
21
- "Comment CommentBlock": m,
22
- Escape: m,
23
- Entity: m,
24
- "Emphasis/...": m,
25
- "StrongEmphasis/...": m,
26
- "Strikethrough/...": m,
27
- "TableHeader/...": m,
28
- "Link/... Image/...": m,
29
- "OrderedList/... BulletList/...": m,
30
- "BlockQuote/...": m,
31
- "InlineCode CodeText": m,
32
- "URL Autolink": m,
33
- "HeaderMark HardBreak QuoteMark ListMark LinkMark EmphasisMark CodeMark StrikethroughMark": m,
34
- "CodeInfo LinkLabel TaskMarker TableDelimiter": m,
35
- LinkTitle: m,
36
- Paragraph: m,
37
- "QuoteType/.. QuoteTypeMark QuoteTypeText": m
38
- }), J = { props: [Y] }, q = (e, t, s = {}) => {
39
- const o = class {
12
+ const h = U.define("none"), Y = X({
13
+ "Blockquote/...": h,
14
+ HorizontalRule: h,
15
+ "ATXHeading1/... SetextHeading1/...": h,
16
+ "ATXHeading2/... SetextHeading2/...": h,
17
+ "ATXHeading3/...": h,
18
+ "ATXHeading4/...": h,
19
+ "ATXHeading5/...": h,
20
+ "ATXHeading6/...": h,
21
+ "Comment CommentBlock": h,
22
+ Escape: h,
23
+ Entity: h,
24
+ "Emphasis/...": h,
25
+ "StrongEmphasis/...": h,
26
+ "Strikethrough/...": h,
27
+ "TableHeader/...": h,
28
+ "Link/... Image/...": h,
29
+ "OrderedList/... BulletList/...": h,
30
+ "BlockQuote/...": h,
31
+ "InlineCode CodeText": h,
32
+ "URL Autolink": h,
33
+ "HeaderMark HardBreak QuoteMark ListMark LinkMark EmphasisMark CodeMark StrikethroughMark": h,
34
+ "CodeInfo LinkLabel TaskMarker TableDelimiter": h,
35
+ LinkTitle: h,
36
+ Paragraph: h,
37
+ "QuoteType/.. QuoteTypeMark QuoteTypeText": h
38
+ }), J = { props: [Y] }, y = (e, t, r = {}) => {
39
+ const i = class {
40
40
  constructor(c) {
41
- v(this, "decorations");
42
- v(this, "conf");
41
+ S(this, "decorations");
42
+ S(this, "conf");
43
43
  this.conf = t, this.decorations = e(c, this.conf);
44
44
  }
45
45
  update(c) {
46
46
  (c.docChanged || c.viewportChanged || c.selectionSet) && (this.decorations = e(c.view, this.conf));
47
47
  }
48
48
  };
49
- return j.fromClass(o, { decorations: (a) => a.decorations, ...s });
50
- }, M = (e, t, s) => {
51
- const o = e.state.selection.ranges;
52
- for (let a of o)
53
- if (a.from >= t && a.from <= s || a.to >= t && a.to <= s || a.from <= t && a.to >= s)
49
+ return j.fromClass(i, { decorations: (a) => a.decorations, ...r });
50
+ }, x = (e, t, r) => {
51
+ const i = e.state.selection.ranges;
52
+ for (let a of i)
53
+ if (a.from >= t && a.from <= r || a.to >= t && a.to <= r || a.from <= t && a.to >= r)
54
54
  return !0;
55
55
  return !1;
56
- }, y = (e, t) => {
57
- for (const { from: s, to: o } of e.visibleRanges)
58
- E(e.state).iterate({ ...t, from: s, to: o });
56
+ }, v = (e, t) => {
57
+ for (const { from: r, to: i } of e.visibleRanges)
58
+ I(e.state).iterate({ ...t, from: r, to: i });
59
59
  };
60
60
  function ee(e, t) {
61
- const s = ["Document"], o = {}, a = {
62
- HorizontalRule: (r, n, i = !0) => [
63
- l.line({ class: "hr " + (i ? "sw" : "") }).range(r),
64
- l.mark({ class: "mk" }).range(r, n)
61
+ const r = ["Document"], i = {}, a = {
62
+ HorizontalRule: (n, s, o = !0) => [
63
+ l.line({ class: "hr " + (o ? "sw" : "") }).range(n),
64
+ l.mark({ class: "mk" }).range(n, s)
65
65
  ]
66
66
  }, c = [];
67
- return y(e, {
68
- enter: ({ type: r, from: n, to: i }) => (r.name in a && c.push(...a[r.name](n, i, M(e, n, i))), s.includes(r.name) || r.name in o)
67
+ return v(e, {
68
+ enter: ({ type: n, from: s, to: o }) => (n.name in a && c.push(...a[n.name](s, o, x(e, s, o))), r.includes(n.name) || n.name in i)
69
69
  }), l.set(c, !1);
70
70
  }
71
- const te = () => T.baseTheme({
71
+ const te = () => M.baseTheme({
72
72
  "& .hr": { position: "relative" },
73
73
  "& .hr > .mk": { fontSize: "0" },
74
74
  "& .hr.sw > .mk": { fontSize: "inherit" },
@@ -82,28 +82,28 @@ const te = () => T.baseTheme({
82
82
  height: ".2ch"
83
83
  }
84
84
  }), ne = () => [
85
- q(ee, {}),
85
+ y(ee, {}),
86
86
  te()
87
87
  ];
88
- function se(e, t) {
89
- const s = ["FencedCode"], o = {
90
- StrongEmphasis: (r = !0, n, i) => l.mark({ class: "il st " + (r ? "sw" : "") }).range(n, i),
91
- Strikethrough: (r = !0, n, i) => l.mark({ class: "il sk " + (r ? "sw" : "") }).range(n, i),
92
- InlineCode: (r = !0, n, i) => l.mark({ class: "il ic " + (r ? "sw" : "") }).range(n, i),
93
- Emphasis: (r = !0, n, i) => l.mark({ class: "il it " + (r ? "sw" : "") }).range(n, i),
94
- Mark: (r, n) => l.mark({ class: "mkl" }).range(r, n)
88
+ function re(e, t) {
89
+ const r = ["FencedCode"], i = {
90
+ StrongEmphasis: (n = !0, s, o) => l.mark({ class: "il st " + (n ? "sw" : "") }).range(s, o),
91
+ Strikethrough: (n = !0, s, o) => l.mark({ class: "il sk " + (n ? "sw" : "") }).range(s, o),
92
+ InlineCode: (n = !0, s, o) => l.mark({ class: "il ic " + (n ? "sw" : "") }).range(s, o),
93
+ Emphasis: (n = !0, s, o) => l.mark({ class: "il it " + (n ? "sw" : "") }).range(s, o),
94
+ Mark: (n, s) => l.mark({ class: "mkl" }).range(n, s)
95
95
  }, a = ["EmphasisMark", "CodeMark", "StrikethroughMark"], c = [];
96
- return y(e, {
97
- enter: ({ type: { name: r }, from: n, to: i }) => a.includes(r) ? (c.push(o.Mark(n, i)), !1) : (r in o && c.push(
98
- o[r](
99
- M(e, n, i),
100
- n,
101
- i
96
+ return v(e, {
97
+ enter: ({ type: { name: n }, from: s, to: o }) => a.includes(n) ? (c.push(i.Mark(s, o)), !1) : (n in i && c.push(
98
+ i[n](
99
+ x(e, s, o),
100
+ s,
101
+ o
102
102
  )
103
- ), !s.includes(r))
103
+ ), !r.includes(n))
104
104
  }), l.set(c, !1);
105
105
  }
106
- const re = T.baseTheme({
106
+ const se = M.baseTheme({
107
107
  "& .it ": { fontStyle: "italic" },
108
108
  "& .st ": { fontWeight: "bold" },
109
109
  "& .sk ": { textDecoration: "line-through" },
@@ -113,38 +113,38 @@ const re = T.baseTheme({
113
113
  borderRadius: ".6ch",
114
114
  backgroundColor: "var(--cm-ic-background, hsl(from black h s l / .2))"
115
115
  }
116
- }), oe = T.baseTheme({
116
+ }), oe = M.baseTheme({
117
117
  ".il .mkl": { fontSize: "0" },
118
118
  "&.cm-focused .il.sw > .mkl": { fontSize: "inherit" }
119
119
  }), ie = () => [
120
- q(se, {}),
121
- re,
120
+ y(re, {}),
121
+ se,
122
122
  oe
123
123
  ];
124
- class ae extends x {
125
- constructor(s) {
124
+ class ae extends $ {
125
+ constructor(r) {
126
126
  super();
127
- v(this, "checked", !1);
128
- this.checked = s;
127
+ S(this, "checked", !1);
128
+ this.checked = r;
129
129
  }
130
130
  // eq(other) { return other.checked == this.checked }
131
131
  toDOM() {
132
- let s = document.createElement("span");
133
- s.setAttribute("aria-hidden", "true"), s.className = "TaskMark";
134
- let o = s.appendChild(document.createElement("input"));
135
- return o.type = "checkbox", o.checked = this.checked, s;
132
+ let r = document.createElement("span");
133
+ r.setAttribute("aria-hidden", "true"), r.className = "TaskMark";
134
+ let i = r.appendChild(document.createElement("input"));
135
+ return i.type = "checkbox", i.checked = this.checked, r;
136
136
  }
137
137
  ignoreEvent() {
138
138
  return !1;
139
139
  }
140
140
  }
141
141
  function ce(e, t) {
142
- const s = [
142
+ const r = [
143
143
  "Document",
144
144
  "ListItem",
145
145
  "Task",
146
146
  "Blockquote"
147
- ], o = {
147
+ ], i = {
148
148
  BulletList: {
149
149
  class: "bl",
150
150
  offset: 2
@@ -154,57 +154,66 @@ function ce(e, t) {
154
154
  offset: 3
155
155
  }
156
156
  }, a = {
157
- ListMark: (i, d, u, g = !0) => l.mark({ class: `${u.class} lm ${g ? "sw" : ""}` }).range(i, d),
158
- TaskMarker: (i, d, u, g = !0) => {
159
- const C = e.state.doc.sliceString(i + 1, d - 1) === "x";
160
- return g ? l.mark({ class: `tm ${C ? "ck" : ""}` }).range(i, d) : l.replace({
161
- widget: new ae(C)
162
- }).range(i, d);
157
+ ListMark: (o, d, u, g = !0) => l.mark({ class: `${u.class} lm ${g ? "sw" : ""}` }).range(o, d),
158
+ TaskMarker: (o, d, u, g = !0) => {
159
+ const m = e.state.doc.sliceString(o + 1, d - 1) === "x";
160
+ return g ? l.mark({ class: `tm ${m ? "ck" : ""}` }).range(o, d) : l.replace({
161
+ widget: new ae(m)
162
+ }).range(o, d);
163
163
  }
164
164
  }, c = {
165
- ListItem: (i, d, u, g) => {
166
- const C = u.offset + (g ? 4 : 0), p = i + C, h = `calc(100% - ${Math.max(0, C) + 4}ch)`;
165
+ ListItem: (o, d, u, g, m) => {
166
+ const w = u.offset + (g ? 4 : 0), p = o + w, T = `calc(100% - ${Math.max(0, w + m) + 4}ch)`;
167
167
  return p >= d ? [] : [
168
168
  l.mark({
169
169
  class: "ls-text-line",
170
- attributes: { style: `width: ${h}` }
170
+ attributes: { style: `width: ${T}` }
171
171
  }).range(p, d)
172
172
  ];
173
173
  }
174
- }, r = [], n = [];
175
- return y(e, {
176
- enter: ({ name: i, from: d, to: u, node: g }) => i in o ? (n.push({ name: i, from: d, to: u }), !0) : (i in a && r.push(a[i](
177
- d,
178
- u,
179
- o[n.slice(-1)[0].name],
180
- M(e, d, u)
181
- )), i in c && r.push(...c[i](
182
- d,
183
- u,
184
- o[n.slice(-1)[0].name],
185
- g.getChild("Task") !== null
186
- )), s.includes(i)),
187
- leave: ({ name: i, from: d, to: u }) => {
188
- const g = n.slice(-1)[0];
189
- g && g.name === i && g.from === d && g.to === u && n.pop();
174
+ }, n = [], s = [];
175
+ return v(e, {
176
+ enter: ({ name: o, from: d, to: u, node: g }) => {
177
+ if (o in i)
178
+ return s.push({ name: o, from: d, to: u }), !0;
179
+ if (o in a && n.push(a[o](
180
+ d,
181
+ u,
182
+ i[s.slice(-1)[0].name],
183
+ x(e, d, u)
184
+ )), o in c) {
185
+ const m = e.state.doc.lineAt(d);
186
+ n.push(...c[o](
187
+ d,
188
+ m.to,
189
+ i[s.slice(-1)[0].name],
190
+ g.getChild("Task") !== null,
191
+ d - m.from
192
+ ));
193
+ }
194
+ return r.includes(o);
195
+ },
196
+ leave: ({ name: o, from: d, to: u }) => {
197
+ const g = s.slice(-1)[0];
198
+ g && g.name === o && g.from === d && g.to === u && s.pop();
190
199
  }
191
- }), l.set(r, !0);
200
+ }), l.set(n, !0);
192
201
  }
193
202
  const le = (e, t) => {
194
- var o;
195
- let s = e.target;
196
- if (s.nodeName === "INPUT" && ((o = s.parentElement) != null && o.classList.contains("TaskMark"))) return de(t, t.posAtDOM(s));
203
+ var i;
204
+ let r = e.target;
205
+ if (r.nodeName === "INPUT" && ((i = r.parentElement) != null && i.classList.contains("TaskMark"))) return de(t, t.posAtDOM(r));
197
206
  }, de = (e, t) => {
198
- const s = t - 2, o = t - 1;
199
- let a = e.state.doc.sliceString(Math.max(0, s), o), c;
200
- if (a === "x") c = { from: s, to: o, insert: " " };
201
- else if (a === " ") c = { from: s, to: o, insert: "x" };
207
+ const r = t - 2, i = t - 1;
208
+ let a = e.state.doc.sliceString(Math.max(0, r), i), c;
209
+ if (a === "x") c = { from: r, to: i, insert: " " };
210
+ else if (a === " ") c = { from: r, to: i, insert: "x" };
202
211
  else return !1;
203
212
  return e.dispatch({ changes: c }), !0;
204
- }, ue = () => T.baseTheme({
213
+ }, ue = () => M.baseTheme({
205
214
  "& .lm.bl": {
206
215
  position: "relative",
207
- paddingInlineStart: "1ch",
216
+ // paddingInlineStart: "1ch",
208
217
  color: "transparent"
209
218
  },
210
219
  "& .lm.bl::before": {
@@ -240,47 +249,47 @@ const le = (e, t) => {
240
249
  width: "unset !important"
241
250
  }
242
251
  }), ge = () => [
243
- q(ce, {}, { eventHandlers: { mousedown: le } }),
252
+ y(ce, {}, { eventHandlers: { mousedown: le } }),
244
253
  ue()
245
254
  ], he = (e, t) => {
246
- var o;
247
- let s = e.target;
248
- if (s.nodeName === "BUTTON" && ((o = s.parentElement) != null && o.classList.contains("wg-codeblock"))) {
255
+ var i;
256
+ let r = e.target;
257
+ if (r.nodeName === "BUTTON" && ((i = r.parentElement) != null && i.classList.contains("wg-codeblock"))) {
249
258
  const a = ["FencedCode", "CodeBlock"];
250
259
  let c = "";
251
- const r = {
252
- enter: ({ type: { name: n }, from: i, to: d, node: u }) => (a.includes(n) && (c = me(t, u.toTree(), i, d)), !a.includes(n))
260
+ const n = {
261
+ enter: ({ type: { name: s }, from: o, to: d, node: u }) => (a.includes(s) && (c = me(t, u.toTree(), o, d)), !a.includes(s))
253
262
  };
254
- return E(t.state).iterate({
255
- ...r,
256
- from: t.posAtDOM(s),
257
- to: t.posAtDOM(s) + 2
263
+ return I(t.state).iterate({
264
+ ...n,
265
+ from: t.posAtDOM(r),
266
+ to: t.posAtDOM(r) + 2
258
267
  }), navigator.clipboard.writeText(c), !0;
259
268
  }
260
- }, me = (e, t, s, o) => {
269
+ }, me = (e, t, r, i) => {
261
270
  const a = ["CodeMark", "CodeInfo"];
262
- let c = e.state.doc.sliceString(s, o), r = /* @__PURE__ */ new Set();
271
+ let c = e.state.doc.sliceString(r, i), n = /* @__PURE__ */ new Set();
263
272
  t.iterate({
264
- enter({ type: { name: u }, from: g, node: C }) {
265
- a.includes(u) && r.add(e.state.doc.lineAt(g + s).number);
273
+ enter({ type: { name: u }, from: g, node: m }) {
274
+ a.includes(u) && n.add(e.state.doc.lineAt(g + r).number);
266
275
  }
267
276
  });
268
- const n = e.state.doc.lineAt(s), i = s - n.from, d = [];
277
+ const s = e.state.doc.lineAt(r), o = r - s.from, d = [];
269
278
  return c.split(`
270
279
  `).forEach((u, g) => {
271
- r.has(g + n.number) || d.push(u.slice(i));
280
+ n.has(g + s.number) || d.push(u.slice(o));
272
281
  }), d.join(`
273
282
  `);
274
283
  };
275
- class A extends x {
276
- constructor(s, o, a) {
284
+ class B extends $ {
285
+ constructor(r, i, a, c = 1) {
277
286
  super();
278
- v(this, "classes", "");
279
- this.classes = s, this.width = o, this.marginLeft = a;
287
+ S(this, "classes", "");
288
+ this.classes = r, this.width = i, this.marginLeft = a, this.spaces = c;
280
289
  }
281
290
  toDOM() {
282
- let s = document.createElement("span");
283
- return s.setAttribute("aria-hidden", "true"), s.className = this.classes + " vacio", s.textContent = " ", s.style.width = this.width, s.style.marginLeft = this.marginLeft, s;
291
+ let r = document.createElement("span");
292
+ return r.setAttribute("aria-hidden", "true"), r.className = this.classes + " empty", r.textContent = " ".repeat(this.spaces), r.style.width = this.width, r.style.marginLeft = this.marginLeft, r;
284
293
  }
285
294
  ignoreEvent() {
286
295
  return !1;
@@ -290,112 +299,138 @@ const pe = (e) => `<svg class="cb-icon" viewBox="0 0 18 18" fill="none" xmlns="h
290
299
  <path class="cb-icon-path cb.i1" fill-rule="evenodd" clip-rule="evenodd" d="M15 0C15.5304 0 16.0391 0.210714 16.4142 0.585786C16.7893 0.960859 17 1.46957 17 2V12C17 12.5304 16.7893 13.0391 16.4142 13.4142C16.0391 13.7893 15.5304 14 15 14H14V6C14 4.93913 13.5786 3.92172 12.8284 3.17157C12.0783 2.42143 11.0609 2 10 2H7C6.64895 1.99924 6.30395 2.09135 6 2.267V2C6 1.46957 6.21071 0.960859 6.58579 0.585786C6.96086 0.210714 7.46957 0 8 0H15Z"/>
291
300
  <path class="cb-icon-path cb.i1" fill-rule="evenodd" clip-rule="evenodd" d="M5 4.054V8H1.2C1.27464 7.84448 1.3691 7.69928 1.481 7.568L3.941 4.698C4.2169 4.37661 4.58771 4.15111 5 4.054ZM7 4V8C7 8.53043 6.78929 9.03914 6.41421 9.41421C6.03914 9.78929 5.53043 10 5 10H1V16C1 16.5304 1.21071 17.0391 1.58579 17.4142C1.96086 17.7893 2.46957 18 3 18H10C10.5304 18 11.0391 17.7893 11.4142 17.4142C11.7893 17.0391 12 16.5304 12 16V6C12 5.46957 11.7893 4.96086 11.4142 4.58579C11.0391 4.21071 10.5304 4 10 4H7Z"/>
292
301
  </svg>`;
293
- class fe extends x {
294
- constructor(t, s) {
295
- super(), this.type = t, this.code = s;
302
+ class fe extends $ {
303
+ constructor(t, r) {
304
+ super(), this.type = t, this.code = r;
296
305
  }
297
306
  toDOM() {
298
307
  let t = document.createElement("span");
299
308
  t.setAttribute("aria-hidden", "true"), t.className = "wg-codeblock";
300
- let s = document.createElement("button");
301
- return s.className = "wg-codeblock-btn", s.innerHTML = pe(), t.appendChild(s), t;
309
+ let r = document.createElement("button");
310
+ return r.className = "wg-codeblock-btn", r.innerHTML = pe(), t.appendChild(r), t;
302
311
  }
303
312
  ignoreEvent() {
304
313
  return !1;
305
314
  }
306
315
  }
307
- const H = [];
316
+ const E = [];
308
317
  function D(e, t) {
309
318
  const {
310
- mode: s
319
+ mode: r,
311
320
  /* type, mark */
312
- } = t, o = ["Document", "Blockquote", "ListItem", "BulletList", "OrderedList"], a = {
321
+ /**
322
+ * @type {object}
323
+ * @property {number} marginLeft - Margin left for the code block
324
+ * @property {number} paddingLeft - Padding left for the code block
325
+ */
326
+ options: i
327
+ } = t, a = ["Document", "Blockquote", "ListItem", "BulletList", "OrderedList"], c = {
313
328
  FencedCode: Z,
314
329
  CodeBlock: Z
315
- }, c = {
316
- CodeMark: (n, i, d) => [l.mark({ class: "cb-mk" }).range(i, d)],
317
- CodeInfo: (n, i, d) => [l.mark({ class: "cb-mi" }).range(i, d)]
318
- }, r = [];
319
- return y(e, {
320
- enter: ({ type: { name: n }, from: i, to: d }) => (s === "type" && n in a && r.push(...a[n](e, i, d)), s === "mark" && n in c && r.push(...c[n](e, i, d)), o.includes(n) || n in a ? (H.push({ name: n, from: i, to: d }), !0) : !1),
321
- Leave: ({ type: { name: n }, from: i, to: d }) => o.includes(n) || n in a ? (H.pop(), !0) : !1
330
+ }, n = {
331
+ CodeMark: (o, d, u) => [l.mark({ class: "cb-mk" }).range(d, u)],
332
+ CodeInfo: (o, d, u) => [l.mark({ class: "cb-mi" }).range(d, u)]
333
+ }, s = [];
334
+ return v(e, {
335
+ enter: ({ type: { name: o }, from: d, to: u }) => (r === "type" && o in c && s.push(...c[o](e, d, u, i)), r === "mark" && o in n && s.push(...n[o](e, d, u)), a.includes(o) || o in c ? (E.push({ name: o, from: d, to: u }), !0) : !1),
336
+ Leave: ({ type: { name: o }, from: d, to: u }) => a.includes(o) || o in c ? (E.pop(), !0) : !1
322
337
  }), {
323
- type: l.set(r, !0),
324
- mark: l.set(r, !0)
325
- }[s];
338
+ type: l.set(s, !0),
339
+ mark: l.set(s, !0)
340
+ }[r];
326
341
  }
327
- const Z = (e, t, s) => {
328
- const o = [], a = H[H.length - 1], c = ["BulletList", "OrderedList", "ListItem"].some((p) => p === a.name), r = ["Blockquote"].some((p) => p === a.name), n = e.state.doc.lineAt(t), i = t - n.from, d = i > 0, u = M(e, n.from, s);
329
- u || o.push(
342
+ const Z = (e, t, r, i) => {
343
+ const a = i.marginLeft, c = i.paddingLeft, n = [], s = E[E.length - 1], o = ["BulletList", "OrderedList", "ListItem"].some((b) => b === s.name), d = ["Blockquote"].some((b) => b === s.name), u = e.state.doc.lineAt(t), g = t - u.from, m = g > 0, w = x(e, u.from, r);
344
+ n.push(
330
345
  l.widget({ widget: new fe("view.state.sliceDoc(from, to)", "code"), side: 0 }).range(t + 1)
331
346
  );
332
- const g = n.number, C = e.state.doc.sliceString(t, s).split(`
347
+ const p = u.number, T = e.state.doc.sliceString(t, r).split(`
333
348
  `).length;
334
- for (let p = g; p < C + g; p++) {
335
- const { from: h, to: k } = e.state.doc.line(p), L = "100% - 1.2ch", b = ["cb-content"];
336
- u && b.push("sw"), p === g && b.push("cb-start"), p === C + g - 1 && b.push("cb-end");
337
- const f = Math.max(h + i, 0);
338
- if (k < f)
339
- b.push("free"), o.push(
349
+ for (let b = p; b < T + p; b++) {
350
+ const { from: f, to: k } = e.state.doc.line(b), L = `100% - ${a + c}px`, q = ["cb-content"];
351
+ w && q.push("sw"), b === p && q.push("cb-start"), b === T + p - 1 && q.push("cb-end");
352
+ const C = Math.max(f + g, 0);
353
+ if (k < C)
354
+ n.push(l.widget({
355
+ widget: new B(
356
+ ["left", "cb-error"].join(" "),
357
+ "0.1px"
358
+ ),
359
+ side: 0
360
+ }).range(k), l.widget({
361
+ widget: new B(
362
+ ["cb-error", "right"].join(" "),
363
+ "",
364
+ "",
365
+ C - k
366
+ ),
367
+ side: 1
368
+ }).range(k));
369
+ else if (f === k && f === C)
370
+ n.push(l.widget({
371
+ widget: new B(
372
+ [...q, "left"].join(" "),
373
+ "0"
374
+ ),
375
+ side: 0
376
+ }).range(k), l.widget({
377
+ widget: new B(
378
+ q.join(" "),
379
+ `calc(${L} - ${c}px)`,
380
+ "0"
381
+ ),
382
+ side: 1
383
+ }).range(C));
384
+ else if (C === k)
385
+ q.push("wg"), n.push(
340
386
  l.widget({
341
- widget: new A(
342
- b.join(" "),
343
- `calc(${L} - ${f - h}ch)`,
344
- `calc(${f - k}ch + 2px)`
387
+ widget: new B(
388
+ q.join(" "),
389
+ `calc(${L} - ${C - f}ch)`
345
390
  ),
346
391
  side: 1
347
- }).range(k)
348
- ), console.log("Hello World");
349
- else if (f === k)
350
- b.push("wg"), o.push(
351
- l.widget({
352
- widget: new A(
353
- b.join(" "),
354
- `calc(${L} - ${f - h}ch)`
355
- ),
356
- side: 1
357
- }).range(f)
392
+ }).range(C)
358
393
  );
359
- else if (c || r || d) {
360
- const w = { style: `width: calc(${L} - ${f - h}ch)` };
361
- k > f && o.push(l.mark({ class: b.join(" "), attributes: w }).range(f, k)), h !== f && c && o.push(l.mark({ class: "cb-listsp" }).range(h, f)), h !== f && d && o.push(l.mark({ class: "cb-spacer" }).range(h, f)), h !== f && r && o.push(l.mark({ class: "cb-quote bq" }).range(h, f));
362
- } else if (h !== k) {
363
- const w = { style: `width: calc(${L})` };
364
- o.push(l.mark({ class: b.join(" "), attributes: w }).range(h, k));
394
+ else if (o || d || m) {
395
+ const H = { style: `width: calc(${L} - ${C - f}ch)` };
396
+ k > C && n.push(l.mark({ class: q.join(" "), attributes: H }).range(C, k)), f !== C && o && n.push(l.mark({ class: "cb-listsp" }).range(f, C)), f !== C && m && n.push(l.mark({ class: "cb-spacer" }).range(f, C)), f !== C && d && n.push(l.mark({ class: "cb-quote bq" }).range(f, C));
397
+ } else if (f !== k) {
398
+ const H = { style: `width: calc(${L})` };
399
+ n.push(l.mark({ class: q.join(" "), attributes: H }).range(f, k));
365
400
  }
366
- o.push(l.line({ class: "cb-line" }).range(h));
401
+ n.push(l.line({ class: "cb-line" }).range(f));
367
402
  }
368
- return o;
369
- }, Ce = () => {
370
- const o = "4px", a = "1lh";
371
- return T.baseTheme({
372
- ".cb-start": { borderRadius: `${o} ${o} 0 0` },
373
- ".cb-end ": { borderRadius: `0 0 ${o} ${o}` },
374
- ".cb-start.cb-end": { borderRadius: `${o}` },
375
- ".cb-content": {
403
+ return n;
404
+ }, Ce = (e) => {
405
+ const t = e.marginLeft, r = e.paddingLeft, i = 0, a = "4px", c = "1lh";
406
+ return M.baseTheme({
407
+ "& .cb-start": { borderRadius: `${a} ${a} 0 0` },
408
+ "& .cb-end ": { borderRadius: `0 0 ${a} ${a}` },
409
+ "& .cb-start.cb-end": { borderRadius: `${a}` },
410
+ "& .cm-line .cb-content": {
376
411
  display: "inline-block",
377
- marginLeft: "2px",
378
- paddingLeft: "6px",
379
- paddingRigth: "0px",
412
+ marginLeft: `${t}px`,
413
+ paddingLeft: `${r}px`,
414
+ paddingRigth: `${i}px`,
380
415
  position: "relative"
381
416
  },
382
- ".cb-content.wg": { cursor: "text" },
383
- ".cb-content.wg.start": {
417
+ "& .cb-content.wg": { cursor: "text" },
418
+ "& .cb-content.wg.start": {
384
419
  maxWidth: "1px",
385
420
  Width: "1px",
386
- paddingLeft: "5px"
421
+ paddingLeft: `${r - 1}px`
387
422
  },
388
- ".cb-content.wg.end": {
423
+ "& .cb-content.wg.end": {
389
424
  marginLeft: "0",
390
425
  paddingLeft: "0"
391
426
  },
392
- ".cb-mi, .cb-mk": { color: "transparent" },
427
+ "& .cb-mi,& .cb-mk": { color: "transparent" },
393
428
  "&.cm-focused .cb-content.sw > .cb-mi, &.cm-focused .cb-content.sw > .cb-mk": { color: "inherit" },
394
429
  "&.cm-focused .cb-content.sw .wg-codeblock": {
395
430
  display: "none",
396
431
  opacity: "0"
397
432
  },
398
- ".wg-codeblock": {
433
+ "& .wg-codeblock": {
399
434
  display: "inline-block",
400
435
  position: "absolute",
401
436
  top: "0",
@@ -403,7 +438,7 @@ const Z = (e, t, s) => {
403
438
  zIndex: "100",
404
439
  margin: ".05lh"
405
440
  },
406
- ".wg-codeblock-btn": {
441
+ "& .wg-codeblock-btn": {
407
442
  padding: "0",
408
443
  display: "inline-flex",
409
444
  borderRadius: "999999px",
@@ -412,54 +447,66 @@ const Z = (e, t, s) => {
412
447
  outline: "none",
413
448
  justifyContent: "center",
414
449
  alignItems: "center",
415
- height: `calc(${a} + 4px )`,
450
+ height: `calc(${c} + 4px )`,
416
451
  width: "5ch"
417
452
  },
418
- ".cb-icon": {
419
- width: a,
420
- height: a,
453
+ "& .cb-icon": {
454
+ width: c,
455
+ height: c,
421
456
  pointerEvents: "none",
422
457
  fill: "currentColor",
423
458
  opacity: "0.7"
424
459
  },
425
- ".wg-codeblock-btn:hover": { background: "rgba(0, 0, 0, 0.07)" },
426
- ".wg-codeblock-btn:hover .cb-icon": { opacity: "1" },
427
- ".cb-content.cb-start.cb-end .wg-codeblock": {
460
+ "& .wg-codeblock-btn:hover": { background: "rgba(0, 0, 0, 0.07)" },
461
+ "& .wg-codeblock-btn:hover .cb-icon": { opacity: "1" },
462
+ "& .cb-content.cb-start.cb-end .wg-codeblock": {
428
463
  marginTop: "0",
429
464
  marginBottom: "0",
430
465
  top: "0",
431
466
  bottom: "0"
432
467
  },
433
- ".cb-content.cb-start.cb-end .wg-codeblock-btn": {
468
+ "& .cb-content.cb-start.cb-end .wg-codeblock-btn": {
434
469
  boxSizing: "border-box",
435
470
  maxHeight: "100%",
436
471
  width: "5ch"
437
472
  },
438
473
  "& .cb-content": {
439
474
  backgroundColor: "var(--cm-ic-background, hsl(from black h s l / .1))"
475
+ },
476
+ "& .cb-error.left": { padding: "0" },
477
+ "& .cb-error.right": { paddingRight: `${t}px` },
478
+ "& .cb-error": {
479
+ display: "inline-block",
480
+ backgroundColor: "var(--cm-ic-error, hsl(from red h s l / .5))"
440
481
  }
441
482
  });
442
- }, ke = () => [
443
- q(D, { mode: "mark" }),
444
- q(D, { mode: "type" }, { eventHandlers: { mousedown: he } }),
445
- Ce()
446
- ];
483
+ }, ke = () => {
484
+ const e = {
485
+ marginLeft: 2,
486
+ paddingLeft: 6
487
+ };
488
+ return [
489
+ y(D, { mode: "mark" }),
490
+ y(D, { mode: "type", options: e }, { eventHandlers: { mousedown: he } }),
491
+ Ce(e)
492
+ ];
493
+ };
447
494
  function be(e, t) {
448
- const s = ["Document"], o = {
449
- ATXHeading1: (r, n = !0) => l.line({ class: "h1 hg " + (n ? "sw" : "") }).range(r),
450
- ATXHeading2: (r, n = !0) => l.line({ class: "h2 hg " + (n ? "sw" : "") }).range(r),
451
- ATXHeading3: (r, n = !0) => l.line({ class: "h3 hg " + (n ? "sw" : "") }).range(r),
452
- ATXHeading4: (r, n = !0) => l.line({ class: "h4 hg " + (n ? "sw" : "") }).range(r),
453
- ATXHeading5: (r, n = !0) => l.line({ class: "h5 hg " + (n ? "sw" : "") }).range(r),
454
- ATXHeading6: (r, n = !0) => l.line({ class: "h6 hg " + (n ? "sw" : "") }).range(r)
495
+ const r = ["Document"], i = {
496
+ ATXHeading1: (n, s = !0) => l.line({ class: "h1 hg " + (s ? "sw" : "") }).range(n),
497
+ ATXHeading2: (n, s = !0) => l.line({ class: "h2 hg " + (s ? "sw" : "") }).range(n),
498
+ ATXHeading3: (n, s = !0) => l.line({ class: "h3 hg " + (s ? "sw" : "") }).range(n),
499
+ ATXHeading4: (n, s = !0) => l.line({ class: "h4 hg " + (s ? "sw" : "") }).range(n),
500
+ ATXHeading5: (n, s = !0) => l.line({ class: "h5 hg " + (s ? "sw" : "") }).range(n),
501
+ ATXHeading6: (n, s = !0) => l.line({ class: "h6 hg " + (s ? "sw" : "") }).range(n)
455
502
  }, a = {
456
- HeaderMark: (r, n) => l.mark({ class: "mk" }).range(r, n)
503
+ HeaderMark: (n, s) => l.mark({ class: "mk" }).range(n, s)
457
504
  }, c = [];
458
- return y(e, {
459
- enter: ({ type: r, from: n, to: i }) => (r.name in o && c.push(o[r.name](n, M(e, n, i))), r.name in a && c.push(a[r.name](n, i + 1)), s.includes(r.name) || r.name in o)
505
+ return v(e, {
506
+ enter: ({ type: n, from: s, to: o }) => (n.name in i && c.push(i[n.name](s, x(e, s, o))), n.name in a && c.push(a[n.name](s, o + 1)), r.includes(n.name) || n.name in i)
460
507
  }), l.set(c, !1);
461
508
  }
462
- const we = T.baseTheme({
509
+ const we = M.baseTheme({
463
510
  "& .h1 ": { fontSize: "2.00em", fontWeight: "bolder" },
464
511
  "& .h2 ": { fontSize: "1.55em", fontWeight: "bolder" },
465
512
  "& .h3 ": { fontSize: "1.35em", fontWeight: "bolder" },
@@ -467,11 +514,11 @@ const we = T.baseTheme({
467
514
  "& .h5 ": { fontSize: "1.25em", fontWeight: "semi-bold" },
468
515
  "& .h6 ": { fontSize: "1.25em", fontWeight: "normal" },
469
516
  "& .hg ": { lineHeight: "1.5lh" }
470
- }), Le = T.baseTheme({
517
+ }), Le = M.baseTheme({
471
518
  "& .hg .mk": { fontSize: "0" },
472
519
  "&.cm-focused .hg.sw .mk": { fontSize: "inherit" }
473
520
  }), Te = () => [
474
- q(be, {}),
521
+ y(be, {}),
475
522
  we,
476
523
  Le
477
524
  ], qe = (e) => `<svg class="qt-icon qt-caution" width="400" height="400" viewBox="0 0 400 400" fill="none" xmlns="http://www.w3.org/2000/svg">
@@ -485,7 +532,7 @@ const we = T.baseTheme({
485
532
  </svg>`, ve = (e) => `<svg class="qt-icon qt-tip" width="400" height="400" viewBox="0 0 400 400" fill="none" xmlns="http://www.w3.org/2000/svg">
486
533
  <path fill-rule="evenodd" clip-rule="evenodd" d="M197.813 54.2439C196.932 54.6529 195.79 55.5789 195.274 56.3019L194.336 57.6169L194.219 70.8359L194.102 84.0549L195.076 85.3319C197.802 88.9059 203.271 88.5369 205.364 84.6369C206.151 83.1699 206.872 60.7239 206.215 58.1479C205.842 56.6839 203.21 53.9059 202.196 53.9059C201.901 53.9059 201.155 53.8149 200.537 53.7039C199.864 53.5829 198.772 53.7989 197.813 54.2439ZM116.233 86.0419C113.323 87.6899 112.27 91.6249 113.92 94.6849C115.402 97.4339 131.364 113.194 132.973 113.496C138.573 114.546 142.477 110.343 140.971 104.883C140.465 103.049 125.118 87.2169 122.574 85.9039C120.632 84.9019 118.15 84.9559 116.233 86.0419ZM277.93 85.7559C276.466 86.4829 260.132 103.191 259.49 104.618C257.281 109.529 261.871 114.699 267.084 113.171C268.604 112.726 283.491 98.5359 285.985 95.1559C289.892 89.8619 283.853 82.8139 277.93 85.7559ZM192.578 105.326C174.207 107.647 159.188 115.505 147.608 128.855C123.664 156.459 124.119 191.541 148.828 223.047C160.759 238.26 165.383 249.444 166.996 266.992C167.829 276.054 168.682 277.986 172.825 280.204C174.652 281.182 221.998 281.773 225.389 280.86C229.012 279.884 232.583 275.584 232.967 271.735C233.077 270.63 233.363 267.529 233.603 264.844C234.904 250.229 238.454 241.734 249.573 226.622C261.236 210.772 265.303 202.299 269.01 186.133C271.624 174.731 269.08 156.872 263.028 144.145C251.295 119.471 219.462 101.931 192.578 105.326ZM88.992 165.981C83.602 166.183 82.734 166.309 81.765 167.028C77.932 169.873 77.932 174.66 81.766 177.503C83.099 178.491 104.15 178.988 108.11 178.124C114.214 176.794 115.972 170.208 111.179 166.626C109.976 165.727 101.966 165.494 88.992 165.981ZM289.847 166.481C285.102 168.919 285.171 174.882 289.974 177.45C292.2 178.64 314.187 179.022 317.07 177.921C322.542 175.831 321.886 167.919 316.118 166.457C312.336 165.498 291.723 165.517 289.847 166.481ZM132.14 230.477C129.964 231.352 113.316 248.951 113.059 250.648C112.263 255.894 117.791 260.112 122.389 257.768C124.057 256.918 139.906 240.858 140.656 239.258C143.226 233.779 137.81 228.195 132.14 230.477ZM262.386 230.871C259.487 232.447 258.349 236.857 260.122 239.648C261.348 241.579 276.261 256.486 277.701 257.219C282.933 259.885 288.816 254.457 286.416 249.179C285.559 247.294 271.67 232.693 269.4 231.29C267.429 230.071 264.211 229.879 262.386 230.871ZM174.576 292.561C170.753 293.719 169.922 295.59 169.922 303.033C169.922 310.255 170.618 312.154 173.969 314.076L175.977 315.227L200.113 315.231C223.446 315.234 224.301 315.208 225.774 314.457C229.279 312.669 230.367 309.882 230.446 302.493L230.504 297.04L229.29 295.365C226.903 292.07 228.123 292.201 200.195 292.23C186.66 292.243 175.131 292.392 174.576 292.561ZM180.946 325.217C179.882 325.963 179.759 328.554 180.683 330.774C185.032 341.224 208.831 343.084 217.528 333.654C220.185 330.773 221.108 326.967 219.531 325.391C218.456 324.315 182.465 324.154 180.946 325.217Z"/>
487
534
  </svg>`, Q = { tip: ve, note: xe, important: ye, warning: Me, caution: qe, none: () => "" };
488
- class He extends x {
535
+ class He extends $ {
489
536
  constructor(t) {
490
537
  super(), this.type = t;
491
538
  }
@@ -501,7 +548,7 @@ class He extends x {
501
548
  }
502
549
  }
503
550
  function $e(e, t) {
504
- const s = ["Document", "ListItem", "BulletList", "OrderedList"], o = {
551
+ const r = ["Document", "ListItem", "BulletList", "OrderedList"], i = {
505
552
  none: "bq-none-mark",
506
553
  note: "bq-note-mark",
507
554
  tip: "bq-tip-mark",
@@ -509,61 +556,61 @@ function $e(e, t) {
509
556
  important: "bq-important-mark",
510
557
  caution: "bq-caution-mark"
511
558
  }, a = {
512
- QuoteMark: (n, i, d) => {
559
+ QuoteMark: (s, o, d) => {
513
560
  const u = ["qt-mk"];
514
- return d in o ? u.push(o[d]) : u.push(o.none), l.mark({
561
+ return d in i ? u.push(i[d]) : u.push(i.none), l.mark({
515
562
  class: u.join(" ")
516
- }).range(n, i);
563
+ }).range(s, o);
517
564
  },
518
- QuoteType: (n, i, d) => l.widget({
565
+ QuoteType: (s, o, d) => l.widget({
519
566
  widget: new He(d),
520
567
  side: 1
521
- }).range(n),
522
- BlockquoteLine: (n, i) => l.line({ class: "bq-line " + (i ? "sw" : "") }).range(n),
523
- quoteLine: (n, i, d) => {
568
+ }).range(s),
569
+ BlockquoteLine: (s, o) => l.line({ class: "bq-line " + (o ? "sw" : "") }).range(s),
570
+ quoteLine: (s, o, d) => {
524
571
  const u = `calc(100% - ${Math.max(0, d) + 1.2}ch)`;
525
572
  return l.mark({
526
573
  class: "bq-text-line",
527
574
  attributes: { style: `width: ${u}` }
528
- }).range(n, i);
575
+ }).range(s, o);
529
576
  }
530
- }, c = (n, i, d, u) => {
531
- const g = [], C = d.number, p = (h, k) => {
532
- let L = 0;
533
- const b = [];
534
- let f = 0;
577
+ }, c = (s, o, d, u) => {
578
+ const g = [], m = d.number, w = (p, T) => {
579
+ let b = 0;
580
+ const f = [];
581
+ let k = 0;
535
582
  return {
536
- enter({ name: w, node: I, from: $, to: S }) {
537
- w === "Blockquote" && b.push(Se(n, I)), w === "QuoteMark" && (g.push(a[w]($, S, b[L])), f = S, L++), w === "QuoteType" && g.push(a[w]($, S, b[L - 1]));
583
+ enter({ name: L, node: q, from: C, to: H }) {
584
+ L === "Blockquote" && f.push(Se(s, q)), L === "QuoteMark" && (g.push(a[L](C, H, f[b])), k = H, b++), L === "QuoteType" && g.push(a[L](C, H, f[b - 1]));
538
585
  },
539
- leave({ name: w, from: I, to: $ }) {
540
- w === "Paragraph" && f < k && g.push(a.quoteLine(f, k, f - h));
586
+ leave({ name: L, from: q, to: C }) {
587
+ L === "Paragraph" && k < T && g.push(a.quoteLine(k, T, k - p));
541
588
  }
542
589
  };
543
590
  };
544
- for (let h = C; h < u + C; h++) {
545
- const { from: k, to: L } = n.state.doc.line(h), { from: b, to: f } = i, w = M(n, b, f);
546
- g.push(a.BlockquoteLine(k, w)), E(n.state).iterate({ from: k, to: L, ...p(k, L) });
591
+ for (let p = m; p < u + m; p++) {
592
+ const { from: T, to: b } = s.state.doc.line(p), { from: f, to: k } = o, L = x(s, f, k);
593
+ g.push(a.BlockquoteLine(T, L)), I(s.state).iterate({ from: T, to: b, ...w(T, b) });
547
594
  }
548
595
  return g;
549
- }, r = [];
550
- return y(e, {
551
- enter: ({ name: n, from: i, to: d, node: u }) => {
552
- if (n === "Blockquote") {
553
- const g = e.state.sliceDoc(i, d).split(`
554
- `), C = e.state.doc.lineAt(i);
555
- r.push(...c(e, u, C, g.length));
596
+ }, n = [];
597
+ return v(e, {
598
+ enter: ({ name: s, from: o, to: d, node: u }) => {
599
+ if (s === "Blockquote") {
600
+ const g = e.state.sliceDoc(o, d).split(`
601
+ `), m = e.state.doc.lineAt(o);
602
+ n.push(...c(e, u, m, g.length));
556
603
  }
557
- return s.includes(n);
604
+ return r.includes(s);
558
605
  }
559
- }), l.set(r, !0);
606
+ }), l.set(n, !0);
560
607
  }
561
608
  const Se = (e, t) => {
562
- const s = t.getChild("QuoteType");
563
- if (!s) return "none";
564
- const o = s.getChild("QuoteTypeText");
565
- return o ? e.state.sliceDoc(o.from, o.to).toLowerCase() : "none";
566
- }, Be = () => T.baseTheme({
609
+ const r = t.getChild("QuoteType");
610
+ if (!r) return "none";
611
+ const i = r.getChild("QuoteTypeText");
612
+ return i ? e.state.sliceDoc(i.from, i.to).toLowerCase() : "none";
613
+ }, Be = () => M.baseTheme({
567
614
  "& .qt-mk": {
568
615
  // outline: "1px red solid",
569
616
  position: "relative",
@@ -613,78 +660,78 @@ const Se = (e, t) => {
613
660
  "& .wg-qt-icon > .qt-warning": { fill: "var(--bq-warning-mark, peru)" },
614
661
  "& .wg-qt-icon > .qt-caution": { fill: "var(--bq-caution-mark, red)" }
615
662
  }), Ee = () => [
616
- q($e, {}),
663
+ y($e, {}),
617
664
  Be()
618
- ], Ie = {
665
+ ], Ae = {
619
666
  name: "QuoteTypeParser",
620
667
  parse(e, t) {
621
668
  if ((() => {
622
- for (let o = 0; o < e.depth; o++)
623
- if (e.parentType(o).name === "Blockquote") return !0;
669
+ for (let i = 0; i < e.depth; i++)
670
+ if (e.parentType(i).name === "Blockquote") return !0;
624
671
  return !1;
625
672
  })()) {
626
- const o = t.text.match(/^(\s*>\s*)+(\[!\w+\])\s*$/);
627
- if (o && o[2]) {
628
- const a = o[2], c = t.text.indexOf(a), r = c + a.length, n = e.elt("QuoteType", e.lineStart + c, e.lineStart + r);
629
- n.children = [
673
+ const i = t.text.match(/^(\s*>\s*)+(\[!\w+\])\s*$/);
674
+ if (i && i[2]) {
675
+ const a = i[2], c = t.text.indexOf(a), n = c + a.length, s = e.elt("QuoteType", e.lineStart + c, e.lineStart + n);
676
+ s.children = [
630
677
  e.elt("QuoteTypeMark", e.lineStart + c, e.lineStart + c + 2),
631
- e.elt("QuoteTypeText", e.lineStart + c + 2, e.lineStart + r - 1),
632
- e.elt("QuoteTypeMark", e.lineStart + r - 1, e.lineStart + r)
633
- ], e.addElement(n);
678
+ e.elt("QuoteTypeText", e.lineStart + c + 2, e.lineStart + n - 1),
679
+ e.elt("QuoteTypeMark", e.lineStart + n - 1, e.lineStart + n)
680
+ ], e.addElement(s);
634
681
  }
635
682
  }
636
683
  return !1;
637
684
  }
638
- }, Ae = {
685
+ }, Ie = {
639
686
  defineNodes: [
640
- { name: "QuoteType", style: { "QuoteType/...": B.content } },
641
- { name: "QuoteTypeMark", style: B.processingInstruction },
642
- { name: "QuoteTypeText", style: B.bool }
687
+ { name: "QuoteType", style: { "QuoteType/...": A.content } },
688
+ { name: "QuoteTypeMark", style: A.processingInstruction },
689
+ { name: "QuoteTypeText", style: A.bool }
643
690
  ],
644
- parseBlock: [Ie]
645
- }, N = (e, t, s) => {
646
- const o = e.state.sliceDoc(t, s), a = o.match(/\[(.*)\]/);
691
+ parseBlock: [Ae]
692
+ }, N = (e, t, r) => {
693
+ const i = e.state.sliceDoc(t, r), a = i.match(/\[(.*)\]/);
647
694
  return a !== null && a.length > 1 ? {
648
695
  text: a[1],
649
- from: t + o.indexOf(a[1]),
696
+ from: t + i.indexOf(a[1]),
650
697
  to: t + 1 + a[1].length
651
698
  } : { text: null };
652
699
  };
653
700
  function De(e, t) {
654
- const s = ["FencedCode", "Image", "Link"], o = {
701
+ const r = ["FencedCode", "Image", "Link"], i = {
655
702
  Link: {
656
703
  marks: ["LinkMark"],
657
704
  url: "URL"
658
705
  }
659
706
  }, a = {
660
- Link: (r, n, i) => l.mark({ class: "link " + (i ? "sw" : "") }).range(r, n),
661
- LinkMark: (r, n) => l.mark({ class: "lk-mk" }).range(r, n),
662
- TextDec: (r, n, i) => l.mark({
707
+ Link: (n, s, o) => l.mark({ class: "link " + (o ? "sw" : "") }).range(n, s),
708
+ LinkMark: (n, s) => l.mark({ class: "lk-mk" }).range(n, s),
709
+ TextDec: (n, s, o) => l.mark({
663
710
  class: "lk-text url",
664
711
  tagName: "a",
665
- attributes: { href: i, target: "_blank" }
666
- }).range(r, n),
667
- URL: (r, n, i) => l.mark({
712
+ attributes: { href: o, target: "_blank" }
713
+ }).range(n, s),
714
+ URL: (n, s, o) => l.mark({
668
715
  class: "lk-url url",
669
716
  tagName: "a",
670
- attributes: { href: i, target: "_blank" }
671
- }).range(r, n)
717
+ attributes: { href: o, target: "_blank" }
718
+ }).range(n, s)
672
719
  }, c = [];
673
- return y(e, {
674
- enter: ({ type: { name: r }, from: n, to: i, node: d }) => {
675
- if (r === "URL" && c.push(a.URL(n, i, e.state.sliceDoc(n, i))), !(r in o)) return !s.includes(r);
676
- c.push(a.Link(n, i, M(e, n, i)));
677
- const u = o[r].marks.flatMap((p) => d.getChildren(p));
678
- c.push(...u.map(({ from: p, to: h }) => a.LinkMark(p, h)));
679
- const g = d.getChild(o[r].url);
680
- let C = null;
720
+ return v(e, {
721
+ enter: ({ type: { name: n }, from: s, to: o, node: d }) => {
722
+ if (n === "URL" && c.push(a.URL(s, o, e.state.sliceDoc(s, o))), !(n in i)) return !r.includes(n);
723
+ c.push(a.Link(s, o, x(e, s, o)));
724
+ const u = i[n].marks.flatMap((w) => d.getChildren(w));
725
+ c.push(...u.map(({ from: w, to: p }) => a.LinkMark(w, p)));
726
+ const g = d.getChild(i[n].url);
727
+ let m = null;
681
728
  if (g !== null) {
682
- const { from: p, to: h } = g;
683
- C = e.state.sliceDoc(p, h), c.push(a.URL(p, h, C));
729
+ const { from: w, to: p } = g;
730
+ m = e.state.sliceDoc(w, p), c.push(a.URL(w, p, m));
684
731
  }
685
732
  if (d.getChild("Image") === null) {
686
- const { text: p, from: h, to: k } = N(e, n, i);
687
- p !== null && C !== null && c.push(a.TextDec(h, k, C));
733
+ const { text: w, from: p, to: T } = N(e, s, o);
734
+ w !== null && m !== null && c.push(a.TextDec(p, T, m));
688
735
  }
689
736
  return !1;
690
737
  }
@@ -696,22 +743,22 @@ const Ze = (e, t) => e.ctrlKey ? Qe(
696
743
  ) : !1, Qe = (e) => {
697
744
  if (e.nodeName === "A" && e.href && e.classList.contains("url"))
698
745
  return window.open(e.href, e.target), !0;
699
- }, ze = T.baseTheme({
746
+ }, ze = M.baseTheme({
700
747
  ".lk-mk, .link > .lk-url": { display: "none" },
701
748
  "&.cm-focused .link.sw .lk-mk, &.cm-focused .link.sw .lk-url": { display: "inherit" }
702
749
  }), Re = () => [
703
- q(De, {}, { eventHandlers: { mousedown: Ze } }),
750
+ y(De, {}, { eventHandlers: { mousedown: Ze } }),
704
751
  ze
705
752
  ];
706
- class Ne extends x {
707
- constructor(t, s = null, o = "[image]") {
708
- super(), this.img = t, this.url = s, this.alt = o;
753
+ class Ne extends $ {
754
+ constructor(t, r = null, i = "[image]") {
755
+ super(), this.img = t, this.url = r, this.alt = i;
709
756
  }
710
757
  toDOM() {
711
758
  let t = document.createElement("img");
712
759
  if (t.src = this.img, t.alt = this.alt, t.style.minWidth = "100px", this.url) {
713
- let s = document.createElement("a");
714
- return s.href = this.url, s.target = "_blank", s.classList.add("url"), s.appendChild(t), s;
760
+ let r = document.createElement("a");
761
+ return r.href = this.url, r.target = "_blank", r.classList.add("url"), r.appendChild(t), r;
715
762
  } else
716
763
  return t;
717
764
  }
@@ -723,49 +770,49 @@ class Ne extends x {
723
770
  }
724
771
  }
725
772
  function Pe(e, t) {
726
- const s = ["FencedCode", "Image"], o = [];
727
- return y(e, {
728
- enter: ({ type: { name: a }, from: c, to: r, node: n }) => {
729
- if (a === "Image" && !M(e, c, r)) {
730
- const { from: i, to: d } = n.getChild("URL"), u = e.state.sliceDoc(i, d), { text: g } = N(e, c, r);
731
- o.push(
773
+ const r = ["FencedCode", "Image"], i = [];
774
+ return v(e, {
775
+ enter: ({ type: { name: a }, from: c, to: n, node: s }) => {
776
+ if (a === "Image" && !x(e, c, n)) {
777
+ const { from: o, to: d } = s.getChild("URL"), u = e.state.sliceDoc(o, d), { text: g } = N(e, c, n);
778
+ i.push(
732
779
  l.replace({
733
- widget: new Ne(u, _e(e, n), g)
734
- }).range(c, r)
780
+ widget: new Ne(u, _e(e, s), g)
781
+ }).range(c, n)
735
782
  );
736
783
  }
737
- return !s.includes(a);
784
+ return !r.includes(a);
738
785
  }
739
- }), l.set(o, !1);
786
+ }), l.set(i, !1);
740
787
  }
741
788
  const _e = (e, t) => {
742
- const o = t.parent.getChild("URL");
743
- if (o !== null) {
744
- const { from: a, to: c } = o;
789
+ const i = t.parent.getChild("URL");
790
+ if (i !== null) {
791
+ const { from: a, to: c } = i;
745
792
  return e.state.sliceDoc(a, c);
746
793
  }
747
794
  return null;
748
- }, Oe = (e, t) => e.ctrlKey ? We(
795
+ }, Oe = (e, t) => e.ctrlKey ? Ve(
749
796
  e.target
750
797
  /* as HTMLElement */
751
- ) : !1, We = (e) => {
798
+ ) : !1, Ve = (e) => {
752
799
  const t = e.parentElement ?? !1;
753
800
  if (e.nodeName === "IMG" && t && t.nodeName === "A" && t.classList.contains("url"))
754
801
  return !0;
755
- }, Ve = T.baseTheme({}), Fe = () => [
756
- q(Pe, {}, { eventHandlers: { mousedown: Oe } }),
757
- Ve
802
+ }, We = M.baseTheme({}), Fe = () => [
803
+ y(Pe, {}, { eventHandlers: { mousedown: Oe } }),
804
+ We
758
805
  ];
759
- class z extends x {
760
- constructor(t, s = !1) {
761
- super(), this.content = t, this.tag = s;
806
+ class z extends $ {
807
+ constructor(t, r = !1) {
808
+ super(), this.content = t, this.tag = r;
762
809
  }
763
810
  toDOM() {
764
811
  const t = document.createElement("div");
765
812
  t.className = "cm-html-widget", t.setAttribute("aria-hidden", "true");
766
- const s = this.content.replace(/^```html\n?/, "").replace(/```$/, "").trim();
767
- return t.innerHTML = (this.tag ? '<span class="cm-rendered-tag">RTAG</span>' : "") + s, t.querySelectorAll("script").forEach((o) => {
768
- o.parentNode.removeChild(o);
813
+ const r = this.content.replace(/^```html\n?/, "").replace(/```$/, "").trim();
814
+ return t.innerHTML = (this.tag ? '<span class="cm-rendered-tag">RTAG</span>' : "") + r, t.querySelectorAll("script").forEach((i) => {
815
+ i.parentNode.removeChild(i);
769
816
  }), t;
770
817
  }
771
818
  ignoreEvent(t) {
@@ -781,9 +828,9 @@ const P = G.define(), Ue = K.define({
781
828
  },
782
829
  update(e, t) {
783
830
  e = e.map(t.changes);
784
- for (let s of t.effects)
785
- if (s.is(P))
786
- return s.value;
831
+ for (let r of t.effects)
832
+ if (r.is(P))
833
+ return r.value;
787
834
  return e;
788
835
  },
789
836
  provide: (e) => R.decorations.from(e)
@@ -792,31 +839,31 @@ function Xe(e) {
792
839
  const t = [
793
840
  /<br>/,
794
841
  /<img .*\/>/
795
- ], s = {
842
+ ], r = {
796
843
  HTMLBlock: (a, c) => {
797
- const r = e.state.doc.sliceString(a, c);
844
+ const n = e.state.doc.sliceString(a, c);
798
845
  return [l.replace({
799
- widget: new z(r),
846
+ widget: new z(n),
800
847
  inclusive: !1
801
848
  }).range(a, c)];
802
849
  },
803
850
  HTMLTag: (a, c) => {
804
- const r = e.state.doc.sliceString(a, c);
805
- return console.log(r), t.some((n) => n.test(r)) ? (console.log(r), [
851
+ const n = e.state.doc.sliceString(a, c);
852
+ return console.log(n), t.some((s) => s.test(n)) ? (console.log(n), [
806
853
  l.replace({
807
- widget: new z(r, !0),
854
+ widget: new z(n, !0),
808
855
  inclusive: !1
809
856
  }).range(a, c)
810
857
  ]) : [];
811
858
  }
812
- }, o = [];
813
- return y(e, {
814
- enter: ({ type: a, from: c, to: r, node: n }) => {
815
- a.name in s && (!M(e, c, r) || !e.hasFocus) && o.push(...s[a.name](c, r));
859
+ }, i = [];
860
+ return v(e, {
861
+ enter: ({ type: a, from: c, to: n, node: s }) => {
862
+ a.name in r && (!x(e, c, n) || !e.hasFocus) && i.push(...r[a.name](c, n));
816
863
  }
817
- }), l.set(o);
864
+ }), l.set(i);
818
865
  }
819
- const je = T.baseTheme({
866
+ const je = M.baseTheme({
820
867
  "& .cm-html-widget": {
821
868
  all: "unset"
822
869
  // outline: "red solid 2px",
@@ -841,25 +888,25 @@ const je = T.baseTheme({
841
888
  const {
842
889
  markdown: {
843
890
  defaultCodeLanguage: t,
844
- codeLanguages: s,
845
- addKeymap: o,
891
+ codeLanguages: r,
892
+ addKeymap: i,
846
893
  base: a,
847
894
  completeHTMLTags: c,
848
- htmlTagLanguage: r,
849
- extensions: n = []
895
+ htmlTagLanguage: n,
896
+ extensions: s = []
850
897
  } = {}
851
898
  // theme
852
- } = e ?? {}, i = {
899
+ } = e ?? {}, o = {
853
900
  defaultCodeLanguage: t,
854
- codeLanguages: s || W,
855
- addKeymap: o,
901
+ codeLanguages: r || V,
902
+ addKeymap: i,
856
903
  base: a,
857
904
  completeHTMLTags: c,
858
- htmlTagLanguage: r,
859
- extensions: [...n, F, J, Ae]
905
+ htmlTagLanguage: n,
906
+ extensions: [...s, F, J, Ie]
860
907
  };
861
908
  return [
862
- V(i),
909
+ W(o),
863
910
  ne(),
864
911
  ie(),
865
912
  ge(),
@@ -882,6 +929,6 @@ export {
882
929
  Re as LinkPlugin,
883
930
  ge as ListPlugin,
884
931
  Ee as QuotePlugin,
885
- Ae as QuoteType,
932
+ Ie as QuoteType,
886
933
  ct as gnosis
887
934
  };