@prosekit/lit 0.0.20 → 0.0.22
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.
- package/dist/_tsup-dts-rollup.d.ts +23 -55
- package/dist/{chunk-LBLOUW67.js → chunk-KJJEZNYD.js} +16 -32
- package/dist/{chunk-KA7LSXZQ.js → chunk-P336E72L.js} +41 -17
- package/dist/{chunk-RTIPZK6D.js → chunk-XOVIMVFL.js} +12 -24
- package/dist/{chunk-IQHL2ANE.js → chunk-XTIVRSSC.js} +7 -16
- package/dist/{chunk-3UDA5JEW.js → chunk-ZN7DMIEB.js} +15 -10
- package/dist/prosekit-lit-autocomplete-empty.js +10 -16
- package/dist/prosekit-lit-autocomplete-item.js +2 -2
- package/dist/prosekit-lit-autocomplete-list.js +3 -3
- package/dist/prosekit-lit-autocomplete-popover.js +26 -29
- package/dist/prosekit-lit-code-block-popover.js +2 -3
- package/dist/prosekit-lit-combo-box-input.js +3 -5
- package/dist/prosekit-lit-combo-box-item.js +2 -3
- package/dist/prosekit-lit-combo-box-list.js +3 -5
- package/dist/prosekit-lit-combo-box.js +3 -4
- package/dist/prosekit-lit-popover.js +2 -3
- package/package.json +6 -6
- package/dist/chunk-TRZW33VF.js +0 -35
- package/src/index.ts +0 -1
@@ -2,7 +2,6 @@ import { AutoUpdateOptions } from '@floating-ui/dom';
|
|
2
2
|
import { CommandArgs } from '@prosekit/core';
|
3
3
|
import { ComputePositionConfig } from '@floating-ui/dom';
|
4
4
|
import { CSSResult } from 'lit';
|
5
|
-
import { CSSResultGroup } from 'lit';
|
6
5
|
import { Editor } from '@prosekit/core';
|
7
6
|
import { Extension } from '@prosekit/core';
|
8
7
|
import { ExtensionTyping } from '@prosekit/core';
|
@@ -17,13 +16,10 @@ import { TemplateResult } from 'lit';
|
|
17
16
|
import { UserProjectConfigExport } from 'vitest/dist/config.js';
|
18
17
|
import { VirtualElement } from '@floating-ui/dom';
|
19
18
|
|
20
|
-
export declare class AutocompleteEmpty extends
|
21
|
-
/** @hidden */
|
22
|
-
static styles: CSSResultGroup;
|
19
|
+
export declare class AutocompleteEmpty extends LightElement implements AutocompleteEmptyProps {
|
23
20
|
listContext?: AutocompleteListContext;
|
21
|
+
connectedCallback(): void;
|
24
22
|
protected willUpdate(_changedProperties: PropertyValues<this>): void;
|
25
|
-
/** @hidden */
|
26
|
-
render(): TemplateResult<1> | null;
|
27
23
|
}
|
28
24
|
|
29
25
|
export declare interface AutocompleteEmptyProps {
|
@@ -34,21 +30,16 @@ export declare interface AutocompleteEmptyProps {
|
|
34
30
|
* navigation. Preferably pass a `value`, otherwise the value will be inferred
|
35
31
|
* from the rendered item's `textContent`.
|
36
32
|
*/
|
37
|
-
declare class AutocompleteItem extends
|
38
|
-
/** @hidden */
|
39
|
-
static styles: CSSResultGroup;
|
33
|
+
declare class AutocompleteItem extends LightElement implements Partial<AutocompleteItemProps> {
|
40
34
|
value: string;
|
41
35
|
selected: boolean;
|
42
36
|
/** @hidden */
|
43
37
|
onSelect?: VoidFunction;
|
44
|
-
/** @hidden */
|
45
|
-
defaultSlot?: HTMLSlotElement;
|
46
38
|
listContext?: AutocompleteListContext;
|
47
39
|
get content(): string;
|
48
|
-
|
40
|
+
connectedCallback(): void;
|
41
|
+
protected willUpdate(): void;
|
49
42
|
protected updated(changedProperties: PropertyValues<this>): void;
|
50
|
-
/** @hidden */
|
51
|
-
render(): TemplateResult<1> | null;
|
52
43
|
}
|
53
44
|
export { AutocompleteItem }
|
54
45
|
export { AutocompleteItem as AutocompleteItem_alias_1 }
|
@@ -60,9 +51,7 @@ declare interface AutocompleteItemProps {
|
|
60
51
|
export { AutocompleteItemProps }
|
61
52
|
export { AutocompleteItemProps as AutocompleteItemProps_alias_1 }
|
62
53
|
|
63
|
-
declare class AutocompleteList extends
|
64
|
-
/** @hidden */
|
65
|
-
static styles: CSSResultGroup;
|
54
|
+
declare class AutocompleteList extends LightElement implements Partial<AutocompleteListProps> {
|
66
55
|
/** @hidden */
|
67
56
|
private listManager;
|
68
57
|
/** @hidden */
|
@@ -71,17 +60,12 @@ declare class AutocompleteList extends LitElement implements Partial<Autocomplet
|
|
71
60
|
editor?: Editor;
|
72
61
|
popoverContext: AutocompletePopoverContext | null;
|
73
62
|
context: AutocompleteListContext;
|
74
|
-
|
63
|
+
connectedCallback(): void;
|
75
64
|
private get items();
|
76
65
|
selectFirstItem(): void;
|
77
66
|
private updateValue;
|
78
|
-
private registerValue;
|
79
|
-
/** @hidden */
|
80
|
-
defaultSlot?: HTMLSlotElement;
|
81
67
|
/** @hidden */
|
82
68
|
willUpdate(changedProperties: PropertyValues<this>): void;
|
83
|
-
/** @hidden */
|
84
|
-
render(): TemplateResult<1>;
|
85
69
|
}
|
86
70
|
export { AutocompleteList }
|
87
71
|
export { AutocompleteList as AutocompleteList_alias_1 }
|
@@ -89,7 +73,6 @@ export { AutocompleteList as AutocompleteList_alias_1 }
|
|
89
73
|
export declare interface AutocompleteListContext {
|
90
74
|
scores: Map<string, number>;
|
91
75
|
selectedValue: string;
|
92
|
-
registerValue: (value: string) => VoidFunction;
|
93
76
|
}
|
94
77
|
|
95
78
|
export declare class AutocompleteListController implements ReactiveController {
|
@@ -109,9 +92,7 @@ declare interface AutocompleteListProps {
|
|
109
92
|
export { AutocompleteListProps }
|
110
93
|
export { AutocompleteListProps as AutocompleteListProps_alias_1 }
|
111
94
|
|
112
|
-
export declare class AutocompletePopover extends
|
113
|
-
/** @hidden */
|
114
|
-
static styles: CSSResultGroup;
|
95
|
+
export declare class AutocompletePopover extends Popover implements Partial<AutocompletePopoverProps> {
|
115
96
|
/** @hidden */
|
116
97
|
private controller;
|
117
98
|
editor?: Editor;
|
@@ -123,13 +104,9 @@ export declare class AutocompletePopover extends LitElement implements Partial<A
|
|
123
104
|
private get list();
|
124
105
|
private updateContext;
|
125
106
|
/** @hidden */
|
126
|
-
defaultSlot?: HTMLSlotElement;
|
127
|
-
/** @hidden */
|
128
|
-
protected get active(): boolean;
|
129
|
-
/** @hidden */
|
130
107
|
willUpdate(): void;
|
131
108
|
/** @hidden */
|
132
|
-
|
109
|
+
hide(): void;
|
133
110
|
}
|
134
111
|
|
135
112
|
export declare interface AutocompletePopoverContext {
|
@@ -165,10 +142,6 @@ export { AutoUpdateOptions }
|
|
165
142
|
|
166
143
|
export declare const blockComponentStyles: CSSResult;
|
167
144
|
|
168
|
-
declare class BlockElement extends LitElement {
|
169
|
-
setHidden(hidden: boolean): void;
|
170
|
-
}
|
171
|
-
|
172
145
|
export declare class CodeBlockPopover extends Popover implements Partial<CodeBlockPopoverProps> {
|
173
146
|
editor?: Editor;
|
174
147
|
/** @hidden */
|
@@ -210,7 +183,7 @@ export declare const comboBoxContext: {
|
|
210
183
|
__context__: ComboBoxContext;
|
211
184
|
};
|
212
185
|
|
213
|
-
export declare class ComboBoxInput extends
|
186
|
+
export declare class ComboBoxInput extends LightElement {
|
214
187
|
placeholder: string;
|
215
188
|
comboBoxContext: ComboBoxContext | null;
|
216
189
|
private visible;
|
@@ -225,12 +198,8 @@ export declare interface ComboBoxInputProps {
|
|
225
198
|
placeholder?: string;
|
226
199
|
}
|
227
200
|
|
228
|
-
declare class ComboBoxItem extends
|
229
|
-
/** @hidden */
|
230
|
-
static styles: CSSResultGroup;
|
201
|
+
declare class ComboBoxItem extends LightElement {
|
231
202
|
editor?: Editor;
|
232
|
-
/** @hidden */
|
233
|
-
defaultSlot?: HTMLSlotElement;
|
234
203
|
selected: boolean;
|
235
204
|
comboBoxContext?: ComboBoxContext;
|
236
205
|
/** @hidden */
|
@@ -246,7 +215,7 @@ declare type ComboBoxItemProps = {
|
|
246
215
|
export { ComboBoxItemProps }
|
247
216
|
export { ComboBoxItemProps as ComboBoxItemProps_alias_1 }
|
248
217
|
|
249
|
-
declare class ComboBoxList extends
|
218
|
+
declare class ComboBoxList extends LightElement {
|
250
219
|
comboBoxContext: ComboBoxContext | null;
|
251
220
|
connectedCallback(): void;
|
252
221
|
}
|
@@ -311,8 +280,9 @@ export declare function isComboBoxItem(element?: Element | null): element is Com
|
|
311
280
|
|
312
281
|
export declare function isComboBoxList(element?: Element | null): element is ComboBoxList;
|
313
282
|
|
314
|
-
export declare class
|
283
|
+
export declare class LightElement extends LitElement {
|
315
284
|
createRenderRoot(): this;
|
285
|
+
setHidden(hidden: boolean): void;
|
316
286
|
}
|
317
287
|
|
318
288
|
export declare class ListManager<Item extends {
|
@@ -357,11 +327,9 @@ export declare class ListManager<Item extends {
|
|
357
327
|
/**
|
358
328
|
* A custom element that displays a popover anchored to a reference element.
|
359
329
|
*/
|
360
|
-
export declare class Popover extends
|
330
|
+
export declare class Popover extends LightElement implements Partial<PopoverProps> {
|
361
331
|
/** @hidden */
|
362
332
|
constructor();
|
363
|
-
/** @hidden */
|
364
|
-
static styles: CSSResultGroup;
|
365
333
|
/**
|
366
334
|
* Controls the visibility of the popover element. When set to `true`, the popover is displayed and positioned
|
367
335
|
* relative to its reference element. When set to `false`, the popover is hidden and its positioning logic is
|
@@ -394,7 +362,11 @@ export declare class Popover extends LightBlockElement implements Partial<Popove
|
|
394
362
|
*/
|
395
363
|
autoUpdateOptions?: AutoUpdateOptions;
|
396
364
|
/** @hidden */
|
397
|
-
private
|
365
|
+
private disposeAutoUpdate?;
|
366
|
+
/** @hidden */
|
367
|
+
private disposeEventListeners?;
|
368
|
+
/** @hidden */
|
369
|
+
connectedCallback(): void;
|
398
370
|
/** @hidden */
|
399
371
|
disconnectedCallback(): void;
|
400
372
|
/** @hidden */
|
@@ -404,7 +376,9 @@ export declare class Popover extends LightBlockElement implements Partial<Popove
|
|
404
376
|
/** @hidden */
|
405
377
|
private compute;
|
406
378
|
/** @hidden */
|
407
|
-
|
379
|
+
hide(): void;
|
380
|
+
private handleDocumentMouseDown;
|
381
|
+
private handleDocumentKeyDown;
|
408
382
|
}
|
409
383
|
|
410
384
|
/**
|
@@ -464,10 +438,4 @@ export declare function queryClosestComboBoxItem(element?: Element | null): Comb
|
|
464
438
|
/** Rounds a value to the nearest device pixel ratio. */
|
465
439
|
export declare function roundByDPR(value: number): number;
|
466
440
|
|
467
|
-
export declare class ShadowBlockElement extends BlockElement {
|
468
|
-
/** @hidden */
|
469
|
-
static styles: CSSResultGroup;
|
470
|
-
setHidden(hidden: boolean): void;
|
471
|
-
}
|
472
|
-
|
473
441
|
export { }
|
@@ -5,9 +5,9 @@ import {
|
|
5
5
|
ListManager
|
6
6
|
} from "./chunk-PCXKL6TA.js";
|
7
7
|
import {
|
8
|
-
|
9
|
-
|
10
|
-
} from "./chunk-
|
8
|
+
LightElement,
|
9
|
+
__decorateClass
|
10
|
+
} from "./chunk-ZN7DMIEB.js";
|
11
11
|
|
12
12
|
// src/components/autocomplete-popover/context.ts
|
13
13
|
import { createContext } from "@lit/context";
|
@@ -18,8 +18,8 @@ var commandPopoverContext = createContext(
|
|
18
18
|
// src/components/autocomplete-list/component.ts
|
19
19
|
import { consume, provide } from "@lit/context";
|
20
20
|
import "@prosekit/core";
|
21
|
-
import
|
22
|
-
import { customElement, property,
|
21
|
+
import "lit";
|
22
|
+
import { customElement, property, state } from "lit/decorators.js";
|
23
23
|
|
24
24
|
// src/utils/command-score.ts
|
25
25
|
import commandScoreModule from "@superhuman/command-score";
|
@@ -84,7 +84,7 @@ var AutocompleteListController = class {
|
|
84
84
|
|
85
85
|
// src/components/autocomplete-list/component.ts
|
86
86
|
var propNames = ["editor"];
|
87
|
-
var AutocompleteList = class extends
|
87
|
+
var AutocompleteList = class extends LightElement {
|
88
88
|
constructor() {
|
89
89
|
super(...arguments);
|
90
90
|
/** @hidden */
|
@@ -115,15 +115,15 @@ var AutocompleteList = class extends LitElement {
|
|
115
115
|
this.popoverContext = null;
|
116
116
|
this.context = {
|
117
117
|
scores: /* @__PURE__ */ new Map(),
|
118
|
-
selectedValue: ""
|
119
|
-
registerValue: (value) => this.registerValue(value)
|
118
|
+
selectedValue: ""
|
120
119
|
};
|
121
120
|
}
|
122
121
|
get active() {
|
123
122
|
var _a, _b;
|
124
123
|
return (_b = (_a = this.popoverContext) == null ? void 0 : _a.active) != null ? _b : false;
|
125
124
|
}
|
126
|
-
|
125
|
+
connectedCallback() {
|
126
|
+
super.connectedCallback();
|
127
127
|
this.listManager.selectFirstItem();
|
128
128
|
this.addEventListener(
|
129
129
|
"mousemove",
|
@@ -143,25 +143,18 @@ var AutocompleteList = class extends LitElement {
|
|
143
143
|
);
|
144
144
|
}
|
145
145
|
get items() {
|
146
|
-
|
147
|
-
|
146
|
+
return Array.from(
|
147
|
+
this.querySelectorAll("prosekit-autocomplete-item")
|
148
|
+
).filter(isAutocompleteItem);
|
148
149
|
}
|
149
150
|
selectFirstItem() {
|
150
151
|
this.listManager.selectFirstItem();
|
151
152
|
}
|
152
153
|
updateValue(selectedValue) {
|
153
|
-
if (this.context.selectedValue === selectedValue)
|
154
|
+
if (this.context.selectedValue === selectedValue) {
|
154
155
|
return;
|
155
|
-
this.context = { ...this.context, selectedValue };
|
156
|
-
}
|
157
|
-
registerValue(value) {
|
158
|
-
if (!this.context.scores.has(value)) {
|
159
|
-
this.context.scores.set(value, 0);
|
160
|
-
this.requestUpdate();
|
161
156
|
}
|
162
|
-
|
163
|
-
this.context.scores.delete(value);
|
164
|
-
};
|
157
|
+
this.context = { ...this.context, selectedValue };
|
165
158
|
}
|
166
159
|
/** @hidden */
|
167
160
|
willUpdate(changedProperties) {
|
@@ -169,23 +162,17 @@ var AutocompleteList = class extends LitElement {
|
|
169
162
|
if (changedProperties.has("editor") && this.editor) {
|
170
163
|
this.controller.setEditor(this.editor);
|
171
164
|
}
|
172
|
-
const
|
165
|
+
const query = (_b = (_a = this.popoverContext) == null ? void 0 : _a.query) != null ? _b : "";
|
173
166
|
const scores = new Map(
|
174
167
|
this.items.map((item) => {
|
175
168
|
const content = item.content;
|
176
|
-
const score = commandScore(content,
|
169
|
+
const score = commandScore(content, query);
|
177
170
|
return [content, score];
|
178
171
|
})
|
179
172
|
);
|
180
173
|
this.context = { ...this.context, scores };
|
181
174
|
}
|
182
|
-
/** @hidden */
|
183
|
-
render() {
|
184
|
-
return html`<slot></slot>`;
|
185
|
-
}
|
186
175
|
};
|
187
|
-
/** @hidden */
|
188
|
-
AutocompleteList.styles = blockComponentStyles;
|
189
176
|
__decorateClass([
|
190
177
|
property({ attribute: false })
|
191
178
|
], AutocompleteList.prototype, "editor", 2);
|
@@ -197,9 +184,6 @@ __decorateClass([
|
|
197
184
|
provide({ context: commandListContext }),
|
198
185
|
state()
|
199
186
|
], AutocompleteList.prototype, "context", 2);
|
200
|
-
__decorateClass([
|
201
|
-
query("slot")
|
202
|
-
], AutocompleteList.prototype, "defaultSlot", 2);
|
203
187
|
AutocompleteList = __decorateClass([
|
204
188
|
customElement("prosekit-autocomplete-list")
|
205
189
|
], AutocompleteList);
|
@@ -1,17 +1,13 @@
|
|
1
1
|
import {
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
__decorateClass,
|
6
|
-
blockComponentStyles
|
7
|
-
} from "./chunk-3UDA5JEW.js";
|
2
|
+
LightElement,
|
3
|
+
__decorateClass
|
4
|
+
} from "./chunk-ZN7DMIEB.js";
|
8
5
|
|
9
6
|
// src/components/popover/index.ts
|
10
7
|
import {
|
11
8
|
autoUpdate,
|
12
9
|
computePosition
|
13
10
|
} from "@floating-ui/dom";
|
14
|
-
import "lit";
|
15
11
|
import { customElement, property } from "lit/decorators.js";
|
16
12
|
|
17
13
|
// src/utils/round-by-dpr.ts
|
@@ -40,16 +36,46 @@ var propNames = [
|
|
40
36
|
"autoUpdate",
|
41
37
|
"autoUpdateOptions"
|
42
38
|
];
|
43
|
-
var Popover = class extends
|
39
|
+
var Popover = class extends LightElement {
|
44
40
|
/** @hidden */
|
45
41
|
constructor() {
|
46
42
|
super();
|
47
43
|
this.active = false;
|
48
44
|
this.autoUpdate = false;
|
45
|
+
this.handleDocumentMouseDown = (event) => {
|
46
|
+
const path = event.composedPath();
|
47
|
+
if (!path.includes(this)) {
|
48
|
+
this.hide();
|
49
|
+
}
|
50
|
+
};
|
51
|
+
this.handleDocumentKeyDown = (event) => {
|
52
|
+
if (event.key === "Escape" && this.active) {
|
53
|
+
event.stopPropagation();
|
54
|
+
this.hide();
|
55
|
+
return;
|
56
|
+
}
|
57
|
+
};
|
58
|
+
}
|
59
|
+
/** @hidden */
|
60
|
+
connectedCallback() {
|
61
|
+
super.connectedCallback();
|
62
|
+
const handleMouseDown = this.handleDocumentMouseDown.bind(this);
|
63
|
+
const handleKeyDown = this.handleDocumentKeyDown.bind(this);
|
64
|
+
document.addEventListener("mousedown", handleMouseDown);
|
65
|
+
document.addEventListener("keydown", handleKeyDown);
|
66
|
+
this.disposeEventListeners = () => {
|
67
|
+
document.removeEventListener("mousedown", handleMouseDown);
|
68
|
+
document.removeEventListener("keydown", handleKeyDown);
|
69
|
+
};
|
49
70
|
}
|
50
71
|
/** @hidden */
|
51
72
|
disconnectedCallback() {
|
52
|
-
|
73
|
+
var _a, _b;
|
74
|
+
super.disconnectedCallback();
|
75
|
+
(_a = this.disposeAutoUpdate) == null ? void 0 : _a.call(this);
|
76
|
+
this.disposeAutoUpdate = void 0;
|
77
|
+
(_b = this.disposeEventListeners) == null ? void 0 : _b.call(this);
|
78
|
+
this.disposeEventListeners = void 0;
|
53
79
|
}
|
54
80
|
/** @hidden */
|
55
81
|
updated() {
|
@@ -58,14 +84,16 @@ var Popover = class extends LightBlockElement {
|
|
58
84
|
}
|
59
85
|
/** @hidden */
|
60
86
|
start() {
|
61
|
-
|
87
|
+
var _a;
|
88
|
+
(_a = this.disposeAutoUpdate) == null ? void 0 : _a.call(this);
|
89
|
+
this.disposeAutoUpdate = void 0;
|
62
90
|
const reference = this.reference;
|
63
91
|
if (!reference)
|
64
92
|
return;
|
65
93
|
if (!this.active)
|
66
94
|
return;
|
67
95
|
if (this.autoUpdate) {
|
68
|
-
this.
|
96
|
+
this.disposeAutoUpdate = autoUpdate(
|
69
97
|
reference,
|
70
98
|
this,
|
71
99
|
() => void this.compute(),
|
@@ -94,14 +122,10 @@ var Popover = class extends LightBlockElement {
|
|
94
122
|
this.style.transform = `translate(${roundByDPR(x)}px,${roundByDPR(y)}px)`;
|
95
123
|
}
|
96
124
|
/** @hidden */
|
97
|
-
|
98
|
-
|
99
|
-
(_a = this.cleanupAutoUpdate) == null ? void 0 : _a.call(this);
|
100
|
-
this.cleanupAutoUpdate = void 0;
|
125
|
+
hide() {
|
126
|
+
this.active = false;
|
101
127
|
}
|
102
128
|
};
|
103
|
-
/** @hidden */
|
104
|
-
Popover.styles = blockComponentStyles;
|
105
129
|
__decorateClass([
|
106
130
|
property({ type: Boolean, reflect: true })
|
107
131
|
], Popover.prototype, "active", 2);
|
@@ -2,16 +2,16 @@ import {
|
|
2
2
|
commandListContext
|
3
3
|
} from "./chunk-6P3YKUWI.js";
|
4
4
|
import {
|
5
|
-
|
6
|
-
|
7
|
-
} from "./chunk-
|
5
|
+
LightElement,
|
6
|
+
__decorateClass
|
7
|
+
} from "./chunk-ZN7DMIEB.js";
|
8
8
|
|
9
9
|
// src/components/autocomplete-item/component.ts
|
10
10
|
import { consume } from "@lit/context";
|
11
|
-
import
|
12
|
-
import { customElement, property,
|
11
|
+
import "lit";
|
12
|
+
import { customElement, property, state } from "lit/decorators.js";
|
13
13
|
var propNames = ["value", "onSelect"];
|
14
|
-
var AutocompleteItem = class extends
|
14
|
+
var AutocompleteItem = class extends LightElement {
|
15
15
|
constructor() {
|
16
16
|
super(...arguments);
|
17
17
|
this.value = "";
|
@@ -21,32 +21,23 @@ var AutocompleteItem = class extends LitElement {
|
|
21
21
|
const text = this.value || this.textContent || "";
|
22
22
|
return text.trim().toLowerCase();
|
23
23
|
}
|
24
|
-
|
24
|
+
connectedCallback() {
|
25
|
+
super.connectedCallback();
|
26
|
+
this.role = "option";
|
27
|
+
}
|
28
|
+
willUpdate() {
|
25
29
|
var _a, _b;
|
26
30
|
const content = this.content;
|
27
31
|
this.selected = content === ((_a = this.listContext) == null ? void 0 : _a.selectedValue);
|
28
32
|
const score = ((_b = this.listContext) == null ? void 0 : _b.scores.get(content)) || 0;
|
29
|
-
this.
|
30
|
-
this.hidden = score <= 0;
|
31
|
-
if (changedProperties.has("listContext") && this.listContext) {
|
32
|
-
this.listContext.registerValue(this.content);
|
33
|
-
}
|
33
|
+
this.setHidden(score <= 0);
|
34
34
|
}
|
35
35
|
updated(changedProperties) {
|
36
36
|
if (this.selected && changedProperties.has("selected") && !changedProperties.get("selected")) {
|
37
37
|
this.scrollIntoView({ block: "nearest" });
|
38
38
|
}
|
39
39
|
}
|
40
|
-
/** @hidden */
|
41
|
-
render() {
|
42
|
-
if (this.hidden) {
|
43
|
-
return null;
|
44
|
-
}
|
45
|
-
return html`<div role="option" aria-selected="${this.selected}"><slot></slot></div>`;
|
46
|
-
}
|
47
40
|
};
|
48
|
-
/** @hidden */
|
49
|
-
AutocompleteItem.styles = blockComponentStyles;
|
50
41
|
__decorateClass([
|
51
42
|
property({ type: String, reflect: true, attribute: "data-value" })
|
52
43
|
], AutocompleteItem.prototype, "value", 2);
|
@@ -56,9 +47,6 @@ __decorateClass([
|
|
56
47
|
__decorateClass([
|
57
48
|
property({ attribute: false })
|
58
49
|
], AutocompleteItem.prototype, "onSelect", 2);
|
59
|
-
__decorateClass([
|
60
|
-
query("slot")
|
61
|
-
], AutocompleteItem.prototype, "defaultSlot", 2);
|
62
50
|
__decorateClass([
|
63
51
|
consume({ context: commandListContext, subscribe: true }),
|
64
52
|
state({})
|
@@ -2,19 +2,15 @@ import {
|
|
2
2
|
comboBoxContext
|
3
3
|
} from "./chunk-C4MW43I4.js";
|
4
4
|
import {
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
__decorateClass,
|
9
|
-
blockComponentStyles
|
10
|
-
} from "./chunk-3UDA5JEW.js";
|
5
|
+
LightElement,
|
6
|
+
__decorateClass
|
7
|
+
} from "./chunk-ZN7DMIEB.js";
|
11
8
|
|
12
9
|
// src/components/combo-box-item/component.ts
|
13
10
|
import { consume } from "@lit/context";
|
14
|
-
import "lit";
|
15
|
-
import { customElement, property, query, state } from "lit/decorators.js";
|
11
|
+
import { customElement, property, state } from "lit/decorators.js";
|
16
12
|
var propNames = [];
|
17
|
-
var ComboBoxItem = class extends
|
13
|
+
var ComboBoxItem = class extends LightElement {
|
18
14
|
constructor() {
|
19
15
|
super(...arguments);
|
20
16
|
this.selected = false;
|
@@ -22,21 +18,16 @@ var ComboBoxItem = class extends LightBlockElement {
|
|
22
18
|
updated() {
|
23
19
|
var _a, _b, _c, _d;
|
24
20
|
const content = ((_a = this.textContent) != null ? _a : "").trim();
|
25
|
-
const
|
26
|
-
const match = content.toLowerCase().includes(
|
21
|
+
const query = ((_c = (_b = this.comboBoxContext) == null ? void 0 : _b.inputValue) != null ? _c : "").trim();
|
22
|
+
const match = content.toLowerCase().includes(query.toLowerCase());
|
27
23
|
this.selected = match && content === ((_d = this.comboBoxContext) == null ? void 0 : _d.selectedValue);
|
28
24
|
this.ariaSelected = String(this.selected);
|
29
25
|
this.setHidden(!match);
|
30
26
|
}
|
31
27
|
};
|
32
|
-
/** @hidden */
|
33
|
-
ComboBoxItem.styles = blockComponentStyles;
|
34
28
|
__decorateClass([
|
35
29
|
property({ attribute: false })
|
36
30
|
], ComboBoxItem.prototype, "editor", 2);
|
37
|
-
__decorateClass([
|
38
|
-
query("slot")
|
39
|
-
], ComboBoxItem.prototype, "defaultSlot", 2);
|
40
31
|
__decorateClass([
|
41
32
|
property({ type: Boolean, reflect: true, attribute: "data-selected" })
|
42
33
|
], ComboBoxItem.prototype, "selected", 2);
|
@@ -10,17 +10,22 @@ var __decorateClass = (decorators, target, key, kind) => {
|
|
10
10
|
return result;
|
11
11
|
};
|
12
12
|
|
13
|
-
// src/
|
14
|
-
import {
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
13
|
+
// src/components/block-element/index.ts
|
14
|
+
import { LitElement } from "lit";
|
15
|
+
var LightElement = class extends LitElement {
|
16
|
+
createRenderRoot() {
|
17
|
+
return this;
|
18
|
+
}
|
19
|
+
setHidden(hidden) {
|
20
|
+
if (this.hidden !== hidden) {
|
21
|
+
this.hidden = hidden;
|
22
|
+
const display = this.style.display;
|
23
|
+
this.style.display = hidden ? "none" : display === "none" ? "" : display;
|
24
|
+
}
|
25
|
+
}
|
26
|
+
};
|
22
27
|
|
23
28
|
export {
|
24
29
|
__decorateClass,
|
25
|
-
|
30
|
+
LightElement
|
26
31
|
};
|
@@ -2,16 +2,20 @@ import {
|
|
2
2
|
commandListContext
|
3
3
|
} from "./chunk-6P3YKUWI.js";
|
4
4
|
import {
|
5
|
-
|
6
|
-
|
7
|
-
} from "./chunk-
|
5
|
+
LightElement,
|
6
|
+
__decorateClass
|
7
|
+
} from "./chunk-ZN7DMIEB.js";
|
8
8
|
|
9
9
|
// src/components/autocomplete-empty/index.ts
|
10
10
|
import { consume } from "@lit/context";
|
11
|
-
import
|
11
|
+
import "lit";
|
12
12
|
import { customElement, state } from "lit/decorators.js";
|
13
13
|
var propNames = [];
|
14
|
-
var AutocompleteEmpty = class extends
|
14
|
+
var AutocompleteEmpty = class extends LightElement {
|
15
|
+
connectedCallback() {
|
16
|
+
super.connectedCallback();
|
17
|
+
this.role = "option";
|
18
|
+
}
|
15
19
|
willUpdate(_changedProperties) {
|
16
20
|
var _a;
|
17
21
|
const scores = (_a = this.listContext) == null ? void 0 : _a.scores;
|
@@ -24,19 +28,9 @@ var AutocompleteEmpty = class extends LitElement {
|
|
24
28
|
}
|
25
29
|
}
|
26
30
|
}
|
27
|
-
this.
|
28
|
-
this.inert = hasMatch;
|
29
|
-
}
|
30
|
-
/** @hidden */
|
31
|
-
render() {
|
32
|
-
if (this.hidden) {
|
33
|
-
return null;
|
34
|
-
}
|
35
|
-
return html`<div role="option"><slot></slot></div>`;
|
31
|
+
this.setHidden(hasMatch);
|
36
32
|
}
|
37
33
|
};
|
38
|
-
/** @hidden */
|
39
|
-
AutocompleteEmpty.styles = blockComponentStyles;
|
40
34
|
__decorateClass([
|
41
35
|
consume({ context: commandListContext, subscribe: true }),
|
42
36
|
state()
|
@@ -1,11 +1,11 @@
|
|
1
1
|
import {
|
2
2
|
AutocompleteList,
|
3
3
|
propNames
|
4
|
-
} from "./chunk-
|
5
|
-
import "./chunk-
|
4
|
+
} from "./chunk-KJJEZNYD.js";
|
5
|
+
import "./chunk-XOVIMVFL.js";
|
6
6
|
import "./chunk-6P3YKUWI.js";
|
7
7
|
import "./chunk-PCXKL6TA.js";
|
8
|
-
import "./chunk-
|
8
|
+
import "./chunk-ZN7DMIEB.js";
|
9
9
|
export {
|
10
10
|
AutocompleteList,
|
11
11
|
propNames
|
@@ -1,21 +1,20 @@
|
|
1
1
|
import {
|
2
2
|
commandPopoverContext
|
3
|
-
} from "./chunk-
|
4
|
-
import "./chunk-
|
3
|
+
} from "./chunk-KJJEZNYD.js";
|
4
|
+
import "./chunk-XOVIMVFL.js";
|
5
5
|
import "./chunk-6P3YKUWI.js";
|
6
6
|
import "./chunk-PCXKL6TA.js";
|
7
|
-
import "./chunk-KA7LSXZQ.js";
|
8
|
-
import "./chunk-TRZW33VF.js";
|
9
7
|
import {
|
10
|
-
|
11
|
-
|
12
|
-
|
8
|
+
Popover
|
9
|
+
} from "./chunk-P336E72L.js";
|
10
|
+
import {
|
11
|
+
__decorateClass
|
12
|
+
} from "./chunk-ZN7DMIEB.js";
|
13
13
|
|
14
14
|
// src/components/autocomplete-popover/index.ts
|
15
15
|
import { provide } from "@lit/context";
|
16
16
|
import "@prosekit/core";
|
17
|
-
import {
|
18
|
-
import { customElement, property, query, state } from "lit/decorators.js";
|
17
|
+
import { customElement, property, state } from "lit/decorators.js";
|
19
18
|
|
20
19
|
// src/components/autocomplete-list/helpers.ts
|
21
20
|
function isAutocompleteList(element) {
|
@@ -79,8 +78,8 @@ var AutocompletePopoverController = class {
|
|
79
78
|
if (span) {
|
80
79
|
this.reference = span;
|
81
80
|
}
|
82
|
-
const
|
83
|
-
this.onChange(
|
81
|
+
const query = defaultQueryBuilder(options.match);
|
82
|
+
this.onChange(query != null ? query : "", !!this.reference);
|
84
83
|
this.handleDismiss = options.ignoreMatch;
|
85
84
|
this.handleSubmit = options.deleteMatch;
|
86
85
|
setTimeout(() => {
|
@@ -159,7 +158,7 @@ var defaultPopoverOptions = {
|
|
159
158
|
|
160
159
|
// src/components/autocomplete-popover/index.ts
|
161
160
|
var propNames = ["editor", "regex", "popoverOptions"];
|
162
|
-
var AutocompletePopover = class extends
|
161
|
+
var AutocompletePopover = class extends Popover {
|
163
162
|
constructor() {
|
164
163
|
super(...arguments);
|
165
164
|
/** @hidden */
|
@@ -182,41 +181,42 @@ var AutocompletePopover = class extends LitElement {
|
|
182
181
|
};
|
183
182
|
}
|
184
183
|
get list() {
|
185
|
-
|
186
|
-
return (
|
184
|
+
const element = this.querySelector("prosekit-autocomplete-list");
|
185
|
+
return isAutocompleteList(element) ? element : null;
|
187
186
|
}
|
188
|
-
updateContext(
|
189
|
-
if (this.context.query ===
|
187
|
+
updateContext(query, active) {
|
188
|
+
if (this.context.query === query && this.context.active === active) {
|
190
189
|
return;
|
191
190
|
}
|
192
|
-
this.context = { ...this.context, query
|
191
|
+
this.context = { ...this.context, query, active };
|
193
192
|
requestAnimationFrame(() => {
|
194
193
|
var _a;
|
195
194
|
(_a = this.list) == null ? void 0 : _a.selectFirstItem();
|
196
195
|
});
|
197
196
|
}
|
198
197
|
/** @hidden */
|
199
|
-
get active() {
|
200
|
-
var _a;
|
201
|
-
return !!((_a = this.controller) == null ? void 0 : _a.reference);
|
202
|
-
}
|
203
|
-
/** @hidden */
|
204
198
|
willUpdate() {
|
199
|
+
var _a, _b;
|
205
200
|
if (this.editor) {
|
206
201
|
this.controller.setEditor(this.editor);
|
207
202
|
}
|
208
203
|
if (this.regex) {
|
209
204
|
this.controller.setRegex(this.regex);
|
210
205
|
}
|
206
|
+
this.active = !!((_a = this.controller) == null ? void 0 : _a.reference);
|
207
|
+
this.reference = (_b = this.controller.reference) != null ? _b : void 0;
|
208
|
+
this.options = this.popoverOptions;
|
211
209
|
}
|
212
210
|
/** @hidden */
|
213
|
-
|
211
|
+
hide() {
|
214
212
|
var _a;
|
215
|
-
|
213
|
+
super.hide();
|
214
|
+
if ((_a = this.controller) == null ? void 0 : _a.reference) {
|
215
|
+
this.controller.reference = null;
|
216
|
+
this.reference = void 0;
|
217
|
+
}
|
216
218
|
}
|
217
219
|
};
|
218
|
-
/** @hidden */
|
219
|
-
AutocompletePopover.styles = blockComponentStyles;
|
220
220
|
__decorateClass([
|
221
221
|
property({ attribute: false })
|
222
222
|
], AutocompletePopover.prototype, "editor", 2);
|
@@ -233,9 +233,6 @@ __decorateClass([
|
|
233
233
|
__decorateClass([
|
234
234
|
property({ attribute: false })
|
235
235
|
], AutocompletePopover.prototype, "onSelect", 2);
|
236
|
-
__decorateClass([
|
237
|
-
query("slot")
|
238
|
-
], AutocompletePopover.prototype, "defaultSlot", 2);
|
239
236
|
AutocompletePopover = __decorateClass([
|
240
237
|
customElement("prosekit-autocomplete-popover")
|
241
238
|
], AutocompletePopover);
|
@@ -1,10 +1,9 @@
|
|
1
1
|
import {
|
2
2
|
Popover
|
3
|
-
} from "./chunk-
|
4
|
-
import "./chunk-TRZW33VF.js";
|
3
|
+
} from "./chunk-P336E72L.js";
|
5
4
|
import {
|
6
5
|
__decorateClass
|
7
|
-
} from "./chunk-
|
6
|
+
} from "./chunk-ZN7DMIEB.js";
|
8
7
|
|
9
8
|
// src/components/code-block-popover/index.ts
|
10
9
|
import { offset } from "@floating-ui/dom";
|
@@ -2,18 +2,16 @@ import {
|
|
2
2
|
comboBoxContext
|
3
3
|
} from "./chunk-C4MW43I4.js";
|
4
4
|
import {
|
5
|
-
|
6
|
-
} from "./chunk-TRZW33VF.js";
|
7
|
-
import {
|
5
|
+
LightElement,
|
8
6
|
__decorateClass
|
9
|
-
} from "./chunk-
|
7
|
+
} from "./chunk-ZN7DMIEB.js";
|
10
8
|
|
11
9
|
// src/components/combo-box-input/index.ts
|
12
10
|
import { consume } from "@lit/context";
|
13
11
|
import { html } from "lit";
|
14
12
|
import { customElement, property, state } from "lit/decorators.js";
|
15
13
|
var propNames = ["placeholder"];
|
16
|
-
var ComboBoxInput = class extends
|
14
|
+
var ComboBoxInput = class extends LightElement {
|
17
15
|
constructor() {
|
18
16
|
super(...arguments);
|
19
17
|
this.placeholder = "";
|
@@ -1,10 +1,9 @@
|
|
1
1
|
import {
|
2
2
|
ComboBoxItem,
|
3
3
|
propNames
|
4
|
-
} from "./chunk-
|
4
|
+
} from "./chunk-XTIVRSSC.js";
|
5
5
|
import "./chunk-C4MW43I4.js";
|
6
|
-
import "./chunk-
|
7
|
-
import "./chunk-3UDA5JEW.js";
|
6
|
+
import "./chunk-ZN7DMIEB.js";
|
8
7
|
export {
|
9
8
|
ComboBoxItem,
|
10
9
|
propNames
|
@@ -2,17 +2,15 @@ import {
|
|
2
2
|
comboBoxContext
|
3
3
|
} from "./chunk-C4MW43I4.js";
|
4
4
|
import {
|
5
|
-
|
6
|
-
} from "./chunk-TRZW33VF.js";
|
7
|
-
import {
|
5
|
+
LightElement,
|
8
6
|
__decorateClass
|
9
|
-
} from "./chunk-
|
7
|
+
} from "./chunk-ZN7DMIEB.js";
|
10
8
|
|
11
9
|
// src/components/combo-box-list/component.ts
|
12
10
|
import { consume } from "@lit/context";
|
13
11
|
import { customElement, state } from "lit/decorators.js";
|
14
12
|
var propNames = [];
|
15
|
-
var ComboBoxList = class extends
|
13
|
+
var ComboBoxList = class extends LightElement {
|
16
14
|
constructor() {
|
17
15
|
super(...arguments);
|
18
16
|
this.comboBoxContext = null;
|
@@ -1,17 +1,16 @@
|
|
1
|
-
import "./chunk-
|
1
|
+
import "./chunk-XTIVRSSC.js";
|
2
2
|
import {
|
3
3
|
ListManager
|
4
4
|
} from "./chunk-PCXKL6TA.js";
|
5
5
|
import {
|
6
6
|
Popover
|
7
|
-
} from "./chunk-
|
7
|
+
} from "./chunk-P336E72L.js";
|
8
8
|
import {
|
9
9
|
comboBoxContext
|
10
10
|
} from "./chunk-C4MW43I4.js";
|
11
|
-
import "./chunk-TRZW33VF.js";
|
12
11
|
import {
|
13
12
|
__decorateClass
|
14
|
-
} from "./chunk-
|
13
|
+
} from "./chunk-ZN7DMIEB.js";
|
15
14
|
|
16
15
|
// src/components/combo-box/index.ts
|
17
16
|
import { provide } from "@lit/context";
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@prosekit/lit",
|
3
3
|
"type": "module",
|
4
|
-
"version": "0.0.
|
4
|
+
"version": "0.0.22",
|
5
5
|
"private": false,
|
6
6
|
"author": {
|
7
7
|
"name": "ocavue",
|
@@ -86,12 +86,12 @@
|
|
86
86
|
],
|
87
87
|
"dependencies": {
|
88
88
|
"@floating-ui/dom": "^1.5.3",
|
89
|
-
"@lit/context": "^1.0.
|
90
|
-
"@prosekit/core": "^0.0.
|
91
|
-
"@prosekit/extensions": "^0.0.
|
92
|
-
"@prosekit/pm": "^0.0.
|
89
|
+
"@lit/context": "^1.0.1",
|
90
|
+
"@prosekit/core": "^0.0.18",
|
91
|
+
"@prosekit/extensions": "^0.0.20",
|
92
|
+
"@prosekit/pm": "^0.0.7",
|
93
93
|
"@superhuman/command-score": "^0.5.0",
|
94
|
-
"lit": "^3.0.
|
94
|
+
"lit": "^3.0.2"
|
95
95
|
},
|
96
96
|
"devDependencies": {
|
97
97
|
"@prosekit/dev": "*",
|
package/dist/chunk-TRZW33VF.js
DELETED
@@ -1,35 +0,0 @@
|
|
1
|
-
import {
|
2
|
-
blockComponentStyles
|
3
|
-
} from "./chunk-3UDA5JEW.js";
|
4
|
-
|
5
|
-
// src/components/block-element/index.ts
|
6
|
-
import { LitElement } from "lit";
|
7
|
-
var BlockElement = class extends LitElement {
|
8
|
-
setHidden(hidden) {
|
9
|
-
if (this.hidden !== hidden) {
|
10
|
-
this.hidden = hidden;
|
11
|
-
const display = this.style.display;
|
12
|
-
this.style.display = hidden ? "none" : display === "none" ? "" : display;
|
13
|
-
}
|
14
|
-
}
|
15
|
-
};
|
16
|
-
var LightBlockElement = class extends BlockElement {
|
17
|
-
createRenderRoot() {
|
18
|
-
return this;
|
19
|
-
}
|
20
|
-
};
|
21
|
-
var ShadowBlockElement = class extends BlockElement {
|
22
|
-
setHidden(hidden) {
|
23
|
-
if (this.hidden !== hidden) {
|
24
|
-
this.hidden = hidden;
|
25
|
-
const display = this.style.display;
|
26
|
-
this.style.display = hidden ? "none" : display === "none" ? "" : display;
|
27
|
-
}
|
28
|
-
}
|
29
|
-
};
|
30
|
-
/** @hidden */
|
31
|
-
ShadowBlockElement.styles = blockComponentStyles;
|
32
|
-
|
33
|
-
export {
|
34
|
-
LightBlockElement
|
35
|
-
};
|
package/src/index.ts
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
export {}
|