@prosekit/lit 0.2.7 → 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 +27 -1088
- 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 -190
- package/dist/prosekit-lit-popover.d.ts +3 -6
- package/dist/prosekit-lit-popover.js +7 -8
- package/dist/prosekit-lit-resizable.d.ts +2 -3
- package/dist/prosekit-lit-resizable.js +5 -108
- package/dist/prosekit-lit-tooltip.d.ts +3 -0
- package/dist/prosekit-lit-tooltip.js +9 -0
- package/package.json +24 -95
- package/dist/chunk-3AZDRLDR.js +0 -39
- package/dist/chunk-3TPE2GKD.js +0 -51
- package/dist/chunk-5CI65R73.js +0 -9
- package/dist/chunk-C4MW43I4.js +0 -9
- package/dist/chunk-CPC45JQ7.js +0 -202
- package/dist/chunk-I5EMQRE4.js +0 -60
- package/dist/chunk-MZAHIYA5.js +0 -114
- package/dist/chunk-S72UTR5M.js +0 -9
- package/dist/chunk-WEUGKLVB.js +0 -9
- package/dist/chunk-XHBZNZ2L.js +0 -369
- package/dist/prosekit-lit-autocomplete-empty.d.ts +0 -3
- package/dist/prosekit-lit-autocomplete-empty.js +0 -44
- package/dist/prosekit-lit-autocomplete-item.d.ts +0 -3
- package/dist/prosekit-lit-autocomplete-item.js +0 -10
- package/dist/prosekit-lit-autocomplete-list.d.ts +0 -3
- package/dist/prosekit-lit-autocomplete-list.js +0 -12
- package/dist/prosekit-lit-autocomplete-popover.d.ts +0 -4
- package/dist/prosekit-lit-autocomplete-popover.js +0 -199
- package/dist/prosekit-lit-block-popover.d.ts +0 -3
- package/dist/prosekit-lit-block-popover.js +0 -169
- package/dist/prosekit-lit-combo-box-input.d.ts +0 -3
- package/dist/prosekit-lit-combo-box-input.js +0 -92
- package/dist/prosekit-lit-combo-box-item.d.ts +0 -3
- package/dist/prosekit-lit-combo-box-item.js +0 -10
- package/dist/prosekit-lit-combo-box-list.d.ts +0 -3
- package/dist/prosekit-lit-combo-box-list.js +0 -44
- package/dist/prosekit-lit-combo-box.d.ts +0 -3
- package/dist/prosekit-lit-combo-box.js +0 -130
- package/dist/prosekit-lit-drag-handle.d.ts +0 -3
- package/dist/prosekit-lit-drag-handle.js +0 -94
- package/dist/prosekit-lit-resizable-handle.d.ts +0 -3
- package/dist/prosekit-lit-resizable-handle.js +0 -159
@@ -1,169 +0,0 @@
|
|
1
|
-
import {
|
2
|
-
blockPopoverContext
|
3
|
-
} from "./chunk-S72UTR5M.js";
|
4
|
-
import {
|
5
|
-
Popover
|
6
|
-
} from "./chunk-XHBZNZ2L.js";
|
7
|
-
import {
|
8
|
-
defineCustomElement
|
9
|
-
} from "./chunk-3AZDRLDR.js";
|
10
|
-
|
11
|
-
// src/components/block-popover/index.ts
|
12
|
-
import { ContextProvider } from "@lit/context";
|
13
|
-
|
14
|
-
// src/components/block-popover/pointer-move.ts
|
15
|
-
import { defineDOMEventHandler, union } from "@prosekit/core";
|
16
|
-
|
17
|
-
// src/utils/throttle.ts
|
18
|
-
function throttle(callback, wait) {
|
19
|
-
let lastTime = 0;
|
20
|
-
return (...args) => {
|
21
|
-
const now = Date.now();
|
22
|
-
if (now - lastTime >= wait) {
|
23
|
-
callback(...args);
|
24
|
-
lastTime = now;
|
25
|
-
}
|
26
|
-
};
|
27
|
-
}
|
28
|
-
|
29
|
-
// src/components/block-popover/pointer-move.ts
|
30
|
-
function defineElementHoverHandler(handler) {
|
31
|
-
const handlePointerEvent = (view, event) => {
|
32
|
-
var _a;
|
33
|
-
const rect = view.dom.getBoundingClientRect();
|
34
|
-
const pos = (_a = view.posAtCoords({
|
35
|
-
top: event.clientY,
|
36
|
-
// Use the center of the editor
|
37
|
-
left: rect.left + rect.width / 2
|
38
|
-
})) == null ? void 0 : _a.inside;
|
39
|
-
if (pos == null || pos < 0) {
|
40
|
-
handler(null, null, null, null);
|
41
|
-
return;
|
42
|
-
}
|
43
|
-
const $pos = view.state.doc.resolve(pos);
|
44
|
-
const node = view.state.doc.nodeAt(pos);
|
45
|
-
const element = view.nodeDOM(pos);
|
46
|
-
if ($pos.depth >= 1 && $pos.index($pos.depth) === 0) {
|
47
|
-
const ancestorPos = $pos.before($pos.depth);
|
48
|
-
const node2 = view.state.doc.nodeAt(ancestorPos);
|
49
|
-
const element2 = view.nodeDOM(ancestorPos);
|
50
|
-
if (!element2) {
|
51
|
-
handler(null, null, null, null);
|
52
|
-
return;
|
53
|
-
}
|
54
|
-
const reference = {
|
55
|
-
contextElement: element2,
|
56
|
-
// Get the bounding client rect of the parent node, including its
|
57
|
-
// margins.
|
58
|
-
getBoundingClientRect: () => {
|
59
|
-
const rect2 = element2.getBoundingClientRect();
|
60
|
-
const style = window.getComputedStyle(element2);
|
61
|
-
const marginTop = Number.parseInt(style.marginTop, 10) || 0;
|
62
|
-
const marginRight = Number.parseInt(style.marginRight, 10) || 0;
|
63
|
-
const marginBottom = Number.parseInt(style.marginBottom, 10) || 0;
|
64
|
-
const marginLeft = Number.parseInt(style.marginLeft, 10) || 0;
|
65
|
-
return {
|
66
|
-
top: rect2.top - marginTop,
|
67
|
-
right: rect2.right + marginRight,
|
68
|
-
bottom: rect2.bottom + marginBottom,
|
69
|
-
left: rect2.left - marginLeft,
|
70
|
-
width: rect2.width + marginLeft + marginRight,
|
71
|
-
height: rect2.height + marginTop + marginBottom,
|
72
|
-
x: rect2.x - marginLeft,
|
73
|
-
y: rect2.y - marginTop
|
74
|
-
};
|
75
|
-
}
|
76
|
-
};
|
77
|
-
handler(reference, element2, node2, ancestorPos);
|
78
|
-
return;
|
79
|
-
}
|
80
|
-
handler(element, element, node, pos);
|
81
|
-
};
|
82
|
-
return union([
|
83
|
-
defineDOMEventHandler("pointermove", throttle(handlePointerEvent, 200)),
|
84
|
-
defineDOMEventHandler("pointerout", handlePointerEvent),
|
85
|
-
defineDOMEventHandler("keypress", () => handler(null, null, null, null))
|
86
|
-
]);
|
87
|
-
}
|
88
|
-
|
89
|
-
// src/components/block-popover/index.ts
|
90
|
-
var propNames = ["editor"];
|
91
|
-
var BlockPopover = class extends Popover {
|
92
|
-
constructor() {
|
93
|
-
super();
|
94
|
-
this.positioning = {
|
95
|
-
strategy: "absolute",
|
96
|
-
placement: "left-start",
|
97
|
-
fitViewport: true,
|
98
|
-
flip: false,
|
99
|
-
inline: false,
|
100
|
-
autoUpdate: true,
|
101
|
-
shift: true,
|
102
|
-
overlap: false,
|
103
|
-
hide: true,
|
104
|
-
offset: 4
|
105
|
-
};
|
106
|
-
// We don't want the popover to overflow the editor area so we set `elevated` to false.
|
107
|
-
this.elevated = false;
|
108
|
-
this.context = new ContextProvider(this, {
|
109
|
-
context: blockPopoverContext,
|
110
|
-
initialValue: {
|
111
|
-
pos: null,
|
112
|
-
node: null,
|
113
|
-
element: null
|
114
|
-
}
|
115
|
-
});
|
116
|
-
useBlockPopover(this, (reference, element, node, pos) => {
|
117
|
-
this.reference = reference != null ? reference : void 0;
|
118
|
-
this.context.setValue({ pos, element, node });
|
119
|
-
});
|
120
|
-
}
|
121
|
-
willUpdate(changedProperties) {
|
122
|
-
super.willUpdate(changedProperties);
|
123
|
-
this.open = !!(this == null ? void 0 : this.reference);
|
124
|
-
}
|
125
|
-
};
|
126
|
-
/**
|
127
|
-
* @hidden
|
128
|
-
*/
|
129
|
-
BlockPopover.properties = {
|
130
|
-
...Popover.properties,
|
131
|
-
editor: { type: Object, reflect: false, attribute: false }
|
132
|
-
};
|
133
|
-
function useBlockPopover(host, handler) {
|
134
|
-
let dispose;
|
135
|
-
let editor;
|
136
|
-
let prevElement = null;
|
137
|
-
let prevPos = null;
|
138
|
-
const extension = defineElementHoverHandler(
|
139
|
-
(reference, element, node, pos) => {
|
140
|
-
if (prevElement === element && prevPos === pos) {
|
141
|
-
return;
|
142
|
-
}
|
143
|
-
prevElement = element;
|
144
|
-
prevPos = pos;
|
145
|
-
handler(reference, element, node, pos);
|
146
|
-
}
|
147
|
-
);
|
148
|
-
host.addController({
|
149
|
-
hostUpdated: () => {
|
150
|
-
if (editor !== host.editor) {
|
151
|
-
editor = host.editor;
|
152
|
-
dispose == null ? void 0 : dispose();
|
153
|
-
dispose = void 0;
|
154
|
-
if (editor) {
|
155
|
-
dispose = editor.use(extension);
|
156
|
-
}
|
157
|
-
}
|
158
|
-
},
|
159
|
-
hostDisconnected: () => {
|
160
|
-
dispose == null ? void 0 : dispose();
|
161
|
-
dispose = void 0;
|
162
|
-
}
|
163
|
-
});
|
164
|
-
}
|
165
|
-
defineCustomElement("prosekit-block-popover", BlockPopover);
|
166
|
-
export {
|
167
|
-
BlockPopover,
|
168
|
-
propNames
|
169
|
-
};
|
@@ -1,92 +0,0 @@
|
|
1
|
-
import {
|
2
|
-
comboBoxContext
|
3
|
-
} from "./chunk-C4MW43I4.js";
|
4
|
-
import {
|
5
|
-
LightElement,
|
6
|
-
defineCustomElement
|
7
|
-
} from "./chunk-3AZDRLDR.js";
|
8
|
-
|
9
|
-
// src/components/combo-box-input/index.ts
|
10
|
-
import { ContextConsumer } from "@lit/context";
|
11
|
-
import { html } from "lit";
|
12
|
-
var propNames = ["placeholder"];
|
13
|
-
var ComboBoxInput = class extends LightElement {
|
14
|
-
constructor() {
|
15
|
-
super(...arguments);
|
16
|
-
this.placeholder = "";
|
17
|
-
this.comboBoxContext = new ContextConsumer(this, {
|
18
|
-
context: comboBoxContext,
|
19
|
-
subscribe: true
|
20
|
-
});
|
21
|
-
this.visible = false;
|
22
|
-
}
|
23
|
-
handleKeydown(event) {
|
24
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
25
|
-
switch (event.code) {
|
26
|
-
case "ArrowUp":
|
27
|
-
(_b = (_a = this.comboBoxContext.value) == null ? void 0 : _a.listManager) == null ? void 0 : _b.handleArrowUp();
|
28
|
-
event.preventDefault();
|
29
|
-
return;
|
30
|
-
case "ArrowDown":
|
31
|
-
(_d = (_c = this.comboBoxContext.value) == null ? void 0 : _c.listManager) == null ? void 0 : _d.handleArrowDown();
|
32
|
-
event.preventDefault();
|
33
|
-
return;
|
34
|
-
case "Escape":
|
35
|
-
(_f = (_e = this.comboBoxContext.value) == null ? void 0 : _e.listManager) == null ? void 0 : _f.handleEscape();
|
36
|
-
event.preventDefault();
|
37
|
-
return;
|
38
|
-
case "Enter":
|
39
|
-
(_h = (_g = this.comboBoxContext.value) == null ? void 0 : _g.listManager) == null ? void 0 : _h.handleEnter();
|
40
|
-
event.preventDefault();
|
41
|
-
return;
|
42
|
-
}
|
43
|
-
}
|
44
|
-
handleInput(event) {
|
45
|
-
var _a, _b, _c;
|
46
|
-
const value = (_b = (_a = event == null ? void 0 : event.target) == null ? void 0 : _a.value) != null ? _b : "";
|
47
|
-
(_c = this.comboBoxContext.value) == null ? void 0 : _c.setInputValue(value);
|
48
|
-
}
|
49
|
-
/**
|
50
|
-
* @hidden
|
51
|
-
*/
|
52
|
-
firstUpdated() {
|
53
|
-
const resizeObserver = new ResizeObserver((entries) => {
|
54
|
-
const visible = entries.some(
|
55
|
-
(entry) => entry.contentRect.width > 0 && entry.contentRect.width > 0
|
56
|
-
);
|
57
|
-
if (this.visible !== visible && visible) {
|
58
|
-
setTimeout(() => {
|
59
|
-
var _a;
|
60
|
-
return (_a = this.querySelector("input")) == null ? void 0 : _a.focus();
|
61
|
-
}, 0);
|
62
|
-
}
|
63
|
-
this.visible = visible;
|
64
|
-
});
|
65
|
-
resizeObserver.observe(this);
|
66
|
-
}
|
67
|
-
/**
|
68
|
-
* @hidden
|
69
|
-
*/
|
70
|
-
render() {
|
71
|
-
var _a, _b;
|
72
|
-
return html`
|
73
|
-
<input
|
74
|
-
placeholder=${this.placeholder}
|
75
|
-
@keydown=${(event) => this.handleKeydown(event)}
|
76
|
-
@input=${(event) => this.handleInput(event)}
|
77
|
-
.value=${(_b = (_a = this.comboBoxContext.value) == null ? void 0 : _a.inputValue) != null ? _b : ""}
|
78
|
-
></input>
|
79
|
-
`;
|
80
|
-
}
|
81
|
-
};
|
82
|
-
/**
|
83
|
-
* @hidden
|
84
|
-
*/
|
85
|
-
ComboBoxInput.properties = {
|
86
|
-
placeholder: { attribute: true }
|
87
|
-
};
|
88
|
-
defineCustomElement("prosekit-combo-box-input", ComboBoxInput);
|
89
|
-
export {
|
90
|
-
ComboBoxInput,
|
91
|
-
propNames
|
92
|
-
};
|
@@ -1,44 +0,0 @@
|
|
1
|
-
import {
|
2
|
-
comboBoxContext
|
3
|
-
} from "./chunk-C4MW43I4.js";
|
4
|
-
import {
|
5
|
-
LightElement,
|
6
|
-
defineCustomElement
|
7
|
-
} from "./chunk-3AZDRLDR.js";
|
8
|
-
|
9
|
-
// src/components/combo-box-list/component.ts
|
10
|
-
import { ContextConsumer } from "@lit/context";
|
11
|
-
var propNames = [];
|
12
|
-
var ComboBoxList = class extends LightElement {
|
13
|
-
constructor() {
|
14
|
-
super(...arguments);
|
15
|
-
this.comboBoxContext = new ContextConsumer(this, {
|
16
|
-
context: comboBoxContext,
|
17
|
-
subscribe: true
|
18
|
-
});
|
19
|
-
}
|
20
|
-
connectedCallback() {
|
21
|
-
super.connectedCallback();
|
22
|
-
this.addEventListener("mousemove", (event) => {
|
23
|
-
var _a;
|
24
|
-
(_a = this.comboBoxContext.value) == null ? void 0 : _a.listManager.handleMouseMove(event);
|
25
|
-
});
|
26
|
-
this.addEventListener("mouseover", (event) => {
|
27
|
-
var _a;
|
28
|
-
(_a = this.comboBoxContext.value) == null ? void 0 : _a.listManager.handleMouseOver(event);
|
29
|
-
});
|
30
|
-
this.addEventListener("mousedown", (event) => {
|
31
|
-
var _a;
|
32
|
-
(_a = this.comboBoxContext.value) == null ? void 0 : _a.listManager.handleMouseDown(event);
|
33
|
-
});
|
34
|
-
this.addEventListener("click", (event) => {
|
35
|
-
var _a;
|
36
|
-
(_a = this.comboBoxContext.value) == null ? void 0 : _a.listManager.handleClick(event);
|
37
|
-
});
|
38
|
-
}
|
39
|
-
};
|
40
|
-
defineCustomElement("prosekit-combo-box-list", ComboBoxList);
|
41
|
-
export {
|
42
|
-
ComboBoxList,
|
43
|
-
propNames
|
44
|
-
};
|
@@ -1,130 +0,0 @@
|
|
1
|
-
import "./chunk-3TPE2GKD.js";
|
2
|
-
import {
|
3
|
-
ListManager
|
4
|
-
} from "./chunk-MZAHIYA5.js";
|
5
|
-
import {
|
6
|
-
Popover
|
7
|
-
} from "./chunk-XHBZNZ2L.js";
|
8
|
-
import {
|
9
|
-
comboBoxContext
|
10
|
-
} from "./chunk-C4MW43I4.js";
|
11
|
-
import {
|
12
|
-
defineCustomElement
|
13
|
-
} from "./chunk-3AZDRLDR.js";
|
14
|
-
|
15
|
-
// src/components/combo-box/index.ts
|
16
|
-
import { ContextProvider } from "@lit/context";
|
17
|
-
|
18
|
-
// src/components/combo-box-item/helpers.ts
|
19
|
-
function isComboBoxItem(element) {
|
20
|
-
var _a;
|
21
|
-
return ((_a = element == null ? void 0 : element.tagName) == null ? void 0 : _a.toLowerCase()) === "prosekit-combo-box-item";
|
22
|
-
}
|
23
|
-
function queryClosestComboBoxItem(element) {
|
24
|
-
if (!element) {
|
25
|
-
return null;
|
26
|
-
}
|
27
|
-
if (isComboBoxItem(element)) {
|
28
|
-
return element;
|
29
|
-
}
|
30
|
-
const item = element.closest("prosekit-combo-box-item");
|
31
|
-
if (isComboBoxItem(item)) {
|
32
|
-
return item;
|
33
|
-
}
|
34
|
-
return null;
|
35
|
-
}
|
36
|
-
|
37
|
-
// src/components/combo-box/index.ts
|
38
|
-
var propNames = ["onDismiss"];
|
39
|
-
var ComboBox = class extends Popover {
|
40
|
-
constructor() {
|
41
|
-
super(...arguments);
|
42
|
-
this.listManager = new ListManager({
|
43
|
-
getItems: () => {
|
44
|
-
return this.items;
|
45
|
-
},
|
46
|
-
getSelectedValue: () => {
|
47
|
-
var _a;
|
48
|
-
return ((_a = this.getContext().selectedValue) != null ? _a : "").trim();
|
49
|
-
},
|
50
|
-
setSelectedValue: (value, reason) => {
|
51
|
-
return this.setSelectedValue(value, reason);
|
52
|
-
},
|
53
|
-
getItemValue: (item) => {
|
54
|
-
var _a;
|
55
|
-
return ((_a = item.textContent) != null ? _a : "").trim();
|
56
|
-
},
|
57
|
-
queryClosestItem: queryClosestComboBoxItem,
|
58
|
-
getActive: () => {
|
59
|
-
return true;
|
60
|
-
},
|
61
|
-
onDismiss: () => {
|
62
|
-
this.hide();
|
63
|
-
},
|
64
|
-
onSelect: (item) => {
|
65
|
-
var _a;
|
66
|
-
if (item == null ? void 0 : item.onSelect) {
|
67
|
-
this.setSelectedValue("", "keyboard");
|
68
|
-
(_a = item == null ? void 0 : item.onSelect) == null ? void 0 : _a.call(item);
|
69
|
-
this.hide();
|
70
|
-
return true;
|
71
|
-
}
|
72
|
-
return false;
|
73
|
-
}
|
74
|
-
});
|
75
|
-
this.context = new ContextProvider(this, {
|
76
|
-
context: comboBoxContext,
|
77
|
-
initialValue: {
|
78
|
-
inputValue: "",
|
79
|
-
setInputValue: (inputValue) => {
|
80
|
-
this.setInputValue(inputValue);
|
81
|
-
},
|
82
|
-
selectedValue: "",
|
83
|
-
selectedReason: "keyboard",
|
84
|
-
listManager: this.listManager
|
85
|
-
}
|
86
|
-
});
|
87
|
-
}
|
88
|
-
/**
|
89
|
-
* @hidden
|
90
|
-
*/
|
91
|
-
hide() {
|
92
|
-
var _a;
|
93
|
-
super.hide();
|
94
|
-
this.setInputValue("");
|
95
|
-
(_a = this.onDismiss) == null ? void 0 : _a.call(this);
|
96
|
-
}
|
97
|
-
getContext() {
|
98
|
-
return this.context.value;
|
99
|
-
}
|
100
|
-
setInputValue(inputValue) {
|
101
|
-
const context = this.context.value;
|
102
|
-
if (context.inputValue === inputValue) {
|
103
|
-
return;
|
104
|
-
}
|
105
|
-
this.context.setValue({ ...context, inputValue });
|
106
|
-
}
|
107
|
-
setSelectedValue(selectedValue, selectedReason) {
|
108
|
-
const context = this.context.value;
|
109
|
-
if (context.selectedValue === selectedValue) {
|
110
|
-
return;
|
111
|
-
}
|
112
|
-
this.context.setValue({ ...context, selectedValue, selectedReason });
|
113
|
-
}
|
114
|
-
get items() {
|
115
|
-
const items = this.querySelectorAll("prosekit-combo-box-item");
|
116
|
-
return Array.from(items).filter(isComboBoxItem);
|
117
|
-
}
|
118
|
-
};
|
119
|
-
/**
|
120
|
-
* @hidden
|
121
|
-
*/
|
122
|
-
ComboBox.properties = {
|
123
|
-
...Popover.properties,
|
124
|
-
onDismiss: { attribute: false }
|
125
|
-
};
|
126
|
-
defineCustomElement("prosekit-combo-box", ComboBox);
|
127
|
-
export {
|
128
|
-
ComboBox,
|
129
|
-
propNames
|
130
|
-
};
|
@@ -1,94 +0,0 @@
|
|
1
|
-
import {
|
2
|
-
blockPopoverContext
|
3
|
-
} from "./chunk-S72UTR5M.js";
|
4
|
-
import {
|
5
|
-
LightElement,
|
6
|
-
defineCustomElement
|
7
|
-
} from "./chunk-3AZDRLDR.js";
|
8
|
-
|
9
|
-
// src/components/drag-handle/index.ts
|
10
|
-
import { ContextConsumer } from "@lit/context";
|
11
|
-
import { Slice, Fragment } from "@prosekit/pm/model";
|
12
|
-
import { NodeSelection } from "@prosekit/pm/state";
|
13
|
-
|
14
|
-
// src/controllers/use-mount.ts
|
15
|
-
function useMount(host, onMount) {
|
16
|
-
let dispose;
|
17
|
-
host.addController({
|
18
|
-
hostConnected: () => {
|
19
|
-
dispose == null ? void 0 : dispose();
|
20
|
-
dispose = onMount();
|
21
|
-
},
|
22
|
-
hostDisconnected: () => {
|
23
|
-
dispose == null ? void 0 : dispose();
|
24
|
-
dispose = void 0;
|
25
|
-
}
|
26
|
-
});
|
27
|
-
}
|
28
|
-
|
29
|
-
// src/controllers/use-event-listener.ts
|
30
|
-
function useEventListener(target, type, listener, options) {
|
31
|
-
useMount(target, () => {
|
32
|
-
target.addEventListener(type, listener, options);
|
33
|
-
return () => {
|
34
|
-
target.removeEventListener(type, listener, options);
|
35
|
-
};
|
36
|
-
});
|
37
|
-
}
|
38
|
-
|
39
|
-
// src/components/drag-handle/index.ts
|
40
|
-
var propNames = ["editor"];
|
41
|
-
var DragHandle = class extends LightElement {
|
42
|
-
constructor() {
|
43
|
-
super();
|
44
|
-
this.blockPopoverContext = new ContextConsumer(this, {
|
45
|
-
context: blockPopoverContext,
|
46
|
-
subscribe: true
|
47
|
-
});
|
48
|
-
}
|
49
|
-
connectedCallback() {
|
50
|
-
super.connectedCallback();
|
51
|
-
this.draggable = true;
|
52
|
-
useEventListener(this, "pointerdown", () => {
|
53
|
-
var _a, _b;
|
54
|
-
const { pos } = (_a = this.blockPopoverContext.value) != null ? _a : {};
|
55
|
-
const { view } = (_b = this.editor) != null ? _b : {};
|
56
|
-
if (pos == null || !view) {
|
57
|
-
return;
|
58
|
-
}
|
59
|
-
view.dispatch(
|
60
|
-
view.state.tr.setSelection(NodeSelection.create(view.state.doc, pos))
|
61
|
-
);
|
62
|
-
requestAnimationFrame(() => {
|
63
|
-
view.focus();
|
64
|
-
});
|
65
|
-
});
|
66
|
-
useEventListener(this, "dragstart", (event) => {
|
67
|
-
var _a, _b;
|
68
|
-
const { pos, element, node } = (_a = this.blockPopoverContext.value) != null ? _a : {};
|
69
|
-
const { view } = (_b = this.editor) != null ? _b : {};
|
70
|
-
if (pos == null || !element || !node || !view || !event.dataTransfer) {
|
71
|
-
return;
|
72
|
-
}
|
73
|
-
event.dataTransfer.clearData();
|
74
|
-
event.dataTransfer.setData("text/html", element.outerHTML);
|
75
|
-
event.dataTransfer.effectAllowed = "copyMove";
|
76
|
-
event.dataTransfer.setDragImage(element, 0, 0);
|
77
|
-
view.dragging = {
|
78
|
-
slice: new Slice(Fragment.from(node), 0, 0),
|
79
|
-
move: true
|
80
|
-
};
|
81
|
-
});
|
82
|
-
}
|
83
|
-
};
|
84
|
-
/**
|
85
|
-
* @hidden
|
86
|
-
*/
|
87
|
-
DragHandle.properties = {
|
88
|
-
editor: { type: Object, reflect: false, attribute: false }
|
89
|
-
};
|
90
|
-
defineCustomElement("prosekit-drag-handle", DragHandle);
|
91
|
-
export {
|
92
|
-
DragHandle,
|
93
|
-
propNames
|
94
|
-
};
|