@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/README.md +1 -0
- package/dist/gnosis.mjs +413 -366
- package/dist/gnosis.umd.js +7 -7
- package/package.json +1 -1
package/dist/gnosis.mjs
CHANGED
|
@@ -1,74 +1,74 @@
|
|
|
1
1
|
var _ = Object.defineProperty;
|
|
2
|
-
var O = (e, t,
|
|
3
|
-
var
|
|
4
|
-
import { languages as
|
|
5
|
-
import { markdown as
|
|
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
|
|
8
|
-
import { ViewPlugin as j, Decoration as l, WidgetType as
|
|
9
|
-
import { syntaxTree as
|
|
10
|
-
import { EditorView as
|
|
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
|
|
13
|
-
"Blockquote/...":
|
|
14
|
-
HorizontalRule:
|
|
15
|
-
"ATXHeading1/... SetextHeading1/...":
|
|
16
|
-
"ATXHeading2/... SetextHeading2/...":
|
|
17
|
-
"ATXHeading3/...":
|
|
18
|
-
"ATXHeading4/...":
|
|
19
|
-
"ATXHeading5/...":
|
|
20
|
-
"ATXHeading6/...":
|
|
21
|
-
"Comment CommentBlock":
|
|
22
|
-
Escape:
|
|
23
|
-
Entity:
|
|
24
|
-
"Emphasis/...":
|
|
25
|
-
"StrongEmphasis/...":
|
|
26
|
-
"Strikethrough/...":
|
|
27
|
-
"TableHeader/...":
|
|
28
|
-
"Link/... Image/...":
|
|
29
|
-
"OrderedList/... BulletList/...":
|
|
30
|
-
"BlockQuote/...":
|
|
31
|
-
"InlineCode CodeText":
|
|
32
|
-
"URL Autolink":
|
|
33
|
-
"HeaderMark HardBreak QuoteMark ListMark LinkMark EmphasisMark CodeMark StrikethroughMark":
|
|
34
|
-
"CodeInfo LinkLabel TaskMarker TableDelimiter":
|
|
35
|
-
LinkTitle:
|
|
36
|
-
Paragraph:
|
|
37
|
-
"QuoteType/.. QuoteTypeMark QuoteTypeText":
|
|
38
|
-
}), J = { props: [Y] },
|
|
39
|
-
const
|
|
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
|
-
|
|
42
|
-
|
|
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(
|
|
50
|
-
},
|
|
51
|
-
const
|
|
52
|
-
for (let a of
|
|
53
|
-
if (a.from >= t && a.from <=
|
|
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
|
-
},
|
|
57
|
-
for (const { from:
|
|
58
|
-
|
|
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
|
|
62
|
-
HorizontalRule: (
|
|
63
|
-
l.line({ class: "hr " + (
|
|
64
|
-
l.mark({ class: "mk" }).range(
|
|
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
|
|
68
|
-
enter: ({ type:
|
|
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 = () =>
|
|
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
|
-
|
|
85
|
+
y(ee, {}),
|
|
86
86
|
te()
|
|
87
87
|
];
|
|
88
|
-
function
|
|
89
|
-
const
|
|
90
|
-
StrongEmphasis: (
|
|
91
|
-
Strikethrough: (
|
|
92
|
-
InlineCode: (
|
|
93
|
-
Emphasis: (
|
|
94
|
-
Mark: (
|
|
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
|
|
97
|
-
enter: ({ type: { name:
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
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
|
-
), !
|
|
103
|
+
), !r.includes(n))
|
|
104
104
|
}), l.set(c, !1);
|
|
105
105
|
}
|
|
106
|
-
const
|
|
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 =
|
|
116
|
+
}), oe = M.baseTheme({
|
|
117
117
|
".il .mkl": { fontSize: "0" },
|
|
118
118
|
"&.cm-focused .il.sw > .mkl": { fontSize: "inherit" }
|
|
119
119
|
}), ie = () => [
|
|
120
|
-
|
|
121
|
-
|
|
120
|
+
y(re, {}),
|
|
121
|
+
se,
|
|
122
122
|
oe
|
|
123
123
|
];
|
|
124
|
-
class ae extends
|
|
125
|
-
constructor(
|
|
124
|
+
class ae extends $ {
|
|
125
|
+
constructor(r) {
|
|
126
126
|
super();
|
|
127
|
-
|
|
128
|
-
this.checked =
|
|
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
|
|
133
|
-
|
|
134
|
-
let
|
|
135
|
-
return
|
|
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
|
|
142
|
+
const r = [
|
|
143
143
|
"Document",
|
|
144
144
|
"ListItem",
|
|
145
145
|
"Task",
|
|
146
146
|
"Blockquote"
|
|
147
|
-
],
|
|
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: (
|
|
158
|
-
TaskMarker: (
|
|
159
|
-
const
|
|
160
|
-
return g ? l.mark({ class: `tm ${
|
|
161
|
-
widget: new ae(
|
|
162
|
-
}).range(
|
|
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: (
|
|
166
|
-
const
|
|
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: ${
|
|
170
|
+
attributes: { style: `width: ${T}` }
|
|
171
171
|
}).range(p, d)
|
|
172
172
|
];
|
|
173
173
|
}
|
|
174
|
-
},
|
|
175
|
-
return
|
|
176
|
-
enter: ({ name:
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
o
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
o
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
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(
|
|
200
|
+
}), l.set(n, !0);
|
|
192
201
|
}
|
|
193
202
|
const le = (e, t) => {
|
|
194
|
-
var
|
|
195
|
-
let
|
|
196
|
-
if (
|
|
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
|
|
199
|
-
let a = e.state.doc.sliceString(Math.max(0,
|
|
200
|
-
if (a === "x") c = { from:
|
|
201
|
-
else if (a === " ") c = { from:
|
|
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 = () =>
|
|
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
|
-
|
|
252
|
+
y(ce, {}, { eventHandlers: { mousedown: le } }),
|
|
244
253
|
ue()
|
|
245
254
|
], he = (e, t) => {
|
|
246
|
-
var
|
|
247
|
-
let
|
|
248
|
-
if (
|
|
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
|
|
252
|
-
enter: ({ type: { name:
|
|
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
|
|
255
|
-
...
|
|
256
|
-
from: t.posAtDOM(
|
|
257
|
-
to: t.posAtDOM(
|
|
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,
|
|
269
|
+
}, me = (e, t, r, i) => {
|
|
261
270
|
const a = ["CodeMark", "CodeInfo"];
|
|
262
|
-
let c = e.state.doc.sliceString(
|
|
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:
|
|
265
|
-
a.includes(u) &&
|
|
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
|
|
277
|
+
const s = e.state.doc.lineAt(r), o = r - s.from, d = [];
|
|
269
278
|
return c.split(`
|
|
270
279
|
`).forEach((u, g) => {
|
|
271
|
-
|
|
280
|
+
n.has(g + s.number) || d.push(u.slice(o));
|
|
272
281
|
}), d.join(`
|
|
273
282
|
`);
|
|
274
283
|
};
|
|
275
|
-
class
|
|
276
|
-
constructor(
|
|
284
|
+
class B extends $ {
|
|
285
|
+
constructor(r, i, a, c = 1) {
|
|
277
286
|
super();
|
|
278
|
-
|
|
279
|
-
this.classes =
|
|
287
|
+
S(this, "classes", "");
|
|
288
|
+
this.classes = r, this.width = i, this.marginLeft = a, this.spaces = c;
|
|
280
289
|
}
|
|
281
290
|
toDOM() {
|
|
282
|
-
let
|
|
283
|
-
return
|
|
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
|
|
294
|
-
constructor(t,
|
|
295
|
-
super(), this.type = t, this.code =
|
|
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
|
|
301
|
-
return
|
|
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
|
|
316
|
+
const E = [];
|
|
308
317
|
function D(e, t) {
|
|
309
318
|
const {
|
|
310
|
-
mode:
|
|
319
|
+
mode: r,
|
|
311
320
|
/* type, mark */
|
|
312
|
-
|
|
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
|
-
},
|
|
316
|
-
CodeMark: (
|
|
317
|
-
CodeInfo: (
|
|
318
|
-
},
|
|
319
|
-
return
|
|
320
|
-
enter: ({ type: { name:
|
|
321
|
-
Leave: ({ type: { name:
|
|
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(
|
|
324
|
-
mark: l.set(
|
|
325
|
-
}[
|
|
338
|
+
type: l.set(s, !0),
|
|
339
|
+
mark: l.set(s, !0)
|
|
340
|
+
}[r];
|
|
326
341
|
}
|
|
327
|
-
const Z = (e, t,
|
|
328
|
-
const
|
|
329
|
-
|
|
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
|
|
347
|
+
const p = u.number, T = e.state.doc.sliceString(t, r).split(`
|
|
333
348
|
`).length;
|
|
334
|
-
for (let
|
|
335
|
-
const { from:
|
|
336
|
-
|
|
337
|
-
const
|
|
338
|
-
if (k <
|
|
339
|
-
|
|
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
|
|
342
|
-
|
|
343
|
-
`calc(${L} - ${
|
|
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(
|
|
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 (
|
|
360
|
-
const
|
|
361
|
-
k >
|
|
362
|
-
} else if (
|
|
363
|
-
const
|
|
364
|
-
|
|
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
|
-
|
|
401
|
+
n.push(l.line({ class: "cb-line" }).range(f));
|
|
367
402
|
}
|
|
368
|
-
return
|
|
369
|
-
}, Ce = () => {
|
|
370
|
-
const
|
|
371
|
-
return
|
|
372
|
-
".cb-start": { borderRadius: `${
|
|
373
|
-
".cb-end ": { borderRadius: `0 0 ${
|
|
374
|
-
".cb-start.cb-end": { borderRadius: `${
|
|
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:
|
|
378
|
-
paddingLeft:
|
|
379
|
-
paddingRigth:
|
|
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:
|
|
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
|
|
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(${
|
|
450
|
+
height: `calc(${c} + 4px )`,
|
|
416
451
|
width: "5ch"
|
|
417
452
|
},
|
|
418
|
-
".cb-icon": {
|
|
419
|
-
width:
|
|
420
|
-
height:
|
|
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
|
-
|
|
444
|
-
|
|
445
|
-
|
|
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
|
|
449
|
-
ATXHeading1: (
|
|
450
|
-
ATXHeading2: (
|
|
451
|
-
ATXHeading3: (
|
|
452
|
-
ATXHeading4: (
|
|
453
|
-
ATXHeading5: (
|
|
454
|
-
ATXHeading6: (
|
|
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: (
|
|
503
|
+
HeaderMark: (n, s) => l.mark({ class: "mk" }).range(n, s)
|
|
457
504
|
}, c = [];
|
|
458
|
-
return
|
|
459
|
-
enter: ({ type:
|
|
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 =
|
|
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 =
|
|
517
|
+
}), Le = M.baseTheme({
|
|
471
518
|
"& .hg .mk": { fontSize: "0" },
|
|
472
519
|
"&.cm-focused .hg.sw .mk": { fontSize: "inherit" }
|
|
473
520
|
}), Te = () => [
|
|
474
|
-
|
|
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
|
|
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
|
|
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: (
|
|
559
|
+
QuoteMark: (s, o, d) => {
|
|
513
560
|
const u = ["qt-mk"];
|
|
514
|
-
return d in
|
|
561
|
+
return d in i ? u.push(i[d]) : u.push(i.none), l.mark({
|
|
515
562
|
class: u.join(" ")
|
|
516
|
-
}).range(
|
|
563
|
+
}).range(s, o);
|
|
517
564
|
},
|
|
518
|
-
QuoteType: (
|
|
565
|
+
QuoteType: (s, o, d) => l.widget({
|
|
519
566
|
widget: new He(d),
|
|
520
567
|
side: 1
|
|
521
|
-
}).range(
|
|
522
|
-
BlockquoteLine: (
|
|
523
|
-
quoteLine: (
|
|
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(
|
|
575
|
+
}).range(s, o);
|
|
529
576
|
}
|
|
530
|
-
}, c = (
|
|
531
|
-
const g = [],
|
|
532
|
-
let
|
|
533
|
-
const
|
|
534
|
-
let
|
|
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:
|
|
537
|
-
|
|
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:
|
|
540
|
-
|
|
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
|
|
545
|
-
const { from:
|
|
546
|
-
g.push(a.BlockquoteLine(
|
|
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
|
-
},
|
|
550
|
-
return
|
|
551
|
-
enter: ({ name:
|
|
552
|
-
if (
|
|
553
|
-
const g = e.state.sliceDoc(
|
|
554
|
-
`),
|
|
555
|
-
|
|
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
|
|
604
|
+
return r.includes(s);
|
|
558
605
|
}
|
|
559
|
-
}), l.set(
|
|
606
|
+
}), l.set(n, !0);
|
|
560
607
|
}
|
|
561
608
|
const Se = (e, t) => {
|
|
562
|
-
const
|
|
563
|
-
if (!
|
|
564
|
-
const
|
|
565
|
-
return
|
|
566
|
-
}, Be = () =>
|
|
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
|
-
|
|
663
|
+
y($e, {}),
|
|
617
664
|
Be()
|
|
618
|
-
],
|
|
665
|
+
], Ae = {
|
|
619
666
|
name: "QuoteTypeParser",
|
|
620
667
|
parse(e, t) {
|
|
621
668
|
if ((() => {
|
|
622
|
-
for (let
|
|
623
|
-
if (e.parentType(
|
|
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
|
|
627
|
-
if (
|
|
628
|
-
const a =
|
|
629
|
-
|
|
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 +
|
|
632
|
-
e.elt("QuoteTypeMark", e.lineStart +
|
|
633
|
-
], e.addElement(
|
|
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
|
-
},
|
|
685
|
+
}, Ie = {
|
|
639
686
|
defineNodes: [
|
|
640
|
-
{ name: "QuoteType", style: { "QuoteType/...":
|
|
641
|
-
{ name: "QuoteTypeMark", style:
|
|
642
|
-
{ name: "QuoteTypeText", style:
|
|
687
|
+
{ name: "QuoteType", style: { "QuoteType/...": A.content } },
|
|
688
|
+
{ name: "QuoteTypeMark", style: A.processingInstruction },
|
|
689
|
+
{ name: "QuoteTypeText", style: A.bool }
|
|
643
690
|
],
|
|
644
|
-
parseBlock: [
|
|
645
|
-
}, N = (e, t,
|
|
646
|
-
const
|
|
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 +
|
|
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
|
|
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: (
|
|
661
|
-
LinkMark: (
|
|
662
|
-
TextDec: (
|
|
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:
|
|
666
|
-
}).range(
|
|
667
|
-
URL: (
|
|
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:
|
|
671
|
-
}).range(
|
|
717
|
+
attributes: { href: o, target: "_blank" }
|
|
718
|
+
}).range(n, s)
|
|
672
719
|
}, c = [];
|
|
673
|
-
return
|
|
674
|
-
enter: ({ type: { name:
|
|
675
|
-
if (
|
|
676
|
-
c.push(a.Link(
|
|
677
|
-
const u =
|
|
678
|
-
c.push(...u.map(({ from:
|
|
679
|
-
const g = d.getChild(
|
|
680
|
-
let
|
|
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:
|
|
683
|
-
|
|
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:
|
|
687
|
-
|
|
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 =
|
|
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
|
-
|
|
750
|
+
y(De, {}, { eventHandlers: { mousedown: Ze } }),
|
|
704
751
|
ze
|
|
705
752
|
];
|
|
706
|
-
class Ne extends
|
|
707
|
-
constructor(t,
|
|
708
|
-
super(), this.img = t, this.url =
|
|
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
|
|
714
|
-
return
|
|
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
|
|
727
|
-
return
|
|
728
|
-
enter: ({ type: { name: a }, from: c, to:
|
|
729
|
-
if (a === "Image" && !
|
|
730
|
-
const { from:
|
|
731
|
-
|
|
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,
|
|
734
|
-
}).range(c,
|
|
780
|
+
widget: new Ne(u, _e(e, s), g)
|
|
781
|
+
}).range(c, n)
|
|
735
782
|
);
|
|
736
783
|
}
|
|
737
|
-
return !
|
|
784
|
+
return !r.includes(a);
|
|
738
785
|
}
|
|
739
|
-
}), l.set(
|
|
786
|
+
}), l.set(i, !1);
|
|
740
787
|
}
|
|
741
788
|
const _e = (e, t) => {
|
|
742
|
-
const
|
|
743
|
-
if (
|
|
744
|
-
const { from: a, to: c } =
|
|
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 ?
|
|
795
|
+
}, Oe = (e, t) => e.ctrlKey ? Ve(
|
|
749
796
|
e.target
|
|
750
797
|
/* as HTMLElement */
|
|
751
|
-
) : !1,
|
|
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
|
-
},
|
|
756
|
-
|
|
757
|
-
|
|
802
|
+
}, We = M.baseTheme({}), Fe = () => [
|
|
803
|
+
y(Pe, {}, { eventHandlers: { mousedown: Oe } }),
|
|
804
|
+
We
|
|
758
805
|
];
|
|
759
|
-
class z extends
|
|
760
|
-
constructor(t,
|
|
761
|
-
super(), this.content = t, this.tag =
|
|
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
|
|
767
|
-
return t.innerHTML = (this.tag ? '<span class="cm-rendered-tag">RTAG</span>' : "") +
|
|
768
|
-
|
|
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
|
|
785
|
-
if (
|
|
786
|
-
return
|
|
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
|
-
],
|
|
842
|
+
], r = {
|
|
796
843
|
HTMLBlock: (a, c) => {
|
|
797
|
-
const
|
|
844
|
+
const n = e.state.doc.sliceString(a, c);
|
|
798
845
|
return [l.replace({
|
|
799
|
-
widget: new z(
|
|
846
|
+
widget: new z(n),
|
|
800
847
|
inclusive: !1
|
|
801
848
|
}).range(a, c)];
|
|
802
849
|
},
|
|
803
850
|
HTMLTag: (a, c) => {
|
|
804
|
-
const
|
|
805
|
-
return console.log(
|
|
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(
|
|
854
|
+
widget: new z(n, !0),
|
|
808
855
|
inclusive: !1
|
|
809
856
|
}).range(a, c)
|
|
810
857
|
]) : [];
|
|
811
858
|
}
|
|
812
|
-
},
|
|
813
|
-
return
|
|
814
|
-
enter: ({ type: a, from: c, to:
|
|
815
|
-
a.name in
|
|
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(
|
|
864
|
+
}), l.set(i);
|
|
818
865
|
}
|
|
819
|
-
const je =
|
|
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:
|
|
845
|
-
addKeymap:
|
|
891
|
+
codeLanguages: r,
|
|
892
|
+
addKeymap: i,
|
|
846
893
|
base: a,
|
|
847
894
|
completeHTMLTags: c,
|
|
848
|
-
htmlTagLanguage:
|
|
849
|
-
extensions:
|
|
895
|
+
htmlTagLanguage: n,
|
|
896
|
+
extensions: s = []
|
|
850
897
|
} = {}
|
|
851
898
|
// theme
|
|
852
|
-
} = e ?? {},
|
|
899
|
+
} = e ?? {}, o = {
|
|
853
900
|
defaultCodeLanguage: t,
|
|
854
|
-
codeLanguages:
|
|
855
|
-
addKeymap:
|
|
901
|
+
codeLanguages: r || V,
|
|
902
|
+
addKeymap: i,
|
|
856
903
|
base: a,
|
|
857
904
|
completeHTMLTags: c,
|
|
858
|
-
htmlTagLanguage:
|
|
859
|
-
extensions: [...
|
|
905
|
+
htmlTagLanguage: n,
|
|
906
|
+
extensions: [...s, F, J, Ie]
|
|
860
907
|
};
|
|
861
908
|
return [
|
|
862
|
-
|
|
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
|
-
|
|
932
|
+
Ie as QuoteType,
|
|
886
933
|
ct as gnosis
|
|
887
934
|
};
|