zs_library 0.2.3 → 0.3.5

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 (67) hide show
  1. package/README.md +0 -33
  2. package/dist/{Desktop → components/Desktop}/ContextMenu/index.d.ts +1 -2
  3. package/dist/{Desktop → components/Desktop}/Items/GroupItem.d.ts +1 -2
  4. package/dist/{Desktop → components/Desktop}/Items/Modal/GroupItemModal.d.ts +1 -2
  5. package/dist/{Desktop → components/Desktop}/Items/Modal/InfoModal.d.ts +0 -1
  6. package/dist/{Desktop → components/Desktop}/Items/SortableItem.d.ts +3 -4
  7. package/dist/{Desktop → components/Desktop}/Sortable.d.ts +3 -5
  8. package/dist/{Desktop → components/Desktop}/context/config/context.d.ts +2 -2
  9. package/dist/components/Desktop/context/config/hooks.d.ts +1 -0
  10. package/dist/{Desktop → components/Desktop}/context/state/context.d.ts +2 -2
  11. package/dist/components/Desktop/context/state/hooks.d.ts +1 -0
  12. package/dist/{Desktop → components/Desktop}/index.d.ts +1 -2
  13. package/dist/components/Desktop/utils.d.ts +33 -0
  14. package/dist/components/Editor/components/BlockTools/MediaAndEmbed/Image/index.d.ts +146 -0
  15. package/dist/components/Editor/components/BlockTools/MediaAndEmbed/Image/types/types.d.ts +172 -0
  16. package/dist/components/Editor/components/BlockTools/MediaAndEmbed/Image/ui.d.ts +132 -0
  17. package/dist/components/Editor/components/BlockTools/MediaAndEmbed/Image/uploader.d.ts +60 -0
  18. package/dist/components/Editor/components/BlockTools/MediaAndEmbed/Image/utils/dom.d.ts +10 -0
  19. package/dist/components/Editor/components/BlockTools/MediaAndEmbed/Image/utils/isPromise.d.ts +7 -0
  20. package/dist/components/Editor/components/BlockTools/TextAndTypography/Alert/index.d.ts +238 -0
  21. package/dist/components/Editor/components/BlockTools/TextAndTypography/Delimiter/index.d.ts +270 -0
  22. package/dist/components/Editor/components/BlockTools/TextAndTypography/Header/index.d.ts +249 -0
  23. package/dist/components/Editor/components/BlockTools/TextAndTypography/Paragraph/index.d.ts +189 -0
  24. package/dist/components/Editor/components/BlockTools/TextAndTypography/Paragraph/utils/makeFragment.d.ts +7 -0
  25. package/dist/components/Editor/components/BlockTools/TextAndTypography/Quote/index.d.ts +282 -0
  26. package/dist/components/Editor/components/BlockTuneTools/Delete/index.d.ts +33 -0
  27. package/dist/components/Editor/components/BlockTuneTools/MoveDown/index.d.ts +37 -0
  28. package/dist/components/Editor/components/BlockTuneTools/MoveUp/index.d.ts +37 -0
  29. package/dist/components/Editor/index.d.ts +9 -0
  30. package/dist/components/MdEditor/i18n/index.d.ts +4 -0
  31. package/dist/components/MdEditor/i18n/zh_CN.d.ts +5 -0
  32. package/dist/components/MdEditor/index.d.ts +54 -0
  33. package/dist/components/index.d.ts +2 -0
  34. package/dist/index.d.ts +1 -2
  35. package/dist/index.js +1654 -2
  36. package/package.json +102 -112
  37. package/.eslintrc.js +0 -3
  38. package/LICENSE +0 -21
  39. package/dist/Desktop/ContextMenu/index.js +0 -209
  40. package/dist/Desktop/Items/GroupItem.js +0 -179
  41. package/dist/Desktop/Items/Modal/GroupItemModal.js +0 -159
  42. package/dist/Desktop/Items/Modal/InfoModal.js +0 -34
  43. package/dist/Desktop/Items/SortableItem.js +0 -78
  44. package/dist/Desktop/Sortable.js +0 -185
  45. package/dist/Desktop/config.js +0 -16
  46. package/dist/Desktop/context/config/context.js +0 -36
  47. package/dist/Desktop/context/config/hooks.d.ts +0 -1
  48. package/dist/Desktop/context/config/hooks.js +0 -6
  49. package/dist/Desktop/context/state/context.js +0 -362
  50. package/dist/Desktop/context/state/hooks.d.ts +0 -1
  51. package/dist/Desktop/context/state/hooks.js +0 -6
  52. package/dist/Desktop/index.js +0 -40
  53. package/dist/Desktop/style.js +0 -4
  54. package/dist/Desktop/theme.js +0 -28
  55. package/dist/Desktop/types.js +0 -1
  56. package/dist/Desktop/utils.d.ts +0 -33
  57. package/dist/Desktop/utils.js +0 -37
  58. package/dist/Editor/Blocks/CodeBlock/CodeBlock.d.ts +0 -23
  59. package/dist/Editor/Blocks/CodeBlock/CodeBlock.js +0 -196
  60. package/dist/Editor/Blocks/CodeBlock/index.d.ts +0 -30
  61. package/dist/Editor/Blocks/CodeBlock/index.js +0 -21
  62. package/dist/Editor/index.d.ts +0 -17
  63. package/dist/Editor/index.js +0 -132
  64. /package/dist/{Desktop → components/Desktop}/config.d.ts +0 -0
  65. /package/dist/{Desktop → components/Desktop}/style.d.ts +0 -0
  66. /package/dist/{Desktop → components/Desktop}/theme.d.ts +0 -0
  67. /package/dist/{Desktop → components/Desktop}/types.d.ts +0 -0
