@ecsplico/editor 3.5.0 → 3.5.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.
Files changed (28) hide show
  1. package/CHANGELOG.md +7 -2
  2. package/dist/code/CodeSurface.vue.d.ts +1 -1
  3. package/dist/document/DocumentSurface.vue.d.ts +1 -1
  4. package/dist/features/ai/protocol/generate.d.ts +1 -1
  5. package/dist/features/image-studio/node-core.d.ts +46 -0
  6. package/dist/features/image-studio/node-core.js +79 -0
  7. package/dist/features/image-studio/node-core.js.map +1 -0
  8. package/dist/features/image-studio/node-store.d.ts +3 -11
  9. package/dist/features/image-studio/node-store.js +15 -44
  10. package/dist/features/image-studio/node-store.js.map +1 -1
  11. package/dist/features/image-studio/react/ImageStudioChat.js +101 -0
  12. package/dist/features/image-studio/react/ImageStudioChat.js.map +1 -0
  13. package/dist/features/image-studio/react/ImageStudioDialog.d.ts +19 -0
  14. package/dist/features/image-studio/react/ImageStudioDialog.js +357 -0
  15. package/dist/features/image-studio/react/ImageStudioDialog.js.map +1 -0
  16. package/dist/features/image-studio/react/ImageStudioTile.js +51 -0
  17. package/dist/features/image-studio/react/ImageStudioTile.js.map +1 -0
  18. package/dist/features/image-studio/react/ImageStudioView.js +126 -0
  19. package/dist/features/image-studio/react/ImageStudioView.js.map +1 -0
  20. package/dist/features/image-studio/react/store.d.ts +37 -0
  21. package/dist/features/image-studio/react/store.js +46 -0
  22. package/dist/features/image-studio/react/store.js.map +1 -0
  23. package/dist/features/image-studio/react.d.ts +18 -0
  24. package/dist/features/image-studio/react.js +21 -0
  25. package/dist/features/image-studio/react.js.map +1 -0
  26. package/dist/markdown/MarkdownSurface.vue.d.ts +1 -1
  27. package/dist/vue/AdvancedEditor.vue.d.ts +1 -1
  28. package/package.json +6 -1
