@prosekit/lit 0.0.3 → 0.0.5
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/chunk-65QAWC7L.js +236 -0
- package/dist/{chunk-6FOWUXQ2.js → chunk-J73E7P6J.js} +9 -2
- package/dist/chunk-UDTISUHF.js +69 -0
- package/dist/context-19474449.d.ts +7 -0
- package/dist/context-436a56d3.d.ts +8 -0
- package/dist/prosekit-lit-components-autocomplete-empty.d.ts +16 -0
- package/dist/prosekit-lit-components-autocomplete-empty.js +46 -0
- package/dist/prosekit-lit-components-autocomplete-item.d.ts +31 -0
- package/dist/prosekit-lit-components-autocomplete-item.js +7 -0
- package/dist/prosekit-lit-components-autocomplete-list.d.ts +42 -0
- package/dist/prosekit-lit-components-autocomplete-list.js +8 -0
- package/dist/prosekit-lit-components-autocomplete-popover.d.ts +46 -0
- package/dist/prosekit-lit-components-autocomplete-popover.js +359 -0
- package/package.json +30 -28
- package/src/index.ts +0 -4
- package/dist/chunk-WHIPWT4H.js +0 -122
- package/dist/options-7235df55.d.ts +0 -14
- package/dist/prosekit-lit-elements-menu-item.d.ts +0 -16
- package/dist/prosekit-lit-elements-menu-item.js +0 -37
- package/dist/prosekit-lit-elements-menu.d.ts +0 -50
- package/dist/prosekit-lit-elements-menu.js +0 -169
- package/dist/prosekit-lit-elements-popover-suggestion.d.ts +0 -59
- package/dist/prosekit-lit-elements-popover-suggestion.js +0 -218
- package/dist/prosekit-lit-elements-popover.d.ts +0 -65
- package/dist/prosekit-lit-elements-popover.js +0 -7
@@ -0,0 +1,359 @@
|
|
1
|
+
import {
|
2
|
+
commandPopoverContext
|
3
|
+
} from "./chunk-65QAWC7L.js";
|
4
|
+
import "./chunk-UDTISUHF.js";
|
5
|
+
import {
|
6
|
+
__decorateClass,
|
7
|
+
blockComponentStyles
|
8
|
+
} from "./chunk-J73E7P6J.js";
|
9
|
+
|
10
|
+
// src/components/popover/index.ts
|
11
|
+
import {
|
12
|
+
autoUpdate,
|
13
|
+
computePosition
|
14
|
+
} from "@floating-ui/dom";
|
15
|
+
import {
|
16
|
+
LitElement,
|
17
|
+
html
|
18
|
+
} from "lit";
|
19
|
+
import { customElement, property, query, state } from "lit/decorators.js";
|
20
|
+
import { styleMap } from "lit/directives/style-map.js";
|
21
|
+
|
22
|
+
// src/utils/round-by-dpr.ts
|
23
|
+
function roundByDPR(value) {
|
24
|
+
const dpr = window.devicePixelRatio || 1;
|
25
|
+
return Math.round(value * dpr) / dpr;
|
26
|
+
}
|
27
|
+
|
28
|
+
// src/components/popover/options.ts
|
29
|
+
import "@floating-ui/dom";
|
30
|
+
|
31
|
+
// src/components/popover/index.ts
|
32
|
+
var Popover = class extends LitElement {
|
33
|
+
/** @hidden */
|
34
|
+
constructor() {
|
35
|
+
super();
|
36
|
+
this.active = false;
|
37
|
+
this.autoUpdate = false;
|
38
|
+
}
|
39
|
+
/** @hidden */
|
40
|
+
disconnectedCallback() {
|
41
|
+
this.cleanup();
|
42
|
+
}
|
43
|
+
/** @hidden */
|
44
|
+
updated(changed) {
|
45
|
+
if (!changed.has("computed")) {
|
46
|
+
this.start();
|
47
|
+
}
|
48
|
+
}
|
49
|
+
/** @hidden */
|
50
|
+
start() {
|
51
|
+
this.cleanup();
|
52
|
+
const reference = this.reference;
|
53
|
+
const floating = this.floating;
|
54
|
+
if (!reference)
|
55
|
+
return;
|
56
|
+
if (this.autoUpdate) {
|
57
|
+
this.cleanupAutoUpdate = autoUpdate(
|
58
|
+
reference,
|
59
|
+
floating,
|
60
|
+
() => void this.compute(),
|
61
|
+
this.autoUpdateOptions
|
62
|
+
);
|
63
|
+
} else {
|
64
|
+
void this.compute();
|
65
|
+
}
|
66
|
+
}
|
67
|
+
/** @hidden */
|
68
|
+
async compute() {
|
69
|
+
const reference = this.reference;
|
70
|
+
const floating = this.floating;
|
71
|
+
if (!reference)
|
72
|
+
return;
|
73
|
+
const options = this.options;
|
74
|
+
this.computed = await computePosition(reference, floating, options);
|
75
|
+
}
|
76
|
+
/** @hidden */
|
77
|
+
cleanup() {
|
78
|
+
var _a;
|
79
|
+
(_a = this.cleanupAutoUpdate) == null ? void 0 : _a.call(this);
|
80
|
+
this.cleanupAutoUpdate = void 0;
|
81
|
+
}
|
82
|
+
/** @hidden */
|
83
|
+
render() {
|
84
|
+
var _a;
|
85
|
+
const { x, y, strategy } = (_a = this.computed) != null ? _a : {
|
86
|
+
x: 0,
|
87
|
+
y: 0,
|
88
|
+
strategy: "absolute"
|
89
|
+
};
|
90
|
+
const style = {
|
91
|
+
top: "0",
|
92
|
+
left: "0",
|
93
|
+
position: strategy,
|
94
|
+
transform: `translate(${roundByDPR(x)}px,${roundByDPR(y)}px)`,
|
95
|
+
display: this.active ? void 0 : "none"
|
96
|
+
};
|
97
|
+
return html`<div class="floating" style="${styleMap(style)}"><slot></slot></div>`;
|
98
|
+
}
|
99
|
+
};
|
100
|
+
/** @hidden */
|
101
|
+
Popover.styles = blockComponentStyles;
|
102
|
+
__decorateClass([
|
103
|
+
property({ type: Boolean, reflect: true })
|
104
|
+
], Popover.prototype, "active", 2);
|
105
|
+
__decorateClass([
|
106
|
+
query(".floating")
|
107
|
+
], Popover.prototype, "floating", 2);
|
108
|
+
__decorateClass([
|
109
|
+
property({ attribute: false })
|
110
|
+
], Popover.prototype, "reference", 2);
|
111
|
+
__decorateClass([
|
112
|
+
property({ attribute: false })
|
113
|
+
], Popover.prototype, "options", 2);
|
114
|
+
__decorateClass([
|
115
|
+
property({
|
116
|
+
type: Boolean,
|
117
|
+
reflect: true
|
118
|
+
})
|
119
|
+
], Popover.prototype, "autoUpdate", 2);
|
120
|
+
__decorateClass([
|
121
|
+
property({ type: Object })
|
122
|
+
], Popover.prototype, "autoUpdateOptions", 2);
|
123
|
+
__decorateClass([
|
124
|
+
state()
|
125
|
+
], Popover.prototype, "computed", 2);
|
126
|
+
Popover = __decorateClass([
|
127
|
+
customElement("prosekit-popover")
|
128
|
+
], Popover);
|
129
|
+
|
130
|
+
// src/components/autocomplete-popover/index.ts
|
131
|
+
import { provide } from "@lit-labs/context";
|
132
|
+
import "@prosekit/core";
|
133
|
+
import { html as html2, LitElement as LitElement2 } from "lit";
|
134
|
+
import { customElement as customElement2, property as property2, query as query2, state as state2 } from "lit/decorators.js";
|
135
|
+
|
136
|
+
// src/components/autocomplete-list/helpers.ts
|
137
|
+
function isAutocompleteList(element) {
|
138
|
+
var _a;
|
139
|
+
return ((_a = element == null ? void 0 : element.tagName) == null ? void 0 : _a.toLowerCase()) === "prosekit-autocomplete-list";
|
140
|
+
}
|
141
|
+
|
142
|
+
// src/components/autocomplete-popover/controller.ts
|
143
|
+
import "@prosekit/core";
|
144
|
+
import {
|
145
|
+
AutocompleteRule,
|
146
|
+
addAutocomplete
|
147
|
+
} from "@prosekit/extensions/autocomplete";
|
148
|
+
import "lit";
|
149
|
+
|
150
|
+
// src/components/autocomplete-popover/helpers.ts
|
151
|
+
function defaultQueryBuilder(match) {
|
152
|
+
return match[0].toLowerCase().replace(/[!"#$%&'()*+,-./:;<=>?@[\\\]^_`{|}~]/g, "").replace(/\s\s+/g, " ").trim();
|
153
|
+
}
|
154
|
+
|
155
|
+
// src/components/autocomplete-popover/controller.ts
|
156
|
+
var AutocompletePopoverController = class {
|
157
|
+
constructor(host, onChange) {
|
158
|
+
this.host = host;
|
159
|
+
this.onChange = onChange;
|
160
|
+
this.reference = null;
|
161
|
+
this.editor = null;
|
162
|
+
this.regex = null;
|
163
|
+
this.cleanup = null;
|
164
|
+
this.handleDismiss = null;
|
165
|
+
this.handleSubmit = null;
|
166
|
+
this.host.addController(this);
|
167
|
+
}
|
168
|
+
setEditor(editor) {
|
169
|
+
if (this.editor !== editor) {
|
170
|
+
this.editor = editor;
|
171
|
+
this.addExtension();
|
172
|
+
this.host.requestUpdate();
|
173
|
+
}
|
174
|
+
}
|
175
|
+
setRegex(regex) {
|
176
|
+
if (this.regex !== regex) {
|
177
|
+
this.regex = regex;
|
178
|
+
this.addExtension();
|
179
|
+
this.host.requestUpdate();
|
180
|
+
}
|
181
|
+
}
|
182
|
+
addExtension() {
|
183
|
+
var _a;
|
184
|
+
const regex = this.regex;
|
185
|
+
const editor = this.editor;
|
186
|
+
if (!regex || !editor) {
|
187
|
+
return;
|
188
|
+
}
|
189
|
+
(_a = this.cleanup) == null ? void 0 : _a.call(this);
|
190
|
+
this.cleanup = null;
|
191
|
+
const handleEnter = (options) => {
|
192
|
+
const span = editor.view.dom.querySelector(
|
193
|
+
".prosemirror-prediction-match"
|
194
|
+
);
|
195
|
+
if (span) {
|
196
|
+
this.reference = span;
|
197
|
+
}
|
198
|
+
const query3 = defaultQueryBuilder(options.match);
|
199
|
+
this.onChange(query3 != null ? query3 : "", !!this.reference);
|
200
|
+
this.handleDismiss = options.ignoreMatch;
|
201
|
+
this.handleSubmit = options.deleteMatch;
|
202
|
+
setTimeout(() => {
|
203
|
+
this.host.requestUpdate();
|
204
|
+
}, 0);
|
205
|
+
};
|
206
|
+
const handleLeave = () => {
|
207
|
+
this.reference = null;
|
208
|
+
this.host.requestUpdate();
|
209
|
+
this.onChange("", false);
|
210
|
+
this.handleDismiss = null;
|
211
|
+
this.handleSubmit = null;
|
212
|
+
};
|
213
|
+
const rule = new AutocompleteRule({
|
214
|
+
regex,
|
215
|
+
onEnter: handleEnter,
|
216
|
+
onLeave: handleLeave
|
217
|
+
});
|
218
|
+
const extension = addAutocomplete(rule);
|
219
|
+
this.cleanup = editor.use(extension);
|
220
|
+
}
|
221
|
+
hostDisconnected() {
|
222
|
+
var _a;
|
223
|
+
(_a = this.cleanup) == null ? void 0 : _a.call(this);
|
224
|
+
this.cleanup = null;
|
225
|
+
}
|
226
|
+
};
|
227
|
+
|
228
|
+
// src/components/autocomplete-popover/default-popover-options.ts
|
229
|
+
import {
|
230
|
+
flip,
|
231
|
+
inline,
|
232
|
+
offset,
|
233
|
+
shift,
|
234
|
+
size
|
235
|
+
} from "@floating-ui/dom";
|
236
|
+
var defaultDetectOverflowOptions = {
|
237
|
+
// Make sure the popover is always at least 8px away from the boundary
|
238
|
+
padding: 8
|
239
|
+
};
|
240
|
+
var defaultPopoverOptions = {
|
241
|
+
placement: "bottom-end",
|
242
|
+
middleware: [
|
243
|
+
offset(({ rects }) => ({
|
244
|
+
// Put the popover at the bottom right corner
|
245
|
+
alignmentAxis: -rects.floating.width,
|
246
|
+
// Move down the popover by 4px
|
247
|
+
mainAxis: 4
|
248
|
+
})),
|
249
|
+
size({
|
250
|
+
apply: ({ availableHeight, elements }) => {
|
251
|
+
const style = {
|
252
|
+
// Minimum acceptable height is 100px.
|
253
|
+
// `flip` will then take over.
|
254
|
+
maxHeight: `${Math.max(100, availableHeight)}px`,
|
255
|
+
overflowY: "auto"
|
256
|
+
};
|
257
|
+
Object.assign(elements.floating.style, style);
|
258
|
+
},
|
259
|
+
...defaultDetectOverflowOptions
|
260
|
+
}),
|
261
|
+
// Flip the popover to the top if it's overflowing the viewport
|
262
|
+
flip({
|
263
|
+
fallbackStrategy: "initialPlacement",
|
264
|
+
fallbackAxisSideDirection: "start",
|
265
|
+
crossAxis: false,
|
266
|
+
...defaultDetectOverflowOptions
|
267
|
+
}),
|
268
|
+
shift({
|
269
|
+
...defaultDetectOverflowOptions
|
270
|
+
}),
|
271
|
+
// Use the text caret as the reference point
|
272
|
+
inline()
|
273
|
+
]
|
274
|
+
};
|
275
|
+
|
276
|
+
// src/components/autocomplete-popover/index.ts
|
277
|
+
var AutocompletePopover = class extends LitElement2 {
|
278
|
+
constructor() {
|
279
|
+
super(...arguments);
|
280
|
+
/** @hidden */
|
281
|
+
this.controller = new AutocompletePopoverController(
|
282
|
+
this,
|
283
|
+
this.updateContext.bind(this)
|
284
|
+
);
|
285
|
+
this.popoverOptions = defaultPopoverOptions;
|
286
|
+
this.context = {
|
287
|
+
active: false,
|
288
|
+
query: "",
|
289
|
+
handleDismiss: () => {
|
290
|
+
var _a, _b;
|
291
|
+
return (_b = (_a = this.controller).handleDismiss) == null ? void 0 : _b.call(_a);
|
292
|
+
},
|
293
|
+
handleSubmit: () => {
|
294
|
+
var _a, _b;
|
295
|
+
return (_b = (_a = this.controller).handleSubmit) == null ? void 0 : _b.call(_a);
|
296
|
+
}
|
297
|
+
};
|
298
|
+
}
|
299
|
+
get list() {
|
300
|
+
var _a, _b, _c;
|
301
|
+
return (_c = (_b = (_a = this.defaultSlot) == null ? void 0 : _a.assignedElements({ flatten: true })) == null ? void 0 : _b.find(isAutocompleteList)) != null ? _c : null;
|
302
|
+
}
|
303
|
+
updateContext(query3, active) {
|
304
|
+
if (this.context.query === query3 && this.context.active === active) {
|
305
|
+
return;
|
306
|
+
}
|
307
|
+
this.context = { ...this.context, query: query3, active };
|
308
|
+
requestAnimationFrame(() => {
|
309
|
+
var _a;
|
310
|
+
(_a = this.list) == null ? void 0 : _a.selectFirstItem();
|
311
|
+
});
|
312
|
+
}
|
313
|
+
/** @hidden */
|
314
|
+
get active() {
|
315
|
+
var _a;
|
316
|
+
return !!((_a = this.controller) == null ? void 0 : _a.reference);
|
317
|
+
}
|
318
|
+
/** @hidden */
|
319
|
+
willUpdate() {
|
320
|
+
if (this.editor) {
|
321
|
+
this.controller.setEditor(this.editor);
|
322
|
+
}
|
323
|
+
if (this.regex) {
|
324
|
+
this.controller.setRegex(this.regex);
|
325
|
+
}
|
326
|
+
}
|
327
|
+
/** @hidden */
|
328
|
+
render() {
|
329
|
+
var _a;
|
330
|
+
return html2`<prosekit-popover .active="${this.active}" .reference="${(_a = this.controller.reference) != null ? _a : void 0}" .options="${this.popoverOptions}"><slot></slot></prosekit-popover>`;
|
331
|
+
}
|
332
|
+
};
|
333
|
+
/** @hidden */
|
334
|
+
AutocompletePopover.styles = blockComponentStyles;
|
335
|
+
__decorateClass([
|
336
|
+
property2({ attribute: false })
|
337
|
+
], AutocompletePopover.prototype, "editor", 2);
|
338
|
+
__decorateClass([
|
339
|
+
property2({ attribute: false })
|
340
|
+
], AutocompletePopover.prototype, "regex", 2);
|
341
|
+
__decorateClass([
|
342
|
+
property2({ attribute: false })
|
343
|
+
], AutocompletePopover.prototype, "popoverOptions", 2);
|
344
|
+
__decorateClass([
|
345
|
+
provide({ context: commandPopoverContext }),
|
346
|
+
state2()
|
347
|
+
], AutocompletePopover.prototype, "context", 2);
|
348
|
+
__decorateClass([
|
349
|
+
property2({ attribute: false })
|
350
|
+
], AutocompletePopover.prototype, "onSelect", 2);
|
351
|
+
__decorateClass([
|
352
|
+
query2("slot")
|
353
|
+
], AutocompletePopover.prototype, "defaultSlot", 2);
|
354
|
+
AutocompletePopover = __decorateClass([
|
355
|
+
customElement2("prosekit-autocomplete-popover")
|
356
|
+
], AutocompletePopover);
|
357
|
+
export {
|
358
|
+
AutocompletePopover
|
359
|
+
};
|
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.5",
|
5
5
|
"private": false,
|
6
6
|
"author": {
|
7
7
|
"name": "ocavue",
|
@@ -30,36 +30,38 @@
|
|
30
30
|
"import": "./dist/prosekit-lit.js",
|
31
31
|
"default": "./dist/prosekit-lit.js"
|
32
32
|
},
|
33
|
-
"./
|
34
|
-
"types": "./dist/prosekit-lit-
|
35
|
-
"import": "./dist/prosekit-lit-
|
36
|
-
"default": "./dist/prosekit-lit-
|
33
|
+
"./components/autocomplete-empty": {
|
34
|
+
"types": "./dist/prosekit-lit-components-autocomplete-empty.d.ts",
|
35
|
+
"import": "./dist/prosekit-lit-components-autocomplete-empty.js",
|
36
|
+
"default": "./dist/prosekit-lit-components-autocomplete-empty.js"
|
37
37
|
},
|
38
|
-
"./
|
39
|
-
"types": "./dist/prosekit-lit-
|
40
|
-
"import": "./dist/prosekit-lit-
|
41
|
-
"default": "./dist/prosekit-lit-
|
38
|
+
"./components/autocomplete-item": {
|
39
|
+
"types": "./dist/prosekit-lit-components-autocomplete-item.d.ts",
|
40
|
+
"import": "./dist/prosekit-lit-components-autocomplete-item.js",
|
41
|
+
"default": "./dist/prosekit-lit-components-autocomplete-item.js"
|
42
42
|
},
|
43
|
-
"./
|
44
|
-
"types": "./dist/prosekit-lit-
|
45
|
-
"import": "./dist/prosekit-lit-
|
46
|
-
"default": "./dist/prosekit-lit-
|
43
|
+
"./components/autocomplete-list": {
|
44
|
+
"types": "./dist/prosekit-lit-components-autocomplete-list.d.ts",
|
45
|
+
"import": "./dist/prosekit-lit-components-autocomplete-list.js",
|
46
|
+
"default": "./dist/prosekit-lit-components-autocomplete-list.js"
|
47
47
|
},
|
48
|
-
"./
|
49
|
-
"types": "./dist/prosekit-lit-
|
50
|
-
"import": "./dist/prosekit-lit-
|
51
|
-
"default": "./dist/prosekit-lit-
|
48
|
+
"./components/autocomplete-popover": {
|
49
|
+
"types": "./dist/prosekit-lit-components-autocomplete-popover.d.ts",
|
50
|
+
"import": "./dist/prosekit-lit-components-autocomplete-popover.js",
|
51
|
+
"default": "./dist/prosekit-lit-components-autocomplete-popover.js"
|
52
52
|
}
|
53
53
|
},
|
54
54
|
"files": [
|
55
55
|
"dist"
|
56
56
|
],
|
57
57
|
"dependencies": {
|
58
|
-
"@floating-ui/dom": "^1.4.
|
58
|
+
"@floating-ui/dom": "^1.4.5",
|
59
|
+
"@lit-labs/context": "^0.3.3",
|
59
60
|
"@lit/reactive-element": "^1.6.2",
|
60
|
-
"@prosekit/core": "^0.0.
|
61
|
-
"@prosekit/extensions": "^0.0.
|
61
|
+
"@prosekit/core": "^0.0.4",
|
62
|
+
"@prosekit/extensions": "^0.0.4",
|
62
63
|
"@prosekit/pm": "^0.0.3",
|
64
|
+
"@superhuman/command-score": "^0.5.0",
|
63
65
|
"lit": "^2.7.6",
|
64
66
|
"lit-element": "^3.3.2",
|
65
67
|
"lit-html": "^2.7.5"
|
@@ -82,17 +84,17 @@
|
|
82
84
|
".": [
|
83
85
|
"./dist/prosekit-lit.d.ts"
|
84
86
|
],
|
85
|
-
"
|
86
|
-
"./dist/prosekit-lit-
|
87
|
+
"components/autocomplete-empty": [
|
88
|
+
"./dist/prosekit-lit-components-autocomplete-empty.d.ts"
|
87
89
|
],
|
88
|
-
"
|
89
|
-
"./dist/prosekit-lit-
|
90
|
+
"components/autocomplete-item": [
|
91
|
+
"./dist/prosekit-lit-components-autocomplete-item.d.ts"
|
90
92
|
],
|
91
|
-
"
|
92
|
-
"./dist/prosekit-lit-
|
93
|
+
"components/autocomplete-list": [
|
94
|
+
"./dist/prosekit-lit-components-autocomplete-list.d.ts"
|
93
95
|
],
|
94
|
-
"
|
95
|
-
"./dist/prosekit-lit-
|
96
|
+
"components/autocomplete-popover": [
|
97
|
+
"./dist/prosekit-lit-components-autocomplete-popover.d.ts"
|
96
98
|
]
|
97
99
|
}
|
98
100
|
}
|
package/src/index.ts
CHANGED
package/dist/chunk-WHIPWT4H.js
DELETED
@@ -1,122 +0,0 @@
|
|
1
|
-
import {
|
2
|
-
__decorateClass,
|
3
|
-
blockComponentStyles
|
4
|
-
} from "./chunk-6FOWUXQ2.js";
|
5
|
-
|
6
|
-
// src/elements/popover/popover.ts
|
7
|
-
import {
|
8
|
-
autoUpdate,
|
9
|
-
computePosition
|
10
|
-
} from "@floating-ui/dom";
|
11
|
-
import { LitElement, html } from "lit";
|
12
|
-
import { customElement, property, query, state } from "lit/decorators.js";
|
13
|
-
import { styleMap } from "lit/directives/style-map.js";
|
14
|
-
|
15
|
-
// src/utils/round-by-dpr.ts
|
16
|
-
function roundByDPR(value) {
|
17
|
-
const dpr = window.devicePixelRatio || 1;
|
18
|
-
return Math.round(value * dpr) / dpr;
|
19
|
-
}
|
20
|
-
|
21
|
-
// src/elements/popover/popover.ts
|
22
|
-
var Popover = class extends LitElement {
|
23
|
-
/** @hidden */
|
24
|
-
constructor() {
|
25
|
-
super();
|
26
|
-
this.active = false;
|
27
|
-
this.autoUpdate = false;
|
28
|
-
}
|
29
|
-
/** @hidden */
|
30
|
-
disconnectedCallback() {
|
31
|
-
this.cleanup();
|
32
|
-
}
|
33
|
-
/** @hidden */
|
34
|
-
updated(changed) {
|
35
|
-
if (!changed.has("computed")) {
|
36
|
-
this.start();
|
37
|
-
}
|
38
|
-
}
|
39
|
-
/** @hidden */
|
40
|
-
start() {
|
41
|
-
this.cleanup();
|
42
|
-
const reference = this.reference;
|
43
|
-
const floating = this.floating;
|
44
|
-
if (!reference)
|
45
|
-
return;
|
46
|
-
if (this.autoUpdate) {
|
47
|
-
this.cleanupAutoUpdate = autoUpdate(
|
48
|
-
reference,
|
49
|
-
floating,
|
50
|
-
() => void this.compute(),
|
51
|
-
this.autoUpdateOptions
|
52
|
-
);
|
53
|
-
} else {
|
54
|
-
void this.compute();
|
55
|
-
}
|
56
|
-
}
|
57
|
-
/** @hidden */
|
58
|
-
async compute() {
|
59
|
-
const reference = this.reference;
|
60
|
-
const floating = this.floating;
|
61
|
-
if (!reference)
|
62
|
-
return;
|
63
|
-
const options = this.options;
|
64
|
-
this.computed = await computePosition(reference, floating, options);
|
65
|
-
}
|
66
|
-
/** @hidden */
|
67
|
-
cleanup() {
|
68
|
-
var _a;
|
69
|
-
(_a = this.cleanupAutoUpdate) == null ? void 0 : _a.call(this);
|
70
|
-
this.cleanupAutoUpdate = void 0;
|
71
|
-
}
|
72
|
-
/** @hidden */
|
73
|
-
render() {
|
74
|
-
var _a;
|
75
|
-
const { x, y, strategy } = (_a = this.computed) != null ? _a : {
|
76
|
-
x: 0,
|
77
|
-
y: 0,
|
78
|
-
strategy: "absolute"
|
79
|
-
};
|
80
|
-
const style = {
|
81
|
-
top: "0",
|
82
|
-
left: "0",
|
83
|
-
position: strategy,
|
84
|
-
transform: `translate(${roundByDPR(x)}px,${roundByDPR(y)}px)`,
|
85
|
-
display: this.active ? void 0 : "none"
|
86
|
-
};
|
87
|
-
return html`<div class="floating" style="${styleMap(style)}"><slot></slot></div>`;
|
88
|
-
}
|
89
|
-
};
|
90
|
-
/** @hidden */
|
91
|
-
Popover.styles = blockComponentStyles;
|
92
|
-
__decorateClass([
|
93
|
-
property({ type: Boolean, reflect: true })
|
94
|
-
], Popover.prototype, "active", 2);
|
95
|
-
__decorateClass([
|
96
|
-
query(".floating")
|
97
|
-
], Popover.prototype, "floating", 2);
|
98
|
-
__decorateClass([
|
99
|
-
property()
|
100
|
-
], Popover.prototype, "reference", 2);
|
101
|
-
__decorateClass([
|
102
|
-
property()
|
103
|
-
], Popover.prototype, "options", 2);
|
104
|
-
__decorateClass([
|
105
|
-
property({
|
106
|
-
type: Boolean,
|
107
|
-
reflect: true
|
108
|
-
})
|
109
|
-
], Popover.prototype, "autoUpdate", 2);
|
110
|
-
__decorateClass([
|
111
|
-
property({ type: Object })
|
112
|
-
], Popover.prototype, "autoUpdateOptions", 2);
|
113
|
-
__decorateClass([
|
114
|
-
state()
|
115
|
-
], Popover.prototype, "computed", 2);
|
116
|
-
Popover = __decorateClass([
|
117
|
-
customElement("prosekit-popover")
|
118
|
-
], Popover);
|
119
|
-
|
120
|
-
export {
|
121
|
-
Popover
|
122
|
-
};
|
@@ -1,14 +0,0 @@
|
|
1
|
-
import { ComputePositionConfig } from '@floating-ui/dom';
|
2
|
-
|
3
|
-
/**
|
4
|
-
* The `PopoverOptions` interface defines the options that can be passed to the
|
5
|
-
* `computePosition` function from Floating UI. These options are used to
|
6
|
-
* configure the positioning of the popover element relative to its reference
|
7
|
-
* element. For more information on the available options, please refer to the
|
8
|
-
* Floating UI documentation.
|
9
|
-
*
|
10
|
-
* https://floating-ui.com/docs/computeposition#options
|
11
|
-
*/
|
12
|
-
type PopoverOptions = ComputePositionConfig;
|
13
|
-
|
14
|
-
export { PopoverOptions as P };
|
@@ -1,16 +0,0 @@
|
|
1
|
-
import * as lit from 'lit';
|
2
|
-
import { LitElement, CSSResultGroup } from 'lit';
|
3
|
-
|
4
|
-
declare class MenuItem extends LitElement {
|
5
|
-
/** @hidden */
|
6
|
-
constructor();
|
7
|
-
/** @hidden */
|
8
|
-
static styles: CSSResultGroup;
|
9
|
-
focused: boolean;
|
10
|
-
hidden: boolean;
|
11
|
-
onSelect?: VoidFunction;
|
12
|
-
/** @hidden */
|
13
|
-
render(): lit.TemplateResult<1>;
|
14
|
-
}
|
15
|
-
|
16
|
-
export { MenuItem };
|
@@ -1,37 +0,0 @@
|
|
1
|
-
import {
|
2
|
-
__decorateClass,
|
3
|
-
blockComponentStyles
|
4
|
-
} from "./chunk-6FOWUXQ2.js";
|
5
|
-
|
6
|
-
// src/elements/menu-item.ts
|
7
|
-
import { LitElement, html } from "lit";
|
8
|
-
import { customElement, property } from "lit/decorators.js";
|
9
|
-
var MenuItem = class extends LitElement {
|
10
|
-
/** @hidden */
|
11
|
-
constructor() {
|
12
|
-
super();
|
13
|
-
this.focused = false;
|
14
|
-
this.hidden = false;
|
15
|
-
}
|
16
|
-
/** @hidden */
|
17
|
-
render() {
|
18
|
-
return html`<div role="menuitem"><slot></slot></div>`;
|
19
|
-
}
|
20
|
-
};
|
21
|
-
/** @hidden */
|
22
|
-
MenuItem.styles = blockComponentStyles;
|
23
|
-
__decorateClass([
|
24
|
-
property({ type: Boolean, reflect: true, attribute: "data-focused" })
|
25
|
-
], MenuItem.prototype, "focused", 2);
|
26
|
-
__decorateClass([
|
27
|
-
property({ type: Boolean, reflect: true, attribute: "data-hidden" })
|
28
|
-
], MenuItem.prototype, "hidden", 2);
|
29
|
-
__decorateClass([
|
30
|
-
property({ attribute: false })
|
31
|
-
], MenuItem.prototype, "onSelect", 2);
|
32
|
-
MenuItem = __decorateClass([
|
33
|
-
customElement("prosekit-menu-item")
|
34
|
-
], MenuItem);
|
35
|
-
export {
|
36
|
-
MenuItem
|
37
|
-
};
|
@@ -1,50 +0,0 @@
|
|
1
|
-
import * as lit from 'lit';
|
2
|
-
import { LitElement, CSSResultGroup, PropertyValueMap } from 'lit';
|
3
|
-
import { Editor } from '@prosekit/core';
|
4
|
-
import { MenuItem } from './prosekit-lit-elements-menu-item.js';
|
5
|
-
|
6
|
-
declare class Menu extends LitElement {
|
7
|
-
/** @hidden */
|
8
|
-
constructor();
|
9
|
-
/** @hidden */
|
10
|
-
static styles: CSSResultGroup;
|
11
|
-
editor?: Editor;
|
12
|
-
/** @hidden */
|
13
|
-
focusedItem?: MenuItem;
|
14
|
-
/** @hidden */
|
15
|
-
defaultSlot?: HTMLSlotElement;
|
16
|
-
/** @hidden */
|
17
|
-
private cleanup;
|
18
|
-
/** @hidden */
|
19
|
-
protected firstUpdated(): void;
|
20
|
-
protected updated(_changedProperties: PropertyValueMap<any> | Map<PropertyKey, unknown>): void;
|
21
|
-
/** @hidden */
|
22
|
-
disconnectedCallback(): void;
|
23
|
-
ensureFocusedItem(): void;
|
24
|
-
/** @hidden */
|
25
|
-
private handleArrowUp;
|
26
|
-
/** @hidden */
|
27
|
-
private handleArrowDown;
|
28
|
-
/** @hidden */
|
29
|
-
private handleEscape;
|
30
|
-
/** @hidden */
|
31
|
-
private handleMouseOver;
|
32
|
-
/** @hidden */
|
33
|
-
private handleEnter;
|
34
|
-
/** @hidden */
|
35
|
-
private handleClick;
|
36
|
-
/** @hidden */
|
37
|
-
private handleSelect;
|
38
|
-
/** @hidden */
|
39
|
-
private focusItem;
|
40
|
-
/** @hidden */
|
41
|
-
private blurItem;
|
42
|
-
/** @hidden */
|
43
|
-
private queryAllMenuItems;
|
44
|
-
/** @hidden */
|
45
|
-
private queryVisibleMenuItems;
|
46
|
-
/** @hidden */
|
47
|
-
render(): lit.TemplateResult<1>;
|
48
|
-
}
|
49
|
-
|
50
|
-
export { Menu };
|