@webiny/app-admin 5.23.1 → 5.24.0-beta.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.
Files changed (135) hide show
  1. package/base/Admin.d.ts +1 -8
  2. package/base/Base.d.ts +1 -1
  3. package/base/plugins/AddGraphQLQuerySelection.d.ts +2 -2
  4. package/base/providers/ApolloProvider.d.ts +9 -3
  5. package/base/providers/TelemetryProvider.d.ts +2 -4
  6. package/base/providers/TelemetryProvider.js +5 -0
  7. package/base/providers/UiStateProvider.d.ts +1 -3
  8. package/base/providers/ViewCompositionProvider.d.ts +2 -4
  9. package/base/ui/Menu.d.ts +6 -1
  10. package/base/ui/Menu.js +87 -25
  11. package/base/ui/Navigation.d.ts +3 -5
  12. package/base/ui/Navigation.js +9 -26
  13. package/base/ui/Search.d.ts +2 -5
  14. package/base/ui/Tags.d.ts +1 -1
  15. package/base/ui/UserMenu.d.ts +2 -5
  16. package/components/AdminLayout.d.ts +1 -2
  17. package/components/AppInstaller/AppInstaller.d.ts +2 -4
  18. package/components/AppInstaller/Sidebar.d.ts +8 -6
  19. package/components/AppInstaller/Sidebar.js +9 -9
  20. package/components/AppInstaller/styled.d.ts +4 -4
  21. package/components/AppInstaller/useInstaller.d.ts +26 -9
  22. package/components/AppInstaller/useInstaller.js +42 -34
  23. package/components/EmptyView.d.ts +4 -4
  24. package/components/FileManager/BottomInfoBar/SupportedFileTypes.d.ts +5 -4
  25. package/components/FileManager/BottomInfoBar/SupportedFileTypes.js +2 -1
  26. package/components/FileManager/BottomInfoBar/UploadStatus.d.ts +5 -4
  27. package/components/FileManager/BottomInfoBar.d.ts +4 -2
  28. package/components/FileManager/DropFilesHere.d.ts +4 -3
  29. package/components/FileManager/DropFilesHere.js +5 -2
  30. package/components/FileManager/File.d.ts +7 -8
  31. package/components/FileManager/File.js +11 -5
  32. package/components/FileManager/FileDetails/Name.d.ts +7 -5
  33. package/components/FileManager/FileDetails/Name.js +2 -2
  34. package/components/FileManager/FileDetails/Tags.d.ts +7 -5
  35. package/components/FileManager/FileDetails/Tags.js +4 -2
  36. package/components/FileManager/FileDetails.d.ts +6 -8
  37. package/components/FileManager/FileDetails.js +14 -2
  38. package/components/FileManager/FileManagerContext.d.ts +12 -9
  39. package/components/FileManager/FileManagerContext.js +9 -7
  40. package/components/FileManager/FileManagerView.d.ts +2 -10
  41. package/components/FileManager/FileManagerView.js +19 -8
  42. package/components/FileManager/LeftSidebar.d.ts +6 -5
  43. package/components/FileManager/LeftSidebar.js +4 -4
  44. package/components/FileManager/NoPermissionView.d.ts +2 -2
  45. package/components/FileManager/NoResults.d.ts +3 -2
  46. package/components/FileManager/NoResults.js +5 -2
  47. package/components/FileManager/getFileTypePlugin.d.ts +4 -1
  48. package/components/FileManager/getFileTypePlugin.js +5 -0
  49. package/components/FileManager/getFileUploader.d.ts +2 -1
  50. package/components/FileManager/outputFileSelectionError.d.ts +4 -1
  51. package/components/FileManager/outputFileSelectionError.js +5 -0
  52. package/components/FileManager/types.d.ts +49 -0
  53. package/components/FileManager/types.js +1 -0
  54. package/components/FileManager.d.ts +15 -10
  55. package/components/FileManager.js +15 -12
  56. package/components/FloatingActionButton.d.ts +2 -2
  57. package/components/MultiImageUpload.d.ts +13 -4
  58. package/components/MultiImageUpload.js +15 -4
  59. package/components/OverlayLayout/OverlayLayout.d.ts +9 -12
  60. package/components/Permissions/StyledComponents.d.ts +6 -4
  61. package/components/RichTextEditor/RichTextEditor.d.ts +2 -2
  62. package/components/RichTextEditor/tools/header/index.d.ts +33 -34
  63. package/components/RichTextEditor/tools/header/index.js +2 -3
  64. package/components/RichTextEditor/tools/image/index.d.ts +36 -13
  65. package/components/RichTextEditor/tools/image/index.js +4 -2
  66. package/components/RichTextEditor/tools/image/tunes.d.ts +12 -15
  67. package/components/RichTextEditor/tools/image/tunes.js +2 -1
  68. package/components/RichTextEditor/tools/image/types.d.ts +29 -0
  69. package/components/RichTextEditor/tools/image/types.js +1 -0
  70. package/components/RichTextEditor/tools/image/ui.d.ts +33 -26
  71. package/components/RichTextEditor/tools/image/ui.js +24 -11
  72. package/components/RichTextEditor/tools/paragraph/index.d.ts +31 -31
  73. package/components/RichTextEditor/tools/paragraph/index.js +11 -15
  74. package/components/RichTextEditor/tools/textColor/index.d.ts +22 -21
  75. package/components/RichTextEditor/tools/textColor/index.js +3 -1
  76. package/components/Routes.d.ts +2 -2
  77. package/components/SearchUI.d.ts +4 -4
  78. package/components/SimpleForm/SimpleForm.d.ts +7 -9
  79. package/components/SimpleUI/InputField.d.ts +3 -3
  80. package/components/SimpleUI/InputField.js +18 -18
  81. package/components/SingleImageUpload.d.ts +4 -9
  82. package/components/SingleImageUpload.js +2 -1
  83. package/components/SplitView/SplitView.d.ts +5 -5
  84. package/hooks/useConfirmationDialog.d.ts +6 -5
  85. package/hooks/useConfirmationDialog.js +1 -2
  86. package/hooks/useDialog.d.ts +8 -3
  87. package/hooks/useDialog.js +1 -1
  88. package/hooks/useSnackbar.d.ts +6 -3
  89. package/package.json +17 -14
  90. package/plugins/FileManagerFileTypePlugin.d.ts +1 -1
  91. package/plugins/MenuPlugin.d.ts +3 -3
  92. package/plugins/fileManager/fileImage/DeleteAction.d.ts +6 -2
  93. package/plugins/fileManager/fileImage/EditAction.d.ts +7 -6
  94. package/plugins/fileManager/fileImage/EditAction.js +18 -9
  95. package/plugins/globalSearch/SearchBar.d.ts +13 -0
  96. package/plugins/globalSearch/SearchBar.js +5 -0
  97. package/plugins/globalSearch/SearchBarDropdown.d.ts +16 -1
  98. package/plugins/globalSearch/index.d.ts +2 -1
  99. package/plugins/globalSearch/styled.d.ts +3 -3
  100. package/plugins/index.d.ts +2 -1
  101. package/types.d.ts +8 -6
  102. package/ui/UIElement.d.ts +1 -1
  103. package/ui/UIView.d.ts +1 -1
  104. package/ui/elements/AccordionElement.d.ts +5 -5
  105. package/ui/elements/AccordionElement.js +4 -0
  106. package/ui/elements/ButtonElement.d.ts +3 -3
  107. package/ui/elements/ButtonGroupElement.d.ts +2 -2
  108. package/ui/elements/NavigationMenuElement.d.ts +5 -1
  109. package/ui/elements/NavigationMenuElement.js +3 -2
  110. package/ui/elements/PlaceholderElement.d.ts +2 -1
  111. package/ui/elements/SmallButtonElement.d.ts +1 -1
  112. package/ui/elements/TypographyElement.d.ts +1 -1
  113. package/ui/elements/form/FileManagerElement/styled.d.ts +9 -9
  114. package/ui/elements/form/FileManagerElement.d.ts +4 -3
  115. package/ui/elements/form/FormElement.d.ts +5 -5
  116. package/ui/elements/form/FormFieldElement.d.ts +6 -5
  117. package/ui/elements/form/FormFieldElement.js +5 -5
  118. package/ui/elements/form/InputElement.d.ts +1 -0
  119. package/ui/views/AdminView/HeaderSectionCenterElement.d.ts +2 -2
  120. package/ui/views/AdminView/HeaderSectionLeftElement.d.ts +2 -2
  121. package/ui/views/AdminView/HeaderSectionRightElement.d.ts +2 -2
  122. package/ui/views/AdminView/components/Hamburger.d.ts +2 -2
  123. package/ui/views/AdminView/components/Snackbar.d.ts +2 -2
  124. package/ui/views/FormView/FormContainerElement.d.ts +2 -2
  125. package/ui/views/FormView/FormFooterElement.d.ts +3 -3
  126. package/ui/views/FormView/FormHeaderElement.d.ts +2 -2
  127. package/ui/views/FormView.d.ts +1 -1
  128. package/ui/views/FormView.js +4 -2
  129. package/ui/views/OverlayView/ContentElement.d.ts +2 -2
  130. package/ui/views/OverlayView/HeaderElement.d.ts +5 -5
  131. package/ui/views/OverlayView/useOverlayView.d.ts +4 -5
  132. package/ui/views/OverlayView/useOverlayView.js +2 -2
  133. package/ui/views/OverlayView.d.ts +4 -6
  134. package/ui/views/SplitView/SplitViewPanelElement.d.ts +3 -3
  135. package/ui/views/SplitView.d.ts +1 -1
