@prosekit/svelte 0.0.0-next-20240626133927 → 0.0.0-next-20240715024943

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 (108) hide show
  1. package/dist/build/components/autocomplete/autocomplete-empty.gen.d.ts +3 -4
  2. package/dist/build/components/autocomplete/autocomplete-empty.gen.d.ts.map +1 -1
  3. package/dist/build/components/autocomplete/autocomplete-empty.gen.svelte +8 -5
  4. package/dist/build/components/autocomplete/autocomplete-empty.gen.svelte.d.ts.map +1 -1
  5. package/dist/build/components/autocomplete/autocomplete-item.gen.d.ts +3 -4
  6. package/dist/build/components/autocomplete/autocomplete-item.gen.d.ts.map +1 -1
  7. package/dist/build/components/autocomplete/autocomplete-item.gen.svelte +8 -5
  8. package/dist/build/components/autocomplete/autocomplete-item.gen.svelte.d.ts.map +1 -1
  9. package/dist/build/components/autocomplete/autocomplete-list.gen.d.ts +3 -4
  10. package/dist/build/components/autocomplete/autocomplete-list.gen.d.ts.map +1 -1
  11. package/dist/build/components/autocomplete/autocomplete-list.gen.svelte +8 -5
  12. package/dist/build/components/autocomplete/autocomplete-list.gen.svelte.d.ts.map +1 -1
  13. package/dist/build/components/autocomplete/autocomplete-popover.gen.d.ts +3 -4
  14. package/dist/build/components/autocomplete/autocomplete-popover.gen.d.ts.map +1 -1
  15. package/dist/build/components/autocomplete/autocomplete-popover.gen.svelte +8 -5
  16. package/dist/build/components/autocomplete/autocomplete-popover.gen.svelte.d.ts.map +1 -1
  17. package/dist/build/components/block-handle/block-drag-handle.gen.d.ts +3 -4
  18. package/dist/build/components/block-handle/block-drag-handle.gen.d.ts.map +1 -1
  19. package/dist/build/components/block-handle/block-drag-handle.gen.svelte +8 -5
  20. package/dist/build/components/block-handle/block-drag-handle.gen.svelte.d.ts.map +1 -1
  21. package/dist/build/components/block-handle/block-popover.gen.d.ts +3 -4
  22. package/dist/build/components/block-handle/block-popover.gen.d.ts.map +1 -1
  23. package/dist/build/components/block-handle/block-popover.gen.svelte +8 -5
  24. package/dist/build/components/block-handle/block-popover.gen.svelte.d.ts.map +1 -1
  25. package/dist/build/components/inline-popover/inline-popover.gen.d.ts +3 -4
  26. package/dist/build/components/inline-popover/inline-popover.gen.d.ts.map +1 -1
  27. package/dist/build/components/inline-popover/inline-popover.gen.svelte +8 -5
  28. package/dist/build/components/inline-popover/inline-popover.gen.svelte.d.ts.map +1 -1
  29. package/dist/build/components/node-view-consumer/index.d.ts +6 -0
  30. package/dist/build/components/node-view-consumer/index.d.ts.map +1 -0
  31. package/dist/build/components/node-view-consumer/index.js +5 -0
  32. package/dist/build/components/node-view-consumer/node-view-consumer.svelte +15 -0
  33. package/dist/build/components/node-view-consumer/node-view-consumer.svelte.d.ts +17 -0
  34. package/dist/build/components/node-view-consumer/node-view-consumer.svelte.d.ts.map +1 -0
  35. package/dist/build/components/node-view-wrapper/index.d.ts +6 -0
  36. package/dist/build/components/node-view-wrapper/index.d.ts.map +1 -0
  37. package/dist/build/components/node-view-wrapper/index.js +2 -0
  38. package/dist/build/components/node-view-wrapper/node-view-wrapper.svelte +20 -0
  39. package/dist/build/components/node-view-wrapper/node-view-wrapper.svelte.d.ts +19 -0
  40. package/dist/build/components/node-view-wrapper/node-view-wrapper.svelte.d.ts.map +1 -0
  41. package/dist/build/components/popover/popover-content.gen.d.ts +3 -4
  42. package/dist/build/components/popover/popover-content.gen.d.ts.map +1 -1
  43. package/dist/build/components/popover/popover-content.gen.svelte +8 -5
  44. package/dist/build/components/popover/popover-content.gen.svelte.d.ts.map +1 -1
  45. package/dist/build/components/popover/popover-root.gen.d.ts +3 -4
  46. package/dist/build/components/popover/popover-root.gen.d.ts.map +1 -1
  47. package/dist/build/components/popover/popover-root.gen.svelte +8 -5
  48. package/dist/build/components/popover/popover-root.gen.svelte.d.ts.map +1 -1
  49. package/dist/build/components/popover/popover-trigger.gen.d.ts +3 -4
  50. package/dist/build/components/popover/popover-trigger.gen.d.ts.map +1 -1
  51. package/dist/build/components/popover/popover-trigger.gen.svelte +8 -5
  52. package/dist/build/components/popover/popover-trigger.gen.svelte.d.ts.map +1 -1
  53. package/dist/build/components/{prosekit.d.ts → prosekit/index.d.ts} +1 -1
  54. package/dist/build/components/prosekit/index.d.ts.map +1 -0
  55. package/dist/build/components/prosekit/index.js +7 -0
  56. package/dist/build/components/prosekit/prosekit.svelte +14 -0
  57. package/dist/build/components/prosekit/prosekit.svelte.d.ts.map +1 -0
  58. package/dist/build/components/resizable/resizable-handle.gen.d.ts +3 -4
  59. package/dist/build/components/resizable/resizable-handle.gen.d.ts.map +1 -1
  60. package/dist/build/components/resizable/resizable-handle.gen.svelte +8 -5
  61. package/dist/build/components/resizable/resizable-handle.gen.svelte.d.ts.map +1 -1
  62. package/dist/build/components/resizable/resizable-root.gen.d.ts +3 -4
  63. package/dist/build/components/resizable/resizable-root.gen.d.ts.map +1 -1
  64. package/dist/build/components/resizable/resizable-root.gen.svelte +8 -5
  65. package/dist/build/components/resizable/resizable-root.gen.svelte.d.ts.map +1 -1
  66. package/dist/build/components/tooltip/tooltip-content.gen.d.ts +3 -4
  67. package/dist/build/components/tooltip/tooltip-content.gen.d.ts.map +1 -1
  68. package/dist/build/components/tooltip/tooltip-content.gen.svelte +8 -5
  69. package/dist/build/components/tooltip/tooltip-content.gen.svelte.d.ts.map +1 -1
  70. package/dist/build/components/tooltip/tooltip-root.gen.d.ts +3 -4
  71. package/dist/build/components/tooltip/tooltip-root.gen.d.ts.map +1 -1
  72. package/dist/build/components/tooltip/tooltip-root.gen.svelte +8 -5
  73. package/dist/build/components/tooltip/tooltip-root.gen.svelte.d.ts.map +1 -1
  74. package/dist/build/components/tooltip/tooltip-trigger.gen.d.ts +3 -4
  75. package/dist/build/components/tooltip/tooltip-trigger.gen.d.ts.map +1 -1
  76. package/dist/build/components/tooltip/tooltip-trigger.gen.svelte +8 -5
  77. package/dist/build/components/tooltip/tooltip-trigger.gen.svelte.d.ts.map +1 -1
  78. package/dist/build/contexts/editor-context.d.ts +1 -1
  79. package/dist/build/contexts/editor-context.d.ts.map +1 -1
  80. package/dist/build/contexts/editor-context.js +2 -3
  81. package/dist/build/hooks/use-editor-extension.d.ts.map +1 -1
  82. package/dist/build/hooks/use-editor-extension.js +21 -17
  83. package/dist/build/hooks/use-editor.d.ts.map +1 -1
  84. package/dist/build/hooks/use-editor.js +3 -4
  85. package/dist/build/index.d.ts +4 -2
  86. package/dist/build/index.d.ts.map +1 -1
  87. package/dist/build/index.js +2 -1
  88. package/dist/build/node-view/define-svelte-node-view-factory.d.ts +4 -0
  89. package/dist/build/node-view/define-svelte-node-view-factory.d.ts.map +1 -0
  90. package/dist/build/node-view/define-svelte-node-view-factory.js +7 -0
  91. package/dist/build/node-view/define-svelte-node-view.d.ts +9 -0
  92. package/dist/build/node-view/define-svelte-node-view.d.ts.map +1 -0
  93. package/dist/build/node-view/define-svelte-node-view.js +26 -0
  94. package/dist/build/node-view/types.d.ts +38 -0
  95. package/dist/build/node-view/types.d.ts.map +1 -0
  96. package/dist/build/node-view/types.js +1 -0
  97. package/dist/build/utils/use-web-component.d.ts +2 -0
  98. package/dist/build/utils/use-web-component.d.ts.map +1 -0
  99. package/dist/build/utils/use-web-component.js +36 -0
  100. package/package.json +10 -9
  101. package/dist/build/components/prosekit.d.ts.map +0 -1
  102. package/dist/build/components/prosekit.js +0 -7
  103. package/dist/build/components/prosekit.svelte +0 -10
  104. package/dist/build/components/prosekit.svelte.d.ts.map +0 -1
  105. package/dist/build/utils/remove-undefined.d.ts +0 -2
  106. package/dist/build/utils/remove-undefined.d.ts.map +0 -1
  107. package/dist/build/utils/remove-undefined.js +0 -10
  108. /package/dist/build/components/{prosekit.svelte.d.ts → prosekit/prosekit.svelte.d.ts} +0 -0
