@prosekit/lit 0.1.6 → 0.1.8
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 +201 -0
- package/dist/chunk-WEUGKLVB.js +9 -0
- package/dist/prosekit-lit-inline-popover.js +9 -1
- package/dist/prosekit-lit-resizable-handle.d.ts +3 -0
- package/dist/prosekit-lit-resizable-handle.js +159 -0
- package/dist/prosekit-lit-resizable.d.ts +3 -0
- package/dist/prosekit-lit-resizable.js +107 -0
- package/package.json +21 -5
@@ -9,6 +9,7 @@ import { Options } from 'tsup';
|
|
9
9
|
import { PropertyValues } from 'lit';
|
10
10
|
import { ReactiveController } from 'lit';
|
11
11
|
import { ReactiveControllerHost } from 'lit';
|
12
|
+
import type { Selection as Selection_2 } from '@prosekit/pm/state';
|
12
13
|
import { TemplateResult } from 'lit';
|
13
14
|
import { VirtualElement } from '@floating-ui/dom';
|
14
15
|
|
@@ -228,6 +229,11 @@ export declare const blockComponentStyles: CSSResult;
|
|
228
229
|
*/
|
229
230
|
export declare const boundary: HTMLElement | undefined;
|
230
231
|
|
232
|
+
export declare function calcResize(position: 'top' | 'right' | 'bottom' | 'left' | 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right', w: number, h: number, dx: number, dy: number, aspectRatio: number | null | undefined): [w: number, h: number];
|
233
|
+
|
234
|
+
/**
|
235
|
+
* @internal
|
236
|
+
*/
|
231
237
|
export declare class ComboBox extends Popover {
|
232
238
|
/**
|
233
239
|
* @hidden
|
@@ -283,6 +289,9 @@ export declare const comboBoxContext: {
|
|
283
289
|
__context__: ComboBoxContext;
|
284
290
|
};
|
285
291
|
|
292
|
+
/**
|
293
|
+
* @internal
|
294
|
+
*/
|
286
295
|
export declare class ComboBoxInput extends LightElement {
|
287
296
|
/**
|
288
297
|
* @hidden
|
@@ -307,10 +316,16 @@ export declare class ComboBoxInput extends LightElement {
|
|
307
316
|
render(): TemplateResult<1>;
|
308
317
|
}
|
309
318
|
|
319
|
+
/**
|
320
|
+
* @internal
|
321
|
+
*/
|
310
322
|
export declare interface ComboBoxInputProps {
|
311
323
|
placeholder?: string;
|
312
324
|
}
|
313
325
|
|
326
|
+
/**
|
327
|
+
* @internal
|
328
|
+
*/
|
314
329
|
declare class ComboBoxItem extends LightElement {
|
315
330
|
/**
|
316
331
|
* @hidden
|
@@ -340,12 +355,18 @@ declare class ComboBoxItem extends LightElement {
|
|
340
355
|
export { ComboBoxItem }
|
341
356
|
export { ComboBoxItem as ComboBoxItem_alias_1 }
|
342
357
|
|
358
|
+
/**
|
359
|
+
* @internal
|
360
|
+
*/
|
343
361
|
declare type ComboBoxItemProps = {
|
344
362
|
onSelect?: VoidFunction;
|
345
363
|
};
|
346
364
|
export { ComboBoxItemProps }
|
347
365
|
export { ComboBoxItemProps as ComboBoxItemProps_alias_1 }
|
348
366
|
|
367
|
+
/**
|
368
|
+
* @internal
|
369
|
+
*/
|
349
370
|
declare class ComboBoxList extends LightElement {
|
350
371
|
private comboBoxContext;
|
351
372
|
connectedCallback(): void;
|
@@ -353,12 +374,18 @@ declare class ComboBoxList extends LightElement {
|
|
353
374
|
export { ComboBoxList }
|
354
375
|
export { ComboBoxList as ComboBoxList_alias_1 }
|
355
376
|
|
377
|
+
/**
|
378
|
+
* @internal
|
379
|
+
*/
|
356
380
|
declare type ComboBoxListProps = {
|
357
381
|
lang?: string;
|
358
382
|
};
|
359
383
|
export { ComboBoxListProps }
|
360
384
|
export { ComboBoxListProps as ComboBoxListProps_alias_1 }
|
361
385
|
|
386
|
+
/**
|
387
|
+
* @internal
|
388
|
+
*/
|
362
389
|
export declare interface ComboBoxProps extends PopoverProps {
|
363
390
|
onDismiss?: VoidFunction;
|
364
391
|
}
|
@@ -473,6 +500,10 @@ export declare function isComboBoxItem(element?: Element | null): element is Com
|
|
473
500
|
|
474
501
|
export declare function isComboBoxList(element?: Element | null): element is ComboBoxList;
|
475
502
|
|
503
|
+
export declare function isFinitePositiveNumber(value: unknown): value is number;
|
504
|
+
|
505
|
+
export declare function isInCodeBlock(selection: Selection_2): boolean | undefined;
|
506
|
+
|
476
507
|
export declare class LightElement extends LitElement {
|
477
508
|
/**
|
478
509
|
* @hidden
|
@@ -666,6 +697,9 @@ export declare interface PopoverProps {
|
|
666
697
|
autoUpdateOptions?: AutoUpdateOptions;
|
667
698
|
}
|
668
699
|
|
700
|
+
/**
|
701
|
+
* @internal
|
702
|
+
*/
|
669
703
|
export declare const propNames: readonly [];
|
670
704
|
|
671
705
|
declare const propNames_2: readonly ["value", "onSelect"];
|
@@ -676,28 +710,195 @@ declare const propNames_3: readonly ["editor"];
|
|
676
710
|
export { propNames_3 as propNames_alias_3 }
|
677
711
|
export { propNames_3 as propNames_alias_4 }
|
678
712
|
|
713
|
+
/**
|
714
|
+
* @internal
|
715
|
+
*/
|
679
716
|
declare const propNames_4: readonly ["onSelect"];
|
680
717
|
export { propNames_4 as propNames_alias_8 }
|
681
718
|
export { propNames_4 as propNames_alias_9 }
|
682
719
|
|
720
|
+
/**
|
721
|
+
* @internal
|
722
|
+
*/
|
683
723
|
declare const propNames_5: never[];
|
684
724
|
export { propNames_5 as propNames_alias_10 }
|
685
725
|
export { propNames_5 as propNames_alias_11 }
|
686
726
|
|
727
|
+
/**
|
728
|
+
* @internal
|
729
|
+
*/
|
730
|
+
declare const propNames_6: readonly ["width", "height", "aspectRatio", "onSizeChangeStart", "onSizeChange", "onSizeChangeEnd"];
|
731
|
+
export { propNames_6 as propNames_alias_14 }
|
732
|
+
export { propNames_6 as propNames_alias_15 }
|
733
|
+
|
734
|
+
/**
|
735
|
+
* @internal
|
736
|
+
*/
|
737
|
+
declare const propNames_7: readonly [];
|
738
|
+
export { propNames_7 as propNames_alias_16 }
|
739
|
+
export { propNames_7 as propNames_alias_17 }
|
740
|
+
|
687
741
|
export declare const propNames_alias_12: readonly ["editor", "popoverOptions"];
|
688
742
|
|
689
743
|
export declare const propNames_alias_13: readonly ["active", "reference", "options", "autoUpdate", "autoUpdateOptions"];
|
690
744
|
|
691
745
|
export declare const propNames_alias_5: readonly ["editor", "regex", "popoverOptions"];
|
692
746
|
|
747
|
+
/**
|
748
|
+
* @internal
|
749
|
+
*/
|
693
750
|
export declare const propNames_alias_6: readonly ["onDismiss"];
|
694
751
|
|
752
|
+
/**
|
753
|
+
* @internal
|
754
|
+
*/
|
695
755
|
export declare const propNames_alias_7: readonly ["placeholder"];
|
696
756
|
|
697
757
|
export declare function queryClosestAutocompleteItem(element?: Element | null): AutocompleteItem | null;
|
698
758
|
|
699
759
|
export declare function queryClosestComboBoxItem(element?: Element | null): ComboBoxItem | null;
|
700
760
|
|
761
|
+
/**
|
762
|
+
* @public
|
763
|
+
*/
|
764
|
+
declare class Resizable extends LightElement implements Partial<ResizableProps> {
|
765
|
+
/**
|
766
|
+
* @hidden
|
767
|
+
*/
|
768
|
+
static properties: {
|
769
|
+
width: {
|
770
|
+
attribute: false;
|
771
|
+
};
|
772
|
+
height: {
|
773
|
+
attribute: false;
|
774
|
+
};
|
775
|
+
aspectRatio: {
|
776
|
+
attribute: false;
|
777
|
+
};
|
778
|
+
onResize: {
|
779
|
+
attribute: false;
|
780
|
+
};
|
781
|
+
onResizeEnd: {
|
782
|
+
attribute: false;
|
783
|
+
};
|
784
|
+
resizing: {
|
785
|
+
attribute: string;
|
786
|
+
type: BooleanConstructor;
|
787
|
+
reflect: true;
|
788
|
+
};
|
789
|
+
};
|
790
|
+
width?: number | string;
|
791
|
+
height?: number | string;
|
792
|
+
aspectRatio?: number;
|
793
|
+
resizing?: boolean;
|
794
|
+
onSizeChangeStart?: (size: {
|
795
|
+
width: number;
|
796
|
+
height: number;
|
797
|
+
}) => void;
|
798
|
+
onSizeChange?: (size: {
|
799
|
+
width: number;
|
800
|
+
height: number;
|
801
|
+
}) => void | {
|
802
|
+
width?: number | string;
|
803
|
+
height?: number | string;
|
804
|
+
};
|
805
|
+
onSizeChangeEnd?: (size: {
|
806
|
+
width: number;
|
807
|
+
height: number;
|
808
|
+
}) => void;
|
809
|
+
private context;
|
810
|
+
private startWidth;
|
811
|
+
private startHeight;
|
812
|
+
private handleResizeStart;
|
813
|
+
private handleResize;
|
814
|
+
private handleResizeEnd;
|
815
|
+
private updateStyle;
|
816
|
+
/**
|
817
|
+
* @hidden
|
818
|
+
*/
|
819
|
+
connectedCallback(): void;
|
820
|
+
/**
|
821
|
+
* @hidden
|
822
|
+
*/
|
823
|
+
protected updated(changedProperties: PropertyValues<this>): void;
|
824
|
+
}
|
825
|
+
export { Resizable }
|
826
|
+
export { Resizable as Resizable_alias_1 }
|
827
|
+
|
828
|
+
/**
|
829
|
+
* @internal
|
830
|
+
*/
|
831
|
+
export declare interface ResizableContext {
|
832
|
+
onResizeStart: () => readonly [
|
833
|
+
width: number,
|
834
|
+
height: number,
|
835
|
+
aspectRatio: number
|
836
|
+
];
|
837
|
+
onResize: (width: number, height: number) => void;
|
838
|
+
onResizeEnd: () => void;
|
839
|
+
}
|
840
|
+
|
841
|
+
/**
|
842
|
+
* @internal
|
843
|
+
*/
|
844
|
+
export declare const resizableContext: {
|
845
|
+
__context__: ResizableContext;
|
846
|
+
};
|
847
|
+
|
848
|
+
/**
|
849
|
+
* @public
|
850
|
+
*/
|
851
|
+
declare class ResizableHandle extends LightElement implements Partial<ResizableHandleProps> {
|
852
|
+
private context;
|
853
|
+
/**
|
854
|
+
* @hidden
|
855
|
+
*/
|
856
|
+
static properties: {
|
857
|
+
position: {
|
858
|
+
attribute: false;
|
859
|
+
};
|
860
|
+
};
|
861
|
+
position?: ResizableHandleProps['position'];
|
862
|
+
connectedCallback(): void;
|
863
|
+
}
|
864
|
+
export { ResizableHandle }
|
865
|
+
export { ResizableHandle as ResizableHandle_alias_1 }
|
866
|
+
|
867
|
+
/**
|
868
|
+
* @internal
|
869
|
+
*/
|
870
|
+
declare type ResizableHandleProps = {
|
871
|
+
position: 'top' | 'right' | 'bottom' | 'left' | 'top-left' | 'top-right' | 'bottom-right' | 'bottom-left';
|
872
|
+
};
|
873
|
+
export { ResizableHandleProps }
|
874
|
+
export { ResizableHandleProps as ResizableHandleProps_alias_1 }
|
875
|
+
|
876
|
+
/**
|
877
|
+
* @public
|
878
|
+
*/
|
879
|
+
declare interface ResizableProps {
|
880
|
+
width?: string | number;
|
881
|
+
height?: string | number;
|
882
|
+
aspectRatio?: number;
|
883
|
+
onSizeChangeStart?: (size: {
|
884
|
+
width: number;
|
885
|
+
height: number;
|
886
|
+
}) => void;
|
887
|
+
onSizeChange?: (size: {
|
888
|
+
width: number;
|
889
|
+
height: number;
|
890
|
+
}) => void | {
|
891
|
+
width?: number | string;
|
892
|
+
height?: number | string;
|
893
|
+
};
|
894
|
+
onSizeChangeEnd?: (size: {
|
895
|
+
width: number;
|
896
|
+
height: number;
|
897
|
+
}) => void;
|
898
|
+
}
|
899
|
+
export { ResizableProps }
|
900
|
+
export { ResizableProps as ResizableProps_alias_1 }
|
901
|
+
|
701
902
|
/** Rounds a value to the nearest device pixel ratio. */
|
702
903
|
export declare function roundByDPR(value: number): number;
|
703
904
|
|
@@ -14,12 +14,20 @@ import "lit";
|
|
14
14
|
|
15
15
|
// src/components/inline-popover/helpers.ts
|
16
16
|
import { isNodeSelection, isTextSelection } from "@prosekit/core";
|
17
|
+
|
18
|
+
// src/utils/is-in-code-block.ts
|
19
|
+
function isInCodeBlock(selection) {
|
20
|
+
const type = selection.$from.parent.type;
|
21
|
+
return type.spec.code && type.isBlock;
|
22
|
+
}
|
23
|
+
|
24
|
+
// src/components/inline-popover/helpers.ts
|
17
25
|
function getVirtualSelectionElement(view) {
|
18
26
|
if (typeof window === "undefined" || view.isDestroyed) {
|
19
27
|
return;
|
20
28
|
}
|
21
29
|
const selection = view.state.selection;
|
22
|
-
if (!selection.empty && (isTextSelection(selection) || isNodeSelection(selection))) {
|
30
|
+
if (!selection.empty && !isInCodeBlock(selection) && (isTextSelection(selection) || isNodeSelection(selection))) {
|
23
31
|
return getDomRange();
|
24
32
|
}
|
25
33
|
}
|
@@ -0,0 +1,159 @@
|
|
1
|
+
import {
|
2
|
+
resizableContext
|
3
|
+
} from "./chunk-WEUGKLVB.js";
|
4
|
+
import {
|
5
|
+
LightElement,
|
6
|
+
defineCustomElement
|
7
|
+
} from "./chunk-S32IZIQF.js";
|
8
|
+
|
9
|
+
// src/components/resizable-handle/component.ts
|
10
|
+
import { ContextConsumer } from "@lit/context";
|
11
|
+
|
12
|
+
// src/utils/is-finite-positive-number.ts
|
13
|
+
function isFinitePositiveNumber(value) {
|
14
|
+
return typeof value === "number" && Number.isFinite(value) && value > 0;
|
15
|
+
}
|
16
|
+
|
17
|
+
// src/components/resizable-handle/calc-resize.ts
|
18
|
+
function calcResize(position, w, h, dx, dy, aspectRatio) {
|
19
|
+
aspectRatio = aspectRatio ? aspectRatio : w / h;
|
20
|
+
aspectRatio = isFinitePositiveNumber(aspectRatio) ? aspectRatio : 1;
|
21
|
+
switch (position) {
|
22
|
+
case "bottom-right":
|
23
|
+
return calcBottomRightResize(w, h, dx, dy, aspectRatio);
|
24
|
+
case "bottom-left":
|
25
|
+
return calcBottomLeftResize(w, h, dx, dy, aspectRatio);
|
26
|
+
case "top-right":
|
27
|
+
return calcTopRightResize(w, h, dx, dy, aspectRatio);
|
28
|
+
case "top-left":
|
29
|
+
return calcTopLeftResize(w, h, dx, dy, aspectRatio);
|
30
|
+
case "top":
|
31
|
+
return calcTopResize(w, h, dx, dy, aspectRatio);
|
32
|
+
case "right":
|
33
|
+
return calcRightResize(w, h, dx, dy, aspectRatio);
|
34
|
+
case "bottom":
|
35
|
+
return calcBottomResize(w, h, dx, dy, aspectRatio);
|
36
|
+
case "left":
|
37
|
+
return calcLeftResize(w, h, dx, dy, aspectRatio);
|
38
|
+
default:
|
39
|
+
throw new RangeError(`Invalid position: ${position}`);
|
40
|
+
}
|
41
|
+
}
|
42
|
+
var calcBottomRightResize = (w, h, dx, dy, r) => {
|
43
|
+
w += dx;
|
44
|
+
h += dy;
|
45
|
+
const sum = w + h;
|
46
|
+
h = sum / (r + 1);
|
47
|
+
w = sum - h;
|
48
|
+
return [w, h];
|
49
|
+
};
|
50
|
+
var calcBottomLeftResize = (w, h, dx, dy, r) => {
|
51
|
+
w -= dx;
|
52
|
+
h += dy;
|
53
|
+
const sum = w + h;
|
54
|
+
h = sum / (r + 1);
|
55
|
+
w = sum - h;
|
56
|
+
return [w, h];
|
57
|
+
};
|
58
|
+
var calcTopRightResize = (w, h, dx, dy, r) => {
|
59
|
+
w += dx;
|
60
|
+
h -= dy;
|
61
|
+
const sum = w + h;
|
62
|
+
h = sum / (r + 1);
|
63
|
+
w = sum - h;
|
64
|
+
return [w, h];
|
65
|
+
};
|
66
|
+
var calcTopLeftResize = (w, h, dx, dy, r) => {
|
67
|
+
w -= dx;
|
68
|
+
h -= dy;
|
69
|
+
const sum = w + h;
|
70
|
+
h = sum / (r + 1);
|
71
|
+
w = sum - h;
|
72
|
+
return [w, h];
|
73
|
+
};
|
74
|
+
var calcTopResize = (w, h, dx, dy, r) => {
|
75
|
+
h -= dy;
|
76
|
+
w = h * r;
|
77
|
+
return [w, h];
|
78
|
+
};
|
79
|
+
var calcRightResize = (w, h, dx, dy, r) => {
|
80
|
+
w += dx;
|
81
|
+
h = w / r;
|
82
|
+
return [w, h];
|
83
|
+
};
|
84
|
+
var calcBottomResize = (w, h, dx, dy, r) => {
|
85
|
+
h += dy;
|
86
|
+
w = h * r;
|
87
|
+
return [w, h];
|
88
|
+
};
|
89
|
+
var calcLeftResize = (w, h, dx, dy, r) => {
|
90
|
+
w -= dx;
|
91
|
+
h = w / r;
|
92
|
+
return [w, h];
|
93
|
+
};
|
94
|
+
|
95
|
+
// src/components/resizable-handle/component.ts
|
96
|
+
var propNames = [];
|
97
|
+
var ResizableHandle = class extends LightElement {
|
98
|
+
constructor() {
|
99
|
+
super(...arguments);
|
100
|
+
this.context = new ContextConsumer(this, {
|
101
|
+
context: resizableContext
|
102
|
+
});
|
103
|
+
}
|
104
|
+
connectedCallback() {
|
105
|
+
super.connectedCallback();
|
106
|
+
let startX = 0;
|
107
|
+
let startY = 0;
|
108
|
+
let width = 0;
|
109
|
+
let height = 0;
|
110
|
+
let aspectRatio = 1;
|
111
|
+
const handlePointerMove = (event) => {
|
112
|
+
var _a;
|
113
|
+
event.preventDefault();
|
114
|
+
const dx = event.x - startX;
|
115
|
+
const dy = event.y - startY;
|
116
|
+
const [w, h] = calcResize(
|
117
|
+
this.position || "bottom-right",
|
118
|
+
width,
|
119
|
+
height,
|
120
|
+
dx,
|
121
|
+
dy,
|
122
|
+
aspectRatio
|
123
|
+
);
|
124
|
+
(_a = this.context.value) == null ? void 0 : _a.onResize(w, h);
|
125
|
+
};
|
126
|
+
const handlePointerDown = (event) => {
|
127
|
+
var _a;
|
128
|
+
event.preventDefault();
|
129
|
+
startX = event.x;
|
130
|
+
startY = event.y;
|
131
|
+
const size = (_a = this.context.value) == null ? void 0 : _a.onResizeStart();
|
132
|
+
if (size) {
|
133
|
+
;
|
134
|
+
[width, height, aspectRatio] = size;
|
135
|
+
}
|
136
|
+
this.ownerDocument.addEventListener("pointermove", handlePointerMove);
|
137
|
+
this.ownerDocument.addEventListener("pointerup", handlePointerUp);
|
138
|
+
};
|
139
|
+
const handlePointerUp = (event) => {
|
140
|
+
var _a;
|
141
|
+
event.preventDefault();
|
142
|
+
(_a = this.context.value) == null ? void 0 : _a.onResizeEnd();
|
143
|
+
this.ownerDocument.removeEventListener("pointermove", handlePointerMove);
|
144
|
+
this.ownerDocument.removeEventListener("pointerup", handlePointerUp);
|
145
|
+
};
|
146
|
+
this.addEventListener("pointerdown", handlePointerDown);
|
147
|
+
}
|
148
|
+
};
|
149
|
+
/**
|
150
|
+
* @hidden
|
151
|
+
*/
|
152
|
+
ResizableHandle.properties = {
|
153
|
+
position: { attribute: false }
|
154
|
+
};
|
155
|
+
defineCustomElement("prosekit-resizable-handle", ResizableHandle);
|
156
|
+
export {
|
157
|
+
ResizableHandle,
|
158
|
+
propNames
|
159
|
+
};
|
@@ -0,0 +1,107 @@
|
|
1
|
+
import {
|
2
|
+
resizableContext
|
3
|
+
} from "./chunk-WEUGKLVB.js";
|
4
|
+
import {
|
5
|
+
LightElement,
|
6
|
+
defineCustomElement
|
7
|
+
} from "./chunk-S32IZIQF.js";
|
8
|
+
|
9
|
+
// src/components/resizable/component.ts
|
10
|
+
import { ContextProvider } from "@lit/context";
|
11
|
+
var propNames = [
|
12
|
+
"width",
|
13
|
+
"height",
|
14
|
+
"aspectRatio",
|
15
|
+
"onSizeChangeStart",
|
16
|
+
"onSizeChange",
|
17
|
+
"onSizeChangeEnd"
|
18
|
+
];
|
19
|
+
var Resizable = class extends LightElement {
|
20
|
+
constructor() {
|
21
|
+
super(...arguments);
|
22
|
+
this.context = new ContextProvider(this, {
|
23
|
+
context: resizableContext,
|
24
|
+
initialValue: {
|
25
|
+
onResizeStart: () => this.handleResizeStart(),
|
26
|
+
onResize: (w, h) => this.handleResize(w, h),
|
27
|
+
onResizeEnd: () => this.handleResizeEnd()
|
28
|
+
}
|
29
|
+
});
|
30
|
+
this.startWidth = 0;
|
31
|
+
this.startHeight = 0;
|
32
|
+
}
|
33
|
+
handleResizeStart() {
|
34
|
+
var _a, _b;
|
35
|
+
const { width, height } = this.getBoundingClientRect();
|
36
|
+
this.startWidth = width;
|
37
|
+
this.startHeight = height;
|
38
|
+
(_a = this.onSizeChangeStart) == null ? void 0 : _a.call(this, { width, height });
|
39
|
+
this.resizing = true;
|
40
|
+
return [width, height, (_b = this.aspectRatio) != null ? _b : width / height];
|
41
|
+
}
|
42
|
+
handleResize(width, height) {
|
43
|
+
var _a, _b, _c;
|
44
|
+
const output = (_a = this.onSizeChange) == null ? void 0 : _a.call(this, { width, height });
|
45
|
+
this.width = (_b = output == null ? void 0 : output.width) != null ? _b : width;
|
46
|
+
this.height = (_c = output == null ? void 0 : output.height) != null ? _c : height;
|
47
|
+
}
|
48
|
+
handleResizeEnd() {
|
49
|
+
var _a;
|
50
|
+
const { width, height } = this.getBoundingClientRect();
|
51
|
+
this.resizing = false;
|
52
|
+
(_a = this.onSizeChangeEnd) == null ? void 0 : _a.call(this, { width, height });
|
53
|
+
}
|
54
|
+
updateStyle() {
|
55
|
+
const w = this.width;
|
56
|
+
const h = this.height;
|
57
|
+
const r = this.aspectRatio;
|
58
|
+
if (w != null && w !== "" && Number.isFinite(w)) {
|
59
|
+
this.style.width = typeof w === "number" ? `${w}px` : w;
|
60
|
+
} else {
|
61
|
+
this.style.width = "";
|
62
|
+
}
|
63
|
+
if (h != null && h !== "" && Number.isFinite(h)) {
|
64
|
+
this.style.height = typeof h === "number" ? `${h}px` : h;
|
65
|
+
} else {
|
66
|
+
this.style.height = "";
|
67
|
+
}
|
68
|
+
if (r && Number.isFinite(r)) {
|
69
|
+
this.style.aspectRatio = `${r}`;
|
70
|
+
if (this.style.width && this.startWidth >= this.startHeight && r >= 1) {
|
71
|
+
this.style.height = "auto";
|
72
|
+
} else if (this.style.height && this.startWidth <= this.startHeight && r <= 1) {
|
73
|
+
this.style.width = "auto";
|
74
|
+
}
|
75
|
+
}
|
76
|
+
}
|
77
|
+
/**
|
78
|
+
* @hidden
|
79
|
+
*/
|
80
|
+
connectedCallback() {
|
81
|
+
super.connectedCallback();
|
82
|
+
this.updateStyle();
|
83
|
+
}
|
84
|
+
/**
|
85
|
+
* @hidden
|
86
|
+
*/
|
87
|
+
updated(changedProperties) {
|
88
|
+
super.updated(changedProperties);
|
89
|
+
this.updateStyle();
|
90
|
+
}
|
91
|
+
};
|
92
|
+
/**
|
93
|
+
* @hidden
|
94
|
+
*/
|
95
|
+
Resizable.properties = {
|
96
|
+
width: { attribute: false },
|
97
|
+
height: { attribute: false },
|
98
|
+
aspectRatio: { attribute: false },
|
99
|
+
onResize: { attribute: false },
|
100
|
+
onResizeEnd: { attribute: false },
|
101
|
+
resizing: { attribute: "data-resizing", type: Boolean, reflect: true }
|
102
|
+
};
|
103
|
+
defineCustomElement("prosekit-resizable", Resizable);
|
104
|
+
export {
|
105
|
+
Resizable,
|
106
|
+
propNames
|
107
|
+
};
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@prosekit/lit",
|
3
3
|
"type": "module",
|
4
|
-
"version": "0.1.
|
4
|
+
"version": "0.1.8",
|
5
5
|
"private": false,
|
6
6
|
"author": {
|
7
7
|
"name": "ocavue",
|
@@ -79,16 +79,26 @@
|
|
79
79
|
"types": "./dist/prosekit-lit-popover.d.ts",
|
80
80
|
"import": "./dist/prosekit-lit-popover.js",
|
81
81
|
"default": "./dist/prosekit-lit-popover.js"
|
82
|
+
},
|
83
|
+
"./resizable": {
|
84
|
+
"types": "./dist/prosekit-lit-resizable.d.ts",
|
85
|
+
"import": "./dist/prosekit-lit-resizable.js",
|
86
|
+
"default": "./dist/prosekit-lit-resizable.js"
|
87
|
+
},
|
88
|
+
"./resizable-handle": {
|
89
|
+
"types": "./dist/prosekit-lit-resizable-handle.d.ts",
|
90
|
+
"import": "./dist/prosekit-lit-resizable-handle.js",
|
91
|
+
"default": "./dist/prosekit-lit-resizable-handle.js"
|
82
92
|
}
|
83
93
|
},
|
84
94
|
"files": [
|
85
95
|
"dist"
|
86
96
|
],
|
87
97
|
"dependencies": {
|
88
|
-
"@floating-ui/dom": "^1.5.
|
98
|
+
"@floating-ui/dom": "^1.5.4",
|
89
99
|
"@lit/context": "^1.1.0",
|
90
|
-
"@prosekit/core": "^0.2.
|
91
|
-
"@prosekit/extensions": "^0.2.
|
100
|
+
"@prosekit/core": "^0.2.2",
|
101
|
+
"@prosekit/extensions": "^0.2.2",
|
92
102
|
"@prosekit/pm": "^0.1.1",
|
93
103
|
"@superhuman/command-score": "^0.5.0",
|
94
104
|
"lit": "^3.1.0"
|
@@ -98,7 +108,7 @@
|
|
98
108
|
"minify-literals": "^1.0.8",
|
99
109
|
"tsup": "^8.0.1",
|
100
110
|
"typescript": "^5.3.3",
|
101
|
-
"vitest": "^1.1.
|
111
|
+
"vitest": "^1.1.3"
|
102
112
|
},
|
103
113
|
"scripts": {
|
104
114
|
"build:tsup": "tsup",
|
@@ -139,6 +149,12 @@
|
|
139
149
|
],
|
140
150
|
"popover": [
|
141
151
|
"./dist/prosekit-lit-popover.d.ts"
|
152
|
+
],
|
153
|
+
"resizable": [
|
154
|
+
"./dist/prosekit-lit-resizable.d.ts"
|
155
|
+
],
|
156
|
+
"resizable-handle": [
|
157
|
+
"./dist/prosekit-lit-resizable-handle.d.ts"
|
142
158
|
]
|
143
159
|
}
|
144
160
|
}
|