@prosekit/web
Advanced tools
Comparing version 0.0.0-next-20240724173606 to 0.0.0-next-20240901092634
@@ -10,11 +10,16 @@ import { BaseElement } from '@aria-ui/core'; | ||
import { defaultTooltipTriggerProps } from '@aria-ui/tooltip'; | ||
import type { defineTableCommands } from '@prosekit/extensions/table'; | ||
import { Editor } from '@prosekit/core'; | ||
import type { EditorView } from '@prosekit/pm/view'; | ||
import type { EmptyObject } from '@aria-ui/core'; | ||
import { Extension } from '@prosekit/core'; | ||
import { ExtensionTyping } from '@prosekit/core'; | ||
import { FocusChangeHandler } from '@prosekit/core'; | ||
import { ItemFilter } from '@aria-ui/collection'; | ||
import { Keymap } from '@prosekit/core'; | ||
import { ListboxProps } from '@aria-ui/listbox'; | ||
import { MenuContentProps } from '@aria-ui/menu'; | ||
import { MenuItemProps } from '@aria-ui/menu'; | ||
import { Options } from 'tsup'; | ||
import type { OverlayPositionerProps } from '@aria-ui/overlay'; | ||
import { OverlayPositionerProps } from '@aria-ui/overlay'; | ||
import type { Placement } from '@floating-ui/dom'; | ||
@@ -28,3 +33,3 @@ import { PopoverContentProps } from '@aria-ui/popover'; | ||
import { SignalState } from '@aria-ui/core'; | ||
import type { TooltipContentProps } from '@aria-ui/tooltip'; | ||
import { TooltipContentProps } from '@aria-ui/tooltip'; | ||
import { TooltipRootProps } from '@aria-ui/tooltip'; | ||
@@ -52,3 +57,3 @@ import { TooltipTriggerProps } from '@aria-ui/tooltip'; | ||
declare interface AutocompleteEmptyProps { | ||
declare interface AutocompleteEmptyProps extends EmptyObject { | ||
} | ||
@@ -180,2 +185,5 @@ export { AutocompleteEmptyProps } | ||
/** | ||
* @deprecated Use `BlockHandleDraggableProps` instead. | ||
*/ | ||
declare interface BlockDragHandleProps { | ||
@@ -192,10 +200,63 @@ /** | ||
declare class BlockHandleAddElement extends BlockHandleAddElement_base { | ||
} | ||
export { BlockHandleAddElement } | ||
export { BlockHandleAddElement as BlockHandleAddElement_alias_1 } | ||
declare const BlockHandleAddElement_base: { | ||
new (): BaseElement & BlockHandleAddProps; | ||
prototype: HTMLElement; | ||
}; | ||
declare interface BlockHandleAddProps { | ||
/** | ||
* The ProseKit editor instance. | ||
* | ||
* @default null | ||
*/ | ||
editor: Editor | null; | ||
} | ||
export { BlockHandleAddProps } | ||
export { BlockHandleAddProps as BlockHandleAddProps_alias_1 } | ||
declare class BlockHandleDraggableElement extends BlockHandleDraggableElement_base { | ||
} | ||
export { BlockHandleDraggableElement } | ||
export { BlockHandleDraggableElement as BlockHandleDraggableElement_alias_1 } | ||
declare const BlockHandleDraggableElement_base: { | ||
new (): BaseElement & BlockHandleDraggableProps; | ||
prototype: HTMLElement; | ||
}; | ||
declare interface BlockHandleDraggableProps { | ||
/** | ||
* The ProseKit editor instance. | ||
* | ||
* @default null | ||
*/ | ||
editor: Editor | null; | ||
} | ||
export { BlockHandleDraggableProps } | ||
export { BlockHandleDraggableProps as BlockHandleDraggableProps_alias_1 } | ||
declare class BlockHandlePopoverElement extends BlockHandlePopoverElement_base { | ||
} | ||
export { BlockHandlePopoverElement } | ||
export { BlockHandlePopoverElement as BlockHandlePopoverElement_alias_1 } | ||
declare const BlockHandlePopoverElement_base: { | ||
new (): BaseElement & BlockHandlePopoverProps; | ||
prototype: HTMLElement; | ||
}; | ||
declare interface BlockHandlePopoverProps extends BlockPopoverProps { | ||
} | ||
export { BlockHandlePopoverProps } | ||
export { BlockHandlePopoverProps as BlockHandlePopoverProps_alias_1 } | ||
/** | ||
* @internal | ||
*/ | ||
export declare interface BlockPopoverContext { | ||
pos: number | null; | ||
node: ProseMirrorNode | null; | ||
element: HTMLElement | null; | ||
} | ||
export declare type BlockPopoverContext = HoverState | null; | ||
@@ -301,2 +362,39 @@ /** | ||
declare const defaultBlockHandleAddProps: Readonly<{ | ||
editor: null; | ||
}>; | ||
export { defaultBlockHandleAddProps } | ||
export { defaultBlockHandleAddProps as defaultBlockHandleAddProps_alias_1 } | ||
declare const defaultBlockHandleDraggableProps: Readonly<{ | ||
editor: null; | ||
}>; | ||
export { defaultBlockHandleDraggableProps } | ||
export { defaultBlockHandleDraggableProps as defaultBlockHandleDraggableProps_alias_1 } | ||
declare const defaultBlockHandlePopoverProps: Readonly<{ | ||
editor: null; | ||
placement: "left-start"; | ||
offset: 4; | ||
strategy: "absolute"; | ||
autoUpdate: true; | ||
hoist: false; | ||
transform: false; | ||
flip: false; | ||
shift: false; | ||
overlap: false; | ||
fitViewport: false; | ||
sameWidth: false; | ||
sameHeight: false; | ||
inline: false; | ||
hide: false; | ||
boundary: "clippingAncestors"; | ||
rootBoundary: "viewport"; | ||
overflowPadding: 0; | ||
elementContext: "floating"; | ||
altBoundary: true; | ||
}>; | ||
export { defaultBlockHandlePopoverProps } | ||
export { defaultBlockHandlePopoverProps as defaultBlockHandlePopoverProps_alias_1 } | ||
declare const defaultBlockPopoverProps: Readonly<{ | ||
@@ -384,2 +482,113 @@ editor: null; | ||
declare const defaultTableHandleColumnRootProps: Readonly<{ | ||
editor: null; | ||
placement: "top"; | ||
strategy: "absolute"; | ||
autoUpdate: true; | ||
hoist: false; | ||
transform: false; | ||
offset: null; | ||
flip: false; | ||
shift: false; | ||
overlap: false; | ||
fitViewport: false; | ||
sameWidth: false; | ||
sameHeight: false; | ||
inline: false; | ||
hide: false; | ||
boundary: "clippingAncestors"; | ||
rootBoundary: "viewport"; | ||
overflowPadding: 0; | ||
elementContext: "floating"; | ||
altBoundary: true; | ||
}>; | ||
export { defaultTableHandleColumnRootProps } | ||
export { defaultTableHandleColumnRootProps as defaultTableHandleColumnRootProps_alias_1 } | ||
declare const defaultTableHandleColumnTriggerProps: Readonly<{ | ||
editor: null; | ||
}>; | ||
export { defaultTableHandleColumnTriggerProps } | ||
export { defaultTableHandleColumnTriggerProps as defaultTableHandleColumnTriggerProps_alias_1 } | ||
declare const defaultTableHandlePopoverContentProps: Readonly<{ | ||
placement: "right-start"; | ||
offset: { | ||
mainAxis: number; | ||
crossAxis: number; | ||
}; | ||
editor: null; | ||
onKeydownHandlerAdd: null; | ||
hoist: true; | ||
flip: true; | ||
shift: true; | ||
overflowPadding: 4; | ||
onEscapeKeyDown: null; | ||
onPointerDownOutside: null; | ||
onFocusOutside: null; | ||
onInteractOutside: null; | ||
strategy: "absolute"; | ||
autoUpdate: true; | ||
transform: false; | ||
overlap: false; | ||
fitViewport: false; | ||
sameWidth: false; | ||
sameHeight: false; | ||
inline: false; | ||
hide: false; | ||
boundary: "clippingAncestors"; | ||
rootBoundary: "viewport"; | ||
elementContext: "floating"; | ||
altBoundary: true; | ||
}>; | ||
export { defaultTableHandlePopoverContentProps } | ||
export { defaultTableHandlePopoverContentProps as defaultTableHandlePopoverContentProps_alias_1 } | ||
declare const defaultTableHandlePopoverItemProps: Readonly<{ | ||
disabled: false; | ||
value: ""; | ||
query: ""; | ||
filter: ItemFilter; | ||
onSelect: null; | ||
}>; | ||
export { defaultTableHandlePopoverItemProps } | ||
export { defaultTableHandlePopoverItemProps as defaultTableHandlePopoverItemProps_alias_1 } | ||
declare const defaultTableHandleRootProps: Readonly<{ | ||
editor: null; | ||
}>; | ||
export { defaultTableHandleRootProps } | ||
export { defaultTableHandleRootProps as defaultTableHandleRootProps_alias_1 } | ||
declare const defaultTableHandleRowRootProps: Readonly<{ | ||
editor: null; | ||
placement: "left"; | ||
strategy: "absolute"; | ||
autoUpdate: true; | ||
hoist: false; | ||
transform: false; | ||
offset: null; | ||
flip: false; | ||
shift: false; | ||
overlap: false; | ||
fitViewport: false; | ||
sameWidth: false; | ||
sameHeight: false; | ||
inline: false; | ||
hide: false; | ||
boundary: "clippingAncestors"; | ||
rootBoundary: "viewport"; | ||
overflowPadding: 0; | ||
elementContext: "floating"; | ||
altBoundary: true; | ||
}>; | ||
export { defaultTableHandleRowRootProps } | ||
export { defaultTableHandleRowRootProps as defaultTableHandleRowRootProps_alias_1 } | ||
declare const defaultTableHandleRowTriggerProps: Readonly<{ | ||
editor: null; | ||
}>; | ||
export { defaultTableHandleRowTriggerProps } | ||
export { defaultTableHandleRowTriggerProps as defaultTableHandleRowTriggerProps_alias_1 } | ||
declare const defaultTooltipContentProps: { | ||
@@ -415,2 +624,4 @@ shift: true; | ||
export declare function defineCellHoverHandler(handler: (hoveringCell: HoveringCellInfo | null) => void): Extension<ExtensionTyping<any, any, any>>; | ||
export declare function defineCustomElement(name: string, constructor: CustomElementConstructor, options?: ElementDefinitionOptions): void; | ||
@@ -420,6 +631,25 @@ | ||
export declare type ElementHoverHandler = (reference: VirtualElement | null, element: HTMLElement | null, node: ProseMirrorNode | null, pos: number | null) => void; | ||
export declare type ElementHoverHandler = (reference: VirtualElement | null, hoverState: HoverState | null) => void; | ||
export declare function getHoveringCell(view: EditorView, event: MouseEvent): HoveringCellInfo | undefined; | ||
export declare function getVirtualSelectionElement(view: EditorView): ReferenceElement | undefined; | ||
export declare interface HoveringCellInfo { | ||
rowIndex: number; | ||
colIndex: number; | ||
cellPos: number; | ||
rowFirstCellPos: number; | ||
colFirstCellPos: number; | ||
} | ||
/** | ||
* @internal | ||
*/ | ||
export declare interface HoverState { | ||
element: HTMLElement; | ||
node: ProseMirrorNode; | ||
pos: number; | ||
} | ||
declare class InlinePopoverElement extends InlinePopoverElement_base { | ||
@@ -512,3 +742,3 @@ } | ||
export declare function omit<T extends Record<string, unknown>, K extends keyof T>(object: T, keys: K[]): Omit<T, K>; | ||
export declare function isHoveringCellInfoEqual(a?: HoveringCellInfo | null, b?: HoveringCellInfo | null): boolean; | ||
@@ -641,5 +871,166 @@ /** | ||
declare type TableCommandsExtension = ReturnType<typeof defineTableCommands>; | ||
declare type TableCommandsExtension_2 = ReturnType<typeof defineTableCommands>; | ||
declare class TableHandleColumnRootElement extends TableHandleColumnRootElement_base { | ||
} | ||
export { TableHandleColumnRootElement } | ||
export { TableHandleColumnRootElement as TableHandleColumnRootElement_alias_1 } | ||
declare const TableHandleColumnRootElement_base: { | ||
new (): BaseElement & TableHandleColumnRootProps; | ||
prototype: HTMLElement; | ||
}; | ||
declare interface TableHandleColumnRootProps extends Omit<OverlayPositionerProps, 'placement'> { | ||
/** | ||
* The ProseKit editor instance. | ||
* | ||
* @default null | ||
*/ | ||
editor: Editor | null; | ||
/** | ||
* The placement of the popover, relative to the hovered table cell. | ||
* | ||
* @default "top" | ||
*/ | ||
placement: Placement; | ||
} | ||
export { TableHandleColumnRootProps } | ||
export { TableHandleColumnRootProps as TableHandleColumnRootProps_alias_1 } | ||
declare class TableHandleColumnTriggerElement extends TableHandleColumnTriggerElement_base { | ||
} | ||
export { TableHandleColumnTriggerElement } | ||
export { TableHandleColumnTriggerElement as TableHandleColumnTriggerElement_alias_1 } | ||
declare const TableHandleColumnTriggerElement_base: { | ||
new (): BaseElement & TableHandleColumnTriggerProps; | ||
prototype: HTMLElement; | ||
}; | ||
declare interface TableHandleColumnTriggerProps { | ||
editor: Editor<TableCommandsExtension> | null; | ||
} | ||
export { TableHandleColumnTriggerProps } | ||
export { TableHandleColumnTriggerProps as TableHandleColumnTriggerProps_alias_1 } | ||
declare class TableHandlePopoverContentElement extends TableHandlePopoverContentElement_base { | ||
} | ||
export { TableHandlePopoverContentElement } | ||
export { TableHandlePopoverContentElement as TableHandlePopoverContentElement_alias_1 } | ||
declare const TableHandlePopoverContentElement_base: { | ||
new (): BaseElement & TableHandlePopoverContentProps; | ||
prototype: HTMLElement; | ||
}; | ||
declare interface TableHandlePopoverContentProps extends Omit<MenuContentProps, 'placement' | 'offset'> { | ||
/** | ||
* @default 'bottom-start' | ||
*/ | ||
placement: MenuContentProps['placement']; | ||
/** | ||
* @default {mainAxis: -4, crossAxis: 4} | ||
*/ | ||
offset: MenuContentProps['offset']; | ||
editor: Editor | null; | ||
} | ||
export { TableHandlePopoverContentProps } | ||
export { TableHandlePopoverContentProps as TableHandlePopoverContentProps_alias_1 } | ||
declare class TableHandlePopoverItemElement extends TableHandlePopoverItemElement_base { | ||
} | ||
export { TableHandlePopoverItemElement } | ||
export { TableHandlePopoverItemElement as TableHandlePopoverItemElement_alias_1 } | ||
declare const TableHandlePopoverItemElement_base: { | ||
new (): BaseElement & TableHandlePopoverItemProps; | ||
prototype: HTMLElement; | ||
}; | ||
declare interface TableHandlePopoverItemProps extends MenuItemProps { | ||
disabled?: boolean; | ||
} | ||
export { TableHandlePopoverItemProps } | ||
export { TableHandlePopoverItemProps as TableHandlePopoverItemProps_alias_1 } | ||
/** | ||
* @internal | ||
*/ | ||
export declare type TableHandleRootContext = HoveringCellInfo | null; | ||
/** | ||
* @internal | ||
*/ | ||
export declare const tableHandleRootContext: Context<TableHandleRootContext>; | ||
declare class TableHandleRootElement extends TableHandleRootElement_base { | ||
} | ||
export { TableHandleRootElement } | ||
export { TableHandleRootElement as TableHandleRootElement_alias_1 } | ||
declare const TableHandleRootElement_base: { | ||
new (): BaseElement & TableHandleRootProps; | ||
prototype: HTMLElement; | ||
}; | ||
declare interface TableHandleRootProps { | ||
/** | ||
* The ProseKit editor instance. | ||
* | ||
* @default null | ||
*/ | ||
editor: Editor | null; | ||
} | ||
export { TableHandleRootProps } | ||
export { TableHandleRootProps as TableHandleRootProps_alias_1 } | ||
declare class TableHandleRowRootElement extends TableHandleRowRootElement_base { | ||
} | ||
export { TableHandleRowRootElement } | ||
export { TableHandleRowRootElement as TableHandleRowRootElement_alias_1 } | ||
declare const TableHandleRowRootElement_base: { | ||
new (): BaseElement & TableHandleRowRootProps; | ||
prototype: HTMLElement; | ||
}; | ||
declare interface TableHandleRowRootProps extends Omit<OverlayPositionerProps, 'placement'> { | ||
/** | ||
* The ProseKit editor instance. | ||
* | ||
* @default null | ||
*/ | ||
editor: Editor | null; | ||
/** | ||
* The placement of the popover, relative to the hovered table cell. | ||
* | ||
* @default "left" | ||
*/ | ||
placement: Placement; | ||
} | ||
export { TableHandleRowRootProps } | ||
export { TableHandleRowRootProps as TableHandleRowRootProps_alias_1 } | ||
declare class TableHandleRowTriggerElement extends TableHandleRowTriggerElement_base { | ||
} | ||
export { TableHandleRowTriggerElement } | ||
export { TableHandleRowTriggerElement as TableHandleRowTriggerElement_alias_1 } | ||
declare const TableHandleRowTriggerElement_base: { | ||
new (): BaseElement & TableHandleRowTriggerProps; | ||
prototype: HTMLElement; | ||
}; | ||
declare interface TableHandleRowTriggerProps { | ||
editor: Editor<TableCommandsExtension_2> | null; | ||
} | ||
export { TableHandleRowTriggerProps } | ||
export { TableHandleRowTriggerProps as TableHandleRowTriggerProps_alias_1 } | ||
/** | ||
* @internal | ||
*/ | ||
export declare function throttle<Args extends any[]>(callback: (...args: Args) => void, wait: number): (...args: Args) => void; | ||
@@ -694,4 +1085,16 @@ | ||
/** | ||
* @deprecated Use `useBlockHandleDraggable` instead. | ||
*/ | ||
export declare function useBlockDragHandle(host: ConnectableElement, state: SignalState<BlockDragHandleProps>): void; | ||
export declare function useBlockHandleAdd(host: ConnectableElement, state: SignalState<BlockHandleAddProps>): void; | ||
export declare function useBlockHandleDraggable(host: ConnectableElement, state: SignalState<BlockHandleDraggableProps>): void; | ||
export declare function useBlockHandlePopover(host: ConnectableElement, state: SignalState<BlockHandlePopoverProps>): void; | ||
/** | ||
* @deprecated Use `useBlockHandlePopover` instead. | ||
*/ | ||
export declare function useBlockPopover(host: ConnectableElement, state: SignalState<BlockPopoverProps>): void; | ||
@@ -706,2 +1109,4 @@ | ||
export declare function useEditorTyping(host: ConnectableElement, editor: ReadonlySignal<Editor | null>): ReadonlySignal<boolean>; | ||
/** | ||
@@ -728,2 +1133,16 @@ * @internal | ||
export declare function useTableHandleColumnRoot(host: ConnectableElement, state: SignalState<TableHandleColumnRootProps>): void; | ||
export declare function useTableHandleColumnTrigger(host: ConnectableElement, state: SignalState<TableHandleColumnTriggerProps>): void; | ||
export declare function useTableHandlePopoverContent(host: ConnectableElement, state: SignalState<TableHandlePopoverContentProps>): void; | ||
export declare function useTableHandlePopoverItem(element: ConnectableElement, state: SignalState<TableHandlePopoverItemProps>): void; | ||
export declare function useTableHandleRoot(host: ConnectableElement, state: SignalState<TableHandleRootProps>): void; | ||
export declare function useTableHandleRowRoot(host: ConnectableElement, state: SignalState<TableHandleRowRootProps>): void; | ||
export declare function useTableHandleRowTrigger(host: ConnectableElement, state: SignalState<TableHandleRowTriggerProps>): void; | ||
export { useTooltipContent } | ||
@@ -730,0 +1149,0 @@ |
@@ -85,3 +85,2 @@ import { | ||
import { | ||
createSignal, | ||
mapSignals, | ||
@@ -99,11 +98,3 @@ useEffect as useEffect2 | ||
} from "@prosekit/core"; | ||
// src/utils/omit.ts | ||
function omit(object, keys) { | ||
return Object.fromEntries( | ||
Object.entries(object).filter(([key]) => !keys.includes(key)) | ||
); | ||
} | ||
// src/components/autocomplete/autocomplete-list/state.ts | ||
import omit from "just-omit"; | ||
function useAutocompleteList(element, state) { | ||
@@ -157,10 +148,7 @@ const open = openContext.consume(element); | ||
function useKeyboardHandler(element, open, editor) { | ||
const keydownHandler = createSignal( | ||
null | ||
); | ||
let keydownHandler = null; | ||
let disposeKeydownHandler; | ||
useEffect2(element, () => { | ||
const editorValue = editor.get(); | ||
const keydownHandlerValue = keydownHandler.get(); | ||
if (!editorValue || !keydownHandlerValue) { | ||
if (!editorValue) { | ||
return; | ||
@@ -174,3 +162,3 @@ } | ||
} | ||
keydownHandlerValue(event); | ||
keydownHandler == null ? void 0 : keydownHandler(event); | ||
return event.defaultPrevented; | ||
@@ -185,3 +173,3 @@ } | ||
return (keydownHandlerValue) => { | ||
keydownHandler.set(keydownHandlerValue); | ||
keydownHandler = keydownHandlerValue; | ||
return () => { | ||
@@ -203,3 +191,5 @@ disposeKeydownHandler == null ? void 0 : disposeKeydownHandler(); | ||
// src/components/autocomplete/autocomplete-popover/props.ts | ||
import { defaultOverlayPositionerProps } from "@aria-ui/overlay"; | ||
import { | ||
defaultOverlayPositionerProps | ||
} from "@aria-ui/overlay"; | ||
var body = typeof document !== "undefined" && document.querySelector("body"); | ||
@@ -225,3 +215,3 @@ var defaultBoundary = body || "clippingAncestors"; | ||
createComputed, | ||
createSignal as createSignal3, | ||
createSignal as createSignal2, | ||
useAnimationFrame, | ||
@@ -245,7 +235,7 @@ useAttribute, | ||
import { | ||
createSignal as createSignal2, | ||
createSignal, | ||
useEffect as useEffect3 | ||
} from "@aria-ui/core"; | ||
function useFirstRendering(host) { | ||
const firstRendering = createSignal2(true); | ||
const firstRendering = createSignal(true); | ||
useEffect3(host, () => { | ||
@@ -267,6 +257,6 @@ requestAnimationFrame(() => { | ||
const { editor, regex, ...overlayState } = state; | ||
const reference = createSignal3(null); | ||
const query = createSignal3(""); | ||
const onDismiss = createSignal3(null); | ||
const onSubmit = createSignal3(null); | ||
const reference = createSignal2(null); | ||
const query = createSignal2(""); | ||
const onDismiss = createSignal2(null); | ||
const onSubmit = createSignal2(null); | ||
const presence = createComputed(() => !!reference.get()); | ||
@@ -315,3 +305,3 @@ queryContext.provide(host, query); | ||
} | ||
return addAutocompleteExtension( | ||
const rule = createAutocompleteRule( | ||
editorValue, | ||
@@ -324,5 +314,7 @@ regexValue, | ||
); | ||
const extension = defineAutocomplete(rule); | ||
return editorValue.use(extension); | ||
}); | ||
} | ||
function addAutocompleteExtension(editor, regex, reference, query, onDismiss, onSubmit) { | ||
function createAutocompleteRule(editor, regex, reference, query, onDismiss, onSubmit) { | ||
const handleEnter = (options) => { | ||
@@ -343,3 +335,3 @@ const span = editor.view.dom.querySelector(".prosemirror-prediction-match"); | ||
}; | ||
const rule = new AutocompleteRule({ | ||
return new AutocompleteRule({ | ||
regex, | ||
@@ -349,4 +341,2 @@ onEnter: handleEnter, | ||
}); | ||
const extension = defineAutocomplete(rule); | ||
return editor.use(extension); | ||
} | ||
@@ -353,0 +343,0 @@ function createKeymapHandler(handler, enabled) { |
export { BlockDragHandleElement } from './_tsup-dts-rollup'; | ||
export { defaultBlockDragHandleProps } from './_tsup-dts-rollup'; | ||
export { BlockDragHandleProps } from './_tsup-dts-rollup'; | ||
export { BlockHandleAddElement } from './_tsup-dts-rollup'; | ||
export { defaultBlockHandleAddProps } from './_tsup-dts-rollup'; | ||
export { BlockHandleAddProps } from './_tsup-dts-rollup'; | ||
export { BlockHandleDraggableElement } from './_tsup-dts-rollup'; | ||
export { defaultBlockHandleDraggableProps } from './_tsup-dts-rollup'; | ||
export { BlockHandleDraggableProps } from './_tsup-dts-rollup'; | ||
export { BlockHandlePopoverElement } from './_tsup-dts-rollup'; | ||
export { defaultBlockHandlePopoverProps } from './_tsup-dts-rollup'; | ||
export { BlockHandlePopoverProps } from './_tsup-dts-rollup'; | ||
export { BlockPopoverElement } from './_tsup-dts-rollup'; | ||
export { defaultBlockPopoverProps } from './_tsup-dts-rollup'; | ||
export { BlockPopoverProps } from './_tsup-dts-rollup'; |
@@ -18,2 +18,4 @@ import { | ||
import { | ||
createSignal, | ||
useAttribute, | ||
useEffect, | ||
@@ -29,7 +31,3 @@ useEventListener | ||
"prosekit-block-popover-context", | ||
{ | ||
pos: null, | ||
node: null, | ||
element: null | ||
} | ||
null | ||
); | ||
@@ -43,6 +41,11 @@ | ||
}); | ||
usePointerDownHandler(host, context, state.editor); | ||
useDraggingPreview(host, context, state.editor); | ||
useDataDraggingAttribute(host); | ||
} | ||
function usePointerDownHandler(host, context, editor) { | ||
useEventListener(host, "pointerdown", () => { | ||
var _a, _b; | ||
const { pos } = (_a = context.get()) != null ? _a : {}; | ||
const { view } = (_b = state.editor.get()) != null ? _b : {}; | ||
const { view } = (_b = editor.get()) != null ? _b : {}; | ||
if (pos == null || view == null) { | ||
@@ -58,9 +61,12 @@ return; | ||
}); | ||
} | ||
function useDraggingPreview(host, context, editor) { | ||
useEventListener(host, "dragstart", (event) => { | ||
var _a, _b; | ||
const { pos, element, node } = (_a = context.get()) != null ? _a : {}; | ||
const { view } = (_b = state.editor.get()) != null ? _b : {}; | ||
if (pos == null || !element || !node || !view || !event.dataTransfer) { | ||
var _a; | ||
const hoverState = context.get(); | ||
const { view } = (_a = editor.get()) != null ? _a : {}; | ||
if (!hoverState || !view || !event.dataTransfer) { | ||
return; | ||
} | ||
const { element, node } = hoverState; | ||
event.dataTransfer.clearData(); | ||
@@ -76,2 +82,16 @@ event.dataTransfer.setData("text/html", element.outerHTML); | ||
} | ||
function useDataDraggingAttribute(host) { | ||
const dragging = useDragging(host); | ||
useAttribute(host, "data-dragging", () => dragging.get() ? "" : void 0); | ||
} | ||
function useDragging(host) { | ||
const dragging = createSignal(false); | ||
useEventListener(host, "dragstart", () => { | ||
dragging.set(true); | ||
}); | ||
useEventListener(host, "dragend", () => { | ||
dragging.set(false); | ||
}); | ||
return dragging; | ||
} | ||
@@ -83,7 +103,62 @@ // src/components/block-handle/block-drag-handle/element.gen.ts | ||
// src/components/block-handle/block-popover/element.gen.ts | ||
// src/components/block-handle/block-handle-add/element.gen.ts | ||
import { ElementBuilder as ElementBuilder2 } from "@aria-ui/core"; | ||
// src/components/block-handle/block-handle-add/props.ts | ||
var defaultBlockHandleAddProps = Object.freeze({ | ||
editor: null | ||
}); | ||
// src/components/block-handle/block-handle-add/state.ts | ||
import { | ||
useEventListener as useEventListener2 | ||
} from "@aria-ui/core"; | ||
import { insertDefaultBlock } from "@prosekit/core"; | ||
function useBlockHandleAdd(host, state) { | ||
const context = blockPopoverContext.consume(host); | ||
useEventListener2(host, "pointerdown", (event) => { | ||
event.preventDefault(); | ||
const editor = state.editor.get(); | ||
const hoverState = context.get(); | ||
if (!editor || !hoverState) { | ||
return; | ||
} | ||
const { node, pos } = hoverState; | ||
editor.exec(insertDefaultBlock({ pos: pos + node.nodeSize })); | ||
editor.focus(); | ||
context.set(null); | ||
}); | ||
} | ||
// src/components/block-handle/block-handle-add/element.gen.ts | ||
var BlockHandleAddElement = class extends ElementBuilder2(useBlockHandleAdd, defaultBlockHandleAddProps) { | ||
}; | ||
defineCustomElement("prosekit-block-handle-add", BlockHandleAddElement); | ||
// src/components/block-handle/block-handle-draggable/element.gen.ts | ||
import { ElementBuilder as ElementBuilder3 } from "@aria-ui/core"; | ||
// src/components/block-handle/block-handle-draggable/props.ts | ||
var defaultBlockHandleDraggableProps = Object.freeze({ | ||
editor: null | ||
}); | ||
// src/components/block-handle/block-handle-draggable/state.ts | ||
import "@aria-ui/core"; | ||
function useBlockHandleDraggable(host, state) { | ||
useBlockDragHandle(host, state); | ||
} | ||
// src/components/block-handle/block-handle-draggable/element.gen.ts | ||
var BlockHandleDraggableElement = class extends ElementBuilder3(useBlockHandleDraggable, defaultBlockHandleDraggableProps) { | ||
}; | ||
defineCustomElement("prosekit-block-handle-draggable", BlockHandleDraggableElement); | ||
// src/components/block-handle/block-handle-popover/element.gen.ts | ||
import { ElementBuilder as ElementBuilder4 } from "@aria-ui/core"; | ||
// src/components/block-handle/block-popover/props.ts | ||
import { defaultOverlayPositionerProps } from "@aria-ui/overlay"; | ||
import { | ||
defaultOverlayPositionerProps | ||
} from "@aria-ui/overlay"; | ||
var defaultBlockPopoverProps = Object.freeze({ | ||
@@ -96,7 +171,14 @@ ...defaultOverlayPositionerProps, | ||
// src/components/block-handle/block-handle-popover/props.ts | ||
var defaultBlockHandlePopoverProps = Object.freeze({ | ||
...defaultBlockPopoverProps | ||
}); | ||
// src/components/block-handle/block-handle-popover/state.ts | ||
import "@aria-ui/core"; | ||
// src/components/block-handle/block-popover/state.ts | ||
import { | ||
createComputed, | ||
createSignal, | ||
useAttribute, | ||
createSignal as createSignal2, | ||
useAttribute as useAttribute2, | ||
useEffect as useEffect2 | ||
@@ -133,3 +215,3 @@ } from "@aria-ui/core"; | ||
if (pos == null || pos < 0) { | ||
handler(null, null, null, null); | ||
handler(null, null); | ||
return; | ||
@@ -144,4 +226,4 @@ } | ||
const element2 = view.nodeDOM(ancestorPos); | ||
if (!element2) { | ||
handler(null, null, null, null); | ||
if (!element2 || !node2) { | ||
handler(null, null); | ||
return; | ||
@@ -172,12 +254,12 @@ } | ||
}; | ||
handler(reference, element2, node2, ancestorPos); | ||
handler(reference, { element: element2, node: node2, pos: ancestorPos }); | ||
return; | ||
} | ||
handler(element, element, node, pos); | ||
handler(element, element && node && { element, node, pos }); | ||
}; | ||
return union([ | ||
return union( | ||
defineDOMEventHandler("pointermove", throttle(handlePointerEvent, 200)), | ||
defineDOMEventHandler("pointerout", handlePointerEvent), | ||
defineDOMEventHandler("keypress", () => handler(null, null, null, null)) | ||
]); | ||
defineDOMEventHandler("keypress", () => handler(null, null)) | ||
); | ||
} | ||
@@ -188,40 +270,48 @@ | ||
const { editor, ...overlayState } = state; | ||
const reference = createSignal(null); | ||
const reference = createSignal2(null); | ||
useOverlayPositionerState(host, overlayState, { reference }); | ||
const context = createSignal({ | ||
pos: null, | ||
node: null, | ||
element: null | ||
}); | ||
const context = createSignal2(null); | ||
blockPopoverContext.provide(host, context); | ||
const open = createSignal(false); | ||
const open = createSignal2(false); | ||
useEffect2(host, () => { | ||
open.set(!!context.get().element); | ||
var _a; | ||
open.set(!!((_a = context.get()) == null ? void 0 : _a.element)); | ||
}); | ||
useHoverExtension(host, editor, (referenceValue, element, node, pos) => { | ||
useHoverExtension(host, editor, (referenceValue, hoverState) => { | ||
reference.set(referenceValue); | ||
context.set({ element, node, pos }); | ||
context.set(hoverState); | ||
}); | ||
const presence = createComputed(() => !!reference.get()); | ||
useAttribute(host, "data-state", () => presence.get() ? "open" : "closed"); | ||
usePresence(host, presence); | ||
useAttribute2(host, "data-state", () => open.get() ? "open" : "closed"); | ||
usePresence(host, open); | ||
} | ||
function useHoverExtension(host, editor, handler) { | ||
let prevElement = null; | ||
let prevPos = null; | ||
const extension = defineElementHoverHandler( | ||
(reference, element, node, pos) => { | ||
if (prevElement === element && prevPos === pos) { | ||
return; | ||
} | ||
prevElement = element; | ||
prevPos = pos; | ||
handler(reference, element, node, pos); | ||
let prevHoverState = null; | ||
const extension = defineElementHoverHandler((reference, hoverState) => { | ||
if (isHoverStateEqual(prevHoverState, hoverState)) { | ||
return; | ||
} | ||
); | ||
prevHoverState = hoverState; | ||
handler(reference, hoverState); | ||
}); | ||
useEditorExtension(host, editor, extension); | ||
} | ||
function isHoverStateEqual(a, b) { | ||
if (!a && !b) return true; | ||
if (!a || !b) return false; | ||
return a.element === b.element && a.pos === b.pos && a.node.eq(b.node); | ||
} | ||
// src/components/block-handle/block-handle-popover/state.ts | ||
function useBlockHandlePopover(host, state) { | ||
useBlockPopover(host, state); | ||
} | ||
// src/components/block-handle/block-handle-popover/element.gen.ts | ||
var BlockHandlePopoverElement = class extends ElementBuilder4(useBlockHandlePopover, defaultBlockHandlePopoverProps) { | ||
}; | ||
defineCustomElement("prosekit-block-handle-popover", BlockHandlePopoverElement); | ||
// src/components/block-handle/block-popover/element.gen.ts | ||
var BlockPopoverElement = class extends ElementBuilder2(useBlockPopover, defaultBlockPopoverProps) { | ||
import { ElementBuilder as ElementBuilder5 } from "@aria-ui/core"; | ||
var BlockPopoverElement = class extends ElementBuilder5(useBlockPopover, defaultBlockPopoverProps) { | ||
}; | ||
@@ -231,5 +321,11 @@ defineCustomElement("prosekit-block-popover", BlockPopoverElement); | ||
BlockDragHandleElement, | ||
BlockHandleAddElement, | ||
BlockHandleDraggableElement, | ||
BlockHandlePopoverElement, | ||
BlockPopoverElement, | ||
defaultBlockDragHandleProps, | ||
defaultBlockHandleAddProps, | ||
defaultBlockHandleDraggableProps, | ||
defaultBlockHandlePopoverProps, | ||
defaultBlockPopoverProps | ||
}; |
@@ -12,3 +12,5 @@ import { | ||
// src/components/inline-popover/inline-popover/props.ts | ||
import { defaultOverlayPositionerProps } from "@aria-ui/overlay"; | ||
import { | ||
defaultOverlayPositionerProps | ||
} from "@aria-ui/overlay"; | ||
var defaultInlinePopoverProps = Object.freeze({ | ||
@@ -54,3 +56,5 @@ ...defaultOverlayPositionerProps, | ||
// src/hooks/use-editor-update-event.ts | ||
import { defineUpdateHandler } from "@prosekit/core"; | ||
import { | ||
defineUpdateHandler | ||
} from "@prosekit/core"; | ||
function useEditorUpdateEvent(host, editor, handler) { | ||
@@ -57,0 +61,0 @@ const extension = defineUpdateHandler(handler); |
@@ -9,3 +9,5 @@ import { | ||
// src/components/tooltip/tooltip-content/props.ts | ||
import { defaultTooltipContentProps as defaultProps } from "@aria-ui/tooltip"; | ||
import { | ||
defaultTooltipContentProps as defaultProps | ||
} from "@aria-ui/tooltip"; | ||
var defaultTooltipContentProps = { | ||
@@ -12,0 +14,0 @@ ...defaultProps, |
{ | ||
"name": "@prosekit/web", | ||
"type": "module", | ||
"version": "0.0.0-next-20240724173606", | ||
"version": "0.0.0-next-20240901092634", | ||
"private": false, | ||
@@ -58,2 +58,7 @@ "author": { | ||
}, | ||
"./table-handle": { | ||
"types": "./dist/prosekit-web-table-handle.d.ts", | ||
"import": "./dist/prosekit-web-table-handle.js", | ||
"default": "./dist/prosekit-web-table-handle.js" | ||
}, | ||
"./tooltip": { | ||
@@ -70,18 +75,21 @@ "types": "./dist/prosekit-web-tooltip.d.ts", | ||
"@aria-ui/collection": "^0.0.3", | ||
"@aria-ui/core": "^0.0.17", | ||
"@aria-ui/listbox": "^0.0.17", | ||
"@aria-ui/overlay": "^0.0.18", | ||
"@aria-ui/popover": "^0.0.19", | ||
"@aria-ui/presence": "^0.0.13", | ||
"@aria-ui/tooltip": "^0.0.21", | ||
"@floating-ui/dom": "^1.6.8", | ||
"@zag-js/dom-query": "^0.62.0", | ||
"@prosekit/core": "^0.0.0-next-20240724173606", | ||
"@prosekit/extensions": "^0.0.0-next-20240724173606", | ||
"@prosekit/pm": "^0.0.0-next-20240724173606" | ||
"@aria-ui/core": "^0.0.18", | ||
"@aria-ui/listbox": "^0.0.18", | ||
"@aria-ui/menu": "^0.0.12", | ||
"@aria-ui/overlay": "^0.0.19", | ||
"@aria-ui/popover": "^0.0.20", | ||
"@aria-ui/presence": "^0.0.14", | ||
"@aria-ui/tooltip": "^0.0.22", | ||
"@floating-ui/dom": "^1.6.10", | ||
"@zag-js/dom-query": "^0.65.1", | ||
"just-omit": "^2.2.0", | ||
"prosemirror-tables": "^1.5.0", | ||
"@prosekit/core": "^0.0.0-next-20240901092634", | ||
"@prosekit/extensions": "^0.0.0-next-20240901092634", | ||
"@prosekit/pm": "^0.0.0-next-20240901092634" | ||
}, | ||
"devDependencies": { | ||
"tsup": "^8.2.2", | ||
"typescript": "^5.5.3", | ||
"vitest": "^2.0.4", | ||
"tsup": "^8.2.4", | ||
"typescript": "^5.5.4", | ||
"vitest": "^2.0.5", | ||
"@prosekit/dev": "0.0.0" | ||
@@ -114,2 +122,5 @@ }, | ||
], | ||
"table-handle": [ | ||
"./dist/prosekit-web-table-handle.d.ts" | ||
], | ||
"tooltip": [ | ||
@@ -116,0 +127,0 @@ "./dist/prosekit-web-tooltip.d.ts" |
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
100096
22
2643
15
+ Added@aria-ui/menu@^0.0.12
+ Addedjust-omit@^2.2.0
+ Addedprosemirror-tables@^1.5.0
+ Added@aria-ui/core@0.0.18(transitive)
+ Added@aria-ui/listbox@0.0.18(transitive)
+ Added@aria-ui/menu@0.0.12(transitive)
+ Added@aria-ui/overlay@0.0.19(transitive)
+ Added@aria-ui/popover@0.0.20(transitive)
+ Added@aria-ui/presence@0.0.14(transitive)
+ Added@aria-ui/tooltip@0.0.22(transitive)
+ Added@zag-js/dismissable@0.63.0(transitive)
+ Added@zag-js/dom-event@0.63.0(transitive)
+ Added@zag-js/dom-query@0.63.00.65.1(transitive)
+ Added@zag-js/interact-outside@0.63.0(transitive)
+ Added@zag-js/text-selection@0.63.0(transitive)
+ Added@zag-js/types@0.63.0(transitive)
+ Added@zag-js/utils@0.63.0(transitive)
+ Addedjust-omit@2.2.0(transitive)
- Removed@aria-ui/core@0.0.17(transitive)
- Removed@aria-ui/listbox@0.0.17(transitive)
- Removed@aria-ui/overlay@0.0.18(transitive)
- Removed@aria-ui/popover@0.0.19(transitive)
- Removed@aria-ui/presence@0.0.13(transitive)
- Removed@aria-ui/tooltip@0.0.21(transitive)
- Removed@zag-js/dismissable@0.59.0(transitive)
- Removed@zag-js/dom-event@0.59.0(transitive)
- Removed@zag-js/dom-query@0.59.00.62.1(transitive)
- Removed@zag-js/interact-outside@0.59.0(transitive)
- Removed@zag-js/text-selection@0.59.0(transitive)
- Removed@zag-js/types@0.59.0(transitive)
- Removed@zag-js/utils@0.59.0(transitive)
Updated@aria-ui/core@^0.0.18
Updated@aria-ui/listbox@^0.0.18
Updated@aria-ui/overlay@^0.0.19
Updated@aria-ui/popover@^0.0.20
Updated@aria-ui/presence@^0.0.14
Updated@aria-ui/tooltip@^0.0.22
Updated@floating-ui/dom@^1.6.10
Updated@zag-js/dom-query@^0.65.1