@@ -1,8 +1,9 @@
1
- /// <reference types="react" />
2
- declare function LeftSidebar({ toggleTag, queryParams: { tags } }: {
3
- toggleTag: any;
1
+ import React from "react";
2
+ interface LeftSidebarProps {
3
+ toggleTag: (item: string) => void;
4
4
  queryParams: {
5
- tags: any;
5
+ tags: string[];
6
6
  };
7
- }): JSX.Element;
7
+ }
8
+ declare const LeftSidebar: React.FC<LeftSidebarProps>;
8
9
  export default LeftSidebar;
@@ -54,9 +54,9 @@ var Tag = /*#__PURE__*/styled("div", {
54
54
  }
55
55
  });
56
56
 
57
- function LeftSidebar(_ref) {
58
- var toggleTag = _ref.toggleTag,
59
- tags = _ref.queryParams.tags;
57
+ var LeftSidebar = function LeftSidebar(props) {
58
+ var toggleTag = props.toggleTag,
59
+ tags = props.queryParams.tags;
60
60
  var activeTags = Array.isArray(tags) ? tags : [];
61
61
 
62
62
  var _useQuery = useQuery(LIST_TAGS),
@@ -90,6 +90,6 @@ function LeftSidebar(_ref) {
90
90
  icon: /*#__PURE__*/React.createElement(TagIcon, null)
91
91
  }), " ", item);
