@prosekit/lit 0.0.0-next-20230627094841
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/LICENSE +21 -0
- package/README.md +0 -0
- package/dist/chunk-43BFWKM2.js +26 -0
- package/dist/chunk-5VENWR7M.js +118 -0
- package/dist/chunk-6EHMW3VI.js +19 -0
- package/dist/chunk-7C2I5DWH.js +122 -0
- package/dist/chunk-CFFBSSAU.js +121 -0
- package/dist/chunk-EZ4YICBQ.js +108 -0
- package/dist/chunk-JFOZX34E.js +109 -0
- package/dist/chunk-NMFTOM6J.js +189 -0
- package/dist/chunk-S65R2BUY.js +15 -0
- package/dist/chunk-TFM6CTEO.js +9 -0
- package/dist/chunk-VYMBIH4T.js +120 -0
- package/dist/chunk-WUZ77NLF.js +108 -0
- package/dist/chunk-XEV4EE3R.js +13 -0
- package/dist/chunk-Y34HGIIF.js +20 -0
- package/dist/chunk-YS57RXAX.js +124 -0
- package/dist/prosekit-lit-elements-menu-item.js +37 -0
- package/dist/prosekit-lit-elements-menu.js +169 -0
- package/dist/prosekit-lit-elements-picker.js +11 -0
- package/dist/prosekit-lit-elements-popover-slash.js +211 -0
- package/dist/prosekit-lit-elements-popover-suggestion-consumer.js +36 -0
- package/dist/prosekit-lit-elements-popover-suggestion.js +218 -0
- package/dist/prosekit-lit-elements-popover.js +7 -0
- package/dist/prosekit-lit-elements-popover2.js +119 -0
- package/dist/prosekit-lit-elements-slash-popover.js +213 -0
- package/dist/prosekit-lit.js +0 -0
- package/package.json +80 -0
- package/src/index.ts +5 -0
@@ -0,0 +1,189 @@
|
|
1
|
+
import {
|
2
|
+
createVisibilityFilter
|
3
|
+
} from "./chunk-Y34HGIIF.js";
|
4
|
+
import {
|
5
|
+
__decorateClass,
|
6
|
+
blockComponentStyles
|
7
|
+
} from "./chunk-43BFWKM2.js";
|
8
|
+
|
9
|
+
// src/elements/picker/picker.ts
|
10
|
+
import {
|
11
|
+
flip,
|
12
|
+
inline,
|
13
|
+
offset,
|
14
|
+
shift,
|
15
|
+
size
|
16
|
+
} from "@floating-ui/dom";
|
17
|
+
import { ProseKitError } from "@prosekit/core";
|
18
|
+
import { addSuggestion } from "@prosekit/extension-suggestion";
|
19
|
+
import { LitElement, html } from "lit";
|
20
|
+
import { customElement, property, query, state } from "lit/decorators.js";
|
21
|
+
|
22
|
+
// src/elements/menu/is-menu.ts
|
23
|
+
function isMenu(element) {
|
24
|
+
var _a, _b;
|
25
|
+
return ((_a = element == null ? void 0 : element.tagName) == null ? void 0 : _a.toLowerCase()) === "prosekit-menu" || ["menu"].includes((_b = element == null ? void 0 : element.getAttribute("role")) != null ? _b : "");
|
26
|
+
}
|
27
|
+
|
28
|
+
// src/elements/picker/picker.ts
|
29
|
+
var Picker = class extends LitElement {
|
30
|
+
constructor() {
|
31
|
+
super(...arguments);
|
32
|
+
this.popoverOptions = defaultPopoverOptions;
|
33
|
+
}
|
34
|
+
render() {
|
35
|
+
return html`<prosekit-popover .active="${this.active}" .reference="${this.reference}" .options="${this.popoverOptions}"><slot @menu-dismiss="${() => {
|
36
|
+
var _a;
|
37
|
+
return (_a = this.handleDismiss) == null ? void 0 : _a.call(this);
|
38
|
+
}}" @menu-select="${() => {
|
39
|
+
var _a;
|
40
|
+
return (_a = this.handleSubmit) == null ? void 0 : _a.call(this);
|
41
|
+
}}"></slot></prosekit-popover>`;
|
42
|
+
}
|
43
|
+
firstUpdated(_changedProperties) {
|
44
|
+
setTimeout(() => {
|
45
|
+
const editor = this.editor;
|
46
|
+
if (!editor) {
|
47
|
+
throw new ProseKitError("Missing 'editor' property");
|
48
|
+
}
|
49
|
+
if (!this.rules) {
|
50
|
+
throw new ProseKitError("Missing 'rules' property");
|
51
|
+
}
|
52
|
+
const extension = addSuggestion({
|
53
|
+
rules: this.rules,
|
54
|
+
onMatch: ({ dismiss, deleteMatch, match, matchAfter }) => {
|
55
|
+
var _a;
|
56
|
+
if (!this.editor)
|
57
|
+
return;
|
58
|
+
const editor2 = this.editor;
|
59
|
+
const span = editor2.view.dom.querySelector(
|
60
|
+
".prosemirror-prediction-match"
|
61
|
+
);
|
62
|
+
if (span) {
|
63
|
+
this.reference = span;
|
64
|
+
}
|
65
|
+
const matchText = match[0] + ((_a = matchAfter == null ? void 0 : matchAfter[0]) != null ? _a : "");
|
66
|
+
console.log("matchText:", matchText);
|
67
|
+
const menu = this.queryMenu();
|
68
|
+
console.log("menu:", menu);
|
69
|
+
if (menu)
|
70
|
+
menu.query = matchText;
|
71
|
+
this.handleDismiss = () => {
|
72
|
+
console.log("this.handleDismiss");
|
73
|
+
dismiss();
|
74
|
+
};
|
75
|
+
this.handleSubmit = () => {
|
76
|
+
console.log("this.handleSubmit");
|
77
|
+
deleteMatch();
|
78
|
+
};
|
79
|
+
},
|
80
|
+
onDeactivate: () => {
|
81
|
+
console.log("onDeactivate");
|
82
|
+
this.reference = void 0;
|
83
|
+
}
|
84
|
+
});
|
85
|
+
this.removeExtension = editor.use(extension);
|
86
|
+
}, 0);
|
87
|
+
}
|
88
|
+
disconnectedCallback() {
|
89
|
+
super.disconnectedCallback();
|
90
|
+
this.reference = void 0;
|
91
|
+
if (this.removeExtension) {
|
92
|
+
this.removeExtension();
|
93
|
+
this.removeExtension = void 0;
|
94
|
+
}
|
95
|
+
}
|
96
|
+
updated() {
|
97
|
+
const menu = this.queryMenu();
|
98
|
+
if (menu) {
|
99
|
+
console.log("set active to ", this.active);
|
100
|
+
menu.active = this.active;
|
101
|
+
}
|
102
|
+
}
|
103
|
+
get active() {
|
104
|
+
return !!this.reference;
|
105
|
+
}
|
106
|
+
queryMenu({
|
107
|
+
visible = null
|
108
|
+
} = {}) {
|
109
|
+
var _a, _b, _c, _d;
|
110
|
+
const menus = (_c = (_b = (_a = this.defaultSlot) == null ? void 0 : _a.assignedElements({ flatten: true })) == null ? void 0 : _b.filter(isMenu)) == null ? void 0 : _c.filter(createVisibilityFilter(visible));
|
111
|
+
return (_d = menus == null ? void 0 : menus[0]) != null ? _d : null;
|
112
|
+
}
|
113
|
+
};
|
114
|
+
Picker.styles = blockComponentStyles;
|
115
|
+
__decorateClass([
|
116
|
+
property()
|
117
|
+
], Picker.prototype, "editor", 2);
|
118
|
+
__decorateClass([
|
119
|
+
property()
|
120
|
+
], Picker.prototype, "rules", 2);
|
121
|
+
__decorateClass([
|
122
|
+
property({ type: Object })
|
123
|
+
], Picker.prototype, "popoverOptions", 2);
|
124
|
+
__decorateClass([
|
125
|
+
state()
|
126
|
+
], Picker.prototype, "reference", 2);
|
127
|
+
__decorateClass([
|
128
|
+
state()
|
129
|
+
], Picker.prototype, "removeExtension", 2);
|
130
|
+
__decorateClass([
|
131
|
+
state()
|
132
|
+
], Picker.prototype, "handleDismiss", 2);
|
133
|
+
__decorateClass([
|
134
|
+
state()
|
135
|
+
], Picker.prototype, "handleSubmit", 2);
|
136
|
+
__decorateClass([
|
137
|
+
query("slot")
|
138
|
+
], Picker.prototype, "defaultSlot", 2);
|
139
|
+
__decorateClass([
|
140
|
+
query("popover")
|
141
|
+
], Picker.prototype, "popover", 2);
|
142
|
+
Picker = __decorateClass([
|
143
|
+
customElement("prosekit-picker")
|
144
|
+
], Picker);
|
145
|
+
var defaultDetectOverflowOptions = {
|
146
|
+
// Make sure the popover is always at least 8px away from the boundary
|
147
|
+
padding: 8
|
148
|
+
// boundary: document.body,
|
149
|
+
};
|
150
|
+
var defaultPopoverOptions = {
|
151
|
+
placement: "bottom-end",
|
152
|
+
middleware: [
|
153
|
+
offset(({ rects }) => ({
|
154
|
+
// Put the popover at the bottom right corner
|
155
|
+
alignmentAxis: -rects.floating.width,
|
156
|
+
// Move down the popover by 4px
|
157
|
+
mainAxis: 4
|
158
|
+
})),
|
159
|
+
size({
|
160
|
+
apply: ({ availableHeight, elements }) => {
|
161
|
+
const style = {
|
162
|
+
// Minimum acceptable height is 100px.
|
163
|
+
// `flip` will then take over.....v2
|
164
|
+
maxHeight: `${Math.max(100, availableHeight)}px`,
|
165
|
+
overflowY: "auto"
|
166
|
+
};
|
167
|
+
Object.assign(elements.floating.style, style);
|
168
|
+
},
|
169
|
+
...defaultDetectOverflowOptions
|
170
|
+
}),
|
171
|
+
// Flip the popover to the top if it's overflowing the viewport
|
172
|
+
flip({
|
173
|
+
fallbackStrategy: "initialPlacement",
|
174
|
+
fallbackAxisSideDirection: "start",
|
175
|
+
crossAxis: false,
|
176
|
+
...defaultDetectOverflowOptions
|
177
|
+
}),
|
178
|
+
shift({
|
179
|
+
...defaultDetectOverflowOptions
|
180
|
+
}),
|
181
|
+
// Use the text caret as the reference point
|
182
|
+
inline()
|
183
|
+
]
|
184
|
+
};
|
185
|
+
|
186
|
+
export {
|
187
|
+
Picker,
|
188
|
+
defaultPopoverOptions
|
189
|
+
};
|
@@ -0,0 +1,15 @@
|
|
1
|
+
var __defProp = Object.defineProperty;
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
3
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
4
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
5
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
6
|
+
if (decorator = decorators[i])
|
7
|
+
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
8
|
+
if (kind && result)
|
9
|
+
__defProp(target, key, result);
|
10
|
+
return result;
|
11
|
+
};
|
12
|
+
|
13
|
+
export {
|
14
|
+
__decorateClass
|
15
|
+
};
|
@@ -0,0 +1,120 @@
|
|
1
|
+
import {
|
2
|
+
blockComponentStyles
|
3
|
+
} from "./chunk-XEV4EE3R.js";
|
4
|
+
import {
|
5
|
+
__decorateClass
|
6
|
+
} from "./chunk-S65R2BUY.js";
|
7
|
+
|
8
|
+
// src/elements/popover.ts
|
9
|
+
import {
|
10
|
+
autoUpdate,
|
11
|
+
computePosition
|
12
|
+
} from "@floating-ui/dom";
|
13
|
+
import { LitElement, html } from "lit";
|
14
|
+
import { customElement, property, query, state } from "lit/decorators.js";
|
15
|
+
import { styleMap } from "lit/directives/style-map.js";
|
16
|
+
var Popover = class extends LitElement {
|
17
|
+
/** @hidden */
|
18
|
+
constructor() {
|
19
|
+
super();
|
20
|
+
this.active = false;
|
21
|
+
this.autoUpdate = false;
|
22
|
+
}
|
23
|
+
/** @hidden */
|
24
|
+
disconnectedCallback() {
|
25
|
+
this.cleanup();
|
26
|
+
}
|
27
|
+
/** @hidden */
|
28
|
+
updated(changed) {
|
29
|
+
if (!changed.has("computed")) {
|
30
|
+
this.start();
|
31
|
+
}
|
32
|
+
}
|
33
|
+
/** @hidden */
|
34
|
+
start() {
|
35
|
+
this.cleanup();
|
36
|
+
const reference = this.reference;
|
37
|
+
const floating = this.floating;
|
38
|
+
if (!reference)
|
39
|
+
return;
|
40
|
+
if (this.autoUpdate) {
|
41
|
+
this.cleanupAutoUpdate = autoUpdate(
|
42
|
+
reference,
|
43
|
+
floating,
|
44
|
+
() => void this.compute(),
|
45
|
+
this.autoUpdateOptions
|
46
|
+
);
|
47
|
+
} else {
|
48
|
+
void this.compute();
|
49
|
+
}
|
50
|
+
}
|
51
|
+
/** @hidden */
|
52
|
+
async compute() {
|
53
|
+
const reference = this.reference;
|
54
|
+
const floating = this.floating;
|
55
|
+
if (!reference)
|
56
|
+
return;
|
57
|
+
const options = this.options;
|
58
|
+
this.computed = await computePosition(reference, floating, options);
|
59
|
+
}
|
60
|
+
/** @hidden */
|
61
|
+
cleanup() {
|
62
|
+
var _a;
|
63
|
+
(_a = this.cleanupAutoUpdate) == null ? void 0 : _a.call(this);
|
64
|
+
this.cleanupAutoUpdate = void 0;
|
65
|
+
}
|
66
|
+
/** @hidden */
|
67
|
+
render() {
|
68
|
+
var _a;
|
69
|
+
const { x, y, strategy } = (_a = this.computed) != null ? _a : {
|
70
|
+
x: 0,
|
71
|
+
y: 0,
|
72
|
+
strategy: "absolute"
|
73
|
+
};
|
74
|
+
const style = {
|
75
|
+
top: "0",
|
76
|
+
left: "0",
|
77
|
+
position: strategy,
|
78
|
+
transform: `translate(${roundByDPR(x)}px,${roundByDPR(y)}px)`,
|
79
|
+
display: this.active ? void 0 : "none"
|
80
|
+
};
|
81
|
+
return html`<div class="floating" style="${styleMap(style)}"><slot></slot></div>`;
|
82
|
+
}
|
83
|
+
};
|
84
|
+
/** @hidden */
|
85
|
+
Popover.styles = blockComponentStyles;
|
86
|
+
__decorateClass([
|
87
|
+
property({ type: Boolean, reflect: true })
|
88
|
+
], Popover.prototype, "active", 2);
|
89
|
+
__decorateClass([
|
90
|
+
query(".floating")
|
91
|
+
], Popover.prototype, "floating", 2);
|
92
|
+
__decorateClass([
|
93
|
+
property()
|
94
|
+
], Popover.prototype, "reference", 2);
|
95
|
+
__decorateClass([
|
96
|
+
property()
|
97
|
+
], Popover.prototype, "options", 2);
|
98
|
+
__decorateClass([
|
99
|
+
property({
|
100
|
+
type: Boolean,
|
101
|
+
reflect: true
|
102
|
+
})
|
103
|
+
], Popover.prototype, "autoUpdate", 2);
|
104
|
+
__decorateClass([
|
105
|
+
property({ type: Object })
|
106
|
+
], Popover.prototype, "autoUpdateOptions", 2);
|
107
|
+
__decorateClass([
|
108
|
+
state()
|
109
|
+
], Popover.prototype, "computed", 2);
|
110
|
+
Popover = __decorateClass([
|
111
|
+
customElement("prosekit-popover")
|
112
|
+
], Popover);
|
113
|
+
function roundByDPR(value) {
|
114
|
+
const dpr = window.devicePixelRatio || 1;
|
115
|
+
return Math.round(value * dpr) / dpr;
|
116
|
+
}
|
117
|
+
|
118
|
+
export {
|
119
|
+
Popover
|
120
|
+
};
|
@@ -0,0 +1,108 @@
|
|
1
|
+
import {
|
2
|
+
__decorateClass,
|
3
|
+
blockComponentStyles
|
4
|
+
} from "./chunk-43BFWKM2.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
|
+
var Popover = class extends LitElement {
|
15
|
+
constructor() {
|
16
|
+
super(...arguments);
|
17
|
+
this.active = false;
|
18
|
+
this.reference = null;
|
19
|
+
this.autoUpdate = false;
|
20
|
+
}
|
21
|
+
disconnectedCallback() {
|
22
|
+
this.cleanup();
|
23
|
+
}
|
24
|
+
updated(changed) {
|
25
|
+
if (!changed.has("computed")) {
|
26
|
+
this.start();
|
27
|
+
}
|
28
|
+
}
|
29
|
+
start() {
|
30
|
+
this.cleanup();
|
31
|
+
const reference = this.reference;
|
32
|
+
const floating = this.floating;
|
33
|
+
if (!reference)
|
34
|
+
return;
|
35
|
+
if (this.autoUpdate) {
|
36
|
+
this.cleanupAutoUpdate = autoUpdate(
|
37
|
+
reference,
|
38
|
+
floating,
|
39
|
+
() => void this.compute(),
|
40
|
+
this.autoUpdateOptions
|
41
|
+
);
|
42
|
+
} else {
|
43
|
+
void this.compute();
|
44
|
+
}
|
45
|
+
}
|
46
|
+
async compute() {
|
47
|
+
const reference = this.reference;
|
48
|
+
const floating = this.floating;
|
49
|
+
if (!reference)
|
50
|
+
return;
|
51
|
+
const options = this.options;
|
52
|
+
this.computed = await computePosition(reference, floating, options);
|
53
|
+
}
|
54
|
+
render() {
|
55
|
+
var _a;
|
56
|
+
const { x, y, strategy } = (_a = this.computed) != null ? _a : {
|
57
|
+
x: 0,
|
58
|
+
y: 0,
|
59
|
+
strategy: "absolute"
|
60
|
+
};
|
61
|
+
const style = {
|
62
|
+
top: "0",
|
63
|
+
left: "0",
|
64
|
+
position: strategy,
|
65
|
+
transform: `translate(${roundByDPR(x)}px,${roundByDPR(y)}px)`,
|
66
|
+
display: this.active ? void 0 : "none"
|
67
|
+
};
|
68
|
+
return html`<div class="floating" style="${styleMap(style)}"><slot></slot></div>`;
|
69
|
+
}
|
70
|
+
cleanup() {
|
71
|
+
var _a;
|
72
|
+
(_a = this.cleanupAutoUpdate) == null ? void 0 : _a.call(this);
|
73
|
+
this.cleanupAutoUpdate = void 0;
|
74
|
+
}
|
75
|
+
};
|
76
|
+
Popover.styles = blockComponentStyles;
|
77
|
+
__decorateClass([
|
78
|
+
property({ type: Boolean, reflect: true })
|
79
|
+
], Popover.prototype, "active", 2);
|
80
|
+
__decorateClass([
|
81
|
+
query(".floating")
|
82
|
+
], Popover.prototype, "floating", 2);
|
83
|
+
__decorateClass([
|
84
|
+
property()
|
85
|
+
], Popover.prototype, "reference", 2);
|
86
|
+
__decorateClass([
|
87
|
+
property({ type: Object })
|
88
|
+
], Popover.prototype, "options", 2);
|
89
|
+
__decorateClass([
|
90
|
+
property({ type: Boolean, reflect: true })
|
91
|
+
], Popover.prototype, "autoUpdate", 2);
|
92
|
+
__decorateClass([
|
93
|
+
property({ type: Object })
|
94
|
+
], Popover.prototype, "autoUpdateOptions", 2);
|
95
|
+
__decorateClass([
|
96
|
+
state()
|
97
|
+
], Popover.prototype, "computed", 2);
|
98
|
+
Popover = __decorateClass([
|
99
|
+
customElement("prosekit-popover")
|
100
|
+
], Popover);
|
101
|
+
function roundByDPR(value) {
|
102
|
+
const dpr = window.devicePixelRatio || 1;
|
103
|
+
return Math.round(value * dpr) / dpr;
|
104
|
+
}
|
105
|
+
|
106
|
+
export {
|
107
|
+
Popover
|
108
|
+
};
|
@@ -0,0 +1,13 @@
|
|
1
|
+
// src/styles/block-component.styles.ts
|
2
|
+
import { css as css2 } from "lit";
|
3
|
+
|
4
|
+
// src/styles/component.styles.ts
|
5
|
+
import { css } from "lit";
|
6
|
+
var componentStyles = css`:host{box-sizing:border-box}:host *,:host ::after,:host ::before{box-sizing:inherit}`;
|
7
|
+
|
8
|
+
// src/styles/block-component.styles.ts
|
9
|
+
var blockComponentStyles = css2`${componentStyles}:host{display:block}`;
|
10
|
+
|
11
|
+
export {
|
12
|
+
blockComponentStyles
|
13
|
+
};
|
@@ -0,0 +1,20 @@
|
|
1
|
+
// src/utils/visibility.ts
|
2
|
+
function isVisibleElement(element) {
|
3
|
+
return !element.hidden;
|
4
|
+
}
|
5
|
+
function isHiddenElement(element) {
|
6
|
+
return element.hidden;
|
7
|
+
}
|
8
|
+
function createVisibilityFilter(visible) {
|
9
|
+
if (visible === true)
|
10
|
+
return isVisibleElement;
|
11
|
+
if (visible === false)
|
12
|
+
return isHiddenElement;
|
13
|
+
return () => true;
|
14
|
+
}
|
15
|
+
|
16
|
+
export {
|
17
|
+
isVisibleElement,
|
18
|
+
isHiddenElement,
|
19
|
+
createVisibilityFilter
|
20
|
+
};
|
@@ -0,0 +1,124 @@
|
|
1
|
+
import {
|
2
|
+
blockComponentStyles
|
3
|
+
} from "./chunk-XEV4EE3R.js";
|
4
|
+
import {
|
5
|
+
__decorateClass
|
6
|
+
} from "./chunk-S65R2BUY.js";
|
7
|
+
|
8
|
+
// src/elements/popover/popover.ts
|
9
|
+
import {
|
10
|
+
autoUpdate,
|
11
|
+
computePosition
|
12
|
+
} from "@floating-ui/dom";
|
13
|
+
import { LitElement, html } from "lit";
|
14
|
+
import { customElement, property, query, state } from "lit/decorators.js";
|
15
|
+
import { styleMap } from "lit/directives/style-map.js";
|
16
|
+
|
17
|
+
// src/utils/round-by-dpr.ts
|
18
|
+
function roundByDPR(value) {
|
19
|
+
const dpr = window.devicePixelRatio || 1;
|
20
|
+
return Math.round(value * dpr) / dpr;
|
21
|
+
}
|
22
|
+
|
23
|
+
// src/elements/popover/popover.ts
|
24
|
+
var Popover = class extends LitElement {
|
25
|
+
/** @hidden */
|
26
|
+
constructor() {
|
27
|
+
super();
|
28
|
+
this.active = false;
|
29
|
+
this.autoUpdate = false;
|
30
|
+
}
|
31
|
+
/** @hidden */
|
32
|
+
disconnectedCallback() {
|
33
|
+
this.cleanup();
|
34
|
+
}
|
35
|
+
/** @hidden */
|
36
|
+
updated(changed) {
|
37
|
+
if (!changed.has("computed")) {
|
38
|
+
this.start();
|
39
|
+
}
|
40
|
+
}
|
41
|
+
/** @hidden */
|
42
|
+
start() {
|
43
|
+
this.cleanup();
|
44
|
+
const reference = this.reference;
|
45
|
+
const floating = this.floating;
|
46
|
+
if (!reference)
|
47
|
+
return;
|
48
|
+
if (this.autoUpdate) {
|
49
|
+
this.cleanupAutoUpdate = autoUpdate(
|
50
|
+
reference,
|
51
|
+
floating,
|
52
|
+
() => void this.compute(),
|
53
|
+
this.autoUpdateOptions
|
54
|
+
);
|
55
|
+
} else {
|
56
|
+
void this.compute();
|
57
|
+
}
|
58
|
+
}
|
59
|
+
/** @hidden */
|
60
|
+
async compute() {
|
61
|
+
const reference = this.reference;
|
62
|
+
const floating = this.floating;
|
63
|
+
if (!reference)
|
64
|
+
return;
|
65
|
+
const options = this.options;
|
66
|
+
this.computed = await computePosition(reference, floating, options);
|
67
|
+
}
|
68
|
+
/** @hidden */
|
69
|
+
cleanup() {
|
70
|
+
var _a;
|
71
|
+
(_a = this.cleanupAutoUpdate) == null ? void 0 : _a.call(this);
|
72
|
+
this.cleanupAutoUpdate = void 0;
|
73
|
+
}
|
74
|
+
/** @hidden */
|
75
|
+
render() {
|
76
|
+
var _a;
|
77
|
+
const { x, y, strategy } = (_a = this.computed) != null ? _a : {
|
78
|
+
x: 0,
|
79
|
+
y: 0,
|
80
|
+
strategy: "absolute"
|
81
|
+
};
|
82
|
+
const style = {
|
83
|
+
top: "0",
|
84
|
+
left: "0",
|
85
|
+
position: strategy,
|
86
|
+
transform: `translate(${roundByDPR(x)}px,${roundByDPR(y)}px)`,
|
87
|
+
display: this.active ? void 0 : "none"
|
88
|
+
};
|
89
|
+
return html`<div class="floating" style="${styleMap(style)}"><slot></slot></div>`;
|
90
|
+
}
|
91
|
+
};
|
92
|
+
/** @hidden */
|
93
|
+
Popover.styles = blockComponentStyles;
|
94
|
+
__decorateClass([
|
95
|
+
property({ type: Boolean, reflect: true })
|
96
|
+
], Popover.prototype, "active", 2);
|
97
|
+
__decorateClass([
|
98
|
+
query(".floating")
|
99
|
+
], Popover.prototype, "floating", 2);
|
100
|
+
__decorateClass([
|
101
|
+
property()
|
102
|
+
], Popover.prototype, "reference", 2);
|
103
|
+
__decorateClass([
|
104
|
+
property()
|
105
|
+
], Popover.prototype, "options", 2);
|
106
|
+
__decorateClass([
|
107
|
+
property({
|
108
|
+
type: Boolean,
|
109
|
+
reflect: true
|
110
|
+
})
|
111
|
+
], Popover.prototype, "autoUpdate", 2);
|
112
|
+
__decorateClass([
|
113
|
+
property({ type: Object })
|
114
|
+
], Popover.prototype, "autoUpdateOptions", 2);
|
115
|
+
__decorateClass([
|
116
|
+
state()
|
117
|
+
], Popover.prototype, "computed", 2);
|
118
|
+
Popover = __decorateClass([
|
119
|
+
customElement("prosekit-popover")
|
120
|
+
], Popover);
|
121
|
+
|
122
|
+
export {
|
123
|
+
Popover
|
124
|
+
};
|
@@ -0,0 +1,37 @@
|
|
1
|
+
import {
|
2
|
+
__decorateClass,
|
3
|
+
blockComponentStyles
|
4
|
+
} from "./chunk-43BFWKM2.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
|
+
};
|