tiptap-markdown-react 0.14.1 → 0.14.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -1
- package/dist/index.js +47 -36
- package/dist/index.js.map +1 -1
- package/dist/style.css +51 -52
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -258,7 +258,6 @@ Override any of these CSS variables on an ancestor (e.g. `:root` or the editor c
|
|
|
258
258
|
| `--tmr-line-height` | `1.7` | Content line height |
|
|
259
259
|
| `--tmr-min-height` | `420px` | Editor min height |
|
|
260
260
|
| `--tmr-code-bg` | `#f4f4f4` | Inline code background |
|
|
261
|
-
| `--tmr-code-max-height` | `480px` | Readonly code block max height (long blocks scroll internally; the header toggle expands to full height; `none` disables the cap). Editable code blocks are never capped |
|
|
262
261
|
| `--tmr-table-header-bg` | `#f7f7f7` | Table header background |
|
|
263
262
|
| `--tmr-comment-ring` | `rgba(219, 171, 10, 0.55)` | Active mark / block outline ring |
|
|
264
263
|
| `--tmr-comment-gutter-bg` | `#f4b400` | Gutter bubble background |
|
package/dist/index.js
CHANGED
|
@@ -1292,25 +1292,25 @@ function createChart(options = {}) {
|
|
|
1292
1292
|
}
|
|
1293
1293
|
});
|
|
1294
1294
|
}
|
|
1295
|
-
const wrapper = "
|
|
1296
|
-
const header$1 = "
|
|
1297
|
-
const langTrigger = "
|
|
1298
|
-
const langChevron = "
|
|
1299
|
-
const readonlyHeader = "
|
|
1300
|
-
const langBadge = "
|
|
1301
|
-
const langMenu = "
|
|
1302
|
-
const langItem = "
|
|
1303
|
-
const langItemSelected = "
|
|
1304
|
-
const langItemCheck = "
|
|
1305
|
-
const deleteBtn = "
|
|
1306
|
-
const pre = "
|
|
1307
|
-
const readonly = "
|
|
1308
|
-
const
|
|
1309
|
-
const gutter = "
|
|
1310
|
-
const gutterLine = "
|
|
1311
|
-
const readonlyActions = "
|
|
1312
|
-
const actionBtn = "
|
|
1313
|
-
const langBraces = "
|
|
1295
|
+
const wrapper = "_wrapper_k8th1_2";
|
|
1296
|
+
const header$1 = "_header_k8th1_18";
|
|
1297
|
+
const langTrigger = "_langTrigger_k8th1_28";
|
|
1298
|
+
const langChevron = "_langChevron_k8th1_50";
|
|
1299
|
+
const readonlyHeader = "_readonlyHeader_k8th1_56";
|
|
1300
|
+
const langBadge = "_langBadge_k8th1_64";
|
|
1301
|
+
const langMenu = "_langMenu_k8th1_78";
|
|
1302
|
+
const langItem = "_langItem_k8th1_91";
|
|
1303
|
+
const langItemSelected = "_langItemSelected_k8th1_110";
|
|
1304
|
+
const langItemCheck = "_langItemCheck_k8th1_115";
|
|
1305
|
+
const deleteBtn = "_deleteBtn_k8th1_123";
|
|
1306
|
+
const pre = "_pre_k8th1_143";
|
|
1307
|
+
const readonly = "_readonly_k8th1_56";
|
|
1308
|
+
const folded = "_folded_k8th1_161";
|
|
1309
|
+
const gutter = "_gutter_k8th1_167";
|
|
1310
|
+
const gutterLine = "_gutterLine_k8th1_184";
|
|
1311
|
+
const readonlyActions = "_readonlyActions_k8th1_188";
|
|
1312
|
+
const actionBtn = "_actionBtn_k8th1_194";
|
|
1313
|
+
const langBraces = "_langBraces_k8th1_213";
|
|
1314
1314
|
const styles$4 = {
|
|
1315
1315
|
wrapper,
|
|
1316
1316
|
header: header$1,
|
|
@@ -1325,7 +1325,7 @@ const styles$4 = {
|
|
|
1325
1325
|
deleteBtn,
|
|
1326
1326
|
pre,
|
|
1327
1327
|
readonly,
|
|
1328
|
-
|
|
1328
|
+
folded,
|
|
1329
1329
|
gutter,
|
|
1330
1330
|
gutterLine,
|
|
1331
1331
|
readonlyActions,
|
|
@@ -1370,8 +1370,7 @@ function CodeBlockView({
|
|
|
1370
1370
|
const editable = editor.isEditable;
|
|
1371
1371
|
const readonly2 = !editable;
|
|
1372
1372
|
const [copied, setCopied] = useState(false);
|
|
1373
|
-
const [
|
|
1374
|
-
const [scrollable, setScrollable] = useState(false);
|
|
1373
|
+
const [folded2, setFolded] = useState(false);
|
|
1375
1374
|
const [lineCount, setLineCount] = useState(
|
|
1376
1375
|
() => Math.max((node.textContent ?? "").split("\n").length, 1)
|
|
1377
1376
|
);
|
|
@@ -1382,17 +1381,12 @@ function CodeBlockView({
|
|
|
1382
1381
|
if (!pre2) return;
|
|
1383
1382
|
const update = () => {
|
|
1384
1383
|
setLineCount(Math.max((pre2.textContent ?? "").split("\n").length, 1));
|
|
1385
|
-
setScrollable(pre2.scrollHeight > pre2.clientHeight + 2);
|
|
1386
1384
|
};
|
|
1387
1385
|
update();
|
|
1388
1386
|
const mo = new MutationObserver(update);
|
|
1389
1387
|
mo.observe(pre2, { childList: true, subtree: true, characterData: true });
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
mo.disconnect();
|
|
1393
|
-
window.removeEventListener("resize", update);
|
|
1394
|
-
};
|
|
1395
|
-
}, [readonly2, expanded2]);
|
|
1388
|
+
return () => mo.disconnect();
|
|
1389
|
+
}, [readonly2]);
|
|
1396
1390
|
const handleCopy = () => {
|
|
1397
1391
|
var _a2;
|
|
1398
1392
|
const text = node.textContent ?? "";
|
|
@@ -1419,7 +1413,7 @@ function CodeBlockView({
|
|
|
1419
1413
|
const wrapperClass = [
|
|
1420
1414
|
styles$4.wrapper,
|
|
1421
1415
|
readonly2 ? styles$4.readonly : "",
|
|
1422
|
-
|
|
1416
|
+
folded2 ? styles$4.folded : ""
|
|
1423
1417
|
].filter(Boolean).join(" ");
|
|
1424
1418
|
return /* @__PURE__ */ jsxs(NodeViewWrapper, { className: wrapperClass, children: [
|
|
1425
1419
|
editable ? /* @__PURE__ */ jsxs("div", { className: styles$4.header, contentEditable: false, children: [
|
|
@@ -1491,18 +1485,18 @@ function CodeBlockView({
|
|
|
1491
1485
|
children: copied ? /* @__PURE__ */ jsx(CheckIcon, { size: 14 }) : /* @__PURE__ */ jsx(CopyIcon, { size: 14 })
|
|
1492
1486
|
}
|
|
1493
1487
|
),
|
|
1494
|
-
|
|
1488
|
+
/* @__PURE__ */ jsx(
|
|
1495
1489
|
"button",
|
|
1496
1490
|
{
|
|
1497
1491
|
type: "button",
|
|
1498
1492
|
className: styles$4.actionBtn,
|
|
1499
|
-
onClick: () =>
|
|
1500
|
-
"aria-label":
|
|
1501
|
-
title:
|
|
1502
|
-
"aria-expanded":
|
|
1493
|
+
onClick: () => setFolded((v) => !v),
|
|
1494
|
+
"aria-label": folded2 ? labels.expand : labels.collapse,
|
|
1495
|
+
title: folded2 ? labels.expand : labels.collapse,
|
|
1496
|
+
"aria-expanded": !folded2,
|
|
1503
1497
|
children: /* @__PURE__ */ jsx(ChevronsUpDownIcon, { size: 14 })
|
|
1504
1498
|
}
|
|
1505
|
-
)
|
|
1499
|
+
)
|
|
1506
1500
|
] })
|
|
1507
1501
|
] })
|
|
1508
1502
|
),
|
|
@@ -1888,6 +1882,23 @@ function MarkdownPreview({
|
|
|
1888
1882
|
},
|
|
1889
1883
|
[extensions]
|
|
1890
1884
|
);
|
|
1885
|
+
useEffect(() => {
|
|
1886
|
+
if (!editor) return;
|
|
1887
|
+
const strip = () => {
|
|
1888
|
+
const { doc, tr } = editor.state;
|
|
1889
|
+
const last = doc.lastChild;
|
|
1890
|
+
if (doc.childCount > 1 && (last == null ? void 0 : last.type.name) === "paragraph" && last.content.size === 0) {
|
|
1891
|
+
editor.view.dispatch(
|
|
1892
|
+
tr.delete(doc.content.size - last.nodeSize, doc.content.size)
|
|
1893
|
+
);
|
|
1894
|
+
}
|
|
1895
|
+
};
|
|
1896
|
+
strip();
|
|
1897
|
+
editor.on("update", strip);
|
|
1898
|
+
return () => {
|
|
1899
|
+
editor.off("update", strip);
|
|
1900
|
+
};
|
|
1901
|
+
}, [editor]);
|
|
1891
1902
|
useEffect(() => {
|
|
1892
1903
|
if (!editor) return;
|
|
1893
1904
|
editor.commands.setContent(prepared, { contentType: "markdown" });
|