92
92
  })));
93
- }
93
+ };
94
94
 
95
95
  export default LeftSidebar;
@@ -1,3 +1,3 @@
1
- /// <reference types="react" />
2
- declare const NoPermissionView: () => JSX.Element;
1
+ import React from "react";
2
+ declare const NoPermissionView: React.FC;
3
3
  export default NoPermissionView;
@@ -1,2 +1,3 @@
1
- /// <reference types="react" />
2
- export default function DropFilesHere(): JSX.Element;
1
+ import React from "react";
2
+ declare const DropFilesHere: React.FC;
3
+ export default DropFilesHere;
@@ -6,8 +6,11 @@ var styles = /*#__PURE__*/css({
6
6
  position: "absolute",
7
7
  width: "100%"
8
8
  }, "label:styles;");
9
- export default function DropFilesHere() {
9
+
10
+ var DropFilesHere = function DropFilesHere() {
10
11
  return /*#__PURE__*/React.createElement("div", {
11
12
  className: styles
12
13
  }, /*#__PURE__*/React.createElement("div", null, "No results found."));
13
- }
14
+ };
15
+
16
+ export default DropFilesHere;
@@ -1 +1,4 @@
1
- export default function getFileTypePlugin(file: any): any;
1
+ import { AdminFileManagerFileTypePlugin } from "../../types";
2
+ import { FileManagerFileTypePlugin } from "../../plugins/FileManagerFileTypePlugin";
3
+ import { FileItem } from "./types";
4
+ export default function getFileTypePlugin(file: FileItem): AdminFileManagerFileTypePlugin | FileManagerFileTypePlugin;
@@ -9,6 +9,11 @@ export default function getFileTypePlugin(file) {
9
9
  }
10
10
 
11
11
  var fileTypePlugins = [].concat(_toConsumableArray(plugins.byType("admin-file-manager-file-type")), _toConsumableArray(plugins.byType(FileManagerFileTypePlugin.type)));
