@mittwald/flow-react-components 1.3.0-next.23 → 1.3.0-next.24

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 (27) hide show
  1. package/dist/assets/component-index.json +1 -1
  2. package/dist/assets/doc-properties.json +1 -1
  3. package/dist/css/all-layered.css +1 -1
  4. package/dist/css/all.css +1 -1
  5. package/dist/js/_virtual/_24.locale.mjs +10 -2
  6. package/dist/js/packages/components/src/components/MarkdownEditor/MarkdownEditor.mjs +16 -3
  7. package/dist/js/packages/components/src/components/MarkdownEditor/MarkdownEditor.mjs.map +1 -1
  8. package/dist/js/packages/components/src/components/MarkdownEditor/MarkdownEditor.module.mjs +4 -2
  9. package/dist/js/packages/components/src/components/MarkdownEditor/MarkdownEditor.module.mjs.map +1 -1
  10. package/dist/js/packages/components/src/components/MarkdownEditor/components/AttachmentButton.mjs +47 -0
  11. package/dist/js/packages/components/src/components/MarkdownEditor/components/AttachmentButton.mjs.map +1 -0
  12. package/dist/js/packages/components/src/components/MarkdownEditor/components/Toolbar.mjs +21 -20
  13. package/dist/js/packages/components/src/components/MarkdownEditor/components/Toolbar.mjs.map +1 -1
  14. package/dist/js/packages/components/src/components/MarkdownEditor/components/ToolbarButton.mjs +1 -1
  15. package/dist/js/packages/components/src/components/MarkdownEditor/components/ToolbarButton.mjs.map +1 -1
  16. package/dist/js/packages/components/src/components/MarkdownEditor/lib/fileUpload.mjs +73 -0
  17. package/dist/js/packages/components/src/components/MarkdownEditor/lib/fileUpload.mjs.map +1 -0
  18. package/dist/js/packages/components/src/components/MarkdownEditor/lib/useFileUpload.mjs +141 -0
  19. package/dist/js/packages/components/src/components/MarkdownEditor/lib/useFileUpload.mjs.map +1 -0
  20. package/dist/types/components/MarkdownEditor/MarkdownEditor.d.ts +20 -0
  21. package/dist/types/components/MarkdownEditor/components/AttachmentButton.d.ts +1 -0
  22. package/dist/types/components/MarkdownEditor/components/Toolbar.d.ts +11 -2
  23. package/dist/types/components/MarkdownEditor/components/ToolbarButton.d.ts +8 -2
  24. package/dist/types/components/MarkdownEditor/index.d.ts +1 -1
  25. package/dist/types/components/MarkdownEditor/lib/fileUpload.d.ts +19 -0
  26. package/dist/types/components/MarkdownEditor/lib/useFileUpload.d.ts +1 -0
  27. package/package.json +9 -9
@@ -1,13 +1,33 @@
1
1
  import { ComponentType } from 'react';
2
2
  import { MarkdownProps } from '../Markdown';
3
3
  import { TextAreaProps } from '../TextArea';
4
+ import { MarkdownEditorUpload } from './lib/fileUpload';
4
5
  export type MarkdownEditorMode = "editor" | "preview";
6
+ export type { MarkdownEditorUpload };
5
7
  export interface MarkdownEditorProps extends TextAreaProps, Pick<MarkdownProps, "headingOffset"> {
6
8
  /**
7
9
  * Allows replacing the markdown preview renderer implementation. Defaults to
8
10
  * the internal `Markdown` component.
9
11
  */
10
12
  markdownComponent?: ComponentType<MarkdownProps>;
13
+ /**
14
+ * Uploads a file the user dropped onto the editor, pasted into it or picked
15
+ * with its attachment button. A placeholder comment sits at the cursor while
16
+ * the returned promise is pending: resolving replaces it with markdown
17
+ * linking to the file — an image embed for an image — and rejecting takes it
18
+ * back out. Without this prop the editor takes no files at all.
19
+ *
20
+ * Named without an `on` prefix on purpose: the remote generator turns an
21
+ * `on*` prop into a fire-and-forget event, and this one has to hand a result
22
+ * back.
23
+ */
24
+ uploadFile?: (file: File) => Promise<MarkdownEditorUpload>;
25
+ /**
26
+ * Which file types the editor takes, as the `accept` attribute of a file
27
+ * input: a comma separated list of MIME types (`image/png`), MIME wildcards
28
+ * (`image/*`) and file extensions (`.png`). Defaults to every type.
29
+ */
30
+ accept?: string;
11
31
  }
12
32
  /** @flr-generate all */
13
33
  export declare const MarkdownEditor: import('react').FunctionComponent<MarkdownEditorProps & import('react').RefAttributes<HTMLTextAreaElement>>;
@@ -1,11 +1,20 @@
1
1
  import { FC } from 'react';
2
- import { ToolBarButtonProps } from './ToolbarButton';
3
2
  import { ModeButtonProps } from './ModeButton';
4
3
  import { ButtonProps } from '../../Button';
4
+ import { InsertType } from '../lib/modifyValueByType';
5
5
  interface ToolbarProps extends Pick<ButtonProps, "isDisabled"> {
6
6
  currentMode: ModeButtonProps["currentMode"];
7
7
  onModeChange: ModeButtonProps["onChange"];
8
- onToolPressed: ToolBarButtonProps["onPress"];
8
+ onToolPressed: (type: InsertType) => void;
9
+ /** Which file types the attachment button offers. */
10
+ accept?: string;
11
+ /** Renders the attachment button when set. */
12
+ onFilesSelected?: (files: File[]) => void;
13
+ /**
14
+ * Disables the attachment button, which a read-only editor takes no files
15
+ * for.
16
+ */
17
+ isReadOnly?: boolean;
9
18
  }
