@zuilib/text-editor 0.10.0 → 0.11.0
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 +28 -0
- package/README.md +41 -25
- package/dist/index.d.ts +54 -27
- package/dist/index.js +283 -270
- package/dist/styles.css +78 -34
- package/package.json +9 -5
package/dist/index.js
CHANGED
|
@@ -1611,7 +1611,6 @@ function MarkdownSyncPlugin({
|
|
|
1611
1611
|
import { useEffect as useEffect5 } from "react";
|
|
1612
1612
|
import { useLexicalComposerContext as useLexicalComposerContext5 } from "@lexical/react/LexicalComposerContext";
|
|
1613
1613
|
import { $getSelection as $getSelection4, $isRangeSelection as $isRangeSelection4, COMMAND_PRIORITY_HIGH, KEY_DOWN_COMMAND } from "lexical";
|
|
1614
|
-
import { $isTableRowNode as $isTableRowNode2 } from "@lexical/table";
|
|
1615
1614
|
|
|
1616
1615
|
// src/transformers/tableSettings.ts
|
|
1617
1616
|
import {
|
|
@@ -1755,7 +1754,7 @@ function formatTableSettingsMarker(settings, options = {}) {
|
|
|
1755
1754
|
return pairs.length > 0 ? `<!-- ${pairs.join("; ")} -->` : null;
|
|
1756
1755
|
}
|
|
1757
1756
|
|
|
1758
|
-
// src/transformers/
|
|
1757
|
+
// src/transformers/tableGrid.ts
|
|
1759
1758
|
import {
|
|
1760
1759
|
$createParagraphNode as $createParagraphNode2,
|
|
1761
1760
|
$getNodeByKey as $getNodeByKey3,
|
|
@@ -1782,6 +1781,19 @@ function $isHeaderRow(row) {
|
|
|
1782
1781
|
const cells = row ? $cells(row) : [];
|
|
1783
1782
|
return cells.length > 0 && cells.every((cell) => cell.hasHeaderState(TableCellHeaderStates.ROW));
|
|
1784
1783
|
}
|
|
1784
|
+
function $columnCount(table) {
|
|
1785
|
+
const first = $rows(table)[0];
|
|
1786
|
+
return first ? $cells(first).length : 0;
|
|
1787
|
+
}
|
|
1788
|
+
function $emptyCell(headerState) {
|
|
1789
|
+
return $createTableCellNode(headerState).append($createParagraphNode2());
|
|
1790
|
+
}
|
|
1791
|
+
function $selectCellAt(table, row, column) {
|
|
1792
|
+
const rows = $rows(table);
|
|
1793
|
+
const target = rows[Math.max(0, Math.min(row, rows.length - 1))];
|
|
1794
|
+
const cells = target ? $cells(target) : [];
|
|
1795
|
+
cells[Math.max(0, Math.min(column, cells.length - 1))]?.selectStart();
|
|
1796
|
+
}
|
|
1785
1797
|
function $getSelectedTableCell() {
|
|
1786
1798
|
const selection = $getSelection3();
|
|
1787
1799
|
let node = null;
|
|
@@ -1791,29 +1803,27 @@ function $getSelectedTableCell() {
|
|
|
1791
1803
|
const cell = $findMatchingParent2(node, (n2) => $isTableCellNode(n2));
|
|
1792
1804
|
return $isTableCellNode(cell) ? cell : null;
|
|
1793
1805
|
}
|
|
1794
|
-
function $
|
|
1806
|
+
function $getTableCellPosition() {
|
|
1795
1807
|
const cell = $getSelectedTableCell();
|
|
1796
1808
|
const row = cell?.getParent();
|
|
1797
1809
|
const table = row?.getParent();
|
|
1798
1810
|
if (!cell || !$isTableRowNode(row) || !$isTableNode2(table)) return null;
|
|
1799
1811
|
const rows = $rows(table);
|
|
1800
1812
|
return {
|
|
1801
|
-
|
|
1813
|
+
row: rows.indexOf(row),
|
|
1802
1814
|
column: $cells(row).indexOf(cell),
|
|
1803
|
-
|
|
1815
|
+
rows: rows.length,
|
|
1816
|
+
columns: $columnCount(table),
|
|
1804
1817
|
hasHeader: $isHeaderRow(rows[0])
|
|
1805
1818
|
};
|
|
1806
1819
|
}
|
|
1807
1820
|
function insertableRowIndices(position) {
|
|
1808
1821
|
const indices = [];
|
|
1809
|
-
for (let i = position.hasHeader ? 1 : 0; i <= position.
|
|
1822
|
+
for (let i = position.hasHeader ? 1 : 0; i <= position.rows; i++) indices.push(i);
|
|
1810
1823
|
return indices;
|
|
1811
1824
|
}
|
|
1812
1825
|
function canDeleteRow(position) {
|
|
1813
|
-
return position.
|
|
1814
|
-
}
|
|
1815
|
-
function $selectCell(cell) {
|
|
1816
|
-
cell?.selectStart();
|
|
1826
|
+
return position.rows > 1;
|
|
1817
1827
|
}
|
|
1818
1828
|
function $insertTableRowAt(table, index, column = 0) {
|
|
1819
1829
|
const rows = $rows(table);
|
|
@@ -1823,16 +1833,16 @@ function $insertTableRowAt(table, index, column = 0) {
|
|
|
1823
1833
|
const referenceCells = reference ? $cells(reference) : [];
|
|
1824
1834
|
const row = $createTableRowNode();
|
|
1825
1835
|
for (const cell of referenceCells) {
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1836
|
+
row.append(
|
|
1837
|
+
$emptyCell(
|
|
1838
|
+
cell.hasHeaderState(TableCellHeaderStates.COLUMN) ? TableCellHeaderStates.COLUMN : TableCellHeaderStates.NO_STATUS
|
|
1839
|
+
)
|
|
1840
|
+
);
|
|
1831
1841
|
}
|
|
1842
|
+
if (referenceCells.length === 0) row.append($emptyCell(TableCellHeaderStates.NO_STATUS));
|
|
1832
1843
|
if (at >= rows.length) table.append(row);
|
|
1833
1844
|
else rows[at].insertBefore(row);
|
|
1834
|
-
|
|
1835
|
-
$selectCell(cells[Math.min(column, cells.length - 1)]);
|
|
1845
|
+
$selectCellAt(table, at, column);
|
|
1836
1846
|
return row;
|
|
1837
1847
|
}
|
|
1838
1848
|
function $deleteTableRowAt(table, index, column = 0) {
|
|
@@ -1847,20 +1857,56 @@ function $deleteTableRowAt(table, index, column = 0) {
|
|
|
1847
1857
|
cell.setHeaderStyles(TableCellHeaderStates.ROW, TableCellHeaderStates.ROW);
|
|
1848
1858
|
}
|
|
1849
1859
|
}
|
|
1850
|
-
|
|
1851
|
-
const cells = $cells(target);
|
|
1852
|
-
$selectCell(cells[Math.min(column, cells.length - 1)]);
|
|
1860
|
+
$selectCellAt(table, index, column);
|
|
1853
1861
|
return true;
|
|
1854
1862
|
}
|
|
1855
1863
|
function $insertTableRowNear(table, position) {
|
|
1856
|
-
const at = $
|
|
1864
|
+
const at = $getTableCellPosition();
|
|
1857
1865
|
if (!at) return null;
|
|
1858
|
-
return $insertTableRowAt(table, position === "below" ? at.
|
|
1866
|
+
return $insertTableRowAt(table, position === "below" ? at.row + 1 : at.row, at.column);
|
|
1859
1867
|
}
|
|
1860
1868
|
function $deleteSelectedTableRow(table) {
|
|
1861
|
-
const at = $
|
|
1869
|
+
const at = $getTableCellPosition();
|
|
1862
1870
|
if (!at || !canDeleteRow(at)) return false;
|
|
1863
|
-
return $deleteTableRowAt(table, at.
|
|
1871
|
+
return $deleteTableRowAt(table, at.row, at.column);
|
|
1872
|
+
}
|
|
1873
|
+
function insertableColumnIndices(position) {
|
|
1874
|
+
const indices = [];
|
|
1875
|
+
for (let i = 0; i <= position.columns; i++) indices.push(i);
|
|
1876
|
+
return indices;
|
|
1877
|
+
}
|
|
1878
|
+
function canDeleteColumn(position) {
|
|
1879
|
+
return position.columns > 1;
|
|
1880
|
+
}
|
|
1881
|
+
function $insertTableColumnAt(table, index, row = 0) {
|
|
1882
|
+
const at = Math.max(0, Math.min(index, $columnCount(table)));
|
|
1883
|
+
for (const tableRow of $rows(table)) {
|
|
1884
|
+
const cells = $cells(tableRow);
|
|
1885
|
+
const cell = $emptyCell(
|
|
1886
|
+
$isHeaderRow(tableRow) ? TableCellHeaderStates.ROW : TableCellHeaderStates.NO_STATUS
|
|
1887
|
+
);
|
|
1888
|
+
if (at < cells.length) cells[at].insertBefore(cell);
|
|
1889
|
+
else tableRow.append(cell);
|
|
1890
|
+
}
|
|
1891
|
+
$selectCellAt(table, row, at);
|
|
1892
|
+
}
|
|
1893
|
+
function $deleteTableColumnAt(table, index, row = 0) {
|
|
1894
|
+
const columns = $columnCount(table);
|
|
1895
|
+
if (index < 0 || index >= columns || columns < 2) return false;
|
|
1896
|
+
for (const tableRow of $rows(table)) $cells(tableRow)[index]?.remove();
|
|
1897
|
+
$selectCellAt(table, row, index);
|
|
1898
|
+
return true;
|
|
1899
|
+
}
|
|
1900
|
+
function $insertTableColumnNear(table, position) {
|
|
1901
|
+
const at = $getTableCellPosition();
|
|
1902
|
+
if (!at) return false;
|
|
1903
|
+
$insertTableColumnAt(table, position === "after" ? at.column + 1 : at.column, at.row);
|
|
1904
|
+
return true;
|
|
1905
|
+
}
|
|
1906
|
+
function $deleteSelectedTableColumn(table) {
|
|
1907
|
+
const at = $getTableCellPosition();
|
|
1908
|
+
if (!at || !canDeleteColumn(at)) return false;
|
|
1909
|
+
return $deleteTableColumnAt(table, at.column, at.row);
|
|
1864
1910
|
}
|
|
1865
1911
|
|
|
1866
1912
|
// src/plugins/TableRowShortcutsPlugin.tsx
|
|
@@ -1881,16 +1927,14 @@ function TableRowShortcutsPlugin() {
|
|
|
1881
1927
|
const shortcut = shortcutFor(event);
|
|
1882
1928
|
if (!shortcut) return false;
|
|
1883
1929
|
const table = $getSelectedTable();
|
|
1884
|
-
const position = $
|
|
1930
|
+
const position = $getTableCellPosition();
|
|
1885
1931
|
if (!table || !position) return false;
|
|
1886
1932
|
if (shortcut === "tab") {
|
|
1887
1933
|
const selection = $getSelection4();
|
|
1888
|
-
const
|
|
1889
|
-
const columns = $isTableRowNode2(firstRow) ? firstRow.getChildrenSize() : 0;
|
|
1890
|
-
const isLastCell = position.index === position.count - 1 && position.column === columns - 1;
|
|
1934
|
+
const isLastCell = position.row === position.rows - 1 && position.column === position.columns - 1;
|
|
1891
1935
|
if (!isLastCell || !$isRangeSelection4(selection) || !selection.isCollapsed()) return false;
|
|
1892
1936
|
event.preventDefault();
|
|
1893
|
-
$insertTableRowAt(table, position.
|
|
1937
|
+
$insertTableRowAt(table, position.rows);
|
|
1894
1938
|
return true;
|
|
1895
1939
|
}
|
|
1896
1940
|
event.preventDefault();
|
|
@@ -5915,7 +5959,7 @@ import {
|
|
|
5915
5959
|
$createTableRowNode as $createTableRowNode2,
|
|
5916
5960
|
$isTableCellNode as $isTableCellNode2,
|
|
5917
5961
|
$isTableNode as $isTableNode3,
|
|
5918
|
-
$isTableRowNode as $
|
|
5962
|
+
$isTableRowNode as $isTableRowNode2,
|
|
5919
5963
|
TableCellHeaderStates as TableCellHeaderStates2,
|
|
5920
5964
|
TableCellNode,
|
|
5921
5965
|
TableNode,
|
|
@@ -5930,7 +5974,7 @@ function $getMarkerSettings(node) {
|
|
|
5930
5974
|
}
|
|
5931
5975
|
function getTableColumnsSize(table) {
|
|
5932
5976
|
const row = table.getFirstChild();
|
|
5933
|
-
return $
|
|
5977
|
+
return $isTableRowNode2(row) ? row.getChildrenSize() : 0;
|
|
5934
5978
|
}
|
|
5935
5979
|
function createTableCell(textContent) {
|
|
5936
5980
|
const unescaped = textContent.replace(/\\n/g, "\n");
|
|
@@ -5953,7 +5997,7 @@ var TABLE = {
|
|
|
5953
5997
|
});
|
|
5954
5998
|
if (marker) output.push(marker);
|
|
5955
5999
|
for (const row of node.getChildren()) {
|
|
5956
|
-
if (!$
|
|
6000
|
+
if (!$isTableRowNode2(row)) continue;
|
|
5957
6001
|
const rowOutput = [];
|
|
5958
6002
|
let isHeaderRow = false;
|
|
5959
6003
|
for (const cell of row.getChildren()) {
|
|
@@ -5978,7 +6022,7 @@ var TABLE = {
|
|
|
5978
6022
|
const table2 = parentNode.getPreviousSibling();
|
|
5979
6023
|
if (!table2 || !$isTableNode3(table2)) return;
|
|
5980
6024
|
const lastRow = table2.getLastChild();
|
|
5981
|
-
if (!lastRow || !$
|
|
6025
|
+
if (!lastRow || !$isTableRowNode2(lastRow)) return;
|
|
5982
6026
|
lastRow.getChildren().forEach((cell) => {
|
|
5983
6027
|
if ($isTableCellNode2(cell)) {
|
|
5984
6028
|
cell.setHeaderStyles(TableCellHeaderStates2.ROW, TableCellHeaderStates2.ROW);
|
|
@@ -6365,139 +6409,98 @@ import { useCallback as useCallback7 } from "react";
|
|
|
6365
6409
|
import { useLexicalComposerContext as useLexicalComposerContext11 } from "@lexical/react/LexicalComposerContext";
|
|
6366
6410
|
import { useLexicalEditable as useLexicalEditable2 } from "@lexical/react/useLexicalEditable";
|
|
6367
6411
|
|
|
6368
|
-
// src/components/
|
|
6412
|
+
// src/components/TableRail.tsx
|
|
6369
6413
|
import { useCallback as useCallback4, useRef as useRef7, useState as useState6 } from "react";
|
|
6370
6414
|
import { jsx as jsx14, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
6371
|
-
var TABLE_RAIL_WIDTH = 28;
|
|
6372
|
-
|
|
6415
|
+
var TABLE_RAIL_WIDTH = { row: 28, column: 24 };
|
|
6416
|
+
var NAMES = { row: "row", column: "column" };
|
|
6417
|
+
function TableRail({
|
|
6418
|
+
axis,
|
|
6419
|
+
box,
|
|
6420
|
+
lanes,
|
|
6421
|
+
current,
|
|
6422
|
+
insertable,
|
|
6423
|
+
canDelete,
|
|
6424
|
+
onInsert,
|
|
6425
|
+
onDelete
|
|
6426
|
+
}) {
|
|
6373
6427
|
const rail = useRef7(null);
|
|
6374
|
-
const [
|
|
6375
|
-
const
|
|
6428
|
+
const [pointer, setPointer] = useState6(null);
|
|
6429
|
+
const width = TABLE_RAIL_WIDTH[axis];
|
|
6430
|
+
const vertical = axis === "row";
|
|
6431
|
+
const boundary = useCallback4(
|
|
6376
6432
|
(index) => {
|
|
6377
|
-
if (index <
|
|
6378
|
-
const last =
|
|
6379
|
-
return last ? last.
|
|
6433
|
+
if (index < lanes.length) return lanes[index].start;
|
|
6434
|
+
const last = lanes[lanes.length - 1];
|
|
6435
|
+
return last ? last.start + last.size : 0;
|
|
6380
6436
|
},
|
|
6381
|
-
[
|
|
6437
|
+
[lanes]
|
|
6382
6438
|
);
|
|
6383
6439
|
const onPointerMove = useCallback4(
|
|
6384
6440
|
(event) => {
|
|
6385
|
-
const
|
|
6386
|
-
if (!
|
|
6387
|
-
|
|
6388
|
-
let nearest = null;
|
|
6389
|
-
let distance = Number.POSITIVE_INFINITY;
|
|
6390
|
-
for (const index of insertableRowIndices(position)) {
|
|
6391
|
-
const d = Math.abs(boundaryTop(index) - y);
|
|
6392
|
-
if (d < distance) {
|
|
6393
|
-
distance = d;
|
|
6394
|
-
nearest = index;
|
|
6395
|
-
}
|
|
6396
|
-
}
|
|
6397
|
-
setHovered(nearest);
|
|
6441
|
+
const rect = rail.current?.getBoundingClientRect();
|
|
6442
|
+
if (!rect) return;
|
|
6443
|
+
setPointer(vertical ? event.clientY - rect.top : event.clientX - rect.left);
|
|
6398
6444
|
},
|
|
6399
|
-
[
|
|
6445
|
+
[vertical]
|
|
6400
6446
|
);
|
|
6401
|
-
if (
|
|
6402
|
-
const
|
|
6403
|
-
|
|
6404
|
-
|
|
6447
|
+
if (lanes.length === 0) return null;
|
|
6448
|
+
const handle = (() => {
|
|
6449
|
+
if (pointer === null) return { mode: "insert", index: lanes.length };
|
|
6450
|
+
let nearest = lanes.length;
|
|
6451
|
+
let distance = Number.POSITIVE_INFINITY;
|
|
6452
|
+
for (const index of insertable) {
|
|
6453
|
+
const d = Math.abs(boundary(index) - pointer);
|
|
6454
|
+
if (d < distance) {
|
|
6455
|
+
distance = d;
|
|
6456
|
+
nearest = index;
|
|
6457
|
+
}
|
|
6458
|
+
}
|
|
6459
|
+
const under = lanes.findIndex((lane2) => pointer >= lane2.start && pointer < lane2.start + lane2.size);
|
|
6460
|
+
const lane = lanes[under];
|
|
6461
|
+
const threshold = lane ? Math.min(10, lane.size * 0.3) : 0;
|
|
6462
|
+
if (!canDelete || under === -1 || distance <= threshold) return { mode: "insert", index: nearest };
|
|
6463
|
+
return { mode: "delete", index: under };
|
|
6464
|
+
})();
|
|
6465
|
+
const at = (value) => vertical ? { top: value } : { left: value };
|
|
6466
|
+
const span = (lane) => vertical ? { top: lane.start + 3, height: Math.max(4, lane.size - 6) } : { left: lane.start + 3, width: Math.max(4, lane.size - 6) };
|
|
6467
|
+
const across = vertical ? { left: width, width: box.width } : { top: width, height: box.height };
|
|
6468
|
+
const marker = lanes[Math.min(current, lanes.length - 1)];
|
|
6469
|
+
const isAppend = handle.mode === "insert" && handle.index === lanes.length;
|
|
6470
|
+
const name = NAMES[axis];
|
|
6471
|
+
const label = handle.mode === "delete" ? `Delete ${name} ${handle.index + 1}` : isAppend ? `Add ${name}` : `Insert ${name} before ${name} ${handle.index + 1}`;
|
|
6472
|
+
const previewStyle = handle.mode === "insert" ? { ...at(boundary(handle.index)), ...across } : vertical ? { top: lanes[handle.index].start, height: lanes[handle.index].size, ...across } : { left: lanes[handle.index].start, width: lanes[handle.index].size, ...across };
|
|
6405
6473
|
return /* @__PURE__ */ jsxs11(
|
|
6406
6474
|
"div",
|
|
6407
6475
|
{
|
|
6408
6476
|
ref: rail,
|
|
6409
|
-
className:
|
|
6410
|
-
style: { top: box.top, left: box.left -
|
|
6477
|
+
className: `zui-table-rail is-${axis}`,
|
|
6478
|
+
style: vertical ? { top: box.top, left: box.left - width, width, height: box.height } : { top: box.top - width, left: box.left, width: box.width, height: width },
|
|
6411
6479
|
onPointerMove,
|
|
6412
|
-
onPointerLeave: () =>
|
|
6480
|
+
onPointerLeave: () => setPointer(null),
|
|
6413
6481
|
children: [
|
|
6414
|
-
/* @__PURE__ */ jsx14(
|
|
6415
|
-
"div",
|
|
6416
|
-
{
|
|
6417
|
-
className: "zui-table-rail-marker",
|
|
6418
|
-
style: { top: current.top + 3, height: Math.max(4, current.height - 6) },
|
|
6419
|
-
"aria-hidden": true
|
|
6420
|
-
}
|
|
6421
|
-
),
|
|
6482
|
+
/* @__PURE__ */ jsx14("div", { className: "zui-table-rail-marker", style: span(marker), "aria-hidden": true }),
|
|
6422
6483
|
/* @__PURE__ */ jsx14(
|
|
6423
6484
|
"button",
|
|
6424
6485
|
{
|
|
6425
6486
|
type: "button",
|
|
6426
|
-
className: `zui-table-rail-
|
|
6427
|
-
style:
|
|
6428
|
-
|
|
6429
|
-
|
|
6487
|
+
className: `zui-table-rail-handle is-${handle.mode} ${pointer === null ? "is-resting" : ""}`,
|
|
6488
|
+
style: at(
|
|
6489
|
+
handle.mode === "insert" ? boundary(handle.index) : lanes[handle.index].start + lanes[handle.index].size / 2
|
|
6490
|
+
),
|
|
6491
|
+
title: label,
|
|
6492
|
+
"aria-label": label,
|
|
6430
6493
|
onMouseDown: (e) => e.preventDefault(),
|
|
6431
|
-
onClick: () => onInsert(
|
|
6432
|
-
children: /* @__PURE__ */ jsx14("svg", { viewBox: "0 0 12 12", width: "12", height: "12", fill: "none", stroke: "currentColor", strokeWidth: "1.8", strokeLinecap: "round", children: /* @__PURE__ */ jsx14("path", { d: "M6 2.5v7M2.5 6h7" }) })
|
|
6494
|
+
onClick: () => handle.mode === "insert" ? onInsert(handle.index) : onDelete(handle.index),
|
|
6495
|
+
children: /* @__PURE__ */ jsx14("svg", { viewBox: "0 0 12 12", width: "12", height: "12", fill: "none", stroke: "currentColor", strokeWidth: "1.8", strokeLinecap: "round", children: handle.mode === "insert" ? /* @__PURE__ */ jsx14("path", { d: "M6 2.5v7M2.5 6h7" }) : /* @__PURE__ */ jsx14("path", { d: "M2.5 6h7" }) })
|
|
6433
6496
|
}
|
|
6434
6497
|
),
|
|
6435
|
-
/* @__PURE__ */ jsx14(
|
|
6436
|
-
"div",
|
|
6437
|
-
{
|
|
6438
|
-
className: "zui-table-rail-line",
|
|
6439
|
-
style: { top: insertTop, left: TABLE_RAIL_WIDTH, width: box.width },
|
|
6440
|
-
"aria-hidden": true
|
|
6441
|
-
}
|
|
6442
|
-
)
|
|
6498
|
+
/* @__PURE__ */ jsx14("div", { className: `zui-table-rail-preview is-${handle.mode}`, style: previewStyle, "aria-hidden": true })
|
|
6443
6499
|
]
|
|
6444
6500
|
}
|
|
6445
6501
|
);
|
|
6446
6502
|
}
|
|
6447
6503
|
|
|
6448
|
-
// src/components/shortcutLabel.ts
|
|
6449
|
-
var isApple = typeof navigator !== "undefined" && /Mac|iPhone|iPad|iPod/.test(navigator.platform ?? "");
|
|
6450
|
-
function shortcutLabel(keys) {
|
|
6451
|
-
const parts = keys.split("+");
|
|
6452
|
-
if (isApple) {
|
|
6453
|
-
const glyphs = {
|
|
6454
|
-
Mod: "\u2318",
|
|
6455
|
-
Shift: "\u21E7",
|
|
6456
|
-
Alt: "\u2325",
|
|
6457
|
-
Enter: "\u21A9",
|
|
6458
|
-
Backspace: "\u232B",
|
|
6459
|
-
Tab: "\u21E5"
|
|
6460
|
-
};
|
|
6461
|
-
return parts.map((part) => glyphs[part] ?? part).join("");
|
|
6462
|
-
}
|
|
6463
|
-
return parts.map((part) => part === "Mod" ? "Ctrl" : part).join("+");
|
|
6464
|
-
}
|
|
6465
|
-
|
|
6466
|
-
// src/components/tableRowActions.tsx
|
|
6467
|
-
import { Fragment as Fragment5, jsx as jsx15, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
6468
|
-
var TABLE_ROW_ACTIONS = [
|
|
6469
|
-
{
|
|
6470
|
-
action: "insert-above",
|
|
6471
|
-
label: "Insert row above",
|
|
6472
|
-
shortcut: "Mod+Shift+Enter",
|
|
6473
|
-
icon: /* @__PURE__ */ jsxs12(Fragment5, { children: [
|
|
6474
|
-
/* @__PURE__ */ jsx15("path", { d: "M3 11.5h14M3 15.5h14" }),
|
|
6475
|
-
/* @__PURE__ */ jsx15("path", { d: "M10 3.5v5M7.5 6h5" })
|
|
6476
|
-
] })
|
|
6477
|
-
},
|
|
6478
|
-
{
|
|
6479
|
-
action: "insert-below",
|
|
6480
|
-
label: "Insert row below",
|
|
6481
|
-
shortcut: "Mod+Enter",
|
|
6482
|
-
icon: /* @__PURE__ */ jsxs12(Fragment5, { children: [
|
|
6483
|
-
/* @__PURE__ */ jsx15("path", { d: "M3 4.5h14M3 8.5h14" }),
|
|
6484
|
-
/* @__PURE__ */ jsx15("path", { d: "M10 11.5v5M7.5 14h5" })
|
|
6485
|
-
] })
|
|
6486
|
-
},
|
|
6487
|
-
{
|
|
6488
|
-
action: "delete",
|
|
6489
|
-
label: "Delete row",
|
|
6490
|
-
shortcut: "Mod+Shift+Backspace",
|
|
6491
|
-
icon: /* @__PURE__ */ jsxs12(Fragment5, { children: [
|
|
6492
|
-
/* @__PURE__ */ jsx15("path", { d: "M3 5.5h14M3 14.5h14" }),
|
|
6493
|
-
/* @__PURE__ */ jsx15("path", { d: "M7.5 10h5" })
|
|
6494
|
-
] })
|
|
6495
|
-
}
|
|
6496
|
-
];
|
|
6497
|
-
function tableRowActionTitle(action) {
|
|
6498
|
-
return `${action.label} (${shortcutLabel(action.shortcut)})`;
|
|
6499
|
-
}
|
|
6500
|
-
|
|
6501
6504
|
// src/useMarkdownEditor.ts
|
|
6502
6505
|
import { useCallback as useCallback5, useEffect as useEffect11, useRef as useRef8, useState as useState7 } from "react";
|
|
6503
6506
|
import {
|
|
@@ -6535,7 +6538,7 @@ function useMarkdownEditor() {
|
|
|
6535
6538
|
const [canUndo, setCanUndo] = useState7(false);
|
|
6536
6539
|
const [canRedo, setCanRedo] = useState7(false);
|
|
6537
6540
|
const [tableSettings, setTableSettingsState] = useState7(null);
|
|
6538
|
-
const [
|
|
6541
|
+
const [tableCell, setTableCell] = useState7(null);
|
|
6539
6542
|
const activeDrawingRef = useRef8(null);
|
|
6540
6543
|
const [drawingWidth, setDrawingWidth] = useState7(null);
|
|
6541
6544
|
useEffect11(
|
|
@@ -6544,7 +6547,7 @@ function useMarkdownEditor() {
|
|
|
6544
6547
|
editorState.read(() => {
|
|
6545
6548
|
const table = $getSelectedTable();
|
|
6546
6549
|
setTableSettingsState(table ? $getTableSettings(table) : null);
|
|
6547
|
-
|
|
6550
|
+
setTableCell(table ? $getTableCellPosition() : null);
|
|
6548
6551
|
setDrawingWidth($readDrawingWidth(activeDrawingRef.current));
|
|
6549
6552
|
const selection = $getSelection6();
|
|
6550
6553
|
if (!$isRangeSelection6(selection)) {
|
|
@@ -6655,6 +6658,21 @@ function useMarkdownEditor() {
|
|
|
6655
6658
|
if (table) $deleteSelectedTableRow(table);
|
|
6656
6659
|
});
|
|
6657
6660
|
}, [editor]);
|
|
6661
|
+
const insertTableColumn = useCallback5(
|
|
6662
|
+
(position = "after") => {
|
|
6663
|
+
editor.update(() => {
|
|
6664
|
+
const table = $getSelectedTable();
|
|
6665
|
+
if (table) $insertTableColumnNear(table, position);
|
|
6666
|
+
});
|
|
6667
|
+
},
|
|
6668
|
+
[editor]
|
|
6669
|
+
);
|
|
6670
|
+
const deleteTableColumn = useCallback5(() => {
|
|
6671
|
+
editor.update(() => {
|
|
6672
|
+
const table = $getSelectedTable();
|
|
6673
|
+
if (table) $deleteSelectedTableColumn(table);
|
|
6674
|
+
});
|
|
6675
|
+
}, [editor]);
|
|
6658
6676
|
const setBlockWidth = useCallback5(
|
|
6659
6677
|
(width) => {
|
|
6660
6678
|
const key = activeDrawingRef.current;
|
|
@@ -6689,9 +6707,11 @@ function useMarkdownEditor() {
|
|
|
6689
6707
|
setTableWidth,
|
|
6690
6708
|
tableDensity: tableSettings?.density ?? null,
|
|
6691
6709
|
setTableDensity,
|
|
6692
|
-
|
|
6710
|
+
tableCell,
|
|
6693
6711
|
insertTableRow,
|
|
6694
6712
|
deleteTableRow,
|
|
6713
|
+
insertTableColumn,
|
|
6714
|
+
deleteTableColumn,
|
|
6695
6715
|
canUndo,
|
|
6696
6716
|
canRedo,
|
|
6697
6717
|
undo,
|
|
@@ -6700,23 +6720,23 @@ function useMarkdownEditor() {
|
|
|
6700
6720
|
}
|
|
6701
6721
|
|
|
6702
6722
|
// src/components/Toolbar.tsx
|
|
6703
|
-
import { Fragment as
|
|
6723
|
+
import { Fragment as Fragment5, jsx as jsx15, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
6704
6724
|
function Toolbar({ children, className }) {
|
|
6705
|
-
return /* @__PURE__ */
|
|
6725
|
+
return /* @__PURE__ */ jsx15(
|
|
6706
6726
|
"div",
|
|
6707
6727
|
{
|
|
6708
6728
|
className: `zui-text-editor-toolbar ${className ?? ""}`,
|
|
6709
6729
|
role: "toolbar",
|
|
6710
|
-
children: children ?? /* @__PURE__ */
|
|
6711
|
-
/* @__PURE__ */
|
|
6712
|
-
/* @__PURE__ */
|
|
6713
|
-
/* @__PURE__ */
|
|
6730
|
+
children: children ?? /* @__PURE__ */ jsxs12(Fragment5, { children: [
|
|
6731
|
+
/* @__PURE__ */ jsx15(FormatButtons, {}),
|
|
6732
|
+
/* @__PURE__ */ jsx15(ToolbarDivider, {}),
|
|
6733
|
+
/* @__PURE__ */ jsx15(InsertButtons, {})
|
|
6714
6734
|
] })
|
|
6715
6735
|
}
|
|
6716
6736
|
);
|
|
6717
6737
|
}
|
|
6718
6738
|
function ToolbarDivider() {
|
|
6719
|
-
return /* @__PURE__ */
|
|
6739
|
+
return /* @__PURE__ */ jsx15("div", { className: "zui-text-editor-toolbar-divider" });
|
|
6720
6740
|
}
|
|
6721
6741
|
function ToolbarButton({
|
|
6722
6742
|
label,
|
|
@@ -6726,7 +6746,7 @@ function ToolbarButton({
|
|
|
6726
6746
|
disabled = false,
|
|
6727
6747
|
className
|
|
6728
6748
|
}) {
|
|
6729
|
-
return /* @__PURE__ */
|
|
6749
|
+
return /* @__PURE__ */ jsx15(
|
|
6730
6750
|
"button",
|
|
6731
6751
|
{
|
|
6732
6752
|
type: "button",
|
|
@@ -6742,7 +6762,7 @@ function ToolbarButton({
|
|
|
6742
6762
|
);
|
|
6743
6763
|
}
|
|
6744
6764
|
function Icon2({ children, strokeWidth = 1.5 }) {
|
|
6745
|
-
return /* @__PURE__ */
|
|
6765
|
+
return /* @__PURE__ */ jsx15(
|
|
6746
6766
|
"svg",
|
|
6747
6767
|
{
|
|
6748
6768
|
viewBox: "0 0 20 20",
|
|
@@ -6761,27 +6781,27 @@ var FORMAT_BUTTONS = [
|
|
|
6761
6781
|
{
|
|
6762
6782
|
format: "bold",
|
|
6763
6783
|
label: "Bold",
|
|
6764
|
-
icon: /* @__PURE__ */
|
|
6784
|
+
icon: /* @__PURE__ */ jsx15(Icon2, { strokeWidth: 1.8, children: /* @__PURE__ */ jsx15("path", { d: "M6 3.5h5a3 3 0 0 1 0 6H6zm0 6h6a3 3 0 0 1 0 6H6z" }) })
|
|
6765
6785
|
},
|
|
6766
6786
|
{
|
|
6767
6787
|
format: "italic",
|
|
6768
6788
|
label: "Italic",
|
|
6769
|
-
icon: /* @__PURE__ */
|
|
6789
|
+
icon: /* @__PURE__ */ jsx15(Icon2, { strokeWidth: 1.6, children: /* @__PURE__ */ jsx15("path", { d: "M8.5 3.5h6M5.5 16.5h6M11.5 3.5l-3 13" }) })
|
|
6770
6790
|
},
|
|
6771
6791
|
{
|
|
6772
6792
|
format: "strikethrough",
|
|
6773
6793
|
label: "Strikethrough",
|
|
6774
|
-
icon: /* @__PURE__ */
|
|
6794
|
+
icon: /* @__PURE__ */ jsx15(Icon2, { strokeWidth: 1.6, children: /* @__PURE__ */ jsx15("path", { d: "M4 10h12M13.5 5.5c-.6-1.2-2-2-3.5-2-2 0-3.5 1.2-3.5 2.8 0 .5.1.9.4 1.3m-.4 5c.5 1.6 2 2.9 3.9 2.9 2 0 3.6-1.2 3.6-2.9 0-.4-.1-.8-.2-1.1" }) })
|
|
6775
6795
|
},
|
|
6776
6796
|
{
|
|
6777
6797
|
format: "code",
|
|
6778
6798
|
label: "Inline code",
|
|
6779
|
-
icon: /* @__PURE__ */
|
|
6799
|
+
icon: /* @__PURE__ */ jsx15(Icon2, { strokeWidth: 1.6, children: /* @__PURE__ */ jsx15("path", { d: "M7.5 6L4 10l3.5 4M12.5 6L16 10l-3.5 4" }) })
|
|
6780
6800
|
}
|
|
6781
6801
|
];
|
|
6782
6802
|
function FormatButtons() {
|
|
6783
6803
|
const { activeFormats, toggleFormat } = useMarkdownEditor();
|
|
6784
|
-
return /* @__PURE__ */
|
|
6804
|
+
return /* @__PURE__ */ jsx15(Fragment5, { children: FORMAT_BUTTONS.map(({ format, label, icon }) => /* @__PURE__ */ jsx15(
|
|
6785
6805
|
ToolbarButton,
|
|
6786
6806
|
{
|
|
6787
6807
|
label,
|
|
@@ -6794,36 +6814,36 @@ function FormatButtons() {
|
|
|
6794
6814
|
}
|
|
6795
6815
|
function InsertButtons() {
|
|
6796
6816
|
const { insertTable, insertDrawing } = useMarkdownEditor();
|
|
6797
|
-
return /* @__PURE__ */
|
|
6798
|
-
/* @__PURE__ */
|
|
6799
|
-
/* @__PURE__ */
|
|
6800
|
-
/* @__PURE__ */
|
|
6817
|
+
return /* @__PURE__ */ jsxs12(Fragment5, { children: [
|
|
6818
|
+
/* @__PURE__ */ jsx15(ToolbarButton, { label: "Insert table", onClick: () => insertTable(), children: /* @__PURE__ */ jsxs12(Icon2, { children: [
|
|
6819
|
+
/* @__PURE__ */ jsx15("rect", { x: "3", y: "3.5", width: "14", height: "13", rx: "1.5" }),
|
|
6820
|
+
/* @__PURE__ */ jsx15("path", { d: "M3 8h14M8 8v8.5M13 8v8.5" })
|
|
6801
6821
|
] }) }),
|
|
6802
|
-
/* @__PURE__ */
|
|
6803
|
-
/* @__PURE__ */
|
|
6804
|
-
/* @__PURE__ */
|
|
6805
|
-
/* @__PURE__ */
|
|
6822
|
+
/* @__PURE__ */ jsx15(ToolbarButton, { label: "Insert drawing", onClick: insertDrawing, children: /* @__PURE__ */ jsxs12(Icon2, { children: [
|
|
6823
|
+
/* @__PURE__ */ jsx15("rect", { x: "3", y: "5", width: "8", height: "6", rx: "1.5" }),
|
|
6824
|
+
/* @__PURE__ */ jsx15("path", { d: "M13.5 8h3M14.5 6.5L17.5 8l-3 1.5" }),
|
|
6825
|
+
/* @__PURE__ */ jsx15("ellipse", { cx: "13", cy: "14.5", rx: "4", ry: "2.8" })
|
|
6806
6826
|
] }) })
|
|
6807
6827
|
] });
|
|
6808
6828
|
}
|
|
6809
6829
|
function HistoryButtons() {
|
|
6810
6830
|
const { canUndo, canRedo, undo, redo } = useMarkdownEditor();
|
|
6811
|
-
return /* @__PURE__ */
|
|
6812
|
-
/* @__PURE__ */
|
|
6813
|
-
/* @__PURE__ */
|
|
6814
|
-
/* @__PURE__ */
|
|
6831
|
+
return /* @__PURE__ */ jsxs12(Fragment5, { children: [
|
|
6832
|
+
/* @__PURE__ */ jsx15(ToolbarButton, { label: "Undo", onClick: undo, disabled: !canUndo, children: /* @__PURE__ */ jsxs12(Icon2, { children: [
|
|
6833
|
+
/* @__PURE__ */ jsx15("path", { d: "M7 6L3.5 9.5 7 13" }),
|
|
6834
|
+
/* @__PURE__ */ jsx15("path", { d: "M3.5 9.5H12a4 4 0 0 1 0 8h-1" })
|
|
6815
6835
|
] }) }),
|
|
6816
|
-
/* @__PURE__ */
|
|
6817
|
-
/* @__PURE__ */
|
|
6818
|
-
/* @__PURE__ */
|
|
6836
|
+
/* @__PURE__ */ jsx15(ToolbarButton, { label: "Redo", onClick: redo, disabled: !canRedo, children: /* @__PURE__ */ jsxs12(Icon2, { children: [
|
|
6837
|
+
/* @__PURE__ */ jsx15("path", { d: "M13 6l3.5 3.5L13 13" }),
|
|
6838
|
+
/* @__PURE__ */ jsx15("path", { d: "M16.5 9.5H8a4 4 0 0 0 0 8h1" })
|
|
6819
6839
|
] }) })
|
|
6820
6840
|
] });
|
|
6821
6841
|
}
|
|
6822
6842
|
|
|
6823
6843
|
// src/components/TableSettingsToolbar.tsx
|
|
6824
|
-
import { jsx as
|
|
6844
|
+
import { jsx as jsx16 } from "react/jsx-runtime";
|
|
6825
6845
|
function Icon3({ children }) {
|
|
6826
|
-
return /* @__PURE__ */
|
|
6846
|
+
return /* @__PURE__ */ jsx16(
|
|
6827
6847
|
"svg",
|
|
6828
6848
|
{
|
|
6829
6849
|
viewBox: "0 0 20 20",
|
|
@@ -6838,36 +6858,17 @@ function Icon3({ children }) {
|
|
|
6838
6858
|
}
|
|
6839
6859
|
);
|
|
6840
6860
|
}
|
|
6841
|
-
function TableSettingsToolbar({
|
|
6842
|
-
settings,
|
|
6843
|
-
|
|
6844
|
-
|
|
6845
|
-
|
|
6846
|
-
|
|
6847
|
-
|
|
6848
|
-
|
|
6849
|
-
|
|
6850
|
-
|
|
6851
|
-
|
|
6852
|
-
label,
|
|
6853
|
-
active: layoutPreset(settings.width) === preset,
|
|
6854
|
-
onClick: () => onSettings({ width, density }),
|
|
6855
|
-
children: /* @__PURE__ */ jsx17(Icon3, { children: icon })
|
|
6856
|
-
},
|
|
6857
|
-
preset
|
|
6858
|
-
)),
|
|
6859
|
-
/* @__PURE__ */ jsx17(ToolbarDivider, {}),
|
|
6860
|
-
TABLE_ROW_ACTIONS.map((rowAction) => /* @__PURE__ */ jsx17(
|
|
6861
|
-
ToolbarButton,
|
|
6862
|
-
{
|
|
6863
|
-
label: tableRowActionTitle(rowAction),
|
|
6864
|
-
disabled: rowAction.action === "delete" && !canDeleteRow(position) || rowAction.action === "insert-above" && position.hasHeader && position.index === 0,
|
|
6865
|
-
onClick: () => onRowAction(rowAction.action),
|
|
6866
|
-
children: /* @__PURE__ */ jsx17(Icon3, { children: rowAction.icon })
|
|
6867
|
-
},
|
|
6868
|
-
rowAction.action
|
|
6869
|
-
))
|
|
6870
|
-
] });
|
|
6861
|
+
function TableSettingsToolbar({ settings, style, onSettings }) {
|
|
6862
|
+
return /* @__PURE__ */ jsx16("div", { className: "zui-table-settings", role: "toolbar", "aria-label": "Table settings", style, children: LAYOUT_OPTIONS.map(({ preset, label, icon, width, density }) => /* @__PURE__ */ jsx16(
|
|
6863
|
+
ToolbarButton,
|
|
6864
|
+
{
|
|
6865
|
+
label,
|
|
6866
|
+
active: layoutPreset(settings.width) === preset,
|
|
6867
|
+
onClick: () => onSettings({ width, density }),
|
|
6868
|
+
children: /* @__PURE__ */ jsx16(Icon3, { children: icon })
|
|
6869
|
+
},
|
|
6870
|
+
preset
|
|
6871
|
+
)) });
|
|
6871
6872
|
}
|
|
6872
6873
|
|
|
6873
6874
|
// src/plugins/useSelectedTable.ts
|
|
@@ -6876,12 +6877,17 @@ import { useLexicalComposerContext as useLexicalComposerContext10 } from "@lexic
|
|
|
6876
6877
|
function measure(element, main) {
|
|
6877
6878
|
const rect = element.getBoundingClientRect();
|
|
6878
6879
|
const mainRect = main.getBoundingClientRect();
|
|
6879
|
-
const
|
|
6880
|
-
(
|
|
6881
|
-
const r = row.getBoundingClientRect();
|
|
6882
|
-
return { top: r.top - rect.top, height: r.height };
|
|
6883
|
-
}
|
|
6880
|
+
const rowElements = Array.from(
|
|
6881
|
+
element.querySelectorAll(":scope > tbody > tr, :scope > tr")
|
|
6884
6882
|
);
|
|
6883
|
+
const rows = rowElements.map((row) => {
|
|
6884
|
+
const r = row.getBoundingClientRect();
|
|
6885
|
+
return { start: r.top - rect.top, size: r.height };
|
|
6886
|
+
});
|
|
6887
|
+
const columns = Array.from(rowElements[0]?.children ?? []).map((cell) => {
|
|
6888
|
+
const r = cell.getBoundingClientRect();
|
|
6889
|
+
return { start: r.left - rect.left, size: r.width };
|
|
6890
|
+
});
|
|
6885
6891
|
return {
|
|
6886
6892
|
box: {
|
|
6887
6893
|
top: rect.top - mainRect.top,
|
|
@@ -6890,7 +6896,8 @@ function measure(element, main) {
|
|
|
6890
6896
|
width: rect.width,
|
|
6891
6897
|
height: rect.height
|
|
6892
6898
|
},
|
|
6893
|
-
rows
|
|
6899
|
+
rows,
|
|
6900
|
+
columns
|
|
6894
6901
|
};
|
|
6895
6902
|
}
|
|
6896
6903
|
function useSelectedTable() {
|
|
@@ -6899,7 +6906,7 @@ function useSelectedTable() {
|
|
|
6899
6906
|
const sync = useCallback6(() => {
|
|
6900
6907
|
const table = editor.getEditorState().read(() => {
|
|
6901
6908
|
const node = $getSelectedTable();
|
|
6902
|
-
const position = $
|
|
6909
|
+
const position = $getTableCellPosition();
|
|
6903
6910
|
return node && position ? { key: node.getKey(), settings: $getTableSettings(node), position } : null;
|
|
6904
6911
|
});
|
|
6905
6912
|
const element = table ? editor.getElementByKey(table.key) : null;
|
|
@@ -6934,66 +6941,66 @@ function useSelectedTable() {
|
|
|
6934
6941
|
}
|
|
6935
6942
|
|
|
6936
6943
|
// src/plugins/TableControlsPlugin.tsx
|
|
6937
|
-
import { Fragment as
|
|
6944
|
+
import { Fragment as Fragment6, jsx as jsx17, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
6938
6945
|
function TableControlsPlugin() {
|
|
6939
6946
|
const [editor] = useLexicalComposerContext11();
|
|
6940
6947
|
const isEditable = useLexicalEditable2();
|
|
6941
6948
|
const table = useSelectedTable();
|
|
6942
|
-
const
|
|
6943
|
-
(
|
|
6944
|
-
editor.update(() => {
|
|
6945
|
-
const node = $getSelectedTable();
|
|
6946
|
-
if (node) $setTableSettings(node, next);
|
|
6947
|
-
});
|
|
6948
|
-
},
|
|
6949
|
-
[editor]
|
|
6950
|
-
);
|
|
6951
|
-
const rowAction = useCallback7(
|
|
6952
|
-
(action) => {
|
|
6949
|
+
const withTable = useCallback7(
|
|
6950
|
+
(fn) => {
|
|
6953
6951
|
editor.update(() => {
|
|
6954
6952
|
const node = $getSelectedTable();
|
|
6955
|
-
if (
|
|
6956
|
-
if (action === "delete") $deleteSelectedTableRow(node);
|
|
6957
|
-
else $insertTableRowNear(node, action === "insert-above" ? "above" : "below");
|
|
6953
|
+
if (node) fn(node);
|
|
6958
6954
|
});
|
|
6959
6955
|
},
|
|
6960
6956
|
[editor]
|
|
6961
6957
|
);
|
|
6962
|
-
const
|
|
6963
|
-
(
|
|
6964
|
-
|
|
6965
|
-
const node = $getSelectedTable();
|
|
6966
|
-
if (node) $insertTableRowAt(node, index);
|
|
6967
|
-
});
|
|
6968
|
-
},
|
|
6969
|
-
[editor]
|
|
6958
|
+
const updateSettings = useCallback7(
|
|
6959
|
+
(next) => withTable((node) => $setTableSettings(node, next)),
|
|
6960
|
+
[withTable]
|
|
6970
6961
|
);
|
|
6971
6962
|
if (!isEditable || !table) return null;
|
|
6972
|
-
|
|
6973
|
-
|
|
6963
|
+
const { position } = table;
|
|
6964
|
+
return /* @__PURE__ */ jsxs13(Fragment6, { children: [
|
|
6965
|
+
/* @__PURE__ */ jsx17(
|
|
6974
6966
|
TableSettingsToolbar,
|
|
6975
6967
|
{
|
|
6976
6968
|
settings: table.settings,
|
|
6977
|
-
|
|
6978
|
-
|
|
6979
|
-
|
|
6980
|
-
|
|
6969
|
+
style: { top: table.box.top - TABLE_RAIL_WIDTH.column, right: table.box.right },
|
|
6970
|
+
onSettings: updateSettings
|
|
6971
|
+
}
|
|
6972
|
+
),
|
|
6973
|
+
/* @__PURE__ */ jsx17(
|
|
6974
|
+
TableRail,
|
|
6975
|
+
{
|
|
6976
|
+
axis: "row",
|
|
6977
|
+
box: table.box,
|
|
6978
|
+
lanes: table.rows,
|
|
6979
|
+
current: position.row,
|
|
6980
|
+
insertable: insertableRowIndices(position),
|
|
6981
|
+
canDelete: canDeleteRow(position),
|
|
6982
|
+
onInsert: (index) => withTable((node) => $insertTableRowAt(node, index, position.column)),
|
|
6983
|
+
onDelete: (index) => withTable((node) => $deleteTableRowAt(node, index, position.column))
|
|
6981
6984
|
}
|
|
6982
6985
|
),
|
|
6983
|
-
/* @__PURE__ */
|
|
6984
|
-
|
|
6986
|
+
/* @__PURE__ */ jsx17(
|
|
6987
|
+
TableRail,
|
|
6985
6988
|
{
|
|
6989
|
+
axis: "column",
|
|
6986
6990
|
box: table.box,
|
|
6987
|
-
|
|
6988
|
-
|
|
6989
|
-
|
|
6991
|
+
lanes: table.columns,
|
|
6992
|
+
current: position.column,
|
|
6993
|
+
insertable: insertableColumnIndices(position),
|
|
6994
|
+
canDelete: canDeleteColumn(position),
|
|
6995
|
+
onInsert: (index) => withTable((node) => $insertTableColumnAt(node, index, position.row)),
|
|
6996
|
+
onDelete: (index) => withTable((node) => $deleteTableColumnAt(node, index, position.row))
|
|
6990
6997
|
}
|
|
6991
6998
|
)
|
|
6992
6999
|
] });
|
|
6993
7000
|
}
|
|
6994
7001
|
|
|
6995
7002
|
// src/EditorContent.tsx
|
|
6996
|
-
import { jsx as
|
|
7003
|
+
import { jsx as jsx18, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
6997
7004
|
function EditorContent({
|
|
6998
7005
|
placeholder = "Start writing...",
|
|
6999
7006
|
foldable = true,
|
|
@@ -7001,7 +7008,7 @@ function EditorContent({
|
|
|
7001
7008
|
}) {
|
|
7002
7009
|
const { mode, readOnly, autoFocus, rawValue, onRawChange } = useEditorContext();
|
|
7003
7010
|
if (mode === "edit-raw") {
|
|
7004
|
-
return /* @__PURE__ */
|
|
7011
|
+
return /* @__PURE__ */ jsx18(
|
|
7005
7012
|
"textarea",
|
|
7006
7013
|
{
|
|
7007
7014
|
className: "zui-text-editor-textarea",
|
|
@@ -7014,24 +7021,24 @@ function EditorContent({
|
|
|
7014
7021
|
}
|
|
7015
7022
|
);
|
|
7016
7023
|
}
|
|
7017
|
-
return /* @__PURE__ */
|
|
7018
|
-
/* @__PURE__ */
|
|
7019
|
-
/* @__PURE__ */
|
|
7024
|
+
return /* @__PURE__ */ jsxs14("div", { className: "zui-text-editor-body", children: [
|
|
7025
|
+
/* @__PURE__ */ jsxs14("div", { className: "zui-text-editor-main", children: [
|
|
7026
|
+
/* @__PURE__ */ jsx18(
|
|
7020
7027
|
RichTextPlugin,
|
|
7021
7028
|
{
|
|
7022
|
-
contentEditable: /* @__PURE__ */
|
|
7029
|
+
contentEditable: /* @__PURE__ */ jsx18(
|
|
7023
7030
|
ContentEditable,
|
|
7024
7031
|
{
|
|
7025
7032
|
className: "zui-text-editor-content",
|
|
7026
7033
|
"aria-placeholder": placeholder,
|
|
7027
|
-
placeholder: /* @__PURE__ */
|
|
7034
|
+
placeholder: /* @__PURE__ */ jsx18("div", { className: "zui-text-editor-placeholder", children: placeholder })
|
|
7028
7035
|
}
|
|
7029
7036
|
),
|
|
7030
7037
|
ErrorBoundary: LexicalErrorBoundary
|
|
7031
7038
|
}
|
|
7032
7039
|
),
|
|
7033
|
-
foldable && /* @__PURE__ */
|
|
7034
|
-
/* @__PURE__ */
|
|
7040
|
+
foldable && /* @__PURE__ */ jsx18(FoldingPlugin, {}),
|
|
7041
|
+
/* @__PURE__ */ jsx18(TableControlsPlugin, {})
|
|
7035
7042
|
] }),
|
|
7036
7043
|
children
|
|
7037
7044
|
] });
|
|
@@ -7043,7 +7050,7 @@ import { useLexicalComposerContext as useLexicalComposerContext12 } from "@lexic
|
|
|
7043
7050
|
import {
|
|
7044
7051
|
TableOfContentsPlugin
|
|
7045
7052
|
} from "@lexical/react/LexicalTableOfContentsPlugin";
|
|
7046
|
-
import { jsx as
|
|
7053
|
+
import { jsx as jsx19, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
7047
7054
|
var INDENT_PER_LEVEL = {
|
|
7048
7055
|
h1: 0,
|
|
7049
7056
|
h2: 1,
|
|
@@ -7095,16 +7102,16 @@ function OutlinePlugin() {
|
|
|
7095
7102
|
},
|
|
7096
7103
|
[editor]
|
|
7097
7104
|
);
|
|
7098
|
-
return /* @__PURE__ */
|
|
7105
|
+
return /* @__PURE__ */ jsx19(TableOfContentsPlugin, { children: (entries) => {
|
|
7099
7106
|
for (const [key] of entries) {
|
|
7100
7107
|
editor.getElementByKey(key)?.setAttribute("data-outline-key", key);
|
|
7101
7108
|
}
|
|
7102
|
-
return /* @__PURE__ */
|
|
7109
|
+
return /* @__PURE__ */ jsxs15(
|
|
7103
7110
|
"div",
|
|
7104
7111
|
{
|
|
7105
7112
|
className: `zui-text-editor-outline ${collapsed ? "is-collapsed" : ""}`,
|
|
7106
7113
|
children: [
|
|
7107
|
-
/* @__PURE__ */
|
|
7114
|
+
/* @__PURE__ */ jsx19(
|
|
7108
7115
|
"button",
|
|
7109
7116
|
{
|
|
7110
7117
|
type: "button",
|
|
@@ -7113,7 +7120,7 @@ function OutlinePlugin() {
|
|
|
7113
7120
|
"aria-label": collapsed ? "Show outline" : "Hide outline",
|
|
7114
7121
|
"aria-expanded": !collapsed,
|
|
7115
7122
|
onClick: () => setCollapsed((c2) => !c2),
|
|
7116
|
-
children: /* @__PURE__ */
|
|
7123
|
+
children: /* @__PURE__ */ jsx19(
|
|
7117
7124
|
"svg",
|
|
7118
7125
|
{
|
|
7119
7126
|
viewBox: "0 0 20 20",
|
|
@@ -7123,14 +7130,14 @@ function OutlinePlugin() {
|
|
|
7123
7130
|
stroke: "currentColor",
|
|
7124
7131
|
strokeWidth: "1.8",
|
|
7125
7132
|
strokeLinecap: "round",
|
|
7126
|
-
children: /* @__PURE__ */
|
|
7133
|
+
children: /* @__PURE__ */ jsx19("path", { d: "M4 5h12M4 10h8M4 15h10" })
|
|
7127
7134
|
}
|
|
7128
7135
|
)
|
|
7129
7136
|
}
|
|
7130
7137
|
),
|
|
7131
|
-
!collapsed && /* @__PURE__ */
|
|
7132
|
-
entries.length === 0 && /* @__PURE__ */
|
|
7133
|
-
entries.map(([key, text, tag]) => /* @__PURE__ */
|
|
7138
|
+
!collapsed && /* @__PURE__ */ jsxs15("nav", { className: "zui-text-editor-outline-list", "aria-label": "Table of contents", children: [
|
|
7139
|
+
entries.length === 0 && /* @__PURE__ */ jsx19("div", { className: "zui-text-editor-outline-empty", children: "No headings" }),
|
|
7140
|
+
entries.map(([key, text, tag]) => /* @__PURE__ */ jsx19(
|
|
7134
7141
|
"button",
|
|
7135
7142
|
{
|
|
7136
7143
|
type: "button",
|
|
@@ -7151,11 +7158,11 @@ function OutlinePlugin() {
|
|
|
7151
7158
|
}
|
|
7152
7159
|
|
|
7153
7160
|
// src/MarkdownEditor.tsx
|
|
7154
|
-
import { jsx as
|
|
7161
|
+
import { jsx as jsx20, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
7155
7162
|
var DEFAULT_ITEMS = {
|
|
7156
|
-
format: /* @__PURE__ */
|
|
7157
|
-
insert: /* @__PURE__ */
|
|
7158
|
-
history: /* @__PURE__ */
|
|
7163
|
+
format: /* @__PURE__ */ jsx20(FormatButtons, {}),
|
|
7164
|
+
insert: /* @__PURE__ */ jsx20(InsertButtons, {}),
|
|
7165
|
+
history: /* @__PURE__ */ jsx20(HistoryButtons, {})
|
|
7159
7166
|
};
|
|
7160
7167
|
function EditorToolbar({
|
|
7161
7168
|
children,
|
|
@@ -7163,7 +7170,7 @@ function EditorToolbar({
|
|
|
7163
7170
|
}) {
|
|
7164
7171
|
const { mode, readOnly } = useEditorContext();
|
|
7165
7172
|
if (mode !== "edit-md" || readOnly) return null;
|
|
7166
|
-
return /* @__PURE__ */
|
|
7173
|
+
return /* @__PURE__ */ jsx20(Toolbar, { className, children });
|
|
7167
7174
|
}
|
|
7168
7175
|
function MarkdownEditor({
|
|
7169
7176
|
placeholder,
|
|
@@ -7172,10 +7179,10 @@ function MarkdownEditor({
|
|
|
7172
7179
|
foldable = true,
|
|
7173
7180
|
...rootProps
|
|
7174
7181
|
}) {
|
|
7175
|
-
return /* @__PURE__ */
|
|
7176
|
-
toolbar === true && /* @__PURE__ */
|
|
7182
|
+
return /* @__PURE__ */ jsxs16(EditorRoot, { ...rootProps, children: [
|
|
7183
|
+
toolbar === true && /* @__PURE__ */ jsx20(EditorToolbar, {}),
|
|
7177
7184
|
typeof toolbar === "function" && toolbar(DEFAULT_ITEMS),
|
|
7178
|
-
/* @__PURE__ */
|
|
7185
|
+
/* @__PURE__ */ jsx20(EditorContent, { placeholder, foldable, children: outline && /* @__PURE__ */ jsx20(OutlinePlugin, {}) })
|
|
7179
7186
|
] });
|
|
7180
7187
|
}
|
|
7181
7188
|
MarkdownEditor.Root = EditorRoot;
|
|
@@ -7349,14 +7356,18 @@ var DRAWING_DATA_JSON_SCHEMA = {
|
|
|
7349
7356
|
export {
|
|
7350
7357
|
$createDrawingNode,
|
|
7351
7358
|
$createFrontmatterNode,
|
|
7359
|
+
$deleteSelectedTableColumn,
|
|
7352
7360
|
$deleteSelectedTableRow,
|
|
7361
|
+
$deleteTableColumnAt,
|
|
7353
7362
|
$deleteTableRowAt,
|
|
7354
7363
|
$getSelectedTable,
|
|
7355
7364
|
$getSelectedTableCell,
|
|
7365
|
+
$getTableCellPosition,
|
|
7356
7366
|
$getTableDensity,
|
|
7357
|
-
$getTableRowPosition,
|
|
7358
7367
|
$getTableSettings,
|
|
7359
7368
|
$getTableWidth,
|
|
7369
|
+
$insertTableColumnAt,
|
|
7370
|
+
$insertTableColumnNear,
|
|
7360
7371
|
$insertTableRowAt,
|
|
7361
7372
|
$insertTableRowNear,
|
|
7362
7373
|
$isDrawingNode,
|
|
@@ -7399,6 +7410,7 @@ export {
|
|
|
7399
7410
|
anchorPoint,
|
|
7400
7411
|
bindEndpoints,
|
|
7401
7412
|
boxOutline,
|
|
7413
|
+
canDeleteColumn,
|
|
7402
7414
|
canDeleteRow,
|
|
7403
7415
|
codeTokenizer,
|
|
7404
7416
|
connectorPoints,
|
|
@@ -7412,6 +7424,7 @@ export {
|
|
|
7412
7424
|
inkAmplitude,
|
|
7413
7425
|
inkFillOffset,
|
|
7414
7426
|
inkStroke,
|
|
7427
|
+
insertableColumnIndices,
|
|
7415
7428
|
insertableRowIndices,
|
|
7416
7429
|
isBlockWidth,
|
|
7417
7430
|
isDrawingSkeleton,
|