Skip to content

fix(types): tools export types added #2802

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
Aug 9, 2024
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
}
}
]
}
8 changes: 6 additions & 2 deletions cypress.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { defineConfig } from 'cypress';
import path from 'node:path';
import vitePreprocessor from 'cypress-vite';

export default defineConfig({
env: {
Expand All @@ -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.
Expand All @@ -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',
Expand Down
4 changes: 4 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

### 2.30.4

- `Fix` - Tool's exporting types added

### 2.30.3

- `Fix` – I18n in nested popover
Expand Down
2 changes: 1 addition & 1 deletion example/tools/text-variant-tune
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion src/codex.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

import { EditorConfig } from '../types';
import type { EditorConfig } from '../types';

/**
* Apply polyfills
Expand Down
10 changes: 5 additions & 5 deletions src/components/__module.ts
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
4 changes: 2 additions & 2 deletions src/components/block-tunes/block-tune-delete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

/**
*
Expand Down
4 changes: 2 additions & 2 deletions src/components/block-tunes/block-tune-move-down.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';


/**
Expand Down
4 changes: 2 additions & 2 deletions src/components/block-tunes/block-tune-move-up.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

/**
*
Expand Down
8 changes: 4 additions & 4 deletions src/components/block/api.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down
23 changes: 12 additions & 11 deletions src/components/block/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {
import type {
BlockAPI as BlockAPIInterface,
BlockTool as IBlockTool,
BlockToolData,
Expand All @@ -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 BlockTool from '../tools/block';

import BlockTune from '../tools/tune';
import { BlockTuneData } from '../../../types/block-tunes/block-tune-data';
import ToolsCollection from '../tools/collection';
import type BlockTune 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
Expand Down
5 changes: 3 additions & 2 deletions src/components/blocks.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/components/core.ts
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 1 addition & 1 deletion src/components/events/BlockChanged.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BlockMutationEvent } from '../../../types/events/block';
import type { BlockMutationEvent } from '../../../types/events/block';

/**
* Fired when some block state has changed
Expand Down
17 changes: 11 additions & 6 deletions src/components/events/index.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/components/i18n/index.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/components/i18n/namespace-internal.ts
Original file line number Diff line number Diff line change
@@ -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';

/**
Expand Down
4 changes: 2 additions & 2 deletions src/components/inline-tools/inline-tool-bold.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/components/inline-tools/inline-tool-convert.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
2 changes: 1 addition & 1 deletion src/components/inline-tools/inline-tool-italic.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { InlineTool, SanitizerConfig } from '../../../types';
import type { InlineTool, SanitizerConfig } from '../../../types';
import { IconItalic } from '@codexteam/icons';

/**
Expand Down
4 changes: 2 additions & 2 deletions src/components/inline-tools/inline-tool-link.ts
Original file line number Diff line number Diff line change
@@ -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';

/**
Expand Down
4 changes: 2 additions & 2 deletions src/components/modules/api/blocks.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/components/modules/api/caret.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand Down
2 changes: 1 addition & 1 deletion src/components/modules/api/events.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Module from '../../__module';
import { Events } from '../../../../types/api';
import type { Events } from '../../../../types/api';

/**
* @class EventsAPI
Expand Down
2 changes: 1 addition & 1 deletion src/components/modules/api/i18n.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
2 changes: 1 addition & 1 deletion src/components/modules/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/components/modules/api/inlineToolbar.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { InlineToolbar } from '../../../../types/api/inline-toolbar';
import type { InlineToolbar } from '../../../../types/api/inline-toolbar';
import Module from '../../__module';

/**
Expand Down
2 changes: 1 addition & 1 deletion src/components/modules/api/listeners.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Listeners } from '../../../../types/api';
import type { Listeners } from '../../../../types/api';
import Module from '../../__module';

/**
Expand Down
6 changes: 3 additions & 3 deletions src/components/modules/api/notifier.ts
Original file line number Diff line number Diff line change
@@ -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';

/**
*
Expand Down
2 changes: 1 addition & 1 deletion src/components/modules/api/readonly.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ReadOnly } from '../../../../types/api';
import type { ReadOnly } from '../../../../types/api';
import Module from '../../__module';

/**
Expand Down
4 changes: 2 additions & 2 deletions src/components/modules/api/sanitizer.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand Down
4 changes: 2 additions & 2 deletions src/components/modules/api/saver.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand Down
2 changes: 1 addition & 1 deletion src/components/modules/api/selection.ts
Original file line number Diff line number Diff line change
@@ -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';

/**
Expand Down
Loading
Loading