@kystverket/styrbord 1.8.5 → 1.9.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.
- package/README.md +4 -0
- package/dist/src/components/kystverket/FileUploader/FileUploader.context.d.ts +3 -2
- package/dist/src/components/kystverket/MarkdownToReact/markdownToReact.d.ts +1 -9
- package/dist/src/components/kystverket/MarkdownToReact/markdownToReact.stories.d.ts +1 -1
- package/dist/src/components/kystverket/RichTextArea/hooks/useRichTextImageUpload.d.ts +5 -3
- package/dist/src/components/kystverket/RichTextArea/richTextArea.types.d.ts +10 -7
- package/dist/src/components/kystverket/RichTextArea/utils/ImageRefUtils.d.ts +2 -7
- package/dist/src/main.d.ts +1 -0
- package/dist/src/utils/fileInfoResolver.d.ts +7 -0
- package/dist/style.css +1 -1
- package/dist/style.js +1554 -1532
- package/dist/style.umd.cjs +9 -9
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -41,6 +41,10 @@ Styrbords design tokens hentes fra [@Kystverket/styrbord-tokens](https://github.
|
|
|
41
41
|
|
|
42
42
|
## Endringslogg
|
|
43
43
|
|
|
44
|
+
### 2026-06-09 -- v1.9.0
|
|
45
|
+
|
|
46
|
+
Oppdatert RichTextArea og MarkdownToReact til å bruke FileUploader sin context for å håndtere henting av fil-informasjon gjennom `deriveFileInfosFromStorageIds`
|
|
47
|
+
|
|
44
48
|
### 2026-05-22 -- v1.7.2
|
|
45
49
|
|
|
46
50
|
Lagt inn bildehåndtering i RichTextArea og MarkdownToReact. Du laster opp bildet selv og legger inn en referanse-lenke i markdownen. Lenken tolkes i MarkdownToReact, slik at markdownen holdes så liten som mulig.
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { FileInfo, UploadFileResult } from './FileUploader.types';
|
|
2
|
+
import type { DeriveFileInfosFromStorageIds } from '~/utils/fileInfoResolver';
|
|
2
3
|
export type FileChangeCallback = (files: FileInfo[]) => void;
|
|
3
4
|
export interface FileUploaderContextProps {
|
|
4
|
-
deriveFileInfosFromStorageIds
|
|
5
|
+
deriveFileInfosFromStorageIds: DeriveFileInfosFromStorageIds;
|
|
5
6
|
uploadFile: (file: FormData) => Promise<UploadFileResult>;
|
|
6
7
|
deleteFile: (fileId: string) => Promise<void>;
|
|
7
8
|
}
|
|
@@ -1,13 +1,5 @@
|
|
|
1
|
-
import { MaybePromise } from '~/utils/utility.types';
|
|
2
|
-
type ResolvedImageRefs = Record<string, ResolvedImageRef>;
|
|
3
1
|
export type MarkdownToReactProps = {
|
|
4
2
|
markdown: string;
|
|
5
|
-
/** Optional sync/async resolver that receives all refs found in markdown. */
|
|
6
|
-
resolveImageRefs?: (refs?: string[]) => MaybePromise<ResolvedImageRefs>;
|
|
7
3
|
};
|
|
8
|
-
|
|
9
|
-
src: string;
|
|
10
|
-
alt?: string;
|
|
11
|
-
} | string | null | undefined;
|
|
12
|
-
declare const MarkdownToReact: ({ markdown, resolveImageRefs }: MarkdownToReactProps) => React.JSX.Element;
|
|
4
|
+
declare const MarkdownToReact: ({ markdown }: MarkdownToReactProps) => React.JSX.Element;
|
|
13
5
|
export default MarkdownToReact;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { StoryObj } from '@storybook/react-vite';
|
|
2
2
|
declare const meta: {
|
|
3
3
|
title: string;
|
|
4
|
-
component: ({ markdown
|
|
4
|
+
component: ({ markdown }: import("./markdownToReact").MarkdownToReactProps) => React.JSX.Element;
|
|
5
5
|
decorators: ((Story: import("storybook/internal/csf").PartialStoryFn, context: import("storybook/internal/csf").StoryContext) => React.JSX.Element)[];
|
|
6
6
|
tags: string[];
|
|
7
7
|
argTypes: {
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import type { Editor } from '@milkdown/core';
|
|
2
2
|
import type { Ctx } from '@milkdown/ctx';
|
|
3
3
|
import type { InlineImageConfig } from '@milkdown/components/image-inline';
|
|
4
|
-
import type
|
|
4
|
+
import { type DeriveFileInfosFromStorageIds } from '~/utils/fileInfoResolver';
|
|
5
|
+
import type { OnImageUploadFn } from '../richTextArea.types';
|
|
5
6
|
type UseRichTextImageUploadParams = {
|
|
6
7
|
disabled: boolean;
|
|
7
8
|
get: () => Editor | undefined;
|
|
8
9
|
updateToolbarState: (ctx: Ctx) => void;
|
|
9
|
-
latestOnUploadRef: React.RefObject<
|
|
10
|
+
latestOnUploadRef: React.RefObject<OnImageUploadFn | undefined> | undefined;
|
|
11
|
+
deriveFileInfosFromStorageIds?: DeriveFileInfosFromStorageIds;
|
|
10
12
|
sasToRefMap: React.RefObject<Map<string, string>>;
|
|
11
13
|
pendingImageSelectionRef: React.RefObject<{
|
|
12
14
|
from: number;
|
|
@@ -21,5 +23,5 @@ type UseRichTextImageUploadReturn = {
|
|
|
21
23
|
success: boolean;
|
|
22
24
|
}>;
|
|
23
25
|
};
|
|
24
|
-
export declare const useRichTextImageUpload: ({ disabled, get, updateToolbarState, latestOnUploadRef, sasToRefMap, pendingImageSelectionRef, }: UseRichTextImageUploadParams) => UseRichTextImageUploadReturn;
|
|
26
|
+
export declare const useRichTextImageUpload: ({ disabled, get, updateToolbarState, latestOnUploadRef, deriveFileInfosFromStorageIds, sasToRefMap, pendingImageSelectionRef, }: UseRichTextImageUploadParams) => UseRichTextImageUploadReturn;
|
|
25
27
|
export {};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { CmdKey } from '@milkdown/core';
|
|
2
|
-
import { MaybePromise } from '~/utils/utility.types';
|
|
3
2
|
export type RichTextAreaProps = {
|
|
4
3
|
value: string | null | undefined;
|
|
5
4
|
onChange: (markdown: string) => void;
|
|
@@ -12,25 +11,29 @@ export type RichTextAreaProps = {
|
|
|
12
11
|
required?: boolean | string;
|
|
13
12
|
error?: string;
|
|
14
13
|
/** Optional upload handler that returns a display src and optional stable image ref. */
|
|
15
|
-
onImageUpload?:
|
|
14
|
+
onImageUpload?: OnImageUploadFn;
|
|
16
15
|
/** Optional remove handler for deleting persisted images by stable ref. */
|
|
17
16
|
onImageRemove?: (ref: string) => Promise<void>;
|
|
18
|
-
/** Optional resolver that maps image refs in markdown to renderable image sources. */
|
|
19
|
-
resolveImageRefs?: (refs?: string[]) => MaybePromise<Record<string, ResolvedImageRef>>;
|
|
20
17
|
};
|
|
21
18
|
export type ToolbarCommand<T = unknown> = {
|
|
22
19
|
key: CmdKey<T>;
|
|
23
20
|
value?: T;
|
|
24
21
|
};
|
|
25
|
-
export type
|
|
26
|
-
|
|
22
|
+
export type ResolvedImageRef = {
|
|
23
|
+
storageId: string;
|
|
24
|
+
previewUri: string;
|
|
27
25
|
alt?: string;
|
|
28
26
|
};
|
|
29
|
-
export type ResolvedImageRef = ImageMarkdown | undefined;
|
|
30
27
|
export type ImageUploadResult = {
|
|
31
28
|
src: string;
|
|
32
29
|
ref?: string;
|
|
33
30
|
alt?: string;
|
|
34
31
|
};
|
|
32
|
+
export type FileUploaderStyleImageUploadResult = {
|
|
33
|
+
storageId: string;
|
|
34
|
+
success: boolean;
|
|
35
|
+
error?: string;
|
|
36
|
+
};
|
|
37
|
+
export type OnImageUploadFn = (file: File) => Promise<ImageUploadResult | FileUploaderStyleImageUploadResult | string | null>;
|
|
35
38
|
export type ImageInsertHandler = (file: File) => void;
|
|
36
39
|
export type UploadImageFn = (file: File) => Promise<ImageUploadResult | string | null>;
|
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type ResolvedImageRef = {
|
|
3
|
-
src: string;
|
|
4
|
-
alt?: string;
|
|
5
|
-
} | string | null | undefined;
|
|
1
|
+
import { type DeriveFileInfosFromStorageIds } from '~/utils/fileInfoResolver';
|
|
6
2
|
export declare const getImageRefsFromMarkdown: (markdown: string) => string[];
|
|
7
|
-
export declare const convertFromRefToImage: (markdown: string,
|
|
3
|
+
export declare const convertFromRefToImage: (markdown: string, deriveFileInfosFromStorageIds: DeriveFileInfosFromStorageIds, urlToRefMap?: Map<string, string>, previousRefToUrlMap?: Map<string, string>) => Promise<string>;
|
|
8
4
|
export declare const replaceImageUrlsWithRefs: (markdown: string, sasToRefMap: Map<string, string>) => string;
|
|
9
|
-
export {};
|
package/dist/src/main.d.ts
CHANGED
|
@@ -46,6 +46,7 @@ export { DateTimePicker, type DateTimePickerProps } from './components/kystverke
|
|
|
46
46
|
export { FileUploader, type FileUploaderProps, type ExistingFilesProviderItem, } from './components/kystverket/FileUploader/FileUploader';
|
|
47
47
|
export { FileUploaderContext, type FileUploaderContextProps, } from './components/kystverket/FileUploader/FileUploader.context';
|
|
48
48
|
export type * from './components/kystverket/FileUploader/FileUploader.types';
|
|
49
|
+
export type { DeriveFileInfosFromStorageIds } from './utils/fileInfoResolver';
|
|
49
50
|
export { default as CardTitle, type CardTitleProps } from './components/designsystemet/CardTitle/CardTitle';
|
|
50
51
|
export { Button } from './components/designsystemet/Button/Button';
|
|
51
52
|
export type { ButtonProps } from './components/designsystemet/Button/Button';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type ExtraFileInfo } from '~/components/kystverket/FileUploader/FileUploader.types';
|
|
2
|
+
import { type MaybePromise } from '~/utils/utility.types';
|
|
3
|
+
export type DeriveFileInfosFromStorageIds = (storageIds: string[]) => MaybePromise<ExtraFileInfo[]>;
|
|
4
|
+
export declare const createStorageIdToExtraFileInfoMap: (extraFileInfos: ExtraFileInfo[]) => Map<string, ExtraFileInfo>;
|
|
5
|
+
export declare const getExtraFileInfoPreviewUri: (extraFileInfo: ExtraFileInfo | undefined, options?: {
|
|
6
|
+
preferThumbnail?: boolean;
|
|
7
|
+
}) => string | undefined;
|