zs_library 0.2.2 → 0.3.4

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 +1651 -2
  36. package/package.json +60 -70
  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
@@ -0,0 +1,60 @@
1
+ import { UploadOptions, UploadResponseFormat, ImageConfig } from './types/types';
2
+ /**
3
+ * Params interface for Uploader constructor
4
+ */
5
+ interface UploaderParams {
6
+ /**
7
+ * Configuration for the uploader
8
+ */
9
+ config: ImageConfig;
10
+ /**
11
+ * Handles the upload response.
12
+ * @param {UploadResponseFormat} response - Response format expected from the backend on file uploading.
13
+ * @returns {void}
14
+ */
15
+ onUpload: (response: UploadResponseFormat) => void;
16
+ /**
17
+ *
18
+ * @param error : error type
19
+ * @returns void
20
+ */
21
+ onError: (error: string) => void;
22
+ }
23
+ /**
24
+ * Module for file uploading. Handle 3 scenarios:
25
+ * 1. Select file from device and upload
26
+ * 2. Upload by pasting URL
27
+ * 3. Upload by pasting file from Clipboard or by Drag'n'Drop
28
+ */
29
+ export default class Uploader {
30
+ private config;
31
+ private onUpload;
32
+ private onError;
33
+ /**
34
+ * @param params - uploader module params
35
+ * @param params.config - image tool config
36
+ * @param params.onUpload - one callback for all uploading (file, url, d-n-d, pasting)
37
+ * @param params.onError - callback for uploading errors
38
+ */
39
+ constructor({ config, onUpload, onError }: UploaderParams);
40
+ /**
41
+ * Handle clicks on the upload file button
42
+ * Fires ajax.transport()
43
+ * @param onPreview - callback fired when preview is ready
44
+ */
45
+ uploadSelectedFile({ onPreview }: UploadOptions): void;
46
+ /**
47
+ * Handle clicks on the upload file button
48
+ * Fires ajax.post()
49
+ * @param url - image source url
50
+ */
51
+ uploadByUrl(url: string): void;
52
+ /**
53
+ * Handle clicks on the upload file button
54
+ * Fires ajax.post()
55
+ * @param file - file pasted by drag-n-drop
56
+ * @param onPreview - file pasted by drag-n-drop
57
+ */
58
+ uploadByFile(file: Blob, { onPreview }: UploadOptions): void;
59
+ }
60
+ export {};
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Helper for making Elements with attributes
3
+ * @param tagName - new Element tag name
4
+ * @param classNames - list or name of CSS class
5
+ * @param attributes - any attributes
6
+ * @returns
7
+ */
8
+ export declare function make(tagName: string, classNames?: string[] | string | null, attributes?: {
9
+ [key: string]: string | boolean;
10
+ }): HTMLElement;
@@ -0,0 +1,7 @@
1
+ import { UploadResponseFormat } from '../types/types';
2
+ /**
3
+ * Check if passed object is a Promise
4
+ * @param object - object to check
5
+ * @returns
6
+ */
7
+ export default function isPromise(object: Promise<UploadResponseFormat>): object is Promise<UploadResponseFormat>;
@@ -0,0 +1,238 @@
1
+ import { API, PasteEvent } from '@editorjs/editorjs';
2
+ /**
3
+ * @description Tool's input and output data format
4
+ */
5
+ export interface AlertData {
6
+ align?: string;
7
+ type: string;
8
+ message: string;
9
+ }
10
+ export interface ConstructorArgs {
11
+ data: AlertData;
12
+ config: {
13
+ alertTypes: string[];
14
+ defaultType: string;
15
+ defaultAlign: string;
16
+ messagePlaceholder: string;
17
+ };
18
+ api: API;
19
+ readOnly: boolean;
20
+ }
21
+ export interface AlertCSS {
22
+ wrapper: string;
23
+ wrapperForType: (type: string) => string;
24
+ wrapperForAlignType: (alignType: string) => string;
25
+ message: string;
26
+ }
27
+ /**
28
+ * @class Alert
29
+ * @classdesc Alert Tool for Editor.js
30
+ * @property {AlertData} data - Alert Tool`s input and output data
31
+ * @property {object} api - Editor.js API instance
32
+ *
33
+ * @typedef {object} AlertData
34
+ * @description Alert Tool`s input and output data
35
+ * @property {string} type - Alert type
36
+ * @property {string} alignType - Alert align type
37
+ * @property {string} message - Alert message
38
+ *
39
+ * @typedef {object} AlertConfig
40
+ * @description Alert Tool`s initial configuration
41
+ * @property {string} defaultType - default Alert type
42
+ * @property {string} defaultAlignType - default align Alert type
43
+ * @property {string} messagePlaceholder - placeholder to show in Alert`s message input
44
+ */
45
+ export default class Alert {
46
+ /**
47
+ * Editor.js API
48
+ * @private
49
+ */
50
+ private api;
51
+ /**
52
+ * Read-only mode flag
53
+ * @private
54
+ */
55
+ private readOnly;
56
+ /**
57
+ * Block's data
58
+ * @private
59
+ */
60
+ private _data;
61
+ /**
62
+ * Alert Tool's CSS classes
63
+ */
64
+ private _CSS;
65
+ private container;
66
+ private alertTypes;
67
+ private defaultType;
68
+ private defaultAlign;
69
+ private messagePlaceholder;
70
+ /**
71
+ * Get Toolbox settings
72
+ *
73
+ * @public
74
+ * @returns {string}
75
+ */
76
+ static get toolbox(): {
77
+ icon: string;
78
+ title: string;
79
+ };
80
+ /**
81
+ * Allow to press Enter inside the Alert block
82
+ * @public
83
+ * @returns {boolean}
84
+ */
85
+ static get enableLineBreaks(): boolean;
86
+ /**
87
+ * Default Alert type
88
+ *
89
+ * @public
90
+ * @returns {string}
91
+ */
92
+ static get DEFAULT_TYPE(): string;
93
+ /**
94
+ * Default Alert align type
95
+ *
96
+ * @public
97
+ * @returns {string}
98
+ */
99
+ static get DEFAULT_ALIGN_TYPE(): string;
100
+ /**
101
+ * Default placeholder for Alert message
102
+ *
103
+ * @public
104
+ * @returns {string}
105
+ */
106
+ static get DEFAULT_MESSAGE_PLACEHOLDER(): string;
107
+ /**
108
+ * Supported Alert types
109
+ *
110
+ * @public
111
+ * @returns {array}
112
+ */
113
+ static get ALERT_TYPES(): string[];
114
+ /**
115
+ * Supported Align types
116
+ *
117
+ * @public
118
+ * @returns {array}
119
+ */
120
+ static get ALIGN_TYPES(): string[];
121
+ /**
122
+ * Alert Tool`s styles
123
+ *
124
+ * @returns {Object}
125
+ */
126
+ get CSS(): {
127
+ wrapper: string;
128
+ wrapperForType: (type: string) => string;
129
+ wrapperForAlignType: (alignType: string) => string;
130
+ message: string;
131
+ };
132
+ /**
133
+ * Render plugin`s main Element and fill it with saved data
134
+ *
135
+ * @param {AlertData} data — previously saved data
136
+ * @param {AlertConfig} config — user config for Tool
137
+ * @param {Object} api - Editor.js API
138
+ * @param {boolean} readOnly - read only mode flag
139
+ */
140
+ constructor({ data, config, api, readOnly }: ConstructorArgs);
141
+ /**
142
+ * Returns true to notify the core that read-only mode is supported
143
+ *
144
+ * @return {boolean}
145
+ */
146
+ static get isReadOnlySupported(): boolean;
147
+ /**
148
+ * Create Alert Tool container
149
+ *
150
+ * @returns {Element}
151
+ */
152
+ render(): HTMLElement;
153
+ /**
154
+ * Create Block's settings block
155
+ *
156
+ * @returns {array}
157
+ */
158
+ renderSettings(): {
159
+ icon: string;
160
+ name: string;
161
+ label: string;
162
+ toggle: string;
163
+ isActive: boolean;
164
+ onActivate: () => void;
165
+ }[];
166
+ /**
167
+ * Helper for formatting Alert Type / Align Type
168
+ *
169
+ * @param {string} type - Alert type or Align type
170
+ * @returns {string}
171
+ */
172
+ _getFormattedName(name: string): string;
173
+ /**
174
+ * Helper for changing style of Alert block with the selected Alert type
175
+ *
176
+ * @param {string} newType - new Alert type to be applied to the block
177
+ * @private
178
+ */
179
+ _changeAlertType(newType: string): void;
180
+ /**
181
+ * Helper for changing align of Alert block with the selected Align type
182
+ *
183
+ * @param {string} newAlign - new align type to be applied to the block
184
+ * @private
185
+ */
186
+ _changeAlignType(newAlign: string): void;
187
+ /**
188
+ * Extract Alert data from Alert Tool element
189
+ *
190
+ * @param {HTMLDivElement} alertElement - element to save
191
+ * @returns {AlertData}
192
+ */
193
+ save(alertElement: HTMLElement): {
194
+ message: string | undefined;
195
+ align?: string;
196
+ type: string;
197
+ };
198
+ /**
199
+ * Helper for making Elements with attributes
200
+ *
201
+ * @param {string} tagName - new Element tag name
202
+ * @param {array|string} classNames - list or name of CSS classname(s)
203
+ * @param {Object} attributes - any attributes
204
+ * @returns {Element}
205
+ * @private
206
+ */
207
+ _make(tagName: string, classNames?: string[] | string | null, attributes?: {
208
+ [x: string]: string;
209
+ }): HTMLElement;
210
+ /**
211
+ * Fill Alert's message with the pasted content
212
+ *
213
+ * @param {PasteEvent} event - event with pasted content
214
+ */
215
+ onPaste(event: PasteEvent): void;
216
+ /**
217
+ * Allow Alert to be converted to/from other blocks
218
+ */
219
+ static get conversionConfig(): {
220
+ export: (data: {
221
+ message: string;
222
+ }) => string;
223
+ import: (string: string) => {
224
+ message: string;
225
+ type: string;
226
+ alignType: string;
227
+ };
228
+ };
229
+ /**
230
+ * Sanitizer config for Alert Tool saved data
231
+ * @returns {Object}
232
+ */
233
+ static get sanitize(): {
234
+ message: boolean;
235
+ type: boolean;
236
+ alignType: boolean;
237
+ };
238
+ }
@@ -0,0 +1,270 @@
1
+ /**
2
+ * Delimiter plugin for Editor.js
3
+ * Supported config:
4
+ * * defaultStyle {string} (Default: 'star')
5
+ * * styleOptions {string[]} (Default: Delimiter.DELIMITER_STYLES)
6
+ * * defaultLineWidth {number} (Default: 25)
7
+ * * lineWidthOptions {number[]} (Default: Delimiter.SUPPORTED_LINE_WIDTHS)
8
+ * * defaultLineThickness {number} (Default: 2)
9
+ * * lineThicknessOptions {number[]} (Default: Delimiter.LINE_THICKNESS)
10
+ *
11
+ * @class Delimiter
12
+ * @typedef {Delimiter}
13
+ */
14
+ export default class Delimiter {
15
+ /**
16
+ * Editor.js Toolbox settings
17
+ *
18
+ * @static
19
+ * @readonly
20
+ * @type {{ icon: any; title: string; }}
21
+ */
22
+ static get toolbox(): {
23
+ icon: string;
24
+ title: string;
25
+ };
26
+ /**
27
+ * To notify Editor.js core that read-only is supported
28
+ *
29
+ * @static
30
+ * @readonly
31
+ * @type {boolean}
32
+ */
33
+ static get isReadOnlySupported(): boolean;
34
+ /**
35
+ * All supported delimiter styles
36
+ *
37
+ * @static
38
+ * @readonly
39
+ * @type {string[]}
40
+ */
41
+ static get DELIMITER_STYLES(): string[];
42
+ /**
43
+ * Default delimiter style
44
+ *
45
+ * @static
46
+ * @readonly
47
+ * @type {string}
48
+ */
49
+ static get DEFAULT_DELIMITER_STYLE(): string;
50
+ /**
51
+ * All supported widths for delimiter line style
52
+ *
53
+ * @static
54
+ * @readonly
55
+ * @type {number[]}
56
+ */
57
+ static get SUPPORTED_LINE_WIDTHS(): number[];
58
+ /**
59
+ * Default width for delimiter line style
60
+ *
61
+ * @static
62
+ * @readonly
63
+ * @type {number}
64
+ */
65
+ static get DEFAULT_LINE_WIDTH(): number;
66
+ /**
67
+ * All supported thickness options for delimiter line style
68
+ *
69
+ * @static
70
+ * @readonly
71
+ * @type {number[]}
72
+ */
73
+ static get LINE_THICKNESS(): number[];
74
+ /**
75
+ * Default thickness for delimiter line style
76
+ *
77
+ * @static
78
+ * @readonly
79
+ * @type {number}
80
+ */
81
+ static get DEFAULT_LINE_THICKNESS(): number;
82
+ /**
83
+ * Automatic sanitize config for Editor.js
84
+ *
85
+ * @static
86
+ * @readonly
87
+ * @type {{ style: boolean; lineWidth: boolean; lineThickness: boolean; }}
88
+ */
89
+ static get sanitize(): {
90
+ style: boolean;
91
+ lineWidth: boolean;
92
+ lineThickness: boolean;
93
+ };
94
+ /**
95
+ * Creates an instance of Delimiter.
96
+ *
97
+ * @constructor
98
+ * @param {{ api: {}; config: {}; data: {}; }} props
99
+ */
100
+ constructor({ api, config, data }: {
101
+ api: any;
102
+ config: any;
103
+ data: any;
104
+ });
105
+ /**
106
+ * All available delimiter styles
107
+ * - Finds intersection between supported and user selected delimiter styles
108
+ *
109
+ * @readonly
110
+ * @type {string[]}
111
+ */
112
+ get availableDelimiterStyles(): string[];
113
+ /**
114
+ * User's default delimiter style
115
+ * - Finds union of user choice and the actual default
116
+ *
117
+ * @readonly
118
+ * @type {string}
119
+ */
120
+ get userDefaultDelimiterStyle(): string;
121
+ /**
122
+ * All available widths for delimiter line style
123
+ * - Finds all valid user selected line widths (falls back to default when empty)
124
+ *
125
+ * @readonly
126
+ * @type {number[]}
127
+ */
128
+ get availableLineWidths(): number[];
129
+ /**
130
+ * User's default line width
131
+ * - Finds union of user choice and the actual default
132
+ *
133
+ * @readonly
134
+ * @type {number}
135
+ */
136
+ get userDefaultLineWidth(): number;
137
+ /**
138
+ * All available line thickness options
139
+ * - Finds intersection between supported and user selected line thickness options
140
+ *
141
+ * @readonly
142
+ * @type {number[]}
143
+ */
144
+ get availableLineThickness(): number[];
145
+ /**
146
+ * User's default line thickness
147
+ * - Finds union of user choice and the actual default
148
+ *
149
+ * @readonly
150
+ * @type {number}
151
+ */
152
+ get userDefaultLineThickness(): number;
153
+ /**
154
+ * To normalize input data
155
+ *
156
+ * @param {*} data
157
+ * @returns {{ style: string; lineWidth: number; lineThickness: number; }}
158
+ */
159
+ _normalizeData(data: any): {};
160
+ /**
161
+ * Current delimiter style
162
+ *
163
+ * @readonly
164
+ * @type {string}
165
+ */
166
+ get currentDelimiterStyle(): string;
167
+ /**
168
+ * Current width for delimiter line style
169
+ *
170
+ * @readonly
171
+ * @type {number}
172
+ */
173
+ get currentLineWidth(): number;
174
+ /**
175
+ * Current thickness for delimiter line style
176
+ *
177
+ * @readonly
178
+ * @type {number}
179
+ */
180
+ get currentLineThickness(): number;
181
+ /**
182
+ * Create a child element of the block parent
183
+ *
184
+ * @returns {*}
185
+ */
186
+ _createChildElement(): HTMLSpanElement;
187
+ /**
188
+ * Create and return block element
189
+ *
190
+ * @returns {*}
191
+ */
192
+ _getElement(): HTMLElement;
193
+ /**
194
+ * Replace the current element with a new one
195
+ */
196
+ _replaceElement(): void;
197
+ /**
198
+ * Callback for Delimiter style change to star
199
+ */
200
+ _setStar(): void;
201
+ /**
202
+ * Callback for Delimiter style change to dash
203
+ */
204
+ _setDash(): void;
205
+ /**
206
+ * Callback for Delimiter style change (to line) or line width change
207
+ *
208
+ * @param {number} newWidth
209
+ */
210
+ _setLine(newWidth: any): void;
211
+ /**
212
+ * Callback for line thickness change
213
+ *
214
+ * @param {number} newThickness
215
+ */
216
+ _setLineThickness(newThickness: any): void;
217
+ /**
218
+ * HTML element to render on the UI by Editor.js
219
+ *
220
+ * @returns {*}
221
+ */
222
+ render(): any;
223
+ /**
224
+ * Editor.js save method to extract block data from the UI
225
+ *
226
+ * @param {*} blockContent
227
+ * @returns {{ style: string; lineWidth: number; lineThickness: number; }}
228
+ */
229
+ save(): {
230
+ style: string;
231
+ lineWidth: number;
232
+ lineThickness: number;
233
+ } | {
234
+ style: string;
235
+ lineWidth?: undefined;
236
+ lineThickness?: undefined;
237
+ };
238
+ /**
239
+ * Get formatted label for Block settings menu
240
+ *
241
+ * @param {string} name
242
+ * @param {string} prefix
243
+ * @returns {string}
244
+ */
245
+ _getFormattedLabel(name: any, prefix: any, suffix: any): any;
246
+ /**
247
+ * Create a Block menu setting
248
+ *
249
+ * @param {string} icon
250
+ * @param {string} label
251
+ * @param {*} onActivate
252
+ * @param {boolean} isActive
253
+ * @param {string} group
254
+ * @returns {{ icon: string; label: string; onActivate: any; isActive: boolean; closeOnActivate: boolean; toggle: string; }}
255
+ */
256
+ _createSetting: (icon: any, label: any, onActivate: any, isActive: any, group: any) => {
257
+ icon: any;
258
+ label: any;
259
+ onActivate: any;
260
+ isActive: any;
261
+ closeOnActivate: boolean;
262
+ toggle: any;
263
+ };
264
+ /**
265
+ * Block settings menu items
266
+ *
267
+ * @returns {[{*}]}
268
+ */
269
+ renderSettings(): any[];
270
+ }