fix(types): tools export types added (#2802)

* fix types export

* lint

* changelog

* tests fixed

* fix tests imports

* lint tests

* upd submodule

* Update yarn.lock

* rename wrapper to factory

* Update package.json

* rename to adapters

* Update tools.d.ts

* BlockTool -> BlockToolAdapter etc

* Update nested-list

* Update collection.ts
This commit is contained in:
Peter 2024-08-09 18:04:57 +03:00 committed by GitHub
commit 3d01be4a69
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
131 changed files with 776 additions and 471 deletions

View file

@ -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"],
}
}
]
}

View file

@ -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',

View file

@ -1,5 +1,9 @@
# Changelog
### 2.30.4
- `Fix` - Tool's exporting types added
### 2.30.3
- `Fix`  I18n in nested popover

@ -1 +1 @@
Subproject commit 95b37462dc93c19b83f0481f509034a40d436cf2
Subproject commit 591bd2ca6839f923e3d37a1ebaad6e5d15075a89

@ -1 +1 @@
Subproject commit a80eefb4007c85a52085897398dd28afc5bfd81f
Subproject commit 7f51a16d4ab46eff9364f09cea52e09518896d2a

View file

@ -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",

View file

@ -1,6 +1,6 @@
'use strict';
import { EditorConfig } from '../types';
import type { EditorConfig } from '../types';
/**
* Apply polyfills

View file

@ -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 <T> of the Module generic.

View file

@ -3,9 +3,9 @@
* @classdesc Editor's default tune that moves up selected block
* @copyright <CodeX Team> 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';
/**
*

View file

@ -4,9 +4,9 @@
* @copyright <CodeX Team> 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';
/**

View file

@ -3,9 +3,9 @@
* @classdesc Editor's default tune that moves up selected block
* @copyright <CodeX Team> 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';
/**
*

View file

@ -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

View file

@ -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<BlockEvents> {
/**
* 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<BlockEvents> {
/**
* Tunes used by Tool
*/
public readonly tunes: ToolsCollection<BlockTune>;
public readonly tunes: ToolsCollection<BlockTuneAdapter>;
/**
* Tool's user configuration
@ -233,7 +234,7 @@ export default class Block extends EventsDispatcher<BlockEvents> {
this.toolInstance = tool.create(data, this.blockAPI, readOnly);
/**
* @type {BlockTune[]}
* @type {BlockTuneAdapter[]}
*/
this.tunes = tool.tunes;

View file

@ -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

View file

@ -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.

View file

