@prosekit/web 0.5.1 → 0.5.3

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,7 +1,6 @@
1
1
  import { BaseElementConstructor } from '@aria-ui/core';
2
2
  import { ConnectableElement } from '@aria-ui/core';
3
3
  import { Context } from '@aria-ui/core';
4
- import { config as default_alias_1 } from '@prosekit/dev/config-vitest';
5
4
  import type { defineTableCommands } from '@prosekit/extensions/table';
6
5
  import { Editor } from '@prosekit/core';
7
6
  import type { EditorView } from '@prosekit/pm/view';
@@ -17,7 +16,6 @@ import { MenuContentEvents } from '@aria-ui/menu/elements';
17
16
  import { MenuContentProps } from '@aria-ui/menu/elements';
18
17
  import { MenuItemEvents } from '@aria-ui/menu';
19
18
  import { MenuItemProps } from '@aria-ui/menu';
20
- import { Options } from 'tsup';
21
19
  import { OverlayPositionerEvents } from '@aria-ui/overlay/elements';
22
20
  import { OverlayPositionerEvents as OverlayPositionerEvents_2 } from '@aria-ui/overlay';
23
21
  import { OverlayPositionerProps } from '@aria-ui/overlay/elements';
@@ -370,10 +368,6 @@ export declare const blockPopoverContext: Context<BlockPopoverContext>;
370
368
 
371
369
  export declare function calcResize(position: 'top' | 'right' | 'bottom' | 'left' | 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right', w: number, h: number, dx: number, dy: number, aspectRatio: number | null | undefined): [w: number, h: number];
372
370
 
373
- export declare const default_alias: Options | Options[] | ((overrideOptions: Options) => Options | Options[] | Promise<Options | Options[]>);
374
-
375
- export { default_alias_1 }
376
-
377
371
  export declare function defaultQueryBuilder(match: RegExpExecArray): string;
378
372
 
379
373
  export declare function defineCustomElement(name: string, constructor: CustomElementConstructor, options?: ElementDefinitionOptions): void;
@@ -4,8 +4,7 @@ import {
4
4
  } from "@aria-ui/core";
5
5
  function useEditorExtension(host, editor, extension) {
6
6
  useEffect(host, () => {
7
- var _a;
8
- return (_a = editor.get()) == null ? void 0 : _a.use(extension);
7
+ return editor.get()?.use(extension);
9
8
  });
10
9
  }
11
10
 
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-ZGQ225UP.js";
4
4
  import {
5
5
  useEditorExtension
6
- } from "./chunk-MZSYOTZT.js";
6
+ } from "./chunk-WTW6FOH3.js";
7
7
 
8
8
  // src/components/autocomplete/autocomplete-empty/element.gen.ts
9
9
  import { defineCustomElement, registerCustomElement } from "@aria-ui/core";
@@ -54,15 +54,16 @@ function useAutocompleteItem(element, { state, emit }) {
54
54
  useListboxItem(element, { state, emit });
55
55
  const open = openContext.consume(element);
56
56
  useEffect(element, () => {
57
- var _a;
58
57
  if (!state.value.peek() && open.get()) {
59
- state.value.set((_a = element.textContent) != null ? _a : "");
58
+ state.value.set(element.textContent ?? "");
60
59
  }
61
60
  });
62
61
  }
63
62
 
64
63
  // src/components/autocomplete/autocomplete-item/types.ts
