Update editor, themes, menus, backgrounds, and release tooling
This commit is contained in:
@@ -2,12 +2,14 @@ import type { EditorView } from "@codemirror/view";
|
||||
import { actionIcon } from "../ui/actionIcons";
|
||||
import { moveTableAxis, type TableAxis } from "./tableStructure";
|
||||
import type { CellRange } from "./tableSelection";
|
||||
import { attachTooltip } from "../ui/tooltip";
|
||||
|
||||
const controls = new WeakMap<HTMLTableElement, (axis: TableAxis, index: number, keyboard: boolean) => void>();
|
||||
|
||||
export function tableDragControls(root: HTMLElement, wrapper: HTMLElement, table: HTMLTableElement, scroll: HTMLElement, view: EditorView, source: () => string, select: (range: CellRange) => void, change: (text: string, structural: boolean) => void) {
|
||||
const lifecycle = new AbortController(), options = { signal: lifecycle.signal };
|
||||
const handles: { axis: TableAxis; index: number; button: HTMLButtonElement }[] = [];
|
||||
const tooltipCleanup: (() => void)[] = [];
|
||||
const layer = document.createElement("div");
|
||||
layer.className = "table-drag-layer";
|
||||
wrapper.append(layer);
|
||||
@@ -172,8 +174,7 @@ export function tableDragControls(root: HTMLElement, wrapper: HTMLElement, table
|
||||
const label = `Move ${axis} ${index + 1}`;
|
||||
const tooltip = `${label} · Drag to reorder · ${axis === "row" ? "↑/↓" : "←/→"} to move`;
|
||||
button.setAttribute("aria-label", label);
|
||||
button.title = tooltip;
|
||||
button.dataset.tooltip = tooltip;
|
||||
tooltipCleanup.push(attachTooltip(button, () => drag ? "" : tooltip));
|
||||
button.append(actionIcon("grip"));
|
||||
layer.append(button);
|
||||
handles.push({ axis, index, button });
|
||||
@@ -222,5 +223,5 @@ export function tableDragControls(root: HTMLElement, wrapper: HTMLElement, table
|
||||
const observer = new ResizeObserver(scheduleLayout);
|
||||
observer.observe(table); observer.observe(scroll);
|
||||
scheduleLayout();
|
||||
return { destroy() { cancel(); cancelAnimationFrame(layoutFrame); lifecycle.abort(); observer.disconnect(); controls.delete(table); } };
|
||||
return { destroy() { cancel(); tooltipCleanup.forEach(dispose => dispose()); cancelAnimationFrame(layoutFrame); lifecycle.abort(); observer.disconnect(); controls.delete(table); } };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user