12
+ /**
13
+ * TODO: if we are searching last available plugin, we can refactor this.
14
+ * TODO: check out @pavel
15
+ */
16
+
12
17
  var plugin = null;
13
18
 
14
19
  for (var i = 0; i < fileTypePlugins.length; i++) {
@@ -1,2 +1,3 @@
1
- declare const _default: () => (file: File, options: import("@webiny/app/types").UploadOptions) => Promise<any>;
1
+ import { AppFileManagerStoragePlugin } from "@webiny/app/types";
2
+ declare const _default: () => AppFileManagerStoragePlugin["upload"];
2
3
  export default _default;
@@ -1,2 +1,5 @@
1
- declare const _default: (errors: any) => string;
1
+ declare const _default: (errors: Record<string, any>[]) => string | null;
2
+ /**
3
+ * Figure out correct types for the errors.
4
+ */
2
5
  export default _default;
@@ -1,4 +1,9 @@
1
1
  import bytes from "bytes";
2
+ /**
3
+ * Figure out correct types for the errors.
4
+ */
5
+ // TODO @ts-refactor
6
+
2
7
  export default (function (errors) {
3
8
  if (errors.length > 1) {
4
9
  var error = errors.find(function (error) {
@@ -0,0 +1,49 @@
1
+ export interface FileItem {
2
+ id: string;
3
+ name: string;
4
+ key: string;
5
+ src: string;
6
+ size: number;
7
+ type: string;
8
+ tags: string[];
9
+ createdOn: string;
10
+ createdBy: {
11
+ id: string;
12
+ };
13
+ [key: string]: any;
14
+ }
15
+ export interface CreateFileResponse {
16
+ fileManager: {
17
+ createFile: {
18
+ data: FileItem;
19
+ error?: Error | null;
20
+ };
21
+ };
22
+ }
23
+ export interface UpdateFileResponse {
24
+ fileManager: {
25
+ updateFile: {
26
+ data: FileItem;
27
+ error?: Error | null;
28
+ };
29
+ };
30
+ }
31
+ export interface ListFilesResponse {
32
+ fileManager: {
33
+ listFiles: {
34
+ data: FileItem[];
35
+ error?: Error | null;
36
+ meta: {
37
+ hasMoreItems: boolean;
38
+ totalItem: number;
39
+ cursor: string | null;
40
+ };
41
+ };
42
+ };
43
+ }
44
+ export interface ListFileTagsResponse {
45
+ fileManager: {
46
+ listTags: string[];
47
+ error: Error | null;
48
+ };
49
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -1,18 +1,23 @@
1
- import * as React from "react";
2
- declare type FileManagerProps = {
3
- onChange?: Function;
1
+ import React from "react";
2
+ import { FileItem } from "./FileManager/types";
3
+ export interface ShowFileManagerCallable {
4
+ (onChange?: (file?: FileItem | FileItem[]) => void): void;
5
+ }
6
+ export interface FileManagerPropsChildren {
7
+ showFileManager: ShowFileManagerCallable;
8
+ }
9
+ export interface FileManagerProps {
10
+ onChange?: (files: FileItem[] | FileItem) => void;
4
11
  onChangePick?: string[];
5
12
  images?: boolean;
6
13
  multiple?: boolean;
7
14
  accept?: Array<string>;
8
- children: ({ showFileManager: Function }: {
9
- showFileManager: any;
10
- }) => React.ReactNode;
15
+ children: (params: FileManagerPropsChildren) => React.ReactNode;
11
16
  maxSize?: number | string;
12
17
  multipleMaxCount?: number;
13
18
  multipleMaxSize?: number | string;
14
19
  onClose?: Function;
15
- onUploadCompletion?: Function;
16
- };
17
- export declare function FileManager({ children, ...rest }: FileManagerProps): JSX.Element;
18
- export {};
20
+ onUploadCompletion?: (files: FileItem[]) => void;
21
+ }
22
+ export declare type FileManagerPortalProps = Omit<FileManagerProps, "children">;
23
+ export declare const FileManager: React.FC<FileManagerProps>;
@@ -8,15 +8,11 @@ import _inherits from "@babel/runtime/helpers/inherits";
8
8
  import _createSuper from "@babel/runtime/helpers/createSuper";
9
9
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
10
10
  var _excluded = ["children"];
11
- import * as React from "react";
11
+ import React, { useCallback, useEffect, useRef, useState } from "react";
12
12
  import ReactDOM from "react-dom";
13
13
  import FileManagerView from "./FileManager/FileManagerView";
14
14
  import pick from "lodash/pick";
15
15
  import { FileManagerProvider } from "./FileManager/FileManagerContext";
16
- var useState = React.useState,
17
- useRef = React.useRef,
18
- useCallback = React.useCallback,
19
- useEffect = React.useEffect;
20
16
 
21
17
  var FileManagerPortal = /*#__PURE__*/function (_React$Component) {
22
18
  _inherits(FileManagerPortal, _React$Component);
@@ -67,15 +63,22 @@ var FileManagerPortal = /*#__PURE__*/function (_React$Component) {
67
63
  var container = this.container;
68
64
 
69
65
  var handleFileOnChange = function handleFileOnChange(files) {
66
+ if (!files || files.length === 0) {
67
+ return;
68
+ }
69
+
70
70
  var fields = Array.isArray(onChangePick) ? onChangePick : ["id", "name", "key", "src", "size", "type"];
71
71
 
72
- if (Array.isArray(files)) {
73
- onChange(files.map(function (file) {
72
+ if (Array.isArray(files) === true) {
73
+ var items = files.map(function (file) {
74
74
  return pick(file, fields);
75
- }));
76
- } else {
77
- onChange(pick(files, fields));
75
+ });
76
+ onChange(items);
77
+ return;
78
78
  }
79
+
80
+ var file = pick(files, fields);
81
+ onChange(file);
79
82
  };
80
83
 
81
84
  var props = {
@@ -101,7 +104,7 @@ var FileManagerPortal = /*#__PURE__*/function (_React$Component) {
101
104
  return FileManagerPortal;
102
105
  }(React.Component);
103
106
 
104
- export function FileManager(_ref) {
107
+ export var FileManager = function FileManager(_ref) {
105
108
  var children = _ref.children,
106
109
  rest = _objectWithoutProperties(_ref, _excluded);
107
110
 
@@ -130,4 +133,4 @@ export function FileManager(_ref) {
130
133
  })), children({
131
134
  showFileManager: showFileManager
132
135
  }));
133
- }
136
+ };
@@ -1,3 +1,3 @@
1
- /// <reference types="react" />
2
- declare const FloatingActionButton: (props: any) => JSX.Element;
1
+ import * as React from "react";
2
+ declare const FloatingActionButton: React.FC;
3
3
  export { FloatingActionButton };
@@ -1,4 +1,13 @@
1
- /// <reference types="react" />
2
- declare type Props = any;
3
- export default function MultiImageUpload({ imagePreviewProps, ...multiImageUploadProps }: Props): JSX.Element;
4
- export {};
1
+ import * as React from "react";
2
+ /**
3
+ * TODO @ts-refactor
4
+ */
5
+ interface Props {
6
+ imagePreviewProps: {
7
+ src: string;
8
+ [key: string]: any;
9
+ };
10
+ [key: string]: any;
11
+ }
12
+ declare const MultiImageUpload: React.FC<Props>;
13
+ export default MultiImageUpload;
@@ -2,13 +2,22 @@ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProper
2
2
  var _excluded = ["imagePreviewProps"];
3
3
  import * as React from "react";
4
4
  import { Image } from "@webiny/app/components/Image";
5
- import { MultiImageUpload as UiMultiImageUpload } from "@webiny/ui/ImageUpload"; // TODO: @adrian define props type
5
+ import { MultiImageUpload as UiMultiImageUpload } from "@webiny/ui/ImageUpload";
6
+ /**
7
+ * TODO @ts-refactor
8
+ */
6
9
 
7
- export default function MultiImageUpload(_ref) {
10
+ var MultiImageUpload = function MultiImageUpload(_ref) {
8
11
  var imagePreviewProps = _ref.imagePreviewProps,
9
12
  multiImageUploadProps = _objectWithoutProperties(_ref, _excluded);
10
13
 
11
- return /*#__PURE__*/React.createElement(UiMultiImageUpload, Object.assign({
14
+ return /*#__PURE__*/React.createElement(UiMultiImageUpload
15
+ /**
16
+ * TODO @ts-refactor
17
+ * It appers that renderImagePreview does not exist on UiMultiImageUpload. So how did this work?
18
+ */
19
+ // @ts-ignore
20
+ , Object.assign({
12
21
  renderImagePreview: function renderImagePreview(renderImageProps) {
13
22
  return /*#__PURE__*/React.createElement(Image, Object.assign({
14
23
  transform: {
@@ -17,4 +26,6 @@ export default function MultiImageUpload(_ref) {
17
26
  }, imagePreviewProps, renderImageProps));
18
27
  }
19
28
  }, multiImageUploadProps));
20
- }
29
+ };
30
+
31
+ export default MultiImageUpload;
@@ -1,23 +1,20 @@
1
1
  import * as React from "react";
2
- declare type OverlayLayoutProps = {
2
+ import { ExitHandler } from "react-transition-group/Transition";
3
+ interface OverlayLayoutProps {
3
4
  barMiddle?: React.ReactNode;
4
5
  barLeft?: React.ReactNode;
5
6
  barRight?: React.ReactNode;
6
7
  children: React.ReactNode;
7
- onExited?: Function;
8
+ onExited?: ExitHandler<HTMLElement>;
8
9
  style?: React.CSSProperties;
9
- };
10
- declare type State = {
10
+ }
11
+ interface State {
11
12
  isVisible: boolean;
12
- };
13
+ }
13
14
  export declare class OverlayLayout extends React.Component<OverlayLayoutProps, State> {
14
- constructor(props: any);
15
- static defaultProps: {
16
- onExited: any;
17
- };
18
- state: {
19
- isVisible: boolean;
20
- };
15
+ constructor(props: OverlayLayoutProps);
16
+ static defaultProps: Partial<OverlayLayoutProps>;
17
+ state: State;
21
18
  hideComponent(): void;
22
19
  componentWillUnmount(): void;
23
20
  render(): JSX.Element;
@@ -1,6 +1,8 @@
1
- /// <reference types="react" />
1
+ import React from "react";
2
2
  export declare const flexClass: string;
3
3
  export declare const gridNoPaddingClass: string;
4
- export declare const PermissionInfo: ({ title }: {
5
- title: any;
6
- }) => JSX.Element;
4
+ interface Props {
5
+ title: string;
6
+ }
7
+ export declare const PermissionInfo: React.FC<Props>;
8
+ export {};
@@ -1,3 +1,3 @@
1
- /// <reference types="react" />
1
+ import React from "react";
2
2
  import { RichTextEditorProps } from "@webiny/ui/RichTextEditor";
3
- export declare const RichTextEditor: (props: RichTextEditorProps) => JSX.Element;
3
+ export declare const RichTextEditor: React.FC<RichTextEditorProps>;
@@ -1,21 +1,25 @@
1
- import { API } from "@editorjs/editorjs";
1
+ import { HTMLPasteEvent } from "@editorjs/editorjs";
2
2
  import { TextAlign, Alignment } from "../utils";
3
- declare type Typography = {
3
+ interface Typography {
4
4
  [key: string]: {
5
5
  label: string;
6
6
  component: string;
7
7
  className: string;
8
8
  };
9
- };
10
- declare type HeaderData = {
9
+ }
10
+ export interface HeaderData {
11
11
  text: string;
12
- level: any;
13
- textAlign: TextAlign;
14
- };
15
- declare type HeaderConfig = {
12
+ level: number;
13
+ textAlign?: TextAlign;
14
+ alignment?: Alignment;
15
+ className?: string;
16
+ }
17
+ interface HeaderConfig {
16
18
  levels: number[];
17
19
  typography: Typography;
18
- };
20
+ placeholder?: string;
21
+ defaultLevel?: number;
22
+ }
19
23
  interface HeaderArgs {
20
24
  data: HeaderData;
21
25
  config: HeaderConfig;
@@ -23,15 +27,15 @@ interface HeaderArgs {
23
27
  readOnly: boolean;
24
28
  }
25
29
  declare class Header {
26
- api: API;
27
- readOnly: boolean;
28
- settingsButtons: any[];
29
- _CSS: any;
30
- _settings: any;
31
- _data: any;
32
- _element: any;
33
- alignments: Alignment[];
34
- typography: Typography;
30
+ private readonly api;
31
+ private readonly readOnly;
32
+ private readonly settingsButtons;
33
+ private readonly _CSS;
34
+ private readonly _settings;
35
+ private _data;
36
+ private _element;
37
+ private readonly alignments;
38
+ private readonly typography;
35
39
  /**
36
40
  * Render plugin`s main Element and fill it with saved data
37
41
  *
@@ -50,7 +54,7 @@ declare class Header {
50
54
  * @returns {HeaderData}
51
55
  * @private
52
56
  */
53
- normalizeData(data: any): any;
57
+ normalizeData(data: Partial<HeaderData>): HeaderData;
54
58
  /**
55
59
  * Return Tool's view
56
60
  *
@@ -69,13 +73,13 @@ declare class Header {
69
73
  *
70
74
  * @param {number} level - level to set
71
75
  */
72
- setLevel(level: any): void;
76
+ setLevel(level: number): void;
73
77
  /**
74
78
  * Callback for Block's settings buttons
75
79
  *
76
80
  * @param {number} alignment - level to set
77
81
  */
78
- setAlignment(alignment: any): void;
82
+ setAlignment(alignment: Alignment): void;
79
83
  /**
80
84
  * Method that specified how to merge two Text blocks.
81
85
  * Called by Editor.js by backspace at the beginning of the Block
@@ -83,7 +87,7 @@ declare class Header {
83
87
  * @param {HeaderData} data - saved data to merger with current block
84
88
  * @public
85
89
  */
86
- merge(data: any): void;
90
+ merge(data: HeaderData): void;
87
91
  /**
88
92
  * Validate Text block data:
89
93
  * - check for emptiness
@@ -92,7 +96,7 @@ declare class Header {
92
96
  * @returns {boolean} false if saved data is not correct, otherwise true
93
97
  * @public
94
98
  */
95
- validate(blockData: any): boolean;
99
+ validate(blockData: HeaderData): boolean;
96
100
  /**
97
101
  * Extract Tool's data from the view
98
102
  *
@@ -100,19 +104,14 @@ declare class Header {
100
104
  * @returns {HeaderData} - saved data
101
105
  * @public
102
106
  */
103
- save(toolsContent: any): {
104
- text: any;
105
- level: number;
106
- textAlign: TextAlign.START;
107
- className: any;
108
- };
107
+ save(toolsContent: HTMLHeadingElement): HeaderData;
109
108
  /**
110
109
  * Extract textAlign from className
111
110
  *
112
111
  * @param {string} className - heading element className
113
112
  * @returns {TextAlign} textAlign
114
113
  */
115
- getTextAlign(className: any): TextAlign.START;
114
+ getTextAlign(className: string): TextAlign;
116
115
  /**
117
116
  * Allow Header to be converted to/from other blocks
118
117
  */
@@ -139,7 +138,7 @@ declare class Header {
139
138
  * @returns {HeaderData} Current data
140
139
  * @private
141
140
  */
142
- get data(): any;
141
+ get data(): HeaderData;
143
142
  /**
144
143
  * Store data in plugin:
145
144
  * - at the this._data property
@@ -148,7 +147,7 @@ declare class Header {
148
147
  * @param {HeaderData} data — data to set
149
148
  * @private
150
149
  */
151
- set data(data: any);
150
+ set data(data: HeaderData);
152
151
  /**
153
152
  * Get tag for target level
154
153
  * By default returns second-leveled header
@@ -201,9 +200,9 @@ declare class Header {
201
200
  /**
202
201
  * Handle H1-H6 tags on paste to substitute it with header Tool
203
202
  *
204
- * @param {PasteEvent} event - event with pasted content
203
+ * @param {HTMLPasteEvent} event - event with pasted content
205
204
  */
206
- onPaste(event: any): void;
205
+ onPaste(event: HTMLPasteEvent): void;
207
206
  /**
208
207
  * Used by Editor.js paste handling API.
209
208
  * Provides configuration to handle H1-H6 tags.
@@ -288,12 +288,11 @@ var Header = /*#__PURE__*/function () {
288
288
  }, {
289
289
  key: "merge",
290
290
  value: function merge(data) {
291
- var newData = {
291
+ this.data = {
292
292
  text: this.data.text + data.text,
293
293
  level: this.data.level,
294
294
  alignment: this.data.alignment
295
295
  };
296
- this.data = newData;
297
296
  }
298
297
  /**
299
298
  * Validate Text block data:
@@ -607,7 +606,7 @@ var Header = /*#__PURE__*/function () {
607
606
  /**
608
607
  * Handle H1-H6 tags on paste to substitute it with header Tool
609
608
  *
610
- * @param {PasteEvent} event - event with pasted content
609
+ * @param {HTMLPasteEvent} event - event with pasted content
611
610
  */
612
611
 
613
612
  }, {
@@ -1,3 +1,30 @@
1
+ import { API } from "@editorjs/editorjs";
2
+ import { Tune } from "./types";
3
+ interface File {
4
+ src: string;
5
+ }
6
+ interface GetFileSourceCallable {
7
+ (file: File | string): string;
8
+ }
9
+ interface OnSelectFileCallable {
10
+ (file: File): string;
11
+ }
12
+ interface ImageToolData {
13
+ caption: string;
14
+ file: string;
15
+ }
16
+ interface ImageToolParams {
17
+ data: ImageToolData;
18
+ config: Config;
19
+ api: API;
20
+ readOnly: boolean;
21
+ }
22
+ interface Config {
23
+ getFileSrc: GetFileSourceCallable;
24
+ onSelectFile: OnSelectFileCallable;
25
+ actions: Tune[];
26
+ context: Record<string, any>;
27
+ }
1
28
  export default class ImageTool {
2
29
  private readonly api;
3
30
  private readonly readOnly;
@@ -22,12 +49,7 @@ export default class ImageTool {
22
49
  icon: string;
23
50
  title: string;
24
51
  };
25
- constructor({ data, config, api, readOnly }: {
26
- data: any;
27
- config: any;
28
- api: any;
29
- readOnly: any;
30
- });
52
+ constructor({ data, config, api, readOnly }: ImageToolParams);
31
53
  /**
32
54
  * Renders Block content
33
55
  *
@@ -43,7 +65,7 @@ export default class ImageTool {
43
65
  *
44
66
  * @returns {ImageToolData}
45
67
  */
46
- save(): any;
68
+ save(): ImageToolData;
47
69
  /**
48
70
  * Makes buttons with tunes: stretch image
49
71
  *
@@ -51,7 +73,7 @@ export default class ImageTool {
51
73
  *
52
74
  * @returns {Element}
53
75
  */
54
- renderSettings(): any;
76
+ renderSettings(): HTMLElement;
55
77
  /**
56
78
  * Stores all Tool's data
57
79
  *
@@ -59,7 +81,7 @@ export default class ImageTool {
59
81
  *
60
82
  * @param {ImageToolData} data - data in Image Tool format
61
83
  */
62
- set data(data: any);
84
+ set data(data: ImageToolData);
63
85
  /**
64
86
  * Return Tool data
65
87
  *
@@ -67,7 +89,7 @@ export default class ImageTool {
67
89
  *
68
90
  * @returns {ImageToolData}
69
91
  */
70
- get data(): any;
92
+ get data(): ImageToolData;
71
93
  /**
72
94
  * Set new image file
73
95
  *
@@ -75,7 +97,7 @@ export default class ImageTool {
75
97
  *
76
98
  * @param {object} file - uploaded file data
77
99
  */
78
- set image(file: any);
100
+ set image(file: File | string);
79
101
  /**
80
102
  * Callback fired when Block Tune is activated
81
103
  *
@@ -84,7 +106,7 @@ export default class ImageTool {
84
106
  * @param {string} tuneName - tune that has been clicked
85
107
  * @returns {void}
86
108
  */
87
- tuneToggled(tuneName: any): void;
109
+ tuneToggled(tuneName: string): void;
88
110
  /**
89
111
  * Set one tune
90
112
  *
@@ -92,6 +114,7 @@ export default class ImageTool {
92
114
  * @param {boolean} value - tune state
93
115
  * @returns {void}
94
116
  */
95
- setTune(tuneName: any, value: any): void;
117
+ setTune(tuneName: string, value: boolean): void;
96
118
  isReadOnly(): boolean;
97
119
  }
120
+ export {};
@@ -158,8 +158,10 @@ var ImageTool = /*#__PURE__*/function () {
158
158
  this._data.caption = data.caption || "";
159
159
  this.ui.fillCaption(this._data.caption);
160
160
  Tunes.tunes.forEach(function (_ref2) {
161
- var tune = _ref2.name;
162
- var value = typeof data[tune] !== "undefined" ? data[tune] === true || data[tune] === "true" : false;
161
+ var name = _ref2.name;
162
+ var tune = name;
163
+ var initialValue = data[tune];
164
+ var value = initialValue === true || initialValue === "true";
163
165
 
164
166
  _this2.setTune(tune, value);
165
167
  });