@prosekit/svelte 0.9.0-beta.6 → 0.9.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.
@@ -10,11 +10,18 @@ export interface AutocompletePositionerProps {
10
10
  */
11
11
  placement?: AutocompletePositionerElementProps['placement'];
12
12
  /**
13
- * The distance between the popover and the hovered block.
13
+ * The distance between the popover and the text selection.
14
14
  *
15
- * @default 4
15
+ * @default { mainAxis: 8, crossAxis: -4 }
16
16
  */
17
17
  offset?: AutocompletePositionerElementProps['offset'];
18
+ /**
19
+ * Whether to hide the floating element when the reference element or the
20
+ * floating element is fully clipped.
21
+ *
22
+ * @default true
23
+ */
24
+ hide?: AutocompletePositionerElementProps['hide'];
18
25
  /** @default true */
19
26
  inline?: AutocompletePositionerElementProps['inline'];
20
27
  /** @default true */
@@ -75,13 +82,6 @@ export interface AutocompletePositionerProps {
75
82
  * @default false
76
83
  */
77
84
  sameHeight?: AutocompletePositionerElementProps['sameHeight'];
78
- /**
79
- * Whether to hide the floating element when the reference element or the
80
- * floating element is fully clipped.
81
- *
82
- * @default false
83
- */
84
- hide?: AutocompletePositionerElementProps['hide'];
85
85
  /**
86
86
  * Describes the root boundary that the element will be checked for overflow relative to.
87
87
  * Please see https://floating-ui.com/docs/detectoverflow#rootboundary for more information.
@@ -1 +1 @@
1
- {"version":3,"file":"autocomplete-positioner.gen.d.ts","sourceRoot":"","sources":["../../../../src/components/autocomplete/autocomplete-positioner.gen.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,6BAA6B,EAAE,2BAA2B,IAAI,kCAAkC,EAAE,MAAM,4BAA4B,CAAC;AACnJ,OAAO,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AACjD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAItD,qEAAqE;AACrE,MAAM,WAAW,2BAA2B;IAC1C;;;;OAIG;IACH,SAAS,CAAC,EAAE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AC,EAAE,kCAAkC,CAAC,aAAa,CAAC,CAAC;IAChE,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,4FAA4F;AAC5F,eAAO,MAAM,sBAAsB,EAAE,SAAS,CAAC,2BAA2B,GAAG,cAAc,CAAC,6BAA6B,CAAC,CAA6H,CAAC"}
1
+ {"version":3,"file":"autocomplete-positioner.gen.d.ts","sourceRoot":"","sources":["../../../../src/components/autocomplete/autocomplete-positioner.gen.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,6BAA6B,EAAE,2BAA2B,IAAI,kCAAkC,EAAE,MAAM,4BAA4B,CAAC;AACnJ,OAAO,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AACjD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAItD,qEAAqE;AACrE,MAAM,WAAW,2BAA2B;IAC1C;;;;OAIG;IACH,SAAS,CAAC,EAAE,kCAAkC,CAAC,WAAW,CAAC,CAAC;IAC5D;;;;OAIG;IACH,MAAM,CAAC,EAAE,kCAAkC,CAAC,QAAQ,CAAC,CAAC;IACtD;;;;;OAKG;IACH,IAAI,CAAC,EAAE,kCAAkC,CAAC,MAAM,CAAC,CAAC;IAClD,oBAAoB;IACpB,MAAM,CAAC,EAAE,kCAAkC,CAAC,QAAQ,CAAC,CAAC;IACtD,oBAAoB;IACpB,KAAK,CAAC,EAAE,kCAAkC,CAAC,OAAO,CAAC,CAAC;IACpD,oBAAoB;IACpB,WAAW,CAAC,EAAE,kCAAkC,CAAC,aAAa,CAAC,CAAC;IAChE,kCAAkC;IAClC,QAAQ,CAAC,EAAE,kCAAkC,CAAC,UAAU,CAAC,CAAC;IAC1D,iBAAiB;IACjB,eAAe,CAAC,EAAE,kCAAkC,CAAC,iBAAiB,CAAC,CAAC;IACxE;;;;OAIG;IACH,QAAQ,CAAC,EAAE,kCAAkC,CAAC,UAAU,CAAC,CAAC;IAC1D;;;;;;OAMG;IACH,UAAU,CAAC,EAAE,kCAAkC,CAAC,YAAY,CAAC,CAAC;IAC9D;;;;;;;OAOG;IACH,IAAI,CAAC,EAAE,kCAAkC,CAAC,MAAM,CAAC,CAAC;IAClD;;;;OAIG;IACH,KAAK,CAAC,EAAE,kCAAkC,CAAC,OAAO,CAAC,CAAC;IACpD;;;;;OAKG;IACH,OAAO,CAAC,EAAE,kCAAkC,CAAC,SAAS,CAAC,CAAC;IACxD;;;;;OAKG;IACH,SAAS,CAAC,EAAE,kCAAkC,CAAC,WAAW,CAAC,CAAC;IAC5D;;;;;OAKG;IACH,UAAU,CAAC,EAAE,kCAAkC,CAAC,YAAY,CAAC,CAAC;IAC9D;;;;;OAKG;IACH,YAAY,CAAC,EAAE,kCAAkC,CAAC,cAAc,CAAC,CAAC;IAClE;;;;;;OAMG;IACH,cAAc,CAAC,EAAE,kCAAkC,CAAC,gBAAgB,CAAC,CAAC;IACtE;;;;;;OAMG;IACH,WAAW,CAAC,EAAE,kCAAkC,CAAC,aAAa,CAAC,CAAC;IAChE,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,4FAA4F;AAC5F,eAAO,MAAM,sBAAsB,EAAE,SAAS,CAAC,2BAA2B,GAAG,cAAc,CAAC,6BAA6B,CAAC,CAA6H,CAAC"}
@@ -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,13 @@
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
  *
9
10
  * @public
10
11
  */
11
- export declare const ProseKit: typeof SvelteComponent<ProseKitProps>;
12
+ export declare const ProseKit: Component<ProseKitProps>;
12
13
  //# 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;;;;GAIG;AACH,eAAO,MAAM,QAAQ,EAAW,SAAS,CAAC,aAAa,CAAC,CAAA"}
@@ -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":"A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"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
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@prosekit/svelte",
3
3
  "type": "module",
4
- "version": "0.9.0-beta.6",
4
+ "version": "0.9.1",
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-beta.1",
87
- "@prosekit/pm": "^0.1.16-beta.0",
88
- "@prosekit/web": "^0.8.0-beta.6"
86
+ "@prosekit/core": "^0.12.0",
87
+ "@prosekit/pm": "^0.1.16",
88
+ "@prosekit/web": "^0.8.1"
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",
102
- "svelte": "^5.55.3",
103
- "svelte-check": "^4.4.6",
100
+ "@sveltejs/vite-plugin-svelte": "^7.1.2",
101
+ "@types/node": "^24.12.2",
102
+ "svelte": "^5.55.5",
103
+ "svelte-check": "^4.4.8",
104
104
  "tsx": "^4.21.0",
105
- "typescript": "~5.9.3",
106
- "vitest": "^4.1.4",
105
+ "typescript": "~6.0.3",
106
+ "vitest": "^4.1.5",
107
107
  "vitest-browser-svelte": "^2.1.1",
108
108
  "@prosekit/config-ts": "0.0.0",
109
109
  "@prosekit/config-vitest": "0.0.0",
@@ -15,11 +15,18 @@ export interface AutocompletePositionerProps {
15
15
  */
16
16
  placement?: AutocompletePositionerElementProps['placement'];
17
17
  /**
18
- * The distance between the popover and the hovered block.
18
+ * The distance between the popover and the text selection.
19
19
  *
20
- * @default 4
20
+ * @default { mainAxis: 8, crossAxis: -4 }
21
21
  */
22
22
  offset?: AutocompletePositionerElementProps['offset'];
23
+ /**
24
+ * Whether to hide the floating element when the reference element or the
25
+ * floating element is fully clipped.
26
+ *
27
+ * @default true
28
+ */
29
+ hide?: AutocompletePositionerElementProps['hide'];
23
30
  /** @default true */
24
31
  inline?: AutocompletePositionerElementProps['inline'];
25
32
  /** @default true */
@@ -80,13 +87,6 @@ export interface AutocompletePositionerProps {
80
87
  * @default false
81
88
  */
82
89
  sameHeight?: AutocompletePositionerElementProps['sameHeight'];
83
- /**
84
- * Whether to hide the floating element when the reference element or the
85
- * floating element is fully clipped.
86
- *
87
- * @default false
88
- */
89
- hide?: AutocompletePositionerElementProps['hide'];
90
90
  /**
91
91
  * Describes the root boundary that the element will be checked for overflow relative to.
92
92
  * Please see https://floating-ui.com/docs/detectoverflow#rootboundary for more information.
@@ -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,10 +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
 
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
  /**
@@ -12,4 +13,4 @@ export interface ProseKitProps {
12
13
  *
13
14
  * @public
14
15
  */
15
- export const ProseKit = Comp as typeof SvelteComponent<any> as typeof SvelteComponent<ProseKitProps>
16
+ 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
  }