Skip to content

Build your personal knowledge base with Trilium Notes

client/text editor/tables: improve some comments

Adorian Doran2647d442a99d
diff --git a/apps/client/src/menus/context_menu_utils.ts b/apps/client/src/menus/context_menu_utils.ts
index d6b86f718e..037e6ae295 100644
--- a/apps/client/src/menus/context_menu_utils.ts
+++ b/apps/client/src/menus/context_menu_utils.ts
@@ -48,9 +48,8 @@ export function submenuItem<T>(
}
/**
- * A row that runs `primary` when clicked and opens `primary` and its `variants` as a submenu. The
- * row shows the shortcut of `primary`. The submenu lists `primary` again because a tap on a touch
- * device only unfolds a submenu row. While `primary` is disabled, the row only opens the submenu.
+ * A row that runs `primary` on click and shows its shortcut. Its submenu lists `primary`, then
+ * `variants`: a tap on a touch device only opens a submenu row.
*/
export function splitMenuItem<T>(
primary: MenuCommandItem<T>,
diff --git a/apps/client/src/menus/note_context_menu.spec.ts b/apps/client/src/menus/note_context_menu.spec.ts
index 494410f6c5..2365e77984 100644
--- a/apps/client/src/menus/note_context_menu.spec.ts
+++ b/apps/client/src/menus/note_context_menu.spec.ts
@@ -294,7 +294,7 @@ describe("buildNoteContextMenuItems", () => {
"electron_context_menu.search_online",
"electron_context_menu.search_in_trilium"
]);
- // The table's paste rows join the paste variants, as a group of their own.
+ // The table's paste rows come after the paste variants and a separator.
expect(titles(submenu(items, "electron_context_menu.paste"))).toEqual([
"electron_context_menu.paste",
"electron_context_menu.paste-as-plain-text",
diff --git a/apps/client/src/menus/table_context_menu.spec.ts b/apps/client/src/menus/table_context_menu.spec.ts
index 34e6cc357d..35b63c35d2 100644
--- a/apps/client/src/menus/table_context_menu.spec.ts
+++ b/apps/client/src/menus/table_context_menu.spec.ts
@@ -161,7 +161,7 @@ describe("buildTableMenuSections", () => {
run(laterRow.main, LATER_ROW_TITLE);
expect(laterRow.executed).toEqual([LATER_ROW]);
- // Several rows below the first take neither item.
+ // A selection of several rows below the first shows neither item.
expect(titles(build([FIRST_ROWS, LATER_ROW]).main))
.toEqual(MAIN_TITLES.filter((title) => title !== FIRST_ROWS_TITLE));
});
@@ -369,10 +369,8 @@ describe("hasTableCellSelection", () => {
});
/**
- * A minimal editor double: `TableContextMenu` is present unless `hasPlugin` says otherwise, every
- * command is enabled except the ones in `disabledCommands`, and only the ones in
- * `checkedCommands` have a `true` value. Its paste target restores the selection unless
- * `restoreResult` is `false`.
+ * A minimal editor double: `TableContextMenu` is present unless `hasPlugin` says otherwise, and
+ * every command is enabled except the ones in `disabledCommands`.
*/
function stubEditor(
disabledCommands: string[] = [],
diff --git a/apps/client/src/menus/table_context_menu.ts b/apps/client/src/menus/table_context_menu.ts
index d82c387bf7..41023ba993 100644
--- a/apps/client/src/menus/table_context_menu.ts
+++ b/apps/client/src/menus/table_context_menu.ts
@@ -7,8 +7,7 @@ import { submenuItem } from "./context_menu_utils.js";
import { getTextEditorContaining } from "./text_editor_context_menu.js";
/**
- * The table sections of the text editor's right-click menu. `clipboard` is the host's clipboard
- * access, which the paste rows items need.
+ * The table sections of the text editor's right-click menu. `clipboard` enables the paste rows.
*
* Returns `null` when the click is not on a table cell of the active text editor.
*/
@@ -53,8 +52,7 @@ export function buildTableMenuSections(
trailingIcon: editor.commands.get(commandName)?.value === true ? "bx bx-check" : undefined
});
- // The header items are one toggle under two labels, so only the one enabled for the
- // selection is shown.
+ // One toggle under two labels: only the item enabled for the selection is shown.
const headerItem = [
toggleItem(t("table_context_menu.set_header_row"), "bx bx-dock-top",
"triliumSetTableHeaderRow"),
@@ -124,7 +122,7 @@ export function buildTableMenuSections(
/** The part of the menu host's paste support that the paste rows items use. */
export interface ClipboardAccess {
- /** Whether the clipboard holds anything to paste. */
+ /** Whether the clipboard has anything to paste. */
enabled: boolean;
/** Reads the HTML and plain-text flavors of the clipboard, empty when absent. */
read(): Promise<{ html: string; text: string }>;
@@ -144,9 +142,8 @@ export interface TableMenuSections {
/** Selection of the spanned rows or columns, or of the whole table. Shown below deletion. */
select: MenuItem<CommandNames>;
/**
- * Pasting the clipboard as new rows above or below the row of the selection. Shown in the
- * _Paste_ submenu; empty unless the selection is in one row and the host can read the
- * clipboard.
+ * Pasting the clipboard as new rows, shown in the _Paste_ submenu. Empty unless the selection
+ * is in one row and the host can read the clipboard.
*/
pasteRows: MenuItem<CommandNames>[];
}
diff --git a/packages/ckeditor5/src/plugins/cuttonote.ts b/packages/ckeditor5/src/plugins/cuttonote.ts
index 0109e0f894..c7853c6c33 100644
--- a/packages/ckeditor5/src/plugins/cuttonote.ts
+++ b/packages/ckeditor5/src/plugins/cuttonote.ts
@@ -18,9 +18,8 @@ export interface PasteTarget {
*/
paste(html: string, text: string): void;
/**
- * Moves the selection back onto the pinned ranges and releases them, for a paste that runs
- * through a command instead of `paste()`. Returns `false`, leaving the selection alone, when
- * the pinned content is gone.
+ * Moves the selection back onto the pinned ranges and releases them. Returns `false` when the
+ * pinned content is gone.
*/
restore(): boolean;
/** Detaches the pinned ranges without pasting. Safe to call more than once. */
diff --git a/packages/ckeditor5/src/plugins/table_context_menu.ts b/packages/ckeditor5/src/plugins/table_context_menu.ts
index e954ae05d3..b4576eb912 100644
--- a/packages/ckeditor5/src/plugins/table_context_menu.ts
+++ b/packages/ckeditor5/src/plugins/table_context_menu.ts
@@ -16,14 +16,11 @@ import { DistributeTableColumnsCommand } from "./table_distribute_columns.js";
* Editor-side support for the client's table context menu.
*
* Registers insert commands that honor the size of the current selection (the upstream
- * `insertTableRow*` / `insertTableColumn*` commands always insert one row or column),
- * `triliumDistributeTableColumns` and `triliumSelectTable`, the whole-table counterpart of the
- * upstream `selectTableRow` / `selectTableColumn`, and the two header-row commands over the
- * upstream `setTableRowHeader`, which differ in the selections they accept. Keeps a multi-cell
- * selection alive under a right-click, and moves the selection to the cell a context menu is
- * opened on. Merge, split and delete need no counterparts here: the upstream `mergeTableCells`,
- * `splitTableCell*` and `removeTableRow` / `removeTableColumn` commands already act on the whole
- * selection.
+ * `insertTableRow*` / `insertTableColumn*` commands always insert one row or column) and
+ * `triliumDistributeTableColumns`, keeps a multi-cell selection alive under a right-click, and
+ * moves the selection to the cell a context menu is opened on. Merge, split and delete need no
+ * counterparts here: the upstream `mergeTableCells`, `splitTableCell*` and `removeTableRow` /
+ * `removeTableColumn` commands already act on the whole selection.
*/
export default class TableContextMenu extends Plugin {
@@ -192,10 +189,8 @@ export class DeleteTableCommand extends Command {
export type TableHeaderRowsScope = "firstRows" | "laterRow";
/**
- * Toggles the heading rows through the upstream `setTableRowHeader`, enabled only for the
- * selections its scope covers. `value` is `true` while every selected row is a heading row;
- * executing then turns the selected rows and the heading rows below them into body rows.
- * Otherwise, it extends the heading rows down to the last selected row.
+ * Toggles the heading rows through the upstream `setTableRowHeader`, for the selections of its
+ * `scope`. `value` is `true` while every selected row is a heading row.
*/
export class TableHeaderRowsCommand extends Command {
diff --git a/packages/ckeditor5/src/plugins/table_paste_rows.ts b/packages/ckeditor5/src/plugins/table_paste_rows.ts
index 411a5a8955..caa325e8e5 100644
--- a/packages/ckeditor5/src/plugins/table_paste_rows.ts
+++ b/packages/ckeditor5/src/plugins/table_paste_rows.ts
@@ -35,11 +35,8 @@ export interface TablePasteRowsOptions {
}
/**
- * Pastes clipboard content as new rows above or below the row of the selection, then selects
- * them. A pasted table becomes one row per table row, starting at the first column, and widens
- * the table when it has more columns; other content goes in the first cell of one new row. The
- * rows go outside any block of rows that a merged cell joins. Enabled while the selection is in
- * a single row.
+ * Pastes clipboard content as new rows next to the row of the selection, and selects them.
+ * Enabled while the selection is in a single row.
*/
export class TablePasteRowsCommand extends Command {
@@ -74,6 +71,7 @@ export class TablePasteRowsCommand extends Command {
return;
}
+ // The new rows go outside the block of rows that merged cells join to this one.
const [group] = splitIntoGroups(table, "row", tableUtils.getRowIndexes(cells));
const at = this.direction === "above" ? group.first : group.last + 1;
let insertedRows = 0;
diff --git a/packages/commons/src/lib/electron_api_interface.ts b/packages/commons/src/lib/electron_api_interface.ts
index 090a10c734..950c67cb09 100644
--- a/packages/commons/src/lib/electron_api_interface.ts
+++ b/packages/commons/src/lib/electron_api_interface.ts
@@ -233,7 +233,7 @@ export interface ElectronClipboardApi {
/**
* Reads the HTML flavor of the system clipboard, the same way as {@link readText}. Empty when
- * the clipboard holds no HTML.
+ * the clipboard has no HTML.
*/
readHTML(): Promise<string>;
}