diff --git a/.eslintrc b/.eslintrc index 1548af3a4..4504754c2 100644 --- a/.eslintrc +++ b/.eslintrc @@ -36,6 +36,23 @@ "navigator": true }, "rules": { - "jsdoc/require-returns-type": "off" - } + "jsdoc/require-returns-type": "off", + "@typescript-eslint/strict-boolean-expressions": "warn", + "@typescript-eslint/consistent-type-imports": "error", + "@typescript-eslint/consistent-type-exports": "error" + }, + "overrides": [ + { + "files": [ + "tsconfig.json", + "package.json", + "tsconfig.*.json", + "tslint.json" + ], + "rules": { + "quotes": [1, "double"], + "semi": [1, "never"], + } + } + ] } diff --git a/cypress.config.ts b/cypress.config.ts index f0e4573a2..58f69cfe7 100644 --- a/cypress.config.ts +++ b/cypress.config.ts @@ -1,4 +1,6 @@ import { defineConfig } from 'cypress'; +import path from 'node:path'; +import vitePreprocessor from 'cypress-vite'; export default defineConfig({ env: { @@ -12,7 +14,9 @@ export default defineConfig({ // We've imported your old cypress plugins here. // You may want to clean this up later by importing these. setupNodeEvents(on, config) { - on('file:preprocessor', require('cypress-vite')(config)); + on('file:preprocessor', vitePreprocessor({ + configFile: path.resolve(__dirname, './vite.config.test.js'), + })); /** * Plugin for cypress that adds better terminal output for easier debugging. @@ -21,7 +25,7 @@ export default defineConfig({ */ require('cypress-terminal-report/src/installLogsPrinter')(on); - require('./test/cypress/plugins/index.ts')(on, config); + require('@cypress/code-coverage/task')(on, config); }, specPattern: 'test/cypress/tests/**/*.cy.{js,jsx,ts,tsx}', supportFile: 'test/cypress/support/index.ts', diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 09401cceb..6c6bf200b 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +### 2.30.4 + +- `Fix` - Tool's exporting types added + ### 2.30.3 - `Fix` – I18n in nested popover diff --git a/example/tools/nested-list b/example/tools/nested-list index 95b37462d..591bd2ca6 160000 --- a/example/tools/nested-list +++ b/example/tools/nested-list @@ -1 +1 @@ -Subproject commit 95b37462dc93c19b83f0481f509034a40d436cf2 +Subproject commit 591bd2ca6839f923e3d37a1ebaad6e5d15075a89 diff --git a/example/tools/text-variant-tune b/example/tools/text-variant-tune index a80eefb40..7f51a16d4 160000 --- a/example/tools/text-variant-tune +++ b/example/tools/text-variant-tune @@ -1 +1 @@ -Subproject commit a80eefb4007c85a52085897398dd28afc5bfd81f +Subproject commit 7f51a16d4ab46eff9364f09cea52e09518896d2a diff --git a/package.json b/package.json index c5c1bd3d3..b93c73292 100644 --- a/package.json +++ b/package.json @@ -40,12 +40,12 @@ }, "devDependencies": { "@babel/register": "^7.21.0", - "@codexteam/icons": "^0.3.0", + "@codexteam/icons": "0.3.2", "@codexteam/shortcuts": "^1.1.1", "@cypress/code-coverage": "^3.10.3", "@editorjs/code": "^2.7.0", "@editorjs/delimiter": "^1.2.0", - "@editorjs/header": "^2.7.0", + "@editorjs/header": "^2.8.7", "@editorjs/paragraph": "^2.11.6", "@editorjs/simple-image": "^1.4.1", "@types/node": "^18.15.11", diff --git a/src/codex.ts b/src/codex.ts index df3f56d61..27d50acdb 100644 --- a/src/codex.ts +++ b/src/codex.ts @@ -1,6 +1,6 @@ 'use strict'; -import { EditorConfig } from '../types'; +import type { EditorConfig } from '../types'; /** * Apply polyfills diff --git a/src/components/__module.ts b/src/components/__module.ts index 4ad521adf..a591c25c2 100644 --- a/src/components/__module.ts +++ b/src/components/__module.ts @@ -1,9 +1,9 @@ -import { EditorModules } from '../types-internal/editor-modules'; -import { EditorConfig } from '../../types'; -import { ModuleConfig } from '../types-internal/module-config'; +import type { EditorModules } from '../types-internal/editor-modules'; +import type { EditorConfig } from '../../types'; +import type { ModuleConfig } from '../types-internal/module-config'; import Listeners from './utils/listeners'; -import EventsDispatcher from './utils/events'; -import { EditorEventMap } from './events'; +import type EventsDispatcher from './utils/events'; +import type { EditorEventMap } from './events'; /** * The type of the Module generic. diff --git a/src/components/block-tunes/block-tune-delete.ts b/src/components/block-tunes/block-tune-delete.ts index 4f1258109..390ea76e1 100644 --- a/src/components/block-tunes/block-tune-delete.ts +++ b/src/components/block-tunes/block-tune-delete.ts @@ -3,9 +3,9 @@ * @classdesc Editor's default tune that moves up selected block * @copyright 2018 */ -import { API, BlockTune } from '../../../types'; +import type { API, BlockTune } from '../../../types'; import { IconCross } from '@codexteam/icons'; -import { MenuConfig } from '../../../types/tools/menu-config'; +import type { MenuConfig } from '../../../types/tools/menu-config'; /** * diff --git a/src/components/block-tunes/block-tune-move-down.ts b/src/components/block-tunes/block-tune-move-down.ts index 5809c0a07..0e7986a0d 100644 --- a/src/components/block-tunes/block-tune-move-down.ts +++ b/src/components/block-tunes/block-tune-move-down.ts @@ -4,9 +4,9 @@ * @copyright 2018 */ -import { API, BlockTune } from '../../../types'; +import type { API, BlockTune } from '../../../types'; import { IconChevronDown } from '@codexteam/icons'; -import { TunesMenuConfig } from '../../../types/tools'; +import type { TunesMenuConfig } from '../../../types/tools'; /** diff --git a/src/components/block-tunes/block-tune-move-up.ts b/src/components/block-tunes/block-tune-move-up.ts index 36f645f48..e87d31269 100644 --- a/src/components/block-tunes/block-tune-move-up.ts +++ b/src/components/block-tunes/block-tune-move-up.ts @@ -3,9 +3,9 @@ * @classdesc Editor's default tune that moves up selected block * @copyright 2018 */ -import { API, BlockTune } from '../../../types'; +import type { API, BlockTune } from '../../../types'; import { IconChevronUp } from '@codexteam/icons'; -import { TunesMenuConfig } from '../../../types/tools'; +import type { TunesMenuConfig } from '../../../types/tools'; /** * diff --git a/src/components/block/api.ts b/src/components/block/api.ts index 64a12b00d..4bd26adc5 100644 --- a/src/components/block/api.ts +++ b/src/components/block/api.ts @@ -1,7 +1,7 @@ -import Block from './index'; -import { BlockToolData, ToolConfig, ToolboxConfigEntry } from '../../../types/tools'; -import { SavedData } from '../../../types/data-formats'; -import { BlockAPI as BlockAPIInterface } from '../../../types/api'; +import type Block from './index'; +import type { BlockToolData, ToolConfig, ToolboxConfigEntry } from '../../../types/tools'; +import type { SavedData } from '../../../types/data-formats'; +import type { BlockAPI as BlockAPIInterface } from '../../../types/api'; /** * Constructs new BlockAPI object diff --git a/src/components/block/index.ts b/src/components/block/index.ts index 33c54b7b1..36c4aa2ae 100644 --- a/src/components/block/index.ts +++ b/src/components/block/index.ts @@ -1,4 +1,4 @@ -import { +import type { BlockAPI as BlockAPIInterface, BlockTool as IBlockTool, BlockToolData, @@ -9,24 +9,25 @@ import { PopoverItemParams } from '../../../types'; -import { SavedData } from '../../../types/data-formats'; +import type { SavedData } from '../../../types/data-formats'; import $, { toggleEmptyMark } from '../dom'; import * as _ from '../utils'; -import ApiModules from '../modules/api'; +import type ApiModules from '../modules/api'; import BlockAPI from './api'; import SelectionUtils from '../selection'; -import BlockTool from '../tools/block'; +import type BlockToolAdapter from '../tools/block'; -import BlockTune from '../tools/tune'; -import { BlockTuneData } from '../../../types/block-tunes/block-tune-data'; -import ToolsCollection from '../tools/collection'; +import type BlockTuneAdapter from '../tools/tune'; +import type { BlockTuneData } from '../../../types/block-tunes/block-tune-data'; +import type ToolsCollection from '../tools/collection'; import EventsDispatcher from '../utils/events'; -import { TunesMenuConfigItem } from '../../../types/tools'; +import type { TunesMenuConfigItem } from '../../../types/tools'; import { isMutationBelongsToElement } from '../utils/mutations'; -import { EditorEventMap, FakeCursorAboutToBeToggled, FakeCursorHaveBeenSet, RedactorDomChanged } from '../events'; -import { RedactorDomChangedPayload } from '../events/RedactorDomChanged'; +import type { EditorEventMap } from '../events'; +import { FakeCursorAboutToBeToggled, FakeCursorHaveBeenSet, RedactorDomChanged } from '../events'; +import type { RedactorDomChangedPayload } from '../events/RedactorDomChanged'; import { convertBlockDataToString, isSameBlockData } from '../utils/blocks'; -import { PopoverItemType } from '../utils/popover'; +import { PopoverItemType } from '@/types/utils/popover/popover-item-type'; /** * Interface describes Block class constructor argument @@ -45,7 +46,7 @@ interface BlockConstructorOptions { /** * Tool object */ - tool: BlockTool; + tool: BlockToolAdapter; /** * Editor's API methods @@ -130,7 +131,7 @@ export default class Block extends EventsDispatcher { /** * Instance of the Tool Block represents */ - public readonly tool: BlockTool; + public readonly tool: BlockToolAdapter; /** * User Tool configuration @@ -145,7 +146,7 @@ export default class Block extends EventsDispatcher { /** * Tunes used by Tool */ - public readonly tunes: ToolsCollection; + public readonly tunes: ToolsCollection; /** * Tool's user configuration @@ -233,7 +234,7 @@ export default class Block extends EventsDispatcher { this.toolInstance = tool.create(data, this.blockAPI, readOnly); /** - * @type {BlockTune[]} + * @type {BlockTuneAdapter[]} */ this.tunes = tool.tunes; diff --git a/src/components/blocks.ts b/src/components/blocks.ts index c0a4d9332..30334ae20 100644 --- a/src/components/blocks.ts +++ b/src/components/blocks.ts @@ -1,7 +1,8 @@ import * as _ from './utils'; import $ from './dom'; -import Block, { BlockToolAPI } from './block'; -import { MoveEvent } from '../../types/tools'; +import type Block from './block'; +import { BlockToolAPI } from './block'; +import type { MoveEvent } from '../../types/tools'; /** * @class Blocks diff --git a/src/components/core.ts b/src/components/core.ts index 65bea1c95..87f8beac7 100644 --- a/src/components/core.ts +++ b/src/components/core.ts @@ -1,12 +1,12 @@ import $ from './dom'; import * as _ from './utils'; -import { EditorConfig, SanitizerConfig } from '../../types'; -import { EditorModules } from '../types-internal/editor-modules'; +import type { EditorConfig, SanitizerConfig } from '../../types'; +import type { EditorModules } from '../types-internal/editor-modules'; import I18n from './i18n'; import { CriticalError } from './errors/critical'; import EventsDispatcher from './utils/events'; import Modules from './modules'; -import { EditorEventMap } from './events'; +import type { EditorEventMap } from './events'; /** * Editor.js core class. Bootstraps modules. diff --git a/src/components/events/BlockChanged.ts b/src/components/events/BlockChanged.ts index dfd83823a..3b8ff2e1b 100644 --- a/src/components/events/BlockChanged.ts +++ b/src/components/events/BlockChanged.ts @@ -1,4 +1,4 @@ -import { BlockMutationEvent } from '../../../types/events/block'; +import type { BlockMutationEvent } from '../../../types/events/block'; /** * Fired when some block state has changed diff --git a/src/components/events/index.ts b/src/components/events/index.ts index 15aac17da..10f82cdc1 100644 --- a/src/components/events/index.ts +++ b/src/components/events/index.ts @@ -1,9 +1,14 @@ -import { RedactorDomChanged, RedactorDomChangedPayload } from './RedactorDomChanged'; -import { BlockChanged, BlockChangedPayload } from './BlockChanged'; -import { BlockHovered, BlockHoveredPayload } from './BlockHovered'; -import { FakeCursorAboutToBeToggled, FakeCursorAboutToBeToggledPayload } from './FakeCursorAboutToBeToggled'; -import { FakeCursorHaveBeenSet, FakeCursorHaveBeenSetPayload } from './FakeCursorHaveBeenSet'; -import { EditorMobileLayoutToggled, EditorMobileLayoutToggledPayload } from './EditorMobileLayoutToggled'; +import type { RedactorDomChangedPayload } from './RedactorDomChanged'; +import { RedactorDomChanged } from './RedactorDomChanged'; +import type { BlockChangedPayload } from './BlockChanged'; +import { BlockChanged } from './BlockChanged'; +import type { BlockHovered, BlockHoveredPayload } from './BlockHovered'; +import type { FakeCursorAboutToBeToggledPayload } from './FakeCursorAboutToBeToggled'; +import { FakeCursorAboutToBeToggled } from './FakeCursorAboutToBeToggled'; +import type { FakeCursorHaveBeenSetPayload } from './FakeCursorHaveBeenSet'; +import { FakeCursorHaveBeenSet } from './FakeCursorHaveBeenSet'; +import type { EditorMobileLayoutToggledPayload } from './EditorMobileLayoutToggled'; +import { EditorMobileLayoutToggled } from './EditorMobileLayoutToggled'; /** * Events fired by Editor Event Dispatcher diff --git a/src/components/i18n/index.ts b/src/components/i18n/index.ts index b522a365a..feccdbb6f 100644 --- a/src/components/i18n/index.ts +++ b/src/components/i18n/index.ts @@ -1,6 +1,6 @@ import defaultDictionary from './locales/en/messages.json'; -import { I18nDictionary, Dictionary } from '../../../types/configs'; -import { LeavesDictKeys } from '../../types-internal/i18n-internal-namespace'; +import type { I18nDictionary, Dictionary } from '../../../types/configs'; +import type { LeavesDictKeys } from '../../types-internal/i18n-internal-namespace'; /** * Type for all available internal dictionary strings diff --git a/src/components/i18n/namespace-internal.ts b/src/components/i18n/namespace-internal.ts index 0a7b10a32..ed9520a59 100644 --- a/src/components/i18n/namespace-internal.ts +++ b/src/components/i18n/namespace-internal.ts @@ -1,5 +1,5 @@ import defaultDictionary from './locales/en/messages.json'; -import { DictNamespaces } from '../../types-internal/i18n-internal-namespace'; +import type { DictNamespaces } from '../../types-internal/i18n-internal-namespace'; import { isObject, isString } from '../utils'; /** diff --git a/src/components/inline-tools/inline-tool-bold.ts b/src/components/inline-tools/inline-tool-bold.ts index 9959011dd..c3a4d9d2b 100644 --- a/src/components/inline-tools/inline-tool-bold.ts +++ b/src/components/inline-tools/inline-tool-bold.ts @@ -1,6 +1,6 @@ -import { InlineTool, SanitizerConfig } from '../../../types'; +import type { InlineTool, SanitizerConfig } from '../../../types'; import { IconBold } from '@codexteam/icons'; -import { MenuConfig } from '../../../types/tools'; +import type { MenuConfig } from '../../../types/tools'; /** * Bold Tool diff --git a/src/components/inline-tools/inline-tool-convert.ts b/src/components/inline-tools/inline-tool-convert.ts index 71d2e5249..b0347a682 100644 --- a/src/components/inline-tools/inline-tool-convert.ts +++ b/src/components/inline-tools/inline-tool-convert.ts @@ -1,8 +1,8 @@ import { IconReplace } from '@codexteam/icons'; -import { InlineTool, API } from '../../../types'; -import { MenuConfig, MenuConfigItem } from '../../../types/tools'; +import type { InlineTool, API } from '../../../types'; +import type { MenuConfig, MenuConfigItem } from '../../../types/tools'; import * as _ from '../utils'; -import { Blocks, Selection, Tools, Caret, I18n } from '../../../types/api'; +import type { Blocks, Selection, Tools, Caret, I18n } from '../../../types/api'; import SelectionUtils from '../selection'; import { getConvertibleToolsForBlock } from '../utils/blocks'; import I18nInternal from '../i18n'; diff --git a/src/components/inline-tools/inline-tool-italic.ts b/src/components/inline-tools/inline-tool-italic.ts index e271bd457..526a56779 100644 --- a/src/components/inline-tools/inline-tool-italic.ts +++ b/src/components/inline-tools/inline-tool-italic.ts @@ -1,4 +1,4 @@ -import { InlineTool, SanitizerConfig } from '../../../types'; +import type { InlineTool, SanitizerConfig } from '../../../types'; import { IconItalic } from '@codexteam/icons'; /** diff --git a/src/components/inline-tools/inline-tool-link.ts b/src/components/inline-tools/inline-tool-link.ts index f66cf79a6..9b413a564 100644 --- a/src/components/inline-tools/inline-tool-link.ts +++ b/src/components/inline-tools/inline-tool-link.ts @@ -1,7 +1,7 @@ import SelectionUtils from '../selection'; import * as _ from '../utils'; -import { InlineTool, SanitizerConfig, API } from '../../../types'; -import { Notifier, Toolbar, I18n, InlineToolbar } from '../../../types/api'; +import type { InlineTool, SanitizerConfig, API } from '../../../types'; +import type { Notifier, Toolbar, I18n, InlineToolbar } from '../../../types/api'; import { IconLink, IconUnlink } from '@codexteam/icons'; /** diff --git a/src/components/modules/api/blocks.ts b/src/components/modules/api/blocks.ts index 6c0c58696..f9297d5d4 100644 --- a/src/components/modules/api/blocks.ts +++ b/src/components/modules/api/blocks.ts @@ -1,11 +1,11 @@ import type { BlockAPI as BlockAPIInterface, Blocks } from '../../../../types/api'; -import { BlockToolData, OutputBlockData, OutputData, ToolConfig } from '../../../../types'; +import type { BlockToolData, OutputBlockData, OutputData, ToolConfig } from '../../../../types'; import * as _ from './../../utils'; import BlockAPI from '../../block/api'; import Module from '../../__module'; import Block from '../../block'; import { capitalize } from '../../utils'; -import { BlockTuneData } from '../../../../types/block-tunes/block-tune-data'; +import type { BlockTuneData } from '../../../../types/block-tunes/block-tune-data'; /** * @class BlocksAPI diff --git a/src/components/modules/api/caret.ts b/src/components/modules/api/caret.ts index e889ea5f3..e5ca5af2e 100644 --- a/src/components/modules/api/caret.ts +++ b/src/components/modules/api/caret.ts @@ -1,4 +1,4 @@ -import { BlockAPI, Caret } from '../../../../types/api'; +import type { BlockAPI, Caret } from '../../../../types/api'; import Module from '../../__module'; import { resolveBlock } from '../../utils/api'; diff --git a/src/components/modules/api/events.ts b/src/components/modules/api/events.ts index 865b913e9..74484a239 100644 --- a/src/components/modules/api/events.ts +++ b/src/components/modules/api/events.ts @@ -1,5 +1,5 @@ import Module from '../../__module'; -import { Events } from '../../../../types/api'; +import type { Events } from '../../../../types/api'; /** * @class EventsAPI diff --git a/src/components/modules/api/i18n.ts b/src/components/modules/api/i18n.ts index 6d42314cc..25e353751 100644 --- a/src/components/modules/api/i18n.ts +++ b/src/components/modules/api/i18n.ts @@ -1,4 +1,4 @@ -import { I18n } from '../../../../types/api'; +import type { I18n } from '../../../../types/api'; import I18nInternal from '../../i18n'; import { logLabeled } from '../../utils'; import Module from '../../__module'; diff --git a/src/components/modules/api/index.ts b/src/components/modules/api/index.ts index e66e605c7..e334244de 100644 --- a/src/components/modules/api/index.ts +++ b/src/components/modules/api/index.ts @@ -6,7 +6,7 @@ * if you cant to read more about how API works, please see docs */ import Module from '../../__module'; -import { API as APIInterfaces } from '../../../../types'; +import type { API as APIInterfaces } from '../../../../types'; /** * @class API diff --git a/src/components/modules/api/inlineToolbar.ts b/src/components/modules/api/inlineToolbar.ts index dca74ca90..2091d9c01 100644 --- a/src/components/modules/api/inlineToolbar.ts +++ b/src/components/modules/api/inlineToolbar.ts @@ -1,4 +1,4 @@ -import { InlineToolbar } from '../../../../types/api/inline-toolbar'; +import type { InlineToolbar } from '../../../../types/api/inline-toolbar'; import Module from '../../__module'; /** diff --git a/src/components/modules/api/listeners.ts b/src/components/modules/api/listeners.ts index ec87e1bc4..b7092899a 100644 --- a/src/components/modules/api/listeners.ts +++ b/src/components/modules/api/listeners.ts @@ -1,4 +1,4 @@ -import { Listeners } from '../../../../types/api'; +import type { Listeners } from '../../../../types/api'; import Module from '../../__module'; /** diff --git a/src/components/modules/api/notifier.ts b/src/components/modules/api/notifier.ts index 85b457d43..3efcc7d85 100644 --- a/src/components/modules/api/notifier.ts +++ b/src/components/modules/api/notifier.ts @@ -1,8 +1,8 @@ -import { Notifier as INotifier } from '../../../../types/api'; +import type { Notifier as INotifier } from '../../../../types/api'; import Notifier from '../../utils/notifier'; -import { ConfirmNotifierOptions, NotifierOptions, PromptNotifierOptions } from 'codex-notifier'; +import type { ConfirmNotifierOptions, NotifierOptions, PromptNotifierOptions } from 'codex-notifier'; import Module from '../../__module'; -import { ModuleConfig } from '../../../types-internal/module-config'; +import type { ModuleConfig } from '../../../types-internal/module-config'; /** * diff --git a/src/components/modules/api/readonly.ts b/src/components/modules/api/readonly.ts index 5c5270527..78e0abb2d 100644 --- a/src/components/modules/api/readonly.ts +++ b/src/components/modules/api/readonly.ts @@ -1,4 +1,4 @@ -import { ReadOnly } from '../../../../types/api'; +import type { ReadOnly } from '../../../../types/api'; import Module from '../../__module'; /** diff --git a/src/components/modules/api/sanitizer.ts b/src/components/modules/api/sanitizer.ts index 1f1a259cc..723329879 100644 --- a/src/components/modules/api/sanitizer.ts +++ b/src/components/modules/api/sanitizer.ts @@ -1,5 +1,5 @@ -import { Sanitizer as ISanitizer } from '../../../../types/api'; -import { SanitizerConfig } from '../../../../types/configs'; +import type { Sanitizer as ISanitizer } from '../../../../types/api'; +import type { SanitizerConfig } from '../../../../types/configs'; import Module from '../../__module'; import { clean } from '../../utils/sanitizer'; diff --git a/src/components/modules/api/saver.ts b/src/components/modules/api/saver.ts index 5db9b88ad..ad0eac29c 100644 --- a/src/components/modules/api/saver.ts +++ b/src/components/modules/api/saver.ts @@ -1,5 +1,5 @@ -import { Saver } from '../../../../types/api'; -import { OutputData } from '../../../../types'; +import type { Saver } from '../../../../types/api'; +import type { OutputData } from '../../../../types'; import * as _ from '../../utils'; import Module from '../../__module'; diff --git a/src/components/modules/api/selection.ts b/src/components/modules/api/selection.ts index ba3087209..53d221fbd 100644 --- a/src/components/modules/api/selection.ts +++ b/src/components/modules/api/selection.ts @@ -1,5 +1,5 @@ import SelectionUtils from '../../selection'; -import { Selection as SelectionAPIInterface } from '../../../../types/api'; +import type { Selection as SelectionAPIInterface } from '../../../../types/api'; import Module from '../../__module'; /** diff --git a/src/components/modules/api/styles.ts b/src/components/modules/api/styles.ts index aced02a55..a75c71213 100644 --- a/src/components/modules/api/styles.ts +++ b/src/components/modules/api/styles.ts @@ -1,4 +1,4 @@ -import { Styles } from '../../../../types/api'; +import type { Styles } from '../../../../types/api'; import Module from '../../__module'; /** diff --git a/src/components/modules/api/toolbar.ts b/src/components/modules/api/toolbar.ts index 321cbf4ce..f94e71304 100644 --- a/src/components/modules/api/toolbar.ts +++ b/src/components/modules/api/toolbar.ts @@ -1,4 +1,4 @@ -import { Toolbar } from '../../../../types/api'; +import type { Toolbar } from '../../../../types/api'; import Module from '../../__module'; import * as _ from './../../utils'; /** diff --git a/src/components/modules/api/tools.ts b/src/components/modules/api/tools.ts index f120fa590..c4ce7cb6d 100644 --- a/src/components/modules/api/tools.ts +++ b/src/components/modules/api/tools.ts @@ -1,4 +1,4 @@ -import { Tools as ToolsAPIInterface } from '../../../../types/api'; +import type { Tools as ToolsAPIInterface } from '../../../../types/api'; import Module from '../../__module'; /** diff --git a/src/components/modules/api/tooltip.ts b/src/components/modules/api/tooltip.ts index 3b2b5ba15..37077d0c3 100644 --- a/src/components/modules/api/tooltip.ts +++ b/src/components/modules/api/tooltip.ts @@ -1,7 +1,7 @@ -import { Tooltip as ITooltip } from '../../../../types/api'; +import type { Tooltip as ITooltip } from '../../../../types/api'; import type { TooltipOptions, TooltipContent } from 'codex-tooltip/types'; import Module from '../../__module'; -import { ModuleConfig } from '../../../types-internal/module-config'; +import type { ModuleConfig } from '../../../types-internal/module-config'; import * as tooltip from '../../utils/tooltip'; /** * @class TooltipAPI diff --git a/src/components/modules/api/ui.ts b/src/components/modules/api/ui.ts index b1e42d18b..3bd867cca 100644 --- a/src/components/modules/api/ui.ts +++ b/src/components/modules/api/ui.ts @@ -1,5 +1,5 @@ import Module from '../../__module'; -import { Ui, UiNodes } from '../../../../types/api'; +import type { Ui, UiNodes } from '../../../../types/api'; /** * API module allowing to access some Editor UI elements diff --git a/src/components/modules/blockManager.ts b/src/components/modules/blockManager.ts index ec555f208..fd06dd71b 100644 --- a/src/components/modules/blockManager.ts +++ b/src/components/modules/blockManager.ts @@ -9,10 +9,10 @@ import Module from '../__module'; import $ from '../dom'; import * as _ from '../utils'; import Blocks from '../blocks'; -import { BlockToolData, PasteEvent } from '../../../types'; -import { BlockTuneData } from '../../../types/block-tunes/block-tune-data'; +import type { BlockToolData, PasteEvent } from '../../../types'; +import type { BlockTuneData } from '../../../types/block-tunes/block-tune-data'; import BlockAPI from '../block/api'; -import { BlockMutationEventMap, BlockMutationType } from '../../../types/events/block'; +import type { BlockMutationEventMap, BlockMutationType } from '../../../types/events/block'; import { BlockRemovedMutationType } from '../../../types/events/block/BlockRemoved'; import { BlockAddedMutationType } from '../../../types/events/block/BlockAdded'; import { BlockMovedMutationType } from '../../../types/events/block/BlockMoved'; diff --git a/src/components/modules/blockSelection.ts b/src/components/modules/blockSelection.ts index f6844bdcc..a6edcb8c8 100644 --- a/src/components/modules/blockSelection.ts +++ b/src/components/modules/blockSelection.ts @@ -5,13 +5,13 @@ * @version 1.0.0 */ import Module from '../__module'; -import Block from '../block'; +import type Block from '../block'; import * as _ from '../utils'; import $ from '../dom'; import Shortcuts from '../utils/shortcuts'; import SelectionUtils from '../selection'; -import { SanitizerConfig } from '../../../types/configs'; +import type { SanitizerConfig } from '../../../types/configs'; import { clean } from '../utils/sanitizer'; /** diff --git a/src/components/modules/caret.ts b/src/components/modules/caret.ts index 5193daa3a..276eef4b0 100644 --- a/src/components/modules/caret.ts +++ b/src/components/modules/caret.ts @@ -1,6 +1,6 @@ import Selection from '../selection'; import Module from '../__module'; -import Block from '../block'; +import type Block from '../block'; import * as caretUtils from '../utils/caret'; import $ from '../dom'; diff --git a/src/components/modules/crossBlockSelection.ts b/src/components/modules/crossBlockSelection.ts index bcebfa4f3..1b18b8e6d 100644 --- a/src/components/modules/crossBlockSelection.ts +++ b/src/components/modules/crossBlockSelection.ts @@ -1,5 +1,5 @@ import Module from '../__module'; -import Block from '../block'; +import type Block from '../block'; import SelectionUtils from '../selection'; import * as _ from '../utils'; diff --git a/src/components/modules/modificationsObserver.ts b/src/components/modules/modificationsObserver.ts index 10e3aa566..6185d7d5f 100644 --- a/src/components/modules/modificationsObserver.ts +++ b/src/components/modules/modificationsObserver.ts @@ -1,6 +1,6 @@ -import { BlockId } from '../../../types'; -import { BlockMutationEvent, BlockMutationType } from '../../../types/events/block'; -import { ModuleConfig } from '../../types-internal/module-config'; +import type { BlockId } from '../../../types'; +import type { BlockMutationEvent, BlockMutationType } from '../../../types/events/block'; +import type { ModuleConfig } from '../../types-internal/module-config'; import Module from '../__module'; import { modificationsObserverBatchTimeout } from '../constants'; import { BlockChanged, FakeCursorAboutToBeToggled, FakeCursorHaveBeenSet, RedactorDomChanged } from '../events'; diff --git a/src/components/modules/paste.ts b/src/components/modules/paste.ts index bdbec4458..6a8378c41 100644 --- a/src/components/modules/paste.ts +++ b/src/components/modules/paste.ts @@ -1,17 +1,17 @@ import Module from '../__module'; import $ from '../dom'; import * as _ from '../utils'; -import { +import type { BlockAPI, PasteEvent, PasteEventDetail, SanitizerConfig, SanitizerRule } from '../../../types'; -import Block from '../block'; -import { SavedData } from '../../../types/data-formats'; +import type Block from '../block'; +import type { SavedData } from '../../../types/data-formats'; import { clean, sanitizeBlocks } from '../utils/sanitizer'; -import BlockTool from '../tools/block'; +import type BlockToolAdapter from '../tools/block'; /** * Tag substitute object. @@ -21,7 +21,7 @@ interface TagSubstitute { * Name of related Tool * */ - tool: BlockTool; + tool: BlockToolAdapter; /** * If a Tool specifies just a tag name, all the attributes will be sanitized. @@ -47,7 +47,7 @@ interface PatternSubstitute { /** * Name of related Tool */ - tool: BlockTool; + tool: BlockToolAdapter; } /** @@ -290,7 +290,7 @@ export default class Paste extends Module { * * @param tool - BlockTool object */ - private processTool = (tool: BlockTool): void => { + private processTool = (tool: BlockToolAdapter): void => { try { const toolInstance = tool.create({}, {} as BlockAPI, false); @@ -345,7 +345,7 @@ export default class Paste extends Module { * * @param tool - BlockTool object */ - private getTagsConfig(tool: BlockTool): void { + private getTagsConfig(tool: BlockToolAdapter): void { if (tool.pasteConfig === false) { return; } @@ -390,7 +390,7 @@ export default class Paste extends Module { * * @param tool - BlockTool object */ - private getFilesConfig(tool: BlockTool): void { + private getFilesConfig(tool: BlockToolAdapter): void { if (tool.pasteConfig === false) { return; } @@ -435,7 +435,7 @@ export default class Paste extends Module { * * @param tool - BlockTool object */ - private getPatternsConfig(tool: BlockTool): void { + private getPatternsConfig(tool: BlockToolAdapter): void { if ( tool.pasteConfig === false || !tool.pasteConfig.patterns || diff --git a/src/components/modules/renderer.ts b/src/components/modules/renderer.ts index 940ff179b..150af7a2c 100644 --- a/src/components/modules/renderer.ts +++ b/src/components/modules/renderer.ts @@ -1,9 +1,9 @@ import Module from '../__module'; import * as _ from '../utils'; import type { BlockId, BlockToolData, OutputBlockData } from '../../../types'; -import type BlockTool from '../tools/block'; +import type BlockToolAdapter from '../tools/block'; import type { StubData } from '../../tools/stub'; -import Block from '../block'; +import type Block from '../block'; /** * Module that responsible for rendering Blocks on editor initialization @@ -92,7 +92,7 @@ export default class Renderer extends Module { let title = tool; if (Tools.unavailable.has(tool)) { - const toolboxSettings = (Tools.unavailable.get(tool) as BlockTool).toolbox; + const toolboxSettings = (Tools.unavailable.get(tool) as BlockToolAdapter).toolbox; if (toolboxSettings !== undefined && toolboxSettings[0].title !== undefined) { title = toolboxSettings[0].title; diff --git a/src/components/modules/saver.ts b/src/components/modules/saver.ts index af8136d3f..c02192835 100644 --- a/src/components/modules/saver.ts +++ b/src/components/modules/saver.ts @@ -6,9 +6,9 @@ * @version 2.0.0 */ import Module from '../__module'; -import { OutputData } from '../../../types'; -import { SavedData, ValidatedData } from '../../../types/data-formats'; -import Block from '../block'; +import type { OutputData } from '../../../types'; +import type { SavedData, ValidatedData } from '../../../types/data-formats'; +import type Block from '../block'; import * as _ from '../utils'; import { sanitizeBlocks } from '../utils/sanitizer'; diff --git a/src/components/modules/toolbar/blockSettings.ts b/src/components/modules/toolbar/blockSettings.ts index ef47da288..88f861b40 100644 --- a/src/components/modules/toolbar/blockSettings.ts +++ b/src/components/modules/toolbar/blockSettings.ts @@ -1,14 +1,15 @@ import Module from '../../__module'; import $ from '../../dom'; import SelectionUtils from '../../selection'; -import Block from '../../block'; +import type Block from '../../block'; import I18n from '../../i18n'; import { I18nInternalNS } from '../../i18n/namespace-internal'; -import Flipper from '../../flipper'; -import { MenuConfigItem } from '../../../../types/tools'; +import type Flipper from '../../flipper'; +import type { MenuConfigItem } from '../../../../types/tools'; import { resolveAliases } from '../../utils/resolve-aliases'; -import { type Popover, PopoverDesktop, PopoverMobile, PopoverItemParams, PopoverItemType } from '../../utils/popover'; -import { PopoverEvent } from '../../utils/popover/popover.types'; +import type { PopoverItemParams } from '../../utils/popover'; +import { type Popover, PopoverDesktop, PopoverMobile, PopoverItemType } from '../../utils/popover'; +import { PopoverEvent } from '@/types/utils/popover/popover-event'; import { isMobileScreen } from '../../utils'; import { EditorMobileLayoutToggled } from '../../events'; import { IconReplace } from '@codexteam/icons'; diff --git a/src/components/modules/toolbar/index.ts b/src/components/modules/toolbar/index.ts index b03a69745..3098c6aba 100644 --- a/src/components/modules/toolbar/index.ts +++ b/src/components/modules/toolbar/index.ts @@ -4,8 +4,8 @@ import * as _ from '../../utils'; import I18n from '../../i18n'; import { I18nInternalNS } from '../../i18n/namespace-internal'; import * as tooltip from '../../utils/tooltip'; -import { ModuleConfig } from '../../../types-internal/module-config'; -import Block from '../../block'; +import type { ModuleConfig } from '../../../types-internal/module-config'; +import type Block from '../../block'; import Toolbox, { ToolboxEvent } from '../../ui/toolbox'; import { IconMenu, IconPlus } from '@codexteam/icons'; import { BlockHovered } from '../../events/BlockHovered'; diff --git a/src/components/modules/toolbar/inline.ts b/src/components/modules/toolbar/inline.ts index 350c75084..4a138c204 100644 --- a/src/components/modules/toolbar/inline.ts +++ b/src/components/modules/toolbar/inline.ts @@ -3,13 +3,14 @@ import Module from '../../__module'; import $ from '../../dom'; import SelectionUtils from '../../selection'; import * as _ from '../../utils'; -import { InlineTool as IInlineTool } from '../../../../types'; +import type { InlineTool as IInlineTool } from '../../../../types'; import I18n from '../../i18n'; import { I18nInternalNS } from '../../i18n/namespace-internal'; import Shortcuts from '../../utils/shortcuts'; -import { ModuleConfig } from '../../../types-internal/module-config'; +import type { ModuleConfig } from '../../../types-internal/module-config'; import { CommonInternalSettings } from '../../tools/base'; -import { Popover, PopoverItemHtmlParams, PopoverItemParams, PopoverItemType, WithChildren } from '../../utils/popover'; +import type { Popover, PopoverItemHtmlParams, PopoverItemParams, WithChildren } from '../../utils/popover'; +import { PopoverItemType } from '../../utils/popover'; import { PopoverInline } from '../../utils/popover/popover-inline'; /** diff --git a/src/components/modules/tools.ts b/src/components/modules/tools.ts index 01fd7ef14..618242697 100644 --- a/src/components/modules/tools.ts +++ b/src/components/modules/tools.ts @@ -1,16 +1,16 @@ import Paragraph from '@editorjs/paragraph'; import Module from '../__module'; import * as _ from '../utils'; -import { SanitizerConfig, ToolConfig, ToolConstructable, ToolSettings } from '../../../types'; +import type { SanitizerConfig, ToolConfig, ToolConstructable, ToolSettings } from '../../../types'; import BoldInlineTool from '../inline-tools/inline-tool-bold'; import ItalicInlineTool from '../inline-tools/inline-tool-italic'; import LinkInlineTool from '../inline-tools/inline-tool-link'; import ConvertInlineTool from '../inline-tools/inline-tool-convert'; import Stub from '../../tools/stub'; import ToolsFactory from '../tools/factory'; -import InlineTool from '../tools/inline'; -import BlockTool from '../tools/block'; -import BlockTune from '../tools/tune'; +import type InlineToolAdapter from '../tools/inline'; +import type BlockToolAdapter from '../tools/block'; +import type BlockTuneAdapter from '../tools/tune'; import MoveDownTune from '../block-tunes/block-tune-move-down'; import DeleteTune from '../block-tunes/block-tune-delete'; import MoveUpTune from '../block-tunes/block-tune-move-up'; @@ -51,14 +51,14 @@ export default class Tools extends Module { /** * Return Tools for the Inline Toolbar */ - public get inlineTools(): ToolsCollection { + public get inlineTools(): ToolsCollection { return this.available.inlineTools; } /** * Return editor block tools */ - public get blockTools(): ToolsCollection { + public get blockTools(): ToolsCollection { return this.available.blockTools; } @@ -67,14 +67,14 @@ export default class Tools extends Module { * * @returns {object} - object of Inline Tool's classes */ - public get blockTunes(): ToolsCollection { + public get blockTunes(): ToolsCollection { return this.available.blockTunes; } /** * Returns default Tool object */ - public get defaultTool(): BlockTool { + public get defaultTool(): BlockToolAdapter { return this.blockTools.get(this.config.defaultBlock); } @@ -303,7 +303,7 @@ export default class Tools extends Module { * * @param tool - Block Tool */ - private assignInlineToolsToBlockTool(tool: BlockTool): void { + private assignInlineToolsToBlockTool(tool: BlockToolAdapter): void { /** * If common inlineToolbar property is false no Inline Tools should be assigned */ @@ -317,7 +317,7 @@ export default class Tools extends Module { * - if common settings is 'true' or not specified, get default order */ if (tool.enabledInlineTools === true) { - tool.inlineTools = new ToolsCollection( + tool.inlineTools = new ToolsCollection( Array.isArray(this.config.inlineToolbar) ? this.config.inlineToolbar.map(name => [name, this.inlineTools.get(name)]) /** @@ -333,7 +333,7 @@ export default class Tools extends Module { * If user pass the list of inline tools for the particular tool, return it. */ if (Array.isArray(tool.enabledInlineTools)) { - tool.inlineTools = new ToolsCollection( + tool.inlineTools = new ToolsCollection( /** Prepend ConvertTo Inline Tool */ ['convertTo', ...tool.enabledInlineTools].map(name => [name, this.inlineTools.get(name)]) ); @@ -345,27 +345,27 @@ export default class Tools extends Module { * * @param tool — Block Tool */ - private assignBlockTunesToBlockTool(tool: BlockTool): void { + private assignBlockTunesToBlockTool(tool: BlockToolAdapter): void { if (tool.enabledBlockTunes === false) { return; } if (Array.isArray(tool.enabledBlockTunes)) { - const userTunes = new ToolsCollection( + const userTunes = new ToolsCollection( tool.enabledBlockTunes.map(name => [name, this.blockTunes.get(name)]) ); - tool.tunes = new ToolsCollection([...userTunes, ...this.blockTunes.internalTools]); + tool.tunes = new ToolsCollection([...userTunes, ...this.blockTunes.internalTools]); return; } if (Array.isArray(this.config.tunes)) { - const userTunes = new ToolsCollection( + const userTunes = new ToolsCollection( this.config.tunes.map(name => [name, this.blockTunes.get(name)]) ); - tool.tunes = new ToolsCollection([...userTunes, ...this.blockTunes.internalTools]); + tool.tunes = new ToolsCollection([...userTunes, ...this.blockTunes.internalTools]); return; } diff --git a/src/components/tools/base.ts b/src/components/tools/base.ts index 22bc83ef6..2e211707b 100644 --- a/src/components/tools/base.ts +++ b/src/components/tools/base.ts @@ -1,28 +1,11 @@ -import { Tool, ToolConstructable, ToolSettings } from '../../../types/tools'; -import type { SanitizerConfig, API as ApiMethods } from '../../../types'; +import type { Tool, ToolConstructable, ToolSettings } from '@/types/tools'; +import type { SanitizerConfig, API as ApiMethods } from '@/types'; import * as _ from '../utils'; -import type InlineTool from './inline'; -import type BlockTool from './block'; -import type BlockTune from './tune'; - -/** - * What kind of plugins developers can create - */ -export enum ToolType { - /** - * Block tool - */ - Block, - /** - * Inline tool - */ - Inline, - - /** - * Block tune - */ - Tune, -} +import { ToolType } from '@/types/tools/adapters/tool-type'; +import type { BaseToolAdapter as BaseToolAdapterInterface } from '@/types/tools/adapters/base-tool-adapter'; +import type { InlineToolAdapter as InlineToolAdapterInterface } from '@/types/tools/adapters/inline-tool-adapter'; +import type { BlockToolAdapter as BlockToolAdapterInterface } from '@/types/tools/adapters/block-tool-adapter'; +import type { BlockTuneAdapter as BlockTuneAdapterInterface } from '@/types/tools/adapters/block-tune-adapter'; /** * Enum of Tool options provided by user @@ -130,11 +113,11 @@ interface ConstructorOptions { /** * Base abstract class for Tools */ -export default abstract class BaseTool { +export default abstract class BaseToolAdapter implements BaseToolAdapterInterface { /** * Tool type: Block, Inline or Tune */ - public type: ToolType; + public type: Type; /** * Tool name specified in EditorJS config @@ -247,21 +230,21 @@ export default abstract class BaseTool { /** * Returns true if Tools is inline */ - public isInline(): this is InlineTool { + public isInline(): this is InlineToolAdapterInterface { return this.type === ToolType.Inline; } /** * Returns true if Tools is block */ - public isBlock(): this is BlockTool { + public isBlock(): this is BlockToolAdapterInterface { return this.type === ToolType.Block; } /** * Returns true if Tools is tune */ - public isTune(): this is BlockTune { + public isTune(): this is BlockTuneAdapterInterface { return this.type === ToolType.Tune; } @@ -271,5 +254,5 @@ export default abstract class BaseTool { * @param args */ // eslint-disable-next-line @typescript-eslint/no-explicit-any - public abstract create(...args: any[]): Type; + public abstract create(...args: any[]): ToolClass; } diff --git a/src/components/tools/block.ts b/src/components/tools/block.ts index a9ee44396..d56cc4321 100644 --- a/src/components/tools/block.ts +++ b/src/components/tools/block.ts @@ -1,5 +1,5 @@ -import BaseTool, { InternalBlockToolSettings, ToolType, UserSettings } from './base'; -import { +import BaseToolAdapter, { InternalBlockToolSettings, UserSettings } from './base'; +import type { BlockAPI, BlockTool as IBlockTool, BlockToolConstructable, @@ -7,30 +7,32 @@ import { ConversionConfig, PasteConfig, SanitizerConfig, ToolboxConfig, ToolboxConfigEntry -} from '../../../types'; +} from '@/types'; import * as _ from '../utils'; -import InlineTool from './inline'; -import BlockTune from './tune'; +import type InlineToolAdapter from './inline'; +import type BlockTuneAdapter from './tune'; import ToolsCollection from './collection'; +import type { BlockToolAdapter as BlockToolAdapterInterface } from '@/types/tools/adapters/block-tool-adapter'; +import { ToolType } from '@/types/tools/adapters/tool-type'; /** * Class to work with Block tools constructables */ -export default class BlockTool extends BaseTool { +export default class BlockToolAdapter extends BaseToolAdapter implements BlockToolAdapterInterface { /** * Tool type — Block */ - public type = ToolType.Block; + public type: ToolType.Block = ToolType.Block; /** * InlineTool collection for current Block Tool */ - public inlineTools: ToolsCollection = new ToolsCollection(); + public inlineTools: ToolsCollection = new ToolsCollection(); /** * BlockTune collection for current Block Tool */ - public tunes: ToolsCollection = new ToolsCollection(); + public tunes: ToolsCollection = new ToolsCollection(); /** * Tool's constructable blueprint diff --git a/src/components/tools/collection.ts b/src/components/tools/collection.ts index 38ebf8c4a..c82d49626 100644 --- a/src/components/tools/collection.ts +++ b/src/components/tools/collection.ts @@ -1,44 +1,46 @@ -import BlockTool from './block'; -import InlineTool from './inline'; -import BlockTune from './tune'; +import type BlockToolAdapter from './block'; +import type InlineToolAdapter from './inline'; +import type BlockTuneAdapter from './tune'; +import type { ToolsCollection as ToolsCollectionInterface } from '@/types/tools/adapters/tools-collection'; -export type ToolClass = BlockTool | InlineTool | BlockTune; + +export type ToolClass = BlockToolAdapter | InlineToolAdapter | BlockTuneAdapter; /** * Class to store Editor Tools */ -export default class ToolsCollection extends Map { +export default class ToolsCollection extends Map implements ToolsCollectionInterface { /** * Returns Block Tools collection */ - public get blockTools(): ToolsCollection { + public get blockTools(): ToolsCollection { const tools = Array .from(this.entries()) - .filter(([, tool]) => tool.isBlock()) as [string, BlockTool][]; + .filter(([, tool]) => tool.isBlock()) as [string, BlockToolAdapter][]; - return new ToolsCollection(tools); + return new ToolsCollection(tools); } /** * Returns Inline Tools collection */ - public get inlineTools(): ToolsCollection { + public get inlineTools(): ToolsCollection { const tools = Array .from(this.entries()) - .filter(([, tool]) => tool.isInline()) as [string, InlineTool][]; + .filter(([, tool]) => tool.isInline()) as [string, InlineToolAdapter][]; - return new ToolsCollection(tools); + return new ToolsCollection(tools); } /** * Returns Block Tunes collection */ - public get blockTunes(): ToolsCollection { + public get blockTunes(): ToolsCollection { const tools = Array .from(this.entries()) - .filter(([, tool]) => tool.isTune()) as [string, BlockTune][]; + .filter(([, tool]) => tool.isTune()) as [string, BlockTuneAdapter][]; - return new ToolsCollection(tools); + return new ToolsCollection(tools); } /** diff --git a/src/components/tools/factory.ts b/src/components/tools/factory.ts index fdf032c09..94d501df7 100644 --- a/src/components/tools/factory.ts +++ b/src/components/tools/factory.ts @@ -1,12 +1,12 @@ -import { ToolConstructable, ToolSettings } from '../../../types/tools'; +import type { ToolConstructable, ToolSettings } from '../../../types/tools'; import { InternalInlineToolSettings, InternalTuneSettings } from './base'; -import InlineTool from './inline'; -import BlockTune from './tune'; -import BlockTool from './block'; -import ApiModule from '../modules/api'; -import { EditorConfig } from '../../../types/configs'; +import InlineToolAdapter from './inline'; +import BlockTuneAdapter from './tune'; +import BlockToolAdapter from './block'; +import type ApiModule from '../modules/api'; +import type { EditorConfig } from '../../../types/configs'; -type ToolConstructor = typeof InlineTool | typeof BlockTool | typeof BlockTune; +type ToolConstructor = typeof InlineToolAdapter | typeof BlockToolAdapter | typeof BlockTuneAdapter; /** * Factory to construct classes to work with tools @@ -48,7 +48,7 @@ export default class ToolsFactory { * * @param name - tool name */ - public get(name: string): InlineTool | BlockTool | BlockTune { + public get(name: string): InlineToolAdapter | BlockToolAdapter | BlockTuneAdapter { const { class: constructable, isInternal = false, ...config } = this.config[name]; const Constructor = this.getConstructor(constructable); @@ -73,11 +73,11 @@ export default class ToolsFactory { private getConstructor(constructable: ToolConstructable): ToolConstructor { switch (true) { case constructable[InternalInlineToolSettings.IsInline]: - return InlineTool; + return InlineToolAdapter; case constructable[InternalTuneSettings.IsTune]: - return BlockTune; + return BlockTuneAdapter; default: - return BlockTool; + return BlockToolAdapter; } } } diff --git a/src/components/tools/inline.ts b/src/components/tools/inline.ts index 64fd27288..a1f419293 100644 --- a/src/components/tools/inline.ts +++ b/src/components/tools/inline.ts @@ -1,14 +1,16 @@ -import BaseTool, { InternalInlineToolSettings, ToolType } from './base'; -import { InlineTool as IInlineTool, InlineToolConstructable } from '../../../types'; +import BaseToolAdapter, { InternalInlineToolSettings } from './base'; +import type { InlineTool as IInlineTool, InlineToolConstructable } from '@/types'; +import type { InlineToolAdapter as InlineToolAdapterInterface } from '@/types/tools/adapters/inline-tool-adapter'; +import { ToolType } from '@/types/tools/adapters/tool-type'; /** * InlineTool object to work with Inline Tools constructables */ -export default class InlineTool extends BaseTool { +export default class InlineToolAdapter extends BaseToolAdapter implements InlineToolAdapterInterface { /** * Tool type — Inline */ - public type = ToolType.Inline; + public type: ToolType.Inline = ToolType.Inline; /** * Tool's constructable blueprint diff --git a/src/components/tools/tune.ts b/src/components/tools/tune.ts index 29dac95b0..c183c2dee 100644 --- a/src/components/tools/tune.ts +++ b/src/components/tools/tune.ts @@ -1,17 +1,19 @@ -import BaseTool, { ToolType } from './base'; -import { BlockAPI, BlockTune as IBlockTune, BlockTuneConstructable } from '../../../types'; -import { BlockTuneData } from '../../../types/block-tunes/block-tune-data'; +import BaseToolAdapter from './base'; +import type { BlockAPI, BlockTune as IBlockTune, BlockTuneConstructable } from '@/types'; +import type { BlockTuneData } from '@/types/block-tunes/block-tune-data'; +import type { BlockTuneAdapter as BlockTuneAdapterInterface } from '@/types/tools/adapters/block-tune-adapter'; +import { ToolType } from '@/types/tools/adapters/tool-type'; /** * Stub class for BlockTunes * * @todo Implement */ -export default class BlockTune extends BaseTool { +export default class BlockTuneAdapter extends BaseToolAdapter implements BlockTuneAdapterInterface { /** * Tool type — Tune */ - public type = ToolType.Tune; + public type: ToolType.Tune = ToolType.Tune; /** * Tool's constructable blueprint diff --git a/src/components/ui/toolbox.ts b/src/components/ui/toolbox.ts index 0e1502b6b..0cbcb85cd 100644 --- a/src/components/ui/toolbox.ts +++ b/src/components/ui/toolbox.ts @@ -1,16 +1,17 @@ import * as _ from '../utils'; import { BlockToolAPI } from '../block'; import Shortcuts from '../utils/shortcuts'; -import BlockTool from '../tools/block'; -import ToolsCollection from '../tools/collection'; -import { API, BlockToolData, ToolboxConfigEntry, PopoverItemParams, BlockAPI } from '../../../types'; +import type BlockToolAdapter from '../tools/block'; +import type ToolsCollection from '../tools/collection'; +import type { API, BlockToolData, ToolboxConfigEntry, PopoverItemParams, BlockAPI } from '@/types'; import EventsDispatcher from '../utils/events'; import I18n from '../i18n'; import { I18nInternalNS } from '../i18n/namespace-internal'; -import { PopoverEvent } from '../utils/popover/popover.types'; +import { PopoverEvent } from '@/types/utils/popover/popover-event'; import Listeners from '../utils/listeners'; import Dom from '../dom'; -import { Popover, PopoverDesktop, PopoverMobile } from '../utils/popover'; +import type { Popover } from '../utils/popover'; +import { PopoverDesktop, PopoverMobile } from '../utils/popover'; import { EditorMobileLayoutToggled } from '../events'; /** @@ -98,7 +99,7 @@ export default class Toolbox extends EventsDispatcher { /** * List of Tools available. Some of them will be shown in the Toolbox */ - private tools: ToolsCollection; + private tools: ToolsCollection; /** * Text labels used in the Toolbox. Should be passed from the i18n module @@ -130,7 +131,7 @@ export default class Toolbox extends EventsDispatcher { * @param options.api - Editor API methods * @param options.tools - Tools available to check whether some of them should be displayed at the Toolbox or not */ - constructor({ api, tools, i18nLabels }: {api: API; tools: ToolsCollection; i18nLabels: Record}) { + constructor({ api, tools, i18nLabels }: {api: API; tools: ToolsCollection; i18nLabels: Record}) { super(); this.api = api; @@ -285,8 +286,8 @@ export default class Toolbox extends EventsDispatcher { * Returns list of tools that enables the Toolbox (by specifying the 'toolbox' getter) */ @_.cacheable - private get toolsToBeDisplayed(): BlockTool[] { - const result: BlockTool[] = []; + private get toolsToBeDisplayed(): BlockToolAdapter[] { + const result: BlockToolAdapter[] = []; this.tools.forEach((tool) => { const toolToolboxSettings = tool.toolbox; @@ -307,7 +308,7 @@ export default class Toolbox extends EventsDispatcher { /** * Maps tool data to popover item structure */ - const toPopoverItem = (toolboxItem: ToolboxConfigEntry, tool: BlockTool): PopoverItemParams => { + const toPopoverItem = (toolboxItem: ToolboxConfigEntry, tool: BlockToolAdapter): PopoverItemParams => { return { icon: toolboxItem.icon, title: I18n.t(I18nInternalNS.toolNames, toolboxItem.title || _.capitalize(tool.name)), @@ -337,7 +338,7 @@ export default class Toolbox extends EventsDispatcher { * Iterate all tools and enable theirs shortcuts if specified */ private enableShortcuts(): void { - this.toolsToBeDisplayed.forEach((tool: BlockTool) => { + this.toolsToBeDisplayed.forEach((tool: BlockToolAdapter) => { const shortcut = tool.shortcut; if (shortcut) { @@ -386,7 +387,7 @@ export default class Toolbox extends EventsDispatcher { * Fired when the Read-Only mode is activated */ private removeAllShortcuts(): void { - this.toolsToBeDisplayed.forEach((tool: BlockTool) => { + this.toolsToBeDisplayed.forEach((tool: BlockToolAdapter) => { const shortcut = tool.shortcut; if (shortcut) { diff --git a/src/components/utils/api.ts b/src/components/utils/api.ts index 4031bf6f1..2aa0e255b 100644 --- a/src/components/utils/api.ts +++ b/src/components/utils/api.ts @@ -1,6 +1,6 @@ import type { BlockAPI } from '../../../types/api/block'; -import { EditorModules } from '../../types-internal/editor-modules'; -import Block from '../block'; +import type { EditorModules } from '../../types-internal/editor-modules'; +import type Block from '../block'; /** * Returns Block instance by passed Block index or Block id diff --git a/src/components/utils/blocks.ts b/src/components/utils/blocks.ts index 52e739bfa..471bb8647 100644 --- a/src/components/utils/blocks.ts +++ b/src/components/utils/blocks.ts @@ -1,9 +1,9 @@ -import { BlockAPI } from '../../../types'; +import type { BlockAPI } from '../../../types'; import type { ConversionConfig } from '../../../types/configs/conversion-config'; -import { SavedData } from '../../../types/data-formats'; +import type { SavedData } from '../../../types/data-formats'; import type { BlockToolData } from '../../../types/tools/block-tool-data'; import type Block from '../block'; -import BlockTool from '../tools/block'; +import type BlockToolAdapter from '../tools/block'; import { isFunction, isString, log, equals, isEmpty } from '../utils'; import { isToolConvertable } from './tools'; @@ -47,7 +47,7 @@ export function isSameBlockData(data1: BlockToolData, data2: BlockToolData): boo * @param block - block to get conversion items for * @param allBlockTools - all block tools available in the editor */ -export async function getConvertibleToolsForBlock(block: BlockAPI, allBlockTools: BlockTool[]): Promise { +export async function getConvertibleToolsForBlock(block: BlockAPI, allBlockTools: BlockToolAdapter[]): Promise { const savedData = await block.save() as SavedData; const blockData = savedData.data; diff --git a/src/components/utils/notifier.ts b/src/components/utils/notifier.ts index 9ba64bf07..d71571602 100644 --- a/src/components/utils/notifier.ts +++ b/src/components/utils/notifier.ts @@ -3,7 +3,8 @@ * * @see https://github.com/codex-team/js-notifier */ -import notifier, { ConfirmNotifierOptions, NotifierOptions, PromptNotifierOptions } from 'codex-notifier'; +import type { ConfirmNotifierOptions, NotifierOptions, PromptNotifierOptions } from 'codex-notifier'; +import notifier from 'codex-notifier'; /** * Util for showing notifications diff --git a/src/components/utils/popover/components/hint/hint.ts b/src/components/utils/popover/components/hint/hint.ts index 828eb139b..8774f180d 100644 --- a/src/components/utils/popover/components/hint/hint.ts +++ b/src/components/utils/popover/components/hint/hint.ts @@ -1,6 +1,6 @@ import Dom from '../../../../dom'; import { css } from './hint.const'; -import { HintParams } from './hint.types'; +import type { HintParams } from '@/types/utils/popover/hint'; import './hint.css'; diff --git a/src/components/utils/popover/components/hint/index.ts b/src/components/utils/popover/components/hint/index.ts index 9e4870aba..94442802d 100644 --- a/src/components/utils/popover/components/hint/index.ts +++ b/src/components/utils/popover/components/hint/index.ts @@ -1,2 +1,6 @@ export * from './hint'; -export * from './hint.types'; +export type { + HintParams, + HintPosition, + HintTextAlignment +} from '@/types/utils/popover/hint'; diff --git a/src/components/utils/popover/components/popover-header/popover-header.ts b/src/components/utils/popover/components/popover-header/popover-header.ts index edfe4e412..62d558eaa 100644 --- a/src/components/utils/popover/components/popover-header/popover-header.ts +++ b/src/components/utils/popover/components/popover-header/popover-header.ts @@ -1,4 +1,4 @@ -import { PopoverHeaderParams } from './popover-header.types'; +import type { PopoverHeaderParams } from './popover-header.types'; import Dom from '../../../../dom'; import { css } from './popover-header.const'; import { IconChevronLeft } from '@codexteam/icons'; diff --git a/src/components/utils/popover/components/popover-item/index.ts b/src/components/utils/popover/components/popover-item/index.ts index 12c91d40a..5f2ff4a5f 100644 --- a/src/components/utils/popover/components/popover-item/index.ts +++ b/src/components/utils/popover/components/popover-item/index.ts @@ -3,7 +3,8 @@ import { PopoverItemSeparator } from './popover-item-separator/popover-item-sepa import { PopoverItem } from './popover-item'; export * from './popover-item-default/popover-item-default.const'; -export * from './popover-item.types'; +export type * from '@/types/utils/popover/popover-item.d.ts'; +export { PopoverItemType } from '@/types/utils/popover/popover-item-type'; export { PopoverItemDefault, diff --git a/src/components/utils/popover/components/popover-item/popover-item-default/popover-item-default.ts b/src/components/utils/popover/components/popover-item/popover-item-default/popover-item-default.ts index df50e73e4..7e9889ac8 100644 --- a/src/components/utils/popover/components/popover-item/popover-item-default/popover-item-default.ts +++ b/src/components/utils/popover/components/popover-item/popover-item-default/popover-item-default.ts @@ -1,10 +1,10 @@ import Dom from '../../../../../dom'; import { IconDotCircle, IconChevronRight } from '@codexteam/icons'; -import { +import type { PopoverItemDefaultParams as PopoverItemDefaultParams, PopoverItemRenderParamsMap, PopoverItemType -} from '../popover-item.types'; +} from '@/types/utils/popover/popover-item'; import { PopoverItem } from '../popover-item'; import { css } from './popover-item-default.const'; diff --git a/src/components/utils/popover/components/popover-item/popover-item-html/popover-item-html.ts b/src/components/utils/popover/components/popover-item/popover-item-html/popover-item-html.ts index d06210ebf..c578b14f9 100644 --- a/src/components/utils/popover/components/popover-item/popover-item-html/popover-item-html.ts +++ b/src/components/utils/popover/components/popover-item/popover-item-html/popover-item-html.ts @@ -1,5 +1,5 @@ import { PopoverItem } from '../popover-item'; -import { PopoverItemHtmlParams, PopoverItemRenderParamsMap, PopoverItemType } from '../popover-item.types'; +import type { PopoverItemHtmlParams, PopoverItemRenderParamsMap, PopoverItemType } from '@/types/utils/popover/popover-item'; import { css } from './popover-item-html.const'; import Dom from '../../../../../dom'; diff --git a/src/components/utils/popover/components/popover-item/popover-item.ts b/src/components/utils/popover/components/popover-item/popover-item.ts index 9fc59b563..b211cab99 100644 --- a/src/components/utils/popover/components/popover-item/popover-item.ts +++ b/src/components/utils/popover/components/popover-item/popover-item.ts @@ -1,6 +1,6 @@ import * as tooltip from '../../../../utils/tooltip'; import { type HintPosition, Hint } from '../hint'; -import { PopoverItemParams } from './popover-item.types'; +import type { PopoverItemParams } from '@/types/utils/popover/popover-item'; /** * Popover item abstract class diff --git a/src/components/utils/popover/components/search-input/search-input.ts b/src/components/utils/popover/components/search-input/search-input.ts index b726ce5a5..0714ff1c5 100644 --- a/src/components/utils/popover/components/search-input/search-input.ts +++ b/src/components/utils/popover/components/search-input/search-input.ts @@ -1,7 +1,8 @@ import Dom from '../../../../dom'; import Listeners from '../../../listeners'; import { IconSearch } from '@codexteam/icons'; -import { SearchInputEvent, SearchInputEventMap, SearchableItem } from './search-input.types'; +import type { SearchInputEventMap, SearchableItem } from './search-input.types'; +import { SearchInputEvent } from './search-input.types'; import { css } from './search-input.const'; import EventsDispatcher from '../../../events'; diff --git a/src/components/utils/popover/index.ts b/src/components/utils/popover/index.ts index d7834a95a..f335f5816 100644 --- a/src/components/utils/popover/index.ts +++ b/src/components/utils/popover/index.ts @@ -2,8 +2,8 @@ import { PopoverDesktop } from './popover-desktop'; import { PopoverInline } from './popover-inline'; import { PopoverMobile } from './popover-mobile'; -export * from './popover.types'; -export * from './components/popover-item/popover-item.types'; +export type * from '@/types/utils/popover'; +export { PopoverItemType } from '@/types/utils/popover/popover-item-type'; /** * Union type for all popovers diff --git a/src/components/utils/popover/popover-abstract.ts b/src/components/utils/popover/popover-abstract.ts index 7b8e8f0a3..f04539546 100644 --- a/src/components/utils/popover/popover-abstract.ts +++ b/src/components/utils/popover/popover-abstract.ts @@ -1,11 +1,13 @@ -import { PopoverItem, PopoverItemDefault, PopoverItemRenderParamsMap, PopoverItemSeparator, PopoverItemType } from './components/popover-item'; +import type { PopoverItem, PopoverItemRenderParamsMap } from './components/popover-item'; +import { PopoverItemDefault, PopoverItemSeparator, PopoverItemType } from './components/popover-item'; import Dom from '../../dom'; -import { SearchInput } from './components/search-input'; +import type { SearchInput } from './components/search-input'; import EventsDispatcher from '../events'; import Listeners from '../listeners'; -import { PopoverEventMap, PopoverMessages, PopoverParams, PopoverEvent, PopoverNodes } from './popover.types'; +import type { PopoverEventMap, PopoverMessages, PopoverParams, PopoverNodes } from '@/types/utils/popover/popover'; +import { PopoverEvent } from '@/types/utils/popover/popover-event'; import { css } from './popover.const'; -import { PopoverItemParams } from './components/popover-item'; +import type { PopoverItemParams } from './components/popover-item'; import { PopoverItemHtml } from './components/popover-item/popover-item-html/popover-item-html'; /** diff --git a/src/components/utils/popover/popover-desktop.ts b/src/components/utils/popover/popover-desktop.ts index 7adff41f8..1eb6ae6c0 100644 --- a/src/components/utils/popover/popover-desktop.ts +++ b/src/components/utils/popover/popover-desktop.ts @@ -1,10 +1,13 @@ import Flipper from '../../flipper'; import { PopoverAbstract } from './popover-abstract'; -import { PopoverItem, PopoverItemRenderParamsMap, PopoverItemSeparator, css as popoverItemCls } from './components/popover-item'; -import { PopoverEvent, PopoverParams } from './popover.types'; +import type { PopoverItem, PopoverItemRenderParamsMap } from './components/popover-item'; +import { PopoverItemSeparator, css as popoverItemCls } from './components/popover-item'; +import type { PopoverParams } from '@/types/utils/popover/popover'; +import { PopoverEvent } from '@/types/utils/popover/popover-event'; import { keyCodes } from '../../utils'; import { CSSVariables, css } from './popover.const'; -import { SearchInput, SearchInputEvent, SearchableItem } from './components/search-input'; +import type { SearchableItem } from './components/search-input'; +import { SearchInput, SearchInputEvent } from './components/search-input'; import { cacheable } from '../../utils'; import { PopoverItemDefault } from './components/popover-item'; import { PopoverItemHtml } from './components/popover-item/popover-item-html/popover-item-html'; diff --git a/src/components/utils/popover/popover-inline.ts b/src/components/utils/popover/popover-inline.ts index a82db45cf..ebe91223c 100644 --- a/src/components/utils/popover/popover-inline.ts +++ b/src/components/utils/popover/popover-inline.ts @@ -1,9 +1,10 @@ import { isMobileScreen } from '../../utils'; -import { PopoverItem, PopoverItemDefault, PopoverItemType } from './components/popover-item'; +import type { PopoverItem } from './components/popover-item'; +import { PopoverItemDefault, PopoverItemType } from './components/popover-item'; import { PopoverItemHtml } from './components/popover-item/popover-item-html/popover-item-html'; import { PopoverDesktop } from './popover-desktop'; import { CSSVariables, css } from './popover.const'; -import { PopoverParams } from './popover.types'; +import type { PopoverParams } from '@/types/utils/popover/popover'; /** * Horizontal popover that is displayed inline with the content @@ -128,7 +129,7 @@ export class PopoverInline extends PopoverDesktop { protected override showNestedItems(item: PopoverItemDefault | PopoverItemHtml): void { if (this.nestedPopoverTriggerItem === item) { this.destroyNestedPopoverIfExists(); - + this.nestedPopoverTriggerItem = null; return; diff --git a/src/components/utils/popover/popover-mobile.ts b/src/components/utils/popover/popover-mobile.ts index fb599199a..c787d7e3a 100644 --- a/src/components/utils/popover/popover-mobile.ts +++ b/src/components/utils/popover/popover-mobile.ts @@ -2,8 +2,9 @@ import { PopoverAbstract } from './popover-abstract'; import ScrollLocker from '../scroll-locker'; import { PopoverHeader } from './components/popover-header'; import { PopoverStatesHistory } from './utils/popover-states-history'; -import { PopoverMobileNodes, PopoverParams } from './popover.types'; -import { PopoverItemDefault, PopoverItemParams, PopoverItemType } from './components/popover-item'; +import type { PopoverMobileNodes, PopoverParams } from '@/types/utils/popover/popover'; +import type { PopoverItemDefault, PopoverItemParams } from './components/popover-item'; +import { PopoverItemType } from './components/popover-item'; import { css } from './popover.const'; import Dom from '../../dom'; diff --git a/src/components/utils/popover/utils/popover-states-history.ts b/src/components/utils/popover/utils/popover-states-history.ts index 92975468c..1beb3c26f 100644 --- a/src/components/utils/popover/utils/popover-states-history.ts +++ b/src/components/utils/popover/utils/popover-states-history.ts @@ -1,4 +1,4 @@ -import { PopoverItem } from '../../../../../types'; +import type { PopoverItemParams } from '@/types/utils/popover/popover-item'; /** * Represents single states history item @@ -12,7 +12,7 @@ interface PopoverStatesHistoryItem { /** * Popover items */ - items: PopoverItem[] + items: PopoverItemParams[] } /** @@ -54,7 +54,7 @@ export class PopoverStatesHistory { /** * Items list retrieved from the current state */ - public get currentItems(): PopoverItem[] { + public get currentItems(): PopoverItemParams[] { if (this.history.length === 0) { return []; } diff --git a/src/components/utils/sanitizer.ts b/src/components/utils/sanitizer.ts index 9d55a82a5..69d501490 100644 --- a/src/components/utils/sanitizer.ts +++ b/src/components/utils/sanitizer.ts @@ -30,8 +30,8 @@ import * as _ from '../utils'; */ import HTMLJanitor from 'html-janitor'; -import { BlockToolData, SanitizerConfig } from '../../../types'; -import { SavedData } from '../../../types/data-formats'; +import type { BlockToolData, SanitizerConfig } from '../../../types'; +import type { SavedData } from '../../../types/data-formats'; /** * Sanitize Blocks diff --git a/src/components/utils/tools.ts b/src/components/utils/tools.ts index 2defc4912..4c384ca6f 100644 --- a/src/components/utils/tools.ts +++ b/src/components/utils/tools.ts @@ -1,4 +1,4 @@ -import BlockTool from '../tools/block'; +import type BlockToolAdapter from '../tools/block'; import { isFunction, isString } from '../utils'; /** @@ -7,7 +7,7 @@ import { isFunction, isString } from '../utils'; * @param tool - tool to check * @param direction - export for tool to merge from, import for tool to merge to */ -export function isToolConvertable(tool: BlockTool, direction: 'export' | 'import'): boolean { +export function isToolConvertable(tool: BlockToolAdapter, direction: 'export' | 'import'): boolean { if (!tool.conversionConfig) { return false; } diff --git a/src/tools/stub/index.ts b/src/tools/stub/index.ts index be75295f8..a4c8aebc9 100644 --- a/src/tools/stub/index.ts +++ b/src/tools/stub/index.ts @@ -1,5 +1,5 @@ import $ from '../../components/dom'; -import { API, BlockTool, BlockToolConstructorOptions, BlockToolData } from '../../../types'; +import type { API, BlockTool, BlockToolConstructorOptions, BlockToolData } from '../../../types'; import { IconWarning } from '@codexteam/icons'; export interface StubData extends BlockToolData { diff --git a/test/cypress/fixtures/tools/ContentlessTool.ts b/test/cypress/fixtures/tools/ContentlessTool.ts index 49b137772..be5885665 100644 --- a/test/cypress/fixtures/tools/ContentlessTool.ts +++ b/test/cypress/fixtures/tools/ContentlessTool.ts @@ -1,4 +1,4 @@ -import { BlockTool } from '../../../../types'; +import type { BlockTool } from '../../../../types'; /** * In the simplest Contentless Tool (eg. Delimiter) there is no data to save diff --git a/test/cypress/fixtures/tools/SimpleHeader.ts b/test/cypress/fixtures/tools/SimpleHeader.ts index 17cb89a9f..cd87aa7ec 100644 --- a/test/cypress/fixtures/tools/SimpleHeader.ts +++ b/test/cypress/fixtures/tools/SimpleHeader.ts @@ -1,4 +1,4 @@ -import { +import type { BaseTool, BlockToolConstructorOptions, BlockToolData, diff --git a/test/cypress/fixtures/tools/ToolMock.ts b/test/cypress/fixtures/tools/ToolMock.ts index 0ef835f8a..67b290454 100644 --- a/test/cypress/fixtures/tools/ToolMock.ts +++ b/test/cypress/fixtures/tools/ToolMock.ts @@ -1,4 +1,4 @@ -import { BlockTool, BlockToolConstructorOptions } from '../../../../types'; +import type { BlockTool, BlockToolConstructorOptions } from '../../../../types'; /** * Simple structure for Tool data diff --git a/test/cypress/fixtures/types/PartialBlockMutationEvent.ts b/test/cypress/fixtures/types/PartialBlockMutationEvent.ts index 75e23e990..6955eb227 100644 --- a/test/cypress/fixtures/types/PartialBlockMutationEvent.ts +++ b/test/cypress/fixtures/types/PartialBlockMutationEvent.ts @@ -1,4 +1,4 @@ -import { BlockMutationEvent, BlockMutationType } from '../../../../types'; +import type { BlockMutationEvent, BlockMutationType } from '../../../../types'; /** * Simplified version of the BlockMutationEvent with optional fields that could be used in tests diff --git a/test/cypress/plugins/index.ts b/test/cypress/plugins/index.ts deleted file mode 100644 index 3731ae53e..000000000 --- a/test/cypress/plugins/index.ts +++ /dev/null @@ -1,15 +0,0 @@ -/** - * This file contains connection of Cypres plugins - */ -import * as codeCoverageTask from '@cypress/code-coverage/task'; - -module.exports = (on, config): unknown => { - /** - * Add Cypress task to get code coverage - */ - codeCoverageTask(on, config); - - // It's IMPORTANT to return the config object - // with any changed environment variables - return config; -}; diff --git a/test/cypress/support/e2e.ts b/test/cypress/support/e2e.ts index d19830777..0ec34b571 100644 --- a/test/cypress/support/e2e.ts +++ b/test/cypress/support/e2e.ts @@ -1,3 +1,4 @@ +import '@cypress/code-coverage/support'; /* global chai */ // because this file is imported from cypress/support/e2e.js @@ -5,7 +6,7 @@ // available to them because the supportFile is bundled and served // prior to any spec files loading -import PartialBlockMutationEvent from '../fixtures/types/PartialBlockMutationEvent'; +import type PartialBlockMutationEvent from '../fixtures/types/PartialBlockMutationEvent'; /** * Chai plugin for checking if passed onChange method is called with an array of passed events diff --git a/test/cypress/support/utils/createEditorWithTextBlocks.ts b/test/cypress/support/utils/createEditorWithTextBlocks.ts index 95deb66bb..08d0fc49b 100644 --- a/test/cypress/support/utils/createEditorWithTextBlocks.ts +++ b/test/cypress/support/utils/createEditorWithTextBlocks.ts @@ -1,4 +1,4 @@ -import { EditorConfig } from '../../../../types/index'; +import type { EditorConfig } from '../../../../types/index'; import Chainable = Cypress.Chainable; import type EditorJS from '../../../../types/index'; diff --git a/test/cypress/tests/api/block.cy.ts b/test/cypress/tests/api/block.cy.ts index 188de0689..d5d731f11 100644 --- a/test/cypress/tests/api/block.cy.ts +++ b/test/cypress/tests/api/block.cy.ts @@ -1,4 +1,4 @@ -import EditorJS from '../../../../types'; +import type EditorJS from '../../../../types'; import { BlockChangedMutationType } from '../../../../types/events/block/BlockChanged'; /** diff --git a/test/cypress/tests/api/blocks.cy.ts b/test/cypress/tests/api/blocks.cy.ts index 66496bf71..17da54bf3 100644 --- a/test/cypress/tests/api/blocks.cy.ts +++ b/test/cypress/tests/api/blocks.cy.ts @@ -1,7 +1,7 @@ import type EditorJS from '../../../../types/index'; import type { ConversionConfig, ToolboxConfig } from '../../../../types'; import ToolMock from '../../fixtures/tools/ToolMock'; -import {nanoid} from "nanoid"; +import { nanoid } from 'nanoid'; /** * There will be described test cases of 'blocks.*' API @@ -108,13 +108,12 @@ describe('api.blocks', () => { * Example Tune Class */ class ExampleTune { - protected data: object; /** * * @param data */ - constructor({ data}) { + constructor({ data }) { this.data = data; } diff --git a/test/cypress/tests/api/caret.cy.ts b/test/cypress/tests/api/caret.cy.ts index a50c7b276..882bc1534 100644 --- a/test/cypress/tests/api/caret.cy.ts +++ b/test/cypress/tests/api/caret.cy.ts @@ -1,4 +1,4 @@ -import EditorJS from '../../../../types'; +import type EditorJS from '../../../../types'; /** * Test cases for Caret API diff --git a/test/cypress/tests/api/toolbar.cy.ts b/test/cypress/tests/api/toolbar.cy.ts index 4a8d92378..41da27b14 100644 --- a/test/cypress/tests/api/toolbar.cy.ts +++ b/test/cypress/tests/api/toolbar.cy.ts @@ -1,7 +1,7 @@ /** * There will be described test cases of 'api.toolbar.*' API */ -import EditorJS from '../../../../types'; +import type EditorJS from '../../../../types'; describe('api.toolbar', () => { /** diff --git a/test/cypress/tests/api/tools.cy.ts b/test/cypress/tests/api/tools.cy.ts index 85bfae7e3..be6a52c3b 100644 --- a/test/cypress/tests/api/tools.cy.ts +++ b/test/cypress/tests/api/tools.cy.ts @@ -1,6 +1,6 @@ -import { ToolboxConfig, BlockToolData, ToolboxConfigEntry, PasteConfig } from '../../../../types'; -import EditorJS from '../../../../types'; -import { HTMLPasteEvent, TunesMenuConfig } from '../../../../types/tools'; +import type { ToolboxConfig, BlockToolData, ToolboxConfigEntry, PasteConfig } from '../../../../types'; +import type EditorJS from '../../../../types'; +import type { HTMLPasteEvent, TunesMenuConfig } from '../../../../types/tools'; /* eslint-disable @typescript-eslint/no-empty-function */ diff --git a/test/cypress/tests/api/tunes.cy.ts b/test/cypress/tests/api/tunes.cy.ts index 9cf760fe9..104e4d4ac 100644 --- a/test/cypress/tests/api/tunes.cy.ts +++ b/test/cypress/tests/api/tunes.cy.ts @@ -1,4 +1,4 @@ -import { TunesMenuConfig } from '../../../../types/tools'; +import type { TunesMenuConfig } from '../../../../types/tools'; /* eslint-disable @typescript-eslint/no-empty-function */ diff --git a/test/cypress/tests/copy-paste.cy.ts b/test/cypress/tests/copy-paste.cy.ts index 4862c5109..9a9b4a27c 100644 --- a/test/cypress/tests/copy-paste.cy.ts +++ b/test/cypress/tests/copy-paste.cy.ts @@ -1,7 +1,7 @@ import Header from '@editorjs/header'; import Image from '@editorjs/simple-image'; import * as _ from '../../../src/components/utils'; -import { BlockTool, BlockToolData, OutputData } from '../../../types'; +import type { BlockTool, BlockToolData, OutputData } from '../../../types'; import $ from '../../../src/components/dom'; import type EditorJS from '../../../types/index'; diff --git a/test/cypress/tests/i18n.cy.ts b/test/cypress/tests/i18n.cy.ts index b17df991e..1bcb6b4c7 100644 --- a/test/cypress/tests/i18n.cy.ts +++ b/test/cypress/tests/i18n.cy.ts @@ -1,5 +1,5 @@ import Header from '@editorjs/header'; -import { ToolboxConfig } from '../../../types'; +import type { ToolboxConfig } from '../../../types'; describe('Editor i18n', () => { context('Toolbox', () => { diff --git a/test/cypress/tests/modules/Tools.cy.ts b/test/cypress/tests/modules/Tools.cy.ts index 407ed032a..b4d7770b4 100644 --- a/test/cypress/tests/modules/Tools.cy.ts +++ b/test/cypress/tests/modules/Tools.cy.ts @@ -1,8 +1,8 @@ /* tslint:disable:max-classes-per-file */ /* eslint-disable @typescript-eslint/no-explicit-any, jsdoc/require-jsdoc */ import Tools from '../../../../src/components/modules/tools'; -import { EditorConfig } from '../../../../types'; -import BlockTool from '../../../../src/components/tools/block'; +import type { EditorConfig } from '../../../../types'; +import BlockToolAdapter from '../../../../src/components/tools/block'; describe('Tools module', () => { const defaultConfig = { @@ -315,7 +315,7 @@ describe('Tools module', () => { * @todo add check if user provided default tool is not Block Tool */ it('should return BlockTool instance', () => { - expect(module.defaultTool).to.be.instanceOf(BlockTool); + expect(module.defaultTool).to.be.instanceOf(BlockToolAdapter); }); it('should return default Tool', () => { diff --git a/test/cypress/tests/readOnly.cy.ts b/test/cypress/tests/readOnly.cy.ts index 8bd922568..f1f8e496c 100644 --- a/test/cypress/tests/readOnly.cy.ts +++ b/test/cypress/tests/readOnly.cy.ts @@ -1,4 +1,5 @@ -import EditorJS, { EditorConfig } from '../../../types'; +import type { EditorConfig } from '../../../types'; +import type EditorJS from '../../../types'; describe('ReadOnly API spec', () => { /** diff --git a/test/cypress/tests/sanitisation.cy.ts b/test/cypress/tests/sanitisation.cy.ts index 313e7085c..f0653b870 100644 --- a/test/cypress/tests/sanitisation.cy.ts +++ b/test/cypress/tests/sanitisation.cy.ts @@ -1,5 +1,5 @@ import type EditorJS from '../../../types/index'; -import { OutputData } from '../../../types/index'; +import type { OutputData } from '../../../types/index'; /* eslint-disable @typescript-eslint/no-explicit-any */ diff --git a/test/cypress/tests/tools/BlockTool.cy.ts b/test/cypress/tests/tools/BlockTool.cy.ts index 29df97712..f1ec19243 100644 --- a/test/cypress/tests/tools/BlockTool.cy.ts +++ b/test/cypress/tests/tools/BlockTool.cy.ts @@ -1,9 +1,9 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ /* tslint:disable:max-classes-per-file */ -import { BlockToolData, ToolSettings } from '../../../../types'; -import { ToolType } from '../../../../src/components/tools/base'; -import BlockTool from '../../../../src/components/tools/block'; -import InlineTool from '../../../../src/components/tools/inline'; +import type { BlockToolData, ToolSettings } from '@/types'; +import { ToolType } from '@/types/tools/adapters/tool-type'; +import BlockToolAdapter from '../../../../src/components/tools/block'; +import InlineToolAdapter from '../../../../src/components/tools/inline'; import ToolsCollection from '../../../../src/components/tools/collection'; describe('BlockTool', () => { @@ -80,20 +80,20 @@ describe('BlockTool', () => { }; it('.type should return ToolType.Block', () => { - const tool = new BlockTool(options as any); + const tool = new BlockToolAdapter(options as any); expect(tool.type).to.be.eq(ToolType.Block); }); it('.name should return correct value', () => { - const tool = new BlockTool(options as any); + const tool = new BlockToolAdapter(options as any); expect(tool.name).to.be.eq(options.name); }); it('.isDefault should return correct value', () => { - const tool1 = new BlockTool(options as any); - const tool2 = new BlockTool({ + const tool1 = new BlockToolAdapter(options as any); + const tool2 = new BlockToolAdapter({ ...options, isDefault: true, } as any); @@ -103,8 +103,8 @@ describe('BlockTool', () => { }); it('.isInternal should return correct value', () => { - const tool1 = new BlockTool(options as any); - const tool2 = new BlockTool({ + const tool1 = new BlockToolAdapter(options as any); + const tool2 = new BlockToolAdapter({ ...options, isInternal: true, } as any); @@ -115,13 +115,13 @@ describe('BlockTool', () => { context('.settings', () => { it('should return correct value', () => { - const tool = new BlockTool(options as any); + const tool = new BlockToolAdapter(options as any); expect(tool.settings).to.be.deep.eq(options.config.config); }); it('should add default placeholder if Tool is default', () => { - const tool = new BlockTool({ + const tool = new BlockToolAdapter({ ...options, isDefault: true, } as any); @@ -132,15 +132,15 @@ describe('BlockTool', () => { context('.sanitizeConfig', () => { it('should return correct value', () => { - const tool = new BlockTool(options as any); + const tool = new BlockToolAdapter(options as any); expect(tool.sanitizeConfig).to.be.deep.eq(options.constructable.sanitize); }); it('should return composed config if there are enabled inline tools', () => { - const tool = new BlockTool(options as any); + const tool = new BlockToolAdapter(options as any); - const inlineTool = new InlineTool({ + const inlineTool = new InlineToolAdapter({ name: 'inlineTool', constructable: class { public static sanitize = { @@ -167,12 +167,12 @@ describe('BlockTool', () => { }); it('should return inline tools config if block one is not set', () => { - const tool = new BlockTool({ + const tool = new BlockToolAdapter({ ...options, constructable: class {}, } as any); - const inlineTool1 = new InlineTool({ + const inlineTool1 = new InlineToolAdapter({ name: 'inlineTool', constructable: class { public static sanitize = { @@ -183,7 +183,7 @@ describe('BlockTool', () => { config: {}, } as any); - const inlineTool2 = new InlineTool({ + const inlineTool2 = new InlineToolAdapter({ name: 'inlineTool', constructable: class { public static sanitize = { @@ -204,7 +204,7 @@ describe('BlockTool', () => { }); it('should return empty object by default', () => { - const tool = new BlockTool({ + const tool = new BlockToolAdapter({ ...options, constructable: class {}, } as any); @@ -214,44 +214,44 @@ describe('BlockTool', () => { }); it('.isBlock() should return true', () => { - const tool = new BlockTool(options as any); + const tool = new BlockToolAdapter(options as any); expect(tool.isBlock()).to.be.true; }); it('.isInline() should return false', () => { - const tool = new BlockTool(options as any); + const tool = new BlockToolAdapter(options as any); expect(tool.isInline()).to.be.false; }); it('.isTune() should return false', () => { - const tool = new BlockTool(options as any); + const tool = new BlockToolAdapter(options as any); expect(tool.isTune()).to.be.false; }); it('.isReadOnlySupported should return correct value', () => { - const tool = new BlockTool(options as any); + const tool = new BlockToolAdapter(options as any); expect(tool.isReadOnlySupported).to.be.eq(options.constructable.isReadOnlySupported); }); it('.isLineBreaksEnabled should return correct value', () => { - const tool = new BlockTool(options as any); + const tool = new BlockToolAdapter(options as any); expect(tool.isLineBreaksEnabled).to.be.eq(options.constructable.enableLineBreaks); }); it('.conversionConfig should return correct value', () => { - const tool = new BlockTool(options as any); + const tool = new BlockToolAdapter(options as any); expect(tool.conversionConfig).to.be.deep.eq(options.constructable.conversionConfig); }); describe('.pasteConfig', () => { it('should return correct value', () => { - const tool = new BlockTool(options as any); + const tool = new BlockToolAdapter(options as any); expect(tool.pasteConfig).to.be.deep.eq(options.constructable.pasteConfig); }); @@ -263,7 +263,7 @@ describe('BlockTool', () => { public static pasteConfig = false; }, }; - const tool = new BlockTool(optionsWithDisabledPaste as any); + const tool = new BlockToolAdapter(optionsWithDisabledPaste as any); expect(tool.pasteConfig).to.be.deep.eq(optionsWithDisabledPaste.constructable.pasteConfig); }); @@ -275,7 +275,7 @@ describe('BlockTool', () => { public static pasteConfig = undefined; }, }; - const tool = new BlockTool(optionsWithoutPasteConfig as any); + const tool = new BlockToolAdapter(optionsWithoutPasteConfig as any); expect(tool.pasteConfig).to.be.deep.eq({}); }); @@ -283,13 +283,13 @@ describe('BlockTool', () => { context('.enabledInlineTools', () => { it('should return correct value', () => { - const tool = new BlockTool(options as any); + const tool = new BlockToolAdapter(options as any); expect(tool.enabledInlineTools).to.be.deep.eq(options.config.inlineToolbar); }); it('should return false by default', () => { - const tool = new BlockTool({ + const tool = new BlockToolAdapter({ ...options, config: { ...options.config, @@ -302,7 +302,7 @@ describe('BlockTool', () => { }); it('.enabledBlockTunes should return correct value', () => { - const tool = new BlockTool(options as any); + const tool = new BlockToolAdapter(options as any); expect(tool.enabledBlockTunes).to.be.deep.eq(options.config.tunes); }); @@ -310,7 +310,7 @@ describe('BlockTool', () => { context('.prepare()', () => { it('should call Tool prepare method', () => { options.constructable.prepare = cy.stub(); - const tool = new BlockTool(options as any); + const tool = new BlockToolAdapter(options as any); tool.prepare(); @@ -321,7 +321,7 @@ describe('BlockTool', () => { }); it('should not fail if Tool prepare method is not exist', () => { - const tool = new BlockTool({ + const tool = new BlockToolAdapter({ ...options, constructable: {}, } as any); @@ -333,7 +333,7 @@ describe('BlockTool', () => { context('.reset()', () => { it('should call Tool reset method', () => { options.constructable.reset = cy.stub(); - const tool = new BlockTool(options as any); + const tool = new BlockToolAdapter(options as any); tool.reset(); @@ -341,7 +341,7 @@ describe('BlockTool', () => { }); it('should not fail if Tool reset method is not exist', () => { - const tool = new BlockTool({ + const tool = new BlockToolAdapter({ ...options, constructable: {}, } as any); @@ -352,13 +352,13 @@ describe('BlockTool', () => { context('.shortcut', () => { it('should return user provided shortcut', () => { - const tool = new BlockTool(options as any); + const tool = new BlockToolAdapter(options as any); expect(tool.shortcut).to.be.eq(options.config.shortcut); }); it('should return Tool provided shortcut if user one is not specified', () => { - const tool = new BlockTool({ + const tool = new BlockToolAdapter({ ...options, config: { ...options.config, @@ -372,13 +372,13 @@ describe('BlockTool', () => { context('.toolbox', () => { it('should return user provided toolbox config wrapped in array', () => { - const tool = new BlockTool(options as any); + const tool = new BlockToolAdapter(options as any); expect(tool.toolbox).to.be.deep.eq([ options.config.toolbox ]); }); it('should return Tool provided toolbox config wrapped in array if user one is not specified', () => { - const tool = new BlockTool({ + const tool = new BlockToolAdapter({ ...options, config: { ...options.config, @@ -390,7 +390,7 @@ describe('BlockTool', () => { }); it('should merge Tool provided toolbox config and user one and wrap result in array in case both are objects', () => { - const tool1 = new BlockTool({ + const tool1 = new BlockToolAdapter({ ...options, config: { ...options.config, @@ -399,7 +399,7 @@ describe('BlockTool', () => { }, }, } as any); - const tool2 = new BlockTool({ + const tool2 = new BlockToolAdapter({ ...options, config: { ...options.config, @@ -426,7 +426,7 @@ describe('BlockTool', () => { icon: options.config.toolbox.icon, title: options.config.toolbox.title, }; - const tool = new BlockTool({ + const tool = new BlockToolAdapter({ ...options, constructable: { ...options.constructable, @@ -450,7 +450,7 @@ describe('BlockTool', () => { title: 'Toolbox entry 2', }, ]; - const tool = new BlockTool({ + const tool = new BlockToolAdapter({ ...options, config: { ...options.config, @@ -478,7 +478,7 @@ describe('BlockTool', () => { }, ]; - const tool = new BlockTool({ + const tool = new BlockToolAdapter({ ...options, constructable: { ...options.constructable, @@ -507,7 +507,7 @@ describe('BlockTool', () => { }); it('should return undefined if user specifies false as a value', () => { - const tool = new BlockTool({ + const tool = new BlockToolAdapter({ ...options, config: { ...options.config, @@ -519,7 +519,7 @@ describe('BlockTool', () => { }); it('should return undefined if Tool specifies false as a value', () => { - const tool = new BlockTool({ + const tool = new BlockToolAdapter({ ...options, constructable: class { public static toolbox = false; @@ -530,7 +530,7 @@ describe('BlockTool', () => { }); it('should return undefined if Tool provides empty config', () => { - const tool = new BlockTool({ + const tool = new BlockToolAdapter({ ...options, constructable: class { public static toolbox = {}; @@ -542,7 +542,7 @@ describe('BlockTool', () => { }); context('.create()', () => { - const tool = new BlockTool(options as any); + const tool = new BlockToolAdapter(options as any); const data = { text: 'text' }; const blockAPI = { // eslint-disable-next-line @typescript-eslint/no-empty-function diff --git a/test/cypress/tests/tools/BlockTune.cy.ts b/test/cypress/tests/tools/BlockTune.cy.ts index 3c8c14fa0..c0001b4a3 100644 --- a/test/cypress/tests/tools/BlockTune.cy.ts +++ b/test/cypress/tests/tools/BlockTune.cy.ts @@ -1,9 +1,9 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ /* tslint:disable:max-classes-per-file */ -import { ToolSettings } from '../../../../types'; -import { ToolType } from '../../../../src/components/tools/base'; -import BlockTune from '../../../../src/components/tools/tune'; -import { BlockTuneData } from '../../../../types/block-tunes/block-tune-data'; +import type { ToolSettings } from '@/types'; +import { ToolType } from '@/types/tools/adapters/tool-type'; +import BlockTuneAdapter from '../../../../src/components/tools/tune'; +import type { BlockTuneData } from '@/types/block-tunes/block-tune-data'; describe('BlockTune', () => { /** @@ -45,20 +45,20 @@ describe('BlockTune', () => { }; it('.type should return ToolType.Tune', () => { - const tool = new BlockTune(options as any); + const tool = new BlockTuneAdapter(options as any); expect(tool.type).to.be.eq(ToolType.Tune); }); it('.name should return correct value', () => { - const tool = new BlockTune(options as any); + const tool = new BlockTuneAdapter(options as any); expect(tool.name).to.be.eq(options.name); }); it('.isInternal should return correct value', () => { - const tool1 = new BlockTune(options as any); - const tool2 = new BlockTune({ + const tool1 = new BlockTuneAdapter(options as any); + const tool2 = new BlockTuneAdapter({ ...options, isInternal: true, } as any); @@ -68,25 +68,25 @@ describe('BlockTune', () => { }); it('.settings should return correct value', () => { - const tool = new BlockTune(options as any); + const tool = new BlockTuneAdapter(options as any); expect(tool.settings).to.be.deep.eq(options.config.config); }); it('.isBlock() should return false', () => { - const tool = new BlockTune(options as any); + const tool = new BlockTuneAdapter(options as any); expect(tool.isBlock()).to.be.false; }); it('.isInline() should return false', () => { - const tool = new BlockTune(options as any); + const tool = new BlockTuneAdapter(options as any); expect(tool.isInline()).to.be.false; }); it('.isTune() should return true', () => { - const tool = new BlockTune(options as any); + const tool = new BlockTuneAdapter(options as any); expect(tool.isTune()).to.be.true; }); @@ -94,7 +94,7 @@ describe('BlockTune', () => { context('.prepare()', () => { it('should call Tool prepare method', () => { options.constructable.prepare = cy.stub(); - const tool = new BlockTune(options as any); + const tool = new BlockTuneAdapter(options as any); tool.prepare(); @@ -105,7 +105,7 @@ describe('BlockTune', () => { }); it('should not fail if Tool prepare method is not exist', () => { - const tool = new BlockTune({ + const tool = new BlockTuneAdapter({ ...options, constructable: {}, } as any); @@ -117,7 +117,7 @@ describe('BlockTune', () => { context('.reset()', () => { it('should call Tool reset method', () => { options.constructable.reset = cy.stub(); - const tool = new BlockTune(options as any); + const tool = new BlockTuneAdapter(options as any); tool.reset(); @@ -125,7 +125,7 @@ describe('BlockTune', () => { }); it('should not fail if Tool reset method is not exist', () => { - const tool = new BlockTune({ + const tool = new BlockTuneAdapter({ ...options, constructable: {}, } as any); @@ -135,7 +135,7 @@ describe('BlockTune', () => { }); context('.create()', () => { - const tool = new BlockTune(options as any); + const tool = new BlockTuneAdapter(options as any); const data = { text: 'text' }; const blockAPI = { // eslint-disable-next-line @typescript-eslint/no-empty-function diff --git a/test/cypress/tests/tools/InlineTool.cy.ts b/test/cypress/tests/tools/InlineTool.cy.ts index 656d0f37e..62fd8868f 100644 --- a/test/cypress/tests/tools/InlineTool.cy.ts +++ b/test/cypress/tests/tools/InlineTool.cy.ts @@ -1,8 +1,8 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ /* tslint:disable:max-classes-per-file */ -import { ToolSettings } from '../../../../types'; -import { ToolType } from '../../../../src/components/tools/base'; -import InlineTool from '../../../../src/components/tools/inline'; +import type { ToolSettings } from '@/types'; +import { ToolType } from '@/types/tools/adapters/tool-type'; +import InlineToolAdapter from '../../../../src/components/tools/inline'; describe('InlineTool', () => { /** @@ -52,26 +52,26 @@ describe('InlineTool', () => { }; it('.type should return ToolType.Inline', () => { - const tool = new InlineTool(options as any); + const tool = new InlineToolAdapter(options as any); expect(tool.type).to.be.eq(ToolType.Inline); }); it('.name should return correct value', () => { - const tool = new InlineTool(options as any); + const tool = new InlineToolAdapter(options as any); expect(tool.name).to.be.eq(options.name); }); it('.title should return correct title', () => { - const tool = new InlineTool(options as any); + const tool = new InlineToolAdapter(options as any); expect(tool.title).to.be.eq(options.constructable.title); }); it('.isInternal should return correct value', () => { - const tool1 = new InlineTool(options as any); - const tool2 = new InlineTool({ + const tool1 = new InlineToolAdapter(options as any); + const tool2 = new InlineToolAdapter({ ...options, isInternal: true, } as any); @@ -81,31 +81,31 @@ describe('InlineTool', () => { }); it('.settings should return correct value', () => { - const tool = new InlineTool(options as any); + const tool = new InlineToolAdapter(options as any); expect(tool.settings).to.be.deep.eq(options.config.config); }); it('.sanitizeConfig should return correct value', () => { - const tool = new InlineTool(options as any); + const tool = new InlineToolAdapter(options as any); expect(tool.sanitizeConfig).to.be.deep.eq(options.constructable.sanitize); }); it('.isBlock() should return false', () => { - const tool = new InlineTool(options as any); + const tool = new InlineToolAdapter(options as any); expect(tool.isBlock()).to.be.false; }); it('.isInline() should return true', () => { - const tool = new InlineTool(options as any); + const tool = new InlineToolAdapter(options as any); expect(tool.isInline()).to.be.true; }); it('.isTune() should return false', () => { - const tool = new InlineTool(options as any); + const tool = new InlineToolAdapter(options as any); expect(tool.isTune()).to.be.false; }); @@ -113,7 +113,7 @@ describe('InlineTool', () => { context('.prepare()', () => { it('should call Tool prepare method', () => { options.constructable.prepare = cy.stub(); - const tool = new InlineTool(options as any); + const tool = new InlineToolAdapter(options as any); tool.prepare(); @@ -124,7 +124,7 @@ describe('InlineTool', () => { }); it('should not fail if Tool prepare method is not exist', () => { - const tool = new InlineTool({ + const tool = new InlineToolAdapter({ ...options, constructable: {}, } as any); @@ -136,7 +136,7 @@ describe('InlineTool', () => { context('.reset()', () => { it('should call Tool reset method', () => { options.constructable.reset = cy.stub(); - const tool = new InlineTool(options as any); + const tool = new InlineToolAdapter(options as any); tool.reset(); @@ -144,7 +144,7 @@ describe('InlineTool', () => { }); it('should not fail if Tool reset method is not exist', () => { - const tool = new InlineTool({ + const tool = new InlineToolAdapter({ ...options, constructable: {}, } as any); @@ -155,13 +155,13 @@ describe('InlineTool', () => { context('.shortcut', () => { it('should return user provided shortcut', () => { - const tool = new InlineTool(options as any); + const tool = new InlineToolAdapter(options as any); expect(tool.shortcut).to.be.eq(options.config.shortcut); }); it('should return Tool provided shortcut if user one is not specified', () => { - const tool = new InlineTool({ + const tool = new InlineToolAdapter({ ...options, config: { ...options.config, @@ -174,7 +174,7 @@ describe('InlineTool', () => { }); context('.create()', () => { - const tool = new InlineTool(options as any); + const tool = new InlineToolAdapter(options as any); it('should return Tool instance', () => { expect(tool.create()).to.be.instanceOf(options.constructable); diff --git a/test/cypress/tests/tools/ToolsCollection.cy.ts b/test/cypress/tests/tools/ToolsCollection.cy.ts index 126093240..b6dcb37e4 100644 --- a/test/cypress/tests/tools/ToolsCollection.cy.ts +++ b/test/cypress/tests/tools/ToolsCollection.cy.ts @@ -1,9 +1,9 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ import ToolsCollection from '../../../../src/components/tools/collection'; -import BlockTool from '../../../../src/components/tools/block'; -import InlineTool from '../../../../src/components/tools/inline'; -import BlockTune from '../../../../src/components/tools/tune'; -import BaseTool from '../../../../src/components/tools/base'; +import type BlockToolAdapter from '../../../../src/components/tools/block'; +import type InlineToolAdapter from '../../../../src/components/tools/inline'; +import type BlockTuneAdapter from '../../../../src/components/tools/tune'; +import type BaseToolAdapter from '../../../../src/components/tools/base'; const FakeTool = { isBlock(): boolean { @@ -89,7 +89,7 @@ describe('ToolsCollection', (): void => { .from( collection.blockTools.values() ) - .every((tool: BlockTool) => tool.isBlock()) + .every((tool: BlockToolAdapter) => tool.isBlock()) ).to.be.true; }); }); @@ -105,7 +105,7 @@ describe('ToolsCollection', (): void => { .from( collection.inlineTools.values() ) - .every((tool: InlineTool) => tool.isInline()) + .every((tool: InlineToolAdapter) => tool.isInline()) ).to.be.true; }); }); @@ -121,7 +121,7 @@ describe('ToolsCollection', (): void => { .from( collection.blockTunes.values() ) - .every((tool: BlockTune) => tool.isTune()) + .every((tool: BlockTuneAdapter) => tool.isTune()) ).to.be.true; }); }); @@ -137,7 +137,7 @@ describe('ToolsCollection', (): void => { .from( collection.internalTools.values() ) - .every((tool: BaseTool) => tool.isInternal) + .every((tool: BaseToolAdapter) => tool.isInternal) ).to.be.true; }); }); @@ -153,7 +153,7 @@ describe('ToolsCollection', (): void => { .from( collection.externalTools.values() ) - .every((tool: BaseTool) => !tool.isInternal) + .every((tool: BaseToolAdapter) => !tool.isInternal) ).to.be.true; }); }); @@ -166,7 +166,7 @@ describe('ToolsCollection', (): void => { .from( collection.blockTunes.internalTools.values() ) - .every((tool: BlockTune) => tool.isTune() && tool.isInternal) + .every((tool: BlockTuneAdapter) => tool.isTune() && tool.isInternal) ).to.be.true; }); }); @@ -178,7 +178,7 @@ describe('ToolsCollection', (): void => { .from( collection.externalTools.blockTools.values() ) - .every((tool: BlockTool) => tool.isBlock() && !tool.isInternal) + .every((tool: BlockToolAdapter) => tool.isBlock() && !tool.isInternal) ).to.be.true; }); }); diff --git a/test/cypress/tests/tools/ToolsFactory.cy.ts b/test/cypress/tests/tools/ToolsFactory.cy.ts index a645c7366..6bb5aed98 100644 --- a/test/cypress/tests/tools/ToolsFactory.cy.ts +++ b/test/cypress/tests/tools/ToolsFactory.cy.ts @@ -2,9 +2,9 @@ import LinkInlineTool from '../../../../src/components/inline-tools/inline-tool-link'; import MoveUpTune from '../../../../src/components/block-tunes/block-tune-move-up'; import ToolsFactory from '../../../../src/components/tools/factory'; -import InlineTool from '../../../../src/components/tools/inline'; -import BlockTool from '../../../../src/components/tools/block'; -import BlockTune from '../../../../src/components/tools/tune'; +import InlineToolAdapter from '../../../../src/components/tools/inline'; +import BlockToolAdapter from '../../../../src/components/tools/block'; +import BlockTuneAdapter from '../../../../src/components/tools/tune'; import Paragraph from '@editorjs/paragraph'; describe('ToolsFactory', (): void => { @@ -49,19 +49,19 @@ describe('ToolsFactory', (): void => { it('should return InlineTool object for inline tool', (): void => { const tool = factory.get('link'); - expect(tool instanceof InlineTool).to.be.true; + expect(tool instanceof InlineToolAdapter).to.be.true; }); it('should return BlockTool object for block tool', (): void => { const tool = factory.get('paragraph'); - expect(tool instanceof BlockTool).to.be.true; + expect(tool instanceof BlockToolAdapter).to.be.true; }); it('should return BlockTune object for tune', (): void => { const tool = factory.get('moveUp'); - expect(tool instanceof BlockTune).to.be.true; + expect(tool instanceof BlockTuneAdapter).to.be.true; }); }); }); diff --git a/test/cypress/tests/ui/BlockTunes.cy.ts b/test/cypress/tests/ui/BlockTunes.cy.ts index fddbf7332..b5f39c076 100644 --- a/test/cypress/tests/ui/BlockTunes.cy.ts +++ b/test/cypress/tests/ui/BlockTunes.cy.ts @@ -1,7 +1,7 @@ import { selectionChangeDebounceTimeout } from '../../../../src/components/constants'; import Header from '@editorjs/header'; -import { ToolboxConfig } from '../../../../types'; -import { MenuConfig } from '../../../../types/tools'; +import type { ToolboxConfig } from '../../../../types'; +import type { MenuConfig } from '../../../../types/tools'; describe('BlockTunes', function () { diff --git a/test/cypress/tests/ui/InlineToolbar.cy.ts b/test/cypress/tests/ui/InlineToolbar.cy.ts index 1b243cfb4..eca588172 100644 --- a/test/cypress/tests/ui/InlineToolbar.cy.ts +++ b/test/cypress/tests/ui/InlineToolbar.cy.ts @@ -1,6 +1,6 @@ import Header from '@editorjs/header'; -import { MenuConfig } from '../../../../types/tools'; +import type { MenuConfig } from '../../../../types/tools'; describe('Inline Toolbar', () => { describe('Separators', () => { diff --git a/test/cypress/tests/ui/toolbox.cy.ts b/test/cypress/tests/ui/toolbox.cy.ts index ca4da3a9e..d6d1ade63 100644 --- a/test/cypress/tests/ui/toolbox.cy.ts +++ b/test/cypress/tests/ui/toolbox.cy.ts @@ -1,5 +1,5 @@ import type EditorJS from '../../../../types/index'; -import { ConversionConfig, ToolboxConfig } from '../../../../types/index'; +import type { ConversionConfig, ToolboxConfig } from '../../../../types/index'; import ToolMock from '../../fixtures/tools/ToolMock'; describe('Toolbox', function () { diff --git a/test/cypress/tests/utils/flipper.cy.ts b/test/cypress/tests/utils/flipper.cy.ts index 1a91d81c3..09be68153 100644 --- a/test/cypress/tests/utils/flipper.cy.ts +++ b/test/cypress/tests/utils/flipper.cy.ts @@ -1,4 +1,4 @@ -import { PopoverItemParams } from '../../../../types/index.js'; +import type { PopoverItemParams } from '../../../../types/index.js'; /** * Mock of some Block Tool diff --git a/test/cypress/tests/utils/popover.cy.ts b/test/cypress/tests/utils/popover.cy.ts index 748747ca1..28ae3001f 100644 --- a/test/cypress/tests/utils/popover.cy.ts +++ b/test/cypress/tests/utils/popover.cy.ts @@ -1,6 +1,6 @@ import { PopoverDesktop as Popover, PopoverItemType } from '../../../../src/components/utils/popover'; -import { PopoverItemParams } from '../../../../types'; -import { MenuConfig } from '../../../../types/tools'; +import type { PopoverItemParams } from '@/types/utils/popover'; +import type { MenuConfig } from '../../../../types/tools'; import Header from '@editorjs/header'; /* eslint-disable @typescript-eslint/no-empty-function */ diff --git a/test/cypress/tsconfig.json b/test/cypress/tsconfig.json index 4d48eb0fb..7ccaeff75 100644 --- a/test/cypress/tsconfig.json +++ b/test/cypress/tsconfig.json @@ -1,13 +1,9 @@ { - "compilerOptions": { - "target": "es2017", - "lib": ["dom", "es2017", "es2018", "es2019"], - "moduleResolution": "node", - "resolveJsonModule": true, - "allowSyntheticDefaultImports": true, - "experimentalDecorators": true - }, - "include": [ - "../../**/*.ts" - ] - } + "extends": "../../tsconfig.json", + "compilerOptions": { + "types": ["cypress", "node"], + }, + "include": [ + "**/*.ts" + ] +} diff --git a/tsconfig.build.json b/tsconfig.build.json index 27722617f..3eaa0be45 100644 --- a/tsconfig.build.json +++ b/tsconfig.build.json @@ -1,4 +1,4 @@ { "extends": "./tsconfig.json", - "exclude": ["test"] + "exclude": [ "test" ], } diff --git a/tsconfig.json b/tsconfig.json index c4e387d99..6025fa123 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,5 +1,6 @@ { "compilerOptions" : { + "strict": true, "sourceMap": true, "target": "es2017", "declaration": false, @@ -11,6 +12,15 @@ // allows to omit export default in .json files "allowSyntheticDefaultImports": true, - "experimentalDecorators": true - } + "experimentalDecorators": true, + "baseUrl": "./", + "paths": { + "@/types": [ "./types/" ], + "@/types/*": [ "./types/*" ], + }, + + // @todo move to cypress/tsconfig.json when cypress will support overriding tsconfig path + // @see https://github.com/cypress-io/cypress/issues/23045 + "esModuleInterop": true + }, } diff --git a/types/api/blocks.d.ts b/types/api/blocks.d.ts index 7b9a0455e..f5957bbac 100644 --- a/types/api/blocks.d.ts +++ b/types/api/blocks.d.ts @@ -1,4 +1,3 @@ -import Block from '../../src/components/block'; import {OutputBlockData, OutputData} from '../data-formats/output-data'; import {BlockToolData, ToolConfig} from '../tools'; import {BlockAPI} from './block'; diff --git a/types/api/tools.d.ts b/types/api/tools.d.ts index c578451f7..3363c4a81 100644 --- a/types/api/tools.d.ts +++ b/types/api/tools.d.ts @@ -1,4 +1,4 @@ -import BlockTool from "../../src/components/tools/block"; +import { BlockToolAdapter } from '@/types/tools/adapters/block-tool-adapter'; /** * Describes methods for accessing installed Editor tools @@ -7,5 +7,5 @@ export interface Tools { /** * Returns all available Block Tools */ - getBlockTools(): BlockTool[]; + getBlockTools(): BlockToolAdapter[]; } diff --git a/types/block-tunes/block-tune.d.ts b/types/block-tunes/block-tune.d.ts index 9ef43d306..2220a4780 100644 --- a/types/block-tunes/block-tune.d.ts +++ b/types/block-tunes/block-tune.d.ts @@ -8,7 +8,8 @@ import { MenuConfig } from '../tools'; export interface BlockTune { /** * Returns BlockTune's UI. - * Either HTMLELement (@deprecated) or MenuConfig (@see https://editorjs.io/menu-config/) + * Should return either MenuConfig (recommended) (@see https://editorjs.io/menu-config/) + * or HTMLElement (UI consitency is not guaranteed) */ render(): HTMLElement | MenuConfig; @@ -18,8 +19,6 @@ export interface BlockTune { * You can wrap Tool's content with any wrapper you want to provide Tune's UI * * @param {HTMLElement} pluginsContent — Tool's content wrapper - * - * @return {HTMLElement} */ wrap?(pluginsContent: HTMLElement): HTMLElement; diff --git a/types/configs/index.d.ts b/types/configs/index.d.ts index 4468fca9a..20723a1db 100644 --- a/types/configs/index.d.ts +++ b/types/configs/index.d.ts @@ -5,4 +5,3 @@ export * from './conversion-config'; export * from './log-levels'; export * from './i18n-config'; export * from './i18n-dictionary'; -export * from '../../src/components/utils/popover'; diff --git a/types/index.d.ts b/types/index.d.ts index 1a7e83bf0..66f0eb38c 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -80,10 +80,7 @@ export { I18nConfig, } from './configs'; -export { - PopoverItemParams, - PopoverItemDefaultParams, -} from '../src/components/utils/popover'; +export * from './utils/popover'; export { OutputData, OutputBlockData} from './data-formats/output-data'; export { BlockId } from './data-formats/block-id'; diff --git a/types/tools/adapters/base-tool-adapter.d.ts b/types/tools/adapters/base-tool-adapter.d.ts new file mode 100644 index 000000000..761d71336 --- /dev/null +++ b/types/tools/adapters/base-tool-adapter.d.ts @@ -0,0 +1,76 @@ +import { Tool, ToolSettings } from '..'; +import type { SanitizerConfig } from '../..'; + +import { ToolType } from './tool-type'; +import { InlineToolAdapter } from './inline-tool-adapter'; +import { BlockToolAdapter } from './block-tool-adapter'; +import { BlockTuneAdapter } from './block-tune-adapter'; + +export interface BaseToolAdapter { + /** + * Tool type: Block, Inline or Tune + */ + type: Type; + + /** + * Tool name specified in EditorJS config + */ + name: string; + + /** + * Flag show is current Tool internal (bundled with EditorJS core) or not + */ + readonly isInternal: boolean; + + /** + * Flag show is current Tool default or not + */ + readonly isDefault: boolean; + + /** + * Returns Tool user configuration + */ + settings: ToolSettings; + + /** + * Calls Tool's reset method + */ + reset(): void | Promise; + + /** + * Calls Tool's prepare method + */ + prepare(): void | Promise; + + /** + * Returns shortcut for Tool (internal or specified by user) + */ + shortcut: string | undefined; + + /** + * Returns Tool's sanitizer configuration + */ + sanitizeConfig: SanitizerConfig; + + /** + * Returns true if Tools is inline + */ + isInline(): this is InlineToolAdapter; + + /** + * Returns true if Tools is block + */ + isBlock(): this is BlockToolAdapter; + + /** + * Returns true if Tools is tune + */ + isTune(): this is BlockTuneAdapter; + + /** + * Constructs new Tool instance from constructable blueprint + * + * @param args + */ + create(...args: any[]): ToolClass; +} diff --git a/types/tools/adapters/block-tool-adapter.d.ts b/types/tools/adapters/block-tool-adapter.d.ts new file mode 100644 index 000000000..3b37a2433 --- /dev/null +++ b/types/tools/adapters/block-tool-adapter.d.ts @@ -0,0 +1,78 @@ +import { ToolsCollection } from './tools-collection'; +import { ToolType } from './tool-type'; +import { InlineToolAdapter } from './inline-tool-adapter'; +import { BlockTuneAdapter } from './block-tune-adapter'; +import { BlockTool } from '../block-tool'; +import { BlockToolData } from '../block-tool-data'; +import { BlockAPI } from '../../api/block'; +import { ToolboxConfigEntry } from '../tool-settings'; +import { ConversionConfig } from '../../configs/conversion-config'; +import { PasteConfig } from '../../configs/paste-config'; +import { SanitizerConfig } from '../../configs/sanitizer-config'; +import { BaseToolAdapter } from './base-tool-adapter'; + +interface BlockToolAdapter extends BaseToolAdapter{ + /** + * InlineTool collection for current Block Tool + */ + inlineTools: ToolsCollection; + + /** + * BlockTune collection for current Block Tool + */ + tunes: ToolsCollection; + + /** + * Creates new Tool instance + * @param data - Tool data + * @param block - BlockAPI for current Block + * @param readOnly - True if Editor is in read-only mode + */ + create(data: BlockToolData, block: BlockAPI, readOnly: boolean): BlockTool; + + /** + * Returns true if read-only mode is supported by Tool + */ + isReadOnlySupported: boolean; + + /** + * Returns true if Tool supports linebreaks + */ + isLineBreaksEnabled: boolean; + + /** + * Returns Tool toolbox configuration (internal or user-specified) + */ + toolbox: ToolboxConfigEntry[] | undefined; + + /** + * Returns Tool conversion configuration + */ + conversionConfig: ConversionConfig | undefined; + + /** + * Returns enabled inline tools for Tool + */ + enabledInlineTools: boolean | string[]; + + /** + * Returns enabled tunes for Tool + */ + enabledBlockTunes: boolean | string[]; + + /** + * Returns Tool paste configuration + */ + pasteConfig: PasteConfig; + + /** + * Returns sanitize configuration for Block Tool including configs from related Inline Tools and Block Tunes + */ + sanitizeConfig: SanitizerConfig; + + /** + * Returns sanitizer configuration composed from sanitize config of Inline Tools enabled for Tool + */ + baseSanitizeConfig: SanitizerConfig; +} + diff --git a/types/tools/adapters/block-tune-adapter.d.ts b/types/tools/adapters/block-tune-adapter.d.ts new file mode 100644 index 000000000..880f8264e --- /dev/null +++ b/types/tools/adapters/block-tune-adapter.d.ts @@ -0,0 +1,14 @@ +import { BlockAPI, BlockTune } from '../..'; +import { BlockTuneData } from '../../block-tunes/block-tune-data'; +import { BaseToolAdapter } from './base-tool-adapter'; +import { ToolType } from './tool-type'; + +interface BlockTuneAdapter extends BaseToolAdapter { + /** + * Constructs new BlockTune instance from constructable + * + * @param data - Tune data + * @param block - Block API object + */ + create(data: BlockTuneData, block: BlockAPI): BlockTune; +} diff --git a/types/tools/adapters/inline-tool-adapter.d.ts b/types/tools/adapters/inline-tool-adapter.d.ts new file mode 100644 index 000000000..6c55f1c76 --- /dev/null +++ b/types/tools/adapters/inline-tool-adapter.d.ts @@ -0,0 +1,15 @@ +import { InlineTool as IInlineTool, InlineTool } from '../..'; +import { BaseToolAdapter } from './base-tool-adapter'; +import { ToolType } from './tool-type'; + +interface InlineToolAdapter extends BaseToolAdapter { + /** + * Returns title for Inline Tool if specified by user + */ + title: string; + + /** + * Constructs new InlineTool instance from constructable + */ + create(): IInlineTool; +} diff --git a/types/tools/adapters/tool-factory.d.ts b/types/tools/adapters/tool-factory.d.ts new file mode 100644 index 000000000..9e7082794 --- /dev/null +++ b/types/tools/adapters/tool-factory.d.ts @@ -0,0 +1,5 @@ +import { BlockToolAdapter } from './block-tool-adapter'; +import { BlockTuneAdapter } from './block-tune-adapter'; +import { InlineToolAdapter } from './inline-tool-adapter'; + +export type ToolFactory = BlockToolAdapter | InlineToolAdapter | BlockTuneAdapter; diff --git a/types/tools/adapters/tool-type.ts b/types/tools/adapters/tool-type.ts new file mode 100644 index 000000000..adef96d34 --- /dev/null +++ b/types/tools/adapters/tool-type.ts @@ -0,0 +1,18 @@ +/** + * What kind of plugins developers can create + */ +export enum ToolType { + /** + * Block tool + */ + Block, + /** + * Inline tool + */ + Inline, + + /** + * Block tune + */ + Tune, +} diff --git a/types/tools/adapters/tools-collection.d.ts b/types/tools/adapters/tools-collection.d.ts new file mode 100644 index 000000000..273c93866 --- /dev/null +++ b/types/tools/adapters/tools-collection.d.ts @@ -0,0 +1,34 @@ +import { BlockToolAdapter } from './block-tool-adapter'; +import { BlockTuneAdapter } from './block-tune-adapter'; +import { InlineToolAdapter } from './inline-tool-adapter'; +import { ToolFactory } from './tool-factory'; + +/** + * Interface for a collection of tools. + */ +export interface ToolsCollection { + /** + * Returns Block Tools collection + */ + blockTools: ToolsCollection; + + /** + * Returns Inline Tools collection + */ + inlineTools: ToolsCollection; + + /** + * Returns Block Tunes collection + */ + blockTunes: ToolsCollection; + + /** + * Returns internal Tools collection + */ + internalTools: ToolsCollection; + + /** + * Returns Tools collection provided by user + */ + externalTools: ToolsCollection; +} diff --git a/src/components/utils/popover/components/hint/hint.types.ts b/types/utils/popover/hint.d.ts similarity index 100% rename from src/components/utils/popover/components/hint/hint.types.ts rename to types/utils/popover/hint.d.ts diff --git a/types/utils/popover/index.d.ts b/types/utils/popover/index.d.ts new file mode 100644 index 000000000..9f3172f51 --- /dev/null +++ b/types/utils/popover/index.d.ts @@ -0,0 +1,5 @@ +export type * from './hint'; +export type * from './popover-item'; +export * from './popover-item-type'; +export type * from './popover'; +export * from './popover-event'; diff --git a/types/utils/popover/popover-event.ts b/types/utils/popover/popover-event.ts new file mode 100644 index 000000000..2e74dbc03 --- /dev/null +++ b/types/utils/popover/popover-event.ts @@ -0,0 +1,15 @@ + +/** + * Event that can be triggered by the Popover + */ +export enum PopoverEvent { + /** + * When popover closes + */ + Closed = 'closed', + + /** + * When it closes because item with 'closeOnActivate' property set was clicked + */ + ClosedOnActivate = 'closed-on-activate', +} diff --git a/types/utils/popover/popover-item-type.ts b/types/utils/popover/popover-item-type.ts new file mode 100644 index 000000000..e26d3722d --- /dev/null +++ b/types/utils/popover/popover-item-type.ts @@ -0,0 +1,13 @@ +/** + * Popover item types + */ +export enum PopoverItemType { + /** Regular item with icon, title and other properties */ + Default = 'default', + + /** Gray line used to separate items from each other */ + Separator = 'separator', + + /** Item with custom html content */ + Html = 'html' +} diff --git a/src/components/utils/popover/components/popover-item/popover-item.types.ts b/types/utils/popover/popover-item.d.ts similarity index 93% rename from src/components/utils/popover/components/popover-item/popover-item.types.ts rename to types/utils/popover/popover-item.d.ts index 9f7a64011..3957fdae0 100644 --- a/src/components/utils/popover/components/popover-item/popover-item.types.ts +++ b/types/utils/popover/popover-item.d.ts @@ -1,18 +1,7 @@ -import { HintTextAlignment, HintParams, HintPosition } from '../hint'; +import { HintParams, HintPosition, HintTextAlignment } from "./hint"; +import { PopoverItemType } from "./popover-item-type"; -/** - * Popover item types - */ -export enum PopoverItemType { - /** Regular item with icon, title and other properties */ - Default = 'default', - - /** Gray line used to separate items from each other */ - Separator = 'separator', - - /** Item with custom html content */ - Html = 'html' -} +export { PopoverItemType } from './popover-item-type'; /** * Represents popover item children configuration diff --git a/src/components/utils/popover/popover.types.ts b/types/utils/popover/popover.d.ts similarity index 85% rename from src/components/utils/popover/popover.types.ts rename to types/utils/popover/popover.d.ts index 0af9a11f1..a42641f94 100644 --- a/src/components/utils/popover/popover.types.ts +++ b/types/utils/popover/popover.d.ts @@ -1,4 +1,5 @@ -import { PopoverItemParams } from '../../../../types'; +import { PopoverItemParams } from './popover-item'; +import { PopoverEvent } from './popover-event'; /** * Params required to render popover @@ -54,20 +55,6 @@ export interface PopoverMessages { search?: string } -/** - * Event that can be triggered by the Popover - */ -export enum PopoverEvent { - /** - * When popover closes - */ - Closed = 'closed', - - /** - * When it closes because item with 'closeOnActivate' property set was clicked - */ - ClosedOnActivate = 'closed-on-activate', -} /** * Events fired by the Popover diff --git a/vite.config.js b/vite.config.js index 63c4ca9d1..98bc3c261 100644 --- a/vite.config.js +++ b/vite.config.js @@ -57,6 +57,12 @@ export default { 'VERSION': JSON.stringify(VERSION), }, + resolve: { + alias: { + '@/types': path.resolve(__dirname, './types'), + }, + }, + server: { port: 3303, open: true, diff --git a/vite.config.test.js b/vite.config.test.js new file mode 100644 index 000000000..a053f5805 --- /dev/null +++ b/vite.config.test.js @@ -0,0 +1,18 @@ +import path from 'path'; +import { defineConfig } from 'vite'; + +export default defineConfig({ + build: { + minify: false, + sourcemap: true, + }, + define: { + 'NODE_ENV': JSON.stringify('test'), + 'VERSION': JSON.stringify('test-version'), + }, + resolve: { + alias: { + '@/types': path.resolve(__dirname, './types'), + }, + }, +}); diff --git a/yarn.lock b/yarn.lock index df7d4b53a..f616c23e2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -207,6 +207,11 @@ "@babel/helper-validator-identifier" "^7.19.1" to-fast-properties "^2.0.0" +"@codexteam/icons@0.3.2": + version "0.3.2" + resolved "https://registry.yarnpkg.com/@codexteam/icons/-/icons-0.3.2.tgz#b7aed0ba7b344e07953101f5476cded570d4f150" + integrity sha512-P1ep2fHoy0tv4wx85eic+uee5plDnZQ1Qa6gDfv7eHPkCXorMtVqJhzMb75o1izogh6G7380PqmFDXV3bW3Pig== + "@codexteam/icons@^0.0.4": version "0.0.4" resolved "https://registry.yarnpkg.com/@codexteam/icons/-/icons-0.0.4.tgz#8b72dcd3f3a1b0d880bdceb2abebd74b46d3ae13" @@ -222,11 +227,6 @@ resolved "https://registry.yarnpkg.com/@codexteam/icons/-/icons-0.0.6.tgz#5553ada48dddf5940851ccc142cfe17835c36ad3" integrity sha512-L7Q5PET8PjKcBT5wp7VR+FCjwCi5PUp7rd/XjsgQ0CI5FJz0DphyHGRILMuDUdCW2MQT9NHbVr4QP31vwAkS/A== -"@codexteam/icons@^0.3.0": - version "0.3.0" - resolved "https://registry.yarnpkg.com/@codexteam/icons/-/icons-0.3.0.tgz#62380b4053d487a257de443864b5c72dafab95e6" - integrity sha512-fJE9dfFdgq8xU+sbsxjH0Kt8Yeatw9xHBJWb77DhRkEXz3OCoIS6hrRC1ewHEryxzIjxD8IyQrRq2f+Gz3BcmA== - "@codexteam/shortcuts@^1.1.1": version "1.2.0" resolved "https://registry.yarnpkg.com/@codexteam/shortcuts/-/shortcuts-1.2.0.tgz#b8dd7396962b0bd845a5c8f8f19bc6119b520e19" @@ -564,12 +564,18 @@ dependencies: "@codexteam/icons" "^0.0.5" -"@editorjs/header@^2.7.0": - version "2.7.0" - resolved "https://registry.yarnpkg.com/@editorjs/header/-/header-2.7.0.tgz#755d104a9210a8e2d9ccf22b175b2a93bdbb2330" - integrity sha512-4fGKGe2ZYblVqR/P/iw5ieG00uXInFgNMftBMqJRYcB2hUPD30kuu7Sn6eJDcLXoKUMOeqi8Z2AlUxYAmvw7zQ== +"@editorjs/editorjs@^2.29.1": + version "2.30.2" + resolved "https://registry.yarnpkg.com/@editorjs/editorjs/-/editorjs-2.30.2.tgz#b045af18a9ebe0c02cb32be41b2a98e23ee08e59" + integrity sha512-JjtUDs2/aHTEjNZzEf/2cugpIli1+aNeU8mloOd5USbVxv2vC02HTMpv7Vc1UyB7dIuc45JaYSJwgnBZp9duhA== + +"@editorjs/header@^2.8.7": + version "2.8.7" + resolved "https://registry.yarnpkg.com/@editorjs/header/-/header-2.8.7.tgz#6aa34e01638d18fbbc6d3bd75f1844869eca9193" + integrity sha512-rfxzYFR/Jhaocj3Xxx8XjEjyzfPbBIVkcPZ9Uy3rEz1n3ewhV0V4zwuxCjVfFhLUVgQQExq43BxJnTNlLOzqDQ== dependencies: "@codexteam/icons" "^0.0.5" + "@editorjs/editorjs" "^2.29.1" "@editorjs/paragraph@^2.11.6": version "2.11.6"