@ebl-vue/editorjs 2.31.8

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 (69) hide show
  1. package/LICENSE +190 -0
  2. package/README.md +244 -0
  3. package/dist/editorjs.mjs +11242 -0
  4. package/dist/editorjs.umd.js +51 -0
  5. package/dist/vendor.LICENSE.txt +462 -0
  6. package/package.json +80 -0
  7. package/types/api/block.d.ts +87 -0
  8. package/types/api/blocks.d.ts +160 -0
  9. package/types/api/caret.d.ts +67 -0
  10. package/types/api/events.d.ts +28 -0
  11. package/types/api/i18n.d.ts +11 -0
  12. package/types/api/index.d.ts +17 -0
  13. package/types/api/inline-toolbar.d.ts +15 -0
  14. package/types/api/listeners.d.ts +32 -0
  15. package/types/api/notifier.d.ts +14 -0
  16. package/types/api/readonly.d.ts +17 -0
  17. package/types/api/sanitizer.d.ts +14 -0
  18. package/types/api/saver.d.ts +13 -0
  19. package/types/api/selection.d.ts +41 -0
  20. package/types/api/styles.d.ts +44 -0
  21. package/types/api/toolbar.d.ts +26 -0
  22. package/types/api/tools.d.ts +11 -0
  23. package/types/api/tooltip.d.ts +30 -0
  24. package/types/api/ui.d.ts +24 -0
  25. package/types/block-tunes/block-tune-data.d.ts +1 -0
  26. package/types/block-tunes/block-tune.d.ts +70 -0
  27. package/types/block-tunes/index.d.ts +1 -0
  28. package/types/configs/conversion-config.ts +26 -0
  29. package/types/configs/editor-config.d.ts +118 -0
  30. package/types/configs/i18n-config.d.ts +16 -0
  31. package/types/configs/i18n-dictionary.d.ts +93 -0
  32. package/types/configs/index.d.ts +7 -0
  33. package/types/configs/log-levels.d.ts +9 -0
  34. package/types/configs/paste-config.d.ts +38 -0
  35. package/types/configs/sanitizer-config.d.ts +43 -0
  36. package/types/data-formats/block-data.d.ts +23 -0
  37. package/types/data-formats/block-id.ts +4 -0
  38. package/types/data-formats/index.d.ts +2 -0
  39. package/types/data-formats/output-data.d.ts +46 -0
  40. package/types/events/block/Base.ts +11 -0
  41. package/types/events/block/BlockAdded.ts +21 -0
  42. package/types/events/block/BlockChanged.ts +21 -0
  43. package/types/events/block/BlockMoved.ts +26 -0
  44. package/types/events/block/BlockRemoved.ts +21 -0
  45. package/types/events/block/index.ts +44 -0
  46. package/types/index.d.ts +190 -0
  47. package/types/tools/adapters/base-tool-adapter.d.ts +76 -0
  48. package/types/tools/adapters/block-tool-adapter.d.ts +78 -0
  49. package/types/tools/adapters/block-tune-adapter.d.ts +14 -0
  50. package/types/tools/adapters/inline-tool-adapter.d.ts +15 -0
  51. package/types/tools/adapters/tool-factory.d.ts +5 -0
  52. package/types/tools/adapters/tool-type.ts +18 -0
  53. package/types/tools/adapters/tools-collection.d.ts +34 -0
  54. package/types/tools/block-tool-data.d.ts +5 -0
  55. package/types/tools/block-tool.d.ts +121 -0
  56. package/types/tools/hook-events.d.ts +23 -0
  57. package/types/tools/index.d.ts +16 -0
  58. package/types/tools/inline-tool.d.ts +66 -0
  59. package/types/tools/menu-config.d.ts +54 -0
  60. package/types/tools/paste-events.d.ts +52 -0
  61. package/types/tools/tool-config.d.ts +4 -0
  62. package/types/tools/tool-settings.d.ts +91 -0
  63. package/types/tools/tool.d.ts +60 -0
  64. package/types/utils/popover/hint.d.ts +29 -0
  65. package/types/utils/popover/index.d.ts +5 -0
  66. package/types/utils/popover/popover-event.ts +15 -0
  67. package/types/utils/popover/popover-item-type.ts +13 -0
  68. package/types/utils/popover/popover-item.d.ts +248 -0
  69. package/types/utils/popover/popover.d.ts +101 -0
