@prosekit/lit 0.0.0-next-20231120040948 → 0.0.0-next-20240421132240

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.
Files changed (39) hide show
  1. package/dist/_tsup-dts-rollup.d.ts +33 -433
  2. package/dist/prosekit-lit-autocomplete.d.ts +4 -0
  3. package/dist/prosekit-lit-autocomplete.js +11 -0
  4. package/dist/prosekit-lit-block-handle.d.ts +2 -0
  5. package/dist/prosekit-lit-block-handle.js +7 -0
  6. package/dist/prosekit-lit-inline-popover.d.ts +0 -3
  7. package/dist/prosekit-lit-inline-popover.js +2 -151
  8. package/dist/prosekit-lit-popover.d.ts +3 -5
  9. package/dist/prosekit-lit-popover.js +7 -7
  10. package/dist/prosekit-lit-resizable.d.ts +2 -0
  11. package/dist/prosekit-lit-resizable.js +7 -0
  12. package/dist/prosekit-lit-tooltip.d.ts +3 -0
  13. package/dist/prosekit-lit-tooltip.js +9 -0
  14. package/package.json +35 -73
  15. package/dist/chunk-55G7TJI3.js +0 -48
  16. package/dist/chunk-6P3YKUWI.js +0 -9
  17. package/dist/chunk-7WLKD2U6.js +0 -184
  18. package/dist/chunk-C4MW43I4.js +0 -9
  19. package/dist/chunk-GWGDLLFN.js +0 -61
  20. package/dist/chunk-O5JP3B34.js +0 -31
  21. package/dist/chunk-PCXKL6TA.js +0 -109
  22. package/dist/chunk-XBNMYITV.js +0 -191
  23. package/dist/prosekit-lit-autocomplete-empty.d.ts +0 -3
  24. package/dist/prosekit-lit-autocomplete-empty.js +0 -44
  25. package/dist/prosekit-lit-autocomplete-item.d.ts +0 -3
  26. package/dist/prosekit-lit-autocomplete-item.js +0 -10
  27. package/dist/prosekit-lit-autocomplete-list.d.ts +0 -3
  28. package/dist/prosekit-lit-autocomplete-list.js +0 -12
  29. package/dist/prosekit-lit-autocomplete-popover.d.ts +0 -4
  30. package/dist/prosekit-lit-autocomplete-popover.js +0 -252
  31. package/dist/prosekit-lit-combo-box-input.d.ts +0 -3
  32. package/dist/prosekit-lit-combo-box-input.js +0 -72
  33. package/dist/prosekit-lit-combo-box-item.d.ts +0 -3
  34. package/dist/prosekit-lit-combo-box-item.js +0 -10
  35. package/dist/prosekit-lit-combo-box-list.d.ts +0 -3
  36. package/dist/prosekit-lit-combo-box-list.js +0 -48
  37. package/dist/prosekit-lit-combo-box.d.ts +0 -3
  38. package/dist/prosekit-lit-combo-box.js +0 -110
  39. package/src/index.ts +0 -1
@@ -1,456 +1,56 @@
1
- import { AutoUpdateOptions } from '@floating-ui/dom';
2
- import { ComputePositionConfig } from '@floating-ui/dom';
3
- import { CSSResult } from 'lit';
4
- import { Editor } from '@prosekit/core';
5
- import type { EditorView } from '@prosekit/pm/view';
6
- import { Keymap } from '@prosekit/core';
7
- import { LitElement } from 'lit';
1
+ import { AutocompleteEmptyElement as AutocompleteEmpty } from '@prosekit/web/autocomplete';
2
+ import { AutocompleteItemElement as AutocompleteItem } from '@prosekit/web/autocomplete';
3
+ import { AutocompleteListElement as AutocompleteList } from '@prosekit/web/autocomplete';
4
+ import { AutocompletePopoverElement as AutocompletePopover } from '@prosekit/web/autocomplete';
5
+ import { BlockDragHandleElement as BlockDragHandle } from '@prosekit/web/block-handle';
6
+ import { BlockPopoverElement as BlockPopover } from '@prosekit/web/block-handle';
7
+ import { InlinePopoverElement as InlinePopover } from '@prosekit/web/inline-popover';
8
8
  import { Options } from 'tsup';
