Improve editor, plugin updates, and window transfers for 0.1.41
This commit is contained in:
@@ -1,12 +1,24 @@
|
||||
import assert from "node:assert/strict";
|
||||
import test from "node:test";
|
||||
import { alignTableCells, clipboardCells, copyTableCells, deleteTableCells, formatTableCells, mapTableCells, pasteTableCells } from "../src/lib/editor/tableSelection.ts";
|
||||
import { alignTableCells, clipboardCells, copyTableCells, copyTableMarkdown, deleteTableCells, formatTableCells, mapTableCells, pasteTableCells } from "../src/lib/editor/tableSelection.ts";
|
||||
import { htmlToMarkdown } from "../src/lib/workspace/htmlToMarkdown.ts";
|
||||
import { parseMarkdownTable } from "../src/lib/editor/markdownTable.ts";
|
||||
import { renderMarkdownHtml, plainInlineMarkdown } from "../src/lib/workspace/noteHtml.ts";
|
||||
import { tableCellMarkdown } from "../src/lib/editor/tableCellMarkdown.ts";
|
||||
|
||||
const source = "| A | B | C |\r\n| --- | :---: | ---: |\r\n| one | two | three |\r\n| four | five | six |\r\n\r\nTail";
|
||||
const range = { anchor: { row: 2, column: 1 }, head: { row: 1, column: 0 } };
|
||||
test("selected cells retain table structure and line breaks through HTML clipboard", () => {
|
||||
const source = "| Name | Notes |\n| --- | --- |\n| **Alpha** | First<br>Second |";
|
||||
const range = { anchor: { row: 0, column: 0 }, head: { row: 1, column: 1 } };
|
||||
const copied = copyTableMarkdown(source, range);
|
||||
const pasted = htmlToMarkdown(renderMarkdownHtml(copied, new Map()));
|
||||
const table = parseMarkdownTable(pasted)!;
|
||||
assert.equal(table.columns, 2);
|
||||
assert.equal(table.rows.length, 3);
|
||||
assert.equal(table.rows[2].cells[0].text, "**Alpha**");
|
||||
assert.equal(table.rows[2].cells[1].text, "First<br>Second");
|
||||
});
|
||||
test("reversed rectangular selections only change selected cells and preserve CRLF", () => {
|
||||
const changed = formatTableCells(source, range, "bold");
|
||||
assert.equal(changed, source.replace("one", "**one**").replace("two", "**two**").replace("four", "**four**").replace("five", "**five**"));
|
||||
|
||||
Reference in New Issue
Block a user