From a07b838409dbe65b825861be1210594c9b2d9608 Mon Sep 17 00:00:00 2001
From: e11sy <130844513+e11sy@users.noreply.github.com>
Date: Mon, 18 Nov 2024 19:55:12 +0300
Subject: [PATCH 1/7] add file with icons
---
src/styles/icons/index.ts | 11 +++++++++++
1 file changed, 11 insertions(+)
create mode 100644 src/styles/icons/index.ts
diff --git a/src/styles/icons/index.ts b/src/styles/icons/index.ts
new file mode 100644
index 0000000..f141485
--- /dev/null
+++ b/src/styles/icons/index.ts
@@ -0,0 +1,11 @@
+/**
+ * This file exports icons needed for Editorjs List plugin, but this icons are still unreleased
+ * @todo remove this file and use icons from codex-team/icons package, when version with this icons will be released
+ */
+
+export declare const IconNumber = '';
+export declare const IconLowerRoman = '';
+export declare const IconUpperRoman = '';
+export declare const IconUpperAlpha = '';
+export declare const IconLowerAlpha = '';
+export declare const IconStartWith = '';
From b1dde61203ca7d85d9e8b208dd6db1828a5d429f Mon Sep 17 00:00:00 2001
From: e11sy <130844513+e11sy@users.noreply.github.com>
Date: Mon, 18 Nov 2024 20:45:18 +0300
Subject: [PATCH 2/7] add icons and separator
---
src/index.ts | 10 +++++++---
src/styles/icons/index.ts | 12 ++++++------
src/types/OlCounterType.ts | 10 ++++++++++
3 files changed, 23 insertions(+), 9 deletions(-)
diff --git a/src/index.ts b/src/index.ts
index f228177..6db2314 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -5,12 +5,13 @@ import type {
ToolConfig
} from '@editorjs/editorjs/types/tools';
import { IconListBulleted, IconListNumbered, IconChecklist } from '@codexteam/icons';
+import { IconUpperAlpha, IconStartWith } from './styles/icons/index.js';
import type { ListConfig, ListData, ListDataStyle, ListItem, OldListData } from './types/ListParams';
import ListTabulator from './ListTabulator';
import { CheckListRenderer, OrderedListRenderer, UnorderedListRenderer } from './ListRenderer';
import type { ListRenderer } from './types/ListRenderer';
import { renderToolboxInput } from './utils/renderToolboxInput';
-import { type OlCounterType, OlCounterTypesMap } from './types/OlCounterType';
+import { OlCounterIconsMap, type OlCounterType, OlCounterTypesMap } from './types/OlCounterType';
/**
* Build styles
@@ -316,6 +317,7 @@ export default class EditorjsList {
const orderedListTunes: MenuConfigItem[] = [
{
label: this.api.i18n.t('Start with'),
+ icon: IconStartWith,
children: {
items: [
{
@@ -330,6 +332,7 @@ export default class EditorjsList {
const orderedListCountersTunes: MenuConfigItem = {
label: this.api.i18n.t('Counters type'),
+ icon: IconUpperAlpha,
children: {
items: [],
},
@@ -342,6 +345,7 @@ export default class EditorjsList {
OlCounterTypesMap.forEach((_, counterType: string) => {
orderedListCountersTunes.children.items!.push({
title: this.api.i18n.t(counterType),
+ icon: OlCounterIconsMap.get(counterType),
isActive: (this.data.meta as OrderedListItemMeta).counterType === OlCounterTypesMap.get(counterType),
closeOnActivate: true,
onActivate: () => {
@@ -349,8 +353,8 @@ export default class EditorjsList {
},
});
});
-
- defaultTunes.push(...orderedListTunes, orderedListCountersTunes);
+ // @ts-expect-error ts(2820) can not use PopoverItem enum from editor.js types
+ defaultTunes.push({ type: 'separator' }, ...orderedListTunes, orderedListCountersTunes);
}
return defaultTunes;
diff --git a/src/styles/icons/index.ts b/src/styles/icons/index.ts
index f141485..6809178 100644
--- a/src/styles/icons/index.ts
+++ b/src/styles/icons/index.ts
@@ -3,9 +3,9 @@
* @todo remove this file and use icons from codex-team/icons package, when version with this icons will be released
*/
-export declare const IconNumber = '';
-export declare const IconLowerRoman = '';
-export declare const IconUpperRoman = '';
-export declare const IconUpperAlpha = '';
-export declare const IconLowerAlpha = '';
-export declare const IconStartWith = '';
+export const IconNumber = '';
+export const IconLowerRoman = '';
+export const IconUpperRoman = '';
+export const IconUpperAlpha = '';
+export const IconLowerAlpha = '';
+export const IconStartWith = '';
diff --git a/src/types/OlCounterType.ts b/src/types/OlCounterType.ts
index b39e2ee..1557a3a 100644
--- a/src/types/OlCounterType.ts
+++ b/src/types/OlCounterType.ts
@@ -1,3 +1,5 @@
+import { IconNumber, IconLowerRoman, IconUpperRoman, IconLowerAlpha, IconUpperAlpha } from '../styles/icons/index.js';
+
export type OlCounterType = 'numeric' | 'upper-roman' | 'lower-roman' | 'upper-alpha' | 'lower-alpha';
/**
@@ -29,3 +31,11 @@ export const OlCounterTypesMap = new Map([
*/
['Upper Alpha', 'upper-alpha'],
]);
+
+export const OlCounterIconsMap = new Map([
+ ['Numeric', IconNumber],
+ ['Lower Roman', IconLowerRoman],
+ ['Upper Roman', IconUpperRoman],
+ ['Lower Alpha', IconLowerAlpha],
+ ['Upper Alpha', IconUpperAlpha],
+]);
From f4c47db6ea09001db2e722891ce16673cef6b39d Mon Sep 17 00:00:00 2001
From: e11sy <130844513+e11sy@users.noreply.github.com>
Date: Wed, 20 Nov 2024 17:55:37 +0300
Subject: [PATCH 3/7] fix icon svgs
---
src/styles/icons/index.ts | 15 +++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)
diff --git a/src/styles/icons/index.ts b/src/styles/icons/index.ts
index 6809178..f4bb03a 100644
--- a/src/styles/icons/index.ts
+++ b/src/styles/icons/index.ts
@@ -1,11 +1,10 @@
/**
- * This file exports icons needed for Editorjs List plugin, but this icons are still unreleased
+ * This file exports icons needed for Editorjs List plugin, but this icons are not released yet
* @todo remove this file and use icons from codex-team/icons package, when version with this icons will be released
*/
-
-export const IconNumber = '';
-export const IconLowerRoman = '';
-export const IconUpperRoman = '';
-export const IconUpperAlpha = '';
-export const IconLowerAlpha = '';
-export const IconStartWith = '';
+export const IconNumber = '';
+export const IconLowerRoman = '';
+export const IconUpperRoman = '';
+export const IconUpperAlpha = '';
+export const IconLowerAlpha = '';
+export const IconStartWith = '';
From bfee657f3cc9e46037c7c46c30c87bc6ea417afd Mon Sep 17 00:00:00 2001
From: e11sy <130844513+e11sy@users.noreply.github.com>
Date: Wed, 20 Nov 2024 17:58:53 +0300
Subject: [PATCH 4/7] improve comments
---
src/types/OlCounterType.ts | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/src/types/OlCounterType.ts b/src/types/OlCounterType.ts
index 1557a3a..f7af3d9 100644
--- a/src/types/OlCounterType.ts
+++ b/src/types/OlCounterType.ts
@@ -33,9 +33,28 @@ export const OlCounterTypesMap = new Map([
]);
export const OlCounterIconsMap = new Map([
+ /**
+ * Value that represents Icon for Numeric counter type
+ */
['Numeric', IconNumber],
+
+ /**
+ * Value that represents Icon for Lower Roman counter type
+ */
['Lower Roman', IconLowerRoman],
+
+ /**
+ * Value that represents Icon for Upper Roman counter type
+ */
['Upper Roman', IconUpperRoman],
+
+ /**
+ * Value that represents Icon for Lower Alpha counter type
+ */
['Lower Alpha', IconLowerAlpha],
+
+ /**
+ * Value that represents Icon for Upper Alpha counter type
+ */
['Upper Alpha', IconUpperAlpha],
]);
From 1fdb4c43a031b782b0f72a8f8ac223a182a3d4a5 Mon Sep 17 00:00:00 2001
From: e11sy <130844513+e11sy@users.noreply.github.com>
Date: Wed, 20 Nov 2024 18:00:05 +0300
Subject: [PATCH 5/7] comments
---
src/types/OlCounterType.ts | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/types/OlCounterType.ts b/src/types/OlCounterType.ts
index f7af3d9..fbdb8cf 100644
--- a/src/types/OlCounterType.ts
+++ b/src/types/OlCounterType.ts
@@ -3,7 +3,7 @@ import { IconNumber, IconLowerRoman, IconUpperRoman, IconLowerAlpha, IconUpperAl
export type OlCounterType = 'numeric' | 'upper-roman' | 'lower-roman' | 'upper-alpha' | 'lower-alpha';
/**
- * Enum that represents all of the supported styles of the counters for ordered list
+ * Map that represents all of the supported styles of the counters for ordered list
*/
export const OlCounterTypesMap = new Map([
/**
@@ -32,6 +32,9 @@ export const OlCounterTypesMap = new Map([
['Upper Alpha', 'upper-alpha'],
]);
+/**
+ * Map that represents relation between supported counter types and theirs icons to be displayed in toolbox
+ */
export const OlCounterIconsMap = new Map([
/**
* Value that represents Icon for Numeric counter type
From 7195ecb7f4ae9391b4e986efa5293e239b508ac6 Mon Sep 17 00:00:00 2001
From: e11sy <130844513+e11sy@users.noreply.github.com>
Date: Wed, 20 Nov 2024 18:14:30 +0300
Subject: [PATCH 6/7] improve counter type tune
---
src/index.ts | 9 ++++-----
src/types/OlCounterType.ts | 10 +++++-----
2 files changed, 9 insertions(+), 10 deletions(-)
diff --git a/src/index.ts b/src/index.ts
index 6db2314..4cb763d 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -5,7 +5,7 @@ import type {
ToolConfig
} from '@editorjs/editorjs/types/tools';
import { IconListBulleted, IconListNumbered, IconChecklist } from '@codexteam/icons';
-import { IconUpperAlpha, IconStartWith } from './styles/icons/index.js';
+import { IconStartWith } from './styles/icons/index.js';
import type { ListConfig, ListData, ListDataStyle, ListItem, OldListData } from './types/ListParams';
import ListTabulator from './ListTabulator';
import { CheckListRenderer, OrderedListRenderer, UnorderedListRenderer } from './ListRenderer';
@@ -331,8 +331,8 @@ export default class EditorjsList {
];
const orderedListCountersTunes: MenuConfigItem = {
- label: this.api.i18n.t('Counters type'),
- icon: IconUpperAlpha,
+ label: this.api.i18n.t('Counter type'),
+ icon: OlCounterIconsMap.get((this.data.meta as OrderedListItemMeta).counterType!),
children: {
items: [],
},
@@ -341,11 +341,10 @@ export default class EditorjsList {
/**
* For each counter type in OlCounterType create toolbox item
*/
-
OlCounterTypesMap.forEach((_, counterType: string) => {
orderedListCountersTunes.children.items!.push({
title: this.api.i18n.t(counterType),
- icon: OlCounterIconsMap.get(counterType),
+ icon: OlCounterIconsMap.get(OlCounterTypesMap.get(counterType)!),
isActive: (this.data.meta as OrderedListItemMeta).counterType === OlCounterTypesMap.get(counterType),
closeOnActivate: true,
onActivate: () => {
diff --git a/src/types/OlCounterType.ts b/src/types/OlCounterType.ts
index fbdb8cf..b1b151a 100644
--- a/src/types/OlCounterType.ts
+++ b/src/types/OlCounterType.ts
@@ -39,25 +39,25 @@ export const OlCounterIconsMap = new Map([
/**
* Value that represents Icon for Numeric counter type
*/
- ['Numeric', IconNumber],
+ ['numeric', IconNumber],
/**
* Value that represents Icon for Lower Roman counter type
*/
- ['Lower Roman', IconLowerRoman],
+ ['lower-roman', IconLowerRoman],
/**
* Value that represents Icon for Upper Roman counter type
*/
- ['Upper Roman', IconUpperRoman],
+ ['upper-roman', IconUpperRoman],
/**
* Value that represents Icon for Lower Alpha counter type
*/
- ['Lower Alpha', IconLowerAlpha],
+ ['lower-alpha', IconLowerAlpha],
/**
* Value that represents Icon for Upper Alpha counter type
*/
- ['Upper Alpha', IconUpperAlpha],
+ ['upper-alpha', IconUpperAlpha],
]);
From b7c17f4b2e40cbfda354244f027645de7af1039e Mon Sep 17 00:00:00 2001
From: e11sy <130844513+e11sy@users.noreply.github.com>
Date: Wed, 20 Nov 2024 18:18:08 +0300
Subject: [PATCH 7/7] bump version
---
package.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/package.json b/package.json
index d9057c7..2dad172 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "@editorjs/list",
- "version": "2.0.0",
+ "version": "2.0.1",
"keywords": [
"codex editor",
"list",