9
- import { PropertyValues } from 'lit';
10
- import { ReactiveController } from 'lit';
11
- import { ReactiveControllerHost } from 'lit';
12
- import { TemplateResult } from 'lit';
13
- import { UserProjectConfigExport } from 'vitest/dist/config.js';
14
- import { VirtualElement } from '@floating-ui/dom';
9
+ import { PopoverContentElement as PopoverContent } from '@prosekit/web/popover';
10
+ import { PopoverRootElement as PopoverRoot } from '@prosekit/web/popover';
11
+ import { PopoverTriggerElement as PopoverTrigger } from '@prosekit/web/popover';
12
+ import { ResizableHandleElement as ResizableHandle } from '@prosekit/web/resizable';
13
+ import { ResizableRootElement as ResizableRoot } from '@prosekit/web/resizable';
14
+ import { TooltipContentElement as TooltipContent } from '@prosekit/web/tooltip';
15
+ import { TooltipRootElement as TooltipRoot } from '@prosekit/web/tooltip';
16
+ import { TooltipTriggerElement as TooltipTrigger } from '@prosekit/web/tooltip';
15
17
 
16
- export declare class AutocompleteEmpty extends LightElement implements AutocompleteEmptyProps {
17
- listContext?: AutocompleteListContext;
18
- connectedCallback(): void;
19
- protected willUpdate(_changedProperties: PropertyValues<this>): void;
20
- }
18
+ export { AutocompleteEmpty }
21
19
 
22
- export declare interface AutocompleteEmptyProps {
23
- }
24
-
25
- /**
26
- * Command menu item. Becomes active on pointer enter or through keyboard
27
- * navigation. Preferably pass a `value`, otherwise the value will be inferred
28
- * from the rendered item's `textContent`.
29
- */
30
- declare class AutocompleteItem extends LightElement implements Partial<AutocompleteItemProps> {
31
- value: string;
32
- selected: boolean;
33
- /** @hidden */
34
- onSelect?: VoidFunction;
35
- listContext?: AutocompleteListContext;
36
- get content(): string;
37
- connectedCallback(): void;
38
- protected willUpdate(): void;
39
- protected updated(changedProperties: PropertyValues<this>): void;
40
- }
41
20
  export { AutocompleteItem }
42
- export { AutocompleteItem as AutocompleteItem_alias_1 }
43
-
44
- declare interface AutocompleteItemProps {
45
- value?: string;
46
- onSelect: VoidFunction;
47
- }
48
- export { AutocompleteItemProps }
49
- export { AutocompleteItemProps as AutocompleteItemProps_alias_1 }
50
21
 
51
- declare class AutocompleteList extends LightElement implements Partial<AutocompleteListProps> {
52
- /** @hidden */
53
- private listManager;
54
- /** @hidden */
55
- private controller;
56
- private get active();
57
- editor?: Editor;
58
- popoverContext: AutocompletePopoverContext | null;
59
- context: AutocompleteListContext;
60
- connectedCallback(): void;
61
- private get items();
62
- selectFirstItem(): void;
63
- private updateValue;
64
- /** @hidden */
65
- willUpdate(changedProperties: PropertyValues<this>): void;
66
- }
67
22
  export { AutocompleteList }