@ -1,4 +1,4 @@
import { BlockMutationEvent } from '../../../types/events/block';
import type { BlockMutationEvent } from '../../../types/events/block';
/**
* Fired when some block state has changed

View file

@ -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

View file

@ -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

View file

@ -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';
/**

View file

@ -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

View file

@ -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';

View file

@ -1,4 +1,4 @@
import { InlineTool, SanitizerConfig } from '../../../types';
import type { InlineTool, SanitizerConfig } from '../../../types';
import { IconItalic } from '@codexteam/icons';
/**

View file

@ -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';
/**

View file

@ -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

View file

@ -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';

View file

@ -1,5 +1,5 @@
import Module from '../../__module';
import { Events } from '../../../../types/api';
import type { Events } from '../../../../types/api';
/**
* @class EventsAPI

View file

@ -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';

View file

@ -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

View file

@ -1,4 +1,4 @@
import { InlineToolbar } from '../../../../types/api/inline-toolbar';
import type { InlineToolbar } from '../../../../types/api/inline-toolbar';
import Module from '../../__module';
/**

View file

@ -1,4 +1,4 @@
import { Listeners } from '../../../../types/api';
import type { Listeners } from '../../../../types/api';
import Module from '../../__module';
/**

View file

@ -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';
/**
*

View file

@ -1,4 +1,4 @@
import { ReadOnly } from '../../../../types/api';
import type { ReadOnly } from '../../../../types/api';
import Module from '../../__module';
/**

View file

@ -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';

View file

@ -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';

View file

@ -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';
/**

View file

@ -1,4 +1,4 @@
import { Styles } from '../../../../types/api';
import type { Styles } from '../../../../types/api';
import Module from '../../__module';
/**

View file

@ -1,4 +1,4 @@
import { Toolbar } from '../../../../types/api';
import type { Toolbar } from '../../../../types/api';
import Module from '../../__module';
import * as _ from './../../utils';
/**

View file

@ -1,4 +1,4 @@
import { Tools as ToolsAPIInterface } from '../../../../types/api';
import type { Tools as ToolsAPIInterface } from '../../../../types/api';
import Module from '../../__module';
/**

View file

@ -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

View file

@ -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

View file

@ -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';

View file

@ -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';
/**

View file

@ -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';

View file

@ -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';

View file

@ -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';

View file

@ -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 ||

View file

@ -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;

View file

@ -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';

View file

@ -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';

View file

@ -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';

View file

@ -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';
/**

View file

@ -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<InlineTool> {
public get inlineTools(): ToolsCollection<InlineToolAdapter> {
return this.available.inlineTools;
}
/**
* Return editor block tools
*/
public get blockTools(): ToolsCollection<BlockTool> {
public get blockTools(): ToolsCollection<BlockToolAdapter> {
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<BlockTune> {
public get blockTunes(): ToolsCollection<BlockTuneAdapter> {
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<InlineTool>(
tool.inlineTools = new ToolsCollection<InlineToolAdapter>(
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<InlineTool>(
tool.inlineTools = new ToolsCollection<InlineToolAdapter>(
/** 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<BlockTune>(
const userTunes = new ToolsCollection<BlockTuneAdapter>(
tool.enabledBlockTunes.map(name => [name, this.blockTunes.get(name)])
);
tool.tunes = new ToolsCollection<BlockTune>([...userTunes, ...this.blockTunes.internalTools]);
tool.tunes = new ToolsCollection<BlockTuneAdapter>([...userTunes, ...this.blockTunes.internalTools]);
return;
}
if (Array.isArray(this.config.tunes)) {
const userTunes = new ToolsCollection<BlockTune>(
const userTunes = new ToolsCollection<BlockTuneAdapter>(
this.config.tunes.map(name => [name, this.blockTunes.get(name)])
);
tool.tunes = new ToolsCollection<BlockTune>([...userTunes, ...this.blockTunes.internalTools]);
tool.tunes = new ToolsCollection<BlockTuneAdapter>([...userTunes, ...this.blockTunes.internalTools]);
return;
}

View file

@ -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<Type extends Tool = Tool> {
export default abstract class BaseToolAdapter<Type extends ToolType = ToolType, ToolClass extends Tool = Tool> implements BaseToolAdapterInterface<ToolType, Tool> {
/**
* 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<Type extends Tool = Tool> {
/**
* 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<Type extends Tool = Tool> {
* @param args
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
public abstract create(...args: any[]): Type;
public abstract create(...args: any[]): ToolClass;
}

View file

@ -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<IBlockTool> {
export default class BlockToolAdapter extends BaseToolAdapter<ToolType.Block, IBlockTool> implements BlockToolAdapterInterface {
/**
* Tool type Block
*/
public type = ToolType.Block;
public type: ToolType.Block = ToolType.Block;
/**
* InlineTool collection for current Block Tool
*/
public inlineTools: ToolsCollection<InlineTool> = new ToolsCollection<InlineTool>();
public inlineTools: ToolsCollection<InlineToolAdapter> = new ToolsCollection<InlineToolAdapter>();
/**
* BlockTune collection for current Block Tool
*/
public tunes: ToolsCollection<BlockTune> = new ToolsCollection<BlockTune>();
public tunes: ToolsCollection<BlockTuneAdapter> = new ToolsCollection<BlockTuneAdapter>();
/**
* Tool's constructable blueprint

View file

@ -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<V extends ToolClass = ToolClass> extends Map<string, V> {
export default class ToolsCollection<V extends ToolClass = ToolClass> extends Map<string, V> implements ToolsCollectionInterface<V> {
/**
* Returns Block Tools collection
*/
public get blockTools(): ToolsCollection<BlockTool> {
public get blockTools(): ToolsCollection<BlockToolAdapter> {
const tools = Array
.from(this.entries())
.filter(([, tool]) => tool.isBlock()) as [string, BlockTool][];
.filter(([, tool]) => tool.isBlock()) as [string, BlockToolAdapter][];
return new ToolsCollection<BlockTool>(tools);
return new ToolsCollection<BlockToolAdapter>(tools);
}
/**
* Returns Inline Tools collection
*/
public get inlineTools(): ToolsCollection<InlineTool> {
public get inlineTools(): ToolsCollection<InlineToolAdapter> {
const tools = Array
.from(this.entries())
.filter(([, tool]) => tool.isInline()) as [string, InlineTool][];
.filter(([, tool]) => tool.isInline()) as [string, InlineToolAdapter][];
return new ToolsCollection<InlineTool>(tools);
return new ToolsCollection<InlineToolAdapter>(tools);
}
/**
* Returns Block Tunes collection
*/
public get blockTunes(): ToolsCollection<BlockTune> {
public get blockTunes(): ToolsCollection<BlockTuneAdapter> {
const tools = Array
.from(this.entries())
.filter(([, tool]) => tool.isTune()) as [string, BlockTune][];
.filter(([, tool]) => tool.isTune()) as [string, BlockTuneAdapter][];
return new ToolsCollection<BlockTune>(tools);
return new ToolsCollection<BlockTuneAdapter>(tools);
}
/**

View file

@ -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;
}
}
}

View file

@ -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<IInlineTool> {
export default class InlineToolAdapter extends BaseToolAdapter<ToolType.Inline, IInlineTool> implements InlineToolAdapterInterface {
/**
* Tool type Inline
*/
public type = ToolType.Inline;
public type: ToolType.Inline = ToolType.Inline;
/**
* Tool's constructable blueprint

View file

@ -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<IBlockTune> {
export default class BlockTuneAdapter extends BaseToolAdapter<ToolType.Tune, IBlockTune> implements BlockTuneAdapterInterface {
/**
* Tool type Tune
*/
public type = ToolType.Tune;
public type: ToolType.Tune = ToolType.Tune;
/**
* Tool's constructable blueprint

View file

@ -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<ToolboxEventMap> {
/**
* List of Tools available. Some of them will be shown in the Toolbox
*/
private tools: ToolsCollection<BlockTool>;
private tools: ToolsCollection<BlockToolAdapter>;
/**
* Text labels used in the Toolbox. Should be passed from the i18n module
@ -130,7 +131,7 @@ export default class Toolbox extends EventsDispatcher<ToolboxEventMap> {
* @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<BlockTool>; i18nLabels: Record<ToolboxTextLabelsKeys, string>}) {
constructor({ api, tools, i18nLabels }: {api: API; tools: ToolsCollection<BlockToolAdapter>; i18nLabels: Record<ToolboxTextLabelsKeys, string>}) {
super();
this.api = api;
@ -285,8 +286,8 @@ export default class Toolbox extends EventsDispatcher<ToolboxEventMap> {
* 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<ToolboxEventMap> {
/**
* 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<ToolboxEventMap> {
* 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<ToolboxEventMap> {
* 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) {

View file

@ -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

View file

@ -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<BlockTool[]> {
export async function getConvertibleToolsForBlock(block: BlockAPI, allBlockTools: BlockToolAdapter[]): Promise<BlockToolAdapter[]> {
const savedData = await block.save() as SavedData;
const blockData = savedData.data;

View file

@ -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

View file

@ -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';

View file

@ -1,2 +1,6 @@
export * from './hint';
export * from './hint.types';
export type {
HintParams,
HintPosition,
HintTextAlignment
} from '@/types/utils/popover/hint';

View file

@ -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';

View file

@ -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,

View file

@ -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';

View file

@ -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';

View file

@ -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

View file

@ -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';

View file

@ -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

View file

@ -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';
/**

View file

@ -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';

View file

@ -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;

View file

@ -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';

View file

@ -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 [];
}

View file

@ -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

View file

@ -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;
}

View file

@ -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 {

View file

@ -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

View file

@ -1,4 +1,4 @@
import {
import type {
BaseTool,
BlockToolConstructorOptions,
BlockToolData,

View file

@ -1,4 +1,4 @@
import { BlockTool, BlockToolConstructorOptions } from '../../../../types';
import type { BlockTool, BlockToolConstructorOptions } from '../../../../types';
/**
* Simple structure for Tool data

View file

@ -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

View file

@ -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;
};

View file

@ -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

View file

@ -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';

View file

@ -1,4 +1,4 @@
import EditorJS from '../../../../types';
import type EditorJS from '../../../../types';
import { BlockChangedMutationType } from '../../../../types/events/block/BlockChanged';
/**

View file

@ -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;
}

View file

@ -1,4 +1,4 @@
import EditorJS from '../../../../types';
import type EditorJS from '../../../../types';
/**
* Test cases for Caret API

View file

@ -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', () => {
/**

View file

@ -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 */

View file

@ -1,4 +1,4 @@
import { TunesMenuConfig } from '../../../../types/tools';
import type { TunesMenuConfig } from '../../../../types/tools';
/* eslint-disable @typescript-eslint/no-empty-function */

View file

@ -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';

View file

@ -1,5 +1,5 @@
import Header from '@editorjs/header';
import { ToolboxConfig } from '../../../types';
import type { ToolboxConfig } from '../../../types';
describe('Editor i18n', () => {
context('Toolbox', () => {

View file

@ -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', () => {

View file

@ -1,4 +1,5 @@
import EditorJS, { EditorConfig } from '../../../types';
import type { EditorConfig } from '../../../types';
import type EditorJS from '../../../types';
describe('ReadOnly API spec', () => {
/**

View file

@ -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 */

View file

@ -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

View file

@ -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

View file

@ -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);

Some files were not shown because too many files have changed in this diff Show more