@spatika/editor 1.6.1 → 1.6.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spatika/editor",
3
- "version": "1.6.1",
3
+ "version": "1.6.2",
4
4
  "license": "MIT",
5
5
  "description": "Spatika UI — Tiptap-powered rich text editor with glass theming, AI hooks, and extensible toolbar",
6
6
  "homepage": "https://spatika.sweyam.com",
@@ -62,6 +62,7 @@ describe("ToolbarInsertPanels", () => {
62
62
  const editor = createEditor();
63
63
  const close = vi.fn();
64
64
  const onGalleryPrefetch = vi.fn();
65
+ const chain = editor.chain();
65
66
 
66
67
  render(
67
68
  <ImageInsertPanel
@@ -71,13 +72,17 @@ describe("ToolbarInsertPanels", () => {
71
72
  galleryPhotos: [{ id: 1, url: "https://example.com/gallery.png", alt: "Gallery photo" }],
72
73
  onGalleryPrefetch,
73
74
  galleryOpenLabel: "Open full gallery",
75
+ galleryInsertWidth: "min(100%, 28rem)",
74
76
  }}
75
77
  />,
76
78
  );
77
79
 
78
80
  expect(onGalleryPrefetch).toHaveBeenCalled();
79
81
  await userEvent.click(screen.getByRole("button", { name: "Gallery photo" }));
80
- expect(editor.chain).toHaveBeenCalled();
82
+ expect(chain.setImage).toHaveBeenCalledWith({
83
+ src: "https://example.com/gallery.png",
84
+ width: "min(100%, 28rem)",
85
+ });
81
86
  expect(close).toHaveBeenCalled();
82
87
  });
83
88
 
@@ -75,8 +75,12 @@ export function LinkInsertPanel({ editor, close }: PanelProps) {
75
75
  );
76
76
  }
77
77
 
78
- function insertImageSrc(editor: Editor, src: string) {
79
- editor.chain().focus().setImage({ src }).run();
78
+ function insertImageSrc(editor: Editor, src: string, width?: string) {
79
+ editor
80
+ .chain()
81
+ .focus()
82
+ .setImage(width ? { src, width } : { src })
83
+ .run();
80
84
  }
81
85
 
82
86
  function resolveGalleryPhotoSrc(photo: NonNullable<ImageInsertConfig["galleryPhotos"]>[number]) {
@@ -119,7 +123,7 @@ export function ImageInsertPanel({ editor, close, config }: ImagePanelProps) {
119
123
 
120
124
  const insertGalleryPhoto = (photoUrl: string) => {
121
125
  if (!photoUrl.trim()) return;
122
- insertImageSrc(editor, photoUrl);
126
+ insertImageSrc(editor, photoUrl, config?.galleryInsertWidth);
123
127
  close();
124
128
  };
125
129
 
package/src/lib/types.ts CHANGED
@@ -47,6 +47,8 @@ export type ImageInsertConfig = {
47
47
  galleryEmptyMessage?: string;
48
48
  /** Label for the host gallery action button. Default "Open gallery". */
49
49
  galleryOpenLabel?: string;
50
+ /** Width applied when inserting from the gallery quick-pick. */
51
+ galleryInsertWidth?: string;
50
52
  };
51
53
 
52
54
  export type SlashCommandItem = {
@@ -718,7 +718,8 @@
718
718
  }
719
719
 
720
720
  .spk-editor-image-insert {
721
- min-width: 16rem;
721
+ min-width: 0;
722
+ max-width: 100%;
722
723
  }
723
724
 
724
725
  .spk-editor-image-gallery {
@@ -729,13 +730,14 @@
729
730
 
730
731
  .spk-editor-image-gallery-grid {
731
732
  display: grid;
732
- grid-template-columns: repeat(4, minmax(0, 1fr));
733
- gap: 0.4rem;
733
+ grid-template-columns: repeat(5, minmax(0, 1fr));
734
+ gap: 0.35rem;
734
735
  }
735
736
 
736
737
  .spk-editor-image-gallery-item {
737
738
  position: relative;
738
739
  aspect-ratio: 1;
740
+ max-height: 3.25rem;
739
741
  overflow: hidden;
740
742
  border: 2px solid transparent;
741
743
  border-radius: 0.65rem;
@@ -894,6 +896,8 @@
894
896
  .spk-editor-toolbar-popover-panel--portal {
895
897
  position: fixed;
896
898
  z-index: 60;
899
+ width: min(18rem, calc(100vw - 1.5rem));
900
+ max-width: min(18rem, calc(100vw - 1.5rem));
897
901
  }
898
902
 
899
903
  .spk-editor-ai-panel {