68
- export { AutocompleteList as AutocompleteList_alias_1 }
69
-
70
- export declare interface AutocompleteListContext {
71
- scores: Map<string, number>;
72
- selectedValue: string;
73
- }
74
-
75
- export declare class AutocompleteListController implements ReactiveController {
76
- private host;
77
- private keymap;
78
- private editor;
79
- private cleanup;
80
- constructor(host: ReactiveControllerHost, keymap: Keymap);
81
- setEditor(editor: Editor): void;
82
- hostDisconnected(): void;
83
- private defineExtension;
84
- }
85
-
86
- declare interface AutocompleteListProps {
87
- editor: Editor;
88
- }
89
- export { AutocompleteListProps }
90
- export { AutocompleteListProps as AutocompleteListProps_alias_1 }
91
-
92
- export declare class AutocompletePopover extends Popover implements Partial<AutocompletePopoverProps> {
93
- /** @hidden */
94
- private controller;
95
- editor?: Editor;
96
- regex?: RegExp;
97
- popoverOptions: PopoverOptions;
98
- context: AutocompletePopoverContext;
99
- /** @hidden */
100
- onSelect?: VoidFunction;
101
- private get list();
102
- private updateContext;
103
- /** @hidden */
104
- willUpdate(changedProperties: PropertyValues<this>): void;
105
- /** @hidden */
106
- hide(): void;
107
- }
108
-
109
- export declare interface AutocompletePopoverContext {
110
- active: boolean;
111
- query: string;
112
- handleDismiss: VoidFunction;
113
- handleSubmit: VoidFunction;
114
- }
115
-
116
- export declare class AutocompletePopoverController implements ReactiveController {
117
- private host;
118
- private onChange;
119
- reference: Element | null;
120
- private editor;
121
- private regex;
122
- private cleanup;
123
- handleDismiss: VoidFunction | null;
124
- handleSubmit: VoidFunction | null;
125
- constructor(host: ReactiveControllerHost, onChange: (query: string, active: boolean) => void);
126
- setEditor(editor: Editor): void;
127
- setRegex(regex: RegExp): void;
128
- private defineExtension;
129
- hostDisconnected(): void;
130
- }
131
-
132
- export declare interface AutocompletePopoverProps {
133
- editor: Editor;
134
- regex: RegExp;
135
- popoverOptions?: PopoverOptions;
136
- }
137
-
138
- export { AutoUpdateOptions }
139
-
140
- export declare const blockComponentStyles: CSSResult;
141
-
142
- export declare class ComboBox extends Popover {
143
- onDismiss?: VoidFunction;
144
- private listManager;
145
- context: ComboBoxContext;
146
- get items(): ComboBoxItem[];
147
- }
148
-
149
- export declare interface ComboBoxContext {
150
- inputValue: string;
151
- setInputValue: (val: string) => void;
152
- selectedValue: string;
153
- setSelectedValue: (val: string) => void;
154
- listManager: ListManager<ComboBoxItem>;
155
- }
156
-
157
- export declare const comboBoxContext: {
158
- __context__: ComboBoxContext;
159
- };
160
-
161
- export declare class ComboBoxInput extends LightElement {
162
- placeholder: string;
163
- comboBoxContext: ComboBoxContext | null;
164
- private visible;
165
- private handleKeydown;
166
- private handleInput;
167
- protected firstUpdated(): void;
168
- /** @hidden */
169
- render(): TemplateResult<1>;
170
- }
171
-
172
- export declare interface ComboBoxInputProps {
173
- placeholder?: string;
174
- }
175
-
176
- declare class ComboBoxItem extends LightElement {
177
- editor?: Editor;
178
- selected: boolean;
179
- comboBoxContext?: ComboBoxContext;
180
- /** @hidden */
181
- onSelect?: VoidFunction;
182
- protected updated(): void;
183
- }
184
- export { ComboBoxItem }
185
- export { ComboBoxItem as ComboBoxItem_alias_1 }
186
-
187
- declare type ComboBoxItemProps = {
188
- onSelect?: VoidFunction;
189
- };
190
- export { ComboBoxItemProps }
191
- export { ComboBoxItemProps as ComboBoxItemProps_alias_1 }
192
-
193
- declare class ComboBoxList extends LightElement {
194
- comboBoxContext: ComboBoxContext | null;
195
- connectedCallback(): void;
196
- }
197
- export { ComboBoxList }
198
- export { ComboBoxList as ComboBoxList_alias_1 }
199
-
200
- declare type ComboBoxListProps = {
201
- lang?: string;
202
- };
203
- export { ComboBoxListProps }
204
- export { ComboBoxListProps as ComboBoxListProps_alias_1 }
205
-
206
- export declare interface ComboBoxProps extends PopoverProps {
207
- onDismiss?: VoidFunction;
208
- }
209
-
210
- export declare const commandListContext: {
211
- __context__: AutocompleteListContext;
212
- };
213
-
214
- export declare const commandPopoverContext: {
215
- __context__: AutocompletePopoverContext;
216
- };
217
23
 
218
- declare type CommandScore = (item: string, query: string) => number;
24
+ export { AutocompletePopover }
219
25
 
220
- export declare const commandScore: CommandScore;
26
+ export { BlockDragHandle }
221
27
 
222
- export declare const componentStyles: CSSResult;
28
+ export { BlockPopover }
223
29
 
224
30
  export declare const default_alias: Options | Options[] | ((overrideOptions: Options) => Options | Options[] | Promise<Options | Options[]>);
225
31
 
