@prosekit/preact 0.5.1 → 0.6.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.
Files changed (42) hide show
  1. package/dist/{create-component-D7yDR5ux.js → create-component-BqjC2d_2.js} +3 -3
  2. package/dist/{create-component-D7yDR5ux.js.map → create-component-BqjC2d_2.js.map} +1 -1
  3. package/dist/{create-props-EGV61dJR.d.ts → create-props-DTgCRwCm.d.ts} +2 -2
  4. package/dist/create-props-DTgCRwCm.d.ts.map +1 -0
  5. package/dist/{editor-context-imq7MdJr.js → editor-context-DNun2Non.js} +2 -2
  6. package/dist/{editor-context-imq7MdJr.js.map → editor-context-DNun2Non.js.map} +1 -1
  7. package/dist/prosekit-preact-autocomplete.d.ts +2 -2
  8. package/dist/prosekit-preact-autocomplete.d.ts.map +1 -1
  9. package/dist/prosekit-preact-autocomplete.js +2 -2
  10. package/dist/prosekit-preact-block-handle.d.ts +1 -1
  11. package/dist/prosekit-preact-block-handle.d.ts.map +1 -1
  12. package/dist/prosekit-preact-block-handle.js +2 -2
  13. package/dist/prosekit-preact-drop-indicator.d.ts +1 -1
  14. package/dist/prosekit-preact-drop-indicator.d.ts.map +1 -1
  15. package/dist/prosekit-preact-drop-indicator.js +2 -2
  16. package/dist/prosekit-preact-inline-popover.d.ts +1 -1
  17. package/dist/prosekit-preact-inline-popover.d.ts.map +1 -1
  18. package/dist/prosekit-preact-inline-popover.js +2 -2
  19. package/dist/prosekit-preact-popover.d.ts +1 -1
  20. package/dist/prosekit-preact-popover.d.ts.map +1 -1
  21. package/dist/prosekit-preact-popover.js +2 -2
  22. package/dist/prosekit-preact-resizable.d.ts +1 -1
  23. package/dist/prosekit-preact-resizable.d.ts.map +1 -1
  24. package/dist/prosekit-preact-resizable.js +2 -2
  25. package/dist/prosekit-preact-table-handle.d.ts +1 -1
  26. package/dist/prosekit-preact-table-handle.d.ts.map +1 -1
  27. package/dist/prosekit-preact-table-handle.js +2 -2
  28. package/dist/prosekit-preact-tooltip.d.ts +1 -1
  29. package/dist/prosekit-preact-tooltip.d.ts.map +1 -1
  30. package/dist/prosekit-preact-tooltip.js +2 -2
  31. package/dist/prosekit-preact.d.ts +88 -2
  32. package/dist/prosekit-preact.d.ts.map +1 -1
  33. package/dist/prosekit-preact.js +139 -24
  34. package/dist/prosekit-preact.js.map +1 -1
  35. package/package.json +9 -7
  36. package/src/components/prosekit.ts +14 -1
  37. package/src/extensions/preact-mark-view.ts +93 -0
  38. package/src/extensions/preact-node-view.ts +93 -0
  39. package/src/hooks/use-editor-derived-value.ts +83 -0
  40. package/src/hooks/use-extension.ts +1 -1
  41. package/src/index.ts +16 -0
  42. package/dist/create-props-EGV61dJR.d.ts.map +0 -1
@@ -1,4 +1,4 @@
1
- import { useEditorContext } from "./editor-context-imq7MdJr.js";
1
+ import { n as useEditorContext } from "./editor-context-DNun2Non.js";
2
2
  import { createElement } from "preact";
3
3
  import { useEffect, useLayoutEffect, useMemo, useRef, useState } from "preact/hooks";
4
4
  import { forwardRef } from "preact/compat";
@@ -93,5 +93,5 @@ function createComponent(tagName, displayName, propNames, eventNames) {
93
93
  }
94
94
 
95
95
  //#endregion
96
- export { createComponent };
97
- //# sourceMappingURL=create-component-D7yDR5ux.js.map
96
+ export { createComponent as t };
97
+ //# sourceMappingURL=create-component-BqjC2d_2.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"create-component-D7yDR5ux.js","names":["cleanups: VoidFunction[]","properties: Record<string, unknown>","attributes: Record<string, unknown>","eventHandlers: Record<string, AnyFunction>","fixedEventHandlers: Record<string, AnyFunction>"],"sources":["../src/components/merge-refs.ts","../src/components/create-component.ts"],"sourcesContent":["import type { Ref } from 'preact'\n\n/**\n * Assigns a value to a ref.\n * @returns The ref cleanup callback, if any.\n */\nfunction assignRef<T>(\n ref: Ref<T> | undefined,\n value: T | null,\n): VoidFunction | undefined | void {\n if (typeof ref === 'function') {\n return ref(value)\n } else if (ref) {\n ref.current = value\n }\n}\n\n/**\n * Merges multiple refs into a single one.\n */\nexport function mergeRefs<T>(refs: (Ref<T> | undefined)[]): Ref<T> {\n return (value: T | null) => {\n const cleanups: VoidFunction[] = []\n\n for (const ref of refs) {\n const cleanup = assignRef(ref, value)\n const isCleanup = typeof cleanup === 'function'\n cleanups.push(isCleanup ? cleanup : () => assignRef(ref, null))\n }\n\n return () => {\n for (const cleanup of cleanups) cleanup()\n }\n }\n}\n","import type { AnyFunction } from '@prosekit/core'\nimport { createElement } from 'preact'\nimport {\n forwardRef,\n type ForwardRefExoticComponent,\n type HTMLAttributes,\n type RefAttributes,\n} from 'preact/compat'\nimport {\n useEffect,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n} from 'preact/hooks'\n\nimport { useEditorContext } from '../contexts/editor-context'\n\nimport { mergeRefs } from './merge-refs'\n\nconst useIsomorphicLayoutEffect = typeof window !== 'undefined' ? useLayoutEffect : useEffect\n\nexport function createComponent<\n Props extends object,\n CustomElement extends HTMLElement,\n>(\n tagName: string,\n displayName: string,\n propNames: string[],\n eventNames: string[],\n): ForwardRefExoticComponent<\n Partial<Props> & RefAttributes<CustomElement> & HTMLAttributes<CustomElement>\n> {\n const hasEditor = propNames.includes('editor')\n const lowerCaseEventNameMap = new Map(\n eventNames.map((name) => [name.toLowerCase(), name]),\n )\n\n const Component = forwardRef<any, any>((props: Props, ref) => {\n const [el, setEl] = useState<HTMLElement | null>(null)\n\n const properties: Record<string, unknown> = {}\n const attributes: Record<string, unknown> = {}\n const eventHandlersRef = useRef<Record<string, AnyFunction>>({})\n const eventHandlers: Record<string, AnyFunction> = {}\n\n for (const [name, value] of Object.entries(props)) {\n if (value === undefined) {\n continue\n }\n\n if (propNames.includes(name)) {\n properties[name] = value\n continue\n }\n\n if (name.startsWith('on')) {\n const lowerCaseEventName = name.slice(2).toLowerCase()\n const eventName = lowerCaseEventNameMap.get(lowerCaseEventName)\n if (eventName) {\n const extractDetail = eventName.endsWith('Change')\n eventHandlers[eventName] = (event: Event) => {\n const handler = value as AnyFunction | null\n if (typeof handler === 'function') {\n handler(extractDetail ? (event as CustomEvent).detail : event)\n }\n }\n continue\n }\n }\n\n if (name === 'className') {\n attributes['class'] = value\n } else {\n attributes[name] = value\n }\n }\n\n const editor = useEditorContext()\n\n if (hasEditor && editor && !properties['editor']) {\n properties['editor'] = editor\n }\n\n // Set all properties.\n useIsomorphicLayoutEffect(() => {\n if (!el) return\n for (const [name, value] of Object.entries(properties)) {\n if (value !== undefined) {\n // @ts-expect-error: we know that name is a valid property name\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n el[name] = value as unknown as any\n }\n }\n }, [el, ...propNames.map((name) => properties[name])])\n\n // Put all event listeners extracted from `props` into `eventHandlersRef`.\n useIsomorphicLayoutEffect(() => {\n eventHandlersRef.current = eventHandlers\n })\n\n // Register the event listeners to the element.\n useIsomorphicLayoutEffect(() => {\n if (!el) {\n return\n }\n\n const fixedEventHandlers: Record<string, AnyFunction> = {}\n\n for (const eventName of eventNames) {\n fixedEventHandlers[eventName] = (event: Event) => {\n eventHandlersRef.current[eventName]?.(event)\n }\n }\n\n for (const [name, handler] of Object.entries(fixedEventHandlers)) {\n el.addEventListener(name, handler)\n }\n\n return () => {\n for (const [name, handler] of Object.entries(fixedEventHandlers)) {\n el.removeEventListener(name, handler)\n }\n }\n }, [el])\n\n const mergedRef = useMemo(() => mergeRefs([ref, setEl]), [ref])\n\n return createElement(tagName, { ...attributes, ref: mergedRef })\n })\n\n Component.displayName = displayName\n\n return Component\n}\n"],"mappings":";;;;;;;;;;AAMA,SAAS,UACP,KACA,OACiC;AACjC,KAAI,OAAO,QAAQ,WACjB,QAAO,IAAI,MAAM;UACR,IACT,KAAI,UAAU;;;;;AAOlB,SAAgB,UAAa,MAAsC;AACjE,SAAQ,UAAoB;EAC1B,MAAMA,WAA2B,EAAE;AAEnC,OAAK,MAAM,OAAO,MAAM;GACtB,MAAM,UAAU,UAAU,KAAK,MAAM;GACrC,MAAM,YAAY,OAAO,YAAY;A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KAAI,UAAU,OAGZ,IAAG,QAAQ;KAGd,CAAC,IAAI,GAAG,UAAU,KAAK,SAAS,WAAW,MAAM,CAAC,CAAC;AAGtD,kCAAgC;AAC9B,oBAAiB,UAAU;IAC3B;AAGF,kCAAgC;AAC9B,OAAI,CAAC,GACH;GAGF,MAAMC,qBAAkD,EAAE;AAE1D,QAAK,MAAM,aAAa,WACtB,oBAAmB,cAAc,UAAiB;AAChD,qBAAiB,QAAQ,aAAa,MAAM;;AAIhD,QAAK,MAAM,CAAC,MAAM,YAAY,OAAO,QAAQ,mBAAmB,CAC9D,IAAG,iBAAiB,MAAM,QAAQ;AAGpC,gBAAa;AACX,SAAK,MAAM,CAAC,MAAM,YAAY,OAAO,QAAQ,mBAAmB,CAC9D,IAAG,oBAAoB,MAAM,QAAQ;;KAGxC,CAAC,GAAG,CAAC;EAER,MAAM,YAAY,cAAc,UAAU,CAAC,KAAK,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC;AAE/D,SAAO,cAAc,SAAS;GAAE,GAAG;GAAY,KAAK;GAAW,CAAC;GAChE;AAEF,WAAU,cAAc;AAExB,QAAO"}
1
+ {"version":3,"file":"create-component-BqjC2d_2.js","names":["cleanups: VoidFunction[]","properties: Record<string, unknown>","attributes: Record<string, unknown>","eventHandlers: Record<string, AnyFunction>","fixedEventHandlers: Record<string, AnyFunction>"],"sources":["../src/components/merge-refs.ts","../src/components/create-component.ts"],"sourcesContent":["import type { Ref } from 'preact'\n\n/**\n * Assigns a value to a ref.\n * @returns The ref cleanup callback, if any.\n */\nfunction assignRef<T>(\n ref: Ref<T> | undefined,\n value: T | null,\n): VoidFunction | undefined | void {\n if (typeof ref === 'function') {\n return ref(value)\n } else if (ref) {\n ref.current = value\n }\n}\n\n/**\n * Merges multiple refs into a single one.\n */\nexport function mergeRefs<T>(refs: (Ref<T> | undefined)[]): Ref<T> {\n return (value: T | null) => {\n const cleanups: VoidFunction[] = []\n\n for (const ref of refs) {\n const cleanup = assignRef(ref, value)\n const isCleanup = typeof cleanup === 'function'\n cleanups.push(isCleanup ? cleanup : () => assignRef(ref, null))\n }\n\n return () => {\n for (const cleanup of cleanups) cleanup()\n }\n }\n}\n","import type { AnyFunction } from '@prosekit/core'\nimport { createElement } from 'preact'\nimport {\n forwardRef,\n type ForwardRefExoticComponent,\n type HTMLAttributes,\n type RefAttributes,\n} from 'preact/compat'\nimport {\n useEffect,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n} from 'preact/hooks'\n\nimport { useEditorContext } from '../contexts/editor-context'\n\nimport { mergeRefs } from './merge-refs'\n\nconst useIsomorphicLayoutEffect = typeof window !== 'undefined' ? useLayoutEffect : useEffect\n\nexport function createComponent<\n Props extends object,\n CustomElement extends HTMLElement,\n>(\n tagName: string,\n displayName: string,\n propNames: string[],\n eventNames: string[],\n): ForwardRefExoticComponent<\n Partial<Props> & RefAttributes<CustomElement> & HTMLAttributes<CustomElement>\n> {\n const hasEditor = propNames.includes('editor')\n const lowerCaseEventNameMap = new Map(\n eventNames.map((name) => [name.toLowerCase(), name]),\n )\n\n const Component = forwardRef<any, any>((props: Props, ref) => {\n const [el, setEl] = useState<HTMLElement | null>(null)\n\n const properties: Record<string, unknown> = {}\n const attributes: Record<string, unknown> = {}\n const eventHandlersRef = useRef<Record<string, AnyFunction>>({})\n const eventHandlers: Record<string, AnyFunction> = {}\n\n for (const [name, value] of Object.entries(props)) {\n if (value === undefined) {\n continue\n }\n\n if (propNames.includes(name)) {\n properties[name] = value\n continue\n }\n\n if (name.startsWith('on')) {\n const lowerCaseEventName = name.slice(2).toLowerCase()\n const eventName = lowerCaseEventNameMap.get(lowerCaseEventName)\n if (eventName) {\n const extractDetail = eventName.endsWith('Change')\n eventHandlers[eventName] = (event: Event) => {\n const handler = value as AnyFunction | null\n if (typeof handler === 'function') {\n handler(extractDetail ? (event as CustomEvent).detail : event)\n }\n }\n continue\n }\n }\n\n if (name === 'className') {\n attributes['class'] = value\n } else {\n attributes[name] = value\n }\n }\n\n const editor = useEditorContext()\n\n if (hasEditor && editor && !properties['editor']) {\n properties['editor'] = editor\n }\n\n // Set all properties.\n useIsomorphicLayoutEffect(() => {\n if (!el) return\n for (const [name, value] of Object.entries(properties)) {\n if (value !== undefined) {\n // @ts-expect-error: we know that name is a valid property name\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n el[name] = value as unknown as any\n }\n }\n }, [el, ...propNames.map((name) => properties[name])])\n\n // Put all event listeners extracted from `props` into `eventHandlersRef`.\n useIsomorphicLayoutEffect(() => {\n eventHandlersRef.current = eventHandlers\n })\n\n // Register the event listeners to the element.\n useIsomorphicLayoutEffect(() => {\n if (!el) {\n return\n }\n\n const fixedEventHandlers: Record<string, AnyFunction> = {}\n\n for (const eventName of eventNames) {\n fixedEventHandlers[eventName] = (event: Event) => {\n eventHandlersRef.current[eventName]?.(event)\n }\n }\n\n for (const [name, handler] of Object.entries(fixedEventHandlers)) {\n el.addEventListener(name, handler)\n }\n\n return () => {\n for (const [name, handler] of Object.entries(fixedEventHandlers)) {\n el.removeEventListener(name, handler)\n }\n }\n }, [el])\n\n const mergedRef = useMemo(() => mergeRefs([ref, setEl]), [ref])\n\n return createElement(tagName, { ...attributes, ref: mergedRef })\n })\n\n Component.displayName = displayName\n\n return Component\n}\n"],"mappings":";;;;;;;;;;AAMA,SAAS,UACP,KACA,OACiC;AACjC,KAAI,OAAO,QAAQ,WACjB,QAAO,IAAI,MAAM;UACR,IACT,KAAI,UAAU;;;;;AAOlB,SAAgB,UAAa,MAAsC;AACjE,SAAQ,UAAoB;EAC1B,MAAMA,WAA2B,EAAE;AAEnC,OAAK,MAAM,OAAO,MAAM;GACtB,MAAM,UAAU,UAAU,KAAK,MAAM;GACrC,MAAM,YAAY,OAAO,YAAY;AACrC,YAAS,KAAK,YAAY,gBAAgB,UAAU,KAAK,KAAK,CAAC;;AAGjE,eAAa;AACX,QAAK,MAAM,WAAW,SAAU,UAAS;;;;;;;ACX/C,MAAM,4BAA4B,OAAO,WAAW,cAA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kCAAgC;AAC9B,OAAI,CAAC,GACH;GAGF,MAAMC,qBAAkD,EAAE;AAE1D,QAAK,MAAM,aAAa,WACtB,oBAAmB,cAAc,UAAiB;AAChD,qBAAiB,QAAQ,aAAa,MAAM;;AAIhD,QAAK,MAAM,CAAC,MAAM,YAAY,OAAO,QAAQ,mBAAmB,CAC9D,IAAG,iBAAiB,MAAM,QAAQ;AAGpC,gBAAa;AACX,SAAK,MAAM,CAAC,MAAM,YAAY,OAAO,QAAQ,mBAAmB,CAC9D,IAAG,oBAAoB,MAAM,QAAQ;;KAGxC,CAAC,GAAG,CAAC;EAER,MAAM,YAAY,cAAc,UAAU,CAAC,KAAK,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC;AAE/D,SAAO,cAAc,SAAS;GAAE,GAAG;GAAY,KAAK;GAAW,CAAC;GAChE;AAEF,WAAU,cAAc;AAExB,QAAO"}
@@ -2,5 +2,5 @@
2
2
  type CreateProps<Props extends { [PropName in keyof Props]: unknown }, Events extends { [EventName in keyof Events]: CustomEvent }> = Props & CreateEventProps<Events>;
