@kystverket/styrbord 1.7.1 → 1.7.3
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 -14
- package/dist/src/components/designsystemet/Suggestion/Suggestion.d.ts +17 -0
- package/dist/src/components/kystverket/MarkdownToReact/markdownToReact.d.ts +6 -1
- package/dist/src/components/kystverket/MarkdownToReact/markdownToReact.stories.d.ts +2 -1
- package/dist/src/components/kystverket/RichTextArea/components/Toolbar/toolbar.d.ts +3 -1
- package/dist/src/components/kystverket/RichTextArea/components/Toolbar/toolbar.stories.d.ts +3 -1
- package/dist/src/components/kystverket/RichTextArea/hooks/useRichTextCommands.d.ts +22 -0
- package/dist/src/components/kystverket/RichTextArea/hooks/useRichTextImageUpload.d.ts +21 -0
- package/dist/src/components/kystverket/RichTextArea/richTextArea.d.ts +2 -12
- package/dist/src/components/kystverket/RichTextArea/richTextArea.editor.d.ts +21 -0
- package/dist/src/components/kystverket/RichTextArea/richTextArea.stories.d.ts +11 -0
- package/dist/src/components/kystverket/RichTextArea/richTextArea.types.d.ts +31 -0
- package/dist/src/components/kystverket/RichTextArea/utils/linkUtils.d.ts +1 -0
- package/dist/src/main.d.ts +3 -2
- package/dist/style.css +1 -1
- package/dist/style.js +1936 -1790
- package/dist/style.umd.cjs +7 -7
- package/package.json +1 -1
- package/dist/src/components/designsystemet/Suggestion/Suggestion.stories.d.ts +0 -8
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-05-22 -- v1.7.2
|
|
45
|
+
|
|
46
|
+
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.
|
|
47
|
+
|
|
44
48
|
### 2026-05-19 -- v1.7.0
|
|
45
49
|
|
|
46
50
|
Etter mange problemer med implementasjon og styling av en DatePicker har vi gått til en native datepicker. Noen attributter på datepicker er ikke lenger nødvendige eller tilgjengelige.
|
|
@@ -148,17 +152,3 @@ Arbeid for å gjøre Styrbord mindre forskjellig fra Designsystemet. Dette gjør
|
|
|
148
152
|
- Tillater ikke lenger å sende en boolsk verdi til error attributter i input-komponenter.
|
|
149
153
|
|
|
150
154
|
Komponentene `<Button>`, `<Tabs>`, `<Select>`, `<NumberInput>`, `<TextInput>` og `<TextArea>` overskriver fortsatt noen Designsystem-komponenter med mer eller mindre inkompatible interface.
|
|
151
|
-
|
|
152
|
-
### 2025-06-17
|
|
153
|
-
|
|
154
|
-
Vi har fjernet alle egne tittelkomponenter og henviser istedet til Designsystemets `Heading`-komponent.
|
|
155
|
-
|
|
156
|
-
- `Display size="lg"` ➡️ `Heading data-size="2xl"`
|
|
157
|
-
- `Display size="md"` ➡️ `Heading data-size="xl"`
|
|
158
|
-
- `Display size="sm"` ➡️ `Heading data-size="lg"`
|
|
159
|
-
- `Headline size="lg"` ➡️ `Heading data-size="md"`
|
|
160
|
-
- `Headline size="md"` ➡️ `Heading data-size="sm"`
|
|
161
|
-
- `Headline size="sm"` ➡️ `Heading data-size="xs"`
|
|
162
|
-
- `Title size="lg"` ➡️ `Heading data-size="sm"`
|
|
163
|
-
- `Title size="md"` ➡️ `Heading data-size="xs"`
|
|
164
|
-
- `Title size="sm"` ➡️ `Heading data-size="2xs"`
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { EXPERIMENTAL_Suggestion as DsSuggestion, type SuggestionProps as DsSuggestionProps } from '@digdir/designsystemet-react';
|
|
2
|
+
export type SuggestionProps = {
|
|
3
|
+
label?: string;
|
|
4
|
+
required?: boolean | string;
|
|
5
|
+
optional?: boolean | string;
|
|
6
|
+
error?: string;
|
|
7
|
+
} & DsSuggestionProps;
|
|
8
|
+
declare function SuggestionRoot({ children, label, className, required, optional, error, ...props }: SuggestionProps): React.JSX.Element;
|
|
9
|
+
type SuggestionComponent = typeof SuggestionRoot & {
|
|
10
|
+
Clear: typeof DsSuggestion.Clear;
|
|
11
|
+
Empty: typeof DsSuggestion.Empty;
|
|
12
|
+
Input: typeof DsSuggestion.Input;
|
|
13
|
+
List: typeof DsSuggestion.List;
|
|
14
|
+
Option: typeof DsSuggestion.Option;
|
|
15
|
+
};
|
|
16
|
+
export declare const Suggestion: SuggestionComponent;
|
|
17
|
+
export {};
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
export type MarkdownToReactProps = {
|
|
2
2
|
markdown: string;
|
|
3
|
+
resolveImageRef?: (ref: string) => ResolvedImageRef;
|
|
3
4
|
};
|
|
4
|
-
|
|
5
|
+
export type ResolvedImageRef = {
|
|
6
|
+
src: string;
|
|
7
|
+
alt?: string;
|
|
8
|
+
} | undefined;
|
|
9
|
+
declare const MarkdownToReact: ({ markdown, resolveImageRef }: MarkdownToReactProps) => React.JSX.Element;
|
|
5
10
|
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 }: import("./markdownToReact").MarkdownToReactProps) => React.JSX.Element;
|
|
4
|
+
component: ({ markdown, resolveImageRef }: 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: {
|
|
@@ -19,3 +19,4 @@ export declare const Lists: Story;
|
|
|
19
19
|
export declare const CodeBlock: Story;
|
|
20
20
|
export declare const Links: Story;
|
|
21
21
|
export declare const Combined: Story;
|
|
22
|
+
export declare const ResolveImageRefExample: Story;
|
|
@@ -7,6 +7,7 @@ type ToolbarProps = {
|
|
|
7
7
|
isBulletListActive: boolean;
|
|
8
8
|
isOrderedListActive: boolean;
|
|
9
9
|
isLinkActive: boolean;
|
|
10
|
+
canUploadImage?: boolean;
|
|
10
11
|
selectedFormat: BlockType;
|
|
11
12
|
linkPopoverTarget?: string;
|
|
12
13
|
onBold: () => void;
|
|
@@ -17,6 +18,7 @@ type ToolbarProps = {
|
|
|
17
18
|
onRedo: () => void;
|
|
18
19
|
onFormatChange: (format: BlockType) => void;
|
|
19
20
|
onLink: () => void;
|
|
21
|
+
onImageUpload?: () => void;
|
|
20
22
|
};
|
|
21
|
-
export declare const Toolbar: ({ disabled, isBoldActive, isItalicActive, isBulletListActive, isOrderedListActive, isLinkActive, selectedFormat, linkPopoverTarget, onBulletList, onOrderedList, onBold, onItalic, onUndo, onRedo, onFormatChange, onLink, }: ToolbarProps) => React.JSX.Element;
|
|
23
|
+
export declare const Toolbar: ({ disabled, isBoldActive, isItalicActive, isBulletListActive, isOrderedListActive, isLinkActive, canUploadImage, selectedFormat, linkPopoverTarget, onBulletList, onOrderedList, onBold, onItalic, onUndo, onRedo, onFormatChange, onLink, onImageUpload, }: ToolbarProps) => React.JSX.Element;
|
|
22
24
|
export {};
|
|
@@ -2,13 +2,14 @@ import type { StoryObj } from '@storybook/react-vite';
|
|
|
2
2
|
import { type BlockType } from './toolbar';
|
|
3
3
|
declare const meta: {
|
|
4
4
|
title: string;
|
|
5
|
-
component: ({ disabled, isBoldActive, isItalicActive, isBulletListActive, isOrderedListActive, isLinkActive, selectedFormat, linkPopoverTarget, onBulletList, onOrderedList, onBold, onItalic, onUndo, onRedo, onFormatChange, onLink, }: {
|
|
5
|
+
component: ({ disabled, isBoldActive, isItalicActive, isBulletListActive, isOrderedListActive, isLinkActive, canUploadImage, selectedFormat, linkPopoverTarget, onBulletList, onOrderedList, onBold, onItalic, onUndo, onRedo, onFormatChange, onLink, onImageUpload, }: {
|
|
6
6
|
disabled?: boolean;
|
|
7
7
|
isBoldActive: boolean;
|
|
8
8
|
isItalicActive: boolean;
|
|
9
9
|
isBulletListActive: boolean;
|
|
10
10
|
isOrderedListActive: boolean;
|
|
11
11
|
isLinkActive: boolean;
|
|
12
|
+
canUploadImage?: boolean;
|
|
12
13
|
selectedFormat: BlockType;
|
|
13
14
|
linkPopoverTarget?: string;
|
|
14
15
|
onBold: () => void;
|
|
@@ -19,6 +20,7 @@ declare const meta: {
|
|
|
19
20
|
onRedo: () => void;
|
|
20
21
|
onFormatChange: (format: BlockType) => void;
|
|
21
22
|
onLink: () => void;
|
|
23
|
+
onImageUpload?: () => void;
|
|
22
24
|
}) => React.JSX.Element;
|
|
23
25
|
decorators: ((Story: import("storybook/internal/csf").PartialStoryFn, context: import("storybook/internal/csf").StoryContext) => React.JSX.Element)[];
|
|
24
26
|
tags: string[];
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Editor } from '@milkdown/core';
|
|
2
|
+
import type { Ctx } from '@milkdown/ctx';
|
|
3
|
+
import type { ToolbarCommand } from '../richTextArea.types';
|
|
4
|
+
import type { BlockType } from '../components/Toolbar/toolbar';
|
|
5
|
+
type UseRichTextCommandsParams = {
|
|
6
|
+
disabled: boolean;
|
|
7
|
+
get: () => Editor | undefined;
|
|
8
|
+
updateToolbarState: (ctx: Ctx) => void;
|
|
9
|
+
};
|
|
10
|
+
type UseRichTextCommandsReturn = {
|
|
11
|
+
executeInEditor: (fn: (ctx: Ctx) => void) => void;
|
|
12
|
+
runCommand: <T>(command: ToolbarCommand<T>) => void;
|
|
13
|
+
runCommands: (commandsToRun: ToolbarCommand<unknown>[]) => void;
|
|
14
|
+
toggleList: (params: {
|
|
15
|
+
isTargetListActive: boolean;
|
|
16
|
+
isOtherListActive: boolean;
|
|
17
|
+
wrapCommand: ToolbarCommand<unknown>;
|
|
18
|
+
}) => void;
|
|
19
|
+
handleFormatChange: (format: BlockType) => void;
|
|
20
|
+
};
|
|
21
|
+
export declare const useRichTextCommands: ({ disabled, get, updateToolbarState, }: UseRichTextCommandsParams) => UseRichTextCommandsReturn;
|
|
22
|
+
export { toggleStrongCommand, toggleEmphasisCommand, wrapInBulletListCommand, wrapInOrderedListCommand, } from '@milkdown/preset-commonmark';
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Editor } from '@milkdown/core';
|
|
2
|
+
import type { Ctx } from '@milkdown/ctx';
|
|
3
|
+
import type { InlineImageConfig } from '@milkdown/components/image-inline';
|
|
4
|
+
import type { UploadImageFn } from '../richTextArea.types';
|
|
5
|
+
type UseRichTextImageUploadParams = {
|
|
6
|
+
disabled: boolean;
|
|
7
|
+
get: () => Editor | undefined;
|
|
8
|
+
updateToolbarState: (ctx: Ctx) => void;
|
|
9
|
+
latestOnUploadRef: React.RefObject<UploadImageFn | undefined> | undefined;
|
|
10
|
+
sasToRefMap: React.RefObject<Map<string, string>>;
|
|
11
|
+
};
|
|
12
|
+
type UseRichTextImageUploadReturn = {
|
|
13
|
+
isUploadingImage: boolean;
|
|
14
|
+
inlineImageConfig: (config: InlineImageConfig) => InlineImageConfig;
|
|
15
|
+
insertImageFromFile: (file: File) => void;
|
|
16
|
+
handleImageFileInputChange: (event: React.ChangeEvent<HTMLInputElement>) => Promise<{
|
|
17
|
+
success: boolean;
|
|
18
|
+
}>;
|
|
19
|
+
};
|
|
20
|
+
export declare const useRichTextImageUpload: ({ disabled, get, updateToolbarState, latestOnUploadRef, sasToRefMap, }: UseRichTextImageUploadParams) => UseRichTextImageUploadReturn;
|
|
21
|
+
export {};
|
|
@@ -1,14 +1,4 @@
|
|
|
1
1
|
import '@milkdown/prose/view/style/prosemirror.css';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
onChange: (markdown: string) => void;
|
|
5
|
-
placeholder?: string;
|
|
6
|
-
disabled?: boolean;
|
|
7
|
-
className?: string;
|
|
8
|
-
label?: string;
|
|
9
|
-
description?: string | React.ReactNode;
|
|
10
|
-
optional?: boolean | string | undefined;
|
|
11
|
-
required?: boolean | string | undefined;
|
|
12
|
-
error?: string;
|
|
13
|
-
};
|
|
2
|
+
import type { RichTextAreaProps } from './richTextArea.types';
|
|
3
|
+
export type { RichTextAreaProps };
|
|
14
4
|
export declare const RichTextArea: ({ className, ...props }: RichTextAreaProps) => React.JSX.Element;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { InlineImageConfig } from '@milkdown/components/image-inline';
|
|
2
|
+
import type { EditorView } from '@milkdown/prose/view';
|
|
3
|
+
import type { ImageInsertHandler, UploadImageFn } from './richTextArea.types';
|
|
4
|
+
export declare const normalizeMarkdownBreakTags: (value: string) => string;
|
|
5
|
+
export declare const richTextCommonmarkPlugins: import("@milkdown/ctx").MilkdownPlugin[];
|
|
6
|
+
export declare const richTextEditorPlugins: readonly [import("@milkdown/ctx").MilkdownPlugin[], import("@milkdown/ctx").MilkdownPlugin[], import("@milkdown/ctx").MilkdownPlugin[], import("@milkdown/ctx").MilkdownPlugin];
|
|
7
|
+
export declare const hasImageFile: (files: ArrayLike<File> | undefined) => File | null;
|
|
8
|
+
export declare const createRichTextAreaEditorEditable: (disabled: boolean) => () => boolean;
|
|
9
|
+
export declare const handleRichTextAreaEditorClick: (_view: EditorView, event: MouseEvent) => boolean;
|
|
10
|
+
export declare const handleRichTextAreaEditorKeydown: (view: EditorView, event: KeyboardEvent) => boolean;
|
|
11
|
+
export declare const createRichTextAreaEditorPaste: (canUploadImage: boolean, insertImageFromFile: ImageInsertHandler) => (_view: EditorView, event: ClipboardEvent) => boolean;
|
|
12
|
+
export declare const createRichTextAreaEditorDrop: (canUploadImage: boolean, insertImageFromFile: ImageInsertHandler) => (_view: EditorView, event: DragEvent) => boolean;
|
|
13
|
+
export declare const createRichTextAreaInlineImageUpload: (uploadImage: UploadImageFn, sasToRefMap: Map<string, string>) => (file: File) => Promise<string>;
|
|
14
|
+
export declare const createRichTextAreaInlineImageConfig: (uploadImage: UploadImageFn, sasToRefMap: Map<string, string>) => (config: InlineImageConfig) => {
|
|
15
|
+
onUpload: (file: File) => Promise<string>;
|
|
16
|
+
imageIcon: string | undefined;
|
|
17
|
+
uploadButton: string | undefined;
|
|
18
|
+
confirmButton: string | undefined;
|
|
19
|
+
uploadPlaceholderText: string;
|
|
20
|
+
proxyDomURL?: (url: string) => Promise<string> | string;
|
|
21
|
+
};
|
|
@@ -11,3 +11,14 @@ type Story = StoryObj<typeof meta>;
|
|
|
11
11
|
export declare const Default: Story;
|
|
12
12
|
export declare const Disabled: Story;
|
|
13
13
|
export declare const WithError: Story;
|
|
14
|
+
/**
|
|
15
|
+
* Demonstrates stable image references in markdown.
|
|
16
|
+
*
|
|
17
|
+
* `onUpload` returns both:
|
|
18
|
+
* - `src` — a data URL used by the editor to display the image immediately
|
|
19
|
+
* - `ref` — a stable opaque ID (e.g. Azure blob path / UUID) stored in the markdown instead of the SAS URL
|
|
20
|
+
*
|
|
21
|
+
* The `onChange` output will contain `` rather than the raw data URL,
|
|
22
|
+
* which is what a `MarkdownToReact` or similar renderers would receive where you implement a resolver function to provide a SAS URI or similar.
|
|
23
|
+
*/
|
|
24
|
+
export declare const WithImageRef: Story;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { CmdKey } from '@milkdown/core';
|
|
2
|
+
export type RichTextAreaProps = {
|
|
3
|
+
value: string | null | undefined;
|
|
4
|
+
onChange: (markdown: string) => void;
|
|
5
|
+
onUpload?: UploadImageFn;
|
|
6
|
+
placeholder?: string;
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
className?: string;
|
|
9
|
+
label?: string;
|
|
10
|
+
description?: string | React.ReactNode;
|
|
11
|
+
optional?: boolean | string;
|
|
12
|
+
required?: boolean | string;
|
|
13
|
+
error?: string;
|
|
14
|
+
};
|
|
15
|
+
export type ToolbarCommand<T = unknown> = {
|
|
16
|
+
key: CmdKey<T>;
|
|
17
|
+
value?: T;
|
|
18
|
+
};
|
|
19
|
+
export type ImageMarkdown = {
|
|
20
|
+
src: string;
|
|
21
|
+
alt?: string;
|
|
22
|
+
title?: string;
|
|
23
|
+
};
|
|
24
|
+
export type ImageUploadResult = {
|
|
25
|
+
src: string;
|
|
26
|
+
ref?: string;
|
|
27
|
+
alt?: string;
|
|
28
|
+
title?: string;
|
|
29
|
+
};
|
|
30
|
+
export type ImageInsertHandler = (file: File) => void;
|
|
31
|
+
export type UploadImageFn = (file: File) => Promise<ImageUploadResult | string | null>;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { EditorState } from '@milkdown/prose/state';
|
|
2
2
|
export declare const normalizeHref: (rawHref: string) => string;
|
|
3
|
+
export declare const replaceUrlsWithRefs: (markdown: string, sasToRefMap: Map<string, string>) => string;
|
|
3
4
|
export declare const getSelectionLinkRange: (state: EditorState) => {
|
|
4
5
|
from: number;
|
|
5
6
|
to: number;
|
package/dist/src/main.d.ts
CHANGED
|
@@ -71,7 +71,8 @@ export { Avatar } from './components/designsystemet/Avatar/Avatar';
|
|
|
71
71
|
export type { AvatarProps } from './components/designsystemet/Avatar/Avatar';
|
|
72
72
|
export { IdProvider, useIdProvider } from './utils/idContext';
|
|
73
73
|
export { SlotDialog, type SlotDialogProps } from './components/kystverket/SlotDialog/SlotDialog';
|
|
74
|
-
export {
|
|
74
|
+
export { Suggestion } from './components/designsystemet/Suggestion/Suggestion';
|
|
75
|
+
export type { SuggestionProps } from './components/designsystemet/Suggestion/Suggestion';
|
|
75
76
|
export { RovingFocusItem, RovingFocusRoot, omit, useCheckboxGroup, useDebounceCallback, useIsomorphicLayoutEffect, useMediaQuery, usePagination, useRadioGroup, useSynchronizedAnimation, } from '@digdir/designsystemet-react';
|
|
76
77
|
export type { Size, UseRadioGroupProps, UseCheckboxGroupProps, UsePaginationProps, MergeRight, LabelRequired, } from '@digdir/designsystemet-react';
|
|
77
78
|
export type { BadgePositionProps, BadgeProps } from '@digdir/designsystemet-react';
|
|
@@ -126,7 +127,7 @@ export type { SkipLinkProps } from '@digdir/designsystemet-react';
|
|
|
126
127
|
export { SkipLink } from '@digdir/designsystemet-react';
|
|
127
128
|
export type { SpinnerProps } from '@digdir/designsystemet-react';
|
|
128
129
|
export { Spinner } from '@digdir/designsystemet-react';
|
|
129
|
-
export type { SuggestionClearProps, SuggestionEmptyProps, SuggestionInputProps, SuggestionItem, SuggestionListProps, SuggestionMultipleProps, SuggestionOptionProps,
|
|
130
|
+
export type { SuggestionClearProps, SuggestionEmptyProps, SuggestionInputProps, SuggestionItem, SuggestionListProps, SuggestionMultipleProps, SuggestionOptionProps, SuggestionSingleProps, } from '@digdir/designsystemet-react';
|
|
130
131
|
export { EXPERIMENTAL_Suggestion, EXPERIMENTAL_SuggestionClear, EXPERIMENTAL_SuggestionEmpty, EXPERIMENTAL_SuggestionInput, EXPERIMENTAL_SuggestionList, EXPERIMENTAL_SuggestionOption, } from '@digdir/designsystemet-react';
|
|
131
132
|
export type { SwitchProps } from '@digdir/designsystemet-react';
|
|
132
133
|
export { Switch } from '@digdir/designsystemet-react';
|