226
- export declare const default_alias_1: UserProjectConfigExport;
227
-
228
- /**
229
- * Default popover options.
230
- */
231
- export declare const defaultPopoverOptions: PopoverOptions;
232
-
233
- /**
234
- * Default popover options.
235
- */
236
- export declare const defaultPopoverOptions_alias_1: PopoverOptions;
237
-
238
- export declare const defaultPopoverOptions_alias_2: PopoverOptions;
239
-
240
- export declare function defaultQueryBuilder(match: RegExpExecArray): string;
241
-
242
- export declare function getVirtualSelectionElement(view: EditorView): Range | undefined;
243
-
244
- export declare class InlinePopover extends Popover implements Partial<InlinePopoverProps> {
245
- /** @hidden */
246
- private controller;
247
- editor?: Editor;
248
- popoverOptions: PopoverOptions;
249
- constructor();
250
- /** @hidden */
251
- willUpdate(): void;
252
- /** @hidden */
253
- hide(): void;
254
- }
255
-
256
- export declare class InlinePopoverController implements ReactiveController {
257
- private host;
258
- reference?: VirtualElement;
259
- private editor?;
260
- private cleanupExtension?;
261
- private cleanupEventListener?;
262
- private mouseHovering;
263
- constructor(host: ReactiveControllerHost);
264
- setEditor(editor: Editor): void;
265
- hostConnected(): void;
266
- hostDisconnected(): void;
267
- private update;
268
- private defineExtension;
269
- }
270
-
271
- export declare interface InlinePopoverProps {
272
- editor: Editor;
273
- popoverOptions?: PopoverOptions;
274
- }
275
-
276
- export declare function isAutocompleteItem(element?: Element | null): element is AutocompleteItem;
277
-
278
- export declare function isAutocompleteList(element?: Element | null): element is AutocompleteList;
279
-
280
- export declare function isComboBoxItem(element?: Element | null): element is ComboBoxItem;
281
-
282
- export declare function isComboBoxList(element?: Element | null): element is ComboBoxList;
283
-
284
- export declare class LightElement extends LitElement {
285
- createRenderRoot(): this;
286
- setHidden(hidden: boolean): void;
287
- }
288
-
289
- export declare class ListManager<Item extends {
290
- hidden: boolean;
291
- } & HTMLElement> {
292
- private lastMouseMoveTime;
293
- private getItems;
294
- private getSelectedValue;
295
- private setSelectedValue;
296
- private getItemValue;
297
- private queryClosestItem;
298
- private getActive;
299
- private onDismiss;
300
- private onSelect;
301
- constructor(options: {
302
- getItems: () => Item[];
303
- getSelectedValue: () => string;
304
- setSelectedValue: (value: string) => void;
305
- getItemValue: (item: Item) => string;
306
- queryClosestItem: (element: HTMLElement) => Item | null;
307
- getActive: () => boolean;
308
- onDismiss: () => void;
309
- onSelect: (item?: Item | null) => void;
310
- });
311
- get items(): Item[];
312
- get availableItems(): Item[];
313
- get firstItem(): Item | null;
314
- get selectedItem(): Item | null;
315
- private updateSelectedByChange;
316
- private handleSelect;
317
- selectFirstItem(): void;
318
- handleMouseMove(_event: MouseEvent): void;
319
- handleMouseOver(event: MouseEvent): void;
320
- handleMouseDown(event: MouseEvent): void;
321
- handleClick(event: MouseEvent): void;
322
- handleArrowUp(): boolean;
323
- handleArrowDown(): boolean;
324
- handleEscape(): boolean;
325
- handleEnter(): boolean;
326
- }
327
-
328
- /**
329
- * A custom element that displays a popover anchored to a reference element.
330
- */
331
- export declare class Popover extends LightElement implements Partial<PopoverProps> {
332
- /** @hidden */
333
- constructor();
334
- /**
335
- * Controls the visibility of the popover element. When set to `true`, the popover is displayed and positioned
336
- * relative to its reference element. When set to `false`, the popover is hidden and its positioning logic is
337
- * deactivated.
338
- */
339
- active: boolean;
340
- /**
341
- * The element that the popover is anchored to. This can be either a DOM element or an object that implements the
342
- * virtual element interface from Floating UI.
343
- */
344
- reference?: Element | VirtualElement;
345
- /**
346
- * The options that are passed to the `computePosition` function from Floating UI. These options are used to
347
- * configure the positioning of the popover element relative to its reference element. For more information on the
348
- * available options, please refer to the Floating UI documentation.
349
- */
350
- options?: PopoverOptions;
351
- /**
352
- * Controls whether the popover position is automatically updated when the reference element changes position. When
353
- * set to `true`, the popover position is updated automatically. When set to `false`, the popover position is only
354
- * updated when the given properties are changed.
355
- *
356
- * @default false
357
- */
358
- autoUpdate: boolean;
359
- /**
360
- * The options that are passed to the `autoUpdate` function from Floating UI. These options are used to configure the
361
- * automatic update behavior of the popover position. For more information on the available options, please refer to
362
- * the Floating UI documentation. This property is only used when the `autoUpdate` property is set to `true`.
363
- */
364
- autoUpdateOptions?: AutoUpdateOptions;
365
- /**
366
- * Controls whether the popover should be dismissed based on user interaction.
367
- *
368
- * Available options:
369
- *
370
- * - "off": The popover is not dismissed.
371
- * - "on": The popover is dismissed when the user clicks outside of the popover or presses the escape key.
372
- * - "click": The popover is dismissed when the user clicks outside of the popover.
373
- * - "escape": The popover is dismissed when the user presses the escape key.
374
- *
375
- * @default "on"
376
- */
377
- dismiss: string;
378
- /** @hidden */
379
- private disposeAutoUpdate?;
380
- /** @hidden */
381
- private disposeEventListeners?;
382
- /** @hidden */
383
- connectedCallback(): void;
384
- /** @hidden */
385
- disconnectedCallback(): void;
386
- /** @hidden */
387
- protected updated(changedProperties: PropertyValues<this>): void;
388
- /** @hidden */
389
- private start;
390
- /** @hidden */
391
- private compute;
392
- /** @hidden */
393
- hide(): void;
394
- private handleDocumentMouseDown;
395
- private handleDocumentKeyDown;
396
- }
397
-
398
- /**
399
- * The `PopoverOptions` interface defines the options that can be passed to the
400
- * `computePosition` function from Floating UI. These options are used to
401
- * configure the positioning of the popover element relative to its reference
402
- * element. For more information on the available options, please refer to the
403
- * Floating UI documentation.
404
- *
405
- * https://floating-ui.com/docs/computeposition#options
406
- */
407
- declare type PopoverOptions = ComputePositionConfig;
408
- export { PopoverOptions }
409
- export { PopoverOptions as PopoverOptions_alias_1 }
410
- export { PopoverOptions as PopoverOptions_alias_2 }
411
- export { PopoverOptions as PopoverOptions_alias_3 }
412
-
413
- export declare interface PopoverProps {
414
- active: boolean;
415
- reference?: Element | VirtualElement;
416
- options?: PopoverOptions;
417
- autoUpdate?: boolean;
418
- autoUpdateOptions?: AutoUpdateOptions;
419
- }
420
-
421
- export declare const propNames: readonly [];
422
-
423
- declare const propNames_2: readonly ["value", "onSelect"];
424
- export { propNames_2 as propNames_alias_1 }
425
- export { propNames_2 as propNames_alias_2 }
426
-
427
- declare const propNames_3: readonly ["editor"];
428
- export { propNames_3 as propNames_alias_3 }
429
- export { propNames_3 as propNames_alias_4 }
430
-
431
- declare const propNames_4: never[];
432
- export { propNames_4 as propNames_alias_8 }
433
- export { propNames_4 as propNames_alias_9 }
32
+ export declare const default_alias_1: {
33
+ test: {
34
+ environment: "jsdom";
35
+ };
36
+ };
434
37
 
