@mantine-vue/tiptap 3.4.0 → 3.6.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.
@@ -1,5 +1,6 @@
1
1
  import type { Editor } from '@tiptap/vue-3';
2
2
  import type { ResolvedRichTextEditorLabels } from './labels';
3
+ import type { ImageUploadResult } from './extensions/UploadImage';
3
4
  export interface RichTextEditorContextValue {
4
5
  getStyles: (selector: string, options?: {
5
6
  active?: boolean;
@@ -17,5 +18,7 @@ export interface RichTextEditorContextValue {
17
18
  unstyled: boolean | undefined;
18
19
  variant: string | undefined;
19
20
  onSourceCodeTextSwitch?: (isSourceCodeModeActive: boolean) => void;
21
+ onImageUpload?: (file: File) => Promise<string | ImageUploadResult>;
22
+ onImageUploadError?: (file: File, error: unknown) => void;
20
23
  }
21
24
  export declare const provideRichTextEditorContext: (value: RichTextEditorContextValue) => void, useRichTextEditorContext: () => RichTextEditorContextValue;
@@ -8,6 +8,7 @@ import { RichTextEditorSourceCodeControl } from './RichTextEditorControl/RichTex
8
8
  import { RichTextEditorTableInsertControl } from './RichTextEditorControl/RichTextEditorTableInsertControl';
9
9
  import { RichTextEditorDetailsControl } from './RichTextEditorControl/RichTextEditorDetailsControl';
10
10
  import { RichTextEditorInvisibleCharactersControl } from './RichTextEditorControl/RichTextEditorInvisibleCharactersControl';
11
+ import { RichTextEditorImageUploadControl } from './RichTextEditorControl/RichTextEditorImageUploadControl';
11
12
  import { RichTextEditorControlsGroup } from './RichTextEditorControlsGroup/RichTextEditorControlsGroup';
12
13
  import { RichTextEditorToolbar } from './RichTextEditorToolbar/RichTextEditorToolbar';
13
14
  export declare const RichTextEditor: import("@mantine-vue/core").MantineComponent<{
@@ -71,6 +72,7 @@ export declare const RichTextEditor: import("@mantine-vue/core").MantineComponen
71
72
  TableSplitCell: typeof controls.TableSplitCellControl;
72
73
  Details: typeof RichTextEditorDetailsControl;
73
74
  InvisibleCharacters: typeof RichTextEditorInvisibleCharactersControl;
75
+ ImageUpload: typeof RichTextEditorImageUploadControl;
74
76
  };
75
77
  }>;
76
78
  export type { RichTextEditorFactory, RichTextEditorOwnProps, RichTextEditorProps, RichTextEditorSlots, RichTextEditorStylesNames, RichTextEditorVariant, } from './RichTextEditor.types';
@@ -2,6 +2,8 @@ import type { VNodeChild } from 'vue';
2
2
  import type { Editor } from '@tiptap/vue-3';
3
3
  import type { BoxProps, Factory, StylesApiProps } from '@mantine-vue/core';
4
4
  import type { RichTextEditorLabels } from './labels';
5
+ import type { ImageUploadResult } from './extensions/UploadImage';
6
+ import type { RichTextEditorImageUploadControl } from './RichTextEditorControl/RichTextEditorImageUploadControl';
5
7
  import type { RichTextEditorContent } from './RichTextEditorContent/RichTextEditorContent';
6
8
  import type { RichTextEditorControl } from './RichTextEditorControl/RichTextEditorControl';
7
9
  import type { BoldControl, ItalicControl, StrikeThroughControl, UnderlineControl, ClearFormattingControl, H1Control, H2Control, H3Control, H4Control, H5Control, H6Control, BulletListControl, OrderedListControl, UnlinkControl, BlockquoteControl, AlignLeftControl, AlignRightControl, AlignCenterControl, AlignJustifyControl, SuperscriptControl, SubscriptControl, CodeControl, CodeBlockControl, HighlightControl, HrControl, UnsetColorControl, UndoControl, RedoControl, TaskListControl, TaskListSinkControl, TaskListLiftControl, TableDeleteControl, TableColumnBeforeControl, TableColumnAfterControl, TableColumnDeleteControl, TableRowBeforeControl, TableRowAfterControl, TableRowDeleteControl, TableToggleHeaderRowControl, TableToggleHeaderColumnControl, TableMergeCellsControl, TableSplitCellControl } from './RichTextEditorControl/controls';
@@ -29,6 +31,10 @@ export interface RichTextEditorOwnProps extends StylesApiProps<RichTextEditorFac
29
31
  labels?: Partial<RichTextEditorLabels>;
30
32
  /** Visual variant. @default 'default' */
31
33
  variant?: RichTextEditorVariant;
34
+ /** Called when an image file is picked with `RichTextEditor.ImageUpload` control, must return a promise that resolves to the uploaded image URL or to an object with `src` and optional `alt` and `title`. Takes precedence over `onImageUpload` option of the extension created with `getUploadImageExtension`. */
35
+ onImageUpload?: (file: File) => Promise<string | ImageUploadResult>;
36
+ /** Called when an image picked with `RichTextEditor.ImageUpload` control fails to upload. Takes precedence over `onImageUploadError` option of the extension created with `getUploadImageExtension`. */
37
+ onImageUploadError?: (file: File, error: unknown) => void;
32
38
  }
33
39
  export interface RichTextEditorProps extends Omit<BoxProps, keyof RichTextEditorOwnProps | 'component'>, RichTextEditorOwnProps {
34
40
  }
@@ -96,5 +102,6 @@ export type RichTextEditorFactory = Factory<{
96
102
  TableSplitCell: typeof TableSplitCellControl;
97
103
  Details: typeof RichTextEditorDetailsControl;
98
104
  InvisibleCharacters: typeof RichTextEditorInvisibleCharactersControl;
105
+ ImageUpload: typeof RichTextEditorImageUploadControl;
99
106
  };
100
107
  }>;
