Files
outline/app/editor/extensions/UpArrowAtStart.ts
T
Tom Moor fca10221b9 chore: promote no-explicit-any from warn to error (#12244)
* chore: promote no-explicit-any from warn to error and resolve violations

Upgrades the oxlint rule severity and removes all 40 existing
`no-explicit-any` warnings across the codebase. Most call sites gained
proper types (SharedEditor refs, JSONNode/JSONMark for ProseMirror JSON
walking, DocumentsStore, dd-trace `Span` parameter inference, prosemirror
Fragment public API in place of internal `(fragment as any).content`).
A few load-bearing `any` uses were preserved with scoped disable
comments where changing the type would cascade widely (Sequelize JSONB
columns on `Event`, the `withTracing` higher-order function generic,
`Extension.options` consumed by many subclasses, dd-trace's `req`
patching).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-02 12:14:23 -04:00

48 lines
1.4 KiB
TypeScript

import { Plugin } from "prosemirror-state";
import type { EditorView } from "prosemirror-view";
import Extension from "@shared/editor/lib/Extension";
export default class UpArrowAtStart extends Extension {
get name() {
return "upArrowAtStart";
}
get plugins() {
return [
new Plugin({
props: {
handleKeyDown: (view: EditorView, event: KeyboardEvent) => {
// Only handle up arrow key
if (event.key !== "ArrowUp") {
return false;
}
const { state } = view;
const { selection } = state;
// Check if cursor is at the very beginning of the document
// and it's an empty selection (cursor, not text selection)
if (selection.empty && selection.from <= 1) {
// Also check if we're at the start of the first text node
const $pos = state.doc.resolve(selection.from);
const isAtDocStart = $pos.parentOffset === 0 && $pos.depth <= 1;
if (isAtDocStart) {
const props = this.editor.props as {
onUpArrowAtStart?: () => void;
};
if (props.onUpArrowAtStart) {
props.onUpArrowAtStart();
return true;
}
}
}
return false;
},
},
}),
];
}
}