435
- declare const propNames_5: never[];
436
- export { propNames_5 as propNames_alias_10 }
437
- export { propNames_5 as propNames_alias_11 }
38
+ export { InlinePopover }
438
39
 
439
- export declare const propNames_alias_12: readonly ["editor", "popoverOptions"];
40
+ export { PopoverContent }
440
41
 
441
- export declare const propNames_alias_13: readonly ["active", "reference", "options", "autoUpdate", "autoUpdateOptions"];
42
+ export { PopoverRoot }
442
43
 
443
- export declare const propNames_alias_5: readonly ["editor", "regex", "popoverOptions"];
44
+ export { PopoverTrigger }
444
45
 
445
- export declare const propNames_alias_6: readonly ["onDismiss"];
46
+ export { ResizableHandle }
446
47
 
447
- export declare const propNames_alias_7: readonly ["placeholder"];
48
+ export { ResizableRoot }
448
49
 
449
- export declare function queryClosestAutocompleteItem(element?: Element | null): AutocompleteItem | null;
50
+ export { TooltipContent }
450
51
 
451
- export declare function queryClosestComboBoxItem(element?: Element | null): ComboBoxItem | null;
52
+ export { TooltipRoot }
452
53
 
453
- /** Rounds a value to the nearest device pixel ratio. */
454
- export declare function roundByDPR(value: number): number;
54
+ export { TooltipTrigger }
455
55
 
