@prosekit/web
Advanced tools
Comparing version 0.0.0-next-20240605080819 to 0.0.0-next-20240616145703
@@ -323,3 +323,4 @@ import { BaseElement } from '@aria-ui/core'; | ||
editor: null; | ||
open: true; | ||
defaultOpen: true; | ||
open: false; | ||
onOpenChange: null; | ||
@@ -439,2 +440,13 @@ placement: "top"; | ||
/** | ||
* Whether the popover is open by default when some inline content is | ||
* selected. | ||
* | ||
* When `defaultOpen` is true, the popover will open or close based on the | ||
* inline selection. When `defaultOpen` is false, the popover will never be | ||
* opened unless the `open` prop is true. | ||
* | ||
* @default true | ||
*/ | ||
defaultOpen: boolean; | ||
/** | ||
* Whether the popover is open. | ||
@@ -444,7 +456,7 @@ * | ||
* | ||
* @default `true` | ||
* @default false | ||
*/ | ||
open: boolean; | ||
/** | ||
* A callback that is called when the popover's open state changes. | ||
* Event handler called when the open state changed caused by user interaction (i.e. select or unselect inline content). | ||
* | ||
@@ -451,0 +463,0 @@ * @default null |
import { | ||
useEditorExtension | ||
} from "./chunk-VJEVDINM.js"; | ||
} from "./chunk-MZSYOTZT.js"; | ||
import { | ||
@@ -58,3 +58,3 @@ defineCustomElement | ||
var _a; | ||
!value.peek() && open.value && (value.value = (_a = element.textContent) != null ? _a : ""); | ||
!value.peek() && open.get() && value.set((_a = element.textContent) != null ? _a : ""); | ||
}), { onSelect, value }; | ||
@@ -105,12 +105,12 @@ } | ||
return useEffect2(element, () => { | ||
listboxQuery.value = query.value; | ||
listboxQuery.set(query.get()); | ||
}), useEffect2(element, () => { | ||
open.value || (listboxValue.value = "", query.value = ""); | ||
open.get() || (listboxValue.set(""), query.set("")); | ||
}), useEffect2(element, () => { | ||
if (!open.value) | ||
autoFocus.value = !1; | ||
if (!open.get()) | ||
autoFocus.set(!1); | ||
else { | ||
let canceled = !1; | ||
return requestAnimationFrame(() => { | ||
canceled || (autoFocus.value = !0); | ||
canceled || autoFocus.set(!0); | ||
}), () => { | ||
@@ -129,3 +129,3 @@ canceled = !0; | ||
return useEffect2(element, () => { | ||
let editorValue = editor.value, keydownHandlerValue = keydownHandler.value; | ||
let editorValue = editor.get(), keydownHandlerValue = keydownHandler.get(); | ||
if (!editorValue || !keydownHandlerValue) | ||
@@ -135,3 +135,3 @@ return; | ||
"keydown", | ||
(view, event) => view.composing || event.defaultPrevented || !open.value ? !1 : (keydownHandlerValue(event), event.defaultPrevented) | ||
(view, event) => view.composing || event.defaultPrevented || !open.get() ? !1 : (keydownHandlerValue(event), event.defaultPrevented) | ||
); | ||
@@ -141,3 +141,3 @@ disposeKeydownHandler == null || disposeKeydownHandler(), disposeKeydownHandler = editorValue.use( | ||
); | ||
}), (keydownHandlerValue) => (keydownHandler.value = keydownHandlerValue, () => { | ||
}), (keydownHandlerValue) => (keydownHandler.set(keydownHandlerValue), () => { | ||
disposeKeydownHandler == null || disposeKeydownHandler(), disposeKeydownHandler = null; | ||
@@ -202,3 +202,3 @@ }); | ||
requestAnimationFrame(() => { | ||
firstRendering.value = !1; | ||
firstRendering.set(!1); | ||
}); | ||
@@ -219,3 +219,3 @@ }), firstRendering; | ||
function useAutocompletePopoverState(host, state) { | ||
let { editor, regex, ...overlayState } = state, reference = createSignal3(null), query = createSignal3(""), onDismiss = createSignal3(null), onSubmit = createSignal3(null), presence = createComputed(() => !!reference.value); | ||
let { editor, regex, ...overlayState } = state, reference = createSignal3(null), query = createSignal3(""), onDismiss = createSignal3(null), onSubmit = createSignal3(null), presence = createComputed(() => !!reference.get()); | ||
queryContext.provide(host, query), onSubmitContext.provide(host, onSubmit), openContext.provide(host, presence), useEscapeKeydown(host, editor, createKeymapHandler(onDismiss, presence)), useAutocompleteExtension( | ||
@@ -233,6 +233,6 @@ host, | ||
var _a; | ||
let queryValue = query.value; | ||
let queryValue = query.get(); | ||
firstRendering.peek() || (_a = state.onQueryChange.peek()) == null || _a(queryValue); | ||
}), useAnimationFrame(host, () => { | ||
let presenceValue = presence.value, onOpenChangeValue = state.onOpenChange.peek(); | ||
let presenceValue = presence.get(), onOpenChangeValue = state.onOpenChange.peek(); | ||
if (onOpenChangeValue) | ||
@@ -246,3 +246,3 @@ return () => { | ||
useEffect4(host, () => { | ||
let editorValue = editor.value, regexValue = regex.value; | ||
let editorValue = editor.get(), regexValue = regex.get(); | ||
if (!(!editorValue || !regexValue)) | ||
@@ -262,5 +262,5 @@ return addAutocompleteExtension( | ||
let span = editor.view.dom.querySelector(".prosemirror-prediction-match"); | ||
span && (reference.value = span), query.value = defaultQueryBuilder(options.match), onDismiss.value = options.ignoreMatch, onSubmit.value = options.deleteMatch; | ||
span && reference.set(span), query.set(defaultQueryBuilder(options.match)), onDismiss.set(options.ignoreMatch), onSubmit.set(options.deleteMatch); | ||
}, handleLeave = () => { | ||
reference.value = null, query.value = "", onDismiss.value = null, onSubmit.value = null; | ||
reference.set(null), query.set(""), onDismiss.set(null), onSubmit.set(null); | ||
}, rule = new AutocompleteRule({ | ||
@@ -275,3 +275,3 @@ regex, | ||
return () => { | ||
if (!enabled.value) | ||
if (!enabled.get()) | ||
return !1; | ||
@@ -278,0 +278,0 @@ let fn = handler.peek(); |
import { | ||
useEditorExtension | ||
} from "./chunk-VJEVDINM.js"; | ||
} from "./chunk-MZSYOTZT.js"; | ||
import { | ||
@@ -44,3 +44,3 @@ defineCustomElement | ||
var _a, _b; | ||
let { pos } = (_a = context.value) != null ? _a : {}, { view } = (_b = state.editor.value) != null ? _b : {}; | ||
let { pos } = (_a = context.get()) != null ? _a : {}, { view } = (_b = state.editor.get()) != null ? _b : {}; | ||
pos == null || view == null || (view.dispatch( | ||
@@ -53,3 +53,3 @@ view.state.tr.setSelection(NodeSelection.create(view.state.doc, pos)) | ||
var _a, _b; | ||
let { pos, element, node } = (_a = context.value) != null ? _a : {}, { view } = (_b = state.editor.value) != null ? _b : {}; | ||
let { pos, element, node } = (_a = context.get()) != null ? _a : {}, { view } = (_b = state.editor.get()) != null ? _b : {}; | ||
pos == null || !element || !node || !view || !event.dataTransfer || (event.dataTransfer.clearData(), event.dataTransfer.setData("text/html", element.outerHTML), event.dataTransfer.effectAllowed = "copyMove", event.dataTransfer.setDragImage(element, 0, 0), view.dragging = { | ||
@@ -164,8 +164,8 @@ slice: new Slice(Fragment.from(node), 0, 0), | ||
useEffect2(host, () => { | ||
open.value = !!context.value.element; | ||
open.set(!!context.get().element); | ||
}), useHoverExtension(host, editor, (referenceValue, element, node, pos) => { | ||
reference.value = referenceValue, context.value = { element, node, pos }; | ||
reference.set(referenceValue), context.set({ element, node, pos }); | ||
}); | ||
let presence = createComputed(() => !!reference.value); | ||
return useAttribute(host, "data-state", () => presence.value ? "open" : "closed"), usePresence(host, presence), state; | ||
let presence = createComputed(() => !!reference.get()); | ||
return useAttribute(host, "data-state", () => presence.get() ? "open" : "closed"), usePresence(host, presence), state; | ||
} | ||
@@ -172,0 +172,0 @@ function useHoverExtension(host, editor, handler) { |
import { | ||
useEditorExtension | ||
} from "./chunk-VJEVDINM.js"; | ||
} from "./chunk-MZSYOTZT.js"; | ||
import { | ||
@@ -16,3 +16,4 @@ defineCustomElement | ||
editor: null, | ||
open: !0, | ||
defaultOpen: !0, | ||
open: !1, | ||
onOpenChange: null, | ||
@@ -116,10 +117,10 @@ placement: "top", | ||
function useInlinePopoverState(host, state) { | ||
let { editor, open, onOpenChange, ...overlayState } = state, reference = useInlinePopoverReference(host, editor); | ||
useOverlayPositionerState(host, overlayState, { reference }); | ||
let presence = createComputed(() => !!reference.value && open.value); | ||
useAttribute(host, "data-state", () => presence.value ? "open" : "closed"), usePresence(host, presence), useEffect(host, () => { | ||
var _a; | ||
let presenceValue = presence.value; | ||
(_a = onOpenChange.peek()) == null || _a(presenceValue); | ||
}); | ||
let { editor, defaultOpen, open, onOpenChange, ...overlayState } = state, reference = useInlinePopoverReference(host, editor), hasReference = createComputed(() => !!reference.get()); | ||
useEffect(host, () => { | ||
let hasReferenceValue = hasReference.get(), onOpenChangeValue = onOpenChange.peek(), defaultOpenValue = defaultOpen.peek(), openValue = open.peek(); | ||
onOpenChangeValue && (defaultOpenValue || openValue) && onOpenChangeValue(hasReferenceValue); | ||
}), useEffect(host, () => { | ||
let hasReferenceValue = hasReference.get(), defaultOpenValue = defaultOpen.peek(); | ||
hasReferenceValue && defaultOpenValue ? open.set(!0) : hasReferenceValue || open.set(!1); | ||
}), useOverlayPositionerState(host, overlayState, { reference }), useAttribute(host, "data-state", () => open.get() ? "open" : "closed"), usePresence(host, open); | ||
} | ||
@@ -131,3 +132,3 @@ function useInlinePopoverReference(host, editor) { | ||
}), useEditorUpdateEvent(host, editor, (view) => { | ||
!editorFocused && host.contains(host.ownerDocument.activeElement) || (reference.value = getVirtualSelectionElement(view)); | ||
!editorFocused && host.contains(host.ownerDocument.activeElement) || reference.set(getVirtualSelectionElement(view)); | ||
}), reference; | ||
@@ -134,0 +135,0 @@ } |
@@ -88,8 +88,8 @@ import { | ||
let startX = 0, startY = 0, width = 0, height = 0, aspectRatio = 1, pointerPressing = createSignal(!1), handlePointerDown = (event) => { | ||
var _a, _b; | ||
event.preventDefault(), pointerPressing.value = !0, startX = event.x, startY = event.y; | ||
let size = (_b = (_a = context.onResizeStart).value) == null ? void 0 : _b.call(_a); | ||
var _a; | ||
event.preventDefault(), pointerPressing.set(!0), startX = event.x, startY = event.y; | ||
let size = (_a = context.onResizeStart.get()) == null ? void 0 : _a(); | ||
size && ([width, height, aspectRatio] = size); | ||
}, handlePointerMove = (event) => { | ||
var _a, _b; | ||
var _a; | ||
event.preventDefault(); | ||
@@ -104,6 +104,6 @@ let dx = event.x - startX, dy = event.y - startY, [w, h] = calcResize( | ||
); | ||
(_b = (_a = context.onResize).value) == null || _b.call(_a, w, h); | ||
(_a = context.onResize.get()) == null || _a(w, h); | ||
}, handlePointerUp = (event) => { | ||
var _a, _b; | ||
event.preventDefault(), pointerPressing.value = !1, (_b = (_a = context.onResizeEnd).value) == null || _b.call(_a); | ||
var _a; | ||
event.preventDefault(), pointerPressing.set(!1), (_a = context.onResizeEnd.get()) == null || _a(); | ||
}; | ||
@@ -113,3 +113,3 @@ useEffect(host, () => (host.addEventListener("pointerdown", handlePointerDown), () => { | ||
})), useEffect(host, () => { | ||
if (!pointerPressing.value) | ||
if (!pointerPressing.get()) | ||
return; | ||
@@ -159,3 +159,3 @@ let win = getWindow(host); | ||
var _a; | ||
(_a = state.onSizeChange.peek()) == null || _a({ width, height }), state.width.value = width, state.height.value = height; | ||
(_a = state.onSizeChange.peek()) == null || _a({ width, height }), state.width.set(width), state.height.set(height); | ||
}, onResizeEnd = () => { | ||
@@ -169,5 +169,5 @@ var _a; | ||
host, | ||
state.width.value, | ||
state.height.value, | ||
state.aspectRatio.value | ||
state.width.get(), | ||
state.height.get(), | ||
state.aspectRatio.get() | ||
); | ||
@@ -174,0 +174,0 @@ }); |
{ | ||
"name": "@prosekit/web", | ||
"type": "module", | ||
"version": "0.0.0-next-20240605080819", | ||
"version": "0.0.0-next-20240616145703", | ||
"private": false, | ||
@@ -69,13 +69,13 @@ "author": { | ||
"@aria-ui/collection": "^0.0.3", | ||
"@aria-ui/core": "^0.0.14", | ||
"@aria-ui/listbox": "^0.0.13", | ||
"@aria-ui/overlay": "^0.0.15", | ||
"@aria-ui/popover": "^0.0.14", | ||
"@aria-ui/presence": "^0.0.9", | ||
"@aria-ui/tooltip": "^0.0.16", | ||
"@aria-ui/core": "^0.0.15", | ||
"@aria-ui/listbox": "^0.0.14", | ||
"@aria-ui/overlay": "^0.0.16", | ||
"@aria-ui/popover": "^0.0.16", | ||
"@aria-ui/presence": "^0.0.10", | ||
"@aria-ui/tooltip": "^0.0.17", | ||
"@floating-ui/dom": "^1.6.5", | ||
"@zag-js/dom-query": "^0.53.0", | ||
"@prosekit/core": "^0.0.0-next-20240605080819", | ||
"@prosekit/extensions": "^0.0.0-next-20240605080819", | ||
"@prosekit/pm": "^0.0.0-next-20240605080819" | ||
"@zag-js/dom-query": "^0.57.0", | ||
"@prosekit/core": "^0.0.0-next-20240616145703", | ||
"@prosekit/pm": "^0.0.0-next-20240616145703", | ||
"@prosekit/extensions": "^0.0.0-next-20240616145703" | ||
}, | ||
@@ -82,0 +82,0 @@ "devDependencies": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
63986
1528
+ Added@aria-ui/core@0.0.15(transitive)
+ Added@aria-ui/listbox@0.0.14(transitive)
+ Added@aria-ui/overlay@0.0.16(transitive)
+ Added@aria-ui/popover@0.0.16(transitive)
+ Added@aria-ui/presence@0.0.10(transitive)
+ Added@aria-ui/tooltip@0.0.17(transitive)
+ Added@zag-js/dismissable@0.57.0(transitive)
+ Added@zag-js/dom-event@0.57.0(transitive)
+ Added@zag-js/dom-query@0.57.0(transitive)
+ Added@zag-js/interact-outside@0.57.0(transitive)
+ Added@zag-js/text-selection@0.57.0(transitive)
+ Added@zag-js/types@0.57.0(transitive)
+ Added@zag-js/utils@0.57.0(transitive)
- Removed@aria-ui/core@0.0.14(transitive)
- Removed@aria-ui/listbox@0.0.13(transitive)
- Removed@aria-ui/overlay@0.0.15(transitive)
- Removed@aria-ui/popover@0.0.14(transitive)
- Removed@aria-ui/presence@0.0.9(transitive)
- Removed@aria-ui/tooltip@0.0.16(transitive)
- Removed@zag-js/dismissable@0.50.0(transitive)
- Removed@zag-js/dom-event@0.50.0(transitive)
- Removed@zag-js/dom-query@0.50.00.53.0(transitive)
- Removed@zag-js/interact-outside@0.50.0(transitive)
- Removed@zag-js/text-selection@0.50.0(transitive)
- Removed@zag-js/types@0.50.0(transitive)
- Removed@zag-js/utils@0.50.0(transitive)
Updated@aria-ui/core@^0.0.15
Updated@aria-ui/listbox@^0.0.14
Updated@aria-ui/overlay@^0.0.16
Updated@aria-ui/popover@^0.0.16
Updated@aria-ui/presence@^0.0.10
Updated@aria-ui/tooltip@^0.0.17
Updated@zag-js/dom-query@^0.57.0