From d5f8eb93b6ca2eb1c067cfc317d0d79226fea5bd Mon Sep 17 00:00:00 2001 From: e11sy <130844513+e11sy@users.noreply.github.com> Date: Wed, 6 Nov 2024 21:13:15 +0300 Subject: [PATCH 1/3] get rid of `Nested` in naming --- README.md | 14 +++++++------- eslint.config.mjs | 2 +- example/example.html | 8 ++++---- index.html | 6 +++--- package.json | 16 ++++++++-------- src/ListRenderer/ChecklistRenderer.ts | 6 +++--- src/ListRenderer/ListRenderer.ts | 6 +++--- src/ListRenderer/OrderedListRenderer.ts | 8 ++++---- src/ListRenderer/UnorderedListRenderer.ts | 8 ++++---- src/ListTabulator/index.ts | 14 +++++++------- src/index.ts | 22 ++++++++++------------ src/types/ListParams.ts | 4 ++-- src/utils/normalizeData.ts | 6 +++--- src/utils/renderToolboxInput.ts | 2 +- vite.config.js | 4 ++-- 15 files changed, 62 insertions(+), 64 deletions(-) diff --git a/README.md b/README.md index 551c669a..e99b17a8 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ ![](https://badgen.net/badge/Editor.js/v2.19.2/blue) -# Nested List Tool for Editor.js +# Editorjs List Tool Multi-leveled lists for the [Editor.js](https://editorjs.io). @@ -24,31 +24,31 @@ Use `Tab` and `Shift+Tab` keys to create or remove sublist with a padding. Get the package ```shell -yarn add @editorjs/nested-list +yarn add @editorjs/list ``` Include module at your application ```javascript -import NestedList from '@editorjs/nested-list'; +import List from '@editorjs/list'; ``` -Optionally, you can load this tool from CDN [JsDelivr CDN](https://cdn.jsdelivr.net/npm/@editorjs/nested-list@latest) +Optionally, you can load this tool from CDN [JsDelivr CDN](https://cdn.jsdelivr.net/npm/@editorjs/list@latest) ## Usage -Add the NestedList Tool to the `tools` property of the Editor.js initial config. +Add the List Tool to the `tools` property of the Editor.js initial config. ```javascript import EditorJS from '@editorjs/editorjs'; -import NestedList from '@editorjs/nested-list'; +import List from '@editorjs/list'; var editor = EditorJS({ // ... tools: { ... list: { - class: NestedList, + class: List, inlineToolbar: true, config: { defaultStyle: 'unordered' diff --git a/eslint.config.mjs b/eslint.config.mjs index 63e37db0..16eebf9c 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -27,7 +27,7 @@ export default [ * Redefine language oprions and some of the rules of the CodeX eslint config for typescript config */ { - name: 'editorjs-nested-list', + name: 'editorjs-list', ignores: ['vite.config.js', 'eslint.config.mjs', 'postcss.config.js', '**/json-preview.js'], plugins: { '@typescript-eslint': TsPlugin, diff --git a/example/example.html b/example/example.html index 5410d64c..6f6f363f 100644 --- a/example/example.html +++ b/example/example.html @@ -59,7 +59,7 @@ - + @@ -120,8 +120,8 @@ */ image: SimpleImage, - nestedList: { - class: NestedList, + List: { + class: List, inlineToolbar: true, shortcut: 'CMD+SHIFT+L' }, @@ -189,7 +189,7 @@ data: { blocks: [ { - type : 'nestedList', + type : 'List', data : { items : [ { diff --git a/index.html b/index.html index 5b62daac..3d949a15 100644 --- a/index.html +++ b/index.html @@ -197,9 +197,9 @@ data : { style : "checklist", items : [ - "This is List tool data", + "This is old List tool data", "That would be displayed", - "In Nested List tool" + "In new List tool" ], }, }, @@ -216,7 +216,7 @@ checked: false }, { - text: "In Nested List tool", + text: "In new List tool", checked: true } ] diff --git a/package.json b/package.json index d208cd5d..aac973d2 100644 --- a/package.json +++ b/package.json @@ -1,25 +1,25 @@ { - "name": "@editorjs/nested-list", + "name": "@editorjs/list", "version": "1.4.3", "keywords": [ "codex editor", - "nested-list", + "list", "editor.js", "editorjs" ], - "description": "Nested list Tool for EditorJS", - "repository": "https://github.com/editor-js/nested-list.git", + "description": "Editorjs List Tool for EditorJS", + "repository": "https://github.com/editor-js/list.git", "author": "CodeX ", "license": "MIT", "files": [ "dist" ], - "main": "./dist/nested-list.umd.js", - "module": "./dist/nested-list.mjs", + "main": "./dist/editorjs-list.umd.js", + "module": "./dist/editorjs-list.mjs", "exports": { ".": { - "import": "./dist/nested-list.mjs", - "require": "./dist/nested-list.umd.js", + "import": "./dist/editorjs-list.mjs", + "require": "./dist/editorjs-list.umd.js", "types": "./dist/index.d.ts" } }, diff --git a/src/ListRenderer/ChecklistRenderer.ts b/src/ListRenderer/ChecklistRenderer.ts index 0faf108a..7ed6863b 100644 --- a/src/ListRenderer/ChecklistRenderer.ts +++ b/src/ListRenderer/ChecklistRenderer.ts @@ -1,6 +1,6 @@ import { IconCheck } from '@codexteam/icons'; import type { ChecklistItemMeta } from '../types/ItemMeta'; -import type { NestedListConfig } from '../types/ListParams'; +import type { ListConfig } from '../types/ListParams'; import { isEmpty, make } from '@editorjs/dom'; import { DefaultListCssClasses } from './ListRenderer'; import type { ListCssClasses, ListRendererInterface } from './ListRenderer'; @@ -43,7 +43,7 @@ export class CheckListRenderer implements ListRendererInterface { private api: API; /** - * Is NestedList Tool read-only option + * Is Editorjs List Tool read-only option */ private readOnly: boolean; /** * Tool's configuration */ - private config?: NestedListConfig; + private config?: ListConfig; /** * Full content of the list @@ -138,7 +138,7 @@ export default class ListTabulator { } /** - * Function that is responsible for rendering nested list with contents + * Function that is responsible for rendering list with contents * @returns Filled with content wrapper element of the list */ public render(): ItemChildWrapperElement { @@ -252,7 +252,7 @@ export default class ListTabulator { /** * On paste sanitzation config. Allow only tags that are allowed in the Tool. * @returns - config that determines tags supposted by paste handler - * @todo - refactor and move to nested list instance + * @todo - refactor and move to list instance */ public static get pasteConfig(): PasteConfig { return { @@ -340,7 +340,7 @@ export default class ListTabulator { /** * On paste callback that is fired from Editor. * @param event - event with pasted data - * @todo - refactor and move to nested list instance + * @todo - refactor and move to list instance */ public onPaste(event: PasteEvent): void { const list = event.detail.data; @@ -358,7 +358,7 @@ export default class ListTabulator { /** * Handle UL, OL and LI tags paste and returns List data * @param element - html element that contains whole list - * @todo - refactor and move to nested list instance + * @todo - refactor and move to list instance */ public pasteHandler(element: PasteEvent['detail']['data']): ListData { const { tagName: tag } = element; diff --git a/src/index.ts b/src/index.ts index 19a80aee..412ade0a 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 type { NestedListConfig, ListData, ListDataStyle, ListItem, OldListData } from './types/ListParams'; +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'; @@ -22,14 +22,14 @@ import normalizeData from './utils/normalizeData'; import type { PasteEvent } from './types'; /** - * Constructor Params for Nested List Tool, use to pass initial data and settings + * Constructor Params for Editorjs List Tool, use to pass initial data and settings */ -export type ListParams = BlockToolConstructorOptions; +export type ListParams = BlockToolConstructorOptions; /** * Default class of the component used in editor */ -export default class NestedList { +export default class EditorjsList { /** * Notify core that read-only mode is supported */ @@ -101,11 +101,11 @@ export default class NestedList { * @param content - contents string * @returns - list data formed from contents string */ - import: (content: string, config: ToolConfig) => ListData; + import: (content: string, config: ToolConfig) => ListData; } { return { export: (data) => { - return NestedList.joinRecursive(data); + return EditorjsList.joinRecursive(data); }, import: (content, config) => { return { @@ -154,19 +154,19 @@ export default class NestedList { private api: API; /** - * Is NestedList Tool read-only + * Is Ediotrjs List Tool read-only */ private readOnly: boolean; /** * Tool's configuration */ - private config: NestedListConfig | undefined; + private config: ListConfig | undefined; /** * Default list style formes as passed default list style from config or 'ordered' as default */ - private defaultListStyle?: NestedListConfig['defaultStyle']; + private defaultListStyle?: ListConfig['defaultStyle']; /** * Tool's data @@ -231,7 +231,7 @@ export default class NestedList { */ private static joinRecursive(data: ListData | ListItem): string { return data.items - .map(item => `${item.content} ${NestedList.joinRecursive(item)}`) + .map(item => `${item.content} ${EditorjsList.joinRecursive(item)}`) .join(''); } @@ -356,7 +356,6 @@ export default class NestedList { /** * On paste callback that is fired from Editor. * @param event - event with pasted data - * @todo - refactor and move to nested list instance */ public onPaste(event: PasteEvent): void { const { tagName: tag } = event.detail.data; @@ -376,7 +375,6 @@ export default class NestedList { /** * Handle UL, OL and LI tags paste and returns List data * @param element - html element that contains whole list - * @todo - refactor and move to nested list instance */ public pasteHandler(element: PasteEvent['detail']['data']): ListData { const data = this.list!.pasteHandler(element); diff --git a/src/types/ListParams.ts b/src/types/ListParams.ts index 8d9fef5b..21470c1c 100644 --- a/src/types/ListParams.ts +++ b/src/types/ListParams.ts @@ -7,7 +7,7 @@ import type { OlCounterType } from './OlCounterType'; export type ListDataStyle = 'ordered' | 'unordered' | 'checklist'; /** - * Interface that represents data of the Nested List tool + * Interface that represents data of the List tool */ export interface ListData { /** @@ -89,7 +89,7 @@ export interface ListItem { /** * Tool's configuration */ -export interface NestedListConfig { +export interface ListConfig { /** * default list style: ordered or unordered * default is unordered diff --git a/src/utils/normalizeData.ts b/src/utils/normalizeData.ts index 51b2e0a1..e51abd28 100644 --- a/src/utils/normalizeData.ts +++ b/src/utils/normalizeData.ts @@ -2,7 +2,7 @@ import type { OldListData, ListData, ListItem, OldChecklistData } from '../types /** * Method that checks if data is result of the Old list tool save mtehod - * @param data - data of the OldList, Checklist or NestedList tool + * @param data - data of the OldList, Checklist or Editorjs List tool * @returns true if data related to the List tool, false otherwise */ function instanceOfOldListData(data: ListData | OldListData | OldChecklistData): data is OldListData { @@ -11,7 +11,7 @@ function instanceOfOldListData(data: ListData | OldListData | OldChecklistData): /** * Method that checks if data is result of the Old checklist tool save method - * @param data - data of the Checklist, OldList or NestedList tool + * @param data - data of the Checklist, OldList or Editorjs List tool * @returns true if data is related to the Checklist tool, false otherwise */ function instanceOfChecklistData(data: ListData | OldListData | OldChecklistData): data is OldChecklistData { @@ -27,7 +27,7 @@ function instanceOfChecklistData(data: ListData | OldListData | OldChecklistData /** * Method that checks if passed data is related to the legacy format and normalizes it * @param data - data to be checked - * @returns - normalized data, ready to be used by Nested List tool + * @returns - normalized data, ready to be used by Editorjs List tool */ export default function normalizeData(data: ListData | OldListData | OldChecklistData): ListData { const normalizedDataItems: ListItem[] = []; diff --git a/src/utils/renderToolboxInput.ts b/src/utils/renderToolboxInput.ts index 5669cbd0..e9bdd720 100644 --- a/src/utils/renderToolboxInput.ts +++ b/src/utils/renderToolboxInput.ts @@ -33,7 +33,7 @@ const css = { /** * Method that renders html element for popover start with item - * @param inputCallback - callback method that could change nested list attributes on input + * @param inputCallback - callback method that could change list attributes on input * @param inputOptions - options used in input rendering * @param inputOptions.value - input will be rendered with this value inside * @param inputOptions.placeholder - placeholder, that will be displayed in input diff --git a/vite.config.js b/vite.config.js index 65445a4a..a5835906 100644 --- a/vite.config.js +++ b/vite.config.js @@ -13,8 +13,8 @@ export default { lib: { // eslint-disable-next-line no-undef entry: path.resolve(__dirname, 'src', 'index.ts'), - name: 'NestedList', - fileName: 'nested-list', + name: 'EditorjsList', + fileName: 'editorjs-list', }, }, define: { From 12c13bc11b8453f960221782a972b63914e23942 Mon Sep 17 00:00:00 2001 From: e11sy <130844513+e11sy@users.noreply.github.com> Date: Wed, 6 Nov 2024 21:14:01 +0300 Subject: [PATCH 2/3] bump version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index aac973d2..4ede9a43 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@editorjs/list", - "version": "1.4.3", + "version": "2.0.0", "keywords": [ "codex editor", "list", From 40ad72f1e0ab75807097bfcd09652f87c56694c8 Mon Sep 17 00:00:00 2001 From: e11sy <130844513+e11sy@users.noreply.github.com> Date: Wed, 6 Nov 2024 21:18:51 +0300 Subject: [PATCH 3/3] typo --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4ede9a43..d9057c7d 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "editor.js", "editorjs" ], - "description": "Editorjs List Tool for EditorJS", + "description": "List Tool for EditorJS", "repository": "https://github.com/editor-js/list.git", "author": "CodeX ", "license": "MIT",