456
56
  export { }
@@ -0,0 +1,4 @@
1
+ export { AutocompleteEmpty } from './_tsup-dts-rollup';
2
+ export { AutocompleteItem } from './_tsup-dts-rollup';
3
+ export { AutocompleteList } from './_tsup-dts-rollup';
4
+ export { AutocompletePopover } from './_tsup-dts-rollup';
@@ -0,0 +1,11 @@
1
+ // src/components/autocomplete/index.ts
2
+ import { AutocompleteEmptyElement } from "@prosekit/web/autocomplete";
3
+ import { AutocompleteItemElement } from "@prosekit/web/autocomplete";
4
+ import { AutocompleteListElement } from "@prosekit/web/autocomplete";
5
+ import { AutocompletePopoverElement } from "@prosekit/web/autocomplete";
6
+ export {
7
+ AutocompleteEmptyElement as AutocompleteEmpty,
8
+ AutocompleteItemElement as AutocompleteItem,
9
+ AutocompleteListElement as AutocompleteList,
10
+ AutocompletePopoverElement as AutocompletePopover
11
+ };
@@ -0,0 +1,2 @@
1
+ export { BlockDragHandle } from './_tsup-dts-rollup';
2
+ export { BlockPopover } from './_tsup-dts-rollup';
@@ -0,0 +1,7 @@
1
+ // src/components/block-handle/index.ts
2
+ import { BlockDragHandleElement } from "@prosekit/web/block-handle";
3
+ import { BlockPopoverElement } from "@prosekit/web/block-handle";
4
+ export {
5
+ BlockDragHandleElement as BlockDragHandle,
6
+ BlockPopoverElement as BlockPopover
7
+ };
@@ -1,4 +1 @@
1
- export { PopoverOptions_alias_1 as PopoverOptions } from './_tsup-dts-rollup';
2
- export { propNames_alias_12 as propNames } from './_tsup-dts-rollup';
3
- export { InlinePopoverProps } from './_tsup-dts-rollup';
4
1
  export { InlinePopover } from './_tsup-dts-rollup';
@@ -1,154 +1,5 @@
1
- import {
2
- Popover
3
- } from "./chunk-7WLKD2U6.js";
4
- import {
5
- __decorateClass
6
- } from "./chunk-O5JP3B34.js";
7
-
8
1
  // src/components/inline-popover/index.ts
