@prosekit/svelte 0.9.0 → 0.9.2

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 (44) hide show
  1. package/dist/build/components/autocomplete/autocomplete-root.gen.d.ts +9 -0
  2. package/dist/build/components/autocomplete/autocomplete-root.gen.d.ts.map +1 -1
  3. package/dist/build/components/autocomplete/autocomplete-root.gen.svelte +3 -3
  4. package/dist/build/components/autocomplete/autocomplete-root.gen.svelte.d.ts +1 -0
  5. package/dist/build/components/autocomplete/autocomplete-root.gen.svelte.d.ts.map +1 -1
  6. package/dist/build/components/prosekit/index.d.ts +3 -4
  7. package/dist/build/components/prosekit/index.d.ts.map +1 -1
  8. package/dist/build/components/prosekit/index.js +0 -2
  9. package/dist/build/components/prosekit/prosekit.svelte +5 -4
  10. package/dist/build/components/prosekit/prosekit.svelte.d.ts +6 -27
  11. package/dist/build/components/prosekit/prosekit.svelte.d.ts.map +1 -1
  12. package/dist/build/contexts/editor-context.d.ts +1 -1
  13. package/dist/build/contexts/editor-context.d.ts.map +1 -1
  14. package/dist/build/contexts/editor-context.js +8 -6
  15. package/dist/build/extensions/svelte-mark-view.d.ts +0 -10
  16. package/dist/build/extensions/svelte-mark-view.d.ts.map +1 -1
  17. package/dist/build/extensions/svelte-mark-view.js +0 -2
  18. package/dist/build/extensions/svelte-node-view.d.ts +0 -10
  19. package/dist/build/extensions/svelte-node-view.d.ts.map +1 -1
  20. package/dist/build/extensions/svelte-node-view.js +0 -2
  21. package/dist/build/hooks/use-doc-change.d.ts +0 -2
  22. package/dist/build/hooks/use-doc-change.d.ts.map +1 -1
  23. package/dist/build/hooks/use-doc-change.js +0 -2
  24. package/dist/build/hooks/use-editor-derived-value.d.ts +0 -2
  25. package/dist/build/hooks/use-editor-derived-value.d.ts.map +1 -1
  26. package/dist/build/hooks/use-editor-derived-value.js +0 -2
  27. package/dist/build/hooks/use-editor.d.ts +0 -2
  28. package/dist/build/hooks/use-editor.d.ts.map +1 -1
  29. package/dist/build/hooks/use-editor.js +0 -2
  30. package/dist/build/hooks/use-state-update.d.ts +0 -2
  31. package/dist/build/hooks/use-state-update.d.ts.map +1 -1
  32. package/dist/build/hooks/use-state-update.js +0 -2
  33. package/package.json +9 -9
  34. package/src/components/autocomplete/autocomplete-root.gen.svelte +3 -3
  35. package/src/components/autocomplete/autocomplete-root.gen.ts +9 -0
  36. package/src/components/prosekit/index.ts +3 -4
  37. package/src/components/prosekit/prosekit.svelte +5 -4
  38. package/src/contexts/editor-context.ts +8 -6
  39. package/src/extensions/svelte-mark-view.ts +0 -10
  40. package/src/extensions/svelte-node-view.ts +0 -10
  41. package/src/hooks/use-doc-change.ts +0 -2
  42. package/src/hooks/use-editor-derived-value.ts +0 -2
  43. package/src/hooks/use-editor.ts +0 -2
  44. package/src/hooks/use-state-update.ts +0 -2
