@prosekit/lit 0.2.8 → 0.3.0
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 +24 -1111
- package/dist/prosekit-lit-autocomplete.d.ts +4 -0
- package/dist/prosekit-lit-autocomplete.js +11 -0
- package/dist/prosekit-lit-block-handle.d.ts +2 -0
- package/dist/prosekit-lit-block-handle.js +7 -0
- package/dist/prosekit-lit-inline-popover.d.ts +0 -3
- package/dist/prosekit-lit-inline-popover.js +2 -191
- package/dist/prosekit-lit-popover.d.ts +3 -6
- package/dist/prosekit-lit-popover.js +7 -9
- package/dist/prosekit-lit-resizable.d.ts +2 -3
- package/dist/prosekit-lit-resizable.js +5 -110
- package/dist/prosekit-lit-tooltip.d.ts +3 -0
- package/dist/prosekit-lit-tooltip.js +9 -0
- package/package.json +24 -121
- package/dist/chunk-5CI65R73.js +0 -9
- package/dist/chunk-7E5POS6D.js +0 -53
- package/dist/chunk-BFBBTEVM.js +0 -204
- package/dist/chunk-C4MW43I4.js +0 -9
- package/dist/chunk-FKSZFUL3.js +0 -371
- package/dist/chunk-LCDA7GFP.js +0 -11
- package/dist/chunk-MZAHIYA5.js +0 -114
- package/dist/chunk-S72UTR5M.js +0 -9
- package/dist/chunk-UIHDPY7W.js +0 -30
- package/dist/chunk-VPUV5WUG.js +0 -62
- package/dist/chunk-WEUGKLVB.js +0 -9
- package/dist/prosekit-lit-autocomplete-empty.d.ts +0 -3
- package/dist/prosekit-lit-autocomplete-empty.js +0 -46
- package/dist/prosekit-lit-autocomplete-item.d.ts +0 -3
- package/dist/prosekit-lit-autocomplete-item.js +0 -11
- package/dist/prosekit-lit-autocomplete-list.d.ts +0 -3
- package/dist/prosekit-lit-autocomplete-list.js +0 -13
- package/dist/prosekit-lit-autocomplete-popover.d.ts +0 -4
- package/dist/prosekit-lit-autocomplete-popover.js +0 -200
- package/dist/prosekit-lit-block-popover.d.ts +0 -3
- package/dist/prosekit-lit-block-popover.js +0 -170
- package/dist/prosekit-lit-combo-box-input.d.ts +0 -3
- package/dist/prosekit-lit-combo-box-input.js +0 -94
- package/dist/prosekit-lit-combo-box-item.d.ts +0 -3
- package/dist/prosekit-lit-combo-box-item.js +0 -11
- package/dist/prosekit-lit-combo-box-list.d.ts +0 -3
- package/dist/prosekit-lit-combo-box-list.js +0 -46
- package/dist/prosekit-lit-combo-box.d.ts +0 -3
- package/dist/prosekit-lit-combo-box.js +0 -131
- package/dist/prosekit-lit-drag-handle.d.ts +0 -3
- package/dist/prosekit-lit-drag-handle.js +0 -96
- package/dist/prosekit-lit-popover-content.d.ts +0 -3
- package/dist/prosekit-lit-popover-content.js +0 -17
- package/dist/prosekit-lit-popover-root.d.ts +0 -3
- package/dist/prosekit-lit-popover-root.js +0 -17
- package/dist/prosekit-lit-popover-trigger.d.ts +0 -3
- package/dist/prosekit-lit-popover-trigger.js +0 -12
- package/dist/prosekit-lit-resizable-handle.d.ts +0 -3
- package/dist/prosekit-lit-resizable-handle.js +0 -161
package/dist/chunk-S72UTR5M.js
DELETED
package/dist/chunk-UIHDPY7W.js
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
// src/components/block-element/index.ts
|
2
|
-
import { LitElement } from "lit";
|
3
|
-
var LightElement = class extends LitElement {
|
4
|
-
/**
|
5
|
-
* @hidden
|
6
|
-
*/
|
7
|
-
constructor() {
|
8
|
-
super();
|
9
|
-
}
|
10
|
-
/**
|
11
|
-
* @hidden
|
12
|
-
*/
|
13
|
-
createRenderRoot() {
|
14
|
-
return this;
|
15
|
-
}
|
16
|
-
/**
|
17
|
-
* @hidden
|
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
|
-
};
|
27
|
-
|
28
|
-
export {
|
29
|
-
LightElement
|
30
|
-
};
|
package/dist/chunk-VPUV5WUG.js
DELETED
@@ -1,62 +0,0 @@
|
|
1
|
-
import {
|
2
|
-
autocompleteListContext
|
3
|
-
} from "./chunk-5CI65R73.js";
|
4
|
-
import {
|
5
|
-
LightElement
|
6
|
-
} from "./chunk-UIHDPY7W.js";
|
7
|
-
import {
|
8
|
-
defineCustomElement
|
9
|
-
} from "./chunk-LCDA7GFP.js";
|
10
|
-
|
11
|
-
// src/components/autocomplete-item/component.ts
|
12
|
-
import { ContextConsumer } from "@lit/context";
|
13
|
-
import "lit";
|
14
|
-
var propNames = ["value", "onSelect"];
|
15
|
-
var AutocompleteItem = class extends LightElement {
|
16
|
-
constructor() {
|
17
|
-
super(...arguments);
|
18
|
-
this.listContext = new ContextConsumer(this, {
|
19
|
-
context: autocompleteListContext,
|
20
|
-
subscribe: true
|
21
|
-
});
|
22
|
-
this.value = "";
|
23
|
-
this.selected = false;
|
24
|
-
}
|
25
|
-
get content() {
|
26
|
-
const text = this.value || this.textContent || "";
|
27
|
-
return text.trim().toLowerCase();
|
28
|
-
}
|
29
|
-
connectedCallback() {
|
30
|
-
super.connectedCallback();
|
31
|
-
this.role = "option";
|
32
|
-
}
|
33
|
-
willUpdate() {
|
34
|
-
var _a, _b;
|
35
|
-
const content = this.content;
|
36
|
-
const score = ((_a = this.listContext.value) == null ? void 0 : _a.scores.get(content)) || 0;
|
37
|
-
const hidden = score <= 0;
|
38
|
-
this.selected = !hidden && content === ((_b = this.listContext.value) == null ? void 0 : _b.selectedValue);
|
39
|
-
this.setHidden(hidden);
|
40
|
-
}
|
41
|
-
updated(changedProperties) {
|
42
|
-
var _a;
|
43
|
-
this.ariaSelected = String(this.selected);
|
44
|
-
if (this.selected && changedProperties.has("selected") && !changedProperties.get("selected") && ((_a = this.listContext.value) == null ? void 0 : _a.selectedReason) === "keyboard") {
|
45
|
-
this.scrollIntoView({ block: "nearest" });
|
46
|
-
}
|
47
|
-
}
|
48
|
-
};
|
49
|
-
/**
|
50
|
-
* @hidden
|
51
|
-
*/
|
52
|
-
AutocompleteItem.properties = {
|
53
|
-
value: { type: String, reflect: true, attribute: "data-value" },
|
54
|
-
selected: { type: Boolean, reflect: true, attribute: "data-selected" },
|
55
|
-
onSelect: { attribute: false }
|
56
|
-
};
|
57
|
-
defineCustomElement("prosekit-autocomplete-item", AutocompleteItem);
|
58
|
-
|
59
|
-
export {
|
60
|
-
propNames,
|
61
|
-
AutocompleteItem
|
62
|
-
};
|
package/dist/chunk-WEUGKLVB.js
DELETED
@@ -1,46 +0,0 @@
|
|
1
|
-
import {
|
2
|
-
autocompleteListContext
|
3
|
-
} from "./chunk-5CI65R73.js";
|
4
|
-
import {
|
5
|
-
LightElement
|
6
|
-
} from "./chunk-UIHDPY7W.js";
|
7
|
-
import {
|
8
|
-
defineCustomElement
|
9
|
-
} from "./chunk-LCDA7GFP.js";
|
10
|
-
|
11
|
-
// src/components/autocomplete-empty/index.ts
|
12
|
-
import { ContextConsumer } from "@lit/context";
|
13
|
-
import "lit";
|
14
|
-
var propNames = [];
|
15
|
-
var AutocompleteEmpty = class extends LightElement {
|
16
|
-
constructor() {
|
17
|
-
super(...arguments);
|
18
|
-
this.listContext = new ContextConsumer(this, {
|
19
|
-
context: autocompleteListContext,
|
20
|
-
subscribe: true
|
21
|
-
});
|
22
|
-
}
|
23
|
-
connectedCallback() {
|
24
|
-
super.connectedCallback();
|
25
|
-
this.role = "option";
|
26
|
-
}
|
27
|
-
willUpdate(_changedProperties) {
|
28
|
-
var _a;
|
29
|
-
const scores = (_a = this.listContext.value) == null ? void 0 : _a.scores;
|
30
|
-
let hasMatch = false;
|
31
|
-
if (scores) {
|
32
|
-
for (const score of scores.values()) {
|
33
|
-
if (score > 0) {
|
34
|
-
hasMatch = true;
|
35
|
-
break;
|
36
|
-
}
|
37
|
-
}
|
38
|
-
}
|
39
|
-
this.setHidden(hasMatch);
|
40
|
-
}
|
41
|
-
};
|
42
|
-
defineCustomElement("prosekit-autocomplete-empty", AutocompleteEmpty);
|
43
|
-
export {
|
44
|
-
AutocompleteEmpty,
|
45
|
-
propNames
|
46
|
-
};
|
@@ -1,13 +0,0 @@
|
|
1
|
-
import {
|
2
|
-
AutocompleteList,
|
3
|
-
propNames
|
4
|
-
} from "./chunk-BFBBTEVM.js";
|
5
|
-
import "./chunk-VPUV5WUG.js";
|
6
|
-
import "./chunk-5CI65R73.js";
|
7
|
-
import "./chunk-MZAHIYA5.js";
|
8
|
-
import "./chunk-UIHDPY7W.js";
|
9
|
-
import "./chunk-LCDA7GFP.js";
|
10
|
-
export {
|
11
|
-
AutocompleteList,
|
12
|
-
propNames
|
13
|
-
};
|
@@ -1,200 +0,0 @@
|
|
1
|
-
import {
|
2
|
-
autocompletePopoverContext
|
3
|
-
} from "./chunk-BFBBTEVM.js";
|
4
|
-
import "./chunk-VPUV5WUG.js";
|
5
|
-
import "./chunk-5CI65R73.js";
|
6
|
-
import "./chunk-MZAHIYA5.js";
|
7
|
-
import {
|
8
|
-
Popover
|
9
|
-
} from "./chunk-FKSZFUL3.js";
|
10
|
-
import "./chunk-UIHDPY7W.js";
|
11
|
-
import {
|
12
|
-
defineCustomElement
|
13
|
-
} from "./chunk-LCDA7GFP.js";
|
14
|
-
|
15
|
-
// src/components/autocomplete-popover/index.ts
|
16
|
-
import { ContextProvider } from "@lit/context";
|
17
|
-
import "@prosekit/core";
|
18
|
-
|
19
|
-
// src/components/autocomplete-list/helpers.ts
|
20
|
-
function isAutocompleteList(element) {
|
21
|
-
var _a;
|
22
|
-
return ((_a = element == null ? void 0 : element.tagName) == null ? void 0 : _a.toLowerCase()) === "prosekit-autocomplete-list";
|
23
|
-
}
|
24
|
-
|
25
|
-
// src/components/autocomplete-popover/controller.ts
|
26
|
-
import "@prosekit/core";
|
27
|
-
import {
|
28
|
-
AutocompleteRule,
|
29
|
-
defineAutocomplete
|
30
|
-
} from "@prosekit/extensions/autocomplete";
|
31
|
-
import "lit";
|
32
|
-
|
33
|
-
// src/components/autocomplete-popover/helpers.ts
|
34
|
-
function defaultQueryBuilder(match) {
|
35
|
-
return match[0].toLowerCase().replace(/[!"#$%&'()*+,-./:;<=>?@[\\\]^_`{|}~]/g, "").replace(/\s\s+/g, " ").trim();
|
36
|
-
}
|
37
|
-
|
38
|
-
// src/components/autocomplete-popover/controller.ts
|
39
|
-
var AutocompletePopoverController = class {
|
40
|
-
constructor(host, onChange) {
|
41
|
-
this.host = host;
|
42
|
-
this.onChange = onChange;
|
43
|
-
this.reference = null;
|
44
|
-
this.editor = null;
|
45
|
-
this.regex = null;
|
46
|
-
this.cleanup = null;
|
47
|
-
this.handleDismiss = null;
|
48
|
-
this.handleSubmit = null;
|
49
|
-
this.host.addController(this);
|
50
|
-
}
|
51
|
-
setEditor(editor) {
|
52
|
-
if (this.editor !== editor) {
|
53
|
-
this.editor = editor;
|
54
|
-
this.defineExtension();
|
55
|
-
this.host.requestUpdate();
|
56
|
-
}
|
57
|
-
}
|
58
|
-
setRegex(regex) {
|
59
|
-
if (this.regex !== regex) {
|
60
|
-
this.regex = regex;
|
61
|
-
this.defineExtension();
|
62
|
-
this.host.requestUpdate();
|
63
|
-
}
|
64
|
-
}
|
65
|
-
defineExtension() {
|
66
|
-
var _a;
|
67
|
-
const regex = this.regex;
|
68
|
-
const editor = this.editor;
|
69
|
-
if (!regex || !editor) {
|
70
|
-
return;
|
71
|
-
}
|
72
|
-
(_a = this.cleanup) == null ? void 0 : _a.call(this);
|
73
|
-
this.cleanup = null;
|
74
|
-
const handleEnter = (options) => {
|
75
|
-
const span = editor.view.dom.querySelector(
|
76
|
-
".prosemirror-prediction-match"
|
77
|
-
);
|
78
|
-
if (span) {
|
79
|
-
this.reference = span;
|
80
|
-
}
|
81
|
-
const query = defaultQueryBuilder(options.match);
|
82
|
-
this.onChange(query != null ? query : "", !!this.reference);
|
83
|
-
this.handleDismiss = options.ignoreMatch;
|
84
|
-
this.handleSubmit = options.deleteMatch;
|
85
|
-
};
|
86
|
-
const handleLeave = () => {
|
87
|
-
this.reference = null;
|
88
|
-
this.host.requestUpdate();
|
89
|
-
this.onChange("", false);
|
90
|
-
this.handleDismiss = null;
|
91
|
-
this.handleSubmit = null;
|
92
|
-
};
|
93
|
-
const rule = new AutocompleteRule({
|
94
|
-
regex,
|
95
|
-
onEnter: handleEnter,
|
96
|
-
onLeave: handleLeave
|
97
|
-
});
|
98
|
-
const extension = defineAutocomplete(rule);
|
99
|
-
this.cleanup = editor.use(extension);
|
100
|
-
}
|
101
|
-
hostDisconnected() {
|
102
|
-
var _a;
|
103
|
-
(_a = this.cleanup) == null ? void 0 : _a.call(this);
|
104
|
-
this.cleanup = null;
|
105
|
-
}
|
106
|
-
};
|
107
|
-
|
108
|
-
// src/components/autocomplete-popover/index.ts
|
109
|
-
var propNames = ["editor", "regex", "positioning"];
|
110
|
-
var AutocompletePopover = class extends Popover {
|
111
|
-
constructor() {
|
112
|
-
super(...arguments);
|
113
|
-
/**
|
114
|
-
* @hidden
|
115
|
-
*/
|
116
|
-
this.controller = new AutocompletePopoverController(
|
117
|
-
this,
|
118
|
-
this.updateContext.bind(this)
|
119
|
-
);
|
120
|
-
this.positioning = {
|
121
|
-
strategy: "fixed",
|
122
|
-
placement: "bottom-start",
|
123
|
-
fitViewport: true,
|
124
|
-
flip: false,
|
125
|
-
inline: true
|
126
|
-
};
|
127
|
-
this.context = new ContextProvider(this, {
|
128
|
-
context: autocompletePopoverContext,
|
129
|
-
initialValue: {
|
130
|
-
active: false,
|
131
|
-
query: "",
|
132
|
-
handleDismiss: () => {
|
133
|
-
var _a, _b;
|
134
|
-
return (_b = (_a = this.controller).handleDismiss) == null ? void 0 : _b.call(_a);
|
135
|
-
},
|
136
|
-
handleSubmit: () => {
|
137
|
-
var _a, _b;
|
138
|
-
return (_b = (_a = this.controller).handleSubmit) == null ? void 0 : _b.call(_a);
|
139
|
-
}
|
140
|
-
}
|
141
|
-
});
|
142
|
-
}
|
143
|
-
get list() {
|
144
|
-
const element = this.querySelector("prosekit-autocomplete-list");
|
145
|
-
return isAutocompleteList(element) ? element : null;
|
146
|
-
}
|
147
|
-
updateContext(query, active) {
|
148
|
-
const context = this.context.value;
|
149
|
-
if (context.query !== query || context.active !== active) {
|
150
|
-
this.context.setValue({ ...context, query, active });
|
151
|
-
} else if (!active) {
|
152
|
-
return;
|
153
|
-
}
|
154
|
-
this.requestUpdate();
|
155
|
-
requestAnimationFrame(() => {
|
156
|
-
var _a;
|
157
|
-
(_a = this.list) == null ? void 0 : _a.selectFirstItem();
|
158
|
-
});
|
159
|
-
}
|
160
|
-
/**
|
161
|
-
* @hidden
|
162
|
-
*/
|
163
|
-
willUpdate(changedProperties) {
|
164
|
-
var _a, _b;
|
165
|
-
super.willUpdate(changedProperties);
|
166
|
-
if (this.editor) {
|
167
|
-
this.controller.setEditor(this.editor);
|
168
|
-
}
|
169
|
-
if (this.regex) {
|
170
|
-
this.controller.setRegex(this.regex);
|
171
|
-
}
|
172
|
-
this.open = !!((_a = this.controller) == null ? void 0 : _a.reference);
|
173
|
-
this.reference = (_b = this.controller.reference) != null ? _b : void 0;
|
174
|
-
}
|
175
|
-
/**
|
176
|
-
* @hidden
|
177
|
-
*/
|
178
|
-
hide() {
|
179
|
-
var _a;
|
180
|
-
super.hide();
|
181
|
-
if ((_a = this.controller) == null ? void 0 : _a.reference) {
|
182
|
-
this.controller.reference = null;
|
183
|
-
this.reference = void 0;
|
184
|
-
}
|
185
|
-
}
|
186
|
-
};
|
187
|
-
/**
|
188
|
-
* @hidden
|
189
|
-
*/
|
190
|
-
AutocompletePopover.properties = {
|
191
|
-
...Popover.properties,
|
192
|
-
editor: { type: Object, reflect: false, attribute: false },
|
193
|
-
regex: { attribute: false },
|
194
|
-
positioning: { type: Object, reflect: false, attribute: false }
|
195
|
-
};
|
196
|
-
defineCustomElement("prosekit-autocomplete-popover", AutocompletePopover);
|
197
|
-
export {
|
198
|
-
AutocompletePopover,
|
199
|
-
propNames
|
200
|
-
};
|
@@ -1,170 +0,0 @@
|
|
1
|
-
import {
|
2
|
-
blockPopoverContext
|
3
|
-
} from "./chunk-S72UTR5M.js";
|
4
|
-
import {
|
5
|
-
Popover
|
6
|
-
} from "./chunk-FKSZFUL3.js";
|
7
|
-
import "./chunk-UIHDPY7W.js";
|
8
|
-
import {
|
9
|
-
defineCustomElement
|
10
|
-
} from "./chunk-LCDA7GFP.js";
|
11
|
-
|
12
|
-
// src/components/block-popover/index.ts
|
13
|
-
import { ContextProvider } from "@lit/context";
|
14
|
-
|
15
|
-
// src/components/block-popover/pointer-move.ts
|
16
|
-
import { defineDOMEventHandler, union } from "@prosekit/core";
|
17
|
-
|
18
|
-
// src/utils/throttle.ts
|
19
|
-
function throttle(callback, wait) {
|
20
|
-
let lastTime = 0;
|
21
|
-
return (...args) => {
|
22
|
-
const now = Date.now();
|
23
|
-
if (now - lastTime >= wait) {
|
24
|
-
callback(...args);
|
25
|
-
lastTime = now;
|
26
|
-
}
|
27
|
-
};
|
28
|
-
}
|
29
|
-
|
30
|
-
// src/components/block-popover/pointer-move.ts
|
31
|
-
function defineElementHoverHandler(handler) {
|
32
|
-
const handlePointerEvent = (view, event) => {
|
33
|
-
var _a;
|
34
|
-
const rect = view.dom.getBoundingClientRect();
|
35
|
-
const pos = (_a = view.posAtCoords({
|
36
|
-
top: event.clientY,
|
37
|
-
// Use the center of the editor
|
38
|
-
left: rect.left + rect.width / 2
|
39
|
-
})) == null ? void 0 : _a.inside;
|
40
|
-
if (pos == null || pos < 0) {
|
41
|
-
handler(null, null, null, null);
|
42
|
-
return;
|
43
|
-
}
|
44
|
-
const $pos = view.state.doc.resolve(pos);
|
45
|
-
const node = view.state.doc.nodeAt(pos);
|
46
|
-
const element = view.nodeDOM(pos);
|
47
|
-
if ($pos.depth >= 1 && $pos.index($pos.depth) === 0) {
|
48
|
-
const ancestorPos = $pos.before($pos.depth);
|
49
|
-
const node2 = view.state.doc.nodeAt(ancestorPos);
|
50
|
-
const element2 = view.nodeDOM(ancestorPos);
|
51
|
-
if (!element2) {
|
52
|
-
handler(null, null, null, null);
|
53
|
-
return;
|
54
|
-
}
|
55
|
-
const reference = {
|
56
|
-
contextElement: element2,
|
57
|
-
// Get the bounding client rect of the parent node, including its
|
58
|
-
// margins.
|
59
|
-
getBoundingClientRect: () => {
|
60
|
-
const rect2 = element2.getBoundingClientRect();
|
61
|
-
const style = window.getComputedStyle(element2);
|
62
|
-
const marginTop = Number.parseInt(style.marginTop, 10) || 0;
|
63
|
-
const marginRight = Number.parseInt(style.marginRight, 10) || 0;
|
64
|
-
const marginBottom = Number.parseInt(style.marginBottom, 10) || 0;
|
65
|
-
const marginLeft = Number.parseInt(style.marginLeft, 10) || 0;
|
66
|
-
return {
|
67
|
-
top: rect2.top - marginTop,
|
68
|
-
right: rect2.right + marginRight,
|
69
|
-
bottom: rect2.bottom + marginBottom,
|
70
|
-
left: rect2.left - marginLeft,
|
71
|
-
width: rect2.width + marginLeft + marginRight,
|
72
|
-
height: rect2.height + marginTop + marginBottom,
|
73
|
-
x: rect2.x - marginLeft,
|
74
|
-
y: rect2.y - marginTop
|
75
|
-
};
|
76
|
-
}
|
77
|
-
};
|
78
|
-
handler(reference, element2, node2, ancestorPos);
|
79
|
-
return;
|
80
|
-
}
|
81
|
-
handler(element, element, node, pos);
|
82
|
-
};
|
83
|
-
return union([
|
84
|
-
defineDOMEventHandler("pointermove", throttle(handlePointerEvent, 200)),
|
85
|
-
defineDOMEventHandler("pointerout", handlePointerEvent),
|
86
|
-
defineDOMEventHandler("keypress", () => handler(null, null, null, null))
|
87
|
-
]);
|
88
|
-
}
|
89
|
-
|
90
|
-
// src/components/block-popover/index.ts
|
91
|
-
var propNames = ["editor"];
|
92
|
-
var BlockPopover = class extends Popover {
|
93
|
-
constructor() {
|
94
|
-
super();
|
95
|
-
this.positioning = {
|
96
|
-
strategy: "absolute",
|
97
|
-
placement: "left-start",
|
98
|
-
fitViewport: true,
|
99
|
-
flip: false,
|
100
|
-
inline: false,
|
101
|
-
autoUpdate: true,
|
102
|
-
shift: true,
|
103
|
-
overlap: false,
|
104
|
-
hide: true,
|
105
|
-
offset: 4
|
106
|
-
};
|
107
|
-
// We don't want the popover to overflow the editor area so we set `elevated` to false.
|
108
|
-
this.elevated = false;
|
109
|
-
this.context = new ContextProvider(this, {
|
110
|
-
context: blockPopoverContext,
|
111
|
-
initialValue: {
|
112
|
-
pos: null,
|
113
|
-
node: null,
|
114
|
-
element: null
|
115
|
-
}
|
116
|
-
});
|
117
|
-
useBlockPopover(this, (reference, element, node, pos) => {
|
118
|
-
this.reference = reference != null ? reference : void 0;
|
119
|
-
this.context.setValue({ pos, element, node });
|
120
|
-
});
|
121
|
-
}
|
122
|
-
willUpdate(changedProperties) {
|
123
|
-
super.willUpdate(changedProperties);
|
124
|
-
this.open = !!(this == null ? void 0 : this.reference);
|
125
|
-
}
|
126
|
-
};
|
127
|
-
/**
|
128
|
-
* @hidden
|
129
|
-
*/
|
130
|
-
BlockPopover.properties = {
|
131
|
-
...Popover.properties,
|
132
|
-
editor: { type: Object, reflect: false, attribute: false }
|
133
|
-
};
|
134
|
-
function useBlockPopover(host, handler) {
|
135
|
-
let dispose;
|
136
|
-
let editor;
|
137
|
-
let prevElement = null;
|
138
|
-
let prevPos = null;
|
139
|
-
const extension = defineElementHoverHandler(
|
140
|
-
(reference, element, node, pos) => {
|
141
|
-
if (prevElement === element && prevPos === pos) {
|
142
|
-
return;
|
143
|
-
}
|
144
|
-
prevElement = element;
|
145
|
-
prevPos = pos;
|
146
|
-
handler(reference, element, node, pos);
|
147
|
-
}
|
148
|
-
);
|
149
|
-
host.addController({
|
150
|
-
hostUpdated: () => {
|
151
|
-
if (editor !== host.editor) {
|
152
|
-
editor = host.editor;
|
153
|
-
dispose == null ? void 0 : dispose();
|
154
|
-
dispose = void 0;
|
155
|
-
if (editor) {
|
156
|
-
dispose = editor.use(extension);
|
157
|
-
}
|
158
|
-
}
|
159
|
-
},
|
160
|
-
hostDisconnected: () => {
|
161
|
-
dispose == null ? void 0 : dispose();
|
162
|
-
dispose = void 0;
|
163
|
-
}
|
164
|
-
});
|
165
|
-
}
|
166
|
-
defineCustomElement("prosekit-block-popover", BlockPopover);
|
167
|
-
export {
|
168
|
-
BlockPopover,
|
169
|
-
propNames
|
170
|
-
};
|
@@ -1,94 +0,0 @@
|
|
1
|
-
import {
|
2
|
-
comboBoxContext
|
3
|
-
} from "./chunk-C4MW43I4.js";
|
4
|
-
import {
|
5
|
-
LightElement
|
6
|
-
} from "./chunk-UIHDPY7W.js";
|
7
|
-
import {
|
8
|
-
defineCustomElement
|
9
|
-
} from "./chunk-LCDA7GFP.js";
|
10
|
-
|
11
|
-
// src/components/combo-box-input/index.ts
|
12
|
-
import { ContextConsumer } from "@lit/context";
|
13
|
-
import { html } from "lit";
|
14
|
-
var propNames = ["placeholder"];
|
15
|
-
var ComboBoxInput = class extends LightElement {
|
16
|
-
constructor() {
|
17
|
-
super(...arguments);
|
18
|
-
this.placeholder = "";
|
19
|
-
this.comboBoxContext = new ContextConsumer(this, {
|
20
|
-
context: comboBoxContext,
|
21
|
-
subscribe: true
|
22
|
-
});
|
23
|
-
this.visible = false;
|
24
|
-
}
|
25
|
-
handleKeydown(event) {
|
26
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
27
|
-
switch (event.code) {
|
28
|
-
case "ArrowUp":
|
29
|
-
(_b = (_a = this.comboBoxContext.value) == null ? void 0 : _a.listManager) == null ? void 0 : _b.handleArrowUp();
|
30
|
-
event.preventDefault();
|
31
|
-
return;
|
32
|
-
case "ArrowDown":
|
33
|
-
(_d = (_c = this.comboBoxContext.value) == null ? void 0 : _c.listManager) == null ? void 0 : _d.handleArrowDown();
|
34
|
-
event.preventDefault();
|
35
|
-
return;
|
36
|
-
case "Escape":
|
37
|
-
(_f = (_e = this.comboBoxContext.value) == null ? void 0 : _e.listManager) == null ? void 0 : _f.handleEscape();
|
38
|
-
event.preventDefault();
|
39
|
-
return;
|
40
|
-
case "Enter":
|
41
|
-
(_h = (_g = this.comboBoxContext.value) == null ? void 0 : _g.listManager) == null ? void 0 : _h.handleEnter();
|
42
|
-
event.preventDefault();
|
43
|
-
return;
|
44
|
-
}
|
45
|
-
}
|
46
|
-
handleInput(event) {
|
47
|
-
var _a, _b, _c;
|
48
|
-
const value = (_b = (_a = event == null ? void 0 : event.target) == null ? void 0 : _a.value) != null ? _b : "";
|
49
|
-
(_c = this.comboBoxContext.value) == null ? void 0 : _c.setInputValue(value);
|
50
|
-
}
|
51
|
-
/**
|
52
|
-
* @hidden
|
53
|
-
*/
|
54
|
-
firstUpdated() {
|
55
|
-
const resizeObserver = new ResizeObserver((entries) => {
|
56
|
-
const visible = entries.some(
|
57
|
-
(entry) => entry.contentRect.width > 0 && entry.contentRect.width > 0
|
58
|
-
);
|
59
|
-
if (this.visible !== visible && visible) {
|
60
|
-
setTimeout(() => {
|
61
|
-
var _a;
|
62
|
-
return (_a = this.querySelector("input")) == null ? void 0 : _a.focus();
|
63
|
-
}, 0);
|
64
|
-
}
|
65
|
-
this.visible = visible;
|
66
|
-
});
|
67
|
-
resizeObserver.observe(this);
|
68
|
-
}
|
69
|
-
/**
|
70
|
-
* @hidden
|
71
|
-
*/
|
72
|
-
render() {
|
73
|
-
var _a, _b;
|
74
|
-
return html`
|
75
|
-
<input
|
76
|
-
placeholder=${this.placeholder}
|
77
|
-
@keydown=${(event) => this.handleKeydown(event)}
|
78
|
-
@input=${(event) => this.handleInput(event)}
|
79
|
-
.value=${(_b = (_a = this.comboBoxContext.value) == null ? void 0 : _a.inputValue) != null ? _b : ""}
|
80
|
-
></input>
|
81
|
-
`;
|
82
|
-
}
|
83
|
-
};
|
84
|
-
/**
|
85
|
-
* @hidden
|
86
|
-
*/
|
87
|
-
ComboBoxInput.properties = {
|
88
|
-
placeholder: { attribute: true }
|
89
|
-
};
|
90
|
-
defineCustomElement("prosekit-combo-box-input", ComboBoxInput);
|
91
|
-
export {
|
92
|
-
ComboBoxInput,
|
93
|
-
propNames
|
94
|
-
};
|