3
3
  type CreateEventProps<Events extends { [EventName in keyof Events]: CustomEvent }> = { [EventName in keyof Events as `on${Capitalize<string & EventName>}`]: (event: EventName extends `${string}Change` ? Events[EventName]['detail'] : Events[EventName]) => void };
4
4
  //#endregion
5
- export { CreateProps };
6
- //# sourceMappingURL=create-props-EGV61dJR.d.ts.map
5
+ export { CreateProps as t };
6
+ //# sourceMappingURL=create-props-DTgCRwCm.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-props-DTgCRwCm.d.ts","names":[],"sources":["../src/components/create-props.ts"],"sourcesContent":[],"mappings":";KAAY,yCAAA,MACyB,KADd,GAAA,OAAA,EACc,EAAA,eAAA,gBACE,MAAA,MAAA,GAAS,WAAT,EAAS,CAAA,GAC5C,KAD4C,GACpC,gBADoC,CACnB,MADmB,CAAA;KAG3C,gBAFD,CAAA,eAAA,gBAAyB,MAGU,MAHV,GAGmB,WAHnB,EAAjB,CAAA,GAAA,gBAAgB,MAKN,MALM,IAAA,KAKS,UALT,CAAA,MAAA,GAK6B,SAL7B,CAAA,EAAA,GAAA,CAAA,KAAA,EAMjB,SANiB,SAAA,GAAA,MAAA,QAAA,GAMqB,MANrB,CAM4B,SAN5B,CAAA,CAAA,QAAA,CAAA,GAOpB,MAPoB,CAOb,SAPa,CAAA,EAAA,GAAA,IAAA,EAAQ"}
@@ -15,5 +15,5 @@ function useEditorContext() {
15
15
  const EditorContextProvider = editorContext.Provider;
16
16
 
17
17
  //#endregion
18
- export { EditorContextProvider, useEditorContext };
19
- //# sourceMappingURL=editor-context-imq7MdJr.js.map
18
+ export { useEditorContext as n, EditorContextProvider as t };
19
+ //# sourceMappingURL=editor-context-DNun2Non.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"editor-context-imq7MdJr.js","names":["EditorContextProvider: Provider<Editor | null>"],"sources":["../src/contexts/editor-context.ts"],"sourcesContent":["import type {\n Editor,\n Extension,\n} from '@prosekit/core'\nimport {\n createContext,\n type Provider,\n} from 'preact'\nimport { useContext } from 'preact/hooks'\n\nconst editorContext = createContext<Editor | null>(null)\n\n/**\n * @internal\n */\nexport function useEditorContext<E extends Extension>(): Editor<E> | null {\n return useContext(editorContext)\n}\n\n/**\n * @internal\n */\nexport const EditorContextProvider: Provider<Editor | null> = editorContext.Provider\n"],"mappings":";;;;AAUA,MAAM,gBAAgB,cAA6B,KAAK;;;;AAKxD,SAAgB,mBAA0D;AACxE,QAAO,WAAW,cAAc;;;;;AAMlC,MAAaA,wBAAiD,cAAc"}
1
+ {"version":3,"file":"editor-context-DNun2Non.js","names":["EditorContextProvider: Provider<Editor | null>"],"sources":["../src/contexts/editor-context.ts"],"sourcesContent":["import type {\n Editor,\n Extension,\n} from '@prosekit/core'\nimport {\n createContext,\n type Provider,\n} from 'preact'\nimport { useContext } from 'preact/hooks'\n\nconst editorContext = createContext<Editor | null>(null)\n\n/**\n * @internal\n */\nexport function useEditorContext<E extends Extension>(): Editor<E> | null {\n return useContext(editorContext)\n}\n\n/**\n * @internal\n */\nexport const EditorContextProvider: Provider<Editor | null> = editorContext.Provider\n"],"mappings":";;;;AAUA,MAAM,gBAAgB,cAA6B,KAAK;;;;AAKxD,SAAgB,mBAA0D;AACxE,QAAO,WAAW,cAAc;;;;;AAMlC,MAAaA,wBAAiD,cAAc"}
@@ -1,6 +1,6 @@
1
- import { CreateProps } from "./create-props-EGV61dJR.js";
2
- import { AutocompleteEmptyElement, AutocompleteEmptyEvents, AutocompleteEmptyProps as AutocompleteEmptyProps$1, AutocompleteItemElement, AutocompleteItemEvents, AutocompleteItemProps as AutocompleteItemProps$1, AutocompleteListElement, AutocompleteListEvents, AutocompleteListProps as AutocompleteListProps$1, AutocompletePopoverElement, AutocompletePopoverEvents, AutocompletePopoverProps as AutocompletePopoverProps$1 } from "@prosekit/web/autocomplete";
1
+ import { t as CreateProps } from "./create-props-DTgCRwCm.js";
3
2
  import { ForwardRefExoticComponent, HTMLAttributes, RefAttributes } from "preact/compat";
3
+ import { AutocompleteEmptyElement, AutocompleteEmptyEvents, AutocompleteEmptyProps as AutocompleteEmptyProps$1, AutocompleteItemElement, AutocompleteItemEvents, AutocompleteItemProps as AutocompleteItemProps$1, AutocompleteListElement, AutocompleteListEvents, AutocompleteListProps as AutocompleteListProps$1, AutocompletePopoverElement, AutocompletePopoverEvents, AutocompletePopoverProps as AutocompletePopoverProps$1 } from "@prosekit/web/autocomplete";
4
4
 
5
5
  //#region src/components/autocomplete/autocomplete-empty.gen.d.ts
6
6
 
@@ -1 +1 @@
1
- {"version":3,"file":"prosekit-preact-autocomplete.d.ts","names":[],"sources":["../src/components/autocomplete/autocomplete-empty.gen.ts","../src/components/autocomplete/autocomplete-item.gen.ts","../src/components/autocomplete/autocomplete-list.gen.ts","../src/components/autocomplete/autocomplete-popover.gen.ts"],"sourcesContent":[],"mappings":";;;;;;;;AAmBA;AAAwC,UAAvB,sBAAA,SAA+B,OAAR,CAAgB,WAAhB,CAA4B,wBAA5B,EAAmC,uBAAnC,CAAA,CAAA,CAAA;AAAmC,cAE9D,iBAF8D,EAE3C,yBAF2C,CAGzE,OAHyE,CAGjE,sBAHiE,CAAA,GAIzE,aAJyE,CAI3D,wBAJ2D,CAAA,GAKzE,cALyE,CAK1D,wBAL0D,CAAA,CAAA;;;;;AAA3E;AAAwC,UCAvB,qBAAA,SAA8B,ODAP,CCAe,WDAf,CCA2B,uBDA3B,ECAkC,sBDAlC,CAAA,CAAA,CAAA;AAAmC,cCE9D,gBDF8D,ECE5C,yBDF4C,CCGzE,ODHyE,CCGjE,qBDHiE,CAAA,GCIzE,aDJyE,CCI3D,uBDJ2D,CAAA,GCKzE,cDLyE,CCK1D,uBDL0D,CAAA,CAAA;;;;;AAA3E;AAAwC,UEAvB,qBAAA,SAA8B,OFAP,CEAe,WFAf,CEA2B,uBFA3B,EEAkC,sBFAlC,CAAA,CAAA,CAAA;AAAmC,cEE9D,gBFF8D,EEE5C,yBFF4C,CEGzE,OFHyE,CEGjE,qBFHiE,CAAA,GEIzE,aFJyE,CEI3D,uBFJ2D,CAAA,GEKzE,cFLyE,CEK1D,uBFL0D,CAAA,CAAA;;;;;AAA3E;AAAwC,UGAvB,wBAAA,SAAiC,OHAV,CGAkB,WHAlB,CGA8B,0BHA9B,EGAqC,yBHArC,CAAA,CAAA,CAAA;AAAmC,cGE9D,mBHF8D,EGEzC,yBHFyC,CGGzE,OHHyE,CGGjE,wBHHiE,CAAA,GGIzE,aHJyE,CGI3D,0BHJ2D,CAAA,GGKzE,cHLyE,CGK1D,0BHL0D,CAAA,CAAA"}
1
+ {"version":3,"file":"prosekit-preact-autocomplete.d.ts","names":[],"sources":["../src/components/autocomplete/autocomplete-empty.gen.ts","../src/components/autocomplete/autocomplete-item.gen.ts","../src/components/autocomplete/autocomplete-list.gen.ts","../src/components/autocomplete/autocomplete-popover.gen.ts"],"sourcesContent":[],"mappings":";;;;;;;;AAmBA;AAAoE,UAAnD,sBAAA,SAA+B,OAAoB,CAAZ,WAAY,CAAA,wBAAA,EAAO,uBAAP,CAAA,CAAA,CAAA;AAAZ,cAE3C,iBAF2C,EAExB,yBAFwB,CAGtD,OAHsD,CAG9C,sBAH8C,CAAA,GAItD,aAJsD,CAIxC,wBAJwC,CAAA,GAKtD,cALsD,CAKvC,wBALuC,CAAA,CAAA;;;;;AAAxD;AAAoE,UCAnD,qBAAA,SAA8B,ODAqB,CCAb,WDAa,CCAD,uBDAC,ECAM,sBDAN,CAAA,CAAA,CAAA;AAAZ,cCE3C,gBDF2C,ECEzB,yBDFyB,CCGtD,ODHsD,CCG9C,qBDH8C,CAAA,GCItD,aDJsD,CCIxC,uBDJwC,CAAA,GCKtD,cDLsD,CCKvC,uBDLuC,CAAA,CAAA;;;;;AAAxD;AAAoE,UEAnD,qBAAA,SAA8B,OFAqB,CEAb,WFAa,CEAD,uBFAC,EEAM,sBFAN,CAAA,CAAA,CAAA;AAAZ,cEE3C,gBFF2C,EEEzB,yBFFyB,CEGtD,OFHsD,CEG9C,qBFH8C,CAAA,GEItD,aFJsD,CEIxC,uBFJwC,CAAA,GEKtD,cFLsD,CEKvC,uBFLuC,CAAA,CAAA;;;;;AAAxD;AAAoE,UGAnD,wBAAA,SAAiC,OHAkB,CGAV,WHAU,CGAE,0BHAF,EGAS,yBHAT,CAAA,CAAA,CAAA;AAAZ,cGE3C,mBHF2C,EGEtB,yBHFsB,CGGtD,OHHsD,CGG9C,wBHH8C,CAAA,GGItD,aHJsD,CGIxC,0BHJwC,CAAA,GGKtD,cHLsD,CGKvC,0BHLuC,CAAA,CAAA"}
@@ -1,5 +1,5 @@
1
- import "./editor-context-imq7MdJr.js";
2
- import { createComponent } from "./create-component-D7yDR5ux.js";
1
+ import "./editor-context-DNun2Non.js";
2
+ import { t as createComponent } from "./create-component-BqjC2d_2.js";
3
3
  import { autocompleteEmptyEvents, autocompleteEmptyProps, autocompleteItemEvents, autocompleteItemProps, autocompleteListEvents, autocompleteListProps, autocompletePopoverEvents, autocompletePopoverProps } from "@prosekit/web/autocomplete";
4
4
 
5
5
  //#region src/components/autocomplete/autocomplete-empty.gen.ts
@@ -1,4 +1,4 @@
1
- import { CreateProps } from "./create-props-EGV61dJR.js";
1
+ import { t as CreateProps } from "./create-props-DTgCRwCm.js";
2
2
  import { ForwardRefExoticComponent, HTMLAttributes, RefAttributes } from "preact/compat";
3
3
  import { BlockHandleAddElement, BlockHandleAddEvents, BlockHandleAddProps as BlockHandleAddProps$1, BlockHandleDraggableElement, BlockHandleDraggableEvents, BlockHandleDraggableProps as BlockHandleDraggableProps$1, BlockHandlePopoverElement, BlockHandlePopoverEvents, BlockHandlePopoverProps as BlockHandlePopoverProps$1 } from "@prosekit/web/block-handle";
4
4
 
@@ -1 +1 @@
1
- {"version":3,"file":"prosekit-preact-block-handle.d.ts","names":[],"sources":["../src/components/block-handle/block-handle-add.gen.ts","../src/components/block-handle/block-handle-draggable.gen.ts","../src/components/block-handle/block-handle-popover.gen.ts"],"sourcesContent":[],"mappings":";;;;;;;;AAmBA;AAAqC,UAApB,mBAAA,SAA4B,OAAR,CAAgB,WAAhB,CAA4B,qBAA5B,EAAmC,oBAAnC,CAAA,CAAA,CAAA;AAAmC,cAE3D,cAF2D,EAE3C,yBAF2C,CAGtE,OAHsE,CAG9D,mBAH8D,CAAA,GAItE,aAJsE,CAIxD,qBAJwD,CAAA,GAKtE,cALsE,CAKvD,qBALuD,CAAA,CAAA;;;;;AAAxE;AAAqC,UCApB,yBAAA,SAAkC,ODAd,CCAsB,WDAtB,CCAkC,2BDAlC,ECAyC,0BDAzC,CAAA,CAAA,CAAA;AAAmC,cCE3D,oBDF2D,ECErC,yBDFqC,CCGtE,ODHsE,CCG9D,yBDH8D,CAAA,GCItE,aDJsE,CCIxD,2BDJwD,CAAA,GCKtE,cDLsE,CCKvD,2BDLuD,CAAA,CAAA;;;;;AAAxE;AAAqC,UEApB,uBAAA,SAAgC,OFAZ,CEAoB,WFApB,CEAgC,yBFAhC,EEAuC,wBFAvC,CAAA,CAAA,CAAA;AAAmC,cEE3D,kBFF2D,EEEvC,yBFFuC,CEGtE,OFHsE,CEG9D,uBFH8D,CAAA,GEItE,aFJsE,CEIxD,yBFJwD,CAAA,GEKtE,cFLsE,CEKvD,yBFLuD,CAAA,CAAA"}
1
+ {"version":3,"file":"prosekit-preact-block-handle.d.ts","names":[],"sources":["../src/components/block-handle/block-handle-add.gen.ts","../src/components/block-handle/block-handle-draggable.gen.ts","../src/components/block-handle/block-handle-popover.gen.ts"],"sourcesContent":[],"mappings":";;;;;;;;AAmBA;AAAiE,UAAhD,mBAAA,SAA4B,OAAoB,CAAZ,WAAY,CAAA,qBAAA,EAAO,oBAAP,CAAA,CAAA,CAAA;AAAZ,cAExC,cAFwC,EAExB,yBAFwB,CAGnD,OAHmD,CAG3C,mBAH2C,CAAA,GAInD,aAJmD,CAIrC,qBAJqC,CAAA,GAKnD,cALmD,CAKpC,qBALoC,CAAA,CAAA;;;;;AAArD;AAAiE,UCAhD,yBAAA,SAAkC,ODAc,CCAN,WDAM,CCAM,2BDAN,ECAa,0BDAb,CAAA,CAAA,CAAA;AAAZ,cCExC,oBDFwC,ECElB,yBDFkB,CCGnD,ODHmD,CCG3C,yBDH2C,CAAA,GCInD,aDJmD,CCIrC,2BDJqC,CAAA,GCKnD,cDLmD,CCKpC,2BDLoC,CAAA,CAAA;;;;;AAArD;AAAiE,UEAhD,uBAAA,SAAgC,OFAgB,CEAR,WFAQ,CEAI,yBFAJ,EEAW,wBFAX,CAAA,CAAA,CAAA;AAAZ,cEExC,kBFFwC,EEEpB,yBFFoB,CEGnD,OFHmD,CEG3C,uBFH2C,CAAA,GEInD,aFJmD,CEIrC,yBFJqC,CAAA,GEKnD,cFLmD,CEKpC,yBFLoC,CAAA,CAAA"}
@@ -1,5 +1,5 @@
1
- import "./editor-context-imq7MdJr.js";
2
- import { createComponent } from "./create-component-D7yDR5ux.js";
1
+ import "./editor-context-DNun2Non.js";
2
+ import { t as createComponent } from "./create-component-BqjC2d_2.js";
3
3
  import { blockHandleAddEvents, blockHandleAddProps, blockHandleDraggableEvents, blockHandleDraggableProps, blockHandlePopoverEvents, blockHandlePopoverProps } from "@prosekit/web/block-handle";
4
4
 
5
5
  //#region src/components/block-handle/block-handle-add.gen.ts
@@ -1,4 +1,4 @@
1
- import { CreateProps } from "./create-props-EGV61dJR.js";
1
+ import { t as CreateProps } from "./create-props-DTgCRwCm.js";
2
2
  import { ForwardRefExoticComponent, HTMLAttributes, RefAttributes } from "preact/compat";
3
3
  import { DropIndicatorElement, DropIndicatorEvents, DropIndicatorProps as DropIndicatorProps$1 } from "@prosekit/web/drop-indicator";
4
4
 
@@ -1 +1 @@
1
- {"version":3,"file":"prosekit-preact-drop-indicator.d.ts","names":[],"sources":["../src/components/drop-indicator/drop-indicator.gen.ts"],"sourcesContent":[],"mappings":";;;;;;;;AAmBA;AAAoC,UAAnB,kBAAA,SAA2B,OAAR,CAAgB,WAAhB,CAA4B,oBAA5B,EAAmC,mBAAnC,CAAA,CAAA,CAAA;AAAmC,cAE1D,aAF0D,EAE3C,yBAF2C,CAGrE,OAHqE,CAG7D,kBAH6D,CAAA,GAIrE,aAJqE,CAIvD,oBAJuD,CAAA,GAKrE,cALqE,CAKtD,oBALsD,CAAA,CAAA"}
1
+ {"version":3,"file":"prosekit-preact-drop-indicator.d.ts","names":[],"sources":["../src/components/drop-indicator/drop-indicator.gen.ts"],"sourcesContent":[],"mappings":";;;;;;;;AAmBA;AAAgE,UAA/C,kBAAA,SAA2B,OAAoB,CAAZ,WAAY,CAAA,oBAAA,EAAO,mBAAP,CAAA,CAAA,CAAA;AAAZ,cAEvC,aAFuC,EAExB,yBAFwB,CAGlD,OAHkD,CAG1C,kBAH0C,CAAA,GAIlD,aAJkD,CAIpC,oBAJoC,CAAA,GAKlD,cALkD,CAKnC,oBALmC,CAAA,CAAA"}
@@ -1,5 +1,5 @@
1
- import "./editor-context-imq7MdJr.js";
2
- import { createComponent } from "./create-component-D7yDR5ux.js";
1
+ import "./editor-context-DNun2Non.js";
2
+ import { t as createComponent } from "./create-component-BqjC2d_2.js";
3
3
  import { dropIndicatorEvents, dropIndicatorProps } from "@prosekit/web/drop-indicator";
4
4
 
5
5
  //#region src/components/drop-indicator/drop-indicator.gen.ts
@@ -1,4 +1,4 @@
1
- import { CreateProps } from "./create-props-EGV61dJR.js";
1
+ import { t as CreateProps } from "./create-props-DTgCRwCm.js";
2
2
  import { ForwardRefExoticComponent, HTMLAttributes, RefAttributes } from "preact/compat";
3
3
  import { InlinePopoverElement, InlinePopoverEvents, InlinePopoverProps as InlinePopoverProps$1 } from "@prosekit/web/inline-popover";
4
4
 
@@ -1 +1 @@
1
- {"version":3,"file":"prosekit-preact-inline-popover.d.ts","names":[],"sources":["../src/components/inline-popover/inline-popover.gen.ts"],"sourcesContent":[],"mappings":";;;;;;;;AAmBA;AAAoC,UAAnB,kBAAA,SAA2B,OAAR,CAAgB,WAAhB,CAA4B,oBAA5B,EAAmC,mBAAnC,CAAA,CAAA,CAAA;AAAmC,cAE1D,aAF0D,EAE3C,yBAF2C,CAGrE,OAHqE,CAG7D,kBAH6D,CAAA,GAIrE,aAJqE,CAIvD,oBAJuD,CAAA,GAKrE,cALqE,CAKtD,oBALsD,CAAA,CAAA"}
1
+ {"version":3,"file":"prosekit-preact-inline-popover.d.ts","names":[],"sources":["../src/components/inline-popover/inline-popover.gen.ts"],"sourcesContent":[],"mappings":";;;;;;;;AAmBA;AAAgE,UAA/C,kBAAA,SAA2B,OAAoB,CAAZ,WAAY,CAAA,oBAAA,EAAO,mBAAP,CAAA,CAAA,CAAA;AAAZ,cAEvC,aAFuC,EAExB,yBAFwB,CAGlD,OAHkD,CAG1C,kBAH0C,CAAA,GAIlD,aAJkD,CAIpC,oBAJoC,CAAA,GAKlD,cALkD,CAKnC,oBALmC,CAAA,CAAA"}
@@ -1,5 +1,5 @@
1
- import "./editor-context-imq7MdJr.js";
2
- import { createComponent } from "./create-component-D7yDR5ux.js";
1
+ import "./editor-context-DNun2Non.js";
2
+ import { t as createComponent } from "./create-component-BqjC2d_2.js";
3
3
  import { inlinePopoverEvents, inlinePopoverProps } from "@prosekit/web/inline-popover";
4
4
 
5
5
  //#region src/components/inline-popover/inline-popover.gen.ts
@@ -1,4 +1,4 @@
1
- import { CreateProps } from "./create-props-EGV61dJR.js";
1
+ import { t as CreateProps } from "./create-props-DTgCRwCm.js";
2
2
  import { ForwardRefExoticComponent, HTMLAttributes, RefAttributes } from "preact/compat";
3
3
  import { PopoverContentElement, PopoverContentEvents, PopoverContentProps as PopoverContentProps$1, PopoverRootElement, PopoverRootEvents, PopoverRootProps as PopoverRootProps$1, PopoverTriggerElement, PopoverTriggerEvents, PopoverTriggerProps as PopoverTriggerProps$1 } from "@prosekit/web/popover";
4
4
 
@@ -1 +1 @@
1
- {"version":3,"file":"prosekit-preact-popover.d.ts","names":[],"sources":["../src/components/popover/popover-content.gen.ts","../src/components/popover/popover-root.gen.ts","../src/components/popover/popover-trigger.gen.ts"],"sourcesContent":[],"mappings":";;;;;;;;AAmBA;AAAqC,UAApB,mBAAA,SAA4B,OAAR,CAAgB,WAAhB,CAA4B,qBAA5B,EAAmC,oBAAnC,CAAA,CAAA,CAAA;AAAmC,cAE3D,cAF2D,EAE3C,yBAF2C,CAGtE,OAHsE,CAG9D,mBAH8D,CAAA,GAItE,aAJsE,CAIxD,qBAJwD,CAAA,GAKtE,cALsE,CAKvD,qBALuD,CAAA,CAAA;;;;;AAAxE;AAAqC,UCApB,gBAAA,SAAyB,ODAL,CCAa,WDAb,CCAyB,kBDAzB,ECAgC,iBDAhC,CAAA,CAAA,CAAA;AAAmC,cCE3D,WDF2D,ECE9C,yBDF8C,CCGtE,ODHsE,CCG9D,gBDH8D,CAAA,GCItE,aDJsE,CCIxD,kBDJwD,CAAA,GCKtE,cDLsE,CCKvD,kBDLuD,CAAA,CAAA;;;;;AAAxE;AAAqC,UEApB,mBAAA,SAA4B,OFAR,CEAgB,WFAhB,CEA4B,qBFA5B,EEAmC,oBFAnC,CAAA,CAAA,CAAA;AAAmC,cEE3D,cFF2D,EEE3C,yBFF2C,CEGtE,OFHsE,CEG9D,mBFH8D,CAAA,GEItE,aFJsE,CEIxD,qBFJwD,CAAA,GEKtE,cFLsE,CEKvD,qBFLuD,CAAA,CAAA"}
1
+ {"version":3,"file":"prosekit-preact-popover.d.ts","names":[],"sources":["../src/components/popover/popover-content.gen.ts","../src/components/popover/popover-root.gen.ts","../src/components/popover/popover-trigger.gen.ts"],"sourcesContent":[],"mappings":";;;;;;;;AAmBA;AAAiE,UAAhD,mBAAA,SAA4B,OAAoB,CAAZ,WAAY,CAAA,qBAAA,EAAO,oBAAP,CAAA,CAAA,CAAA;AAAZ,cAExC,cAFwC,EAExB,yBAFwB,CAGnD,OAHmD,CAG3C,mBAH2C,CAAA,GAInD,aAJmD,CAIrC,qBAJqC,CAAA,GAKnD,cALmD,CAKpC,qBALoC,CAAA,CAAA;;;;;AAArD;AAAiE,UCAhD,gBAAA,SAAyB,ODAuB,CCAf,WDAe,CCAH,kBDAG,ECAI,iBDAJ,CAAA,CAAA,CAAA;AAAZ,cCExC,WDFwC,ECE3B,yBDF2B,CCGnD,ODHmD,CCG3C,gBDH2C,CAAA,GCInD,aDJmD,CCIrC,kBDJqC,CAAA,GCKnD,cDLmD,CCKpC,kBDLoC,CAAA,CAAA;;;;;AAArD;AAAiE,UEAhD,mBAAA,SAA4B,OFAoB,CEAZ,WFAY,CEAA,qBFAA,EEAO,oBFAP,CAAA,CAAA,CAAA;AAAZ,cEExC,cFFwC,EEExB,yBFFwB,CEGnD,OFHmD,CEG3C,mBFH2C,CAAA,GEInD,aFJmD,CEIrC,qBFJqC,CAAA,GEKnD,cFLmD,CEKpC,qBFLoC,CAAA,CAAA"}
@@ -1,5 +1,5 @@
1
- import "./editor-context-imq7MdJr.js";
2
- import { createComponent } from "./create-component-D7yDR5ux.js";
1
+ import "./editor-context-DNun2Non.js";
2
+ import { t as createComponent } from "./create-component-BqjC2d_2.js";
3
3
  import { popoverContentEvents, popoverContentProps, popoverRootEvents, popoverRootProps, popoverTriggerEvents, popoverTriggerProps } from "@prosekit/web/popover";
4
4
 
5
5
  //#region src/components/popover/popover-content.gen.ts
@@ -1,4 +1,4 @@
1
- import { CreateProps } from "./create-props-EGV61dJR.js";
1
+ import { t as CreateProps } from "./create-props-DTgCRwCm.js";
2
2
  import { ForwardRefExoticComponent, HTMLAttributes, RefAttributes } from "preact/compat";
3
3
  import { ResizableHandleElement, ResizableHandleEvents, ResizableHandleProps as ResizableHandleProps$1, ResizableRootElement, ResizableRootEvents, ResizableRootProps as ResizableRootProps$1 } from "@prosekit/web/resizable";
4
4
 
@@ -1 +1 @@
1
- {"version":3,"file":"prosekit-preact-resizable.d.ts","names":[],"sources":["../src/components/resizable/resizable-handle.gen.ts","../src/components/resizable/resizable-root.gen.ts"],"sourcesContent":[],"mappings":";;;;;;;;AAmBA;AAAsC,UAArB,oBAAA,SAA6B,OAAR,CAAgB,WAAhB,CAA4B,sBAA5B,EAAmC,qBAAnC,CAAA,CAAA,CAAA;AAAmC,cAE5D,eAF4D,EAE3C,yBAF2C,CAGvE,OAHuE,CAG/D,oBAH+D,CAAA,GAIvE,aAJuE,CAIzD,sBAJyD,CAAA,GAKvE,cALuE,CAKxD,sBALwD,CAAA,CAAA;;;;;AAAzE;AAAsC,UCArB,kBAAA,SAA2B,ODAN,CCAc,WDAd,CCA0B,oBDA1B,ECAiC,mBDAjC,CAAA,CAAA,CAAA;AAAmC,cCE5D,aDF4D,ECE7C,yBDF6C,CCGvE,ODHuE,CCG/D,kBDH+D,CAAA,GCIvE,aDJuE,CCIzD,oBDJyD,CAAA,GCKvE,cDLuE,CCKxD,oBDLwD,CAAA,CAAA"}
1
+ {"version":3,"file":"prosekit-preact-resizable.d.ts","names":[],"sources":["../src/components/resizable/resizable-handle.gen.ts","../src/components/resizable/resizable-root.gen.ts"],"sourcesContent":[],"mappings":";;;;;;;;AAmBA;AAAkE,UAAjD,oBAAA,SAA6B,OAAoB,CAAZ,WAAY,CAAA,sBAAA,EAAO,qBAAP,CAAA,CAAA,CAAA;AAAZ,cAEzC,eAFyC,EAExB,yBAFwB,CAGpD,OAHoD,CAG5C,oBAH4C,CAAA,GAIpD,aAJoD,CAItC,sBAJsC,CAAA,GAKpD,cALoD,CAKrC,sBALqC,CAAA,CAAA;;;;;AAAtD;AAAkE,UCAjD,kBAAA,SAA2B,ODAsB,CCAd,WDAc,CCAF,oBDAE,ECAK,mBDAL,CAAA,CAAA,CAAA;AAAZ,cCEzC,aDFyC,ECE1B,yBDF0B,CCGpD,ODHoD,CCG5C,kBDH4C,CAAA,GCIpD,aDJoD,CCItC,oBDJsC,CAAA,GCKpD,cDLoD,CCKrC,oBDLqC,CAAA,CAAA"}
@@ -1,5 +1,5 @@
1
- import "./editor-context-imq7MdJr.js";
2
- import { createComponent } from "./create-component-D7yDR5ux.js";
1
+ import "./editor-context-DNun2Non.js";
2
+ import { t as createComponent } from "./create-component-BqjC2d_2.js";
3
3
  import { resizableHandleEvents, resizableHandleProps, resizableRootEvents, resizableRootProps } from "@prosekit/web/resizable";
4
4
 
5
5
  //#region src/components/resizable/resizable-handle.gen.ts
@@ -1,4 +1,4 @@
1
- import { CreateProps } from "./create-props-EGV61dJR.js";
1
+ import { t as CreateProps } from "./create-props-DTgCRwCm.js";
2
2
  import { ForwardRefExoticComponent, HTMLAttributes, RefAttributes } from "preact/compat";
3
3
  import { TableHandleColumnRootElement, TableHandleColumnRootEvents, TableHandleColumnRootProps as TableHandleColumnRootProps$1, TableHandleColumnTriggerElement, TableHandleColumnTriggerEvents, TableHandleColumnTriggerProps as TableHandleColumnTriggerProps$1, TableHandleDragPreviewElement, TableHandleDragPreviewEvents, TableHandleDragPreviewProps as TableHandleDragPreviewProps$1, TableHandleDropIndicatorElement, TableHandleDropIndicatorEvents, TableHandleDropIndicatorProps as TableHandleDropIndicatorProps$1, TableHandlePopoverContentElement, TableHandlePopoverContentEvents, TableHandlePopoverContentProps as TableHandlePopoverContentProps$1, TableHandlePopoverItemElement, TableHandlePopoverItemEvents, TableHandlePopoverItemProps as TableHandlePopoverItemProps$1, TableHandleRootElement, TableHandleRootEvents, TableHandleRootProps as TableHandleRootProps$1, TableHandleRowRootElement, TableHandleRowRootEvents, TableHandleRowRootProps as TableHandleRowRootProps$1, TableHandleRowTriggerElement, TableHandleRowTriggerEvents, TableHandleRowTriggerProps as TableHandleRowTriggerProps$1 } from "@prosekit/web/table-handle";
4
4
 
@@ -1 +1 @@
1
- {"version":3,"file":"prosekit-preact-table-handle.d.ts","names":[],"sources":["../src/components/table-handle/table-handle-column-root.gen.ts","../src/components/table-handle/table-handle-column-trigger.gen.ts","../src/components/table-handle/table-handle-drag-preview.gen.ts","../src/components/table-handle/table-handle-drop-indicator.gen.ts","../src/components/table-handle/table-handle-popover-content.gen.ts","../src/components/table-handle/table-handle-popover-item.gen.ts","../src/components/table-handle/table-handle-root.gen.ts","../src/components/table-handle/table-handle-row-root.gen.ts","../src/components/table-handle/table-handle-row-trigger.gen.ts"],"sourcesContent":[],"mappings":";;;;;;;;AAmBA;AAA4C,UAA3B,0BAAA,SAAmC,OAAR,CAAgB,WAAhB,CAA4B,4BAA5B,EAAmC,2BAAnC,CAAA,CAAA,CAAA;AAAmC,cAElE,qBAFkE,EAE3C,yBAF2C,CAG7E,OAH6E,CAGrE,0BAHqE,CAAA,GAI7E,aAJ6E,CAI/D,4BAJ+D,CAAA,GAK7E,cAL6E,CAK9D,4BAL8D,CAAA,CAAA;;;;;AAA/E;AAA4C,UCA3B,6BAAA,SAAsC,ODAX,CCAmB,WDAnB,CCA+B,+BDA/B,ECAsC,8BDAtC,CAAA,CAAA,CAAA;AAAmC,cCElE,wBDFkE,ECExC,yBDFwC,CCG7E,ODH6E,CCGrE,6BDHqE,CAAA,GCI7E,aDJ6E,CCI/D,+BDJ+D,CAAA,GCK7E,cDL6E,CCK9D,+BDL8D,CAAA,CAAA;;;;;AAA/E;AAA4C,UEA3B,2BAAA,SAAoC,OFAT,CEAiB,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CMK9D,sBNL8D,CAAA,CAAA;;;;;AAA/E;AAA4C,UOA3B,uBAAA,SAAgC,OPAL,COAa,WPAb,COAyB,yBPAzB,EOAgC,wBPAhC,CAAA,CAAA,CAAA;AAAmC,cOElE,kBPFkE,EOE9C,yBPF8C,COG7E,OPH6E,COGrE,uBPHqE,CAAA,GOI7E,aPJ6E,COI/D,yBPJ+D,CAAA,GOK7E,cPL6E,COK9D,yBPL8D,CAAA,CAAA;;;;;AAA/E;AAA4C,UQA3B,0BAAA,SAAmC,ORAR,CQAgB,WRAhB,CQA4B,4BRA5B,EQAmC,2BRAnC,CAAA,CAAA,CAAA;AAAmC,cQElE,qBRFkE,EQE3C,yBRF2C,CQG7E,ORH6E,CQGrE,0BRHqE,CAAA,GQI7E,aRJ6E,CQI/D,4BRJ+D,CAAA,GQK7E,cRL6E,CQK9D,4BRL8D,CAAA,CAAA"}
1
+ {"version":3,"file":"prosekit-preact-table-handle.d.ts","names":[],"sources":["../src/components/table-handle/table-handle-column-root.gen.ts","../src/components/table-handle/table-handle-column-trigger.gen.ts","../src/components/table-handle/table-handle-drag-preview.gen.ts","../src/components/table-handle/table-handle-drop-indicator.gen.ts","../src/components/table-handle/table-handle-popover-content.gen.ts","../src/components/table-handle/table-handle-popover-item.gen.ts","../src/components/table-handle/table-handle-root.gen.ts","../src/components/table-handle/table-handle-row-root.gen.ts","../src/components/table-handle/table-handle-row-trigger.gen.ts"],"sourcesContent":[],"mappings":";;;;;;;;AAmBA;AAAwE,UAAvD,0BAAA,SAAmC,OAAoB,CAAZ,WAAY,CAAA,4BAAA,EAAO,2BAAP,CAAA,CAAA,CAAA;AAAZ,cAE/C,qBAF+C,EAExB,yBAFwB,CAG1D,OAH0D,CAGlD,0BAHkD,CAAA,GAI1D,aAJ0D,CAI5C,4BAJ4C,CAAA,GAK1D,cAL0D,CAK3C,4BAL2C,CAAA,CAAA;;;;;AAA5D;AAAwE,UCAvD,6BAAA,SAAsC,ODAiB,CCAT,WDAS,CCAG,+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;;;;AAA5D;AAAwE,UMAvD,oBAAA,SAA6B,ONA0B,CMAlB,WNAkB,CMAN,sBNAM,EMAC,qBNAD,CAAA,CAAA,CAAA;AAAZ,cME/C,eNF+C,EME9B,yBNF8B,CMG1D,ONH0D,CMGlD,oBNHkD,CAAA,GMI1D,aNJ0D,CMI5C,sBNJ4C,CAAA,GMK1D,cNL0D,CMK3C,sBNL2C,CAAA,CAAA;;;;;AAA5D;AAAwE,UOAvD,uBAAA,SAAgC,OPAuB,COAf,WPAe,COAH,yBPAG,EOAI,wBPAJ,CAAA,CAAA,CAAA;AAAZ,cOE/C,kBPF+C,EOE3B,yBPF2B,COG1D,OPH0D,COGlD,uBPHkD,CAAA,GOI1D,aPJ0D,COI5C,yBPJ4C,CAAA,GOK1D,cPL0D,COK3C,yBPL2C,CAAA,CAAA;;;;;AAA5D;AAAwE,UQAvD,0BAAA,SAAmC,ORAoB,CQAZ,WRAY,CQAA,4BRAA,EQAO,2BRAP,CAAA,CAAA,CAAA;AAAZ,cQE/C,qBRF+C,EQExB,yBRFwB,CQG1D,ORH0D,CQGlD,0BRHkD,CAAA,GQI1D,aRJ0D,CQI5C,4BRJ4C,CAAA,GQK1D,cRL0D,CQK3C,4BRL2C,CAAA,CAAA"}
@@ -1,5 +1,5 @@
1
- import "./editor-context-imq7MdJr.js";
2
- import { createComponent } from "./create-component-D7yDR5ux.js";
1
+ import "./editor-context-DNun2Non.js";
2
+ import { t as createComponent } from "./create-component-BqjC2d_2.js";
3
3
  import { tableHandleColumnRootEvents, tableHandleColumnRootProps, tableHandleColumnTriggerEvents, tableHandleColumnTriggerProps, tableHandleDragPreviewEvents, tableHandleDragPreviewProps, tableHandleDropIndicatorEvents, tableHandleDropIndicatorProps, tableHandlePopoverContentEvents, tableHandlePopoverContentProps, tableHandlePopoverItemEvents, tableHandlePopoverItemProps, tableHandleRootEvents, tableHandleRootProps, tableHandleRowRootEvents, tableHandleRowRootProps, tableHandleRowTriggerEvents, tableHandleRowTriggerProps } from "@prosekit/web/table-handle";
4
4
 
5
5
  //#region src/components/table-handle/table-handle-column-root.gen.ts
@@ -1,4 +1,4 @@
1
- import { CreateProps } from "./create-props-EGV61dJR.js";
1
+ import { t as CreateProps } from "./create-props-DTgCRwCm.js";
2
2
  import { ForwardRefExoticComponent, HTMLAttributes, RefAttributes } from "preact/compat";
3
3
  import { TooltipContentElement, TooltipContentEvents, TooltipContentProps as TooltipContentProps$1, TooltipRootElement, TooltipRootEvents, TooltipRootProps as TooltipRootProps$1, TooltipTriggerElement, TooltipTriggerEvents, TooltipTriggerProps as TooltipTriggerProps$1 } from "@prosekit/web/tooltip";
4
4
 
@@ -1 +1 @@
1
- {"version":3,"file":"prosekit-preact-tooltip.d.ts","names":[],"sources":["../src/components/tooltip/tooltip-content.gen.ts","../src/components/tooltip/tooltip-root.gen.ts","../src/components/tooltip/tooltip-trigger.gen.ts"],"sourcesContent":[],"mappings":";;;;;;;;AAmBA;AAAqC,UAApB,mBAAA,SAA4B,OAAR,CAAgB,WAAhB,CAA4B,qBAA5B,EAAmC,oBAAnC,CAAA,CAAA,CAAA;AAAmC,cAE3D,cAF2D,EAE3C,yBAF2C,CAGtE,OAHsE,CAG9D,mBAH8D,CAAA,GAItE,aAJsE,CAIxD,qBAJwD,CAAA,GAKtE,cALsE,CAKvD,qBALuD,CAAA,CAAA;;;;;AAAxE;AAAqC,UCApB,gBAAA,SAAyB,ODAL,CCAa,WDAb,CCAyB,kBDAzB,ECAgC,iBDAhC,CAAA,CAAA,CAAA;AAAmC,cCE3D,WDF2D,ECE9C,yBDF8C,CCGtE,ODHsE,CCG9D,gBDH8D,CAAA,GCItE,aDJsE,CCIxD,kBDJwD,CAAA,GCKtE,cDLsE,CCKvD,kBDLuD,CAAA,CAAA;;;;;AAAxE;AAAqC,UEApB,mBAAA,SAA4B,OFAR,CEAgB,WFAhB,CEA4B,qBFA5B,EEAmC,oBFAnC,CAAA,CAAA,CAAA;AAAmC,cEE3D,cFF2D,EEE3C,yBFF2C,CEGtE,OFHsE,CEG9D,mBFH8D,CAAA,GEItE,aFJsE,CEIxD,qBFJwD,CAAA,GEKtE,cFLsE,CEKvD,qBFLuD,CAAA,CAAA"}
1
+ {"version":3,"file":"prosekit-preact-tooltip.d.ts","names":[],"sources":["../src/components/tooltip/tooltip-content.gen.ts","../src/components/tooltip/tooltip-root.gen.ts","../src/components/tooltip/tooltip-trigger.gen.ts"],"sourcesContent":[],"mappings":";;;;;;;;AAmBA;AAAiE,UAAhD,mBAAA,SAA4B,OAAoB,CAAZ,WAAY,CAAA,qBAAA,EAAO,oBAAP,CAAA,CAAA,CAAA;AAAZ,cAExC,cAFwC,EAExB,yBAFwB,CAGnD,OAHmD,CAG3C,mBAH2C,CAAA,GAInD,aAJmD,CAIrC,qBAJqC,CAAA,GAKnD,cALmD,CAKpC,qBALoC,CAAA,CAAA;;;;;AAArD;AAAiE,UCAhD,gBAAA,SAAyB,ODAuB,CCAf,WDAe,CCAH,kBDAG,ECAI,iBDAJ,CAAA,CAAA,CAAA;AAAZ,cCExC,WDFwC,ECE3B,yBDF2B,CCGnD,ODHmD,CCG3C,gBDH2C,CAAA,GCInD,aDJmD,CCIrC,kBDJqC,CAAA,GCKnD,cDLmD,CCKpC,kBDLoC,CAAA,CAAA;;;;;AAArD;AAAiE,UEAhD,mBAAA,SAA4B,OFAoB,CEAZ,WFAY,CEAA,qBFAA,EEAO,oBFAP,CAAA,CAAA,CAAA;AAAZ,cEExC,cFFwC,EEExB,yBFFwB,CEGnD,OFHmD,CEG3C,mBFH2C,CAAA,GEInD,aFJmD,CEIrC,qBFJqC,CAAA,GEKnD,cFLmD,CEKpC,qBFLoC,CAAA,CAAA"}
@@ -1,5 +1,5 @@
1
- import "./editor-context-imq7MdJr.js";
2
- import { createComponent } from "./create-component-D7yDR5ux.js";
1
+ import "./editor-context-DNun2Non.js";
2
+ import { t as createComponent } from "./create-component-BqjC2d_2.js";
3
3
  import { tooltipContentEvents, tooltipContentProps, tooltipRootEvents, tooltipRootProps, tooltipTriggerEvents, tooltipTriggerProps } from "@prosekit/web/tooltip";
4
4
 
5
5
  //#region src/components/tooltip/tooltip-content.gen.ts
@@ -1,5 +1,7 @@
1
+ import { MarkViewContext, NodeViewContext } from "@prosemirror-adapter/preact";
1
2
  import { ComponentChildren, ComponentType } from "preact";
2
3
  import { Editor, Extension, Keymap, Priority } from "@prosekit/core";
4
+ import { CoreMarkViewUserOptions, CoreNodeViewUserOptions } from "@prosemirror-adapter/core";
3
5
  import { ProseMirrorNode } from "@prosekit/pm/model";
4
6
  import { EditorState } from "@prosekit/pm/state";
5
7
 
@@ -15,11 +17,65 @@ interface ProseKitProps {
15
17
  */
16
18
  declare const ProseKit: ComponentType<ProseKitProps>;
17
19
  //#endregion
20
+ //#region src/extensions/preact-mark-view.d.ts
21
+ /**
22
+ * @public
23
+ */
24
+ interface PreactMarkViewProps extends MarkViewContext {}
25
+ /**
26
+ * @public
27
+ */
28
+ type PreactMarkViewComponent = ComponentType<PreactMarkViewProps>;
29
+ /**
30
+ * Options for {@link definePreactMarkView}.
31
+ *
32
+ * @public
33
+ */
34
+ interface PreactMarkViewOptions extends CoreMarkViewUserOptions<PreactMarkViewComponent> {
35
+ /**
36
+ * The name of the mark type.
37
+ */
38
+ name: string;
39
+ }
40
+ /**
41
+ * Defines a mark view using a Preact component.
42
+ *
43
+ * @public
44
+ */
45
+ declare function definePreactMarkView(options: PreactMarkViewOptions): Extension;
46
+ //#endregion
47
+ //#region src/extensions/preact-node-view.d.ts
48
+ /**
49
+ * @public
50
+ */
51
+ interface PreactNodeViewProps extends NodeViewContext {}
52
+ /**
53
+ * @public
54
+ */
55
+ type PreactNodeViewComponent = ComponentType<PreactNodeViewProps>;
56
+ /**
57
+ * Options for {@link definePreactNodeView}.
58
+ *
59
+ * @public
60
+ */
61
+ interface PreactNodeViewOptions extends CoreNodeViewUserOptions<PreactNodeViewComponent> {
62
+ /**
63
+ * The name of the node type.
64
+ */
65
+ name: string;
66
+ }
67
+ /**
68
+ * Defines a node view using a Preact component.
69
+ *
70
+ * @public
71
+ */
72
+ declare function definePreactNodeView(options: PreactNodeViewOptions): Extension;
73
+ //#endregion
18
74
  //#region src/hooks/use-extension.d.ts
19
75
  interface UseExtensionOptions {
20
76
  /**
21
77
  * The editor to add the extension to. If not provided, it will use the
22
- * editor from the nearest `ProseKit` component.
78
+ * editor from the nearest `<ProseKit>` component.
23
79
  */
24
80
  editor?: Editor;
25
81
  /**
@@ -61,6 +117,36 @@ declare function useEditor<E extends Extension = any>(options?: {
61
117
  update?: boolean;
62
118
  }): Editor<E>;
63
119
  //#endregion
120
+ //#region src/hooks/use-editor-derived-value.d.ts
121
+ interface UseEditorDerivedOptions<E extends Extension = any> {
122
+ /**
123
+ * The editor to add the extension to. If not provided, it will use the
124
+ * editor from the nearest `<ProseKit>` component.
125
+ */
126
+ editor?: Editor<E>;
127
+ }
128
+ /**
129
+ * Runs a function to derive a value from the editor instance after editor state
130
+ * changes.
131
+ *
132
+ * This is useful when you need to render something based on the editor state,
133
+ * for example, whether the selected text is wrapped in an italic mark.
134
+ *
135
+ * It returns the derived value that updates whenever the editor state changes.
136
+ *
137
+ * @public
138
+ */
139
+ declare function useEditorDerivedValue<E extends Extension, Derived>(
140
+ /**
141
+ * A function that receives the editor instance and returns a derived value.
142
+ *
143
+ * It will be called whenever the editor's document state changes, or when it
144
+ * mounts.
145
+ *
146
+ * This function should be memoized.
147
+ */
148
+ derive: (editor: Editor<E>) => Derived, options?: UseEditorDerivedOptions<E>): Derived;
149
+ //#endregion
64
150
  //#region src/hooks/use-keymap.d.ts
65
151
  declare function useKeymap(keymap: Keymap, options?: UseExtensionOptions): void;
66
152
  //#endregion
@@ -87,5 +173,5 @@ type PropsWithChildren<P = unknown> = P & {
87
173
  children?: ComponentChildren | undefined;
88
174
  };
89
175
  //#endregion
90
- export { type PropsWithChildren, type PropsWithClass, ProseKit, type ProseKitProps, type UseExtensionOptions, useDocChange, useEditor, useExtension, useKeymap, useStateUpdate };
176
+ export { type PreactMarkViewComponent, type PreactMarkViewOptions, type PreactMarkViewProps, type PreactNodeViewComponent, type PreactNodeViewOptions, type PreactNodeViewProps, type PropsWithChildren, type PropsWithClass, ProseKit, type ProseKitProps, type UseEditorDerivedOptions, type UseExtensionOptions, definePreactMarkView, definePreactNodeView, useDocChange, useEditor, useEditorDerivedValue, useExtension, useKeymap, useStateUpdate };
91
177
  //# sourceMappingURL=prosekit-preact.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"prosekit-preact.d.ts","names":[],"sources":["../src/components/prosekit.ts","../src/hooks/use-extension.ts","../src/hooks/use-doc-change.ts","../src/hooks/use-editor.ts","../src/hooks/use-keymap.ts","../src/hooks/use-state-update.ts","../src/types.ts"],"sourcesContent":[],"mappings":";;;;;;UASiB,aAAA;UACP;aACG;;AAFb;;;;;AAUa,cAAA,QAIZ,EAJsB,aAItB,CAJoC,aAIpC,CAAA;;;UCZgB,mBAAA;;;;;EDFA,MAAA,CAAA,ECON,MDPM;EAAa;;;EAEA,QAAA,CAAA,ECUjB,QDViB;AAQ9B;;;;AAAoC,iBCQpB,YAAA;;;;AAhBhB;SAAoC,EAqBvB,SArBuB,GAAA,IAAA,EAAA,OAAA,CAAA,EAsBxB,mBAtBwB,CAAA,EAAA,IAAA;;;;;;;ADFpC;AAA8B,iBEKd,YAAA,CFLc,OAAA,EAAA,CAAA,GAAA,EEMb,eFNa,EAAA,GAAA,IAAA,EAAA,OAAA,CAAA,EEOlB,mBFPkB,CAAA,EAAA,IAAA;;;;;;;;AAAb,iBGWD,SHXc,CAAA,UGWM,SHXN,GAAA,GAAA,CAAA,CAAA,QAAA,EAAA;EAAA;;;;AAU9B;;QAAqC,CAAA,EAAA,OAAA;IGSjC,MHTmB,CGSZ,CHTY,CAAA;;;iBIRP,SAAA,SAAkB,kBAAkB;;;;;;;AJFpD;AAA8B,iBKKd,cAAA,CLLc,OAAA,EAAA,CAAA,KAAA,EKMX,WLNW,EAAA,GAAA,IAAA,EAAA,OAAA,CAAA,EKOlB,mBLPkB,CAAA,EAAA,IAAA;;;;;;KMJlB,8BAA8B;;ENIzB,SAAA,CAAA,EAAA,MAAa,GAAA,SAAA;CAAA;;;;AAUjB,KMND,iBNUX,CAAA,IAAA,OAAA,CAAA,GMV4C,CNU5C,GAAA;EAAA,QAAA,CAAA,EMTY,iBNSZ,GAAA,SAAA"}
1
+ {"version":3,"file":"prosekit-preact.d.ts","names":[],"sources":["../src/components/prosekit.ts","../src/extensions/preact-mark-view.ts","../src/extensions/preact-node-view.ts","../src/hooks/use-extension.ts","../src/hooks/use-doc-change.ts","../src/hooks/use-editor.ts","../src/hooks/use-editor-derived-value.ts","../src/hooks/use-keymap.ts","../src/hooks/use-state-update.ts","../src/types.ts"],"sourcesContent":[],"mappings":";;;;;;;;UAYiB,aAAA;UACP;aACG;;;;AAFb;AAUA;;cAAa,UAAU,cAAc;;;;;;UCGpB,mBAAA,SAA4B,iBDb7C;AAUA;;;KCQY,uBAAA,GAA0B,cAAc;AALpD;AAKA;AAOA;AAiCA;;UAjCiB,qBAAA,SAA8B,wBAAwB;;ACZvE;AAKA;EAOiB,IAAA,EAAA,MAAA;AAiCjB;AC3CA;;;;ACbA;iBHwDgB,oBAAA,UAA8B,wBAAwB;;;;;;UC7CrD,mBAAA,SAA4B,iBFb7C;AAUA;;;KEQY,uBAAA,GAA0B,cAAc;ADLpD;AAKA;AAOA;AAiCA;;UCjCiB,qBAAA,SAA8B,wBAAwB;;AAZvE;AAKA;EAOiB,IAAA,EAAA,MAAA;AAiCjB;AC3CA;;;;ACbA;iBFwDgB,oBAAA,UAA8B,wBAAwB;;;UC3DrD,mBAAA;;;;;WAKN;;AHJX;AAUA;aGDa;;;AFIb;AAKA;AAOiB,iBEVD,YAAA;AF2ChB;;;;AC7CA,SAAiB,ECOJ,SDPI,GAAA,IAAoB,EAAA,OAAuB,CAAvB,ECQzB,mBDRgD,CAAA,EAAA,IAAA;;;;;;;;iBEX5C,YAAA,gBACC,oCACL;;;;;;;;iBCII,oBAAoB,wBJUpC;;ADlBA;AAUA;;;;ECGiB,MAAA,CAAA,EAAA,OAAA;AAKjB,CAAA,CAAA,EIFI,MJEQ,CIFD,CJEC,CAAA;;;UKjBK,kCAAkC;;;;;WAKxC,OAAO;;ANNlB;AAUA;;;;ACGA;AAKA;AAOA;AAiCA;;;iBKtCgB,gCAAgC;AJPhD;AAKA;AAOA;AAiCA;;;;AC3DA;AAgBA,MAAgB,EAAA,CAAA,MAAA,EGcG,MHdS,CGcF,CHdE,CAAA,EAAA,GGcK,OHTpB,EAAA,OACkB,CAAnB,EGSA,uBHTmB,CGSK,CHTL,CAAA,CAAA,EGU5B,OHV4B;;;iBItBf,SAAA,SAAkB,kBAAkB;;;;;;;;iBCGpC,cAAA,kBACG,gCACP;;;;;;KCXA,8BAA8B;;;;ATO1C;AAUA;;KSTY,iCAAiC;aAChC;ARWb,CAAA"}
@@ -1,23 +1,10 @@
1
- import { EditorContextProvider, useEditorContext } from "./editor-context-imq7MdJr.js";
1
+ import { n as useEditorContext, t as EditorContextProvider } from "./editor-context-DNun2Non.js";
2
+ import { ProsemirrorAdapterProvider, useMarkViewContext, useMarkViewFactory, useNodeViewContext, useNodeViewFactory } from "@prosemirror-adapter/preact";
2
3
  import { h } from "preact";
3
4
  import { useEffect, useMemo, useReducer } from "preact/hooks";
4
- import { EditorNotFoundError, ProseKitError, defineDocChangeHandler, defineKeymap, defineMountHandler, defineUpdateHandler, union, withPriority } from "@prosekit/core";
5
+ import { EditorNotFoundError, ProseKitError, defineDocChangeHandler, defineKeymap, defineMarkViewComponent, defineMarkViewFactory, defineMountHandler, defineNodeViewComponent, defineNodeViewFactory, defineUpdateHandler, union, withPriority } from "@prosekit/core";
6
+ import { useSyncExternalStore } from "preact/compat";
5
7
 
6
- //#region src/components/prosekit.ts
7
- /**
8
- * The root component for a ProseKit editor.
9
- *
10
- * @public
11
- */
12
- const ProseKit = (props) => {
13
- const { editor, children } = props;
14
- return h(EditorContextProvider, {
15
- value: editor,
16
- children
17
- });
18
- };
19
-
20
- //#endregion
21
8
  //#region src/hooks/use-editor-extension.ts
22
9
  /**
23
10
  * @internal
@@ -50,6 +37,94 @@ function useExtension(extension, options) {
50
37
  useEditorExtension(options?.editor || editorContext, usePriorityExtension(extension, options?.priority));
51
38
  }
52
39
 
40
+ //#endregion
41
+ //#region src/extensions/preact-mark-view.ts
42
+ function withMarkViewProps(component) {
43
+ return function MarkViewPropsWrapper() {
44
+ return h(component, useMarkViewContext());
45
+ };
46
+ }
47
+ /**
48
+ * @internal
49
+ */
50
+ const PreactMarkViewConsumer = () => {
51
+ const markViewFactory = useMarkViewFactory();
52
+ useExtension(useMemo(() => definePreactMarkViewFactory(markViewFactory), [markViewFactory]));
53
+ return null;
54
+ };
55
+ /**
56
+ * Defines a mark view using a Preact component.
57
+ *
58
+ * @public
59
+ */
60
+ function definePreactMarkView(options) {
61
+ const { name, component,...userOptions } = options;
62
+ return defineMarkViewComponent({
63
+ group: "preact",
64
+ name,
65
+ args: {
66
+ ...userOptions,
67
+ component: withMarkViewProps(component)
68
+ }
69
+ });
70
+ }
71
+ function definePreactMarkViewFactory(factory) {
72
+ return defineMarkViewFactory({
73
+ group: "preact",
74
+ factory
75
+ });
76
+ }
77
+
78
+ //#endregion
79
+ //#region src/extensions/preact-node-view.ts
80
+ function withNodeViewProps(component) {
81
+ return function NodeViewPropsWrapper() {
82
+ return h(component, useNodeViewContext());
83
+ };
84
+ }
85
+ /**
86
+ * @internal
87
+ */
88
+ const PreactNodeViewConsumer = () => {
89
+ const nodeViewFactory = useNodeViewFactory();
90
+ useExtension(useMemo(() => definePreactNodeViewFactory(nodeViewFactory), [nodeViewFactory]));
91
+ return null;
92
+ };
93
+ /**
94
+ * Defines a node view using a Preact component.
95
+ *
96
+ * @public
97
+ */
98
+ function definePreactNodeView(options) {
99
+ const { name, component,...userOptions } = options;
100
+ return defineNodeViewComponent({
101
+ group: "preact",
102
+ name,
103
+ args: {
104
+ ...userOptions,
105
+ component: withNodeViewProps(component)
106
+ }
107
+ });
108
+ }
109
+ function definePreactNodeViewFactory(factory) {
110
+ return defineNodeViewFactory({
111
+ group: "preact",
112
+ factory
113
+ });
114
+ }
115
+
116
+ //#endregion
117
+ //#region src/components/prosekit.ts
118
+ /**
119
+ * The root component for a ProseKit editor.
120
+ *
121
+ * @public
122
+ */
123
+ const ProseKit = (props) => {
124
+ const { editor, children } = props;
125
+ return h(ProsemirrorAdapterProvider, null, h(EditorContextProvider, { value: editor }, h(PreactNodeViewConsumer, null), h(PreactMarkViewConsumer, null), children));
126
+ };
127
+
53
128
  //#endregion
54
129
  //#region src/hooks/use-doc-change.ts
55
130
  /**
@@ -58,8 +133,7 @@ function useExtension(extension, options) {
58
133
  * @public
59
134
  */
60
135
  function useDocChange(handler, options) {
61
- const extension = useMemo(() => defineDocChangeHandler((view) => handler(view.state.doc)), [handler]);
62
- useExtension(extension, options);
136
+ useExtension(useMemo(() => defineDocChangeHandler((view) => handler(view.state.doc)), [handler]), options);
63
137
  }
64
138
 
65
139
  //#endregion
@@ -91,11 +165,53 @@ function useForceUpdate() {
91
165
  return dispatch;
92
166
  }
93
167
 
168
+ //#endregion
169
+ //#region src/hooks/use-editor-derived-value.ts
170
+ /**
171
+ * Runs a function to derive a value from the editor instance after editor state
172
+ * changes.
173
+ *
174
+ * This is useful when you need to render something based on the editor state,
175
+ * for example, whether the selected text is wrapped in an italic mark.
176
+ *
177
+ * It returns the derived value that updates whenever the editor state changes.
178
+ *
179
+ * @public
180
+ */
181
+ function useEditorDerivedValue(derive, options) {
182
+ const editorContext = useEditorContext();
183
+ const editor = options?.editor ?? editorContext;
184
+ if (!editor) throw new EditorNotFoundError();
185
+ const [subscribe, getSnapshot] = useMemo(() => {
186
+ return createEditorStore(editor, derive);
187
+ }, [editor, derive]);
188
+ return useSyncExternalStore(subscribe, getSnapshot);
189
+ }
190
+ function createEditorStore(editor, derive) {
191
+ let dirty = true;
192
+ let derived;
193
+ const subscribe = (onChange) => {
194
+ const handleChange = () => {
195
+ dirty = true;
196
+ onChange();
197
+ };
198
+ const extension = union(defineUpdateHandler(handleChange), defineMountHandler(handleChange));
199
+ return editor.use(extension);
200
+ };
201
+ const getSnapshot = () => {
202
+ if (dirty) {
203
+ dirty = false;
204
+ derived = derive(editor);
205
+ }
206
+ return derived;
207
+ };
208
+ return [subscribe, getSnapshot];
209
+ }
210
+
94
211
  //#endregion
95
212
  //#region src/hooks/use-keymap.ts
96
213
  function useKeymap(keymap, options) {
97
- const extension = useMemo(() => defineKeymap(keymap), [keymap]);
98
- useExtension(extension, options);
214
+ useExtension(useMemo(() => defineKeymap(keymap), [keymap]), options);
99
215
  }
100
216
 
101
217
  //#endregion
@@ -106,10 +222,9 @@ function useKeymap(keymap, options) {
106
222
  * @public
107
223
  */
108
224
  function useStateUpdate(handler, options) {
109
- const extension = useMemo(() => defineUpdateHandler((view) => handler(view.state)), [handler]);
110
- useExtension(extension, options);
225
+ useExtension(useMemo(() => defineUpdateHandler((view) => handler(view.state)), [handler]), options);
111
226
  }
112
227
 
113
228
  //#endregion
114
- export { ProseKit, useDocChange, useEditor, useExtension, useKeymap, useStateUpdate };
229
+ export { ProseKit, definePreactMarkView, definePreactNodeView, useDocChange, useEditor, useEditorDerivedValue, useExtension, useKeymap, useStateUpdate };
115
230
  //# sourceMappingURL=prosekit-preact.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"prosekit-preact.js","names":["ProseKit: ComponentType<ProseKitProps>"],"sources":["../src/components/prosekit.ts","../src/hooks/use-editor-extension.ts","../src/hooks/use-priority-extension.ts","../src/hooks/use-extension.ts","../src/hooks/use-doc-change.ts","../src/hooks/use-editor.ts","../src/hooks/use-keymap.ts","../src/hooks/use-state-update.ts"],"sourcesContent":["import type { Editor } from '@prosekit/core'\nimport {\n h,\n type ComponentChildren,\n type ComponentType,\n} from 'preact'\n\nimport { EditorContextProvider } from '../contexts/editor-context'\n\nexport interface ProseKitProps {\n editor: Editor\n children?: ComponentChildren\n}\n\n/**\n * The root component for a ProseKit editor.\n *\n * @public\n */\nexport const ProseKit: ComponentType<ProseKitProps> = (props) => {\n const { editor, children } = props\n\n return h(EditorContextProvider, { value: editor, children })\n}\n","import {\n EditorNotFoundError,\n type Editor,\n type Extension,\n} from '@prosekit/core'\nimport { useEffect } from 'preact/hooks'\n\n/**\n * @internal\n */\nexport function useEditorExtension(\n editor: Editor | null | undefined,\n extension: Extension | null,\n): void {\n if (!editor) {\n throw new EditorNotFoundError()\n }\n\n useEffect(() => {\n if (extension) {\n return editor.use(extension)\n }\n }, [editor, extension])\n}\n","import {\n withPriority,\n type Extension,\n type Priority,\n} from '@prosekit/core'\nimport { useMemo } from 'preact/hooks'\n\n/**\n * @internal\n */\nexport function usePriorityExtension<T extends Extension = Extension>(\n extension: T | null,\n priority?: Priority | null,\n): T | null {\n return useMemo(() => {\n return extension && priority ? withPriority(extension, priority) : extension\n }, [extension, priority])\n}\n","import type {\n Editor,\n Extension,\n Priority,\n} from '@prosekit/core'\n\nimport { useEditorContext } from '../contexts/editor-context'\n\nimport { useEditorExtension } from './use-editor-extension'\nimport { usePriorityExtension } from './use-priority-extension'\n\nexport interface UseExtensionOptions {\n /**\n * The editor to add the extension to. If not provided, it will use the\n * editor from the nearest `ProseKit` component.\n */\n editor?: Editor\n\n /**\n * Optional priority to add the extension with.\n */\n priority?: Priority\n}\n\n/**\n * Add an extension to the editor.\n */\nexport function useExtension(\n /**\n * The extension to add to the editor. If it changes, the previous\n * extension will be removed and the new one (if not null) will be added.\n */\n extension: Extension | null,\n options?: UseExtensionOptions,\n): void {\n const editorContext = useEditorContext()\n useEditorExtension(\n options?.editor || editorContext,\n usePriorityExtension(extension, options?.priority),\n )\n}\n","import { defineDocChangeHandler } from '@prosekit/core'\nimport type { ProseMirrorNode } from '@prosekit/pm/model'\nimport { useMemo } from 'preact/hooks'\n\nimport {\n useExtension,\n type UseExtensionOptions,\n} from './use-extension'\n\n/**\n * Calls the given handler whenever the editor document changes.\n *\n * @public\n */\nexport function useDocChange(\n handler: (doc: ProseMirrorNode) => void,\n options?: UseExtensionOptions,\n): void {\n const extension = useMemo(\n () => defineDocChangeHandler((view) => handler(view.state.doc)),\n [handler],\n )\n useExtension(extension, options)\n}\n","import {\n defineMountHandler,\n defineUpdateHandler,\n ProseKitError,\n union,\n type Editor,\n type Extension,\n} from '@prosekit/core'\nimport {\n useEffect,\n useReducer,\n} from 'preact/hooks'\n\nimport { useEditorContext } from '../contexts/editor-context'\n\n/**\n * Retrieves the editor instance from the nearest ProseKit component.\n *\n * @public\n */\nexport function useEditor<E extends Extension = any>(options?: {\n /**\n * Whether to update the component when the editor is mounted or editor state\n * is updated.\n *\n * @default false\n */\n update?: boolean\n}): Editor<E> {\n const update = options?.update ?? false\n\n const editor = useEditorContext<E>()\n if (!editor) {\n throw new ProseKitError(\n 'useEditor must be used within the ProseKit component',\n )\n }\n\n const forceUpdate = useForceUpdate()\n\n useEffect(() => {\n if (update) {\n const extension = union(\n defineMountHandler(forceUpdate),\n defineUpdateHandler(forceUpdate),\n )\n return editor.use(extension)\n }\n }, [editor, update, forceUpdate])\n\n return editor\n}\n\nfunction useForceUpdate() {\n const [, dispatch] = useReducer((x: number) => x + 1, 0)\n return dispatch\n}\n","import {\n defineKeymap,\n type Keymap,\n} from '@prosekit/core'\nimport { useMemo } from 'preact/hooks'\n\nimport {\n useExtension,\n type UseExtensionOptions,\n} from './use-extension'\n\nexport function useKeymap(keymap: Keymap, options?: UseExtensionOptions): void {\n const extension = useMemo(() => defineKeymap(keymap), [keymap])\n useExtension(extension, options)\n}\n","import { defineUpdateHandler } from '@prosekit/core'\nimport type { EditorState } from '@prosekit/pm/state'\nimport { useMemo } from 'preact/hooks'\n\nimport {\n useExtension,\n type UseExtensionOptions,\n} from './use-extension'\n\n/**\n * Calls the given handler whenever the editor state changes.\n *\n * @public\n */\nexport function useStateUpdate(\n handler: (state: EditorState) => void,\n options?: UseExtensionOptions,\n): void {\n const extension = useMemo(\n () => defineUpdateHandler((view) => handler(view.state)),\n [hand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;CAC7E,MAAM,YAAY,cAAc,aAAa,OAAO,EAAE,CAAC,OAAO,CAAC;AAC/D,cAAa,WAAW,QAAQ;;;;;;;;;;ACClC,SAAgB,eACd,SACA,SACM;CACN,MAAM,YAAY,cACV,qBAAqB,SAAS,QAAQ,KAAK,MAAM,CAAC,EACxD,CAAC,QAAQ,CACV;AACD,cAAa,WAAW,QAAQ"}
1
+ {"version":3,"file":"prosekit-preact.js","names":["PreactMarkViewConsumer: FunctionComponent","PreactNodeViewConsumer: FunctionComponent","ProseKit: ComponentType<ProseKitProps>","derived: Derived"],"sources":["../src/hooks/use-editor-extension.ts","../src/hooks/use-priority-extension.ts","../src/hooks/use-extension.ts","../src/extensions/preact-mark-view.ts","../src/extensions/preact-node-view.ts","../src/components/prosekit.ts","../src/hooks/use-doc-change.ts","../src/hooks/use-editor.ts","../src/hooks/use-editor-derived-value.ts","../src/hooks/use-keymap.ts","../src/hooks/use-state-update.ts"],"sourcesContent":["import {\n EditorNotFoundError,\n type Editor,\n type Extension,\n} from '@prosekit/core'\nimport { useEffect } from 'preact/hooks'\n\n/**\n * @internal\n */\nexport function useEditorExtension(\n editor: Editor | null | undefined,\n extension: Extension | null,\n): void {\n if (!editor) {\n throw new EditorNotFoundError()\n }\n\n useEffect(() => {\n if (extension) {\n return editor.use(extension)\n }\n }, [editor, extension])\n}\n","import {\n withPriority,\n type Extension,\n type Priority,\n} from '@prosekit/core'\nimport { useMemo } from 'preact/hooks'\n\n/**\n * @internal\n */\nexport function usePriorityExtension<T extends Extension = Extension>(\n extension: T | null,\n priority?: Priority | null,\n): T | null {\n return useMemo(() => {\n return extension && priority ? withPriority(extension, priority) : extension\n }, [extension, priority])\n}\n","import type {\n Editor,\n Extension,\n Priority,\n} from '@prosekit/core'\n\nimport { useEditorContext } from '../contexts/editor-context'\n\nimport { useEditorExtension } from './use-editor-extension'\nimport { usePriorityExtension } from './use-priority-extension'\n\nexport interface UseExtensionOptions {\n /**\n * The editor to add the extension to. If not provided, it will use the\n * editor from the nearest `<ProseKit>` component.\n */\n editor?: Editor\n\n /**\n * Optional priority to add the extension with.\n */\n priority?: Priority\n}\n\n/**\n * Add an extension to the editor.\n */\nexport function useExtension(\n /**\n * The extension to add to the editor. If it changes, the previous\n * extension will be removed and the new one (if not null) will be added.\n */\n extension: Extension | null,\n options?: UseExtensionOptions,\n): void {\n const editorContext = useEditorContext()\n useEditorExtension(\n options?.editor || editorContext,\n usePriorityExtension(extension, options?.priority),\n )\n}\n","import {\n defineMarkViewComponent,\n defineMarkViewFactory,\n type Extension,\n} from '@prosekit/core'\nimport type { MarkViewConstructor } from '@prosekit/pm/view'\nimport type { CoreMarkViewUserOptions } from '@prosemirror-adapter/core'\nimport {\n useMarkViewContext,\n useMarkViewFactory,\n type MarkViewContext,\n type PreactMarkViewUserOptions,\n} from '@prosemirror-adapter/preact'\nimport {\n h,\n type ComponentType,\n type FunctionComponent,\n} from 'preact'\nimport { useMemo } from 'preact/hooks'\n\nimport { useExtension } from '../hooks/use-extension'\n\n/**\n * @public\n */\nexport interface PreactMarkViewProps extends MarkViewContext {}\n\n/**\n * @public\n */\nexport type PreactMarkViewComponent = ComponentType<PreactMarkViewProps>\n\n/**\n * Options for {@link definePreactMarkView}.\n *\n * @public\n */\nexport interface PreactMarkViewOptions extends CoreMarkViewUserOptions<PreactMarkViewComponent> {\n /**\n * The name of the mark type.\n */\n name: string\n}\n\nfunction withMarkViewProps(component: PreactMarkViewComponent) {\n return function MarkViewPropsWrapper() {\n const props: PreactMarkViewProps = useMarkViewContext()\n return h(component, props)\n }\n}\n\n/**\n * @internal\n */\nexport const PreactMarkViewConsumer: FunctionComponent = () => {\n const markViewFactory = useMarkViewFactory()\n const extension = useMemo(\n () => definePreactMarkViewFactory(markViewFactory),\n [markViewFactory],\n )\n useExtension(extension)\n\n return null\n}\n\n/**\n * Defines a mark view using a Preact component.\n *\n * @public\n */\nexport function definePreactMarkView(options: PreactMarkViewOptions): Extension {\n const { name, component, ...userOptions } = options\n\n const args: PreactMarkViewUserOptions = {\n ...userOptions,\n component: withMarkViewProps(component),\n }\n\n return defineMarkViewComponent<PreactMarkViewUserOptions>({\n group: 'preact',\n name,\n args,\n })\n}\n\nfunction definePreactMarkViewFactory(\n factory: (options: PreactMarkViewUserOptions) => MarkViewConstructor,\n) {\n return defineMarkViewFactory<PreactMarkViewUserOptions>({\n group: 'preact',\n factory,\n })\n}\n","import {\n defineNodeViewComponent,\n defineNodeViewFactory,\n type Extension,\n} from '@prosekit/core'\nimport type { NodeViewConstructor } from '@prosekit/pm/view'\nimport type { CoreNodeViewUserOptions } from '@prosemirror-adapter/core'\nimport {\n useNodeViewContext,\n useNodeViewFactory,\n type NodeViewContext,\n type PreactNodeViewUserOptions,\n} from '@prosemirror-adapter/preact'\nimport {\n h,\n type ComponentType,\n type FunctionComponent,\n} from 'preact'\nimport { useMemo } from 'preact/hooks'\n\nimport { useExtension } from '../hooks/use-extension'\n\n/**\n * @public\n */\nexport interface PreactNodeViewProps extends NodeViewContext {}\n\n/**\n * @public\n */\nexport type PreactNodeViewComponent = ComponentType<PreactNodeViewProps>\n\n/**\n * Options for {@link definePreactNodeView}.\n *\n * @public\n */\nexport interface PreactNodeViewOptions extends CoreNodeViewUserOptions<PreactNodeViewComponent> {\n /**\n * The name of the node type.\n */\n name: string\n}\n\nfunction withNodeViewProps(component: PreactNodeViewComponent) {\n return function NodeViewPropsWrapper() {\n const props: PreactNodeViewProps = useNodeViewContext()\n return h(component, props)\n }\n}\n\n/**\n * @internal\n */\nexport const PreactNodeViewConsumer: FunctionComponent = () => {\n const nodeViewFactory = useNodeViewFactory()\n const extension = useMemo(\n () => definePreactNodeViewFactory(nodeViewFactory),\n [nodeViewFactory],\n )\n useExtension(extension)\n\n return null\n}\n\n/**\n * Defines a node view using a Preact component.\n *\n * @public\n */\nexport function definePreactNodeView(options: PreactNodeViewOptions): Extension {\n const { name, component, ...userOptions } = options\n\n const args: PreactNodeViewUserOptions = {\n ...userOptions,\n component: withNodeViewProps(component),\n }\n\n return defineNodeViewComponent<PreactNodeViewUserOptions>({\n group: 'preact',\n name,\n args,\n })\n}\n\nfunction definePreactNodeViewFactory(\n factory: (options: PreactNodeViewUserOptions) => NodeViewConstructor,\n) {\n return defineNodeViewFactory<PreactNodeViewUserOptions>({\n group: 'preact',\n factory,\n })\n}\n","import type { Editor } from '@prosekit/core'\nimport { ProsemirrorAdapterProvider } from '@prosemirror-adapter/preact'\nimport {\n h,\n type ComponentChildren,\n type ComponentType,\n} from 'preact'\n\nimport { EditorContextProvider } from '../contexts/editor-context'\nimport { PreactMarkViewConsumer } from '../extensions/preact-mark-view'\nimport { PreactNodeViewConsumer } from '../extensions/preact-node-view'\n\nexport interface ProseKitProps {\n editor: Editor\n children?: ComponentChildren\n}\n\n/**\n * The root component for a ProseKit editor.\n *\n * @public\n */\nexport const ProseKit: ComponentType<ProseKitProps> = (props) => {\n const { editor, children } = props\n\n return h(\n ProsemirrorAdapterProvider,\n null,\n h(\n EditorContextProvider,\n { value: editor },\n h(PreactNodeViewConsumer, null),\n h(PreactMarkViewConsumer, null),\n children,\n ),\n )\n}\n","import { defineDocChangeHandler } from '@prosekit/core'\nimport type { ProseMirrorNode } from '@prosekit/pm/model'\nimport { useMemo } from 'preact/hooks'\n\nimport {\n useExtension,\n type UseExtensionOptions,\n} from './use-extension'\n\n/**\n * Calls the given handler whenever the editor document changes.\n *\n * @public\n */\nexport function useDocChange(\n handler: (doc: ProseMirrorNode) => void,\n options?: UseExtensionOptions,\n): void {\n const extension = useMemo(\n () => defineDocChangeHandler((view) => handler(view.state.doc)),\n [handler],\n )\n useExtension(extension, options)\n}\n","import {\n defineMountHandler,\n defineUpdateHandler,\n ProseKitError,\n union,\n type Editor,\n type Extension,\n} from '@prosekit/core'\nimport {\n useEffect,\n useReducer,\n} from 'preact/hooks'\n\nimport { useEditorContext } from '../contexts/editor-context'\n\n/**\n * Retrieves the editor instance from the nearest ProseKit component.\n *\n * @public\n */\nexport function useEditor<E extends Extension = any>(options?: {\n /**\n * Whether to update the component when the editor is mounted or editor state\n * is updated.\n *\n * @default false\n */\n update?: boolean\n}): Editor<E> {\n const update = options?.update ?? false\n\n const editor = useEditorContext<E>()\n if (!editor) {\n throw new ProseKitError(\n 'useEditor must be used within the ProseKit component',\n )\n }\n\n const forceUpdate = useForceUpdate()\n\n useEffect(() => {\n if (update) {\n const extension = union(\n defineMountHandler(forceUpdate),\n defineUpdateHandler(forceUpdate),\n )\n return editor.use(extension)\n }\n }, [editor, update, forceUpdate])\n\n return editor\n}\n\nfunction useForceUpdate() {\n const [, dispatch] = useReducer((x: number) => x + 1, 0)\n return dispatch\n}\n","import {\n defineMountHandler,\n defineUpdateHandler,\n EditorNotFoundError,\n union,\n type Editor,\n type Extension,\n} from '@prosekit/core'\nimport { useSyncExternalStore } from 'preact/compat'\nimport { useMemo } from 'preact/hooks'\n\nimport { useEditorContext } from '../contexts/editor-context'\n\nexport interface UseEditorDerivedOptions<E extends Extension = any> {\n /**\n * The editor to add the extension to. If not provided, it will use the\n * editor from the nearest `<ProseKit>` component.\n */\n editor?: Editor<E>\n}\n\n/**\n * Runs a function to derive a value from the editor instance after editor state\n * changes.\n *\n * This is useful when you need to render something based on the editor state,\n * for example, whether the selected text is wrapped in an italic mark.\n *\n * It returns the derived value that updates whenever the editor state changes.\n *\n * @public\n */\nexport function useEditorDerivedValue<E extends Extension, Derived>(\n /**\n * A function that receives the editor instance and returns a derived value.\n *\n * It will be called whenever the editor's document state changes, or when it\n * mounts.\n *\n * This function should be memoized.\n */\n derive: (editor: Editor<E>) => Derived,\n options?: UseEditorDerivedOptions<E>,\n): Derived {\n const editorContext = useEditorContext<E>()\n const editor = options?.editor ?? editorContext\n if (!editor) {\n throw new EditorNotFoundError()\n }\n\n const [subscribe, getSnapshot] = useMemo(() => {\n return createEditorStore(editor, derive)\n }, [editor, derive])\n\n return useSyncExternalStore(subscribe, getSnapshot)\n}\n\nfunction createEditorStore<Derived, E extends Extension = any>(editor: Editor<E>, derive: (editor: Editor<E>) => Derived) {\n let dirty = true\n let derived: Derived\n\n const subscribe = (onChange: VoidFunction): VoidFunction => {\n const handleChange = () => {\n dirty = true\n onChange()\n }\n const extension = union(\n defineUpdateHandler(handleChange),\n defineMountHandler(handleChange),\n )\n return editor.use(extension)\n }\n\n const getSnapshot = () => {\n if (dirty) {\n dirty = false\n derived = derive(editor)\n }\n return derived\n }\n\n return [subscribe, getSnapshot] as const\n}\n","import {\n defineKeymap,\n type Keymap,\n} from '@prosekit/core'\nimport { useMemo } from 'preact/hooks'\n\nimport {\n useExtension,\n type UseExtensionOptions,\n} from './use-extension'\n\nexport function useKeymap(keymap: Keymap, options?: UseExtensionOptions): void {\n const extension = useMemo(() => defineKeymap(keymap), [keymap])\n useExtension(extension, options)\n}\n","import { defineUpdateHandler } from '@prosekit/core'\nimport type { EditorState } from '@prosekit/pm/state'\nimport { useMemo } from 'preact/hooks'\n\nimport {\n useExtension,\n type UseExtensionOptions,\n} from './use-extension'\n\n/**\n * Calls the given handler whenever the editor state changes.\n *\n * @public\n */\nexport function useStateUpdate(\n handler: (state: EditorState) => void,\n options?: UseExtensionOptions,\n): void {\n const extension = useMemo(\n () => defineUpdateHandler((view) => handler(view.state)),\n [handler],\n )\n useExtension(extension, options)\n}\n"],"mappings":";;;;;;;;;;;AAUA,SAAgB,mBACd,QACA,WACM;AACN,KAAI,CAAC,OACH,OAAM,IAAI,qBAAqB;AAGjC,iBAAgB;AACd,MAAI,UACF,QAAO,OAAO,IAAI,UAAU;IAE7B,CAAC,QAAQ,UAAU,CAAC;;;;;;;;ACZzB,SAAgB,qBACd,WACA,UACU;AACV,QAAO,cAAc;AACnB,SAAO,aAAa,WAAW,aAAa,WAAW,SAAS,GAAG;IAClE,CAAC,WAAW,SAAS,CAAC;;;;;;;;ACW3B,SAAgB,aAKd,WACA,SACM;CACN,MAAM,gBAAgB,kBAAkB;AACxC,oBACE,SAAS,UAAU,eACnB,qBAAqB,WAAW,SAAS,SAAS,CACnD;;;;;ACKH,SA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7E,cADkB,cAAc,aAAa,OAAO,EAAE,CAAC,OAAO,CAAC,EACvC,QAAQ;;;;;;;;;;ACClC,SAAgB,eACd,SACA,SACM;AAKN,cAJkB,cACV,qBAAqB,SAAS,QAAQ,KAAK,MAAM,CAAC,EACxD,CAAC,QAAQ,CACV,EACuB,QAAQ"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@prosekit/preact",
3
3
  "type": "module",
4
- "version": "0.5.1",
4
+ "version": "0.6.1",
5
5
  "private": false,
6
6
  "description": "Preact components and utilities for ProseKit",
7
7
  "author": {
@@ -68,9 +68,11 @@
68
68
  "src"
69
69
  ],
70
70
  "dependencies": {
71
- "@prosekit/core": "^0.8.4",
72
- "@prosekit/pm": "^0.1.12",
73
- "@prosekit/web": "^0.7.4"
71
+ "@prosemirror-adapter/core": "^0.4.6",
72
+ "@prosemirror-adapter/preact": "^0.4.6",
73
+ "@prosekit/core": "^0.8.6",
74
+ "@prosekit/web": "^0.7.6",
75
+ "@prosekit/pm": "^0.1.14"
74
76
  },
75
77
  "peerDependencies": {
76
78
  "preact": ">= 10.11.0"
@@ -81,9 +83,9 @@
81
83
  }
82
84
  },
83
85
  "devDependencies": {
84
- "preact": "^10.27.1",
85
- "tsdown": "^0.14.2",
86
- "typescript": "~5.9.2",
86
+ "preact": "^10.27.2",
87
+ "tsdown": "^0.16.2",
88
+ "typescript": "~5.9.3",
87
89
  "@prosekit/config-tsdown": "0.0.0",
88
90
  "@prosekit/config-vitest": "0.0.0"
89
91
  },
@@ -1,4 +1,5 @@
1
1
  import type { Editor } from '@prosekit/core'
2
+ import { ProsemirrorAdapterProvider } from '@prosemirror-adapter/preact'
2
3
  import {
3
4
  h,
4
5
  type ComponentChildren,
@@ -6,6 +7,8 @@ import {
6
7
  } from 'preact'
7
8
 
8
9
  import { EditorContextProvider } from '../contexts/editor-context'
10
+ import { PreactMarkViewConsumer } from '../extensions/preact-mark-view'
11
+ import { PreactNodeViewConsumer } from '../extensions/preact-node-view'
9
12
 
10
13
  export interface ProseKitProps {
11
14
  editor: Editor
@@ -20,5 +23,15 @@ export interface ProseKitProps {
20
23
  export const ProseKit: ComponentType<ProseKitProps> = (props) => {
21
24
  const { editor, children } = props
22
25
 
23
- return h(EditorContextProvider, { value: editor, children })
26
+ return h(
27
+ ProsemirrorAdapterProvider,
28
+ null,
29
+ h(
30
+ EditorContextProvider,
31
+ { value: editor },
32
+ h(PreactNodeViewConsumer, null),
33
+ h(PreactMarkViewConsumer, null),
34
+ children,
35
+ ),
36
+ )
24
37
  }
@@ -0,0 +1,93 @@
1
+ import {
2
+ defineMarkViewComponent,
3
+ defineMarkViewFactory,
4
+ type Extension,
5
+ } from '@prosekit/core'
6
+ import type { MarkViewConstructor } from '@prosekit/pm/view'
7
+ import type { CoreMarkViewUserOptions } from '@prosemirror-adapter/core'
8
+ import {
9
+ useMarkViewContext,
10
+ useMarkViewFactory,
11
+ type MarkViewContext,
12
+ type PreactMarkViewUserOptions,
13
+ } from '@prosemirror-adapter/preact'
14
+ import {
15
+ h,
16
+ type ComponentType,
17
+ type FunctionComponent,
18
+ } from 'preact'
19
+ import { useMemo } from 'preact/hooks'
20
+
21
+ import { useExtension } from '../hooks/use-extension'
22
+
23
+ /**
24
+ * @public
25
+ */
26
+ export interface PreactMarkViewProps extends MarkViewContext {}
27
+
28
+ /**
29
+ * @public
30
+ */
31
+ export type PreactMarkViewComponent = ComponentType<PreactMarkViewProps>
32
+
33
+ /**
34
+ * Options for {@link definePreactMarkView}.
35
+ *
36
+ * @public
37
+ */
38
+ export interface PreactMarkViewOptions extends CoreMarkViewUserOptions<PreactMarkViewComponent> {
39
+ /**
40
+ * The name of the mark type.
41
+ */
42
+ name: string
43
+ }
44
+
45
+ function withMarkViewProps(component: PreactMarkViewComponent) {
46
+ return function MarkViewPropsWrapper() {
47
+ const props: PreactMarkViewProps = useMarkViewContext()
48
+ return h(component, props)
49
+ }
50
+ }
51
+
52
+ /**
53
+ * @internal
54
+ */
55
+ export const PreactMarkViewConsumer: FunctionComponent = () => {
56
+ const markViewFactory = useMarkViewFactory()
57
+ const extension = useMemo(
58
+ () => definePreactMarkViewFactory(markViewFactory),
59
+ [markViewFactory],
60
+ )
61
+ useExtension(extension)
62
+
63
+ return null
64
+ }
65
+
66
+ /**
67
+ * Defines a mark view using a Preact component.
68
+ *
69
+ * @public
70
+ */
71
+ export function definePreactMarkView(options: PreactMarkViewOptions): Extension {
72
+ const { name, component, ...userOptions } = options
73
+
74
+ const args: PreactMarkViewUserOptions = {
75
+ ...userOptions,
76
+ component: withMarkViewProps(component),
77
+ }
78
+
79
+ return defineMarkViewComponent<PreactMarkViewUserOptions>({
80
+ group: 'preact',
81
+ name,
82
+ args,
83
+ })
84
+ }
85
+
86
+ function definePreactMarkViewFactory(
87
+ factory: (options: PreactMarkViewUserOptions) => MarkViewConstructor,
88
+ ) {
89
+ return defineMarkViewFactory<PreactMarkViewUserOptions>({
90
+ group: 'preact',
91
+ factory,
92
+ })
93
+ }
@@ -0,0 +1,93 @@
1
+ import {
2
+ defineNodeViewComponent,
3
+ defineNodeViewFactory,
4
+ type Extension,
5
+ } from '@prosekit/core'
6
+ import type { NodeViewConstructor } from '@prosekit/pm/view'
7
+ import type { CoreNodeViewUserOptions } from '@prosemirror-adapter/core'
8
+ import {
9
+ useNodeViewContext,
10
+ useNodeViewFactory,
11
+ type NodeViewContext,
12
+ type PreactNodeViewUserOptions,
13
+ } from '@prosemirror-adapter/preact'
14
+ import {
15
+ h,
16
+ type ComponentType,
17
+ type FunctionComponent,
18
+ } from 'preact'
19
+ import { useMemo } from 'preact/hooks'
20
+
21
+ import { useExtension } from '../hooks/use-extension'
22
+
23
+ /**
24
+ * @public
25
+ */
26
+ export interface PreactNodeViewProps extends NodeViewContext {}
27
+
28
+ /**
29
+ * @public
30
+ */
31
+ export type PreactNodeViewComponent = ComponentType<PreactNodeViewProps>
32
+
33
+ /**
34
+ * Options for {@link definePreactNodeView}.
35
+ *
36
+ * @public
37
+ */
38
+ export interface PreactNodeViewOptions extends CoreNodeViewUserOptions<PreactNodeViewComponent> {
39
+ /**
40
+ * The name of the node type.
41
+ */
42
+ name: string
43
+ }
44
+
45
+ function withNodeViewProps(component: PreactNodeViewComponent) {
46
+ return function NodeViewPropsWrapper() {
47
+ const props: PreactNodeViewProps = useNodeViewContext()
48
+ return h(component, props)
49
+ }
50
+ }
51
+
52
+ /**
53
+ * @internal
54
+ */
55
+ export const PreactNodeViewConsumer: FunctionComponent = () => {
56
+ const nodeViewFactory = useNodeViewFactory()
57
+ const extension = useMemo(
58
+ () => definePreactNodeViewFactory(nodeViewFactory),
59
+ [nodeViewFactory],
60
+ )
61
+ useExtension(extension)
62
+
63
+ return null
64
+ }
65
+
66
+ /**
67
+ * Defines a node view using a Preact component.
68
+ *
69
+ * @public
70
+ */
71
+ export function definePreactNodeView(options: PreactNodeViewOptions): Extension {
72
+ const { name, component, ...userOptions } = options
73
+
74
+ const args: PreactNodeViewUserOptions = {
75
+ ...userOptions,
76
+ component: withNodeViewProps(component),
77
+ }
78
+
79
+ return defineNodeViewComponent<PreactNodeViewUserOptions>({
80
+ group: 'preact',
81
+ name,
82
+ args,
83
+ })
84
+ }
85
+
86
+ function definePreactNodeViewFactory(
87
+ factory: (options: PreactNodeViewUserOptions) => NodeViewConstructor,
88
+ ) {
89
+ return defineNodeViewFactory<PreactNodeViewUserOptions>({
90
+ group: 'preact',
91
+ factory,
92
+ })
93
+ }
@@ -0,0 +1,83 @@
1
+ import {
2
+ defineMountHandler,
3
+ defineUpdateHandler,
4
+ EditorNotFoundError,
5
+ union,
6
+ type Editor,
7
+ type Extension,
8
+ } from '@prosekit/core'
9
+ import { useSyncExternalStore } from 'preact/compat'
10
+ import { useMemo } from 'preact/hooks'
11
+
12
+ import { useEditorContext } from '../contexts/editor-context'
13
+
14
+ export interface UseEditorDerivedOptions<E extends Extension = any> {
15
+ /**
16
+ * The editor to add the extension to. If not provided, it will use the
17
+ * editor from the nearest `<ProseKit>` component.
18
+ */
19
+ editor?: Editor<E>
20
+ }
21
+
22
+ /**
23
+ * Runs a function to derive a value from the editor instance after editor state
24
+ * changes.
25
+ *
26
+ * This is useful when you need to render something based on the editor state,
27
+ * for example, whether the selected text is wrapped in an italic mark.
28
+ *
29
+ * It returns the derived value that updates whenever the editor state changes.
30
+ *
31
+ * @public
32
+ */
33
+ export function useEditorDerivedValue<E extends Extension, Derived>(
34
+ /**
35
+ * A function that receives the editor instance and returns a derived value.
36
+ *
37
+ * It will be called whenever the editor's document state changes, or when it
38
+ * mounts.
39
+ *
40
+ * This function should be memoized.
41
+ */
42
+ derive: (editor: Editor<E>) => Derived,
43
+ options?: UseEditorDerivedOptions<E>,
44
+ ): Derived {
45
+ const editorContext = useEditorContext<E>()
46
+ const editor = options?.editor ?? editorContext
47
+ if (!editor) {
48
+ throw new EditorNotFoundError()
49
+ }
50
+
51
+ const [subscribe, getSnapshot] = useMemo(() => {
52
+ return createEditorStore(editor, derive)
53
+ }, [editor, derive])
54
+
55
+ return useSyncExternalStore(subscribe, getSnapshot)
56
+ }
57
+
58
+ function createEditorStore<Derived, E extends Extension = any>(editor: Editor<E>, derive: (editor: Editor<E>) => Derived) {
59
+ let dirty = true
60
+ let derived: Derived
61
+
62
+ const subscribe = (onChange: VoidFunction): VoidFunction => {
63
+ const handleChange = () => {
64
+ dirty = true
65
+ onChange()
66
+ }
67
+ const extension = union(
68
+ defineUpdateHandler(handleChange),
69
+ defineMountHandler(handleChange),
70
+ )
71
+ return editor.use(extension)
72
+ }
73
+
74
+ const getSnapshot = () => {
75
+ if (dirty) {
76
+ dirty = false
77
+ derived = derive(editor)
78
+ }
79
+ return derived
80
+ }
81
+
82
+ return [subscribe, getSnapshot] as const
83
+ }
@@ -12,7 +12,7 @@ import { usePriorityExtension } from './use-priority-extension'
12
12
  export interface UseExtensionOptions {
13
13
  /**
14
14
  * The editor to add the extension to. If not provided, it will use the
15
- * editor from the nearest `ProseKit` component.
15
+ * editor from the nearest `<ProseKit>` component.
16
16
  */
17
17
  editor?: Editor
18
18
 
package/src/index.ts CHANGED
@@ -2,8 +2,24 @@ export {
2
2
  ProseKit,
3
3
  type ProseKitProps,
4
4
  } from './components/prosekit'
5
+ export {
6
+ definePreactMarkView,
7
+ type PreactMarkViewComponent,
8
+ type PreactMarkViewOptions,
9
+ type PreactMarkViewProps,
10
+ } from './extensions/preact-mark-view'
11
+ export {
12
+ definePreactNodeView,
13
+ type PreactNodeViewComponent,
14
+ type PreactNodeViewOptions,
15
+ type PreactNodeViewProps,
16
+ } from './extensions/preact-node-view'
5
17
  export { useDocChange } from './hooks/use-doc-change'
6
18
  export { useEditor } from './hooks/use-editor'
19
+ export {
20
+ useEditorDerivedValue,
21
+ type UseEditorDerivedOptions,
22
+ } from './hooks/use-editor-derived-value'
7
23
  export {
8
24
  useExtension,
9
25
  type UseExtensionOptions,
@@ -1 +0,0 @@
1
- {"version":3,"file":"create-props-EGV61dJR.d.ts","names":[],"sources":["../src/components/create-props.ts"],"sourcesContent":[],"mappings":";KAAY,yCAAA,MACyB,KADd,GAAA,OAAA,EAAA,EAAA,eAAA,gBACc,MACE,MADF,GACW,WADX,MAEjC,KADmC,GAC3B,gBAD2B,CACV,MADU,CAAA;KAGlC,gBAH2C,CAAA,eAAA,gBAC5C,MAGmC,MAHnC,GAG4C,WAH5C,sBAAQ,MAKU,MALV,IAAA,KAKyB,UALzB,CAAA,MAAA,GAK6C,SAL7C,CAAA,EAAA,GAAA,CAAA,KAAA,EAMD,SANC,SAAA,GAAA,MAAA,QAAA,GAMqC,MANrC,CAM4C,SAN5C,CAAA,CAAA,QAAA,CAAA,GAOJ,MAPI,CAOG,SAPH,CAAA,EAAA,GAAA,IAAA,EAAgB"}