package/README.md CHANGED
@@ -5,39 +5,6 @@
5
5
 
6
6
  个人业务组件库 React
7
7
 
8
- ## Usage
9
-
10
- TODO
11
-
12
- ## Options
13
-
14
- TODO
15
-
16
- ## Development
17
-
18
- ```bash
19
- # install dependencies
20
- $ pnpm install
21
-
22
- # develop library by docs demo
23
- $ pnpm start
24
-
25
- # build library source code
26
- $ pnpm run build
27
-
28
- # build library source code in watch mode
29
- $ pnpm run build:watch
30
-
31
- # build docs
32
- $ pnpm run docs:build
33
-
34
- # Locally preview the production build.
35
- $ pnpm run docs:preview
36
-
37
- # check your project for potential problems
38
- $ pnpm run doctor
39
- ```
40
-
41
8
  ## LICENSE
42
9
 
43
10
  MIT
@@ -1,4 +1,3 @@
1
- import React from 'react';
2
1
  import { SortItem } from '../types';
3
2
  export interface ContextMenuProps<D, C> {
4
3
  showShareButton?: boolean;
@@ -9,5 +8,5 @@ export interface ContextMenuProps<D, C> {
9
8
  onInfoClick?: (item: SortItem<D, C>) => void;
10
9
  onRemoveClick?: (item: SortItem<D, C>, remove: (id: string) => void) => void;
11
10
  }
12
- declare const ContextMenu: <D, C>(props: ContextMenuProps<D, C>) => React.JSX.Element;
11
+ declare const ContextMenu: <D, C>(props: ContextMenuProps<D, C>) => import("react/jsx-runtime").JSX.Element;
13
12
  export default ContextMenu;
@@ -1,8 +1,7 @@
1
- import React from 'react';
2
1
  import { SortItem } from '../types';
3
2
  import { SortableItemProps } from './SortableItem';
4
3
  interface SortableGroupItemProps<D, C> extends SortableItemProps<D, C> {
5
4
  data: SortItem<D, C>;
6
5
  }
7
- declare const SortableGroupItem: <D, C>(props: SortableGroupItemProps<D, C>) => React.JSX.Element;
6
+ declare const SortableGroupItem: <D, C>(props: SortableGroupItemProps<D, C>) => import("react/jsx-runtime").JSX.Element;
8
7
  export default SortableGroupItem;
@@ -1,9 +1,8 @@
1
- import React from 'react';
2
1
  import { SortItem } from '../../types';
3
2
  interface GroupItemModalProps<D, C> {
4
3
  data: SortItem | null;
5
4
  onClose: () => void;
6
5
  onItemClick?: (item: SortItem<D, C>) => void;
7
6
  }
8
- declare const GroupItemModal: <D, C>(props: GroupItemModalProps<D, C>) => React.JSX.Element;
7
+ declare const GroupItemModal: <D, C>(props: GroupItemModalProps<D, C>) => import("react/jsx-runtime").JSX.Element;
9
8
  export default GroupItemModal;
@@ -1,4 +1,3 @@
1
- import 'rc-dialog/assets/index.css';
2
1
  import { FC } from 'react';
3
2
  import { SortItem } from '../../types';
4
3
  export interface ItemInfoModalProps {
@@ -1,5 +1,4 @@
1
- import 'rc-tooltip/assets/bootstrap_white.css';
2
- import React from 'react';
1
+ import { default as React } from 'react';
3
2
  import { SortItem } from '../types';
4
3
  export interface SortableItemProps<D, C> {
5
4
  data: SortItem<D, C>;
@@ -12,6 +11,6 @@ export interface SortableItemProps<D, C> {
12
11
  parentIds?: (string | number)[];
13
12
  childrenLength?: number;
14
13
  }
15
- export declare const SortableItemDefaultContent: <D, C>(props: SortableItemProps<D, C>) => React.JSX.Element;
16
- declare const SortableItem: <D, C>(props: SortableItemProps<D, C>) => React.JSX.Element;
14
+ export declare const SortableItemDefaultContent: <D, C>(props: SortableItemProps<D, C>) => import("react/jsx-runtime").JSX.Element;
15
+ declare const SortableItem: <D, C>(props: SortableItemProps<D, C>) => import("react/jsx-runtime").JSX.Element;
17
16
  export default SortableItem;
@@ -1,7 +1,5 @@
1
- import React from 'react';
2
- import Slider, { Settings } from 'react-slick';
3
- import 'slick-carousel/slick/slick-theme.css';
4
- import 'slick-carousel/slick/slick.css';
1
+ import { default as React } from 'react';
2
+ import { default as Slider, Settings } from 'react-slick';
5
3
  import { SortItem } from './types';
6
4
  export interface Pagination {
7
5
  position?: 'top' | 'bottom' | 'left' | 'right';
@@ -29,5 +27,5 @@ export interface SortableProps<D, C> {
29
27
  */
30
28
  onItemClick?: (item: SortItem<D, C>) => void;
31
29
  }
32
- declare const Sortable: <D, C>(props: SortableProps<D, C>) => React.JSX.Element;
30
+ declare const Sortable: <D, C>(props: SortableProps<D, C>) => import("react/jsx-runtime").JSX.Element;
33
31
  export default Sortable;
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ import { default as React } from 'react';
2
2
  import { ContextMenuProps } from '../../ContextMenu';
3
3
  import { Theme } from '../../theme';
4
4
  import { SortItem } from '../../types';
@@ -41,4 +41,4 @@ export interface SortableConfigProviderProps<D, C> extends Omit<SortableConfig<D
41
41
  readonly theme?: 'light' | 'dark' | Theme;
42
42
  children: React.ReactNode;
43
43
  }
44
- export declare const SortableConfigProvider: <D, C>(props: SortableConfigProviderProps<D, C>) => React.JSX.Element;
44
+ export declare const SortableConfigProvider: <D, C>(props: SortableConfigProviderProps<D, C>) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1 @@
1
+ export declare const useSortableConfig: () => import('./context').SortableConfig<any, any>;
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ import { default as React } from 'react';
2
2
  import { SortItem } from '../../types';
3
3
  interface ContextMenu {
4
4
  rect: DOMRect;
@@ -55,5 +55,5 @@ export interface SortableStateProviderProps<D, C> {
55
55
  enableCaching?: boolean;
56
56
  children: React.ReactNode;
57
57
  }
58
- export declare const SortableStateProvider: <D, C>(props: SortableStateProviderProps<D, C>) => React.JSX.Element;
58
+ export declare const SortableStateProvider: <D, C>(props: SortableStateProviderProps<D, C>) => import("react/jsx-runtime").JSX.Element;
59
59
  export {};
@@ -0,0 +1 @@
1
+ export declare const useSortableState: () => import('./context').SortableState;
@@ -1,8 +1,7 @@
1
- import React from 'react';
2
1
  import { SortableProps } from './Sortable';
3
2
  import { SortableConfigProviderProps } from './context/config/context';
4
3
  import { SortableStateProviderProps } from './context/state/context';
5
4
  export interface DesktopProps<D = any, C = any> extends SortableProps<D, C>, Omit<SortableStateProviderProps<D, C>, 'children'>, Omit<SortableConfigProviderProps<D, C>, 'children'> {
6
5
  }
7
- declare const Desktop: <D, C>(props: DesktopProps<D, C>) => React.JSX.Element;
6
+ declare const Desktop: <D, C>(props: DesktopProps<D, C>) => import("react/jsx-runtime").JSX.Element;
8
7
  export default Desktop;
@@ -0,0 +1,33 @@
1
+ import { Theme } from './theme';
2
+ import { SortItem } from './types';
3
+ declare class SortableUtils {
4
+ /** 清理重复id */
5
+ static uniqueArray: (array: SortItem[]) => SortItem<any, any>[];
6
+ static getTheme: (theme?: Theme) => {
7
+ light: {
8
+ itemNameColor?: string;
9
+ itemIconBackgroundColor?: string;
10
+ itemIconShadowColor?: string;
11
+ groupItemIconBackgroundColor?: string;
12
+ groupItemIconShadowColor?: string;
13
+ groupItemModalBackgroundColor?: string;
14
+ contextMenuTextColor?: string;
15
+ contextMenuActiveColor?: string;
16
+ contextMenuBackgroundColor?: string;
17
+ contextMenuShadowColor?: string;
18
+ };
19
+ dark: {
20
+ itemNameColor?: string;
21
+ itemIconBackgroundColor?: string;
22
+ itemIconShadowColor?: string;
23
+ groupItemIconBackgroundColor?: string;
24
+ groupItemIconShadowColor?: string;
25
+ groupItemModalBackgroundColor?: string;
26
+ contextMenuTextColor?: string;
27
+ contextMenuActiveColor?: string;
28
+ contextMenuBackgroundColor?: string;
29
+ contextMenuShadowColor?: string;
30
+ };
31
+ };
32
+ }
33
+ export default SortableUtils;
@@ -0,0 +1,146 @@
1
+ import { TunesMenuConfig } from '@editorjs/editorjs/types/tools';
2
+ import { ToolboxConfig, PasteConfig, BlockToolConstructorOptions, BlockTool, PasteEvent } from '@editorjs/editorjs';
3
+ import { ActionConfig, ImageToolData, ImageConfig } from './types/types';
4
+ type ImageToolConstructorOptions = BlockToolConstructorOptions<ImageToolData, ImageConfig>;
5
+ /**
6
+ * Implementation of ImageTool class
7
+ */
8
+ export default class ImageTool implements BlockTool {
9
+ /**
10
+ * Editor.js API instance
11
+ */
12
+ private api;
13
+ /**
14
+ * Flag indicating read-only mode
15
+ */
16
+ private readOnly;
17
+ /**
18
+ * Current Block API instance
19
+ */
20
+ private block;
21
+ /**
22
+ * Configuration for the ImageTool
23
+ */
24
+ private config;
25
+ /**
26
+ * Uploader module instance
27
+ */
28
+ private uploader;
29
+ /**
30
+ * UI module instance
31
+ */
32
+ private ui;
33
+ /**
34
+ * Stores current block data internally
35
+ */
36
+ private _data;
37
+ /**
38
+ * @param tool - tool properties got from editor.js
39
+ * @param tool.data - previously saved data
40
+ * @param tool.config - user config for Tool
41
+ * @param tool.api - Editor.js API
42
+ * @param tool.readOnly - read-only mode flag
43
+ * @param tool.block - current Block API
44
+ */
45
+ constructor({ data, config, api, readOnly, block, }: ImageToolConstructorOptions);
46
+ /**
47
+ * Notify core that read-only mode is supported
48
+ */
49
+ static get isReadOnlySupported(): boolean;
50
+ /**
51
+ * Get Tool toolbox settings
52
+ * icon - Tool icon's SVG
53
+ * title - title to show in toolbox
54
+ */
55
+ static get toolbox(): ToolboxConfig;
56
+ /**
57
+ * Available image tools
58
+ */
59
+ static get tunes(): Array<ActionConfig>;
60
+ /**
61
+ * Renders Block content
62
+ */
63
+ render(): HTMLDivElement;
64
+ /**
65
+ * Validate data: check if Image exists
66
+ * @param savedData — data received after saving
67
+ * @returns false if saved data is not correct, otherwise true
68
+ */
69
+ validate(savedData: ImageToolData): boolean;
70
+ /**
71
+ * Return Block data
72
+ */
73
+ save(): ImageToolData;
74
+ /**
75
+ * Returns configuration for block tunes: add background, add border, stretch image
76
+ * @returns TunesMenuConfig
77
+ */
78
+ renderSettings(): TunesMenuConfig;
79
+ /**
80
+ * Fires after clicks on the Toolbox Image Icon
81
+ * Initiates click on the Select File button
82
+ */
83
+ appendCallback(): void;
84
+ /**
85
+ * Specify paste substitutes
86
+ * @see {@link https://github.com/codex-team/editor.js/blob/master/docs/tools.md#paste-handling}
87
+ */
88
+ static get pasteConfig(): PasteConfig;
89
+ /**
90
+ * Specify paste handlers
91
+ * @see {@link https://github.com/codex-team/editor.js/blob/master/docs/tools.md#paste-handling}
92
+ * @param event - editor.js custom paste event
93
+ * {@link https://github.com/codex-team/editor.js/blob/master/types/tools/paste-events.d.ts}
94
+ */
95
+ onPaste(event: PasteEvent): Promise<void>;
96
+ /**
97
+ * Private methods
98
+ * ̿̿ ̿̿ ̿̿ ̿'̿'\̵͇̿̿\з= ( ▀ ͜͞ʖ▀) =ε/̵͇̿̿/’̿’̿ ̿ ̿̿ ̿̿ ̿̿
99
+ */
100
+ /**
101
+ * Stores all Tool's data
102
+ * @param data - data in Image Tool format
103
+ */
104
+ private set data(value);
105
+ /**
106
+ * Return Tool data
107
+ */
108
+ private get data();
109
+ /**
110
+ * Set new image file
111
+ * @param file - uploaded file data
112
+ */
113
+ private set image(value);
114
+ /**
115
+ * File uploading callback
116
+ * @param response - uploading server response
117
+ */
118
+ private onUpload;
119
+ /**
120
+ * Handle uploader errors
121
+ * @param errorText - uploading error info
122
+ */
123
+ private uploadingFailed;
124
+ /**
125
+ * Callback fired when Block Tune is activated
126
+ * @param tuneName - tune that has been clicked
127
+ */
128
+ private tuneToggled;
129
+ /**
130
+ * Set one tune
131
+ * @param tuneName - {@link Tunes.tunes}
132
+ * @param value - tune state
133
+ */
134
+ private setTune;
135
+ /**
136
+ * Show preloader and upload image file
137
+ * @param file - file that is currently uploading (from paste)
138
+ */
139
+ private uploadFile;
140
+ /**
141
+ * Show preloader and upload image by target url
142
+ * @param url - url pasted
143
+ */
144
+ private uploadUrl;
145
+ }
146
+ export {};
@@ -0,0 +1,172 @@
1
+ import { HTMLPasteEventDetail } from '@editorjs/editorjs';
2
+ /**
3
+ * Represents options for uploading, including a function to handle previewing.
4
+ */
5
+ export interface UploadOptions {
6
+ /**
7
+ * Callback function to be called when the preview is ready.
8
+ * @param src - The source of the preview as a string.
9
+ * @returns void
10
+ */
11
+ onPreview: (src: string) => void;
12
+ }
13
+ /**
14
+ * User configuration of Image block tunes. Allows to add custom tunes through the config
15
+ */
16
+ export interface ActionConfig {
17
+ /**
18
+ * The name of the tune.
19
+ */
20
+ name: string;
21
+ /**
22
+ * The icon for the tune. Should be an SVG string.
23
+ */
24
+ icon: string;
25
+ /**
26
+ * The title of the tune. This will be displayed in the UI.
27
+ */
28
+ title: string;
29
+ /**
30
+ * An optional flag indicating whether the tune is a toggle (true) or not (false).
31
+ */
32
+ toggle?: boolean;
33
+ /**
34
+ * An optional action function to be executed when the tune is activated.
35
+ */
36
+ action?: Function;
37
+ }
38
+ /**
39
+ * UploadResponseFormat interface representing the response format expected from the backend on file uploading.
40
+ */
41
+ export interface UploadResponseFormat<AdditionalFileData = {}> {
42
+ /**
43
+ * success - 1 for successful uploading, 0 for failure
44
+ */
45
+ success: number;
46
+ /**
47
+ * Object with file data.
48
+ * 'url' is required,
49
+ * also can contain any additional data that will be saved and passed back
50
+ */
51
+ file: {
52
+ /**
53
+ * The URL of the uploaded image.
54
+ */
55
+ url: string;
56
+ } & AdditionalFileData;
57
+ }
58
+ /**
59
+ * ImageToolData type representing the input and output data format for the image tool, including optional custome actions.
60
+ */
61
+ export type ImageToolData<Actions = {}, AdditionalFileData = {}> = {
62
+ /**
63
+ * Caption for the image.
64
+ */
65
+ caption: string;
66
+ /**
67
+ * Flag indicating whether the image has a border.
68
+ */
69
+ withBorder: boolean;
70
+ /**
71
+ * Flag indicating whether the image has a background.
72
+ */
73
+ withBackground: boolean;
74
+ /**
75
+ * Flag indicating whether the image is stretched.
76
+ */
77
+ stretched: boolean;
78
+ /**
79
+ * Object containing the URL of the image file.
80
+ * Also can contain any additional data.
81
+ */
82
+ file: {
83
+ /**
84
+ * The URL of the image.
85
+ */
86
+ url: string;
87
+ } & AdditionalFileData;
88
+ } & (Actions extends Record<string, boolean> ? Actions : {});
89
+ /**
90
+ *
91
+ * @description Config supported by Tool
92
+ */
93
+ export interface ImageConfig {
94
+ /**
95
+ * Endpoints for upload, whether using file or URL.
96
+ */
97
+ endpoints: {
98
+ /**
99
+ * Endpoint for file upload.
100
+ */
101
+ byFile?: string;
102
+ /**
103
+ * Endpoints for URL upload.
104
+ */
105
+ byUrl?: string;
106
+ };
107
+ /**
108
+ * Field name for the uploaded image.
109
+ */
110
+ field?: string;
111
+ /**
112
+ * Allowed mime-types for the uploaded image.
113
+ */
114
+ types?: string;
115
+ /**
116
+ * Placeholder text for the caption field.
117
+ */
118
+ captionPlaceholder?: string;
119
+ /**
120
+ * Additional data to send with requests.
121
+ */
122
+ additionalRequestData?: object;
123
+ /**
124
+ * Additional headers to send with requests.
125
+ */
126
+ additionalRequestHeaders?: object;
127
+ /**
128
+ * Custom content for the select file button.
129
+ */
130
+ buttonContent?: string;
131
+ /**
132
+ * Optional custom uploader.
133
+ */
134
+ uploader?: {
135
+ /**
136
+ * Method to upload an image by file.
137
+ */
138
+ uploadByFile?: (file: Blob) => Promise<UploadResponseFormat>;
139
+ /**
140
+ * Method to upload an image by URL.
141
+ */
142
+ uploadByUrl?: (url: string) => Promise<UploadResponseFormat>;
143
+ };
144
+ /**
145
+ * Additional actions for the tool.
146
+ */
147
+ actions?: ActionConfig[];
148
+ }
149
+ /**
150
+ * Interface representing the details of a paste event for HTML elements.
151
+ * Extends the `HTMLPasteEventDetail` interface to include additional data properties.
152
+ */
153
+ export interface HTMLPasteEventDetailExtended extends HTMLPasteEventDetail {
154
+ /**
155
+ * The data property containing the source of the image and HTML element details.
156
+ */
157
+ data: {
158
+ /**
159
+ * The source URL of the pasted image.
160
+ */
161
+ src: string;
162
+ } & HTMLElement;
163
+ }
164
+ /**
165
+ * Parameter type of Image setter function in ImageTool
166
+ */
167
+ export type ImageSetterParam = {
168
+ /**
169
+ * url path of the image
170
+ */
171
+ url: string;
172
+ };
@@ -0,0 +1,132 @@
1
+ import { API } from '@editorjs/editorjs';
2
+ import { ImageToolData, ImageConfig } from './types/types';
3
+ /**
4
+ * Nodes interface representing various elements in the UI.
5
+ */
6
+ interface Nodes {
7
+ /**
8
+ * Wrapper element in the UI.
9
+ */
10
+ wrapper: HTMLElement;
11
+ /**
12
+ * Container for the image element in the UI.
13
+ */
14
+ imageContainer: HTMLElement;
15
+ /**
16
+ * Button for selecting files.
17
+ */
18
+ fileButton: HTMLElement;
19
+ /**
20
+ * Represents the image element in the UI, if one is present; otherwise, it's undefined.
21
+ */
22
+ imageEl?: HTMLElement;
23
+ /**
24
+ * Preloader element for the image.
25
+ */
26
+ imagePreloader: HTMLElement;
27
+ /**
28
+ * Caption element for the image.
29
+ */
30
+ caption: HTMLElement;
31
+ }
32
+ /**
33
+ * ConstructorParams interface representing parameters for the Ui class constructor.
34
+ */
35
+ interface ConstructorParams {
36
+ /**
37
+ * Editor.js API.
38
+ */
39
+ api: API;
40
+ /**
41
+ * Configuration for the image.
42
+ */
43
+ config: ImageConfig;
44
+ /**
45
+ * Callback function for selecting a file.
46
+ */
47
+ onSelectFile: () => void;
48
+ /**
49
+ * Flag indicating if the UI is in read-only mode.
50
+ */
51
+ readOnly: boolean;
52
+ }
53
+ /**
54
+ * Class for working with UI:
55
+ * - rendering base structure
56
+ * - show/hide preview
57
+ * - apply tune view
58
+ */
59
+ export default class Ui {
60
+ /**
61
+ * Nodes representing various elements in the UI.
62
+ */
63
+ nodes: Nodes;
64
+ /**
65
+ * API instance for Editor.js.
66
+ */
67
+ private api;
68
+ /**
69
+ * Configuration for the image tool.
70
+ */
71
+ private config;
72
+ /**
73
+ * Callback function for selecting a file.
74
+ */
75
+ private onSelectFile;
76
+ /**
77
+ * Flag indicating if the UI is in read-only mode.
78
+ */
79
+ private readOnly;
80
+ /**
81
+ * @param ui - image tool Ui module
82
+ * @param ui.api - Editor.js API
83
+ * @param ui.config - user config
84
+ * @param ui.onSelectFile - callback for clicks on Select file button
85
+ * @param ui.readOnly - read-only mode flag
86
+ */
87
+ constructor({ api, config, onSelectFile, readOnly }: ConstructorParams);
88
+ /**
89
+ * Apply visual representation of activated tune
90
+ * @param tuneName - one of available tunes {@link Tunes.tunes}
91
+ * @param status - true for enable, false for disable
92
+ */
93
+ applyTune(tuneName: string, status: boolean): void;
94
+ /**
95
+ * Renders tool UI
96
+ * @param toolData - saved tool data
97
+ */
98
+ render(toolData: ImageToolData): HTMLElement;
99
+ /**
100
+ * Shows uploading preloader
101
+ * @param src - preview source
102
+ */
103
+ showPreloader(src: string): void;
104
+ /**
105
+ * Hide uploading preloader
106
+ */
107
+ hidePreloader(): void;
108
+ /**
109
+ * Shows an image
110
+ * @param url - image source
111
+ */
112
+ fillImage(url: string): void;
113
+ /**
114
+ * Shows caption input
115
+ * @param text - caption content text
116
+ */
117
+ fillCaption(text: string): void;
118
+ /**
119
+ * CSS classes
120
+ */
121
+ private get CSS();
122
+ /**
123
+ * Creates upload-file button
124
+ */
125
+ private createFileButton;
126
+ /**
127
+ * Changes UI status
128
+ * @param status - see {@link Ui.status} constants
129
+ */
130
+ private toggleStatus;
131
+ }
132
+ export {};