@kystverket/styrbord 2.11.0 → 2.12.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.
@@ -13,6 +13,8 @@ type ToolbarProps = {
13
13
  linkPopoverTarget?: string;
14
14
  canUploadImage?: boolean;
15
15
  showToolbar?: boolean;
16
+ allowHeading?: boolean;
17
+ allowLink?: boolean;
16
18
  onBold: () => void;
17
19
  onItalic: () => void;
18
20
  onBulletList: () => void;
@@ -24,5 +26,5 @@ type ToolbarProps = {
24
26
  onImageUpload?: () => void;
25
27
  };
26
28
  export declare const getToolbarItems: (toolbar: Element) => HTMLElement[];
27
- export declare const Toolbar: ({ ref, disabled, isBoldActive, isItalicActive, isBulletListActive, isOrderedListActive, isLinkActive, selectedFormat, linkPopoverTarget, canUploadImage, onBulletList, onOrderedList, onBold, onItalic, onUndo, onRedo, onFormatChange, onLink, onImageUpload, showToolbar, }: ToolbarProps) => React.JSX.Element | undefined;
29
+ export declare const Toolbar: ({ ref, disabled, isBoldActive, isItalicActive, isBulletListActive, isOrderedListActive, isLinkActive, selectedFormat, linkPopoverTarget, canUploadImage, onBulletList, onOrderedList, onBold, onItalic, onUndo, onRedo, onFormatChange, onLink, onImageUpload, showToolbar, allowHeading, allowLink, }: ToolbarProps) => React.JSX.Element | undefined;
28
30
  export {};
@@ -2,7 +2,7 @@ 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: ({ ref, disabled, isBoldActive, isItalicActive, isBulletListActive, isOrderedListActive, isLinkActive, selectedFormat, linkPopoverTarget, canUploadImage, onBulletList, onOrderedList, onBold, onItalic, onUndo, onRedo, onFormatChange, onLink, onImageUpload, showToolbar, }: {
5
+ component: ({ ref, disabled, isBoldActive, isItalicActive, isBulletListActive, isOrderedListActive, isLinkActive, selectedFormat, linkPopoverTarget, canUploadImage, onBulletList, onOrderedList, onBold, onItalic, onUndo, onRedo, onFormatChange, onLink, onImageUpload, showToolbar, allowHeading, allowLink, }: {
6
6
  ref?: React.Ref<HTMLDivElement>;
7
7
  disabled?: boolean;
8
8
  isBoldActive: boolean;
@@ -14,6 +14,8 @@ declare const meta: {
14
14
  linkPopoverTarget?: string;
15
15
  canUploadImage?: boolean;
16
16
  showToolbar?: boolean;
17
+ allowHeading?: boolean;
18
+ allowLink?: boolean;
17
19
  onBold: () => void;
18
20
  onItalic: () => void;
19
21
  onBulletList: () => void;
@@ -1,11 +1,17 @@
1
1
  import type { InlineImageConfig } from '@milkdown/components/image-inline';
2
+ import type { MilkdownPlugin } from '@milkdown/ctx';
2
3
  import type { Node as ProseNode } from '@milkdown/prose/model';
3
4
  import { Plugin } from '@milkdown/prose/state';
4
5
  import type { EditorView } from '@milkdown/prose/view';
5
6
  import type { ImageInsertHandler, UploadImageFn } from './richTextArea.types';
6
7
  export declare const normalizeMarkdownBreakTags: (value: string) => string;
7
- export declare const richTextCommonmarkPlugins: import("@milkdown/ctx").MilkdownPlugin[];
8
- export declare const richTextEditorPlugins: readonly [import("@milkdown/ctx").MilkdownPlugin[], import("@milkdown/ctx").MilkdownPlugin[], import("@milkdown/ctx").MilkdownPlugin[], import("@milkdown/ctx").MilkdownPlugin];
8
+ export declare const richTextCommonmarkPlugins: MilkdownPlugin[];
9
+ export type RichTextFeatures = {
10
+ allowHeading: boolean;
11
+ allowLink: boolean;
12
+ };
13
+ export declare const createRichTextCommonmarkPlugins: (features: RichTextFeatures) => MilkdownPlugin[];
14
+ export declare const richTextEditorPlugins: readonly [MilkdownPlugin[], MilkdownPlugin[], MilkdownPlugin[], MilkdownPlugin];
9
15
  export declare const hasImageFile: (files: ArrayLike<File> | undefined) => File | null;
10
16
  export declare const createRichTextAreaEditorEditable: (disabled: boolean) => () => boolean;
11
17
  export declare const handleRichTextAreaEditorClick: (_view: EditorView, event: MouseEvent) => boolean;
@@ -1,6 +1,7 @@
1
1
  import { Editor } from '@milkdown/core';
2
2
  import type { InlineImageConfig } from '@milkdown/components/image-inline';
3
3
  import type { Ctx } from '@milkdown/ctx';
4
+ import type { RichTextFeatures } from './richTextArea.editor';
4
5
  type CreateRichTextAreaEditorParams = {
5
6
  root: HTMLElement;
6
7
  disabled: boolean;
@@ -10,6 +11,7 @@ type CreateRichTextAreaEditorParams = {
10
11
  /** Whether Alt+F10 has a toolbar item to go to; without one, Tab must be allowed to leave a list. */
11
12
  canReachToolbar: () => boolean;
12
13
  canUploadImage: boolean;
14
+ features: RichTextFeatures;
13
15
  dispatchImageFromFile: (file: File) => void;
14
16
  updateInlineImageConfig: (config: InlineImageConfig) => InlineImageConfig;
15
17
  updateToolbarState: (ctx: Ctx) => void;
@@ -21,5 +23,5 @@ type CreateRichTextAreaEditorParams = {
21
23
  getMaxLength: () => number | undefined;
22
24
  isExternalUpdate: () => boolean;
23
25
  };
24
- export declare const createRichTextAreaEditor: ({ root, disabled, editorMarkdown, describedBy, canReachToolbar, canUploadImage, dispatchImageFromFile, updateInlineImageConfig, updateToolbarState, onMarkdownUpdated, onEmptyChange, toValue, onValueLengthChange, getMaxLength, isExternalUpdate, }: CreateRichTextAreaEditorParams) => Editor;
26
+ export declare const createRichTextAreaEditor: ({ root, disabled, editorMarkdown, describedBy, canReachToolbar, canUploadImage, features, dispatchImageFromFile, updateInlineImageConfig, updateToolbarState, onMarkdownUpdated, onEmptyChange, toValue, onValueLengthChange, getMaxLength, isExternalUpdate, }: CreateRichTextAreaEditorParams) => Editor;
25
27
  export {};
@@ -18,6 +18,8 @@ declare const meta: {
18
18
  maxLength?: number | undefined;
19
19
  bottomToolbar?: React.ReactNode;
20
20
  showToolbar?: boolean | undefined;
21
+ allowHeading?: boolean | undefined;
22
+ allowLink?: boolean | undefined;
21
23
  onImageUpload?: import("./richTextArea.types").OnImageUploadFn | undefined;
22
24
  onImageRemove?: ((ref: string) => Promise<void>) | undefined;
23
25
  }>) => React.JSX.Element))[];
@@ -28,6 +30,7 @@ type Story = StoryObj<typeof meta>;
28
30
  export declare const Default: Story;
29
31
  export declare const Disabled: Story;
30
32
  export declare const WithCodeFormatting: Story;
33
+ export declare const WithoutHeadingsAndLinks: Story;
31
34
  export declare const WithError: Story;
32
35
  export declare const WithMaxLength: Story;
33
36
  export declare const WithBottomToolbar: Story;
@@ -18,6 +18,10 @@ export type RichTextAreaProps = {
18
18
  bottomToolbar?: ReactNode;
19
19
  /** Optional upload handler that returns a display src and optional stable image ref. */
20
20
  showToolbar?: boolean;
21
+ /** Allow headings. When false, the format menu is hidden and headings in the value load as paragraphs. Defaults to true. */
22
+ allowHeading?: boolean;
23
+ /** Allow links. When false, the link button is hidden and links in the value load as their text. Defaults to true. */
24
+ allowLink?: boolean;
21
25
  onImageUpload?: OnImageUploadFn;
22
26
  /** Optional remove handler for deleting persisted images by stable ref. */
23
27
  onImageRemove?: (ref: string) => Promise<void>;