@blankdotpage/cake 0.1.6 → 0.1.7

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.
@@ -68,6 +68,8 @@ export declare class CakeEngine {
68
68
  private handleCompositionStartBound;
69
69
  private handleCompositionEndBound;
70
70
  private handleSelectionChangeBound;
71
+ private handleFocusInBound;
72
+ private handleFocusOutBound;
71
73
  private handleScrollBound;
72
74
  private handleResizeBound;
73
75
  private handleClickBound;
@@ -100,6 +102,7 @@ export declare class CakeEngine {
100
102
  getFocusRect(): SelectionRect | null;
101
103
  getContainer(): HTMLElement;
102
104
  getContentRoot(): HTMLElement | null;
105
+ getLines(): import("./selection/selection-layout").LineInfo[];
103
106
  getOverlayRoot(): HTMLDivElement;
104
107
  syncPlaceholder(): void;
105
108
  insertText(text: string): void;
@@ -117,11 +120,15 @@ export declare class CakeEngine {
117
120
  redo(): void;
118
121
  canUndo(): boolean;
119
122
  canRedo(): boolean;
120
- executeCommand(command: EditCommand): boolean;
123
+ executeCommand(command: EditCommand, options?: {
124
+ restoreFocus?: boolean;
125
+ }): boolean;
121
126
  private attachListeners;
122
127
  private attachDragListeners;
123
128
  private detachDragListeners;
124
129
  private detachListeners;
130
+ private handleFocusIn;
131
+ private handleFocusOut;
125
132
  private render;
126
133
  private isEmptyParagraphDoc;
127
134
  private updatePlaceholder;
@@ -7,6 +7,7 @@ export declare function toLayoutRect(params: {
7
7
  left: number;
8
8
  };
9
9
  }): LayoutRect;
10
+ export declare function groupDomRectsByRow(rects: DOMRect[]): DOMRect[];
10
11
  export declare function createDomLayoutMeasurer(params: {
11
12
  root: HTMLElement;
12
13
  container: HTMLElement;
@@ -35,3 +36,14 @@ export declare function createOffsetToXMeasurer(params: {
35
36
  lines: LineInfo[];
36
37
  }): (lineIndex: number, offsetInLine: number) => number | null;
37
38
  export declare function cursorOffsetToDomOffset(cursorToCodeUnit: number[], offset: number): number;
39
+ export type HitTestResult = {
40
+ cursorOffset: number;
41
+ pastRowEnd: boolean;
42
+ };
43
+ export declare function hitTestFromLayout(params: {
44
+ clientX: number;
45
+ clientY: number;
46
+ root: HTMLElement;
47
+ container: HTMLElement;
48
+ lines: LineInfo[];
49
+ }): HitTestResult | null;
@@ -1,2 +1,3 @@
1
1
  export { CakeEditor } from "./react/CakeEditor";
2
2
  export type { CakeEditorProps, CakeEditorRef, CakeEditorSelection, CakeEditorUpdate, } from "./react/CakeEditor";
3
+ export type { EditCommand, CoreEditCommand, ExtensionCommand } from "./core/runtime";
@@ -1,5 +1,4 @@
1
- import type { StateCommand } from "@codemirror/state";
2
- import type { CakeExtension } from "../core/runtime";
1
+ import type { CakeExtension, EditCommand } from "../core/runtime";
3
2
  export type CakeEditorSelection = {
4
3
  start: number;
5
4
  end: number;
@@ -30,7 +29,22 @@ export interface CakeEditorRef {
30
29
  blur: () => void;
31
30
  hasFocus: () => boolean;
32
31
  selectAll: () => void;
33
- executeCommand: (command: StateCommand) => boolean;
32
+ /**
33
+ * Execute a semantic edit command.
34
+ *
35
+ * Semantic commands are defined by extensions and allow callers to use
36
+ * high-level commands like `{ type: "toggle-bold" }` instead of
37
+ * syntax-specific commands like `{ type: "toggle-inline", marker: "**" }`.
38
+ *
39
+ * Available commands depend on which extensions are registered.
40
+ *
41
+ * @param command - The command to execute
42
+ * @param options.restoreFocus - If true, refocus the editor after executing.
43
+ * Use this when calling from a toolbar button that steals focus.
44
+ */
45
+ executeCommand: (command: EditCommand, options?: {
46
+ restoreFocus?: boolean;
47
+ }) => boolean;
34
48
  applyUpdate: (update: CakeEditorUpdate) => void;
35
49
  getValue: () => string;
36
50
  getSelection: () => {