65
- import { listboxItemEvents } from "@aria-ui/listbox";
64
+ import {
65
+ listboxItemEvents
66
+ } from "@aria-ui/listbox";
66
67
  var autocompleteItemProps = {
67
68
  value: {
68
69
  default: ""
@@ -92,8 +93,8 @@ import {
92
93
  useListbox
93
94
  } from "@aria-ui/listbox/elements";
94
95
  import {
95
- Priority,
96
96
  defineDOMEventHandler,
97
+ Priority,
97
98
  withPriority
98
99
  } from "@prosekit/core";
99
100
  function useAutocompleteList(element, { state, emit }) {
@@ -107,9 +108,8 @@ function useAutocompleteList(element, { state, emit }) {
107
108
  );
108
109
  useEffect2(element, () => {
109
110
  element.addEventListener("valueChange", () => {
110
- var _a;
111
111
  if (onSubmit) {
112
- (_a = onSubmit.get()) == null ? void 0 : _a();
112
+ onSubmit.get()?.();
113
113
  }
114
114
  });
115
115
  });
@@ -211,8 +211,8 @@ import {
211
211
  import { useOverlayPositionerState } from "@aria-ui/overlay/elements";
212
212
  import { usePresence } from "@aria-ui/presence";
213
213
  import {
214
- Priority as Priority2,
215
214
  defineKeymap,
215
+ Priority as Priority2,
216
216
  withPriority as withPriority2
217
217
  } from "@prosekit/core";
218
218
  import {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  useEditorExtension
3
- } from "./chunk-MZSYOTZT.js";
3
+ } from "./chunk-WTW6FOH3.js";
4
4
 
5
5
  // src/components/block-handle/block-handle-add/element.gen.ts
6
6
  import { defineCustomElement, registerCustomElement } from "@aria-ui/core";
@@ -60,7 +60,10 @@ import {
60
60
  useEffect,
61
61
  useEventListener as useEventListener2
62
62
  } from "@aria-ui/core";
63
- import { Fragment, Slice } from "@prosekit/pm/model";
63
+ import {
64
+ Fragment,
65
+ Slice
66
+ } from "@prosekit/pm/model";
64
67
  import { NodeSelection } from "@prosekit/pm/state";
65
68
  function useBlockHandleDraggable(host, { state }) {
66
69
  const context = blockPopoverContext.consume(host);
@@ -73,9 +76,8 @@ function useBlockHandleDraggable(host, { state }) {
73
76
  }
74
77
  function usePointerDownHandler(host, context, editor) {
75
78
  useEventListener2(host, "pointerdown", () => {
76
- var _a, _b;
77
- const { pos } = (_a = context.get()) != null ? _a : {};
78
- const { view } = (_b = editor.get()) != null ? _b : {};
79
+ const { pos } = context.get() ?? {};
80
+ const { view } = editor.get() ?? {};
79
81
  if (pos == null || view == null) {
80
82
  return;
81
83
  }
@@ -89,9 +91,8 @@ function usePointerDownHandler(host, context, editor) {
89
91
  }
90
92
  function useDraggingPreview(host, context, editor) {
91
93
  useEventListener2(host, "dragstart", (event) => {
92
- var _a;
93
94
  const hoverState = context.get();
94
- const { view } = (_a = editor.get()) != null ? _a : {};
95
+ const { view } = editor.get() ?? {};
95
96
  if (!hoverState || !view || !event.dataTransfer) {
96
97
  return;
97
98
  }
@@ -149,7 +150,10 @@ import { useOverlayPositionerState } from "@aria-ui/overlay/elements";
149
150
  import { usePresence } from "@aria-ui/presence";
150
151
 
151
152
  // src/components/block-handle/block-handle-popover/pointer-move.ts
152
- import { defineDOMEventHandler, union } from "@prosekit/core";
153
+ import {
154
+ defineDOMEventHandler,
155
+ union
156
+ } from "@prosekit/core";
153
157
 
154
158
  // src/utils/throttle.ts
155
159
  function throttle(callback, wait) {
@@ -166,13 +170,12 @@ function throttle(callback, wait) {
166
170
  // src/components/block-handle/block-handle-popover/pointer-move.ts
167
171
  function defineElementHoverHandler(handler) {
168
172
  const handlePointerEvent = (view, event) => {
169
- var _a;
170
173
  const rect = view.dom.getBoundingClientRect();
171
- const pos = (_a = view.posAtCoords({
174
+ const pos = view.posAtCoords({
172
175
  top: event.clientY,
173
176
  // Use the center of the editor
174
177
  left: rect.left + rect.width / 2
175
- })) == null ? void 0 : _a.inside;
178
+ })?.inside;
176
179
  if (pos == null || pos < 0) {
177
180
  handler(null, null);
178
181
  return;
@@ -232,8 +235,7 @@ function useBlockHandlePopover(host, { state }) {
232
235
  blockPopoverContext.provide(host, context);
233
236
  const open = createSignal2(false);
234
237
  useEffect2(host, () => {
235
- var _a;
236
- open.set(!!((_a = context.get()) == null ? void 0 : _a.element));
238
+ open.set(!!context.get()?.element);
237
239
  });
238
240
  useHoverExtension(host, editor, (referenceValue, hoverState) => {
239
241
  reference.set(referenceValue);
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  useEditorExtension
3
- } from "./chunk-MZSYOTZT.js";
3
+ } from "./chunk-WTW6FOH3.js";
4
4
 
5
5
  // src/components/inline-popover/inline-popover/element.gen.ts
6
6
  import { defineCustomElement, registerCustomElement } from "@aria-ui/core";
@@ -34,7 +34,9 @@ function useEditorUpdateEvent(host, editor, handler) {
34
34
  }
35
35
 
36
36
  // src/hooks/use-keymap.ts
37
- import { defineKeymap } from "@prosekit/core";
37
+ import {
38
+ defineKeymap
39
+ } from "@prosekit/core";
38
40
  function useKeymap(host, editor, keymap) {
39
41
  const extension = defineKeymap(keymap);
40
42
  return useEditorExtension(host, editor, extension);
@@ -67,7 +69,7 @@ function getDomDecoration(view) {
67
69
  }
68
70
  function getDomRange(view) {
69
71
  const win = view.dom.ownerDocument.defaultView;
70
- const selection = win == null ? void 0 : win.getSelection();
72
+ const selection = win?.getSelection();
71
73
  if (!selection || selection.isCollapsed) {
72
74
  return;
73
75
  }
@@ -26,7 +26,10 @@ import { defineCustomElement as defineCustomElement2, registerCustomElement as r
26
26
  import { usePopoverRoot } from "@aria-ui/popover/elements";
27
27
 
28
28
  // src/components/popover/popover-root/types.ts
29
- import { popoverRootEvents, popoverRootProps } from "@aria-ui/popover/elements";
29
+ import {
30
+ popoverRootEvents,
31
+ popoverRootProps
32
+ } from "@aria-ui/popover/elements";
30
33
 
31
34
  // src/components/popover/popover-root/element.gen.ts
32
35
  var PopoverRootElement = class extends defineCustomElement2({
@@ -121,19 +121,17 @@ function useResizableHandleState(host, state, context) {
121
121
  let aspectRatio = 1;
122
122
  const pointerPressing = createSignal(false);
123
123
  const handlePointerDown = (event) => {
124
- var _a;
125
124
  event.preventDefault();
126
125
  pointerPressing.set(true);
127
126
  startX = event.x;
128
127
  startY = event.y;
129
- const size = (_a = context.onResizeStart.get()) == null ? void 0 : _a();
128
+ const size = context.onResizeStart.get()?.();
130
129
  if (size) {
131
130
  ;
132
131
  [width, height, aspectRatio] = size;
133
132
  }
134
133
  };
135
134
  const handlePointerMove = (event) => {
136
- var _a;
137
135
  event.preventDefault();
138
136
  const dx = event.x - startX;
139
137
  const dy = event.y - startY;
@@ -145,13 +143,12 @@ function useResizableHandleState(host, state, context) {
145
143
  dy,
146
144
  aspectRatio
147
145
  );
148
- (_a = context.onResize.get()) == null ? void 0 : _a(w, h);
146
+ context.onResize.get()?.(w, h);
149
147
  };
150
148
  const handlePointerUp = (event) => {
151
- var _a;
152
149
  event.preventDefault();
153
150
  pointerPressing.set(false);
154
- (_a = context.onResizeEnd.get()) == null ? void 0 : _a();
151
+ context.onResizeEnd.get()?.();
155
152
  };
156
153
  useEffect(host, () => {
157
154
  host.addEventListener("pointerdown", handlePointerDown);
@@ -200,9 +197,8 @@ import {
200
197
  function useResizableRoot(host, { state, emit }) {
201
198
  const resizing = createSignal2(false);
202
199
  const onResizeStart = () => {
203
- var _a;
204
200
  const { width, height } = host.getBoundingClientRect();
205
- let aspectRatio = (_a = state.aspectRatio.peek()) != null ? _a : width / height;
201
+ let aspectRatio = state.aspectRatio.peek() ?? width / height;
206
202
  if (!isFinitePositiveNumber(aspectRatio)) {
207
203
  aspectRatio = 0;
208
204
  }
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-ZGQ225UP.js";
4
4
  import {
5
5
  useEditorExtension
6
- } from "./chunk-MZSYOTZT.js";
6
+ } from "./chunk-WTW6FOH3.js";
7
7
 
8
8
  // src/components/table-handle/table-handle-column-root/element.gen.ts
9
9
  import { defineCustomElement, registerCustomElement } from "@aria-ui/core";
@@ -34,13 +34,11 @@ function useTableHandleColumnRoot(host, { state }) {
34
34
  const { editor, ...overlayState } = state;
35
35
  const rootContext = tableHandleRootContext.consume(host);
36
36
  const colFirstCellPos = createComputed(() => {
37
- var _a;
38
- return (_a = rootContext.get()) == null ? void 0 : _a.colFirstCellPos;
37
+ return rootContext.get()?.colFirstCellPos;
39
38
  });
40
39
  const referenceCell = createComputed(() => {
41
- var _a;
42
40
  const pos = colFirstCellPos.get();
43
- const view = (_a = editor.get()) == null ? void 0 : _a.view;
41
+ const view = editor.get()?.view;
44
42
  if (!pos || !view) return null;
45
43
  return view.nodeDOM(pos);
46
44
  });
@@ -99,9 +97,8 @@ function useTableHandleColumnTrigger(host, { state }) {
99
97
  useMenuTrigger(host);
100
98
  const context = tableHandleRootContext.consume(host);
101
99
  useEventListener(host, "pointerdown", () => {
102
- var _a;
103
100
  const editor = state.editor.peek();
104
- const cellPos = (_a = context.peek()) == null ? void 0 : _a.cellPos;
101
+ const cellPos = context.peek()?.cellPos;
105
102
  if (!editor || !cellPos) return;
106
103
  editor.exec(selectTableColumn({ head: cellPos }));
107
104
  });
@@ -250,13 +247,18 @@ import {
250
247
  createSignal as createSignal4,
251
248
  useEffect as useEffect3
252
249
  } from "@aria-ui/core";
253
- import { defineDOMEventHandler as defineDOMEventHandler2 } from "@prosekit/core";
250
+ import {
251
+ defineDOMEventHandler as defineDOMEventHandler2
252
+ } from "@prosekit/core";
254
253
 
255
254
  // src/hooks/use-editor-typing.ts
256
255
  import {
257
256
  createSignal as createSignal3
258
257
  } from "@aria-ui/core";
259
- import { defineDOMEventHandler, union } from "@prosekit/core";
258
+ import {
259
+ defineDOMEventHandler,
260
+ union
261
+ } from "@prosekit/core";
260
262
  function useEditorTyping(host, editor) {
261
263
  const typing = createSignal3(false);
262
264
  const handleKeypress = () => {
@@ -274,16 +276,18 @@ function useEditorTyping(host, editor) {
274
276
  }
275
277
 
276
278
  // src/components/table-handle/utils.ts
277
- import { cellAround, TableMap } from "prosemirror-tables";
279
+ import {
280
+ cellAround,
281
+ TableMap
282
+ } from "prosemirror-tables";
278
283
  function isHoveringCellInfoEqual(a, b) {
279
284
  if (!a && !b) return true;
280
285
  if (!a || !b) return false;
281
286
  return a.rowIndex === b.rowIndex && a.colIndex === b.colIndex && a.cellPos === b.cellPos && a.rowFirstCellPos === b.rowFirstCellPos && a.colFirstCellPos === b.colFirstCellPos;
282
287
  }
283
288
  function domCellAround(target) {
284
- var _a;
285
289
  while (target && target.nodeName != "TD" && target.nodeName != "TH") {
286
- target = ((_a = target.classList) == null ? void 0 : _a.contains("ProseMirror")) ? null : target.parentNode;
290
+ target = target.classList?.contains("ProseMirror") ? null : target.parentNode;
287
291
  }
288
292
  return target;
289
293
  }
@@ -353,18 +357,17 @@ function useHoveringCell(host, editor) {
353
357
  function defineCellHoverHandler(handler) {
354
358
  const pointerHandler = (view, event) => {
355
359
  const hoveringCell = getHoveringCell(view, event);
356
- return handler(hoveringCell != null ? hoveringCell : null);
360
+ return handler(hoveringCell ?? null);
357
361
  };
358
362
  return defineDOMEventHandler2("pointerover", pointerHandler);
359
363
  }
360
364
  function useSelecting(host, editor, isInTable) {
361
365
  const selecting = createSignal4(false);
362
366
  useEffect3(host, () => {
363
- var _a;
364
367
  if (!isInTable.get()) {
365
368
  return;
366
369
  }
367
- const root = (_a = editor.peek()) == null ? void 0 : _a.view.root;
370
+ const root = editor.peek()?.view.root;
368
371
  if (!root) {
369
372
  return;
370
373
  }
@@ -425,13 +428,11 @@ function useTableHandleRowRoot(host, { state }) {
425
428
  const { editor, ...overlayState } = state;
426
429
  const rootContext = tableHandleRootContext.consume(host);
427
430
  const rowFirstCellPos = createComputed4(() => {
428
- var _a;
429
- return (_a = rootContext.get()) == null ? void 0 : _a.rowFirstCellPos;
431
+ return rootContext.get()?.rowFirstCellPos;
430
432
  });
431
433
  const referenceCell = createComputed4(() => {
432
- var _a;
433
434
  const pos = rowFirstCellPos.get();
434
- const view = (_a = editor.get()) == null ? void 0 : _a.view;
435
+ const view = editor.get()?.view;
435
436
  if (!pos || !view) return null;
436
437
  return view.nodeDOM(pos);
437
438
  });
@@ -493,9 +494,8 @@ function useTableHandleRowTrigger(host, {
493
494
  useMenuTrigger2(host);
494
495
  const context = tableHandleRootContext.consume(host);
495
496
  useEventListener2(host, "pointerdown", () => {
496
- var _a;
497
497
  const editor = state.editor.peek();
498
- const cellPos = (_a = context.peek()) == null ? void 0 : _a.cellPos;
498
+ const cellPos = context.peek()?.cellPos;
499
499
  if (!editor || !cellPos) return;
500
500
  editor.exec(selectTableRow({ head: cellPos }));
501
501
  });
@@ -26,7 +26,10 @@ import { defineCustomElement as defineCustomElement2, registerCustomElement as r
26
26
  import { useTooltipRoot } from "@aria-ui/tooltip/elements";
27
27
 
28
28
  // src/components/tooltip/tooltip-root/types.ts
29
- import { tooltipRootEvents, tooltipRootProps } from "@aria-ui/tooltip/elements";
29
+ import {
30
+ tooltipRootEvents,
31
+ tooltipRootProps
32
+ } from "@aria-ui/tooltip/elements";
30
33
 
31
34
  // src/components/tooltip/tooltip-root/element.gen.ts
32
35
  var TooltipRootElement = class extends defineCustomElement2({
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@prosekit/web",
3
3
  "type": "module",
4
- "version": "0.5.1",
4
+ "version": "0.5.3",
5
5
  "private": false,
6
6
  "author": {
7
7
  "name": "ocavue",
@@ -71,31 +71,31 @@
71
71
  ],
72
72
  "dependencies": {
73
73
  "@aria-ui/collection": "^0.0.4",
74
- "@aria-ui/core": "^0.0.19",
75
- "@aria-ui/listbox": "^0.0.20",
76
- "@aria-ui/menu": "^0.0.15",
77
- "@aria-ui/overlay": "^0.0.21",
78
- "@aria-ui/popover": "^0.0.23",
79
- "@aria-ui/presence": "^0.0.16",
80
- "@aria-ui/tooltip": "^0.0.25",
74
+ "@aria-ui/core": "^0.0.20",
75
+ "@aria-ui/listbox": "^0.0.22",
76
+ "@aria-ui/menu": "^0.0.17",
77
+ "@aria-ui/overlay": "^0.0.23",
78
+ "@aria-ui/popover": "^0.0.25",
79
+ "@aria-ui/presence": "^0.0.17",
80
+ "@aria-ui/tooltip": "^0.0.27",
81
81
  "@floating-ui/dom": "^1.6.12",
82
- "@zag-js/dom-query": "^0.78.0",
82
+ "@zag-js/dom-query": "^0.79.3",
83
83
  "just-map-values": "^3.2.0",
84
84
  "just-omit": "^2.2.0",
85
- "prosemirror-tables": "^1.6.1",
86
- "@prosekit/core": "^0.7.13",
87
- "@prosekit/extensions": "^0.7.22",
88
- "@prosekit/pm": "^0.1.9"
85
+ "prosemirror-tables": "^1.6.2",
86
+ "@prosekit/core": "^0.7.14",
87
+ "@prosekit/pm": "^0.1.9",
88
+ "@prosekit/extensions": "^0.7.23"
89
89
  },
90
90
  "devDependencies": {
91
91
  "tsup": "^8.3.5",
92
- "typescript": "^5.6.3",
93
- "vitest": "^2.1.6",
92
+ "typescript": "~5.7.2",
93
+ "vitest": "^2.1.8",
94
94
  "@prosekit/dev": "0.0.0"
95
95
  },
96
96
  "scripts": {
97
- "build:tsup": "tsup",
98
- "build:tsc": "tsc -b tsconfig.json"
97
+ "build:tsc": "tsc -b tsconfig.json",
98
+ "build:tsup": "tsup"
99
99
  },
100
100
  "types": "./dist/prosekit-web.d.ts",
101
101
  "typesVersions": {