@prosekit/svelte 0.6.0 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/build/components/mark-view-consumer/index.d.ts +6 -0
- package/dist/build/components/mark-view-consumer/index.d.ts.map +1 -0
- package/dist/build/components/mark-view-consumer/index.js +5 -0
- package/dist/build/components/mark-view-consumer/mark-view-consumer.svelte +15 -0
- package/dist/build/components/mark-view-consumer/mark-view-consumer.svelte.d.ts +21 -0
- package/dist/build/components/mark-view-consumer/mark-view-consumer.svelte.d.ts.map +1 -0
- package/dist/build/components/mark-view-wrapper/index.d.ts +4 -0
- package/dist/build/components/mark-view-wrapper/index.d.ts.map +1 -0
- package/dist/build/components/mark-view-wrapper/index.js +2 -0
- package/dist/build/components/mark-view-wrapper/mark-view-wrapper.svelte +17 -0
- package/dist/build/components/mark-view-wrapper/mark-view-wrapper.svelte.d.ts +5 -0
- package/dist/build/components/mark-view-wrapper/mark-view-wrapper.svelte.d.ts.map +1 -0
- package/dist/build/components/mark-view-wrapper/props.d.ts +6 -0
- package/dist/build/components/mark-view-wrapper/props.d.ts.map +1 -0
- package/dist/build/components/node-view-consumer/node-view-consumer.svelte +1 -1
- package/dist/build/components/node-view-wrapper/node-view-wrapper.svelte +1 -1
- package/dist/build/components/node-view-wrapper/node-view-wrapper.svelte.d.ts +1 -0
- package/dist/build/components/node-view-wrapper/node-view-wrapper.svelte.d.ts.map +1 -1
- package/dist/build/components/node-view-wrapper/props.d.ts +1 -1
- package/dist/build/components/node-view-wrapper/props.d.ts.map +1 -1
- package/dist/build/components/prosekit/prosekit.svelte +2 -0
- package/dist/build/components/prosekit/prosekit.svelte.d.ts.map +1 -1
- package/dist/build/extensions/svelte-mark-view.d.ts +33 -0
- package/dist/build/extensions/svelte-mark-view.d.ts.map +1 -0
- package/dist/build/extensions/svelte-mark-view.js +40 -0
- package/dist/build/extensions/svelte-node-view.d.ts +33 -0
- package/dist/build/extensions/svelte-node-view.d.ts.map +1 -0
- package/dist/build/{node-view/define-svelte-node-view.js → extensions/svelte-node-view.js} +7 -1
- package/dist/build/index.d.ts +2 -2
- package/dist/build/index.d.ts.map +1 -1
- package/dist/build/index.js +2 -1
- package/package.json +8 -7
- package/dist/build/node-view/define-svelte-node-view-factory.d.ts +0 -4
- package/dist/build/node-view/define-svelte-node-view-factory.d.ts.map +0 -1
- package/dist/build/node-view/define-svelte-node-view-factory.js +0 -7
- package/dist/build/node-view/define-svelte-node-view.d.ts +0 -9
- package/dist/build/node-view/define-svelte-node-view.d.ts.map +0 -1
- package/dist/build/node-view/types.d.ts +0 -38
- package/dist/build/node-view/types.d.ts.map +0 -1
- /package/dist/build/{node-view/types.js → components/mark-view-wrapper/props.js} +0 -0
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/mark-view-consumer/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAA;AAIvC;;GAEG;AACH,eAAO,MAAM,gBAAgB,EAAW,SAAS,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAA"}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<script lang="ts">
|
2
|
+
import {
|
3
|
+
useMarkViewFactory,
|
4
|
+
type MarkViewFactory,
|
5
|
+
} from '@prosemirror-adapter/svelte'
|
6
|
+
import { readable } from 'svelte/store'
|
7
|
+
import { defineSvelteMarkViewFactory } from '../../extensions/svelte-mark-view'
|
8
|
+
import { useExtension } from '../../hooks/use-extension'
|
9
|
+
|
10
|
+
const markViewFactory: MarkViewFactory = useMarkViewFactory()
|
11
|
+
const extension = defineSvelteMarkViewFactory(markViewFactory)
|
12
|
+
useExtension(readable(extension))
|
13
|
+
</script>
|
14
|
+
|
15
|
+
<slot />
|
@@ -0,0 +1,21 @@
|
|
1
|
+
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> {
|
2
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
3
|
+
$$bindings?: Bindings;
|
4
|
+
} & Exports;
|
5
|
+
(internal: unknown, props: {
|
6
|
+
$$events?: Events;
|
7
|
+
$$slots?: Slots;
|
8
|
+
}): Exports & {
|
9
|
+
$set?: any;
|
10
|
+
$on?: any;
|
11
|
+
};
|
12
|
+
z_$$bindings?: Bindings;
|
13
|
+
}
|
14
|
+
declare const MarkViewConsumer: $$__sveltets_2_IsomorphicComponent<any, {
|
15
|
+
[evt: string]: CustomEvent<any>;
|
16
|
+
}, {
|
17
|
+
default: {};
|
18
|
+
}, {}, string>;
|
19
|
+
type MarkViewConsumer = InstanceType<typeof MarkViewConsumer>;
|
20
|
+
export default MarkViewConsumer;
|
21
|
+
//# sourceMappingURL=mark-view-consumer.svelte.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"mark-view-consumer.svelte.d.ts","sourceRoot":"","sources":["../../../../../src/components/mark-view-consumer/mark-view-consumer.svelte.ts"],"names":[],"mappings":"AA0BA,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;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;IACtG,YAAY,CAAC,EAAE,QAAQ,CAAC;CAC3B;AAUD,QAAA,MAAM,gBAAgB;;;;cAAmF,CAAC;AACxF,KAAK,gBAAgB,GAAG,YAAY,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAChE,eAAe,gBAAgB,CAAC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/mark-view-wrapper/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAA;AAGvC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAA;AAEnD,eAAO,MAAM,eAAe,EAAW,SAAS,CAAC,oBAAoB,CAAC,CAAA"}
|
@@ -0,0 +1,17 @@
|
|
1
|
+
<script lang="ts">
|
2
|
+
import { useMarkViewContext } from '@prosemirror-adapter/svelte'
|
3
|
+
import type { SvelteMarkViewProps } from '../../extensions/svelte-mark-view'
|
4
|
+
import type { MarkViewWrapperProps } from './props'
|
5
|
+
|
6
|
+
const { component: MarkViewComponent }: MarkViewWrapperProps = $props()
|
7
|
+
|
8
|
+
const markViewProps: SvelteMarkViewProps = {
|
9
|
+
contentRef: useMarkViewContext('contentRef'),
|
10
|
+
view: useMarkViewContext('view'),
|
11
|
+
mark: useMarkViewContext('mark'),
|
12
|
+
}
|
13
|
+
</script>
|
14
|
+
|
15
|
+
{#if MarkViewComponent}
|
16
|
+
<MarkViewComponent {...markViewProps} />
|
17
|
+
{/if}
|
@@ -0,0 +1,5 @@
|
|
1
|
+
import type { MarkViewWrapperProps } from './props';
|
2
|
+
declare const MarkViewWrapper: import("svelte").Component<MarkViewWrapperProps, {}, "">;
|
3
|
+
type MarkViewWrapper = ReturnType<typeof MarkViewWrapper>;
|
4
|
+
export default MarkViewWrapper;
|
5
|
+
//# sourceMappingURL=mark-view-wrapper.svelte.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"mark-view-wrapper.svelte.d.ts","sourceRoot":"","sources":["../../../../../src/components/mark-view-wrapper/mark-view-wrapper.svelte.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAsBpD,QAAA,MAAM,eAAe,0DAAsC,CAAC;AAC5D,KAAK,eAAe,GAAG,UAAU,CAAC,OAAO,eAAe,CAAC,CAAC;AAC1D,eAAe,eAAe,CAAC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"props.d.ts","sourceRoot":"","sources":["../../../../../src/components/mark-view-wrapper/props.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAA;AAEvC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAA;AAE5E,MAAM,WAAW,oBAAoB;IACnC,SAAS,CAAC,EAAE,SAAS,CAAC,mBAAmB,CAAC,CAAA;CAC3C"}
|
@@ -4,8 +4,8 @@ import {
|
|
4
4
|
type NodeViewFactory,
|
5
5
|
} from '@prosemirror-adapter/svelte'
|
6
6
|
import { readable } from 'svelte/store'
|
7
|
+
import { defineSvelteNodeViewFactory } from '../../extensions/svelte-node-view'
|
7
8
|
import { useExtension } from '../../hooks/use-extension'
|
8
|
-
import { defineSvelteNodeViewFactory } from '../../node-view/define-svelte-node-view-factory'
|
9
9
|
|
10
10
|
const nodeViewFactory: NodeViewFactory = useNodeViewFactory()
|
11
11
|
const extension = defineSvelteNodeViewFactory(nodeViewFactory)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
<script lang="ts">
|
2
2
|
import { useNodeViewContext } from '@prosemirror-adapter/svelte'
|
3
|
-
import type { SvelteNodeViewProps } from '../../node-view
|
3
|
+
import type { SvelteNodeViewProps } from '../../extensions/svelte-node-view'
|
4
4
|
import type { NodeViewWrapperProps } from './props'
|
5
5
|
|
6
6
|
const { component: NodeViewComponent }: NodeViewWrapperProps = $props()
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import type { NodeViewWrapperProps } from './props';
|
2
2
|
declare const NodeViewWrapper: import("svelte").Component<NodeViewWrapperProps, {}, "">;
|
3
|
+
type NodeViewWrapper = ReturnType<typeof NodeViewWrapper>;
|
3
4
|
export default NodeViewWrapper;
|
4
5
|
//# sourceMappingURL=node-view-wrapper.svelte.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"node-view-wrapper.svelte.d.ts","sourceRoot":"","sources":["../../../../../src/components/node-view-wrapper/node-view-wrapper.svelte.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,SAAS,
|
1
|
+
{"version":3,"file":"node-view-wrapper.svelte.d.ts","sourceRoot":"","sources":["../../../../../src/components/node-view-wrapper/node-view-wrapper.svelte.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AA2BpD,QAAA,MAAM,eAAe,0DAAsC,CAAC;AAC5D,KAAK,eAAe,GAAG,UAAU,CAAC,OAAO,eAAe,CAAC,CAAC;AAC1D,eAAe,eAAe,CAAC"}
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import type { Component } from 'svelte';
|
2
|
-
import type { SvelteNodeViewProps } from '../../node-view
|
2
|
+
import type { SvelteNodeViewProps } from '../../extensions/svelte-node-view';
|
3
3
|
export interface NodeViewWrapperProps {
|
4
4
|
component?: Component<SvelteNodeViewProps>;
|
5
5
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"props.d.ts","sourceRoot":"","sources":["../../../../../src/components/node-view-wrapper/props.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAA;AAEvC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,
|
1
|
+
{"version":3,"file":"props.d.ts","sourceRoot":"","sources":["../../../../../src/components/node-view-wrapper/props.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAA;AAEvC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAA;AAE5E,MAAM,WAAW,oBAAoB;IACnC,SAAS,CAAC,EAAE,SAAS,CAAC,mBAAmB,CAAC,CAAA;CAC3C"}
|
@@ -2,6 +2,7 @@
|
|
2
2
|
import type { Editor } from '@prosekit/core'
|
3
3
|
import { useProsemirrorAdapterProvider } from '@prosemirror-adapter/svelte'
|
4
4
|
import { setEditorContext } from '../../contexts/editor-context'
|
5
|
+
import { MarkViewConsumer } from '../mark-view-consumer'
|
5
6
|
import { NodeViewConsumer } from '../node-view-consumer'
|
6
7
|
|
7
8
|
export let editor: Editor
|
@@ -12,3 +13,4 @@ useProsemirrorAdapterProvider()
|
|
12
13
|
|
13
14
|
<slot />
|
14
15
|
<NodeViewConsumer />
|
16
|
+
<MarkViewConsumer />
|
@@ -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;
|
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;AAyB5C,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;;;;;;;cAe8C,CAAC;AAChF,KAAK,QAAQ,GAAG,YAAY,CAAC,OAAO,QAAQ,CAAC,CAAC;AAChD,eAAe,QAAQ,CAAC"}
|
@@ -0,0 +1,33 @@
|
|
1
|
+
import { type Extension } from '@prosekit/core';
|
2
|
+
import type { MarkViewConstructor } from '@prosekit/pm/view';
|
3
|
+
import type { CoreMarkViewUserOptions } from '@prosemirror-adapter/core';
|
4
|
+
import type { MarkViewContext, SvelteMarkViewUserOptions } from '@prosemirror-adapter/svelte';
|
5
|
+
import type { Component } from 'svelte';
|
6
|
+
/**
|
7
|
+
* @public
|
8
|
+
*/
|
9
|
+
export interface SvelteMarkViewProps extends MarkViewContext {
|
10
|
+
}
|
11
|
+
/**
|
12
|
+
* @public
|
13
|
+
*/
|
14
|
+
export type SvelteMarkViewComponent = Component<SvelteMarkViewProps>;
|
15
|
+
/**
|
16
|
+
* Options for {@link defineSvelteMarkView}.
|
17
|
+
*
|
18
|
+
* @public
|
19
|
+
*/
|
20
|
+
export interface SvelteMarkViewOptions extends CoreMarkViewUserOptions<SvelteMarkViewComponent> {
|
21
|
+
/**
|
22
|
+
* The name of the mark type.
|
23
|
+
*/
|
24
|
+
name: string;
|
25
|
+
}
|
26
|
+
/**
|
27
|
+
* Defines a mark view using a Svelte component.
|
28
|
+
*
|
29
|
+
* @public
|
30
|
+
*/
|
31
|
+
export declare function defineSvelteMarkView(options: SvelteMarkViewOptions): Extension;
|
32
|
+
export declare function defineSvelteMarkViewFactory(factory: (options: SvelteMarkViewUserOptions) => MarkViewConstructor): Extension<import("@prosekit/core").ExtensionTyping<any, any, any>>;
|
33
|
+
//# sourceMappingURL=svelte-mark-view.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"svelte-mark-view.d.ts","sourceRoot":"","sources":["../../../../src/extensions/svelte-mark-view.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,SAAS,EACf,MAAM,gBAAgB,CAAA;AACvB,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAA;AAC5D,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAA;AACxE,OAAO,KAAK,EACV,eAAe,EACf,yBAAyB,EAC1B,MAAM,6BAA6B,CAAA;AACpC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAA;AAIvC;;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;AAID;;;;GAIG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,qBAAqB,GAC7B,SAAS,CAkBX;AAiBD,wBAAgB,2BAA2B,CACzC,OAAO,EAAE,CAAC,OAAO,EAAE,yBAAyB,KAAK,mBAAmB,sEAMrE"}
|
@@ -0,0 +1,40 @@
|
|
1
|
+
import { defineMarkViewComponent, defineMarkViewFactory, definePlugin, } from '@prosekit/core';
|
2
|
+
import { MarkViewWrapper } from '../components/mark-view-wrapper';
|
3
|
+
const isServer = typeof window === 'undefined';
|
4
|
+
/**
|
5
|
+
* Defines a mark view using a Svelte component.
|
6
|
+
*
|
7
|
+
* @public
|
8
|
+
*/
|
9
|
+
export function defineSvelteMarkView(options) {
|
10
|
+
// Don't register mark views on the server
|
11
|
+
if (isServer) {
|
12
|
+
return definePlugin([]);
|
13
|
+
}
|
14
|
+
const { name, component, ...userOptions } = options;
|
15
|
+
const args = {
|
16
|
+
...userOptions,
|
17
|
+
component: wrapComponent(component),
|
18
|
+
};
|
19
|
+
return defineMarkViewComponent({
|
20
|
+
group: 'svelte',
|
21
|
+
name,
|
22
|
+
args,
|
23
|
+
});
|
24
|
+
}
|
25
|
+
function wrapComponent(component) {
|
26
|
+
// `MarkViewWrapper` is an object during SSR
|
27
|
+
if (!MarkViewWrapper || typeof MarkViewWrapper !== 'function') {
|
28
|
+
return component;
|
29
|
+
}
|
30
|
+
const MarkViewPropsWrapper = (internals, props) => {
|
31
|
+
return MarkViewWrapper(internals, { ...props, component });
|
32
|
+
};
|
33
|
+
return MarkViewPropsWrapper;
|
34
|
+
}
|
35
|
+
export function defineSvelteMarkViewFactory(factory) {
|
36
|
+
return defineMarkViewFactory({
|
37
|
+
group: 'svelte',
|
38
|
+
factory,
|
39
|
+
});
|
40
|
+
}
|
@@ -0,0 +1,33 @@
|
|
1
|
+
import { type Extension } from '@prosekit/core';
|
2
|
+
import type { NodeViewConstructor } from '@prosekit/pm/view';
|
3
|
+
import type { CoreNodeViewUserOptions } from '@prosemirror-adapter/core';
|
4
|
+
import type { NodeViewContext, SvelteNodeViewUserOptions } from '@prosemirror-adapter/svelte';
|
5
|
+
import type { Component } from 'svelte';
|
6
|
+
/**
|
7
|
+
* @public
|
8
|
+
*/
|
9
|
+
export interface SvelteNodeViewProps extends NodeViewContext {
|
10
|
+
}
|
11
|
+
/**
|
12
|
+
* @public
|
13
|
+
*/
|
14
|
+
export type SvelteNodeViewComponent = Component<SvelteNodeViewProps>;
|
15
|
+
/**
|
16
|
+
* Options for {@link defineSvelteNodeView}.
|
17
|
+
*
|
18
|
+
* @public
|
19
|
+
*/
|
20
|
+
export interface SvelteNodeViewOptions extends CoreNodeViewUserOptions<SvelteNodeViewComponent> {
|
21
|
+
/**
|
22
|
+
* The name of the node type.
|
23
|
+
*/
|
24
|
+
name: string;
|
25
|
+
}
|
26
|
+
/**
|
27
|
+
* Defines a node view using a Svelte component.
|
28
|
+
*
|
29
|
+
* @public
|
30
|
+
*/
|
31
|
+
export declare function defineSvelteNodeView(options: SvelteNodeViewOptions): Extension;
|
32
|
+
export declare function defineSvelteNodeViewFactory(factory: (options: SvelteNodeViewUserOptions) => NodeViewConstructor): Extension<import("@prosekit/core").ExtensionTyping<any, any, any>>;
|
33
|
+
//# sourceMappingURL=svelte-node-view.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"svelte-node-view.d.ts","sourceRoot":"","sources":["../../../../src/extensions/svelte-node-view.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,SAAS,EACf,MAAM,gBAAgB,CAAA;AACvB,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAA;AAC5D,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAA;AACxE,OAAO,KAAK,EACV,eAAe,EACf,yBAAyB,EAC1B,MAAM,6BAA6B,CAAA;AACpC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAA;AAIvC;;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;AAID;;;;GAIG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,qBAAqB,GAC7B,SAAS,CAkBX;AAiBD,wBAAgB,2BAA2B,CACzC,OAAO,EAAE,CAAC,OAAO,EAAE,yBAAyB,KAAK,mBAAmB,sEAMrE"}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { defineNodeViewComponent, definePlugin, } from '@prosekit/core';
|
1
|
+
import { defineNodeViewComponent, defineNodeViewFactory, definePlugin, } from '@prosekit/core';
|
2
2
|
import { NodeViewWrapper } from '../components/node-view-wrapper';
|
3
3
|
const isServer = typeof window === 'undefined';
|
4
4
|
/**
|
@@ -32,3 +32,9 @@ function wrapComponent(component) {
|
|
32
32
|
};
|
33
33
|
return NodeViewPropsWrapper;
|
34
34
|
}
|
35
|
+
export function defineSvelteNodeViewFactory(factory) {
|
36
|
+
return defineNodeViewFactory({
|
37
|
+
group: 'svelte',
|
38
|
+
factory,
|
39
|
+
});
|
40
|
+
}
|
package/dist/build/index.d.ts
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
export { ProseKit, type ProseKitProps, } from './components/prosekit';
|
2
|
+
export { defineSvelteMarkView, type SvelteMarkViewComponent, type SvelteMarkViewOptions, type SvelteMarkViewProps, } from './extensions/svelte-mark-view';
|
3
|
+
export { defineSvelteNodeView, type SvelteNodeViewComponent, type SvelteNodeViewOptions, type SvelteNodeViewProps, } from './extensions/svelte-node-view';
|
2
4
|
export { useDocChange } from './hooks/use-doc-change';
|
3
5
|
export { useEditor } from './hooks/use-editor';
|
4
6
|
export { useExtension, type UseExtensionOptions, } from './hooks/use-extension';
|
5
7
|
export { useKeymap } from './hooks/use-keymap';
|
6
8
|
export { useStateUpdate } from './hooks/use-state-update';
|
7
|
-
export { defineSvelteNodeView } from './node-view/define-svelte-node-view';
|
8
|
-
export type { SvelteNodeViewComponent, SvelteNodeViewOptions, SvelteNodeViewProps, } from './node-view/types';
|
9
9
|
export type { PropsWithClass } from './types';
|
10
10
|
//# sourceMappingURL=index.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EACR,KAAK,aAAa,GACnB,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAA;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAC9C,OAAO,EACL,YAAY,EACZ,KAAK,mBAAmB,GACzB,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AACzD,
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EACR,KAAK,aAAa,GACnB,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EACL,oBAAoB,EACpB,KAAK,uBAAuB,EAC5B,KAAK,qBAAqB,EAC1B,KAAK,mBAAmB,GACzB,MAAM,+BAA+B,CAAA;AACtC,OAAO,EACL,oBAAoB,EACpB,KAAK,uBAAuB,EAC5B,KAAK,qBAAqB,EAC1B,KAAK,mBAAmB,GACzB,MAAM,+BAA+B,CAAA;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAA;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAC9C,OAAO,EACL,YAAY,EACZ,KAAK,mBAAmB,GACzB,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AACzD,YAAY,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA"}
|
package/dist/build/index.js
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
export { ProseKit, } from './components/prosekit';
|
2
|
+
export { defineSvelteMarkView, } from './extensions/svelte-mark-view';
|
3
|
+
export { defineSvelteNodeView, } from './extensions/svelte-node-view';
|
2
4
|
export { useDocChange } from './hooks/use-doc-change';
|
3
5
|
export { useEditor } from './hooks/use-editor';
|
4
6
|
export { useExtension, } from './hooks/use-extension';
|
5
7
|
export { useKeymap } from './hooks/use-keymap';
|
6
8
|
export { useStateUpdate } from './hooks/use-state-update';
|
7
|
-
export { defineSvelteNodeView } from './node-view/define-svelte-node-view';
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@prosekit/svelte",
|
3
3
|
"type": "module",
|
4
|
-
"version": "0.6.
|
4
|
+
"version": "0.6.1",
|
5
5
|
"private": false,
|
6
6
|
"author": {
|
7
7
|
"name": "ocavue",
|
@@ -77,7 +77,8 @@
|
|
77
77
|
"dist"
|
78
78
|
],
|
79
79
|
"dependencies": {
|
80
|
-
"@prosemirror-adapter/
|
80
|
+
"@prosemirror-adapter/core": "^0.4.0",
|
81
|
+
"@prosemirror-adapter/svelte": "^0.4.0",
|
81
82
|
"@prosekit/core": "^0.7.13",
|
82
83
|
"@prosekit/web": "^0.5.1",
|
83
84
|
"@prosekit/pm": "^0.1.9"
|
@@ -92,13 +93,13 @@
|
|
92
93
|
},
|
93
94
|
"devDependencies": {
|
94
95
|
"@sveltejs/package": "^2.3.7",
|
95
|
-
"@types/node": "^20.17.
|
96
|
+
"@types/node": "^20.17.9",
|
96
97
|
"read-pkg": "^9.0.1",
|
97
|
-
"svelte": "^5.
|
98
|
-
"svelte-check": "^4.1.
|
98
|
+
"svelte": "^5.14.4",
|
99
|
+
"svelte-check": "^4.1.1",
|
99
100
|
"tsx": "^4.19.2",
|
100
|
-
"typescript": "
|
101
|
-
"vitest": "^2.1.
|
101
|
+
"typescript": "~5.6.3",
|
102
|
+
"vitest": "^2.1.8",
|
102
103
|
"@prosekit/dev": "0.0.0"
|
103
104
|
},
|
104
105
|
"scripts": {
|
@@ -1,4 +0,0 @@
|
|
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
|
@@ -1 +0,0 @@
|
|
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"}
|
@@ -1,9 +0,0 @@
|
|
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
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"define-svelte-node-view.d.ts","sourceRoot":"","sources":["../../../../src/node-view/define-svelte-node-view.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,SAAS,EACf,MAAM,gBAAgB,CAAA;AAMvB,OAAO,KAAK,EAEV,qBAAqB,EACtB,MAAM,SAAS,CAAA;AAIhB;;;;GAIG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,qBAAqB,GAC7B,SAAS,CAkBX"}
|
@@ -1,38 +0,0 @@
|
|
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 { Component } 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 = Component<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
|
@@ -1 +0,0 @@
|
|
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,EACV,KAAK,EACL,eAAe,EAChB,MAAM,oBAAoB,CAAA;AAC3B,OAAO,KAAK,EACV,UAAU,EACV,gBAAgB,EAChB,UAAU,EACX,MAAM,mBAAmB,CAAA;AAC1B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAA;AACvC,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,SAAS,CAAC,mBAAmB,CAAC,CAAA;AAEpE;;;;GAIG;AACH,MAAM,WAAW,qBAAsB,SAAQ,mBAAmB;IAChE;;OAEG;IACH,IAAI,EAAE,MAAM,CAAA;IAEZ;;OAEG;IACH,SAAS,EAAE,uBAAuB,CAAA;CACnC"}
|
File without changes
|