themed-markdown 0.1.92 → 0.1.94
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/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +724 -150
- package/dist/industryMarkdown/components/IndustryMarkdownComponents.d.ts +16 -12
- package/dist/industryMarkdown/components/IndustryMarkdownComponents.d.ts.map +1 -1
- package/dist/industryMarkdown/components/IndustryMarkdownSlide.d.ts +34 -0
- package/dist/industryMarkdown/components/IndustryMarkdownSlide.d.ts.map +1 -1
- package/dist/industryMarkdown/utils/blockDeletion.d.ts +57 -0
- package/dist/industryMarkdown/utils/blockDeletion.d.ts.map +1 -0
- package/dist/industryMarkdown/utils/rehypeSourcePositions.d.ts +45 -0
- package/dist/industryMarkdown/utils/rehypeSourcePositions.d.ts.map +1 -0
- package/dist/industryMarkdown/utils/useBlockSelection.d.ts +50 -0
- package/dist/industryMarkdown/utils/useBlockSelection.d.ts.map +1 -0
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1053,7 +1053,8 @@ function resetFontScale(theme2) {
|
|
|
1053
1053
|
|
|
1054
1054
|
// industryMarkdown/components/IndustryMarkdownSlide.tsx
|
|
1055
1055
|
import { defaultSchema } from "hast-util-sanitize";
|
|
1056
|
-
import
|
|
1056
|
+
import { Trash2 } from "lucide-react";
|
|
1057
|
+
import React13, { useRef as useRef9, useEffect as useEffect9, useLayoutEffect as useLayoutEffect2, useState as useState11, useMemo as useMemo3, useCallback as useCallback3 } from "react";
|
|
1057
1058
|
import { createPortal as createPortal2 } from "react-dom";
|
|
1058
1059
|
import ReactMarkdown from "react-markdown";
|
|
1059
1060
|
import rehypeHighlight from "rehype-highlight";
|
|
@@ -1062,6 +1063,110 @@ import rehypeSanitize from "rehype-sanitize";
|
|
|
1062
1063
|
import rehypeSlug from "rehype-slug";
|
|
1063
1064
|
import remarkGfm from "remark-gfm";
|
|
1064
1065
|
|
|
1066
|
+
// industryMarkdown/utils/blockDeletion.ts
|
|
1067
|
+
function lineStartOffset(text, line) {
|
|
1068
|
+
if (line <= 1)
|
|
1069
|
+
return 0;
|
|
1070
|
+
let offset = 0;
|
|
1071
|
+
let current = 1;
|
|
1072
|
+
while (current < line) {
|
|
1073
|
+
const nl = text.indexOf(`
|
|
1074
|
+
`, offset);
|
|
1075
|
+
if (nl === -1)
|
|
1076
|
+
return text.length;
|
|
1077
|
+
offset = nl + 1;
|
|
1078
|
+
current += 1;
|
|
1079
|
+
}
|
|
1080
|
+
return offset;
|
|
1081
|
+
}
|
|
1082
|
+
function lineEndOffset(text, line) {
|
|
1083
|
+
const start = lineStartOffset(text, line);
|
|
1084
|
+
const nl = text.indexOf(`
|
|
1085
|
+
`, start);
|
|
1086
|
+
return nl === -1 ? text.length : nl;
|
|
1087
|
+
}
|
|
1088
|
+
function computeChunkOffsets(content, chunks) {
|
|
1089
|
+
const offsets = [];
|
|
1090
|
+
let cursor = 0;
|
|
1091
|
+
for (const chunk of chunks) {
|
|
1092
|
+
if (!chunk.content) {
|
|
1093
|
+
offsets.push(-1);
|
|
1094
|
+
continue;
|
|
1095
|
+
}
|
|
1096
|
+
const idx = content.indexOf(chunk.content, cursor);
|
|
1097
|
+
offsets.push(idx);
|
|
1098
|
+
if (idx !== -1) {
|
|
1099
|
+
cursor = idx + chunk.content.length;
|
|
1100
|
+
}
|
|
1101
|
+
}
|
|
1102
|
+
return offsets;
|
|
1103
|
+
}
|
|
1104
|
+
function computeDeletion(content, chunks, targets) {
|
|
1105
|
+
const offsets = computeChunkOffsets(content, chunks);
|
|
1106
|
+
const ranges = [];
|
|
1107
|
+
for (const target of targets) {
|
|
1108
|
+
const base = offsets[target.chunkIndex];
|
|
1109
|
+
const chunk = chunks[target.chunkIndex];
|
|
1110
|
+
if (base === undefined || base < 0 || !chunk)
|
|
1111
|
+
continue;
|
|
1112
|
+
const chunkText = chunk.content;
|
|
1113
|
+
const startRel = lineStartOffset(chunkText, target.startLine);
|
|
1114
|
+
let endRel = lineEndOffset(chunkText, target.endLine);
|
|
1115
|
+
if (chunkText[endRel] === `
|
|
1116
|
+
`)
|
|
1117
|
+
endRel += 1;
|
|
1118
|
+
if (endRel < chunkText.length) {
|
|
1119
|
+
const nextNl = chunkText.indexOf(`
|
|
1120
|
+
`, endRel);
|
|
1121
|
+
const followingLineEnd = nextNl === -1 ? chunkText.length : nextNl;
|
|
1122
|
+
if (chunkText.slice(endRel, followingLineEnd).trim() === "") {
|
|
1123
|
+
endRel = nextNl === -1 ? chunkText.length : nextNl + 1;
|
|
1124
|
+
}
|
|
1125
|
+
}
|
|
1126
|
+
ranges.push({ start: base + startRel, end: base + endRel });
|
|
1127
|
+
}
|
|
1128
|
+
ranges.sort((a, b) => a.start - b.start);
|
|
1129
|
+
const merged = [];
|
|
1130
|
+
for (const range of ranges) {
|
|
1131
|
+
const last = merged[merged.length - 1];
|
|
1132
|
+
if (last && range.start <= last.end) {
|
|
1133
|
+
last.end = Math.max(last.end, range.end);
|
|
1134
|
+
} else {
|
|
1135
|
+
merged.push({ ...range });
|
|
1136
|
+
}
|
|
1137
|
+
}
|
|
1138
|
+
let newContent = "";
|
|
1139
|
+
let removedText = "";
|
|
1140
|
+
let cursor = 0;
|
|
1141
|
+
for (const range of merged) {
|
|
1142
|
+
newContent += content.slice(cursor, range.start);
|
|
1143
|
+
removedText += content.slice(range.start, range.end);
|
|
1144
|
+
cursor = range.end;
|
|
1145
|
+
}
|
|
1146
|
+
newContent += content.slice(cursor);
|
|
1147
|
+
return { newContent, removedText, ranges: merged };
|
|
1148
|
+
}
|
|
1149
|
+
function computeTextDeletion(content, chunks, chunkIndex, startOffset, endOffset) {
|
|
1150
|
+
const empty = { newContent: content, removedText: "", ranges: [] };
|
|
1151
|
+
const chunk = chunks[chunkIndex];
|
|
1152
|
+
if (!chunk)
|
|
1153
|
+
return empty;
|
|
1154
|
+
const base = computeChunkOffsets(content, chunks)[chunkIndex];
|
|
1155
|
+
if (base === undefined || base < 0)
|
|
1156
|
+
return empty;
|
|
1157
|
+
const start = Math.min(startOffset, endOffset);
|
|
1158
|
+
const end = Math.max(startOffset, endOffset);
|
|
1159
|
+
if (start === end)
|
|
1160
|
+
return empty;
|
|
1161
|
+
const absStart = base + start;
|
|
1162
|
+
const absEnd = base + end;
|
|
1163
|
+
return {
|
|
1164
|
+
newContent: content.slice(0, absStart) + content.slice(absEnd),
|
|
1165
|
+
removedText: content.slice(absStart, absEnd),
|
|
1166
|
+
ranges: [{ start: absStart, end: absEnd }]
|
|
1167
|
+
};
|
|
1168
|
+
}
|
|
1169
|
+
|
|
1065
1170
|
// industryMarkdown/utils/highlightSearchMatches.ts
|
|
1066
1171
|
function highlightSearchMatches(content, searchQuery) {
|
|
1067
1172
|
if (!searchQuery || !searchQuery.trim()) {
|
|
@@ -1644,6 +1749,42 @@ function parseSkillMarkdown(content) {
|
|
|
1644
1749
|
// industryMarkdown/utils/markdownUtils.ts
|
|
1645
1750
|
var parseMarkdownChunks2 = parseMarkdownChunks;
|
|
1646
1751
|
|
|
1752
|
+
// industryMarkdown/utils/rehypeSourcePositions.ts
|
|
1753
|
+
var SKIP_TAGS = new Set(["pre", "code"]);
|
|
1754
|
+
function isText(node) {
|
|
1755
|
+
return node.type === "text";
|
|
1756
|
+
}
|
|
1757
|
+
function rehypeSourcePositions() {
|
|
1758
|
+
return (tree) => {
|
|
1759
|
+
const visit = (node) => {
|
|
1760
|
+
const children = node.children;
|
|
1761
|
+
if (!children)
|
|
1762
|
+
return;
|
|
1763
|
+
if (node.type === "element" && SKIP_TAGS.has(node.tagName))
|
|
1764
|
+
return;
|
|
1765
|
+
const out = [];
|
|
1766
|
+
for (const child of children) {
|
|
1767
|
+
const startOffset = isText(child) ? child.position?.start?.offset : undefined;
|
|
1768
|
+
const endOffset = isText(child) ? child.position?.end?.offset : undefined;
|
|
1769
|
+
if (isText(child) && typeof startOffset === "number" && typeof endOffset === "number" && child.value.trim() !== "") {
|
|
1770
|
+
out.push({
|
|
1771
|
+
type: "element",
|
|
1772
|
+
tagName: "span",
|
|
1773
|
+
properties: { dataSrcStart: startOffset, dataSrcEnd: endOffset },
|
|
1774
|
+
children: [child],
|
|
1775
|
+
position: child.position
|
|
1776
|
+
});
|
|
1777
|
+
} else {
|
|
1778
|
+
visit(child);
|
|
1779
|
+
out.push(child);
|
|
1780
|
+
}
|
|
1781
|
+
}
|
|
1782
|
+
node.children = out;
|
|
1783
|
+
};
|
|
1784
|
+
visit(tree);
|
|
1785
|
+
};
|
|
1786
|
+
}
|
|
1787
|
+
|
|
1647
1788
|
// industryMarkdown/utils/useAnnotations.ts
|
|
1648
1789
|
import { useEffect as useEffect2, useLayoutEffect, useMemo, useRef, useState as useState2 } from "react";
|
|
1649
1790
|
|
|
@@ -2042,16 +2183,197 @@ function useAnnotations({
|
|
|
2042
2183
|
return mounts;
|
|
2043
2184
|
}
|
|
2044
2185
|
|
|
2186
|
+
// industryMarkdown/utils/useBlockSelection.ts
|
|
2187
|
+
import { useCallback, useEffect as useEffect3, useRef as useRef2, useState as useState3 } from "react";
|
|
2188
|
+
var BLOCK_SELECTED_ATTR = "data-md-selected";
|
|
2189
|
+
function parseTarget(el) {
|
|
2190
|
+
const chunk = el.getAttribute("data-md-chunk");
|
|
2191
|
+
const start = el.getAttribute("data-md-start");
|
|
2192
|
+
const end = el.getAttribute("data-md-end");
|
|
2193
|
+
if (chunk === null || start === null || end === null)
|
|
2194
|
+
return null;
|
|
2195
|
+
const chunkIndex = Number(chunk);
|
|
2196
|
+
const startLine = Number(start);
|
|
2197
|
+
const endLine = Number(end);
|
|
2198
|
+
if ([chunkIndex, startLine, endLine].some(Number.isNaN))
|
|
2199
|
+
return null;
|
|
2200
|
+
return { chunkIndex, startLine, endLine };
|
|
2201
|
+
}
|
|
2202
|
+
function firstTextNode(node) {
|
|
2203
|
+
if (node.nodeType === Node.TEXT_NODE)
|
|
2204
|
+
return node;
|
|
2205
|
+
const walker = document.createTreeWalker(node, NodeFilter.SHOW_TEXT);
|
|
2206
|
+
return walker.nextNode();
|
|
2207
|
+
}
|
|
2208
|
+
function lastTextNode(node) {
|
|
2209
|
+
if (node.nodeType === Node.TEXT_NODE)
|
|
2210
|
+
return node;
|
|
2211
|
+
const walker = document.createTreeWalker(node, NodeFilter.SHOW_TEXT);
|
|
2212
|
+
let last = null;
|
|
2213
|
+
let current = walker.nextNode();
|
|
2214
|
+
while (current) {
|
|
2215
|
+
last = current;
|
|
2216
|
+
current = walker.nextNode();
|
|
2217
|
+
}
|
|
2218
|
+
return last;
|
|
2219
|
+
}
|
|
2220
|
+
function resolveBoundary(container, offset, preferEnd) {
|
|
2221
|
+
if (container.nodeType === Node.TEXT_NODE) {
|
|
2222
|
+
return { textNode: container, local: offset };
|
|
2223
|
+
}
|
|
2224
|
+
if (container.nodeType !== Node.ELEMENT_NODE)
|
|
2225
|
+
return null;
|
|
2226
|
+
const children = container.childNodes;
|
|
2227
|
+
const before = children[offset - 1];
|
|
2228
|
+
const after = children[offset];
|
|
2229
|
+
if (preferEnd) {
|
|
2230
|
+
const beforeText = before && lastTextNode(before);
|
|
2231
|
+
if (beforeText)
|
|
2232
|
+
return { textNode: beforeText, local: beforeText.length };
|
|
2233
|
+
const afterText = after && firstTextNode(after);
|
|
2234
|
+
if (afterText)
|
|
2235
|
+
return { textNode: afterText, local: 0 };
|
|
2236
|
+
} else {
|
|
2237
|
+
const afterText = after && firstTextNode(after);
|
|
2238
|
+
if (afterText)
|
|
2239
|
+
return { textNode: afterText, local: 0 };
|
|
2240
|
+
const beforeText = before && lastTextNode(before);
|
|
2241
|
+
if (beforeText)
|
|
2242
|
+
return { textNode: beforeText, local: beforeText.length };
|
|
2243
|
+
}
|
|
2244
|
+
return null;
|
|
2245
|
+
}
|
|
2246
|
+
function boundaryToSource(textNode, local) {
|
|
2247
|
+
const wrapper = textNode.parentElement?.closest("[data-src-start]");
|
|
2248
|
+
if (!wrapper)
|
|
2249
|
+
return null;
|
|
2250
|
+
const srcStart = Number(wrapper.getAttribute("data-src-start"));
|
|
2251
|
+
if (Number.isNaN(srcStart))
|
|
2252
|
+
return null;
|
|
2253
|
+
const chunkEl = wrapper.closest("[data-md-chunk]");
|
|
2254
|
+
const chunkIndex = chunkEl ? Number(chunkEl.getAttribute("data-md-chunk")) : NaN;
|
|
2255
|
+
if (Number.isNaN(chunkIndex))
|
|
2256
|
+
return null;
|
|
2257
|
+
return { chunkIndex, offset: srcStart + local };
|
|
2258
|
+
}
|
|
2259
|
+
function resolveTextRange(range) {
|
|
2260
|
+
const startB = resolveBoundary(range.startContainer, range.startOffset, false);
|
|
2261
|
+
const endB = resolveBoundary(range.endContainer, range.endOffset, true);
|
|
2262
|
+
if (!startB || !endB)
|
|
2263
|
+
return null;
|
|
2264
|
+
const startSrc = boundaryToSource(startB.textNode, startB.local);
|
|
2265
|
+
const endSrc = boundaryToSource(endB.textNode, endB.local);
|
|
2266
|
+
if (!startSrc || !endSrc)
|
|
2267
|
+
return null;
|
|
2268
|
+
if (startSrc.chunkIndex !== endSrc.chunkIndex)
|
|
2269
|
+
return null;
|
|
2270
|
+
const startOffset = Math.min(startSrc.offset, endSrc.offset);
|
|
2271
|
+
const endOffset = Math.max(startSrc.offset, endSrc.offset);
|
|
2272
|
+
if (startOffset === endOffset)
|
|
2273
|
+
return null;
|
|
2274
|
+
return { chunkIndex: startSrc.chunkIndex, startOffset, endOffset };
|
|
2275
|
+
}
|
|
2276
|
+
function useBlockSelection({
|
|
2277
|
+
rootRef,
|
|
2278
|
+
enabled,
|
|
2279
|
+
mode
|
|
2280
|
+
}) {
|
|
2281
|
+
const [selection, setSelection] = useState3(null);
|
|
2282
|
+
const selectedEls = useRef2([]);
|
|
2283
|
+
const clearOutline = useCallback(() => {
|
|
2284
|
+
selectedEls.current.forEach((el) => el.removeAttribute(BLOCK_SELECTED_ATTR));
|
|
2285
|
+
selectedEls.current = [];
|
|
2286
|
+
}, []);
|
|
2287
|
+
const clear = useCallback(() => {
|
|
2288
|
+
clearOutline();
|
|
2289
|
+
setSelection(null);
|
|
2290
|
+
}, [clearOutline]);
|
|
2291
|
+
useEffect3(() => {
|
|
2292
|
+
if (!enabled) {
|
|
2293
|
+
clear();
|
|
2294
|
+
return;
|
|
2295
|
+
}
|
|
2296
|
+
const root = rootRef.current;
|
|
2297
|
+
if (!root)
|
|
2298
|
+
return;
|
|
2299
|
+
const anchorFor = (range) => {
|
|
2300
|
+
const rootRect = root.getBoundingClientRect();
|
|
2301
|
+
const rangeRect = range.getBoundingClientRect();
|
|
2302
|
+
return {
|
|
2303
|
+
top: rangeRect.top - rootRect.top + root.scrollTop,
|
|
2304
|
+
bottom: rangeRect.bottom - rootRect.top + root.scrollTop,
|
|
2305
|
+
left: rangeRect.right - rootRect.left + root.scrollLeft
|
|
2306
|
+
};
|
|
2307
|
+
};
|
|
2308
|
+
const resolveBlock = (sel, range) => {
|
|
2309
|
+
const tagged = Array.from(root.querySelectorAll(`[data-md-start]`));
|
|
2310
|
+
const matched = tagged.filter((el) => sel.containsNode(el, true));
|
|
2311
|
+
if (matched.length === 0)
|
|
2312
|
+
return false;
|
|
2313
|
+
const topLevel = matched.filter((el) => !matched.some((other) => other !== el && other.contains(el)));
|
|
2314
|
+
const targets = [];
|
|
2315
|
+
topLevel.forEach((el) => {
|
|
2316
|
+
const target = parseTarget(el);
|
|
2317
|
+
if (target)
|
|
2318
|
+
targets.push(target);
|
|
2319
|
+
});
|
|
2320
|
+
if (targets.length === 0)
|
|
2321
|
+
return false;
|
|
2322
|
+
clearOutline();
|
|
2323
|
+
topLevel.forEach((el) => el.setAttribute(BLOCK_SELECTED_ATTR, "true"));
|
|
2324
|
+
selectedEls.current = topLevel;
|
|
2325
|
+
setSelection({ kind: "block", targets, anchor: anchorFor(range) });
|
|
2326
|
+
return true;
|
|
2327
|
+
};
|
|
2328
|
+
const resolve = () => {
|
|
2329
|
+
const sel = document.getSelection();
|
|
2330
|
+
if (!sel || sel.rangeCount === 0 || sel.isCollapsed) {
|
|
2331
|
+
clear();
|
|
2332
|
+
return;
|
|
2333
|
+
}
|
|
2334
|
+
const range = sel.getRangeAt(0);
|
|
2335
|
+
if (!root.contains(range.commonAncestorContainer)) {
|
|
2336
|
+
clear();
|
|
2337
|
+
return;
|
|
2338
|
+
}
|
|
2339
|
+
if (mode === "text") {
|
|
2340
|
+
const text = resolveTextRange(range);
|
|
2341
|
+
if (text) {
|
|
2342
|
+
clearOutline();
|
|
2343
|
+
setSelection({ kind: "text", ...text, anchor: anchorFor(range) });
|
|
2344
|
+
return;
|
|
2345
|
+
}
|
|
2346
|
+
}
|
|
2347
|
+
if (!resolveBlock(sel, range)) {
|
|
2348
|
+
clear();
|
|
2349
|
+
}
|
|
2350
|
+
};
|
|
2351
|
+
const handleMouseUp = () => window.setTimeout(resolve, 0);
|
|
2352
|
+
const handleKeyUp = (event) => {
|
|
2353
|
+
if (["Shift", "Meta", "Control", "Alt"].includes(event.key))
|
|
2354
|
+
return;
|
|
2355
|
+
window.setTimeout(resolve, 0);
|
|
2356
|
+
};
|
|
2357
|
+
document.addEventListener("mouseup", handleMouseUp);
|
|
2358
|
+
document.addEventListener("keyup", handleKeyUp);
|
|
2359
|
+
return () => {
|
|
2360
|
+
document.removeEventListener("mouseup", handleMouseUp);
|
|
2361
|
+
document.removeEventListener("keyup", handleKeyUp);
|
|
2362
|
+
};
|
|
2363
|
+
}, [enabled, mode, rootRef, clear, clearOutline]);
|
|
2364
|
+
return { selection, clear };
|
|
2365
|
+
}
|
|
2366
|
+
|
|
2045
2367
|
// industryMarkdown/components/IndustryHtmlModal.tsx
|
|
2046
|
-
import React3, { useCallback, useState as
|
|
2368
|
+
import React3, { useCallback as useCallback2, useState as useState4 } from "react";
|
|
2047
2369
|
var useIndustryHtmlModal = () => {
|
|
2048
|
-
const [htmlModalOpen, setHtmlModalOpen] =
|
|
2049
|
-
const [htmlModalContent, setHtmlModalContent] =
|
|
2050
|
-
const openHtmlModal =
|
|
2370
|
+
const [htmlModalOpen, setHtmlModalOpen] = useState4(false);
|
|
2371
|
+
const [htmlModalContent, setHtmlModalContent] = useState4("");
|
|
2372
|
+
const openHtmlModal = useCallback2((content) => {
|
|
2051
2373
|
setHtmlModalContent(content);
|
|
2052
2374
|
setHtmlModalOpen(true);
|
|
2053
2375
|
}, []);
|
|
2054
|
-
const closeHtmlModal =
|
|
2376
|
+
const closeHtmlModal = useCallback2(() => {
|
|
2055
2377
|
setHtmlModalOpen(false);
|
|
2056
2378
|
}, []);
|
|
2057
2379
|
return { htmlModalOpen, htmlModalContent, openHtmlModal, closeHtmlModal };
|
|
@@ -2157,11 +2479,11 @@ function IndustryHtmlModal({ isOpen, onClose, htmlContent, theme: theme2 }) {
|
|
|
2157
2479
|
|
|
2158
2480
|
// industryMarkdown/components/IndustryLazyMermaidDiagram.tsx
|
|
2159
2481
|
import { MoveRight } from "lucide-react";
|
|
2160
|
-
import React6, { useEffect as
|
|
2482
|
+
import React6, { useEffect as useEffect5, useRef as useRef4, useState as useState6 } from "react";
|
|
2161
2483
|
|
|
2162
2484
|
// industryMarkdown/components/IndustryMermaidDiagram.tsx
|
|
2163
2485
|
import { Expand, Copy, Check } from "lucide-react";
|
|
2164
|
-
import React5, { useEffect as
|
|
2486
|
+
import React5, { useEffect as useEffect4, useRef as useRef3, useState as useState5 } from "react";
|
|
2165
2487
|
var getMermaidSync = () => {
|
|
2166
2488
|
if (typeof window !== "undefined") {
|
|
2167
2489
|
const mermaid = window.mermaid;
|
|
@@ -2183,12 +2505,12 @@ function IndustryMermaidDiagram({
|
|
|
2183
2505
|
onExpandClick
|
|
2184
2506
|
}) {
|
|
2185
2507
|
const theme2 = themeOverride ?? theme;
|
|
2186
|
-
const [errorDetails, setErrorDetails] =
|
|
2187
|
-
const [isIntersecting, setIsIntersecting] =
|
|
2188
|
-
const [hasRendered, setHasRendered] =
|
|
2189
|
-
const [containerElement, setContainerElement] =
|
|
2190
|
-
const [copiedError, setCopiedError] =
|
|
2191
|
-
const observerRef =
|
|
2508
|
+
const [errorDetails, setErrorDetails] = useState5(null);
|
|
2509
|
+
const [isIntersecting, setIsIntersecting] = useState5(false);
|
|
2510
|
+
const [hasRendered, setHasRendered] = useState5(false);
|
|
2511
|
+
const [containerElement, setContainerElement] = useState5(null);
|
|
2512
|
+
const [copiedError, setCopiedError] = useState5(false);
|
|
2513
|
+
const observerRef = useRef3(null);
|
|
2192
2514
|
const containerRef = React5.useCallback((node) => {
|
|
2193
2515
|
setContainerElement(node);
|
|
2194
2516
|
if (observerRef.current) {
|
|
@@ -2213,14 +2535,14 @@ function IndustryMermaidDiagram({
|
|
|
2213
2535
|
observerRef.current.observe(node);
|
|
2214
2536
|
}
|
|
2215
2537
|
}, [rootMargin, hasRendered, isModalMode]);
|
|
2216
|
-
|
|
2538
|
+
useEffect4(() => {
|
|
2217
2539
|
return () => {
|
|
2218
2540
|
if (observerRef.current) {
|
|
2219
2541
|
observerRef.current.disconnect();
|
|
2220
2542
|
}
|
|
2221
2543
|
};
|
|
2222
2544
|
}, []);
|
|
2223
|
-
|
|
2545
|
+
useEffect4(() => {
|
|
2224
2546
|
if (!hasRendered)
|
|
2225
2547
|
return;
|
|
2226
2548
|
const renderDiagram = async () => {
|
|
@@ -2555,15 +2877,15 @@ function IndustryLazyMermaidDiagram({
|
|
|
2555
2877
|
onExpandClick
|
|
2556
2878
|
}) {
|
|
2557
2879
|
const theme2 = themeOverride ?? theme;
|
|
2558
|
-
const [isIntersecting, setIsIntersecting] =
|
|
2559
|
-
const [hasRendered, setHasRendered] =
|
|
2560
|
-
const [isMounted, setIsMounted] =
|
|
2561
|
-
const [hasError, setHasError] =
|
|
2562
|
-
const containerRef =
|
|
2563
|
-
|
|
2880
|
+
const [isIntersecting, setIsIntersecting] = useState6(false);
|
|
2881
|
+
const [hasRendered, setHasRendered] = useState6(false);
|
|
2882
|
+
const [isMounted, setIsMounted] = useState6(false);
|
|
2883
|
+
const [hasError, setHasError] = useState6(false);
|
|
2884
|
+
const containerRef = useRef4(null);
|
|
2885
|
+
useEffect5(() => {
|
|
2564
2886
|
setIsMounted(true);
|
|
2565
2887
|
}, []);
|
|
2566
|
-
|
|
2888
|
+
useEffect5(() => {
|
|
2567
2889
|
if (!isMounted)
|
|
2568
2890
|
return;
|
|
2569
2891
|
if (typeof IntersectionObserver === "undefined") {
|
|
@@ -2684,7 +3006,7 @@ function IndustryLazyMermaidDiagram({
|
|
|
2684
3006
|
|
|
2685
3007
|
// industryMarkdown/components/IndustryMarkdownComponents.tsx
|
|
2686
3008
|
import { Copy as Copy2, Monitor, FileText, Check as Check2 } from "lucide-react";
|
|
2687
|
-
import React9, { useMemo as useMemo2, useState as
|
|
3009
|
+
import React9, { useMemo as useMemo2, useState as useState8, useRef as useRef6 } from "react";
|
|
2688
3010
|
|
|
2689
3011
|
// industryMarkdown/utils/componentUtils.tsx
|
|
2690
3012
|
import React7 from "react";
|
|
@@ -2721,7 +3043,7 @@ var LinkWithLoadingIndicator = ({ href, children, onClick, className, style }) =
|
|
|
2721
3043
|
};
|
|
2722
3044
|
// industryMarkdown/components/IndustryBashCommandDropdown.tsx
|
|
2723
3045
|
import { Play, ChevronDown } from "lucide-react";
|
|
2724
|
-
import React8, { useState as
|
|
3046
|
+
import React8, { useState as useState7, useRef as useRef5, useEffect as useEffect6 } from "react";
|
|
2725
3047
|
var IndustryBashCommandDropdown = ({
|
|
2726
3048
|
commands,
|
|
2727
3049
|
allCommands,
|
|
@@ -2730,11 +3052,11 @@ var IndustryBashCommandDropdown = ({
|
|
|
2730
3052
|
slideIdPrefix: _slideIdPrefix,
|
|
2731
3053
|
theme: themeOverride
|
|
2732
3054
|
}) => {
|
|
2733
|
-
const [isOpen, setIsOpen] =
|
|
2734
|
-
const [isRunning, setIsRunning] =
|
|
2735
|
-
const dropdownRef =
|
|
3055
|
+
const [isOpen, setIsOpen] = useState7(false);
|
|
3056
|
+
const [isRunning, setIsRunning] = useState7(false);
|
|
3057
|
+
const dropdownRef = useRef5(null);
|
|
2736
3058
|
const theme2 = themeOverride ?? theme;
|
|
2737
|
-
|
|
3059
|
+
useEffect6(() => {
|
|
2738
3060
|
const handleClickOutside = (event) => {
|
|
2739
3061
|
if (dropdownRef.current && !dropdownRef.current.contains(event.target)) {
|
|
2740
3062
|
setIsOpen(false);
|
|
@@ -2853,7 +3175,7 @@ var IndustryBashCommandDropdown = ({
|
|
|
2853
3175
|
e.currentTarget.style.backgroundColor = theme2.colors.muted;
|
|
2854
3176
|
}
|
|
2855
3177
|
}, "\uD83D\uDE80 Run all (", commands.length, " commands)"), commands.map((cmd, index) => {
|
|
2856
|
-
const [isHovered, setIsHovered] =
|
|
3178
|
+
const [isHovered, setIsHovered] = useState7(false);
|
|
2857
3179
|
return /* @__PURE__ */ React8.createElement("div", {
|
|
2858
3180
|
key: index,
|
|
2859
3181
|
style: dropdownItemStyle(isHovered),
|
|
@@ -2909,8 +3231,8 @@ var OptimizedMarkdownMedia = React9.memo(({
|
|
|
2909
3231
|
const transformedSrc = useMemo2(() => {
|
|
2910
3232
|
return transformImageUrl(src, repositoryInfo);
|
|
2911
3233
|
}, [src, repositoryInfo]);
|
|
2912
|
-
const [hasErrored, setHasErrored] =
|
|
2913
|
-
const retryCount =
|
|
3234
|
+
const [hasErrored, setHasErrored] = useState8(() => failedImageCache.has(transformedSrc));
|
|
3235
|
+
const retryCount = useRef6(0);
|
|
2914
3236
|
const mediaStyle = useMemo2(() => ({
|
|
2915
3237
|
maxWidth: "100%",
|
|
2916
3238
|
height: "auto",
|
|
@@ -3014,8 +3336,24 @@ var createIndustryMarkdownComponents = ({
|
|
|
3014
3336
|
slideHeaderMarginTopOverride,
|
|
3015
3337
|
index,
|
|
3016
3338
|
repositoryInfo,
|
|
3017
|
-
editable = false
|
|
3339
|
+
editable = false,
|
|
3340
|
+
selectableBlocks = false,
|
|
3341
|
+
onDeleteListItem
|
|
3018
3342
|
}) => {
|
|
3343
|
+
const blockMeta = (node) => {
|
|
3344
|
+
if (!selectableBlocks)
|
|
3345
|
+
return {};
|
|
3346
|
+
const position = node?.position;
|
|
3347
|
+
const startLine = position?.start?.line;
|
|
3348
|
+
const endLine = position?.end?.line;
|
|
3349
|
+
if (typeof startLine !== "number" || typeof endLine !== "number")
|
|
3350
|
+
return {};
|
|
3351
|
+
return {
|
|
3352
|
+
"data-md-chunk": index,
|
|
3353
|
+
"data-md-start": startLine,
|
|
3354
|
+
"data-md-end": endLine
|
|
3355
|
+
};
|
|
3356
|
+
};
|
|
3019
3357
|
const getLuminance = (hex) => {
|
|
3020
3358
|
const rgb = hex.replace("#", "").match(/.{2}/g);
|
|
3021
3359
|
if (!rgb)
|
|
@@ -3029,7 +3367,7 @@ var createIndustryMarkdownComponents = ({
|
|
|
3029
3367
|
headerStyles.marginTop = slideHeaderMarginTopOverride ? `${slideHeaderMarginTopOverride}px` : 0;
|
|
3030
3368
|
}
|
|
3031
3369
|
return {
|
|
3032
|
-
h1: ({ children, ...props }) => /* @__PURE__ */ React9.createElement("h1", {
|
|
3370
|
+
h1: ({ children, node, ...props }) => /* @__PURE__ */ React9.createElement("h1", {
|
|
3033
3371
|
style: {
|
|
3034
3372
|
color: theme2.colors.text,
|
|
3035
3373
|
fontSize: theme2.fontSizes[5],
|
|
@@ -3042,9 +3380,10 @@ var createIndustryMarkdownComponents = ({
|
|
|
3042
3380
|
borderBottom: `1px solid ${theme2.colors.border}`,
|
|
3043
3381
|
...headerStyles
|
|
3044
3382
|
},
|
|
3045
|
-
...props
|
|
3383
|
+
...props,
|
|
3384
|
+
...blockMeta(node)
|
|
3046
3385
|
}, children),
|
|
3047
|
-
h2: ({ children, ...props }) => /* @__PURE__ */ React9.createElement("h2", {
|
|
3386
|
+
h2: ({ children, node, ...props }) => /* @__PURE__ */ React9.createElement("h2", {
|
|
3048
3387
|
style: {
|
|
3049
3388
|
color: theme2.colors.text,
|
|
3050
3389
|
fontSize: theme2.fontSizes[4],
|
|
@@ -3057,9 +3396,10 @@ var createIndustryMarkdownComponents = ({
|
|
|
3057
3396
|
borderBottom: `1px solid ${theme2.colors.border}`,
|
|
3058
3397
|
...headerStyles
|
|
3059
3398
|
},
|
|
3060
|
-
...props
|
|
3399
|
+
...props,
|
|
3400
|
+
...blockMeta(node)
|
|
3061
3401
|
}, children),
|
|
3062
|
-
h3: ({ children, ...props }) => /* @__PURE__ */ React9.createElement("h3", {
|
|
3402
|
+
h3: ({ children, node, ...props }) => /* @__PURE__ */ React9.createElement("h3", {
|
|
3063
3403
|
style: {
|
|
3064
3404
|
color: theme2.colors.text,
|
|
3065
3405
|
fontSize: theme2.fontSizes[3],
|
|
@@ -3069,9 +3409,10 @@ var createIndustryMarkdownComponents = ({
|
|
|
3069
3409
|
marginBottom: theme2.space[3],
|
|
3070
3410
|
fontFamily: theme2.fonts.heading
|
|
3071
3411
|
},
|
|
3072
|
-
...props
|
|
3412
|
+
...props,
|
|
3413
|
+
...blockMeta(node)
|
|
3073
3414
|
}, children),
|
|
3074
|
-
h4: ({ children, ...props }) => /* @__PURE__ */ React9.createElement("h4", {
|
|
3415
|
+
h4: ({ children, node, ...props }) => /* @__PURE__ */ React9.createElement("h4", {
|
|
3075
3416
|
style: {
|
|
3076
3417
|
color: theme2.colors.text,
|
|
3077
3418
|
fontSize: theme2.fontSizes[2],
|
|
@@ -3081,9 +3422,10 @@ var createIndustryMarkdownComponents = ({
|
|
|
3081
3422
|
marginBottom: theme2.space[2],
|
|
3082
3423
|
fontFamily: theme2.fonts.heading
|
|
3083
3424
|
},
|
|
3084
|
-
...props
|
|
3425
|
+
...props,
|
|
3426
|
+
...blockMeta(node)
|
|
3085
3427
|
}, children),
|
|
3086
|
-
h5: ({ children, ...props }) => /* @__PURE__ */ React9.createElement("h5", {
|
|
3428
|
+
h5: ({ children, node, ...props }) => /* @__PURE__ */ React9.createElement("h5", {
|
|
3087
3429
|
style: {
|
|
3088
3430
|
color: theme2.colors.text,
|
|
3089
3431
|
fontSize: theme2.fontSizes[1],
|
|
@@ -3093,9 +3435,10 @@ var createIndustryMarkdownComponents = ({
|
|
|
3093
3435
|
marginBottom: theme2.space[1],
|
|
3094
3436
|
fontFamily: theme2.fonts.heading
|
|
3095
3437
|
},
|
|
3096
|
-
...props
|
|
3438
|
+
...props,
|
|
3439
|
+
...blockMeta(node)
|
|
3097
3440
|
}, children),
|
|
3098
|
-
h6: ({ children, ...props }) => /* @__PURE__ */ React9.createElement("h6", {
|
|
3441
|
+
h6: ({ children, node, ...props }) => /* @__PURE__ */ React9.createElement("h6", {
|
|
3099
3442
|
style: {
|
|
3100
3443
|
color: theme2.colors.text,
|
|
3101
3444
|
fontSize: theme2.fontSizes[1],
|
|
@@ -3105,9 +3448,10 @@ var createIndustryMarkdownComponents = ({
|
|
|
3105
3448
|
marginBottom: theme2.space[1],
|
|
3106
3449
|
fontFamily: theme2.fonts.heading
|
|
3107
3450
|
},
|
|
3108
|
-
...props
|
|
3451
|
+
...props,
|
|
3452
|
+
...blockMeta(node)
|
|
3109
3453
|
}, children),
|
|
3110
|
-
p: ({ children, ...props }) => /* @__PURE__ */ React9.createElement("p", {
|
|
3454
|
+
p: ({ children, node, ...props }) => /* @__PURE__ */ React9.createElement("p", {
|
|
3111
3455
|
style: {
|
|
3112
3456
|
color: theme2.colors.text,
|
|
3113
3457
|
fontSize: theme2.fontSizes[2],
|
|
@@ -3115,9 +3459,10 @@ var createIndustryMarkdownComponents = ({
|
|
|
3115
3459
|
marginBottom: theme2.space[3],
|
|
3116
3460
|
fontFamily: theme2.fonts.body
|
|
3117
3461
|
},
|
|
3118
|
-
...props
|
|
3462
|
+
...props,
|
|
3463
|
+
...blockMeta(node)
|
|
3119
3464
|
}, children),
|
|
3120
|
-
ul: ({ children, ...props }) => /* @__PURE__ */ React9.createElement("ul", {
|
|
3465
|
+
ul: ({ children, node, ...props }) => /* @__PURE__ */ React9.createElement("ul", {
|
|
3121
3466
|
style: {
|
|
3122
3467
|
color: theme2.colors.text,
|
|
3123
3468
|
fontSize: theme2.fontSizes[2],
|
|
@@ -3127,9 +3472,10 @@ var createIndustryMarkdownComponents = ({
|
|
|
3127
3472
|
listStyleType: "disc",
|
|
3128
3473
|
fontFamily: theme2.fonts.body
|
|
3129
3474
|
},
|
|
3130
|
-
...props
|
|
3475
|
+
...props,
|
|
3476
|
+
...blockMeta(node)
|
|
3131
3477
|
}, children),
|
|
3132
|
-
ol: ({ children, ...props }) => /* @__PURE__ */ React9.createElement("ol", {
|
|
3478
|
+
ol: ({ children, node, ...props }) => /* @__PURE__ */ React9.createElement("ol", {
|
|
3133
3479
|
style: {
|
|
3134
3480
|
color: theme2.colors.text,
|
|
3135
3481
|
fontSize: theme2.fontSizes[2],
|
|
@@ -3139,9 +3485,10 @@ var createIndustryMarkdownComponents = ({
|
|
|
3139
3485
|
listStyleType: "decimal",
|
|
3140
3486
|
fontFamily: theme2.fonts.body
|
|
3141
3487
|
},
|
|
3142
|
-
...props
|
|
3488
|
+
...props,
|
|
3489
|
+
...blockMeta(node)
|
|
3143
3490
|
}, children),
|
|
3144
|
-
li: ({ children, ...props }) => {
|
|
3491
|
+
li: ({ children, node, ...props }) => {
|
|
3145
3492
|
const isTaskListItem = Array.isArray(children) && children.length > 0 && React9.isValidElement(children[0]) && children[0]?.props?.type === "checkbox";
|
|
3146
3493
|
if (isTaskListItem) {
|
|
3147
3494
|
const checkbox = children[0];
|
|
@@ -3156,7 +3503,7 @@ var createIndustryMarkdownComponents = ({
|
|
|
3156
3503
|
}
|
|
3157
3504
|
});
|
|
3158
3505
|
const checked = checkbox?.props?.checked || false;
|
|
3159
|
-
const lineNumber = props.sourcePosition?.start?.line ||
|
|
3506
|
+
const lineNumber = props.sourcePosition?.start?.line || node?.position?.start?.line || 1;
|
|
3160
3507
|
const id = `${slideIdPrefix}-checkbox-${lineNumber}`;
|
|
3161
3508
|
const isChecked = checkedItems[id] ?? checked;
|
|
3162
3509
|
const handleChange = (e) => {
|
|
@@ -3204,6 +3551,37 @@ var createIndustryMarkdownComponents = ({
|
|
|
3204
3551
|
}
|
|
3205
3552
|
}, labelContent.length > 0 ? labelContent : null)), nestedListElements.length > 0 ? nestedListElements : null);
|
|
3206
3553
|
}
|
|
3554
|
+
const position = node?.position;
|
|
3555
|
+
const itemStart = position?.start?.line;
|
|
3556
|
+
const itemEnd = position?.end?.line;
|
|
3557
|
+
const deletable = selectableBlocks && !!onDeleteListItem && typeof itemStart === "number" && typeof itemEnd === "number";
|
|
3558
|
+
if (deletable) {
|
|
3559
|
+
return /* @__PURE__ */ React9.createElement("li", {
|
|
3560
|
+
className: "md-del-li",
|
|
3561
|
+
style: {
|
|
3562
|
+
marginBottom: theme2.space[2],
|
|
3563
|
+
paddingTop: theme2.space[1],
|
|
3564
|
+
color: theme2.colors.text,
|
|
3565
|
+
lineHeight: theme2.lineHeights.relaxed,
|
|
3566
|
+
display: "flex",
|
|
3567
|
+
alignItems: "flex-start"
|
|
3568
|
+
},
|
|
3569
|
+
...props,
|
|
3570
|
+
...blockMeta(node)
|
|
3571
|
+
}, /* @__PURE__ */ React9.createElement("button", {
|
|
3572
|
+
type: "button",
|
|
3573
|
+
className: "md-del-marker",
|
|
3574
|
+
"aria-label": "Delete list item",
|
|
3575
|
+
title: "Delete this item",
|
|
3576
|
+
onClick: (e) => {
|
|
3577
|
+
e.preventDefault();
|
|
3578
|
+
e.stopPropagation();
|
|
3579
|
+
onDeleteListItem(index, itemStart, itemEnd);
|
|
3580
|
+
}
|
|
3581
|
+
}), /* @__PURE__ */ React9.createElement("div", {
|
|
3582
|
+
style: { flex: 1, minWidth: 0 }
|
|
3583
|
+
}, children));
|
|
3584
|
+
}
|
|
3207
3585
|
return /* @__PURE__ */ React9.createElement("li", {
|
|
3208
3586
|
style: {
|
|
3209
3587
|
marginBottom: theme2.space[2],
|
|
@@ -3211,16 +3589,39 @@ var createIndustryMarkdownComponents = ({
|
|
|
3211
3589
|
color: theme2.colors.text,
|
|
3212
3590
|
lineHeight: theme2.lineHeights.relaxed
|
|
3213
3591
|
},
|
|
3214
|
-
...props
|
|
3592
|
+
...props,
|
|
3593
|
+
...blockMeta(node)
|
|
3215
3594
|
}, children);
|
|
3216
3595
|
},
|
|
3217
|
-
|
|
3596
|
+
blockquote: ({ children, node, ...props }) => /* @__PURE__ */ React9.createElement("blockquote", {
|
|
3597
|
+
style: {
|
|
3598
|
+
margin: `0 0 ${theme2.space[3]}px 0`,
|
|
3599
|
+
padding: `${theme2.space[2]}px ${theme2.space[4]}px`,
|
|
3600
|
+
borderLeft: `4px solid ${theme2.colors.border}`,
|
|
3601
|
+
color: theme2.colors.textSecondary,
|
|
3602
|
+
fontStyle: "italic",
|
|
3603
|
+
fontFamily: theme2.fonts.body
|
|
3604
|
+
},
|
|
3605
|
+
...props,
|
|
3606
|
+
...blockMeta(node)
|
|
3607
|
+
}, children),
|
|
3608
|
+
hr: ({ node, ...props }) => /* @__PURE__ */ React9.createElement("hr", {
|
|
3609
|
+
style: {
|
|
3610
|
+
border: "none",
|
|
3611
|
+
borderTop: `1px solid ${theme2.colors.border}`,
|
|
3612
|
+
margin: `${theme2.space[4]}px 0`
|
|
3613
|
+
},
|
|
3614
|
+
...props,
|
|
3615
|
+
...blockMeta(node)
|
|
3616
|
+
}),
|
|
3617
|
+
table: ({ children, node, ...props }) => /* @__PURE__ */ React9.createElement("div", {
|
|
3218
3618
|
style: {
|
|
3219
3619
|
overflowX: "auto",
|
|
3220
3620
|
marginBottom: theme2.space[4],
|
|
3221
3621
|
borderRadius: theme2.radii[2],
|
|
3222
3622
|
border: `1px solid ${theme2.colors.border}`
|
|
3223
|
-
}
|
|
3623
|
+
},
|
|
3624
|
+
...blockMeta(node)
|
|
3224
3625
|
}, /* @__PURE__ */ React9.createElement("table", {
|
|
3225
3626
|
style: {
|
|
3226
3627
|
width: "100%",
|
|
@@ -3306,7 +3707,7 @@ var createIndustryMarkdownComponents = ({
|
|
|
3306
3707
|
const codeString = extractTextFromChildren(children);
|
|
3307
3708
|
const matchLang = /language-(\w+)/.exec(className || "");
|
|
3308
3709
|
const language = matchLang ? matchLang[1] : null;
|
|
3309
|
-
const [copied, setCopied] =
|
|
3710
|
+
const [copied, setCopied] = useState8(false);
|
|
3310
3711
|
let isInline;
|
|
3311
3712
|
let isCodeBlock;
|
|
3312
3713
|
const hasNewlines = codeString.includes(`
|
|
@@ -3372,7 +3773,8 @@ var createIndustryMarkdownComponents = ({
|
|
|
3372
3773
|
fontSize: theme2.fontSizes[0]
|
|
3373
3774
|
};
|
|
3374
3775
|
return /* @__PURE__ */ React9.createElement("div", {
|
|
3375
|
-
style: containerStyle
|
|
3776
|
+
style: containerStyle,
|
|
3777
|
+
...blockMeta(node)
|
|
3376
3778
|
}, /* @__PURE__ */ React9.createElement("div", {
|
|
3377
3779
|
style: headerStyle
|
|
3378
3780
|
}, /* @__PURE__ */ React9.createElement("span", {
|
|
@@ -3531,11 +3933,11 @@ var createIndustryMarkdownComponents = ({
|
|
|
3531
3933
|
};
|
|
3532
3934
|
|
|
3533
3935
|
// industryMarkdown/components/IndustryMermaidModal.tsx
|
|
3534
|
-
import React11, { useEffect as
|
|
3936
|
+
import React11, { useEffect as useEffect8, useRef as useRef8 } from "react";
|
|
3535
3937
|
import { createPortal } from "react-dom";
|
|
3536
3938
|
|
|
3537
3939
|
// industryMarkdown/components/IndustryZoomableMermaidDiagram.tsx
|
|
3538
|
-
import React10, { useEffect as
|
|
3940
|
+
import React10, { useEffect as useEffect7, useRef as useRef7, useState as useState9 } from "react";
|
|
3539
3941
|
import { TransformWrapper, TransformComponent } from "react-zoom-pan-pinch";
|
|
3540
3942
|
function IndustryZoomableMermaidDiagram({
|
|
3541
3943
|
code,
|
|
@@ -3545,13 +3947,13 @@ function IndustryZoomableMermaidDiagram({
|
|
|
3545
3947
|
padding = 0.9
|
|
3546
3948
|
}) {
|
|
3547
3949
|
const theme2 = themeOverride ?? theme;
|
|
3548
|
-
const [calculatedScale, setCalculatedScale] =
|
|
3549
|
-
const [hasInitialized, setHasInitialized] =
|
|
3550
|
-
const containerRef =
|
|
3551
|
-
const diagramRef =
|
|
3552
|
-
const [isCalculating, setIsCalculating] =
|
|
3553
|
-
const transformRef =
|
|
3554
|
-
|
|
3950
|
+
const [calculatedScale, setCalculatedScale] = useState9(1);
|
|
3951
|
+
const [hasInitialized, setHasInitialized] = useState9(false);
|
|
3952
|
+
const containerRef = useRef7(null);
|
|
3953
|
+
const diagramRef = useRef7(null);
|
|
3954
|
+
const [isCalculating, setIsCalculating] = useState9(true);
|
|
3955
|
+
const transformRef = useRef7(null);
|
|
3956
|
+
useEffect7(() => {
|
|
3555
3957
|
if (!containerRef.current || !diagramRef.current)
|
|
3556
3958
|
return;
|
|
3557
3959
|
const calculateOptimalScale = () => {
|
|
@@ -3615,7 +4017,7 @@ function IndustryZoomableMermaidDiagram({
|
|
|
3615
4017
|
resizeObserver.disconnect();
|
|
3616
4018
|
};
|
|
3617
4019
|
}, [code, fitStrategy, padding]);
|
|
3618
|
-
|
|
4020
|
+
useEffect7(() => {
|
|
3619
4021
|
if (hasInitialized && transformRef.current) {
|
|
3620
4022
|
const { centerView } = transformRef.current;
|
|
3621
4023
|
centerView(calculatedScale, 0, "easeOut");
|
|
@@ -3725,8 +4127,8 @@ function IndustryMermaidModal({
|
|
|
3725
4127
|
mermaidCode,
|
|
3726
4128
|
theme: theme2
|
|
3727
4129
|
}) {
|
|
3728
|
-
const modalRef =
|
|
3729
|
-
|
|
4130
|
+
const modalRef = useRef8(null);
|
|
4131
|
+
useEffect8(() => {
|
|
3730
4132
|
const handleEscape = (event) => {
|
|
3731
4133
|
if (event.key === "Escape") {
|
|
3732
4134
|
onClose();
|
|
@@ -3828,7 +4230,7 @@ function IndustryMermaidModal({
|
|
|
3828
4230
|
}
|
|
3829
4231
|
|
|
3830
4232
|
// industryMarkdown/components/IndustryPlaceholderModal.tsx
|
|
3831
|
-
import React12, { useState as
|
|
4233
|
+
import React12, { useState as useState10 } from "react";
|
|
3832
4234
|
function IndustryPlaceholderModal({
|
|
3833
4235
|
isOpen,
|
|
3834
4236
|
onClose,
|
|
@@ -3837,7 +4239,7 @@ function IndustryPlaceholderModal({
|
|
|
3837
4239
|
onCopy,
|
|
3838
4240
|
theme: theme2
|
|
3839
4241
|
}) {
|
|
3840
|
-
const [values, setValues] =
|
|
4242
|
+
const [values, setValues] = useState10({});
|
|
3841
4243
|
if (!isOpen)
|
|
3842
4244
|
return null;
|
|
3843
4245
|
const handleSubmit = (e) => {
|
|
@@ -4244,6 +4646,52 @@ var annotationCSS = `
|
|
|
4244
4646
|
cursor: pointer;
|
|
4245
4647
|
}
|
|
4246
4648
|
`;
|
|
4649
|
+
var blockSelectionCSS = `
|
|
4650
|
+
.markdown-slide [data-md-selected] {
|
|
4651
|
+
outline: 2px solid var(--industry-md-delete-outline, rgba(220, 38, 38, 0.7));
|
|
4652
|
+
outline-offset: 2px;
|
|
4653
|
+
border-radius: 3px;
|
|
4654
|
+
background-color: var(--industry-md-delete-bg, rgba(220, 38, 38, 0.08));
|
|
4655
|
+
}
|
|
4656
|
+
|
|
4657
|
+
/* Clickable list-item markers (bullet / number) for per-item deletion. */
|
|
4658
|
+
.markdown-slide li.md-del-li {
|
|
4659
|
+
list-style: none;
|
|
4660
|
+
}
|
|
4661
|
+
.markdown-slide .md-del-marker {
|
|
4662
|
+
flex: 0 0 auto;
|
|
4663
|
+
width: 1.5em;
|
|
4664
|
+
margin-right: 0.35em;
|
|
4665
|
+
padding: 0;
|
|
4666
|
+
box-sizing: border-box;
|
|
4667
|
+
appearance: none;
|
|
4668
|
+
background: transparent;
|
|
4669
|
+
border: none;
|
|
4670
|
+
color: inherit;
|
|
4671
|
+
font: inherit;
|
|
4672
|
+
line-height: inherit;
|
|
4673
|
+
text-align: right;
|
|
4674
|
+
cursor: pointer;
|
|
4675
|
+
user-select: none;
|
|
4676
|
+
transition: color 0.15s ease;
|
|
4677
|
+
}
|
|
4678
|
+
.markdown-slide ul .md-del-marker::before {
|
|
4679
|
+
content: "\\2022"; /* • */
|
|
4680
|
+
}
|
|
4681
|
+
.markdown-slide ol {
|
|
4682
|
+
counter-reset: md-del-counter;
|
|
4683
|
+
}
|
|
4684
|
+
.markdown-slide ol > li > .md-del-marker::before {
|
|
4685
|
+
counter-increment: md-del-counter;
|
|
4686
|
+
content: counter(md-del-counter) ".";
|
|
4687
|
+
}
|
|
4688
|
+
.markdown-slide .md-del-marker:hover {
|
|
4689
|
+
color: var(--industry-md-delete-outline, #dc2626);
|
|
4690
|
+
}
|
|
4691
|
+
.markdown-slide .md-del-marker:hover::before {
|
|
4692
|
+
content: "\\2715"; /* ✕ */
|
|
4693
|
+
}
|
|
4694
|
+
`;
|
|
4247
4695
|
var fontTransitionCSS = `
|
|
4248
4696
|
.markdown-slide * {
|
|
4249
4697
|
transition: font-size 0.2s ease-in-out;
|
|
@@ -4307,6 +4755,12 @@ var injectStyles = () => {
|
|
|
4307
4755
|
annotationStyle.textContent = annotationCSS;
|
|
4308
4756
|
document.head.appendChild(annotationStyle);
|
|
4309
4757
|
}
|
|
4758
|
+
if (!document.getElementById("markdown-slide-block-selection")) {
|
|
4759
|
+
const blockSelectionStyle = document.createElement("style");
|
|
4760
|
+
blockSelectionStyle.id = "markdown-slide-block-selection";
|
|
4761
|
+
blockSelectionStyle.textContent = blockSelectionCSS;
|
|
4762
|
+
document.head.appendChild(blockSelectionStyle);
|
|
4763
|
+
}
|
|
4310
4764
|
stylesInjected = true;
|
|
4311
4765
|
}
|
|
4312
4766
|
};
|
|
@@ -4338,6 +4792,10 @@ var IndustryMarkdownSlide = React13.memo(function IndustryMarkdownSlide2({
|
|
|
4338
4792
|
keyboardScrollConfig,
|
|
4339
4793
|
repositoryInfo,
|
|
4340
4794
|
editable = false,
|
|
4795
|
+
selectableBlocks = false,
|
|
4796
|
+
deletionMode = "block",
|
|
4797
|
+
onContentChange,
|
|
4798
|
+
onDeleteBlocks,
|
|
4341
4799
|
annotations,
|
|
4342
4800
|
activeAnnotationId,
|
|
4343
4801
|
renderAnnotation,
|
|
@@ -4345,9 +4803,9 @@ var IndustryMarkdownSlide = React13.memo(function IndustryMarkdownSlide2({
|
|
|
4345
4803
|
onAnnotationClick,
|
|
4346
4804
|
annotationStyle
|
|
4347
4805
|
}) {
|
|
4348
|
-
const slideRef =
|
|
4349
|
-
const scrollPositionsRef =
|
|
4350
|
-
const [measuredContainerWidth, setMeasuredContainerWidth] =
|
|
4806
|
+
const slideRef = useRef9(null);
|
|
4807
|
+
const scrollPositionsRef = useRef9(new Map);
|
|
4808
|
+
const [measuredContainerWidth, setMeasuredContainerWidth] = useState11(null);
|
|
4351
4809
|
const chunks = useMemo3(() => {
|
|
4352
4810
|
if (typeof content !== "string")
|
|
4353
4811
|
return [];
|
|
@@ -4358,16 +4816,16 @@ var IndustryMarkdownSlide = React13.memo(function IndustryMarkdownSlide2({
|
|
|
4358
4816
|
return [];
|
|
4359
4817
|
}
|
|
4360
4818
|
}, [content, slideIdPrefix]);
|
|
4361
|
-
const [checkedItems, setCheckedItems] =
|
|
4819
|
+
const [checkedItems, setCheckedItems] = useState11({});
|
|
4362
4820
|
const { htmlModalOpen, htmlModalContent, openHtmlModal, closeHtmlModal } = useIndustryHtmlModal();
|
|
4363
|
-
const [mermaidModalOpen, setMermaidModalOpen] =
|
|
4364
|
-
const [mermaidModalCode, setMermaidModalCode] =
|
|
4365
|
-
const [placeholderModalOpen, setPlaceholderModalOpen] =
|
|
4366
|
-
const [placeholderModalData, setPlaceholderModalData] =
|
|
4367
|
-
|
|
4821
|
+
const [mermaidModalOpen, setMermaidModalOpen] = useState11(false);
|
|
4822
|
+
const [mermaidModalCode, setMermaidModalCode] = useState11("");
|
|
4823
|
+
const [placeholderModalOpen, setPlaceholderModalOpen] = useState11(false);
|
|
4824
|
+
const [placeholderModalData, setPlaceholderModalData] = useState11(null);
|
|
4825
|
+
useEffect9(() => {
|
|
4368
4826
|
injectStyles();
|
|
4369
4827
|
}, []);
|
|
4370
|
-
|
|
4828
|
+
useEffect9(() => {
|
|
4371
4829
|
if (containerWidth !== undefined) {
|
|
4372
4830
|
return;
|
|
4373
4831
|
}
|
|
@@ -4426,7 +4884,7 @@ var IndustryMarkdownSlide = React13.memo(function IndustryMarkdownSlide2({
|
|
|
4426
4884
|
...keyboardScrollConfig?.keys
|
|
4427
4885
|
}
|
|
4428
4886
|
};
|
|
4429
|
-
const handleKeyDown =
|
|
4887
|
+
const handleKeyDown = useCallback3((event) => {
|
|
4430
4888
|
if (!enableKeyboardScrolling) {
|
|
4431
4889
|
return;
|
|
4432
4890
|
}
|
|
@@ -4536,7 +4994,7 @@ var IndustryMarkdownSlide = React13.memo(function IndustryMarkdownSlide2({
|
|
|
4536
4994
|
}, scrollConfig.smoothScroll ? 100 : 0);
|
|
4537
4995
|
}
|
|
4538
4996
|
}, [enableKeyboardScrolling, isVisible, slideIndex, scrollConfig]);
|
|
4539
|
-
|
|
4997
|
+
useEffect9(() => {
|
|
4540
4998
|
if (autoFocusOnVisible && isVisible && slideRef.current) {
|
|
4541
4999
|
slideRef.current.focus({ preventScroll: true });
|
|
4542
5000
|
}
|
|
@@ -4601,7 +5059,7 @@ var IndustryMarkdownSlide = React13.memo(function IndustryMarkdownSlide2({
|
|
|
4601
5059
|
additionalPadding,
|
|
4602
5060
|
disableBasePadding
|
|
4603
5061
|
]);
|
|
4604
|
-
|
|
5062
|
+
useEffect9(() => {
|
|
4605
5063
|
const slideElement = slideRef.current;
|
|
4606
5064
|
if (slideElement) {
|
|
4607
5065
|
const handleScroll = () => {
|
|
@@ -4688,7 +5146,17 @@ var IndustryMarkdownSlide = React13.memo(function IndustryMarkdownSlide2({
|
|
|
4688
5146
|
}
|
|
4689
5147
|
}), []);
|
|
4690
5148
|
const rootMargin = isVisible ? "0px" : "100px";
|
|
4691
|
-
const
|
|
5149
|
+
const hasDeleteHandler = !!onContentChange || !!onDeleteBlocks;
|
|
5150
|
+
const blockDeletionEnabled = selectableBlocks && hasDeleteHandler;
|
|
5151
|
+
const handleDeleteListItem = useCallback3((chunkIndex, startLine, endLine) => {
|
|
5152
|
+
const targets = [{ chunkIndex, startLine, endLine }];
|
|
5153
|
+
const { newContent, removedText } = computeDeletion(content, chunks, targets);
|
|
5154
|
+
if (newContent === content)
|
|
5155
|
+
return;
|
|
5156
|
+
onContentChange?.(newContent);
|
|
5157
|
+
onDeleteBlocks?.({ newContent, removedText, targets });
|
|
5158
|
+
}, [content, chunks, onContentChange, onDeleteBlocks]);
|
|
5159
|
+
const getMarkdownComponents = useCallback3((chunkIndex) => {
|
|
4692
5160
|
const baseComponents = createIndustryMarkdownComponents({
|
|
4693
5161
|
theme: theme2,
|
|
4694
5162
|
slideIdPrefix,
|
|
@@ -4704,7 +5172,9 @@ var IndustryMarkdownSlide = React13.memo(function IndustryMarkdownSlide2({
|
|
|
4704
5172
|
slideHeaderMarginTopOverride,
|
|
4705
5173
|
index: chunkIndex,
|
|
4706
5174
|
repositoryInfo,
|
|
4707
|
-
editable
|
|
5175
|
+
editable,
|
|
5176
|
+
selectableBlocks,
|
|
5177
|
+
onDeleteListItem: blockDeletionEnabled ? handleDeleteListItem : undefined
|
|
4708
5178
|
});
|
|
4709
5179
|
if (searchQuery) {
|
|
4710
5180
|
return {
|
|
@@ -4738,8 +5208,24 @@ var IndustryMarkdownSlide = React13.memo(function IndustryMarkdownSlide2({
|
|
|
4738
5208
|
slideHeaderMarginTopOverride,
|
|
4739
5209
|
repositoryInfo,
|
|
4740
5210
|
searchQuery,
|
|
4741
|
-
editable
|
|
5211
|
+
editable,
|
|
5212
|
+
selectableBlocks,
|
|
5213
|
+
blockDeletionEnabled,
|
|
5214
|
+
handleDeleteListItem
|
|
4742
5215
|
]);
|
|
5216
|
+
const sourcePositionsEnabled = blockDeletionEnabled && deletionMode === "text" && !searchQuery;
|
|
5217
|
+
const rehypePlugins = useMemo3(() => {
|
|
5218
|
+
const plugins = [
|
|
5219
|
+
rehypeRaw,
|
|
5220
|
+
[rehypeSanitize, sanitizeSchema],
|
|
5221
|
+
rehypeSlug,
|
|
5222
|
+
rehypeHighlight
|
|
5223
|
+
];
|
|
5224
|
+
if (sourcePositionsEnabled) {
|
|
5225
|
+
plugins.push(rehypeSourcePositions);
|
|
5226
|
+
}
|
|
5227
|
+
return plugins;
|
|
5228
|
+
}, [sanitizeSchema, sourcePositionsEnabled]);
|
|
4743
5229
|
const renderedChunks = useMemo3(() => {
|
|
4744
5230
|
if (chunks.length === 0) {
|
|
4745
5231
|
return /* @__PURE__ */ React13.createElement("div", {
|
|
@@ -4757,12 +5243,7 @@ var IndustryMarkdownSlide = React13.memo(function IndustryMarkdownSlide2({
|
|
|
4757
5243
|
return /* @__PURE__ */ React13.createElement(ReactMarkdown, {
|
|
4758
5244
|
key: `${chunk.id}-${JSON.stringify(theme2.colors.accent)}`,
|
|
4759
5245
|
remarkPlugins: [remarkGfm],
|
|
4760
|
-
rehypePlugins
|
|
4761
|
-
rehypeRaw,
|
|
4762
|
-
[rehypeSanitize, sanitizeSchema],
|
|
4763
|
-
rehypeSlug,
|
|
4764
|
-
rehypeHighlight
|
|
4765
|
-
],
|
|
5246
|
+
rehypePlugins,
|
|
4766
5247
|
components: getMarkdownComponents(index)
|
|
4767
5248
|
}, processedContent);
|
|
4768
5249
|
}
|
|
@@ -4790,7 +5271,7 @@ var IndustryMarkdownSlide = React13.memo(function IndustryMarkdownSlide2({
|
|
|
4790
5271
|
content,
|
|
4791
5272
|
searchQuery,
|
|
4792
5273
|
theme2,
|
|
4793
|
-
|
|
5274
|
+
rehypePlugins,
|
|
4794
5275
|
getMarkdownComponents,
|
|
4795
5276
|
rootMargin,
|
|
4796
5277
|
onCopyMermaidError,
|
|
@@ -4803,6 +5284,65 @@ var IndustryMarkdownSlide = React13.memo(function IndustryMarkdownSlide2({
|
|
|
4803
5284
|
onSelectionChange,
|
|
4804
5285
|
onAnnotationClick
|
|
4805
5286
|
});
|
|
5287
|
+
const { selection: blockSelection, clear: clearBlockSelection } = useBlockSelection({
|
|
5288
|
+
rootRef: slideRef,
|
|
5289
|
+
enabled: blockDeletionEnabled,
|
|
5290
|
+
mode: deletionMode
|
|
5291
|
+
});
|
|
5292
|
+
const handleDeleteSelection = useCallback3(() => {
|
|
5293
|
+
if (!blockSelection)
|
|
5294
|
+
return;
|
|
5295
|
+
const result = blockSelection.kind === "text" ? computeTextDeletion(content, chunks, blockSelection.chunkIndex, blockSelection.startOffset, blockSelection.endOffset) : computeDeletion(content, chunks, blockSelection.targets);
|
|
5296
|
+
if (result.newContent === content) {
|
|
5297
|
+
clearBlockSelection();
|
|
5298
|
+
return;
|
|
5299
|
+
}
|
|
5300
|
+
onContentChange?.(result.newContent);
|
|
5301
|
+
onDeleteBlocks?.({
|
|
5302
|
+
newContent: result.newContent,
|
|
5303
|
+
removedText: result.removedText,
|
|
5304
|
+
targets: blockSelection.kind === "block" ? blockSelection.targets : []
|
|
5305
|
+
});
|
|
5306
|
+
clearBlockSelection();
|
|
5307
|
+
}, [blockSelection, content, chunks, onContentChange, onDeleteBlocks, clearBlockSelection]);
|
|
5308
|
+
const handleSlideKeyDown = useCallback3((event) => {
|
|
5309
|
+
if (blockDeletionEnabled && blockSelection && (event.key === "Delete" || event.key === "Backspace")) {
|
|
5310
|
+
event.preventDefault();
|
|
5311
|
+
event.stopPropagation();
|
|
5312
|
+
handleDeleteSelection();
|
|
5313
|
+
return;
|
|
5314
|
+
}
|
|
5315
|
+
handleKeyDown(event);
|
|
5316
|
+
}, [blockDeletionEnabled, blockSelection, handleDeleteSelection, handleKeyDown]);
|
|
5317
|
+
const deleteBtnRef = useRef9(null);
|
|
5318
|
+
const [deleteBtnPos, setDeleteBtnPos] = useState11(null);
|
|
5319
|
+
useLayoutEffect2(() => {
|
|
5320
|
+
const root = slideRef.current;
|
|
5321
|
+
const btn = deleteBtnRef.current;
|
|
5322
|
+
if (!blockSelection || !root || !btn) {
|
|
5323
|
+
setDeleteBtnPos(null);
|
|
5324
|
+
return;
|
|
5325
|
+
}
|
|
5326
|
+
const { top, bottom, left } = blockSelection.anchor;
|
|
5327
|
+
const w = btn.offsetWidth;
|
|
5328
|
+
const h = btn.offsetHeight;
|
|
5329
|
+
const gap = 4;
|
|
5330
|
+
const margin = 4;
|
|
5331
|
+
let nextTop = top - h - gap;
|
|
5332
|
+
if (nextTop < root.scrollTop + margin) {
|
|
5333
|
+
nextTop = bottom + gap;
|
|
5334
|
+
}
|
|
5335
|
+
const maxTop = root.scrollTop + root.clientHeight - h - margin;
|
|
5336
|
+
if (nextTop > maxTop)
|
|
5337
|
+
nextTop = Math.max(root.scrollTop + margin, maxTop);
|
|
5338
|
+
let nextLeft = left + gap;
|
|
5339
|
+
const maxLeft = root.scrollLeft + root.clientWidth - w - margin;
|
|
5340
|
+
if (nextLeft > maxLeft)
|
|
5341
|
+
nextLeft = maxLeft;
|
|
5342
|
+
if (nextLeft < root.scrollLeft + margin)
|
|
5343
|
+
nextLeft = root.scrollLeft + margin;
|
|
5344
|
+
setDeleteBtnPos({ top: nextTop, left: nextLeft });
|
|
5345
|
+
}, [blockSelection]);
|
|
4806
5346
|
const annotationCSSVars = {};
|
|
4807
5347
|
if (annotationStyle?.backgroundColor) {
|
|
4808
5348
|
annotationCSSVars["--industry-md-annotation-bg"] = annotationStyle.backgroundColor;
|
|
@@ -4829,7 +5369,7 @@ var IndustryMarkdownSlide = React13.memo(function IndustryMarkdownSlide2({
|
|
|
4829
5369
|
...annotationCSSVars
|
|
4830
5370
|
},
|
|
4831
5371
|
tabIndex: 0,
|
|
4832
|
-
onKeyDown:
|
|
5372
|
+
onKeyDown: handleSlideKeyDown,
|
|
4833
5373
|
onClick: () => {
|
|
4834
5374
|
if (slideRef.current) {
|
|
4835
5375
|
slideRef.current.focus();
|
|
@@ -4837,7 +5377,38 @@ var IndustryMarkdownSlide = React13.memo(function IndustryMarkdownSlide2({
|
|
|
4837
5377
|
}
|
|
4838
5378
|
}, renderedChunks, renderAnnotation && annotationMounts.filter((mount) => mount.resolved).map((mount) => createPortal2(/* @__PURE__ */ React13.createElement(React13.Fragment, {
|
|
4839
5379
|
key: mount.annotation.id
|
|
4840
|
-
}, renderAnnotation(mount.annotation)), mount.host)), /* @__PURE__ */ React13.createElement(
|
|
5380
|
+
}, renderAnnotation(mount.annotation)), mount.host)), blockDeletionEnabled && blockSelection && /* @__PURE__ */ React13.createElement("button", {
|
|
5381
|
+
ref: deleteBtnRef,
|
|
5382
|
+
type: "button",
|
|
5383
|
+
"aria-label": "Delete selected block",
|
|
5384
|
+
title: "Delete selected block",
|
|
5385
|
+
onMouseDown: (e) => e.preventDefault(),
|
|
5386
|
+
onClick: (e) => {
|
|
5387
|
+
e.stopPropagation();
|
|
5388
|
+
handleDeleteSelection();
|
|
5389
|
+
},
|
|
5390
|
+
style: {
|
|
5391
|
+
position: "absolute",
|
|
5392
|
+
top: deleteBtnPos?.top ?? blockSelection.anchor.top,
|
|
5393
|
+
left: deleteBtnPos?.left ?? blockSelection.anchor.left,
|
|
5394
|
+
visibility: deleteBtnPos ? "visible" : "hidden",
|
|
5395
|
+
zIndex: 20,
|
|
5396
|
+
display: "flex",
|
|
5397
|
+
alignItems: "center",
|
|
5398
|
+
gap: theme2.space[1],
|
|
5399
|
+
padding: `${theme2.space[1]}px ${theme2.space[2]}px`,
|
|
5400
|
+
backgroundColor: theme2.colors.error || "#dc2626",
|
|
5401
|
+
color: "#fff",
|
|
5402
|
+
border: "none",
|
|
5403
|
+
borderRadius: theme2.radii[1],
|
|
5404
|
+
fontSize: theme2.fontSizes[0],
|
|
5405
|
+
fontFamily: theme2.fonts.body,
|
|
5406
|
+
cursor: "pointer",
|
|
5407
|
+
boxShadow: theme2.shadows?.[2] ?? "0 2px 8px rgba(0,0,0,0.25)"
|
|
5408
|
+
}
|
|
5409
|
+
}, /* @__PURE__ */ React13.createElement(Trash2, {
|
|
5410
|
+
size: 14
|
|
5411
|
+
}), "Delete"), /* @__PURE__ */ React13.createElement(IndustryHtmlModal, {
|
|
4841
5412
|
isOpen: htmlModalOpen,
|
|
4842
5413
|
onClose: closeHtmlModal,
|
|
4843
5414
|
htmlContent: htmlModalContent,
|
|
@@ -4858,7 +5429,7 @@ var IndustryMarkdownSlide = React13.memo(function IndustryMarkdownSlide2({
|
|
|
4858
5429
|
});
|
|
4859
5430
|
// industryMarkdown/components/SlidePresentation.tsx
|
|
4860
5431
|
import { AnimatedResizableLayout } from "@principal-ade/panels";
|
|
4861
|
-
import React17, { useState as
|
|
5432
|
+
import React17, { useState as useState12, useCallback as useCallback4, useRef as useRef11, useEffect as useEffect11 } from "react";
|
|
4862
5433
|
|
|
4863
5434
|
// industryMarkdown/utils/extractSlideTitles.ts
|
|
4864
5435
|
function extractSlideTitle2(content, slideIndex) {
|
|
@@ -5129,7 +5700,7 @@ var SlideNavigationHeader = ({
|
|
|
5129
5700
|
|
|
5130
5701
|
// industryMarkdown/components/SlideSearchBar.tsx
|
|
5131
5702
|
import { Search, X as X2 } from "lucide-react";
|
|
5132
|
-
import React16, { useRef as
|
|
5703
|
+
import React16, { useRef as useRef10, useEffect as useEffect10 } from "react";
|
|
5133
5704
|
var SlideSearchBar = ({
|
|
5134
5705
|
showSearch,
|
|
5135
5706
|
searchQuery,
|
|
@@ -5143,8 +5714,8 @@ var SlideSearchBar = ({
|
|
|
5143
5714
|
onClose,
|
|
5144
5715
|
onClear
|
|
5145
5716
|
}) => {
|
|
5146
|
-
const searchInputRef =
|
|
5147
|
-
|
|
5717
|
+
const searchInputRef = useRef10(null);
|
|
5718
|
+
useEffect10(() => {
|
|
5148
5719
|
if (showSearch && searchInputRef.current) {
|
|
5149
5720
|
searchInputRef.current.focus();
|
|
5150
5721
|
}
|
|
@@ -5346,8 +5917,8 @@ var SlidePresentation = ({
|
|
|
5346
5917
|
fontSizeScale,
|
|
5347
5918
|
theme: theme2
|
|
5348
5919
|
}) => {
|
|
5349
|
-
const [isMobile, setIsMobile] =
|
|
5350
|
-
|
|
5920
|
+
const [isMobile, setIsMobile] = useState12(false);
|
|
5921
|
+
useEffect11(() => {
|
|
5351
5922
|
const checkMobile = () => {
|
|
5352
5923
|
setIsMobile(/iPhone|iPad|iPod|Android/i.test(navigator.userAgent) || window.innerWidth < 768);
|
|
5353
5924
|
};
|
|
@@ -5357,17 +5928,17 @@ var SlidePresentation = ({
|
|
|
5357
5928
|
}, []);
|
|
5358
5929
|
const effectiveTocDisplayMode = isMobile ? "overlay" : tocDisplayMode;
|
|
5359
5930
|
const defaultTocOpen = initialTocOpen ?? effectiveTocDisplayMode === "sidebar";
|
|
5360
|
-
const [currentSlide, setCurrentSlide] =
|
|
5361
|
-
const [isFullscreen, setIsFullscreen] =
|
|
5362
|
-
const [showTOC, setShowTOC] =
|
|
5363
|
-
const [showSearch, setShowSearch] =
|
|
5364
|
-
const [searchQuery, setSearchQuery] =
|
|
5365
|
-
const [searchResults, setSearchResults] =
|
|
5366
|
-
const [currentSearchResult, setCurrentSearchResult] =
|
|
5367
|
-
const [searchStartSlide, setSearchStartSlide] =
|
|
5368
|
-
const containerRef =
|
|
5931
|
+
const [currentSlide, setCurrentSlide] = useState12(initialSlide);
|
|
5932
|
+
const [isFullscreen, setIsFullscreen] = useState12(false);
|
|
5933
|
+
const [showTOC, setShowTOC] = useState12(defaultTocOpen);
|
|
5934
|
+
const [showSearch, setShowSearch] = useState12(false);
|
|
5935
|
+
const [searchQuery, setSearchQuery] = useState12("");
|
|
5936
|
+
const [searchResults, setSearchResults] = useState12([]);
|
|
5937
|
+
const [currentSearchResult, setCurrentSearchResult] = useState12(-1);
|
|
5938
|
+
const [searchStartSlide, setSearchStartSlide] = useState12(0);
|
|
5939
|
+
const containerRef = useRef11(null);
|
|
5369
5940
|
const slideTitles = extractAllSlideTitles(slides);
|
|
5370
|
-
const navigateToSlide =
|
|
5941
|
+
const navigateToSlide = useCallback4((slideIndex) => {
|
|
5371
5942
|
if (slideIndex >= 0 && slideIndex < slides.length) {
|
|
5372
5943
|
setCurrentSlide(slideIndex);
|
|
5373
5944
|
onSlideChange?.(slideIndex);
|
|
@@ -5376,7 +5947,7 @@ var SlidePresentation = ({
|
|
|
5376
5947
|
}
|
|
5377
5948
|
}
|
|
5378
5949
|
}, [slides.length, onSlideChange, effectiveTocDisplayMode]);
|
|
5379
|
-
|
|
5950
|
+
useEffect11(() => {
|
|
5380
5951
|
if (!searchQuery.trim()) {
|
|
5381
5952
|
setSearchResults([]);
|
|
5382
5953
|
setCurrentSearchResult(-1);
|
|
@@ -5394,7 +5965,7 @@ var SlidePresentation = ({
|
|
|
5394
5965
|
setSearchResults(results);
|
|
5395
5966
|
setCurrentSearchResult(-1);
|
|
5396
5967
|
}, [searchQuery, slides]);
|
|
5397
|
-
const navigateToSearchResult =
|
|
5968
|
+
const navigateToSearchResult = useCallback4((resultIndex) => {
|
|
5398
5969
|
if (searchResults.length === 0)
|
|
5399
5970
|
return;
|
|
5400
5971
|
let newIndex = resultIndex;
|
|
@@ -5409,22 +5980,22 @@ var SlidePresentation = ({
|
|
|
5409
5980
|
navigateToSlide(targetSlide);
|
|
5410
5981
|
}
|
|
5411
5982
|
}, [searchResults, navigateToSlide, currentSlide, currentSearchResult]);
|
|
5412
|
-
const closeSearch =
|
|
5983
|
+
const closeSearch = useCallback4(() => {
|
|
5413
5984
|
setShowSearch(false);
|
|
5414
5985
|
}, []);
|
|
5415
|
-
const clearSearch =
|
|
5986
|
+
const clearSearch = useCallback4(() => {
|
|
5416
5987
|
setSearchQuery("");
|
|
5417
5988
|
setSearchResults([]);
|
|
5418
5989
|
setCurrentSearchResult(-1);
|
|
5419
5990
|
setSearchStartSlide(0);
|
|
5420
5991
|
}, []);
|
|
5421
|
-
const goToPreviousSlide =
|
|
5992
|
+
const goToPreviousSlide = useCallback4(() => {
|
|
5422
5993
|
navigateToSlide(currentSlide - 1);
|
|
5423
5994
|
}, [currentSlide, navigateToSlide]);
|
|
5424
|
-
const goToNextSlide =
|
|
5995
|
+
const goToNextSlide = useCallback4(() => {
|
|
5425
5996
|
navigateToSlide(currentSlide + 1);
|
|
5426
5997
|
}, [currentSlide, navigateToSlide]);
|
|
5427
|
-
const toggleFullscreen =
|
|
5998
|
+
const toggleFullscreen = useCallback4(() => {
|
|
5428
5999
|
if (!containerRef.current)
|
|
5429
6000
|
return;
|
|
5430
6001
|
if (!isFullscreen) {
|
|
@@ -5435,7 +6006,7 @@ var SlidePresentation = ({
|
|
|
5435
6006
|
setIsFullscreen(false);
|
|
5436
6007
|
}
|
|
5437
6008
|
}, [isFullscreen]);
|
|
5438
|
-
|
|
6009
|
+
useEffect11(() => {
|
|
5439
6010
|
const handleKeyDown = (event) => {
|
|
5440
6011
|
if (event.target instanceof HTMLInputElement || event.target instanceof HTMLTextAreaElement) {
|
|
5441
6012
|
if (showSearch && (event.key === "Tab" || event.key === "Enter" || event.key === "Escape")) {} else {
|
|
@@ -5553,7 +6124,7 @@ var SlidePresentation = ({
|
|
|
5553
6124
|
currentSearchResult,
|
|
5554
6125
|
tocDisplayMode
|
|
5555
6126
|
]);
|
|
5556
|
-
|
|
6127
|
+
useEffect11(() => {
|
|
5557
6128
|
if (currentSlide >= slides.length && slides.length > 0) {
|
|
5558
6129
|
setCurrentSlide(slides.length - 1);
|
|
5559
6130
|
}
|
|
@@ -6014,7 +6585,7 @@ var SlidePresentation = ({
|
|
|
6014
6585
|
};
|
|
6015
6586
|
// industryMarkdown/components/SlidePresentationBook.tsx
|
|
6016
6587
|
import { AnimatedResizableLayout as AnimatedResizableLayout2 } from "@principal-ade/panels";
|
|
6017
|
-
import React18, { useState as
|
|
6588
|
+
import React18, { useState as useState13, useCallback as useCallback5, useRef as useRef12, useEffect as useEffect12 } from "react";
|
|
6018
6589
|
var SlidePresentationBook = ({
|
|
6019
6590
|
slides,
|
|
6020
6591
|
initialSlide = 0,
|
|
@@ -6044,8 +6615,8 @@ var SlidePresentationBook = ({
|
|
|
6044
6615
|
repositoryInfo,
|
|
6045
6616
|
width
|
|
6046
6617
|
}) => {
|
|
6047
|
-
const [isMobile, setIsMobile] =
|
|
6048
|
-
|
|
6618
|
+
const [isMobile, setIsMobile] = useState13(false);
|
|
6619
|
+
useEffect12(() => {
|
|
6049
6620
|
const checkMobile = () => {
|
|
6050
6621
|
setIsMobile(/iPhone|iPad|iPod|Android/i.test(navigator.userAgent) || window.innerWidth < 768);
|
|
6051
6622
|
};
|
|
@@ -6056,20 +6627,20 @@ var SlidePresentationBook = ({
|
|
|
6056
6627
|
const effectiveTocDisplayMode = isMobile && viewMode === "single" ? "overlay" : tocDisplayMode ?? (viewMode === "single" ? "sidebar" : "overlay");
|
|
6057
6628
|
const defaultTocOpen = initialTocOpen ?? false;
|
|
6058
6629
|
const adjustedInitialSlide = viewMode === "book" ? Math.floor(initialSlide / 2) * 2 : initialSlide;
|
|
6059
|
-
const [currentSlide, setCurrentSlide] =
|
|
6060
|
-
const [isFullscreen, setIsFullscreen] =
|
|
6061
|
-
const [showTOC, setShowTOC] =
|
|
6062
|
-
const [showSearch, setShowSearch] =
|
|
6063
|
-
const [searchQuery, setSearchQuery] =
|
|
6064
|
-
const [searchResults, setSearchResults] =
|
|
6065
|
-
const [currentSearchResult, setCurrentSearchResult] =
|
|
6066
|
-
const [searchStartSlide, setSearchStartSlide] =
|
|
6067
|
-
const [collapsedSide, setCollapsedSide] =
|
|
6068
|
-
const [lastInteractedSide, setLastInteractedSide] =
|
|
6069
|
-
const containerRef =
|
|
6630
|
+
const [currentSlide, setCurrentSlide] = useState13(adjustedInitialSlide);
|
|
6631
|
+
const [isFullscreen, setIsFullscreen] = useState13(false);
|
|
6632
|
+
const [showTOC, setShowTOC] = useState13(defaultTocOpen);
|
|
6633
|
+
const [showSearch, setShowSearch] = useState13(false);
|
|
6634
|
+
const [searchQuery, setSearchQuery] = useState13("");
|
|
6635
|
+
const [searchResults, setSearchResults] = useState13([]);
|
|
6636
|
+
const [currentSearchResult, setCurrentSearchResult] = useState13(-1);
|
|
6637
|
+
const [searchStartSlide, setSearchStartSlide] = useState13(0);
|
|
6638
|
+
const [collapsedSide, setCollapsedSide] = useState13(null);
|
|
6639
|
+
const [lastInteractedSide, setLastInteractedSide] = useState13("left");
|
|
6640
|
+
const containerRef = useRef12(null);
|
|
6070
6641
|
const slideTitles = extractAllSlideTitles(slides);
|
|
6071
6642
|
const stepSize = viewMode === "book" ? 2 : 1;
|
|
6072
|
-
const navigateToSlide =
|
|
6643
|
+
const navigateToSlide = useCallback5((slideIndex) => {
|
|
6073
6644
|
const targetSlide = viewMode === "book" ? Math.floor(slideIndex / 2) * 2 : slideIndex;
|
|
6074
6645
|
if (targetSlide >= 0 && targetSlide < slides.length) {
|
|
6075
6646
|
setCurrentSlide(targetSlide);
|
|
@@ -6079,7 +6650,7 @@ var SlidePresentationBook = ({
|
|
|
6079
6650
|
}
|
|
6080
6651
|
}
|
|
6081
6652
|
}, [slides.length, onSlideChange, viewMode, effectiveTocDisplayMode]);
|
|
6082
|
-
|
|
6653
|
+
useEffect12(() => {
|
|
6083
6654
|
if (!searchQuery.trim()) {
|
|
6084
6655
|
setSearchResults([]);
|
|
6085
6656
|
setCurrentSearchResult(-1);
|
|
@@ -6097,7 +6668,7 @@ var SlidePresentationBook = ({
|
|
|
6097
6668
|
setSearchResults(results);
|
|
6098
6669
|
setCurrentSearchResult(-1);
|
|
6099
6670
|
}, [searchQuery, slides]);
|
|
6100
|
-
const navigateToSearchResult =
|
|
6671
|
+
const navigateToSearchResult = useCallback5((resultIndex) => {
|
|
6101
6672
|
if (searchResults.length === 0)
|
|
6102
6673
|
return;
|
|
6103
6674
|
let newIndex = resultIndex;
|
|
@@ -6112,22 +6683,22 @@ var SlidePresentationBook = ({
|
|
|
6112
6683
|
navigateToSlide(targetSlide);
|
|
6113
6684
|
}
|
|
6114
6685
|
}, [searchResults, navigateToSlide, currentSlide, currentSearchResult]);
|
|
6115
|
-
const closeSearch =
|
|
6686
|
+
const closeSearch = useCallback5(() => {
|
|
6116
6687
|
setShowSearch(false);
|
|
6117
6688
|
}, []);
|
|
6118
|
-
const clearSearch =
|
|
6689
|
+
const clearSearch = useCallback5(() => {
|
|
6119
6690
|
setSearchQuery("");
|
|
6120
6691
|
setSearchResults([]);
|
|
6121
6692
|
setCurrentSearchResult(-1);
|
|
6122
6693
|
setSearchStartSlide(0);
|
|
6123
6694
|
}, []);
|
|
6124
|
-
const goToPreviousSlide =
|
|
6695
|
+
const goToPreviousSlide = useCallback5(() => {
|
|
6125
6696
|
navigateToSlide(currentSlide - stepSize);
|
|
6126
6697
|
}, [currentSlide, navigateToSlide, stepSize]);
|
|
6127
|
-
const goToNextSlide =
|
|
6698
|
+
const goToNextSlide = useCallback5(() => {
|
|
6128
6699
|
navigateToSlide(currentSlide + stepSize);
|
|
6129
6700
|
}, [currentSlide, navigateToSlide, stepSize]);
|
|
6130
|
-
const handleCollapseLeft =
|
|
6701
|
+
const handleCollapseLeft = useCallback5(() => {
|
|
6131
6702
|
if (collapsedSide === "left") {
|
|
6132
6703
|
setCollapsedSide(null);
|
|
6133
6704
|
} else if (collapsedSide === "right") {
|
|
@@ -6137,7 +6708,7 @@ var SlidePresentationBook = ({
|
|
|
6137
6708
|
setCollapsedSide("right");
|
|
6138
6709
|
}
|
|
6139
6710
|
}, [collapsedSide]);
|
|
6140
|
-
const handleCollapseRight =
|
|
6711
|
+
const handleCollapseRight = useCallback5(() => {
|
|
6141
6712
|
if (collapsedSide === "right") {
|
|
6142
6713
|
setCollapsedSide(null);
|
|
6143
6714
|
} else if (collapsedSide === "left") {
|
|
@@ -6147,7 +6718,7 @@ var SlidePresentationBook = ({
|
|
|
6147
6718
|
setCollapsedSide("left");
|
|
6148
6719
|
}
|
|
6149
6720
|
}, [collapsedSide]);
|
|
6150
|
-
const toggleFullscreen =
|
|
6721
|
+
const toggleFullscreen = useCallback5(() => {
|
|
6151
6722
|
if (!containerRef.current)
|
|
6152
6723
|
return;
|
|
6153
6724
|
if (!isFullscreen) {
|
|
@@ -6158,7 +6729,7 @@ var SlidePresentationBook = ({
|
|
|
6158
6729
|
setIsFullscreen(false);
|
|
6159
6730
|
}
|
|
6160
6731
|
}, [isFullscreen]);
|
|
6161
|
-
|
|
6732
|
+
useEffect12(() => {
|
|
6162
6733
|
const handleKeyDown = (event) => {
|
|
6163
6734
|
if (event.target instanceof HTMLInputElement || event.target instanceof HTMLTextAreaElement) {
|
|
6164
6735
|
if (showSearch && (event.key === "Tab" || event.key === "Enter" || event.key === "Escape")) {} else {
|
|
@@ -6277,7 +6848,7 @@ var SlidePresentationBook = ({
|
|
|
6277
6848
|
searchResults,
|
|
6278
6849
|
effectiveTocDisplayMode
|
|
6279
6850
|
]);
|
|
6280
|
-
|
|
6851
|
+
useEffect12(() => {
|
|
6281
6852
|
if (currentSlide >= slides.length && slides.length > 0) {
|
|
6282
6853
|
setCurrentSlide(slides.length - 1);
|
|
6283
6854
|
}
|
|
@@ -6940,7 +7511,7 @@ var SlidePresentationBook = ({
|
|
|
6940
7511
|
}));
|
|
6941
7512
|
};
|
|
6942
7513
|
// industryMarkdown/components/DocumentView.tsx
|
|
6943
|
-
import React19, { useRef as
|
|
7514
|
+
import React19, { useRef as useRef13 } from "react";
|
|
6944
7515
|
var DocumentView = ({
|
|
6945
7516
|
content,
|
|
6946
7517
|
onCheckboxChange,
|
|
@@ -6965,7 +7536,7 @@ var DocumentView = ({
|
|
|
6965
7536
|
onAnnotationClick,
|
|
6966
7537
|
annotationStyle
|
|
6967
7538
|
}) => {
|
|
6968
|
-
const containerRef =
|
|
7539
|
+
const containerRef = useRef13(null);
|
|
6969
7540
|
const backgroundColor = transparentBackground ? "transparent" : theme2.colors.background;
|
|
6970
7541
|
return /* @__PURE__ */ React19.createElement("div", {
|
|
6971
7542
|
ref: containerRef,
|
|
@@ -7429,6 +8000,9 @@ export {
|
|
|
7429
8000
|
createPresentationWithErrorMessage,
|
|
7430
8001
|
createIndustryMarkdownComponents,
|
|
7431
8002
|
createGithubFileSource,
|
|
8003
|
+
computeTextDeletion,
|
|
8004
|
+
computeDeletion,
|
|
8005
|
+
computeChunkOffsets,
|
|
7432
8006
|
ThemeProvider,
|
|
7433
8007
|
SlideSearchBar,
|
|
7434
8008
|
SlidePresentationBook,
|