@prosekit/svelte 0.0.21 → 0.1.0

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.
@@ -1,11 +1,7 @@
1
- import { type Editor, type Extension } from '@prosekit/core';
2
- import { type Readable } from 'svelte/store';
1
+ import { type Editor } from '@prosekit/core';
3
2
  export interface EditorContext {
4
3
  editor: Editor;
5
4
  }
6
5
  export declare function setEditorContext(editor: Editor): void;
7
6
  export declare function getEditorContext(): EditorContext;
8
- export declare function getEditor<E extends Extension = any>(options?: {
9
- update?: boolean;
10
- }): Readable<Editor<E>>;
11
7
  //# 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,EAEL,KAAK,MAAM,EACX,KAAK,SAAS,EAEf,MAAM,gBAAgB,CAAA;AAEvB,OAAO,EAAsB,KAAK,QAAQ,EAAE,MAAM,cAAc,CAAA;AAEhE,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,MAAM,CAAA;CACf;AAID,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAMrD;AAED,wBAAgB,gBAAgB,IAAI,aAAa,CAOhD;AAED,wBAAgB,SAAS,CAAC,CAAC,SAAS,SAAS,GAAG,GAAG,EAAE,OAAO,CAAC,EAAE;IAC7D,MAAM,CAAC,EAAE,OAAO,CAAA;CACjB,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAiBtB"}