10
19
  export declare const Toolbar: FC<ToolbarProps>;
11
20
  export {};
@@ -1,8 +1,14 @@
1
1
  import { FC } from 'react';
2
2
  import { InsertType } from '../lib/modifyValueByType';
3
3
  import { ButtonProps } from '../../Button';
4
+ /**
5
+ * What a toolbar button is: every markdown syntax it inserts, plus the one tool
6
+ * that does something else. The name is also the `toolbar.<type>` locale key of
7
+ * the button's label.
8
+ */
9
+ export type ToolbarButtonType = InsertType | "attachment";
4
10
  export interface ToolBarButtonProps extends Pick<ButtonProps, "isDisabled" | "children"> {
5
- type: InsertType;
6
- onPress?: (type: InsertType) => void;
11
+ type: ToolbarButtonType;
12
+ onPress?: () => void;
7
13
  }
8
14
  export declare const ToolbarButton: FC<ToolBarButtonProps>;
@@ -1,2 +1,2 @@
1
- export { type MarkdownEditorProps, MarkdownEditor } from './MarkdownEditor';
1
+ export { type MarkdownEditorProps, type MarkdownEditorUpload, MarkdownEditor, } from './MarkdownEditor';
2
2
  export { default } from './MarkdownEditor';
@@ -0,0 +1,19 @@
1
+ /**
2
+ * The result of uploading a file dropped into, pasted into or selected in a
3
+ * `MarkdownEditor`.
4
+ */
5
+ export interface MarkdownEditorUpload {
6
+ /** The URL the uploaded file is available at. */
7
+ url: string;
8
+ /**
9
+ * The link text of the inserted markdown — the alt text for an image.
10
+ * Defaults to the name of the uploaded file.
11
+ */
12
+ name?: string;
13
+ }
14
+ /** A new editor value together with where the cursor ends up in it. */
15
+ export interface ValueEdit {
16
+ value: string;
17
+ selectionStart: number;
18
+ selectionEnd: number;
19
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mittwald/flow-react-components",
3
- "version": "1.3.0-next.23",
3
+ "version": "1.3.0-next.24",
4
4
  "type": "module",
5
5
  "description": "A React implementation of Flow, mittwald’s design system",
6
6
  "homepage": "https://flow.mittwald.de",
@@ -83,9 +83,9 @@
83
83
  "@internationalized/string-compiler": "^3.4.1",
84
84
  "@lezer/common": "^1.5.2",
85
85
  "@lezer/highlight": "^1.2.3",
86
- "@mittwald/flow-icons": "^1.3.0-next.23",
86
+ "@mittwald/flow-icons": "^1.3.0-next.24",
87
87
  "@mittwald/password-tools-js": "^3.0.0",
88
- "@mittwald/react-tunnel": "^1.3.0-next.23",
88
+ "@mittwald/react-tunnel": "^1.3.0-next.24",
89
89
  "@mittwald/react-use-promise": "^4.2.2",
90
90
  "@react-aria/form": "^3.2.1",
91
91
  "@react-aria/i18n": "^3.13.1",
@@ -138,12 +138,12 @@
138
138
  "@internationalized/date": "^3.12.3",
139
139
  "@lezer/generator": "^1.8.0",
140
140
  "@lezer/lr": "^1.4.10",
141
- "@mittwald/flow-core": "1.3.0-next.23",
142
- "@mittwald/flow-design-tokens": "1.3.0-next.23",
143
- "@mittwald/flow-icons-base": "1.3.0-next.23",
141
+ "@mittwald/flow-core": "1.3.0-next.24",
142
+ "@mittwald/flow-design-tokens": "1.3.0-next.24",
143
+ "@mittwald/flow-icons-base": "1.3.0-next.24",
144
144
  "@mittwald/react-use-promise": "^4.2.2",
145
145
  "@mittwald/remote-dom-react": "1.2.2-mittwald.10",
146
- "@mittwald/typescript-config": "1.3.0-next.23",
146
+ "@mittwald/typescript-config": "1.3.0-next.24",
147
147
  "@nx/storybook": "^22.7.6",
148
148
  "@storybook/addon-a11y": "^10.5.10",
149
149
  "@storybook/addon-actions": "^9.0.8",
@@ -195,7 +195,7 @@
195
195
  },
196
196
  "peerDependencies": {
197
197
  "@internationalized/date": "^3.12.2",
198
- "@mittwald/flow-icons-pro": "1.3.0-next.23",
198
+ "@mittwald/flow-icons-pro": "1.3.0-next.24",
199
199
  "@mittwald/react-use-promise": "^4.2.2",
200
200
  "next": "^16.2.3",
201
201
  "react": "^19.2.0",
@@ -219,5 +219,5 @@
219
219
  "browserslist": [
220
220
  "baseline widely available"
221
221
  ],
222
- "gitHead": "b84c26db5a41b973c9a130728764b42312bee16d"
222
+ "gitHead": "f086d24ab9c6ffb1c639ce5552e090d075d87a9e"
223
223
  }