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