@@ -1,14 +1,17 @@
1
1
  <script lang="ts">
2
2
  import '@prosekit/web/popover'
3
3
  import { defaultPopoverTriggerProps } from '@prosekit/web/popover'
4
+ import { useWebComponent } from '../../utils/use-web-component'
4
5
 
5
- import { useEditorContext } from '../../contexts/editor-context'
6
+ let attributes: Record<string, unknown> = {}
7
+ let element: HTMLElement | undefined = undefined
8
+ const handleChange = useWebComponent(defaultPopoverTriggerProps)
6
9
 
7
- const hasEditor = Object.hasOwn(defaultPopoverTriggerProps, 'editor')
8
- const editorContext = useEditorContext()
9
- const editor = hasEditor ? editorContext : undefined
10
+ $: {
11
+ attributes = handleChange(element, $$props)
12
+ }
10
13
  </script>
11
14
 
12
- <prosekit-popover-trigger {editor} {...$$props}>
15
+ <prosekit-popover-trigger {...attributes} bind:this={element}>
13
16
  <slot />
14
17
  </prosekit-popover-trigger>
@@ -1 +1 @@
1
- {"version":3,"file":"popover-trigger.gen.svelte.d.ts","sourceRoot":"","sources":["../../../../../src/components/popover/popover-trigger.gen.svelte"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,QAAQ,CAE5C;AACD,OAAO,uBAAuB,CAAA;AAsB9B,QAAA,MAAM,SAAS;;;;;;;;;;CAA+D,CAAC;AAC/E,MAAM,MAAM,mBAAmB,GAAG,OAAO,SAAS,CAAC,KAAK,CAAC;AACzD,MAAM,MAAM,oBAAoB,GAAG,OAAO,SAAS,CAAC,MAAM,CAAC;AAC3D,MAAM,MAAM,mBAAmB,GAAG,OAAO,SAAS,CAAC,KAAK,CAAC;AAEzD,MAAM,CAAC,OAAO,OAAO,cAAe,SAAQ,oBAAoB,CAAC,mBAAmB,EAAE,oBAAoB,EAAE,mBAAmB,CAAC;CAC/H"}
1
+ {"version":3,"file":"popover-trigger.gen.svelte.d.ts","sourceRoot":"","sources":["../../../../../src/components/popover/popover-trigger.gen.svelte"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,QAAQ,CAE5C;AACD,OAAO,uBAAuB,CAAA;AAwB9B,QAAA,MAAM,SAAS;;;;;;;;;;CAA+D,CAAC;AAC/E,MAAM,MAAM,mBAAmB,GAAG,OAAO,SAAS,CAAC,KAAK,CAAC;AACzD,MAAM,MAAM,oBAAoB,GAAG,OAAO,SAAS,CAAC,MAAM,CAAC;AAC3D,MAAM,MAAM,mBAAmB,GAAG,OAAO,SAAS,CAAC,KAAK,CAAC;AAEzD,MAAM,CAAC,OAAO,OAAO,cAAe,SAAQ,oBAAoB,CAAC,mBAAmB,EAAE,oBAAoB,EAAE,mBAAmB,CAAC;CAC/H"}
@@ -9,4 +9,4 @@ export interface ProseKitProps {
9
9
  * @public
10
10
  */
11
11
  export declare const ProseKit: typeof SvelteComponent<ProseKitProps>;
12
- //# sourceMappingURL=prosekit.d.ts.map
12
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +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,EACoB,OAAO,eAAe,CAAC,aAAa,CAAC,CAAA"}
@@ -0,0 +1,7 @@
1
+ import Comp from './prosekit.svelte';
2
+ /**
3
+ * The root component for a ProseKit editor.
4
+ *
5
+ * @public
6
+ */
7
+ export const ProseKit = Comp;
@@ -0,0 +1,14 @@
1
+ <script lang="ts">
2
+ import type { Editor } from '@prosekit/core'
3
+ import { useProsemirrorAdapterProvider } from '@prosemirror-adapter/svelte'
4
+ import { setEditorContext } from '../../contexts/editor-context'
5
+ import { NodeViewConsumer } from '../node-view-consumer'
6
+
7
+ export let editor: Editor
8
+
9
+ setEditorContext(editor)
10
+ useProsemirrorAdapterProvider()
11
+ </script>
12
+
13
+ <slot />
14
+ <NodeViewConsumer />
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prosekit.svelte.d.ts","sourceRoot":"","sources":["../../../../../src/components/prosekit/prosekit.svelte"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,QAAQ,CAE5C;AACD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAsB5C,QAAA,MAAM,SAAS;;gBAD8B,MAAM;;;;;;;;CACI,CAAC;AACxD,MAAM,MAAM,aAAa,GAAG,OAAO,SAAS,CAAC,KAAK,CAAC;AACnD,MAAM,MAAM,cAAc,GAAG,OAAO,SAAS,CAAC,MAAM,CAAC;AACrD,MAAM,MAAM,aAAa,GAAG,OAAO,SAAS,CAAC,KAAK,CAAC;AAEnD,MAAM,CAAC,OAAO,OAAO,QAAS,SAAQ,oBAAoB,CAAC,aAAa,EAAE,cAAc,EAAE,aAAa,CAAC;CACvG"}
@@ -1,6 +1,5 @@
1
- import type { ResizableHandleProps } from '@prosekit/web/resizable';
1
+ import type { ResizableHandleElement, ResizableHandleProps } from '@prosekit/web/resizable';
2
2
  import type { SvelteComponent } from 'svelte';
3
- export declare const ResizableHandle: typeof SvelteComponent<Partial<ResizableHandleProps> & {
4
- class?: string;
5
- }>;
3
+ import type { HTMLAttributes } from 'svelte/elements';
4
+ export declare const ResizableHandle: typeof SvelteComponent<Partial<ResizableHandleProps> & HTMLAttributes<ResizableHandleElement>>;
6
5
  //# sourceMappingURL=resizable-handle.gen.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"resizable-handle.gen.d.ts","sourceRoot":"","sources":["../../../../../src/components/resizable/resizable-handle.gen.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAA;AACnE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAA;AAI7C,eAAO,MAAM,eAAe,EAA+C,OAAO,eAAe,CAAC,OAAO,CAAC,oBAAoB,CAAC,GAAG;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAC,CAAC,CAAA"}
1
+ {"version":3,"file":"resizable-handle.gen.d.ts","sourceRoot":"","sources":["../../../../../src/components/resizable/resizable-handle.gen.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAA;AAC3F,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAA;AAC7C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAIrD,eAAO,MAAM,eAAe,EAAgB,OAAO,eAAe,CAAC,OAAO,CAAC,oBAAoB,CAAC,GAAG,cAAc,CAAC,sBAAsB,CAAC,CAAC,CAAA"}
@@ -1,14 +1,17 @@
1
1
  <script lang="ts">
2
2
  import '@prosekit/web/resizable'
3
3
  import { defaultResizableHandleProps } from '@prosekit/web/resizable'
4
+ import { useWebComponent } from '../../utils/use-web-component'
4
5
 
5
- import { useEditorContext } from '../../contexts/editor-context'
6
+ let attributes: Record<string, unknown> = {}
7
+ let element: HTMLElement | undefined = undefined
8
+ const handleChange = useWebComponent(defaultResizableHandleProps)
6
9
 
7
- const hasEditor = Object.hasOwn(defaultResizableHandleProps, 'editor')
8
- const editorContext = useEditorContext()
9
- const editor = hasEditor ? editorContext : undefined
10
+ $: {
11
+ attributes = handleChange(element, $$props)
12
+ }
10
13
  </script>
11
14
 
12
- <prosekit-resizable-handle {editor} {...$$props}>
15
+ <prosekit-resizable-handle {...attributes} bind:this={element}>
13
16
  <slot />
14
17
  </prosekit-resizable-handle>
@@ -1 +1 @@
1
- {"version":3,"file":"resizable-handle.gen.svelte.d.ts","sourceRoot":"","sources":["../../../../../src/components/resizable/resizable-handle.gen.svelte"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,QAAQ,CAE5C;AACD,OAAO,yBAAyB,CAAA;AAsBhC,QAAA,MAAM,SAAS;;;;;;;;;;CAA+D,CAAC;AAC/E,MAAM,MAAM,oBAAoB,GAAG,OAAO,SAAS,CAAC,KAAK,CAAC;AAC1D,MAAM,MAAM,qBAAqB,GAAG,OAAO,SAAS,CAAC,MAAM,CAAC;AAC5D,MAAM,MAAM,oBAAoB,GAAG,OAAO,SAAS,CAAC,KAAK,CAAC;AAE1D,MAAM,CAAC,OAAO,OAAO,eAAgB,SAAQ,oBAAoB,CAAC,oBAAoB,EAAE,qBAAqB,EAAE,oBAAoB,CAAC;CACnI"}
1
+ {"version":3,"file":"resizable-handle.gen.svelte.d.ts","sourceRoot":"","sources":["../../../../../src/components/resizable/resizable-handle.gen.svelte"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,QAAQ,CAE5C;AACD,OAAO,yBAAyB,CAAA;AAwBhC,QAAA,MAAM,SAAS;;;;;;;;;;CAA+D,CAAC;AAC/E,MAAM,MAAM,oBAAoB,GAAG,OAAO,SAAS,CAAC,KAAK,CAAC;AAC1D,MAAM,MAAM,qBAAqB,GAAG,OAAO,SAAS,CAAC,MAAM,CAAC;AAC5D,MAAM,MAAM,oBAAoB,GAAG,OAAO,SAAS,CAAC,KAAK,CAAC;AAE1D,MAAM,CAAC,OAAO,OAAO,eAAgB,SAAQ,oBAAoB,CAAC,oBAAoB,EAAE,qBAAqB,EAAE,oBAAoB,CAAC;CACnI"}
@@ -1,6 +1,5 @@
1
- import type { ResizableRootProps } from '@prosekit/web/resizable';
1
+ import type { ResizableRootElement, ResizableRootProps } from '@prosekit/web/resizable';
2
2
  import type { SvelteComponent } from 'svelte';
3
- export declare const ResizableRoot: typeof SvelteComponent<Partial<ResizableRootProps> & {
4
- class?: string;
5
- }>;
3
+ import type { HTMLAttributes } from 'svelte/elements';
4
+ export declare const ResizableRoot: typeof SvelteComponent<Partial<ResizableRootProps> & HTMLAttributes<ResizableRootElement>>;
6
5
  //# sourceMappingURL=resizable-root.gen.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"resizable-root.gen.d.ts","sourceRoot":"","sources":["../../../../../src/components/resizable/resizable-root.gen.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AACjE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAA;AAI7C,eAAO,MAAM,aAAa,EAA+C,OAAO,eAAe,CAAC,OAAO,CAAC,kBAAkB,CAAC,GAAG;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAC,CAAC,CAAA"}
1
+ {"version":3,"file":"resizable-root.gen.d.ts","sourceRoot":"","sources":["../../../../../src/components/resizable/resizable-root.gen.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AACvF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAA;AAC7C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAIrD,eAAO,MAAM,aAAa,EAAgB,OAAO,eAAe,CAAC,OAAO,CAAC,kBAAkB,CAAC,GAAG,cAAc,CAAC,oBAAoB,CAAC,CAAC,CAAA"}
@@ -1,14 +1,17 @@
1
1
  <script lang="ts">
2
2
  import '@prosekit/web/resizable'
3
3
  import { defaultResizableRootProps } from '@prosekit/web/resizable'
4
+ import { useWebComponent } from '../../utils/use-web-component'
4
5
 
5
- import { useEditorContext } from '../../contexts/editor-context'
6
+ let attributes: Record<string, unknown> = {}
7
+ let element: HTMLElement | undefined = undefined
8
+ const handleChange = useWebComponent(defaultResizableRootProps)
6
9
 
7
- const hasEditor = Object.hasOwn(defaultResizableRootProps, 'editor')
8
- const editorContext = useEditorContext()
9
- const editor = hasEditor ? editorContext : undefined
10
+ $: {
11
+ attributes = handleChange(element, $$props)
12
+ }
10
13
  </script>
11
14
 
12
- <prosekit-resizable-root {editor} {...$$props}>
15
+ <prosekit-resizable-root {...attributes} bind:this={element}>
13
16
  <slot />
14
17
  </prosekit-resizable-root>
@@ -1 +1 @@
1
- {"version":3,"file":"resizable-root.gen.svelte.d.ts","sourceRoot":"","sources":["../../../../../src/components/resizable/resizable-root.gen.svelte"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,QAAQ,CAE5C;AACD,OAAO,yBAAyB,CAAA;AAsBhC,QAAA,MAAM,SAAS;;;;;;;;;;CAA+D,CAAC;AAC/E,MAAM,MAAM,kBAAkB,GAAG,OAAO,SAAS,CAAC,KAAK,CAAC;AACxD,MAAM,MAAM,mBAAmB,GAAG,OAAO,SAAS,CAAC,MAAM,CAAC;AAC1D,MAAM,MAAM,kBAAkB,GAAG,OAAO,SAAS,CAAC,KAAK,CAAC;AAExD,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,oBAAoB,CAAC,kBAAkB,EAAE,mBAAmB,EAAE,kBAAkB,CAAC;CAC3H"}
1
+ {"version":3,"file":"resizable-root.gen.svelte.d.ts","sourceRoot":"","sources":["../../../../../src/components/resizable/resizable-root.gen.svelte"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,QAAQ,CAE5C;AACD,OAAO,yBAAyB,CAAA;AAwBhC,QAAA,MAAM,SAAS;;;;;;;;;;CAA+D,CAAC;AAC/E,MAAM,MAAM,kBAAkB,GAAG,OAAO,SAAS,CAAC,KAAK,CAAC;AACxD,MAAM,MAAM,mBAAmB,GAAG,OAAO,SAAS,CAAC,MAAM,CAAC;AAC1D,MAAM,MAAM,kBAAkB,GAAG,OAAO,SAAS,CAAC,KAAK,CAAC;AAExD,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,oBAAoB,CAAC,kBAAkB,EAAE,mBAAmB,EAAE,kBAAkB,CAAC;CAC3H"}
@@ -1,6 +1,5 @@
1
- import type { TooltipContentProps } from '@prosekit/web/tooltip';
1
+ import type { TooltipContentElement, TooltipContentProps } from '@prosekit/web/tooltip';
2
2
  import type { SvelteComponent } from 'svelte';
3
- export declare const TooltipContent: typeof SvelteComponent<Partial<TooltipContentProps> & {
4
- class?: string;
5
- }>;
3
+ import type { HTMLAttributes } from 'svelte/elements';
4
+ export declare const TooltipContent: typeof SvelteComponent<Partial<TooltipContentProps> & HTMLAttributes<TooltipContentElement>>;
6
5
  //# sourceMappingURL=tooltip-content.gen.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"tooltip-content.gen.d.ts","sourceRoot":"","sources":["../../../../../src/components/tooltip/tooltip-content.gen.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;AAChE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAA;AAI7C,eAAO,MAAM,cAAc,EAA+C,OAAO,eAAe,CAAC,OAAO,CAAC,mBAAmB,CAAC,GAAG;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAC,CAAC,CAAA"}
1
+ {"version":3,"file":"tooltip-content.gen.d.ts","sourceRoot":"","sources":["../../../../../src/components/tooltip/tooltip-content.gen.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;AACvF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAA;AAC7C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAIrD,eAAO,MAAM,cAAc,EAAgB,OAAO,eAAe,CAAC,OAAO,CAAC,mBAAmB,CAAC,GAAG,cAAc,CAAC,qBAAqB,CAAC,CAAC,CAAA"}
@@ -1,14 +1,17 @@
1
1
  <script lang="ts">
2
2
  import '@prosekit/web/tooltip'
3
3
  import { defaultTooltipContentProps } from '@prosekit/web/tooltip'
4
+ import { useWebComponent } from '../../utils/use-web-component'
4
5
 
5
- import { useEditorContext } from '../../contexts/editor-context'
6
+ let attributes: Record<string, unknown> = {}
7
+ let element: HTMLElement | undefined = undefined
8
+ const handleChange = useWebComponent(defaultTooltipContentProps)
6
9
 
7
- const hasEditor = Object.hasOwn(defaultTooltipContentProps, 'editor')
8
- const editorContext = useEditorContext()
9
- const editor = hasEditor ? editorContext : undefined
10
+ $: {
11
+ attributes = handleChange(element, $$props)
12
+ }
10
13
  </script>
11
14
 
12
- <prosekit-tooltip-content {editor} {...$$props}>
15
+ <prosekit-tooltip-content {...attributes} bind:this={element}>
13
16
  <slot />
14
17
  </prosekit-tooltip-content>
@@ -1 +1 @@
1
- {"version":3,"file":"tooltip-content.gen.svelte.d.ts","sourceRoot":"","sources":["../../../../../src/components/tooltip/tooltip-content.gen.svelte"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,QAAQ,CAE5C;AACD,OAAO,uBAAuB,CAAA;AAsB9B,QAAA,MAAM,SAAS;;;;;;;;;;CAA+D,CAAC;AAC/E,MAAM,MAAM,mBAAmB,GAAG,OAAO,SAAS,CAAC,KAAK,CAAC;AACzD,MAAM,MAAM,oBAAoB,GAAG,OAAO,SAAS,CAAC,MAAM,CAAC;AAC3D,MAAM,MAAM,mBAAmB,GAAG,OAAO,SAAS,CAAC,KAAK,CAAC;AAEzD,MAAM,CAAC,OAAO,OAAO,cAAe,SAAQ,oBAAoB,CAAC,mBAAmB,EAAE,oBAAoB,EAAE,mBAAmB,CAAC;CAC/H"}
1
+ {"version":3,"file":"tooltip-content.gen.svelte.d.ts","sourceRoot":"","sources":["../../../../../src/components/tooltip/tooltip-content.gen.svelte"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,QAAQ,CAE5C;AACD,OAAO,uBAAuB,CAAA;AAwB9B,QAAA,MAAM,SAAS;;;;;;;;;;CAA+D,CAAC;AAC/E,MAAM,MAAM,mBAAmB,GAAG,OAAO,SAAS,CAAC,KAAK,CAAC;AACzD,MAAM,MAAM,oBAAoB,GAAG,OAAO,SAAS,CAAC,MAAM,CAAC;AAC3D,MAAM,MAAM,mBAAmB,GAAG,OAAO,SAAS,CAAC,KAAK,CAAC;AAEzD,MAAM,CAAC,OAAO,OAAO,cAAe,SAAQ,oBAAoB,CAAC,mBAAmB,EAAE,oBAAoB,EAAE,mBAAmB,CAAC;CAC/H"}
@@ -1,6 +1,5 @@
1
- import type { TooltipRootProps } from '@prosekit/web/tooltip';
1
+ import type { TooltipRootElement, TooltipRootProps } from '@prosekit/web/tooltip';
2
2
  import type { SvelteComponent } from 'svelte';
3
- export declare const TooltipRoot: typeof SvelteComponent<Partial<TooltipRootProps> & {
4
- class?: string;
5
- }>;
3
+ import type { HTMLAttributes } from 'svelte/elements';
4
+ export declare const TooltipRoot: typeof SvelteComponent<Partial<TooltipRootProps> & HTMLAttributes<TooltipRootElement>>;
6
5
  //# sourceMappingURL=tooltip-root.gen.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"tooltip-root.gen.d.ts","sourceRoot":"","sources":["../../../../../src/components/tooltip/tooltip-root.gen.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AAC7D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAA;AAI7C,eAAO,MAAM,WAAW,EAA+C,OAAO,eAAe,CAAC,OAAO,CAAC,gBAAgB,CAAC,GAAG;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAC,CAAC,CAAA"}
1
+ {"version":3,"file":"tooltip-root.gen.d.ts","sourceRoot":"","sources":["../../../../../src/components/tooltip/tooltip-root.gen.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AACjF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAA;AAC7C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAIrD,eAAO,MAAM,WAAW,EAAgB,OAAO,eAAe,CAAC,OAAO,CAAC,gBAAgB,CAAC,GAAG,cAAc,CAAC,kBAAkB,CAAC,CAAC,CAAA"}
@@ -1,14 +1,17 @@
1
1
  <script lang="ts">
2
2
  import '@prosekit/web/tooltip'
3
3
  import { defaultTooltipRootProps } from '@prosekit/web/tooltip'
4
+ import { useWebComponent } from '../../utils/use-web-component'
4
5
 
5
- import { useEditorContext } from '../../contexts/editor-context'
6
+ let attributes: Record<string, unknown> = {}
7
+ let element: HTMLElement | undefined = undefined
8
+ const handleChange = useWebComponent(defaultTooltipRootProps)
6
9
 
7
- const hasEditor = Object.hasOwn(defaultTooltipRootProps, 'editor')
8
- const editorContext = useEditorContext()
9
- const editor = hasEditor ? editorContext : undefined
10
+ $: {
11
+ attributes = handleChange(element, $$props)
12
+ }
10
13
  </script>
11
14
 
12
- <prosekit-tooltip-root {editor} {...$$props}>
15
+ <prosekit-tooltip-root {...attributes} bind:this={element}>
13
16
  <slot />
14
17
  </prosekit-tooltip-root>
@@ -1 +1 @@
1
- {"version":3,"file":"tooltip-root.gen.svelte.d.ts","sourceRoot":"","sources":["../../../../../src/components/tooltip/tooltip-root.gen.svelte"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,QAAQ,CAE5C;AACD,OAAO,uBAAuB,CAAA;AAsB9B,QAAA,MAAM,SAAS;;;;;;;;;;CAA+D,CAAC;AAC/E,MAAM,MAAM,gBAAgB,GAAG,OAAO,SAAS,CAAC,KAAK,CAAC;AACtD,MAAM,MAAM,iBAAiB,GAAG,OAAO,SAAS,CAAC,MAAM,CAAC;AACxD,MAAM,MAAM,gBAAgB,GAAG,OAAO,SAAS,CAAC,KAAK,CAAC;AAEtD,MAAM,CAAC,OAAO,OAAO,WAAY,SAAQ,oBAAoB,CAAC,gBAAgB,EAAE,iBAAiB,EAAE,gBAAgB,CAAC;CACnH"}
1
+ {"version":3,"file":"tooltip-root.gen.svelte.d.ts","sourceRoot":"","sources":["../../../../../src/components/tooltip/tooltip-root.gen.svelte"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,QAAQ,CAE5C;AACD,OAAO,uBAAuB,CAAA;AAwB9B,QAAA,MAAM,SAAS;;;;;;;;;;CAA+D,CAAC;AAC/E,MAAM,MAAM,gBAAgB,GAAG,OAAO,SAAS,CAAC,KAAK,CAAC;AACtD,MAAM,MAAM,iBAAiB,GAAG,OAAO,SAAS,CAAC,MAAM,CAAC;AACxD,MAAM,MAAM,gBAAgB,GAAG,OAAO,SAAS,CAAC,KAAK,CAAC;AAEtD,MAAM,CAAC,OAAO,OAAO,WAAY,SAAQ,oBAAoB,CAAC,gBAAgB,EAAE,iBAAiB,EAAE,gBAAgB,CAAC;CACnH"}
@@ -1,6 +1,5 @@
1
- import type { TooltipTriggerProps } from '@prosekit/web/tooltip';
1
+ import type { TooltipTriggerElement, TooltipTriggerProps } from '@prosekit/web/tooltip';
2
2
  import type { SvelteComponent } from 'svelte';
3
- export declare const TooltipTrigger: typeof SvelteComponent<Partial<TooltipTriggerProps> & {
4
- class?: string;
5
- }>;
3
+ import type { HTMLAttributes } from 'svelte/elements';
4
+ export declare const TooltipTrigger: typeof SvelteComponent<Partial<TooltipTriggerProps> & HTMLAttributes<TooltipTriggerElement>>;
6
5
  //# sourceMappingURL=tooltip-trigger.gen.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"tooltip-trigger.gen.d.ts","sourceRoot":"","sources":["../../../../../src/components/tooltip/tooltip-trigger.gen.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;AAChE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAA;AAI7C,eAAO,MAAM,cAAc,EAA+C,OAAO,eAAe,CAAC,OAAO,CAAC,mBAAmB,CAAC,GAAG;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAC,CAAC,CAAA"}
1
+ {"version":3,"file":"tooltip-trigger.gen.d.ts","sourceRoot":"","sources":["../../../../../src/components/tooltip/tooltip-trigger.gen.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;AACvF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAA;AAC7C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAIrD,eAAO,MAAM,cAAc,EAAgB,OAAO,eAAe,CAAC,OAAO,CAAC,mBAAmB,CAAC,GAAG,cAAc,CAAC,qBAAqB,CAAC,CAAC,CAAA"}
@@ -1,14 +1,17 @@
1
1
  <script lang="ts">
2
2
  import '@prosekit/web/tooltip'
3
3
  import { defaultTooltipTriggerProps } from '@prosekit/web/tooltip'
4
+ import { useWebComponent } from '../../utils/use-web-component'
4
5
 
5
- import { useEditorContext } from '../../contexts/editor-context'
6
+ let attributes: Record<string, unknown> = {}
7
+ let element: HTMLElement | undefined = undefined
8
+ const handleChange = useWebComponent(defaultTooltipTriggerProps)
6
9
 
7
- const hasEditor = Object.hasOwn(defaultTooltipTriggerProps, 'editor')
8
- const editorContext = useEditorContext()
9
- const editor = hasEditor ? editorContext : undefined
10
+ $: {
11
+ attributes = handleChange(element, $$props)
12
+ }
10
13
  </script>
11
14
 
12
- <prosekit-tooltip-trigger {editor} {...$$props}>
15
+ <prosekit-tooltip-trigger {...attributes} bind:this={element}>
13
16
  <slot />
14
17
  </prosekit-tooltip-trigger>
@@ -1 +1 @@
1
- {"version":3,"file":"tooltip-trigger.gen.svelte.d.ts","sourceRoot":"","sources":["../../../../../src/components/tooltip/tooltip-trigger.gen.svelte"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,QAAQ,CAE5C;AACD,OAAO,uBAAuB,CAAA;AAsB9B,QAAA,MAAM,SAAS;;;;;;;;;;CAA+D,CAAC;AAC/E,MAAM,MAAM,mBAAmB,GAAG,OAAO,SAAS,CAAC,KAAK,CAAC;AACzD,MAAM,MAAM,oBAAoB,GAAG,OAAO,SAAS,CAAC,MAAM,CAAC;AAC3D,MAAM,MAAM,mBAAmB,GAAG,OAAO,SAAS,CAAC,KAAK,CAAC;AAEzD,MAAM,CAAC,OAAO,OAAO,cAAe,SAAQ,oBAAoB,CAAC,mBAAmB,EAAE,oBAAoB,EAAE,mBAAmB,CAAC;CAC/H"}
1
+ {"version":3,"file":"tooltip-trigger.gen.svelte.d.ts","sourceRoot":"","sources":["../../../../../src/components/tooltip/tooltip-trigger.gen.svelte"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,QAAQ,CAE5C;AACD,OAAO,uBAAuB,CAAA;AAwB9B,QAAA,MAAM,SAAS;;;;;;;;;;CAA+D,CAAC;AAC/E,MAAM,MAAM,mBAAmB,GAAG,OAAO,SAAS,CAAC,KAAK,CAAC;AACzD,MAAM,MAAM,oBAAoB,GAAG,OAAO,SAAS,CAAC,MAAM,CAAC;AAC3D,MAAM,MAAM,mBAAmB,GAAG,OAAO,SAAS,CAAC,KAAK,CAAC;AAEzD,MAAM,CAAC,OAAO,OAAO,cAAe,SAAQ,oBAAoB,CAAC,mBAAmB,EAAE,oBAAoB,EAAE,mBAAmB,CAAC;CAC/H"}
@@ -6,5 +6,5 @@ export declare function setEditorContext(editor: Editor): void;
6
6
  /**
7
7
  * @internal
8
8
  */
9
- export declare function useEditorContext<E extends Extension>(): Editor<E> | null;
9
+ export declare function useEditorContext<E extends Extension>(): Editor<E> | void;
10
10
  //# sourceMappingURL=editor-context.d.ts.map
@@ -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,IAAI,CAKxE"}
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,IAAI,CAIxE"}
@@ -14,8 +14,7 @@ export function setEditorContext(editor) {
14
14
  * @internal
15
15
  */
16
16
  export function useEditorContext() {
17
- if (!hasContext(key)) {
18
- return null;
17
+ if (hasContext(key)) {
18
+ return getContext(key);
19
19
  }
20
- return getContext(key);
21
20
  }
@@ -1 +1 @@
1
- {"version":3,"file":"use-editor-extension.d.ts","sourceRoot":"","sources":["../../../../src/hooks/use-editor-extension.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAuB,KAAK,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAE5E,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,cAAc,CAAA;AAI5C;;GAEG;AACH,wBAAgB,kBAAkB,CAChC,WAAW,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EACtC,cAAc,EAAE,QAAQ,CAAC,SAAS,GAAG,IAAI,CAAC,QAyB3C"}
1
+ {"version":3,"file":"use-editor-extension.d.ts","sourceRoot":"","sources":["../../../../src/hooks/use-editor-extension.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAuB,KAAK,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAE5E,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,cAAc,CAAA;AAI5C;;GAEG;AACH,wBAAgB,kBAAkB,CAChC,WAAW,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EACtC,cAAc,EAAE,QAAQ,CAAC,SAAS,GAAG,IAAI,CAAC,QA6B3C"}
@@ -1,5 +1,5 @@
1
1
  import { Editor, EditorNotFoundError } from '@prosekit/core';
2
- import { onDestroy } from 'svelte';
2
+ import { onMount } from 'svelte';
3
3
  import {} from 'svelte/store';
4
4
  import { useEditorContext } from '../contexts/editor-context';
5
5
  /**
@@ -7,21 +7,25 @@ import { useEditorContext } from '../contexts/editor-context';
7
7
  */
8
8
  export function useEditorExtension(maybeEditor, extensionStore) {
9
9
  const editorContext = useEditorContext();
10
- let cleanup;
11
- const unsubscribe = extensionStore.subscribe((extension) => {
12
- cleanup === null || cleanup === void 0 ? void 0 : cleanup();
13
- cleanup = undefined;
14
- const editor = maybeEditor || editorContext;
15
- if (!editor) {
16
- throw new EditorNotFoundError();
17
- }
18
- if (extension) {
19
- cleanup = editor.use(extension);
20
- }
21
- });
22
- onDestroy(() => {
23
- cleanup === null || cleanup === void 0 ? void 0 : cleanup();
24
- cleanup = undefined;
25
- unsubscribe();
10
+ onMount(() => {
11
+ let cleanup;
12
+ let unsubscribe;
13
+ unsubscribe = extensionStore.subscribe((extension) => {
14
+ cleanup === null || cleanup === void 0 ? void 0 : cleanup();
15
+ cleanup = undefined;
16
+ const editor = maybeEditor || editorContext;
17
+ if (!editor) {
18
+ throw new EditorNotFoundError();
19
+ }
20
+ if (extension) {
21
+ cleanup = editor.use(extension);
22
+ }
23
+ });
24
+ return () => {
25
+ cleanup === null || cleanup === void 0 ? void 0 : cleanup();
26
+ cleanup = undefined;
27
+ unsubscribe === null || unsubscribe === void 0 ? void 0 : unsubscribe();
28
+ unsubscribe = undefined;
29
+ };
26
30
  });
27
31
  }
@@ -1 +1 @@
1
- {"version":3,"file":"use-editor.d.ts","sourceRoot":"","sources":["../../../../src/hooks/use-editor.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,MAAM,EACX,KAAK,SAAS,EAEf,MAAM,gBAAgB,CAAA;AAEvB,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,CA2BtB"}
1
+ {"version":3,"file":"use-editor.d.ts","sourceRoot":"","sources":["../../../../src/hooks/use-editor.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,MAAM,EACX,KAAK,SAAS,EACf,MAAM,gBAAgB,CAAA;AAEvB,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,CA0BtB"}
@@ -1,5 +1,5 @@
1
- import { defineMountHandler, defineUpdateHandler, union, ProseKitError, } from '@prosekit/core';
2
- import { onDestroy, onMount } from 'svelte';
1
+ import { ProseKitError, defineMountHandler, defineUpdateHandler, union, } from '@prosekit/core';
2
+ import { onMount } from 'svelte';
3
3
  import { readonly, writable } from 'svelte/store';
4
4
  import { useEditorContext } from '../contexts/editor-context';
5
5
  /**
@@ -24,8 +24,7 @@ export function useEditor(options) {
24
24
  defineMountHandler(forceUpdate),
25
25
  defineUpdateHandler(forceUpdate),
26
26
  ]);
27
- const dispose = editor.use(extension);
28
- onDestroy(dispose);
27
+ return editor.use(extension);
29
28
  });
30
29
  }
31
30
  return readonly(editorStore);
@@ -1,8 +1,10 @@
1
- export { ProseKit } from './components/prosekit';
1
+ export { ProseKit, type ProseKitProps } from './components/prosekit';
2
+ export { useDocChange } from './hooks/use-doc-change';
2
3
  export { useEditor } from './hooks/use-editor';
3
4
  export { useExtension, type UseExtensionOptions } from './hooks/use-extension';
4
5
  export { useKeymap } from './hooks/use-keymap';
5
6
  export { useStateUpdate } from './hooks/use-state-update';
6
- export { useDocChange } from './hooks/use-doc-change';
7
+ export { defineSvelteNodeView } from './node-view/define-svelte-node-view';
8
+ export type { SvelteNodeViewComponent, SvelteNodeViewOptions, SvelteNodeViewProps, } from './node-view/types';
7
9
  export type { PropsWithClass } from './types';
8
10
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAC9C,OAAO,EAAE,YAAY,EAAE,KAAK,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;AAC9E,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAA;AACrD,YAAY,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,KAAK,aAAa,EAAE,MAAM,uBAAuB,CAAA;AACpE,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAA;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAC9C,OAAO,EAAE,YAAY,EAAE,KAAK,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;AAC9E,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AACzD,OAAO,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAA;AAC1E,YAAY,EACV,uBAAuB,EACvB,qBAAqB,EACrB,mBAAmB,GACpB,MAAM,mBAAmB,CAAA;AAC1B,YAAY,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA"}
@@ -1,6 +1,7 @@
1
1
  export { ProseKit } from './components/prosekit';
2
+ export { useDocChange } from './hooks/use-doc-change';
2
3
  export { useEditor } from './hooks/use-editor';
3
4
  export { useExtension } from './hooks/use-extension';
4
5
  export { useKeymap } from './hooks/use-keymap';
5
6
  export { useStateUpdate } from './hooks/use-state-update';
6
- export { useDocChange } from './hooks/use-doc-change';
7
+ export { defineSvelteNodeView } from './node-view/define-svelte-node-view';
@@ -0,0 +1,4 @@
1
+ import type { NodeViewConstructor } from '@prosekit/pm/view';
2
+ import type { SvelteNodeViewUserOptions } from '@prosemirror-adapter/svelte';
3
+ export declare function defineSvelteNodeViewFactory(factory: (options: SvelteNodeViewUserOptions) => NodeViewConstructor): import("@prosekit/core").Extension<import("@prosekit/core").ExtensionTyping<any, any, any>>;
4
+ //# sourceMappingURL=define-svelte-node-view-factory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"define-svelte-node-view-factory.d.ts","sourceRoot":"","sources":["../../../../src/node-view/define-svelte-node-view-factory.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAA;AAC5D,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAA;AAE5E,wBAAgB,2BAA2B,CACzC,OAAO,EAAE,CAAC,OAAO,EAAE,yBAAyB,KAAK,mBAAmB,+FAMrE"}
@@ -0,0 +1,7 @@
1
+ import { defineNodeViewFactory } from '@prosekit/core';
2
+ export function defineSvelteNodeViewFactory(factory) {
3
+ return defineNodeViewFactory({
4
+ group: 'svelte',
5
+ factory,
6
+ });
7
+ }
@@ -0,0 +1,9 @@
1
+ import { type Extension } from '@prosekit/core';
2
+ import type { SvelteNodeViewOptions } from './types';
3
+ /**
4
+ * Defines a node view using a Svelte component.
5
+ *
6
+ * @public
7
+ */
8
+ export declare function defineSvelteNodeView(options: SvelteNodeViewOptions): Extension;
9
+ //# sourceMappingURL=define-svelte-node-view.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"define-svelte-node-view.d.ts","sourceRoot":"","sources":["../../../../src/node-view/define-svelte-node-view.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2B,KAAK,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAMxE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AAEpD;;;;GAIG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,qBAAqB,GAC7B,SAAS,CAoBX"}
@@ -0,0 +1,26 @@
1
+ import { defineNodeViewComponent } from '@prosekit/core';
2
+ import { NodeViewWrapper } from '../components/node-view-wrapper';
3
+ /**
4
+ * Defines a node view using a Svelte component.
5
+ *
6
+ * @public
7
+ */
8
+ export function defineSvelteNodeView(options) {
9
+ const { name, component, ...userOptions } = options;
10
+ const args = {
11
+ ...userOptions,
12
+ component: class NodeViewPropsWrapper extends NodeViewWrapper {
13
+ constructor(options) {
14
+ super({
15
+ ...options,
16
+ props: { ...options.props, component },
17
+ });
18
+ }
19
+ },
20
+ };
21
+ return defineNodeViewComponent({
22
+ group: 'svelte',
23
+ name,
24
+ args,
25
+ });
26
+ }
@@ -0,0 +1,38 @@
1
+ import type { BaseNodeViewOptions } from '@prosekit/core';
2
+ import type { Attrs, ProseMirrorNode } from '@prosekit/pm/model';
3
+ import type { Decoration, DecorationSource, EditorView } from '@prosekit/pm/view';
4
+ import type { ComponentType, SvelteComponent } from 'svelte';
5
+ import type { Writable } from 'svelte/store';
6
+ /**
7
+ * @public
8
+ */
9
+ export interface SvelteNodeViewProps {
10
+ contentRef: (node: HTMLElement | null) => void;
11
+ view: EditorView;
12
+ getPos: () => number | undefined;
13
+ setAttrs: (attrs: Attrs) => void;
14
+ node: Writable<ProseMirrorNode>;
15
+ selected: Writable<boolean>;
16
+ decorations: Writable<readonly Decoration[]>;
17
+ innerDecorations: Writable<DecorationSource>;
18
+ }
19
+ /**
20
+ * @public
21
+ */
22
+ export type SvelteNodeViewComponent = ComponentType<SvelteComponent<SvelteNodeViewProps>>;
23
+ /**
24
+ * Options for {@link defineSvelteNodeView}.
25
+ *
26
+ * @public
27
+ */
28
+ export interface SvelteNodeViewOptions extends BaseNodeViewOptions {
29
+ /**
30
+ * The name of the node type.
31
+ */
32
+ name: string;
33
+ /**
34
+ * The Svelte component to render the node.
35
+ */
36
+ component: SvelteNodeViewComponent;
37
+ }
38
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/node-view/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAA;AACzD,OAAO,KAAK,EAAE,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AAChE,OAAO,KAAK,EACV,UAAU,EACV,gBAAgB,EAChB,UAAU,EACX,MAAM,mBAAmB,CAAA;AAC1B,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAA;AAC5D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AAE5C;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAElC,UAAU,EAAE,CAAC,IAAI,EAAE,WAAW,GAAG,IAAI,KAAK,IAAI,CAAA;IAC9C,IAAI,EAAE,UAAU,CAAA;IAChB,MAAM,EAAE,MAAM,MAAM,GAAG,SAAS,CAAA;IAChC,QAAQ,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAA;IAGhC,IAAI,EAAE,QAAQ,CAAC,eAAe,CAAC,CAAA;IAC/B,QAAQ,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAA;IAC3B,WAAW,EAAE,QAAQ,CAAC,SAAS,UAAU,EAAE,CAAC,CAAA;IAC5C,gBAAgB,EAAE,QAAQ,CAAC,gBAAgB,CAAC,CAAA;CAC7C;AAED;;GAEG;AACH,MAAM,MAAM,uBAAuB,GAAG,aAAa,CACjD,eAAe,CAAC,mBAAmB,CAAC,CACrC,CAAA;AAED;;;;GAIG;AACH,MAAM,WAAW,qBAAsB,SAAQ,mBAAmB;IAChE;;OAEG;IACH,IAAI,EAAE,MAAM,CAAA;IAEZ;;OAEG;IACH,SAAS,EAAE,uBAAuB,CAAA;CACnC"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ export declare function useWebComponent(defaultProps: Readonly<Record<string, unknown>>): (element: HTMLElement | undefined, $$props: Record<string, unknown>) => Record<string, unknown>;
2
+ //# sourceMappingURL=use-web-component.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-web-component.d.ts","sourceRoot":"","sources":["../../../../src/utils/use-web-component.ts"],"names":[],"mappings":"AAMA,wBAAgB,eAAe,CAC7B,YAAY,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,aAQpC,WAAW,GAAG,SAAS,WACvB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,6BA6BnC"}
@@ -0,0 +1,36 @@
1
+ import { useEditorContext } from '../contexts/editor-context';
2
+ // For unknown reason, Svelte v4 cannot set properties on a web component
3
+ // when I directly use `{...$$props}`. It seems that Svelte v4 recognizes
4
+ // the properties as attributes. Here is a workaround to set the properties
5
+ // on the element manually and only let Svelte set the attributes.
6
+ export function useWebComponent(defaultProps) {
7
+ const propertyNames = Object.keys(defaultProps);
8
+ const hasEditor = propertyNames.includes('editor');
9
+ const editorContext = useEditorContext();
10
+ function handleChange(element, $$props) {
11
+ const properties = {};
12
+ const attributes = {};
13
+ for (const [key, value] of Object.entries($$props)) {
14
+ if (value === undefined || key.startsWith('$')) {
15
+ continue;
16
+ }
17
+ else if (propertyNames.includes(key)) {
18
+ properties[key] = value;
19
+ }
20
+ else {
21
+ attributes[key] = value;
22
+ }
23
+ }
24
+ if (hasEditor && !properties.editor && editorContext) {
25
+ properties.editor = editorContext;
26
+ }
27
+ if (element) {
28
+ for (const [key, value] of Object.entries(properties)) {
29
+ ;
30
+ element[key] = value;
31
+ }
32
+ }
33
+ return attributes;
34
+ }
35
+ return handleChange;
36
+ }