@jackuait/blok 0.1.1 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,44 +1,99 @@
1
1
  /**
2
- * Describes styles API
2
+ * Describes styles API - provides Tailwind CSS utility classes for tool styling.
3
+ *
4
+ * All values are Tailwind utility class strings that can be extended using tailwind-merge.
5
+ *
6
+ * @example
7
+ * // Basic usage
8
+ * element.className = api.styles.block;
9
+ *
10
+ * @example
11
+ * // Extending with custom styles using tailwind-merge
12
+ * import { twMerge } from 'tailwind-merge';
13
+ * const customBlock = twMerge(api.styles.block, 'my-4 bg-gray-100');
14
+ *
15
+ * @since 2.0.0 - Changed from BEM class names to Tailwind utility strings
3
16
  */
4
17
  export interface Styles {
5
18
  /**
6
- * Main Editor`s block styles
19
+ * Base block styles - applied to block tool wrappers.
20
+ * Provides vertical padding for consistent block spacing.
21
+ * Includes placeholder styling via pseudo-element.
22
+ *
23
+ * @example 'py-[theme(spacing.block-padding-vertical)] px-0 [&::-webkit-input-placeholder]:!leading-normal'
7
24
  */
8
25
  block: string;
9
26
 
10
27
  /**
11
- * Styles for Inline Toolbar button
28
+ * Styles for Inline Toolbar button.
29
+ * Provides flexbox centering, transparent background, and proper sizing.
30
+ *
31
+ * @example 'flex justify-center items-center border-0 rounded h-full p-0 w-7 bg-transparent cursor-pointer'
12
32
  */
13
33
  inlineToolButton: string;
14
34
 
15
35
  /**
16
- * Styles for active Inline Toolbar button
36
+ * Styles for active Inline Toolbar button.
37
+ * Apply alongside inlineToolButton when the tool is active.
38
+ *
39
+ * @example 'bg-icon-active-bg text-icon-active-text'
17
40
  */
18
41
  inlineToolButtonActive: string;
19
42
 
20
43
  /**
21
- * Styles for inputs
44
+ * Styles for input elements.
45
+ * Provides full width, border, padding, shadow, and Firefox placeholder workaround.
46
+ *
47
+ * @example 'w-full rounded-[3px] border border-line-gray px-3 py-2.5 outline-none shadow-input'
22
48
  */
23
49
  input: string;
24
50
 
25
51
  /**
26
- * Loader styles
52
+ * Loader styles for loading states.
53
+ * Provides relative positioning, border, and spinning animation.
54
+ *
55
+ * @example 'relative border border-line-gray before:animate-rotation'
27
56
  */
28
57
  loader: string;
29
58
 
30
59
  /**
31
- * Styles for Settings box buttons
60
+ * Styles for Settings box buttons.
61
+ * Provides flexbox centering, transparent background, minimum sizing,
62
+ * mobile responsive sizing, and hover states.
63
+ *
64
+ * @example 'inline-flex items-center justify-center rounded-[3px] cursor-pointer'
32
65
  */
33
66
  settingsButton: string;
34
67
 
35
68
  /**
36
- * Styles for active Settings box buttons
69
+ * Styles for active Settings box buttons.
70
+ * Apply alongside settingsButton when the button is active.
71
+ *
72
+ * @example 'text-active-icon'
37
73
  */
38
74
  settingsButtonActive: string;
39
75
 
40
76
  /**
41
- * Styles for buttons
77
+ * Styles for focused Settings box buttons.
78
+ * Apply alongside settingsButton when the button has focus.
79
+ *
80
+ * @example 'shadow-button-focused bg-item-focus-bg'
81
+ */
82
+ settingsButtonFocused: string;
83
+
84
+ /**
85
+ * Styles for focused Settings box buttons with animation.
86
+ * Apply alongside settingsButton and settingsButtonFocused for click animation.
87
+ *
88
+ * @example 'animate-button-clicked'
89
+ */
90
+ settingsButtonFocusedAnimated: string;
91
+
92
+ /**
93
+ * Styles for general buttons.
94
+ * Provides padding, border, background, shadow, hover states, and SVG styling.
95
+ *
96
+ * @example 'p-[13px] rounded-[3px] border border-line-gray text-[14.9px] bg-white'
42
97
  */
43
98
  button: string;
44
99
  }
