@prosekit/lit 0.2.0 → 0.2.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.
@@ -922,6 +922,9 @@ export declare function roundByDPR(value: number): number;
922
922
 
923
923
  export declare function setFloatingStyles(element: HTMLElement, options: PositioningOptions): void;
924
924
 
925
+ /**
926
+ * @internal
927
+ */
925
928
  export declare function useDismissable(host: LitElement, { onEscapeKeyDown, onPointerDownOutside, onDismiss, getReference, }: {
926
929
  onEscapeKeyDown: (event: KeyboardEvent) => void;
927
930
  onPointerDownOutside: (event: Event) => void;
@@ -929,16 +932,34 @@ export declare function useDismissable(host: LitElement, { onEscapeKeyDown, onPo
929
932
  getReference?: () => ReferenceElement | null | undefined;
930
933
  }): void;
931
934
 
935
+ /**
936
+ * @internal
937
+ */
932
938
  export declare function useEditorExtension(host: WithEditor<ReactiveControllerHost>, extension: Extension): void;
933
939
 
940
+ /**
941
+ * @internal
942
+ */
934
943
  export declare function useEditorFocusChangeEvent(host: WithEditor<ReactiveControllerHost>, handler: FocusChangeHandler): void;
935
944
 
945
+ /**
946
+ * @internal
947
+ */
936
948
  export declare function useEditorUpdateEvent(host: WithEditor<ReactiveControllerHost>, handler: UpdateHandler): void;
937
949
 
950
+ /**
951
+ * @internal
952
+ */
938
953
  export declare function useEffect<T>(host: ReactiveControllerHost, getValue: () => T, onChange: (value: T) => void): void;
939
954
 
955
+ /**
956
+ * @internal
957
+ */
940
958
  export declare function useInlinePopover(host: WithEditor<LitElement>, onReferenceChange: (reference: ReferenceElement | undefined) => void): () => ReferenceElement | undefined;
941
959
 
960
+ /**
961
+ * @internal
962
+ */
942
963
  export declare function usePointerDownEvent(host: LitElement, handler: (event: PointerEvent) => void): void;
943
964
 
944
965
  export declare function usePopover(host: LitElement, getReference: () => ReferenceElement | null, getPositioning: () => PositioningOptions | null): void;
@@ -58,18 +58,6 @@ function useEditorUpdateEvent(host, handler) {
58
58
  useEditorExtension(host, extension);
59
59
  }
60
60
 
61
- // src/controllers/use-pointer-down-event.ts
62
- function usePointerDownEvent(host, handler) {
63
- host.addController({
64
- hostConnected: () => {
65
- host.addEventListener("pointerdown", handler);
66
- },
67
- hostDisconnected: () => {
68
- host.removeEventListener("pointerdown", handler);
69
- }
70
- });
71
- }
72
-
73
61
  // src/components/inline-popover/helpers.ts
74
62
  import { isNodeSelection, isTextSelection } from "@prosekit/core";
75
63
 
@@ -110,20 +98,17 @@ function getDomRange() {
110
98
 
111
99
  // src/components/inline-popover/use-inline-popover.ts
112
100
  function useInlinePopover(host, onReferenceChange) {
113
- let interacting = false;
114
101
  let reference;
115
- usePointerDownEvent(host, () => {
116
- interacting = true;
117
- });
102
+ let editorFocused = false;
103
+ const isPopoverFocused = () => {
104
+ return !editorFocused && host.contains(host.ownerDocument.activeElement);
105
+ };
118
106
  useEditorFocusChangeEvent(host, (focus) => {
119
- if (focus) {
120
- interacting = false;
121
- }
107
+ editorFocused = focus;
122
108
  });
123
109
  useEditorUpdateEvent(host, (view) => {
124
- if (interacting) {
110
+ if (isPopoverFocused())
125
111
  return;
126
- }
127
112
  const ref = getVirtualSelectionElement(view);
128
113
  if (reference !== ref) {
129
114
  reference = ref;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@prosekit/lit",
3
3
  "type": "module",
4
- "version": "0.2.0",
4
+ "version": "0.2.1",
5
5
  "private": false,
6
6
  "author": {
7
7
  "name": "ocavue",
@@ -95,15 +95,15 @@
95
95
  "dist"
96
96
  ],
97
97
  "dependencies": {
98
- "@floating-ui/dom": "^1.5.3",
98
+ "@floating-ui/dom": "^1.5.4",
99
99
  "@lit/context": "^1.1.0",
100
- "@prosekit/core": "^0.2.4",
101
- "@prosekit/extensions": "^0.2.4",
100
+ "@prosekit/core": "^0.2.6",
101
+ "@prosekit/extensions": "^0.2.5",
102
102
  "@prosekit/pm": "^0.1.1",
103
103
  "@superhuman/command-score": "^0.5.0",
104
- "@zag-js/dismissable": "^0.32.0",
105
- "@zag-js/dom-query": "^0.32.0",
106
- "@zag-js/utils": "^0.32.0",
104
+ "@zag-js/dismissable": "^0.32.1",
105
+ "@zag-js/dom-query": "^0.32.1",
106
+ "@zag-js/utils": "^0.32.1",
107
107
  "lit": "^3.1.1"
108
108
  },
109
109
  "devDependencies": {
@@ -111,7 +111,7 @@
111
111
  "minify-literals": "^1.0.8",
112
112
  "tsup": "^8.0.1",
113
113
  "typescript": "^5.3.3",
114
- "vitest": "^1.2.0"
114
+ "vitest": "^1.2.1"
115
115
  },
116
116
  "scripts": {
117
117
  "build:tsup": "tsup",
package/src/index.ts DELETED
@@ -1 +0,0 @@
1
- export {}