Skip to content

Commit 7160820

Browse files
committed
fix(migration): address feedback from PR review
1 parent 7bbc379 commit 7160820

File tree

5 files changed

+17
-41
lines changed

5 files changed

+17
-41
lines changed

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,6 @@
4545
"vite-plugin-dts": "^3.9.1"
4646
},
4747
"dependencies": {
48-
"@codexteam/icons": "^0.0.5"
48+
"@codexteam/icons": "^0.3.1"
4949
}
5050
}

src/index.ts

Lines changed: 8 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import './index.css';
22
import { getLineStartPosition } from './utils/string';
33
import { IconBrackets } from '@codexteam/icons';
4-
import { API, PasteEvent } from '@editorjs/editorjs';
4+
import { API, BlockToolConstructorOptions, BlockTool, PasteEvent } from '@editorjs/editorjs';
55

66
/**
77
* CodeTool for Editor.js
@@ -11,7 +11,7 @@ import { API, PasteEvent } from '@editorjs/editorjs';
1111
*/
1212

1313
/**
14-
* @description CodeTool's data
14+
* @description CodeTool generates data in this format
1515
*/
1616
export interface CodeData {
1717
code: string;
@@ -42,54 +42,34 @@ interface CodeToolNodes {
4242
textarea: HTMLTextAreaElement | null;
4343
}
4444

45-
/**
46-
* @description Constructor arguments for CodeTool
47-
*/
48-
interface ConstructorArgs {
49-
/** Previously saved data */
50-
data: CodeData;
51-
/** User config for the tool */
52-
config: CodeConfig;
53-
/** Editor.js API */
54-
api: API;
55-
/** Read-only mode flag */
56-
readOnly: boolean;
57-
}
58-
5945
/**
6046
* Code Tool for the Editor.js allows to include code examples in your articles.
6147
*/
62-
export default class CodeTool {
48+
export default class CodeTool implements BlockTool {
6349
/**
6450
* Editor.js API
65-
* @private
6651
*/
6752
private api: API;
6853
/**
6954
* Read-only mode flag
70-
* @private
7155
*/
7256
private readOnly: boolean;
7357
/**
7458
* CodeTool's placeholder
75-
* @private
7659
*/
7760
private placeholder: string;
7861
/**
7962
* CodeTool's CSS
80-
* @private
8163
*/
8264
private CSS: CodeToolCSS;
8365
/**
8466
* CodeTool nodes
85-
* @private
8667
*/
8768
private nodes: CodeToolNodes;
8869
/**
8970
* CodeTool's data
90-
* @private
9171
*/
92-
private _data: CodeData;
72+
private _data!: CodeData;
9373

9474
/**
9575
* Notify core that read-only mode is supported
@@ -124,7 +104,7 @@ export default class CodeTool {
124104
* @param {object} options.api - Editor.js API
125105
* @param {boolean} options.readOnly - read only mode flag
126106
*/
127-
constructor({ data, config, api, readOnly }: ConstructorArgs) {
107+
constructor({ data, config, api, readOnly }: BlockToolConstructorOptions) {
128108
this.api = api;
129109
this.readOnly = readOnly;
130110

@@ -142,7 +122,7 @@ export default class CodeTool {
142122
textarea: null,
143123
};
144124

145-
this._data = {
125+
this.data = {
146126
code: data.code || '',
147127
};
148128

@@ -161,7 +141,7 @@ export default class CodeTool {
161141

162142
wrapper.classList.add(this.CSS.baseClass, this.CSS.wrapper);
163143
textarea.classList.add(this.CSS.textarea, this.CSS.input);
164-
textarea.textContent = this._data.code;
144+
textarea.textContent = this.data.code;
165145

166146
textarea.placeholder = this.placeholder;
167147

@@ -220,7 +200,7 @@ export default class CodeTool {
220200

221201
if ('data' in detail) {
222202
const content = detail.data as string;
223-
this._data = {
203+
this.data = {
224204
code: content || '',
225205
};
226206
}

src/types/codexteam-icons.d.ts

Lines changed: 0 additions & 4 deletions
This file was deleted.

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
resolved "https://registry.npmjs.org/@babel/parser/-/parser-7.24.8.tgz"
88
integrity sha512-WzfbgXOkGzZiXXCqk43kKwZjzwx4oulxZi3nq2TYL9mOjQv6kYwul9mz6ID36njuL7Xkp6nJEfok848Zj10j/w==
99

10-
"@codexteam/icons@^0.0.5":
11-
version "0.0.5"
12-
resolved "https://registry.npmjs.org/@codexteam/icons/-/icons-0.0.5.tgz"
13-
integrity sha512-s6H2KXhLz2rgbMZSkRm8dsMJvyUNZsEjxobBEg9ztdrb1B2H3pEzY6iTwI4XUPJWJ3c3qRKwV4TrO3J5jUdoQA==
10+
"@codexteam/icons@^0.3.1":
11+
version "0.3.1"
12+
resolved "https://registry.npmjs.org/@codexteam/icons/-/icons-0.3.1.tgz"
13+
integrity sha512-xojjd40csucwaKz/Nnh/iy18BtTdQjq3YQNL6MCqqFRyUNN+8nRfm/Mp+Y4xo6TseDkReS2tM1FbuULyrFjn0w==
1414

1515
"@editorjs/editorjs@^2.30.2":
1616
version "2.30.2"

0 commit comments

Comments
 (0)