@@ -0,0 +1,46 @@
1
+ import { createImageStudioNodeCore } from "../node-core.js";
2
+ import { useCallback, useEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";
3
+ //#region src/features/image-studio/react/store.ts
4
+ const noUnsubscribe = () => {};
5
+ /**
6
+ * The `ImageStudioReactStore` of one `imageStudio` node (the React wrapper of `createImageStudioNodeCore`): `state`
7
+ * follows the node's `studio` attribute, `update` writes it back as one transaction, the rest goes to
8
+ * `backend.images`. The core lives for as long as the component and the `editor`, `backend` and `documentId` stay the
9
+ * same; the first render returns `undefined` (the core is built in an effect), so render the dialog once there is a store.
10
+ */
11
+ function useImageStudioNodeStore(options) {
12
+ const { editor, backend, documentId } = options;
13
+ const getPos = useRef(options.getPos);
14
+ getPos.current = options.getPos;
15
+ const [core, setCore] = useState();
16
+ useEffect(() => {
17
+ const own = createImageStudioNodeCore({
18
+ editor,
19
+ backend,
20
+ documentId,
21
+ getPos: () => getPos.current()
22
+ });
23
+ setCore(own);
24
+ return () => {
25
+ own.dispose();
26
+ setCore(void 0);
27
+ };
28
+ }, [
29
+ editor,
30
+ backend,
31
+ documentId
32
+ ]);
33
+ const subscribe = useCallback((listener) => core ? core.subscribe(listener) : noUnsubscribe, [core]);
34
+ const getSnapshot = useCallback(() => core?.get(), [core]);
35
+ const snapshot = useSyncExternalStore(subscribe, getSnapshot, getSnapshot);
36
+ return useMemo(() => core && snapshot ? {
37
+ ...snapshot,
38
+ update: core.update,
39
+ generate: core.generate,
40
+ upload: core.upload
41
+ } : void 0, [core, snapshot]);
42
+ }
43
+ //#endregion
44
+ export { useImageStudioNodeStore };
45
+
46
+ //# sourceMappingURL=store.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"store.js","names":[],"sources":["../../../../src/features/image-studio/react/store.ts"],"sourcesContent":["import { useCallback, useEffect, useMemo, useRef, useState, useSyncExternalStore } from 'react'\nimport { createImageStudioNodeCore, type ImageStudioNodeCore, type ImageStudioNodeCoreOptions } from '../node-core'\nimport type { ImageStudioImage, ImageStudioPromptBlock, ImageStudioState } from '../state'\n\n/**\n * What the React Bild-Studio dialog drives; a host supplies it. The same contract as the Vue `ImageStudioStore`, with\n * plain values where Vue has refs: the host re-renders the dialog with a new `state` after `update`.\n *\n * The dialog applies the reducers of `../state` and hands the result to `update`; the store only persists it. The\n * store's methods never touch `state` themselves:\n * - `update` must lead to a new `state` (the dialog keeps working on its own latest value until `state` changes).\n * - `generate` produces one image from the block's `state.description`, the active Prompt-Bausteine and the active\n * images (the host builds the prompt). When it resolves, the dialog calls `update(addGeneration(state, image, turn))`;\n * when it rejects (and the signal was not aborted) the dialog appends a turn with `imageId: null` and the message as\n * `problem`. An aborted generation adds nothing.\n * - `upload` stores the file and returns the image; the dialog then calls `update(addReference(state, image))`.\n * - `problem` is a problem of the store itself (the Prompt-Bausteine could not be loaded, say); the dialog shows it as a notice.\n */\nexport interface ImageStudioReactStore {\n readonly state: ImageStudioState\n /** The managed list of Prompt-Bausteine, loaded by the host. */\n readonly promptBlocks: readonly ImageStudioPromptBlock[]\n /** Called with the state after a reducer; the host persists it. */\n update: (next: ImageStudioState) => void\n generate: (instruction: string, signal: AbortSignal) => Promise<ImageStudioImage>\n upload: (file: File) => Promise<ImageStudioImage>\n readonly problem: string | undefined\n}\n\nconst noUnsubscribe = () => {}\n\n/**\n * The `ImageStudioReactStore` of one `imageStudio` node (the React wrapper of `createImageStudioNodeCore`): `state`\n * follows the node's `studio` attribute, `update` writes it back as one transaction, the rest goes to\n * `backend.images`. The core lives for as long as the component and the `editor`, `backend` and `documentId` stay the\n * same; the first render returns `undefined` (the core is built in an effect), so render the dialog once there is a store.\n */\nexport function useImageStudioNodeStore(options: ImageStudioNodeCoreOptions): ImageStudioReactStore | undefined {\n const { editor, backend, documentId } = options\n const getPos = useRef(options.getPos)\n getPos.current = options.getPos\n const [core, setCore] = useState<ImageStudioNodeCore>()\n useEffect(() => {\n const own = createImageStudioNodeCore({ editor, backend, documentId, getPos: () => getPos.current() })\n setCore(own)\n return () => {\n own.dispose()\n setCore(undefined)\n }\n }, [editor, backend, documentId])\n const subscribe = useCallback((listener: () => void) => core ? core.subscribe(listener) : noUnsubscribe, [core])\n const getSnapshot = useCallback(() => core?.get(), [core])\n const snapshot = useSyncExternalStore(subscribe, getSnapshot, getSnapshot)\n return useMemo(\n () => core && snapshot ? { ...snapshot, update: core.update, generate: core.generate, upload: core.upload } : undefined,\n [core, snapshot],\n )\n}\n"],"mappings":";;;AA6BA,MAAM,sBAAsB,CAAC;;;;;;;AAQ7B,SAAgB,wBAAwB,SAAwE;CAC9G,MAAM,EAAE,QAAQ,SAAS,eAAe;CACxC,MAAM,SAAS,OAAO,QAAQ,MAAM;CACpC,OAAO,UAAU,QAAQ;CACzB,MAAM,CAAC,MAAM,WAAW,SAA8B;CACtD,gBAAgB;EACd,MAAM,MAAM,0BAA0B;GAAE;GAAQ;GAAS;GAAY,cAAc,OAAO,QAAQ;EAAE,CAAC;EACrG,QAAQ,GAAG;EACX,aAAa;GACX,IAAI,QAAQ;GACZ,QAAQ,KAAA,CAAS;EACnB;CACF,GAAG;EAAC;EAAQ;EAAS;CAAU,CAAC;CAChC,MAAM,YAAY,aAAa,aAAyB,OAAO,KAAK,UAAU,QAAQ,IAAI,eAAe,CAAC,IAAI,CAAC;CAC/G,MAAM,cAAc,kBAAkB,MAAM,IAAI,GAAG,CAAC,IAAI,CAAC;CACzD,MAAM,WAAW,qBAAqB,WAAW,aAAa,WAAW;CACzE,OAAO,cACC,QAAQ,WAAW;EAAE,GAAG;EAAU,QAAQ,KAAK;EAAQ,UAAU,KAAK;EAAU,QAAQ,KAAK;CAAO,IAAI,KAAA,GAC9G,CAAC,MAAM,QAAQ,CACjB;AACF"}
@@ -0,0 +1,18 @@
1
+ import { ImageStudioImage, ImageStudioPromptBlock } from "../../core/backend-types.js";
2
+ import { ReactFeature } from "../../react/EditorSurface.js";
3
+ import "../../react/index.js";
4
+ import { EMPTY_IMAGE_STUDIO_STATE, ImageStudioState, ImageStudioTurn, addGeneration, addReference, isEmptyImageStudioState, normalizeImageStudioState, removeImage, select, selectedImage, setDescription, toggleImage, togglePromptBlock } from "./state.js";
5
+ import { ImageStudioNodeCore, ImageStudioNodeCoreOptions, ImageStudioNodeSnapshot, createImageStudioNodeCore } from "./node-core.js";
6
+ import { ImageStudioReactStore, useImageStudioNodeStore } from "./react/store.js";
7
+ import { ImageStudioDialog } from "./react/ImageStudioDialog.js";
8
+ //#region src/features/image-studio/react.d.ts
9
+ /**
10
+ * The React Bild-Studio feature (shadcn): the `imageStudio` block with its React view (picture or description
11
+ * placeholder, opens the studio dialog on double-click and through the block action `image-studio.open`), the `/` entry
12
+ * `bild-studio` and the action. Generation, upload and the Prompt-Bausteine need a backend with the `images`
13
+ * capability; without it the view says that generation is not set up.
14
+ */
15
+ export declare function imageStudioFeature(): ReactFeature;
16
+ //#endregion
17
+ export { EMPTY_IMAGE_STUDIO_STATE, ImageStudioDialog, type ImageStudioImage, type ImageStudioNodeCore, type ImageStudioNodeCoreOptions, type ImageStudioNodeSnapshot, type ImageStudioPromptBlock, type ImageStudioReactStore, type ImageStudioState, type ImageStudioTurn, addGeneration, addReference, createImageStudioNodeCore, isEmptyImageStudioState, normalizeImageStudioState, removeImage, select, selectedImage, setDescription, toggleImage, togglePromptBlock, useImageStudioNodeStore };
18
+ //# sourceMappingURL=react.d.ts.map
@@ -0,0 +1,21 @@
1
+ import { EMPTY_IMAGE_STUDIO_STATE, addGeneration, addReference, isEmptyImageStudioState, normalizeImageStudioState, removeImage, select, selectedImage, setDescription, toggleImage, togglePromptBlock } from "./state.js";
2
+ import { imageStudioFeatureCore } from "./feature.js";
3
+ import { ImageStudioDialog } from "./react/ImageStudioDialog.js";
4
+ import { createImageStudioNodeCore } from "./node-core.js";
5
+ import { useImageStudioNodeStore } from "./react/store.js";
6
+ import { ImageStudioView } from "./react/ImageStudioView.js";
7
+ import { ReactNodeViewRenderer } from "@tiptap/react";
8
+ //#region src/features/image-studio/react.ts
9
+ /**
10
+ * The React Bild-Studio feature (shadcn): the `imageStudio` block with its React view (picture or description
11
+ * placeholder, opens the studio dialog on double-click and through the block action `image-studio.open`), the `/` entry
12
+ * `bild-studio` and the action. Generation, upload and the Prompt-Bausteine need a backend with the `images`
13
+ * capability; without it the view says that generation is not set up.
14
+ */
15
+ function imageStudioFeature() {
16
+ return imageStudioFeatureCore({ nodeView: ReactNodeViewRenderer(ImageStudioView) });
17
+ }
18
+ //#endregion
19
+ export { EMPTY_IMAGE_STUDIO_STATE, ImageStudioDialog, addGeneration, addReference, createImageStudioNodeCore, imageStudioFeature, isEmptyImageStudioState, normalizeImageStudioState, removeImage, select, selectedImage, setDescription, toggleImage, togglePromptBlock, useImageStudioNodeStore };
20
+
21
+ //# sourceMappingURL=react.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"react.js","names":[],"sources":["../../../src/features/image-studio/react.ts"],"sourcesContent":["import { ReactNodeViewRenderer } from '@tiptap/react'\nimport type { ReactFeature } from '../../react'\nimport { imageStudioFeatureCore } from './feature'\nimport { ImageStudioView } from './react/ImageStudioView'\n\nexport { ImageStudioDialog } from './react/ImageStudioDialog'\nexport { type ImageStudioReactStore, useImageStudioNodeStore } from './react/store'\nexport { createImageStudioNodeCore, type ImageStudioNodeCore, type ImageStudioNodeCoreOptions, type ImageStudioNodeSnapshot } from './node-core'\nexport {\n addGeneration,\n addReference,\n EMPTY_IMAGE_STUDIO_STATE,\n type ImageStudioImage,\n type ImageStudioPromptBlock,\n type ImageStudioState,\n type ImageStudioTurn,\n isEmptyImageStudioState,\n normalizeImageStudioState,\n removeImage,\n select,\n selectedImage,\n setDescription,\n toggleImage,\n togglePromptBlock,\n} from './state'\n\n/**\n * The React Bild-Studio feature (shadcn): the `imageStudio` block with its React view (picture or description\n * placeholder, opens the studio dialog on double-click and through the block action `image-studio.open`), the `/` entry\n * `bild-studio` and the action. Generation, upload and the Prompt-Bausteine need a backend with the `images`\n * capability; without it the view says that generation is not set up.\n */\nexport function imageStudioFeature(): ReactFeature {\n return imageStudioFeatureCore({ nodeView: ReactNodeViewRenderer(ImageStudioView) })\n}\n"],"mappings":";;;;;;;;;;;;;;AAgCA,SAAgB,qBAAmC;CACjD,OAAO,uBAAuB,EAAE,UAAU,sBAAsB,eAAe,EAAE,CAAC;AACpF"}
@@ -61,9 +61,9 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {
61
61
  onFrontmatter?: ((frontmatter: string | null) => any) | undefined;
62
62
  onDiagnostics?: ((diagnostics: MarkdownDiagnostic[]) => any) | undefined;
63
63
  }>, {
64
- modelValue: string;
65
64
  editable: boolean;
66
65
  settingsUi: "internal" | "external";
66
+ modelValue: string;
67
67
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
68
68
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
69
69
  declare const _default: typeof __VLS_export;
@@ -87,8 +87,8 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {
87
87
  onContentError?: ((error: Error) => any) | undefined;
88
88
  onSettingsOpen?: ((tab?: string | undefined) => any) | undefined;
89
89
  }>, {
90
- ai: boolean;
91
90
  content: ContentLevel | readonly FeatureId[];
91
+ ai: boolean;
92
92
  editable: boolean;
93
93
  settingsUi: "internal" | "external";
94
94
  interaction: InteractionLevel | readonly FeatureId[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ecsplico/editor",
3
- "version": "3.5.0",
3
+ "version": "3.5.1",
4
4
  "type": "module",
5
5
  "description": "Vue and React editor library on TipTap v3 (Vue: Nuxt UI; React: shadcn/ui): framework-free features with Vue and React bindings, simple and advanced presets, tree-shakeable entries. Built ESM with type declarations.",
6
6
  "license": "MIT",
@@ -184,6 +184,11 @@
184
184
  "types": "./dist/features/image-studio/vue.d.ts",
185
185
  "import": "./dist/features/image-studio/vue.js"
186
186
  },
187
+ "./image-studio/react": {
188
+ "skaile-source": "./src/features/image-studio/react.ts",
189
+ "types": "./dist/features/image-studio/react.d.ts",
190
+ "import": "./dist/features/image-studio/react.js"
191
+ },
187
192
  "./image-studio/schema": {
188
193
  "skaile-source": "./src/features/image-studio/schema.ts",
189
194
  "types": "./dist/features/image-studio/schema.d.ts",