@@ -1,7 +1,7 @@
1
1
  import { BlockToolAdapter } from '../tools/adapters/block-tool-adapter';
2
2
 
3
3
  /**
4
- * Describes methods for accessing installed Editor tools
4
+ * Describes methods for accessing installed Blok tools
5
5
  */
6
6
  export interface Tools {
7
7
  /**
package/types/api/ui.d.ts CHANGED
@@ -1,19 +1,19 @@
1
1
  /**
2
- * Describes API module allowing to access some Editor UI elements and methods
2
+ * Describes API module allowing to access some Blok UI elements and methods
3
3
  */
4
4
  export interface Ui {
5
5
  /**
6
- * Allows accessing some Editor UI elements
6
+ * Allows accessing some Blok UI elements
7
7
  */
8
8
  nodes: UiNodes,
9
9
  }
10
10
 
11
11
  /**
12
- * Allows accessing some Editor UI elements
12
+ * Allows accessing some Blok UI elements
13
13
  */
14
14
  export interface UiNodes {
15
15
  /**
16
- * Top-level editor instance wrapper
16
+ * Top-level blok instance wrapper
17
17
  */
18
18
  wrapper: HTMLElement,
19
19
 
@@ -8,7 +8,7 @@ import { BaseToolConstructable, MenuConfig } from '../tools';
8
8
  export interface BlockTune {
9
9
  /**
10
10
  * Returns BlockTune's UI.
11
- * Should return either MenuConfig (recommended) (@see https://editorjs.io/menu-config/)
11
+ * Should return either MenuConfig (recommended)
12
12
  * or an HTMLElement (UI consistency is not guaranteed)
13
13
  */
14
14
  render(): HTMLElement | MenuConfig;
@@ -4,14 +4,14 @@ import {SanitizerConfig} from './sanitizer-config';
4
4
  import {I18nConfig} from './i18n-config';
5
5
  import { BlockMutationEvent } from '../events/block';
6
6
 
7
- export interface EditorConfig {
7
+ export interface BlokConfig {
8
8
  /**
9
- * Element where Editor will be appended
9
+ * Element where Blok will be appended
10
10
  */
11
11
  holder?: string | HTMLElement;
12
12
 
13
13
  /**
14
- * If true, set caret at the first Block after Editor is ready
14
+ * If true, set caret at the first Block after Blok is ready
15
15
  */
16
16
  autofocus?: boolean;
17
17
 
@@ -48,17 +48,17 @@ export interface EditorConfig {
48
48
  }
49
49
 
50
50
  /**
51
- * Data to render on Editor start
51
+ * Data to render on Blok start
52
52
  */
53
53
  data?: OutputData;
54
54
 
55
55
  /**
56
- * Height of Editor's bottom area that allows to set focus on the last Block
56
+ * Height of Blok's bottom area that allows to set focus on the last Block
57
57
  */
58
58
  minHeight?: number;
59
59
 
60
60
  /**
61
- * Editors log level (how many logs you want to see)
61
+ * Blok's log level (how many logs you want to see)
62
62
  */
63
63
  logLevel?: LogLevels;
64
64
 
@@ -73,13 +73,13 @@ export interface EditorConfig {
73
73
  i18n?: I18nConfig;
74
74
 
75
75
  /**
76
- * Fires when Editor is ready to work
76
+ * Fires when Blok is ready to work
77
77
  */
78
78
  onReady?(): void;
79
79
 
80
80
  /**
81
81
  * Fires when something changed in DOM
82
- * @param api - editor.js api
82
+ * @param api - blok.js api
83
83
  * @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.
84
84
  */
85
85
  onChange?(api: API, event: BlockMutationEvent | BlockMutationEvent[]): void;
@@ -16,7 +16,7 @@ export interface I18nDictionary {
16
16
 
17
17
  /**
18
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
19
+ * The first-level keys of this object should be equal of keys ot the 'tools' property of BlokConfig
20
20
  * Includes internal tools: "paragraph", "stub"
21
21
  *
22
22
  * Example:
@@ -34,7 +34,7 @@ export interface I18nDictionary {
34
34
 
35
35
  /**
36
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
37
+ * The first-level keys of this object should be equal of 'name' ot the 'tools.<toolName>.tunes' property of BlokConfig
38
38
  * Including some internal block-tunes: "delete", "moveUp", "moveDown
39
39
  *
40
40
  * Example:
@@ -53,7 +53,7 @@ export interface I18nDictionary {
53
53
  blockTunes?: Dictionary;
54
54
 
55
55
  /**
56
- * Translation of internal UI components of the editor.js core
56
+ * Translation of internal UI components of the blok.js core
57
57
  */
58
58
  ui?: Dictionary;
59
59
  }
@@ -1,4 +1,4 @@
1
- export * from './editor-config';
1
+ export * from './blok-config';
2
2
  export * from './sanitizer-config';
3
3
  export * from './paste-config';
4
4
  export * from './conversion-config';
@@ -0,0 +1,98 @@
1
+ /**
2
+ * Base options interface for notifications
3
+ */
4
+ export interface NotifierOptions {
5
+ /**
6
+ * Notification message (can contains HTML)
7
+ */
8
+ message: string;
9
+
10
+ /**
11
+ * Type of notification:
12
+ * - 'alert' (default)
13
+ * - 'confirm'
14
+ * - 'prompt'
15
+ */
16
+ type?: string;
17
+
18
+ /**
19
+ * Add class `blok-notify--${style}` to popup
20
+ * We have some default styles: 'success' and 'error'
21
+ */
22
+ style?: string;
23
+
24
+ /**
25
+ * Notification expire time in ms (8s by default)
26
+ * Only 'alert' notifies expires
27
+ */
28
+ time?: number;
29
+ }
30
+
31
+ /**
32
+ * Confirm notification options
33
+ */
34
+ export interface ConfirmNotifierOptions extends NotifierOptions {
35
+ /**
36
+ * Text for confirmation button
37
+ * 'Confirm' by default
38
+ */
39
+ okText?: string;
40
+
41
+ /**
42
+ * Confirm button pressing callback
43
+ * @param {Event} event
44
+ */
45
+ okHandler?: (event: Event) => void;
46
+
47
+ /**
48
+ * Text for cancel button
49
+ * 'Cancel' by default
50
+ */
51
+ cancelText?: string;
52
+
53
+ /**
54
+ * Cancel button or cross button pressing callback
55
+ * @param {Event} event
56
+ */
57
+ cancelHandler?: (event: Event) => void;
58
+ }
59
+
60
+ /**
61
+ * Prompt notification options
62
+ */
63
+ export interface PromptNotifierOptions extends NotifierOptions {
64
+ /**
65
+ * Text for the Submit button
66
+ * 'Ok' by default
67
+ */
68
+ okText?: string;
69
+
70
+ /**
71
+ * Submit button pressing callback
72
+ * Gets input's value as a parameter
73
+ * @param {string} value
74
+ */
75
+ okHandler: (value: string) => void;
76
+
77
+ /**
78
+ * Cross button pressing callback
79
+ * @param {Event} event
80
+ */
81
+ cancelHandler?: (event: Event) => void;
82
+
83
+ /**
84
+ * Type of input
85
+ * 'text' by default
86
+ */
87
+ inputType?: string;
88
+
89
+ /**
90
+ * Input placeholder
91
+ */
92
+ placeholder?: string;
93
+
94
+ /**
95
+ * Input default value
96
+ */
97
+ default?: string;
98
+ }
@@ -30,7 +30,7 @@ export interface OutputBlockData<Type extends string = string, Data extends obje
30
30
 
31
31
  export interface OutputData {
32
32
  /**
33
- * Editor's version
33
+ * Blok's version
34
34
  */
35
35
  version?: string;
36
36
 
@@ -16,6 +16,6 @@ interface BlockAddedEventDetail extends BlockMutationEventDetail {
16
16
  }
17
17
 
18
18
  /**
19
- * Event will be fired when the new block is added to the editor
19
+ * Event will be fired when the new block is added to the blok
20
20
  */
21
21
  export type BlockAddedEvent = CustomEvent<BlockAddedEventDetail>;
package/types/index.d.ts CHANGED
@@ -7,7 +7,7 @@
7
7
  import {
8
8
  Dictionary,
9
9
  DictValue,
10
- EditorConfig,
10
+ BlokConfig,
11
11
  I18nConfig,
12
12
  I18nDictionary,
13
13
  } from './configs';
@@ -68,7 +68,7 @@ export {
68
68
  } from './tools';
69
69
  export {BlockTune, BlockTuneConstructable} from './block-tunes';
70
70
  export {
71
- EditorConfig,
71
+ BlokConfig,
72
72
  SanitizerConfig,
73
73
  SanitizerRule,
74
74
  PasteConfig,
@@ -123,9 +123,9 @@ export interface API {
123
123
  }
124
124
 
125
125
  /**
126
- * Main Editor class
126
+ * Main Blok class
127
127
  */
128
- declare class EditorJS {
128
+ declare class Blok {
129
129
  public static version: string;
130
130
 
131
131
  public isReady: Promise<void>;
@@ -140,7 +140,7 @@ declare class EditorJS {
140
140
  public inlineToolbar: InlineToolbar;
141
141
  public tooltip: Tooltip;
142
142
  public readOnly: ReadOnly;
143
- constructor(configuration?: EditorConfig|string);
143
+ constructor(configuration?: BlokConfig|string);
144
144
 
145
145
  /**
146
146
  * API shorthands
@@ -182,10 +182,10 @@ declare class EditorJS {
182
182
  public emit(eventName: string, data: any): void;
183
183
 
184
184
  /**
185
- * Destroy Editor instance and related DOM elements
185
+ * Destroy Blok instance and related DOM elements
186
186
  */
187
187
  public destroy(): void;
188
188
  }
189
189
 
190
- export as namespace EditorJS;
191
- export default EditorJS;
190
+ export as namespace Blok;
191
+ export default Blok;
@@ -13,12 +13,12 @@ export interface BaseToolAdapter<Type extends ToolType, ToolClass extends Tool>
13
13
  type: Type;
14
14
 
15
15
  /**
16
- * Tool name specified in EditorJS config
16
+ * Tool name specified in Blok config
17
17
  */
18
18
  name: string;
19
19
 
20
20
  /**
21
- * Flag show is current Tool internal (bundled with EditorJS core) or not
21
+ * Flag show is current Tool internal (bundled with Blok core) or not
22
22
  */
23
23
  readonly isInternal: boolean;
24
24
 
@@ -26,7 +26,7 @@ interface BlockToolAdapter extends BaseToolAdapter<ToolType.Block, BlockTool>{
26
26
  * Creates new Tool instance
27
27
  * @param data - Tool data
28
28
  * @param block - BlockAPI for current Block
29
- * @param readOnly - True if Editor is in read-only mode
29
+ * @param readOnly - True if Blok is in read-only mode
30
30
  */
31
31
  create(data: BlockToolData, block: BlockAPI, readOnly: boolean): BlockTool;
32
32
 
@@ -51,7 +51,7 @@ export interface BlockTool extends BaseTool {
51
51
 
52
52
  /**
53
53
  * Cleanup resources used by your tool here
54
- * Called when the editor is destroyed
54
+ * Called when the blok is destroyed
55
55
  */
56
56
  destroy?(): void;
57
57
 
@@ -28,7 +28,7 @@ export interface ToolboxConfigEntry {
28
28
  }
29
29
 
30
30
  /**
31
- * Object passed to the Tool's constructor by {@link EditorConfig#tools}
31
+ * Object passed to the Tool's constructor by {@link BlokConfig#tools}
32
32
  *
33
33
  * @template Config - the structure describing a config object supported by the tool
34
34
  */
@@ -11,7 +11,6 @@ export interface BaseTool<RenderReturnType = HTMLElement> {
11
11
  * Tool`s render method
12
12
  *
13
13
  * For Inline Tools returns {@link MenuConfig}
14
- * @see https://editorjs.io/menu-config
15
14
  *
16
15
  * For Block Tools returns tool`s wrapper html element
17
16
  */
@@ -20,7 +19,7 @@ export interface BaseTool<RenderReturnType = HTMLElement> {
20
19
 
21
20
  export interface BaseToolConstructorOptions<C extends object = any> {
22
21
  /**
23
- * Editor.js API
22
+ * Blok API
24
23
  */
25
24
  api: API;
26
25
 
@@ -39,6 +39,12 @@ export interface PopoverItemChildren {
39
39
  * Called once children popover is closed
40
40
  */
41
41
  onClose?: () => void;
42
+
43
+ /**
44
+ * True if the chevron icon should be hidden for this item.
45
+ * Useful for items like link tool that render custom content instead of a dropdown list.
46
+ */
47
+ hideChevron?: boolean;
42
48
  }
43
49
 
44
50
  /**
@@ -226,12 +232,29 @@ type PopoverItemHintRenderParams = {
226
232
  };
227
233
 
228
234
 
235
+ /**
236
+ * Common popover item render params shared across item types
237
+ */
238
+ interface PopoverItemCommonRenderParams {
239
+ /**
240
+ * If true, item is rendered inside an inline popover.
241
+ * Applies different styling for inline context.
242
+ */
243
+ isInline?: boolean;
244
+
245
+ /**
246
+ * If true, item is rendered inside a nested popover within an inline popover.
247
+ * Applies nested popover styling.
248
+ */
249
+ isNestedInline?: boolean;
250
+ }
251
+
229
252
  /**
230
253
  * Popover item render params.
231
254
  * The parameters that are not set by user via popover api but rather depend on technical implementation
232
255
  */
233
256
  export type PopoverItemRenderParamsMap = {
234
- [PopoverItemType.Default]?: {
257
+ [PopoverItemType.Default]?: PopoverItemCommonRenderParams & {
235
258
  /**
236
259
  * Wrapper tag for the item.
237
260
  * Div by default
@@ -241,13 +264,21 @@ export type PopoverItemRenderParamsMap = {
241
264
  /**
242
265
  * Hint render params
243
266
  */
244
- hint?: PopoverItemHintRenderParams
267
+ hint?: PopoverItemHintRenderParams;
268
+
269
+ /**
270
+ * If true, adds a gap/margin after the icon.
271
+ * True by default. Set to false for inline tools where icons are displayed without titles.
272
+ */
273
+ iconWithGap?: boolean;
245
274
  };
246
275
 
247
- [PopoverItemType.Html]?: {
276
+ [PopoverItemType.Html]?: PopoverItemCommonRenderParams & {
248
277
  /**
249
278
  * Hint render params
250
279
  */
251
280
  hint?: PopoverItemHintRenderParams
252
281
  };
282
+
283
+ [PopoverItemType.Separator]?: PopoverItemCommonRenderParams;
253
284
  };