prosekit 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 +13 -0
- package/dist/basic/style.css +133 -0
- package/dist/chunk-23S3SZFA.js +46 -0
- package/dist/chunk-2MVHS73Q.js +709 -0
- package/dist/chunk-4GDRVRDP.js +0 -0
- package/dist/chunk-5PFF57NB.js +1546 -0
- package/dist/chunk-6A2XHVFY.js +46 -0
- package/dist/chunk-7OYIOTDD.js +16472 -0
- package/dist/chunk-ARJTWYPA.js +1321 -0
- package/dist/chunk-CDGN4JUS.js +1546 -0
- package/dist/chunk-CG5B6PMC.js +973 -0
- package/dist/chunk-DDN3TFRH.js +185 -0
- package/dist/chunk-EQV3CWHZ.js +2213 -0
- package/dist/chunk-ERNIDFFW.js +1711 -0
- package/dist/chunk-FAVXZAF7.js +3279 -0
- package/dist/chunk-HSPTUO6P.js +53 -0
- package/dist/chunk-JMNJUDT7.js +165 -0
- package/dist/chunk-LXCCO2LO.js +52 -0
- package/dist/chunk-MIPON3OH.js +922 -0
- package/dist/chunk-NAWSCY5F.js +166 -0
- package/dist/chunk-S64NFSV2.js +236 -0
- package/dist/chunk-S65R2BUY.js +15 -0
- package/dist/chunk-T2V5UU6H.js +204 -0
- package/dist/chunk-TWIMWRRZ.js +57 -0
- package/dist/chunk-US2P3K6I.js +185 -0
- package/dist/chunk-UTNVEPBA.js +950 -0
- package/dist/chunk-UWHQRU5N.js +4883 -0
- package/dist/chunk-VIKPJJET.js +662 -0
- package/dist/chunk-WAMZOD5I.js +67 -0
- package/dist/chunk-YUY5I2TY.js +236 -0
- package/dist/core/style.css +54 -0
- package/dist/extension-list/style.css +78 -0
- package/dist/pm/view/style/prosemirror.css +52 -0
- package/dist/prosekit-basic.js +2 -0
- package/dist/prosekit-core.js +2 -0
- package/dist/prosekit-extension-blockquote.js +2 -0
- package/dist/prosekit-extension-bold.js +2 -0
- package/dist/prosekit-extension-code-block.js +2 -0
- package/dist/prosekit-extension-code.js +2 -0
- package/dist/prosekit-extension-heading.js +2 -0
- package/dist/prosekit-extension-horizontal-rule.js +2 -0
- package/dist/prosekit-extension-italic.js +2 -0
- package/dist/prosekit-extension-list.js +2 -0
- package/dist/prosekit-extension-suggestion.js +2 -0
- package/dist/prosekit-lit-elements-menu-item.js +2 -0
- package/dist/prosekit-lit-elements-menu.js +2 -0
- package/dist/prosekit-lit-elements-popover.js +2 -0
- package/dist/prosekit-lit.js +2 -0
- package/dist/prosekit-pm-commands.js +2 -0
- package/dist/prosekit-pm-inputrules.js +2 -0
- package/dist/prosekit-pm-keymap.js +2 -0
- package/dist/prosekit-pm-model.js +2 -0
- package/dist/prosekit-pm-state.js +2 -0
- package/dist/prosekit-pm-transform.js +2 -0
- package/dist/prosekit-pm-view.js +2 -0
- package/dist/prosekit-pm.js +2 -0
- package/dist/prosekit-react-components-menu-item.js +2 -0
- package/dist/prosekit-react-components-menu.js +2 -0
- package/dist/prosekit-react-components-popover-suggestion.js +2 -0
- package/dist/prosekit-react-components-popover.js +2 -0
- package/dist/prosekit-react.js +2 -0
- package/dist/prosekit-vue-components-menu-item.js +2 -0
- package/dist/prosekit-vue-components-menu.js +2 -0
- package/dist/prosekit-vue-components-popover-suggestion.js +2 -0
- package/dist/prosekit-vue-components-popover.js +2 -0
- package/dist/prosekit-vue.js +2 -0
- package/dist/prosekit.js +0 -0
- package/package.json +262 -0
- package/src/index.ts +1 -0
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import {
|
|
2
|
+
b,
|
|
3
|
+
blockComponentStyles,
|
|
4
|
+
e,
|
|
5
|
+
n,
|
|
6
|
+
r,
|
|
7
|
+
s,
|
|
8
|
+
t
|
|
9
|
+
} from "./chunk-CG5B6PMC.js";
|
|
10
|
+
import {
|
|
11
|
+
ProseKitError,
|
|
12
|
+
addKeymap
|
|
13
|
+
} from "./chunk-2MVHS73Q.js";
|
|
14
|
+
import {
|
|
15
|
+
__decorateClass
|
|
16
|
+
} from "./chunk-S65R2BUY.js";
|
|
17
|
+
|
|
18
|
+
// ../lit/src/utils/is-menu-item.ts
|
|
19
|
+
function isMenuItem(element) {
|
|
20
|
+
var _a, _b;
|
|
21
|
+
return ((_a = element == null ? void 0 : element.tagName) == null ? void 0 : _a.toLowerCase()) === "prosekit-menu-item" || ["menuitem", "menuitemcheckbox", "menuitemradio"].includes(
|
|
22
|
+
(_b = element == null ? void 0 : element.getAttribute("role")) != null ? _b : ""
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// ../lit/src/utils/visibility.ts
|
|
27
|
+
function isVisibleElement(element) {
|
|
28
|
+
return !element.hidden;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// ../lit/src/elements/menu.ts
|
|
32
|
+
var Menu = class extends s {
|
|
33
|
+
/** @hidden */
|
|
34
|
+
constructor() {
|
|
35
|
+
super();
|
|
36
|
+
/** @hidden */
|
|
37
|
+
this.cleanup = [];
|
|
38
|
+
}
|
|
39
|
+
/** @hidden */
|
|
40
|
+
firstUpdated() {
|
|
41
|
+
if (!this.editor) {
|
|
42
|
+
throw new ProseKitError("Property editor is required");
|
|
43
|
+
}
|
|
44
|
+
const extension = addKeymap({
|
|
45
|
+
ArrowUp: () => this.handleArrowUp(),
|
|
46
|
+
ArrowDown: () => this.handleArrowDown(),
|
|
47
|
+
Escape: () => this.handleEscape(),
|
|
48
|
+
Enter: () => this.handleEnter()
|
|
49
|
+
});
|
|
50
|
+
this.cleanup.push(this.editor.use(extension));
|
|
51
|
+
}
|
|
52
|
+
updated(_changedProperties) {
|
|
53
|
+
this.ensureFocusedItem();
|
|
54
|
+
}
|
|
55
|
+
/** @hidden */
|
|
56
|
+
disconnectedCallback() {
|
|
57
|
+
super.disconnectedCallback();
|
|
58
|
+
this.cleanup.forEach((fn) => fn());
|
|
59
|
+
}
|
|
60
|
+
ensureFocusedItem() {
|
|
61
|
+
const items = this.queryVisibleMenuItems();
|
|
62
|
+
if (this.focusedItem && items.includes(this.focusedItem)) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
this.focusItem(items[0]);
|
|
66
|
+
}
|
|
67
|
+
/** @hidden */
|
|
68
|
+
handleArrowUp() {
|
|
69
|
+
const items = this.queryVisibleMenuItems();
|
|
70
|
+
let prevIndex = this.focusedItem ? items.indexOf(this.focusedItem) : 0;
|
|
71
|
+
if (prevIndex === -1) {
|
|
72
|
+
prevIndex = 0;
|
|
73
|
+
}
|
|
74
|
+
const nextIndex = (prevIndex + items.length - 1) % items.length;
|
|
75
|
+
this.focusItem(items[nextIndex]);
|
|
76
|
+
return true;
|
|
77
|
+
}
|
|
78
|
+
/** @hidden */
|
|
79
|
+
handleArrowDown() {
|
|
80
|
+
const items = this.queryVisibleMenuItems();
|
|
81
|
+
const prevIndex = this.focusedItem ? items.indexOf(this.focusedItem) : -1;
|
|
82
|
+
const nextIndex = (prevIndex + items.length + 1) % items.length;
|
|
83
|
+
this.focusItem(items[nextIndex]);
|
|
84
|
+
return true;
|
|
85
|
+
}
|
|
86
|
+
/** @hidden */
|
|
87
|
+
handleEscape() {
|
|
88
|
+
const event = new CustomEvent("menu-dismiss", {
|
|
89
|
+
bubbles: true,
|
|
90
|
+
composed: false
|
|
91
|
+
});
|
|
92
|
+
this.dispatchEvent(event);
|
|
93
|
+
this.blurItem();
|
|
94
|
+
return true;
|
|
95
|
+
}
|
|
96
|
+
/** @hidden */
|
|
97
|
+
handleMouseOver(event) {
|
|
98
|
+
const target = event.target;
|
|
99
|
+
if (isMenuItem(target) && isVisibleElement(target)) {
|
|
100
|
+
this.focusItem(target);
|
|
101
|
+
}
|
|
102
|
+
return true;
|
|
103
|
+
}
|
|
104
|
+
/** @hidden */
|
|
105
|
+
handleEnter() {
|
|
106
|
+
if (this.focusedItem) {
|
|
107
|
+
this.handleSelect(this.focusedItem);
|
|
108
|
+
return true;
|
|
109
|
+
}
|
|
110
|
+
return false;
|
|
111
|
+
}
|
|
112
|
+
/** @hidden */
|
|
113
|
+
handleClick(event) {
|
|
114
|
+
const target = event.target;
|
|
115
|
+
if (isMenuItem(target) && isVisibleElement(target)) {
|
|
116
|
+
this.handleSelect(target);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
/** @hidden */
|
|
120
|
+
handleSelect(menuItem) {
|
|
121
|
+
var _a;
|
|
122
|
+
(_a = menuItem.onSelect) == null ? void 0 : _a.call(menuItem);
|
|
123
|
+
const event = new CustomEvent("menu-select", {
|
|
124
|
+
bubbles: true,
|
|
125
|
+
composed: false
|
|
126
|
+
});
|
|
127
|
+
this.dispatchEvent(event);
|
|
128
|
+
this.blurItem();
|
|
129
|
+
}
|
|
130
|
+
/** @hidden */
|
|
131
|
+
focusItem(item) {
|
|
132
|
+
this.blurItem();
|
|
133
|
+
if (!item) {
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
item.focused = true;
|
|
137
|
+
this.focusedItem = item;
|
|
138
|
+
}
|
|
139
|
+
/** @hidden */
|
|
140
|
+
blurItem() {
|
|
141
|
+
if (this.focusedItem) {
|
|
142
|
+
this.focusedItem.focused = false;
|
|
143
|
+
this.focusedItem = void 0;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
/** @hidden */
|
|
147
|
+
queryAllMenuItems() {
|
|
148
|
+
var _a, _b, _c;
|
|
149
|
+
return (_c = (_b = (_a = this.defaultSlot) == null ? void 0 : _a.assignedElements({ flatten: true })) == null ? void 0 : _b.filter(isMenuItem)) != null ? _c : [];
|
|
150
|
+
}
|
|
151
|
+
/** @hidden */
|
|
152
|
+
queryVisibleMenuItems() {
|
|
153
|
+
return this.queryAllMenuItems().filter(isVisibleElement);
|
|
154
|
+
}
|
|
155
|
+
/** @hidden */
|
|
156
|
+
render() {
|
|
157
|
+
return b`
|
|
158
|
+
<div
|
|
159
|
+
role="menu"
|
|
160
|
+
@mouseover=${this.handleMouseOver.bind(this)}
|
|
161
|
+
@click=${this.handleClick.bind(this)}
|
|
162
|
+
>
|
|
163
|
+
<slot></slot>
|
|
164
|
+
</div>
|
|
165
|
+
`;
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
/** @hidden */
|
|
169
|
+
Menu.styles = blockComponentStyles;
|
|
170
|
+
__decorateClass([
|
|
171
|
+
n({ attribute: false })
|
|
172
|
+
], Menu.prototype, "editor", 2);
|
|
173
|
+
__decorateClass([
|
|
174
|
+
t()
|
|
175
|
+
], Menu.prototype, "focusedItem", 2);
|
|
176
|
+
__decorateClass([
|
|
177
|
+
r("slot")
|
|
178
|
+
], Menu.prototype, "defaultSlot", 2);
|
|
179
|
+
Menu = __decorateClass([
|
|
180
|
+
e("prosekit-menu")
|
|
181
|
+
], Menu);
|
|
182
|
+
|
|
183
|
+
export {
|
|
184
|
+
Menu
|
|
185
|
+
};
|