@latentic/live-markdown 0.0.1 → 0.1.1
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/CHANGELOG.md +58 -0
- package/README.md +71 -5
- package/dist/index.d.ts +53 -3
- package/dist/index.js +193 -63
- package/dist/index.js.map +1 -1
- package/dist/styles.css +7 -2
- package/package.json +43 -17
package/dist/index.js
CHANGED
|
@@ -356,7 +356,7 @@ var verbatimPasteKeymap = keymap.of([
|
|
|
356
356
|
}
|
|
357
357
|
]);
|
|
358
358
|
var markdownPaste = [pasteHandler, verbatimPasteKeymap];
|
|
359
|
-
var PARSE_BUDGET_MS =
|
|
359
|
+
var PARSE_BUDGET_MS = 150;
|
|
360
360
|
function treeAt(state, pos) {
|
|
361
361
|
return ensureSyntaxTree(state, pos + 1, PARSE_BUDGET_MS) ?? syntaxTree(state);
|
|
362
362
|
}
|
|
@@ -1514,6 +1514,38 @@ var nodeRulesFacet = Facet.define({
|
|
|
1514
1514
|
return Object.assign({}, ...values);
|
|
1515
1515
|
}
|
|
1516
1516
|
});
|
|
1517
|
+
var inlineScanRulesFacet = Facet.define({
|
|
1518
|
+
combine: (values) => values
|
|
1519
|
+
});
|
|
1520
|
+
function scanInline(rules, text, at = 0) {
|
|
1521
|
+
const found = [];
|
|
1522
|
+
for (const rule of rules) {
|
|
1523
|
+
rule.pattern.lastIndex = 0;
|
|
1524
|
+
let match;
|
|
1525
|
+
while ((match = rule.pattern.exec(text)) !== null) {
|
|
1526
|
+
found.push({
|
|
1527
|
+
from: at + match.index,
|
|
1528
|
+
to: at + match.index + match[0].length,
|
|
1529
|
+
html: rule.render(match)
|
|
1530
|
+
});
|
|
1531
|
+
}
|
|
1532
|
+
}
|
|
1533
|
+
found.sort((a, b) => a.from - b.from || b.to - a.to);
|
|
1534
|
+
const kept = [];
|
|
1535
|
+
for (const span of found) {
|
|
1536
|
+
const last = kept[kept.length - 1];
|
|
1537
|
+
if (!last || span.from >= last.to) kept.push(span);
|
|
1538
|
+
}
|
|
1539
|
+
return kept;
|
|
1540
|
+
}
|
|
1541
|
+
|
|
1542
|
+
// src/codemirror/core/htmlEscape.ts
|
|
1543
|
+
function escapeText(value) {
|
|
1544
|
+
return value.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
1545
|
+
}
|
|
1546
|
+
function escapeAttr(value) {
|
|
1547
|
+
return escapeText(value).replace(/"/g, """);
|
|
1548
|
+
}
|
|
1517
1549
|
var SLICE_MS = 10;
|
|
1518
1550
|
var GAP_MS = 25;
|
|
1519
1551
|
var parseToEnd = ViewPlugin.fromClass(
|
|
@@ -1955,6 +1987,73 @@ var imageRule = (ctx) => {
|
|
|
1955
1987
|
})
|
|
1956
1988
|
};
|
|
1957
1989
|
};
|
|
1990
|
+
var CODE_NODES = /* @__PURE__ */ new Set(["FencedCode", "CodeBlock", "InlineCode"]);
|
|
1991
|
+
function viewportTree(view) {
|
|
1992
|
+
return ensureSyntaxTree(view.state, view.viewport.to, 100) ?? syntaxTree(view.state);
|
|
1993
|
+
}
|
|
1994
|
+
function docTree(state) {
|
|
1995
|
+
return ensureSyntaxTree(state, state.doc.length, 20) ?? syntaxTree(state);
|
|
1996
|
+
}
|
|
1997
|
+
function inCode(tree, pos) {
|
|
1998
|
+
let node = tree.resolveInner(pos, 1);
|
|
1999
|
+
for (; node; node = node.parent) {
|
|
2000
|
+
if (CODE_NODES.has(node.name)) return true;
|
|
2001
|
+
}
|
|
2002
|
+
return false;
|
|
2003
|
+
}
|
|
2004
|
+
|
|
2005
|
+
// src/codemirror/core/linkResolution.ts
|
|
2006
|
+
var DEFINITION_CONTAINERS = /* @__PURE__ */ new Set([
|
|
2007
|
+
"Document",
|
|
2008
|
+
"Blockquote",
|
|
2009
|
+
"BulletList",
|
|
2010
|
+
"OrderedList",
|
|
2011
|
+
"ListItem"
|
|
2012
|
+
]);
|
|
2013
|
+
function normalizeLabel(label) {
|
|
2014
|
+
return label.trim().replace(/\s+/g, " ").toLowerCase();
|
|
2015
|
+
}
|
|
2016
|
+
function labelInner(state, label) {
|
|
2017
|
+
return state.sliceDoc(label.from + 1, label.to - 1);
|
|
2018
|
+
}
|
|
2019
|
+
var definedLabels = /* @__PURE__ */ new WeakMap();
|
|
2020
|
+
function definitions(state) {
|
|
2021
|
+
const cached = definedLabels.get(state);
|
|
2022
|
+
if (cached) return cached;
|
|
2023
|
+
const labels = /* @__PURE__ */ new Set();
|
|
2024
|
+
docTree(state).iterate({
|
|
2025
|
+
enter: (node) => {
|
|
2026
|
+
if (node.name !== "LinkReference") return DEFINITION_CONTAINERS.has(node.name);
|
|
2027
|
+
const label = node.node.getChild("LinkLabel");
|
|
2028
|
+
if (label) labels.add(normalizeLabel(labelInner(state, label)));
|
|
2029
|
+
return false;
|
|
2030
|
+
}
|
|
2031
|
+
});
|
|
2032
|
+
definedLabels.set(state, labels);
|
|
2033
|
+
return labels;
|
|
2034
|
+
}
|
|
2035
|
+
function ownLabel(state, link) {
|
|
2036
|
+
let open = null;
|
|
2037
|
+
let close = null;
|
|
2038
|
+
for (let child = link.firstChild; child; child = child.nextSibling) {
|
|
2039
|
+
if (child.name !== "LinkMark") continue;
|
|
2040
|
+
const mark2 = state.sliceDoc(child.from, child.to);
|
|
2041
|
+
if (mark2 === "[" && !open) open = child;
|
|
2042
|
+
else if (mark2 === "]" && !close) close = child;
|
|
2043
|
+
}
|
|
2044
|
+
if (!open || !close || close.from <= open.to) return null;
|
|
2045
|
+
return state.sliceDoc(open.to, close.from);
|
|
2046
|
+
}
|
|
2047
|
+
function linkResolves(link, state) {
|
|
2048
|
+
if (link.getChild("URL")) return true;
|
|
2049
|
+
const reference = link.getChild("LinkLabel");
|
|
2050
|
+
const explicit = reference ? labelInner(state, reference) : "";
|
|
2051
|
+
const key = explicit.trim() === "" ? ownLabel(state, link) ?? "" : explicit;
|
|
2052
|
+
return key.trim() !== "" && definitions(state).has(normalizeLabel(key));
|
|
2053
|
+
}
|
|
2054
|
+
function linkHasVisibleLabel(link, state) {
|
|
2055
|
+
return (ownLabel(state, link) ?? "").trim() !== "";
|
|
2056
|
+
}
|
|
1958
2057
|
var BulletWidget = class extends WidgetType {
|
|
1959
2058
|
/**
|
|
1960
2059
|
* Eq returns true if two widgets are interchangeable — when CM6
|
|
@@ -2068,19 +2167,8 @@ var taskMarkerRule = (ctx) => {
|
|
|
2068
2167
|
};
|
|
2069
2168
|
|
|
2070
2169
|
// src/codemirror/core/registry.ts
|
|
2071
|
-
function
|
|
2072
|
-
|
|
2073
|
-
if (!link) return false;
|
|
2074
|
-
let bracketOpen = null;
|
|
2075
|
-
let bracketClose = null;
|
|
2076
|
-
for (let child = link.firstChild; child; child = child.nextSibling) {
|
|
2077
|
-
if (child.name !== "LinkMark") continue;
|
|
2078
|
-
const mark2 = ctx.state.sliceDoc(child.from, child.to);
|
|
2079
|
-
if (mark2 === "[" && !bracketOpen) bracketOpen = child;
|
|
2080
|
-
else if (mark2 === "]" && !bracketClose) bracketClose = child;
|
|
2081
|
-
}
|
|
2082
|
-
if (!bracketOpen || !bracketClose || bracketClose.from <= bracketOpen.to) return false;
|
|
2083
|
-
return ctx.state.sliceDoc(bracketOpen.to, bracketClose.from).trim() !== "";
|
|
2170
|
+
function parentLink(ctx) {
|
|
2171
|
+
return ctx.parentName === "Link" ? ctx.node.parent : null;
|
|
2084
2172
|
}
|
|
2085
2173
|
var NODE_RULES = {
|
|
2086
2174
|
// ----- Structural wrappers (never directly styled) -----
|
|
@@ -2111,7 +2199,11 @@ var NODE_RULES = {
|
|
|
2111
2199
|
Emphasis: mark("cm-emphasis"),
|
|
2112
2200
|
StrongEmphasis: mark("cm-strong"),
|
|
2113
2201
|
InlineCode: mark("cm-inline-code"),
|
|
2114
|
-
Link:
|
|
2202
|
+
// A `Link` node is not yet a link: Lezer emits one for every `[…]`, and the
|
|
2203
|
+
// reference lookup CommonMark requires is left to us. Unresolved, it is the
|
|
2204
|
+
// literal brackets the author typed — most `[…]` in prose, and every optional
|
|
2205
|
+
// argument in a LaTeX block.
|
|
2206
|
+
Link: (ctx) => linkResolves(ctx.node, ctx.state) ? { paint: "mark", className: "cm-link" } : none,
|
|
2115
2207
|
Image: imageRule,
|
|
2116
2208
|
// `` → inline `<img>` widget
|
|
2117
2209
|
// ----- Inline literal sub-nodes (rendered inside their parent) -----
|
|
@@ -2121,8 +2213,9 @@ var NODE_RULES = {
|
|
|
2121
2213
|
// Bare GFM autolinks and <angle> autolinks emit the SAME node name, and
|
|
2122
2214
|
// there the URL IS the content — same class of bug when hidden.
|
|
2123
2215
|
URL: (ctx) => {
|
|
2124
|
-
|
|
2125
|
-
|
|
2216
|
+
const link = parentLink(ctx);
|
|
2217
|
+
if (!link) return { paint: "mark", className: "cm-link" };
|
|
2218
|
+
return linkHasVisibleLabel(link, ctx.state) ? { paint: "hide" } : { paint: "mark", className: "cm-link" };
|
|
2126
2219
|
},
|
|
2127
2220
|
LinkLabel: raw("visible inside Link; parent mark styles it"),
|
|
2128
2221
|
LinkTitle: hideAlways(),
|
|
@@ -2153,8 +2246,12 @@ var NODE_RULES = {
|
|
|
2153
2246
|
// `*` / `_`
|
|
2154
2247
|
CodeMark: hideAlways(),
|
|
2155
2248
|
// backticks for inline / fence pairs for blocks
|
|
2156
|
-
|
|
2157
|
-
//
|
|
2249
|
+
// `[`/`]`/`(`/`)` — chrome only where they really are chrome. An unresolved
|
|
2250
|
+
// link's brackets are content, and hiding them rewrote the document on screen.
|
|
2251
|
+
LinkMark: (ctx) => {
|
|
2252
|
+
const link = parentLink(ctx);
|
|
2253
|
+
return link && !linkResolves(link, ctx.state) ? none : { paint: "hide" };
|
|
2254
|
+
},
|
|
2158
2255
|
QuoteMark: hideAlways(),
|
|
2159
2256
|
// `>`
|
|
2160
2257
|
ListMark: listMarkRule,
|
|
@@ -2902,20 +2999,6 @@ function slugKey(value) {
|
|
|
2902
2999
|
}
|
|
2903
3000
|
return raw2.split("-").filter(Boolean).join("-");
|
|
2904
3001
|
}
|
|
2905
|
-
var CODE_NODES = /* @__PURE__ */ new Set(["FencedCode", "CodeBlock", "InlineCode"]);
|
|
2906
|
-
function viewportTree(view) {
|
|
2907
|
-
return ensureSyntaxTree(view.state, view.viewport.to, 100) ?? syntaxTree(view.state);
|
|
2908
|
-
}
|
|
2909
|
-
function docTree(state) {
|
|
2910
|
-
return ensureSyntaxTree(state, state.doc.length, 20) ?? syntaxTree(state);
|
|
2911
|
-
}
|
|
2912
|
-
function inCode(tree, pos) {
|
|
2913
|
-
let node = tree.resolveInner(pos, 1);
|
|
2914
|
-
for (; node; node = node.parent) {
|
|
2915
|
-
if (CODE_NODES.has(node.name)) return true;
|
|
2916
|
-
}
|
|
2917
|
-
return false;
|
|
2918
|
-
}
|
|
2919
3002
|
var WIKILINK_RE = /\[\[([^\]\n]+?)\]\]/g;
|
|
2920
3003
|
var HIDE = Decoration.replace({});
|
|
2921
3004
|
var linkMark = Decoration.mark({ class: "cm-wikilink" });
|
|
@@ -3073,12 +3156,6 @@ var clickModel = EditorView.domEventHandlers({
|
|
|
3073
3156
|
});
|
|
3074
3157
|
|
|
3075
3158
|
// src/codemirror/table/tableInline.ts
|
|
3076
|
-
function escapeText(value) {
|
|
3077
|
-
return value.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
3078
|
-
}
|
|
3079
|
-
function escapeAttr(value) {
|
|
3080
|
-
return escapeText(value).replace(/"/g, """);
|
|
3081
|
-
}
|
|
3082
3159
|
function codeText(state, node) {
|
|
3083
3160
|
let innerFrom = node.from;
|
|
3084
3161
|
let innerTo = node.to;
|
|
@@ -3154,8 +3231,26 @@ function renderRange(state, parent, from, to) {
|
|
|
3154
3231
|
if (pos < to) html += state.sliceDoc(pos, to);
|
|
3155
3232
|
return html;
|
|
3156
3233
|
}
|
|
3234
|
+
function straddlesChild(cell, from, to) {
|
|
3235
|
+
for (let child = cell.firstChild; child; child = child.nextSibling) {
|
|
3236
|
+
if (child.from < from && child.to > from) return true;
|
|
3237
|
+
if (child.from < to && child.to > to) return true;
|
|
3238
|
+
}
|
|
3239
|
+
return false;
|
|
3240
|
+
}
|
|
3157
3241
|
function renderInlineCell(state, cell) {
|
|
3158
|
-
|
|
3242
|
+
const rules = state.facet(inlineScanRulesFacet);
|
|
3243
|
+
const tree = docTree(state);
|
|
3244
|
+
let html = "";
|
|
3245
|
+
let pos = cell.from;
|
|
3246
|
+
for (const span of scanInline(rules, state.sliceDoc(cell.from, cell.to), cell.from)) {
|
|
3247
|
+
if (span.from < pos) continue;
|
|
3248
|
+
if (inCode(tree, span.from) || inCode(tree, span.to - 1)) continue;
|
|
3249
|
+
if (straddlesChild(cell, span.from, span.to)) continue;
|
|
3250
|
+
html += renderRange(state, cell, pos, span.from) + span.html;
|
|
3251
|
+
pos = span.to;
|
|
3252
|
+
}
|
|
3253
|
+
return (html + renderRange(state, cell, pos, cell.to)).trim();
|
|
3159
3254
|
}
|
|
3160
3255
|
|
|
3161
3256
|
// src/codemirror/table/tableModel.ts
|
|
@@ -3256,8 +3351,9 @@ var CELL_SANITIZE_CONFIG = {
|
|
|
3256
3351
|
ALLOWED_ATTR: ["href", "class"],
|
|
3257
3352
|
RETURN_TRUSTED_TYPE: false
|
|
3258
3353
|
};
|
|
3259
|
-
function renderCellInto(el, source) {
|
|
3354
|
+
function renderCellInto(el, source, rules) {
|
|
3260
3355
|
el.innerHTML = DOMPurify.sanitize(source, CELL_SANITIZE_CONFIG);
|
|
3356
|
+
for (const rule of rules) rule.hydrate?.(el);
|
|
3261
3357
|
}
|
|
3262
3358
|
function tableV2Sync(surface) {
|
|
3263
3359
|
return EditorView.updateListener.of((update) => {
|
|
@@ -3268,8 +3364,8 @@ function tableV2Sync(surface) {
|
|
|
3268
3364
|
}
|
|
3269
3365
|
|
|
3270
3366
|
// src/codemirror/tablev2/tableWidgetV2.ts
|
|
3271
|
-
function fillCell(el, cell, row, col) {
|
|
3272
|
-
renderCellInto(el, cell.html);
|
|
3367
|
+
function fillCell(el, cell, row, col, rules) {
|
|
3368
|
+
renderCellInto(el, cell.html, rules);
|
|
3273
3369
|
el.dataset.row = String(row);
|
|
3274
3370
|
el.dataset.col = String(col);
|
|
3275
3371
|
el.dataset.cellFrom = String(cell.from);
|
|
@@ -3297,7 +3393,8 @@ var TableWidgetV2 = class extends WidgetType {
|
|
|
3297
3393
|
eq(other) {
|
|
3298
3394
|
return other.sourceFrom === this.sourceFrom && other.sourceTo === this.sourceTo && JSON.stringify(other.data) === JSON.stringify(this.data);
|
|
3299
3395
|
}
|
|
3300
|
-
toDOM() {
|
|
3396
|
+
toDOM(view) {
|
|
3397
|
+
const rules = view.state.facet(inlineScanRulesFacet);
|
|
3301
3398
|
const wrap = document.createElement("div");
|
|
3302
3399
|
wrap.className = "cm-tablev2-wrap cm-table-wrap";
|
|
3303
3400
|
wrap.dataset.tablev2From = String(this.sourceFrom);
|
|
@@ -3308,7 +3405,7 @@ var TableWidgetV2 = class extends WidgetType {
|
|
|
3308
3405
|
const headRow = document.createElement("tr");
|
|
3309
3406
|
this.data.header.forEach((cell, col) => {
|
|
3310
3407
|
const th = document.createElement("th");
|
|
3311
|
-
fillCell(th, cell, 0, col);
|
|
3408
|
+
fillCell(th, cell, 0, col, rules);
|
|
3312
3409
|
const align = this.data.alignments[col];
|
|
3313
3410
|
if (align) th.style.textAlign = align;
|
|
3314
3411
|
headRow.appendChild(th);
|
|
@@ -3320,7 +3417,7 @@ var TableWidgetV2 = class extends WidgetType {
|
|
|
3320
3417
|
const tr = document.createElement("tr");
|
|
3321
3418
|
cells2.forEach((cell, col) => {
|
|
3322
3419
|
const td = document.createElement("td");
|
|
3323
|
-
fillCell(td, cell, r + 1, col);
|
|
3420
|
+
fillCell(td, cell, r + 1, col, rules);
|
|
3324
3421
|
const align = this.data.alignments[col];
|
|
3325
3422
|
if (align) td.style.textAlign = align;
|
|
3326
3423
|
tr.appendChild(td);
|
|
@@ -3331,7 +3428,8 @@ var TableWidgetV2 = class extends WidgetType {
|
|
|
3331
3428
|
wrap.appendChild(table);
|
|
3332
3429
|
return wrap;
|
|
3333
3430
|
}
|
|
3334
|
-
updateDOM(dom) {
|
|
3431
|
+
updateDOM(dom, view) {
|
|
3432
|
+
const rules = view.state.facet(inlineScanRulesFacet);
|
|
3335
3433
|
if (dom.dataset.tablev2From === void 0) return false;
|
|
3336
3434
|
const rows = dom.querySelectorAll("tr");
|
|
3337
3435
|
if (rows.length !== 1 + this.data.rows.length) return false;
|
|
@@ -3345,7 +3443,7 @@ var TableWidgetV2 = class extends WidgetType {
|
|
|
3345
3443
|
for (let r = 0; r < grid.length; r++) {
|
|
3346
3444
|
const cells2 = rows[r].children;
|
|
3347
3445
|
grid[r].forEach((cell, col) => {
|
|
3348
|
-
fillCell(cells2[col], cell, r, col);
|
|
3446
|
+
fillCell(cells2[col], cell, r, col, rules);
|
|
3349
3447
|
});
|
|
3350
3448
|
}
|
|
3351
3449
|
return true;
|
|
@@ -4293,12 +4391,19 @@ var highlightPlugin = ViewPlugin.fromClass(
|
|
|
4293
4391
|
}
|
|
4294
4392
|
);
|
|
4295
4393
|
|
|
4394
|
+
// src/codemirror/highlight/highlightScanRule.ts
|
|
4395
|
+
var highlightScanRule = {
|
|
4396
|
+
name: "highlight",
|
|
4397
|
+
pattern: HIGHLIGHT_RE,
|
|
4398
|
+
render: (match) => `<span class="cm-highlight">${escapeText(match[1] ?? "")}</span>`
|
|
4399
|
+
};
|
|
4400
|
+
|
|
4296
4401
|
// src/codemirror/extensions/highlightExtension.ts
|
|
4297
4402
|
var highlightExtension = {
|
|
4298
4403
|
name: "@compose/highlight",
|
|
4299
4404
|
version: "0.1.0",
|
|
4300
4405
|
description: "Renders `==text==` with a yellow highlight background.",
|
|
4301
|
-
extensions: [highlightPlugin]
|
|
4406
|
+
extensions: [highlightPlugin, inlineScanRulesFacet.of(highlightScanRule)]
|
|
4302
4407
|
};
|
|
4303
4408
|
var FOOTNOTE_REF_RE = /(?<!\])\[\^([^\]\s]+)\](?!:)/g;
|
|
4304
4409
|
var FOOTNOTE_DEF_LINE_RE = /^\[\^([^\]\s]+)\]:\s/;
|
|
@@ -4365,13 +4470,27 @@ var footnotePlugin = ViewPlugin.fromClass(
|
|
|
4365
4470
|
}
|
|
4366
4471
|
);
|
|
4367
4472
|
|
|
4473
|
+
// src/codemirror/footnote/footnoteScanRule.ts
|
|
4474
|
+
var footnoteScanRule = {
|
|
4475
|
+
name: "footnote",
|
|
4476
|
+
pattern: FOOTNOTE_REF_RE,
|
|
4477
|
+
render: (match) => `<span class="cm-footnote-ref">${escapeText(match[1] ?? "")}</span>`
|
|
4478
|
+
};
|
|
4479
|
+
|
|
4368
4480
|
// src/codemirror/extensions/footnoteExtension.ts
|
|
4369
4481
|
var footnoteExtension = {
|
|
4370
4482
|
name: "@compose/footnote",
|
|
4371
4483
|
version: "0.1.0",
|
|
4372
4484
|
description: "Renders `[^id]` references and `[^id]:` definitions with tooltip jump.",
|
|
4373
|
-
extensions: [footnotePlugin]
|
|
4485
|
+
extensions: [footnotePlugin, inlineScanRulesFacet.of(footnoteScanRule)]
|
|
4374
4486
|
};
|
|
4487
|
+
function renderMathInto(el, tex, displayMode) {
|
|
4488
|
+
try {
|
|
4489
|
+
katex.render(tex, el, { displayMode, throwOnError: false, output: "html" });
|
|
4490
|
+
} catch {
|
|
4491
|
+
el.textContent = tex;
|
|
4492
|
+
}
|
|
4493
|
+
}
|
|
4375
4494
|
var MathWidget = class extends WidgetType {
|
|
4376
4495
|
constructor(tex, displayMode) {
|
|
4377
4496
|
super();
|
|
@@ -4384,15 +4503,7 @@ var MathWidget = class extends WidgetType {
|
|
|
4384
4503
|
toDOM(_view) {
|
|
4385
4504
|
const span = document.createElement(this.displayMode ? "div" : "span");
|
|
4386
4505
|
span.className = this.displayMode ? "cm-math-block" : "cm-math-inline";
|
|
4387
|
-
|
|
4388
|
-
katex.render(this.tex, span, {
|
|
4389
|
-
displayMode: this.displayMode,
|
|
4390
|
-
throwOnError: false,
|
|
4391
|
-
output: "html"
|
|
4392
|
-
});
|
|
4393
|
-
} catch {
|
|
4394
|
-
span.textContent = this.tex;
|
|
4395
|
-
}
|
|
4506
|
+
renderMathInto(span, this.tex, this.displayMode);
|
|
4396
4507
|
return span;
|
|
4397
4508
|
}
|
|
4398
4509
|
ignoreEvent() {
|
|
@@ -4465,12 +4576,24 @@ var mathPlugin = StateField.define({
|
|
|
4465
4576
|
]
|
|
4466
4577
|
});
|
|
4467
4578
|
|
|
4579
|
+
// src/codemirror/math/mathScanRule.ts
|
|
4580
|
+
var mathScanRule = {
|
|
4581
|
+
name: "math",
|
|
4582
|
+
pattern: INLINE_MATH_RE,
|
|
4583
|
+
render: (match) => `<span class="cm-math-inline">${escapeText(match[1] ?? "")}</span>`,
|
|
4584
|
+
hydrate: (root) => {
|
|
4585
|
+
for (const el of root.querySelectorAll(".cm-math-inline")) {
|
|
4586
|
+
renderMathInto(el, el.textContent ?? "", false);
|
|
4587
|
+
}
|
|
4588
|
+
}
|
|
4589
|
+
};
|
|
4590
|
+
|
|
4468
4591
|
// src/codemirror/extensions/mathExtension.ts
|
|
4469
4592
|
var mathExtension = {
|
|
4470
4593
|
name: "@compose/math",
|
|
4471
4594
|
version: "0.1.0",
|
|
4472
4595
|
description: "Renders `$x$` inline and `$$x$$` block math via KaTeX.",
|
|
4473
|
-
extensions: [mathPlugin]
|
|
4596
|
+
extensions: [mathPlugin, inlineScanRulesFacet.of(mathScanRule)]
|
|
4474
4597
|
};
|
|
4475
4598
|
|
|
4476
4599
|
// src/codemirror/extensions/mermaidExtension.ts
|
|
@@ -4778,7 +4901,7 @@ var InlineCellSurface = class {
|
|
|
4778
4901
|
}
|
|
4779
4902
|
const model = modelAt(view.state, s.tableFrom);
|
|
4780
4903
|
const cell = model ? cellAt(model, s.ref.row, s.ref.col) : null;
|
|
4781
|
-
if (cell) renderCellInto(s.el, cell.html);
|
|
4904
|
+
if (cell) renderCellInto(s.el, cell.html, view.state.facet(inlineScanRulesFacet));
|
|
4782
4905
|
}
|
|
4783
4906
|
cancel() {
|
|
4784
4907
|
const s = this.edit;
|
|
@@ -5385,12 +5508,19 @@ function tableExtension() {
|
|
|
5385
5508
|
};
|
|
5386
5509
|
}
|
|
5387
5510
|
|
|
5511
|
+
// src/codemirror/wikilink/wikilinkScanRule.ts
|
|
5512
|
+
var wikilinkScanRule = {
|
|
5513
|
+
name: "wikilink",
|
|
5514
|
+
pattern: WIKILINK_RE,
|
|
5515
|
+
render: (match) => `<span class="cm-wikilink">${escapeText(parseWikilinkBody(match[1] ?? "").label)}</span>`
|
|
5516
|
+
};
|
|
5517
|
+
|
|
5388
5518
|
// src/codemirror/extensions/wikilinkExtension.ts
|
|
5389
5519
|
var wikilinkExtension = {
|
|
5390
5520
|
name: "@compose/wikilink",
|
|
5391
5521
|
version: "0.1.0",
|
|
5392
5522
|
description: "Renders `[[target]]` / `[[target|alias]]` as clickable links.",
|
|
5393
|
-
extensions: [wikilinkPlugin]
|
|
5523
|
+
extensions: [wikilinkPlugin, inlineScanRulesFacet.of(wikilinkScanRule)]
|
|
5394
5524
|
};
|
|
5395
5525
|
var programmaticSwap = Annotation.define();
|
|
5396
5526
|
var AUTOSAVE_DEBOUNCE_MS = 500;
|
|
@@ -5799,6 +5929,6 @@ function CodeMirrorMarkdownEditorInner({
|
|
|
5799
5929
|
}
|
|
5800
5930
|
var CodeMirrorMarkdownEditor = memo(CodeMirrorMarkdownEditorInner);
|
|
5801
5931
|
|
|
5802
|
-
export { CodeMirrorMarkdownEditor, IMAGE_EDIT_ALT_EVENT, blockCommands, buildImageMarkdown, composeExtensions, computeFileDir, defaultResolveImageSrc, dirnamePath, editorBaseTheme, extractImageBlobs, extractImageFiles, footnoteExtension, formatCommands, getCachedMermaidPng, hasUriScheme, headingLine, hideAlways, highlightExtension, highlightFenceSpans, imageInsertHandlers, insertImageBlob, isAbsolutePath, isMermaidFenceInfo, joinPath, line, mark, markdownDecorationsPlugin, mathExtension, mermaidExtension, nodeRulesFacet, onEditorUpdate, parseFrontmatter, parseWikilinkBody, pickImageFileForCaret, raw, renderMermaidToSvg, resolveWikilinkTarget, resolveWorkspaceLink, serializeMarkdown, setFrontmatterField, showImageActionMenu, structural, tableExtension, treeAt, warmMermaidPng, wikilinkExtension };
|
|
5932
|
+
export { CodeMirrorMarkdownEditor, IMAGE_EDIT_ALT_EVENT, blockCommands, buildImageMarkdown, composeExtensions, computeFileDir, defaultResolveImageSrc, dirnamePath, editorBaseTheme, escapeAttr, escapeText, extractImageBlobs, extractImageFiles, footnoteExtension, formatCommands, getCachedMermaidPng, hasUriScheme, headingLine, hideAlways, highlightExtension, highlightFenceSpans, imageInsertHandlers, inlineScanRulesFacet, insertImageBlob, isAbsolutePath, isMermaidFenceInfo, joinPath, line, mark, markdownDecorationsPlugin, mathExtension, mermaidExtension, nodeRulesFacet, onEditorUpdate, parseFrontmatter, parseWikilinkBody, pickImageFileForCaret, raw, renderMermaidToSvg, resolveWikilinkTarget, resolveWorkspaceLink, scanInline, serializeMarkdown, setFrontmatterField, showImageActionMenu, structural, tableExtension, treeAt, warmMermaidPng, wikilinkExtension };
|
|
5803
5933
|
//# sourceMappingURL=index.js.map
|
|
5804
5934
|
//# sourceMappingURL=index.js.map
|