@@ -23,6 +23,15 @@ export interface AutocompleteRootProps {
23
23
  * @default defaultItemFilter
24
24
  */
25
25
  filter?: AutocompleteRootElementProps['filter'];
26
+ /**
27
+ * The reference to position the popup against. This can be a DOM element, a
28
+ * Floating UI virtual element, or a function that returns either of them.
29
+ * By default, the popup will be positioned against the text content that
30
+ * triggers the autocomplete.
31
+ *
32
+ * @default null
33
+ */
34
+ anchor?: AutocompleteRootElementProps['anchor'];
26
35
  /** Fired when the open state changes. */
27
36
  onOpenChange?: (event: AutocompleteRootEvents['openChange']) => void;
28
37
  /** Fired when the query changes. */
@@ -1 +1 @@
1
- {"version":3,"file":"autocomplete-root.gen.d.ts","sourceRoot":"","sources":["../../../../src/components/autocomplete/autocomplete-root.gen.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,uBAAuB,EAAE,sBAAsB,EAAE,qBAAqB,IAAI,4BAA4B,EAAE,MAAM,4BAA4B,CAAC;AACzJ,OAAO,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AACjD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAItD,+DAA+D;AAC/D,MAAM,WAAW,qBAAqB;IACpC;;;;;OAKG;IACH,MAAM,CAAC,EAAE,4BAA4B,CAAC,QAAQ,CAAC,CAAC;IAChD;;;;OAIG;IACH,KAAK,CAAC,EAAE,4BAA4B,CAAC,OAAO,CAAC,CAAC;IAC9C;;;;;OAKG;IACH,MAAM,CAAC,EAAE,4BAA4B,CAAC,QAAQ,CAAC,CAAC;IAChD,yCAAyC;IACzC,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,sBAAsB,CAAC,YAAY,CAAC,KAAK,IAAI,CAAC;IACrE,oCAAoC;IACpC,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,sBAAsB,CAAC,aAAa,CAAC,KAAK,IAAI,CAAC;IACvE;;;OAGG;IACH,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,sBAAsB,CAAC,aAAa,CAAC,KAAK,IAAI,CAAC;IACvE;;;OAGG;IACH,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,sBAAsB,CAAC,cAAc,CAAC,KAAK,IAAI,CAAC;IACzE,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,sFAAsF;AACtF,eAAO,MAAM,gBAAgB,EAAE,SAAS,CAAC,qBAAqB,GAAG,cAAc,CAAC,uBAAuB,CAAC,CAA2G,CAAC"}
1
+ {"version":3,"file":"autocomplete-root.gen.d.ts","sourceRoot":"","sources":["../../../../src/components/autocomplete/autocomplete-root.gen.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,uBAAuB,EAAE,sBAAsB,EAAE,qBAAqB,IAAI,4BAA4B,EAAE,MAAM,4BAA4B,CAAC;AACzJ,OAAO,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AACjD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAItD,+DAA+D;AAC/D,MAAM,WAAW,qBAAqB;IACpC;;;;;OAKG;IACH,MAAM,CAAC,EAAE,4BAA4B,CAAC,QAAQ,CAAC,CAAC;IAChD;;;;OAIG;IACH,KAAK,CAAC,EAAE,4BAA4B,CAAC,OAAO,CAAC,CAAC;IAC9C;;;;;OAKG;IACH,MAAM,CAAC,EAAE,4BAA4B,CAAC,QAAQ,CAAC,CAAC;IAChD;;;;;;;OAOG;IACH,MAAM,CAAC,EAAE,4BAA4B,CAAC,QAAQ,CAAC,CAAC;IAChD,yCAAyC;IACzC,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,sBAAsB,CAAC,YAAY,CAAC,KAAK,IAAI,CAAC;IACrE,oCAAoC;IACpC,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,sBAAsB,CAAC,aAAa,CAAC,KAAK,IAAI,CAAC;IACvE;;;OAGG;IACH,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,sBAAsB,CAAC,aAAa,CAAC,KAAK,IAAI,CAAC;IACvE;;;OAGG;IACH,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,sBAAsB,CAAC,cAAc,CAAC,KAAK,IAAI,CAAC;IACzE,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,sFAAsF;AACtF,eAAO,MAAM,gBAAgB,EAAE,SAAS,CAAC,qBAAqB,GAAG,cAAc,CAAC,uBAAuB,CAAC,CAA2G,CAAC"}
@@ -5,16 +5,16 @@
5
5
  import { useEditorContext } from '../../contexts/editor-context.js'
6
6
  registerAutocompleteRootElement()
7
7
 
8
- let { editor: p0, filter: p1, regex: p2, onOpenChange: e0, onQueryChange: e1, onValueChange: e2, onValuesChange: e3, children = undefined, ...restProps } = $props()
8
+ let { anchor: p0, editor: p1, filter: p2, regex: p3, onOpenChange: e0, onQueryChange: e1, onValueChange: e2, onValuesChange: e3, children = undefined, ...restProps } = $props()
9
9
  let element: AutocompleteRootElement | undefined
10
10
  const handlers: EventListener[] = []
11
11
 
12
- const p0Fallback = useEditorContext()
12
+ const p1Fallback = useEditorContext()
13
13
 
14
14
  $effect(() => {
15
15
  if (!element) return
16
16
 
17
- Object.assign(element, { editor: p0 ?? p0Fallback, filter: p1, regex: p2 })
17
+ Object.assign(element, { anchor: p0, editor: p1 ?? p1Fallback, filter: p2, regex: p3 })
18
18
 
19
19
  handlers.length = 0
20
20
  handlers.push(e0)
@@ -1,4 +1,5 @@
1
1
  declare const AutocompleteRoot: import("svelte").Component<{
2
+ anchor: any;
2
3
  editor: any;
3
4
  filter: any;
4
5
  regex: any;
@@ -1 +1 @@
1
- {"version":3,"file":"autocomplete-root.gen.svelte.d.ts","sourceRoot":"","sources":["../../../../src/components/autocomplete/autocomplete-root.gen.svelte.ts"],"names":[],"mappings":"AAgDA,QAAA,MAAM,gBAAgB;YAnCkE,GAAG;YAAU,GAAG;WAAS,GAAG;kBAAgB,GAAG;mBAAiB,GAAG;mBAAiB,GAAG;oBAAkB,GAAG;eAAa,GAAG;gCAmCtJ,CAAC;AAC/D,KAAK,gBAAgB,GAAG,UAAU,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAC5D,eAAe,gBAAgB,CAAC"}
1
+ {"version":3,"file":"autocomplete-root.gen.svelte.d.ts","sourceRoot":"","sources":["../../../../src/components/autocomplete/autocomplete-root.gen.svelte.ts"],"names":[],"mappings":"AAgDA,QAAA,MAAM,gBAAgB;YAnCkE,GAAG;YAAU,GAAG;YAAU,GAAG;WAAS,GAAG;kBAAgB,GAAG;mBAAiB,GAAG;mBAAiB,GAAG;oBAAkB,GAAG;eAAa,GAAG;gCAmCnK,CAAC;AAC/D,KAAK,gBAAgB,GAAG,UAAU,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAC5D,eAAe,gBAAgB,CAAC"}
@@ -1,12 +1,11 @@
1
1
  import type { Editor } from '@prosekit/core';
2
- import type { SvelteComponent } from 'svelte';
2
+ import type { Component, Snippet } from 'svelte';
3
3
  export interface ProseKitProps {
4
4
  editor: Editor;
5
+ children?: Snippet;
5
6
  }
6
7
  /**
7
8
  * The root component for a ProseKit editor.
8
- *
9
- * @public
10
9
  */
11
- export declare const ProseKit: typeof SvelteComponent<ProseKitProps>;
10
+ export declare const ProseKit: Component<ProseKitProps>;
12
11
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/prosekit/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAC5C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAA;AAI7C,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,MAAM,CAAA;CACf;AAED;;;;GAIG;AACH,eAAO,MAAM,QAAQ,EAA0C,OAAO,eAAe,CAAC,aAAa,CAAC,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/prosekit/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAC5C,OAAO,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAA;AAIhD,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB;AAED;;GAEG;AACH,eAAO,MAAM,QAAQ,EAAW,SAAS,CAAC,aAAa,CAAC,CAAA"}
@@ -1,7 +1,5 @@
1
1
  import Comp from './prosekit.svelte';
2
2
  /**
3
3
  * The root component for a ProseKit editor.
4
- *
5
- * @public
6
4
  */
7
5
  export const ProseKit = Comp;
@@ -1,13 +1,14 @@
1
1
  <script lang="ts">
2
2
  import type { Editor } from '@prosekit/core'
3
+ import type { Snippet } from 'svelte'
3
4
  import { setEditorContext } from '../../contexts/editor-context.js'
4
5
  import { ViewRenderer } from '../view-renderer/index.js'
5
6
 
6
- export let editor: Editor
7
+ let props: { editor: Editor; children?: Snippet } = $props()
7
8
 
8
- setEditorContext(editor)
9
+ setEditorContext(() => props.editor)
9
10
  </script>
10
11
 
11
- <ViewRenderer {editor}>
12
- <slot />
12
+ <ViewRenderer editor={props.editor}>
13
+ {@render props.children?.()}
13
14
  </ViewRenderer>
@@ -1,31 +1,10 @@
1
1
  import type { Editor } from '@prosekit/core';
2
- interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
3
- new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
4
- $$bindings?: Bindings;
5
- } & Exports;
6
- (internal: unknown, props: Props & {
7
- $$events?: Events;
8
- $$slots?: Slots;
9
- }): Exports & {
10
- $set?: any;
11
- $on?: any;
12
- };
13
- z_$$bindings?: Bindings;
14
- }
15
- type $$__sveltets_2_PropsWithChildren<Props, Slots> = Props & (Slots extends {
16
- default: any;
17
- } ? Props extends Record<string, never> ? any : {
18
- children?: any;
19
- } : {});
20
- declare const Prosekit: $$__sveltets_2_IsomorphicComponent<$$__sveltets_2_PropsWithChildren<{
2
+ import type { Snippet } from 'svelte';
3
+ type $$ComponentProps = {
21
4
  editor: Editor;
22
- }, {
23
- default: {};
24
- }>, {
25
- [evt: string]: CustomEvent<any>;
26
- }, {
27
- default: {};
28
- }, {}, string>;
29
- type Prosekit = InstanceType<typeof Prosekit>;
5
+ children?: Snippet;
6
+ };
7
+ declare const Prosekit: import("svelte").Component<$$ComponentProps, {}, "">;
8
+ type Prosekit = ReturnType<typeof Prosekit>;
30
9
  export default Prosekit;
31
10
  //# sourceMappingURL=prosekit.svelte.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"prosekit.svelte.d.ts","sourceRoot":"","sources":["../../../../src/components/prosekit/prosekit.svelte.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAoB5C,UAAU,kCAAkC,CAAC,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,GAAG,EAAE,MAAM,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,GAAG,EAAE,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,GAAG,EAAE,OAAO,GAAG,EAAE,EAAE,QAAQ,GAAG,MAAM;IACpM,KAAK,OAAO,EAAE,OAAO,QAAQ,EAAE,2BAA2B,CAAC,KAAK,CAAC,GAAG,OAAO,QAAQ,EAAE,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,GAAG;QAAE,UAAU,CAAC,EAAE,QAAQ,CAAA;KAAE,GAAG,OAAO,CAAC;IACjK,CAAC,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,GAAG;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,KAAK,CAAA;KAAC,GAAG,OAAO,GAAG;QAAE,IAAI,CAAC,EAAE,GAAG,CAAC;QAAC,GAAG,CAAC,EAAE,GAAG,CAAA;KAAE,CAAC;IAC9G,YAAY,CAAC,EAAE,QAAQ,CAAC;CAC3B;AACD,KAAK,gCAAgC,CAAC,KAAK,EAAE,KAAK,IAAI,KAAK,GACvD,CAAC,KAAK,SAAS;IAAE,OAAO,EAAE,GAAG,CAAA;CAAE,GACzB,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,GACnC,GAAG,GACH;IAAE,QAAQ,CAAC,EAAE,GAAG,CAAA;CAAE,GAClB,EAAE,CAAC,CAAC;AAId,QAAA,MAAM,QAAQ;YAf+B,MAAM;;;;;;;cAegD,CAAC;AAClF,KAAK,QAAQ,GAAG,YAAY,CAAC,OAAO,QAAQ,CAAC,CAAC;AAChD,eAAe,QAAQ,CAAC"}
1
+ {"version":3,"file":"prosekit.svelte.d.ts","sourceRoot":"","sources":["../../../../src/components/prosekit/prosekit.svelte.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAC5C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAA;AAIpC,KAAK,gBAAgB,GAAI;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AAkBjE,QAAA,MAAM,QAAQ,sDAAwC,CAAC;AACvD,KAAK,QAAQ,GAAG,UAAU,CAAC,OAAO,QAAQ,CAAC,CAAC;AAC5C,eAAe,QAAQ,CAAC"}
@@ -2,7 +2,7 @@ import { type Editor, type Extension } from '@prosekit/core';
2
2
  /**
3
3
  * @internal
4
4
  */
5
- export declare function setEditorContext(editor: Editor): void;
5
+ export declare function setEditorContext(getEditor: () => Editor): void;
6
6
  /**
7
7
  * @internal
8
8
  */
@@ -1 +1 @@
1
- {"version":3,"file":"editor-context.d.ts","sourceRoot":"","sources":["../../../src/contexts/editor-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,MAAM,EAAE,KAAK,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAK3E;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAKrD;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,SAAS,KAAK,MAAM,CAAC,CAAC,CAAC,GAAG,SAAS,CAI7E"}
1
+ {"version":3,"file":"editor-context.d.ts","sourceRoot":"","sources":["../../../src/contexts/editor-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,MAAM,EAAE,KAAK,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAK3E;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,MAAM,MAAM,GAAG,IAAI,CAE9D;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,SAAS,KAAK,MAAM,CAAC,CAAC,CAAC,GAAG,SAAS,CAS7E"}
@@ -4,17 +4,19 @@ const key = 'prosekit-svelte-editor-context';
4
4
  /**
5
5
  * @internal
6
6
  */
7
- export function setEditorContext(editor) {
8
- if (!editor) {
9
- throw new ProseKitError('editor should not be empty');
10
- }
11
- setContext(key, editor);
7
+ export function setEditorContext(getEditor) {
8
+ setContext(key, getEditor);
12
9
  }
13
10
  /**
14
11
  * @internal
15
12
  */
16
13
  export function useEditorContext() {
17
14
  if (hasContext(key)) {
18
- return getContext(key);
15
+ const context = getContext(key);
16
+ const editor = context();
17
+ if (!editor) {
18
+ throw new ProseKitError('editor should not be empty');
19
+ }
20
+ return editor;
19
21
  }
20
22
  }
@@ -2,19 +2,11 @@ import { type Extension } from '@prosekit/core';
2
2
  import type { CoreMarkViewUserOptions } from '@prosemirror-adapter/core';
3
3
  import { type MarkViewContext, type SvelteRendererResult } from '@prosemirror-adapter/svelte';
4
4
  import { type Component } from 'svelte';
5
- /**
6
- * @public
7
- */
8
5
  export interface SvelteMarkViewProps extends MarkViewContext {
9
6
  }
10
- /**
11
- * @public
12
- */
13
7
  export type SvelteMarkViewComponent = Component<SvelteMarkViewProps>;
14
8
  /**
15
9
  * Options for {@link defineSvelteMarkView}.
16
- *
17
- * @public
18
10
  */
19
11
  export interface SvelteMarkViewOptions extends CoreMarkViewUserOptions<SvelteMarkViewComponent> {
20
12
  /**
@@ -28,8 +20,6 @@ export interface SvelteMarkViewOptions extends CoreMarkViewUserOptions<SvelteMar
28
20
  export declare function defineSvelteMarkViewFactory(renderSvelteRenderer: SvelteRendererResult['renderSvelteRenderer'], removeSvelteRenderer: SvelteRendererResult['removeSvelteRenderer'], context: Map<any, any>): Extension;
29
21
  /**
30
22
  * Defines a mark view using a Svelte component.
31
- *
32
- * @public
33
23
  */
34
24
  export declare function defineSvelteMarkView(options: SvelteMarkViewOptions): Extension;
35
25
  //# sourceMappingURL=svelte-mark-view.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"svelte-mark-view.d.ts","sourceRoot":"","sources":["../../../src/extensions/svelte-mark-view.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgE,KAAK,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC7G,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAA;AACxE,OAAO,EAGL,KAAK,eAAe,EACpB,KAAK,oBAAoB,EAC1B,MAAM,6BAA6B,CAAA;AACpC,OAAO,EAA6B,KAAK,SAAS,EAAE,MAAM,QAAQ,CAAA;AAElE;;GAEG;AACH,MAAM,WAAW,mBAAoB,SAAQ,eAAe;CAAG;AAE/D;;GAEG;AACH,MAAM,MAAM,uBAAuB,GAAG,SAAS,CAAC,mBAAmB,CAAC,CAAA;AAEpE;;;;GAIG;AACH,MAAM,WAAW,qBAAsB,SAAQ,uBAAuB,CAAC,uBAAuB,CAAC;IAC7F;;OAEG;IACH,IAAI,EAAE,MAAM,CAAA;CACb;AAkBD;;GAEG;AACH,wBAAgB,2BAA2B,CACzC,oBAAoB,EAAE,oBAAoB,CAAC,sBAAsB,CAAC,EAClE,oBAAoB,EAAE,oBAAoB,CAAC,sBAAsB,CAAC,EAClE,OAAO,EAAE,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,GACrB,SAAS,CAMX;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,qBAAqB,GAC7B,SAAS,CAWX"}
1
+ {"version":3,"file":"svelte-mark-view.d.ts","sourceRoot":"","sources":["../../../src/extensions/svelte-mark-view.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgE,KAAK,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC7G,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAA;AACxE,OAAO,EAGL,KAAK,eAAe,EACpB,KAAK,oBAAoB,EAC1B,MAAM,6BAA6B,CAAA;AACpC,OAAO,EAA6B,KAAK,SAAS,EAAE,MAAM,QAAQ,CAAA;AAElE,MAAM,WAAW,mBAAoB,SAAQ,eAAe;CAAG;AAE/D,MAAM,MAAM,uBAAuB,GAAG,SAAS,CAAC,mBAAmB,CAAC,CAAA;AAEpE;;GAEG;AACH,MAAM,WAAW,qBAAsB,SAAQ,uBAAuB,CAAC,uBAAuB,CAAC;IAC7F;;OAEG;IACH,IAAI,EAAE,MAAM,CAAA;CACb;AAkBD;;GAEG;AACH,wBAAgB,2BAA2B,CACzC,oBAAoB,EAAE,oBAAoB,CAAC,sBAAsB,CAAC,EAClE,oBAAoB,EAAE,oBAAoB,CAAC,sBAAsB,CAAC,EAClE,OAAO,EAAE,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,GACrB,SAAS,CAMX;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,qBAAqB,GAC7B,SAAS,CAWX"}
@@ -30,8 +30,6 @@ export function defineSvelteMarkViewFactory(renderSvelteRenderer, removeSvelteRe
30
30
  }
31
31
  /**
32
32
  * Defines a mark view using a Svelte component.
33
- *
34
- * @public
35
33
  */
36
34
  export function defineSvelteMarkView(options) {
37
35
  // Don't register mark views on the server
@@ -2,19 +2,11 @@ import { type Extension } from '@prosekit/core';
2
2
  import type { CoreNodeViewUserOptions } from '@prosemirror-adapter/core';
3
3
  import { type NodeViewContext, type SvelteRendererResult } from '@prosemirror-adapter/svelte';
4
4
  import { type Component } from 'svelte';
5
- /**
6
- * @public
7
- */
8
5
  export interface SvelteNodeViewProps extends NodeViewContext {
9
6
  }
10
- /**
11
- * @public
12
- */
13
7
  export type SvelteNodeViewComponent = Component<SvelteNodeViewProps>;
14
8
  /**
15
9
  * Options for {@link defineSvelteNodeView}.
16
- *
17
- * @public
18
10
  */
19
11
  export interface SvelteNodeViewOptions extends CoreNodeViewUserOptions<SvelteNodeViewComponent> {
20
12
  /**
@@ -28,8 +20,6 @@ export interface SvelteNodeViewOptions extends CoreNodeViewUserOptions<SvelteNod
28
20
  export declare function defineSvelteNodeViewFactory(renderSvelteRenderer: SvelteRendererResult['renderSvelteRenderer'], removeSvelteRenderer: SvelteRendererResult['removeSvelteRenderer'], context: Map<any, any>): Extension;
29
21
  /**
30
22
  * Defines a node view using a Svelte component.
31
- *
32
- * @public
33
23
  */
34
24
  export declare function defineSvelteNodeView(options: SvelteNodeViewOptions): Extension;
35
25
  //# sourceMappingURL=svelte-node-view.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"svelte-node-view.d.ts","sourceRoot":"","sources":["../../../src/extensions/svelte-node-view.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgE,KAAK,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC7G,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAA;AACxE,OAAO,EAGL,KAAK,eAAe,EACpB,KAAK,oBAAoB,EAC1B,MAAM,6BAA6B,CAAA;AACpC,OAAO,EAA6B,KAAK,SAAS,EAAE,MAAM,QAAQ,CAAA;AAElE;;GAEG;AACH,MAAM,WAAW,mBAAoB,SAAQ,eAAe;CAAG;AAE/D;;GAEG;AACH,MAAM,MAAM,uBAAuB,GAAG,SAAS,CAAC,mBAAmB,CAAC,CAAA;AAEpE;;;;GAIG;AACH,MAAM,WAAW,qBAAsB,SAAQ,uBAAuB,CAAC,uBAAuB,CAAC;IAC7F;;OAEG;IACH,IAAI,EAAE,MAAM,CAAA;CACb;AAkBD;;GAEG;AACH,wBAAgB,2BAA2B,CACzC,oBAAoB,EAAE,oBAAoB,CAAC,sBAAsB,CAAC,EAClE,oBAAoB,EAAE,oBAAoB,CAAC,sBAAsB,CAAC,EAClE,OAAO,EAAE,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,GACrB,SAAS,CAMX;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,qBAAqB,GAC7B,SAAS,CAWX"}
1
+ {"version":3,"file":"svelte-node-view.d.ts","sourceRoot":"","sources":["../../../src/extensions/svelte-node-view.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgE,KAAK,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC7G,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAA;AACxE,OAAO,EAGL,KAAK,eAAe,EACpB,KAAK,oBAAoB,EAC1B,MAAM,6BAA6B,CAAA;AACpC,OAAO,EAA6B,KAAK,SAAS,EAAE,MAAM,QAAQ,CAAA;AAElE,MAAM,WAAW,mBAAoB,SAAQ,eAAe;CAAG;AAE/D,MAAM,MAAM,uBAAuB,GAAG,SAAS,CAAC,mBAAmB,CAAC,CAAA;AAEpE;;GAEG;AACH,MAAM,WAAW,qBAAsB,SAAQ,uBAAuB,CAAC,uBAAuB,CAAC;IAC7F;;OAEG;IACH,IAAI,EAAE,MAAM,CAAA;CACb;AAkBD;;GAEG;AACH,wBAAgB,2BAA2B,CACzC,oBAAoB,EAAE,oBAAoB,CAAC,sBAAsB,CAAC,EAClE,oBAAoB,EAAE,oBAAoB,CAAC,sBAAsB,CAAC,EAClE,OAAO,EAAE,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,GACrB,SAAS,CAMX;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,qBAAqB,GAC7B,SAAS,CAWX"}
@@ -30,8 +30,6 @@ export function defineSvelteNodeViewFactory(renderSvelteRenderer, removeSvelteRe
30
30
  }
31
31
  /**
32
32
  * Defines a node view using a Svelte component.
33
- *
34
- * @public
35
33
  */
36
34
  export function defineSvelteNodeView(options) {
37
35
  // Don't register node views on the server
@@ -2,8 +2,6 @@ import type { ProseMirrorNode } from '@prosekit/pm/model';
2
2
  import { type UseExtensionOptions } from './use-extension.ts';
3
3
  /**
4
4
  * Calls the given handler whenever the editor document changes.
5
- *
6
- * @public
7
5
  */
8
6
  export declare function useDocChange(handler: (doc: ProseMirrorNode) => void, options?: UseExtensionOptions): void;
9
7
  //# sourceMappingURL=use-doc-change.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"use-doc-change.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-doc-change.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AAGzD,OAAO,EAAgB,KAAK,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AAE3E;;;;GAIG;AACH,wBAAgB,YAAY,CAC1B,OAAO,EAAE,CAAC,GAAG,EAAE,eAAe,KAAK,IAAI,EACvC,OAAO,CAAC,EAAE,mBAAmB,GAC5B,IAAI,CAGN"}
1
+ {"version":3,"file":"use-doc-change.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-doc-change.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AAGzD,OAAO,EAAgB,KAAK,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AAE3E;;GAEG;AACH,wBAAgB,YAAY,CAC1B,OAAO,EAAE,CAAC,GAAG,EAAE,eAAe,KAAK,IAAI,EACvC,OAAO,CAAC,EAAE,mBAAmB,GAC5B,IAAI,CAGN"}
@@ -3,8 +3,6 @@ import { readable } from 'svelte/store';
3
3
  import { useExtension } from "./use-extension.js";
4
4
  /**
5
5
  * Calls the given handler whenever the editor document changes.
6
- *
7
- * @public
8
6
  */
9
7
  export function useDocChange(handler, options) {
10
8
  const extension = defineDocChangeHandler((view) => handler(view.state.doc));
@@ -16,8 +16,6 @@ export interface UseEditorDerivedOptions<E extends Extension = any> {
16
16
  *
17
17
  * It returns a Svelte store that stores the derived value and updates whenever
18
18
  * the editor state changes.
19
- *
20
- * @public
21
19
  */
22
20
  export declare function useEditorDerivedValue<E extends Extension, Derived>(
23
21
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"use-editor-derived-value.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-editor-derived-value.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AACvD,OAAO,EAAqB,KAAK,QAAQ,EAAE,MAAM,cAAc,CAAA;AAI/D,MAAM,WAAW,uBAAuB,CAAC,CAAC,SAAS,SAAS,GAAG,GAAG;IAChE;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAA;CACnB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,qBAAqB,CAAC,CAAC,SAAS,SAAS,EAAE,OAAO;AAChE;;;;;GAKG;AACH,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,KAAK,OAAO,EACtC,OAAO,CAAC,EAAE,uBAAuB,CAAC,CAAC,CAAC,GACnC,QAAQ,CAAC,OAAO,CAAC,CAOnB"}
1
+ {"version":3,"file":"use-editor-derived-value.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-editor-derived-value.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AACvD,OAAO,EAAqB,KAAK,QAAQ,EAAE,MAAM,cAAc,CAAA;AAI/D,MAAM,WAAW,uBAAuB,CAAC,CAAC,SAAS,SAAS,GAAG,GAAG;IAChE;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAA;CACnB;AAED;;;;;;;;;GASG;AACH,wBAAgB,qBAAqB,CAAC,CAAC,SAAS,SAAS,EAAE,OAAO;AAChE;;;;;GAKG;AACH,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,KAAK,OAAO,EACtC,OAAO,CAAC,EAAE,uBAAuB,CAAC,CAAC,CAAC,GACnC,QAAQ,CAAC,OAAO,CAAC,CAOnB"}
@@ -9,8 +9,6 @@ import { useEditor } from "./use-editor.js";
9
9
  *
10
10
  * It returns a Svelte store that stores the derived value and updates whenever
11
11
  * the editor state changes.
12
- *
13
- * @public
14
12
  */
15
13
  export function useEditorDerivedValue(
16
14
  /**
@@ -2,8 +2,6 @@ import { type Editor, type Extension } from '@prosekit/core';
2
2
  import { type Readable } from 'svelte/store';
3
3
  /**
4
4
  * Retrieves the editor instance from the nearest ProseKit component.
5
- *
6
- * @public
7
5
  */
8
6
  export declare function useEditor<E extends Extension = any>(options?: {
9
7
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"use-editor.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-editor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiE,KAAK,MAAM,EAAE,KAAK,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAE3H,OAAO,EAAsB,KAAK,QAAQ,EAAE,MAAM,cAAc,CAAA;AAIhE;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,CAAC,SAAS,SAAS,GAAG,GAAG,EAAE,OAAO,CAAC,EAAE;IAC7D;;;;;OAKG;IACH,MAAM,CAAC,EAAE,OAAO,CAAA;CACjB,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CA8BtB"}
1
+ {"version":3,"file":"use-editor.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-editor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiE,KAAK,MAAM,EAAE,KAAK,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAE3H,OAAO,EAAsB,KAAK,QAAQ,EAAE,MAAM,cAAc,CAAA;AAIhE;;GAEG;AACH,wBAAgB,SAAS,CAAC,CAAC,SAAS,SAAS,GAAG,GAAG,EAAE,OAAO,CAAC,EAAE;IAC7D;;;;;OAKG;IACH,MAAM,CAAC,EAAE,OAAO,CAAA;CACjB,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CA8BtB"}
@@ -4,8 +4,6 @@ import { readonly, writable } from 'svelte/store';
4
4
  import { useEditorContext } from "../contexts/editor-context.js";
5
5
  /**
6
6
  * Retrieves the editor instance from the nearest ProseKit component.
7
- *
8
- * @public
9
7
  */
10
8
  export function useEditor(options) {
11
9
  const update = options?.update ?? false;
@@ -2,8 +2,6 @@ import type { EditorState } from '@prosekit/pm/state';
2
2
  import { type UseExtensionOptions } from './use-extension.ts';
3
3
  /**
4
4
  * Calls the given handler whenever the editor state changes.
5
- *
6
- * @public
7
5
  */
8
6
  export declare function useStateUpdate(handler: (state: EditorState) => void, options?: UseExtensionOptions): void;
9
7
  //# sourceMappingURL=use-state-update.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"use-state-update.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-state-update.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAGrD,OAAO,EAAgB,KAAK,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AAE3E;;;;GAIG;AACH,wBAAgB,cAAc,CAC5B,OAAO,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,EACrC,OAAO,CAAC,EAAE,mBAAmB,GAC5B,IAAI,CAGN"}
1
+ {"version":3,"file":"use-state-update.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-state-update.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAGrD,OAAO,EAAgB,KAAK,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AAE3E;;GAEG;AACH,wBAAgB,cAAc,CAC5B,OAAO,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,EACrC,OAAO,CAAC,EAAE,mBAAmB,GAC5B,IAAI,CAGN"}
@@ -3,8 +3,6 @@ import { readable } from 'svelte/store';
3
3
  import { useExtension } from "./use-extension.js";
4
4
  /**
5
5
  * Calls the given handler whenever the editor state changes.
6
- *
7
- * @public
8
6
  */
9
7
  export function useStateUpdate(handler, options) {
10
8
  const extension = defineUpdateHandler((view) => handler(view.state));
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@prosekit/svelte",
3
3
  "type": "module",
4
- "version": "0.9.0",
4
+ "version": "0.9.2",
5
5
  "private": false,
6
6
  "description": "Svelte components and utilities for ProseKit",
7
7
  "author": {
@@ -83,9 +83,9 @@
83
83
  "dependencies": {
84
84
  "@prosemirror-adapter/core": "^0.5.3",
85
85
  "@prosemirror-adapter/svelte": "^0.5.3",
86
- "@prosekit/core": "^0.12.0",
87
- "@prosekit/web": "^0.8.0",
88
- "@prosekit/pm": "^0.1.16"
86
+ "@prosekit/core": "^0.12.1",
87
+ "@prosekit/web": "^0.8.2",
88
+ "@prosekit/pm": "^0.1.17"
89
89
  },
90
90
  "peerDependencies": {
91
91
  "svelte": ">= 5.0.0"
@@ -97,13 +97,13 @@
97
97
  },
98
98
  "devDependencies": {
99
99
  "@sveltejs/package": "^2.5.7",
100
- "@sveltejs/vite-plugin-svelte": "^7.0.0",
101
- "@types/node": "^24.10.13",
100
+ "@sveltejs/vite-plugin-svelte": "^7.1.2",
101
+ "@types/node": "^24.12.2",
102
102
  "svelte": "^5.55.5",
103
- "svelte-check": "^4.4.6",
103
+ "svelte-check": "^4.4.8",
104
104
  "tsx": "^4.21.0",
105
- "typescript": "~5.9.3",
106
- "vitest": "^4.1.5",
105
+ "typescript": "~6.0.3",
106
+ "vitest": "^4.1.6",
107
107
  "vitest-browser-svelte": "^2.1.1",
108
108
  "@prosekit/config-ts": "0.0.0",
109
109
  "@prosekit/config-vitest": "0.0.0",
@@ -5,16 +5,16 @@
5
5
  import { useEditorContext } from '../../contexts/editor-context.ts'
6
6
  registerAutocompleteRootElement()
7
7
 
8
- let { editor: p0, filter: p1, regex: p2, onOpenChange: e0, onQueryChange: e1, onValueChange: e2, onValuesChange: e3, children = undefined, ...restProps } = $props()
8
+ let { anchor: p0, editor: p1, filter: p2, regex: p3, onOpenChange: e0, onQueryChange: e1, onValueChange: e2, onValuesChange: e3, children = undefined, ...restProps } = $props()
9
9
  let element: AutocompleteRootElement | undefined
10
10
  const handlers: EventListener[] = []
11
11
 
12
- const p0Fallback = useEditorContext()
12
+ const p1Fallback = useEditorContext()
13
13
 
14
14
  $effect(() => {
15
15
  if (!element) return
16
16
 
17
- Object.assign(element, { editor: p0 ?? p0Fallback, filter: p1, regex: p2 })
17
+ Object.assign(element, { anchor: p0, editor: p1 ?? p1Fallback, filter: p2, regex: p3 })
18
18
 
19
19
  handlers.length = 0
20
20
  handlers.push(e0)
@@ -28,6 +28,15 @@ export interface AutocompleteRootProps {
28
28
  * @default defaultItemFilter
29
29
  */
30
30
  filter?: AutocompleteRootElementProps['filter'];
31
+ /**
32
+ * The reference to position the popup against. This can be a DOM element, a
33
+ * Floating UI virtual element, or a function that returns either of them.
34
+ * By default, the popup will be positioned against the text content that
35
+ * triggers the autocomplete.
36
+ *
37
+ * @default null
38
+ */
39
+ anchor?: AutocompleteRootElementProps['anchor'];
31
40
  /** Fired when the open state changes. */
32
41
  onOpenChange?: (event: AutocompleteRootEvents['openChange']) => void;
33
42
  /** Fired when the query changes. */
@@ -1,15 +1,14 @@
1
1
  import type { Editor } from '@prosekit/core'
2
- import type { SvelteComponent } from 'svelte'
2
+ import type { Component, Snippet } from 'svelte'
3
3
 
4
4
  import Comp from './prosekit.svelte'
5
5
 
6
6
  export interface ProseKitProps {
7
7
  editor: Editor
8
+ children?: Snippet
8
9
  }
9
10
 
10
11
  /**
11
12
  * The root component for a ProseKit editor.
12
- *
13
- * @public
14
13
  */
15
- export const ProseKit = Comp as typeof SvelteComponent<any> as typeof SvelteComponent<ProseKitProps>
14
+ export const ProseKit = Comp as Component<ProseKitProps>
@@ -1,13 +1,14 @@
1
1
  <script lang="ts">
2
2
  import type { Editor } from '@prosekit/core'
3
+ import type { Snippet } from 'svelte'
3
4
  import { setEditorContext } from '../../contexts/editor-context.ts'
4
5
  import { ViewRenderer } from '../view-renderer/index.ts'
5
6
 
6
- export let editor: Editor
7
+ let props: { editor: Editor; children?: Snippet } = $props()
7
8
 
8
- setEditorContext(editor)
9
+ setEditorContext(() => props.editor)
9
10
  </script>
10
11
 
11
- <ViewRenderer {editor}>
12
- <slot />
12
+ <ViewRenderer editor={props.editor}>
13
+ {@render props.children?.()}
13
14
  </ViewRenderer>
@@ -6,11 +6,8 @@ const key = 'prosekit-svelte-editor-context'
6
6
  /**
7
7
  * @internal
8
8
  */
9
- export function setEditorContext(editor: Editor): void {
10
- if (!editor) {
11
- throw new ProseKitError('editor should not be empty')
12
- }
13
- setContext(key, editor)
9
+ export function setEditorContext(getEditor: () => Editor): void {
10
+ setContext(key, getEditor)
14
11
  }
15
12
 
16
13
  /**
@@ -18,6 +15,11 @@ export function setEditorContext(editor: Editor): void {
18
15
  */
19
16
  export function useEditorContext<E extends Extension>(): Editor<E> | undefined {
20
17
  if (hasContext(key)) {
21
- return getContext(key)
18
+ const context: () => Editor = getContext(key)
19
+ const editor = context()
20
+ if (!editor) {
21
+ throw new ProseKitError('editor should not be empty')
22
+ }
23
+ return editor
22
24
  }
23
25
  }
@@ -8,20 +8,12 @@ import {
8
8
  } from '@prosemirror-adapter/svelte'
9
9
  import { flushSync, mount, unmount, type Component } from 'svelte'
10
10
 
11
- /**
12
- * @public
13
- */
14
11
  export interface SvelteMarkViewProps extends MarkViewContext {}
15
12
 
16
- /**
17
- * @public
18
- */
19
13
  export type SvelteMarkViewComponent = Component<SvelteMarkViewProps>
20
14
 
21
15
  /**
22
16
  * Options for {@link defineSvelteMarkView}.
23
- *
24
- * @public
25
17
  */
26
18
  export interface SvelteMarkViewOptions extends CoreMarkViewUserOptions<SvelteMarkViewComponent> {
27
19
  /**
@@ -63,8 +55,6 @@ export function defineSvelteMarkViewFactory(
63
55
 
64
56
  /**
65
57
  * Defines a mark view using a Svelte component.
66
- *
67
- * @public
68
58
  */
69
59
  export function defineSvelteMarkView(
70
60
  options: SvelteMarkViewOptions,
@@ -8,20 +8,12 @@ import {
8
8
  } from '@prosemirror-adapter/svelte'
9
9
  import { flushSync, mount, unmount, type Component } from 'svelte'
10
10
 
11
- /**
12
- * @public
13
- */
14
11
  export interface SvelteNodeViewProps extends NodeViewContext {}
15
12
 
16
- /**
17
- * @public
18
- */
19
13
  export type SvelteNodeViewComponent = Component<SvelteNodeViewProps>
20
14
 
21
15
  /**
22
16
  * Options for {@link defineSvelteNodeView}.
23
- *
24
- * @public
25
17
  */
26
18
  export interface SvelteNodeViewOptions extends CoreNodeViewUserOptions<SvelteNodeViewComponent> {
27
19
  /**
@@ -63,8 +55,6 @@ export function defineSvelteNodeViewFactory(
63
55
 
64
56
  /**
65
57
  * Defines a node view using a Svelte component.
66
- *
67
- * @public
68
58
  */
69
59
  export function defineSvelteNodeView(
70
60
  options: SvelteNodeViewOptions,
@@ -6,8 +6,6 @@ import { useExtension, type UseExtensionOptions } from './use-extension.ts'
6
6
 
7
7
  /**
8
8
  * Calls the given handler whenever the editor document changes.
9
- *
10
- * @public
11
9
  */
12
10
  export function useDocChange(
13
11
  handler: (doc: ProseMirrorNode) => void,
@@ -20,8 +20,6 @@ export interface UseEditorDerivedOptions<E extends Extension = any> {
20
20
  *
21
21
  * It returns a Svelte store that stores the derived value and updates whenever
22
22
  * the editor state changes.
23
- *
24
- * @public
25
23
  */
26
24
  export function useEditorDerivedValue<E extends Extension, Derived>(
27
25
  /**
@@ -6,8 +6,6 @@ import { useEditorContext } from '../contexts/editor-context.ts'
6
6
 
7
7
  /**
8
8
  * Retrieves the editor instance from the nearest ProseKit component.
9
- *
10
- * @public
11
9
  */
12
10
  export function useEditor<E extends Extension = any>(options?: {
13
11
  /**
@@ -6,8 +6,6 @@ import { useExtension, type UseExtensionOptions } from './use-extension.ts'
6
6
 
7
7
  /**
8
8
  * Calls the given handler whenever the editor state changes.
9
- *
10
- * @public
11
9
  */
12
10
  export function useStateUpdate(
13
11
  handler: (state: EditorState) => void,