@@ -1,5 +1,6 @@
1
1
  import type { Editor } from '@tiptap/vue-3';
2
2
  import type { RichTextEditorLabels } from './labels';
3
+ import type { ImageUploadResult } from './extensions/UploadImage';
3
4
  import type { RichTextEditorSlots, RichTextEditorVariant } from './RichTextEditor.types';
4
5
  interface RichTextEditorRuntimeProps {
5
6
  editor: Editor | null | undefined;
@@ -8,6 +9,8 @@ interface RichTextEditorRuntimeProps {
8
9
  onSourceCodeTextSwitch?: (isSourceCodeModeActive: boolean) => void;
9
10
  labels?: Partial<RichTextEditorLabels>;
10
11
  variant?: RichTextEditorVariant;
12
+ onImageUpload?: (file: File) => Promise<string | ImageUploadResult>;
13
+ onImageUploadError?: (file: File, error: unknown) => void;
11
14
  classNames?: unknown;
12
15
  styles?: unknown;
13
16
  vars?: unknown;
@@ -0,0 +1,2 @@
1
+ export declare const RichTextEditorImageUploadControl: import("vue").DefineComponent<import("./RichTextEditorImageUploadControl.types").RichTextEditorImageUploadControlRuntimeProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("./RichTextEditorImageUploadControl.types").RichTextEditorImageUploadControlRuntimeProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
2
+ export type { RichTextEditorImageUploadControlProps } from './RichTextEditorImageUploadControl.types';
@@ -0,0 +1,11 @@
1
+ import type { BoxProps } from '@mantine-vue/core';
2
+ import type { RichTextEditorControlBaseProps } from './RichTextEditorControl.types';
3
+ export interface RichTextEditorImageUploadControlRuntimeProps {
4
+ accept?: string;
5
+ disabled?: boolean;
6
+ icon?: any;
7
+ }
8
+ export type RichTextEditorImageUploadControlProps = Omit<RichTextEditorControlBaseProps, 'classNames' | 'styles' | 'vars'> & BoxProps & {
9
+ /** Accepted file types. @default 'image/*' */
10
+ accept?: string;
11
+ };
@@ -0,0 +1,4 @@
1
+ import type { RichTextEditorImageUploadControlRuntimeProps } from './RichTextEditorImageUploadControl.types';
2
+ declare const __VLS_export: import("vue").DefineComponent<RichTextEditorImageUploadControlRuntimeProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<RichTextEditorImageUploadControlRuntimeProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
3
+ declare const _default: typeof __VLS_export;
4
+ export default _default;
@@ -6,4 +6,5 @@ export * from './RichTextEditorSourceCodeControl';
6
6
  export * from './RichTextEditorTableInsertControl';
7
7
  export * from './RichTextEditorDetailsControl';
8
8
  export * from './RichTextEditorInvisibleCharactersControl';
9
+ export * from './RichTextEditorImageUploadControl';
9
10
  export * from './controls';
@@ -0,0 +1,21 @@
1
+ export interface ImageUploadResult {
2
+ /** URL of the uploaded image, set as `src` attribute */
3
+ src: string;
4
+ /** Alternative text of the uploaded image, set as `alt` attribute */
5
+ alt?: string;
6
+ /** Title of the uploaded image, set as `title` attribute */
7
+ title?: string;
8
+ }
9
+ export interface UploadImageOptions {
10
+ /** Called for every image file that is picked, dropped or pasted, must return a promise that resolves to the uploaded image URL or to an object with `src` and optional `alt` and `title` */
11
+ onImageUpload: (file: File) => Promise<string | ImageUploadResult>;
12
+ /** Called when image upload fails */
13
+ onImageUploadError?: (file: File, error: unknown) => void;
14
+ /** Called for every image in pasted or dropped HTML, return `true` to download the image and pass it to `onImageUpload`. By default, only images with `data:` URL sources are uploaded. */
15
+ shouldUploadPastedImage?: (src: string) => boolean;
16
+ }
17
+ export declare function getImageFiles(files: FileList | File[] | null | undefined): File[];
18
+ export declare function insertImageFilesWithUpload(view: any, files: File[], pos: number, options: UploadImageOptions): void;
19
+ export declare function insertImageWithUpload(view: any, file: File, pos: number, options: UploadImageOptions): void;
20
+ export declare function getUploadImageExtensionOptions(editor: any): Partial<UploadImageOptions>;
21
+ export declare function getUploadImageExtension(TipTapImage: any, options: UploadImageOptions): any;
@@ -1,2 +1,3 @@
1
1
  export { Link } from './Link';
2
2
  export { getTaskListExtension } from './TaskList';
3
+ export * from './UploadImage';
@@ -54,3 +54,4 @@ export declare const IconTableMergeCells: Component<IconProps>;
54
54
  export declare const IconTableSplitCell: Component<IconProps>;
55
55
  export declare const IconDetails: Component<IconProps>;
56
56
  export declare const IconPilcrow: Component<IconProps>;
57
+ export declare const IconPhoto: Component<IconProps>;
package/lib/labels.d.ts CHANGED
@@ -60,6 +60,7 @@ export interface RichTextEditorLabels {
60
60
  tableSplitCellControlLabel?: string;
61
61
  detailsControlLabel?: string;
62
62
  invisibleCharactersControlLabel?: string;
63
+ imageUploadControlLabel?: string;
63
64
  }
64
65
  export type ResolvedRichTextEditorLabels = Required<RichTextEditorLabels>;
65
66
  export declare const DEFAULT_LABELS: ResolvedRichTextEditorLabels;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mantine-vue/tiptap",
3
- "version": "3.4.0",
3
+ "version": "3.6.0",
4
4
  "description": "Vue rich text editor based on tiptap, equivalent to @mantine/tiptap",
5
5
  "license": "MIT",
6
6
  "files": [
@@ -45,8 +45,8 @@
45
45
  },
46
46
  "peerDependencies": {
47
47
  "@floating-ui/dom": "^1.0.0",
48
- "@mantine-vue/core": "3.4.0",
49
- "@mantine-vue/hooks": "3.4.0",
48
+ "@mantine-vue/core": "3.6.0",
49
+ "@mantine-vue/hooks": "3.6.0",
50
50
  "@tiptap/core": ">=3.3.0",
51
51
  "@tiptap/extension-link": ">=3.3.0",
52
52
  "@tiptap/pm": ">=3.3.0",