@bendyline/squisq-editor-react 2.11.0 → 2.11.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-TCLNRATG.js → chunk-A2W4GYPG.js} +48 -2
- package/dist/{chunk-FT5F2EGI.js → chunk-QIQNP2GI.js} +465 -128
- package/dist/{chunk-JYPLPGYJ.js → chunk-SK3MQSHQ.js} +1 -1
- package/dist/index.d.ts +16 -3
- package/dist/index.js +3 -3
- package/dist/json-editor/index.js +2 -2
- package/dist/shell/index.d.ts +2 -2
- package/dist/shell/index.js +2 -2
- package/dist/{shell-DInMVUpf.d.ts → shell-CJkHDwpz.d.ts} +14 -2
- package/dist/styles/index.css +63 -8
- package/package.json +6 -6
|
@@ -15,6 +15,8 @@ var RE_LEGACY_ITALIC_STAR = /(?<!\*)\*(?![\s*])(.+?)(?<![\s*])([ \t]+)\*(?=$|[^\
|
|
|
15
15
|
var ESCAPABLE_MD_CHARS = ["*", "_", "~", "\\"];
|
|
16
16
|
var RE_MD_ESCAPE = /\\([*_~\\])/g;
|
|
17
17
|
var RE_INLINE_CODE = /`(.+?)`/g;
|
|
18
|
+
var BACKTICK = "`";
|
|
19
|
+
var FENCE = "```";
|
|
18
20
|
var RE_IMAGE = /!\[(.*?)\]\((.+?)\)/g;
|
|
19
21
|
var RE_MENTION = /@\[([^\]]+?)\]\(([a-z][a-z0-9+.-]*)\\?:([^)\s]+)\)/gi;
|
|
20
22
|
var RE_MENTION_TAG = /<span\b[^>]*?\bdata-mention\b[^>]*?>(?:<[^>]+>)*([^<]*)<\/span>/gi;
|
|
@@ -26,10 +28,50 @@ var RE_VERT_ALIGN_TAG = /<(sup|sub)>((?:(?!<\/?(?:sup|sub)>)[\s\S])*)<\/\1>/gi;
|
|
|
26
28
|
var RE_A_TAG = /<a\b([^>]*)>(.*?)<\/a>/g;
|
|
27
29
|
var RE_IMG_TAG = /<img\b([^>]*)>/g;
|
|
28
30
|
var RE_STRIP_TAGS = /<[^>]+>/g;
|
|
31
|
+
function joinWrappedCodeSpans(lines) {
|
|
32
|
+
if (!lines.some((line) => line.includes(BACKTICK))) return lines;
|
|
33
|
+
const joined = [];
|
|
34
|
+
let inFence = false;
|
|
35
|
+
for (let i = 0; i < lines.length; i++) {
|
|
36
|
+
const line = lines[i];
|
|
37
|
+
if (line.startsWith(FENCE)) {
|
|
38
|
+
inFence = !inFence;
|
|
39
|
+
joined.push(line);
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
if (inFence || !leavesCodeSpanOpen(line)) {
|
|
43
|
+
joined.push(line);
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
let merged = line;
|
|
47
|
+
let next = i + 1;
|
|
48
|
+
let closed = false;
|
|
49
|
+
while (next < lines.length) {
|
|
50
|
+
const candidate = lines[next];
|
|
51
|
+
if (candidate.trim() === "" || candidate.startsWith(FENCE)) break;
|
|
52
|
+
merged = `${merged} ${candidate.replace(/^[ \t]+/, "")}`;
|
|
53
|
+
next++;
|
|
54
|
+
if (!leavesCodeSpanOpen(merged)) {
|
|
55
|
+
closed = true;
|
|
56
|
+
break;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
if (!closed) {
|
|
60
|
+
joined.push(line);
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
joined.push(merged);
|
|
64
|
+
i = next - 1;
|
|
65
|
+
}
|
|
66
|
+
return joined;
|
|
67
|
+
}
|
|
68
|
+
function leavesCodeSpanOpen(text) {
|
|
69
|
+
return text.replace(RE_INLINE_CODE, "").includes(BACKTICK);
|
|
70
|
+
}
|
|
29
71
|
function markdownToTiptap(markdown) {
|
|
30
72
|
if (!markdown.trim()) return "<p></p>";
|
|
31
73
|
const html = markdown.replace(/\r\n/g, "\n").replace(/\r/g, "\n");
|
|
32
|
-
const lines = html.split("\n");
|
|
74
|
+
const lines = joinWrappedCodeSpans(html.split("\n"));
|
|
33
75
|
const frontmatterEnd = findFrontmatterEnd(lines);
|
|
34
76
|
const outputBlocks = [];
|
|
35
77
|
let inCodeBlock = false;
|
|
@@ -403,7 +445,7 @@ function tiptapToMarkdown(html) {
|
|
|
403
445
|
while ((cellExec = cellRegex.exec(rowHtml)) !== null) {
|
|
404
446
|
const tag = cellExec[1];
|
|
405
447
|
const attrs = cellExec[2];
|
|
406
|
-
const content =
|
|
448
|
+
const content = htmlToTableCell(cellExec[3].replace(/<\/?p>/g, ""));
|
|
407
449
|
const alignExec = attrs.match(/text-align:\s*(left|center|right)/);
|
|
408
450
|
cells.push({
|
|
409
451
|
content,
|
|
@@ -789,6 +831,7 @@ function inlineToHtml(text) {
|
|
|
789
831
|
const name = tag.toLowerCase();
|
|
790
832
|
return stash(`<${name}>${inlineToHtml(inner)}</${name}>`);
|
|
791
833
|
});
|
|
834
|
+
staged = staged.replace(/<br\s*\/?>/gi, () => stash("<br>"));
|
|
792
835
|
staged = staged.replace(
|
|
793
836
|
RE_IMAGE,
|
|
794
837
|
(_m, alt, src) => stash(`<img alt="${escapeHtml(alt)}" src="${escapeHtml(src)}">`)
|
|
@@ -1031,6 +1074,9 @@ function htmlToInline(html) {
|
|
|
1031
1074
|
result = vault.restore(result);
|
|
1032
1075
|
return restoreLeadingSpaces(unescapeHtml(result));
|
|
1033
1076
|
}
|
|
1077
|
+
function htmlToTableCell(html) {
|
|
1078
|
+
return htmlToInline(html).replace(/ {2}\n/g, "<br>");
|
|
1079
|
+
}
|
|
1034
1080
|
function preserveLeadingSpaces(html) {
|
|
1035
1081
|
return html.replace(/^ +/, (spaces) => " ".repeat(spaces.length));
|
|
1036
1082
|
}
|