@@ -0,0 +1,118 @@
1
+ import {ToolConstructable, ToolSettings} from '../tools';
2
+ import {API, LogLevels, OutputData} from '../index';
3
+ import {SanitizerConfig} from './sanitizer-config';
4
+ import {I18nConfig} from './i18n-config';
5
+ import { BlockMutationEvent } from '../events/block';
6
+
7
+ export interface EditorConfig {
8
+ /**
9
+ * Element where Editor will be append
10
+ * @deprecated property will be removed in the next major release, use holder instead
11
+ */
12
+ holderId?: string | HTMLElement;
13
+
14
+ /**
15
+ * Element where Editor will be appended
16
+ */
17
+ holder?: string | HTMLElement;
18
+
19
+ /**
20
+ * If true, set caret at the first Block after Editor is ready
21
+ */
22
+ autofocus?: boolean;
23
+
24
+ /**
25
+ * This Tool will be used as default
26
+ * Name should be equal to one of Tool`s keys of passed tools
27
+ * If not specified, Paragraph Tool will be used
28
+ */
29
+ defaultBlock?: string;
30
+
31
+ /**
32
+ * @deprecated
33
+ * This property will be deprecated in the next major release.
34
+ * Use the 'defaultBlock' property instead.
35
+ */
36
+ initialBlock?: string;
37
+
38
+ /**
39
+ * First Block placeholder
40
+ */
41
+ placeholder?: string|false;
42
+
43
+ /**
44
+ * Define default sanitizer configuration
45
+ * @see {@link sanitizer}
46
+ */
47
+ sanitizer?: SanitizerConfig;
48
+
49
+ /**
50
+ * If true, toolbar won't be shown
51
+ */
52
+ hideToolbar?: boolean;
53
+
54
+ /**
55
+ * Map of Tools to use
56
+ */
57
+ tools?: {
58
+ [toolName: string]: ToolConstructable|ToolSettings;
59
+ }
60
+
61
+ /**
62
+ * Data to render on Editor start
63
+ */
64
+ data?: OutputData;
65
+
66
+ /**
67
+ * Height of Editor's bottom area that allows to set focus on the last Block
68
+ */
69
+ minHeight?: number;
70
+
71
+ /**
72
+ * Editors log level (how many logs you want to see)
73
+ */
74
+ logLevel?: LogLevels;
75
+
76
+ /**
77
+ * Enable read-only mode
78
+ */
79
+ readOnly?: boolean;
80
+
81
+ /**
82
+ * Internalization config
83
+ */
84
+ i18n?: I18nConfig;
85
+
86
+ /**
87
+ * Fires when Editor is ready to work
88
+ */
89
+ onReady?(): void;
90
+
91
+ /**
92
+ * Fires when something changed in DOM
93
+ * @param api - editor.js api
94
+ * @param event - custom event describing mutation. If several mutations happened at once, they will be batched and you'll get an array of events here.
95
+ */
96
+ onChange?(api: API, event: BlockMutationEvent | BlockMutationEvent[]): void;
97
+
98
+ /**
99
+ * Defines default toolbar for all tools.
100
+ */
101
+ inlineToolbar?: string[]|boolean;
102
+
103
+ /**
104
+ * Common Block Tunes list. Will be added to all the blocks which do not specify their own 'tunes' set
105
+ */
106
+ tunes?: string[];
107
+
108
+ /**
109
+ * Section for style-related settings
110
+ */
111
+ style?: {
112
+ /**
113
+ * A random value to handle Content Security Policy "style-src" policy
114
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/nonce
115
+ */
116
+ nonce?: string;
117
+ }
118
+ }
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Available options of i18n config property
3
+ */
4
+ import { I18nDictionary } from './i18n-dictionary';
5
+
6
+ export interface I18nConfig {
7
+ /**
8
+ * Dictionary used for translation
9
+ */
10
+ messages?: I18nDictionary;
11
+
12
+ /**
13
+ * Text direction. If not set, uses ltr
14
+ */
15
+ direction?: 'ltr' | 'rtl';
16
+ }
@@ -0,0 +1,93 @@
1
+ /**
2
+ * Structure of the i18n dictionary
3
+ */
4
+ export interface I18nDictionary {
5
+ /**
6
+ * Section for translation Tool Names: both block and inline tools
7
+ * Example:
8
+ * "toolNames": {
9
+ * "Text": "Параграф",
10
+ * "Heading": "Заголовок",
11
+ * "List": "Список",
12
+ * ...
13
+ * },
14
+ */
15
+ toolNames?: Dictionary;
16
+
17
+ /**
18
+ * Section for passing translations to the external tools classes
19
+ * The first-level keys of this object should be equal of keys ot the 'tools' property of EditorConfig
20
+ * Includes internal tools: "paragraph", "stub"
21
+ *
22
+ * Example:
23
+ * "tools": {
24
+ * "warning": {
25
+ * "Title": "Название",
26
+ * "Message": "Сообщение",
27
+ * },
28
+ * "link": {
29
+ * "Add a link": "Вставьте ссылку"
30
+ * },
31
+ * },
32
+ */
33
+ tools?: Dictionary;
34
+
35
+ /**
36
+ * Section allows to translate Block Tunes
37
+ * The first-level keys of this object should be equal of 'name' ot the 'tools.<toolName>.tunes' property of EditorConfig
38
+ * Including some internal block-tunes: "delete", "moveUp", "moveDown
39
+ *
40
+ * Example:
41
+ * "blockTunes": {
42
+ * "delete": {
43
+ * "Delete": "Удалить"
44
+ * },
45
+ * "moveUp": {
46
+ * "Move up": "Переместить вверх"
47
+ * },
48
+ * "moveDown": {
49
+ * "Move down": "Переместить вниз"
50
+ * }
51
+ * },
52
+ */
53
+ blockTunes?: Dictionary;
54
+
55
+ /**
56
+ * Translation of internal UI components of the editor.js core
57
+ */
58
+ ui?: Dictionary;
59
+ }
60
+
61
+ /**
62
+ * Represent item of the I18nDictionary config
63
+ */
64
+ export interface Dictionary {
65
+ /**
66
+ * The keys of the object can represent two entities:
67
+ * 1. Dictionary key usually is an original string from default locale, like "Convert to"
68
+ * 2. Sub-namespace section, like "toolbar.converter.<...>"
69
+ *
70
+ * Example of 1:
71
+ * toolbox: {
72
+ * "Add": "Добавить",
73
+ * }
74
+ *
75
+ * Example of 2:
76
+ * ui: {
77
+ * toolbar: {
78
+ * toolbox: { <-- Example of 1
79
+ * "Add": "Добавить"
80
+ * }
81
+ * }
82
+ * }
83
+ */
84
+ [key: string]: DictValue;
85
+ }
86
+
87
+ /**
88
+ * The value of the dictionary can be:
89
+ * - other dictionary
90
+ * - result translate string
91
+ */
92
+ export type DictValue = {[key: string]: Dictionary | string} | string;
93
+
@@ -0,0 +1,7 @@
1
+ export * from './editor-config';
2
+ export * from './sanitizer-config';
3
+ export * from './paste-config';
4
+ export * from './conversion-config';
5
+ export * from './log-levels';
6
+ export * from './i18n-config';
7
+ export * from './i18n-dictionary';
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Available log levels
3
+ */
4
+ export enum LogLevels {
5
+ VERBOSE = 'VERBOSE',
6
+ INFO = 'INFO',
7
+ WARN = 'WARN',
8
+ ERROR = 'ERROR',
9
+ }
@@ -0,0 +1,38 @@
1
+ import { SanitizerConfig } from './sanitizer-config';
2
+
3
+ /**
4
+ * Tool onPaste configuration object
5
+ */
6
+ interface PasteConfigSpecified {
7
+ /**
8
+ * Array of tags Tool can substitute.
9
+ *
10
+ * Could also contain a sanitize-config if you need to save some tag's attribute.
11
+ * For example:
12
+ * [
13
+ * {
14
+ * img: { src: true },
15
+ * }
16
+ * ],
17
+ * @type string[]
18
+ */
19
+ tags?: (string | SanitizerConfig)[];
20
+
21
+ /**
22
+ * Object of string patterns Tool can substitute.
23
+ * Key is your internal key and value is RegExp
24
+ *
25
+ * @type {{[key: string]: RegExp}}
26
+ */
27
+ patterns?: {[key: string]: RegExp};
28
+
29
+ /**
30
+ * Object with arrays of extensions and MIME types Tool can substitute
31
+ */
32
+ files?: {extensions?: string[], mimeTypes?: string[]};
33
+ }
34
+
35
+ /**
36
+ * Alias for PasteConfig with false
37
+ */
38
+ export type PasteConfig = PasteConfigSpecified | false;
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Sanitizer config of each HTML element
3
+ * @see {@link https://github.com/guardian/html-janitor#options}
4
+ */
5
+ export type TagConfig = boolean | { [attr: string]: boolean | string };
6
+
7
+ export type SanitizerRule = TagConfig | ((el: Element) => TagConfig)
8
+
9
+ export interface SanitizerConfig {
10
+ /**
11
+ * Tag name and params not to be stripped off
12
+ * @see {@link https://github.com/guardian/html-janitor}
13
+ *
14
+ * @example Save P tags
15
+ * p: true
16
+ *
17
+ * @example Save A tags and do not strip HREF attribute
18
+ * a: {
19
+ * href: true
20
+ * }
21
+ *
22
+ * @example Save A tags with TARGET="_blank" attribute
23
+ * a: function (aTag) {
24
+ * return aTag.target === '_black';
25
+ * }
26
+ *
27
+ * @example Save U tags that are not empty
28
+ * u: function(el){
29
+ * return el.textContent !== '';
30
+ * }
31
+ *
32
+ * @example For blockquote with class 'indent' save CLASS and STYLE attributes
33
+ * Otherwise strip all attributes
34
+ * blockquote: function(el) {
35
+ * if (el.classList.contains('indent')) {
36
+ * return { 'class': true, 'style': true };
37
+ * } else {
38
+ * return {};
39
+ * }
40
+ * }
41
+ */
42
+ [key: string]: SanitizerRule;
43
+ }
@@ -0,0 +1,23 @@
1
+ import {BlockToolData} from '../tools';
2
+ import { BlockId } from './block-id';
3
+
4
+ /**
5
+ * Tool's saved data
6
+ */
7
+ export interface SavedData {
8
+ id: BlockId;
9
+ tool: string;
10
+ data: BlockToolData;
11
+ time: number;
12
+ }
13
+
14
+ /**
15
+ * Tool's data after validation
16
+ */
17
+ export interface ValidatedData {
18
+ id?: BlockId;
19
+ tool?: string;
20
+ data?: BlockToolData;
21
+ time?: number;
22
+ isValid: boolean;
23
+ }
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Unique identifier of a block
3
+ */
4
+ export type BlockId = string;
@@ -0,0 +1,2 @@
1
+ export * from './block-data';
2
+ export * from './output-data';
@@ -0,0 +1,46 @@
1
+ import {BlockToolData} from '../tools';
2
+ import {BlockTuneData} from '../block-tunes/block-tune-data';
3
+ import { BlockId } from './block-id';
4
+
5
+ /**
6
+ * Output of one Tool
7
+ *
8
+ * @template Type - the string literal describing a tool type
9
+ * @template Data - the structure describing a data object supported by the tool
10
+ */
11
+ export interface OutputBlockData<Type extends string = string, Data extends object = any> {
12
+ /**
13
+ * Unique Id of the block
14
+ */
15
+ id?: BlockId;
16
+ /**
17
+ * Tool type
18
+ */
19
+ type: Type;
20
+ /**
21
+ * Saved Block data
22
+ */
23
+ data: BlockToolData<Data>;
24
+
25
+ /**
26
+ * Block Tunes data
27
+ */
28
+ tunes?: {[name: string]: BlockTuneData};
29
+ }
30
+
31
+ export interface OutputData {
32
+ /**
33
+ * Editor's version
34
+ */
35
+ version?: string;
36
+
37
+ /**
38
+ * Timestamp of saving in milliseconds
39
+ */
40
+ time?: number;
41
+
42
+ /**
43
+ * Saved Blocks
44
+ */
45
+ blocks: OutputBlockData[];
46
+ }
@@ -0,0 +1,11 @@
1
+ import type { BlockAPI } from '../../api';
2
+
3
+ /**
4
+ * Details of CustomEvent fired on block mutation
5
+ */
6
+ export interface BlockMutationEventDetail {
7
+ /**
8
+ * Affected block
9
+ */
10
+ target: BlockAPI;
11
+ }
@@ -0,0 +1,21 @@
1
+ import type { BlockMutationEventDetail } from './Base';
2
+
3
+ /**
4
+ * Type name of CustomEvent related to block added event
5
+ */
6
+ export const BlockAddedMutationType = 'block-added';
7
+
8
+ /**
9
+ * Information about added block
10
+ */
11
+ interface BlockAddedEventDetail extends BlockMutationEventDetail {
12
+ /**
13
+ * Index of added block
14
+ */
15
+ index: number;
16
+ }
17
+
18
+ /**
19
+ * Event will be fired when the new block is added to the editor
20
+ */
21
+ export type BlockAddedEvent = CustomEvent<BlockAddedEventDetail>;
@@ -0,0 +1,21 @@
1
+ import type { BlockMutationEventDetail } from './Base';
2
+
3
+ /**
4
+ * Type name of CustomEvent related to block changed event
5
+ */
6
+ export const BlockChangedMutationType = 'block-changed';
7
+
8
+ /**
9
+ * Information about changed block
10
+ */
11
+ interface BlockChangedEventDetail extends BlockMutationEventDetail {
12
+ /**
13
+ * Index of changed block
14
+ */
15
+ index: number;
16
+ }
17
+
18
+ /**
19
+ * Event will be fired when some block is changed
20
+ */
21
+ export type BlockChangedEvent = CustomEvent<BlockChangedEventDetail>;
@@ -0,0 +1,26 @@
1
+ import type { BlockMutationEventDetail } from './Base';
2
+
3
+ /**
4
+ * Type name of CustomEvent related to block moved event
5
+ */
6
+ export const BlockMovedMutationType = 'block-moved';
7
+
8
+ /**
9
+ * Information about moved block
10
+ */
11
+ interface BlockMovedEventDetail extends BlockMutationEventDetail {
12
+ /**
13
+ * Previous block position
14
+ */
15
+ fromIndex: number;
16
+
17
+ /**
18
+ * New block position
19
+ */
20
+ toIndex: number;
21
+ }
22
+
23
+ /**
24
+ * Event will be fired when some block is moved to another position
25
+ */
26
+ export type BlockMovedEvent = CustomEvent<BlockMovedEventDetail>;
@@ -0,0 +1,21 @@
1
+ import type { BlockMutationEventDetail } from './Base';
2
+
3
+ /**
4
+ * Type name of CustomEvent related to block removed event
5
+ */
6
+ export const BlockRemovedMutationType = 'block-removed';
7
+
8
+ /**
9
+ * Information about removed block
10
+ */
11
+ interface BlockRemovedEventDetail extends BlockMutationEventDetail {
12
+ /**
13
+ * Index of removed block
14
+ */
15
+ index: number;
16
+ }
17
+
18
+ /**
19
+ * Event will be fired when some block is removed
20
+ */
21
+ export type BlockRemovedEvent = CustomEvent<BlockRemovedEventDetail>;
@@ -0,0 +1,44 @@
1
+ import type { BlockAddedEvent, BlockAddedMutationType } from './BlockAdded';
2
+ import type { BlockChangedEvent, BlockChangedMutationType } from './BlockChanged';
3
+ import type { BlockMovedEvent, BlockMovedMutationType } from './BlockMoved';
4
+ import type { BlockRemovedEvent, BlockRemovedMutationType } from './BlockRemoved';
5
+
6
+ /**
7
+ * Map for Custom Events related to block mutation types
8
+ */
9
+ export interface BlockMutationEventMap {
10
+ /**
11
+ * New Block added
12
+ */
13
+ [BlockAddedMutationType]: BlockAddedEvent;
14
+
15
+ /**
16
+ * On Block deletion
17
+ */
18
+ [BlockRemovedMutationType]: BlockRemovedEvent;
19
+
20
+ /**
21
+ * Moving of a Block
22
+ */
23
+ [BlockMovedMutationType]: BlockMovedEvent;
24
+
25
+ /**
26
+ * Any changes inside the Block
27
+ */
28
+ [BlockChangedMutationType]: BlockChangedEvent;
29
+ }
30
+
31
+ /**
32
+ * What kind of modification happened with the Block
33
+ */
34
+ export type BlockMutationType = keyof BlockMutationEventMap;
35
+
36
+ /**
37
+ * Returns a union type of values of passed object
38
+ */
39
+ type ValueOf<T> = T[keyof T];
40
+
41
+ /**
42
+ * CustomEvent describing a change related to a block
43
+ */
44
+ export type BlockMutationEvent = ValueOf<BlockMutationEventMap>;