@sendbird/actionbook-core 0.10.10 → 0.10.12

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/ui/index.js CHANGED
@@ -1447,7 +1447,7 @@ function fromProseMirrorJSON(pmJSON) {
1447
1447
  }
1448
1448
 
1449
1449
  // src/markdown/serializer.ts
1450
- import { defaultHandlers as defaultHandlers3, toMarkdown } from "mdast-util-to-markdown";
1450
+ import { defaultHandlers as defaultHandlers2, toMarkdown } from "mdast-util-to-markdown";
1451
1451
 
1452
1452
  // node_modules/devlop/lib/default.js
1453
1453
  function ok() {
@@ -1505,13 +1505,13 @@ function footnoteReferencePeek() {
1505
1505
  function footnoteReference(node, _, state, info) {
1506
1506
  const tracker = state.createTracker(info);
1507
1507
  let value = tracker.move("[^");
1508
- const exit2 = state.enter("footnoteReference");
1508
+ const exit = state.enter("footnoteReference");
1509
1509
  const subexit = state.enter("reference");
1510
1510
  value += tracker.move(
1511
1511
  state.safe(state.associationId(node), { after: "]", before: value })
1512
1512
  );
1513
1513
  subexit();
1514
- exit2();
1514
+ exit();
1515
1515
  value += tracker.move("]");
1516
1516
  return value;
1517
1517
  }
@@ -1544,7 +1544,7 @@ function gfmFootnoteToMarkdown(options) {
1544
1544
  function footnoteDefinition(node, _, state, info) {
1545
1545
  const tracker = state.createTracker(info);
1546
1546
  let value = tracker.move("[^");
1547
- const exit2 = state.enter("footnoteDefinition");
1547
+ const exit = state.enter("footnoteDefinition");
1548
1548
  const subexit = state.enter("label");
1549
1549
  value += tracker.move(
1550
1550
  state.safe(state.associationId(node), { before: value, after: "]" })
@@ -1560,7 +1560,7 @@ function gfmFootnoteToMarkdown(options) {
1560
1560
  )
1561
1561
  );
1562
1562
  }
1563
- exit2();
1563
+ exit();
1564
1564
  return value;
1565
1565
  }
1566
1566
  }
@@ -1608,7 +1608,7 @@ function exitStrikethrough(token) {
1608
1608
  }
1609
1609
  function handleDelete(node, _, state, info) {
1610
1610
  const tracker = state.createTracker(info);
1611
- const exit2 = state.enter("strikethrough");
1611
+ const exit = state.enter("strikethrough");
1612
1612
  let value = tracker.move("~~");
1613
1613
  value += state.containerPhrasing(node, {
1614
1614
  ...tracker.current(),
@@ -1616,310 +1616,15 @@ function handleDelete(node, _, state, info) {
1616
1616
  after: "~"
1617
1617
  });
1618
1618
  value += tracker.move("~~");
1619
- exit2();
1619
+ exit();
1620
1620
  return value;
1621
1621
  }
1622
1622
  function peekDelete() {
1623
1623
  return "~";
1624
1624
  }
1625
1625
 
1626
- // node_modules/markdown-table/index.js
1627
- function defaultStringLength(value) {
1628
- return value.length;
1629
- }
1630
- function markdownTable(table2, options) {
1631
- const settings = options || {};
1632
- const align = (settings.align || []).concat();
1633
- const stringLength = settings.stringLength || defaultStringLength;
1634
- const alignments = [];
1635
- const cellMatrix = [];
1636
- const sizeMatrix = [];
1637
- const longestCellByColumn = [];
1638
- let mostCellsPerRow = 0;
1639
- let rowIndex = -1;
1640
- while (++rowIndex < table2.length) {
1641
- const row2 = [];
1642
- const sizes2 = [];
1643
- let columnIndex2 = -1;
1644
- if (table2[rowIndex].length > mostCellsPerRow) {
1645
- mostCellsPerRow = table2[rowIndex].length;
1646
- }
1647
- while (++columnIndex2 < table2[rowIndex].length) {
1648
- const cell = serialize(table2[rowIndex][columnIndex2]);
1649
- if (settings.alignDelimiters !== false) {
1650
- const size = stringLength(cell);
1651
- sizes2[columnIndex2] = size;
1652
- if (longestCellByColumn[columnIndex2] === void 0 || size > longestCellByColumn[columnIndex2]) {
1653
- longestCellByColumn[columnIndex2] = size;
1654
- }
1655
- }
1656
- row2.push(cell);
1657
- }
1658
- cellMatrix[rowIndex] = row2;
1659
- sizeMatrix[rowIndex] = sizes2;
1660
- }
1661
- let columnIndex = -1;
1662
- if (typeof align === "object" && "length" in align) {
1663
- while (++columnIndex < mostCellsPerRow) {
1664
- alignments[columnIndex] = toAlignment(align[columnIndex]);
1665
- }
1666
- } else {
1667
- const code3 = toAlignment(align);
1668
- while (++columnIndex < mostCellsPerRow) {
1669
- alignments[columnIndex] = code3;
1670
- }
1671
- }
1672
- columnIndex = -1;
1673
- const row = [];
1674
- const sizes = [];
1675
- while (++columnIndex < mostCellsPerRow) {
1676
- const code3 = alignments[columnIndex];
1677
- let before = "";
1678
- let after = "";
1679
- if (code3 === 99) {
1680
- before = ":";
1681
- after = ":";
1682
- } else if (code3 === 108) {
1683
- before = ":";
1684
- } else if (code3 === 114) {
1685
- after = ":";
1686
- }
1687
- let size = settings.alignDelimiters === false ? 1 : Math.max(
1688
- 1,
1689
- longestCellByColumn[columnIndex] - before.length - after.length
1690
- );
1691
- const cell = before + "-".repeat(size) + after;
1692
- if (settings.alignDelimiters !== false) {
1693
- size = before.length + size + after.length;
1694
- if (size > longestCellByColumn[columnIndex]) {
1695
- longestCellByColumn[columnIndex] = size;
1696
- }
1697
- sizes[columnIndex] = size;
1698
- }
1699
- row[columnIndex] = cell;
1700
- }
1701
- cellMatrix.splice(1, 0, row);
1702
- sizeMatrix.splice(1, 0, sizes);
1703
- rowIndex = -1;
1704
- const lines = [];
1705
- while (++rowIndex < cellMatrix.length) {
1706
- const row2 = cellMatrix[rowIndex];
1707
- const sizes2 = sizeMatrix[rowIndex];
1708
- columnIndex = -1;
1709
- const line = [];
1710
- while (++columnIndex < mostCellsPerRow) {
1711
- const cell = row2[columnIndex] || "";
1712
- let before = "";
1713
- let after = "";
1714
- if (settings.alignDelimiters !== false) {
1715
- const size = longestCellByColumn[columnIndex] - (sizes2[columnIndex] || 0);
1716
- const code3 = alignments[columnIndex];
1717
- if (code3 === 114) {
1718
- before = " ".repeat(size);
1719
- } else if (code3 === 99) {
1720
- if (size % 2) {
1721
- before = " ".repeat(size / 2 + 0.5);
1722
- after = " ".repeat(size / 2 - 0.5);
1723
- } else {
1724
- before = " ".repeat(size / 2);
1725
- after = before;
1726
- }
1727
- } else {
1728
- after = " ".repeat(size);
1729
- }
1730
- }
1731
- if (settings.delimiterStart !== false && !columnIndex) {
1732
- line.push("|");
1733
- }
1734
- if (settings.padding !== false && // Don’t add the opening space if we’re not aligning and the cell is
1735
- // empty: there will be a closing space.
1736
- !(settings.alignDelimiters === false && cell === "") && (settings.delimiterStart !== false || columnIndex)) {
1737
- line.push(" ");
1738
- }
1739
- if (settings.alignDelimiters !== false) {
1740
- line.push(before);
1741
- }
1742
- line.push(cell);
1743
- if (settings.alignDelimiters !== false) {
1744
- line.push(after);
1745
- }
1746
- if (settings.padding !== false) {
1747
- line.push(" ");
1748
- }
1749
- if (settings.delimiterEnd !== false || columnIndex !== mostCellsPerRow - 1) {
1750
- line.push("|");
1751
- }
1752
- }
1753
- lines.push(
1754
- settings.delimiterEnd === false ? line.join("").replace(/ +$/, "") : line.join("")
1755
- );
1756
- }
1757
- return lines.join("\n");
1758
- }
1759
- function serialize(value) {
1760
- return value === null || value === void 0 ? "" : String(value);
1761
- }
1762
- function toAlignment(value) {
1763
- const code3 = typeof value === "string" ? value.codePointAt(0) : 0;
1764
- return code3 === 67 || code3 === 99 ? 99 : code3 === 76 || code3 === 108 ? 108 : code3 === 82 || code3 === 114 ? 114 : 0;
1765
- }
1766
-
1767
- // node_modules/mdast-util-gfm-table/lib/index.js
1768
- import { defaultHandlers } from "mdast-util-to-markdown";
1769
- function gfmTableFromMarkdown() {
1770
- return {
1771
- enter: {
1772
- table: enterTable,
1773
- tableData: enterCell,
1774
- tableHeader: enterCell,
1775
- tableRow: enterRow
1776
- },
1777
- exit: {
1778
- codeText: exitCodeText,
1779
- table: exitTable,
1780
- tableData: exit,
1781
- tableHeader: exit,
1782
- tableRow: exit
1783
- }
1784
- };
1785
- }
1786
- function enterTable(token) {
1787
- const align = token._align;
1788
- ok(align, "expected `_align` on table");
1789
- this.enter(
1790
- {
1791
- type: "table",
1792
- align: align.map(function(d) {
1793
- return d === "none" ? null : d;
1794
- }),
1795
- children: []
1796
- },
1797
- token
1798
- );
1799
- this.data.inTable = true;
1800
- }
1801
- function exitTable(token) {
1802
- this.exit(token);
1803
- this.data.inTable = void 0;
1804
- }
1805
- function enterRow(token) {
1806
- this.enter({ type: "tableRow", children: [] }, token);
1807
- }
1808
- function exit(token) {
1809
- this.exit(token);
1810
- }
1811
- function enterCell(token) {
1812
- this.enter({ type: "tableCell", children: [] }, token);
1813
- }
1814
- function exitCodeText(token) {
1815
- let value = this.resume();
1816
- if (this.data.inTable) {
1817
- value = value.replace(/\\([\\|])/g, replace);
1818
- }
1819
- const node = this.stack[this.stack.length - 1];
1820
- ok(node.type === "inlineCode");
1821
- node.value = value;
1822
- this.exit(token);
1823
- }
1824
- function replace($0, $1) {
1825
- return $1 === "|" ? $1 : $0;
1826
- }
1827
- function gfmTableToMarkdown(options) {
1828
- const settings = options || {};
1829
- const padding = settings.tableCellPadding;
1830
- const alignDelimiters = settings.tablePipeAlign;
1831
- const stringLength = settings.stringLength;
1832
- const around = padding ? " " : "|";
1833
- return {
1834
- unsafe: [
1835
- { character: "\r", inConstruct: "tableCell" },
1836
- { character: "\n", inConstruct: "tableCell" },
1837
- // A pipe, when followed by a tab or space (padding), or a dash or colon
1838
- // (unpadded delimiter row), could result in a table.
1839
- { atBreak: true, character: "|", after: "[ :-]" },
1840
- // A pipe in a cell must be encoded.
1841
- { character: "|", inConstruct: "tableCell" },
1842
- // A colon must be followed by a dash, in which case it could start a
1843
- // delimiter row.
1844
- { atBreak: true, character: ":", after: "-" },
1845
- // A delimiter row can also start with a dash, when followed by more
1846
- // dashes, a colon, or a pipe.
1847
- // This is a stricter version than the built in check for lists, thematic
1848
- // breaks, and setex heading underlines though:
1849
- // <https://github.com/syntax-tree/mdast-util-to-markdown/blob/51a2038/lib/unsafe.js#L57>
1850
- { atBreak: true, character: "-", after: "[:|-]" }
1851
- ],
1852
- handlers: {
1853
- inlineCode: inlineCodeWithTable,
1854
- table: handleTable,
1855
- tableCell: handleTableCell,
1856
- tableRow: handleTableRow
1857
- }
1858
- };
1859
- function handleTable(node, _, state, info) {
1860
- return serializeData(handleTableAsData(node, state, info), node.align);
1861
- }
1862
- function handleTableRow(node, _, state, info) {
1863
- const row = handleTableRowAsData(node, state, info);
1864
- const value = serializeData([row]);
1865
- return value.slice(0, value.indexOf("\n"));
1866
- }
1867
- function handleTableCell(node, _, state, info) {
1868
- const exit2 = state.enter("tableCell");
1869
- const subexit = state.enter("phrasing");
1870
- const value = state.containerPhrasing(node, {
1871
- ...info,
1872
- before: around,
1873
- after: around
1874
- });
1875
- subexit();
1876
- exit2();
1877
- return value;
1878
- }
1879
- function serializeData(matrix, align) {
1880
- return markdownTable(matrix, {
1881
- align,
1882
- // @ts-expect-error: `markdown-table` types should support `null`.
1883
- alignDelimiters,
1884
- // @ts-expect-error: `markdown-table` types should support `null`.
1885
- padding,
1886
- // @ts-expect-error: `markdown-table` types should support `null`.
1887
- stringLength
1888
- });
1889
- }
1890
- function handleTableAsData(node, state, info) {
1891
- const children = node.children;
1892
- let index = -1;
1893
- const result = [];
1894
- const subexit = state.enter("table");
1895
- while (++index < children.length) {
1896
- result[index] = handleTableRowAsData(children[index], state, info);
1897
- }
1898
- subexit();
1899
- return result;
1900
- }
1901
- function handleTableRowAsData(node, state, info) {
1902
- const children = node.children;
1903
- let index = -1;
1904
- const result = [];
1905
- const subexit = state.enter("tableRow");
1906
- while (++index < children.length) {
1907
- result[index] = handleTableCell(children[index], node, state, info);
1908
- }
1909
- subexit();
1910
- return result;
1911
- }
1912
- function inlineCodeWithTable(node, parent, state) {
1913
- let value = defaultHandlers.inlineCode(node, parent, state);
1914
- if (state.stack.includes("tableCell")) {
1915
- value = value.replace(/\|/g, "\\$&");
1916
- }
1917
- return value;
1918
- }
1919
- }
1920
-
1921
1626
  // node_modules/mdast-util-gfm-task-list-item/lib/index.js
1922
- import { defaultHandlers as defaultHandlers2 } from "mdast-util-to-markdown";
1627
+ import { defaultHandlers } from "mdast-util-to-markdown";
1923
1628
  function gfmTaskListItemFromMarkdown() {
1924
1629
  return {
1925
1630
  exit: {
@@ -1979,7 +1684,7 @@ function listItemWithTaskListItem(node, parent, state, info) {
1979
1684
  if (checkable) {
1980
1685
  tracker.move(checkbox);
1981
1686
  }
1982
- let value = defaultHandlers2.listItem(node, parent, state, {
1687
+ let value = defaultHandlers.listItem(node, parent, state, {
1983
1688
  ...info,
1984
1689
  ...tracker.current()
1985
1690
  });
@@ -2186,18 +1891,22 @@ function convertBlock(node, depth = 0) {
2186
1891
  }
2187
1892
  case "table": {
2188
1893
  const tbl = node;
2189
- const rows = tbl.children.map((row, rowIdx) => {
2190
- const cells = row.children.map((cell) => {
2191
- const content = cell.children.flatMap((child) => convertInline(child, [], depth + 2));
2192
- return {
2193
- type: "tableCell",
2194
- ...rowIdx === 0 ? { header: true } : {},
2195
- content
2196
- };
2197
- });
2198
- return { type: "tableRow", content: cells };
2199
- });
2200
- return [{ type: "table", content: rows }];
1894
+ const paragraphs = [];
1895
+ for (const row of tbl.children) {
1896
+ const inlines = [];
1897
+ for (let ci = 0; ci < row.children.length; ci++) {
1898
+ if (ci > 0 && inlines.length > 0) {
1899
+ inlines.push({ type: "text", text: " | " });
1900
+ }
1901
+ for (const child of row.children[ci].children) {
1902
+ inlines.push(...convertInline(child, [], depth + 1));
1903
+ }
1904
+ }
1905
+ if (inlines.length > 0) {
1906
+ paragraphs.push({ type: "paragraph", content: inlines });
1907
+ }
1908
+ }
1909
+ return paragraphs;
2201
1910
  }
2202
1911
  default:
2203
1912
  if ("children" in node && Array.isArray(node.children)) {
@@ -2373,14 +2082,22 @@ function blockToMdast(node, depth = 0) {
2373
2082
  return result;
2374
2083
  }
2375
2084
  case "table": {
2376
- const rows = node.content.map((row) => ({
2377
- type: "tableRow",
2378
- children: row.content.map((cell) => ({
2379
- type: "tableCell",
2380
- children: cell.content.flatMap((c) => inlineToMdast(c, depth + 2))
2381
- }))
2382
- }));
2383
- return [{ type: "table", children: rows }];
2085
+ const result = [];
2086
+ for (const row of node.content) {
2087
+ const children = [];
2088
+ for (let ci = 0; ci < row.content.length; ci++) {
2089
+ if (ci > 0 && children.length > 0) {
2090
+ children.push({ type: "text", value: " | " });
2091
+ }
2092
+ for (const cell of row.content[ci].content) {
2093
+ children.push(...inlineToMdast(cell, depth + 1));
2094
+ }
2095
+ }
2096
+ if (children.length > 0) {
2097
+ result.push({ type: "paragraph", children });
2098
+ }
2099
+ }
2100
+ return result;
2384
2101
  }
2385
2102
  case "noteBlock":
2386
2103
  return [];
@@ -2412,7 +2129,6 @@ var gfmNoAutolinkToMarkdown = () => ({
2412
2129
  extensions: [
2413
2130
  gfmFootnoteToMarkdown(),
2414
2131
  gfmStrikethroughToMarkdown(),
2415
- gfmTableToMarkdown(),
2416
2132
  gfmTaskListItemToMarkdown()
2417
2133
  ]
2418
2134
  });
@@ -2430,7 +2146,7 @@ function isJinjaTagParagraph(node) {
2430
2146
  function textHandler(node, parent, state, info) {
2431
2147
  const originalUnsafe = state.unsafe;
2432
2148
  state.unsafe = originalUnsafe.filter((p) => !(p.character === "_" && !p.atBreak));
2433
- const result = defaultHandlers3.text(node, parent, state, info);
2149
+ const result = defaultHandlers2.text(node, parent, state, info);
2434
2150
  state.unsafe = originalUnsafe;
2435
2151
  return result;
2436
2152
  }
@@ -2448,11 +2164,11 @@ function listItemHandler(node, parent, state, info) {
2448
2164
  const savedStart = list.start;
2449
2165
  const idx = list.children.indexOf(node);
2450
2166
  list.start = value - idx;
2451
- const result = defaultHandlers3.listItem(node, parent, state, info);
2167
+ const result = defaultHandlers2.listItem(node, parent, state, info);
2452
2168
  list.start = savedStart;
2453
2169
  return result;
2454
2170
  }
2455
- return defaultHandlers3.listItem(node, parent, state, info);
2171
+ return defaultHandlers2.listItem(node, parent, state, info);
2456
2172
  }
2457
2173
  function serializeToMarkdown(doc2) {
2458
2174
  const mdastTree = toMdast(doc2);
@@ -2479,9 +2195,9 @@ function serializeToMarkdown(doc2) {
2479
2195
  link: linkHandler,
2480
2196
  listItem: listItemHandler,
2481
2197
  emphasis: ((node, _parent, state, info) => {
2482
- const exit2 = state.enter("emphasis");
2198
+ const exit = state.enter("emphasis");
2483
2199
  const value = state.containerPhrasing(node, { ...info, before: "_", after: "_" });
2484
- exit2();
2200
+ exit();
2485
2201
  return `__${value}__`;
2486
2202
  }),
2487
2203
  ...resourceTagToMarkdown().handlers,
@@ -3354,7 +3070,7 @@ function createHistoryPlugin() {
3354
3070
  }
3355
3071
 
3356
3072
  // src/ui/plugin/keymapPlugin.ts
3357
- import { baseKeymap, chainCommands, newlineInCode, createParagraphNear, liftEmptyBlock, splitBlock, toggleMark, setBlockType, joinBackward } from "prosemirror-commands";
3073
+ import { baseKeymap, chainCommands, deleteSelection, newlineInCode, createParagraphNear, liftEmptyBlock, splitBlock, toggleMark, setBlockType, joinBackward } from "prosemirror-commands";
3358
3074
  import { AllSelection, Plugin as Plugin2, TextSelection as TextSelection2 } from "prosemirror-state";
3359
3075
  import { keymap as keymap3 } from "prosemirror-keymap";
3360
3076
  import { liftListItem, sinkListItem, splitListItem, wrapInList } from "prosemirror-schema-list";
@@ -3590,7 +3306,48 @@ var joinListItemBackward = (state, dispatch) => {
3590
3306
  }
3591
3307
  return liftListItem(listItem)(state, dispatch);
3592
3308
  };
3309
+ var backspaceDeleteFirstEmptyParagraph = (state, dispatch) => {
3310
+ const { $from } = state.selection;
3311
+ if (!state.selection.empty) return false;
3312
+ if ($from.parent.type.name !== "paragraph") return false;
3313
+ if (!isEffectivelyEmpty($from.parent)) return false;
3314
+ if ($from.depth !== 1) return false;
3315
+ const indexInDoc = $from.index(0);
3316
+ if (indexInDoc !== 0) return false;
3317
+ if (state.doc.childCount < 2) return false;
3318
+ if (dispatch) {
3319
+ const from = $from.before(1);
3320
+ const to = $from.after(1);
3321
+ const tr = state.tr.delete(from, to);
3322
+ dispatch(tr.scrollIntoView());
3323
+ }
3324
+ return true;
3325
+ };
3326
+ var deleteSelectionKeepPosition = (state, dispatch) => {
3327
+ if (state.selection.empty) return false;
3328
+ const { from, to } = state.selection;
3329
+ const $from = state.doc.resolve(from);
3330
+ const $to = state.doc.resolve(to);
3331
+ const fromBlockIdx = $from.index(0);
3332
+ const toBlockIdx = $to.index(0);
3333
+ const fromAtBlockStart = from === $from.start(0) + $from.posAtIndex(fromBlockIdx, 0) - $from.start(0);
3334
+ const toAtBlockEnd = to >= $to.posAtIndex(toBlockIdx, 0) + state.doc.child(toBlockIdx).nodeSize - ($to.start(0) - $from.start(0));
3335
+ if (!dispatch) return deleteSelection(state);
3336
+ const tr = state.tr;
3337
+ tr.deleteSelection();
3338
+ const pos = tr.selection.from;
3339
+ const $pos = tr.doc.resolve(pos);
3340
+ if ($pos.depth === 0 || $pos.parent.type.name !== "paragraph" && $pos.parent.type.name !== "heading" && $pos.parentOffset === 0) {
3341
+ const para = paragraph.create();
3342
+ tr.insert(pos, para);
3343
+ tr.setSelection(TextSelection2.near(tr.doc.resolve(pos + 1)));
3344
+ }
3345
+ dispatch(tr.scrollIntoView());
3346
+ return true;
3347
+ };
3593
3348
  var backspaceCommand = chainCommands(
3349
+ deleteSelectionKeepPosition,
3350
+ backspaceDeleteFirstEmptyParagraph,
3594
3351
  backspaceDeleteEmptyBlock,
3595
3352
  backspaceAfterList,
3596
3353
  backspaceAfterLeafBlock,
@@ -4359,503 +4116,8 @@ function gfmStrikethrough(options) {
4359
4116
  }
4360
4117
  }
4361
4118
 
4362
- // node_modules/micromark-extension-gfm-table/lib/syntax.js
4363
- import { markdownLineEnding as markdownLineEnding2, markdownLineEndingOrSpace as markdownLineEndingOrSpace3, markdownSpace as markdownSpace3 } from "micromark-util-character";
4364
-
4365
- // node_modules/micromark-extension-gfm-table/lib/edit-map.js
4366
- var EditMap = class {
4367
- /**
4368
- * Create a new edit map.
4369
- */
4370
- constructor() {
4371
- this.map = [];
4372
- }
4373
- /**
4374
- * Create an edit: a remove and/or add at a certain place.
4375
- *
4376
- * @param {number} index
4377
- * @param {number} remove
4378
- * @param {Array<Event>} add
4379
- * @returns {undefined}
4380
- */
4381
- add(index, remove, add) {
4382
- addImplementation(this, index, remove, add);
4383
- }
4384
- // To do: add this when moving to `micromark`.
4385
- // /**
4386
- // * Create an edit: but insert `add` before existing additions.
4387
- // *
4388
- // * @param {number} index
4389
- // * @param {number} remove
4390
- // * @param {Array<Event>} add
4391
- // * @returns {undefined}
4392
- // */
4393
- // addBefore(index, remove, add) {
4394
- // addImplementation(this, index, remove, add, true)
4395
- // }
4396
- /**
4397
- * Done, change the events.
4398
- *
4399
- * @param {Array<Event>} events
4400
- * @returns {undefined}
4401
- */
4402
- consume(events) {
4403
- this.map.sort(function(a, b) {
4404
- return a[0] - b[0];
4405
- });
4406
- if (this.map.length === 0) {
4407
- return;
4408
- }
4409
- let index = this.map.length;
4410
- const vecs = [];
4411
- while (index > 0) {
4412
- index -= 1;
4413
- vecs.push(events.slice(this.map[index][0] + this.map[index][1]), this.map[index][2]);
4414
- events.length = this.map[index][0];
4415
- }
4416
- vecs.push(events.slice());
4417
- events.length = 0;
4418
- let slice = vecs.pop();
4419
- while (slice) {
4420
- for (const element of slice) {
4421
- events.push(element);
4422
- }
4423
- slice = vecs.pop();
4424
- }
4425
- this.map.length = 0;
4426
- }
4427
- };
4428
- function addImplementation(editMap, at, remove, add) {
4429
- let index = 0;
4430
- if (remove === 0 && add.length === 0) {
4431
- return;
4432
- }
4433
- while (index < editMap.map.length) {
4434
- if (editMap.map[index][0] === at) {
4435
- editMap.map[index][1] += remove;
4436
- editMap.map[index][2].push(...add);
4437
- return;
4438
- }
4439
- index += 1;
4440
- }
4441
- editMap.map.push([at, remove, add]);
4442
- }
4443
-
4444
- // node_modules/micromark-extension-gfm-table/lib/infer.js
4445
- function gfmTableAlign(events, index) {
4446
- let inDelimiterRow = false;
4447
- const align = [];
4448
- while (index < events.length) {
4449
- const event = events[index];
4450
- if (inDelimiterRow) {
4451
- if (event[0] === "enter") {
4452
- if (event[1].type === "tableContent") {
4453
- align.push(events[index + 1][1].type === "tableDelimiterMarker" ? "left" : "none");
4454
- }
4455
- } else if (event[1].type === "tableContent") {
4456
- if (events[index - 1][1].type === "tableDelimiterMarker") {
4457
- const alignIndex = align.length - 1;
4458
- align[alignIndex] = align[alignIndex] === "left" ? "center" : "right";
4459
- }
4460
- } else if (event[1].type === "tableDelimiterRow") {
4461
- break;
4462
- }
4463
- } else if (event[0] === "enter" && event[1].type === "tableDelimiterRow") {
4464
- inDelimiterRow = true;
4465
- }
4466
- index += 1;
4467
- }
4468
- return align;
4469
- }
4470
-
4471
- // node_modules/micromark-extension-gfm-table/lib/syntax.js
4472
- function gfmTable() {
4473
- return {
4474
- flow: {
4475
- null: {
4476
- name: "table",
4477
- tokenize: tokenizeTable,
4478
- resolveAll: resolveTable
4479
- }
4480
- }
4481
- };
4482
- }
4483
- function tokenizeTable(effects, ok2, nok) {
4484
- const self = this;
4485
- let size = 0;
4486
- let sizeB = 0;
4487
- let seen;
4488
- return start;
4489
- function start(code3) {
4490
- let index = self.events.length - 1;
4491
- while (index > -1) {
4492
- const type = self.events[index][1].type;
4493
- if (type === "lineEnding" || // Note: markdown-rs uses `whitespace` instead of `linePrefix`
4494
- type === "linePrefix") index--;
4495
- else break;
4496
- }
4497
- const tail = index > -1 ? self.events[index][1].type : null;
4498
- const next = tail === "tableHead" || tail === "tableRow" ? bodyRowStart : headRowBefore;
4499
- if (next === bodyRowStart && self.parser.lazy[self.now().line]) {
4500
- return nok(code3);
4501
- }
4502
- return next(code3);
4503
- }
4504
- function headRowBefore(code3) {
4505
- effects.enter("tableHead");
4506
- effects.enter("tableRow");
4507
- return headRowStart(code3);
4508
- }
4509
- function headRowStart(code3) {
4510
- if (code3 === 124) {
4511
- return headRowBreak(code3);
4512
- }
4513
- seen = true;
4514
- sizeB += 1;
4515
- return headRowBreak(code3);
4516
- }
4517
- function headRowBreak(code3) {
4518
- if (code3 === null) {
4519
- return nok(code3);
4520
- }
4521
- if (markdownLineEnding2(code3)) {
4522
- if (sizeB > 1) {
4523
- sizeB = 0;
4524
- self.interrupt = true;
4525
- effects.exit("tableRow");
4526
- effects.enter("lineEnding");
4527
- effects.consume(code3);
4528
- effects.exit("lineEnding");
4529
- return headDelimiterStart;
4530
- }
4531
- return nok(code3);
4532
- }
4533
- if (markdownSpace3(code3)) {
4534
- return factorySpace(effects, headRowBreak, "whitespace")(code3);
4535
- }
4536
- sizeB += 1;
4537
- if (seen) {
4538
- seen = false;
4539
- size += 1;
4540
- }
4541
- if (code3 === 124) {
4542
- effects.enter("tableCellDivider");
4543
- effects.consume(code3);
4544
- effects.exit("tableCellDivider");
4545
- seen = true;
4546
- return headRowBreak;
4547
- }
4548
- effects.enter("data");
4549
- return headRowData(code3);
4550
- }
4551
- function headRowData(code3) {
4552
- if (code3 === null || code3 === 124 || markdownLineEndingOrSpace3(code3)) {
4553
- effects.exit("data");
4554
- return headRowBreak(code3);
4555
- }
4556
- effects.consume(code3);
4557
- return code3 === 92 ? headRowEscape : headRowData;
4558
- }
4559
- function headRowEscape(code3) {
4560
- if (code3 === 92 || code3 === 124) {
4561
- effects.consume(code3);
4562
- return headRowData;
4563
- }
4564
- return headRowData(code3);
4565
- }
4566
- function headDelimiterStart(code3) {
4567
- self.interrupt = false;
4568
- if (self.parser.lazy[self.now().line]) {
4569
- return nok(code3);
4570
- }
4571
- effects.enter("tableDelimiterRow");
4572
- seen = false;
4573
- if (markdownSpace3(code3)) {
4574
- return factorySpace(effects, headDelimiterBefore, "linePrefix", self.parser.constructs.disable.null.includes("codeIndented") ? void 0 : 4)(code3);
4575
- }
4576
- return headDelimiterBefore(code3);
4577
- }
4578
- function headDelimiterBefore(code3) {
4579
- if (code3 === 45 || code3 === 58) {
4580
- return headDelimiterValueBefore(code3);
4581
- }
4582
- if (code3 === 124) {
4583
- seen = true;
4584
- effects.enter("tableCellDivider");
4585
- effects.consume(code3);
4586
- effects.exit("tableCellDivider");
4587
- return headDelimiterCellBefore;
4588
- }
4589
- return headDelimiterNok(code3);
4590
- }
4591
- function headDelimiterCellBefore(code3) {
4592
- if (markdownSpace3(code3)) {
4593
- return factorySpace(effects, headDelimiterValueBefore, "whitespace")(code3);
4594
- }
4595
- return headDelimiterValueBefore(code3);
4596
- }
4597
- function headDelimiterValueBefore(code3) {
4598
- if (code3 === 58) {
4599
- sizeB += 1;
4600
- seen = true;
4601
- effects.enter("tableDelimiterMarker");
4602
- effects.consume(code3);
4603
- effects.exit("tableDelimiterMarker");
4604
- return headDelimiterLeftAlignmentAfter;
4605
- }
4606
- if (code3 === 45) {
4607
- sizeB += 1;
4608
- return headDelimiterLeftAlignmentAfter(code3);
4609
- }
4610
- if (code3 === null || markdownLineEnding2(code3)) {
4611
- return headDelimiterCellAfter(code3);
4612
- }
4613
- return headDelimiterNok(code3);
4614
- }
4615
- function headDelimiterLeftAlignmentAfter(code3) {
4616
- if (code3 === 45) {
4617
- effects.enter("tableDelimiterFiller");
4618
- return headDelimiterFiller(code3);
4619
- }
4620
- return headDelimiterNok(code3);
4621
- }
4622
- function headDelimiterFiller(code3) {
4623
- if (code3 === 45) {
4624
- effects.consume(code3);
4625
- return headDelimiterFiller;
4626
- }
4627
- if (code3 === 58) {
4628
- seen = true;
4629
- effects.exit("tableDelimiterFiller");
4630
- effects.enter("tableDelimiterMarker");
4631
- effects.consume(code3);
4632
- effects.exit("tableDelimiterMarker");
4633
- return headDelimiterRightAlignmentAfter;
4634
- }
4635
- effects.exit("tableDelimiterFiller");
4636
- return headDelimiterRightAlignmentAfter(code3);
4637
- }
4638
- function headDelimiterRightAlignmentAfter(code3) {
4639
- if (markdownSpace3(code3)) {
4640
- return factorySpace(effects, headDelimiterCellAfter, "whitespace")(code3);
4641
- }
4642
- return headDelimiterCellAfter(code3);
4643
- }
4644
- function headDelimiterCellAfter(code3) {
4645
- if (code3 === 124) {
4646
- return headDelimiterBefore(code3);
4647
- }
4648
- if (code3 === null || markdownLineEnding2(code3)) {
4649
- if (!seen || size !== sizeB) {
4650
- return headDelimiterNok(code3);
4651
- }
4652
- effects.exit("tableDelimiterRow");
4653
- effects.exit("tableHead");
4654
- return ok2(code3);
4655
- }
4656
- return headDelimiterNok(code3);
4657
- }
4658
- function headDelimiterNok(code3) {
4659
- return nok(code3);
4660
- }
4661
- function bodyRowStart(code3) {
4662
- effects.enter("tableRow");
4663
- return bodyRowBreak(code3);
4664
- }
4665
- function bodyRowBreak(code3) {
4666
- if (code3 === 124) {
4667
- effects.enter("tableCellDivider");
4668
- effects.consume(code3);
4669
- effects.exit("tableCellDivider");
4670
- return bodyRowBreak;
4671
- }
4672
- if (code3 === null || markdownLineEnding2(code3)) {
4673
- effects.exit("tableRow");
4674
- return ok2(code3);
4675
- }
4676
- if (markdownSpace3(code3)) {
4677
- return factorySpace(effects, bodyRowBreak, "whitespace")(code3);
4678
- }
4679
- effects.enter("data");
4680
- return bodyRowData(code3);
4681
- }
4682
- function bodyRowData(code3) {
4683
- if (code3 === null || code3 === 124 || markdownLineEndingOrSpace3(code3)) {
4684
- effects.exit("data");
4685
- return bodyRowBreak(code3);
4686
- }
4687
- effects.consume(code3);
4688
- return code3 === 92 ? bodyRowEscape : bodyRowData;
4689
- }
4690
- function bodyRowEscape(code3) {
4691
- if (code3 === 92 || code3 === 124) {
4692
- effects.consume(code3);
4693
- return bodyRowData;
4694
- }
4695
- return bodyRowData(code3);
4696
- }
4697
- }
4698
- function resolveTable(events, context) {
4699
- let index = -1;
4700
- let inFirstCellAwaitingPipe = true;
4701
- let rowKind = 0;
4702
- let lastCell = [0, 0, 0, 0];
4703
- let cell = [0, 0, 0, 0];
4704
- let afterHeadAwaitingFirstBodyRow = false;
4705
- let lastTableEnd = 0;
4706
- let currentTable;
4707
- let currentBody;
4708
- let currentCell;
4709
- const map2 = new EditMap();
4710
- while (++index < events.length) {
4711
- const event = events[index];
4712
- const token = event[1];
4713
- if (event[0] === "enter") {
4714
- if (token.type === "tableHead") {
4715
- afterHeadAwaitingFirstBodyRow = false;
4716
- if (lastTableEnd !== 0) {
4717
- flushTableEnd(map2, context, lastTableEnd, currentTable, currentBody);
4718
- currentBody = void 0;
4719
- lastTableEnd = 0;
4720
- }
4721
- currentTable = {
4722
- type: "table",
4723
- start: Object.assign({}, token.start),
4724
- // Note: correct end is set later.
4725
- end: Object.assign({}, token.end)
4726
- };
4727
- map2.add(index, 0, [["enter", currentTable, context]]);
4728
- } else if (token.type === "tableRow" || token.type === "tableDelimiterRow") {
4729
- inFirstCellAwaitingPipe = true;
4730
- currentCell = void 0;
4731
- lastCell = [0, 0, 0, 0];
4732
- cell = [0, index + 1, 0, 0];
4733
- if (afterHeadAwaitingFirstBodyRow) {
4734
- afterHeadAwaitingFirstBodyRow = false;
4735
- currentBody = {
4736
- type: "tableBody",
4737
- start: Object.assign({}, token.start),
4738
- // Note: correct end is set later.
4739
- end: Object.assign({}, token.end)
4740
- };
4741
- map2.add(index, 0, [["enter", currentBody, context]]);
4742
- }
4743
- rowKind = token.type === "tableDelimiterRow" ? 2 : currentBody ? 3 : 1;
4744
- } else if (rowKind && (token.type === "data" || token.type === "tableDelimiterMarker" || token.type === "tableDelimiterFiller")) {
4745
- inFirstCellAwaitingPipe = false;
4746
- if (cell[2] === 0) {
4747
- if (lastCell[1] !== 0) {
4748
- cell[0] = cell[1];
4749
- currentCell = flushCell(map2, context, lastCell, rowKind, void 0, currentCell);
4750
- lastCell = [0, 0, 0, 0];
4751
- }
4752
- cell[2] = index;
4753
- }
4754
- } else if (token.type === "tableCellDivider") {
4755
- if (inFirstCellAwaitingPipe) {
4756
- inFirstCellAwaitingPipe = false;
4757
- } else {
4758
- if (lastCell[1] !== 0) {
4759
- cell[0] = cell[1];
4760
- currentCell = flushCell(map2, context, lastCell, rowKind, void 0, currentCell);
4761
- }
4762
- lastCell = cell;
4763
- cell = [lastCell[1], index, 0, 0];
4764
- }
4765
- }
4766
- } else if (token.type === "tableHead") {
4767
- afterHeadAwaitingFirstBodyRow = true;
4768
- lastTableEnd = index;
4769
- } else if (token.type === "tableRow" || token.type === "tableDelimiterRow") {
4770
- lastTableEnd = index;
4771
- if (lastCell[1] !== 0) {
4772
- cell[0] = cell[1];
4773
- currentCell = flushCell(map2, context, lastCell, rowKind, index, currentCell);
4774
- } else if (cell[1] !== 0) {
4775
- currentCell = flushCell(map2, context, cell, rowKind, index, currentCell);
4776
- }
4777
- rowKind = 0;
4778
- } else if (rowKind && (token.type === "data" || token.type === "tableDelimiterMarker" || token.type === "tableDelimiterFiller")) {
4779
- cell[3] = index;
4780
- }
4781
- }
4782
- if (lastTableEnd !== 0) {
4783
- flushTableEnd(map2, context, lastTableEnd, currentTable, currentBody);
4784
- }
4785
- map2.consume(context.events);
4786
- index = -1;
4787
- while (++index < context.events.length) {
4788
- const event = context.events[index];
4789
- if (event[0] === "enter" && event[1].type === "table") {
4790
- event[1]._align = gfmTableAlign(context.events, index);
4791
- }
4792
- }
4793
- return events;
4794
- }
4795
- function flushCell(map2, context, range, rowKind, rowEnd, previousCell) {
4796
- const groupName = rowKind === 1 ? "tableHeader" : rowKind === 2 ? "tableDelimiter" : "tableData";
4797
- const valueName = "tableContent";
4798
- if (range[0] !== 0) {
4799
- previousCell.end = Object.assign({}, getPoint(context.events, range[0]));
4800
- map2.add(range[0], 0, [["exit", previousCell, context]]);
4801
- }
4802
- const now = getPoint(context.events, range[1]);
4803
- previousCell = {
4804
- type: groupName,
4805
- start: Object.assign({}, now),
4806
- // Note: correct end is set later.
4807
- end: Object.assign({}, now)
4808
- };
4809
- map2.add(range[1], 0, [["enter", previousCell, context]]);
4810
- if (range[2] !== 0) {
4811
- const relatedStart = getPoint(context.events, range[2]);
4812
- const relatedEnd = getPoint(context.events, range[3]);
4813
- const valueToken = {
4814
- type: valueName,
4815
- start: Object.assign({}, relatedStart),
4816
- end: Object.assign({}, relatedEnd)
4817
- };
4818
- map2.add(range[2], 0, [["enter", valueToken, context]]);
4819
- if (rowKind !== 2) {
4820
- const start = context.events[range[2]];
4821
- const end = context.events[range[3]];
4822
- start[1].end = Object.assign({}, end[1].end);
4823
- start[1].type = "chunkText";
4824
- start[1].contentType = "text";
4825
- if (range[3] > range[2] + 1) {
4826
- const a = range[2] + 1;
4827
- const b = range[3] - range[2] - 1;
4828
- map2.add(a, b, []);
4829
- }
4830
- }
4831
- map2.add(range[3] + 1, 0, [["exit", valueToken, context]]);
4832
- }
4833
- if (rowEnd !== void 0) {
4834
- previousCell.end = Object.assign({}, getPoint(context.events, rowEnd));
4835
- map2.add(rowEnd, 0, [["exit", previousCell, context]]);
4836
- previousCell = void 0;
4837
- }
4838
- return previousCell;
4839
- }
4840
- function flushTableEnd(map2, context, index, table2, tableBody) {
4841
- const exits = [];
4842
- const related = getPoint(context.events, index);
4843
- if (tableBody) {
4844
- tableBody.end = Object.assign({}, related);
4845
- exits.push(["exit", tableBody, context]);
4846
- }
4847
- table2.end = Object.assign({}, related);
4848
- exits.push(["exit", table2, context]);
4849
- map2.add(index + 1, 0, exits);
4850
- }
4851
- function getPoint(events, index) {
4852
- const event = events[index];
4853
- const side = event[0] === "enter" ? "start" : "end";
4854
- return event[1][side];
4855
- }
4856
-
4857
4119
  // node_modules/micromark-extension-gfm-task-list-item/lib/syntax.js
4858
- import { markdownLineEnding as markdownLineEnding3, markdownLineEndingOrSpace as markdownLineEndingOrSpace4, markdownSpace as markdownSpace4 } from "micromark-util-character";
4120
+ import { markdownLineEnding as markdownLineEnding2, markdownLineEndingOrSpace as markdownLineEndingOrSpace3, markdownSpace as markdownSpace3 } from "micromark-util-character";
4859
4121
  var tasklistCheck = {
4860
4122
  name: "tasklistCheck",
4861
4123
  tokenize: tokenizeTasklistCheck
@@ -4886,7 +4148,7 @@ function tokenizeTasklistCheck(effects, ok2, nok) {
4886
4148
  return inside;
4887
4149
  }
4888
4150
  function inside(code3) {
4889
- if (markdownLineEndingOrSpace4(code3)) {
4151
+ if (markdownLineEndingOrSpace3(code3)) {
4890
4152
  effects.enter("taskListCheckValueUnchecked");
4891
4153
  effects.consume(code3);
4892
4154
  effects.exit("taskListCheckValueUnchecked");
@@ -4911,10 +4173,10 @@ function tokenizeTasklistCheck(effects, ok2, nok) {
4911
4173
  return nok(code3);
4912
4174
  }
4913
4175
  function after(code3) {
4914
- if (markdownLineEnding3(code3)) {
4176
+ if (markdownLineEnding2(code3)) {
4915
4177
  return ok2(code3);
4916
4178
  }
4917
- if (markdownSpace4(code3)) {
4179
+ if (markdownSpace3(code3)) {
4918
4180
  return effects.check({
4919
4181
  tokenize: spaceThenNonSpace
4920
4182
  }, ok2, nok)(code3);
@@ -5268,11 +4530,10 @@ function jinjaBlockTransform(tree) {
5268
4530
  }
5269
4531
 
5270
4532
  // src/markdown/parser.ts
5271
- var gfmNoAutolink = () => combineExtensions([gfmFootnote(), gfmStrikethrough(), gfmTable(), gfmTaskListItem()]);
4533
+ var gfmNoAutolink = () => combineExtensions([gfmFootnote(), gfmStrikethrough(), gfmTaskListItem()]);
5272
4534
  var gfmNoAutolinkFromMarkdown = () => [
5273
4535
  gfmFootnoteFromMarkdown(),
5274
4536
  gfmStrikethroughFromMarkdown(),
5275
- gfmTableFromMarkdown(),
5276
4537
  gfmTaskListItemFromMarkdown()
5277
4538
  ];
5278
4539
  var MAX_DEPTH5 = 128;