9
- import "@prosekit/core";
10
- import { customElement, property } from "lit/decorators.js";
11
-
12
- // src/components/inline-popover/controller.ts
13
- import { defineUpdateHandler } from "@prosekit/core";
14
- import "lit";
15
-
16
- // src/components/inline-popover/helpers.ts
17
- import { isNodeSelection, isTextSelection } from "@prosekit/core";
18
- function getVirtualSelectionElement(view) {
19
- if (typeof window === "undefined" || view.isDestroyed) {
20
- return;
21
- }
22
- const selection = view.state.selection;
23
- if (!selection.empty && (isTextSelection(selection) || isNodeSelection(selection))) {
24
- return getDomRange();
25
- }
26
- }
27
- function getDomRange() {
28
- const selection = window.getSelection();
29
- if (!selection || selection.isCollapsed) {
30
- return;
31
- }
32
- const range = typeof selection.rangeCount === "number" && selection.rangeCount > 0 && selection.getRangeAt(0);
33
- if (!range) {
34
- return;
35
- }
36
- return range;
37
- }
38
-
39
- // src/components/inline-popover/controller.ts
40
- var InlinePopoverController = class {
41
- constructor(host) {
42
- this.host = host;
43
- this.mouseHovering = false;
44
- this.host.addController(this);
45
- }
46
- setEditor(editor) {
47
- if (this.editor !== editor) {
48
- this.editor = editor;
49
- this.defineExtension();
50
- this.host.requestUpdate();
51
- }
52
- }
53
- hostConnected() {
54
- var _a;
55
- const handleMouseDown = () => {
56
- this.mouseHovering = true;
57
- };
58
- const handleMouseUp = () => {
59
- this.mouseHovering = false;
60
- this.update();
61
- };
62
- document.addEventListener("mousedown", handleMouseDown);
63
- document.addEventListener("mouseup", handleMouseUp);
64
- (_a = this.cleanupEventListener) == null ? void 0 : _a.call(this);
65
- this.cleanupEventListener = () => {
66
- document.removeEventListener("mousedown", handleMouseDown);
67
- document.removeEventListener("mouseup", handleMouseUp);
68
- };
69
- }
70
- hostDisconnected() {
71
- var _a, _b;
72
- (_a = this.cleanupExtension) == null ? void 0 : _a.call(this);
73
- this.cleanupExtension = void 0;
74
- (_b = this.cleanupEventListener) == null ? void 0 : _b.call(this);
75
- this.cleanupEventListener = void 0;
76
- }
77
- update() {
78
- const editor = this.editor;
79
- if (!editor || this.mouseHovering) {
80
- return;
81
- }
82
- const reference = getVirtualSelectionElement(editor.view);
83
- if (this.reference !== reference) {
84
- this.reference = reference;
85
- this.host.requestUpdate();
86
- }
87
- }
88
- defineExtension() {
89
- var _a;
90
- const editor = this.editor;
91
- if (!editor) {
92
- return;
93
- }
94
- const extension = defineUpdateHandler(() => this.update());
95
- (_a = this.cleanupExtension) == null ? void 0 : _a.call(this);
96
- this.cleanupExtension = editor.use(extension);
97
- }
98
- };
99
-
100
- // src/components/inline-popover/default-popover-options.ts
101
- import { inline, offset, shift } from "@floating-ui/dom";
102
- var defaultPopoverOptions = {
103
- placement: "top",
104
- strategy: "absolute",
105
- middleware: [
106
- inline(),
107
- offset(8),
108
- shift({ mainAxis: true, crossAxis: true, padding: 8 })
109
- ]
110
- };
111
-
112
- // src/components/inline-popover/index.ts
113
- var propNames = ["editor", "popoverOptions"];
114
- var InlinePopover = class extends Popover {
115
- constructor() {
116
- super();
117
- /** @hidden */
118
- this.controller = new InlinePopoverController(this);
119
- this.popoverOptions = defaultPopoverOptions;
120
- this.dismiss = "escape";
121
- }
122
- /** @hidden */
123
- willUpdate() {
124
- var _a, _b;
125
- if (this.editor) {
126
- this.controller.setEditor(this.editor);
127
- }
128
- this.active = !!((_a = this.controller) == null ? void 0 : _a.reference);
129
- this.reference = (_b = this.controller.reference) != null ? _b : void 0;
130
- this.options = this.popoverOptions;
131
- }
132
- /** @hidden */
133
- hide() {
134
- var _a;
135
- super.hide();
136
- if ((_a = this.controller) == null ? void 0 : _a.reference) {
137
- this.controller.reference = void 0;
138
- this.reference = void 0;
139
- }
140
- }
141
- };
142
- __decorateClass([
143
- property({ attribute: false })
144
- ], InlinePopover.prototype, "editor", 2);
145
- __decorateClass([
146
- property({ attribute: false })
147
- ], InlinePopover.prototype, "popoverOptions", 2);
148
- InlinePopover = __decorateClass([
149
- customElement("prosekit-inline-popover")
150
- ], InlinePopover);
2
+ import { InlinePopoverElement } from "@prosekit/web/inline-popover";
151
3
  export {
152
- InlinePopover,
153
- propNames
4
+ InlinePopoverElement as InlinePopover
154
5
  };
@@ -1,5 +1,3 @@
1
- export { AutoUpdateOptions } from './_tsup-dts-rollup';
2
- export { PopoverOptions_alias_2 as PopoverOptions } from './_tsup-dts-rollup';
3
- export { propNames_alias_13 as propNames } from './_tsup-dts-rollup';
4
- export { PopoverProps } from './_tsup-dts-rollup';
5
- export { Popover } from './_tsup-dts-rollup';
1
+ export { PopoverContent } from './_tsup-dts-rollup';
2
+ export { PopoverRoot } from './_tsup-dts-rollup';
3
+ export { PopoverTrigger } from './_tsup-dts-rollup';