denwa-react-shared 1.0.97 → 1.1.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 { BaseEditor, Descendant } from 'slate';
|
|
2
2
|
import { ReactEditor } from 'slate-react';
|
|
3
|
+
import { PictureData } from './types';
|
|
3
4
|
/**
|
|
4
5
|
* @description Активна ли кнопка блока
|
|
5
6
|
* @param editor - slate editor
|
|
@@ -48,6 +49,23 @@ export declare const insertLink: (editor: BaseEditor & ReactEditor, url: string)
|
|
|
48
49
|
* @param editor - slate editor
|
|
49
50
|
*/
|
|
50
51
|
export declare const wrapLink: (editor: BaseEditor & ReactEditor, url: string) => void;
|
|
52
|
+
/**
|
|
53
|
+
* @description Вставка картинки
|
|
54
|
+
* @param editor - slate editor
|
|
55
|
+
* @param url - url картинки
|
|
56
|
+
* @param pictureData - подготовленные варианты для <picture>
|
|
57
|
+
*/
|
|
58
|
+
export declare const insertImage: (editor: BaseEditor & ReactEditor, url: string | ArrayBuffer | null, pictureData?: PictureData) => void;
|
|
59
|
+
/**
|
|
60
|
+
* @description Проверка что url изображения корректный
|
|
61
|
+
* @param url - url картинки
|
|
62
|
+
*/
|
|
63
|
+
export declare const isImageUrl: (url: string | ArrayBuffer | null) => boolean;
|
|
64
|
+
/**
|
|
65
|
+
* @description Поддержка картинок в редакторе
|
|
66
|
+
* @param editor - slate editor
|
|
67
|
+
*/
|
|
68
|
+
export declare const withImages: (editor: BaseEditor & ReactEditor) => BaseEditor & ReactEditor;
|
|
51
69
|
/**
|
|
52
70
|
* @description Поддержка ссылок в редакторе
|
|
53
71
|
* @param editor - slate editor
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { FC } from 'react';
|
|
2
|
+
import { PictureData } from './types';
|
|
2
3
|
interface ToolbarProps {
|
|
3
4
|
boldText: string;
|
|
4
5
|
italicText: string;
|
|
@@ -12,7 +13,12 @@ interface ToolbarProps {
|
|
|
12
13
|
linkErrorText: string;
|
|
13
14
|
linkButtonTooltipText: string;
|
|
14
15
|
removeLinkTooltipText: string;
|
|
16
|
+
imageButtonTooltipText?: string;
|
|
15
17
|
onErrorMessage: (error: string) => void;
|
|
18
|
+
onUploadImage?: (file: File) => Promise<{
|
|
19
|
+
url: string;
|
|
20
|
+
pictureData?: PictureData;
|
|
21
|
+
} | null>;
|
|
16
22
|
}
|
|
17
23
|
export declare const Toolbar: FC<ToolbarProps>;
|
|
18
24
|
export {};
|
|
@@ -19,11 +19,16 @@ export interface BaseTextEditorProps {
|
|
|
19
19
|
linkErrorText: string;
|
|
20
20
|
linkButtonTooltipText: string;
|
|
21
21
|
removeLinkTooltipText: string;
|
|
22
|
+
imageButtonTooltipText?: string;
|
|
22
23
|
language: string;
|
|
23
24
|
readOnly?: boolean;
|
|
24
25
|
onSetContent: (contentJSON: string, lang: string) => void;
|
|
25
26
|
onSetHtml: (html: string, lang: string) => void;
|
|
26
27
|
onErrorMessage: (error: string) => void;
|
|
28
|
+
onUploadImage?: (file: File) => Promise<{
|
|
29
|
+
url: string;
|
|
30
|
+
pictureData?: PictureData;
|
|
31
|
+
} | null>;
|
|
27
32
|
}
|
|
28
33
|
export interface ElementProps extends RenderElementProps {
|
|
29
34
|
element: any;
|
|
@@ -31,12 +36,28 @@ export interface ElementProps extends RenderElementProps {
|
|
|
31
36
|
export interface LeafProps extends RenderLeafProps {
|
|
32
37
|
leaf: any;
|
|
33
38
|
}
|
|
34
|
-
export type ElementTypes = 'title' | 'subtitle' | 'paragraph' | 'note' | 'info' | 'list-item' | 'numbered-list' | 'bulleted-list' | 'link';
|
|
39
|
+
export type ElementTypes = 'title' | 'subtitle' | 'paragraph' | 'note' | 'info' | 'list-item' | 'numbered-list' | 'bulleted-list' | 'image' | 'link';
|
|
40
|
+
export interface PictureData {
|
|
41
|
+
image1x: string;
|
|
42
|
+
image2x?: string;
|
|
43
|
+
image1xWebp?: string;
|
|
44
|
+
image2xWebp?: string;
|
|
45
|
+
image1xAvif?: string;
|
|
46
|
+
image2xAvif?: string;
|
|
47
|
+
mobileImage1x?: string;
|
|
48
|
+
mobileImage2x?: string;
|
|
49
|
+
mobileImage1xWebp?: string;
|
|
50
|
+
mobileImage2xWebp?: string;
|
|
51
|
+
mobileImage1xAvif?: string;
|
|
52
|
+
mobileImage2xAvif?: string;
|
|
53
|
+
}
|
|
35
54
|
export type CustomElement = {
|
|
36
55
|
type: ElementTypes;
|
|
37
56
|
url?: string | ArrayBuffer | null;
|
|
38
57
|
href?: string;
|
|
39
58
|
align?: 'left' | 'center' | 'right' | 'justify';
|
|
59
|
+
pictureData?: PictureData;
|
|
60
|
+
alt?: string;
|
|
40
61
|
children: CustomText[];
|
|
41
62
|
selection?: Range | null;
|
|
42
63
|
};
|