@prosekit/lit 0.2.8 → 0.3.1
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 +22 -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
|
@@ -1,46 +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-list/component.ts
|
|
12
|
-
import { ContextConsumer } from "@lit/context";
|
|
13
|
-
var propNames = [];
|
|
14
|
-
var ComboBoxList = class extends LightElement {
|
|
15
|
-
constructor() {
|
|
16
|
-
super(...arguments);
|
|
17
|
-
this.comboBoxContext = new ContextConsumer(this, {
|
|
18
|
-
context: comboBoxContext,
|
|
19
|
-
subscribe: true
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
connectedCallback() {
|
|
23
|
-
super.connectedCallback();
|
|
24
|
-
this.addEventListener("mousemove", (event) => {
|
|
25
|
-
var _a;
|
|
26
|
-
(_a = this.comboBoxContext.value) == null ? void 0 : _a.listManager.handleMouseMove(event);
|
|
27
|
-
});
|
|
28
|
-
this.addEventListener("mouseover", (event) => {
|
|
29
|
-
var _a;
|
|
30
|
-
(_a = this.comboBoxContext.value) == null ? void 0 : _a.listManager.handleMouseOver(event);
|
|
31
|
-
});
|
|
32
|
-
this.addEventListener("mousedown", (event) => {
|
|
33
|
-
var _a;
|
|
34
|
-
(_a = this.comboBoxContext.value) == null ? void 0 : _a.listManager.handleMouseDown(event);
|
|
35
|
-
});
|
|
36
|
-
this.addEventListener("click", (event) => {
|
|
37
|
-
var _a;
|
|
38
|
-
(_a = this.comboBoxContext.value) == null ? void 0 : _a.listManager.handleClick(event);
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
defineCustomElement("prosekit-combo-box-list", ComboBoxList);
|
|
43
|
-
export {
|
|
44
|
-
ComboBoxList,
|
|
45
|
-
propNames
|
|
46
|
-
};
|
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
import "./chunk-7E5POS6D.js";
|
|
2
|
-
import {
|
|
3
|
-
ListManager
|
|
4
|
-
} from "./chunk-MZAHIYA5.js";
|
|
5
|
-
import {
|
|
6
|
-
Popover
|
|
7
|
-
} from "./chunk-FKSZFUL3.js";
|
|
8
|
-
import {
|
|
9
|
-
comboBoxContext
|
|
10
|
-
} from "./chunk-C4MW43I4.js";
|
|
11
|
-
import "./chunk-UIHDPY7W.js";
|
|
12
|
-
import {
|
|
13
|
-
defineCustomElement
|
|
14
|
-
} from "./chunk-LCDA7GFP.js";
|
|
15
|
-
|
|
16
|
-
// src/components/combo-box/index.ts
|
|
17
|
-
import { ContextProvider } from "@lit/context";
|
|
18
|
-
|
|
19
|
-
// src/components/combo-box-item/helpers.ts
|
|
20
|
-
function isComboBoxItem(element) {
|
|
21
|
-
var _a;
|
|
22
|
-
return ((_a = element == null ? void 0 : element.tagName) == null ? void 0 : _a.toLowerCase()) === "prosekit-combo-box-item";
|
|
23
|
-
}
|
|
24
|
-
function queryClosestComboBoxItem(element) {
|
|
25
|
-
if (!element) {
|
|
26
|
-
return null;
|
|
27
|
-
}
|
|
28
|
-
if (isComboBoxItem(element)) {
|
|
29
|
-
return element;
|
|
30
|
-
}
|
|
31
|
-
const item = element.closest("prosekit-combo-box-item");
|
|
32
|
-
if (isComboBoxItem(item)) {
|
|
33
|
-
return item;
|
|
34
|
-
}
|
|
35
|
-
return null;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
// src/components/combo-box/index.ts
|
|
39
|
-
var propNames = ["onDismiss"];
|
|
40
|
-
var ComboBox = class extends Popover {
|
|
41
|
-
constructor() {
|
|
42
|
-
super(...arguments);
|
|
43
|
-
this.listManager = new ListManager({
|
|
44
|
-
getItems: () => {
|
|
45
|
-
return this.items;
|
|
46
|
-
},
|
|
47
|
-
getSelectedValue: () => {
|
|
48
|
-
var _a;
|
|
49
|
-
return ((_a = this.getContext().selectedValue) != null ? _a : "").trim();
|
|
50
|
-
},
|
|
51
|
-
setSelectedValue: (value, reason) => {
|
|
52
|
-
return this.setSelectedValue(value, reason);
|
|
53
|
-
},
|
|
54
|
-
getItemValue: (item) => {
|
|
55
|
-
var _a;
|
|
56
|
-
return ((_a = item.textContent) != null ? _a : "").trim();
|
|
57
|
-
},
|
|
58
|
-
queryClosestItem: queryClosestComboBoxItem,
|
|
59
|
-
getActive: () => {
|
|
60
|
-
return true;
|
|
61
|
-
},
|
|
62
|
-
onDismiss: () => {
|
|
63
|
-
this.hide();
|
|
64
|
-
},
|
|
65
|
-
onSelect: (item) => {
|
|
66
|
-
var _a;
|
|
67
|
-
if (item == null ? void 0 : item.onSelect) {
|
|
68
|
-
this.setSelectedValue("", "keyboard");
|
|
69
|
-
(_a = item == null ? void 0 : item.onSelect) == null ? void 0 : _a.call(item);
|
|
70
|
-
this.hide();
|
|
71
|
-
return true;
|
|
72
|
-
}
|
|
73
|
-
return false;
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
this.context = new ContextProvider(this, {
|
|
77
|
-
context: comboBoxContext,
|
|
78
|
-
initialValue: {
|
|
79
|
-
inputValue: "",
|
|
80
|
-
setInputValue: (inputValue) => {
|
|
81
|
-
this.setInputValue(inputValue);
|
|
82
|
-
},
|
|
83
|
-
selectedValue: "",
|
|
84
|
-
selectedReason: "keyboard",
|
|
85
|
-
listManager: this.listManager
|
|
86
|
-
}
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* @hidden
|
|
91
|
-
*/
|
|
92
|
-
hide() {
|
|
93
|
-
var _a;
|
|
94
|
-
super.hide();
|
|
95
|
-
this.setInputValue("");
|
|
96
|
-
(_a = this.onDismiss) == null ? void 0 : _a.call(this);
|
|
97
|
-
}
|
|
98
|
-
getContext() {
|
|
99
|
-
return this.context.value;
|
|
100
|
-
}
|
|
101
|
-
setInputValue(inputValue) {
|
|
102
|
-
const context = this.context.value;
|
|
103
|
-
if (context.inputValue === inputValue) {
|
|
104
|
-
return;
|
|
105
|
-
}
|
|
106
|
-
this.context.setValue({ ...context, inputValue });
|
|
107
|
-
}
|
|
108
|
-
setSelectedValue(selectedValue, selectedReason) {
|
|
109
|
-
const context = this.context.value;
|
|
110
|
-
if (context.selectedValue === selectedValue) {
|
|
111
|
-
return;
|
|
112
|
-
}
|
|
113
|
-
this.context.setValue({ ...context, selectedValue, selectedReason });
|
|
114
|
-
}
|
|
115
|
-
get items() {
|
|
116
|
-
const items = this.querySelectorAll("prosekit-combo-box-item");
|
|
117
|
-
return Array.from(items).filter(isComboBoxItem);
|
|
118
|
-
}
|
|
119
|
-
};
|
|
120
|
-
/**
|
|
121
|
-
* @hidden
|
|
122
|
-
*/
|
|
123
|
-
ComboBox.properties = {
|
|
124
|
-
...Popover.properties,
|
|
125
|
-
onDismiss: { attribute: false }
|
|
126
|
-
};
|
|
127
|
-
defineCustomElement("prosekit-combo-box", ComboBox);
|
|
128
|
-
export {
|
|
129
|
-
ComboBox,
|
|
130
|
-
propNames
|
|
131
|
-
};
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
blockPopoverContext
|
|
3
|
-
} from "./chunk-S72UTR5M.js";
|
|
4
|
-
import {
|
|
5
|
-
LightElement
|
|
6
|
-
} from "./chunk-UIHDPY7W.js";
|
|
7
|
-
import {
|
|
8
|
-
defineCustomElement
|
|
9
|
-
} from "./chunk-LCDA7GFP.js";
|
|
10
|
-
|
|
11
|
-
// src/components/drag-handle/index.ts
|
|
12
|
-
import { ContextConsumer } from "@lit/context";
|
|
13
|
-
import { Slice, Fragment } from "@prosekit/pm/model";
|
|
14
|
-
import { NodeSelection } from "@prosekit/pm/state";
|
|
15
|
-
|
|
16
|
-
// src/controllers/use-mount.ts
|
|
17
|
-
function useMount(host, onMount) {
|
|
18
|
-
let dispose;
|
|
19
|
-
host.addController({
|
|
20
|
-
hostConnected: () => {
|
|
21
|
-
dispose == null ? void 0 : dispose();
|
|
22
|
-
dispose = onMount();
|
|
23
|
-
},
|
|
24
|
-
hostDisconnected: () => {
|
|
25
|
-
dispose == null ? void 0 : dispose();
|
|
26
|
-
dispose = void 0;
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
// src/controllers/use-event-listener.ts
|
|
32
|
-
function useEventListener(target, type, listener, options) {
|
|
33
|
-
useMount(target, () => {
|
|
34
|
-
target.addEventListener(type, listener, options);
|
|
35
|
-
return () => {
|
|
36
|
-
target.removeEventListener(type, listener, options);
|
|
37
|
-
};
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
// src/components/drag-handle/index.ts
|
|
42
|
-
var propNames = ["editor"];
|
|
43
|
-
var DragHandle = class extends LightElement {
|
|
44
|
-
constructor() {
|
|
45
|
-
super();
|
|
46
|
-
this.blockPopoverContext = new ContextConsumer(this, {
|
|
47
|
-
context: blockPopoverContext,
|
|
48
|
-
subscribe: true
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
connectedCallback() {
|
|
52
|
-
super.connectedCallback();
|
|
53
|
-
this.draggable = true;
|
|
54
|
-
useEventListener(this, "pointerdown", () => {
|
|
55
|
-
var _a, _b;
|
|
56
|
-
const { pos } = (_a = this.blockPopoverContext.value) != null ? _a : {};
|
|
57
|
-
const { view } = (_b = this.editor) != null ? _b : {};
|
|
58
|
-
if (pos == null || !view) {
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
view.dispatch(
|
|
62
|
-
view.state.tr.setSelection(NodeSelection.create(view.state.doc, pos))
|
|
63
|
-
);
|
|
64
|
-
requestAnimationFrame(() => {
|
|
65
|
-
view.focus();
|
|
66
|
-
});
|
|
67
|
-
});
|
|
68
|
-
useEventListener(this, "dragstart", (event) => {
|
|
69
|
-
var _a, _b;
|
|
70
|
-
const { pos, element, node } = (_a = this.blockPopoverContext.value) != null ? _a : {};
|
|
71
|
-
const { view } = (_b = this.editor) != null ? _b : {};
|
|
72
|
-
if (pos == null || !element || !node || !view || !event.dataTransfer) {
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
event.dataTransfer.clearData();
|
|
76
|
-
event.dataTransfer.setData("text/html", element.outerHTML);
|
|
77
|
-
event.dataTransfer.effectAllowed = "copyMove";
|
|
78
|
-
event.dataTransfer.setDragImage(element, 0, 0);
|
|
79
|
-
view.dragging = {
|
|
80
|
-
slice: new Slice(Fragment.from(node), 0, 0),
|
|
81
|
-
move: true
|
|
82
|
-
};
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
};
|
|
86
|
-
/**
|
|
87
|
-
* @hidden
|
|
88
|
-
*/
|
|
89
|
-
DragHandle.properties = {
|
|
90
|
-
editor: { type: Object, reflect: false, attribute: false }
|
|
91
|
-
};
|
|
92
|
-
defineCustomElement("prosekit-drag-handle", DragHandle);
|
|
93
|
-
export {
|
|
94
|
-
DragHandle,
|
|
95
|
-
propNames
|
|
96
|
-
};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
defineCustomElement
|
|
3
|
-
} from "./chunk-LCDA7GFP.js";
|
|
4
|
-
|
|
5
|
-
// src/components/popover-content/index.ts
|
|
6
|
-
import {
|
|
7
|
-
PopoverContentElement,
|
|
8
|
-
defaultPopoverContentProps
|
|
9
|
-
} from "@aria-ui/popover";
|
|
10
|
-
var propNames = Object.keys(
|
|
11
|
-
defaultPopoverContentProps
|
|
12
|
-
);
|
|
13
|
-
defineCustomElement("prosekit-popover-content", PopoverContentElement);
|
|
14
|
-
export {
|
|
15
|
-
PopoverContentElement as PopoverContent,
|
|
16
|
-
propNames
|
|
17
|
-
};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
defineCustomElement
|
|
3
|
-
} from "./chunk-LCDA7GFP.js";
|
|
4
|
-
|
|
5
|
-
// src/components/popover-root/index.ts
|
|
6
|
-
import {
|
|
7
|
-
PopoverRootElement,
|
|
8
|
-
defaultPopoverRootProps
|
|
9
|
-
} from "@aria-ui/popover";
|
|
10
|
-
var propNames = Object.keys(
|
|
11
|
-
defaultPopoverRootProps
|
|
12
|
-
);
|
|
13
|
-
defineCustomElement("prosekit-popover-root", PopoverRootElement);
|
|
14
|
-
export {
|
|
15
|
-
PopoverRootElement as PopoverRoot,
|
|
16
|
-
propNames
|
|
17
|
-
};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
defineCustomElement
|
|
3
|
-
} from "./chunk-LCDA7GFP.js";
|
|
4
|
-
|
|
5
|
-
// src/components/popover-trigger/index.ts
|
|
6
|
-
import { PopoverTriggerElement } from "@aria-ui/popover";
|
|
7
|
-
var propNames = [];
|
|
8
|
-
defineCustomElement("prosekit-popover-trigger", PopoverTriggerElement);
|
|
9
|
-
export {
|
|
10
|
-
PopoverTriggerElement as PopoverTrigger,
|
|
11
|
-
propNames
|
|
12
|
-
};
|
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
resizableContext
|
|
3
|
-
} from "./chunk-WEUGKLVB.js";
|
|
4
|
-
import {
|
|
5
|
-
LightElement
|
|
6
|
-
} from "./chunk-UIHDPY7W.js";
|
|
7
|
-
import {
|
|
8
|
-
defineCustomElement
|
|
9
|
-
} from "./chunk-LCDA7GFP.js";
|
|
10
|
-
|
|
11
|
-
// src/components/resizable-handle/component.ts
|
|
12
|
-
import { ContextConsumer } from "@lit/context";
|
|
13
|
-
|
|
14
|
-
// src/utils/is-finite-positive-number.ts
|
|
15
|
-
function isFinitePositiveNumber(value) {
|
|
16
|
-
return typeof value === "number" && Number.isFinite(value) && value > 0;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
// src/components/resizable-handle/calc-resize.ts
|
|
20
|
-
function calcResize(position, w, h, dx, dy, aspectRatio) {
|
|
21
|
-
aspectRatio = aspectRatio ? aspectRatio : w / h;
|
|
22
|
-
aspectRatio = isFinitePositiveNumber(aspectRatio) ? aspectRatio : 1;
|
|
23
|
-
switch (position) {
|
|
24
|
-
case "bottom-right":
|
|
25
|
-
return calcBottomRightResize(w, h, dx, dy, aspectRatio);
|
|
26
|
-
case "bottom-left":
|
|
27
|
-
return calcBottomLeftResize(w, h, dx, dy, aspectRatio);
|
|
28
|
-
case "top-right":
|
|
29
|
-
return calcTopRightResize(w, h, dx, dy, aspectRatio);
|
|
30
|
-
case "top-left":
|
|
31
|
-
return calcTopLeftResize(w, h, dx, dy, aspectRatio);
|
|
32
|
-
case "top":
|
|
33
|
-
return calcTopResize(w, h, dx, dy, aspectRatio);
|
|
34
|
-
case "right":
|
|
35
|
-
return calcRightResize(w, h, dx, dy, aspectRatio);
|
|
36
|
-
case "bottom":
|
|
37
|
-
return calcBottomResize(w, h, dx, dy, aspectRatio);
|
|
38
|
-
case "left":
|
|
39
|
-
return calcLeftResize(w, h, dx, dy, aspectRatio);
|
|
40
|
-
default:
|
|
41
|
-
throw new RangeError(`Invalid position: ${position}`);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
var calcBottomRightResize = (w, h, dx, dy, r) => {
|
|
45
|
-
w += dx;
|
|
46
|
-
h += dy;
|
|
47
|
-
const sum = w + h;
|
|
48
|
-
h = sum / (r + 1);
|
|
49
|
-
w = sum - h;
|
|
50
|
-
return [w, h];
|
|
51
|
-
};
|
|
52
|
-
var calcBottomLeftResize = (w, h, dx, dy, r) => {
|
|
53
|
-
w -= dx;
|
|
54
|
-
h += dy;
|
|
55
|
-
const sum = w + h;
|
|
56
|
-
h = sum / (r + 1);
|
|
57
|
-
w = sum - h;
|
|
58
|
-
return [w, h];
|
|
59
|
-
};
|
|
60
|
-
var calcTopRightResize = (w, h, dx, dy, r) => {
|
|
61
|
-
w += dx;
|
|
62
|
-
h -= dy;
|
|
63
|
-
const sum = w + h;
|
|
64
|
-
h = sum / (r + 1);
|
|
65
|
-
w = sum - h;
|
|
66
|
-
return [w, h];
|
|
67
|
-
};
|
|
68
|
-
var calcTopLeftResize = (w, h, dx, dy, r) => {
|
|
69
|
-
w -= dx;
|
|
70
|
-
h -= dy;
|
|
71
|
-
const sum = w + h;
|
|
72
|
-
h = sum / (r + 1);
|
|
73
|
-
w = sum - h;
|
|
74
|
-
return [w, h];
|
|
75
|
-
};
|
|
76
|
-
var calcTopResize = (w, h, dx, dy, r) => {
|
|
77
|
-
h -= dy;
|
|
78
|
-
w = h * r;
|
|
79
|
-
return [w, h];
|
|
80
|
-
};
|
|
81
|
-
var calcRightResize = (w, h, dx, dy, r) => {
|
|
82
|
-
w += dx;
|
|
83
|
-
h = w / r;
|
|
84
|
-
return [w, h];
|
|
85
|
-
};
|
|
86
|
-
var calcBottomResize = (w, h, dx, dy, r) => {
|
|
87
|
-
h += dy;
|
|
88
|
-
w = h * r;
|
|
89
|
-
return [w, h];
|
|
90
|
-
};
|
|
91
|
-
var calcLeftResize = (w, h, dx, dy, r) => {
|
|
92
|
-
w -= dx;
|
|
93
|
-
h = w / r;
|
|
94
|
-
return [w, h];
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
// src/components/resizable-handle/component.ts
|
|
98
|
-
var propNames = [];
|
|
99
|
-
var ResizableHandle = class extends LightElement {
|
|
100
|
-
constructor() {
|
|
101
|
-
super(...arguments);
|
|
102
|
-
this.context = new ContextConsumer(this, {
|
|
103
|
-
context: resizableContext
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
connectedCallback() {
|
|
107
|
-
super.connectedCallback();
|
|
108
|
-
let startX = 0;
|
|
109
|
-
let startY = 0;
|
|
110
|
-
let width = 0;
|
|
111
|
-
let height = 0;
|
|
112
|
-
let aspectRatio = 1;
|
|
113
|
-
const handlePointerMove = (event) => {
|
|
114
|
-
var _a;
|
|
115
|
-
event.preventDefault();
|
|
116
|
-
const dx = event.x - startX;
|
|
117
|
-
const dy = event.y - startY;
|
|
118
|
-
const [w, h] = calcResize(
|
|
119
|
-
this.position || "bottom-right",
|
|
120
|
-
width,
|
|
121
|
-
height,
|
|
122
|
-
dx,
|
|
123
|
-
dy,
|
|
124
|
-
aspectRatio
|
|
125
|
-
);
|
|
126
|
-
(_a = this.context.value) == null ? void 0 : _a.onResize(w, h);
|
|
127
|
-
};
|
|
128
|
-
const handlePointerDown = (event) => {
|
|
129
|
-
var _a;
|
|
130
|
-
event.preventDefault();
|
|
131
|
-
startX = event.x;
|
|
132
|
-
startY = event.y;
|
|
133
|
-
const size = (_a = this.context.value) == null ? void 0 : _a.onResizeStart();
|
|
134
|
-
if (size) {
|
|
135
|
-
;
|
|
136
|
-
[width, height, aspectRatio] = size;
|
|
137
|
-
}
|
|
138
|
-
this.ownerDocument.addEventListener("pointermove", handlePointerMove);
|
|
139
|
-
this.ownerDocument.addEventListener("pointerup", handlePointerUp);
|
|
140
|
-
};
|
|
141
|
-
const handlePointerUp = (event) => {
|
|
142
|
-
var _a;
|
|
143
|
-
event.preventDefault();
|
|
144
|
-
(_a = this.context.value) == null ? void 0 : _a.onResizeEnd();
|
|
145
|
-
this.ownerDocument.removeEventListener("pointermove", handlePointerMove);
|
|
146
|
-
this.ownerDocument.removeEventListener("pointerup", handlePointerUp);
|
|
147
|
-
};
|
|
148
|
-
this.addEventListener("pointerdown", handlePointerDown);
|
|
149
|
-
}
|
|
150
|
-
};
|
|
151
|
-
/**
|
|
152
|
-
* @hidden
|
|
153
|
-
*/
|
|
154
|
-
ResizableHandle.properties = {
|
|
155
|
-
position: { attribute: false }
|
|
156
|
-
};
|
|
157
|
-
defineCustomElement("prosekit-resizable-handle", ResizableHandle);
|
|
158
|
-
export {
|
|
159
|
-
ResizableHandle,
|
|
160
|
-
propNames
|
|
161
|
-
};
|