1
+ {"version":3,"file":"editor-context.d.ts","sourceRoot":"","sources":["../../../../src/contexts/editor-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAG3D,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,MAAM,CAAA;CACf;AAID,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAMrD;AAED,wBAAgB,gBAAgB,IAAI,aAAa,CAOhD"}
@@ -1,6 +1,5 @@
1
- import { ProseKitError, defineEventHandler, } from '@prosekit/core';
2
- import { getContext, hasContext, onDestroy, onMount, setContext } from 'svelte';
3
- import { readonly, writable } from 'svelte/store';
1
+ import { ProseKitError } from '@prosekit/core';
2
+ import { getContext, hasContext, setContext } from 'svelte';
4
3
  const key = 'prosekit-svelte-editor-context';
5
4
  export function setEditorContext(editor) {
6
5
  if (!editor) {
@@ -15,19 +14,3 @@ export function getEditorContext() {
15
14
  }
16
15
  return getContext(key);
17
16
  }
18
- export function getEditor(options) {
19
- var _a;
20
- const update = (_a = options === null || options === void 0 ? void 0 : options.update) !== null && _a !== void 0 ? _a : false;
21
- const editor = getEditorContext().editor;
22
- const editorStore = writable(editor);
23
- if (update) {
24
- onMount(() => {
25
- const forceUpdate = () => {
26
- editorStore.set(editor);
27
- };
28
- const dispose = editor.use(defineEventHandler({ update: forceUpdate }));
29
- onDestroy(dispose);
30
- });
31
- }
32
- return readonly(editorStore);
33
- }
@@ -0,0 +1,6 @@
1
+ import { type Editor, type Extension } from '@prosekit/core';
2
+ import { type Readable } from 'svelte/store';
3
+ export declare function useEditor<E extends Extension = any>(options?: {
4
+ update?: boolean;
5
+ }): Readable<Editor<E>>;
6
+ //# sourceMappingURL=use-editor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-editor.d.ts","sourceRoot":"","sources":["../../../../src/hooks/use-editor.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,MAAM,EACX,KAAK,SAAS,EACf,MAAM,gBAAgB,CAAA;AAEvB,OAAO,EAAsB,KAAK,QAAQ,EAAE,MAAM,cAAc,CAAA;AAIhE,wBAAgB,SAAS,CAAC,CAAC,SAAS,SAAS,GAAG,GAAG,EAAE,OAAO,CAAC,EAAE;IAC7D,MAAM,CAAC,EAAE,OAAO,CAAA;CACjB,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAiBtB"}
@@ -0,0 +1,20 @@
1
+ import { defineUpdateHandler, } from '@prosekit/core';
2
+ import { onDestroy, onMount } from 'svelte';
3
+ import { readonly, writable } from 'svelte/store';
4
+ import { getEditorContext } from '../contexts/editor-context';
5
+ export function useEditor(options) {
6
+ var _a;
7
+ const update = (_a = options === null || options === void 0 ? void 0 : options.update) !== null && _a !== void 0 ? _a : false;
8
+ const editor = getEditorContext().editor;
9
+ const editorStore = writable(editor);
10
+ if (update) {
11
+ onMount(() => {
12
+ const forceUpdate = () => {
13
+ editorStore.set(editor);
14
+ };
15
+ const dispose = editor.use(defineUpdateHandler(forceUpdate));
16
+ onDestroy(dispose);
17
+ });
18
+ }
19
+ return readonly(editorStore);
20
+ }
@@ -0,0 +1,3 @@
1
+ import { type Extension } from '@prosekit/core';
2
+ export declare function useExtension<T extends Extension = Extension>(extension: T): VoidFunction;
3
+ //# sourceMappingURL=use-extension.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-extension.d.ts","sourceRoot":"","sources":["../../../../src/hooks/use-extension.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAI/C,wBAAgB,YAAY,CAAC,CAAC,SAAS,SAAS,GAAG,SAAS,EAC1D,SAAS,EAAE,CAAC,GACX,YAAY,CAcd"}
@@ -0,0 +1,14 @@
1
+ import {} from '@prosekit/core';
2
+ import { useEditor } from './use-editor';
3
+ export function useExtension(extension) {
4
+ const editorStore = useEditor();
5
+ let cleanup = null;
6
+ editorStore.subscribe((editor) => {
7
+ cleanup === null || cleanup === void 0 ? void 0 : cleanup();
8
+ cleanup = editor.use(extension);
9
+ });
10
+ return () => {
11
+ cleanup === null || cleanup === void 0 ? void 0 : cleanup();
12
+ cleanup = null;
13
+ };
14
+ }
@@ -0,0 +1,3 @@
1
+ import { type Keymap } from '@prosekit/core';
2
+ export declare function useKeymap(keymap: Keymap): VoidFunction;
3
+ //# sourceMappingURL=use-keymap.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-keymap.d.ts","sourceRoot":"","sources":["../../../../src/hooks/use-keymap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAI1D,wBAAgB,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY,CAGtD"}
@@ -0,0 +1,6 @@
1
+ import { defineKeymap } from '@prosekit/core';
2
+ import { useExtension } from './use-extension';
3
+ export function useKeymap(keymap) {
4
+ const extension = defineKeymap(keymap);
5
+ return useExtension(extension);
6
+ }
@@ -1,3 +1,5 @@
1
- export { getEditor } from './contexts/editor-context';
1
+ export { useEditor } from './hooks/use-editor';
2
+ export { useExtension } from './hooks/use-extension';
3
+ export { useKeymap } from './hooks/use-keymap';
2
4
  export { ProseKit } from './components/prosekit';
3
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAA;AAErD,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAE9C,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA"}
@@ -1,2 +1,4 @@
1
- export { getEditor } from './contexts/editor-context';
1
+ export { useEditor } from './hooks/use-editor';
2
+ export { useExtension } from './hooks/use-extension';
3
+ export { useKeymap } from './hooks/use-keymap';
2
4
  export { ProseKit } from './components/prosekit';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@prosekit/svelte",
3
3
  "type": "module",
4
- "version": "0.0.21",
4
+ "version": "0.1.0",
5
5
  "private": false,
6
6
  "author": {
7
7
  "name": "ocavue",
@@ -54,12 +54,6 @@
54
54
  "import": "./dist/prosekit-svelte-autocomplete-popover.js",
55
55
  "default": "./dist/prosekit-svelte-autocomplete-popover.js"
56
56
  },
57
- "./code-block-popover": {
58
- "types": "./dist/prosekit-svelte-code-block-popover.d.ts",
59
- "svelte": "./dist/prosekit-svelte-code-block-popover.js",
60
- "import": "./dist/prosekit-svelte-code-block-popover.js",
61
- "default": "./dist/prosekit-svelte-code-block-popover.js"
62
- },
63
57
  "./combo-box": {
64
58
  "types": "./dist/prosekit-svelte-combo-box.d.ts",
65
59
  "svelte": "./dist/prosekit-svelte-combo-box.js",
@@ -101,8 +95,8 @@
101
95
  "dist"
102
96
  ],
103
97
  "dependencies": {
104
- "@prosekit/core": "^0.0.19",
105
- "@prosekit/lit": "^0.0.23"
98
+ "@prosekit/core": "^0.1.0",
99
+ "@prosekit/lit": "^0.1.0"
106
100
  },
107
101
  "peerDependencies": {
108
102
  "svelte": ">= 3.0.0"
@@ -115,9 +109,9 @@
115
109
  "devDependencies": {
116
110
  "@prosekit/dev": "*",
117
111
  "@sveltejs/package": "^2.2.2",
118
- "@types/node": "^20.8.10",
112
+ "@types/node": "^20.9.0",
119
113
  "read-pkg": "^9.0.0",
120
- "svelte": "^4.2.2",
114
+ "svelte": "^4.2.3",
121
115
  "svelte-check": "^3.5.2",
122
116
  "tsx": "^3.14.0",
123
117
  "typescript": "^5.2.2",
@@ -144,9 +138,6 @@
144
138
  "autocomplete-popover": [
145
139
  "./dist/prosekit-svelte-autocomplete-popover.d.ts"
146
140
  ],
147
- "code-block-popover": [
148
- "./dist/prosekit-svelte-code-block-popover.d.ts"
149
- ],
150
141
  "combo-box": [
151
142
  "./dist/prosekit-svelte-combo-box.d.ts"
152
143
  ],
@@ -1,7 +0,0 @@
1
- import type { CodeBlockPopoverProps as CodeBlockPopoverElementProps } from '@prosekit/lit/code-block-popover';
2
- import type { SvelteComponent } from 'svelte';
3
- export type CodeBlockPopoverProps = {
4
- class?: string;
5
- } & CodeBlockPopoverElementProps;
6
- export declare const CodeBlockPopover: typeof SvelteComponent<CodeBlockPopoverProps>;
7
- //# sourceMappingURL=code-block-popover.gen.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"code-block-popover.gen.d.ts","sourceRoot":"","sources":["../../../../src/components/code-block-popover.gen.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,IAAI,4BAA4B,EAAE,MAAM,kCAAkC,CAAA;AAC7G,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAA;AAI7C,MAAM,MAAM,qBAAqB,GAAG;IAClC,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,GAAG,4BAA4B,CAAA;AAEhC,eAAO,MAAM,gBAAgB,EAA+D,uBAAuB,qBAAqB,CAAC,CAAA"}
@@ -1,2 +0,0 @@
1
- import CodeBlockPopoverComponent from './code-block-popover.gen.svelte';
2
- export const CodeBlockPopover = CodeBlockPopoverComponent;
@@ -1,7 +0,0 @@
1
- <script lang="ts">
2
- import '@prosekit/lit/code-block-popover'
3
- </script>
4
-
5
- <prosekit-code-block-popover {...$$props}>
6
- <slot />
7
- </prosekit-code-block-popover>
@@ -1,20 +0,0 @@
1
- import { SvelteComponentTyped } from "svelte";
2
- import '@prosekit/lit/code-block-popover';
3
- declare const __propDef: {
4
- props: {
5
- [x: string]: any;
6
- };
7
- events: {
8
- [evt: string]: CustomEvent<any>;
9
- };
10
- slots: {
11
- default: {};
12
- };
13
- };
14
- export type CodeBlockPopoverProps = typeof __propDef.props;
15
- export type CodeBlockPopoverEvents = typeof __propDef.events;
16
- export type CodeBlockPopoverSlots = typeof __propDef.slots;
17
- export default class CodeBlockPopover extends SvelteComponentTyped<CodeBlockPopoverProps, CodeBlockPopoverEvents, CodeBlockPopoverSlots> {
18
- }
19
- export {};
20
- //# sourceMappingURL=code-block-popover.gen.svelte.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"code-block-popover.gen.svelte.d.ts","sourceRoot":"","sources":["../../../../src/components/code-block-popover.gen.svelte"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,QAAQ,CAE5C;AACD,OAAO,kCAAkC,CAAA;AAYzC,QAAA,MAAM,SAAS;;;;;;;;;;CAA+D,CAAC;AAC/E,MAAM,MAAM,qBAAqB,GAAG,OAAO,SAAS,CAAC,KAAK,CAAC;AAC3D,MAAM,MAAM,sBAAsB,GAAG,OAAO,SAAS,CAAC,MAAM,CAAC;AAC7D,MAAM,MAAM,qBAAqB,GAAG,OAAO,SAAS,CAAC,KAAK,CAAC;AAE3D,MAAM,CAAC,OAAO,OAAO,gBAAiB,SAAQ,oBAAoB,CAAC,qBAAqB,EAAE,sBAAsB,EAAE,qBAAqB,CAAC;CACvI"}
@@ -1 +0,0 @@
1
- export * from './build/components/code-block-popover.gen'
@@ -1 +0,0 @@
1
- export * from './build/components/code-block-popover.gen'