@usememos/editor 26.10.0 → 26.10.2

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.
@@ -1,20 +1,51 @@
1
- type Placement = 'below' | 'above';
1
+ import { type Icon } from '../icons.js';
2
+ export type Placement = 'below' | 'above';
3
+ /** Sets the element an editor's popups are appended to (the `popupContainer` option). */
4
+ export declare function setPopupContainer(owner: HTMLElement, container: HTMLElement | undefined): void;
5
+ /** Where the popups of the editor `owner` go: `popupContainer`, else the nearest open dialog or `aria-modal` ancestor, else the body. */
6
+ export declare function popupContainer(owner: HTMLElement): HTMLElement;
7
+ /**
8
+ * Appends a shown `position: fixed` element to its container, and returns
9
+ * the offset of its containing block. The offset is not zero when an
10
+ * ancestor has a `transform`, `filter` or `contain` style, which makes
11
+ * `position: fixed` relative to that ancestor instead of the viewport.
12
+ */
13
+ export declare function attach(el: HTMLElement, owner: HTMLElement): {
14
+ x: number;
15
+ y: number;
16
+ };
17
+ /** The visible part of the layout viewport, which the on-screen keyboard can shrink. */
18
+ export declare function visibleViewport(view: Window): {
19
+ left: number;
20
+ top: number;
21
+ width: number;
22
+ height: number;
23
+ };
2
24
  export declare const isMac: boolean;
25
+ /** Safari, which sends the Enter that commits a composition after `compositionend`. */
26
+ export declare const isSafari: boolean;
3
27
  /** True on touch devices, which have no hover and show their own menu over a selection. */
4
28
  export declare const isTouch: () => boolean;
5
29
  export declare class Popup {
6
30
  private readonly owner;
7
31
  readonly el: HTMLElement;
8
32
  private open;
33
+ private placed;
9
34
  constructor(owner: HTMLElement, className: string);
10
35
  get isOpen(): boolean;
11
- /** Shows the popup next to `rect` (viewport coordinates), flipping to stay on screen. */
36
+ /** The side of the anchor the popup was last shown on. */
37
+ get side(): Placement;
38
+ /**
39
+ * Shows the popup next to `rect` (viewport coordinates), flipping to stay
40
+ * on screen. With `align: 'end'`, its right edge lines up with `rect.right`
41
+ * (for right-to-left text).
42
+ */
12
43
  show(rect: {
13
44
  left: number;
14
45
  top: number;
15
46
  bottom: number;
16
47
  right?: number;
17
- }, placement?: Placement, gap?: number): void;
48
+ }, placement?: Placement, gap?: number, align?: 'start' | 'end'): void;
18
49
  hide(): void;
19
50
  destroy(): void;
20
51
  private copyTheme;
@@ -22,8 +53,12 @@ export declare class Popup {
22
53
  export interface MenuItem {
23
54
  id: string;
24
55
  label: string;
25
- /** Short glyph shown before the label. */
26
- icon?: string;
56
+ /** Secondary text after the label. */
57
+ detail?: string;
58
+ /** Text in the label to mark (the query): its first case-insensitive occurrence. */
59
+ mark?: string;
60
+ /** Shown before the label: text, or an element that is cloned. */
61
+ icon?: Icon;
27
62
  /** Extra words that match when filtering. */
28
63
  aliases?: string[];
29
64
  danger?: boolean;
@@ -41,13 +76,27 @@ export declare class Menu {
41
76
  private readonly id;
42
77
  /** Called after an item runs. */
43
78
  onPicked: (() => void) | null;
79
+ /** Called when the highlight moves, by key, by mouse or because the items changed. */
80
+ onHighlight: ((index: number) => void) | null;
44
81
  constructor(owner: HTMLElement, className: string, role?: 'listbox' | 'menu');
45
82
  get el(): HTMLElement;
46
83
  get isOpen(): boolean;
47
84
  get activeDescendant(): string | null;
48
85
  setSections(sections: MenuSection[], emptyLabel?: string): void;
86
+ /** Replaces the items with a line of text that is not an option, such as "Loading…". */
87
+ setMessage(text: string, className: string): void;
88
+ /** Marks the list as waiting for newer items (`aria-busy`). */
89
+ set busy(busy: boolean);
49
90
  get count(): number;
91
+ /** The ID of the highlighted item. */
92
+ get activeId(): string | null;
93
+ /** Highlights the item with this ID. Returns false when there is none. */
94
+ highlightId(id: string): boolean;
95
+ /** Moves the highlight by a page: the number of items that fit in the list's height. Stops at the ends. */
96
+ page(direction: 1 | -1): void;
50
97
  highlight(i: number): void;
98
+ /** The index of the highlighted item. */
99
+ get activeIndex(): number;
51
100
  move(delta: number): void;
52
101
  pick(i?: number): void;
53
102
  hide(): void;
@@ -55,4 +104,3 @@ export declare class Menu {
55
104
  }
56
105
  /** Case-insensitive match of a query against an item's label and aliases (a substring, also with spaces ignored). */
57
106
  export declare function matches(item: Pick<MenuItem, 'label' | 'aliases'>, query: string): boolean;
58
- export {};
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Scrolls `from` and each of its ancestors that scroll, then the window, by the least
3
+ * amount that shows `rect`. Like `scrollIntoView({ block: 'nearest' })`, but
4
+ * for a rectangle, so a caret inside a tall block is shown, not the block's top.
5
+ */
6
+ export declare function scrollRectIntoView(from: Element, rect: DOMRect): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@usememos/editor",
3
- "version": "26.10.0",
3
+ "version": "26.10.2",
4
4
  "description": "A block editor for standard Markdown. Zero runtime dependencies, with an optional React component.",
5
5
  "keywords": [
6
6
  "markdown",
@@ -50,11 +50,15 @@
50
50
  "prepack": "npm run build"
51
51
  },
52
52
  "peerDependencies": {
53
- "react": ">=18"
53
+ "react": ">=18",
54
+ "react-dom": ">=18"
54
55
  },
55
56
  "peerDependenciesMeta": {
56
57
  "react": {
57
58
  "optional": true
59
+ },
60
+ "react-dom": {
61
+ "optional": true
58
62
  }
59
63
  }
60
64
  }