Skip to content

Commit

Permalink
fix(issues): based on review provided
Browse files Browse the repository at this point in the history
  • Loading branch information
dependentmadani committed Jul 23, 2024
1 parent 067c736 commit 9ce343d
Show file tree
Hide file tree
Showing 6 changed files with 100 additions and 27 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@editorjs/image",
"version": "2.9.2",
"version": "2.9.3",
"keywords": [
"codex editor",
"image",
Expand Down Expand Up @@ -47,12 +47,12 @@
"postcss-nested-ancestors": "^3.0.0",
"request": "^2.88.0",
"typescript": "^5.4.5",
"typescript-eslint": "^7.17.0",
"vite": "^5.3.1",
"vite-plugin-css-injected-by-js": "^3.5.1",
"vite-plugin-dts": "^3.9.1"
},
"dependencies": {
"@codexteam/icons": "^0.3.0",
"typescript-eslint": "^7.16.1"
"@codexteam/icons": "^0.3.0"
}
}
10 changes: 2 additions & 8 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export default class ImageTool implements BlockTool {
*/
this.uploader = new Uploader({
config: this.config,
onUpload: (response: UploadResponseFormat<object>) => this.onUpload(response),
onUpload: (response: UploadResponseFormat) => this.onUpload(response),
onError: (error: string) => this.uploadingFailed(error),
});

Expand Down Expand Up @@ -150,7 +150,6 @@ export default class ImageTool implements BlockTool {

/**
* Notify core that read-only mode is supported
* @returns
*/
public static get isReadOnlySupported(): boolean {
return true;
Expand All @@ -160,7 +159,6 @@ export default class ImageTool implements BlockTool {
* Get Tool toolbox settings
* icon - Tool icon's SVG
* title - title to show in toolbox
* @returns
*/
public static get toolbox(): ToolboxConfig {
return {
Expand All @@ -171,7 +169,6 @@ export default class ImageTool implements BlockTool {

/**
* Available image tools
* @returns
*/
public static get tunes(): Array<ActionConfig> {
return [
Expand Down Expand Up @@ -215,7 +212,6 @@ export default class ImageTool implements BlockTool {

/**
* Return Block data
* @returns
*/
public save(): ImageToolData {
const caption = this.ui.nodes.caption;
Expand Down Expand Up @@ -263,7 +259,6 @@ export default class ImageTool implements BlockTool {
/**
* Specify paste substitutes
* @see {@link https://github.com/codex-team/editor.js/blob/master/docs/tools.md#paste-handling}
* @returns
*/
public static get pasteConfig(): PasteConfig {
return {
Expand Down Expand Up @@ -296,7 +291,6 @@ export default class ImageTool implements BlockTool {
* @see {@link https://github.com/codex-team/editor.js/blob/master/docs/tools.md#paste-handling}
* @param event - editor.js custom paste event
* {@link https://github.com/codex-team/editor.js/blob/master/types/tools/paste-events.d.ts}
* @returns
*/
public async onPaste(event: PasteEvent): Promise<void> {
switch (event.type) {
Expand Down Expand Up @@ -405,7 +399,7 @@ export default class ImageTool implements BlockTool {
*/
private tuneToggled(tuneName: keyof ImageToolData): void {
// inverse tune state
this.setTune(tuneName, this._data[tuneName] != undefined ? false : true);
this.setTune(tuneName, this._data[tuneName] !== undefined ? false : true);
}

/**
Expand Down
8 changes: 3 additions & 5 deletions src/ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,9 @@ export default class Ui {
/**
* Renders tool UI
* @param toolData - saved tool data
* @returns
*/
public render(toolData: ImageToolData): HTMLElement {
if (toolData.file == undefined || Object.keys(toolData.file).length === 0) {
if (toolData.file === undefined || Object.keys(toolData.file).length === 0) {
this.toggleStatus(UiState.Empty);
} else {
this.toggleStatus(UiState.Uploading);
Expand Down Expand Up @@ -247,7 +246,7 @@ export default class Ui {
/**
* Preloader does not exists on first rendering with presaved data
*/
if (this.nodes.imagePreloader != undefined) {
if (this.nodes.imagePreloader !== undefined) {
this.nodes.imagePreloader.style.backgroundImage = '';
}
});
Expand All @@ -260,7 +259,7 @@ export default class Ui {
* @param text - caption content text
*/
public fillCaption(text: string): void {
if (this.nodes.caption != undefined) {
if (this.nodes.caption !== undefined) {
this.nodes.caption.innerHTML = text;
}
}
Expand Down Expand Up @@ -288,7 +287,6 @@ export default class Ui {

/**
* Creates upload-file button
* @returns
*/
private createFileButton(): HTMLElement {
const button = make('div', [this.CSS.button]);
Expand Down
2 changes: 1 addition & 1 deletion src/utils/dom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export function make(tagName: string, classNames: string[] | string | null = nul

if (Array.isArray(classNames)) {
el.classList.add(...classNames);
} else if (classNames != null) {
} else if (classNames !== null) {
el.classList.add(classNames);
}

Expand Down
2 changes: 1 addition & 1 deletion src/utils/isPromise.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ import type { UploadResponseFormat } from '../types/types';
* @returns
*/
export default function isPromise(object: Promise<UploadResponseFormat>): object is Promise<UploadResponseFormat> {
return object != undefined && typeof object.then === 'function';
return object !== undefined && typeof object.then === 'function';
}
99 changes: 90 additions & 9 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,22 @@
resolved "https://registry.yarnpkg.com/@types/semver/-/semver-7.5.8.tgz#8268a8c57a3e4abd25c165ecd36237db7948a55e"
integrity sha512-I8EUhyrgfLrcTkzV3TSsGyl1tSuPrEDzr0yd5m90UgNxQkyDXULk3b6MlQqTCpZpNtWe1K0hzclnZkTcLBe2UQ==

"@typescript-eslint/eslint-plugin@7.16.1", "@typescript-eslint/eslint-plugin@^7.16.1":
"@typescript-eslint/eslint-plugin@7.17.0":
version "7.17.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-7.17.0.tgz#c8ed1af1ad2928ede5cdd207f7e3090499e1f77b"
integrity sha512-pyiDhEuLM3PuANxH7uNYan1AaFs5XE0zw1hq69JBvGvE7gSuEoQl1ydtEe/XQeoC3GQxLXyOVa5kNOATgM638A==
dependencies:
"@eslint-community/regexpp" "^4.10.0"
"@typescript-eslint/scope-manager" "7.17.0"
"@typescript-eslint/type-utils" "7.17.0"
"@typescript-eslint/utils" "7.17.0"
"@typescript-eslint/visitor-keys" "7.17.0"
graphemer "^1.4.0"
ignore "^5.3.1"
natural-compare "^1.4.0"
ts-api-utils "^1.3.0"

"@typescript-eslint/eslint-plugin@^7.16.1":
version "7.16.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-7.16.1.tgz#f5f5da52db674b1f2cdb9d5f3644e5b2ec750465"
integrity sha512-SxdPak/5bO0EnGktV05+Hq8oatjAYVY3Zh2bye9pGZy6+jwyR3LG3YKkV4YatlsgqXP28BTeVm9pqwJM96vf2A==
Expand All @@ -508,7 +523,18 @@
natural-compare "^1.4.0"
ts-api-utils "^1.3.0"

"@typescript-eslint/parser@7.16.1", "@typescript-eslint/parser@^7.16.1":
"@typescript-eslint/parser@7.17.0":
version "7.17.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-7.17.0.tgz#be8e32c159190cd40a305a2121220eadea5a88e7"
integrity sha512-puiYfGeg5Ydop8eusb/Hy1k7QmOU6X3nvsqCgzrB2K4qMavK//21+PzNE8qeECgNOIoertJPUC1SpegHDI515A==
dependencies:
"@typescript-eslint/scope-manager" "7.17.0"
"@typescript-eslint/types" "7.17.0"
"@typescript-eslint/typescript-estree" "7.17.0"
"@typescript-eslint/visitor-keys" "7.17.0"
debug "^4.3.4"

"@typescript-eslint/parser@^7.16.1":
version "7.16.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-7.16.1.tgz#84c581cf86c8b2becd48d33ddc41a6303d57b274"
integrity sha512-u+1Qx86jfGQ5i4JjK33/FnawZRpsLxRnKzGE6EABZ40KxVT/vWsiZFEBBHjFOljmmV3MBYOHEKi0Jm9hbAOClA==
Expand All @@ -535,6 +561,14 @@
"@typescript-eslint/types" "7.16.1"
"@typescript-eslint/visitor-keys" "7.16.1"

"@typescript-eslint/scope-manager@7.17.0":
version "7.17.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-7.17.0.tgz#e072d0f914662a7bfd6c058165e3c2b35ea26b9d"
integrity sha512-0P2jTTqyxWp9HiKLu/Vemr2Rg1Xb5B7uHItdVZ6iAenXmPo4SZ86yOPCJwMqpCyaMiEHTNqizHfsbmCFT1x9SA==
dependencies:
"@typescript-eslint/types" "7.17.0"
"@typescript-eslint/visitor-keys" "7.17.0"

"@typescript-eslint/type-utils@7.16.1":
version "7.16.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/type-utils/-/type-utils-7.16.1.tgz#4d7ae4f3d9e3c8cbdabae91609b1a431de6aa6ca"
Expand All @@ -545,6 +579,16 @@
debug "^4.3.4"
ts-api-utils "^1.3.0"

"@typescript-eslint/type-utils@7.17.0":
version "7.17.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/type-utils/-/type-utils-7.17.0.tgz#c5da78feb134c9c9978cbe89e2b1a589ed22091a"
integrity sha512-XD3aaBt+orgkM/7Cei0XNEm1vwUxQ958AOLALzPlbPqb8C1G8PZK85tND7Jpe69Wualri81PLU+Zc48GVKIMMA==
dependencies:
"@typescript-eslint/typescript-estree" "7.17.0"
"@typescript-eslint/utils" "7.17.0"
debug "^4.3.4"
ts-api-utils "^1.3.0"

"@typescript-eslint/types@6.21.0":
version "6.21.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-6.21.0.tgz#205724c5123a8fef7ecd195075fa6e85bac3436d"
Expand All @@ -555,6 +599,11 @@
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-7.16.1.tgz#bbab066276d18e398bc64067b23f1ce84dfc6d8c"
integrity sha512-AQn9XqCzUXd4bAVEsAXM/Izk11Wx2u4H3BAfQVhSfzfDOm/wAON9nP7J5rpkCxts7E5TELmN845xTUCQrD1xIQ==

"@typescript-eslint/types@7.17.0":
version "7.17.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-7.17.0.tgz#7ce8185bdf06bc3494e73d143dbf3293111b9cff"
integrity sha512-a29Ir0EbyKTKHnZWbNsrc/gqfIBqYPwj3F2M+jWE/9bqfEHg0AMtXzkbUkOG6QgEScxh2+Pz9OXe11jHDnHR7A==

"@typescript-eslint/types@^7.2.0":
version "7.13.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-7.13.1.tgz#787db283bd0b58751094c90d5b58bbf5e9fc9bd8"
Expand Down Expand Up @@ -588,6 +637,20 @@
semver "^7.6.0"
ts-api-utils "^1.3.0"

"@typescript-eslint/typescript-estree@7.17.0":
version "7.17.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-7.17.0.tgz#dcab3fea4c07482329dd6107d3c6480e228e4130"
integrity sha512-72I3TGq93t2GoSBWI093wmKo0n6/b7O4j9o8U+f65TVD0FS6bI2180X5eGEr8MA8PhKMvYe9myZJquUT2JkCZw==
dependencies:
"@typescript-eslint/types" "7.17.0"
"@typescript-eslint/visitor-keys" "7.17.0"
debug "^4.3.4"
globby "^11.1.0"
is-glob "^4.0.3"
minimatch "^9.0.4"
semver "^7.6.0"
ts-api-utils "^1.3.0"

"@typescript-eslint/utils@7.16.1":
version "7.16.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-7.16.1.tgz#df42dc8ca5a4603016fd102db0346cdab415cdb7"
Expand All @@ -598,6 +661,16 @@
"@typescript-eslint/types" "7.16.1"
"@typescript-eslint/typescript-estree" "7.16.1"

"@typescript-eslint/utils@7.17.0":
version "7.17.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-7.17.0.tgz#815cd85b9001845d41b699b0ce4f92d6dfb84902"
integrity sha512-r+JFlm5NdB+JXc7aWWZ3fKSm1gn0pkswEwIYsrGPdsT2GjsRATAKXiNtp3vgAAO1xZhX8alIOEQnNMl3kbTgJw==
dependencies:
"@eslint-community/eslint-utils" "^4.4.0"
"@typescript-eslint/scope-manager" "7.17.0"
"@typescript-eslint/types" "7.17.0"
"@typescript-eslint/typescript-estree" "7.17.0"

"@typescript-eslint/utils@^6.21.0":
version "6.21.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-6.21.0.tgz#4714e7a6b39e773c1c8e97ec587f520840cd8134"
Expand Down Expand Up @@ -627,6 +700,14 @@
"@typescript-eslint/types" "7.16.1"
eslint-visitor-keys "^3.4.3"

"@typescript-eslint/visitor-keys@7.17.0":
version "7.17.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-7.17.0.tgz#680465c734be30969e564b4647f38d6cdf49bfb0"
integrity sha512-RVGC9UhPOCsfCdI9pU++K4nD7to+jTcMIbXTSOcrLqUEW6gF2pU1UUbYJKc9cvcRSK1UDeMJ7pdMxf4bhMpV/A==
dependencies:
"@typescript-eslint/types" "7.17.0"
eslint-visitor-keys "^3.4.3"

"@volar/language-core@1.11.1", "@volar/language-core@~1.11.1":
version "1.11.1"
resolved "https://registry.yarnpkg.com/@volar/language-core/-/language-core-1.11.1.tgz#ecdf12ea8dc35fb8549e517991abcbf449a5ad4f"
Expand Down Expand Up @@ -3009,14 +3090,14 @@ typed-array-length@^1.0.6:
is-typed-array "^1.1.13"
possible-typed-array-names "^1.0.0"

typescript-eslint@^7.16.1:
version "7.16.1"
resolved "https://registry.yarnpkg.com/typescript-eslint/-/typescript-eslint-7.16.1.tgz#4855e11985b3dbd13a94b4e7e6523b2ec5d1c759"
integrity sha512-889oE5qELj65q/tGeOSvlreNKhimitFwZqQ0o7PcWC7/lgRkAMknznsCsV8J8mZGTP/Z+cIbX8accf2DE33hrA==
typescript-eslint@^7.17.0:
version "7.17.0"
resolved "https://registry.yarnpkg.com/typescript-eslint/-/typescript-eslint-7.17.0.tgz#cc5eddafd38b3c1fe8a52826469d5c78700b7aa7"
integrity sha512-spQxsQvPguduCUfyUvLItvKqK3l8KJ/kqs5Pb/URtzQ5AC53Z6us32St37rpmlt2uESG23lOFpV4UErrmy4dZQ==
dependencies:
"@typescript-eslint/eslint-plugin" "7.16.1"
"@typescript-eslint/parser" "7.16.1"
"@typescript-eslint/utils" "7.16.1"
"@typescript-eslint/eslint-plugin" "7.17.0"
"@typescript-eslint/parser" "7.17.0"
"@typescript-eslint/utils" "7.17.0"

typescript@5.4.2:
version "5.4.2"
Expand Down

0 comments on commit 9ce343d

Please sign in to comment.